Skip to content

Commit

Permalink
fix: (MM-59956) Android crash when sharing (#8122) (#8126)
Browse files Browse the repository at this point in the history
(cherry picked from commit 1de7b5e)

Co-authored-by: Rahim Rahman <[email protected]>
  • Loading branch information
mattermost-build and rahimrahman authored Aug 2, 2024
1 parent 48b80ef commit 21c7628
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 1 deletion.
11 changes: 11 additions & 0 deletions android/app/src/main/AndroidManifest.xml
Original file line number Diff line number Diff line change
Expand Up @@ -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"
Expand Down Expand Up @@ -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>
Original file line number Diff line number Diff line change
@@ -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
Expand Down Expand Up @@ -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)

}
}

0 comments on commit 21c7628

Please sign in to comment.