Loading camera/ICameraService.cpp +24 −0 Original line number Diff line number Diff line Loading @@ -209,6 +209,20 @@ public: return status; } virtual status_t setTorchMode(const String16& cameraId, bool enabled, const sp<IBinder>& clientBinder) { Parcel data, reply; data.writeInterfaceToken(ICameraService::getInterfaceDescriptor()); data.writeString16(cameraId); data.writeInt32(enabled ? 1 : 0); data.writeStrongBinder(clientBinder); remote()->transact(BnCameraService::SET_TORCH_MODE, data, &reply); if (readExceptionCode(reply)) return -EPROTO; return reply.readInt32(); } // connect to camera service (pro client) virtual status_t connectPro(const sp<IProCameraCallbacks>& cameraCb, int cameraId, const String16 &clientPackageName, int clientUid, Loading Loading @@ -490,6 +504,16 @@ status_t BnCameraService::onTransact( } return NO_ERROR; } break; case SET_TORCH_MODE: { CHECK_INTERFACE(ICameraService, data, reply); String16 cameraId = data.readString16(); bool enabled = data.readInt32() != 0 ? true : false; const sp<IBinder> clientBinder = data.readStrongBinder(); status_t status = setTorchMode(cameraId, enabled, clientBinder); reply->writeNoException(); reply->writeInt32(status); return NO_ERROR; } break; default: return BBinder::onTransact(code, data, reply, flags); } Loading camera/ICameraServiceListener.cpp +25 −2 Original line number Diff line number Diff line Loading @@ -29,6 +29,7 @@ namespace android { namespace { enum { STATUS_CHANGED = IBinder::FIRST_CALL_TRANSACTION, TORCH_STATUS_CHANGED, }; }; // namespace anonymous Loading @@ -54,8 +55,21 @@ public: data, &reply, IBinder::FLAG_ONEWAY); } reply.readExceptionCode(); virtual void onTorchStatusChanged(TorchStatus status, const String16 &cameraId) { Parcel data, reply; data.writeInterfaceToken( ICameraServiceListener::getInterfaceDescriptor()); data.writeInt32(static_cast<int32_t>(status)); data.writeString16(cameraId); remote()->transact(TORCH_STATUS_CHANGED, data, &reply, IBinder::FLAG_ONEWAY); } }; Loading @@ -75,7 +89,16 @@ status_t BnCameraServiceListener::onTransact( int32_t cameraId = data.readInt32(); onStatusChanged(status, cameraId); reply->writeNoException(); return NO_ERROR; } break; case TORCH_STATUS_CHANGED: { CHECK_INTERFACE(ICameraServiceListener, data, reply); TorchStatus status = static_cast<TorchStatus>(data.readInt32()); String16 cameraId = data.readString16(); onTorchStatusChanged(status, cameraId); return NO_ERROR; } break; Loading camera/tests/ProCameraTests.cpp +6 −0 Original line number Diff line number Diff line Loading @@ -89,6 +89,12 @@ struct ServiceListener : public BnCameraServiceListener { mCondition.broadcast(); } void onTorchStatusChanged(TorchStatus status, const String16& cameraId) { dout << "On torch status changed: 0x" << std::hex << (unsigned int) status << " cameraId " << cameraId.string() << std::endl; } status_t waitForStatusChange(Status& newStatus) { Mutex::Autolock al(mMutex); Loading include/camera/ICameraService.h +7 −0 Original line number Diff line number Diff line Loading @@ -53,6 +53,7 @@ public: GET_LEGACY_PARAMETERS, SUPPORTS_CAMERA_API, CONNECT_LEGACY, SET_TORCH_MODE, }; enum { Loading Loading @@ -142,6 +143,12 @@ public: int clientUid, /*out*/ sp<ICamera>& device) = 0; /** * Turn on or off a camera's torch mode. */ virtual status_t setTorchMode(const String16& cameraId, bool enabled, const sp<IBinder>& clientBinder) = 0; }; // ---------------------------------------------------------------------------- Loading include/camera/ICameraServiceListener.h +24 −0 Original line number Diff line number Diff line Loading @@ -66,9 +66,33 @@ public: STATUS_UNKNOWN = 0xFFFFFFFF, }; /** * The torch mode status of a camera. * * Initial status will be transmitted with onTorchStatusChanged immediately * after this listener is added to the service listener list. */ enum TorchStatus { // The camera's torch mode has become available to use via // setTorchMode(). TORCH_STATUS_AVAILABLE = TORCH_MODE_STATUS_AVAILABLE, // The camera's torch mode has become not available to use via // setTorchMode(). TORCH_STATUS_NOT_AVAILABLE = TORCH_MODE_STATUS_RESOURCE_BUSY, // The camera's torch mode has been turned off by setTorchMode(). TORCH_STATUS_OFF = TORCH_MODE_STATUS_OFF, // The camera's torch mode has been turned on by setTorchMode(). TORCH_STATUS_ON = 0x80000000, // Use to initialize variables only TORCH_STATUS_UNKNOWN = 0xFFFFFFFF, }; DECLARE_META_INTERFACE(CameraServiceListener); virtual void onStatusChanged(Status status, int32_t cameraId) = 0; virtual void onTorchStatusChanged(TorchStatus status, const String16& cameraId) = 0; }; // ---------------------------------------------------------------------------- Loading Loading
camera/ICameraService.cpp +24 −0 Original line number Diff line number Diff line Loading @@ -209,6 +209,20 @@ public: return status; } virtual status_t setTorchMode(const String16& cameraId, bool enabled, const sp<IBinder>& clientBinder) { Parcel data, reply; data.writeInterfaceToken(ICameraService::getInterfaceDescriptor()); data.writeString16(cameraId); data.writeInt32(enabled ? 1 : 0); data.writeStrongBinder(clientBinder); remote()->transact(BnCameraService::SET_TORCH_MODE, data, &reply); if (readExceptionCode(reply)) return -EPROTO; return reply.readInt32(); } // connect to camera service (pro client) virtual status_t connectPro(const sp<IProCameraCallbacks>& cameraCb, int cameraId, const String16 &clientPackageName, int clientUid, Loading Loading @@ -490,6 +504,16 @@ status_t BnCameraService::onTransact( } return NO_ERROR; } break; case SET_TORCH_MODE: { CHECK_INTERFACE(ICameraService, data, reply); String16 cameraId = data.readString16(); bool enabled = data.readInt32() != 0 ? true : false; const sp<IBinder> clientBinder = data.readStrongBinder(); status_t status = setTorchMode(cameraId, enabled, clientBinder); reply->writeNoException(); reply->writeInt32(status); return NO_ERROR; } break; default: return BBinder::onTransact(code, data, reply, flags); } Loading
camera/ICameraServiceListener.cpp +25 −2 Original line number Diff line number Diff line Loading @@ -29,6 +29,7 @@ namespace android { namespace { enum { STATUS_CHANGED = IBinder::FIRST_CALL_TRANSACTION, TORCH_STATUS_CHANGED, }; }; // namespace anonymous Loading @@ -54,8 +55,21 @@ public: data, &reply, IBinder::FLAG_ONEWAY); } reply.readExceptionCode(); virtual void onTorchStatusChanged(TorchStatus status, const String16 &cameraId) { Parcel data, reply; data.writeInterfaceToken( ICameraServiceListener::getInterfaceDescriptor()); data.writeInt32(static_cast<int32_t>(status)); data.writeString16(cameraId); remote()->transact(TORCH_STATUS_CHANGED, data, &reply, IBinder::FLAG_ONEWAY); } }; Loading @@ -75,7 +89,16 @@ status_t BnCameraServiceListener::onTransact( int32_t cameraId = data.readInt32(); onStatusChanged(status, cameraId); reply->writeNoException(); return NO_ERROR; } break; case TORCH_STATUS_CHANGED: { CHECK_INTERFACE(ICameraServiceListener, data, reply); TorchStatus status = static_cast<TorchStatus>(data.readInt32()); String16 cameraId = data.readString16(); onTorchStatusChanged(status, cameraId); return NO_ERROR; } break; Loading
camera/tests/ProCameraTests.cpp +6 −0 Original line number Diff line number Diff line Loading @@ -89,6 +89,12 @@ struct ServiceListener : public BnCameraServiceListener { mCondition.broadcast(); } void onTorchStatusChanged(TorchStatus status, const String16& cameraId) { dout << "On torch status changed: 0x" << std::hex << (unsigned int) status << " cameraId " << cameraId.string() << std::endl; } status_t waitForStatusChange(Status& newStatus) { Mutex::Autolock al(mMutex); Loading
include/camera/ICameraService.h +7 −0 Original line number Diff line number Diff line Loading @@ -53,6 +53,7 @@ public: GET_LEGACY_PARAMETERS, SUPPORTS_CAMERA_API, CONNECT_LEGACY, SET_TORCH_MODE, }; enum { Loading Loading @@ -142,6 +143,12 @@ public: int clientUid, /*out*/ sp<ICamera>& device) = 0; /** * Turn on or off a camera's torch mode. */ virtual status_t setTorchMode(const String16& cameraId, bool enabled, const sp<IBinder>& clientBinder) = 0; }; // ---------------------------------------------------------------------------- Loading
include/camera/ICameraServiceListener.h +24 −0 Original line number Diff line number Diff line Loading @@ -66,9 +66,33 @@ public: STATUS_UNKNOWN = 0xFFFFFFFF, }; /** * The torch mode status of a camera. * * Initial status will be transmitted with onTorchStatusChanged immediately * after this listener is added to the service listener list. */ enum TorchStatus { // The camera's torch mode has become available to use via // setTorchMode(). TORCH_STATUS_AVAILABLE = TORCH_MODE_STATUS_AVAILABLE, // The camera's torch mode has become not available to use via // setTorchMode(). TORCH_STATUS_NOT_AVAILABLE = TORCH_MODE_STATUS_RESOURCE_BUSY, // The camera's torch mode has been turned off by setTorchMode(). TORCH_STATUS_OFF = TORCH_MODE_STATUS_OFF, // The camera's torch mode has been turned on by setTorchMode(). TORCH_STATUS_ON = 0x80000000, // Use to initialize variables only TORCH_STATUS_UNKNOWN = 0xFFFFFFFF, }; DECLARE_META_INTERFACE(CameraServiceListener); virtual void onStatusChanged(Status status, int32_t cameraId) = 0; virtual void onTorchStatusChanged(TorchStatus status, const String16& cameraId) = 0; }; // ---------------------------------------------------------------------------- Loading