diff options
author | 2020-02-19 21:23:07 -0800 | |
---|---|---|
committer | 2020-03-04 11:38:59 -0800 | |
commit | 8b0eedf99c66d98ca5b2dc7fb146ae32a758c426 (patch) | |
tree | 124c4d999f0099d07e833c7298480fddc482549b | |
parent | 31c94a2f0e7b7e87f94b9d28a691bce9b5b732f1 (diff) |
UpdateEngine: fix cleanupAppliedPayload impl
IUpdateEngine.cleanupSuccessfulUpdate is now asynchronous with a callback.
Update UpdateEngine.cleanupAppliedPayload accordingly to use the new impl.
Bug: 147696014
Test: apply OTA
Change-Id: I9b308316dcb8e6a507063d3060fed7693da82a19
-rw-r--r-- | core/java/android/os/UpdateEngine.java | 35 |
1 files changed, 34 insertions, 1 deletions
diff --git a/core/java/android/os/UpdateEngine.java b/core/java/android/os/UpdateEngine.java index 223f92054f79..de274c082c80 100644 --- a/core/java/android/os/UpdateEngine.java +++ b/core/java/android/os/UpdateEngine.java @@ -559,6 +559,37 @@ public class UpdateEngine { } } + private static class CleanupAppliedPayloadCallback extends IUpdateEngineCallback.Stub { + private int mErrorCode = ErrorCodeConstants.ERROR; + private boolean mCompleted = false; + private Object mLock = new Object(); + private int getResult() { + synchronized (mLock) { + while (!mCompleted) { + try { + mLock.wait(); + } catch (InterruptedException ex) { + // do nothing, just wait again. + } + } + return mErrorCode; + } + } + + @Override + public void onStatusUpdate(int status, float percent) { + } + + @Override + public void onPayloadApplicationComplete(int errorCode) { + synchronized (mLock) { + mErrorCode = errorCode; + mCompleted = true; + mLock.notifyAll(); + } + } + } + /** * Cleanup files used by the previous update and free up space after the * device has been booted successfully into the new build. @@ -590,8 +621,10 @@ public class UpdateEngine { @WorkerThread @ErrorCode public int cleanupAppliedPayload() { + CleanupAppliedPayloadCallback callback = new CleanupAppliedPayloadCallback(); try { - return mUpdateEngine.cleanupSuccessfulUpdate(); + mUpdateEngine.cleanupSuccessfulUpdate(callback); + return callback.getResult(); } catch (RemoteException e) { throw e.rethrowFromSystemServer(); } |