Merge "Return non-negetive value in getMobileStats method" am: 9fb04e29e5
am: 515a54a93e Change-Id: I54a400b4231c38db25aa1b717f302a8a52e1773e
This commit is contained in:
@@ -433,6 +433,10 @@ public class TrafficStats {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private static long addIfSupported(long stat) {
|
||||||
|
return (stat == UNSUPPORTED) ? 0 : stat;
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Return number of packets transmitted across mobile networks since device
|
* Return number of packets transmitted across mobile networks since device
|
||||||
* boot. Counts packets across all mobile network interfaces, and always
|
* boot. Counts packets across all mobile network interfaces, and always
|
||||||
@@ -445,7 +449,7 @@ public class TrafficStats {
|
|||||||
public static long getMobileTxPackets() {
|
public static long getMobileTxPackets() {
|
||||||
long total = 0;
|
long total = 0;
|
||||||
for (String iface : getMobileIfaces()) {
|
for (String iface : getMobileIfaces()) {
|
||||||
total += getTxPackets(iface);
|
total += addIfSupported(getTxPackets(iface));
|
||||||
}
|
}
|
||||||
return total;
|
return total;
|
||||||
}
|
}
|
||||||
@@ -462,7 +466,7 @@ public class TrafficStats {
|
|||||||
public static long getMobileRxPackets() {
|
public static long getMobileRxPackets() {
|
||||||
long total = 0;
|
long total = 0;
|
||||||
for (String iface : getMobileIfaces()) {
|
for (String iface : getMobileIfaces()) {
|
||||||
total += getRxPackets(iface);
|
total += addIfSupported(getRxPackets(iface));
|
||||||
}
|
}
|
||||||
return total;
|
return total;
|
||||||
}
|
}
|
||||||
@@ -479,7 +483,7 @@ public class TrafficStats {
|
|||||||
public static long getMobileTxBytes() {
|
public static long getMobileTxBytes() {
|
||||||
long total = 0;
|
long total = 0;
|
||||||
for (String iface : getMobileIfaces()) {
|
for (String iface : getMobileIfaces()) {
|
||||||
total += getTxBytes(iface);
|
total += addIfSupported(getTxBytes(iface));
|
||||||
}
|
}
|
||||||
return total;
|
return total;
|
||||||
}
|
}
|
||||||
@@ -496,7 +500,7 @@ public class TrafficStats {
|
|||||||
public static long getMobileRxBytes() {
|
public static long getMobileRxBytes() {
|
||||||
long total = 0;
|
long total = 0;
|
||||||
for (String iface : getMobileIfaces()) {
|
for (String iface : getMobileIfaces()) {
|
||||||
total += getRxBytes(iface);
|
total += addIfSupported(getRxBytes(iface));
|
||||||
}
|
}
|
||||||
return total;
|
return total;
|
||||||
}
|
}
|
||||||
@@ -511,9 +515,7 @@ public class TrafficStats {
|
|||||||
} catch (RemoteException e) {
|
} catch (RemoteException e) {
|
||||||
throw e.rethrowFromSystemServer();
|
throw e.rethrowFromSystemServer();
|
||||||
}
|
}
|
||||||
if (stat != UNSUPPORTED) {
|
total += addIfSupported(stat);
|
||||||
total += stat;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
return total;
|
return total;
|
||||||
}
|
}
|
||||||
@@ -528,9 +530,7 @@ public class TrafficStats {
|
|||||||
} catch (RemoteException e) {
|
} catch (RemoteException e) {
|
||||||
throw e.rethrowFromSystemServer();
|
throw e.rethrowFromSystemServer();
|
||||||
}
|
}
|
||||||
if (stat != UNSUPPORTED) {
|
total += addIfSupported(stat);
|
||||||
total += stat;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
return total;
|
return total;
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user