Skip to content

Commit b531d7b

Browse files
authored
Merge branch 'master' into fix/rounded-clickable-press-highlight
2 parents 2f7b675 + 35cfea4 commit b531d7b

2 files changed

Lines changed: 12 additions & 4 deletions

File tree

CHANGELOG.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,7 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
1010
## Fixed
1111

1212
- Match clickable view ripple corners to uniform `borderRadius` on Android 12+.
13+
- Use expedited WorkManager requests for widget background tasks on Android 12+ to reduce delays when the app is in the background, with fallback to regular work when expedited quota is exhausted.
1314

1415
## [0.20.3] - 2026-05-02
1516

android/src/main/java/com/reactnativeandroidwidget/RNWidgetJsCommunication.java

Lines changed: 11 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,12 @@
11
package com.reactnativeandroidwidget;
22

33
import android.content.Context;
4+
import android.os.Build;
45

56
import androidx.work.Data;
67
import androidx.work.ExistingWorkPolicy;
78
import androidx.work.OneTimeWorkRequest;
9+
import androidx.work.OutOfQuotaPolicy;
810
import androidx.work.WorkManager;
911

1012
import java.util.concurrent.TimeUnit;
@@ -22,14 +24,19 @@ public static void requestWidgetUpdate(Context context, String widgetName) {
2224
protected static void startBackgroundTask(Context context, Data data) {
2325
workManagerWorkaround(context);
2426

25-
OneTimeWorkRequest headlessJsTaskWorkRequest =
27+
OneTimeWorkRequest.Builder builder =
2628
new OneTimeWorkRequest.Builder(RNWidgetBackgroundTaskWorker.class)
27-
.setInputData(data)
28-
.build();
29+
.setInputData(data);
30+
31+
// Reduce background scheduling delays on Android 12+.
32+
// Falls back to regular work if expedited quota is exhausted.
33+
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.S) {
34+
builder.setExpedited(OutOfQuotaPolicy.RUN_AS_NON_EXPEDITED_WORK_REQUEST);
35+
}
2936

3037
WorkManager
3138
.getInstance(context)
32-
.enqueue(headlessJsTaskWorkRequest);
39+
.enqueue(builder.build());
3340
}
3441

3542
// `APPWIDGET_UPDATE` (`onUpdate`) method is called when the WorkManager queue is empty.

0 commit comments

Comments
 (0)