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 public static final int EVENT_CAMERA_CONNECT_SHARED_PRIMARY = 10; 34 public static final int EVENT_CAMERA_CONNECT_SHARED_SECONDARY = 11; 35 public static final int EVENT_CLIENT_ACCESS_PRIORITIES_CHANGED_TO_PRIMARY = 12; 36 public static final int EVENT_CLIENT_ACCESS_PRIORITIES_CHANGED_TO_SECONDARY = 13; 37 public static final int EVENT_CAMERA_CLOSED = 14; 38 public static final int EVENT_CAMERA_DISCONNECTED = 15; 39 public static final int EVENT_CAMERA_SESSION_CONFIGURED = 16; 40 public static final int EVENT_CAMERA_SESSION_CONFIGURE_FAILED = 17; 41 public static final int EVENT_CAMERA_SESSION_CLOSED = 18; 42 public static final int EVENT_CAMERA_PREVIEW_STARTED = 19; 43 public static final int EVENT_CAMERA_PREVIEW_COMPLETED = 20; 44 public static final int EVENT_CAMERA_UNSUPPORTED_ACTIVITY_STARTED = 21; 45 public static final int EVENT_CAMERA_UNSUPPORTED_ACTIVITY_FAILED = 22; 46 47 public static final int OP_OPEN_CAMERA = 100; 48 public static final int OP_OPEN_CAMERA_SHARED = 101; 49 public static final int OP_CLOSE_CAMERA = 102; 50 public static final int OP_CREATE_SHARED_SESSION = 103; 51 public static final int OP_START_PREVIEW = 104; 52 public static final int OP_STOP_PREVIEW = 105; 53 public static final int OP_CREATE_SHARED_SESSION_INVALID_CONFIGS = 106; 54 public static final int OP_PERFORM_UNSUPPORTED_COMMANDS = 107; 55 public static final int OP_PERFORM_UNSUPPORTED_CAPTURE_SESSION_COMMANDS = 108; 56 57 public static final String EVENT_CAMERA_ERROR_STR = "error"; 58 public static final String EVENT_CAMERA_CONNECT_STR = "connect"; 59 public static final String EVENT_CAMERA_EVICTED_STR = "evicted"; 60 public static final String EVENT_CAMERA_AVAILABLE_STR = "available"; 61 public static final String EVENT_CAMERA_UNAVAILABLE_STR = "unavailable"; 62 public static final String EVENT_ACTIVITY_RESUMED_STR = "resumed"; 63 public static final String EVENT_ACTIVITY_PAUSED_STR = "paused"; 64 public static final String EVENT_CAMERA_ACCESS_PRIORITIES_CHANGED_STR = 65 "onCameraAccessPrioritiesChanged"; 66 public static final String EVENT_ACTIVITY_TOP_RESUMED_TRUE_STR = "topResumedTrue"; 67 public static final String EVENT_ACTIVITY_TOP_RESUMED_FALSE_STR = "topResumedFalse"; 68 69 public static final String EVENT_CAMERA_UNKNOWN_STR = "unknown"; 70 71 public static final String EXTRA_IGNORE_CAMERA_ACCESS = "ignoreCameraAccess"; 72 public static final String EXTRA_IGNORE_TOP_ACTIVITY_RESUMED = "ignoreTopActivityResumed"; 73 public static final String EXTRA_IGNORE_ACTIVITY_PAUSED = "ignoreActivityPaused"; 74 public static final String EXTRA_CAMERA_ID = "cameraId"; 75 public static final String EXTRA_RESULT_RECEIVER = "resultReceiver"; 76 public static final String EXTRA_REMOTE_MESSENGER = "remoteMessenger"; 77 public static final String EXTRA_SHARED_STREAM_ARRAY = "sharedStreamArray"; 78 79 public static final Integer SURFACE_TYPE_SURFACE_VIEW = 0; 80 public static final Integer SURFACE_TYPE_IMAGE_READER = 4; 81 82 /** 83 * Convert the given error code to a string. 84 * 85 * @param err error code from {@link TestConstants}. 86 * @return string for this error code. 87 */ errToStr(int err)88 public static String errToStr(int err) { 89 switch(err) { 90 case EVENT_CAMERA_ERROR: 91 return EVENT_CAMERA_ERROR_STR; 92 case EVENT_CAMERA_CONNECT: 93 return EVENT_CAMERA_CONNECT_STR; 94 case EVENT_CAMERA_EVICTED: 95 return EVENT_CAMERA_EVICTED_STR; 96 case EVENT_CAMERA_AVAILABLE: 97 return EVENT_CAMERA_AVAILABLE_STR; 98 case EVENT_CAMERA_UNAVAILABLE: 99 return EVENT_CAMERA_UNAVAILABLE_STR; 100 case EVENT_ACTIVITY_RESUMED: 101 return EVENT_ACTIVITY_RESUMED_STR; 102 case EVENT_ACTIVITY_PAUSED: 103 return EVENT_ACTIVITY_PAUSED_STR; 104 case EVENT_CAMERA_ACCESS_PRIORITIES_CHANGED: 105 return EVENT_CAMERA_ACCESS_PRIORITIES_CHANGED_STR; 106 case EVENT_ACTIVITY_TOP_RESUMED_TRUE: 107 return EVENT_ACTIVITY_TOP_RESUMED_TRUE_STR; 108 case EVENT_ACTIVITY_TOP_RESUMED_FALSE: 109 return EVENT_ACTIVITY_TOP_RESUMED_FALSE_STR; 110 default: 111 return EVENT_CAMERA_UNKNOWN_STR + " " + err; 112 } 113 } 114 115 /** 116 * Convert the given array of error codes to an array of strings. 117 * 118 * @param err array of error codes from {@link TestConstants}. 119 * @return string array for the given error codes. 120 */ convertToStringArray(int[] err)121 public static String[] convertToStringArray(int[] err) { 122 if (err == null) return null; 123 String[] ret = new String[err.length]; 124 for (int i = 0; i < err.length; i++) { 125 ret[i] = errToStr(err[i]); 126 } 127 return ret; 128 } 129 130 } 131