This reverts commit b833cb6267.
This commit is contained in:
@@ -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()
|
||||
|
||||
Reference in New Issue
Block a user