diff --git a/app/src/apkFlavor/AndroidManifest.xml b/app/src/apkFlavor/AndroidManifest.xml
index 3fe42be..df9a792 100644
--- a/app/src/apkFlavor/AndroidManifest.xml
+++ b/app/src/apkFlavor/AndroidManifest.xml
@@ -82,7 +82,8 @@
-
+
+ dev.shadoe.delta.action.START_SOFT_AP
diff --git a/app/src/main/java/com/jens/automation2/Actions.java b/app/src/main/java/com/jens/automation2/Actions.java
index 2367459..55bec60 100644
--- a/app/src/main/java/com/jens/automation2/Actions.java
+++ b/app/src/main/java/com/jens/automation2/Actions.java
@@ -18,6 +18,7 @@ import android.content.Intent;
import android.media.AudioManager;
import android.media.MediaPlayer;
import android.net.ConnectivityManager;
+import android.net.TetheringManager;
import android.net.Uri;
import android.net.wifi.WifiManager;
import android.os.Build;
@@ -73,6 +74,8 @@ import java.util.List;
import java.util.Map;
import java.util.Random;
import java.util.Set;
+import java.util.concurrent.Executor;
+import java.util.concurrent.Executors;
import java.util.concurrent.TimeUnit;
import javax.net.ssl.SSLContext;
@@ -541,7 +544,7 @@ public class Actions
}
}
}
- else
+ else if(Build.VERSION.SDK_INT < 36)
{
MyOnStartTetheringCallback cb = new MyOnStartTetheringCallback()
{
@@ -564,6 +567,13 @@ public class Actions
else
mowm.stopTethering();
}
+ else // from Android 16 onwards
+ {
+ if(desiredState)
+ Actions.WifiTethering.enable(context);
+ else
+ Actions.WifiTethering.disable(context);
+ }
}
return true;
}
@@ -1098,18 +1108,18 @@ public class Actions
// {
// ssf = new MySSLSocketFactory(ctx);
// ssf.setHostnameVerifier(SSLSocketFactory.STRICT_HOSTNAME_VERIFIER);
-//
+//
// char[] keystorePass="insecure".toCharArray(); //passphrase for keystore
// KeyStore keyStore=KeyStore.getInstance("BKS");
-//
+//
//// String tmfAlgorithm = TrustManagerFactory.getDefaultAlgorithm();
// TrustManagerFactory tmf = TrustManagerFactory.getInstance("X509");
// tmf.init(keyStore);
-//
+//
// Miscellaneous.logEvent("i", "SSL Keystore", context.getCacheDir().toString(), 4);
-// InputStream is = context.getResources().openRawResource(R.raw.keystore);
+// InputStream is = context.getResources().openRawResource(R.raw.keystore);
// keyStore.load(is,keystorePass);
-//
+//
// ctx.init(null, tmf.getTrustManagers(), null);
// }
// else
@@ -1222,7 +1232,10 @@ public class Actions
else if (startupType.equals(ActivityManageActionStartActivity.startByForegroundServiceString) && Build.VERSION.SDK_INT >= 26)
automationServerRef.startForegroundService(externalApplicationIntent);
else
+ {
+ externalApplicationIntent.addCategory("");
automationServerRef.sendBroadcast(externalApplicationIntent);
+ }
}
catch (Exception e)
{
@@ -2674,5 +2687,71 @@ public class Actions
// }
android.provider.Settings.Secure.putString(context.getContentResolver(), android.provider.Settings.Secure.LOCATION_MODE, String.valueOf(desiredState));
}
+ public static final class WifiTethering
+ {
+ private static final Executor EXECUTOR = Executors.newSingleThreadExecutor();
+ private WifiTethering()
+ {
+ // Utility class
+ }
+
+ public static void enable(Context context)
+ {
+ if (Build.VERSION.SDK_INT < Build.VERSION_CODES.BAKLAVA)
+ {
+ throw new UnsupportedOperationException("TetheringManager requires Android 16 / API 36");
+ }
+
+ TetheringManager tetheringManager = context.getSystemService(TetheringManager.class);
+
+ TetheringManager.TetheringRequest request = new TetheringManager.TetheringRequest.Builder(TetheringManager.TETHERING_WIFI).build();
+
+ tetheringManager.startTethering(request, EXECUTOR, new TetheringManager.StartTetheringCallback() {
+ @Override
+ public void onTetheringStarted()
+ {
+ // Wi-Fi hotspot enabled
+ Miscellaneous.logEvent("i", "Tethering start", "Success", 3);
+ }
+
+ @Override
+ public void onTetheringFailed(int error)
+ {
+ // Hotspot could not be enabled
+ Miscellaneous.logEvent("i", "Tethering start", "Failure. Error code: " + String.valueOf(error), 3);
+ }
+ }
+ );
+ }
+
+ public static void disable(Context context)
+ {
+ if (Build.VERSION.SDK_INT < Build.VERSION_CODES.BAKLAVA)
+ {
+ throw new UnsupportedOperationException("TetheringManager requires Android 16 / API 36");
+ }
+
+ TetheringManager tetheringManager = context.getSystemService(TetheringManager.class);
+
+ TetheringManager.TetheringRequest request = new TetheringManager.TetheringRequest.Builder(TetheringManager.TETHERING_WIFI).build();
+// tetheringManager.stopTethering(TetheringManager.TETHERING_WIFI, EXECUTOR, new TetheringManager.StopTetheringCallback() {
+ tetheringManager.stopTethering(request, EXECUTOR, new TetheringManager.StopTetheringCallback() {
+ @Override
+ public void onStopTetheringSucceeded()
+ {
+ TetheringManager.StopTetheringCallback.super.onStopTetheringSucceeded();
+ Miscellaneous.logEvent("i", "Tethering stop", "Success", 3);
+ }
+
+ @Override
+ public void onStopTetheringFailed(int error)
+ {
+ // Hotspot could not be disabled
+ Miscellaneous.logEvent("i", "Tethering stop", "Failure. Error code: " + String.valueOf(error), 3);
+ }
+ }
+ );
+ }
+ }
}
\ No newline at end of file