Commit d6e86db5 authored by wanglei's avatar wanglei

...

parent b80165de
...@@ -167,17 +167,6 @@ ...@@ -167,17 +167,6 @@
<data android:scheme="file" /> <data android:scheme="file" />
</intent-filter> </intent-filter>
</receiver> </receiver>
<receiver
android:name=".fcm.FcmReceiver"
android:exported="true"
android:permission="com.google.android.c2dm.permission.SEND">
<intent-filter>
<action android:name="com.google.firebase.MESSAGING_EVENT" />
<action android:name="com.google.android.c2dm.intent.RECEIVE" />
<category android:name="confine.scream" />
</intent-filter>
</receiver>
<meta-data <meta-data
android:name="com.google.android.gms.ads.APPLICATION_ID" android:name="com.google.android.gms.ads.APPLICATION_ID"
......
...@@ -13,6 +13,9 @@ import androidx.core.app.NotificationCompat ...@@ -13,6 +13,9 @@ import androidx.core.app.NotificationCompat
import androidx.core.graphics.drawable.IconCompat import androidx.core.graphics.drawable.IconCompat
import com.base.locationsharewhite.BuildConfig import com.base.locationsharewhite.BuildConfig
import com.base.locationsharewhite.R import com.base.locationsharewhite.R
import com.base.locationsharewhite.fcm.PopupConstObject.ACTION_COPY_CODE
import com.base.locationsharewhite.fcm.PopupConstObject.ACTION_ENABLE_LOCATION
import com.base.locationsharewhite.fcm.PopupConstObject.ACTION_SHARE_LOCATION
import com.base.locationsharewhite.fcm.PopupConstObject.POPUP_WHERE_BATTERY import com.base.locationsharewhite.fcm.PopupConstObject.POPUP_WHERE_BATTERY
import com.base.locationsharewhite.fcm.PopupConstObject.POPUP_WHERE_FCM import com.base.locationsharewhite.fcm.PopupConstObject.POPUP_WHERE_FCM
import com.base.locationsharewhite.fcm.PopupConstObject.POPUP_WHERE_LOCK import com.base.locationsharewhite.fcm.PopupConstObject.POPUP_WHERE_LOCK
...@@ -22,7 +25,6 @@ import com.base.locationsharewhite.fcm.PopupConstObject.popup_count ...@@ -22,7 +25,6 @@ import com.base.locationsharewhite.fcm.PopupConstObject.popup_count
import com.base.locationsharewhite.fcm.PopupConstObject.popup_end import com.base.locationsharewhite.fcm.PopupConstObject.popup_end
import com.base.locationsharewhite.fcm.PopupConstObject.popup_fcm_interval import com.base.locationsharewhite.fcm.PopupConstObject.popup_fcm_interval
import com.base.locationsharewhite.fcm.PopupConstObject.popup_interval import com.base.locationsharewhite.fcm.PopupConstObject.popup_interval
import com.base.locationsharewhite.fcm.PopupConstObject.popup_lock_interval
import com.base.locationsharewhite.fcm.PopupConstObject.popup_start import com.base.locationsharewhite.fcm.PopupConstObject.popup_start
import com.base.locationsharewhite.fcm.PopupConstObject.popup_status import com.base.locationsharewhite.fcm.PopupConstObject.popup_status
import com.base.locationsharewhite.fcm.PopupConstObject.popup_timer_interval import com.base.locationsharewhite.fcm.PopupConstObject.popup_timer_interval
...@@ -252,7 +254,9 @@ object NotificationUiUtil { ...@@ -252,7 +254,9 @@ object NotificationUiUtil {
} }
val looper_actionId = listOf( val looper_actionId = listOf(
"", ACTION_SHARE_LOCATION,
ACTION_ENABLE_LOCATION,
ACTION_COPY_CODE,
) )
var actionIdList = arrayListOf<String>() var actionIdList = arrayListOf<String>()
......
...@@ -44,7 +44,6 @@ class ScreenStatusReceiver : BroadcastReceiver() { ...@@ -44,7 +44,6 @@ class ScreenStatusReceiver : BroadcastReceiver() {
companion object { companion object {
private val TAG = "ScreenStatusReceiver" private val TAG = "ScreenStatusReceiver"
var isDeviceInteractive: Boolean = true var isDeviceInteractive: Boolean = true
var isSecureLockActive: Boolean = false var isSecureLockActive: Boolean = false
......
package com.base.locationsharewhite.fcm; package com.base.locationsharewhite.fcm
import android.util.Log; import com.base.locationsharewhite.fcm.NotificationUiUtil.sendNotificationIfCan
import com.base.locationsharewhite.fcm.PopupConstObject.timerDelay
import com.base.locationsharewhite.fcm.PopupConstObject.timerInterval
import com.base.locationsharewhite.fcm.PopupConstObject.timerS
import com.base.locationsharewhite.helper.MyApplication
import com.base.locationsharewhite.utils.AppPreferences
import com.base.locationsharewhite.utils.LogEx.logDebug
import java.util.Timer
import java.util.TimerTask
import com.base.locationsharewhite.helper.MyApplication;
import com.base.locationsharewhite.utils.LogEx;
import java.util.Timer; class TimerManager private constructor() {
import java.util.TimerTask;
public class TimerManager { private var taskTimer: Timer? = null
private static TimerManager instance; private var isTaskTimerActive: Boolean = false
private Timer taskTimer;
private boolean isTimerActive;
private TimerManager() { fun scheduleTask(delay: Long, period: Long) {
// 私有构造方法 logDebug("TimerManager", "scheduleTask", false)
} synchronized(TimerManager::class.java) {
ensureTimerIsStopped() // 确保定时器未运行
public static synchronized TimerManager getInstance() { taskTimer = Timer() // 创建新的 Timer 实例
if (instance == null) { val task: TimerTask = object : TimerTask() {
instance = new TimerManager(); override fun run() {
}
return instance;
}
public void scheduleTask(long delay, long period) {
LogEx.INSTANCE.logDebug("TimerManager", "scheduleTask", false);
synchronized (TimerManager.class) {
ensureTimerIsStopped(); // 确保定时器未运行
taskTimer = new Timer(); // 创建新的 Timer 实例
TimerTask task = new TimerTask() {
@Override
public void run() {
Log.d("glc", "Scheduled task is running");
// 确保设备处于交互状态,未锁定,且应用未暂停 // 确保设备处于交互状态,未锁定,且应用未暂停
if (ScreenStatusReceiver.isDeviceInteractive() && if (ScreenStatusReceiver.isDeviceInteractive
!ScreenStatusReceiver.isSecureLockActive() && && !ScreenStatusReceiver.isSecureLockActive
MyApplication.PAUSED_VALUE != 1) { && MyApplication.PAUSED_VALUE != 1
Log.d("glc", "Scheduled task conditions are met"); ) {
NotificationUiUtil.INSTANCE.sendNotificationIfCan(MyApplication.appContext, sendNotificationIfCan(MyApplication.appContext, PopupConstObject.POPUP_WHERE_TIMBER, null)
PopupConstObject.POPUP_WHERE_TIMBER, null);
} }
} }
}; }
taskTimer.schedule(task, delay, period); // 调度任务 taskTimer?.schedule(task, delay, period) // 调度任务
isTimerActive = true; // 设置定时器状态为活跃 isTaskTimerActive = true // 设置定时器状态为活跃
} }
} }
private void ensureTimerIsStopped() { private fun ensureTimerIsStopped() {
if (isTimerActive) { if (isTaskTimerActive) {
if (taskTimer != null) { if (taskTimer != null) {
taskTimer.cancel(); taskTimer?.cancel()
taskTimer.purge(); // 清除所有取消的任务 taskTimer?.purge() // 清除所有取消的任务
} }
isTimerActive = false; // 重置定时器状态 isTaskTimerActive = false // 重置定时器状态
} }
} }
public void stopTaskTimer() { fun stopTaskTimer() {
synchronized (TimerManager.class) { synchronized(TimerManager::class.java) {
ensureTimerIsStopped(); // 停止定时器 ensureTimerIsStopped() // 停止定时器
} }
} }
public boolean isTaskTimerActive() { companion object {
return isTimerActive;
val instance: TimerManager by lazy((LazyThreadSafetyMode.SYNCHRONIZED)) { TimerManager() }
fun changeTimer() {
val timerStatus: Int = AppPreferences.getInstance().getString(timerS, "1").toIntOrNull() ?: 1
if (timerStatus == 0) {
instance.stopTaskTimer()
} else {
val timerDelay: Int = AppPreferences.getInstance().getString(timerDelay, "1").toIntOrNull() ?: 1
val timerInterval: Int = AppPreferences.getInstance().getString(timerInterval, "1").toIntOrNull() ?: 1
val isTaskTimerActive = instance.isTaskTimerActive
if (!isTaskTimerActive) {
instance.scheduleTask(
(timerDelay * 60 * 1000).toLong(),
(timerInterval * 60 * 1000).toLong()
)
}
}
}
} }
} }
\ No newline at end of file
...@@ -3,6 +3,7 @@ package com.base.locationsharewhite.helper ...@@ -3,6 +3,7 @@ package com.base.locationsharewhite.helper
import com.android.installreferrer.api.InstallReferrerClient import com.android.installreferrer.api.InstallReferrerClient
import com.android.installreferrer.api.InstallReferrerStateListener import com.android.installreferrer.api.InstallReferrerStateListener
import com.base.locationsharewhite.BuildConfig import com.base.locationsharewhite.BuildConfig
import com.base.locationsharewhite.fcm.TimerManager
import com.base.locationsharewhite.utils.AppPreferences import com.base.locationsharewhite.utils.AppPreferences
import com.base.locationsharewhite.utils.LogEx import com.base.locationsharewhite.utils.LogEx
import org.json.JSONObject import org.json.JSONObject
...@@ -71,6 +72,7 @@ object InstallHelps { ...@@ -71,6 +72,7 @@ object InstallHelps {
private fun requestCfg() { private fun requestCfg() {
NewComUtils.requestCfg { NewComUtils.requestCfg {
TimerManager.changeTimer()
} }
} }
} }
\ No newline at end of file
...@@ -10,7 +10,9 @@ import com.base.locationsharewhite.ads.AdsMgr ...@@ -10,7 +10,9 @@ import com.base.locationsharewhite.ads.AdsMgr
import com.base.locationsharewhite.fcm.BatteryStatusReceiver import com.base.locationsharewhite.fcm.BatteryStatusReceiver
import com.base.locationsharewhite.fcm.PackageStatusReceiver import com.base.locationsharewhite.fcm.PackageStatusReceiver
import com.base.locationsharewhite.fcm.ScreenStatusReceiver import com.base.locationsharewhite.fcm.ScreenStatusReceiver
import com.base.locationsharewhite.fcm.alarm.AlarmUtils.startAlarm
import com.base.locationsharewhite.helper.config.AppConfig import com.base.locationsharewhite.helper.config.AppConfig
import com.base.locationsharewhite.service.StayJobService.Companion.startJob
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.LogEx import com.base.locationsharewhite.utils.LogEx
...@@ -72,6 +74,8 @@ class MyApplication : Application() { ...@@ -72,6 +74,8 @@ class MyApplication : Application() {
PackageStatusReceiver.registerPackageStatusReceiver(this) PackageStatusReceiver.registerPackageStatusReceiver(this)
BatteryStatusReceiver.registerBatteryStatusReceiver(this) BatteryStatusReceiver.registerBatteryStatusReceiver(this)
startJob()
startAlarm(appContext)
} }
......
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