[MS28.1] Fix several hidden API dependencies

This includes:
1. Replace Slog with Log
2. Use android.util.IndentingPrintWriter instead of the
   deprecated internal one.
3. Replace usages of ArrayUtils with CollectionUtils.
4. Reimplement DumpUtils#checkDumpPermission in PermissionUtils.
5. Replace MathUtils.constrain with NetworkStatsUtils.constrain

Test: FrameworksNetTests
Bug: 204830222
Change-Id: I2b064fc25497288d66018584e66da98c79bd208d
This commit is contained in:
Junyu Lai
2021-12-30 06:23:36 +00:00
parent f81e323a23
commit c7ba513aaf
4 changed files with 53 additions and 51 deletions

View File

@@ -35,8 +35,8 @@ import android.os.SystemClock;
import com.android.internal.annotations.GuardedBy; import com.android.internal.annotations.GuardedBy;
import com.android.internal.annotations.VisibleForTesting; import com.android.internal.annotations.VisibleForTesting;
import com.android.internal.util.ArrayUtils;
import com.android.internal.util.ProcFileReader; import com.android.internal.util.ProcFileReader;
import com.android.net.module.util.CollectionUtils;
import libcore.io.IoUtils; import libcore.io.IoUtils;
@@ -434,7 +434,7 @@ public class NetworkStatsFactory {
entry.txBytes = reader.nextLong(); entry.txBytes = reader.nextLong();
entry.txPackets = reader.nextLong(); entry.txPackets = reader.nextLong();
if ((limitIfaces == null || ArrayUtils.contains(limitIfaces, entry.iface)) if ((limitIfaces == null || CollectionUtils.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.insertEntry(entry); stats.insertEntry(entry);

View File

@@ -38,7 +38,7 @@ import android.os.Messenger;
import android.os.Process; import android.os.Process;
import android.os.RemoteException; import android.os.RemoteException;
import android.util.ArrayMap; import android.util.ArrayMap;
import android.util.Slog; import android.util.Log;
import android.util.SparseArray; import android.util.SparseArray;
import com.android.internal.annotations.VisibleForTesting; import com.android.internal.annotations.VisibleForTesting;
@@ -83,7 +83,7 @@ class NetworkStatsObservers {
RequestInfo requestInfo = buildRequestInfo(request, messenger, binder, callingUid, RequestInfo requestInfo = buildRequestInfo(request, messenger, binder, callingUid,
accessLevel); accessLevel);
if (LOGV) Slog.v(TAG, "Registering observer for " + request); if (LOGV) Log.v(TAG, "Registering observer for " + request);
getHandler().sendMessage(mHandler.obtainMessage(MSG_REGISTER, requestInfo)); getHandler().sendMessage(mHandler.obtainMessage(MSG_REGISTER, requestInfo));
return request; return request;
} }
@@ -116,7 +116,7 @@ class NetworkStatsObservers {
if (mHandler == null) { if (mHandler == null) {
synchronized (this) { synchronized (this) {
if (mHandler == null) { if (mHandler == null) {
if (LOGV) Slog.v(TAG, "Creating handler"); if (LOGV) Log.v(TAG, "Creating handler");
mHandler = new Handler(getHandlerLooperLocked(), mHandlerCallback); mHandler = new Handler(getHandlerLooperLocked(), mHandlerCallback);
} }
} }
@@ -172,15 +172,15 @@ class NetworkStatsObservers {
RequestInfo requestInfo; RequestInfo requestInfo;
requestInfo = mDataUsageRequests.get(request.requestId); requestInfo = mDataUsageRequests.get(request.requestId);
if (requestInfo == null) { if (requestInfo == null) {
if (LOGV) Slog.v(TAG, "Trying to unregister unknown request " + request); if (LOGV) Log.v(TAG, "Trying to unregister unknown request " + request);
return; return;
} }
if (Process.SYSTEM_UID != callingUid && requestInfo.mCallingUid != callingUid) { if (Process.SYSTEM_UID != callingUid && requestInfo.mCallingUid != callingUid) {
Slog.w(TAG, "Caller uid " + callingUid + " is not owner of " + request); Log.w(TAG, "Caller uid " + callingUid + " is not owner of " + request);
return; return;
} }
if (LOGV) Slog.v(TAG, "Unregistering " + request); if (LOGV) Log.v(TAG, "Unregistering " + request);
mDataUsageRequests.remove(request.requestId); mDataUsageRequests.remove(request.requestId);
requestInfo.unlinkDeathRecipient(); requestInfo.unlinkDeathRecipient();
requestInfo.callCallback(NetworkStatsManager.CALLBACK_RELEASED); requestInfo.callCallback(NetworkStatsManager.CALLBACK_RELEASED);
@@ -201,7 +201,7 @@ class NetworkStatsObservers {
// Cap the minimum threshold to a safe default to avoid too many callbacks // Cap the minimum threshold to a safe default to avoid too many callbacks
long thresholdInBytes = Math.max(MIN_THRESHOLD_BYTES, request.thresholdInBytes); long thresholdInBytes = Math.max(MIN_THRESHOLD_BYTES, request.thresholdInBytes);
if (thresholdInBytes < request.thresholdInBytes) { if (thresholdInBytes < request.thresholdInBytes) {
Slog.w(TAG, "Threshold was too low for " + request Log.w(TAG, "Threshold was too low for " + request
+ ". Overriding to a safer default of " + thresholdInBytes + " bytes"); + ". Overriding to a safer default of " + thresholdInBytes + " bytes");
} }
return new DataUsageRequest(mNextDataUsageRequestId.incrementAndGet(), return new DataUsageRequest(mNextDataUsageRequestId.incrementAndGet(),
@@ -255,8 +255,9 @@ class NetworkStatsObservers {
@Override @Override
public void binderDied() { public void binderDied() {
if (LOGV) Slog.v(TAG, "RequestInfo binderDied(" if (LOGV) {
+ mRequest + ", " + mBinder + ")"); Log.v(TAG, "RequestInfo binderDied(" + mRequest + ", " + mBinder + ")");
}
mStatsObserver.unregister(mRequest, Process.SYSTEM_UID); mStatsObserver.unregister(mRequest, Process.SYSTEM_UID);
callCallback(NetworkStatsManager.CALLBACK_RELEASED); callCallback(NetworkStatsManager.CALLBACK_RELEASED);
} }
@@ -299,13 +300,13 @@ class NetworkStatsObservers {
msg.setData(bundle); msg.setData(bundle);
try { try {
if (LOGV) { if (LOGV) {
Slog.v(TAG, "sending notification " + callbackTypeToName(callbackType) Log.v(TAG, "sending notification " + callbackTypeToName(callbackType)
+ " for " + mRequest); + " for " + mRequest);
} }
mMessenger.send(msg); mMessenger.send(msg);
} catch (RemoteException e) { } catch (RemoteException e) {
// May occur naturally in the race of binder death. // May occur naturally in the race of binder death.
Slog.w(TAG, "RemoteException caught trying to send a callback msg for " + mRequest); Log.w(TAG, "RemoteException caught trying to send a callback msg for " + mRequest);
} }
} }
@@ -341,7 +342,7 @@ class NetworkStatsObservers {
protected boolean checkStats() { protected boolean checkStats() {
long bytesSoFar = getTotalBytesForNetwork(mRequest.template); long bytesSoFar = getTotalBytesForNetwork(mRequest.template);
if (LOGV) { if (LOGV) {
Slog.v(TAG, bytesSoFar + " bytes so far since notification for " Log.v(TAG, bytesSoFar + " bytes so far since notification for "
+ mRequest.template); + mRequest.template);
} }
if (bytesSoFar > mRequest.thresholdInBytes) { if (bytesSoFar > mRequest.thresholdInBytes) {
@@ -416,7 +417,7 @@ class NetworkStatsObservers {
return history.getTotalBytes(); return history.getTotalBytes();
} catch (SecurityException e) { } catch (SecurityException e) {
if (LOGV) { if (LOGV) {
Slog.w(TAG, "CallerUid " + mCallingUid + " may have lost access to uid " Log.w(TAG, "CallerUid " + mCallingUid + " may have lost access to uid "
+ uid); + uid);
} }
return 0; return 0;

View File

@@ -32,13 +32,12 @@ import android.net.TrafficStats;
import android.os.Binder; import android.os.Binder;
import android.os.DropBoxManager; import android.os.DropBoxManager;
import android.service.NetworkStatsRecorderProto; import android.service.NetworkStatsRecorderProto;
import android.util.IndentingPrintWriter;
import android.util.Log; import android.util.Log;
import android.util.MathUtils; import android.util.MathUtils;
import android.util.Slog;
import android.util.proto.ProtoOutputStream; import android.util.proto.ProtoOutputStream;
import com.android.internal.util.FileRotator; import com.android.internal.util.FileRotator;
import com.android.internal.util.IndentingPrintWriter;
import com.google.android.collect.Sets; import com.google.android.collect.Sets;
@@ -132,7 +131,7 @@ public class NetworkStatsRecorder {
} }
public void setPersistThreshold(long thresholdBytes) { public void setPersistThreshold(long thresholdBytes) {
if (LOGV) Slog.v(TAG, "setPersistThreshold() with " + thresholdBytes); if (LOGV) Log.v(TAG, "setPersistThreshold() with " + thresholdBytes);
mPersistThresholdBytes = MathUtils.constrain( mPersistThresholdBytes = MathUtils.constrain(
thresholdBytes, 1 * KB_IN_BYTES, 100 * MB_IN_BYTES); thresholdBytes, 1 * KB_IN_BYTES, 100 * MB_IN_BYTES);
} }
@@ -185,7 +184,7 @@ public class NetworkStatsRecorder {
} }
private NetworkStatsCollection loadLocked(long start, long end) { private NetworkStatsCollection loadLocked(long start, long end) {
if (LOGD) Slog.d(TAG, "loadLocked() reading from disk for " + mCookie); if (LOGD) Log.d(TAG, "loadLocked() reading from disk for " + mCookie);
final NetworkStatsCollection res = new NetworkStatsCollection(mBucketDuration); final NetworkStatsCollection res = new NetworkStatsCollection(mBucketDuration);
try { try {
mRotator.readMatching(res, start, end); mRotator.readMatching(res, start, end);
@@ -272,7 +271,7 @@ public class NetworkStatsRecorder {
mLastSnapshot = snapshot; mLastSnapshot = snapshot;
if (LOGV && unknownIfaces.size() > 0) { if (LOGV && unknownIfaces.size() > 0) {
Slog.w(TAG, "unknown interfaces " + unknownIfaces + ", ignoring those stats"); Log.w(TAG, "unknown interfaces " + unknownIfaces + ", ignoring those stats");
} }
} }
@@ -296,7 +295,7 @@ public class NetworkStatsRecorder {
public void forcePersistLocked(long currentTimeMillis) { public void forcePersistLocked(long currentTimeMillis) {
Objects.requireNonNull(mRotator, "missing FileRotator"); Objects.requireNonNull(mRotator, "missing FileRotator");
if (mPending.isDirty()) { if (mPending.isDirty()) {
if (LOGD) Slog.d(TAG, "forcePersistLocked() writing for " + mCookie); if (LOGD) Log.d(TAG, "forcePersistLocked() writing for " + mCookie);
try { try {
mRotator.rewriteActive(mPendingRewriter, currentTimeMillis); mRotator.rewriteActive(mPendingRewriter, currentTimeMillis);
mRotator.maybeRotate(currentTimeMillis); mRotator.maybeRotate(currentTimeMillis);

View File

@@ -141,19 +141,18 @@ import android.text.format.DateUtils;
import android.util.ArrayMap; import android.util.ArrayMap;
import android.util.ArraySet; import android.util.ArraySet;
import android.util.EventLog; import android.util.EventLog;
import android.util.IndentingPrintWriter;
import android.util.Log; import android.util.Log;
import android.util.MathUtils;
import android.util.Slog;
import android.util.SparseIntArray; import android.util.SparseIntArray;
import android.util.proto.ProtoOutputStream; import android.util.proto.ProtoOutputStream;
import com.android.internal.annotations.GuardedBy; import com.android.internal.annotations.GuardedBy;
import com.android.internal.annotations.VisibleForTesting; import com.android.internal.annotations.VisibleForTesting;
import com.android.internal.util.ArrayUtils;
import com.android.internal.util.DumpUtils;
import com.android.internal.util.FileRotator; import com.android.internal.util.FileRotator;
import com.android.internal.util.IndentingPrintWriter;
import com.android.net.module.util.BinderUtils; import com.android.net.module.util.BinderUtils;
import com.android.net.module.util.CollectionUtils;
import com.android.net.module.util.NetworkStatsUtils;
import com.android.net.module.util.PermissionUtils;
import com.android.server.EventLogTags; import com.android.server.EventLogTags;
import com.android.server.LocalServices; import com.android.server.LocalServices;
@@ -163,6 +162,7 @@ import java.io.IOException;
import java.io.PrintWriter; import java.io.PrintWriter;
import java.time.Clock; import java.time.Clock;
import java.time.ZoneOffset; import java.time.ZoneOffset;
import java.util.ArrayList;
import java.util.Arrays; import java.util.Arrays;
import java.util.HashSet; import java.util.HashSet;
import java.util.List; import java.util.List;
@@ -646,7 +646,7 @@ public class NetworkStatsService extends INetworkStatsService.Stub {
try { try {
mNetworkManager.setGlobalAlert(mGlobalAlertBytes); mNetworkManager.setGlobalAlert(mGlobalAlertBytes);
} catch (IllegalStateException e) { } catch (IllegalStateException e) {
Slog.w(TAG, "problem registering for global alert: " + e); Log.w(TAG, "problem registering for global alert: " + e);
} catch (RemoteException e) { } catch (RemoteException e) {
// ignored; service lives in system_server // ignored; service lives in system_server
} }
@@ -766,7 +766,7 @@ public class NetworkStatsService extends INetworkStatsService.Stub {
return stats; return stats;
} catch (NullPointerException e) { } catch (NullPointerException e) {
// TODO: Track down and fix the cause of this crash and remove this catch block. // TODO: Track down and fix the cause of this crash and remove this catch block.
Slog.wtf(TAG, "NullPointerException in getSummaryForAllUid", e); Log.wtf(TAG, "NullPointerException in getSummaryForAllUid", e);
throw e; throw e;
} }
} }
@@ -823,7 +823,7 @@ public class NetworkStatsService extends INetworkStatsService.Stub {
SubscriptionPlan plan = null; SubscriptionPlan plan = null;
if ((flags & NetworkStatsManager.FLAG_AUGMENT_WITH_SUBSCRIPTION_PLAN) != 0 if ((flags & NetworkStatsManager.FLAG_AUGMENT_WITH_SUBSCRIPTION_PLAN) != 0
&& mSettings.getAugmentEnabled()) { && mSettings.getAugmentEnabled()) {
if (LOGD) Slog.d(TAG, "Resolving plan for " + template); if (LOGD) Log.d(TAG, "Resolving plan for " + template);
final long token = Binder.clearCallingIdentity(); final long token = Binder.clearCallingIdentity();
try { try {
plan = LocalServices.getService(NetworkPolicyManagerInternal.class) plan = LocalServices.getService(NetworkPolicyManagerInternal.class)
@@ -831,7 +831,7 @@ public class NetworkStatsService extends INetworkStatsService.Stub {
} finally { } finally {
Binder.restoreCallingIdentity(token); Binder.restoreCallingIdentity(token);
} }
if (LOGD) Slog.d(TAG, "Resolved to plan " + plan); if (LOGD) Log.d(TAG, "Resolved to plan " + plan);
} }
return plan; return plan;
} }
@@ -936,7 +936,7 @@ public class NetworkStatsService extends INetworkStatsService.Stub {
@Override @Override
public String[] getMobileIfaces() { public String[] getMobileIfaces() {
// TODO (b/192758557): Remove debug log. // TODO (b/192758557): Remove debug log.
if (ArrayUtils.contains(mMobileIfaces, null)) { if (CollectionUtils.contains(mMobileIfaces, null)) {
throw new NullPointerException( throw new NullPointerException(
"null element in mMobileIfaces: " + Arrays.toString(mMobileIfaces)); "null element in mMobileIfaces: " + Arrays.toString(mMobileIfaces));
} }
@@ -1014,9 +1014,10 @@ public class NetworkStatsService extends INetworkStatsService.Stub {
private void advisePersistThreshold(long thresholdBytes) { private void advisePersistThreshold(long thresholdBytes) {
// clamp threshold into safe range // clamp threshold into safe range
mPersistThreshold = MathUtils.constrain(thresholdBytes, 128 * KB_IN_BYTES, 2 * MB_IN_BYTES); mPersistThreshold = NetworkStatsUtils.constrain(thresholdBytes,
128 * KB_IN_BYTES, 2 * MB_IN_BYTES);
if (LOGV) { if (LOGV) {
Slog.v(TAG, "advisePersistThreshold() given " + thresholdBytes + ", clamped to " Log.v(TAG, "advisePersistThreshold() given " + thresholdBytes + ", clamped to "
+ mPersistThreshold); + mPersistThreshold);
} }
@@ -1279,7 +1280,7 @@ public class NetworkStatsService extends INetworkStatsService.Stub {
private void handleNotifyNetworkStatusLocked(@NonNull Network[] defaultNetworks, private void handleNotifyNetworkStatusLocked(@NonNull Network[] defaultNetworks,
@NonNull NetworkStateSnapshot[] snapshots) { @NonNull NetworkStateSnapshot[] snapshots) {
if (!mSystemReady) return; if (!mSystemReady) return;
if (LOGV) Slog.v(TAG, "handleNotifyNetworkStatusLocked()"); if (LOGV) Log.v(TAG, "handleNotifyNetworkStatusLocked()");
// take one last stats snapshot before updating iface mapping. this // take one last stats snapshot before updating iface mapping. this
// isn't perfect, since the kernel may already be counting traffic from // isn't perfect, since the kernel may already be counting traffic from
@@ -1303,7 +1304,8 @@ public class NetworkStatsService extends INetworkStatsService.Stub {
final int displayTransport = final int displayTransport =
getDisplayTransport(snapshot.getNetworkCapabilities().getTransportTypes()); getDisplayTransport(snapshot.getNetworkCapabilities().getTransportTypes());
final boolean isMobile = (NetworkCapabilities.TRANSPORT_CELLULAR == displayTransport); final boolean isMobile = (NetworkCapabilities.TRANSPORT_CELLULAR == displayTransport);
final boolean isDefault = ArrayUtils.contains(mDefaultNetworks, snapshot.getNetwork()); final boolean isDefault = CollectionUtils.contains(
mDefaultNetworks, snapshot.getNetwork());
final int subType = combineSubtypeEnabled ? SUBTYPE_COMBINED final int subType = combineSubtypeEnabled ? SUBTYPE_COMBINED
: getSubTypeForStateSnapshot(snapshot); : getSubTypeForStateSnapshot(snapshot);
final NetworkIdentity ident = NetworkIdentity.buildNetworkIdentity(mContext, snapshot, final NetworkIdentity ident = NetworkIdentity.buildNetworkIdentity(mContext, snapshot,
@@ -1386,7 +1388,7 @@ public class NetworkStatsService extends INetworkStatsService.Stub {
mMobileIfaces = mobileIfaces.toArray(new String[0]); mMobileIfaces = mobileIfaces.toArray(new String[0]);
// TODO (b/192758557): Remove debug log. // TODO (b/192758557): Remove debug log.
if (ArrayUtils.contains(mMobileIfaces, null)) { if (CollectionUtils.contains(mMobileIfaces, null)) {
throw new NullPointerException( throw new NullPointerException(
"null element in mMobileIfaces: " + Arrays.toString(mMobileIfaces)); "null element in mMobileIfaces: " + Arrays.toString(mMobileIfaces));
} }
@@ -1401,7 +1403,7 @@ public class NetworkStatsService extends INetworkStatsService.Stub {
if (spec instanceof TelephonyNetworkSpecifier) { if (spec instanceof TelephonyNetworkSpecifier) {
return ((TelephonyNetworkSpecifier) spec).getSubscriptionId(); return ((TelephonyNetworkSpecifier) spec).getSubscriptionId();
} else { } else {
Slog.wtf(TAG, "getSubIdForState invalid NetworkSpecifier"); Log.wtf(TAG, "getSubIdForState invalid NetworkSpecifier");
return INVALID_SUBSCRIPTION_ID; return INVALID_SUBSCRIPTION_ID;
} }
} }
@@ -1485,7 +1487,7 @@ public class NetworkStatsService extends INetworkStatsService.Stub {
try { try {
recordSnapshotLocked(currentTime); recordSnapshotLocked(currentTime);
} catch (IllegalStateException e) { } catch (IllegalStateException e) {
Slog.w(TAG, "problem reading network stats: " + e); Log.w(TAG, "problem reading network stats: " + e);
} catch (RemoteException e) { } catch (RemoteException e) {
// ignored; service lives in system_server // ignored; service lives in system_server
} }
@@ -1510,7 +1512,7 @@ public class NetworkStatsService extends INetworkStatsService.Stub {
@GuardedBy("mStatsLock") @GuardedBy("mStatsLock")
private void performPollLocked(int flags) { private void performPollLocked(int flags) {
if (!mSystemReady) return; if (!mSystemReady) return;
if (LOGV) Slog.v(TAG, "performPollLocked(flags=0x" + Integer.toHexString(flags) + ")"); if (LOGV) Log.v(TAG, "performPollLocked(flags=0x" + Integer.toHexString(flags) + ")");
Trace.traceBegin(TRACE_TAG_NETWORK, "performPollLocked"); Trace.traceBegin(TRACE_TAG_NETWORK, "performPollLocked");
final boolean persistNetwork = (flags & FLAG_PERSIST_NETWORK) != 0; final boolean persistNetwork = (flags & FLAG_PERSIST_NETWORK) != 0;
@@ -1632,7 +1634,7 @@ public class NetworkStatsService extends INetworkStatsService.Stub {
*/ */
@GuardedBy("mStatsLock") @GuardedBy("mStatsLock")
private void removeUidsLocked(int... uids) { private void removeUidsLocked(int... uids) {
if (LOGV) Slog.v(TAG, "removeUidsLocked() for UIDs " + Arrays.toString(uids)); if (LOGV) Log.v(TAG, "removeUidsLocked() for UIDs " + Arrays.toString(uids));
// Perform one last poll before removing // Perform one last poll before removing
performPollLocked(FLAG_PERSIST_ALL); performPollLocked(FLAG_PERSIST_ALL);
@@ -1651,19 +1653,19 @@ public class NetworkStatsService extends INetworkStatsService.Stub {
*/ */
@GuardedBy("mStatsLock") @GuardedBy("mStatsLock")
private void removeUserLocked(int userId) { private void removeUserLocked(int userId) {
if (LOGV) Slog.v(TAG, "removeUserLocked() for userId=" + userId); if (LOGV) Log.v(TAG, "removeUserLocked() for userId=" + userId);
// Build list of UIDs that we should clean up // Build list of UIDs that we should clean up
int[] uids = new int[0]; final ArrayList<Integer> uids = new ArrayList<>();
final List<ApplicationInfo> apps = mContext.getPackageManager().getInstalledApplications( final List<ApplicationInfo> apps = mContext.getPackageManager().getInstalledApplications(
PackageManager.MATCH_ANY_USER PackageManager.MATCH_ANY_USER
| PackageManager.MATCH_DISABLED_COMPONENTS); | PackageManager.MATCH_DISABLED_COMPONENTS);
for (ApplicationInfo app : apps) { for (ApplicationInfo app : apps) {
final int uid = UserHandle.getUid(userId, app.uid); final int uid = UserHandle.getUid(userId, app.uid);
uids = ArrayUtils.appendInt(uids, uid); uids.add(uid);
} }
removeUidsLocked(uids); removeUidsLocked(CollectionUtils.toIntArray(uids));
} }
private class NetworkStatsManagerInternalImpl extends NetworkStatsManagerInternal { private class NetworkStatsManagerInternalImpl extends NetworkStatsManagerInternal {
@@ -1706,7 +1708,7 @@ public class NetworkStatsService extends INetworkStatsService.Stub {
public void setStatsProviderWarningAndLimitAsync( public void setStatsProviderWarningAndLimitAsync(
@NonNull String iface, long warning, long limit) { @NonNull String iface, long warning, long limit) {
if (LOGV) { if (LOGV) {
Slog.v(TAG, "setStatsProviderWarningAndLimitAsync(" Log.v(TAG, "setStatsProviderWarningAndLimitAsync("
+ iface + "," + warning + "," + limit + ")"); + iface + "," + warning + "," + limit + ")");
} }
invokeForAllStatsProviderCallbacks((cb) -> cb.mProvider.onSetWarningAndLimit(iface, invokeForAllStatsProviderCallbacks((cb) -> cb.mProvider.onSetWarningAndLimit(iface,
@@ -1716,7 +1718,7 @@ public class NetworkStatsService extends INetworkStatsService.Stub {
@Override @Override
protected void dump(FileDescriptor fd, PrintWriter rawWriter, String[] args) { protected void dump(FileDescriptor fd, PrintWriter rawWriter, String[] args) {
if (!DumpUtils.checkDumpPermission(mContext, TAG, rawWriter)) return; if (!PermissionUtils.checkDumpPermission(mContext, TAG, rawWriter)) return;
long duration = DateUtils.DAY_IN_MILLIS; long duration = DateUtils.DAY_IN_MILLIS;
final HashSet<String> argSet = new HashSet<String>(); final HashSet<String> argSet = new HashSet<String>();
@@ -1777,15 +1779,15 @@ public class NetworkStatsService extends INetworkStatsService.Stub {
pw.println("Configs:"); pw.println("Configs:");
pw.increaseIndent(); pw.increaseIndent();
pw.printPair(NETSTATS_COMBINE_SUBTYPE_ENABLED, mSettings.getCombineSubtypeEnabled()); pw.print(NETSTATS_COMBINE_SUBTYPE_ENABLED, mSettings.getCombineSubtypeEnabled());
pw.println(); pw.println();
pw.decreaseIndent(); pw.decreaseIndent();
pw.println("Active interfaces:"); pw.println("Active interfaces:");
pw.increaseIndent(); pw.increaseIndent();
for (int i = 0; i < mActiveIfaces.size(); i++) { for (int i = 0; i < mActiveIfaces.size(); i++) {
pw.printPair("iface", mActiveIfaces.keyAt(i)); pw.print("iface", mActiveIfaces.keyAt(i));
pw.printPair("ident", mActiveIfaces.valueAt(i)); pw.print("ident", mActiveIfaces.valueAt(i));
pw.println(); pw.println();
} }
pw.decreaseIndent(); pw.decreaseIndent();
@@ -1793,8 +1795,8 @@ public class NetworkStatsService extends INetworkStatsService.Stub {
pw.println("Active UID interfaces:"); pw.println("Active UID interfaces:");
pw.increaseIndent(); pw.increaseIndent();
for (int i = 0; i < mActiveUidIfaces.size(); i++) { for (int i = 0; i < mActiveUidIfaces.size(); i++) {
pw.printPair("iface", mActiveUidIfaces.keyAt(i)); pw.print("iface", mActiveUidIfaces.keyAt(i));
pw.printPair("ident", mActiveUidIfaces.valueAt(i)); pw.print("ident", mActiveUidIfaces.valueAt(i));
pw.println(); pw.println();
} }
pw.decreaseIndent(); pw.decreaseIndent();