Skip to content

Commit 91f37f9

Browse files
committed
Fix possible crash with merge callback
In some scenarios, the merge callback can be cleared sooner than when it was initially set, tripping up the assertion we do in unbind(). Signed-off-by: Andrew Gunnerson <[email protected]>
1 parent 9babaa1 commit 91f37f9

File tree

1 file changed

+8
-1
lines changed

1 file changed

+8
-1
lines changed

app/src/main/java/com/chiller3/custota/updater/UpdaterThread.kt

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -167,8 +167,15 @@ class UpdaterThread(
167167
// This cannot be unbound. The callback is removed from update_engine only when the merge
168168
// operation finishes or the binder client process dies.
169169
EngineCallback(EngineWatchType.MERGE).let {
170-
updateEngine.cleanupSuccessfulUpdate(it)
170+
// We set mergeCallback first because calling cleanupSuccessfulUpdate() may result in a
171+
// synchronous call to onPayloadApplicationComplete(), which clears the callback.
171172
mergeCallback = it
173+
try {
174+
updateEngine.cleanupSuccessfulUpdate(it)
175+
} catch (e: Exception) {
176+
mergeCallback = null
177+
throw e
178+
}
172179
}
173180
}
174181

0 commit comments

Comments
 (0)