Merge "Adding support for calling into SystemNavigationGestureSettings" into udc-dev
diff --git a/AndroidManifest.xml b/AndroidManifest.xml
index 7a51340..59b25ac 100644
--- a/AndroidManifest.xml
+++ b/AndroidManifest.xml
@@ -131,6 +131,7 @@
<uses-permission android:name="android.permission.LIST_ENABLED_CREDENTIAL_PROVIDERS" />
<uses-permission android:name="android.permission.CUSTOMIZE_SYSTEM_UI" />
<uses-permission android:name="android.permission.REMAP_MODIFIER_KEYS" />
+ <uses-permission android:name="android.permission.ACCESS_GPU_SERVICE" />
<application
android:name=".SettingsApplication"
@@ -3492,12 +3493,25 @@
<category android:name="android.intent.category.DEFAULT" />
</intent-filter>
<meta-data android:name="com.android.settings.FRAGMENT_CLASS"
- android:value="com.android.settings.applications.specialaccess.turnscreenon.TurnScreenOnSettings" />
+ android:value="com.android.settings.applications.manageapplications.ManageApplications" />
<meta-data android:name="com.android.settings.HIGHLIGHT_MENU_KEY"
android:value="@string/menu_key_apps"/>
</activity>
<activity
+ android:name="Settings$AppTurnScreenOnSettingsActivity"
+ android:exported="true"
+ android:label="@string/turn_screen_on_title">
+ <intent-filter android:priority="1">
+ <action android:name="android.settings.TURN_SCREEN_ON_SETTINGS" />
+ <category android:name="android.intent.category.DEFAULT" />
+ <data android:scheme="package" />
+ </intent-filter>
+ <meta-data android:name="com.android.settings.FRAGMENT_CLASS"
+ android:value="com.android.settings.applications.specialaccess.turnscreenon.TurnScreenOnDetails"/>
+ </activity>
+
+ <activity
android:name="Settings$InteractAcrossProfilesSettingsActivity"
android:exported="true"
android:label="@string/interact_across_profiles_title">
diff --git a/res/drawable/ic_battery_alert_theme.xml b/res/drawable/ic_battery_alert_theme.xml
new file mode 100644
index 0000000..a046a3e
--- /dev/null
+++ b/res/drawable/ic_battery_alert_theme.xml
@@ -0,0 +1,27 @@
+<!--
+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.
+-->
+<vector xmlns:android="http://schemas.android.com/apk/res/android"
+ android:width="24dp"
+ android:height="24dp"
+ android:viewportWidth="24.0"
+ android:viewportHeight="24.0">
+ <path
+ android:fillColor="?android:attr/colorAccent"
+ android:pathData="M13,17h-2v-2h2V17zM13,13h-2V8h2V13z"/>
+ <path
+ android:fillColor="?android:attr/colorAccent"
+ android:pathData="M16.2,22.5H7.8c-1.3,0 -2.3,-1 -2.3,-2.3V5.8c0,-1.3 1,-2.3 2.3,-2.3h0.7v-2h7v2h0.7c1.3,0 2.3,1.1 2.3,2.3v14.3C18.5,21.5 17.5,22.5 16.2,22.5zM7.8,5.5c-0.2,0 -0.3,0.2 -0.3,0.3v14.3c0,0.2 0.2,0.3 0.3,0.3h8.3c0.2,0 0.3,-0.1 0.3,-0.3V5.8c0,-0.2 -0.1,-0.3 -0.3,-0.3h-2.7v-2h-3v2H7.8z"/>
+</vector>
diff --git a/res/drawable/ic_battery_status_good_theme.xml b/res/drawable/ic_battery_status_good_theme.xml
new file mode 100644
index 0000000..0870785
--- /dev/null
+++ b/res/drawable/ic_battery_status_good_theme.xml
@@ -0,0 +1,27 @@
+<!--
+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.
+-->
+<vector xmlns:android="http://schemas.android.com/apk/res/android"
+ android:width="24dp"
+ android:height="24dp"
+ android:viewportWidth="24.0"
+ android:viewportHeight="24.0">
+ <path
+ android:fillColor="?android:attr/colorAccent"
+ android:pathData="M16.2,22.5H7.8c-1.3,0 -2.3,-1 -2.3,-2.3V5.8c0,-1.3 1,-2.3 2.3,-2.3h0.7v-2h7v2h0.7c1.3,0 2.3,1.1 2.3,2.3v14.3C18.5,21.5 17.5,22.5 16.2,22.5zM7.8,5.5c-0.2,0 -0.3,0.2 -0.3,0.3v14.3c0,0.2 0.2,0.3 0.3,0.3h8.3c0.2,0 0.3,-0.1 0.3,-0.3V5.8c0,-0.2 -0.1,-0.3 -0.3,-0.3h-2.7v-2h-3v2H7.8z"/>
+ <path
+ android:fillColor="?android:attr/colorAccent"
+ android:pathData="M16.1,11.1l-1.4,-1.5l-3.9,3.9l-1.5,-1.4l-1.4,1.4l2.9,2.9z"/>
+</vector>
diff --git a/res/drawable/ic_perm_device_information_red_24dp.xml b/res/drawable/ic_perm_device_information_red_24dp.xml
deleted file mode 100644
index d375c0b..0000000
--- a/res/drawable/ic_perm_device_information_red_24dp.xml
+++ /dev/null
@@ -1,32 +0,0 @@
-<!--
- Copyright (C) 2017 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.
--->
-
-<vector xmlns:android="http://schemas.android.com/apk/res/android"
- android:width="24dp"
- android:height="24dp"
- android:viewportWidth="24.0"
- android:viewportHeight="24.0"
- android:tint="?android:attr/colorError">
- <path
- android:fillColor="#FF000000"
- android:pathData="M11,7h2v2h-2z"/>
- <path
- android:fillColor="#FF000000"
- android:pathData="M11,11h2v6h-2z"/>
- <path
- android:fillColor="#FF000000"
- android:pathData="M17,1.01L7,1C5.9,1 5,1.9 5,3v18c0,1.1 0.9,2 2,2h10c1.1,0 2,-0.9 2,-2V3C19,1.9 18.1,1.01 17,1.01zM17,21H7l0,-1h10V21zM17,18H7V6h10V18zM7,4V3h10v1H7z"/>
-</vector>
diff --git a/res/drawable/ic_perm_device_information_green_24dp.xml b/res/drawable/ic_perm_device_information_theme.xml
similarity index 82%
rename from res/drawable/ic_perm_device_information_green_24dp.xml
rename to res/drawable/ic_perm_device_information_theme.xml
index e309b40..f7e2547 100644
--- a/res/drawable/ic_perm_device_information_green_24dp.xml
+++ b/res/drawable/ic_perm_device_information_theme.xml
@@ -1,5 +1,5 @@
<!--
- Copyright (C) 2018 The Android Open Source Project
+ 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.
@@ -13,19 +13,18 @@
See the License for the specific language governing permissions and
limitations under the License.
-->
-
<vector xmlns:android="http://schemas.android.com/apk/res/android"
android:width="24dp"
android:height="24dp"
android:viewportWidth="24.0"
android:viewportHeight="24.0">
<path
- android:fillColor="#0F9D58"
+ android:fillColor="?android:attr/colorAccent"
android:pathData="M11,7h2v2h-2z"/>
<path
- android:fillColor="#0F9D58"
+ android:fillColor="?android:attr/colorAccent"
android:pathData="M11,11h2v6h-2z"/>
<path
- android:fillColor="#0F9D58"
+ android:fillColor="?android:attr/colorAccent"
android:pathData="M17,1.01L7,1C5.9,1 5,1.9 5,3v18c0,1.1 0.9,2 2,2h10c1.1,0 2,-0.9 2,-2V3C19,1.9 18.1,1.01 17,1.01zM17,21H7l0,-1h10V21zM17,18H7V6h10V18zM7,4V3h10v1H7z"/>
</vector>
diff --git a/res/layout/locale_dialog.xml b/res/layout/locale_dialog.xml
index 480c0e2..0a3cd03 100644
--- a/res/layout/locale_dialog.xml
+++ b/res/layout/locale_dialog.xml
@@ -13,44 +13,48 @@
See the License for the specific language governing permissions and
limitations under the License.
-->
-<LinearLayout
+<ScrollView
xmlns:android="http://schemas.android.com/apk/res/android"
- android:layout_width="wrap_content"
+ android:layout_width="match_parent"
android:layout_height="wrap_content"
- android:paddingTop="@dimen/admin_details_dialog_padding"
- android:paddingStart="@dimen/admin_details_dialog_padding"
- android:paddingEnd="@dimen/admin_details_dialog_padding"
- android:paddingBottom="@dimen/admin_details_dialog_padding_bottom"
- android:orientation="vertical"
- android:layoutDirection="locale"
- android:textDirection="locale">
+ android:fadeScrollbars="false"
+ android:scrollbarStyle="outsideOverlay"
+ android:fillViewport="true">
+
<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
+ android:paddingTop="@dimen/admin_details_dialog_padding"
+ android:paddingStart="@dimen/admin_details_dialog_padding"
+ android:paddingEnd="@dimen/admin_details_dialog_padding"
+ android:paddingBottom="@dimen/admin_details_dialog_padding_bottom"
android:orientation="vertical"
- android:gravity="center_horizontal"
- android:paddingBottom="@dimen/admin_details_dialog_title_bottom_padding">
- <ImageView
- android:layout_width="@dimen/admin_details_dialog_icon_size"
- android:layout_height="@dimen/admin_details_dialog_icon_size"
- android:scaleType="fitCenter"
- android:src="@drawable/ic_settings_language"
- android:tint="#4F8438"
- android:contentDescription="@null"/>
- <TextView
- android:id="@+id/dialog_title"
- android:layout_width="wrap_content"
+ android:layoutDirection="locale"
+ android:textDirection="locale">
+ <LinearLayout
+ android:layout_width="match_parent"
android:layout_height="wrap_content"
- android:layout_marginTop="16dp"
+ android:orientation="vertical"
android:gravity="center_horizontal"
- android:textAppearance="@style/TextAppearance.AdminDialogTitle"
- android:textAlignment="textStart"/>
- </LinearLayout>
+ android:paddingBottom="@dimen/admin_details_dialog_title_bottom_padding">
+ <ImageView
+ android:layout_width="@dimen/admin_details_dialog_icon_size"
+ android:layout_height="@dimen/admin_details_dialog_icon_size"
+ android:scaleType="fitCenter"
+ android:src="@drawable/ic_settings_language"
+ android:tint="#4F8438"
+ android:contentDescription="@null"/>
+ <TextView
+ android:id="@+id/dialog_title"
+ android:layout_width="match_parent"
+ android:layout_height="wrap_content"
+ android:layout_marginTop="16dp"
+ android:gravity="center"
+ android:textSize="20sp"
+ android:textColor="?android:attr/textColorPrimary"
+ android:fontFamily="@*android:string/config_headlineFontFamilyMedium"/>
+ </LinearLayout>
- <ScrollView
- android:layout_width="match_parent"
- android:layout_height="wrap_content"
- android:fadeScrollbars="false">
<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
@@ -60,10 +64,11 @@
android:id="@+id/dialog_msg"
android:layout_width="match_parent"
android:layout_height="wrap_content"
+ android:textSize="16sp"
android:maxLength="200"
android:autoLink="email|phone|web"
android:textColor="?android:attr/textColorSecondary"
android:textAlignment="textStart"/>
</LinearLayout>
- </ScrollView>
-</LinearLayout>
+ </LinearLayout>
+</ScrollView>
diff --git a/res/layout/sim_confirm_dialog_item_multiple_enabled_profiles_supported.xml b/res/layout/sim_confirm_dialog_item_multiple_enabled_profiles_supported.xml
index 700fab3..6b5ffae 100644
--- a/res/layout/sim_confirm_dialog_item_multiple_enabled_profiles_supported.xml
+++ b/res/layout/sim_confirm_dialog_item_multiple_enabled_profiles_supported.xml
@@ -14,12 +14,12 @@
limitations under the License.
-->
-<TextView xmlns:android="http://schemas.android.com/apk/res/android"
+<Button xmlns:android="http://schemas.android.com/apk/res/android"
android:id="@+id/title"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:minHeight="?attr/listPreferredItemHeightSmall"
- style="?attr/materialAlertDialogBodyTextStyle"
+ style="@style/SettingsLibActionButton"
android:gravity="center"
android:paddingTop="?attr/listPreferredItemPaddingStart"
android:paddingBottom="?attr/listPreferredItemPaddingEnd"
diff --git a/res/layout/supported_links_dialog_item.xml b/res/layout/supported_links_dialog_item.xml
index bbd2857..8a18935 100644
--- a/res/layout/supported_links_dialog_item.xml
+++ b/res/layout/supported_links_dialog_item.xml
@@ -19,6 +19,7 @@
android:id="@android:id/text1"
android:layout_width="match_parent"
android:layout_height="wrap_content"
+ android:textDirection="locale"
android:minHeight="?android:attr/listPreferredItemHeightSmall"
android:ellipsize="marquee"
android:gravity="center_vertical"
diff --git a/res/values/strings.xml b/res/values/strings.xml
index a366ac7..9083548 100644
--- a/res/values/strings.xml
+++ b/res/values/strings.xml
@@ -5474,9 +5474,9 @@
<!-- [CHAR_LIMIT=NONE] Device screen on time category for a selected slot -->
<string name="screen_time_category_for_slot">Screen time for <xliff:g id="slot">%s</xliff:g></string>
<!-- [CHAR_LIMIT=NONE] The spinner item text in the battery usage breakdown. -->
- <string name="battery_usage_spinner_breakdown_by_apps">Breakdown by apps</string>
+ <string name="battery_usage_spinner_by_apps">By apps</string>
<!-- [CHAR_LIMIT=NONE] The spinner item text in the battery usage breakdown. -->
- <string name="battery_usage_spinner_breakdown_by_system">Breakdown by system</string>
+ <string name="battery_usage_spinner_by_systems">By systems</string>
<!-- [CHAR_LIMIT=NONE] Less than some percentage, e.g. < 1% -->
<string name="battery_usage_less_than_percent">< <xliff:g id="percentage">%1$s</xliff:g></string>
<!-- Process Stats strings -->
diff --git a/res/xml/app_info_settings.xml b/res/xml/app_info_settings.xml
index e004f28..d8af009 100644
--- a/res/xml/app_info_settings.xml
+++ b/res/xml/app_info_settings.xml
@@ -85,7 +85,7 @@
<Preference
android:key="battery"
- android:title="@string/app_battery_usage_title"
+ android:title="@string/battery_details_title"
android:summary="@string/summary_placeholder" />
<Preference
diff --git a/res/xml/special_access.xml b/res/xml/special_access.xml
index e380ba4..2fb4af4 100644
--- a/res/xml/special_access.xml
+++ b/res/xml/special_access.xml
@@ -195,7 +195,11 @@
android:key="turn_screen_on"
android:title="@string/turn_screen_on_title"
android:order="-200"
- android:fragment="com.android.settings.applications.specialaccess.turnscreenon.TurnScreenOnSettings" />
+ android:fragment="com.android.settings.applications.manageapplications.ManageApplications">
+ <extra
+ android:name="classname"
+ android:value="com.android.settings.Settings$TurnScreenOnSettingsActivity" />
+ </Preference>
<Preference
android:key="special_access_more"
diff --git a/res/xml/turn_screen_on_settings.xml b/res/xml/turn_screen_on_settings.xml
deleted file mode 100644
index 6aefa72..0000000
--- a/res/xml/turn_screen_on_settings.xml
+++ /dev/null
@@ -1,23 +0,0 @@
-<?xml version="1.0" encoding="utf-8"?>
-<!--
- 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.
- -->
-
-<PreferenceScreen
- xmlns:android="http://schemas.android.com/apk/res/android"
- xmlns:settings="http://schemas.android.com/apk/res-auto"
- android:key="turn_screen_on_screen"
- android:title="@string/turn_screen_on_title"
- settings:searchable="false" />
diff --git a/src/com/android/settings/Settings.java b/src/com/android/settings/Settings.java
index c172be5..a8fa527 100644
--- a/src/com/android/settings/Settings.java
+++ b/src/com/android/settings/Settings.java
@@ -352,6 +352,7 @@
public static class PremiumSmsAccessActivity extends SettingsActivity { /* empty */ }
public static class PictureInPictureSettingsActivity extends SettingsActivity { /* empty */ }
public static class TurnScreenOnSettingsActivity extends SettingsActivity { /* empty */ }
+ public static class AppTurnScreenOnSettingsActivity extends SettingsActivity { /* empty */ }
public static class AppPictureInPictureSettingsActivity extends SettingsActivity { /* empty */ }
public static class ZenAccessSettingsActivity extends SettingsActivity { /* empty */ }
public static class ZenAccessDetailSettingsActivity extends SettingsActivity {}
diff --git a/src/com/android/settings/applications/AppStateTurnScreenOnBridge.java b/src/com/android/settings/applications/AppStateTurnScreenOnBridge.java
new file mode 100644
index 0000000..8a75c0b
--- /dev/null
+++ b/src/com/android/settings/applications/AppStateTurnScreenOnBridge.java
@@ -0,0 +1,86 @@
+/*
+ * 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.applications;
+
+import android.Manifest;
+import android.app.AppOpsManager;
+import android.content.Context;
+
+import com.android.settingslib.applications.ApplicationsState;
+import com.android.settingslib.applications.ApplicationsState.AppEntry;
+import com.android.settingslib.applications.ApplicationsState.AppFilter;
+
+import java.util.List;
+
+/**
+ * Connects app op info to the ApplicationsState. Extends {@link AppStateAppOpsBridge} to tailor
+ * to the semantics of {@link Manifest.permission#TURN_SCREEN_ON}.
+ * Also provides app filters that can use the info.
+ */
+public class AppStateTurnScreenOnBridge extends AppStateAppOpsBridge {
+ private static final String APP_OP_STR = AppOpsManager.OPSTR_TURN_SCREEN_ON;
+ private static final String[] PERMISSIONS = {
+ Manifest.permission.TURN_SCREEN_ON
+ };
+
+ private AppOpsManager mAppOpsManager;
+
+ public AppStateTurnScreenOnBridge(Context context, ApplicationsState appState,
+ Callback callback) {
+ super(context, appState, callback, AppOpsManager.strOpToOp(APP_OP_STR), PERMISSIONS);
+ mAppOpsManager = context.getSystemService(AppOpsManager.class);
+ }
+
+ @Override
+ protected void updateExtraInfo(AppEntry app, String pkg, int uid) {
+ app.extraInfo = getPermissionInfo(pkg, uid);
+ }
+
+ @Override
+ protected void loadAllExtraInfo() {
+ super.loadAllExtraInfo();
+ final List<AppEntry> apps = mAppSession.getAllApps();
+ for (AppEntry app : apps) {
+ if (app.extraInfo instanceof PermissionState) {
+ ((PermissionState) app.extraInfo).appOpMode = mAppOpsManager.unsafeCheckOpNoThrow(
+ APP_OP_STR, app.info.uid, app.info.packageName);
+ }
+ }
+ }
+
+ @Override
+ public PermissionState getPermissionInfo(String pkg, int uid) {
+ PermissionState ps = super.getPermissionInfo(pkg, uid);
+ ps.appOpMode = mAppOpsManager.unsafeCheckOpNoThrow(APP_OP_STR, uid, pkg);
+ return ps;
+ }
+
+ public static final AppFilter FILTER_TURN_SCREEN_ON_APPS = new AppFilter() {
+
+ @Override
+ public void init() {
+ }
+
+ @Override
+ public boolean filterApp(AppEntry info) {
+ // If extraInfo != null, it means that the app has declared
+ // Manifest.permission.TURN_SCREEN_ON and therefore it should appear on our
+ // list
+ return info.extraInfo != null;
+ }
+ };
+}
diff --git a/src/com/android/settings/applications/appinfo/TurnScreenOnDetails.java b/src/com/android/settings/applications/appinfo/TurnScreenOnDetails.java
new file mode 100644
index 0000000..39e1a5f
--- /dev/null
+++ b/src/com/android/settings/applications/appinfo/TurnScreenOnDetails.java
@@ -0,0 +1,130 @@
+/*
+ * 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.applications.appinfo;
+
+import static android.app.Activity.RESULT_CANCELED;
+import static android.app.Activity.RESULT_OK;
+import static android.app.AppOpsManager.MODE_ALLOWED;
+import static android.app.AppOpsManager.MODE_ERRORED;
+
+import android.app.AppOpsManager;
+import android.app.settings.SettingsEnums;
+import android.content.Context;
+import android.os.Bundle;
+
+import androidx.appcompat.app.AlertDialog;
+import androidx.preference.Preference;
+import androidx.preference.Preference.OnPreferenceChangeListener;
+import androidx.preference.SwitchPreference;
+
+import com.android.settings.R;
+import com.android.settings.Settings;
+import com.android.settings.applications.AppInfoWithHeader;
+import com.android.settings.applications.AppStateAppOpsBridge;
+import com.android.settings.applications.AppStateTurnScreenOnBridge;
+import com.android.settingslib.applications.ApplicationsState;
+
+/**
+ * Detail page for turn screen on special app access.
+ */
+public class TurnScreenOnDetails extends AppInfoWithHeader implements OnPreferenceChangeListener {
+
+ private static final String KEY_APP_OPS_SETTINGS_SWITCH = "app_ops_settings_switch";
+
+ private AppStateTurnScreenOnBridge mAppBridge;
+ private AppOpsManager mAppOpsManager;
+ private SwitchPreference mSwitchPref;
+ private AppStateAppOpsBridge.PermissionState mPermissionState;
+
+
+ @Override
+ public void onCreate(Bundle savedInstanceState) {
+ super.onCreate(savedInstanceState);
+
+ final Context context = getActivity();
+ mAppBridge = new AppStateTurnScreenOnBridge(context, mState, /*callback=*/ null);
+ mAppOpsManager = context.getSystemService(AppOpsManager.class);
+
+ // find preferences
+ addPreferencesFromResource(R.xml.turn_screen_on_permissions_details);
+ mSwitchPref = (SwitchPreference) findPreference(KEY_APP_OPS_SETTINGS_SWITCH);
+ mSwitchPref.setOnPreferenceChangeListener(this);
+ }
+
+ @Override
+ public boolean onPreferenceChange(Preference preference, Object newValue) {
+ final boolean checked = (Boolean) newValue;
+ if (preference == mSwitchPref) {
+ if (mPermissionState != null && checked != mPermissionState.isPermissible()) {
+ if (Settings.TurnScreenOnSettingsActivity.class.getName().equals(
+ getIntent().getComponent().getClassName())) {
+ setResult(checked ? RESULT_OK : RESULT_CANCELED);
+ }
+ setCanTurnScreenOn(checked);
+ refreshUi();
+ }
+ return true;
+ }
+ return false;
+ }
+
+ @Override
+ protected boolean refreshUi() {
+ if (mPackageInfo == null || mPackageInfo.applicationInfo == null) {
+ return false;
+ }
+ mPermissionState = mAppBridge.getPermissionInfo(mPackageName,
+ mPackageInfo.applicationInfo.uid);
+ mSwitchPref.setEnabled(mPermissionState.permissionDeclared);
+ mSwitchPref.setChecked(mPermissionState.isPermissible());
+ return true;
+ }
+
+ @Override
+ protected AlertDialog createDialog(int id, int errorCode) {
+ return null;
+ }
+
+ @Override
+ public int getMetricsCategory() {
+ return SettingsEnums.SETTINGS_MANAGE_TURN_SCREEN_ON;
+ }
+
+ /**
+ * Sets whether the app associated with the given {@code packageName} is allowed to turn the
+ * screen on.
+ */
+ void setCanTurnScreenOn(boolean newState) {
+ mAppOpsManager.setUidMode(AppOpsManager.OPSTR_TURN_SCREEN_ON,
+ mPackageInfo.applicationInfo.uid, newState ? MODE_ALLOWED : MODE_ERRORED);
+ }
+
+ /**
+ * @return the summary for the current state of whether the app associated with the given
+ * packageName is allowed to turn the screen on.
+ */
+ public static int getSummary(Context context, ApplicationsState.AppEntry entry) {
+ final AppStateAppOpsBridge.PermissionState state;
+ if (entry.extraInfo instanceof AppStateAppOpsBridge.PermissionState) {
+ state = (AppStateAppOpsBridge.PermissionState) entry.extraInfo;
+ } else {
+ state = new AppStateTurnScreenOnBridge(context, /*appState=*/ null,
+ /*callback=*/ null).getPermissionInfo(entry.info.packageName, entry.info.uid);
+ }
+ return state.isPermissible() ? R.string.app_permission_summary_allowed
+ : R.string.app_permission_summary_not_allowed;
+ }
+}
diff --git a/src/com/android/settings/applications/credentials/CredentialManagerPreferenceController.java b/src/com/android/settings/applications/credentials/CredentialManagerPreferenceController.java
index 43c4647..c627df3 100644
--- a/src/com/android/settings/applications/credentials/CredentialManagerPreferenceController.java
+++ b/src/com/android/settings/applications/credentials/CredentialManagerPreferenceController.java
@@ -41,6 +41,8 @@
import android.provider.DeviceConfig;
import android.provider.Settings;
import android.text.TextUtils;
+import com.android.settingslib.utils.ThreadUtils;
+import com.android.internal.content.PackageMonitor;
import android.util.IconDrawableFactory;
import android.util.Log;
@@ -236,20 +238,11 @@
@OnLifecycleEvent(ON_CREATE)
void onCreate(LifecycleOwner lifecycleOwner) {
- if (mCredentialManager == null) {
- return;
- }
-
- setAvailableServices(
- lifecycleOwner,
- mCredentialManager.getCredentialProviderServices(
- getUser(), CredentialManager.PROVIDER_FILTER_USER_PROVIDERS_ONLY),
- null);
+ update();
}
@VisibleForTesting
void setAvailableServices(
- LifecycleOwner lifecycleOwner,
List<CredentialProviderInfo> availableServices,
String flagOverrideForTest) {
mFlagOverrideForTest = flagOverrideForTest;
@@ -642,6 +635,40 @@
void setActivityResult(int resultCode);
}
+ /**
+ * Monitor coming and going credman services and calls {@link #update()} when necessary
+ */
+ private final PackageMonitor mSettingsPackageMonitor = new PackageMonitor() {
+ @Override
+ public void onPackageAdded(String packageName, int uid) {
+ ThreadUtils.postOnMainThread(() -> update());
+ }
+
+ @Override
+ public void onPackageModified(String packageName) {
+ ThreadUtils.postOnMainThread(() -> update());
+ }
+
+ @Override
+ public void onPackageRemoved(String packageName, int uid) {
+ ThreadUtils.postOnMainThread(() -> update());
+ }
+ };
+
+ /**
+ * Update the data in this UI.
+ */
+ private void update() {
+ if (mCredentialManager == null) {
+ return;
+ }
+
+ setAvailableServices(
+ mCredentialManager.getCredentialProviderServices(
+ getUser(), CredentialManager.PROVIDER_FILTER_USER_PROVIDERS_ONLY),
+ null);
+ }
+
/** Dialog fragment parent class. */
private abstract static class CredentialManagerDialogFragment extends DialogFragment
implements DialogInterface.OnClickListener {
diff --git a/src/com/android/settings/applications/intentpicker/AppLaunchSettings.java b/src/com/android/settings/applications/intentpicker/AppLaunchSettings.java
index b1ab1cc..cc662aa 100644
--- a/src/com/android/settings/applications/intentpicker/AppLaunchSettings.java
+++ b/src/com/android/settings/applications/intentpicker/AppLaunchSettings.java
@@ -281,12 +281,18 @@
final List<String> verifiedLinksList = IntentPickerUtils.getLinksList(
mDomainVerificationManager, mPackageName, DOMAIN_STATE_VERIFIED);
- return new AlertDialog.Builder(mContext)
+ AlertDialog dialog = new AlertDialog.Builder(mContext)
.setCustomTitle(titleView)
.setCancelable(true)
.setItems(verifiedLinksList.toArray(new String[0]), /* listener= */ null)
.setPositiveButton(R.string.app_launch_dialog_ok, /* listener= */ null)
.create();
+ if (dialog.getListView() != null) {
+ dialog.getListView().setTextDirection(View.TEXT_DIRECTION_LOCALE);
+ } else {
+ Log.w(TAG, "createVerifiedLinksDialog: dialog.getListView() is null, please check it.");
+ }
+ return dialog;
}
@VisibleForTesting
diff --git a/src/com/android/settings/applications/intentpicker/SupportedLinksAdapter.java b/src/com/android/settings/applications/intentpicker/SupportedLinksAdapter.java
index 9288d52..0716971 100644
--- a/src/com/android/settings/applications/intentpicker/SupportedLinksAdapter.java
+++ b/src/com/android/settings/applications/intentpicker/SupportedLinksAdapter.java
@@ -17,6 +17,8 @@
package com.android.settings.applications.intentpicker;
import android.content.Context;
+import android.graphics.drawable.Drawable;
+import android.util.Log;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
@@ -29,6 +31,7 @@
/** This adapter is for supported links dialog. */
public class SupportedLinksAdapter extends BaseAdapter {
+ private static final String TAG = "SupportedLinksAdapter";
private final Context mContext;
private final List<SupportedLinkWrapper> mWrapperList;
@@ -62,6 +65,14 @@
R.layout.supported_links_dialog_item, /* root= */ null);
}
final CheckedTextView textView = convertView.findViewById(android.R.id.text1);
+ Drawable[] drawables = textView.getCompoundDrawables();
+ if (mContext.getResources().getConfiguration().getLayoutDirection()
+ == View.LAYOUT_DIRECTION_RTL && drawables[0] != null) {
+ Log.d(TAG, "getView: RTL direction.");
+ // Set a checkbox position. It is same as the android:drawableRight attribute.
+ textView.setCompoundDrawables(/* left= */ null, /* top= */ null, drawables[0],
+ /* bottom= */ null);
+ }
textView.setText(mWrapperList.get(position).getDisplayTitle(mContext));
textView.setEnabled(mWrapperList.get(position).isEnabled());
textView.setChecked(mWrapperList.get(position).isChecked());
diff --git a/src/com/android/settings/applications/manageapplications/AppFilterRegistry.java b/src/com/android/settings/applications/manageapplications/AppFilterRegistry.java
index f319592..e7bb88d 100644
--- a/src/com/android/settings/applications/manageapplications/AppFilterRegistry.java
+++ b/src/com/android/settings/applications/manageapplications/AppFilterRegistry.java
@@ -30,6 +30,7 @@
import com.android.settings.applications.AppStateNotificationBridge;
import com.android.settings.applications.AppStateOverlayBridge;
import com.android.settings.applications.AppStatePowerBridge;
+import com.android.settings.applications.AppStateTurnScreenOnBridge;
import com.android.settings.applications.AppStateUsageBridge;
import com.android.settings.applications.AppStateWriteSettingsBridge;
import com.android.settings.nfc.AppStateNfcTagAppsBridge;
@@ -67,6 +68,7 @@
FILTER_LONG_BACKGROUND_TASKS,
FILTER_APPS_CLONE,
FILTER_APPS_NFC_TAG,
+ FILTER_APPS_TURN_SCREEN_ON,
})
@interface FilterType {}
@@ -98,8 +100,9 @@
public static final int FILTER_LONG_BACKGROUND_TASKS = 24;
public static final int FILTER_APPS_CLONE = 25;
public static final int FILTER_APPS_NFC_TAG = 26;
- private static final int NUM_FILTER_ENTRIES = 27;
- // Next id: 27. If you add an entry here, please change NUM_FILTER_ENTRIES.
+ public static final int FILTER_APPS_TURN_SCREEN_ON = 27;
+ private static final int NUM_FILTER_ENTRIES = 28;
+ // Next id: 28. If you add an entry here, please change NUM_FILTER_ENTRIES.
private static AppFilterRegistry sRegistry;
@@ -271,6 +274,12 @@
AppStateNfcTagAppsBridge.FILTER_APPS_NFC_TAG,
FILTER_APPS_NFC_TAG,
R.string.change_nfc_tag_apps_title);
+
+ // Apps that are allowed to turn the screen on.
+ mFilters[FILTER_APPS_TURN_SCREEN_ON] = new AppFilterItem(
+ AppStateTurnScreenOnBridge.FILTER_TURN_SCREEN_ON_APPS,
+ FILTER_APPS_TURN_SCREEN_ON,
+ R.string.turn_screen_on_title);
}
public static AppFilterRegistry getInstance() {
@@ -313,6 +322,8 @@
return FILTER_APPS_CLONE;
case ManageApplications.LIST_TYPE_NFC_TAG_APPS:
return FILTER_APPS_NFC_TAG;
+ case ManageApplications.LIST_TYPE_TURN_SCREEN_ON:
+ return FILTER_APPS_TURN_SCREEN_ON;
default:
return FILTER_APPS_ALL;
}
diff --git a/src/com/android/settings/applications/manageapplications/ManageApplications.java b/src/com/android/settings/applications/manageapplications/ManageApplications.java
index 0fbbf18..16b1b6c 100644
--- a/src/com/android/settings/applications/manageapplications/ManageApplications.java
+++ b/src/com/android/settings/applications/manageapplications/ManageApplications.java
@@ -110,6 +110,7 @@
import com.android.settings.Settings.NotificationAppListActivity;
import com.android.settings.Settings.NotificationReviewPermissionsActivity;
import com.android.settings.Settings.OverlaySettingsActivity;
+import com.android.settings.Settings.TurnScreenOnSettingsActivity;
import com.android.settings.Settings.UsageAccessSettingsActivity;
import com.android.settings.Settings.WriteSettingsActivity;
import com.android.settings.SettingsActivity;
@@ -129,6 +130,7 @@
import com.android.settings.applications.AppStateNotificationBridge.NotificationsSentState;
import com.android.settings.applications.AppStateOverlayBridge;
import com.android.settings.applications.AppStatePowerBridge;
+import com.android.settings.applications.AppStateTurnScreenOnBridge;
import com.android.settings.applications.AppStateUsageBridge;
import com.android.settings.applications.AppStateUsageBridge.UsageState;
import com.android.settings.applications.AppStateWriteSettingsBridge;
@@ -142,6 +144,7 @@
import com.android.settings.applications.appinfo.LongBackgroundTasksDetails;
import com.android.settings.applications.appinfo.ManageExternalStorageDetails;
import com.android.settings.applications.appinfo.MediaManagementAppsDetails;
+import com.android.settings.applications.appinfo.TurnScreenOnDetails;
import com.android.settings.applications.appinfo.WriteSettingsDetails;
import com.android.settings.core.InstrumentedFragment;
import com.android.settings.core.SubSettingLauncher;
@@ -268,6 +271,7 @@
public static final int LIST_TYPE_LONG_BACKGROUND_TASKS = 16;
public static final int LIST_TYPE_CLONED_APPS = 17;
public static final int LIST_TYPE_NFC_TAG_APPS = 18;
+ public static final int LIST_TYPE_TURN_SCREEN_ON = 19;
// List types that should show instant apps.
public static final Set<Integer> LIST_TYPES_WITH_INSTANT = new ArraySet<>(Arrays.asList(
@@ -569,6 +573,8 @@
return SettingsEnums.CLONED_APPS;
case LIST_TYPE_NFC_TAG_APPS:
return SettingsEnums.CONFIG_NFC_TAG_APP_PREF;
+ case LIST_TYPE_TURN_SCREEN_ON:
+ return SettingsEnums.SETTINGS_TURN_SCREEN_ON_ACCESS;
default:
return SettingsEnums.PAGE_UNKNOWN;
}
@@ -739,6 +745,9 @@
startAppInfoFragment(ChangeNfcTagAppsStateDetails.class,
R.string.change_nfc_tag_apps_title);
break;
+ case LIST_TYPE_TURN_SCREEN_ON:
+ startAppInfoFragment(TurnScreenOnDetails.class, R.string.turn_screen_on_title);
+ break;
// TODO: Figure out if there is a way where we can spin up the profile's settings
// process ahead of time, to avoid a long load of data when user clicks on a managed
// app. Maybe when they load the list of apps that contains managed profile apps.
@@ -1066,6 +1075,8 @@
screenTitle = R.string.cloned_apps_dashboard_title;
} else if (className.equals(ChangeNfcTagAppsActivity.class.getName())) {
screenTitle = R.string.change_nfc_tag_apps_title;
+ } else if (className.equals(TurnScreenOnSettingsActivity.class.getName())) {
+ screenTitle = R.string.turn_screen_on_title;
} else {
if (screenTitle == -1) {
screenTitle = R.string.all_apps;
@@ -1276,6 +1287,8 @@
mExtraInfoBridge = new AppStateClonedAppsBridge(mContext, mState, this);
} else if (mManageApplications.mListType == LIST_TYPE_NFC_TAG_APPS) {
mExtraInfoBridge = new AppStateNfcTagAppsBridge(mContext, mState, this);
+ } else if (mManageApplications.mListType == LIST_TYPE_TURN_SCREEN_ON) {
+ mExtraInfoBridge = new AppStateTurnScreenOnBridge(mContext, mState, this);
} else {
mExtraInfoBridge = null;
}
@@ -1830,6 +1843,9 @@
holder.setSummary(
ChangeNfcTagAppsStateDetails.getSummary(mContext, entry));
break;
+ case LIST_TYPE_TURN_SCREEN_ON:
+ holder.setSummary(TurnScreenOnDetails.getSummary(mContext, entry));
+ break;
default:
holder.updateSizeText(entry, mManageApplications.mInvalidSizeStr, mWhichSize);
break;
diff --git a/src/com/android/settings/applications/manageapplications/ManageApplicationsUtil.kt b/src/com/android/settings/applications/manageapplications/ManageApplicationsUtil.kt
index 6be5c20..78a4a6b 100644
--- a/src/com/android/settings/applications/manageapplications/ManageApplicationsUtil.kt
+++ b/src/com/android/settings/applications/manageapplications/ManageApplicationsUtil.kt
@@ -33,6 +33,7 @@
import com.android.settings.Settings.NotificationReviewPermissionsActivity
import com.android.settings.Settings.OverlaySettingsActivity
import com.android.settings.Settings.StorageUseActivity
+import com.android.settings.Settings.TurnScreenOnSettingsActivity
import com.android.settings.Settings.UsageAccessSettingsActivity
import com.android.settings.Settings.WriteSettingsActivity
import com.android.settings.applications.appinfo.AppLocaleDetails
@@ -51,6 +52,7 @@
import com.android.settings.applications.manageapplications.ManageApplications.LIST_TYPE_NOTIFICATION
import com.android.settings.applications.manageapplications.ManageApplications.LIST_TYPE_OVERLAY
import com.android.settings.applications.manageapplications.ManageApplications.LIST_TYPE_STORAGE
+import com.android.settings.applications.manageapplications.ManageApplications.LIST_TYPE_TURN_SCREEN_ON
import com.android.settings.applications.manageapplications.ManageApplications.LIST_TYPE_USAGE_ACCESS
import com.android.settings.applications.manageapplications.ManageApplications.LIST_TYPE_WIFI_ACCESS
import com.android.settings.applications.manageapplications.ManageApplications.LIST_TYPE_WRITE_SETTINGS
@@ -88,6 +90,7 @@
LongBackgroundTasksActivity::class to LIST_TYPE_LONG_BACKGROUND_TASKS,
ClonedAppsListActivity::class to LIST_TYPE_CLONED_APPS,
ChangeNfcTagAppsActivity::class to LIST_TYPE_NFC_TAG_APPS,
+ TurnScreenOnSettingsActivity::class to LIST_TYPE_TURN_SCREEN_ON,
)
@JvmField
diff --git a/src/com/android/settings/applications/specialaccess/turnscreenon/TurnScreenOnDetails.java b/src/com/android/settings/applications/specialaccess/turnscreenon/TurnScreenOnDetails.java
deleted file mode 100644
index 4540ab9..0000000
--- a/src/com/android/settings/applications/specialaccess/turnscreenon/TurnScreenOnDetails.java
+++ /dev/null
@@ -1,118 +0,0 @@
-/*
- * 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.applications.specialaccess.turnscreenon;
-
-import static android.app.AppOpsManager.MODE_ALLOWED;
-import static android.app.AppOpsManager.MODE_ERRORED;
-import static android.app.AppOpsManager.OP_TURN_SCREEN_ON;
-
-import android.app.AppOpsManager;
-import android.app.settings.SettingsEnums;
-import android.os.Bundle;
-
-import androidx.appcompat.app.AlertDialog;
-import androidx.preference.Preference;
-import androidx.preference.Preference.OnPreferenceChangeListener;
-import androidx.preference.SwitchPreference;
-
-import com.android.settings.R;
-import com.android.settings.applications.AppInfoWithHeader;
-
-/**
- * Detail page for turn screen on special app access.
- */
-public class TurnScreenOnDetails extends AppInfoWithHeader
- implements OnPreferenceChangeListener {
-
- private static final String KEY_APP_OPS_SETTINGS_SWITCH = "app_ops_settings_switch";
-
- private SwitchPreference mSwitchPref;
- private AppOpsManager mAppOpsManager;
-
- @Override
- public void onCreate(Bundle savedInstanceState) {
- super.onCreate(savedInstanceState);
-
- mAppOpsManager = this.getSystemService(AppOpsManager.class);
-
- // find preferences
- addPreferencesFromResource(R.xml.turn_screen_on_permissions_details);
- mSwitchPref = (SwitchPreference) findPreference(KEY_APP_OPS_SETTINGS_SWITCH);
-
- // set title/summary for all of them
- mSwitchPref.setTitle(R.string.allow_turn_screen_on);
-
- // install event listeners
- mSwitchPref.setOnPreferenceChangeListener(this);
- }
-
- @Override
- public boolean onPreferenceChange(Preference preference, Object newValue) {
- if (preference == mSwitchPref) {
- setTurnScreenOnAppOp(mPackageInfo.applicationInfo.uid, mPackageName,
- (Boolean) newValue);
- return true;
- }
- return false;
- }
-
- @Override
- protected boolean refreshUi() {
- boolean isAllowed = isTurnScreenOnAllowed(mAppOpsManager,
- mPackageInfo.applicationInfo.uid, mPackageName);
- mSwitchPref.setChecked(isAllowed);
- return true;
- }
-
- @Override
- protected AlertDialog createDialog(int id, int errorCode) {
- return null;
- }
-
- @Override
- public int getMetricsCategory() {
- return SettingsEnums.SETTINGS_MANAGE_TURN_SCREEN_ON;
- }
-
- /**
- * Sets whether the app associated with the given {@code packageName} is allowed to turn the
- * screen on.
- */
- void setTurnScreenOnAppOp(int uid, String packageName, boolean value) {
- final int newMode = value ? MODE_ALLOWED : MODE_ERRORED;
- mAppOpsManager.setMode(OP_TURN_SCREEN_ON, uid, packageName, newMode);
- }
-
- /**
- * @return whether the app associated with the given {@code packageName} is allowed to turn the
- * screen on.
- */
- static boolean isTurnScreenOnAllowed(AppOpsManager appOpsManager, int uid, String packageName) {
- return appOpsManager.checkOpNoThrow(OP_TURN_SCREEN_ON, uid, packageName) == MODE_ALLOWED;
- }
-
- /**
- * @return the summary for the current state of whether the app associated with the given
- * packageName is allowed to turn the screen on.
- */
- public static int getPreferenceSummary(AppOpsManager appOpsManager, int uid,
- String packageName) {
- final boolean enabled = TurnScreenOnDetails.isTurnScreenOnAllowed(appOpsManager, uid,
- packageName);
- return enabled ? R.string.app_permission_summary_allowed
- : R.string.app_permission_summary_not_allowed;
- }
-}
diff --git a/src/com/android/settings/applications/specialaccess/turnscreenon/TurnScreenOnSettings.java b/src/com/android/settings/applications/specialaccess/turnscreenon/TurnScreenOnSettings.java
deleted file mode 100644
index 742831e..0000000
--- a/src/com/android/settings/applications/specialaccess/turnscreenon/TurnScreenOnSettings.java
+++ /dev/null
@@ -1,215 +0,0 @@
-/*
- * 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.applications.specialaccess.turnscreenon;
-
-import android.Manifest;
-import android.annotation.Nullable;
-import android.app.AppOpsManager;
-import android.app.settings.SettingsEnums;
-import android.content.Context;
-import android.content.pm.ApplicationInfo;
-import android.content.pm.PackageInfo;
-import android.content.pm.PackageManager;
-import android.content.pm.UserInfo;
-import android.os.Bundle;
-import android.os.UserHandle;
-import android.os.UserManager;
-import android.util.IconDrawableFactory;
-import android.util.Pair;
-import android.view.View;
-
-import androidx.annotation.VisibleForTesting;
-import androidx.preference.Preference;
-import androidx.preference.Preference.OnPreferenceClickListener;
-import androidx.preference.PreferenceScreen;
-
-import com.android.settings.R;
-import com.android.settings.Utils;
-import com.android.settings.applications.AppInfoBase;
-import com.android.settings.search.BaseSearchIndexProvider;
-import com.android.settings.widget.EmptyTextSettings;
-import com.android.settingslib.search.SearchIndexable;
-import com.android.settingslib.widget.AppPreference;
-
-import java.text.Collator;
-import java.util.ArrayList;
-import java.util.Comparator;
-import java.util.List;
-
-/**
- * Settings page for providing special app access to turn the screen of the device on.
- */
-@SearchIndexable
-public class TurnScreenOnSettings extends EmptyTextSettings {
-
- @VisibleForTesting
- static final List<String> IGNORE_PACKAGE_LIST = new ArrayList<>();
-
- static {
- IGNORE_PACKAGE_LIST.add(Utils.SYSTEMUI_PACKAGE_NAME);
- }
-
- /**
- * Comparator by name, then user id.
- * {@see PackageItemInfo#DisplayNameComparator}
- */
- static class AppComparator implements Comparator<Pair<ApplicationInfo, Integer>> {
-
- private final Collator mCollator = Collator.getInstance();
- private final PackageManager mPm;
-
- AppComparator(PackageManager pm) {
- mPm = pm;
- }
-
- public final int compare(Pair<ApplicationInfo, Integer> a,
- Pair<ApplicationInfo, Integer> b) {
- CharSequence sa = a.first.loadLabel(mPm);
- if (sa == null) sa = a.first.name;
- CharSequence sb = b.first.loadLabel(mPm);
- if (sb == null) sb = b.first.name;
- int nameCmp = mCollator.compare(sa.toString(), sb.toString());
- if (nameCmp != 0) {
- return nameCmp;
- } else {
- return a.second - b.second;
- }
- }
- }
-
- private AppOpsManager mAppOpsManager;
- private Context mContext;
- private PackageManager mPackageManager;
- private UserManager mUserManager;
- private IconDrawableFactory mIconDrawableFactory;
-
- public TurnScreenOnSettings() {
- // Do nothing
- }
-
- public TurnScreenOnSettings(PackageManager pm, UserManager um) {
- mPackageManager = pm;
- mUserManager = um;
- }
-
- @Override
- public void onCreate(Bundle icicle) {
- super.onCreate(icicle);
-
- mContext = getActivity();
- mPackageManager = mContext.getPackageManager();
- mUserManager = mContext.getSystemService(UserManager.class);
- mAppOpsManager = mContext.getSystemService(AppOpsManager.class);
- mIconDrawableFactory = IconDrawableFactory.newInstance(mContext);
- }
-
- @Override
- public void onResume() {
- super.onResume();
-
- // Clear the prefs
- final PreferenceScreen screen = getPreferenceScreen();
- screen.removeAll();
-
- // Fetch the set of applications for each profile which have the permission required to turn
- // the screen on with a wake lock.
- final ArrayList<Pair<ApplicationInfo, Integer>> apps = collectTurnScreenOnApps(
- UserHandle.myUserId());
- apps.sort(new AppComparator(mPackageManager));
-
- // Rebuild the list of prefs
- final Context prefContext = getPrefContext();
- for (final Pair<ApplicationInfo, Integer> appData : apps) {
- final ApplicationInfo appInfo = appData.first;
- final int userId = appData.second;
- final UserHandle user = UserHandle.of(userId);
- final String packageName = appInfo.packageName;
- final CharSequence label = appInfo.loadLabel(mPackageManager);
-
- final Preference pref = new AppPreference(prefContext);
- pref.setIcon(mIconDrawableFactory.getBadgedIcon(appInfo, userId));
- pref.setTitle(mPackageManager.getUserBadgedLabel(label, user));
- pref.setSummary(TurnScreenOnDetails.getPreferenceSummary(mAppOpsManager,
- appInfo.uid, packageName));
- pref.setOnPreferenceClickListener(new OnPreferenceClickListener() {
- @Override
- public boolean onPreferenceClick(Preference preference) {
- AppInfoBase.startAppInfoFragment(TurnScreenOnDetails.class,
- getString(R.string.turn_screen_on_title),
- packageName, appInfo.uid,
- TurnScreenOnSettings.this, -1, getMetricsCategory());
- return true;
- }
- });
- screen.addPreference(pref);
- }
- }
-
- @Override
- public void onViewCreated(View view, @Nullable Bundle savedInstanceState) {
- super.onViewCreated(view, savedInstanceState);
- setEmptyText(R.string.no_applications);
- }
-
- @Override
- protected int getPreferenceScreenResId() {
- return R.xml.turn_screen_on_settings;
- }
-
- @Override
- public int getMetricsCategory() {
- return SettingsEnums.SETTINGS_TURN_SCREEN_ON_ACCESS;
- }
-
- /**
- * @return the list of applications for the given user and all their profiles that can turn on
- * the screen with wake locks.
- */
- @VisibleForTesting
- ArrayList<Pair<ApplicationInfo, Integer>> collectTurnScreenOnApps(int userId) {
- final ArrayList<Pair<ApplicationInfo, Integer>> apps = new ArrayList<>();
- final ArrayList<Integer> userIds = new ArrayList<>();
- for (UserInfo user : mUserManager.getProfiles(userId)) {
- userIds.add(user.id);
- }
-
- for (int id : userIds) {
- final List<PackageInfo> installedPackages = mPackageManager.getInstalledPackagesAsUser(
- /* flags= */ 0, id);
- for (PackageInfo packageInfo : installedPackages) {
- if (hasTurnScreenOnPermission(mPackageManager, packageInfo.packageName)) {
- apps.add(new Pair<>(packageInfo.applicationInfo, id));
- }
- }
- }
- return apps;
- }
-
- /**
- * @return true if the package has the permission to turn the screen on.
- */
- @VisibleForTesting
- static boolean hasTurnScreenOnPermission(PackageManager packageManager, String packageName) {
- if (IGNORE_PACKAGE_LIST.contains(packageName)) {
- return false;
- }
- return packageManager.checkPermission(Manifest.permission.TURN_SCREEN_ON, packageName)
- == PackageManager.PERMISSION_GRANTED;
- }
-
- public static final BaseSearchIndexProvider SEARCH_INDEX_DATA_PROVIDER =
- new BaseSearchIndexProvider(R.xml.turn_screen_on_settings);
-}
diff --git a/src/com/android/settings/biometrics/fingerprint/FingerprintSettings.java b/src/com/android/settings/biometrics/fingerprint/FingerprintSettings.java
index 59bbc13..40a719a 100644
--- a/src/com/android/settings/biometrics/fingerprint/FingerprintSettings.java
+++ b/src/com/android/settings/biometrics/fingerprint/FingerprintSettings.java
@@ -593,10 +593,16 @@
}
private void updateAddPreference() {
- if (getActivity() == null) return; // Activity went away
+ if (getActivity() == null) {
+ return; // Activity went away
+ }
final Preference addPreference = findPreference(KEY_FINGERPRINT_ADD);
+ if (addPreference == null) {
+ return; // b/275519315 Skip if updateAddPreference() invoke before addPreference()
+ }
+
/* Disable preference if too many fingerprints added */
final int max = getContext().getResources().getInteger(
com.android.internal.R.integer.config_fingerprintMaxTemplatesPerUser);
diff --git a/src/com/android/settings/biometrics2/ui/view/FingerprintEnrollmentActivity.java b/src/com/android/settings/biometrics2/ui/view/FingerprintEnrollmentActivity.java
index d84ce61..4a09eb9 100644
--- a/src/com/android/settings/biometrics2/ui/view/FingerprintEnrollmentActivity.java
+++ b/src/com/android/settings/biometrics2/ui/view/FingerprintEnrollmentActivity.java
@@ -66,7 +66,6 @@
import androidx.annotation.Nullable;
import androidx.fragment.app.Fragment;
import androidx.fragment.app.FragmentActivity;
-import androidx.fragment.app.FragmentManager;
import androidx.lifecycle.Observer;
import androidx.lifecycle.ViewModelProvider;
import androidx.lifecycle.viewmodel.CreationExtras;
@@ -194,11 +193,13 @@
// fragment
setContentView(R.layout.biometric_enrollment_container);
+ final Fragment fragment = getSupportFragmentManager().findFragmentById(
+ R.id.fragment_container_view);
if (DEBUG) {
- Log.e(TAG, "onCreate() has savedInstance:" + (savedInstanceState != null));
+ Log.d(TAG, "onCreate() has savedInstance:" + (savedInstanceState != null)
+ + ", fragment:" + fragment);
}
- if (savedInstanceState == null) {
- Log.d(TAG, "onCreate()"); // Use to differentiate biometrics v2
+ if (fragment == null) {
checkCredential();
final EnrollmentRequest request = mViewModel.getRequest();
if (request.isSkipFindSensor()) {
@@ -209,42 +210,26 @@
startIntroFragment();
}
} else {
- final FragmentManager manager = getSupportFragmentManager();
- String[] tags = new String[] {
- FINISH_TAG,
- ENROLLING_UDFPS_TAG,
- ENROLLING_SFPS_TAG,
- ENROLLING_RFPS_TAG,
- FIND_UDFPS_TAG,
- FIND_SFPS_TAG,
- FIND_RFPS_TAG,
- INTRO_TAG
- };
- for (String tag: tags) {
- final Fragment fragment = manager.findFragmentByTag(tag);
- if (fragment == null) {
- continue;
- }
- if (DEBUG) {
- Log.e(TAG, "onCreate() currentFragment:" + tag);
- }
- if (tag.equals(INTRO_TAG)) {
- attachIntroViewModel();
- } else if (tag.equals(FIND_UDFPS_TAG) || tag.equals(FIND_SFPS_TAG)
- || tag.equals(FIND_RFPS_TAG)) {
- attachFindSensorViewModel();
- attachIntroViewModel();
- } else if (tag.equals(ENROLLING_UDFPS_TAG) || tag.equals(ENROLLING_SFPS_TAG)
- || tag.equals(ENROLLING_RFPS_TAG)) {
- attachEnrollingViewModel();
- attachFindSensorViewModel();
- attachIntroViewModel();
- } else { // FINISH_TAG
- attachFinishViewModel();
- attachFindSensorViewModel();
- attachIntroViewModel();
- }
- break;
+ final String tag = fragment.getTag();
+ if (INTRO_TAG.equals(tag)) {
+ attachIntroViewModel();
+ } else if (FIND_UDFPS_TAG.equals(tag) || FIND_SFPS_TAG.equals(tag)
+ || FIND_RFPS_TAG.equals(tag)) {
+ attachFindSensorViewModel();
+ attachIntroViewModel();
+ } else if (ENROLLING_UDFPS_TAG.equals(tag) || ENROLLING_SFPS_TAG.equals(tag)
+ || ENROLLING_RFPS_TAG.equals(tag)) {
+ attachEnrollingViewModel();
+ attachFindSensorViewModel();
+ attachIntroViewModel();
+ } else if (FINISH_TAG.equals(tag)) {
+ attachFinishViewModel();
+ attachFindSensorViewModel();
+ attachIntroViewModel();
+ } else {
+ Log.e(TAG, "fragment tag " + tag + " not found");
+ finish();
+ return;
}
}
diff --git a/src/com/android/settings/core/gateway/SettingsGateway.java b/src/com/android/settings/core/gateway/SettingsGateway.java
index 836a544..149d1f4 100644
--- a/src/com/android/settings/core/gateway/SettingsGateway.java
+++ b/src/com/android/settings/core/gateway/SettingsGateway.java
@@ -50,6 +50,7 @@
import com.android.settings.applications.appinfo.LongBackgroundTasksDetails;
import com.android.settings.applications.appinfo.ManageExternalStorageDetails;
import com.android.settings.applications.appinfo.MediaManagementAppsDetails;
+import com.android.settings.applications.appinfo.TurnScreenOnDetails;
import com.android.settings.applications.appinfo.WriteSettingsDetails;
import com.android.settings.applications.appops.BackgroundCheckSummary;
import com.android.settings.applications.assist.ManageAssist;
@@ -62,8 +63,6 @@
import com.android.settings.applications.specialaccess.pictureinpicture.PictureInPictureDetails;
import com.android.settings.applications.specialaccess.pictureinpicture.PictureInPictureSettings;
import com.android.settings.applications.specialaccess.premiumsms.PremiumSmsAccess;
-import com.android.settings.applications.specialaccess.turnscreenon.TurnScreenOnDetails;
-import com.android.settings.applications.specialaccess.turnscreenon.TurnScreenOnSettings;
import com.android.settings.applications.specialaccess.vrlistener.VrListenerSettings;
import com.android.settings.applications.specialaccess.zenaccess.ZenAccessDetails;
import com.android.settings.backup.PrivacySettings;
@@ -368,7 +367,6 @@
OneHandedSettings.class.getName(),
MobileNetworkSettings.class.getName(),
AppLocaleDetails.class.getName(),
- TurnScreenOnSettings.class.getName(),
TurnScreenOnDetails.class.getName(),
NfcAndPaymentFragment.class.getName(),
ColorAndMotionFragment.class.getName(),
diff --git a/src/com/android/settings/development/ForcePeakRefreshRatePreferenceController.java b/src/com/android/settings/development/ForcePeakRefreshRatePreferenceController.java
index d5d4025..2e0a6b4 100644
--- a/src/com/android/settings/development/ForcePeakRefreshRatePreferenceController.java
+++ b/src/com/android/settings/development/ForcePeakRefreshRatePreferenceController.java
@@ -16,17 +16,18 @@
package com.android.settings.development;
+import static com.android.internal.display.RefreshRateSettingsUtils.DEFAULT_REFRESH_RATE;
+
import android.content.Context;
-import android.hardware.display.DisplayManager;
import android.provider.Settings;
import android.util.Log;
-import android.view.Display;
import androidx.annotation.VisibleForTesting;
import androidx.preference.Preference;
import androidx.preference.PreferenceScreen;
import androidx.preference.SwitchPreference;
+import com.android.internal.display.RefreshRateSettingsUtils;
import com.android.settings.R;
import com.android.settings.core.PreferenceControllerMixin;
import com.android.settingslib.development.DeveloperOptionsPreferenceController;
@@ -35,12 +36,6 @@
implements Preference.OnPreferenceChangeListener, PreferenceControllerMixin {
@VisibleForTesting
- static float DEFAULT_REFRESH_RATE = 60f;
-
- @VisibleForTesting
- static float NO_CONFIG = 0f;
-
- @VisibleForTesting
float mPeakRefreshRate;
private static final String TAG = "ForcePeakRefreshRateCtr";
@@ -48,17 +43,8 @@
public ForcePeakRefreshRatePreferenceController(Context context) {
super(context);
-
- final DisplayManager dm = context.getSystemService(DisplayManager.class);
- final Display display = dm.getDisplay(Display.DEFAULT_DISPLAY);
-
- if (display == null) {
- Log.w(TAG, "No valid default display device");
- mPeakRefreshRate = DEFAULT_REFRESH_RATE;
- } else {
- mPeakRefreshRate = findPeakRefreshRate(display.getSupportedModes());
- }
-
+ mPeakRefreshRate =
+ RefreshRateSettingsUtils.findHighestRefreshRateForDefaultDisplay(context);
Log.d(TAG, "DEFAULT_REFRESH_RATE : " + DEFAULT_REFRESH_RATE
+ " mPeakRefreshRate : " + mPeakRefreshRate);
}
@@ -99,34 +85,20 @@
@Override
protected void onDeveloperOptionsSwitchDisabled() {
super.onDeveloperOptionsSwitchDisabled();
- Settings.System.putFloat(mContext.getContentResolver(),
- Settings.System.MIN_REFRESH_RATE, NO_CONFIG);
+ Settings.System.putInt(mContext.getContentResolver(),
+ Settings.System.FORCE_PEAK_REFRESH_RATE, 0);
((SwitchPreference) mPreference).setChecked(false);
}
@VisibleForTesting
void forcePeakRefreshRate(boolean enable) {
- final float peakRefreshRate = enable ? mPeakRefreshRate : NO_CONFIG;
- Settings.System.putFloat(mContext.getContentResolver(),
- Settings.System.MIN_REFRESH_RATE, peakRefreshRate);
+ Settings.System.putInt(mContext.getContentResolver(),
+ Settings.System.FORCE_PEAK_REFRESH_RATE, enable ? 1 : 0);
}
boolean isForcePeakRefreshRateEnabled() {
- final float peakRefreshRate = Settings.System.getFloat(mContext.getContentResolver(),
- Settings.System.MIN_REFRESH_RATE, NO_CONFIG);
-
- return peakRefreshRate >= mPeakRefreshRate;
- }
-
- private float findPeakRefreshRate(Display.Mode[] modes) {
- float peakRefreshRate = DEFAULT_REFRESH_RATE;
- for (Display.Mode mode : modes) {
- if (Math.round(mode.getRefreshRate()) > peakRefreshRate) {
- peakRefreshRate = mode.getRefreshRate();
- }
- }
-
- return peakRefreshRate;
+ return Settings.System.getInt(mContext.getContentResolver(),
+ Settings.System.FORCE_PEAK_REFRESH_RATE, 0) == 1;
}
}
diff --git a/src/com/android/settings/display/PeakRefreshRatePreferenceController.java b/src/com/android/settings/display/PeakRefreshRatePreferenceController.java
index 31004d4..72eca5b 100644
--- a/src/com/android/settings/display/PeakRefreshRatePreferenceController.java
+++ b/src/com/android/settings/display/PeakRefreshRatePreferenceController.java
@@ -16,18 +16,20 @@
package com.android.settings.display;
+import static com.android.internal.display.RefreshRateSettingsUtils.DEFAULT_REFRESH_RATE;
+
import android.content.Context;
import android.hardware.display.DisplayManager;
import android.os.Handler;
import android.provider.DeviceConfig;
import android.provider.Settings;
import android.util.Log;
-import android.view.Display;
import androidx.annotation.VisibleForTesting;
import androidx.preference.Preference;
import androidx.preference.PreferenceScreen;
+import com.android.internal.display.RefreshRateSettingsUtils;
import com.android.settings.R;
import com.android.settings.core.TogglePreferenceController;
import com.android.settingslib.core.lifecycle.LifecycleObserver;
@@ -39,8 +41,6 @@
public class PeakRefreshRatePreferenceController extends TogglePreferenceController
implements LifecycleObserver, OnStart, OnStop {
- @VisibleForTesting static float DEFAULT_REFRESH_RATE = 60f;
-
@VisibleForTesting float mPeakRefreshRate;
private static final String TAG = "RefreshRatePrefCtr";
@@ -65,17 +65,8 @@
updateState(mPreference);
}
};
-
- final DisplayManager dm = mContext.getSystemService(DisplayManager.class);
- final Display display = dm.getDisplay(Display.DEFAULT_DISPLAY);
-
- if (display == null) {
- Log.w(TAG, "No valid default display device");
- mPeakRefreshRate = DEFAULT_REFRESH_RATE;
- } else {
- mPeakRefreshRate = findPeakRefreshRate(display.getSupportedModes());
- }
-
+ mPeakRefreshRate =
+ RefreshRateSettingsUtils.findHighestRefreshRateForDefaultDisplay(context);
Log.d(
TAG,
"DEFAULT_REFRESH_RATE : "
@@ -88,8 +79,7 @@
public void displayPreference(PreferenceScreen screen) {
super.displayPreference(screen);
- int defaultPeakRefreshRate = mContext.getResources().getInteger(
- com.android.internal.R.integer.config_defaultPeakRefreshRate);
+ int defaultPeakRefreshRate = Math.round(mPeakRefreshRate);
mPreference = screen.findPreference(getPreferenceKey());
mPreference.setSummary(mContext.getString(
@@ -107,21 +97,15 @@
@Override
public boolean isChecked() {
- final float peakRefreshRate =
- Settings.System.getFloat(
- mContext.getContentResolver(),
- Settings.System.PEAK_REFRESH_RATE,
- getDefaultPeakRefreshRate());
- return Math.round(peakRefreshRate) == Math.round(mPeakRefreshRate);
+ return Settings.System.getInt(mContext.getContentResolver(), Settings.System.SMOOTH_DISPLAY,
+ 0) == 1;
}
@Override
public boolean setChecked(boolean isChecked) {
- final float peakRefreshRate = isChecked ? mPeakRefreshRate : DEFAULT_REFRESH_RATE;
- Log.d(TAG, "setChecked to : " + peakRefreshRate);
-
- return Settings.System.putFloat(
- mContext.getContentResolver(), Settings.System.PEAK_REFRESH_RATE, peakRefreshRate);
+ Log.d(TAG, "setChecked to : " + isChecked);
+ return Settings.System.putInt(
+ mContext.getContentResolver(), Settings.System.SMOOTH_DISPLAY, isChecked ? 1 : 0);
}
@Override
@@ -139,17 +123,6 @@
mDeviceConfigDisplaySettings.stopListening();
}
- @VisibleForTesting
- float findPeakRefreshRate(Display.Mode[] modes) {
- float peakRefreshRate = DEFAULT_REFRESH_RATE;
- for (Display.Mode mode : modes) {
- if (Math.round(mode.getRefreshRate()) > peakRefreshRate) {
- peakRefreshRate = mode.getRefreshRate();
- }
- }
- return peakRefreshRate;
- }
-
private class DeviceConfigDisplaySettings
implements DeviceConfig.OnPropertiesChangedListener, Executor {
public void startListening() {
@@ -192,15 +165,4 @@
}
}
}
-
- private float getDefaultPeakRefreshRate() {
- float defaultPeakRefreshRate = mDeviceConfigDisplaySettings.getDefaultPeakRefreshRate();
- if (defaultPeakRefreshRate == INVALIDATE_REFRESH_RATE) {
- defaultPeakRefreshRate = (float) mContext.getResources().getInteger(
- com.android.internal.R.integer.config_defaultPeakRefreshRate);
- }
-
- Log.d(TAG, "DeviceConfig getDefaultPeakRefreshRate : " + defaultPeakRefreshRate);
- return defaultPeakRefreshRate;
- }
}
diff --git a/src/com/android/settings/fuelgauge/batterytip/tips/BatteryDefenderTip.java b/src/com/android/settings/fuelgauge/batterytip/tips/BatteryDefenderTip.java
index df0c192..15d8c99 100644
--- a/src/com/android/settings/fuelgauge/batterytip/tips/BatteryDefenderTip.java
+++ b/src/com/android/settings/fuelgauge/batterytip/tips/BatteryDefenderTip.java
@@ -55,7 +55,7 @@
@Override
public int getIconId() {
- return R.drawable.ic_battery_status_good_24dp;
+ return R.drawable.ic_battery_status_good_theme;
}
@Override
diff --git a/src/com/android/settings/fuelgauge/batterytip/tips/HighUsageTip.java b/src/com/android/settings/fuelgauge/batterytip/tips/HighUsageTip.java
index 0a7b1ab..47938fb 100644
--- a/src/com/android/settings/fuelgauge/batterytip/tips/HighUsageTip.java
+++ b/src/com/android/settings/fuelgauge/batterytip/tips/HighUsageTip.java
@@ -71,7 +71,7 @@
@Override
public int getIconId() {
- return R.drawable.ic_perm_device_information_red_24dp;
+ return R.drawable.ic_perm_device_information_theme;
}
@Override
diff --git a/src/com/android/settings/fuelgauge/batterytip/tips/IncompatibleChargerTip.java b/src/com/android/settings/fuelgauge/batterytip/tips/IncompatibleChargerTip.java
index c1616ea..dc9b804 100644
--- a/src/com/android/settings/fuelgauge/batterytip/tips/IncompatibleChargerTip.java
+++ b/src/com/android/settings/fuelgauge/batterytip/tips/IncompatibleChargerTip.java
@@ -48,7 +48,7 @@
@Override
public int getIconId() {
- return R.drawable.ic_battery_alert_24dp;
+ return R.drawable.ic_battery_alert_theme;
}
@Override
diff --git a/src/com/android/settings/fuelgauge/batterytip/tips/LowBatteryTip.java b/src/com/android/settings/fuelgauge/batterytip/tips/LowBatteryTip.java
index 7ec8811..aeff7e9 100644
--- a/src/com/android/settings/fuelgauge/batterytip/tips/LowBatteryTip.java
+++ b/src/com/android/settings/fuelgauge/batterytip/tips/LowBatteryTip.java
@@ -51,12 +51,7 @@
@Override
public int getIconId() {
- return mState = R.drawable.ic_battery_status_bad_24dp;
- }
-
- @Override
- public int getIconTintColorId() {
- return mState = R.color.battery_bad_color_light;
+ return mState = R.drawable.ic_battery_saver_accent_24dp;
}
@Override
diff --git a/src/com/android/settings/fuelgauge/batterytip/tips/RestrictAppTip.java b/src/com/android/settings/fuelgauge/batterytip/tips/RestrictAppTip.java
index 6fb1c9a..55ac3fa 100644
--- a/src/com/android/settings/fuelgauge/batterytip/tips/RestrictAppTip.java
+++ b/src/com/android/settings/fuelgauge/batterytip/tips/RestrictAppTip.java
@@ -93,8 +93,8 @@
@Override
public int getIconId() {
return mState == StateType.HANDLED
- ? R.drawable.ic_perm_device_information_green_24dp
- : R.drawable.ic_battery_alert_24dp;
+ ? R.drawable.ic_perm_device_information_theme
+ : R.drawable.ic_battery_alert_theme;
}
@Override
diff --git a/src/com/android/settings/fuelgauge/batterytip/tips/SmartBatteryTip.java b/src/com/android/settings/fuelgauge/batterytip/tips/SmartBatteryTip.java
index 106766f..0593e88 100644
--- a/src/com/android/settings/fuelgauge/batterytip/tips/SmartBatteryTip.java
+++ b/src/com/android/settings/fuelgauge/batterytip/tips/SmartBatteryTip.java
@@ -48,7 +48,7 @@
@Override
public int getIconId() {
- return R.drawable.ic_perm_device_information_red_24dp;
+ return R.drawable.ic_perm_device_information_theme;
}
@Override
diff --git a/src/com/android/settings/fuelgauge/batteryusage/BatteryUsageBreakdownController.java b/src/com/android/settings/fuelgauge/batteryusage/BatteryUsageBreakdownController.java
index cd1bdef..c272a49 100644
--- a/src/com/android/settings/fuelgauge/batteryusage/BatteryUsageBreakdownController.java
+++ b/src/com/android/settings/fuelgauge/batteryusage/BatteryUsageBreakdownController.java
@@ -177,8 +177,8 @@
mAppListPreferenceGroup.setOrderingAsAdded(false);
mSpinnerPreference.initializeSpinner(
new String[]{
- mPrefContext.getString(R.string.battery_usage_spinner_breakdown_by_apps),
- mPrefContext.getString(R.string.battery_usage_spinner_breakdown_by_system)
+ mPrefContext.getString(R.string.battery_usage_spinner_by_apps),
+ mPrefContext.getString(R.string.battery_usage_spinner_by_systems)
},
new AdapterView.OnItemSelectedListener() {
@Override
diff --git a/src/com/android/settings/privacy/AppDataSharingUpdatesPreferenceController.java b/src/com/android/settings/privacy/AppDataSharingUpdatesPreferenceController.java
index 2720ff6..5372a16 100644
--- a/src/com/android/settings/privacy/AppDataSharingUpdatesPreferenceController.java
+++ b/src/com/android/settings/privacy/AppDataSharingUpdatesPreferenceController.java
@@ -43,7 +43,7 @@
private boolean isPrivacySafetyLabelChangeNotificationsEnabled(Context context) {
PackageManager packageManager = context.getPackageManager();
return DeviceConfig.getBoolean(DeviceConfig.NAMESPACE_PRIVACY,
- SAFETY_LABEL_CHANGE_NOTIFICATIONS_ENABLED, false)
+ SAFETY_LABEL_CHANGE_NOTIFICATIONS_ENABLED, true)
&& !packageManager.hasSystemFeature(PackageManager.FEATURE_AUTOMOTIVE)
&& !packageManager.hasSystemFeature(PackageManager.FEATURE_LEANBACK)
&& !packageManager.hasSystemFeature(PackageManager.FEATURE_WATCH);
diff --git a/src/com/android/settings/safetycenter/BiometricsSafetySource.java b/src/com/android/settings/safetycenter/BiometricsSafetySource.java
index 74964ce..9dc5b4e 100644
--- a/src/com/android/settings/safetycenter/BiometricsSafetySource.java
+++ b/src/com/android/settings/safetycenter/BiometricsSafetySource.java
@@ -22,7 +22,9 @@
import android.hardware.face.FaceManager;
import android.hardware.fingerprint.FingerprintManager;
import android.os.Bundle;
+import android.os.Process;
import android.os.UserHandle;
+import android.os.UserManager;
import android.safetycenter.SafetyEvent;
import android.safetycenter.SafetySourceData;
import android.safetycenter.SafetySourceStatus;
@@ -43,8 +45,7 @@
private static final int REQUEST_CODE_FACE_SETTING = 20;
private static final int REQUEST_CODE_FINGERPRINT_SETTING = 30;
- private BiometricsSafetySource() {
- }
+ private BiometricsSafetySource() {}
/** Sets biometric safety data for Safety Center. */
public static void setSafetySourceData(Context context, SafetyEvent safetyEvent) {
@@ -52,41 +53,59 @@
return;
}
- final int userId = UserHandle.myUserId();
+ final UserHandle userHandle = Process.myUserHandle();
+ final int userId = userHandle.getIdentifier();
+ final UserManager userManager = UserManager.get(context);
+ UserHandle profileParentUserHandle = userManager.getProfileParent(userHandle);
+ if (profileParentUserHandle == null) {
+ profileParentUserHandle = userHandle;
+ }
+ final Context profileParentContext =
+ context.createContextAsUser(profileParentUserHandle, 0);
- final BiometricNavigationUtils biometricNavigationUtils = new BiometricNavigationUtils(
- userId);
+ final BiometricNavigationUtils biometricNavigationUtils =
+ new BiometricNavigationUtils(userId);
final CombinedBiometricStatusUtils combinedBiometricStatusUtils =
new CombinedBiometricStatusUtils(context, userId);
final ActiveUnlockStatusUtils activeUnlockStatusUtils =
new ActiveUnlockStatusUtils(context);
- if (activeUnlockStatusUtils.isAvailable()) {
+ if (!userManager.isProfile() && activeUnlockStatusUtils.isAvailable()) {
final RestrictedLockUtils.EnforcedAdmin disablingAdmin =
combinedBiometricStatusUtils.getDisablingAdmin();
- setBiometricSafetySourceData(context,
+ setBiometricSafetySourceData(
+ context,
activeUnlockStatusUtils.getTitleForActiveUnlock(),
combinedBiometricStatusUtils.getSummary(),
- createPendingIntent(context,
- biometricNavigationUtils.getBiometricSettingsIntent(context,
+ createPendingIntent(
+ context,
+ biometricNavigationUtils.getBiometricSettingsIntent(
+ context,
combinedBiometricStatusUtils.getSettingsClassName(),
- disablingAdmin, Bundle.EMPTY),
+ disablingAdmin,
+ Bundle.EMPTY),
REQUEST_CODE_COMBINED_BIOMETRIC_SETTING),
disablingAdmin == null /* enabled */,
combinedBiometricStatusUtils.hasEnrolled(),
safetyEvent);
return;
-
}
if (combinedBiometricStatusUtils.isAvailable()) {
final RestrictedLockUtils.EnforcedAdmin disablingAdmin =
combinedBiometricStatusUtils.getDisablingAdmin();
- setBiometricSafetySourceData(context,
+ setBiometricSafetySourceData(
+ context,
combinedBiometricStatusUtils.getTitle(),
combinedBiometricStatusUtils.getSummary(),
- createPendingIntent(context,
- biometricNavigationUtils.getBiometricSettingsIntent(context,
- combinedBiometricStatusUtils.getSettingsClassNameBasedOnUser(),
- disablingAdmin, Bundle.EMPTY),
+ createPendingIntent(
+ profileParentContext,
+ biometricNavigationUtils
+ .getBiometricSettingsIntent(
+ context,
+ combinedBiometricStatusUtils
+ .getSettingsClassNameBasedOnUser(),
+ disablingAdmin,
+ Bundle.EMPTY)
+ .setIdentifier(Integer.toString(userId)),
REQUEST_CODE_COMBINED_BIOMETRIC_SETTING),
disablingAdmin == null /* enabled */,
combinedBiometricStatusUtils.hasEnrolled(),
@@ -100,13 +119,19 @@
if (faceStatusUtils.isAvailable()) {
final RestrictedLockUtils.EnforcedAdmin disablingAdmin =
faceStatusUtils.getDisablingAdmin();
- setBiometricSafetySourceData(context,
+ setBiometricSafetySourceData(
+ context,
faceStatusUtils.getTitle(),
faceStatusUtils.getSummary(),
- createPendingIntent(context,
- biometricNavigationUtils.getBiometricSettingsIntent(context,
- faceStatusUtils.getSettingsClassName(), disablingAdmin,
- Bundle.EMPTY),
+ createPendingIntent(
+ profileParentContext,
+ biometricNavigationUtils
+ .getBiometricSettingsIntent(
+ context,
+ faceStatusUtils.getSettingsClassName(),
+ disablingAdmin,
+ Bundle.EMPTY)
+ .setIdentifier(Integer.toString(userId)),
REQUEST_CODE_FACE_SETTING),
disablingAdmin == null /* enabled */,
faceStatusUtils.hasEnrolled(),
@@ -116,19 +141,25 @@
}
final FingerprintManager fingerprintManager = Utils.getFingerprintManagerOrNull(context);
- final FingerprintStatusUtils fingerprintStatusUtils = new FingerprintStatusUtils(context,
- fingerprintManager, userId);
+ final FingerprintStatusUtils fingerprintStatusUtils =
+ new FingerprintStatusUtils(context, fingerprintManager, userId);
if (fingerprintStatusUtils.isAvailable()) {
final RestrictedLockUtils.EnforcedAdmin disablingAdmin =
fingerprintStatusUtils.getDisablingAdmin();
- setBiometricSafetySourceData(context,
+ setBiometricSafetySourceData(
+ context,
fingerprintStatusUtils.getTitle(),
fingerprintStatusUtils.getSummary(),
- createPendingIntent(context,
- biometricNavigationUtils.getBiometricSettingsIntent(context,
- fingerprintStatusUtils.getSettingsClassName(), disablingAdmin,
- Bundle.EMPTY),
+ createPendingIntent(
+ profileParentContext,
+ biometricNavigationUtils
+ .getBiometricSettingsIntent(
+ context,
+ fingerprintStatusUtils.getSettingsClassName(),
+ disablingAdmin,
+ Bundle.EMPTY)
+ .setIdentifier(Integer.toString(userId)),
REQUEST_CODE_FINGERPRINT_SETTING),
disablingAdmin == null /* enabled */,
fingerprintStatusUtils.hasEnrolled(),
@@ -140,33 +171,38 @@
public static void onBiometricsChanged(Context context) {
setSafetySourceData(
context,
- new SafetyEvent.Builder(SafetyEvent.SAFETY_EVENT_TYPE_SOURCE_STATE_CHANGED).build()
- );
+ new SafetyEvent.Builder(SafetyEvent.SAFETY_EVENT_TYPE_SOURCE_STATE_CHANGED)
+ .build());
}
- private static void setBiometricSafetySourceData(Context context, String title, String summary,
- PendingIntent pendingIntent, boolean enabled, boolean hasEnrolled,
+ private static void setBiometricSafetySourceData(
+ Context context,
+ String title,
+ String summary,
+ PendingIntent pendingIntent,
+ boolean enabled,
+ boolean hasEnrolled,
SafetyEvent safetyEvent) {
final int severityLevel =
- enabled && hasEnrolled ? SafetySourceData.SEVERITY_LEVEL_INFORMATION
+ enabled && hasEnrolled
+ ? SafetySourceData.SEVERITY_LEVEL_INFORMATION
: SafetySourceData.SEVERITY_LEVEL_UNSPECIFIED;
- final SafetySourceStatus status = new SafetySourceStatus.Builder(title, summary,
- severityLevel).setPendingIntent(pendingIntent).setEnabled(enabled).build();
+ final SafetySourceStatus status =
+ new SafetySourceStatus.Builder(title, summary, severityLevel)
+ .setPendingIntent(pendingIntent)
+ .setEnabled(enabled)
+ .build();
final SafetySourceData safetySourceData =
new SafetySourceData.Builder().setStatus(status).build();
- SafetyCenterManagerWrapper.get().setSafetySourceData(
- context, SAFETY_SOURCE_ID, safetySourceData, safetyEvent);
+ SafetyCenterManagerWrapper.get()
+ .setSafetySourceData(context, SAFETY_SOURCE_ID, safetySourceData, safetyEvent);
}
- private static PendingIntent createPendingIntent(Context context, Intent intent,
- int requestCode) {
- return PendingIntent
- .getActivity(
- context,
- requestCode,
- intent,
- PendingIntent.FLAG_IMMUTABLE);
+ private static PendingIntent createPendingIntent(
+ Context context, Intent intent, int requestCode) {
+ return PendingIntent.getActivity(
+ context, requestCode, intent, PendingIntent.FLAG_IMMUTABLE);
}
}
diff --git a/src/com/android/settings/spa/app/appinfo/AppBatteryPreference.kt b/src/com/android/settings/spa/app/appinfo/AppBatteryPreference.kt
index 4587bb2..0b4e7d5 100644
--- a/src/com/android/settings/spa/app/appinfo/AppBatteryPreference.kt
+++ b/src/com/android/settings/spa/app/appinfo/AppBatteryPreference.kt
@@ -54,7 +54,7 @@
if (!presenter.isAvailable()) return
Preference(object : PreferenceModel {
- override val title = stringResource(R.string.app_battery_usage_title)
+ override val title = stringResource(R.string.battery_details_title)
override val summary = presenter.summary
override val enabled = presenter.enabled
override val onClick = presenter::startActivity
diff --git a/src/com/android/settings/users/UserDetailsSettings.java b/src/com/android/settings/users/UserDetailsSettings.java
index 9a17982..2f9031e 100644
--- a/src/com/android/settings/users/UserDetailsSettings.java
+++ b/src/com/android/settings/users/UserDetailsSettings.java
@@ -41,6 +41,7 @@
import com.android.settingslib.RestrictedLockUtils;
import com.android.settingslib.RestrictedLockUtilsInternal;
import com.android.settingslib.RestrictedPreference;
+import com.android.settingslib.utils.CustomDialogHelper;
import java.util.concurrent.ExecutorService;
import java.util.concurrent.Executors;
@@ -74,6 +75,7 @@
private static final int DIALOG_CONFIRM_RESET_GUEST = 4;
private static final int DIALOG_CONFIRM_RESET_GUEST_AND_SWITCH_USER = 5;
private static final int DIALOG_CONFIRM_REVOKE_ADMIN = 6;
+ private static final int DIALOG_CONFIRM_GRANT_ADMIN = 7;
/** Whether to enable the app_copying fragment. */
private static final boolean SHOW_APP_COPYING_PREF = false;
@@ -188,11 +190,12 @@
mMetricsFeatureProvider.action(getActivity(),
SettingsEnums.ACTION_REVOKE_ADMIN_FROM_SETTINGS);
showDialog(DIALOG_CONFIRM_REVOKE_ADMIN);
- return false;
+ } else {
+ mMetricsFeatureProvider.action(getActivity(),
+ SettingsEnums.ACTION_GRANT_ADMIN_FROM_SETTINGS);
+ showDialog(DIALOG_CONFIRM_GRANT_ADMIN);
}
- mMetricsFeatureProvider.action(getActivity(),
- SettingsEnums.ACTION_GRANT_ADMIN_FROM_SETTINGS);
- updateUserAdminStatus(true);
+ return false;
}
return true;
}
@@ -208,6 +211,8 @@
return SettingsEnums.DIALOG_USER_ENABLE_CALLING_AND_SMS;
case DIALOG_CONFIRM_REVOKE_ADMIN:
return SettingsEnums.DIALOG_REVOKE_USER_ADMIN;
+ case DIALOG_CONFIRM_GRANT_ADMIN:
+ return SettingsEnums.DIALOG_GRANT_USER_ADMIN;
case DIALOG_SETUP_USER:
return SettingsEnums.DIALOG_USER_SETUP;
default:
@@ -252,13 +257,55 @@
(dialog, which) -> switchUser());
}
case DIALOG_CONFIRM_REVOKE_ADMIN:
- return UserDialogs.createConfirmRevokeAdmin(getActivity(),
- (dialog, which) -> updateUserAdminStatus(false));
+ return createRevokeAdminDialog(getContext());
+ case DIALOG_CONFIRM_GRANT_ADMIN:
+ return createGrantAdminDialog(getContext());
}
throw new IllegalArgumentException("Unsupported dialogId " + dialogId);
}
/**
+ * Creates dialog to confirm revoking admin rights.
+ * @return created confirmation dialog
+ */
+ private Dialog createRevokeAdminDialog(Context context) {
+ CustomDialogHelper dialogHelper = new CustomDialogHelper(context);
+ dialogHelper.setIcon(
+ context.getDrawable(com.android.settingslib.R.drawable.ic_admin_panel_settings));
+ dialogHelper.setTitle(R.string.user_revoke_admin_confirm_title);
+ dialogHelper.setMessage(R.string.user_revoke_admin_confirm_message);
+ dialogHelper.setPositiveButton(R.string.remove, view -> {
+ updateUserAdminStatus(false);
+ dialogHelper.getDialog().dismiss();
+ });
+ dialogHelper.setBackButton(R.string.cancel, view -> {
+ dialogHelper.getDialog().dismiss();
+ });
+ return dialogHelper.getDialog();
+ }
+
+ /**
+ * Creates dialog to confirm granting admin rights.
+ * @return created confirmation dialog
+ */
+ private Dialog createGrantAdminDialog(Context context) {
+ CustomDialogHelper dialogHelper = new CustomDialogHelper(context);
+ dialogHelper.setIcon(
+ context.getDrawable(com.android.settingslib.R.drawable.ic_admin_panel_settings));
+ dialogHelper.setTitle(com.android.settingslib.R.string.user_grant_admin_title);
+ dialogHelper.setMessage(com.android.settingslib.R.string.user_grant_admin_message);
+ dialogHelper.setPositiveButton(com.android.settingslib.R.string.user_grant_admin_button,
+ view -> {
+ updateUserAdminStatus(true);
+ dialogHelper.getDialog().dismiss();
+ });
+ dialogHelper.setBackButton(R.string.cancel, view -> {
+ dialogHelper.getDialog().dismiss();
+ });
+ return dialogHelper.getDialog();
+ }
+
+ /**
* Erase the current guest user and create a new one in the background. UserSettings will
* handle guest creation after receiving the {@link UserSettings.RESULT_GUEST_REMOVED} result.
*/
diff --git a/src/com/android/settings/users/UserDialogs.java b/src/com/android/settings/users/UserDialogs.java
index 1e26eff..c2f2528 100644
--- a/src/com/android/settings/users/UserDialogs.java
+++ b/src/com/android/settings/users/UserDialogs.java
@@ -202,19 +202,4 @@
.setNegativeButton(android.R.string.cancel, null)
.create();
}
-
- /**
- * Creates a dialog to confirm that the admin privileges of the user should be revoked.
- *
- * @param onConfirmListener Callback object for positive action
- */
- public static Dialog createConfirmRevokeAdmin(Context context,
- DialogInterface.OnClickListener onConfirmListener) {
- return new AlertDialog.Builder(context)
- .setTitle(R.string.user_revoke_admin_confirm_title)
- .setMessage(R.string.user_revoke_admin_confirm_message)
- .setPositiveButton(R.string.remove, onConfirmListener)
- .setNegativeButton(android.R.string.cancel, null)
- .create();
- }
}
diff --git a/tests/robotests/src/com/android/settings/applications/appinfo/TurnScreenOnDetailsTest.java b/tests/robotests/src/com/android/settings/applications/appinfo/TurnScreenOnDetailsTest.java
new file mode 100644
index 0000000..180b805
--- /dev/null
+++ b/tests/robotests/src/com/android/settings/applications/appinfo/TurnScreenOnDetailsTest.java
@@ -0,0 +1,142 @@
+/*
+ * 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.applications.appinfo;
+
+import static com.google.common.truth.Truth.assertThat;
+
+import static org.mockito.ArgumentMatchers.anyInt;
+import static org.mockito.ArgumentMatchers.nullable;
+import static org.mockito.Mockito.verify;
+import static org.mockito.Mockito.when;
+
+import android.content.pm.ApplicationInfo;
+import android.content.pm.PackageInfo;
+
+import androidx.preference.SwitchPreference;
+
+import com.android.settings.applications.AppStateAppOpsBridge;
+import com.android.settings.applications.AppStateTurnScreenOnBridge;
+
+import org.junit.Before;
+import org.junit.Test;
+import org.junit.runner.RunWith;
+import org.mockito.Mock;
+import org.mockito.MockitoAnnotations;
+import org.robolectric.RobolectricTestRunner;
+import org.robolectric.util.ReflectionHelpers;
+
+@RunWith(RobolectricTestRunner.class)
+public class TurnScreenOnDetailsTest {
+
+ @Mock
+ private SwitchPreference mSwitchPref;
+ @Mock
+ private PackageInfo mPackageInfo;
+ @Mock
+ private AppStateTurnScreenOnBridge mAppStateBridge;
+ @Mock
+ private AppStateAppOpsBridge.PermissionState mPermissionState;
+
+ private final TurnScreenOnDetails mFragment = new TurnScreenOnDetails();
+
+
+
+ @Before
+ public void setUp() {
+ MockitoAnnotations.initMocks(this);
+ ReflectionHelpers.setField(mFragment, "mSwitchPref", mSwitchPref);
+ ReflectionHelpers.setField(mFragment, "mAppBridge", mAppStateBridge);
+ }
+
+ @Test
+ public void refreshUi_noPackageInfo_shouldReturnFalseAndNoCrash() {
+ mFragment.refreshUi();
+
+ assertThat(mFragment.refreshUi()).isFalse();
+ // should not crash
+ }
+
+ @Test
+ public void refreshUi_noApplicationInfo_shouldReturnFalseAndNoCrash() {
+ ReflectionHelpers.setField(mFragment, "mPackageInfo", mPackageInfo);
+
+ mFragment.refreshUi();
+
+ assertThat(mFragment.refreshUi()).isFalse();
+ // should not crash
+ }
+
+ @Test
+ public void refreshUi_hasApplicationInfo_shouldReturnTrue() {
+ ReflectionHelpers.setField(mFragment, "mPackageInfo", mPackageInfo);
+ mPackageInfo.applicationInfo = new ApplicationInfo();
+ when(mAppStateBridge.getPermissionInfo(nullable(String.class), anyInt()))
+ .thenReturn(mPermissionState);
+
+ mFragment.refreshUi();
+
+ assertThat(mFragment.refreshUi()).isTrue();
+ }
+
+ @Test
+ public void refreshUi_permissionNotDeclared_switchPreferenceDisabled() {
+ ReflectionHelpers.setField(mFragment, "mPackageInfo", mPackageInfo);
+ mPackageInfo.applicationInfo = new ApplicationInfo();
+ when(mAppStateBridge.getPermissionInfo(nullable(String.class), anyInt()))
+ .thenReturn(mPermissionState);
+ mPermissionState.permissionDeclared = false;
+
+ mFragment.refreshUi();
+ verify(mSwitchPref).setEnabled(false);
+ }
+
+ @Test
+ public void refreshUi_permissionDeclared_switchPreferenceEnabled() {
+ ReflectionHelpers.setField(mFragment, "mPackageInfo", mPackageInfo);
+ mPackageInfo.applicationInfo = new ApplicationInfo();
+ when(mAppStateBridge.getPermissionInfo(nullable(String.class), anyInt()))
+ .thenReturn(mPermissionState);
+ mPermissionState.permissionDeclared = true;
+
+ mFragment.refreshUi();
+ verify(mSwitchPref).setEnabled(true);
+ }
+
+ @Test
+ public void refreshUi_turnScreenOnAllowed_switchPreferenceChecked() {
+ ReflectionHelpers.setField(mFragment, "mPackageInfo", mPackageInfo);
+ mPackageInfo.applicationInfo = new ApplicationInfo();
+ when(mAppStateBridge.getPermissionInfo(nullable(String.class), anyInt()))
+ .thenReturn(mPermissionState);
+
+ when(mPermissionState.isPermissible()).thenReturn(true);
+ mFragment.refreshUi();
+ verify(mSwitchPref).setChecked(true);
+ }
+
+ @Test
+ public void refreshUi_turnScreenOnDisallowed_switchPreferenceUnchecked() {
+ ReflectionHelpers.setField(mFragment, "mPackageInfo", mPackageInfo);
+ mPackageInfo.applicationInfo = new ApplicationInfo();
+ when(mAppStateBridge.getPermissionInfo(nullable(String.class), anyInt()))
+ .thenReturn(mPermissionState);
+
+ when(mPermissionState.isPermissible()).thenReturn(false);
+ mFragment.refreshUi();
+ verify(mSwitchPref).setChecked(false);
+ }
+}
diff --git a/tests/robotests/src/com/android/settings/applications/specialaccess/turnscreenon/TurnScreenOnDetailsTest.java b/tests/robotests/src/com/android/settings/applications/specialaccess/turnscreenon/TurnScreenOnDetailsTest.java
deleted file mode 100644
index c27ad2b..0000000
--- a/tests/robotests/src/com/android/settings/applications/specialaccess/turnscreenon/TurnScreenOnDetailsTest.java
+++ /dev/null
@@ -1,74 +0,0 @@
-/*
- * 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.applications.specialaccess.turnscreenon;
-
-import static android.app.AppOpsManager.MODE_ALLOWED;
-import static android.app.AppOpsManager.MODE_ERRORED;
-import static android.app.AppOpsManager.OP_TURN_SCREEN_ON;
-
-import static com.google.common.truth.Truth.assertThat;
-
-import static org.mockito.ArgumentMatchers.eq;
-import static org.mockito.Mockito.when;
-
-import android.app.AppOpsManager;
-
-import org.junit.Before;
-import org.junit.Test;
-import org.junit.runner.RunWith;
-import org.mockito.Mock;
-import org.mockito.MockitoAnnotations;
-import org.robolectric.RobolectricTestRunner;
-
-@RunWith(RobolectricTestRunner.class)
-public class TurnScreenOnDetailsTest {
-
- private static final int UID = 0;
- private static final String PACKAGE_NAME = "com.android.fake.package";
-
- @Mock
- private AppOpsManager mAppOpsManager;
-
-
-
- @Before
- public void setUp() {
- MockitoAnnotations.initMocks(this);
- }
-
- @Test
- public void isTurnScreenOnAllowed_appOpErrored_shouldReturnFalse() {
- when(mAppOpsManager.checkOpNoThrow(eq(OP_TURN_SCREEN_ON), eq(UID),
- eq(PACKAGE_NAME))).thenReturn(MODE_ERRORED);
-
- boolean isAllowed = TurnScreenOnDetails.isTurnScreenOnAllowed(mAppOpsManager, UID,
- PACKAGE_NAME);
-
- assertThat(isAllowed).isFalse();
- }
-
- @Test
- public void isTurnScreenOnAllowed_appOpAllowed_shouldReturnTrue() {
- when(mAppOpsManager.checkOpNoThrow(eq(OP_TURN_SCREEN_ON), eq(UID),
- eq(PACKAGE_NAME))).thenReturn(MODE_ALLOWED);
-
- boolean isAllowed = TurnScreenOnDetails.isTurnScreenOnAllowed(mAppOpsManager, UID,
- PACKAGE_NAME);
-
- assertThat(isAllowed).isTrue();
- }
-}
diff --git a/tests/robotests/src/com/android/settings/applications/specialaccess/turnscreenon/TurnScreenOnSettingsTest.java b/tests/robotests/src/com/android/settings/applications/specialaccess/turnscreenon/TurnScreenOnSettingsTest.java
deleted file mode 100644
index a260211..0000000
--- a/tests/robotests/src/com/android/settings/applications/specialaccess/turnscreenon/TurnScreenOnSettingsTest.java
+++ /dev/null
@@ -1,188 +0,0 @@
-/*
- * 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.applications.specialaccess.turnscreenon;
-
-
-import static com.google.common.truth.Truth.assertThat;
-
-import static org.mockito.ArgumentMatchers.anyInt;
-import static org.mockito.ArgumentMatchers.eq;
-import static org.mockito.Mockito.when;
-
-import android.Manifest;
-import android.content.pm.ApplicationInfo;
-import android.content.pm.PackageInfo;
-import android.content.pm.PackageManager;
-import android.content.pm.UserInfo;
-import android.os.UserManager;
-import android.util.Pair;
-
-import com.android.settings.testutils.FakeFeatureFactory;
-
-import com.google.common.collect.ImmutableList;
-
-import org.junit.Before;
-import org.junit.Test;
-import org.junit.runner.RunWith;
-import org.mockito.Mock;
-import org.mockito.MockitoAnnotations;
-import org.robolectric.RobolectricTestRunner;
-
-import java.util.ArrayList;
-import java.util.List;
-
-@RunWith(RobolectricTestRunner.class)
-public class TurnScreenOnSettingsTest {
-
- private static final int PRIMARY_USER_ID = 0;
- private static final int PROFILE_USER_ID = 10;
-
- private TurnScreenOnSettings mFragment;
- @Mock
- private PackageManager mPackageManager;
- @Mock
- private UserManager mUserManager;
- private ArrayList<PackageInfo> mPrimaryUserPackages;
- private ArrayList<PackageInfo> mProfileUserPackages;
-
- @Before
- public void setUp() {
- MockitoAnnotations.initMocks(this);
- FakeFeatureFactory.setupForTest();
- mFragment = new TurnScreenOnSettings(mPackageManager, mUserManager);
- mPrimaryUserPackages = new ArrayList<>();
- mProfileUserPackages = new ArrayList<>();
- when(mPackageManager.getInstalledPackagesAsUser(anyInt(), eq(PRIMARY_USER_ID)))
- .thenReturn(mPrimaryUserPackages);
- when(mPackageManager.getInstalledPackagesAsUser(anyInt(), eq(PROFILE_USER_ID)))
- .thenReturn(mProfileUserPackages);
-
- UserInfo primaryUserInfo = new UserInfo();
- primaryUserInfo.id = PRIMARY_USER_ID;
- UserInfo profileUserInfo = new UserInfo();
- profileUserInfo.id = PROFILE_USER_ID;
-
- when(mUserManager.getProfiles(PRIMARY_USER_ID))
- .thenReturn(ImmutableList.of(primaryUserInfo, profileUserInfo));
- }
-
- @Test
- public void testCollectTurnScreenOnApps_variousPackages_shouldReturnOnlyPackagesWithTurnScreenOnPermission() {
- PackageInfo primaryP1 = createPackage("Calculator", true);
- PackageInfo primaryP2 = createPackage("Clock", false);
- PackageInfo profileP1 = createPackage("Browser", false);
- PackageInfo profileP2 = createPackage("Files", true);
- mPrimaryUserPackages.add(primaryP1);
- mPrimaryUserPackages.add(primaryP2);
- mProfileUserPackages.add(profileP1);
- mProfileUserPackages.add(profileP2);
-
- List<Pair<ApplicationInfo, Integer>> apps = mFragment.collectTurnScreenOnApps(
- PRIMARY_USER_ID);
-
- assertThat(containsPackages(apps, primaryP1, profileP2)).isTrue();
- assertThat(containsPackages(apps, primaryP2, profileP1)).isFalse();
- }
-
- @Test
- public void collectTurnScreenOnApps_noTurnScreenOnPackages_shouldReturnEmptyList() {
- PackageInfo primaryP1 = createPackage("Calculator", false);
- PackageInfo profileP1 = createPackage("Browser", false);
- mPrimaryUserPackages.add(primaryP1);
- mProfileUserPackages.add(profileP1);
-
- List<Pair<ApplicationInfo, Integer>> apps = mFragment.collectTurnScreenOnApps(
- PRIMARY_USER_ID);
-
- assertThat(apps).isEmpty();
- }
-
- @Test
- public void sort_multiplePackages_appsShouldBeOrderedByAppName() {
- PackageInfo primaryP1 = createPackage("Android", true);
- PackageInfo primaryP2 = createPackage("Boop", true);
- PackageInfo primaryP3 = createPackage("Deck", true);
- PackageInfo profileP1 = createPackage("Android", true);
- PackageInfo profileP2 = createPackage("Cool", true);
- PackageInfo profileP3 = createPackage("Fast", false);
- mPrimaryUserPackages.add(primaryP1);
- mPrimaryUserPackages.add(primaryP2);
- mPrimaryUserPackages.add(primaryP3);
- mProfileUserPackages.add(profileP1);
- mProfileUserPackages.add(profileP2);
- mProfileUserPackages.add(profileP3);
- List<Pair<ApplicationInfo, Integer>> apps = mFragment.collectTurnScreenOnApps(
- PRIMARY_USER_ID);
-
- apps.sort(new TurnScreenOnSettings.AppComparator(null));
-
- assertThat(isOrdered(apps, primaryP1, profileP1, primaryP2, profileP2, primaryP3)).isTrue();
- }
-
- @Test
- public void hasTurnScreenOnPermission_ignoredPackages_shouldReturnFalse() {
- boolean res = false;
-
- for (String ignoredPackage : TurnScreenOnSettings.IGNORE_PACKAGE_LIST) {
- res |= TurnScreenOnSettings.hasTurnScreenOnPermission(mPackageManager, ignoredPackage);
- }
-
- assertThat(res).isFalse();
- }
-
- private boolean containsPackages(List<Pair<ApplicationInfo, Integer>> apps,
- PackageInfo... packages) {
- for (PackageInfo aPackage : packages) {
- boolean found = false;
- for (Pair<ApplicationInfo, Integer> app : apps) {
- if (app.first == aPackage.applicationInfo) {
- found = true;
- break;
- }
- }
- if (!found) {
- return false;
- }
- }
- return true;
- }
-
- private boolean isOrdered(List<Pair<ApplicationInfo, Integer>> apps, PackageInfo... packages) {
- if (apps.size() != packages.length) {
- return false;
- }
-
- for (int i = 0; i < packages.length; i++) {
- if (packages[i].applicationInfo != apps.get(i).first) {
- return false;
- }
- }
- return true;
- }
-
- private PackageInfo createPackage(String packageName, boolean hasTurnScreenOnPermission) {
- PackageInfo pi = new PackageInfo();
- when(mPackageManager.checkPermission(Manifest.permission.TURN_SCREEN_ON,
- packageName)).thenReturn(
- hasTurnScreenOnPermission ? PackageManager.PERMISSION_GRANTED
- : PackageManager.PERMISSION_DENIED);
- pi.packageName = packageName;
- pi.applicationInfo = new ApplicationInfo();
- pi.applicationInfo.name = packageName;
- return pi;
- }
-}
diff --git a/tests/robotests/src/com/android/settings/development/ForcePeakRefreshRatePreferenceControllerTest.java b/tests/robotests/src/com/android/settings/development/ForcePeakRefreshRatePreferenceControllerTest.java
index 2e93d5e..7dfde38 100644
--- a/tests/robotests/src/com/android/settings/development/ForcePeakRefreshRatePreferenceControllerTest.java
+++ b/tests/robotests/src/com/android/settings/development/ForcePeakRefreshRatePreferenceControllerTest.java
@@ -16,8 +16,8 @@
package com.android.settings.development;
-import static com.android.settings.development.ForcePeakRefreshRatePreferenceController.DEFAULT_REFRESH_RATE;
-import static com.android.settings.development.ForcePeakRefreshRatePreferenceController.NO_CONFIG;
+import static com.android.internal.display.RefreshRateSettingsUtils.DEFAULT_REFRESH_RATE;
+
import static com.google.common.truth.Truth.assertThat;
import static org.mockito.Mockito.verify;
@@ -38,8 +38,6 @@
import org.robolectric.RuntimeEnvironment;
import org.robolectric.annotation.Config;
-import android.util.Log;
-
@RunWith(RobolectricTestRunner.class)
public class ForcePeakRefreshRatePreferenceControllerTest {
@@ -63,22 +61,18 @@
@Test
public void onPreferenceChange_preferenceChecked_shouldEnableForcePeak() {
- mController.mPeakRefreshRate = 88f;
-
mController.onPreferenceChange(mPreference, true);
- assertThat(Settings.System.getFloat(mContext.getContentResolver(),
- Settings.System.MIN_REFRESH_RATE, NO_CONFIG)).isEqualTo(88f);
+ assertThat(Settings.System.getInt(mContext.getContentResolver(),
+ Settings.System.FORCE_PEAK_REFRESH_RATE, -1)).isEqualTo(1);
}
@Test
public void onPreferenceChange_preferenceUnchecked_shouldDisableForcePeak() {
- mController.mPeakRefreshRate = 88f;
-
mController.onPreferenceChange(mPreference, false);
- assertThat(Settings.System.getFloat(mContext.getContentResolver(),
- Settings.System.MIN_REFRESH_RATE, NO_CONFIG)).isEqualTo(NO_CONFIG);
+ assertThat(Settings.System.getInt(mContext.getContentResolver(),
+ Settings.System.FORCE_PEAK_REFRESH_RATE, -1)).isEqualTo(0);
}
@Test
@@ -125,8 +119,8 @@
public void onDeveloperOptionsDisabled_shouldDisablePreference() {
mController.onDeveloperOptionsSwitchDisabled();
- assertThat(Settings.System.getFloat(mContext.getContentResolver(),
- Settings.System.MIN_REFRESH_RATE, -1f)).isEqualTo(NO_CONFIG);
+ assertThat(Settings.System.getInt(mContext.getContentResolver(),
+ Settings.System.FORCE_PEAK_REFRESH_RATE, -1)).isEqualTo(0);
assertThat(mPreference.isChecked()).isFalse();
assertThat(mPreference.isEnabled()).isFalse();
}
diff --git a/tests/robotests/src/com/android/settings/display/PeakRefreshRatePreferenceControllerTest.java b/tests/robotests/src/com/android/settings/display/PeakRefreshRatePreferenceControllerTest.java
index aaeeea4..9c3644e 100644
--- a/tests/robotests/src/com/android/settings/display/PeakRefreshRatePreferenceControllerTest.java
+++ b/tests/robotests/src/com/android/settings/display/PeakRefreshRatePreferenceControllerTest.java
@@ -16,15 +16,14 @@
package com.android.settings.display;
+import static com.android.internal.display.RefreshRateSettingsUtils.DEFAULT_REFRESH_RATE;
import static com.android.settings.core.BasePreferenceController.AVAILABLE;
import static com.android.settings.core.BasePreferenceController.UNSUPPORTED_ON_DEVICE;
-import static com.android.settings.display.PeakRefreshRatePreferenceController.DEFAULT_REFRESH_RATE;
import static com.google.common.truth.Truth.assertThat;
import android.content.Context;
import android.provider.Settings;
-import android.view.Display;
import androidx.preference.SwitchPreference;
@@ -70,23 +69,21 @@
}
@Test
- public void setChecked_enableSmoothDisplay_setCurrentRefreshRate() {
- mController.mPeakRefreshRate = 88f;
+ public void setChecked_enableSmoothDisplay() {
mController.setChecked(true);
- assertThat(Settings.System.getFloat(mContext.getContentResolver(),
- Settings.System.PEAK_REFRESH_RATE, DEFAULT_REFRESH_RATE))
- .isEqualTo(88.0f);
+ assertThat(Settings.System.getInt(mContext.getContentResolver(),
+ Settings.System.SMOOTH_DISPLAY, -1))
+ .isEqualTo(1);
}
@Test
- public void setChecked_disableSmoothDisplay_setDefaultRefreshRate() {
- mController.mPeakRefreshRate = 88f;
+ public void setChecked_disableSmoothDisplay() {
mController.setChecked(false);
- assertThat(Settings.System.getFloat(mContext.getContentResolver(),
- Settings.System.PEAK_REFRESH_RATE, DEFAULT_REFRESH_RATE))
- .isEqualTo(DEFAULT_REFRESH_RATE);
+ assertThat(Settings.System.getInt(mContext.getContentResolver(),
+ Settings.System.SMOOTH_DISPLAY, -1))
+ .isEqualTo(0);
}
@Test
@@ -103,36 +100,21 @@
assertThat(mController.isChecked()).isFalse();
}
- @Test
- public void findPeakRefreshRate_moreThanOneHigherThanDefault() {
- Display.Mode lower = new Display.Mode(0, 0, 0, DEFAULT_REFRESH_RATE - 1);
- Display.Mode def = new Display.Mode(0, 0, 0, DEFAULT_REFRESH_RATE);
- Display.Mode higher = new Display.Mode(0, 0, 0, DEFAULT_REFRESH_RATE + 1);
- Display.Mode higher1 = new Display.Mode(0, 0, 0, DEFAULT_REFRESH_RATE + 2);
-
- assertThat(mController.findPeakRefreshRate(
- new Display.Mode[] {lower, def, higher, higher1}))
- .isEqualTo(DEFAULT_REFRESH_RATE + 2);
- assertThat(mController.findPeakRefreshRate(
- new Display.Mode[] {lower, def, higher1, higher}))
- .isEqualTo(DEFAULT_REFRESH_RATE + 2);
- }
-
private void enableSmoothDisplayPreference() {
mController.mPeakRefreshRate = 88f;
- Settings.System.putFloat(
+ Settings.System.putInt(
mContext.getContentResolver(),
- Settings.System.PEAK_REFRESH_RATE,
- mController.mPeakRefreshRate);
+ Settings.System.SMOOTH_DISPLAY,
+ 1);
}
private void disableSmoothDisplayPreference() {
mController.mPeakRefreshRate = 88f;
- Settings.System.putFloat(
+ Settings.System.putInt(
mContext.getContentResolver(),
- Settings.System.PEAK_REFRESH_RATE,
- DEFAULT_REFRESH_RATE);
+ Settings.System.SMOOTH_DISPLAY,
+ 0);
}
}
diff --git a/tests/robotests/src/com/android/settings/fuelgauge/batterytip/tips/BatteryDefenderTipTest.java b/tests/robotests/src/com/android/settings/fuelgauge/batterytip/tips/BatteryDefenderTipTest.java
index 244c394..eee2df3 100644
--- a/tests/robotests/src/com/android/settings/fuelgauge/batterytip/tips/BatteryDefenderTipTest.java
+++ b/tests/robotests/src/com/android/settings/fuelgauge/batterytip/tips/BatteryDefenderTipTest.java
@@ -85,7 +85,7 @@
@Test
public void getIcon_showIcon() {
assertThat(mBatteryDefenderTip.getIconId())
- .isEqualTo(R.drawable.ic_battery_status_good_24dp);
+ .isEqualTo(R.drawable.ic_battery_status_good_theme);
}
@Test
diff --git a/tests/robotests/src/com/android/settings/fuelgauge/batterytip/tips/IncompatibleChargerTipTest.java b/tests/robotests/src/com/android/settings/fuelgauge/batterytip/tips/IncompatibleChargerTipTest.java
index 9f74e1b..a5f1ab3 100644
--- a/tests/robotests/src/com/android/settings/fuelgauge/batterytip/tips/IncompatibleChargerTipTest.java
+++ b/tests/robotests/src/com/android/settings/fuelgauge/batterytip/tips/IncompatibleChargerTipTest.java
@@ -85,7 +85,7 @@
@Test
public void getIcon_showIcon() {
assertThat(mIncompatibleChargerTip.getIconId())
- .isEqualTo(R.drawable.ic_battery_alert_24dp);
+ .isEqualTo(R.drawable.ic_battery_alert_theme);
}
@Test
diff --git a/tests/robotests/src/com/android/settings/fuelgauge/batterytip/tips/LowBatteryTipTest.java b/tests/robotests/src/com/android/settings/fuelgauge/batterytip/tips/LowBatteryTipTest.java
index 108a1dd..3f42231 100644
--- a/tests/robotests/src/com/android/settings/fuelgauge/batterytip/tips/LowBatteryTipTest.java
+++ b/tests/robotests/src/com/android/settings/fuelgauge/batterytip/tips/LowBatteryTipTest.java
@@ -70,8 +70,7 @@
mContext.getString(R.string.battery_tip_low_battery_title));
assertThat(mLowBatteryTip.getSummary(mContext)).isEqualTo(
mContext.getString(R.string.battery_tip_low_battery_summary));
- assertThat(mLowBatteryTip.getIconId()).isEqualTo(R.drawable.ic_battery_status_bad_24dp);
- assertThat(mLowBatteryTip.getIconTintColorId()).isEqualTo(R.color.battery_bad_color_light);
+ assertThat(mLowBatteryTip.getIconId()).isEqualTo(R.drawable.ic_battery_saver_accent_24dp);
}
@Test
diff --git a/tests/robotests/src/com/android/settings/fuelgauge/batteryusage/BatteryChartPreferenceControllerTest.java b/tests/robotests/src/com/android/settings/fuelgauge/batteryusage/BatteryChartPreferenceControllerTest.java
index 9cebd19..e1c193c 100644
--- a/tests/robotests/src/com/android/settings/fuelgauge/batteryusage/BatteryChartPreferenceControllerTest.java
+++ b/tests/robotests/src/com/android/settings/fuelgauge/batteryusage/BatteryChartPreferenceControllerTest.java
@@ -332,7 +332,7 @@
mBatteryChartPreferenceController.mHourlyChartIndex = 2;
assertThat(mBatteryChartPreferenceController.getSlotInformation()).isEqualTo(
- "10 AM - 12 PM");
+ "10 AM - 12 PM");
}
@Test
@@ -342,7 +342,7 @@
mBatteryChartPreferenceController.mHourlyChartIndex = 8;
assertThat(mBatteryChartPreferenceController.getSlotInformation()).isEqualTo(
- "Sunday 4 PM - 6 PM");
+ "Sunday 4 PM - 6 PM");
}
@Test
@@ -352,7 +352,7 @@
mBatteryChartPreferenceController.mHourlyChartIndex = 0;
assertThat(mBatteryChartPreferenceController.getSlotInformation()).isEqualTo(
- "7:01 AM - 8 AM");
+ "7:01 AM - 8 AM");
}
@Test
@@ -362,7 +362,7 @@
mBatteryChartPreferenceController.mHourlyChartIndex = 3;
assertThat(mBatteryChartPreferenceController.getSlotInformation()).isEqualTo(
- "12 PM - now");
+ "12 PM - now");
}
@Test
@@ -372,7 +372,7 @@
mBatteryChartPreferenceController.mHourlyChartIndex = 0;
assertThat(mBatteryChartPreferenceController.getSlotInformation()).isEqualTo(
- "7:01 AM - now");
+ "7:01 AM - now");
}
@Test
diff --git a/tests/spa_unit/src/com/android/settings/spa/app/appinfo/AppBatteryPreferenceTest.kt b/tests/spa_unit/src/com/android/settings/spa/app/appinfo/AppBatteryPreferenceTest.kt
index 8f1a9a2..a7a54e6 100644
--- a/tests/spa_unit/src/com/android/settings/spa/app/appinfo/AppBatteryPreferenceTest.kt
+++ b/tests/spa_unit/src/com/android/settings/spa/app/appinfo/AppBatteryPreferenceTest.kt
@@ -101,7 +101,7 @@
setContent(notInstalledApp)
- composeTestRule.onNode(hasTextExactly(context.getString(R.string.app_battery_usage_title)))
+ composeTestRule.onNode(hasTextExactly(context.getString(R.string.battery_details_title)))
.assertIsDisplayed()
.assertIsNotEnabled()
}
@@ -114,7 +114,7 @@
composeTestRule.onNode(
hasTextExactly(
- context.getString(R.string.app_battery_usage_title),
+ context.getString(R.string.battery_details_title),
context.getString(R.string.no_battery_summary),
),
).assertIsDisplayed().assertIsEnabled()
diff --git a/tests/uitests/src/com/android/settings/biometrics2/ui/view/FingerprintEnrollmentActivityTest.java b/tests/uitests/src/com/android/settings/biometrics2/ui/view/FingerprintEnrollmentActivityTest.java
index ae32651..3cd0009 100644
--- a/tests/uitests/src/com/android/settings/biometrics2/ui/view/FingerprintEnrollmentActivityTest.java
+++ b/tests/uitests/src/com/android/settings/biometrics2/ui/view/FingerprintEnrollmentActivityTest.java
@@ -56,12 +56,15 @@
private static final String ACTIVITY_CLASS_NAME =
"com.android.settings.biometrics2.ui.view.FingerprintEnrollmentActivity";
private static final String EXTRA_IS_SETUP_FLOW = "isSetupFlow";
+ private static final String EXTRA_SKIP_INTRO = "skip_intro";
private static final String EXTRA_SKIP_FIND_SENSOR = "skip_find_sensor";
private static final String EXTRA_FROM_SETTINGS_SUMMARY = "from_settings_summary";
private static final String EXTRA_PAGE_TRANSITION_TYPE = "page_transition_type";
private static final String EXTRA_KEY_GK_PW_HANDLE = "gk_pw_handle";
private static final String TEST_PIN = "1234";
+ private static final String DO_IT_LATER = "Do it later";
+
private static final String UDFPS_ENROLLING_TITLE = "Touch & hold the fingerprint sensor";
private static final String SFPS_ENROLLING_TITLE =
"Lift, then touch. Move your finger slightly each time.";
@@ -120,6 +123,12 @@
mDevice.pressHome();
}
+ @After
+ public void tearDown() throws Exception {
+ LockScreenUtil.resetLockscreen(TEST_PIN);
+ mDevice.pressHome();
+ }
+
@Test
public void testIntroChooseLock() {
final Intent intent = newActivityIntent();
@@ -165,7 +174,7 @@
agreeBtn.click();
// FindUdfps page
- assertThat(mDevice.wait(Until.hasObject(By.text("Do it later")), IDLE_TIMEOUT)).isTrue();
+ assertThat(mDevice.wait(Until.hasObject(By.text(DO_IT_LATER)), IDLE_TIMEOUT)).isTrue();
final UiObject2 lottie = mDevice.findObject(By.res(SETTINGS_PACKAGE_NAME,
"illustration_lottie"));
assertThat(lottie).isNotNull();
@@ -193,7 +202,7 @@
agreeBtn.click();
// FindUdfps page
- assertThat(mDevice.wait(Until.hasObject(By.text("Do it later")), IDLE_TIMEOUT)).isTrue();
+ assertThat(mDevice.wait(Until.hasObject(By.text(DO_IT_LATER)), IDLE_TIMEOUT)).isTrue();
final UiObject2 lottie = mDevice.findObject(By.res(SETTINGS_PACKAGE_NAME,
"illustration_lottie"));
assertThat(lottie).isNotNull();
@@ -221,7 +230,7 @@
agreeBtn.click();
// FindSfps page
- assertThat(mDevice.wait(Until.hasObject(By.text("Do it later")), IDLE_TIMEOUT)).isTrue();
+ assertThat(mDevice.wait(Until.hasObject(By.text(DO_IT_LATER)), IDLE_TIMEOUT)).isTrue();
final UiObject2 lottie = mDevice.findObject(By.res(SETTINGS_PACKAGE_NAME,
"illustration_lottie"));
assertThat(lottie).isNotNull();
@@ -244,7 +253,7 @@
agreeBtn.click();
// FindRfps page
- assertThat(mDevice.wait(Until.hasObject(By.text("Do it later")), IDLE_TIMEOUT)).isTrue();
+ assertThat(mDevice.wait(Until.hasObject(By.text(DO_IT_LATER)), IDLE_TIMEOUT)).isTrue();
final UiObject2 lottie = mDevice.findObject(By.res(SETTINGS_PACKAGE_NAME,
"illustration_lottie"));
if (lottie == null) {
@@ -284,15 +293,15 @@
agreeBtn.click();
// FindSensor page
- assertThat(mDevice.wait(Until.hasObject(By.text("Do it later")), IDLE_TIMEOUT)).isTrue();
- final UiObject2 doItLaterBtn = mDevice.findObject(By.text("Do it later"));
+ assertThat(mDevice.wait(Until.hasObject(By.text(DO_IT_LATER)), IDLE_TIMEOUT)).isTrue();
+ final UiObject2 doItLaterBtn = mDevice.findObject(By.text(DO_IT_LATER));
assertThat(doItLaterBtn).isNotNull();
assertThat(doItLaterBtn.isClickable()).isTrue();
doItLaterBtn.click();
// Back to home
mDevice.waitForWindowUpdate("com.android.settings", IDLE_TIMEOUT);
- assertThat(mDevice.findObject(By.text("Do it later"))).isNull();
+ assertThat(mDevice.findObject(By.text(DO_IT_LATER))).isNull();
}
@Test
@@ -308,8 +317,8 @@
agreeBtn.click();
// FindSensor page
- assertThat(mDevice.wait(Until.hasObject(By.text("Do it later")), IDLE_TIMEOUT)).isTrue();
- final UiObject2 doItLaterBtn = mDevice.findObject(By.text("Do it later"));
+ assertThat(mDevice.wait(Until.hasObject(By.text(DO_IT_LATER)), IDLE_TIMEOUT)).isTrue();
+ final UiObject2 doItLaterBtn = mDevice.findObject(By.text(DO_IT_LATER));
assertThat(doItLaterBtn).isNotNull();
assertThat(doItLaterBtn.isClickable()).isTrue();
doItLaterBtn.click();
@@ -325,7 +334,7 @@
// Back to home
mDevice.waitForWindowUpdate("com.android.settings", IDLE_TIMEOUT);
assertThat(mDevice.findObject(By.text("Skip anyway"))).isNull();
- assertThat(mDevice.findObject(By.text("Do it later"))).isNull();
+ assertThat(mDevice.findObject(By.text(DO_IT_LATER))).isNull();
}
@Test
@@ -341,8 +350,8 @@
agreeBtn.click();
// FindSensor page
- assertThat(mDevice.wait(Until.hasObject(By.text("Do it later")), IDLE_TIMEOUT)).isTrue();
- final UiObject2 doItLaterBtn = mDevice.findObject(By.text("Do it later"));
+ assertThat(mDevice.wait(Until.hasObject(By.text(DO_IT_LATER)), IDLE_TIMEOUT)).isTrue();
+ final UiObject2 doItLaterBtn = mDevice.findObject(By.text(DO_IT_LATER));
assertThat(doItLaterBtn).isNotNull();
assertThat(doItLaterBtn.isClickable()).isTrue();
doItLaterBtn.click();
@@ -356,7 +365,7 @@
goBackBtn.click();
// FindSensor page again
- assertThat(mDevice.wait(Until.hasObject(By.text("Do it later")), IDLE_TIMEOUT)).isTrue();
+ assertThat(mDevice.wait(Until.hasObject(By.text(DO_IT_LATER)), IDLE_TIMEOUT)).isTrue();
}
@Test
@@ -447,10 +456,103 @@
assertThat(mDevice.wait(Until.hasObject(By.text(mEnrollingTitle)), IDLE_TIMEOUT)).isTrue();
}
- @After
- public void tearDown() throws Exception {
- LockScreenUtil.resetLockscreen(TEST_PIN);
- mDevice.pressHome();
+ @Test
+ public void testFindUdfpsWithGkPwHandle_clickStart() {
+ assumeTrue(mCanAssumeUdfps);
+
+ LockScreenUtil.setLockscreen(LockScreenUtil.LockscreenType.PIN, TEST_PIN, true);
+
+ launchFindSensorWithGkPwHandle();
+
+ // FindUdfps page
+ assertThat(mDevice.wait(Until.hasObject(By.text(DO_IT_LATER)), IDLE_TIMEOUT)).isTrue();
+ final UiObject2 lottie = mDevice.findObject(By.res(SETTINGS_PACKAGE_NAME,
+ "illustration_lottie"));
+ assertThat(lottie).isNotNull();
+ assertThat(lottie.isClickable()).isTrue();
+ final UiObject2 startBtn = mDevice.findObject(By.text("Start"));
+ assertThat(startBtn.isClickable()).isTrue();
+ startBtn.click();
+
+ // Enrolling page
+ assertThat(mDevice.wait(Until.hasObject(By.text(mEnrollingTitle)), IDLE_TIMEOUT)).isTrue();
+ }
+
+ @Test
+ public void testFindUdfpsWithGkPwHandle_clickLottie() {
+ assumeTrue(mCanAssumeUdfps);
+
+ LockScreenUtil.setLockscreen(LockScreenUtil.LockscreenType.PIN, TEST_PIN, true);
+
+ launchFindSensorWithGkPwHandle();
+
+ // FindUdfps page
+ assertThat(mDevice.wait(Until.hasObject(By.text(DO_IT_LATER)), IDLE_TIMEOUT)).isTrue();
+ final UiObject2 lottie = mDevice.findObject(By.res(SETTINGS_PACKAGE_NAME,
+ "illustration_lottie"));
+ assertThat(lottie).isNotNull();
+ assertThat(lottie.isClickable()).isTrue();
+ final UiObject2 startBtn = mDevice.findObject(By.text("Start"));
+ assertThat(startBtn.isClickable()).isTrue();
+ lottie.click();
+
+ // Enrolling page
+ assertThat(mDevice.wait(Until.hasObject(By.text(mEnrollingTitle)), IDLE_TIMEOUT)).isTrue();
+ }
+
+ @Test
+ public void testFindSfpsWithGkPwHandle() {
+ assumeTrue(mCanAssumeSfps);
+
+ LockScreenUtil.setLockscreen(LockScreenUtil.LockscreenType.PIN, TEST_PIN, true);
+
+ launchFindSensorWithGkPwHandle();
+
+ // FindSfps page
+ assertThat(mDevice.wait(Until.hasObject(By.text(DO_IT_LATER)), IDLE_TIMEOUT)).isTrue();
+ final UiObject2 lottie = mDevice.findObject(By.res(SETTINGS_PACKAGE_NAME,
+ "illustration_lottie"));
+ assertThat(lottie).isNotNull();
+
+ // We don't have view which can be clicked to run to next page, stop at here.
+ }
+
+ @Test
+ public void testFindRfpsWithGkPwHandle() {
+ assumeFalse(mCanAssumeUdfps || mCanAssumeSfps);
+
+ LockScreenUtil.setLockscreen(LockScreenUtil.LockscreenType.PIN, TEST_PIN, true);
+
+ launchFindSensorWithGkPwHandle();
+
+ // FindRfps page
+ assertThat(mDevice.wait(Until.hasObject(By.text(DO_IT_LATER)), IDLE_TIMEOUT)).isTrue();
+ final UiObject2 lottie = mDevice.findObject(By.res(SETTINGS_PACKAGE_NAME,
+ "illustration_lottie"));
+ if (lottie == null) {
+ // FindSfps page shall have an animation view if no lottie view
+ assertThat(mDevice.findObject(By.res(SETTINGS_PACKAGE_NAME,
+ "fingerprint_sensor_location_animation"))).isNotNull();
+ }
+ }
+
+
+ @Test
+ public void testFindSensorWithGkPwHandle_clickSkipInFindSensor() {
+ LockScreenUtil.setLockscreen(LockScreenUtil.LockscreenType.PIN, TEST_PIN, true);
+
+ launchFindSensorWithGkPwHandle();
+
+ // FindSensor page
+ assertThat(mDevice.wait(Until.hasObject(By.text(DO_IT_LATER)), IDLE_TIMEOUT)).isTrue();
+ final UiObject2 doItLaterBtn = mDevice.findObject(By.text(DO_IT_LATER));
+ assertThat(doItLaterBtn).isNotNull();
+ assertThat(doItLaterBtn.isClickable()).isTrue();
+ doItLaterBtn.click();
+
+ // Back to home
+ mDevice.waitForWindowUpdate("com.android.settings", IDLE_TIMEOUT);
+ assertThat(mDevice.findObject(By.text(DO_IT_LATER))).isNull();
}
private void launchIntroWithGkPwHandle(boolean isSuw) {
@@ -469,6 +571,20 @@
userId, LockPatternUtils.VERIFY_FLAG_REQUEST_GK_PW_HANDLE, onVerifyCallback);
}
+ private void launchFindSensorWithGkPwHandle() {
+ LockPatternUtils lockPatternUtils = new LockPatternUtils(mContext);
+ final LockscreenCredential lockscreenCredential = LockscreenCredential.createPin(TEST_PIN);
+ final int userId = UserHandle.myUserId();
+ final LockPatternChecker.OnVerifyCallback onVerifyCallback = (response, timeoutMs) -> {
+ final Intent intent = newActivityIntent();
+ intent.putExtra(EXTRA_SKIP_INTRO, true);
+ intent.putExtra(EXTRA_KEY_GK_PW_HANDLE, response.getGatekeeperPasswordHandle());
+ mContext.startActivity(intent);
+ };
+ LockPatternChecker.verifyCredential(lockPatternUtils, lockscreenCredential,
+ userId, LockPatternUtils.VERIFY_FLAG_REQUEST_GK_PW_HANDLE, onVerifyCallback);
+ }
+
private void launchEnrollingWithGkPwHandle() {
LockPatternUtils lockPatternUtils = new LockPatternUtils(mContext);
final LockscreenCredential lockscreenCredential = LockscreenCredential.createPin(TEST_PIN);
diff --git a/tests/unit/src/com/android/settings/applications/credentials/CredentialManagerPreferenceControllerTest.java b/tests/unit/src/com/android/settings/applications/credentials/CredentialManagerPreferenceControllerTest.java
index b02cf1c..2a2aaee 100644
--- a/tests/unit/src/com/android/settings/applications/credentials/CredentialManagerPreferenceControllerTest.java
+++ b/tests/unit/src/com/android/settings/applications/credentials/CredentialManagerPreferenceControllerTest.java
@@ -484,7 +484,7 @@
CredentialManagerPreferenceController controller =
new CredentialManagerPreferenceController(
mContext, mCredentialsPreferenceCategory.getKey());
- controller.setAvailableServices(() -> mock(Lifecycle.class), availableServices, addServiceOverride);
+ controller.setAvailableServices(availableServices, addServiceOverride);
controller.setDelegate(mDelegate);
return controller;
}
diff --git a/tests/unit/src/com/android/settings/applications/manageapplications/AppFilterRegistryTest.java b/tests/unit/src/com/android/settings/applications/manageapplications/AppFilterRegistryTest.java
index ff5c0d8..023fc0f 100644
--- a/tests/unit/src/com/android/settings/applications/manageapplications/AppFilterRegistryTest.java
+++ b/tests/unit/src/com/android/settings/applications/manageapplications/AppFilterRegistryTest.java
@@ -23,6 +23,7 @@
import static com.android.settings.applications.manageapplications.AppFilterRegistry.FILTER_APPS_MEDIA_MANAGEMENT;
import static com.android.settings.applications.manageapplications.AppFilterRegistry.FILTER_APPS_POWER_ALLOWLIST;
import static com.android.settings.applications.manageapplications.AppFilterRegistry.FILTER_APPS_RECENT;
+import static com.android.settings.applications.manageapplications.AppFilterRegistry.FILTER_APPS_TURN_SCREEN_ON;
import static com.android.settings.applications.manageapplications.AppFilterRegistry.FILTER_APPS_USAGE_ACCESS;
import static com.android.settings.applications.manageapplications.AppFilterRegistry.FILTER_APPS_WITH_OVERLAY;
import static com.android.settings.applications.manageapplications.AppFilterRegistry.FILTER_APPS_WRITE_SETTINGS;
@@ -38,6 +39,7 @@
import static com.android.settings.applications.manageapplications.ManageApplications.LIST_TYPE_NOTIFICATION;
import static com.android.settings.applications.manageapplications.ManageApplications.LIST_TYPE_OVERLAY;
import static com.android.settings.applications.manageapplications.ManageApplications.LIST_TYPE_STORAGE;
+import static com.android.settings.applications.manageapplications.ManageApplications.LIST_TYPE_TURN_SCREEN_ON;
import static com.android.settings.applications.manageapplications.ManageApplications.LIST_TYPE_USAGE_ACCESS;
import static com.android.settings.applications.manageapplications.ManageApplications.LIST_TYPE_WRITE_SETTINGS;
@@ -82,5 +84,8 @@
assertThat(registry.getDefaultFilterType(LIST_TYPE_LONG_BACKGROUND_TASKS))
.isEqualTo(FILTER_LONG_BACKGROUND_TASKS);
+
+ assertThat(registry.getDefaultFilterType(LIST_TYPE_TURN_SCREEN_ON)).isEqualTo(
+ FILTER_APPS_TURN_SCREEN_ON);
}
}