Loading services/backup/java/com/android/server/backup/BackupManagerService.java +6 −7 Original line number Diff line number Diff line Loading @@ -698,6 +698,7 @@ public class BackupManagerService implements BackupManagerServiceInterface { final SparseArray<Operation> mCurrentOperations = new SparseArray<Operation>(); final Object mCurrentOpLock = new Object(); final Random mTokenGenerator = new Random(); final AtomicInteger mNextToken = new AtomicInteger(); final SparseArray<AdbParams> mAdbBackupRestoreConfirmations = new SparseArray<AdbParams>(); Loading Loading @@ -770,15 +771,13 @@ public class BackupManagerService implements BackupManagerServiceInterface { @GuardedBy("mQueueLock") ArrayList<FullBackupEntry> mFullBackupQueue; // Utility: build a new random integer token // Utility: build a new random integer token. The low bits are the ordinal of the // operation for near-time uniqueness, and the upper bits are random for app- // side unpredictability. @Override public int generateRandomIntegerToken() { int token; do { synchronized (mTokenGenerator) { token = mTokenGenerator.nextInt(); } } while (token < 0); int token = mTokenGenerator.nextInt() & ~0xFF; token |= (mNextToken.incrementAndGet() & 0xFF); return token; } Loading Loading
services/backup/java/com/android/server/backup/BackupManagerService.java +6 −7 Original line number Diff line number Diff line Loading @@ -698,6 +698,7 @@ public class BackupManagerService implements BackupManagerServiceInterface { final SparseArray<Operation> mCurrentOperations = new SparseArray<Operation>(); final Object mCurrentOpLock = new Object(); final Random mTokenGenerator = new Random(); final AtomicInteger mNextToken = new AtomicInteger(); final SparseArray<AdbParams> mAdbBackupRestoreConfirmations = new SparseArray<AdbParams>(); Loading Loading @@ -770,15 +771,13 @@ public class BackupManagerService implements BackupManagerServiceInterface { @GuardedBy("mQueueLock") ArrayList<FullBackupEntry> mFullBackupQueue; // Utility: build a new random integer token // Utility: build a new random integer token. The low bits are the ordinal of the // operation for near-time uniqueness, and the upper bits are random for app- // side unpredictability. @Override public int generateRandomIntegerToken() { int token; do { synchronized (mTokenGenerator) { token = mTokenGenerator.nextInt(); } } while (token < 0); int token = mTokenGenerator.nextInt() & ~0xFF; token |= (mNextToken.incrementAndGet() & 0xFF); return token; } Loading