mirror of
https://github.com/danog/termux-api.git
synced 2024-11-26 20:04:42 +01:00
Wifi API additions (#177)
* Added Wifi turn on/off methods * Added Wifi toggle method
This commit is contained in:
parent
875d6ec4d5
commit
1689cfec08
@ -22,6 +22,7 @@
|
||||
<uses-permission android:name="android.permission.READ_PHONE_STATE" />
|
||||
<uses-permission android:name="android.permission.ACCESS_NETWORK_STATE" />
|
||||
<uses-permission android:name="android.permission.ACCESS_WIFI_STATE" />
|
||||
<uses-permission android:name="android.permission.CHANGE_WIFI_STATE" />
|
||||
<uses-permission android:name="android.permission.WRITE_SETTINGS"
|
||||
tools:ignore="ProtectedPermissions" />
|
||||
<uses-permission android:name="android.permission.USE_FINGERPRINT" />
|
||||
|
@ -168,6 +168,9 @@ public class TermuxApiReceiver extends BroadcastReceiver {
|
||||
WifiAPI.onReceiveWifiScanInfo(this, context, intent);
|
||||
}
|
||||
break;
|
||||
case "WifiEnable":
|
||||
WifiAPI.onReceiveWifiEnable(this, context, intent);
|
||||
break;
|
||||
default:
|
||||
TermuxApiLogger.error("Unrecognized 'api_method' extra: '" + apiMethod + "'");
|
||||
}
|
||||
|
@ -112,4 +112,15 @@ public class WifiAPI {
|
||||
});
|
||||
}
|
||||
|
||||
static void onReceiveWifiEnable(TermuxApiReceiver apiReceiver, final Context context, final Intent intent) {
|
||||
ResultReturner.returnData(apiReceiver, intent, new ResultReturner.ResultJsonWriter() {
|
||||
@Override
|
||||
public void writeJson(JsonWriter out) {
|
||||
WifiManager manager = (WifiManager) context.getSystemService(Context.WIFI_SERVICE);
|
||||
boolean state = intent.getBooleanExtra("enabled", false);
|
||||
manager.setWifiEnabled(state);
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user