Skip to content

Commit

Permalink
switch foreground service type
Browse files Browse the repository at this point in the history
This might fix the background microphone usage.
mwarning committed Aug 28, 2024

Verified

This commit was signed with the committer’s verified signature. The key has expired.
Czaki Grzegorz Bokota
1 parent 4e84cc4 commit a518a3d
Showing 2 changed files with 6 additions and 4 deletions.
5 changes: 3 additions & 2 deletions app/src/main/AndroidManifest.xml
Original file line number Diff line number Diff line change
@@ -6,7 +6,8 @@
android:name="android.hardware.camera"
android:required="false" />

<uses-permission android:name="android.permission.FOREGROUND_SERVICE_MEDIA_PLAYBACK" />
<uses-permission android:name="android.permission.FOREGROUND_SERVICE_MICROPHONE" />
<uses-permission android:name="android.permission.FOREGROUND_SERVICE_CAMERA" />

<!-- Backup Import/Export -->
<uses-permission android:name="android.permission.READ_EXTERNAL_STORAGE" />
@@ -56,7 +57,7 @@
<service
android:name=".MainService"
android:exported="false"
android:foregroundServiceType="mediaPlayback" />
android:foregroundServiceType="camera|microphone" />

<activity
android:name=".StartActivity"
5 changes: 3 additions & 2 deletions app/src/main/kotlin/d/d/meshenger/MainService.kt
Original file line number Diff line number Diff line change
@@ -3,7 +3,8 @@ package d.d.meshenger
import android.app.*
import android.content.Context
import android.content.Intent
import android.content.pm.ServiceInfo.FOREGROUND_SERVICE_TYPE_MEDIA_PLAYBACK
import android.content.pm.ServiceInfo.FOREGROUND_SERVICE_TYPE_CAMERA
import android.content.pm.ServiceInfo.FOREGROUND_SERVICE_TYPE_MICROPHONE
import android.graphics.Color
import android.os.Binder
import android.os.Build
@@ -186,7 +187,7 @@ class MainService : Service(), Runnable {
if (Build.VERSION.SDK_INT < Build.VERSION_CODES.TIRAMISU) {
startForeground(NOTIFICATION_ID, notification)
} else {
startForeground(NOTIFICATION_ID, notification, FOREGROUND_SERVICE_TYPE_MEDIA_PLAYBACK)
startForeground(NOTIFICATION_ID, notification, FOREGROUND_SERVICE_TYPE_MICROPHONE or FOREGROUND_SERVICE_TYPE_CAMERA)
}
} else if (intent.action == STOP_FOREGROUND_ACTION) {
Log.d(this, "onStartCommand() Received Stop Foreground Intent")

0 comments on commit a518a3d

Please sign in to comment.