summaryrefslogtreecommitdiff
path: root/core/java
diff options
context:
space:
mode:
Diffstat (limited to 'core/java')
-rw-r--r--core/java/android/net/IIpConnectivityMetrics.aidl8
-rw-r--r--core/java/android/net/metrics/IpConnectivityLog.java59
2 files changed, 64 insertions, 3 deletions
diff --git a/core/java/android/net/IIpConnectivityMetrics.aidl b/core/java/android/net/IIpConnectivityMetrics.aidl
index aeaf09d8fafe..aa3682d92105 100644
--- a/core/java/android/net/IIpConnectivityMetrics.aidl
+++ b/core/java/android/net/IIpConnectivityMetrics.aidl
@@ -19,6 +19,9 @@ package android.net;
import android.os.Parcelable;
import android.net.ConnectivityMetricsEvent;
import android.net.INetdEventCallback;
+import android.net.LinkProperties;
+import android.net.Network;
+import android.net.NetworkCapabilities;
/** {@hide} */
interface IIpConnectivityMetrics {
@@ -29,6 +32,11 @@ interface IIpConnectivityMetrics {
*/
int logEvent(in ConnectivityMetricsEvent event);
+ void logDefaultNetworkValidity(boolean valid);
+ void logDefaultNetworkEvent(in Network defaultNetwork, int score, boolean validated,
+ in LinkProperties lp, in NetworkCapabilities nc, in Network previousDefaultNetwork,
+ int previousScore, in LinkProperties previousLp, in NetworkCapabilities previousNc);
+
/**
* Callback can be registered by DevicePolicyManager or NetworkWatchlistService only.
* @return status {@code true} if registering/unregistering of the callback was successful,
diff --git a/core/java/android/net/metrics/IpConnectivityLog.java b/core/java/android/net/metrics/IpConnectivityLog.java
index a008d855025a..58ea91573775 100644
--- a/core/java/android/net/metrics/IpConnectivityLog.java
+++ b/core/java/android/net/metrics/IpConnectivityLog.java
@@ -17,10 +17,13 @@
package android.net.metrics;
import android.annotation.NonNull;
+import android.annotation.Nullable;
import android.annotation.SystemApi;
import android.net.ConnectivityMetricsEvent;
import android.net.IIpConnectivityMetrics;
+import android.net.LinkProperties;
import android.net.Network;
+import android.net.NetworkCapabilities;
import android.os.Parcelable;
import android.os.RemoteException;
import android.os.ServiceManager;
@@ -66,6 +69,9 @@ public class IpConnectivityLog {
final IIpConnectivityMetrics service =
IIpConnectivityMetrics.Stub.asInterface(ServiceManager.getService(SERVICE_NAME));
if (service == null) {
+ if (DBG) {
+ Log.d(TAG, SERVICE_NAME + " service was not ready");
+ }
return false;
}
// Two threads racing here will write the same pointer because getService
@@ -83,9 +89,6 @@ public class IpConnectivityLog {
*/
public boolean log(@NonNull ConnectivityMetricsEvent ev) {
if (!checkLoggerService()) {
- if (DBG) {
- Log.d(TAG, SERVICE_NAME + " service was not ready");
- }
return false;
}
if (ev.timestamp == 0) {
@@ -161,6 +164,56 @@ public class IpConnectivityLog {
return log(makeEv(data));
}
+ /**
+ * Logs the validation status of the default network.
+ * @param valid whether the current default network was validated (i.e., whether it had
+ * {@link NetworkCapabilities.NET_CAPABILITY_VALIDATED}
+ * @return true if the event was successfully logged.
+ * @hide
+ */
+ public boolean logDefaultNetworkValidity(boolean valid) {
+ if (!checkLoggerService()) {
+ return false;
+ }
+ try {
+ mService.logDefaultNetworkValidity(valid);
+ } catch (RemoteException ignored) {
+ // Only called within the system server.
+ }
+ return true;
+ }
+
+ /**
+ * Logs a change in the default network.
+ *
+ * @param defaultNetwork the current default network
+ * @param score the current score of {@code defaultNetwork}
+ * @param lp the {@link LinkProperties} of {@code defaultNetwork}
+ * @param nc the {@link NetworkCapabilities} of the {@code defaultNetwork}
+ * @param validated whether {@code defaultNetwork} network is validated
+ * @param previousDefaultNetwork the previous default network
+ * @param previousScore the score of {@code previousDefaultNetwork}
+ * @param previousLp the {@link LinkProperties} of {@code previousDefaultNetwork}
+ * @param previousNc the {@link NetworkCapabilities} of {@code previousDefaultNetwork}
+ * @return true if the event was successfully logged.
+ * @hide
+ */
+ public boolean logDefaultNetworkEvent(@Nullable Network defaultNetwork, int score,
+ boolean validated, @Nullable LinkProperties lp, @Nullable NetworkCapabilities nc,
+ @Nullable Network previousDefaultNetwork, int previousScore,
+ @Nullable LinkProperties previousLp, @Nullable NetworkCapabilities previousNc) {
+ if (!checkLoggerService()) {
+ return false;
+ }
+ try {
+ mService.logDefaultNetworkEvent(defaultNetwork, score, validated, lp, nc,
+ previousDefaultNetwork, previousScore, previousLp, previousNc);
+ } catch (RemoteException ignored) {
+ // Only called within the system server.
+ }
+ return true;
+ }
+
private static ConnectivityMetricsEvent makeEv(Event data) {
ConnectivityMetricsEvent ev = new ConnectivityMetricsEvent();
ev.data = data;