Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit 2ae97bf0 authored by Automerger Merge Worker's avatar Automerger Merge Worker
Browse files

Merge "UpdateEngine: fix cleanupAppliedPayload impl" am: 54aba47b am: a339e2de am: 1c9a4667

Change-Id: Ifbdb141d6ef030c403b37cc257d2b4ab6178dd73
parents 5fdbed59 1c9a4667
Loading
Loading
Loading
Loading
+34 −1
Original line number Original line Diff line number Diff line
@@ -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
     * Cleanup files used by the previous update and free up space after the
     * device has been booted successfully into the new build.
     * device has been booted successfully into the new build.
@@ -590,8 +621,10 @@ public class UpdateEngine {
    @WorkerThread
    @WorkerThread
    @ErrorCode
    @ErrorCode
    public int cleanupAppliedPayload() {
    public int cleanupAppliedPayload() {
        CleanupAppliedPayloadCallback callback = new CleanupAppliedPayloadCallback();
        try {
        try {
            return mUpdateEngine.cleanupSuccessfulUpdate();
            mUpdateEngine.cleanupSuccessfulUpdate(callback);
            return callback.getResult();
        } catch (RemoteException e) {
        } catch (RemoteException e) {
            throw e.rethrowFromSystemServer();
            throw e.rethrowFromSystemServer();
        }
        }