system alert 权限 +1
This commit is contained in:
parent
c050c4b6ba
commit
1489be0c64
|
|
@ -4,5 +4,7 @@ class NotifyConst {
|
||||||
|
|
||||||
companion object {
|
companion object {
|
||||||
const val MIN_INTERVAL_UNIT = 30 * 1000L
|
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)
|
val residentModel = ResidentModelManger().getModel(context)
|
||||||
if(context.canSendNotification()){
|
if(context.canSendNotification()){
|
||||||
residentTrack(residentModel)
|
residentTrack(residentModel)
|
||||||
|
|
|
||||||
|
|
@ -1,9 +1,12 @@
|
||||||
package com.remax.notification.newUtil
|
package com.remax.notification.newUtil
|
||||||
|
|
||||||
|
import com.ama.core.architecture.util.DateUtil
|
||||||
import com.ama.core.architecture.util.SpUtil
|
import com.ama.core.architecture.util.SpUtil
|
||||||
|
import com.remax.notification.NotifyConst
|
||||||
|
|
||||||
object NotificationRecorder {
|
object NotificationRecorder {
|
||||||
private val mLastShowTimeMap = mutableMapOf<String, Long>()
|
private val mLastShowTimeMap = mutableMapOf<String, Long>()
|
||||||
|
private var mLastSystemAlertTimeMs = DateUtil.getCurTimeMs() - NotifyConst.MIN_INTERVAL_SHOW_SYSTEM_ALERT + 20 * 1000
|
||||||
|
|
||||||
init {
|
init {
|
||||||
mLastShowTimeMap.putAll( SpUtil.instance().getMap<String, Long>(SpUtil.NOTIFI_LAST_NOTIFY_SHOW_MS))
|
mLastShowTimeMap.putAll( SpUtil.instance().getMap<String, Long>(SpUtil.NOTIFI_LAST_NOTIFY_SHOW_MS))
|
||||||
|
|
@ -18,5 +21,13 @@ object NotificationRecorder {
|
||||||
return mLastShowTimeMap[notifyType]?: 0L
|
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 androidx.core.app.NotificationManagerCompat
|
||||||
import com.ama.core.architecture.BaseApp
|
import com.ama.core.architecture.BaseApp
|
||||||
import com.ama.core.architecture.util.permission.PermissionUtil
|
import com.ama.core.architecture.util.permission.PermissionUtil
|
||||||
|
import com.remax.notification.NotifyConst
|
||||||
|
|
||||||
class NotificationUtil private constructor() {
|
class NotificationUtil private constructor() {
|
||||||
|
|
||||||
|
|
@ -492,7 +493,13 @@ class NotificationUtil private constructor() {
|
||||||
|
|
||||||
|
|
||||||
fun checkOverlayPermission(callback: PermissionUtil.ICallback) {
|
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