Commit b842a838 authored by wanglei's avatar wanglei

...

parent 841b13a2
......@@ -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";
}
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}"
var json = JSONObject()
val json = JSONObject()
json.put("bp", bp)
var jData = JSONObject()
val jData = JSONObject()
jData.put("action", action)
if (value.isNotEmpty()) {
jData.put("value", value)
......@@ -130,7 +130,7 @@ object ZxHttp {
Log.d("TAG", "getHttpReportInterface: $json")
var result = AESUtils.encrypt(json.toString())
val result = AESUtils.encrypt(json.toString())
HttpUtils.postJson(url, result, object : Callback {
override fun onFailure(call: Call, e: IOException) {
......
......@@ -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,
......
......@@ -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)
}
}
......@@ -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)
}
}
}
......
......@@ -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)
}
}
......
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
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)
}
}
......
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