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

Commit 70be1673 authored by Dianne Hackborn's avatar Dianne Hackborn
Browse files

Fix problem where power manager was calling battery stats with bad wl type.

Also fiddle code to reduce duplication.

Change-Id: I3f1b086e53ef88dac1ec1896fe711b3cfe7fdd58
parent a224f70b
Loading
Loading
Loading
Loading
+36 −38
Original line number Diff line number Diff line
@@ -660,6 +660,8 @@ class PowerManagerService extends IPowerManager.Stub
    }

    void noteStartWakeLocked(WakeLock wl, WorkSource ws) {
        if (wl.monitorType >= 0) {
            long origId = Binder.clearCallingIdentity();
            try {
                if (ws != null) {
                    mBatteryStats.noteStartWakelockFromSource(ws, wl.pid, wl.tag,
@@ -669,10 +671,15 @@ class PowerManagerService extends IPowerManager.Stub
                }
            } catch (RemoteException e) {
                // Ignore
            } finally {
                Binder.restoreCallingIdentity(origId);
            }
        }
    }

    void noteStopWakeLocked(WakeLock wl, WorkSource ws) {
        if (wl.monitorType >= 0) {
            long origId = Binder.clearCallingIdentity();
            try {
                if (ws != null) {
                    mBatteryStats.noteStopWakelockFromSource(ws, wl.pid, wl.tag,
@@ -682,6 +689,9 @@ class PowerManagerService extends IPowerManager.Stub
                }
            } catch (RemoteException e) {
                // Ignore
            } finally {
                Binder.restoreCallingIdentity(origId);
            }
        }
    }

@@ -813,8 +823,6 @@ class PowerManagerService extends IPowerManager.Stub
        if (ws != null) {
            enforceWakeSourcePermission(uid, pid);
        }
        long ident = Binder.clearCallingIdentity();
        try {
        synchronized (mLocks) {
            int index = mLocks.getIndex(lock);
            if (index < 0) {
@@ -826,9 +834,6 @@ class PowerManagerService extends IPowerManager.Stub
            noteStopWakeLocked(wl, oldsource);
            noteStartWakeLocked(wl, ws);
        }
        } finally {
            Binder.restoreCallingIdentity(ident);
        }
    }

    public void releaseWakeLock(IBinder lock, int flags) {
@@ -884,14 +889,7 @@ class PowerManagerService extends IPowerManager.Stub
        // Unlink the lock from the binder.
        wl.binder.unlinkToDeath(wl, 0);

        if (wl.monitorType >= 0) {
            long origId = Binder.clearCallingIdentity();
            try {
        noteStopWakeLocked(wl, wl.ws);
            } finally {
                Binder.restoreCallingIdentity(origId);
            }
        }
    }

    private class PokeLock implements IBinder.DeathRecipient