/** {@link BackupDataOutput#writeEntityData(byte[], int)} */ public int writeEntityData(byte[] data, int size) throws IOException { if (backupDataOutput != null) { return backupDataOutput.writeEntityData(data, size); } else { return writeEntityData2(data, size); } }
private static int removeDeletedKeysFromBackup(Set<String> deletedIds, BackupDataOutput data) throws IOException { int rows = 0; for(String deleted: deletedIds) { if (VERBOSE) { Log.v(TAG, "dropping deleted item " + deleted); } data.writeEntityHeader(deleted, -1); rows++; } return rows; }
private void writeRowToBackup(Key key, byte[] blob, Journal out, BackupDataOutput data) throws IOException { String backupKey = keyToBackupKey(key); data.writeEntityHeader(backupKey, blob.length); data.writeEntityData(blob, blob.length); out.rows++; out.bytes += blob.length; if (VERBOSE) { Log.v(TAG, "saving " + geKeyType(key) + " " + backupKey + ": " + getKeyName(key) + "/" + blob.length); } if(DEBUG_PAYLOAD) { String encoded = Base64.encodeToString(blob, 0, blob.length, Base64.NO_WRAP); final int chunkSize = 1024; for (int offset = 0; offset < encoded.length(); offset += chunkSize) { int end = offset + chunkSize; end = Math.min(end, encoded.length()); Log.w(TAG, "wrote " + encoded.substring(offset, end)); } } }
data.writeEntityHeader(KEY, -1); // delete existing data if any writeNewState(0, newState); } catch (IOException e) { writer.close(); data.writeEntityHeader(KEY, byteArrayOutputStream.size()); data.writeEntityData(byteArrayOutputStream.toByteArray(), byteArrayOutputStream.size()); byteArrayOutputStream.close();
/** {@link BackupDataOutput#writeEntityHeader(String, int)} */ public int writeEntityHeader(String key, int dataSize, String fileExtension) throws IOException { headerOrdinalNumber++; if (backupDataOutput != null) { return backupDataOutput.writeEntityHeader(key, dataSize); } else { return writeEntityHeader2(key, dataSize, fileExtension); } }