diff options
Diffstat (limited to 'packages/SystemUI/src')
3 files changed, 69 insertions, 33 deletions
diff --git a/packages/SystemUI/src/com/android/systemui/statusbar/KeyguardIndicationController.java b/packages/SystemUI/src/com/android/systemui/statusbar/KeyguardIndicationController.java index 07a055c..31c94f7 100644 --- a/packages/SystemUI/src/com/android/systemui/statusbar/KeyguardIndicationController.java +++ b/packages/SystemUI/src/com/android/systemui/statusbar/KeyguardIndicationController.java @@ -26,6 +26,7 @@ import android.content.BroadcastReceiver; import android.content.Context; import android.content.Intent; import android.content.IntentFilter; +import android.content.res.Resources; import android.graphics.Color; import android.os.BatteryManager; import android.os.BatteryStats; @@ -45,6 +46,7 @@ import android.view.View; public class KeyguardIndicationController { private static final String TAG = "KeyguardIndicationController"; + private static final boolean DEBUG_CHARGING_CURRENT = false; private static final int MSG_HIDE_TRANSIENT = 1; @@ -52,6 +54,9 @@ public class KeyguardIndicationController { private final KeyguardIndicationTextView mTextView; private final IBatteryStats mBatteryInfo; + private final int mSlowThreshold; + private final int mFastThreshold; + private String mRestingIndication; private String mTransientIndication; private int mTransientTextColor; @@ -59,11 +64,18 @@ public class KeyguardIndicationController { private boolean mPowerPluggedIn; private boolean mPowerCharged; + private int mChargingSpeed; + private int mChargingCurrent; public KeyguardIndicationController(Context context, KeyguardIndicationTextView textView) { mContext = context; mTextView = textView; + Resources res = context.getResources(); + mSlowThreshold = res.getInteger(R.integer.config_chargingSlowlyThreshold); + mFastThreshold = res.getInteger(R.integer.config_chargingFastThreshold); + + mBatteryInfo = IBatteryStats.Stub.asInterface( ServiceManager.getService(BatteryStats.SERVICE_NAME)); KeyguardUpdateMonitor.getInstance(context).registerCallback(mUpdateMonitor); @@ -150,7 +162,11 @@ public class KeyguardIndicationController { return mTransientIndication; } if (mPowerPluggedIn) { - return computePowerIndication(); + String indication = computePowerIndication(); + if (DEBUG_CHARGING_CURRENT) { + indication += ", " + (mChargingCurrent / 1000) + " mA"; + } + return indication; } return mRestingIndication; } @@ -174,7 +190,19 @@ public class KeyguardIndicationController { } // Fall back to simple charging label. - return mContext.getResources().getString(R.string.keyguard_plugged_in); + int chargingId; + switch (mChargingSpeed) { + case KeyguardUpdateMonitor.BatteryStatus.CHARGING_FAST: + chargingId = R.string.keyguard_plugged_in_charging_fast; + break; + case KeyguardUpdateMonitor.BatteryStatus.CHARGING_SLOWLY: + chargingId = R.string.keyguard_plugged_in_charging_slowly; + break; + default: + chargingId = R.string.keyguard_plugged_in; + break; + } + return mContext.getResources().getString(chargingId); } KeyguardUpdateMonitorCallback mUpdateMonitor = new KeyguardUpdateMonitorCallback() { @@ -184,6 +212,8 @@ public class KeyguardIndicationController { || status.status == BatteryManager.BATTERY_STATUS_FULL; mPowerPluggedIn = status.isPluggedIn() && isChargingOrFull; mPowerCharged = status.isCharged(); + mChargingCurrent = status.maxChargingCurrent; + mChargingSpeed = status.getChargingSpeed(mSlowThreshold, mFastThreshold); updateIndication(); } }; diff --git a/packages/SystemUI/src/com/android/systemui/statusbar/phone/KeyguardBottomAreaView.java b/packages/SystemUI/src/com/android/systemui/statusbar/phone/KeyguardBottomAreaView.java index 6627360..8e5d4d6 100644 --- a/packages/SystemUI/src/com/android/systemui/statusbar/phone/KeyguardBottomAreaView.java +++ b/packages/SystemUI/src/com/android/systemui/statusbar/phone/KeyguardBottomAreaView.java @@ -644,6 +644,16 @@ public class KeyguardBottomAreaView extends FrameLayout implements View.OnClickL } @Override + public void onScreenTurnedOn() { + mLockIcon.setScreenOn(true); + } + + @Override + public void onScreenTurnedOff() { + mLockIcon.setScreenOn(false); + } + + @Override public void onKeyguardVisibilityChanged(boolean showing) { mLockIcon.update(); } diff --git a/packages/SystemUI/src/com/android/systemui/statusbar/phone/LockIcon.java b/packages/SystemUI/src/com/android/systemui/statusbar/phone/LockIcon.java index 06d2fca..463abfc 100644 --- a/packages/SystemUI/src/com/android/systemui/statusbar/phone/LockIcon.java +++ b/packages/SystemUI/src/com/android/systemui/statusbar/phone/LockIcon.java @@ -34,12 +34,6 @@ import com.android.systemui.statusbar.policy.AccessibilityController; */ public class LockIcon extends KeyguardAffordanceView { - /** - * Delay animations a bit when the screen just turned on as a heuristic to start them after - * the screen has actually turned on. - */ - private static final long ANIM_DELAY_AFTER_SCREEN_ON = 250; - private static final int STATE_LOCKED = 0; private static final int STATE_LOCK_OPEN = 1; private static final int STATE_FACE_UNLOCK = 2; @@ -50,6 +44,8 @@ public class LockIcon extends KeyguardAffordanceView { private boolean mLastDeviceInteractive; private boolean mTransientFpError; private boolean mDeviceInteractive; + private boolean mScreenOn; + private boolean mLastScreenOn; private final TrustDrawable mTrustDrawable; private final UnlockMethodCache mUnlockMethodCache; private AccessibilityController mAccessibilityController; @@ -88,6 +84,11 @@ public class LockIcon extends KeyguardAffordanceView { update(); } + public void setScreenOn(boolean screenOn) { + mScreenOn = screenOn; + update(); + } + public void update() { boolean visible = isShown() && KeyguardUpdateMonitor.getInstance(mContext).isDeviceInteractive(); @@ -96,20 +97,20 @@ public class LockIcon extends KeyguardAffordanceView { } else { mTrustDrawable.stop(); } - if (!visible) { - return; - } // TODO: Real icon for facelock. int state = getState(); boolean anyFingerprintIcon = state == STATE_FINGERPRINT || state == STATE_FINGERPRINT_ERROR; - if (state != mLastState || mDeviceInteractive != mLastDeviceInteractive) { + if (state != mLastState || mDeviceInteractive != mLastDeviceInteractive + || mScreenOn != mLastScreenOn) { + boolean isAnim = true; int iconRes = getAnimationResForTransition(mLastState, state, mLastDeviceInteractive, - mDeviceInteractive); + mDeviceInteractive, mLastScreenOn, mScreenOn); if (iconRes == R.drawable.lockscreen_fingerprint_draw_off_animation) { anyFingerprintIcon = true; } if (iconRes == -1) { - iconRes = getIconForState(state); + iconRes = getIconForState(state, mScreenOn, mDeviceInteractive); + isAnim = false; } Drawable icon = mContext.getDrawable(iconRes); final AnimatedVectorDrawable animation = icon instanceof AnimatedVectorDrawable @@ -135,23 +136,12 @@ public class LockIcon extends KeyguardAffordanceView { : R.string.accessibility_unlock_button); setContentDescription(contentDescription); mHasFingerPrintIcon = anyFingerprintIcon; - if (animation != null) { - - // If we play the draw on animation, delay it by one frame when the screen is - // actually turned on. - if (iconRes == R.drawable.lockscreen_fingerprint_draw_on_animation) { - postOnAnimationDelayed(new Runnable() { - @Override - public void run() { - animation.start(); - } - }, ANIM_DELAY_AFTER_SCREEN_ON); - } else { - animation.start(); - } + if (animation != null && isAnim) { + animation.start(); } mLastState = state; mLastDeviceInteractive = mDeviceInteractive; + mLastScreenOn = mScreenOn; } // Hide trust circle when fingerprint is running. @@ -192,7 +182,7 @@ public class LockIcon extends KeyguardAffordanceView { mAccessibilityController = accessibilityController; } - private int getIconForState(int state) { + private int getIconForState(int state, boolean screenOn, boolean deviceInteractive) { switch (state) { case STATE_LOCKED: return R.drawable.ic_lock_24dp; @@ -201,7 +191,11 @@ public class LockIcon extends KeyguardAffordanceView { case STATE_FACE_UNLOCK: return com.android.internal.R.drawable.ic_account_circle; case STATE_FINGERPRINT: - return R.drawable.ic_fingerprint; + // If screen is off and device asleep, use the draw on animation so the first frame + // gets drawn. + return screenOn && deviceInteractive + ? R.drawable.ic_fingerprint + : R.drawable.lockscreen_fingerprint_draw_on_animation; case STATE_FINGERPRINT_ERROR: return R.drawable.ic_fingerprint_error; default: @@ -209,8 +203,9 @@ public class LockIcon extends KeyguardAffordanceView { } } - private int getAnimationResForTransition(int oldState, int newState, boolean oldScreenOn, - boolean screenOn) { + private int getAnimationResForTransition(int oldState, int newState, + boolean oldDeviceInteractive, boolean deviceInteractive, + boolean oldScreenOn, boolean screenOn) { if (oldState == STATE_FINGERPRINT && newState == STATE_FINGERPRINT_ERROR) { return R.drawable.lockscreen_fingerprint_fp_to_error_state_animation; } else if (oldState == STATE_FINGERPRINT_ERROR && newState == STATE_FINGERPRINT) { @@ -218,7 +213,8 @@ public class LockIcon extends KeyguardAffordanceView { } else if (oldState == STATE_FINGERPRINT && newState == STATE_LOCK_OPEN && !mUnlockMethodCache.isTrusted()) { return R.drawable.lockscreen_fingerprint_draw_off_animation; - } else if (newState == STATE_FINGERPRINT && !oldScreenOn && screenOn) { + } else if (newState == STATE_FINGERPRINT && (!oldScreenOn && screenOn && deviceInteractive + || screenOn && !oldDeviceInteractive && deviceInteractive)) { return R.drawable.lockscreen_fingerprint_draw_on_animation; } else { return -1; |
