From bae5e9d06bb86038e340a6dcf8ee2b60a3daf980 Mon Sep 17 00:00:00 2001 From: Mygod Date: Fri, 22 Jul 2016 15:44:11 +0800 Subject: [PATCH] Check bgService in ShadowsocksTileService --- .../com/github/shadowsocks/ShadowsocksTileService.scala | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/src/main/scala/com/github/shadowsocks/ShadowsocksTileService.scala b/src/main/scala/com/github/shadowsocks/ShadowsocksTileService.scala index 52ca468a..ae7cdad0 100644 --- a/src/main/scala/com/github/shadowsocks/ShadowsocksTileService.scala +++ b/src/main/scala/com/github/shadowsocks/ShadowsocksTileService.scala @@ -46,7 +46,7 @@ final class ShadowsocksTileService extends TileService with ServiceBoundContext } } - override def onServiceConnected = callback.stateChanged(bgService.getState, null) + override def onServiceConnected() = callback.stateChanged(bgService.getState, null) override def onCreate { super.onCreate @@ -66,9 +66,9 @@ final class ShadowsocksTileService extends TileService with ServiceBoundContext detachService // just in case the user switches to NAT mode, also saves battery } - override def onClick = if (isLocked) unlockAndRun(toggle) else toggle() + override def onClick() = if (isLocked) unlockAndRun(toggle) else toggle() - private def toggle() = bgService.getState match { + private def toggle() = if (bgService != null) bgService.getState match { case State.STOPPED => Utils.startSsService(this) case State.CONNECTED => Utils.stopSsService(this) case _ => // ignore