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
gugelfrei
Emilian Peev 6 years ago
parent 332adf69b9
commit 573291c251

@ -45,9 +45,15 @@ interface ICameraServiceProxy
const int CAMERA_FACING_FRONT = 1; const int CAMERA_FACING_FRONT = 1;
const int CAMERA_FACING_EXTERNAL = 2; const int CAMERA_FACING_EXTERNAL = 2;
/**
* Values for notifyCameraState api level
*/
const int CAMERA_API_LEVEL_1 = 1;
const int CAMERA_API_LEVEL_2 = 2;
/** /**
* Update the status of a camera device. * Update the status of a camera device.
*/ */
oneway void notifyCameraState(String cameraId, int facing, int newCameraState, oneway void notifyCameraState(String cameraId, int facing, int newCameraState,
String clientName); String clientName, int apiLevel);
} }

@ -2241,9 +2241,13 @@ status_t CameraService::BasicClient::startCameraOps() {
// Transition device availability listeners from PRESENT -> NOT_AVAILABLE // Transition device availability listeners from PRESENT -> NOT_AVAILABLE
sCameraService->updateStatus(StatusInternal::NOT_AVAILABLE, mCameraIdStr); 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 // Transition device state to OPEN
sCameraService->updateProxyDeviceState(ICameraServiceProxy::CAMERA_STATE_OPEN, sCameraService->updateProxyDeviceState(ICameraServiceProxy::CAMERA_STATE_OPEN,
mCameraIdStr, mCameraFacing, mClientPackageName); mCameraIdStr, mCameraFacing, mClientPackageName, apiLevel);
return OK; return OK;
} }
@ -2268,9 +2272,13 @@ status_t CameraService::BasicClient::finishCameraOps() {
sCameraService->updateStatus(StatusInternal::PRESENT, sCameraService->updateStatus(StatusInternal::PRESENT,
mCameraIdStr, rejected); 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 // Transition device state to CLOSED
sCameraService->updateProxyDeviceState(ICameraServiceProxy::CAMERA_STATE_CLOSED, sCameraService->updateProxyDeviceState(ICameraServiceProxy::CAMERA_STATE_CLOSED,
mCameraIdStr, mCameraFacing, mClientPackageName); mCameraIdStr, mCameraFacing, mClientPackageName, apiLevel);
} }
// Always stop watching, even if no camera op is active // Always stop watching, even if no camera op is active
if (mOpsCallback != NULL) { if (mOpsCallback != NULL) {
@ -2876,11 +2884,11 @@ void CameraService::CameraState::updateStatus(StatusInternal status,
} }
void CameraService::updateProxyDeviceState(int newState, 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(); sp<ICameraServiceProxy> proxyBinder = getCameraServiceProxy();
if (proxyBinder == nullptr) return; if (proxyBinder == nullptr) return;
String16 id(cameraId); String16 id(cameraId);
proxyBinder->notifyCameraState(id, newState, facing, clientName); proxyBinder->notifyCameraState(id, newState, facing, clientName, apiLevel);
} }
status_t CameraService::getTorchStatusLocked( status_t CameraService::getTorchStatusLocked(

@ -189,7 +189,8 @@ public:
int newState, int newState,
const String8& cameraId, const String8& cameraId,
int facing, int facing,
const String16& clientName); const String16& clientName,
int apiLevel);
///////////////////////////////////////////////////////////////////// /////////////////////////////////////////////////////////////////////
// CameraDeviceFactory functionality // CameraDeviceFactory functionality

@ -262,7 +262,8 @@ binder::Status CameraClient::disconnect() {
mHardware->stopPreview(); mHardware->stopPreview();
sCameraService->updateProxyDeviceState( sCameraService->updateProxyDeviceState(
hardware::ICameraServiceProxy::CAMERA_STATE_IDLE, hardware::ICameraServiceProxy::CAMERA_STATE_IDLE,
mCameraIdStr, mCameraFacing, mClientPackageName); mCameraIdStr, mCameraFacing, mClientPackageName,
hardware::ICameraServiceProxy::CAMERA_API_LEVEL_1);
mHardware->cancelPicture(); mHardware->cancelPicture();
// Release the hardware resources. // Release the hardware resources.
mHardware->release(); mHardware->release();
@ -424,7 +425,8 @@ status_t CameraClient::startPreviewMode() {
if (result == NO_ERROR) { if (result == NO_ERROR) {
sCameraService->updateProxyDeviceState( sCameraService->updateProxyDeviceState(
hardware::ICameraServiceProxy::CAMERA_STATE_ACTIVE, hardware::ICameraServiceProxy::CAMERA_STATE_ACTIVE,
mCameraIdStr, mCameraFacing, mClientPackageName); mCameraIdStr, mCameraFacing, mClientPackageName,
hardware::ICameraServiceProxy::CAMERA_API_LEVEL_1);
} }
return result; return result;
} }
@ -467,7 +469,8 @@ void CameraClient::stopPreview() {
mHardware->stopPreview(); mHardware->stopPreview();
sCameraService->updateProxyDeviceState( sCameraService->updateProxyDeviceState(
hardware::ICameraServiceProxy::CAMERA_STATE_IDLE, hardware::ICameraServiceProxy::CAMERA_STATE_IDLE,
mCameraIdStr, mCameraFacing, mClientPackageName); mCameraIdStr, mCameraFacing, mClientPackageName,
hardware::ICameraServiceProxy::CAMERA_API_LEVEL_1);
mPreviewBuffer.clear(); mPreviewBuffer.clear();
} }
@ -973,7 +976,8 @@ void CameraClient::handleShutter(void) {
// idle now, until preview is restarted // idle now, until preview is restarted
sCameraService->updateProxyDeviceState( sCameraService->updateProxyDeviceState(
hardware::ICameraServiceProxy::CAMERA_STATE_IDLE, hardware::ICameraServiceProxy::CAMERA_STATE_IDLE,
mCameraIdStr, mCameraFacing, mClientPackageName); mCameraIdStr, mCameraFacing, mClientPackageName,
hardware::ICameraServiceProxy::CAMERA_API_LEVEL_1);
mLock.unlock(); mLock.unlock();
} }

@ -251,7 +251,9 @@ void Camera2ClientBase<TClientBase>::notifyIdle() {
if (mDeviceActive) { if (mDeviceActive) {
getCameraService()->updateProxyDeviceState( getCameraService()->updateProxyDeviceState(
hardware::ICameraServiceProxy::CAMERA_STATE_IDLE, TClientBase::mCameraIdStr, 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; mDeviceActive = false;
@ -267,7 +269,9 @@ void Camera2ClientBase<TClientBase>::notifyShutter(const CaptureResultExtras& re
if (!mDeviceActive) { if (!mDeviceActive) {
getCameraService()->updateProxyDeviceState( getCameraService()->updateProxyDeviceState(
hardware::ICameraServiceProxy::CAMERA_STATE_ACTIVE, TClientBase::mCameraIdStr, 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; mDeviceActive = true;

Loading…
Cancel
Save