Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit 2c78323a authored by Danesh M's avatar Danesh M
Browse files

Framework : Long press back to kill fixes

- Only show message / vibrate if an app was actually killed.
- Escape out of the outter loop as well upon killing an app

Change-Id: I8c1ea2070e8b4b51caab0f6e2b7d31475d1f4601
parent bff05353
Loading
Loading
Loading
Loading
+8 −3
Original line number Diff line number Diff line
@@ -837,7 +837,7 @@ public class PhoneWindowManager implements WindowManagerPolicy {
    Runnable mBackLongPress = new Runnable() {
        public void run() {
            try {
                performHapticFeedbackLw(null, HapticFeedbackConstants.LONG_PRESS, false);
                boolean targetKilled = false;
                IActivityManager am = ActivityManagerNative.getDefault();
                List<RunningAppProcessInfo> apps = am.getRunningAppProcesses();
                for (RunningAppProcessInfo appInfo : apps) {
@@ -846,18 +846,23 @@ public class PhoneWindowManager implements WindowManagerPolicy {
                    // root, phone, etc.)
                    if (uid >= Process.FIRST_APPLICATION_UID && uid <= Process.LAST_APPLICATION_UID
                            && appInfo.importance == RunningAppProcessInfo.IMPORTANCE_FOREGROUND) {
                        Toast.makeText(mContext, R.string.app_killed_message, Toast.LENGTH_SHORT).show();
                        if (appInfo.pkgList != null && (appInfo.pkgList.length > 0)) {
                            for (String pkg : appInfo.pkgList) {
                                if (!pkg.equals("com.android.systemui")) {
                                    am.forceStopPackage(pkg);
                                    targetKilled = true;
                                    break;
                                }
                            }
                        } else {
                            Process.killProcess(appInfo.pid);
                            break;
                            targetKilled = true;
                        }
                    }
                    if (targetKilled) {
                        performHapticFeedbackLw(null, HapticFeedbackConstants.LONG_PRESS, false);
                        Toast.makeText(mContext, R.string.app_killed_message, Toast.LENGTH_SHORT).show();
                        break;
                    }
                }
            } catch (RemoteException remoteException) {