summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
author Joel Scherpelz <jscherpelz@google.com> 2017-05-29 03:28:00 +0000
committer Gerrit Code Review <noreply-gerritcodereview@google.com> 2017-05-29 03:28:02 +0000
commitbf152b14c4d1c9fa46c19fe48fdd63934ba06fa2 (patch)
treecdf94d93b2c75c7855325129ea5182e9ab683ae0
parent39ce589f0b13693468fcc2e8f55eb299c6a52057 (diff)
parentb369bf5d3a80a98fca7f9c4585fe735bb489b458 (diff)
Merge "Support requesting and receiving wakeup events"
-rw-r--r--services/core/java/com/android/server/ConnectivityService.java32
-rw-r--r--services/core/java/com/android/server/connectivity/NetdEventListenerService.java4
2 files changed, 34 insertions, 2 deletions
diff --git a/services/core/java/com/android/server/ConnectivityService.java b/services/core/java/com/android/server/ConnectivityService.java
index 7b4981e478ff..da9c96669037 100644
--- a/services/core/java/com/android/server/ConnectivityService.java
+++ b/services/core/java/com/android/server/ConnectivityService.java
@@ -214,6 +214,13 @@ public class ConnectivityService extends IConnectivityManager.Stub
// 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;
@@ -4480,7 +4487,7 @@ public class ConnectivityService extends IConnectivityManager.Stub
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()) {
@@ -4518,7 +4525,26 @@ public class ConnectivityService extends IConnectivityManager.Stub
}
}
- 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);
@@ -4529,6 +4555,7 @@ public class ConnectivityService extends IConnectivityManager.Stub
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);
}
@@ -4537,6 +4564,7 @@ public class ConnectivityService extends IConnectivityManager.Stub
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 3f056a54d1f4..4bd6fb36bee0 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 @@ public class NetdEventListenerService extends INetdEventListener.Stub {
}
}
+ @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