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

Commit da7b36c9 authored by Annie Meng's avatar Annie Meng Committed by Android (Google) Code Review
Browse files

Merge "Disable bmgr if BMS is not running"

parents 88cc4d09 89270374
Loading
Loading
Loading
Loading
+22 −3
Original line number Diff line number Diff line
@@ -71,9 +71,7 @@ public final class Bmgr {
            return;
        }

        mBmgr = IBackupManager.Stub.asInterface(ServiceManager.getService("backup"));
        if (mBmgr == null) {
            System.err.println(BMGR_NOT_RUNNING_ERR);
        if (!isBmgrActive()) {
            return;
        }

@@ -150,6 +148,27 @@ public final class Bmgr {
        showUsage();
    }

    private boolean isBmgrActive() {
        mBmgr = IBackupManager.Stub.asInterface(ServiceManager.getService("backup"));
        if (mBmgr == null) {
            System.err.println(BMGR_NOT_RUNNING_ERR);
            return false;
        }

        try {
            if (!mBmgr.isBackupServiceActive(UserHandle.USER_SYSTEM)) {
                System.err.println(BMGR_NOT_RUNNING_ERR);
                return false;
            }
        } catch (RemoteException e) {
            System.err.println(e.toString());
            System.err.println(BMGR_NOT_RUNNING_ERR);
            return false;
        }

        return true;
    }

    private String enableToString(boolean enabled) {
        return enabled ? "enabled" : "disabled";
    }