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

Commit ef8f74b2 authored by TreeHugger Robot's avatar TreeHugger Robot Committed by Android (Google) Code Review
Browse files

Merge "Camera: Connect activity resizing state to camera service" into sc-dev

parents a240be90 b91f180d
Loading
Loading
Loading
Loading
+6 −0
Original line number Diff line number Diff line
@@ -35,4 +35,10 @@ interface ICameraServiceProxy
     * Update the status of a camera device.
     */
    oneway void notifyCameraState(in CameraSessionStats cameraSessionStats);

    /**
     * Reports whether the top activity needs a rotate and crop override.
     */
    boolean isRotateAndCropOverrideNeeded(String packageName, int sensorOrientation,
            int lensFacing);
}
+9 −2
Original line number Diff line number Diff line
@@ -743,7 +743,7 @@ Status CameraService::getCameraVendorTagCache(
    return Status::ok();
}

int CameraService::getDeviceVersion(const String8& cameraId, int* facing) {
int CameraService::getDeviceVersion(const String8& cameraId, int* facing, int* orientation) {
    ATRACE_CALL();

    int deviceVersion = 0;
@@ -760,6 +760,9 @@ int CameraService::getDeviceVersion(const String8& cameraId, int* facing) {
        res = mCameraProviderManager->getCameraInfo(cameraId.string(), &info);
        if (res != OK) return -1;
        *facing = info.facing;
        if (orientation) {
            *orientation = info.orientation;
        }
    }

    return deviceVersion;
@@ -1555,6 +1558,7 @@ Status CameraService::connectHelper(const sp<CALLBACK>& cameraCb, const String8&

    sp<CLIENT> client = nullptr;
    int facing = -1;
    int orientation = 0;
    bool isNdk = (clientPackageName.size() == 0);
    {
        // Acquire mServiceLock and prevent other clients from connecting
@@ -1620,7 +1624,7 @@ Status CameraService::connectHelper(const sp<CALLBACK>& cameraCb, const String8&
        // give flashlight a chance to close devices if necessary.
        mFlashlight->prepareDeviceOpen(cameraId);

        int deviceVersion = getDeviceVersion(cameraId, /*out*/&facing);
        int deviceVersion = getDeviceVersion(cameraId, /*out*/&facing, /*out*/&orientation);
        if (facing == -1) {
            ALOGE("%s: Unable to get camera device \"%s\"  facing", __FUNCTION__, cameraId.string());
            return STATUS_ERROR_FMT(ERROR_INVALID_OPERATION,
@@ -1688,6 +1692,9 @@ Status CameraService::connectHelper(const sp<CALLBACK>& cameraCb, const String8&
        // Set rotate-and-crop override behavior
        if (mOverrideRotateAndCropMode != ANDROID_SCALER_ROTATE_AND_CROP_AUTO) {
            client->setRotateAndCropOverride(mOverrideRotateAndCropMode);
        } else if (CameraServiceProxyWrapper::isRotateAndCropOverrideNeeded(clientPackageName,
                    orientation, facing)) {
            client->setRotateAndCropOverride(ANDROID_SCALER_ROTATE_AND_CROP_90);
        }

        // Set camera muting behavior
+2 −1
Original line number Diff line number Diff line
@@ -213,7 +213,8 @@ public:

    /////////////////////////////////////////////////////////////////////
    // CameraDeviceFactory functionality
    int                 getDeviceVersion(const String8& cameraId, int* facing = NULL);
    int                 getDeviceVersion(const String8& cameraId, int* facing = nullptr,
            int* orientation = nullptr);

    /////////////////////////////////////////////////////////////////////
    // Shared utilities
+15 −0
Original line number Diff line number Diff line
@@ -120,6 +120,21 @@ void CameraServiceProxyWrapper::pingCameraServiceProxy() {
    proxyBinder->pingForUserUpdate();
}

bool CameraServiceProxyWrapper::isRotateAndCropOverrideNeeded(
        String16 packageName, int sensorOrientation, int lensFacing) {
    sp<ICameraServiceProxy> proxyBinder = getCameraServiceProxy();
    if (proxyBinder == nullptr) return true;
    bool ret = true;
    auto status = proxyBinder->isRotateAndCropOverrideNeeded(packageName, sensorOrientation,
            lensFacing, &ret);
    if (!status.isOk()) {
        ALOGE("%s: Failed during top activity orientation query: %s", __FUNCTION__,
                status.exceptionMessage().c_str());
    }

    return ret;
}

void CameraServiceProxyWrapper::updateProxyDeviceState(const CameraSessionStats& sessionStats) {
    sp<ICameraServiceProxy> proxyBinder = getCameraServiceProxy();
    if (proxyBinder == nullptr) return;
+4 −0
Original line number Diff line number Diff line
@@ -90,6 +90,10 @@ public:

    // Ping camera service proxy for user update
    static void pingCameraServiceProxy();

    // Check whether the current top activity needs a rotate and crop override.
    static bool isRotateAndCropOverrideNeeded(String16 packageName, int sensorOrientation,
            int lensFacing);
};

} // android