Skip to content

Commit 7619ecd

Browse files
author
ukanth
committed
changes for target sdk 34
1 parent 84813f4 commit 7619ecd

File tree

2 files changed

+13
-2
lines changed

2 files changed

+13
-2
lines changed

app/src/main/AndroidManifest.xml

+8-1
Original file line numberDiff line numberDiff line change
@@ -38,6 +38,7 @@
3838
<uses-permission android:name="android.permission.INTERNET" />
3939
<uses-permission android:name="android.permission.ACCESS_WIFI_STATE" />
4040

41+
<uses-permission android:name="android.permission.FOREGROUND_SERVICE_SPECIAL_USE"></uses-permission>
4142
<!-- Allows access to bluetooth tethering state -->
4243
<uses-permission android:name="android.permission.BLUETOOTH" />
4344
<uses-permission android:name="android.permission.BLUETOOTH_ADMIN"/>
@@ -195,8 +196,14 @@
195196

196197
<service
197198
android:name=".service.FirewallService"
199+
android:foregroundServiceType="specialUse"
198200
android:exported="true"
199-
android:launchMode="singleTop" />
201+
android:launchMode="singleTop" >
202+
203+
<property android:name="android.app.PROPERTY_SPECIAL_USE_FGS_SUBTYPE"
204+
android:value="Firewall service"/>
205+
206+
</service>
200207

201208
<service
202209
android:name=".service.ToggleTileService"

app/src/main/java/dev/ukanth/ufirewall/service/FirewallService.java

+5-1
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,7 @@
11
package dev.ukanth.ufirewall.service;
22

3+
import static android.content.pm.ServiceInfo.FOREGROUND_SERVICE_TYPE_SPECIAL_USE;
4+
35
import android.app.Notification;
46
import android.app.NotificationChannel;
57
import android.app.NotificationManager;
@@ -150,7 +152,9 @@ private void addNotification() {
150152
.build();
151153

152154
//if(G.activeNotification()) {
153-
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.O) {
155+
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.UPSIDE_DOWN_CAKE) {
156+
startForeground(NOTIFICATION_ID, notification, FOREGROUND_SERVICE_TYPE_SPECIAL_USE);
157+
} else if(Build.VERSION.SDK_INT >= Build.VERSION_CODES.O ) {
154158
startForeground(NOTIFICATION_ID, notification);
155159
} else {
156160
manager.notify(NOTIFICATION_ID, notification);

0 commit comments

Comments
 (0)