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