Revert "Add Voice activation apps into Settings->Apps->Special a..."

Revert submission 25108596-va-special-access

Reason for revert: voice activation is not going in V

Reverted changes: /q/submissionid:25108596-va-special-access

Bug: 306447565
Bug: 393727896

Test: presubmit

Change-Id: I4977e7d543cb800fc9fb6962bba3afebb9480dcc
Merged-In: I4977e7d543cb800fc9fb6962bba3afebb9480dcc
This commit is contained in:
Faye Yan
2024-04-04 02:29:19 +00:00
committed by Chaohui Wang
parent f6b5904511
commit a7065f4d36
9 changed files with 0 additions and 218 deletions

View File

@@ -9703,13 +9703,6 @@
<!-- Label for showing apps that can manage external storage[CHAR LIMIT=45] -->
<string name="filter_manage_external_storage">Can access all files</string>
<!-- Voice Activation apps settings title [CHAR LIMIT=40] -->
<string name="voice_activation_apps_title">Voice activation apps</string>
<!-- Label for a setting which controls whether an app can be voice activated [CHAR LIMIT=NONE] -->
<string name="permit_voice_activation_apps">Allow voice activation</string>
<!-- Description for a setting which controls whether an app can be voice activated [CHAR LIMIT=NONE] -->
<string name ="allow_voice_activation_apps_description">Voice activation turns-on approved apps, hands-free, using voice command. Built-in adaptive sensing ensures data stays private only to you.\n\n<a href="">More about protected adaptive sensing</a></string>
<!-- Manage full screen intent permission title [CHAR LIMIT=40] -->
<string name="full_screen_intent_title">Full screen notifications</string>

View File

@@ -114,11 +114,6 @@
android:title="@string/full_screen_intent_title"
settings:controller="com.android.settings.spa.app.specialaccess.UseFullScreenIntentPreferenceController" />
<Preference
android:key="voice_activation_apps"
android:title="@string/voice_activation_apps_title"
settings:controller="com.android.settings.spa.app.specialaccess.VoiceActivationAppsPreferenceController" />
<Preference
android:key="picture_in_picture"
android:title="@string/picture_in_picture_title"

View File

@@ -38,7 +38,6 @@ import com.android.settings.spa.app.specialaccess.MediaManagementAppsAppListProv
import com.android.settings.spa.app.specialaccess.ModifySystemSettingsAppListProvider
import com.android.settings.spa.app.specialaccess.NfcTagAppsSettingsProvider
import com.android.settings.spa.app.specialaccess.PictureInPictureListProvider
import com.android.settings.spa.app.specialaccess.VoiceActivationAppsListProvider
import com.android.settings.spa.app.specialaccess.WifiControlAppListProvider
import com.android.settings.wifi.ChangeWifiStateDetails
@@ -67,8 +66,6 @@ object SettingsActivityUtil {
WifiControlAppListProvider.getAppInfoRoutePrefix(),
NfcTagAppsSettingsProvider::class.qualifiedName to
NfcTagAppsSettingsProvider.getAppInfoRoutePrefix(),
VoiceActivationAppsListProvider::class.qualifiedName to
VoiceActivationAppsListProvider.getAppInfoRoutePrefix(),
BackupTasksAppsListProvider::class.qualifiedName to
BackupTasksAppsListProvider.getAppInfoRoutePrefix(),
)

View File

@@ -41,7 +41,6 @@ import com.android.settings.spa.app.specialaccess.PictureInPictureListProvider
import com.android.settings.spa.app.specialaccess.SpecialAppAccessPageProvider
import com.android.settings.spa.app.specialaccess.TurnScreenOnAppsAppListProvider
import com.android.settings.spa.app.specialaccess.UseFullScreenIntentAppListProvider
import com.android.settings.spa.app.specialaccess.VoiceActivationAppsListProvider
import com.android.settings.spa.app.specialaccess.WifiControlAppListProvider
import com.android.settings.spa.app.storage.StorageAppListPageProvider
import com.android.settings.spa.core.instrumentation.SpaLogProvider
@@ -76,7 +75,6 @@ open class SettingsSpaEnvironment(context: Context) : SpaEnvironment(context) {
PictureInPictureListProvider,
InstallUnknownAppsListProvider,
AlarmsAndRemindersAppListProvider,
VoiceActivationAppsListProvider,
WifiControlAppListProvider,
NfcTagAppsSettingsProvider,
LongBackgroundTasksAppListProvider,

View File

@@ -67,7 +67,6 @@ object SpecialAppAccessPageProvider : SettingsPageProvider {
PictureInPictureListProvider,
InstallUnknownAppsListProvider,
AlarmsAndRemindersAppListProvider,
VoiceActivationAppsListProvider,
WifiControlAppListProvider,
LongBackgroundTasksAppListProvider,
TurnScreenOnAppsAppListProvider,

View File

@@ -1,67 +0,0 @@
/*
* Copyright (C) 2023 The Android Open Source Project
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package com.android.settings.spa.app.specialaccess
import android.Manifest
import android.app.AppOpsManager
import android.app.settings.SettingsEnums
import android.content.Context
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)
}
class VoiceActivationAppsListModel(context: Context) : AppOpPermissionListModel(context) {
override val pageTitleResId = R.string.voice_activation_apps_title
override val switchTitleResId = R.string.permit_voice_activation_apps
override val footerResId = R.string.allow_voice_activation_apps_description
override val appOp = AppOpsManager.OP_RECEIVE_SANDBOX_TRIGGER_AUDIO
override val permission = Manifest.permission.RECEIVE_SANDBOX_TRIGGER_AUDIO
override val setModeByUid = true
override fun setAllowed(record: AppOpPermissionRecord, newAllowed: Boolean) {
super.setAllowed(record, newAllowed)
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
else -> SettingsEnums.APP_SPECIAL_PERMISSION_RECEIVE_SANDBOX_TRIGGER_AUDIO_DENY
}
/**
* Leave the package string empty as we should not log the package names for the collected
* metrics.
*/
FeatureFactory.featureFactory.metricsFeatureProvider.action(context, category, "")
}
}

View File

@@ -1,38 +0,0 @@
/*
* Copyright (C) 2023 The Android Open Source Project
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package com.android.settings.spa.app.specialaccess
import android.content.Context
import androidx.preference.Preference
import com.android.settings.core.BasePreferenceController
import com.android.settings.flags.Flags
import com.android.settings.spa.SpaActivity.Companion.startSpaActivity
class VoiceActivationAppsPreferenceController(context: Context, preferenceKey: String) :
BasePreferenceController(context, preferenceKey) {
override fun getAvailabilityStatus() =
if (Flags.enableVoiceActivationAppsInSettings()) AVAILABLE
else CONDITIONALLY_UNAVAILABLE
override fun handlePreferenceTreeClick(preference: Preference): Boolean {
if (preference.key == mPreferenceKey) {
mContext.startSpaActivity(VoiceActivationAppsListProvider.getAppListRoute())
return true
}
return false
}
}

View File

@@ -1,65 +0,0 @@
package com.android.settings.spa.app.specialaccess
import android.content.Context
import android.platform.test.annotations.RequiresFlagsDisabled
import android.platform.test.annotations.RequiresFlagsEnabled
import android.platform.test.flag.junit.CheckFlagsRule
import android.platform.test.flag.junit.DeviceFlagsValueProvider
import androidx.preference.Preference
import androidx.test.core.app.ApplicationProvider
import androidx.test.ext.junit.runners.AndroidJUnit4
import com.android.settings.flags.Flags
import com.google.common.truth.Truth.assertThat
import org.junit.Rule
import org.junit.Test
import org.junit.runner.RunWith
import org.mockito.kotlin.any
import org.mockito.kotlin.doNothing
import org.mockito.kotlin.spy
import org.mockito.kotlin.whenever
@RunWith(AndroidJUnit4::class)
class VoiceActivationAppsPreferenceControllerTest {
@get:Rule
val checkFlagsRule: CheckFlagsRule = DeviceFlagsValueProvider.createCheckFlagsRule()
private val context: Context = spy(ApplicationProvider.getApplicationContext()) {
doNothing().whenever(mock).startActivity(any())
}
private val matchedPreference = Preference(context).apply { key = preferenceKey }
private val misMatchedPreference = Preference(context).apply { key = testPreferenceKey }
private val controller = VoiceActivationAppsPreferenceController(context, preferenceKey)
@Test
@RequiresFlagsEnabled(Flags.FLAG_ENABLE_VOICE_ACTIVATION_APPS_IN_SETTINGS)
fun getAvailabilityStatus_enableVoiceActivationApps_returnAvailable() {
assertThat(controller.isAvailable).isTrue()
}
@Test
@RequiresFlagsDisabled(Flags.FLAG_ENABLE_VOICE_ACTIVATION_APPS_IN_SETTINGS)
fun getAvailableStatus_disableVoiceActivationApps_returnConditionallyUnavailable() {
assertThat(controller.isAvailable).isFalse()
}
@Test
fun handlePreferenceTreeClick_keyMatched_returnTrue() {
assertThat(controller.handlePreferenceTreeClick(matchedPreference)).isTrue()
}
@Test
fun handlePreferenceTreeClick_keyMisMatched_returnFalse() {
assertThat(controller.handlePreferenceTreeClick(misMatchedPreference)).isFalse()
}
companion object {
private const val preferenceKey: String = "voice_activation_apps"
private const val testPreferenceKey: String = "test_key"
}
}

View File

@@ -1,30 +0,0 @@
package com.android.settings.spa.app.specialaccess
import android.Manifest
import android.app.AppOpsManager
import android.content.Context
import androidx.test.core.app.ApplicationProvider
import androidx.test.ext.junit.runners.AndroidJUnit4
import com.android.settings.R
import com.google.common.truth.Truth.assertThat
import org.junit.Test
import org.junit.runner.RunWith
@RunWith(AndroidJUnit4::class)
class VoiceActivationAppsTest {
private val context: Context = ApplicationProvider.getApplicationContext()
private val listModel = VoiceActivationAppsListModel(context)
@Test
fun modelResourceIdAndProperties() {
assertThat(listModel.pageTitleResId).isEqualTo(R.string.voice_activation_apps_title)
assertThat(listModel.switchTitleResId).isEqualTo(R.string.permit_voice_activation_apps)
assertThat(listModel.footerResId).isEqualTo(R.string.allow_voice_activation_apps_description)
assertThat(listModel.appOp).isEqualTo(AppOpsManager.OP_RECEIVE_SANDBOX_TRIGGER_AUDIO)
assertThat(listModel.permission).isEqualTo(
Manifest.permission.RECEIVE_SANDBOX_TRIGGER_AUDIO
)
assertThat(listModel.setModeByUid).isTrue()
}
}