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

Commit ed974ebd authored by Jayant Chowdhary's avatar Jayant Chowdhary Committed by Android (Google) Code Review
Browse files

Merge "cameraserver: Allow CameraManager to specify rotation override for clients" into main

parents a3944bb0 81d81b06
Loading
Loading
Loading
Loading
+2 −2
Original line number Diff line number Diff line
@@ -70,11 +70,11 @@ Camera::~Camera()
}

sp<Camera> Camera::connect(int cameraId, const std::string& clientPackageName,
        int clientUid, int clientPid, int targetSdkVersion, bool overrideToPortrait,
        int clientUid, int clientPid, int targetSdkVersion, int rotationOverride,
        bool forceSlowJpegMode, int32_t deviceId, int32_t devicePolicy)
{
    return CameraBaseT::connect(cameraId, clientPackageName, clientUid,
            clientPid, targetSdkVersion, overrideToPortrait, forceSlowJpegMode, deviceId,
            clientPid, targetSdkVersion, rotationOverride, forceSlowJpegMode, deviceId,
            devicePolicy);
}

+6 −6
Original line number Diff line number Diff line
@@ -163,7 +163,7 @@ 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,
                                               int rotationOverride, bool forceSlowJpegMode,
                                               int32_t deviceId, int32_t devicePolicy)
{
    ALOGV("%s: connect", __FUNCTION__);
@@ -174,10 +174,10 @@ sp<TCam> CameraBase<TCam, TCamTraits>::connect(int cameraId,
    binder::Status ret;
    if (cs != nullptr) {
        TCamConnectService fnConnectService = TCamTraits::fnConnectService;
        ALOGI("Connect camera (legacy API) - overrideToPortrait %d, forceSlowJpegMode %d",
                overrideToPortrait, forceSlowJpegMode);
        ALOGI("Connect camera (legacy API) - rotationOverride %d, forceSlowJpegMode %d",
                rotationOverride, forceSlowJpegMode);
        ret = (cs.get()->*fnConnectService)(cl, cameraId, clientPackageName, clientUid,
                clientPid, targetSdkVersion, overrideToPortrait, forceSlowJpegMode, deviceId,
                clientPid, targetSdkVersion, rotationOverride, forceSlowJpegMode, deviceId,
                devicePolicy, /*out*/ &c->mCamera);
    }
    if (ret.isOk() && c->mCamera != nullptr) {
@@ -279,11 +279,11 @@ int CameraBase<TCam, TCamTraits>::getNumberOfCameras(int32_t deviceId, int32_t d
// 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, int32_t deviceId, int32_t devicePolicy,
        int rotationOverride, 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, deviceId, devicePolicy,
    binder::Status res = cs->getCameraInfo(cameraId, rotationOverride, deviceId, devicePolicy,
            cameraInfo);
    return res.isOk() ? OK : res.serviceSpecificErrorCode();
}
+47 −15
Original line number Diff line number Diff line
@@ -75,12 +75,29 @@ interface ICameraService
     */
    int getNumberOfCameras(int type, int deviceId, int devicePolicy);

    /**
     * If changed, reflect in
     * frameworks/base/core/java/android/hardware/camera2/CameraManager.java.
     * We have an enum here since the decision to override to portrait mode / fetch the
     * rotationOverride as it exists in CameraManager right now is based on a static system
     * property and not something that changes based dynamically, say on fold state. As a result,
     * we can't use just a boolean to differentiate between the case where cameraserver should
     * override to portrait (sensor orientation is 0, 180) or just rotate the sensor feed (sensor
     * orientation is 90, 270)
     */
    const int ROTATION_OVERRIDE_NONE = 0;
    const int ROTATION_OVERRIDE_OVERRIDE_TO_PORTRAIT = 1;
    const int ROTATION_OVERRIDE_ROTATION_ONLY = 2;

    /**
     * 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 rotationOverride Whether to override the sensor orientation information to
     *        correspond to portrait: {@link ICameraService#ROTATION_OVERRIDE_OVERRIDE_TO_PORTRAIT}
     *        will override the sensor orientation and rotate and crop, while {@link
     *        ICameraService#ROTATION_OVERRIDE_ROTATION_ONLY} will rotate and crop the camera feed
     *        without changing the sensor orientation.
     * @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
@@ -88,7 +105,7 @@ interface ICameraService
     *                     policy.
     * @return CameraInfo for the camera.
     */
    CameraInfo getCameraInfo(int cameraId, boolean overrideToPortrait, int deviceId,
    CameraInfo getCameraInfo(int cameraId, int rotationOverride, int deviceId,
            int devicePolicy);

    /**
@@ -105,8 +122,12 @@ interface ICameraService
     * @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 targetSdkVersion the target sdk level of the application calling this function.
     * @param rotationOverride Whether to override the sensor orientation information to
     *        correspond to portrait: {@link ICameraService#ROTATION_OVERRIDE_OVERRIDE_TO_PORTRAIT}
     *        will override the sensor orientation and rotate and crop, while {@link
     *        ICameraService#ROTATION_OVERRIDE_ROTATION_ONLY} will rotate and crop the camera feed
     *        without changing the sensor orientation.
     * @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
@@ -119,7 +140,7 @@ interface ICameraService
            @utf8InCpp String opPackageName,
            int clientUid, int clientPid,
            int targetSdkVersion,
            boolean overrideToPortrait,
            int rotationOverride,
            boolean forceSlowJpegMode,
            int deviceId,
            int devicePolicy);
@@ -131,8 +152,12 @@ interface ICameraService
     * @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 targetSdkVersion the target sdk level of the application calling this function.
     * @param rotationOverride Whether to override the sensor orientation information to
     *        correspond to portrait: {@link ICameraService#ROTATION_OVERRIDE_OVERRIDE_TO_PORTRAIT}
     *        will override the sensor orientation and rotate and crop, while {@link
     *        ICameraService#ROTATION_OVERRIDE_ROTATION_ONLY} will rotate and crop the camera feed
     *        without changing the sensor orientation.
     * @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
@@ -145,7 +170,7 @@ interface ICameraService
            @nullable @utf8InCpp String featureId,
            int clientUid, int oomScoreOffset,
            int targetSdkVersion,
            boolean overrideToPortrait,
            int rotationOverride,
            int deviceId,
            int devicePolicy);

@@ -217,8 +242,12 @@ interface ICameraService
     * 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 targetSdkVersion the target sdk level of the application calling this function.
     * @param rotationOverride Whether to override the sensor orientation information to
     *        correspond to portrait: {@link ICameraService#ROTATION_OVERRIDE_OVERRIDE_TO_PORTRAIT}
     *        will override the sensor orientation and rotate and crop, while {@link
     *        ICameraService#ROTATION_OVERRIDE_ROTATION_ONLY} will rotate and crop the camera feed
     *        without changing the sensor orientation.
     * @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
@@ -227,7 +256,7 @@ interface ICameraService
     * @return Characteristics for the given camera.
     */
    CameraMetadataNative getCameraCharacteristics(@utf8InCpp String cameraId, int targetSdkVersion,
            boolean overrideToPortrait, int deviceId, int devicePolicy);
            int rotationOverride, int deviceId, int devicePolicy);

    /**
     * Read in the vendor tag descriptors from the camera module HAL.
@@ -403,8 +432,11 @@ interface ICameraService
     *
     * @param cameraId ID of the device for which the session characteristics must be fetched.
     * @param targetSdkVersion the target sdk level of the application calling this function.
     * @param overrideToPortrait Whether to override the sensor orientation information to
     *                           correspond to portrait.
     * @param rotationOverride Whether to override the sensor orientation information to
     *        correspond to portrait: {@link ICameraService#ROTATION_OVERRIDE_OVERRIDE_TO_PORTRAIT}
     *        will override the sensor orientation and rotate and crop, while {@link
     *        ICameraService#ROTATION_OVERRIDE_ROTATION_ONLY} will rotate and crop the camera feed
     *        without changing the sensor orientation.
     * @param sessionConfiguration Session configuration for which the characteristics
     *                             must be fetched.
     * @param deviceId The device id of the context associated with the caller.
@@ -416,7 +448,7 @@ interface ICameraService
     */
    CameraMetadataNative getSessionCharacteristics(@utf8InCpp String cameraId,
            int targetSdkVersion,
            boolean overrideToPortrait,
            int rotationOverride,
            in SessionConfiguration sessionConfiguration,
            int deviceId,
            int devicePolicy);
+2 −2
Original line number Diff line number Diff line
@@ -59,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, int32_t, int32_t,
        int, const std::string&, int, int, int, int, bool, int32_t, int32_t,
        /*out*/
        sp<::android::hardware::ICamera>*);
    static TCamConnectService     fnConnectService;
@@ -83,7 +83,7 @@ public:
    static  sp<Camera>  connect(int cameraId,
                                const std::string& clientPackageName,
                                int clientUid, int clientPid, int targetSdkVersion,
                                bool overrideToPortrait, bool forceSlowJpegMode,
                                int rotationOverride, bool forceSlowJpegMode,
                                int32_t deviceId = kDefaultDeviceId, int32_t devicePolicy = 0);

            virtual     ~Camera();
+2 −2
Original line number Diff line number Diff line
@@ -125,7 +125,7 @@ public:
    static sp<TCam>      connect(int cameraId,
                                 const std::string& clientPackageName,
                                 int clientUid, int clientPid, int targetSdkVersion,
                                 bool overrideToPortrait, bool forceSlowJpegMode,
                                 int rotationOverride, bool forceSlowJpegMode,
                                 int32_t deviceId, int32_t devicePolicy);
    virtual void         disconnect();

@@ -134,7 +134,7 @@ public:
    static int           getNumberOfCameras(int32_t deviceId, int32_t devicePolicy);

    static status_t      getCameraInfo(int cameraId,
                                       bool overrideToPortrait,
                                       int rotationOverride,
                                       int32_t deviceId,
                                       int32_t devicePolicy,
                                       /*out*/
Loading