From 78f99c6a67079eda69b6eb569ad39f16bf3717eb Mon Sep 17 00:00:00 2001 From: Faye Yan Date: Wed, 17 Jan 2024 22:44:42 +0000 Subject: [PATCH] Fix the op mode dependency for the second toggle: If OP_RECEIVE_SANDBOX_TRIGGER_AUDIO is toggled to deny, OP_RECEIVE_SANDBOXED_DETECTION_TRAINING_DATA is set to deny and toggled. If OP_RECEIVE_SANDBOX_TRIGGER_AUDIO is toggled to allow, OP_RECEIVE_SANDBOXED_DETECTION_TRAINNING_DATA is unchanged. Bug: 309677007 Test: presubmit Change-Id: I83bbfdb71ad1aa0e29c55275948ec88fc7f83c6a --- .../spa/app/specialaccess/VoiceActivationApps.kt | 12 ++++++++---- 1 file changed, 8 insertions(+), 4 deletions(-) diff --git a/src/com/android/settings/spa/app/specialaccess/VoiceActivationApps.kt b/src/com/android/settings/spa/app/specialaccess/VoiceActivationApps.kt index a7f971418cd..aafe49382db 100644 --- a/src/com/android/settings/spa/app/specialaccess/VoiceActivationApps.kt +++ b/src/com/android/settings/spa/app/specialaccess/VoiceActivationApps.kt @@ -56,9 +56,12 @@ class VoiceActivationAppsListModel(context: Context) : AppOpPermissionListModel( override val appOp = AppOpsManager.OP_RECEIVE_SANDBOX_TRIGGER_AUDIO override val permission = Manifest.permission.RECEIVE_SANDBOX_TRIGGER_AUDIO override val setModeByUid = true - + private var receiveDetectionTrainingDataOpController:AppOpsController? = null override fun setAllowed(record: AppOpPermissionRecord, newAllowed: Boolean) { super.setAllowed(record, newAllowed) + if (!newAllowed && receiveDetectionTrainingDataOpController != null) { + receiveDetectionTrainingDataOpController!!.setAllowed(false) + } logPermissionChange(newAllowed) } @@ -79,20 +82,21 @@ class VoiceActivationAppsListModel(context: Context) : AppOpPermissionListModel( isReceiveSandBoxTriggerAudioOpAllowed: () -> Boolean? ): ReceiveDetectionTrainingDataOpSwitchModel { val context = LocalContext.current - val ReceiveDetectionTrainingDataOpController = remember { + receiveDetectionTrainingDataOpController = remember { AppOpsController( context = context, app = record.app, op = AppOpsManager.OP_RECEIVE_SANDBOXED_DETECTION_TRAINING_DATA, ) } - val isReceiveDetectionTrainingDataOpAllowed = isReceiveDetectionTrainingDataOpAllowed(record, ReceiveDetectionTrainingDataOpController) + val isReceiveDetectionTrainingDataOpAllowed = isReceiveDetectionTrainingDataOpAllowed(record, receiveDetectionTrainingDataOpController!!) + return remember(record) { ReceiveDetectionTrainingDataOpSwitchModel( context, record, isReceiveSandBoxTriggerAudioOpAllowed, - ReceiveDetectionTrainingDataOpController, + receiveDetectionTrainingDataOpController!!, isReceiveDetectionTrainingDataOpAllowed, ) }.also { model -> LaunchedEffect(model, Dispatchers.Default) { model.initState() } }