Merge "Register ConnectivityService with dumpsys priorities"

This commit is contained in:
TreeHugger Robot
2017-10-26 23:45:46 +00:00
committed by Android (Google) Code Review
2 changed files with 31 additions and 1 deletions

View File

@@ -143,6 +143,7 @@ import com.android.server.connectivity.tethering.TetheringDependencies;
import com.android.server.net.BaseNetworkObserver;
import com.android.server.net.LockdownVpnTracker;
import com.android.server.net.NetworkPolicyManagerInternal;
import com.android.server.utils.PriorityDump;
import com.google.android.collect.Lists;
@@ -682,6 +683,28 @@ public class ConnectivityService extends IConnectivityManager.Stub
}
private LegacyTypeTracker mLegacyTypeTracker = new LegacyTypeTracker();
/**
* Helper class which parses out priority arguments and dumps sections according to their
* priority. If priority arguments are omitted, function calls the legacy dump command.
*/
private final PriorityDump.PriorityDumper mPriorityDumper = new PriorityDump.PriorityDumper() {
@Override
public void dumpHigh(FileDescriptor fd, PrintWriter pw, String[] args, boolean asProto) {
doDump(fd, pw, new String[] {DIAG_ARG}, asProto);
doDump(fd, pw, new String[] {SHORT_ARG}, asProto);
}
@Override
public void dumpNormal(FileDescriptor fd, PrintWriter pw, String[] args, boolean asProto) {
doDump(fd, pw, args, asProto);
}
@Override
public void dump(FileDescriptor fd, PrintWriter pw, String[] args, boolean asProto) {
doDump(fd, pw, args, asProto);
}
};
public ConnectivityService(Context context, INetworkManagementService netManager,
INetworkStatsService statsService, INetworkPolicyManager policyManager) {
this(context, netManager, statsService, policyManager, new IpConnectivityLog());
@@ -1862,8 +1885,13 @@ public class ConnectivityService extends IConnectivityManager.Stub
@Override
protected void dump(FileDescriptor fd, PrintWriter writer, String[] args) {
PriorityDump.dump(mPriorityDumper, fd, writer, args);
}
private void doDump(FileDescriptor fd, PrintWriter writer, String[] args, boolean asProto) {
final IndentingPrintWriter pw = new IndentingPrintWriter(writer, " ");
if (!DumpUtils.checkDumpPermission(mContext, TAG, pw)) return;
if (asProto) return;
if (argsContain(args, DIAG_ARG)) {
dumpNetworkDiagnostics(pw);

View File

@@ -1138,7 +1138,9 @@ public final class SystemServer {
try {
connectivity = new ConnectivityService(
context, networkManagement, networkStats, networkPolicy);
ServiceManager.addService(Context.CONNECTIVITY_SERVICE, connectivity);
ServiceManager.addService(Context.CONNECTIVITY_SERVICE, connectivity,
/* allowIsolated= */ false,
DUMP_FLAG_PRIORITY_HIGH | DUMP_FLAG_PRIORITY_NORMAL);
networkStats.bindConnectivityManager(connectivity);
networkPolicy.bindConnectivityManager(connectivity);
} catch (Throwable e) {