Merge "Allow single press of physical button to go home without sleeping." into lmp-mr1-modular-dev
This commit is contained in:
@ -17,6 +17,7 @@
|
|||||||
package android.view;
|
package android.view;
|
||||||
|
|
||||||
import android.annotation.IntDef;
|
import android.annotation.IntDef;
|
||||||
|
import android.annotation.SystemApi;
|
||||||
import android.content.Context;
|
import android.content.Context;
|
||||||
import android.content.pm.ActivityInfo;
|
import android.content.pm.ActivityInfo;
|
||||||
import android.content.res.CompatibilityInfo;
|
import android.content.res.CompatibilityInfo;
|
||||||
@ -104,6 +105,13 @@ public interface WindowManagerPolicy {
|
|||||||
*/
|
*/
|
||||||
public final static String EXTRA_HDMI_PLUGGED_STATE = "state";
|
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
|
* Pass this event to the user / app. To be returned from
|
||||||
* {@link #interceptKeyBeforeQueueing}.
|
* {@link #interceptKeyBeforeQueueing}.
|
||||||
|
@ -153,6 +153,7 @@ public class PhoneWindowManager implements WindowManagerPolicy {
|
|||||||
static final int SHORT_PRESS_POWER_GO_TO_SLEEP = 1;
|
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 = 2;
|
||||||
static final int SHORT_PRESS_POWER_REALLY_GO_TO_SLEEP_AND_GO_HOME = 3;
|
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_NOTHING = 0;
|
||||||
static final int LONG_PRESS_POWER_GLOBAL_ACTIONS = 1;
|
static final int LONG_PRESS_POWER_GLOBAL_ACTIONS = 1;
|
||||||
@ -971,6 +972,9 @@ public class PhoneWindowManager implements WindowManagerPolicy {
|
|||||||
PowerManager.GO_TO_SLEEP_FLAG_NO_DOZE);
|
PowerManager.GO_TO_SLEEP_FLAG_NO_DOZE);
|
||||||
launchHomeFromHotKey();
|
launchHomeFromHotKey();
|
||||||
break;
|
break;
|
||||||
|
case SHORT_PRESS_POWER_GO_HOME:
|
||||||
|
launchHomeFromHotKey();
|
||||||
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -2991,7 +2995,7 @@ public class PhoneWindowManager implements WindowManagerPolicy {
|
|||||||
} catch (RemoteException e) {
|
} catch (RemoteException e) {
|
||||||
}
|
}
|
||||||
sendCloseSystemWindows(SYSTEM_DIALOG_REASON_HOME_KEY);
|
sendCloseSystemWindows(SYSTEM_DIALOG_REASON_HOME_KEY);
|
||||||
startDockOrHome();
|
startDockOrHome(true /*fromHomeKey*/);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
@ -3009,7 +3013,7 @@ public class PhoneWindowManager implements WindowManagerPolicy {
|
|||||||
} else {
|
} else {
|
||||||
// Otherwise, just launch Home
|
// Otherwise, just launch Home
|
||||||
sendCloseSystemWindows(SYSTEM_DIALOG_REASON_HOME_KEY);
|
sendCloseSystemWindows(SYSTEM_DIALOG_REASON_HOME_KEY);
|
||||||
startDockOrHome();
|
startDockOrHome(true /*fromHomeKey*/);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -5821,19 +5825,31 @@ public class PhoneWindowManager implements WindowManagerPolicy {
|
|||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
|
|
||||||
void startDockOrHome() {
|
void startDockOrHome(boolean fromHomeKey) {
|
||||||
awakenDreams();
|
awakenDreams();
|
||||||
|
|
||||||
Intent dock = createHomeDockIntent();
|
Intent dock = createHomeDockIntent();
|
||||||
if (dock != null) {
|
if (dock != null) {
|
||||||
try {
|
try {
|
||||||
|
if (fromHomeKey) {
|
||||||
|
dock.putExtra(WindowManagerPolicy.EXTRA_FROM_HOME_KEY, fromHomeKey);
|
||||||
|
}
|
||||||
mContext.startActivityAsUser(dock, UserHandle.CURRENT);
|
mContext.startActivityAsUser(dock, UserHandle.CURRENT);
|
||||||
return;
|
return;
|
||||||
} catch (ActivityNotFoundException e) {
|
} 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);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -5848,7 +5864,7 @@ public class PhoneWindowManager implements WindowManagerPolicy {
|
|||||||
} catch (RemoteException e) {
|
} catch (RemoteException e) {
|
||||||
}
|
}
|
||||||
sendCloseSystemWindows();
|
sendCloseSystemWindows();
|
||||||
startDockOrHome();
|
startDockOrHome(false /*fromHomeKey*/);
|
||||||
} else {
|
} else {
|
||||||
// This code brings home to the front or, if it is already
|
// This code brings home to the front or, if it is already
|
||||||
// at the front, puts the device to sleep.
|
// at the front, puts the device to sleep.
|
||||||
|
Reference in New Issue
Block a user