Skip to content
Commit 99c1ddc9 authored by John Zhao's avatar John Zhao Committed by Fan Zhang
Browse files

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: default avatarJohn Zhao <yuankuiz@qualcomm.corp-partner.google.com>
parent 90d5e7b1
Loading
Loading
Loading
Loading
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment