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

Commit 36382f13 authored by TreeHugger Robot's avatar TreeHugger Robot Committed by Android (Google) Code Review
Browse files

Merge "Move keys removal to background handler." into tm-dev

parents 3b2c9ed5 815e7559
Loading
Loading
Loading
Loading
+14 −3
Original line number Diff line number Diff line
@@ -17,6 +17,7 @@
package com.android.server.pm;

import static android.content.pm.PackageManager.UNINSTALL_REASON_UNKNOWN;
import static android.os.Trace.TRACE_TAG_PACKAGE_MANAGER;
import static android.os.incremental.IncrementalManager.isIncrementalPath;
import static android.os.storage.StorageManager.FLAG_STORAGE_CE;
import static android.os.storage.StorageManager.FLAG_STORAGE_DE;
@@ -29,6 +30,7 @@ import static com.android.server.pm.PackageManagerService.TAG;

import android.annotation.NonNull;
import android.content.pm.PackageManager;
import android.os.Trace;
import android.os.UserHandle;
import android.os.incremental.IncrementalManager;
import android.util.Log;
@@ -334,10 +336,19 @@ final class RemovePackageHelper {
                mPm.mSettings.writeKernelMappingLPr(deletedPs);
            }
        }

        if (removedAppId != -1) {
            // A user ID was deleted here. Go through all users and remove it
            // from KeyStore.
            mAppDataHelper.clearKeystoreData(UserHandle.USER_ALL, removedAppId);
            // A user ID was deleted here. Go through all users and remove it from KeyStore.
            final int appIdToRemove = removedAppId;
            mPm.mInjector.getBackgroundHandler().post(() -> {
                try {
                    Trace.traceBegin(TRACE_TAG_PACKAGE_MANAGER,
                            "clearKeystoreData:" + appIdToRemove);
                    mAppDataHelper.clearKeystoreData(UserHandle.USER_ALL, appIdToRemove);
                } finally {
                    Trace.traceEnd(TRACE_TAG_PACKAGE_MANAGER);
                }
            });
        }
    }
}
+2 −0
Original line number Diff line number Diff line
@@ -203,6 +203,7 @@ class MockSystem(withSession: (StaticMockitoSessionBuilder) -> Unit = {}) {
        val domainVerificationManagerInternal: DomainVerificationManagerInternal = mock()
        val handler = TestHandler(null)
        val defaultAppProvider: DefaultAppProvider = mock()
        val backgroundHandler = TestHandler(null)
    }

    companion object {
@@ -286,6 +287,7 @@ class MockSystem(withSession: (StaticMockitoSessionBuilder) -> Unit = {}) {
            .thenReturn(mocks.domainVerificationManagerInternal)
        whenever(mocks.injector.handler) { mocks.handler }
        whenever(mocks.injector.defaultAppProvider) { mocks.defaultAppProvider }
        whenever(mocks.injector.backgroundHandler) { mocks.backgroundHandler }
        wheneverStatic { SystemConfig.getInstance() }.thenReturn(mocks.systemConfig)
        whenever(mocks.systemConfig.availableFeatures).thenReturn(DEFAULT_AVAILABLE_FEATURES_MAP)
        whenever(mocks.systemConfig.sharedLibraries).thenReturn(DEFAULT_SHARED_LIBRARIES_LIST)