Loading camera/Camera.cpp +3 −2 Original line number Diff line number Diff line Loading @@ -71,10 +71,11 @@ Camera::~Camera() sp<Camera> Camera::connect(int cameraId, const std::string& clientPackageName, int clientUid, int clientPid, int targetSdkVersion, bool overrideToPortrait, bool forceSlowJpegMode) bool forceSlowJpegMode, int32_t deviceId, int32_t devicePolicy) { return CameraBaseT::connect(cameraId, clientPackageName, clientUid, clientPid, targetSdkVersion, overrideToPortrait, forceSlowJpegMode); clientPid, targetSdkVersion, overrideToPortrait, forceSlowJpegMode, deviceId, devicePolicy); } status_t Camera::reconnect() Loading camera/CameraBase.cpp +15 −9 Original line number Diff line number Diff line Loading @@ -73,6 +73,9 @@ status_t CameraStatus::writeToParcel(android::Parcel* parcel) const { if (res != OK) return res; res = parcel->writeString16(toString16(clientPackage)); if (res != OK) return res; res = parcel->writeInt32(deviceId); return res; } Loading @@ -97,6 +100,7 @@ status_t CameraStatus::readFromParcel(const android::Parcel* parcel) { if (res != OK) return res; clientPackage = toStdString(tempClientPackage); res = parcel->readInt32(&deviceId); return res; } Loading @@ -123,7 +127,7 @@ namespace { }; sp<DeathNotifier> gDeathNotifier; }; // namespace anonymous } // namespace anonymous /////////////////////////////////////////////////////////// // CameraBase definition Loading Loading @@ -159,7 +163,8 @@ template <typename TCam, typename TCamTraits> sp<TCam> CameraBase<TCam, TCamTraits>::connect(int cameraId, const std::string& clientPackageName, int clientUid, int clientPid, int targetSdkVersion, bool overrideToPortrait, bool forceSlowJpegMode) bool overrideToPortrait, bool forceSlowJpegMode, int32_t deviceId, int32_t devicePolicy) { ALOGV("%s: connect", __FUNCTION__); sp<TCam> c = new TCam(cameraId); Loading @@ -172,8 +177,8 @@ sp<TCam> CameraBase<TCam, TCamTraits>::connect(int cameraId, ALOGI("Connect camera (legacy API) - overrideToPortrait %d, forceSlowJpegMode %d", overrideToPortrait, forceSlowJpegMode); ret = (cs.get()->*fnConnectService)(cl, cameraId, clientPackageName, clientUid, clientPid, targetSdkVersion, overrideToPortrait, forceSlowJpegMode, /*out*/ &c->mCamera); clientPid, targetSdkVersion, overrideToPortrait, forceSlowJpegMode, deviceId, devicePolicy, /*out*/ &c->mCamera); } if (ret.isOk() && c->mCamera != nullptr) { IInterface::asBinder(c->mCamera)->linkToDeath(c); Loading Loading @@ -252,7 +257,7 @@ void CameraBase<TCam, TCamTraits>::notifyCallback(int32_t msgType, } template <typename TCam, typename TCamTraits> int CameraBase<TCam, TCamTraits>::getNumberOfCameras() { int CameraBase<TCam, TCamTraits>::getNumberOfCameras(int32_t deviceId, int32_t devicePolicy) { const sp<::android::hardware::ICameraService> cs = getCameraService(); if (!cs.get()) { Loading @@ -261,8 +266,8 @@ int CameraBase<TCam, TCamTraits>::getNumberOfCameras() { } int32_t count; binder::Status res = cs->getNumberOfCameras( ::android::hardware::ICameraService::CAMERA_TYPE_BACKWARD_COMPATIBLE, &count); ::android::hardware::ICameraService::CAMERA_TYPE_BACKWARD_COMPATIBLE, deviceId, devicePolicy, &count); if (!res.isOk()) { ALOGE("Error reading number of cameras: %s", res.toString8().c_str()); Loading @@ -274,11 +279,12 @@ int CameraBase<TCam, TCamTraits>::getNumberOfCameras() { // this can be in BaseCamera but it should be an instance method template <typename TCam, typename TCamTraits> status_t CameraBase<TCam, TCamTraits>::getCameraInfo(int cameraId, bool overrideToPortrait, bool overrideToPortrait, int32_t deviceId, int32_t devicePolicy, struct hardware::CameraInfo* cameraInfo) { const sp<::android::hardware::ICameraService> cs = getCameraService(); if (cs == 0) return UNKNOWN_ERROR; binder::Status res = cs->getCameraInfo(cameraId, overrideToPortrait, cameraInfo); binder::Status res = cs->getCameraInfo(cameraId, overrideToPortrait, deviceId, devicePolicy, cameraInfo); return res.isOk() ? OK : res.serviceSpecificErrorCode(); } Loading camera/aidl/android/hardware/ICameraService.aidl +137 −24 Original line number Diff line number Diff line Loading @@ -63,14 +63,33 @@ interface ICameraService const int CAMERA_TYPE_ALL = 1; /** * Return the number of camera devices available in the system * Return the number of camera devices available in the system. * * @param type The type of the camera, can be either CAMERA_TYPE_BACKWARD_COMPATIBLE * or CAMERA_TYPE_ALL. * @param deviceId The device id of the context associated with the caller. * @param devicePolicy The camera policy of the device of the associated context (default * policy for default device context). Only virtual cameras would be exposed * only for custom policy and only real cameras would be exposed for default * policy. */ int getNumberOfCameras(int type); int getNumberOfCameras(int type, int deviceId, int devicePolicy); /** * Fetch basic camera information for a camera device * Fetch basic camera information for a camera. * * @param cameraId The ID of the camera to fetch information for. * @param overrideToPortrait Whether to override the sensor orientation information to * correspond to portrait. * @param deviceId The device id of the context associated with the caller. * @param devicePolicy The camera policy of the device of the associated context (default * policy for default device context). Only virtual cameras would be exposed * only for custom policy and only real cameras would be exposed for default * policy. * @return CameraInfo for the camera. */ CameraInfo getCameraInfo(int cameraId, boolean overrideToPortrait); CameraInfo getCameraInfo(int cameraId, boolean overrideToPortrait, int deviceId, int devicePolicy); /** * Default UID/PID values for non-privileged callers of Loading @@ -80,7 +99,20 @@ interface ICameraService const int USE_CALLING_PID = -1; /** * Open a camera device through the old camera API * Open a camera device through the old camera API. * * @param cameraId The ID of the camera to open. * @param opPackageName The package name to report for the app-ops. * @param clientUid UID for the calling client. * @param clientPid PID for the calling client. * @param overrideToPortrait Whether to override the sensor orientation information to * correspond to portrait. * @param forceSlowJpegMode Whether to force slow jpeg mode. * @param deviceId The device id of the context associated with the caller. * @param devicePolicy The camera policy of the device of the associated context (default * policy for default device context). Only virtual cameras would be exposed * only for custom policy and only real cameras would be exposed for default * policy. */ ICamera connect(ICameraClient client, int cameraId, Loading @@ -88,11 +120,24 @@ interface ICameraService int clientUid, int clientPid, int targetSdkVersion, boolean overrideToPortrait, boolean forceSlowJpegMode); boolean forceSlowJpegMode, int deviceId, int devicePolicy); /** * Open a camera device through the new camera API * Only supported for device HAL versions >= 3.2 * Open a camera device through the new camera API. * Only supported for device HAL versions >= 3.2. * * @param cameraId The ID of the camera to open. * @param opPackageName The package name to report for the app-ops. * @param clientUid UID for the calling client. * @param overrideToPortrait Whether to override the sensor orientation information to * correspond to portrait. * @param deviceId The device id of the context associated with the caller. * @param devicePolicy The camera policy of the device of the associated context (default * policy for default device context). Only virtual cameras would be exposed * only for custom policy and only real cameras would be exposed for default * policy. */ ICameraDeviceUser connectDevice(ICameraDeviceCallbacks callbacks, @utf8InCpp String cameraId, Loading @@ -100,7 +145,9 @@ interface ICameraService @nullable @utf8InCpp String featureId, int clientUid, int oomScoreOffset, int targetSdkVersion, boolean overrideToPortrait); boolean overrideToPortrait, int deviceId, int devicePolicy); /** * Add listener for changes to camera device and flashlight state. Loading Loading @@ -168,9 +215,19 @@ interface ICameraService /** * Read the static camera metadata for a camera device. * Only supported for device HAL versions >= 3.2 * * @param cameraId The ID of the camera to fetch metadata for. * @param overrideToPortrait Whether to override the sensor orientation information to * correspond to portrait. * @param deviceId The device id of the context associated with the caller. * @param devicePolicy The camera policy of the device of the associated context (default * policy for default device context). Only virtual cameras would be exposed * only for custom policy and only real cameras would be exposed for default * policy. * @return Characteristics for the given camera. */ CameraMetadataNative getCameraCharacteristics(@utf8InCpp String cameraId, int targetSdkVersion, boolean overrideToPortrait); boolean overrideToPortrait, int deviceId, int devicePolicy); /** * Read in the vendor tag descriptors from the camera module HAL. Loading Loading @@ -206,14 +263,46 @@ interface ICameraService ICameraInjectionSession injectCamera(@utf8InCpp String packageName, @utf8InCpp String internalCamId, @utf8InCpp String externalCamId, in ICameraInjectionCallback CameraInjectionCallback); void setTorchMode(@utf8InCpp String cameraId, boolean enabled, IBinder clientBinder); /** * Set the torch mode for a camera device. * * @param cameraId The ID of the camera to set torch mode for. * @param deviceId The device id of the context associated with the caller. * @param devicePolicy The camera policy of the device of the associated context (default * policy for default device context). Only virtual cameras would be exposed * only for custom policy and only real cameras would be exposed for default * policy. */ void setTorchMode(@utf8InCpp String cameraId, boolean enabled, IBinder clientBinder, int deviceId, int devicePolicy); // Change the brightness level of the flash unit associated with cameraId to strengthLevel. // If the torch is in OFF state and strengthLevel > 0 then the torch will also be turned ON. void turnOnTorchWithStrengthLevel(@utf8InCpp String cameraId, int strengthLevel, IBinder clientBinder); /** * Change the brightness level of the flash unit associated with cameraId to strengthLevel. * If the torch is in OFF state and strengthLevel > 0 then the torch will also be turned ON. * * @param cameraId The ID of the camera. * @param strengthLevel The torch strength level to set for the camera. * @param deviceId The device id of the context associated with the caller. * @param devicePolicy The camera policy of the device of the associated context (default * policy for default device context). Only virtual cameras would be exposed * only for custom policy and only real cameras would be exposed for default * policy. */ void turnOnTorchWithStrengthLevel(@utf8InCpp String cameraId, int strengthLevel, IBinder clientBinder, int deviceId, int devicePolicy); // Get the brightness level of the flash unit associated with cameraId. int getTorchStrengthLevel(@utf8InCpp String cameraId); /** * Get the brightness level of the flash unit associated with cameraId. * * @param cameraId The ID of the camera. * @param deviceId The device id of the context associated with the caller. * @param devicePolicy The camera policy of the device of the associated context (default * policy for default device context). Only virtual cameras would be exposed * only for custom policy and only real cameras would be exposed for default * policy. * @return Torch strength level for the camera. */ int getTorchStrengthLevel(@utf8InCpp String cameraId, int deviceId, int devicePolicy); /** * Notify the camera service of a system event. Should only be called from system_server. Loading Loading @@ -274,8 +363,20 @@ interface ICameraService const int DEVICE_STATE_FOLDED = 4; const int DEVICE_STATE_LAST_FRAMEWORK_BIT = 0x80000000; // 1 << 31; // Create a CaptureRequest metadata based on template id CameraMetadataNative createDefaultRequest(@utf8InCpp String cameraId, int templateId); /** * Create a CaptureRequest metadata based on template id * * @param cameraId The camera id to create the CaptureRequest for. * @param templateId The template id create the CaptureRequest for. * @param deviceId the device id of the context associated with the caller. * @param devicePolicy The camera policy of the device of the associated context (default * policy for default device context). Only virtual cameras would be exposed * only for custom policy and only real cameras would be exposed for default * policy. * @return Metadata representing the CaptureRequest. */ CameraMetadataNative createDefaultRequest(@utf8InCpp String cameraId, int templateId, int deviceId, int devicePolicy); /** * Check whether a particular session configuration with optional session parameters Loading @@ -283,23 +384,35 @@ interface ICameraService * * @param cameraId The camera id to query session configuration for * @param sessionConfiguration Specific session configuration to be verified. * @param deviceId The device id of the context associated with the caller. * @param devicePolicy The camera policy of the device of the associated context (default * policy for default device context). Only virtual cameras would be exposed * only for custom policy and only real cameras would be exposed for default * policy. * @return true - in case the stream combination is supported. * false - in case there is no device support. */ boolean isSessionConfigurationWithParametersSupported(@utf8InCpp String cameraId, in SessionConfiguration sessionConfiguration); in SessionConfiguration sessionConfiguration, int deviceId, int devicePolicy); /** * Get the camera characteristics for a particular session configuration for * the given camera device. * * @param cameraId ID of the device for which the session characteristics must be fetched. * @param sessionConfiguration session configuration for which the characteristics * @param sessionConfiguration Session configuration for which the characteristics * must be fetched. * @return - characteristics associated with the given session. * @param deviceId The device id of the context associated with the caller. * @param devicePolicy The camera policy of the device of the associated context (default * policy for default device context). Only virtual cameras would be exposed * only for custom policy and only real cameras would be exposed for default * policy. * @return Characteristics associated with the given session. */ CameraMetadataNative getSessionCharacteristics(@utf8InCpp String cameraId, int targetSdkVersion, boolean overrideToPortrait, in SessionConfiguration sessionConfiguration); in SessionConfiguration sessionConfiguration, int deviceId, int devicePolicy); } camera/aidl/android/hardware/ICameraServiceListener.aidl +12 −6 Original line number Diff line number Diff line Loading @@ -51,14 +51,20 @@ interface ICameraServiceListener // Use to initialize variables only const int STATUS_UNKNOWN = -1; oneway void onStatusChanged(int status, @utf8InCpp String cameraId); // We pass deviceId associated with a camera in the callbacks, which is the id of the virtual // device owning the camera (for virtual cameras), or kDefaultDeviceId (for real // cameras). The deviceId is being passed so that the API layer (CameraManagerGlobal) can filter // out the cameras that don't correspond to the context associated with the caller who // registers a callback. oneway void onStatusChanged(int status, @utf8InCpp String cameraId, int deviceId); /** * Notify registered client about status changes for a physical camera backing * a logical camera. */ oneway void onPhysicalCameraStatusChanged(int status, @utf8InCpp String cameraId, @utf8InCpp String physicalCameraId); @utf8InCpp String physicalCameraId, int deviceId); /** * The torch mode status of a camera. Loading @@ -82,9 +88,9 @@ interface ICameraServiceListener // Use to initialize variables only const int TORCH_STATUS_UNKNOWN = -1; oneway void onTorchStatusChanged(int status, @utf8InCpp String cameraId); oneway void onTorchStatusChanged(int status, @utf8InCpp String cameraId, int deviceId); oneway void onTorchStrengthLevelChanged(@utf8InCpp String cameraId, int newTorchStrength); oneway void onTorchStrengthLevelChanged(@utf8InCpp String cameraId, int newTorchStrength, int deviceId); /** * Notify registered clients about camera access priority changes. Loading @@ -98,6 +104,6 @@ interface ICameraServiceListener * Only clients with android.permission.CAMERA_OPEN_CLOSE_LISTENER permission * will receive such callbacks. */ oneway void onCameraOpened(@utf8InCpp String cameraId, @utf8InCpp String clientPackageId); oneway void onCameraClosed(@utf8InCpp String cameraId); oneway void onCameraOpened(@utf8InCpp String cameraId, @utf8InCpp String clientPackageId, int deviceId); oneway void onCameraClosed(@utf8InCpp String cameraId, int deviceId); } camera/include/camera/Camera.h +5 −3 Original line number Diff line number Diff line Loading @@ -27,6 +27,7 @@ #include <camera/android/hardware/ICamera.h> #include <camera/android/hardware/ICameraClient.h> #include <camera/CameraBase.h> #include <camera/CameraUtils.h> namespace android { Loading Loading @@ -58,7 +59,7 @@ struct CameraTraits<Camera> typedef ::android::hardware::ICameraClient TCamCallbacks; typedef ::android::binder::Status (::android::hardware::ICameraService::*TCamConnectService) (const sp<::android::hardware::ICameraClient>&, int, const std::string&, int, int, int, bool, bool, int, const std::string&, int, int, int, bool, bool, int32_t, int32_t, /*out*/ sp<::android::hardware::ICamera>*); static TCamConnectService fnConnectService; Loading @@ -82,7 +83,8 @@ public: static sp<Camera> connect(int cameraId, const std::string& clientPackageName, int clientUid, int clientPid, int targetSdkVersion, bool overrideToPortrait, bool forceSlowJpegMode); bool overrideToPortrait, bool forceSlowJpegMode, int32_t deviceId = kDefaultDeviceId, int32_t devicePolicy = 0); virtual ~Camera(); Loading Loading @@ -197,6 +199,6 @@ protected: friend class CameraBase; }; }; // namespace android } // namespace android #endif Loading
camera/Camera.cpp +3 −2 Original line number Diff line number Diff line Loading @@ -71,10 +71,11 @@ Camera::~Camera() sp<Camera> Camera::connect(int cameraId, const std::string& clientPackageName, int clientUid, int clientPid, int targetSdkVersion, bool overrideToPortrait, bool forceSlowJpegMode) bool forceSlowJpegMode, int32_t deviceId, int32_t devicePolicy) { return CameraBaseT::connect(cameraId, clientPackageName, clientUid, clientPid, targetSdkVersion, overrideToPortrait, forceSlowJpegMode); clientPid, targetSdkVersion, overrideToPortrait, forceSlowJpegMode, deviceId, devicePolicy); } status_t Camera::reconnect() Loading
camera/CameraBase.cpp +15 −9 Original line number Diff line number Diff line Loading @@ -73,6 +73,9 @@ status_t CameraStatus::writeToParcel(android::Parcel* parcel) const { if (res != OK) return res; res = parcel->writeString16(toString16(clientPackage)); if (res != OK) return res; res = parcel->writeInt32(deviceId); return res; } Loading @@ -97,6 +100,7 @@ status_t CameraStatus::readFromParcel(const android::Parcel* parcel) { if (res != OK) return res; clientPackage = toStdString(tempClientPackage); res = parcel->readInt32(&deviceId); return res; } Loading @@ -123,7 +127,7 @@ namespace { }; sp<DeathNotifier> gDeathNotifier; }; // namespace anonymous } // namespace anonymous /////////////////////////////////////////////////////////// // CameraBase definition Loading Loading @@ -159,7 +163,8 @@ template <typename TCam, typename TCamTraits> sp<TCam> CameraBase<TCam, TCamTraits>::connect(int cameraId, const std::string& clientPackageName, int clientUid, int clientPid, int targetSdkVersion, bool overrideToPortrait, bool forceSlowJpegMode) bool overrideToPortrait, bool forceSlowJpegMode, int32_t deviceId, int32_t devicePolicy) { ALOGV("%s: connect", __FUNCTION__); sp<TCam> c = new TCam(cameraId); Loading @@ -172,8 +177,8 @@ sp<TCam> CameraBase<TCam, TCamTraits>::connect(int cameraId, ALOGI("Connect camera (legacy API) - overrideToPortrait %d, forceSlowJpegMode %d", overrideToPortrait, forceSlowJpegMode); ret = (cs.get()->*fnConnectService)(cl, cameraId, clientPackageName, clientUid, clientPid, targetSdkVersion, overrideToPortrait, forceSlowJpegMode, /*out*/ &c->mCamera); clientPid, targetSdkVersion, overrideToPortrait, forceSlowJpegMode, deviceId, devicePolicy, /*out*/ &c->mCamera); } if (ret.isOk() && c->mCamera != nullptr) { IInterface::asBinder(c->mCamera)->linkToDeath(c); Loading Loading @@ -252,7 +257,7 @@ void CameraBase<TCam, TCamTraits>::notifyCallback(int32_t msgType, } template <typename TCam, typename TCamTraits> int CameraBase<TCam, TCamTraits>::getNumberOfCameras() { int CameraBase<TCam, TCamTraits>::getNumberOfCameras(int32_t deviceId, int32_t devicePolicy) { const sp<::android::hardware::ICameraService> cs = getCameraService(); if (!cs.get()) { Loading @@ -261,8 +266,8 @@ int CameraBase<TCam, TCamTraits>::getNumberOfCameras() { } int32_t count; binder::Status res = cs->getNumberOfCameras( ::android::hardware::ICameraService::CAMERA_TYPE_BACKWARD_COMPATIBLE, &count); ::android::hardware::ICameraService::CAMERA_TYPE_BACKWARD_COMPATIBLE, deviceId, devicePolicy, &count); if (!res.isOk()) { ALOGE("Error reading number of cameras: %s", res.toString8().c_str()); Loading @@ -274,11 +279,12 @@ int CameraBase<TCam, TCamTraits>::getNumberOfCameras() { // this can be in BaseCamera but it should be an instance method template <typename TCam, typename TCamTraits> status_t CameraBase<TCam, TCamTraits>::getCameraInfo(int cameraId, bool overrideToPortrait, bool overrideToPortrait, int32_t deviceId, int32_t devicePolicy, struct hardware::CameraInfo* cameraInfo) { const sp<::android::hardware::ICameraService> cs = getCameraService(); if (cs == 0) return UNKNOWN_ERROR; binder::Status res = cs->getCameraInfo(cameraId, overrideToPortrait, cameraInfo); binder::Status res = cs->getCameraInfo(cameraId, overrideToPortrait, deviceId, devicePolicy, cameraInfo); return res.isOk() ? OK : res.serviceSpecificErrorCode(); } Loading
camera/aidl/android/hardware/ICameraService.aidl +137 −24 Original line number Diff line number Diff line Loading @@ -63,14 +63,33 @@ interface ICameraService const int CAMERA_TYPE_ALL = 1; /** * Return the number of camera devices available in the system * Return the number of camera devices available in the system. * * @param type The type of the camera, can be either CAMERA_TYPE_BACKWARD_COMPATIBLE * or CAMERA_TYPE_ALL. * @param deviceId The device id of the context associated with the caller. * @param devicePolicy The camera policy of the device of the associated context (default * policy for default device context). Only virtual cameras would be exposed * only for custom policy and only real cameras would be exposed for default * policy. */ int getNumberOfCameras(int type); int getNumberOfCameras(int type, int deviceId, int devicePolicy); /** * Fetch basic camera information for a camera device * Fetch basic camera information for a camera. * * @param cameraId The ID of the camera to fetch information for. * @param overrideToPortrait Whether to override the sensor orientation information to * correspond to portrait. * @param deviceId The device id of the context associated with the caller. * @param devicePolicy The camera policy of the device of the associated context (default * policy for default device context). Only virtual cameras would be exposed * only for custom policy and only real cameras would be exposed for default * policy. * @return CameraInfo for the camera. */ CameraInfo getCameraInfo(int cameraId, boolean overrideToPortrait); CameraInfo getCameraInfo(int cameraId, boolean overrideToPortrait, int deviceId, int devicePolicy); /** * Default UID/PID values for non-privileged callers of Loading @@ -80,7 +99,20 @@ interface ICameraService const int USE_CALLING_PID = -1; /** * Open a camera device through the old camera API * Open a camera device through the old camera API. * * @param cameraId The ID of the camera to open. * @param opPackageName The package name to report for the app-ops. * @param clientUid UID for the calling client. * @param clientPid PID for the calling client. * @param overrideToPortrait Whether to override the sensor orientation information to * correspond to portrait. * @param forceSlowJpegMode Whether to force slow jpeg mode. * @param deviceId The device id of the context associated with the caller. * @param devicePolicy The camera policy of the device of the associated context (default * policy for default device context). Only virtual cameras would be exposed * only for custom policy and only real cameras would be exposed for default * policy. */ ICamera connect(ICameraClient client, int cameraId, Loading @@ -88,11 +120,24 @@ interface ICameraService int clientUid, int clientPid, int targetSdkVersion, boolean overrideToPortrait, boolean forceSlowJpegMode); boolean forceSlowJpegMode, int deviceId, int devicePolicy); /** * Open a camera device through the new camera API * Only supported for device HAL versions >= 3.2 * Open a camera device through the new camera API. * Only supported for device HAL versions >= 3.2. * * @param cameraId The ID of the camera to open. * @param opPackageName The package name to report for the app-ops. * @param clientUid UID for the calling client. * @param overrideToPortrait Whether to override the sensor orientation information to * correspond to portrait. * @param deviceId The device id of the context associated with the caller. * @param devicePolicy The camera policy of the device of the associated context (default * policy for default device context). Only virtual cameras would be exposed * only for custom policy and only real cameras would be exposed for default * policy. */ ICameraDeviceUser connectDevice(ICameraDeviceCallbacks callbacks, @utf8InCpp String cameraId, Loading @@ -100,7 +145,9 @@ interface ICameraService @nullable @utf8InCpp String featureId, int clientUid, int oomScoreOffset, int targetSdkVersion, boolean overrideToPortrait); boolean overrideToPortrait, int deviceId, int devicePolicy); /** * Add listener for changes to camera device and flashlight state. Loading Loading @@ -168,9 +215,19 @@ interface ICameraService /** * Read the static camera metadata for a camera device. * Only supported for device HAL versions >= 3.2 * * @param cameraId The ID of the camera to fetch metadata for. * @param overrideToPortrait Whether to override the sensor orientation information to * correspond to portrait. * @param deviceId The device id of the context associated with the caller. * @param devicePolicy The camera policy of the device of the associated context (default * policy for default device context). Only virtual cameras would be exposed * only for custom policy and only real cameras would be exposed for default * policy. * @return Characteristics for the given camera. */ CameraMetadataNative getCameraCharacteristics(@utf8InCpp String cameraId, int targetSdkVersion, boolean overrideToPortrait); boolean overrideToPortrait, int deviceId, int devicePolicy); /** * Read in the vendor tag descriptors from the camera module HAL. Loading Loading @@ -206,14 +263,46 @@ interface ICameraService ICameraInjectionSession injectCamera(@utf8InCpp String packageName, @utf8InCpp String internalCamId, @utf8InCpp String externalCamId, in ICameraInjectionCallback CameraInjectionCallback); void setTorchMode(@utf8InCpp String cameraId, boolean enabled, IBinder clientBinder); /** * Set the torch mode for a camera device. * * @param cameraId The ID of the camera to set torch mode for. * @param deviceId The device id of the context associated with the caller. * @param devicePolicy The camera policy of the device of the associated context (default * policy for default device context). Only virtual cameras would be exposed * only for custom policy and only real cameras would be exposed for default * policy. */ void setTorchMode(@utf8InCpp String cameraId, boolean enabled, IBinder clientBinder, int deviceId, int devicePolicy); // Change the brightness level of the flash unit associated with cameraId to strengthLevel. // If the torch is in OFF state and strengthLevel > 0 then the torch will also be turned ON. void turnOnTorchWithStrengthLevel(@utf8InCpp String cameraId, int strengthLevel, IBinder clientBinder); /** * Change the brightness level of the flash unit associated with cameraId to strengthLevel. * If the torch is in OFF state and strengthLevel > 0 then the torch will also be turned ON. * * @param cameraId The ID of the camera. * @param strengthLevel The torch strength level to set for the camera. * @param deviceId The device id of the context associated with the caller. * @param devicePolicy The camera policy of the device of the associated context (default * policy for default device context). Only virtual cameras would be exposed * only for custom policy and only real cameras would be exposed for default * policy. */ void turnOnTorchWithStrengthLevel(@utf8InCpp String cameraId, int strengthLevel, IBinder clientBinder, int deviceId, int devicePolicy); // Get the brightness level of the flash unit associated with cameraId. int getTorchStrengthLevel(@utf8InCpp String cameraId); /** * Get the brightness level of the flash unit associated with cameraId. * * @param cameraId The ID of the camera. * @param deviceId The device id of the context associated with the caller. * @param devicePolicy The camera policy of the device of the associated context (default * policy for default device context). Only virtual cameras would be exposed * only for custom policy and only real cameras would be exposed for default * policy. * @return Torch strength level for the camera. */ int getTorchStrengthLevel(@utf8InCpp String cameraId, int deviceId, int devicePolicy); /** * Notify the camera service of a system event. Should only be called from system_server. Loading Loading @@ -274,8 +363,20 @@ interface ICameraService const int DEVICE_STATE_FOLDED = 4; const int DEVICE_STATE_LAST_FRAMEWORK_BIT = 0x80000000; // 1 << 31; // Create a CaptureRequest metadata based on template id CameraMetadataNative createDefaultRequest(@utf8InCpp String cameraId, int templateId); /** * Create a CaptureRequest metadata based on template id * * @param cameraId The camera id to create the CaptureRequest for. * @param templateId The template id create the CaptureRequest for. * @param deviceId the device id of the context associated with the caller. * @param devicePolicy The camera policy of the device of the associated context (default * policy for default device context). Only virtual cameras would be exposed * only for custom policy and only real cameras would be exposed for default * policy. * @return Metadata representing the CaptureRequest. */ CameraMetadataNative createDefaultRequest(@utf8InCpp String cameraId, int templateId, int deviceId, int devicePolicy); /** * Check whether a particular session configuration with optional session parameters Loading @@ -283,23 +384,35 @@ interface ICameraService * * @param cameraId The camera id to query session configuration for * @param sessionConfiguration Specific session configuration to be verified. * @param deviceId The device id of the context associated with the caller. * @param devicePolicy The camera policy of the device of the associated context (default * policy for default device context). Only virtual cameras would be exposed * only for custom policy and only real cameras would be exposed for default * policy. * @return true - in case the stream combination is supported. * false - in case there is no device support. */ boolean isSessionConfigurationWithParametersSupported(@utf8InCpp String cameraId, in SessionConfiguration sessionConfiguration); in SessionConfiguration sessionConfiguration, int deviceId, int devicePolicy); /** * Get the camera characteristics for a particular session configuration for * the given camera device. * * @param cameraId ID of the device for which the session characteristics must be fetched. * @param sessionConfiguration session configuration for which the characteristics * @param sessionConfiguration Session configuration for which the characteristics * must be fetched. * @return - characteristics associated with the given session. * @param deviceId The device id of the context associated with the caller. * @param devicePolicy The camera policy of the device of the associated context (default * policy for default device context). Only virtual cameras would be exposed * only for custom policy and only real cameras would be exposed for default * policy. * @return Characteristics associated with the given session. */ CameraMetadataNative getSessionCharacteristics(@utf8InCpp String cameraId, int targetSdkVersion, boolean overrideToPortrait, in SessionConfiguration sessionConfiguration); in SessionConfiguration sessionConfiguration, int deviceId, int devicePolicy); }
camera/aidl/android/hardware/ICameraServiceListener.aidl +12 −6 Original line number Diff line number Diff line Loading @@ -51,14 +51,20 @@ interface ICameraServiceListener // Use to initialize variables only const int STATUS_UNKNOWN = -1; oneway void onStatusChanged(int status, @utf8InCpp String cameraId); // We pass deviceId associated with a camera in the callbacks, which is the id of the virtual // device owning the camera (for virtual cameras), or kDefaultDeviceId (for real // cameras). The deviceId is being passed so that the API layer (CameraManagerGlobal) can filter // out the cameras that don't correspond to the context associated with the caller who // registers a callback. oneway void onStatusChanged(int status, @utf8InCpp String cameraId, int deviceId); /** * Notify registered client about status changes for a physical camera backing * a logical camera. */ oneway void onPhysicalCameraStatusChanged(int status, @utf8InCpp String cameraId, @utf8InCpp String physicalCameraId); @utf8InCpp String physicalCameraId, int deviceId); /** * The torch mode status of a camera. Loading @@ -82,9 +88,9 @@ interface ICameraServiceListener // Use to initialize variables only const int TORCH_STATUS_UNKNOWN = -1; oneway void onTorchStatusChanged(int status, @utf8InCpp String cameraId); oneway void onTorchStatusChanged(int status, @utf8InCpp String cameraId, int deviceId); oneway void onTorchStrengthLevelChanged(@utf8InCpp String cameraId, int newTorchStrength); oneway void onTorchStrengthLevelChanged(@utf8InCpp String cameraId, int newTorchStrength, int deviceId); /** * Notify registered clients about camera access priority changes. Loading @@ -98,6 +104,6 @@ interface ICameraServiceListener * Only clients with android.permission.CAMERA_OPEN_CLOSE_LISTENER permission * will receive such callbacks. */ oneway void onCameraOpened(@utf8InCpp String cameraId, @utf8InCpp String clientPackageId); oneway void onCameraClosed(@utf8InCpp String cameraId); oneway void onCameraOpened(@utf8InCpp String cameraId, @utf8InCpp String clientPackageId, int deviceId); oneway void onCameraClosed(@utf8InCpp String cameraId, int deviceId); }
camera/include/camera/Camera.h +5 −3 Original line number Diff line number Diff line Loading @@ -27,6 +27,7 @@ #include <camera/android/hardware/ICamera.h> #include <camera/android/hardware/ICameraClient.h> #include <camera/CameraBase.h> #include <camera/CameraUtils.h> namespace android { Loading Loading @@ -58,7 +59,7 @@ struct CameraTraits<Camera> typedef ::android::hardware::ICameraClient TCamCallbacks; typedef ::android::binder::Status (::android::hardware::ICameraService::*TCamConnectService) (const sp<::android::hardware::ICameraClient>&, int, const std::string&, int, int, int, bool, bool, int, const std::string&, int, int, int, bool, bool, int32_t, int32_t, /*out*/ sp<::android::hardware::ICamera>*); static TCamConnectService fnConnectService; Loading @@ -82,7 +83,8 @@ public: static sp<Camera> connect(int cameraId, const std::string& clientPackageName, int clientUid, int clientPid, int targetSdkVersion, bool overrideToPortrait, bool forceSlowJpegMode); bool overrideToPortrait, bool forceSlowJpegMode, int32_t deviceId = kDefaultDeviceId, int32_t devicePolicy = 0); virtual ~Camera(); Loading Loading @@ -197,6 +199,6 @@ protected: friend class CameraBase; }; }; // namespace android } // namespace android #endif