diff options
author | Bryce Lee <brycelee@google.com> | 2015-02-07 00:41:29 +0000 |
---|---|---|
committer | android-build-merger <android-build-merger@google.com> | 2015-02-07 00:41:29 +0000 |
commit | f5a3fee9d6d116754be4ce8746465c202a07c499 (patch) | |
tree | cbde738751a0c29813e8ff289a5eb0cc71de3325 | |
parent | 11f51ffad2559298be9ab3c0775754164c3f6f7f (diff) | |
parent | d1444b63a173ce21f8588e09fd17f3cc83528c24 (diff) | |
download | frameworks_base-f5a3fee9d6d116754be4ce8746465c202a07c499.zip frameworks_base-f5a3fee9d6d116754be4ce8746465c202a07c499.tar.gz frameworks_base-f5a3fee9d6d116754be4ce8746465c202a07c499.tar.bz2 |
am 1d97aa4d: Merge "Allow single press of physical button to go home without sleeping." into lmp-mr1-modular-dev
automerge: d1444b6
* commit 'd1444b63a173ce21f8588e09fd17f3cc83528c24':
Allow single press of physical button to go home without sleeping.
-rw-r--r-- | core/java/android/view/WindowManagerPolicy.java | 8 | ||||
-rw-r--r-- | policy/src/com/android/internal/policy/impl/PhoneWindowManager.java | 26 |
2 files changed, 29 insertions, 5 deletions
diff --git a/core/java/android/view/WindowManagerPolicy.java b/core/java/android/view/WindowManagerPolicy.java index ff1fde7..3f35612 100644 --- a/core/java/android/view/WindowManagerPolicy.java +++ b/core/java/android/view/WindowManagerPolicy.java @@ -17,6 +17,7 @@ package android.view; import android.annotation.IntDef; +import android.annotation.SystemApi; import android.content.Context; import android.content.pm.ActivityInfo; import android.content.res.CompatibilityInfo; @@ -105,6 +106,13 @@ public interface WindowManagerPolicy { public final static String EXTRA_HDMI_PLUGGED_STATE = "state"; /** + * Set to {@code true} when intent was invoked from pressing the home key. + * @hide + */ + @SystemApi + public static final String EXTRA_FROM_HOME_KEY = "android.intent.extra.FROM_HOME_KEY"; + + /** * Pass this event to the user / app. To be returned from * {@link #interceptKeyBeforeQueueing}. */ diff --git a/policy/src/com/android/internal/policy/impl/PhoneWindowManager.java b/policy/src/com/android/internal/policy/impl/PhoneWindowManager.java index 8320656..dca7db1 100644 --- a/policy/src/com/android/internal/policy/impl/PhoneWindowManager.java +++ b/policy/src/com/android/internal/policy/impl/PhoneWindowManager.java @@ -154,6 +154,7 @@ public class PhoneWindowManager implements WindowManagerPolicy { static final int SHORT_PRESS_POWER_GO_TO_SLEEP = 1; static final int SHORT_PRESS_POWER_REALLY_GO_TO_SLEEP = 2; static final int SHORT_PRESS_POWER_REALLY_GO_TO_SLEEP_AND_GO_HOME = 3; + static final int SHORT_PRESS_POWER_GO_HOME = 4; static final int LONG_PRESS_POWER_NOTHING = 0; static final int LONG_PRESS_POWER_GLOBAL_ACTIONS = 1; @@ -974,6 +975,9 @@ public class PhoneWindowManager implements WindowManagerPolicy { PowerManager.GO_TO_SLEEP_FLAG_NO_DOZE); launchHomeFromHotKey(); break; + case SHORT_PRESS_POWER_GO_HOME: + launchHomeFromHotKey(); + break; } } } @@ -2989,7 +2993,7 @@ public class PhoneWindowManager implements WindowManagerPolicy { } catch (RemoteException e) { } sendCloseSystemWindows(SYSTEM_DIALOG_REASON_HOME_KEY); - startDockOrHome(); + startDockOrHome(true /*fromHomeKey*/); } } }); @@ -3007,7 +3011,7 @@ public class PhoneWindowManager implements WindowManagerPolicy { } else { // Otherwise, just launch Home sendCloseSystemWindows(SYSTEM_DIALOG_REASON_HOME_KEY); - startDockOrHome(); + startDockOrHome(true /*fromHomeKey*/); } } } @@ -5880,19 +5884,31 @@ public class PhoneWindowManager implements WindowManagerPolicy { return null; } - void startDockOrHome() { + void startDockOrHome(boolean fromHomeKey) { awakenDreams(); Intent dock = createHomeDockIntent(); if (dock != null) { try { + if (fromHomeKey) { + dock.putExtra(WindowManagerPolicy.EXTRA_FROM_HOME_KEY, fromHomeKey); + } mContext.startActivityAsUser(dock, UserHandle.CURRENT); return; } catch (ActivityNotFoundException e) { } } - mContext.startActivityAsUser(mHomeIntent, UserHandle.CURRENT); + Intent intent; + + if (fromHomeKey) { + intent = new Intent(mHomeIntent); + intent.putExtra(WindowManagerPolicy.EXTRA_FROM_HOME_KEY, fromHomeKey); + } else { + intent = mHomeIntent; + } + + mContext.startActivityAsUser(intent, UserHandle.CURRENT); } /** @@ -5907,7 +5923,7 @@ public class PhoneWindowManager implements WindowManagerPolicy { } catch (RemoteException e) { } sendCloseSystemWindows(); - startDockOrHome(); + startDockOrHome(false /*fromHomeKey*/); } else { // This code brings home to the front or, if it is already // at the front, puts the device to sleep. |