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

This reverts commit b833cb6267.
This commit is contained in:
Mygod
2016-07-12 15:56:32 +08:00
parent b833cb6267
commit c92d66d9f3
4 changed files with 7 additions and 8 deletions
-1
View File
@@ -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()