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

Commit 36381bc7 authored by Treehugger Robot's avatar Treehugger Robot Committed by Gerrit Code Review
Browse files

Merge "Added service state override testing tool"

parents 4c7bdf68 60c9dad2
Loading
Loading
Loading
Loading
+1 −2
Original line number Original line Diff line number Diff line
@@ -276,8 +276,7 @@ public abstract class Phone extends Handler implements PhoneInternalInterface {
    public SmsUsageMonitor mSmsUsageMonitor;
    public SmsUsageMonitor mSmsUsageMonitor;
    protected AtomicReference<UiccCardApplication> mUiccApplication =
    protected AtomicReference<UiccCardApplication> mUiccApplication =
            new AtomicReference<UiccCardApplication>();
            new AtomicReference<UiccCardApplication>();

    TelephonyTester mTelephonyTester;
    private TelephonyTester mTelephonyTester;
    private String mName;
    private String mName;
    private final String mActionDetached;
    private final String mActionDetached;
    private final String mActionAttached;
    private final String mActionAttached;
+4 −0
Original line number Original line Diff line number Diff line
@@ -2675,6 +2675,10 @@ public class ServiceStateTracker extends Handler {
        useDataRegStateForDataOnlyDevices();
        useDataRegStateForDataOnlyDevices();
        resetServiceStateInIwlanMode();
        resetServiceStateInIwlanMode();


        if (Build.IS_DEBUGGABLE && mPhone.mTelephonyTester != null) {
            mPhone.mTelephonyTester.overrideServiceState(mNewSS);
        }

        if (DBG) {
        if (DBG) {
            log("Poll ServiceState done: "
            log("Poll ServiceState done: "
                    + " oldSS=[" + mSS + "] newSS=[" + mNewSS + "]"
                    + " oldSS=[" + mSS + "] newSS=[" + mNewSS + "]"
+70 −1
Original line number Original line Diff line number Diff line
@@ -50,6 +50,10 @@ import java.util.List;
 * adb shell am broadcast -a com.android.internal.telephony.{name}.action_attached
 * adb shell am broadcast -a com.android.internal.telephony.{name}.action_attached
 * adb shell am broadcast -a com.android.internal.telephony.TestConferenceEventPackage -e filename
 * adb shell am broadcast -a com.android.internal.telephony.TestConferenceEventPackage -e filename
 *      test_filename.xml
 *      test_filename.xml
 * adb shell am broadcast -a com.android.internal.telephony.TestServiceState --ei data_rat 10 --ei
 *      data_roaming_type 3
 * adb shell am broadcast -a com.android.internal.telephony.TestServiceState --es action reset
 *
 */
 */
public class TelephonyTester {
public class TelephonyTester {
    private static final String LOG_TAG = "TelephonyTester";
    private static final String LOG_TAG = "TelephonyTester";
@@ -99,8 +103,24 @@ public class TelephonyTester {


    private static final String EXTRA_CODE = "code";
    private static final String EXTRA_CODE = "code";



    private static final String ACTION_TEST_SERVICE_STATE =
            "com.android.internal.telephony.TestServiceState";

    private static final String EXTRA_ACTION = "action";
    private static final String EXTRA_VOICE_RAT = "voice_rat";
    private static final String EXTRA_DATA_RAT = "data_rat";
    private static final String EXTRA_VOICE_REG_STATE = "voice_reg_state";
    private static final String EXTRA_DATA_REG_STATE = "data_reg_state";
    private static final String EXTRA_VOICE_ROAMING_TYPE = "voice_roaming_type";
    private static final String EXTRA_DATA_ROAMING_TYPE = "data_roaming_type";

    private static final String ACTION_RESET = "reset";

    private static List<ImsExternalCallState> mImsExternalCallStates = null;
    private static List<ImsExternalCallState> mImsExternalCallStates = null;


    private Intent mServiceStateTestIntent;

    private Phone mPhone;
    private Phone mPhone;


    // The static intent receiver one for all instances and we assume this
    // The static intent receiver one for all instances and we assume this
@@ -133,6 +153,13 @@ public class TelephonyTester {
                } else if (action.equals(ACTION_TEST_SUPP_SRVC_NOTIFICATION)) {
                } else if (action.equals(ACTION_TEST_SUPP_SRVC_NOTIFICATION)) {
                    log("handle supp service notification test intent");
                    log("handle supp service notification test intent");
                    sendTestSuppServiceNotification(intent);
                    sendTestSuppServiceNotification(intent);
                } else if (action.equals(ACTION_TEST_SERVICE_STATE)) {
                    log("handle test service state changed intent");
                    // Trigger the service state update. The replacement will be done in
                    // overrideServiceState().
                    mServiceStateTestIntent = intent;
                    mPhone.getServiceStateTracker().sendEmptyMessage(
                            ServiceStateTracker.EVENT_NETWORK_STATE_CHANGED);
                } else {
                } else {
                    if (DBG) log("onReceive: unknown action=" + action);
                    if (DBG) log("onReceive: unknown action=" + action);
                }
                }
@@ -162,6 +189,9 @@ public class TelephonyTester {
                filter.addAction(ACTION_TEST_HANDOVER_FAIL);
                filter.addAction(ACTION_TEST_HANDOVER_FAIL);
                filter.addAction(ACTION_TEST_SUPP_SRVC_NOTIFICATION);
                filter.addAction(ACTION_TEST_SUPP_SRVC_NOTIFICATION);
                mImsExternalCallStates = new ArrayList<ImsExternalCallState>();
                mImsExternalCallStates = new ArrayList<ImsExternalCallState>();
            } else {
                filter.addAction(ACTION_TEST_SERVICE_STATE);
                log("register for intent action=" + ACTION_TEST_SERVICE_STATE);
            }
            }


            phone.getContext().registerReceiver(mIntentReceiver, filter, null, mPhone.getHandler());
            phone.getContext().registerReceiver(mIntentReceiver, filter, null, mPhone.getHandler());
@@ -298,4 +328,43 @@ public class TelephonyTester {
            imsPhone.notifySuppSvcNotification(suppServiceNotification);
            imsPhone.notifySuppSvcNotification(suppServiceNotification);
        }
        }
    }
    }

    void overrideServiceState(ServiceState ss) {
        if (mServiceStateTestIntent == null || ss == null) return;
        if (mServiceStateTestIntent.hasExtra(EXTRA_ACTION)
                && ACTION_RESET.equals(mServiceStateTestIntent.getStringExtra(EXTRA_ACTION))) {
            log("Service state override reset");
            return;
        }
        if (mServiceStateTestIntent.hasExtra(EXTRA_VOICE_REG_STATE)) {
            ss.setVoiceRegState(mServiceStateTestIntent.getIntExtra(EXTRA_VOICE_REG_STATE,
                    ServiceState.RIL_REG_STATE_UNKNOWN));
            log("Override voice reg state with " + ss.getVoiceRegState());
        }
        if (mServiceStateTestIntent.hasExtra(EXTRA_DATA_REG_STATE)) {
            ss.setDataRegState(mServiceStateTestIntent.getIntExtra(EXTRA_DATA_REG_STATE,
                    ServiceState.RIL_REG_STATE_UNKNOWN));
            log("Override data reg state with " + ss.getDataRegState());
        }
        if (mServiceStateTestIntent.hasExtra(EXTRA_VOICE_RAT)) {
            ss.setRilVoiceRadioTechnology(mServiceStateTestIntent.getIntExtra(EXTRA_VOICE_RAT,
                    ServiceState.RIL_RADIO_TECHNOLOGY_UNKNOWN));
            log("Override voice rat with " + ss.getRilVoiceRadioTechnology());
        }
        if (mServiceStateTestIntent.hasExtra(EXTRA_DATA_RAT)) {
            ss.setRilDataRadioTechnology(mServiceStateTestIntent.getIntExtra(EXTRA_DATA_RAT,
                    ServiceState.RIL_RADIO_TECHNOLOGY_UNKNOWN));
            log("Override data rat with " + ss.getRilDataRadioTechnology());
        }
        if (mServiceStateTestIntent.hasExtra(EXTRA_VOICE_ROAMING_TYPE)) {
            ss.setVoiceRoamingType(mServiceStateTestIntent.getIntExtra(EXTRA_VOICE_ROAMING_TYPE,
                    ServiceState.ROAMING_TYPE_UNKNOWN));
            log("Override voice roaming type with " + ss.getVoiceRoamingType());
        }
        if (mServiceStateTestIntent.hasExtra(EXTRA_DATA_ROAMING_TYPE)) {
            ss.setDataRoamingType(mServiceStateTestIntent.getIntExtra(EXTRA_DATA_ROAMING_TYPE,
                    ServiceState.ROAMING_TYPE_UNKNOWN));
            log("Override data roaming type with " + ss.getDataRoamingType());
        }
    }
}
}
 No newline at end of file