From 76c1dee62529ee7d1bc3266d40b2b5748ebd1f1f Mon Sep 17 00:00:00 2001 From: ZhanGSKen Date: Fri, 19 Dec 2025 21:05:42 +0800 Subject: [PATCH] =?UTF-8?q?MainActivity=E6=9C=AC=E5=9C=B0=E6=B6=88?= =?UTF-8?q?=E6=81=AF=E5=8F=91=E9=80=81=E6=95=B4=E7=90=86=E4=B8=AD=E3=80=82?= =?UTF-8?q?=E3=80=82=E3=80=82?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- powerbell/build.properties | 4 +- .../studio/powerbell/MainActivity.java | 57 ++++++++++--------- .../services/ControlCenterService.java | 22 ++----- 3 files changed, 37 insertions(+), 46 deletions(-) diff --git a/powerbell/build.properties b/powerbell/build.properties index e5d3ce7..e70403e 100644 --- a/powerbell/build.properties +++ b/powerbell/build.properties @@ -1,8 +1,8 @@ #Created by .winboll/winboll_app_build.gradle -#Fri Dec 19 12:39:12 GMT 2025 +#Fri Dec 19 12:56:06 GMT 2025 stageCount=10 libraryProject= baseVersion=15.14 publishVersion=15.14.9 -buildCount=46 +buildCount=47 baseBetaVersion=15.14.10 diff --git a/powerbell/src/main/java/cc/winboll/studio/powerbell/MainActivity.java b/powerbell/src/main/java/cc/winboll/studio/powerbell/MainActivity.java index 7b10ec6..2d1ed3f 100644 --- a/powerbell/src/main/java/cc/winboll/studio/powerbell/MainActivity.java +++ b/powerbell/src/main/java/cc/winboll/studio/powerbell/MainActivity.java @@ -2,14 +2,11 @@ package cc.winboll.studio.powerbell; import android.app.Activity; import android.content.Intent; -import android.database.Cursor; import android.graphics.drawable.Drawable; -import android.net.Uri; import android.os.Build; import android.os.Bundle; import android.os.Handler; import android.os.Message; -import android.provider.MediaStore; import android.view.KeyEvent; import android.view.Menu; import android.view.MenuItem; @@ -23,11 +20,13 @@ import cc.winboll.studio.libaes.utils.DevelopUtils; import cc.winboll.studio.libaes.utils.WinBoLLActivityManager; import cc.winboll.studio.libaes.views.ADsBannerView; import cc.winboll.studio.libappbase.LogUtils; +import cc.winboll.studio.libappbase.ToastUtils; import cc.winboll.studio.powerbell.activities.BackgroundSettingsActivity; import cc.winboll.studio.powerbell.activities.BatteryReportActivity; import cc.winboll.studio.powerbell.activities.ClearRecordActivity; import cc.winboll.studio.powerbell.activities.SettingsActivity; import cc.winboll.studio.powerbell.activities.WinBoLLActivity; +import cc.winboll.studio.powerbell.models.AppConfigBean; import cc.winboll.studio.powerbell.models.BackgroundBean; import cc.winboll.studio.powerbell.models.ControlCenterServiceBean; import cc.winboll.studio.powerbell.services.ControlCenterService; @@ -487,9 +486,11 @@ public class MainActivity extends WinBoLLActivity implements MainContentView.OnV } // ======================== 消息发送方法 ======================== - private void notifyServiceAppConfigChange() { + private void notifyServiceAppConfigChange(AppConfigBean configBean) { LogUtils.d(TAG, "notifyServiceAppConfigChange: 通知服务配置变更"); // 预留配置变更通知逻辑 + ToastUtils.show("notifyServiceAppConfigChange"); + ControlCenterService.updateStatus(this, configBean); } // ======================== 静态工具方法 ======================== @@ -510,30 +511,30 @@ public class MainActivity extends WinBoLLActivity implements MainContentView.OnV } // ======================== 辅助工具方法 ======================== - private String getRealPathFromUri(Uri contentUri) { - LogUtils.d(TAG, "getRealPathFromUri: 解析Uri路径,Uri=" + contentUri); - if (contentUri == null) { - LogUtils.e(TAG, "getRealPathFromUri: Uri为空,解析失败"); - return null; - } - String realPath = null; - String[] projection = {MediaStore.MediaColumns.DATA}; - Cursor cursor = getContentResolver().query(contentUri, projection, null, null, null); - if (cursor != null) { - try { - if (cursor.moveToNext()) { - int columnIndex = cursor.getColumnIndex(MediaStore.MediaColumns.DATA); - if (columnIndex > -1) { - realPath = cursor.getString(columnIndex); - } - } - } finally { - cursor.close(); - } - } - LogUtils.d(TAG, "getRealPathFromUri: 解析完成,路径=" + realPath); - return realPath; - } +// private String getRealPathFromUri(Uri contentUri) { +// LogUtils.d(TAG, "getRealPathFromUri: 解析Uri路径,Uri=" + contentUri); +// if (contentUri == null) { +// LogUtils.e(TAG, "getRealPathFromUri: Uri为空,解析失败"); +// return null; +// } +// String realPath = null; +// String[] projection = {MediaStore.MediaColumns.DATA}; +// Cursor cursor = getContentResolver().query(contentUri, projection, null, null, null); +// if (cursor != null) { +// try { +// if (cursor.moveToNext()) { +// int columnIndex = cursor.getColumnIndex(MediaStore.MediaColumns.DATA); +// if (columnIndex > -1) { +// realPath = cursor.getString(columnIndex); +// } +// } +// } finally { +// cursor.close(); +// } +// } +// LogUtils.d(TAG, "getRealPathFromUri: 解析完成,路径=" + realPath); +// return realPath; +// } private APPInfo genDefaultAppInfo() { LogUtils.d(TAG, "genDefaultAppInfo: 生成默认应用信息"); diff --git a/powerbell/src/main/java/cc/winboll/studio/powerbell/services/ControlCenterService.java b/powerbell/src/main/java/cc/winboll/studio/powerbell/services/ControlCenterService.java index bd176fa..bc8106e 100644 --- a/powerbell/src/main/java/cc/winboll/studio/powerbell/services/ControlCenterService.java +++ b/powerbell/src/main/java/cc/winboll/studio/powerbell/services/ControlCenterService.java @@ -19,6 +19,7 @@ import cc.winboll.studio.powerbell.threads.RemindThread; import cc.winboll.studio.powerbell.utils.NotificationManagerUtils; import java.io.Serializable; import java.util.List; +import cc.winboll.studio.powerbell.receivers.ControlCenterServiceReceiver; /** * @Author ZhanGSKen&豆包大模型 @@ -32,8 +33,8 @@ public class ControlCenterService extends Service { public static final String TAG = "ControlCenterService"; // 服务指令Action常量(带包名前缀防冲突) - public static final String ACTION_RESTART_REMIND_THREAD = "cc.winboll.studio.powerbell.action.RESTART_REMIND_THREAD"; - public static final String EXTRA_APP_CONFIG_BEAN = "cc.winboll.studio.powerbell.extra.APP_CONFIG_BEAN"; +// public static final String ACTION_RESTART_REMIND_THREAD = "cc.winboll.studio.powerbell.action.RESTART_REMIND_THREAD"; +// public static final String EXTRA_APP_CONFIG_BEAN = "cc.winboll.studio.powerbell.extra.APP_CONFIG_BEAN"; // 超时/阈值常量 private static final long THREAD_STOP_TIMEOUT = 1000L; @@ -325,21 +326,10 @@ public class ControlCenterService extends Service { } Intent intent = new Intent(context, ControlCenterService.class); - intent.setAction(ACTION_RESTART_REMIND_THREAD); - intent.putExtra(EXTRA_APP_CONFIG_BEAN, (Serializable) configBean); + intent.setAction(ControlCenterServiceReceiver.ACTION_APPCONFIG_CHANGED); + intent.putExtra(ControlCenterServiceReceiver.EXTRA_APP_CONFIG_BEAN, (Serializable) configBean); intent.setPackage(context.getPackageName()); - intent.addFlags(Intent.FLAG_INCLUDE_STOPPED_PACKAGES); - - try { - if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.O) { - context.startForegroundService(intent); - } else { - context.startService(intent); - } - LogUtils.d(TAG, "updateStatus: 配置更新指令发送成功"); - } catch (Exception e) { - LogUtils.e(TAG, "updateStatus: 发送指令异常", e); - } + context.sendBroadcast(intent); } /**