Merge "Add Wi-Fi hotspot > Security Settings page" into udc-dev
diff --git a/AndroidManifest.xml b/AndroidManifest.xml
index a6a354e..6aad2af 100644
--- a/AndroidManifest.xml
+++ b/AndroidManifest.xml
@@ -1358,7 +1358,7 @@
<activity
android:name="Settings$SmartAutoRotateSettingsActivity"
android:label="@string/accelerometer_title"
- android:icon="@drawable/ic_screen_rotation_24dp"
+ android:icon="@drawable/ic_screen_rotation"
android:exported="true">
<intent-filter android:priority="1">
<action android:name="android.settings.AUTO_ROTATE_SETTINGS" />
@@ -2955,13 +2955,6 @@
</intent-filter>
</activity>
- <activity android:name=".bluetooth.RequestPermissionHelperActivity"
- android:label="@string/bluetooth_pairing_request"
- android:excludeFromRecents="true"
- android:permission="android.permission.BLUETOOTH_CONNECT"
- android:theme="@*android:style/Theme.DeviceDefault.Dialog.Alert.DayNight">
- </activity>
-
<service android:name=".bluetooth.BluetoothPairingService" />
<receiver android:name=".bluetooth.BluetoothPairingRequest"
diff --git a/OWNERS b/OWNERS
index 8938b64..6d4f95f 100644
--- a/OWNERS
+++ b/OWNERS
@@ -2,22 +2,18 @@
android-settings-core-eng+gerrit@google.com
# People who can approve changes for submission
-arcwang@google.com
cantol@google.com
chaohuiw@google.com
chiujason@google.com
-cyl@google.com
+dswliu@google.com
edgarwang@google.com
-llz@google.com
millchen@google.com
songchenxi@google.com
-stanleytfwang@google.com
sunnyshao@google.com
yantingyang@google.com
ykhung@google.com
# Emergency only
-lijun@google.com
wangqi@google.com
yanglu@google.com
diff --git a/color-check-baseline.xml b/color-check-baseline.xml
index 2fd63fc..509d9ae 100644
--- a/color-check-baseline.xml
+++ b/color-check-baseline.xml
@@ -4437,6 +4437,22 @@
priority="4"
summary="Using hardcoded color"
explanation="Hardcoded color values are bad because theme changes cannot be uniformly applied.Instead use the theme specific colors such as `?android:attr/textColorPrimary` in attributes.
This ensures that a theme change from a light to a dark theme can be uniformlyapplied across the app."
+ errorLine1=" android:color="@color/homepage_display_background" />"
+ errorLine2=" ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~">
+ <location
+ file="res/drawable/ic_screen_rotation.xml"
+ line="24"
+ column="13"/>
+ </issue>
+
+ <issue
+ id="HardCodedColor"
+ severity="Error"
+ message="Avoid using hardcoded color"
+ category="Correctness"
+ priority="4"
+ summary="Using hardcoded color"
+ explanation="Hardcoded color values are bad because theme changes cannot be uniformly applied.Instead use the theme specific colors such as `?android:attr/textColorPrimary` in attributes.
This ensures that a theme change from a light to a dark theme can be uniformlyapplied across the app."
errorLine1=" <background android:drawable="@color/shortcut_background"/>"
errorLine2=" ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~">
<location
diff --git a/res-product/values/strings.xml b/res-product/values/strings.xml
index 2f01c47..2a58f45 100644
--- a/res-product/values/strings.xml
+++ b/res-product/values/strings.xml
@@ -96,6 +96,12 @@
<!-- Introduction detail message shown in face enrollment dialog when asking for parental consent [CHAR LIMIT=NONE]-->
<string name="security_settings_face_enroll_introduction_consent_message_0" product="device">Allow your child to use their face to unlock their device</string>
<!-- Introduction detail message shown in face enrollment dialog when asking for parental consent [CHAR LIMIT=NONE]-->
+ <string name="security_settings_face_enroll_introduction_consent_message_0_class3" product="default">Allow your child to use their face to unlock their phone or verify it\u2019s them. This happens when they sign in to apps, approve a purchase, and more.</string>
+ <!-- Introduction detail message shown in face enrollment dialog when asking for parental consent [CHAR LIMIT=NONE]-->
+ <string name="security_settings_face_enroll_introduction_consent_message_0_class3" product="tablet">Allow your child to use their face to unlock their tablet or verify it\u2019s them. This happens when they sign in to apps, approve a purchase, and more.</string>
+ <!-- Introduction detail message shown in face enrollment dialog when asking for parental consent [CHAR LIMIT=NONE]-->
+ <string name="security_settings_face_enroll_introduction_consent_message_0_class3" product="device">Allow your child to use their face to unlock their device or verify it\u2019s them. This happens when they sign in to apps, approve a purchase, and more.</string>
+ <!-- Introduction detail message shown in face enrollment dialog when asking for parental consent [CHAR LIMIT=NONE]-->
<string name="security_settings_face_enroll_introduction_consent_message" product="default">Using your child\u2019s face to unlock their phone may be less secure than a strong pattern or PIN.</string>
<!-- Introduction detail message shown in face enrollment dialog when asking for parental consent [CHAR LIMIT=NONE]-->
<string name="security_settings_face_enroll_introduction_consent_message" product="tablet">Using your child\u2019s face to unlock their tablet may be less secure than a strong pattern or PIN.</string>
diff --git a/res/drawable/ic_check_24dp.xml b/res/drawable/ic_check_24dp.xml
index 9ac8021..0ed6b32 100644
--- a/res/drawable/ic_check_24dp.xml
+++ b/res/drawable/ic_check_24dp.xml
@@ -18,8 +18,8 @@
android:height="24dp"
android:viewportWidth="24.0"
android:viewportHeight="24.0"
- android:tint="?androidprv:attr/materialColorPrimaryContainer">
+ android:tint="?androidprv:attr/colorAccent">
<path
android:pathData="M9,16.17L4.83,12l-1.42,1.41L9,19 21,7l-1.41,-1.41z"
android:fillColor="@android:color/white"/>
-</vector>
\ No newline at end of file
+</vector>
diff --git a/res/drawable/ic_screen_rotation.xml b/res/drawable/ic_screen_rotation.xml
new file mode 100644
index 0000000..f1bde27
--- /dev/null
+++ b/res/drawable/ic_screen_rotation.xml
@@ -0,0 +1,33 @@
+<?xml version="1.0" encoding="utf-8"?>
+<!--
+ 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.
+ -->
+
+<layer-list xmlns:android="http://schemas.android.com/apk/res/android">
+
+ <item>
+ <com.android.settingslib.widget.AdaptiveIconShapeDrawable
+ android:width="@dimen/dashboard_tile_image_size"
+ android:height="@dimen/dashboard_tile_image_size"
+ android:color="@color/homepage_display_background" />
+ </item>
+
+ <item
+ android:width="@dimen/dashboard_tile_foreground_image_size"
+ android:height="@dimen/dashboard_tile_foreground_image_size"
+ android:start="@dimen/dashboard_tile_foreground_image_inset"
+ android:top="@dimen/dashboard_tile_foreground_image_inset"
+ android:drawable="@drawable/ic_screen_rotation_24dp" />
+</layer-list>
diff --git a/res/layout/modifier_key_picker_dialog.xml b/res/layout/modifier_key_picker_dialog.xml
index 6de3294..fd4d75e 100644
--- a/res/layout/modifier_key_picker_dialog.xml
+++ b/res/layout/modifier_key_picker_dialog.xml
@@ -14,94 +14,102 @@
limitations under the License.
-->
-<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
- xmlns:androidprv="http://schemas.android.com/apk/prv/res/android"
- android:id="@+id/modifier_key_fragment_container"
- android:orientation="vertical"
- android:layout_width="match_parent"
- android:layout_height="match_parent" >
+<ScrollView
+ xmlns:android="http://schemas.android.com/apk/res/android"
+ xmlns:androidprv="http://schemas.android.com/apk/prv/res/android"
+ android:id="@+id/modifier_key_fragment_scroll_view"
+ android:layout_width="match_parent"
+ android:layout_height="match_parent">
- <LinearLayout android:orientation="vertical"
- android:layout_width="match_parent"
- android:layout_height="match_parent"
- android:divider="?android:dividerHorizontal"
- android:showDividers="end" >
- <TextView
- android:id="@+id/modifier_key_picker_title"
- android:layout_width="wrap_content"
- android:layout_height="wrap_content"
- android:layout_marginTop="24dip"
- android:layout_marginBottom="8dip"
- android:layout_gravity="center_horizontal"
- android:singleLine="true"
- android:textAppearance="?android:attr/textAppearanceLarge"
- android:textColor="?android:attr/textColorPrimary"
- android:text="@string/modifier_keys_picker_title"/>
+ <LinearLayout
+ android:id="@+id/modifier_key_fragment_container"
+ android:orientation="vertical"
+ android:layout_width="match_parent"
+ android:layout_height="match_parent" >
- <TextView
- android:id="@+id/modifier_key_picker_summary"
- android:layout_width="wrap_content"
+ <LinearLayout android:orientation="vertical"
+ android:layout_width="match_parent"
+ android:layout_height="wrap_content"
+ android:divider="?android:dividerHorizontal"
+ android:showDividers="end" >
+ <TextView
+ android:id="@+id/modifier_key_picker_title"
+ android:layout_width="wrap_content"
+ android:layout_height="wrap_content"
+ android:layout_marginTop="24dp"
+ android:layout_marginBottom="8dp"
+ android:layout_marginStart="16dp"
+ android:layout_marginEnd="16dp"
+ android:layout_gravity="center_horizontal"
+ android:textAppearance="?android:attr/textAppearanceLarge"
+ android:textColor="?android:attr/textColorPrimary"
+ android:text="@string/modifier_keys_picker_title"/>
+
+ <TextView
+ android:id="@+id/modifier_key_picker_summary"
+ android:layout_width="wrap_content"
+ android:layout_height="wrap_content"
+ android:layout_marginTop="8dp"
+ android:layout_marginBottom="16dp"
+ android:layout_marginStart="16dp"
+ android:layout_marginEnd="16dp"
+ android:layout_gravity="center_horizontal"
+ android:textAppearance="?android:attr/textAppearanceSmall"
+ android:textColor="?android:attr/textColorSecondary"/>
+ </LinearLayout>
+
+ <LinearLayout android:orientation="vertical"
+ android:layout_width="match_parent"
+ android:layout_height="wrap_content"
+ android:divider="?android:dividerHorizontal"
+ android:showDividers="end">
+ <ListView
+ android:id="@+id/modifier_key_picker"
+ android:layout_width="wrap_content"
+ android:layout_height="352dp"
+ android:divider="@null"
+ android:dividerHeight="8dp"
+ android:padding="16dp"
+ android:listSelector="@drawable/modifier_key_lisetview_background"
+ />
+ </LinearLayout>
+
+ <RelativeLayout
+ android:layout_width="match_parent"
android:layout_height="wrap_content"
- android:layout_marginTop="8dip"
- android:layout_marginBottom="16dip"
- android:layout_gravity="center_horizontal"
- android:singleLine="true"
- android:textAppearance="?android:attr/textAppearanceSmall"
- android:textColor="?android:attr/textColorSecondary"/>
+ android:layout_marginStart="8dp"
+ android:layout_marginEnd="8dp"
+ android:layout_marginTop="6dp"
+ android:layout_marginBottom="6dp">
+
+ <Button
+ android:id="@+id/modifier_key_cancel_button"
+ android:layout_width="wrap_content"
+ android:layout_height="wrap_content"
+ android:layout_marginTop="6dp"
+ android:layout_marginBottom="6dp"
+ android:layout_marginStart="8dp"
+ android:layout_alignParentStart="true"
+ android:paddingVertical="14dp"
+ android:drawablePadding="9dp"
+ style="@style/ModifierKeyButtonCancel"
+ android:textColor="?android:attr/textColorPrimary"
+ android:text="@string/modifier_keys_cancel"/>
+
+ <Button
+ android:id="@+id/modifier_key_done_button"
+ android:layout_width="wrap_content"
+ android:layout_height="wrap_content"
+ android:layout_marginTop="6dp"
+ android:layout_marginBottom="6dp"
+ android:layout_marginEnd="8dp"
+ android:layout_alignParentEnd="true"
+ android:paddingVertical="14dp"
+ android:drawablePadding="9dp"
+ style="@style/ModifierKeyButtonDone"
+ android:textColor="?androidprv:attr/materialColorOnPrimary"
+ android:text="@string/modifier_keys_done"/>
+
+ </RelativeLayout>
</LinearLayout>
-
- <LinearLayout android:orientation="vertical"
- android:layout_width="match_parent"
- android:layout_height="match_parent"
- android:divider="?android:dividerHorizontal"
- android:showDividers="end">
- <ListView
- android:id="@+id/modifier_key_picker"
- android:layout_width="wrap_content"
- android:layout_height="wrap_content"
- android:divider="@null"
- android:dividerHeight="8dp"
- android:padding="16dip"
- android:listSelector="@drawable/modifier_key_lisetview_background"
- />
- </LinearLayout>
-
- <RelativeLayout
- android:layout_width="wrap_content"
- android:layout_height="wrap_content"
- android:layout_marginStart="8dip"
- android:layout_marginEnd="8dip"
- android:layout_marginTop="6dip"
- android:layout_marginBottom="6dip"
- android:layout_weight="1">
-
- <Button
- android:id="@+id/modifier_key_cancel_button"
- android:layout_width="wrap_content"
- android:layout_height="wrap_content"
- android:layout_marginTop="6dip"
- android:layout_marginBottom="6dip"
- android:layout_marginStart="8dip"
- android:layout_alignParentStart="true"
- android:paddingVertical="14dp"
- android:drawablePadding="9dp"
- style="@style/ModifierKeyButtonCancel"
- android:textColor="?android:attr/textColorPrimary"
- android:text="@string/modifier_keys_cancel"/>
-
- <Button
- android:id="@+id/modifier_key_done_button"
- android:layout_width="wrap_content"
- android:layout_height="wrap_content"
- android:layout_marginTop="6dip"
- android:layout_marginBottom="6dip"
- android:layout_marginEnd="8dip"
- android:layout_alignParentEnd="true"
- android:paddingVertical="14dp"
- android:drawablePadding="9dp"
- style="@style/ModifierKeyButtonDone"
- android:textColor="?androidprv:attr/materialColorOnPrimary"
- android:text="@string/modifier_keys_done"/>
-
- </RelativeLayout>
-</LinearLayout>
\ No newline at end of file
+</ScrollView>
\ No newline at end of file
diff --git a/res/layout/modifier_key_reset_dialog.xml b/res/layout/modifier_key_reset_dialog.xml
index 11712bf..784b608 100644
--- a/res/layout/modifier_key_reset_dialog.xml
+++ b/res/layout/modifier_key_reset_dialog.xml
@@ -26,7 +26,6 @@
android:layout_marginTop="24dip"
android:layout_marginBottom="8dip"
android:layout_gravity="center_horizontal"
- android:singleLine="true"
android:textAppearance="?android:attr/textAppearanceLarge"
android:textColor="?android:attr/textColorPrimary"
android:text="@string/modifier_keys_reset_title" />
@@ -39,7 +38,6 @@
android:layout_marginBottom="16dip"
android:layout_marginStart="32dip"
android:layout_marginEnd="32dip"
- android:gravity="center"
android:layout_gravity="center_horizontal"
android:textAppearance="?android:attr/textAppearanceSmall"
android:textColor="?android:attr/textColorSecondary"
diff --git a/res/values/strings.xml b/res/values/strings.xml
index 8fb13ac..f31f105 100644
--- a/res/values/strings.xml
+++ b/res/values/strings.xml
@@ -11908,6 +11908,12 @@
<!-- Developer settings: Summary for disabling phantom process monitoring. [CHAR LIMIT=NONE]-->
<string name="disable_phantom_process_monitor_summary">Disable restrictions on the system resource usage of the app child processes</string>
+ <!-- Developer settings: Title for force enabling Notes role. [CHAR LIMIT=50]-->
+ <string name="enable_notes_role_title">Force enable Notes role</string>
+ <!-- Developer settings: Summary for disabling phantom process monitoring. [CHAR LIMIT=NONE]-->
+ <string name="enable_notes_role_summary">Enable note-taking system integrations via the Notes role. If the Notes role is already enabled, does nothing.</string>
+
+
<!-- BT LE Audio Device: Media Broadcast -->
<!-- The title of the Media Broadcast Dialog [CHAR LIMIT=none] -->
<string name="bluetooth_broadcast_dialog_title">Broadcast</string>
diff --git a/res/xml/development_settings.xml b/res/xml/development_settings.xml
index 9e1dbad..e7aac3e 100644
--- a/res/xml/development_settings.xml
+++ b/res/xml/development_settings.xml
@@ -713,6 +713,11 @@
android:title="@string/disable_phantom_process_monitor_title"
android:summary="@string/disable_phantom_process_monitor_summary" />
+ <SwitchPreference
+ android:key="force_enable_notes_role"
+ android:title="@string/enable_notes_role_title"
+ android:summary="@string/enable_notes_role_summary" />
+
</PreferenceCategory>
<PreferenceCategory
diff --git a/src/com/android/settings/Utils.java b/src/com/android/settings/Utils.java
index 388a510..68b1a48 100644
--- a/src/com/android/settings/Utils.java
+++ b/src/com/android/settings/Utils.java
@@ -134,6 +134,8 @@
public static final String SETTINGS_PACKAGE_NAME = "com.android.settings";
+ public static final String SYSTEMUI_PACKAGE_NAME = "com.android.systemui";
+
public static final String OS_PKG = "os";
/**
diff --git a/src/com/android/settings/applications/AppStateOverlayBridge.java b/src/com/android/settings/applications/AppStateOverlayBridge.java
index 64a6ea1..2276b19 100644
--- a/src/com/android/settings/applications/AppStateOverlayBridge.java
+++ b/src/com/android/settings/applications/AppStateOverlayBridge.java
@@ -19,6 +19,7 @@
import android.app.AppOpsManager;
import android.content.Context;
+import com.android.settings.Utils;
import com.android.settingslib.applications.ApplicationsState;
import com.android.settingslib.applications.ApplicationsState.AppEntry;
import com.android.settingslib.applications.ApplicationsState.AppFilter;
@@ -59,7 +60,7 @@
private static final List<String> DISABLE_PACKAGE_LIST = new ArrayList<>();
static {
- DISABLE_PACKAGE_LIST.add("com.android.systemui");
+ DISABLE_PACKAGE_LIST.add(Utils.SYSTEMUI_PACKAGE_NAME);
}
public OverlayState(PermissionState permissionState) {
diff --git a/src/com/android/settings/applications/RecentAppStatsMixin.java b/src/com/android/settings/applications/RecentAppStatsMixin.java
index 6705b25..4e8f795 100644
--- a/src/com/android/settings/applications/RecentAppStatsMixin.java
+++ b/src/com/android/settings/applications/RecentAppStatsMixin.java
@@ -17,6 +17,7 @@
package com.android.settings.applications;
import static com.android.settings.Utils.SETTINGS_PACKAGE_NAME;
+import static com.android.settings.Utils.SYSTEMUI_PACKAGE_NAME;
import android.app.Application;
import android.app.usage.UsageStats;
@@ -76,7 +77,7 @@
"android",
"com.android.phone",
SETTINGS_PACKAGE_NAME,
- "com.android.systemui",
+ SYSTEMUI_PACKAGE_NAME,
"com.android.providers.calendar",
"com.android.providers.media"
));
diff --git a/src/com/android/settings/applications/specialaccess/pictureinpicture/PictureInPictureSettings.java b/src/com/android/settings/applications/specialaccess/pictureinpicture/PictureInPictureSettings.java
index d794de6..3c90bf3 100644
--- a/src/com/android/settings/applications/specialaccess/pictureinpicture/PictureInPictureSettings.java
+++ b/src/com/android/settings/applications/specialaccess/pictureinpicture/PictureInPictureSettings.java
@@ -38,6 +38,7 @@
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;
@@ -57,7 +58,7 @@
static final List<String> IGNORE_PACKAGE_LIST = new ArrayList<>();
static {
- IGNORE_PACKAGE_LIST.add("com.android.systemui");
+ IGNORE_PACKAGE_LIST.add(Utils.SYSTEMUI_PACKAGE_NAME);
}
/**
diff --git a/src/com/android/settings/applications/specialaccess/turnscreenon/TurnScreenOnSettings.java b/src/com/android/settings/applications/specialaccess/turnscreenon/TurnScreenOnSettings.java
index 014971a..742831e 100644
--- a/src/com/android/settings/applications/specialaccess/turnscreenon/TurnScreenOnSettings.java
+++ b/src/com/android/settings/applications/specialaccess/turnscreenon/TurnScreenOnSettings.java
@@ -37,6 +37,7 @@
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;
@@ -58,7 +59,7 @@
static final List<String> IGNORE_PACKAGE_LIST = new ArrayList<>();
static {
- IGNORE_PACKAGE_LIST.add("com.android.systemui");
+ IGNORE_PACKAGE_LIST.add(Utils.SYSTEMUI_PACKAGE_NAME);
}
/**
diff --git a/src/com/android/settings/biometrics/combination/CombinedBiometricStatusUtils.java b/src/com/android/settings/biometrics/combination/CombinedBiometricStatusUtils.java
index d3e8fa7..8cc6bc4 100644
--- a/src/com/android/settings/biometrics/combination/CombinedBiometricStatusUtils.java
+++ b/src/com/android/settings/biometrics/combination/CombinedBiometricStatusUtils.java
@@ -133,6 +133,19 @@
}
/**
+ * Returns the class name of the Settings page corresponding to combined biometric settings
+ * based on the current user.
+ */
+ public String getSettingsClassNameBasedOnUser() {
+ UserManager userManager = mContext.getSystemService(UserManager.class);
+ if (userManager != null && userManager.isProfile()) {
+ return getProfileSettingsClassName();
+ } else {
+ return getSettingsClassName();
+ }
+ }
+
+ /**
* Returns the class name of the Settings page corresponding to combined biometric settings.
*/
public String getSettingsClassName() {
diff --git a/src/com/android/settings/biometrics/face/FaceEnrollIntroduction.java b/src/com/android/settings/biometrics/face/FaceEnrollIntroduction.java
index 3e8c458..efd9753 100644
--- a/src/com/android/settings/biometrics/face/FaceEnrollIntroduction.java
+++ b/src/com/android/settings/biometrics/face/FaceEnrollIntroduction.java
@@ -592,6 +592,10 @@
return data;
}
+ protected boolean isFaceStrong() {
+ return mIsFaceStrong;
+ }
+
private void onFaceStrengthChanged() {
// Set up and show the "less secure" info section if necessary.
if (!mIsFaceStrong && getResources().getBoolean(
diff --git a/src/com/android/settings/biometrics/face/FaceEnrollParentalConsent.java b/src/com/android/settings/biometrics/face/FaceEnrollParentalConsent.java
index a3a745d..aabbf6f 100644
--- a/src/com/android/settings/biometrics/face/FaceEnrollParentalConsent.java
+++ b/src/com/android/settings/biometrics/face/FaceEnrollParentalConsent.java
@@ -47,13 +47,14 @@
R.string.security_settings_face_enroll_introduction_control_consent_title,
R.string.security_settings_face_enroll_introduction_control_consent_message,
R.string.security_settings_face_enroll_introduction_consent_message_0,
+ R.string.security_settings_face_enroll_introduction_consent_message_0_class3,
R.string.security_settings_face_enroll_introduction_info_consent_less_secure
};
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
- setDescriptionText(R.string.security_settings_face_enroll_introduction_consent_message_0);
+ updateDescriptionText();
}
@Override
@@ -144,4 +145,16 @@
public int getMetricsCategory() {
return SettingsEnums.FACE_PARENTAL_CONSENT;
}
+
+ @Override
+ protected void updateDescriptionText() {
+ super.updateDescriptionText();
+ if (isFaceStrong()) {
+ setDescriptionText(getString(
+ R.string.security_settings_face_enroll_introduction_consent_message_0_class3));
+ } else {
+ setDescriptionText(
+ R.string.security_settings_face_enroll_introduction_consent_message_0);
+ }
+ }
}
diff --git a/src/com/android/settings/biometrics/fingerprint/FingerprintEnrollParentalConsent.java b/src/com/android/settings/biometrics/fingerprint/FingerprintEnrollParentalConsent.java
index c33ae17..7f4142d 100644
--- a/src/com/android/settings/biometrics/fingerprint/FingerprintEnrollParentalConsent.java
+++ b/src/com/android/settings/biometrics/fingerprint/FingerprintEnrollParentalConsent.java
@@ -131,4 +131,12 @@
public int getMetricsCategory() {
return SettingsEnums.FINGERPRINT_PARENTAL_CONSENT;
}
+
+
+ @Override
+ protected void updateDescriptionText() {
+ super.updateDescriptionText();
+ setDescriptionText(
+ R.string.security_settings_fingerprint_enroll_introduction_consent_message);
+ }
}
diff --git a/src/com/android/settings/biometrics2/ui/view/FingerprintEnrollEnrollingIconTouchDialog.java b/src/com/android/settings/biometrics2/ui/view/FingerprintEnrollEnrollingIconTouchDialog.java
index e86d755..f4fe7ff 100644
--- a/src/com/android/settings/biometrics2/ui/view/FingerprintEnrollEnrollingIconTouchDialog.java
+++ b/src/com/android/settings/biometrics2/ui/view/FingerprintEnrollEnrollingIconTouchDialog.java
@@ -18,14 +18,11 @@
import android.app.Dialog;
import android.app.settings.SettingsEnums;
-import android.content.Context;
import android.os.Bundle;
import androidx.appcompat.app.AlertDialog;
-import androidx.lifecycle.ViewModelProvider;
import com.android.settings.R;
-import com.android.settings.biometrics2.ui.viewmodel.FingerprintEnrollEnrollingViewModel;
import com.android.settings.core.instrumentation.InstrumentedDialogFragment;
/**
@@ -33,15 +30,6 @@
*/
public class FingerprintEnrollEnrollingIconTouchDialog extends InstrumentedDialogFragment {
- private FingerprintEnrollEnrollingViewModel mViewModel;
-
- @Override
- public void onAttach(Context context) {
- mViewModel = new ViewModelProvider(getActivity()).get(
- FingerprintEnrollEnrollingViewModel.class);
- super.onAttach(context);
- }
-
@Override
public Dialog onCreateDialog(Bundle savedInstanceState) {
AlertDialog.Builder builder = new AlertDialog.Builder(getActivity(),
@@ -50,10 +38,7 @@
.setMessage(R.string.security_settings_fingerprint_enroll_touch_dialog_message)
.setPositiveButton(
R.string.security_settings_fingerprint_enroll_dialog_ok,
- (dialog, which) -> {
- dialog.dismiss();
- mViewModel.onIconTouchDialogDismiss();
- });
+ (dialog, which) -> dialog.dismiss());
return builder.create();
}
diff --git a/src/com/android/settings/biometrics2/ui/view/FingerprintEnrollmentActivity.java b/src/com/android/settings/biometrics2/ui/view/FingerprintEnrollmentActivity.java
index 62928af..d84ce61 100644
--- a/src/com/android/settings/biometrics2/ui/view/FingerprintEnrollmentActivity.java
+++ b/src/com/android/settings/biometrics2/ui/view/FingerprintEnrollmentActivity.java
@@ -27,7 +27,6 @@
import static com.android.settings.biometrics2.ui.viewmodel.AutoCredentialViewModel.CREDENTIAL_IS_GENERATING_CHALLENGE;
import static com.android.settings.biometrics2.ui.viewmodel.AutoCredentialViewModel.CREDENTIAL_VALID;
import static com.android.settings.biometrics2.ui.viewmodel.FingerprintEnrollEnrollingViewModel.ErrorDialogData;
-import static com.android.settings.biometrics2.ui.viewmodel.FingerprintEnrollEnrollingViewModel.FINGERPRINT_ENROLL_ENROLLING_ACTION_DISMISS_ICON_TOUCH_DIALOG;
import static com.android.settings.biometrics2.ui.viewmodel.FingerprintEnrollEnrollingViewModel.FINGERPRINT_ENROLL_ENROLLING_ACTION_DONE;
import static com.android.settings.biometrics2.ui.viewmodel.FingerprintEnrollEnrollingViewModel.FINGERPRINT_ENROLL_ENROLLING_ACTION_SHOW_ICON_TOUCH_DIALOG;
import static com.android.settings.biometrics2.ui.viewmodel.FingerprintEnrollEnrollingViewModel.FINGERPRINT_ENROLL_ENROLLING_CANCELED_BECAUSE_BACK_PRESSED;
@@ -518,10 +517,6 @@
SKIP_SETUP_FIND_FPS_DIALOG_TAG);
break;
}
- case FINGERPRINT_ENROLL_ENROLLING_ACTION_DISMISS_ICON_TOUCH_DIALOG: {
- onSetActivityResult(new ActivityResult(BiometricEnrollBase.RESULT_TIMEOUT, null));
- break;
- }
case FINGERPRINT_ENROLL_ENROLLING_CANCELED_BECAUSE_BACK_PRESSED: {
if (getSupportFragmentManager().getBackStackEntryCount() > 0) {
getSupportFragmentManager().popBackStack();
diff --git a/src/com/android/settings/biometrics2/ui/viewmodel/FingerprintEnrollEnrollingViewModel.java b/src/com/android/settings/biometrics2/ui/viewmodel/FingerprintEnrollEnrollingViewModel.java
index 025c58b..12584ee 100644
--- a/src/com/android/settings/biometrics2/ui/viewmodel/FingerprintEnrollEnrollingViewModel.java
+++ b/src/com/android/settings/biometrics2/ui/viewmodel/FingerprintEnrollEnrollingViewModel.java
@@ -61,24 +61,18 @@
public static final int FINGERPRINT_ENROLL_ENROLLING_ACTION_SHOW_ICON_TOUCH_DIALOG = 1;
/**
- * Icon touch dialog dismiss
- */
- public static final int FINGERPRINT_ENROLL_ENROLLING_ACTION_DISMISS_ICON_TOUCH_DIALOG = 2;
-
- /**
* Has got latest cancelled event due to user skip
*/
- public static final int FINGERPRINT_ENROLL_ENROLLING_CANCELED_BECAUSE_USER_SKIP = 3;
+ public static final int FINGERPRINT_ENROLL_ENROLLING_CANCELED_BECAUSE_USER_SKIP = 2;
/**
* Has got latest cancelled event due to back key
*/
- public static final int FINGERPRINT_ENROLL_ENROLLING_CANCELED_BECAUSE_BACK_PRESSED = 4;
+ public static final int FINGERPRINT_ENROLL_ENROLLING_CANCELED_BECAUSE_BACK_PRESSED = 3;
@IntDef(prefix = { "FINGERPRINT_ENROLL_ENROLLING_ACTION_" }, value = {
FINGERPRINT_ENROLL_ENROLLING_ACTION_DONE,
FINGERPRINT_ENROLL_ENROLLING_ACTION_SHOW_ICON_TOUCH_DIALOG,
- FINGERPRINT_ENROLL_ENROLLING_ACTION_DISMISS_ICON_TOUCH_DIALOG,
FINGERPRINT_ENROLL_ENROLLING_CANCELED_BECAUSE_USER_SKIP,
FINGERPRINT_ENROLL_ENROLLING_CANCELED_BECAUSE_BACK_PRESSED
})
@@ -116,7 +110,6 @@
private final Vibrator mVibrator;
private final MutableLiveData<Integer> mActionLiveData = new MutableLiveData<>();
- private final MutableLiveData<Integer> mIconTouchDialogLiveData = new MutableLiveData<>();
private final MutableLiveData<ErrorDialogData> mErrorDialogLiveData = new MutableLiveData<>();
private final MutableLiveData<Integer> mErrorDialogActionLiveData = new MutableLiveData<>();
@@ -234,17 +227,6 @@
}
/**
- * Icon touch dialog dismiss
- */
- public void onIconTouchDialogDismiss() {
- final int action = FINGERPRINT_ENROLL_ENROLLING_ACTION_DISMISS_ICON_TOUCH_DIALOG;
- if (DEBUG) {
- Log.d(TAG, "onIconTouchDialogDismiss, post action " + action);
- }
- mActionLiveData.postValue(action);
- }
-
- /**
* get enroll stage threshold
*/
public float getEnrollStageThreshold(int index) {
diff --git a/src/com/android/settings/bluetooth/RequestPermissionActivity.java b/src/com/android/settings/bluetooth/RequestPermissionActivity.java
index 588bc73..620cfb0 100644
--- a/src/com/android/settings/bluetooth/RequestPermissionActivity.java
+++ b/src/com/android/settings/bluetooth/RequestPermissionActivity.java
@@ -42,6 +42,8 @@
import com.android.settings.R;
import com.android.settingslib.bluetooth.BluetoothDiscoverableTimeoutReceiver;
+import kotlin.Unit;
+
import java.time.Duration;
/**
@@ -100,12 +102,15 @@
case BluetoothAdapter.STATE_ON:
case BluetoothAdapter.STATE_TURNING_ON: {
- Intent intent = new Intent(this, RequestPermissionHelperActivity.class);
- intent.putExtra(RequestPermissionHelperActivity.EXTRA_APP_LABEL, mAppLabel);
- intent.setAction(RequestPermissionHelperActivity
- .ACTION_INTERNAL_REQUEST_BT_OFF);
-
- startActivityForResult(intent, 0);
+ RequestPermissionHelper.INSTANCE.requestDisable(this, mAppLabel,
+ () -> {
+ onDisableConfirmed();
+ return Unit.INSTANCE;
+ },
+ () -> {
+ cancelAndFinish();
+ return Unit.INSTANCE;
+ });
} break;
default: {
@@ -126,18 +131,17 @@
* case via the broadcast receiver.
*/
- /*
- * Start the helper activity to:
- * 1) ask the user about enabling bt AND discovery
- * 2) enable BT upon confirmation
- */
- Intent intent = new Intent(this, RequestPermissionHelperActivity.class);
- intent.setAction(RequestPermissionHelperActivity.ACTION_INTERNAL_REQUEST_BT_ON);
- intent.putExtra(RequestPermissionHelperActivity.EXTRA_APP_LABEL, mAppLabel);
- if (mRequest == REQUEST_ENABLE_DISCOVERABLE) {
- intent.putExtra(BluetoothAdapter.EXTRA_DISCOVERABLE_DURATION, mTimeout);
- }
- startActivityForResult(intent, 0);
+ // Start the helper activity to ask the user about enabling bt AND discovery
+ RequestPermissionHelper.INSTANCE.requestEnable(this, mAppLabel,
+ mRequest == REQUEST_ENABLE_DISCOVERABLE ? mTimeout : -1,
+ () -> {
+ onEnableConfirmed();
+ return Unit.INSTANCE;
+ },
+ () -> {
+ cancelAndFinish();
+ return Unit.INSTANCE;
+ });
} break;
case BluetoothAdapter.STATE_ON: {
@@ -202,42 +206,27 @@
mDialog.show();
}
- @Override
- protected void onActivityResult(int requestCode, int resultCode, Intent data) {
- if (resultCode != Activity.RESULT_OK) {
- cancelAndFinish();
- return;
+ private void onEnableConfirmed() {
+ mBluetoothAdapter.enable();
+ if (mBluetoothAdapter.getState() == BluetoothAdapter.STATE_ON) {
+ proceedAndFinish();
+ } else {
+ // If BT is not up yet, show "Turning on Bluetooth..."
+ mReceiver = new StateChangeReceiver();
+ registerReceiver(mReceiver, new IntentFilter(BluetoothAdapter.ACTION_STATE_CHANGED));
+ createDialog();
}
+ }
- switch (mRequest) {
- case REQUEST_ENABLE:
- case REQUEST_ENABLE_DISCOVERABLE: {
- if (mBluetoothAdapter.getState() == BluetoothAdapter.STATE_ON) {
- proceedAndFinish();
- } else {
- // If BT is not up yet, show "Turning on Bluetooth..."
- mReceiver = new StateChangeReceiver();
- registerReceiver(mReceiver, new IntentFilter(
- BluetoothAdapter.ACTION_STATE_CHANGED));
- createDialog();
- }
- } break;
-
- case REQUEST_DISABLE: {
- if (mBluetoothAdapter.getState() == BluetoothAdapter.STATE_OFF) {
- proceedAndFinish();
- } else {
- // If BT is not up yet, show "Turning off Bluetooth..."
- mReceiver = new StateChangeReceiver();
- registerReceiver(mReceiver, new IntentFilter(
- BluetoothAdapter.ACTION_STATE_CHANGED));
- createDialog();
- }
- } break;
-
- default: {
- cancelAndFinish();
- } break;
+ private void onDisableConfirmed() {
+ mBluetoothAdapter.disable();
+ if (mBluetoothAdapter.getState() == BluetoothAdapter.STATE_OFF) {
+ proceedAndFinish();
+ } else {
+ // If BT is not up yet, show "Turning off Bluetooth..."
+ mReceiver = new StateChangeReceiver();
+ registerReceiver(mReceiver, new IntentFilter(BluetoothAdapter.ACTION_STATE_CHANGED));
+ createDialog();
}
}
diff --git a/src/com/android/settings/bluetooth/RequestPermissionHelper.kt b/src/com/android/settings/bluetooth/RequestPermissionHelper.kt
new file mode 100644
index 0000000..000a7d1
--- /dev/null
+++ b/src/com/android/settings/bluetooth/RequestPermissionHelper.kt
@@ -0,0 +1,98 @@
+/*
+ * 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.bluetooth
+
+import android.content.Context
+import android.os.UserManager
+import androidx.appcompat.app.AlertDialog
+import com.android.settings.R
+import com.android.settingslib.spaprivileged.framework.common.devicePolicyManager
+import com.android.settingslib.spaprivileged.framework.common.userManager
+
+object RequestPermissionHelper {
+ fun requestEnable(
+ context: Context,
+ appLabel: CharSequence?,
+ timeout: Int,
+ onAllow: () -> Unit,
+ onDeny: () -> Unit,
+ ) {
+ if (context.resources.getBoolean(R.bool.auto_confirm_bluetooth_activation_dialog)) {
+ // Don't even show the dialog if configured this way
+ onAllow()
+ return
+ }
+ AlertDialog.Builder(context).apply {
+ setMessage(context.getEnableMessage(timeout, appLabel))
+ setPositiveButton(R.string.allow) { _, _ ->
+ if (context.isDisallowBluetooth()) onDeny() else onAllow()
+ }
+ setNegativeButton(R.string.deny) { _, _ -> onDeny() }
+ setOnCancelListener { onDeny() }
+ }.show()
+ }
+
+ fun requestDisable(
+ context: Context,
+ appLabel: CharSequence?,
+ onAllow: () -> Unit,
+ onDeny: () -> Unit,
+ ) {
+ if (context.resources.getBoolean(R.bool.auto_confirm_bluetooth_activation_dialog)) {
+ // Don't even show the dialog if configured this way
+ onAllow()
+ return
+ }
+ AlertDialog.Builder(context).apply {
+ setMessage(context.getDisableMessage(appLabel))
+ setPositiveButton(R.string.allow) { _, _ -> onAllow() }
+ setNegativeButton(R.string.deny) { _, _ -> onDeny() }
+ setOnCancelListener { onDeny() }
+ }.show()
+ }
+}
+
+// If Bluetooth is disallowed, don't try to enable it, show policy transparency message instead.
+private fun Context.isDisallowBluetooth() =
+ if (userManager.hasUserRestriction(UserManager.DISALLOW_BLUETOOTH)) {
+ devicePolicyManager.createAdminSupportIntent(UserManager.DISALLOW_BLUETOOTH)
+ ?.let { startActivity(it) }
+ true
+ } else false
+
+private fun Context.getEnableMessage(timeout: Int, name: CharSequence?): String = when {
+ timeout < 0 -> when (name) {
+ null -> getString(R.string.bluetooth_ask_enablement_no_name)
+ else -> getString(R.string.bluetooth_ask_enablement, name)
+ }
+
+ timeout == BluetoothDiscoverableEnabler.DISCOVERABLE_TIMEOUT_NEVER -> when (name) {
+ null -> getString(R.string.bluetooth_ask_enablement_and_lasting_discovery_no_name)
+ else -> getString(R.string.bluetooth_ask_enablement_and_lasting_discovery, name)
+ }
+
+ else -> when (name) {
+ null -> getString(R.string.bluetooth_ask_enablement_and_discovery_no_name, timeout)
+ else -> getString(R.string.bluetooth_ask_enablement_and_discovery, name, timeout)
+ }
+}
+
+private fun Context.getDisableMessage(name: CharSequence?): String =
+ when (name) {
+ null -> getString(R.string.bluetooth_ask_disablement_no_name)
+ else -> getString(R.string.bluetooth_ask_disablement, name)
+ }
diff --git a/src/com/android/settings/bluetooth/RequestPermissionHelperActivity.java b/src/com/android/settings/bluetooth/RequestPermissionHelperActivity.java
deleted file mode 100644
index 99ac928..0000000
--- a/src/com/android/settings/bluetooth/RequestPermissionHelperActivity.java
+++ /dev/null
@@ -1,178 +0,0 @@
-/*
- * Copyright (C) 2009 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.bluetooth;
-
-import android.app.Activity;
-import android.app.admin.DevicePolicyManager;
-import android.bluetooth.BluetoothAdapter;
-import android.content.DialogInterface;
-import android.content.Intent;
-import android.os.Bundle;
-import android.os.UserManager;
-import android.util.Log;
-
-import com.android.internal.app.AlertActivity;
-import com.android.internal.app.AlertController;
-import com.android.settings.R;
-
-/**
- * RequestPermissionHelperActivity asks the user whether to toggle Bluetooth.
- *
- * TODO: This activity isn't needed - this should be folded in RequestPermissionActivity
- */
-public class RequestPermissionHelperActivity extends AlertActivity implements
- DialogInterface.OnClickListener {
- private static final String TAG = "RequestPermissionHelperActivity";
-
- public static final String ACTION_INTERNAL_REQUEST_BT_ON =
- "com.android.settings.bluetooth.ACTION_INTERNAL_REQUEST_BT_ON";
-
- public static final String ACTION_INTERNAL_REQUEST_BT_OFF =
- "com.android.settings.bluetooth.ACTION_INTERNAL_REQUEST_BT_OFF";
-
- public static final String EXTRA_APP_LABEL =
- "com.android.settings.bluetooth.extra.APP_LABEL";
-
- private BluetoothAdapter mBluetoothAdapter;
-
- private CharSequence mAppLabel;
-
- private int mTimeout = -1;
-
- private int mRequest;
-
- @Override
- protected void onCreate(Bundle savedInstanceState) {
- super.onCreate(savedInstanceState);
-
- setResult(RESULT_CANCELED);
-
- // Note: initializes mBluetoothAdapter and returns true on error
- if (!parseIntent()) {
- finish();
- return;
- }
-
- if (getResources().getBoolean(R.bool.auto_confirm_bluetooth_activation_dialog)) {
- // Don't even show the dialog if configured this way
- onClick(null, BUTTON_POSITIVE);
- dismiss();
- }
-
- createDialog();
- }
-
- void createDialog() {
- final AlertController.AlertParams p = mAlertParams;
-
- switch (mRequest) {
- case RequestPermissionActivity.REQUEST_ENABLE: {
- if (mTimeout < 0) {
- p.mMessage = mAppLabel != null
- ? getString(R.string.bluetooth_ask_enablement, mAppLabel)
- : getString(R.string.bluetooth_ask_enablement_no_name);
- } else if (mTimeout == BluetoothDiscoverableEnabler.DISCOVERABLE_TIMEOUT_NEVER) {
- p.mMessage = mAppLabel != null
- ? getString(
- R.string.bluetooth_ask_enablement_and_lasting_discovery,
- mAppLabel)
- : getString(
- R.string.bluetooth_ask_enablement_and_lasting_discovery_no_name);
- } else {
- p.mMessage = mAppLabel != null
- ? getString(R.string.bluetooth_ask_enablement_and_discovery,
- mAppLabel, mTimeout)
- : getString(R.string.bluetooth_ask_enablement_and_discovery_no_name,
- mTimeout);
- }
- } break;
-
- case RequestPermissionActivity.REQUEST_DISABLE: {
- p.mMessage = mAppLabel != null
- ? getString(R.string.bluetooth_ask_disablement, mAppLabel)
- : getString(R.string.bluetooth_ask_disablement_no_name);
- } break;
- }
-
- p.mPositiveButtonText = getString(R.string.allow);
- p.mPositiveButtonListener = this;
- p.mNegativeButtonText = getString(R.string.deny);
-
- setupAlert();
- }
-
- public void onClick(DialogInterface dialog, int which) {
- switch (mRequest) {
- case RequestPermissionActivity.REQUEST_ENABLE:
- case RequestPermissionActivity.REQUEST_ENABLE_DISCOVERABLE: {
- UserManager userManager = getSystemService(UserManager.class);
- if (userManager.hasUserRestriction(UserManager.DISALLOW_BLUETOOTH)) {
- // If Bluetooth is disallowed, don't try to enable it, show policy transparency
- // message instead.
- DevicePolicyManager dpm = getSystemService(DevicePolicyManager.class);
- Intent intent = dpm.createAdminSupportIntent(UserManager.DISALLOW_BLUETOOTH);
- if (intent != null) {
- startActivity(intent);
- }
- } else {
- mBluetoothAdapter.enable();
- setResult(Activity.RESULT_OK);
- }
- } break;
-
- case RequestPermissionActivity.REQUEST_DISABLE: {
- mBluetoothAdapter.disable();
- setResult(Activity.RESULT_OK);
- } break;
- }
- }
-
- /**
- * Parse the received Intent and initialize mBluetoothAdapter.
- * @return true if an error occurred; false otherwise
- */
- private boolean parseIntent() {
- Intent intent = getIntent();
- if (intent == null) {
- return false;
- }
-
- String action = intent.getAction();
- if (ACTION_INTERNAL_REQUEST_BT_ON.equals(action)) {
- mRequest = RequestPermissionActivity.REQUEST_ENABLE;
- if (intent.hasExtra(BluetoothAdapter.EXTRA_DISCOVERABLE_DURATION)) {
- // Value used for display purposes. Not range checking.
- mTimeout = intent.getIntExtra(BluetoothAdapter.EXTRA_DISCOVERABLE_DURATION,
- BluetoothDiscoverableEnabler.DEFAULT_DISCOVERABLE_TIMEOUT);
- }
- } else if (ACTION_INTERNAL_REQUEST_BT_OFF.equals(action)) {
- mRequest = RequestPermissionActivity.REQUEST_DISABLE;
- } else {
- return false;
- }
-
- mAppLabel = getIntent().getCharSequenceExtra(EXTRA_APP_LABEL);
-
- mBluetoothAdapter = BluetoothAdapter.getDefaultAdapter();
- if (mBluetoothAdapter == null) {
- Log.e(TAG, "Error: there's a problem starting Bluetooth");
- return false;
- }
-
- return true;
- }
-}
diff --git a/src/com/android/settings/connecteddevice/BluetoothDashboardFragment.java b/src/com/android/settings/connecteddevice/BluetoothDashboardFragment.java
index b30aee4..66f2f1b 100644
--- a/src/com/android/settings/connecteddevice/BluetoothDashboardFragment.java
+++ b/src/com/android/settings/connecteddevice/BluetoothDashboardFragment.java
@@ -25,6 +25,7 @@
import com.android.settings.R;
import com.android.settings.SettingsActivity;
+import com.android.settings.Utils;
import com.android.settings.bluetooth.BluetoothDeviceRenamePreferenceController;
import com.android.settings.bluetooth.BluetoothSwitchPreferenceController;
import com.android.settings.dashboard.DashboardFragment;
@@ -45,8 +46,6 @@
private static final String TAG = "BluetoothDashboardFrag";
private static final String KEY_BLUETOOTH_SCREEN_FOOTER = "bluetooth_screen_footer";
- private static final String SETTINGS_PACKAGE_NAME = "com.android.settings";
- private static final String SYSTEMUI_PACKAGE_NAME = "com.android.systemui";
private static final String SLICE_ACTION = "com.android.settings.SEARCH_RESULT_TRAMPOLINE";
private static final boolean DEBUG = Log.isLoggable(TAG, Log.DEBUG);
@@ -112,8 +111,8 @@
@VisibleForTesting
boolean isAlwaysDiscoverable(String callingAppPackageName, String action) {
return TextUtils.equals(SLICE_ACTION, action) ? false
- : TextUtils.equals(SETTINGS_PACKAGE_NAME, callingAppPackageName)
- || TextUtils.equals(SYSTEMUI_PACKAGE_NAME, callingAppPackageName);
+ : TextUtils.equals(Utils.SETTINGS_PACKAGE_NAME, callingAppPackageName)
+ || TextUtils.equals(Utils.SYSTEMUI_PACKAGE_NAME, callingAppPackageName);
}
/**
diff --git a/src/com/android/settings/connecteddevice/ConnectedDeviceDashboardFragment.java b/src/com/android/settings/connecteddevice/ConnectedDeviceDashboardFragment.java
index 3c6077e..9286b81 100644
--- a/src/com/android/settings/connecteddevice/ConnectedDeviceDashboardFragment.java
+++ b/src/com/android/settings/connecteddevice/ConnectedDeviceDashboardFragment.java
@@ -28,6 +28,7 @@
import com.android.settings.R;
import com.android.settings.SettingsActivity;
+import com.android.settings.Utils;
import com.android.settings.core.SettingsUIDeviceConfig;
import com.android.settings.dashboard.DashboardFragment;
import com.android.settings.search.BaseSearchIndexProvider;
@@ -38,7 +39,6 @@
public class ConnectedDeviceDashboardFragment extends DashboardFragment {
private static final String TAG = "ConnectedDeviceFrag";
- private static final String SYSTEMUI_PACKAGE_NAME = "com.android.systemui";
private static final boolean DEBUG = Log.isLoggable(TAG, Log.DEBUG);
private static final String SLICE_ACTION = "com.android.settings.SEARCH_RESULT_TRAMPOLINE";
@@ -92,8 +92,8 @@
@VisibleForTesting
boolean isAlwaysDiscoverable(String callingAppPackageName, String action) {
return TextUtils.equals(SLICE_ACTION, action) ? false
- : TextUtils.equals(SETTINGS_PACKAGE_NAME, callingAppPackageName)
- || TextUtils.equals(SYSTEMUI_PACKAGE_NAME, callingAppPackageName);
+ : TextUtils.equals(Utils.SETTINGS_PACKAGE_NAME, callingAppPackageName)
+ || TextUtils.equals(Utils.SYSTEMUI_PACKAGE_NAME, callingAppPackageName);
}
/**
diff --git a/src/com/android/settings/development/DevelopmentSettingsDashboardFragment.java b/src/com/android/settings/development/DevelopmentSettingsDashboardFragment.java
index acc0e7c..65d3be0 100644
--- a/src/com/android/settings/development/DevelopmentSettingsDashboardFragment.java
+++ b/src/com/android/settings/development/DevelopmentSettingsDashboardFragment.java
@@ -733,6 +733,7 @@
controllers.add(new PhantomProcessPreferenceController(context));
controllers.add(new ContrastPreferenceController(
context, context.getSystemService(UiModeManager.class)));
+ controllers.add(new ForceEnableNotesRolePreferenceController(context));
return controllers;
}
diff --git a/src/com/android/settings/development/ForceEnableNotesRolePreferenceController.java b/src/com/android/settings/development/ForceEnableNotesRolePreferenceController.java
new file mode 100644
index 0000000..7821bec
--- /dev/null
+++ b/src/com/android/settings/development/ForceEnableNotesRolePreferenceController.java
@@ -0,0 +1,103 @@
+/*
+ * 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.
+ */
+/*
+ * 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.development;
+
+import static android.os.UserHandle.USER_CURRENT;
+
+import android.content.Context;
+import android.content.om.IOverlayManager;
+import android.os.RemoteException;
+import android.os.ServiceManager;
+
+import androidx.preference.Preference;
+import androidx.preference.SwitchPreference;
+
+import com.android.internal.R;
+import com.android.internal.annotations.VisibleForTesting;
+import com.android.settings.core.PreferenceControllerMixin;
+import com.android.settingslib.development.DeveloperOptionsPreferenceController;
+
+public class ForceEnableNotesRolePreferenceController
+ extends DeveloperOptionsPreferenceController
+ implements Preference.OnPreferenceChangeListener, PreferenceControllerMixin {
+
+ private static final String NOTES_ROLE_ENABLED_KEY =
+ "force_enable_notes_role";
+
+ private static final String OVERLAY_PACKAGE_NAME =
+ "com.android.role.notes.enabled";
+
+ private final IOverlayManager mOverlayManager;
+
+ public ForceEnableNotesRolePreferenceController(Context context) {
+ super(context);
+ mOverlayManager = IOverlayManager.Stub.asInterface(
+ ServiceManager.getService(Context.OVERLAY_SERVICE));
+ }
+
+ @Override
+ public String getPreferenceKey() {
+ return NOTES_ROLE_ENABLED_KEY;
+ }
+
+ @Override
+ public boolean onPreferenceChange(Preference preference, Object newValue) {
+ setEnabled((boolean) newValue);
+ return true;
+ }
+
+ @Override
+ public void updateState(Preference preference) {
+ ((SwitchPreference) mPreference).setChecked(isEnabled());
+ }
+
+ @Override
+ protected void onDeveloperOptionsSwitchDisabled() {
+ super.onDeveloperOptionsSwitchDisabled();
+ ((SwitchPreference) mPreference).setChecked(false);
+ setEnabled(false);
+ }
+
+ @VisibleForTesting
+ protected boolean isEnabled() {
+ return mContext.getResources().getBoolean(R.bool.config_enableDefaultNotes);
+ }
+
+ @VisibleForTesting
+ protected void setEnabled(boolean enabled) {
+ try {
+ mOverlayManager.setEnabled(OVERLAY_PACKAGE_NAME, enabled, USER_CURRENT);
+ } catch (RemoteException e) {
+ throw e.rethrowFromSystemServer();
+ }
+ }
+}
diff --git a/src/com/android/settings/display/AmbientDisplayAlwaysOnPreferenceController.java b/src/com/android/settings/display/AmbientDisplayAlwaysOnPreferenceController.java
index bf81727..e0e25df 100644
--- a/src/com/android/settings/display/AmbientDisplayAlwaysOnPreferenceController.java
+++ b/src/com/android/settings/display/AmbientDisplayAlwaysOnPreferenceController.java
@@ -121,7 +121,7 @@
final PowerManager powerManager = context.getSystemService(PowerManager.class);
final PackageManager packageManager = context.getPackageManager();
final String packageName = context.getString(
- com.android.internal.R.string.config_defaultWellbeingPackage);
+ com.android.internal.R.string.config_systemWellbeing);
try {
uid = packageManager.getApplicationInfo(packageName, /* flags= */ 0).uid;
} catch (PackageManager.NameNotFoundException e) {
diff --git a/src/com/android/settings/display/darkmode/BedtimeSettings.java b/src/com/android/settings/display/darkmode/BedtimeSettings.java
index 28121b2..5b9b4d2 100644
--- a/src/com/android/settings/display/darkmode/BedtimeSettings.java
+++ b/src/com/android/settings/display/darkmode/BedtimeSettings.java
@@ -37,7 +37,7 @@
mContext = context;
mPackageManager = context.getPackageManager();
mWellbeingPackage = mContext.getResources().getString(
- com.android.internal.R.string.config_defaultWellbeingPackage);
+ com.android.internal.R.string.config_systemWellbeing);
}
/**
diff --git a/src/com/android/settings/fuelgauge/PowerUsageFeatureProviderImpl.java b/src/com/android/settings/fuelgauge/PowerUsageFeatureProviderImpl.java
index ac72ced..496cfab 100644
--- a/src/com/android/settings/fuelgauge/PowerUsageFeatureProviderImpl.java
+++ b/src/com/android/settings/fuelgauge/PowerUsageFeatureProviderImpl.java
@@ -16,6 +16,8 @@
package com.android.settings.fuelgauge;
+import static com.android.settings.Utils.SYSTEMUI_PACKAGE_NAME;
+
import android.content.Context;
import android.content.Intent;
import android.content.pm.PackageManager;
@@ -35,9 +37,8 @@
private static final String PACKAGE_CALENDAR_PROVIDER = "com.android.providers.calendar";
private static final String PACKAGE_MEDIA_PROVIDER = "com.android.providers.media";
- private static final String PACKAGE_SYSTEMUI = "com.android.systemui";
private static final String[] PACKAGES_SYSTEM = {PACKAGE_MEDIA_PROVIDER,
- PACKAGE_CALENDAR_PROVIDER, PACKAGE_SYSTEMUI};
+ PACKAGE_CALENDAR_PROVIDER, SYSTEMUI_PACKAGE_NAME};
protected PackageManager mPackageManager;
protected Context mContext;
diff --git a/src/com/android/settings/fuelgauge/batterytip/BatteryTipLoader.java b/src/com/android/settings/fuelgauge/batterytip/BatteryTipLoader.java
index e622f4c..8e9d485 100644
--- a/src/com/android/settings/fuelgauge/batterytip/BatteryTipLoader.java
+++ b/src/com/android/settings/fuelgauge/batterytip/BatteryTipLoader.java
@@ -72,7 +72,7 @@
.detect());
tips.add(new BatteryDefenderDetector(batteryInfo, context).detect());
tips.add(new DockDefenderDetector(batteryInfo, context).detect());
- tips.add(new IncompatibleChargerDetector(context, batteryInfo).detect());
+ tips.add(new IncompatibleChargerDetector(context).detect());
Collections.sort(tips);
return tips;
}
diff --git a/src/com/android/settings/fuelgauge/batterytip/detectors/IncompatibleChargerDetector.java b/src/com/android/settings/fuelgauge/batterytip/detectors/IncompatibleChargerDetector.java
index 483e37d..cfd9a2c 100644
--- a/src/com/android/settings/fuelgauge/batterytip/detectors/IncompatibleChargerDetector.java
+++ b/src/com/android/settings/fuelgauge/batterytip/detectors/IncompatibleChargerDetector.java
@@ -18,7 +18,6 @@
import android.content.Context;
import android.util.Log;
-import com.android.settings.fuelgauge.BatteryInfo;
import com.android.settings.fuelgauge.batterytip.tips.BatteryTip;
import com.android.settings.fuelgauge.batterytip.tips.IncompatibleChargerTip;
import com.android.settingslib.Utils;
@@ -28,25 +27,17 @@
private static final String TAG = "IncompatibleChargerDetector";
private final Context mContext;
- private final BatteryInfo mBatteryInfo;
- public IncompatibleChargerDetector(Context context, BatteryInfo batteryInfo) {
+ public IncompatibleChargerDetector(Context context) {
mContext = context;
- mBatteryInfo = batteryInfo;
}
@Override
public BatteryTip detect() {
- int state = BatteryTip.StateType.INVISIBLE;
- boolean isIncompatibleCharging = false;
-
- // Check incompatible charging state if the device is plugged.
- if (mBatteryInfo.pluggedStatus != 0) {
- isIncompatibleCharging = Utils.containsIncompatibleChargers(mContext, TAG);
- if (isIncompatibleCharging) {
- state = BatteryTip.StateType.NEW;
- }
- }
+ final boolean isIncompatibleCharging =
+ Utils.containsIncompatibleChargers(mContext, TAG);
+ final int state = isIncompatibleCharging
+ ? BatteryTip.StateType.NEW : BatteryTip.StateType.INVISIBLE;
Log.d(TAG, "detect() state= " + state + " isIncompatibleCharging: "
+ isIncompatibleCharging);
return new IncompatibleChargerTip(state);
diff --git a/src/com/android/settings/fuelgauge/batteryusage/BatteryChartPreferenceController.java b/src/com/android/settings/fuelgauge/batteryusage/BatteryChartPreferenceController.java
index d192e1a..e9d10f2 100644
--- a/src/com/android/settings/fuelgauge/batteryusage/BatteryChartPreferenceController.java
+++ b/src/com/android/settings/fuelgauge/batteryusage/BatteryChartPreferenceController.java
@@ -296,6 +296,10 @@
});
mHourlyChartView = hourlyChartView;
mHourlyChartView.setOnSelectListener(trapezoidIndex -> {
+ if (mDailyChartIndex == BatteryChartViewModel.SELECTED_INDEX_ALL) {
+ // This will happen when a daily slot and an hour slot are clicked together.
+ return;
+ }
if (mHourlyChartIndex == trapezoidIndex) {
return;
}
diff --git a/src/com/android/settings/fuelgauge/batteryusage/BatteryChartView.java b/src/com/android/settings/fuelgauge/batteryusage/BatteryChartView.java
index b17ccaa..445a5d1 100644
--- a/src/com/android/settings/fuelgauge/batteryusage/BatteryChartView.java
+++ b/src/com/android/settings/fuelgauge/batteryusage/BatteryChartView.java
@@ -16,6 +16,7 @@
package com.android.settings.fuelgauge.batteryusage;
import static com.android.settings.Utils.formatPercentage;
+import static com.android.settings.fuelgauge.batteryusage.BatteryChartViewModel.AxisLabelPosition.BETWEEN_TRAPEZOIDS;
import static java.lang.Math.round;
import static java.util.Objects.requireNonNull;
@@ -29,6 +30,7 @@
import android.graphics.Path;
import android.graphics.Rect;
import android.os.Bundle;
+import android.util.ArraySet;
import android.util.AttributeSet;
import android.util.Log;
import android.view.HapticFeedbackConstants;
@@ -52,13 +54,13 @@
import java.util.ArrayList;
import java.util.List;
import java.util.Locale;
+import java.util.Set;
/** A widget component to draw chart graph. */
public class BatteryChartView extends AppCompatImageView implements View.OnClickListener {
private static final String TAG = "BatteryChartView";
private static final int DIVIDER_COLOR = Color.parseColor("#CDCCC5");
- private static final long UPDATE_STATE_DELAYED_TIME = 500L;
/** A callback listener for selected group index is updated. */
public interface OnSelectListener {
@@ -70,6 +72,7 @@
private final Rect mIndent = new Rect();
private final Rect[] mPercentageBounds = new Rect[]{new Rect(), new Rect(), new Rect()};
private final List<Rect> mAxisLabelsBounds = new ArrayList<>();
+ private final Set<Integer> mLabelDrawnIndexes = new ArraySet<>();
private BatteryChartViewModel mViewModel;
private int mHoveredIndex = BatteryChartViewModel.SELECTED_INDEX_INVALID;
@@ -80,6 +83,7 @@
private int mTrapezoidColor;
private int mTrapezoidSolidColor;
private int mTrapezoidHoverColor;
+ private int mDefaultTextColor;
private int mTextPadding;
private Paint mDividerPaint;
private Paint mTrapezoidPaint;
@@ -134,6 +138,7 @@
// Pre-draws the view first to load style atttributions into paint.
textView.draw(new Canvas());
mTextPaint = textView.getPaint();
+ mDefaultTextColor = mTextPaint.getColor();
} else {
mTextPaint = null;
}
@@ -332,6 +337,7 @@
final int height = getHeight() - mIndent.top - mIndent.bottom;
// Draws the top divider line for 100% curve.
float offsetY = mIndent.top + mDividerWidth * .5f;
+ mDividerPaint.setColor(DIVIDER_COLOR);
canvas.drawLine(0, offsetY, width, offsetY, mDividerPaint);
drawPercentage(canvas, /*index=*/ 0, offsetY);
@@ -351,6 +357,7 @@
private void drawPercentage(Canvas canvas, int index, float offsetY) {
if (mTextPaint != null) {
mTextPaint.setTextAlign(Paint.Align.RIGHT);
+ mTextPaint.setColor(mDefaultTextColor);
canvas.drawText(
mPercentages[index],
getWidth(),
@@ -367,18 +374,6 @@
final float bottomY = getHeight() - mIndent.bottom;
final float startY = bottomY - mDividerHeight;
final float trapezoidSlotOffset = mTrapezoidHOffset + mDividerWidth * .5f;
- // Draws each vertical dividers.
- float startX = mDividerWidth * .5f;
- for (int index = 0; index < dividerCount; index++) {
- canvas.drawLine(startX, startY, startX, bottomY, mDividerPaint);
- final float nextX = startX + mDividerWidth + unitWidth;
- // Updates the trapezoid slots for drawing.
- if (index < mTrapezoidSlots.length) {
- mTrapezoidSlots[index].mLeft = round(startX + trapezoidSlotOffset);
- mTrapezoidSlots[index].mRight = round(nextX - trapezoidSlotOffset);
- }
- startX = nextX;
- }
// Draws the axis label slot information.
if (mViewModel != null) {
final float baselineY = getHeight() - mTextPadding;
@@ -404,6 +399,26 @@
}
drawAxisLabels(canvas, axisLabelDisplayAreas, baselineY);
}
+ // Draws each vertical dividers.
+ float startX = mDividerWidth * .5f;
+ for (int index = 0; index < dividerCount; index++) {
+ float dividerY = bottomY;
+ if (mViewModel.axisLabelPosition() == BETWEEN_TRAPEZOIDS
+ && mLabelDrawnIndexes.contains(index)) {
+ mDividerPaint.setColor(mTrapezoidSolidColor);
+ dividerY += mDividerHeight / 4f;
+ } else {
+ mDividerPaint.setColor(DIVIDER_COLOR);
+ }
+ canvas.drawLine(startX, startY, startX, dividerY, mDividerPaint);
+ final float nextX = startX + mDividerWidth + unitWidth;
+ // Updates the trapezoid slots for drawing.
+ if (index < mTrapezoidSlots.length) {
+ mTrapezoidSlots[index].mLeft = round(startX + trapezoidSlotOffset);
+ mTrapezoidSlots[index].mRight = round(nextX - trapezoidSlotOffset);
+ }
+ startX = nextX;
+ }
}
/** Gets all the axis label texts displaying area positions if they are shown. */
@@ -432,9 +447,12 @@
private void drawAxisLabels(Canvas canvas, final Rect[] displayAreas, final float baselineY) {
final int lastIndex = displayAreas.length - 1;
+ mLabelDrawnIndexes.clear();
// Suppose first and last labels are always able to draw.
drawAxisLabelText(canvas, 0, displayAreas[0], baselineY);
+ mLabelDrawnIndexes.add(0);
drawAxisLabelText(canvas, lastIndex, displayAreas[lastIndex], baselineY);
+ mLabelDrawnIndexes.add(lastIndex);
drawAxisLabelsBetweenStartIndexAndEndIndex(canvas, displayAreas, 0, lastIndex, baselineY);
}
@@ -458,6 +476,7 @@
return;
}
drawAxisLabelText(canvas, middleIndex, displayAreas[middleIndex], baselineY);
+ mLabelDrawnIndexes.add(middleIndex);
drawAxisLabelsBetweenStartIndexAndEndIndex(
canvas, displayAreas, startIndex, middleIndex, baselineY);
drawAxisLabelsBetweenStartIndexAndEndIndex(
@@ -471,7 +490,9 @@
return;
}
drawAxisLabelText(canvas, middleIndex1, displayAreas[middleIndex1], baselineY);
+ mLabelDrawnIndexes.add(middleIndex1);
drawAxisLabelText(canvas, middleIndex2, displayAreas[middleIndex2], baselineY);
+ mLabelDrawnIndexes.add(middleIndex2);
drawAxisLabelsBetweenStartIndexAndEndIndex(
canvas, displayAreas, startIndex, middleIndex1, baselineY);
drawAxisLabelsBetweenStartIndexAndEndIndex(
@@ -488,12 +509,14 @@
private void drawAxisLabelText(
Canvas canvas, final int index, final Rect displayArea, final float baselineY) {
+ mTextPaint.setColor(mTrapezoidSolidColor);
mTextPaint.setTextAlign(Paint.Align.CENTER);
canvas.drawText(
mViewModel.getText(index),
displayArea.centerX(),
baselineY,
mTextPaint);
+ mLabelDrawnIndexes.add(index);
}
private void drawTrapezoids(Canvas canvas) {
diff --git a/src/com/android/settings/fuelgauge/batteryusage/BatteryUsageBreakdownController.java b/src/com/android/settings/fuelgauge/batteryusage/BatteryUsageBreakdownController.java
index 2121c60..cd1bdef 100644
--- a/src/com/android/settings/fuelgauge/batteryusage/BatteryUsageBreakdownController.java
+++ b/src/com/android/settings/fuelgauge/batteryusage/BatteryUsageBreakdownController.java
@@ -313,11 +313,8 @@
@VisibleForTesting
void removeAndCacheAllUnusedPreferences() {
List<BatteryDiffEntry> entries = getBatteryDiffEntries();
- Set<String> entryKeySet = new ArraySet<>();
- for (BatteryDiffEntry entry : entries) {
- entryKeySet.add(entry.getKey());
- }
-
+ Set<String> entryKeySet = new ArraySet<>(entries.size());
+ entries.forEach(entry -> entryKeySet.add(entry.getKey()));
final int prefsCount = mAppListPreferenceGroup.getPreferenceCount();
for (int index = prefsCount - 1; index >= 0; index--) {
final Preference pref = mAppListPreferenceGroup.getPreference(index);
diff --git a/src/com/android/settings/fuelgauge/batteryusage/DataProcessor.java b/src/com/android/settings/fuelgauge/batteryusage/DataProcessor.java
index ec1a4be..24571cd 100644
--- a/src/com/android/settings/fuelgauge/batteryusage/DataProcessor.java
+++ b/src/com/android/settings/fuelgauge/batteryusage/DataProcessor.java
@@ -725,9 +725,9 @@
@VisibleForTesting
@Nullable
static Map<Long, Map<String, List<AppUsagePeriod>>> buildAppUsagePeriodList(
- final List<AppUsageEvent> allAppUsageEvents, final List<BatteryEvent> batteryEventList,
+ final List<AppUsageEvent> appUsageEvents, final List<BatteryEvent> batteryEventList,
final long startTime, final long endTime) {
- if (allAppUsageEvents.isEmpty()) {
+ if (appUsageEvents.isEmpty()) {
return null;
}
@@ -735,7 +735,7 @@
// use.
final List<AppUsageEvent> deviceEvents = new ArrayList<>();
final ArrayMap<Integer, List<AppUsageEvent>> usageEventsByInstanceId = new ArrayMap<>();
- for (final AppUsageEvent event : allAppUsageEvents) {
+ for (final AppUsageEvent event : appUsageEvents) {
final AppUsageEventType eventType = event.getType();
if (eventType == AppUsageEventType.ACTIVITY_RESUMED
|| eventType == AppUsageEventType.ACTIVITY_STOPPED) {
@@ -852,9 +852,11 @@
final List<AppUsagePeriod> usagePeriodList,
final List<BatteryEvent> batteryEventList) {
final List<AppUsagePeriod> resultList = new ArrayList<>();
+ int index = 0;
for (AppUsagePeriod inputPeriod : usagePeriodList) {
long lastStartTime = inputPeriod.getStartTime();
- for (BatteryEvent batteryEvent : batteryEventList) {
+ while (index < batteryEventList.size()) {
+ BatteryEvent batteryEvent = batteryEventList.get(index);
if (batteryEvent.getTimestamp() < inputPeriod.getStartTime()) {
// Because the batteryEventList has been sorted, here is to mark the power
// connection state when the usage period starts. If power is connected when
@@ -865,6 +867,7 @@
} else if (batteryEvent.getType() == BatteryEventType.POWER_DISCONNECTED) {
lastStartTime = inputPeriod.getStartTime();
}
+ index++;
continue;
}
if (batteryEvent.getTimestamp() > inputPeriod.getEndTime()) {
@@ -883,6 +886,7 @@
} else if (batteryEvent.getType() == BatteryEventType.POWER_DISCONNECTED) {
lastStartTime = batteryEvent.getTimestamp();
}
+ index++;
}
if (lastStartTime != 0) {
resultList.add(AppUsagePeriod.newBuilder()
diff --git a/src/com/android/settings/fuelgauge/batteryusage/DatabaseUtils.java b/src/com/android/settings/fuelgauge/batteryusage/DatabaseUtils.java
index 84a39bb..0435e45 100644
--- a/src/com/android/settings/fuelgauge/batteryusage/DatabaseUtils.java
+++ b/src/com/android/settings/fuelgauge/batteryusage/DatabaseUtils.java
@@ -110,13 +110,7 @@
// For testing only.
@VisibleForTesting
- static Supplier<Cursor> sFakeBatteryStateSupplier;
- @VisibleForTesting
- static Supplier<Cursor> sFakeAppUsageEventSupplier;
- @VisibleForTesting
- static Supplier<Cursor> sFakeAppUsageLatestTimestampSupplier;
- @VisibleForTesting
- static Supplier<Cursor> sFakeBatteryEventSupplier;
+ static Supplier<Cursor> sFakeSupplier;
private DatabaseUtils() {
}
@@ -340,7 +334,7 @@
resolver.insert(BATTERY_EVENT_URI, contentValues);
Log.d(TAG, "insert() battery event data into database: " + batteryEvent.toString());
} catch (Exception e) {
- Log.e(TAG, "insert() battery event data into database error:\n" + e);
+ Log.e(TAG, "insert() battery event data into database error:", e);
}
Log.d(TAG, String.format("sendBatteryEventData() in %d/ms",
(System.currentTimeMillis() - startTime)));
@@ -487,8 +481,8 @@
Context context, final Uri appUsageLatestTimestampUri) {
// We have already make sure the context here is with profile parent's user identity. Don't
// need to check whether current user is work profile.
- try (Cursor cursor = sFakeAppUsageLatestTimestampSupplier != null
- ? sFakeAppUsageLatestTimestampSupplier.get()
+ try (Cursor cursor = sFakeSupplier != null
+ ? sFakeSupplier.get()
: context.getContentResolver().query(
appUsageLatestTimestampUri, null, null, null)) {
if (cursor == null || cursor.getCount() == 0) {
@@ -514,8 +508,8 @@
if (context == null) {
return appUsageEventList;
}
- try (Cursor cursor = sFakeAppUsageEventSupplier != null
- ? sFakeAppUsageEventSupplier.get()
+ try (Cursor cursor = sFakeSupplier != null
+ ? sFakeSupplier.get()
: context.getContentResolver().query(appUsageEventUri, null, null, null)) {
if (cursor == null || cursor.getCount() == 0) {
return appUsageEventList;
@@ -540,8 +534,8 @@
if (context == null) {
return batteryEventList;
}
- try (Cursor cursor = sFakeBatteryEventSupplier != null
- ? sFakeBatteryEventSupplier.get()
+ try (Cursor cursor = sFakeSupplier != null
+ ? sFakeSupplier.get()
: context.getContentResolver().query(batteryEventUri, null, null, null)) {
if (cursor == null || cursor.getCount() == 0) {
return batteryEventList;
@@ -566,7 +560,7 @@
return null;
}
final Map<Long, Map<String, BatteryHistEntry>> resultMap = new HashMap();
- try (Cursor cursor = sFakeBatteryStateSupplier != null ? sFakeBatteryStateSupplier.get() :
+ try (Cursor cursor = sFakeSupplier != null ? sFakeSupplier.get() :
context.getContentResolver().query(batteryStateUri, null, null, null)) {
if (cursor == null || cursor.getCount() == 0) {
return resultMap;
diff --git a/src/com/android/settings/network/SubscriptionUtil.java b/src/com/android/settings/network/SubscriptionUtil.java
index 9c4ac03..9d953bf 100644
--- a/src/com/android/settings/network/SubscriptionUtil.java
+++ b/src/com/android/settings/network/SubscriptionUtil.java
@@ -438,6 +438,7 @@
}
}
+ Log.d(TAG, "getSelectableSubscriptionInfoList: " + selectableList);
return selectableList;
}
}
diff --git a/src/com/android/settings/panel/PanelFeatureProviderImpl.java b/src/com/android/settings/panel/PanelFeatureProviderImpl.java
index 57a1ab0..71711f9 100644
--- a/src/com/android/settings/panel/PanelFeatureProviderImpl.java
+++ b/src/com/android/settings/panel/PanelFeatureProviderImpl.java
@@ -22,9 +22,9 @@
import android.provider.Settings;
import android.util.FeatureFlagUtils;
-public class PanelFeatureProviderImpl implements PanelFeatureProvider {
+import com.android.settings.Utils;
- private static final String SYSTEMUI_PACKAGE_NAME = "com.android.systemui";
+public class PanelFeatureProviderImpl implements PanelFeatureProvider {
@Override
public PanelContent getPanel(Context context, Bundle bundle) {
@@ -42,7 +42,7 @@
// Redirect to the internet dialog in SystemUI.
Intent intent = new Intent(Settings.Panel.ACTION_INTERNET_CONNECTIVITY);
intent.addFlags(Intent.FLAG_RECEIVER_FOREGROUND)
- .setPackage(SYSTEMUI_PACKAGE_NAME);
+ .setPackage(Utils.SYSTEMUI_PACKAGE_NAME);
context.sendBroadcast(intent);
return null;
case Settings.Panel.ACTION_NFC:
@@ -55,7 +55,7 @@
// Redirect to the volume panel in SystemUI.
Intent volumeIntent = new Intent(Settings.Panel.ACTION_VOLUME);
volumeIntent.addFlags(Intent.FLAG_RECEIVER_FOREGROUND).setPackage(
- SYSTEMUI_PACKAGE_NAME);
+ Utils.SYSTEMUI_PACKAGE_NAME);
context.sendBroadcast(volumeIntent);
return null;
} else {
diff --git a/src/com/android/settings/safetycenter/BiometricsSafetySource.java b/src/com/android/settings/safetycenter/BiometricsSafetySource.java
index 1fe366d..74964ce 100644
--- a/src/com/android/settings/safetycenter/BiometricsSafetySource.java
+++ b/src/com/android/settings/safetycenter/BiometricsSafetySource.java
@@ -85,7 +85,7 @@
combinedBiometricStatusUtils.getSummary(),
createPendingIntent(context,
biometricNavigationUtils.getBiometricSettingsIntent(context,
- combinedBiometricStatusUtils.getSettingsClassName(),
+ combinedBiometricStatusUtils.getSettingsClassNameBasedOnUser(),
disablingAdmin, Bundle.EMPTY),
REQUEST_CODE_COMBINED_BIOMETRIC_SETTING),
disablingAdmin == null /* enabled */,
diff --git a/src/com/android/settings/sim/receivers/SimSlotChangeHandler.java b/src/com/android/settings/sim/receivers/SimSlotChangeHandler.java
index f6c9cc4..dabb088 100644
--- a/src/com/android/settings/sim/receivers/SimSlotChangeHandler.java
+++ b/src/com/android/settings/sim/receivers/SimSlotChangeHandler.java
@@ -43,7 +43,6 @@
import com.google.common.collect.ImmutableList;
-import java.util.ArrayList;
import java.util.List;
import java.util.stream.Collectors;
@@ -100,6 +99,9 @@
int lastRemovableSlotState = getLastRemovableSimSlotState(mContext);
int currentRemovableSlotState = removableSlotInfo.getCardStateInfo();
+ Log.i(TAG,
+ "lastRemovableSlotState: " + lastRemovableSlotState + ",currentRemovableSlotState: "
+ + currentRemovableSlotState);
boolean isRemovableSimInserted =
lastRemovableSlotState == UiccSlotInfo.CARD_STATE_INFO_ABSENT
&& currentRemovableSlotState == UiccSlotInfo.CARD_STATE_INFO_PRESENT;
@@ -259,7 +261,7 @@
}
List<SubscriptionInfo> subscriptionInfos = getAvailableRemovableSubscription();
- if (subscriptionInfos == null || subscriptionInfos.get(0) == null) {
+ if (subscriptionInfos.isEmpty()) {
Log.e(TAG, "Unable to find the removable subscriptionInfo. Do nothing.");
return;
}
@@ -275,6 +277,7 @@
private void setRemovableSimSlotState(Context context, int state) {
final SharedPreferences prefs = context.getSharedPreferences(EUICC_PREFS, MODE_PRIVATE);
prefs.edit().putInt(KEY_REMOVABLE_SLOT_STATE, state).apply();
+ Log.d(TAG, "setRemovableSimSlotState: " + state);
}
private int getSuwRemovableSlotAction(Context context) {
@@ -332,13 +335,14 @@
}
protected List<SubscriptionInfo> getAvailableRemovableSubscription() {
- List<SubscriptionInfo> subList = new ArrayList<>();
- for (SubscriptionInfo info : SubscriptionUtil.getAvailableSubscriptions(mContext)) {
- if (!info.isEmbedded()) {
- subList.add(info);
- }
- }
- return subList;
+ List<SubscriptionInfo> removableSubscriptions =
+ SubscriptionUtil.getAvailableSubscriptions(mContext);
+ return ImmutableList.copyOf(
+ removableSubscriptions.stream()
+ // ToDo: This condition is for psim only. If device supports removable
+ // esim, it needs an new condition.
+ .filter(sub -> !sub.isEmbedded())
+ .collect(Collectors.toList()));
}
private void startChooseSimActivity(boolean psimInserted) {
diff --git a/src/com/android/settings/spa/SettingsSpaEnvironment.kt b/src/com/android/settings/spa/SettingsSpaEnvironment.kt
index c2716b6..455fe9f 100644
--- a/src/com/android/settings/spa/SettingsSpaEnvironment.kt
+++ b/src/com/android/settings/spa/SettingsSpaEnvironment.kt
@@ -17,6 +17,7 @@
package com.android.settings.spa
import android.content.Context
+import android.util.FeatureFlagUtils
import com.android.settings.spa.app.AllAppListPageProvider
import com.android.settings.spa.app.AppsMainPageProvider
import com.android.settings.spa.app.appinfo.AppInfoSettingsProvider
@@ -43,6 +44,7 @@
import com.android.settings.spa.system.SystemMainPageProvider
import com.android.settingslib.spa.framework.common.SettingsPageProviderRepository
import com.android.settingslib.spa.framework.common.SpaEnvironment
+import com.android.settingslib.spa.framework.common.SpaLogger
import com.android.settingslib.spa.framework.common.createSettingsPage
import com.android.settingslib.spaprivileged.template.app.TogglePermissionAppListProvider
import com.android.settingslib.spaprivileged.template.app.TogglePermissionAppListTemplate
@@ -88,5 +90,8 @@
),
)
}
- override val logger = SpaLogProvider
+ override val logger =
+ if (FeatureFlagUtils.isEnabled(context, FeatureFlagUtils.SETTINGS_ENABLE_SPA_METRICS))
+ SpaLogProvider
+ else object: SpaLogger {}
}
diff --git a/src/com/android/settings/spa/system/AppLanguagesListModel.kt b/src/com/android/settings/spa/system/AppLanguagesListModel.kt
index 3141d68..942bcc4 100644
--- a/src/com/android/settings/spa/system/AppLanguagesListModel.kt
+++ b/src/com/android/settings/spa/system/AppLanguagesListModel.kt
@@ -33,8 +33,10 @@
import com.android.settings.applications.appinfo.AppLocaleDetails
import com.android.settings.localepicker.AppLocalePickerActivity
import com.android.settingslib.spa.framework.util.filterItem
+import com.android.settingslib.spaprivileged.framework.common.asUser
import com.android.settingslib.spaprivileged.model.app.AppListModel
import com.android.settingslib.spaprivileged.model.app.AppRecord
+import com.android.settingslib.spaprivileged.model.app.userHandle
import com.android.settingslib.spaprivileged.template.app.AppListItem
import com.android.settingslib.spaprivileged.template.app.AppListItemModel
import kotlinx.coroutines.Dispatchers
@@ -54,17 +56,18 @@
override fun transform(userIdFlow: Flow<Int>, appListFlow: Flow<List<ApplicationInfo>>) =
userIdFlow.map { userId ->
- packageManager.queryIntentActivitiesAsUser(
+ userId to packageManager.queryIntentActivitiesAsUser(
AppLocaleUtil.LAUNCHER_ENTRY_INTENT,
PackageManager.ResolveInfoFlags.of(PackageManager.GET_META_DATA.toLong()),
userId,
)
- }.combine(appListFlow) { resolveInfos, appList ->
+ }.combine(appListFlow) { (userId, resolveInfos), appList ->
+ val userContext = context.asUser(UserHandle.of(userId))
appList.map { app ->
AppLanguagesRecord(
app = app,
isAppLocaleSupported = AppLocaleUtil.canDisplayLocaleUi(
- context, app, resolveInfos
+ userContext, app, resolveInfos
),
)
}
@@ -86,9 +89,7 @@
}.collectAsStateWithLifecycle(initialValue = stringResource(R.string.summary_placeholder))
private fun getSummary(app: ApplicationInfo): String =
- AppLocaleDetails.getAppDefaultLocale(context, app.packageName)?.let {
- AppLocaleDetails.getSummary(context, app).toString()
- } ?: context.getString(R.string.preference_of_system_locale_summary)
+ AppLocaleDetails.getSummary(context, app).toString()
@Composable
override fun AppListItemModel<AppLanguagesRecord>.AppItem() {
@@ -96,8 +97,7 @@
val intent = Intent(context, AppLocalePickerActivity::class.java).apply {
data = Uri.parse("package:${record.app.packageName}")
}
- val userHandle : UserHandle = UserHandle.getUserHandleForUid(record.app.uid)
- context.startActivityAsUser(intent, userHandle)
+ context.startActivityAsUser(intent, record.app.userHandle)
}
}
}
diff --git a/src/com/android/settings/support/SupportDashboardActivity.java b/src/com/android/settings/support/SupportDashboardActivity.java
index b8a22b9..4654858 100644
--- a/src/com/android/settings/support/SupportDashboardActivity.java
+++ b/src/com/android/settings/support/SupportDashboardActivity.java
@@ -17,7 +17,6 @@
import android.app.Activity;
import android.content.Context;
-import android.content.Intent;
import android.os.Bundle;
import com.android.settings.R;
@@ -37,6 +36,9 @@
@SearchIndexable
public class SupportDashboardActivity extends Activity implements Indexable {
+ public static final String ACTION_SUPPORT_SETTINGS =
+ "com.android.settings.action.SUPPORT_SETTINGS";
+
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
@@ -70,7 +72,7 @@
data.summaryOn = context.getString(R.string.support_summary);
data.intentTargetPackage = context.getPackageName();
data.intentTargetClass = SupportDashboardActivity.class.getName();
- data.intentAction = Intent.ACTION_MAIN;
+ data.intentAction = ACTION_SUPPORT_SETTINGS;
data.key = SUPPORT_SEARCH_INDEX_KEY;
result.add(data);
diff --git a/src/com/android/settings/wifi/WifiConfigController2.java b/src/com/android/settings/wifi/WifiConfigController2.java
index 9a29c1c..f92b58f 100644
--- a/src/com/android/settings/wifi/WifiConfigController2.java
+++ b/src/com/android/settings/wifi/WifiConfigController2.java
@@ -592,28 +592,32 @@
return null;
}
- WifiConfiguration config = new WifiConfiguration();
-
+ WifiConfiguration config;
if (mWifiEntry == null) {
+ config = new WifiConfiguration();
config.SSID = "\"" + mSsidView.getText().toString() + "\"";
// If the user adds a network manually, assume that it is hidden.
config.hiddenSSID = mHiddenSettingsSpinner.getSelectedItemPosition() == HIDDEN_NETWORK;
- } else if (!mWifiEntry.isSaved()) {
- config.SSID = "\"" + mWifiEntry.getTitle() + "\"";
+ } else if (mWifiEntry.isSaved()) {
+ config = new WifiConfiguration(mWifiEntry.getWifiConfiguration());
} else {
- config.networkId = mWifiEntry.getWifiConfiguration().networkId;
- config.hiddenSSID = mWifiEntry.getWifiConfiguration().hiddenSSID;
+ config = new WifiConfiguration();
+ config.SSID = "\"" + mWifiEntry.getTitle() + "\"";
}
config.shared = mSharedCheckBox.isChecked();
switch (mWifiEntrySecurity) {
case WifiEntry.SECURITY_NONE:
- config.setSecurityParams(WifiConfiguration.SECURITY_TYPE_OPEN);
+ if (mWifiEntry == null || !mWifiEntry.isSaved()) {
+ config.setSecurityParams(WifiConfiguration.SECURITY_TYPE_OPEN);
+ }
break;
case WifiEntry.SECURITY_WEP:
- config.setSecurityParams(WifiConfiguration.SECURITY_TYPE_WEP);
+ if (mWifiEntry == null || !mWifiEntry.isSaved()) {
+ config.setSecurityParams(WifiConfiguration.SECURITY_TYPE_WEP);
+ }
if (mPasswordView.length() != 0) {
int length = mPasswordView.length();
String password = mPasswordView.getText().toString();
@@ -628,7 +632,9 @@
break;
case WifiEntry.SECURITY_PSK:
- config.setSecurityParams(WifiConfiguration.SECURITY_TYPE_PSK);
+ if (mWifiEntry == null || !mWifiEntry.isSaved()) {
+ config.setSecurityParams(WifiConfiguration.SECURITY_TYPE_PSK);
+ }
if (mPasswordView.length() != 0) {
String password = mPasswordView.getText().toString();
if (password.matches("[0-9A-Fa-f]{64}")) {
@@ -642,13 +648,16 @@
case WifiEntry.SECURITY_EAP:
case WifiEntry.SECURITY_EAP_WPA3_ENTERPRISE:
case WifiEntry.SECURITY_EAP_SUITE_B:
- if (mWifiEntrySecurity == WifiEntry.SECURITY_EAP_SUITE_B) {
- // allowedSuiteBCiphers will be set according to certificate type
- config.setSecurityParams(WifiConfiguration.SECURITY_TYPE_EAP_SUITE_B);
- } else if (mWifiEntrySecurity == WifiEntry.SECURITY_EAP_WPA3_ENTERPRISE) {
- config.setSecurityParams(WifiConfiguration.SECURITY_TYPE_EAP_WPA3_ENTERPRISE);
- } else {
- config.setSecurityParams(WifiConfiguration.SECURITY_TYPE_EAP);
+ if (mWifiEntry == null || !mWifiEntry.isSaved()) {
+ if (mWifiEntrySecurity == WifiEntry.SECURITY_EAP_SUITE_B) {
+ // allowedSuiteBCiphers will be set according to certificate type
+ config.setSecurityParams(WifiConfiguration.SECURITY_TYPE_EAP_SUITE_B);
+ } else if (mWifiEntrySecurity == WifiEntry.SECURITY_EAP_WPA3_ENTERPRISE) {
+ config.setSecurityParams(
+ WifiConfiguration.SECURITY_TYPE_EAP_WPA3_ENTERPRISE);
+ } else {
+ config.setSecurityParams(WifiConfiguration.SECURITY_TYPE_EAP);
+ }
}
config.enterpriseConfig = new WifiEnterpriseConfig();
int eapMethod = mEapMethodSpinner.getSelectedItemPosition();
@@ -790,7 +799,9 @@
}
break;
case WifiEntry.SECURITY_SAE:
- config.setSecurityParams(WifiConfiguration.SECURITY_TYPE_SAE);
+ if (mWifiEntry == null || !mWifiEntry.isSaved()) {
+ config.setSecurityParams(WifiConfiguration.SECURITY_TYPE_SAE);
+ }
if (mPasswordView.length() != 0) {
String password = mPasswordView.getText().toString();
config.preSharedKey = '"' + password + '"';
@@ -798,7 +809,9 @@
break;
case WifiEntry.SECURITY_OWE:
- config.setSecurityParams(WifiConfiguration.SECURITY_TYPE_OWE);
+ if (mWifiEntry == null || !mWifiEntry.isSaved()) {
+ config.setSecurityParams(WifiConfiguration.SECURITY_TYPE_OWE);
+ }
break;
default:
diff --git a/tests/robotests/src/com/android/settings/bluetooth/RequestPermissionHelperTest.kt b/tests/robotests/src/com/android/settings/bluetooth/RequestPermissionHelperTest.kt
new file mode 100644
index 0000000..ce0792c
--- /dev/null
+++ b/tests/robotests/src/com/android/settings/bluetooth/RequestPermissionHelperTest.kt
@@ -0,0 +1,247 @@
+/*
+ * 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.bluetooth
+
+import androidx.activity.ComponentActivity
+import com.android.settings.R
+import com.android.settings.testutils.shadow.ShadowAlertDialogCompat
+import com.google.common.truth.Truth.assertThat
+import org.junit.After
+import org.junit.Before
+import org.junit.Test
+import org.junit.runner.RunWith
+import org.mockito.Mockito.spy
+import org.robolectric.RobolectricTestRunner
+import org.robolectric.android.controller.ActivityController
+import org.robolectric.annotation.Config
+import org.mockito.Mockito.`when` as whenever
+
+@RunWith(RobolectricTestRunner::class)
+@Config(shadows = [ShadowAlertDialogCompat::class])
+class RequestPermissionHelperTest {
+ private lateinit var activityController: ActivityController<ComponentActivity>
+
+ @Before
+ fun setUp() {
+ activityController =
+ ActivityController.of(ComponentActivity()).create().start().postCreate(null).resume()
+ }
+
+ @After
+ fun tearDown() {
+ activityController.pause().stop().destroy()
+ }
+
+ @Test
+ fun requestEnable_withAppLabelAndNoTimeout_hasCorrectMessage() {
+ val activity = activityController.get()
+ RequestPermissionHelper.requestEnable(
+ context = activity,
+ appLabel = "App Label",
+ timeout = -1,
+ onAllow = {},
+ onDeny = {},
+ )
+
+ assertLatestMessageIs("App Label wants to turn on Bluetooth")
+ }
+
+ @Test
+ fun requestEnable_withAppLabelAndZeroTimeout_hasCorrectMessage() {
+ val activity = activityController.get()
+ RequestPermissionHelper.requestEnable(
+ context = activity,
+ appLabel = "App Label",
+ timeout = 0,
+ onAllow = {},
+ onDeny = {},
+ )
+
+ assertLatestMessageIs(
+ "App Label wants to turn on Bluetooth and make your phone visible to other devices. " +
+ "You can change this later in Bluetooth settings."
+ )
+ }
+
+ @Test
+ fun requestEnable_withAppLabelAndNormalTimeout_hasCorrectMessage() {
+ val activity = activityController.get()
+ RequestPermissionHelper.requestEnable(
+ context = activity,
+ appLabel = "App Label",
+ timeout = 120,
+ onAllow = {},
+ onDeny = {},
+ )
+
+ assertLatestMessageIs(
+ "App Label wants to turn on Bluetooth and make your phone visible to other devices " +
+ "for 120 seconds."
+ )
+ }
+
+ @Test
+ fun requestEnable_withNoAppLabelAndNoTimeout_hasCorrectMessage() {
+ val activity = activityController.get()
+ RequestPermissionHelper.requestEnable(
+ context = activity,
+ appLabel = null,
+ timeout = -1,
+ onAllow = {},
+ onDeny = {},
+ )
+
+ assertLatestMessageIs("An app wants to turn on Bluetooth")
+ }
+
+ @Test
+ fun requestEnable_withNoAppLabelAndZeroTimeout_hasCorrectMessage() {
+ val activity = activityController.get()
+ RequestPermissionHelper.requestEnable(
+ context = activity,
+ appLabel = null,
+ timeout = 0,
+ onAllow = {},
+ onDeny = {},
+ )
+
+ assertLatestMessageIs(
+ "An app wants to turn on Bluetooth and make your phone visible to other devices. " +
+ "You can change this later in Bluetooth settings."
+ )
+ }
+
+ @Test
+ fun requestEnable_withNoAppLabelAndNormalTimeout_hasCorrectMessage() {
+ val activity = activityController.get()
+ RequestPermissionHelper.requestEnable(
+ context = activity,
+ appLabel = null,
+ timeout = 120,
+ onAllow = {},
+ onDeny = {},
+ )
+
+ assertLatestMessageIs(
+ "An app wants to turn on Bluetooth and make your phone visible to other devices for " +
+ "120 seconds."
+ )
+ }
+
+ @Test
+ fun requestEnable_whenAutoConfirm_onAllowIsCalled() {
+ val activity = getActivityWith(autoConfirm = true)
+ var onAllowCalled = false
+
+ RequestPermissionHelper.requestEnable(
+ context = activity,
+ appLabel = null,
+ timeout = -1,
+ onAllow = { onAllowCalled = true },
+ onDeny = {},
+ )
+
+ assertThat(onAllowCalled).isTrue()
+ }
+
+ @Test
+ fun requestEnable_whenNotAutoConfirm_onAllowIsNotCalledWhenRequest() {
+ val activity = getActivityWith(autoConfirm = false)
+ var onAllowCalled = false
+
+ RequestPermissionHelper.requestEnable(
+ context = activity,
+ appLabel = null,
+ timeout = -1,
+ onAllow = { onAllowCalled = true },
+ onDeny = {},
+ )
+
+ assertThat(onAllowCalled).isFalse()
+ }
+
+ @Test
+ fun requestDisable_withAppLabel_hasCorrectMessage() {
+ val activity = activityController.get()
+ RequestPermissionHelper.requestDisable(
+ context = activity,
+ appLabel = "App Label",
+ onAllow = {},
+ onDeny = {},
+ )
+
+ assertLatestMessageIs("App Label wants to turn off Bluetooth")
+ }
+
+ @Test
+ fun requestDisable_withNoAppLabel_hasCorrectMessage() {
+ val activity = activityController.get()
+ RequestPermissionHelper.requestDisable(
+ context = activity,
+ appLabel = null,
+ onAllow = {},
+ onDeny = {},
+ )
+
+ assertLatestMessageIs("An app wants to turn off Bluetooth")
+ }
+
+ @Test
+ fun requestDisable_whenAutoConfirm_onAllowIsCalled() {
+ val activity = getActivityWith(autoConfirm = true)
+ var onAllowCalled = false
+
+ RequestPermissionHelper.requestDisable(
+ context = activity,
+ appLabel = null,
+ onAllow = { onAllowCalled = true },
+ onDeny = {},
+ )
+
+ assertThat(onAllowCalled).isTrue()
+ }
+
+ @Test
+ fun requestDisable_whenNotAutoConfirm_onAllowIsNotCalledWhenRequest() {
+ val activity = getActivityWith(autoConfirm = false)
+ var onAllowCalled = false
+
+ RequestPermissionHelper.requestDisable(
+ context = activity,
+ appLabel = null,
+ onAllow = { onAllowCalled = true },
+ onDeny = {},
+ )
+
+ assertThat(onAllowCalled).isFalse()
+ }
+
+ private fun getActivityWith(autoConfirm: Boolean): ComponentActivity {
+ val activity = spy(activityController.get())
+ val spyResources = spy(activity.resources)
+ whenever(activity.resources).thenReturn(spyResources)
+ whenever(spyResources.getBoolean(R.bool.auto_confirm_bluetooth_activation_dialog))
+ .thenReturn(autoConfirm)
+ return activity
+ }
+
+ private fun assertLatestMessageIs(message: String) {
+ val dialog = ShadowAlertDialogCompat.getLatestAlertDialog()
+ val shadowDialog = ShadowAlertDialogCompat.shadowOf(dialog)
+ assertThat(shadowDialog.message.toString()).isEqualTo(message)
+ }
+}
diff --git a/tests/robotests/src/com/android/settings/development/ForceEnableNotesRolePreferenceControllerTest.java b/tests/robotests/src/com/android/settings/development/ForceEnableNotesRolePreferenceControllerTest.java
new file mode 100644
index 0000000..32a28fe
--- /dev/null
+++ b/tests/robotests/src/com/android/settings/development/ForceEnableNotesRolePreferenceControllerTest.java
@@ -0,0 +1,102 @@
+/*
+ * 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.development;
+
+import static org.junit.Assert.assertFalse;
+import static org.junit.Assert.assertTrue;
+import static org.mockito.Mockito.verify;
+import static org.mockito.Mockito.when;
+
+import androidx.preference.PreferenceScreen;
+import androidx.preference.SwitchPreference;
+
+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.RuntimeEnvironment;
+
+@RunWith(RobolectricTestRunner.class)
+public class ForceEnableNotesRolePreferenceControllerTest {
+
+ @Mock
+ private PreferenceScreen mScreen;
+ @Mock
+ private SwitchPreference mPreference;
+
+ private ForceEnableNotesRolePreferenceController mController;
+
+ @Before
+ public void setUp() {
+ MockitoAnnotations.initMocks(this);
+ mController = new ForceEnableNotesRolePreferenceController(
+ RuntimeEnvironment.application) {
+ private boolean mEnabled;
+
+ protected boolean isEnabled() {
+ return mEnabled;
+ }
+
+ protected void setEnabled(boolean enabled) {
+ mEnabled = enabled;
+ }
+ };
+ when(mScreen.findPreference(mController.getPreferenceKey())).thenReturn(mPreference);
+ mController.displayPreference(mScreen);
+ }
+
+ @Test
+ public void updateState_enabled_preferenceShouldBeChecked() {
+ mController.setEnabled(true);
+ mController.updateState(mPreference);
+
+ verify(mPreference).setChecked(true);
+ }
+
+ @Test
+ public void updateState_disabled_preferenceShouldBeUnchecked() {
+ mController.setEnabled(false);
+ mController.updateState(mPreference);
+
+ verify(mPreference).setChecked(false);
+ }
+
+ @Test
+ public void onPreferenceChange_checked_shouldBeEnabled() {
+ mController.onPreferenceChange(mPreference, true);
+
+ assertTrue(mController.isEnabled());
+ }
+
+ @Test
+ public void onPreferenceChange_unchecked_shouldNotBeEnabled() {
+ mController.onPreferenceChange(mPreference, false);
+
+ assertFalse(mController.isEnabled());
+ }
+
+ @Test
+ public void onDeveloperOptionsSwitchDisabled_preferenceShouldNotBeEnabled() {
+ mController.onDeveloperOptionsSwitchDisabled();
+
+ assertFalse(mController.isEnabled());
+ verify(mPreference).setEnabled(false);
+ verify(mPreference).setChecked(false);
+ }
+}
diff --git a/tests/robotests/src/com/android/settings/display/AmbientDisplayAlwaysOnPreferenceControllerTest.java b/tests/robotests/src/com/android/settings/display/AmbientDisplayAlwaysOnPreferenceControllerTest.java
index 405ea12..3ad14e5 100644
--- a/tests/robotests/src/com/android/settings/display/AmbientDisplayAlwaysOnPreferenceControllerTest.java
+++ b/tests/robotests/src/com/android/settings/display/AmbientDisplayAlwaysOnPreferenceControllerTest.java
@@ -74,7 +74,7 @@
mController.setConfig(mConfig);
mApplicationInfo.uid = 1;
- when(mContext.getString(R.string.config_defaultWellbeingPackage)).thenReturn(TEST_PACKAGE);
+ when(mContext.getString(R.string.config_systemWellbeing)).thenReturn(TEST_PACKAGE);
when(mContext.getPackageManager()).thenReturn(mPackageManager);
doReturn(mApplicationInfo).when(mPackageManager).getApplicationInfo(
diff --git a/tests/robotests/src/com/android/settings/display/darkmode/DarkModeCustomBedtimePreferenceControllerTest.java b/tests/robotests/src/com/android/settings/display/darkmode/DarkModeCustomBedtimePreferenceControllerTest.java
index 7f50568..85d6fab 100644
--- a/tests/robotests/src/com/android/settings/display/darkmode/DarkModeCustomBedtimePreferenceControllerTest.java
+++ b/tests/robotests/src/com/android/settings/display/darkmode/DarkModeCustomBedtimePreferenceControllerTest.java
@@ -77,7 +77,7 @@
when(mContext.getSystemService(UiModeManager.class)).thenReturn(mService);
when(mContext.getResources()).thenReturn(mResources);
- when(mResources.getString(com.android.internal.R.string.config_defaultWellbeingPackage))
+ when(mResources.getString(com.android.internal.R.string.config_systemWellbeing))
.thenReturn("wellbeing");
when(mScreen.findPreference(anyString())).thenReturn(mFooterPreference);
diff --git a/tests/robotests/src/com/android/settings/display/darkmode/DarkModeScheduleSelectorControllerTest.java b/tests/robotests/src/com/android/settings/display/darkmode/DarkModeScheduleSelectorControllerTest.java
index d776e5e..d95635e 100644
--- a/tests/robotests/src/com/android/settings/display/darkmode/DarkModeScheduleSelectorControllerTest.java
+++ b/tests/robotests/src/com/android/settings/display/darkmode/DarkModeScheduleSelectorControllerTest.java
@@ -84,7 +84,7 @@
when(mContext.getSystemService(LocationManager.class)).thenReturn(mLocationManager);
when(mContext.getResources()).thenReturn(mResources);
when(mResources.getConfiguration()).thenReturn(mConfigNightNo);
- when(mResources.getString(com.android.internal.R.string.config_defaultWellbeingPackage))
+ when(mResources.getString(com.android.internal.R.string.config_systemWellbeing))
.thenReturn("wellbeing");
when(mContext.getString(R.string.dark_ui_auto_mode_never)).thenReturn("never");
diff --git a/tests/robotests/src/com/android/settings/dream/WhenToDreamPreferenceControllerTest.java b/tests/robotests/src/com/android/settings/dream/WhenToDreamPreferenceControllerTest.java
index 6e687bb..e173add 100644
--- a/tests/robotests/src/com/android/settings/dream/WhenToDreamPreferenceControllerTest.java
+++ b/tests/robotests/src/com/android/settings/dream/WhenToDreamPreferenceControllerTest.java
@@ -72,7 +72,7 @@
mApplicationInfo.uid = 1;
when(mContext.getString(
- com.android.internal.R.string.config_defaultWellbeingPackage)).thenReturn(
+ com.android.internal.R.string.config_systemWellbeing)).thenReturn(
TEST_PACKAGE);
when(mContext.getPackageManager()).thenReturn(mPackageManager);
diff --git a/tests/robotests/src/com/android/settings/fuelgauge/batterytip/detectors/IncompatibleChargerDetectorTest.java b/tests/robotests/src/com/android/settings/fuelgauge/batterytip/detectors/IncompatibleChargerDetectorTest.java
index 1dfe6e2..9ababe7 100644
--- a/tests/robotests/src/com/android/settings/fuelgauge/batterytip/detectors/IncompatibleChargerDetectorTest.java
+++ b/tests/robotests/src/com/android/settings/fuelgauge/batterytip/detectors/IncompatibleChargerDetectorTest.java
@@ -25,7 +25,6 @@
import android.hardware.usb.UsbPort;
import android.hardware.usb.UsbPortStatus;
-import com.android.settings.fuelgauge.BatteryInfo;
import com.android.settings.fuelgauge.batterytip.tips.BatteryTip;
import org.junit.Before;
@@ -42,7 +41,6 @@
@RunWith(RobolectricTestRunner.class)
public final class IncompatibleChargerDetectorTest {
- @Mock private BatteryInfo mBatteryInfo;
@Mock private UsbPort mUsbPort;
@Mock private UsbManager mUsbManager;
@Mock private UsbPortStatus mUsbPortStatus;
@@ -55,14 +53,11 @@
MockitoAnnotations.initMocks(this);
mContext = spy(RuntimeEnvironment.application);
when(mContext.getSystemService(UsbManager.class)).thenReturn(mUsbManager);
- mIncompatibleChargerDetector =
- new IncompatibleChargerDetector(mContext, mBatteryInfo);
+ mIncompatibleChargerDetector = new IncompatibleChargerDetector(mContext);
}
@Test
- public void detect_unplugDevice_shouldNotShowTip() {
- mBatteryInfo.pluggedStatus = 0;
-
+ public void detect_withoutIncompatibleCharger_shouldNotShowTip() {
BatteryTip batteryTip = mIncompatibleChargerDetector.detect();
assertThat(batteryTip.isVisible()).isFalse();
@@ -70,18 +65,7 @@
}
@Test
- public void detect_plugDeviceWithoutIncompatibleCharger_shouldNotShowTip() {
- mBatteryInfo.pluggedStatus = 1;
-
- BatteryTip batteryTip = mIncompatibleChargerDetector.detect();
-
- assertThat(batteryTip.isVisible()).isFalse();
- assertThat(batteryTip.getState()).isEqualTo(BatteryTip.StateType.INVISIBLE);
- }
-
- @Test
- public void detect_plugDeviceWithIncompatibleCharger_showTip() {
- mBatteryInfo.pluggedStatus = 1;
+ public void detect_withIncompatibleCharger_showTip() {
setupIncompatibleCharging();
BatteryTip batteryTip = mIncompatibleChargerDetector.detect();
diff --git a/tests/robotests/src/com/android/settings/fuelgauge/batteryusage/BatteryUsageBreakdownControllerTest.java b/tests/robotests/src/com/android/settings/fuelgauge/batteryusage/BatteryUsageBreakdownControllerTest.java
index 16fec09..8d0a839 100644
--- a/tests/robotests/src/com/android/settings/fuelgauge/batteryusage/BatteryUsageBreakdownControllerTest.java
+++ b/tests/robotests/src/com/android/settings/fuelgauge/batteryusage/BatteryUsageBreakdownControllerTest.java
@@ -176,7 +176,7 @@
}
@Test
- public void removeAndCacheAllUnusedPreferences_removePerf_buildCacheAndRemoveAllPreference() {
+ public void removeAndCacheAllUnusedPreferences_removePref_buildCacheAndRemoveAllPreference() {
doReturn(1).when(mAppListPreferenceGroup).getPreferenceCount();
doReturn(mPowerGaugePreference).when(mAppListPreferenceGroup).getPreference(0);
doReturn(PREF_KEY2).when(mBatteryHistEntry).getKey();
@@ -193,7 +193,7 @@
}
@Test
- public void removeAndCacheAllUnusedPreferences_keepPerf_KeepAllPreference() {
+ public void removeAndCacheAllUnusedPreferences_keepPref_KeepAllPreference() {
doReturn(1).when(mAppListPreferenceGroup).getPreferenceCount();
doReturn(mPowerGaugePreference).when(mAppListPreferenceGroup).getPreference(0);
doReturn(PREF_KEY).when(mBatteryHistEntry).getKey();
diff --git a/tests/robotests/src/com/android/settings/fuelgauge/batteryusage/DataProcessManagerTest.java b/tests/robotests/src/com/android/settings/fuelgauge/batteryusage/DataProcessManagerTest.java
index 753a7f7..2a00116 100644
--- a/tests/robotests/src/com/android/settings/fuelgauge/batteryusage/DataProcessManagerTest.java
+++ b/tests/robotests/src/com/android/settings/fuelgauge/batteryusage/DataProcessManagerTest.java
@@ -102,7 +102,7 @@
AppUsageEventEntity.KEY_UID,
AppUsageEventEntity.KEY_PACKAGE_NAME,
AppUsageEventEntity.KEY_TIMESTAMP});
- DatabaseUtils.sFakeAppUsageEventSupplier = () -> cursor;
+ DatabaseUtils.sFakeSupplier = () -> cursor;
doReturn(true).when(mUserManager).isUserUnlocked(anyInt());
mDataProcessManager.start();
@@ -171,7 +171,7 @@
cursor.addRow(new Object[] {
AppUsageEventType.ACTIVITY_STOPPED.getNumber(), /*timestamp=*/ 6, /*userId=*/ 1,
/*instanceId=*/ 2, packageName});
- DatabaseUtils.sFakeAppUsageEventSupplier = () -> cursor;
+ DatabaseUtils.sFakeSupplier = () -> cursor;
final DataProcessManager dataProcessManager = new DataProcessManager(
mContext, /*handler=*/ null, /*rawStartTimestamp=*/ 2L, /*callbackFunction=*/ null,
@@ -240,7 +240,7 @@
AppUsageEventEntity.KEY_TIMESTAMP});
// Adds fake data into the cursor.
cursor.addRow(new Object[] {101L, "app name1", 1001L});
- DatabaseUtils.sFakeAppUsageEventSupplier = () -> cursor;
+ DatabaseUtils.sFakeSupplier = () -> cursor;
mDataProcessManager.start();
diff --git a/tests/robotests/src/com/android/settings/fuelgauge/batteryusage/DatabaseUtilsTest.java b/tests/robotests/src/com/android/settings/fuelgauge/batteryusage/DatabaseUtilsTest.java
index 20799d4..efce44e 100644
--- a/tests/robotests/src/com/android/settings/fuelgauge/batteryusage/DatabaseUtilsTest.java
+++ b/tests/robotests/src/com/android/settings/fuelgauge/batteryusage/DatabaseUtilsTest.java
@@ -261,7 +261,7 @@
public void getAppUsageStartTimestampOfUser_emptyCursorContent_returnEarliestTimestamp() {
final MatrixCursor cursor =
new MatrixCursor(new String[] {AppUsageEventEntity.KEY_TIMESTAMP});
- DatabaseUtils.sFakeAppUsageLatestTimestampSupplier = () -> cursor;
+ DatabaseUtils.sFakeSupplier = () -> cursor;
final long earliestTimestamp = 10001L;
assertThat(DatabaseUtils.getAppUsageStartTimestampOfUser(
@@ -270,7 +270,7 @@
@Test
public void getAppUsageStartTimestampOfUser_nullCursor_returnEarliestTimestamp() {
- DatabaseUtils.sFakeAppUsageLatestTimestampSupplier = () -> null;
+ DatabaseUtils.sFakeSupplier = () -> null;
final long earliestTimestamp = 10001L;
assertThat(DatabaseUtils.getAppUsageStartTimestampOfUser(
mContext, /*userId=*/ 0, earliestTimestamp)).isEqualTo(earliestTimestamp);
@@ -283,7 +283,7 @@
new MatrixCursor(new String[] {AppUsageEventEntity.KEY_TIMESTAMP});
// Adds fake data into the cursor.
cursor.addRow(new Object[] {returnedTimestamp});
- DatabaseUtils.sFakeAppUsageLatestTimestampSupplier = () -> cursor;
+ DatabaseUtils.sFakeSupplier = () -> cursor;
final long earliestTimestamp1 = 1001L;
assertThat(DatabaseUtils.getAppUsageStartTimestampOfUser(
@@ -302,7 +302,7 @@
AppUsageEventEntity.KEY_PACKAGE_NAME,
AppUsageEventEntity.KEY_TIMESTAMP,
AppUsageEventEntity.KEY_APP_USAGE_EVENT_TYPE});
- DatabaseUtils.sFakeAppUsageEventSupplier = () -> cursor;
+ DatabaseUtils.sFakeSupplier = () -> cursor;
assertThat(DatabaseUtils.getAppUsageEventForUsers(
mContext,
@@ -313,7 +313,7 @@
@Test
public void getAppUsageEventForUsers_nullCursor_returnEmptyMap() {
- DatabaseUtils.sFakeAppUsageEventSupplier = () -> null;
+ DatabaseUtils.sFakeSupplier = () -> null;
assertThat(DatabaseUtils.getAppUsageEventForUsers(
mContext,
/*calendar=*/ null,
@@ -335,7 +335,7 @@
cursor.addRow(new Object[] {101L, "app name2", timestamp2});
cursor.addRow(new Object[] {101L, "app name3", timestamp2});
cursor.addRow(new Object[] {101L, "app name4", timestamp2});
- DatabaseUtils.sFakeAppUsageEventSupplier = () -> cursor;
+ DatabaseUtils.sFakeSupplier = () -> cursor;
final List<AppUsageEvent> appUsageEventList = DatabaseUtils.getAppUsageEventForUsers(
mContext,
@@ -356,7 +356,7 @@
BatteryHistEntry.KEY_UID,
BatteryHistEntry.KEY_USER_ID,
BatteryHistEntry.KEY_TIMESTAMP});
- DatabaseUtils.sFakeBatteryStateSupplier = () -> cursor;
+ DatabaseUtils.sFakeSupplier = () -> cursor;
assertThat(DatabaseUtils.getHistoryMapSinceLastFullCharge(
mContext, /*calendar=*/ null)).isEmpty();
@@ -364,7 +364,7 @@
@Test
public void getHistoryMapSinceLastFullCharge_nullCursor_returnEmptyMap() {
- DatabaseUtils.sFakeBatteryStateSupplier = () -> null;
+ DatabaseUtils.sFakeSupplier = () -> null;
assertThat(DatabaseUtils.getHistoryMapSinceLastFullCharge(
mContext, /*calendar=*/ null)).isEmpty();
}
@@ -383,7 +383,7 @@
"app name3", timestamp2, 3, ConvertUtils.CONSUMER_TYPE_UID_BATTERY});
cursor.addRow(new Object[] {
"app name4", timestamp2, 4, ConvertUtils.CONSUMER_TYPE_UID_BATTERY});
- DatabaseUtils.sFakeBatteryStateSupplier = () -> cursor;
+ DatabaseUtils.sFakeSupplier = () -> cursor;
final Map<Long, Map<String, BatteryHistEntry>> batteryHistMap =
DatabaseUtils.getHistoryMapSinceLastFullCharge(
@@ -413,7 +413,7 @@
doReturn(true).when(mUserManager).isManagedProfile();
doReturn(UserHandle.SYSTEM).when(mUserManager).getProfileParent(UserHandle.CURRENT);
- DatabaseUtils.sFakeBatteryStateSupplier = () -> getMatrixCursor();
+ DatabaseUtils.sFakeSupplier = () -> getMatrixCursor();
final Map<Long, Map<String, BatteryHistEntry>> batteryHistMap =
DatabaseUtils.getHistoryMapSinceLastFullCharge(
diff --git a/tests/robotests/src/com/android/settings/support/SupportDashboardActivityTest.java b/tests/robotests/src/com/android/settings/support/SupportDashboardActivityTest.java
index 0124551..f510994 100644
--- a/tests/robotests/src/com/android/settings/support/SupportDashboardActivityTest.java
+++ b/tests/robotests/src/com/android/settings/support/SupportDashboardActivityTest.java
@@ -16,6 +16,8 @@
package com.android.settings.support;
+import static com.android.settings.support.SupportDashboardActivity.ACTION_SUPPORT_SETTINGS;
+
import static com.google.common.truth.Truth.assertThat;
import android.content.Context;
@@ -59,7 +61,7 @@
mContext.getString(R.string.page_tab_title_support));
assertThat(value.intentTargetPackage).isEqualTo(mContext.getPackageName());
assertThat(value.intentTargetClass).isEqualTo(SupportDashboardActivity.class.getName());
- assertThat(value.intentAction).isEqualTo(Intent.ACTION_MAIN);
+ assertThat(value.intentAction).isEqualTo(ACTION_SUPPORT_SETTINGS);
}
@Test
diff --git a/tests/robotests/src/com/android/settings/wifi/WifiConfigController2Test.java b/tests/robotests/src/com/android/settings/wifi/WifiConfigController2Test.java
index ad086b7..faaa0fa 100644
--- a/tests/robotests/src/com/android/settings/wifi/WifiConfigController2Test.java
+++ b/tests/robotests/src/com/android/settings/wifi/WifiConfigController2Test.java
@@ -470,7 +470,7 @@
private void checkSavedMacRandomizedValue(int macRandomizedValue) {
when(mWifiEntry.isSaved()).thenReturn(true);
- final WifiConfiguration mockWifiConfig = mock(WifiConfiguration.class);
+ final WifiConfiguration mockWifiConfig = spy(new WifiConfiguration());
when(mockWifiConfig.getIpConfiguration()).thenReturn(mock(IpConfiguration.class));
when(mWifiEntry.getWifiConfiguration()).thenReturn(mockWifiConfig);
mockWifiConfig.macRandomizationSetting = macRandomizedValue;
@@ -809,9 +809,10 @@
private void setUpModifyingSavedPeapConfigController() {
when(mWifiEntry.isSaved()).thenReturn(true);
when(mWifiEntry.getSecurity()).thenReturn(WifiEntry.SECURITY_EAP);
- final WifiConfiguration mockWifiConfig = mock(WifiConfiguration.class);
+ final WifiConfiguration mockWifiConfig = spy(new WifiConfiguration());
+ mockWifiConfig.setSecurityParams(WifiConfiguration.SECURITY_TYPE_EAP);
when(mockWifiConfig.getIpConfiguration()).thenReturn(mock(IpConfiguration.class));
- final WifiEnterpriseConfig mockWifiEnterpriseConfig = mock(WifiEnterpriseConfig.class);
+ final WifiEnterpriseConfig mockWifiEnterpriseConfig = spy(new WifiEnterpriseConfig());
when(mockWifiEnterpriseConfig.getEapMethod()).thenReturn(Eap.PEAP);
mockWifiConfig.enterpriseConfig = mockWifiEnterpriseConfig;
when(mWifiEntry.getWifiConfiguration()).thenReturn(mockWifiConfig);
@@ -980,8 +981,8 @@
private void setUpModifyingSavedCertificateConfigController(String savedCaCertificate,
String savedUserCertificate) {
- final WifiConfiguration mockWifiConfig = mock(WifiConfiguration.class);
- final WifiEnterpriseConfig mockWifiEnterpriseConfig = mock(WifiEnterpriseConfig.class);
+ final WifiConfiguration mockWifiConfig = spy(new WifiConfiguration());
+ final WifiEnterpriseConfig mockWifiEnterpriseConfig = spy(new WifiEnterpriseConfig());
mockWifiConfig.enterpriseConfig = mockWifiEnterpriseConfig;
when(mWifiEntry.isSaved()).thenReturn(true);
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 cffc452..ae32651 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
@@ -33,6 +33,7 @@
import android.support.test.uiautomator.UiObject2;
import android.support.test.uiautomator.Until;
+import androidx.annotation.NonNull;
import androidx.test.InstrumentationRegistry;
import androidx.test.runner.AndroidJUnit4;
@@ -54,18 +55,25 @@
private static final String SETTINGS_PACKAGE_NAME = "com.android.settings";
private static final String ACTIVITY_CLASS_NAME =
"com.android.settings.biometrics2.ui.view.FingerprintEnrollmentActivity";
- public static final String EXTRA_IS_SETUP_FLOW = "isSetupFlow";
+ private static final String EXTRA_IS_SETUP_FLOW = "isSetupFlow";
+ 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 UDFPS_ENROLLING_TITLE = "Touch & hold the fingerprint sensor";
+ private static final String SFPS_ENROLLING_TITLE =
+ "Lift, then touch. Move your finger slightly each time.";
+ private static final String RFPS_ENROLLING_TITLE = "Lift, then touch again";
+
private UiDevice mDevice;
private byte[] mToken = new byte[]{};
private Context mContext;
private boolean mFingerprintPropCallbackLaunched;
private boolean mCanAssumeUdfps;
private boolean mCanAssumeSfps;
+ private String mEnrollingTitle;
private static final int IDLE_TIMEOUT = 10000;
@@ -94,6 +102,13 @@
final FingerprintSensorPropertiesInternal prop = list.get(0);
mCanAssumeUdfps = prop.isAnyUdfpsType();
mCanAssumeSfps = prop.isAnySidefpsType();
+ if (mCanAssumeUdfps) {
+ mEnrollingTitle = UDFPS_ENROLLING_TITLE;
+ } else if (mCanAssumeSfps) {
+ mEnrollingTitle = SFPS_ENROLLING_TITLE;
+ } else {
+ mEnrollingTitle = RFPS_ENROLLING_TITLE;
+ }
}
});
@@ -106,8 +121,9 @@
}
@Test
- public void testLaunchChooseLock() {
- launchFingerprintEnrollActivity(false, null);
+ public void testIntroChooseLock() {
+ final Intent intent = newActivityIntent();
+ mContext.startActivity(intent);
assertThat(mDevice.wait(Until.hasObject(By.text("Choose your backup screen lock method")),
IDLE_TIMEOUT)).isTrue();
}
@@ -135,12 +151,12 @@
}
@Test
- public void testLaunchWithGkPwHandle_withUdfps_clickStart() {
+ public void testIntroWithGkPwHandle_withUdfps_clickStart() {
assumeTrue(mCanAssumeUdfps);
LockScreenUtil.setLockscreen(LockScreenUtil.LockscreenType.PIN, TEST_PIN, true);
- launchFingerprintEnrollActivityWithGkPwHandle(false);
+ launchIntroWithGkPwHandle(false);
// Intro page
verifyIntroPage();
@@ -159,17 +175,16 @@
startBtn.click();
// Enrolling page
- assertThat(mDevice.wait(Until.hasObject(By.text("Touch & hold the fingerprint sensor")),
- IDLE_TIMEOUT)).isTrue();
+ assertThat(mDevice.wait(Until.hasObject(By.text(mEnrollingTitle)), IDLE_TIMEOUT)).isTrue();
}
@Test
- public void testLaunchWithGkPwHandle_withUdfps_clickLottie() {
+ public void testIntroWithGkPwHandle_withUdfps_clickLottie() {
assumeTrue(mCanAssumeUdfps);
LockScreenUtil.setLockscreen(LockScreenUtil.LockscreenType.PIN, TEST_PIN, true);
- launchFingerprintEnrollActivityWithGkPwHandle(false);
+ launchIntroWithGkPwHandle(false);
// Intro page
verifyIntroPage();
@@ -188,17 +203,16 @@
lottie.click();
// Enrolling page
- assertThat(mDevice.wait(Until.hasObject(By.text("Touch & hold the fingerprint sensor")),
- IDLE_TIMEOUT)).isTrue();
+ assertThat(mDevice.wait(Until.hasObject(By.text(mEnrollingTitle)), IDLE_TIMEOUT)).isTrue();
}
@Test
- public void testLaunchWithGkPwHandle_withSfps() {
+ public void testIntroWithGkPwHandle_withSfps() {
assumeTrue(mCanAssumeSfps);
LockScreenUtil.setLockscreen(LockScreenUtil.LockscreenType.PIN, TEST_PIN, true);
- launchFingerprintEnrollActivityWithGkPwHandle(false);
+ launchIntroWithGkPwHandle(false);
// Intro page
verifyIntroPage();
@@ -216,12 +230,12 @@
}
@Test
- public void testLaunchWithGkPwHandle_withRfps() {
+ public void testIntroWithGkPwHandle_withRfps() {
assumeFalse(mCanAssumeUdfps || mCanAssumeSfps);
LockScreenUtil.setLockscreen(LockScreenUtil.LockscreenType.PIN, TEST_PIN, true);
- launchFingerprintEnrollActivityWithGkPwHandle(false);
+ launchIntroWithGkPwHandle(false);
// Intro page
verifyIntroPage();
@@ -241,10 +255,10 @@
}
@Test
- public void testLaunchWithGkPwHandle_clickNoThanksInIntroPage() {
+ public void testIntroWithGkPwHandle_clickNoThanksInIntroPage() {
LockScreenUtil.setLockscreen(LockScreenUtil.LockscreenType.PIN, TEST_PIN, true);
- launchFingerprintEnrollActivityWithGkPwHandle(false);
+ launchIntroWithGkPwHandle(false);
// Intro page
verifyIntroPage();
@@ -258,10 +272,10 @@
}
@Test
- public void testLaunchWithGkPwHandle_clickSkipInFindSensor() {
+ public void testIntroWithGkPwHandle_clickSkipInFindSensor() {
LockScreenUtil.setLockscreen(LockScreenUtil.LockscreenType.PIN, TEST_PIN, true);
- launchFingerprintEnrollActivityWithGkPwHandle(false);
+ launchIntroWithGkPwHandle(false);
// Intro page
verifyIntroPage();
@@ -282,10 +296,10 @@
}
@Test
- public void testLaunchWithGkPwHandle_clickSkipAnywayInFindFpsDialog_whenIsSuw() {
+ public void testIntroWithGkPwHandle_clickSkipAnywayInFindFpsDialog_whenIsSuw() {
LockScreenUtil.setLockscreen(LockScreenUtil.LockscreenType.PIN, TEST_PIN, true);
- launchFingerprintEnrollActivityWithGkPwHandle(true);
+ launchIntroWithGkPwHandle(true);
// Intro page
verifyIntroPage();
@@ -315,10 +329,10 @@
}
@Test
- public void testLaunchWithGkPwHandle_clickGoBackInFindFpsDialog_whenIsSuw() {
+ public void testIntroWithGkPwHandle_clickGoBackInFindFpsDialog_whenIsSuw() {
LockScreenUtil.setLockscreen(LockScreenUtil.LockscreenType.PIN, TEST_PIN, true);
- launchFingerprintEnrollActivityWithGkPwHandle(true);
+ launchIntroWithGkPwHandle(true);
// Intro page
verifyIntroPage();
@@ -346,43 +360,138 @@
}
@Test
- public void testLaunchCheckPin() {
+ public void testIntroCheckPin() {
LockScreenUtil.setLockscreen(LockScreenUtil.LockscreenType.PIN, TEST_PIN, true);
- launchFingerprintEnrollActivity(false, null);
+ final Intent intent = newActivityIntent();
+ mContext.startActivity(intent);
assertThat(mDevice.wait(Until.hasObject(By.text("Enter your device PIN to continue")),
IDLE_TIMEOUT)).isTrue();
}
+ @Test
+ public void testEnrollingWithGkPwHandle() {
+ LockScreenUtil.setLockscreen(LockScreenUtil.LockscreenType.PIN, TEST_PIN, true);
+
+ launchEnrollingWithGkPwHandle();
+
+ // Enrolling screen
+ mDevice.waitForIdle();
+ assertThat(mDevice.wait(Until.hasObject(By.text(mEnrollingTitle)), IDLE_TIMEOUT)).isTrue();
+ }
+
+ @Test
+ public void testEnrollingIconTouchDialog_withSfps() {
+ assumeTrue(mCanAssumeSfps);
+
+ LockScreenUtil.setLockscreen(LockScreenUtil.LockscreenType.PIN, TEST_PIN, true);
+
+ launchEnrollingWithGkPwHandle();
+
+ // Enrolling screen
+ mDevice.waitForIdle();
+ assertThat(mDevice.wait(Until.hasObject(By.text(mEnrollingTitle)), IDLE_TIMEOUT)).isTrue();
+
+ final UiObject2 lottie = mDevice.findObject(By.res(SETTINGS_PACKAGE_NAME,
+ "illustration_lottie"));
+ assertThat(lottie).isNotNull();
+
+ lottie.click();
+ lottie.click();
+ lottie.click();
+
+ // IconTouchDialog
+ mDevice.waitForIdle();
+ assertThat(mDevice.wait(Until.hasObject(By.text("Touch the sensor instead")), IDLE_TIMEOUT))
+ .isTrue();
+ final UiObject2 okButton = mDevice.findObject(By.text("OK"));
+ assertThat(okButton).isNotNull();
+
+ okButton.click();
+
+ // Enrolling screen again
+ mDevice.waitForIdle();
+ assertThat(mDevice.wait(Until.hasObject(By.text(mEnrollingTitle)), IDLE_TIMEOUT)).isTrue();
+ }
+
+ @Test
+ public void testEnrollingIconTouchDialog_withRfps() {
+ assumeFalse(mCanAssumeUdfps || mCanAssumeSfps);
+
+ LockScreenUtil.setLockscreen(LockScreenUtil.LockscreenType.PIN, TEST_PIN, true);
+
+ launchEnrollingWithGkPwHandle();
+
+ // Enrolling screen
+ mDevice.waitForIdle();
+ assertThat(mDevice.wait(Until.hasObject(By.text(mEnrollingTitle)), IDLE_TIMEOUT)).isTrue();
+
+ final UiObject2 lottie = mDevice.findObject(By.res(SETTINGS_PACKAGE_NAME,
+ "fingerprint_progress_bar"));
+ assertThat(lottie).isNotNull();
+
+ lottie.click();
+ lottie.click();
+ lottie.click();
+
+ // IconTouchDialog
+ mDevice.waitForIdle();
+ assertThat(mDevice.wait(Until.hasObject(By.text("Whoops, that\u2019s not the sensor")),
+ IDLE_TIMEOUT)).isTrue();
+ final UiObject2 okButton = mDevice.findObject(By.text("OK"));
+ assertThat(okButton).isNotNull();
+
+ okButton.click();
+
+ // Enrolling screen again
+ mDevice.waitForIdle();
+ assertThat(mDevice.wait(Until.hasObject(By.text(mEnrollingTitle)), IDLE_TIMEOUT)).isTrue();
+ }
+
@After
public void tearDown() throws Exception {
LockScreenUtil.resetLockscreen(TEST_PIN);
mDevice.pressHome();
}
- private void launchFingerprintEnrollActivityWithGkPwHandle(boolean isSuw) {
+ private void launchIntroWithGkPwHandle(boolean isSuw) {
LockPatternUtils lockPatternUtils = new LockPatternUtils(mContext);
final LockscreenCredential lockscreenCredential = LockscreenCredential.createPin(TEST_PIN);
final int userId = UserHandle.myUserId();
final LockPatternChecker.OnVerifyCallback onVerifyCallback = (response, timeoutMs) -> {
- launchFingerprintEnrollActivity(isSuw, response.getGatekeeperPasswordHandle());
+ final Intent intent = newActivityIntent();
+ if (isSuw) {
+ intent.putExtra(EXTRA_IS_SETUP_FLOW, 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 launchFingerprintEnrollActivity(boolean isSuw, Long gkPwHandle) {
+ private void launchEnrollingWithGkPwHandle() {
+ 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_FIND_SENSOR, 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);
+ }
+
+ @NonNull
+ private Intent newActivityIntent() {
Intent intent = new Intent();
intent.setClassName(SETTINGS_PACKAGE_NAME, ACTIVITY_CLASS_NAME);
- if (isSuw) {
- intent.putExtra(EXTRA_IS_SETUP_FLOW, true);
- }
intent.putExtra(EXTRA_FROM_SETTINGS_SUMMARY, true);
intent.putExtra(EXTRA_PAGE_TRANSITION_TYPE, 1);
intent.putExtra(Intent.EXTRA_USER_ID, mContext.getUserId());
- if (gkPwHandle != null) {
- intent.putExtra(EXTRA_KEY_GK_PW_HANDLE, gkPwHandle);
- }
intent.setFlags(Intent.FLAG_ACTIVITY_CLEAR_TOP | Intent.FLAG_ACTIVITY_NEW_TASK);
- mContext.startActivity(intent);
+ return intent;
+
}
}
diff --git a/tests/unit/src/com/android/settings/biometrics2/ui/viewmodel/FingerprintEnrollEnrollingViewModelTest.java b/tests/unit/src/com/android/settings/biometrics2/ui/viewmodel/FingerprintEnrollEnrollingViewModelTest.java
index 4de1057..fb0937e 100644
--- a/tests/unit/src/com/android/settings/biometrics2/ui/viewmodel/FingerprintEnrollEnrollingViewModelTest.java
+++ b/tests/unit/src/com/android/settings/biometrics2/ui/viewmodel/FingerprintEnrollEnrollingViewModelTest.java
@@ -21,7 +21,6 @@
import static android.hardware.fingerprint.FingerprintSensorProperties.TYPE_UDFPS_ULTRASONIC;
import static com.android.settings.biometrics2.ui.viewmodel.FingerprintEnrollEnrollingViewModel.ErrorDialogData;
-import static com.android.settings.biometrics2.ui.viewmodel.FingerprintEnrollEnrollingViewModel.FINGERPRINT_ENROLL_ENROLLING_ACTION_DISMISS_ICON_TOUCH_DIALOG;
import static com.android.settings.biometrics2.ui.viewmodel.FingerprintEnrollEnrollingViewModel.FINGERPRINT_ENROLL_ENROLLING_ACTION_SHOW_ICON_TOUCH_DIALOG;
import static com.android.settings.biometrics2.ui.viewmodel.FingerprintEnrollEnrollingViewModel.FINGERPRINT_ENROLL_ENROLLING_CANCELED_BECAUSE_BACK_PRESSED;
import static com.android.settings.biometrics2.ui.viewmodel.FingerprintEnrollEnrollingViewModel.FINGERPRINT_ENROLL_ENROLLING_CANCELED_BECAUSE_USER_SKIP;
@@ -103,10 +102,6 @@
mViewModel.showIconTouchDialog();
assertThat(actionLiveData.getValue()).isEqualTo(
FINGERPRINT_ENROLL_ENROLLING_ACTION_SHOW_ICON_TOUCH_DIALOG);
-
- mViewModel.onIconTouchDialogDismiss();
- assertThat(actionLiveData.getValue()).isEqualTo(
- FINGERPRINT_ENROLL_ENROLLING_ACTION_DISMISS_ICON_TOUCH_DIALOG);
}
@Test