Snap for 9649615 from 4aaf6c191b to udc-release

Change-Id: I3d3a1baa4dddd3254bc39a029b1175a0e496d3bb
This commit is contained in:
Android Build Coastguard Worker
2023-02-24 04:28:14 +00:00
17 changed files with 153 additions and 54 deletions

View File

@@ -1418,4 +1418,9 @@
<item>@color/screen_flash_preset_opacity_color_11</item>
<item>@color/screen_flash_preset_opacity_color_12</item>
</array>
<!-- hide 3G option from preferred network type UI -->
<integer-array name="network_mode_3g_deprecated_carrier_id" translatable="false">
</integer-array>
</resources>

View File

@@ -3916,8 +3916,8 @@
<string name="modifier_keys_caps_lock" translatable="false">Caps lock</string>
<!-- Title for the button to trigger the 'modifier keys ctrl'. [CHAR LIMIT=15] -->
<string name="modifier_keys_ctrl" translatable="false">Ctrl</string>
<!-- Title for the button to trigger the 'modifier keys meta'. [CHAR LIMIT=15] -->
<string name="modifier_keys_meta" translatable="false">Meta</string>
<!-- Title for the button to trigger the 'modifier keys action key'. [CHAR LIMIT=15] -->
<string name="modifier_keys_meta" translatable="false">Action key</string>
<!-- Title for the button to trigger the 'modifier keys alt'. [CHAR LIMIT=15] -->
<string name="modifier_keys_alt" translatable="false">Alt</string>
@@ -4100,18 +4100,20 @@
<string name="experimental_category_title">Experimental</string>
<!-- Title for feature flags dashboard where developers can turn on experimental features [CHAR LIMIT=50] -->
<string name="feature_flags_dashboard_title">Feature flags</string>
<!-- Title for snoop logger filters dashboard where developers can turn on filters [CHAR LIMIT=50] -->
<string name="snoop_logger_filters_dashboard_title">Snoop Logger Filters</string>
<!-- Summary for the snoop logger filters [CHAR LIMIT=50] -->
<string name="bt_hci_snoop_log_filters_dashboard_summary">Set filters (Toggle Bluetooth after changing this setting)</string>
<!-- Title for the snoop logger pbap filter [CHAR LIMIT=50] -->
<string name="bt_hci_snoop_log_filter_pbap_title">Snoop Logger Filter PBAP</string>
<!-- Title for the snoop logger map filter [CHAR LIMIT=50] -->
<string name="bt_hci_snoop_log_filter_map_title">Snoop Logger Filter MAP</string>
<!-- Summary for the snoop logger filters [CHAR LIMIT=50] -->
<string name="bt_hci_snoop_log_filter_summary">Set filtering mode. (Toggle Bluetooth after changing this setting)</string>
<!-- Summary for the snoop logger profile filters while disabled [CHAR LIMIT=50] -->
<string name="bt_hci_snoop_log_filtered_mode_disabled_summary">Enable Snoop Log Mode Filtered to change this option.</string>
<!-- Title for snoop logger filters dashboard where developers can turn on filters [CHAR LIMIT=100] -->
<string name="bt_hci_snoop_log_filters_dashboard_title">Bluetooth HCI snoop log filtering</string>
<!-- Summary for the snoop logger filters [CHAR LIMIT=100] -->
<string name="bt_hci_snoop_log_filters_dashboard_summary">Set filters</string>
<!-- Summary for the snoop logger filters [CHAR LIMIT=100] -->
<string name="bt_hci_snoop_log_filters_dashboard_footer">Disable and enable Bluetooth for the changes to take effect</string>
<!-- Title for the snoop logger pbap filter [CHAR LIMIT=100] -->
<string name="bt_hci_snoop_log_filter_pbap_title">Bluetooth HCI snoop log filtering PBAP</string>
<!-- Title for the snoop logger map filter [CHAR LIMIT=100] -->
<string name="bt_hci_snoop_log_filter_map_title">Bluetooth HCI snoop log filtering MAP</string>
<!-- Summary for the snoop logger filters [CHAR LIMIT=100] -->
<string name="bt_hci_snoop_log_filter_summary">Set filtering mode. (Disable and enable Bluetooth for the changes to take effect)</string>
<!-- Summary for the snoop logger profile filters while disabled [CHAR LIMIT=100] -->
<string name="bt_hci_snoop_log_filtered_mode_disabled_summary">Set Bluetooth HCI snoop log mode to Enabled Filtered to change this option</string>
<!-- Title for the Talkback Accessibility Service. Displayed on the Accessibility Settings screen in Setup Wizard. [CHAR_LIMIT=25] -->
<string name="talkback_title">Talkback</string>
<!-- Summary for the Talkback Accessibility Service. Lets the user know that Talkback is a screenreader and that it is usually most helpful to blind and low vision users and whether the service is on. [CHAR_LIMIT=none] -->
@@ -7784,12 +7786,12 @@
<!-- Summary for a warning message about security implications of enabling a notification
listener, displayed as a dialog message. [CHAR LIMIT=NONE] -->
<string name="notification_listener_security_warning_summary">
<xliff:g id="notification_listener_name">%1$s</xliff:g> will be able to read all notifications,
The <xliff:g id="notification_listener_name">%1$s</xliff:g> app will be able to read all notifications,
including personal information such as contact names, photos, and the text of messages you receive.
This app will also be able to snooze or dismiss notifications or take action on buttons in notifications, including answering phone calls.
\n\nThis will also give the app the ability to turn Do Not Disturb on or off and change related settings.
</string>
<string name="nls_warning_prompt"><xliff:g id="notification_listener_name">%1$s</xliff:g> will be able to:</string>
<string name="nls_warning_prompt">The <xliff:g id="notification_listener_name">%1$s</xliff:g> app will be able to:</string>
<string name="nls_feature_read_title">Read your notifications</string>
<string name="nls_feature_read_summary">It can read your notifications, including personal information such as contacts, messages, and photos.</string>
<string name="nls_feature_reply_title">Reply to messages</string>

View File

@@ -83,7 +83,7 @@
<Preference
android:key="snoop_logger_filters_dashboard"
android:title="@string/snoop_logger_filters_dashboard_title"
android:title="@string/bt_hci_snoop_log_filters_dashboard_title"
android:fragment=
"com.android.settings.development.snooplogger.SnoopLoggerFiltersDashboard" />

View File

@@ -18,7 +18,7 @@
<PreferenceScreen
xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:settings="http://schemas.android.com/apk/res-auto"
android:title="@string/snoop_logger_filters_dashboard_title" >
android:title="@string/bt_hci_snoop_log_filters_dashboard_title" >
<PreferenceCategory
android:key="snoop_logger_filters_category"
@@ -26,4 +26,10 @@
android:title="@string/bt_hci_snoop_log_filters_dashboard_summary"
settings:controller=
"com.android.settings.development.snooplogger.SnoopLoggerFiltersPreferenceController" />
<com.android.settingslib.widget.FooterPreference
android:key="snoop_logger_filters_footer"
android:title="@string/bt_hci_snoop_log_filters_dashboard_footer"
android:selectable="false"
settings:searchable="false"/>
</PreferenceScreen>

View File

@@ -162,7 +162,7 @@ public class SimEidPreferenceController extends BasePreferenceController
mShowEidOnSummary = true;
dialogShwon.setOnDismissListener(dlg -> {
mPreference.setSummary(getSummary());
mPreference.setSummary(PhoneNumberUtil.expandByTts(getSummary()));
});
}

View File

@@ -152,6 +152,11 @@ public interface PowerUsageFeatureProvider {
*/
Set<Integer> getOthersSystemComponentSet();
/**
* Returns {@link Set} for the custom system component names which are combined into others
*/
Set<String> getOthersCustomComponentNameSet();
/**
* Returns {@link Set} for hiding system component ids in the usage screen
*/

View File

@@ -172,6 +172,11 @@ public class PowerUsageFeatureProviderImpl implements PowerUsageFeatureProvider
return new ArraySet<>();
}
@Override
public Set<String> getOthersCustomComponentNameSet() {
return new ArraySet<>();
}
@Override
public Set<Integer> getHideSystemComponentSet() {
return new ArraySet<>();

View File

@@ -20,7 +20,6 @@ import android.animation.Animator;
import android.animation.AnimatorListenerAdapter;
import android.app.settings.SettingsEnums;
import android.content.Context;
import android.content.res.Configuration;
import android.os.Bundle;
import android.os.Handler;
import android.os.Looper;
@@ -68,8 +67,6 @@ public class BatteryChartPreferenceController extends AbstractPreferenceControll
private static final String KEY_DAILY_CHART_INDEX = "daily_chart_index";
private static final String KEY_HOURLY_CHART_INDEX = "hourly_chart_index";
private static int sUiMode = Configuration.UI_MODE_NIGHT_UNDEFINED;
/**
* A callback listener for battery usage is updated.
* This happens when battery usage data is ready or the selected index is changed.
@@ -167,14 +164,6 @@ public class BatteryChartPreferenceController extends AbstractPreferenceControll
@Override
public void onResume() {
final int currentUiMode =
mContext.getResources().getConfiguration().uiMode
& Configuration.UI_MODE_NIGHT_MASK;
if (sUiMode != currentUiMode) {
sUiMode = currentUiMode;
BatteryDiffEntry.clearCache();
Log.d(TAG, "clear icon and label cache since uiMode is changed");
}
mIs24HourFormat = DateFormat.is24HourFormat(mContext);
mMetricsFeatureProvider.action(mPrefContext, SettingsEnums.OPEN_BATTERY_USAGE);
}

View File

@@ -17,6 +17,7 @@
package com.android.settings.fuelgauge.batteryusage;
import android.content.Context;
import android.os.BatteryConsumer;
import androidx.annotation.NonNull;
@@ -151,11 +152,17 @@ public class BatteryDiffData {
final PowerUsageFeatureProvider featureProvider,
final List<BatteryDiffEntry> systemEntries) {
final Set<Integer> othersSystemComponentSet = featureProvider.getOthersSystemComponentSet();
final Set<String> othersCustomComponentNameSet =
featureProvider.getOthersCustomComponentNameSet();
BatteryDiffEntry.OthersBatteryDiffEntry othersDiffEntry = null;
final Iterator<BatteryDiffEntry> systemListIterator = systemEntries.iterator();
while (systemListIterator.hasNext()) {
final BatteryDiffEntry batteryDiffEntry = systemListIterator.next();
if (othersSystemComponentSet.contains(batteryDiffEntry.mBatteryHistEntry.mDrainType)) {
final int componentId = batteryDiffEntry.mBatteryHistEntry.mDrainType;
if (othersSystemComponentSet.contains(componentId) || (
componentId >= BatteryConsumer.FIRST_CUSTOM_POWER_COMPONENT_ID
&& othersCustomComponentNameSet.contains(
batteryDiffEntry.getAppLabel()))) {
if (othersDiffEntry == null) {
othersDiffEntry = new BatteryDiffEntry.OthersBatteryDiffEntry(context);
}

View File

@@ -18,6 +18,7 @@ package com.android.settings.fuelgauge.batteryusage;
import android.app.settings.SettingsEnums;
import android.content.Context;
import android.content.res.Configuration;
import android.graphics.drawable.Drawable;
import android.os.Handler;
import android.os.Looper;
@@ -43,6 +44,7 @@ import com.android.settingslib.core.instrumentation.MetricsFeatureProvider;
import com.android.settingslib.core.lifecycle.Lifecycle;
import com.android.settingslib.core.lifecycle.LifecycleObserver;
import com.android.settingslib.core.lifecycle.events.OnDestroy;
import com.android.settingslib.core.lifecycle.events.OnResume;
import com.android.settingslib.widget.FooterPreference;
import java.util.HashMap;
@@ -51,15 +53,15 @@ import java.util.Map;
/** Controller for battery usage breakdown preference group. */
public class BatteryUsageBreakdownController extends BasePreferenceController
implements LifecycleObserver, OnDestroy {
implements LifecycleObserver, OnResume, OnDestroy {
private static final String TAG = "BatteryUsageBreakdownController";
private static final String ROOT_PREFERENCE_KEY = "battery_usage_breakdown";
private static final String FOOTER_PREFERENCE_KEY = "battery_usage_footer";
private static final String SPINNER_PREFERENCE_KEY = "battery_usage_spinner";
private static final String APP_LIST_PREFERENCE_KEY = "app_list";
private static final String PACKAGE_NAME_NONE = "none";
private static final int ENABLED_ICON_ALPHA = 255;
private static final int DISABLED_ICON_ALPHA = 255 / 3;
private static int sUiMode = Configuration.UI_MODE_NIGHT_UNDEFINED;
private final SettingsActivity mActivity;
private final InstrumentedPreferenceFragment mFragment;
@@ -98,6 +100,19 @@ public class BatteryUsageBreakdownController extends BasePreferenceController
}
}
@Override
public void onResume() {
final int currentUiMode =
mContext.getResources().getConfiguration().uiMode
& Configuration.UI_MODE_NIGHT_MASK;
if (sUiMode != currentUiMode) {
sUiMode = currentUiMode;
BatteryDiffEntry.clearCache();
mPreferenceCache.clear();
Log.d(TAG, "clear icon and label cache since uiMode is changed");
}
}
@Override
public void onDestroy() {
mHandler.removeCallbacksAndMessages(/*token=*/ null);
@@ -268,12 +283,11 @@ public class BatteryUsageBreakdownController extends BasePreferenceController
pref.setSingleLineTitle(true);
// Sets the BatteryDiffEntry to preference for launching detailed page.
pref.setBatteryDiffEntry(entry);
pref.setEnabled(entry.validForRestriction());
pref.setSelectable(entry.validForRestriction());
setPreferenceSummary(pref, entry);
if (!isAdded) {
mAppListPreferenceGroup.addPreference(pref);
}
appIcon.setAlpha(pref.isEnabled() ? ENABLED_ICON_ALPHA : DISABLED_ICON_ALPHA);
prefIndex++;
}
Log.d(TAG, String.format("addAllPreferences() is finished in %d/ms",

View File

@@ -19,6 +19,8 @@ package com.android.settings.fuelgauge.batteryusage;
import android.content.Context;
import android.graphics.drawable.Drawable;
import android.util.AttributeSet;
import android.view.View;
import android.view.ViewGroup;
import android.widget.TextView;
import androidx.preference.PreferenceViewHolder;
@@ -37,6 +39,10 @@ import com.android.settingslib.widget.AppPreference;
public class PowerGaugePreference extends AppPreference {
private static final double PERCENTAGE_TO_SHOW_THRESHOLD = 1f;
// Please see go/battery-usage-app-list-alpha
private static final float SELECTABLE_ALPHA = 1f;
private static final float UNSELECTABLE_ALPHA_LIGHT_MODE = 0.65f;
private static final float UNSELECTABLE_ALPHA_DARK_MODE = 0.5f;
private BatteryEntry mInfo;
private BatteryDiffEntry mBatteryDiffEntry;
@@ -125,6 +131,11 @@ public class PowerGaugePreference extends AppPreference {
public void onBindViewHolder(PreferenceViewHolder view) {
super.onBindViewHolder(view);
final boolean isNightMode = Utils.isNightMode(getContext());
final float alpha = isSelectable() ? SELECTABLE_ALPHA
: (isNightMode ? UNSELECTABLE_ALPHA_DARK_MODE : UNSELECTABLE_ALPHA_LIGHT_MODE);
setViewAlpha(view.itemView, alpha);
final TextView subtitle = (TextView) view.findViewById(R.id.widget_summary);
subtitle.setText(mProgress);
if (mShowAnomalyIcon) {
@@ -138,4 +149,15 @@ public class PowerGaugePreference extends AppPreference {
titleView.setContentDescription(mContentDescription);
}
}
private static void setViewAlpha(View view, float alpha) {
if (view instanceof ViewGroup) {
final ViewGroup viewGroup = (ViewGroup) view;
for (int i = viewGroup.getChildCount() - 1; i >= 0; i--) {
setViewAlpha(viewGroup.getChildAt(i), alpha);
}
} else {
view.setAlpha(alpha);
}
}
}

View File

@@ -54,6 +54,7 @@ public class ModifierKeysPickerDialogFragment extends DialogFragment {
private Preference mPreference;
private String mKeyDefaultName;
private String mKeyFocus;
private Context mContext;
private InputManager mIm;
@@ -72,6 +73,7 @@ public class ModifierKeysPickerDialogFragment extends DialogFragment {
public ModifierKeysPickerDialogFragment(Preference preference, InputManager inputManager) {
mPreference = preference;
mKeyDefaultName = preference.getTitle().toString();
mKeyFocus = preference.getSummary().toString();
mIm = inputManager;
}
@@ -101,11 +103,11 @@ public class ModifierKeysPickerDialogFragment extends DialogFragment {
ModifierKeyAdapter adapter = new ModifierKeyAdapter(modifierKeys);
ListView listView = dialoglayout.findViewById(R.id.modifier_key_picker);
listView.setAdapter(adapter);
setInitialFocusItem(modifierKeys, adapter);
listView.setOnItemClickListener(new AdapterView.OnItemClickListener() {
@Override
public void onItemClick(AdapterView<?> adapterView, View view, int i, long l) {
adapter.setCurrentItem(i);
adapter.setClick(true);
adapter.notifyDataSetChanged();
}
});
@@ -165,13 +167,22 @@ public class ModifierKeysPickerDialogFragment extends DialogFragment {
return modifierKeyDialog;
}
private void setInitialFocusItem(
List<String> modifierKeys, ModifierKeyAdapter adapter) {
if (modifierKeys.indexOf(mKeyFocus) == -1) {
adapter.setCurrentItem(modifierKeys.indexOf(mKeyDefaultName));
} else {
adapter.setCurrentItem(modifierKeys.indexOf(mKeyFocus));
}
adapter.notifyDataSetChanged();
}
private static boolean isKeyCapsLock(Context context, String key) {
return key.equals(context.getString(R.string.modifier_keys_caps_lock));
}
class ModifierKeyAdapter extends BaseAdapter {
private int mCurrentItem = 0;
private boolean mIsClick = false;
private List<String> mList;
ModifierKeyAdapter(List<String> list) {
@@ -201,12 +212,15 @@ public class ModifierKeysPickerDialogFragment extends DialogFragment {
TextView textView = view.findViewById(R.id.modifier_key_text);
ImageView checkIcon = view.findViewById(R.id.modifier_key_check_icon);
textView.setText(mList.get(i));
if (mCurrentItem == i && mIsClick) {
if (mCurrentItem == i) {
textView.setTextColor(getColorOfColorAccentPrimaryVariant());
checkIcon.setImageAlpha(255);
view.setBackground(
mContext.getDrawable(R.drawable.modifier_key_lisetview_background));
} else {
textView.setTextColor(getColorOfTextColorPrimary());
checkIcon.setImageAlpha(0);
view.setBackground(null);
}
return view;
}
@@ -218,10 +232,6 @@ public class ModifierKeysPickerDialogFragment extends DialogFragment {
public int getCurrentItem() {
return this.mCurrentItem;
}
public void setClick(boolean click) {
this.mIsClick = click;
}
}
private int getColorOfTextColorPrimary() {

View File

@@ -22,6 +22,7 @@ import static androidx.lifecycle.Lifecycle.Event.ON_STOP;
import android.content.Context;
import android.os.PersistableBundle;
import android.telephony.CarrierConfigManager;
import android.telephony.SubscriptionInfo;
import android.telephony.SubscriptionManager;
import android.telephony.TelephonyCallback;
import android.telephony.TelephonyManager;
@@ -244,6 +245,24 @@ public class EnabledNetworkModePreferenceController extends
// TODO: Using the carrier config.
mDisplay3gOptions = getResourcesForSubId().getBoolean(
R.bool.config_display_network_mode_3g_option);
int[] carriersWithout3gMenu = getResourcesForSubId().getIntArray(
R.array.network_mode_3g_deprecated_carrier_id);
if ((carriersWithout3gMenu != null) && (carriersWithout3gMenu.length > 0)) {
SubscriptionManager sm = mContext.getSystemService(SubscriptionManager.class);
SubscriptionInfo subInfo = sm.getActiveSubscriptionInfo(mSubId);
if (subInfo != null) {
int carrierId = subInfo.getCarrierId();
for (int idx = 0; idx < carriersWithout3gMenu.length; idx++) {
if (carrierId == carriersWithout3gMenu[idx]) {
mDisplay3gOptions = false;
break;
}
}
}
}
mLteEnabled = carrierConfig.getBoolean(CarrierConfigManager.KEY_LTE_ENABLED_BOOL);
}
Log.d(LOG_TAG, "PreferenceEntriesBuilder: subId" + mSubId

View File

@@ -831,7 +831,7 @@ public class ChooseLockPassword extends SettingsActivity {
mIsAlphaMode
? R.string.lockpassword_password_too_short
: R.string.lockpassword_pin_too_short);
if (mLockPatternUtils.isAutoPinConfirmFeatureAvailable()
if (LockPatternUtils.isAutoPinConfirmFeatureAvailable()
&& !mIsAlphaMode
&& error.requirement < MIN_AUTO_PIN_REQUIREMENT_LENGTH) {
Map<String, Object> arguments = new HashMap<>();
@@ -929,7 +929,7 @@ public class ChooseLockPassword extends SettingsActivity {
}
private void setAutoPinConfirmOption(boolean enabled, int length) {
if (!mLockPatternUtils.isAutoPinConfirmFeatureAvailable()
if (!LockPatternUtils.isAutoPinConfirmFeatureAvailable()
|| mAutoPinConfirmOption == null) {
return;
}

View File

@@ -57,7 +57,7 @@ public class AutoPinConfirmPreferenceController extends AbstractPreferenceContro
@Override
public boolean isAvailable() {
return mLockPatternUtils.isAutoPinConfirmFeatureAvailable() && isPinLock()
return LockPatternUtils.isAutoPinConfirmFeatureAvailable() && isPinLock()
&& isPinLengthEligibleForAutoConfirmation();
}

View File

@@ -157,7 +157,7 @@ public final class BatteryUsageBreakdownControllerTest {
assertThat(pref.getOrder()).isEqualTo(1);
assertThat(pref.getBatteryDiffEntry()).isSameInstanceAs(mBatteryDiffEntry);
assertThat(pref.isSingleLineTitle()).isTrue();
assertThat(pref.isEnabled()).isFalse();
assertThat(pref.isSelectable()).isFalse();
}
@Test

View File

@@ -16,17 +16,23 @@
package com.android.settings.security.screenlock;
import static android.provider.DeviceConfig.NAMESPACE_AUTO_PIN_CONFIRMATION;
import static com.android.internal.widget.LockPatternUtils.FLAG_ENABLE_AUTO_PIN_CONFIRMATION;
import static com.google.common.truth.Truth.assertThat;
import static org.mockito.Mockito.verify;
import static org.mockito.Mockito.when;
import android.content.Context;
import android.provider.DeviceConfig;
import androidx.preference.SwitchPreference;
import androidx.test.core.app.ApplicationProvider;
import com.android.internal.widget.LockPatternUtils;
import com.android.settings.testutils.shadow.ShadowDeviceConfig;
import org.junit.Before;
import org.junit.Test;
@@ -34,8 +40,10 @@ import org.junit.runner.RunWith;
import org.mockito.Mock;
import org.mockito.MockitoAnnotations;
import org.robolectric.RobolectricTestRunner;
import org.robolectric.annotation.Config;
@RunWith(RobolectricTestRunner.class)
@Config(shadows = {ShadowDeviceConfig.class})
public class AutoPinConfirmPreferenceControllerTest {
private static final Integer TEST_USER_ID = 1;
@Mock
@@ -54,16 +62,18 @@ public class AutoPinConfirmPreferenceControllerTest {
@Test
public void isAvailable_featureEnabledAndLockSetToNone_shouldReturnFalse() {
DeviceConfig.setProperty(NAMESPACE_AUTO_PIN_CONFIRMATION, FLAG_ENABLE_AUTO_PIN_CONFIRMATION,
"true", /* makeDefault */ false);
when(mLockPatternUtils.isSecure(TEST_USER_ID)).thenReturn(true);
when(mLockPatternUtils.isAutoPinConfirmFeatureAvailable()).thenReturn(true);
assertThat(mController.isAvailable()).isFalse();
}
@Test
public void isAvailable_featureEnabledAndLockSetToPassword_shouldReturnFalse() {
DeviceConfig.setProperty(NAMESPACE_AUTO_PIN_CONFIRMATION, FLAG_ENABLE_AUTO_PIN_CONFIRMATION,
"true", /* makeDefault */ false);
when(mLockPatternUtils.isSecure(TEST_USER_ID)).thenReturn(true);
when(mLockPatternUtils.isAutoPinConfirmFeatureAvailable()).thenReturn(true);
when(mLockPatternUtils.getCredentialTypeForUser(TEST_USER_ID))
.thenReturn(LockPatternUtils.CREDENTIAL_TYPE_PASSWORD);
@@ -72,7 +82,8 @@ public class AutoPinConfirmPreferenceControllerTest {
@Test
public void isAvailable_featureEnabledAndLockSetToPIN_lengthLessThanSix_shouldReturnFalse() {
when(mLockPatternUtils.isAutoPinConfirmFeatureAvailable()).thenReturn(true);
DeviceConfig.setProperty(NAMESPACE_AUTO_PIN_CONFIRMATION, FLAG_ENABLE_AUTO_PIN_CONFIRMATION,
"true", /* makeDefault */ false);
when(mLockPatternUtils.getCredentialTypeForUser(TEST_USER_ID))
.thenReturn(LockPatternUtils.CREDENTIAL_TYPE_PIN);
when(mLockPatternUtils.getPinLength(TEST_USER_ID)).thenReturn(5L);
@@ -82,8 +93,9 @@ public class AutoPinConfirmPreferenceControllerTest {
@Test
public void isAvailable_featureEnabledAndLockSetToPIN_lengthMoreThanEqSix_shouldReturnTrue() {
DeviceConfig.setProperty(NAMESPACE_AUTO_PIN_CONFIRMATION, FLAG_ENABLE_AUTO_PIN_CONFIRMATION,
"true", /* makeDefault */ false);
when(mLockPatternUtils.isSecure(TEST_USER_ID)).thenReturn(true);
when(mLockPatternUtils.isAutoPinConfirmFeatureAvailable()).thenReturn(true);
when(mLockPatternUtils.getCredentialTypeForUser(TEST_USER_ID))
.thenReturn(LockPatternUtils.CREDENTIAL_TYPE_PIN);
when(mLockPatternUtils.getPinLength(TEST_USER_ID)).thenReturn(6L);
@@ -93,7 +105,8 @@ public class AutoPinConfirmPreferenceControllerTest {
@Test
public void isAvailable_featureDisabledAndLockSetToPIN_shouldReturnFalse() {
when(mLockPatternUtils.isAutoPinConfirmFeatureAvailable()).thenReturn(false);
DeviceConfig.setProperty(NAMESPACE_AUTO_PIN_CONFIRMATION, FLAG_ENABLE_AUTO_PIN_CONFIRMATION,
"false", /* makeDefault */ false);
when(mLockPatternUtils.isSecure(TEST_USER_ID)).thenReturn(true);
when(mLockPatternUtils.getCredentialTypeForUser(TEST_USER_ID))
.thenReturn(LockPatternUtils.CREDENTIAL_TYPE_PIN);
@@ -103,7 +116,8 @@ public class AutoPinConfirmPreferenceControllerTest {
@Test
public void updateState_ChangingSettingState_shouldSetPreferenceToAppropriateCheckedState() {
when(mLockPatternUtils.isAutoPinConfirmFeatureAvailable()).thenReturn(true);
DeviceConfig.setProperty(NAMESPACE_AUTO_PIN_CONFIRMATION, FLAG_ENABLE_AUTO_PIN_CONFIRMATION,
"true", /* makeDefault */ false);
// When auto_pin_confirm setting is disabled, switchPreference is unchecked
when(mLockPatternUtils.isAutoPinConfirmEnabled(TEST_USER_ID)).thenReturn(false);
mController.updateState(mPreference);
@@ -117,7 +131,8 @@ public class AutoPinConfirmPreferenceControllerTest {
@Test
public void onPreferenceChange_shouldUpdatePinAutoConfirmSetting() {
when(mLockPatternUtils.isAutoPinConfirmFeatureAvailable()).thenReturn(true);
DeviceConfig.setProperty(NAMESPACE_AUTO_PIN_CONFIRMATION, FLAG_ENABLE_AUTO_PIN_CONFIRMATION,
"true", /* makeDefault */ false);
mController.onPreferenceChange(mPreference, /* newValue= */ true);
verify(mLockPatternUtils).setAutoPinConfirm(true, TEST_USER_ID);
}