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

Commit 2a2b27f8 authored by Treehugger Robot's avatar Treehugger Robot Committed by Automerger Merge Worker
Browse files

Merge "Add extra logging" am: 47b98a2d am: 9479208d am: 09d3410e am: 0ec82bc2

parents cc580a03 0ec82bc2
Loading
Loading
Loading
Loading
+19 −9
Original line number Diff line number Diff line
@@ -57,9 +57,11 @@ public final class VcnCellUnderlyingNetworkTemplate extends VcnUnderlyingNetwork
    @NonNull private final Set<Integer> mAllowedSpecificCarrierIds;

    private static final String ROAMING_MATCH_KEY = "mRoamingMatchCriteria";
    private static final int DEFAULT_ROAMING_MATCH_CRITERIA = MATCH_ANY;
    private final int mRoamingMatchCriteria;

    private static final String OPPORTUNISTIC_MATCH_KEY = "mOpportunisticMatchCriteria";
    private static final int DEFAULT_OPPORTUNISTIC_MATCH_CRITERIA = MATCH_ANY;
    private final int mOpportunisticMatchCriteria;

    private VcnCellUnderlyingNetworkTemplate(
@@ -253,23 +255,31 @@ public final class VcnCellUnderlyingNetworkTemplate extends VcnUnderlyingNetwork
    /** @hide */
    @Override
    void dumpTransportSpecificFields(IndentingPrintWriter pw) {
        pw.println("mAllowedNetworkPlmnIds: " + mAllowedNetworkPlmnIds.toString());
        pw.println("mAllowedSpecificCarrierIds: " + mAllowedSpecificCarrierIds.toString());
        if (!mAllowedNetworkPlmnIds.isEmpty()) {
            pw.println("mAllowedNetworkPlmnIds: " + mAllowedNetworkPlmnIds);
        }
        if (!mAllowedNetworkPlmnIds.isEmpty()) {
            pw.println("mAllowedSpecificCarrierIds: " + mAllowedSpecificCarrierIds);
        }
        if (mRoamingMatchCriteria != DEFAULT_ROAMING_MATCH_CRITERIA) {
            pw.println("mRoamingMatchCriteria: " + getMatchCriteriaString(mRoamingMatchCriteria));
        }
        if (mOpportunisticMatchCriteria != DEFAULT_OPPORTUNISTIC_MATCH_CRITERIA) {
            pw.println(
                    "mOpportunisticMatchCriteria: "
                            + getMatchCriteriaString(mOpportunisticMatchCriteria));
        }
    }

    /** This class is used to incrementally build VcnCellUnderlyingNetworkTemplate objects. */
    public static final class Builder {
        private int mMeteredMatchCriteria = MATCH_ANY;
        private int mMeteredMatchCriteria = DEFAULT_METERED_MATCH_CRITERIA;

        @NonNull private final Set<String> mAllowedNetworkPlmnIds = new ArraySet<>();
        @NonNull private final Set<Integer> mAllowedSpecificCarrierIds = new ArraySet<>();

        private int mRoamingMatchCriteria = MATCH_ANY;
        private int mOpportunisticMatchCriteria = MATCH_ANY;
        private int mRoamingMatchCriteria = DEFAULT_ROAMING_MATCH_CRITERIA;
        private int mOpportunisticMatchCriteria = DEFAULT_OPPORTUNISTIC_MATCH_CRITERIA;

        private int mMinEntryUpstreamBandwidthKbps = DEFAULT_MIN_BANDWIDTH_KBPS;
        private int mMinExitUpstreamBandwidthKbps = DEFAULT_MIN_BANDWIDTH_KBPS;
+18 −7
Original line number Diff line number Diff line
@@ -15,8 +15,6 @@
 */
package android.net.vcn;

import static android.net.vcn.VcnUnderlyingNetworkTemplate.MATCH_ANY;

import static com.android.internal.annotations.VisibleForTesting.Visibility;

import android.annotation.IntDef;
@@ -88,6 +86,9 @@ public abstract class VcnUnderlyingNetworkTemplate {
    /** @hide */
    static final String METERED_MATCH_KEY = "mMeteredMatchCriteria";

    /** @hide */
    static final int DEFAULT_METERED_MATCH_CRITERIA = MATCH_ANY;

    private final int mMeteredMatchCriteria;

    /** @hide */
@@ -237,11 +238,21 @@ public abstract class VcnUnderlyingNetworkTemplate {
        pw.println(this.getClass().getSimpleName() + ":");
        pw.increaseIndent();

        if (mMeteredMatchCriteria != DEFAULT_METERED_MATCH_CRITERIA) {
            pw.println("mMeteredMatchCriteria: " + getMatchCriteriaString(mMeteredMatchCriteria));
        }
        if (mMinEntryUpstreamBandwidthKbps != DEFAULT_MIN_BANDWIDTH_KBPS) {
            pw.println("mMinEntryUpstreamBandwidthKbps: " + mMinEntryUpstreamBandwidthKbps);
        }
        if (mMinExitUpstreamBandwidthKbps != DEFAULT_MIN_BANDWIDTH_KBPS) {
            pw.println("mMinExitUpstreamBandwidthKbps: " + mMinExitUpstreamBandwidthKbps);
        }
        if (mMinEntryDownstreamBandwidthKbps != DEFAULT_MIN_BANDWIDTH_KBPS) {
            pw.println("mMinEntryDownstreamBandwidthKbps: " + mMinEntryDownstreamBandwidthKbps);
        }
        if (mMinExitDownstreamBandwidthKbps != DEFAULT_MIN_BANDWIDTH_KBPS) {
            pw.println("mMinExitDownstreamBandwidthKbps: " + mMinExitDownstreamBandwidthKbps);
        }
        dumpTransportSpecificFields(pw);

        pw.decreaseIndent();
+3 −1
Original line number Diff line number Diff line
@@ -147,8 +147,10 @@ public final class VcnWifiUnderlyingNetworkTemplate extends VcnUnderlyingNetwork
    /** @hide */
    @Override
    void dumpTransportSpecificFields(IndentingPrintWriter pw) {
        if (!mSsids.isEmpty()) {
            pw.println("mSsids: " + mSsids);
        }
    }

    /**
     * Retrieve the matching SSIDs, or an empty set if any SSID is acceptable.
+21 −9
Original line number Diff line number Diff line
@@ -153,7 +153,7 @@ import java.util.concurrent.TimeUnit;
public class VcnManagementService extends IVcnManagementService.Stub {
    @NonNull private static final String TAG = VcnManagementService.class.getSimpleName();
    private static final long DUMP_TIMEOUT_MILLIS = TimeUnit.SECONDS.toMillis(5);
    private static final int LOCAL_LOG_LINE_COUNT = 128;
    private static final int LOCAL_LOG_LINE_COUNT = 512;

    // Public for use in all other VCN classes
    @NonNull public static final LocalLog LOCAL_LOG = new LocalLog(LOCAL_LOG_LINE_COUNT);
@@ -456,7 +456,7 @@ public class VcnManagementService extends IVcnManagementService.Stub {
            synchronized (mLock) {
                final TelephonySubscriptionSnapshot oldSnapshot = mLastSnapshot;
                mLastSnapshot = snapshot;
                logDbg("new snapshot: " + mLastSnapshot);
                logInfo("new snapshot: " + mLastSnapshot);

                // Start any VCN instances as necessary
                for (Entry<ParcelUuid, VcnConfig> entry : mConfigs.entrySet()) {
@@ -522,6 +522,8 @@ public class VcnManagementService extends IVcnManagementService.Stub {

    @GuardedBy("mLock")
    private void stopVcnLocked(@NonNull ParcelUuid uuidToTeardown) {
        logInfo("Stopping VCN config for subGrp: " + uuidToTeardown);

        // Remove in 2 steps. Make sure teardownAsync is triggered before removing from the map.
        final Vcn vcnToTeardown = mVcns.get(uuidToTeardown);
        if (vcnToTeardown == null) {
@@ -567,7 +569,7 @@ public class VcnManagementService extends IVcnManagementService.Stub {

    @GuardedBy("mLock")
    private void startVcnLocked(@NonNull ParcelUuid subscriptionGroup, @NonNull VcnConfig config) {
        logDbg("Starting VCN config for subGrp: " + subscriptionGroup);
        logInfo("Starting VCN config for subGrp: " + subscriptionGroup);

        // TODO(b/193687515): Support multiple VCNs active at the same time
        if (!mVcns.isEmpty()) {
@@ -626,7 +628,7 @@ public class VcnManagementService extends IVcnManagementService.Stub {
        if (!config.getProvisioningPackageName().equals(opPkgName)) {
            throw new IllegalArgumentException("Mismatched caller and VcnConfig creator");
        }
        logDbg("VCN config updated for subGrp: " + subscriptionGroup);
        logInfo("VCN config updated for subGrp: " + subscriptionGroup);

        mContext.getSystemService(AppOpsManager.class)
                .checkPackage(mDeps.getBinderCallingUid(), config.getProvisioningPackageName());
@@ -652,7 +654,7 @@ public class VcnManagementService extends IVcnManagementService.Stub {
    public void clearVcnConfig(@NonNull ParcelUuid subscriptionGroup, @NonNull String opPkgName) {
        requireNonNull(subscriptionGroup, "subscriptionGroup was null");
        requireNonNull(opPkgName, "opPkgName was null");
        logDbg("VCN config cleared for subGrp: " + subscriptionGroup);
        logInfo("VCN config cleared for subGrp: " + subscriptionGroup);

        mContext.getSystemService(AppOpsManager.class)
                .checkPackage(mDeps.getBinderCallingUid(), opPkgName);
@@ -1050,24 +1052,34 @@ public class VcnManagementService extends IVcnManagementService.Stub {
        Slog.d(TAG, msg, tr);
    }

    private void logInfo(String msg) {
        Slog.i(TAG, msg);
        LOCAL_LOG.log("[INFO] [" + TAG + "] " + msg);
    }

    private void logInfo(String msg, Throwable tr) {
        Slog.i(TAG, msg, tr);
        LOCAL_LOG.log("[INFO] [" + TAG + "] " + msg + tr);
    }

    private void logErr(String msg) {
        Slog.e(TAG, msg);
        LOCAL_LOG.log(TAG + " ERR: " + msg);
        LOCAL_LOG.log("[ERR] [" + TAG + "] " + msg);
    }

    private void logErr(String msg, Throwable tr) {
        Slog.e(TAG, msg, tr);
        LOCAL_LOG.log(TAG + " ERR: " + msg + tr);
        LOCAL_LOG.log("[ERR ] [" + TAG + "] " + msg + tr);
    }

    private void logWtf(String msg) {
        Slog.wtf(TAG, msg);
        LOCAL_LOG.log(TAG + " WTF: " + msg);
        LOCAL_LOG.log("[WTF] [" + TAG + "] " + msg);
    }

    private void logWtf(String msg, Throwable tr) {
        Slog.wtf(TAG, msg, tr);
        LOCAL_LOG.log(TAG + " WTF: " + msg + tr);
        LOCAL_LOG.log("[WTF ] [" + TAG + "] " + msg + tr);
    }

    /**
+9 −7
Original line number Diff line number Diff line
@@ -341,6 +341,9 @@ public class Vcn extends Handler {
                if (gatewayConnection == null) {
                    logWtf("Found gatewayConnectionConfig without GatewayConnection");
                } else {
                    logInfo(
                            "Config updated, restarting gateway "
                                    + gatewayConnection.getLogPrefix());
                    gatewayConnection.teardownAsynchronously();
                }
            }
@@ -397,7 +400,7 @@ public class Vcn extends Handler {
        // If preexisting VcnGatewayConnection(s) satisfy request, return
        for (VcnGatewayConnectionConfig gatewayConnectionConfig : mVcnGatewayConnections.keySet()) {
            if (isRequestSatisfiedByGatewayConnectionConfig(request, gatewayConnectionConfig)) {
                logDbg("Request already satisfied by existing VcnGatewayConnection: " + request);
                logVdbg("Request already satisfied by existing VcnGatewayConnection: " + request);
                return;
            }
        }
@@ -407,8 +410,6 @@ public class Vcn extends Handler {
        for (VcnGatewayConnectionConfig gatewayConnectionConfig :
                mConfig.getGatewayConnectionConfigs()) {
            if (isRequestSatisfiedByGatewayConnectionConfig(request, gatewayConnectionConfig)) {
                logDbg("Bringing up new VcnGatewayConnection for request " + request);

                if (getExposedCapabilitiesForMobileDataState(gatewayConnectionConfig).isEmpty()) {
                    // Skip; this network does not provide any services if mobile data is disabled.
                    continue;
@@ -424,6 +425,7 @@ public class Vcn extends Handler {
                    return;
                }

                logInfo("Bringing up new VcnGatewayConnection for request " + request);
                final VcnGatewayConnection vcnGatewayConnection =
                        mDeps.newVcnGatewayConnection(
                                mVcnContext,
@@ -455,7 +457,7 @@ public class Vcn extends Handler {
    }

    private void handleGatewayConnectionQuit(VcnGatewayConnectionConfig config) {
        logDbg("VcnGatewayConnection quit: " + config);
        logInfo("VcnGatewayConnection quit: " + config);
        mVcnGatewayConnections.remove(config);

        // Trigger a re-evaluation of all NetworkRequests (to make sure any that can be satisfied
@@ -534,7 +536,7 @@ public class Vcn extends Handler {
            // Trigger re-evaluation of all requests; mobile data state impacts supported caps.
            mVcnContext.getVcnNetworkProvider().resendAllRequests(mRequestListener);

            logDbg("Mobile data " + (mIsMobileDataEnabled ? "enabled" : "disabled"));
            logInfo("Mobile data " + (mIsMobileDataEnabled ? "enabled" : "disabled"));
        }
    }

@@ -569,11 +571,11 @@ public class Vcn extends Handler {
    }

    private String getLogPrefix() {
        return "["
        return "("
                + LogUtils.getHashedSubscriptionGroup(mSubscriptionGroup)
                + "-"
                + System.identityHashCode(this)
                + "] ";
                + ") ";
    }

    private void logVdbg(String msg) {
Loading