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

Commit 50219186 authored by Artem Iglikov's avatar Artem Iglikov
Browse files

Clone BackupManagerService and make Trampoline aware of the clone.

RefactoredBackupManagerService is an exact clone of
BackupManagerService. Trampoline chooses between these two based on
backup_refactored_service_disabled global setting, defaulting to true.

Test: manual: flashed the device, ran `settings put global
backup_refactored_service_disabled 1|0`, verified that correct class was
instantiated, ran bmgr backupnow command to make sure that it works.

Bug: 36850431

Change-Id: I8ef91b928a40aae022f88f07a4126a00b1d5e220
parent c6f9ea88
Loading
Loading
Loading
Loading
+8 −0
Original line number Diff line number Diff line
@@ -9784,6 +9784,14 @@ public final class Settings {
        public static final String LOCATION_SETTINGS_LINK_TO_PERMISSIONS_ENABLED =
                "location_settings_link_to_permissions_enabled";

        /**
         * Flag to enable use of RefactoredBackupManagerService.
         *
         * @hide
         */
        public static final String BACKUP_REFACTORED_SERVICE_DISABLED =
            "backup_refactored_service_disabled";

        /**
         * Settings to backup. This is here so that it's in the same place as the settings
         * keys and easy to update.
+1 −0
Original line number Diff line number Diff line
@@ -101,6 +101,7 @@ public class SettingsBackupTest {
                    Settings.Global.APP_IDLE_CONSTANTS,
                    Settings.Global.ASSISTED_GPS_ENABLED,
                    Settings.Global.AUDIO_SAFE_VOLUME_STATE,
                    Settings.Global.BACKUP_REFACTORED_SERVICE_DISABLED,
                    Settings.Global.BATTERY_DISCHARGE_DURATION_THRESHOLD,
                    Settings.Global.BATTERY_DISCHARGE_THRESHOLD,
                    Settings.Global.BLE_SCAN_ALWAYS_AVAILABLE,
+11372 −0

File added.

Preview size limit exceeded, changes collapsed.

+15 −2
Original line number Diff line number Diff line
@@ -33,6 +33,7 @@ import android.os.Process;
import android.os.RemoteException;
import android.os.SystemProperties;
import android.os.UserHandle;
import android.provider.Settings;
import android.util.Slog;

import com.android.internal.util.DumpUtils;
@@ -65,6 +66,18 @@ public class Trampoline extends IBackupManager.Stub {
        mGlobalDisable = SystemProperties.getBoolean(BACKUP_DISABLE_PROPERTY, false);
    }

    private BackupManagerServiceInterface createService() {
        boolean refactoredServiceEnabled = Settings.Global.getInt(mContext.getContentResolver(),
            Settings.Global.BACKUP_REFACTORED_SERVICE_DISABLED, 1) == 0;
        if (refactoredServiceEnabled) {
            Slog.i(TAG, "Instantiating RefactoredBackupManagerService");
            return new RefactoredBackupManagerService(mContext, this);
        }

        Slog.i(TAG, "Instantiating BackupManagerService");
        return new BackupManagerService(mContext, this);
    }

    // internal control API
    public void initialize(final int whichUser) {
        // Note that only the owner user is currently involved in backup/restore
@@ -78,7 +91,7 @@ public class Trampoline extends IBackupManager.Stub {

            synchronized (this) {
                if (!mSuppressFile.exists()) {
                    mService = new BackupManagerService(mContext, this);
                    mService = createService();
                } else {
                    Slog.i(TAG, "Backup inactive in user " + whichUser);
                }
@@ -105,7 +118,7 @@ public class Trampoline extends IBackupManager.Stub {
                    Slog.i(TAG, "Making backup "
                            + (makeActive ? "" : "in") + "active in user " + userHandle);
                    if (makeActive) {
                        mService = new BackupManagerService(mContext, this);
                        mService = createService();
                        mSuppressFile.delete();
                    } else {
                        mService = null;