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

Commit 8e48e6d9 authored by Yifan Hong's avatar Yifan Hong
Browse files

Add @ErrorCode annotation to UpdateEngine APIs

Test: TH

Change-Id: I3016132454ea38d2eaf69b907c726f46b2608509
parent 2ce03276
Loading
Loading
Loading
Loading
+24 −1
Original line number Original line Diff line number Diff line
@@ -16,6 +16,7 @@


package android.os;
package android.os;


import android.annotation.IntDef;
import android.annotation.NonNull;
import android.annotation.NonNull;
import android.annotation.SystemApi;
import android.annotation.SystemApi;
import android.os.IUpdateEngine;
import android.os.IUpdateEngine;
@@ -157,6 +158,26 @@ public class UpdateEngine {
        public static final int DEVICE_CORRUPTED = 61;
        public static final int DEVICE_CORRUPTED = 61;
    }
    }


    /** @hide */
    @IntDef(value = {
            ErrorCodeConstants.SUCCESS,
            ErrorCodeConstants.ERROR,
            ErrorCodeConstants.FILESYSTEM_COPIER_ERROR,
            ErrorCodeConstants.POST_INSTALL_RUNNER_ERROR,
            ErrorCodeConstants.PAYLOAD_MISMATCHED_TYPE_ERROR,
            ErrorCodeConstants.INSTALL_DEVICE_OPEN_ERROR,
            ErrorCodeConstants.KERNEL_DEVICE_OPEN_ERROR,
            ErrorCodeConstants.DOWNLOAD_TRANSFER_ERROR,
            ErrorCodeConstants.PAYLOAD_HASH_MISMATCH_ERROR,
            ErrorCodeConstants.PAYLOAD_SIZE_MISMATCH_ERROR,
            ErrorCodeConstants.DOWNLOAD_PAYLOAD_VERIFICATION_ERROR,
            ErrorCodeConstants.PAYLOAD_TIMESTAMP_ERROR,
            ErrorCodeConstants.UPDATED_BUT_NOT_ACTIVE,
            ErrorCodeConstants.NOT_ENOUGH_SPACE,
            ErrorCodeConstants.DEVICE_CORRUPTED,
    })
    public @interface ErrorCode {}

    /**
    /**
     * Status codes for update engine. Values must agree with the ones in
     * Status codes for update engine. Values must agree with the ones in
     * {@code system/update_engine/client_library/include/update_engine/update_status.h}.
     * {@code system/update_engine/client_library/include/update_engine/update_status.h}.
@@ -439,7 +460,7 @@ public class UpdateEngine {
     * Return value of {@link #allocateSpace.}
     * Return value of {@link #allocateSpace.}
     */
     */
    public static final class AllocateSpaceResult {
    public static final class AllocateSpaceResult {
        private int mErrorCode = ErrorCodeConstants.SUCCESS;
        private @ErrorCode int mErrorCode = ErrorCodeConstants.SUCCESS;
        private long mFreeSpaceRequired = 0;
        private long mFreeSpaceRequired = 0;
        private AllocateSpaceResult() {}
        private AllocateSpaceResult() {}
        /**
        /**
@@ -454,6 +475,7 @@ public class UpdateEngine {
         * <li>Other {@link ErrorCodeConstants} for other errors.</li>
         * <li>Other {@link ErrorCodeConstants} for other errors.</li>
         * </ul>
         * </ul>
         */
         */
        @ErrorCode
        public int errorCode() {
        public int errorCode() {
            return mErrorCode;
            return mErrorCode;
        }
        }
@@ -559,6 +581,7 @@ public class UpdateEngine {
     * @throws ServiceSpecificException if other transient errors has occurred.
     * @throws ServiceSpecificException if other transient errors has occurred.
     * A reboot may or may not help resolving the issue.
     * A reboot may or may not help resolving the issue.
     */
     */
    @ErrorCode
    public int cleanupAppliedPayload() {
    public int cleanupAppliedPayload() {
        try {
        try {
            return mUpdateEngine.cleanupSuccessfulUpdate();
            return mUpdateEngine.cleanupSuccessfulUpdate();