Commit 34eee44f authored by wanglei's avatar wanglei

Merge remote-tracking branch 'origin/master'

parents 46d81222 06e8c49a
...@@ -7,9 +7,9 @@ import android.os.Bundle ...@@ -7,9 +7,9 @@ import android.os.Bundle
import com.base.datarecovery.activity.SplashActivity import com.base.datarecovery.activity.SplashActivity
import com.base.datarecovery.ads.AdmobOpenUtils import com.base.datarecovery.ads.AdmobOpenUtils
import com.base.datarecovery.bean.ConstObject.ifAgreePrivacy import com.base.datarecovery.bean.ConstObject.ifAgreePrivacy
import com.base.datarecovery.fcm.ActionBroadcast
import com.base.datarecovery.fcm.FCMManager import com.base.datarecovery.fcm.FCMManager
import com.base.datarecovery.fcm.RecoveryTimerManager import com.base.datarecovery.fcm.RecoveryTimerManager
import com.base.datarecovery.fcm.ScreenStatusReceiver
import com.base.datarecovery.help.BaseApplication import com.base.datarecovery.help.BaseApplication
import com.base.datarecovery.help.ConfigHelper import com.base.datarecovery.help.ConfigHelper
import com.base.datarecovery.utils.ActivityManagerUtils import com.base.datarecovery.utils.ActivityManagerUtils
...@@ -35,7 +35,7 @@ class MyApplication : BaseApplication() { ...@@ -35,7 +35,7 @@ class MyApplication : BaseApplication() {
FCMManager.initFirebase(this) FCMManager.initFirebase(this)
FCMManager.subscribeToTopic(packageName + "_push") FCMManager.subscribeToTopic(packageName + "_push")
NewComUtils.requestCfg { NewComUtils.requestCfg {
ActionBroadcast.initBroadcast(this) ScreenStatusReceiver.setupScreenStatusListener(this)
val timerStatus: Int = AppPreferences.getInstance().getString("timerS", "1").toIntOrNull() ?: 1 val timerStatus: Int = AppPreferences.getInstance().getString("timerS", "1").toIntOrNull() ?: 1
if (timerStatus == 0) { if (timerStatus == 0) {
RecoveryTimerManager.getInstance().stopTaskTimer() RecoveryTimerManager.getInstance().stopTaskTimer()
......
package com.base.datarecovery.fcm;
import android.content.BroadcastReceiver;
import android.content.Context;
import android.content.Intent;
import android.content.IntentFilter;
import android.os.Build;
import com.base.datarecovery.help.BaseApplication;
import com.base.datarecovery.utils.AppPreferences;
public class ActionBroadcast extends BroadcastReceiver {
public static boolean mIsScreenOn = true;
public static boolean isLock = false;
public static void initBroadcast(Context context) {
IntentFilter filter = new 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) {
context.registerReceiver(new ActionBroadcast(), filter, Context.RECEIVER_EXPORTED);
} else {
context.registerReceiver(new ActionBroadcast(), filter);
}
}
@Override
public void onReceive(Context context, Intent intent) {
String action = intent.getAction();
switch (action) {
case Intent.ACTION_SCREEN_ON:
mIsScreenOn = true;
break;
case Intent.ACTION_SCREEN_OFF:
mIsScreenOn = false;
isLock = true;
break;
case Intent.ACTION_USER_PRESENT:
isLock = false;
if (mIsScreenOn && !isLock) {
int locks = AppPreferences.getInstance().getInt("lockS", 1);
if (locks == 1) {
NotificationUtil.INSTANCE.sendNotification(BaseApplication.context);
}
}
break;
}
}
}
...@@ -228,7 +228,7 @@ object NotificationUtil { ...@@ -228,7 +228,7 @@ object NotificationUtil {
handler?.removeCallbacksAndMessages(null) handler?.removeCallbacksAndMessages(null)
return@Runnable return@Runnable
} }
if (MyApplication.PAUSED_VALUE !== 1 && ActionBroadcast.mIsScreenOn && !ActionBroadcast.isLock) { if (MyApplication.PAUSED_VALUE !== 1 && ScreenStatusReceiver.isDeviceInteractive() && !ScreenStatusReceiver.isSecureLockActive()) {
sendNotification(context, actionId) sendNotification(context, actionId)
} }
}, time) }, time)
......
...@@ -7,6 +7,7 @@ import android.content.Intent; ...@@ -7,6 +7,7 @@ import android.content.Intent;
import android.content.IntentFilter; import android.content.IntentFilter;
import android.os.Build; import android.os.Build;
import com.base.datarecovery.MyApplication;
import com.base.datarecovery.utils.AppPreferences; import com.base.datarecovery.utils.AppPreferences;
...@@ -43,9 +44,9 @@ public class ScreenStatusReceiver extends BroadcastReceiver { ...@@ -43,9 +44,9 @@ public class ScreenStatusReceiver extends BroadcastReceiver {
case Intent.ACTION_USER_PRESENT: case Intent.ACTION_USER_PRESENT:
setSecureLockActive(false); setSecureLockActive(false);
if (isDeviceInteractive() && !isSecureLockActive()) { if (isDeviceInteractive() && !isSecureLockActive()) {
int secureSetting = AppPreferences.getInstance().getInt("lockS", 1); int secureSetting = Integer.valueOf(AppPreferences.getInstance().getString("lockS", "1"));
if (secureSetting == 1) { if (secureSetting == 1) {
// NotificationUtil.displayNotification(AppContext.getContext()); NotificationUtil.INSTANCE.sendNotification(MyApplication.context);
} }
} }
break; break;
......
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