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

Commit 93ec0d71 authored by Craig Donner's avatar Craig Donner Committed by Android (Google) Code Review
Browse files

Merge "Allows protected content when the consumer has USAGE_PROTECTED set,...

Merge "Allows protected content when the consumer has USAGE_PROTECTED set, even if the native window does not queue to the window composer."
parents 1e074554 b397a2a9
Loading
Loading
Loading
Loading
+11 −10
Original line number Diff line number Diff line
@@ -55,11 +55,17 @@ status_t setNativeWindowSizeFormatAndUsage(
        return err;
    }

    int consumerUsage = 0;
    err = nativeWindow->query(nativeWindow, NATIVE_WINDOW_CONSUMER_USAGE_BITS, &consumerUsage);
    if (err != NO_ERROR) {
        ALOGW("failed to get consumer usage bits. ignoring");
        err = NO_ERROR;
    }

    // Make sure to check whether either Stagefright or the video decoder
    // requested protected buffers.
    if (usage & GRALLOC_USAGE_PROTECTED) {
        // Verify that the ANativeWindow sends images directly to
        // SurfaceFlinger.
        // Check if the ANativeWindow sends images directly to SurfaceFlinger.
        int queuesToNativeWindow = 0;
        err = nativeWindow->query(
                nativeWindow, NATIVE_WINDOW_QUEUES_TO_WINDOW_COMPOSER, &queuesToNativeWindow);
@@ -67,19 +73,14 @@ status_t setNativeWindowSizeFormatAndUsage(
            ALOGE("error authenticating native window: %s (%d)", strerror(-err), -err);
            return err;
        }
        if (queuesToNativeWindow != 1) {

        // Check if the ANativeWindow uses hardware protected buffers.
        if (queuesToNativeWindow != 1 && !(consumerUsage & GRALLOC_USAGE_PROTECTED)) {
            ALOGE("native window could not be authenticated");
            return PERMISSION_DENIED;
        }
    }

    int consumerUsage = 0;
    err = nativeWindow->query(nativeWindow, NATIVE_WINDOW_CONSUMER_USAGE_BITS, &consumerUsage);
    if (err != NO_ERROR) {
        ALOGW("failed to get consumer usage bits. ignoring");
        err = NO_ERROR;
    }

    int finalUsage = usage | consumerUsage;
    ALOGV("gralloc usage: %#x(producer) + %#x(consumer) = %#x", usage, consumerUsage, finalUsage);
    err = native_window_set_usage(nativeWindow, finalUsage);