mirror of
https://github.com/deltachat/deltachat-android.git
synced 2025-10-03 09:49:21 +02:00
Merge pull request #3526 from deltachat/adb/issue-3525
use synchronized block to avoid IllegalMonitorStateException
This commit is contained in:
commit
9d244611bc
2 changed files with 12 additions and 8 deletions
2
.github/workflows/preview-apk.yml
vendored
2
.github/workflows/preview-apk.yml
vendored
|
@ -49,7 +49,7 @@ jobs:
|
|||
run: ./gradlew --no-daemon assembleGplayDebug
|
||||
|
||||
- name: Upload APK
|
||||
uses: actions/upload-artifact@v3
|
||||
uses: actions/upload-artifact@v4
|
||||
with:
|
||||
name: app-preview.apk
|
||||
path: 'build/outputs/apk/gplay/debug/*.apk'
|
||||
|
|
|
@ -49,12 +49,14 @@ public final class FetchForegroundService extends Service {
|
|||
// The background fetch was successful, but we need to wait until all events were processed.
|
||||
// After all events were processed, we will get DC_EVENT_ACCOUNTS_BACKGROUND_FETCH_DONE,
|
||||
// and stop() will be called.
|
||||
synchronized (STOP_NOTIFIER) {
|
||||
while (fetchingSynchronously) {
|
||||
try {
|
||||
// The `wait()` needs to be enclosed in a while loop because there may be
|
||||
// "spurious wake-ups", i.e. `wait()` may return even though `notifyAll()` wasn't called.
|
||||
STOP_NOTIFIER.wait();
|
||||
} catch (InterruptedException ex) { }
|
||||
} catch (InterruptedException ex) {}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -63,8 +65,10 @@ public final class FetchForegroundService extends Service {
|
|||
public static void stop(Context context) {
|
||||
if (fetchingSynchronously) {
|
||||
fetchingSynchronously = false;
|
||||
synchronized (STOP_NOTIFIER) {
|
||||
STOP_NOTIFIER.notifyAll();
|
||||
}
|
||||
}
|
||||
|
||||
synchronized (SERVICE_LOCK) {
|
||||
if (service != null) {
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue