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

Commit 21bce584 authored by Jiwen Cai's avatar Jiwen Cai Committed by android-build-merger
Browse files

Merge "SurfaceUtils: query CONSUMER_IS_PROTECTED" into oc-dev am: 9694ba34

am: e374617c

Change-Id: I02dc5c77e6a9ad26f963f53db41fab8e68280dcb
parents 772468f8 e374617c
Loading
Loading
Loading
Loading
+13 −3
Original line number Diff line number Diff line
@@ -91,9 +91,19 @@ status_t setNativeWindowSizeFormatAndUsage(
            return err;
        }

        // Check if the ANativeWindow uses hardware protected buffers.
        if (queuesToNativeWindow != 1 && !(consumerUsage & GRALLOC_USAGE_PROTECTED)) {
            ALOGE("native window could not be authenticated");
        // Check if the consumer end of the ANativeWindow can handle protected content.
        int isConsumerProtected = 0;
        err = nativeWindow->query(
                nativeWindow, NATIVE_WINDOW_CONSUMER_IS_PROTECTED, &isConsumerProtected);
        if (err != NO_ERROR) {
            ALOGE("error query native window: %s (%d)", strerror(-err), -err);
            return err;
        }

        // Deny queuing into native window if neither condition is satisfied.
        if (queuesToNativeWindow != 1 && isConsumerProtected != 1) {
            ALOGE("native window cannot handle protected buffers: the consumer should either be "
                  "a hardware composer or support hardware protection");
            return PERMISSION_DENIED;
        }
    }