am eccaf729: Allow going to home action to work for SHORT_PRESS_POWER_GO_HOME with keyguard enabled.

* commit 'eccaf7290ab833d12049a184747603cd74261490':
  Allow going to home action to work for SHORT_PRESS_POWER_GO_HOME with keyguard enabled.
This commit is contained in:
Bryce Lee
2015-04-10 19:51:32 +00:00
committed by Android Git Automerger

View File

@@ -992,7 +992,7 @@ public class PhoneWindowManager implements WindowManagerPolicy {
launchHomeFromHotKey(); launchHomeFromHotKey();
break; break;
case SHORT_PRESS_POWER_GO_HOME: case SHORT_PRESS_POWER_GO_HOME:
launchHomeFromHotKey(); launchHomeFromHotKey(true /* awakenFromDreams */, false /*respectKeyguard*/);
break; break;
} }
} }
@@ -1070,7 +1070,7 @@ public class PhoneWindowManager implements WindowManagerPolicy {
PowerManager.GO_TO_SLEEP_REASON_SLEEP_BUTTON, 0); PowerManager.GO_TO_SLEEP_REASON_SLEEP_BUTTON, 0);
break; break;
case SHORT_PRESS_SLEEP_GO_TO_SLEEP_AND_GO_HOME: case SHORT_PRESS_SLEEP_GO_TO_SLEEP_AND_GO_HOME:
launchHomeFromHotKey(false /* awakenDreams */); launchHomeFromHotKey(false /* awakenDreams */, true /*respectKeyguard*/);
mPowerManager.goToSleep(event.getEventTime(), mPowerManager.goToSleep(event.getEventTime(),
PowerManager.GO_TO_SLEEP_REASON_SLEEP_BUTTON, 0); PowerManager.GO_TO_SLEEP_REASON_SLEEP_BUTTON, 0);
break; break;
@@ -3064,50 +3064,56 @@ public class PhoneWindowManager implements WindowManagerPolicy {
} }
void launchHomeFromHotKey() { void launchHomeFromHotKey() {
launchHomeFromHotKey(true /* awakenFromDreams */); launchHomeFromHotKey(true /* awakenFromDreams */, true /*respectKeyguard*/);
} }
/** /**
* A home key -> launch home action was detected. Take the appropriate action * A home key -> launch home action was detected. Take the appropriate action
* given the situation with the keyguard. * given the situation with the keyguard.
*/ */
void launchHomeFromHotKey(final boolean awakenFromDreams) { void launchHomeFromHotKey(final boolean awakenFromDreams, final boolean respectKeyguard) {
if (isKeyguardShowingAndNotOccluded()) { if (respectKeyguard) {
// don't launch home if keyguard showing if (isKeyguardShowingAndNotOccluded()) {
} else if (!mHideLockScreen && mKeyguardDelegate.isInputRestricted()) { // don't launch home if keyguard showing
// when in keyguard restricted mode, must first verify unlock return;
// before launching home }
mKeyguardDelegate.verifyUnlock(new OnKeyguardExitResult() {
@Override if (!mHideLockScreen && mKeyguardDelegate.isInputRestricted()) {
public void onKeyguardExitResult(boolean success) { // when in keyguard restricted mode, must first verify unlock
if (success) { // before launching home
try { mKeyguardDelegate.verifyUnlock(new OnKeyguardExitResult() {
ActivityManagerNative.getDefault().stopAppSwitches(); @Override
} catch (RemoteException e) { public void onKeyguardExitResult(boolean success) {
if (success) {
try {
ActivityManagerNative.getDefault().stopAppSwitches();
} catch (RemoteException e) {
}
sendCloseSystemWindows(SYSTEM_DIALOG_REASON_HOME_KEY);
startDockOrHome(true /*fromHomeKey*/, awakenFromDreams);
} }
sendCloseSystemWindows(SYSTEM_DIALOG_REASON_HOME_KEY);
startDockOrHome(true /*fromHomeKey*/, awakenFromDreams);
} }
} });
}); return;
}
}
// no keyguard stuff to worry about, just launch home!
try {
ActivityManagerNative.getDefault().stopAppSwitches();
} catch (RemoteException e) {
}
if (mRecentsVisible) {
// Hide Recents and notify it to launch Home
if (awakenFromDreams) {
awakenDreams();
}
sendCloseSystemWindows(SYSTEM_DIALOG_REASON_HOME_KEY);
hideRecentApps(false, true);
} else { } else {
// no keyguard stuff to worry about, just launch home! // Otherwise, just launch Home
try { sendCloseSystemWindows(SYSTEM_DIALOG_REASON_HOME_KEY);
ActivityManagerNative.getDefault().stopAppSwitches(); startDockOrHome(true /*fromHomeKey*/, awakenFromDreams);
} catch (RemoteException e) {
}
if (mRecentsVisible) {
// Hide Recents and notify it to launch Home
if (awakenFromDreams) {
awakenDreams();
}
sendCloseSystemWindows(SYSTEM_DIALOG_REASON_HOME_KEY);
hideRecentApps(false, true);
} else {
// Otherwise, just launch Home
sendCloseSystemWindows(SYSTEM_DIALOG_REASON_HOME_KEY);
startDockOrHome(true /*fromHomeKey*/, awakenFromDreams);
}
} }
} }