am 353fe1c6: am 0d210f63: Animation for touch, wake and unlock

* commit '353fe1c665e0065d4c8eecdf41c22f1a1a607f2c':
  Animation for touch, wake and unlock
This commit is contained in:
Jorim Jaggi
2015-07-28 23:43:46 +00:00
committed by Android Git Automerger
23 changed files with 420 additions and 131 deletions

View File

@@ -994,6 +994,12 @@ public interface WindowManagerPolicy {
*/
public void screenTurningOn(ScreenOnListener screenOnListener);
/**
* Called when the device has actually turned on the screen, i.e. the display power state has
* been set to ON and the screen is unblocked.
*/
public void screenTurnedOn();
/**
* Called when the device has turned the screen off.
*/

View File

@@ -64,6 +64,16 @@ oneway interface IKeyguardService {
*/
void onScreenTurningOn(IKeyguardDrawnCallback callback);
/**
* Called when the screen has actually turned on.
*/
void onScreenTurnedOn();
/**
* Called when the screen has turned off.
*/
void onScreenTurnedOff();
void setKeyguardEnabled(boolean enabled);
void onSystemReady();
void doKeyguardTimeout(in Bundle options);

View File

@@ -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

View File

@@ -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) {

View File

@@ -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();

View File

@@ -103,6 +103,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;
@@ -118,8 +135,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;
@@ -156,6 +173,7 @@ public class KeyguardUpdateMonitor implements TrustManager.TrustListener {
private boolean mSwitchingUser;
private boolean mDeviceInteractive;
private boolean mScreenOn;
private SubscriptionManager mSubscriptionManager;
private List<SubscriptionInfo> mSubscriptionInfo;
@@ -212,11 +230,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);
@@ -249,7 +267,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;
@@ -372,19 +390,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;
}
}
@@ -410,7 +430,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...");
}
@@ -429,7 +449,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);
}
@@ -765,24 +785,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();
@@ -1450,22 +1470,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;
}
/**

View File

@@ -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.

View File

@@ -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"/>

View File

@@ -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>

View File

@@ -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);
}

View File

@@ -131,6 +131,18 @@ public class KeyguardService extends Service {
mKeyguardViewMediator.onScreenTurningOn(callback);
}
@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();

View File

@@ -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();

View File

@@ -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

View File

@@ -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.

View File

@@ -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);

View File

@@ -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();
}
}

View File

@@ -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

View File

@@ -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);
}
}
}

View File

@@ -127,7 +127,7 @@ public class UnlockMethodCache {
}
@Override
public void onScreenTurnedOn() {
public void onStartedWakingUp() {
update(false /* updateAlways */);
}

View File

@@ -106,6 +106,10 @@ final class DisplayPowerController implements AutomaticBrightnessController.Call
private static final int BRIGHTNESS_RAMP_RATE_FAST = 200;
private static final int BRIGHTNESS_RAMP_RATE_SLOW = 40;
private static final int REPORTED_TO_POLICY_SCREEN_OFF = 0;
private static final int REPORTED_TO_POLICY_SCREEN_TURNING_ON = 1;
private static final int REPORTED_TO_POLICY_SCREEN_ON = 2;
private final Object mLock = new Object();
private final Context mContext;
@@ -231,8 +235,8 @@ final class DisplayPowerController implements AutomaticBrightnessController.Call
// The elapsed real time when the screen on was blocked.
private long mScreenOnBlockStartRealTime;
// True if we told the window manager policy that the screen was off.
private boolean mReportedScreenOffToPolicy;
// Screen state we reported to policy. Must be one of REPORTED_TO_POLICY_SCREEN_* fields.
private int mReportedScreenStateToPolicy;
// Remembers whether certain kinds of brightness adjustments
// were recently applied so that we can decide how to transition.
@@ -699,6 +703,13 @@ final class DisplayPowerController implements AutomaticBrightnessController.Call
final boolean finished = ready
&& !mScreenBrightnessRampAnimator.isAnimating();
// Notify policy about screen turned on.
if (ready && state != Display.STATE_OFF
&& mReportedScreenStateToPolicy == REPORTED_TO_POLICY_SCREEN_TURNING_ON) {
mReportedScreenStateToPolicy = REPORTED_TO_POLICY_SCREEN_ON;
mWindowManagerPolicy.screenTurnedOn();
}
// Grab a wake lock if we have unfinished business.
if (!finished && !mUnfinishedBusiness) {
if (DEBUG) {
@@ -776,12 +787,13 @@ final class DisplayPowerController implements AutomaticBrightnessController.Call
// it is only removed once the window manager tells us that the activity has
// finished drawing underneath.
final boolean isOff = (state == Display.STATE_OFF);
if (isOff && !mReportedScreenOffToPolicy && !mScreenOffBecauseOfProximity) {
mReportedScreenOffToPolicy = true;
if (isOff && mReportedScreenStateToPolicy != REPORTED_TO_POLICY_SCREEN_OFF
&& !mScreenOffBecauseOfProximity) {
mReportedScreenStateToPolicy = REPORTED_TO_POLICY_SCREEN_OFF;
unblockScreenOn();
mWindowManagerPolicy.screenTurnedOff();
} else if (!isOff && mReportedScreenOffToPolicy) {
mReportedScreenOffToPolicy = false;
} else if (!isOff && mReportedScreenStateToPolicy == REPORTED_TO_POLICY_SCREEN_OFF) {
mReportedScreenStateToPolicy = REPORTED_TO_POLICY_SCREEN_TURNING_ON;
if (mPowerState.getColorFadeLevel() == 0.0f) {
blockScreenOn();
} else {
@@ -1095,7 +1107,7 @@ final class DisplayPowerController implements AutomaticBrightnessController.Call
pw.println(" mAppliedLowPower=" + mAppliedLowPower);
pw.println(" mPendingScreenOnUnblocker=" + mPendingScreenOnUnblocker);
pw.println(" mPendingScreenOff=" + mPendingScreenOff);
pw.println(" mReportedScreenOffToPolicy=" + mReportedScreenOffToPolicy);
pw.println(" mReportedToPolicy=" + reportedToPolicyToString(mReportedScreenStateToPolicy));
pw.println(" mScreenBrightnessRampAnimator.isAnimating()=" +
mScreenBrightnessRampAnimator.isAnimating());
@@ -1132,6 +1144,19 @@ final class DisplayPowerController implements AutomaticBrightnessController.Call
}
}
private static String reportedToPolicyToString(int state) {
switch (state) {
case REPORTED_TO_POLICY_SCREEN_OFF:
return "REPORTED_TO_POLICY_SCREEN_OFF";
case REPORTED_TO_POLICY_SCREEN_TURNING_ON:
return "REPORTED_TO_POLICY_SCREEN_TURNING_ON";
case REPORTED_TO_POLICY_SCREEN_ON:
return "REPORTED_TO_POLICY_SCREEN_ON";
default:
return Integer.toString(state);
}
}
private static Spline createAutoBrightnessSpline(int[] lux, int[] brightness) {
try {
final int n = brightness.length;

View File

@@ -251,7 +251,7 @@ public class PhoneWindowManager implements WindowManagerPolicy {
}
/** Amount of time (in milliseconds) to wait for windows drawn before powering on. */
static final int WAITING_FOR_DRAWN_TIMEOUT = 500;
static final int WAITING_FOR_DRAWN_TIMEOUT = 1000;
/**
* Lock protecting internal state. Must not call out into window
@@ -2469,6 +2469,9 @@ public class PhoneWindowManager implements WindowManagerPolicy {
return isKeyguard ? -1 : R.anim.dock_top_enter;
}
} else if (win == mNavigationBar) {
if (win.getAttrs().windowAnimations != 0) {
return 0;
}
// This can be on either the bottom or the right.
if (mNavigationBarOnBottom) {
if (transit == TRANSIT_EXIT
@@ -5556,6 +5559,10 @@ public class PhoneWindowManager implements WindowManagerPolicy {
mWindowManagerDrawComplete = false;
mScreenOnListener = null;
updateOrientationListenerLp();
if (mKeyguardDelegate != null) {
mKeyguardDelegate.onScreenTurnedOff();
}
}
}
@@ -5581,6 +5588,16 @@ public class PhoneWindowManager implements WindowManagerPolicy {
}
}
// Called on the DisplayManager's DisplayPowerController thread.
@Override
public void screenTurnedOn() {
synchronized (mLock) {
if (mKeyguardDelegate != null) {
mKeyguardDelegate.onScreenTurnedOn();
}
}
}
private void finishWindowsDrawn() {
synchronized (mLock) {
if (!mScreenOnEarly || mWindowManagerDrawComplete) {

View File

@@ -144,6 +144,7 @@ public class KeyguardServiceDelegate {
mKeyguardService.onStartedWakingUp();
mKeyguardService.onScreenTurningOn(
new KeyguardShowDelegate(mDrawnListenerWhenConnect));
mKeyguardService.onScreenTurnedOn();
mDrawnListenerWhenConnect = null;
}
if (mKeyguardState.bootCompleted) {
@@ -229,6 +230,13 @@ public class KeyguardServiceDelegate {
}
}
public void onScreenTurnedOff() {
if (mKeyguardService != null) {
if (DEBUG) Log.v(TAG, "onScreenTurnedOff()");
mKeyguardService.onScreenTurnedOff();
}
}
public void onScreenTurningOn(final DrawnListener drawnListener) {
if (mKeyguardService != null) {
if (DEBUG) Log.v(TAG, "onScreenTurnedOn(showListener = " + drawnListener + ")");
@@ -243,6 +251,13 @@ public class KeyguardServiceDelegate {
}
}
public void onScreenTurnedOn() {
if (mKeyguardService != null) {
if (DEBUG) Log.v(TAG, "onScreenTurnedOn()");
mKeyguardService.onScreenTurnedOn();
}
}
public void onStartedGoingToSleep(int why) {
if (mKeyguardService != null) {
mKeyguardService.onStartedGoingToSleep(why);

View File

@@ -141,6 +141,24 @@ public class KeyguardServiceWrapper implements IKeyguardService {
}
}
@Override
public void onScreenTurnedOn() {
try {
mService.onScreenTurnedOn();
} catch (RemoteException e) {
Slog.w(TAG , "Remote Exception", e);
}
}
@Override
public void onScreenTurnedOff() {
try {
mService.onScreenTurnedOff();
} catch (RemoteException e) {
Slog.w(TAG , "Remote Exception", e);
}
}
@Override // Binder interface
public void setKeyguardEnabled(boolean enabled) {
try {