Snap for 8273439 from 2adf0a066f to tm-release

Change-Id: I9d94df5fc92097a49f3088e827d0ac16bf35deca
This commit is contained in:
Android Build Coastguard Worker
2022-03-09 02:08:37 +00:00
31 changed files with 150 additions and 64 deletions

View File

@@ -0,0 +1,36 @@
<!--
Copyright 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/accessibility_icon_size"
android:height="@dimen/accessibility_icon_size"
android:color="@color/accessibility_feature_background"/>
</item>
<item android:gravity="center">
<vector
android:width="@dimen/accessibility_icon_foreground_size"
android:height="@dimen/accessibility_icon_foreground_size"
android:viewportWidth="24"
android:viewportHeight="24">
<path
android:fillColor="#ffffff"
android:fillType="evenOdd"
android:pathData="M9,22Q7.55,22 6.275,21.45Q5,20.9 4.05,19.95Q3.1,19 2.55,17.725Q2,16.45 2,15Q2,12.975 3.05,11.3Q4.1,9.625 5.8,8.75Q6.3,7.775 7.038,7.037Q7.775,6.3 8.75,5.8Q9.575,4.1 11.275,3.05Q12.975,2 15,2Q16.45,2 17.725,2.55Q19,3.1 19.95,4.05Q20.9,5 21.45,6.275Q22,7.55 22,9Q22,11.125 20.95,12.75Q19.9,14.375 18.2,15.25Q17.7,16.225 16.962,16.962Q16.225,17.7 15.25,18.2Q14.375,19.9 12.7,20.95Q11.025,22 9,22ZM9,20Q9.825,20 10.588,19.75Q11.35,19.5 12,19Q10.55,19 9.275,18.45Q8,17.9 7.05,16.95Q6.1,16 5.55,14.725Q5,13.45 5,12Q4.5,12.65 4.25,13.412Q4,14.175 4,15Q4,16.05 4.4,16.95Q4.8,17.85 5.475,18.525Q6.15,19.2 7.05,19.6Q7.95,20 9,20ZM12,17Q12.825,17 13.613,16.75Q14.4,16.5 15.05,16Q13.575,16 12.3,15.438Q11.025,14.875 10.075,13.925Q9.125,12.975 8.562,11.7Q8,10.425 8,8.95Q7.5,9.6 7.25,10.387Q7,11.175 7,12Q7,13.05 7.388,13.95Q7.775,14.85 8.475,15.525Q9.15,16.225 10.05,16.613Q10.95,17 12,17ZM15,14Q15.45,14 15.863,13.925Q16.275,13.85 16.7,13.7Q17.25,12.2 16.863,10.812Q16.475,9.425 15.525,8.475Q14.575,7.525 13.188,7.137Q11.8,6.75 10.3,7.3Q10.15,7.725 10.075,8.137Q10,8.55 10,9Q10,10.05 10.387,10.95Q10.775,11.85 11.475,12.525Q12.15,13.225 13.05,13.613Q13.95,14 15,14ZM19,12.05Q19.5,11.4 19.75,10.612Q20,9.825 20,9Q20,7.95 19.613,7.05Q19.225,6.15 18.525,5.475Q17.85,4.775 16.95,4.387Q16.05,4 15,4Q14.125,4 13.363,4.25Q12.6,4.5 11.95,5Q13.425,5 14.7,5.562Q15.975,6.125 16.925,7.075Q17.875,8.025 18.438,9.3Q19,10.575 19,12.05Z" />
</vector>
</item>
</layer-list>

View File

@@ -61,10 +61,10 @@
style="@style/SudGlifIcon"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_gravity="?attr/sudGlifHeaderGravity"
android:scaleType="fitStart"
android:layout_marginStart="0dp"
android:layout_marginEnd="0dp"
android:src="@drawable/ic_fingerprint_header" />
android:src="@drawable/ic_lock" />
<TextView
android:id="@+id/suc_layout_title"

View File

@@ -205,4 +205,7 @@
<!-- Battery error text color -->
<color name="battery_info_error_color_black">@*android:color/primary_text_default_material_light</color>
<!-- Background for multiple user settings page avatars -->
<color name="user_avatar_color_bg">?androidprv:attr/colorSurface</color>
</resources>

View File

@@ -134,6 +134,7 @@
<dimen name="avatar_length">48dp</dimen>
<dimen name="avatar_margin_top">56dp</dimen>
<dimen name="avatar_margin_end">24dp</dimen>
<dimen name="multiple_users_avatar_size">20dp</dimen>
<!-- Homepage title -->
<dimen name="homepage_title_margin_bottom">8dp</dimen>

View File

@@ -10619,7 +10619,7 @@
<!-- Body text of prompt dialog app can invoke to turn off optimization [CHAR LIMIT=NONE] -->
<string name="high_power_prompt_body">
Allowing <xliff:g id="app_name" example="Settings">%1$s</xliff:g> to always run in the background may reduce battery life.
\n\nYou can change this later from Settings > Apps &amp; notifications.</string>
\n\nYou can change this later from Settings > Apps.</string>
<!-- Summary of power usage for an app [CHAR LIMIT=NONE] -->
<string name="battery_summary"><xliff:g id="percentage" example="2">%1$s</xliff:g> use since last full charge</string>
<!-- Summary of power usage for an app within past 24 hr[CHAR LIMIT=NONE] -->
@@ -13625,7 +13625,7 @@
<!-- Title for default print service main switch. [CHAR LIMIT=50] -->
<string name="default_print_service_main_switch_title">Use print service</string>
<!-- Title for multiple users main switch. [CHAR LIMIT=50] -->
<string name="multiple_users_main_switch_title">Use multiple users</string>
<string name="multiple_users_main_switch_title">Enable multiple users</string>
<!-- Title for wireless debugging main switch. [CHAR LIMIT=50] -->
<string name="wireless_debugging_main_switch_title">Use wireless debugging</string>
<!-- Title for graphics driver main switch. [CHAR LIMIT=50] -->

View File

@@ -50,6 +50,7 @@
settings:searchable="false"/>
<SwitchPreference
android:icon="@drawable/ic_accessibility_animation"
android:key="toggle_disable_animations"
android:persistent="false"
android:summary="@string/accessibility_disable_animations_summary"

View File

@@ -47,4 +47,12 @@
android:persistent="true"
android:summary="@string/talkback_summary"/>
<SwitchPreference
android:icon="@drawable/ic_accessibility_animation"
android:key="toggle_disable_animations"
android:persistent="false"
android:summary="@string/accessibility_disable_animations_summary"
android:title="@string/accessibility_disable_animations"
settings:controller="com.android.settings.accessibility.DisableAnimationsPreferenceController"/>
</PreferenceScreen>

View File

@@ -23,6 +23,7 @@
<com.android.settingslib.widget.MainSwitchPreference
android:order="-100"
android:key="battery_saver"
android:title="@string/battery_saver_master_switch_title"
settings:controller="com.android.settings.fuelgauge.batterysaver.BatterySaverButtonPreferenceController"/>
<Preference

View File

@@ -297,7 +297,7 @@
android:title="@string/tethering_hardware_offload"
android:summary="@string/tethering_hardware_offload_summary" />
<com.android.settingslib.RestrictedSwitchPreference
<com.android.settingslib.RestrictedPreference
android:key="default_usb_configuration"
android:fragment="com.android.settings.connecteddevice.usb.UsbDefaultFragment"
android:title="@string/usb_default_label"/>

View File

@@ -46,7 +46,7 @@
android:key="gesture_one_handed_action_pull_screen_down"
android:title="@string/one_handed_action_pull_down_screen_title"
android:summary="@string/one_handed_action_pull_down_screen_summary"
settings:controller="com.android.settings.gesture_one_handed_mode_footer_textgestures.OneHandedActionPullDownPrefController"/>
settings:controller="com.android.settings.gestures.OneHandedActionPullDownPrefController"/>
<com.android.settingslib.widget.SelectorWithWidgetPreference
android:key="gesture_one_handed_action_show_notification"

View File

@@ -40,13 +40,11 @@
<com.android.settingslib.RestrictedPreference
android:key="user_add"
android:title="@string/user_add_user_or_profile_menu"
android:icon="@drawable/ic_add_40dp"
android:order="20"/>
<com.android.settingslib.RestrictedPreference
android:key="supervised_user_add"
android:title="@*android:string/supervised_user_creation_label"
android:icon="@*android:drawable/ic_add_supervised_user"
android:order="25"/>
<com.android.settingslib.RestrictedSwitchPreference

View File

@@ -37,7 +37,11 @@ import com.android.settingslib.transition.SettingsTransitionHelper;
*/
public class BiometricNavigationUtils {
private final int mUserId = UserHandle.myUserId();
private final int mUserId;
public BiometricNavigationUtils(int userId) {
mUserId = userId;
}
/**
* Tries to launch the Settings screen if Quiet Mode is not enabled

View File

@@ -60,7 +60,7 @@ public abstract class BiometricStatusPreferenceController extends BasePreference
.getSecurityFeatureProvider()
.getLockPatternUtils(context);
mProfileChallengeUserId = Utils.getManagedProfileId(mUm, mUserId);
mBiometricNavigationUtils = new BiometricNavigationUtils();
mBiometricNavigationUtils = new BiometricNavigationUtils(getUserId());
}
@Override

View File

@@ -56,7 +56,7 @@ public class CombinedBiometricStatusPreferenceController extends
public CombinedBiometricStatusPreferenceController(
Context context, String key, Lifecycle lifecycle) {
super(context, key);
mCombinedBiometricStatusUtils = new CombinedBiometricStatusUtils(context);
mCombinedBiometricStatusUtils = new CombinedBiometricStatusUtils(context, getUserId());
if (lifecycle != null) {
lifecycle.addObserver(this);

View File

@@ -20,7 +20,6 @@ import android.content.Context;
import android.hardware.biometrics.BiometricAuthenticator;
import android.hardware.face.FaceManager;
import android.hardware.fingerprint.FingerprintManager;
import android.os.UserHandle;
import androidx.annotation.Nullable;
@@ -35,17 +34,18 @@ import com.android.settingslib.RestrictedLockUtils.EnforcedAdmin;
*/
public class CombinedBiometricStatusUtils {
private final int mUserId = UserHandle.myUserId();
private final int mUserId;
private final Context mContext;
@Nullable
FingerprintManager mFingerprintManager;
@Nullable
FaceManager mFaceManager;
public CombinedBiometricStatusUtils(Context context) {
public CombinedBiometricStatusUtils(Context context, int userId) {
mContext = context;
mFingerprintManager = Utils.getFingerprintManagerOrNull(context);
mFaceManager = Utils.getFaceManagerOrNull(context);
mUserId = userId;
}
/**

View File

@@ -57,7 +57,7 @@ public class FaceStatusPreferenceController extends BiometricStatusPreferenceCon
public FaceStatusPreferenceController(Context context, String key, Lifecycle lifecycle) {
super(context, key);
mFaceManager = Utils.getFaceManagerOrNull(context);
mFaceStatusUtils = new FaceStatusUtils(context, mFaceManager);
mFaceStatusUtils = new FaceStatusUtils(context, mFaceManager, getUserId());
if (lifecycle != null) {
lifecycle.addObserver(this);

View File

@@ -19,7 +19,6 @@ package com.android.settings.biometrics.face;
import android.content.Context;
import android.hardware.biometrics.BiometricAuthenticator;
import android.hardware.face.FaceManager;
import android.os.UserHandle;
import com.android.settings.R;
import com.android.settings.Settings;
@@ -32,13 +31,14 @@ import com.android.settingslib.RestrictedLockUtils.EnforcedAdmin;
*/
public class FaceStatusUtils {
private final int mUserId = UserHandle.myUserId();
private final int mUserId;
private final Context mContext;
private final FaceManager mFaceManager;
public FaceStatusUtils(Context context, FaceManager faceManager) {
public FaceStatusUtils(Context context, FaceManager faceManager, int userId) {
mContext = context;
mFaceManager = faceManager;
mUserId = userId;
}
/**

View File

@@ -58,7 +58,7 @@ public class FingerprintStatusPreferenceController extends BiometricStatusPrefer
super(context, key);
mFingerprintManager = Utils.getFingerprintManagerOrNull(context);
mFingerprintStatusUtils =
new FingerprintStatusUtils(context, mFingerprintManager);
new FingerprintStatusUtils(context, mFingerprintManager, getUserId());
if (lifecycle != null) {
lifecycle.addObserver(this);

View File

@@ -19,7 +19,6 @@ package com.android.settings.biometrics.fingerprint;
import android.content.Context;
import android.hardware.biometrics.BiometricAuthenticator;
import android.hardware.fingerprint.FingerprintManager;
import android.os.UserHandle;
import com.android.settings.R;
import com.android.settings.Utils;
@@ -31,13 +30,15 @@ import com.android.settingslib.RestrictedLockUtils.EnforcedAdmin;
*/
public class FingerprintStatusUtils {
private final int mUserId = UserHandle.myUserId();
private final int mUserId;
private final Context mContext;
private final FingerprintManager mFingerprintManager;
public FingerprintStatusUtils(Context context, FingerprintManager fingerprintManager) {
public FingerprintStatusUtils(Context context, FingerprintManager fingerprintManager,
int userId) {
mContext = context;
mFingerprintManager = fingerprintManager;
mUserId = userId;
}
/**

View File

@@ -25,7 +25,7 @@ import androidx.preference.Preference;
import androidx.preference.PreferenceScreen;
import com.android.settings.core.PreferenceControllerMixin;
import com.android.settingslib.RestrictedSwitchPreference;
import com.android.settingslib.RestrictedPreference;
import com.android.settingslib.development.DeveloperOptionsPreferenceController;
public class DefaultUsbConfigurationPreferenceController extends
@@ -33,7 +33,7 @@ public class DefaultUsbConfigurationPreferenceController extends
private static final String PREFERENCE_KEY = "default_usb_configuration";
private RestrictedSwitchPreference mPreference;
private RestrictedPreference mPreference;
public DefaultUsbConfigurationPreferenceController(Context context) {
super(context);

View File

@@ -95,7 +95,6 @@ public class BatterySaverButtonPreferenceController extends
public void displayPreference(PreferenceScreen screen) {
super.displayPreference(screen);
mPreference = screen.findPreference(getPreferenceKey());
mPreference.setTitle(mContext.getString(R.string.battery_saver_master_switch_title));
mPreference.addOnSwitchChangeListener(this);
mPreference.updateStatus(isChecked());
}
@@ -113,7 +112,6 @@ public class BatterySaverButtonPreferenceController extends
@Override
public boolean setChecked(boolean stateOn) {
// This screen already shows a warning, so we don't need another warning.
mPreference.updateStatus(isChecked());
return BatterySaverUtils.setPowerSaveMode(mContext, stateOn,
false /* needFirstTimeWarning */);
}

View File

@@ -22,6 +22,7 @@ import android.content.Intent;
import android.hardware.face.FaceManager;
import android.hardware.fingerprint.FingerprintManager;
import android.os.Bundle;
import android.os.UserHandle;
import android.safetycenter.SafetyEvent;
import android.safetycenter.SafetySourceData;
import android.safetycenter.SafetySourceStatus;
@@ -47,9 +48,12 @@ public final class BiometricsSafetySource {
return;
}
final BiometricNavigationUtils biometricNavigationUtils = new BiometricNavigationUtils();
final int userId = UserHandle.myUserId();
final BiometricNavigationUtils biometricNavigationUtils = new BiometricNavigationUtils(
userId);
final CombinedBiometricStatusUtils combinedBiometricStatusUtils =
new CombinedBiometricStatusUtils(context);
new CombinedBiometricStatusUtils(context, userId);
if (combinedBiometricStatusUtils.isAvailable()) {
final RestrictedLockUtils.EnforcedAdmin disablingAdmin =
@@ -66,7 +70,7 @@ public final class BiometricsSafetySource {
}
final FaceManager faceManager = Utils.getFaceManagerOrNull(context);
final FaceStatusUtils faceStatusUtils = new FaceStatusUtils(context, faceManager);
final FaceStatusUtils faceStatusUtils = new FaceStatusUtils(context, faceManager, userId);
if (faceStatusUtils.isAvailable()) {
final RestrictedLockUtils.EnforcedAdmin disablingAdmin =
@@ -85,7 +89,7 @@ public final class BiometricsSafetySource {
final FingerprintManager fingerprintManager = Utils.getFingerprintManagerOrNull(context);
final FingerprintStatusUtils fingerprintStatusUtils = new FingerprintStatusUtils(context,
fingerprintManager);
fingerprintManager, userId);
if (fingerprintStatusUtils.isAvailable()) {
final RestrictedLockUtils.EnforcedAdmin disablingAdmin =

View File

@@ -96,6 +96,10 @@ public final class LockScreenSafetySource {
context,
new ScreenLockPreferenceDetailsUtils(context, SettingsEnums.SAFETY_CENTER),
new SafetyEvent.Builder(SAFETY_EVENT_TYPE_SOURCE_STATE_CHANGED).build());
// Also send refreshed safety center data for biometrics, since changing lockscreen settings
// can unset biometrics.
BiometricsSafetySource.onBiometricsChanged(context);
}
private static IconAction createGearMenuIconAction(Context context,
@@ -126,7 +130,7 @@ public final class LockScreenSafetySource {
NO_SCREEN_LOCK_ISSUE_ID,
context.getString(R.string.no_screen_lock_issue_title),
context.getString(R.string.no_screen_lock_issue_summary),
SafetySourceStatus.STATUS_LEVEL_RECOMMENDATION,
SafetySourceIssue.SEVERITY_LEVEL_RECOMMENDATION,
NO_SCREEN_LOCK_ISSUE_TYPE_ID)
.setIssueCategory(SafetySourceIssue.ISSUE_CATEGORY_DEVICE)
.addAction(action).build();

View File

@@ -16,6 +16,8 @@
package com.android.settings.users;
import static com.android.settingslib.Utils.getColorAttrDefaultColor;
import android.app.Activity;
import android.app.ActivityManager;
import android.app.Dialog;
@@ -31,7 +33,9 @@ import android.content.pm.UserInfo;
import android.content.res.Resources;
import android.graphics.Bitmap;
import android.graphics.BitmapFactory;
import android.graphics.BlendMode;
import android.graphics.drawable.Drawable;
import android.graphics.drawable.LayerDrawable;
import android.net.Uri;
import android.os.AsyncTask;
import android.os.Bundle;
@@ -46,6 +50,7 @@ import android.provider.ContactsContract;
import android.text.TextUtils;
import android.util.Log;
import android.util.SparseArray;
import android.view.Gravity;
import android.view.Menu;
import android.view.MenuInflater;
import android.view.MenuItem;
@@ -1123,7 +1128,8 @@ public class UserSettings extends SettingsPreferenceFragment
&& WizardManagerHelper.isDeviceProvisioned(context)
&& mUserCaps.mUserSwitcherEnabled) {
mAddGuest.setVisible(true);
mAddGuest.setIcon(getEncircledDefaultIcon());
Drawable icon = context.getDrawable(R.drawable.ic_account_circle);
mAddGuest.setIcon(centerAndTint(icon));
mAddGuest.setSelectable(true);
if (mGuestUserAutoCreated && mGuestCreationScheduled.get()) {
mAddGuest.setTitle(com.android.settingslib.R.string.user_guest);
@@ -1140,11 +1146,15 @@ public class UserSettings extends SettingsPreferenceFragment
private void updateAddUser(Context context) {
updateAddUserCommon(context, mAddUser, mUserCaps.mCanAddRestrictedProfile);
Drawable icon = context.getDrawable(R.drawable.ic_account_circle_filled);
mAddUser.setIcon(centerAndTint(icon));
}
private void updateAddSupervisedUser(Context context) {
if (!TextUtils.isEmpty(mConfigSupervisedUserCreationPackage)) {
updateAddUserCommon(context, mAddSupervisedUser, false);
Drawable icon = context.getDrawable(R.drawable.ic_add_supervised_user);
mAddSupervisedUser.setIcon(centerAndTint(icon));
} else {
mAddSupervisedUser.setVisible(false);
}
@@ -1162,6 +1172,7 @@ public class UserSettings extends SettingsPreferenceFragment
|| (canAddRestrictedProfile
&& mUserManager.canAddMoreUsers(UserManager.USER_TYPE_FULL_RESTRICTED));
addUser.setEnabled(canAddMoreUsers && !mAddingUser && canSwitchUserNow());
if (!canAddMoreUsers) {
addUser.setSummary(
getString(R.string.user_add_max_count, getRealUsersCount()));
@@ -1177,6 +1188,20 @@ public class UserSettings extends SettingsPreferenceFragment
}
}
private Drawable centerAndTint(Drawable icon) {
icon.setTintBlendMode(BlendMode.SRC_IN);
icon.setTint(getColorAttrDefaultColor(getContext(), android.R.attr.textColorPrimary));
Drawable bg = getContext().getDrawable(R.drawable.user_avatar_bg).mutate();
LayerDrawable ld = new LayerDrawable(new Drawable[] {bg, icon});
int size = getContext().getResources().getDimensionPixelSize(
R.dimen.multiple_users_avatar_size);
ld.setLayerSize(1, size, size);
ld.setLayerGravity(1, Gravity.CENTER);
return ld;
}
/**
* @return number of non-guest non-managed users
*/

View File

@@ -32,7 +32,7 @@ import android.os.UserHandle;
import androidx.preference.PreferenceScreen;
import com.android.settingslib.RestrictedLockUtils;
import com.android.settingslib.RestrictedSwitchPreference;
import com.android.settingslib.RestrictedPreference;
import org.junit.Before;
import org.junit.Test;
@@ -48,7 +48,7 @@ public class DefaultUsbConfigurationPreferenceControllerTest {
private static final ComponentName TEST_COMPONENT_NAME = new ComponentName("test", "test");
@Mock
private RestrictedSwitchPreference mPreference;
private RestrictedPreference mPreference;
@Mock
private PreferenceScreen mPreferenceScreen;
@Mock

View File

@@ -75,7 +75,7 @@ public class BatterySaverButtonPreferenceControllerTest {
public void updateState_lowPowerOn_preferenceIsChecked() {
when(mPowerManager.isPowerSaveMode()).thenReturn(true);
mController.onSwitchChanged(null, mPowerManager.isPowerSaveMode());
mPreference.updateStatus(mPowerManager.isPowerSaveMode());
assertThat(mPreference.isChecked()).isTrue();
}
@@ -84,7 +84,7 @@ public class BatterySaverButtonPreferenceControllerTest {
public void testUpdateState_lowPowerOff_preferenceIsUnchecked() {
when(mPowerManager.isPowerSaveMode()).thenReturn(false);
mController.onSwitchChanged(null, mPowerManager.isPowerSaveMode());
mPreference.updateStatus(mPowerManager.isPowerSaveMode());
assertThat(mPreference.isChecked()).isFalse();
}

View File

@@ -64,7 +64,7 @@ public class BiometricNavigationUtilsTest {
mContext = spy(ApplicationProvider.getApplicationContext());
when(mContext.getSystemService(UserManager.class)).thenReturn(mUserManager);
doNothing().when(mContext).startActivity(any());
mBiometricNavigationUtils = new BiometricNavigationUtils();
mBiometricNavigationUtils = new BiometricNavigationUtils(UserHandle.myUserId());
}
@Test

View File

@@ -56,7 +56,8 @@ public class CombinedBiometricStatusUtilsTest {
private static final ComponentName COMPONENT_NAME =
new ComponentName("package", "class");
private static final UserHandle USER_HANDLE = new UserHandle(UserHandle.myUserId());
private static final int USER_ID = UserHandle.myUserId();
private static final UserHandle USER_HANDLE = new UserHandle(USER_ID);;
@Mock
@@ -85,7 +86,8 @@ public class CombinedBiometricStatusUtilsTest {
when(mApplicationContext.getSystemService(Context.DEVICE_POLICY_SERVICE))
.thenReturn(mDevicePolicyManager);
when(mApplicationContext.getSystemService(Context.FACE_SERVICE)).thenReturn(mFaceManager);
mCombinedBiometricStatusUtils = new CombinedBiometricStatusUtils(mApplicationContext);
mCombinedBiometricStatusUtils = new CombinedBiometricStatusUtils(
mApplicationContext, USER_ID);
}
@Test

View File

@@ -49,7 +49,8 @@ public class FaceStatusUtilsTest {
private static final ComponentName COMPONENT_NAME =
new ComponentName("package", "class");
private static final UserHandle USER_HANDLE = new UserHandle(UserHandle.myUserId());
private static final int USER_ID = UserHandle.myUserId();
private static final UserHandle USER_HANDLE = new UserHandle(USER_ID);
@Mock
@@ -78,7 +79,7 @@ public class FaceStatusUtilsTest {
when(mApplicationContext.getSystemService(Context.DEVICE_POLICY_SERVICE))
.thenReturn(mDevicePolicyManager);
when(mApplicationContext.getSystemService(Context.FACE_SERVICE)).thenReturn(mFaceManager);
mFaceStatusUtils = new FaceStatusUtils(mApplicationContext, mFaceManager);
mFaceStatusUtils = new FaceStatusUtils(mApplicationContext, mFaceManager, USER_ID);
}
@Test

View File

@@ -52,7 +52,8 @@ public class FingerprintStatusUtilsTest {
private static final ComponentName COMPONENT_NAME =
new ComponentName("package", "class");
private static final UserHandle USER_HANDLE = new UserHandle(UserHandle.myUserId());
private static final int USER_ID = UserHandle.myUserId();
private static final UserHandle USER_HANDLE = new UserHandle(USER_ID);
@Mock
@@ -82,7 +83,7 @@ public class FingerprintStatusUtilsTest {
.thenReturn(mDevicePolicyManager);
when(mApplicationContext.getSystemService(Context.FACE_SERVICE)).thenReturn(mFaceManager);
mFingerprintStatusUtils =
new FingerprintStatusUtils(mApplicationContext, mFingerprintManager);
new FingerprintStatusUtils(mApplicationContext, mFingerprintManager, USER_ID);
}
@Test

View File

@@ -22,6 +22,7 @@ import static com.google.common.truth.Truth.assertThat;
import static org.mockito.ArgumentMatchers.any;
import static org.mockito.ArgumentMatchers.anyInt;
import static org.mockito.ArgumentMatchers.eq;
import static org.mockito.Mockito.never;
import static org.mockito.Mockito.verify;
import static org.mockito.Mockito.when;
@@ -117,12 +118,9 @@ public class LockScreenSafetySourceTest {
LockScreenSafetySource.setSafetySourceData(mApplicationContext,
mScreenLockPreferenceDetailsUtils, EVENT_SOURCE_STATE_CHANGED);
ArgumentCaptor<String> idCaptor = ArgumentCaptor.forClass(String.class);
verify(mSafetyCenterManagerWrapper).setSafetySourceData(
any(), idCaptor.capture(), any(), any());
String safetySourceId = idCaptor.getValue();
assertThat(safetySourceId).isEqualTo(LockScreenSafetySource.SAFETY_SOURCE_ID);
verify(mSafetyCenterManagerWrapper).setSafetySourceData(
any(), eq(LockScreenSafetySource.SAFETY_SOURCE_ID), any(), any());
}
@Test
@@ -132,12 +130,9 @@ public class LockScreenSafetySourceTest {
LockScreenSafetySource.setSafetySourceData(mApplicationContext,
mScreenLockPreferenceDetailsUtils, EVENT_SOURCE_STATE_CHANGED);
ArgumentCaptor<SafetyEvent> eventCaptor = ArgumentCaptor.forClass(SafetyEvent.class);
verify(mSafetyCenterManagerWrapper).setSafetySourceData(
any(), any(), any(), eventCaptor.capture());
SafetyEvent safetyEvent = eventCaptor.getValue();
assertThat(safetyEvent).isEqualTo(EVENT_SOURCE_STATE_CHANGED);
verify(mSafetyCenterManagerWrapper).setSafetySourceData(
any(), any(), any(), eq(EVENT_SOURCE_STATE_CHANGED));
}
@Test
@@ -176,7 +171,7 @@ public class LockScreenSafetySourceTest {
ArgumentCaptor<SafetySourceData> captor = ArgumentCaptor.forClass(SafetySourceData.class);
verify(mSafetyCenterManagerWrapper).setSafetySourceData(
any(), any(), captor.capture(), any());
any(), eq(LockScreenSafetySource.SAFETY_SOURCE_ID), captor.capture(), any());
SafetySourceData safetySourceData = captor.getValue();
SafetySourceStatus safetySourceStatus = safetySourceData.getStatus();
@@ -195,7 +190,7 @@ public class LockScreenSafetySourceTest {
ArgumentCaptor<SafetySourceData> captor = ArgumentCaptor.forClass(SafetySourceData.class);
verify(mSafetyCenterManagerWrapper).setSafetySourceData(
any(), any(), captor.capture(), any());
any(), eq(LockScreenSafetySource.SAFETY_SOURCE_ID), captor.capture(), any());
SafetySourceData safetySourceData = captor.getValue();
SafetySourceStatus safetySourceStatus = safetySourceData.getStatus();
@@ -221,7 +216,7 @@ public class LockScreenSafetySourceTest {
}
@Test
public void setSafetySourceData_whenLockPatternIsNotSecure_setIssue() {
public void setSafetySourceData_whenLockPatternIsNotSecure_setsIssue() {
whenScreenLockIsEnabled();
when(mSafetyCenterManagerWrapper.isEnabled(mApplicationContext)).thenReturn(true);
when(mScreenLockPreferenceDetailsUtils.isLockPatternSecure()).thenReturn(false);
@@ -231,7 +226,7 @@ public class LockScreenSafetySourceTest {
ArgumentCaptor<SafetySourceData> captor = ArgumentCaptor.forClass(SafetySourceData.class);
verify(mSafetyCenterManagerWrapper).setSafetySourceData(
any(), any(), captor.capture(), any());
any(), eq(LockScreenSafetySource.SAFETY_SOURCE_ID), captor.capture(), any());
SafetySourceData safetySourceData = captor.getValue();
assertThat(safetySourceData.getIssues()).hasSize(1);
@@ -244,7 +239,7 @@ public class LockScreenSafetySourceTest {
ResourcesUtils.getResourcesString(mApplicationContext,
"no_screen_lock_issue_summary"));
assertThat(issue.getSeverityLevel()).isEqualTo(
SafetySourceStatus.STATUS_LEVEL_RECOMMENDATION);
SafetySourceIssue.SEVERITY_LEVEL_RECOMMENDATION);
assertThat(issue.getIssueTypeId()).isEqualTo(
LockScreenSafetySource.NO_SCREEN_LOCK_ISSUE_TYPE_ID);
assertThat(issue.getIssueCategory()).isEqualTo(SafetySourceIssue.ISSUE_CATEGORY_DEVICE);
@@ -270,7 +265,7 @@ public class LockScreenSafetySourceTest {
ArgumentCaptor<SafetySourceData> captor = ArgumentCaptor.forClass(SafetySourceData.class);
verify(mSafetyCenterManagerWrapper).setSafetySourceData(
any(), any(), captor.capture(), any());
any(), eq(LockScreenSafetySource.SAFETY_SOURCE_ID), captor.capture(), any());
SafetySourceData safetySourceData = captor.getValue();
SafetySourceStatus safetySourceStatus = safetySourceData.getStatus();
@@ -289,7 +284,7 @@ public class LockScreenSafetySourceTest {
ArgumentCaptor<SafetySourceData> captor = ArgumentCaptor.forClass(SafetySourceData.class);
verify(mSafetyCenterManagerWrapper).setSafetySourceData(
any(), any(), captor.capture(), any());
any(), eq(LockScreenSafetySource.SAFETY_SOURCE_ID), captor.capture(), any());
SafetySourceData safetySourceData = captor.getValue();
SafetySourceStatus safetySourceStatus = safetySourceData.getStatus();
@@ -311,7 +306,7 @@ public class LockScreenSafetySourceTest {
final ArgumentCaptor<SafetySourceData> captor = ArgumentCaptor.forClass(
SafetySourceData.class);
verify(mSafetyCenterManagerWrapper).setSafetySourceData(
any(), any(), captor.capture(), any());
any(), eq(LockScreenSafetySource.SAFETY_SOURCE_ID), captor.capture(), any());
final IconAction iconAction = captor.getValue().getStatus().getIconAction();
assertThat(iconAction.getIconType()).isEqualTo(IconAction.ICON_TYPE_GEAR);
@@ -330,7 +325,7 @@ public class LockScreenSafetySourceTest {
ArgumentCaptor<SafetySourceData> captor = ArgumentCaptor.forClass(SafetySourceData.class);
verify(mSafetyCenterManagerWrapper).setSafetySourceData(
any(), any(), captor.capture(), any());
any(), eq(LockScreenSafetySource.SAFETY_SOURCE_ID), captor.capture(), any());
SafetySourceData safetySourceData = captor.getValue();
SafetySourceStatus safetySourceStatus = safetySourceData.getStatus();
@@ -338,13 +333,16 @@ public class LockScreenSafetySourceTest {
}
@Test
public void onLockScreenChange_whenSafetyCenterEnabled_setData() {
public void onLockScreenChange_whenSafetyCenterEnabled_setsLockscreenAndBiometricData() {
whenScreenLockIsEnabled();
when(mSafetyCenterManagerWrapper.isEnabled(mApplicationContext)).thenReturn(true);
LockScreenSafetySource.onLockScreenChange(mApplicationContext);
verify(mSafetyCenterManagerWrapper).setSafetySourceData(any(), any(), any(), any());
verify(mSafetyCenterManagerWrapper).setSafetySourceData(
any(), eq(LockScreenSafetySource.SAFETY_SOURCE_ID), any(), any());
verify(mSafetyCenterManagerWrapper).setSafetySourceData(
any(), eq(BiometricsSafetySource.SAFETY_SOURCE_ID), any(), any());
}
@Test