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

Commit 598225ae authored by Tao Bao's avatar Tao Bao Committed by Android (Google) Code Review
Browse files

Merge "UpdateEngine: Expose unbind as system API."

parents 1e249aea 445c304f
Loading
Loading
Loading
Loading
+1 −0
Original line number Diff line number Diff line
@@ -34501,6 +34501,7 @@ package android.os {
    method public void resetStatus();
    method public void resume();
    method public void suspend();
    method public boolean unbind();
  }
  public static final class UpdateEngine.ErrorCodeConstants {
+53 −32
Original line number Diff line number Diff line
@@ -21,8 +21,6 @@ import android.os.IUpdateEngine;
import android.os.IUpdateEngineCallback;
import android.os.RemoteException;

import android.util.Log;

/**
 * UpdateEngine handles calls to the update engine which takes care of A/B OTA
 * updates. It wraps up the update engine Binder APIs and exposes them as
@@ -90,6 +88,8 @@ public class UpdateEngine {
    }

    private IUpdateEngine mUpdateEngine;
    private IUpdateEngineCallback mUpdateEngineCallback = null;
    private final Object mUpdateEngineCallbackLock = new Object();

    /**
     * Creates a new instance.
@@ -107,7 +107,8 @@ public class UpdateEngine {
     */
    @SystemApi
    public boolean bind(final UpdateEngineCallback callback, final Handler handler) {
        IUpdateEngineCallback updateEngineCallback = new IUpdateEngineCallback.Stub() {
        synchronized (mUpdateEngineCallbackLock) {
            mUpdateEngineCallback = new IUpdateEngineCallback.Stub() {
                @Override
                public void onStatusUpdate(final int status, final float percent) {
                    if (handler != null) {
@@ -138,11 +139,12 @@ public class UpdateEngine {
            };

            try {
            return mUpdateEngine.bind(updateEngineCallback);
                return mUpdateEngine.bind(mUpdateEngineCallback);
            } catch (RemoteException e) {
                throw e.rethrowFromSystemServer();
            }
        }
    }

    /**
     * Equivalent to {@code bind(callback, null)}.
@@ -249,4 +251,23 @@ public class UpdateEngine {
            throw e.rethrowFromSystemServer();
        }
    }

    /**
     * Unbinds the last bound callback function.
     */
    @SystemApi
    public boolean unbind() {
        synchronized (mUpdateEngineCallbackLock) {
            if (mUpdateEngineCallback == null) {
                return true;
            }
            try {
                boolean result = mUpdateEngine.unbind(mUpdateEngineCallback);
                mUpdateEngineCallback = null;
                return result;
            } catch (RemoteException e) {
                throw e.rethrowFromSystemServer();
            }
        }
    }
}