MainActivity本地消息发送整理中。。。

This commit is contained in:
2025-12-19 21:05:42 +08:00
parent e967ce5511
commit 76c1dee625
3 changed files with 37 additions and 46 deletions

View File

@@ -1,8 +1,8 @@
#Created by .winboll/winboll_app_build.gradle #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 stageCount=10
libraryProject= libraryProject=
baseVersion=15.14 baseVersion=15.14
publishVersion=15.14.9 publishVersion=15.14.9
buildCount=46 buildCount=47
baseBetaVersion=15.14.10 baseBetaVersion=15.14.10

View File

@@ -2,14 +2,11 @@ package cc.winboll.studio.powerbell;
import android.app.Activity; import android.app.Activity;
import android.content.Intent; import android.content.Intent;
import android.database.Cursor;
import android.graphics.drawable.Drawable; import android.graphics.drawable.Drawable;
import android.net.Uri;
import android.os.Build; import android.os.Build;
import android.os.Bundle; import android.os.Bundle;
import android.os.Handler; import android.os.Handler;
import android.os.Message; import android.os.Message;
import android.provider.MediaStore;
import android.view.KeyEvent; import android.view.KeyEvent;
import android.view.Menu; import android.view.Menu;
import android.view.MenuItem; 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.utils.WinBoLLActivityManager;
import cc.winboll.studio.libaes.views.ADsBannerView; import cc.winboll.studio.libaes.views.ADsBannerView;
import cc.winboll.studio.libappbase.LogUtils; 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.BackgroundSettingsActivity;
import cc.winboll.studio.powerbell.activities.BatteryReportActivity; import cc.winboll.studio.powerbell.activities.BatteryReportActivity;
import cc.winboll.studio.powerbell.activities.ClearRecordActivity; import cc.winboll.studio.powerbell.activities.ClearRecordActivity;
import cc.winboll.studio.powerbell.activities.SettingsActivity; import cc.winboll.studio.powerbell.activities.SettingsActivity;
import cc.winboll.studio.powerbell.activities.WinBoLLActivity; 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.BackgroundBean;
import cc.winboll.studio.powerbell.models.ControlCenterServiceBean; import cc.winboll.studio.powerbell.models.ControlCenterServiceBean;
import cc.winboll.studio.powerbell.services.ControlCenterService; 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: 通知服务配置变更"); 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) { // private String getRealPathFromUri(Uri contentUri) {
LogUtils.d(TAG, "getRealPathFromUri: 解析Uri路径Uri=" + contentUri); // LogUtils.d(TAG, "getRealPathFromUri: 解析Uri路径Uri=" + contentUri);
if (contentUri == null) { // if (contentUri == null) {
LogUtils.e(TAG, "getRealPathFromUri: Uri为空解析失败"); // LogUtils.e(TAG, "getRealPathFromUri: Uri为空解析失败");
return null; // return null;
} // }
String realPath = null; // String realPath = null;
String[] projection = {MediaStore.MediaColumns.DATA}; // String[] projection = {MediaStore.MediaColumns.DATA};
Cursor cursor = getContentResolver().query(contentUri, projection, null, null, null); // Cursor cursor = getContentResolver().query(contentUri, projection, null, null, null);
if (cursor != null) { // if (cursor != null) {
try { // try {
if (cursor.moveToNext()) { // if (cursor.moveToNext()) {
int columnIndex = cursor.getColumnIndex(MediaStore.MediaColumns.DATA); // int columnIndex = cursor.getColumnIndex(MediaStore.MediaColumns.DATA);
if (columnIndex > -1) { // if (columnIndex > -1) {
realPath = cursor.getString(columnIndex); // realPath = cursor.getString(columnIndex);
} // }
} // }
} finally { // } finally {
cursor.close(); // cursor.close();
} // }
} // }
LogUtils.d(TAG, "getRealPathFromUri: 解析完成,路径=" + realPath); // LogUtils.d(TAG, "getRealPathFromUri: 解析完成,路径=" + realPath);
return realPath; // return realPath;
} // }
private APPInfo genDefaultAppInfo() { private APPInfo genDefaultAppInfo() {
LogUtils.d(TAG, "genDefaultAppInfo: 生成默认应用信息"); LogUtils.d(TAG, "genDefaultAppInfo: 生成默认应用信息");

View File

@@ -19,6 +19,7 @@ import cc.winboll.studio.powerbell.threads.RemindThread;
import cc.winboll.studio.powerbell.utils.NotificationManagerUtils; import cc.winboll.studio.powerbell.utils.NotificationManagerUtils;
import java.io.Serializable; import java.io.Serializable;
import java.util.List; import java.util.List;
import cc.winboll.studio.powerbell.receivers.ControlCenterServiceReceiver;
/** /**
* @Author ZhanGSKen&豆包大模型<zhangsken@qq.com> * @Author ZhanGSKen&豆包大模型<zhangsken@qq.com>
@@ -32,8 +33,8 @@ public class ControlCenterService extends Service {
public static final String TAG = "ControlCenterService"; public static final String TAG = "ControlCenterService";
// 服务指令Action常量带包名前缀防冲突 // 服务指令Action常量带包名前缀防冲突
public static final String ACTION_RESTART_REMIND_THREAD = "cc.winboll.studio.powerbell.action.RESTART_REMIND_THREAD"; // 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 EXTRA_APP_CONFIG_BEAN = "cc.winboll.studio.powerbell.extra.APP_CONFIG_BEAN";
// 超时/阈值常量 // 超时/阈值常量
private static final long THREAD_STOP_TIMEOUT = 1000L; 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 intent = new Intent(context, ControlCenterService.class);
intent.setAction(ACTION_RESTART_REMIND_THREAD); intent.setAction(ControlCenterServiceReceiver.ACTION_APPCONFIG_CHANGED);
intent.putExtra(EXTRA_APP_CONFIG_BEAN, (Serializable) configBean); intent.putExtra(ControlCenterServiceReceiver.EXTRA_APP_CONFIG_BEAN, (Serializable) configBean);
intent.setPackage(context.getPackageName()); intent.setPackage(context.getPackageName());
intent.addFlags(Intent.FLAG_INCLUDE_STOPPED_PACKAGES); context.sendBroadcast(intent);
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);
}
} }
/** /**