Commit 849b7f18 authored by Max Lv's avatar Max Lv

add backup agent support

parent febff658
...@@ -19,8 +19,12 @@ ...@@ -19,8 +19,12 @@
android:name=".ShadowsocksApplication" android:name=".ShadowsocksApplication"
android:hardwareAccelerated="true" android:hardwareAccelerated="true"
android:icon="@drawable/ic_launcher" android:icon="@drawable/ic_launcher"
android:backupAgent=".ShadowsocksBackupAgent"
android:label="@string/app_name"> android:label="@string/app_name">
<meta-data android:name="com.google.android.backup.api_key"
android:value="AEdPqrEAAAAI_zVxZthz2HDuz9toTvkYvL0L5GA-OjeUIfBeXg" />
<activity <activity
android:name=".Shadowsocks" android:name=".Shadowsocks"
android:label="@string/app_name" android:label="@string/app_name"
......
...@@ -65,6 +65,7 @@ import org.jraf.android.backport.switchwidget.Switch ...@@ -65,6 +65,7 @@ import org.jraf.android.backport.switchwidget.Switch
import android.content.pm.{PackageInfo, PackageManager} import android.content.pm.{PackageInfo, PackageManager}
import android.net.{Uri, VpnService} import android.net.{Uri, VpnService}
import android.webkit.{WebViewClient, WebView} import android.webkit.{WebViewClient, WebView}
import android.app.backup.BackupManager
object Shadowsocks { object Shadowsocks {
...@@ -513,6 +514,7 @@ class Shadowsocks ...@@ -513,6 +514,7 @@ class Shadowsocks
super.onDestroy() super.onDestroy()
Crouton.cancelAllCroutons() Crouton.cancelAllCroutons()
unregisterReceiver(receiver) unregisterReceiver(receiver)
(new BackupManager(this)).dataChanged()
} }
def reset() { def reset() {
......
package com.github.shadowsocks
import android.app.backup.{SharedPreferencesBackupHelper, BackupAgentHelper}
class ShadowsocksBackupAgent extends BackupAgentHelper {
// The names of the SharedPreferences groups that the application maintains. These
// are the same strings that are passed to getSharedPreferences(String, int).
val PREFS_DISPLAY = "com.github.shadowsocks_preferences"
// An arbitrary string used within the BackupAgentHelper implementation to
// identify the SharedPreferencesBackupHelper's data.
val MY_PREFS_BACKUP_KEY = "com.github.shadowsocks"
override def onCreate() {
val helper = new SharedPreferencesBackupHelper(this, PREFS_DISPLAY)
addHelper(MY_PREFS_BACKUP_KEY, helper)
}
}
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