system alert 权限 +1
This commit is contained in:
parent
c050c4b6ba
commit
1489be0c64
|
|
@ -4,5 +4,7 @@ class NotifyConst {
|
|||
|
||||
companion object {
|
||||
const val MIN_INTERVAL_UNIT = 30 * 1000L
|
||||
|
||||
const val MIN_INTERVAL_SHOW_SYSTEM_ALERT = 600 * 1000L
|
||||
}
|
||||
}
|
||||
|
|
@ -505,6 +505,8 @@ object NotificationTriggerController {
|
|||
}
|
||||
})
|
||||
|
||||
|
||||
|
||||
val residentModel = ResidentModelManger().getModel(context)
|
||||
if(context.canSendNotification()){
|
||||
residentTrack(residentModel)
|
||||
|
|
|
|||
|
|
@ -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<String, Long>()
|
||||
private var mLastSystemAlertTimeMs = DateUtil.getCurTimeMs() - NotifyConst.MIN_INTERVAL_SHOW_SYSTEM_ALERT + 20 * 1000
|
||||
|
||||
init {
|
||||
mLastShowTimeMap.putAll( SpUtil.instance().getMap<String, Long>(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()
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
|
@ -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()
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
|||
Loading…
Reference in New Issue