[SP24] Rename functions that add Entry unconditionally
Currently, in NetworkStats, there are many methods to manipulate the records. However, some methods are similar and ambiguous, such as addEntry, addValues, setValues, addIfaceValues, combineValues and combineAllValues. Thus, properly grouping and renaming methods are necessary. In this change, for methods that add one record unconditionally, name them insertEntry. setIfaceValues -> insertEntry addEntry -> insertEntry Test: atest FrameworksNetTests ImsPhoneCallTrackerTest TetheringTests Test: m doc-comment-check-docs Bug: 148895143 Change-Id: I801ddc49e283a254b9586700c9b597c0adb0d459
This commit is contained in:
@@ -503,7 +503,7 @@ public final class NetworkStats implements Parcelable {
|
|||||||
NetworkStats.Entry entry = null;
|
NetworkStats.Entry entry = null;
|
||||||
for (int i = 0; i < size; i++) {
|
for (int i = 0; i < size; i++) {
|
||||||
entry = getValues(i, entry);
|
entry = getValues(i, entry);
|
||||||
clone.addEntry(entry);
|
clone.insertEntry(entry);
|
||||||
}
|
}
|
||||||
return clone;
|
return clone;
|
||||||
}
|
}
|
||||||
@@ -530,26 +530,26 @@ public final class NetworkStats implements Parcelable {
|
|||||||
|
|
||||||
/** @hide */
|
/** @hide */
|
||||||
@VisibleForTesting
|
@VisibleForTesting
|
||||||
public NetworkStats addIfaceValues(
|
public NetworkStats insertEntry(
|
||||||
String iface, long rxBytes, long rxPackets, long txBytes, long txPackets) {
|
String iface, long rxBytes, long rxPackets, long txBytes, long txPackets) {
|
||||||
return addEntry(
|
return insertEntry(
|
||||||
iface, UID_ALL, SET_DEFAULT, TAG_NONE, rxBytes, rxPackets, txBytes, txPackets, 0L);
|
iface, UID_ALL, SET_DEFAULT, TAG_NONE, rxBytes, rxPackets, txBytes, txPackets, 0L);
|
||||||
}
|
}
|
||||||
|
|
||||||
/** @hide */
|
/** @hide */
|
||||||
@VisibleForTesting
|
@VisibleForTesting
|
||||||
public NetworkStats addEntry(String iface, int uid, int set, int tag, long rxBytes,
|
public NetworkStats insertEntry(String iface, int uid, int set, int tag, long rxBytes,
|
||||||
long rxPackets, long txBytes, long txPackets, long operations) {
|
long rxPackets, long txBytes, long txPackets, long operations) {
|
||||||
return addEntry(new Entry(
|
return insertEntry(new Entry(
|
||||||
iface, uid, set, tag, rxBytes, rxPackets, txBytes, txPackets, operations));
|
iface, uid, set, tag, rxBytes, rxPackets, txBytes, txPackets, operations));
|
||||||
}
|
}
|
||||||
|
|
||||||
/** @hide */
|
/** @hide */
|
||||||
@VisibleForTesting
|
@VisibleForTesting
|
||||||
public NetworkStats addEntry(String iface, int uid, int set, int tag, int metered, int roaming,
|
public NetworkStats insertEntry(String iface, int uid, int set, int tag, int metered,
|
||||||
int defaultNetwork, long rxBytes, long rxPackets, long txBytes, long txPackets,
|
int roaming, int defaultNetwork, long rxBytes, long rxPackets, long txBytes,
|
||||||
long operations) {
|
long txPackets, long operations) {
|
||||||
return addEntry(new Entry(
|
return insertEntry(new Entry(
|
||||||
iface, uid, set, tag, metered, roaming, defaultNetwork, rxBytes, rxPackets,
|
iface, uid, set, tag, metered, roaming, defaultNetwork, rxBytes, rxPackets,
|
||||||
txBytes, txPackets, operations));
|
txBytes, txPackets, operations));
|
||||||
}
|
}
|
||||||
@@ -559,7 +559,7 @@ public final class NetworkStats implements Parcelable {
|
|||||||
* object can be recycled across multiple calls.
|
* object can be recycled across multiple calls.
|
||||||
* @hide
|
* @hide
|
||||||
*/
|
*/
|
||||||
public NetworkStats addEntry(Entry entry) {
|
public NetworkStats insertEntry(Entry entry) {
|
||||||
if (size >= capacity) {
|
if (size >= capacity) {
|
||||||
final int newLength = Math.max(size, 10) * 3 / 2;
|
final int newLength = Math.max(size, 10) * 3 / 2;
|
||||||
iface = Arrays.copyOf(iface, newLength);
|
iface = Arrays.copyOf(iface, newLength);
|
||||||
@@ -702,7 +702,7 @@ public final class NetworkStats implements Parcelable {
|
|||||||
entry.roaming, entry.defaultNetwork);
|
entry.roaming, entry.defaultNetwork);
|
||||||
if (i == -1) {
|
if (i == -1) {
|
||||||
// only create new entry when positive contribution
|
// only create new entry when positive contribution
|
||||||
addEntry(entry);
|
insertEntry(entry);
|
||||||
} else {
|
} else {
|
||||||
rxBytes[i] += entry.rxBytes;
|
rxBytes[i] += entry.rxBytes;
|
||||||
rxPackets[i] += entry.rxPackets;
|
rxPackets[i] += entry.rxPackets;
|
||||||
@@ -1040,7 +1040,7 @@ public final class NetworkStats implements Parcelable {
|
|||||||
entry.operations = Math.max(entry.operations, 0);
|
entry.operations = Math.max(entry.operations, 0);
|
||||||
}
|
}
|
||||||
|
|
||||||
result.addEntry(entry);
|
result.insertEntry(entry);
|
||||||
}
|
}
|
||||||
|
|
||||||
return result;
|
return result;
|
||||||
|
|||||||
@@ -229,7 +229,7 @@ public class NetworkStatsFactory {
|
|||||||
entry.txPackets += reader.nextLong();
|
entry.txPackets += reader.nextLong();
|
||||||
}
|
}
|
||||||
|
|
||||||
stats.addEntry(entry);
|
stats.insertEntry(entry);
|
||||||
reader.finishLine();
|
reader.finishLine();
|
||||||
}
|
}
|
||||||
} catch (NullPointerException|NumberFormatException e) {
|
} catch (NullPointerException|NumberFormatException e) {
|
||||||
@@ -279,7 +279,7 @@ public class NetworkStatsFactory {
|
|||||||
entry.txBytes = reader.nextLong();
|
entry.txBytes = reader.nextLong();
|
||||||
entry.txPackets = reader.nextLong();
|
entry.txPackets = reader.nextLong();
|
||||||
|
|
||||||
stats.addEntry(entry);
|
stats.insertEntry(entry);
|
||||||
reader.finishLine();
|
reader.finishLine();
|
||||||
}
|
}
|
||||||
} catch (NullPointerException|NumberFormatException e) {
|
} catch (NullPointerException|NumberFormatException e) {
|
||||||
@@ -439,7 +439,7 @@ public class NetworkStatsFactory {
|
|||||||
if ((limitIfaces == null || ArrayUtils.contains(limitIfaces, entry.iface))
|
if ((limitIfaces == null || ArrayUtils.contains(limitIfaces, entry.iface))
|
||||||
&& (limitUid == UID_ALL || limitUid == entry.uid)
|
&& (limitUid == UID_ALL || limitUid == entry.uid)
|
||||||
&& (limitTag == TAG_ALL || limitTag == entry.tag)) {
|
&& (limitTag == TAG_ALL || limitTag == entry.tag)) {
|
||||||
stats.addEntry(entry);
|
stats.insertEntry(entry);
|
||||||
}
|
}
|
||||||
|
|
||||||
reader.finishLine();
|
reader.finishLine();
|
||||||
|
|||||||
@@ -759,7 +759,7 @@ public class NetworkStatsService extends INetworkStatsService.Stub {
|
|||||||
final NetworkStatsHistory.Entry entry = history.getValues(start, end, now, null);
|
final NetworkStatsHistory.Entry entry = history.getValues(start, end, now, null);
|
||||||
|
|
||||||
final NetworkStats stats = new NetworkStats(end - start, 1);
|
final NetworkStats stats = new NetworkStats(end - start, 1);
|
||||||
stats.addEntry(new NetworkStats.Entry(IFACE_ALL, UID_ALL, SET_ALL, TAG_NONE,
|
stats.insertEntry(new NetworkStats.Entry(IFACE_ALL, UID_ALL, SET_ALL, TAG_NONE,
|
||||||
METERED_ALL, ROAMING_ALL, DEFAULT_NETWORK_ALL, entry.rxBytes, entry.rxPackets,
|
METERED_ALL, ROAMING_ALL, DEFAULT_NETWORK_ALL, entry.rxBytes, entry.rxPackets,
|
||||||
entry.txBytes, entry.txPackets, entry.operations));
|
entry.txBytes, entry.txPackets, entry.operations));
|
||||||
return stats;
|
return stats;
|
||||||
|
|||||||
Reference in New Issue
Block a user