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

Commit b4dabb09 authored by Songchun Fan's avatar Songchun Fan
Browse files

[pm] add deDataInode in PackageUserState

It's possible that an app doesn't have a CE node on a user if the user
is locked or the CE storage for the user hasn't been prepared yet. In
those situations, there's only the DE node. We should use both the CE
node and the DE node to determine if the data dir exists.

This CL doesn't change any existing API behavior.

BUG: 288142708
Test: manual

Change-Id: I6cc0673d675c2ca9e51ddf7d9217c3c9f2b7e2cd
parent 28aef0fe
Loading
Loading
Loading
Loading
+11 −5
Original line number Diff line number Diff line
@@ -17,7 +17,6 @@
package com.android.server.pm;

import static android.os.Trace.TRACE_TAG_PACKAGE_MANAGER;

import static com.android.server.pm.PackageManagerService.TAG;
import static com.android.server.pm.PackageManagerServiceUtils.getPackageManagerLocal;
import static com.android.server.pm.PackageManagerServiceUtils.logCriticalInfo;
@@ -228,7 +227,7 @@ public class AppDataHelper {
                userId, flags, appId, seInfo, targetSdkVersion, usesSdk);
        args.previousAppId = previousAppId;

        return batch.createAppData(args).whenComplete((ceDataInode, e) -> {
        return batch.createAppData(args).whenComplete((createAppDataResult, e) -> {
            // Note: this code block is executed with the Installer lock
            // already held, since it's invoked as a side-effect of
            // executeBatchLI()
@@ -237,7 +236,7 @@ public class AppDataHelper {
                        + ", but trying to recover: " + e);
                destroyAppDataLeafLIF(pkg, userId, flags);
                try {
                    ceDataInode = mInstaller.createAppData(args).ceDataInode;
                    createAppDataResult = mInstaller.createAppData(args);
                    logCriticalInfo(Log.DEBUG, "Recovery succeeded!");
                } catch (Installer.InstallerException e2) {
                    logCriticalInfo(Log.DEBUG, "Recovery failed!");
@@ -279,12 +278,19 @@ public class AppDataHelper {
                }
            }

            final long ceDataInode = createAppDataResult.ceDataInode;
            final long deDataInode = createAppDataResult.deDataInode;

            if ((flags & StorageManager.FLAG_STORAGE_CE) != 0 && ceDataInode != -1) {
                // TODO: mark this structure as dirty so we persist it!
                synchronized (mPm.mLock) {
                    ps.setCeDataInode(ceDataInode, userId);
                }
            }
            if ((flags & StorageManager.FLAG_STORAGE_DE) != 0 && deDataInode != -1) {
                synchronized (mPm.mLock) {
                    ps.setDeDataInode(deDataInode, userId);
                }
            }

            prepareAppDataContentsLeafLIF(pkg, ps, userId, flags);
        });
@@ -609,7 +615,7 @@ public class AppDataHelper {
        destroyAppDataLeafLIF(pkg, userId, flags);
    }

    public void destroyAppDataLeafLIF(AndroidPackage pkg, int userId, int flags) {
    private void destroyAppDataLeafLIF(AndroidPackage pkg, int userId, int flags) {
        final Computer snapshot = mPm.snapshotComputer();
        final PackageStateInternal packageStateInternal =
                snapshot.getPackageStateInternal(pkg.getPackageName());
+1 −0
Original line number Diff line number Diff line
@@ -569,6 +569,7 @@ final class DeletePackageHelper {

            ps.setUserState(nextUserId,
                    ps.getCeDataInode(nextUserId),
                    ps.getDeDataInode(nextUserId),
                    COMPONENT_ENABLED_STATE_DEFAULT,
                    false /*installed*/,
                    true /*stopped*/,
+7 −5
Original line number Diff line number Diff line
@@ -257,6 +257,7 @@ public class Installer extends SystemService {
    private static CreateAppDataResult buildPlaceholderCreateAppDataResult() {
        final CreateAppDataResult result = new CreateAppDataResult();
        result.ceDataInode = -1;
        result.deDataInode = -1;
        result.exceptionCode = 0;
        result.exceptionMessage = null;
        return result;
@@ -361,7 +362,7 @@ public class Installer extends SystemService {
        private boolean mExecuted;

        private final List<CreateAppDataArgs> mArgs = new ArrayList<>();
        private final List<CompletableFuture<Long>> mFutures = new ArrayList<>();
        private final List<CompletableFuture<CreateAppDataResult>> mFutures = new ArrayList<>();

        /**
         * Enqueue the given {@code installd} operation to be executed in the
@@ -371,11 +372,12 @@ public class Installer extends SystemService {
         * {@link Installer} object.
         */
        @NonNull
        public synchronized CompletableFuture<Long> createAppData(CreateAppDataArgs args) {
        public synchronized CompletableFuture<CreateAppDataResult> createAppData(
                CreateAppDataArgs args) {
            if (mExecuted) {
                throw new IllegalStateException();
            }
            final CompletableFuture<Long> future = new CompletableFuture<>();
            final CompletableFuture<CreateAppDataResult> future = new CompletableFuture<>();
            mArgs.add(args);
            mFutures.add(future);
            return future;
@@ -402,9 +404,9 @@ public class Installer extends SystemService {
                final CreateAppDataResult[] results = installer.createAppDataBatched(args);
                for (int j = 0; j < results.length; j++) {
                    final CreateAppDataResult result = results[j];
                    final CompletableFuture<Long> future = mFutures.get(i + j);
                    final CompletableFuture<CreateAppDataResult> future = mFutures.get(i + j);
                    if (result.exceptionCode == 0) {
                        future.complete(result.ceDataInode);
                        future.complete(result);
                    } else {
                        future.completeExceptionally(
                                new InstallerException(result.exceptionMessage));
+23 −13

File changed.

Preview size limit exceeded, changes collapsed.

+1 −0
Original line number Diff line number Diff line
@@ -277,6 +277,7 @@ final class RemovePackageHelper {
                mAppDataHelper.destroyAppDataLIF(pkg, nextUserId,
                        FLAG_STORAGE_DE | FLAG_STORAGE_CE | FLAG_STORAGE_EXTERNAL);
                ps.setCeDataInode(-1, nextUserId);
                ps.setDeDataInode(-1, nextUserId);
            }
            mAppDataHelper.clearKeystoreData(nextUserId, ps.getAppId());
            preferredActivityHelper.clearPackagePreferredActivities(ps.getPackageName(),
Loading