修复服务启动逻辑

This commit is contained in:
2025-12-19 20:42:40 +08:00
parent bea77409a5
commit e967ce5511
2 changed files with 6 additions and 6 deletions

View File

@@ -1,8 +1,8 @@
#Created by .winboll/winboll_app_build.gradle #Created by .winboll/winboll_app_build.gradle
#Fri Dec 19 10:59:14 GMT 2025 #Fri Dec 19 12:39:12 GMT 2025
stageCount=10 stageCount=10
libraryProject= libraryProject=
baseVersion=15.14 baseVersion=15.14
publishVersion=15.14.9 publishVersion=15.14.9
buildCount=44 buildCount=46
baseBetaVersion=15.14.10 baseBetaVersion=15.14.10

View File

@@ -49,8 +49,8 @@ public class ControlCenterService extends Service {
private AppConfigBean mCurrentConfigBean; private AppConfigBean mCurrentConfigBean;
private NotificationMessage mForegroundNotifyMsg; private NotificationMessage mForegroundNotifyMsg;
// 服务状态标记volatile保证多线程可见性 // 服务状态标记volatile保证多线程可见性
private static volatile boolean isServiceRunning; private static volatile boolean isServiceRunning = false;
private static volatile boolean mIsDestroyed; private static volatile boolean mIsDestroyed = true;
// ================================== 服务生命周期方法按执行顺序排列onCreate→onStartCommand→onBind→onDestroy================================= // ================================== 服务生命周期方法按执行顺序排列onCreate→onStartCommand→onBind→onDestroy=================================
@Override @Override
@@ -110,14 +110,14 @@ public class ControlCenterService extends Service {
* 服务核心运行逻辑在onCreate/onStartCommand复用 * 服务核心运行逻辑在onCreate/onStartCommand复用
* 避免重复初始化,保证前台服务优先启动 * 避免重复初始化,保证前台服务优先启动
*/ */
private void runCoreServiceLogic() { private synchronized void runCoreServiceLogic() {
LogUtils.d(TAG, "runCoreServiceLogic: 执行核心逻辑"); LogUtils.d(TAG, "runCoreServiceLogic: 执行核心逻辑");
loadLatestServiceControlConfig(); loadLatestServiceControlConfig();
boolean serviceEnabled = mServiceControlBean != null && mServiceControlBean.isEnableService(); boolean serviceEnabled = mServiceControlBean != null && mServiceControlBean.isEnableService();
LogUtils.d(TAG, "runCoreServiceLogic: 服务启用=" + serviceEnabled + " | 已运行=" + isServiceRunning + " | 已销毁=" + mIsDestroyed); LogUtils.d(TAG, "runCoreServiceLogic: 服务启用=" + serviceEnabled + " | 已运行=" + isServiceRunning + " | 已销毁=" + mIsDestroyed);
if (serviceEnabled && !isServiceRunning && !mIsDestroyed) { if (serviceEnabled && !isServiceRunning) {
isServiceRunning = true; isServiceRunning = true;
mIsDestroyed = false; mIsDestroyed = false;