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

Commit 919f85f2 authored by Dongwon Kang's avatar Dongwon Kang
Browse files

MediaPlayer2: replace IPCThreadState with libbinder_ndk.

checkCallingPermission() testing in dumpPlayers is dropped
since MediaPlayer2 is not running on system service so the
checking in MediaPlayer2 is not meaningful.

Test: make libmedia2_jni
Bug: 112766913
Change-Id: I8af753f0d83689f92348ecf986c30c75d7ae12ff
parent 2c66f89f
Loading
Loading
Loading
Loading
+1 −0
Original line number Diff line number Diff line
@@ -16,6 +16,7 @@ cc_library_static {
        "libandroid_runtime",
        "libaudioclient",
        "libbinder",
        "libbinder_ndk",
        "libcutils",
        "libgui",
        "liblog",
+92 −99
Original line number Diff line number Diff line
@@ -18,9 +18,7 @@
//#define LOG_NDEBUG 0
#define LOG_TAG "MediaPlayer2Native"

#include <binder/IServiceManager.h>
#include <binder/IPCThreadState.h>

#include <android/binder_ibinder.h>
#include <media/AudioSystem.h>
#include <media/DataSourceDesc.h>
#include <media/MediaAnalyticsItem.h>
@@ -102,10 +100,6 @@ status_t dumpPlayers(int fd, const Vector<String16>& args) {
    String8 result;
    SortedVector< sp<MediaPlayer2> > players; //to serialise the mutex unlock & client destruction.

    if (checkCallingPermission(String16("android.permission.DUMP")) == false) {
        snprintf(buffer, SIZE, "Permission Denial: can't dump MediaPlayer2\n");
        result.append(buffer);
    } else {
    {
        Mutex::Autolock lock(sRecordLock);
        ensureInit_l();
@@ -209,7 +203,7 @@ status_t dumpPlayers(int fd, const Vector<String16>& args) {
        //std::string s = GetUnreachableMemoryString(true /* contents */, 10000 /* limit */);
        //result.append(s.c_str(), s.size());
    }
    }

    write(fd, result.string(), result.size());
    return NO_ERROR;
}
@@ -252,9 +246,8 @@ MediaPlayer2::MediaPlayer2(int32_t sessionId) {
    mVideoWidth = mVideoHeight = 0;
    mSendLevel = 0;

    // TODO: get pid and uid from JAVA
    mPid = IPCThreadState::self()->getCallingPid();
    mUid = IPCThreadState::self()->getCallingUid();
    mPid = AIBinder_getCallingPid();
    mUid = AIBinder_getCallingUid();

    mAudioOutput = new MediaPlayer2AudioOutput(sessionId, mUid, mPid, NULL /*attributes*/);
}