Commit b24197a8 by zhangchengbo

fix:通过aar接口获取[顺丰app]传递手机号进行掩码操作

parent b2d418fc
...@@ -13,6 +13,7 @@ import android.util.Log ...@@ -13,6 +13,7 @@ import android.util.Log
import androidx.annotation.RequiresApi import androidx.annotation.RequiresApi
import androidx.coordinatorlayout.widget.CoordinatorLayout import androidx.coordinatorlayout.widget.CoordinatorLayout
import androidx.lifecycle.lifecycleScope import androidx.lifecycle.lifecycleScope
import com.android.sfsylibrary.CallHistoryManager
import com.secspace.sms.R import com.secspace.sms.R
import com.secspace.sms.adapters.ConversationsAdapter import com.secspace.sms.adapters.ConversationsAdapter
import com.secspace.sms.adapters.SearchResultsAdapter import com.secspace.sms.adapters.SearchResultsAdapter
...@@ -424,37 +425,54 @@ class MainActivity : SimpleActivity() { ...@@ -424,37 +425,54 @@ class MainActivity : SimpleActivity() {
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.firstOrNull() ?: return//获取第一条未掩码会话 val firstConversation = sortedConversations.firstOrNull() ?: return//获取第一条未掩码会话
// Log.d(TAG, " MainActivity firstConversation() 获取第一条会话 =: ${GsonUtil.parseBeanToJson(firstConversation)}") Log.d(TAG, " MainActivity firstConversation() 获取第一条会话 =: ${GsonUtil.parseBeanToJson(firstConversation)}")
val phoneNumber = firstConversation.title.replace(" ", "") var 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> ->
val listCallRecent: List<RecentCall> = recents.distinctBy { it.phoneNumber }
// Log.d(TAG, "----MainActivity----最近通话记录列表 :${GsonUtil.parseListToJson(listCallRecent)}") val phoneNumberResult = CallHistoryManager.getInstance(this@MainActivity).phoneNumber
val findResult: RecentCall? = listCallRecent.firstOrNull { it.phoneNumber.replace(" ", "") == phoneNumber && it.isShunFeng } if (phoneNumberResult.isNotEmpty()) {
// Log.d(TAG, "----MainActivity----是否从通话记录中查找到电话号Result:${findResult != null}") // Log.d(TAG, "----MainActivity---- phoneNumberResult :$phoneNumberResult")
//从最近通话记录中找到了号码 进行掩码操作 val listResult: List<String> = phoneNumberResult.split(",")
if (findResult != null) { // Log.d(TAG, "----MainActivity---- listResult :$listResult")
PhoneUtils.phoneNumberFormat(phoneNumber) { itNumber -> if (listResult.isNotEmpty()) {
firstConversation.phoneNumber = itNumber for (item in listResult.distinct()) {
firstConversation.isSFNumber = true if (item.length < 11) continue
// Log.d( PhoneUtils.phoneNumberFormat(item) { itNumber ->
// TAG, firstConversation.phoneNumber = itNumber
// "----MainActivity----手机号掩码操作 itNumber:${itNumber} phoneNumber:${firstConversation.phoneNumber} threadId:${firstConversation.threadId} " firstConversation.isSFNumber = true
// ) }
}
CallHistoryManager.getInstance(this@MainActivity).clearPhoneNumber()
}
} else {
RecentsHelper(context = this@MainActivity).getRecentCalls(false, Int.MAX_VALUE) { recents: List<RecentCall> ->
val listCallRecent: List<RecentCall> = recents.distinctBy { it.phoneNumber }
Log.d(TAG, "----MainActivity----最近通话记录列表 :${GsonUtil.parseListToJson(listCallRecent)}")
val findResult: RecentCall? = listCallRecent.firstOrNull { it.phoneNumber.replace(" ", "") == phoneNumber && it.isShunFeng }
Log.d(TAG, "----MainActivity----是否从通话记录中查找到电话号Result:${findResult != null}")
//从最近通话记录中找到了号码 进行掩码操作
if (findResult != null) {
PhoneUtils.phoneNumberFormat(phoneNumber) { itNumber ->
firstConversation.phoneNumber = itNumber
firstConversation.isSFNumber = true
}
} }
} }
} }
} }
//根据最新的短信threadId 获取所有短信列表 取最新一条记录 //根据最新的短信threadId 获取所有短信列表 取最新一条记录
val messages: java.util.ArrayList<Message> = getMessages(firstConversation.threadId, true) val messages: java.util.ArrayList<Message> = getMessages(firstConversation.threadId, true)
// Log.e(TAG, " MainActivity getMessages() 执行查询会话 messages 数据库 =:${GsonUtil.parseListToJson(messages)} ") // Log.e(TAG, " MainActivity getMessages() 执行查询会话 messages 数据库 =:${GsonUtil.parseListToJson(messages)} ")
val lastMsg = messages.last() val lastMsg = messages.last()
firstConversation.snippet = lastMsg.body firstConversation.snippet = lastMsg.body
firstConversation.date = lastMsg.date firstConversation.date = lastMsg.date
Log.e(TAG, " MainActivity getMessages() firstConversation 数据库 =:${GsonUtil.parseBeanToJson(firstConversation)} ")
conversationsDB.insertOrUpdate(firstConversation) conversationsDB.insertOrUpdate(firstConversation)
} }
} }
...@@ -470,7 +488,7 @@ class MainActivity : SimpleActivity() { ...@@ -470,7 +488,7 @@ class MainActivity : SimpleActivity() {
lifecycleScope.launch(Dispatchers.Main) { lifecycleScope.launch(Dispatchers.Main) {
// delay(1_000) // delay(1_000)
// Log.d(TAG, " MainActivity setupConversations() 修改后显示短信列表数据 =: ${GsonUtil.parseListToJson(sortedConversations)}") Log.d(TAG, " MainActivity setupConversations() 修改后显示短信列表数据 =: ${GsonUtil.parseListToJson(sortedConversations)}")
// runOnUiThread { // runOnUiThread {
if (cached && config.appRunCount == 1) { if (cached && config.appRunCount == 1) {
// there are no cached conversations on the first run so we show the loading placeholder and progress until we are done loading from telephony // there are no cached conversations on the first run so we show the loading placeholder and progress until we are done loading from telephony
......
...@@ -125,8 +125,12 @@ abstract class BaseConversationsAdapter( ...@@ -125,8 +125,12 @@ abstract class BaseConversationsAdapter(
conversationFrame.isSelected = selectedKeys.contains(conversation.hashCode()) conversationFrame.isSelected = selectedKeys.contains(conversation.hashCode())
conversationAddress.apply { conversationAddress.apply {
text = conversation.title text = if(conversation.phoneNumber.contains("**")){
// Log.e("shuju", "----BaseAdapter----conversationAddress:${conversation.title} name = $${conversation.phoneNumber}") conversation.phoneNumber
}else {
conversation.title
}
// Log.e("MainActivity", "----BaseAdapter----conversationAddress:${conversation.title} name = ${conversation.phoneNumber}")
setTextSize(TypedValue.COMPLEX_UNIT_PX, fontSize * 1.2f) setTextSize(TypedValue.COMPLEX_UNIT_PX, fontSize * 1.2f)
} }
......
...@@ -8,6 +8,7 @@ import android.database.Cursor ...@@ -8,6 +8,7 @@ import android.database.Cursor
import android.os.Handler import android.os.Handler
import android.os.Looper import android.os.Looper
import android.provider.Telephony import android.provider.Telephony
import com.android.sfsylibrary.CallHistoryManager
import com.secspace.log.Log import com.secspace.log.Log
import com.secspace.sms.extensions.* import com.secspace.sms.extensions.*
import com.secspace.sms.helpers.Config import com.secspace.sms.helpers.Config
...@@ -30,7 +31,6 @@ import com.simplemobiletools.commons.helpers.SimpleContactsHelper ...@@ -30,7 +31,6 @@ import com.simplemobiletools.commons.helpers.SimpleContactsHelper
import com.simplemobiletools.commons.helpers.ensureBackgroundThread import com.simplemobiletools.commons.helpers.ensureBackgroundThread
import com.simplemobiletools.commons.models.PhoneNumber import com.simplemobiletools.commons.models.PhoneNumber
import com.simplemobiletools.commons.models.SimpleContact import com.simplemobiletools.commons.models.SimpleContact
import com.simplemobiletools.commons.util.GsonUtil
class SmsReceiver : BroadcastReceiver() { class SmsReceiver : BroadcastReceiver() {
private val TAG: String = "SmsReceiver" private val TAG: String = "SmsReceiver"
...@@ -231,12 +231,29 @@ class SmsReceiver : BroadcastReceiver() { ...@@ -231,12 +231,29 @@ class SmsReceiver : BroadcastReceiver() {
} }
} }
// Log.d(TAG, "SmsReceiver aesPhoneNumber 手机号是否加密 :${aesPhoneNumber}")
if (aesPhoneNumber.isNotBlank()) { if (aesPhoneNumber.isNotBlank()) {
val tipPopup = MyPushWindow(context, aesPhoneNumber, body) val tipPopup = MyPushWindow(context, aesPhoneNumber, body)
tipPopup.show() tipPopup.show()
} else { } else {
val tipPopup = MyPushWindow(context, address, body) val phoneNumberResult = CallHistoryManager.getInstance(context).phoneNumber
tipPopup.show() // Log.d(TAG, "SmsReceiver phoneNumberResult : $phoneNumberResult")
val listResult: List<String> = phoneNumberResult.split(",")
if (listResult.isNotEmpty()) {
for (item in listResult.distinct()) {
if (item.length < 11) continue
if (item.contains("+86")) {
item.replace("+86", "")
}
PhoneUtils.phoneNumberFormat(item) { itNumber ->
val tipPopup = MyPushWindow(context, itNumber, body)
tipPopup.show()
}
}
} else {
val tipPopup = MyPushWindow(context, address, body)
tipPopup.show()
}
} }
} }
confirmCallBack.invoke() confirmCallBack.invoke()
......
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