Skip to content

Commit

Permalink
base: don't show global actions if shutdown sequence was started
Browse files Browse the repository at this point in the history
Change-Id: Icd77aa7529faf438dcc80e45434826465a11aab8
Signed-off-by: Jorge Ruesga <jorge@ruesga.com>

Conflicts:
	services/java/com/android/server/power/ShutdownThread.java
  • Loading branch information
jruesga authored and Mahdi-Rom committed Jun 22, 2014
1 parent f048d50 commit a31ff00
Show file tree
Hide file tree
Showing 4 changed files with 34 additions and 15 deletions.
1 change: 1 addition & 0 deletions core/java/android/view/WindowManagerPolicy.java
Expand Up @@ -430,6 +430,7 @@ public FakeWindow addFakeWindow(Looper looper,
public void shutdown(boolean confirm);
public void rebootSafeMode(boolean confirm);
public void reboot();
public boolean isShutdownSequenceStarted();

/**
* Return the window manager lock needed to correctly call "Lw" methods.
Expand Down
Expand Up @@ -1023,18 +1023,26 @@ else if (FactoryTest.isLongPressOnPowerOffEnabled()) {
break;
case LONG_PRESS_POWER_GLOBAL_ACTIONS:
mPowerKeyHandled = true;
if (!performHapticFeedbackLw(null, HapticFeedbackConstants.LONG_PRESS, false)) {
performAuditoryFeedbackForAccessibilityIfNeed();
if (mWindowManagerFuncs.isShutdownSequenceStarted()) {
sendCloseSystemWindows(SYSTEM_DIALOG_REASON_GLOBAL_ACTIONS);
} else {
if (!performHapticFeedbackLw(null, HapticFeedbackConstants.LONG_PRESS, false)) {
performAuditoryFeedbackForAccessibilityIfNeed();
}
sendCloseSystemWindows(SYSTEM_DIALOG_REASON_GLOBAL_ACTIONS);
showGlobalActionsDialog();
}
sendCloseSystemWindows(SYSTEM_DIALOG_REASON_GLOBAL_ACTIONS);
showGlobalActionsDialog();
break;
case LONG_PRESS_POWER_SHUT_OFF:
case LONG_PRESS_POWER_SHUT_OFF_NO_CONFIRM:
mPowerKeyHandled = true;
performHapticFeedbackLw(null, HapticFeedbackConstants.LONG_PRESS, false);
sendCloseSystemWindows(SYSTEM_DIALOG_REASON_GLOBAL_ACTIONS);
mWindowManagerFuncs.shutdown(resolvedBehavior == LONG_PRESS_POWER_SHUT_OFF);
if (mWindowManagerFuncs.isShutdownSequenceStarted()) {
sendCloseSystemWindows(SYSTEM_DIALOG_REASON_GLOBAL_ACTIONS);
} else {
performHapticFeedbackLw(null, HapticFeedbackConstants.LONG_PRESS, false);
sendCloseSystemWindows(SYSTEM_DIALOG_REASON_GLOBAL_ACTIONS);
mWindowManagerFuncs.shutdown(resolvedBehavior == LONG_PRESS_POWER_SHUT_OFF);
}
break;
}
}
Expand Down
20 changes: 12 additions & 8 deletions services/java/com/android/server/power/ShutdownThread.java
Expand Up @@ -15,7 +15,6 @@
* limitations under the License.
*/


package com.android.server.power;

import java.util.concurrent.atomic.AtomicBoolean;
Expand Down Expand Up @@ -65,11 +64,11 @@ public final class ShutdownThread extends Thread {

// length of vibration before shutting down
private static final int SHUTDOWN_VIBRATE_MS = 500;

// state tracking
private static Object sIsStartedGuard = new Object();
private static boolean sIsStarted = false;

private static boolean mReboot;
private static boolean mRebootSafeMode;
private static String mRebootReason;
Expand All @@ -94,10 +93,16 @@ public final class ShutdownThread extends Thread {
private Handler mHandler;

private static AlertDialog sConfirmDialog;

private ShutdownThread() {
}


public static boolean isStarted() {
synchronized (sIsStartedGuard) {
return sIsStarted;
}
}

/**
* Request a clean shutdown, waiting for subsystems to clean up their
* state etc. Must be called from a Looper thread in which its UI
Expand Down Expand Up @@ -358,14 +363,13 @@ public void run() {
// Shutdown radios.
shutdownRadios(MAX_RADIO_WAIT_TIME);
Log.i(TAG, "Sending shutdown broadcast...");

// First send the high-level shut down broadcast.
Intent intent = new Intent(Intent.ACTION_SHUTDOWN);
intent.addFlags(Intent.FLAG_RECEIVER_FOREGROUND);
mContext.sendBroadcastAsUser(intent, UserHandle.ALL);

Log.i(TAG, "Shutting down activity manager...");

final IActivityManager am =
ActivityManagerNative.asInterface(ServiceManager.checkService("activity"));
if (am != null) {
Expand Down
6 changes: 6 additions & 0 deletions services/java/com/android/server/wm/WindowManagerService.java
Expand Up @@ -5346,6 +5346,12 @@ public void rebootSafeMode(boolean confirm) {
ShutdownThread.rebootSafeMode(getUiContext(), confirm);
}

// Called by window manager policy. Not exposed externally.
@Override
public boolean isShutdownSequenceStarted() {
return ShutdownThread.isStarted();
}

@Override
public void setInputFilter(IInputFilter filter) {
if (!checkCallingPermission(android.Manifest.permission.FILTER_EVENTS, "setInputFilter()")) {
Expand Down

0 comments on commit a31ff00

Please sign in to comment.