Merge pull request 'Foreground Permission Reset' (#843) from android_foreground_fix into trunk
continuous-integration/drone/push Build is passing Details

Reviewed-on: #843
This commit is contained in:
Sarah Jamie Lewis 2024-02-23 19:48:17 +00:00
commit eaae82ef55
2 changed files with 11 additions and 3 deletions

View File

@ -1,4 +1,4 @@
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
<manifest xmlns:android="http://schemas.android.com/apk/res/android" xmlns:tools="http://schemas.android.com/tools"
package="im.cwtch.flwtch">
<!-- io.flutter.app.FlutterApplication is an android.app.Application that
calls FlutterMain.startInitialization(this); in its onCreate method.
@ -38,14 +38,21 @@
android:name="flutterEmbedding"
android:value="2" />
<!--Needed to run in background (lol)-->
<service
android:name="androidx.work.impl.foreground.SystemForegroundService"
android:foregroundServiceType="dataSync"
tools:node="merge" />
</application>
<!--Needed to access Tor socket-->
<uses-permission android:name="android.permission.INTERNET" />
<!--Needed to run in background (lol)-->
<!-- Needed for running in the background -->
<uses-permission android:name="android.permission.FOREGROUND_SERVICE" />
<!-- As of Android 13 this permission is required -->
<uses-permission android:name="android.permission.FOREGROUND_SERVICE_DATA_SYNC" />
<!-- Ability to ask user to exempt app from power management (which can kill it more frequently especially on some devices.
Allows app to use ACTION_IGNORE_BATTERY_OPTIMIZATION_SETTINGS -->

View File

@ -11,6 +11,7 @@ import android.graphics.Color
import android.net.Uri
import android.os.Build
import android.util.Log
import android.content.pm.ServiceInfo
import androidx.annotation.RequiresApi
import androidx.core.app.NotificationCompat
import androidx.localbroadcastmanager.content.LocalBroadcastManager
@ -292,7 +293,7 @@ class FlwtchWorker(context: Context, parameters: WorkerParameters) :
.addAction(android.R.drawable.ic_delete, cancel, PendingIntent.getActivity(applicationContext, 2, cancelIntent, flags))
.build()
return ForegroundInfo(101, notification)
return ForegroundInfo(101, notification, ServiceInfo.FOREGROUND_SERVICE_TYPE_DATA_SYNC)
}
@RequiresApi(Build.VERSION_CODES.O)