From add1c96d5c469664753e5f0aabac89f58124c2cb Mon Sep 17 00:00:00 2001 From: Mygod Date: Thu, 19 Sep 2019 11:28:04 +0800 Subject: [PATCH] Show notification unconditionally since cancellation is available --- .../be/mygod/vpnhotspot/LocalOnlyHotspotService.kt | 11 +++-------- 1 file changed, 3 insertions(+), 8 deletions(-) diff --git a/mobile/src/main/java/be/mygod/vpnhotspot/LocalOnlyHotspotService.kt b/mobile/src/main/java/be/mygod/vpnhotspot/LocalOnlyHotspotService.kt index 5a7ba26c..fc6c36cc 100644 --- a/mobile/src/main/java/be/mygod/vpnhotspot/LocalOnlyHotspotService.kt +++ b/mobile/src/main/java/be/mygod/vpnhotspot/LocalOnlyHotspotService.kt @@ -43,10 +43,7 @@ class LocalOnlyHotspotService : IpNeighbourMonitoringService(), CoroutineScope { null -> { } // stopped "" -> { WifiApManager.cancelLocalOnlyHotspotRequest() - reservation?.close() - updateNotification() - stopService() - iface = null + reservation?.close() ?: stopService() } else -> reservation!!.close() } @@ -86,10 +83,7 @@ class LocalOnlyHotspotService : IpNeighbourMonitoringService(), CoroutineScope { override fun onStartCommand(intent: Intent?, flags: Int, startId: Int): Int { if (binder.iface != null) return START_STICKY binder.iface = "" - // show invisible foreground notification on television to avoid being killed - // or for bug with airplane mode on API 28-: https://issuetracker.google.com/issues/128350148 - if (app.uiMode.currentModeType == Configuration.UI_MODE_TYPE_TELEVISION || - Build.VERSION.SDK_INT < 29) updateNotification() + updateNotification() // show invisible foreground notification to avoid being killed // throws IllegalStateException if the caller attempts to start the LocalOnlyHotspot while they // have an outstanding request. // https://android.googlesource.com/platform/frameworks/opt/net/wifi/+/53e0284/service/java/com/android/server/wifi/WifiServiceImpl.java#1192 @@ -157,6 +151,7 @@ class LocalOnlyHotspotService : IpNeighbourMonitoringService(), CoroutineScope { } private fun stopService() { + binder.iface = null unregisterReceiver() ServiceNotification.stopForeground(this) stopSelf()