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

Commit 28b27204 authored by TreeHugger Robot's avatar TreeHugger Robot Committed by Android (Google) Code Review
Browse files

Merge "Add more package names for MediaProvider"

parents 11b45e9f 3fea286f
Loading
Loading
Loading
Loading
+13 −10
Original line number Original line Diff line number Diff line
@@ -31,7 +31,10 @@ namespace android {


static_assert(sizeof(ClientIdType) == sizeof(void*), "ClientIdType should be pointer-sized");
static_assert(sizeof(ClientIdType) == sizeof(void*), "ClientIdType should be pointer-sized");


static constexpr const char* MEDIA_PROVIDER_PKG_NAME = "com.google.android.providers.media.module";
static constexpr const char* MEDIA_PROVIDER_PKG_NAMES[] = {
        "com.android.providers.media.module",
        "com.google.android.providers.media.module",
};


using ::aidl::android::media::BnTranscodingClient;
using ::aidl::android::media::BnTranscodingClient;
using ::aidl::android::media::IMediaTranscodingService;  // For service error codes
using ::aidl::android::media::IMediaTranscodingService;  // For service error codes
@@ -261,16 +264,16 @@ void TranscodingClientManager::BinderDiedCallback(void* cookie) {
TranscodingClientManager::TranscodingClientManager(
TranscodingClientManager::TranscodingClientManager(
        const std::shared_ptr<ControllerClientInterface>& controller)
        const std::shared_ptr<ControllerClientInterface>& controller)
      : mDeathRecipient(AIBinder_DeathRecipient_new(BinderDiedCallback)),
      : mDeathRecipient(AIBinder_DeathRecipient_new(BinderDiedCallback)),
        mSessionController(controller),
        mSessionController(controller) {
        mMediaProviderUid(-1) {
    ALOGD("TranscodingClientManager started");
    ALOGD("TranscodingClientManager started");
    uid_t mpuid;
    uid_t mpuid;
    if (TranscodingUidPolicy::getUidForPackage(String16(MEDIA_PROVIDER_PKG_NAME), mpuid) ==
    for (const char* pkgName : MEDIA_PROVIDER_PKG_NAMES) {
        NO_ERROR) {
        if (TranscodingUidPolicy::getUidForPackage(String16(pkgName), mpuid) == NO_ERROR) {
        ALOGI("Found MediaProvider uid: %d", mpuid);
            ALOGI("Found %s's uid: %d", pkgName, mpuid);
        mMediaProviderUid = mpuid;
            mMediaProviderUid.insert(mpuid);
        } else {
        } else {
        ALOGW("Couldn't get uid for MediaProvider.");
            ALOGW("Couldn't get uid for %s.", pkgName);
        }
    }
    }
}
}


@@ -303,7 +306,7 @@ void TranscodingClientManager::dumpAllClients(int fd, const Vector<String16>& ar
}
}


bool TranscodingClientManager::isTrustedCallingUid(uid_t uid) {
bool TranscodingClientManager::isTrustedCallingUid(uid_t uid) {
    if (uid > 0 && uid == mMediaProviderUid) {
    if (uid > 0 && mMediaProviderUid.count(uid) > 0) {
        return true;
        return true;
    }
    }


+1 −1
Original line number Original line Diff line number Diff line
@@ -109,7 +109,7 @@ private:
    ::ndk::ScopedAIBinder_DeathRecipient mDeathRecipient;
    ::ndk::ScopedAIBinder_DeathRecipient mDeathRecipient;


    std::shared_ptr<ControllerClientInterface> mSessionController;
    std::shared_ptr<ControllerClientInterface> mSessionController;
    uid_t mMediaProviderUid;
    std::unordered_set<uid_t> mMediaProviderUid;


    static std::atomic<ClientIdType> sCookieCounter;
    static std::atomic<ClientIdType> sCookieCounter;
    static std::mutex sCookie2ClientLock;
    static std::mutex sCookie2ClientLock;