[MS27] Expose noteUntaggedSocket SystemApi

While Data usage related codes are moving to mainline module,
StrictMode#vmUntaggedSocketEnabled() and onUntaggedSocket()
can no longer be accessed from NetworkManagementSocketTagger.

Thus, expose alternative SystemApi to allow invocations from
the module.

Test: TH
Bug: 204830222
Exempt-From-Owner-Approval: 1. Owner approved the change with
  explicitly granted submission after adderessing the
  straight-forward comment. 2. Owner is OOO for 3 months.
Change-Id: Ib54ff54ce3617ae0d04080a1740e78b086bbb039
This commit is contained in:
Junyu Lai
2021-12-28 14:33:57 +00:00
parent 92524a042c
commit 0cf9e87c79
3 changed files with 15 additions and 2 deletions

View File

@@ -321,6 +321,10 @@ package android.os {
method @Nullable public android.os.IBinder getOrThrow() throws android.os.StatsServiceManager.ServiceNotFoundException;
}
public final class StrictMode {
method public static void noteUntaggedSocket();
}
public class SystemConfigManager {
method @NonNull public java.util.List<android.content.ComponentName> getEnabledComponentOverrides(@NonNull String);
}

View File

@@ -15,10 +15,13 @@
*/
package android.os;
import static android.annotation.SystemApi.Client.MODULE_LIBRARIES;
import android.animation.ValueAnimator;
import android.annotation.IntDef;
import android.annotation.NonNull;
import android.annotation.Nullable;
import android.annotation.SystemApi;
import android.annotation.TestApi;
import android.app.ActivityManager;
import android.app.ActivityThread;
@@ -2694,6 +2697,12 @@ public final class StrictMode {
((AndroidBlockGuardPolicy) policy).onCustomSlowCall(name);
}
/** @hide */
@SystemApi(client = MODULE_LIBRARIES)
public static void noteUntaggedSocket() {
if (vmUntaggedSocketEnabled()) onUntaggedSocket();
}
/**
* For code to note that a resource was obtained using a type other than its defined type. This
* is a no-op unless the current thread's {@link android.os.StrictMode.ThreadPolicy} has {@link

View File

@@ -70,8 +70,8 @@ public final class NetworkManagementSocketTagger extends SocketTagger {
Log.d(TAG, "tagSocket(" + fd.getInt$() + ") with statsTag=0x"
+ Integer.toHexString(options.statsTag) + ", statsUid=" + options.statsUid);
}
if (options.statsTag == -1 && StrictMode.vmUntaggedSocketEnabled()) {
StrictMode.onUntaggedSocket();
if (options.statsTag == -1) {
StrictMode.noteUntaggedSocket();
}
// TODO: skip tagging when options would be no-op
tagSocketFd(fd, options.statsTag, options.statsUid);