Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit 0cf9e87c authored by Junyu Lai's avatar Junyu Lai
Browse files

[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
parent 92524a04
Loading
Loading
Loading
Loading
+4 −0
Original line number Diff line number Diff line
@@ -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);
  }
+9 −0
Original line number Diff line number Diff line
@@ -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
+2 −2
Original line number Diff line number Diff line
@@ -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);