Move kernelToTag to NetworkStatsFactory. am: 09d2a4b175

Original change: https://android-review.googlesource.com/c/platform/frameworks/base/+/1964913

Change-Id: Ib763cf77b54e4583e51a337d4261069621e65f56
This commit is contained in:
Lorenzo Colitti
2022-01-31 14:04:49 +00:00
committed by Automerger Merge Worker
2 changed files with 13 additions and 15 deletions

View File

@@ -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);
}

View File

@@ -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.