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

Commit 06e20a03 authored by hkuang's avatar hkuang Committed by Hangyu Kuang
Browse files

transcoding: Add permission check in addClient.

This is used to allow only MediaProvider access the media transcoding
service.

Bug: 179496636
Test: atest  CtsMediaTranscodingTestCases:MediaTranscodeManagerTest
Change-Id: If38e7d2283631e2e174af657ab0b409c77c3ff26
parent 925e03a9
Loading
Loading
Loading
Loading
+9 −0
Original line number Diff line number Diff line
@@ -315,6 +315,15 @@ bool TranscodingClientManager::isTrustedCaller(pid_t pid, uid_t uid) {
status_t TranscodingClientManager::addClient(
        const std::shared_ptr<ITranscodingClientCallback>& callback, const std::string& clientName,
        const std::string& opPackageName, std::shared_ptr<ITranscodingClient>* outClient) {
    int32_t callingPid = AIBinder_getCallingPid();
    int32_t callingUid = AIBinder_getCallingUid();

    // Check if client has the permission
    if (!isTrustedCaller(callingPid, callingUid)) {
        ALOGE("addClient rejected (clientPid %d, clientUid %d)", callingPid, callingUid);
        return IMediaTranscodingService::ERROR_PERMISSION_DENIED;
    }

    // Validate the client.
    if (callback == nullptr || clientName.empty() || opPackageName.empty()) {
        ALOGE("Invalid client");