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

Commit 71dea373 authored by James Dong's avatar James Dong Committed by Android (Google) Code Review
Browse files

Merge "Added permission check for all sensitive drm API calls"

parents fe35a46f 5df62805
Loading
Loading
Loading
Loading
+21 −0
Original line number Original line Diff line number Diff line
@@ -159,12 +159,18 @@ int DrmManagerService::checkRightsStatus(
status_t DrmManagerService::consumeRights(
status_t DrmManagerService::consumeRights(
            int uniqueId, DecryptHandle* decryptHandle, int action, bool reserve) {
            int uniqueId, DecryptHandle* decryptHandle, int action, bool reserve) {
    ALOGV("Entering consumeRights");
    ALOGV("Entering consumeRights");
    if (!isProtectedCallAllowed()) {
        return DRM_ERROR_NO_PERMISSION;
    }
    return mDrmManager->consumeRights(uniqueId, decryptHandle, action, reserve);
    return mDrmManager->consumeRights(uniqueId, decryptHandle, action, reserve);
}
}


status_t DrmManagerService::setPlaybackStatus(
status_t DrmManagerService::setPlaybackStatus(
            int uniqueId, DecryptHandle* decryptHandle, int playbackStatus, int64_t position) {
            int uniqueId, DecryptHandle* decryptHandle, int playbackStatus, int64_t position) {
    ALOGV("Entering setPlaybackStatus");
    ALOGV("Entering setPlaybackStatus");
    if (!isProtectedCallAllowed()) {
        return DRM_ERROR_NO_PERMISSION;
    }
    return mDrmManager->setPlaybackStatus(uniqueId, decryptHandle, playbackStatus, position);
    return mDrmManager->setPlaybackStatus(uniqueId, decryptHandle, playbackStatus, position);
}
}


@@ -229,12 +235,18 @@ DecryptHandle* DrmManagerService::openDecryptSession(


status_t DrmManagerService::closeDecryptSession(int uniqueId, DecryptHandle* decryptHandle) {
status_t DrmManagerService::closeDecryptSession(int uniqueId, DecryptHandle* decryptHandle) {
    ALOGV("Entering closeDecryptSession");
    ALOGV("Entering closeDecryptSession");
    if (!isProtectedCallAllowed()) {
        return DRM_ERROR_NO_PERMISSION;
    }
    return mDrmManager->closeDecryptSession(uniqueId, decryptHandle);
    return mDrmManager->closeDecryptSession(uniqueId, decryptHandle);
}
}


status_t DrmManagerService::initializeDecryptUnit(int uniqueId, DecryptHandle* decryptHandle,
status_t DrmManagerService::initializeDecryptUnit(int uniqueId, DecryptHandle* decryptHandle,
            int decryptUnitId, const DrmBuffer* headerInfo) {
            int decryptUnitId, const DrmBuffer* headerInfo) {
    ALOGV("Entering initializeDecryptUnit");
    ALOGV("Entering initializeDecryptUnit");
    if (!isProtectedCallAllowed()) {
        return DRM_ERROR_NO_PERMISSION;
    }
    return mDrmManager->initializeDecryptUnit(uniqueId,decryptHandle, decryptUnitId, headerInfo);
    return mDrmManager->initializeDecryptUnit(uniqueId,decryptHandle, decryptUnitId, headerInfo);
}
}


@@ -242,18 +254,27 @@ status_t DrmManagerService::decrypt(
            int uniqueId, DecryptHandle* decryptHandle, int decryptUnitId,
            int uniqueId, DecryptHandle* decryptHandle, int decryptUnitId,
            const DrmBuffer* encBuffer, DrmBuffer** decBuffer, DrmBuffer* IV) {
            const DrmBuffer* encBuffer, DrmBuffer** decBuffer, DrmBuffer* IV) {
    ALOGV("Entering decrypt");
    ALOGV("Entering decrypt");
    if (!isProtectedCallAllowed()) {
        return DRM_ERROR_NO_PERMISSION;
    }
    return mDrmManager->decrypt(uniqueId, decryptHandle, decryptUnitId, encBuffer, decBuffer, IV);
    return mDrmManager->decrypt(uniqueId, decryptHandle, decryptUnitId, encBuffer, decBuffer, IV);
}
}


status_t DrmManagerService::finalizeDecryptUnit(
status_t DrmManagerService::finalizeDecryptUnit(
            int uniqueId, DecryptHandle* decryptHandle, int decryptUnitId) {
            int uniqueId, DecryptHandle* decryptHandle, int decryptUnitId) {
    ALOGV("Entering finalizeDecryptUnit");
    ALOGV("Entering finalizeDecryptUnit");
    if (!isProtectedCallAllowed()) {
        return DRM_ERROR_NO_PERMISSION;
    }
    return mDrmManager->finalizeDecryptUnit(uniqueId, decryptHandle, decryptUnitId);
    return mDrmManager->finalizeDecryptUnit(uniqueId, decryptHandle, decryptUnitId);
}
}


ssize_t DrmManagerService::pread(int uniqueId, DecryptHandle* decryptHandle,
ssize_t DrmManagerService::pread(int uniqueId, DecryptHandle* decryptHandle,
            void* buffer, ssize_t numBytes, off64_t offset) {
            void* buffer, ssize_t numBytes, off64_t offset) {
    ALOGV("Entering pread");
    ALOGV("Entering pread");
    if (!isProtectedCallAllowed()) {
        return DRM_ERROR_NO_PERMISSION;
    }
    return mDrmManager->pread(uniqueId, decryptHandle, buffer, numBytes, offset);
    return mDrmManager->pread(uniqueId, decryptHandle, buffer, numBytes, offset);
}
}


+1 −0
Original line number Original line Diff line number Diff line
@@ -43,6 +43,7 @@ enum {
    DRM_ERROR_DECRYPT                       = ERROR_BASE - 5,
    DRM_ERROR_DECRYPT                       = ERROR_BASE - 5,
    DRM_ERROR_CANNOT_HANDLE                 = ERROR_BASE - 6,
    DRM_ERROR_CANNOT_HANDLE                 = ERROR_BASE - 6,
    DRM_ERROR_TAMPER_DETECTED               = ERROR_BASE - 7,
    DRM_ERROR_TAMPER_DETECTED               = ERROR_BASE - 7,
    DRM_ERROR_NO_PERMISSION                 = ERROR_BASE - 8,


    DRM_NO_ERROR                            = NO_ERROR
    DRM_NO_ERROR                            = NO_ERROR
};
};