summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorFrank Li <lifr@google.com>2020-06-24 16:36:37 +0000
committerAutomerger Merge Worker <android-build-automerger-merge-worker@system.gserviceaccount.com>2020-06-24 16:36:37 +0000
commitc2cdb2c76459fd41a6307de517dbb21d41cef311 (patch)
tree528734e58ad933a85370d7261c69968de84726d1 /src
parent4a61b59c36ff0a0839dc7b3d5dd1a9576e977797 (diff)
parentad90e1bfe13e6a5dc85a33d64c37981ce1ac4408 (diff)
Fix NullPointerException on addErrorCode when input is Invalid error code am: ad90e1bfe1
Original change: https://googleplex-android-review.googlesource.com/c/platform/packages/modules/NetworkStack/+/11987398 Change-Id: I78c4025468341c9a515bcedd83cf19ea6795e283
Diffstat (limited to 'src')
-rw-r--r--src/com/android/networkstack/metrics/IpProvisioningMetrics.java11
1 files changed, 10 insertions, 1 deletions
diff --git a/src/com/android/networkstack/metrics/IpProvisioningMetrics.java b/src/com/android/networkstack/metrics/IpProvisioningMetrics.java
index 1f969d4..64e173d 100644
--- a/src/com/android/networkstack/metrics/IpProvisioningMetrics.java
+++ b/src/com/android/networkstack/metrics/IpProvisioningMetrics.java
@@ -120,12 +120,21 @@ public class IpProvisioningMetrics {
transSuccess ? HostnameTransResult.HTR_SUCCESS : HostnameTransResult.HTR_FAILURE);
}
+ private static DhcpErrorCode dhcpErrorFromNumberSafe(int number) {
+ // See DhcpErrorCode.errorCodeWithOption
+ // TODO: add a DhcpErrorCode method to extract the code;
+ // or replace legacy error codes with the new metrics.
+ final DhcpErrorCode error = DhcpErrorCode.forNumber(number & 0xFFFF0000);
+ if (error == null) return DhcpErrorCode.ET_UNKNOWN;
+ return error;
+ }
+
/**
* write the DHCP error code into DhcpSession.
*/
public void addDhcpErrorCode(final int errorCode) {
if (mDhcpSessionBuilder.getErrorCodeCount() >= MAX_DHCP_ERROR_COUNT) return;
- mDhcpSessionBuilder.addErrorCode(DhcpErrorCode.forNumber(errorCode));
+ mDhcpSessionBuilder.addErrorCode(dhcpErrorFromNumberSafe(errorCode));
}
/**