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

Commit 295e48eb authored by Treehugger Robot's avatar Treehugger Robot Committed by Automerger Merge Worker
Browse files

Merge "remove PROP_QTAGUID_ENABLED" am: 999147b4 am: 8d888d92 am: b3135ed7 am: fa6d0cfd

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

Change-Id: I74c9ca7b74391d9c365ba39e4ad8471f827c7f0c
parents fe32fa92 fa6d0cfd
Loading
Loading
Loading
Loading
+15 −31
Original line number Diff line number Diff line
@@ -17,7 +17,6 @@
package com.android.server;

import android.os.StrictMode;
import android.os.SystemProperties;
import android.util.Log;
import android.util.Slog;

@@ -33,13 +32,6 @@ public final class NetworkManagementSocketTagger extends SocketTagger {
    private static final String TAG = "NetworkManagementSocketTagger";
    private static final boolean LOGD = false;

    /**
     * {@link SystemProperties} key that indicates if {@code qtaguid} bandwidth
     * controls have been enabled.
     */
    // TODO: remove when always enabled, or once socket tagging silently fails.
    public static final String PROP_QTAGUID_ENABLED = "net.qtaguid_enabled";

    private static ThreadLocal<SocketTags> threadSocketTags = new ThreadLocal<SocketTags>() {
        @Override
        protected SocketTags initialValue() {
@@ -88,15 +80,13 @@ public final class NetworkManagementSocketTagger extends SocketTagger {
    private void tagSocketFd(FileDescriptor fd, int tag, int uid) {
        if (tag == -1 && uid == -1) return;

        if (SystemProperties.getBoolean(PROP_QTAGUID_ENABLED, false)) {
        final int errno = native_tagSocketFd(fd, tag, uid);
        if (errno < 0) {
            Log.i(TAG, "tagSocketFd(" + fd.getInt$() + ", "
                      + tag + ", " +
                    + tag + ", "
                    + uid + ") failed with errno" + errno);
        }
    }
    }

    @Override
    public void untag(FileDescriptor fd) throws SocketException {
@@ -110,13 +100,11 @@ public final class NetworkManagementSocketTagger extends SocketTagger {
        final SocketTags options = threadSocketTags.get();
        if (options.statsTag == -1 && options.statsUid == -1) return;

        if (SystemProperties.getBoolean(PROP_QTAGUID_ENABLED, false)) {
        final int errno = native_untagSocketFd(fd);
        if (errno < 0) {
            Log.w(TAG, "untagSocket(" + fd.getInt$() + ") failed with errno " + errno);
        }
    }
    }

    public static class SocketTags {
        public int statsTag = -1;
@@ -124,23 +112,19 @@ public final class NetworkManagementSocketTagger extends SocketTagger {
    }

    public static void setKernelCounterSet(int uid, int counterSet) {
        if (SystemProperties.getBoolean(PROP_QTAGUID_ENABLED, false)) {
        final int errno = native_setCounterSet(counterSet, uid);
        if (errno < 0) {
            Log.w(TAG, "setKernelCountSet(" + uid + ", " + counterSet + ") failed with errno "
                    + errno);
        }
    }
    }

    public static void resetKernelUidStats(int uid) {
        if (SystemProperties.getBoolean(PROP_QTAGUID_ENABLED, false)) {
        int errno = native_deleteTagData(0, uid);
        if (errno < 0) {
            Slog.w(TAG, "problem clearing counters for uid " + uid + " : errno " + errno);
        }
    }
    }

    /**
     * Convert {@code /proc/} tag format to {@link Integer}. Assumes incoming
+0 −6
Original line number Diff line number Diff line
@@ -39,8 +39,6 @@ import static android.net.NetworkStats.STATS_PER_UID;
import static android.net.NetworkStats.TAG_NONE;
import static android.net.TrafficStats.UID_TETHERING;

import static com.android.server.NetworkManagementSocketTagger.PROP_QTAGUID_ENABLED;

import android.annotation.NonNull;
import android.app.ActivityManager;
import android.content.Context;
@@ -72,7 +70,6 @@ import android.os.ServiceManager;
import android.os.ServiceSpecificException;
import android.os.StrictMode;
import android.os.SystemClock;
import android.os.SystemProperties;
import android.os.Trace;
import android.text.TextUtils;
import android.util.Log;
@@ -446,9 +443,6 @@ public class NetworkManagementService extends INetworkManagementService.Stub {
        // push any existing quota or UID rules
        synchronized (mQuotaLock) {

            // Netd unconditionally enable bandwidth control
            SystemProperties.set(PROP_QTAGUID_ENABLED, "1");

            mStrictEnabled = true;

            setDataSaverModeEnabled(mDataSaverMode);