diff --git a/permissionmanager/src/main/ets/pages/authority-tertiary-groups.ets b/permissionmanager/src/main/ets/pages/authority-tertiary-groups.ets index 85b370150d36064c10253b9140a528a7c71fba2a..208861b0704026665d91764b3623aad585ccb4a2 100644 --- a/permissionmanager/src/main/ets/pages/authority-tertiary-groups.ets +++ b/permissionmanager/src/main/ets/pages/authority-tertiary-groups.ets @@ -525,23 +525,27 @@ struct applicationItem { } globalListen() { - this.globalIsOn = globalIsOn; - if (this.currentGroup == 'CAMERA') { - cameraManager = camera.getCameraManager(this.context); - cameraManager.on('cameraMute', (err, curMuted) => { - Log.info('curMuted: ' + JSON.stringify(curMuted) + ' err: ' + JSON.stringify(err)); - this.globalIsOn = !curMuted; - }) - } else { - let audioManager = audio.getAudioManager(); - let audioVolumeManager = audioManager.getVolumeManager(); - let groupId = audio.DEFAULT_VOLUME_GROUP_ID; - audioVolumeGroupManager = audioVolumeManager.getVolumeGroupManagerSync(groupId); - audioVolumeGroupManager.on('micStateChange', micStateChange => { - let muteState = audioVolumeGroupManager.isPersistentMicMute(); - Log.info('micStateChange: ' + JSON.stringify(muteState)); - this.globalIsOn = !muteState; - }) + try { + this.globalIsOn = globalIsOn; + if (this.currentGroup === 'CAMERA') { + cameraManager = camera.getCameraManager(this.context); + cameraManager.on('cameraMute', (err, curMuted) => { + Log.info('curMuted: ' + curMuted + ' err: ' + JSON.stringify(err)); + this.globalIsOn = !curMuted; + }) + } else { + let audioManager = audio.getAudioManager(); + let audioVolumeManager = audioManager.getVolumeManager(); + let groupId = audio.DEFAULT_VOLUME_GROUP_ID; + audioVolumeGroupManager = audioVolumeManager.getVolumeGroupManagerSync(groupId); + audioVolumeGroupManager.on('micStateChange', micStateChange => { + let muteState = audioVolumeGroupManager.isPersistentMicMute(); + Log.info('micStateChange: ' + muteState); + this.globalIsOn = !muteState; + }) + } + } catch (error) { + Log.error(`Register listening failed, code: ${error.code}, message: ${error.message}.`); } }