android: report network info without an error alert, remove comments that restate the code

This commit is contained in:
Narasimha-sc committed 2026-10-20 09:10:24 +00:00
1 parent dcc48284be
commit 9e6047989e
3 files changed
+1 -4

No files matched your search

@@ -52,7 +52,6 @@ class NetworkObserver {
// the interface is compared too - a VPN that reconnected as another one can have the same
// address, and an interface being configured has none yet
let pathChanged = interface != prevInterface || lost(prevGateways, gateways) || lost(prevAddresses, addresses)
// the report that was not accepted is repeated when the next path update is received
if prevInfo != info || (info.online && pathChanged) {
prevInfo = setNetworkInfo(info) ? info : nil
}
@@ -160,11 +160,9 @@ class NetworkObserver {
private suspend fun sendNetworkInfo(info: UserNetworkInfo, network: Network?, removals: Int, ctrlGen: Int): Boolean {
if (ctrlGen != ctrlGeneration) return false
// the controller is passed, so that replacing it while the report is sent does not fail the command
val ctrl = controller.currentCtrl() ?: return false.also { reportFailed(ctrlGen) }
// a failed command must not be recorded as sent, and it throws when the response cannot be parsed
val sent = try { controller.apiSetNetworkInfo(info, ctrl) } catch (e: Throwable) { Log.e(TAG, "Error reporting network info: ${e.stackTraceToString()}"); false }
// when it was not sent the network info is reported again when the next event is received
if (sent) setSentInfo(info, network, removals, ctrlGen) else reportFailed(ctrlGen)
return sent
}
@@ -1534,7 +1534,7 @@ object ChatController {
}
suspend fun apiSetNetworkInfo(networkInfo: UserNetworkInfo, ctrl: ChatCtrl): Boolean =
sendCommandOkResp(null, CC.APISetNetworkInfo(networkInfo), ctrl)
sendCmd(null, CC.APISetNetworkInfo(networkInfo), ctrl).result is CR.CmdOk
suspend fun apiSetMemberSettings(rh: Long?, groupId: Long, groupMemberId: Long, memberSettings: GroupMemberSettings): Boolean =
sendCommandOkResp(rh, CC.ApiSetMemberSettings(groupId, groupMemberId, memberSettings))