Remove .aidl.Config and persisting SharedPreferences (#742)

Previously a profile can exist in the following forms:

* `.database.Profile` used for everything backend;
* `.ShadowsocksSettings` which uses Preferences to provide UI to tweak settings;
* `.aidl.Config` used for IPC;
* `<data dir>/shared_pref/com.github.shadowsocks_preferences.xml` which exists for no apparent reason.

Thus long code block can be seen whose purpose is simply converting the data from one form to another. This commit intends to remove the latter two by:

1. Using profile ID and take advantage of fs r/w lock SQLite uses for IPC and better extensibility;
2. Stop persisting redundant fields in the preferences file and update database directly.
This commit is contained in:
Mygod
2016-07-05 01:07:09 -05:00
committed by Max Lv
parent 8515edff60
commit c480137dec
18 changed files with 414 additions and 630 deletions
@@ -58,11 +58,11 @@ class ShadowsocksRunnerService extends Service with ServiceBoundContext {
}
def startBackgroundService() {
if (app.isNatEnabled) bgService.use(ConfigUtils.loadFromSharedPreferences) else {
if (app.isNatEnabled) bgService.use(app.profileId) else {
val intent = VpnService.prepare(ShadowsocksRunnerService.this)
if (intent == null) {
if (bgService != null) {
bgService.use(ConfigUtils.loadFromSharedPreferences)
bgService.use(app.profileId)
}
}
}