Merge "Update KeyguardIndicationController" into sc-dev
This commit is contained in:
@@ -19,6 +19,7 @@ package com.android.systemui.keyguard;
|
||||
import android.annotation.Nullable;
|
||||
import android.content.res.ColorStateList;
|
||||
import android.graphics.Color;
|
||||
import android.text.TextUtils;
|
||||
import android.view.View;
|
||||
|
||||
import androidx.annotation.IntDef;
|
||||
@@ -69,8 +70,7 @@ public class KeyguardIndicationRotateTextViewController extends
|
||||
public KeyguardIndicationRotateTextViewController(
|
||||
KeyguardIndicationTextView view,
|
||||
@Main DelayableExecutor executor,
|
||||
StatusBarStateController statusBarStateController,
|
||||
int lockScreenMode
|
||||
StatusBarStateController statusBarStateController
|
||||
) {
|
||||
super(view);
|
||||
mMaxAlpha = view.getAlpha();
|
||||
@@ -78,7 +78,6 @@ public class KeyguardIndicationRotateTextViewController extends
|
||||
mInitialTextColorState = mView != null
|
||||
? mView.getTextColors() : ColorStateList.valueOf(Color.WHITE);
|
||||
mStatusBarStateController = statusBarStateController;
|
||||
mView.setLockScreenMode(lockScreenMode);
|
||||
init();
|
||||
}
|
||||
|
||||
@@ -102,7 +101,7 @@ public class KeyguardIndicationRotateTextViewController extends
|
||||
* the IndicationQueue comes around.
|
||||
*/
|
||||
public void updateIndication(@IndicationType int type, KeyguardIndication newIndication,
|
||||
boolean showImmediately) {
|
||||
boolean updateImmediately) {
|
||||
if (type == INDICATION_TYPE_NOW_PLAYING
|
||||
|| type == INDICATION_TYPE_REVERSE_CHARGING) {
|
||||
// temporarily don't show here, instead use AmbientContainer b/181049781
|
||||
@@ -125,7 +124,7 @@ public class KeyguardIndicationRotateTextViewController extends
|
||||
return;
|
||||
}
|
||||
|
||||
final boolean showNow = showImmediately
|
||||
final boolean showNow = updateImmediately
|
||||
|| mCurrIndicationType == INDICATION_TYPE_NONE
|
||||
|| mCurrIndicationType == type;
|
||||
if (hasNewIndication) {
|
||||
@@ -139,7 +138,7 @@ public class KeyguardIndicationRotateTextViewController extends
|
||||
|
||||
if (mCurrIndicationType == type
|
||||
&& !hasNewIndication
|
||||
&& showImmediately) {
|
||||
&& updateImmediately) {
|
||||
if (mShowNextIndicationRunnable != null) {
|
||||
mShowNextIndicationRunnable.runImmediately();
|
||||
} else {
|
||||
@@ -154,6 +153,10 @@ public class KeyguardIndicationRotateTextViewController extends
|
||||
* If the current indication is of this type, immediately stops showing the message.
|
||||
*/
|
||||
public void hideIndication(@IndicationType int type) {
|
||||
if (!mIndicationMessages.containsKey(type)
|
||||
|| TextUtils.isEmpty(mIndicationMessages.get(type).getMessage())) {
|
||||
return;
|
||||
}
|
||||
updateIndication(type, null, true);
|
||||
}
|
||||
|
||||
|
||||
@@ -20,7 +20,6 @@ import static android.app.admin.DevicePolicyManager.DEVICE_OWNER_TYPE_FINANCED;
|
||||
import static android.view.View.GONE;
|
||||
import static android.view.View.VISIBLE;
|
||||
|
||||
import static com.android.keyguard.KeyguardUpdateMonitor.LOCK_SCREEN_MODE_LAYOUT_1;
|
||||
import static com.android.systemui.DejankUtils.whitelistIpcs;
|
||||
import static com.android.systemui.keyguard.KeyguardIndicationRotateTextViewController.INDICATION_TYPE_ALIGNMENT;
|
||||
import static com.android.systemui.keyguard.KeyguardIndicationRotateTextViewController.INDICATION_TYPE_BATTERY;
|
||||
@@ -30,6 +29,7 @@ import static com.android.systemui.keyguard.KeyguardIndicationRotateTextViewCont
|
||||
import static com.android.systemui.keyguard.KeyguardIndicationRotateTextViewController.INDICATION_TYPE_RESTING;
|
||||
import static com.android.systemui.keyguard.KeyguardIndicationRotateTextViewController.INDICATION_TYPE_TRUST;
|
||||
import static com.android.systemui.keyguard.KeyguardIndicationRotateTextViewController.INDICATION_TYPE_USER_LOCKED;
|
||||
import static com.android.systemui.plugins.FalsingManager.LOW_PENALTY;
|
||||
|
||||
import android.animation.Animator;
|
||||
import android.animation.AnimatorListenerAdapter;
|
||||
@@ -77,6 +77,7 @@ import com.android.systemui.dagger.qualifiers.Main;
|
||||
import com.android.systemui.dock.DockManager;
|
||||
import com.android.systemui.keyguard.KeyguardIndication;
|
||||
import com.android.systemui.keyguard.KeyguardIndicationRotateTextViewController;
|
||||
import com.android.systemui.plugins.FalsingManager;
|
||||
import com.android.systemui.plugins.statusbar.StatusBarStateController;
|
||||
import com.android.systemui.statusbar.phone.KeyguardIndicationTextView;
|
||||
import com.android.systemui.statusbar.phone.StatusBarKeyguardViewManager;
|
||||
@@ -120,6 +121,7 @@ public class KeyguardIndicationController implements KeyguardStateController.Cal
|
||||
private final @Main DelayableExecutor mExecutor;
|
||||
private final LockPatternUtils mLockPatternUtils;
|
||||
private final IActivityManager mIActivityManager;
|
||||
private final FalsingManager mFalsingManager;
|
||||
|
||||
protected KeyguardIndicationRotateTextViewController mRotateTextViewController;
|
||||
private BroadcastReceiver mBroadcastReceiver;
|
||||
@@ -171,7 +173,8 @@ public class KeyguardIndicationController implements KeyguardStateController.Cal
|
||||
DevicePolicyManager devicePolicyManager,
|
||||
IBatteryStats iBatteryStats,
|
||||
UserManager userManager,
|
||||
@Main DelayableExecutor executor) {
|
||||
@Main DelayableExecutor executor,
|
||||
FalsingManager falsingManager) {
|
||||
mContext = context;
|
||||
mBroadcastDispatcher = broadcastDispatcher;
|
||||
mDevicePolicyManager = devicePolicyManager;
|
||||
@@ -188,6 +191,7 @@ public class KeyguardIndicationController implements KeyguardStateController.Cal
|
||||
mExecutor = executor;
|
||||
mLockPatternUtils = new LockPatternUtils(context);
|
||||
mIActivityManager = ActivityManager.getService();
|
||||
mFalsingManager = falsingManager;
|
||||
|
||||
mKeyguardUpdateMonitor.registerCallback(getKeyguardCallback());
|
||||
mKeyguardUpdateMonitor.registerCallback(mTickReceiver);
|
||||
@@ -203,8 +207,7 @@ public class KeyguardIndicationController implements KeyguardStateController.Cal
|
||||
mRotateTextViewController = new KeyguardIndicationRotateTextViewController(
|
||||
indicationArea.findViewById(R.id.keyguard_indication_text_bottom),
|
||||
mExecutor,
|
||||
mStatusBarStateController,
|
||||
mLockScreenMode);
|
||||
mStatusBarStateController);
|
||||
updateIndication(false /* animate */);
|
||||
updateDisclosure();
|
||||
if (mBroadcastReceiver == null) {
|
||||
@@ -284,9 +287,7 @@ public class KeyguardIndicationController implements KeyguardStateController.Cal
|
||||
mRotateTextViewController.hideIndication(INDICATION_TYPE_DISCLOSURE);
|
||||
}
|
||||
|
||||
if (isKeyguardLayoutEnabled()) {
|
||||
updateResting();
|
||||
}
|
||||
updateResting();
|
||||
}
|
||||
|
||||
private CharSequence getDisclosureText(@Nullable CharSequence organizationName) {
|
||||
@@ -306,10 +307,6 @@ public class KeyguardIndicationController implements KeyguardStateController.Cal
|
||||
}
|
||||
|
||||
private void updateOwnerInfo() {
|
||||
if (!isKeyguardLayoutEnabled()) {
|
||||
mRotateTextViewController.hideIndication(INDICATION_TYPE_OWNER_INFO);
|
||||
return;
|
||||
}
|
||||
String info = mLockPatternUtils.getDeviceOwnerInfo();
|
||||
if (info == null) {
|
||||
// Use the current user owner information if enabled.
|
||||
@@ -431,15 +428,7 @@ public class KeyguardIndicationController implements KeyguardStateController.Cal
|
||||
}
|
||||
}
|
||||
|
||||
protected boolean isKeyguardLayoutEnabled() {
|
||||
return mLockScreenMode == LOCK_SCREEN_MODE_LAYOUT_1;
|
||||
}
|
||||
|
||||
private void updateLogoutView() {
|
||||
if (!isKeyguardLayoutEnabled()) {
|
||||
mRotateTextViewController.hideIndication(INDICATION_TYPE_LOGOUT);
|
||||
return;
|
||||
}
|
||||
final boolean shouldShowLogout = mKeyguardUpdateMonitor.isLogoutEnabled()
|
||||
&& KeyguardUpdateMonitor.getCurrentUser() != UserHandle.USER_SYSTEM;
|
||||
if (shouldShowLogout) {
|
||||
@@ -452,6 +441,9 @@ public class KeyguardIndicationController implements KeyguardStateController.Cal
|
||||
.setBackground(mContext.getDrawable(
|
||||
com.android.systemui.R.drawable.logout_button_background))
|
||||
.setClickListener((view) -> {
|
||||
if (mFalsingManager.isFalseTap(LOW_PENALTY)) {
|
||||
return;
|
||||
}
|
||||
int currentUserId = KeyguardUpdateMonitor.getCurrentUser();
|
||||
try {
|
||||
mIActivityManager.switchUser(UserHandle.USER_SYSTEM);
|
||||
@@ -651,76 +643,8 @@ public class KeyguardIndicationController implements KeyguardStateController.Cal
|
||||
}
|
||||
|
||||
// LOCK SCREEN
|
||||
// Some cases here might need to hide the indication (if the battery is not present)
|
||||
int userId = KeyguardUpdateMonitor.getCurrentUser();
|
||||
|
||||
if (mLockScreenMode == LOCK_SCREEN_MODE_LAYOUT_1) {
|
||||
mTopIndicationView.setVisibility(GONE);
|
||||
updateIndications(animate, userId);
|
||||
} else {
|
||||
boolean hideIndication = false;
|
||||
boolean isError = false;
|
||||
String trustGrantedIndication = getTrustGrantedIndication();
|
||||
String trustManagedIndication = getTrustManagedIndication();
|
||||
String powerIndication = null;
|
||||
|
||||
if (mPowerPluggedIn || mEnableBatteryDefender) {
|
||||
powerIndication = computePowerIndication();
|
||||
}
|
||||
if (!mKeyguardUpdateMonitor.isUserUnlocked(userId)) {
|
||||
mTopIndicationView.switchIndication(
|
||||
com.android.internal.R.string.lockscreen_storage_locked);
|
||||
} else if (!TextUtils.isEmpty(mTransientIndication)) {
|
||||
if (powerIndication != null && !mTransientIndication.equals(powerIndication)) {
|
||||
String indication = mContext.getResources().getString(
|
||||
R.string.keyguard_indication_trust_unlocked_plugged_in,
|
||||
mTransientIndication, powerIndication);
|
||||
mTopIndicationView.switchIndication(indication, null);
|
||||
hideIndication = !mBatteryPresent;
|
||||
} else {
|
||||
mTopIndicationView.switchIndication(mTransientIndication, null);
|
||||
}
|
||||
isError = mTransientTextIsError;
|
||||
} else if (!TextUtils.isEmpty(trustGrantedIndication)
|
||||
&& mKeyguardUpdateMonitor.getUserHasTrust(userId)) {
|
||||
if (powerIndication != null) {
|
||||
String indication = mContext.getResources().getString(
|
||||
R.string.keyguard_indication_trust_unlocked_plugged_in,
|
||||
trustGrantedIndication, powerIndication);
|
||||
mTopIndicationView.switchIndication(indication, null);
|
||||
hideIndication = !mBatteryPresent;
|
||||
} else {
|
||||
mTopIndicationView.switchIndication(trustGrantedIndication, null);
|
||||
}
|
||||
} else if (!TextUtils.isEmpty(mAlignmentIndication)) {
|
||||
mTopIndicationView.switchIndication(mAlignmentIndication, null);
|
||||
isError = true;
|
||||
hideIndication = !mBatteryPresent;
|
||||
} else if (mPowerPluggedIn || mEnableBatteryDefender) {
|
||||
if (DEBUG_CHARGING_SPEED) {
|
||||
powerIndication += ", " + (mChargingWattage / 1000) + " mW";
|
||||
}
|
||||
if (animate) {
|
||||
animateText(mTopIndicationView, powerIndication);
|
||||
} else {
|
||||
mTopIndicationView.switchIndication(powerIndication, null);
|
||||
}
|
||||
hideIndication = !mBatteryPresent;
|
||||
} else if (!TextUtils.isEmpty(trustManagedIndication)
|
||||
&& mKeyguardUpdateMonitor.getUserTrustIsManaged(userId)
|
||||
&& !mKeyguardUpdateMonitor.getUserHasTrust(userId)) {
|
||||
mTopIndicationView.switchIndication(trustManagedIndication, null);
|
||||
} else {
|
||||
mTopIndicationView.switchIndication(mRestingIndication, null);
|
||||
}
|
||||
|
||||
mTopIndicationView.setTextColor(
|
||||
isError ? Utils.getColorError(mContext) : mInitialTextColorState);
|
||||
|
||||
if (hideIndication) {
|
||||
mIndicationArea.setVisibility(GONE);
|
||||
}
|
||||
}
|
||||
mTopIndicationView.setVisibility(GONE);
|
||||
updateIndications(animate, KeyguardUpdateMonitor.getCurrentUser());
|
||||
}
|
||||
|
||||
// animates textView - textView moves up and bounces down
|
||||
@@ -883,7 +807,7 @@ public class KeyguardIndicationController implements KeyguardStateController.Cal
|
||||
|
||||
@Override
|
||||
public void onUnlockedChanged() {
|
||||
updateIndication(!mDozing);
|
||||
updateIndication(false);
|
||||
}
|
||||
|
||||
protected class BaseKeyguardCallback extends KeyguardUpdateMonitorCallback {
|
||||
@@ -1025,7 +949,7 @@ public class KeyguardIndicationController implements KeyguardStateController.Cal
|
||||
@Override
|
||||
public void onBiometricRunningStateChanged(boolean running,
|
||||
BiometricSourceType biometricSourceType) {
|
||||
if (running) {
|
||||
if (running && biometricSourceType == BiometricSourceType.FACE) {
|
||||
// Let's hide any previous messages when authentication starts, otherwise
|
||||
// multiple auth attempts would overlap.
|
||||
hideTransientIndication();
|
||||
|
||||
@@ -16,8 +16,6 @@
|
||||
|
||||
package com.android.systemui.statusbar.phone;
|
||||
|
||||
import static com.android.keyguard.KeyguardUpdateMonitor.LOCK_SCREEN_MODE_LAYOUT_1;
|
||||
|
||||
import android.animation.Animator;
|
||||
import android.animation.AnimatorListenerAdapter;
|
||||
import android.animation.AnimatorSet;
|
||||
@@ -40,16 +38,12 @@ import java.util.LinkedList;
|
||||
* A view to show hints on Keyguard ("Swipe up to unlock", "Tap again to open").
|
||||
*/
|
||||
public class KeyguardIndicationTextView extends TextView {
|
||||
private static final int FADE_OUT_MILLIS = 200;
|
||||
private static final int FADE_IN_MILLIS = 250;
|
||||
private static final long MSG_DURATION_MILLIS = 600;
|
||||
private long mNextAnimationTime = 0;
|
||||
private boolean mAnimationsEnabled = true;
|
||||
private LinkedList<CharSequence> mMessages = new LinkedList<>();
|
||||
private LinkedList<KeyguardIndication> mKeyguardIndicationInfo = new LinkedList<>();
|
||||
|
||||
private boolean mUseNewAnimations = false;
|
||||
|
||||
public KeyguardIndicationTextView(Context context) {
|
||||
super(context);
|
||||
}
|
||||
@@ -67,10 +61,6 @@ public class KeyguardIndicationTextView extends TextView {
|
||||
super(context, attrs, defStyleAttr, defStyleRes);
|
||||
}
|
||||
|
||||
public void setLockScreenMode(int lockScreenMode) {
|
||||
mUseNewAnimations = lockScreenMode == LOCK_SCREEN_MODE_LAYOUT_1;
|
||||
}
|
||||
|
||||
/**
|
||||
* Changes the text with an animation and makes sure a single indication is shown long enough.
|
||||
*/
|
||||
@@ -148,15 +138,11 @@ public class KeyguardIndicationTextView extends TextView {
|
||||
}
|
||||
});
|
||||
|
||||
if (mUseNewAnimations) {
|
||||
Animator yTranslate =
|
||||
ObjectAnimator.ofFloat(this, View.TRANSLATION_Y, 0, -getYTranslationPixels());
|
||||
yTranslate.setDuration(getFadeOutDuration());
|
||||
fadeOut.setInterpolator(Interpolators.FAST_OUT_LINEAR_IN);
|
||||
animatorSet.playTogether(fadeOut, yTranslate);
|
||||
} else {
|
||||
animatorSet.play(fadeOut);
|
||||
}
|
||||
Animator yTranslate =
|
||||
ObjectAnimator.ofFloat(this, View.TRANSLATION_Y, 0, -getYTranslationPixels());
|
||||
yTranslate.setDuration(getFadeOutDuration());
|
||||
fadeOut.setInterpolator(Interpolators.FAST_OUT_LINEAR_IN);
|
||||
animatorSet.playTogether(fadeOut, yTranslate);
|
||||
|
||||
return animatorSet;
|
||||
}
|
||||
@@ -168,20 +154,16 @@ public class KeyguardIndicationTextView extends TextView {
|
||||
fadeIn.setDuration(getFadeInDuration());
|
||||
fadeIn.setInterpolator(Interpolators.LINEAR_OUT_SLOW_IN);
|
||||
|
||||
if (mUseNewAnimations) {
|
||||
Animator yTranslate =
|
||||
ObjectAnimator.ofFloat(this, View.TRANSLATION_Y, getYTranslationPixels(), 0);
|
||||
yTranslate.setDuration(getYInDuration());
|
||||
yTranslate.addListener(new AnimatorListenerAdapter() {
|
||||
@Override
|
||||
public void onAnimationCancel(Animator animation) {
|
||||
setTranslationY(0);
|
||||
}
|
||||
});
|
||||
animatorSet.playTogether(yTranslate, fadeIn);
|
||||
} else {
|
||||
animatorSet.play(fadeIn);
|
||||
}
|
||||
Animator yTranslate =
|
||||
ObjectAnimator.ofFloat(this, View.TRANSLATION_Y, getYTranslationPixels(), 0);
|
||||
yTranslate.setDuration(getYInDuration());
|
||||
yTranslate.addListener(new AnimatorListenerAdapter() {
|
||||
@Override
|
||||
public void onAnimationCancel(Animator animation) {
|
||||
setTranslationY(0);
|
||||
}
|
||||
});
|
||||
animatorSet.playTogether(yTranslate, fadeIn);
|
||||
|
||||
return animatorSet;
|
||||
}
|
||||
@@ -193,26 +175,22 @@ public class KeyguardIndicationTextView extends TextView {
|
||||
|
||||
private long getFadeInDelay() {
|
||||
if (!mAnimationsEnabled) return 0L;
|
||||
if (mUseNewAnimations) return 150L;
|
||||
return 0L;
|
||||
return 150L;
|
||||
}
|
||||
|
||||
private long getFadeInDuration() {
|
||||
if (!mAnimationsEnabled) return 0L;
|
||||
if (mUseNewAnimations) return 317L;
|
||||
return FADE_IN_MILLIS;
|
||||
return 317L;
|
||||
}
|
||||
|
||||
private long getYInDuration() {
|
||||
if (!mAnimationsEnabled) return 0L;
|
||||
if (mUseNewAnimations) return 600L;
|
||||
return 0L;
|
||||
return 600L;
|
||||
}
|
||||
|
||||
private long getFadeOutDuration() {
|
||||
if (!mAnimationsEnabled) return 0L;
|
||||
if (mUseNewAnimations) return 167L;
|
||||
return FADE_OUT_MILLIS;
|
||||
return 167L;
|
||||
}
|
||||
|
||||
private void setNextAnimationTime(long time) {
|
||||
|
||||
@@ -17,7 +17,6 @@
|
||||
package com.android.systemui.keyguard;
|
||||
|
||||
|
||||
import static com.android.keyguard.KeyguardUpdateMonitor.LOCK_SCREEN_MODE_LAYOUT_1;
|
||||
import static com.android.systemui.keyguard.KeyguardIndicationRotateTextViewController.INDICATION_TYPE_BATTERY;
|
||||
import static com.android.systemui.keyguard.KeyguardIndicationRotateTextViewController.INDICATION_TYPE_DISCLOSURE;
|
||||
import static com.android.systemui.keyguard.KeyguardIndicationRotateTextViewController.INDICATION_TYPE_OWNER_INFO;
|
||||
@@ -77,7 +76,7 @@ public class KeyguardIndicationRotateTextViewControllerTest extends SysuiTestCas
|
||||
MockitoAnnotations.initMocks(this);
|
||||
when(mView.getTextColors()).thenReturn(ColorStateList.valueOf(Color.WHITE));
|
||||
mController = new KeyguardIndicationRotateTextViewController(mView, mExecutor,
|
||||
mStatusBarStateController, LOCK_SCREEN_MODE_LAYOUT_1);
|
||||
mStatusBarStateController);
|
||||
mController.onViewAttached();
|
||||
|
||||
verify(mStatusBarStateController).addCallback(mStatusBarStateListenerCaptor.capture());
|
||||
|
||||
@@ -20,7 +20,13 @@ import static android.app.admin.DevicePolicyManager.DEVICE_OWNER_TYPE_DEFAULT;
|
||||
import static android.app.admin.DevicePolicyManager.DEVICE_OWNER_TYPE_FINANCED;
|
||||
import static android.content.pm.UserInfo.FLAG_MANAGED_PROFILE;
|
||||
|
||||
import static com.android.systemui.keyguard.KeyguardIndicationRotateTextViewController.INDICATION_TYPE_ALIGNMENT;
|
||||
import static com.android.systemui.keyguard.KeyguardIndicationRotateTextViewController.INDICATION_TYPE_BATTERY;
|
||||
import static com.android.systemui.keyguard.KeyguardIndicationRotateTextViewController.INDICATION_TYPE_DISCLOSURE;
|
||||
import static com.android.systemui.keyguard.KeyguardIndicationRotateTextViewController.INDICATION_TYPE_RESTING;
|
||||
import static com.android.systemui.keyguard.KeyguardIndicationRotateTextViewController.INDICATION_TYPE_TRANSIENT;
|
||||
import static com.android.systemui.keyguard.KeyguardIndicationRotateTextViewController.INDICATION_TYPE_TRUST;
|
||||
import static com.android.systemui.keyguard.KeyguardIndicationRotateTextViewController.INDICATION_TYPE_USER_LOCKED;
|
||||
|
||||
import static com.google.common.truth.Truth.assertThat;
|
||||
|
||||
@@ -29,6 +35,8 @@ import static org.junit.Assert.assertTrue;
|
||||
import static org.mockito.ArgumentMatchers.any;
|
||||
import static org.mockito.ArgumentMatchers.anyBoolean;
|
||||
import static org.mockito.ArgumentMatchers.anyInt;
|
||||
import static org.mockito.ArgumentMatchers.anyObject;
|
||||
import static org.mockito.ArgumentMatchers.anyString;
|
||||
import static org.mockito.ArgumentMatchers.eq;
|
||||
import static org.mockito.Mockito.clearInvocations;
|
||||
import static org.mockito.Mockito.mock;
|
||||
@@ -70,6 +78,7 @@ import com.android.systemui.broadcast.BroadcastDispatcher;
|
||||
import com.android.systemui.dock.DockManager;
|
||||
import com.android.systemui.keyguard.KeyguardIndication;
|
||||
import com.android.systemui.keyguard.KeyguardIndicationRotateTextViewController;
|
||||
import com.android.systemui.plugins.FalsingManager;
|
||||
import com.android.systemui.plugins.statusbar.StatusBarStateController;
|
||||
import com.android.systemui.statusbar.phone.KeyguardIndicationTextView;
|
||||
import com.android.systemui.statusbar.phone.LockIcon;
|
||||
@@ -130,6 +139,8 @@ public class KeyguardIndicationControllerTest extends SysuiTestCase {
|
||||
private DockManager mDockManager;
|
||||
@Mock
|
||||
private KeyguardIndicationRotateTextViewController mRotateTextViewController;
|
||||
@Mock
|
||||
private FalsingManager mFalsingManager;
|
||||
@Captor
|
||||
private ArgumentCaptor<DockManager.AlignmentStateListener> mAlignmentListener;
|
||||
@Captor
|
||||
@@ -197,7 +208,7 @@ public class KeyguardIndicationControllerTest extends SysuiTestCase {
|
||||
mController = new KeyguardIndicationController(mContext, mWakeLockBuilder,
|
||||
mKeyguardStateController, mStatusBarStateController, mKeyguardUpdateMonitor,
|
||||
mDockManager, mBroadcastDispatcher, mDevicePolicyManager, mIBatteryStats,
|
||||
mUserManager, mExecutor);
|
||||
mUserManager, mExecutor, mFalsingManager);
|
||||
mController.setIndicationArea(mIndicationArea);
|
||||
verify(mStatusBarStateController).addCallback(mStatusBarStateListenerCaptor.capture());
|
||||
mStatusBarStateListener = mStatusBarStateListenerCaptor.getValue();
|
||||
@@ -227,10 +238,11 @@ public class KeyguardIndicationControllerTest extends SysuiTestCase {
|
||||
});
|
||||
mInstrumentation.waitForIdleSync();
|
||||
|
||||
assertThat(mTextView.getText()).isEqualTo(
|
||||
|
||||
verifyIndicationMessage(INDICATION_TYPE_ALIGNMENT,
|
||||
mContext.getResources().getString(R.string.dock_alignment_slow_charging));
|
||||
assertThat(mTextView.getCurrentTextColor()).isEqualTo(
|
||||
Utils.getColorError(mContext).getDefaultColor());
|
||||
assertThat(mKeyguardIndicationCaptor.getValue().getTextColor())
|
||||
.isEqualTo(Utils.getColorError(mContext));
|
||||
}
|
||||
|
||||
@Test
|
||||
@@ -244,10 +256,10 @@ public class KeyguardIndicationControllerTest extends SysuiTestCase {
|
||||
});
|
||||
mInstrumentation.waitForIdleSync();
|
||||
|
||||
assertThat(mTextView.getText()).isEqualTo(
|
||||
verifyIndicationMessage(INDICATION_TYPE_ALIGNMENT,
|
||||
mContext.getResources().getString(R.string.dock_alignment_not_charging));
|
||||
assertThat(mTextView.getCurrentTextColor()).isEqualTo(
|
||||
Utils.getColorError(mContext).getDefaultColor());
|
||||
assertThat(mKeyguardIndicationCaptor.getValue().getTextColor())
|
||||
.isEqualTo(Utils.getColorError(mContext));
|
||||
}
|
||||
|
||||
@Test
|
||||
@@ -293,9 +305,7 @@ public class KeyguardIndicationControllerTest extends SysuiTestCase {
|
||||
when(mDevicePolicyManager.isOrganizationOwnedDeviceWithManagedProfile()).thenReturn(false);
|
||||
sendUpdateDisclosureBroadcast();
|
||||
|
||||
verify(mRotateTextViewController).hideIndication(INDICATION_TYPE_DISCLOSURE);
|
||||
verify(mRotateTextViewController, never()).updateIndication(eq(INDICATION_TYPE_DISCLOSURE),
|
||||
any(), anyBoolean());
|
||||
verifyHideIndication(INDICATION_TYPE_DISCLOSURE);
|
||||
}
|
||||
|
||||
@Test
|
||||
@@ -305,10 +315,7 @@ public class KeyguardIndicationControllerTest extends SysuiTestCase {
|
||||
when(mDevicePolicyManager.getDeviceOwnerOrganizationName()).thenReturn(null);
|
||||
sendUpdateDisclosureBroadcast();
|
||||
|
||||
verify(mRotateTextViewController).updateIndication(eq(INDICATION_TYPE_DISCLOSURE),
|
||||
mKeyguardIndicationCaptor.capture(), eq(false));
|
||||
assertThat(mKeyguardIndicationCaptor.getValue().getMessage())
|
||||
.isEqualTo(mDisclosureGeneric);
|
||||
verifyIndicationMessage(INDICATION_TYPE_DISCLOSURE, mDisclosureGeneric);
|
||||
}
|
||||
|
||||
@Test
|
||||
@@ -320,10 +327,7 @@ public class KeyguardIndicationControllerTest extends SysuiTestCase {
|
||||
when(mDevicePolicyManager.getOrganizationNameForUser(eq(10))).thenReturn(null);
|
||||
sendUpdateDisclosureBroadcast();
|
||||
|
||||
verify(mRotateTextViewController).updateIndication(eq(INDICATION_TYPE_DISCLOSURE),
|
||||
mKeyguardIndicationCaptor.capture(), eq(false));
|
||||
assertThat(mKeyguardIndicationCaptor.getValue().getMessage())
|
||||
.isEqualTo(mDisclosureGeneric);
|
||||
verifyIndicationMessage(INDICATION_TYPE_DISCLOSURE, mDisclosureGeneric);
|
||||
}
|
||||
|
||||
@Test
|
||||
@@ -333,10 +337,7 @@ public class KeyguardIndicationControllerTest extends SysuiTestCase {
|
||||
when(mDevicePolicyManager.getDeviceOwnerOrganizationName()).thenReturn(ORGANIZATION_NAME);
|
||||
sendUpdateDisclosureBroadcast();
|
||||
|
||||
verify(mRotateTextViewController).updateIndication(eq(INDICATION_TYPE_DISCLOSURE),
|
||||
mKeyguardIndicationCaptor.capture(), eq(false));
|
||||
assertThat(mKeyguardIndicationCaptor.getValue().getMessage())
|
||||
.isEqualTo(mDisclosureWithOrganization);
|
||||
verifyIndicationMessage(INDICATION_TYPE_DISCLOSURE, mDisclosureWithOrganization);
|
||||
}
|
||||
|
||||
@Test
|
||||
@@ -348,10 +349,7 @@ public class KeyguardIndicationControllerTest extends SysuiTestCase {
|
||||
when(mDevicePolicyManager.getOrganizationNameForUser(eq(10))).thenReturn(ORGANIZATION_NAME);
|
||||
sendUpdateDisclosureBroadcast();
|
||||
|
||||
verify(mRotateTextViewController).updateIndication(eq(INDICATION_TYPE_DISCLOSURE),
|
||||
mKeyguardIndicationCaptor.capture(), eq(false));
|
||||
assertThat(mKeyguardIndicationCaptor.getValue().getMessage())
|
||||
.isEqualTo(mDisclosureWithOrganization);
|
||||
verifyIndicationMessage(INDICATION_TYPE_DISCLOSURE, mDisclosureWithOrganization);
|
||||
}
|
||||
|
||||
@Test
|
||||
@@ -363,26 +361,20 @@ public class KeyguardIndicationControllerTest extends SysuiTestCase {
|
||||
when(mDevicePolicyManager.getDeviceOwnerOrganizationName()).thenReturn(null);
|
||||
sendUpdateDisclosureBroadcast();
|
||||
|
||||
verify(mRotateTextViewController).updateIndication(eq(INDICATION_TYPE_DISCLOSURE),
|
||||
mKeyguardIndicationCaptor.capture(), eq(false));
|
||||
assertThat(mKeyguardIndicationCaptor.getValue().getMessage())
|
||||
.isEqualTo(mDisclosureGeneric);
|
||||
verifyIndicationMessage(INDICATION_TYPE_DISCLOSURE, mDisclosureGeneric);
|
||||
reset(mRotateTextViewController);
|
||||
|
||||
when(mDevicePolicyManager.isDeviceManaged()).thenReturn(true);
|
||||
when(mDevicePolicyManager.getDeviceOwnerOrganizationName()).thenReturn(ORGANIZATION_NAME);
|
||||
sendUpdateDisclosureBroadcast();
|
||||
|
||||
verify(mRotateTextViewController).updateIndication(eq(INDICATION_TYPE_DISCLOSURE),
|
||||
mKeyguardIndicationCaptor.capture(), eq(false));
|
||||
assertThat(mKeyguardIndicationCaptor.getValue().getMessage())
|
||||
.isEqualTo(mDisclosureWithOrganization);
|
||||
verifyIndicationMessage(INDICATION_TYPE_DISCLOSURE, mDisclosureWithOrganization);
|
||||
reset(mRotateTextViewController);
|
||||
|
||||
when(mDevicePolicyManager.isDeviceManaged()).thenReturn(false);
|
||||
sendUpdateDisclosureBroadcast();
|
||||
|
||||
verify(mRotateTextViewController).hideIndication(INDICATION_TYPE_DISCLOSURE);
|
||||
verifyHideIndication(INDICATION_TYPE_DISCLOSURE);
|
||||
}
|
||||
|
||||
@Test
|
||||
@@ -395,10 +387,7 @@ public class KeyguardIndicationControllerTest extends SysuiTestCase {
|
||||
.thenReturn(DEVICE_OWNER_TYPE_FINANCED);
|
||||
sendUpdateDisclosureBroadcast();
|
||||
|
||||
verify(mRotateTextViewController).updateIndication(eq(INDICATION_TYPE_DISCLOSURE),
|
||||
mKeyguardIndicationCaptor.capture(), eq(false));
|
||||
assertThat(mKeyguardIndicationCaptor.getValue().getMessage())
|
||||
.isEqualTo(mFinancedDisclosureWithOrganization);
|
||||
verifyIndicationMessage(INDICATION_TYPE_DISCLOSURE, mFinancedDisclosureWithOrganization);
|
||||
}
|
||||
|
||||
@Test
|
||||
@@ -462,10 +451,11 @@ public class KeyguardIndicationControllerTest extends SysuiTestCase {
|
||||
mController.getKeyguardCallback().onBiometricHelp(
|
||||
KeyguardUpdateMonitor.BIOMETRIC_HELP_FACE_NOT_RECOGNIZED, message,
|
||||
BiometricSourceType.FACE);
|
||||
assertThat(mTextView.getText()).isEqualTo(message);
|
||||
verifyTransientMessage(message);
|
||||
reset(mRotateTextViewController);
|
||||
mStatusBarStateListener.onDozingChanged(true);
|
||||
|
||||
assertThat(mTextView.getText()).isNotEqualTo(message);
|
||||
verifyHideIndication(INDICATION_TYPE_TRANSIENT);
|
||||
}
|
||||
|
||||
@Test
|
||||
@@ -477,7 +467,7 @@ public class KeyguardIndicationControllerTest extends SysuiTestCase {
|
||||
mController.getKeyguardCallback().onBiometricError(FaceManager.FACE_ERROR_TIMEOUT,
|
||||
"A message", BiometricSourceType.FACE);
|
||||
|
||||
assertThat(mTextView.getText()).isEqualTo(message);
|
||||
verifyTransientMessage(message);
|
||||
mStatusBarStateListener.onDozingChanged(true);
|
||||
|
||||
assertThat(mTextView.getText()).isNotEqualTo(message);
|
||||
@@ -503,19 +493,22 @@ public class KeyguardIndicationControllerTest extends SysuiTestCase {
|
||||
reset(mKeyguardUpdateMonitor);
|
||||
|
||||
mController.setVisible(true);
|
||||
assertThat(mTextView.getText()).isEqualTo(
|
||||
verifyIndicationMessage(INDICATION_TYPE_USER_LOCKED,
|
||||
mContext.getString(com.android.internal.R.string.lockscreen_storage_locked));
|
||||
|
||||
reset(mRotateTextViewController);
|
||||
when(mKeyguardUpdateMonitor.getUserHasTrust(anyInt())).thenReturn(true);
|
||||
when(mKeyguardUpdateMonitor.isUserUnlocked(anyInt())).thenReturn(true);
|
||||
mController.setRestingIndication(restingIndication);
|
||||
assertThat(mTextView.getText()).isEqualTo(mController.getTrustGrantedIndication());
|
||||
verifyHideIndication(INDICATION_TYPE_USER_LOCKED);
|
||||
verifyIndicationMessage(INDICATION_TYPE_RESTING, restingIndication);
|
||||
|
||||
reset(mRotateTextViewController);
|
||||
reset(mKeyguardUpdateMonitor);
|
||||
when(mKeyguardUpdateMonitor.isUserUnlocked(anyInt())).thenReturn(true);
|
||||
when(mKeyguardUpdateMonitor.getUserHasTrust(anyInt())).thenReturn(false);
|
||||
mController.onUnlockedChanged();
|
||||
assertThat(mTextView.getText()).isEqualTo(restingIndication);
|
||||
verifyIndicationMessage(INDICATION_TYPE_RESTING, restingIndication);
|
||||
}
|
||||
|
||||
@Test
|
||||
@@ -567,12 +560,10 @@ public class KeyguardIndicationControllerTest extends SysuiTestCase {
|
||||
when(mKeyguardUpdateMonitor.getUserHasTrust(anyInt())).thenReturn(true);
|
||||
mController.setPowerPluggedIn(true);
|
||||
mController.setVisible(true);
|
||||
String powerIndication = mController.computePowerIndication();
|
||||
String pluggedIndication = mContext.getString(R.string.keyguard_indication_trust_unlocked);
|
||||
pluggedIndication = mContext.getString(
|
||||
R.string.keyguard_indication_trust_unlocked_plugged_in,
|
||||
pluggedIndication, powerIndication);
|
||||
assertThat(mTextView.getText()).isEqualTo(pluggedIndication);
|
||||
|
||||
verifyIndicationMessage(
|
||||
INDICATION_TYPE_TRUST,
|
||||
mContext.getString(R.string.keyguard_indication_trust_unlocked));
|
||||
}
|
||||
|
||||
@Test
|
||||
@@ -586,10 +577,11 @@ public class KeyguardIndicationControllerTest extends SysuiTestCase {
|
||||
mController.getKeyguardCallback().onRefreshBatteryInfo(status);
|
||||
mController.setVisible(true);
|
||||
|
||||
String percentage = NumberFormat.getPercentInstance().format(80 / 100f);
|
||||
String pluggedIndication = mContext.getString(
|
||||
R.string.keyguard_plugged_in_charging_limited, percentage);
|
||||
assertThat(mTextView.getText()).isEqualTo(pluggedIndication);
|
||||
verifyIndicationMessage(
|
||||
INDICATION_TYPE_BATTERY,
|
||||
mContext.getString(
|
||||
R.string.keyguard_plugged_in_charging_limited,
|
||||
NumberFormat.getPercentInstance().format(80 / 100f)));
|
||||
}
|
||||
|
||||
@Test
|
||||
@@ -603,10 +595,11 @@ public class KeyguardIndicationControllerTest extends SysuiTestCase {
|
||||
mController.getKeyguardCallback().onRefreshBatteryInfo(status);
|
||||
mController.setVisible(true);
|
||||
|
||||
String percentage = NumberFormat.getPercentInstance().format(80 / 100f);
|
||||
String pluggedIndication = mContext.getString(
|
||||
R.string.keyguard_plugged_in_charging_limited, percentage);
|
||||
assertThat(mTextView.getText()).isEqualTo(pluggedIndication);
|
||||
verifyIndicationMessage(
|
||||
INDICATION_TYPE_BATTERY,
|
||||
mContext.getString(
|
||||
R.string.keyguard_plugged_in_charging_limited,
|
||||
NumberFormat.getPercentInstance().format(80 / 100f)));
|
||||
}
|
||||
|
||||
@Test
|
||||
@@ -620,12 +613,13 @@ public class KeyguardIndicationControllerTest extends SysuiTestCase {
|
||||
mController.getKeyguardCallback().onRefreshBatteryInfo(status);
|
||||
mController.setVisible(true);
|
||||
|
||||
String chargedIndication = mContext.getString(R.string.keyguard_charged);
|
||||
assertThat(mTextView.getText()).isEqualTo(chargedIndication);
|
||||
verifyIndicationMessage(
|
||||
INDICATION_TYPE_BATTERY,
|
||||
mContext.getString(R.string.keyguard_charged));
|
||||
}
|
||||
|
||||
@Test
|
||||
public void onRefreshBatteryInfo_dischargingWithOverheat_presentBatteryPercentage() {
|
||||
public void onRefreshBatteryInfo_dozing_dischargingWithOverheat_presentBatteryPercentage() {
|
||||
createController();
|
||||
BatteryStatus status = new BatteryStatus(BatteryManager.BATTERY_STATUS_DISCHARGING,
|
||||
90 /* level */, 0 /* plugged */, BatteryManager.BATTERY_HEALTH_OVERHEAT,
|
||||
@@ -646,10 +640,32 @@ public class KeyguardIndicationControllerTest extends SysuiTestCase {
|
||||
mController.getKeyguardCallback().onRequireUnlockForNfc();
|
||||
mController.setVisible(true);
|
||||
|
||||
assertThat(mTextView.getText()).isEqualTo(message);
|
||||
verifyTransientMessage(message);
|
||||
}
|
||||
|
||||
private void sendUpdateDisclosureBroadcast() {
|
||||
mBroadcastReceiver.onReceive(mContext, new Intent());
|
||||
}
|
||||
|
||||
private void verifyIndicationMessage(int type, String message) {
|
||||
verify(mRotateTextViewController).updateIndication(eq(type),
|
||||
mKeyguardIndicationCaptor.capture(), anyBoolean());
|
||||
assertThat(mKeyguardIndicationCaptor.getValue().getMessage())
|
||||
.isEqualTo(message);
|
||||
}
|
||||
|
||||
private void verifyHideIndication(int type) {
|
||||
if (type == INDICATION_TYPE_TRANSIENT) {
|
||||
verify(mRotateTextViewController).hideTransient();
|
||||
verify(mRotateTextViewController, never()).showTransient(anyString(), anyBoolean());
|
||||
} else {
|
||||
verify(mRotateTextViewController).hideIndication(type);
|
||||
verify(mRotateTextViewController, never()).updateIndication(eq(type),
|
||||
anyObject(), anyBoolean());
|
||||
}
|
||||
}
|
||||
|
||||
private void verifyTransientMessage(String message) {
|
||||
verify(mRotateTextViewController).showTransient(eq(message), anyBoolean());
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user