diff options
author | 2020-03-05 22:57:08 +0000 | |
---|---|---|
committer | 2020-03-05 22:57:08 +0000 | |
commit | 47af8f93b80d18d80907be7006888f464fcd30d5 (patch) | |
tree | 6d8edfef1b97d594b74ec100be266aed6c955712 | |
parent | e3c130ac0e481e375ccb46fae33d9e31255c2f73 (diff) | |
parent | 8b0eedf99c66d98ca5b2dc7fb146ae32a758c426 (diff) |
Merge "UpdateEngine: fix cleanupAppliedPayload impl" into rvc-dev
-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(); } |