blob: a29f3a6febca6787157530b20f23b3a939f9c154 [file] [log] [blame]
Igor Murashkin44cfcf02013-03-01 16:22:28 -08001/*
2 * Copyright (C) 2013 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#define LOG_TAG "Camera2ClientBase"
18#define ATRACE_TAG ATRACE_TAG_CAMERA
19//#define LOG_NDEBUG 0
20
Colin Crosse5729fa2014-03-21 15:04:25 -070021#include <inttypes.h>
22
Igor Murashkin44cfcf02013-03-01 16:22:28 -080023#include <utils/Log.h>
24#include <utils/Trace.h>
25
26#include <cutils/properties.h>
27#include <gui/Surface.h>
28#include <gui/Surface.h>
Igor Murashkin44cfcf02013-03-01 16:22:28 -080029
Shuzhen Wang316781a2020-08-18 18:11:01 -070030#include <camera/CameraSessionStats.h>
31
Eino-Ville Talvala7b82efe2013-07-25 17:12:35 -070032#include "common/Camera2ClientBase.h"
Igor Murashkine7ee7632013-06-11 18:10:18 -070033
Eino-Ville Talvala7b82efe2013-07-25 17:12:35 -070034#include "api2/CameraDeviceClient.h"
35
Eino-Ville Talvalad309fb92015-11-25 12:12:45 -080036#include "device3/Camera3Device.h"
Jayant Chowdhary35642f22022-01-08 00:39:39 +000037#include "device3/aidl/AidlCamera3Device.h"
Jayant Chowdhary22441f32021-12-26 18:35:41 -080038#include "device3/hidl/HidlCamera3Device.h"
Jayant Chowdhary12361932018-08-27 14:46:13 -070039#include "utils/CameraThreadState.h"
Shuzhen Wang316781a2020-08-18 18:11:01 -070040#include "utils/CameraServiceProxyWrapper.h"
Igor Murashkin44cfcf02013-03-01 16:22:28 -080041
42namespace android {
43using namespace camera2;
44
Igor Murashkin44cfcf02013-03-01 16:22:28 -080045// Interface used by CameraService
46
47template <typename TClientBase>
48Camera2ClientBase<TClientBase>::Camera2ClientBase(
49 const sp<CameraService>& cameraService,
50 const sp<TCamCallbacks>& remoteCallback,
51 const String16& clientPackageName,
Jayant Chowdharyeb0169f2022-01-31 00:00:02 -080052 bool systemNativeClient,
Jooyung Han3f9a3b42020-01-23 12:27:18 +090053 const std::optional<String16>& clientFeatureId,
Eino-Ville Talvala2f09bac2016-12-13 11:29:54 -080054 const String8& cameraId,
Yin-Chia Yehc3e9d6f2018-02-06 10:56:32 -080055 int api1CameraId,
Igor Murashkin44cfcf02013-03-01 16:22:28 -080056 int cameraFacing,
Emilian Peev8b64f282021-03-25 16:49:57 -070057 int sensorOrientation,
Igor Murashkin44cfcf02013-03-01 16:22:28 -080058 int clientPid,
59 uid_t clientUid,
Shuzhen Wangd4abdf72021-05-28 11:22:50 -070060 int servicePid,
Emilian Peev5104fe92021-10-21 14:27:09 -070061 bool overrideForPerfClass,
62 bool legacyClient):
Jayant Chowdharyeb0169f2022-01-31 00:00:02 -080063 TClientBase(cameraService, remoteCallback, clientPackageName, systemNativeClient,
64 clientFeatureId, cameraId, api1CameraId, cameraFacing, sensorOrientation, clientPid,
65 clientUid, servicePid),
Yin-Chia Yehcd8fce82014-06-18 10:51:34 -070066 mSharedCameraCallbacks(remoteCallback),
Eino-Ville Talvala2f09bac2016-12-13 11:29:54 -080067 mDeviceVersion(cameraService->getDeviceVersion(TClientBase::mCameraIdStr)),
Yin-Chia Yehc3e9d6f2018-02-06 10:56:32 -080068 mDeviceActive(false), mApi1CameraId(api1CameraId)
Igor Murashkin44cfcf02013-03-01 16:22:28 -080069{
Eino-Ville Talvala2f09bac2016-12-13 11:29:54 -080070 ALOGI("Camera %s: Opened. Client: %s (PID %d, UID %d)", cameraId.string(),
Eino-Ville Talvalab9d2f332014-09-18 17:24:22 -070071 String8(clientPackageName).string(), clientPid, clientUid);
Igor Murashkin98e24722013-06-19 19:51:04 -070072
Eino-Ville Talvalab9d2f332014-09-18 17:24:22 -070073 mInitialClientPid = clientPid;
Jayant Chowdhary22441f32021-12-26 18:35:41 -080074 mOverrideForPerfClass = overrideForPerfClass;
75 mLegacyClient = legacyClient;
Igor Murashkin44cfcf02013-03-01 16:22:28 -080076}
77
78template <typename TClientBase>
79status_t Camera2ClientBase<TClientBase>::checkPid(const char* checkLocation)
80 const {
81
Jayant Chowdhary12361932018-08-27 14:46:13 -070082 int callingPid = CameraThreadState::getCallingPid();
Igor Murashkin44cfcf02013-03-01 16:22:28 -080083 if (callingPid == TClientBase::mClientPid) return NO_ERROR;
84
85 ALOGE("%s: attempt to use a locked camera from a different process"
86 " (old pid %d, new pid %d)", checkLocation, TClientBase::mClientPid, callingPid);
87 return PERMISSION_DENIED;
88}
89
90template <typename TClientBase>
Emilian Peevbd8c5032018-02-14 23:05:40 +000091status_t Camera2ClientBase<TClientBase>::initialize(sp<CameraProviderManager> manager,
92 const String8& monitorTags) {
93 return initializeImpl(manager, monitorTags);
Eino-Ville Talvala2f09bac2016-12-13 11:29:54 -080094}
95
96template <typename TClientBase>
97template <typename TProviderPtr>
Emilian Peevbd8c5032018-02-14 23:05:40 +000098status_t Camera2ClientBase<TClientBase>::initializeImpl(TProviderPtr providerPtr,
99 const String8& monitorTags) {
Igor Murashkin44cfcf02013-03-01 16:22:28 -0800100 ATRACE_CALL();
Eino-Ville Talvala2f09bac2016-12-13 11:29:54 -0800101 ALOGV("%s: Initializing client for camera %s", __FUNCTION__,
102 TClientBase::mCameraIdStr.string());
Igor Murashkin44cfcf02013-03-01 16:22:28 -0800103 status_t res;
104
Igor Murashkine6800ce2013-03-04 17:25:57 -0800105 // Verify ops permissions
106 res = TClientBase::startCameraOps();
107 if (res != OK) {
108 return res;
109 }
Jayant Chowdhary22441f32021-12-26 18:35:41 -0800110 IPCTransport providerTransport = IPCTransport::INVALID;
111 res = providerPtr->getCameraIdIPCTransport(TClientBase::mCameraIdStr.string(),
112 &providerTransport);
113 if (res != OK) {
114 return res;
115 }
116 switch (providerTransport) {
117 case IPCTransport::HIDL:
118 mDevice =
119 new HidlCamera3Device(TClientBase::mCameraIdStr, mOverrideForPerfClass,
120 mLegacyClient);
121 break;
122 case IPCTransport::AIDL:
Jayant Chowdhary35642f22022-01-08 00:39:39 +0000123 mDevice =
124 new AidlCamera3Device(TClientBase::mCameraIdStr, mOverrideForPerfClass,
125 mLegacyClient);
126 break;
Jayant Chowdhary22441f32021-12-26 18:35:41 -0800127 default:
128 ALOGE("%s Invalid transport for camera id %s", __FUNCTION__,
129 TClientBase::mCameraIdStr.string());
130 return NO_INIT;
131 }
Igor Murashkine6800ce2013-03-04 17:25:57 -0800132 if (mDevice == NULL) {
Eino-Ville Talvala2f09bac2016-12-13 11:29:54 -0800133 ALOGE("%s: Camera %s: No device connected",
134 __FUNCTION__, TClientBase::mCameraIdStr.string());
Igor Murashkine6800ce2013-03-04 17:25:57 -0800135 return NO_INIT;
136 }
137
Emilian Peevbd8c5032018-02-14 23:05:40 +0000138 res = mDevice->initialize(providerPtr, monitorTags);
Igor Murashkin44cfcf02013-03-01 16:22:28 -0800139 if (res != OK) {
Eino-Ville Talvala2f09bac2016-12-13 11:29:54 -0800140 ALOGE("%s: Camera %s: unable to initialize device: %s (%d)",
141 __FUNCTION__, TClientBase::mCameraIdStr.string(), strerror(-res), res);
Zhijun He66281c32013-09-13 17:59:59 -0700142 return res;
Igor Murashkin44cfcf02013-03-01 16:22:28 -0800143 }
144
Yin-Chia Yeh5fd603e2019-11-20 11:22:27 -0800145 wp<NotificationListener> weakThis(this);
Yin-Chia Yehe1c80632016-08-08 14:48:05 -0700146 res = mDevice->setNotifyCallback(weakThis);
Igor Murashkin44cfcf02013-03-01 16:22:28 -0800147
148 return OK;
149}
150
151template <typename TClientBase>
152Camera2ClientBase<TClientBase>::~Camera2ClientBase() {
153 ATRACE_CALL();
154
155 TClientBase::mDestructionStarted = true;
156
157 disconnect();
158
Eino-Ville Talvala2f09bac2016-12-13 11:29:54 -0800159 ALOGI("Closed Camera %s. Client was: %s (PID %d, UID %u)",
160 TClientBase::mCameraIdStr.string(),
Svetoslav Ganov280405a2015-05-12 02:19:27 +0000161 String8(TClientBase::mClientPackageName).string(),
Eino-Ville Talvalab9d2f332014-09-18 17:24:22 -0700162 mInitialClientPid, TClientBase::mClientUid);
Igor Murashkin44cfcf02013-03-01 16:22:28 -0800163}
164
165template <typename TClientBase>
Eino-Ville Talvalac4003962016-01-13 10:07:04 -0800166status_t Camera2ClientBase<TClientBase>::dumpClient(int fd,
Igor Murashkin44cfcf02013-03-01 16:22:28 -0800167 const Vector<String16>& args) {
168 String8 result;
Eino-Ville Talvala2f09bac2016-12-13 11:29:54 -0800169 result.appendFormat("Camera2ClientBase[%s] (%p) PID: %d, dump:\n",
170 TClientBase::mCameraIdStr.string(),
Eino-Ville Talvalae992e752014-11-07 16:17:48 -0800171 (TClientBase::getRemoteCallback() != NULL ?
Marco Nelissen06b46062014-11-14 07:58:25 -0800172 IInterface::asBinder(TClientBase::getRemoteCallback()).get() : NULL),
Igor Murashkin44cfcf02013-03-01 16:22:28 -0800173 TClientBase::mClientPid);
174 result.append(" State: ");
175
176 write(fd, result.string(), result.size());
177 // TODO: print dynamic/request section from most recent requests
178
179 return dumpDevice(fd, args);
180}
181
182template <typename TClientBase>
Avichal Rakesh7e53cad2021-10-05 13:46:30 -0700183status_t Camera2ClientBase<TClientBase>::startWatchingTags(const String8 &tags, int out) {
184 sp<CameraDeviceBase> device = mDevice;
185 if (!device) {
186 dprintf(out, " Device is detached");
187 return OK;
188 }
189
190 return device->startWatchingTags(tags);
191}
192
193template <typename TClientBase>
194status_t Camera2ClientBase<TClientBase>::stopWatchingTags(int out) {
195 sp<CameraDeviceBase> device = mDevice;
196 if (!device) {
197 dprintf(out, " Device is detached");
198 return OK;
199 }
200
201 return device->stopWatchingTags();
202}
203
204template <typename TClientBase>
205status_t Camera2ClientBase<TClientBase>::dumpWatchedEventsToVector(std::vector<std::string> &out) {
206 sp<CameraDeviceBase> device = mDevice;
207 if (!device) {
208 // Nothing to dump if the device is detached
209 return OK;
210 }
211 return device->dumpWatchedEventsToVector(out);
212}
213
214template <typename TClientBase>
Igor Murashkin44cfcf02013-03-01 16:22:28 -0800215status_t Camera2ClientBase<TClientBase>::dumpDevice(
216 int fd,
217 const Vector<String16>& args) {
218 String8 result;
219
220 result = " Device dump:\n";
221 write(fd, result.string(), result.size());
222
Yin-Chia Yehe5138f12017-11-10 14:10:05 -0800223 sp<CameraDeviceBase> device = mDevice;
224 if (!device.get()) {
Igor Murashkin44cfcf02013-03-01 16:22:28 -0800225 result = " *** Device is detached\n";
226 write(fd, result.string(), result.size());
227 return NO_ERROR;
228 }
229
Yin-Chia Yehe5138f12017-11-10 14:10:05 -0800230 status_t res = device->dump(fd, args);
Igor Murashkin44cfcf02013-03-01 16:22:28 -0800231 if (res != OK) {
232 result = String8::format(" Error dumping device: %s (%d)",
233 strerror(-res), res);
234 write(fd, result.string(), result.size());
235 }
236
237 return NO_ERROR;
238}
239
240// ICameraClient2BaseUser interface
241
242
243template <typename TClientBase>
Eino-Ville Talvalad56db1d2015-12-17 16:50:35 -0800244binder::Status Camera2ClientBase<TClientBase>::disconnect() {
Igor Murashkin44cfcf02013-03-01 16:22:28 -0800245 ATRACE_CALL();
246 Mutex::Autolock icl(mBinderSerializationLock);
247
Eino-Ville Talvalad56db1d2015-12-17 16:50:35 -0800248 binder::Status res = binder::Status::ok();
Igor Murashkin44cfcf02013-03-01 16:22:28 -0800249 // Allow both client and the media server to disconnect at all times
Jayant Chowdhary12361932018-08-27 14:46:13 -0700250 int callingPid = CameraThreadState::getCallingPid();
Igor Murashkin44cfcf02013-03-01 16:22:28 -0800251 if (callingPid != TClientBase::mClientPid &&
Eino-Ville Talvalad56db1d2015-12-17 16:50:35 -0800252 callingPid != TClientBase::mServicePid) return res;
Igor Murashkin44cfcf02013-03-01 16:22:28 -0800253
Eino-Ville Talvala2f09bac2016-12-13 11:29:54 -0800254 ALOGV("Camera %s: Shutting down", TClientBase::mCameraIdStr.string());
Igor Murashkin44cfcf02013-03-01 16:22:28 -0800255
Rucha Katakwardf223072021-06-15 10:21:00 -0700256 // Before detaching the device, cache the info from current open session.
257 // The disconnected check avoids duplication of info and also prevents
258 // deadlock while acquiring service lock in cacheDump.
259 if (!TClientBase::mDisconnected) {
260 Camera2ClientBase::getCameraService()->cacheDump();
261 }
262
Igor Murashkin44cfcf02013-03-01 16:22:28 -0800263 detachDevice();
264
Igor Murashkine6800ce2013-03-04 17:25:57 -0800265 CameraService::BasicClient::disconnect();
Igor Murashkin44cfcf02013-03-01 16:22:28 -0800266
Shuzhen Wang316781a2020-08-18 18:11:01 -0700267 ALOGV("Camera %s: Shut down complete", TClientBase::mCameraIdStr.string());
Eino-Ville Talvalad56db1d2015-12-17 16:50:35 -0800268
269 return res;
Igor Murashkin44cfcf02013-03-01 16:22:28 -0800270}
271
272template <typename TClientBase>
273void Camera2ClientBase<TClientBase>::detachDevice() {
274 if (mDevice == 0) return;
275 mDevice->disconnect();
276
Eino-Ville Talvala2f09bac2016-12-13 11:29:54 -0800277 ALOGV("Camera %s: Detach complete", TClientBase::mCameraIdStr.string());
Igor Murashkin44cfcf02013-03-01 16:22:28 -0800278}
279
280template <typename TClientBase>
281status_t Camera2ClientBase<TClientBase>::connect(
282 const sp<TCamCallbacks>& client) {
283 ATRACE_CALL();
284 ALOGV("%s: E", __FUNCTION__);
285 Mutex::Autolock icl(mBinderSerializationLock);
286
287 if (TClientBase::mClientPid != 0 &&
Jayant Chowdhary12361932018-08-27 14:46:13 -0700288 CameraThreadState::getCallingPid() != TClientBase::mClientPid) {
Igor Murashkin44cfcf02013-03-01 16:22:28 -0800289
Eino-Ville Talvala2f09bac2016-12-13 11:29:54 -0800290 ALOGE("%s: Camera %s: Connection attempt from pid %d; "
Igor Murashkin44cfcf02013-03-01 16:22:28 -0800291 "current locked to pid %d",
292 __FUNCTION__,
Eino-Ville Talvala2f09bac2016-12-13 11:29:54 -0800293 TClientBase::mCameraIdStr.string(),
Jayant Chowdhary12361932018-08-27 14:46:13 -0700294 CameraThreadState::getCallingPid(),
Igor Murashkin44cfcf02013-03-01 16:22:28 -0800295 TClientBase::mClientPid);
296 return BAD_VALUE;
297 }
298
Jayant Chowdhary12361932018-08-27 14:46:13 -0700299 TClientBase::mClientPid = CameraThreadState::getCallingPid();
Igor Murashkin44cfcf02013-03-01 16:22:28 -0800300
301 TClientBase::mRemoteCallback = client;
302 mSharedCameraCallbacks = client;
303
304 return OK;
305}
306
307/** Device-related methods */
308
309template <typename TClientBase>
Jianing Weicb0652e2014-03-12 18:29:36 -0700310void Camera2ClientBase<TClientBase>::notifyError(
Eino-Ville Talvalad56db1d2015-12-17 16:50:35 -0800311 int32_t errorCode,
Jianing Weicb0652e2014-03-12 18:29:36 -0700312 const CaptureResultExtras& resultExtras) {
313 ALOGE("Error condition %d reported by HAL, requestId %" PRId32, errorCode,
314 resultExtras.requestId);
Igor Murashkin44cfcf02013-03-01 16:22:28 -0800315}
316
317template <typename TClientBase>
Eino-Ville Talvala178e8232021-04-16 18:41:39 -0700318status_t Camera2ClientBase<TClientBase>::notifyActive() {
319 if (!mDeviceActive) {
320 status_t res = TClientBase::startCameraStreamingOps();
321 if (res != OK) {
322 ALOGE("%s: Camera %s: Error starting camera streaming ops: %d", __FUNCTION__,
323 TClientBase::mCameraIdStr.string(), res);
324 return res;
325 }
326 CameraServiceProxyWrapper::logActive(TClientBase::mCameraIdStr);
327 }
328 mDeviceActive = true;
329
330 ALOGV("Camera device is now active");
331 return OK;
332}
333
334template <typename TClientBase>
Shuzhen Wang316781a2020-08-18 18:11:01 -0700335void Camera2ClientBase<TClientBase>::notifyIdle(
336 int64_t requestCount, int64_t resultErrorCount, bool deviceError,
337 const std::vector<hardware::CameraStreamStats>& streamStats) {
Eino-Ville Talvala412fe562015-08-20 17:08:32 -0700338 if (mDeviceActive) {
Eino-Ville Talvala178e8232021-04-16 18:41:39 -0700339 status_t res = TClientBase::finishCameraStreamingOps();
340 if (res != OK) {
341 ALOGE("%s: Camera %s: Error finishing streaming ops: %d", __FUNCTION__,
342 TClientBase::mCameraIdStr.string(), res);
343 }
Shuzhen Wang316781a2020-08-18 18:11:01 -0700344 CameraServiceProxyWrapper::logIdle(TClientBase::mCameraIdStr,
345 requestCount, resultErrorCount, deviceError, streamStats);
Eino-Ville Talvala412fe562015-08-20 17:08:32 -0700346 }
347 mDeviceActive = false;
348
Eino-Ville Talvalaf1e98d82013-09-06 09:32:43 -0700349 ALOGV("Camera device is now idle");
350}
351
352template <typename TClientBase>
Jianing Weicb0652e2014-03-12 18:29:36 -0700353void Camera2ClientBase<TClientBase>::notifyShutter(const CaptureResultExtras& resultExtras,
Igor Murashkin44cfcf02013-03-01 16:22:28 -0800354 nsecs_t timestamp) {
Jianing Weicb0652e2014-03-12 18:29:36 -0700355 (void)resultExtras;
Igor Murashkin44cfcf02013-03-01 16:22:28 -0800356 (void)timestamp;
357
Jianing Weicb0652e2014-03-12 18:29:36 -0700358 ALOGV("%s: Shutter notification for request id %" PRId32 " at time %" PRId64,
359 __FUNCTION__, resultExtras.requestId, timestamp);
Igor Murashkin44cfcf02013-03-01 16:22:28 -0800360}
361
362template <typename TClientBase>
363void Camera2ClientBase<TClientBase>::notifyAutoFocus(uint8_t newState,
364 int triggerId) {
365 (void)newState;
366 (void)triggerId;
367
368 ALOGV("%s: Autofocus state now %d, last trigger %d",
369 __FUNCTION__, newState, triggerId);
370
Igor Murashkin44cfcf02013-03-01 16:22:28 -0800371}
372
373template <typename TClientBase>
374void Camera2ClientBase<TClientBase>::notifyAutoExposure(uint8_t newState,
375 int triggerId) {
376 (void)newState;
377 (void)triggerId;
378
379 ALOGV("%s: Autoexposure state now %d, last trigger %d",
380 __FUNCTION__, newState, triggerId);
381}
382
383template <typename TClientBase>
384void Camera2ClientBase<TClientBase>::notifyAutoWhitebalance(uint8_t newState,
385 int triggerId) {
386 (void)newState;
387 (void)triggerId;
388
389 ALOGV("%s: Auto-whitebalance state now %d, last trigger %d",
390 __FUNCTION__, newState, triggerId);
391}
392
393template <typename TClientBase>
Eino-Ville Talvala4d44cad2015-04-11 13:15:45 -0700394void Camera2ClientBase<TClientBase>::notifyPrepared(int streamId) {
395 (void)streamId;
396
397 ALOGV("%s: Stream %d now prepared",
398 __FUNCTION__, streamId);
399}
400
401template <typename TClientBase>
Shuzhen Wang9d066012016-09-30 11:30:20 -0700402void Camera2ClientBase<TClientBase>::notifyRequestQueueEmpty() {
403
404 ALOGV("%s: Request queue now empty", __FUNCTION__);
405}
406
407template <typename TClientBase>
Chien-Yu Chene8c535e2016-04-14 12:18:26 -0700408void Camera2ClientBase<TClientBase>::notifyRepeatingRequestError(long lastFrameNumber) {
409 (void)lastFrameNumber;
410
411 ALOGV("%s: Repeating request was stopped. Last frame number is %ld",
412 __FUNCTION__, lastFrameNumber);
413}
414
415template <typename TClientBase>
Igor Murashkin44cfcf02013-03-01 16:22:28 -0800416int Camera2ClientBase<TClientBase>::getCameraId() const {
Yin-Chia Yehc3e9d6f2018-02-06 10:56:32 -0800417 return mApi1CameraId;
Igor Murashkin44cfcf02013-03-01 16:22:28 -0800418}
419
420template <typename TClientBase>
Yin-Chia Yehcd8fce82014-06-18 10:51:34 -0700421int Camera2ClientBase<TClientBase>::getCameraDeviceVersion() const {
422 return mDeviceVersion;
423}
424
425template <typename TClientBase>
Igor Murashkin44cfcf02013-03-01 16:22:28 -0800426const sp<CameraDeviceBase>& Camera2ClientBase<TClientBase>::getCameraDevice() {
427 return mDevice;
428}
429
430template <typename TClientBase>
431const sp<CameraService>& Camera2ClientBase<TClientBase>::getCameraService() {
Eino-Ville Talvala2f09bac2016-12-13 11:29:54 -0800432 return TClientBase::sCameraService;
Igor Murashkin44cfcf02013-03-01 16:22:28 -0800433}
434
435template <typename TClientBase>
436Camera2ClientBase<TClientBase>::SharedCameraCallbacks::Lock::Lock(
437 SharedCameraCallbacks &client) :
438
439 mRemoteCallback(client.mRemoteCallback),
440 mSharedClient(client) {
441
442 mSharedClient.mRemoteCallbackLock.lock();
443}
444
445template <typename TClientBase>
446Camera2ClientBase<TClientBase>::SharedCameraCallbacks::Lock::~Lock() {
447 mSharedClient.mRemoteCallbackLock.unlock();
448}
449
450template <typename TClientBase>
451Camera2ClientBase<TClientBase>::SharedCameraCallbacks::SharedCameraCallbacks(
452 const sp<TCamCallbacks>&client) :
453
454 mRemoteCallback(client) {
455}
456
457template <typename TClientBase>
458typename Camera2ClientBase<TClientBase>::SharedCameraCallbacks&
459Camera2ClientBase<TClientBase>::SharedCameraCallbacks::operator=(
460 const sp<TCamCallbacks>&client) {
461
462 Mutex::Autolock l(mRemoteCallbackLock);
463 mRemoteCallback = client;
464 return *this;
465}
466
467template <typename TClientBase>
468void Camera2ClientBase<TClientBase>::SharedCameraCallbacks::clear() {
469 Mutex::Autolock l(mRemoteCallbackLock);
470 mRemoteCallback.clear();
471}
472
Cliff Wud3a05312021-04-26 23:07:31 +0800473template <typename TClientBase>
474status_t Camera2ClientBase<TClientBase>::injectCamera(const String8& injectedCamId,
475 sp<CameraProviderManager> manager) {
476 return mDevice->injectCamera(injectedCamId, manager);
477}
478
479template <typename TClientBase>
480status_t Camera2ClientBase<TClientBase>::stopInjection() {
481 return mDevice->stopInjection();
482}
483
Igor Murashkin44cfcf02013-03-01 16:22:28 -0800484template class Camera2ClientBase<CameraService::Client>;
Igor Murashkine7ee7632013-06-11 18:10:18 -0700485template class Camera2ClientBase<CameraDeviceClientBase>;
Igor Murashkin44cfcf02013-03-01 16:22:28 -0800486
487} // namespace android