Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit b1b289a0 authored by Android (Google) Code Review's avatar Android (Google) Code Review
Browse files

Merge change Id6688603 into eclair

* changes:
  Better event log tracking for initializeDevice() requests -- on success, record "backup_initialize" event; on failure, record "backup_transport_failure" event (and add tags to "backup_transport_failure" events that aren't associated with a particular package -- namely "(initialize)" and "(finish)").
parents 2e4dbe70 726247ca
Loading
Loading
Loading
Loading
+23 −23
Original line number Original line Diff line number Diff line
@@ -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();
                    Log.i(TAG, "Device init on " + transport.transportDirName());
                    int status = transport.initializeDevice();

                    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
                    if (status != BackupConstants.TRANSPORT_OK) {
                        Log.e(TAG, "Transport error in initializeDevice()");
                        Log.i(TAG, "Device init failed");
                        EventLog.writeEvent(BACKUP_TRANSPORT_FAILURE_EVENT, "(initialize)");
                        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