微波EDA网,见证研发工程师的成长!
首页 > 研发问答 > 手机设计讨论 > MTK手机平台交流 > SIM卡设置内的卡名称及运营商名称的语言类别随系统语言切换而改变

SIM卡设置内的卡名称及运营商名称的语言类别随系统语言切换而改变

时间:10-02 整理:3721RD 点击:
[DESCRIPTION]
很多客户希望在改变系统语言的时候能够在SIM卡设置里面看到SIM卡信息的语言也发生变化。主要涉及到的两个地方是SIM卡的名称和运营商的名称。
[SOLUTION]
对于SIM卡的名称的改变:
首先一个前提是用户自己去写入的SIM卡名称不可能做到跟随系统的语言切换。我们这边所说的SIM卡名称是系统默认的
SIM卡名称。
系统默认的SIM卡名称获取处有两处,从SIM卡中的EF_SPN文件中读取或者根据MCCMNC来匹配。并且会优先根据MCCMNC进
行匹配,在进行匹配的时候我们就已经针对常见运营商做了多种语言的资源文件。但是只是在开机的时候会去进行一次
匹配,系统语言发生变化时并不会重新改变。为了实现此功能,具体代码修改如下:
1在subscriptionController.java文件内new一个广播,作用是接收
Intent.ACTION_CONFIGURATION_CHANGED广播,然后当前的所有SubscriptionInfo进行重新命名,在
这里就会根据当前的语言环境来设置运营商的名称。设置完之后要把这个值存入数据库:
private BroADCastReceiver mSubReceiver = new BroadcastReceiver() {
public void onReceive(Context context, Intent intent) {
String action = intent.getAction();
List<SubscriptionInfo> newList=getActiveSubscriptionInfoList()
if (action.equals(Intent.ACTION_CONFIGURATION_CHANGED)) {
for(int i=0;I<newList.size();i++){
SubscriptionInfo msubinfo=newList.get(i);
int subId = msubinfo.getSubscriptionId();
int slotId = msubinfo.getSimSlotIndex()
String nameToSet;
String simNumeric=mTelephonyManager.getSimOperatorNumericForSubscription(subId);
String simMvnoName = SpnOverride.getInstance().lookupOperatorNameForDisplayName( subId ,simNumeric,
true, mContext);
String simCarrierName=mTelephonyManager.getSimOperatorNameForSubscription(subId);
if (!TextUtils.isEmpty(simMvnoName)) {
nameToSet = simMvnoName;
} else {
if (!TextUtils.isEmpty(simCarrierName)) {
nameToSet = simCarrierName;
} else {
nameToSet = "CARD " + Integer.toString(slotId + 1);
}
}
setDisplayName(nameToSet,subId);
}
}
}
};
2 在subscriptionController的初始化时注册该广播即在下面的方法:
private SubscriptionController(Context c) {
.
.
.
//注册新广播
IntentFiLTEr mIntentFilter = new IntentFilter(Intent.ACTION_CONFIGURATION_CHANGED) ;
mContext.registerReceiver(mSubReceiver, mIntentFilter);
.
.
.
}
SIM卡设置中对于SIM卡运营商名称的改变:
我们所说的运营商名称是指在用户在设置SIM卡信息的Dialog中的运营商名称
此处的字符串获取方式是调用telephonyManager.getSimOperatorNameForSubscription()方法,这个方法最终获取运营
商名称的来源是SIM卡中的EF_SPN文件,因此不能随系统语言变化而变化。为了实现功能我们在
/packages/apps/Settings/src/com/android/settings/sim/SimSettings.java的createEditDialog函数内,做如下修

1在SimSettings.java的内部类SimPreference中添加一个函数如下:
Public String getOperName(){
final TelephonyManager tm = (TelephonyManager) getActivity().
getSystEMService(Context.TELEPHONY_SERVICE);
String numeric=
tm.getSimOperatorNumericForSubscription(mSubInfoRecord.getSubscriptionId());
String operName = null;
if ((numeric.equals("46000")) || (numeric.equals("46002")) || (numeric.equals("46007"))
|| (numeric.equals("46008"))) {
operName = context.getText(com.mediatek.R.string.oper_long_46000).toString();
} else if ((numeric.equals("46001")) || (numeric.equals("46009"))) {
operName = context.getText(com.mediatek.R.string.oper_long_46001).toString();
} else if ((numeric.equals("46003")) || (numeric.equals("46011"))) {
operName = context.getText(com.mediatek.R.string.oper_long_46003).toString();
} else if (numeric.equals("46601")) {
operName = context.getText(com.mediatek.R.string.oper_long_46601).toString();
} else if (numeric.equals("46692")) {
operName = context.getText(com.mediatek.R.string.oper_long_46692).toString();
} else if (numeric.equals("46697")) {
operName = context.getText(com.mediatek.R.string.oper_long_46697).toString();
} else if (numeric.equals("99998")) {
operName = context.getText(com.mediatek.R.string.oper_long_99998).toString();
} else if (numeric.equals("99999")) {
operName = context.getText(com.mediatek.R.string.oper_long_99999).toString();
}
return operName;
}
2将此函数添加到SimSettings.java的createEditDialog函数内
public void createEditDialog(SimPreference simPref) {
.
.
final TelephonyManager tm =(TelephonyManager)
getActivity().getSystemService(Context.TELEPHONY_SERVICE);
//修改开始
String operName = getOperName();
//会优先赋值operName 给运营商名称。因为operName 会根据语言环境做变化。
if (!TextUtils.isEmpty(operName )) {
simCarrierName = operName ;
} else{
String simCarrierName =
tm.getSimOperatorNameForSubscription(mSubInfoRecord.getSubscriptionId());
}
//修改完毕
TextView carrierView = (TextView) dialogLayout.findViewById(R.id.carrier);
carrierView.setText(!TextUtils.isEmpty(simCarrierName) ? simCarrierName :
getContext().getString(com.android.internal.R.string.unknownName));
.
.
}

Copyright © 2017-2020 微波EDA网 版权所有

网站地图

Top