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

Commit 6e6f574d authored by Amit Mahajan's avatar Amit Mahajan Committed by android-build-merger
Browse files

Merge "Change to handle RUIM_RECORDS_LOADED only if phone type is CDMA" into nyc-dev

am: 55ff0eb7

* commit '55ff0eb7':
  Change to handle RUIM_RECORDS_LOADED only if phone type is CDMA
parents 9fb5593f 55ff0eb7
Loading
Loading
Loading
Loading
+59 −51
Original line number Diff line number Diff line
@@ -537,7 +537,7 @@ public class ServiceStateTracker extends Handler {
        mEventLog = TelephonyEventLog.getInstance(mPhone.getContext(), mPhone.getPhoneId());
    }

    protected void updatePhoneType() {
    public void updatePhoneType() {
        mSS = new ServiceState();
        mNewSS = new ServiceState();
        mLastCellInfoListTime = 0;
@@ -552,8 +552,6 @@ public class ServiceStateTracker extends Handler {
        mIsMinInfoReady = false;
        mNitzUpdatedTime = false;

        onUpdateIccAvailability();

        //cancel any pending pollstate request on voice tech switching
        cancelPollState();

@@ -604,6 +602,10 @@ public class ServiceStateTracker extends Handler {
            mPhone.notifyOtaspChanged(OTASP_UNINITIALIZED);
        }

        // This should be done after the technology specific initializations above since it relies
        // on fields like mIsSubscriptionFromRuim (which is updated above)
        onUpdateIccAvailability();

        mPhone.setSystemProperty(TelephonyProperties.PROPERTY_DATA_NETWORK_TYPE,
                ServiceState.rilRadioTechnologyToString(ServiceState.RIL_RADIO_TECHNOLOGY_UNKNOWN));
        // Query signal strength from the modem after service tracker is created (i.e. boot up,
@@ -1144,6 +1146,7 @@ public class ServiceStateTracker extends Handler {
                break;

            case EVENT_RESTRICTED_STATE_CHANGED:
                if (mPhone.isPhoneTypeGsm()) {
                    // This is a notification from
                    // CommandsInterface.setOnRestrictedStateChanged

@@ -1152,6 +1155,7 @@ public class ServiceStateTracker extends Handler {
                    ar = (AsyncResult) msg.obj;

                    onRestrictedStateChanged(ar);
                }
                break;

            case EVENT_ALL_DATA_DISCONNECTED:
@@ -1213,6 +1217,7 @@ public class ServiceStateTracker extends Handler {
                break;

            case EVENT_POLL_STATE_CDMA_SUBSCRIPTION: // Handle RIL_CDMA_SUBSCRIPTION
                if (!mPhone.isPhoneTypeGsm()) {
                    ar = (AsyncResult) msg.obj;

                    if (ar.exception == null) {
@@ -1235,20 +1240,22 @@ public class ServiceStateTracker extends Handler {
                                mIccRecords.setImsi(getImsi());
                            } else {
                                if (DBG) {
                                log("GET_CDMA_SUBSCRIPTION either mIccRecords is null  or NV type device" +
                                        " - not setting Imsi in mIccRecords");
                                    log("GET_CDMA_SUBSCRIPTION either mIccRecords is null or NV " +
                                            "type device - not setting Imsi in mIccRecords");
                                }
                            }
                        } else {
                            if (DBG) {
                            log("GET_CDMA_SUBSCRIPTION: error parsing cdmaSubscription params num="
                                    + cdmaSubscription.length);
                                log("GET_CDMA_SUBSCRIPTION: error parsing cdmaSubscription " +
                                        "params num=" + cdmaSubscription.length);
                            }
                        }
                    }
                }
                break;

            case EVENT_RUIM_RECORDS_LOADED:
                if (!mPhone.isPhoneTypeGsm()) {
                    log("EVENT_RUIM_RECORDS_LOADED: what=" + msg.what);
                    updatePhoneObject();
                    if (mPhone.isPhoneTypeCdma()) {
@@ -1273,6 +1280,7 @@ public class ServiceStateTracker extends Handler {
                        // the latest variables.
                        pollState();
                    }
                }
                break;

            case EVENT_ERI_FILE_LOADED:
+1 −1
Original line number Diff line number Diff line
@@ -38,7 +38,7 @@ import java.util.HashMap;
 * EriManager loads the ERI file definitions and manages the CDMA roaming information.
 *
 */
public final class EriManager {
public class EriManager {

    class EriFile {

+54 −1
Original line number Diff line number Diff line
@@ -19,7 +19,9 @@ package com.android.internal.telephony;
import android.content.Intent;
import android.os.AsyncResult;
import android.os.Bundle;
import android.os.Handler;
import android.os.HandlerThread;
import android.os.Message;
import android.os.Parcel;
import android.os.UserHandle;
import android.telephony.CellInfo;
@@ -30,6 +32,7 @@ import android.telephony.SubscriptionManager;
import android.telephony.gsm.GsmCellLocation;
import android.test.suitebuilder.annotation.MediumTest;

import com.android.internal.telephony.cdma.CdmaSubscriptionSourceManager;
import com.android.internal.telephony.dataconnection.DcTracker;
import com.android.internal.telephony.test.SimulatedCommands;
import com.android.internal.telephony.uicc.IccCardApplicationStatus;
@@ -37,11 +40,13 @@ import com.android.internal.telephony.uicc.IccCardApplicationStatus;
import static com.android.internal.telephony.TelephonyTestUtils.waitForMs;
import static org.junit.Assert.*;

import static org.mockito.Matchers.any;
import static org.mockito.Matchers.anyString;
import static org.mockito.Mockito.anyInt;
import static org.mockito.Mockito.atLeast;
import static org.mockito.Mockito.doReturn;
import static org.mockito.Mockito.eq;
import static org.mockito.Mockito.times;
import static org.mockito.Mockito.verify;

import org.junit.After;
@@ -60,6 +65,7 @@ public class ServiceStateTrackerTest extends TelephonyTest {
    private ProxyController mProxyController;

    private ServiceStateTracker sst;
    private ServiceStateTrackerTestHandler mSSTTestHandler;

    private class ServiceStateTrackerTestHandler extends HandlerThread {

@@ -101,7 +107,8 @@ public class ServiceStateTrackerTest extends TelephonyTest {
        int dds = SubscriptionManager.getDefaultDataSubscriptionId();
        doReturn(dds).when(mPhone).getSubId();

        new ServiceStateTrackerTestHandler(getClass().getSimpleName()).start();
        mSSTTestHandler = new ServiceStateTrackerTestHandler(getClass().getSimpleName());
        mSSTTestHandler.start();
        waitUntilReady();
        waitForMs(600);
        logd("ServiceStateTrackerTest -Setup!");
@@ -286,4 +293,50 @@ public class ServiceStateTrackerTest extends TelephonyTest {
        assertEquals(2, cl.getLac());
        assertEquals(3, cl.getCid());
    }

    @Test
    @MediumTest
    public void testUpdatePhoneType() {
        doReturn(false).when(mPhone).isPhoneTypeGsm();
        doReturn(true).when(mPhone).isPhoneTypeCdmaLte();
        doReturn(CdmaSubscriptionSourceManager.SUBSCRIPTION_FROM_RUIM).when(mCdmaSSM).
                getCdmaSubscriptionSource();

        logd("Calling updatePhoneType");
        // switch to CDMA
        sst.updatePhoneType();

        ArgumentCaptor<Integer> integerArgumentCaptor = ArgumentCaptor.forClass(Integer.class);
        verify(mRuimRecords).registerForRecordsLoaded(eq(sst), integerArgumentCaptor.capture(),
                any(Object.class));

        // response for mRuimRecords.registerForRecordsLoaded()
        Message msg = Message.obtain();
        msg.what = integerArgumentCaptor.getValue();
        msg.obj = new AsyncResult(null, null, null);
        sst.sendMessage(msg);
        waitForMs(100);

        // on RUIM_RECORDS_LOADED, sst is expected to call following apis
        verify(mRuimRecords, times(1)).isProvisioned();
        verify(mPhone, times(1)).prepareEri();

        // switch back to GSM
        doReturn(true).when(mPhone).isPhoneTypeGsm();
        doReturn(false).when(mPhone).isPhoneTypeCdmaLte();

        // response for mRuimRecords.registerForRecordsLoaded() can be sent after switching to GSM
        msg = Message.obtain();
        msg.what = integerArgumentCaptor.getValue();
        msg.obj = new AsyncResult(null, null, null);
        sst.sendMessage(msg);

        // There's no easy way to check if the msg was handled or discarded. Wait to make sure sst
        // did not crash, and then verify that the functions called records loaded are not called
        // again
        waitForMs(200);

        verify(mRuimRecords, times(1)).isProvisioned();
        verify(mPhone, times(1)).prepareEri();
    }
}
+4 −0
Original line number Diff line number Diff line
@@ -55,6 +55,7 @@ import com.android.ims.ImsCallProfile;
import com.android.ims.ImsEcbm;
import com.android.ims.ImsManager;
import com.android.internal.telephony.cdma.CdmaSubscriptionSourceManager;
import com.android.internal.telephony.cdma.EriManager;
import com.android.internal.telephony.dataconnection.DcTracker;
import com.android.internal.telephony.imsphone.ImsPhone;
import com.android.internal.telephony.imsphone.ImsPhoneCallTracker;
@@ -168,6 +169,8 @@ public abstract class TelephonyTest {
    protected SmsUsageMonitor mSmsUsageMonitor;
    @Mock
    protected PackageInfo mPackageInfo;
    @Mock
    protected EriManager mEriManager;

    protected TelephonyManager mTelephonyManager;
    protected SimulatedCommands mSimulatedCommands;
@@ -344,6 +347,7 @@ public abstract class TelephonyTest {
        doReturn(PhoneConstants.PHONE_TYPE_GSM).when(mPhone).getPhoneType();
        doReturn(mCT).when(mPhone).getCallTracker();
        doReturn(mSST).when(mPhone).getServiceStateTracker();
        mPhone.mEriManager = mEriManager;

        //mUiccController
        doReturn(mUiccCardApplication3gpp).when(mUiccController).getUiccCardApplication(anyInt(),