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

Commit 666c0815 authored by Mengjun Leng's avatar Mengjun Leng
Browse files

Make radio power off immediately after data cleanup is complete

Currently Telephony needs to wait 30s to make radio power off on
DDS SUB, even the data connection clean-up is finished.

To avoid the latency time, detect the progress of data cleanup on
own SUB, once it done, make radio power off immediately.

Change-Id: I0d40b027da8196397499d5f72832191fbce81ef2
parent 1c26f71f
Loading
Loading
Loading
Loading
+7 −7
Original line number Diff line number Diff line
@@ -3920,16 +3920,16 @@ public class ServiceStateTracker extends Handler {
                        mPhone.mCT.mBackgroundCall.hangupIfAlive();
                        mPhone.mCT.mForegroundCall.hangupIfAlive();
                    }
                    dcTracker.cleanUpAllConnections(Phone.REASON_RADIO_TURNED_OFF);
                    if (dds != mPhone.getSubId()
                            && !ProxyController.getInstance().isDataDisconnected(dds)) {
                        if (DBG) log("Data is active on DDS.  Wait for all data disconnect");
                        // Data is not disconnected on DDS. Wait for the data disconnect complete
                    if (!ProxyController.getInstance().isDataDisconnected(mPhone.getSubId())) {
                        if (DBG) log("Wait for all data disconnect");
                        // Data is not disconnected. Wait for the data disconnect complete
                        // before sending the RADIO_POWER off.
                        ProxyController.getInstance().registerForAllDataDisconnected(dds, this,
                                EVENT_ALL_DATA_DISCONNECTED, null);
                        ProxyController.getInstance().registerForAllDataDisconnected(
                                mPhone.getSubId(), this, EVENT_ALL_DATA_DISCONNECTED, null);
                        mPendingRadioPowerOffAfterDataOff = true;
                    }
                    dcTracker.cleanUpAllConnections(Phone.REASON_RADIO_TURNED_OFF);

                    Message msg = Message.obtain(this);
                    msg.what = EVENT_SET_RADIO_POWER_OFF;
                    msg.arg1 = ++mPendingRadioPowerOffAfterDataOffTag;
+13 −0
Original line number Diff line number Diff line
@@ -25,6 +25,7 @@ import static org.mockito.Matchers.any;
import static org.mockito.Matchers.anyLong;
import static org.mockito.Matchers.nullable;
import static org.mockito.Mockito.anyInt;
import static org.mockito.Mockito.anyObject;
import static org.mockito.Mockito.anyString;
import static org.mockito.Mockito.atLeast;
import static org.mockito.Mockito.doReturn;
@@ -211,6 +212,18 @@ public class ServiceStateTrackerTest extends TelephonyTest {
        assertTrue(oldState != mSimulatedCommands.getRadioState().isOn());
    }

    @Test
    @MediumTest
    public void testSetRadioPowerOffUnderDataConnected() {
        sst.setRadioPower(true);
        waitForMs(100);
        doReturn(false).when(mDct).isDisconnected();
        sst.setRadioPower(false);
        waitForMs(200);
        verify(this.mProxyController, times(1)).registerForAllDataDisconnected(anyInt(),
                 eq(sst), anyInt(), anyObject());
    }

    @Test
    @MediumTest
    public void testSetRadioPowerFromCarrier() {