Skip to content

Commit

Permalink
Switch PushService to the specialUse foreground service type
Browse files Browse the repository at this point in the history
  • Loading branch information
cketti committed Jan 9, 2025
1 parent 52ca64d commit 8452cda
Show file tree
Hide file tree
Showing 10 changed files with 36 additions and 12 deletions.
4 changes: 3 additions & 1 deletion app-k9mail/badging/fossRelease-badging.txt
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,8 @@ uses-permission: name='android.permission.INTERNET'
uses-permission: name='android.permission.VIBRATE'
uses-permission: name='android.permission.WAKE_LOCK'
uses-permission: name='android.permission.FOREGROUND_SERVICE'
uses-permission: name='android.permission.FOREGROUND_SERVICE_DATA_SYNC'
uses-permission: name='android.permission.FOREGROUND_SERVICE_DATA_SYNC' maxSdkVersion='33'
uses-permission: name='android.permission.FOREGROUND_SERVICE_SPECIAL_USE'
uses-permission: name='android.permission.SCHEDULE_EXACT_ALARM'
uses-permission: name='android.permission.USE_BIOMETRIC'
uses-permission: name='android.permission.USE_FINGERPRINT'
Expand Down Expand Up @@ -79,6 +80,7 @@ application-icon-65534:'res/drawable-v26/ic_launcher.xml'
application: label='K-9 Mail' icon='res/drawable-v26/ic_launcher.xml'
uses-library-not-required:'com.sec.android.app.multiwindow'
launchable-activity: name='com.fsck.k9.activity.MessageList' label='' icon=''
property: name='android.app.PROPERTY_SPECIAL_USE_FGS_SUBTYPE' value='This service is used to maintain a continuous connection to an IMAP server to be able to provide instant notifications to the user when a new email arrives. Firebase Cloud Messaging is not suitable for this task, neither are mechanisms like AndroidX WorkManager. Other foreground service types aren't a good fit for this use case.'
uses-library-not-required:'androidx.window.extensions'
uses-library-not-required:'androidx.window.sidecar'
feature-group: label=''
Expand Down
4 changes: 3 additions & 1 deletion app-k9mail/badging/fullRelease-badging.txt
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,8 @@ uses-permission: name='android.permission.INTERNET'
uses-permission: name='android.permission.VIBRATE'
uses-permission: name='android.permission.WAKE_LOCK'
uses-permission: name='android.permission.FOREGROUND_SERVICE'
uses-permission: name='android.permission.FOREGROUND_SERVICE_DATA_SYNC'
uses-permission: name='android.permission.FOREGROUND_SERVICE_DATA_SYNC' maxSdkVersion='33'
uses-permission: name='android.permission.FOREGROUND_SERVICE_SPECIAL_USE'
uses-permission: name='android.permission.SCHEDULE_EXACT_ALARM'
uses-permission: name='android.permission.USE_BIOMETRIC'
uses-permission: name='android.permission.USE_FINGERPRINT'
Expand Down Expand Up @@ -80,6 +81,7 @@ application-icon-65534:'res/drawable-v26/ic_launcher.xml'
application: label='K-9 Mail' icon='res/drawable-v26/ic_launcher.xml'
uses-library-not-required:'com.sec.android.app.multiwindow'
launchable-activity: name='com.fsck.k9.activity.MessageList' label='' icon=''
property: name='android.app.PROPERTY_SPECIAL_USE_FGS_SUBTYPE' value='This service is used to maintain a continuous connection to an IMAP server to be able to provide instant notifications to the user when a new email arrives. Firebase Cloud Messaging is not suitable for this task, neither are mechanisms like AndroidX WorkManager. Other foreground service types aren't a good fit for this use case.'
uses-library-not-required:'androidx.window.extensions'
uses-library-not-required:'androidx.window.sidecar'
feature-group: label=''
Expand Down
4 changes: 3 additions & 1 deletion app-thunderbird/badging/fossBeta-badging.txt
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,8 @@ uses-permission: name='android.permission.INTERNET'
uses-permission: name='android.permission.VIBRATE'
uses-permission: name='android.permission.WAKE_LOCK'
uses-permission: name='android.permission.FOREGROUND_SERVICE'
uses-permission: name='android.permission.FOREGROUND_SERVICE_DATA_SYNC'
uses-permission: name='android.permission.FOREGROUND_SERVICE_DATA_SYNC' maxSdkVersion='33'
uses-permission: name='android.permission.FOREGROUND_SERVICE_SPECIAL_USE'
uses-permission: name='android.permission.SCHEDULE_EXACT_ALARM'
uses-permission: name='android.permission.USE_BIOMETRIC'
uses-permission: name='android.permission.USE_FINGERPRINT'
Expand Down Expand Up @@ -80,6 +81,7 @@ application-icon-65534:'res/mipmap-anydpi-v26/ic_launcher.xml'
application: label='Thunderbird Beta' icon='res/mipmap-anydpi-v26/ic_launcher.xml'
uses-library-not-required:'com.sec.android.app.multiwindow'
launchable-activity: name='com.fsck.k9.activity.MessageList' label='' icon=''
property: name='android.app.PROPERTY_SPECIAL_USE_FGS_SUBTYPE' value='This service is used to maintain a continuous connection to an IMAP server to be able to provide instant notifications to the user when a new email arrives. Firebase Cloud Messaging is not suitable for this task, neither are mechanisms like AndroidX WorkManager. Other foreground service types aren't a good fit for this use case.'
uses-library-not-required:'androidx.window.extensions'
uses-library-not-required:'androidx.window.sidecar'
feature-group: label=''
Expand Down
4 changes: 3 additions & 1 deletion app-thunderbird/badging/fossDaily-badging.txt
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,8 @@ uses-permission: name='android.permission.INTERNET'
uses-permission: name='android.permission.VIBRATE'
uses-permission: name='android.permission.WAKE_LOCK'
uses-permission: name='android.permission.FOREGROUND_SERVICE'
uses-permission: name='android.permission.FOREGROUND_SERVICE_DATA_SYNC'
uses-permission: name='android.permission.FOREGROUND_SERVICE_DATA_SYNC' maxSdkVersion='33'
uses-permission: name='android.permission.FOREGROUND_SERVICE_SPECIAL_USE'
uses-permission: name='android.permission.SCHEDULE_EXACT_ALARM'
uses-permission: name='android.permission.USE_BIOMETRIC'
uses-permission: name='android.permission.USE_FINGERPRINT'
Expand Down Expand Up @@ -80,6 +81,7 @@ application-icon-65534:'res/mipmap-anydpi-v26/ic_launcher.xml'
application: label='Thunderbird Daily' icon='res/mipmap-anydpi-v26/ic_launcher.xml'
uses-library-not-required:'com.sec.android.app.multiwindow'
launchable-activity: name='com.fsck.k9.activity.MessageList' label='' icon=''
property: name='android.app.PROPERTY_SPECIAL_USE_FGS_SUBTYPE' value='This service is used to maintain a continuous connection to an IMAP server to be able to provide instant notifications to the user when a new email arrives. Firebase Cloud Messaging is not suitable for this task, neither are mechanisms like AndroidX WorkManager. Other foreground service types aren't a good fit for this use case.'
uses-library-not-required:'androidx.window.extensions'
uses-library-not-required:'androidx.window.sidecar'
feature-group: label=''
Expand Down
4 changes: 3 additions & 1 deletion app-thunderbird/badging/fossRelease-badging.txt
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,8 @@ uses-permission: name='android.permission.INTERNET'
uses-permission: name='android.permission.VIBRATE'
uses-permission: name='android.permission.WAKE_LOCK'
uses-permission: name='android.permission.FOREGROUND_SERVICE'
uses-permission: name='android.permission.FOREGROUND_SERVICE_DATA_SYNC'
uses-permission: name='android.permission.FOREGROUND_SERVICE_DATA_SYNC' maxSdkVersion='33'
uses-permission: name='android.permission.FOREGROUND_SERVICE_SPECIAL_USE'
uses-permission: name='android.permission.SCHEDULE_EXACT_ALARM'
uses-permission: name='android.permission.USE_BIOMETRIC'
uses-permission: name='android.permission.USE_FINGERPRINT'
Expand Down Expand Up @@ -80,6 +81,7 @@ application-icon-65534:'res/mipmap-anydpi-v26/ic_launcher.xml'
application: label='Thunderbird' icon='res/mipmap-anydpi-v26/ic_launcher.xml'
uses-library-not-required:'com.sec.android.app.multiwindow'
launchable-activity: name='com.fsck.k9.activity.MessageList' label='' icon=''
property: name='android.app.PROPERTY_SPECIAL_USE_FGS_SUBTYPE' value='This service is used to maintain a continuous connection to an IMAP server to be able to provide instant notifications to the user when a new email arrives. Firebase Cloud Messaging is not suitable for this task, neither are mechanisms like AndroidX WorkManager. Other foreground service types aren't a good fit for this use case.'
uses-library-not-required:'androidx.window.extensions'
uses-library-not-required:'androidx.window.sidecar'
feature-group: label=''
Expand Down
4 changes: 3 additions & 1 deletion app-thunderbird/badging/fullBeta-badging.txt
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,8 @@ uses-permission: name='android.permission.INTERNET'
uses-permission: name='android.permission.VIBRATE'
uses-permission: name='android.permission.WAKE_LOCK'
uses-permission: name='android.permission.FOREGROUND_SERVICE'
uses-permission: name='android.permission.FOREGROUND_SERVICE_DATA_SYNC'
uses-permission: name='android.permission.FOREGROUND_SERVICE_DATA_SYNC' maxSdkVersion='33'
uses-permission: name='android.permission.FOREGROUND_SERVICE_SPECIAL_USE'
uses-permission: name='android.permission.SCHEDULE_EXACT_ALARM'
uses-permission: name='android.permission.USE_BIOMETRIC'
uses-permission: name='android.permission.USE_FINGERPRINT'
Expand Down Expand Up @@ -81,6 +82,7 @@ application-icon-65534:'res/mipmap-anydpi-v26/ic_launcher.xml'
application: label='Thunderbird Beta' icon='res/mipmap-anydpi-v26/ic_launcher.xml'
uses-library-not-required:'com.sec.android.app.multiwindow'
launchable-activity: name='com.fsck.k9.activity.MessageList' label='' icon=''
property: name='android.app.PROPERTY_SPECIAL_USE_FGS_SUBTYPE' value='This service is used to maintain a continuous connection to an IMAP server to be able to provide instant notifications to the user when a new email arrives. Firebase Cloud Messaging is not suitable for this task, neither are mechanisms like AndroidX WorkManager. Other foreground service types aren't a good fit for this use case.'
uses-library-not-required:'androidx.window.extensions'
uses-library-not-required:'androidx.window.sidecar'
feature-group: label=''
Expand Down
4 changes: 3 additions & 1 deletion app-thunderbird/badging/fullDaily-badging.txt
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,8 @@ uses-permission: name='android.permission.INTERNET'
uses-permission: name='android.permission.VIBRATE'
uses-permission: name='android.permission.WAKE_LOCK'
uses-permission: name='android.permission.FOREGROUND_SERVICE'
uses-permission: name='android.permission.FOREGROUND_SERVICE_DATA_SYNC'
uses-permission: name='android.permission.FOREGROUND_SERVICE_DATA_SYNC' maxSdkVersion='33'
uses-permission: name='android.permission.FOREGROUND_SERVICE_SPECIAL_USE'
uses-permission: name='android.permission.SCHEDULE_EXACT_ALARM'
uses-permission: name='android.permission.USE_BIOMETRIC'
uses-permission: name='android.permission.USE_FINGERPRINT'
Expand Down Expand Up @@ -81,6 +82,7 @@ application-icon-65534:'res/mipmap-anydpi-v26/ic_launcher.xml'
application: label='Thunderbird Daily' icon='res/mipmap-anydpi-v26/ic_launcher.xml'
uses-library-not-required:'com.sec.android.app.multiwindow'
launchable-activity: name='com.fsck.k9.activity.MessageList' label='' icon=''
property: name='android.app.PROPERTY_SPECIAL_USE_FGS_SUBTYPE' value='This service is used to maintain a continuous connection to an IMAP server to be able to provide instant notifications to the user when a new email arrives. Firebase Cloud Messaging is not suitable for this task, neither are mechanisms like AndroidX WorkManager. Other foreground service types aren't a good fit for this use case.'
uses-library-not-required:'androidx.window.extensions'
uses-library-not-required:'androidx.window.sidecar'
feature-group: label=''
Expand Down
4 changes: 3 additions & 1 deletion app-thunderbird/badging/fullRelease-badging.txt
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,8 @@ uses-permission: name='android.permission.INTERNET'
uses-permission: name='android.permission.VIBRATE'
uses-permission: name='android.permission.WAKE_LOCK'
uses-permission: name='android.permission.FOREGROUND_SERVICE'
uses-permission: name='android.permission.FOREGROUND_SERVICE_DATA_SYNC'
uses-permission: name='android.permission.FOREGROUND_SERVICE_DATA_SYNC' maxSdkVersion='33'
uses-permission: name='android.permission.FOREGROUND_SERVICE_SPECIAL_USE'
uses-permission: name='android.permission.SCHEDULE_EXACT_ALARM'
uses-permission: name='android.permission.USE_BIOMETRIC'
uses-permission: name='android.permission.USE_FINGERPRINT'
Expand Down Expand Up @@ -81,6 +82,7 @@ application-icon-65534:'res/mipmap-anydpi-v26/ic_launcher.xml'
application: label='Thunderbird' icon='res/mipmap-anydpi-v26/ic_launcher.xml'
uses-library-not-required:'com.sec.android.app.multiwindow'
launchable-activity: name='com.fsck.k9.activity.MessageList' label='' icon=''
property: name='android.app.PROPERTY_SPECIAL_USE_FGS_SUBTYPE' value='This service is used to maintain a continuous connection to an IMAP server to be able to provide instant notifications to the user when a new email arrives. Firebase Cloud Messaging is not suitable for this task, neither are mechanisms like AndroidX WorkManager. Other foreground service types aren't a good fit for this use case.'
uses-library-not-required:'androidx.window.extensions'
uses-library-not-required:'androidx.window.sidecar'
feature-group: label=''
Expand Down
12 changes: 9 additions & 3 deletions legacy/common/src/main/AndroidManifest.xml
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,8 @@
<uses-permission android:name="android.permission.VIBRATE" />
<uses-permission android:name="android.permission.WAKE_LOCK" />
<uses-permission android:name="android.permission.FOREGROUND_SERVICE" />
<uses-permission android:name="android.permission.FOREGROUND_SERVICE_DATA_SYNC" />
<uses-permission android:name="android.permission.FOREGROUND_SERVICE_DATA_SYNC" android:maxSdkVersion="33" />
<uses-permission android:name="android.permission.FOREGROUND_SERVICE_SPECIAL_USE" />
<uses-permission android:name="android.permission.SCHEDULE_EXACT_ALARM"
tools:ignore="ProtectedPermissions"
/>
Expand Down Expand Up @@ -242,8 +243,13 @@
<service
android:name="com.fsck.k9.controller.push.PushService"
android:exported="false"
android:foregroundServiceType="dataSync"
/>
android:foregroundServiceType="dataSync|specialUse"
>
<property
android:name="android.app.PROPERTY_SPECIAL_USE_FGS_SUBTYPE"
android:value="This service is used to maintain a continuous connection to an IMAP server to be able to provide instant notifications to the user when a new email arrives. Firebase Cloud Messaging is not suitable for this task, neither are mechanisms like AndroidX WorkManager. Other foreground service types aren't a good fit for this use case."
/>
</service>

<provider
android:name="com.fsck.k9.provider.AttachmentProvider"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -66,7 +66,9 @@ class PushService : Service() {
val notificationId = pushNotificationManager.notificationId
val notification = pushNotificationManager.createForegroundNotification()

if (Build.VERSION.SDK_INT >= 29) {
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.UPSIDE_DOWN_CAKE) {
startForeground(notificationId, notification, ServiceInfo.FOREGROUND_SERVICE_TYPE_SPECIAL_USE)
} else if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.Q) {
startForeground(notificationId, notification, ServiceInfo.FOREGROUND_SERVICE_TYPE_DATA_SYNC)
} else {
startForeground(notificationId, notification)
Expand Down

0 comments on commit 8452cda

Please sign in to comment.