Loading services/backup/java/com/android/server/backup/BackupAndRestoreFeatureFlags.java +25 −0 Original line number Diff line number Diff line Loading @@ -52,4 +52,29 @@ public class BackupAndRestoreFeatureFlags { /* name= */ "backup_transport_callback_timeout_millis", /* defaultValue= */ 300000); // 5 minutes } /** * Retrieves the value of the flag "full_backup_write_to_transport_buffer_size_bytes". * The returned value is max size of a chunk of backup data that is sent to the transport. */ @RequiresPermission(Manifest.permission.READ_DEVICE_CONFIG) public static int getFullBackupWriteToTransportBufferSizeBytes() { return DeviceConfig.getInt( NAMESPACE, /* name= */ "full_backup_write_to_transport_buffer_size_bytes", /* defaultValue= */ 8 * 1024); // 8 KB } /** * Retrieves the value of the flag "full_backup_utils_route_buffer_size_bytes". * The returned value is max size of a chunk of backup data that routed from write end of * pipe from BackupAgent, to read end of pipe to Full Backup Task (PFTBT). */ @RequiresPermission(Manifest.permission.READ_DEVICE_CONFIG) public static int getFullBackupUtilsRouteBufferSizeBytes() { return DeviceConfig.getInt( NAMESPACE, /* name= */ "full_backup_utils_route_buffer_size_bytes", /* defaultValue= */ 32 * 1024); // 32 KB } } services/backup/java/com/android/server/backup/fullbackup/PerformFullTransportBackupTask.java +4 −2 Original line number Diff line number Diff line Loading @@ -40,6 +40,7 @@ import android.util.Slog; import com.android.server.EventLogTags; import com.android.server.backup.BackupAgentTimeoutParameters; import com.android.server.backup.BackupAndRestoreFeatureFlags; import com.android.server.backup.BackupRestoreTask; import com.android.server.backup.FullBackupJob; import com.android.server.backup.OperationStorage; Loading Loading @@ -142,7 +143,6 @@ public class PerformFullTransportBackupTask extends FullBackupTask implements Ba } private static final String TAG = "PFTBT"; private UserBackupManagerService mUserBackupManagerService; private final Object mCancelLock = new Object(); Loading Loading @@ -388,7 +388,9 @@ public class PerformFullTransportBackupTask extends FullBackupTask implements Ba // Set up to send data to the transport final int N = mPackages.size(); final byte[] buffer = new byte[8192]; final int chunkSizeInBytes = BackupAndRestoreFeatureFlags.getFullBackupWriteToTransportBufferSizeBytes(); final byte[] buffer = new byte[chunkSizeInBytes]; for (int i = 0; i < N; i++) { mBackupRunner = null; PackageInfo currentPackage = mPackages.get(i); Loading services/backup/java/com/android/server/backup/utils/FullBackupUtils.java +7 −3 Original line number Diff line number Diff line Loading @@ -21,6 +21,8 @@ import static com.android.server.backup.BackupManagerService.TAG; import android.os.ParcelFileDescriptor; import android.util.Slog; import com.android.server.backup.BackupAndRestoreFeatureFlags; import java.io.DataInputStream; import java.io.EOFException; import java.io.FileInputStream; Loading @@ -31,8 +33,9 @@ import java.io.OutputStream; * Low-level utility methods for full backup. */ public class FullBackupUtils { /** * Reads data from pipe and writes it to the stream in chunks of up to 32KB. * Reads data from pipe and writes it to the stream. * * @param inPipe - pipe to read the data from. * @param out - stream to write the data to. Loading @@ -43,8 +46,9 @@ public class FullBackupUtils { // We do not take close() responsibility for the pipe FD FileInputStream raw = new FileInputStream(inPipe.getFileDescriptor()); DataInputStream in = new DataInputStream(raw); byte[] buffer = new byte[32 * 1024]; final int chunkSizeInBytes = BackupAndRestoreFeatureFlags.getFullBackupUtilsRouteBufferSizeBytes(); byte[] buffer = new byte[chunkSizeInBytes]; int chunkTotal; while ((chunkTotal = in.readInt()) > 0) { while (chunkTotal > 0) { Loading services/tests/mockingservicestests/src/com/android/server/backup/BackupAndRestoreFeatureFlagsTest.java +38 −4 Original line number Diff line number Diff line Loading @@ -46,8 +46,9 @@ public class BackupAndRestoreFeatureFlagsTest { @Test public void getBackupTransportFutureTimeoutMillis_set_returnsSetValue() { DeviceConfig.setProperty("backup_and_restore", "backup_transport_future_timeout_millis", "1234", false); DeviceConfig.setProperty(/*namespace=*/ "backup_and_restore", /*name=*/ "backup_transport_future_timeout_millis", /*value=*/ "1234", /*makeDefault=*/ false); assertThat( BackupAndRestoreFeatureFlags.getBackupTransportFutureTimeoutMillis()).isEqualTo( Loading @@ -63,11 +64,44 @@ public class BackupAndRestoreFeatureFlagsTest { @Test public void getBackupTransportCallbackTimeoutMillis_set_returnsSetValue() { DeviceConfig.setProperty("backup_and_restore", "backup_transport_callback_timeout_millis", "5678", false); DeviceConfig.setProperty(/*namespace=*/ "backup_and_restore", /*name=*/ "backup_transport_callback_timeout_millis", /*value=*/ "5678", /*makeDefault=*/ false); assertThat( BackupAndRestoreFeatureFlags.getBackupTransportCallbackTimeoutMillis()).isEqualTo( 5678); } @Test public void getFullBackupWriteToTransportBufferSizeBytes_notSet_returnsDefault() { assertThat(BackupAndRestoreFeatureFlags.getFullBackupWriteToTransportBufferSizeBytes()) .isEqualTo(8 * 1024); } @Test public void getFullBackupWriteToTransportBufferSizeBytes_set_returnsSetValue() { DeviceConfig.setProperty(/*namespace=*/ "backup_and_restore", /*name=*/ "full_backup_write_to_transport_buffer_size_bytes", /*value=*/ "5678", /*makeDefault=*/ false); assertThat(BackupAndRestoreFeatureFlags.getFullBackupWriteToTransportBufferSizeBytes()) .isEqualTo(5678); } @Test public void getFullBackupUtilsRouteBufferSizeBytes_notSet_returnsDefault() { assertThat(BackupAndRestoreFeatureFlags.getFullBackupUtilsRouteBufferSizeBytes()) .isEqualTo(32 * 1024); } @Test public void getFullBackupUtilsRouteBufferSizeBytes_set_returnsSetValue() { DeviceConfig.setProperty(/*namespace=*/ "backup_and_restore", /*name=*/ "full_backup_utils_route_buffer_size_bytes", /*value=*/ "5678", /*makeDefault=*/ false); assertThat(BackupAndRestoreFeatureFlags.getFullBackupUtilsRouteBufferSizeBytes()) .isEqualTo(5678); } } Loading
services/backup/java/com/android/server/backup/BackupAndRestoreFeatureFlags.java +25 −0 Original line number Diff line number Diff line Loading @@ -52,4 +52,29 @@ public class BackupAndRestoreFeatureFlags { /* name= */ "backup_transport_callback_timeout_millis", /* defaultValue= */ 300000); // 5 minutes } /** * Retrieves the value of the flag "full_backup_write_to_transport_buffer_size_bytes". * The returned value is max size of a chunk of backup data that is sent to the transport. */ @RequiresPermission(Manifest.permission.READ_DEVICE_CONFIG) public static int getFullBackupWriteToTransportBufferSizeBytes() { return DeviceConfig.getInt( NAMESPACE, /* name= */ "full_backup_write_to_transport_buffer_size_bytes", /* defaultValue= */ 8 * 1024); // 8 KB } /** * Retrieves the value of the flag "full_backup_utils_route_buffer_size_bytes". * The returned value is max size of a chunk of backup data that routed from write end of * pipe from BackupAgent, to read end of pipe to Full Backup Task (PFTBT). */ @RequiresPermission(Manifest.permission.READ_DEVICE_CONFIG) public static int getFullBackupUtilsRouteBufferSizeBytes() { return DeviceConfig.getInt( NAMESPACE, /* name= */ "full_backup_utils_route_buffer_size_bytes", /* defaultValue= */ 32 * 1024); // 32 KB } }
services/backup/java/com/android/server/backup/fullbackup/PerformFullTransportBackupTask.java +4 −2 Original line number Diff line number Diff line Loading @@ -40,6 +40,7 @@ import android.util.Slog; import com.android.server.EventLogTags; import com.android.server.backup.BackupAgentTimeoutParameters; import com.android.server.backup.BackupAndRestoreFeatureFlags; import com.android.server.backup.BackupRestoreTask; import com.android.server.backup.FullBackupJob; import com.android.server.backup.OperationStorage; Loading Loading @@ -142,7 +143,6 @@ public class PerformFullTransportBackupTask extends FullBackupTask implements Ba } private static final String TAG = "PFTBT"; private UserBackupManagerService mUserBackupManagerService; private final Object mCancelLock = new Object(); Loading Loading @@ -388,7 +388,9 @@ public class PerformFullTransportBackupTask extends FullBackupTask implements Ba // Set up to send data to the transport final int N = mPackages.size(); final byte[] buffer = new byte[8192]; final int chunkSizeInBytes = BackupAndRestoreFeatureFlags.getFullBackupWriteToTransportBufferSizeBytes(); final byte[] buffer = new byte[chunkSizeInBytes]; for (int i = 0; i < N; i++) { mBackupRunner = null; PackageInfo currentPackage = mPackages.get(i); Loading
services/backup/java/com/android/server/backup/utils/FullBackupUtils.java +7 −3 Original line number Diff line number Diff line Loading @@ -21,6 +21,8 @@ import static com.android.server.backup.BackupManagerService.TAG; import android.os.ParcelFileDescriptor; import android.util.Slog; import com.android.server.backup.BackupAndRestoreFeatureFlags; import java.io.DataInputStream; import java.io.EOFException; import java.io.FileInputStream; Loading @@ -31,8 +33,9 @@ import java.io.OutputStream; * Low-level utility methods for full backup. */ public class FullBackupUtils { /** * Reads data from pipe and writes it to the stream in chunks of up to 32KB. * Reads data from pipe and writes it to the stream. * * @param inPipe - pipe to read the data from. * @param out - stream to write the data to. Loading @@ -43,8 +46,9 @@ public class FullBackupUtils { // We do not take close() responsibility for the pipe FD FileInputStream raw = new FileInputStream(inPipe.getFileDescriptor()); DataInputStream in = new DataInputStream(raw); byte[] buffer = new byte[32 * 1024]; final int chunkSizeInBytes = BackupAndRestoreFeatureFlags.getFullBackupUtilsRouteBufferSizeBytes(); byte[] buffer = new byte[chunkSizeInBytes]; int chunkTotal; while ((chunkTotal = in.readInt()) > 0) { while (chunkTotal > 0) { Loading
services/tests/mockingservicestests/src/com/android/server/backup/BackupAndRestoreFeatureFlagsTest.java +38 −4 Original line number Diff line number Diff line Loading @@ -46,8 +46,9 @@ public class BackupAndRestoreFeatureFlagsTest { @Test public void getBackupTransportFutureTimeoutMillis_set_returnsSetValue() { DeviceConfig.setProperty("backup_and_restore", "backup_transport_future_timeout_millis", "1234", false); DeviceConfig.setProperty(/*namespace=*/ "backup_and_restore", /*name=*/ "backup_transport_future_timeout_millis", /*value=*/ "1234", /*makeDefault=*/ false); assertThat( BackupAndRestoreFeatureFlags.getBackupTransportFutureTimeoutMillis()).isEqualTo( Loading @@ -63,11 +64,44 @@ public class BackupAndRestoreFeatureFlagsTest { @Test public void getBackupTransportCallbackTimeoutMillis_set_returnsSetValue() { DeviceConfig.setProperty("backup_and_restore", "backup_transport_callback_timeout_millis", "5678", false); DeviceConfig.setProperty(/*namespace=*/ "backup_and_restore", /*name=*/ "backup_transport_callback_timeout_millis", /*value=*/ "5678", /*makeDefault=*/ false); assertThat( BackupAndRestoreFeatureFlags.getBackupTransportCallbackTimeoutMillis()).isEqualTo( 5678); } @Test public void getFullBackupWriteToTransportBufferSizeBytes_notSet_returnsDefault() { assertThat(BackupAndRestoreFeatureFlags.getFullBackupWriteToTransportBufferSizeBytes()) .isEqualTo(8 * 1024); } @Test public void getFullBackupWriteToTransportBufferSizeBytes_set_returnsSetValue() { DeviceConfig.setProperty(/*namespace=*/ "backup_and_restore", /*name=*/ "full_backup_write_to_transport_buffer_size_bytes", /*value=*/ "5678", /*makeDefault=*/ false); assertThat(BackupAndRestoreFeatureFlags.getFullBackupWriteToTransportBufferSizeBytes()) .isEqualTo(5678); } @Test public void getFullBackupUtilsRouteBufferSizeBytes_notSet_returnsDefault() { assertThat(BackupAndRestoreFeatureFlags.getFullBackupUtilsRouteBufferSizeBytes()) .isEqualTo(32 * 1024); } @Test public void getFullBackupUtilsRouteBufferSizeBytes_set_returnsSetValue() { DeviceConfig.setProperty(/*namespace=*/ "backup_and_restore", /*name=*/ "full_backup_utils_route_buffer_size_bytes", /*value=*/ "5678", /*makeDefault=*/ false); assertThat(BackupAndRestoreFeatureFlags.getFullBackupUtilsRouteBufferSizeBytes()) .isEqualTo(5678); } }