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

Commit 6052ef56 authored by Artem Iglikov's avatar Artem Iglikov
Browse files

Add unit test for Trampoline.

This adds the test to FrameworksServicesTests test suite, which can be
run with the following command:

make FrameworksServicesTests -j &&
adb install -r ${OUT}/data/app/FrameworksServicesTests/FrameworksServicesTests.apk &&
adb shell am instrument -w -e package com.android.server.backup \
com.android.frameworks.servicestests/android.support.test.runner.AndroidJUnitRunner

Bug: 37520021

Test: manually ran the test

Change-Id: I3f0dc50b0eb2ff2bc9360c68714c27e82b820897
parent dc52b3c0
Loading
Loading
Loading
Loading
+27 −5
Original line number Original line Diff line number Diff line
@@ -43,6 +43,22 @@ import java.io.FileDescriptor;
import java.io.IOException;
import java.io.IOException;
import java.io.PrintWriter;
import java.io.PrintWriter;



/**
 * A proxy to BackupManagerService implementation.
 *
 * This is an external interface to the BackupManagerService which is being accessed via published
 * binder (see BackupManagerService$Lifecycle). This lets us turn down the heavy implementation
 * object on the fly without disturbing binders that have been cached somewhere in the system.
 *
 * This is where it is decided whether backup subsystem is available. It can be disabled with the
 * following two methods:
 *
 * <ul>
 * <li> Temporarily - create a file named Trampoline.BACKUP_SUPPRESS_FILENAME, or
 * <li> Product level - set Trampoline.BACKUP_DISABLE_PROPERTY system property to true.
 * </ul>
 */
public class Trampoline extends IBackupManager.Stub {
public class Trampoline extends IBackupManager.Stub {
    static final String TAG = "BackupManagerService";
    static final String TAG = "BackupManagerService";
    static final boolean DEBUG_TRAMPOLINE = false;
    static final boolean DEBUG_TRAMPOLINE = false;
@@ -59,14 +75,20 @@ public class Trampoline extends IBackupManager.Stub {
    volatile BackupManagerServiceInterface mService;
    volatile BackupManagerServiceInterface mService;


    public Trampoline(Context context) {
    public Trampoline(Context context) {
        this(context,
                SystemProperties.getBoolean(BACKUP_DISABLE_PROPERTY, false),
                new File(new File(Environment.getDataDirectory(), "backup"),
                        BACKUP_SUPPRESS_FILENAME));
    }

    protected Trampoline(Context context, boolean globalDisable, File suppressFile) {
        mContext = context;
        mContext = context;
        File dir = new File(Environment.getDataDirectory(), "backup");
        mGlobalDisable = globalDisable;
        dir.mkdirs();
        mSuppressFile = suppressFile;
        mSuppressFile = new File(dir, BACKUP_SUPPRESS_FILENAME);
        mSuppressFile.getParentFile().mkdirs();
        mGlobalDisable = SystemProperties.getBoolean(BACKUP_DISABLE_PROPERTY, false);
    }
    }


    private BackupManagerServiceInterface createService() {
    protected BackupManagerServiceInterface createService() {
        boolean refactoredServiceEnabled = Settings.Global.getInt(mContext.getContentResolver(),
        boolean refactoredServiceEnabled = Settings.Global.getInt(mContext.getContentResolver(),
            Settings.Global.BACKUP_REFACTORED_SERVICE_DISABLED, 1) == 0;
            Settings.Global.BACKUP_REFACTORED_SERVICE_DISABLED, 1) == 0;
        if (refactoredServiceEnabled) {
        if (refactoredServiceEnabled) {
+1 −0
Original line number Original line Diff line number Diff line
@@ -15,6 +15,7 @@ LOCAL_STATIC_JAVA_LIBRARIES := \
    frameworks-base-testutils \
    frameworks-base-testutils \
    services.accessibility \
    services.accessibility \
    services.appwidget \
    services.appwidget \
    services.backup \
    services.core \
    services.core \
    services.devicepolicy \
    services.devicepolicy \
    services.net \
    services.net \
+647 −0

File added.

Preview size limit exceeded, changes collapsed.