微波EDA网,见证研发工程师的成长!
首页 > 研发问答 > 手机设计讨论 > MTK手机平台交流 > SIM卡设置里面关闭一张卡时如何自动将默认数据,通话,短信切换到另一张卡

SIM卡设置里面关闭一张卡时如何自动将默认数据,通话,短信切换到另一张卡

时间:10-02 整理:3721RD 点击:
[DESCRIPTION]
双卡项目中很多客户希望在关闭一张卡时,自动将默认的数据,通话,短信切换到另一张卡上。
[SOLUTION]
在SIMSettings里关闭一张卡的时候,会调用到DefaultSIMmanagementExt.java文件的
setToClosedSimSlot函数,默认代码这里是空,因此不会做切换,如果客户想要客制化此功能的话,请作如下
修改:
在默认的空函数中添加代码,客户可根据自身项目需要里面三个函数中的任意一个或多个。但是默认通话功能切换对
应的函数有三个,还请注意。
public void setToClosedSimSlot(int simSlot) {
Xlog.d(TAG, "setToClosedSimSlot = " + simSlot);
setToChangeDefaultData(simSlot);
setToChangeDefaultVoice(simSlot);
setToChangeDefaultSMS(simSlot);
}
setToClosedSimSlot
改变默认数据
public void setToChangeDefaultData(int simSlot) {
int subId = 0;
int subId_close;
int subId_t;
int mSubId;
int simCount;
subId_close = subscriptionManager.getSubIdUsingPhoneId(simSlot);
SubscriptionManager subscriptionManager = SubscriptionManager.fROM(mContext);
TelephonyManager mTelephonyManager = TelephonyManager.from(mContext);
subId = subscriptionManager.getDefaultDataSubId();
Log.d(TAG, " setToChangeDefaultData: subId = " + subId + "subId_close=" + subId_close);
if (subId_close != subId) {
return;
}
simCount = mTelephonyManager.getSimCount();
Log.d(TAG, " setToChangeDefaultData: simCount = " + simCount);
for (int i = 0; i < simCount; i++) {
mSubId = subscriptionManager. getSubIdUsingPhoneId(i);
final SubscriptionInfo sir = subscriptionManager.getActiveSubScriptionInfo(mSubId);
if (sir != null) {
subId_t = sir.getSubscriptionId();
Log.d(TAG, " setToChangeDefaultData: sir subId_t = " + subId_t);
if (subId_t != subId) {
subscriptionManager.setDefaultDataSubId(subId_t);
}
}
}
}
//改变默认通话(一共有三个函数和改变默认通话相关)
public void setToChangeDefaultVoice(int simSlot) {
int subId = 0;
int subId_close;
int subId_t;
int mSubId;
int simCount;
subId_close = subscriptionManager.getSubIdUsingPhoneId(simSlot);
SubscriptionManager subscriptionManager = SubscriptionManager.from(mContext);
TelephonyManager mTelephonyManager = TelephonyManager.from(mContext);
subId = subscriptionManager.getDefaultVoiceSubId();
Log.d(TAG, " setToChangeDefaultVoice: subId = " + subId + "subId_close=" +
subId_close);
if (subId_close != subId) {
return;
}
simCount = mTelephonyManager.getSimCount();
Log.d(TAG, " setToChangeDefaultVoice: simCount = " + simCount);
for (int i = 0; i < simCount; i++) {
mSubId = subscriptionManager. getSubIdUsingPhoneId(i);
final SubscriptionInfo sir = subscriptionManager.getActiveSubScriptionInfo(mSubId);
if (sir != null) {
subId_t = sir.getSubscriptionId();
Log.d(TAG, " setToChangeDefaultVoice: sir subId_t = " + subId_t);
if (subId_t != subId) {
PhoneAccountHandle phoneaccounthandle = subScriptionIdToPhoneAccountHandle(subId_t);
setUserSelectedOutgoingPhoneAccount(phoneaccounthandle);
}
}
}
}
//改变默认通话调用到的函数
private PhoneAccountHandle subScriptionIdToPhoneAccountHandle(final int subId){
final Telecommanager telecomManager =telecomManager.from(this);
final Iterator< PhoneAccountHandle > phoneAccounts =
telecomManager.getCallCapablePhoneAccouts().listIterator();
while(phoneAccounts.hasNext()){
final PhoneAccountHandle phoneAccountHandle = phoneAccounts.next();
final PhoneAccount phoneAccount = telecomManager.getPhoneAccount(phoneAccountHandle);
final String phoneAccountId = phoneAccountHandle .getId();
if(phoneAccount.hasCapabilities(phoneAccount.CAPABILITY_SIM_SUBSCRIPTION)
&&TextUtils.isDigitsOnly(phoneAccountId)
&&Integer.parseInt(phoneAccountId)==subId)
return phoneAccountHandle;
}
return null;
}
//改变默认通话调用到的函数
private void setUserSelectedOutgoingPhoneAccount(PhoneAccountHandle phoneAccount){
final TelecomManager telecommanager = TelecomManager.from(this);
telecommanager. setUserSelectedOutgoingPhoneAccount
}
//改变默认短信
public void setToChangeDefaultSMS(int simSlot) {
int subId = 0;
int subId_close;
int subId_t;
int mSubId;
int simCount;
subId_close = subscriptionManager.getSubIdUsingPhoneId(simSlot);
SubscriptionManager subscriptionManager = SubscriptionManager.from(mContext);
TelephonyManager mTelephonyManager = TelephonyManager.from(mContext);
subId = subscriptionManager.getDefaultSmsSubId();
Log.d(TAG, " setToChangeDefaultSMS: subId = " + subId + "subId_close=" + subId_close);
if (subId_close != subId) {
return;
}
simCount = mTelephonyManager.getSimCount();
Log.d(TAG, " setToChangeDefaultSMS: simCount = " + simCount);
for (int i = 0; i < simCount; i++) {
mSubId = subscriptionManager. getSubIdUsingPhoneId(i);
final SubscriptionInfo sir = subscriptionManager.getActiveSubScriptionInfo(mSubId);
if (sir != null) {
subId_t = sir.getSubscriptionId();
Log.d(TAG, " setToChangeDefaultSMS: sir subId_t = " + subId_t);
if (subId_t != subId) {
subscriptionManager.setDefaultSmsSubId(subId_t);
}
}
}
}

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

网站地图

Top