]> git.ipfire.org Git - thirdparty/strongswan.git/commitdiff
android: Suppress deprecation warning because of stopForeground()
authorTobias Brunner <tobias@strongswan.org>
Wed, 5 Feb 2025 16:02:42 +0000 (17:02 +0100)
committerTobias Brunner <tobias@strongswan.org>
Tue, 18 Feb 2025 13:12:43 +0000 (14:12 +0100)
src/frontends/android/app/src/main/java/org/strongswan/android/logic/CharonVpnService.java

index 03e59f7ee2ad753ed07d7f230548932a7d8baf62..314678eded4a594e63e27450aaffb692e994b282 100644 (file)
@@ -399,11 +399,24 @@ public class CharonVpnService extends VpnService implements Runnable, VpnStateSe
                        public void run()
                        {
                                mShowNotification = false;
-                               stopForeground(true);
+                               if (Build.VERSION.SDK_INT < Build.VERSION_CODES.N)
+                               {
+                                       stopForegroundCompat();
+                               }
+                               else
+                               {
+                                       stopForeground(STOP_FOREGROUND_REMOVE);
+                               }
                        }
                });
        }
 
+       @SuppressWarnings("deprecation")
+       private void stopForegroundCompat()
+       {
+               stopForeground(true);
+       }
+
        /**
         * Create a notification channel for Android 8+
         */