Filter out apps that are not pre-granted with voice activation
permission for voice activation apps.
Bug: 306447565
Bug: 303727896
Bug: 309677303
Test: presubmit
Change-Id: Iecdfdb158029e139283233cbfbae7b405a916f24
diff --git a/src/com/android/settings/spa/app/specialaccess/VoiceActivationApps.kt b/src/com/android/settings/spa/app/specialaccess/VoiceActivationApps.kt
index de5f3b7..1225806 100644
--- a/src/com/android/settings/spa/app/specialaccess/VoiceActivationApps.kt
+++ b/src/com/android/settings/spa/app/specialaccess/VoiceActivationApps.kt
@@ -20,14 +20,18 @@
import android.app.AppOpsManager
import android.app.settings.SettingsEnums
import android.content.Context
-import android.content.res.Resources
import com.android.settings.R
import com.android.settings.overlay.FeatureFactory
+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
-
+/**
+ * This class builds an App List under voice activation apps and the individual page which
+ * allows the user to toggle voice activation related permissions on / off for the apps displayed
+ * in the list.
+ */
object VoiceActivationAppsListProvider : TogglePermissionAppListProvider {
override val permissionType = "VoiceActivationApps"
override fun createModel(context: Context) = VoiceActivationAppsListModel(context)
@@ -46,6 +50,9 @@
logPermissionChange(newAllowed)
}
+ override fun isChangeable(record: AppOpPermissionRecord): Boolean =
+ super.isChangeable(record) && record.app.hasGrantPermission(permission)
+
private fun logPermissionChange(newAllowed: Boolean) {
val category = when {
newAllowed -> SettingsEnums.APP_SPECIAL_PERMISSION_RECEIVE_SANDBOX_TRIGGER_AUDIO_ALLOW