Android Q 默认数据sim卡一可以弹窗,默认使用卡一数据;而卡二关闭不使用
依据客户需求:
开机默认使用卡一数据,即不用做sim卡一还是卡二的弹窗选择,直接默认使用卡一。
subInfoList.get(0);sim卡一
subInfoList.get(1);sim卡二
vendor/mediatek/proprietary/packages/apps/MtkSettings/src/com/android/settings/sim/SimDialogActivity.java
/// M: Add for showing the SIM dialog. @{
// In some case, the SIM dialog should be updated in onNewIntent().
private void showSimDialog(int dialogType) {
switch (dialogType) {
case DATA_PICK:
case CALLS_PICK:
case SMS_PICK:
/// M: For ALPS02463456, activity state is in chaos. @{
if (isFinishing()) {
Log.e(TAG, "Activity is finishing.");
}
/// @}新增判断:
//*/add def sim card 1 for data not close
if (dialogType == DATA_PICK) {// || CALLS_PICK || SMS_PICK
final ArrayList<String> list = new ArrayList<String>();
final SubscriptionManager subscriptionManager = SubscriptionManager.from(this);
final List<SubscriptionInfo> subInfoList =
subscriptionManager.getActiveSubscriptionInfoList(true);
final SubscriptionInfo sir;
sir = subInfoList.get(0);//0 def sim 1
int targetSub = (sir == null
? SubscriptionManager.INVALID_SUBSCRIPTION_ID
: sir.getSubscriptionId());
if (CdmaUtils.isCdmaCardCompetionForData(this)) {
int defaultId = SubscriptionManager
.getDefaultDataSubscriptionId();
Log.d("SIM", "==currnt default subId=====" + defaultId
+ ", targetId=" + targetSub);if (defaultId != targetSub) {
if (TelephonyUtils.isInCall()) {
Toast.makeText(this,
R.string.default_data_switch_err_msg1,
Toast.LENGTH_SHORT).show();
} else {
setDefaultDataSubId(this, targetSub);
}
}
} else {
setDefaultDataSubId(this, targetSub);
}
finish();
break;
}
//*/
mDialog = createDialog(this, dialogType);
mDialog.show();
Log.d(TAG, "show selection dialog=" + mDialog);
/// @}
break;
case PREFERRED_PICK:
/// M: For ALPS02423087, hot plug SIM timing issue. @{
// The sub list may be already changed.
List<SubscriptionInfo> subs = SubscriptionManager.from(this)
.getActiveSubscriptionInfoList(true);
if (subs == null || subs.size() != 1) {
Log.w(TAG, "Subscription count is not 1, skip preferred SIM dialog");
finish();
return;
}
/// @}displayPreferredDialog(getIntent().getIntExtra(PREFERRED_SIM, 0));
break;
case SMS_PICK_FOR_MESSAGE:
/// M: Not support now.
break;
default:
throw new IllegalArgumentException("Invalid dialog type " + dialogType + " sent.");
}}
/// @}
其他安卓版本尽量参考使用!
原文地址:https://blog.csdn.net/qq_46687516/article/details/143689439
免责声明:本站文章内容转载自网络资源,如本站内容侵犯了原著者的合法权益,可联系本站删除。更多内容请关注自学内容网(zxcms.com)!