她正在尝试检查AirPlaneMode复选框是否已准备就绪,如果没有,则点击。但它总是点击checkBox而不管它是否被点击:
无法弄清楚我在做错的地方。
代码:
public class AirPlaneModeHandler extends UiAutomatorTestCase{
//private Context context;
private int isAiplaneEnables;
private void executeShellCommand(String paramString)
{
try
{
Process p = Runtime.getRuntime().exec(paramString);
p.waitFor();
Thread.sleep(1000L);
return ;
}
catch (Exception localException){}
}
public void startTest() {
try {
//isAiplaneEnables = Settings.System.getInt(getContentResolver(),Settings.Global.AIRPLANE_MODE_ON,0);
// toggleAiplaneMode();
executeShellCommand("am start -n com.android.settings/.Settings");
Thread.sleep(1000L);
UiObject moreBtn = new UiObject(new UiSelector().index(4));
if(moreBtn!=null) {
moreBtn.click();
}
Thread.sleep(1000L);
UiObject object = new UiObject(new UiSelector().text("Airplane mode"));
if(object!=null) {
if(!object.isChecked())
object.click();
}
} catch (Exception localException) {
// Log.d("POST", localException.getMessage());
}
}
}