This commit is contained in:
jens 2021-09-25 02:03:44 +02:00
parent 8563234db3
commit e60fb1535a
2 changed files with 49 additions and 24 deletions

View File

@ -1252,6 +1252,30 @@ public class Actions
int state = 0;
try
{
if(Build.VERSION.SDK_INT > Build.VERSION_CODES.O_MR1)
{
/*
Android 8.1 is the last version on which the transaction code can be determined
with the below method. From 9.0 on the field TRANSACTION_setDataEnabled does not
exist anymore. Usually it was 83 and we'll just try this number hardcoded.
Alternatively the bottom of this might be an approach:
https://stackoverflow.com/questions/26539445/the-setmobiledataenabled-method-is-no-longer-callable-as-of-android-l-and-later
*/
SubscriptionManager mSubscriptionManager = (SubscriptionManager) context.getSystemService(Context.TELEPHONY_SUBSCRIPTION_SERVICE);
// Loop through the subscription list i.e. SIM list.
for (int i = 0; i < mSubscriptionManager.getActiveSubscriptionInfoCountMax(); i++)
{
// Get the active subscription ID for a given SIM card.
int subscriptionId = mSubscriptionManager.getActiveSubscriptionInfoList().get(i).getSubscriptionId();
// Execute the command via `su` to turn off
// mobile network for a subscription service.
command = "service call phone " + "83" + " i32 " + subscriptionId + " i32 " + desiredState;
Miscellaneous.logEvent("i", "setDataConnectionWithRoot()", "Running command: " + command.toString(), 5);
return executeCommandViaSu(new String[]{command});
}
}
else
{
// Get the current state of the mobile network.
state = isMobileDataEnabled() ? 0 : 1;
@ -1287,6 +1311,7 @@ public class Actions
}
}
}
}
catch (Exception e)
{
// Oops! Something went wrong, so we throw the exception here.

View File

@ -411,11 +411,11 @@ public class ActivityPermissions extends Activity
addToArrayListUnique(Manifest.permission.ACCESS_NETWORK_STATE, requiredPermissions);
break;
case charging:
addToArrayListUnique(Manifest.permission.READ_PHONE_STATE, requiredPermissions);
// addToArrayListUnique(Manifest.permission.READ_PHONE_STATE, requiredPermissions);
// addToArrayListUnique("android.permission.BATTERY_STATS", requiredPermissions);
break;
case headsetPlugged:
addToArrayListUnique(Manifest.permission.READ_PHONE_STATE, requiredPermissions);
// addToArrayListUnique(Manifest.permission.READ_PHONE_STATE, requiredPermissions);
break;
case nfcTag:
addToArrayListUnique(Manifest.permission.NFC, requiredPermissions);