Move kernelToTag to NetworkStatsFactory. am: 09d2a4b175 am: b9e2b370fb
Original change: https://android-review.googlesource.com/c/platform/frameworks/base/+/1964913 Change-Id: I3bd1b8fb38cb302612139b8ba1940e72e0dc2380
This commit is contained in:
@@ -111,19 +111,6 @@ public final class NetworkManagementSocketTagger extends SocketTagger {
|
||||
public int statsUid = -1;
|
||||
}
|
||||
|
||||
/**
|
||||
* Convert {@code /proc/} tag format to {@link Integer}. Assumes incoming
|
||||
* format like {@code 0x7fffffff00000000}.
|
||||
*/
|
||||
public static int kernelToTag(String string) {
|
||||
int length = string.length();
|
||||
if (length > 10) {
|
||||
return Long.decode(string.substring(0, length - 8)).intValue();
|
||||
} else {
|
||||
return 0;
|
||||
}
|
||||
}
|
||||
|
||||
private static native int native_tagSocketFd(FileDescriptor fd, int tag, int uid);
|
||||
private static native int native_untagSocketFd(FileDescriptor fd);
|
||||
}
|
||||
|
||||
@@ -22,8 +22,6 @@ import static android.net.NetworkStats.TAG_ALL;
|
||||
import static android.net.NetworkStats.TAG_NONE;
|
||||
import static android.net.NetworkStats.UID_ALL;
|
||||
|
||||
import static com.android.server.NetworkManagementSocketTagger.kernelToTag;
|
||||
|
||||
import android.annotation.NonNull;
|
||||
import android.annotation.Nullable;
|
||||
import android.content.Context;
|
||||
@@ -469,6 +467,19 @@ public class NetworkStatsFactory {
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Convert {@code /proc/} tag format to {@link Integer}. Assumes incoming
|
||||
* format like {@code 0x7fffffff00000000}.
|
||||
*/
|
||||
public static int kernelToTag(String string) {
|
||||
int length = string.length();
|
||||
if (length > 10) {
|
||||
return Long.decode(string.substring(0, length - 8)).intValue();
|
||||
} else {
|
||||
return 0;
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Parse statistics from file into given {@link NetworkStats} object. Values
|
||||
* are expected to monotonically increase since device boot.
|
||||
|
||||
Reference in New Issue
Block a user