Skip to content

Commit 3e118a8

Browse files
committed
fix(android): switch FGS type connectedDevice→dataSync — connectedDevice requires runtime BLE grants at startForeground() time which aren't held at launch
1 parent c4710e3 commit 3e118a8

1 file changed

Lines changed: 3 additions & 8 deletions

File tree

mobile_app/plugins/withAndroidForegroundService.js

Lines changed: 3 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -52,7 +52,7 @@ class LxmfForegroundService : Service() {
5252
.setPriority(NotificationCompat.PRIORITY_LOW)
5353
.build()
5454
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.UPSIDE_DOWN_CAKE) {
55-
startForeground(NOTIF_ID, notification, ServiceInfo.FOREGROUND_SERVICE_TYPE_CONNECTED_DEVICE)
55+
startForeground(NOTIF_ID, notification, ServiceInfo.FOREGROUND_SERVICE_TYPE_DATA_SYNC)
5656
} else {
5757
startForeground(NOTIF_ID, notification)
5858
}
@@ -129,12 +129,7 @@ function withAndroidForegroundService(config) {
129129
perms.push({ $: { 'android:name': name } });
130130
};
131131
addPerm('android.permission.FOREGROUND_SERVICE');
132-
addPerm('android.permission.FOREGROUND_SERVICE_CONNECTED_DEVICE');
133-
addPerm('android.permission.BLUETOOTH_ADVERTISE');
134-
addPerm('android.permission.BLUETOOTH_CONNECT');
135-
addPerm('android.permission.BLUETOOTH_SCAN');
136-
addPerm('android.permission.CHANGE_WIFI_STATE');
137-
addPerm('android.permission.CHANGE_NETWORK_STATE');
132+
addPerm('android.permission.FOREGROUND_SERVICE_DATA_SYNC');
138133

139134
const app = manifest.application[0];
140135
if (!app.service) app.service = [];
@@ -143,7 +138,7 @@ function withAndroidForegroundService(config) {
143138
app.service.push({
144139
$: {
145140
'android:name': fqn,
146-
'android:foregroundServiceType': 'connectedDevice',
141+
'android:foregroundServiceType': 'dataSync',
147142
'android:exported': 'false',
148143
},
149144
});

0 commit comments

Comments
 (0)