Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit d4abdf74 authored by Shuzhen Wang's avatar Shuzhen Wang
Browse files

Camera: Filter small JPEG sizes based on targetSdkVersion

To maintain backward compatbility, filter out small (<1080p) JPEG sizes
for Performance Class 12 primary cameras in camera service if the
application targets sdk version 31.

Maintain old behavior for applications targetting older sdk version.

Also remove some redundant code in CameraProviderManager.

Test: Camera CTS
Bug: 187913092
Change-Id: I302fb90e331dc9c7da26f51ab99ab150bba68493
parent a69e5dde
Loading
Loading
Loading
Loading
+3 −2
Original line number Original line Diff line number Diff line
@@ -71,9 +71,10 @@ Camera::~Camera()
}
}


sp<Camera> Camera::connect(int cameraId, const String16& clientPackageName,
sp<Camera> Camera::connect(int cameraId, const String16& clientPackageName,
        int clientUid, int clientPid)
        int clientUid, int clientPid, int targetSdkVersion)
{
{
    return CameraBaseT::connect(cameraId, clientPackageName, clientUid, clientPid);
    return CameraBaseT::connect(cameraId, clientPackageName, clientUid,
            clientPid, targetSdkVersion);
}
}


status_t Camera::reconnect()
status_t Camera::reconnect()
+2 −2
Original line number Original line Diff line number Diff line
@@ -152,7 +152,7 @@ const sp<::android::hardware::ICameraService> CameraBase<TCam, TCamTraits>::getC
template <typename TCam, typename TCamTraits>
template <typename TCam, typename TCamTraits>
sp<TCam> CameraBase<TCam, TCamTraits>::connect(int cameraId,
sp<TCam> CameraBase<TCam, TCamTraits>::connect(int cameraId,
                                               const String16& clientPackageName,
                                               const String16& clientPackageName,
                                               int clientUid, int clientPid)
                                               int clientUid, int clientPid, int targetSdkVersion)
{
{
    ALOGV("%s: connect", __FUNCTION__);
    ALOGV("%s: connect", __FUNCTION__);
    sp<TCam> c = new TCam(cameraId);
    sp<TCam> c = new TCam(cameraId);
@@ -163,7 +163,7 @@ sp<TCam> CameraBase<TCam, TCamTraits>::connect(int cameraId,
    if (cs != nullptr) {
    if (cs != nullptr) {
        TCamConnectService fnConnectService = TCamTraits::fnConnectService;
        TCamConnectService fnConnectService = TCamTraits::fnConnectService;
        ret = (cs.get()->*fnConnectService)(cl, cameraId, clientPackageName, clientUid,
        ret = (cs.get()->*fnConnectService)(cl, cameraId, clientPackageName, clientUid,
                                               clientPid, /*out*/ &c->mCamera);
                                               clientPid, targetSdkVersion, /*out*/ &c->mCamera);
    }
    }
    if (ret.isOk() && c->mCamera != nullptr) {
    if (ret.isOk() && c->mCamera != nullptr) {
        IInterface::asBinder(c->mCamera)->linkToDeath(c);
        IInterface::asBinder(c->mCamera)->linkToDeath(c);
+8 −4
Original line number Original line Diff line number Diff line
@@ -82,7 +82,8 @@ interface ICameraService
    ICamera connect(ICameraClient client,
    ICamera connect(ICameraClient client,
            int cameraId,
            int cameraId,
            String opPackageName,
            String opPackageName,
            int clientUid, int clientPid);
            int clientUid, int clientPid,
            int targetSdkVersion);


    /**
    /**
     * Open a camera device through the new camera API
     * Open a camera device through the new camera API
@@ -92,7 +93,8 @@ interface ICameraService
            String cameraId,
            String cameraId,
            String opPackageName,
            String opPackageName,
            @nullable String featureId,
            @nullable String featureId,
            int clientUid, int oomScoreOffset);
            int clientUid, int oomScoreOffset,
            int targetSdkVersion);


    /**
    /**
     * Add listener for changes to camera device and flashlight state.
     * Add listener for changes to camera device and flashlight state.
@@ -114,13 +116,15 @@ interface ICameraService
      * corresponding camera ids.
      * corresponding camera ids.
      *
      *
      * @param sessions the set of camera id and session configuration pairs to be queried.
      * @param sessions the set of camera id and session configuration pairs to be queried.
      * @param targetSdkVersion the target sdk level of the application calling this function.
      * @return true  - the set of concurrent camera id and stream combinations is supported.
      * @return true  - the set of concurrent camera id and stream combinations is supported.
      *         false - the set of concurrent camera id and stream combinations is not supported
      *         false - the set of concurrent camera id and stream combinations is not supported
      *                 OR the method was called with a set of camera ids not returned by
      *                 OR the method was called with a set of camera ids not returned by
      *                 getConcurrentCameraIds().
      *                 getConcurrentCameraIds().
      */
      */
    boolean isConcurrentSessionConfigurationSupported(
    boolean isConcurrentSessionConfigurationSupported(
            in CameraIdAndSessionConfiguration[] sessions);
            in CameraIdAndSessionConfiguration[] sessions,
            int targetSdkVersion);


    /**
    /**
     * Remove listener for changes to camera device and flashlight state.
     * Remove listener for changes to camera device and flashlight state.
@@ -131,7 +135,7 @@ interface ICameraService
     * Read the static camera metadata for a camera device.
     * Read the static camera metadata for a camera device.
     * Only supported for device HAL versions >= 3.2
     * Only supported for device HAL versions >= 3.2
     */
     */
    CameraMetadataNative getCameraCharacteristics(String cameraId);
    CameraMetadataNative getCameraCharacteristics(String cameraId, int targetSdkVersion);


    /**
    /**
     * Read in the vendor tag descriptors from the camera module HAL.
     * Read in the vendor tag descriptors from the camera module HAL.
+2 −2
Original line number Original line Diff line number Diff line
@@ -58,7 +58,7 @@ struct CameraTraits<Camera>
    typedef ::android::hardware::ICameraClient TCamCallbacks;
    typedef ::android::hardware::ICameraClient TCamCallbacks;
    typedef ::android::binder::Status(::android::hardware::ICameraService::*TCamConnectService)
    typedef ::android::binder::Status(::android::hardware::ICameraService::*TCamConnectService)
        (const sp<::android::hardware::ICameraClient>&,
        (const sp<::android::hardware::ICameraClient>&,
        int, const String16&, int, int,
        int, const String16&, int, int, int,
        /*out*/
        /*out*/
        sp<::android::hardware::ICamera>*);
        sp<::android::hardware::ICamera>*);
    static TCamConnectService     fnConnectService;
    static TCamConnectService     fnConnectService;
@@ -81,7 +81,7 @@ public:
    static  sp<Camera>  create(const sp<::android::hardware::ICamera>& camera);
    static  sp<Camera>  create(const sp<::android::hardware::ICamera>& camera);
    static  sp<Camera>  connect(int cameraId,
    static  sp<Camera>  connect(int cameraId,
                                const String16& clientPackageName,
                                const String16& clientPackageName,
                                int clientUid, int clientPid);
                                int clientUid, int clientPid, int targetSdkVersion);


            virtual     ~Camera();
            virtual     ~Camera();


+1 −1
Original line number Original line Diff line number Diff line
@@ -113,7 +113,7 @@ public:


    static sp<TCam>      connect(int cameraId,
    static sp<TCam>      connect(int cameraId,
                                 const String16& clientPackageName,
                                 const String16& clientPackageName,
                                 int clientUid, int clientPid);
                                 int clientUid, int clientPid, int targetSdkVersion);
    virtual void         disconnect();
    virtual void         disconnect();


    void                 setListener(const sp<TCamListener>& listener);
    void                 setListener(const sp<TCamListener>& listener);
Loading