Commit 546a7184 authored by wanglei's avatar wanglei

...

parent ecb1cfcd
......@@ -12,6 +12,7 @@ import com.base.locationsharewhite.fcm.PopupConstObject.popup_battery_interval
import com.base.locationsharewhite.helper.EventUtils
import com.base.locationsharewhite.utils.AppPreferences
import com.base.locationsharewhite.utils.KotlinExt.currentDate
import com.base.locationsharewhite.utils.LogEx
import kotlin.math.absoluteValue
/**
......@@ -22,8 +23,9 @@ class BatteryStatusReceiver() : BroadcastReceiver() {
companion object {
private val TAG = "BatteryStatusReceiver"
fun registerBatteryReceiver(context: Context) {
fun registerBatteryStatusReceiver(context: Context) {
val intentFilter = IntentFilter().apply {
addAction(Intent.ACTION_BATTERY_CHANGED)
}
......@@ -78,12 +80,20 @@ class BatteryStatusReceiver() : BroadcastReceiver() {
val passTime = System.currentTimeMillis() - batteryLastPushTime
val flag2 = batteryLastPushTime == 0L || passTime > interval
val flag = flag1 && flag2
if (!flag) {
EventUtils.event(
"Notification_Error",
"todayBatteryPush=$todayBatteryPush popupBatteryCount=$popupBatteryCount where=$POPUP_WHERE_BATTERY"
"Notification_Error", "todayBatteryPush=$todayBatteryPush " +
"popupBatteryCount=$popupBatteryCount where=$POPUP_WHERE_BATTERY"
)
return flag1 && flag2
LogEx.logDebug(
TAG, "Notification_Error todayBatteryPush=$todayBatteryPush " +
"popupBatteryCount=$popupBatteryCount where=$POPUP_WHERE_BATTERY"
)
}
return flag
}
......
......@@ -11,12 +11,16 @@ import com.base.locationsharewhite.fcm.PopupConstObject.popup_package_interval
import com.base.locationsharewhite.helper.EventUtils
import com.base.locationsharewhite.utils.AppPreferences
import com.base.locationsharewhite.utils.KotlinExt.currentDate
import com.base.locationsharewhite.utils.LogEx
import kotlin.math.E
class PackageStatusReceiver() : BroadcastReceiver() {
companion object {
fun registerBatteryReceiver(context: Context) {
private val TAG = "PackageStatusReceiver"
fun registerPackageStatusReceiver(context: Context) {
val intentFilter = IntentFilter().apply {
addAction(Intent.ACTION_PACKAGE_ADDED)
addAction(Intent.ACTION_PACKAGE_REMOVED)
......@@ -71,11 +75,19 @@ class PackageStatusReceiver() : BroadcastReceiver() {
val passTime = System.currentTimeMillis() - packageLastPushTime
val flag2 = packageLastPushTime == 0L || passTime > interval
val flag = flag1 && flag2
if (!flag) {
EventUtils.event(
"Notification_Error",
"todayPackagePush=$todayPackagePush popupPackageCount=$popupPackageCount where=$POPUP_WHERE_PACKAGE"
"Notification_Error", "todayPackagePush=$todayPackagePush " +
"popupPackageCount=$popupPackageCount where=$POPUP_WHERE_PACKAGE"
)
return flag1 && flag2
LogEx.logDebug(
TAG, "Notification_Error todayPackagePush=$todayPackagePush " +
"popupPackageCount=$popupPackageCount where=$POPUP_WHERE_PACKAGE"
)
}
return flag
}
/**
......
......@@ -13,10 +13,12 @@ import com.base.locationsharewhite.fcm.PopupConstObject.popup_screen_interval
import com.base.locationsharewhite.helper.EventUtils
import com.base.locationsharewhite.utils.AppPreferences
import com.base.locationsharewhite.utils.KotlinExt.currentDate
import com.base.locationsharewhite.utils.LogEx
import java.util.Objects
class ScreenStatusReceiver : BroadcastReceiver() {
override fun onReceive(context: Context, intent: Intent) {
val action = intent.action
when (Objects.requireNonNull<String?>(action)) {
......@@ -40,10 +42,13 @@ class ScreenStatusReceiver : BroadcastReceiver() {
companion object {
private val TAG = "ScreenStatusReceiver"
var isDeviceInteractive: Boolean = true
var isSecureLockActive: Boolean = false
fun setupScreenStatusListener(context: Context) {
fun registerScreenStatusReceiver(context: Context) {
val intentFilter = IntentFilter()
intentFilter.addAction(Intent.ACTION_SCREEN_OFF)
intentFilter.addAction(Intent.ACTION_SCREEN_ON)
......@@ -96,11 +101,20 @@ class ScreenStatusReceiver : BroadcastReceiver() {
val passTime = System.currentTimeMillis() - screenLastPushTime
val flag2 = screenLastPushTime == 0L || passTime > interval
val flag = flag1 && flag2
if (!flag) {
EventUtils.event(
"Notification_Error",
"todayScreenPush=$todayScreenPush popupScreenCount=$popupScreenCount where=$POPUP_WHERE_LOCK"
"Notification_Error", "todayScreenPush=$todayScreenPush " +
"popupScreenCount=$popupScreenCount where=$POPUP_WHERE_LOCK"
)
LogEx.logDebug(
TAG,
"Notification_Error todayScreenPush=$todayScreenPush " +
"popupScreenCount=$popupScreenCount where=$POPUP_WHERE_LOCK"
)
return flag1 && flag2
}
return flag
}
/**
......
......@@ -7,12 +7,12 @@ import android.os.Bundle
import android.text.TextUtils
import com.base.locationsharewhite.ads.AdsConfigBean
import com.base.locationsharewhite.ads.AdsMgr
import com.base.locationsharewhite.bean.ConstObject.topic_number
import com.base.locationsharewhite.fcm.BatteryStatusReceiver
import com.base.locationsharewhite.fcm.PackageStatusReceiver
import com.base.locationsharewhite.fcm.ScreenStatusReceiver
import com.base.locationsharewhite.helper.config.AppConfig
import com.base.locationsharewhite.ui.splash.SplashActivity
import com.base.locationsharewhite.utils.AppPreferences
import com.base.locationsharewhite.utils.KotlinExt.toFormatMinute
import com.base.locationsharewhite.utils.LogEx
import java.util.Locale
import java.util.UUID
......@@ -58,7 +58,7 @@ class MyApplication : Application() {
LogEx.logDebug(TAG, "uuid=${AppPreferences.getInstance().getString("uuid", "")}")
}
fun initApp() {
private fun initApp() {
// FacebookSdk.sdkInitialize(applicationContext)
val topic = AppConfig.packageName + "_push"
LogEx.logDebug(TAG, "topic=${topic}")
......@@ -67,7 +67,11 @@ class MyApplication : Application() {
InstallHelps.init()
initAdSdk()
initLifeListener()
ScreenStatusReceiver.setupScreenStatusListener(this)
ScreenStatusReceiver.registerScreenStatusReceiver(this)
PackageStatusReceiver.registerPackageStatusReceiver(this)
BatteryStatusReceiver.registerBatteryStatusReceiver(this)
}
......
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