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
#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

View File

@@ -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: 生成默认应用信息");

View File

@@ -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&豆包大模型<zhangsken@qq.com>
@@ -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);
}
/**