blob: d568b4da9a20a310acdecc71507799755981f4dc [file] [log] [blame]
Mathias Agopian3cf61352010-02-09 17:46:37 -08001/*
2 * Copyright (C) 2008 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#ifndef ANDROID_HARDWARE_ICAMERASERVICE_H
18#define ANDROID_HARDWARE_ICAMERASERVICE_H
19
20#include <utils/RefBase.h>
21#include <binder/IInterface.h>
22#include <binder/Parcel.h>
23
Mathias Agopian3cf61352010-02-09 17:46:37 -080024namespace android {
25
Igor Murashkinc073ba52013-02-26 14:32:34 -080026class ICamera;
27class ICameraClient;
Igor Murashkinbfc99152013-02-27 12:55:20 -080028class ICameraServiceListener;
Igor Murashkine7ee7632013-06-11 18:10:18 -070029class ICameraDeviceUser;
30class ICameraDeviceCallbacks;
Zhijun He2b59be82013-09-25 10:14:30 -070031class CameraMetadata;
Ruben Brunkd1176ef2014-02-21 10:51:38 -080032class VendorTagDescriptor;
Igor Murashkin65d14b92014-06-17 12:03:20 -070033class String16;
Igor Murashkinc073ba52013-02-26 14:32:34 -080034
Mathias Agopian3cf61352010-02-09 17:46:37 -080035class ICameraService : public IInterface
36{
37public:
Igor Murashkinbef3f232013-05-30 17:47:38 -070038 /**
39 * Keep up-to-date with ICameraService.aidl in frameworks/base
40 */
Mathias Agopian3cf61352010-02-09 17:46:37 -080041 enum {
Chih-Chung Chang35a055b2010-05-06 16:36:58 +080042 GET_NUMBER_OF_CAMERAS = IBinder::FIRST_CALL_TRANSACTION,
Chih-Chung Changddbdb352010-06-10 13:32:16 +080043 GET_CAMERA_INFO,
Igor Murashkin634a5152013-02-20 17:15:11 -080044 CONNECT,
Igor Murashkine7ee7632013-06-11 18:10:18 -070045 CONNECT_DEVICE,
Igor Murashkinbfc99152013-02-27 12:55:20 -080046 ADD_LISTENER,
47 REMOVE_LISTENER,
Zhijun He2b59be82013-09-25 10:14:30 -070048 GET_CAMERA_CHARACTERISTICS,
Ruben Brunkd1176ef2014-02-21 10:51:38 -080049 GET_CAMERA_VENDOR_TAG_DESCRIPTOR,
Igor Murashkin65d14b92014-06-17 12:03:20 -070050 GET_LEGACY_PARAMETERS,
51 SUPPORTS_CAMERA_API,
Zhijun Heb10cdad2014-06-16 16:38:35 -070052 CONNECT_LEGACY,
Chien-Yu Chen3068d732015-02-09 13:29:57 -080053 SET_TORCH_MODE,
Ruben Brunk36597b22015-03-20 22:15:57 -070054 NOTIFY_SYSTEM_EVENT,
Mathias Agopian3cf61352010-02-09 17:46:37 -080055 };
56
Eino-Ville Talvalaceb388d2013-02-19 10:40:14 -080057 enum {
Chien-Yu Chen98a668f2015-12-18 14:10:33 -080058 USE_CALLING_PID = -1
59 };
60
61 enum {
Eino-Ville Talvalaceb388d2013-02-19 10:40:14 -080062 USE_CALLING_UID = -1
63 };
64
Igor Murashkin65d14b92014-06-17 12:03:20 -070065 enum {
66 API_VERSION_1 = 1,
67 API_VERSION_2 = 2,
68 };
69
Zhijun Heb10cdad2014-06-16 16:38:35 -070070 enum {
Eino-Ville Talvalabad43582015-08-14 13:12:32 -070071 CAMERA_TYPE_BACKWARD_COMPATIBLE = 0,
72 CAMERA_TYPE_ALL = 1,
73 };
74
75 enum {
Zhijun Heb10cdad2014-06-16 16:38:35 -070076 CAMERA_HAL_API_VERSION_UNSPECIFIED = -1
Ruben Brunk36597b22015-03-20 22:15:57 -070077 };
78
79 /**
80 * Keep up-to-date with declarations in
81 * frameworks/base/services/core/java/com/android/server/camera/CameraService.java
82 *
83 * These event codes are intended to be used with the notifySystemEvent call.
84 */
85 enum {
86 NO_EVENT = 0,
87 USER_SWITCHED,
88 };
Zhijun Heb10cdad2014-06-16 16:38:35 -070089
Mathias Agopian3cf61352010-02-09 17:46:37 -080090public:
91 DECLARE_META_INTERFACE(CameraService);
92
Eino-Ville Talvalabad43582015-08-14 13:12:32 -070093 // Get the number of cameras that support basic color camera operation
94 // (type CAMERA_TYPE_BACKWARD_COMPATIBLE)
Igor Murashkinbfc99152013-02-27 12:55:20 -080095 virtual int32_t getNumberOfCameras() = 0;
Eino-Ville Talvalabad43582015-08-14 13:12:32 -070096 // Get the number of cameras of the specified type, one of CAMERA_TYPE_*
97 // enums
98 virtual int32_t getNumberOfCameras(int cameraType) = 0;
Igor Murashkinbfc99152013-02-27 12:55:20 -080099 virtual status_t getCameraInfo(int cameraId,
Igor Murashkine1445da2014-03-17 14:00:29 -0700100 /*out*/
101 struct CameraInfo* cameraInfo) = 0;
Igor Murashkinbfc99152013-02-27 12:55:20 -0800102
Zhijun He2b59be82013-09-25 10:14:30 -0700103 virtual status_t getCameraCharacteristics(int cameraId,
Igor Murashkine1445da2014-03-17 14:00:29 -0700104 /*out*/
105 CameraMetadata* cameraInfo) = 0;
Zhijun He2b59be82013-09-25 10:14:30 -0700106
Igor Murashkine1445da2014-03-17 14:00:29 -0700107 virtual status_t getCameraVendorTagDescriptor(
108 /*out*/
109 sp<VendorTagDescriptor>& desc) = 0;
Ruben Brunkd1176ef2014-02-21 10:51:38 -0800110
Igor Murashkinbfc99152013-02-27 12:55:20 -0800111 // Returns 'OK' if operation succeeded
112 // - Errors: ALREADY_EXISTS if the listener was already added
113 virtual status_t addListener(const sp<ICameraServiceListener>& listener)
114 = 0;
115 // Returns 'OK' if operation succeeded
116 // - Errors: BAD_VALUE if specified listener was not in the listener list
117 virtual status_t removeListener(const sp<ICameraServiceListener>& listener)
118 = 0;
Eino-Ville Talvalaceb388d2013-02-19 10:40:14 -0800119 /**
Chien-Yu Chen98a668f2015-12-18 14:10:33 -0800120 * clientPackageName, clientUid, and clientPid are used for permissions checking. If
121 * clientUid == USE_CALLING_UID, then the calling UID is used instead. If
122 * clientPid == USE_CALLING_PID, then the calling PID is used instead. Only
123 * trusted callers can set a clientUid and clientPid other than USE_CALLING_UID and
124 * USE_CALLING_UID respectively.
Eino-Ville Talvalaceb388d2013-02-19 10:40:14 -0800125 */
Ruben Brunk0f61d8f2013-08-08 13:07:18 -0700126 virtual status_t connect(const sp<ICameraClient>& cameraClient,
Eino-Ville Talvalaceb388d2013-02-19 10:40:14 -0800127 int cameraId,
Svetoslav Ganov280405a2015-05-12 02:19:27 +0000128 const String16& clientPackageName,
Ruben Brunk0f61d8f2013-08-08 13:07:18 -0700129 int clientUid,
Chien-Yu Chen98a668f2015-12-18 14:10:33 -0800130 int clientPid,
Ruben Brunk0f61d8f2013-08-08 13:07:18 -0700131 /*out*/
132 sp<ICamera>& device) = 0;
Igor Murashkin634a5152013-02-20 17:15:11 -0800133
Ruben Brunk0f61d8f2013-08-08 13:07:18 -0700134 virtual status_t connectDevice(
Igor Murashkine7ee7632013-06-11 18:10:18 -0700135 const sp<ICameraDeviceCallbacks>& cameraCb,
136 int cameraId,
Svetoslav Ganov280405a2015-05-12 02:19:27 +0000137 const String16& clientPackageName,
Ruben Brunk0f61d8f2013-08-08 13:07:18 -0700138 int clientUid,
139 /*out*/
140 sp<ICameraDeviceUser>& device) = 0;
Igor Murashkin65d14b92014-06-17 12:03:20 -0700141
142 virtual status_t getLegacyParameters(
143 int cameraId,
144 /*out*/
145 String16* parameters) = 0;
146
147 /**
148 * Returns OK if device supports camera2 api,
149 * returns -EOPNOTSUPP if it doesn't.
150 */
151 virtual status_t supportsCameraApi(
152 int cameraId, int apiVersion) = 0;
Zhijun Heb10cdad2014-06-16 16:38:35 -0700153
154 /**
155 * Connect the device as a legacy device for a given HAL version.
156 * For halVersion, use CAMERA_API_DEVICE_VERSION_* for a particular
157 * version, or CAMERA_HAL_API_VERSION_UNSPECIFIED for a service-selected version.
158 */
159 virtual status_t connectLegacy(const sp<ICameraClient>& cameraClient,
160 int cameraId, int halVersion,
Svetoslav Ganov280405a2015-05-12 02:19:27 +0000161 const String16& clientPackageName,
Zhijun Heb10cdad2014-06-16 16:38:35 -0700162 int clientUid,
163 /*out*/
164 sp<ICamera>& device) = 0;
Chien-Yu Chen3068d732015-02-09 13:29:57 -0800165
166 /**
Chien-Yu Chen88da5262015-02-17 13:56:46 -0800167 * Turn on or off a camera's torch mode. Torch mode will be turned off by
168 * camera service if the lastest client binder that turns it on dies.
169 *
170 * return values:
171 * 0: on a successful operation.
172 * -ENOSYS: the camera device doesn't support this operation. It it returned
173 * if and only if android.flash.into.available is false.
174 * -EBUSY: the camera device is opened.
175 * -EINVAL: camera_id is invalid or clientBinder is NULL when enabling a
176 * torch mode.
Chien-Yu Chen3068d732015-02-09 13:29:57 -0800177 */
178 virtual status_t setTorchMode(const String16& cameraId, bool enabled,
179 const sp<IBinder>& clientBinder) = 0;
Ruben Brunk36597b22015-03-20 22:15:57 -0700180
181 /**
182 * Notify the camera service of a system event. Should only be called from system_server.
183 */
Ruben Brunk6267b532015-04-30 17:44:07 -0700184 virtual void notifySystemEvent(int32_t eventId, const int32_t* args, size_t length) = 0;
Mathias Agopian3cf61352010-02-09 17:46:37 -0800185};
186
187// ----------------------------------------------------------------------------
188
189class BnCameraService: public BnInterface<ICameraService>
190{
191public:
192 virtual status_t onTransact( uint32_t code,
193 const Parcel& data,
194 Parcel* reply,
195 uint32_t flags = 0);
196};
197
198}; // namespace android
199
200#endif