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

Commit 7146ced4 authored by Bharatt Kukreja's avatar Bharatt Kukreja
Browse files

Add AUTOFRAMING_AUTO mode

When an app sets CONTROL_AUTOFRAMING to AUTO, the app needs to fetch the
system default for the autoframing state.

Test: CTS tests continue to pass
Bug: 234004829
Change-Id: I2ef2c10dbe2889e18c28218cea68f3779afdad5f
parent 4605759a
Loading
Loading
Loading
Loading
+7 −0
Original line number Diff line number Diff line
@@ -45,6 +45,13 @@ interface ICameraServiceProxy
     */
    int getRotateAndCropOverride(String packageName, int lensFacing, int userId);

    /**
     * Returns the necessary autoframing override for the top activity which
     * will be one of ({@link android.hardware.camera2.CameraMetadata#AUTOFRAMING_FALSE},
     * {@link android.hardware.camera2.CameraMetadata#AUTOFRAMING_TRUE}).
     */
    int getAutoframingOverride(String packageName);

    /**
     * Checks if the camera has been disabled via device policy.
     */
+53 −3
Original line number Diff line number Diff line
@@ -1989,6 +1989,15 @@ Status CameraService::connectHelper(const sp<CALLBACK>& cameraCb, const String8&
                    clientPackageName, facing, multiuser_get_user_id(clientUid)));
        }

        // Set autoframing override behaviour
        if (mOverrideAutoframingMode != ANDROID_CONTROL_AUTOFRAMING_AUTO) {
            client->setAutoframingOverride(mOverrideAutoframingMode);
        } else {
            client->setAutoframingOverride(
                mCameraServiceProxyWrapper->getAutoframingOverride(
                    clientPackageName));
        }

        // Set camera muting behavior
        bool isCameraPrivacyEnabled =
                mSensorPrivacyPolicy->isCameraPrivacyEnabled();
@@ -4892,6 +4901,10 @@ status_t CameraService::shellCommand(int in, int out, int err, const Vector<Stri
        return handleSetRotateAndCrop(args);
    } else if (args.size() >= 1 && args[0] == String16("get-rotate-and-crop")) {
        return handleGetRotateAndCrop(out);
    } else if (args.size() >= 2 && args[0] == String16("set-autoframing")) {
        return handleSetAutoframing(args);
    } else if (args.size() >= 1 && args[0] == String16("get-autoframing")) {
        return handleGetAutoframing(out);
    } else if (args.size() >= 2 && args[0] == String16("set-image-dump-mask")) {
        return handleSetImageDumpMask(args);
    } else if (args.size() >= 1 && args[0] == String16("get-image-dump-mask")) {
@@ -4995,6 +5008,34 @@ status_t CameraService::handleSetRotateAndCrop(const Vector<String16>& args) {
    return OK;
}

status_t CameraService::handleSetAutoframing(const Vector<String16>& args) {
    char* end;
    int autoframingValue = (int) strtol(String8(args[1]), &end, /*base=*/10);
    if ((*end != '\0') ||
            (autoframingValue != ANDROID_CONTROL_AUTOFRAMING_OFF &&
             autoframingValue != ANDROID_CONTROL_AUTOFRAMING_ON &&
             autoframingValue != ANDROID_CONTROL_AUTOFRAMING_AUTO)) {
        return BAD_VALUE;
    }

    Mutex::Autolock lock(mServiceLock);
    mOverrideAutoframingMode = autoframingValue;

    if (autoframingValue == ANDROID_CONTROL_AUTOFRAMING_AUTO) return OK;

    const auto clients = mActiveClientManager.getAll();
    for (auto& current : clients) {
        if (current != nullptr) {
            const auto basicClient = current->getValue();
            if (basicClient.get() != nullptr) {
                basicClient->setAutoframingOverride(autoframingValue);
            }
        }
    }

    return OK;
}

status_t CameraService::handleSetCameraServiceWatchdog(const Vector<String16>& args) {
    int enableWatchdog = atoi(String8(args[1]));

@@ -5023,6 +5064,12 @@ status_t CameraService::handleGetRotateAndCrop(int out) {
    return dprintf(out, "rotateAndCrop override: %d\n", mOverrideRotateAndCropMode);
}

status_t CameraService::handleGetAutoframing(int out) {
    Mutex::Autolock lock(mServiceLock);

    return dprintf(out, "autoframing override: %d\n", mOverrideAutoframingMode);
}

status_t CameraService::handleSetImageDumpMask(const Vector<String16>& args) {
    char *endPtr;
    errno = 0;
@@ -5420,6 +5467,9 @@ status_t CameraService::printHelp(int out) {
        "  set-rotate-and-crop <ROTATION> overrides the rotate-and-crop value for AUTO backcompat\n"
        "      Valid values 0=0 deg, 1=90 deg, 2=180 deg, 3=270 deg, 4=No override\n"
        "  get-rotate-and-crop returns the current override rotate-and-crop value\n"
        "  set-autoframing <VALUE> overrides the autoframing value for AUTO\n"
        "      Valid values 0=false, 1=true, 2=auto\n"
        "  get-autoframing returns the current override autoframing value\n"
        "  set-image-dump-mask <MASK> specifies the formats to be saved to disk\n"
        "      Valid values 0=OFF, 1=ON for JPEG\n"
        "  get-image-dump-mask returns the current image-dump-mask value\n"
+12 −0
Original line number Diff line number Diff line
@@ -337,6 +337,9 @@ public:
        // Override rotate-and-crop AUTO behavior
        virtual status_t setRotateAndCropOverride(uint8_t rotateAndCrop) = 0;

        // Override autoframing AUTO behaviour
        virtual status_t setAutoframingOverride(uint8_t autoframingValue) = 0;

        // Whether the client supports camera muting (black only output)
        virtual bool supportsCameraMute() = 0;

@@ -1230,6 +1233,12 @@ private:
    // Get the rotate-and-crop AUTO override behavior
    status_t handleGetRotateAndCrop(int out);

    // Set the autoframing AUTO override behaviour.
    status_t handleSetAutoframing(const Vector<String16>& args);

    // Get the autoframing AUTO override behaviour
    status_t handleGetAutoframing(int out);

    // Set the mask for image dump to disk
    status_t handleSetImageDumpMask(const Vector<String16>& args);

@@ -1325,6 +1334,9 @@ private:
    // Current override cmd rotate-and-crop mode; AUTO means no override
    uint8_t mOverrideRotateAndCropMode = ANDROID_SCALER_ROTATE_AND_CROP_AUTO;

    // Current autoframing mode
    uint8_t mOverrideAutoframingMode = ANDROID_CONTROL_AUTOFRAMING_AUTO;

    // Current image dump mask
    uint8_t mImageDumpMask = 0;

+7 −0
Original line number Diff line number Diff line
@@ -2363,6 +2363,13 @@ status_t Camera2Client::setRotateAndCropOverride(uint8_t rotateAndCrop) {
        static_cast<camera_metadata_enum_android_scaler_rotate_and_crop_t>(rotateAndCrop));
}

status_t Camera2Client::setAutoframingOverride(uint8_t autoframingValue) {
    if (autoframingValue > ANDROID_CONTROL_AUTOFRAMING_AUTO) return BAD_VALUE;

    return mDevice->setAutoframingAutoBehavior(
        static_cast<camera_metadata_enum_android_control_autoframing_t>(autoframingValue));
}

bool Camera2Client::supportsCameraMute() {
    return mDevice->supportsCameraMute();
}
+1 −0
Original line number Diff line number Diff line
@@ -86,6 +86,7 @@ public:
    virtual status_t        setAudioRestriction(int mode);
    virtual int32_t         getGlobalAudioRestriction();
    virtual status_t        setRotateAndCropOverride(uint8_t rotateAndCrop);
    virtual status_t        setAutoframingOverride(uint8_t autoframingMode);

    virtual bool            supportsCameraMute();
    virtual status_t        setCameraMute(bool enabled);
Loading