Merge "Support "dumpsys connectivity tethering""
diff --git a/services/core/java/com/android/server/ConnectivityService.java b/services/core/java/com/android/server/ConnectivityService.java
index ad02980..2435c27 100644
--- a/services/core/java/com/android/server/ConnectivityService.java
+++ b/services/core/java/com/android/server/ConnectivityService.java
@@ -215,6 +215,13 @@
// See Settings.Secure.CONNECTIVITY_RELEASE_PENDING_INTENT_DELAY_MS
private final int mReleasePendingIntentDelayMs;
+ // Driver specific constants used to select packets received via
+ // WiFi that caused the phone to exit sleep state. Currently there
+ // is only one kernel implementation so we can get away with
+ // constants.
+ private static final int mWakeupPacketMark = 0x80000000;
+ private static final int mWakeupPacketMask = 0x80000000;
+
private MockableSystemProperties mSystemProperties;
private Tethering mTethering;
@@ -4484,7 +4491,7 @@
networkAgent.clatd.fixupLinkProperties(oldLp);
}
- updateInterfaces(newLp, oldLp, netId);
+ updateInterfaces(newLp, oldLp, netId, networkAgent.networkCapabilities);
updateMtu(newLp, oldLp);
// TODO - figure out what to do for clat
// for (LinkProperties lp : newLp.getStackedLinks()) {
@@ -4522,7 +4529,26 @@
}
}
- private void updateInterfaces(LinkProperties newLp, LinkProperties oldLp, int netId) {
+ private void wakeupAddInterface(String iface, NetworkCapabilities caps) throws RemoteException {
+ // Marks are only available on WiFi interaces. Checking for
+ // marks on unsupported interfaces is harmless.
+ if (!caps.hasTransport(NetworkCapabilities.TRANSPORT_WIFI)) {
+ return;
+ }
+ mNetd.getNetdService().wakeupAddInterface(
+ iface, "iface:" + iface, mWakeupPacketMark, mWakeupPacketMask);
+ }
+
+ private void wakeupDelInterface(String iface, NetworkCapabilities caps) throws RemoteException {
+ if (!caps.hasTransport(NetworkCapabilities.TRANSPORT_WIFI)) {
+ return;
+ }
+ mNetd.getNetdService().wakeupDelInterface(
+ iface, "iface:" + iface, mWakeupPacketMark, mWakeupPacketMask);
+ }
+
+ private void updateInterfaces(LinkProperties newLp, LinkProperties oldLp, int netId,
+ NetworkCapabilities caps) {
CompareResult<String> interfaceDiff = new CompareResult<String>();
if (oldLp != null) {
interfaceDiff = oldLp.compareAllInterfaceNames(newLp);
@@ -4533,6 +4559,7 @@
try {
if (DBG) log("Adding iface " + iface + " to network " + netId);
mNetd.addInterfaceToNetwork(iface, netId);
+ wakeupAddInterface(iface, caps);
} catch (Exception e) {
loge("Exception adding interface: " + e);
}
@@ -4541,6 +4568,7 @@
try {
if (DBG) log("Removing iface " + iface + " from network " + netId);
mNetd.removeInterfaceFromNetwork(iface, netId);
+ wakeupDelInterface(iface, caps);
} catch (Exception e) {
loge("Exception removing interface: " + e);
}
diff --git a/services/core/java/com/android/server/connectivity/NetdEventListenerService.java b/services/core/java/com/android/server/connectivity/NetdEventListenerService.java
index 3f056a5..4bd6fb3 100644
--- a/services/core/java/com/android/server/connectivity/NetdEventListenerService.java
+++ b/services/core/java/com/android/server/connectivity/NetdEventListenerService.java
@@ -198,6 +198,10 @@
}
}
+ @Override
+ public synchronized void onWakeupEvent(String prefix, int uid, int gid, long timestampNs) {
+ }
+
public synchronized void flushStatistics(List<IpConnectivityEvent> events) {
events.add(flushConnectStats());
// TODO: migrate DnsEventBatch to IpConnectivityLogClass.DNSLatencies