TV MAC ADDRESS 요청 루나 API 함수 추가

This commit is contained in:
dongyoungKo
2025-04-18 15:46:44 +09:00
parent 3eca5e4486
commit a6799503b8
5 changed files with 58 additions and 13 deletions

View File

@@ -1,10 +1,4 @@
import React, {
useCallback,
useEffect,
useMemo,
useRef,
useState,
} from "react";
import React, { useCallback, useEffect, useRef } from "react";
import { useDispatch, useSelector } from "react-redux";
@@ -14,7 +8,6 @@ import ThemeDecorator from "@enact/sandstone/ThemeDecorator";
import Spotlight from "@enact/spotlight";
import appinfo from "../../webos-meta/appinfo.json";
import { types } from "../actions/actionTypes";
import {
changeAppStatus,
checkFirstLaunch,
@@ -28,19 +21,16 @@ import {
setGNBMenu,
setSecondLayerInfo,
} from "../actions/commonActions";
import { getConnectionInfo } from "../actions/deviceActions";
import { getShoptimeTerms } from "../actions/empActions";
import { getHomeMenu, getHomeTerms } from "../actions/homeActions";
import {
getMyRecommandedKeyword,
getMyUpcomingAlertShow,
setMyTermsWithdraw,
} from "../actions/myPageActions";
import { pushPanel } from "../actions/panelActions";
import { countryCode, ricCode } from "../api/apiConfig";
import NotSupportedVersion from "../components/NotSupportedVersion/NotSupportedVersion";
import TPopUp from "../components/TPopUp/TPopUp";
import usePrevious from "../hooks/usePrevious";
import { checkValidCountry } from "../lunaSend/common";
import { lunaTest } from "../lunaSend/lunaTest";
import { store } from "../store/store";
import * as Config from "../utils/Config";
@@ -134,6 +124,7 @@ function AppBase(props) {
const oldDb8Deleted = useSelector(
(state) => state.localSettings.oldDb8Deleted
);
const macAddress = useSelector((state) => state.device);
const deviceCountryCode = httpHeader?.["X-Device-Country"] || "";
@@ -275,7 +266,10 @@ function AppBase(props) {
dispatch(getDeviceId());
dispatch(getHttpHeaderForServiceRequest());
dispatch(getSystemSettings());
// dispatch(getSystemInfo());
if (window.webOSSystem) {
dispatch(getConnectionInfo());
}
document.addEventListener("visibilitychange", visibilityChanged);
document.addEventListener("webOSRelaunch", handleRelaunchEvent);
//local virtual cursorvisiblilty
@@ -380,6 +374,12 @@ function AppBase(props) {
);
}, [dispatch]);
useEffect(() => {
if (macAddress) {
console.log("#macAddress", macAddress);
}
}, [macAddress]);
return (
<ErrorBoundary>
{webOSVersion === "" ? null : Number(webOSVersion) < 4 ? (

View File

@@ -10,6 +10,7 @@ export const types = {
REGISTER_DEVICE: "REGISTER_DEVICE",
REGISTER_DEVICE_INFO: "REGISTER_DEVICE_INFO",
GET_DEVICE_INFO: "GET_DEVICE_INFO",
GET_DEVICE_MACADDRESS: "GET_DEVICE_ADDRESS",
CLEAR_REGISTER_DEVICE_INFO: "CLEAR_REGISTER_DEVICE_INFO",
// common actions

View File

@@ -1,5 +1,6 @@
import { URLS } from "../api/apiConfig";
import { runDelayedAction, setTokenRefreshing, TAxios } from "../api/TAxios";
import * as lunaSend from "../lunaSend";
import { types } from "./actionTypes";
import { changeLocalSettings } from "./commonActions";
@@ -152,6 +153,25 @@ export const getReAuthenticationCode = () => (dispatch, getState) => {
);
};
// macAddress
export const getConnectionInfo = () => (dispatch, getState) => {
lunaSend.getConnectionInfo({
onSuccess: (res) => {
if (res && res.retrunValue) {
console.log("getConnentionInfo", res);
const macAddress = res?.wiredInfo.macAddress;
dispatch({
type: types.GET_DEVICE_MACADDRESS,
payload: macAddress,
});
}
},
onFailure: (err) => {
console.log("getConnentionInfo", err);
},
});
};
export const clearRegisterDeviceInfo = () => ({
type: types.CLEAR_REGISTER_DEVICE_INFO,
});

View File

@@ -420,3 +420,20 @@ export const enableNotification = ({ onSuccess, onFailure, onComplete }) => {
onComplete,
});
};
export const getConnectionInfo = ({ onSuccess, onFailure, onComplete }) => {
if (process.env.REACT_APP_MODE === "DEBUG") {
console.log("LUNA SEND getConnectionInfo");
return "Some Hard Coded Mock Data";
} else {
return new LS2Request().send({
service: "luna://com.webos.service.connectionmanager",
method: "getinfo",
subscribe: false,
parameters: {},
onSuccess,
onFailure,
onComplete,
});
}
};

View File

@@ -1,6 +1,7 @@
import { types } from "../actions/actionTypes";
const initialState = {
macAddress: { wifi: "", wired: "", p2p: "" },
regDeviceData: {},
regDeviceInfoData: {},
};
@@ -22,11 +23,17 @@ export const deviceReducer = (state = initialState, action) => {
...state,
deviceInfo: action.payload.data.dvcInfo,
};
case types.GET_DEVICE_MACADDRESS:
return {
...state,
macAddress: action,
};
case types.CLEAR_REGISTER_DEVICE_INFO:
return {
...state,
regDeviceInfoData: { retCode: undefined },
};
default:
return state;
}