@Override public void performBackup(ParcelFileDescriptor oldState,BackupDataOutput data,ParcelFileDescriptor newState){
  if (VERBOSE)   Log.v(TAG,"onBackup");
  Journal in=readJournal(oldState);
  if (!launcherIsReady()) {
    writeJournal(newState,in);
    return;
  }
  Log.v(TAG,"lastBackupTime = " + in.t);
  mKeys.clear();
  applyJournal(in);
  long newBackupTime=System.currentTimeMillis();
  try {
    backupFavorites(data);
    backupScreens(data);
    backupIcons(data);
    backupWidgets(data);
    HashSet<String> validKeys=new HashSet<String>();
    for (    Key key : mKeys) {
      validKeys.add(keyToBackupKey(key));
    }
    mExistingKeys.removeAll(validKeys);
    for (    String deleted : mExistingKeys) {
      if (VERBOSE)       Log.v(TAG,"dropping deleted item " + deleted);
      data.writeEntityHeader(deleted,-1);
    }
    mExistingKeys.clear();
    mLastBackupRestoreTime=newBackupTime;
    Journal state=getCurrentStateJournal();
    writeRowToBackup(JOURNAL_KEY,state,data);
  }
 catch (  IOException e) {
    Log.e(TAG,"launcher backup has failed",e);
  }
  writeNewStateDescription(newState);
}

@ Override public void performBackup ( ParcelFileDescriptor oldState , BackupDataOutput data , ParcelFileDescriptor newState ) { if ( VERBOSE ) Log . v ( TAG , "onBackup" ) ; Journal in = readJournal ( oldState ) ; if ( ! launcherIsReady ( ) ) { writeJournal ( newState , in ) ; return ; } Log . v ( TAG , "lastBackupTime = " + in . t ) ; mKeys . clear ( ) ; applyJournal ( in ) ; long newBackupTime = System . currentTimeMillis ( ) ; try { backupFavorites ( data ) ; backupScreens ( data ) ; backupIcons ( data ) ; backupWidgets ( data ) ; HashSet < String > validKeys = new HashSet < String > ( ) ; for ( Key key : mKeys ) { validKeys . add ( keyToBackupKey ( key ) ) ; } mExistingKeys . removeAll ( validKeys ) ; for ( String deleted : mExistingKeys ) { if ( VERBOSE ) Log . v ( TAG , "dropping deleted item " + deleted ) ; data . writeEntityHeader ( deleted , - 1 ) ; } mExistingKeys . clear ( ) ; mLastBackupRestoreTime = newBackupTime ; Journal state = getCurrentStateJournal ( ) ; writeRowToBackup ( JOURNAL_KEY , state , data ) ; } catch ( IOException e ) { Log . e ( TAG , "launcher backup has failed" , e ) ; } writeNewStateDescription ( newState ) ; }
back up launcher data so we can restore the user ' s state on a new device . < p > the journal is a timestamp and a list of keys that were saved as of that time . < p > keys may come back in any order , so each key / value is one complete row of the database .
