I am trying to toggle airplane mode on kitkat version, on rooted emulator. I am using espresso for automation and i have scenario in which i have to switch on airplane mode and do some kind of steps in the app
I have modified time using the following method :
public static void amTime() {
try {
Process su = Runtime.getRuntime().exec("su");
DataOutputStream outputStream = new DataOutputStream(su.getOutputStream());
outputStream.writeBytes("date -s 20181015.070000");
outputStream.flush();
outputStream.writeBytes("exit\n");
outputStream.flush();
su.wait(2000);
} catch (Exception e){
Log.e("Set Time", e.getMessage());
}
}
But I am unable to switch to airplane mode, i have tried different patterns... used the above method and modified following line with the adb commands
outputStream.writeBytes("mode airplane_mode_on 1");
outputStream.writeBytes("adb shell -c settings put global airplane_mode_on 1");
outputStream.writeBytes("adb shell -c settings put global airplane_mode_on 0");
can someone help with the code or adb script, by which i can switch on and off the airplane mode