Camera: Add API level to service proxy notification
The client API level should be part of the service proxy
notifications.
Bug: 68653614
Test: Manual using application
Change-Id: Id8a9fb51a8ba91795283c846b55a9343cf8505df
diff --git a/services/camera/libcameraservice/CameraService.cpp b/services/camera/libcameraservice/CameraService.cpp
index 89ca6bb..1ed66d3 100644
--- a/services/camera/libcameraservice/CameraService.cpp
+++ b/services/camera/libcameraservice/CameraService.cpp
@@ -2241,9 +2241,13 @@
// Transition device availability listeners from PRESENT -> NOT_AVAILABLE
sCameraService->updateStatus(StatusInternal::NOT_AVAILABLE, mCameraIdStr);
+ int apiLevel = hardware::ICameraServiceProxy::CAMERA_API_LEVEL_1;
+ if (canCastToApiClient(API_2)) {
+ apiLevel = hardware::ICameraServiceProxy::CAMERA_API_LEVEL_2;
+ }
// Transition device state to OPEN
sCameraService->updateProxyDeviceState(ICameraServiceProxy::CAMERA_STATE_OPEN,
- mCameraIdStr, mCameraFacing, mClientPackageName);
+ mCameraIdStr, mCameraFacing, mClientPackageName, apiLevel);
return OK;
}
@@ -2268,9 +2272,13 @@
sCameraService->updateStatus(StatusInternal::PRESENT,
mCameraIdStr, rejected);
+ int apiLevel = hardware::ICameraServiceProxy::CAMERA_API_LEVEL_1;
+ if (canCastToApiClient(API_2)) {
+ apiLevel = hardware::ICameraServiceProxy::CAMERA_API_LEVEL_2;
+ }
// Transition device state to CLOSED
sCameraService->updateProxyDeviceState(ICameraServiceProxy::CAMERA_STATE_CLOSED,
- mCameraIdStr, mCameraFacing, mClientPackageName);
+ mCameraIdStr, mCameraFacing, mClientPackageName, apiLevel);
}
// Always stop watching, even if no camera op is active
if (mOpsCallback != NULL) {
@@ -2876,11 +2884,11 @@
}
void CameraService::updateProxyDeviceState(int newState,
- const String8& cameraId, int facing, const String16& clientName) {
+ const String8& cameraId, int facing, const String16& clientName, int apiLevel) {
sp<ICameraServiceProxy> proxyBinder = getCameraServiceProxy();
if (proxyBinder == nullptr) return;
String16 id(cameraId);
- proxyBinder->notifyCameraState(id, newState, facing, clientName);
+ proxyBinder->notifyCameraState(id, newState, facing, clientName, apiLevel);
}
status_t CameraService::getTorchStatusLocked(
diff --git a/services/camera/libcameraservice/CameraService.h b/services/camera/libcameraservice/CameraService.h
index 81048e6..3e7b1d4 100644
--- a/services/camera/libcameraservice/CameraService.h
+++ b/services/camera/libcameraservice/CameraService.h
@@ -189,7 +189,8 @@
int newState,
const String8& cameraId,
int facing,
- const String16& clientName);
+ const String16& clientName,
+ int apiLevel);
/////////////////////////////////////////////////////////////////////
// CameraDeviceFactory functionality
diff --git a/services/camera/libcameraservice/api1/CameraClient.cpp b/services/camera/libcameraservice/api1/CameraClient.cpp
index 8c6cd3d..0931865 100644
--- a/services/camera/libcameraservice/api1/CameraClient.cpp
+++ b/services/camera/libcameraservice/api1/CameraClient.cpp
@@ -262,7 +262,8 @@
mHardware->stopPreview();
sCameraService->updateProxyDeviceState(
hardware::ICameraServiceProxy::CAMERA_STATE_IDLE,
- mCameraIdStr, mCameraFacing, mClientPackageName);
+ mCameraIdStr, mCameraFacing, mClientPackageName,
+ hardware::ICameraServiceProxy::CAMERA_API_LEVEL_1);
mHardware->cancelPicture();
// Release the hardware resources.
mHardware->release();
@@ -424,7 +425,8 @@
if (result == NO_ERROR) {
sCameraService->updateProxyDeviceState(
hardware::ICameraServiceProxy::CAMERA_STATE_ACTIVE,
- mCameraIdStr, mCameraFacing, mClientPackageName);
+ mCameraIdStr, mCameraFacing, mClientPackageName,
+ hardware::ICameraServiceProxy::CAMERA_API_LEVEL_1);
}
return result;
}
@@ -467,7 +469,8 @@
mHardware->stopPreview();
sCameraService->updateProxyDeviceState(
hardware::ICameraServiceProxy::CAMERA_STATE_IDLE,
- mCameraIdStr, mCameraFacing, mClientPackageName);
+ mCameraIdStr, mCameraFacing, mClientPackageName,
+ hardware::ICameraServiceProxy::CAMERA_API_LEVEL_1);
mPreviewBuffer.clear();
}
@@ -973,7 +976,8 @@
// idle now, until preview is restarted
sCameraService->updateProxyDeviceState(
hardware::ICameraServiceProxy::CAMERA_STATE_IDLE,
- mCameraIdStr, mCameraFacing, mClientPackageName);
+ mCameraIdStr, mCameraFacing, mClientPackageName,
+ hardware::ICameraServiceProxy::CAMERA_API_LEVEL_1);
mLock.unlock();
}
diff --git a/services/camera/libcameraservice/common/Camera2ClientBase.cpp b/services/camera/libcameraservice/common/Camera2ClientBase.cpp
index db26027..3266f09 100644
--- a/services/camera/libcameraservice/common/Camera2ClientBase.cpp
+++ b/services/camera/libcameraservice/common/Camera2ClientBase.cpp
@@ -251,7 +251,9 @@
if (mDeviceActive) {
getCameraService()->updateProxyDeviceState(
hardware::ICameraServiceProxy::CAMERA_STATE_IDLE, TClientBase::mCameraIdStr,
- TClientBase::mCameraFacing, TClientBase::mClientPackageName);
+ TClientBase::mCameraFacing, TClientBase::mClientPackageName,
+ ((mApi1CameraId < 0) ? hardware::ICameraServiceProxy::CAMERA_API_LEVEL_2 :
+ hardware::ICameraServiceProxy::CAMERA_API_LEVEL_1));
}
mDeviceActive = false;
@@ -267,7 +269,9 @@
if (!mDeviceActive) {
getCameraService()->updateProxyDeviceState(
hardware::ICameraServiceProxy::CAMERA_STATE_ACTIVE, TClientBase::mCameraIdStr,
- TClientBase::mCameraFacing, TClientBase::mClientPackageName);
+ TClientBase::mCameraFacing, TClientBase::mClientPackageName,
+ ((mApi1CameraId < 0) ? hardware::ICameraServiceProxy::CAMERA_API_LEVEL_2 :
+ hardware::ICameraServiceProxy::CAMERA_API_LEVEL_1));
}
mDeviceActive = true;