Refactored KeyguardIndicationController and LockIcon.
Notes: - KeyguardIndicationController can now be provided via the SystemUIFactory. - Created a BaseKeyguardCallback to allow extention of KIC callback implementation. - LockIcon can now be extended through the KIC to support an avatar icon for entering trust. Test: runtest systemui Bug: 34589272 Change-Id: I3a8745dc5054841155a6db41c7e5e8ae5ae1f30d
This commit is contained in:
@@ -30,9 +30,11 @@ import com.android.systemui.R;
|
||||
import com.android.systemui.assist.AssistManager;
|
||||
import com.android.systemui.keyguard.DismissCallbackRegistry;
|
||||
import com.android.systemui.statusbar.BaseStatusBar;
|
||||
import com.android.systemui.statusbar.KeyguardIndicationController;
|
||||
import com.android.systemui.statusbar.ScrimView;
|
||||
import com.android.systemui.statusbar.phone.KeyguardBouncer;
|
||||
import com.android.systemui.statusbar.phone.LightBarController;
|
||||
import com.android.systemui.statusbar.phone.LockIcon;
|
||||
import com.android.systemui.statusbar.phone.LockscreenWallpaper;
|
||||
import com.android.systemui.statusbar.phone.NotificationIconAreaController;
|
||||
import com.android.systemui.statusbar.phone.PhoneStatusBar;
|
||||
@@ -115,6 +117,11 @@ public class SystemUIFactory {
|
||||
return new NotificationIconAreaController(context, phoneStatusBar);
|
||||
}
|
||||
|
||||
public KeyguardIndicationController createKeyguardIndicationController(Context context,
|
||||
ViewGroup indicationArea, LockIcon lockIcon) {
|
||||
return new KeyguardIndicationController(context, indicationArea, lockIcon);
|
||||
}
|
||||
|
||||
public QSTileHost createQSTileHost(Context context, PhoneStatusBar statusBar,
|
||||
StatusBarIconController iconController) {
|
||||
return new QSTileHost(context, statusBar, iconController);
|
||||
|
||||
@@ -47,6 +47,7 @@ import com.android.systemui.R;
|
||||
import com.android.systemui.statusbar.phone.KeyguardIndicationTextView;
|
||||
import com.android.systemui.statusbar.phone.LockIcon;
|
||||
import com.android.systemui.statusbar.phone.StatusBarKeyguardViewManager;
|
||||
import com.android.systemui.statusbar.policy.UserInfoController;
|
||||
|
||||
/**
|
||||
* Controls the indications and error messages shown on the Keyguard
|
||||
@@ -83,6 +84,8 @@ public class KeyguardIndicationController {
|
||||
private int mChargingWattage;
|
||||
private String mMessageToShowOnScreenOn;
|
||||
|
||||
private KeyguardUpdateMonitorCallback mUpdateMonitor;
|
||||
|
||||
private final DevicePolicyManager mDevicePolicyManager;
|
||||
|
||||
public KeyguardIndicationController(Context context, ViewGroup indicationArea,
|
||||
@@ -106,7 +109,7 @@ public class KeyguardIndicationController {
|
||||
mDevicePolicyManager = (DevicePolicyManager) context.getSystemService(
|
||||
Context.DEVICE_POLICY_SERVICE);
|
||||
|
||||
KeyguardUpdateMonitor.getInstance(context).registerCallback(mUpdateMonitor);
|
||||
KeyguardUpdateMonitor.getInstance(context).registerCallback(getKeyguardCallback());
|
||||
context.registerReceiverAsUser(mTickReceiver, UserHandle.SYSTEM,
|
||||
new IntentFilter(Intent.ACTION_TIME_TICK), null,
|
||||
Dependency.get(Dependency.TIME_TICK_HANDLER));
|
||||
@@ -114,6 +117,23 @@ public class KeyguardIndicationController {
|
||||
updateDisclosure();
|
||||
}
|
||||
|
||||
/**
|
||||
* Gets the {@link KeyguardUpdateMonitorCallback} instance associated with this
|
||||
* {@link KeyguardIndicationController}.
|
||||
*
|
||||
* <p>Subclasses may override this method to extend or change the callback behavior by extending
|
||||
* the {@link BaseKeyguardCallback}.
|
||||
*
|
||||
* @return A KeyguardUpdateMonitorCallback. Multiple calls to this method <b>must</b> return the
|
||||
* same instance.
|
||||
*/
|
||||
protected KeyguardUpdateMonitorCallback getKeyguardCallback() {
|
||||
if (mUpdateMonitor == null) {
|
||||
mUpdateMonitor = new BaseKeyguardCallback();
|
||||
}
|
||||
return mUpdateMonitor;
|
||||
}
|
||||
|
||||
private void updateDisclosure() {
|
||||
if (mDevicePolicyManager == null) {
|
||||
return;
|
||||
@@ -151,6 +171,12 @@ public class KeyguardIndicationController {
|
||||
updateIndication();
|
||||
}
|
||||
|
||||
/**
|
||||
* Sets the active controller managing changes and callbacks to user information.
|
||||
*/
|
||||
public void setUserInfoController(UserInfoController userInfoController) {
|
||||
}
|
||||
|
||||
/**
|
||||
* Hides transient indication in {@param delayMs}.
|
||||
*/
|
||||
@@ -264,8 +290,37 @@ public class KeyguardIndicationController {
|
||||
}
|
||||
}
|
||||
|
||||
KeyguardUpdateMonitorCallback mUpdateMonitor = new KeyguardUpdateMonitorCallback() {
|
||||
public int mLastSuccessiveErrorMessage = -1;
|
||||
public void setStatusBarKeyguardViewManager(
|
||||
StatusBarKeyguardViewManager statusBarKeyguardViewManager) {
|
||||
mStatusBarKeyguardViewManager = statusBarKeyguardViewManager;
|
||||
}
|
||||
|
||||
BroadcastReceiver mTickReceiver = new BroadcastReceiver() {
|
||||
@Override
|
||||
public void onReceive(Context context, Intent intent) {
|
||||
mHandler.post(() -> {
|
||||
if (mVisible) {
|
||||
updateIndication();
|
||||
}
|
||||
});
|
||||
}
|
||||
};
|
||||
|
||||
private final Handler mHandler = new Handler() {
|
||||
@Override
|
||||
public void handleMessage(Message msg) {
|
||||
if (msg.what == MSG_HIDE_TRANSIENT && mTransientIndication != null) {
|
||||
mTransientIndication = null;
|
||||
updateIndication();
|
||||
} else if (msg.what == MSG_CLEAR_FP_MSG) {
|
||||
mLockIcon.setTransientFpError(false);
|
||||
hideTransientIndication();
|
||||
}
|
||||
}
|
||||
};
|
||||
|
||||
protected class BaseKeyguardCallback extends KeyguardUpdateMonitorCallback {
|
||||
private int mLastSuccessiveErrorMessage = -1;
|
||||
|
||||
@Override
|
||||
public void onRefreshBatteryInfo(KeyguardUpdateMonitor.BatteryStatus status) {
|
||||
@@ -372,34 +427,4 @@ public class KeyguardIndicationController {
|
||||
}
|
||||
}
|
||||
};
|
||||
|
||||
BroadcastReceiver mTickReceiver = new BroadcastReceiver() {
|
||||
@Override
|
||||
public void onReceive(Context context, Intent intent) {
|
||||
mHandler.post(() -> {
|
||||
if (mVisible) {
|
||||
updateIndication();
|
||||
}
|
||||
});
|
||||
}
|
||||
};
|
||||
|
||||
|
||||
private final Handler mHandler = new Handler() {
|
||||
@Override
|
||||
public void handleMessage(Message msg) {
|
||||
if (msg.what == MSG_HIDE_TRANSIENT && mTransientIndication != null) {
|
||||
mTransientIndication = null;
|
||||
updateIndication();
|
||||
} else if (msg.what == MSG_CLEAR_FP_MSG) {
|
||||
mLockIcon.setTransientFpError(false);
|
||||
hideTransientIndication();
|
||||
}
|
||||
}
|
||||
};
|
||||
|
||||
public void setStatusBarKeyguardViewManager(
|
||||
StatusBarKeyguardViewManager statusBarKeyguardViewManager) {
|
||||
mStatusBarKeyguardViewManager = statusBarKeyguardViewManager;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -29,11 +29,12 @@ import com.android.keyguard.KeyguardUpdateMonitor;
|
||||
import com.android.systemui.R;
|
||||
import com.android.systemui.statusbar.KeyguardAffordanceView;
|
||||
import com.android.systemui.statusbar.policy.AccessibilityController;
|
||||
import com.android.systemui.statusbar.policy.UserInfoController.OnUserInfoChangedListener;
|
||||
|
||||
/**
|
||||
* Manages the different states and animations of the unlock icon.
|
||||
*/
|
||||
public class LockIcon extends KeyguardAffordanceView {
|
||||
public class LockIcon extends KeyguardAffordanceView implements OnUserInfoChangedListener {
|
||||
|
||||
private static final int FP_DRAW_OFF_TIMEOUT = 800;
|
||||
|
||||
@@ -49,6 +50,7 @@ public class LockIcon extends KeyguardAffordanceView {
|
||||
private boolean mDeviceInteractive;
|
||||
private boolean mScreenOn;
|
||||
private boolean mLastScreenOn;
|
||||
private Drawable mUserAvatarIcon;
|
||||
private TrustDrawable mTrustDrawable;
|
||||
private final UnlockMethodCache mUnlockMethodCache;
|
||||
private AccessibilityController mAccessibilityController;
|
||||
@@ -80,6 +82,12 @@ public class LockIcon extends KeyguardAffordanceView {
|
||||
mTrustDrawable.stop();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onUserInfoChanged(String name, Drawable picture, String userAccount) {
|
||||
mUserAvatarIcon = picture;
|
||||
update();
|
||||
}
|
||||
|
||||
public void setTransientFpError(boolean transientFpError) {
|
||||
mTransientFpError = transientFpError;
|
||||
update();
|
||||
@@ -126,27 +134,33 @@ public class LockIcon extends KeyguardAffordanceView {
|
||||
boolean trustHidden = anyFingerprintIcon;
|
||||
if (state != mLastState || mDeviceInteractive != mLastDeviceInteractive
|
||||
|| mScreenOn != mLastScreenOn || force) {
|
||||
boolean isAnim = true;
|
||||
int iconRes = getAnimationResForTransition(mLastState, state, mLastDeviceInteractive,
|
||||
int iconAnimRes =
|
||||
getAnimationResForTransition(mLastState, state, mLastDeviceInteractive,
|
||||
mDeviceInteractive, mLastScreenOn, mScreenOn);
|
||||
if (iconRes == R.drawable.lockscreen_fingerprint_draw_off_animation) {
|
||||
boolean isAnim = iconAnimRes != -1;
|
||||
if (iconAnimRes == R.drawable.lockscreen_fingerprint_draw_off_animation) {
|
||||
anyFingerprintIcon = true;
|
||||
useAdditionalPadding = true;
|
||||
trustHidden = true;
|
||||
} else if (iconRes == R.drawable.trusted_state_to_error_animation) {
|
||||
} else if (iconAnimRes == R.drawable.trusted_state_to_error_animation) {
|
||||
anyFingerprintIcon = true;
|
||||
useAdditionalPadding = false;
|
||||
trustHidden = true;
|
||||
} else if (iconRes == R.drawable.error_to_trustedstate_animation) {
|
||||
} else if (iconAnimRes == R.drawable.error_to_trustedstate_animation) {
|
||||
anyFingerprintIcon = true;
|
||||
useAdditionalPadding = false;
|
||||
trustHidden = false;
|
||||
}
|
||||
if (iconRes == -1) {
|
||||
iconRes = getIconForState(state, mScreenOn, mDeviceInteractive);
|
||||
isAnim = false;
|
||||
|
||||
Drawable icon;
|
||||
if (isAnim) {
|
||||
// Load the animation resource.
|
||||
icon = mContext.getDrawable(iconAnimRes);
|
||||
} else {
|
||||
// Load the static icon resource based on the current state.
|
||||
icon = getIconForState(state, mScreenOn, mDeviceInteractive);
|
||||
}
|
||||
Drawable icon = mContext.getDrawable(iconRes);
|
||||
|
||||
final AnimatedVectorDrawable animation = icon instanceof AnimatedVectorDrawable
|
||||
? (AnimatedVectorDrawable) icon
|
||||
: null;
|
||||
@@ -175,7 +189,7 @@ public class LockIcon extends KeyguardAffordanceView {
|
||||
animation.start();
|
||||
}
|
||||
|
||||
if (iconRes == R.drawable.lockscreen_fingerprint_draw_off_animation) {
|
||||
if (iconAnimRes == R.drawable.lockscreen_fingerprint_draw_off_animation) {
|
||||
removeCallbacks(mDrawOffTimeout);
|
||||
postDelayed(mDrawOffTimeout, FP_DRAW_OFF_TIMEOUT);
|
||||
} else {
|
||||
@@ -225,25 +239,38 @@ public class LockIcon extends KeyguardAffordanceView {
|
||||
mAccessibilityController = accessibilityController;
|
||||
}
|
||||
|
||||
private int getIconForState(int state, boolean screenOn, boolean deviceInteractive) {
|
||||
private Drawable getIconForState(int state, boolean screenOn, boolean deviceInteractive) {
|
||||
int iconRes;
|
||||
switch (state) {
|
||||
case STATE_LOCKED:
|
||||
return R.drawable.ic_lock_24dp;
|
||||
iconRes = R.drawable.ic_lock_24dp;
|
||||
break;
|
||||
case STATE_LOCK_OPEN:
|
||||
return R.drawable.ic_lock_open_24dp;
|
||||
if (mUnlockMethodCache.isTrustManaged() && mUnlockMethodCache.isTrusted()
|
||||
&& mUserAvatarIcon != null) {
|
||||
return mUserAvatarIcon;
|
||||
} else {
|
||||
iconRes = R.drawable.ic_lock_open_24dp;
|
||||
}
|
||||
break;
|
||||
case STATE_FACE_UNLOCK:
|
||||
return com.android.internal.R.drawable.ic_account_circle;
|
||||
iconRes = com.android.internal.R.drawable.ic_account_circle;
|
||||
break;
|
||||
case STATE_FINGERPRINT:
|
||||
// If screen is off and device asleep, use the draw on animation so the first frame
|
||||
// gets drawn.
|
||||
return screenOn && deviceInteractive
|
||||
iconRes = screenOn && deviceInteractive
|
||||
? R.drawable.ic_fingerprint
|
||||
: R.drawable.lockscreen_fingerprint_draw_on_animation;
|
||||
break;
|
||||
case STATE_FINGERPRINT_ERROR:
|
||||
return R.drawable.ic_fingerprint_error;
|
||||
iconRes = R.drawable.ic_fingerprint_error;
|
||||
break;
|
||||
default:
|
||||
throw new IllegalArgumentException();
|
||||
}
|
||||
|
||||
return mContext.getDrawable(iconRes);
|
||||
}
|
||||
|
||||
private int getAnimationResForTransition(int oldState, int newState,
|
||||
|
||||
@@ -801,7 +801,8 @@ public class PhoneStatusBar extends BaseStatusBar implements DemoMode,
|
||||
(KeyguardStatusView) mStatusBarWindow.findViewById(R.id.keyguard_status_view);
|
||||
mKeyguardBottomArea =
|
||||
(KeyguardBottomAreaView) mStatusBarWindow.findViewById(R.id.keyguard_bottom_area);
|
||||
mKeyguardIndicationController = new KeyguardIndicationController(mContext,
|
||||
mKeyguardIndicationController =
|
||||
SystemUIFactory.getInstance().createKeyguardIndicationController(mContext,
|
||||
(ViewGroup) mStatusBarWindow.findViewById(R.id.keyguard_indication_area),
|
||||
mKeyguardBottomArea.getLockIcon());
|
||||
mKeyguardBottomArea.setKeyguardIndicationController(mKeyguardIndicationController);
|
||||
@@ -1179,6 +1180,8 @@ public class PhoneStatusBar extends BaseStatusBar implements DemoMode,
|
||||
mFingerprintUnlockController);
|
||||
mKeyguardIndicationController.setStatusBarKeyguardViewManager(
|
||||
mStatusBarKeyguardViewManager);
|
||||
mKeyguardIndicationController.setUserInfoController(
|
||||
Dependency.get(UserInfoController.class));
|
||||
mFingerprintUnlockController.setStatusBarKeyguardViewManager(mStatusBarKeyguardViewManager);
|
||||
mIconPolicy.setStatusBarKeyguardViewManager(mStatusBarKeyguardViewManager);
|
||||
mRemoteInputController.addCallback(mStatusBarKeyguardViewManager);
|
||||
|
||||
Reference in New Issue
Block a user