Fix compatibility with Android 14

This commit is contained in:
iKirby
2023-08-02 10:46:50 +08:00
committed by GitHub
parent 58bd31d6b7
commit 3ccf4d6def
3 changed files with 20 additions and 15 deletions

View File

@@ -4,6 +4,7 @@
<uses-permission android:name="android.permission.INTERNET" />
<uses-permission android:name="android.permission.FOREGROUND_SERVICE" />
<uses-permission android:name="android.permission.FOREGROUND_SERVICE_SPECIAL_USE" />
<uses-permission android:name="android.permission.POST_NOTIFICATIONS" />
<uses-permission android:name="android.permission.RECEIVE_BOOT_COMPLETED" />
<uses-permission android:name="android.permission.CHANGE_NETWORK_STATE" />
@@ -120,14 +121,23 @@
<service
android:name=".bg.VPNService"
android:exported="false"
android:foregroundServiceType="specialUse"
android:permission="android.permission.BIND_VPN_SERVICE">
<intent-filter>
<action android:name="android.net.VpnService" />
</intent-filter>
<property
android:name="android.app.PROPERTY_SPECIAL_USE_FGS_SUBTYPE"
android:value="vpn" />
</service>
<service
android:name=".bg.ProxyService"
android:exported="false" />
android:exported="false"
android:foregroundServiceType="specialUse">
<property
android:name="android.app.PROPERTY_SPECIAL_USE_FGS_SUBTYPE"
android:value="proxy" />
</service>
<receiver
android:name=".bg.BootReceiver"

View File

@@ -235,10 +235,10 @@ class BoxService(
status.value = Status.Starting
if (!receiverRegistered) {
service.registerReceiver(receiver, IntentFilter().apply {
ContextCompat.registerReceiver(service, receiver, IntentFilter().apply {
addAction(Action.SERVICE_CLOSE)
addAction(Action.SERVICE_RELOAD)
})
}, ContextCompat.RECEIVER_NOT_EXPORTED)
receiverRegistered = true
}