[Service][TV] Add TV productinfo webapis 62/243762/5
authorDongHyun Song <dh81.song@samsung.com>
Thu, 10 Sep 2020 00:36:51 +0000 (09:36 +0900)
committerDongHyun Song <dh81.song@samsung.com>
Mon, 28 Sep 2020 09:23:50 +0000 (09:23 +0000)
Add webapis.productinfo of TV profile.

Related chromium-efl patch:
  https://review.tizen.org/gerrit/238981/

Change-Id: I1c865e7d0b2f2708f09e4de504a52836585c7090
Signed-off-by: DongHyun Song <dh81.song@samsung.com>
wrt_app/service/device_api_router.ts

index b7a6e0f..42a57f3 100644 (file)
@@ -50,6 +50,44 @@ export class DeviceAPIRouter {
     global.webapis.getPackageId = () => {
       return this.packageId;
     }
+    this.initProductWebapis();
+  }
+
+  initProductWebapis() {
+    // for TV profile
+    if (wrt.tv && !global.webapis.productinfo) {
+      global.webapis.cachedProperty = global.webapis.cachedProperty ?? {};
+      let getCachedValue = (name: string) => {
+        if (global.webapis.cachedProperty[name]) {
+          return global.webapis.cachedProperty[name];
+        }
+        let tv = wrt.tv as NativeWRTjs.TVExtension;
+        return (global.webapis.cachedProperty[name] = tv.queryProductValue(name));
+      }
+      global.webapis.productinfo = {
+        getDuid: () => {
+          return getCachedValue('getDuid');
+        },
+        getFirmware: () => {
+          return getCachedValue('getFirmware');
+        },
+        getLocalSet: () => {
+          return getCachedValue('getLocalSet');
+        },
+        getModel: () => {
+          return getCachedValue('getModel');
+        },
+        getModelCode: () => {
+          return getCachedValue('getModelCode');
+        },
+        getRealModel: () => {
+          return getCachedValue('getRealModel');
+        },
+        getSmartTVServerVersion: () => {
+          return getCachedValue('getSmartTVServerVersion');
+        }
+      };
+    }
   }
 
   initAccessControlManager() {