blob: 3e8992aaafc0950ff14b41431c24530aa92dc98f [file] [log] [blame]
Eino-Ville Talvalad56db1d2015-12-17 16:50:35 -08001/*
2 * Copyright (C) 2013 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
17package android.hardware;
18
19import android.hardware.ICamera;
20import android.hardware.ICameraClient;
21import android.hardware.camera2.ICameraDeviceUser;
22import android.hardware.camera2.ICameraDeviceCallbacks;
23import android.hardware.camera2.params.VendorTagDescriptor;
Emilian Peev71c73a22017-03-21 16:35:51 +000024import android.hardware.camera2.params.VendorTagDescriptorCache;
Eino-Ville Talvalad56db1d2015-12-17 16:50:35 -080025import android.hardware.camera2.impl.CameraMetadataNative;
26import android.hardware.ICameraServiceListener;
27import android.hardware.CameraInfo;
Eino-Ville Talvalaf51fca22016-12-13 11:25:55 -080028import android.hardware.CameraStatus;
Eino-Ville Talvalad56db1d2015-12-17 16:50:35 -080029
30/**
31 * Binder interface for the native camera service running in mediaserver.
32 *
33 * @hide
34 */
35interface ICameraService
36{
37 /**
38 * All camera service and device Binder calls may return a
39 * ServiceSpecificException with the following error codes
40 */
41 const int ERROR_PERMISSION_DENIED = 1;
42 const int ERROR_ALREADY_EXISTS = 2;
43 const int ERROR_ILLEGAL_ARGUMENT = 3;
44 const int ERROR_DISCONNECTED = 4;
45 const int ERROR_TIMED_OUT = 5;
46 const int ERROR_DISABLED = 6;
47 const int ERROR_CAMERA_IN_USE = 7;
48 const int ERROR_MAX_CAMERAS_IN_USE = 8;
49 const int ERROR_DEPRECATED_HAL = 9;
50 const int ERROR_INVALID_OPERATION = 10;
51
52 /**
53 * Types for getNumberOfCameras
54 */
55 const int CAMERA_TYPE_BACKWARD_COMPATIBLE = 0;
56 const int CAMERA_TYPE_ALL = 1;
57
58 /**
59 * Return the number of camera devices available in the system
60 */
61 int getNumberOfCameras(int type);
62
63 /**
64 * Fetch basic camera information for a camera device
65 */
66 CameraInfo getCameraInfo(int cameraId);
67
68 /**
69 * Default UID/PID values for non-privileged callers of
70 * connect(), connectDevice(), and connectLegacy()
71 */
72 const int USE_CALLING_UID = -1;
73 const int USE_CALLING_PID = -1;
74
75 /**
76 * Open a camera device through the old camera API
77 */
78 ICamera connect(ICameraClient client,
79 int cameraId,
80 String opPackageName,
81 int clientUid, int clientPid);
82
83 /**
84 * Open a camera device through the new camera API
85 * Only supported for device HAL versions >= 3.2
86 */
87 ICameraDeviceUser connectDevice(ICameraDeviceCallbacks callbacks,
Eino-Ville Talvalaf51fca22016-12-13 11:25:55 -080088 String cameraId,
Eino-Ville Talvalad56db1d2015-12-17 16:50:35 -080089 String opPackageName,
90 int clientUid);
91
92 /**
93 * halVersion constant for connectLegacy
94 */
95 const int CAMERA_HAL_API_VERSION_UNSPECIFIED = -1;
96
97 /**
98 * Open a camera device in legacy mode, if supported by the camera module HAL.
99 */
100 ICamera connectLegacy(ICameraClient client,
101 int cameraId,
102 int halVersion,
103 String opPackageName,
104 int clientUid);
105
106 /**
Eino-Ville Talvalaf51fca22016-12-13 11:25:55 -0800107 * Add listener for changes to camera device and flashlight state.
108 *
109 * Also returns the set of currently-known camera IDs and state of each device.
110 * Adding a listener will trigger the torch status listener to fire for all
Emilian Peev53722fa2019-02-22 17:47:20 -0800111 * devices that have a flash unit.
Eino-Ville Talvalad56db1d2015-12-17 16:50:35 -0800112 */
Eino-Ville Talvalaf51fca22016-12-13 11:25:55 -0800113 CameraStatus[] addListener(ICameraServiceListener listener);
114
115 /**
116 * Remove listener for changes to camera device and flashlight state.
117 */
Eino-Ville Talvalad56db1d2015-12-17 16:50:35 -0800118 void removeListener(ICameraServiceListener listener);
119
120 /**
121 * Read the static camera metadata for a camera device.
122 * Only supported for device HAL versions >= 3.2
123 */
Eino-Ville Talvalaf51fca22016-12-13 11:25:55 -0800124 CameraMetadataNative getCameraCharacteristics(String cameraId);
Eino-Ville Talvalad56db1d2015-12-17 16:50:35 -0800125
126 /**
127 * Read in the vendor tag descriptors from the camera module HAL.
128 * Intended to be used by the native code of CameraMetadataNative to correctly
129 * interpret camera metadata with vendor tags.
130 */
131 VendorTagDescriptor getCameraVendorTagDescriptor();
132
133 /**
Emilian Peev71c73a22017-03-21 16:35:51 +0000134 * Retrieve the vendor tag descriptor cache which can have multiple vendor
135 * providers.
136 * Intended to be used by the native code of CameraMetadataNative to correctly
137 * interpret camera metadata with vendor tags.
138 */
139 VendorTagDescriptorCache getCameraVendorTagCache();
140
141 /**
Eino-Ville Talvalad56db1d2015-12-17 16:50:35 -0800142 * Read the legacy camera1 parameters into a String
143 */
144 String getLegacyParameters(int cameraId);
145
146 /**
147 * apiVersion constants for supportsCameraApi
148 */
149 const int API_VERSION_1 = 1;
150 const int API_VERSION_2 = 2;
151
Shuzhen Wangf9d2c022018-08-21 12:07:35 -0700152 // Determines if a particular API version is supported directly for a cameraId.
Eino-Ville Talvalaf51fca22016-12-13 11:25:55 -0800153 boolean supportsCameraApi(String cameraId, int apiVersion);
Shuzhen Wangf9d2c022018-08-21 12:07:35 -0700154 // Determines if a cameraId is a hidden physical camera of a logical multi-camera.
155 boolean isHiddenPhysicalCamera(String cameraId);
Eino-Ville Talvalad56db1d2015-12-17 16:50:35 -0800156
Eino-Ville Talvalaf51fca22016-12-13 11:25:55 -0800157 void setTorchMode(String cameraId, boolean enabled, IBinder clientBinder);
Eino-Ville Talvalad56db1d2015-12-17 16:50:35 -0800158
159 /**
160 * Notify the camera service of a system event. Should only be called from system_server.
161 *
162 * Callers require the android.permission.CAMERA_SEND_SYSTEM_EVENTS permission.
163 */
164 const int EVENT_NONE = 0;
Eino-Ville Talvala63f36112018-12-06 14:57:03 -0800165 const int EVENT_USER_SWITCHED = 1; // The argument is the set of new foreground user IDs.
Eino-Ville Talvalad56db1d2015-12-17 16:50:35 -0800166 oneway void notifySystemEvent(int eventId, in int[] args);
Eino-Ville Talvala63f36112018-12-06 14:57:03 -0800167
168 /**
169 * Notify the camera service of a device physical status change. May only be called from
170 * a privileged process.
171 *
172 * newState is a bitfield consisting of DEVICE_STATE_* values combined together. Valid state
173 * combinations are device-specific. At device startup, the camera service will assume the device
174 * state is NORMAL until otherwise notified.
175 *
176 * Callers require the android.permission.CAMERA_SEND_SYSTEM_EVENTS permission.
177 */
178 oneway void notifyDeviceStateChange(long newState);
179
180 // Bitfield constants for notifyDeviceStateChange
181 // All bits >= 32 are for custom vendor states
182 // Written as ints since AIDL does not support long constants.
183 const int DEVICE_STATE_NORMAL = 0;
184 const int DEVICE_STATE_BACK_COVERED = 1;
185 const int DEVICE_STATE_FRONT_COVERED = 2;
186 const int DEVICE_STATE_FOLDED = 4;
187 const int DEVICE_STATE_LAST_FRAMEWORK_BIT = 0x80000000; // 1 << 31;
188
Eino-Ville Talvalad56db1d2015-12-17 16:50:35 -0800189}