Loading services/core/java/com/android/server/pm/PackageManagerService.java +14 −14 Original line number Original line Diff line number Diff line Loading @@ -378,14 +378,14 @@ import java.util.function.Predicate; * <p> * <p> * Internally there are two important locks: * Internally there are two important locks: * <ul> * <ul> * <li>{@link #mPackages} is used to guard all in-memory parsed package details * <li>{@link #mLock} is used to guard all in-memory parsed package details * and other related state. It is a fine-grained lock that should only be held * and other related state. It is a fine-grained lock that should only be held * momentarily, as it's one of the most contended locks in the system. * momentarily, as it's one of the most contended locks in the system. * <li>{@link #mInstallLock} is used to guard all {@code installd} access, whose * <li>{@link #mInstallLock} is used to guard all {@code installd} access, whose * operations typically involve heavy lifting of application data on disk. Since * operations typically involve heavy lifting of application data on disk. Since * {@code installd} is single-threaded, and it's operations can often be slow, * {@code installd} is single-threaded, and it's operations can often be slow, * this lock should never be acquired while already holding {@link #mPackages}. * this lock should never be acquired while already holding {@link #mLock}. * Conversely, it's safe to acquire {@link #mPackages} momentarily while already * Conversely, it's safe to acquire {@link #mLock} momentarily while already * holding {@link #mInstallLock}. * holding {@link #mInstallLock}. * </ul> * </ul> * Many internal methods rely on the caller to hold the appropriate locks, and * Many internal methods rely on the caller to hold the appropriate locks, and Loading @@ -394,8 +394,8 @@ import java.util.function.Predicate; * <li>fooLI(): the caller must hold {@link #mInstallLock} * <li>fooLI(): the caller must hold {@link #mInstallLock} * <li>fooLIF(): the caller must hold {@link #mInstallLock} and the package * <li>fooLIF(): the caller must hold {@link #mInstallLock} and the package * being modified must be frozen * being modified must be frozen * <li>fooLPr(): the caller must hold {@link #mPackages} for reading * <li>fooLPr(): the caller must hold {@link #mLock} for reading * <li>fooLPw(): the caller must hold {@link #mPackages} for writing * <li>fooLPw(): the caller must hold {@link #mLock} for writing * </ul> * </ul> * <p> * <p> * Because this class is very central to the platform's security; please run all * Because this class is very central to the platform's security; please run all Loading Loading @@ -669,7 +669,7 @@ public class PackageManagerService extends IPackageManager.Stub // Lock for global state used when modifying package state or settings. // Lock for global state used when modifying package state or settings. // Methods that must be called with this lock held have // Methods that must be called with this lock held have // the suffix "Locked". Some methods may use the legacy the suffix "LP" // the suffix "Locked". Some methods may use the legacy suffix "LP" final Object mLock; final Object mLock; // Keys are String (package name), values are Package. // Keys are String (package name), values are Package. Loading Loading @@ -6531,13 +6531,13 @@ public class PackageManagerService extends IPackageManager.Stub } } // TODO: handle preferred activities missing while user has amnesia // TODO: handle preferred activities missing while user has amnesia /** <b>must not hold {@link #mPackages}</b> */ /** <b>must not hold {@link #mLock}</b> */ ResolveInfo findPreferredActivityNotLocked(Intent intent, String resolvedType, int flags, ResolveInfo findPreferredActivityNotLocked(Intent intent, String resolvedType, int flags, List<ResolveInfo> query, int priority, boolean always, List<ResolveInfo> query, int priority, boolean always, boolean removeMatches, boolean debug, int userId) { boolean removeMatches, boolean debug, int userId) { if (Thread.holdsLock(mLock)) { if (Thread.holdsLock(mLock)) { Slog.wtf(TAG, "Calling thread " + Thread.currentThread().getName() Slog.wtf(TAG, "Calling thread " + Thread.currentThread().getName() + " is holding mPackages", new Throwable()); + " is holding mLock", new Throwable()); } } if (!mUserManager.exists(userId)) return null; if (!mUserManager.exists(userId)) return null; final int callingUid = Binder.getCallingUid(); final int callingUid = Binder.getCallingUid(); Loading Loading @@ -16195,7 +16195,7 @@ public class PackageManagerService extends IPackageManager.Stub /** /** * On successful install, executes remaining steps after commit completes and the package lock * On successful install, executes remaining steps after commit completes and the package lock * is released. These are typically more expensive or require calls to installd, which often * is released. These are typically more expensive or require calls to installd, which often * locks on {@link #mPackages}. * locks on {@link #mLock}. */ */ private void executePostCommitSteps(CommitRequest commitRequest) { private void executePostCommitSteps(CommitRequest commitRequest) { for (ReconciledPackage reconciledPkg : commitRequest.reconciledPackages.values()) { for (ReconciledPackage reconciledPkg : commitRequest.reconciledPackages.values()) { Loading Loading @@ -19872,11 +19872,11 @@ public class PackageManagerService extends IPackageManager.Stub return null; return null; } } /** <b>must not hold {@link #mPackages}</b> */ /** <b>must not hold {@link #mLock}</b> */ private void updateDefaultHomeNotLocked(SparseBooleanArray userIds) { private void updateDefaultHomeNotLocked(SparseBooleanArray userIds) { if (Thread.holdsLock(mLock)) { if (Thread.holdsLock(mLock)) { Slog.wtf(TAG, "Calling thread " + Thread.currentThread().getName() Slog.wtf(TAG, "Calling thread " + Thread.currentThread().getName() + " is holding mPackages", new Throwable()); + " is holding mLock", new Throwable()); } } for (int i = userIds.size() - 1; i >= 0; --i) { for (int i = userIds.size() - 1; i >= 0; --i) { final int userId = userIds.keyAt(i); final int userId = userIds.keyAt(i); Loading @@ -19885,14 +19885,14 @@ public class PackageManagerService extends IPackageManager.Stub } } /** /** * <b>must not hold {@link #mPackages}</b> * <b>must not hold {@link #mLock}</b> * * * @return Whether the ACTION_PREFERRED_ACTIVITY_CHANGED broadcast has been scheduled. * @return Whether the ACTION_PREFERRED_ACTIVITY_CHANGED broadcast has been scheduled. */ */ private boolean updateDefaultHomeNotLocked(int userId) { private boolean updateDefaultHomeNotLocked(int userId) { if (Thread.holdsLock(mLock)) { if (Thread.holdsLock(mLock)) { Slog.wtf(TAG, "Calling thread " + Thread.currentThread().getName() Slog.wtf(TAG, "Calling thread " + Thread.currentThread().getName() + " is holding mPackages", new Throwable()); + " is holding mLock", new Throwable()); } } if (!mSystemReady) { if (!mSystemReady) { // We might get called before system is ready because of package changes etc, but // We might get called before system is ready because of package changes etc, but Loading Loading @@ -21823,7 +21823,7 @@ public class PackageManagerService extends IPackageManager.Stub * will try recovering system apps by wiping data; third-party app data is * will try recovering system apps by wiping data; third-party app data is * left intact. * left intact. * <p> * <p> * <em>Note: To avoid a deadlock, do not call this method with {@code mPackages} lock held</em> * <em>Note: To avoid a deadlock, do not call this method with {@code mLock} lock held</em> */ */ private void prepareAppDataAfterInstallLIF(PackageParser.Package pkg) { private void prepareAppDataAfterInstallLIF(PackageParser.Package pkg) { final PackageSetting ps; final PackageSetting ps; Loading
services/core/java/com/android/server/pm/PackageManagerService.java +14 −14 Original line number Original line Diff line number Diff line Loading @@ -378,14 +378,14 @@ import java.util.function.Predicate; * <p> * <p> * Internally there are two important locks: * Internally there are two important locks: * <ul> * <ul> * <li>{@link #mPackages} is used to guard all in-memory parsed package details * <li>{@link #mLock} is used to guard all in-memory parsed package details * and other related state. It is a fine-grained lock that should only be held * and other related state. It is a fine-grained lock that should only be held * momentarily, as it's one of the most contended locks in the system. * momentarily, as it's one of the most contended locks in the system. * <li>{@link #mInstallLock} is used to guard all {@code installd} access, whose * <li>{@link #mInstallLock} is used to guard all {@code installd} access, whose * operations typically involve heavy lifting of application data on disk. Since * operations typically involve heavy lifting of application data on disk. Since * {@code installd} is single-threaded, and it's operations can often be slow, * {@code installd} is single-threaded, and it's operations can often be slow, * this lock should never be acquired while already holding {@link #mPackages}. * this lock should never be acquired while already holding {@link #mLock}. * Conversely, it's safe to acquire {@link #mPackages} momentarily while already * Conversely, it's safe to acquire {@link #mLock} momentarily while already * holding {@link #mInstallLock}. * holding {@link #mInstallLock}. * </ul> * </ul> * Many internal methods rely on the caller to hold the appropriate locks, and * Many internal methods rely on the caller to hold the appropriate locks, and Loading @@ -394,8 +394,8 @@ import java.util.function.Predicate; * <li>fooLI(): the caller must hold {@link #mInstallLock} * <li>fooLI(): the caller must hold {@link #mInstallLock} * <li>fooLIF(): the caller must hold {@link #mInstallLock} and the package * <li>fooLIF(): the caller must hold {@link #mInstallLock} and the package * being modified must be frozen * being modified must be frozen * <li>fooLPr(): the caller must hold {@link #mPackages} for reading * <li>fooLPr(): the caller must hold {@link #mLock} for reading * <li>fooLPw(): the caller must hold {@link #mPackages} for writing * <li>fooLPw(): the caller must hold {@link #mLock} for writing * </ul> * </ul> * <p> * <p> * Because this class is very central to the platform's security; please run all * Because this class is very central to the platform's security; please run all Loading Loading @@ -669,7 +669,7 @@ public class PackageManagerService extends IPackageManager.Stub // Lock for global state used when modifying package state or settings. // Lock for global state used when modifying package state or settings. // Methods that must be called with this lock held have // Methods that must be called with this lock held have // the suffix "Locked". Some methods may use the legacy the suffix "LP" // the suffix "Locked". Some methods may use the legacy suffix "LP" final Object mLock; final Object mLock; // Keys are String (package name), values are Package. // Keys are String (package name), values are Package. Loading Loading @@ -6531,13 +6531,13 @@ public class PackageManagerService extends IPackageManager.Stub } } // TODO: handle preferred activities missing while user has amnesia // TODO: handle preferred activities missing while user has amnesia /** <b>must not hold {@link #mPackages}</b> */ /** <b>must not hold {@link #mLock}</b> */ ResolveInfo findPreferredActivityNotLocked(Intent intent, String resolvedType, int flags, ResolveInfo findPreferredActivityNotLocked(Intent intent, String resolvedType, int flags, List<ResolveInfo> query, int priority, boolean always, List<ResolveInfo> query, int priority, boolean always, boolean removeMatches, boolean debug, int userId) { boolean removeMatches, boolean debug, int userId) { if (Thread.holdsLock(mLock)) { if (Thread.holdsLock(mLock)) { Slog.wtf(TAG, "Calling thread " + Thread.currentThread().getName() Slog.wtf(TAG, "Calling thread " + Thread.currentThread().getName() + " is holding mPackages", new Throwable()); + " is holding mLock", new Throwable()); } } if (!mUserManager.exists(userId)) return null; if (!mUserManager.exists(userId)) return null; final int callingUid = Binder.getCallingUid(); final int callingUid = Binder.getCallingUid(); Loading Loading @@ -16195,7 +16195,7 @@ public class PackageManagerService extends IPackageManager.Stub /** /** * On successful install, executes remaining steps after commit completes and the package lock * On successful install, executes remaining steps after commit completes and the package lock * is released. These are typically more expensive or require calls to installd, which often * is released. These are typically more expensive or require calls to installd, which often * locks on {@link #mPackages}. * locks on {@link #mLock}. */ */ private void executePostCommitSteps(CommitRequest commitRequest) { private void executePostCommitSteps(CommitRequest commitRequest) { for (ReconciledPackage reconciledPkg : commitRequest.reconciledPackages.values()) { for (ReconciledPackage reconciledPkg : commitRequest.reconciledPackages.values()) { Loading Loading @@ -19872,11 +19872,11 @@ public class PackageManagerService extends IPackageManager.Stub return null; return null; } } /** <b>must not hold {@link #mPackages}</b> */ /** <b>must not hold {@link #mLock}</b> */ private void updateDefaultHomeNotLocked(SparseBooleanArray userIds) { private void updateDefaultHomeNotLocked(SparseBooleanArray userIds) { if (Thread.holdsLock(mLock)) { if (Thread.holdsLock(mLock)) { Slog.wtf(TAG, "Calling thread " + Thread.currentThread().getName() Slog.wtf(TAG, "Calling thread " + Thread.currentThread().getName() + " is holding mPackages", new Throwable()); + " is holding mLock", new Throwable()); } } for (int i = userIds.size() - 1; i >= 0; --i) { for (int i = userIds.size() - 1; i >= 0; --i) { final int userId = userIds.keyAt(i); final int userId = userIds.keyAt(i); Loading @@ -19885,14 +19885,14 @@ public class PackageManagerService extends IPackageManager.Stub } } /** /** * <b>must not hold {@link #mPackages}</b> * <b>must not hold {@link #mLock}</b> * * * @return Whether the ACTION_PREFERRED_ACTIVITY_CHANGED broadcast has been scheduled. * @return Whether the ACTION_PREFERRED_ACTIVITY_CHANGED broadcast has been scheduled. */ */ private boolean updateDefaultHomeNotLocked(int userId) { private boolean updateDefaultHomeNotLocked(int userId) { if (Thread.holdsLock(mLock)) { if (Thread.holdsLock(mLock)) { Slog.wtf(TAG, "Calling thread " + Thread.currentThread().getName() Slog.wtf(TAG, "Calling thread " + Thread.currentThread().getName() + " is holding mPackages", new Throwable()); + " is holding mLock", new Throwable()); } } if (!mSystemReady) { if (!mSystemReady) { // We might get called before system is ready because of package changes etc, but // We might get called before system is ready because of package changes etc, but Loading Loading @@ -21823,7 +21823,7 @@ public class PackageManagerService extends IPackageManager.Stub * will try recovering system apps by wiping data; third-party app data is * will try recovering system apps by wiping data; third-party app data is * left intact. * left intact. * <p> * <p> * <em>Note: To avoid a deadlock, do not call this method with {@code mPackages} lock held</em> * <em>Note: To avoid a deadlock, do not call this method with {@code mLock} lock held</em> */ */ private void prepareAppDataAfterInstallLIF(PackageParser.Package pkg) { private void prepareAppDataAfterInstallLIF(PackageParser.Package pkg) { final PackageSetting ps; final PackageSetting ps;