am b1b289a0: Merge change Id6688603 into eclair

Merge commit 'b1b289a01d20a3a2e08775d31994f0abca996a63' into eclair-plus-aosp

* commit 'b1b289a01d20a3a2e08775d31994f0abca996a63':
  Better event log tracking for initializeDevice() requests --
This commit is contained in:
Dan Egnor
2009-09-29 20:48:12 -07:00
committed by Android Git Automerger

View File

@@ -106,6 +106,7 @@ class BackupManagerService extends IBackupManager.Stub {
private static final int BACKUP_PACKAGE_EVENT = 2824; private static final int BACKUP_PACKAGE_EVENT = 2824;
private static final int BACKUP_SUCCESS_EVENT = 2825; private static final int BACKUP_SUCCESS_EVENT = 2825;
private static final int BACKUP_RESET_EVENT = 2826; private static final int BACKUP_RESET_EVENT = 2826;
private static final int BACKUP_INITIALIZE_EVENT = 2827;
private static final int RESTORE_START_EVENT = 2830; private static final int RESTORE_START_EVENT = 2830;
private static final int RESTORE_TRANSPORT_FAILURE_EVENT = 2831; private static final int RESTORE_TRANSPORT_FAILURE_EVENT = 2831;
@@ -1062,7 +1063,14 @@ class BackupManagerService extends IBackupManager.Stub {
// If we haven't stored anything yet, we need to do an init operation. // If we haven't stored anything yet, we need to do an init operation.
if (status == BackupConstants.TRANSPORT_OK && mEverStoredApps.size() == 0) { if (status == BackupConstants.TRANSPORT_OK && mEverStoredApps.size() == 0) {
Log.i(TAG, "Initializing (wiping) backup transport storage");
status = mTransport.initializeDevice(); status = mTransport.initializeDevice();
if (status == BackupConstants.TRANSPORT_OK) {
EventLog.writeEvent(BACKUP_INITIALIZE_EVENT);
} else {
EventLog.writeEvent(BACKUP_TRANSPORT_FAILURE_EVENT, "(initialize)");
Log.e(TAG, "Transport error in initializeDevice()");
}
} }
// The package manager doesn't have a proper <application> etc, but since // The package manager doesn't have a proper <application> etc, but since
@@ -1091,7 +1099,7 @@ class BackupManagerService extends IBackupManager.Stub {
int millis = (int) (SystemClock.elapsedRealtime() - startRealtime); int millis = (int) (SystemClock.elapsedRealtime() - startRealtime);
EventLog.writeEvent(BACKUP_SUCCESS_EVENT, mQueue.size(), millis); EventLog.writeEvent(BACKUP_SUCCESS_EVENT, mQueue.size(), millis);
} else { } else {
EventLog.writeEvent(BACKUP_TRANSPORT_FAILURE_EVENT, ""); EventLog.writeEvent(BACKUP_TRANSPORT_FAILURE_EVENT, "(finish)");
Log.e(TAG, "Transport error in finishBackup()"); Log.e(TAG, "Transport error in finishBackup()");
} }
} }
@@ -1714,7 +1722,6 @@ class BackupManagerService extends IBackupManager.Stub {
@Override @Override
public void run() { public void run() {
int status;
try { try {
for (String transportName : mQueue) { for (String transportName : mQueue) {
IBackupTransport transport = getTransport(transportName); IBackupTransport transport = getTransport(transportName);
@@ -1723,33 +1730,30 @@ class BackupManagerService extends IBackupManager.Stub {
continue; continue;
} }
status = BackupConstants.TRANSPORT_OK; Log.i(TAG, "Initializing (wiping) backup transport storage: " + transportName);
File stateDir = null; EventLog.writeEvent(BACKUP_START_EVENT, transport.transportDirName());
long startRealtime = SystemClock.elapsedRealtime();
int status = transport.initializeDevice();
Log.i(TAG, "Device init on " + transport.transportDirName());
stateDir = new File(mBaseStateDir, transport.transportDirName());
status = transport.initializeDevice();
if (status != BackupConstants.TRANSPORT_OK) {
Log.e(TAG, "Error from initializeDevice: " + status);
}
if (status == BackupConstants.TRANSPORT_OK) { if (status == BackupConstants.TRANSPORT_OK) {
status = transport.finishBackup(); status = transport.finishBackup();
} }
// Okay, the wipe really happened. Clean up our local bookkeeping. // Okay, the wipe really happened. Clean up our local bookkeeping.
if (status == BackupConstants.TRANSPORT_OK) { if (status == BackupConstants.TRANSPORT_OK) {
resetBackupState(stateDir); Log.i(TAG, "Device init successful");
int millis = (int) (SystemClock.elapsedRealtime() - startRealtime);
EventLog.writeEvent(BACKUP_INITIALIZE_EVENT);
resetBackupState(new File(mBaseStateDir, transport.transportDirName()));
EventLog.writeEvent(BACKUP_SUCCESS_EVENT, 0, millis);
synchronized (mQueueLock) { synchronized (mQueueLock) {
recordInitPendingLocked(false, transportName); recordInitPendingLocked(false, transportName);
} }
} } else {
// If this didn't work, requeue this one and try again
// If this didn't work, requeue this one and try again // after a suitable interval
// after a suitable interval Log.e(TAG, "Transport error in initializeDevice()");
if (status != BackupConstants.TRANSPORT_OK) { EventLog.writeEvent(BACKUP_TRANSPORT_FAILURE_EVENT, "(initialize)");
Log.i(TAG, "Device init failed");
synchronized (mQueueLock) { synchronized (mQueueLock) {
recordInitPendingLocked(true, transportName); recordInitPendingLocked(true, transportName);
} }
@@ -1759,11 +1763,7 @@ class BackupManagerService extends IBackupManager.Stub {
+ transportName + " resched in " + delay); + transportName + " resched in " + delay);
mAlarmManager.set(AlarmManager.RTC_WAKEUP, mAlarmManager.set(AlarmManager.RTC_WAKEUP,
System.currentTimeMillis() + delay, mRunInitIntent); System.currentTimeMillis() + delay, mRunInitIntent);
} else {
// success!
Log.i(TAG, "Device init successful");
} }
} }
} catch (RemoteException e) { } catch (RemoteException e) {
// can't happen; the transports are local // can't happen; the transports are local