Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions androidApp/build.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -67,8 +67,8 @@ android {
applicationId = "com.smjcco.wxpusher"
minSdk = libs.versions.android.minSdk.get().toInt()
targetSdk = libs.versions.android.targetSdk.get().toInt()
versionCode = 10811
versionName = "1.8.11"
versionCode = 10820
versionName = "1.8.20"
//指定产物名称
setProperty("archivesBaseName", "wxpusher-app-v$versionName")

Expand Down
17 changes: 16 additions & 1 deletion androidApp/src/androidMain/AndroidManifest.xml
Original file line number Diff line number Diff line change
Expand Up @@ -121,6 +121,21 @@
android:launchMode="singleTask"
android:screenOrientation="portrait" />

<activity
android:name=".page.pushchannel.PushChannelSettingActivity"
android:exported="false"
android:screenOrientation="portrait" />

<activity
android:name=".page.pushchannel.alert.WsAlertSettingActivity"
android:exported="false"
android:screenOrientation="portrait" />

<activity
android:name=".page.pushchannel.alert.SystemPushSoundGuideActivity"
android:exported="false"
android:screenOrientation="portrait" />

<activity
android:name=".page.web.WxpWebViewActivity"
android:exported="true" />
Expand Down Expand Up @@ -275,4 +290,4 @@
<!--微信包名,Android 11+需要-->
<package android:name="com.tencent.mm" />
</queries>
</manifest>
</manifest>
Original file line number Diff line number Diff line change
Expand Up @@ -42,14 +42,12 @@ class WxPusherApplication : Application() {
WxpAppDataService.init();
//初始化设备基础信息
WxpBaseInfoService.init(WxpBaseInfoServiceImpl())
// 先加载本地降级配置,再决定推送通道;云端刷新后通知协调器热切换。
ConfigManager.init(this)
PushManager.init(this)
//上报一次绑定关系,主要是为了更新设备活跃时间
WxpAppDataService.updateDeviceInfo()
initTbs()
//注册版本升级市场跳转能力(已适配厂商优先,其他走 TBS)
WxpVersionCheckManager.setNavigator(AppMarketNavigator)
//拉取一个简单的配置
ConfigManager.init(this)
// 启动时执行一次 app_fe 版本刷新(内部有 1 小时间隔,失败无影响)
AppFeVersionManager.refreshOnAppLaunch()
//初始化微信SDK
Expand Down Expand Up @@ -87,4 +85,4 @@ class WxPusherApplication : Application() {
.build()
UpgradeManager.getInstance().init(this, config)
}
}
}
Original file line number Diff line number Diff line change
@@ -1,10 +1,17 @@
package com.smjcco.wxpusher.app

import com.smjcco.wxpusher.base.biz.bean.WxpPlatformEnum
import com.smjcco.wxpusher.base.common.IWxpBaseInfoServiceListener
import com.smjcco.wxpusher.utils.DeviceUtils
import com.smjcco.wxpusher.push.PushPlatformState

class WxpBaseInfoServiceImpl : IWxpBaseInfoServiceListener {
override fun getPlatform(): String {
return DeviceUtils.getPlatform().getPlatform()
/** 获取 Android 客户端平台,不包含当前推送通道信息。 */
override fun getClientPlatform(): String {
return WxpPlatformEnum.Android.platform
}
}

/** 获取当前已经生效或首次注册阶段默认使用的后端推送路由平台。 */
override fun getEffectivePushPlatform(): String {
return PushPlatformState.getEffectivePushPlatform().getPlatform()
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -25,4 +25,10 @@ enum class DevicePlatform(private val platform: String) {
Wecom("Wecom");

fun getPlatform() = platform
}

companion object {
/** 根据后端保存的平台字符串恢复枚举,无法识别时返回空。 */
fun find(platform: String?): DevicePlatform? =
entries.firstOrNull { it.platform == platform }
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,9 @@ object ConfigManager {
// 应用上下文
private lateinit var appContext: Context

// 云端配置发生实际变化时,通知推送通道等运行时组件立即响应。
private val listeners = mutableSetOf<(ConfigItem) -> Unit>()

/**
* 初始化配置管理器
* @param context 应用上下文
Expand Down Expand Up @@ -122,6 +125,23 @@ object ConfigManager {
return currentConfig
}

/** 注册配置变化监听器。 */
fun addListener(listener: (ConfigItem) -> Unit) {
listeners.add(listener)
}

/** 移除配置变化监听器。 */
fun removeListener(listener: (ConfigItem) -> Unit) {
listeners.remove(listener)
}

private suspend fun notifyConfigChanged(config: ConfigItem) {
// 监听方可能更新页面或服务状态,因此统一在主线程回调。
withContext(Dispatchers.Main) {
listeners.toList().forEach { it(config) }
}
}

/**
* 强制从服务器刷新配置
* @param callback 刷新结果回调
Expand All @@ -138,7 +158,12 @@ object ConfigManager {
// 更新当前配置
val compatibleConfig = configResponse?.configs?.let { findCompatibleConfig(it) }
if (compatibleConfig != null) {
// 只有内容真正变化才触发热切换,避免每次刷新重复初始化通道。
val changed = compatibleConfig != currentConfig
currentConfig = compatibleConfig
if (changed) {
notifyConfigChanged(compatibleConfig)
}
} else {
WxpLogUtils.i(TAG, "没有可用配置")
}
Expand All @@ -158,4 +183,4 @@ object ConfigManager {
}
}
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,7 @@ import com.smjcco.wxpusher.page.main.fragment.ProfileFragment
import com.smjcco.wxpusher.page.main.fragment.WxpExtFuncFragment
import com.smjcco.wxpusher.page.main.fragment.WxpProviderListFragment
import com.smjcco.wxpusher.push.PushManager
import com.smjcco.wxpusher.push.ws.alert.WsAlertPlayer
import com.smjcco.wxpusher.push.ws.keepalive.KeepWsAliveServiceStarter
import com.smjcco.wxpusher.utils.PermissionRequester
import com.smjcco.wxpusher.utils.PermissionUtils
Expand Down Expand Up @@ -303,6 +304,8 @@ class WxpMainActivity : WxpBaseActivity(), CurrentTabProvider {

override fun onResume() {
super.onResume()
//用户已经看到消息了,WS 的持续提醒(最长 60 秒)就该停下来
WsAlertPlayer.stopAll()
PushManager.showOpenNoteRemindSettingDialog(this)
//显示首页的时候,尝试启动一次保活服务
KeepWsAliveServiceStarter.start(this)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,9 @@ import com.smjcco.wxpusher.page.messagelist.WxpMessageListPresenter
import com.smjcco.wxpusher.page.messagelist.WxpMessageListReq
import com.smjcco.wxpusher.page.web.WxpWebViewActivity
import com.smjcco.wxpusher.push.IPushTokenChangedListener
import com.smjcco.wxpusher.push.PushChannel
import com.smjcco.wxpusher.push.PushManager
import com.smjcco.wxpusher.push.PushPlatformState
import com.smjcco.wxpusher.utils.DeviceUtils
import com.smjcco.wxpusher.utils.PermissionUtils
import com.smjcco.wxpusher.utils.WxpJumpPageUtils
Expand Down Expand Up @@ -224,7 +226,7 @@ class MessageListFragment : WxpBaseMvpFragment<IWxpMessageListPresenter>(), IWxp
*/
private fun refreshBanner() {
//如果是非厂商通道,并且没有忽略电池优化,就提醒用户关闭电池优化
if (DeviceUtils.getPlatform() == DevicePlatform.Android) {
if (PushPlatformState.getEffectivePushChannel() == PushChannel.WEBSOCKET) {
if (!DeviceUtils.isIgnoringBatteryOptimizations()) {
batteryBanner.visibility = View.VISIBLE
bannerBtn.setOnClickListener {
Expand Down Expand Up @@ -389,10 +391,18 @@ class MessageListFragment : WxpBaseMvpFragment<IWxpMessageListPresenter>(), IWxp
notePermissionCloseImg.setImageDrawable(drawable)
}
notePermissionBanner.setOnClickListener {
WxpJumpPageUtils.jumpToWebUrl(
url = WxpConfig.appFeUrl + "/app/?code=${data.code}#/no-message",
activity = activity
)
// 厂商通道异常时直接引导用户手动切换,其他异常继续使用原排查页面。
if (data.code == 20002
&& PushPlatformState.getEffectivePushChannel() == PushChannel.VENDOR
) {
WxpToastUtils.showToast("当前推送通道异常,请尝试切换推送通道")
WxpJumpPageUtils.jumpToPushChannelSetting(activity)
} else {
WxpJumpPageUtils.jumpToWebUrl(
url = WxpConfig.appFeUrl + "/app/?code=${data.code}#/no-message",
activity = activity
)
}
}

}
Expand Down
Loading
Loading