Skip to content

Commit 90f2460

Browse files
committed
usbip: Use special use foreground service type
1 parent ad61ead commit 90f2460

2 files changed

Lines changed: 6 additions & 3 deletions

File tree

app/src/main/AndroidManifest.xml

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,6 @@
1515
<uses-permission android:name="android.permission.FOREGROUND_SERVICE" />
1616
<uses-permission android:name="android.permission.FOREGROUND_SERVICE_SYSTEM_EXEMPTED" />
1717
<uses-permission android:name="android.permission.FOREGROUND_SERVICE_SPECIAL_USE" />
18-
<uses-permission android:name="android.permission.FOREGROUND_SERVICE_CONNECTED_DEVICE" />
1918
<uses-permission android:name="android.permission.POST_NOTIFICATIONS" />
2019
<uses-permission android:name="android.permission.RECEIVE_BOOT_COMPLETED" />
2120
<uses-permission android:name="android.permission.CHANGE_NETWORK_STATE" />
@@ -150,7 +149,11 @@
150149
<service
151150
android:name=".bg.USBIPService"
152151
android:exported="false"
153-
android:foregroundServiceType="connectedDevice" />
152+
android:foregroundServiceType="specialUse">
153+
<property
154+
android:name="android.app.PROPERTY_SPECIAL_USE_FGS_SUBTYPE"
155+
android:value="usbip" />
156+
</service>
154157

155158
<receiver
156159
android:name=".bg.BootReceiver"

app/src/main/java/io/nekohasekai/sfa/bg/USBIPService.kt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -141,6 +141,6 @@ class USBIPService : Service() {
141141

142142
private fun pendingIntentFlags() = if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.M) PendingIntent.FLAG_IMMUTABLE else 0
143143

144-
private fun foregroundServiceType() = if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.R) ServiceInfo.FOREGROUND_SERVICE_TYPE_CONNECTED_DEVICE else 0
144+
private fun foregroundServiceType() = if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.R) ServiceInfo.FOREGROUND_SERVICE_TYPE_SPECIAL_USE else 0
145145
}
146146
}

0 commit comments

Comments
 (0)