diff --git a/packages/SystemUI/AndroidManifest.xml b/packages/SystemUI/AndroidManifest.xml
index 17f92ee..dd0b3e9 100644
--- a/packages/SystemUI/AndroidManifest.xml
+++ b/packages/SystemUI/AndroidManifest.xml
@@ -271,6 +271,8 @@
<!-- Permission to make accessibility service access Bubbles -->
<uses-permission android:name="android.permission.ADD_TRUSTED_DISPLAY" />
+ <uses-permission android:name="android.permission.FORCE_STOP_PACKAGES"/>
+
<protected-broadcast android:name="com.android.settingslib.action.REGISTER_SLICE_RECEIVER" />
<protected-broadcast android:name="com.android.settingslib.action.UNREGISTER_SLICE_RECEIVER" />
diff --git a/packages/SystemUI/res/drawable/ic_qs_application_action.xml b/packages/SystemUI/res/drawable/ic_qs_application_action.xml
new file mode 100644
index 0000000..b62ef56
--- /dev/null
+++ b/packages/SystemUI/res/drawable/ic_qs_application_action.xml
@@ -0,0 +1,8 @@
+<vector android:alpha="0.75" android:height="48dp"
+ android:viewportHeight="256" android:viewportWidth="256"
+ android:width="48dp" xmlns:android="http://schemas.android.com/apk/res/android">
+ <path android:fillColor="#000000"
+ android:pathData="M6.1,2.4c-5.3,2.9 -5,-2.7 -5.1,125.4 0,129.7 -0.3,123.4 5.5,126 2,0.9 31.5,1.2 121.6,1.2 129.3,-0 123.1,0.3 125.7,-5.5 1.7,-3.8 1.7,-239.2 0,-243 -2.6,-5.8 3.7,-5.5 -126,-5.5 -97.1,0.1 -119.7,0.3 -121.7,1.4zM105.9,71.1c1.7,0.6 3.6,1.9 4.1,2.9 0.6,1.2 1,19.5 1,47.1 0,51.6 0.5,48.9 -8.2,48.9 -3.5,-0 -5.4,-0.6 -6.8,-2 -1.9,-1.9 -2,-3.3 -2,-21.5l0,-19.5 -24,-0 -24,-0 0,19.5c0,18.2 -0.1,19.6 -2,21.5 -2.8,2.8 -10.2,2.8 -13,-0 -1.9,-1.9 -2,-3.3 -2,-47.7 0,-52.1 -0.5,-49.3 8.2,-49.3 3.5,-0 5.4,0.6 6.8,2 1.9,1.9 2,3.3 2,20l0,18 24,-0 24,-0 0,-17.8c0,-19.1 0.6,-21.6 5.3,-22.5 1.2,-0.2 2.5,-0.5 2.8,-0.6 0.3,-0 2,0.4 3.8,1zM191.3,72.1c16.3,5.4 27.4,18.3 30.7,35.7 1.6,8.2 0.8,25 -1.6,32.2 -2.4,7.2 -9,16.7 -14.1,20.5 -2.3,1.6 -4,3.4 -3.9,4 0.1,0.5 1.8,1.9 3.7,3 2.6,1.5 5,2 10.2,1.9 6.6,-0.1 6.7,-0.1 6.7,2.4 0,4 -3.6,10.6 -6.9,12.5 -3.6,2.1 -11.9,2.2 -16.7,0.2 -1.9,-0.8 -6.3,-4.2 -9.8,-7.5l-6.3,-6 -7.9,-0c-14.4,-0 -25.7,-4.5 -34.5,-13.7 -9.4,-9.8 -13.2,-19.8 -13.3,-35.3 -0.1,-16.7 3.5,-27.6 12.6,-37.5 9.3,-10.2 19.4,-14.4 35.1,-14.4 7.3,-0.1 11.3,0.4 16,2z" android:strokeColor="#00000000"/>
+ <path android:fillColor="#000000"
+ android:pathData="M164.3,87.6c-6.4,2.3 -12.6,8.4 -15.9,15.6 -2.6,5.7 -2.9,7.3 -2.9,17.3 0,10.5 0.2,11.4 3.3,17.7 3.7,7.5 7.3,11 15.1,14.6 4.6,2.1 6.4,2.4 13,2 18.4,-1.1 28.7,-13.6 28.5,-34.8 -0.1,-15.3 -4.9,-24.7 -15.5,-30.5 -4.4,-2.4 -6.8,-2.9 -13.4,-3.2 -5.4,-0.2 -9.4,0.2 -12.2,1.3z" android:strokeColor="#00000000"/>
+</vector>
diff --git a/packages/SystemUI/res/values/strings.xml b/packages/SystemUI/res/values/strings.xml
index 174f5c7..9afe964 100644
--- a/packages/SystemUI/res/values/strings.xml
+++ b/packages/SystemUI/res/values/strings.xml
@@ -2879,4 +2879,9 @@
<!-- Text to display in a notification when ACTION_BATTERY_CHANGED.EXTRA_PRESENT field is false
[CHAR LIMIT=NONE] -->
<string name="battery_state_unknown_notification_text">Tap for more information</string>
+
+ <string name="qs_application_running">Amara running</string>
+ <string name="qs_application_stopped">Amara stopped</string>
+ <string name="qs_application_stop_action">Stop Amara</string>
+ <string name="qs_application_start_action">Start Amara</string>
</resources>
diff --git a/packages/SystemUI/src/com/android/systemui/qs/tileimpl/QSFactoryImpl.java b/packages/SystemUI/src/com/android/systemui/qs/tileimpl/QSFactoryImpl.java
index c182a58..1a50a6e 100644
--- a/packages/SystemUI/src/com/android/systemui/qs/tileimpl/QSFactoryImpl.java
+++ b/packages/SystemUI/src/com/android/systemui/qs/tileimpl/QSFactoryImpl.java
@@ -45,6 +45,7 @@
import com.android.systemui.qs.tiles.UserTile;
import com.android.systemui.qs.tiles.WifiTile;
import com.android.systemui.qs.tiles.WorkModeTile;
+import com.android.systemui.qs.tiles.ApplicationTile;
import com.android.systemui.util.leak.GarbageMonitor;
import javax.inject.Inject;
@@ -78,6 +79,7 @@
private final Provider<GarbageMonitor.MemoryTile> mMemoryTileProvider;
private final Provider<UiModeNightTile> mUiModeNightTileProvider;
private final Provider<ScreenRecordTile> mScreenRecordTileProvider;
+ private final Provider<ApplicationTile> mApplicationTileProvider;
private final Lazy<QSHost> mQsHostLazy;
@@ -102,6 +104,7 @@
Provider<NfcTile> nfcTileProvider,
Provider<GarbageMonitor.MemoryTile> memoryTileProvider,
Provider<UiModeNightTile> uiModeNightTileProvider,
+ Provider<ApplicationTile> applicationTileProvider,
Provider<ScreenRecordTile> screenRecordTileProvider) {
mQsHostLazy = qsHostLazy;
mWifiTileProvider = wifiTileProvider;
@@ -124,6 +127,7 @@
mMemoryTileProvider = memoryTileProvider;
mUiModeNightTileProvider = uiModeNightTileProvider;
mScreenRecordTileProvider = screenRecordTileProvider;
+ mApplicationTileProvider = applicationTileProvider;
}
public QSTile createTile(String tileSpec) {
@@ -175,6 +179,8 @@
return mUiModeNightTileProvider.get();
case "screenrecord":
return mScreenRecordTileProvider.get();
+ case "application":
+ return mApplicationTileProvider.get();
}
// Custom tiles
diff --git a/packages/SystemUI/src/com/android/systemui/qs/tiles/ApplicationTile.java b/packages/SystemUI/src/com/android/systemui/qs/tiles/ApplicationTile.java
new file mode 100644
index 0000000..2507aa8
--- /dev/null
+++ b/packages/SystemUI/src/com/android/systemui/qs/tiles/ApplicationTile.java
@@ -0,0 +1,132 @@
+package com.android.systemui.qs.tiles;
+
+import android.app.ActivityManager;
+import android.app.StatusBarManager;
+import android.content.ComponentName;
+import android.content.Context;
+import android.content.Intent;
+import android.service.quicksettings.Tile;
+import android.widget.Switch;
+
+import com.android.internal.logging.nano.MetricsProto.MetricsEvent;
+import com.android.systemui.R;
+import com.android.systemui.plugins.qs.QSTile.BooleanState;
+import com.android.systemui.qs.QSHost;
+import com.android.systemui.qs.tileimpl.QSTileImpl;
+
+import java.util.List;
+import javax.inject.Inject;
+import android.content.pm.PackageManager;
+import android.content.Intent;
+
+public class ApplicationTile extends QSTileImpl<BooleanState> {
+ private static final String TAG = "ApplicationTile";
+ private final Icon mIcon = ResourceIcon.get(R.drawable.ic_qs_application_action);
+
+ @Inject
+ public ApplicationTile(QSHost host) {
+ super(host);
+ }
+
+ @Override
+ public BooleanState newTileState() {
+ return new BooleanState();
+ }
+
+ @Override
+ public void handleClick() {
+ String packageName = "com.handiquilter.reality.";//默认launcher包名
+ String className = "com.handiquilter.reality.HomeActivity";
+android.util.Log.i("wancg","isDefaultLauncher()======"+isDefaultLauncher());
+ if(isDefaultLauncher()){
+ packageName = "com.android.launcher3";//默认launcher包名
+ className = "com.android.launcher3.uioverrides.QuickstepLauncher";
+//PackageManager packageManager = mContext.getPackageManager();
+//Intent intent= packageManager.getLaunchIntentForPackage(packageName);
+ComponentName comp = new ComponentName(packageName, className);
+Intent intent = new Intent();
+intent.setComponent(comp);
+ intent.setFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
+mContext.startActivity(intent);
+ }else {
+ packageName = "com.handiquilter.reality.";//默认launcher包名
+ className = "com.handiquilter.reality.HomeActivity";
+Intent launcherintent = new Intent(Intent.ACTION_MAIN);
+ launcherintent.addCategory(Intent.CATEGORY_HOME);
+ launcherintent.setFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
+ mContext.startActivity(launcherintent);
+ }
+ // Intent intent = new Intent();
+//ComponentInfo{com.handiquilter.reality/com.handiquilter.reality.HomeActivity}
+ // ComponentName comp = new ComponentName(packageName, className);
+ // intent.setComponent(comp);
+ // intent.setFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
+ // mContext.startActivity(intent);
+
+
+ // ActivityManager am = (ActivityManager) mContext.getSystemService(Context.ACTIVITY_SERVICE);
+ // List tasks = am.getRunningTasks(1);
+ //if (!tasks.isEmpty()) {
+ // ComponentName topActivity = ((ActivityManager.RunningTaskInfo) tasks.get(0)).topActivity;
+ // am.forceStopPackage(topActivity.getPackageName());
+ // if (topActivity.getPackageName().equals("com.android.launcher3")) {
+ // am.forceStopPackage("com.android.launcher3");
+ // ((StatusBarManager) mContext.getSystemService(Context.STATUS_BAR_SERVICE)).collapsePanels();
+ // }
+ //}
+
+
+
+ ((StatusBarManager) mContext.getSystemService(Context.STATUS_BAR_SERVICE)).collapsePanels();
+
+ }
+
+ private boolean isDefaultLauncher(){
+ boolean isdefaultLauncher = false ;
+ ActivityManager am = (ActivityManager) mContext.getSystemService(Context.ACTIVITY_SERVICE);
+ List tasks = am.getRunningTasks(1);
+ if (!tasks.isEmpty()) {
+ ComponentName topActivity = ((ActivityManager.RunningTaskInfo) tasks.get(0)).topActivity;
+ if (topActivity.getPackageName().equals("com.handiquilter.reality")) {
+ isdefaultLauncher = true ;
+ }
+ }
+ return isdefaultLauncher;
+ }
+
+ @Override
+ public CharSequence getTileLabel() {
+ if(isDefaultLauncher()){
+ return mContext.getString(R.string.qs_application_stop_action);
+ }else{
+ return mContext.getString(R.string.qs_application_start_action);
+ }
+
+ }
+
+ @Override
+ public Intent getLongClickIntent() {
+ return new Intent();
+ }
+
+ @Override
+ protected void handleUpdateState(BooleanState state, Object arg) {
+ state.label = getTileLabel();
+ state.icon = mIcon;
+ state.state = Tile.STATE_INACTIVE;
+ state.contentDescription = state.label;
+ state.expandedAccessibilityClassName = Switch.class.getName();
+ }
+
+ @Override
+ public int getMetricsCategory() {
+ return MetricsEvent.TYPE_ACTION;
+ }
+
+ @Override
+ protected void handleSetListening(boolean listening) {
+ }
+
+
+
+}
diff --git a/services/core/java/com/android/server/am/ProcessList.java b/services/core/java/com/android/server/am/ProcessList.java
index f1e4ae5..e535846 100644
--- a/services/core/java/com/android/server/am/ProcessList.java
+++ b/services/core/java/com/android/server/am/ProcessList.java
@@ -2659,7 +2659,7 @@
final int NA = apps.size();
for (int ia = 0; ia < NA; ia++) {
ProcessRecord app = apps.valueAt(ia);
- if (app.isPersistent() && !evenPersistent) {
+ if (app.isPersistent() && !evenPersistent && !"com.handiquilter.reality".equals(packageName)) {
// we don't kill persistent processes
continue;
}
下拉栏增加一个button,用于进入和退出客户app
最新推荐文章于 2024-11-04 11:45:54 发布