Browse Source

Merge commit 'd213921054020f7a2140b8df813e6a988e2d9114' into new_dev

weicu
lxm 1 year ago
parent
commit
3f32f66d9e
  1. 2
      local_plugins/qq_music/android/src/main/kotlin/com/yunqiinnovation/qq_music/QQMusicLoginManager.kt
  2. 20
      local_plugins/qq_music/android/src/main/kotlin/com/yunqiinnovation/qq_music/QQMusicManager.kt

2
local_plugins/qq_music/android/src/main/kotlin/com/yunqiinnovation/qq_music/QQMusicLoginManager.kt

@ -134,7 +134,7 @@ class QQMusicLoginManager(private val context: Context) {
Log.d(TAG, "启动QQ音乐登录页面")
// 启动QQ音乐登录
CommonCmd.loginQQMusic(context, URI_LOGIN)
CommonCmd.loginQQMusic(context,context.packageName, URI_LOGIN)
// 等待用户登录完成后进行身份验证
handler.postDelayed({

20
local_plugins/qq_music/android/src/main/kotlin/com/yunqiinnovation/qq_music/QQMusicManager.kt

@ -55,8 +55,6 @@ class QQMusicManager(private val context: Context) {
public val isConnected: Boolean
get() = isBindQQMusicService && qqmusicApi != null
private fun sayHi() {
if (!isBindQQMusicService || qqmusicApi == null) {
Log.w(TAG, "连接QQ音乐失败,可能是QQ音乐帐号状态异常,请打开QQ音乐检查帐号状态是否异常?")
@ -127,8 +125,8 @@ class QQMusicManager(private val context: Context) {
// 延迟发送hi消息,确保Binder连接稳定
Handler(Looper.getMainLooper()).postDelayed({
sayHi()
// 绑定成功后调用回调
callback?.onSuccess()
// // 绑定成功后调用回调
// callback?.onSuccess()
}, 500) // 延迟500ms
}
@ -137,9 +135,9 @@ class QQMusicManager(private val context: Context) {
qqmusicApi = null
isBindQQMusicService = false
// 服务断开时通知错误
callback?.onError(-2, "QQ音乐服务连接断开")
// callback?.onError(-2, "QQ音乐服务连接断开")
//重连绑定
bindQQMusicApiService(callback)
// bindQQMusicApiService(callback)
}
}, Context.BIND_AUTO_CREATE)
@ -162,7 +160,6 @@ class QQMusicManager(private val context: Context) {
// 延迟发送hi消息,确保Binder连接稳定
Handler(Looper.getMainLooper()).postDelayed({
sayHi()
callback?.onSuccess()
}, 500) // 延迟500ms
}
override fun onServiceDisconnected(name: ComponentName?) {
@ -175,8 +172,17 @@ class QQMusicManager(private val context: Context) {
Log.d(TAG, "重试绑定QQ音乐服务 $retryResult")
if (!retryResult) {
callback?.onError(-3, "重试绑定QQ音乐服务失败")
}else{
Handler(Looper.getMainLooper()).postDelayed({
callback?.onSuccess()
}, 1000) // 延迟500ms
}
}, 2000)
}else{
Handler(Looper.getMainLooper()).postDelayed({
callback?.onSuccess()
}, 1000) // 延迟500ms
}
} catch (e: Exception) {
Log.e(TAG, "绑定QQ音乐服务异常", e)

Loading…
Cancel
Save