fix: android 14 foreground permissions

Closes #71
This commit is contained in:
Zane Schepke
2023-12-21 12:17:03 -05:00
parent ffa7a207fb
commit f0ec661223
5 changed files with 21 additions and 10 deletions
+9 -6
View File
@@ -20,9 +20,8 @@
<!--foreground service exempt android 14-->
<uses-permission android:name="android.permission.FOREGROUND_SERVICE_SYSTEM_EXEMPTED"/>
<uses-permission android:name="android.permission.SCHEDULE_EXACT_ALARM"/>
<uses-permission android:name="android.permission.FOREGROUND_SERVICE_SPECIAL_USE"/>
<uses-permission android:name="android.permission.FOREGROUND_SERVICE_LOCATION"/>
<uses-permission android:name="android.permission.FOREGROUND_SERVICE_REMOTE_MESSAGING"/>
<!--foreground service permissions-->
<uses-permission android:name="android.permission.FOREGROUND_SERVICE" />
<uses-permission android:name="android.permission.WAKE_LOCK" />
@@ -46,6 +45,7 @@
</queries>
<application
android:allowBackup="true"
android:enableOnBackInvokedCallback="true"
android:name=".WireGuardAutoTunnel"
android:dataExtractionRules="@xml/data_extraction_rules"
android:fullBackupContent="@xml/backup_rules"
@@ -55,7 +55,7 @@
android:roundIcon="@mipmap/ic_launcher_round"
android:supportsRtl="true"
android:theme="@style/Theme.WireguardAutoTunnel"
tools:targetApi="31">
tools:targetApi="tiramisu">
<activity
android:name=".ui.MainActivity"
android:exported="true"
@@ -84,7 +84,8 @@
<service
android:name=".service.foreground.ForegroundService"
android:enabled="true"
android:foregroundServiceType="remoteMessaging"
android:foregroundServiceType="systemExempted|specialUse"
tools:node="merge"
android:exported="false">
</service>
<service
@@ -106,7 +107,8 @@
android:permission="android.permission.BIND_VPN_SERVICE"
android:enabled="true"
android:persistent="true"
android:foregroundServiceType="systemExempted"
android:foregroundServiceType="systemExempted|specialUse"
tools:node="merge"
android:exported="false">
<intent-filter>
<action android:name="android.net.VpnService"/>
@@ -119,7 +121,8 @@
android:enabled="true"
android:stopWithTask="false"
android:persistent="true"
android:foregroundServiceType="systemExempted"
android:foregroundServiceType="systemExempted|specialUse"
tools:node="merge"
android:exported="false">
</service>
<receiver android:enabled="true" android:name=".receiver.BootReceiver"
@@ -46,6 +46,7 @@ class WireGuardTunnelService : ForegroundService() {
override fun startService(extras: Bundle?) {
super.startService(extras)
// TODO fix grapheneOS calls always-on on install
launchVpnStartingNotification()
val tunnelConfigString = extras?.getString(getString(R.string.tunnel_extras_key))
cancelJob()
@@ -179,7 +180,12 @@ class WireGuardTunnelService : ForegroundService() {
showTimestamp = true,
description = message
)
super.startForeground(foregroundId, notification)
ServiceCompat.startForeground(
this,
foregroundId,
notification,
Constants.SYSTEM_EXEMPT_SERVICE_TYPE_ID
)
}
private fun cancelJob() {