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

Commit 8f811769 authored by Amit Mahajan's avatar Amit Mahajan
Browse files

Change to dispose Gsm/CdmaConnection to make sure wakelock is released

Wakelock acq/release is done only on connection creation and
disconnect. If phone switch happens before disconnect, wakelock is not
released.

Bug: 23334669
Change-Id: Iebf34fa7b05015fec16730ec9e45635181939649
parent 406a0043
Loading
Loading
Loading
Loading
+6 −0
Original line number Diff line number Diff line
@@ -124,6 +124,11 @@ public final class CdmaCallTracker extends CallTracker {

        clearDisconnected();

        for (CdmaConnection cdmaConnection : mConnections) {
            if (cdmaConnection != null) {
                cdmaConnection.dispose();
            }
        }
    }

    @Override
@@ -358,6 +363,7 @@ public final class CdmaCallTracker extends CallTracker {

        updatePhoneState();
        mPhone.notifyPreciseCallStateChanged();

    }

    boolean
+10 −0
Original line number Diff line number Diff line
@@ -186,6 +186,8 @@ public class CdmaConnection extends Connection {
    }

    public void dispose() {
        clearPostDialListeners();
        releaseAllWakeLocks();
    }

    static boolean
@@ -794,6 +796,14 @@ public class CdmaConnection extends Connection {
        }
    }

    private void releaseAllWakeLocks() {
        synchronized (mPartialWakeLock) {
            while (mPartialWakeLock.isHeld()) {
                mPartialWakeLock.release();
            }
        }
    }

    private static boolean isPause(char c) {
        return c == PhoneNumberUtils.PAUSE;
    }
+6 −1
Original line number Diff line number Diff line
@@ -119,8 +119,13 @@ public final class GsmCallTracker extends CallTracker {
        mCi.unregisterForOn(this);
        mCi.unregisterForNotAvailable(this);


        clearDisconnected();

        for (GsmConnection gsmConnection : mConnections) {
            if (gsmConnection != null) {
                gsmConnection.dispose();
            }
        }
    }

    @Override
+11 −0
Original line number Diff line number Diff line
@@ -157,6 +157,8 @@ public class GsmConnection extends Connection {
    }

    public void dispose() {
        clearPostDialListeners();
        releaseAllWakeLocks();
    }

    static boolean
@@ -740,6 +742,15 @@ public class GsmConnection extends Connection {
        }
    }

    private void
    releaseAllWakeLocks() {
        synchronized(mPartialWakeLock) {
            while (mPartialWakeLock.isHeld()) {
                mPartialWakeLock.release();
            }
        }
    }

    private void log(String msg) {
        Rlog.d(LOG_TAG, "[GSMConn] " + msg);
    }