1 /*
2  * Copyright (C) 2023 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.android.phone.testapps.satellitetestapp;
18 
19 import static android.telephony.satellite.SatelliteManager.SATELLITE_RESULT_ACCESS_BARRED;
20 import static android.telephony.satellite.SatelliteManager.SATELLITE_RESULT_ERROR;
21 import static android.telephony.satellite.SatelliteManager.SATELLITE_RESULT_ILLEGAL_STATE;
22 import static android.telephony.satellite.SatelliteManager.SATELLITE_RESULT_INVALID_TELEPHONY_STATE;
23 import static android.telephony.satellite.SatelliteManager.SATELLITE_RESULT_MODEM_BUSY;
24 import static android.telephony.satellite.SatelliteManager.SATELLITE_RESULT_MODEM_ERROR;
25 import static android.telephony.satellite.SatelliteManager.SATELLITE_RESULT_NETWORK_ERROR;
26 import static android.telephony.satellite.SatelliteManager.SATELLITE_RESULT_NETWORK_TIMEOUT;
27 import static android.telephony.satellite.SatelliteManager.SATELLITE_RESULT_NOT_AUTHORIZED;
28 import static android.telephony.satellite.SatelliteManager.SATELLITE_RESULT_NOT_REACHABLE;
29 import static android.telephony.satellite.SatelliteManager.SATELLITE_RESULT_NOT_SUPPORTED;
30 import static android.telephony.satellite.SatelliteManager.SATELLITE_RESULT_NO_RESOURCES;
31 import static android.telephony.satellite.SatelliteManager.SATELLITE_RESULT_RADIO_NOT_AVAILABLE;
32 import static android.telephony.satellite.SatelliteManager.SATELLITE_RESULT_REQUEST_ABORTED;
33 import static android.telephony.satellite.SatelliteManager.SATELLITE_RESULT_REQUEST_FAILED;
34 import static android.telephony.satellite.SatelliteManager.SATELLITE_RESULT_REQUEST_IN_PROGRESS;
35 import static android.telephony.satellite.SatelliteManager.SATELLITE_RESULT_REQUEST_NOT_SUPPORTED;
36 import static android.telephony.satellite.SatelliteManager.SATELLITE_RESULT_SERVER_ERROR;
37 import static android.telephony.satellite.SatelliteManager.SATELLITE_RESULT_SERVICE_NOT_PROVISIONED;
38 import static android.telephony.satellite.SatelliteManager.SATELLITE_RESULT_SERVICE_PROVISION_IN_PROGRESS;
39 import static android.telephony.satellite.SatelliteManager.SATELLITE_RESULT_SUCCESS;
40 import static android.telephony.satellite.SatelliteManager.SATELLITE_RESULT_SERVICE_ERROR;
41 import static android.telephony.satellite.SatelliteManager.SATELLITE_RESULT_INVALID_MODEM_STATE;
42 import static android.telephony.satellite.SatelliteManager.SATELLITE_RESULT_INVALID_ARGUMENTS;
43 
44 import android.util.Log;
45 
46 /**
47  * Utils class for satellite error to display as string in SatelliteTestApp UI.
48  */
49 public class SatelliteErrorUtils {
50     private static final String TAG = "SatelliteErrorUtils";
51 
52    /**
53      * @param error int from the satellite manager.
54      * @return The converted SatelliteError for the testapp, result of the operation.
55      */
mapError(int error)56     public static String mapError(int error) {
57         switch (error) {
58             case SATELLITE_RESULT_SUCCESS:
59                 return "SATELLITE_RESULT_SUCCESS";
60             case SATELLITE_RESULT_ERROR:
61                 return "SATELLITE_RESULT_ERROR";
62             case SATELLITE_RESULT_SERVER_ERROR:
63                 return "SATELLITE_RESULT_SERVER_ERROR";
64             case SATELLITE_RESULT_SERVICE_ERROR:
65                 return "SATELLITE_RESULT_SERVICE_ERROR";
66             case SATELLITE_RESULT_MODEM_ERROR:
67                 return "SATELLITE_RESULT_MODEM_ERROR";
68             case SATELLITE_RESULT_NETWORK_ERROR:
69                 return "SATELLITE_RESULT_NETWORK_ERROR";
70             case SATELLITE_RESULT_INVALID_TELEPHONY_STATE:
71                 return "SATELLITE_RESULT_INVALID_TELEPHONY_STATE";
72             case SATELLITE_RESULT_INVALID_MODEM_STATE:
73                 return "SATELLITE_RESULT_INVALID_MODEM_STATE";
74             case SATELLITE_RESULT_INVALID_ARGUMENTS:
75                 return "SATELLITE_RESULT_INVALID_ARGUMENTS";
76             case SATELLITE_RESULT_REQUEST_FAILED:
77                 return "SATELLITE_RESULT_REQUEST_FAILED";
78             case SATELLITE_RESULT_RADIO_NOT_AVAILABLE:
79                 return "SATELLITE_RESULT_RADIO_NOT_AVAILABLE";
80             case SATELLITE_RESULT_REQUEST_NOT_SUPPORTED:
81                 return "SATELLITE_RESULT_REQUEST_NOT_SUPPORTED";
82             case SATELLITE_RESULT_NO_RESOURCES:
83                 return "SATELLITE_RESULT_NO_RESOURCES";
84             case SATELLITE_RESULT_SERVICE_NOT_PROVISIONED:
85                 return "SATELLITE_RESULT_SERVICE_NOT_PROVISIONED";
86             case SATELLITE_RESULT_SERVICE_PROVISION_IN_PROGRESS:
87                 return "SATELLITE_RESULT_SERVICE_PROVISION_IN_PROGRESS";
88             case SATELLITE_RESULT_REQUEST_ABORTED:
89                 return "SATELLITE_RESULT_REQUEST_ABORTED";
90             case SATELLITE_RESULT_ACCESS_BARRED:
91                 return "SATELLITE_RESULT_ACCESS_BARRED";
92             case SATELLITE_RESULT_NETWORK_TIMEOUT:
93                 return "SATELLITE_RESULT_NETWORK_TIMEOUT";
94             case SATELLITE_RESULT_NOT_REACHABLE:
95                 return "SATELLITE_RESULT_NOT_REACHABLE";
96             case SATELLITE_RESULT_NOT_AUTHORIZED:
97                 return "SATELLITE_RESULT_NOT_AUTHORIZED";
98             case SATELLITE_RESULT_NOT_SUPPORTED:
99                 return "SATELLITE_RESULT_NOT_SUPPORTED";
100             case SATELLITE_RESULT_REQUEST_IN_PROGRESS:
101                 return "SATELLITE_RESULT_REQUEST_IN_PROGRESS";
102             case SATELLITE_RESULT_MODEM_BUSY:
103                 return "SATELLITE_RESULT_MODEM_BUSY";
104             case SATELLITE_RESULT_ILLEGAL_STATE:
105                 return "SATELLITE_RESULT_ILLEGAL_STATE";
106         }
107         Log.d(TAG, "Received invalid satellite service error: " + error);
108         return "SATELLITE_RESULT_SERVICE_ERROR";
109     }
110 }
111