@@ -34,17 +34,25 @@ class FusedMockBackend(private val base: LocationBackend, private val fused: Fus
3434 useFused = false
3535 try { fused.start(); useFused = true }
3636 catch (cancelled: CancellationException ) { throw cancelled }
37- catch (error: Exception ) { failure = error.message ? : " GMS 通道启动失败,继续使用标准 Provider" }
37+ catch (error: Exception ) { degrade( error, " GMS 通道启动失败,继续使用标准 Provider" ) }
3838 return BackendResult .Success
3939 }
4040 override suspend fun publish (sample : LocationSample ): BackendResult {
4141 val result = base.publish(sample)
4242 if (result is BackendResult .Failure ) return result
4343 if (useFused) try { fused.publish(sample) }
4444 catch (cancelled: CancellationException ) { throw cancelled }
45- catch (error: Exception ) { useFused = false ; failure = error.message ? : " GMS 提交失败,继续使用标准 Provider" }
45+ catch (error: Exception ) { degrade( error, " GMS 提交失败,继续使用标准 Provider" ) }
4646 return BackendResult .Success
4747 }
48+ private suspend fun degrade (error : Exception , fallback : String ) {
49+ useFused = false
50+ failure = error.message ? : fallback
51+ // A stale fused mock fix can mask healthy platform providers: disable it on degradation.
52+ try { fused.stop() }
53+ catch (cancelled: CancellationException ) { throw cancelled }
54+ catch (cleanup: Exception ) { failure + = " ; GMS 清理待重试:${cleanup.message} " }
55+ }
4856 override suspend fun pause () = base.pause()
4957 override suspend fun resume () = base.resume()
5058 override suspend fun stop (): BackendResult {
0 commit comments