diff options
author | Michael W <baddaemon87@gmail.com> | 2020-04-21 13:29:35 +0200 |
---|---|---|
committer | Michael W <baddaemon87@gmail.com> | 2020-04-21 14:09:38 +0200 |
commit | b101ba5eae2c7fe57f6553260fb07da6d991da84 (patch) | |
tree | 4865d0a80bd1b4b9cf3e4fdfe9dccc6c66b13c8f /sdk/src | |
parent | 13b54376d1d6e1d91e0116c04954ae8c320761d4 (diff) | |
download | lineage-sdk-lineage-16.0.tar.gz lineage-sdk-lineage-16.0.tar.bz2 lineage-sdk-lineage-16.0.zip |
Profiles: Work with a list of subscriptionslineage-16.0
* This is a better approach to work with all subscriptions independently
Change-Id: Ibb8f8a2483bfc1e36dc27e5d6abaf9fc653fbeeb
Diffstat (limited to 'sdk/src')
-rw-r--r-- | sdk/src/java/lineageos/profiles/ConnectionSettings.java | 22 |
1 files changed, 14 insertions, 8 deletions
diff --git a/sdk/src/java/lineageos/profiles/ConnectionSettings.java b/sdk/src/java/lineageos/profiles/ConnectionSettings.java index 66fda392..dd55e4bc 100644 --- a/sdk/src/java/lineageos/profiles/ConnectionSettings.java +++ b/sdk/src/java/lineageos/profiles/ConnectionSettings.java @@ -27,6 +27,7 @@ import android.nfc.NfcAdapter; import android.os.Parcel; import android.os.Parcelable; import android.provider.Settings; +import android.telephony.SubscriptionInfo; import android.telephony.SubscriptionManager; import android.telephony.TelephonyManager; import com.android.internal.telephony.RILConstants; @@ -39,6 +40,7 @@ import org.xmlpull.v1.XmlPullParser; import org.xmlpull.v1.XmlPullParserException; import java.io.IOException; +import java.util.List; /** * The {@link ConnectionSettings} class allows for creating Network/Hardware overrides @@ -257,6 +259,7 @@ public final class ConnectionSettings implements Parcelable { (ConnectivityManager) context.getSystemService(Context.CONNECTIVITY_SERVICE); TelephonyManager tm = (TelephonyManager) context.getSystemService(Context.TELEPHONY_SERVICE); + SubscriptionManager sm = context.getSystemService(SubscriptionManager.class); NfcAdapter nfcAdapter = null; try { nfcAdapter = NfcAdapter.getNfcAdapter(context); @@ -269,14 +272,17 @@ public final class ConnectionSettings implements Parcelable { switch (getConnectionId()) { case PROFILE_CONNECTION_MOBILEDATA: - currentState = tm.getDataEnabled(); - if (forcedState != currentState) { - int phoneCount = tm.getPhoneCount(); - for (int i = 0; i < phoneCount; i++) { - Settings.Global.putInt(context.getContentResolver(), - Settings.Global.MOBILE_DATA + i, (forcedState) ? 1 : 0); - int[] subId = SubscriptionManager.getSubId(i); - tm.setDataEnabled(subId[0], forcedState); + List<SubscriptionInfo> list = sm.getActiveSubscriptionInfoList(); + if (list != null) { + for (int i = 0; i < list.size(); i++) { + int subId = list.get(i).getSubscriptionId(); + int slotIndex = list.get(i).getSimSlotIndex(); + currentState = tm.getDataEnabled(subId); + if (forcedState != currentState) { + Settings.Global.putInt(context.getContentResolver(), + Settings.Global.MOBILE_DATA + i, (forcedState) ? 1 : 0); + tm.setDataEnabled(subId, forcedState); + } } } break; |