blob: c7acdc95898e9b204cc70d75435f05747b8876fd [file] [log] [blame]
Mathias Agopian65ab4712010-07-14 17:59:35 -07001/*
Ruben Brunkd1176ef2014-02-21 10:51:38 -08002 * 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 */
Mathias Agopian65ab4712010-07-14 17:59:35 -070016
17#ifndef ANDROID_SERVERS_CAMERA_CAMERASERVICE_H
18#define ANDROID_SERVERS_CAMERA_CAMERASERVICE_H
19
Eino-Ville Talvalad56db1d2015-12-17 16:50:35 -080020#include <android/hardware/BnCameraService.h>
21#include <android/hardware/ICameraServiceListener.h>
22
Ruben Brunk36597b22015-03-20 22:15:57 -070023#include <cutils/multiuser.h>
Igor Murashkin634a5152013-02-20 17:15:11 -080024#include <utils/Vector.h>
Ruben Brunkb2119af2014-05-09 19:57:56 -070025#include <utils/KeyedVector.h>
Eino-Ville Talvalaceb388d2013-02-19 10:40:14 -080026#include <binder/AppOpsManager.h>
Mathias Agopian5462fc92010-07-14 18:41:18 -070027#include <binder/BinderService.h>
Eino-Ville Talvalaceb388d2013-02-19 10:40:14 -080028#include <binder/IAppOpsCallback.h>
Eino-Ville Talvala412fe562015-08-20 17:08:32 -070029#include <camera/ICameraServiceProxy.h>
Iliyan Malchev8951a972011-04-14 16:55:59 -070030#include <hardware/camera.h>
Mathias Agopian65ab4712010-07-14 17:59:35 -070031
Eino-Ville Talvalaf51fca22016-12-13 11:25:55 -080032#include <android/hardware/camera/common/1.0/types.h>
33
Ruben Brunkd1176ef2014-02-21 10:51:38 -080034#include <camera/VendorTagDescriptor.h>
Jianing Weicb0652e2014-03-12 18:29:36 -070035#include <camera/CaptureResult.h>
Ruben Brunkb2119af2014-05-09 19:57:56 -070036#include <camera/CameraParameters.h>
Igor Murashkinc073ba52013-02-26 14:32:34 -080037
Chien-Yu Chen3068d732015-02-09 13:29:57 -080038#include "CameraFlashlight.h"
39
Yin-Chia Yehe074a932015-01-30 10:29:02 -080040#include "common/CameraModule.h"
Eino-Ville Talvala2f09bac2016-12-13 11:29:54 -080041#include "common/CameraProviderManager.h"
Ronghua Wu022ed722015-05-11 15:15:09 -070042#include "media/RingBuffer.h"
Ruben Brunkcc776712015-02-17 20:18:47 -080043#include "utils/AutoConditionLock.h"
44#include "utils/ClientManager.h"
Yin-Chia Yehe074a932015-01-30 10:29:02 -080045
Ruben Brunkcc776712015-02-17 20:18:47 -080046#include <set>
47#include <string>
48#include <map>
49#include <memory>
Ruben Brunk99e69712015-05-26 17:25:07 -070050#include <utility>
Mathias Agopian65ab4712010-07-14 17:59:35 -070051
52namespace android {
53
Eino-Ville Talvala5e08d602012-05-16 14:59:25 -070054extern volatile int32_t gLogLevel;
55
Mathias Agopian65ab4712010-07-14 17:59:35 -070056class MemoryHeapBase;
57class MediaPlayer;
58
Mathias Agopian5462fc92010-07-14 18:41:18 -070059class CameraService :
60 public BinderService<CameraService>,
Eino-Ville Talvala2f09bac2016-12-13 11:29:54 -080061 public virtual ::android::hardware::BnCameraService,
62 public virtual IBinder::DeathRecipient,
63 public camera_module_callbacks_t,
64 public virtual CameraProviderManager::StatusListener
Mathias Agopian65ab4712010-07-14 17:59:35 -070065{
Mathias Agopian5462fc92010-07-14 18:41:18 -070066 friend class BinderService<CameraService>;
Eino-Ville Talvala2f09bac2016-12-13 11:29:54 -080067 friend class CameraClient;
Mathias Agopian65ab4712010-07-14 17:59:35 -070068public:
Eino-Ville Talvala5e08d602012-05-16 14:59:25 -070069 class Client;
Igor Murashkin634a5152013-02-20 17:15:11 -080070 class BasicClient;
71
Ruben Brunk0bbf8b22015-04-30 14:35:42 -070072 // The effective API level. The Camera2 API running in LEGACY mode counts as API_1.
Ruben Brunkcc776712015-02-17 20:18:47 -080073 enum apiLevel {
74 API_1 = 1,
75 API_2 = 2
76 };
77
Ruben Brunkcc776712015-02-17 20:18:47 -080078 // 3 second busy timeout when other clients are connecting
79 static const nsecs_t DEFAULT_CONNECT_TIMEOUT_NS = 3000000000;
80
Ruben Brunk4f9576b2015-04-10 17:26:56 -070081 // 1 second busy timeout when other clients are disconnecting
82 static const nsecs_t DEFAULT_DISCONNECT_TIMEOUT_NS = 1000000000;
83
Ruben Brunkcc776712015-02-17 20:18:47 -080084 // Default number of messages to store in eviction log
Ruben Brunka8ca9152015-04-07 14:23:40 -070085 static const size_t DEFAULT_EVENT_LOG_LENGTH = 100;
Ruben Brunkcc776712015-02-17 20:18:47 -080086
Eino-Ville Talvalac4003962016-01-13 10:07:04 -080087 // Event log ID
88 static const int SN_EVENT_LOG_ID = 0x534e4554;
89
Igor Murashkin634a5152013-02-20 17:15:11 -080090 // Implementation of BinderService<T>
Mathias Agopian5462fc92010-07-14 18:41:18 -070091 static char const* getServiceName() { return "media.camera"; }
Mathias Agopian65ab4712010-07-14 17:59:35 -070092
93 CameraService();
94 virtual ~CameraService();
95
Igor Murashkin634a5152013-02-20 17:15:11 -080096 /////////////////////////////////////////////////////////////////////
Eino-Ville Talvala2f09bac2016-12-13 11:29:54 -080097 // HAL Callbacks - implements CameraProviderManager::StatusListener
98
Eino-Ville Talvalaf51fca22016-12-13 11:25:55 -080099 virtual void onDeviceStatusChanged(const String8 &cameraId,
Eino-Ville Talvala2f09bac2016-12-13 11:29:54 -0800100 hardware::camera::common::V1_0::CameraDeviceStatus newHalStatus) override;
Chien-Yu Chen88da5262015-02-17 13:56:46 -0800101 virtual void onTorchStatusChanged(const String8& cameraId,
Eino-Ville Talvala2f09bac2016-12-13 11:29:54 -0800102 hardware::camera::common::V1_0::TorchModeStatus newStatus) override;
Igor Murashkincba2c162013-03-20 15:56:31 -0700103
104 /////////////////////////////////////////////////////////////////////
Igor Murashkin634a5152013-02-20 17:15:11 -0800105 // ICameraService
Eino-Ville Talvalad56db1d2015-12-17 16:50:35 -0800106 virtual binder::Status getNumberOfCameras(int32_t type, int32_t* numCameras);
Eino-Ville Talvalabad43582015-08-14 13:12:32 -0700107
Eino-Ville Talvalad56db1d2015-12-17 16:50:35 -0800108 virtual binder::Status getCameraInfo(int cameraId,
109 hardware::CameraInfo* cameraInfo);
Eino-Ville Talvala2f09bac2016-12-13 11:29:54 -0800110 virtual binder::Status getCameraCharacteristics(const String16& cameraId,
Eino-Ville Talvalad56db1d2015-12-17 16:50:35 -0800111 CameraMetadata* cameraInfo);
112 virtual binder::Status getCameraVendorTagDescriptor(
Ruben Brunk0f61d8f2013-08-08 13:07:18 -0700113 /*out*/
Eino-Ville Talvalad56db1d2015-12-17 16:50:35 -0800114 hardware::camera2::params::VendorTagDescriptor* desc);
Ruben Brunk0f61d8f2013-08-08 13:07:18 -0700115
Eino-Ville Talvalad56db1d2015-12-17 16:50:35 -0800116 virtual binder::Status connect(const sp<hardware::ICameraClient>& cameraClient,
117 int32_t cameraId, const String16& clientPackageName,
118 int32_t clientUid, int clientPid,
Zhijun Heb10cdad2014-06-16 16:38:35 -0700119 /*out*/
Eino-Ville Talvalad56db1d2015-12-17 16:50:35 -0800120 sp<hardware::ICamera>* device);
Zhijun Heb10cdad2014-06-16 16:38:35 -0700121
Eino-Ville Talvalad56db1d2015-12-17 16:50:35 -0800122 virtual binder::Status connectLegacy(const sp<hardware::ICameraClient>& cameraClient,
123 int32_t cameraId, int32_t halVersion,
124 const String16& clientPackageName, int32_t clientUid,
Ruben Brunk0f61d8f2013-08-08 13:07:18 -0700125 /*out*/
Eino-Ville Talvalad56db1d2015-12-17 16:50:35 -0800126 sp<hardware::ICamera>* device);
Mathias Agopian65ab4712010-07-14 17:59:35 -0700127
Eino-Ville Talvalad56db1d2015-12-17 16:50:35 -0800128 virtual binder::Status connectDevice(
Eino-Ville Talvalaf51fca22016-12-13 11:25:55 -0800129 const sp<hardware::camera2::ICameraDeviceCallbacks>& cameraCb, const String16& cameraId,
Eino-Ville Talvalad56db1d2015-12-17 16:50:35 -0800130 const String16& clientPackageName, int32_t clientUid,
131 /*out*/
132 sp<hardware::camera2::ICameraDeviceUser>* device);
Igor Murashkinbfc99152013-02-27 12:55:20 -0800133
Eino-Ville Talvalaf51fca22016-12-13 11:25:55 -0800134 virtual binder::Status addListener(const sp<hardware::ICameraServiceListener>& listener,
135 /*out*/
136 std::vector<hardware::CameraStatus>* cameraStatuses);
Eino-Ville Talvalad56db1d2015-12-17 16:50:35 -0800137 virtual binder::Status removeListener(
138 const sp<hardware::ICameraServiceListener>& listener);
139
140 virtual binder::Status getLegacyParameters(
141 int32_t cameraId,
Igor Murashkin65d14b92014-06-17 12:03:20 -0700142 /*out*/
143 String16* parameters);
144
Eino-Ville Talvalad56db1d2015-12-17 16:50:35 -0800145 virtual binder::Status setTorchMode(const String16& cameraId, bool enabled,
Chien-Yu Chen3068d732015-02-09 13:29:57 -0800146 const sp<IBinder>& clientBinder);
147
Eino-Ville Talvalad56db1d2015-12-17 16:50:35 -0800148 virtual binder::Status notifySystemEvent(int32_t eventId,
149 const std::vector<int32_t>& args);
Ruben Brunk36597b22015-03-20 22:15:57 -0700150
Igor Murashkin65d14b92014-06-17 12:03:20 -0700151 // OK = supports api of that version, -EOPNOTSUPP = does not support
Eino-Ville Talvalad56db1d2015-12-17 16:50:35 -0800152 virtual binder::Status supportsCameraApi(
Eino-Ville Talvalaf51fca22016-12-13 11:25:55 -0800153 const String16& cameraId, int32_t apiVersion,
Eino-Ville Talvalad56db1d2015-12-17 16:50:35 -0800154 /*out*/
155 bool *isSupported);
Igor Murashkin65d14b92014-06-17 12:03:20 -0700156
Igor Murashkin634a5152013-02-20 17:15:11 -0800157 // Extra permissions checks
Mathias Agopian65ab4712010-07-14 17:59:35 -0700158 virtual status_t onTransact(uint32_t code, const Parcel& data,
159 Parcel* reply, uint32_t flags);
Igor Murashkin634a5152013-02-20 17:15:11 -0800160
161 virtual status_t dump(int fd, const Vector<String16>& args);
162
163 /////////////////////////////////////////////////////////////////////
164 // Client functionality
Mathias Agopian65ab4712010-07-14 17:59:35 -0700165
166 enum sound_kind {
167 SOUND_SHUTTER = 0,
Chien-Yu Chen82104eb2015-10-14 11:29:31 -0700168 SOUND_RECORDING_START = 1,
169 SOUND_RECORDING_STOP = 2,
Mathias Agopian65ab4712010-07-14 17:59:35 -0700170 NUM_SOUNDS
171 };
172
173 void loadSound();
174 void playSound(sound_kind kind);
175 void releaseSound();
176
Eino-Ville Talvala412fe562015-08-20 17:08:32 -0700177 /**
178 * Update the state of a given camera device (open/close/active/idle) with
179 * the camera proxy service in the system service
180 */
181 static void updateProxyDeviceState(
182 ICameraServiceProxy::CameraState newState,
183 const String8& cameraId);
184
Igor Murashkin98e24722013-06-19 19:51:04 -0700185 /////////////////////////////////////////////////////////////////////
186 // CameraDeviceFactory functionality
Eino-Ville Talvala2f09bac2016-12-13 11:29:54 -0800187 int getDeviceVersion(const String8& cameraId, int* facing = NULL);
Igor Murashkin98e24722013-06-19 19:51:04 -0700188
Eino-Ville Talvalaf67e23e2014-07-23 17:17:59 -0700189 /////////////////////////////////////////////////////////////////////
190 // Shared utilities
Eino-Ville Talvalad56db1d2015-12-17 16:50:35 -0800191 static binder::Status filterGetInfoErrorCode(status_t err);
Igor Murashkin634a5152013-02-20 17:15:11 -0800192
193 /////////////////////////////////////////////////////////////////////
194 // CameraClient functionality
195
Igor Murashkin634a5152013-02-20 17:15:11 -0800196 class BasicClient : public virtual RefBase {
197 public:
Eino-Ville Talvalad56db1d2015-12-17 16:50:35 -0800198 virtual status_t initialize(CameraModule *module) = 0;
Eino-Ville Talvala2f09bac2016-12-13 11:29:54 -0800199 virtual status_t initialize(sp<CameraProviderManager> manager) = 0;
Eino-Ville Talvalad56db1d2015-12-17 16:50:35 -0800200 virtual binder::Status disconnect();
Igor Murashkin634a5152013-02-20 17:15:11 -0800201
Igor Murashkine7ee7632013-06-11 18:10:18 -0700202 // because we can't virtually inherit IInterface, which breaks
203 // virtual inheritance
Eino-Ville Talvalad56db1d2015-12-17 16:50:35 -0800204 virtual sp<IBinder> asBinderWrapper() = 0;
Igor Murashkine7ee7632013-06-11 18:10:18 -0700205
Ruben Brunk9efdf952015-03-18 23:11:57 -0700206 // Return the remote callback binder object (e.g. ICameraDeviceCallbacks)
Eino-Ville Talvalad56db1d2015-12-17 16:50:35 -0800207 sp<IBinder> getRemote() {
Igor Murashkin44cfcf02013-03-01 16:22:28 -0800208 return mRemoteBinder;
Igor Murashkin634a5152013-02-20 17:15:11 -0800209 }
210
Eino-Ville Talvalac4003962016-01-13 10:07:04 -0800211 // Disallows dumping over binder interface
Eino-Ville Talvalad56db1d2015-12-17 16:50:35 -0800212 virtual status_t dump(int fd, const Vector<String16>& args);
Eino-Ville Talvalac4003962016-01-13 10:07:04 -0800213 // Internal dump method to be called by CameraService
Eino-Ville Talvalad56db1d2015-12-17 16:50:35 -0800214 virtual status_t dumpClient(int fd, const Vector<String16>& args) = 0;
Igor Murashkine7ee7632013-06-11 18:10:18 -0700215
Ruben Brunkcc776712015-02-17 20:18:47 -0800216 // Return the package name for this client
217 virtual String16 getPackageName() const;
218
219 // Notify client about a fatal error
Eino-Ville Talvalad56db1d2015-12-17 16:50:35 -0800220 virtual void notifyError(int32_t errorCode,
Ruben Brunkcc776712015-02-17 20:18:47 -0800221 const CaptureResultExtras& resultExtras) = 0;
222
Ruben Brunk6267b532015-04-30 17:44:07 -0700223 // Get the UID of the application client using this
224 virtual uid_t getClientUid() const;
225
Ruben Brunkcc776712015-02-17 20:18:47 -0800226 // Get the PID of the application client using this
227 virtual int getClientPid() const;
Ruben Brunk0bbf8b22015-04-30 14:35:42 -0700228
229 // Check what API level is used for this client. This is used to determine which
230 // superclass this can be cast to.
231 virtual bool canCastToApiClient(apiLevel level) const;
Igor Murashkin634a5152013-02-20 17:15:11 -0800232 protected:
233 BasicClient(const sp<CameraService>& cameraService,
234 const sp<IBinder>& remoteCallback,
Svetoslav Ganov280405a2015-05-12 02:19:27 +0000235 const String16& clientPackageName,
Eino-Ville Talvala2f09bac2016-12-13 11:29:54 -0800236 const String8& cameraIdStr,
Igor Murashkin634a5152013-02-20 17:15:11 -0800237 int cameraFacing,
238 int clientPid,
Eino-Ville Talvalaceb388d2013-02-19 10:40:14 -0800239 uid_t clientUid,
Igor Murashkin634a5152013-02-20 17:15:11 -0800240 int servicePid);
241
242 virtual ~BasicClient();
243
244 // the instance is in the middle of destruction. When this is set,
245 // the instance should not be accessed from callback.
246 // CameraService's mClientLock should be acquired to access this.
247 // - subclasses should set this to true in their destructors.
248 bool mDestructionStarted;
249
250 // these are initialized in the constructor.
Eino-Ville Talvala2f09bac2016-12-13 11:29:54 -0800251 static sp<CameraService> sCameraService;
252 const String8 mCameraIdStr;
253 const int mCameraFacing;
254 String16 mClientPackageName;
Igor Murashkin634a5152013-02-20 17:15:11 -0800255 pid_t mClientPid;
Eino-Ville Talvala2f09bac2016-12-13 11:29:54 -0800256 const uid_t mClientUid;
257 const pid_t mServicePid;
Ruben Brunkcc776712015-02-17 20:18:47 -0800258 bool mDisconnected;
Igor Murashkin634a5152013-02-20 17:15:11 -0800259
260 // - The app-side Binder interface to receive callbacks from us
Igor Murashkine7ee7632013-06-11 18:10:18 -0700261 sp<IBinder> mRemoteBinder; // immutable after constructor
Eino-Ville Talvalaceb388d2013-02-19 10:40:14 -0800262
263 // permissions management
264 status_t startCameraOps();
265 status_t finishCameraOps();
266
Eino-Ville Talvalaceb388d2013-02-19 10:40:14 -0800267 private:
268 AppOpsManager mAppOpsManager;
269
270 class OpsCallback : public BnAppOpsCallback {
271 public:
Chih-Hung Hsieh8b0b9712016-08-09 14:25:53 -0700272 explicit OpsCallback(wp<BasicClient> client);
Eino-Ville Talvalaceb388d2013-02-19 10:40:14 -0800273 virtual void opChanged(int32_t op, const String16& packageName);
274
275 private:
276 wp<BasicClient> mClient;
277
278 }; // class OpsCallback
279
280 sp<OpsCallback> mOpsCallback;
281 // Track whether startCameraOps was called successfully, to avoid
282 // finishing what we didn't start.
283 bool mOpsActive;
284
285 // IAppOpsCallback interface, indirected through opListener
286 virtual void opChanged(int32_t op, const String16& packageName);
287 }; // class BasicClient
Igor Murashkin634a5152013-02-20 17:15:11 -0800288
Eino-Ville Talvalad56db1d2015-12-17 16:50:35 -0800289 class Client : public hardware::BnCamera, public BasicClient
Eino-Ville Talvala5e08d602012-05-16 14:59:25 -0700290 {
291 public:
Eino-Ville Talvalad56db1d2015-12-17 16:50:35 -0800292 typedef hardware::ICameraClient TCamCallbacks;
Igor Murashkin44cfcf02013-03-01 16:22:28 -0800293
Eino-Ville Talvala5e08d602012-05-16 14:59:25 -0700294 // ICamera interface (see ICamera for details)
Eino-Ville Talvalad56db1d2015-12-17 16:50:35 -0800295 virtual binder::Status disconnect();
296 virtual status_t connect(const sp<hardware::ICameraClient>& client) = 0;
Eino-Ville Talvala5e08d602012-05-16 14:59:25 -0700297 virtual status_t lock() = 0;
298 virtual status_t unlock() = 0;
Eino-Ville Talvala1ce7c342013-08-21 13:57:21 -0700299 virtual status_t setPreviewTarget(const sp<IGraphicBufferProducer>& bufferProducer)=0;
Eino-Ville Talvala5e08d602012-05-16 14:59:25 -0700300 virtual void setPreviewCallbackFlag(int flag) = 0;
Eino-Ville Talvala3ee35502013-04-02 15:45:11 -0700301 virtual status_t setPreviewCallbackTarget(
302 const sp<IGraphicBufferProducer>& callbackProducer) = 0;
Eino-Ville Talvala5e08d602012-05-16 14:59:25 -0700303 virtual status_t startPreview() = 0;
304 virtual void stopPreview() = 0;
305 virtual bool previewEnabled() = 0;
Chien-Yu Chen8cca0752015-11-13 15:28:48 -0800306 virtual status_t setVideoBufferMode(int32_t videoBufferMode) = 0;
Eino-Ville Talvala5e08d602012-05-16 14:59:25 -0700307 virtual status_t startRecording() = 0;
308 virtual void stopRecording() = 0;
309 virtual bool recordingEnabled() = 0;
310 virtual void releaseRecordingFrame(const sp<IMemory>& mem) = 0;
311 virtual status_t autoFocus() = 0;
312 virtual status_t cancelAutoFocus() = 0;
313 virtual status_t takePicture(int msgType) = 0;
314 virtual status_t setParameters(const String8& params) = 0;
315 virtual String8 getParameters() const = 0;
316 virtual status_t sendCommand(int32_t cmd, int32_t arg1, int32_t arg2) = 0;
Chien-Yu Chen8cca0752015-11-13 15:28:48 -0800317 virtual status_t setVideoTarget(const sp<IGraphicBufferProducer>& bufferProducer) = 0;
Eino-Ville Talvala5e08d602012-05-16 14:59:25 -0700318
319 // Interface used by CameraService
320 Client(const sp<CameraService>& cameraService,
Eino-Ville Talvalad56db1d2015-12-17 16:50:35 -0800321 const sp<hardware::ICameraClient>& cameraClient,
Svetoslav Ganov280405a2015-05-12 02:19:27 +0000322 const String16& clientPackageName,
Eino-Ville Talvala2f09bac2016-12-13 11:29:54 -0800323 const String8& cameraIdStr,
Eino-Ville Talvala5e08d602012-05-16 14:59:25 -0700324 int cameraFacing,
Igor Murashkinecf17e82012-10-02 16:05:11 -0700325 int clientPid,
Eino-Ville Talvalaceb388d2013-02-19 10:40:14 -0800326 uid_t clientUid,
Igor Murashkinecf17e82012-10-02 16:05:11 -0700327 int servicePid);
Eino-Ville Talvala5e08d602012-05-16 14:59:25 -0700328 ~Client();
329
330 // return our camera client
Eino-Ville Talvalad56db1d2015-12-17 16:50:35 -0800331 const sp<hardware::ICameraClient>& getRemoteCallback() {
Igor Murashkin44cfcf02013-03-01 16:22:28 -0800332 return mRemoteCallback;
Eino-Ville Talvala5e08d602012-05-16 14:59:25 -0700333 }
334
Igor Murashkine7ee7632013-06-11 18:10:18 -0700335 virtual sp<IBinder> asBinderWrapper() {
Marco Nelissen06b46062014-11-14 07:58:25 -0800336 return asBinder(this);
Igor Murashkine7ee7632013-06-11 18:10:18 -0700337 }
338
Eino-Ville Talvalad56db1d2015-12-17 16:50:35 -0800339 virtual void notifyError(int32_t errorCode,
Jianing Weicb0652e2014-03-12 18:29:36 -0700340 const CaptureResultExtras& resultExtras);
Ruben Brunk0bbf8b22015-04-30 14:35:42 -0700341
342 // Check what API level is used for this client. This is used to determine which
343 // superclass this can be cast to.
344 virtual bool canCastToApiClient(apiLevel level) const;
Ruben Brunkcc776712015-02-17 20:18:47 -0800345 protected:
Igor Murashkin634a5152013-02-20 17:15:11 -0800346 // Initialized in constructor
Eino-Ville Talvala5e08d602012-05-16 14:59:25 -0700347
Igor Murashkin634a5152013-02-20 17:15:11 -0800348 // - The app-side Binder interface to receive callbacks from us
Eino-Ville Talvalad56db1d2015-12-17 16:50:35 -0800349 sp<hardware::ICameraClient> mRemoteCallback;
Eino-Ville Talvalaceb388d2013-02-19 10:40:14 -0800350
Eino-Ville Talvala2f09bac2016-12-13 11:29:54 -0800351 int mCameraId; // All API1 clients use integer camera IDs
Eino-Ville Talvalaceb388d2013-02-19 10:40:14 -0800352 }; // class Client
Igor Murashkin634a5152013-02-20 17:15:11 -0800353
Ruben Brunk99e69712015-05-26 17:25:07 -0700354 /**
355 * A listener class that implements the LISTENER interface for use with a ClientManager, and
356 * implements the following methods:
357 * void onClientRemoved(const ClientDescriptor<KEY, VALUE>& descriptor);
358 * void onClientAdded(const ClientDescriptor<KEY, VALUE>& descriptor);
359 */
360 class ClientEventListener {
361 public:
362 void onClientAdded(const resource_policy::ClientDescriptor<String8,
363 sp<CameraService::BasicClient>>& descriptor);
364 void onClientRemoved(const resource_policy::ClientDescriptor<String8,
365 sp<CameraService::BasicClient>>& descriptor);
366 }; // class ClientEventListener
367
Ruben Brunkcc776712015-02-17 20:18:47 -0800368 typedef std::shared_ptr<resource_policy::ClientDescriptor<String8,
369 sp<CameraService::BasicClient>>> DescriptorPtr;
370
371 /**
372 * A container class for managing active camera clients that are using HAL devices. Active
373 * clients are represented by ClientDescriptor objects that contain strong pointers to the
374 * actual BasicClient subclass binder interface implementation.
375 *
376 * This class manages the eviction behavior for the camera clients. See the parent class
377 * implementation in utils/ClientManager for the specifics of this behavior.
378 */
Ruben Brunk99e69712015-05-26 17:25:07 -0700379 class CameraClientManager : public resource_policy::ClientManager<String8,
380 sp<CameraService::BasicClient>, ClientEventListener> {
Ruben Brunkcc776712015-02-17 20:18:47 -0800381 public:
Ruben Brunk99e69712015-05-26 17:25:07 -0700382 CameraClientManager();
Ruben Brunkcc776712015-02-17 20:18:47 -0800383 virtual ~CameraClientManager();
384
385 /**
386 * Return a strong pointer to the active BasicClient for this camera ID, or an empty
387 * if none exists.
388 */
389 sp<CameraService::BasicClient> getCameraClient(const String8& id) const;
390
391 /**
392 * Return a string describing the current state.
393 */
394 String8 toString() const;
395
396 /**
397 * Make a ClientDescriptor object wrapping the given BasicClient strong pointer.
398 */
399 static DescriptorPtr makeClientDescriptor(const String8& key, const sp<BasicClient>& value,
Emilian Peev8131a262017-02-01 12:33:43 +0000400 int32_t cost, const std::set<String8>& conflictingKeys, int32_t score,
401 int32_t ownerId, int32_t state);
Ruben Brunkcc776712015-02-17 20:18:47 -0800402
403 /**
404 * Make a ClientDescriptor object wrapping the given BasicClient strong pointer with
405 * values intialized from a prior ClientDescriptor.
406 */
407 static DescriptorPtr makeClientDescriptor(const sp<BasicClient>& value,
408 const CameraService::DescriptorPtr& partial);
409
410 }; // class CameraClientManager
411
Mathias Agopian65ab4712010-07-14 17:59:35 -0700412private:
Igor Murashkin634a5152013-02-20 17:15:11 -0800413
Eino-Ville Talvalaf51fca22016-12-13 11:25:55 -0800414 typedef hardware::camera::common::V1_0::CameraDeviceStatus CameraDeviceStatus;
415
416 /**
417 * Typesafe version of device status, containing both the HAL-layer and the service interface-
418 * layer values.
419 */
420 enum class StatusInternal : int32_t {
421 NOT_PRESENT = static_cast<int32_t>(CameraDeviceStatus::NOT_PRESENT),
422 PRESENT = static_cast<int32_t>(CameraDeviceStatus::PRESENT),
423 ENUMERATING = static_cast<int32_t>(CameraDeviceStatus::ENUMERATING),
424 NOT_AVAILABLE = static_cast<int32_t>(hardware::ICameraServiceListener::STATUS_NOT_AVAILABLE),
425 UNKNOWN = static_cast<int32_t>(hardware::ICameraServiceListener::STATUS_UNKNOWN)
426 };
427
Ruben Brunkcc776712015-02-17 20:18:47 -0800428 /**
429 * Container class for the state of each logical camera device, including: ID, status, and
430 * dependencies on other devices. The mapping of camera ID -> state saved in mCameraStates
431 * represents the camera devices advertised by the HAL (and any USB devices, when we add
432 * those).
433 *
434 * This container does NOT represent an active camera client. These are represented using
435 * the ClientDescriptors stored in mActiveClientManager.
436 */
437 class CameraState {
438 public:
Eino-Ville Talvala2f09bac2016-12-13 11:29:54 -0800439
Ruben Brunkcc776712015-02-17 20:18:47 -0800440 /**
441 * Make a new CameraState and set the ID, cost, and conflicting devices using the values
442 * returned in the HAL's camera_info struct for each device.
443 */
444 CameraState(const String8& id, int cost, const std::set<String8>& conflicting);
445 virtual ~CameraState();
446
447 /**
448 * Return the status for this device.
449 *
450 * This method acquires mStatusLock.
451 */
Eino-Ville Talvalaf51fca22016-12-13 11:25:55 -0800452 StatusInternal getStatus() const;
Ruben Brunkcc776712015-02-17 20:18:47 -0800453
454 /**
455 * This function updates the status for this camera device, unless the given status
456 * is in the given list of rejected status states, and execute the function passed in
Eino-Ville Talvalad56db1d2015-12-17 16:50:35 -0800457 * with a signature onStatusUpdateLocked(const String8&, int32_t)
Ruben Brunkcc776712015-02-17 20:18:47 -0800458 * if the status has changed.
459 *
460 * This method is idempotent, and will not result in the function passed to
461 * onStatusUpdateLocked being called more than once for the same arguments.
462 * This method aquires mStatusLock.
463 */
464 template<class Func>
Eino-Ville Talvalaf51fca22016-12-13 11:25:55 -0800465 void updateStatus(StatusInternal status,
466 const String8& cameraId,
467 std::initializer_list<StatusInternal> rejectSourceStates,
Ruben Brunkcc776712015-02-17 20:18:47 -0800468 Func onStatusUpdatedLocked);
469
470 /**
471 * Return the last set CameraParameters object generated from the information returned by
472 * the HAL for this device (or an empty CameraParameters object if none has been set).
473 */
474 CameraParameters getShimParams() const;
475
476 /**
477 * Set the CameraParameters for this device.
478 */
479 void setShimParams(const CameraParameters& params);
480
481 /**
482 * Return the resource_cost advertised by the HAL for this device.
483 */
484 int getCost() const;
485
486 /**
487 * Return a set of the IDs of conflicting devices advertised by the HAL for this device.
488 */
489 std::set<String8> getConflicting() const;
490
491 /**
492 * Return the ID of this camera device.
493 */
494 String8 getId() const;
495
496 private:
497 const String8 mId;
Eino-Ville Talvalaf51fca22016-12-13 11:25:55 -0800498 StatusInternal mStatus; // protected by mStatusLock
Ruben Brunkcc776712015-02-17 20:18:47 -0800499 const int mCost;
500 std::set<String8> mConflicting;
501 mutable Mutex mStatusLock;
502 CameraParameters mShimParams;
503 }; // class CameraState
504
Igor Murashkin634a5152013-02-20 17:15:11 -0800505 // Delay-load the Camera HAL module
506 virtual void onFirstRef();
507
Eino-Ville Talvala2f09bac2016-12-13 11:29:54 -0800508 // Load the legacy HAL module
509 status_t loadLegacyHalModule();
510
511 // Eumerate all camera providers in the system
512 status_t enumerateProviders();
513
Ruben Brunkcc776712015-02-17 20:18:47 -0800514 // Check if we can connect, before we acquire the service lock.
Chien-Yu Chen18df60e2016-03-18 18:18:09 -0700515 // The returned originalClientPid is the PID of the original process that wants to connect to
516 // camera.
517 // The returned clientPid is the PID of the client that directly connects to camera.
518 // originalClientPid and clientPid are usually the same except when the application uses
519 // mediaserver to connect to camera (using MediaRecorder to connect to camera). In that case,
520 // clientPid is the PID of mediaserver and originalClientPid is the PID of the application.
Eino-Ville Talvalad56db1d2015-12-17 16:50:35 -0800521 binder::Status validateConnectLocked(const String8& cameraId, const String8& clientName8,
Chien-Yu Chen7939aee2016-03-21 18:19:33 -0700522 /*inout*/int& clientUid, /*inout*/int& clientPid, /*out*/int& originalClientPid) const;
Eino-Ville Talvala04926862016-03-02 15:42:53 -0800523 binder::Status validateClientPermissionsLocked(const String8& cameraId, const String8& clientName8,
Chien-Yu Chen7939aee2016-03-21 18:19:33 -0700524 /*inout*/int& clientUid, /*inout*/int& clientPid, /*out*/int& originalClientPid) const;
Igor Murashkine6800ce2013-03-04 17:25:57 -0800525
Ruben Brunkcc776712015-02-17 20:18:47 -0800526 // Handle active client evictions, and update service state.
527 // Only call with with mServiceLock held.
528 status_t handleEvictionsLocked(const String8& cameraId, int clientPid,
529 apiLevel effectiveApiLevel, const sp<IBinder>& remoteCallback, const String8& packageName,
530 /*out*/
531 sp<BasicClient>* client,
532 std::shared_ptr<resource_policy::ClientDescriptor<String8, sp<BasicClient>>>* partial);
Igor Murashkine6800ce2013-03-04 17:25:57 -0800533
Ruben Brunkcc776712015-02-17 20:18:47 -0800534 // Single implementation shared between the various connect calls
535 template<class CALLBACK, class CLIENT>
Eino-Ville Talvalad56db1d2015-12-17 16:50:35 -0800536 binder::Status connectHelper(const sp<CALLBACK>& cameraCb, const String8& cameraId,
537 int halVersion, const String16& clientPackageName,
538 int clientUid, int clientPid,
Chien-Yu Chen98a668f2015-12-18 14:10:33 -0800539 apiLevel effectiveApiLevel, bool legacyMode, bool shimUpdateOnly,
540 /*out*/sp<CLIENT>& device);
Igor Murashkine6800ce2013-03-04 17:25:57 -0800541
Ruben Brunkcc776712015-02-17 20:18:47 -0800542 // Lock guarding camera service state
Mathias Agopian65ab4712010-07-14 17:59:35 -0700543 Mutex mServiceLock;
Ruben Brunkcc776712015-02-17 20:18:47 -0800544
545 // Condition to use with mServiceLock, used to handle simultaneous connect calls from clients
546 std::shared_ptr<WaitableMutexWrapper> mServiceLockWrapper;
547
548 // Return NO_ERROR if the device with a give ID can be connected to
549 status_t checkIfDeviceIsUsable(const String8& cameraId) const;
550
551 // Container for managing currently active application-layer clients
552 CameraClientManager mActiveClientManager;
553
554 // Mapping from camera ID -> state for each device, map is protected by mCameraStatesLock
555 std::map<String8, std::shared_ptr<CameraState>> mCameraStates;
556
557 // Mutex guarding mCameraStates map
558 mutable Mutex mCameraStatesLock;
559
560 // Circular buffer for storing event logging for dumps
561 RingBuffer<String8> mEventLog;
Ruben Brunka8ca9152015-04-07 14:23:40 -0700562 Mutex mLogLock;
Ruben Brunkcc776712015-02-17 20:18:47 -0800563
Ruben Brunk6267b532015-04-30 17:44:07 -0700564 // Currently allowed user IDs
565 std::set<userid_t> mAllowedUsers;
Ruben Brunk36597b22015-03-20 22:15:57 -0700566
Ruben Brunkcc776712015-02-17 20:18:47 -0800567 /**
Eino-Ville Talvalabad43582015-08-14 13:12:32 -0700568 * Check camera capabilities, such as support for basic color operation
569 */
570 int checkCameraCapabilities(int id, camera_info info, int *latestStrangeCameraId);
571
572 /**
Ruben Brunkcc776712015-02-17 20:18:47 -0800573 * Get the camera state for a given camera id.
574 *
575 * This acquires mCameraStatesLock.
576 */
577 std::shared_ptr<CameraService::CameraState> getCameraState(const String8& cameraId) const;
578
579 /**
580 * Evict client who's remote binder has died. Returns true if this client was in the active
581 * list and was disconnected.
582 *
583 * This method acquires mServiceLock.
584 */
585 bool evictClientIdByRemote(const wp<IBinder>& cameraClient);
586
587 /**
588 * Remove the given client from the active clients list; does not disconnect the client.
589 *
590 * This method acquires mServiceLock.
591 */
592 void removeByClient(const BasicClient* client);
593
594 /**
595 * Add new client to active clients list after conflicting clients have disconnected using the
596 * values set in the partial descriptor passed in to construct the actual client descriptor.
597 * This is typically called at the end of a connect call.
598 *
599 * This method must be called with mServiceLock held.
600 */
601 void finishConnectLocked(const sp<BasicClient>& client, const DescriptorPtr& desc);
602
603 /**
604 * Returns the integer corresponding to the given camera ID string, or -1 on failure.
605 */
606 static int cameraIdToInt(const String8& cameraId);
607
608 /**
609 * Remove a single client corresponding to the given camera id from the list of active clients.
610 * If none exists, return an empty strongpointer.
611 *
612 * This method must be called with mServiceLock held.
613 */
614 sp<CameraService::BasicClient> removeClientLocked(const String8& cameraId);
615
616 /**
Ruben Brunk36597b22015-03-20 22:15:57 -0700617 * Handle a notification that the current device user has changed.
618 */
Eino-Ville Talvalad56db1d2015-12-17 16:50:35 -0800619 void doUserSwitch(const std::vector<int32_t>& newUserIds);
Ruben Brunk36597b22015-03-20 22:15:57 -0700620
621 /**
Ruben Brunka8ca9152015-04-07 14:23:40 -0700622 * Add an event log message.
Ruben Brunkcc776712015-02-17 20:18:47 -0800623 */
Ruben Brunka8ca9152015-04-07 14:23:40 -0700624 void logEvent(const char* event);
Ruben Brunkcc776712015-02-17 20:18:47 -0800625
626 /**
Ruben Brunka8ca9152015-04-07 14:23:40 -0700627 * Add an event log message that a client has been disconnected.
Ruben Brunkcc776712015-02-17 20:18:47 -0800628 */
Ruben Brunka8ca9152015-04-07 14:23:40 -0700629 void logDisconnected(const char* cameraId, int clientPid, const char* clientPackage);
630
631 /**
632 * Add an event log message that a client has been connected.
633 */
634 void logConnected(const char* cameraId, int clientPid, const char* clientPackage);
635
636 /**
637 * Add an event log message that a client's connect attempt has been rejected.
638 */
639 void logRejected(const char* cameraId, int clientPid, const char* clientPackage,
640 const char* reason);
641
642 /**
643 * Add an event log message that the current device user has been switched.
644 */
Ruben Brunk6267b532015-04-30 17:44:07 -0700645 void logUserSwitch(const std::set<userid_t>& oldUserIds,
646 const std::set<userid_t>& newUserIds);
Ruben Brunka8ca9152015-04-07 14:23:40 -0700647
648 /**
649 * Add an event log message that a device has been removed by the HAL
650 */
651 void logDeviceRemoved(const char* cameraId, const char* reason);
652
653 /**
654 * Add an event log message that a device has been added by the HAL
655 */
656 void logDeviceAdded(const char* cameraId, const char* reason);
657
658 /**
659 * Add an event log message that a client has unexpectedly died.
660 */
661 void logClientDied(int clientPid, const char* reason);
Ruben Brunkcc776712015-02-17 20:18:47 -0800662
Eino-Ville Talvala1527f072015-04-07 15:55:31 -0700663 /**
664 * Add a event log message that a serious service-level error has occured
Eino-Ville Talvalad309fb92015-11-25 12:12:45 -0800665 * The errorCode should be one of the Android Errors
Eino-Ville Talvala1527f072015-04-07 15:55:31 -0700666 */
667 void logServiceError(const char* msg, int errorCode);
668
669 /**
670 * Dump the event log to an FD
671 */
672 void dumpEventLog(int fd);
673
Mathias Agopian65ab4712010-07-14 17:59:35 -0700674 int mNumberOfCameras;
Eino-Ville Talvalabad43582015-08-14 13:12:32 -0700675 int mNumberOfNormalCameras;
Mathias Agopian65ab4712010-07-14 17:59:35 -0700676
Mathias Agopian65ab4712010-07-14 17:59:35 -0700677 // sounds
Chih-Chung Changff4f55c2011-10-17 19:03:12 +0800678 MediaPlayer* newMediaPlayer(const char *file);
679
Mathias Agopian65ab4712010-07-14 17:59:35 -0700680 Mutex mSoundLock;
681 sp<MediaPlayer> mSoundPlayer[NUM_SOUNDS];
682 int mSoundRef; // reference count (release all MediaPlayer when 0)
683
Eino-Ville Talvala2f09bac2016-12-13 11:29:54 -0800684 // Basic flag on whether the camera subsystem is in a usable state
685 bool mInitialized;
686
687 CameraModule* mModule;
688 sp<CameraProviderManager> mCameraProviderManager;
Igor Murashkinecf17e82012-10-02 16:05:11 -0700689
Ruben Brunkcc776712015-02-17 20:18:47 -0800690 // Guarded by mStatusListenerMutex
Eino-Ville Talvalad56db1d2015-12-17 16:50:35 -0800691 std::vector<sp<hardware::ICameraServiceListener>> mListenerList;
Ruben Brunkcc776712015-02-17 20:18:47 -0800692 Mutex mStatusListenerLock;
Igor Murashkinbfc99152013-02-27 12:55:20 -0800693
Ruben Brunkcc776712015-02-17 20:18:47 -0800694 /**
695 * Update the status for the given camera id (if that device exists), and broadcast the
696 * status update to all current ICameraServiceListeners if the status has changed. Any
697 * statuses in rejectedSourceStates will be ignored.
698 *
699 * This method must be idempotent.
700 * This method acquires mStatusLock and mStatusListenerLock.
701 */
Eino-Ville Talvalaf51fca22016-12-13 11:25:55 -0800702 void updateStatus(StatusInternal status,
703 const String8& cameraId,
704 std::initializer_list<StatusInternal>
705 rejectedSourceStates);
706 void updateStatus(StatusInternal status,
707 const String8& cameraId);
Igor Murashkinbfc99152013-02-27 12:55:20 -0800708
Chien-Yu Chen3068d732015-02-09 13:29:57 -0800709 // flashlight control
710 sp<CameraFlashlight> mFlashlight;
Chien-Yu Chen88da5262015-02-17 13:56:46 -0800711 // guard mTorchStatusMap
Chien-Yu Chen3068d732015-02-09 13:29:57 -0800712 Mutex mTorchStatusMutex;
Chien-Yu Chenfe751be2015-09-01 14:16:44 -0700713 // guard mTorchClientMap
Chien-Yu Chen88da5262015-02-17 13:56:46 -0800714 Mutex mTorchClientMapMutex;
Chien-Yu Chenfe751be2015-09-01 14:16:44 -0700715 // guard mTorchUidMap
716 Mutex mTorchUidMapMutex;
Chien-Yu Chen3068d732015-02-09 13:29:57 -0800717 // camera id -> torch status
Eino-Ville Talvalaf51fca22016-12-13 11:25:55 -0800718 KeyedVector<String8, hardware::camera::common::V1_0::TorchModeStatus>
719 mTorchStatusMap;
Chien-Yu Chen3068d732015-02-09 13:29:57 -0800720 // camera id -> torch client binder
721 // only store the last client that turns on each camera's torch mode
Ruben Brunk99e69712015-05-26 17:25:07 -0700722 KeyedVector<String8, sp<IBinder>> mTorchClientMap;
723 // camera id -> [incoming uid, current uid] pair
724 std::map<String8, std::pair<int, int>> mTorchUidMap;
Chien-Yu Chen3068d732015-02-09 13:29:57 -0800725
726 // check and handle if torch client's process has died
727 void handleTorchClientBinderDied(const wp<IBinder> &who);
728
729 // handle torch mode status change and invoke callbacks. mTorchStatusMutex
730 // should be locked.
Chien-Yu Chen88da5262015-02-17 13:56:46 -0800731 void onTorchStatusChangedLocked(const String8& cameraId,
Eino-Ville Talvalaf51fca22016-12-13 11:25:55 -0800732 hardware::camera::common::V1_0::TorchModeStatus newStatus);
Chien-Yu Chen3068d732015-02-09 13:29:57 -0800733
734 // get a camera's torch status. mTorchStatusMutex should be locked.
Chien-Yu Chen88da5262015-02-17 13:56:46 -0800735 status_t getTorchStatusLocked(const String8 &cameraId,
Eino-Ville Talvalaf51fca22016-12-13 11:25:55 -0800736 hardware::camera::common::V1_0::TorchModeStatus *status) const;
Chien-Yu Chen3068d732015-02-09 13:29:57 -0800737
738 // set a camera's torch status. mTorchStatusMutex should be locked.
Chien-Yu Chen88da5262015-02-17 13:56:46 -0800739 status_t setTorchStatusLocked(const String8 &cameraId,
Eino-Ville Talvalaf51fca22016-12-13 11:25:55 -0800740 hardware::camera::common::V1_0::TorchModeStatus status);
Chien-Yu Chen3068d732015-02-09 13:29:57 -0800741
Igor Murashkinecf17e82012-10-02 16:05:11 -0700742 // IBinder::DeathRecipient implementation
Igor Murashkinbfc99152013-02-27 12:55:20 -0800743 virtual void binderDied(const wp<IBinder> &who);
Igor Murashkin634a5152013-02-20 17:15:11 -0800744
745 // Helpers
Igor Murashkinbfc99152013-02-27 12:55:20 -0800746
Ruben Brunkd1176ef2014-02-21 10:51:38 -0800747 bool setUpVendorTags();
Ruben Brunkb2119af2014-05-09 19:57:56 -0700748
749 /**
Ruben Brunkb2119af2014-05-09 19:57:56 -0700750 * Initialize and cache the metadata used by the HAL1 shim for a given cameraId.
751 *
Eino-Ville Talvalad56db1d2015-12-17 16:50:35 -0800752 * Sets Status to a service-specific error on failure
Ruben Brunkb2119af2014-05-09 19:57:56 -0700753 */
Eino-Ville Talvalad56db1d2015-12-17 16:50:35 -0800754 binder::Status initializeShimMetadata(int cameraId);
Ruben Brunkb2119af2014-05-09 19:57:56 -0700755
756 /**
Igor Murashkin65d14b92014-06-17 12:03:20 -0700757 * Get the cached CameraParameters for the camera. If they haven't been
758 * cached yet, then initialize them for the first time.
759 *
Eino-Ville Talvalad56db1d2015-12-17 16:50:35 -0800760 * Sets Status to a service-specific error on failure
Igor Murashkin65d14b92014-06-17 12:03:20 -0700761 */
Eino-Ville Talvalad56db1d2015-12-17 16:50:35 -0800762 binder::Status getLegacyParametersLazy(int cameraId, /*out*/CameraParameters* parameters);
Igor Murashkin65d14b92014-06-17 12:03:20 -0700763
Ruben Brunkcc776712015-02-17 20:18:47 -0800764 static int getCallingPid();
765
766 static int getCallingUid();
767
Ruben Brunkb2119af2014-05-09 19:57:56 -0700768 /**
Ruben Brunkcc776712015-02-17 20:18:47 -0800769 * Get the current system time as a formatted string.
Ruben Brunkb2119af2014-05-09 19:57:56 -0700770 */
Ruben Brunkcc776712015-02-17 20:18:47 -0800771 static String8 getFormattedCurrentTime();
772
Eino-Ville Talvalad56db1d2015-12-17 16:50:35 -0800773 static binder::Status makeClient(const sp<CameraService>& cameraService,
Eino-Ville Talvala2f09bac2016-12-13 11:29:54 -0800774 const sp<IInterface>& cameraCb, const String16& packageName, const String8& cameraId,
Ruben Brunkcc776712015-02-17 20:18:47 -0800775 int facing, int clientPid, uid_t clientUid, int servicePid, bool legacyMode,
776 int halVersion, int deviceVersion, apiLevel effectiveApiLevel,
777 /*out*/sp<BasicClient>* client);
Ruben Brunk6267b532015-04-30 17:44:07 -0700778
779 status_t checkCameraAccess(const String16& opPackageName);
780
781 static String8 toString(std::set<userid_t> intSet);
Eino-Ville Talvalaf51fca22016-12-13 11:25:55 -0800782 static int32_t mapToInterface(hardware::camera::common::V1_0::TorchModeStatus status);
783 static StatusInternal mapToInternal(hardware::camera::common::V1_0::CameraDeviceStatus status);
784 static int32_t mapToInterface(StatusInternal status);
Ruben Brunk6267b532015-04-30 17:44:07 -0700785
Eino-Ville Talvala412fe562015-08-20 17:08:32 -0700786 static sp<ICameraServiceProxy> getCameraServiceProxy();
Ruben Brunk2823ce02015-05-19 17:25:13 -0700787 static void pingCameraServiceProxy();
788
Mathias Agopian65ab4712010-07-14 17:59:35 -0700789};
790
Mathias Agopian65ab4712010-07-14 17:59:35 -0700791} // namespace android
792
793#endif