Commit 187cb28d authored by Max Lv's avatar Max Lv

Fix an issue of NAT mode

If call notify() after startForeground() on the same notification id, the
service becomes not that "foreground" and would be killed by system if the
activity is removed from the recent list.
parent 2840a75c
...@@ -30,7 +30,6 @@ class ShadowsocksNotification(private val service: BaseService, profileName: Str ...@@ -30,7 +30,6 @@ class ShadowsocksNotification(private val service: BaseService, profileName: Str
} }
private var lockReceiver: BroadcastReceiver = _ private var lockReceiver: BroadcastReceiver = _
private var callbackRegistered: Boolean = _ private var callbackRegistered: Boolean = _
private var started: Boolean = _
private val builder = new NotificationCompat.Builder(service) private val builder = new NotificationCompat.Builder(service)
.setWhen(0) .setWhen(0)
...@@ -77,9 +76,8 @@ class ShadowsocksNotification(private val service: BaseService, profileName: Str ...@@ -77,9 +76,8 @@ class ShadowsocksNotification(private val service: BaseService, profileName: Str
show() show()
} else if (forceShow) show() } else if (forceShow) show()
def show() = if (started) nm.notify(1, builder.build) else { def show() = {
service.startForeground(1, builder.build) service.startForeground(1, builder.build)
started = true
} }
def destroy() { def destroy() {
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment