2

我正在尝试编写一个 android 工具来启用和禁用移动网络设置中的“启用数据”。我使用 Robotium 来提供帮助。以下是在移动数据上运行的部分代码:

public class MobileNetworkSettings extends ActivityInstrumentationTestCase2 {

    private static final String LAUNCHER_ACTIVITY_FULL_CLASSNAME =     
    "com.android.phone.MobileNetworkSettings";
    static{
        try {
            launcherActivityClass =                 
            Class.forName(LAUNCHER_ACTIVITY_FULL_CLASSNAME);
        } catch (ClassNotFoundException e) {
            throw new RuntimeException(e);
        }
    }
    @SuppressWarnings("unchecked")
    public MobileNetworkSettings() {
        super(launcherActivityClass);
    }
    ......
    public void testTurnOnMobile() {
        ......
        if(solo.isCheckBoxChecked(0)) {
            solo.clickOnCheckBox(0);
            solo.sleep(10000);      
        }
        ......
    }
    @Override
    protected void setUp() throws Exception {
        solo = new Solo(getInstrumentation(), getActivity());
    }
}

我插入我的 3G 加密狗,我可以看到 3G 网络已准备就绪。我可以上网。然后运行仪器。移动数据网络无法恢复。我在 logcat 中看到以下日志:

08-06 15:31:57.460: I/ActivityManager(2202): Force stopping package com.android.phone appid=1001 user=0
08-06 15:31:57.460: I/ActivityManager(2202): Killing proc 12129:com.android.phone/1001: force stop com.android.phone
08-06 15:31:57.460: W/ActivityManager(2202): Scheduling restart of crashed service com.android.phone/.BluetoothPhoneService in 0ms
08-06 15:31:57.460: W/ActivityManager(2202): Scheduling restart of crashed service com.android.phone/.TelephonyDebugService in 0ms
08-06 15:31:57.470: I/ActivityManager(2202):   Force stopping service ServiceRecord{425f43b8 u0 com.android.phone/.TelephonyDebugService}
08-06 15:31:57.470: I/ActivityManager(2202):   Force stopping service ServiceRecord{42468300 u0 com.android.phone/.BluetoothPhoneService}
08-06 15:31:57.480: I/ActivityManager(2202): Start proc com.android.phone for added application com.android.phone: pid=15273 uid=1001 gids={41001, 3002, 3001, 3003, 1015, 1028}
08-06 15:31:57.480: I/ServiceManager(1250): service 'iphonesubinfo' died
08-06 15:31:57.480: I/ServiceManager(1250): service 'phone' died
08-06 15:31:57.480: I/ServiceManager(1250): service 'simphonebook' died
08-06 15:31:57.480: I/ServiceManager(1250): service 'isms' died
08-06 15:31:57.530: E/jdwp(15273): Failed sending reply to debugger: Broken pipe
08-06 15:31:57.530: D/dalvikvm(15273): Debugger has detached; object registry had 1 entries
08-06 15:31:57.530: W/TelephonyProvider(15273): onCreate: confFile=/system/etc/apns-conf.xml oldCheckSum=-1
08-06 15:31:57.540: D/TelephonyManager(15273): getLteOnCdmaMode=0 curVal=-1 product_type='' lteOnCdmaProductType=''
08-06 15:31:57.560: W/dalvikvm(15273): method Landroid/test/InstrumentationTestRunner$StringResultPrinter;.print incorrectly overrides package-private method with same name in Ljunit/textui/ResultPrinter;
08-06 15:31:57.560: I/TestRunner(15273): started: testRepeatTurnOffTurnOn(com.android.robotium.phone.MobileNetworkSettings)
08-06 15:31:57.560: D/TelephonyManager(15273): getLteOnCdmaMode=0 curVal=-1 product_type='' lteOnCdmaProductType=''
08-06 15:31:57.570: D/TelephonyManager(15273): getLteOnCdmaMode=0 curVal=-1 product_type='' lteOnCdmaProductType=''
08-06 15:31:57.580: I/ActivityManager(2202): START u0 {act=android.intent.action.MAIN flg=0x10000000 cmp=com.android.phone/.MobileNetworkSettings} from pid 15273
08-06 15:31:57.590: D/pppd(13883): rcvd [LCP TermReq id=0x4 "No network protocol running"]
08-06 15:31:57.590: I/pppd(13883): LCP terminated by peer (No network protocol running)
08-06 15:31:57.590: I/pppd(13883): Connect time 6.0 minutes.
08-06 15:31:57.590: I/pppd(13883): Sent 6815 bytes, received 4360 bytes.
08-06 15:31:57.610: D/pppd(13883): Script /etc/ppp/ip-down started (pid 15291)
08-06 15:31:57.610: D/pppd(13883): sent [LCP TermAck id=0x4]
08-06 15:31:57.630: D/pppd(13883): Script /etc/ppp/ip-down finished (pid 15291), status = 0x0
......
08-06 15:31:59.330: I/pppd(13883): Modem hangup
08-06 15:31:59.330: I/pppd(13883): Connection terminated.
08-06 15:31:59.340: W/Netd(1253): No subsystem found in netlink event
08-06 15:31:59.340: D/NetlinkEvent(1253): Unexpected netlink message. type=0x11
08-06 15:31:59.340: D/EthernetDataTracker(2202): ignore [ppp0] remove

看起来当我开始单元测试时,某些服务被重新启动(电话,isms ...)并且调制解调器挂断,我必须拔下并插入3G加密狗才能使其恢复。

08-06 15:31:57.480: I/ServiceManager(1250): service 'iphonesubinfo' died
08-06 15:31:57.480: I/ServiceManager(1250): service 'phone' died
08-06 15:31:57.480: I/ServiceManager(1250): service 'simphonebook' died
08-06 15:31:57.480: I/ServiceManager(1250): service 'isms' died

所以我的问题是:

1.当我启动com.android.phone.MobileNetworkSettings时,系统真的会杀掉一些手机相关的服务,导致3G dongle失效吗?

2.如果是,如何在不影响服务的情况下进行测试?或如何通过编程恢复调制解调器?

谢谢你。

4

0 回答 0