DO NOT MERGE base: getDataUsageInfo get cycle validation
When the DataUsageController calculate the DataUsageInfo
based on the cycle from NetworkPolicyManager, that cycle
should be not null. Otherwise, it couldn't be used to do
operation like toInstant() directly.
The error could be got from logcat is as:
E AndroidRuntime: Caused by: java.lang.NullPointerException:
Attempt to invoke virtual method 'java.time.Instant
java.time.ZonedDateTime.toInstant()' on a null object reference
E AndroidRuntime: at com.android.settingslib.net.
DataUsageController.getDataUsageInfo
(DataUsageController.java:140)
Inside of the core/java/android/net/NetworkPolicyManager.java:
public static Iterator<Pair<ZonedDateTime, ZonedDateTime>>
cycleIterator(NetworkPolicy policy) {
... ...
return Pair.create(null, null);
... ...
}
That should be avoided.
Considering it could be happened in the NetworkPolicyManager side,
and it is reasonable if it did it, validating operation is better
to be considered by any caller such as the DataUsageController.
Bug: 113952713
Test: specify the hasNext to be false but the DataUsageController
don't crash.
Change-Id: I2469c129a160e30615ea6011adf18688f951eac8
Signed-off-by: John Zhao <yuankuiz@qualcomm.corp-partner.google.com>
Loading
Please register or sign in to comment