From 1489be0c64a0f468c9967c1e7250629220d7ce00 Mon Sep 17 00:00:00 2001 From: renhaoting <370797079@qq.com> Date: Tue, 30 Dec 2025 17:35:23 +0800 Subject: [PATCH] =?UTF-8?q?system=20alert=20=E6=9D=83=E9=99=90=20+1?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../main/java/com/remax/notification/NotifyConst.kt | 2 ++ .../controller/NotificationTriggerController.kt | 2 ++ .../notification/newUtil/NotificationRecorder.kt | 11 +++++++++++ .../remax/notification/newUtil/NotificationUtil.kt | 9 ++++++++- 4 files changed, 23 insertions(+), 1 deletion(-) diff --git a/notification/src/main/java/com/remax/notification/NotifyConst.kt b/notification/src/main/java/com/remax/notification/NotifyConst.kt index 99e0724..8e031ca 100644 --- a/notification/src/main/java/com/remax/notification/NotifyConst.kt +++ b/notification/src/main/java/com/remax/notification/NotifyConst.kt @@ -4,5 +4,7 @@ class NotifyConst { companion object { const val MIN_INTERVAL_UNIT = 30 * 1000L + + const val MIN_INTERVAL_SHOW_SYSTEM_ALERT = 600 * 1000L } } \ No newline at end of file diff --git a/notification/src/main/java/com/remax/notification/controller/NotificationTriggerController.kt b/notification/src/main/java/com/remax/notification/controller/NotificationTriggerController.kt index afeae20..a755185 100644 --- a/notification/src/main/java/com/remax/notification/controller/NotificationTriggerController.kt +++ b/notification/src/main/java/com/remax/notification/controller/NotificationTriggerController.kt @@ -505,6 +505,8 @@ object NotificationTriggerController { } }) + + val residentModel = ResidentModelManger().getModel(context) if(context.canSendNotification()){ residentTrack(residentModel) diff --git a/notification/src/main/java/com/remax/notification/newUtil/NotificationRecorder.kt b/notification/src/main/java/com/remax/notification/newUtil/NotificationRecorder.kt index 7653b2a..81cb995 100644 --- a/notification/src/main/java/com/remax/notification/newUtil/NotificationRecorder.kt +++ b/notification/src/main/java/com/remax/notification/newUtil/NotificationRecorder.kt @@ -1,9 +1,12 @@ package com.remax.notification.newUtil +import com.ama.core.architecture.util.DateUtil import com.ama.core.architecture.util.SpUtil +import com.remax.notification.NotifyConst object NotificationRecorder { private val mLastShowTimeMap = mutableMapOf() + private var mLastSystemAlertTimeMs = DateUtil.getCurTimeMs() - NotifyConst.MIN_INTERVAL_SHOW_SYSTEM_ALERT + 20 * 1000 init { mLastShowTimeMap.putAll( SpUtil.instance().getMap(SpUtil.NOTIFI_LAST_NOTIFY_SHOW_MS)) @@ -18,5 +21,13 @@ object NotificationRecorder { return mLastShowTimeMap[notifyType]?: 0L } + fun getLastSystemAlertShowTime(): Long { + return mLastSystemAlertTimeMs + } + + fun setLastSystemAlertShowTime() { + mLastSystemAlertTimeMs = DateUtil.getCurTimeMs() + } + } \ No newline at end of file diff --git a/notification/src/main/java/com/remax/notification/newUtil/NotificationUtil.kt b/notification/src/main/java/com/remax/notification/newUtil/NotificationUtil.kt index fcad099..e398bbb 100644 --- a/notification/src/main/java/com/remax/notification/newUtil/NotificationUtil.kt +++ b/notification/src/main/java/com/remax/notification/newUtil/NotificationUtil.kt @@ -15,6 +15,7 @@ import androidx.core.app.NotificationCompat import androidx.core.app.NotificationManagerCompat import com.ama.core.architecture.BaseApp import com.ama.core.architecture.util.permission.PermissionUtil +import com.remax.notification.NotifyConst class NotificationUtil private constructor() { @@ -492,7 +493,13 @@ class NotificationUtil private constructor() { fun checkOverlayPermission(callback: PermissionUtil.ICallback) { - PermissionUtil.checkPermission(Settings.ACTION_MANAGE_OVERLAY_PERMISSION, callback) + if (!Settings.canDrawOverlays(BaseApp.appContext())) { + if (System.currentTimeMillis() - NotificationRecorder.getLastSystemAlertShowTime() >= NotifyConst.MIN_INTERVAL_SHOW_SYSTEM_ALERT) { + PermissionUtil.checkPermission(Settings.ACTION_MANAGE_OVERLAY_PERMISSION, callback) + NotificationRecorder.setLastSystemAlertShowTime() + } + + } } }