blob: c8d3d191b42e70652855a9f8c96533980f5f7696 [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,
Mathias Agopian3cf61352010-02-09 17:46:37 -080054 };
55
Eino-Ville Talvalaceb388d2013-02-19 10:40:14 -080056 enum {
57 USE_CALLING_UID = -1
58 };
59
Igor Murashkin65d14b92014-06-17 12:03:20 -070060 enum {
61 API_VERSION_1 = 1,
62 API_VERSION_2 = 2,
63 };
64
Zhijun Heb10cdad2014-06-16 16:38:35 -070065 enum {
66 CAMERA_HAL_API_VERSION_UNSPECIFIED = -1
67 };
68
Mathias Agopian3cf61352010-02-09 17:46:37 -080069public:
70 DECLARE_META_INTERFACE(CameraService);
71
Igor Murashkinbfc99152013-02-27 12:55:20 -080072 virtual int32_t getNumberOfCameras() = 0;
73 virtual status_t getCameraInfo(int cameraId,
Igor Murashkine1445da2014-03-17 14:00:29 -070074 /*out*/
75 struct CameraInfo* cameraInfo) = 0;
Igor Murashkinbfc99152013-02-27 12:55:20 -080076
Zhijun He2b59be82013-09-25 10:14:30 -070077 virtual status_t getCameraCharacteristics(int cameraId,
Igor Murashkine1445da2014-03-17 14:00:29 -070078 /*out*/
79 CameraMetadata* cameraInfo) = 0;
Zhijun He2b59be82013-09-25 10:14:30 -070080
Igor Murashkine1445da2014-03-17 14:00:29 -070081 virtual status_t getCameraVendorTagDescriptor(
82 /*out*/
83 sp<VendorTagDescriptor>& desc) = 0;
Ruben Brunkd1176ef2014-02-21 10:51:38 -080084
Igor Murashkinbfc99152013-02-27 12:55:20 -080085 // Returns 'OK' if operation succeeded
86 // - Errors: ALREADY_EXISTS if the listener was already added
87 virtual status_t addListener(const sp<ICameraServiceListener>& listener)
88 = 0;
89 // Returns 'OK' if operation succeeded
90 // - Errors: BAD_VALUE if specified listener was not in the listener list
91 virtual status_t removeListener(const sp<ICameraServiceListener>& listener)
92 = 0;
Eino-Ville Talvalaceb388d2013-02-19 10:40:14 -080093 /**
94 * clientPackageName and clientUid are used for permissions checking. if
95 * clientUid == USE_CALLING_UID, then the calling UID is used instead. Only
96 * trusted callers can set a clientUid other than USE_CALLING_UID.
97 */
Ruben Brunk0f61d8f2013-08-08 13:07:18 -070098 virtual status_t connect(const sp<ICameraClient>& cameraClient,
Eino-Ville Talvalaceb388d2013-02-19 10:40:14 -080099 int cameraId,
100 const String16& clientPackageName,
Ruben Brunk0f61d8f2013-08-08 13:07:18 -0700101 int clientUid,
102 /*out*/
103 sp<ICamera>& device) = 0;
Igor Murashkin634a5152013-02-20 17:15:11 -0800104
Ruben Brunk0f61d8f2013-08-08 13:07:18 -0700105 virtual status_t connectDevice(
Igor Murashkine7ee7632013-06-11 18:10:18 -0700106 const sp<ICameraDeviceCallbacks>& cameraCb,
107 int cameraId,
108 const String16& clientPackageName,
Ruben Brunk0f61d8f2013-08-08 13:07:18 -0700109 int clientUid,
110 /*out*/
111 sp<ICameraDeviceUser>& device) = 0;
Igor Murashkin65d14b92014-06-17 12:03:20 -0700112
113 virtual status_t getLegacyParameters(
114 int cameraId,
115 /*out*/
116 String16* parameters) = 0;
117
118 /**
119 * Returns OK if device supports camera2 api,
120 * returns -EOPNOTSUPP if it doesn't.
121 */
122 virtual status_t supportsCameraApi(
123 int cameraId, int apiVersion) = 0;
Zhijun Heb10cdad2014-06-16 16:38:35 -0700124
125 /**
126 * Connect the device as a legacy device for a given HAL version.
127 * For halVersion, use CAMERA_API_DEVICE_VERSION_* for a particular
128 * version, or CAMERA_HAL_API_VERSION_UNSPECIFIED for a service-selected version.
129 */
130 virtual status_t connectLegacy(const sp<ICameraClient>& cameraClient,
131 int cameraId, int halVersion,
132 const String16& clientPackageName,
133 int clientUid,
134 /*out*/
135 sp<ICamera>& device) = 0;
Chien-Yu Chen3068d732015-02-09 13:29:57 -0800136
137 /**
Chien-Yu Chen88da5262015-02-17 13:56:46 -0800138 * Turn on or off a camera's torch mode. Torch mode will be turned off by
139 * camera service if the lastest client binder that turns it on dies.
140 *
141 * return values:
142 * 0: on a successful operation.
143 * -ENOSYS: the camera device doesn't support this operation. It it returned
144 * if and only if android.flash.into.available is false.
145 * -EBUSY: the camera device is opened.
146 * -EINVAL: camera_id is invalid or clientBinder is NULL when enabling a
147 * torch mode.
Chien-Yu Chen3068d732015-02-09 13:29:57 -0800148 */
149 virtual status_t setTorchMode(const String16& cameraId, bool enabled,
150 const sp<IBinder>& clientBinder) = 0;
Mathias Agopian3cf61352010-02-09 17:46:37 -0800151};
152
153// ----------------------------------------------------------------------------
154
155class BnCameraService: public BnInterface<ICameraService>
156{
157public:
158 virtual status_t onTransact( uint32_t code,
159 const Parcel& data,
160 Parcel* reply,
161 uint32_t flags = 0);
162};
163
164}; // namespace android
165
166#endif