修复:v3.0.2来电转发卡槽信息获取失败

This commit is contained in:
pppscn 2022-06-12 16:19:33 +08:00
parent bd4096a072
commit 51e845dcea
2 changed files with 4 additions and 20 deletions

View File

@ -13,7 +13,6 @@ import androidx.work.OneTimeWorkRequestBuilder
import androidx.work.WorkManager
import androidx.work.workDataOf
import com.google.gson.Gson
import com.idormy.sms.forwarder.App
import com.idormy.sms.forwarder.R
import com.idormy.sms.forwarder.entity.CallInfo
import com.idormy.sms.forwarder.entity.MsgInfo
@ -147,22 +146,8 @@ class PhoneStateReceiver : BroadcastReceiver() {
return
}
//获取卡槽信息
if (App.SimInfoList.isEmpty()) {
App.SimInfoList = PhoneUtils.getSimMultiInfo()
}
Log.e(TAG, "SimInfoList = " + App.SimInfoList.toString())
//卡槽id-1=获取失败、0=卡槽1、1=卡槽2
var simSlot = -1
Log.e(TAG, "getSubscriptionId = " + callInfo.simId)
if (callInfo.simId != -1 && App.SimInfoList.isNotEmpty()) {
for (simInfo in App.SimInfoList.values) {
if (simInfo.mSubscriptionId == callInfo.simId) {
simSlot = simInfo.mSimSlotIndex
}
}
}
val simSlot = callInfo.simId
//获取卡槽信息
val simInfo = when (simSlot) {
0 -> "SIM1_" + SettingUtils.extraSim1

View File

@ -218,13 +218,12 @@ class PhoneUtils private constructor() {
val indexViaNumber = if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.N && cursor.getColumnIndex("via_number") != -1) cursor.getColumnIndex("via_number") else -1
var isSimId = false
var indexSimId = -1
if (cursor.getColumnIndex(CallLog.Calls.PHONE_ACCOUNT_ID) != -1
if (cursor.getColumnIndex("simid") != -1) {
indexSimId = cursor.getColumnIndex("simid")
} else if (cursor.getColumnIndex(CallLog.Calls.PHONE_ACCOUNT_ID) != -1
&& Build.VERSION.SDK_INT >= Build.VERSION_CODES.LOLLIPOP
) {
indexSimId = cursor.getColumnIndex(CallLog.Calls.PHONE_ACCOUNT_ID)
} else if (cursor.getColumnIndex("simid") != -1) {
indexSimId = cursor.getColumnIndex("simid")
//isSimId = true
}
do {
val callInfo = CallInfo(