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

Commit e8a73f35 authored by Xin Li's avatar Xin Li
Browse files

DO NOT MERGE - Merge qt-qpr1-dev-plus-aosp@6304901 into stage-aosp-master

Bug: 151763422
Change-Id: I771c3c0d86070c2a6e5f263818a6231291f28d56
parents 32a4b317 91ca2196
Loading
Loading
Loading
Loading
+8 −0
Original line number Diff line number Diff line
@@ -83,4 +83,12 @@ interface ICameraServiceListener
     * can retry after receiving this callback.
     */
    oneway void onCameraAccessPrioritiesChanged();

    /**
     * Notify registered clients about cameras being opened/closed.
     * Only clients with android.permission.CAMERA_OPEN_CLOSE_LISTENER permission
     * will receive such callbacks.
     */
    oneway void onCameraOpened(String cameraId, String clientPackageId);
    oneway void onCameraClosed(String cameraId);
}
+6 −0
Original line number Diff line number Diff line
@@ -92,6 +92,12 @@ class CameraManagerGlobal final : public RefBase {
        }

        virtual binder::Status onCameraAccessPrioritiesChanged();
        virtual binder::Status onCameraOpened(const String16&, const String16&) {
            return binder::Status::ok();
        }
        virtual binder::Status onCameraClosed(const String16&) {
            return binder::Status::ok();
        }

      private:
        const wp<CameraManagerGlobal> mCameraManager;
+11 −0
Original line number Diff line number Diff line
@@ -95,6 +95,17 @@ public:
        return binder::Status::ok();
    }

    virtual binder::Status onCameraOpened(const String16& /*cameraId*/,
            const String16& /*clientPackageName*/) {
        // No op
        return binder::Status::ok();
    }

    virtual binder::Status onCameraClosed(const String16& /*cameraId*/) {
        // No op
        return binder::Status::ok();
    }

    bool waitForNumCameras(size_t num) const {
        Mutex::Autolock l(mLock);

+11 −3
Original line number Diff line number Diff line
@@ -264,8 +264,12 @@ status_t BnCrypto::onTransact(
        {
            CHECK_INTERFACE(ICrypto, data, reply);

            uint8_t uuid[16];
            data.read(uuid, sizeof(uuid));
            uint8_t uuid[16] = {0};
            if (data.read(uuid, sizeof(uuid)) != NO_ERROR) {
                android_errorWriteLog(0x534e4554, "144767096");
                reply->writeInt32(BAD_VALUE);
                return OK;
            }

            size_t opaqueSize = data.readInt32();
            void *opaqueData = NULL;
@@ -280,7 +284,11 @@ status_t BnCrypto::onTransact(
                return NO_MEMORY;
            }

            data.read(opaqueData, opaqueSize);
            if (data.read(opaqueData, opaqueSize) != NO_ERROR) {
                android_errorWriteLog(0x534e4554, "144767096");
                reply->writeInt32(BAD_VALUE);
                return OK;
            }
            reply->writeInt32(createPlugin(uuid, opaqueData, opaqueSize));

            free(opaqueData);
+17 −6
Original line number Diff line number Diff line
@@ -76,10 +76,21 @@ android::status_t InitDataParser::parse(const Vector<uint8_t>& initData,

android::status_t InitDataParser::parsePssh(const Vector<uint8_t>& initData,
        Vector<const uint8_t*>* keyIds) {
    // Description of PSSH format:
    // https://w3c.github.io/encrypted-media/format-registry/initdata/cenc.html
    size_t readPosition = 0;

    // Validate size field
    uint32_t expectedSize = initData.size();
    const char psshIdentifier[4] = {'p', 's', 's', 'h'};
    const uint8_t psshVersion1[4] = {1, 0, 0, 0};
    uint32_t keyIdCount = 0;
    size_t headerSize = sizeof(expectedSize) + sizeof(psshIdentifier) +
                        sizeof(psshVersion1) + kSystemIdSize + sizeof(keyIdCount);
    if (initData.size() < headerSize) {
        return android::ERROR_DRM_CANNOT_HANDLE;
    }

    // Validate size field
    expectedSize = htonl(expectedSize);
    if (memcmp(&initData[readPosition], &expectedSize,
               sizeof(expectedSize)) != 0) {
@@ -88,7 +99,6 @@ android::status_t InitDataParser::parsePssh(const Vector<uint8_t>& initData,
    readPosition += sizeof(expectedSize);

    // Validate PSSH box identifier
    const char psshIdentifier[4] = {'p', 's', 's', 'h'};
    if (memcmp(&initData[readPosition], psshIdentifier,
               sizeof(psshIdentifier)) != 0) {
        return android::ERROR_DRM_CANNOT_HANDLE;
@@ -96,7 +106,6 @@ android::status_t InitDataParser::parsePssh(const Vector<uint8_t>& initData,
    readPosition += sizeof(psshIdentifier);

    // Validate EME version number
    const uint8_t psshVersion1[4] = {1, 0, 0, 0};
    if (memcmp(&initData[readPosition], psshVersion1,
               sizeof(psshVersion1)) != 0) {
        return android::ERROR_DRM_CANNOT_HANDLE;
@@ -110,12 +119,14 @@ android::status_t InitDataParser::parsePssh(const Vector<uint8_t>& initData,
    readPosition += kSystemIdSize;

    // Read key ID count
    uint32_t keyIdCount;
    memcpy(&keyIdCount, &initData[readPosition], sizeof(keyIdCount));
    keyIdCount = ntohl(keyIdCount);
    readPosition += sizeof(keyIdCount);
    if (readPosition + ((uint64_t)keyIdCount * kKeyIdSize) !=
            initData.size() - sizeof(uint32_t)) {

    uint64_t psshSize = 0;
    if (__builtin_mul_overflow(keyIdCount, kKeyIdSize, &psshSize) ||
        __builtin_add_overflow(readPosition, psshSize, &psshSize) ||
        psshSize != initData.size() - sizeof(uint32_t) /* DataSize(0) */) {
        return android::ERROR_DRM_CANNOT_HANDLE;
    }

Loading