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

Commit e227ec61 authored by Christopher Tate's avatar Christopher Tate
Browse files

Let bmgr inspect the set of whitelisted transports

Needed for compliance testing.

Bug 29072466

Change-Id: I025058ab9197f9e2db062bf0074e79f1cd04b443
parent 931a7c03
Loading
Loading
Loading
Loading
+19 −0
Original line number Diff line number Diff line
@@ -122,6 +122,11 @@ public final class Bmgr {
            return;
        }

        if ("whitelist".equals(op)) {
            doPrintWhitelist();
            return;
        }

        System.err.println("Unknown command");
        showUsage();
    }
@@ -604,6 +609,20 @@ public final class Bmgr {
        }
    }

    private void doPrintWhitelist() {
        try {
            final String[] whitelist = mBmgr.getTransportWhitelist();
            if (whitelist != null) {
                for (String transport : whitelist) {
                    System.out.println(transport);
                }
            }
        } catch (RemoteException e) {
            System.err.println(e.toString());
            System.err.println(BMGR_NOT_RUNNING_ERR);
        }
    }

    private String nextArg() {
        if (mNextArg >= mArgs.length) {
            return null;
+8 −0
Original line number Diff line number Diff line
@@ -217,6 +217,14 @@ interface IBackupManager {
     */
    String[] listAllTransports();

    /**
     * Retrieve the list of whitelisted transport components.  Callers do </i>not</i> need
     * any special permission.
     *
     * @return The names of all whitelisted transport components defined by the system.
     */
    String[] getTransportWhitelist();

    /**
     * Specify the current backup transport.  Callers must hold the
     * android.permission.BACKUP permission to use this method.
+9 −0
Original line number Diff line number Diff line
@@ -9597,6 +9597,15 @@ if (MORE_DEBUG) Slog.v(TAG, " + got " + nRead + "; now wanting " + (size - soF
        return list;
    }

    public String[] getTransportWhitelist() {
        // No permission check, intentionally.
        String[] whitelist = new String[mTransportWhitelist.size()];
        for (int i = mTransportWhitelist.size() - 1; i >= 0; i--) {
            whitelist[i] = mTransportWhitelist.valueAt(i).flattenToShortString();
        }
        return whitelist;
    }

    // Select which transport to use for the next backup operation.
    public String selectBackupTransport(String transport) {
        mContext.enforceCallingOrSelfPermission(android.Manifest.permission.BACKUP,
+6 −0
Original line number Diff line number Diff line
@@ -274,6 +274,12 @@ public class Trampoline extends IBackupManager.Stub {
        return (svc != null) ? svc.listAllTransports() : null;
    }

    @Override
    public String[] getTransportWhitelist() {
        BackupManagerService svc = mService;
        return (svc != null) ? svc.getTransportWhitelist() : null;
    }

    @Override
    public String selectBackupTransport(String transport) throws RemoteException {
        BackupManagerService svc = mService;