1 /*
2  * Copyright (C) 2019 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.google.android.car.bugreport;
17 
18 /** Defines {@link MetaBugReport} statuses. */
19 public enum Status {
20     // Bugreport is being written
21     STATUS_WRITE_PENDING(0),
22 
23     // Writing bugreport failed
24     STATUS_WRITE_FAILED(1),
25 
26     // Bugreport is waiting to be uploaded
27     STATUS_UPLOAD_PENDING(2),
28 
29     // Bugreport uploaded successfully
30     STATUS_UPLOAD_SUCCESS(3),
31 
32     // Bugreport failed to upload
33     STATUS_UPLOAD_FAILED(4),
34 
35     // Bugreport is cancelled by user
36     STATUS_USER_CANCELLED(5),
37 
38     // Bugreport is pending user choice on whether to upload or copy.
39     STATUS_PENDING_USER_ACTION(6),
40 
41     // Bugreport was moved successfully.
42     STATUS_MOVE_SUCCESSFUL(7),
43 
44     // Bugreport move has failed.
45     STATUS_MOVE_FAILED(8),
46 
47     // Bugreport is moving to USB drive.
48     STATUS_MOVE_IN_PROGRESS(9),
49 
50     // Bugreport is expired. Associated file is deleted from the disk.
51     STATUS_EXPIRED(10),
52 
53     // Bugreport needs audio message.
54     STATUS_AUDIO_PENDING(11);
55 
56     private final int mValue;
57 
Status(int value)58     Status(int value) {
59         mValue = value;
60     }
61 
62     /** Returns integer value of the status. */
getValue()63     public int getValue() {
64         return mValue;
65     }
66 
67     /** Generates human-readable string from a status value. */
toString(int value)68     public static String toString(int value) {
69         switch (value) {
70             case 0:
71                 return "Write pending";
72             case 1:
73                 return "Write failed";
74             case 2:
75                 return "Upload pending";
76             case 3:
77                 return "Upload successful";
78             case 4:
79                 return "Upload failed";
80             case 5:
81                 return "User cancelled";
82             case 6:
83                 return "Pending user action";
84             case 7:
85                 return "Move successful";
86             case 8:
87                 return "Move failed";
88             case 9:
89                 return "Move in progress";
90             case 10:
91                 return "Expired";
92             case 11:
93                 return "Audio message pending";
94         }
95         return "unknown";
96     }
97 }
98