From 97e198b096083c4f4d97a8fcf6b55434ba293bb3 Mon Sep 17 00:00:00 2001 From: Faye Yan Date: Fri, 26 Jan 2024 04:24:45 +0000 Subject: [PATCH] Revert "Add the second toggle for the egress data permission on voice activation" This reverts commit a0f67e8591259099d978ee22a356b3f53f0b1cf2. Reason for revert: Fedhot team cancel the egress data permission Change-Id: Ib740896b41dc3eea1d196eecaf0abe13eff842a4 --- res/values/strings.xml | 4 - .../app/specialaccess/VoiceActivationApps.kt | 90 ------------------- 2 files changed, 94 deletions(-) diff --git a/res/values/strings.xml b/res/values/strings.xml index 491d58fa6b8..6a8da6a4c74 100644 --- a/res/values/strings.xml +++ b/res/values/strings.xml @@ -9623,10 +9623,6 @@ Allow voice activation Voice activation turns-on approved apps, hands-free, using voice command. Built-in adaptive sensing ensures data stays private only to you.\n\nMore about protected adaptive sensing - - Improve voice activation - - This device uses private intelligence to improve the voice activation model. Apps can receive summarized updates that are aggregated across many users to maintain privacy while improving the model for everyone.\n\nMore about private intelligence Full screen notifications diff --git a/src/com/android/settings/spa/app/specialaccess/VoiceActivationApps.kt b/src/com/android/settings/spa/app/specialaccess/VoiceActivationApps.kt index a7f971418cd..12258068319 100644 --- a/src/com/android/settings/spa/app/specialaccess/VoiceActivationApps.kt +++ b/src/com/android/settings/spa/app/specialaccess/VoiceActivationApps.kt @@ -20,24 +20,12 @@ import android.Manifest import android.app.AppOpsManager import android.app.settings.SettingsEnums import android.content.Context -import androidx.compose.runtime.Composable -import androidx.compose.runtime.LaunchedEffect -import androidx.compose.runtime.getValue -import androidx.compose.runtime.livedata.observeAsState -import androidx.compose.runtime.mutableStateOf -import androidx.compose.runtime.remember -import androidx.compose.runtime.setValue -import androidx.compose.ui.platform.LocalContext import com.android.settings.R import com.android.settings.overlay.FeatureFactory -import com.android.settingslib.spa.widget.preference.SwitchPreference -import com.android.settingslib.spa.widget.preference.SwitchPreferenceModel -import com.android.settingslib.spaprivileged.model.app.AppOpsController import com.android.settingslib.spaprivileged.model.app.PackageManagers.hasGrantPermission import com.android.settingslib.spaprivileged.template.app.AppOpPermissionListModel import com.android.settingslib.spaprivileged.template.app.AppOpPermissionRecord import com.android.settingslib.spaprivileged.template.app.TogglePermissionAppListProvider -import kotlinx.coroutines.Dispatchers /** * This class builds an App List under voice activation apps and the individual page which @@ -65,84 +53,6 @@ class VoiceActivationAppsListModel(context: Context) : AppOpPermissionListModel( override fun isChangeable(record: AppOpPermissionRecord): Boolean = super.isChangeable(record) && record.app.hasGrantPermission(permission) - @Composable - override fun InfoPageAdditionalContent( - record: AppOpPermissionRecord, - isAllowed: () -> Boolean?, - ) { - SwitchPreference(createReceiveDetectionTrainingDataOpSwitchModel(record, isAllowed)) - } - - @Composable - private fun createReceiveDetectionTrainingDataOpSwitchModel( - record: AppOpPermissionRecord, - isReceiveSandBoxTriggerAudioOpAllowed: () -> Boolean? - ): ReceiveDetectionTrainingDataOpSwitchModel { - val context = LocalContext.current - val ReceiveDetectionTrainingDataOpController = remember { - AppOpsController( - context = context, - app = record.app, - op = AppOpsManager.OP_RECEIVE_SANDBOXED_DETECTION_TRAINING_DATA, - ) - } - val isReceiveDetectionTrainingDataOpAllowed = isReceiveDetectionTrainingDataOpAllowed(record, ReceiveDetectionTrainingDataOpController) - return remember(record) { - ReceiveDetectionTrainingDataOpSwitchModel( - context, - record, - isReceiveSandBoxTriggerAudioOpAllowed, - ReceiveDetectionTrainingDataOpController, - isReceiveDetectionTrainingDataOpAllowed, - ) - }.also { model -> LaunchedEffect(model, Dispatchers.Default) { model.initState() } } - } - - private inner class ReceiveDetectionTrainingDataOpSwitchModel( - context: Context, - private val record: AppOpPermissionRecord, - isReceiveSandBoxTriggerAudioOpAllowed: () -> Boolean?, - receiveDetectionTrainingDataOpController: AppOpsController, - isReceiveDetectionTrainingDataOpAllowed: () -> Boolean?, - ) : SwitchPreferenceModel { - private var appChangeable by mutableStateOf(true) - - override val title: String = context.getString(R.string.permit_receive_sandboxed_detection_training_data) - override val summary: () -> String = { context.getString(R.string.receive_sandboxed_detection_training_data_description) } - override val checked = { isReceiveDetectionTrainingDataOpAllowed() == true && isReceiveSandBoxTriggerAudioOpAllowed() == true } - override val changeable = { appChangeable && isReceiveSandBoxTriggerAudioOpAllowed() == true } - - fun initState() { - appChangeable = isChangeable(record) - } - - override val onCheckedChange: (Boolean) -> Unit = { newChecked -> - receiveDetectionTrainingDataOpController.setAllowed(newChecked) - } - } - - @Composable - private fun isReceiveDetectionTrainingDataOpAllowed( - record: AppOpPermissionRecord, - controller: AppOpsController - ): () -> Boolean? { - if (record.hasRequestBroaderPermission) { - // Broader permission trumps the specific permission. - return { true } - } - - val mode = controller.mode.observeAsState() - return { - when (mode.value) { - null -> null - AppOpsManager.MODE_ALLOWED -> true - AppOpsManager.MODE_DEFAULT -> record.app.hasGrantPermission( - Manifest.permission.RECEIVE_SANDBOXED_DETECTION_TRAINING_DATA) - else -> false - } - } - } - private fun logPermissionChange(newAllowed: Boolean) { val category = when { newAllowed -> SettingsEnums.APP_SPECIAL_PERMISSION_RECEIVE_SANDBOX_TRIGGER_AUDIO_ALLOW