Remove RUN_BACKUP_JOBS special app access page.

Bug: 333624438
Test: visual
Change-Id: Ib01bd6556768a943ae7fae013c6ccb82b1b96697
This commit is contained in:
Varun Shah
2024-04-15 23:58:44 +00:00
parent 02f1db61d8
commit 321e08e538
11 changed files with 0 additions and 283 deletions

View File

@@ -970,39 +970,6 @@
android:value="@string/menu_key_apps"/>
</activity>
<activity-alias
android:name="BackupTasksActivity"
android:knownActivityEmbeddingCerts="@array/config_known_host_certs"
android:exported="true"
android:targetActivity=".spa.SpaBridgeActivity"
android:label="@string/run_backup_tasks_title">
<intent-filter android:priority="1">
<action android:name="android.settings.REQUEST_RUN_BACKUP_JOBS" />
<category android:name="android.intent.category.DEFAULT" />
</intent-filter>
<meta-data android:name="com.android.settings.spa.DESTINATION"
android:value="TogglePermissionAppList/BackupTasksApps"/>
<meta-data android:name="com.android.settings.HIGHLIGHT_MENU_KEY"
android:value="@string/menu_key_apps"/>
</activity-alias>
<activity-alias
android:name="AppBackupTasksActivity"
android:knownActivityEmbeddingCerts="@array/config_known_host_certs"
android:exported="true"
android:targetActivity=".spa.SpaAppBridgeActivity"
android:label="@string/run_backup_tasks_title">
<intent-filter android:priority="1">
<action android:name="android.settings.REQUEST_RUN_BACKUP_JOBS" />
<category android:name="android.intent.category.DEFAULT" />
<data android:scheme="package" />
</intent-filter>
<meta-data android:name="com.android.settings.spa.DESTINATION"
android:value="TogglePermissionAppInfoPage/BackupTasksApps"/>
<meta-data android:name="com.android.settings.HIGHLIGHT_MENU_KEY"
android:value="@string/menu_key_apps"/>
</activity-alias>
<activity
android:name="Settings$DateTimeSettingsActivity"
android:label="@string/date_and_time"

View File

@@ -10422,21 +10422,6 @@
<!-- Keywords for settings screen for controlling apps that can run long background tasks [CHAR LIMIT=NONE] -->
<string name="keywords_long_background_tasks">long jobs, data transfer, background tasks</string>
<!-- Title for the settings screen for controlling apps that hold the run backup jobs permission [CHAR LIMIT=60] -->
<string name="run_backup_tasks_title">Perform backup tasks in background</string>
<!-- Label for the switch to toggle the run backup jobs permission [CHAR LIMIT=100] -->
<string name="run_backup_tasks_switch_title">Allow app to run backup-related background tasks</string>
<!-- Description that appears below the run_backup_tasks switch [CHAR LIMIT=NONE] -->
<string name="run_backup_tasks_footer_title">
Indicates that this app has a major use-case where it needs to backup or sync content.
Granting this permission allows the app to run in the background for a slightly longer time
in order to complete the backup-related work.
\n\nIf this permission is denied, the system will not give any special exemption to this
app to complete backup-related work in the background.
</string>
<!-- Keywords for settings screen for controlling apps that hold the run backup tasks permission [CHAR LIMIT=NONE] -->
<string name="keywords_run_backup_tasks">backup tasks, backup jobs</string>
<!-- Reset rate-limiting in the system service ShortcutManager. "ShortcutManager" is the name of a system service and not translatable.
If the word "rate-limit" is hard to translate, use "Reset ShortcutManager API call limit" as the source text, which means
the same thing in this context.

View File

@@ -19,16 +19,6 @@
xmlns:settings="http://schemas.android.com/apk/res-auto"
android:title="@string/special_access">
<Preference
android:key="run_backup_tasks"
android:title="@string/run_backup_tasks_title"
android:order="-2000"
settings:isPreferenceVisible="false"
settings:searchable="false"
settings:keywords="@string/keywords_run_backup_tasks"
settings:controller="com.android.settings.spa.app.specialaccess.BackupTasksAppsPreferenceController">
</Preference>
<Preference
android:key="manage_external_storage"
android:title="@string/manage_external_storage_title"

View File

@@ -31,7 +31,6 @@ import com.android.settings.spa.SpaActivity.Companion.startSpaActivity
import com.android.settings.spa.SpaAppBridgeActivity.Companion.getDestinationForApp
import com.android.settings.spa.app.specialaccess.AlarmsAndRemindersAppListProvider
import com.android.settings.spa.app.specialaccess.AllFilesAccessAppListProvider
import com.android.settings.spa.app.specialaccess.BackupTasksAppsListProvider
import com.android.settings.spa.app.specialaccess.DisplayOverOtherAppsAppListProvider
import com.android.settings.spa.app.specialaccess.InstallUnknownAppsListProvider
import com.android.settings.spa.app.specialaccess.MediaManagementAppsAppListProvider
@@ -66,8 +65,6 @@ object SettingsActivityUtil {
WifiControlAppListProvider.getAppInfoRoutePrefix(),
NfcTagAppsSettingsProvider::class.qualifiedName to
NfcTagAppsSettingsProvider.getAppInfoRoutePrefix(),
BackupTasksAppsListProvider::class.qualifiedName to
BackupTasksAppsListProvider.getAppInfoRoutePrefix(),
)
@JvmStatic

View File

@@ -29,7 +29,6 @@ import com.android.settings.spa.app.backgroundinstall.BackgroundInstalledAppsPag
import com.android.settings.spa.app.battery.BatteryOptimizationModeAppListPageProvider
import com.android.settings.spa.app.specialaccess.AlarmsAndRemindersAppListProvider
import com.android.settings.spa.app.specialaccess.AllFilesAccessAppListProvider
import com.android.settings.spa.app.specialaccess.BackupTasksAppsListProvider
import com.android.settings.spa.app.specialaccess.DisplayOverOtherAppsAppListProvider
import com.android.settings.spa.app.specialaccess.InstallUnknownAppsListProvider
import com.android.settings.spa.app.specialaccess.LongBackgroundTasksAppListProvider
@@ -79,7 +78,6 @@ open class SettingsSpaEnvironment(context: Context) : SpaEnvironment(context) {
NfcTagAppsSettingsProvider,
LongBackgroundTasksAppListProvider,
TurnScreenOnAppsAppListProvider,
BackupTasksAppsListProvider,
)
}

View File

@@ -38,7 +38,6 @@ import com.android.settings.flags.Flags
import com.android.settings.spa.SpaActivity.Companion.startSpaActivity
import com.android.settings.spa.app.appcompat.UserAspectRatioAppPreference
import com.android.settings.spa.app.specialaccess.AlarmsAndRemindersAppListProvider
import com.android.settings.spa.app.specialaccess.BackupTasksAppsListProvider
import com.android.settings.spa.app.specialaccess.DisplayOverOtherAppsAppListProvider
import com.android.settings.spa.app.specialaccess.InstallUnknownAppsListProvider
import com.android.settings.spa.app.specialaccess.ModifySystemSettingsAppListProvider
@@ -166,9 +165,6 @@ private fun AppInfoSettings(packageInfoPresenter: PackageInfoPresenter) {
InstallUnknownAppsListProvider.InfoPageEntryItem(app)
InteractAcrossProfilesDetailsPreference(app)
AlarmsAndRemindersAppListProvider.InfoPageEntryItem(app)
if (Flags.enablePerformBackupTasksInSettings()) {
BackupTasksAppsListProvider.InfoPageEntryItem(app)
}
}
Category(title = stringResource(R.string.app_install_details_group_title)) {

View File

@@ -1,54 +0,0 @@
/*
* Copyright (C) 2024 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.Companion.featureFactory
import com.android.settingslib.spaprivileged.template.app.AppOpPermissionListModel
import com.android.settingslib.spaprivileged.template.app.AppOpPermissionRecord
import com.android.settingslib.spaprivileged.template.app.TogglePermissionAppListProvider
object BackupTasksAppsListProvider : TogglePermissionAppListProvider {
override val permissionType = "BackupTasksApps"
override fun createModel(context: Context) = BackupTasksAppsListModel(context)
}
class BackupTasksAppsListModel(context: Context) : AppOpPermissionListModel(context) {
override val pageTitleResId = R.string.run_backup_tasks_title
override val switchTitleResId = R.string.run_backup_tasks_switch_title
override val footerResId = R.string.run_backup_tasks_footer_title
override val appOp = AppOpsManager.OP_RUN_BACKUP_JOBS
override val permission = Manifest.permission.RUN_BACKUP_JOBS
override val setModeByUid = true
override fun setAllowed(record: AppOpPermissionRecord, newAllowed: Boolean) {
super.setAllowed(record, newAllowed)
logPermissionChange(newAllowed)
}
private fun logPermissionChange(newAllowed: Boolean) {
featureFactory.metricsFeatureProvider.action(
context,
SettingsEnums.ACTION_RUN_BACKUP_TASKS_TOGGLE,
if (newAllowed) 1 else 0
)
}
}

View File

@@ -1,35 +0,0 @@
/*
* Copyright (C) 2024 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.spa.SpaActivity.Companion.startSpaActivity
class BackupTasksAppsPreferenceController(context: Context, preferenceKey: String) :
BasePreferenceController(context, preferenceKey) {
override fun getAvailabilityStatus() = CONDITIONALLY_UNAVAILABLE
override fun handlePreferenceTreeClick(preference: Preference): Boolean {
if (preference.key == mPreferenceKey) {
mContext.startSpaActivity(BackupTasksAppsListProvider.getAppListRoute())
return true
}
return false
}
}

View File

@@ -70,7 +70,6 @@ object SpecialAppAccessPageProvider : SettingsPageProvider {
WifiControlAppListProvider,
LongBackgroundTasksAppListProvider,
TurnScreenOnAppsAppListProvider,
BackupTasksAppsListProvider,
)
.map { it.buildAppListInjectEntry().setLink(fromPage = owner).build() }
}

View File

@@ -1,82 +0,0 @@
/*
* Copyright (C) 2024 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 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 BackupTasksAppsPreferenceControllerTest {
@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 = BackupTasksAppsPreferenceController(context, preferenceKey)
@Test
@RequiresFlagsEnabled(Flags.FLAG_ENABLE_PERFORM_BACKUP_TASKS_IN_SETTINGS)
fun getAvailabilityStatus_enableBackupTasksApps_returnAvailable() {
// Feature is currently disabled so it should return false regardless of flag status.
assertThat(controller.isAvailable).isFalse()
}
@Test
@RequiresFlagsDisabled(Flags.FLAG_ENABLE_PERFORM_BACKUP_TASKS_IN_SETTINGS)
fun getAvailableStatus_disableBackupTasksApps_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 = "backup_tasks_apps"
private const val testPreferenceKey: String = "test_key"
}
}

View File

@@ -1,44 +0,0 @@
/*
* Copyright (C) 2024 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.content.Context
import androidx.test.core.app.ApplicationProvider
import androidx.test.ext.junit.runners.AndroidJUnit4
import com.google.common.truth.Truth.assertThat
import com.android.settings.R
import org.junit.Test
import org.junit.runner.RunWith
@RunWith(AndroidJUnit4::class)
class BackupTasksAppsTest {
private val context: Context = ApplicationProvider.getApplicationContext()
private val listModel = BackupTasksAppsListModel(context)
@Test
fun modelResourceIdAndProperties() {
assertThat(listModel.pageTitleResId).isEqualTo(R.string.run_backup_tasks_title)
assertThat(listModel.switchTitleResId).isEqualTo(R.string.run_backup_tasks_switch_title)
assertThat(listModel.footerResId).isEqualTo(R.string.run_backup_tasks_footer_title)
assertThat(listModel.appOp).isEqualTo(AppOpsManager.OP_RUN_BACKUP_JOBS)
assertThat(listModel.permission).isEqualTo(Manifest.permission.RUN_BACKUP_JOBS)
assertThat(listModel.setModeByUid).isTrue()
}
}