Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Sign in / Register
Toggle navigation
S
swiftcleanerphonehelper
Project
Project
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
Packages
Packages
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
wanglei
swiftcleanerphonehelper
Commits
b842a838
Commit
b842a838
authored
Dec 20, 2024
by
wanglei
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
...
parent
841b13a2
Hide whitespace changes
Inline
Side-by-side
Showing
8 changed files
with
40 additions
and
47 deletions
+40
-47
Global.java
.../main/java/com/swiftcleaner/chovey/model/bean/Global.java
+9
-0
ZxHttp.kt
app/src/main/java/com/zxdemo/http/ZxHttp.kt
+6
-6
NotificationUtils.kt
app/src/main/java/com/zxdemo/notity/NotificationUtils.kt
+11
-9
AppInstallReceiver.kt
app/src/main/java/com/zxdemo/receiver/AppInstallReceiver.kt
+2
-23
BatteryStatusReceiver.kt
...rc/main/java/com/zxdemo/receiver/BatteryStatusReceiver.kt
+3
-2
UnlockReceiver.kt
app/src/main/java/com/zxdemo/receiver/UnlockReceiver.kt
+2
-1
FcmService.kt
app/src/main/java/com/zxdemo/service/FcmService.kt
+5
-3
GlobalTimer.kt
app/src/main/java/com/zxdemo/utils/GlobalTimer.kt
+2
-3
No files found.
app/src/main/java/com/swiftcleaner/chovey/model/bean/Global.java
View file @
b842a838
...
...
@@ -11,6 +11,13 @@ public class Global {
public
static
String
FUNCTION_SCREENSHOT
=
"function_screenshot"
;
public
static
String
NOTIFICATION_WHERE_UNLOCK
=
"notification_where_unlock"
;
public
static
String
NOTIFICATION_WHERE_FCM
=
"notification_where_fcm"
;
public
static
String
NOTIFICATION_WHERE_INSTALL
=
"notification_where_install"
;
public
static
String
NOTIFICATION_WHERE_TIMBER
=
"notification_where_timber"
;
public
static
String
NOTIFICATION_WHERE_BATTERY
=
"notification_where_battery"
;
//配置
public
static
String
NotificationStayStatus
=
"NotificationStayStatus"
;
//int
public
static
String
NotificationStayCount
=
"NotificationStayCount"
;
//int
...
...
@@ -25,4 +32,6 @@ public class Global {
public
static
String
lockNotificationStatus
=
"lockNotificationStatus"
;
public
static
String
batteryNotificationStatus
=
"batteryNotificationStatus"
;
public
static
String
NotificationInterval
=
"notificationInterval"
;
}
app/src/main/java/com/zxdemo/http/ZxHttp.kt
View file @
b842a838
package
com.zxdemo.http
import
android.util.Log
import
com.swiftcleaner.chovey.BuildConfig
import
com.zxdemo.ZxApplication
...
...
@@ -21,7 +22,6 @@ object ZxHttp {
var
referrer
=
""
var
referrerSp
=
SpUtils
.
getInstance
().
getString
(
"referrer"
,
""
)
if
(
referrerSp
.
isNotEmpty
())
{
// referrer = Base64.getEncoder().encodeToString(referrer.toByteArray())
referrer
=
android
.
util
.
Base64
.
encodeToString
(
referrer
.
toByteArray
(),
android
.
util
.
Base64
.
DEFAULT
)
}
...
...
@@ -85,6 +85,7 @@ object ZxHttp {
requestBack
.
invoke
(
1
)
e
.
printStackTrace
()
}
override
fun
onResponse
(
call
:
Call
,
response
:
Response
)
{
// 请求成功时的处理逻辑
try
{
...
...
@@ -115,12 +116,11 @@ object ZxHttp {
}
fun
getHttpReportInterface
(
action
:
String
,
value
:
String
,
ext
:
JSONObject
?)
{
var
bp
=
DeviceUtils
.
getConfigParms
()
// val url = "https://rp.swiftdevinc.xyz/jsonsp?pkg=${com.zxdemo.ZxApplication.packname}"
val
bp
=
DeviceUtils
.
getConfigParms
()
val
url
=
"$REPORT_DOMAIN/jsonsp?pkg=${ZxApplication.packname}"
va
r
json
=
JSONObject
()
va
l
json
=
JSONObject
()
json
.
put
(
"bp"
,
bp
)
va
r
jData
=
JSONObject
()
va
l
jData
=
JSONObject
()
jData
.
put
(
"action"
,
action
)
if
(
value
.
isNotEmpty
())
{
jData
.
put
(
"value"
,
value
)
...
...
@@ -130,7 +130,7 @@ object ZxHttp {
Log
.
d
(
"TAG"
,
"getHttpReportInterface: $json"
)
va
r
result
=
AESUtils
.
encrypt
(
json
.
toString
())
va
l
result
=
AESUtils
.
encrypt
(
json
.
toString
())
HttpUtils
.
postJson
(
url
,
result
,
object
:
Callback
{
override
fun
onFailure
(
call
:
Call
,
e
:
IOException
)
{
...
...
app/src/main/java/com/zxdemo/notity/NotificationUtils.kt
View file @
b842a838
...
...
@@ -13,7 +13,6 @@ import android.os.HandlerThread
import
android.util.Log
import
android.widget.RemoteViews
import
androidx.core.app.NotificationCompat
import
androidx.core.app.NotificationManagerCompat
import
androidx.core.content.ContextCompat
import
com.swiftcleaner.chovey.R
import
com.swiftcleaner.chovey.model.bean.Global
...
...
@@ -25,17 +24,15 @@ import com.swiftcleaner.chovey.model.bean.Global.FUNCTION_LARGE_FILE
import
com.swiftcleaner.chovey.model.bean.Global.FUNCTION_SCREENSHOT
import
com.swiftcleaner.chovey.model.bean.Global.FUNCTION_SIMILAR_PHOTOS
import
com.swiftcleaner.chovey.model.bean.Global.FUNCTION_WHATS_APP
import
com.swiftcleaner.chovey.model.bean.Global.NotificationInterval
import
com.swiftcleaner.chovey.model.bean.Global.NotificationStayCount
import
com.swiftcleaner.chovey.model.bean.Global.NotificationStayDelay
import
com.swiftcleaner.chovey.model.bean.Global.NotificationStayStatus
import
com.swiftcleaner.chovey.view.MainActivity
import
com.swiftcleaner.chovey.view.activity.StartActivity
import
com.zxdemo.ZxApplication.Companion.isAppInForeground
import
com.zxdemo.ZxApplication.Companion.isDeviceLocked
import
com.zxdemo.ZxApplication.Companion.isScreenOn
import
com.zxdemo.ZxApplication
import
com.zxdemo.admob.ReportAdUtils
import
com.zxdemo.http.ZxHttp
import
com.zxdemo.utils.SpUtils
import
java.util.Random
...
...
@@ -125,15 +122,14 @@ object NotificationUtils {
}
val
actionId
=
nextNotificationId
val
intervalTime
=
System
.
currentTimeMillis
()
-
lastNotificationTime
val
spInterval
=
SpUtils
.
getInstance
().
getInt
(
"NotificationInterval"
,
1
)
val
oneMinute
=
1
*
60
*
1000L
val
intervalTime
=
System
.
currentTimeMillis
()
-
lastNotificationTime
val
spInterval
=
SpUtils
.
getInstance
().
getInt
(
NotificationInterval
,
1
)
Log
.
e
(
"sendNotification"
,
"where=$where actionId=$actionId intervalTime=$intervalTime spInterval=$spInterval"
)
if
(
lastNotificationTime
!=
0L
&&
intervalTime
<
spInterval
*
oneMinute
)
{
return
}
val
bigRemoteViews
=
RemoteViews
(
context
.
packageName
,
R
.
layout
.
notification_common
)
val
smallRemoteViews
=
RemoteViews
(
context
.
packageName
,
R
.
layout
.
notification_common_small
)
var
intentAction
=
""
...
...
@@ -148,6 +144,7 @@ object NotificationUtils {
intentAction
=
Global
.
FUNCTION_CLEAN
}
FUNCTION_APP_MANAGER
->
{
bigRemoteViews
.
setImageViewResource
(
R
.
id
.
iv_icon
,
R
.
mipmap
.
h_appmanager
)
smallRemoteViews
.
setImageViewResource
(
R
.
id
.
iv_icon
,
R
.
mipmap
.
h_appmanager
)
...
...
@@ -157,6 +154,7 @@ object NotificationUtils {
smallRemoteViews
.
setTextViewText
(
R
.
id
.
tv_desc
,
desc
)
intentAction
=
Global
.
FUNCTION_CLEAN
}
FUNCTION_BATTERY
->
{
bigRemoteViews
.
setImageViewResource
(
R
.
id
.
iv_icon
,
R
.
mipmap
.
h_batteryinfo
)
smallRemoteViews
.
setImageViewResource
(
R
.
id
.
iv_icon
,
R
.
mipmap
.
h_batteryinfo
)
...
...
@@ -176,7 +174,8 @@ object NotificationUtils {
smallRemoteViews
.
setTextViewText
(
R
.
id
.
tv_desc
,
desc
)
intentAction
=
Global
.
FUNCTION_CLEAN
}
FUNCTION_WHATS_APP
->
{
FUNCTION_WHATS_APP
->
{
bigRemoteViews
.
setImageViewResource
(
R
.
id
.
iv_icon
,
R
.
mipmap
.
h_whatsapp
)
smallRemoteViews
.
setImageViewResource
(
R
.
id
.
iv_icon
,
R
.
mipmap
.
h_whatsapp
)
...
...
@@ -185,6 +184,7 @@ object NotificationUtils {
smallRemoteViews
.
setTextViewText
(
R
.
id
.
tv_desc
,
desc
)
intentAction
=
Global
.
FUNCTION_CLEAN
}
FUNCTION_APP_PROCESS
->
{
bigRemoteViews
.
setImageViewResource
(
R
.
id
.
iv_icon
,
R
.
mipmap
.
jg__appprocss
)
smallRemoteViews
.
setImageViewResource
(
R
.
id
.
iv_icon
,
R
.
mipmap
.
jg__appprocss
)
...
...
@@ -194,6 +194,7 @@ object NotificationUtils {
smallRemoteViews
.
setTextViewText
(
R
.
id
.
tv_desc
,
desc
)
intentAction
=
Global
.
FUNCTION_CLEAN
}
FUNCTION_SIMILAR_PHOTOS
->
{
bigRemoteViews
.
setImageViewResource
(
R
.
id
.
iv_icon
,
R
.
mipmap
.
h_simiar
)
smallRemoteViews
.
setImageViewResource
(
R
.
id
.
iv_icon
,
R
.
mipmap
.
h_simiar
)
...
...
@@ -203,6 +204,7 @@ object NotificationUtils {
smallRemoteViews
.
setTextViewText
(
R
.
id
.
tv_desc
,
desc
)
intentAction
=
Global
.
FUNCTION_CLEAN
}
FUNCTION_SCREENSHOT
->
{
bigRemoteViews
.
setImageViewResource
(
R
.
id
.
iv_icon
,
R
.
mipmap
.
h_screenshot
)
smallRemoteViews
.
setImageViewResource
(
R
.
id
.
iv_icon
,
R
.
mipmap
.
h_screenshot
)
...
...
@@ -227,7 +229,7 @@ object NotificationUtils {
val
open
=
SpUtils
.
getInstance
().
getInt
(
NotificationStayStatus
,
0
)
if
(
open
==
1
)
{
//
notificationHover(context, intent, bigRemoteViews, smallRemoteViews)
notificationHover
(
context
,
intent
,
bigRemoteViews
,
smallRemoteViews
)
}
else
{
sendNotification
(
context
,
...
...
app/src/main/java/com/zxdemo/receiver/AppInstallReceiver.kt
View file @
b842a838
...
...
@@ -6,6 +6,7 @@ import android.content.Intent
import
android.content.IntentFilter
import
android.os.Build
import
android.util.Log
import
com.swiftcleaner.chovey.model.bean.Global.NOTIFICATION_WHERE_INSTALL
import
com.zxdemo.notity.NotificationUtils
import
com.zxdemo.utils.SpUtils
import
java.time.LocalDateTime
...
...
@@ -33,28 +34,6 @@ class AppInstallReceiver : BroadcastReceiver() {
}
override
fun
onReceive
(
context
:
Context
,
intent
:
Intent
)
{
//获取当前时间和上一次推送的时间
var
current
=
LocalDateTime
.
now
()
val
intervalTime
=
1L
//间隔时间(分钟)
val
lastTime
=
SpUtils
.
getInstance
().
getString
(
"NOTICE_APP_TIME"
,
""
)
var
parsedDateTime
:
LocalDateTime
=
current
if
(
lastTime
!=
""
)
{
parsedDateTime
=
LocalDateTime
.
parse
(
lastTime
,
DateTimeFormatter
.
ofPattern
(
"yyyy-MM-dd HH:mm"
))
}
// 计算两个时间点之间的差异
val
minutesBetween
=
ChronoUnit
.
MINUTES
.
between
(
parsedDateTime
,
current
)
if
(
minutesBetween
>=
intervalTime
||
minutesBetween
.
toInt
()
==
0
)
{
intent
.
action
?.
let
{
Log
.
d
(
"TAG"
,
"onReceive:安装卸载推送 ${intent.action}"
)
NotificationUtils
.
sendNotification
(
context
,
"AppInstallReceiver"
)
SpUtils
.
getInstance
().
putString
(
"NOTICE_APP_TIME"
,
current
.
format
(
DateTimeFormatter
.
ofPattern
(
"yyyy-MM-dd HH:mm"
))
)
}
}
NotificationUtils
.
sendNotification
(
context
,
NOTIFICATION_WHERE_INSTALL
)
}
}
app/src/main/java/com/zxdemo/receiver/BatteryStatusReceiver.kt
View file @
b842a838
...
...
@@ -5,6 +5,8 @@ import android.content.Context
import
android.content.Intent
import
android.os.BatteryManager
import
android.util.Log
import
com.swiftcleaner.chovey.model.bean.Global.NOTIFICATION_WHERE_BATTERY
import
com.swiftcleaner.chovey.model.bean.Global.NOTIFICATION_WHERE_INSTALL
import
com.swiftcleaner.chovey.model.bean.Global.batteryNotificationStatus
import
com.zxdemo.notity.NotificationUtils
import
com.zxdemo.utils.SpUtils
...
...
@@ -34,9 +36,8 @@ class BatteryStatusReceiver() : BroadcastReceiver() {
&&
state
==
BatteryManager
.
BATTERY_STATUS_CHARGING
)
{
Log
.
d
(
"TAG"
,
"onReceive: 电池推送"
)
if
(
context
!=
null
)
{
NotificationUtils
.
sendNotification
(
context
,
"BatteryStatusReceiver"
)
NotificationUtils
.
sendNotification
(
context
,
NOTIFICATION_WHERE_BATTERY
)
}
}
}
...
...
app/src/main/java/com/zxdemo/receiver/UnlockReceiver.kt
View file @
b842a838
...
...
@@ -6,6 +6,7 @@ import android.content.Intent
import
android.content.IntentFilter
import
android.os.Build
import
android.util.Log
import
com.swiftcleaner.chovey.model.bean.Global.NOTIFICATION_WHERE_UNLOCK
import
com.swiftcleaner.chovey.model.bean.Global.lockNotificationStatus
import
com.zxdemo.ZxApplication
import
com.zxdemo.notity.NotificationUtils
...
...
@@ -54,7 +55,7 @@ class UnlockReceiver : BroadcastReceiver() {
//获取当前时间和上一次推送的时间
if
(
lockNotificationStatus
==
1
&&
mIsScreenOn
&&
!
isLock
)
{
NotificationUtils
.
sendNotification
(
ZxApplication
.
context
,
"UnlockReceiver"
)
NotificationUtils
.
sendNotification
(
ZxApplication
.
context
,
NOTIFICATION_WHERE_UNLOCK
)
}
}
...
...
app/src/main/java/com/zxdemo/service/FcmService.kt
View file @
b842a838
package
com.zxdemo.service
import
android.util.Log
import
android.annotation.SuppressLint
import
com.google.firebase.messaging.FirebaseMessagingService
import
com.google.firebase.messaging.RemoteMessage
import
com.swiftcleaner.chovey.model.bean.Global.NOTIFICATION_WHERE_FCM
import
com.zxdemo.ZxApplication
import
com.zxdemo.http.ZxHttp
import
com.zxdemo.notity.NotificationUtils
@SuppressLint
(
"MissingFirebaseInstanceTokenRefresh"
)
class
FcmService
:
FirebaseMessagingService
()
{
override
fun
onMessageReceived
(
message
:
RemoteMessage
)
{
Log
.
d
(
"TAG"
,
"onMessageReceived: ${message.data}"
)
ZxHttp
.
getHttpReportInterface
(
"FCM_Received"
,
""
,
null
)
NotificationUtils
.
sendNotification
(
ZxApplication
.
context
,
"FcmService"
)
NotificationUtils
.
sendNotification
(
ZxApplication
.
context
,
NOTIFICATION_WHERE_FCM
)
}
}
\ No newline at end of file
app/src/main/java/com/zxdemo/utils/GlobalTimer.kt
View file @
b842a838
package
com.zxdemo.utils
import
android.util.Log
import
com.swiftcleaner.chovey.model.bean.Global.NOTIFICATION_WHERE_TIMBER
import
com.zxdemo.ZxApplication.Companion.isAppInForeground
import
com.zxdemo.ZxApplication.Companion.isDeviceLocked
import
com.zxdemo.ZxApplication.Companion.isScreenOn
...
...
@@ -31,10 +32,8 @@ object GlobalTimer {
taskTimer
=
Timer
()
// 创建新的 Timer 实例
val
task
=
object
:
TimerTask
()
{
override
fun
run
()
{
Log
.
d
(
"glc"
,
"Scheduled task is running"
)
Log
.
d
(
"glc"
,
"${!isDeviceLocked} ${!isAppInForeground} $isScreenOn"
)
// 确保设备处于交互状态,未锁定,且应用未暂停
NotificationUtils
.
sendNotification
(
ZxApplication
.
context
,
"GlobalTimer"
)
NotificationUtils
.
sendNotification
(
ZxApplication
.
context
,
NOTIFICATION_WHERE_TIMBER
)
}
}
...
...
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