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

Commit f2d849fe authored by Youming Ye's avatar Youming Ye Committed by android-build-merger
Browse files

Merge "Revert "Make radio power off immediately after data cleanup is complete"" am: dda9a83d

am: c879b23b

Change-Id: I6cd5b4ef68590f0be1f2d98904122a2a40be9f9f
parents 2183b01e c879b23b
Loading
Loading
Loading
Loading
+12 −0
Original line number Diff line number Diff line
@@ -163,6 +163,18 @@ public class ProxyController {
        }
    }


    public boolean areAllDataDisconnected(int subId) {
        int phoneId = SubscriptionController.getInstance().getPhoneId(subId);

        if (phoneId >= 0 && phoneId < TelephonyManager.getDefault().getPhoneCount()) {
            return mPhones[phoneId].areAllDataDisconnected();
        } else {
            // if we can't find a phone for the given subId, it is disconnected.
            return true;
        }
    }

    /**
     * Get phone radio type and access technology.
     *
+20 −7
Original line number Diff line number Diff line
@@ -4156,10 +4156,20 @@ public class ServiceStateTracker extends Handler {
    public void powerOffRadioSafely() {
        synchronized (this) {
            if (!mPendingRadioPowerOffAfterDataOff) {
                int dds = SubscriptionManager.getDefaultDataSubscriptionId();
                // To minimize race conditions we call cleanUpAllConnections on
                // both if else paths instead of before this isDisconnected test.
                if (mPhone.areAllDataDisconnected()) {
                if (mPhone.areAllDataDisconnected()
                        && (dds == mPhone.getSubId()
                        || (dds != mPhone.getSubId()
                        && ProxyController.getInstance().areAllDataDisconnected(dds)))) {
                    // To minimize race conditions we do this after isDisconnected
                    for (int transport : mTransportManager.getAvailableTransports()) {
                        if (mPhone.getDcTracker(transport) != null) {
                            mPhone.getDcTracker(transport).cleanUpAllConnections(
                                    Phone.REASON_RADIO_TURNED_OFF);
                        }
                    }
                    if (DBG) log("Data disconnected, turn off radio right away.");
                    hangupAndPowerOff();
                } else {
@@ -4169,12 +4179,6 @@ public class ServiceStateTracker extends Handler {
                        mPhone.mCT.mBackgroundCall.hangupIfAlive();
                        mPhone.mCT.mForegroundCall.hangupIfAlive();
                    }
                    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(
                            mPhone.getSubId(), this, EVENT_ALL_DATA_DISCONNECTED);
                    mPendingRadioPowerOffAfterDataOff = true;
                    for (int transport : mTransportManager.getAvailableTransports()) {
                        if (mPhone.getDcTracker(transport) != null) {
                            mPhone.getDcTracker(transport).cleanUpAllConnections(
@@ -4182,6 +4186,15 @@ public class ServiceStateTracker extends Handler {
                        }
                    }

                    if (dds != mPhone.getSubId()
                            && !ProxyController.getInstance().areAllDataDisconnected(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
                        // before sending the RADIO_POWER off.
                        ProxyController.getInstance().registerForAllDataDisconnected(dds, this,
                                EVENT_ALL_DATA_DISCONNECTED);
                        mPendingRadioPowerOffAfterDataOff = true;
                    }
                    Message msg = Message.obtain(this);
                    msg.what = EVENT_SET_RADIO_POWER_OFF;
                    msg.arg1 = ++mPendingRadioPowerOffAfterDataOffTag;
+0 −12
Original line number Diff line number Diff line
@@ -243,18 +243,6 @@ public class ServiceStateTrackerTest extends TelephonyTest {
                != (mSimulatedCommands.getRadioState() == TelephonyManager.RADIO_POWER_ON));
    }

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

    @Test
    @MediumTest
    public void testSetRadioPowerFromCarrier() {