Commit 504b0350 by zhangchengbo

fix:添加非空判断条件

parent ea77754b
...@@ -413,7 +413,7 @@ class MainActivity : SimpleActivity() { ...@@ -413,7 +413,7 @@ class MainActivity : SimpleActivity() {
// Log.e(TAG, " getNewConversations privateContacts:${GsonUtil.parseListToJson(privateContacts)}") // Log.e(TAG, " getNewConversations privateContacts:${GsonUtil.parseListToJson(privateContacts)}")
//获取系统SMS DB短信列表 //获取系统SMS DB短信列表
val conversations: java.util.ArrayList<Conversation> = getConversations(privateContacts = privateContacts) val conversations: java.util.ArrayList<Conversation> = getConversations(privateContacts = privateContacts)
Log.e(TAG, " getNewConversations 获取系统SMS DB短信列表(脏数据) conversations:${GsonUtil.parseListToJson(conversations)}") Log.e(TAG, " getNewConversations 获取系统SMS DB短信列表(脏数据) conversations:${GsonUtil.parseListToJson(conversations)}")
//通过DB数据与cache对比threadID //通过DB数据与cache对比threadID
conversations.forEach { clonedConversation -> conversations.forEach { clonedConversation ->
...@@ -504,18 +504,19 @@ class MainActivity : SimpleActivity() { ...@@ -504,18 +504,19 @@ class MainActivity : SimpleActivity() {
private fun setFirstConversationAndUpdateData(sortedConversations: ArrayList<Conversation>) { private fun setFirstConversationAndUpdateData(sortedConversations: ArrayList<Conversation>) {
val hasPerMissionResult = this@MainActivity.hasPermission(PERMISSION_READ_CALL_LOG) val hasPerMissionResult = this@MainActivity.hasPermission(PERMISSION_READ_CALL_LOG)
if (hasPerMissionResult && sortedConversations.isNotEmpty()) { if (hasPerMissionResult && sortedConversations.isNotEmpty()) {
val firstConversation = sortedConversations.first()//获取第一条未掩码会话 val firstConversation = sortedConversations.firstOrNull()//获取第一条未掩码会话
Log.d(TAG, " MainActivity firstConversation() 获取第一条会话 =: ${GsonUtil.parseBeanToJson(firstConversation)}") Log.d(TAG, " MainActivity firstConversation() 获取第一条会话 =: ${GsonUtil.parseBeanToJson(firstConversation)}")
if (firstConversation == null) return
val phoneNumber = firstConversation.title.replace(" ", "") val phoneNumber = firstConversation.title.replace(" ", "")
//只针对手机号 //只针对手机号
if (phoneNumber.length != 11 ) return if (phoneNumber.length != 11) return
if (!firstConversation.isSFNumber) { if (!firstConversation.isSFNumber) {
Log.d(TAG, "----MainActivity----获取第一条会话手机号 phoneNumber:$phoneNumber") Log.d(TAG, "----MainActivity----获取第一条会话手机号 phoneNumber:$phoneNumber")
RecentsHelper(context = this@MainActivity).getRecentCalls(false, Int.MAX_VALUE) { recents: List<RecentCall> -> RecentsHelper(context = this@MainActivity).getRecentCalls(false, Int.MAX_VALUE) { recents: List<RecentCall> ->
val listCallRecent: List<RecentCall> = recents.distinctBy { it.phoneNumber } val listCallRecent: List<RecentCall> = recents.distinctBy { it.phoneNumber }
// Log.d(TAG, "----MainActivity----最近通话记录列表 :${GsonUtil.parseListToJson(listCallRecent)}") // Log.d(TAG, "----MainActivity----最近通话记录列表 :${GsonUtil.parseListToJson(listCallRecent)}")
val findResult: RecentCall? = listCallRecent.firstOrNull { it.phoneNumber.replace(" ","") == phoneNumber && it.isShunFeng } val findResult: RecentCall? = listCallRecent.firstOrNull { it.phoneNumber.replace(" ", "") == phoneNumber && it.isShunFeng }
Log.d(TAG, "----MainActivity----是否从通话记录中查找到电话号Result:${findResult != null}") Log.d(TAG, "----MainActivity----是否从通话记录中查找到电话号Result:${findResult != null}")
//从最近通话记录中找到了号码 进行掩码操作 //从最近通话记录中找到了号码 进行掩码操作
if (findResult != null) { if (findResult != null) {
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment