SPN 定制

LA.UM.7.6.2/LINUX/android/frameworks/opt/telephony/src/java/com/android/internal/telephony/uicc/SIMRecords.java 
index d1859ad..492d922 100755
@@ -17,4 +17,5 @@
 package com.android.internal.telephony.uicc;
 
+import android.content.BroadcastReceiver;
 import android.content.Context;
 import android.content.res.Resources;
@@ -26,7 +27,10 @@ import android.telephony.PhoneNumberUtils;
 import android.telephony.Rlog;
 import android.telephony.ServiceState;
+import android.telephony.SubscriptionManager;
 import android.telephony.SmsMessage;
 import android.telephony.SubscriptionInfo;
 import android.text.TextUtils;
+import android.content.Intent;
+import android.content.IntentFilter;
 
 import com.android.internal.telephony.CommandsInterface;
@@ -35,4 +39,5 @@ import com.android.internal.telephony.SmsConstants;
 import com.android.internal.telephony.SubscriptionController;
 import com.android.internal.telephony.gsm.SimTlv;
+import com.android.internal.telephony.uicc.IccCardApplicationStatus.AppState;
 import com.android.internal.telephony.uicc.IccCardApplicationStatus.AppType;
 
@@ -56,4 +61,5 @@ public class SIMRecords extends IccRecords {
     VoiceMailConstants mVmConfig;
 
+    SpnOverride mSpnOverride;
     // ***** Cached SIM State; cleared on channel close
 
@@ -92,4 +98,5 @@ public class SIMRecords extends IccRecords {
         return "SimRecords: " + super.toString()
                 + " mVmConfig" + mVmConfig
+                + " mSpnOverride=" + mSpnOverride
                 + " callForwardingEnabled=" + mCallForwardingStatus
                 + " spnState=" + mSpnState
@@ -169,4 +176,5 @@ public class SIMRecords extends IccRecords {
     // TODO: Possibly move these to IccRecords.java
     private static final int SYSTEM_EVENT_BASE = 0x100;
+    private static final int EVENT_CARRIER_CONFIG_CHANGED = 1 + SYSTEM_EVENT_BASE;
     private static final int EVENT_APP_LOCKED = 2 + SYSTEM_EVENT_BASE;
     private static final int EVENT_APP_NETWORK_LOCKED = 3 + SYSTEM_EVENT_BASE;
@@ -206,5 +214,5 @@ public class SIMRecords extends IccRecords {
 
         mVmConfig = new VoiceMailConstants();
-
+        mSpnOverride = new SpnOverride();
         mRecordsRequested = false;  // No load request is made till SIM ready
         mLockedRecordsReqReason = LOCKED_RECORDS_REQ_REASON_NONE;
@@ -221,6 +229,16 @@ public class SIMRecords extends IccRecords {
         mParentApp.registerForNetworkLocked(this, EVENT_APP_NETWORK_LOCKED, null);
         if (DBG) log("SIMRecords X ctor this=" + this);
+        IntentFilter intentfilter = new IntentFilter();
+        intentfilter.addAction(CarrierConfigManager.ACTION_CARRIER_CONFIG_CHANGED);
+        c.registerReceiver(mReceiver, intentfilter);
     }
-
+    private final BroadcastReceiver mReceiver = new BroadcastReceiver() {
+        @Override
+        public void onReceive(Context context, Intent intent) {
+            if (intent.getAction().equals(CarrierConfigManager.ACTION_CARRIER_CONFIG_CHANGED)) {
+                sendMessage(obtainMessage(EVENT_CARRIER_CONFIG_CHANGED));
+            }
+        }
+    };
     @Override
     public void dispose() {
@@ -1346,5 +1364,8 @@ public class SIMRecords extends IccRecords {
                     }
                     break;
-
+                case EVENT_CARRIER_CONFIG_CHANGED:
+                    Rlog.d(LOG_TAG, "EVENT_CARRIER_CONFIG_CHANGED");
+                    handleCarrierNameOverride();
+                    break;
                 default:
                     super.handleMessage(msg);   // IccRecords handles generic record load responses
@@ -1584,5 +1605,51 @@ public class SIMRecords extends IccRecords {
 
     //***** Private methods
+    private void handleCarrierNameOverride() {
+        CarrierConfigManager configLoader = (CarrierConfigManager)
+                mContext.getSystemService(Context.CARRIER_CONFIG_SERVICE);
+        if (configLoader != null && configLoader.getConfig().getBoolean(
+                CarrierConfigManager.KEY_CARRIER_NAME_OVERRIDE_BOOL)) {
+            String carrierName = configLoader.getConfig().getString(
+                    CarrierConfigManager.KEY_CARRIER_NAME_STRING);
+            setServiceProviderName(carrierName);
+            mTelephonyManager.setSimOperatorNameForPhone(mParentApp.getPhoneId(),
+                    carrierName);
+        } else {
+            setSpnFromConfig(getOperatorNumeric());
+        }
+        setDisplayName();
+    }
+
+    private void setDisplayName() {
+        SubscriptionManager subManager = SubscriptionManager.from(mContext);
+        int[] subId = subManager.getSubId(mParentApp.getPhoneId());
 
+        if ((subId == null) || subId.length <= 0) {
+            log("subId not valid for Phone " + mParentApp.getPhoneId());
+            return;
+        }
+
+        SubscriptionInfo subInfo = subManager.getActiveSubscriptionInfo(subId[0]);
+        if (subInfo != null && subInfo.getNameSource() !=
+                    SubscriptionManager.NAME_SOURCE_USER_INPUT) {
+            CharSequence oldSubName = subInfo.getDisplayName();
+            String newCarrierName = mTelephonyManager.getSimOperatorName(subId[0]);
+
+            if (!TextUtils.isEmpty(newCarrierName) && !newCarrierName.equals(oldSubName)) {
+                log("sim name[" + mParentApp.getPhoneId() + "] = " + newCarrierName);
+                SubscriptionController.getInstance().setDisplayName(newCarrierName, subId[0]);
+            }
+        } else {
+            log("SUB[" + mParentApp.getPhoneId() + "] " + subId[0] + " SubInfo not created yet");
+        }
+    }
+
+    private void setSpnFromConfig(String carrier) {
+        if (mSpnOverride.containsCarrier(carrier)) {
+            setServiceProviderName(mSpnOverride.getSpn(carrier));
+            mTelephonyManager.setSimOperatorNameForPhone(
+                    mParentApp.getPhoneId(), getServiceProviderName());
+        }
+    }
     private void setVoiceMailByCountry (String spn) {
         if (mVmConfig.containsCarrier(spn)) {
@@ -2123,4 +2190,5 @@ public class SIMRecords extends IccRecords {
         super.dump(fd, pw, args);
         pw.println(" mVmConfig=" + mVmConfig);
+        pw.println(" mSpnOverride=" + mSpnOverride);
         pw.println(" mCallForwardingStatus=" + mCallForwardingStatus);
         pw.println(" mSpnState=" + mSpnState);

 LA.UM.7.6.2/LINUX/android/frameworks/opt/telephony/src/java/com/android/internal/telephony/uicc/SpnOverride.java 
new file mode 100644
index 0000000..3a01af6
@@ -0,0 +1,114 @@
+/*
+ * Copyright (C) 2009 The Android Open Source Project
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ *      http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package com.android.internal.telephony.uicc;
+
+import java.io.File;
+import java.io.FileNotFoundException;
+import java.io.FileReader;
+import java.io.IOException;
+import java.util.HashMap;
+
+import org.xmlpull.v1.XmlPullParser;
+import org.xmlpull.v1.XmlPullParserException;
+
+import android.os.Environment;
+import android.telephony.Rlog;
+import android.util.Xml;
+
+import com.android.internal.util.XmlUtils;
+
+public class SpnOverride {
+    private HashMap<String, String> mCarrierSpnMap;
+
+
+    static final String LOG_TAG = "SpnOverride";
+    static final String PARTNER_SPN_OVERRIDE_PATH ="etc/spn-conf.xml";
+    static final String OEM_SPN_OVERRIDE_PATH = "telephony/spn-conf.xml";
+
+    SpnOverride () {
+        mCarrierSpnMap = new HashMap<String, String>();
+        loadSpnOverrides();
+    }
+
+    boolean containsCarrier(String carrier) {
+        return mCarrierSpnMap.containsKey(carrier);
+    }
+
+    String getSpn(String carrier) {
+        return mCarrierSpnMap.get(carrier);
+    }
+
+    private void loadSpnOverrides() {
+        FileReader spnReader;
+
+        File spnFile = new File(Environment.getRootDirectory(),
+                PARTNER_SPN_OVERRIDE_PATH);
+        File oemSpnFile = new File(Environment.getOemDirectory(),
+                OEM_SPN_OVERRIDE_PATH);
+
+        if (oemSpnFile.exists()) {
+            // OEM image exist SPN xml, get the timestamp from OEM & System image for comparison.
+            long oemSpnTime = oemSpnFile.lastModified();
+            long sysSpnTime = spnFile.lastModified();
+            Rlog.d(LOG_TAG, "SPN Timestamp: oemTime = " + oemSpnTime + " sysTime = " + sysSpnTime);
+
+            // To get the newer version of SPN from OEM image
+            if (oemSpnTime > sysSpnTime) {
+                Rlog.d(LOG_TAG, "SPN in OEM image is newer than System image");
+                spnFile = oemSpnFile;
+            }
+        } else {
+            // No SPN in OEM image, so load it from system image.
+            Rlog.d(LOG_TAG, "No SPN in OEM image = " + oemSpnFile.getPath() +
+                " Load SPN from system image");
+        }
+
+        try {
+            spnReader = new FileReader(spnFile);
+        } catch (FileNotFoundException e) {
+            Rlog.w(LOG_TAG, "Can not open " + spnFile.getAbsolutePath());
+            return;
+        }
+
+        try {
+            XmlPullParser parser = Xml.newPullParser();
+            parser.setInput(spnReader);
+
+            XmlUtils.beginDocument(parser, "spnOverrides");
+
+            while (true) {
+                XmlUtils.nextElement(parser);
+
+                String name = parser.getName();
+                if (!"spnOverride".equals(name)) {
+                    break;
+                }
+
+                String numeric = parser.getAttributeValue(null, "numeric");
+                String data    = parser.getAttributeValue(null, "spn");
+
+                mCarrierSpnMap.put(numeric, data);
+            }
+            spnReader.close();
+        } catch (XmlPullParserException e) {
+            Rlog.w(LOG_TAG, "Exception in spn-conf parser " + e);
+        } catch (IOException e) {
+            Rlog.w(LOG_TAG, "Exception in spn-conf parser " + e);
+        }
+    }
+
+}

 LA.UM.7.6.2/LINUX/android/vendor/qcom/proprietary/commonsys/telephony-apps/etc/spn-conf.xml 
index 6eb20b8..631d6ab 100755
@@ -30,3 +30,9 @@
     <spnOverride numeric="45404" spn="Hutchison"  />
     <spnOverride numeric="45406" spn="Smartone"  />
+    <spnOverride numeric="28602" spn="Vodafone Türkiye" />
+    <spnOverride numeric="310340" spn="Limitless Mobile"  />
+    <spnOverride numeric="311170" spn="Tampnet"  />
+    <spnOverride numeric="52015" spn="TOT Mobile" />
+    <spnOverride numeric="61907" spn="QCell"  />
+    <spnOverride numeric="64702" spn="TELCO OI"  />
 </spnOverrides>

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值