add backup agent support

This commit is contained in:
Max Lv
2013-06-04 13:06:42 +08:00
parent febff65896
commit 849b7f1873
3 changed files with 25 additions and 0 deletions
+4
View File
@@ -19,8 +19,12 @@
android:name=".ShadowsocksApplication"
android:hardwareAccelerated="true"
android:icon="@drawable/ic_launcher"
android:backupAgent=".ShadowsocksBackupAgent"
android:label="@string/app_name">
<meta-data android:name="com.google.android.backup.api_key"
android:value="AEdPqrEAAAAI_zVxZthz2HDuz9toTvkYvL0L5GA-OjeUIfBeXg" />
<activity
android:name=".Shadowsocks"
android:label="@string/app_name"
@@ -65,6 +65,7 @@ import org.jraf.android.backport.switchwidget.Switch
import android.content.pm.{PackageInfo, PackageManager}
import android.net.{Uri, VpnService}
import android.webkit.{WebViewClient, WebView}
import android.app.backup.BackupManager
object Shadowsocks {
@@ -513,6 +514,7 @@ class Shadowsocks
super.onDestroy()
Crouton.cancelAllCroutons()
unregisterReceiver(receiver)
(new BackupManager(this)).dataChanged()
}
def reset() {
@@ -0,0 +1,19 @@
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)
}
}