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

Commit 41977ea0 authored by Patrick Baumann's avatar Patrick Baumann Committed by android-build-merger
Browse files

Merge "Bind to DefaultContainerService early for AIA" into pi-dev am: 68e89707

am: 1673f6f9

Change-Id: I98306c974f053b9f6824865c5be12218bae3a780
parents b4346c6e 1673f6f9
Loading
Loading
Loading
Loading
+14 −2
Original line number Original line Diff line number Diff line
@@ -122,8 +122,9 @@ public class PackageInstallerSession extends IPackageInstallerSession.Stub {
    private static final boolean LOGD = true;
    private static final boolean LOGD = true;
    private static final String REMOVE_SPLIT_MARKER_EXTENSION = ".removed";
    private static final String REMOVE_SPLIT_MARKER_EXTENSION = ".removed";


    private static final int MSG_COMMIT = 0;
    private static final int MSG_EARLY_BIND = 0;
    private static final int MSG_ON_PACKAGE_INSTALLED = 1;
    private static final int MSG_COMMIT = 1;
    private static final int MSG_ON_PACKAGE_INSTALLED = 2;


    /** XML constants used for persisting a session */
    /** XML constants used for persisting a session */
    static final String TAG_SESSION = "session";
    static final String TAG_SESSION = "session";
@@ -280,6 +281,9 @@ public class PackageInstallerSession extends IPackageInstallerSession.Stub {
        @Override
        @Override
        public boolean handleMessage(Message msg) {
        public boolean handleMessage(Message msg) {
            switch (msg.what) {
            switch (msg.what) {
                case MSG_EARLY_BIND:
                    earlyBindToDefContainer();
                    break;
                case MSG_COMMIT:
                case MSG_COMMIT:
                    synchronized (mLock) {
                    synchronized (mLock) {
                        try {
                        try {
@@ -315,6 +319,10 @@ public class PackageInstallerSession extends IPackageInstallerSession.Stub {
        }
        }
    };
    };


    private void earlyBindToDefContainer() {
        mPm.earlyBindToDefContainer();
    }

    /**
    /**
     * @return {@code true} iff the installing is app an device owner or affiliated profile owner.
     * @return {@code true} iff the installing is app an device owner or affiliated profile owner.
     */
     */
@@ -410,6 +418,10 @@ public class PackageInstallerSession extends IPackageInstallerSession.Stub {
        } finally {
        } finally {
            Binder.restoreCallingIdentity(identity);
            Binder.restoreCallingIdentity(identity);
        }
        }
        // attempt to bind to the DefContainer as early as possible
        if ((params.installFlags & PackageManager.INSTALL_INSTANT_APP) != 0) {
            mHandler.sendMessage(mHandler.obtainMessage(MSG_EARLY_BIND));
        }
    }
    }


    public SessionInfo generateInfo() {
    public SessionInfo generateInfo() {
+21 −2
Original line number Original line Diff line number Diff line
@@ -1326,6 +1326,7 @@ public class PackageManagerService extends IPackageManager.Stub
    static final int INTENT_FILTER_VERIFIED = 18;
    static final int INTENT_FILTER_VERIFIED = 18;
    static final int WRITE_PACKAGE_LIST = 19;
    static final int WRITE_PACKAGE_LIST = 19;
    static final int INSTANT_APP_RESOLUTION_PHASE_TWO = 20;
    static final int INSTANT_APP_RESOLUTION_PHASE_TWO = 20;
    static final int DEF_CONTAINER_BIND = 21;
    static final int WRITE_SETTINGS_DELAY = 10*1000;  // 10 seconds
    static final int WRITE_SETTINGS_DELAY = 10*1000;  // 10 seconds
@@ -1417,8 +1418,7 @@ public class PackageManagerService extends IPackageManager.Stub
            new ArrayList<HandlerParams>();
            new ArrayList<HandlerParams>();
        private boolean connectToService() {
        private boolean connectToService() {
            if (DEBUG_SD_INSTALL) Log.i(TAG, "Trying to bind to" +
            if (DEBUG_INSTALL) Log.i(TAG, "Trying to bind to DefaultContainerService");
                    " DefaultContainerService");
            Intent service = new Intent().setComponent(DEFAULT_CONTAINER_COMPONENT);
            Intent service = new Intent().setComponent(DEFAULT_CONTAINER_COMPONENT);
            Process.setThreadPriority(Process.THREAD_PRIORITY_DEFAULT);
            Process.setThreadPriority(Process.THREAD_PRIORITY_DEFAULT);
            if (mContext.bindServiceAsUser(service, mDefContainerConn,
            if (mContext.bindServiceAsUser(service, mDefContainerConn,
@@ -1453,6 +1453,17 @@ public class PackageManagerService extends IPackageManager.Stub
        void doHandleMessage(Message msg) {
        void doHandleMessage(Message msg) {
            switch (msg.what) {
            switch (msg.what) {
                case DEF_CONTAINER_BIND:
                    if (!mBound) {
                        Trace.asyncTraceBegin(TRACE_TAG_PACKAGE_MANAGER, "earlyBindingMCS",
                                System.identityHashCode(mHandler));
                        if (!connectToService()) {
                            Slog.e(TAG, "Failed to bind to media container service");
                        }
                        Trace.asyncTraceEnd(TRACE_TAG_PACKAGE_MANAGER, "earlyBindingMCS",
                                System.identityHashCode(mHandler));
                    }
                    break;
                case INIT_COPY: {
                case INIT_COPY: {
                    HandlerParams params = (HandlerParams) msg.obj;
                    HandlerParams params = (HandlerParams) msg.obj;
                    int idx = mPendingInstalls.size();
                    int idx = mPendingInstalls.size();
@@ -13636,6 +13647,14 @@ public class PackageManagerService extends IPackageManager.Stub
        return installReason;
        return installReason;
    }
    }
    /**
     * Attempts to bind to the default container service explicitly instead of doing so lazily on
     * install commit.
     */
    void earlyBindToDefContainer() {
        mHandler.sendMessage(mHandler.obtainMessage(DEF_CONTAINER_BIND));
    }
    void installStage(String packageName, File stagedDir,
    void installStage(String packageName, File stagedDir,
            IPackageInstallObserver2 observer, PackageInstaller.SessionParams sessionParams,
            IPackageInstallObserver2 observer, PackageInstaller.SessionParams sessionParams,
            String installerPackageName, int installerUid, UserHandle user,
            String installerPackageName, int installerUid, UserHandle user,