Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit 34053734 authored by Faye Yan's avatar Faye Yan Committed by Android (Google) Code Review
Browse files

Merge "Fix the op mode dependency for the second toggle: If...

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
parents 77615e83 78f99c6a
Loading
Loading
Loading
Loading
+8 −4
Original line number Diff line number Diff line
@@ -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() } }