blob: 7d98a0b3ca5ed5851db18e6435bbcc693eac2338 [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,
63 bool legacyClient):
Jayant Chowdharyeb0169f2022-01-31 00:00:02 -080064 TClientBase(cameraService, remoteCallback, clientPackageName, systemNativeClient,
65 clientFeatureId, cameraId, api1CameraId, cameraFacing, sensorOrientation, clientPid,
66 clientUid, servicePid),
Yin-Chia Yehcd8fce82014-06-18 10:51:34 -070067 mSharedCameraCallbacks(remoteCallback),
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
Jayant Chowdhary48162a72022-05-27 05:37:14 +0000148 /** Start watchdog thread */
149 mCameraServiceWatchdog = new CameraServiceWatchdog();
150 mCameraServiceWatchdog->run("Camera2ClientBaseWatchdog");
151
Igor Murashkin44cfcf02013-03-01 16:22:28 -0800152 return OK;
153}
154
155template <typename TClientBase>
156Camera2ClientBase<TClientBase>::~Camera2ClientBase() {
157 ATRACE_CALL();
158
159 TClientBase::mDestructionStarted = true;
160
161 disconnect();
162
Ravneetc83d7c42022-06-03 20:51:58 +0000163 if (mCameraServiceWatchdog != NULL) {
164 mCameraServiceWatchdog->requestExit();
165 mCameraServiceWatchdog.clear();
166 }
167
Eino-Ville Talvala2f09bac2016-12-13 11:29:54 -0800168 ALOGI("Closed Camera %s. Client was: %s (PID %d, UID %u)",
169 TClientBase::mCameraIdStr.string(),
Svetoslav Ganov280405a2015-05-12 02:19:27 +0000170 String8(TClientBase::mClientPackageName).string(),
Eino-Ville Talvalab9d2f332014-09-18 17:24:22 -0700171 mInitialClientPid, TClientBase::mClientUid);
Igor Murashkin44cfcf02013-03-01 16:22:28 -0800172}
173
174template <typename TClientBase>
Eino-Ville Talvalac4003962016-01-13 10:07:04 -0800175status_t Camera2ClientBase<TClientBase>::dumpClient(int fd,
Igor Murashkin44cfcf02013-03-01 16:22:28 -0800176 const Vector<String16>& args) {
177 String8 result;
Eino-Ville Talvala2f09bac2016-12-13 11:29:54 -0800178 result.appendFormat("Camera2ClientBase[%s] (%p) PID: %d, dump:\n",
179 TClientBase::mCameraIdStr.string(),
Eino-Ville Talvalae992e752014-11-07 16:17:48 -0800180 (TClientBase::getRemoteCallback() != NULL ?
Marco Nelissen06b46062014-11-14 07:58:25 -0800181 IInterface::asBinder(TClientBase::getRemoteCallback()).get() : NULL),
Igor Murashkin44cfcf02013-03-01 16:22:28 -0800182 TClientBase::mClientPid);
183 result.append(" State: ");
184
185 write(fd, result.string(), result.size());
186 // TODO: print dynamic/request section from most recent requests
187
188 return dumpDevice(fd, args);
189}
190
191template <typename TClientBase>
Avichal Rakesh7e53cad2021-10-05 13:46:30 -0700192status_t Camera2ClientBase<TClientBase>::startWatchingTags(const String8 &tags, int out) {
193 sp<CameraDeviceBase> device = mDevice;
194 if (!device) {
195 dprintf(out, " Device is detached");
196 return OK;
197 }
198
199 return device->startWatchingTags(tags);
200}
201
202template <typename TClientBase>
203status_t Camera2ClientBase<TClientBase>::stopWatchingTags(int out) {
204 sp<CameraDeviceBase> device = mDevice;
205 if (!device) {
206 dprintf(out, " Device is detached");
207 return OK;
208 }
209
210 return device->stopWatchingTags();
211}
212
213template <typename TClientBase>
214status_t Camera2ClientBase<TClientBase>::dumpWatchedEventsToVector(std::vector<std::string> &out) {
215 sp<CameraDeviceBase> device = mDevice;
216 if (!device) {
217 // Nothing to dump if the device is detached
218 return OK;
219 }
220 return device->dumpWatchedEventsToVector(out);
221}
222
223template <typename TClientBase>
Igor Murashkin44cfcf02013-03-01 16:22:28 -0800224status_t Camera2ClientBase<TClientBase>::dumpDevice(
225 int fd,
226 const Vector<String16>& args) {
227 String8 result;
228
229 result = " Device dump:\n";
230 write(fd, result.string(), result.size());
231
Yin-Chia Yehe5138f12017-11-10 14:10:05 -0800232 sp<CameraDeviceBase> device = mDevice;
233 if (!device.get()) {
Igor Murashkin44cfcf02013-03-01 16:22:28 -0800234 result = " *** Device is detached\n";
235 write(fd, result.string(), result.size());
236 return NO_ERROR;
237 }
238
Yin-Chia Yehe5138f12017-11-10 14:10:05 -0800239 status_t res = device->dump(fd, args);
Igor Murashkin44cfcf02013-03-01 16:22:28 -0800240 if (res != OK) {
241 result = String8::format(" Error dumping device: %s (%d)",
242 strerror(-res), res);
243 write(fd, result.string(), result.size());
244 }
245
246 return NO_ERROR;
247}
248
249// ICameraClient2BaseUser interface
250
Igor Murashkin44cfcf02013-03-01 16:22:28 -0800251template <typename TClientBase>
Eino-Ville Talvalad56db1d2015-12-17 16:50:35 -0800252binder::Status Camera2ClientBase<TClientBase>::disconnect() {
Ravneet Dhanjal72c96652022-06-29 01:34:01 +0000253 if (mCameraServiceWatchdog != nullptr && mDevice != nullptr) {
254 // Timer for the disconnect call should be greater than getExpectedInFlightDuration
255 // since this duration is used to error handle methods in the disconnect sequence
256 // thus allowing existing error handling methods to execute first
257 uint64_t maxExpectedDuration =
258 ns2ms(mDevice->getExpectedInFlightDuration() + kBufferTimeDisconnectNs);
259
Jayant Chowdhary3f20d192022-05-31 17:24:39 +0000260 // Initialization from hal succeeded, time disconnect.
261 return mCameraServiceWatchdog->WATCH_CUSTOM_TIMER(disconnectImpl(),
Ravneet Dhanjal72c96652022-06-29 01:34:01 +0000262 maxExpectedDuration / kCycleLengthMs, kCycleLengthMs);
Jayant Chowdhary3f20d192022-05-31 17:24:39 +0000263 }
264 return disconnectImpl();
Jayant Chowdhary48162a72022-05-27 05:37:14 +0000265}
266
267template <typename TClientBase>
268binder::Status Camera2ClientBase<TClientBase>::disconnectImpl() {
Igor Murashkin44cfcf02013-03-01 16:22:28 -0800269 ATRACE_CALL();
Shuzhen Wang046f4a82022-05-05 17:15:24 -0700270 ALOGD("Camera %s: start to disconnect", TClientBase::mCameraIdStr.string());
Igor Murashkin44cfcf02013-03-01 16:22:28 -0800271 Mutex::Autolock icl(mBinderSerializationLock);
272
Shuzhen Wang046f4a82022-05-05 17:15:24 -0700273 ALOGD("Camera %s: serializationLock acquired", TClientBase::mCameraIdStr.string());
Eino-Ville Talvalad56db1d2015-12-17 16:50:35 -0800274 binder::Status res = binder::Status::ok();
Igor Murashkin44cfcf02013-03-01 16:22:28 -0800275 // Allow both client and the media server to disconnect at all times
Jayant Chowdhary12361932018-08-27 14:46:13 -0700276 int callingPid = CameraThreadState::getCallingPid();
Igor Murashkin44cfcf02013-03-01 16:22:28 -0800277 if (callingPid != TClientBase::mClientPid &&
Eino-Ville Talvalad56db1d2015-12-17 16:50:35 -0800278 callingPid != TClientBase::mServicePid) return res;
Igor Murashkin44cfcf02013-03-01 16:22:28 -0800279
Shuzhen Wang046f4a82022-05-05 17:15:24 -0700280 ALOGD("Camera %s: Shutting down", TClientBase::mCameraIdStr.string());
Igor Murashkin44cfcf02013-03-01 16:22:28 -0800281
Rucha Katakwardf223072021-06-15 10:21:00 -0700282 // Before detaching the device, cache the info from current open session.
283 // The disconnected check avoids duplication of info and also prevents
284 // deadlock while acquiring service lock in cacheDump.
285 if (!TClientBase::mDisconnected) {
Shuzhen Wang046f4a82022-05-05 17:15:24 -0700286 ALOGD("Camera %s: start to cacheDump", TClientBase::mCameraIdStr.string());
Rucha Katakwardf223072021-06-15 10:21:00 -0700287 Camera2ClientBase::getCameraService()->cacheDump();
288 }
289
Igor Murashkin44cfcf02013-03-01 16:22:28 -0800290 detachDevice();
291
Igor Murashkine6800ce2013-03-04 17:25:57 -0800292 CameraService::BasicClient::disconnect();
Igor Murashkin44cfcf02013-03-01 16:22:28 -0800293
Shuzhen Wang316781a2020-08-18 18:11:01 -0700294 ALOGV("Camera %s: Shut down complete", TClientBase::mCameraIdStr.string());
Eino-Ville Talvalad56db1d2015-12-17 16:50:35 -0800295
296 return res;
Igor Murashkin44cfcf02013-03-01 16:22:28 -0800297}
298
299template <typename TClientBase>
300void Camera2ClientBase<TClientBase>::detachDevice() {
301 if (mDevice == 0) return;
302 mDevice->disconnect();
303
Eino-Ville Talvala2f09bac2016-12-13 11:29:54 -0800304 ALOGV("Camera %s: Detach complete", TClientBase::mCameraIdStr.string());
Igor Murashkin44cfcf02013-03-01 16:22:28 -0800305}
306
307template <typename TClientBase>
308status_t Camera2ClientBase<TClientBase>::connect(
309 const sp<TCamCallbacks>& client) {
310 ATRACE_CALL();
311 ALOGV("%s: E", __FUNCTION__);
312 Mutex::Autolock icl(mBinderSerializationLock);
313
314 if (TClientBase::mClientPid != 0 &&
Jayant Chowdhary12361932018-08-27 14:46:13 -0700315 CameraThreadState::getCallingPid() != TClientBase::mClientPid) {
Igor Murashkin44cfcf02013-03-01 16:22:28 -0800316
Eino-Ville Talvala2f09bac2016-12-13 11:29:54 -0800317 ALOGE("%s: Camera %s: Connection attempt from pid %d; "
Igor Murashkin44cfcf02013-03-01 16:22:28 -0800318 "current locked to pid %d",
319 __FUNCTION__,
Eino-Ville Talvala2f09bac2016-12-13 11:29:54 -0800320 TClientBase::mCameraIdStr.string(),
Jayant Chowdhary12361932018-08-27 14:46:13 -0700321 CameraThreadState::getCallingPid(),
Igor Murashkin44cfcf02013-03-01 16:22:28 -0800322 TClientBase::mClientPid);
323 return BAD_VALUE;
324 }
325
Jayant Chowdhary12361932018-08-27 14:46:13 -0700326 TClientBase::mClientPid = CameraThreadState::getCallingPid();
Igor Murashkin44cfcf02013-03-01 16:22:28 -0800327
328 TClientBase::mRemoteCallback = client;
329 mSharedCameraCallbacks = client;
330
331 return OK;
332}
333
334/** Device-related methods */
335
336template <typename TClientBase>
Jianing Weicb0652e2014-03-12 18:29:36 -0700337void Camera2ClientBase<TClientBase>::notifyError(
Eino-Ville Talvalad56db1d2015-12-17 16:50:35 -0800338 int32_t errorCode,
Jianing Weicb0652e2014-03-12 18:29:36 -0700339 const CaptureResultExtras& resultExtras) {
340 ALOGE("Error condition %d reported by HAL, requestId %" PRId32, errorCode,
341 resultExtras.requestId);
Igor Murashkin44cfcf02013-03-01 16:22:28 -0800342}
343
344template <typename TClientBase>
Austin Borger4a870a32022-02-25 01:48:41 +0000345status_t Camera2ClientBase<TClientBase>::notifyActive(float maxPreviewFps) {
Eino-Ville Talvala178e8232021-04-16 18:41:39 -0700346 if (!mDeviceActive) {
347 status_t res = TClientBase::startCameraStreamingOps();
348 if (res != OK) {
349 ALOGE("%s: Camera %s: Error starting camera streaming ops: %d", __FUNCTION__,
350 TClientBase::mCameraIdStr.string(), res);
351 return res;
352 }
Austin Borger4a870a32022-02-25 01:48:41 +0000353 CameraServiceProxyWrapper::logActive(TClientBase::mCameraIdStr, maxPreviewFps);
Eino-Ville Talvala178e8232021-04-16 18:41:39 -0700354 }
355 mDeviceActive = true;
356
357 ALOGV("Camera device is now active");
358 return OK;
359}
360
361template <typename TClientBase>
Shuzhen Wangd26b1862022-03-07 12:05:05 -0800362void Camera2ClientBase<TClientBase>::notifyIdleWithUserTag(
Shuzhen Wang316781a2020-08-18 18:11:01 -0700363 int64_t requestCount, int64_t resultErrorCount, bool deviceError,
Shuzhen Wangd26b1862022-03-07 12:05:05 -0800364 const std::vector<hardware::CameraStreamStats>& streamStats,
Shuzhen Wang9372b0b2022-05-11 18:55:19 -0700365 const std::string& userTag, int videoStabilizationMode) {
Eino-Ville Talvala412fe562015-08-20 17:08:32 -0700366 if (mDeviceActive) {
Eino-Ville Talvala178e8232021-04-16 18:41:39 -0700367 status_t res = TClientBase::finishCameraStreamingOps();
368 if (res != OK) {
369 ALOGE("%s: Camera %s: Error finishing streaming ops: %d", __FUNCTION__,
370 TClientBase::mCameraIdStr.string(), res);
371 }
Shuzhen Wang316781a2020-08-18 18:11:01 -0700372 CameraServiceProxyWrapper::logIdle(TClientBase::mCameraIdStr,
Shuzhen Wang9372b0b2022-05-11 18:55:19 -0700373 requestCount, resultErrorCount, deviceError, userTag, videoStabilizationMode,
374 streamStats);
Eino-Ville Talvala412fe562015-08-20 17:08:32 -0700375 }
376 mDeviceActive = false;
377
Eino-Ville Talvalaf1e98d82013-09-06 09:32:43 -0700378 ALOGV("Camera device is now idle");
379}
380
381template <typename TClientBase>
Jianing Weicb0652e2014-03-12 18:29:36 -0700382void Camera2ClientBase<TClientBase>::notifyShutter(const CaptureResultExtras& resultExtras,
Igor Murashkin44cfcf02013-03-01 16:22:28 -0800383 nsecs_t timestamp) {
Jianing Weicb0652e2014-03-12 18:29:36 -0700384 (void)resultExtras;
Igor Murashkin44cfcf02013-03-01 16:22:28 -0800385 (void)timestamp;
386
Jianing Weicb0652e2014-03-12 18:29:36 -0700387 ALOGV("%s: Shutter notification for request id %" PRId32 " at time %" PRId64,
388 __FUNCTION__, resultExtras.requestId, timestamp);
Igor Murashkin44cfcf02013-03-01 16:22:28 -0800389}
390
391template <typename TClientBase>
392void Camera2ClientBase<TClientBase>::notifyAutoFocus(uint8_t newState,
393 int triggerId) {
394 (void)newState;
395 (void)triggerId;
396
397 ALOGV("%s: Autofocus state now %d, last trigger %d",
398 __FUNCTION__, newState, triggerId);
399
Igor Murashkin44cfcf02013-03-01 16:22:28 -0800400}
401
402template <typename TClientBase>
403void Camera2ClientBase<TClientBase>::notifyAutoExposure(uint8_t newState,
404 int triggerId) {
405 (void)newState;
406 (void)triggerId;
407
408 ALOGV("%s: Autoexposure state now %d, last trigger %d",
409 __FUNCTION__, newState, triggerId);
410}
411
412template <typename TClientBase>
413void Camera2ClientBase<TClientBase>::notifyAutoWhitebalance(uint8_t newState,
414 int triggerId) {
415 (void)newState;
416 (void)triggerId;
417
418 ALOGV("%s: Auto-whitebalance state now %d, last trigger %d",
419 __FUNCTION__, newState, triggerId);
420}
421
422template <typename TClientBase>
Eino-Ville Talvala4d44cad2015-04-11 13:15:45 -0700423void Camera2ClientBase<TClientBase>::notifyPrepared(int streamId) {
424 (void)streamId;
425
426 ALOGV("%s: Stream %d now prepared",
427 __FUNCTION__, streamId);
428}
429
430template <typename TClientBase>
Shuzhen Wang9d066012016-09-30 11:30:20 -0700431void Camera2ClientBase<TClientBase>::notifyRequestQueueEmpty() {
432
433 ALOGV("%s: Request queue now empty", __FUNCTION__);
434}
435
436template <typename TClientBase>
Chien-Yu Chene8c535e2016-04-14 12:18:26 -0700437void Camera2ClientBase<TClientBase>::notifyRepeatingRequestError(long lastFrameNumber) {
438 (void)lastFrameNumber;
439
440 ALOGV("%s: Repeating request was stopped. Last frame number is %ld",
441 __FUNCTION__, lastFrameNumber);
442}
443
444template <typename TClientBase>
Igor Murashkin44cfcf02013-03-01 16:22:28 -0800445int Camera2ClientBase<TClientBase>::getCameraId() const {
Yin-Chia Yehc3e9d6f2018-02-06 10:56:32 -0800446 return mApi1CameraId;
Igor Murashkin44cfcf02013-03-01 16:22:28 -0800447}
448
449template <typename TClientBase>
450const sp<CameraDeviceBase>& Camera2ClientBase<TClientBase>::getCameraDevice() {
451 return mDevice;
452}
453
454template <typename TClientBase>
455const sp<CameraService>& Camera2ClientBase<TClientBase>::getCameraService() {
Eino-Ville Talvala2f09bac2016-12-13 11:29:54 -0800456 return TClientBase::sCameraService;
Igor Murashkin44cfcf02013-03-01 16:22:28 -0800457}
458
459template <typename TClientBase>
460Camera2ClientBase<TClientBase>::SharedCameraCallbacks::Lock::Lock(
461 SharedCameraCallbacks &client) :
462
463 mRemoteCallback(client.mRemoteCallback),
464 mSharedClient(client) {
465
466 mSharedClient.mRemoteCallbackLock.lock();
467}
468
469template <typename TClientBase>
470Camera2ClientBase<TClientBase>::SharedCameraCallbacks::Lock::~Lock() {
471 mSharedClient.mRemoteCallbackLock.unlock();
472}
473
474template <typename TClientBase>
475Camera2ClientBase<TClientBase>::SharedCameraCallbacks::SharedCameraCallbacks(
476 const sp<TCamCallbacks>&client) :
477
478 mRemoteCallback(client) {
479}
480
481template <typename TClientBase>
482typename Camera2ClientBase<TClientBase>::SharedCameraCallbacks&
483Camera2ClientBase<TClientBase>::SharedCameraCallbacks::operator=(
484 const sp<TCamCallbacks>&client) {
485
486 Mutex::Autolock l(mRemoteCallbackLock);
487 mRemoteCallback = client;
488 return *this;
489}
490
491template <typename TClientBase>
492void Camera2ClientBase<TClientBase>::SharedCameraCallbacks::clear() {
493 Mutex::Autolock l(mRemoteCallbackLock);
494 mRemoteCallback.clear();
495}
496
Cliff Wud3a05312021-04-26 23:07:31 +0800497template <typename TClientBase>
498status_t Camera2ClientBase<TClientBase>::injectCamera(const String8& injectedCamId,
499 sp<CameraProviderManager> manager) {
500 return mDevice->injectCamera(injectedCamId, manager);
501}
502
503template <typename TClientBase>
504status_t Camera2ClientBase<TClientBase>::stopInjection() {
505 return mDevice->stopInjection();
506}
507
Igor Murashkin44cfcf02013-03-01 16:22:28 -0800508template class Camera2ClientBase<CameraService::Client>;
Igor Murashkine7ee7632013-06-11 18:10:18 -0700509template class Camera2ClientBase<CameraDeviceClientBase>;
Igor Murashkin44cfcf02013-03-01 16:22:28 -0800510
511} // namespace android