diff --git a/host/migration/src/LineageSettings.java b/host/migration/src/LineageSettings.java index 3ba86a4d..381d9c03 100644 --- a/host/migration/src/LineageSettings.java +++ b/host/migration/src/LineageSettings.java @@ -949,8 +949,10 @@ public final class LineageSettings { /** * Whether to allow killing of the foreground app by long-pressing the Back button + * @deprecated * @hide */ + @Deprecated public static final String KILL_APP_LONGPRESS_BACK = "kill_app_longpress_back"; /** Protected Components diff --git a/sdk/src/java/lineageos/providers/LineageSettings.java b/sdk/src/java/lineageos/providers/LineageSettings.java index 4cb5373a..064dd3f8 100644 --- a/sdk/src/java/lineageos/providers/LineageSettings.java +++ b/sdk/src/java/lineageos/providers/LineageSettings.java @@ -2952,8 +2952,10 @@ public final class LineageSettings { /** * Whether to allow killing of the foreground app by long-pressing the Back button + * @deprecated * @hide */ + @Deprecated public static final String KILL_APP_LONGPRESS_BACK = "kill_app_longpress_back"; /** diff --git a/sdk/src/java/org/lineageos/internal/util/ActionUtils.java b/sdk/src/java/org/lineageos/internal/util/ActionUtils.java index 8abd181a..299c4a29 100644 --- a/sdk/src/java/org/lineageos/internal/util/ActionUtils.java +++ b/sdk/src/java/org/lineageos/internal/util/ActionUtils.java @@ -1,5 +1,5 @@ /* - * Copyright (C) 2018-2019 The LineageOS Project + * Copyright (C) 2018-2020 The LineageOS Project * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -17,7 +17,6 @@ package org.lineageos.internal.util; import android.app.ActivityManager; -import android.app.ActivityManager.StackInfo; import android.app.ActivityManagerNative; import android.app.ActivityOptions; import android.app.IActivityManager; @@ -26,7 +25,6 @@ import android.content.Intent; import android.content.pm.PackageManager; import android.content.pm.ResolveInfo; import android.os.RemoteException; -import android.os.UserHandle; import android.util.Log; import java.util.List; @@ -36,37 +34,6 @@ public class ActionUtils { private static final String TAG = ActionUtils.class.getSimpleName(); private static final String SYSTEMUI_PACKAGE = "com.android.systemui"; - /** - * Kills the top most / most recent user application, but leaves out the launcher. - * This is function governed by {@link Settings.Secure.KILL_APP_LONGPRESS_BACK}. - * - * @param context the current context, used to retrieve the package manager. - * @param userId the ID of the currently active user - * @return {@code true} when a user application was found and closed. - */ - public static boolean killForegroundApp(Context context, int userId) { - try { - return killForegroundAppInternal(context, userId); - } catch (RemoteException e) { - Log.e(TAG, "Could not kill foreground app"); - } - return false; - } - - private static boolean killForegroundAppInternal(Context context, int userId) - throws RemoteException { - final String packageName = getForegroundTaskPackageName(context, userId); - - if (packageName == null) { - return false; - } - - final IActivityManager am = ActivityManagerNative.getDefault(); - am.forceStopPackage(packageName, UserHandle.USER_CURRENT); - - return true; - } - /** * Attempt to bring up the last activity in the stack before the current active one. * @@ -125,25 +92,6 @@ public class ActionUtils { return null; } - private static String getForegroundTaskPackageName(Context context, int userId) - throws RemoteException { - final String defaultHomePackage = resolveCurrentLauncherPackage(context, userId); - final IActivityManager am = ActivityManager.getService(); - final StackInfo focusedStack = am.getFocusedStackInfo(); - - if (focusedStack == null || focusedStack.topActivity == null) { - return null; - } - - final String packageName = focusedStack.topActivity.getPackageName(); - if (!packageName.equals(defaultHomePackage) - && !packageName.equals(SYSTEMUI_PACKAGE)) { - return packageName; - } - - return null; - } - private static String resolveCurrentLauncherPackage(Context context, int userId) { final Intent launcherIntent = new Intent(Intent.ACTION_MAIN) .addCategory(Intent.CATEGORY_HOME);