Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit c8f1f33e authored by Al Sutton's avatar Al Sutton Committed by Android (Google) Code Review
Browse files

Merge "Add feature flag for "no data" backup calls"

parents 89b87072 27c64a3b
Loading
Loading
Loading
Loading
+6 −0
Original line number Diff line number Diff line
@@ -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");
    }

    /**
+7 −0
Original line number Diff line number Diff line
@@ -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.
+10 −0
Original line number Diff line number Diff line
@@ -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(