summaryrefslogtreecommitdiffstats
path: root/core/java/android/backup
diff options
context:
space:
mode:
Diffstat (limited to 'core/java/android/backup')
-rw-r--r--core/java/android/backup/BackupService.java137
-rw-r--r--core/java/android/backup/IBackupManager.aidl16
-rw-r--r--core/java/android/backup/IBackupService.aidl59
3 files changed, 15 insertions, 197 deletions
diff --git a/core/java/android/backup/BackupService.java b/core/java/android/backup/BackupService.java
deleted file mode 100644
index 50a5921..0000000
--- a/core/java/android/backup/BackupService.java
+++ /dev/null
@@ -1,137 +0,0 @@
-/*
- * Copyright (C) 2009 The Android Open Source Project
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-package android.backup;
-
-import android.annotation.SdkConstant;
-import android.annotation.SdkConstant.SdkConstantType;
-import android.app.Service;
-import android.backup.IBackupService;
-import android.content.Intent;
-import android.os.IBinder;
-import android.os.ParcelFileDescriptor;
-import android.os.RemoteException;
-import android.util.Log;
-
-/**
- * This is the central interface between an application and Android's
- * settings backup mechanism.
- *
- * In order to use the backup service, your application must implement a
- * subclass of BackupService, and declare an intent filter
- * in the application manifest specifying that your BackupService subclass
- * handles the {@link BackupService#SERVICE_ACTION} intent action. For example:
- *
- * <pre class="prettyprint">
- * &lt;!-- Use the class "MyBackupService" to perform backups for my app --&gt;
- * &lt;service android:name=".MyBackupService"&gt;
- * &lt;intent-filter&gt;
- * &lt;action android:name="android.backup.BackupService.SERVICE" /&gt;
- * &lt;/intent-filter&gt;
- * &lt;/service&gt;</pre>
- *
- * @hide pending API solidification
- */
-
-public abstract class BackupService extends Service {
- /**
- * Service Action: Participate in the backup infrastructure. Applications
- * that wish to use the Android backup mechanism must provide an exported
- * subclass of BackupService and give it an {@link android.content.IntentFilter
- * IntentFilter} that accepts this action.
- */
- @SdkConstant(SdkConstantType.SERVICE_ACTION)
- public static final String SERVICE_ACTION = "android.backup.BackupService.SERVICE";
-
- /**
- * The application is being asked to write any data changed since the
- * last time it performed a backup operation. The state data recorded
- * during the last backup pass is provided in the oldState file descriptor.
- * If oldState is null, no old state is available and the application should perform
- * a full backup. In both cases, a representation of the final backup state after
- * this pass should be written to the file pointed to by the newStateFd file descriptor.
- *
- * @param oldState An open, read-only ParcelFileDescriptor pointing to the last backup
- * state provided by the application. May be null, in which
- * case no prior state is being provided and the application should
- * perform a full backup.
- * @param data An open, read/write ParcelFileDescriptor pointing to the backup data
- * destination. Typically the application will use backup helper
- * classes to write to this file.
- * @param newState An open, read/write ParcelFileDescriptor pointing to an empty
- * file. The application should record the final backup state
- * here after writing the requested data to dataFd.
- */
- public abstract void onBackup(ParcelFileDescriptor oldState, BackupDataOutput data,
- ParcelFileDescriptor newState);
-
- /**
- * The application is being restored from backup, and should replace any
- * existing data with the contents of the backup. The backup data is
- * provided in the file pointed to by the dataFd file descriptor. Once
- * the restore is finished, the application should write a representation
- * of the final state to the newStateFd file descriptor,
- *
- * @param data An open, read-only ParcelFileDescriptor pointing to a full snapshot
- * of the application's data.
- * @param newState An open, read/write ParcelFileDescriptor pointing to an empty
- * file. The application should record the final backup state
- * here after restoring its data from dataFd.
- */
- public abstract void onRestore(ParcelFileDescriptor /* TODO: BackupDataInput */ data, ParcelFileDescriptor newState);
-
-
- // ----- Core implementation -----
-
- /**
- * Returns the private interface called by the backup system. Applications will
- * not typically override this.
- */
- public IBinder onBind(Intent intent) {
- if (intent.getAction().equals(SERVICE_ACTION)) {
- return mBinder;
- }
- return null;
- }
-
- private final IBinder mBinder = new BackupServiceBinder().asBinder();
-
- // ----- IBackupService binder interface -----
- private class BackupServiceBinder extends IBackupService.Stub {
- public void doBackup(ParcelFileDescriptor oldState,
- ParcelFileDescriptor data,
- ParcelFileDescriptor newState) throws RemoteException {
- // !!! TODO - real implementation; for now just invoke the callbacks directly
- Log.v("BackupServiceBinder", "doBackup() invoked");
- BackupDataOutput output = new BackupDataOutput(BackupService.this,
- data.getFileDescriptor());
- try {
- BackupService.this.onBackup(oldState, output, newState);
- } catch (RuntimeException ex) {
- Log.d("BackupService", "onBackup ("
- + BackupService.this.getClass().getName() + ") threw", ex);
- throw ex;
- }
- }
-
- public void doRestore(ParcelFileDescriptor data,
- ParcelFileDescriptor newState) throws RemoteException {
- // !!! TODO - real implementation; for now just invoke the callbacks directly
- Log.v("BackupServiceBinder", "doRestore() invoked");
- BackupService.this.onRestore(data, newState);
- }
- }
-}
diff --git a/core/java/android/backup/IBackupManager.aidl b/core/java/android/backup/IBackupManager.aidl
index cf22798..3468d70 100644
--- a/core/java/android/backup/IBackupManager.aidl
+++ b/core/java/android/backup/IBackupManager.aidl
@@ -34,8 +34,22 @@ interface IBackupManager {
oneway void dataChanged(String packageName);
/**
+ * Notifies the Backup Manager Service that an agent has become available. This
+ * method is only invoked by the Activity Manager.
+ * !!! TODO: permission
+ */
+ oneway void agentConnected(String packageName, IBinder agent);
+
+ /**
+ * Notify the Backup Manager Service that an agent has unexpectedly gone away.
+ * This method is only invoked by the Activity Manager.
+ * !!! TODO: permission
+ */
+ oneway void agentDisconnected(String packageName);
+
+ /**
* Schedule a full backup of the given package.
- * !!! TODO: protect with a signature-or-system permission?
+ * !!! TODO: permission
*/
oneway void scheduleFullBackup(String packageName);
}
diff --git a/core/java/android/backup/IBackupService.aidl b/core/java/android/backup/IBackupService.aidl
deleted file mode 100644
index 1bde8ea..0000000
--- a/core/java/android/backup/IBackupService.aidl
+++ /dev/null
@@ -1,59 +0,0 @@
-/*
- * Copyright 2009, The Android Open Source Project
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-package android.backup;
-
-import android.os.ParcelFileDescriptor;
-
-/**
- * Interface presented by applications being asked to participate in the
- * backup & restore mechanism. End user code does not typically implement
- * this interface; they subclass BackupService instead.
- *
- * {@hide}
- */
-interface IBackupService {
- /**
- * Request that the app perform an incremental backup.
- *
- * @param oldState Read-only file containing the description blob of the
- * app's data state as of the last backup operation's completion.
- * This file is empty or invalid when a full backup is being
- * requested.
- *
- * @param data Read-write file, empty when onBackup() is called, that
- * is the data destination for this backup pass's incrementals.
- *
- * @param newState Read-write file, empty when onBackup() is called,
- * where the new state blob is to be recorded.
- */
- void doBackup(in ParcelFileDescriptor oldState,
- in ParcelFileDescriptor data,
- in ParcelFileDescriptor newState);
-
- /**
- * Restore an entire data snapshot to the application.
- *
- * @param data Read-only file containing the full data snapshot of the
- * app's backup. This is to be a <i>replacement</i> of the app's
- * current data, not to be merged into it.
- *
- * @param newState Read-write file, empty when onRestore() is called,
- * that is to be written with the state description that holds after
- * the restore has been completed.
- */
- void doRestore(in ParcelFileDescriptor data, in ParcelFileDescriptor newState);
-}