1 /* 2 * Copyright (C) 2018 The Android Open Source Project 3 * 4 * Licensed under the Apache License, Version 2.0 (the "License"); 5 * you may not use this file except in compliance with the License. 6 * You may obtain a copy of the License at 7 * 8 * http://www.apache.org/licenses/LICENSE-2.0 9 * 10 * Unless required by applicable law or agreed to in writing, software 11 * distributed under the License is distributed on an "AS IS" BASIS, 12 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 * See the License for the specific language governing permissions and 14 * limitations under the License. 15 */ 16 17 package com.example.android.systemupdatersample.util; 18 19 import android.util.SparseArray; 20 21 /** 22 * Helper class to work with update_engine's error codes. 23 * Many error codes are defined in {@code UpdateEngine.UpdateStatusConstants}, 24 * but you can find more in system/update_engine/common/error_code.h. 25 */ 26 public final class UpdateEngineStatuses { 27 28 private static final SparseArray<String> STATUS_MAP = new SparseArray<>(); 29 30 static { 31 STATUS_MAP.put(0, "IDLE"); 32 STATUS_MAP.put(1, "CHECKING_FOR_UPDATE"); 33 STATUS_MAP.put(2, "UPDATE_AVAILABLE"); 34 STATUS_MAP.put(3, "DOWNLOADING"); 35 STATUS_MAP.put(4, "VERIFYING"); 36 STATUS_MAP.put(5, "FINALIZING"); 37 STATUS_MAP.put(6, "UPDATED_NEED_REBOOT"); 38 STATUS_MAP.put(7, "REPORTING_ERROR_EVENT"); 39 STATUS_MAP.put(8, "ATTEMPTING_ROLLBACK"); 40 STATUS_MAP.put(9, "DISABLED"); 41 } 42 43 /** 44 * converts status code to status name 45 */ 46 public static String getStatusText(int status) { 47 return STATUS_MAP.get(status); 48 } 49 50 private UpdateEngineStatuses() {} 51 } 52