blob: 38bff3ed902e94c222f79974ad1af22a73034e8e [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 {
58 USE_CALLING_UID = -1
59 };
60
Igor Murashkin65d14b92014-06-17 12:03:20 -070061 enum {
62 API_VERSION_1 = 1,
63 API_VERSION_2 = 2,
64 };
65
Zhijun Heb10cdad2014-06-16 16:38:35 -070066 enum {
67 CAMERA_HAL_API_VERSION_UNSPECIFIED = -1
Ruben Brunk36597b22015-03-20 22:15:57 -070068 };
69
70 /**
71 * Keep up-to-date with declarations in
72 * frameworks/base/services/core/java/com/android/server/camera/CameraService.java
73 *
74 * These event codes are intended to be used with the notifySystemEvent call.
75 */
76 enum {
77 NO_EVENT = 0,
78 USER_SWITCHED,
79 };
Zhijun Heb10cdad2014-06-16 16:38:35 -070080
Mathias Agopian3cf61352010-02-09 17:46:37 -080081public:
82 DECLARE_META_INTERFACE(CameraService);
83
Igor Murashkinbfc99152013-02-27 12:55:20 -080084 virtual int32_t getNumberOfCameras() = 0;
85 virtual status_t getCameraInfo(int cameraId,
Igor Murashkine1445da2014-03-17 14:00:29 -070086 /*out*/
87 struct CameraInfo* cameraInfo) = 0;
Igor Murashkinbfc99152013-02-27 12:55:20 -080088
Zhijun He2b59be82013-09-25 10:14:30 -070089 virtual status_t getCameraCharacteristics(int cameraId,
Igor Murashkine1445da2014-03-17 14:00:29 -070090 /*out*/
91 CameraMetadata* cameraInfo) = 0;
Zhijun He2b59be82013-09-25 10:14:30 -070092
Igor Murashkine1445da2014-03-17 14:00:29 -070093 virtual status_t getCameraVendorTagDescriptor(
94 /*out*/
95 sp<VendorTagDescriptor>& desc) = 0;
Ruben Brunkd1176ef2014-02-21 10:51:38 -080096
Igor Murashkinbfc99152013-02-27 12:55:20 -080097 // Returns 'OK' if operation succeeded
98 // - Errors: ALREADY_EXISTS if the listener was already added
99 virtual status_t addListener(const sp<ICameraServiceListener>& listener)
100 = 0;
101 // Returns 'OK' if operation succeeded
102 // - Errors: BAD_VALUE if specified listener was not in the listener list
103 virtual status_t removeListener(const sp<ICameraServiceListener>& listener)
104 = 0;
Eino-Ville Talvalaceb388d2013-02-19 10:40:14 -0800105 /**
106 * clientPackageName and clientUid are used for permissions checking. if
107 * clientUid == USE_CALLING_UID, then the calling UID is used instead. Only
108 * trusted callers can set a clientUid other than USE_CALLING_UID.
109 */
Ruben Brunk0f61d8f2013-08-08 13:07:18 -0700110 virtual status_t connect(const sp<ICameraClient>& cameraClient,
Eino-Ville Talvalaceb388d2013-02-19 10:40:14 -0800111 int cameraId,
Svet Ganov32fa6d02015-05-01 20:47:20 -0700112 const String16& opPackageName,
Ruben Brunk0f61d8f2013-08-08 13:07:18 -0700113 int clientUid,
114 /*out*/
115 sp<ICamera>& device) = 0;
Igor Murashkin634a5152013-02-20 17:15:11 -0800116
Ruben Brunk0f61d8f2013-08-08 13:07:18 -0700117 virtual status_t connectDevice(
Igor Murashkine7ee7632013-06-11 18:10:18 -0700118 const sp<ICameraDeviceCallbacks>& cameraCb,
119 int cameraId,
Svet Ganov32fa6d02015-05-01 20:47:20 -0700120 const String16& opPackageName,
Ruben Brunk0f61d8f2013-08-08 13:07:18 -0700121 int clientUid,
122 /*out*/
123 sp<ICameraDeviceUser>& device) = 0;
Igor Murashkin65d14b92014-06-17 12:03:20 -0700124
125 virtual status_t getLegacyParameters(
126 int cameraId,
127 /*out*/
128 String16* parameters) = 0;
129
130 /**
131 * Returns OK if device supports camera2 api,
132 * returns -EOPNOTSUPP if it doesn't.
133 */
134 virtual status_t supportsCameraApi(
135 int cameraId, int apiVersion) = 0;
Zhijun Heb10cdad2014-06-16 16:38:35 -0700136
137 /**
138 * Connect the device as a legacy device for a given HAL version.
139 * For halVersion, use CAMERA_API_DEVICE_VERSION_* for a particular
140 * version, or CAMERA_HAL_API_VERSION_UNSPECIFIED for a service-selected version.
141 */
142 virtual status_t connectLegacy(const sp<ICameraClient>& cameraClient,
143 int cameraId, int halVersion,
Svet Ganov32fa6d02015-05-01 20:47:20 -0700144 const String16& opPackageName,
Zhijun Heb10cdad2014-06-16 16:38:35 -0700145 int clientUid,
146 /*out*/
147 sp<ICamera>& device) = 0;
Chien-Yu Chen3068d732015-02-09 13:29:57 -0800148
149 /**
Chien-Yu Chen88da5262015-02-17 13:56:46 -0800150 * Turn on or off a camera's torch mode. Torch mode will be turned off by
151 * camera service if the lastest client binder that turns it on dies.
152 *
153 * return values:
154 * 0: on a successful operation.
155 * -ENOSYS: the camera device doesn't support this operation. It it returned
156 * if and only if android.flash.into.available is false.
157 * -EBUSY: the camera device is opened.
158 * -EINVAL: camera_id is invalid or clientBinder is NULL when enabling a
159 * torch mode.
Chien-Yu Chen3068d732015-02-09 13:29:57 -0800160 */
161 virtual status_t setTorchMode(const String16& cameraId, bool enabled,
162 const sp<IBinder>& clientBinder) = 0;
Ruben Brunk36597b22015-03-20 22:15:57 -0700163
164 /**
165 * Notify the camera service of a system event. Should only be called from system_server.
166 */
167 virtual void notifySystemEvent(int eventId, int arg0) = 0;
Mathias Agopian3cf61352010-02-09 17:46:37 -0800168};
169
170// ----------------------------------------------------------------------------
171
172class BnCameraService: public BnInterface<ICameraService>
173{
174public:
175 virtual status_t onTransact( uint32_t code,
176 const Parcel& data,
177 Parcel* reply,
178 uint32_t flags = 0);
179};
180
181}; // namespace android
182
183#endif