• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1 /*
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 
17 package android.hardware;
18 
19 import android.hardware.ICamera;
20 import android.hardware.ICameraClient;
21 import android.hardware.camera2.ICameraDeviceUser;
22 import android.hardware.camera2.ICameraDeviceCallbacks;
23 import android.hardware.camera2.ICameraInjectionCallback;
24 import android.hardware.camera2.ICameraInjectionSession;
25 import android.hardware.camera2.params.VendorTagDescriptor;
26 import android.hardware.camera2.params.VendorTagDescriptorCache;
27 import android.hardware.camera2.utils.ConcurrentCameraIdCombination;
28 import android.hardware.camera2.utils.CameraIdAndSessionConfiguration;
29 import android.hardware.camera2.impl.CameraMetadataNative;
30 import android.hardware.ICameraServiceListener;
31 import android.hardware.CameraInfo;
32 import android.hardware.CameraIdRemapping;
33 import android.hardware.CameraStatus;
34 import android.hardware.CameraExtensionSessionStats;
35 
36 /**
37  * Binder interface for the native camera service running in mediaserver.
38  *
39  * @hide
40  */
41 interface ICameraService
42 {
43     /**
44      * All camera service and device Binder calls may return a
45      * ServiceSpecificException with the following error codes
46      */
47     const int ERROR_PERMISSION_DENIED = 1;
48     const int ERROR_ALREADY_EXISTS = 2;
49     const int ERROR_ILLEGAL_ARGUMENT = 3;
50     const int ERROR_DISCONNECTED = 4;
51     const int ERROR_TIMED_OUT = 5;
52     const int ERROR_DISABLED = 6;
53     const int ERROR_CAMERA_IN_USE = 7;
54     const int ERROR_MAX_CAMERAS_IN_USE = 8;
55     const int ERROR_DEPRECATED_HAL = 9;
56     const int ERROR_INVALID_OPERATION = 10;
57 
58     /**
59      * Types for getNumberOfCameras
60      */
61     const int CAMERA_TYPE_BACKWARD_COMPATIBLE = 0;
62     const int CAMERA_TYPE_ALL = 1;
63 
64     /**
65      * Return the number of camera devices available in the system
66      */
getNumberOfCameras(int type)67     int getNumberOfCameras(int type);
68 
69     /**
70      * Fetch basic camera information for a camera device
71      */
getCameraInfo(int cameraId, boolean overrideToPortrait)72     CameraInfo getCameraInfo(int cameraId, boolean overrideToPortrait);
73 
74     /**
75      * Default UID/PID values for non-privileged callers of
76      * connect() and connectDevice()
77      */
78     const int USE_CALLING_UID = -1;
79     const int USE_CALLING_PID = -1;
80 
81     /**
82      * Open a camera device through the old camera API
83      */
connect(ICameraClient client, int cameraId, String opPackageName, int clientUid, int clientPid, int targetSdkVersion, boolean overrideToPortrait, boolean forceSlowJpegMode)84     ICamera connect(ICameraClient client,
85             int cameraId,
86             String opPackageName,
87             int clientUid, int clientPid,
88             int targetSdkVersion,
89             boolean overrideToPortrait,
90             boolean forceSlowJpegMode);
91 
92     /**
93      * Open a camera device through the new camera API
94      * Only supported for device HAL versions >= 3.2
95      */
connectDevice(ICameraDeviceCallbacks callbacks, String cameraId, String opPackageName, @nullable String featureId, int clientUid, int oomScoreOffset, int targetSdkVersion, boolean overrideToPortrait)96     ICameraDeviceUser connectDevice(ICameraDeviceCallbacks callbacks,
97             String cameraId,
98             String opPackageName,
99             @nullable String featureId,
100             int clientUid, int oomScoreOffset,
101             int targetSdkVersion,
102             boolean overrideToPortrait);
103 
104     /**
105      * Add listener for changes to camera device and flashlight state.
106      *
107      * Also returns the set of currently-known camera IDs and state of each device.
108      * Adding a listener will trigger the torch status listener to fire for all
109      * devices that have a flash unit.
110      */
addListener(ICameraServiceListener listener)111     CameraStatus[] addListener(ICameraServiceListener listener);
112 
113     /**
114      * Get a list of combinations of camera ids which support concurrent streaming.
115      *
116      */
getConcurrentCameraIds()117     ConcurrentCameraIdCombination[] getConcurrentCameraIds();
118 
119     /**
120       * Check whether a particular set of session configurations are concurrently supported by the
121       * corresponding camera ids.
122       *
123       * @param sessions the set of camera id and session configuration pairs to be queried.
124       * @param targetSdkVersion the target sdk level of the application calling this function.
125       * @return true  - the set of concurrent camera id and stream combinations is supported.
126       *         false - the set of concurrent camera id and stream combinations is not supported
127       *                 OR the method was called with a set of camera ids not returned by
128       *                 getConcurrentCameraIds().
129       */
isConcurrentSessionConfigurationSupported( in CameraIdAndSessionConfiguration[] sessions, int targetSdkVersion)130     boolean isConcurrentSessionConfigurationSupported(
131             in CameraIdAndSessionConfiguration[] sessions,
132             int targetSdkVersion);
133 
134     /**
135      * Remap Camera Ids in the CameraService.
136      *
137      * Once this is in effect, all binder calls in the ICameraService that
138      * use logicalCameraId should consult remapping state to arrive at the
139      * correct cameraId to perform the operation on.
140      *
141      * Note: Before the new cameraIdRemapping state is applied, the previous
142      * state is cleared.
143      *
144      * @param cameraIdRemapping the camera ids to remap. Sending an unpopulated
145      *        cameraIdRemapping object will result in clearing of any previous
146      *        cameraIdRemapping state in the camera service.
147      */
remapCameraIds(in CameraIdRemapping cameraIdRemapping)148     void remapCameraIds(in CameraIdRemapping cameraIdRemapping);
149 
150     /**
151      * Remove listener for changes to camera device and flashlight state.
152      */
removeListener(ICameraServiceListener listener)153     void removeListener(ICameraServiceListener listener);
154 
155     /**
156      * Read the static camera metadata for a camera device.
157      * Only supported for device HAL versions >= 3.2
158      */
getCameraCharacteristics(String cameraId, int targetSdkVersion, boolean overrideToPortrait)159     CameraMetadataNative getCameraCharacteristics(String cameraId, int targetSdkVersion,
160             boolean overrideToPortrait);
161 
162     /**
163      * Read in the vendor tag descriptors from the camera module HAL.
164      * Intended to be used by the native code of CameraMetadataNative to correctly
165      * interpret camera metadata with vendor tags.
166      */
getCameraVendorTagDescriptor()167     VendorTagDescriptor getCameraVendorTagDescriptor();
168 
169     /**
170      * Retrieve the vendor tag descriptor cache which can have multiple vendor
171      * providers.
172      * Intended to be used by the native code of CameraMetadataNative to correctly
173      * interpret camera metadata with vendor tags.
174      */
getCameraVendorTagCache()175     VendorTagDescriptorCache getCameraVendorTagCache();
176 
177     /**
178      * Read the legacy camera1 parameters into a String
179      */
getLegacyParameters(int cameraId)180     String getLegacyParameters(int cameraId);
181 
182     /**
183      * apiVersion constants for supportsCameraApi
184      */
185     const int API_VERSION_1 = 1;
186     const int API_VERSION_2 = 2;
187 
188     // Determines if a particular API version is supported directly for a cameraId.
supportsCameraApi(String cameraId, int apiVersion)189     boolean supportsCameraApi(String cameraId, int apiVersion);
190     // Determines if a cameraId is a hidden physical camera of a logical multi-camera.
isHiddenPhysicalCamera(String cameraId)191     boolean isHiddenPhysicalCamera(String cameraId);
192     // Inject the external camera to replace the internal camera session.
injectCamera(String packageName, String internalCamId, String externalCamId, in ICameraInjectionCallback CameraInjectionCallback)193     ICameraInjectionSession injectCamera(String packageName, String internalCamId,
194             String externalCamId, in ICameraInjectionCallback CameraInjectionCallback);
195 
setTorchMode(String cameraId, boolean enabled, IBinder clientBinder)196     void setTorchMode(String cameraId, boolean enabled, IBinder clientBinder);
197 
198     // Change the brightness level of the flash unit associated with cameraId to strengthLevel.
199     // If the torch is in OFF state and strengthLevel > 0 then the torch will also be turned ON.
turnOnTorchWithStrengthLevel(String cameraId, int strengthLevel, IBinder clientBinder)200     void turnOnTorchWithStrengthLevel(String cameraId, int strengthLevel, IBinder clientBinder);
201 
202     // Get the brightness level of the flash unit associated with cameraId.
getTorchStrengthLevel(String cameraId)203     int getTorchStrengthLevel(String cameraId);
204 
205     /**
206      * Notify the camera service of a system event.  Should only be called from system_server.
207      *
208      * Callers require the android.permission.CAMERA_SEND_SYSTEM_EVENTS permission.
209      */
210     const int EVENT_NONE = 0;
211     const int EVENT_USER_SWITCHED = 1; // The argument is the set of new foreground user IDs.
212     const int EVENT_USB_DEVICE_ATTACHED = 2; // The argument is the deviceId and vendorId
213     const int EVENT_USB_DEVICE_DETACHED = 3; // The argument is the deviceId and vendorId
notifySystemEvent(int eventId, in int[] args)214     oneway void notifySystemEvent(int eventId, in int[] args);
215 
216     /**
217      * Notify the camera service of a display configuration change.
218      *
219      * Callers require the android.permission.CAMERA_SEND_SYSTEM_EVENTS permission.
220      */
notifyDisplayConfigurationChange()221     oneway void notifyDisplayConfigurationChange();
222 
223     /**
224      * Notify the camera service of a device physical status change. May only be called from
225      * a privileged process.
226      *
227      * newState is a bitfield consisting of DEVICE_STATE_* values combined together. Valid state
228      * combinations are device-specific. At device startup, the camera service will assume the device
229      * state is NORMAL until otherwise notified.
230      *
231      * Callers require the android.permission.CAMERA_SEND_SYSTEM_EVENTS permission.
232      */
notifyDeviceStateChange(long newState)233     oneway void notifyDeviceStateChange(long newState);
234 
235     /**
236      * Report Extension specific metrics to camera service for logging. This should only be called
237      * by CameraExtensionSession to log extension metrics. All calls after the first must set
238      * CameraExtensionSessionStats.key to the value returned by this function.
239      *
240      * Each subsequent call fully overwrites the existing CameraExtensionSessionStats for the
241      * current session, so the caller is responsible for keeping the stats complete.
242      *
243      * Due to cameraservice and cameraservice_proxy architecture, there is no guarantee that
244      * {@code stats} will be logged immediately (or at all). CameraService will log whatever
245      * extension stats it has at the time of camera session closing which may be before the app
246      * process receives a session/device closed callback; so CameraExtensionSession
247      * should send metrics to the cameraservice preriodically, and cameraservice must handle calls
248      * to this function from sessions that have not been logged yet and from sessions that have
249      * already been closed.
250      *
251      * @return the key that must be used to report updates to previously reported stats.
252      */
reportExtensionSessionStats(in CameraExtensionSessionStats stats)253     String reportExtensionSessionStats(in CameraExtensionSessionStats stats);
254 
255     // Bitfield constants for notifyDeviceStateChange
256     // All bits >= 32 are for custom vendor states
257     // Written as ints since AIDL does not support long constants.
258     const int DEVICE_STATE_NORMAL = 0;
259     const int DEVICE_STATE_BACK_COVERED = 1;
260     const int DEVICE_STATE_FRONT_COVERED = 2;
261     const int DEVICE_STATE_FOLDED = 4;
262     const int DEVICE_STATE_LAST_FRAMEWORK_BIT = 0x80000000; // 1 << 31;
263 
264 }
265