Add feature flag for "no data" backup calls
This will allow us to turn off the new functionality while the transport implementations are updated. Bug: 147481066 Test: m -j RunBackupFrameworksServicesRoboTests Change-Id: I8c0019ff80d94dd8d94299a7b03b78e3081f2b8e
This commit is contained in:
@@ -44,6 +44,9 @@ public class FeatureFlagUtils {
|
||||
public static final String SETTINGS_FUSE_FLAG = "settings_fuse";
|
||||
public static final String NOTIF_CONVO_BYPASS_SHORTCUT_REQ =
|
||||
"settings_notif_convo_bypass_shortcut_req";
|
||||
/** @hide */
|
||||
public static final String BACKUP_NO_KV_DATA_CHANGE_CALLS =
|
||||
"backup_enable_no_data_notification_calls";
|
||||
|
||||
private static final Map<String, String> DEFAULT_FLAGS;
|
||||
|
||||
@@ -62,6 +65,9 @@ public class FeatureFlagUtils {
|
||||
DEFAULT_FLAGS.put("settings_controller_loading_enhancement", "false");
|
||||
DEFAULT_FLAGS.put("settings_conditionals", "false");
|
||||
DEFAULT_FLAGS.put(NOTIF_CONVO_BYPASS_SHORTCUT_REQ, "true");
|
||||
|
||||
// Disabled until backup transports support it.
|
||||
DEFAULT_FLAGS.put(BACKUP_NO_KV_DATA_CHANGE_CALLS, "false");
|
||||
}
|
||||
|
||||
/**
|
||||
|
||||
@@ -47,6 +47,7 @@ import android.os.RemoteException;
|
||||
import android.os.SELinux;
|
||||
import android.os.UserHandle;
|
||||
import android.os.WorkSource;
|
||||
import android.util.FeatureFlagUtils;
|
||||
import android.util.Log;
|
||||
|
||||
import com.android.internal.annotations.GuardedBy;
|
||||
@@ -399,6 +400,12 @@ public class KeyValueBackupTask implements BackupRestoreTask, Runnable {
|
||||
* the transport have no data.
|
||||
*/
|
||||
private void informTransportOfUnchangedApps(Set<String> appsBackedUp) {
|
||||
// If the feautre is not enabled then we just exit early.
|
||||
if (!FeatureFlagUtils.isEnabled(mBackupManagerService.getContext(),
|
||||
FeatureFlagUtils.BACKUP_NO_KV_DATA_CHANGE_CALLS)) {
|
||||
return;
|
||||
}
|
||||
|
||||
String[] succeedingPackages = getSucceedingPackages();
|
||||
if (succeedingPackages == null) {
|
||||
// Nothing is succeeding, so end early.
|
||||
|
||||
@@ -96,6 +96,7 @@ import android.os.Message;
|
||||
import android.os.ParcelFileDescriptor;
|
||||
import android.os.RemoteException;
|
||||
import android.platform.test.annotations.Presubmit;
|
||||
import android.util.FeatureFlagUtils;
|
||||
import android.util.Pair;
|
||||
|
||||
import com.android.internal.backup.IBackupTransport;
|
||||
@@ -258,6 +259,9 @@ public class KeyValueBackupTaskTest {
|
||||
public void tearDown() throws Exception {
|
||||
ShadowBackupDataInput.reset();
|
||||
ShadowApplicationPackageManager.reset();
|
||||
// False by default.
|
||||
FeatureFlagUtils.setEnabled(
|
||||
mContext, FeatureFlagUtils.BACKUP_NO_KV_DATA_CHANGE_CALLS, false);
|
||||
}
|
||||
|
||||
@Test
|
||||
@@ -2344,6 +2348,9 @@ public class KeyValueBackupTaskTest {
|
||||
@Test
|
||||
public void testRunTask_whenNoDataToBackupOnFirstBackup_doesNotTellTransportOfBackup()
|
||||
throws Exception {
|
||||
FeatureFlagUtils.setEnabled(
|
||||
mContext, FeatureFlagUtils.BACKUP_NO_KV_DATA_CHANGE_CALLS, true);
|
||||
|
||||
TransportMock transportMock = setUpInitializedTransport(mTransport);
|
||||
mBackupManagerService.setCurrentToken(0L);
|
||||
when(transportMock.transport.getCurrentRestoreSet()).thenReturn(1234L);
|
||||
@@ -2361,6 +2368,9 @@ public class KeyValueBackupTaskTest {
|
||||
@Test
|
||||
public void testRunTask_whenBackupHasCompletedAndThenNoDataChanges_transportGetsNotified()
|
||||
throws Exception {
|
||||
FeatureFlagUtils.setEnabled(
|
||||
mContext, FeatureFlagUtils.BACKUP_NO_KV_DATA_CHANGE_CALLS, true);
|
||||
|
||||
TransportMock transportMock = setUpInitializedTransport(mTransport);
|
||||
when(transportMock.transport.getCurrentRestoreSet()).thenReturn(1234L);
|
||||
when(transportMock.transport.isAppEligibleForBackup(
|
||||
|
||||
Reference in New Issue
Block a user