通知模块改造尝试。

This commit is contained in:
2026-01-09 19:35:13 +08:00
parent ac4d34a5f8
commit 2a8404cbbe
3 changed files with 17 additions and 18 deletions

View File

@@ -1,8 +1,8 @@
#Created by .winboll/winboll_app_build.gradle
#Thu Jan 08 05:43:21 GMT 2026
#Fri Jan 09 11:30:12 GMT 2026
stageCount=4
libraryProject=
baseVersion=15.14
publishVersion=15.14.3
buildCount=1
buildCount=3
baseBetaVersion=15.14.4

View File

@@ -18,10 +18,9 @@
-keep public class * extends android.app.backup.BackupAgentHelper
-keep public class * extends android.preference.Preference
# 核心修改保留 cc.winboll.studio 包下所有内容不被混淆
# 保留 WinBoLL 核心包及子类(合并简化规则)
-keep class cc.winboll.studio.** { *; }
-keep interface cc.winboll.studio.** { *; }
-keep enum cc.winboll.studio.** { *; }
-keepclassmembers class cc.winboll.studio.** { *; }
# 保留所有类中的 public static final String TAG 字段(便于日志定位)
-keepclassmembers class * {

View File

@@ -32,7 +32,7 @@ public class NotificationManagerUtils {
public static final String TAG = "NotificationManagerUtils";
// ********** 新增:通知版本管理常量 **********
/** 通知版本标识(源码标记版本,变更时会清理旧渠道) */
public static final String NOTIFICATION_VERSION = "v1.0.0";
public static final String NOTIFICATION_VERSION = "v1.0.1";
/** SP存储键已保存的通知版本 */
private static final String SP_KEY_NOTIFICATION_VERSION = "sp_key_notification_version";
/** SP文件名 */
@@ -156,10 +156,10 @@ public class NotificationManagerUtils {
* 初始化通知渠道:前台服务渠道(无铃声+无振动)、临时提醒渠道(系统默认铃声+无振动)
*/
private void initNotificationChannels() {
LogUtils.d(TAG, "initNotificationChannels() 方法调用");
LogUtils.d(TAG, "initNotificationChannels() 执行通知渠道初始化");
// API<26 无渠道机制,直接返回
if (Build.VERSION.SDK_INT < Build.VERSION_CODES.O) {
LogUtils.d(TAG, "initNotificationChannels() API<26无需创建渠道,直接返回");
LogUtils.d(TAG, "initNotificationChannels() API<26无需创建渠道");
return;
}
// 通知服务为空,避免空指针
@@ -168,38 +168,38 @@ public class NotificationManagerUtils {
return;
}
// 1. 前台服务渠道(低优先级,后台保活无打扰)
// 1. 拨号前台服务渠道(低优先级,后台保活无打扰)
NotificationChannel foregroundChannel = new NotificationChannel(
CHANNEL_ID_FOREGROUND,
"拨号服务保活",
"拨号前台服务",
NotificationManager.IMPORTANCE_LOW
);
foregroundChannel.setDescription("拨号服务后台运行,无声音、无振动");
foregroundChannel.setDescription("拨号前台服务后台运行,无声音、无振动");
foregroundChannel.enableLights(false);
foregroundChannel.enableVibration(false);
foregroundChannel.setSound(null, null);
foregroundChannel.setSound(null, null); // 强制无铃声
foregroundChannel.setShowBadge(false);
foregroundChannel.setLockscreenVisibility(Notification.VISIBILITY_SECRET);
LogUtils.d(TAG, "initNotificationChannels() 前台服务渠道配置完成");
LogUtils.d(TAG, "initNotificationChannels() 拨号前台服务渠道配置完成");
// 2. 临时提醒渠道(中优先级,系统默认铃声,无振动)
// 2. 其他临时通知渠道(中优先级,系统默认铃声,无振动)
NotificationChannel temporaryChannel = new NotificationChannel(
CHANNEL_ID_TEMPORARY,
"临时通知提醒",
"临时通知",
NotificationManager.IMPORTANCE_DEFAULT
);
temporaryChannel.setDescription("拨号服务临时通知,系统默认铃声,无振动");
temporaryChannel.setDescription("其他临时通知,系统默认铃声,无振动");
temporaryChannel.enableLights(true);
temporaryChannel.enableVibration(false);
temporaryChannel.setSound(RingtoneManager.getDefaultUri(RingtoneManager.TYPE_NOTIFICATION), Notification.AUDIO_ATTRIBUTES_DEFAULT);
temporaryChannel.setShowBadge(false);
temporaryChannel.setLockscreenVisibility(Notification.VISIBILITY_PUBLIC);
LogUtils.d(TAG, "initNotificationChannels() 临时提醒渠道配置完成");
LogUtils.d(TAG, "initNotificationChannels() 其他临时通知渠道配置完成");
// 注册渠道到系统
mNotificationManager.createNotificationChannel(foregroundChannel);
mNotificationManager.createNotificationChannel(temporaryChannel);
LogUtils.d(TAG, "initNotificationChannels() 成功:创建前台服务+临时提醒渠道");
LogUtils.d(TAG, "initNotificationChannels() 成功:创建前台服务+其他临时通知渠道");
}
// ================================== 对外核心方法(前台服务通知:启动/更新/取消)=================================