Skip to content

Commit 310743b

Browse files
committed
use newer command to toggle airplane mode on Android 11+
1 parent e8a45df commit 310743b

File tree

2 files changed

+6
-3
lines changed

2 files changed

+6
-3
lines changed

app/build.gradle

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -9,8 +9,8 @@ android {
99
applicationId "it.pgp.currenttoggles"
1010
minSdkVersion 21 // for sdk 19 and lower, just use the great PowerToggles :)
1111
targetSdkVersion 28 // do not raise this, otherwise wifi toggle won't work without root on api 29+
12-
versionCode 124230211
13-
versionName "1.2.4"
12+
versionCode 125230305
13+
versionName "1.2.5"
1414
}
1515

1616
buildTypes {

app/src/main/java/it/pgp/currenttoggles/MainActivity.java

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -150,8 +150,11 @@ public static void toggleAirplane(Context context) {
150150
int airplaneEnabled = Misc.isAirplaneModeEnabled(context) ? 1 : 0;
151151
showToast(context, msgs[airplaneEnabled], airplaneEnabled == 0);
152152
try {
153+
String command = Build.VERSION.SDK_INT < 30 ?
154+
"settings put global airplane_mode_on "+(1-airplaneEnabled)+" && am broadcast -a android.intent.action.AIRPLANE_MODE" :
155+
"cmd connectivity airplane-mode "+(airplaneEnabled == 0 ? "enable" : "disable");
153156
RootHandler.executeCommandAndWaitFor(
154-
"settings put global airplane_mode_on "+(1-airplaneEnabled)+" && am broadcast -a android.intent.action.AIRPLANE_MODE",
157+
command,
155158
null, true, null);
156159
}
157160
catch(IOException e) {

0 commit comments

Comments
 (0)