Skip to content
Projects
Groups
Snippets
Help
This project
Loading...
Sign in / Register
Toggle navigation
S
Simple-Sms
Project
Overview
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
zhangchengbo
Simple-Sms
Commits
b24197a8
Commit
b24197a8
authored
Jul 30, 2025
by
zhangchengbo
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
fix:通过aar接口获取[顺丰app]传递手机号进行掩码操作
parent
b2d418fc
Show whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
52 additions
and
13 deletions
+52
-13
MainActivity.kt
...c/main/kotlin/com/secspace/sms/activities/MainActivity.kt
+28
-10
BaseConversationsAdapter.kt
...lin/com/secspace/sms/adapters/BaseConversationsAdapter.kt
+6
-2
SmsReceiver.kt
...src/main/kotlin/com/secspace/sms/receivers/SmsReceiver.kt
+18
-1
No files found.
app/src/main/kotlin/com/secspace/sms/activities/MainActivity.kt
View file @
b24197a8
...
@@ -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)}"
)
va
l
phoneNumber
=
firstConversation
.
title
.
replace
(
" "
,
""
)
va
r
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")
val
phoneNumberResult
=
CallHistoryManager
.
getInstance
(
this
@MainActivity
).
phoneNumber
if
(
phoneNumberResult
.
isNotEmpty
())
{
// Log.d(TAG, "----MainActivity---- phoneNumberResult :$phoneNumberResult")
val
listResult
:
List
<
String
>
=
phoneNumberResult
.
split
(
","
)
// Log.d(TAG, "----MainActivity---- listResult :$listResult")
if
(
listResult
.
isNotEmpty
())
{
for
(
item
in
listResult
.
distinct
())
{
if
(
item
.
length
<
11
)
continue
PhoneUtils
.
phoneNumberFormat
(
item
)
{
itNumber
->
firstConversation
.
phoneNumber
=
itNumber
firstConversation
.
isSFNumber
=
true
}
}
CallHistoryManager
.
getInstance
(
this
@MainActivity
).
clearPhoneNumber
()
}
}
else
{
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
)
{
PhoneUtils
.
phoneNumberFormat
(
phoneNumber
)
{
itNumber
->
PhoneUtils
.
phoneNumberFormat
(
phoneNumber
)
{
itNumber
->
firstConversation
.
phoneNumber
=
itNumber
firstConversation
.
phoneNumber
=
itNumber
firstConversation
.
isSFNumber
=
true
firstConversation
.
isSFNumber
=
true
// Log.d(
// TAG,
// "----MainActivity----手机号掩码操作 itNumber:${itNumber} phoneNumber:${firstConversation.phoneNumber} threadId:${firstConversation.threadId} "
// )
}
}
}
}
}
}
}
}
}
//根据最新的短信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
...
...
app/src/main/kotlin/com/secspace/sms/adapters/BaseConversationsAdapter.kt
View file @
b24197a8
...
@@ -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
)
}
}
...
...
app/src/main/kotlin/com/secspace/sms/receivers/SmsReceiver.kt
View file @
b24197a8
...
@@ -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,14 +231,31 @@ class SmsReceiver : BroadcastReceiver() {
...
@@ -231,14 +231,31 @@ 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
phoneNumberResult
=
CallHistoryManager
.
getInstance
(
context
).
phoneNumber
// 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
)
val
tipPopup
=
MyPushWindow
(
context
,
address
,
body
)
tipPopup
.
show
()
tipPopup
.
show
()
}
}
}
}
}
confirmCallBack
.
invoke
()
confirmCallBack
.
invoke
()
}
}
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment