Merge "Remove subtle dependencies" into nyc-mr1-dev

This commit is contained in:
TreeHugger Robot
2016-07-13 22:55:35 +00:00
committed by Android (Google) Code Review

View File

@@ -182,6 +182,10 @@ public class PackageInstallerService extends IPackageInstaller.Stub {
*/ */
private final Random mRandom = new SecureRandom(); private final Random mRandom = new SecureRandom();
/** All sessions allocated */
@GuardedBy("mSessions")
private final SparseBooleanArray mAllocatedSessions = new SparseBooleanArray();
@GuardedBy("mSessions") @GuardedBy("mSessions")
private final SparseArray<PackageInstallerSession> mSessions = new SparseArray<>(); private final SparseArray<PackageInstallerSession> mSessions = new SparseArray<>();
@@ -365,6 +369,7 @@ public class PackageInstallerService extends IPackageInstaller.Stub {
// keep details around for dumpsys. // keep details around for dumpsys.
mHistoricalSessions.put(session.sessionId, session); mHistoricalSessions.put(session.sessionId, session);
} }
mAllocatedSessions.put(session.sessionId, true);
} }
} }
} }
@@ -768,8 +773,8 @@ public class PackageInstallerService extends IPackageInstaller.Stub {
int sessionId; int sessionId;
do { do {
sessionId = mRandom.nextInt(Integer.MAX_VALUE - 1) + 1; sessionId = mRandom.nextInt(Integer.MAX_VALUE - 1) + 1;
if (mSessions.get(sessionId) == null && mHistoricalSessions.get(sessionId) == null if (!mAllocatedSessions.get(sessionId, false)) {
&& !mLegacySessions.get(sessionId, false)) { mAllocatedSessions.put(sessionId, true);
return sessionId; return sessionId;
} }
} while (n++ < 32); } while (n++ < 32);