Add onReachabilityFailure api in IIpClientCallbacks aidl.
The new API is called when neighbor reachability loss event happens
since networkstack-aidl-interfaces-V13, this CL also defines a few
associated constants representing different neighbor reachability
loss events and a stable parcelable as the parameter.
Bug: 204723906
Test: atest NetworkStackTests
Change-Id: Ie6382206de2107aa4654f0628f2f446017d7ea34
diff --git a/common/networkstackclient/Android.bp b/common/networkstackclient/Android.bp
index 983bb61..3696e92 100644
--- a/common/networkstackclient/Android.bp
+++ b/common/networkstackclient/Android.bp
@@ -102,6 +102,8 @@
// New AIDL classes should go into android.net.networkstack.aidl so they can be clearly
// identified
"src/android/net/networkstack/aidl/dhcp/DhcpOption.aidl",
+ "src/android/net/networkstack/aidl/ip/ReachabilityLossInfoParcelable.aidl",
+ "src/android/net/networkstack/aidl/ip/ReachabilityLossReason.aidl",
],
backend: {
java: {
diff --git a/common/networkstackclient/aidl_api/networkstack-aidl-interfaces/current/android/net/ip/IIpClientCallbacks.aidl b/common/networkstackclient/aidl_api/networkstack-aidl-interfaces/current/android/net/ip/IIpClientCallbacks.aidl
index 488510d..24bbf64 100644
--- a/common/networkstackclient/aidl_api/networkstack-aidl-interfaces/current/android/net/ip/IIpClientCallbacks.aidl
+++ b/common/networkstackclient/aidl_api/networkstack-aidl-interfaces/current/android/net/ip/IIpClientCallbacks.aidl
@@ -48,4 +48,5 @@
oneway void setFallbackMulticastFilter(boolean enabled);
oneway void setNeighborDiscoveryOffload(boolean enable);
oneway void onPreconnectionStart(in List<android.net.Layer2PacketParcelable> packets);
+ oneway void onReachabilityFailure(in android.net.networkstack.aidl.ip.ReachabilityLossInfoParcelable lossInfo);
}
diff --git a/common/networkstackclient/aidl_api/networkstack-aidl-interfaces/current/android/net/networkstack/aidl/ip/ReachabilityLossInfoParcelable.aidl b/common/networkstackclient/aidl_api/networkstack-aidl-interfaces/current/android/net/networkstack/aidl/ip/ReachabilityLossInfoParcelable.aidl
new file mode 100644
index 0000000..bb88434
--- /dev/null
+++ b/common/networkstackclient/aidl_api/networkstack-aidl-interfaces/current/android/net/networkstack/aidl/ip/ReachabilityLossInfoParcelable.aidl
@@ -0,0 +1,39 @@
+/*
+ * Copyright (C) 2021 The Android Open Source Project
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+///////////////////////////////////////////////////////////////////////////////
+// THIS FILE IS IMMUTABLE. DO NOT EDIT IN ANY CASE. //
+///////////////////////////////////////////////////////////////////////////////
+
+// This file is a snapshot of an AIDL file. Do not edit it manually. There are
+// two cases:
+// 1). this is a frozen version file - do not edit this in any case.
+// 2). this is a 'current' file. If you make a backwards compatible change to
+// the interface (from the latest frozen version), the build system will
+// prompt you to update this file with `m <name>-update-api`.
+//
+// You must not make a backward incompatible change to any AIDL file built
+// with the aidl_interface module type with versions property set. The module
+// type is used to build AIDL files in a way that they can be used across
+// independently updatable components of the system. If a device is shipped
+// with such a backward incompatible change, it has a high risk of breaking
+// later when a module using the interface is updated, e.g., Mainline modules.
+
+package android.net.networkstack.aidl.ip;
+@JavaDerive(equals=true, toString=true) @JavaOnlyImmutable
+parcelable ReachabilityLossInfoParcelable {
+ String message;
+ android.net.networkstack.aidl.ip.ReachabilityLossReason reason;
+}
diff --git a/common/networkstackclient/aidl_api/networkstack-aidl-interfaces/current/android/net/networkstack/aidl/ip/ReachabilityLossReason.aidl b/common/networkstackclient/aidl_api/networkstack-aidl-interfaces/current/android/net/networkstack/aidl/ip/ReachabilityLossReason.aidl
new file mode 100644
index 0000000..70a7db2
--- /dev/null
+++ b/common/networkstackclient/aidl_api/networkstack-aidl-interfaces/current/android/net/networkstack/aidl/ip/ReachabilityLossReason.aidl
@@ -0,0 +1,40 @@
+/*
+ * Copyright (C) 2021 The Android Open Source Project
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+///////////////////////////////////////////////////////////////////////////////
+// THIS FILE IS IMMUTABLE. DO NOT EDIT IN ANY CASE. //
+///////////////////////////////////////////////////////////////////////////////
+
+// This file is a snapshot of an AIDL file. Do not edit it manually. There are
+// two cases:
+// 1). this is a frozen version file - do not edit this in any case.
+// 2). this is a 'current' file. If you make a backwards compatible change to
+// the interface (from the latest frozen version), the build system will
+// prompt you to update this file with `m <name>-update-api`.
+//
+// You must not make a backward incompatible change to any AIDL file built
+// with the aidl_interface module type with versions property set. The module
+// type is used to build AIDL files in a way that they can be used across
+// independently updatable components of the system. If a device is shipped
+// with such a backward incompatible change, it has a high risk of breaking
+// later when a module using the interface is updated, e.g., Mainline modules.
+
+package android.net.networkstack.aidl.ip;
+@Backing(type="int")
+enum ReachabilityLossReason {
+ ROAM = 0,
+ CONFIRM = 1,
+ ORGANIC = 2,
+}
diff --git a/common/networkstackclient/src/android/net/ip/IIpClientCallbacks.aidl b/common/networkstackclient/src/android/net/ip/IIpClientCallbacks.aidl
index de398ed..932672e 100644
--- a/common/networkstackclient/src/android/net/ip/IIpClientCallbacks.aidl
+++ b/common/networkstackclient/src/android/net/ip/IIpClientCallbacks.aidl
@@ -18,6 +18,7 @@
import android.net.Layer2PacketParcelable;
import android.net.LinkProperties;
import android.net.ip.IIpClient;
+import android.net.networkstack.aidl.ip.ReachabilityLossInfoParcelable;
import android.net.DhcpResultsParcelable;
/** @hide */
@@ -67,4 +68,8 @@
// Invoked on starting preconnection process.
void onPreconnectionStart(in List<Layer2PacketParcelable> packets);
+
+ // Called when the internal IpReachabilityMonitor (if enabled) has detected the loss of a
+ // critical number of required neighbors or DHCP roaming fails.
+ void onReachabilityFailure(in ReachabilityLossInfoParcelable lossInfo);
}
diff --git a/common/networkstackclient/src/android/net/ip/IpClientCallbacks.java b/common/networkstackclient/src/android/net/ip/IpClientCallbacks.java
index b17fcaa..d3e6cb7 100644
--- a/common/networkstackclient/src/android/net/ip/IpClientCallbacks.java
+++ b/common/networkstackclient/src/android/net/ip/IpClientCallbacks.java
@@ -19,6 +19,7 @@
import android.net.DhcpResultsParcelable;
import android.net.Layer2PacketParcelable;
import android.net.LinkProperties;
+import android.net.networkstack.aidl.ip.ReachabilityLossInfoParcelable;
import java.util.List;
@@ -133,4 +134,12 @@
* Invoked on starting preconnection process.
*/
public void onPreconnectionStart(List<Layer2PacketParcelable> packets) {}
+
+ /**
+ * Called when the internal IpReachabilityMonitor (if enabled) has detected the loss of a
+ * critical number of required neighbors or DHCP roaming fails.
+ *
+ * @param lossInfo the specific neighbor reachability loss information.
+ */
+ public void onReachabilityFailure(ReachabilityLossInfoParcelable lossInfo) {}
}
diff --git a/common/networkstackclient/src/android/net/ip/IpClientUtil.java b/common/networkstackclient/src/android/net/ip/IpClientUtil.java
index 1b55776..d488578 100644
--- a/common/networkstackclient/src/android/net/ip/IpClientUtil.java
+++ b/common/networkstackclient/src/android/net/ip/IpClientUtil.java
@@ -21,6 +21,7 @@
import android.net.Layer2PacketParcelable;
import android.net.LinkProperties;
import android.net.networkstack.ModuleNetworkStackClient;
+import android.net.networkstack.aidl.ip.ReachabilityLossInfoParcelable;
import android.os.ConditionVariable;
import java.io.FileDescriptor;
@@ -182,6 +183,13 @@
mCb.onPreconnectionStart(packets);
}
+ // Called when the internal IpReachabilityMonitor (if enabled) has detected the loss of a
+ // critical number of required neighbors or DHCP roaming fails.
+ @Override
+ public void onReachabilityFailure(ReachabilityLossInfoParcelable lossInfo) {
+ mCb.onReachabilityFailure(lossInfo);
+ }
+
@Override
public int getInterfaceVersion() {
return this.VERSION;
diff --git a/common/networkstackclient/src/android/net/networkstack/aidl/ip/ReachabilityLossInfoParcelable.aidl b/common/networkstackclient/src/android/net/networkstack/aidl/ip/ReachabilityLossInfoParcelable.aidl
new file mode 100644
index 0000000..fda6264
--- /dev/null
+++ b/common/networkstackclient/src/android/net/networkstack/aidl/ip/ReachabilityLossInfoParcelable.aidl
@@ -0,0 +1,28 @@
+/*
+ * Copyright (C) 2021 The Android Open Source Project
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package android.net.networkstack.aidl.ip;
+
+import android.net.networkstack.aidl.ip.ReachabilityLossReason;
+
+@JavaDerive(equals=true, toString=true) @JavaOnlyImmutable
+parcelable ReachabilityLossInfoParcelable {
+ /** The log message when reachability loss happens. */
+ String message;
+
+ /** The specific reason of reachability loss. */
+ ReachabilityLossReason reason;
+}
diff --git a/common/networkstackclient/src/android/net/networkstack/aidl/ip/ReachabilityLossReason.aidl b/common/networkstackclient/src/android/net/networkstack/aidl/ip/ReachabilityLossReason.aidl
new file mode 100644
index 0000000..cc2e9e7
--- /dev/null
+++ b/common/networkstackclient/src/android/net/networkstack/aidl/ip/ReachabilityLossReason.aidl
@@ -0,0 +1,24 @@
+/*
+ * Copyright (C) 2021 The Android Open Source Project
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package android.net.networkstack.aidl.ip;
+
+@Backing(type="int")
+enum ReachabilityLossReason {
+ ROAM, // reachability loss due to L2 roaming.
+ CONFIRM, // reachability loss due to WiFi RSSI check.
+ ORGANIC, // reachability loss notification comes from kernel.
+}