package com.mumux.androidtesting.actions.impl; import com.android.uiautomator.testrunner.UiAutomatorTestCase; import com.mumux.androidtesting.actions.OnOffAction; public class PlaneAction extends OnOffAction { public PlaneAction() { super("PLANE", false, "Turn on/off plane mode", Category.SYSTEM, "setting not updated"); } @Override public String run(UiAutomatorTestCase uiAutomatorTestCase, Runtime runtime) { throw new UnsupportedOperationException(); } /* @Override public void run(UiAutomatorTestCase uiAutomatorTestCase) throws ActionException { boolean status = false; if (args.get(0).equals("on")) { status = true; } System.err.println("status=" + status); // Current status // adb shell settings get global airplane_mode_on 0 if off 1 oif on boolean currentStatus = false; try { int code = Integer.parseInt(execCmd("settings get global airplane_mode_on").trim()); if (code == 1) { currentStatus = true; } } catch (IOException e) { e.printStackTrace(); } System.err.println("current status=" + currentStatus); // Toggle only when necessary if (status != currentStatus) { System.err.println("Toogle Plane mode"); List<String> commands = new ArrayList<String>(); commands.add("am start -a android.settings.AIRPLANE_MODE_SETTINGS"); commands.add("sleep 1"); commands.add("input keyevent 19"); commands.add("input keyevent 23"); commands.add("input keyevent 4"); try { for (String command : commands) { System.err.println(execCmd(command)); } } catch (IOException e) { e.printStackTrace(); throw new ActionException(); } try { Thread.sleep(2000); } catch (InterruptedException e) { e.printStackTrace(); } } } */ }