Launcher3: Add kill action to app shortcuts popup
Squashed: Launcher3: Dismiss task from recents when killed Change-Id: I25f37484a444346bf08e6960893892cc4bf25ada Launcher3: Add FORCE_STOP_PACKAGES permission Change-Id: I20dd0287c47269ccfdd02a8eae2a3da1de96e206 Launcher3: Update kill app button drawable Change-Id: Iff78ae0528b8ed9c7b11952352e4b6d43507e233 Co-authored-by: Ali B <abittin@gmail.com> Co-authored-by: Pranav Vashi <neobuddy89@gmail.com> Co-authored-by: Alexandru Scurtu <sasha.scurtu@gmail.com> [mickaelmendes50: Improve 'kill' action string] [ghostrider-reborn: Add privapp permissions, adapt to Sv2, 13] Signed-off-by: Adithya R <gh0strider.2k18.reborn@gmail.com> Change-Id: Iff78ae0528b8ed9c7b11952352e4b6d43507e233
This commit is contained in:
parent
4c32facc03
commit
dda255a664
26
Android.bp
26
Android.bp
|
@ -228,7 +228,10 @@ android_app {
|
|||
"Home",
|
||||
"Launcher2",
|
||||
],
|
||||
required: ["privapp_whitelist_com.android.launcher3"],
|
||||
required: [
|
||||
"privapp_whitelist_com.android.launcher3",
|
||||
"privapp_whitelist_aospa_launcher3.xml",
|
||||
],
|
||||
|
||||
jacoco: {
|
||||
include_filter: ["com.android.launcher3.**"],
|
||||
|
@ -357,7 +360,10 @@ android_app {
|
|||
"Launcher3",
|
||||
"Launcher3QuickStep",
|
||||
],
|
||||
required: ["privapp_whitelist_com.android.launcher3"],
|
||||
required: [
|
||||
"privapp_whitelist_com.android.launcher3",
|
||||
"privapp_whitelist_aospa_launcher3.xml",
|
||||
],
|
||||
|
||||
additional_manifests: [
|
||||
"AndroidManifest.xml",
|
||||
|
@ -392,7 +398,10 @@ android_app {
|
|||
"Launcher2",
|
||||
"Launcher3",
|
||||
],
|
||||
required: ["privapp_whitelist_com.android.launcher3"],
|
||||
required: [
|
||||
"privapp_whitelist_com.android.launcher3",
|
||||
"privapp_whitelist_aospa_launcher3.xml",
|
||||
],
|
||||
|
||||
resource_dirs: ["quickstep/res"],
|
||||
|
||||
|
@ -443,7 +452,10 @@ android_app {
|
|||
"Launcher3",
|
||||
"Launcher3QuickStep",
|
||||
],
|
||||
required: ["privapp_whitelist_com.android.launcher3"],
|
||||
required: [
|
||||
"privapp_whitelist_com.android.launcher3",
|
||||
"privapp_whitelist_aospa_launcher3.xml",
|
||||
],
|
||||
|
||||
additional_manifests: [
|
||||
"go/AndroidManifest.xml",
|
||||
|
@ -458,3 +470,9 @@ android_app {
|
|||
|
||||
}
|
||||
|
||||
prebuilt_etc {
|
||||
name: "privapp_whitelist_aospa_launcher3.xml",
|
||||
src: "privapp_whitelist_aospa_launcher3.xml",
|
||||
system_ext_specific: true,
|
||||
sub_dir: "permissions",
|
||||
}
|
||||
|
|
|
@ -46,6 +46,8 @@
|
|||
<uses-permission android:name="android.permission.ROTATE_SURFACE_FLINGER" />
|
||||
<uses-permission android:name="android.permission.POST_NOTIFICATIONS" />
|
||||
<uses-permission android:name="android.permission.READ_HOME_APP_SEARCH_DATA" />
|
||||
|
||||
<uses-permission android:name="android.permission.FORCE_STOP_PACKAGES" />
|
||||
<uses-permission android:name="android.permission.DEVICE_POWER" />
|
||||
|
||||
<!--
|
||||
|
|
|
@ -0,0 +1,13 @@
|
|||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<!--
|
||||
Copyright (C) 2022 Paranoid Android
|
||||
SPDX-License-Identifier: Apache-2.0
|
||||
-->
|
||||
<permissions>
|
||||
|
||||
<!-- Additional permissions on top of privapp-permissions-platform.xml -->
|
||||
<privapp-permissions package="com.android.launcher3">
|
||||
<permission name="android.permission.FORCE_STOP_PACKAGES"/>
|
||||
</privapp-permissions>
|
||||
|
||||
</permissions>
|
|
@ -0,0 +1,29 @@
|
|||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<!-- Copyright (C) 2018 The Android Open Source Project
|
||||
|
||||
Licensed under the Apache License, Version 2.0 (the "License");
|
||||
you may not use this file except in compliance with the License.
|
||||
You may obtain a copy of the License at
|
||||
|
||||
http://www.apache.org/licenses/LICENSE-2.0
|
||||
|
||||
Unless required by applicable law or agreed to in writing, software
|
||||
distributed under the License is distributed on an "AS IS" BASIS,
|
||||
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
See the License for the specific language governing permissions and
|
||||
limitations under the License.
|
||||
-->
|
||||
|
||||
<vector
|
||||
xmlns:android="http://schemas.android.com/apk/res/android"
|
||||
android:name="vector"
|
||||
android:width="24dp"
|
||||
android:height="24dp"
|
||||
android:viewportWidth="24"
|
||||
android:viewportHeight="24">
|
||||
<path
|
||||
android:name="path"
|
||||
android:pathData="M 4.707 3.293 L 3.293 4.707 L 10.586 12 L 3.293 19.293 L 4.707 20.707 L 12 13.414 L 19.293 20.707 L 20.707 19.293 L 13.414 12 L 20.707 4.707 L 19.293 3.293 L 12 10.586 L 4.707 3.293 Z"
|
||||
android:fillColor="#ff000000"
|
||||
android:strokeWidth="1"/>
|
||||
</vector>
|
|
@ -0,0 +1,24 @@
|
|||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<!--
|
||||
/*
|
||||
* Copyright (C) 2017 The Android Open Source Project
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
-->
|
||||
<resources xmlns:xliff="urn:oasis:names:tc:xliff:document:1.2">
|
||||
|
||||
<!-- Kill App recents action shortcut -->
|
||||
<string name="recent_task_option_kill_app">Force close</string>
|
||||
<string name="recents_app_killed">App closed</string>
|
||||
</resources>
|
|
@ -120,6 +120,7 @@ public class TaskOverlayFactory implements ResourceBasedOverride {
|
|||
/** Note that these will be shown in order from top to bottom, if available for the task. */
|
||||
private static final TaskShortcutFactory[] MENU_OPTIONS = new TaskShortcutFactory[]{
|
||||
TaskShortcutFactory.APP_INFO,
|
||||
TaskShortcutFactory.KILL_APP,
|
||||
TaskShortcutFactory.SPLIT_SELECT,
|
||||
TaskShortcutFactory.UNINSTALL,
|
||||
TaskShortcutFactory.PIN,
|
||||
|
|
|
@ -22,7 +22,9 @@ import static com.android.launcher3.config.FeatureFlags.ENABLE_OVERVIEW_SELECTIO
|
|||
import static com.android.launcher3.logging.StatsLogManager.LauncherEvent.LAUNCHER_SYSTEM_SHORTCUT_FREE_FORM_TAP;
|
||||
|
||||
import android.app.Activity;
|
||||
import android.app.ActivityManagerNative;
|
||||
import android.app.ActivityOptions;
|
||||
import android.app.IActivityManager;
|
||||
import android.graphics.Bitmap;
|
||||
import android.graphics.Color;
|
||||
import android.graphics.Rect;
|
||||
|
@ -30,11 +32,13 @@ import android.os.Handler;
|
|||
import android.os.Looper;
|
||||
import android.os.RemoteException;
|
||||
import android.os.SystemProperties;
|
||||
import android.os.UserHandle;
|
||||
import android.util.Log;
|
||||
import android.view.View;
|
||||
import android.view.WindowInsets;
|
||||
import android.view.WindowManagerGlobal;
|
||||
import android.window.SplashScreen;
|
||||
import android.widget.Toast;
|
||||
|
||||
import androidx.annotation.Nullable;
|
||||
|
||||
|
@ -410,4 +414,49 @@ public interface TaskShortcutFactory {
|
|||
return null;
|
||||
}
|
||||
};
|
||||
|
||||
TaskShortcutFactory KILL_APP = new TaskShortcutFactory() {
|
||||
public List<SystemShortcut> getShortcuts(BaseDraggingActivity activity,
|
||||
TaskIdAttributeContainer taskContainer) {
|
||||
String packageName = taskContainer.getTaskView()
|
||||
.getItemInfo().getTargetComponent().getPackageName();
|
||||
return Collections.singletonList(new KillSystemShortcut(activity, taskContainer, packageName));
|
||||
|
||||
}
|
||||
};
|
||||
|
||||
class KillSystemShortcut extends SystemShortcut {
|
||||
private static final String TAG = "KillSystemShortcut";
|
||||
private final TaskView mTaskView;
|
||||
private final BaseDraggingActivity mActivity;
|
||||
private final String mPackageName;
|
||||
|
||||
public KillSystemShortcut(BaseDraggingActivity activity,
|
||||
TaskIdAttributeContainer taskContainer, String packageName) {
|
||||
super(R.drawable.ic_kill_app, R.string.recent_task_option_kill_app,
|
||||
activity, taskContainer.getItemInfo(), taskContainer.getTaskView());
|
||||
mTaskView = taskContainer.getTaskView();
|
||||
mActivity = activity;
|
||||
mPackageName = packageName;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onClick(View view) {
|
||||
if (mPackageName != null) {
|
||||
IActivityManager iam = ActivityManagerNative.getDefault();
|
||||
Task task = mTaskView.getTask();
|
||||
if (task != null) {
|
||||
try {
|
||||
iam.forceStopPackage(mPackageName, UserHandle.USER_CURRENT);
|
||||
Toast appKilled = Toast.makeText(mActivity, R.string.recents_app_killed,
|
||||
Toast.LENGTH_SHORT);
|
||||
appKilled.show();
|
||||
((RecentsView)mActivity.getOverviewPanel())
|
||||
.dismissTask(mTaskView, true /* animate */, true /* removeTask */);
|
||||
} catch (RemoteException e) { }
|
||||
}
|
||||
}
|
||||
dismissTaskMenuView(mActivity);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue