summaryrefslogtreecommitdiffstats
path: root/core/java/android/app/ApplicationThreadNative.java
diff options
context:
space:
mode:
authorChristopher Tate <ctate@google.com>2009-05-14 11:12:14 -0700
committerChristopher Tate <ctate@google.com>2009-05-31 13:10:03 -0700
commit181fafaf48208978b8ba2022683ffa78aaeddde1 (patch)
tree7c062847d418415e28813e70aac53c8c47e4ff69 /core/java/android/app/ApplicationThreadNative.java
parentc01159bb00f7273f9b051dfbbe6bc10d54d3a846 (diff)
downloadframeworks_base-181fafaf48208978b8ba2022683ffa78aaeddde1.zip
frameworks_base-181fafaf48208978b8ba2022683ffa78aaeddde1.tar.gz
frameworks_base-181fafaf48208978b8ba2022683ffa78aaeddde1.tar.bz2
Retool the backup process to use a new 'BackupAgent' class
Backups will be handled by launching the application in a special mode under which no activities or services will be started, only the BackupAgent subclass named in the app's android:backupAgent manifest property. This takes the place of the BackupService class used earlier during development. In the cases of *full* backup or restore, an application that does not supply its own BackupAgent will be launched in a restricted manner; in particular, it will be using the default Application class rather than any manifest-declared one. This ensures that the app is not running any code that may try to manipulate its data while the backup system reads/writes its data set.
Diffstat (limited to 'core/java/android/app/ApplicationThreadNative.java')
-rw-r--r--core/java/android/app/ApplicationThreadNative.java35
1 files changed, 33 insertions, 2 deletions
diff --git a/core/java/android/app/ApplicationThreadNative.java b/core/java/android/app/ApplicationThreadNative.java
index f243185..e28fd0f 100644
--- a/core/java/android/app/ApplicationThreadNative.java
+++ b/core/java/android/app/ApplicationThreadNative.java
@@ -230,11 +230,13 @@ public abstract class ApplicationThreadNative extends Binder
IBinder binder = data.readStrongBinder();
IInstrumentationWatcher testWatcher = IInstrumentationWatcher.Stub.asInterface(binder);
int testMode = data.readInt();
+ boolean restrictedBackupMode = (data.readInt() != 0);
Configuration config = Configuration.CREATOR.createFromParcel(data);
HashMap<String, IBinder> services = data.readHashMap(null);
bindApplication(packageName, info,
providers, testName, profileName,
- testArgs, testWatcher, testMode, config, services);
+ testArgs, testWatcher, testMode, restrictedBackupMode,
+ config, services);
return true;
}
@@ -339,6 +341,15 @@ public abstract class ApplicationThreadNative extends Binder
setSchedulingGroup(group);
return true;
}
+
+ case SCHEDULE_CREATE_BACKUP_AGENT_TRANSACTION:
+ {
+ data.enforceInterface(IApplicationThread.descriptor);
+ ApplicationInfo appInfo = ApplicationInfo.CREATOR.createFromParcel(data);
+ int backupMode = data.readInt();
+ scheduleCreateBackupAgent(appInfo, backupMode);
+ return true;
+ }
}
return super.onTransact(code, data, reply, flags);
@@ -492,6 +503,24 @@ class ApplicationThreadProxy implements IApplicationThread {
data.recycle();
}
+ public final void scheduleCreateBackupAgent(ApplicationInfo app, int backupMode)
+ throws RemoteException {
+ Parcel data = Parcel.obtain();
+ data.writeInterfaceToken(IApplicationThread.descriptor);
+ app.writeToParcel(data, 0);
+ data.writeInt(backupMode);
+ mRemote.transact(SCHEDULE_CREATE_BACKUP_AGENT_TRANSACTION, data, null, 0);
+ data.recycle();
+ }
+
+ public final void scheduleDestroyBackupAgent(ApplicationInfo app) throws RemoteException {
+ Parcel data = Parcel.obtain();
+ data.writeInterfaceToken(IApplicationThread.descriptor);
+ app.writeToParcel(data, 0);
+ mRemote.transact(SCHEDULE_DESTROY_BACKUP_AGENT_TRANSACTION, data, null, 0);
+ data.recycle();
+ }
+
public final void scheduleCreateService(IBinder token, ServiceInfo info)
throws RemoteException {
Parcel data = Parcel.obtain();
@@ -551,7 +580,8 @@ class ApplicationThreadProxy implements IApplicationThread {
public final void bindApplication(String packageName, ApplicationInfo info,
List<ProviderInfo> providers, ComponentName testName,
String profileName, Bundle testArgs, IInstrumentationWatcher testWatcher, int debugMode,
- Configuration config, Map<String, IBinder> services) throws RemoteException {
+ boolean restrictedBackupMode, Configuration config,
+ Map<String, IBinder> services) throws RemoteException {
Parcel data = Parcel.obtain();
data.writeInterfaceToken(IApplicationThread.descriptor);
data.writeString(packageName);
@@ -567,6 +597,7 @@ class ApplicationThreadProxy implements IApplicationThread {
data.writeBundle(testArgs);
data.writeStrongInterface(testWatcher);
data.writeInt(debugMode);
+ data.writeInt(restrictedBackupMode ? 1 : 0);
config.writeToParcel(data, 0);
data.writeMap(services);
mRemote.transact(BIND_APPLICATION_TRANSACTION, data, null,