Merge change 3417 into donut
* changes: Adjust IBackupTransport interface
This commit is contained in:
@ -1,5 +1,6 @@
|
|||||||
package com.android.internal.backup;
|
package com.android.internal.backup;
|
||||||
|
|
||||||
|
import android.content.pm.PackageInfo;
|
||||||
import android.os.ParcelFileDescriptor;
|
import android.os.ParcelFileDescriptor;
|
||||||
import android.os.RemoteException;
|
import android.os.RemoteException;
|
||||||
|
|
||||||
@ -12,6 +13,7 @@ import android.os.RemoteException;
|
|||||||
public class AdbTransport extends IBackupTransport.Stub {
|
public class AdbTransport extends IBackupTransport.Stub {
|
||||||
|
|
||||||
public int startSession() throws RemoteException {
|
public int startSession() throws RemoteException {
|
||||||
|
// TODO Auto-generated method stub
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -20,7 +22,7 @@ public class AdbTransport extends IBackupTransport.Stub {
|
|||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
public int performBackup(String packageName, ParcelFileDescriptor data)
|
public int performBackup(PackageInfo packageInfo, ParcelFileDescriptor data)
|
||||||
throws RemoteException {
|
throws RemoteException {
|
||||||
// TODO Auto-generated method stub
|
// TODO Auto-generated method stub
|
||||||
return 0;
|
return 0;
|
||||||
|
@ -1,5 +1,6 @@
|
|||||||
package com.android.internal.backup;
|
package com.android.internal.backup;
|
||||||
|
|
||||||
|
import android.content.pm.PackageInfo;
|
||||||
import android.os.ParcelFileDescriptor;
|
import android.os.ParcelFileDescriptor;
|
||||||
import android.os.RemoteException;
|
import android.os.RemoteException;
|
||||||
|
|
||||||
@ -9,20 +10,20 @@ import android.os.RemoteException;
|
|||||||
|
|
||||||
public class GoogleTransport extends IBackupTransport.Stub {
|
public class GoogleTransport extends IBackupTransport.Stub {
|
||||||
|
|
||||||
public int endSession() throws RemoteException {
|
|
||||||
// TODO Auto-generated method stub
|
|
||||||
return 0;
|
|
||||||
}
|
|
||||||
|
|
||||||
public int performBackup(String packageName, ParcelFileDescriptor data)
|
|
||||||
throws RemoteException {
|
|
||||||
// TODO Auto-generated method stub
|
|
||||||
return 0;
|
|
||||||
}
|
|
||||||
|
|
||||||
public int startSession() throws RemoteException {
|
public int startSession() throws RemoteException {
|
||||||
// TODO Auto-generated method stub
|
// TODO Auto-generated method stub
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public int endSession() throws RemoteException {
|
||||||
|
// TODO Auto-generated method stub
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
public int performBackup(PackageInfo packageInfo, ParcelFileDescriptor data)
|
||||||
|
throws RemoteException {
|
||||||
|
// TODO Auto-generated method stub
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
@ -16,7 +16,7 @@
|
|||||||
|
|
||||||
package com.android.internal.backup;
|
package com.android.internal.backup;
|
||||||
|
|
||||||
import android.os.Bundle;
|
import android.content.pm.PackageInfo;
|
||||||
import android.os.ParcelFileDescriptor;
|
import android.os.ParcelFileDescriptor;
|
||||||
|
|
||||||
/** {@hide} */
|
/** {@hide} */
|
||||||
@ -26,7 +26,7 @@ interface IBackupTransport {
|
|||||||
1. set up the connection to the destination
|
1. set up the connection to the destination
|
||||||
- set up encryption
|
- set up encryption
|
||||||
- for Google cloud, log in using the user's gaia credential or whatever
|
- for Google cloud, log in using the user's gaia credential or whatever
|
||||||
- for sd, spin off the backup transport and establish communication with it
|
- for adb, just set up the all-in-one destination file
|
||||||
2. send each app's backup transaction
|
2. send each app's backup transaction
|
||||||
- parse the data file for key/value pointers etc
|
- parse the data file for key/value pointers etc
|
||||||
- send key/blobsize set to the Google cloud, get back quota ok/rejected response
|
- send key/blobsize set to the Google cloud, get back quota ok/rejected response
|
||||||
@ -37,7 +37,7 @@ interface IBackupTransport {
|
|||||||
- sd target streams raw data into encryption envelope then to sd?
|
- sd target streams raw data into encryption envelope then to sd?
|
||||||
3. shut down connection to destination
|
3. shut down connection to destination
|
||||||
- cloud: tear down connection etc
|
- cloud: tear down connection etc
|
||||||
- sd: close the file and shut down the writer proxy
|
- adb: close the file
|
||||||
*/
|
*/
|
||||||
/**
|
/**
|
||||||
* Establish a connection to the back-end data repository, if necessary. If the transport
|
* Establish a connection to the back-end data repository, if necessary. If the transport
|
||||||
@ -51,13 +51,14 @@ interface IBackupTransport {
|
|||||||
/**
|
/**
|
||||||
* Send one application's data to the backup destination.
|
* Send one application's data to the backup destination.
|
||||||
*
|
*
|
||||||
* @param packageName The identity of the application whose data is being backed up.
|
* @param package The identity of the application whose data is being backed up. This
|
||||||
|
* specifically includes the signature list for the package.
|
||||||
* @param data The data stream that resulted from invoking the application's
|
* @param data The data stream that resulted from invoking the application's
|
||||||
* BackupService.doBackup() method. This may be a pipe rather than a
|
* BackupService.doBackup() method. This may be a pipe rather than a file on
|
||||||
* file on persistent media, so it may not be seekable.
|
* persistent media, so it may not be seekable.
|
||||||
* @return Zero on success; a nonzero error code on failure.
|
* @return Zero on success; a nonzero error code on failure.
|
||||||
*/
|
*/
|
||||||
int performBackup(String packageName, in ParcelFileDescriptor data);
|
int performBackup(in PackageInfo packageInfo, in ParcelFileDescriptor data);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Terminate the backup session, closing files, freeing memory, and cleaning up whatever
|
* Terminate the backup session, closing files, freeing memory, and cleaning up whatever
|
||||||
|
@ -25,6 +25,7 @@ import android.content.Context;
|
|||||||
import android.content.Intent;
|
import android.content.Intent;
|
||||||
import android.content.IntentFilter;
|
import android.content.IntentFilter;
|
||||||
import android.content.pm.ApplicationInfo;
|
import android.content.pm.ApplicationInfo;
|
||||||
|
import android.content.pm.PackageInfo;
|
||||||
import android.content.pm.PackageManager;
|
import android.content.pm.PackageManager;
|
||||||
import android.content.pm.PackageManager.NameNotFoundException;
|
import android.content.pm.PackageManager.NameNotFoundException;
|
||||||
import android.net.Uri;
|
import android.net.Uri;
|
||||||
@ -149,8 +150,6 @@ class BackupManagerService extends IBackupManager.Stub {
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
// !!! TODO: this is buggy right now; we wind up with duplicate participant entries
|
|
||||||
// after using 'adb install -r' of a participating app
|
|
||||||
String action = intent.getAction();
|
String action = intent.getAction();
|
||||||
if (Intent.ACTION_PACKAGE_ADDED.equals(action)) {
|
if (Intent.ACTION_PACKAGE_ADDED.equals(action)) {
|
||||||
synchronized (mBackupParticipants) {
|
synchronized (mBackupParticipants) {
|
||||||
@ -211,6 +210,11 @@ class BackupManagerService extends IBackupManager.Stub {
|
|||||||
Log.d(TAG, "processOneBackup doBackup() on " + packageName);
|
Log.d(TAG, "processOneBackup doBackup() on " + packageName);
|
||||||
|
|
||||||
try {
|
try {
|
||||||
|
// Look up the package info & signatures. This is first so that if it
|
||||||
|
// throws an exception, there's no file setup yet that would need to
|
||||||
|
// be unraveled.
|
||||||
|
PackageInfo packInfo = mPackageManager.getPackageInfo(packageName, PackageManager.GET_SIGNATURES);
|
||||||
|
|
||||||
// !!! TODO: get the state file dir from the transport
|
// !!! TODO: get the state file dir from the transport
|
||||||
File savedStateName = new File(mStateDir, packageName);
|
File savedStateName = new File(mStateDir, packageName);
|
||||||
File backupDataName = new File(mDataDir, packageName + ".data");
|
File backupDataName = new File(mDataDir, packageName + ".data");
|
||||||
@ -253,15 +257,17 @@ class BackupManagerService extends IBackupManager.Stub {
|
|||||||
if (DEBUG) Log.v(TAG, "doBackup() success; calling transport");
|
if (DEBUG) Log.v(TAG, "doBackup() success; calling transport");
|
||||||
backupData =
|
backupData =
|
||||||
ParcelFileDescriptor.open(backupDataName, ParcelFileDescriptor.MODE_READ_ONLY);
|
ParcelFileDescriptor.open(backupDataName, ParcelFileDescriptor.MODE_READ_ONLY);
|
||||||
int error = transport.performBackup(packageName, backupData);
|
int error = transport.performBackup(packInfo, backupData);
|
||||||
|
|
||||||
// !!! TODO: After successful transport, delete the now-stale data
|
// !!! TODO: After successful transport, delete the now-stale data
|
||||||
// and juggle the files so that next time the new state is passed
|
// and juggle the files so that next time the new state is passed
|
||||||
//backupDataName.delete();
|
//backupDataName.delete();
|
||||||
newStateName.renameTo(savedStateName);
|
newStateName.renameTo(savedStateName);
|
||||||
}
|
}
|
||||||
|
} catch (NameNotFoundException e) {
|
||||||
|
Log.e(TAG, "Package not found on backup: " + packageName);
|
||||||
} catch (FileNotFoundException fnf) {
|
} catch (FileNotFoundException fnf) {
|
||||||
Log.d(TAG, "File not found on backup: ");
|
Log.w(TAG, "File not found on backup: ");
|
||||||
fnf.printStackTrace();
|
fnf.printStackTrace();
|
||||||
} catch (RemoteException e) {
|
} catch (RemoteException e) {
|
||||||
Log.d(TAG, "Remote target " + request.appInfo.packageName + " threw during backup:");
|
Log.d(TAG, "Remote target " + request.appInfo.packageName + " threw during backup:");
|
||||||
|
Reference in New Issue
Block a user