Merge "Add dumpsys network_stack version"
am: 2b0582e2e6
Change-Id: I6b2369a9f9c8fed4d762b98af19a8b1a8f78ff53
This commit is contained in:
@@ -62,6 +62,7 @@ import java.util.ArrayDeque;
|
|||||||
import java.util.ArrayList;
|
import java.util.ArrayList;
|
||||||
import java.util.HashSet;
|
import java.util.HashSet;
|
||||||
import java.util.Iterator;
|
import java.util.Iterator;
|
||||||
|
import java.util.concurrent.atomic.AtomicInteger;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Android service used to start the network stack when bound to via an intent.
|
* Android service used to start the network stack when bound to via an intent.
|
||||||
@@ -117,6 +118,15 @@ public class NetworkStackService extends Service {
|
|||||||
@GuardedBy("mValidationLogs")
|
@GuardedBy("mValidationLogs")
|
||||||
private final ArrayDeque<SharedLog> mValidationLogs = new ArrayDeque<>(MAX_VALIDATION_LOGS);
|
private final ArrayDeque<SharedLog> mValidationLogs = new ArrayDeque<>(MAX_VALIDATION_LOGS);
|
||||||
|
|
||||||
|
private static final int VERSION_UNKNOWN = 0;
|
||||||
|
private static final String DUMPSYS_ARG_VERSION = "version";
|
||||||
|
|
||||||
|
/** Version of the AIDL interfaces observed on the system */
|
||||||
|
private final AtomicInteger mSystemAidlVersion = new AtomicInteger(VERSION_UNKNOWN);
|
||||||
|
|
||||||
|
/** Whether different versions have been observed on interfaces provided by the system */
|
||||||
|
private volatile boolean mConflictingSystemAidlVersions = false;
|
||||||
|
|
||||||
private SharedLog addValidationLogs(Network network, String name) {
|
private SharedLog addValidationLogs(Network network, String name) {
|
||||||
final SharedLog log = new SharedLog(NUM_VALIDATION_LOG_LINES, network + " - " + name);
|
final SharedLog log = new SharedLog(NUM_VALIDATION_LOG_LINES, network + " - " + name);
|
||||||
synchronized (mValidationLogs) {
|
synchronized (mValidationLogs) {
|
||||||
@@ -143,6 +153,13 @@ public class NetworkStackService extends Service {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private void updateSystemAidlVersion(final int version) {
|
||||||
|
final int previousVersion = mSystemAidlVersion.getAndSet(version);
|
||||||
|
if (previousVersion != VERSION_UNKNOWN && previousVersion != version) {
|
||||||
|
mConflictingSystemAidlVersions = true;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
@NonNull
|
@NonNull
|
||||||
private final SharedLog mLog = new SharedLog(TAG);
|
private final SharedLog mLog = new SharedLog(TAG);
|
||||||
|
|
||||||
@@ -150,6 +167,7 @@ public class NetworkStackService extends Service {
|
|||||||
public void makeDhcpServer(@NonNull String ifName, @NonNull DhcpServingParamsParcel params,
|
public void makeDhcpServer(@NonNull String ifName, @NonNull DhcpServingParamsParcel params,
|
||||||
@NonNull IDhcpServerCallbacks cb) throws RemoteException {
|
@NonNull IDhcpServerCallbacks cb) throws RemoteException {
|
||||||
checkNetworkStackCallingPermission();
|
checkNetworkStackCallingPermission();
|
||||||
|
updateSystemAidlVersion(cb.getInterfaceVersion());
|
||||||
final DhcpServer server;
|
final DhcpServer server;
|
||||||
try {
|
try {
|
||||||
server = new DhcpServer(
|
server = new DhcpServer(
|
||||||
@@ -171,6 +189,7 @@ public class NetworkStackService extends Service {
|
|||||||
@Override
|
@Override
|
||||||
public void makeNetworkMonitor(Network network, String name, INetworkMonitorCallbacks cb)
|
public void makeNetworkMonitor(Network network, String name, INetworkMonitorCallbacks cb)
|
||||||
throws RemoteException {
|
throws RemoteException {
|
||||||
|
updateSystemAidlVersion(cb.getInterfaceVersion());
|
||||||
final SharedLog log = addValidationLogs(network, name);
|
final SharedLog log = addValidationLogs(network, name);
|
||||||
final NetworkMonitor nm = new NetworkMonitor(mContext, cb, network, log);
|
final NetworkMonitor nm = new NetworkMonitor(mContext, cb, network, log);
|
||||||
cb.onNetworkMonitorCreated(new NetworkMonitorImpl(nm));
|
cb.onNetworkMonitorCreated(new NetworkMonitorImpl(nm));
|
||||||
@@ -178,6 +197,7 @@ public class NetworkStackService extends Service {
|
|||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void makeIpClient(String ifName, IIpClientCallbacks cb) throws RemoteException {
|
public void makeIpClient(String ifName, IIpClientCallbacks cb) throws RemoteException {
|
||||||
|
updateSystemAidlVersion(cb.getInterfaceVersion());
|
||||||
final IpClient ipClient = new IpClient(mContext, ifName, cb, mObserverRegistry, this);
|
final IpClient ipClient = new IpClient(mContext, ifName, cb, mObserverRegistry, this);
|
||||||
|
|
||||||
synchronized (mIpClients) {
|
synchronized (mIpClients) {
|
||||||
@@ -202,6 +222,7 @@ public class NetworkStackService extends Service {
|
|||||||
@Override
|
@Override
|
||||||
public void fetchIpMemoryStore(@NonNull final IIpMemoryStoreCallbacks cb)
|
public void fetchIpMemoryStore(@NonNull final IIpMemoryStoreCallbacks cb)
|
||||||
throws RemoteException {
|
throws RemoteException {
|
||||||
|
updateSystemAidlVersion(cb.getInterfaceVersion());
|
||||||
cb.onIpMemoryStoreFetched(mIpMemoryStoreService);
|
cb.onIpMemoryStoreFetched(mIpMemoryStoreService);
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -209,6 +230,11 @@ public class NetworkStackService extends Service {
|
|||||||
protected void dump(@NonNull FileDescriptor fd, @NonNull PrintWriter fout,
|
protected void dump(@NonNull FileDescriptor fd, @NonNull PrintWriter fout,
|
||||||
@Nullable String[] args) {
|
@Nullable String[] args) {
|
||||||
checkDumpPermission();
|
checkDumpPermission();
|
||||||
|
if (args != null && args.length >= 1 && DUMPSYS_ARG_VERSION.equals(args[0])) {
|
||||||
|
dumpVersion(fout);
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
final IndentingPrintWriter pw = new IndentingPrintWriter(fout, " ");
|
final IndentingPrintWriter pw = new IndentingPrintWriter(fout, " ");
|
||||||
pw.println("NetworkStack logs:");
|
pw.println("NetworkStack logs:");
|
||||||
mLog.dump(fd, pw, args);
|
mLog.dump(fd, pw, args);
|
||||||
@@ -252,6 +278,15 @@ public class NetworkStackService extends Service {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Dump version information of the module and detected system version.
|
||||||
|
*/
|
||||||
|
private void dumpVersion(@NonNull PrintWriter fout) {
|
||||||
|
fout.println("NetworkStackConnector: " + this.VERSION);
|
||||||
|
fout.println("SystemServer: " + mSystemAidlVersion);
|
||||||
|
fout.println("SystemServerConflicts: " + mConflictingSystemAidlVersions);
|
||||||
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public int getInterfaceVersion() {
|
public int getInterfaceVersion() {
|
||||||
return this.VERSION;
|
return this.VERSION;
|
||||||
|
|||||||
Reference in New Issue
Block a user