Merge "Let bmgr inspect the set of whitelisted transports" into nyc-dev

This commit is contained in:
Chris Tate
2016-06-20 17:19:50 +00:00
committed by Android (Google) Code Review
4 changed files with 42 additions and 0 deletions

View File

@ -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;

View File

@ -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.

View File

@ -9598,6 +9598,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,

View File

@ -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;