From 563f61618ea033a2e8d70d5a385e936e50cc1f04 Mon Sep 17 00:00:00 2001 From: lvxiaoqiang Date: Tue, 27 Dec 2022 18:44:44 +0800 Subject: [PATCH] modify camera async api to sync api Signed-off-by: lvxiaoqiang --- .../src/main/ets/common/components/dialog.ets | 9 ++++----- .../main/ets/pages/authority-management.ets | 11 +++++------ .../ets/pages/authority-tertiary-groups.ets | 7 +++---- .../src/main/ets/pages/globalSwitch.ets | 18 ++++++++---------- 4 files changed, 20 insertions(+), 25 deletions(-) diff --git a/permissionmanager/src/main/ets/common/components/dialog.ets b/permissionmanager/src/main/ets/common/components/dialog.ets index a8faa39..7403ebe 100644 --- a/permissionmanager/src/main/ets/common/components/dialog.ets +++ b/permissionmanager/src/main/ets/common/components/dialog.ets @@ -110,11 +110,10 @@ export struct globalDialog { confirm() { if(globalThis.currentPermissionGroup == 'CAMERA') { - camera.getCameraManager(globalThis.context).then(cameraManager => { - cameraManager.muteCamera(true) - this.globalIsOn = false - this.controller.close() - }) + let cameraManager = camera.getCameraManager(globalThis.context); + cameraManager.muteCamera(true); + this.globalIsOn = false; + this.controller.close(); }else { var audioManager = audio.getAudioManager(); audioManager.setMicrophoneMute(true).then(() => { diff --git a/permissionmanager/src/main/ets/pages/authority-management.ets b/permissionmanager/src/main/ets/pages/authority-management.ets index 3e9f8ad..555bb88 100644 --- a/permissionmanager/src/main/ets/pages/authority-management.ets +++ b/permissionmanager/src/main/ets/pages/authority-management.ets @@ -123,12 +123,11 @@ struct authorityManagementPage { }) }) }else { - camera.getCameraManager(globalThis.context).then(cameraManager => { - let mute = cameraManager.isCameraMuted() - router.push({ - uri: 'pages/authority-tertiary-groups', - params: { routerData: dataList, backTitle: item.groupName, globalIsOn: !mute } - }) + let cameraManager = camera.getCameraManager(globalThis.context); + let mute = cameraManager.isCameraMuted() + router.push({ + uri: 'pages/authority-tertiary-groups', + params: { routerData: dataList, backTitle: item.groupName, globalIsOn: !mute } }) } } diff --git a/permissionmanager/src/main/ets/pages/authority-tertiary-groups.ets b/permissionmanager/src/main/ets/pages/authority-tertiary-groups.ets index 7650f1d..6061dea 100644 --- a/permissionmanager/src/main/ets/pages/authority-tertiary-groups.ets +++ b/permissionmanager/src/main/ets/pages/authority-tertiary-groups.ets @@ -457,10 +457,9 @@ struct applicationItem { .onChange((isOn: boolean) => { if(isOn) { if(globalThis.currentPermissionGroup == "CAMERA") { - camera.getCameraManager(globalThis.context).then(cameraManager => { - cameraManager.muteCamera(false) - this.globalIsOn = isOn - }) + let cameraManager = camera.getCameraManager(globalThis.context); + cameraManager.muteCamera(false); + this.globalIsOn = isOn; }else { var audioManager = audio.getAudioManager(); audioManager.setMicrophoneMute(false).then(() => { diff --git a/permissionmanager/src/main/ets/pages/globalSwitch.ets b/permissionmanager/src/main/ets/pages/globalSwitch.ets index 4587ab2..23439f2 100644 --- a/permissionmanager/src/main/ets/pages/globalSwitch.ets +++ b/permissionmanager/src/main/ets/pages/globalSwitch.ets @@ -113,17 +113,15 @@ struct globalDialog { globalThis.globalContext.terminateSelf() }) }else if(globalThis.globalState == CAMERA) { - camera.getCameraManager(globalThis.globalContext).then(cameraManager => { - cameraManager.muteCamera(false) - globalThis.globalContext.terminateSelf() - }) + let cameraManager = camera.getCameraManager(globalThis.globalContext); + cameraManager.muteCamera(false); + globalThis.globalContext.terminateSelf(); }else { - camera.getCameraManager(globalThis.globalContext).then(cameraManager => { - cameraManager.muteCamera(false) - var audioManager = audio.getAudioManager(); - audioManager.setMicrophoneMute(false).then(() => { - globalThis.globalContext.terminateSelf() - }) + let cameraManager = camera.getCameraManager(globalThis.globalContext); + cameraManager.muteCamera(false) + var audioManager = audio.getAudioManager(); + audioManager.setMicrophoneMute(false).then(() => { + globalThis.globalContext.terminateSelf() }) } -- Gitee