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

Commit 43fe18b0 authored by Linux Build Service Account's avatar Linux Build Service Account Committed by Gerrit - the friendly Code Review server
Browse files

Merge "SystemUI: Fix cannot switch apn from quick setting"

parents cf00fe6f 17af8e08
Loading
Loading
Loading
Loading
+29 −9
Original line number Diff line number Diff line
@@ -52,6 +52,7 @@ import android.view.View;

import com.android.internal.telephony.MSimConstants;
import com.android.internal.telephony.IccCardConstants;
import com.android.internal.telephony.PhoneConstants;
import com.android.internal.telephony.TelephonyIntents;
import com.android.internal.telephony.TelephonyProperties;
import com.android.internal.view.RotationPolicy;
@@ -111,9 +112,11 @@ class ExtQuickSettingsModel extends QuickSettingsModel {
            // if the given next apn is null, we will use the saved next apn to switch.
            if (apn == null) {
                apn = mNextApn;
            } else {
            }

            // We will only set the prefer apn to the next apn, and then the data base will be
            // changed, so we will update the view when we receive the content changed message.
            if (apn != null) {
                if (DEBUG) Log.i(TAG, "switch to the next apn, and it's id: " + apn.id);
                ContentValues values = new ContentValues();
                values.put(APN_ID, apn.id);
@@ -268,18 +271,35 @@ class ExtQuickSettingsModel extends QuickSettingsModel {
                }
            }

            String property = TelephonyProperties.PROPERTY_APN_SIM_OPERATOR_NUMERIC;
            int dataSub = 0;
            String property = null;
            String mccMncFromSim = null;
            int activePhone = 0;

            if (MSimTelephonyManager.getDefault().isMultiSimEnabled()) {
                MSimTelephonyManager msimTM = (MSimTelephonyManager)
                        mContext.getSystemService(Context.MSIM_TELEPHONY_SERVICE);
                int prefDataSub = msimTM.getPreferredDataSubscription();
                mccMncFromSim =
                    MSimTelephonyManager.getTelephonyProperty(property, prefDataSub, null);
                dataSub = msimTM.getPreferredDataSubscription();
                activePhone = MSimTelephonyManager.getDefault().getPhoneType(dataSub);
            } else {
                dataSub = TelephonyManager.getDefaultSubscription();
                activePhone = TelephonyManager.getDefault().getPhoneType(dataSub);
            }

            if (activePhone == PhoneConstants.PHONE_TYPE_CDMA) {
                property = TelephonyProperties.PROPERTY_APN_RUIM_OPERATOR_NUMERIC;
            } else {
                property = TelephonyProperties.PROPERTY_APN_SIM_OPERATOR_NUMERIC;
            }

            if (MSimTelephonyManager.getDefault().isMultiSimEnabled()) {
                mccMncFromSim = MSimTelephonyManager
                        .getTelephonyProperty(property, dataSub, null);
            } else {
                int defaultSub = TelephonyManager.getDefaultSubscription();
                mccMncFromSim = TelephonyManager.getTelephonyProperty(property, defaultSub, null);
                mccMncFromSim = TelephonyManager
                        .getTelephonyProperty(property, dataSub, null);
            }

            if (mccMncFromSim != null && mccMncFromSim.length() > 0) {
                result.add(mccMncFromSim);
            }
+4 −13
Original line number Diff line number Diff line
@@ -824,21 +824,12 @@ class QuickSettings {
            apnTile.setOnClickListener(new View.OnClickListener() {
                @Override
                public void onClick(View v) {
                    startSettingsActivity(android.provider.Settings.ACTION_APN_SETTINGS);
                }
            });
            if (LONG_PRESS_TOGGLES) {
                apnTile.setOnLongClickListener(new View.OnLongClickListener() {
                    @Override
                    public boolean onLongClick(View v) {
                    if (mModel != null && mModel.getApnState() != null) {
                        mModel.getApnState().switchToNextApn(null);
                    }
                        apnTile.setPressed(false);
                        return true;
                }
            });
            }

            mModel.addApnTile(apnTile, new QuickSettingsModel.RefreshCallback() {
                @Override
                public void refreshView(QuickSettingsTileView view, State state) {