summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorezio84 <brabus84@gmail.com>2017-05-04 22:11:13 +0200
committerEzio Lacandia Bijelkic <brabus84@gmail.com>2017-05-04 16:27:00 -0400
commita27751b5b9411c56b8e714a6aa0d2ba1b05b14a0 (patch)
tree1f022e24ac99a4fcdf1074f1c1213c248956e6d6
parent285fc2ca3be0101e9cbeeceb8242a209dfac2c5a (diff)
Killapp action: restore home screen before killing the app
to avoid some annoying glitches like the following one: - open app1 - go to home or recents panel then open app2 - use lastapp action or recents panel to open again app1 - use killapp action to kill app1 - app2 comes to foreground, then if you press the back button it will hang for some seconds before going back to home screen. Change-Id: Ia2e8ed3fad80efb50676455b17b3624119fd96c9
-rw-r--r--src/com/android/internal/utils/du/ActionHandler.java10
1 files changed, 10 insertions, 0 deletions
diff --git a/src/com/android/internal/utils/du/ActionHandler.java b/src/com/android/internal/utils/du/ActionHandler.java
index 6455f55..4a3c01e 100644
--- a/src/com/android/internal/utils/du/ActionHandler.java
+++ b/src/com/android/internal/utils/du/ActionHandler.java
@@ -930,8 +930,18 @@ public class ActionHandler {
if (pkg != null && !pkg.equals("com.android.systemui")
&& !pkg.equals(defaultHomePackage)) {
+
+ // Restore home screen stack before killing the app
+ Intent home = new Intent(Intent.ACTION_MAIN, null);
+ home.addCategory(Intent.CATEGORY_HOME);
+ home.addFlags(Intent.FLAG_ACTIVITY_NEW_TASK
+ | Intent.FLAG_ACTIVITY_RESET_TASK_IF_NEEDED);
+ context.startActivity(home);
+
+ // Kill the app
iam.forceStopPackage(pkg, UserHandle.USER_CURRENT);
+ // Remove killed app from Recents
final ActivityManager am = (ActivityManager)
context.getSystemService(Context.ACTIVITY_SERVICE);
final List<ActivityManager.RecentTaskInfo> recentTasks =