bugspray
This commit is contained in:
parent
8563234db3
commit
e60fb1535a
@ -1253,37 +1253,62 @@ public class Actions
|
|||||||
|
|
||||||
try
|
try
|
||||||
{
|
{
|
||||||
// Get the current state of the mobile network.
|
if(Build.VERSION.SDK_INT > Build.VERSION_CODES.O_MR1)
|
||||||
state = isMobileDataEnabled() ? 0 : 1;
|
|
||||||
// Get the value of the "TRANSACTION_setDataEnabled" field.
|
|
||||||
String transactionCode = getTransactionCode(context);
|
|
||||||
// Android 5.1+ (API 22) and later.
|
|
||||||
if (Build.VERSION.SDK_INT > Build.VERSION_CODES.LOLLIPOP)
|
|
||||||
{
|
{
|
||||||
|
/*
|
||||||
|
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);
|
SubscriptionManager mSubscriptionManager = (SubscriptionManager) context.getSystemService(Context.TELEPHONY_SUBSCRIPTION_SERVICE);
|
||||||
// Loop through the subscription list i.e. SIM list.
|
// Loop through the subscription list i.e. SIM list.
|
||||||
for (int i = 0; i < mSubscriptionManager.getActiveSubscriptionInfoCountMax(); i++)
|
for (int i = 0; i < mSubscriptionManager.getActiveSubscriptionInfoCountMax(); i++)
|
||||||
{
|
{
|
||||||
if (transactionCode != null && transactionCode.length() > 0)
|
// Get the active subscription ID for a given SIM card.
|
||||||
{
|
int subscriptionId = mSubscriptionManager.getActiveSubscriptionInfoList().get(i).getSubscriptionId();
|
||||||
// Get the active subscription ID for a given SIM card.
|
// Execute the command via `su` to turn off
|
||||||
int subscriptionId = mSubscriptionManager.getActiveSubscriptionInfoList().get(i).getSubscriptionId();
|
// mobile network for a subscription service.
|
||||||
// Execute the command via `su` to turn off
|
command = "service call phone " + "83" + " i32 " + subscriptionId + " i32 " + desiredState;
|
||||||
// mobile network for a subscription service.
|
Miscellaneous.logEvent("i", "setDataConnectionWithRoot()", "Running command: " + command.toString(), 5);
|
||||||
command = "service call phone " + transactionCode + " i32 " + subscriptionId + " i32 " + desiredState;
|
return executeCommandViaSu(new String[]{command});
|
||||||
Miscellaneous.logEvent("i", "setDataConnectionWithRoot()", "Running command: " + command.toString(), 5);
|
|
||||||
return executeCommandViaSu(new String[]{command});
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
else if (Build.VERSION.SDK_INT == Build.VERSION_CODES.LOLLIPOP)
|
else
|
||||||
{
|
{
|
||||||
// Android 5.0 (API 21) only.
|
// Get the current state of the mobile network.
|
||||||
if (transactionCode != null && transactionCode.length() > 0)
|
state = isMobileDataEnabled() ? 0 : 1;
|
||||||
|
// Get the value of the "TRANSACTION_setDataEnabled" field.
|
||||||
|
String transactionCode = getTransactionCode(context);
|
||||||
|
// Android 5.1+ (API 22) and later.
|
||||||
|
if (Build.VERSION.SDK_INT > Build.VERSION_CODES.LOLLIPOP)
|
||||||
{
|
{
|
||||||
// Execute the command via `su` to turn off mobile network.
|
SubscriptionManager mSubscriptionManager = (SubscriptionManager) context.getSystemService(Context.TELEPHONY_SUBSCRIPTION_SERVICE);
|
||||||
command = "service call phone " + transactionCode + " i32 " + desiredState;
|
// Loop through the subscription list i.e. SIM list.
|
||||||
return executeCommandViaSu(new String[]{command});
|
for (int i = 0; i < mSubscriptionManager.getActiveSubscriptionInfoCountMax(); i++)
|
||||||
|
{
|
||||||
|
if (transactionCode != null && transactionCode.length() > 0)
|
||||||
|
{
|
||||||
|
// 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 " + transactionCode + " i32 " + subscriptionId + " i32 " + desiredState;
|
||||||
|
Miscellaneous.logEvent("i", "setDataConnectionWithRoot()", "Running command: " + command.toString(), 5);
|
||||||
|
return executeCommandViaSu(new String[]{command});
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
else if (Build.VERSION.SDK_INT == Build.VERSION_CODES.LOLLIPOP)
|
||||||
|
{
|
||||||
|
// Android 5.0 (API 21) only.
|
||||||
|
if (transactionCode != null && transactionCode.length() > 0)
|
||||||
|
{
|
||||||
|
// Execute the command via `su` to turn off mobile network.
|
||||||
|
command = "service call phone " + transactionCode + " i32 " + desiredState;
|
||||||
|
return executeCommandViaSu(new String[]{command});
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -411,11 +411,11 @@ public class ActivityPermissions extends Activity
|
|||||||
addToArrayListUnique(Manifest.permission.ACCESS_NETWORK_STATE, requiredPermissions);
|
addToArrayListUnique(Manifest.permission.ACCESS_NETWORK_STATE, requiredPermissions);
|
||||||
break;
|
break;
|
||||||
case charging:
|
case charging:
|
||||||
addToArrayListUnique(Manifest.permission.READ_PHONE_STATE, requiredPermissions);
|
// addToArrayListUnique(Manifest.permission.READ_PHONE_STATE, requiredPermissions);
|
||||||
// addToArrayListUnique("android.permission.BATTERY_STATS", requiredPermissions);
|
// addToArrayListUnique("android.permission.BATTERY_STATS", requiredPermissions);
|
||||||
break;
|
break;
|
||||||
case headsetPlugged:
|
case headsetPlugged:
|
||||||
addToArrayListUnique(Manifest.permission.READ_PHONE_STATE, requiredPermissions);
|
// addToArrayListUnique(Manifest.permission.READ_PHONE_STATE, requiredPermissions);
|
||||||
break;
|
break;
|
||||||
case nfcTag:
|
case nfcTag:
|
||||||
addToArrayListUnique(Manifest.permission.NFC, requiredPermissions);
|
addToArrayListUnique(Manifest.permission.NFC, requiredPermissions);
|
||||||
|
Loading…
Reference in New Issue
Block a user