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

Commit 56dbbcf6 authored by xinhe's avatar xinhe Committed by John Huang
Browse files

Unable to send MMS from Bugle accordian release apk

    The root cause is the race condition.SubId is not valid
when OperatorNumeric is tried to be stored.

Bug:18582651
Change-Id: I3a6f91b04fcaf7752b039c9a8ebf696c25de3722
parent 957b01a0
Loading
Loading
Loading
Loading
+3 −0
Original line number Diff line number Diff line
@@ -1480,6 +1480,9 @@ public class PhoneProxy extends Handler implements Phone {
        mActivePhone.unregisterForRadioCapabilityChanged(h);
    }

    public IccCardProxy getPhoneIccCardProxy() {
        return mIccCardProxy;
    }
    public void dump(FileDescriptor fd, PrintWriter pw, String[] args) {
        try {
            ((PhoneBase)mActivePhone).dump(fd, pw, args);
+36 −2
Original line number Diff line number Diff line
@@ -16,6 +16,8 @@

package com.android.internal.telephony;

import static com.android.internal.telephony.TelephonyProperties.PROPERTY_ICC_OPERATOR_ALPHA;

import android.app.PendingIntent;
import android.content.Context;
import android.content.IntentFilter;
@@ -34,6 +36,7 @@ import android.telephony.SubscriptionManager;
import android.telephony.SubscriptionManager.OnSubscriptionsChangedListener;
import android.telephony.TelephonyManager;
import android.text.TextUtils;
import android.util.Log;
import android.util.Pair;
import android.util.TimeUtils;

@@ -44,6 +47,7 @@ import java.util.List;

import com.android.internal.telephony.dataconnection.DcTrackerBase;
import com.android.internal.telephony.uicc.IccCardApplicationStatus.AppState;
import com.android.internal.telephony.uicc.IccCardProxy;
import com.android.internal.telephony.uicc.IccRecords;
import com.android.internal.telephony.uicc.UiccCardApplication;
import com.android.internal.telephony.uicc.UiccController;
@@ -230,10 +234,40 @@ public abstract class ServiceStateTracker extends Handler {
        public void onSubscriptionsChanged() {
            if (DBG) log("SubscriptionListener.onSubscriptionInfoChanged");
            // Set the network type, in case the radio does not restore it.
            if (mPhoneBase.getSubId() != SubscriptionManager.INVALID_SUBSCRIPTION_ID) {
            int subId = mPhoneBase.getSubId();
            if (SubscriptionManager.isValidSubId(subId)) {
                int networkType = PhoneFactory.calculatePreferredNetworkType(
                        mPhoneBase.getContext(), mPhoneBase.getSubId());
                        mPhoneBase.getContext(), subId);
                mCi.setPreferredNetworkType(networkType, null);

                //store OperatorNumeric in case subId is not valid when EVENT_RECORDS_LOADED issued
                int phoneId = mPhoneBase.getPhoneId();
                PhoneProxy[] phoneProxys = (PhoneProxy[]) PhoneFactory.getPhones();
                if(phoneProxys != null && phoneProxys.length > phoneId) {
                    PhoneProxy phoneProxy = phoneProxys[phoneId];
                    if(phoneProxy != null) {
                        IccCardProxy iccCardProxy = phoneProxy.getPhoneIccCardProxy();
                        if(iccCardProxy != null) {
                            iccCardProxy.saveOperatorNumeric();
                            // store alpha
                            if(iccCardProxy.getIccRecord() != null) {
                                TelephonyManager.setTelephonyProperty(phoneId,
                                        PROPERTY_ICC_OPERATOR_ALPHA,
                                        iccCardProxy.getIccRecord().getServiceProviderName());
                            } else {
                                Log.e(LOG_TAG,"IccRecord is null");
                            }
                        } else {
                            Log.e(LOG_TAG,"iccCardProxy is null");
                        }
                    }else {
                        Log.e(LOG_TAG, "Null phoneProxy");
                    }
                } else {
                    Log.e(LOG_TAG, "invalid phoneProxy[] or PhoneId" + phoneId);
                }
                mPhoneBase.setSystemProperty(TelephonyProperties.PROPERTY_DATA_NETWORK_TYPE,
                    ServiceState.rilRadioTechnologyToString(mSS.getRilDataRadioTechnology()));
            }
        }
    };
+29 −16
Original line number Diff line number Diff line
@@ -224,6 +224,28 @@ public class IccCardProxy extends Handler implements IccCard {
        }
    }

    public void saveOperatorNumeric() {
        if (mIccRecords != null) {
            String operator = mIccRecords.getOperatorNumeric();
            int slotId = mCardIndex;

            log("operator=" + operator + " slotId=" + slotId);
            if (operator != null) {
                log("update icc_operator_numeric=" + operator);
                setSystemProperty(PROPERTY_ICC_OPERATOR_NUMERIC, slotId, operator);
                String countryCode = operator.substring(0,3);
                if (countryCode != null) {
                    setSystemProperty(PROPERTY_ICC_OPERATOR_ISO_COUNTRY, slotId,
                            MccTable.countryCodeForMcc(Integer.parseInt(countryCode)));
                } else {
                    loge("EVENT_RECORDS_LOADED Country code is null");
                }
            } else {
                loge("EVENT_RECORDS_LOADED Operator name is null");
            }
        }
    }

    @Override
    public void handleMessage(Message msg) {
        switch (msg.what) {
@@ -256,22 +278,10 @@ public class IccCardProxy extends Handler implements IccCard {
                break;
            case EVENT_RECORDS_LOADED:
                if (mIccRecords != null) {
                    saveOperatorNumeric();
                    String operator = mIccRecords.getOperatorNumeric();
                    int slotId = mCardIndex;

                    log("operator=" + operator + " slotId=" + slotId);

                    if(operator != null) {
                        log("update icc_operator_numeric=" + operator);
                        setSystemProperty(PROPERTY_ICC_OPERATOR_NUMERIC, slotId, operator);
                        String countryCode = operator.substring(0,3);
                        if (countryCode != null) {
                            setSystemProperty(PROPERTY_ICC_OPERATOR_ISO_COUNTRY, slotId,
                                    MccTable.countryCodeForMcc(Integer.parseInt(countryCode)));
                        } else {
                            loge("EVENT_RECORDS_LOADED Country code is null");
                        }

                        int slotId = mCardIndex;
                        int[] subId = SubscriptionController.getInstance().getSubId(slotId);
                        if (subId != null) {
                            // Update MCC MNC device configuration information only for default sub.
@@ -894,6 +904,9 @@ public class IccCardProxy extends Handler implements IccCard {
        }
    }

    public IccRecords getIccRecord() {
        return mIccRecords;
    }
    private void log(String s) {
        Rlog.d(LOG_TAG, s);
    }