Commit 29ee864e authored by Your Name's avatar Your Name

Merge remote-tracking branch 'origin/master'

# Conflicts:
#	app/src/main/java/com/zxdemo/notity/NotificationUtils.kt
parents 470a639f c89d55f4
...@@ -11,6 +11,13 @@ public class Global { ...@@ -11,6 +11,13 @@ public class Global {
public static String FUNCTION_SCREENSHOT = "function_screenshot"; 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 NotificationStayStatus = "NotificationStayStatus";//int
public static String NotificationStayCount = "NotificationStayCount";//int public static String NotificationStayCount = "NotificationStayCount";//int
...@@ -25,4 +32,6 @@ public class Global { ...@@ -25,4 +32,6 @@ public class Global {
public static String lockNotificationStatus = "lockNotificationStatus"; public static String lockNotificationStatus = "lockNotificationStatus";
public static String batteryNotificationStatus = "batteryNotificationStatus"; public static String batteryNotificationStatus = "batteryNotificationStatus";
public static String NotificationInterval = "notificationInterval";
} }
package com.zxdemo.http package com.zxdemo.http
import android.util.Log import android.util.Log
import com.swiftcleaner.chovey.BuildConfig import com.swiftcleaner.chovey.BuildConfig
import com.zxdemo.ZxApplication import com.zxdemo.ZxApplication
...@@ -21,7 +22,6 @@ object ZxHttp { ...@@ -21,7 +22,6 @@ object ZxHttp {
var referrer = "" var referrer = ""
var referrerSp = SpUtils.getInstance().getString("referrer", "") var referrerSp = SpUtils.getInstance().getString("referrer", "")
if (referrerSp.isNotEmpty()) { if (referrerSp.isNotEmpty()) {
// referrer = Base64.getEncoder().encodeToString(referrer.toByteArray())
referrer = android.util.Base64.encodeToString(referrer.toByteArray(), android.util.Base64.DEFAULT) referrer = android.util.Base64.encodeToString(referrer.toByteArray(), android.util.Base64.DEFAULT)
} }
...@@ -85,6 +85,7 @@ object ZxHttp { ...@@ -85,6 +85,7 @@ object ZxHttp {
requestBack.invoke(1) requestBack.invoke(1)
e.printStackTrace() e.printStackTrace()
} }
override fun onResponse(call: Call, response: Response) { override fun onResponse(call: Call, response: Response) {
// 请求成功时的处理逻辑 // 请求成功时的处理逻辑
try { try {
...@@ -115,12 +116,11 @@ object ZxHttp { ...@@ -115,12 +116,11 @@ object ZxHttp {
} }
fun getHttpReportInterface(action: String, value: String, ext: JSONObject?) { fun getHttpReportInterface(action: String, value: String, ext: JSONObject?) {
var bp = DeviceUtils.getConfigParms() val bp = DeviceUtils.getConfigParms()
// val url = "https://rp.swiftdevinc.xyz/jsonsp?pkg=${com.zxdemo.ZxApplication.packname}"
val url = "$REPORT_DOMAIN/jsonsp?pkg=${ZxApplication.packname}" val url = "$REPORT_DOMAIN/jsonsp?pkg=${ZxApplication.packname}"
var json = JSONObject() val json = JSONObject()
json.put("bp", bp) json.put("bp", bp)
var jData = JSONObject() val jData = JSONObject()
jData.put("action", action) jData.put("action", action)
if (value.isNotEmpty()) { if (value.isNotEmpty()) {
jData.put("value", value) jData.put("value", value)
...@@ -130,7 +130,7 @@ object ZxHttp { ...@@ -130,7 +130,7 @@ object ZxHttp {
Log.d("TAG", "getHttpReportInterface: $json") Log.d("TAG", "getHttpReportInterface: $json")
var result = AESUtils.encrypt(json.toString()) val result = AESUtils.encrypt(json.toString())
HttpUtils.postJson(url, result, object : Callback { HttpUtils.postJson(url, result, object : Callback {
override fun onFailure(call: Call, e: IOException) { override fun onFailure(call: Call, e: IOException) {
......
...@@ -6,6 +6,7 @@ import android.content.Intent ...@@ -6,6 +6,7 @@ import android.content.Intent
import android.content.IntentFilter import android.content.IntentFilter
import android.os.Build import android.os.Build
import android.util.Log import android.util.Log
import com.swiftcleaner.chovey.model.bean.Global.NOTIFICATION_WHERE_INSTALL
import com.zxdemo.notity.NotificationUtils import com.zxdemo.notity.NotificationUtils
import com.zxdemo.utils.SpUtils import com.zxdemo.utils.SpUtils
import java.time.LocalDateTime import java.time.LocalDateTime
...@@ -33,28 +34,6 @@ class AppInstallReceiver : BroadcastReceiver() { ...@@ -33,28 +34,6 @@ class AppInstallReceiver : BroadcastReceiver() {
} }
override fun onReceive(context: Context, intent: Intent) { override fun onReceive(context: Context, intent: Intent) {
//获取当前时间和上一次推送的时间 NotificationUtils.sendNotification(context, NOTIFICATION_WHERE_INSTALL)
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"))
)
}
}
} }
} }
...@@ -5,6 +5,8 @@ import android.content.Context ...@@ -5,6 +5,8 @@ import android.content.Context
import android.content.Intent import android.content.Intent
import android.os.BatteryManager import android.os.BatteryManager
import android.util.Log 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.swiftcleaner.chovey.model.bean.Global.batteryNotificationStatus
import com.zxdemo.notity.NotificationUtils import com.zxdemo.notity.NotificationUtils
import com.zxdemo.utils.SpUtils import com.zxdemo.utils.SpUtils
...@@ -34,9 +36,8 @@ class BatteryStatusReceiver() : BroadcastReceiver() { ...@@ -34,9 +36,8 @@ class BatteryStatusReceiver() : BroadcastReceiver() {
&& &&
state == BatteryManager.BATTERY_STATUS_CHARGING state == BatteryManager.BATTERY_STATUS_CHARGING
) { ) {
Log.d("TAG", "onReceive: 电池推送")
if (context != null) { if (context != null) {
NotificationUtils.sendNotification(context, "BatteryStatusReceiver") NotificationUtils.sendNotification(context, NOTIFICATION_WHERE_BATTERY)
} }
} }
} }
......
...@@ -2,10 +2,8 @@ package com.zxdemo.receiver ...@@ -2,10 +2,8 @@ package com.zxdemo.receiver
import android.content.BroadcastReceiver import android.content.BroadcastReceiver
import android.content.Context import android.content.Context
import android.content.Intent import android.content.Intent
import android.util.Log
class FcmReceiver : BroadcastReceiver() { class FcmReceiver : BroadcastReceiver() {
override fun onReceive(context: Context?, intent: Intent?) { override fun onReceive(context: Context?, intent: Intent?) {
Log.d("TAG", "onReceive:$intent ")
} }
} }
\ No newline at end of file
...@@ -6,6 +6,7 @@ import android.content.Intent ...@@ -6,6 +6,7 @@ import android.content.Intent
import android.content.IntentFilter import android.content.IntentFilter
import android.os.Build import android.os.Build
import android.util.Log import android.util.Log
import com.swiftcleaner.chovey.model.bean.Global.NOTIFICATION_WHERE_UNLOCK
import com.swiftcleaner.chovey.model.bean.Global.lockNotificationStatus import com.swiftcleaner.chovey.model.bean.Global.lockNotificationStatus
import com.zxdemo.ZxApplication import com.zxdemo.ZxApplication
import com.zxdemo.notity.NotificationUtils import com.zxdemo.notity.NotificationUtils
...@@ -54,7 +55,7 @@ class UnlockReceiver : BroadcastReceiver() { ...@@ -54,7 +55,7 @@ class UnlockReceiver : BroadcastReceiver() {
//获取当前时间和上一次推送的时间 //获取当前时间和上一次推送的时间
if (lockNotificationStatus == 1 && mIsScreenOn && !isLock) { if (lockNotificationStatus == 1 && mIsScreenOn && !isLock) {
NotificationUtils.sendNotification(ZxApplication.context, "UnlockReceiver") NotificationUtils.sendNotification(ZxApplication.context, NOTIFICATION_WHERE_UNLOCK)
} }
} }
......
package com.zxdemo.service package com.zxdemo.service
import android.util.Log
import android.annotation.SuppressLint
import com.google.firebase.messaging.FirebaseMessagingService import com.google.firebase.messaging.FirebaseMessagingService
import com.google.firebase.messaging.RemoteMessage import com.google.firebase.messaging.RemoteMessage
import com.swiftcleaner.chovey.model.bean.Global.NOTIFICATION_WHERE_FCM
import com.zxdemo.ZxApplication import com.zxdemo.ZxApplication
import com.zxdemo.http.ZxHttp import com.zxdemo.http.ZxHttp
import com.zxdemo.notity.NotificationUtils import com.zxdemo.notity.NotificationUtils
@SuppressLint("MissingFirebaseInstanceTokenRefresh")
class FcmService : FirebaseMessagingService() { class FcmService : FirebaseMessagingService() {
override fun onMessageReceived(message: RemoteMessage) { override fun onMessageReceived(message: RemoteMessage) {
Log.d("TAG", "onMessageReceived: ${message.data}")
ZxHttp.getHttpReportInterface("FCM_Received", "", null) ZxHttp.getHttpReportInterface("FCM_Received", "", null)
NotificationUtils.sendNotification(ZxApplication.context, "FcmService") NotificationUtils.sendNotification(ZxApplication.context, NOTIFICATION_WHERE_FCM)
} }
} }
\ No newline at end of file
package com.zxdemo.utils package com.zxdemo.utils
import android.util.Log 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.isAppInForeground
import com.zxdemo.ZxApplication.Companion.isDeviceLocked import com.zxdemo.ZxApplication.Companion.isDeviceLocked
import com.zxdemo.ZxApplication.Companion.isScreenOn import com.zxdemo.ZxApplication.Companion.isScreenOn
...@@ -31,11 +32,8 @@ object GlobalTimer { ...@@ -31,11 +32,8 @@ object GlobalTimer {
taskTimer = Timer() // 创建新的 Timer 实例 taskTimer = Timer() // 创建新的 Timer 实例
val task = object : TimerTask() { val task = object : TimerTask() {
override fun run() { 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)
} }
} }
taskTimer!!.schedule(task, delay, period) // 调度任务 taskTimer!!.schedule(task, delay, period) // 调度任务
......
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