自动填充卡槽信息到SIM1备注/SIM2备注(Android 8.0 以下)

This commit is contained in:
pppscn 2021-03-11 09:18:07 +08:00
parent f79d7cee62
commit b80467f54a
4 changed files with 32 additions and 5 deletions

View File

@ -30,7 +30,6 @@
<category android:name="android.intent.category.LAUNCHER" />
</intent-filter>
</activity>
<activity
android:name=".AboutActivity"
android:label="关于" />

View File

@ -66,7 +66,12 @@ public class SettingUtil {
}
public static String getAddExtraSim1() {
return sp_setting.getString(Define.SP_MSG_KEY_STRING_ADD_EXTRA_SIM1, "");
String res = sp_setting.getString(Define.SP_MSG_KEY_STRING_ADD_EXTRA_SIM1, "");
Log.d(TAG, "res=" + res);
if (res == null || res.equals("")) {
res = SimUtil.getSimExtra(1);
}
return res;
}
public static void setAddExtraSim1(String sim1) {
@ -77,7 +82,11 @@ public class SettingUtil {
}
public static String getAddExtraSim2() {
return sp_setting.getString(Define.SP_MSG_KEY_STRING_ADD_EXTRA_SIM2, "");
String res = sp_setting.getString(Define.SP_MSG_KEY_STRING_ADD_EXTRA_SIM2, "");
if (res == null || res.equals("")) {
res = SimUtil.getSimExtra(2);
}
return res;
}
public static void setAddExtraSim2(String sim2) {

View File

@ -82,4 +82,23 @@ public class SimUtil {
//Toast.makeText(MainActivity.this, "获取SIM卡信息失败请先手动设置", Toast.LENGTH_LONG).show();
}
}
//获取卡槽备注
public static String getSimExtra(int simId) {
String res = "";
try {
for (Map.Entry<String, Map> entry : MyApplication.SimInfo.entrySet()) {
Map<String, String> sim = entry.getValue();
int sim_id = Integer.parseInt(sim.get("sim_id")) + 1;
if (sim_id == simId) {
res = sim.get("carrier_name") + "_" + sim.get("phone_number");
break;
}
}
} catch (Exception e) {
Log.d(TAG, "getSimExtra Fail: " + e.getMessage());
}
return res;
}
}

View File

@ -59,7 +59,7 @@
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:gravity="end"
android:text="运营商-手机号"
android:text="运营商_手机号"
android:textSize="9dp" />
</LinearLayout>
@ -98,7 +98,7 @@
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:gravity="end"
android:text="运营商-手机号"
android:text="运营商_手机号"
android:textSize="9dp" />
</LinearLayout>