Merge "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." into main

This commit is contained in:
Faye Yan
2024-01-18 09:11:01 +00:00
committed by Android (Google) Code Review

View File

@@ -56,9 +56,12 @@ class VoiceActivationAppsListModel(context: Context) : AppOpPermissionListModel(
override val appOp = AppOpsManager.OP_RECEIVE_SANDBOX_TRIGGER_AUDIO override val appOp = AppOpsManager.OP_RECEIVE_SANDBOX_TRIGGER_AUDIO
override val permission = Manifest.permission.RECEIVE_SANDBOX_TRIGGER_AUDIO override val permission = Manifest.permission.RECEIVE_SANDBOX_TRIGGER_AUDIO
override val setModeByUid = true override val setModeByUid = true
private var receiveDetectionTrainingDataOpController:AppOpsController? = null
override fun setAllowed(record: AppOpPermissionRecord, newAllowed: Boolean) { override fun setAllowed(record: AppOpPermissionRecord, newAllowed: Boolean) {
super.setAllowed(record, newAllowed) super.setAllowed(record, newAllowed)
if (!newAllowed && receiveDetectionTrainingDataOpController != null) {
receiveDetectionTrainingDataOpController!!.setAllowed(false)
}
logPermissionChange(newAllowed) logPermissionChange(newAllowed)
} }
@@ -79,20 +82,21 @@ class VoiceActivationAppsListModel(context: Context) : AppOpPermissionListModel(
isReceiveSandBoxTriggerAudioOpAllowed: () -> Boolean? isReceiveSandBoxTriggerAudioOpAllowed: () -> Boolean?
): ReceiveDetectionTrainingDataOpSwitchModel { ): ReceiveDetectionTrainingDataOpSwitchModel {
val context = LocalContext.current val context = LocalContext.current
val ReceiveDetectionTrainingDataOpController = remember { receiveDetectionTrainingDataOpController = remember {
AppOpsController( AppOpsController(
context = context, context = context,
app = record.app, app = record.app,
op = AppOpsManager.OP_RECEIVE_SANDBOXED_DETECTION_TRAINING_DATA, op = AppOpsManager.OP_RECEIVE_SANDBOXED_DETECTION_TRAINING_DATA,
) )
} }
val isReceiveDetectionTrainingDataOpAllowed = isReceiveDetectionTrainingDataOpAllowed(record, ReceiveDetectionTrainingDataOpController) val isReceiveDetectionTrainingDataOpAllowed = isReceiveDetectionTrainingDataOpAllowed(record, receiveDetectionTrainingDataOpController!!)
return remember(record) { return remember(record) {
ReceiveDetectionTrainingDataOpSwitchModel( ReceiveDetectionTrainingDataOpSwitchModel(
context, context,
record, record,
isReceiveSandBoxTriggerAudioOpAllowed, isReceiveSandBoxTriggerAudioOpAllowed,
ReceiveDetectionTrainingDataOpController, receiveDetectionTrainingDataOpController!!,
isReceiveDetectionTrainingDataOpAllowed, isReceiveDetectionTrainingDataOpAllowed,
) )
}.also { model -> LaunchedEffect(model, Dispatchers.Default) { model.initState() } } }.also { model -> LaunchedEffect(model, Dispatchers.Default) { model.initState() } }