Loading camera/ICameraServiceProxy.cpp +20 −3 Original line number Diff line number Diff line Loading @@ -29,11 +29,21 @@ public: BpCameraServiceProxy(const sp<IBinder>& impl) : BpInterface<ICameraServiceProxy>(impl) {} virtual void pingForUserUpdate() { Parcel data, reply; Parcel data; data.writeInterfaceToken(ICameraServiceProxy::getInterfaceDescriptor()); remote()->transact(BnCameraServiceProxy::PING_FOR_USER_UPDATE, data, &reply, remote()->transact(BnCameraServiceProxy::PING_FOR_USER_UPDATE, data, nullptr, IBinder::FLAG_ONEWAY); } virtual void notifyCameraState(String16 cameraId, CameraState newCameraState) { Parcel data; data.writeInterfaceToken(ICameraServiceProxy::getInterfaceDescriptor()); data.writeString16(cameraId); data.writeInt32(newCameraState); remote()->transact(BnCameraServiceProxy::NOTIFY_CAMERA_STATE, data, nullptr, IBinder::FLAG_ONEWAY); } }; Loading @@ -47,9 +57,16 @@ status_t BnCameraServiceProxy::onTransact(uint32_t code, const Parcel& data, Par pingForUserUpdate(); return NO_ERROR; } break; case NOTIFY_CAMERA_STATE: { CHECK_INTERFACE(ICameraServiceProxy, data, reply); String16 cameraId = data.readString16(); CameraState newCameraState = static_cast<CameraState>(data.readInt32()); notifyCameraState(cameraId, newCameraState); return NO_ERROR; } break; default: return BBinder::onTransact(code, data, reply, flags); } } }; // namespace android include/camera/ICameraServiceProxy.h +15 −2 Original line number Diff line number Diff line Loading @@ -23,15 +23,30 @@ namespace android { /** * Interface from native camera service to managed-side camera service proxy. * * Keep in sync with frameworks/base/core/java/android/hardware/ICameraServiceProxy.aidl * */ class ICameraServiceProxy : public IInterface { public: enum { PING_FOR_USER_UPDATE = IBinder::FIRST_CALL_TRANSACTION, NOTIFY_CAMERA_STATE }; enum CameraState { CAMERA_STATE_OPEN, CAMERA_STATE_ACTIVE, CAMERA_STATE_IDLE, CAMERA_STATE_CLOSED }; DECLARE_META_INTERFACE(CameraServiceProxy); virtual void pingForUserUpdate() = 0; virtual void notifyCameraState(String16 cameraId, CameraState newCameraState) = 0; }; class BnCameraServiceProxy: public BnInterface<ICameraServiceProxy> Loading @@ -48,5 +63,3 @@ public: }; // namespace android #endif // ANDROID_HARDWARE_ICAMERASERVICEPROXY_H services/camera/libcameraservice/CameraService.cpp +24 −3 Original line number Diff line number Diff line Loading @@ -33,7 +33,6 @@ #include <binder/MemoryBase.h> #include <binder/MemoryHeapBase.h> #include <binder/ProcessInfoService.h> #include <camera/ICameraServiceProxy.h> #include <cutils/atomic.h> #include <cutils/properties.h> #include <gui/Surface.h> Loading Loading @@ -250,13 +249,19 @@ void CameraService::onFirstRef() CameraService::pingCameraServiceProxy(); } void CameraService::pingCameraServiceProxy() { sp<ICameraServiceProxy> CameraService::getCameraServiceProxy() { sp<IServiceManager> sm = defaultServiceManager(); sp<IBinder> binder = sm->getService(String16("media.camera.proxy")); if (binder == nullptr) { return; return nullptr; } sp<ICameraServiceProxy> proxyBinder = interface_cast<ICameraServiceProxy>(binder); return proxyBinder; } void CameraService::pingCameraServiceProxy() { sp<ICameraServiceProxy> proxyBinder = getCameraServiceProxy(); if (proxyBinder == nullptr) return; proxyBinder->pingForUserUpdate(); } Loading Loading @@ -1948,6 +1953,10 @@ status_t CameraService::BasicClient::startCameraOps() { mCameraService->updateStatus(ICameraServiceListener::STATUS_NOT_AVAILABLE, String8::format("%d", mCameraId)); // Transition device state to OPEN mCameraService->updateProxyDeviceState(ICameraServiceProxy::CAMERA_STATE_OPEN, String8::format("%d", mCameraId)); return OK; } Loading @@ -1966,6 +1975,10 @@ status_t CameraService::BasicClient::finishCameraOps() { mCameraService->updateStatus(ICameraServiceListener::STATUS_PRESENT, String8::format("%d", mCameraId), rejected); // Transition device state to CLOSED mCameraService->updateProxyDeviceState(ICameraServiceProxy::CAMERA_STATE_CLOSED, String8::format("%d", mCameraId)); // Notify flashlight that a camera device is closed. mCameraService->mFlashlight->deviceClosed( String8::format("%d", mCameraId)); Loading Loading @@ -2466,6 +2479,14 @@ void CameraService::updateStatus(ICameraServiceListener::Status status, const St }); } void CameraService::updateProxyDeviceState(ICameraServiceProxy::CameraState newState, const String8& cameraId) { sp<ICameraServiceProxy> proxyBinder = getCameraServiceProxy(); if (proxyBinder == nullptr) return; String16 id(cameraId); proxyBinder->notifyCameraState(id, newState); } status_t CameraService::getTorchStatusLocked( const String8& cameraId, ICameraServiceListener::TorchStatus *status) const { Loading services/camera/libcameraservice/CameraService.h +10 −0 Original line number Diff line number Diff line Loading @@ -24,6 +24,7 @@ #include <binder/BinderService.h> #include <binder/IAppOpsCallback.h> #include <camera/ICameraService.h> #include <camera/ICameraServiceProxy.h> #include <hardware/camera.h> #include <camera/ICamera.h> Loading Loading @@ -164,6 +165,14 @@ public: void playSound(sound_kind kind); void releaseSound(); /** * Update the state of a given camera device (open/close/active/idle) with * the camera proxy service in the system service */ static void updateProxyDeviceState( ICameraServiceProxy::CameraState newState, const String8& cameraId); ///////////////////////////////////////////////////////////////////// // CameraDeviceFactory functionality int getDeviceVersion(int cameraId, int* facing = NULL); Loading Loading @@ -728,6 +737,7 @@ private: static String8 toString(std::set<userid_t> intSet); static sp<ICameraServiceProxy> getCameraServiceProxy(); static void pingCameraServiceProxy(); }; Loading services/camera/libcameraservice/api1/Camera2Client.cpp +2 −0 Original line number Diff line number Diff line Loading @@ -1912,6 +1912,8 @@ void Camera2Client::notifyShutter(const CaptureResultExtras& resultExtras, ALOGV("%s: Shutter notification for request id %" PRId32 " at time %" PRId64, __FUNCTION__, resultExtras.requestId, timestamp); mCaptureSequencer->notifyShutter(resultExtras, timestamp); Camera2ClientBase::notifyShutter(resultExtras, timestamp); } camera2::SharedParameters& Camera2Client::getParameters() { Loading Loading
camera/ICameraServiceProxy.cpp +20 −3 Original line number Diff line number Diff line Loading @@ -29,11 +29,21 @@ public: BpCameraServiceProxy(const sp<IBinder>& impl) : BpInterface<ICameraServiceProxy>(impl) {} virtual void pingForUserUpdate() { Parcel data, reply; Parcel data; data.writeInterfaceToken(ICameraServiceProxy::getInterfaceDescriptor()); remote()->transact(BnCameraServiceProxy::PING_FOR_USER_UPDATE, data, &reply, remote()->transact(BnCameraServiceProxy::PING_FOR_USER_UPDATE, data, nullptr, IBinder::FLAG_ONEWAY); } virtual void notifyCameraState(String16 cameraId, CameraState newCameraState) { Parcel data; data.writeInterfaceToken(ICameraServiceProxy::getInterfaceDescriptor()); data.writeString16(cameraId); data.writeInt32(newCameraState); remote()->transact(BnCameraServiceProxy::NOTIFY_CAMERA_STATE, data, nullptr, IBinder::FLAG_ONEWAY); } }; Loading @@ -47,9 +57,16 @@ status_t BnCameraServiceProxy::onTransact(uint32_t code, const Parcel& data, Par pingForUserUpdate(); return NO_ERROR; } break; case NOTIFY_CAMERA_STATE: { CHECK_INTERFACE(ICameraServiceProxy, data, reply); String16 cameraId = data.readString16(); CameraState newCameraState = static_cast<CameraState>(data.readInt32()); notifyCameraState(cameraId, newCameraState); return NO_ERROR; } break; default: return BBinder::onTransact(code, data, reply, flags); } } }; // namespace android
include/camera/ICameraServiceProxy.h +15 −2 Original line number Diff line number Diff line Loading @@ -23,15 +23,30 @@ namespace android { /** * Interface from native camera service to managed-side camera service proxy. * * Keep in sync with frameworks/base/core/java/android/hardware/ICameraServiceProxy.aidl * */ class ICameraServiceProxy : public IInterface { public: enum { PING_FOR_USER_UPDATE = IBinder::FIRST_CALL_TRANSACTION, NOTIFY_CAMERA_STATE }; enum CameraState { CAMERA_STATE_OPEN, CAMERA_STATE_ACTIVE, CAMERA_STATE_IDLE, CAMERA_STATE_CLOSED }; DECLARE_META_INTERFACE(CameraServiceProxy); virtual void pingForUserUpdate() = 0; virtual void notifyCameraState(String16 cameraId, CameraState newCameraState) = 0; }; class BnCameraServiceProxy: public BnInterface<ICameraServiceProxy> Loading @@ -48,5 +63,3 @@ public: }; // namespace android #endif // ANDROID_HARDWARE_ICAMERASERVICEPROXY_H
services/camera/libcameraservice/CameraService.cpp +24 −3 Original line number Diff line number Diff line Loading @@ -33,7 +33,6 @@ #include <binder/MemoryBase.h> #include <binder/MemoryHeapBase.h> #include <binder/ProcessInfoService.h> #include <camera/ICameraServiceProxy.h> #include <cutils/atomic.h> #include <cutils/properties.h> #include <gui/Surface.h> Loading Loading @@ -250,13 +249,19 @@ void CameraService::onFirstRef() CameraService::pingCameraServiceProxy(); } void CameraService::pingCameraServiceProxy() { sp<ICameraServiceProxy> CameraService::getCameraServiceProxy() { sp<IServiceManager> sm = defaultServiceManager(); sp<IBinder> binder = sm->getService(String16("media.camera.proxy")); if (binder == nullptr) { return; return nullptr; } sp<ICameraServiceProxy> proxyBinder = interface_cast<ICameraServiceProxy>(binder); return proxyBinder; } void CameraService::pingCameraServiceProxy() { sp<ICameraServiceProxy> proxyBinder = getCameraServiceProxy(); if (proxyBinder == nullptr) return; proxyBinder->pingForUserUpdate(); } Loading Loading @@ -1948,6 +1953,10 @@ status_t CameraService::BasicClient::startCameraOps() { mCameraService->updateStatus(ICameraServiceListener::STATUS_NOT_AVAILABLE, String8::format("%d", mCameraId)); // Transition device state to OPEN mCameraService->updateProxyDeviceState(ICameraServiceProxy::CAMERA_STATE_OPEN, String8::format("%d", mCameraId)); return OK; } Loading @@ -1966,6 +1975,10 @@ status_t CameraService::BasicClient::finishCameraOps() { mCameraService->updateStatus(ICameraServiceListener::STATUS_PRESENT, String8::format("%d", mCameraId), rejected); // Transition device state to CLOSED mCameraService->updateProxyDeviceState(ICameraServiceProxy::CAMERA_STATE_CLOSED, String8::format("%d", mCameraId)); // Notify flashlight that a camera device is closed. mCameraService->mFlashlight->deviceClosed( String8::format("%d", mCameraId)); Loading Loading @@ -2466,6 +2479,14 @@ void CameraService::updateStatus(ICameraServiceListener::Status status, const St }); } void CameraService::updateProxyDeviceState(ICameraServiceProxy::CameraState newState, const String8& cameraId) { sp<ICameraServiceProxy> proxyBinder = getCameraServiceProxy(); if (proxyBinder == nullptr) return; String16 id(cameraId); proxyBinder->notifyCameraState(id, newState); } status_t CameraService::getTorchStatusLocked( const String8& cameraId, ICameraServiceListener::TorchStatus *status) const { Loading
services/camera/libcameraservice/CameraService.h +10 −0 Original line number Diff line number Diff line Loading @@ -24,6 +24,7 @@ #include <binder/BinderService.h> #include <binder/IAppOpsCallback.h> #include <camera/ICameraService.h> #include <camera/ICameraServiceProxy.h> #include <hardware/camera.h> #include <camera/ICamera.h> Loading Loading @@ -164,6 +165,14 @@ public: void playSound(sound_kind kind); void releaseSound(); /** * Update the state of a given camera device (open/close/active/idle) with * the camera proxy service in the system service */ static void updateProxyDeviceState( ICameraServiceProxy::CameraState newState, const String8& cameraId); ///////////////////////////////////////////////////////////////////// // CameraDeviceFactory functionality int getDeviceVersion(int cameraId, int* facing = NULL); Loading Loading @@ -728,6 +737,7 @@ private: static String8 toString(std::set<userid_t> intSet); static sp<ICameraServiceProxy> getCameraServiceProxy(); static void pingCameraServiceProxy(); }; Loading
services/camera/libcameraservice/api1/Camera2Client.cpp +2 −0 Original line number Diff line number Diff line Loading @@ -1912,6 +1912,8 @@ void Camera2Client::notifyShutter(const CaptureResultExtras& resultExtras, ALOGV("%s: Shutter notification for request id %" PRId32 " at time %" PRId64, __FUNCTION__, resultExtras.requestId, timestamp); mCaptureSequencer->notifyShutter(resultExtras, timestamp); Camera2ClientBase::notifyShutter(resultExtras, timestamp); } camera2::SharedParameters& Camera2Client::getParameters() { Loading