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 public static final int EVENT_ACTIVITY_PAUSED = 6; 30 public static final int EVENT_CAMERA_ACCESS_PRIORITIES_CHANGED = 7; 31 public static final int EVENT_ACTIVITY_TOP_RESUMED_TRUE = 8; 32 public static final int EVENT_ACTIVITY_TOP_RESUMED_FALSE = 9; 33 34 public static final String EVENT_CAMERA_ERROR_STR = "error"; 35 public static final String EVENT_CAMERA_CONNECT_STR = "connect"; 36 public static final String EVENT_CAMERA_EVICTED_STR = "evicted"; 37 public static final String EVENT_CAMERA_AVAILABLE_STR = "available"; 38 public static final String EVENT_CAMERA_UNAVAILABLE_STR = "unavailable"; 39 public static final String EVENT_ACTIVITY_RESUMED_STR = "resumed"; 40 public static final String EVENT_ACTIVITY_PAUSED_STR = "paused"; 41 public static final String EVENT_CAMERA_ACCESS_PRIORITIES_CHANGED_STR = 42 "onCameraAccessPrioritiesChanged"; 43 public static final String EVENT_ACTIVITY_TOP_RESUMED_TRUE_STR = "topResumedTrue"; 44 public static final String EVENT_ACTIVITY_TOP_RESUMED_FALSE_STR = "topResumedFalse"; 45 46 public static final String EVENT_CAMERA_UNKNOWN_STR = "unknown"; 47 48 public static final String EXTRA_IGNORE_CAMERA_ACCESS = "ignoreCameraAccess"; 49 public static final String EXTRA_IGNORE_TOP_ACTIVITY_RESUMED = "ignoreTopActivityResumed"; 50 public static final String EXTRA_IGNORE_ACTIVITY_PAUSED = "ignoreActivityPaused"; 51 52 /** 53 * Convert the given error code to a string. 54 * 55 * @param err error code from {@link TestConstants}. 56 * @return string for this error code. 57 */ errToStr(int err)58 public static String errToStr(int err) { 59 switch(err) { 60 case EVENT_CAMERA_ERROR: 61 return EVENT_CAMERA_ERROR_STR; 62 case EVENT_CAMERA_CONNECT: 63 return EVENT_CAMERA_CONNECT_STR; 64 case EVENT_CAMERA_EVICTED: 65 return EVENT_CAMERA_EVICTED_STR; 66 case EVENT_CAMERA_AVAILABLE: 67 return EVENT_CAMERA_AVAILABLE_STR; 68 case EVENT_CAMERA_UNAVAILABLE: 69 return EVENT_CAMERA_UNAVAILABLE_STR; 70 case EVENT_ACTIVITY_RESUMED: 71 return EVENT_ACTIVITY_RESUMED_STR; 72 case EVENT_ACTIVITY_PAUSED: 73 return EVENT_ACTIVITY_PAUSED_STR; 74 case EVENT_CAMERA_ACCESS_PRIORITIES_CHANGED: 75 return EVENT_CAMERA_ACCESS_PRIORITIES_CHANGED_STR; 76 case EVENT_ACTIVITY_TOP_RESUMED_TRUE: 77 return EVENT_ACTIVITY_TOP_RESUMED_TRUE_STR; 78 case EVENT_ACTIVITY_TOP_RESUMED_FALSE: 79 return EVENT_ACTIVITY_TOP_RESUMED_FALSE_STR; 80 default: 81 return EVENT_CAMERA_UNKNOWN_STR + " " + err; 82 } 83 } 84 85 /** 86 * Convert the given array of error codes to an array of strings. 87 * 88 * @param err array of error codes from {@link TestConstants}. 89 * @return string array for the given error codes. 90 */ convertToStringArray(int[] err)91 public static String[] convertToStringArray(int[] err) { 92 if (err == null) return null; 93 String[] ret = new String[err.length]; 94 for (int i = 0; i < err.length; i++) { 95 ret[i] = errToStr(err[i]); 96 } 97 return ret; 98 } 99 100 } 101