Loading core/java/android/provider/Settings.java +6 −0 Original line number Diff line number Diff line Loading @@ -4069,6 +4069,12 @@ public final class Settings { */ public static final String ANR_SHOW_BACKGROUND = "anr_show_background"; /** * Whether to allow killing of the foreground app by long-pressing the Back button * @hide */ public static final String KILL_APP_LONGPRESS_BACK = "kill_app_longpress_back"; /** * The {@link ComponentName} string of the service to be used as the voice recognition * service. Loading policy/src/com/android/internal/policy/impl/PhoneWindowManager.java +36 −0 Original line number Diff line number Diff line Loading @@ -18,6 +18,7 @@ package com.android.internal.policy.impl; import android.app.Activity; import android.app.ActivityManagerNative; import android.app.ActivityManager.RunningAppProcessInfo; import android.app.IActivityManager; import android.app.IUiModeManager; import android.app.ProgressDialog; Loading Loading @@ -48,6 +49,7 @@ import android.os.LocalPowerManager; import android.os.Message; import android.os.Messenger; import android.os.PowerManager; import android.os.Process; import android.os.RemoteException; import android.os.ServiceManager; import android.os.SystemClock; Loading Loading @@ -142,6 +144,7 @@ import java.io.FileReader; import java.io.IOException; import java.io.PrintWriter; import java.util.ArrayList; import java.util.List; /** * WindowManagerPolicy implementation for the Android phone UI. This Loading Loading @@ -660,6 +663,28 @@ public class PhoneWindowManager implements WindowManagerPolicy { } }; Runnable mBackLongPress = new Runnable() { public void run() { try { IActivityManager mgr = ActivityManagerNative.getDefault(); List<RunningAppProcessInfo> apps = mgr.getRunningAppProcesses(); for (RunningAppProcessInfo appInfo : apps) { int uid = appInfo.uid; // Make sure it's a foreground user application (not system, // root, phone, etc.) if (uid >= Process.FIRST_APPLICATION_UID && uid <= Process.LAST_APPLICATION_UID && appInfo.importance == RunningAppProcessInfo.IMPORTANCE_FOREGROUND) { // Kill the entire pid Process.killProcess(appInfo.pid); break; } } } catch (RemoteException remoteException) { // Do nothing; just let it go. } } }; void showGlobalActionsDialog() { if (mGlobalActions == null) { mGlobalActions = new GlobalActions(mContext); Loading Loading @@ -1520,6 +1545,10 @@ public class PhoneWindowManager implements WindowManagerPolicy { } } if (keyCode == KeyEvent.KEYCODE_BACK && !down) { mHandler.removeCallbacks(mBackLongPress); } // First we always handle the home key here, so applications // can never break it, although if keyguard is on, we do let // it handle it, because that gives us the correct 5 second Loading Loading @@ -1628,6 +1657,13 @@ public class PhoneWindowManager implements WindowManagerPolicy { showOrHideRecentAppsDialog(RECENT_APPS_BEHAVIOR_SHOW_OR_DISMISS); } return -1; } else if (keyCode == KeyEvent.KEYCODE_BACK) { if (Settings.Secure.getInt(mContext.getContentResolver(), Settings.Secure.KILL_APP_LONGPRESS_BACK, 0) == 1) { if (down && repeatCount == 0) { mHandler.postDelayed(mBackLongPress, 2000); } } } // Shortcuts are invoked through Search+key, so intercept those here Loading Loading
core/java/android/provider/Settings.java +6 −0 Original line number Diff line number Diff line Loading @@ -4069,6 +4069,12 @@ public final class Settings { */ public static final String ANR_SHOW_BACKGROUND = "anr_show_background"; /** * Whether to allow killing of the foreground app by long-pressing the Back button * @hide */ public static final String KILL_APP_LONGPRESS_BACK = "kill_app_longpress_back"; /** * The {@link ComponentName} string of the service to be used as the voice recognition * service. Loading
policy/src/com/android/internal/policy/impl/PhoneWindowManager.java +36 −0 Original line number Diff line number Diff line Loading @@ -18,6 +18,7 @@ package com.android.internal.policy.impl; import android.app.Activity; import android.app.ActivityManagerNative; import android.app.ActivityManager.RunningAppProcessInfo; import android.app.IActivityManager; import android.app.IUiModeManager; import android.app.ProgressDialog; Loading Loading @@ -48,6 +49,7 @@ import android.os.LocalPowerManager; import android.os.Message; import android.os.Messenger; import android.os.PowerManager; import android.os.Process; import android.os.RemoteException; import android.os.ServiceManager; import android.os.SystemClock; Loading Loading @@ -142,6 +144,7 @@ import java.io.FileReader; import java.io.IOException; import java.io.PrintWriter; import java.util.ArrayList; import java.util.List; /** * WindowManagerPolicy implementation for the Android phone UI. This Loading Loading @@ -660,6 +663,28 @@ public class PhoneWindowManager implements WindowManagerPolicy { } }; Runnable mBackLongPress = new Runnable() { public void run() { try { IActivityManager mgr = ActivityManagerNative.getDefault(); List<RunningAppProcessInfo> apps = mgr.getRunningAppProcesses(); for (RunningAppProcessInfo appInfo : apps) { int uid = appInfo.uid; // Make sure it's a foreground user application (not system, // root, phone, etc.) if (uid >= Process.FIRST_APPLICATION_UID && uid <= Process.LAST_APPLICATION_UID && appInfo.importance == RunningAppProcessInfo.IMPORTANCE_FOREGROUND) { // Kill the entire pid Process.killProcess(appInfo.pid); break; } } } catch (RemoteException remoteException) { // Do nothing; just let it go. } } }; void showGlobalActionsDialog() { if (mGlobalActions == null) { mGlobalActions = new GlobalActions(mContext); Loading Loading @@ -1520,6 +1545,10 @@ public class PhoneWindowManager implements WindowManagerPolicy { } } if (keyCode == KeyEvent.KEYCODE_BACK && !down) { mHandler.removeCallbacks(mBackLongPress); } // First we always handle the home key here, so applications // can never break it, although if keyguard is on, we do let // it handle it, because that gives us the correct 5 second Loading Loading @@ -1628,6 +1657,13 @@ public class PhoneWindowManager implements WindowManagerPolicy { showOrHideRecentAppsDialog(RECENT_APPS_BEHAVIOR_SHOW_OR_DISMISS); } return -1; } else if (keyCode == KeyEvent.KEYCODE_BACK) { if (Settings.Secure.getInt(mContext.getContentResolver(), Settings.Secure.KILL_APP_LONGPRESS_BACK, 0) == 1) { if (down && repeatCount == 0) { mHandler.postDelayed(mBackLongPress, 2000); } } } // Shortcuts are invoked through Search+key, so intercept those here Loading