Skip to content

Commit f55e7be

Browse files
committed
update isConnected flag in closeResources catch block
1 parent bf1924a commit f55e7be

File tree

1 file changed

+18
-16
lines changed

1 file changed

+18
-16
lines changed

android/app/src/main/java/betaflight/configurator/plugin/SocketPlugin.java

Lines changed: 18 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -135,22 +135,24 @@ public void disconnect(PluginCall call) {
135135
* Helper method to close all resources and clean up state
136136
*/
137137
private void closeResources() {
138-
try {
139-
if (reader != null) {
140-
reader.close();
141-
reader = null;
142-
}
143-
if (writer != null) {
144-
writer.close();
145-
writer = null;
146-
}
147-
if (socket != null) {
148-
socket.close();
149-
socket = null;
138+
try {
139+
if (reader != null) {
140+
reader.close();
141+
reader = null;
142+
}
143+
if (writer != null) {
144+
writer.close();
145+
writer = null;
146+
}
147+
if (socket != null) {
148+
socket.close();
149+
socket = null;
150+
}
151+
} catch (IOException e) {
152+
// Log but continue cleanup
153+
isConnected = false;
154+
getContext().getActivity().runOnUiThread(() ->
155+
Log.e("SocketPlugin", "Error closing resources", e));
150156
}
151-
} catch (IOException e) {
152-
// Log but continue cleanup
153-
getContext().getActivity().runOnUiThread(() ->
154-
Log.e("SocketPlugin", "Error closing resources", e));
155157
}
156158
}

0 commit comments

Comments
 (0)