Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit faaee32d authored by Stephen Bird's avatar Stephen Bird
Browse files

Data Toggle: Bring inline with mainline cyanogen settings

Make the profile data toggle work again

Change-Id: I527e39feabfa9e69fe359ca87cb380a010407f2d
(cherry picked from commit 7ab48650)
parent 78348bcf
Loading
Loading
Loading
Loading
+13 −3
Original line number Original line Diff line number Diff line
@@ -27,6 +27,9 @@ import android.nfc.NfcAdapter;
import android.os.Parcel;
import android.os.Parcel;
import android.os.Parcelable;
import android.os.Parcelable;
import android.provider.Settings;
import android.provider.Settings;
import android.telephony.SubscriptionManager;
import android.telephony.TelephonyManager;

import com.android.internal.telephony.RILConstants;
import com.android.internal.telephony.RILConstants;


import org.xmlpull.v1.XmlPullParser;
import org.xmlpull.v1.XmlPullParser;
@@ -121,7 +124,8 @@ public final class ConnectionSettings implements Parcelable {
        BluetoothAdapter bta = BluetoothAdapter.getDefaultAdapter();
        BluetoothAdapter bta = BluetoothAdapter.getDefaultAdapter();
        LocationManager lm = (LocationManager) context.getSystemService(Context.LOCATION_SERVICE);
        LocationManager lm = (LocationManager) context.getSystemService(Context.LOCATION_SERVICE);
        WifiManager wm = (WifiManager) context.getSystemService(Context.WIFI_SERVICE);
        WifiManager wm = (WifiManager) context.getSystemService(Context.WIFI_SERVICE);
        ConnectivityManager cm = (ConnectivityManager) context.getSystemService(Context.CONNECTIVITY_SERVICE);
        TelephonyManager tm = (TelephonyManager)
                context.getSystemService(Context.TELEPHONY_SERVICE);
        NfcAdapter nfcAdapter = null;
        NfcAdapter nfcAdapter = null;
        try {
        try {
            nfcAdapter = NfcAdapter.getNfcAdapter(context);
            nfcAdapter = NfcAdapter.getNfcAdapter(context);
@@ -134,9 +138,15 @@ public final class ConnectionSettings implements Parcelable {


        switch (getConnectionId()) {
        switch (getConnectionId()) {
            case PROFILE_CONNECTION_MOBILEDATA:
            case PROFILE_CONNECTION_MOBILEDATA:
                currentState = cm.getMobileDataEnabled();
                currentState = tm.getDataEnabled();
                if (forcedState != currentState) {
                if (forcedState != currentState) {
// hharte                    cm.setMobileDataEnabled(forcedState);
                    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);
                    }
                }
                }
                break;
                break;
            case PROFILE_CONNECTION_2G3G4G:
            case PROFILE_CONNECTION_2G3G4G: