From d676fce4a1580c5d2b4185511664ec7b3ccaba90 Mon Sep 17 00:00:00 2001 From: zengpo Date: Mon, 11 Apr 2022 10:49:50 +0800 Subject: [PATCH 1/2] =?UTF-8?q?=E5=88=86=E5=B8=83=E5=BC=8F=E6=9D=83?= =?UTF-8?q?=E9=99=90=E4=BF=AE=E6=94=B9?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../OpenHarmonyPictureGame/entry/src/main/config.json | 5 +++++ .../entry/src/main/ets/MainAbility/pages/index.ets | 10 +++++++++- .../RemoteControllerETS/entry/src/main/config.json | 5 ++++- .../entry/src/main/ets/MainAbility/pages/TVIndex.ets | 8 ++++++++ 4 files changed, 26 insertions(+), 2 deletions(-) diff --git a/Distributed/OpenHarmonyPictureGame/entry/src/main/config.json b/Distributed/OpenHarmonyPictureGame/entry/src/main/config.json index 470bb607..4885531f 100644 --- a/Distributed/OpenHarmonyPictureGame/entry/src/main/config.json +++ b/Distributed/OpenHarmonyPictureGame/entry/src/main/config.json @@ -72,6 +72,11 @@ "autoDesignWidth": false } } + ], + "reqPermissions": [ + { + "name": "ohos.permission.DISTRIBUTED_DATASYNC" + } ] } } \ No newline at end of file diff --git a/Distributed/OpenHarmonyPictureGame/entry/src/main/ets/MainAbility/pages/index.ets b/Distributed/OpenHarmonyPictureGame/entry/src/main/ets/MainAbility/pages/index.ets index 11044822..47d995c8 100644 --- a/Distributed/OpenHarmonyPictureGame/entry/src/main/ets/MainAbility/pages/index.ets +++ b/Distributed/OpenHarmonyPictureGame/entry/src/main/ets/MainAbility/pages/index.ets @@ -17,7 +17,7 @@ import featureAbility from '@ohos.ability.featureAbility'; import prompt from '@system.prompt'; import rpc from "@ohos.rpc"; import commonEvent from '@ohos.commonEvent'; -import RemoteDeviceModel from '../../model/RemoteDeviceModel.ets'; +import RemoteDeviceModel from '../../model/RemoteDeviceModel'; var connectedAbility; @@ -245,6 +245,7 @@ struct PictureGame { async aboutToAppear() { let self = this; + self.grantPermission(); this.onRandom(); // 当被拉起时,通过want传递的参数同步对端界面UI await featureAbility.getWant((error, want) => { @@ -261,6 +262,13 @@ struct PictureGame { }); } + grantPermission(){ + let context = featureAbility.getContext(); + context.requestPermissionsFromUser(['ohos.permission.DISTRIBUTED_DATASYNC'],666,function(result){ + console.info('grantPermission,requestPermissionFromUser,result.requestCode= ${result.requestCode}') + }) + } + onRandom() { this.setupRandomPosition(); this.pictureList = [] diff --git a/Distributed/RemoteControllerETS/entry/src/main/config.json b/Distributed/RemoteControllerETS/entry/src/main/config.json index cd8bc695..e3e36cf3 100644 --- a/Distributed/RemoteControllerETS/entry/src/main/config.json +++ b/Distributed/RemoteControllerETS/entry/src/main/config.json @@ -100,6 +100,9 @@ "autoDesignWidth": false } } - ] + ], + "reqPermissions": [{ + "name": "ohos.permission.DISTRIBUTED_DATASYNC" + }] } } \ No newline at end of file diff --git a/Distributed/RemoteControllerETS/entry/src/main/ets/MainAbility/pages/TVIndex.ets b/Distributed/RemoteControllerETS/entry/src/main/ets/MainAbility/pages/TVIndex.ets index 9bf1ffaf..a1aba1fa 100644 --- a/Distributed/RemoteControllerETS/entry/src/main/ets/MainAbility/pages/TVIndex.ets +++ b/Distributed/RemoteControllerETS/entry/src/main/ets/MainAbility/pages/TVIndex.ets @@ -292,9 +292,17 @@ struct Index { } async aboutToAppear() { + this.grantPermission(); this.subscribeEvent(); } + grantPermission(){ + let context = featureAbility.getContext(); + context.requestPermissionsFromUser(['ohos.permission.DISTRIBUTED_DATASYNC'],666,function(result){ + console.info(`grantPermission,requestPermissionFromUser,result.requestCode= ${result.requestCode}`) + }) + } + subscribeEvent() { let self = this; // 用于保存创建成功的订阅者对象,后续使用其完成订阅及退订的动作 -- Gitee From be41e09d30babc00bce339cd2e71122ee8662a51 Mon Sep 17 00:00:00 2001 From: zengpo Date: Mon, 11 Apr 2022 10:52:45 +0800 Subject: [PATCH 2/2] =?UTF-8?q?=E5=88=86=E5=B8=83=E5=BC=8F=E7=89=88?= =?UTF-8?q?=E6=9C=AC=E4=BF=AE=E6=94=B9?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- Distributed/OpenHarmonyPictureGame/package.json | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/Distributed/OpenHarmonyPictureGame/package.json b/Distributed/OpenHarmonyPictureGame/package.json index eaf9d528..f2e02bd6 100644 --- a/Distributed/OpenHarmonyPictureGame/package.json +++ b/Distributed/OpenHarmonyPictureGame/package.json @@ -10,7 +10,7 @@ "repository": {}, "license": "ISC", "dependencies": { - "@ohos/hvigor": "1.0.4-rc", - "@ohos/hvigor-ohos-plugin": "1.0.4-rc" + "@ohos/hvigor": "1.0.6", + "@ohos/hvigor-ohos-plugin": "1.0.6" } } -- Gitee