am 36b3b1dd: Merge "Support double-tap home to go to recents." into jb-mr2-dev
* commit '36b3b1dd0b963e6d0a3d8f7d16e3bdfe5efcbe4d': Support double-tap home to go to recents.
This commit is contained in:
@@ -542,11 +542,20 @@
|
||||
<!-- Control the behavior when the user long presses the home button.
|
||||
0 - Nothing
|
||||
1 - Recent apps view in SystemUI
|
||||
2 - Launch assist intent
|
||||
This needs to match the constants in
|
||||
policy/src/com/android/internal/policy/impl/PhoneWindowManager.java
|
||||
-->
|
||||
<integer name="config_longPressOnHomeBehavior">1</integer>
|
||||
|
||||
<!-- Control the behavior when the user double-taps the home button.
|
||||
0 - Nothing
|
||||
1 - Recent apps view in SystemUI
|
||||
This needs to match the constants in
|
||||
policy/src/com/android/internal/policy/impl/PhoneWindowManager.java
|
||||
-->
|
||||
<integer name="config_doubleTapOnHomeBehavior">0</integer>
|
||||
|
||||
<!-- Array of light sensor LUX values to define our levels for auto backlight brightness support.
|
||||
The N entries of this array define N + 1 control points as follows:
|
||||
(1-based arrays)
|
||||
|
||||
@@ -1372,6 +1372,7 @@
|
||||
<java-symbol type="integer" name="config_carDockRotation" />
|
||||
<java-symbol type="integer" name="config_defaultUiModeType" />
|
||||
<java-symbol type="integer" name="config_deskDockRotation" />
|
||||
<java-symbol type="integer" name="config_doubleTapOnHomeBehavior" />
|
||||
<java-symbol type="integer" name="config_lidKeyboardAccessibility" />
|
||||
<java-symbol type="integer" name="config_lidNavigationAccessibility" />
|
||||
<java-symbol type="integer" name="config_lidOpenRotation" />
|
||||
|
||||
@@ -141,6 +141,10 @@ public class PhoneWindowManager implements WindowManagerPolicy {
|
||||
// core/res/res/values/config.xml
|
||||
static final int LONG_PRESS_HOME_NOTHING = 0;
|
||||
static final int LONG_PRESS_HOME_RECENT_SYSTEM_UI = 1;
|
||||
static final int LONG_PRESS_HOME_ASSIST = 2;
|
||||
|
||||
static final int DOUBLE_TAP_HOME_NOTHING = 0;
|
||||
static final int DOUBLE_TAP_HOME_RECENT_SYSTEM_UI = 1;
|
||||
|
||||
static final int APPLICATION_MEDIA_SUBLAYER = -2;
|
||||
static final int APPLICATION_MEDIA_OVERLAY_SUBLAYER = -1;
|
||||
@@ -195,6 +199,7 @@ public class PhoneWindowManager implements WindowManagerPolicy {
|
||||
WindowManagerFuncs mWindowManagerFuncs;
|
||||
PowerManager mPowerManager;
|
||||
IStatusBarService mStatusBarService;
|
||||
boolean mPreloadedRecentApps;
|
||||
final Object mServiceAquireLock = new Object();
|
||||
Vibrator mVibrator; // Vibrator for giving feedback of orientation changes
|
||||
SearchManager mSearchManager;
|
||||
@@ -399,7 +404,8 @@ public class PhoneWindowManager implements WindowManagerPolicy {
|
||||
boolean mShowingDream;
|
||||
boolean mDreamingLockscreen;
|
||||
boolean mHomePressed;
|
||||
boolean mHomeLongPressed;
|
||||
boolean mHomeConsumed;
|
||||
boolean mHomeDoubleTapPending;
|
||||
Intent mHomeIntent;
|
||||
Intent mCarDockIntent;
|
||||
Intent mDeskDockIntent;
|
||||
@@ -432,7 +438,10 @@ public class PhoneWindowManager implements WindowManagerPolicy {
|
||||
int mOverscanBottom = 0;
|
||||
|
||||
// What we do when the user long presses on home
|
||||
private int mLongPressOnHomeBehavior = -1;
|
||||
private int mLongPressOnHomeBehavior;
|
||||
|
||||
// What we do when the user double-taps on home
|
||||
private int mDoubleTapOnHomeBehavior;
|
||||
|
||||
// Screenshot trigger states
|
||||
// Time to volume and power must be pressed within this interval of each other.
|
||||
@@ -743,36 +752,35 @@ public class PhoneWindowManager implements WindowManagerPolicy {
|
||||
}
|
||||
|
||||
private void handleLongPressOnHome() {
|
||||
// We can't initialize this in init() since the configuration hasn't been loaded yet.
|
||||
if (mLongPressOnHomeBehavior < 0) {
|
||||
mLongPressOnHomeBehavior
|
||||
= mContext.getResources().getInteger(R.integer.config_longPressOnHomeBehavior);
|
||||
if (mLongPressOnHomeBehavior < LONG_PRESS_HOME_NOTHING ||
|
||||
mLongPressOnHomeBehavior > LONG_PRESS_HOME_RECENT_SYSTEM_UI) {
|
||||
mLongPressOnHomeBehavior = LONG_PRESS_HOME_NOTHING;
|
||||
}
|
||||
}
|
||||
|
||||
if (mLongPressOnHomeBehavior != LONG_PRESS_HOME_NOTHING) {
|
||||
mHomeConsumed = true;
|
||||
performHapticFeedbackLw(null, HapticFeedbackConstants.LONG_PRESS, false);
|
||||
sendCloseSystemWindows(SYSTEM_DIALOG_REASON_RECENT_APPS);
|
||||
|
||||
// Eat the longpress so it won't dismiss the recent apps dialog when
|
||||
// the user lets go of the home key
|
||||
mHomeLongPressed = true;
|
||||
try {
|
||||
IStatusBarService statusbar = getStatusBarService();
|
||||
if (statusbar != null) {
|
||||
statusbar.toggleRecentApps();
|
||||
}
|
||||
} catch (RemoteException e) {
|
||||
Slog.e(TAG, "RemoteException when showing recent apps", e);
|
||||
// re-acquire status bar service next time it is needed.
|
||||
mStatusBarService = null;
|
||||
if (mLongPressOnHomeBehavior == LONG_PRESS_HOME_RECENT_SYSTEM_UI) {
|
||||
toggleRecentApps();
|
||||
} else if (mLongPressOnHomeBehavior == LONG_PRESS_HOME_ASSIST) {
|
||||
launchAssistAction();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private void handleDoubleTapOnHome() {
|
||||
if (mDoubleTapOnHomeBehavior == DOUBLE_TAP_HOME_RECENT_SYSTEM_UI) {
|
||||
mHomeConsumed = true;
|
||||
toggleRecentApps();
|
||||
}
|
||||
}
|
||||
|
||||
private final Runnable mHomeDoubleTapTimeoutRunnable = new Runnable() {
|
||||
@Override
|
||||
public void run() {
|
||||
if (mHomeDoubleTapPending) {
|
||||
mHomeDoubleTapPending = false;
|
||||
launchHomeFromHotKey();
|
||||
}
|
||||
}
|
||||
};
|
||||
|
||||
/**
|
||||
* Create (if necessary) and show or dismiss the recent apps dialog according
|
||||
* according to the requested behavior.
|
||||
@@ -877,6 +885,21 @@ public class PhoneWindowManager implements WindowManagerPolicy {
|
||||
com.android.internal.R.integer.config_lidNavigationAccessibility);
|
||||
mLidControlsSleep = mContext.getResources().getBoolean(
|
||||
com.android.internal.R.bool.config_lidControlsSleep);
|
||||
|
||||
mLongPressOnHomeBehavior = mContext.getResources().getInteger(
|
||||
com.android.internal.R.integer.config_longPressOnHomeBehavior);
|
||||
if (mLongPressOnHomeBehavior < LONG_PRESS_HOME_NOTHING ||
|
||||
mLongPressOnHomeBehavior > LONG_PRESS_HOME_ASSIST) {
|
||||
mLongPressOnHomeBehavior = LONG_PRESS_HOME_NOTHING;
|
||||
}
|
||||
|
||||
mDoubleTapOnHomeBehavior = mContext.getResources().getInteger(
|
||||
com.android.internal.R.integer.config_doubleTapOnHomeBehavior);
|
||||
if (mDoubleTapOnHomeBehavior < DOUBLE_TAP_HOME_NOTHING ||
|
||||
mDoubleTapOnHomeBehavior > DOUBLE_TAP_HOME_RECENT_SYSTEM_UI) {
|
||||
mDoubleTapOnHomeBehavior = LONG_PRESS_HOME_NOTHING;
|
||||
}
|
||||
|
||||
// register for dock events
|
||||
IntentFilter filter = new IntentFilter();
|
||||
filter.addAction(UiModeManager.ACTION_ENTER_CAR_MODE);
|
||||
@@ -1902,48 +1925,44 @@ public class PhoneWindowManager implements WindowManagerPolicy {
|
||||
// If we have released the home key, and didn't do anything else
|
||||
// while it was pressed, then it is time to go home!
|
||||
if (!down) {
|
||||
final boolean homeWasLongPressed = mHomeLongPressed;
|
||||
cancelPreloadRecentApps();
|
||||
|
||||
mHomePressed = false;
|
||||
mHomeLongPressed = false;
|
||||
if (!homeWasLongPressed) {
|
||||
if (mLongPressOnHomeBehavior != LONG_PRESS_HOME_NOTHING) {
|
||||
try {
|
||||
IStatusBarService statusbar = getStatusBarService();
|
||||
if (statusbar != null) {
|
||||
statusbar.cancelPreloadRecentApps();
|
||||
}
|
||||
} catch (RemoteException e) {
|
||||
Slog.e(TAG, "RemoteException when showing recent apps", e);
|
||||
// re-acquire status bar service next time it is needed.
|
||||
mStatusBarService = null;
|
||||
}
|
||||
}
|
||||
|
||||
mHomePressed = false;
|
||||
if (!canceled) {
|
||||
// If an incoming call is ringing, HOME is totally disabled.
|
||||
// (The user is already on the InCallScreen at this point,
|
||||
// and his ONLY options are to answer or reject the call.)
|
||||
boolean incomingRinging = false;
|
||||
try {
|
||||
ITelephony telephonyService = getTelephonyService();
|
||||
if (telephonyService != null) {
|
||||
incomingRinging = telephonyService.isRinging();
|
||||
}
|
||||
} catch (RemoteException ex) {
|
||||
Log.w(TAG, "RemoteException from getPhoneInterface()", ex);
|
||||
}
|
||||
|
||||
if (incomingRinging) {
|
||||
Log.i(TAG, "Ignoring HOME; there's a ringing incoming call.");
|
||||
} else {
|
||||
launchHomeFromHotKey();
|
||||
}
|
||||
} else {
|
||||
Log.i(TAG, "Ignoring HOME; event canceled.");
|
||||
}
|
||||
if (mHomeConsumed) {
|
||||
mHomeConsumed = false;
|
||||
return -1;
|
||||
}
|
||||
|
||||
if (canceled) {
|
||||
Log.i(TAG, "Ignoring HOME; event canceled.");
|
||||
return -1;
|
||||
}
|
||||
|
||||
// If an incoming call is ringing, HOME is totally disabled.
|
||||
// (The user is already on the InCallScreen at this point,
|
||||
// and his ONLY options are to answer or reject the call.)
|
||||
try {
|
||||
ITelephony telephonyService = getTelephonyService();
|
||||
if (telephonyService != null && telephonyService.isRinging()) {
|
||||
Log.i(TAG, "Ignoring HOME; there's a ringing incoming call.");
|
||||
return -1;
|
||||
}
|
||||
} catch (RemoteException ex) {
|
||||
Log.w(TAG, "RemoteException from getPhoneInterface()", ex);
|
||||
}
|
||||
|
||||
// Delay handling home if a double-tap is possible.
|
||||
if (mDoubleTapOnHomeBehavior != DOUBLE_TAP_HOME_NOTHING) {
|
||||
mHandler.removeCallbacks(mHomeDoubleTapTimeoutRunnable); // just in case
|
||||
mHomeDoubleTapPending = true;
|
||||
mHandler.postDelayed(mHomeDoubleTapTimeoutRunnable,
|
||||
ViewConfiguration.getDoubleTapTimeout());
|
||||
return -1;
|
||||
}
|
||||
|
||||
// Go home!
|
||||
launchHomeFromHotKey();
|
||||
return -1;
|
||||
}
|
||||
|
||||
// If a system window has focus, then it doesn't make sense
|
||||
@@ -1964,25 +1983,21 @@ public class PhoneWindowManager implements WindowManagerPolicy {
|
||||
}
|
||||
}
|
||||
}
|
||||
if (down) {
|
||||
if (!mHomePressed && mLongPressOnHomeBehavior == LONG_PRESS_HOME_RECENT_SYSTEM_UI) {
|
||||
try {
|
||||
IStatusBarService statusbar = getStatusBarService();
|
||||
if (statusbar != null) {
|
||||
statusbar.preloadRecentApps();
|
||||
}
|
||||
} catch (RemoteException e) {
|
||||
Slog.e(TAG, "RemoteException when preloading recent apps", e);
|
||||
// re-acquire status bar service next time it is needed.
|
||||
mStatusBarService = null;
|
||||
}
|
||||
|
||||
// Remember that home is pressed and handle special actions.
|
||||
if (repeatCount == 0) {
|
||||
mHomePressed = true;
|
||||
if (mHomeDoubleTapPending) {
|
||||
mHomeDoubleTapPending = false;
|
||||
mHandler.removeCallbacks(mHomeDoubleTapTimeoutRunnable);
|
||||
handleDoubleTapOnHome();
|
||||
} else if (mLongPressOnHomeBehavior == LONG_PRESS_HOME_RECENT_SYSTEM_UI
|
||||
|| mDoubleTapOnHomeBehavior == DOUBLE_TAP_HOME_RECENT_SYSTEM_UI) {
|
||||
preloadRecentApps();
|
||||
}
|
||||
if (repeatCount == 0) {
|
||||
mHomePressed = true;
|
||||
} else if ((event.getFlags() & KeyEvent.FLAG_LONG_PRESS) != 0) {
|
||||
if (!keyguardOn) {
|
||||
handleLongPressOnHome();
|
||||
}
|
||||
} else if ((event.getFlags() & KeyEvent.FLAG_LONG_PRESS) != 0) {
|
||||
if (!keyguardOn) {
|
||||
handleLongPressOnHome();
|
||||
}
|
||||
}
|
||||
return -1;
|
||||
@@ -2029,19 +2044,10 @@ public class PhoneWindowManager implements WindowManagerPolicy {
|
||||
return 0;
|
||||
} else if (keyCode == KeyEvent.KEYCODE_APP_SWITCH) {
|
||||
if (!keyguardOn) {
|
||||
try {
|
||||
IStatusBarService statusbar = getStatusBarService();
|
||||
if (statusbar != null) {
|
||||
if (down && repeatCount == 0) {
|
||||
statusbar.preloadRecentApps();
|
||||
} else if (!down) {
|
||||
statusbar.toggleRecentApps();
|
||||
}
|
||||
}
|
||||
} catch (RemoteException e) {
|
||||
Slog.e(TAG, "RemoteException when preloading recent apps", e);
|
||||
// re-acquire status bar service next time it is needed.
|
||||
mStatusBarService = null;
|
||||
if (down && repeatCount == 0) {
|
||||
preloadRecentApps();
|
||||
} else if (!down) {
|
||||
toggleRecentApps();
|
||||
}
|
||||
}
|
||||
return -1;
|
||||
@@ -2307,6 +2313,51 @@ public class PhoneWindowManager implements WindowManagerPolicy {
|
||||
return mSearchManager;
|
||||
}
|
||||
|
||||
private void preloadRecentApps() {
|
||||
mPreloadedRecentApps = true;
|
||||
try {
|
||||
IStatusBarService statusbar = getStatusBarService();
|
||||
if (statusbar != null) {
|
||||
statusbar.preloadRecentApps();
|
||||
}
|
||||
} catch (RemoteException e) {
|
||||
Slog.e(TAG, "RemoteException when preloading recent apps", e);
|
||||
// re-acquire status bar service next time it is needed.
|
||||
mStatusBarService = null;
|
||||
}
|
||||
}
|
||||
|
||||
private void cancelPreloadRecentApps() {
|
||||
if (mPreloadedRecentApps) {
|
||||
mPreloadedRecentApps = false;
|
||||
try {
|
||||
IStatusBarService statusbar = getStatusBarService();
|
||||
if (statusbar != null) {
|
||||
statusbar.cancelPreloadRecentApps();
|
||||
}
|
||||
} catch (RemoteException e) {
|
||||
Slog.e(TAG, "RemoteException when showing recent apps", e);
|
||||
// re-acquire status bar service next time it is needed.
|
||||
mStatusBarService = null;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private void toggleRecentApps() {
|
||||
mPreloadedRecentApps = false; // preloading no longer needs to be canceled
|
||||
sendCloseSystemWindows(SYSTEM_DIALOG_REASON_RECENT_APPS);
|
||||
try {
|
||||
IStatusBarService statusbar = getStatusBarService();
|
||||
if (statusbar != null) {
|
||||
statusbar.toggleRecentApps();
|
||||
}
|
||||
} catch (RemoteException e) {
|
||||
Slog.e(TAG, "RemoteException when showing recent apps", e);
|
||||
// re-acquire status bar service next time it is needed.
|
||||
mStatusBarService = null;
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* A home key -> launch home action was detected. Take the appropriate action
|
||||
* given the situation with the keyguard.
|
||||
|
||||
Reference in New Issue
Block a user