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

Commit 0913cb17 authored by christosts's avatar christosts Committed by Christos Tsilopoulos
Browse files

Mediaplayer: acquire the wake-lock synchronously

Bug: 265531109
Test: manual test with local test app
Change-Id: I6609960aa7eacbdf7609f28ca68d75eb48059db9
parent 03ac6df7
Loading
Loading
Loading
Loading
+12 −5
Original line number Diff line number Diff line
@@ -28,6 +28,8 @@

namespace android {

const int32_t INVALID_DISPLAY_ID = -1;

AWakeLock::AWakeLock() :
    mPowerManager(NULL),
    mWakeLockToken(NULL),
@@ -59,10 +61,15 @@ bool AWakeLock::acquire() {
        if (mPowerManager != NULL) {
            sp<IBinder> binder = new BBinder();
            int64_t token = IPCThreadState::self()->clearCallingIdentity();
            binder::Status status = mPowerManager->acquireWakeLockAsync(
                    binder, POWERMANAGER_PARTIAL_WAKE_LOCK,
                    String16("AWakeLock"), String16("media"),
                    {} /* workSource */, {} /* historyTag */);
            binder::Status status = mPowerManager->acquireWakeLock(
                binder,
                /*flags= */ POWERMANAGER_PARTIAL_WAKE_LOCK,
                /*tag=*/ String16("AWakeLock"),
                /*packageName=*/ String16("media"),
                /*ws=*/ {},
                /*historyTag=*/ {},
                /*displayId=*/ INVALID_DISPLAY_ID,
                /*callback=*/NULL);
            IPCThreadState::self()->restoreCallingIdentity(token);
            if (status.isOk()) {
                mWakeLockToken = binder;