diff options
author | Jorim Jaggi <jjaggi@google.com> | 2015-07-10 14:24:44 -0700 |
---|---|---|
committer | Jorim Jaggi <jjaggi@google.com> | 2015-07-28 23:02:54 +0000 |
commit | 0d210f6395072db4a4c53d4cb8fac4a59a3965b4 (patch) | |
tree | 7b63f0a48ec2b0fa8b25604efb17ccade833b568 /packages | |
parent | 751a96a040ada09199ca3356d9a515ec090d1237 (diff) | |
download | frameworks_base-0d210f6395072db4a4c53d4cb8fac4a59a3965b4.zip frameworks_base-0d210f6395072db4a4c53d4cb8fac4a59a3965b4.tar.gz frameworks_base-0d210f6395072db4a4c53d4cb8fac4a59a3965b4.tar.bz2 |
Animation for touch, wake and unlock
- Add callback to inform SysUI when the screen has been unblocked
and turned on.
- Cleanup inconsistent messaging about device interactive/screen on
and off.
- Add callbacks to inform SysUI about screen states
- Implement a quick fade for the scrim after touch, wake, and unlock.
First, start with a black scrim on top of everything, and then fade
it out.
- Make sure we play the normal unlock animation when device is pulsing
- Override navigation bar animations for touch, wake and unlock: Fade
in the same manner as the scrim.
Bug: 22571198
Bug: 21855614
Change-Id: I8ff08d72cced1e0f03c78d71ff710d8a4f6b848c
Diffstat (limited to 'packages')
17 files changed, 321 insertions, 123 deletions
diff --git a/packages/Keyguard/src/com/android/keyguard/CarrierText.java b/packages/Keyguard/src/com/android/keyguard/CarrierText.java index e89caf7..159ac4c 100644 --- a/packages/Keyguard/src/com/android/keyguard/CarrierText.java +++ b/packages/Keyguard/src/com/android/keyguard/CarrierText.java @@ -23,7 +23,6 @@ import java.util.Objects; import android.content.Context; import android.content.Intent; import android.content.IntentFilter; -import android.content.res.Resources; import android.content.res.TypedArray; import android.net.ConnectivityManager; import android.net.wifi.WifiManager; @@ -59,11 +58,11 @@ public class CarrierText extends TextView { updateCarrierText(); } - public void onScreenTurnedOff(int why) { + public void onFinishedGoingToSleep(int why) { setSelected(false); }; - public void onScreenTurnedOn() { + public void onStartedWakingUp() { setSelected(true); }; }; @@ -193,8 +192,8 @@ public class CarrierText extends TextView { super.onFinishInflate(); mSeparator = getResources().getString( com.android.internal.R.string.kg_text_message_separator); - final boolean screenOn = KeyguardUpdateMonitor.getInstance(mContext).isScreenOn(); - setSelected(screenOn); // Allow marquee to work. + boolean shouldMarquee = KeyguardUpdateMonitor.getInstance(mContext).isDeviceInteractive(); + setSelected(shouldMarquee); // Allow marquee to work. } @Override diff --git a/packages/Keyguard/src/com/android/keyguard/KeyguardMessageArea.java b/packages/Keyguard/src/com/android/keyguard/KeyguardMessageArea.java index 301b171..2951af9 100644 --- a/packages/Keyguard/src/com/android/keyguard/KeyguardMessageArea.java +++ b/packages/Keyguard/src/com/android/keyguard/KeyguardMessageArea.java @@ -58,10 +58,10 @@ class KeyguardMessageArea extends TextView implements SecurityMessageDisplay { }; private KeyguardUpdateMonitorCallback mInfoCallback = new KeyguardUpdateMonitorCallback() { - public void onScreenTurnedOff(int why) { + public void onFinishedGoingToSleep(int why) { setSelected(false); }; - public void onScreenTurnedOn() { + public void onStartedWakingUp() { setSelected(true); }; }; @@ -126,8 +126,8 @@ class KeyguardMessageArea extends TextView implements SecurityMessageDisplay { @Override protected void onFinishInflate() { - final boolean screenOn = KeyguardUpdateMonitor.getInstance(mContext).isScreenOn(); - setSelected(screenOn); // This is required to ensure marquee works + boolean shouldMarquee = KeyguardUpdateMonitor.getInstance(mContext).isDeviceInteractive(); + setSelected(shouldMarquee); // This is required to ensure marquee works } private void securityMessageChanged(CharSequence message) { diff --git a/packages/Keyguard/src/com/android/keyguard/KeyguardStatusView.java b/packages/Keyguard/src/com/android/keyguard/KeyguardStatusView.java index 4e9621a..f95b0ae 100644 --- a/packages/Keyguard/src/com/android/keyguard/KeyguardStatusView.java +++ b/packages/Keyguard/src/com/android/keyguard/KeyguardStatusView.java @@ -67,12 +67,12 @@ public class KeyguardStatusView extends GridLayout { } @Override - public void onScreenTurnedOn() { + public void onStartedWakingUp() { setEnableMarquee(true); } @Override - public void onScreenTurnedOff(int why) { + public void onFinishedGoingToSleep(int why) { setEnableMarquee(false); } @@ -113,8 +113,8 @@ public class KeyguardStatusView extends GridLayout { mClockView.setShowCurrentUserTime(true); mOwnerInfo = (TextView) findViewById(R.id.owner_info); - final boolean screenOn = KeyguardUpdateMonitor.getInstance(mContext).isScreenOn(); - setEnableMarquee(screenOn); + boolean shouldMarquee = KeyguardUpdateMonitor.getInstance(mContext).isDeviceInteractive(); + setEnableMarquee(shouldMarquee); refresh(); updateOwnerInfo(); diff --git a/packages/Keyguard/src/com/android/keyguard/KeyguardUpdateMonitor.java b/packages/Keyguard/src/com/android/keyguard/KeyguardUpdateMonitor.java index ec185eb..9df0818 100644 --- a/packages/Keyguard/src/com/android/keyguard/KeyguardUpdateMonitor.java +++ b/packages/Keyguard/src/com/android/keyguard/KeyguardUpdateMonitor.java @@ -102,6 +102,23 @@ public class KeyguardUpdateMonitor implements TrustManager.TrustListener { = "com.android.facelock.FACE_UNLOCK_STOPPED"; private static final String FINGERPRINT_WAKE_LOCK_NAME = "wake-and-unlock wakelock"; + /** + * Mode in which we don't need to wake up the device when we get a fingerprint. + */ + private static final int FP_WAKE_NONE = 0; + + /** + * Mode in which we wake up the device, and directly dismiss Keyguard. Active when we acquire + * a fingerprint while the screen is off and the device was sleeping. + */ + private static final int FP_WAKE_DIRECT_UNLOCK = 1; + + /** + * Mode in which we wake up the device, but play the normal dismiss animation. Active when we + * acquire a fingerprint pulsing in doze mode. + * */ + private static final int FP_WAKE_WAKE_TO_BOUNCER = 2; + // Callback messages private static final int MSG_TIME_UPDATE = 301; private static final int MSG_BATTERY_UPDATE = 302; @@ -117,8 +134,8 @@ public class KeyguardUpdateMonitor implements TrustManager.TrustListener { private static final int MSG_USER_SWITCH_COMPLETE = 314; private static final int MSG_USER_INFO_CHANGED = 317; private static final int MSG_REPORT_EMERGENCY_CALL_ACTION = 318; - private static final int MSG_SCREEN_TURNED_ON = 319; - private static final int MSG_SCREEN_TURNED_OFF = 320; + private static final int MSG_STARTED_WAKING_UP = 319; + private static final int MSG_FINISHED_GOING_TO_SLEEP = 320; private static final int MSG_KEYGUARD_BOUNCER_CHANGED = 322; private static final int MSG_FACE_UNLOCK_STATE_CHANGED = 327; private static final int MSG_SIM_SUBSCRIPTION_INFO_CHANGED = 328; @@ -155,6 +172,7 @@ public class KeyguardUpdateMonitor implements TrustManager.TrustListener { private boolean mSwitchingUser; + private boolean mDeviceInteractive; private boolean mScreenOn; private SubscriptionManager mSubscriptionManager; private List<SubscriptionInfo> mSubscriptionInfo; @@ -211,11 +229,11 @@ public class KeyguardUpdateMonitor implements TrustManager.TrustListener { case MSG_REPORT_EMERGENCY_CALL_ACTION: handleReportEmergencyCallAction(); break; - case MSG_SCREEN_TURNED_OFF: - handleScreenTurnedOff(msg.arg1); + case MSG_FINISHED_GOING_TO_SLEEP: + handleFinishedGoingToSleep(msg.arg1); break; - case MSG_SCREEN_TURNED_ON: - handleScreenTurnedOn(); + case MSG_STARTED_WAKING_UP: + handleStartedWakingUp(); break; case MSG_FACE_UNLOCK_STATE_CHANGED: handleFaceUnlockStateChanged(msg.arg1 != 0, msg.arg2); @@ -248,7 +266,7 @@ public class KeyguardUpdateMonitor implements TrustManager.TrustListener { private static int sCurrentUser; - private boolean mWakeAndUnlocking; + private int mFpWakeMode; public synchronized static void setCurrentUser(int currentUser) { sCurrentUser = currentUser; @@ -371,19 +389,21 @@ public class KeyguardUpdateMonitor implements TrustManager.TrustListener { if (acquireInfo != FingerprintManager.FINGERPRINT_ACQUIRED_GOOD) { return; } - if (!mScreenOn) { + if (!mDeviceInteractive && !mScreenOn) { releaseFingerprintWakeLock(); mWakeLock = mPowerManager.newWakeLock( PowerManager.PARTIAL_WAKE_LOCK, FINGERPRINT_WAKE_LOCK_NAME); mWakeLock.acquire(); - mWakeAndUnlocking = true; + mFpWakeMode = FP_WAKE_DIRECT_UNLOCK; if (DEBUG_FP_WAKELOCK) { Log.i(TAG, "fingerprint acquired, grabbing fp wakelock"); } mHandler.postDelayed(mReleaseFingerprintWakeLockRunnable, FINGERPRINT_WAKELOCK_TIMEOUT_MS); + } else if (!mDeviceInteractive) { + mFpWakeMode = FP_WAKE_WAKE_TO_BOUNCER; } else { - mWakeAndUnlocking = false; + mFpWakeMode = FP_WAKE_NONE; } } @@ -409,7 +429,7 @@ public class KeyguardUpdateMonitor implements TrustManager.TrustListener { } private void handleFingerprintAuthenticated() { - if (mWakeAndUnlocking) { + if (mFpWakeMode == FP_WAKE_WAKE_TO_BOUNCER || mFpWakeMode == FP_WAKE_DIRECT_UNLOCK) { if (DEBUG_FP_WAKELOCK) { Log.i(TAG, "fp wakelock: Authenticated, waking up..."); } @@ -428,7 +448,7 @@ public class KeyguardUpdateMonitor implements TrustManager.TrustListener { Log.d(TAG, "Fingerprint disabled by DPM for userId: " + userId); return; } - onFingerprintAuthenticated(userId, mWakeAndUnlocking); + onFingerprintAuthenticated(userId, mFpWakeMode == FP_WAKE_DIRECT_UNLOCK); } finally { setFingerprintRunningDetectionRunning(false); } @@ -749,24 +769,24 @@ public class KeyguardUpdateMonitor implements TrustManager.TrustListener { return sInstance; } - protected void handleScreenTurnedOn() { + protected void handleStartedWakingUp() { updateFingerprintListeningState(); final int count = mCallbacks.size(); for (int i = 0; i < count; i++) { KeyguardUpdateMonitorCallback cb = mCallbacks.get(i).get(); if (cb != null) { - cb.onScreenTurnedOn(); + cb.onStartedWakingUp(); } } } - protected void handleScreenTurnedOff(int arg1) { + protected void handleFinishedGoingToSleep(int arg1) { clearFingerprintRecognized(); final int count = mCallbacks.size(); for (int i = 0; i < count; i++) { KeyguardUpdateMonitorCallback cb = mCallbacks.get(i).get(); if (cb != null) { - cb.onScreenTurnedOff(arg1); + cb.onFinishedGoingToSleep(arg1); } } updateFingerprintListeningState(); @@ -1428,22 +1448,34 @@ public class KeyguardUpdateMonitor implements TrustManager.TrustListener { // TODO: use these callbacks elsewhere in place of the existing notifyScreen*() // (KeyguardViewMediator, KeyguardHostView) + public void dispatchStartedWakingUp() { + synchronized (this) { + mDeviceInteractive = true; + } + mHandler.sendEmptyMessage(MSG_STARTED_WAKING_UP); + } + + public void dispatchFinishedGoingToSleep(int why) { + synchronized(this) { + mDeviceInteractive = false; + } + mHandler.sendMessage(mHandler.obtainMessage(MSG_FINISHED_GOING_TO_SLEEP, why, 0)); + } + public void dispatchScreenTurnedOn() { synchronized (this) { mScreenOn = true; } - mHandler.sendEmptyMessage(MSG_SCREEN_TURNED_ON); } - public void dispatchScreenTurnedOff(int why) { + public void dispatchScreenTurnedOff() { synchronized(this) { mScreenOn = false; } - mHandler.sendMessage(mHandler.obtainMessage(MSG_SCREEN_TURNED_OFF, why, 0)); } - public boolean isScreenOn() { - return mScreenOn; + public boolean isDeviceInteractive() { + return mDeviceInteractive; } /** diff --git a/packages/Keyguard/src/com/android/keyguard/KeyguardUpdateMonitorCallback.java b/packages/Keyguard/src/com/android/keyguard/KeyguardUpdateMonitorCallback.java index 9fd8d30..0cdf999 100644 --- a/packages/Keyguard/src/com/android/keyguard/KeyguardUpdateMonitorCallback.java +++ b/packages/Keyguard/src/com/android/keyguard/KeyguardUpdateMonitorCallback.java @@ -148,17 +148,17 @@ public class KeyguardUpdateMonitorCallback { } /** - * Called when the screen turns on + * Called when the device has started waking up. */ - public void onScreenTurnedOn() { } + public void onStartedWakingUp() { } /** - * Called when the screen turns off + * Called when the device has finished going to sleep. * @param why either {@link WindowManagerPolicy#OFF_BECAUSE_OF_ADMIN}, * {@link WindowManagerPolicy#OFF_BECAUSE_OF_USER}, or * {@link WindowManagerPolicy#OFF_BECAUSE_OF_TIMEOUT}. */ - public void onScreenTurnedOff(int why) { } + public void onFinishedGoingToSleep(int why) { } /** * Called when trust changes for a user. diff --git a/packages/SystemUI/res/anim/navbar_fade_in.xml b/packages/SystemUI/res/anim/navbar_fade_in.xml new file mode 100644 index 0000000..e3429e6 --- /dev/null +++ b/packages/SystemUI/res/anim/navbar_fade_in.xml @@ -0,0 +1,22 @@ +<?xml version="1.0" encoding="utf-8"?> +<!-- + ~ Copyright (C) 2015 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 + --> + +<alpha xmlns:android="http://schemas.android.com/apk/res/android" + android:fromAlpha="0.0" + android:toAlpha="1.0" + android:interpolator="@android:interpolator/linear_out_slow_in" + android:duration="200"/> diff --git a/packages/SystemUI/res/values/styles.xml b/packages/SystemUI/res/values/styles.xml index 1889862..8241ddf 100644 --- a/packages/SystemUI/res/values/styles.xml +++ b/packages/SystemUI/res/values/styles.xml @@ -206,6 +206,11 @@ <item name="android:windowExitAnimation">@*android:anim/shrink_fade_out_from_bottom</item> </style> + <style name="Animation.NavigationBarFadeIn"> + <item name="android:windowEnterAnimation">@anim/navbar_fade_in</item> + <item name="android:windowExitAnimation">@null</item> + </style> + <!-- Standard animations for hiding and showing the status bar. --> <style name="Animation.StatusBar"> </style> diff --git a/packages/SystemUI/src/com/android/systemui/doze/DozeLog.java b/packages/SystemUI/src/com/android/systemui/doze/DozeLog.java index 3f72125..9eb768c 100644 --- a/packages/SystemUI/src/com/android/systemui/doze/DozeLog.java +++ b/packages/SystemUI/src/com/android/systemui/doze/DozeLog.java @@ -244,12 +244,12 @@ public class DozeLog { } @Override - public void onScreenTurnedOn() { + public void onStartedWakingUp() { traceScreenOn(); } @Override - public void onScreenTurnedOff(int why) { + public void onFinishedGoingToSleep(int why) { traceScreenOff(why); } diff --git a/packages/SystemUI/src/com/android/systemui/keyguard/KeyguardService.java b/packages/SystemUI/src/com/android/systemui/keyguard/KeyguardService.java index 9f21dbe..d78800f 100644 --- a/packages/SystemUI/src/com/android/systemui/keyguard/KeyguardService.java +++ b/packages/SystemUI/src/com/android/systemui/keyguard/KeyguardService.java @@ -132,6 +132,18 @@ public class KeyguardService extends Service { } @Override // Binder interface + public void onScreenTurnedOn() { + checkPermission(); + mKeyguardViewMediator.onScreenTurnedOn(); + } + + @Override // Binder interface + public void onScreenTurnedOff() { + checkPermission(); + mKeyguardViewMediator.onScreenTurnedOff(); + } + + @Override // Binder interface public void setKeyguardEnabled(boolean enabled) { checkPermission(); mKeyguardViewMediator.setKeyguardEnabled(enabled); diff --git a/packages/SystemUI/src/com/android/systemui/keyguard/KeyguardViewMediator.java b/packages/SystemUI/src/com/android/systemui/keyguard/KeyguardViewMediator.java index 7d72dab..9f86a52 100644 --- a/packages/SystemUI/src/com/android/systemui/keyguard/KeyguardViewMediator.java +++ b/packages/SystemUI/src/com/android/systemui/keyguard/KeyguardViewMediator.java @@ -41,7 +41,6 @@ import android.os.PowerManager; import android.os.RemoteException; import android.os.SystemClock; import android.os.SystemProperties; -import android.os.Trace; import android.os.UserHandle; import android.os.UserManager; import android.provider.Settings; @@ -138,7 +137,7 @@ public class KeyguardViewMediator extends SystemUI { private static final int HIDE = 3; private static final int RESET = 4; private static final int VERIFY_UNLOCK = 5; - private static final int NOTIFY_SCREEN_OFF = 6; + private static final int NOTIFY_FINISHED_GOING_TO_SLEEP = 6; private static final int NOTIFY_SCREEN_TURNING_ON = 7; private static final int KEYGUARD_DONE = 9; private static final int KEYGUARD_DONE_DRAWING = 10; @@ -150,6 +149,8 @@ public class KeyguardViewMediator extends SystemUI { private static final int ON_ACTIVITY_DRAWN = 19; private static final int KEYGUARD_DONE_PENDING_TIMEOUT = 20; private static final int NOTIFY_STARTED_WAKING_UP = 21; + private static final int NOTIFY_SCREEN_TURNED_ON = 22; + private static final int NOTIFY_SCREEN_TURNED_OFF = 23; /** * The default amount of time we stay awake (used for all key input) @@ -467,12 +468,13 @@ public class KeyguardViewMediator extends SystemUI { mStatusBarKeyguardViewManager.notifyKeyguardAuthenticated(); } } else { - if (wakeAndUnlocking && unlockingWithFingerprintAllowed) { + if (wakeAndUnlocking && mShowing && unlockingWithFingerprintAllowed) { mWakeAndUnlocking = true; + mStatusBarKeyguardViewManager.setWakeAndUnlocking(); keyguardDone(true, true); - } else { + } else if (mShowing && mDeviceInteractive) { if (wakeAndUnlocking) { - mStatusBarKeyguardViewManager.notifyScreenWakeUpRequested(); + mStatusBarKeyguardViewManager.notifyDeviceWakeUpRequested(); } mStatusBarKeyguardViewManager.animateCollapsePanels( FINGERPRINT_COLLAPSE_SPEEDUP_FACTOR); @@ -702,7 +704,7 @@ public class KeyguardViewMediator extends SystemUI { resetKeyguardDonePendingLocked(); mHideAnimationRun = false; - notifyScreenOffLocked(); + notifyFinishedGoingToSleep(); if (mPendingReset) { resetStateLocked(); @@ -713,7 +715,7 @@ public class KeyguardViewMediator extends SystemUI { mPendingLock = false; } } - KeyguardUpdateMonitor.getInstance(mContext).dispatchScreenTurnedOff(why); + KeyguardUpdateMonitor.getInstance(mContext).dispatchFinishedGoingToSleep(why); } private void doKeyguardLaterLocked() { @@ -778,12 +780,22 @@ public class KeyguardViewMediator extends SystemUI { if (DEBUG) Log.d(TAG, "onStartedWakingUp, seq = " + mDelayedShowingSequence); notifyStartedWakingUp(); } - KeyguardUpdateMonitor.getInstance(mContext).dispatchScreenTurnedOn(); + KeyguardUpdateMonitor.getInstance(mContext).dispatchStartedWakingUp(); maybeSendUserPresentBroadcast(); } public void onScreenTurningOn(IKeyguardDrawnCallback callback) { - notifyScreenOnLocked(callback); + notifyScreenOn(callback); + } + + public void onScreenTurnedOn() { + notifyScreenTurnedOn(); + mUpdateMonitor.dispatchScreenTurnedOn(); + } + + public void onScreenTurnedOff() { + notifyScreenTurnedOff(); + mUpdateMonitor.dispatchScreenTurnedOff(); } private void maybeSendUserPresentBroadcast() { @@ -1101,15 +1113,9 @@ public class KeyguardViewMediator extends SystemUI { mHandler.sendEmptyMessage(VERIFY_UNLOCK); } - - /** - * Send a message to keyguard telling it the screen just turned on. - * @see #onScreenTurnedOff(int) - * @see #handleNotifyScreenOff - */ - private void notifyScreenOffLocked() { - if (DEBUG) Log.d(TAG, "notifyScreenOffLocked"); - mHandler.sendEmptyMessage(NOTIFY_SCREEN_OFF); + private void notifyFinishedGoingToSleep() { + if (DEBUG) Log.d(TAG, "notifyFinishedGoingToSleep"); + mHandler.sendEmptyMessage(NOTIFY_FINISHED_GOING_TO_SLEEP); } private void notifyStartedWakingUp() { @@ -1117,12 +1123,24 @@ public class KeyguardViewMediator extends SystemUI { mHandler.sendEmptyMessage(NOTIFY_STARTED_WAKING_UP); } - private void notifyScreenOnLocked(IKeyguardDrawnCallback callback) { - if (DEBUG) Log.d(TAG, "notifyScreenOnLocked"); + private void notifyScreenOn(IKeyguardDrawnCallback callback) { + if (DEBUG) Log.d(TAG, "notifyScreenOn"); Message msg = mHandler.obtainMessage(NOTIFY_SCREEN_TURNING_ON, callback); mHandler.sendMessage(msg); } + private void notifyScreenTurnedOn() { + if (DEBUG) Log.d(TAG, "notifyScreenTurnedOn"); + Message msg = mHandler.obtainMessage(NOTIFY_SCREEN_TURNED_ON); + mHandler.sendMessage(msg); + } + + private void notifyScreenTurnedOff() { + if (DEBUG) Log.d(TAG, "notifyScreenTurnedOff"); + Message msg = mHandler.obtainMessage(NOTIFY_SCREEN_TURNED_OFF); + mHandler.sendMessage(msg); + } + /** * Send message to keyguard telling it to show itself * @see #handleShow @@ -1206,12 +1224,18 @@ public class KeyguardViewMediator extends SystemUI { case VERIFY_UNLOCK: handleVerifyUnlock(); break; - case NOTIFY_SCREEN_OFF: - handleNotifyScreenOff(); + case NOTIFY_FINISHED_GOING_TO_SLEEP: + handleNotifyFinishedGoingToSleep(); break; case NOTIFY_SCREEN_TURNING_ON: handleNotifyScreenTurningOn((IKeyguardDrawnCallback) msg.obj); break; + case NOTIFY_SCREEN_TURNED_ON: + handleNotifyScreenTurnedOn(); + break; + case NOTIFY_SCREEN_TURNED_OFF: + handleNotifyScreenTurnedOff(); + break; case NOTIFY_STARTED_WAKING_UP: handleNotifyStartedWakingUp(); break; @@ -1525,20 +1549,20 @@ public class KeyguardViewMediator extends SystemUI { } /** - * Handle message sent by {@link #notifyScreenOffLocked()} - * @see #NOTIFY_SCREEN_OFF + * Handle message sent by {@link #notifyFinishedGoingToSleep()} + * @see #NOTIFY_FINISHED_GOING_TO_SLEEP */ - private void handleNotifyScreenOff() { + private void handleNotifyFinishedGoingToSleep() { synchronized (KeyguardViewMediator.this) { - if (DEBUG) Log.d(TAG, "handleNotifyScreenOff"); - mStatusBarKeyguardViewManager.onScreenTurnedOff(); + if (DEBUG) Log.d(TAG, "handleNotifyFinishedGoingToSleep"); + mStatusBarKeyguardViewManager.onFinishedGoingToSleep(); } } private void handleNotifyStartedWakingUp() { synchronized (KeyguardViewMediator.this) { if (DEBUG) Log.d(TAG, "handleNotifyWakingUp"); - mStatusBarKeyguardViewManager.onScreenTurnedOn(); + mStatusBarKeyguardViewManager.onStartedWakingUp(); } } @@ -1555,6 +1579,20 @@ public class KeyguardViewMediator extends SystemUI { } } + private void handleNotifyScreenTurnedOn() { + synchronized (this) { + if (DEBUG) Log.d(TAG, "handleNotifyScreenTurnedOn"); + mStatusBarKeyguardViewManager.onScreenTurnedOn(); + } + } + + private void handleNotifyScreenTurnedOff() { + synchronized (this) { + if (DEBUG) Log.d(TAG, "handleNotifyScreenTurnedOff"); + mStatusBarKeyguardViewManager.onScreenTurnedOff(); + } + } + private void notifyDrawn(final IKeyguardDrawnCallback callback) { try { callback.onDrawn(); 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 7c08efc..6627360 100644 --- a/packages/SystemUI/src/com/android/systemui/statusbar/phone/KeyguardBottomAreaView.java +++ b/packages/SystemUI/src/com/android/systemui/statusbar/phone/KeyguardBottomAreaView.java @@ -634,13 +634,13 @@ public class KeyguardBottomAreaView extends FrameLayout implements View.OnClickL } @Override - public void onScreenTurnedOn() { - mLockIcon.setScreenOn(true); + public void onStartedWakingUp() { + mLockIcon.setDeviceInteractive(true); } @Override - public void onScreenTurnedOff(int why) { - mLockIcon.setScreenOn(false); + public void onFinishedGoingToSleep(int why) { + mLockIcon.setDeviceInteractive(false); } @Override 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 d93f7c2..06d2fca 100644 --- a/packages/SystemUI/src/com/android/systemui/statusbar/phone/LockIcon.java +++ b/packages/SystemUI/src/com/android/systemui/statusbar/phone/LockIcon.java @@ -47,9 +47,9 @@ public class LockIcon extends KeyguardAffordanceView { private static final int STATE_FINGERPRINT_ERROR = 4; private int mLastState = 0; - private boolean mLastScreenOn; + private boolean mLastDeviceInteractive; private boolean mTransientFpError; - private boolean mScreenOn; + private boolean mDeviceInteractive; private final TrustDrawable mTrustDrawable; private final UnlockMethodCache mUnlockMethodCache; private AccessibilityController mAccessibilityController; @@ -83,13 +83,14 @@ public class LockIcon extends KeyguardAffordanceView { update(); } - public void setScreenOn(boolean screenOn) { - mScreenOn = screenOn; + public void setDeviceInteractive(boolean deviceInteractive) { + mDeviceInteractive = deviceInteractive; update(); } public void update() { - boolean visible = isShown() && KeyguardUpdateMonitor.getInstance(mContext).isScreenOn(); + boolean visible = isShown() + && KeyguardUpdateMonitor.getInstance(mContext).isDeviceInteractive(); if (visible) { mTrustDrawable.start(); } else { @@ -101,8 +102,9 @@ public class LockIcon extends KeyguardAffordanceView { // TODO: Real icon for facelock. int state = getState(); boolean anyFingerprintIcon = state == STATE_FINGERPRINT || state == STATE_FINGERPRINT_ERROR; - if (state != mLastState || mScreenOn != mLastScreenOn) { - int iconRes = getAnimationResForTransition(mLastState, state, mLastScreenOn, mScreenOn); + if (state != mLastState || mDeviceInteractive != mLastDeviceInteractive) { + int iconRes = getAnimationResForTransition(mLastState, state, mLastDeviceInteractive, + mDeviceInteractive); if (iconRes == R.drawable.lockscreen_fingerprint_draw_off_animation) { anyFingerprintIcon = true; } @@ -149,7 +151,7 @@ public class LockIcon extends KeyguardAffordanceView { } } mLastState = state; - mLastScreenOn = mScreenOn; + mLastDeviceInteractive = mDeviceInteractive; } // Hide trust circle when fingerprint is running. diff --git a/packages/SystemUI/src/com/android/systemui/statusbar/phone/NavigationBarView.java b/packages/SystemUI/src/com/android/systemui/statusbar/phone/NavigationBarView.java index 416fb36..ed49f39 100644 --- a/packages/SystemUI/src/com/android/systemui/statusbar/phone/NavigationBarView.java +++ b/packages/SystemUI/src/com/android/systemui/statusbar/phone/NavigationBarView.java @@ -91,6 +91,7 @@ public class NavigationBarView extends LinearLayout { private OnVerticalChangedListener mOnVerticalChangedListener; private boolean mIsLayoutRtl; + private boolean mLayoutTransitionsEnabled; private class NavTransitionListener implements TransitionListener { private boolean mBackTransitioning; @@ -333,13 +334,6 @@ public class NavigationBarView extends LinearLayout { if (!lt.getTransitionListeners().contains(mTransitionListener)) { lt.addTransitionListener(mTransitionListener); } - if (!mScreenOn && mCurrentView != null) { - lt.disableTransitionType( - LayoutTransition.CHANGE_APPEARING | - LayoutTransition.CHANGE_DISAPPEARING | - LayoutTransition.APPEARING | - LayoutTransition.DISAPPEARING); - } } } if (inLockTask() && disableRecent && !disableHome) { @@ -367,6 +361,44 @@ public class NavigationBarView extends LinearLayout { } } + public void setWakeAndUnlocking(boolean wakeAndUnlocking) { + setUseFadingAnimations(wakeAndUnlocking); + setLayoutTransitionsEnabled(!wakeAndUnlocking); + } + + private void setLayoutTransitionsEnabled(boolean enabled) { + mLayoutTransitionsEnabled = enabled; + ViewGroup navButtons = (ViewGroup) mCurrentView.findViewById(R.id.nav_buttons); + LayoutTransition lt = navButtons.getLayoutTransition(); + if (enabled) { + lt.enableTransitionType(LayoutTransition.APPEARING); + lt.enableTransitionType(LayoutTransition.DISAPPEARING); + lt.enableTransitionType(LayoutTransition.CHANGE_APPEARING); + lt.enableTransitionType(LayoutTransition.CHANGE_DISAPPEARING); + } else { + lt.disableTransitionType(LayoutTransition.APPEARING); + lt.disableTransitionType(LayoutTransition.DISAPPEARING); + lt.disableTransitionType(LayoutTransition.CHANGE_APPEARING); + lt.disableTransitionType(LayoutTransition.CHANGE_DISAPPEARING); + } + } + + private void setUseFadingAnimations(boolean useFadingAnimations) { + WindowManager.LayoutParams lp = (WindowManager.LayoutParams) getLayoutParams(); + if (lp != null) { + boolean old = lp.windowAnimations != 0; + if (!old && useFadingAnimations) { + lp.windowAnimations = R.style.Animation_NavigationBarFadeIn; + } else if (old && !useFadingAnimations) { + lp.windowAnimations = 0; + } else { + return; + } + WindowManager wm = (WindowManager)getContext().getSystemService(Context.WINDOW_SERVICE); + wm.updateViewLayout(this, lp); + } + } + public void setSlippery(boolean newSlippery) { WindowManager.LayoutParams lp = (WindowManager.LayoutParams) getLayoutParams(); if (lp != null) { @@ -425,6 +457,7 @@ public class NavigationBarView extends LinearLayout { } mCurrentView = mRotatedViews[rot]; mCurrentView.setVisibility(View.VISIBLE); + setLayoutTransitionsEnabled(mLayoutTransitionsEnabled); getImeSwitchButton().setOnClickListener(mImeSwitcherClickListener); diff --git a/packages/SystemUI/src/com/android/systemui/statusbar/phone/PhoneStatusBar.java b/packages/SystemUI/src/com/android/systemui/statusbar/phone/PhoneStatusBar.java index dfce170..86755d1 100644 --- a/packages/SystemUI/src/com/android/systemui/statusbar/phone/PhoneStatusBar.java +++ b/packages/SystemUI/src/com/android/systemui/statusbar/phone/PhoneStatusBar.java @@ -3955,7 +3955,7 @@ public class PhoneStatusBar extends BaseStatusBar implements DemoMode, mScreenOnComingFromTouch = true; mScreenOnTouchLocation = new PointF(event.getX(), event.getY()); mNotificationPanel.setTouchDisabled(false); - mStatusBarKeyguardViewManager.notifyScreenWakeUpRequested(); + mStatusBarKeyguardViewManager.notifyDeviceWakeUpRequested(); } } diff --git a/packages/SystemUI/src/com/android/systemui/statusbar/phone/ScrimController.java b/packages/SystemUI/src/com/android/systemui/statusbar/phone/ScrimController.java index 6816399..1a35500 100644 --- a/packages/SystemUI/src/com/android/systemui/statusbar/phone/ScrimController.java +++ b/packages/SystemUI/src/com/android/systemui/statusbar/phone/ScrimController.java @@ -22,11 +22,12 @@ import android.animation.PropertyValuesHolder; import android.animation.ValueAnimator; import android.content.Context; import android.graphics.Color; +import android.util.Log; import android.view.View; import android.view.ViewTreeObserver; -import android.view.animation.AnimationUtils; import android.view.animation.DecelerateInterpolator; import android.view.animation.Interpolator; +import android.view.animation.PathInterpolator; import com.android.systemui.R; import com.android.systemui.statusbar.BackDropView; @@ -62,6 +63,7 @@ public class ScrimController implements ViewTreeObserver.OnPreDrawListener, private boolean mDarkenWhileDragging; private boolean mBouncerShowing; + private boolean mWakeAndUnlocking; private boolean mAnimateChange; private boolean mUpdatePending; private boolean mExpanding; @@ -71,7 +73,7 @@ public class ScrimController implements ViewTreeObserver.OnPreDrawListener, private Runnable mOnAnimationFinished; private boolean mAnimationStarted; private final Interpolator mInterpolator = new DecelerateInterpolator(); - private final Interpolator mLinearOutSlowInInterpolator; + private final Interpolator mKeyguardFadeOutInterpolator = new PathInterpolator(0f, 0, 0.7f, 1f); private BackDropView mBackDropView; private boolean mScrimSrcEnabled; private boolean mDozing; @@ -92,8 +94,6 @@ public class ScrimController implements ViewTreeObserver.OnPreDrawListener, mHeadsUpScrim = headsUpScrim; final Context context = scrimBehind.getContext(); mUnlockMethodCache = UnlockMethodCache.getInstance(context); - mLinearOutSlowInInterpolator = AnimationUtils.loadInterpolator(context, - android.R.interpolator.linear_out_slow_in); mScrimSrcEnabled = scrimSrcEnabled; updateHeadsUpScrim(false); } @@ -128,7 +128,13 @@ public class ScrimController implements ViewTreeObserver.OnPreDrawListener, scheduleUpdate(); } + public void setWakeAndUnlocking() { + mWakeAndUnlocking = true; + scheduleUpdate(); + } + public void animateKeyguardFadingOut(long delay, long duration, Runnable onAnimationFinished) { + mWakeAndUnlocking = false; mAnimateKeyguardFadingOut = true; mDurationOverride = duration; mAnimationDelay = delay; @@ -151,8 +157,10 @@ public class ScrimController implements ViewTreeObserver.OnPreDrawListener, } public void setDozing(boolean dozing) { - mDozing = dozing; - scheduleUpdate(); + if (mDozing != dozing) { + mDozing = dozing; + scheduleUpdate(); + } } public void setDozeInFrontAlpha(float alpha) { @@ -186,6 +194,12 @@ public class ScrimController implements ViewTreeObserver.OnPreDrawListener, if (mAnimateKeyguardFadingOut || mForceHideScrims) { setScrimInFrontColor(0f); setScrimBehindColor(0f); + } else if (mWakeAndUnlocking) { + + // During wake and unlock, we first hide everything behind a black scrim, which then + // gets faded out from animateKeyguardFadingOut. + setScrimInFrontColor(1f); + setScrimBehindColor(0f); } else if (!mKeyguardShowing && !mBouncerShowing) { updateScrimNormal(); setScrimInFrontColor(0); @@ -319,7 +333,7 @@ public class ScrimController implements ViewTreeObserver.OnPreDrawListener, } private Interpolator getInterpolator() { - return mAnimateKeyguardFadingOut ? mLinearOutSlowInInterpolator : mInterpolator; + return mAnimateKeyguardFadingOut ? mKeyguardFadeOutInterpolator : mInterpolator; } @Override diff --git a/packages/SystemUI/src/com/android/systemui/statusbar/phone/StatusBarKeyguardViewManager.java b/packages/SystemUI/src/com/android/systemui/statusbar/phone/StatusBarKeyguardViewManager.java index 6b3a59d..44aa780 100644 --- a/packages/SystemUI/src/com/android/systemui/statusbar/phone/StatusBarKeyguardViewManager.java +++ b/packages/SystemUI/src/com/android/systemui/statusbar/phone/StatusBarKeyguardViewManager.java @@ -20,6 +20,7 @@ import android.content.ComponentCallbacks2; import android.content.Context; import android.os.Bundle; import android.os.SystemClock; +import android.os.Trace; import android.view.KeyEvent; import android.view.View; import android.view.ViewGroup; @@ -59,7 +60,8 @@ public class StatusBarKeyguardViewManager { private ViewGroup mContainer; private StatusBarWindowManager mStatusBarWindowManager; - private boolean mScreenOn = false; + private boolean mDeviceInteractive = false; + private boolean mScreenTurnedOn; private KeyguardBouncer mBouncer; private boolean mShowing; private boolean mOccluded; @@ -69,8 +71,11 @@ public class StatusBarKeyguardViewManager { private boolean mLastOccluded; private boolean mLastBouncerShowing; private boolean mLastBouncerDismissible; + private boolean mLastDeferScrimFadeOut; private OnDismissAction mAfterKeyguardGoneAction; - private boolean mScreenWillWakeUp; + private boolean mDeviceWillWakeUp; + private boolean mWakeAndUnlocking; + private boolean mDeferScrimFadeOut; public StatusBarKeyguardViewManager(Context context, ViewMediatorCallback callback, LockPatternUtils lockPatternUtils) { @@ -155,20 +160,34 @@ public class StatusBarKeyguardViewManager { } } - public void onScreenTurnedOff() { - mScreenOn = false; + public void onFinishedGoingToSleep() { + mDeviceInteractive = false; mPhoneStatusBar.onScreenTurnedOff(); mBouncer.onScreenTurnedOff(); } - public void onScreenTurnedOn() { - mScreenOn = true; - mScreenWillWakeUp = false; + public void onStartedWakingUp() { + mDeviceInteractive = true; + mDeviceWillWakeUp = false; mPhoneStatusBar.onScreenTurnedOn(); } - public void notifyScreenWakeUpRequested() { - mScreenWillWakeUp = !mScreenOn; + public void onScreenTurnedOn() { + mScreenTurnedOn = true; + mWakeAndUnlocking = false; + if (mDeferScrimFadeOut) { + mDeferScrimFadeOut = false; + animateScrimControllerKeyguardFadingOut(0, 200); + updateStates(); + } + } + + public void onScreenTurnedOff() { + mScreenTurnedOn = false; + } + + public void notifyDeviceWakeUpRequested() { + mDeviceWillWakeUp = !mDeviceInteractive; } public void verifyUnlock() { @@ -252,21 +271,11 @@ public class StatusBarKeyguardViewManager { mPhoneStatusBar.setKeyguardFadingAway(startTime, delay, fadeoutDuration); boolean staying = mPhoneStatusBar.hideKeyguard(); if (!staying) { - if (fadeoutDuration == 0) { - mPhoneStatusBar.finishKeyguardFadingAway(); - WindowManagerGlobal.getInstance().trimMemory( - ComponentCallbacks2.TRIM_MEMORY_UI_HIDDEN); + mStatusBarWindowManager.setKeyguardFadingAway(true); + if (mWakeAndUnlocking && !mScreenTurnedOn) { + mDeferScrimFadeOut = true; } else { - mStatusBarWindowManager.setKeyguardFadingAway(true); - mScrimController.animateKeyguardFadingOut(delay, fadeoutDuration, new Runnable() { - @Override - public void run() { - mStatusBarWindowManager.setKeyguardFadingAway(false); - mPhoneStatusBar.finishKeyguardFadingAway(); - WindowManagerGlobal.getInstance().trimMemory( - ComponentCallbacks2.TRIM_MEMORY_UI_HIDDEN); - } - }); + animateScrimControllerKeyguardFadingOut(delay, fadeoutDuration); } } else { mScrimController.animateGoingToFullShade(delay, fadeoutDuration); @@ -281,6 +290,23 @@ public class StatusBarKeyguardViewManager { } + private void animateScrimControllerKeyguardFadingOut(long delay, long duration) { + Trace.asyncTraceBegin(Trace.TRACE_TAG_VIEW, "Fading out", 0); + mScrimController.animateKeyguardFadingOut(delay, duration, new Runnable() { + @Override + public void run() { + mStatusBarWindowManager.setKeyguardFadingAway(false); + mPhoneStatusBar.finishKeyguardFadingAway(); + if (mPhoneStatusBar.getNavigationBarView() != null) { + mPhoneStatusBar.getNavigationBarView().setWakeAndUnlocking(false); + } + WindowManagerGlobal.getInstance().trimMemory( + ComponentCallbacks2.TRIM_MEMORY_UI_HIDDEN); + Trace.asyncTraceEnd(Trace.TRACE_TAG_VIEW, "Fading out", 0); + } + }); + } + private void executeAfterKeyguardGoneAction() { if (mAfterKeyguardGoneAction != null) { mAfterKeyguardGoneAction.onDismiss(); @@ -292,7 +318,7 @@ public class StatusBarKeyguardViewManager { * Dismisses the keyguard by going to the next screen or making it gone. */ public void dismiss() { - if (mScreenOn || mScreenWillWakeUp) { + if (mDeviceInteractive || mDeviceWillWakeUp) { showBouncer(); } } @@ -352,6 +378,7 @@ public class StatusBarKeyguardViewManager { boolean occluded = mOccluded; boolean bouncerShowing = mBouncer.isShowing(); boolean bouncerDismissible = !mBouncer.isFullscreenBouncer(); + boolean deferScrimFadeOut = mDeferScrimFadeOut; if ((bouncerDismissible || !showing) != (mLastBouncerDismissible || !mLastShowing) || mFirstUpdate) { @@ -361,10 +388,15 @@ public class StatusBarKeyguardViewManager { mContainer.setSystemUiVisibility(vis | View.STATUS_BAR_DISABLE_BACK); } } - if ((!(showing && !occluded) || bouncerShowing) - != (!(mLastShowing && !mLastOccluded) || mLastBouncerShowing) || mFirstUpdate) { + + // Hide navigation bar on Keyguard but not on bouncer and also if we are deferring a scrim + // fade out, i.e. we are waiting for the screen to have turned on. + boolean navBarVisible = !deferScrimFadeOut && (!(showing && !occluded) || bouncerShowing); + boolean lastNavBarVisible = !mLastDeferScrimFadeOut && (!(mLastShowing && !mLastOccluded) + || mLastBouncerShowing); + if (navBarVisible != lastNavBarVisible || mFirstUpdate) { if (mPhoneStatusBar.getNavigationBarView() != null) { - if (!(showing && !occluded) || bouncerShowing) { + if (navBarVisible) { mContainer.postOnAnimationDelayed(mMakeNavigationBarVisibleRunnable, getNavBarShowDelay()); } else { @@ -391,6 +423,7 @@ public class StatusBarKeyguardViewManager { mFirstUpdate = false; mLastShowing = showing; mLastOccluded = occluded; + mLastDeferScrimFadeOut = deferScrimFadeOut; mLastBouncerShowing = bouncerShowing; mLastBouncerDismissible = bouncerDismissible; @@ -450,4 +483,12 @@ public class StatusBarKeyguardViewManager { public void notifyKeyguardAuthenticated() { mBouncer.notifyKeyguardAuthenticated(); } + + public void setWakeAndUnlocking() { + mWakeAndUnlocking = true; + mScrimController.setWakeAndUnlocking(); + if (mPhoneStatusBar.getNavigationBarView() != null) { + mPhoneStatusBar.getNavigationBarView().setWakeAndUnlocking(true); + } + } } diff --git a/packages/SystemUI/src/com/android/systemui/statusbar/phone/UnlockMethodCache.java b/packages/SystemUI/src/com/android/systemui/statusbar/phone/UnlockMethodCache.java index c8c45e3..bd537f7 100644 --- a/packages/SystemUI/src/com/android/systemui/statusbar/phone/UnlockMethodCache.java +++ b/packages/SystemUI/src/com/android/systemui/statusbar/phone/UnlockMethodCache.java @@ -127,7 +127,7 @@ public class UnlockMethodCache { } @Override - public void onScreenTurnedOn() { + public void onStartedWakingUp() { update(false /* updateAlways */); } |