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

Commit 6a652e1d authored by Valentin Iftime's avatar Valentin Iftime Committed by Iavor-Valentin Iftime
Browse files

Allow pinning of Assistant app

Use bool config_pinnerAssistantApp (config.xml) to enable pinning for Assistant.

Test:  Set config_pinnerAssistantApp to true in config.xml, build & flash, run adb shell dumpsys pinner , check if assistant package is listed as pinned
Bug: 133211801
Bug: 133218284
Change-Id: If2e4c63156d4dd8f63f3318b5e8fb2db6bc4cc8b
parent b2a9c661
Loading
Loading
Loading
Loading
+3 −0
Original line number Diff line number Diff line
@@ -3483,6 +3483,9 @@
    <!-- True if home app should be pinned via Pinner Service -->
    <bool name="config_pinnerHomeApp">false</bool>

    <!-- True if assistant app should be pinned via Pinner Service -->
    <bool name="config_pinnerAssistantApp">false</bool>

    <!-- List of files pinned by the Pinner Service with the apex boot image b/119800099 -->
    <string-array translatable="false" name="config_apexBootImagePinnerServiceFiles">
    </string-array>
+1 −0
Original line number Diff line number Diff line
@@ -3118,6 +3118,7 @@
  <java-symbol type="array" name="config_defaultPinnerServiceFiles" />
  <java-symbol type="bool" name="config_pinnerCameraApp" />
  <java-symbol type="bool" name="config_pinnerHomeApp" />
  <java-symbol type="bool" name="config_pinnerAssistantApp" />
  <java-symbol type="array" name="config_apexBootImagePinnerServiceFiles" />

  <java-symbol type="string" name="config_doubleTouchGestureEnableFile" />
+33 −1
Original line number Diff line number Diff line
@@ -25,6 +25,7 @@ import android.app.ActivityManager;
import android.app.ActivityManagerInternal;
import android.app.IActivityManager;
import android.app.IUidObserver;
import android.app.SearchManager;
import android.content.BroadcastReceiver;
import android.content.Context;
import android.content.Intent;
@@ -94,6 +95,7 @@ public final class PinnerService extends SystemService {

    private static final int KEY_CAMERA = 0;
    private static final int KEY_HOME = 1;
    private static final int KEY_ASSISTANT = 2;

    // Pin the camera application.
    private static boolean PROP_PIN_CAMERA = SystemProperties.getBoolean(
@@ -107,8 +109,9 @@ public final class PinnerService extends SystemService {

    private static final int MAX_CAMERA_PIN_SIZE = 80 * (1 << 20); // 80MB max for camera app.
    private static final int MAX_HOME_PIN_SIZE = 6 * (1 << 20); // 6MB max for home app.
    private static final int MAX_ASSISTANT_PIN_SIZE = 60 * (1 << 20); // 60MB max for assistant app.

    @IntDef({KEY_CAMERA, KEY_HOME})
    @IntDef({KEY_CAMERA, KEY_HOME, KEY_ASSISTANT})
    @Retention(RetentionPolicy.SOURCE)
    public @interface AppKey {}

@@ -117,6 +120,7 @@ public final class PinnerService extends SystemService {
    private final ActivityManagerInternal mAmInternal;
    private final IActivityManager mAm;
    private final UserManager mUserManager;
    private SearchManager mSearchManager;

    /** The list of the statically pinned files. */
    @GuardedBy("this")
@@ -167,6 +171,8 @@ public final class PinnerService extends SystemService {
                com.android.internal.R.bool.config_pinnerCameraApp);
        boolean shouldPinHome = context.getResources().getBoolean(
                com.android.internal.R.bool.config_pinnerHomeApp);
        boolean shouldPinAssistant = context.getResources().getBoolean(
                com.android.internal.R.bool.config_pinnerAssistantApp);
        if (shouldPinCamera) {
            if (PROP_PIN_CAMERA) {
                mPinKeys.add(KEY_CAMERA);
@@ -177,6 +183,9 @@ public final class PinnerService extends SystemService {
        if (shouldPinHome) {
            mPinKeys.add(KEY_HOME);
        }
        if (shouldPinAssistant) {
            mPinKeys.add(KEY_ASSISTANT);
        }
        mPinnerHandler = new PinnerHandler(BackgroundThread.get().getLooper());

        mAtmInternal = LocalServices.getService(ActivityTaskManagerInternal.class);
@@ -207,6 +216,15 @@ public final class PinnerService extends SystemService {
        sendPinAppsMessage(UserHandle.USER_SYSTEM);
    }

    @Override
    public void onBootPhase(int phase) {
        // SearchManagerService is started after PinnerService, wait for PHASE_SYSTEM_SERVICES_READY
        if (phase == SystemService.PHASE_SYSTEM_SERVICES_READY) {
            mSearchManager = (SearchManager) mContext.getSystemService(Context.SEARCH_SERVICE);
            sendPinAppsMessage(UserHandle.USER_SYSTEM);
        }
    }

    /**
     * Repin apps on user switch.
     * <p>
@@ -408,6 +426,14 @@ public final class PinnerService extends SystemService {
        return getApplicationInfoForIntent(intent, userHandle, false);
    }

    private ApplicationInfo getAssistantInfo(int userHandle) {
        if (mSearchManager != null) {
            Intent intent = mSearchManager.getAssistIntent(false);
            return getApplicationInfoForIntent(intent, userHandle, true);
        }
        return null;
    }

    private ApplicationInfo getApplicationInfoForIntent(Intent intent, int userHandle,
            boolean defaultToSystemApp) {
        if (intent == null) {
@@ -520,6 +546,8 @@ public final class PinnerService extends SystemService {
                return getCameraInfo(userHandle);
            case KEY_HOME:
                return getHomeInfo(userHandle);
            case KEY_ASSISTANT:
                return getAssistantInfo(userHandle);
            default:
                return null;
        }
@@ -534,6 +562,8 @@ public final class PinnerService extends SystemService {
                return "Camera";
            case KEY_HOME:
                return "Home";
            case KEY_ASSISTANT:
                return "Assistant";
            default:
                return null;
        }
@@ -548,6 +578,8 @@ public final class PinnerService extends SystemService {
                return MAX_CAMERA_PIN_SIZE;
            case KEY_HOME:
                return MAX_HOME_PIN_SIZE;
            case KEY_ASSISTANT:
                return MAX_ASSISTANT_PIN_SIZE;
            default:
                return 0;
        }