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

Commit ab57df11 authored by Amit Mahajan's avatar Amit Mahajan Committed by Android Partner Code Review
Browse files

Merge "Unit test for GsmCdmaPhone (handling of messages rcvd on creation)" into mm-wireless-dev

parents 38ae1f3f 14bdfdca
Loading
Loading
Loading
Loading
+88 −105
Original line number Original line Diff line number Diff line
@@ -87,7 +87,7 @@ import java.util.concurrent.atomic.AtomicReference;
public abstract class Phone extends Handler implements PhoneInternalInterface {
public abstract class Phone extends Handler implements PhoneInternalInterface {
    private static final String LOG_TAG = "Phone";
    private static final String LOG_TAG = "Phone";


    public final static Object lockForRadioTechnologyChange = new Object();
    protected final static Object lockForRadioTechnologyChange = new Object();


    private BroadcastReceiver mImsIntentReceiver = new BroadcastReceiver() {
    private BroadcastReceiver mImsIntentReceiver = new BroadcastReceiver() {
        @Override
        @Override
@@ -132,23 +132,23 @@ public abstract class Phone extends Handler implements PhoneInternalInterface {
    /** Supplementary Service Notification received. */
    /** Supplementary Service Notification received. */
    protected static final int EVENT_SSN                         = 2;
    protected static final int EVENT_SSN                         = 2;
    protected static final int EVENT_SIM_RECORDS_LOADED          = 3;
    protected static final int EVENT_SIM_RECORDS_LOADED          = 3;
    protected static final int EVENT_MMI_DONE                    = 4;
    private static final int EVENT_MMI_DONE                      = 4;
    protected static final int EVENT_RADIO_ON                    = 5;
    protected static final int EVENT_RADIO_ON                    = 5;
    protected static final int EVENT_GET_BASEBAND_VERSION_DONE   = 6;
    protected static final int EVENT_GET_BASEBAND_VERSION_DONE   = 6;
    protected static final int EVENT_USSD                        = 7;
    protected static final int EVENT_USSD                        = 7;
    protected static final int EVENT_RADIO_OFF_OR_NOT_AVAILABLE  = 8;
    protected static final int EVENT_RADIO_OFF_OR_NOT_AVAILABLE  = 8;
    protected static final int EVENT_GET_IMEI_DONE               = 9;
    protected static final int EVENT_GET_IMEI_DONE               = 9;
    protected static final int EVENT_GET_IMEISV_DONE             = 10;
    protected static final int EVENT_GET_IMEISV_DONE             = 10;
    protected static final int EVENT_GET_SIM_STATUS_DONE         = 11;
    private static final int EVENT_GET_SIM_STATUS_DONE           = 11;
    protected static final int EVENT_SET_CALL_FORWARD_DONE       = 12;
    protected static final int EVENT_SET_CALL_FORWARD_DONE       = 12;
    protected static final int EVENT_GET_CALL_FORWARD_DONE       = 13;
    protected static final int EVENT_GET_CALL_FORWARD_DONE       = 13;
    protected static final int EVENT_CALL_RING                   = 14;
    protected static final int EVENT_CALL_RING                   = 14;
    protected static final int EVENT_CALL_RING_CONTINUE          = 15;
    private static final int EVENT_CALL_RING_CONTINUE            = 15;


    // Used to intercept the carrier selection calls so that
    // Used to intercept the carrier selection calls so that
    // we can save the values.
    // we can save the values.
    protected static final int EVENT_SET_NETWORK_MANUAL_COMPLETE    = 16;
    private static final int EVENT_SET_NETWORK_MANUAL_COMPLETE      = 16;
    protected static final int EVENT_SET_NETWORK_AUTOMATIC_COMPLETE = 17;
    private static final int EVENT_SET_NETWORK_AUTOMATIC_COMPLETE   = 17;
    protected static final int EVENT_SET_CLIR_COMPLETE              = 18;
    protected static final int EVENT_SET_CLIR_COMPLETE              = 18;
    protected static final int EVENT_REGISTERED_TO_NETWORK          = 19;
    protected static final int EVENT_REGISTERED_TO_NETWORK          = 19;
    protected static final int EVENT_SET_VM_NUMBER_DONE             = 20;
    protected static final int EVENT_SET_VM_NUMBER_DONE             = 20;
@@ -156,22 +156,22 @@ public abstract class Phone extends Handler implements PhoneInternalInterface {
    protected static final int EVENT_GET_DEVICE_IDENTITY_DONE       = 21;
    protected static final int EVENT_GET_DEVICE_IDENTITY_DONE       = 21;
    protected static final int EVENT_RUIM_RECORDS_LOADED            = 22;
    protected static final int EVENT_RUIM_RECORDS_LOADED            = 22;
    protected static final int EVENT_NV_READY                       = 23;
    protected static final int EVENT_NV_READY                       = 23;
    protected static final int EVENT_SET_ENHANCED_VP                = 24;
    private static final int EVENT_SET_ENHANCED_VP                  = 24;
    protected static final int EVENT_EMERGENCY_CALLBACK_MODE_ENTER  = 25;
    protected static final int EVENT_EMERGENCY_CALLBACK_MODE_ENTER  = 25;
    protected static final int EVENT_EXIT_EMERGENCY_CALLBACK_RESPONSE = 26;
    protected static final int EVENT_EXIT_EMERGENCY_CALLBACK_RESPONSE = 26;
    protected static final int EVENT_CDMA_SUBSCRIPTION_SOURCE_CHANGED = 27;
    protected static final int EVENT_CDMA_SUBSCRIPTION_SOURCE_CHANGED = 27;
    // other
    // other
    protected static final int EVENT_SET_NETWORK_AUTOMATIC          = 28;
    protected static final int EVENT_SET_NETWORK_AUTOMATIC          = 28;
    protected static final int EVENT_ICC_RECORD_EVENTS              = 29;
    protected static final int EVENT_ICC_RECORD_EVENTS              = 29;
    protected static final int EVENT_ICC_CHANGED                    = 30;
    private static final int EVENT_ICC_CHANGED                      = 30;
    // Single Radio Voice Call Continuity
    // Single Radio Voice Call Continuity
    protected static final int EVENT_SRVCC_STATE_CHANGED            = 31;
    private static final int EVENT_SRVCC_STATE_CHANGED              = 31;
    protected static final int EVENT_INITIATE_SILENT_REDIAL         = 32;
    private static final int EVENT_INITIATE_SILENT_REDIAL           = 32;
    protected static final int EVENT_RADIO_NOT_AVAILABLE            = 33;
    private static final int EVENT_RADIO_NOT_AVAILABLE              = 33;
    protected static final int EVENT_UNSOL_OEM_HOOK_RAW             = 34;
    private static final int EVENT_UNSOL_OEM_HOOK_RAW               = 34;
    protected static final int EVENT_GET_RADIO_CAPABILITY           = 35;
    protected static final int EVENT_GET_RADIO_CAPABILITY           = 35;
    protected static final int EVENT_SS                             = 36;
    protected static final int EVENT_SS                             = 36;
    protected static final int EVENT_CONFIG_LCE                     = 37;
    private static final int EVENT_CONFIG_LCE                       = 37;
    private static final int EVENT_CHECK_FOR_NETWORK_AUTOMATIC      = 38;
    private static final int EVENT_CHECK_FOR_NETWORK_AUTOMATIC      = 38;
    protected static final int EVENT_VOICE_RADIO_TECH_CHANGED       = 39;
    protected static final int EVENT_VOICE_RADIO_TECH_CHANGED       = 39;
    protected static final int EVENT_REQUEST_VOICE_RADIO_TECH_DONE  = 40;
    protected static final int EVENT_REQUEST_VOICE_RADIO_TECH_DONE  = 40;
@@ -201,7 +201,7 @@ public abstract class Phone extends Handler implements PhoneInternalInterface {
    public static final String CF_ID = "cf_id_key";
    public static final String CF_ID = "cf_id_key";


    // Key used to read/write "disable DNS server check" pref (used for testing)
    // Key used to read/write "disable DNS server check" pref (used for testing)
    public static final String DNS_SERVER_CHECK_DISABLED_KEY = "dns_server_check_disabled_key";
    private static final String DNS_SERVER_CHECK_DISABLED_KEY = "dns_server_check_disabled_key";


    /**
    /**
     * Small container class used to hold information relevant to
     * Small container class used to hold information relevant to
@@ -209,7 +209,7 @@ public abstract class Phone extends Handler implements PhoneInternalInterface {
     * if we are looking for automatic selection. operatorAlphaLong is the
     * if we are looking for automatic selection. operatorAlphaLong is the
     * corresponding operator name.
     * corresponding operator name.
     */
     */
    protected static class NetworkSelectMessage {
    private static class NetworkSelectMessage {
        public Message message;
        public Message message;
        public String operatorNumeric;
        public String operatorNumeric;
        public String operatorAlphaLong;
        public String operatorAlphaLong;
@@ -219,12 +219,12 @@ public abstract class Phone extends Handler implements PhoneInternalInterface {
    /* Instance Variables */
    /* Instance Variables */
    public CommandsInterface mCi;
    public CommandsInterface mCi;
    protected int mVmCount = 0;
    protected int mVmCount = 0;
    boolean mDnsCheckDisabled;
    private boolean mDnsCheckDisabled;
    public DcTracker mDcTracker;
    public DcTracker mDcTracker;
    boolean mDoesRilSendMultipleCallRing;
    private boolean mDoesRilSendMultipleCallRing;
    int mCallRingContinueToken;
    private int mCallRingContinueToken;
    int mCallRingDelay;
    private int mCallRingDelay;
    boolean mIsVoiceCapable = true;
    private boolean mIsVoiceCapable = true;


    // Variable to cache the video capability. When RAT changes, we lose this info and are unable
    // Variable to cache the video capability. When RAT changes, we lose this info and are unable
    // to recover from the state. We cache it and notify listeners when they register.
    // to recover from the state. We cache it and notify listeners when they register.
@@ -249,10 +249,9 @@ public abstract class Phone extends Handler implements PhoneInternalInterface {
    private final AtomicReference<RadioCapability> mRadioCapability =
    private final AtomicReference<RadioCapability> mRadioCapability =
            new AtomicReference<RadioCapability>();
            new AtomicReference<RadioCapability>();


    protected static final int DEFAULT_REPORT_INTERVAL_MS = 200;
    private static final int DEFAULT_REPORT_INTERVAL_MS = 200;
    protected static final boolean LCE_PULL_MODE = true;
    private static final boolean LCE_PULL_MODE = true;
    protected int mReportInterval = 0;  // ms
    private int mLceStatus = RILConstants.LCE_NOT_AVAILABLE;
    protected int mLceStatus = RILConstants.LCE_NOT_AVAILABLE;
    protected TelephonyComponentFactory mTelephonyComponentFactory;
    protected TelephonyComponentFactory mTelephonyComponentFactory;


    //IMS
    //IMS
@@ -260,7 +259,64 @@ public abstract class Phone extends Handler implements PhoneInternalInterface {
    public static final String EXTRA_KEY_ALERT_TITLE = "alertTitle";
    public static final String EXTRA_KEY_ALERT_TITLE = "alertTitle";
    public static final String EXTRA_KEY_ALERT_MESSAGE = "alertMessage";
    public static final String EXTRA_KEY_ALERT_MESSAGE = "alertMessage";
    public static final String EXTRA_KEY_ALERT_SHOW = "alertShow";
    public static final String EXTRA_KEY_ALERT_SHOW = "alertShow";
    public static final String EXTRA_KEY_NOTIFICATION_MESSAGE = "notificationMessage";
    protected static final String EXTRA_KEY_NOTIFICATION_MESSAGE = "notificationMessage";

    private final RegistrantList mPreciseCallStateRegistrants
            = new RegistrantList();

    private final RegistrantList mHandoverRegistrants
            = new RegistrantList();

    private final RegistrantList mNewRingingConnectionRegistrants
            = new RegistrantList();

    private final RegistrantList mIncomingRingRegistrants
            = new RegistrantList();

    protected final RegistrantList mDisconnectRegistrants
            = new RegistrantList();

    private final RegistrantList mServiceStateRegistrants
            = new RegistrantList();

    protected final RegistrantList mMmiCompleteRegistrants
            = new RegistrantList();

    protected final RegistrantList mMmiRegistrants
            = new RegistrantList();

    protected final RegistrantList mUnknownConnectionRegistrants
            = new RegistrantList();

    protected final RegistrantList mSuppServiceFailedRegistrants
            = new RegistrantList();

    protected final RegistrantList mRadioOffOrNotAvailableRegistrants
            = new RegistrantList();

    protected final RegistrantList mSimRecordsLoadedRegistrants
            = new RegistrantList();

    private final RegistrantList mVideoCapabilityChangedRegistrants
            = new RegistrantList();

    protected final RegistrantList mEmergencyCallToggledRegistrants
            = new RegistrantList();

    private Looper mLooper; /* to insure registrants are in correct thread*/

    protected final Context mContext;

    /**
     * PhoneNotifier is an abstraction for all system-wide
     * state change notification. DefaultPhoneNotifier is
     * used here unless running we're inside a unit test.
     */
    protected PhoneNotifier mNotifier;

    protected SimulatedRadioControl mSimulatedRadioControl;

    private boolean mUnitTestMode;


    /**
    /**
     * Returns a string identifier for this phone interface for parties
     * Returns a string identifier for this phone interface for parties
@@ -326,77 +382,6 @@ public abstract class Phone extends Handler implements PhoneInternalInterface {
        return SystemProperties.get(property, defValue);
        return SystemProperties.get(property, defValue);
    }
    }



    protected final RegistrantList mPreciseCallStateRegistrants
            = new RegistrantList();

    protected final RegistrantList mHandoverRegistrants
             = new RegistrantList();

    protected final RegistrantList mNewRingingConnectionRegistrants
            = new RegistrantList();

    protected final RegistrantList mIncomingRingRegistrants
            = new RegistrantList();

    protected final RegistrantList mDisconnectRegistrants
            = new RegistrantList();

    protected final RegistrantList mServiceStateRegistrants
            = new RegistrantList();

    protected final RegistrantList mMmiCompleteRegistrants
            = new RegistrantList();

    protected final RegistrantList mMmiRegistrants
            = new RegistrantList();

    protected final RegistrantList mUnknownConnectionRegistrants
            = new RegistrantList();

    protected final RegistrantList mSuppServiceFailedRegistrants
            = new RegistrantList();

    protected final RegistrantList mRadioOffOrNotAvailableRegistrants
            = new RegistrantList();

    protected final RegistrantList mSimRecordsLoadedRegistrants
            = new RegistrantList();

    protected final RegistrantList mVideoCapabilityChangedRegistrants
            = new RegistrantList();

    protected final RegistrantList mEmergencyCallToggledRegistrants
            = new RegistrantList();


    protected Looper mLooper; /* to insure registrants are in correct thread*/

    protected final Context mContext;

    /**
     * PhoneNotifier is an abstraction for all system-wide
     * state change notification. DefaultPhoneNotifier is
     * used here unless running we're inside a unit test.
     */
    protected PhoneNotifier mNotifier;

    protected SimulatedRadioControl mSimulatedRadioControl;

    boolean mUnitTestMode;

    /**
     * Constructs a Phone in normal (non-unit test) mode.
     *
     * @param notifier An instance of DefaultPhoneNotifier,
     * @param context Context object from hosting application
     * unless unit testing.
     * @param ci the CommandsInterface
     */
    protected Phone(String name, PhoneNotifier notifier, Context context, CommandsInterface ci) {
        this(name, notifier, context, ci, false);
    }

    /**
    /**
     * Constructs a Phone in normal (non-unit test) mode.
     * Constructs a Phone in normal (non-unit test) mode.
     *
     *
@@ -623,7 +608,6 @@ public abstract class Phone extends Handler implements PhoneInternalInterface {
                } else {
                } else {
                    final ArrayList<Integer> statusInfo = (ArrayList<Integer>)ar.result;
                    final ArrayList<Integer> statusInfo = (ArrayList<Integer>)ar.result;
                    mLceStatus = statusInfo.get(0);
                    mLceStatus = statusInfo.get(0);
                    mReportInterval = statusInfo.get(1);
                }
                }
                break;
                break;


@@ -783,7 +767,7 @@ public abstract class Phone extends Handler implements PhoneInternalInterface {
    protected void setIsInEmergencyCall() {
    protected void setIsInEmergencyCall() {
    }
    }


    public void migrateFrom(Phone from) {
    protected void migrateFrom(Phone from) {
        migrate(mHandoverRegistrants, from.mHandoverRegistrants);
        migrate(mHandoverRegistrants, from.mHandoverRegistrants);
        migrate(mPreciseCallStateRegistrants, from.mPreciseCallStateRegistrants);
        migrate(mPreciseCallStateRegistrants, from.mPreciseCallStateRegistrants);
        migrate(mNewRingingConnectionRegistrants, from.mNewRingingConnectionRegistrants);
        migrate(mNewRingingConnectionRegistrants, from.mNewRingingConnectionRegistrants);
@@ -799,7 +783,7 @@ public abstract class Phone extends Handler implements PhoneInternalInterface {
        }
        }
    }
    }


    public void migrate(RegistrantList to, RegistrantList from) {
    protected void migrate(RegistrantList to, RegistrantList from) {
        from.removeCleared();
        from.removeCleared();
        for (int i = 0, n = from.size(); i < n; i++) {
        for (int i = 0, n = from.size(); i < n; i++) {
            Registrant r = (Registrant) from.get(i);
            Registrant r = (Registrant) from.get(i);
@@ -1095,7 +1079,7 @@ public abstract class Phone extends Handler implements PhoneInternalInterface {
     * @param response The message to dispatch when the network selection
     * @param response The message to dispatch when the network selection
     * is complete.
     * is complete.
     *
     *
     * @see #selectNetworkManually(OperatorInfo, android.os.Message )
     * @see #selectNetworkManually(OperatorInfo, boolean, android.os.Message)
     */
     */
    public void setNetworkSelectionModeAutomatic(Message response) {
    public void setNetworkSelectionModeAutomatic(Message response) {
        Rlog.d(LOG_TAG, "setNetworkSelectionModeAutomatic, querying current mode");
        Rlog.d(LOG_TAG, "setNetworkSelectionModeAutomatic, querying current mode");
@@ -1270,7 +1254,7 @@ public abstract class Phone extends Handler implements PhoneInternalInterface {
     * automatic selection, all depending upon the value in the shared
     * automatic selection, all depending upon the value in the shared
     * preferences.
     * preferences.
     */
     */
    public void restoreSavedNetworkSelection(Message response) {
    private void restoreSavedNetworkSelection(Message response) {
        // retrieve the operator
        // retrieve the operator
        OperatorInfo networkSelection = getSavedNetworkSelection();
        OperatorInfo networkSelection = getSavedNetworkSelection();


@@ -1302,7 +1286,7 @@ public abstract class Phone extends Handler implements PhoneInternalInterface {
     * For unit tests; don't send notifications to "Phone"
     * For unit tests; don't send notifications to "Phone"
     * mailbox registrants if true.
     * mailbox registrants if true.
     */
     */
    public void setUnitTestMode(boolean f) {
    private void setUnitTestMode(boolean f) {
        mUnitTestMode = f;
        mUnitTestMode = f;
    }
    }


@@ -1970,7 +1954,7 @@ public abstract class Phone extends Handler implements PhoneInternalInterface {
        mNotifier.notifyDataActivity(this);
        mNotifier.notifyDataActivity(this);
    }
    }


    public void notifyMessageWaitingIndicator() {
    private void notifyMessageWaitingIndicator() {
        // Do not notify voice mail waiting if device doesn't support voice
        // Do not notify voice mail waiting if device doesn't support voice
        if (!mIsVoiceCapable)
        if (!mIsVoiceCapable)
            return;
            return;
@@ -2728,7 +2712,7 @@ public abstract class Phone extends Handler implements PhoneInternalInterface {
    public void dispose() {
    public void dispose() {
    }
    }


    protected void updateImsPhone() {
    private void updateImsPhone() {
        Rlog.d(LOG_TAG, "updateImsPhone"
        Rlog.d(LOG_TAG, "updateImsPhone"
                + " mImsServiceReady=" + mImsServiceReady);
                + " mImsServiceReady=" + mImsServiceReady);


@@ -3008,7 +2992,6 @@ public abstract class Phone extends Handler implements PhoneInternalInterface {
        if (restoreNetworkSelection) {
        if (restoreNetworkSelection) {
            restoreSavedNetworkSelection(null);
            restoreSavedNetworkSelection(null);
        }
        }
        mDcTracker.setDataEnabled(getDataEnabled());
    }
    }


    protected void setPreferredNetworkTypeIfSimLoaded() {
    protected void setPreferredNetworkTypeIfSimLoaded() {
+1 −1
Original line number Original line Diff line number Diff line
@@ -1723,7 +1723,7 @@ public abstract class SMSDispatcher extends Handler {
    }
    }


    protected int getSubId() {
    protected int getSubId() {
        return SubscriptionController.getInstance().getSubIdUsingPhoneId(mPhone.mPhoneId);
        return SubscriptionController.getInstance().getSubIdUsingPhoneId(mPhone.getPhoneId());
    }
    }


    private void checkCallerIsPhoneOrCarrierApp() {
    private void checkCallerIsPhoneOrCarrierApp() {
+35 −4
Original line number Original line Diff line number Diff line
@@ -32,6 +32,7 @@ import com.android.internal.annotations.VisibleForTesting;
import com.android.internal.telephony.BaseCommands;
import com.android.internal.telephony.BaseCommands;
import com.android.internal.telephony.CommandException;
import com.android.internal.telephony.CommandException;
import com.android.internal.telephony.CommandsInterface;
import com.android.internal.telephony.CommandsInterface;
import com.android.internal.telephony.RadioCapability;
import com.android.internal.telephony.cdma.CdmaSmsBroadcastConfigInfo;
import com.android.internal.telephony.cdma.CdmaSmsBroadcastConfigInfo;
import com.android.internal.telephony.dataconnection.DataCallResponse;
import com.android.internal.telephony.dataconnection.DataCallResponse;
import com.android.internal.telephony.dataconnection.DataProfile;
import com.android.internal.telephony.dataconnection.DataProfile;
@@ -75,6 +76,13 @@ public class SimulatedCommands extends BaseCommands
    public final static String FAKE_LONG_NAME = "Fake long name";
    public final static String FAKE_LONG_NAME = "Fake long name";
    public final static String FAKE_SHORT_NAME = "Fake short name";
    public final static String FAKE_SHORT_NAME = "Fake short name";
    public final static String FAKE_MCC_MNC = "310260";
    public final static String FAKE_MCC_MNC = "310260";
    public final static String FAKE_IMEI = "012345678901234";
    public final static String FAKE_IMEISV = "99";
    public final static String FAKE_ESN = "1234";
    public final static String FAKE_MEID = "1234";

    private String mImei;
    private String mImeiSv;


    //***** Instance Variables
    //***** Instance Variables


@@ -575,6 +583,10 @@ public class SimulatedCommands extends BaseCommands
        resultSuccess(result, "012345678901234");
        resultSuccess(result, "012345678901234");
    }
    }


    public void setIMEI(String imei) {
        mImei = imei;
    }

    /**
    /**
     *  returned message
     *  returned message
     *  retMsg.obj = AsyncResult ar
     *  retMsg.obj = AsyncResult ar
@@ -584,7 +596,12 @@ public class SimulatedCommands extends BaseCommands
     */
     */
    @Override
    @Override
    public void getIMEI(Message result) {
    public void getIMEI(Message result) {
        resultSuccess(result, "012345678901234");
        SimulatedCommandsVerifier.getInstance().getIMEI(result);
        resultSuccess(result, mImei != null ? mImei : FAKE_IMEI);
    }

    public void setIMEISV(String imeisv) {
        mImeiSv = imeisv;
    }
    }


    /**
    /**
@@ -596,7 +613,8 @@ public class SimulatedCommands extends BaseCommands
     */
     */
    @Override
    @Override
    public void getIMEISV(Message result) {
    public void getIMEISV(Message result) {
        resultSuccess(result, "99");
        SimulatedCommandsVerifier.getInstance().getIMEISV(result);
        resultSuccess(result, mImeiSv != null ? mImeiSv : FAKE_IMEISV);
    }
    }


    /**
    /**
@@ -1101,6 +1119,7 @@ public class SimulatedCommands extends BaseCommands


    @Override
    @Override
    public void setPreferredNetworkType(int networkType , Message result) {
    public void setPreferredNetworkType(int networkType , Message result) {
        SimulatedCommandsVerifier.getInstance().setPreferredNetworkType(networkType, result);
        mNetworkType = networkType;
        mNetworkType = networkType;
        resultSuccess(result, null);
        resultSuccess(result, null);
    }
    }
@@ -1317,6 +1336,7 @@ public class SimulatedCommands extends BaseCommands


    @Override
    @Override
    public void getNetworkSelectionMode(Message result) {
    public void getNetworkSelectionMode(Message result) {
        SimulatedCommandsVerifier.getInstance().getNetworkSelectionMode(result);
        int ret[] = new int[1];
        int ret[] = new int[1];


        ret[0] = 0;
        ret[0] = 0;
@@ -1333,6 +1353,7 @@ public class SimulatedCommands extends BaseCommands


    @Override
    @Override
    public void getBasebandVersion (Message result) {
    public void getBasebandVersion (Message result) {
        SimulatedCommandsVerifier.getInstance().getBasebandVersion(result);
        resultSuccess(result, "SimulatedCommands");
        resultSuccess(result, "SimulatedCommands");
    }
    }


@@ -1568,7 +1589,8 @@ public class SimulatedCommands extends BaseCommands
    @Override
    @Override
    public void
    public void
    getDeviceIdentity(Message response) {
    getDeviceIdentity(Message response) {
        unimplemented(response);
        SimulatedCommandsVerifier.getInstance().getDeviceIdentity(response);
        resultSuccess(response, new String[] {FAKE_IMEI, FAKE_IMEISV, FAKE_ESN, FAKE_MEID});
    }
    }


    @Override
    @Override
@@ -1737,6 +1759,7 @@ public class SimulatedCommands extends BaseCommands


    @Override
    @Override
    public void getVoiceRadioTechnology(Message response) {
    public void getVoiceRadioTechnology(Message response) {
        SimulatedCommandsVerifier.getInstance().getVoiceRadioTechnology(response);
        int ret[] = new int[1];
        int ret[] = new int[1];
        ret[0] = mVoiceRadioTech;
        ret[0] = mVoiceRadioTech;
        resultSuccess(response, ret);
        resultSuccess(response, ret);
@@ -1878,6 +1901,8 @@ public class SimulatedCommands extends BaseCommands


    @Override
    @Override
    public void startLceService(int report_interval_ms, boolean pullMode, Message result) {
    public void startLceService(int report_interval_ms, boolean pullMode, Message result) {
        SimulatedCommandsVerifier.getInstance().startLceService(report_interval_ms, pullMode,
                result);
        unimplemented(result);
        unimplemented(result);
    }
    }


@@ -1896,6 +1921,11 @@ public class SimulatedCommands extends BaseCommands
        unimplemented(result);
        unimplemented(result);
    }
    }


    @Override
    public void getRadioCapability(Message result) {
        SimulatedCommandsVerifier.getInstance().getRadioCapability(result);
        resultSuccess(result, new RadioCapability(0, 0, 0, 0xFFFF, null, 0));
    }
    public void notifySmsStatus(Object result) {
    public void notifySmsStatus(Object result) {
        if (mSmsStatusRegistrant != null) {
        if (mSmsStatusRegistrant != null) {
            mSmsStatusRegistrant.notifyRegistrant(new AsyncResult(null, result, null));
            mSmsStatusRegistrant.notifyRegistrant(new AsyncResult(null, result, null));
@@ -1931,6 +1961,7 @@ public class SimulatedCommands extends BaseCommands
    }
    }


    private AtomicBoolean mAllowed = new AtomicBoolean(false);
    private AtomicBoolean mAllowed = new AtomicBoolean(false);

    @Override
    @Override
    public void setDataAllowed(boolean allowed, Message result) {
    public void setDataAllowed(boolean allowed, Message result) {
        log("setDataAllowed = " + allowed);
        log("setDataAllowed = " + allowed);
+62 −0
Original line number Original line Diff line number Diff line
@@ -26,10 +26,12 @@ import android.provider.Settings;
import android.telephony.CarrierConfigManager;
import android.telephony.CarrierConfigManager;
import android.telephony.CellLocation;
import android.telephony.CellLocation;
import android.telephony.ServiceState;
import android.telephony.ServiceState;
import android.telephony.TelephonyManager;
import android.telephony.cdma.CdmaCellLocation;
import android.telephony.cdma.CdmaCellLocation;
import android.telephony.gsm.GsmCellLocation;
import android.telephony.gsm.GsmCellLocation;
import android.test.suitebuilder.annotation.SmallTest;
import android.test.suitebuilder.annotation.SmallTest;


import com.android.internal.telephony.test.SimulatedCommands;
import com.android.internal.telephony.uicc.IccException;
import com.android.internal.telephony.uicc.IccException;
import com.android.internal.telephony.uicc.IccRecords;
import com.android.internal.telephony.uicc.IccRecords;


@@ -59,6 +61,8 @@ public class GsmCdmaPhoneTest extends TelephonyTest {
    //mPhoneUnderTest
    //mPhoneUnderTest
    private GsmCdmaPhone mPhoneUT;
    private GsmCdmaPhone mPhoneUT;


    private TelephonyManager mTelephonyManager;

    private class GsmCdmaPhoneTestHandler extends HandlerThread {
    private class GsmCdmaPhoneTestHandler extends HandlerThread {


        private GsmCdmaPhoneTestHandler(String name) {
        private GsmCdmaPhoneTestHandler(String name) {
@@ -96,6 +100,7 @@ public class GsmCdmaPhoneTest extends TelephonyTest {
        super.setUp("GsmCdmaPhoneTest");
        super.setUp("GsmCdmaPhoneTest");


        doReturn(false).when(mSST).isDeviceShuttingDown();
        doReturn(false).when(mSST).isDeviceShuttingDown();
        mTelephonyManager = TelephonyManager.from(mContext);


        new GsmCdmaPhoneTestHandler(TAG).start();
        new GsmCdmaPhoneTestHandler(TAG).start();
        waitUntilReady();
        waitUntilReady();
@@ -474,4 +479,61 @@ public class GsmCdmaPhoneTest extends TelephonyTest {
        waitForMs(50);
        waitForMs(50);
        verify(mSimRecords).setVoiceCallForwardingFlag(anyInt(), anyBoolean(), eq(cfNumber));
        verify(mSimRecords).setVoiceCallForwardingFlag(anyInt(), anyBoolean(), eq(cfNumber));
    }
    }

    /**
     * GsmCdmaPhone handles a lot of messages. This function verifies behavior for messages that are
     * received when obj is created and that are received on phone type switch
     */
    @Test
    @SmallTest
    public void testHandleInitialMessages() {
        // EVENT_RADIO_AVAILABLE
        verify(mSimulatedCommandsVerifier).getBasebandVersion(any(Message.class));
        verify(mSimulatedCommandsVerifier).getIMEI(any(Message.class));
        verify(mSimulatedCommandsVerifier).getIMEISV(any(Message.class));
        verify(mSimulatedCommandsVerifier).getRadioCapability(any(Message.class));
        // once as part of constructor, and once on radio available
        verify(mSimulatedCommandsVerifier, times(2)).startLceService(anyInt(), anyBoolean(),
                any(Message.class));

        // EVENT_RADIO_ON
        verify(mSimulatedCommandsVerifier).getVoiceRadioTechnology(any(Message.class));
        verify(mSimulatedCommandsVerifier).setPreferredNetworkType(
                eq(RILConstants.NETWORK_MODE_LTE_CDMA_EVDO_GSM_WCDMA), any(Message.class));

        // verify responses for above requests:
        // baseband version
        verify(mTelephonyManager).setBasebandVersionForPhone(eq(mPhoneUT.getPhoneId()),
                anyString());
        // IMEI
        assertEquals(SimulatedCommands.FAKE_IMEI, mPhoneUT.getImei());
        // IMEISV
        assertEquals(SimulatedCommands.FAKE_IMEISV, mPhoneUT.getDeviceSvn());
        // radio capability
        verify(mSimulatedCommandsVerifier).getNetworkSelectionMode(any(Message.class));

        switchToCdma(); // this leads to eventRadioAvailable handling on cdma

        // EVENT_RADIO_AVAILABLE
        verify(mSimulatedCommandsVerifier, times(2)).getBasebandVersion(any(Message.class));
        verify(mSimulatedCommandsVerifier).getDeviceIdentity(any(Message.class));
        verify(mSimulatedCommandsVerifier, times(3)).startLceService(anyInt(), anyBoolean(),
                any(Message.class));

        // EVENT_RADIO_ON
        verify(mSimulatedCommandsVerifier, times(2)).getVoiceRadioTechnology(any(Message.class));
        // once on radio on, and once on get baseband version
        verify(mSimulatedCommandsVerifier, times(3)).setPreferredNetworkType(
                eq(RILConstants.NETWORK_MODE_LTE_CDMA_EVDO_GSM_WCDMA), any(Message.class));

        // verify responses for above requests:
        // baseband version
        verify(mTelephonyManager, times(2)).setBasebandVersionForPhone(eq(mPhoneUT.getPhoneId()),
                anyString());
        // device identity
        assertEquals(SimulatedCommands.FAKE_IMEI, mPhoneUT.getImei());
        assertEquals(SimulatedCommands.FAKE_IMEISV, mPhoneUT.getDeviceSvn());
        assertEquals(SimulatedCommands.FAKE_ESN, mPhoneUT.getEsn());
        assertEquals(SimulatedCommands.FAKE_MEID, mPhoneUT.getMeid());
    }
}
}
+0 −10
Original line number Original line Diff line number Diff line
@@ -64,16 +64,6 @@ import java.util.concurrent.atomic.AtomicBoolean;
public class PhoneMock extends Phone {
public class PhoneMock extends Phone {
    private static final String LOG_TAG = "PhoneMock";
    private static final String LOG_TAG = "PhoneMock";


    public PhoneMock(Context context, CommandsInterface ci) {
        super("PhoneMock", null, context, ci);
    }

    protected PhoneMock(String name, PhoneNotifier notifier, Context context,
            CommandsInterface ci) {
        super(name, notifier, context, ci);
        throw new RuntimeException("not implemented");
    }

    protected PhoneMock(String name, PhoneNotifier notifier, Context context, CommandsInterface ci,
    protected PhoneMock(String name, PhoneNotifier notifier, Context context, CommandsInterface ci,
            boolean unitTestMode) {
            boolean unitTestMode) {
        super(name, notifier, context, ci, unitTestMode);
        super(name, notifier, context, ci, unitTestMode);