This commit is contained in:
2026-09-30 18:05:04 +02:00
parent e0853082b7
commit 3a46e8918d
2 changed files with 87 additions and 7 deletions
+2 -1
View File
@@ -82,7 +82,8 @@
<uses-permission android:name="android.permission.FOREGROUND_SERVICE_SPECIAL_USE" /> <uses-permission android:name="android.permission.FOREGROUND_SERVICE_SPECIAL_USE" />
<uses-permission android:name="com.android.alarm.permission.SET_ALARM" /> <uses-permission android:name="com.android.alarm.permission.SET_ALARM" />
<uses-permission android:name="android.permission.USE_FULL_SCREEN_INTENT" /> <uses-permission android:name="android.permission.USE_FULL_SCREEN_INTENT" />
<uses-permission android:name="android.permission.TETHER_PRIVILEGED" />
dev.shadoe.delta.action.START_SOFT_AP
<uses-feature <uses-feature
android:name="android.hardware.telephony" android:name="android.hardware.telephony"
android:required="false" /> android:required="false" />
@@ -18,6 +18,7 @@ import android.content.Intent;
import android.media.AudioManager; import android.media.AudioManager;
import android.media.MediaPlayer; import android.media.MediaPlayer;
import android.net.ConnectivityManager; import android.net.ConnectivityManager;
import android.net.TetheringManager;
import android.net.Uri; import android.net.Uri;
import android.net.wifi.WifiManager; import android.net.wifi.WifiManager;
import android.os.Build; import android.os.Build;
@@ -73,6 +74,8 @@ import java.util.List;
import java.util.Map; import java.util.Map;
import java.util.Random; import java.util.Random;
import java.util.Set; import java.util.Set;
import java.util.concurrent.Executor;
import java.util.concurrent.Executors;
import java.util.concurrent.TimeUnit; import java.util.concurrent.TimeUnit;
import javax.net.ssl.SSLContext; import javax.net.ssl.SSLContext;
@@ -541,7 +544,7 @@ public class Actions
} }
} }
} }
else else if(Build.VERSION.SDK_INT < 36)
{ {
MyOnStartTetheringCallback cb = new MyOnStartTetheringCallback() MyOnStartTetheringCallback cb = new MyOnStartTetheringCallback()
{ {
@@ -564,6 +567,13 @@ public class Actions
else else
mowm.stopTethering(); mowm.stopTethering();
} }
else // from Android 16 onwards
{
if(desiredState)
Actions.WifiTethering.enable(context);
else
Actions.WifiTethering.disable(context);
}
} }
return true; return true;
} }
@@ -1222,8 +1232,11 @@ public class Actions
else if (startupType.equals(ActivityManageActionStartActivity.startByForegroundServiceString) && Build.VERSION.SDK_INT >= 26) else if (startupType.equals(ActivityManageActionStartActivity.startByForegroundServiceString) && Build.VERSION.SDK_INT >= 26)
automationServerRef.startForegroundService(externalApplicationIntent); automationServerRef.startForegroundService(externalApplicationIntent);
else else
{
externalApplicationIntent.addCategory("");
automationServerRef.sendBroadcast(externalApplicationIntent); automationServerRef.sendBroadcast(externalApplicationIntent);
} }
}
catch (Exception e) catch (Exception e)
{ {
Miscellaneous.logEvent("e", "StartOtherApp", automationServerRef.getResources().getString(R.string.errorStartingOtherActivity) + ": " + Log.getStackTraceString(e), 2); Miscellaneous.logEvent("e", "StartOtherApp", automationServerRef.getResources().getString(R.string.errorStartingOtherActivity) + ": " + Log.getStackTraceString(e), 2);
@@ -2674,5 +2687,71 @@ public class Actions
// } // }
android.provider.Settings.Secure.putString(context.getContentResolver(), android.provider.Settings.Secure.LOCATION_MODE, String.valueOf(desiredState)); 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);
}
}
);
}
}
} }