diff options
author | Xiao Ma <xiaom@google.com> | 2019-12-10 15:56:41 +0900 |
---|---|---|
committer | Xiao Ma <xiaom@google.com> | 2019-12-27 16:10:23 +0900 |
commit | d64f58e96166e3695179f64a5eac52e6f53e39ca (patch) | |
tree | 8a9008afba659aa2996870008ce65feeb8b1200a /src/android/net/util | |
parent | 7b60bfa137ad7ec9213ec4c2169cea4f303e2ce0 (diff) |
Read ARP timing properties from DeviceConfig appropriately.
Overload NetworkStackUtils.getDeviceConfigPropertyInt API to check if the
value of property read from DeviceConfig is valid, value in the range
of mininum and maximum would be acceptable, otherwise, return the default
value.
Bug: 128639898
Test: atest NetworkStackTests NetworkStackIntegrationTests
Change-Id: I07e3e9d1e1b7252d852d4665d2ea254f29a1c3eb
Diffstat (limited to 'src/android/net/util')
-rw-r--r-- | src/android/net/util/NetworkStackUtils.java | 17 |
1 files changed, 17 insertions, 0 deletions
diff --git a/src/android/net/util/NetworkStackUtils.java b/src/android/net/util/NetworkStackUtils.java index 45ed367..d147b45 100644 --- a/src/android/net/util/NetworkStackUtils.java +++ b/src/android/net/util/NetworkStackUtils.java @@ -232,6 +232,23 @@ public class NetworkStackUtils { * Look up the value of a property for a particular namespace from {@link DeviceConfig}. * @param namespace The namespace containing the property to look up. * @param name The name of the property to look up. + * @param minimumValue The minimum value of a property. + * @param maximumValue The maximum value of a property. + * @param defaultValue The value to return if the property does not exist or its value is null. + * @return the corresponding value, or defaultValue if none exists or the fetched value is + * greater than maximumValue. + */ + public static int getDeviceConfigPropertyInt(@NonNull String namespace, @NonNull String name, + int minimumValue, int maximumValue, int defaultValue) { + int value = getDeviceConfigPropertyInt(namespace, name, defaultValue); + if (value < minimumValue || value > maximumValue) return defaultValue; + return value; + } + + /** + * Look up the value of a property for a particular namespace from {@link DeviceConfig}. + * @param namespace The namespace containing the property to look up. + * @param name The name of the property to look up. * @param defaultValue The value to return if the property does not exist or its value is null. * @return the corresponding value, or defaultValue if none exists. */ |