Skip to content

Commit

Permalink
Change foreground service type
Browse files Browse the repository at this point in the history
  • Loading branch information
shiftrot committed May 6, 2024
1 parent 81a4a05 commit 67d59c9
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 6 deletions.
9 changes: 5 additions & 4 deletions term/src/main/AndroidManifest.xml
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@
tools:ignore="ScopedStorage" />
<uses-permission android:name="android.permission.ACCESS_SUPERUSER"/>
<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_SPECIAL_USE"/>
<uses-permission android:name="android.permission.REQUEST_IGNORE_BATTERY_OPTIMIZATIONS"/>
<uses-permission android:name="android.permission.POST_NOTIFICATIONS"/>
<uses-permission
Expand Down Expand Up @@ -182,12 +182,13 @@
android:label="Local HTML Viewer"/>

<service android:name=".TermService"
android:foregroundServiceType="dataSync"
android:permission="android.permission.FOREGROUND_SERVICE_TYPE_DATA_SYNC"
android:foregroundServiceType="specialUse"
android:permission="android.permission.FOREGROUND_SERVICE_TYPE_SPECIAL_USE"
android:exported="false">
<property android:name="android.app.PROPERTY_SPECIAL_USE_FGS_SUBTYPE"
android:value="Prevents this app from being forced to close in the background."/>
<intent-filter>
<action android:name="jackpal.androidterm.action.START_TERM.v1"/>

<category android:name="android.intent.category.DEFAULT"/>
</intent-filter>
</service>
Expand Down
4 changes: 2 additions & 2 deletions term/src/main/java/jackpal/androidterm/TermService.java
Original file line number Diff line number Diff line change
Expand Up @@ -215,8 +215,8 @@ private boolean startForegroundServiceNotification(boolean showStatusIcon) {
Notification notification = buildNotification(channelId, showStatusIcon);
if (notification != null) {
if (useNotificationForgroundService()) {
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.Q) {
startForeground(RUNNING_NOTIFICATION, notification, ServiceInfo.FOREGROUND_SERVICE_TYPE_DATA_SYNC);
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.UPSIDE_DOWN_CAKE) {
startForeground(RUNNING_NOTIFICATION, notification, ServiceInfo.FOREGROUND_SERVICE_TYPE_SPECIAL_USE);
} else {
startForeground(RUNNING_NOTIFICATION, notification);
}
Expand Down

0 comments on commit 67d59c9

Please sign in to comment.