Commit c92d66d9 authored by Mygod's avatar Mygod

Revert "Refine #530 again and again" and probably fix #530

This reverts commit b833cb62.
parent b833cb62
......@@ -118,7 +118,6 @@
<service
android:name=".ShadowsocksRunnerService"
android:process=":bg"
android:exported="false">
</service>
......
......@@ -9,4 +9,5 @@ interface IShadowsocksService {
oneway void unregisterCallback(IShadowsocksServiceCallback cb);
oneway void use(in int profileId);
void useSync(in int profileId);
}
......@@ -114,6 +114,8 @@ trait BaseService extends Service {
case _ => Log.w(BaseService.this.getClass.getSimpleName, "Illegal state when invoking use: " + state)
}
})
override def useSync(profileId: Int) = use(profileId)
}
def checkProfile(profile: Profile) = if (TextUtils.isEmpty(profile.host) || TextUtils.isEmpty(profile.password)) {
......
......@@ -54,17 +54,14 @@ class ShadowsocksRunnerService extends Service with ServiceBoundContext {
}
override def onServiceConnected() {
if (bgService != null) {
handler.postDelayed(() => if (bgService != null) {
if (app.isNatEnabled) startBackgroundService()
else if (VpnService.prepare(ShadowsocksRunnerService.this) == null) startBackgroundService()
}
handler.postDelayed(() => stopSelf() , 1000)
stopSelf()
}, 1000)
}
def startBackgroundService() = {
bgService.use(app.profileId)
bgService.getState // ensure the oneway call to use is finished
}
def startBackgroundService() = bgService.useSync(app.profileId)
override def onCreate() {
super.onCreate()
......
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