mirror of
https://github.com/deltachat/deltachat-android.git
synced 2025-10-03 17:59:39 +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
|
run: ./gradlew --no-daemon assembleGplayDebug
|
||||||
|
|
||||||
- name: Upload APK
|
- name: Upload APK
|
||||||
uses: actions/upload-artifact@v3
|
uses: actions/upload-artifact@v4
|
||||||
with:
|
with:
|
||||||
name: app-preview.apk
|
name: app-preview.apk
|
||||||
path: 'build/outputs/apk/gplay/debug/*.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.
|
// 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,
|
// After all events were processed, we will get DC_EVENT_ACCOUNTS_BACKGROUND_FETCH_DONE,
|
||||||
// and stop() will be called.
|
// and stop() will be called.
|
||||||
while (fetchingSynchronously) {
|
synchronized (STOP_NOTIFIER) {
|
||||||
try {
|
while (fetchingSynchronously) {
|
||||||
// The `wait()` needs to be enclosed in a while loop because there may be
|
try {
|
||||||
// "spurious wake-ups", i.e. `wait()` may return even though `notifyAll()` wasn't called.
|
// The `wait()` needs to be enclosed in a while loop because there may be
|
||||||
STOP_NOTIFIER.wait();
|
// "spurious wake-ups", i.e. `wait()` may return even though `notifyAll()` wasn't called.
|
||||||
} catch (InterruptedException ex) { }
|
STOP_NOTIFIER.wait();
|
||||||
|
} catch (InterruptedException ex) {}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -63,7 +65,9 @@ public final class FetchForegroundService extends Service {
|
||||||
public static void stop(Context context) {
|
public static void stop(Context context) {
|
||||||
if (fetchingSynchronously) {
|
if (fetchingSynchronously) {
|
||||||
fetchingSynchronously = false;
|
fetchingSynchronously = false;
|
||||||
STOP_NOTIFIER.notifyAll();
|
synchronized (STOP_NOTIFIER) {
|
||||||
|
STOP_NOTIFIER.notifyAll();
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
synchronized (SERVICE_LOCK) {
|
synchronized (SERVICE_LOCK) {
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue