1 /* 2 * Copyright (C) 2022 The Android Open Source Project 3 * 4 * Licensed under the Apache License, Version 2.0 (the "License"); 5 * you may not use this file except in compliance with the License. 6 * You may obtain a copy of the License at 7 * 8 * http://www.apache.org/licenses/LICENSE-2.0 9 * 10 * Unless required by applicable law or agreed to in writing, software 11 * distributed under the License is distributed on an "AS IS" BASIS, 12 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 * See the License for the specific language governing permissions and 14 * limitations under the License. 15 */ 16 17 package com.android.settings.applications.manageapplications 18 19 import android.content.Context 20 import android.util.FeatureFlagUtils 21 import com.android.settings.Settings.AlarmsAndRemindersActivity 22 import com.android.settings.Settings.AppBatteryUsageActivity 23 import com.android.settings.Settings.UserAspectRatioAppListActivity 24 import com.android.settings.Settings.ChangeNfcTagAppsActivity 25 import com.android.settings.Settings.ChangeWifiStateActivity 26 import com.android.settings.Settings.ClonedAppsListActivity 27 import com.android.settings.Settings.GamesStorageActivity 28 import com.android.settings.Settings.HighPowerApplicationsActivity 29 import com.android.settings.Settings.LongBackgroundTasksActivity 30 import com.android.settings.Settings.ManageExternalSourcesActivity 31 import com.android.settings.Settings.ManageExternalStorageActivity 32 import com.android.settings.Settings.MediaManagementAppsActivity 33 import com.android.settings.Settings.NotificationAppListActivity 34 import com.android.settings.Settings.NotificationReviewPermissionsActivity 35 import com.android.settings.Settings.OverlaySettingsActivity 36 import com.android.settings.Settings.StorageUseActivity 37 import com.android.settings.Settings.TurnScreenOnSettingsActivity 38 import com.android.settings.Settings.UsageAccessSettingsActivity 39 import com.android.settings.Settings.WriteSettingsActivity 40 import com.android.settings.applications.appinfo.AppLocaleDetails 41 import com.android.settings.applications.manageapplications.ManageApplications.LIST_MANAGE_EXTERNAL_STORAGE 42 import com.android.settings.applications.manageapplications.ManageApplications.LIST_TYPE_ALARMS_AND_REMINDERS 43 import com.android.settings.applications.manageapplications.ManageApplications.LIST_TYPE_APPS_LOCALE 44 import com.android.settings.applications.manageapplications.ManageApplications.LIST_TYPE_USER_ASPECT_RATIO_APPS 45 import com.android.settings.applications.manageapplications.ManageApplications.LIST_TYPE_BATTERY_OPTIMIZATION 46 import com.android.settings.applications.manageapplications.ManageApplications.LIST_TYPE_CLONED_APPS 47 import com.android.settings.applications.manageapplications.ManageApplications.LIST_TYPE_GAMES 48 import com.android.settings.applications.manageapplications.ManageApplications.LIST_TYPE_HIGH_POWER 49 import com.android.settings.applications.manageapplications.ManageApplications.LIST_TYPE_LONG_BACKGROUND_TASKS 50 import com.android.settings.applications.manageapplications.ManageApplications.LIST_TYPE_MAIN 51 import com.android.settings.applications.manageapplications.ManageApplications.LIST_TYPE_MANAGE_SOURCES 52 import com.android.settings.applications.manageapplications.ManageApplications.LIST_TYPE_MEDIA_MANAGEMENT_APPS 53 import com.android.settings.applications.manageapplications.ManageApplications.LIST_TYPE_NFC_TAG_APPS 54 import com.android.settings.applications.manageapplications.ManageApplications.LIST_TYPE_NOTIFICATION 55 import com.android.settings.applications.manageapplications.ManageApplications.LIST_TYPE_OVERLAY 56 import com.android.settings.applications.manageapplications.ManageApplications.LIST_TYPE_STORAGE 57 import com.android.settings.applications.manageapplications.ManageApplications.LIST_TYPE_TURN_SCREEN_ON 58 import com.android.settings.applications.manageapplications.ManageApplications.LIST_TYPE_USAGE_ACCESS 59 import com.android.settings.applications.manageapplications.ManageApplications.LIST_TYPE_WIFI_ACCESS 60 import com.android.settings.applications.manageapplications.ManageApplications.LIST_TYPE_WRITE_SETTINGS 61 import com.android.settings.spa.app.AllAppListPageProvider 62 import com.android.settings.spa.app.battery.BatteryOptimizationModeAppListPageProvider 63 import com.android.settings.spa.app.appcompat.UserAspectRatioAppsPageProvider 64 import com.android.settings.spa.app.specialaccess.AlarmsAndRemindersAppListProvider 65 import com.android.settings.spa.app.specialaccess.AllFilesAccessAppListProvider 66 import com.android.settings.spa.app.specialaccess.DisplayOverOtherAppsAppListProvider 67 import com.android.settings.spa.app.specialaccess.InstallUnknownAppsListProvider 68 import com.android.settings.spa.app.specialaccess.LongBackgroundTasksAppListProvider 69 import com.android.settings.spa.app.specialaccess.MediaManagementAppsAppListProvider 70 import com.android.settings.spa.app.specialaccess.ModifySystemSettingsAppListProvider 71 import com.android.settings.spa.app.specialaccess.NfcTagAppsSettingsProvider 72 import com.android.settings.spa.app.specialaccess.TurnScreenOnAppsAppListProvider 73 import com.android.settings.spa.app.specialaccess.WifiControlAppListProvider 74 import com.android.settings.spa.notification.AppListNotificationsPageProvider 75 import com.android.settings.spa.system.AppLanguagesPageProvider 76 77 /** 78 * Utils for [ManageApplications]. 79 */ 80 object ManageApplicationsUtil { 81 private val LIST_TYPE_CLASS_MAP = mapOf( 82 StorageUseActivity::class to LIST_TYPE_STORAGE, 83 UsageAccessSettingsActivity::class to LIST_TYPE_USAGE_ACCESS, 84 HighPowerApplicationsActivity::class to LIST_TYPE_HIGH_POWER, 85 OverlaySettingsActivity::class to LIST_TYPE_OVERLAY, 86 WriteSettingsActivity::class to LIST_TYPE_WRITE_SETTINGS, 87 ManageExternalSourcesActivity::class to LIST_TYPE_MANAGE_SOURCES, 88 GamesStorageActivity::class to LIST_TYPE_GAMES, 89 ChangeWifiStateActivity::class to LIST_TYPE_WIFI_ACCESS, 90 ManageExternalStorageActivity::class to LIST_MANAGE_EXTERNAL_STORAGE, 91 MediaManagementAppsActivity::class to LIST_TYPE_MEDIA_MANAGEMENT_APPS, 92 AlarmsAndRemindersActivity::class to LIST_TYPE_ALARMS_AND_REMINDERS, 93 NotificationAppListActivity::class to LIST_TYPE_NOTIFICATION, 94 NotificationReviewPermissionsActivity::class to LIST_TYPE_NOTIFICATION, 95 AppLocaleDetails::class to LIST_TYPE_APPS_LOCALE, 96 AppBatteryUsageActivity::class to LIST_TYPE_BATTERY_OPTIMIZATION, 97 LongBackgroundTasksActivity::class to LIST_TYPE_LONG_BACKGROUND_TASKS, 98 ClonedAppsListActivity::class to LIST_TYPE_CLONED_APPS, 99 ChangeNfcTagAppsActivity::class to LIST_TYPE_NFC_TAG_APPS, 100 TurnScreenOnSettingsActivity::class to LIST_TYPE_TURN_SCREEN_ON, 101 UserAspectRatioAppListActivity::class to LIST_TYPE_USER_ASPECT_RATIO_APPS, 102 ) 103 104 @JvmField <lambda>null105 val LIST_TYPE_MAP = LIST_TYPE_CLASS_MAP.mapKeys { it.key.java.name } 106 107 @JvmStatic getSpaDestinationnull108 fun getSpaDestination(context: Context, listType: Int): String? { 109 if (!FeatureFlagUtils.isEnabled(context, FeatureFlagUtils.SETTINGS_ENABLE_SPA)) { 110 return null 111 } 112 return when (listType) { 113 LIST_TYPE_OVERLAY -> DisplayOverOtherAppsAppListProvider.getAppListRoute() 114 LIST_TYPE_WRITE_SETTINGS -> ModifySystemSettingsAppListProvider.getAppListRoute() 115 LIST_TYPE_MANAGE_SOURCES -> InstallUnknownAppsListProvider.getAppListRoute() 116 LIST_MANAGE_EXTERNAL_STORAGE -> AllFilesAccessAppListProvider.getAppListRoute() 117 LIST_TYPE_MEDIA_MANAGEMENT_APPS -> MediaManagementAppsAppListProvider.getAppListRoute() 118 LIST_TYPE_ALARMS_AND_REMINDERS -> AlarmsAndRemindersAppListProvider.getAppListRoute() 119 LIST_TYPE_WIFI_ACCESS -> WifiControlAppListProvider.getAppListRoute() 120 LIST_TYPE_NOTIFICATION -> AppListNotificationsPageProvider.name 121 LIST_TYPE_APPS_LOCALE -> AppLanguagesPageProvider.name 122 LIST_TYPE_MAIN -> AllAppListPageProvider.name 123 LIST_TYPE_NFC_TAG_APPS -> NfcTagAppsSettingsProvider.getAppListRoute() 124 LIST_TYPE_USER_ASPECT_RATIO_APPS -> UserAspectRatioAppsPageProvider.name 125 LIST_TYPE_LONG_BACKGROUND_TASKS -> LongBackgroundTasksAppListProvider.getAppListRoute() 126 LIST_TYPE_TURN_SCREEN_ON -> TurnScreenOnAppsAppListProvider.getAppListRoute() 127 // TODO(b/292165031) enable once sorting is supported 128 //LIST_TYPE_STORAGE -> StorageAppListPageProvider.Apps.name 129 //LIST_TYPE_GAMES -> StorageAppListPageProvider.Games.name 130 LIST_TYPE_BATTERY_OPTIMIZATION -> BatteryOptimizationModeAppListPageProvider.name 131 else -> null 132 } 133 } 134 } 135