Commit 546a7184 authored by wanglei's avatar wanglei

...

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