• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1 /*
2  * Copyright (C) 2015 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 android.hardware.multiprocess.camera.cts;
17 
18 /**
19  * Constants used throughout the multi-process unit tests.
20  */
21 public class TestConstants {
22 
23     public static final int EVENT_CAMERA_ERROR = -1;
24     public static final int EVENT_CAMERA_CONNECT = 1;
25     public static final int EVENT_CAMERA_EVICTED = 2;
26     public static final int EVENT_CAMERA_AVAILABLE = 3;
27     public static final int EVENT_CAMERA_UNAVAILABLE = 4;
28     public static final int EVENT_ACTIVITY_RESUMED = 5;
29 
30     public static final String EVENT_CAMERA_ERROR_STR = "error";
31     public static final String EVENT_CAMERA_CONNECT_STR = "connect";
32     public static final String EVENT_CAMERA_EVICTED_STR = "evicted";
33     public static final String EVENT_CAMERA_AVAILABLE_STR = "available";
34     public static final String EVENT_CAMERA_UNAVAILABLE_STR = "unavailable";
35     public static final String EVENT_ACTIVITY_RESUMED_STR = "resumed";
36 
37     public static final String EVENT_CAMERA_UNKNOWN_STR = "unknown";
38 
39     /**
40      * Convert the given error code to a string.
41      *
42      * @param err error code from {@link TestConstants}.
43      * @return string for this error code.
44      */
errToStr(int err)45     public static String errToStr(int err) {
46         switch(err) {
47             case EVENT_CAMERA_ERROR:
48                 return EVENT_CAMERA_ERROR_STR;
49             case EVENT_CAMERA_CONNECT:
50                 return EVENT_CAMERA_CONNECT_STR;
51             case EVENT_CAMERA_EVICTED:
52                 return EVENT_CAMERA_EVICTED_STR;
53             case EVENT_CAMERA_AVAILABLE:
54                 return EVENT_CAMERA_AVAILABLE_STR;
55             case EVENT_CAMERA_UNAVAILABLE:
56                 return EVENT_CAMERA_UNAVAILABLE_STR;
57             case EVENT_ACTIVITY_RESUMED:
58                 return EVENT_ACTIVITY_RESUMED_STR;
59             default:
60                 return EVENT_CAMERA_UNKNOWN_STR + " " + err;
61         }
62     }
63 
64     /**
65      * Convert the given array of error codes to an array of strings.
66      *
67      * @param err array of error codes from {@link TestConstants}.
68      * @return string array for the given error codes.
69      */
convertToStringArray(int[] err)70     public static String[] convertToStringArray(int[] err) {
71         if (err == null) return null;
72         String[] ret = new String[err.length];
73         for (int i = 0; i < err.length; i++) {
74             ret[i] = errToStr(err[i]);
75         }
76         return ret;
77     }
78 
79 }
80