Snap for 9085393 from 535667b5eb to udc-release
Change-Id: I0e4a0a976018364084b4e482c3f27621b8483b7f
This commit is contained in:
@@ -1314,7 +1314,7 @@
|
||||
|
||||
<activity
|
||||
android:name="Settings$DarkThemeSettingsActivity"
|
||||
android:label="@string/dark_ui_auto_mode_title"
|
||||
android:label="@string/dark_ui_mode"
|
||||
android:exported="true"
|
||||
android:enabled="true">
|
||||
<intent-filter android:priority="32">
|
||||
|
||||
File diff suppressed because it is too large
Load Diff
@@ -2435,6 +2435,8 @@
|
||||
<string name="screen_resolution_summary_highest">1440p QHD+</string>
|
||||
<!-- The footer message for switch screen resolution [CHAR LIMIT=NONE] -->
|
||||
<string name="screen_resolution_footer">Full resolution uses more of your battery. Switching your resolution may cause some apps to restart.</string>
|
||||
<!-- Message announced to a11y users when they selected one resolution [CHAR LIMIT=NONE] -->
|
||||
<string name="screen_resolution_selected_a11y">Selected</string>
|
||||
|
||||
<!-- Display settings screen, Color mode settings title [CHAR LIMIT=30] -->
|
||||
<string name="color_mode_title">Colors</string>
|
||||
@@ -2929,13 +2931,13 @@
|
||||
<!-- Title of a line item. Below this title, a user can tap a button to select this option if they want to use their SD card as extra device storage. [CHAR LIMIT=50] -->
|
||||
<string name="storage_wizard_init_v2_internal_title" product="tablet">Format SD card for internal storage</string>
|
||||
<!-- Subtext for a line item. Below this subtext, a user can tap a button to select this option if they want to use their SD card as extra device storage. [CHAR LIMIT=NONE] -->
|
||||
<string name="storage_wizard_init_v2_internal_summary" product="tablet">Store apps \u0026 media to use on this tablet only. <a href="https://support.google.com/android/answer/12153449">Learn more about setting up an SD card</a></string>
|
||||
<string name="storage_wizard_init_v2_internal_summary" product="tablet">Store apps \u0026 media to use on this tablet only. <a href="https://support.google.com/android/answer/12153449">Learn more about setting up an SD card</a>.</string>
|
||||
<!-- Button text. A user can tap this button if they want to use their SD card as extra device storage. [CHAR LIMIT=32] -->
|
||||
<string name="storage_wizard_init_v2_internal_action" product="tablet">Format</string>
|
||||
<!-- Title of a line item. Below this title, a user can tap a button to select this option if they want to use their SD card as extra device storage. [CHAR LIMIT=50] -->
|
||||
<string name="storage_wizard_init_v2_internal_title" product="default">Format SD card for internal storage</string>
|
||||
<!-- Subtext for a line item. Below this subtext, a user can tap a button to select this option if they want to use their SD card as extra device storage. [CHAR LIMIT=NONE] -->
|
||||
<string name="storage_wizard_init_v2_internal_summary" product="default">Store apps \u0026 media to use on this phone only. <a href="https://support.google.com/android/answer/12153449">Learn more about setting up an SD card</a></string>
|
||||
<string name="storage_wizard_init_v2_internal_summary" product="default">Store apps \u0026 media to use on this phone only. <a href="https://support.google.com/android/answer/12153449">Learn more about setting up an SD card</a>.</string>
|
||||
<!-- Button text. A user can tap this button if they want to use their SD card as extra device storage. [CHAR LIMIT=32] -->
|
||||
<string name="storage_wizard_init_v2_internal_action" product="default">Format</string>
|
||||
<!-- This text separates two options in a full-screen message. It's used to indicate a user can choose one option or the other. [CHAR LIMIT=16] -->
|
||||
@@ -2943,7 +2945,7 @@
|
||||
<!-- Title of a line item. Below this title, a user can tap a button to select this option if they want to use their SD card as portable device storage. [CHAR LIMIT=50] -->
|
||||
<string name="storage_wizard_init_v2_external_title">Format SD card for portable storage</string>
|
||||
<!-- Subtext for a line item. Below this subtext, a user can tap a button to select this option if they want to use their SD card as portable device storage. [CHAR LIMIT=NONE] -->
|
||||
<string name="storage_wizard_init_v2_external_summary">Store photos, videos, music, and more and access them from other devices. <a href="https://support.google.com/android/answer/12153449">Learn more about setting up an SD card</a></string>
|
||||
<string name="storage_wizard_init_v2_external_summary">Store photos, videos, music, and more and access them from other devices. <a href="https://support.google.com/android/answer/12153449">Learn more about setting up an SD card</a>.</string>
|
||||
<!-- Button text. A user can tap this button if they want to use their SD card as portable device storage. [CHAR LIMIT=32] -->
|
||||
<string name="storage_wizard_init_v2_external_action">Format</string>
|
||||
<!-- Button text. A user can tap this button if they want to delay setting up their SD card until a later time. [CHAR LIMIT=32] -->
|
||||
|
||||
@@ -283,7 +283,7 @@ public class ManageApplications extends InstrumentedFragment
|
||||
final String className = getClassName(activity.getIntent(), getArguments());
|
||||
if (className.equals(ManageExternalSourcesActivity.class.getName())) {
|
||||
SpaActivity.startSpaActivity(
|
||||
context, InstallUnknownAppsListProvider.INSTANCE.getRoute());
|
||||
context, InstallUnknownAppsListProvider.INSTANCE.getAppListRoute());
|
||||
activity.finish();
|
||||
}
|
||||
}
|
||||
|
||||
@@ -29,6 +29,8 @@ import android.hardware.display.DisplayManager;
|
||||
import android.provider.Settings;
|
||||
import android.text.TextUtils;
|
||||
import android.view.Display;
|
||||
import android.view.accessibility.AccessibilityEvent;
|
||||
import android.view.accessibility.AccessibilityManager;
|
||||
|
||||
import androidx.annotation.VisibleForTesting;
|
||||
import androidx.preference.PreferenceScreen;
|
||||
@@ -65,6 +67,7 @@ public class ScreenResolutionFragment extends RadioButtonPickerFragment {
|
||||
|
||||
private IllustrationPreference mImagePreference;
|
||||
private DisplayObserver mDisplayObserver;
|
||||
private AccessibilityManager mAccessibilityManager;
|
||||
|
||||
@Override
|
||||
public void onAttach(Context context) {
|
||||
@@ -72,6 +75,7 @@ public class ScreenResolutionFragment extends RadioButtonPickerFragment {
|
||||
|
||||
mDefaultDisplay =
|
||||
context.getSystemService(DisplayManager.class).getDisplay(Display.DEFAULT_DISPLAY);
|
||||
mAccessibilityManager = context.getSystemService(AccessibilityManager.class);
|
||||
mResources = context.getResources();
|
||||
mScreenResolutionOptions =
|
||||
mResources.getStringArray(R.array.config_screen_resolution_options_strings);
|
||||
@@ -215,6 +219,14 @@ public class ScreenResolutionFragment extends RadioButtonPickerFragment {
|
||||
if (!mDisplayObserver.setPendingResolutionChange(selectedWidth)) {
|
||||
return;
|
||||
}
|
||||
|
||||
if (mAccessibilityManager.isEnabled()) {
|
||||
AccessibilityEvent event = AccessibilityEvent.obtain();
|
||||
event.setEventType(AccessibilityEvent.TYPE_ANNOUNCEMENT);
|
||||
event.getText().add(mResources.getString(R.string.screen_resolution_selected_a11y));
|
||||
mAccessibilityManager.sendAccessibilityEvent(event);
|
||||
}
|
||||
|
||||
super.onRadioButtonClicked(selected);
|
||||
}
|
||||
|
||||
|
||||
@@ -17,6 +17,8 @@
|
||||
package com.android.settings.spa
|
||||
|
||||
import com.android.settings.spa.app.AppsMainPageProvider
|
||||
import com.android.settings.spa.app.appsettings.AppSettingsProvider
|
||||
import com.android.settings.spa.app.specialaccess.AlarmsAndRemindersAppListProvider
|
||||
import com.android.settings.spa.app.specialaccess.AllFilesAccessAppListProvider
|
||||
import com.android.settings.spa.app.specialaccess.DisplayOverOtherAppsAppListProvider
|
||||
import com.android.settings.spa.app.specialaccess.InstallUnknownAppsListProvider
|
||||
@@ -42,14 +44,16 @@ object SpaEnvironment {
|
||||
DisplayOverOtherAppsAppListProvider,
|
||||
MediaManagementAppsAppListProvider,
|
||||
ModifySystemSettingsAppListProvider,
|
||||
InstallUnknownAppsListProvider,
|
||||
PictureInPictureListProvider,
|
||||
InstallUnknownAppsListProvider,
|
||||
AlarmsAndRemindersAppListProvider,
|
||||
),
|
||||
)
|
||||
SettingsPageProviderRepository(
|
||||
allPageProviders = listOf(
|
||||
HomePageProvider,
|
||||
AppsMainPageProvider,
|
||||
AppSettingsProvider,
|
||||
SpecialAppAccessPageProvider,
|
||||
NotificationMainPageProvider,
|
||||
AppListNotificationsPageProvider,
|
||||
|
||||
85
src/com/android/settings/spa/app/appsettings/AppSettings.kt
Normal file
85
src/com/android/settings/spa/app/appsettings/AppSettings.kt
Normal file
@@ -0,0 +1,85 @@
|
||||
/*
|
||||
* Copyright (C) 2022 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.appsettings
|
||||
|
||||
import android.content.pm.ApplicationInfo
|
||||
import android.content.pm.PackageInfo
|
||||
import android.os.Bundle
|
||||
import androidx.compose.runtime.Composable
|
||||
import androidx.compose.runtime.remember
|
||||
import androidx.compose.ui.res.stringResource
|
||||
import androidx.navigation.NavType
|
||||
import androidx.navigation.navArgument
|
||||
import com.android.settings.R
|
||||
import com.android.settings.spa.app.specialaccess.AlarmsAndRemindersAppListProvider
|
||||
import com.android.settings.spa.app.specialaccess.DisplayOverOtherAppsAppListProvider
|
||||
import com.android.settings.spa.app.specialaccess.InstallUnknownAppsListProvider
|
||||
import com.android.settings.spa.app.specialaccess.ModifySystemSettingsAppListProvider
|
||||
import com.android.settings.spa.app.specialaccess.PictureInPictureListProvider
|
||||
import com.android.settingslib.spa.framework.common.SettingsPageProvider
|
||||
import com.android.settingslib.spa.framework.compose.navigator
|
||||
import com.android.settingslib.spa.widget.scaffold.RegularScaffold
|
||||
import com.android.settingslib.spa.widget.ui.Category
|
||||
import com.android.settingslib.spaprivileged.model.app.PackageManagers
|
||||
import com.android.settingslib.spaprivileged.model.app.toRoute
|
||||
import com.android.settingslib.spaprivileged.template.app.AppInfoProvider
|
||||
|
||||
private const val PACKAGE_NAME = "packageName"
|
||||
private const val USER_ID = "userId"
|
||||
|
||||
object AppSettingsProvider : SettingsPageProvider {
|
||||
override val name = "AppSettings"
|
||||
|
||||
override val parameter = listOf(
|
||||
navArgument(PACKAGE_NAME) { type = NavType.StringType },
|
||||
navArgument(USER_ID) { type = NavType.IntType },
|
||||
)
|
||||
|
||||
@Composable
|
||||
override fun Page(arguments: Bundle?) {
|
||||
val packageName = arguments!!.getString(PACKAGE_NAME)!!
|
||||
val userId = arguments.getInt(USER_ID)
|
||||
remember { PackageManagers.getPackageInfoAsUser(packageName, userId) }?.let {
|
||||
AppSettings(it)
|
||||
}
|
||||
}
|
||||
|
||||
@Composable
|
||||
fun navigator(app: ApplicationInfo) = navigator(route = "$name/${app.toRoute()}")
|
||||
}
|
||||
|
||||
@Composable
|
||||
private fun AppSettings(packageInfo: PackageInfo) {
|
||||
RegularScaffold(title = stringResource(R.string.application_info_label)) {
|
||||
val appInfoProvider = remember { AppInfoProvider(packageInfo) }
|
||||
|
||||
appInfoProvider.AppInfo()
|
||||
|
||||
Category(title = stringResource(R.string.advanced_apps)) {
|
||||
val app = packageInfo.applicationInfo
|
||||
DisplayOverOtherAppsAppListProvider.InfoPageEntryItem(app)
|
||||
ModifySystemSettingsAppListProvider.InfoPageEntryItem(app)
|
||||
PictureInPictureListProvider.InfoPageEntryItem(app)
|
||||
InstallUnknownAppsListProvider.InfoPageEntryItem(app)
|
||||
// TODO: interact_across_profiles
|
||||
AlarmsAndRemindersAppListProvider.InfoPageEntryItem(app)
|
||||
}
|
||||
|
||||
// TODO: app_installer
|
||||
appInfoProvider.FooterAppVersion()
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,99 @@
|
||||
/*
|
||||
* Copyright (C) 2022 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.AlarmManager
|
||||
import android.app.compat.CompatChanges
|
||||
import android.content.Context
|
||||
import android.content.pm.ApplicationInfo
|
||||
import androidx.compose.runtime.Composable
|
||||
import androidx.compose.runtime.livedata.observeAsState
|
||||
import com.android.settings.R
|
||||
import com.android.settingslib.spaprivileged.model.app.AppRecord
|
||||
import com.android.settingslib.spaprivileged.model.app.PackageManagers
|
||||
import com.android.settingslib.spaprivileged.model.app.PackageManagers.hasRequestPermission
|
||||
import com.android.settingslib.spaprivileged.model.app.userHandle
|
||||
import com.android.settingslib.spaprivileged.template.app.TogglePermissionAppListModel
|
||||
import com.android.settingslib.spaprivileged.template.app.TogglePermissionAppListProvider
|
||||
import kotlinx.coroutines.flow.Flow
|
||||
import kotlinx.coroutines.flow.combine
|
||||
import kotlinx.coroutines.flow.map
|
||||
|
||||
object AlarmsAndRemindersAppListProvider : TogglePermissionAppListProvider {
|
||||
override val permissionType = "AlarmsAndReminders"
|
||||
override fun createModel(context: Context) = AlarmsAndRemindersAppListModel(context)
|
||||
}
|
||||
|
||||
data class AlarmsAndRemindersAppRecord(
|
||||
override val app: ApplicationInfo,
|
||||
val isChangeable: Boolean,
|
||||
var controller: AlarmsAndRemindersController,
|
||||
) : AppRecord
|
||||
|
||||
class AlarmsAndRemindersAppListModel(
|
||||
private val context: Context,
|
||||
) : TogglePermissionAppListModel<AlarmsAndRemindersAppRecord> {
|
||||
override val pageTitleResId = R.string.alarms_and_reminders_title
|
||||
override val switchTitleResId = R.string.alarms_and_reminders_switch_title
|
||||
override val footerResId = R.string.alarms_and_reminders_footer_title
|
||||
|
||||
override fun transform(userIdFlow: Flow<Int>, appListFlow: Flow<List<ApplicationInfo>>) =
|
||||
userIdFlow.map { userId ->
|
||||
PackageManagers.getAppOpPermissionPackages(userId, PERMISSION)
|
||||
}.combine(appListFlow) { packageNames, appList ->
|
||||
appList.map { app ->
|
||||
createRecord(app = app, hasRequestPermission = app.packageName in packageNames)
|
||||
}
|
||||
}
|
||||
|
||||
override fun transformItem(app: ApplicationInfo) =
|
||||
createRecord(app = app, hasRequestPermission = app.hasRequestPermission(PERMISSION))
|
||||
|
||||
override fun filter(
|
||||
userIdFlow: Flow<Int>,
|
||||
recordListFlow: Flow<List<AlarmsAndRemindersAppRecord>>,
|
||||
) = recordListFlow.map { recordList ->
|
||||
recordList.filter { it.isChangeable }
|
||||
}
|
||||
|
||||
@Composable
|
||||
override fun isAllowed(record: AlarmsAndRemindersAppRecord) =
|
||||
record.controller.isAllowed.observeAsState()
|
||||
|
||||
override fun isChangeable(record: AlarmsAndRemindersAppRecord) = record.isChangeable
|
||||
|
||||
override fun setAllowed(record: AlarmsAndRemindersAppRecord, newAllowed: Boolean) {
|
||||
record.controller.setAllowed(newAllowed)
|
||||
}
|
||||
|
||||
private fun createRecord(app: ApplicationInfo, hasRequestPermission: Boolean) =
|
||||
AlarmsAndRemindersAppRecord(
|
||||
app = app,
|
||||
isChangeable = hasRequestPermission && app.isChangeEnabled(),
|
||||
controller = AlarmsAndRemindersController(context, app),
|
||||
)
|
||||
|
||||
companion object {
|
||||
private const val PERMISSION: String = Manifest.permission.SCHEDULE_EXACT_ALARM
|
||||
|
||||
private fun ApplicationInfo.isChangeEnabled(): Boolean =
|
||||
CompatChanges.isChangeEnabled(
|
||||
AlarmManager.REQUIRE_EXACT_ALARM_PERMISSION, packageName, userHandle,
|
||||
)
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,53 @@
|
||||
/*
|
||||
* Copyright (C) 2022 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.app.AlarmManager
|
||||
import android.app.AppOpsManager
|
||||
import android.app.AppOpsManager.MODE_ALLOWED
|
||||
import android.app.AppOpsManager.MODE_ERRORED
|
||||
import android.content.Context
|
||||
import android.content.pm.ApplicationInfo
|
||||
import androidx.lifecycle.LiveData
|
||||
import androidx.lifecycle.MutableLiveData
|
||||
import com.android.settingslib.spaprivileged.model.app.userId
|
||||
|
||||
class AlarmsAndRemindersController(
|
||||
context: Context,
|
||||
private val app: ApplicationInfo,
|
||||
) {
|
||||
private val alarmManager = context.getSystemService(AlarmManager::class.java)!!
|
||||
private val appOpsManager = context.getSystemService(AppOpsManager::class.java)!!
|
||||
|
||||
val isAllowed: LiveData<Boolean>
|
||||
get() = _allowed
|
||||
|
||||
fun setAllowed(allowed: Boolean) {
|
||||
val mode = if (allowed) MODE_ALLOWED else MODE_ERRORED
|
||||
appOpsManager.setUidMode(AppOpsManager.OPSTR_SCHEDULE_EXACT_ALARM, app.uid, mode)
|
||||
_allowed.postValue(allowed)
|
||||
}
|
||||
|
||||
private val _allowed = object : MutableLiveData<Boolean>() {
|
||||
override fun onActive() {
|
||||
postValue(alarmManager.hasScheduleExactAlarm(app.packageName, app.userId))
|
||||
}
|
||||
|
||||
override fun onInactive() {
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -34,7 +34,11 @@ object SpecialAppAccessPageProvider : SettingsPageProvider {
|
||||
|
||||
@Composable
|
||||
override fun Page(arguments: Bundle?) {
|
||||
SpecialAppAccessPage()
|
||||
RegularScaffold(title = stringResource(R.string.special_access)) {
|
||||
for (entry in buildEntry(arguments)) {
|
||||
entry.UiLayout()
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@Composable
|
||||
@@ -51,26 +55,12 @@ object SpecialAppAccessPageProvider : SettingsPageProvider {
|
||||
override fun buildEntry(arguments: Bundle?): List<SettingsEntry> {
|
||||
val owner = SettingsPage.create(name, parameter, arguments)
|
||||
return listOf(
|
||||
AllFilesAccessAppListProvider.buildInjectEntry().setLink(fromPage = owner).build(),
|
||||
DisplayOverOtherAppsAppListProvider.buildInjectEntry()
|
||||
.setLink(fromPage = owner).build(),
|
||||
MediaManagementAppsAppListProvider.buildInjectEntry().setLink(fromPage = owner).build(),
|
||||
ModifySystemSettingsAppListProvider.buildInjectEntry()
|
||||
.setLink(fromPage = owner).build(),
|
||||
PictureInPictureListProvider.buildInjectEntry().setLink(fromPage = owner).build(),
|
||||
InstallUnknownAppsListProvider.buildInjectEntry().setLink(fromPage = owner).build(),
|
||||
)
|
||||
}
|
||||
}
|
||||
|
||||
@Composable
|
||||
private fun SpecialAppAccessPage() {
|
||||
RegularScaffold(title = stringResource(R.string.special_access)) {
|
||||
AllFilesAccessAppListProvider.EntryItem()
|
||||
DisplayOverOtherAppsAppListProvider.EntryItem()
|
||||
MediaManagementAppsAppListProvider.EntryItem()
|
||||
ModifySystemSettingsAppListProvider.EntryItem()
|
||||
PictureInPictureListProvider.EntryItem()
|
||||
InstallUnknownAppsListProvider.EntryItem()
|
||||
AllFilesAccessAppListProvider,
|
||||
DisplayOverOtherAppsAppListProvider,
|
||||
MediaManagementAppsAppListProvider,
|
||||
ModifySystemSettingsAppListProvider,
|
||||
PictureInPictureListProvider,
|
||||
InstallUnknownAppsListProvider,
|
||||
).map { it.buildAppListInjectEntry().setLink(fromPage = owner).build() }
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user