Merge "Add visibility control for the UiBlocker" into tm-dev
diff --git a/AndroidManifest.xml b/AndroidManifest.xml
index 9986e34..164d42e 100644
--- a/AndroidManifest.xml
+++ b/AndroidManifest.xml
@@ -205,7 +205,9 @@
</receiver>
<activity android:name=".SubSettings"
- android:theme="@style/Theme.SubSettings" />
+ android:exported="false"
+ android:theme="@style/Theme.SubSettings"
+ android:taskAffinity="com.android.settings.root" />
<activity android:name=".Settings$CreateShortcutActivity"
android:exported="true"
@@ -620,6 +622,17 @@
android:value="@string/menu_key_security"/>
</activity>
+ <activity android:name="Settings$FaceSettingsInternalActivity"
+ android:label="@string/security_settings_face_preference_title"
+ android:exported="false"
+ android:icon="@drawable/ic_face_header"
+ android:taskAffinity="com.android.settings.root">
+ <meta-data android:name="com.android.settings.FRAGMENT_CLASS"
+ android:value="com.android.settings.biometrics.face.FaceSettings" />
+ <meta-data android:name="com.android.settings.HIGHLIGHT_MENU_KEY"
+ android:value="@string/menu_key_security"/>
+ </activity>
+
<activity android:name="Settings$FingerprintSettingsActivity"
android:label="@string/security_settings_fingerprint_preference_title"
android:exported="true"
@@ -636,7 +649,8 @@
<activity android:name="Settings$CombinedBiometricSettingsActivity"
android:label="@string/security_settings_biometric_preference_title"
- android:exported="false">
+ android:exported="false"
+ android:taskAffinity="com.android.settings.root">
<meta-data android:name="com.android.settings.FRAGMENT_CLASS"
android:value="com.android.settings.biometrics.combination.CombinedBiometricSettings" />
<meta-data android:name="com.android.settings.HIGHLIGHT_MENU_KEY"
@@ -721,7 +735,7 @@
android:name="Settings$WifiTetherSettingsActivity"
android:label="@string/wifi_hotspot_checkbox_text"
android:exported="true"
- android:icon="@drawable/ic_wifi_tethering">
+ android:icon="@drawable/ic_homepage_wifi_tethering">
<intent-filter>
<action android:name="com.android.settings.WIFI_TETHER_SETTINGS" />
<category android:name="android.intent.category.DEFAULT" />
@@ -766,7 +780,7 @@
android:name="Settings$VpnSettingsActivity"
android:label="@string/vpn_settings_title"
android:exported="true"
- android:icon="@drawable/ic_settings_wireless">
+ android:icon="@drawable/ic_homepage_vpn">
<intent-filter android:priority="1">
<action android:name="android.settings.VPN_SETTINGS" />
<action android:name="android.net.vpn.SETTINGS" />
@@ -2180,14 +2194,19 @@
android:screenOrientation="portrait"/>
<activity android:name=".biometrics.face.FaceEnrollIntroduction"
- android:exported="true"
- android:screenOrientation="portrait">
+ android:exported="true"
+ android:screenOrientation="portrait">
<intent-filter>
<action android:name="android.settings.FACE_ENROLL"/>
<category android:name="android.intent.category.DEFAULT"/>
</intent-filter>
</activity>
+ <activity android:name=".biometrics.face.FaceEnrollIntroductionInternal"
+ android:exported="false"
+ android:screenOrientation="portrait"
+ android:taskAffinity="com.android.settings.root" />
+
<activity android:name=".biometrics.face.FaceEnrollEducation"
android:exported="false"
android:screenOrientation="portrait"/>
@@ -2217,7 +2236,9 @@
</intent-filter>
</activity>
- <activity android:name=".biometrics.fingerprint.FingerprintSettings" android:exported="false"/>
+ <activity android:name=".biometrics.fingerprint.FingerprintSettings"
+ android:exported="false"
+ android:taskAffinity="com.android.settings.root" />
<activity android:name=".biometrics.fingerprint.FingerprintEnrollFindSensor" android:exported="false"/>
<activity android:name=".biometrics.fingerprint.FingerprintEnrollEnrolling" android:exported="false"/>
<activity android:name=".biometrics.fingerprint.FingerprintEnrollFinish" android:exported="false"/>
@@ -2231,6 +2252,11 @@
</intent-filter>
</activity>
+ <activity android:name=".biometrics.fingerprint.FingerprintEnrollIntroductionInternal"
+ android:exported="false"
+ android:theme="@style/GlifTheme.Light"
+ android:taskAffinity="com.android.settings.root" />
+
<activity android:name=".biometrics.fingerprint.SetupFingerprintEnrollFindSensor" android:exported="false"/>
<activity android:name=".biometrics.fingerprint.SetupFingerprintEnrollEnrolling" android:exported="false"/>
<activity android:name=".biometrics.fingerprint.SetupFingerprintEnrollFinish" android:exported="false"/>
@@ -2910,7 +2936,7 @@
android:name="Settings$DataUsageSummaryActivity"
android:label="@string/data_usage_summary_title"
android:exported="true"
- android:icon="@drawable/ic_settings_data_usage">
+ android:icon="@drawable/ic_homepage_data_usage">
<intent-filter android:priority="1">
<action android:name="android.settings.DATA_USAGE_SETTINGS" />
<category android:name="android.intent.category.DEFAULT" />
@@ -4294,6 +4320,7 @@
android:name=".sim.ChooseSimActivity"
android:theme="@style/GlifV3Theme.DayNight.NoActionBar"
android:launchMode="singleInstance"
+ android:excludeFromRecents="true"
android:exported="false"/>
<activity
diff --git a/res/drawable/ic_homepage_data_usage.xml b/res/drawable/ic_homepage_data_usage.xml
new file mode 100644
index 0000000..6d1227b
--- /dev/null
+++ b/res/drawable/ic_homepage_data_usage.xml
@@ -0,0 +1,33 @@
+<?xml version="1.0" encoding="utf-8"?>
+<!--
+ Copyright (C) 2022 The Android Open Source Project
+
+ Licensed under the Apache License, Version 2.0 (the "License");
+ you may not use this file except in compliance with the License.
+ You may obtain a copy of the License at
+
+ http://www.apache.org/licenses/LICENSE-2.0
+
+ Unless required by applicable law or agreed to in writing, software
+ distributed under the License is distributed on an "AS IS" BASIS,
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ See the License for the specific language governing permissions and
+ limitations under the License.
+ -->
+
+<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_network_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_settings_data_usage" />
+</layer-list>
diff --git a/res/drawable/ic_homepage_vpn.xml b/res/drawable/ic_homepage_vpn.xml
new file mode 100644
index 0000000..d1fba0e
--- /dev/null
+++ b/res/drawable/ic_homepage_vpn.xml
@@ -0,0 +1,33 @@
+<?xml version="1.0" encoding="utf-8"?>
+<!--
+ Copyright (C) 2022 The Android Open Source Project
+
+ Licensed under the Apache License, Version 2.0 (the "License");
+ you may not use this file except in compliance with the License.
+ You may obtain a copy of the License at
+
+ http://www.apache.org/licenses/LICENSE-2.0
+
+ Unless required by applicable law or agreed to in writing, software
+ distributed under the License is distributed on an "AS IS" BASIS,
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ See the License for the specific language governing permissions and
+ limitations under the License.
+ -->
+
+<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_network_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_settings_wireless" />
+</layer-list>
diff --git a/res/drawable/ic_homepage_wifi_tethering.xml b/res/drawable/ic_homepage_wifi_tethering.xml
new file mode 100644
index 0000000..fd4c051
--- /dev/null
+++ b/res/drawable/ic_homepage_wifi_tethering.xml
@@ -0,0 +1,33 @@
+<?xml version="1.0" encoding="utf-8"?>
+<!--
+ Copyright (C) 2022 The Android Open Source Project
+
+ Licensed under the Apache License, Version 2.0 (the "License");
+ you may not use this file except in compliance with the License.
+ You may obtain a copy of the License at
+
+ http://www.apache.org/licenses/LICENSE-2.0
+
+ Unless required by applicable law or agreed to in writing, software
+ distributed under the License is distributed on an "AS IS" BASIS,
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ See the License for the specific language governing permissions and
+ limitations under the License.
+ -->
+
+<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_network_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_wifi_tethering" />
+</layer-list>
diff --git a/res/layout/accessibility_shortcut_secondary_action.xml b/res/layout/accessibility_shortcut_secondary_action.xml
index 8d0ef3b..bdb129f 100644
--- a/res/layout/accessibility_shortcut_secondary_action.xml
+++ b/res/layout/accessibility_shortcut_secondary_action.xml
@@ -21,17 +21,15 @@
android:layout_height="wrap_content"
android:minHeight="?android:attr/listPreferredItemHeightSmall"
android:gravity="center_vertical"
- android:paddingStart="?android:attr/listPreferredItemPaddingStart"
- android:paddingEnd="?android:attr/listPreferredItemPaddingEnd"
android:clipToPadding="false">
<LinearLayout
android:id="@+id/main_frame"
android:layout_width="0dp"
android:layout_height="wrap_content"
+ android:paddingStart="?android:attr/listPreferredItemPaddingStart"
android:layout_weight="1"
- android:gravity="start|center_vertical"
- >
+ android:gravity="start|center_vertical">
<FrameLayout
android:id="@+id/icon_frame"
@@ -91,6 +89,7 @@
android:layout_width="wrap_content"
android:layout_height="match_parent"
android:gravity="end|center_vertical"
+ android:paddingEnd="?android:attr/listPreferredItemPaddingEnd"
android:minWidth="58dp"
android:orientation="vertical" />
diff --git a/res/layout/tare_dropdown_page.xml b/res/layout/tare_dropdown_page.xml
index 674b189..9ec7ebf 100644
--- a/res/layout/tare_dropdown_page.xml
+++ b/res/layout/tare_dropdown_page.xml
@@ -16,8 +16,10 @@
android:theme="@style/Widget.PopupWindow.Settings" />
<FrameLayout
android:id="@+id/frame_layout"
- android:layout_width="match_parent"
+ android:layout_width="0dp"
android:layout_height="wrap_content"
+ app:layout_constrainedWidth="true"
+ app:layout_constrainedHeight="true"
app:layout_constraintBottom_toBottomOf="parent"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintStart_toStartOf="parent"
diff --git a/res/values/strings.xml b/res/values/strings.xml
index 03fc59f..2d3532c 100644
--- a/res/values/strings.xml
+++ b/res/values/strings.xml
@@ -5293,7 +5293,7 @@
<!-- Message for the mail content of the accessibility text reading preview. [CHAR LIMIT=NONE] -->
<string name="accessibility_text_reading_preview_mail_from">From: Bill</string>
<!-- Content for the mail content of the accessibility text reading preview. [CHAR LIMIT=NONE] -->
- <string name="accessibility_text_reading_preview_mail_content">Good morning! Following up on our last conversation, I\u2019d like to check in on the progress of your time machine development plan. Will you be able to have a prototype ready to demo at E3 this year?</string>
+ <string name="accessibility_text_reading_preview_mail_content">Good morning!\n\nI just wanted to check how the designs are coming. Will they be ready before we start building the new balloons?</string>
<!-- Title for the reset button of the accessibility text reading page to reset all preferences state. [CHAR LIMIT=25] -->
<string name="accessibility_text_reading_reset_button_title">Reset settings</string>
<!-- Title for the confirm dialog of reset settings. [CHAR LIMIT=NONE] -->
@@ -10467,8 +10467,14 @@
<item quantity="other"><xliff:g id="count" example="10">%d</xliff:g> unused apps</item>
</plurals>
- <!-- Label of a switch preference that controls whether the system will remove the permissions and free up space when the app has not been used for months [CHAR LIMIT=40]-->
- <string name="unused_apps_switch">Remove permissions and free up space</string>
+ <!-- Label for category for unused app settings for an app. [CHAR LIMIT=40]-->
+ <string name="unused_apps_category">Unused app settings</string>
+
+ <!-- Label of a switch preference that controls whether the system will pause app activity when the app has not been used for months [CHAR LIMIT=40]-->
+ <string name="unused_apps_switch">Pause app activity</string>
+
+ <!-- Summary of the switch preference that controls whether the system will pause app activity when the app has not been used for months [CHAR LIMIT=NONE]-->
+ <string name="unused_apps_switch_summary">Remove permissions, delete temporary files, and stop notifications if unused</string>
<!-- Label for showing all apps in list [CHAR LIMIT=30] -->
<string name="filter_all_apps">All apps</string>
@@ -13514,6 +13520,11 @@
<!-- Summary for allowing screen overlays on Settings app. [CHAR LIMIT=NONE]-->
<string name="overlay_settings_summary">Allow apps that can display over other apps to overlay Settings screens</string>
+ <!-- Developer settings: Title for allowing mock modem service for testing. [CHAR LIMIT=50]-->
+ <string name="allow_mock_modem">Allow Mock Modem</string>
+ <!-- Developer settings: Summary for allowing mock modem service. [CHAR LIMIT=NONE]-->
+ <string name="allow_mock_modem_summary">Allow this device to run Mock Modem service for instrumentation testing. Do not enable this during normal usage of the phone</string>
+
<!-- Title for media control settings [CHAR LIMIT=50]-->
<string name="media_controls_title">Media</string>
<!-- Title of toggle to enable or disable the media resumption feature in quick settings [CHAR LIMIT=50]-->
@@ -13887,9 +13898,15 @@
<string name="tare_actions_ctp">Actions (Cost to Produce)</string>
<!-- Title for the various TARE policy's actions' starting prices [CHAR LIMIT=40]-->
<string name="tare_actions_base_price">Actions (Base Price)</string>
- <!-- Title for the instant, ongoing, and max rewards apps can obtain for different actions that
- benefit the user. [CHAR LIMIT=40]-->
- <string name="tare_rewards">Rewards</string>
+ <!-- Title for the rewards apps can obtain for each instance of an event that implies the user
+ finds the app behavior useful. [CHAR LIMIT=40]-->
+ <string name="tare_rewards_instantaneous">Rewards per single event</string>
+ <!-- Title for the rewards apps can obtain for the total duration (in seconds) of an event that
+ implies the user finds the app behavior useful. [CHAR LIMIT=40]-->
+ <string name="tare_rewards_ongoing">Rewards for total event duration</string>
+ <!-- Title for the max rewards apps can obtain within a 24 hour period for different actions
+ that benefit the user. [CHAR LIMIT=40]-->
+ <string name="tare_rewards_max">Maximum Rewards Per Day</string>
<!-- Title for the Allow While Idle Exact Wakeup Alarm set via
AlarmManager.setExactAndAllowWhileIdle() [CHAR LIMIT=50]-->
<string name="tare_wakeup_exact_idle" translatable="false">
@@ -14025,7 +14042,7 @@
<string-array name="tare_rewards_subfactors" translatable="false">
<item>@string/tare_top_activity</item>
<item>@string/tare_notification_seen</item>
- <item>@string/tare_notification_seen_15_min</item>
+ <!-- TODO: add back once supported <item>@string/tare_notification_seen_15_min</item> -->
<item>@string/tare_notification_interaction</item>
<item>@string/tare_widget_interaction</item>
<item>@string/tare_other_interaction</item>
@@ -14088,13 +14105,13 @@
<string name="placeholder_activity" translatable="false">*This is a temporary placeholder fallback activity.</string>
<!-- The title of the spatial audio [CHAR LIMIT=none] -->
- <string name="bluetooth_details_spatial_audio_title">Spatial audio</string>
+ <string name="bluetooth_details_spatial_audio_title">Spatial Audio</string>
<!-- The summary of the spatial audio [CHAR LIMIT=none] -->
- <string name="bluetooth_details_spatial_audio_summary">Immersive audio seems like it\u0027s coming from all around you. Only works with some media.</string>
+ <string name="bluetooth_details_spatial_audio_summary">Audio from compatible media becomes more immersive</string>
<!-- The title of the head tracking [CHAR LIMIT=none] -->
- <string name="bluetooth_details_head_tracking_title">Make audio more realistic</string>
+ <string name="bluetooth_details_head_tracking_title">Head tracking</string>
<!-- The summary of the head tracking [CHAR LIMIT=none] -->
- <string name="bluetooth_details_head_tracking_summary">Shift positioning of audio so it sounds more natural.</string>
+ <string name="bluetooth_details_head_tracking_summary">Audio changes as you move your head to sound more natural</string>
<!-- Developer Settings: Title for network bandwidth ingress rate limit [CHAR LIMIT=none] -->
<string name="ingress_rate_limit_title">Network download rate limit</string>
diff --git a/res/xml/app_info_settings.xml b/res/xml/app_info_settings.xml
index bb5fbae..95fefb6 100644
--- a/res/xml/app_info_settings.xml
+++ b/res/xml/app_info_settings.xml
@@ -148,6 +148,7 @@
<SwitchPreference
android:key="hibernation_switch"
android:title="@string/unused_apps_switch"
+ android:summary="@string/unused_apps_switch_summary"
settings:controller=
"com.android.settings.applications.appinfo.HibernationSwitchPreferenceController" />
</PreferenceCategory>
diff --git a/res/xml/development_settings.xml b/res/xml/development_settings.xml
index 9867419..89e5167 100644
--- a/res/xml/development_settings.xml
+++ b/res/xml/development_settings.xml
@@ -250,6 +250,11 @@
android:title="@string/force_high_refresh_rate_toggle"
android:summary="@string/force_high_refresh_rate_desc" />
+ <SwitchPreference
+ android:key="allow_mock_modem"
+ android:title="@string/allow_mock_modem"
+ android:summary="@string/allow_mock_modem_summary" />
+
</PreferenceCategory>
<PreferenceCategory
diff --git a/src/com/android/settings/ResetNetworkConfirm.java b/src/com/android/settings/ResetNetworkConfirm.java
index f79bdb2..eff487b 100644
--- a/src/com/android/settings/ResetNetworkConfirm.java
+++ b/src/com/android/settings/ResetNetworkConfirm.java
@@ -138,7 +138,7 @@
if (btManager != null) {
BluetoothAdapter btAdapter = btManager.getAdapter();
if (btAdapter != null) {
- btAdapter.factoryReset();
+ btAdapter.clearBluetooth();
}
}
diff --git a/src/com/android/settings/Settings.java b/src/com/android/settings/Settings.java
index 57d7d10..5c3e53e 100644
--- a/src/com/android/settings/Settings.java
+++ b/src/com/android/settings/Settings.java
@@ -28,6 +28,7 @@
import android.util.Log;
import com.android.internal.annotations.VisibleForTesting;
+import com.android.settings.biometrics.face.FaceSettings;
import com.android.settings.core.FeatureFlags;
import com.android.settings.enterprise.EnterprisePrivacySettings;
import com.android.settings.network.SubscriptionUtil;
@@ -50,6 +51,8 @@
public static class BluetoothSettingsActivity extends SettingsActivity { /* empty */ }
public static class CreateShortcutActivity extends SettingsActivity { /* empty */ }
public static class FaceSettingsActivity extends SettingsActivity { /* empty */ }
+ /** Container for {@link FaceSettings} to use with a pre-defined task affinity. */
+ public static class FaceSettingsInternalActivity extends SettingsActivity { /* empty */ }
public static class FingerprintSettingsActivity extends SettingsActivity { /* empty */ }
public static class CombinedBiometricSettingsActivity extends SettingsActivity { /* empty */ }
public static class CombinedBiometricProfileSettingsActivity extends SettingsActivity { /* empty */ }
diff --git a/src/com/android/settings/accessibility/ToggleScreenMagnificationPreferenceFragment.java b/src/com/android/settings/accessibility/ToggleScreenMagnificationPreferenceFragment.java
index 1176fa4..d2d6a33 100644
--- a/src/com/android/settings/accessibility/ToggleScreenMagnificationPreferenceFragment.java
+++ b/src/com/android/settings/accessibility/ToggleScreenMagnificationPreferenceFragment.java
@@ -27,6 +27,7 @@
import android.content.ContentResolver;
import android.content.Context;
import android.content.DialogInterface;
+import android.content.pm.PackageManager;
import android.icu.text.CaseMap;
import android.net.Uri;
import android.os.Bundle;
@@ -162,9 +163,14 @@
@Override
protected void initSettingsPreference() {
- // If the device doesn't support magnification area, it should hide the settings preference.
- if (!getContext().getResources().getBoolean(
- com.android.internal.R.bool.config_magnification_area)) {
+ // If the device doesn't support window magnification feature, it should hide the
+ // settings preference.
+ final boolean supportWindowMagnification =
+ getContext().getResources().getBoolean(
+ com.android.internal.R.bool.config_magnification_area)
+ && getContext().getPackageManager().hasSystemFeature(
+ PackageManager.FEATURE_WINDOW_MAGNIFICATION);
+ if (!supportWindowMagnification) {
return;
}
mSettingsPreference = new Preference(getPrefContext());
diff --git a/src/com/android/settings/accessibility/VibrationIntensityPreferenceController.java b/src/com/android/settings/accessibility/VibrationIntensityPreferenceController.java
index 6441eeb..bc8c600 100644
--- a/src/com/android/settings/accessibility/VibrationIntensityPreferenceController.java
+++ b/src/com/android/settings/accessibility/VibrationIntensityPreferenceController.java
@@ -73,11 +73,11 @@
mSettingsContentObserver.onDisplayPreference(this, preference);
preference.setEnabled(mPreferenceConfig.isPreferenceEnabled());
preference.setSummaryProvider(unused -> mPreferenceConfig.getSummary());
- // TODO: remove setContinuousUpdates and replace with a different way to play the haptic
- // preview without relying on the setting being propagated to the service.
- preference.setContinuousUpdates(true);
preference.setMin(getMin());
preference.setMax(getMax());
+ // Haptics previews played by the Settings app don't bypass user settings to be played.
+ // The sliders continuously updates the intensity value so the previews can apply them.
+ preference.setContinuousUpdates(true);
}
@Override
diff --git a/src/com/android/settings/accessibility/VibrationMainSwitchPreferenceController.java b/src/com/android/settings/accessibility/VibrationMainSwitchPreferenceController.java
index 726bbc1..02e8926 100644
--- a/src/com/android/settings/accessibility/VibrationMainSwitchPreferenceController.java
+++ b/src/com/android/settings/accessibility/VibrationMainSwitchPreferenceController.java
@@ -23,6 +23,8 @@
import android.database.ContentObserver;
import android.net.Uri;
import android.os.Handler;
+import android.os.VibrationAttributes;
+import android.os.Vibrator;
import android.provider.Settings;
import com.android.settings.R;
@@ -42,9 +44,11 @@
implements LifecycleObserver, OnStart, OnStop {
private final ContentObserver mSettingObserver;
+ private final Vibrator mVibrator;
public VibrationMainSwitchPreferenceController(Context context, String preferenceKey) {
super(context, preferenceKey);
+ mVibrator = context.getSystemService(Vibrator.class);
mSettingObserver = new ContentObserver(new Handler(/* async= */ true)) {
@Override
public void onChange(boolean selfChange, Uri uri) {
@@ -79,9 +83,17 @@
@Override
public boolean setChecked(boolean isChecked) {
- return Settings.System.putInt(mContext.getContentResolver(),
+ boolean success = Settings.System.putInt(mContext.getContentResolver(),
VibrationPreferenceConfig.MAIN_SWITCH_SETTING_KEY,
isChecked ? ON : OFF);
+
+ if (success && isChecked) {
+ // Play a haptic as preview for the main toggle only when touch feedback is enabled.
+ VibrationPreferenceConfig.playVibrationPreview(
+ mVibrator, VibrationAttributes.USAGE_TOUCH);
+ }
+
+ return success;
}
@Override
diff --git a/src/com/android/settings/accessibility/VibrationPreferenceConfig.java b/src/com/android/settings/accessibility/VibrationPreferenceConfig.java
index 9208b18..b4be528 100644
--- a/src/com/android/settings/accessibility/VibrationPreferenceConfig.java
+++ b/src/com/android/settings/accessibility/VibrationPreferenceConfig.java
@@ -49,6 +49,8 @@
* all device vibrations.
*/
public static final String MAIN_SWITCH_SETTING_KEY = Settings.System.VIBRATE_ON;
+ private static final VibrationEffect PREVIEW_VIBRATION_EFFECT =
+ VibrationEffect.createPredefined(VibrationEffect.EFFECT_CLICK);
protected final ContentResolver mContentResolver;
private final AudioManager mAudioManager;
@@ -56,14 +58,22 @@
private final String mSettingKey;
private final String mRingerModeSilentSummary;
private final int mDefaultIntensity;
- private final VibrationAttributes mVibrationAttributes;
+ private final VibrationAttributes mPreviewVibrationAttributes;
/** Returns true if the user setting for enabling device vibrations is enabled. */
public static boolean isMainVibrationSwitchEnabled(ContentResolver contentResolver) {
return Settings.System.getInt(contentResolver, MAIN_SWITCH_SETTING_KEY, ON) == ON;
}
- public VibrationPreferenceConfig(Context context, String settingKey, int vibrationUsage) {
+ /** Play a vibration effect with intensity just selected by the user. */
+ public static void playVibrationPreview(Vibrator vibrator,
+ @VibrationAttributes.Usage int vibrationUsage) {
+ vibrator.vibrate(PREVIEW_VIBRATION_EFFECT,
+ createPreviewVibrationAttributes(vibrationUsage));
+ }
+
+ public VibrationPreferenceConfig(Context context, String settingKey,
+ @VibrationAttributes.Usage int vibrationUsage) {
mContentResolver = context.getContentResolver();
mVibrator = context.getSystemService(Vibrator.class);
mAudioManager = context.getSystemService(AudioManager.class);
@@ -71,9 +81,7 @@
R.string.accessibility_vibration_setting_disabled_for_silent_mode_summary);
mSettingKey = settingKey;
mDefaultIntensity = mVibrator.getDefaultVibrationIntensity(vibrationUsage);
- mVibrationAttributes = new VibrationAttributes.Builder()
- .setUsage(vibrationUsage)
- .build();
+ mPreviewVibrationAttributes = createPreviewVibrationAttributes(vibrationUsage);
}
/** Returns the setting key for this setting preference. */
@@ -118,8 +126,7 @@
/** Play a vibration effect with intensity just selected by the user. */
public void playVibrationPreview() {
- mVibrator.vibrate(VibrationEffect.createPredefined(VibrationEffect.EFFECT_CLICK),
- mVibrationAttributes);
+ mVibrator.vibrate(PREVIEW_VIBRATION_EFFECT, mPreviewVibrationAttributes);
}
private boolean isRingerModeSilent() {
@@ -128,6 +135,16 @@
return mAudioManager.getRingerModeInternal() == AudioManager.RINGER_MODE_SILENT;
}
+ private static VibrationAttributes createPreviewVibrationAttributes(
+ @VibrationAttributes.Usage int vibrationUsage) {
+ return new VibrationAttributes.Builder()
+ .setUsage(vibrationUsage)
+ // Enforce fresh settings to be applied for the preview vibration, as they
+ // are played immediately after the new user values are set.
+ .setFlags(VibrationAttributes.FLAG_INVALIDATE_SETTINGS_CACHE)
+ .build();
+ }
+
/** {@link ContentObserver} for a setting described by a {@link VibrationPreferenceConfig}. */
public static final class SettingObserver extends ContentObserver {
private static final Uri MAIN_SWITCH_SETTING_URI =
diff --git a/src/com/android/settings/accessibility/VibrationRampingRingerTogglePreferenceController.java b/src/com/android/settings/accessibility/VibrationRampingRingerTogglePreferenceController.java
index 8d1b43e..149bed3 100644
--- a/src/com/android/settings/accessibility/VibrationRampingRingerTogglePreferenceController.java
+++ b/src/com/android/settings/accessibility/VibrationRampingRingerTogglePreferenceController.java
@@ -124,6 +124,12 @@
if (isRingVibrationEnabled()) {
// Don't update ramping ringer setting value if ring vibration is disabled.
mAudioManager.setRampingRingerEnabled(isChecked);
+
+ if (isChecked) {
+ // Vibrate when toggle is enabled for consistency with all the other toggle/slides
+ // in the same screen.
+ mRingVibrationPreferenceConfig.playVibrationPreview();
+ }
}
return true;
}
diff --git a/src/com/android/settings/activityembedding/ActivityEmbeddingRulesController.java b/src/com/android/settings/activityembedding/ActivityEmbeddingRulesController.java
index 124bb4f..3ca8168 100644
--- a/src/com/android/settings/activityembedding/ActivityEmbeddingRulesController.java
+++ b/src/com/android/settings/activityembedding/ActivityEmbeddingRulesController.java
@@ -38,6 +38,7 @@
import com.android.settings.SubSettings;
import com.android.settings.biometrics.fingerprint.FingerprintEnrollEnrolling;
import com.android.settings.biometrics.fingerprint.FingerprintEnrollIntroduction;
+import com.android.settings.biometrics.fingerprint.FingerprintEnrollIntroductionInternal;
import com.android.settings.core.FeatureFlags;
import com.android.settings.homepage.DeepLinkHomepageActivity;
import com.android.settings.homepage.SettingsHomepageActivity;
@@ -52,6 +53,8 @@
public class ActivityEmbeddingRulesController {
private static final String TAG = "ActivityEmbeddingCtrl";
+ private static final ComponentName COMPONENT_NAME_WILDCARD = new ComponentName(
+ "*" /* pkg */, "*" /* cls */);
private final Context mContext;
private final SplitController mSplitController;
@@ -187,6 +190,13 @@
new ComponentName(context, SubSettings.class),
null /* secondaryIntentAction */,
clearTop);
+
+ registerTwoPanePairRuleForSettingsHome(
+ context,
+ COMPONENT_NAME_WILDCARD,
+ Intent.ACTION_SAFETY_CENTER,
+ clearTop
+ );
}
private void registerHomepagePlaceholderRule() {
@@ -220,14 +230,14 @@
addActivityFilter(activityFilters, searchIntent);
}
addActivityFilter(activityFilters, FingerprintEnrollIntroduction.class);
+ addActivityFilter(activityFilters, FingerprintEnrollIntroductionInternal.class);
addActivityFilter(activityFilters, FingerprintEnrollEnrolling.class);
addActivityFilter(activityFilters, AvatarPickerActivity.class);
mSplitController.registerRule(new ActivityRule(activityFilters, true /* alwaysExpand */));
}
private static void addActivityFilter(Set<ActivityFilter> activityFilters, Intent intent) {
- activityFilters.add(new ActivityFilter(new ComponentName("*" /* pkg */, "*" /* cls */),
- intent.getAction()));
+ activityFilters.add(new ActivityFilter(COMPONENT_NAME_WILDCARD, intent.getAction()));
}
private void addActivityFilter(Set<ActivityFilter> activityFilters,
diff --git a/src/com/android/settings/applications/specialaccess/deviceadmin/DeviceAdminListPreferenceController.java b/src/com/android/settings/applications/specialaccess/deviceadmin/DeviceAdminListPreferenceController.java
index 25b3abd..dd16006 100644
--- a/src/com/android/settings/applications/specialaccess/deviceadmin/DeviceAdminListPreferenceController.java
+++ b/src/com/android/settings/applications/specialaccess/deviceadmin/DeviceAdminListPreferenceController.java
@@ -37,7 +37,6 @@
import android.text.TextUtils;
import android.util.ArrayMap;
import android.util.Log;
-import android.util.SparseArray;
import androidx.annotation.VisibleForTesting;
import androidx.preference.Preference;
@@ -79,7 +78,6 @@
* user.
*/
private final ArrayList<DeviceAdminListItem> mAdmins = new ArrayList<>();
- private final SparseArray<ComponentName> mProfileOwnerComponents = new SparseArray<>();
private final BroadcastReceiver mBroadcastReceiver = new BroadcastReceiver() {
@Override
@@ -118,6 +116,8 @@
super.displayPreference(screen);
mPreferenceGroup = screen.findPreference(getPreferenceKey());
mFooterPreference = mPreferenceGroup.findPreference(KEY_DEVICE_ADMIN_FOOTER);
+
+ updateList();
}
@Override
@@ -128,19 +128,6 @@
}
@Override
- public void updateState(Preference preference) {
- super.updateState(preference);
- mProfileOwnerComponents.clear();
- final List<UserHandle> profiles = mUm.getUserProfiles();
- final int profilesSize = profiles.size();
- for (int i = 0; i < profilesSize; ++i) {
- final int profileId = profiles.get(i).getIdentifier();
- mProfileOwnerComponents.put(profileId, mDPM.getProfileOwnerAsUser(profileId));
- }
- updateList();
- }
-
- @Override
public void onStop() {
mContext.unregisterReceiver(mBroadcastReceiver);
}
diff --git a/src/com/android/settings/biometrics/face/FaceEnrollIntroductionInternal.java b/src/com/android/settings/biometrics/face/FaceEnrollIntroductionInternal.java
new file mode 100644
index 0000000..7dd29da
--- /dev/null
+++ b/src/com/android/settings/biometrics/face/FaceEnrollIntroductionInternal.java
@@ -0,0 +1,23 @@
+/*
+ * Copyright (C) 2022 The Android Open Source Project
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package com.android.settings.biometrics.face;
+
+/**
+ * Wrapper of {@link FaceEnrollIntroduction} to use with a pre-defined task affinity.
+ */
+public class FaceEnrollIntroductionInternal extends FaceEnrollIntroduction {
+}
diff --git a/src/com/android/settings/biometrics/face/FaceStatusUtils.java b/src/com/android/settings/biometrics/face/FaceStatusUtils.java
index 1749aca..80ffb03 100644
--- a/src/com/android/settings/biometrics/face/FaceStatusUtils.java
+++ b/src/com/android/settings/biometrics/face/FaceStatusUtils.java
@@ -71,8 +71,8 @@
* Returns the class name of the Settings page corresponding to face settings.
*/
public String getSettingsClassName() {
- return hasEnrolled() ? Settings.FaceSettingsActivity.class.getName()
- : FaceEnrollIntroduction.class.getName();
+ return hasEnrolled() ? Settings.FaceSettingsInternalActivity.class.getName()
+ : FaceEnrollIntroductionInternal.class.getName();
}
/**
diff --git a/src/com/android/settings/biometrics/fingerprint/FingerprintEnrollIntroductionInternal.java b/src/com/android/settings/biometrics/fingerprint/FingerprintEnrollIntroductionInternal.java
new file mode 100644
index 0000000..ac32d50
--- /dev/null
+++ b/src/com/android/settings/biometrics/fingerprint/FingerprintEnrollIntroductionInternal.java
@@ -0,0 +1,23 @@
+/*
+ * Copyright (C) 2022 The Android Open Source Project
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package com.android.settings.biometrics.fingerprint;
+
+/**
+ * Wrapper of {@link FingerprintEnrollIntroduction} to use with a pre-defined task affinity.
+ */
+public class FingerprintEnrollIntroductionInternal extends FingerprintEnrollIntroduction {
+}
diff --git a/src/com/android/settings/biometrics/fingerprint/FingerprintStatusUtils.java b/src/com/android/settings/biometrics/fingerprint/FingerprintStatusUtils.java
index 5707f32..82ceed6 100644
--- a/src/com/android/settings/biometrics/fingerprint/FingerprintStatusUtils.java
+++ b/src/com/android/settings/biometrics/fingerprint/FingerprintStatusUtils.java
@@ -79,7 +79,7 @@
*/
public String getSettingsClassName() {
return hasEnrolled() ? FingerprintSettings.class.getName()
- : FingerprintEnrollIntroduction.class.getName();
+ : FingerprintEnrollIntroductionInternal.class.getName();
}
/**
diff --git a/src/com/android/settings/bluetooth/LeAudioBluetoothDetailsHeaderController.java b/src/com/android/settings/bluetooth/LeAudioBluetoothDetailsHeaderController.java
index 06cee85..7b74f77 100644
--- a/src/com/android/settings/bluetooth/LeAudioBluetoothDetailsHeaderController.java
+++ b/src/com/android/settings/bluetooth/LeAudioBluetoothDetailsHeaderController.java
@@ -275,11 +275,15 @@
return;
}
boolean isLeft = (deviceId & LEFT_DEVICE_ID) != 0;
- boolean isRight = (deviceId & LEFT_DEVICE_ID) != 0;
+ boolean isRight = (deviceId & RIGHT_DEVICE_ID) != 0;
boolean isLeftRight = isLeft && isRight;
// The LE device updates the BatteryLayout
if (isLeftRight) {
- Log.d(TAG, "The device id is left+right. Do nothing.");
+ Log.d(TAG, "Show the legacy battery style if the device id is left+right.");
+ final TextView summary = mLayoutPreference.findViewById(R.id.entity_header_summary);
+ if (summary != null) {
+ summary.setText(mCachedDevice.getConnectionSummary());
+ }
} else if (isLeft) {
updateBatteryLayout(getBatteryTitleResource(LEFT_DEVICE_ID),
getBatterySummaryResource(LEFT_DEVICE_ID), cachedDevice.getBatteryLevel());
diff --git a/src/com/android/settings/development/DevelopmentSettingsDashboardFragment.java b/src/com/android/settings/development/DevelopmentSettingsDashboardFragment.java
index 085a372..722e94e 100644
--- a/src/com/android/settings/development/DevelopmentSettingsDashboardFragment.java
+++ b/src/com/android/settings/development/DevelopmentSettingsDashboardFragment.java
@@ -518,6 +518,7 @@
controllers.add(new BugReportInPowerPreferenceController(context));
controllers.add(new AutomaticSystemServerHeapDumpPreferenceController(context));
controllers.add(new MockLocationAppPreferenceController(context, fragment));
+ controllers.add(new MockModemPreferenceController(context));
controllers.add(new DebugViewAttributesPreferenceController(context));
controllers.add(new SelectDebugAppPreferenceController(context, fragment));
controllers.add(new WaitForDebuggerPreferenceController(context));
diff --git a/src/com/android/settings/development/MockModemPreferenceController.java b/src/com/android/settings/development/MockModemPreferenceController.java
new file mode 100644
index 0000000..655f157
--- /dev/null
+++ b/src/com/android/settings/development/MockModemPreferenceController.java
@@ -0,0 +1,86 @@
+/*
+ * Copyright (C) 2022 The Android Open Source Project
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package com.android.settings.development;
+
+import android.content.Context;
+import android.os.SystemProperties;
+import android.util.Log;
+
+import androidx.annotation.VisibleForTesting;
+import androidx.preference.Preference;
+import androidx.preference.SwitchPreference;
+
+import com.android.settings.core.PreferenceControllerMixin;
+import com.android.settingslib.development.DeveloperOptionsPreferenceController;
+
+/**
+ * PreferenceController for MockModem
+ */
+public class MockModemPreferenceController extends
+ DeveloperOptionsPreferenceController implements Preference.OnPreferenceChangeListener,
+ PreferenceControllerMixin {
+
+ private static final String TAG = "MockModemPreferenceController";
+ private static final String ALLOW_MOCK_MODEM_KEY =
+ "allow_mock_modem";
+ @VisibleForTesting
+ static final String ALLOW_MOCK_MODEM_PROPERTY =
+ "persist.radio.allow_mock_modem";
+
+ public MockModemPreferenceController(Context context) {
+ super(context);
+ }
+
+ @Override
+ public String getPreferenceKey() {
+ return ALLOW_MOCK_MODEM_KEY;
+ }
+
+ @Override
+ public boolean onPreferenceChange(Preference preference, Object newValue) {
+ final boolean isEnabled = (Boolean) newValue;
+ try {
+ SystemProperties.set(ALLOW_MOCK_MODEM_PROPERTY,
+ isEnabled ? "true" : "false");
+ } catch (RuntimeException e) {
+ Log.e(TAG, "Fail to set radio system property: " + e.getMessage());
+ }
+ return true;
+ }
+
+ @Override
+ public void updateState(Preference preference) {
+ try {
+ final boolean isEnabled = SystemProperties.getBoolean(
+ ALLOW_MOCK_MODEM_PROPERTY, false /* default */);
+ ((SwitchPreference) mPreference).setChecked(isEnabled);
+ } catch (RuntimeException e) {
+ Log.e(TAG, "Fail to get radio system property: " + e.getMessage());
+ }
+ }
+
+ @Override
+ protected void onDeveloperOptionsSwitchDisabled() {
+ super.onDeveloperOptionsSwitchDisabled();
+ try {
+ SystemProperties.set(ALLOW_MOCK_MODEM_PROPERTY, "false");
+ ((SwitchPreference) mPreference).setChecked(false);
+ } catch (RuntimeException e) {
+ Log.e(TAG, "Fail to set radio system property: " + e.getMessage());
+ }
+ }
+}
diff --git a/src/com/android/settings/development/tare/AlarmManagerFragment.java b/src/com/android/settings/development/tare/AlarmManagerFragment.java
index c4dca37..980954d 100644
--- a/src/com/android/settings/development/tare/AlarmManagerFragment.java
+++ b/src/com/android/settings/development/tare/AlarmManagerFragment.java
@@ -97,7 +97,8 @@
// resources.getString(R.string.tare_modifiers),
resources.getString(R.string.tare_actions_ctp),
resources.getString(R.string.tare_actions_base_price),
- // resources.getString(R.string.tare_rewards)
+ resources.getString(R.string.tare_rewards_instantaneous),
+ resources.getString(R.string.tare_rewards_max)
};
mChildren = new String[][]{
@@ -107,7 +108,8 @@
// resources.getStringArray(R.array.tare_modifiers_subfactors),
resources.getStringArray(R.array.tare_alarm_manager_actions),
resources.getStringArray(R.array.tare_alarm_manager_actions),
- // resources.getStringArray(R.array.tare_rewards_subfactors)
+ resources.getStringArray(R.array.tare_rewards_subfactors),
+ resources.getStringArray(R.array.tare_rewards_subfactors)
};
mKeys = new String[][]{
@@ -147,7 +149,20 @@
EconomyManager.KEY_AM_ACTION_ALARM_INEXACT_NONWAKEUP_BASE_PRICE,
EconomyManager.KEY_AM_ACTION_ALARM_ALARMCLOCK_BASE_PRICE
},
- // {},
+ {
+ EconomyManager.KEY_AM_REWARD_TOP_ACTIVITY_MAX,
+ EconomyManager.KEY_AM_REWARD_NOTIFICATION_SEEN_MAX,
+ EconomyManager.KEY_AM_REWARD_NOTIFICATION_INTERACTION_MAX,
+ EconomyManager.KEY_AM_REWARD_WIDGET_INTERACTION_MAX,
+ EconomyManager.KEY_AM_REWARD_OTHER_USER_INTERACTION_MAX,
+ },
+ {
+ EconomyManager.KEY_AM_REWARD_TOP_ACTIVITY_MAX,
+ EconomyManager.KEY_AM_REWARD_NOTIFICATION_SEEN_MAX,
+ EconomyManager.KEY_AM_REWARD_NOTIFICATION_INTERACTION_MAX,
+ EconomyManager.KEY_AM_REWARD_WIDGET_INTERACTION_MAX,
+ EconomyManager.KEY_AM_REWARD_OTHER_USER_INTERACTION_MAX,
+ }
};
}
}
diff --git a/src/com/android/settings/development/tare/JobSchedulerFragment.java b/src/com/android/settings/development/tare/JobSchedulerFragment.java
index 275e012..bffd648 100644
--- a/src/com/android/settings/development/tare/JobSchedulerFragment.java
+++ b/src/com/android/settings/development/tare/JobSchedulerFragment.java
@@ -98,7 +98,9 @@
// mResources.getString(R.string.tare_modifiers),
resources.getString(R.string.tare_actions_ctp),
resources.getString(R.string.tare_actions_base_price),
- // mResources.getString(R.string.tare_rewards)
+ resources.getString(R.string.tare_rewards_instantaneous),
+ // resources.getString(R.string.tare_rewards_ongoing),
+ resources.getString(R.string.tare_rewards_max)
};
mChildren = new String[][]{
@@ -108,7 +110,9 @@
// mResources.getStringArray(R.array.tare_modifiers_subfactors),
resources.getStringArray(R.array.tare_job_scheduler_actions),
resources.getStringArray(R.array.tare_job_scheduler_actions),
- // mResources.getStringArray(R.array.tare_rewards_subfactors)
+ resources.getStringArray(R.array.tare_rewards_subfactors),
+ // {resources.getString(R.string.tare_top_activity)},
+ resources.getStringArray(R.array.tare_rewards_subfactors)
};
mKeys = new String[][]{
@@ -149,7 +153,21 @@
EconomyManager.KEY_JS_ACTION_JOB_MIN_RUNNING_BASE_PRICE,
EconomyManager.KEY_JS_ACTION_JOB_TIMEOUT_PENALTY_BASE_PRICE
},
- // {},
+ {
+ EconomyManager.KEY_JS_REWARD_TOP_ACTIVITY_MAX,
+ EconomyManager.KEY_JS_REWARD_NOTIFICATION_SEEN_MAX,
+ EconomyManager.KEY_JS_REWARD_NOTIFICATION_INTERACTION_MAX,
+ EconomyManager.KEY_JS_REWARD_WIDGET_INTERACTION_MAX,
+ EconomyManager.KEY_JS_REWARD_OTHER_USER_INTERACTION_MAX,
+ },
+ // {EconomyManager.KEY_JS_REWARD_TOP_ACTIVITY_ONGOING},
+ {
+ EconomyManager.KEY_JS_REWARD_TOP_ACTIVITY_MAX,
+ EconomyManager.KEY_JS_REWARD_NOTIFICATION_SEEN_MAX,
+ EconomyManager.KEY_JS_REWARD_NOTIFICATION_INTERACTION_MAX,
+ EconomyManager.KEY_JS_REWARD_WIDGET_INTERACTION_MAX,
+ EconomyManager.KEY_JS_REWARD_OTHER_USER_INTERACTION_MAX,
+ }
};
}
}
diff --git a/src/com/android/settings/development/tare/TareFactorController.java b/src/com/android/settings/development/tare/TareFactorController.java
index b9f813d..62fde6d 100644
--- a/src/com/android/settings/development/tare/TareFactorController.java
+++ b/src/com/android/settings/development/tare/TareFactorController.java
@@ -530,7 +530,7 @@
} else if (mJobSchedulerMap.containsKey(key)) {
currentMap = mJobSchedulerMap;
} else {
- throw new IllegalArgumentException("Couldn't link key to policy map");
+ throw new IllegalArgumentException("Couldn't link key '" + key + "' to a policy");
}
return currentMap.get(key).factorPolicy;
}
diff --git a/src/com/android/settings/fuelgauge/batterysaver/BatterySaverButtonPreferenceController.java b/src/com/android/settings/fuelgauge/batterysaver/BatterySaverButtonPreferenceController.java
index d24f1b2..da0f2e2 100644
--- a/src/com/android/settings/fuelgauge/batterysaver/BatterySaverButtonPreferenceController.java
+++ b/src/com/android/settings/fuelgauge/batterysaver/BatterySaverButtonPreferenceController.java
@@ -111,9 +111,8 @@
@Override
public boolean setChecked(boolean stateOn) {
- // This screen already shows a warning, so we don't need another warning.
return BatterySaverUtils.setPowerSaveMode(mContext, stateOn,
- false /* needFirstTimeWarning */);
+ true /* needFirstTimeWarning */);
}
@Override
diff --git a/src/com/android/settings/fuelgauge/batterysaver/BatterySaverScheduleRadioButtonsController.java b/src/com/android/settings/fuelgauge/batterysaver/BatterySaverScheduleRadioButtonsController.java
index 737fb0f..378918a 100644
--- a/src/com/android/settings/fuelgauge/batterysaver/BatterySaverScheduleRadioButtonsController.java
+++ b/src/com/android/settings/fuelgauge/batterysaver/BatterySaverScheduleRadioButtonsController.java
@@ -40,7 +40,7 @@
public static final String KEY_NO_SCHEDULE = "key_battery_saver_no_schedule";
public static final String KEY_ROUTINE = "key_battery_saver_routine";
public static final String KEY_PERCENTAGE = "key_battery_saver_percentage";
- public static final int TRIGGER_LEVEL_MIN = 5;
+ public static final int TRIGGER_LEVEL_MIN = 10;
private Context mContext;
private BatterySaverScheduleSeekBarController mSeekBarController;
diff --git a/src/com/android/settings/fuelgauge/batterysaver/BatterySaverScheduleSeekBarController.java b/src/com/android/settings/fuelgauge/batterysaver/BatterySaverScheduleSeekBarController.java
index 173d946..a441449 100644
--- a/src/com/android/settings/fuelgauge/batterysaver/BatterySaverScheduleSeekBarController.java
+++ b/src/com/android/settings/fuelgauge/batterysaver/BatterySaverScheduleSeekBarController.java
@@ -45,7 +45,7 @@
OnPreferenceChangeListener {
public static final int MAX_SEEKBAR_VALUE = 15;
- public static final int MIN_SEEKBAR_VALUE = 1;
+ public static final int MIN_SEEKBAR_VALUE = 2;
public static final String KEY_BATTERY_SAVER_SEEK_BAR = "battery_saver_seek_bar";
@VisibleForTesting
diff --git a/src/com/android/settings/network/apn/ApnEditor.java b/src/com/android/settings/network/apn/ApnEditor.java
index 03db1b8..926c77e 100644
--- a/src/com/android/settings/network/apn/ApnEditor.java
+++ b/src/com/android/settings/network/apn/ApnEditor.java
@@ -149,6 +149,7 @@
private String[] mReadOnlyApnFields;
private boolean mReadOnlyApn;
private Uri mCarrierUri;
+ private boolean mIsCarrierIdApn;
/**
* APN types for data connections. These are usage categories for an APN
@@ -227,7 +228,8 @@
Telephony.Carriers.MVNO_TYPE, // 21
Telephony.Carriers.MVNO_MATCH_DATA, // 22
Telephony.Carriers.EDITED_STATUS, // 23
- Telephony.Carriers.USER_EDITABLE //24
+ Telephony.Carriers.USER_EDITABLE, // 24
+ Telephony.Carriers.CARRIER_ID // 25
};
private static final int ID_INDEX = 0;
@@ -262,6 +264,7 @@
private static final int MVNO_MATCH_DATA_INDEX = 22;
private static final int EDITED_INDEX = 23;
private static final int USER_EDITABLE_INDEX = 24;
+ private static final int CARRIER_ID_INDEX = 25;
@Override
public void onCreate(Bundle icicle) {
@@ -312,6 +315,9 @@
} else {
mApnData = new ApnData(sProjection.length);
}
+ final int carrierId = mApnData.getInteger(CARRIER_ID_INDEX,
+ TelephonyManager.UNKNOWN_CARRIER_ID);
+ mIsCarrierIdApn = (carrierId > TelephonyManager.UNKNOWN_CARRIER_ID);
final boolean isUserEdited = mApnData.getInteger(EDITED_INDEX,
Telephony.Carriers.USER_EDITED) == Telephony.Carriers.USER_EDITED;
@@ -326,6 +332,10 @@
} else if (!ArrayUtils.isEmpty(mReadOnlyApnFields)) {
disableFields(mReadOnlyApnFields);
}
+ // Make sure that a user cannot break carrier id APN matching
+ if (mIsCarrierIdApn) {
+ disableFieldsForCarrieridApn();
+ }
for (int i = 0; i < getPreferenceScreen().getPreferenceCount(); i++) {
getPreferenceScreen().getPreference(i).setOnPreferenceChangeListener(this);
@@ -517,6 +527,16 @@
mMvnoMatchData.setEnabled(false);
}
+ /**
+ * Disables fields for a carrier id APN to avoid breaking the match criteria
+ */
+ private void disableFieldsForCarrieridApn() {
+ mMcc.setEnabled(false);
+ mMnc.setEnabled(false);
+ mMvnoType.setEnabled(false);
+ mMvnoMatchData.setEnabled(false);
+ }
+
@Override
public int getMetricsCategory() {
return SettingsEnums.APN_EDITOR;
@@ -1150,11 +1170,15 @@
final String apn = checkNotSet(mApn.getText());
final String mcc = checkNotSet(mMcc.getText());
final String mnc = checkNotSet(mMnc.getText());
-
+ boolean doNotCheckMccMnc = mIsCarrierIdApn && TextUtils.isEmpty(mcc)
+ && TextUtils.isEmpty(mnc);
if (TextUtils.isEmpty(name)) {
errorMsg = getResources().getString(R.string.error_name_empty);
} else if (TextUtils.isEmpty(apn)) {
errorMsg = getResources().getString(R.string.error_apn_empty);
+ } else if (doNotCheckMccMnc) {
+ Log.d(TAG, "validateApnData: carrier id APN does not have mcc/mnc defined");
+ // no op, skip mcc mnc null check
} else if (mcc == null || mcc.length() != 3) {
errorMsg = getResources().getString(R.string.error_mcc_not3);
} else if ((mnc == null || (mnc.length() & 0xFFFE) != 2)) {
diff --git a/src/com/android/settings/password/ChooseLockSettingsHelper.java b/src/com/android/settings/password/ChooseLockSettingsHelper.java
index 77fcbed..e4d52ba 100644
--- a/src/com/android/settings/password/ChooseLockSettingsHelper.java
+++ b/src/com/android/settings/password/ChooseLockSettingsHelper.java
@@ -44,7 +44,6 @@
private static final String TAG = "ChooseLockSettingsHelper";
- public static final String EXTRA_KEY_TYPE = "type";
public static final String EXTRA_KEY_PASSWORD = "password";
public static final String EXTRA_KEY_RETURN_CREDENTIALS = "return_credentials";
// Force the verifyCredential path instead of checkCredential path. This will be removed
@@ -191,7 +190,7 @@
/**
* @param returnCredentials if true, puts the following credentials into intent for
* onActivityResult with the following keys:
- * {@link #EXTRA_KEY_TYPE}, {@link #EXTRA_KEY_PASSWORD},
+ * {@link #EXTRA_KEY_PASSWORD},
* {@link #EXTRA_KEY_CHALLENGE_TOKEN},
* {@link #EXTRA_KEY_GK_PW_HANDLE}
* Note that if this is true, this can only be called internally.
diff --git a/src/com/android/settings/password/ConfirmLockPassword.java b/src/com/android/settings/password/ConfirmLockPassword.java
index 7dcfc83..a81f975 100644
--- a/src/com/android/settings/password/ConfirmLockPassword.java
+++ b/src/com/android/settings/password/ConfirmLockPassword.java
@@ -39,7 +39,6 @@
import android.os.Looper;
import android.os.SystemClock;
import android.os.UserManager;
-import android.os.storage.StorageManager;
import android.text.Editable;
import android.text.InputType;
import android.text.TextUtils;
@@ -484,11 +483,6 @@
public void onChecked(boolean matched, int timeoutMs) {
mPendingLockCheck = null;
if (matched && isInternalActivity() && mReturnCredentials) {
- // TODO: get rid of EXTRA_KEY_TYPE, since EXTRA_KEY_PASSWORD already
- // distinguishes beteween PIN and password.
- intent.putExtra(ChooseLockSettingsHelper.EXTRA_KEY_TYPE,
- mIsAlpha ? StorageManager.CRYPT_TYPE_PASSWORD
- : StorageManager.CRYPT_TYPE_PIN);
intent.putExtra(
ChooseLockSettingsHelper.EXTRA_KEY_PASSWORD, credential);
}
diff --git a/src/com/android/settings/password/ConfirmLockPattern.java b/src/com/android/settings/password/ConfirmLockPattern.java
index 8b33aa5..1062d94 100644
--- a/src/com/android/settings/password/ConfirmLockPattern.java
+++ b/src/com/android/settings/password/ConfirmLockPattern.java
@@ -32,7 +32,6 @@
import android.os.CountDownTimer;
import android.os.SystemClock;
import android.os.UserManager;
-import android.os.storage.StorageManager;
import android.text.TextUtils;
import android.view.LayoutInflater;
import android.view.MotionEvent;
@@ -523,8 +522,6 @@
public void onChecked(boolean matched, int timeoutMs) {
mPendingLockCheck = null;
if (matched && isInternalActivity() && mReturnCredentials) {
- intent.putExtra(ChooseLockSettingsHelper.EXTRA_KEY_TYPE,
- StorageManager.CRYPT_TYPE_PATTERN);
intent.putExtra(ChooseLockSettingsHelper.EXTRA_KEY_PASSWORD,
pattern);
}
diff --git a/src/com/android/settings/wifi/NetworkRequestDialogActivity.java b/src/com/android/settings/wifi/NetworkRequestDialogActivity.java
index b160d90..30f38d2 100644
--- a/src/com/android/settings/wifi/NetworkRequestDialogActivity.java
+++ b/src/com/android/settings/wifi/NetworkRequestDialogActivity.java
@@ -58,12 +58,17 @@
final static String EXTRA_IS_SPECIFIED_SSID =
"com.android.settings.wifi.extra.REQUEST_IS_FOR_SINGLE_NETWORK";
- @VisibleForTesting NetworkRequestDialogBaseFragment mDialogFragment;
+ @VisibleForTesting
+ NetworkRequestDialogBaseFragment mDialogFragment;
+ @VisibleForTesting
+ boolean mIsSpecifiedSsid;
+ @VisibleForTesting
+ boolean mShowingErrorDialog;
+ @VisibleForTesting
+ ProgressDialog mProgressDialog;
+
private NetworkRequestUserSelectionCallback mUserSelectionCallback;
- private boolean mIsSpecifiedSsid;
- private boolean mShowingErrorDialog;
private WifiConfiguration mMatchedConfig;
- @VisibleForTesting ProgressDialog mProgressDialog;
@Override
protected void onCreate(@Nullable Bundle savedInstanceState) {
@@ -103,7 +108,8 @@
mDialogFragment.show(getSupportFragmentManager(), TAG);
}
- private void dismissDialogs() {
+ @VisibleForTesting
+ void dismissDialogs() {
if (mDialogFragment != null) {
mDialogFragment.dismiss();
mDialogFragment = null;
@@ -174,7 +180,9 @@
return;
}
- mDialogFragment.onUserSelectionCallbackRegistration(userSelectionCallback);
+ if (mDialogFragment != null) {
+ mDialogFragment.onUserSelectionCallbackRegistration(userSelectionCallback);
+ }
}
@Override
@@ -201,7 +209,9 @@
return;
}
- mDialogFragment.onMatch(scanResults);
+ if (mDialogFragment != null) {
+ mDialogFragment.onMatch(scanResults);
+ }
}
@Override
diff --git a/tests/robotests/src/com/android/settings/accessibility/ToggleScreenMagnificationPreferenceFragmentTest.java b/tests/robotests/src/com/android/settings/accessibility/ToggleScreenMagnificationPreferenceFragmentTest.java
index 8500e61..00ff960 100644
--- a/tests/robotests/src/com/android/settings/accessibility/ToggleScreenMagnificationPreferenceFragmentTest.java
+++ b/tests/robotests/src/com/android/settings/accessibility/ToggleScreenMagnificationPreferenceFragmentTest.java
@@ -36,6 +36,7 @@
import android.content.ContentResolver;
import android.content.Context;
import android.content.DialogInterface;
+import android.content.pm.PackageManager;
import android.content.res.Resources;
import android.os.Bundle;
import android.provider.Settings;
@@ -101,6 +102,8 @@
private FragmentActivity mActivity;
@Mock
private ContentResolver mContentResolver;
+ @Mock
+ private PackageManager mPackageManager;
@Before
public void setUpTestFragment() {
@@ -110,6 +113,7 @@
mFragment = spy(new TestToggleScreenMagnificationPreferenceFragment(mContext));
mResources = spy(mContext.getResources());
when(mContext.getResources()).thenReturn(mResources);
+ when(mContext.getPackageManager()).thenReturn(mPackageManager);
when(mFragment.getContext().getResources()).thenReturn(mResources);
when(mFragment.getActivity()).thenReturn(mActivity);
when(mActivity.getContentResolver()).thenReturn(mContentResolver);
@@ -334,10 +338,26 @@
@Ignore("Ignore it since a NPE is happened in ShadowWindowManagerGlobal. (Ref. b/214161063)")
@Test
- public void onCreateView_notSupportsMagnificationArea_settingsPreferenceIsNull() {
+ public void onCreateView_magnificationAreaNotSupported_settingsPreferenceIsNull() {
when(mResources.getBoolean(
com.android.internal.R.bool.config_magnification_area))
.thenReturn(false);
+ when(mPackageManager.hasSystemFeature(PackageManager.FEATURE_WINDOW_MAGNIFICATION))
+ .thenReturn(true);
+
+ mFragment.onCreateView(LayoutInflater.from(mContext), mock(ViewGroup.class), Bundle.EMPTY);
+
+ assertThat(mFragment.mSettingsPreference).isNull();
+ }
+
+ @Ignore("Ignore it since a NPE is happened in ShadowWindowManagerGlobal. (Ref. b/214161063)")
+ @Test
+ public void onCreateView_windowMagnificationNotSupported_settingsPreferenceIsNull() {
+ when(mResources.getBoolean(
+ com.android.internal.R.bool.config_magnification_area))
+ .thenReturn(true);
+ when(mPackageManager.hasSystemFeature(PackageManager.FEATURE_WINDOW_MAGNIFICATION))
+ .thenReturn(false);
mFragment.onCreateView(LayoutInflater.from(mContext), mock(ViewGroup.class), Bundle.EMPTY);
diff --git a/tests/robotests/src/com/android/settings/fuelgauge/batterysaver/BatterySaverButtonPreferenceControllerTest.java b/tests/robotests/src/com/android/settings/fuelgauge/batterysaver/BatterySaverButtonPreferenceControllerTest.java
index 7398e5c..594de6a 100644
--- a/tests/robotests/src/com/android/settings/fuelgauge/batterysaver/BatterySaverButtonPreferenceControllerTest.java
+++ b/tests/robotests/src/com/android/settings/fuelgauge/batterysaver/BatterySaverButtonPreferenceControllerTest.java
@@ -18,13 +18,17 @@
import static com.google.common.truth.Truth.assertThat;
+import static org.mockito.ArgumentMatchers.any;
+import static org.mockito.ArgumentMatchers.anyBoolean;
import static org.mockito.ArgumentMatchers.anyString;
import static org.mockito.Mockito.doReturn;
+import static org.mockito.Mockito.never;
import static org.mockito.Mockito.spy;
import static org.mockito.Mockito.verify;
import static org.mockito.Mockito.when;
import android.content.Context;
+import android.content.Intent;
import android.os.PowerManager;
import android.provider.SettingsSlicesContract;
@@ -90,10 +94,11 @@
}
@Test
- public void setChecked_on_setPowerSaveMode() {
+ public void setChecked_on_showWarningMessage() {
mController.setChecked(true);
- verify(mPowerManager).setPowerSaveModeEnabled(true);
+ verify(mContext).sendBroadcast(any(Intent.class));
+ verify(mPowerManager, never()).setPowerSaveModeEnabled(anyBoolean());
}
@Test
diff --git a/tests/robotests/src/com/android/settings/fuelgauge/batterysaver/BatterySaverScheduleSeekBarControllerTest.java b/tests/robotests/src/com/android/settings/fuelgauge/batterysaver/BatterySaverScheduleSeekBarControllerTest.java
index bc5f0af..9b57593 100644
--- a/tests/robotests/src/com/android/settings/fuelgauge/batterysaver/BatterySaverScheduleSeekBarControllerTest.java
+++ b/tests/robotests/src/com/android/settings/fuelgauge/batterysaver/BatterySaverScheduleSeekBarControllerTest.java
@@ -3,8 +3,8 @@
import static com.google.common.truth.Truth.assertThat;
import static org.mockito.ArgumentMatchers.any;
-import static org.mockito.Mockito.spy;
import static org.mockito.Mockito.never;
+import static org.mockito.Mockito.spy;
import static org.mockito.Mockito.verify;
import android.content.ContentResolver;
@@ -64,10 +64,10 @@
@Test
public void updateSeekBar_percentageMode_hasCorrectProperties() {
- final CharSequence expectedTitle = "5%";
+ final CharSequence expectedTitle = "10%";
Settings.Global.putInt(mResolver, Global.AUTOMATIC_POWER_SAVE_MODE,
PowerManager.POWER_SAVE_MODE_TRIGGER_PERCENTAGE);
- Settings.Global.putInt(mResolver, Global.LOW_POWER_MODE_TRIGGER_LEVEL, 5);
+ Settings.Global.putInt(mResolver, Global.LOW_POWER_MODE_TRIGGER_LEVEL, 10);
mController.updateSeekBar();
assertThat(mController.mSeekBarPreference.isVisible()).isTrue();
diff --git a/tests/robotests/src/com/android/settings/fuelgauge/batterysaver/BatterySaverScheduleSettingsTest.java b/tests/robotests/src/com/android/settings/fuelgauge/batterysaver/BatterySaverScheduleSettingsTest.java
index 5c24da9..bb36c8a 100644
--- a/tests/robotests/src/com/android/settings/fuelgauge/batterysaver/BatterySaverScheduleSettingsTest.java
+++ b/tests/robotests/src/com/android/settings/fuelgauge/batterysaver/BatterySaverScheduleSettingsTest.java
@@ -1,7 +1,5 @@
package com.android.settings.fuelgauge.batterysaver;
-import static com.google.common.truth.Truth.assertThat;
-
import static org.mockito.Mockito.spy;
import static org.mockito.Mockito.verify;
import static org.mockito.Mockito.verifyNoMoreInteractions;
@@ -10,7 +8,6 @@
import android.content.Context;
import android.os.PowerManager;
import android.provider.Settings;
-import android.util.Pair;
import com.android.settings.testutils.FakeFeatureFactory;
import com.android.settingslib.core.instrumentation.MetricsFeatureProvider;
diff --git a/tests/robotests/src/com/android/settings/password/SetupSkipDialogTest.java b/tests/robotests/src/com/android/settings/password/SetupSkipDialogTest.java
index 9be0896..fab1f03 100644
--- a/tests/robotests/src/com/android/settings/password/SetupSkipDialogTest.java
+++ b/tests/robotests/src/com/android/settings/password/SetupSkipDialogTest.java
@@ -18,24 +18,24 @@
import static com.google.common.truth.Truth.assertThat;
-import androidx.appcompat.app.AlertDialog;
import androidx.fragment.app.FragmentActivity;
+import androidx.test.core.app.ApplicationProvider;
import com.android.settings.R;
-import com.android.settings.testutils.shadow.ShadowAlertDialogCompat;
import com.android.settings.testutils.shadow.ShadowUtils;
import org.junit.Before;
-import org.junit.Ignore;
import org.junit.Test;
import org.junit.runner.RunWith;
import org.robolectric.Robolectric;
import org.robolectric.RobolectricTestRunner;
import org.robolectric.annotation.Config;
+import org.robolectric.shadow.api.Shadow;
+import org.robolectric.shadows.ShadowAlertDialog;
+import org.robolectric.shadows.ShadowApplication;
@RunWith(RobolectricTestRunner.class)
-@Config(shadows = {ShadowUtils.class, ShadowAlertDialogCompat.class})
-@Ignore
+@Config(shadows = {ShadowUtils.class, ShadowAlertDialog.class})
public class SetupSkipDialogTest {
private FragmentActivity mActivity;
@@ -45,19 +45,25 @@
mActivity = Robolectric.setupActivity(FragmentActivity.class);
}
+ private ShadowAlertDialog getShadowAlertDialog() {
+ ShadowApplication shadowApplication = Shadow.extract(
+ ApplicationProvider.getApplicationContext());
+ ShadowAlertDialog shadowAlertDialog = shadowApplication.getLatestAlertDialog();
+ assertThat(shadowAlertDialog).isNotNull();
+ return shadowAlertDialog;
+ }
+
@Test
public void frpMessages_areShownCorrectly_whenNotSupported() {
SetupSkipDialog setupSkipDialog =
SetupSkipDialog.newInstance(false, false, false, false, false, false);
setupSkipDialog.show(mActivity.getSupportFragmentManager());
- AlertDialog alertDialog = ShadowAlertDialogCompat.getLatestAlertDialog();
- assertThat(alertDialog).isNotNull();
- ShadowAlertDialogCompat shadowAlertDialog = ShadowAlertDialogCompat.shadowOf(alertDialog);
- assertThat(mActivity.getString(R.string.lock_screen_intro_skip_title)).isEqualTo(
- shadowAlertDialog.getTitle());
- assertThat(mActivity.getString(R.string.lock_screen_intro_skip_dialog_text)).isEqualTo(
- shadowAlertDialog.getMessage());
+ ShadowAlertDialog shadowAlertDialog = getShadowAlertDialog();
+ assertThat(shadowAlertDialog.getTitle().toString()).isEqualTo(
+ mActivity.getString(R.string.lock_screen_intro_skip_title));
+ assertThat(shadowAlertDialog.getMessage().toString()).isEqualTo(
+ mActivity.getString(R.string.lock_screen_intro_skip_dialog_text));
}
@Test
@@ -66,29 +72,24 @@
SetupSkipDialog.newInstance(true, false, false, false, false, false);
setupSkipDialog.show(mActivity.getSupportFragmentManager());
- AlertDialog alertDialog = ShadowAlertDialogCompat.getLatestAlertDialog();
- assertThat(alertDialog).isNotNull();
- ShadowAlertDialogCompat shadowAlertDialog = ShadowAlertDialogCompat.shadowOf(alertDialog);
- assertThat(mActivity.getString(R.string.lock_screen_intro_skip_title)).isEqualTo(
- shadowAlertDialog.getTitle());
- assertThat(mActivity.getString(R.string.lock_screen_intro_skip_dialog_text_frp)).isEqualTo(
- shadowAlertDialog.getMessage());
+ ShadowAlertDialog shadowAlertDialog = getShadowAlertDialog();
+ assertThat(shadowAlertDialog.getTitle().toString()).isEqualTo(
+ mActivity.getString(R.string.lock_screen_intro_skip_title));
+ assertThat(shadowAlertDialog.getMessage().toString()).isEqualTo(
+ mActivity.getString(R.string.lock_screen_intro_skip_dialog_text_frp));
}
@Test
- @Ignore
public void dialogMessage_whenSkipPinSetupForFace_shouldShownCorrectly() {
SetupSkipDialog setupSkipDialog =
SetupSkipDialog.newInstance(true, false, false, false, true, false);
setupSkipDialog.show(mActivity.getSupportFragmentManager());
- AlertDialog alertDialog = ShadowAlertDialogCompat.getLatestAlertDialog();
- assertThat(alertDialog).isNotNull();
- ShadowAlertDialogCompat shadowAlertDialog = ShadowAlertDialogCompat.shadowOf(alertDialog);
- assertThat(shadowAlertDialog.getTitle()).isEqualTo(
- mActivity.getString(R.string.lock_screen_pin_skip_biometrics_title));
- assertThat(shadowAlertDialog.getMessage()).isEqualTo(
- mActivity.getString(R.string.lock_screen_pin_skip_biometrics_message));
+ ShadowAlertDialog shadowAlertDialog = getShadowAlertDialog();
+ assertThat(shadowAlertDialog.getTitle().toString()).isEqualTo(
+ mActivity.getString(R.string.lock_screen_pin_skip_face_title));
+ assertThat(shadowAlertDialog.getMessage().toString()).isEqualTo(
+ mActivity.getString(R.string.lock_screen_pin_skip_face_message));
}
@Test
@@ -97,12 +98,10 @@
SetupSkipDialog.newInstance(true, false, true, false, true, false);
setupSkipDialog.show(mActivity.getSupportFragmentManager());
- AlertDialog alertDialog = ShadowAlertDialogCompat.getLatestAlertDialog();
- assertThat(alertDialog).isNotNull();
- ShadowAlertDialogCompat shadowAlertDialog = ShadowAlertDialogCompat.shadowOf(alertDialog);
- assertThat(shadowAlertDialog.getTitle()).isEqualTo(
+ ShadowAlertDialog shadowAlertDialog = getShadowAlertDialog();
+ assertThat(shadowAlertDialog.getTitle().toString()).isEqualTo(
mActivity.getString(R.string.lock_screen_password_skip_face_title));
- assertThat(shadowAlertDialog.getMessage()).isEqualTo(
+ assertThat(shadowAlertDialog.getMessage().toString()).isEqualTo(
mActivity.getString(R.string.lock_screen_password_skip_face_message));
}
@@ -112,12 +111,10 @@
SetupSkipDialog.newInstance(true, true, false, false, true, false);
setupSkipDialog.show(mActivity.getSupportFragmentManager());
- AlertDialog alertDialog = ShadowAlertDialogCompat.getLatestAlertDialog();
- assertThat(alertDialog).isNotNull();
- ShadowAlertDialogCompat shadowAlertDialog = ShadowAlertDialogCompat.shadowOf(alertDialog);
- assertThat(shadowAlertDialog.getTitle()).isEqualTo(
+ ShadowAlertDialog shadowAlertDialog = getShadowAlertDialog();
+ assertThat(shadowAlertDialog.getTitle().toString()).isEqualTo(
mActivity.getString(R.string.lock_screen_pattern_skip_face_title));
- assertThat(shadowAlertDialog.getMessage()).isEqualTo(
+ assertThat(shadowAlertDialog.getMessage().toString()).isEqualTo(
mActivity.getString(R.string.lock_screen_pattern_skip_face_message));
}
@@ -127,12 +124,10 @@
SetupSkipDialog.newInstance(true, false, false, true, false, false);
setupSkipDialog.show(mActivity.getSupportFragmentManager());
- AlertDialog alertDialog = ShadowAlertDialogCompat.getLatestAlertDialog();
- assertThat(alertDialog).isNotNull();
- ShadowAlertDialogCompat shadowAlertDialog = ShadowAlertDialogCompat.shadowOf(alertDialog);
- assertThat(shadowAlertDialog.getTitle()).isEqualTo(
+ ShadowAlertDialog shadowAlertDialog = getShadowAlertDialog();
+ assertThat(shadowAlertDialog.getTitle().toString()).isEqualTo(
mActivity.getString(R.string.lock_screen_pin_skip_fingerprint_title));
- assertThat(shadowAlertDialog.getMessage()).isEqualTo(
+ assertThat(shadowAlertDialog.getMessage().toString()).isEqualTo(
mActivity.getString(R.string.lock_screen_pin_skip_fingerprint_message));
}
@@ -142,12 +137,10 @@
SetupSkipDialog.newInstance(true, false, true, true, false, false);
setupSkipDialog.show(mActivity.getSupportFragmentManager());
- AlertDialog alertDialog = ShadowAlertDialogCompat.getLatestAlertDialog();
- assertThat(alertDialog).isNotNull();
- ShadowAlertDialogCompat shadowAlertDialog = ShadowAlertDialogCompat.shadowOf(alertDialog);
- assertThat(shadowAlertDialog.getTitle()).isEqualTo(
+ ShadowAlertDialog shadowAlertDialog = getShadowAlertDialog();
+ assertThat(shadowAlertDialog.getTitle().toString()).isEqualTo(
mActivity.getString(R.string.lock_screen_password_skip_fingerprint_title));
- assertThat(shadowAlertDialog.getMessage()).isEqualTo(
+ assertThat(shadowAlertDialog.getMessage().toString()).isEqualTo(
mActivity.getString(R.string.lock_screen_password_skip_fingerprint_message));
}
@@ -157,28 +150,23 @@
SetupSkipDialog.newInstance(true, true, false, true, false, false);
setupSkipDialog.show(mActivity.getSupportFragmentManager());
- AlertDialog alertDialog = ShadowAlertDialogCompat.getLatestAlertDialog();
- assertThat(alertDialog).isNotNull();
- ShadowAlertDialogCompat shadowAlertDialog = ShadowAlertDialogCompat.shadowOf(alertDialog);
- assertThat(shadowAlertDialog.getTitle()).isEqualTo(
+ ShadowAlertDialog shadowAlertDialog = getShadowAlertDialog();
+ assertThat(shadowAlertDialog.getTitle().toString()).isEqualTo(
mActivity.getString(R.string.lock_screen_pattern_skip_fingerprint_title));
- assertThat(shadowAlertDialog.getMessage()).isEqualTo(
+ assertThat(shadowAlertDialog.getMessage().toString()).isEqualTo(
mActivity.getString(R.string.lock_screen_pattern_skip_fingerprint_message));
}
-
@Test
public void dialogMessage_whenSkipPinSetupForBiometrics_shouldShownCorrectly() {
SetupSkipDialog setupSkipDialog =
SetupSkipDialog.newInstance(true, false, false, false, false, true);
setupSkipDialog.show(mActivity.getSupportFragmentManager());
- AlertDialog alertDialog = ShadowAlertDialogCompat.getLatestAlertDialog();
- assertThat(alertDialog).isNotNull();
- ShadowAlertDialogCompat shadowAlertDialog = ShadowAlertDialogCompat.shadowOf(alertDialog);
- assertThat(shadowAlertDialog.getTitle()).isEqualTo(
+ ShadowAlertDialog shadowAlertDialog = getShadowAlertDialog();
+ assertThat(shadowAlertDialog.getTitle().toString()).isEqualTo(
mActivity.getString(R.string.lock_screen_pin_skip_biometrics_title));
- assertThat(shadowAlertDialog.getMessage()).isEqualTo(
+ assertThat(shadowAlertDialog.getMessage().toString()).isEqualTo(
mActivity.getString(R.string.lock_screen_pin_skip_biometrics_message));
}
@@ -188,12 +176,10 @@
SetupSkipDialog.newInstance(true, false, true, false, false, true);
setupSkipDialog.show(mActivity.getSupportFragmentManager());
- AlertDialog alertDialog = ShadowAlertDialogCompat.getLatestAlertDialog();
- assertThat(alertDialog).isNotNull();
- ShadowAlertDialogCompat shadowAlertDialog = ShadowAlertDialogCompat.shadowOf(alertDialog);
- assertThat(shadowAlertDialog.getTitle()).isEqualTo(
+ ShadowAlertDialog shadowAlertDialog = getShadowAlertDialog();
+ assertThat(shadowAlertDialog.getTitle().toString()).isEqualTo(
mActivity.getString(R.string.lock_screen_password_skip_biometrics_title));
- assertThat(shadowAlertDialog.getMessage()).isEqualTo(
+ assertThat(shadowAlertDialog.getMessage().toString()).isEqualTo(
mActivity.getString(R.string.lock_screen_password_skip_biometrics_message));
}
@@ -203,12 +189,10 @@
SetupSkipDialog.newInstance(true, true, false, false, false, true);
setupSkipDialog.show(mActivity.getSupportFragmentManager());
- AlertDialog alertDialog = ShadowAlertDialogCompat.getLatestAlertDialog();
- assertThat(alertDialog).isNotNull();
- ShadowAlertDialogCompat shadowAlertDialog = ShadowAlertDialogCompat.shadowOf(alertDialog);
- assertThat(shadowAlertDialog.getTitle()).isEqualTo(
+ ShadowAlertDialog shadowAlertDialog = getShadowAlertDialog();
+ assertThat(shadowAlertDialog.getTitle().toString()).isEqualTo(
mActivity.getString(R.string.lock_screen_pattern_skip_biometrics_title));
- assertThat(shadowAlertDialog.getMessage()).isEqualTo(
+ assertThat(shadowAlertDialog.getMessage().toString()).isEqualTo(
mActivity.getString(R.string.lock_screen_pattern_skip_biometrics_message));
}
}
diff --git a/tests/robotests/src/com/android/settings/wifi/NetworkRequestDialogActivityTest.java b/tests/robotests/src/com/android/settings/wifi/NetworkRequestDialogActivityTest.java
index fb20045..616cb0b 100644
--- a/tests/robotests/src/com/android/settings/wifi/NetworkRequestDialogActivityTest.java
+++ b/tests/robotests/src/com/android/settings/wifi/NetworkRequestDialogActivityTest.java
@@ -25,7 +25,6 @@
import static org.mockito.Mockito.verify;
import static org.mockito.Mockito.when;
-import android.content.Context;
import android.content.Intent;
import android.net.wifi.ScanResult;
import android.net.wifi.WifiConfiguration;
@@ -42,9 +41,12 @@
import com.android.wifitrackerlib.WifiPickerTracker;
import org.junit.Before;
+import org.junit.Rule;
import org.junit.Test;
import org.junit.runner.RunWith;
-import org.mockito.MockitoAnnotations;
+import org.mockito.Mock;
+import org.mockito.junit.MockitoJUnit;
+import org.mockito.junit.MockitoRule;
import org.robolectric.Robolectric;
import org.robolectric.RobolectricTestRunner;
import org.robolectric.RuntimeEnvironment;
@@ -61,25 +63,26 @@
private static final String TEST_SSID = "testssid";
private static final String TEST_CAPABILITY = "wep";
- NetworkRequestDialogActivity mActivity;
+ @Rule
+ public MockitoRule mRule = MockitoJUnit.rule();
+ @Mock
WifiManager mWifiManager;
- Context mContext;
+ @Mock
+ NetworkRequestUserSelectionCallback mNetworkRequestUserSelectionCallback;
+
+ NetworkRequestDialogActivity mActivity;
+ List<ScanResult> mScanResults = new ArrayList<>();
@Before
public void setUp() {
- MockitoAnnotations.initMocks(this);
- mContext = spy(RuntimeEnvironment.application);
FakeFeatureFactory fakeFeatureFactory = FakeFeatureFactory.setupForTest();
when(fakeFeatureFactory.wifiTrackerLibProvider.createWifiPickerTracker(
any(), any(), any(), any(), any(), anyLong(), anyLong(), any()))
.thenReturn(mock(WifiPickerTracker.class));
+ mScanResults.add(getScanResult(TEST_SSID, TEST_CAPABILITY));
- NetworkRequestDialogActivity activity =
- Robolectric.setupActivity(NetworkRequestDialogActivity.class);
- mActivity = spy(activity);
-
- mWifiManager = mock(WifiManager.class);
- when(mActivity.getSystemService(Context.WIFI_SERVICE)).thenReturn(mWifiManager);
+ mActivity = spy(Robolectric.setupActivity(NetworkRequestDialogActivity.class));
+ when(mActivity.getSystemService(WifiManager.class)).thenReturn(mWifiManager);
}
@Test
@@ -169,10 +172,7 @@
public void specifiedSsid_onMatch_shouldShowDialogFragment() {
startSpecifiedActivity();
- final List<ScanResult> scanResults = new ArrayList<>();
- scanResults.add(getScanResult(TEST_SSID, TEST_CAPABILITY));
-
- mActivity.onMatch(scanResults);
+ mActivity.onMatch(mScanResults);
assertThat(mActivity.mProgressDialog).isNull();
assertThat(mActivity.mDialogFragment).isNotNull();
@@ -193,9 +193,7 @@
public void onUserSelectionConnectFailure_shouldShowDialogFragment() {
WifiConfiguration wifiConfiguration = mock(WifiConfiguration.class);
startSpecifiedActivity();
- final List<ScanResult> scanResults = new ArrayList<>();
- scanResults.add(getScanResult(TEST_SSID, TEST_CAPABILITY));
- mActivity.onMatch(scanResults);
+ mActivity.onMatch(mScanResults);
mActivity.onUserSelectionConnectFailure(wifiConfiguration);
@@ -205,13 +203,9 @@
@Test
public void onClickConnectButton_shouldShowProgressDialog() {
- NetworkRequestUserSelectionCallback networkRequestUserSelectionCallback = mock(
- NetworkRequestUserSelectionCallback.class);
startSpecifiedActivity();
- final List<ScanResult> scanResults = new ArrayList<>();
- scanResults.add(getScanResult(TEST_SSID, TEST_CAPABILITY));
- mActivity.onMatch(scanResults);
- mActivity.onUserSelectionCallbackRegistration(networkRequestUserSelectionCallback);
+ mActivity.onMatch(mScanResults);
+ mActivity.onUserSelectionCallbackRegistration(mNetworkRequestUserSelectionCallback);
mActivity.onClickConnectButton();
@@ -222,9 +216,7 @@
@Test
public void onCancel_shouldCloseAllUI() {
startSpecifiedActivity();
- final List<ScanResult> scanResults = new ArrayList<>();
- scanResults.add(getScanResult(TEST_SSID, TEST_CAPABILITY));
- mActivity.onMatch(scanResults);
+ mActivity.onMatch(mScanResults);
mActivity.onCancel();
@@ -240,4 +232,20 @@
verify(mActivity).finish();
}
+
+ @Test
+ public void onUserSelectionCallbackRegistration_dismissDialogsAndDialogIsNull_shouldNotCrash() {
+ mActivity.dismissDialogs();
+
+ mActivity.onUserSelectionCallbackRegistration(mNetworkRequestUserSelectionCallback);
+ }
+
+ @Test
+ public void onMatch_dismissDialogsAndDialogIsNull_shouldNotCrash() {
+ mActivity.mIsSpecifiedSsid = false;
+ mActivity.mShowingErrorDialog = false;
+ mActivity.dismissDialogs();
+
+ mActivity.onMatch(mScanResults);
+ }
}
diff --git a/tests/unit/src/com/android/settings/biometrics/face/FaceStatusUtilsTest.java b/tests/unit/src/com/android/settings/biometrics/face/FaceStatusUtilsTest.java
index 9f9dd93..6dfb1e6 100644
--- a/tests/unit/src/com/android/settings/biometrics/face/FaceStatusUtilsTest.java
+++ b/tests/unit/src/com/android/settings/biometrics/face/FaceStatusUtilsTest.java
@@ -171,7 +171,7 @@
when(mFaceManager.hasEnrolledTemplates(anyInt())).thenReturn(false);
assertThat(mFaceStatusUtils.getSettingsClassName())
- .isEqualTo(FaceEnrollIntroduction.class.getName());
+ .isEqualTo(FaceEnrollIntroductionInternal.class.getName());
}
@Test
@@ -179,6 +179,6 @@
when(mFaceManager.hasEnrolledTemplates(anyInt())).thenReturn(true);
assertThat(mFaceStatusUtils.getSettingsClassName())
- .isEqualTo(Settings.FaceSettingsActivity.class.getName());
+ .isEqualTo(Settings.FaceSettingsInternalActivity.class.getName());
}
}
diff --git a/tests/unit/src/com/android/settings/biometrics/fingerprint/FingerprintStatusUtilsTest.java b/tests/unit/src/com/android/settings/biometrics/fingerprint/FingerprintStatusUtilsTest.java
index 4ecf82e..6faf801 100644
--- a/tests/unit/src/com/android/settings/biometrics/fingerprint/FingerprintStatusUtilsTest.java
+++ b/tests/unit/src/com/android/settings/biometrics/fingerprint/FingerprintStatusUtilsTest.java
@@ -183,7 +183,7 @@
when(mFingerprintManager.hasEnrolledFingerprints(anyInt())).thenReturn(false);
assertThat(mFingerprintStatusUtils.getSettingsClassName())
- .isEqualTo(FingerprintEnrollIntroduction.class.getName());
+ .isEqualTo(FingerprintEnrollIntroductionInternal.class.getName());
}
@Test
diff --git a/tests/unit/src/com/android/settings/development/MockModemPreferenceControllerTest.java b/tests/unit/src/com/android/settings/development/MockModemPreferenceControllerTest.java
new file mode 100644
index 0000000..f811ac4
--- /dev/null
+++ b/tests/unit/src/com/android/settings/development/MockModemPreferenceControllerTest.java
@@ -0,0 +1,111 @@
+/*
+ * Copyright (C) 2022 The Android Open Source Project
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package com.android.settings.development;
+
+import static com.android.settings.development.MockModemPreferenceController
+ .ALLOW_MOCK_MODEM_PROPERTY;
+
+import static com.google.common.truth.Truth.assertThat;
+
+import android.content.Context;
+import android.os.Looper;
+import android.os.SystemProperties;
+
+import androidx.preference.PreferenceManager;
+import androidx.preference.PreferenceScreen;
+import androidx.preference.SwitchPreference;
+import androidx.test.core.app.ApplicationProvider;
+import androidx.test.ext.junit.runners.AndroidJUnit4;
+
+import org.junit.Before;
+import org.junit.Test;
+import org.junit.runner.RunWith;
+
+@RunWith(AndroidJUnit4.class)
+public class MockModemPreferenceControllerTest {
+
+ private Context mContext;
+ private MockModemPreferenceController mController;
+ private SwitchPreference mPreference;
+
+ @Before
+ public void setUp() {
+ mContext = ApplicationProvider.getApplicationContext();
+ mController = new MockModemPreferenceController(mContext);
+ if (Looper.myLooper() == null) {
+ Looper.prepare();
+ }
+
+ final PreferenceManager preferenceManager = new PreferenceManager(mContext);
+ final PreferenceScreen screen = preferenceManager.createPreferenceScreen(mContext);
+ mPreference = new SwitchPreference(mContext);
+ mPreference.setKey(mController.getPreferenceKey());
+ screen.addPreference(mPreference);
+ mController.displayPreference(screen);
+ }
+
+ @Test
+ public void onPreferenceChanged_settingDisabled_shouldNotAllowedMockModem() {
+ mController.onPreferenceChange(mPreference, false /* new value */);
+
+ final boolean mode = SystemProperties.getBoolean(
+ ALLOW_MOCK_MODEM_PROPERTY, false /* default */);
+
+ assertThat(mode).isFalse();
+ }
+
+ @Test
+ public void onPreferenceChanged_settingEnabled_shouldAllowMockModem() {
+ mController.onPreferenceChange(mPreference, true /* new value */);
+
+ final boolean mode = SystemProperties.getBoolean(
+ ALLOW_MOCK_MODEM_PROPERTY, false /* default */);
+
+ assertThat(mode).isTrue();
+ }
+
+ @Test
+ public void updateState_settingEnabled_preferenceShouldBeChecked() {
+ SystemProperties.set(ALLOW_MOCK_MODEM_PROPERTY,
+ Boolean.toString(true));
+
+ mController.updateState(mPreference);
+ assertThat(mPreference.isChecked()).isTrue();
+ }
+
+ @Test
+ public void updateState_settingDisabled_preferenceShouldNotBeChecked() {
+ SystemProperties.set(ALLOW_MOCK_MODEM_PROPERTY,
+ Boolean.toString(false));
+
+ mController.updateState(mPreference);
+ assertThat(mPreference.isChecked()).isFalse();
+ }
+
+ @Test
+ public void onDeveloperOptionsDisabled_shouldDisablePreference() {
+ mController.onDeveloperOptionsSwitchDisabled();
+ final boolean mode = SystemProperties.getBoolean(
+ ALLOW_MOCK_MODEM_PROPERTY,
+ false /* default */);
+
+ mController.updateState(mPreference);
+
+ assertThat(mode).isFalse();
+ assertThat(mPreference.isChecked()).isFalse();
+ }
+}
diff --git a/tests/unit/src/com/android/settings/deviceinfo/PrivateVolumeForgetTest.java b/tests/unit/src/com/android/settings/deviceinfo/PrivateVolumeForgetTest.java
index 1edfa93..957e0c8 100644
--- a/tests/unit/src/com/android/settings/deviceinfo/PrivateVolumeForgetTest.java
+++ b/tests/unit/src/com/android/settings/deviceinfo/PrivateVolumeForgetTest.java
@@ -28,6 +28,7 @@
import com.android.settings.Settings;
+import org.junit.Ignore;
import org.junit.Rule;
import org.junit.Test;
import org.junit.runner.RunWith;
@@ -40,6 +41,7 @@
new ActivityTestRule<>(Settings.PrivateVolumeForgetActivity.class, true, true);
@Test
+ @Ignore
public void test_invalidSetupDoesNotCrashSettings() {
Context targetContext = InstrumentationRegistry.getInstrumentation().getTargetContext();
Intent intent = new Intent(targetContext, Settings.PrivateVolumeForgetActivity.class);
diff --git a/tests/unit/src/com/android/settings/safetycenter/BiometricsSafetySourceTest.java b/tests/unit/src/com/android/settings/safetycenter/BiometricsSafetySourceTest.java
index 765032b..addb491 100644
--- a/tests/unit/src/com/android/settings/safetycenter/BiometricsSafetySourceTest.java
+++ b/tests/unit/src/com/android/settings/safetycenter/BiometricsSafetySourceTest.java
@@ -47,8 +47,8 @@
import androidx.test.ext.junit.runners.AndroidJUnit4;
import com.android.settings.Settings;
-import com.android.settings.biometrics.face.FaceEnrollIntroduction;
-import com.android.settings.biometrics.fingerprint.FingerprintEnrollIntroduction;
+import com.android.settings.biometrics.face.FaceEnrollIntroductionInternal;
+import com.android.settings.biometrics.fingerprint.FingerprintEnrollIntroductionInternal;
import com.android.settings.biometrics.fingerprint.FingerprintSettings;
import com.android.settings.testutils.ResourcesUtils;
@@ -187,7 +187,7 @@
assertSafetySourceEnabledDataSetWithSingularSummary(
"security_settings_fingerprint_preference_title",
"security_settings_fingerprint_preference_summary_none",
- FingerprintEnrollIntroduction.class.getName());
+ FingerprintEnrollIntroductionInternal.class.getName());
}
@Test
@@ -258,7 +258,7 @@
assertSafetySourceEnabledDataSetWithSingularSummary(
"security_settings_face_preference_title",
"security_settings_face_preference_summary_none",
- FaceEnrollIntroduction.class.getName());
+ FaceEnrollIntroductionInternal.class.getName());
}
@Test
@@ -290,7 +290,7 @@
assertSafetySourceEnabledDataSetWithSingularSummary(
"security_settings_face_preference_title",
"security_settings_face_preference_summary",
- Settings.FaceSettingsActivity.class.getName());
+ Settings.FaceSettingsInternalActivity.class.getName());
}
@Test