blob: ad24392de0b093d55aae7ae67730ebff8df96ab4 [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 {
Jayant Chowdhary48162a72022-05-27 05:37:14 +000043
Igor Murashkin44cfcf02013-03-01 16:22:28 -080044using namespace camera2;
45
Igor Murashkin44cfcf02013-03-01 16:22:28 -080046// Interface used by CameraService
47
48template <typename TClientBase>
49Camera2ClientBase<TClientBase>::Camera2ClientBase(
50 const sp<CameraService>& cameraService,
51 const sp<TCamCallbacks>& remoteCallback,
52 const String16& clientPackageName,
Jayant Chowdharyeb0169f2022-01-31 00:00:02 -080053 bool systemNativeClient,
Jooyung Han3f9a3b42020-01-23 12:27:18 +090054 const std::optional<String16>& clientFeatureId,
Eino-Ville Talvala2f09bac2016-12-13 11:29:54 -080055 const String8& cameraId,
Yin-Chia Yehc3e9d6f2018-02-06 10:56:32 -080056 int api1CameraId,
Igor Murashkin44cfcf02013-03-01 16:22:28 -080057 int cameraFacing,
Emilian Peev8b64f282021-03-25 16:49:57 -070058 int sensorOrientation,
Igor Murashkin44cfcf02013-03-01 16:22:28 -080059 int clientPid,
60 uid_t clientUid,
Shuzhen Wangd4abdf72021-05-28 11:22:50 -070061 int servicePid,
Emilian Peev5104fe92021-10-21 14:27:09 -070062 bool overrideForPerfClass,
Austin Borger3560b7e2022-10-27 12:20:29 -070063 bool overrideToPortrait,
Emilian Peev5104fe92021-10-21 14:27:09 -070064 bool legacyClient):
Jayant Chowdharyeb0169f2022-01-31 00:00:02 -080065 TClientBase(cameraService, remoteCallback, clientPackageName, systemNativeClient,
66 clientFeatureId, cameraId, api1CameraId, cameraFacing, sensorOrientation, clientPid,
Austin Borger3560b7e2022-10-27 12:20:29 -070067 clientUid, servicePid, overrideToPortrait),
Yin-Chia Yehcd8fce82014-06-18 10:51:34 -070068 mSharedCameraCallbacks(remoteCallback),
Yin-Chia Yehc3e9d6f2018-02-06 10:56:32 -080069 mDeviceActive(false), mApi1CameraId(api1CameraId)
Igor Murashkin44cfcf02013-03-01 16:22:28 -080070{
Eino-Ville Talvala2f09bac2016-12-13 11:29:54 -080071 ALOGI("Camera %s: Opened. Client: %s (PID %d, UID %d)", cameraId.string(),
Eino-Ville Talvalab9d2f332014-09-18 17:24:22 -070072 String8(clientPackageName).string(), clientPid, clientUid);
Igor Murashkin98e24722013-06-19 19:51:04 -070073
Eino-Ville Talvalab9d2f332014-09-18 17:24:22 -070074 mInitialClientPid = clientPid;
Jayant Chowdhary22441f32021-12-26 18:35:41 -080075 mOverrideForPerfClass = overrideForPerfClass;
76 mLegacyClient = legacyClient;
Igor Murashkin44cfcf02013-03-01 16:22:28 -080077}
78
79template <typename TClientBase>
80status_t Camera2ClientBase<TClientBase>::checkPid(const char* checkLocation)
81 const {
82
Jayant Chowdhary12361932018-08-27 14:46:13 -070083 int callingPid = CameraThreadState::getCallingPid();
Igor Murashkin44cfcf02013-03-01 16:22:28 -080084 if (callingPid == TClientBase::mClientPid) return NO_ERROR;
85
86 ALOGE("%s: attempt to use a locked camera from a different process"
87 " (old pid %d, new pid %d)", checkLocation, TClientBase::mClientPid, callingPid);
88 return PERMISSION_DENIED;
89}
90
91template <typename TClientBase>
Emilian Peevbd8c5032018-02-14 23:05:40 +000092status_t Camera2ClientBase<TClientBase>::initialize(sp<CameraProviderManager> manager,
93 const String8& monitorTags) {
94 return initializeImpl(manager, monitorTags);
Eino-Ville Talvala2f09bac2016-12-13 11:29:54 -080095}
96
97template <typename TClientBase>
98template <typename TProviderPtr>
Emilian Peevbd8c5032018-02-14 23:05:40 +000099status_t Camera2ClientBase<TClientBase>::initializeImpl(TProviderPtr providerPtr,
100 const String8& monitorTags) {
Igor Murashkin44cfcf02013-03-01 16:22:28 -0800101 ATRACE_CALL();
Eino-Ville Talvala2f09bac2016-12-13 11:29:54 -0800102 ALOGV("%s: Initializing client for camera %s", __FUNCTION__,
103 TClientBase::mCameraIdStr.string());
Igor Murashkin44cfcf02013-03-01 16:22:28 -0800104 status_t res;
105
Igor Murashkine6800ce2013-03-04 17:25:57 -0800106 // Verify ops permissions
107 res = TClientBase::startCameraOps();
108 if (res != OK) {
109 return res;
110 }
Jayant Chowdhary22441f32021-12-26 18:35:41 -0800111 IPCTransport providerTransport = IPCTransport::INVALID;
112 res = providerPtr->getCameraIdIPCTransport(TClientBase::mCameraIdStr.string(),
113 &providerTransport);
114 if (res != OK) {
115 return res;
116 }
117 switch (providerTransport) {
118 case IPCTransport::HIDL:
119 mDevice =
120 new HidlCamera3Device(TClientBase::mCameraIdStr, mOverrideForPerfClass,
Austin Borger3560b7e2022-10-27 12:20:29 -0700121 TClientBase::mOverrideToPortrait, mLegacyClient);
Jayant Chowdhary22441f32021-12-26 18:35:41 -0800122 break;
123 case IPCTransport::AIDL:
Jayant Chowdhary35642f22022-01-08 00:39:39 +0000124 mDevice =
125 new AidlCamera3Device(TClientBase::mCameraIdStr, mOverrideForPerfClass,
Austin Borger3560b7e2022-10-27 12:20:29 -0700126 TClientBase::mOverrideToPortrait, mLegacyClient);
Jayant Chowdhary35642f22022-01-08 00:39:39 +0000127 break;
Jayant Chowdhary22441f32021-12-26 18:35:41 -0800128 default:
129 ALOGE("%s Invalid transport for camera id %s", __FUNCTION__,
130 TClientBase::mCameraIdStr.string());
131 return NO_INIT;
132 }
Igor Murashkine6800ce2013-03-04 17:25:57 -0800133 if (mDevice == NULL) {
Eino-Ville Talvala2f09bac2016-12-13 11:29:54 -0800134 ALOGE("%s: Camera %s: No device connected",
135 __FUNCTION__, TClientBase::mCameraIdStr.string());
Igor Murashkine6800ce2013-03-04 17:25:57 -0800136 return NO_INIT;
137 }
138
Emilian Peevbd8c5032018-02-14 23:05:40 +0000139 res = mDevice->initialize(providerPtr, monitorTags);
Igor Murashkin44cfcf02013-03-01 16:22:28 -0800140 if (res != OK) {
Eino-Ville Talvala2f09bac2016-12-13 11:29:54 -0800141 ALOGE("%s: Camera %s: unable to initialize device: %s (%d)",
142 __FUNCTION__, TClientBase::mCameraIdStr.string(), strerror(-res), res);
Zhijun He66281c32013-09-13 17:59:59 -0700143 return res;
Igor Murashkin44cfcf02013-03-01 16:22:28 -0800144 }
145
Yin-Chia Yeh5fd603e2019-11-20 11:22:27 -0800146 wp<NotificationListener> weakThis(this);
Yin-Chia Yehe1c80632016-08-08 14:48:05 -0700147 res = mDevice->setNotifyCallback(weakThis);
Igor Murashkin44cfcf02013-03-01 16:22:28 -0800148
Jayant Chowdhary48162a72022-05-27 05:37:14 +0000149 /** Start watchdog thread */
150 mCameraServiceWatchdog = new CameraServiceWatchdog();
151 mCameraServiceWatchdog->run("Camera2ClientBaseWatchdog");
152
Igor Murashkin44cfcf02013-03-01 16:22:28 -0800153 return OK;
154}
155
156template <typename TClientBase>
157Camera2ClientBase<TClientBase>::~Camera2ClientBase() {
158 ATRACE_CALL();
159
160 TClientBase::mDestructionStarted = true;
161
162 disconnect();
163
Ravneetc83d7c42022-06-03 20:51:58 +0000164 if (mCameraServiceWatchdog != NULL) {
165 mCameraServiceWatchdog->requestExit();
166 mCameraServiceWatchdog.clear();
167 }
168
Eino-Ville Talvala2f09bac2016-12-13 11:29:54 -0800169 ALOGI("Closed Camera %s. Client was: %s (PID %d, UID %u)",
170 TClientBase::mCameraIdStr.string(),
Svetoslav Ganov280405a2015-05-12 02:19:27 +0000171 String8(TClientBase::mClientPackageName).string(),
Eino-Ville Talvalab9d2f332014-09-18 17:24:22 -0700172 mInitialClientPid, TClientBase::mClientUid);
Igor Murashkin44cfcf02013-03-01 16:22:28 -0800173}
174
175template <typename TClientBase>
Eino-Ville Talvalac4003962016-01-13 10:07:04 -0800176status_t Camera2ClientBase<TClientBase>::dumpClient(int fd,
Igor Murashkin44cfcf02013-03-01 16:22:28 -0800177 const Vector<String16>& args) {
178 String8 result;
Eino-Ville Talvala2f09bac2016-12-13 11:29:54 -0800179 result.appendFormat("Camera2ClientBase[%s] (%p) PID: %d, dump:\n",
180 TClientBase::mCameraIdStr.string(),
Eino-Ville Talvalae992e752014-11-07 16:17:48 -0800181 (TClientBase::getRemoteCallback() != NULL ?
Marco Nelissen06b46062014-11-14 07:58:25 -0800182 IInterface::asBinder(TClientBase::getRemoteCallback()).get() : NULL),
Igor Murashkin44cfcf02013-03-01 16:22:28 -0800183 TClientBase::mClientPid);
184 result.append(" State: ");
185
186 write(fd, result.string(), result.size());
187 // TODO: print dynamic/request section from most recent requests
188
189 return dumpDevice(fd, args);
190}
191
192template <typename TClientBase>
Avichal Rakesh7e53cad2021-10-05 13:46:30 -0700193status_t Camera2ClientBase<TClientBase>::startWatchingTags(const String8 &tags, int out) {
194 sp<CameraDeviceBase> device = mDevice;
195 if (!device) {
196 dprintf(out, " Device is detached");
197 return OK;
198 }
199
200 return device->startWatchingTags(tags);
201}
202
203template <typename TClientBase>
204status_t Camera2ClientBase<TClientBase>::stopWatchingTags(int out) {
205 sp<CameraDeviceBase> device = mDevice;
206 if (!device) {
207 dprintf(out, " Device is detached");
208 return OK;
209 }
210
211 return device->stopWatchingTags();
212}
213
214template <typename TClientBase>
215status_t Camera2ClientBase<TClientBase>::dumpWatchedEventsToVector(std::vector<std::string> &out) {
216 sp<CameraDeviceBase> device = mDevice;
217 if (!device) {
218 // Nothing to dump if the device is detached
219 return OK;
220 }
221 return device->dumpWatchedEventsToVector(out);
222}
223
224template <typename TClientBase>
Igor Murashkin44cfcf02013-03-01 16:22:28 -0800225status_t Camera2ClientBase<TClientBase>::dumpDevice(
226 int fd,
227 const Vector<String16>& args) {
228 String8 result;
229
230 result = " Device dump:\n";
231 write(fd, result.string(), result.size());
232
Yin-Chia Yehe5138f12017-11-10 14:10:05 -0800233 sp<CameraDeviceBase> device = mDevice;
234 if (!device.get()) {
Igor Murashkin44cfcf02013-03-01 16:22:28 -0800235 result = " *** Device is detached\n";
236 write(fd, result.string(), result.size());
237 return NO_ERROR;
238 }
239
Yin-Chia Yehe5138f12017-11-10 14:10:05 -0800240 status_t res = device->dump(fd, args);
Igor Murashkin44cfcf02013-03-01 16:22:28 -0800241 if (res != OK) {
242 result = String8::format(" Error dumping device: %s (%d)",
243 strerror(-res), res);
244 write(fd, result.string(), result.size());
245 }
246
247 return NO_ERROR;
248}
249
250// ICameraClient2BaseUser interface
251
Igor Murashkin44cfcf02013-03-01 16:22:28 -0800252template <typename TClientBase>
Eino-Ville Talvalad56db1d2015-12-17 16:50:35 -0800253binder::Status Camera2ClientBase<TClientBase>::disconnect() {
Ravneet Dhanjal72c96652022-06-29 01:34:01 +0000254 if (mCameraServiceWatchdog != nullptr && mDevice != nullptr) {
255 // Timer for the disconnect call should be greater than getExpectedInFlightDuration
256 // since this duration is used to error handle methods in the disconnect sequence
257 // thus allowing existing error handling methods to execute first
258 uint64_t maxExpectedDuration =
259 ns2ms(mDevice->getExpectedInFlightDuration() + kBufferTimeDisconnectNs);
260
Jayant Chowdhary3f20d192022-05-31 17:24:39 +0000261 // Initialization from hal succeeded, time disconnect.
262 return mCameraServiceWatchdog->WATCH_CUSTOM_TIMER(disconnectImpl(),
Ravneet Dhanjal72c96652022-06-29 01:34:01 +0000263 maxExpectedDuration / kCycleLengthMs, kCycleLengthMs);
Jayant Chowdhary3f20d192022-05-31 17:24:39 +0000264 }
265 return disconnectImpl();
Jayant Chowdhary48162a72022-05-27 05:37:14 +0000266}
267
268template <typename TClientBase>
269binder::Status Camera2ClientBase<TClientBase>::disconnectImpl() {
Igor Murashkin44cfcf02013-03-01 16:22:28 -0800270 ATRACE_CALL();
Shuzhen Wang046f4a82022-05-05 17:15:24 -0700271 ALOGD("Camera %s: start to disconnect", TClientBase::mCameraIdStr.string());
Igor Murashkin44cfcf02013-03-01 16:22:28 -0800272 Mutex::Autolock icl(mBinderSerializationLock);
273
Shuzhen Wang046f4a82022-05-05 17:15:24 -0700274 ALOGD("Camera %s: serializationLock acquired", TClientBase::mCameraIdStr.string());
Eino-Ville Talvalad56db1d2015-12-17 16:50:35 -0800275 binder::Status res = binder::Status::ok();
Igor Murashkin44cfcf02013-03-01 16:22:28 -0800276 // Allow both client and the media server to disconnect at all times
Jayant Chowdhary12361932018-08-27 14:46:13 -0700277 int callingPid = CameraThreadState::getCallingPid();
Igor Murashkin44cfcf02013-03-01 16:22:28 -0800278 if (callingPid != TClientBase::mClientPid &&
Eino-Ville Talvalad56db1d2015-12-17 16:50:35 -0800279 callingPid != TClientBase::mServicePid) return res;
Igor Murashkin44cfcf02013-03-01 16:22:28 -0800280
Shuzhen Wang046f4a82022-05-05 17:15:24 -0700281 ALOGD("Camera %s: Shutting down", TClientBase::mCameraIdStr.string());
Igor Murashkin44cfcf02013-03-01 16:22:28 -0800282
Rucha Katakwardf223072021-06-15 10:21:00 -0700283 // Before detaching the device, cache the info from current open session.
284 // The disconnected check avoids duplication of info and also prevents
285 // deadlock while acquiring service lock in cacheDump.
286 if (!TClientBase::mDisconnected) {
Shuzhen Wang046f4a82022-05-05 17:15:24 -0700287 ALOGD("Camera %s: start to cacheDump", TClientBase::mCameraIdStr.string());
Rucha Katakwardf223072021-06-15 10:21:00 -0700288 Camera2ClientBase::getCameraService()->cacheDump();
289 }
290
Igor Murashkin44cfcf02013-03-01 16:22:28 -0800291 detachDevice();
292
Igor Murashkine6800ce2013-03-04 17:25:57 -0800293 CameraService::BasicClient::disconnect();
Igor Murashkin44cfcf02013-03-01 16:22:28 -0800294
Shuzhen Wang316781a2020-08-18 18:11:01 -0700295 ALOGV("Camera %s: Shut down complete", TClientBase::mCameraIdStr.string());
Eino-Ville Talvalad56db1d2015-12-17 16:50:35 -0800296
297 return res;
Igor Murashkin44cfcf02013-03-01 16:22:28 -0800298}
299
300template <typename TClientBase>
301void Camera2ClientBase<TClientBase>::detachDevice() {
302 if (mDevice == 0) return;
303 mDevice->disconnect();
304
Eino-Ville Talvala2f09bac2016-12-13 11:29:54 -0800305 ALOGV("Camera %s: Detach complete", TClientBase::mCameraIdStr.string());
Igor Murashkin44cfcf02013-03-01 16:22:28 -0800306}
307
308template <typename TClientBase>
309status_t Camera2ClientBase<TClientBase>::connect(
310 const sp<TCamCallbacks>& client) {
311 ATRACE_CALL();
312 ALOGV("%s: E", __FUNCTION__);
313 Mutex::Autolock icl(mBinderSerializationLock);
314
315 if (TClientBase::mClientPid != 0 &&
Jayant Chowdhary12361932018-08-27 14:46:13 -0700316 CameraThreadState::getCallingPid() != TClientBase::mClientPid) {
Igor Murashkin44cfcf02013-03-01 16:22:28 -0800317
Eino-Ville Talvala2f09bac2016-12-13 11:29:54 -0800318 ALOGE("%s: Camera %s: Connection attempt from pid %d; "
Igor Murashkin44cfcf02013-03-01 16:22:28 -0800319 "current locked to pid %d",
320 __FUNCTION__,
Eino-Ville Talvala2f09bac2016-12-13 11:29:54 -0800321 TClientBase::mCameraIdStr.string(),
Jayant Chowdhary12361932018-08-27 14:46:13 -0700322 CameraThreadState::getCallingPid(),
Igor Murashkin44cfcf02013-03-01 16:22:28 -0800323 TClientBase::mClientPid);
324 return BAD_VALUE;
325 }
326
Jayant Chowdhary12361932018-08-27 14:46:13 -0700327 TClientBase::mClientPid = CameraThreadState::getCallingPid();
Igor Murashkin44cfcf02013-03-01 16:22:28 -0800328
329 TClientBase::mRemoteCallback = client;
330 mSharedCameraCallbacks = client;
331
332 return OK;
333}
334
335/** Device-related methods */
336
337template <typename TClientBase>
Jianing Weicb0652e2014-03-12 18:29:36 -0700338void Camera2ClientBase<TClientBase>::notifyError(
Eino-Ville Talvalad56db1d2015-12-17 16:50:35 -0800339 int32_t errorCode,
Jianing Weicb0652e2014-03-12 18:29:36 -0700340 const CaptureResultExtras& resultExtras) {
341 ALOGE("Error condition %d reported by HAL, requestId %" PRId32, errorCode,
342 resultExtras.requestId);
Igor Murashkin44cfcf02013-03-01 16:22:28 -0800343}
344
345template <typename TClientBase>
Austin Borger4a870a32022-02-25 01:48:41 +0000346status_t Camera2ClientBase<TClientBase>::notifyActive(float maxPreviewFps) {
Eino-Ville Talvala178e8232021-04-16 18:41:39 -0700347 if (!mDeviceActive) {
348 status_t res = TClientBase::startCameraStreamingOps();
349 if (res != OK) {
350 ALOGE("%s: Camera %s: Error starting camera streaming ops: %d", __FUNCTION__,
351 TClientBase::mCameraIdStr.string(), res);
352 return res;
353 }
Austin Borger4a870a32022-02-25 01:48:41 +0000354 CameraServiceProxyWrapper::logActive(TClientBase::mCameraIdStr, maxPreviewFps);
Eino-Ville Talvala178e8232021-04-16 18:41:39 -0700355 }
356 mDeviceActive = true;
357
358 ALOGV("Camera device is now active");
359 return OK;
360}
361
362template <typename TClientBase>
Shuzhen Wangd26b1862022-03-07 12:05:05 -0800363void Camera2ClientBase<TClientBase>::notifyIdleWithUserTag(
Shuzhen Wang316781a2020-08-18 18:11:01 -0700364 int64_t requestCount, int64_t resultErrorCount, bool deviceError,
Shuzhen Wangd26b1862022-03-07 12:05:05 -0800365 const std::vector<hardware::CameraStreamStats>& streamStats,
Shuzhen Wang9372b0b2022-05-11 18:55:19 -0700366 const std::string& userTag, int videoStabilizationMode) {
Eino-Ville Talvala412fe562015-08-20 17:08:32 -0700367 if (mDeviceActive) {
Eino-Ville Talvala178e8232021-04-16 18:41:39 -0700368 status_t res = TClientBase::finishCameraStreamingOps();
369 if (res != OK) {
370 ALOGE("%s: Camera %s: Error finishing streaming ops: %d", __FUNCTION__,
371 TClientBase::mCameraIdStr.string(), res);
372 }
Shuzhen Wang316781a2020-08-18 18:11:01 -0700373 CameraServiceProxyWrapper::logIdle(TClientBase::mCameraIdStr,
Shuzhen Wang9372b0b2022-05-11 18:55:19 -0700374 requestCount, resultErrorCount, deviceError, userTag, videoStabilizationMode,
375 streamStats);
Eino-Ville Talvala412fe562015-08-20 17:08:32 -0700376 }
377 mDeviceActive = false;
378
Eino-Ville Talvalaf1e98d82013-09-06 09:32:43 -0700379 ALOGV("Camera device is now idle");
380}
381
382template <typename TClientBase>
Jianing Weicb0652e2014-03-12 18:29:36 -0700383void Camera2ClientBase<TClientBase>::notifyShutter(const CaptureResultExtras& resultExtras,
Igor Murashkin44cfcf02013-03-01 16:22:28 -0800384 nsecs_t timestamp) {
Jianing Weicb0652e2014-03-12 18:29:36 -0700385 (void)resultExtras;
Igor Murashkin44cfcf02013-03-01 16:22:28 -0800386 (void)timestamp;
387
Jianing Weicb0652e2014-03-12 18:29:36 -0700388 ALOGV("%s: Shutter notification for request id %" PRId32 " at time %" PRId64,
389 __FUNCTION__, resultExtras.requestId, timestamp);
Igor Murashkin44cfcf02013-03-01 16:22:28 -0800390}
391
392template <typename TClientBase>
393void Camera2ClientBase<TClientBase>::notifyAutoFocus(uint8_t newState,
394 int triggerId) {
395 (void)newState;
396 (void)triggerId;
397
398 ALOGV("%s: Autofocus state now %d, last trigger %d",
399 __FUNCTION__, newState, triggerId);
400
Igor Murashkin44cfcf02013-03-01 16:22:28 -0800401}
402
403template <typename TClientBase>
404void Camera2ClientBase<TClientBase>::notifyAutoExposure(uint8_t newState,
405 int triggerId) {
406 (void)newState;
407 (void)triggerId;
408
409 ALOGV("%s: Autoexposure state now %d, last trigger %d",
410 __FUNCTION__, newState, triggerId);
411}
412
413template <typename TClientBase>
414void Camera2ClientBase<TClientBase>::notifyAutoWhitebalance(uint8_t newState,
415 int triggerId) {
416 (void)newState;
417 (void)triggerId;
418
419 ALOGV("%s: Auto-whitebalance state now %d, last trigger %d",
420 __FUNCTION__, newState, triggerId);
421}
422
423template <typename TClientBase>
Eino-Ville Talvala4d44cad2015-04-11 13:15:45 -0700424void Camera2ClientBase<TClientBase>::notifyPrepared(int streamId) {
425 (void)streamId;
426
427 ALOGV("%s: Stream %d now prepared",
428 __FUNCTION__, streamId);
429}
430
431template <typename TClientBase>
Shuzhen Wang9d066012016-09-30 11:30:20 -0700432void Camera2ClientBase<TClientBase>::notifyRequestQueueEmpty() {
433
434 ALOGV("%s: Request queue now empty", __FUNCTION__);
435}
436
437template <typename TClientBase>
Chien-Yu Chene8c535e2016-04-14 12:18:26 -0700438void Camera2ClientBase<TClientBase>::notifyRepeatingRequestError(long lastFrameNumber) {
439 (void)lastFrameNumber;
440
441 ALOGV("%s: Repeating request was stopped. Last frame number is %ld",
442 __FUNCTION__, lastFrameNumber);
443}
444
445template <typename TClientBase>
Igor Murashkin44cfcf02013-03-01 16:22:28 -0800446int Camera2ClientBase<TClientBase>::getCameraId() const {
Yin-Chia Yehc3e9d6f2018-02-06 10:56:32 -0800447 return mApi1CameraId;
Igor Murashkin44cfcf02013-03-01 16:22:28 -0800448}
449
450template <typename TClientBase>
451const sp<CameraDeviceBase>& Camera2ClientBase<TClientBase>::getCameraDevice() {
452 return mDevice;
453}
454
455template <typename TClientBase>
456const sp<CameraService>& Camera2ClientBase<TClientBase>::getCameraService() {
Eino-Ville Talvala2f09bac2016-12-13 11:29:54 -0800457 return TClientBase::sCameraService;
Igor Murashkin44cfcf02013-03-01 16:22:28 -0800458}
459
460template <typename TClientBase>
461Camera2ClientBase<TClientBase>::SharedCameraCallbacks::Lock::Lock(
462 SharedCameraCallbacks &client) :
463
464 mRemoteCallback(client.mRemoteCallback),
465 mSharedClient(client) {
466
467 mSharedClient.mRemoteCallbackLock.lock();
468}
469
470template <typename TClientBase>
471Camera2ClientBase<TClientBase>::SharedCameraCallbacks::Lock::~Lock() {
472 mSharedClient.mRemoteCallbackLock.unlock();
473}
474
475template <typename TClientBase>
476Camera2ClientBase<TClientBase>::SharedCameraCallbacks::SharedCameraCallbacks(
477 const sp<TCamCallbacks>&client) :
478
479 mRemoteCallback(client) {
480}
481
482template <typename TClientBase>
483typename Camera2ClientBase<TClientBase>::SharedCameraCallbacks&
484Camera2ClientBase<TClientBase>::SharedCameraCallbacks::operator=(
485 const sp<TCamCallbacks>&client) {
486
487 Mutex::Autolock l(mRemoteCallbackLock);
488 mRemoteCallback = client;
489 return *this;
490}
491
492template <typename TClientBase>
493void Camera2ClientBase<TClientBase>::SharedCameraCallbacks::clear() {
494 Mutex::Autolock l(mRemoteCallbackLock);
495 mRemoteCallback.clear();
496}
497
Cliff Wud3a05312021-04-26 23:07:31 +0800498template <typename TClientBase>
499status_t Camera2ClientBase<TClientBase>::injectCamera(const String8& injectedCamId,
500 sp<CameraProviderManager> manager) {
501 return mDevice->injectCamera(injectedCamId, manager);
502}
503
504template <typename TClientBase>
505status_t Camera2ClientBase<TClientBase>::stopInjection() {
506 return mDevice->stopInjection();
507}
508
Igor Murashkin44cfcf02013-03-01 16:22:28 -0800509template class Camera2ClientBase<CameraService::Client>;
Igor Murashkine7ee7632013-06-11 18:10:18 -0700510template class Camera2ClientBase<CameraDeviceClientBase>;
Igor Murashkin44cfcf02013-03-01 16:22:28 -0800511
512} // namespace android