Merge "Move PM cache invalidate inside mlock" into sc-dev
This commit is contained in:
@@ -883,7 +883,7 @@ public class PackageManagerService extends IPackageManager.Stub
|
||||
// Lock for global state used when modifying package state or settings.
|
||||
// Methods that must be called with this lock held have
|
||||
// the suffix "Locked". Some methods may use the legacy suffix "LP"
|
||||
final Object mLock;
|
||||
final PackageManagerTracedLock mLock;
|
||||
|
||||
// Keys are String (package name), values are Package.
|
||||
@Watched
|
||||
@@ -1042,7 +1042,7 @@ public class PackageManagerService extends IPackageManager.Stub
|
||||
|
||||
private final PackageAbiHelper mAbiHelper;
|
||||
private final Context mContext;
|
||||
private final Object mLock;
|
||||
private final PackageManagerTracedLock mLock;
|
||||
private final Installer mInstaller;
|
||||
private final Object mInstallLock;
|
||||
private final Handler mBackgroundHandler;
|
||||
@@ -1082,7 +1082,7 @@ public class PackageManagerService extends IPackageManager.Stub
|
||||
mDomainVerificationManagerInternalProducer;
|
||||
private final Singleton<Handler> mHandlerProducer;
|
||||
|
||||
Injector(Context context, Object lock, Installer installer,
|
||||
Injector(Context context, PackageManagerTracedLock lock, Installer installer,
|
||||
Object installLock, PackageAbiHelper abiHelper,
|
||||
Handler backgroundHandler,
|
||||
List<ScanPartition> systemPartitions,
|
||||
@@ -1182,7 +1182,7 @@ public class PackageManagerService extends IPackageManager.Stub
|
||||
return mUserManagerProducer.get(this, mPackageManager);
|
||||
}
|
||||
|
||||
public Object getLock() {
|
||||
public PackageManagerTracedLock getLock() {
|
||||
return mLock;
|
||||
}
|
||||
|
||||
@@ -5964,7 +5964,7 @@ public class PackageManagerService extends IPackageManager.Stub
|
||||
final TimingsTraceAndSlog t = new TimingsTraceAndSlog(TAG + "Timing",
|
||||
Trace.TRACE_TAG_PACKAGE_MANAGER);
|
||||
t.traceBegin("create package manager");
|
||||
final Object lock = new Object();
|
||||
final PackageManagerTracedLock lock = new PackageManagerTracedLock();
|
||||
final Object installLock = new Object();
|
||||
HandlerThread backgroundThread = new HandlerThread("PackageManagerBg");
|
||||
backgroundThread.start();
|
||||
@@ -26890,11 +26890,12 @@ public class PackageManagerService extends IPackageManager.Stub
|
||||
outUpdatedPackageNames.add(targetPackageName);
|
||||
modified = true;
|
||||
}
|
||||
|
||||
if (modified) {
|
||||
invalidatePackageInfoCache();
|
||||
}
|
||||
}
|
||||
|
||||
if (modified) {
|
||||
invalidatePackageInfoCache();
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
|
||||
@@ -0,0 +1,24 @@
|
||||
/*
|
||||
* Copyright (C) 2021 The Android Open Source Project
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
package com.android.server.pm;
|
||||
|
||||
/**
|
||||
* This is a unique class that is used as the PackageManager lock. It can be targeted for lock
|
||||
* injection, similar to {@link ActivityManagerGlobalLock}.
|
||||
*/
|
||||
public class PackageManagerTracedLock {
|
||||
}
|
||||
@@ -353,7 +353,7 @@ public final class Settings implements Watchable, Snappable {
|
||||
private static final String ATTR_DATABASE_VERSION = "databaseVersion";
|
||||
private static final String ATTR_VALUE = "value";
|
||||
|
||||
private final Object mLock;
|
||||
private final PackageManagerTracedLock mLock;
|
||||
|
||||
private final RuntimePermissionPersistence mRuntimePermissionsPersistence;
|
||||
|
||||
@@ -525,7 +525,7 @@ public final class Settings implements Watchable, Snappable {
|
||||
|
||||
@VisibleForTesting(visibility = VisibleForTesting.Visibility.PRIVATE)
|
||||
public Settings(Map<String, PackageSetting> pkgSettings) {
|
||||
mLock = new Object();
|
||||
mLock = new PackageManagerTracedLock();
|
||||
mPackages.putAll(pkgSettings);
|
||||
mAppIds = new WatchedArrayList<>();
|
||||
mOtherAppIds = new WatchedSparseArray<>();
|
||||
@@ -562,7 +562,7 @@ public final class Settings implements Watchable, Snappable {
|
||||
Settings(File dataDir, RuntimePermissionsPersistence runtimePermissionsPersistence,
|
||||
LegacyPermissionDataProvider permissionDataProvider,
|
||||
@NonNull DomainVerificationManagerInternal domainVerificationManager,
|
||||
@NonNull Object lock) {
|
||||
@NonNull PackageManagerTracedLock lock) {
|
||||
mLock = lock;
|
||||
mAppIds = new WatchedArrayList<>();
|
||||
mOtherAppIds = new WatchedSparseArray<>();
|
||||
|
||||
@@ -163,7 +163,7 @@ class MockSystem(withSession: (StaticMockitoSessionBuilder) -> Unit = {}) {
|
||||
/** Collection of mocks used for PackageManagerService tests. */
|
||||
|
||||
class Mocks {
|
||||
val lock = Any()
|
||||
val lock = PackageManagerTracedLock()
|
||||
val installLock = Any()
|
||||
val injector: PackageManagerService.Injector = mock()
|
||||
val systemWrapper: PackageManagerService.SystemWrapper = mock()
|
||||
|
||||
@@ -59,10 +59,10 @@ import androidx.test.runner.AndroidJUnit4;
|
||||
|
||||
import com.android.permission.persistence.RuntimePermissionsPersistence;
|
||||
import com.android.server.LocalServices;
|
||||
import com.android.server.pm.verify.domain.DomainVerificationManagerInternal;
|
||||
import com.android.server.pm.parsing.pkg.PackageImpl;
|
||||
import com.android.server.pm.parsing.pkg.ParsedPackage;
|
||||
import com.android.server.pm.permission.LegacyPermissionDataProvider;
|
||||
import com.android.server.pm.verify.domain.DomainVerificationManagerInternal;
|
||||
import com.android.server.utils.WatchableTester;
|
||||
|
||||
import com.google.common.truth.Truth;
|
||||
@@ -1197,7 +1197,7 @@ public class PackageManagerSettingsTests {
|
||||
private Settings makeSettings() {
|
||||
return new Settings(InstrumentationRegistry.getContext().getFilesDir(),
|
||||
mRuntimePermissionsPersistence, mPermissionDataProvider,
|
||||
mDomainVerificationManager, new Object());
|
||||
mDomainVerificationManager, new PackageManagerTracedLock());
|
||||
}
|
||||
|
||||
private void verifyKeySetMetaData(Settings settings)
|
||||
|
||||
Reference in New Issue
Block a user