Commit 3c520af4 authored by wanglei's avatar wanglei

同步代码

parent 894cb1af
...@@ -10,6 +10,7 @@ import android.util.Log ...@@ -10,6 +10,7 @@ import android.util.Log
import com.google.android.gms.ads.MobileAds import com.google.android.gms.ads.MobileAds
import com.google.firebase.FirebaseApp import com.google.firebase.FirebaseApp
import com.base.easyfilemanager.activity.splash.NewSplashActivity import com.base.easyfilemanager.activity.splash.NewSplashActivity
import com.base.easyfilemanager.display.ActionBroadcast.Companion.initBroadcast
import com.base.easyfilemanager.display.fcm.FcmHelper import com.base.easyfilemanager.display.fcm.FcmHelper
import com.base.easyfilemanager.helps.BaseApplication import com.base.easyfilemanager.helps.BaseApplication
import com.base.easyfilemanager.helps.ComUtils.requestCfg import com.base.easyfilemanager.helps.ComUtils.requestCfg
...@@ -72,6 +73,7 @@ class MyApplication : BaseApplication() { ...@@ -72,6 +73,7 @@ class MyApplication : BaseApplication() {
FirebaseApp.initializeApp(this) FirebaseApp.initializeApp(this)
FcmHelper.getToken() FcmHelper.getToken()
FcmHelper.subscribeToTopic() FcmHelper.subscribeToTopic()
context.initBroadcast()
Log.d("MyService", "startService:" + Process.myPid()); Log.d("MyService", "startService:" + Process.myPid());
} }
......
package com.base.easyfilemanager.display
import android.content.BroadcastReceiver
import android.content.Context
import android.content.Intent
import android.content.IntentFilter
import android.os.Build
import android.util.Log
import com.base.easyfilemanager.utils.SPUtils
class ActionBroadcast : BroadcastReceiver() {
private var mIsScreenOn = false
private var isLock = false
companion object {
private val TAG = "ActionBroadcast"
fun Context.initBroadcast() {
val filter = IntentFilter()
filter.addAction(Intent.ACTION_SCREEN_OFF)
filter.addAction(Intent.ACTION_SCREEN_ON)
filter.addAction(Intent.ACTION_USER_PRESENT)
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.TIRAMISU) {
registerReceiver(ActionBroadcast(), filter, Context.RECEIVER_EXPORTED)
} else {
registerReceiver(ActionBroadcast(), filter)
}
}
}
override fun onReceive(context: Context, intent: Intent?) {
val action = intent?.action ?: 0
when (action) {
Intent.ACTION_SCREEN_ON -> {
mIsScreenOn = true
}
Intent.ACTION_SCREEN_OFF -> {
mIsScreenOn = false
isLock = true
}
Intent.ACTION_USER_PRESENT -> {
isLock = false
Log.d("glc", "解锁")
if (mIsScreenOn && !isLock) {
// 展示主动推送
val locks = SPUtils.getInstance().getInt("notification_lockS", 0)
if (locks == 1) {
NotificationUtils.sendTimerPush()
}
}
}
}
}
}
\ No newline at end of file
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