fix: (MM-59956) Android crash when sharing (#8122) (#8126)

(cherry picked from commit 1de7b5e9b7)

Co-authored-by: Rahim Rahman <rahim.rahman@mattermost.com>
This commit is contained in:
Mattermost Build 2024-08-02 18:10:47 +03:00 committed by GitHub
parent 48b80ef09f
commit 21c7628da1
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
2 changed files with 13 additions and 1 deletions

View file

@ -21,6 +21,7 @@
<uses-permission android:name="android.permission.POST_NOTIFICATIONS"/>
<uses-permission android:name="android.permission.FOREGROUND_SERVICE"/>
<uses-permission android:name="android.permission.FOREGROUND_SERVICE_MICROPHONE"/>
<uses-permission android:name="android.permission.FOREGROUND_SERVICE_DATA_SYNC"/>
<!-- Request legacy Bluetooth permissions on older devices. -->
<uses-permission android:name="android.permission.BLUETOOTH"
@ -116,5 +117,15 @@
android:foregroundServiceType="microphone"
android:exported="false"
/>
<!-- Android 14 requires the correct Foreground Service (FGS) type for RNShare -->
<service
android:name="androidx.work.impl.foreground.SystemForegroundService"
android:foregroundServiceType="dataSync"
android:exported="false"
android:stopWithTask="false"
tools:node="merge"
/>
</application>
</manifest>

View file

@ -1,5 +1,6 @@
package com.mattermost.rnshare
import android.content.pm.ServiceInfo
import android.content.Context
import android.util.Log
import androidx.core.app.NotificationCompat
@ -147,7 +148,7 @@ class ShareWorker(context: Context, workerParameters: WorkerParameters) : Worker
.setSmallIcon(applicationContext.resources.getIdentifier("ic_notification", "mipmap", applicationContext.packageName))
.setOngoing(true)
.build()
return ForegroundInfo(1, notification)
return ForegroundInfo(1, notification, ServiceInfo.FOREGROUND_SERVICE_TYPE_DATA_SYNC)
}
}