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

Commit 6d457b9b authored by Pawit Pornkitprasan's avatar Pawit Pornkitprasan Committed by Steve Kondik
Browse files

Fix Quick Settings for MSim [1/2]

 - Show the data usage of active data SIM for QS
 - Immediately update QS when data subscription changes
 - Forward setDataEnabled AS-IS (see part [2/2])

Change-Id: I1c72d9955b1d068ef276386b761f7aa2d664fdc2
parent 049981cb
Loading
Loading
Loading
Loading
+13 −0
Original line number Diff line number Diff line
@@ -433,6 +433,19 @@ public class MSimNetworkControllerImpl extends NetworkControllerImpl {
                    updateDataIcon(i);
                    refreshViews(i);
                }
        } else if (action.equals(TelephonyIntents.ACTION_DEFAULT_DATA_SUBSCRIPTION_CHANGED)) {
            // Update data in QS
            long subId = intent.getLongExtra(PhoneConstants.SUBSCRIPTION_KEY, -1);

            if (subId == -1) {
                Slog.e(TAG, "No subId in ACTION_DEFAULT_DATA_SUBSCRIPTION_CHANGED");
                return;
            }

            int phoneId = getPhoneId(subId);
            updateTelephonySignalStrength(phoneId);
            updateDataNetType(phoneId);
            refreshViews(phoneId);
        }
    }

+2 −1
Original line number Diff line number Diff line
@@ -33,6 +33,7 @@ import android.net.NetworkStatsHistory;
import android.net.NetworkTemplate;
import android.os.RemoteException;
import android.os.ServiceManager;
import android.telephony.SubscriptionManager;
import android.telephony.TelephonyManager;
import android.text.format.DateUtils;
import android.text.format.Time;
@@ -207,7 +208,7 @@ public class MobileDataController {

    private static String getActiveSubscriberId(Context context) {
        final TelephonyManager tele = TelephonyManager.from(context);
        final String actualSubscriberId = tele.getSubscriberId();
        final String actualSubscriberId = tele.getSubscriberId(SubscriptionManager.getDefaultDataSubId());
        return actualSubscriberId;
    }

+1 −0
Original line number Diff line number Diff line
@@ -256,6 +256,7 @@ public class NetworkControllerImpl extends BroadcastReceiver
        filter.addAction(Intent.ACTION_AIRPLANE_MODE_CHANGED);

        filter.addAction(TelephonyIntents.ACTION_SUBINFO_RECORD_UPDATED);
        filter.addAction(TelephonyIntents.ACTION_DEFAULT_DATA_SUBSCRIPTION_CHANGED);

        mWimaxSupported = mContext.getResources().getBoolean(
                com.android.internal.R.bool.config_wimaxEnabled);
+12 −1
Original line number Diff line number Diff line
@@ -3464,7 +3464,18 @@ public class TelephonyManager {
    /** @hide */
    @SystemApi
    public void setDataEnabled(boolean enable) {
        setDataEnabledUsingSubId(getDefaultSubscription(), enable);
        try {
            AppOpsManager appOps = (AppOpsManager)mContext.getSystemService(Context.APP_OPS_SERVICE);
            if (enable) {
                if (appOps.noteOp(AppOpsManager.OP_DATA_CONNECT_CHANGE) != AppOpsManager.MODE_ALLOWED) {
                    Log.w(TAG, "Permission denied by user.");
                    return;
                }
            }
            getITelephony().setDataEnabled(enable);
        } catch (RemoteException e) {
            Log.e(TAG, "Error calling setDataEnabled", e);
        }
    }

    /** @hide */