1 /*
2  * Copyright (C) 2020 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 package com.android.tradefed.result.error;
17 
18 import com.android.tradefed.result.proto.TestRecordProto.FailureStatus;
19 
20 import javax.annotation.Nonnull;
21 
22 /** Error Identifiers from Device errors and device reported errors. */
23 public enum DeviceErrorIdentifier implements ErrorIdentifier {
24 
25     // ********************************************************************************************
26     // Device Errors: 520_001 ~ 530_000
27     // ********************************************************************************************
28     APK_INSTALLATION_FAILED(520_001, FailureStatus.DEPENDENCY_ISSUE),
29     FAIL_ACTIVATE_APEX(520_002, FailureStatus.DEPENDENCY_ISSUE),
30     APEX_ROLLBACK_FAILED(520_003, FailureStatus.DEPENDENCY_ISSUE),
31     MAINLINE_MODULE_ROLLBACK_DETECTED(520_004, FailureStatus.DEPENDENCY_ISSUE),
32 
33     AAPT_PARSER_FAILED(520_050, FailureStatus.DEPENDENCY_ISSUE),
34 
35     SHELL_COMMAND_ERROR(520_100, FailureStatus.DEPENDENCY_ISSUE),
36     DEVICE_UNEXPECTED_RESPONSE(520_101, FailureStatus.DEPENDENCY_ISSUE),
37     FAIL_PUSH_FILE(520_102, FailureStatus.DEPENDENCY_ISSUE),
38     FAIL_PULL_FILE(520_103, FailureStatus.DEPENDENCY_ISSUE),
39     DEVICE_FAILED_TO_RESET(520_104, FailureStatus.DEPENDENCY_ISSUE),
40     DEVICE_FAILED_TO_REMOUNT(520_105, FailureStatus.DEPENDENCY_ISSUE),
41     DEVICE_FAILED_BLUETOOTH_PAIRING(520_106, FailureStatus.DEPENDENCY_ISSUE),
42     DEVICE_FAILED_TO_SNAPSHOT(520_107, FailureStatus.DEPENDENCY_ISSUE),
43     DEVICE_FAILED_TO_RESTORE_SNAPSHOT(520_108, FailureStatus.DEPENDENCY_ISSUE),
44     DEVICE_FAILED_TO_SUSPEND(520_109, FailureStatus.DEPENDENCY_ISSUE),
45     DEVICE_FAILED_TO_RESUME(520_110, FailureStatus.DEPENDENCY_ISSUE),
46     DEVICE_FAILED_TO_STOP(520_111, FailureStatus.DEPENDENCY_ISSUE),
47 
48     INSTRUMENTATION_CRASH(520_200, FailureStatus.SYSTEM_UNDER_TEST_CRASHED),
49     ADB_DISCONNECT(520_201, FailureStatus.DEPENDENCY_ISSUE),
50     INSTRUMENTATION_LOWMEMORYKILLER(520_202, FailureStatus.SYSTEM_UNDER_TEST_CRASHED),
51 
52     FAILED_TO_LAUNCH_GCE(520_500, FailureStatus.LOST_SYSTEM_UNDER_TEST),
53     FAILED_TO_CONNECT_TO_GCE(520_501, FailureStatus.LOST_SYSTEM_UNDER_TEST),
54     ERROR_AFTER_FLASHING(520_502, FailureStatus.LOST_SYSTEM_UNDER_TEST),
55     FAILED_TO_CONNECT_TO_TCP_DEVICE(520_503, FailureStatus.LOST_SYSTEM_UNDER_TEST),
56 
57     DEVICE_UNAVAILABLE(520_750, FailureStatus.LOST_SYSTEM_UNDER_TEST),
58     DEVICE_UNRESPONSIVE(520_751, FailureStatus.LOST_SYSTEM_UNDER_TEST),
59     DEVICE_CRASHED(520_752, FailureStatus.SYSTEM_UNDER_TEST_CRASHED),
60     UNEXPECTED_REBOOT(520_753, FailureStatus.SYSTEM_UNDER_TEST_CRASHED),
61     // Failures of the device action tool.
62     DEVICE_ACTION_EXECUTION_FAILURE(520_754, FailureStatus.DEPENDENCY_ISSUE);
63 
64     private final long code;
65     private final @Nonnull FailureStatus status;
66 
DeviceErrorIdentifier(int code, FailureStatus status)67     DeviceErrorIdentifier(int code, FailureStatus status) {
68         this.code = code;
69         this.status = (status == null ? FailureStatus.UNSET : status);
70     }
71 
72     @Override
code()73     public long code() {
74         return code;
75     }
76 
77     @Override
status()78     public @Nonnull FailureStatus status() {
79         return status;
80     }
81 }
82