diff --git a/AndroidManifest.xml b/AndroidManifest.xml index 9986e34d7c2..164d42e5ffb 100644 --- a/AndroidManifest.xml +++ b/AndroidManifest.xml @@ -205,7 +205,9 @@ + android:exported="false" + android:theme="@style/Theme.SubSettings" + android:taskAffinity="com.android.settings.root" /> + + + + + + android:exported="false" + android:taskAffinity="com.android.settings.root"> + android:icon="@drawable/ic_homepage_wifi_tethering"> @@ -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"> @@ -2180,14 +2194,19 @@ android:screenOrientation="portrait"/> + android:exported="true" + android:screenOrientation="portrait"> + + @@ -2217,7 +2236,9 @@ - + @@ -2231,6 +2252,11 @@ + + @@ -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"> @@ -4294,6 +4320,7 @@ android:name=".sim.ChooseSimActivity" android:theme="@style/GlifV3Theme.DayNight.NoActionBar" android:launchMode="singleInstance" + android:excludeFromRecents="true" android:exported="false"/> + + + + + + + + + + diff --git a/res/drawable/ic_homepage_vpn.xml b/res/drawable/ic_homepage_vpn.xml new file mode 100644 index 00000000000..d1fba0ede6a --- /dev/null +++ b/res/drawable/ic_homepage_vpn.xml @@ -0,0 +1,33 @@ + + + + + + + + + + + diff --git a/res/drawable/ic_homepage_wifi_tethering.xml b/res/drawable/ic_homepage_wifi_tethering.xml new file mode 100644 index 00000000000..fd4c0511476 --- /dev/null +++ b/res/drawable/ic_homepage_wifi_tethering.xml @@ -0,0 +1,33 @@ + + + + + + + + + + + diff --git a/res/layout/accessibility_shortcut_secondary_action.xml b/res/layout/accessibility_shortcut_secondary_action.xml index 8d0ef3bdfe3..bdb129f83e0 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"> + android:gravity="start|center_vertical"> diff --git a/res/layout/tare_dropdown_page.xml b/res/layout/tare_dropdown_page.xml index 674b189912d..9ec7ebfa62e 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" /> From: Bill - 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? + Good morning!\n\nI just wanted to check how the designs are coming. Will they be ready before we start building the new balloons? Reset settings @@ -13887,9 +13887,15 @@ Actions (Cost to Produce) Actions (Base Price) - - Rewards + + Rewards per single event + + Rewards for total event duration + + Maximum Rewards Per Day @@ -14025,7 +14031,7 @@ @string/tare_top_activity @string/tare_notification_seen - @string/tare_notification_seen_15_min + @string/tare_notification_interaction @string/tare_widget_interaction @string/tare_other_interaction @@ -14090,11 +14096,11 @@ Spatial audio - Immersive audio seems like it\u0027s coming from all around you. Only works with some media. + Audio from compatible media becomes more immersive - Make audio more realistic + Head tracking - Shift positioning of audio so it sounds more natural. + Audio changes as you move your head to sound more natural Network download rate limit diff --git a/src/com/android/settings/Settings.java b/src/com/android/settings/Settings.java index 57d7d105188..5c3e53e90eb 100644 --- a/src/com/android/settings/Settings.java +++ b/src/com/android/settings/Settings.java @@ -28,6 +28,7 @@ import android.util.FeatureFlagUtils; 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 class Settings extends SettingsActivity { 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 1176fa462c0..d2d6a3374ca 100644 --- a/src/com/android/settings/accessibility/ToggleScreenMagnificationPreferenceFragment.java +++ b/src/com/android/settings/accessibility/ToggleScreenMagnificationPreferenceFragment.java @@ -27,6 +27,7 @@ import android.content.ComponentName; 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 @@ public class ToggleScreenMagnificationPreferenceFragment extends @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 6441eeb4571..bc8c6005806 100644 --- a/src/com/android/settings/accessibility/VibrationIntensityPreferenceController.java +++ b/src/com/android/settings/accessibility/VibrationIntensityPreferenceController.java @@ -73,11 +73,11 @@ public abstract class VibrationIntensityPreferenceController extends SliderPrefe 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 726bbc1f054..02e89269209 100644 --- a/src/com/android/settings/accessibility/VibrationMainSwitchPreferenceController.java +++ b/src/com/android/settings/accessibility/VibrationMainSwitchPreferenceController.java @@ -23,6 +23,8 @@ import android.content.Context; 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 @@ public class VibrationMainSwitchPreferenceController extends SettingsMainSwitchP 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 @@ public class VibrationMainSwitchPreferenceController extends SettingsMainSwitchP @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 9208b188c49..b4be5281a0c 100644 --- a/src/com/android/settings/accessibility/VibrationPreferenceConfig.java +++ b/src/com/android/settings/accessibility/VibrationPreferenceConfig.java @@ -49,6 +49,8 @@ public abstract class VibrationPreferenceConfig { * 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 @@ public abstract class VibrationPreferenceConfig { 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 @@ public abstract class VibrationPreferenceConfig { 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 @@ public abstract class VibrationPreferenceConfig { /** 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 @@ public abstract class VibrationPreferenceConfig { 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 8d1b43ee926..149bed35373 100644 --- a/src/com/android/settings/accessibility/VibrationRampingRingerTogglePreferenceController.java +++ b/src/com/android/settings/accessibility/VibrationRampingRingerTogglePreferenceController.java @@ -124,6 +124,12 @@ public class VibrationRampingRingerTogglePreferenceController 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 124bb4f2707..3ca81685d14 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.SettingsActivity; 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 @@ import java.util.Set; 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 @@ public class ActivityEmbeddingRulesController { 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 @@ public class ActivityEmbeddingRulesController { 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 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 activityFilters, 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 00000000000..7dd29da3aea --- /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 1749aca2051..80ffb03b0b2 100644 --- a/src/com/android/settings/biometrics/face/FaceStatusUtils.java +++ b/src/com/android/settings/biometrics/face/FaceStatusUtils.java @@ -71,8 +71,8 @@ public class FaceStatusUtils { * 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 00000000000..ac32d5013af --- /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 5707f328601..82ceed6c878 100644 --- a/src/com/android/settings/biometrics/fingerprint/FingerprintStatusUtils.java +++ b/src/com/android/settings/biometrics/fingerprint/FingerprintStatusUtils.java @@ -79,7 +79,7 @@ public class FingerprintStatusUtils { */ public String getSettingsClassName() { return hasEnrolled() ? FingerprintSettings.class.getName() - : FingerprintEnrollIntroduction.class.getName(); + : FingerprintEnrollIntroductionInternal.class.getName(); } /** diff --git a/src/com/android/settings/development/tare/AlarmManagerFragment.java b/src/com/android/settings/development/tare/AlarmManagerFragment.java index c4dca376ae1..980954d7bf9 100644 --- a/src/com/android/settings/development/tare/AlarmManagerFragment.java +++ b/src/com/android/settings/development/tare/AlarmManagerFragment.java @@ -97,7 +97,8 @@ public class AlarmManagerFragment extends Fragment implements // 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 @@ public class AlarmManagerFragment extends Fragment implements // 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 @@ public class AlarmManagerFragment extends Fragment implements 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 275e012e941..bffd648c6be 100644 --- a/src/com/android/settings/development/tare/JobSchedulerFragment.java +++ b/src/com/android/settings/development/tare/JobSchedulerFragment.java @@ -98,7 +98,9 @@ public class JobSchedulerFragment extends Fragment implements // 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 @@ public class JobSchedulerFragment extends Fragment implements // 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 @@ public class JobSchedulerFragment extends Fragment implements 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 b9f813d3ef3..62fde6d4829 100644 --- a/src/com/android/settings/development/tare/TareFactorController.java +++ b/src/com/android/settings/development/tare/TareFactorController.java @@ -530,7 +530,7 @@ public class TareFactorController { } 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 d24f1b25a03..da0f2e2fbe5 100644 --- a/src/com/android/settings/fuelgauge/batterysaver/BatterySaverButtonPreferenceController.java +++ b/src/com/android/settings/fuelgauge/batterysaver/BatterySaverButtonPreferenceController.java @@ -111,9 +111,8 @@ public class BatterySaverButtonPreferenceController extends @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 737fb0f8d2f..378918a50eb 100644 --- a/src/com/android/settings/fuelgauge/batterysaver/BatterySaverScheduleRadioButtonsController.java +++ b/src/com/android/settings/fuelgauge/batterysaver/BatterySaverScheduleRadioButtonsController.java @@ -40,7 +40,7 @@ public class BatterySaverScheduleRadioButtonsController { 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 173d946761a..a441449ba55 100644 --- a/src/com/android/settings/fuelgauge/batterysaver/BatterySaverScheduleSeekBarController.java +++ b/src/com/android/settings/fuelgauge/batterysaver/BatterySaverScheduleSeekBarController.java @@ -45,7 +45,7 @@ public class BatterySaverScheduleSeekBarController implements 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 03db1b89be7..926c77e6530 100644 --- a/src/com/android/settings/network/apn/ApnEditor.java +++ b/src/com/android/settings/network/apn/ApnEditor.java @@ -149,6 +149,7 @@ public class ApnEditor extends SettingsPreferenceFragment 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 @@ public class ApnEditor extends SettingsPreferenceFragment 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 @@ public class ApnEditor extends SettingsPreferenceFragment 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 @@ public class ApnEditor extends SettingsPreferenceFragment } 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 @@ public class ApnEditor extends SettingsPreferenceFragment } 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 @@ public class ApnEditor extends SettingsPreferenceFragment 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 @@ public class ApnEditor extends SettingsPreferenceFragment 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 77fcbed6493..e4d52ba1d21 100644 --- a/src/com/android/settings/password/ChooseLockSettingsHelper.java +++ b/src/com/android/settings/password/ChooseLockSettingsHelper.java @@ -44,7 +44,6 @@ public final class ChooseLockSettingsHelper { 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 @@ public final class ChooseLockSettingsHelper { /** * @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 7dcfc83179a..a81f975f5c6 100644 --- a/src/com/android/settings/password/ConfirmLockPassword.java +++ b/src/com/android/settings/password/ConfirmLockPassword.java @@ -39,7 +39,6 @@ import android.os.Handler; 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 class ConfirmLockPassword extends ConfirmDeviceCredentialBaseActivity { 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 8b33aa5bb54..1062d940ea7 100644 --- a/src/com/android/settings/password/ConfirmLockPattern.java +++ b/src/com/android/settings/password/ConfirmLockPattern.java @@ -32,7 +32,6 @@ import android.os.Bundle; 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 class ConfirmLockPattern extends ConfirmDeviceCredentialBaseActivity { 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/tests/robotests/src/com/android/settings/accessibility/ToggleScreenMagnificationPreferenceFragmentTest.java b/tests/robotests/src/com/android/settings/accessibility/ToggleScreenMagnificationPreferenceFragmentTest.java index 8500e61a9d8..00ff9604a52 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.ComponentName; 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 @@ public class ToggleScreenMagnificationPreferenceFragmentTest { private FragmentActivity mActivity; @Mock private ContentResolver mContentResolver; + @Mock + private PackageManager mPackageManager; @Before public void setUpTestFragment() { @@ -110,6 +113,7 @@ public class ToggleScreenMagnificationPreferenceFragmentTest { 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 @@ public class ToggleScreenMagnificationPreferenceFragmentTest { @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 7398e5ce024..594de6a6e6a 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 @@ package com.android.settings.fuelgauge.batterysaver; 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 @@ public class BatterySaverButtonPreferenceControllerTest { } @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 bc5f0af4d7f..9b575934676 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 @@ package com.android.settings.fuelgauge.batterysaver; 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 @@ public class BatterySaverScheduleSeekBarControllerTest { @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 5c24da9aedb..bb36c8a4620 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.app.settings.SettingsEnums; 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 9be0896e29f..fab1f033d10 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 @@ package com.android.settings.password; 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 @@ public class SetupSkipDialogTest { 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 @@ public class SetupSkipDialogTest { 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 @@ public class SetupSkipDialogTest { 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 @@ public class SetupSkipDialogTest { 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 @@ public class SetupSkipDialogTest { 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 @@ public class SetupSkipDialogTest { 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 @@ public class SetupSkipDialogTest { 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 @@ public class SetupSkipDialogTest { 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 @@ public class SetupSkipDialogTest { 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/unit/src/com/android/settings/biometrics/face/FaceStatusUtilsTest.java b/tests/unit/src/com/android/settings/biometrics/face/FaceStatusUtilsTest.java index 9f9dd9355ec..6dfb1e6093f 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 @@ public class FaceStatusUtilsTest { when(mFaceManager.hasEnrolledTemplates(anyInt())).thenReturn(false); assertThat(mFaceStatusUtils.getSettingsClassName()) - .isEqualTo(FaceEnrollIntroduction.class.getName()); + .isEqualTo(FaceEnrollIntroductionInternal.class.getName()); } @Test @@ -179,6 +179,6 @@ public class FaceStatusUtilsTest { 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 4ecf82e3479..6faf8011278 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 @@ public class FingerprintStatusUtilsTest { 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/deviceinfo/PrivateVolumeForgetTest.java b/tests/unit/src/com/android/settings/deviceinfo/PrivateVolumeForgetTest.java index 1edfa9329c1..957e0c8ed01 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 androidx.test.runner.AndroidJUnit4; 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 @@ public class PrivateVolumeForgetTest { 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 765032b4b70..addb4917381 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.core.app.ApplicationProvider; 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 @@ public class BiometricsSafetySourceTest { assertSafetySourceEnabledDataSetWithSingularSummary( "security_settings_fingerprint_preference_title", "security_settings_fingerprint_preference_summary_none", - FingerprintEnrollIntroduction.class.getName()); + FingerprintEnrollIntroductionInternal.class.getName()); } @Test @@ -258,7 +258,7 @@ public class BiometricsSafetySourceTest { assertSafetySourceEnabledDataSetWithSingularSummary( "security_settings_face_preference_title", "security_settings_face_preference_summary_none", - FaceEnrollIntroduction.class.getName()); + FaceEnrollIntroductionInternal.class.getName()); } @Test @@ -290,7 +290,7 @@ public class BiometricsSafetySourceTest { assertSafetySourceEnabledDataSetWithSingularSummary( "security_settings_face_preference_title", "security_settings_face_preference_summary", - Settings.FaceSettingsActivity.class.getName()); + Settings.FaceSettingsInternalActivity.class.getName()); } @Test