[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
Merged-In: I801ddc49e283a254b9586700c9b597c0adb0d459
(cherry picked from aosp/1256352)
This commit is contained in:
junyulai
2020-03-13 19:04:17 +08:00
committed by Junyu Lai
parent ca952de92d
commit 02a6340ca0
3 changed files with 16 additions and 16 deletions

View File

@@ -503,7 +503,7 @@ public final class NetworkStats implements Parcelable {
NetworkStats.Entry entry = null;
for (int i = 0; i < size; i++) {
entry = getValues(i, entry);
clone.addEntry(entry);
clone.insertEntry(entry);
}
return clone;
}
@@ -530,26 +530,26 @@ public final class NetworkStats implements Parcelable {
/** @hide */
@VisibleForTesting
public NetworkStats addIfaceValues(
public NetworkStats insertEntry(
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);
}
/** @hide */
@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) {
return addEntry(new Entry(
return insertEntry(new Entry(
iface, uid, set, tag, rxBytes, rxPackets, txBytes, txPackets, operations));
}
/** @hide */
@VisibleForTesting
public NetworkStats addEntry(String iface, int uid, int set, int tag, int metered, int roaming,
int defaultNetwork, long rxBytes, long rxPackets, long txBytes, long txPackets,
long operations) {
return addEntry(new Entry(
public NetworkStats insertEntry(String iface, int uid, int set, int tag, int metered,
int roaming, int defaultNetwork, long rxBytes, long rxPackets, long txBytes,
long txPackets, long operations) {
return insertEntry(new Entry(
iface, uid, set, tag, metered, roaming, defaultNetwork, rxBytes, rxPackets,
txBytes, txPackets, operations));
}
@@ -559,7 +559,7 @@ public final class NetworkStats implements Parcelable {
* object can be recycled across multiple calls.
* @hide
*/
public NetworkStats addEntry(Entry entry) {
public NetworkStats insertEntry(Entry entry) {
if (size >= capacity) {
final int newLength = Math.max(size, 10) * 3 / 2;
iface = Arrays.copyOf(iface, newLength);
@@ -702,7 +702,7 @@ public final class NetworkStats implements Parcelable {
entry.roaming, entry.defaultNetwork);
if (i == -1) {
// only create new entry when positive contribution
addEntry(entry);
insertEntry(entry);
} else {
rxBytes[i] += entry.rxBytes;
rxPackets[i] += entry.rxPackets;
@@ -1040,7 +1040,7 @@ public final class NetworkStats implements Parcelable {
entry.operations = Math.max(entry.operations, 0);
}
result.addEntry(entry);
result.insertEntry(entry);
}
return result;