Lockscreen launch animations
- Get rid of ActivityManager.dismissKeyguardOnNextActivity, which was
used for two different things: Dismiss keyguard from somewhere else
(not really necessary anymore), wait to actually dismiss keyguard
after the window behind is drawn. Instead, introduce
keyguardWaitingForActivityDrawn(), and change the semantics where
necessary.
- Make wallpaper_close_enter consistent with task_open_enter and the
Keyguard launch animation.
- Close the panel even on lockscreen when launching a notification.
- Block notification shade updates during the collapsing motion so
notification don't play the disappear animation immediately after
having launched a notification.
Bug: 15991916
Change-Id: I133c177b84e926c87c1a404ba93d633593fec3ab
diff --git a/core/java/android/app/ActivityManagerNative.java b/core/java/android/app/ActivityManagerNative.java
index 311a8f55..a11149e 100644
--- a/core/java/android/app/ActivityManagerNative.java
+++ b/core/java/android/app/ActivityManagerNative.java
@@ -1942,9 +1942,9 @@
return true;
}
- case DISMISS_KEYGUARD_ON_NEXT_ACTIVITY_TRANSACTION: {
+ case KEYGUARD_WAITING_FOR_ACTIVITY_DRAWN_TRANSACTION: {
data.enforceInterface(IActivityManager.descriptor);
- dismissKeyguardOnNextActivity();
+ keyguardWaitingForActivityDrawn();
reply.writeNoException();
return true;
}
@@ -4738,11 +4738,11 @@
reply.recycle();
}
- public void dismissKeyguardOnNextActivity() throws RemoteException {
+ public void keyguardWaitingForActivityDrawn() throws RemoteException {
Parcel data = Parcel.obtain();
Parcel reply = Parcel.obtain();
data.writeInterfaceToken(IActivityManager.descriptor);
- mRemote.transact(DISMISS_KEYGUARD_ON_NEXT_ACTIVITY_TRANSACTION, data, reply, 0);
+ mRemote.transact(KEYGUARD_WAITING_FOR_ACTIVITY_DRAWN_TRANSACTION, data, reply, 0);
reply.readException();
data.recycle();
reply.recycle();
diff --git a/core/java/android/app/IActivityManager.java b/core/java/android/app/IActivityManager.java
index 772e132..4464a67 100644
--- a/core/java/android/app/IActivityManager.java
+++ b/core/java/android/app/IActivityManager.java
@@ -383,7 +383,7 @@
public void showBootMessage(CharSequence msg, boolean always) throws RemoteException;
- public void dismissKeyguardOnNextActivity() throws RemoteException;
+ public void keyguardWaitingForActivityDrawn() throws RemoteException;
public boolean targetTaskAffinityMatchesActivity(IBinder token, String destAffinity)
throws RemoteException;
@@ -688,7 +688,6 @@
int UPDATE_PERSISTENT_CONFIGURATION_TRANSACTION = IBinder.FIRST_CALL_TRANSACTION+135;
int GET_PROCESS_PSS_TRANSACTION = IBinder.FIRST_CALL_TRANSACTION+136;
int SHOW_BOOT_MESSAGE_TRANSACTION = IBinder.FIRST_CALL_TRANSACTION+137;
- int DISMISS_KEYGUARD_ON_NEXT_ACTIVITY_TRANSACTION = IBinder.FIRST_CALL_TRANSACTION+138;
int KILL_ALL_BACKGROUND_PROCESSES_TRANSACTION = IBinder.FIRST_CALL_TRANSACTION+139;
int GET_CONTENT_PROVIDER_EXTERNAL_TRANSACTION = IBinder.FIRST_CALL_TRANSACTION+140;
int REMOVE_CONTENT_PROVIDER_EXTERNAL_TRANSACTION = IBinder.FIRST_CALL_TRANSACTION+141;
@@ -760,4 +759,5 @@
int NOTIFY_LAUNCH_TASK_BEHIND_COMPLETE_TRANSACTION = IBinder.FIRST_CALL_TRANSACTION+228;
int START_ACTIVITY_FROM_RECENTS_TRANSACTION = IBinder.FIRST_CALL_TRANSACTION + 229;
int NOTIFY_ENTER_ANIMATION_COMPLETE_TRANSACTION = IBinder.FIRST_CALL_TRANSACTION+230;
+ int KEYGUARD_WAITING_FOR_ACTIVITY_DRAWN_TRANSACTION = IBinder.FIRST_CALL_TRANSACTION+231;
}
diff --git a/core/java/android/view/WindowManagerPolicy.java b/core/java/android/view/WindowManagerPolicy.java
index b6c650d..a7e02e4 100644
--- a/core/java/android/view/WindowManagerPolicy.java
+++ b/core/java/android/view/WindowManagerPolicy.java
@@ -1014,6 +1014,11 @@
public void dismissKeyguardLw();
/**
+ * Notifies the keyguard that the activity has drawn it was waiting for.
+ */
+ public void notifyActivityDrawnForKeyguardLw();
+
+ /**
* Ask the policy whether the Keyguard has drawn. If the Keyguard is disabled, this method
* returns true as soon as we know that Keyguard is disabled.
*
diff --git a/core/java/com/android/internal/policy/IKeyguardService.aidl b/core/java/com/android/internal/policy/IKeyguardService.aidl
index a5421f5..64f3bea 100644
--- a/core/java/com/android/internal/policy/IKeyguardService.aidl
+++ b/core/java/com/android/internal/policy/IKeyguardService.aidl
@@ -65,4 +65,10 @@
* @param fadeoutDuration the duration of the exit animation, in milliseconds
*/
oneway void startKeyguardExitAnimation(long startTime, long fadeoutDuration);
+
+ /**
+ * Notifies the Keyguard that the activity that was starting has now been drawn and it's safe
+ * to start the keyguard dismiss sequence.
+ */
+ oneway void onActivityDrawn();
}
diff --git a/core/res/res/anim/wallpaper_close_enter.xml b/core/res/res/anim/wallpaper_close_enter.xml
index 981923a..a189813 100644
--- a/core/res/res/anim/wallpaper_close_enter.xml
+++ b/core/res/res/anim/wallpaper_close_enter.xml
@@ -18,15 +18,17 @@
-->
<set xmlns:android="http://schemas.android.com/apk/res/android"
- android:shareInterpolator="false" android:zAdjustment="top">
- <scale android:fromXScale=".2" android:toXScale="1.0"
- android:fromYScale=".2" android:toYScale="1.0"
- android:pivotX="50%p" android:pivotY="50%p"
- android:fillEnabled="true" android:fillBefore="true" android:fillAfter="true"
- android:interpolator="@interpolator/decelerate_cubic"
- android:duration="300" />
+ android:background="#ff000000" android:shareInterpolator="false" android:zAdjustment="top">
+
<alpha android:fromAlpha="0" android:toAlpha="1.0"
- android:fillEnabled="true" android:fillBefore="true" android:fillAfter="true"
- android:interpolator="@interpolator/decelerate_cubic"
- android:duration="300"/>
+ android:fillEnabled="true" android:fillBefore="true" android:fillAfter="true"
+ android:interpolator="@interpolator/decelerate_quart"
+ android:startOffset="300"
+ android:duration="167"/>
+
+ <translate android:fromYDelta="110%" android:toYDelta="0"
+ android:fillEnabled="true" android:fillBefore="true" android:fillAfter="true"
+ android:interpolator="@interpolator/decelerate_quint"
+ android:startOffset="300"
+ android:duration="417" />
</set>
\ No newline at end of file
diff --git a/core/res/res/anim/wallpaper_close_exit.xml b/core/res/res/anim/wallpaper_close_exit.xml
index a91eb49..12b31aef 100644
--- a/core/res/res/anim/wallpaper_close_exit.xml
+++ b/core/res/res/anim/wallpaper_close_exit.xml
@@ -20,5 +20,5 @@
<set xmlns:android="http://schemas.android.com/apk/res/android"
android:detachWallpaper="true" android:shareInterpolator="false" android:zAdjustment="normal">
<alpha android:fromAlpha="1.0" android:toAlpha="1.0"
- android:duration="300" />
+ android:duration="417" />
</set>
\ No newline at end of file
diff --git a/packages/Keyguard/src/com/android/keyguard/KeyguardActivityLauncher.java b/packages/Keyguard/src/com/android/keyguard/KeyguardActivityLauncher.java
index 25f3383..32f7a1e 100644
--- a/packages/Keyguard/src/com/android/keyguard/KeyguardActivityLauncher.java
+++ b/packages/Keyguard/src/com/android/keyguard/KeyguardActivityLauncher.java
@@ -36,6 +36,7 @@
import android.provider.MediaStore;
import android.util.Log;
import android.view.WindowManager;
+import android.view.WindowManagerGlobal;
import com.android.keyguard.KeyguardHostView.OnDismissAction;
@@ -214,9 +215,9 @@
private void dismissKeyguardOnNextActivity() {
try {
- ActivityManagerNative.getDefault().dismissKeyguardOnNextActivity();
+ WindowManagerGlobal.getWindowManagerService().dismissKeyguard();
} catch (RemoteException e) {
- Log.w(TAG, "can't dismiss keyguard on launch");
+ Log.w(TAG, "Error dismissing keyguard", e);
}
}
diff --git a/packages/Keyguard/src/com/android/keyguard/KeyguardViewBase.java b/packages/Keyguard/src/com/android/keyguard/KeyguardViewBase.java
index d9c5a53..e35b2b2 100644
--- a/packages/Keyguard/src/com/android/keyguard/KeyguardViewBase.java
+++ b/packages/Keyguard/src/com/android/keyguard/KeyguardViewBase.java
@@ -237,7 +237,7 @@
}
public void startDisappearAnimation(Runnable finishRunnable) {
- if (!mSecurityContainer.startDisappearAnimation(finishRunnable)) {
+ if (!mSecurityContainer.startDisappearAnimation(finishRunnable) && finishRunnable != null) {
finishRunnable.run();
}
}
diff --git a/packages/Keyguard/src/com/android/keyguard/ViewMediatorCallback.java b/packages/Keyguard/src/com/android/keyguard/ViewMediatorCallback.java
index f74843e..2e5450d 100644
--- a/packages/Keyguard/src/com/android/keyguard/ViewMediatorCallback.java
+++ b/packages/Keyguard/src/com/android/keyguard/ViewMediatorCallback.java
@@ -61,4 +61,9 @@
* Report when keyguard is actually gone
*/
void keyguardGone();
+
+ /**
+ * Report when the UI is ready for dismissing the whole Keyguard.
+ */
+ void readyForKeyguardDone();
}
diff --git a/packages/SystemUI/src/com/android/systemui/keyguard/KeyguardService.java b/packages/SystemUI/src/com/android/systemui/keyguard/KeyguardService.java
index b280ab7..ee699d2 100644
--- a/packages/SystemUI/src/com/android/systemui/keyguard/KeyguardService.java
+++ b/packages/SystemUI/src/com/android/systemui/keyguard/KeyguardService.java
@@ -208,6 +208,12 @@
checkPermission();
mKeyguardViewMediator.startKeyguardExitAnimation(startTime, fadeoutDuration);
}
+
+ @Override
+ public void onActivityDrawn() {
+ checkPermission();
+ mKeyguardViewMediator.onActivityDrawn();
+ }
};
}
diff --git a/packages/SystemUI/src/com/android/systemui/keyguard/KeyguardViewMediator.java b/packages/SystemUI/src/com/android/systemui/keyguard/KeyguardViewMediator.java
index 117515b..e4b395f 100644
--- a/packages/SystemUI/src/com/android/systemui/keyguard/KeyguardViewMediator.java
+++ b/packages/SystemUI/src/com/android/systemui/keyguard/KeyguardViewMediator.java
@@ -133,6 +133,7 @@
private static final int KEYGUARD_TIMEOUT = 13;
private static final int DISMISS = 17;
private static final int START_KEYGUARD_EXIT_ANIM = 18;
+ private static final int ON_ACTIVITY_DRAWN = 19;
/**
* The default amount of time we stay awake (used for all key input)
@@ -256,6 +257,7 @@
private boolean mWaitingUntilKeyguardVisible = false;
private LockPatternUtils mLockPatternUtils;
private boolean mKeyguardDonePending = false;
+ private boolean mHideAnimationRun = false;
private SoundPool mLockSounds;
private int mLockSoundId;
@@ -287,6 +289,7 @@
// ActivityManagerService) will not reconstruct the keyguard if it is already showing.
synchronized (KeyguardViewMediator.this) {
mSwitchingUser = true;
+ mKeyguardDonePending = false;
resetStateLocked();
adjustStatusBarLocked();
// When we switch users we want to bring the new user to the biometric unlock even
@@ -431,12 +434,23 @@
@Override
public void keyguardDonePending() {
mKeyguardDonePending = true;
+ mHideAnimationRun = true;
+ mStatusBarKeyguardViewManager.startPreHideAnimation(null /* finishRunnable */);
}
@Override
public void keyguardGone() {
mKeyguardDisplayManager.hide();
}
+
+ @Override
+ public void readyForKeyguardDone() {
+ if (mKeyguardDonePending) {
+ // Somebody has called keyguardDonePending before, which means that we are
+ // authenticated
+ KeyguardViewMediator.this.keyguardDone(true /* authenticated */, true /* wakeUp */);
+ }
+ }
};
public void userActivity() {
@@ -545,6 +559,7 @@
if (DEBUG) Log.d(TAG, "onScreenTurnedOff(" + why + ")");
mKeyguardDonePending = false;
+ mHideAnimationRun = false;
// Lock immediately based on setting if secure (user has a pin/pattern/password).
// This also "locks" the device when not secure to provide easy access to the
@@ -1067,6 +1082,9 @@
StartKeyguardExitAnimParams params = (StartKeyguardExitAnimParams) msg.obj;
handleStartKeyguardExitAnimation(params.startTime, params.fadeoutDuration);
break;
+ case ON_ACTIVITY_DRAWN:
+ handleOnActivityDrawn();
+ break;
}
}
};
@@ -1181,6 +1199,7 @@
mHiding = false;
mShowing = true;
mKeyguardDonePending = false;
+ mHideAnimationRun = false;
updateActivityLockScreenState();
adjustStatusBarLocked();
userActivity();
@@ -1193,6 +1212,20 @@
mKeyguardDisplayManager.show();
}
+ private final Runnable mKeyguardGoingAwayRunnable = new Runnable() {
+ @Override
+ public void run() {
+ try {
+ // Don't actually hide the Keyguard at the moment, wait for window
+ // manager until it tells us it's safe to do so with
+ // startKeyguardExitAnimation.
+ mWM.keyguardGoingAway();
+ } catch (RemoteException e) {
+ Log.e(TAG, "Error while calling WindowManager", e);
+ }
+ }
+ };
+
/**
* Handle message sent by {@link #hideLocked()}
* @see #HIDE
@@ -1203,19 +1236,11 @@
mHiding = true;
if (mShowing && !mOccluded) {
- mStatusBarKeyguardViewManager.startPreHideAnimation(new Runnable() {
- @Override
- public void run() {
- try {
- // Don't actually hide the Keyguard at the moment, wait for window
- // manager until it tells us it's safe to do so with
- // startKeyguardExitAnimation.
- mWM.keyguardGoingAway();
- } catch (RemoteException e) {
- Log.e(TAG, "Error while calling WindowManager", e);
- }
- }
- });
+ if (!mHideAnimationRun) {
+ mStatusBarKeyguardViewManager.startPreHideAnimation(mKeyguardGoingAwayRunnable);
+ } else {
+ mKeyguardGoingAwayRunnable.run();
+ }
} else {
// Don't try to rely on WindowManager - if Keyguard wasn't showing, window
@@ -1227,6 +1252,12 @@
}
}
+ private void handleOnActivityDrawn() {
+ if (mKeyguardDonePending) {
+ mStatusBarKeyguardViewManager.onActivityDrawn();
+ }
+ }
+
private void handleStartKeyguardExitAnimation(long startTime, long fadeoutDuration) {
synchronized (KeyguardViewMediator.this) {
@@ -1244,6 +1275,7 @@
mStatusBarKeyguardViewManager.hide(startTime, fadeoutDuration);
mShowing = false;
mKeyguardDonePending = false;
+ mHideAnimationRun = false;
updateActivityLockScreenState();
adjustStatusBarLocked();
}
@@ -1357,6 +1389,9 @@
mHandler.sendMessage(msg);
}
+ public void onActivityDrawn() {
+ mHandler.sendEmptyMessage(ON_ACTIVITY_DRAWN);
+ }
public ViewMediatorCallback getViewMediatorCallback() {
return mViewMediatorCallback;
}
diff --git a/packages/SystemUI/src/com/android/systemui/power/PowerDialogWarnings.java b/packages/SystemUI/src/com/android/systemui/power/PowerDialogWarnings.java
index 79fadbd..8420dc0c 100644
--- a/packages/SystemUI/src/com/android/systemui/power/PowerDialogWarnings.java
+++ b/packages/SystemUI/src/com/android/systemui/power/PowerDialogWarnings.java
@@ -16,7 +16,6 @@
package com.android.systemui.power;
-import android.app.ActivityManagerNative;
import android.app.AlertDialog;
import android.content.ContentResolver;
import android.content.Context;
@@ -26,15 +25,14 @@
import android.media.Ringtone;
import android.media.RingtoneManager;
import android.net.Uri;
-import android.os.RemoteException;
import android.os.SystemClock;
-import android.os.UserHandle;
import android.provider.Settings;
import android.util.Slog;
import android.view.ContextThemeWrapper;
import android.view.WindowManager;
import com.android.systemui.R;
+import com.android.systemui.statusbar.phone.PhoneStatusBar;
import java.io.PrintWriter;
@@ -43,6 +41,7 @@
private static final boolean DEBUG = PowerUI.DEBUG;
private final Context mContext;
+ private final PhoneStatusBar mPhoneStatusBar;
private int mBatteryLevel;
private int mBucket;
@@ -52,8 +51,9 @@
private AlertDialog mInvalidChargerDialog;
private AlertDialog mLowBatteryDialog;
- public PowerDialogWarnings(Context context) {
+ public PowerDialogWarnings(Context context, PhoneStatusBar phoneStatusBar) {
mContext = new ContextThemeWrapper(context, android.R.style.Theme_DeviceDefault_Light);
+ mPhoneStatusBar = phoneStatusBar;
}
@Override
@@ -121,12 +121,7 @@
new DialogInterface.OnClickListener() {
@Override
public void onClick(DialogInterface dialog, int which) {
- try {
- ActivityManagerNative.getDefault().dismissKeyguardOnNextActivity();
- } catch (RemoteException e) {
- // we tried
- }
- mContext.startActivityAsUser(intent, UserHandle.CURRENT);
+ mPhoneStatusBar.startActivity(intent, true /* dismissShade */);
dismissLowBatteryWarning();
}
});
diff --git a/packages/SystemUI/src/com/android/systemui/power/PowerNotificationWarnings.java b/packages/SystemUI/src/com/android/systemui/power/PowerNotificationWarnings.java
index dd923e3..d455cec 100644
--- a/packages/SystemUI/src/com/android/systemui/power/PowerNotificationWarnings.java
+++ b/packages/SystemUI/src/com/android/systemui/power/PowerNotificationWarnings.java
@@ -38,6 +38,7 @@
import android.view.View;
import com.android.systemui.R;
+import com.android.systemui.statusbar.phone.PhoneStatusBar;
import com.android.systemui.statusbar.phone.SystemUIDialog;
import java.io.PrintWriter;
@@ -93,10 +94,10 @@
private boolean mInvalidCharger;
private SystemUIDialog mSaverConfirmation;
- public PowerNotificationWarnings(Context context) {
+ public PowerNotificationWarnings(Context context, PhoneStatusBar phoneStatusBar) {
mContext = context;
mNoMan = (NotificationManager) context.getSystemService(Context.NOTIFICATION_SERVICE);
- mFallbackDialogs = new PowerDialogWarnings(context);
+ mFallbackDialogs = new PowerDialogWarnings(context, phoneStatusBar);
mReceiver.init();
}
diff --git a/packages/SystemUI/src/com/android/systemui/power/PowerUI.java b/packages/SystemUI/src/com/android/systemui/power/PowerUI.java
index ccef8eb..d3c7dee 100644
--- a/packages/SystemUI/src/com/android/systemui/power/PowerUI.java
+++ b/packages/SystemUI/src/com/android/systemui/power/PowerUI.java
@@ -32,6 +32,7 @@
import android.util.Slog;
import com.android.systemui.SystemUI;
+import com.android.systemui.statusbar.phone.PhoneStatusBar;
import java.io.FileDescriptor;
import java.io.PrintWriter;
@@ -59,7 +60,7 @@
public void start() {
mPowerManager = (PowerManager) mContext.getSystemService(Context.POWER_SERVICE);
mScreenOffTime = mPowerManager.isScreenOn() ? -1 : SystemClock.elapsedRealtime();
- mWarnings = new PowerNotificationWarnings(mContext);
+ mWarnings = new PowerNotificationWarnings(mContext, getComponent(PhoneStatusBar.class));
ContentObserver obs = new ContentObserver(mHandler) {
@Override
diff --git a/packages/SystemUI/src/com/android/systemui/statusbar/BaseStatusBar.java b/packages/SystemUI/src/com/android/systemui/statusbar/BaseStatusBar.java
index c23a4cd..12fd0cb 100644
--- a/packages/SystemUI/src/com/android/systemui/statusbar/BaseStatusBar.java
+++ b/packages/SystemUI/src/com/android/systemui/statusbar/BaseStatusBar.java
@@ -42,6 +42,7 @@
import android.graphics.Rect;
import android.graphics.drawable.Drawable;
import android.net.Uri;
+import android.os.AsyncTask;
import android.os.Build;
import android.os.Handler;
import android.os.IBinder;
@@ -89,6 +90,7 @@
import com.android.systemui.SystemUI;
import com.android.systemui.statusbar.NotificationData.Entry;
import com.android.systemui.statusbar.phone.KeyguardTouchDelegate;
+import com.android.systemui.statusbar.phone.StatusBarKeyguardViewManager;
import com.android.systemui.statusbar.policy.HeadsUpNotificationView;
import com.android.systemui.statusbar.stack.NotificationStackScrollLayout;
@@ -130,9 +132,6 @@
public static final int EXPANDED_LEAVE_ALONE = -10000;
public static final int EXPANDED_FULL_OPEN = -10001;
- /** If true, delays dismissing the Keyguard until the ActivityManager calls back. */
- protected static final boolean DELAY_DISMISS_TO_ACTIVITY_LAUNCH = false;
-
protected CommandQueue mCommandQueue;
protected IStatusBarService mBarService;
protected H mHandler = createHandler();
@@ -163,6 +162,7 @@
protected DevicePolicyManager mDevicePolicyManager;
protected IDreamManager mDreamManager;
PowerManager mPowerManager;
+ protected StatusBarKeyguardViewManager mStatusBarKeyguardViewManager;
protected int mRowMinHeight;
protected int mRowMaxHeight;
@@ -252,27 +252,33 @@
}
final boolean isActivity = pendingIntent.isActivity();
if (isActivity) {
+ final boolean keyguardShowing = mStatusBarKeyguardViewManager.isShowing();
dismissKeyguardThenExecute(new OnDismissAction() {
@Override
public boolean onDismiss() {
- try {
- // The intent we are sending is for the application, which
- // won't have permission to immediately start an activity after
- // the user switches to home. We know it is safe to do at this
- // point, so make sure new activity switches are now allowed.
- ActivityManagerNative.getDefault().resumeAppSwitches();
- } catch (RemoteException e) {
+ if (keyguardShowing) {
+ try {
+ ActivityManagerNative.getDefault()
+ .keyguardWaitingForActivityDrawn();
+ // The intent we are sending is for the application, which
+ // won't have permission to immediately start an activity after
+ // the user switches to home. We know it is safe to do at this
+ // point, so make sure new activity switches are now allowed.
+ ActivityManagerNative.getDefault().resumeAppSwitches();
+ } catch (RemoteException e) {
+ }
}
boolean handled = superOnClickHandler(view, pendingIntent, fillInIntent);
+ overrideActivityPendingAppTransition(keyguardShowing);
// close the shade if it was open
if (handled) {
- animateCollapsePanels(CommandQueue.FLAG_EXCLUDE_NONE);
+ animateCollapsePanels(CommandQueue.FLAG_EXCLUDE_NONE, true /* force */);
visibilityChanged(false);
}
// Wait for activity start.
- return handled && DELAY_DISMISS_TO_ACTIVITY_LAUNCH;
+ return handled;
}
});
return true;
@@ -1064,7 +1070,7 @@
startAppNotificationSettingsActivity(pkg, appUidF);
animateCollapsePanels(CommandQueue.FLAG_EXCLUDE_NONE);
visibilityChanged(false);
- return DELAY_DISMISS_TO_ACTIVITY_LAUNCH;
+ return true;
}
});
}
@@ -1254,54 +1260,74 @@
}
public void onClick(final View v) {
+ final boolean keyguardShowing = mStatusBarKeyguardViewManager.isShowing();
dismissKeyguardThenExecute(new OnDismissAction() {
public boolean onDismiss() {
- try {
- // The intent we are sending is for the application, which
- // won't have permission to immediately start an activity after
- // the user switches to home. We know it is safe to do at this
- // point, so make sure new activity switches are now allowed.
- ActivityManagerNative.getDefault().resumeAppSwitches();
- } catch (RemoteException e) {
+ if (mIsHeadsUp) {
+ mHeadsUpNotificationView.clear();
}
+ AsyncTask.execute(new Runnable() {
+ @Override
+ public void run() {
+ if (keyguardShowing) {
+ try {
+ ActivityManagerNative.getDefault()
+ .keyguardWaitingForActivityDrawn();
+ // The intent we are sending is for the application, which
+ // won't have permission to immediately start an activity after
+ // the user switches to home. We know it is safe to do at this
+ // point, so make sure new activity switches are now allowed.
+ ActivityManagerNative.getDefault().resumeAppSwitches();
+ } catch (RemoteException e) {
+ }
+ }
- boolean sent = false;
- if (mIntent != null) {
- int[] pos = new int[2];
- v.getLocationOnScreen(pos);
- Intent overlay = new Intent();
- overlay.setSourceBounds(new Rect(pos[0], pos[1],
- pos[0] + v.getWidth(), pos[1] + v.getHeight()));
- try {
- mIntent.send(mContext, 0, overlay);
- sent = true;
- } catch (PendingIntent.CanceledException e) {
- // the stack trace isn't very helpful here.
- // Just log the exception message.
- Log.w(TAG, "Sending contentIntent failed: " + e);
- }
- }
+ if (mIntent != null) {
+ try {
+ mIntent.send();
+ } catch (PendingIntent.CanceledException e) {
+ // the stack trace isn't very helpful here.
+ // Just log the exception message.
+ Log.w(TAG, "Sending contentIntent failed: " + e);
- try {
- if (mIsHeadsUp) {
- mHeadsUpNotificationView.clear();
+ // TODO: Dismiss Keyguard.
+ }
+ if (mIntent.isActivity()) {
+ overrideActivityPendingAppTransition(keyguardShowing);
+ }
+ }
+
+ try {
+ mBarService.onNotificationClick(mNotificationKey);
+ } catch (RemoteException ex) {
+ // system process is dead if we're here.
+ }
}
- mBarService.onNotificationClick(mNotificationKey);
- } catch (RemoteException ex) {
- // system process is dead if we're here.
- }
+ });
// close the shade if it was open
- animateCollapsePanels(CommandQueue.FLAG_EXCLUDE_NONE);
+ animateCollapsePanels(CommandQueue.FLAG_EXCLUDE_NONE, true /* force */);
visibilityChanged(false);
- boolean waitForActivityLaunch = sent && mIntent.isActivity();
- return waitForActivityLaunch && DELAY_DISMISS_TO_ACTIVITY_LAUNCH;
+ return mIntent != null && mIntent.isActivity();
}
});
}
}
+ public void animateCollapsePanels(int flags, boolean force) {
+ }
+
+ public void overrideActivityPendingAppTransition(boolean keyguardShowing) {
+ if (keyguardShowing) {
+ try {
+ mWindowManagerService.overridePendingAppTransition(null, 0, 0, null);
+ } catch (RemoteException e) {
+ Log.w(TAG, "Error overriding app transition: " + e);
+ }
+ }
+ }
+
/**
* The LEDs are turned o)ff when the notification panel is shown, even just a little bit.
* This was added last-minute and is inconsistent with the way the rest of the notifications
diff --git a/packages/SystemUI/src/com/android/systemui/statusbar/phone/ActivityStarter.java b/packages/SystemUI/src/com/android/systemui/statusbar/phone/ActivityStarter.java
index 5bc7e5a..23810f9 100644
--- a/packages/SystemUI/src/com/android/systemui/statusbar/phone/ActivityStarter.java
+++ b/packages/SystemUI/src/com/android/systemui/statusbar/phone/ActivityStarter.java
@@ -24,5 +24,5 @@
* Keyguard.
*/
public interface ActivityStarter {
- public void startActivity(Intent intent);
+ public void startActivity(Intent intent, boolean dismissShade);
}
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 e11f20f..6a800fd 100644
--- a/packages/SystemUI/src/com/android/systemui/statusbar/phone/KeyguardBottomAreaView.java
+++ b/packages/SystemUI/src/com/android/systemui/statusbar/phone/KeyguardBottomAreaView.java
@@ -221,12 +221,12 @@
!mPreviewInflater.wouldLaunchResolverActivity(intent)) {
mContext.startActivityAsUser(intent, UserHandle.CURRENT);
} else {
- mActivityStarter.startActivity(intent);
+ mActivityStarter.startActivity(intent, false /* dismissShade */);
}
}
public void launchPhone() {
- mActivityStarter.startActivity(PHONE_INTENT);
+ mActivityStarter.startActivity(PHONE_INTENT, false /* dismissShade */);
}
diff --git a/packages/SystemUI/src/com/android/systemui/statusbar/phone/KeyguardBouncer.java b/packages/SystemUI/src/com/android/systemui/statusbar/phone/KeyguardBouncer.java
index db42b9d..fc737be 100644
--- a/packages/SystemUI/src/com/android/systemui/statusbar/phone/KeyguardBouncer.java
+++ b/packages/SystemUI/src/com/android/systemui/statusbar/phone/KeyguardBouncer.java
@@ -98,7 +98,7 @@
public void startPreHideAnimation(Runnable runnable) {
if (mKeyguardView != null) {
mKeyguardView.startDisappearAnimation(runnable);
- } else {
+ } else if (runnable != null) {
runnable.run();
}
}
diff --git a/packages/SystemUI/src/com/android/systemui/statusbar/phone/NotificationPanelView.java b/packages/SystemUI/src/com/android/systemui/statusbar/phone/NotificationPanelView.java
index acdc6bc..bac46be 100644
--- a/packages/SystemUI/src/com/android/systemui/statusbar/phone/NotificationPanelView.java
+++ b/packages/SystemUI/src/com/android/systemui/statusbar/phone/NotificationPanelView.java
@@ -414,12 +414,12 @@
}
@Override
- public void fling(float vel, boolean always) {
+ public void fling(float vel, boolean expand) {
GestureRecorder gr = ((PhoneStatusBarView) mBar).mBar.getGestureRecorder();
if (gr != null) {
gr.tag("fling " + ((vel > 0) ? "open" : "closed"), "notifications,v=" + vel);
}
- super.fling(vel, always);
+ super.fling(vel, expand);
}
@Override
diff --git a/packages/SystemUI/src/com/android/systemui/statusbar/phone/PanelBar.java b/packages/SystemUI/src/com/android/systemui/statusbar/phone/PanelBar.java
index 59f94f2..f74d2f4 100644
--- a/packages/SystemUI/src/com/android/systemui/statusbar/phone/PanelBar.java
+++ b/packages/SystemUI/src/com/android/systemui/statusbar/phone/PanelBar.java
@@ -140,7 +140,7 @@
mPanelHolder.setSelectedPanel(mTouchingPanel);
for (PanelView pv : mPanels) {
if (pv != panel) {
- pv.collapse();
+ pv.collapse(false /* delayed */);
}
}
}
@@ -191,7 +191,7 @@
boolean waiting = false;
for (PanelView pv : mPanels) {
if (animate && !pv.isFullyCollapsed()) {
- pv.collapse();
+ pv.collapse(true /* delayed */);
waiting = true;
} else {
pv.resetViews();
diff --git a/packages/SystemUI/src/com/android/systemui/statusbar/phone/PanelView.java b/packages/SystemUI/src/com/android/systemui/statusbar/phone/PanelView.java
index 469a831..c8e943e 100644
--- a/packages/SystemUI/src/com/android/systemui/statusbar/phone/PanelView.java
+++ b/packages/SystemUI/src/com/android/systemui/statusbar/phone/PanelView.java
@@ -99,6 +99,7 @@
};
protected void onExpandingFinished() {
+ mClosing = false;
mBar.onExpandingFinished();
}
@@ -150,7 +151,7 @@
postOnAnimation(new Runnable() {
@Override
public void run() {
- collapse();
+ collapse(false /* delayed */);
}
});
}
@@ -651,7 +652,7 @@
mBar = panelBar;
}
- public void collapse() {
+ public void collapse(boolean delayed) {
if (DEBUG) logf("collapse: " + this);
if (mPeekPending || mPeekAnimator != null) {
mCollapseAfterPeek = true;
@@ -668,7 +669,16 @@
}
mClosing = true;
notifyExpandingStarted();
- fling(0, false /* expand */);
+ if (delayed) {
+ postDelayed(new Runnable() {
+ @Override
+ public void run() {
+ fling(0, false /* expand */);
+ }
+ }, 120);
+ } else {
+ fling(0, false /* expand */);
+ }
}
}
@@ -856,7 +866,7 @@
private final Runnable mPostCollapseRunnable = new Runnable() {
@Override
public void run() {
- collapse();
+ collapse(false /* delayed */);
}
};
private boolean onMiddleClicked() {
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 caecf1d..6a81424 100644
--- a/packages/SystemUI/src/com/android/systemui/statusbar/phone/PhoneStatusBar.java
+++ b/packages/SystemUI/src/com/android/systemui/statusbar/phone/PhoneStatusBar.java
@@ -323,7 +323,7 @@
VelocityTracker mVelocityTracker;
int[] mAbsPos = new int[2];
- Runnable mPostCollapseCleanup = null;
+ ArrayList<Runnable> mPostCollapseRunnables = new ArrayList<>();
// for disabling the status bar
int mDisabled = 0;
@@ -395,7 +395,6 @@
private int mNavigationBarMode;
private Boolean mScreenOn;
- private StatusBarKeyguardViewManager mStatusBarKeyguardViewManager;
private ViewMediatorCallback mKeyguardViewMediatorCallback;
private ScrimController mScrimController;
@@ -575,6 +574,7 @@
mDozeServiceHost = new DozeServiceHost();
putComponent(DozeService.Host.class, mDozeServiceHost);
+ putComponent(PhoneStatusBar.class, this);
setControllerUsers();
}
@@ -887,14 +887,14 @@
return;
}
- mPostCollapseCleanup = new Runnable() {
+ addPostCollapseAction(new Runnable() {
@Override
public void run() {
try {
mBarService.onClearAllNotifications(mCurrentUserId);
} catch (Exception ex) { }
}
- };
+ });
performDismissAllAnimations(viewsToHide);
@@ -1366,6 +1366,17 @@
private void updateNotificationShade() {
if (mStackScroller == null) return;
+ // Do not modify the notifications during collapse.
+ if (isCollapsing()) {
+ addPostCollapseAction(new Runnable() {
+ @Override
+ public void run() {
+ updateNotificationShade();
+ }
+ });
+ return;
+ }
+
ArrayList<Entry> activeNotifications = mNotificationData.getActiveNotifications();
ArrayList<ExpandableNotificationRow> toShow = new ArrayList<>(activeNotifications.size());
final int N = activeNotifications.size();
@@ -2004,8 +2015,8 @@
}
@Override
- public void startActivity(Intent intent) {
- startActivityDismissingKeyguard(intent, false);
+ public void startActivity(Intent intent, boolean dismissShade) {
+ startActivityDismissingKeyguard(intent, false, dismissShade);
}
public ScrimController getScrimController() {
@@ -2126,10 +2137,7 @@
public void animateCollapsePanels(int flags, boolean force) {
if (!force &&
(mState == StatusBarState.KEYGUARD || mState == StatusBarState.SHADE_LOCKED)) {
- if (mPostCollapseCleanup != null) {
- mPostCollapseCleanup.run();
- mPostCollapseCleanup = null;
- }
+ runPostCollapseRunnables();
return;
}
if (SPEW) {
@@ -2159,6 +2167,14 @@
}
}
+ private void runPostCollapseRunnables() {
+ int size = mPostCollapseRunnables.size();
+ for (int i = 0; i < size; i++) {
+ mPostCollapseRunnables.get(i).run();
+ }
+ mPostCollapseRunnables.clear();
+ }
+
public ViewPropertyAnimator setVisibilityWhenDone(
final ViewPropertyAnimator a, final View v, final int vis) {
a.setListener(new AnimatorListenerAdapter() {
@@ -2270,11 +2286,7 @@
// Close any "App info" popups that might have snuck on-screen
dismissPopups();
- if (mPostCollapseCleanup != null) {
- mPostCollapseCleanup.run();
- mPostCollapseCleanup = null;
- }
-
+ runPostCollapseRunnables();
setInteracting(StatusBarManager.WINDOW_STATUS_BAR, false);
showBouncer();
disable(mDisabledUnmodified, true /* animate */);
@@ -2874,7 +2886,8 @@
}
}
- public void startActivityDismissingKeyguard(final Intent intent, boolean onlyProvisioned) {
+ public void startActivityDismissingKeyguard(final Intent intent, boolean onlyProvisioned,
+ final boolean dismissShade) {
if (onlyProvisioned && !isDeviceProvisioned()) return;
final boolean keyguardShowing = mStatusBarKeyguardViewManager.isShowing();
@@ -2884,32 +2897,27 @@
AsyncTask.execute(new Runnable() {
public void run() {
try {
+ if (keyguardShowing) {
+ ActivityManagerNative.getDefault()
+ .keyguardWaitingForActivityDrawn();
+ }
intent.setFlags(
Intent.FLAG_ACTIVITY_NEW_TASK | Intent.FLAG_ACTIVITY_CLEAR_TOP);
mContext.startActivityAsUser(
intent, new UserHandle(UserHandle.USER_CURRENT));
- if (keyguardShowing) {
- mWindowManagerService.overridePendingAppTransition(
- null, 0, 0, null);
- }
+ overrideActivityPendingAppTransition(keyguardShowing);
} catch (RemoteException e) {
}
}
});
- animateCollapsePanels();
-
- return DELAY_DISMISS_TO_ACTIVITY_LAUNCH;
+ if (dismissShade) {
+ animateCollapsePanels(CommandQueue.FLAG_EXCLUDE_NONE, true /* force */);
+ }
+ return true;
}
});
}
- private View.OnClickListener mClockClickListener = new View.OnClickListener() {
- public void onClick(View v) {
- startActivityDismissingKeyguard(
- new Intent(Intent.ACTION_QUICK_CLOCK), true); // have fun, everyone
- }
- };
-
private BroadcastReceiver mBroadcastReceiver = new BroadcastReceiver() {
public void onReceive(Context context, Intent intent) {
if (DEBUG) Log.v(TAG, "onReceive: " + intent);
@@ -3208,19 +3216,7 @@
}
private void handleStartSettingsActivity(Intent intent, boolean onlyProvisioned) {
- if (onlyProvisioned && !isDeviceProvisioned()) return;
- try {
- // Dismiss the lock screen when Settings starts.
- ActivityManagerNative.getDefault().dismissKeyguardOnNextActivity();
- } catch (RemoteException e) {
- }
- intent.setFlags(Intent.FLAG_ACTIVITY_NEW_TASK | Intent.FLAG_ACTIVITY_CLEAR_TOP);
- mContext.startActivityAsUser(intent, new UserHandle(UserHandle.USER_CURRENT));
- animateCollapsePanels();
- }
-
- public void startSettingsActivity(String action) {
- postStartSettingsActivity(new Intent(action), 0);
+ startActivityDismissingKeyguard(intent, onlyProvisioned, true /* dismissShade */);
}
private static class FastColorDrawable extends Drawable {
@@ -3363,6 +3359,14 @@
}
}
+ public boolean isCollapsing() {
+ return mNotificationPanel.isCollapsing();
+ }
+
+ public void addPostCollapseAction(Runnable r) {
+ mPostCollapseRunnables.add(r);
+ }
+
public boolean isInLaunchTransition() {
return mNotificationPanel.isLaunchTransitionRunning()
|| mNotificationPanel.isLaunchTransitionFinished();
@@ -3603,10 +3607,7 @@
}
public void onTrackingStarted() {
- if (mPostCollapseCleanup != null) {
- mPostCollapseCleanup.run();
- mPostCollapseCleanup = null;
- }
+ runPostCollapseRunnables();
}
public void onUnlockHintStarted() {
diff --git a/packages/SystemUI/src/com/android/systemui/statusbar/phone/StatusBarHeaderView.java b/packages/SystemUI/src/com/android/systemui/statusbar/phone/StatusBarHeaderView.java
index 0c62fd3..85aa00d 100644
--- a/packages/SystemUI/src/com/android/systemui/statusbar/phone/StatusBarHeaderView.java
+++ b/packages/SystemUI/src/com/android/systemui/statusbar/phone/StatusBarHeaderView.java
@@ -483,17 +483,19 @@
} else if (v == mAlarmStatus && mNextAlarm != null) {
PendingIntent showIntent = mNextAlarm.getShowIntent();
if (showIntent != null && showIntent.isActivity()) {
- mActivityStarter.startActivity(showIntent.getIntent());
+ mActivityStarter.startActivity(showIntent.getIntent(), true /* dismissShade */);
}
}
}
private void startSettingsActivity() {
- mActivityStarter.startActivity(new Intent(android.provider.Settings.ACTION_SETTINGS));
+ mActivityStarter.startActivity(new Intent(android.provider.Settings.ACTION_SETTINGS),
+ true /* dismissShade */);
}
private void startBatteryActivity() {
- mActivityStarter.startActivity(new Intent(Intent.ACTION_POWER_USAGE_SUMMARY));
+ mActivityStarter.startActivity(new Intent(Intent.ACTION_POWER_USAGE_SUMMARY),
+ true /* dismissShade */);
}
public void setQSPanel(QSPanel qsp) {
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 68dd4f9..b03e6c0 100644
--- a/packages/SystemUI/src/com/android/systemui/statusbar/phone/StatusBarKeyguardViewManager.java
+++ b/packages/SystemUI/src/com/android/systemui/statusbar/phone/StatusBarKeyguardViewManager.java
@@ -206,12 +206,13 @@
* Starts the animation before we dismiss Keyguard, i.e. an disappearing animation on the
* security view of the bouncer.
*
- * @param finishRunnable the runnable to be run after the animation finished
+ * @param finishRunnable the runnable to be run after the animation finished, or {@code null} if
+ * no action should be run
*/
public void startPreHideAnimation(Runnable finishRunnable) {
if (mBouncer.isShowing()) {
mBouncer.startPreHideAnimation(finishRunnable);
- } else {
+ } else if (finishRunnable != null) {
finishRunnable.run();
}
}
@@ -362,4 +363,17 @@
public boolean interceptMediaKey(KeyEvent event) {
return mBouncer.interceptMediaKey(event);
}
+
+ public void onActivityDrawn() {
+ if (mPhoneStatusBar.isCollapsing()) {
+ mPhoneStatusBar.addPostCollapseAction(new Runnable() {
+ @Override
+ public void run() {
+ mViewMediatorCallback.readyForKeyguardDone();
+ }
+ });
+ } else {
+ mViewMediatorCallback.readyForKeyguardDone();
+ }
+ }
}
diff --git a/packages/SystemUI/src/com/android/systemui/volume/VolumeUI.java b/packages/SystemUI/src/com/android/systemui/volume/VolumeUI.java
index 04a3b88..0586a83 100644
--- a/packages/SystemUI/src/com/android/systemui/volume/VolumeUI.java
+++ b/packages/SystemUI/src/com/android/systemui/volume/VolumeUI.java
@@ -1,6 +1,5 @@
package com.android.systemui.volume;
-import android.app.ActivityManagerNative;
import android.content.Context;
import android.content.Intent;
import android.content.res.Configuration;
@@ -18,10 +17,12 @@
import android.os.UserHandle;
import android.provider.Settings;
import android.util.Log;
+import android.view.WindowManagerGlobal;
import com.android.systemui.R;
import com.android.systemui.SystemUI;
import com.android.systemui.keyguard.KeyguardViewMediator;
+import com.android.systemui.statusbar.phone.PhoneStatusBar;
import com.android.systemui.statusbar.policy.ZenModeController;
import com.android.systemui.statusbar.policy.ZenModeControllerImpl;
@@ -138,22 +139,8 @@
private final Runnable mStartZenSettings = new Runnable() {
@Override
public void run() {
- AsyncTask.execute(new Runnable() {
- @Override
- public void run() {
- try {
- // Dismiss the lock screen when Settings starts.
- ActivityManagerNative.getDefault().dismissKeyguardOnNextActivity();
- } catch (RemoteException e) {
- }
- final Intent intent = ZenModePanel.ZEN_SETTINGS;
- intent.setFlags(Intent.FLAG_ACTIVITY_NEW_TASK | Intent.FLAG_ACTIVITY_CLEAR_TOP);
- mContext.startActivityAsUser(intent, new UserHandle(UserHandle.USER_CURRENT));
-
- // dismiss shade if showing
- mContext.sendBroadcast(new Intent(Intent.ACTION_CLOSE_SYSTEM_DIALOGS));
- }
- });
+ getComponent(PhoneStatusBar.class).startActivityDismissingKeyguard(
+ ZenModePanel.ZEN_SETTINGS, true /* onlyProvisioned */, true /* dismissShade */);
mPanel.postDismiss(mDismissDelay);
}
};
diff --git a/policy/src/com/android/internal/policy/impl/PhoneWindowManager.java b/policy/src/com/android/internal/policy/impl/PhoneWindowManager.java
index ca260ec..7efda1a 100644
--- a/policy/src/com/android/internal/policy/impl/PhoneWindowManager.java
+++ b/policy/src/com/android/internal/policy/impl/PhoneWindowManager.java
@@ -4766,13 +4766,19 @@
mHandler.post(new Runnable() {
@Override
public void run() {
- if (mKeyguardDelegate.isDismissable()) {
- // Can we just finish the keyguard straight away?
- mKeyguardDelegate.keyguardDone(false, true);
- } else {
- // ask the keyguard to prompt the user to authenticate if necessary
- mKeyguardDelegate.dismiss();
- }
+ // ask the keyguard to prompt the user to authenticate if necessary
+ mKeyguardDelegate.dismiss();
+ }
+ });
+ }
+ }
+
+ public void notifyActivityDrawnForKeyguardLw() {
+ if (mKeyguardDelegate != null) {
+ mHandler.post(new Runnable() {
+ @Override
+ public void run() {
+ mKeyguardDelegate.onActivityDrawn();
}
});
}
diff --git a/policy/src/com/android/internal/policy/impl/keyguard/KeyguardServiceDelegate.java b/policy/src/com/android/internal/policy/impl/keyguard/KeyguardServiceDelegate.java
index 63a5850..aac02ad 100644
--- a/policy/src/com/android/internal/policy/impl/keyguard/KeyguardServiceDelegate.java
+++ b/policy/src/com/android/internal/policy/impl/keyguard/KeyguardServiceDelegate.java
@@ -334,4 +334,9 @@
mKeyguardState.bootCompleted = true;
}
+ public void onActivityDrawn() {
+ if (mKeyguardService != null) {
+ mKeyguardService.onActivityDrawn();
+ }
+ }
}
diff --git a/policy/src/com/android/internal/policy/impl/keyguard/KeyguardServiceWrapper.java b/policy/src/com/android/internal/policy/impl/keyguard/KeyguardServiceWrapper.java
index 5096bd3..2778b15 100644
--- a/policy/src/com/android/internal/policy/impl/keyguard/KeyguardServiceWrapper.java
+++ b/policy/src/com/android/internal/policy/impl/keyguard/KeyguardServiceWrapper.java
@@ -198,6 +198,14 @@
}
}
+ public void onActivityDrawn() {
+ try {
+ mService.onActivityDrawn();
+ } catch (RemoteException e) {
+ Slog.w(TAG , "Remote Exception", e);
+ }
+ }
+
public void showAssistant() {
// Not used by PhoneWindowManager
}
diff --git a/services/core/java/com/android/server/am/ActivityManagerService.java b/services/core/java/com/android/server/am/ActivityManagerService.java
index 6054401..6ca64d3 100755
--- a/services/core/java/com/android/server/am/ActivityManagerService.java
+++ b/services/core/java/com/android/server/am/ActivityManagerService.java
@@ -5639,17 +5639,13 @@
}
@Override
- public void dismissKeyguardOnNextActivity() {
- enforceNotIsolatedCaller("dismissKeyguardOnNextActivity");
+ public void keyguardWaitingForActivityDrawn() {
+ enforceNotIsolatedCaller("keyguardWaitingForActivityDrawn");
final long token = Binder.clearCallingIdentity();
try {
synchronized (this) {
if (DEBUG_LOCKSCREEN) logLockScreen("");
- if (mLockScreenShown) {
- mLockScreenShown = false;
- comeOutOfSleepIfNeededLocked();
- }
- mStackSupervisor.setDismissKeyguard(true);
+ mWindowManager.keyguardWaitingForActivityDrawn();
}
} finally {
Binder.restoreCallingIdentity(token);
@@ -9263,8 +9259,7 @@
void logLockScreen(String msg) {
if (DEBUG_LOCKSCREEN) Slog.d(TAG, Debug.getCallers(2) + ":" + msg +
" mLockScreenShown=" + mLockScreenShown + " mWentToSleep=" +
- mWentToSleep + " mSleeping=" + mSleeping + " mDismissKeyguardOnNextActivity=" +
- mStackSupervisor.mDismissKeyguardOnNextActivity);
+ mWentToSleep + " mSleeping=" + mSleeping);
}
private void comeOutOfSleepIfNeededLocked() {
diff --git a/services/core/java/com/android/server/am/ActivityStack.java b/services/core/java/com/android/server/am/ActivityStack.java
index 4653742..3f02184 100755
--- a/services/core/java/com/android/server/am/ActivityStack.java
+++ b/services/core/java/com/android/server/am/ActivityStack.java
@@ -46,7 +46,6 @@
import com.android.server.Watchdog;
import com.android.server.am.ActivityManagerService.ItemMatcher;
import com.android.server.am.ActivityStackSupervisor.ActivityContainer;
-import com.android.server.am.ActivityStackSupervisor.ActivityDisplay;
import com.android.server.wm.AppTransition;
import com.android.server.wm.TaskGroup;
import com.android.server.wm.WindowManagerService;
@@ -1059,7 +1058,7 @@
if (next.nowVisible) {
// We won't get a call to reportActivityVisibleLocked() so dismiss lockscreen now.
- mStackSupervisor.dismissKeyguard();
+ mStackSupervisor.notifyActivityDrawnForKeyguard();
}
// schedule an idle timeout in case the app doesn't do it for us.
diff --git a/services/core/java/com/android/server/am/ActivityStackSupervisor.java b/services/core/java/com/android/server/am/ActivityStackSupervisor.java
index 3d23cb7..91cfd78 100644
--- a/services/core/java/com/android/server/am/ActivityStackSupervisor.java
+++ b/services/core/java/com/android/server/am/ActivityStackSupervisor.java
@@ -167,9 +167,6 @@
WindowManagerService mWindowManager;
DisplayManager mDisplayManager;
- /** Dismiss the keyguard after the next activity is displayed? */
- boolean mDismissKeyguardOnNextActivity = false;
-
/** Identifier counter for all ActivityStacks */
private int mLastStackId = HOME_STACK_ID;
@@ -363,12 +360,9 @@
}
}
- void dismissKeyguard() {
+ void notifyActivityDrawnForKeyguard() {
if (ActivityManagerService.DEBUG_LOCKSCREEN) mService.logLockScreen("");
- if (mDismissKeyguardOnNextActivity) {
- mDismissKeyguardOnNextActivity = false;
- mWindowManager.dismissKeyguard();
- }
+ mWindowManager.notifyActivityDrawnForKeyguard();
}
ActivityStack getFocusedStack() {
@@ -439,9 +433,8 @@
return mService.startHomeActivityLocked(mCurrentUser);
}
- void setDismissKeyguard(boolean dismiss) {
- if (ActivityManagerService.DEBUG_LOCKSCREEN) mService.logLockScreen(" dismiss=" + dismiss);
- mDismissKeyguardOnNextActivity = dismiss;
+ void keyguardWaitingForActivityDrawn() {
+ mWindowManager.keyguardWaitingForActivityDrawn();
}
TaskRecord anyTaskForIdLocked(int id) {
@@ -660,7 +653,7 @@
w.thisTime = w.totalTime;
}
mService.notifyAll();
- dismissKeyguard();
+ notifyActivityDrawnForKeyguard();
}
void reportActivityLaunchedLocked(boolean timeout, ActivityRecord r,
@@ -1371,7 +1364,6 @@
resultRecord, resultWho, requestCode,
Activity.RESULT_CANCELED, null);
}
- setDismissKeyguard(false);
ActivityOptions.abort(options);
return err;
}
@@ -1386,7 +1378,6 @@
resultRecord, resultWho, requestCode,
Activity.RESULT_CANCELED, null);
}
- setDismissKeyguard(false);
String msg;
if (!aInfo.exported) {
msg = "Permission Denial: starting " + intent.toString()
@@ -1425,7 +1416,6 @@
}
// We pretend to the caller that it was really started, but
// they will just get a cancel result.
- setDismissKeyguard(false);
ActivityOptions.abort(options);
return ActivityManager.START_SUCCESS;
}
@@ -1444,7 +1434,6 @@
PendingActivityLaunch pal =
new PendingActivityLaunch(r, sourceRecord, startFlags, stack);
mPendingActivityLaunches.add(pal);
- setDismissKeyguard(false);
ActivityOptions.abort(options);
return ActivityManager.START_SWITCHES_CANCELED;
}
@@ -1466,12 +1455,12 @@
err = startActivityUncheckedLocked(r, sourceRecord, voiceSession, voiceInteractor,
startFlags, true, options);
- if (allPausedActivitiesComplete()) {
+ if (err < 0) {
// If someone asked to have the keyguard dismissed on the next
// activity start, but we are not actually doing an activity
// switch... just dismiss the keyguard now, because we
// probably want to see whatever is behind it.
- dismissKeyguard();
+ notifyActivityDrawnForKeyguard();
}
return err;
}
@@ -2852,8 +2841,6 @@
}
public void dump(PrintWriter pw, String prefix) {
- pw.print(prefix); pw.print("mDismissKeyguardOnNextActivity=");
- pw.println(mDismissKeyguardOnNextActivity);
pw.print(prefix); pw.print("mFocusedStack=" + mFocusedStack);
pw.print(" mLastFocusedStack="); pw.println(mLastFocusedStack);
pw.print(prefix); pw.println("mSleepTimeout=" + mSleepTimeout);
diff --git a/services/core/java/com/android/server/wm/WindowManagerService.java b/services/core/java/com/android/server/wm/WindowManagerService.java
index e7ebae7..26dc448 100644
--- a/services/core/java/com/android/server/wm/WindowManagerService.java
+++ b/services/core/java/com/android/server/wm/WindowManagerService.java
@@ -462,6 +462,9 @@
int mRotation = 0;
int mForcedAppOrientation = ActivityInfo.SCREEN_ORIENTATION_UNSPECIFIED;
boolean mAltOrientation = false;
+
+ private boolean mKeyguardWaitingForActivityDrawn;
+
class RotationWatcher {
IRotationWatcher watcher;
IBinder.DeathRecipient deathRecipient;
@@ -5247,6 +5250,20 @@
}
}
+ public void keyguardWaitingForActivityDrawn() {
+ synchronized (mWindowMap) {
+ mKeyguardWaitingForActivityDrawn = true;
+ }
+ }
+
+ public void notifyActivityDrawnForKeyguard() {
+ synchronized (mWindowMap) {
+ if (mKeyguardWaitingForActivityDrawn) {
+ mPolicy.notifyActivityDrawnForKeyguardLw();
+ }
+ }
+ }
+
void showGlobalActions() {
mPolicy.showGlobalActions();
}