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

This commit is contained in:
TreeHugger Robot
2022-03-30 12:09:44 +00:00
committed by Android (Google) Code Review
2 changed files with 16 additions and 3 deletions

View File

@@ -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);
}
});
}
}
}

View File

@@ -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)