Commit e6018d77 authored by wanglei's avatar wanglei

...

parent 1a8ac8c1
...@@ -21,7 +21,9 @@ object PushManager { ...@@ -21,7 +21,9 @@ object PushManager {
*/ */
fun newUserPush(newUserAvoidTime: Int): Boolean { fun newUserPush(newUserAvoidTime: Int): Boolean {
val firstLaunchTime = FileApp.fContext.queryDataStoreBlock(FIRST_LAUNCH_TIME_KEY, 0L) val firstLaunchTime = FileApp.fContext.queryDataStoreBlock(FIRST_LAUNCH_TIME_KEY, 0L)
val flag = (System.currentTimeMillis() - firstLaunchTime) / 1000 > newUserAvoidTime val haveFirstLaunchTime = (System.currentTimeMillis() - firstLaunchTime) / 1000
LogEx.logDebug(TAG, "haveFirstLaunchTime=$haveFirstLaunchTime newUserAvoidTime=$newUserAvoidTime")
val flag = haveFirstLaunchTime > newUserAvoidTime
return flag return flag
} }
...@@ -31,7 +33,9 @@ object PushManager { ...@@ -31,7 +33,9 @@ object PushManager {
*/ */
fun canPushNextTime(interval: Int): Boolean { fun canPushNextTime(interval: Int): Boolean {
val lastPushTime = FileApp.fContext.queryDataStoreBlock(ALL_LAST_PUSH_TIME, 0) val lastPushTime = FileApp.fContext.queryDataStoreBlock(ALL_LAST_PUSH_TIME, 0)
return (System.currentTimeMillis() - lastPushTime) / 1000 > interval val haveInterval = (System.currentTimeMillis() - lastPushTime) / 1000
LogEx.logDebug(TAG, "haveInterval=$haveInterval interval=$interval")
return haveInterval > interval
} }
/** /**
...@@ -43,17 +47,15 @@ object PushManager { ...@@ -43,17 +47,15 @@ object PushManager {
val pushManagement = ComUtils.getPushConfig() val pushManagement = ComUtils.getPushConfig()
// 新用户是否显示 // 新用户是否显示
val newUserAvoidFlag = newUserPush(pushManagement.newuser_avoid_time) if (!newUserPush(pushManagement.newuser_avoid_time)) {
val newUserLog = "新用户推送 newuser_avoid_time=${pushManagement.newuser_avoid_time} newUserFlag=$newUserAvoidFlag" LogEx.logDebug(TAG, "================================新用户推送拦截===============================")
LogEx.logDebug(TAG, newUserLog) EventHelper.event("pushCircleOrder_isPush", "新用户推送拦截", eventParams = eventParams)
if (!newUserAvoidFlag) {
EventHelper.event("pushCircleOrder_isPush", newUserLog, eventParams = eventParams)
return false return false
} }
// 渠道用户是否推送 // 渠道用户是否推送
if (!UserChancelEx.getUserChancelSwitch(pushManagement.push_show)) { if (!UserChancelEx.getUserChancelSwitch(pushManagement.push_show)) {
LogEx.logDebug(TAG, "渠道用户不推送") LogEx.logDebug(TAG, "================================渠道用户拦截===============================")
EventHelper.event("pushCircleOrder_isPush", "渠道用户不推送", eventParams = eventParams) EventHelper.event("pushCircleOrder_isPush", "渠道用户不推送", eventParams = eventParams)
return false return false
} }
...@@ -61,41 +63,33 @@ object PushManager { ...@@ -61,41 +63,33 @@ object PushManager {
//是否上次推送间隔大于配置间隔 //是否上次推送间隔大于配置间隔
val isOganic = UserChancelEx.isOrganicUser() val isOganic = UserChancelEx.isOrganicUser()
val interval = if (isOganic) pushManagement.o_push_interval else pushManagement.all_push_interval val interval = if (isOganic) pushManagement.o_push_interval else pushManagement.all_push_interval
val intervalFlog = canPushNextTime(interval) if (!canPushNextTime(interval)) {
val intervalLog = "推送总间隔推送 interval=$interval intervalFlog=$intervalFlog" LogEx.logDebug(TAG, "================================总间隔拦截===============================")
LogEx.logDebug(TAG, intervalLog)
if (!intervalFlog) {
EventHelper.event("pushCircleOrder_isPush", intervalLog, eventParams = eventParams)
return false return false
} }
//当前类型通知推送间隔是否大于配置间隔 //当前类型通知推送间隔是否大于配置间隔
val pushCfg: PushCfg? = ComUtils.getPushTypeData(actionId.toString()) if (!actionTypeCanPsh(actionId)) {
val pushInterval = pushCfg?.push_interval ?: 0 LogEx.logDebug(TAG, "================================当前通知类型间隔拦截===============================")
val actionIdIntervalFlag = actionTypeCanPsh(actionId) EventHelper.event("pushCircleOrder_isPush", "当前通知类型间隔拦截", eventParams = eventParams)
val log = "当前通知类型间隔推送 actionId=$actionId pushInterval=$pushInterval actionIdIntervalFlag=$actionIdIntervalFlag"
LogEx.logDebug(TAG, log)
if (!actionIdIntervalFlag) {
EventHelper.event("pushCircleOrder_isPush", log, eventParams = eventParams)
return false return false
} }
//是否在前台推送 //是否在前台推送
if (AppUtils.isAppForeground()) { if (AppUtils.isAppForeground()) {
LogEx.logDebug(TAG, "app在前台不推送") LogEx.logDebug(TAG, "================================app在前台拦截===============================")
EventHelper.event("pushCircleOrder_isPush", "app在前台不推送", eventParams = eventParams) EventHelper.event("pushCircleOrder_isPush", "app在前台拦截", eventParams = eventParams)
return false return false
} }
//进程是否是活的 //进程是否是活的
if (!TextUtils.isEmpty(JinChengCheck.getAliveProcessName(FileApp.fContext))) { if (!TextUtils.isEmpty(JinChengCheck.getAliveProcessName(FileApp.fContext))) {
LogEx.logDebug(TAG, "app当前进程未拉起不推送") LogEx.logDebug(TAG, "================================app当前进程未拉起拦截===============================")
EventHelper.event("pushCircleOrder_isPush", "app当前进程未拉起不推送", eventParams = eventParams) EventHelper.event("pushCircleOrder_isPush", "app当前进程未拉起拦截", eventParams = eventParams)
return false return false
} }
return true return true
} }
...@@ -106,8 +100,9 @@ object PushManager { ...@@ -106,8 +100,9 @@ object PushManager {
val pushCfg: PushCfg? = ComUtils.getPushTypeData(actionId.toString()) val pushCfg: PushCfg? = ComUtils.getPushTypeData(actionId.toString())
val pushInterval = pushCfg?.push_interval ?: 0 val pushInterval = pushCfg?.push_interval ?: 0
val lastTypePushTime = FileApp.fContext.queryDataStoreBlock(createByActionId(actionId), 0L) val lastTypePushTime = FileApp.fContext.queryDataStoreBlock(createByActionId(actionId), 0L)
val actionInterval = (System.currentTimeMillis() - lastTypePushTime) / 1000
return (System.currentTimeMillis() - lastTypePushTime) / 1000 > pushInterval LogEx.logDebug(TAG, "actionId=$actionId actionInterval=$actionInterval pushInterval=$pushInterval")
return actionInterval > pushInterval
} }
} }
\ No newline at end of file
...@@ -350,7 +350,7 @@ object NotificationHelper { ...@@ -350,7 +350,7 @@ object NotificationHelper {
val builder = NotificationCompat.Builder(context, CHANNEL_ID) val builder = NotificationCompat.Builder(context, CHANNEL_ID)
.setSmallIcon(R.drawable.ic_logo24) .setSmallIcon(R.mipmap.logo_small)
.setCustomContentView(remoteViews) .setCustomContentView(remoteViews)
.setCustomBigContentView(remoteViews) .setCustomBigContentView(remoteViews)
.setPriority(NotificationCompat.PRIORITY_HIGH) .setPriority(NotificationCompat.PRIORITY_HIGH)
......
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