Loading core/java/android/content/rollback/RollbackManager.java +4 −1 Original line number Diff line number Diff line Loading @@ -74,7 +74,10 @@ public final class RollbackManager { } /** * Returns a list of all currently available rollbacks. * Returns a list of all currently available rollbacks. This includes ones for very recently * installed packages (even if onFinished has not yet been called). As a result, packages that * very recently failed to install may also be included, but those rollbacks will fail with * 'rollback not available'. * * @throws SecurityException if the caller does not have appropriate permissions. */ Loading services/core/java/com/android/server/rollback/RollbackManagerServiceImpl.java +17 −24 Original line number Diff line number Diff line Loading @@ -271,33 +271,9 @@ class RollbackManagerServiceImpl extends IRollbackManager.Stub { }, filter, null, getHandler()); } /** * This method posts a blocking call to the handler thread, so it should not be called from * that same thread. * @throws {@link IllegalStateException} if called from {@link #mHandlerThread} */ @Override public ParceledListSlice getAvailableRollbacks() { enforceManageRollbacks("getAvailableRollbacks"); if (Thread.currentThread().equals(mHandlerThread)) { Slog.wtf(TAG, "Calling getAvailableRollbacks from mHandlerThread " + "causes a deadlock"); throw new IllegalStateException("Cannot call RollbackManager#getAvailableRollbacks " + "from the handler thread!"); } // Wait for the handler thread to get the list of available rollbacks // to get the most up-to-date results. This is intended to reduce test // flakiness when checking available rollbacks immediately after // installing a package with rollback enabled. CountDownLatch latch = new CountDownLatch(1); getHandler().post(() -> latch.countDown()); try { latch.await(); } catch (InterruptedException ie) { throw new IllegalStateException("RollbackManagerHandlerThread interrupted"); } synchronized (mLock) { List<RollbackInfo> rollbacks = new ArrayList<>(); for (int i = 0; i < mRollbacks.size(); ++i) { Loading @@ -306,6 +282,15 @@ class RollbackManagerServiceImpl extends IRollbackManager.Stub { rollbacks.add(rollback.info); } } // Also return new rollbacks for which the PackageRollbackInfo is complete. for (NewRollback newRollback : mNewRollbacks) { if (newRollback.rollback.info.getPackages().size() == newRollback.packageSessionIds.length && !newRollback.isCancelled) { rollbacks.add(newRollback.rollback.info); } } return new ParceledListSlice<>(rollbacks); } } Loading Loading @@ -562,6 +547,14 @@ class RollbackManagerServiceImpl extends IRollbackManager.Stub { } } } for (NewRollback newRollback : mNewRollbacks) { for (PackageRollbackInfo info : newRollback.rollback.info.getPackages()) { if (info.getPackageName().equals(packageName)) { newRollback.isCancelled = true; break; } } } } } Loading Loading
core/java/android/content/rollback/RollbackManager.java +4 −1 Original line number Diff line number Diff line Loading @@ -74,7 +74,10 @@ public final class RollbackManager { } /** * Returns a list of all currently available rollbacks. * Returns a list of all currently available rollbacks. This includes ones for very recently * installed packages (even if onFinished has not yet been called). As a result, packages that * very recently failed to install may also be included, but those rollbacks will fail with * 'rollback not available'. * * @throws SecurityException if the caller does not have appropriate permissions. */ Loading
services/core/java/com/android/server/rollback/RollbackManagerServiceImpl.java +17 −24 Original line number Diff line number Diff line Loading @@ -271,33 +271,9 @@ class RollbackManagerServiceImpl extends IRollbackManager.Stub { }, filter, null, getHandler()); } /** * This method posts a blocking call to the handler thread, so it should not be called from * that same thread. * @throws {@link IllegalStateException} if called from {@link #mHandlerThread} */ @Override public ParceledListSlice getAvailableRollbacks() { enforceManageRollbacks("getAvailableRollbacks"); if (Thread.currentThread().equals(mHandlerThread)) { Slog.wtf(TAG, "Calling getAvailableRollbacks from mHandlerThread " + "causes a deadlock"); throw new IllegalStateException("Cannot call RollbackManager#getAvailableRollbacks " + "from the handler thread!"); } // Wait for the handler thread to get the list of available rollbacks // to get the most up-to-date results. This is intended to reduce test // flakiness when checking available rollbacks immediately after // installing a package with rollback enabled. CountDownLatch latch = new CountDownLatch(1); getHandler().post(() -> latch.countDown()); try { latch.await(); } catch (InterruptedException ie) { throw new IllegalStateException("RollbackManagerHandlerThread interrupted"); } synchronized (mLock) { List<RollbackInfo> rollbacks = new ArrayList<>(); for (int i = 0; i < mRollbacks.size(); ++i) { Loading @@ -306,6 +282,15 @@ class RollbackManagerServiceImpl extends IRollbackManager.Stub { rollbacks.add(rollback.info); } } // Also return new rollbacks for which the PackageRollbackInfo is complete. for (NewRollback newRollback : mNewRollbacks) { if (newRollback.rollback.info.getPackages().size() == newRollback.packageSessionIds.length && !newRollback.isCancelled) { rollbacks.add(newRollback.rollback.info); } } return new ParceledListSlice<>(rollbacks); } } Loading Loading @@ -562,6 +547,14 @@ class RollbackManagerServiceImpl extends IRollbackManager.Stub { } } } for (NewRollback newRollback : mNewRollbacks) { for (PackageRollbackInfo info : newRollback.rollback.info.getPackages()) { if (info.getPackageName().equals(packageName)) { newRollback.isCancelled = true; break; } } } } } Loading