Compare commits
5
Commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
6e6e89b38a | ||
|
|
cad2e9df9d | ||
|
|
b803df9685 | ||
|
|
14f525ec80 | ||
|
|
3a46e8918d |
No files matched your search
+5
-1
@@ -7,7 +7,7 @@ android {
|
||||
|
||||
defaultConfig {
|
||||
applicationId "com.jens.automation2"
|
||||
minSdkVersion 19
|
||||
minSdkVersion 24
|
||||
compileSdkVersion 37
|
||||
buildToolsVersion '36.0.0'
|
||||
useLibrary 'org.apache.http.legacy'
|
||||
@@ -84,4 +84,8 @@ dependencies {
|
||||
testImplementation 'junit:junit:4.13.2'
|
||||
androidTestImplementation 'androidx.test.ext:junit:1.2.1'
|
||||
androidTestImplementation 'androidx.test.espresso:espresso-core:3.4.0'
|
||||
|
||||
def shizuku_version = "13.1.5"
|
||||
implementation "dev.rikka.shizuku:api:$shizuku_version"
|
||||
implementation "dev.rikka.shizuku:provider:$shizuku_version"
|
||||
}
|
||||
@@ -82,7 +82,8 @@
|
||||
<uses-permission android:name="android.permission.FOREGROUND_SERVICE_SPECIAL_USE" />
|
||||
<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.TETHER_PRIVILEGED" />
|
||||
dev.shadoe.delta.action.START_SOFT_AP
|
||||
<uses-feature
|
||||
android:name="android.hardware.telephony"
|
||||
android:required="false" />
|
||||
@@ -274,6 +275,14 @@
|
||||
android:exported="true"
|
||||
/>
|
||||
|
||||
<provider
|
||||
android:name="rikka.shizuku.ShizukuProvider"
|
||||
android:authorities="${applicationId}.shizuku"
|
||||
android:enabled="true"
|
||||
android:exported="true"
|
||||
android:multiprocess="false"
|
||||
android:permission="android.permission.INTERACT_ACROSS_USERS_FULL" />
|
||||
|
||||
<service android:name=".MyAccessibilityService"
|
||||
android:permission="android.permission.BIND_ACCESSIBILITY_SERVICE">
|
||||
<intent-filter>
|
||||
|
||||
@@ -260,6 +260,14 @@
|
||||
android:exported="true"
|
||||
/>
|
||||
|
||||
<provider
|
||||
android:name="rikka.shizuku.ShizukuProvider"
|
||||
android:authorities="${applicationId}.shizuku"
|
||||
android:enabled="true"
|
||||
android:exported="true"
|
||||
android:multiprocess="false"
|
||||
android:permission="android.permission.INTERACT_ACROSS_USERS_FULL" />
|
||||
|
||||
<service android:name=".MyAccessibilityService"
|
||||
android:permission="android.permission.BIND_ACCESSIBILITY_SERVICE">
|
||||
<intent-filter>
|
||||
|
||||
@@ -253,13 +253,20 @@
|
||||
android:value="@integer/google_play_services_version" />
|
||||
<service android:name=".location.GeofenceIntentService"/>
|
||||
|
||||
|
||||
<provider
|
||||
android:name=".FileShareProvider"
|
||||
android:authorities="com.jens.automation2"
|
||||
android:exported="true"
|
||||
/>
|
||||
|
||||
<provider
|
||||
android:name="rikka.shizuku.ShizukuProvider"
|
||||
android:authorities="${applicationId}.shizuku"
|
||||
android:enabled="true"
|
||||
android:exported="true"
|
||||
android:multiprocess="false"
|
||||
android:permission="android.permission.INTERACT_ACROSS_USERS_FULL" />
|
||||
|
||||
</application>
|
||||
|
||||
</manifest>
|
||||
@@ -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);
|
||||
}
|
||||
}
|
||||
);
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -39,6 +39,8 @@ import java.util.Iterator;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
|
||||
import rikka.shizuku.Shizuku;
|
||||
|
||||
public class ActivityPermissions extends Activity
|
||||
{
|
||||
static Map<String, String> mapGeneralPermissions = null;
|
||||
@@ -58,6 +60,7 @@ public class ActivityPermissions extends Activity
|
||||
private static final int requestCodeForPermissionsManageOverlay = 12050;
|
||||
private static final int requestCodeForPermissionsAccessibility = 12051;
|
||||
private static final int requestCodeForPermissionsScheduleExactAlarms = 12052;
|
||||
private static final int requestCodeForPermissionsShizuku = 12053;
|
||||
protected String[] specificPermissionsToRequest = null;
|
||||
|
||||
public static String intentExtraName = "permissionsToBeRequested";
|
||||
@@ -70,6 +73,7 @@ public class ActivityPermissions extends Activity
|
||||
public final static String permissionNameGoogleActivityDetection = "com.google.android.gms.permission.ACTIVITY_RECOGNITION";
|
||||
public final static String permissionNameSuperuser = "android.permission.ACCESS_SUPERUSER";
|
||||
public final static String permissionNameProximity = "android.hardware.sensor.proximity";
|
||||
public final static String permissionNameShizuku = "android_permission_shizuku";
|
||||
|
||||
public static ActivityPermissions getInstance()
|
||||
{
|
||||
@@ -273,6 +277,11 @@ public class ActivityPermissions extends Activity
|
||||
if (!havePermission(s, context))
|
||||
return true;
|
||||
}
|
||||
else if(s.equalsIgnoreCase(permissionNameShizuku))
|
||||
{
|
||||
if(!ShizukuAccess.isAuthorized())
|
||||
return true;
|
||||
}
|
||||
else if (!havePermission(s, context))
|
||||
return true;
|
||||
}
|
||||
@@ -529,6 +538,7 @@ public class ActivityPermissions extends Activity
|
||||
|
||||
if (rule.isRuleActive())
|
||||
{
|
||||
addToArrayListUnique(permissionNameShizuku, requiredPermissions);
|
||||
for (Trigger trigger : rule.getTriggerSet())
|
||||
{
|
||||
switch (trigger.getTriggerType())
|
||||
@@ -1390,6 +1400,11 @@ public class ActivityPermissions extends Activity
|
||||
Linkify.addLinks((TextView) diaglog.findViewById(android.R.id.message), Linkify.ALL);
|
||||
// return;
|
||||
}
|
||||
else if(s.equals(permissionNameShizuku))
|
||||
{
|
||||
ShizukuAccess.requestAuthorization();
|
||||
return;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1909,4 +1924,34 @@ public class ActivityPermissions extends Activity
|
||||
// have all
|
||||
setHaveAllPermissions();
|
||||
}
|
||||
|
||||
public final static class ShizukuAccess
|
||||
{
|
||||
private ShizukuAccess()
|
||||
{
|
||||
}
|
||||
|
||||
public static boolean isAvailable()
|
||||
{
|
||||
return !Shizuku.isPreV11() && Shizuku.pingBinder();
|
||||
}
|
||||
|
||||
public static boolean isAuthorized()
|
||||
{
|
||||
return isAvailable() && Shizuku.checkSelfPermission() == PackageManager.PERMISSION_GRANTED;
|
||||
}
|
||||
|
||||
public static void requestAuthorization()
|
||||
{
|
||||
if (!isAvailable())
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
if (Shizuku.checkSelfPermission() != PackageManager.PERMISSION_GRANTED)
|
||||
{
|
||||
Shizuku.requestPermission(requestCodeForPermissionsShizuku);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -979,4 +979,5 @@
|
||||
<string name="examplesWriteSecureSettings">I do not keep a list of possible settings. Please find those settings on your own. See <a href="https://developer.android.com/reference/android/provider/Settings.Secure">here</a> for some (incomplete) examples.</string>
|
||||
<string name="httpParametersExplanation">If any parameter name starts with %1$s while method is POST, it will not be transmitted like the other parameters (with key=value), but transferred as main data. If the parameter ends with %2$s, no encoding will be performed.</string>
|
||||
<string name="target">Target</string>
|
||||
<string name="android_permission_shizuku" translatable="false">Shizuku</string>
|
||||
</resources>
|
||||
Reference in new issue
Block a user