@Override public void restoreEntity(BackupDataInputStream data){
  if (!restoreSuccessful) {
    return;
  }
  int dataSize=data.size();
  if (mBuffer.length < dataSize) {
    mBuffer=new byte[dataSize];
  }
  try {
    int bytesRead=data.read(mBuffer,0,dataSize);
    if (DEBUG)     Log.d(TAG,"read " + bytesRead + " of "+ dataSize+ " available");
    String backupKey=data.getKey();
    if (JOURNAL_KEY.equals(backupKey)) {
      if (VERBOSE)       Log.v(TAG,"Journal entry restored");
      if (!mKeys.isEmpty()) {
        Log.wtf(TAG,keyToBackupKey(mKeys.get(0)) + " received after " + JOURNAL_KEY);
        restoreSuccessful=false;
        return;
      }
      Journal journal=new Journal();
      MessageNano.mergeFrom(journal,readCheckedBytes(mBuffer,dataSize));
      applyJournal(journal);
      restoreSuccessful=false;
      return;
    }
    if (!mExistingKeys.isEmpty() && !mExistingKeys.contains(backupKey)) {
      if (DEBUG)       Log.e(TAG,"Ignoring key not present in the backup state " + backupKey);
      return;
    }
    Key key=backupKeyToKey(backupKey);
    mKeys.add(key);
switch (key.type) {
case Key.FAVORITE:
      restoreFavorite(key,mBuffer,dataSize);
    break;
case Key.SCREEN:
  restoreScreen(key,mBuffer,dataSize);
break;
case Key.ICON:
restoreIcon(key,mBuffer,dataSize);
break;
case Key.WIDGET:
restoreWidget(key,mBuffer,dataSize);
break;
default :
Log.w(TAG,"unknown restore entity type: " + key.type);
mKeys.remove(key);
break;
}
}
 catch (IOException e) {
Log.w(TAG,"ignoring unparsable backup entry",e);
}
}

@ Override public void restoreEntity ( BackupDataInputStream data ) { if ( ! restoreSuccessful ) { return ; } int dataSize = data . size ( ) ; if ( mBuffer . length < dataSize ) { mBuffer = new byte [ dataSize ] ; } try { int bytesRead = data . read ( mBuffer , 0 , dataSize ) ; if ( DEBUG ) Log . d ( TAG , "read " + bytesRead + " of " + dataSize + " available" ) ; String backupKey = data . getKey ( ) ; if ( JOURNAL_KEY . equals ( backupKey ) ) { if ( VERBOSE ) Log . v ( TAG , "Journal entry restored" ) ; if ( ! mKeys . isEmpty ( ) ) { Log . wtf ( TAG , keyToBackupKey ( mKeys . get ( 0 ) ) + " received after " + JOURNAL_KEY ) ; restoreSuccessful = false ; return ; } Journal journal = new Journal ( ) ; MessageNano . mergeFrom ( journal , readCheckedBytes ( mBuffer , dataSize ) ) ; applyJournal ( journal ) ; restoreSuccessful = false ; return ; } if ( ! mExistingKeys . isEmpty ( ) && ! mExistingKeys . contains ( backupKey ) ) { if ( DEBUG ) Log . e ( TAG , "Ignoring key not present in the backup state " + backupKey ) ; return ; } Key key = backupKeyToKey ( backupKey ) ; mKeys . add ( key ) ; switch ( key . type ) { case Key . FAVORITE : restoreFavorite ( key , mBuffer , dataSize ) ; break ; case Key . SCREEN : restoreScreen ( key , mBuffer , dataSize ) ; break ; case Key . ICON : restoreIcon ( key , mBuffer , dataSize ) ; break ; case Key . WIDGET : restoreWidget ( key , mBuffer , dataSize ) ; break ; default : Log . w ( TAG , "unknown restore entity type: " + key . type ) ; mKeys . remove ( key ) ; break ; } } catch ( IOException e ) { Log . w ( TAG , "ignoring unparsable backup entry" , e ) ; } }
restore launcher configuration from the restored data stream . it assumes that the keys will arrive in lexical order . so if the journal was present in the backup , it should arrive first .
