blob: cc41efe287790966c5103b7948aa494c7447e351 [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;
28class IProCameraUser;
29class IProCameraCallbacks;
Igor Murashkinbfc99152013-02-27 12:55:20 -080030class ICameraServiceListener;
Igor Murashkine7ee7632013-06-11 18:10:18 -070031class ICameraDeviceUser;
32class ICameraDeviceCallbacks;
Zhijun He2b59be82013-09-25 10:14:30 -070033class CameraMetadata;
Ruben Brunkd1176ef2014-02-21 10:51:38 -080034class VendorTagDescriptor;
Igor Murashkin65d14b92014-06-17 12:03:20 -070035class String16;
Igor Murashkinc073ba52013-02-26 14:32:34 -080036
Mathias Agopian3cf61352010-02-09 17:46:37 -080037class ICameraService : public IInterface
38{
39public:
Igor Murashkinbef3f232013-05-30 17:47:38 -070040 /**
41 * Keep up-to-date with ICameraService.aidl in frameworks/base
42 */
Mathias Agopian3cf61352010-02-09 17:46:37 -080043 enum {
Chih-Chung Chang35a055b2010-05-06 16:36:58 +080044 GET_NUMBER_OF_CAMERAS = IBinder::FIRST_CALL_TRANSACTION,
Chih-Chung Changddbdb352010-06-10 13:32:16 +080045 GET_CAMERA_INFO,
Igor Murashkin634a5152013-02-20 17:15:11 -080046 CONNECT,
Igor Murashkinbfc99152013-02-27 12:55:20 -080047 CONNECT_PRO,
Igor Murashkine7ee7632013-06-11 18:10:18 -070048 CONNECT_DEVICE,
Igor Murashkinbfc99152013-02-27 12:55:20 -080049 ADD_LISTENER,
50 REMOVE_LISTENER,
Zhijun He2b59be82013-09-25 10:14:30 -070051 GET_CAMERA_CHARACTERISTICS,
Ruben Brunkd1176ef2014-02-21 10:51:38 -080052 GET_CAMERA_VENDOR_TAG_DESCRIPTOR,
Igor Murashkin65d14b92014-06-17 12:03:20 -070053 GET_LEGACY_PARAMETERS,
54 SUPPORTS_CAMERA_API,
Zhijun Heb10cdad2014-06-16 16:38:35 -070055 CONNECT_LEGACY,
Chien-Yu Chen3068d732015-02-09 13:29:57 -080056 SET_TORCH_MODE,
Mathias Agopian3cf61352010-02-09 17:46:37 -080057 };
58
Eino-Ville Talvalaceb388d2013-02-19 10:40:14 -080059 enum {
60 USE_CALLING_UID = -1
61 };
62
Igor Murashkin65d14b92014-06-17 12:03:20 -070063 enum {
64 API_VERSION_1 = 1,
65 API_VERSION_2 = 2,
66 };
67
Zhijun Heb10cdad2014-06-16 16:38:35 -070068 enum {
69 CAMERA_HAL_API_VERSION_UNSPECIFIED = -1
70 };
71
Mathias Agopian3cf61352010-02-09 17:46:37 -080072public:
73 DECLARE_META_INTERFACE(CameraService);
74
Igor Murashkinbfc99152013-02-27 12:55:20 -080075 virtual int32_t getNumberOfCameras() = 0;
76 virtual status_t getCameraInfo(int cameraId,
Igor Murashkine1445da2014-03-17 14:00:29 -070077 /*out*/
78 struct CameraInfo* cameraInfo) = 0;
Igor Murashkinbfc99152013-02-27 12:55:20 -080079
Zhijun He2b59be82013-09-25 10:14:30 -070080 virtual status_t getCameraCharacteristics(int cameraId,
Igor Murashkine1445da2014-03-17 14:00:29 -070081 /*out*/
82 CameraMetadata* cameraInfo) = 0;
Zhijun He2b59be82013-09-25 10:14:30 -070083
Igor Murashkine1445da2014-03-17 14:00:29 -070084 virtual status_t getCameraVendorTagDescriptor(
85 /*out*/
86 sp<VendorTagDescriptor>& desc) = 0;
Ruben Brunkd1176ef2014-02-21 10:51:38 -080087
Igor Murashkinbfc99152013-02-27 12:55:20 -080088 // Returns 'OK' if operation succeeded
89 // - Errors: ALREADY_EXISTS if the listener was already added
90 virtual status_t addListener(const sp<ICameraServiceListener>& listener)
91 = 0;
92 // Returns 'OK' if operation succeeded
93 // - Errors: BAD_VALUE if specified listener was not in the listener list
94 virtual status_t removeListener(const sp<ICameraServiceListener>& listener)
95 = 0;
Eino-Ville Talvalaceb388d2013-02-19 10:40:14 -080096 /**
97 * clientPackageName and clientUid are used for permissions checking. if
98 * clientUid == USE_CALLING_UID, then the calling UID is used instead. Only
99 * trusted callers can set a clientUid other than USE_CALLING_UID.
100 */
Ruben Brunk0f61d8f2013-08-08 13:07:18 -0700101 virtual status_t connect(const sp<ICameraClient>& cameraClient,
Eino-Ville Talvalaceb388d2013-02-19 10:40:14 -0800102 int cameraId,
103 const String16& clientPackageName,
Ruben Brunk0f61d8f2013-08-08 13:07:18 -0700104 int clientUid,
105 /*out*/
106 sp<ICamera>& device) = 0;
Igor Murashkin634a5152013-02-20 17:15:11 -0800107
Ruben Brunk0f61d8f2013-08-08 13:07:18 -0700108 virtual status_t connectPro(const sp<IProCameraCallbacks>& cameraCb,
Igor Murashkinc073ba52013-02-26 14:32:34 -0800109 int cameraId,
110 const String16& clientPackageName,
Ruben Brunk0f61d8f2013-08-08 13:07:18 -0700111 int clientUid,
112 /*out*/
113 sp<IProCameraUser>& device) = 0;
Igor Murashkine7ee7632013-06-11 18:10:18 -0700114
Ruben Brunk0f61d8f2013-08-08 13:07:18 -0700115 virtual status_t connectDevice(
Igor Murashkine7ee7632013-06-11 18:10:18 -0700116 const sp<ICameraDeviceCallbacks>& cameraCb,
117 int cameraId,
118 const String16& clientPackageName,
Ruben Brunk0f61d8f2013-08-08 13:07:18 -0700119 int clientUid,
120 /*out*/
121 sp<ICameraDeviceUser>& device) = 0;
Igor Murashkin65d14b92014-06-17 12:03:20 -0700122
123 virtual status_t getLegacyParameters(
124 int cameraId,
125 /*out*/
126 String16* parameters) = 0;
127
128 /**
129 * Returns OK if device supports camera2 api,
130 * returns -EOPNOTSUPP if it doesn't.
131 */
132 virtual status_t supportsCameraApi(
133 int cameraId, int apiVersion) = 0;
Zhijun Heb10cdad2014-06-16 16:38:35 -0700134
135 /**
136 * Connect the device as a legacy device for a given HAL version.
137 * For halVersion, use CAMERA_API_DEVICE_VERSION_* for a particular
138 * version, or CAMERA_HAL_API_VERSION_UNSPECIFIED for a service-selected version.
139 */
140 virtual status_t connectLegacy(const sp<ICameraClient>& cameraClient,
141 int cameraId, int halVersion,
142 const String16& clientPackageName,
143 int clientUid,
144 /*out*/
145 sp<ICamera>& device) = 0;
Chien-Yu Chen3068d732015-02-09 13:29:57 -0800146
147 /**
148 * Turn on or off a camera's torch mode.
149 */
150 virtual status_t setTorchMode(const String16& cameraId, bool enabled,
151 const sp<IBinder>& clientBinder) = 0;
Mathias Agopian3cf61352010-02-09 17:46:37 -0800152};
153
154// ----------------------------------------------------------------------------
155
156class BnCameraService: public BnInterface<ICameraService>
157{
158public:
159 virtual status_t onTransact( uint32_t code,
160 const Parcel& data,
161 Parcel* reply,
162 uint32_t flags = 0);
163};
164
165}; // namespace android
166
167#endif