Loading services/core/java/com/android/server/vcn/Vcn.java +49 −29 Original line number Diff line number Diff line Loading @@ -50,6 +50,7 @@ import com.android.internal.annotations.VisibleForTesting.Visibility; import com.android.internal.util.IndentingPrintWriter; import com.android.server.VcnManagementService.VcnCallback; import com.android.server.vcn.TelephonySubscriptionTracker.TelephonySubscriptionSnapshot; import com.android.server.vcn.util.LogUtils; import java.util.Arrays; import java.util.Collections; Loading Loading @@ -305,15 +306,13 @@ public class Vcn extends Handler { handleTeardown(); break; default: Slog.wtf(getLogTag(), "Unknown msg.what: " + msg.what); logWtf("Unknown msg.what: " + msg.what); } } private void handleConfigUpdated(@NonNull VcnConfig config) { // TODO: Add a dump function in VcnConfig that omits PII. Until then, use hashCode() Slog.d( getLogTag(), "Config updated: old = " + mConfig.hashCode() + "; new = " + config.hashCode()); logDbg("Config updated: old = " + mConfig.hashCode() + "; new = " + config.hashCode()); mConfig = config; Loading @@ -328,8 +327,7 @@ public class Vcn extends Handler { // connection details may have changed). if (!mConfig.getGatewayConnectionConfigs().contains(gatewayConnectionConfig)) { if (gatewayConnection == null) { Slog.wtf( getLogTag(), "Found gatewayConnectionConfig without GatewayConnection"); logWtf("Found gatewayConnectionConfig without GatewayConnection"); } else { gatewayConnection.teardownAsynchronously(); } Loading @@ -342,7 +340,7 @@ public class Vcn extends Handler { } private void handleTeardown() { Slog.d(getLogTag(), "Tearing down"); logDbg("Tearing down"); mVcnContext.getVcnNetworkProvider().unregisterListener(mRequestListener); for (VcnGatewayConnection gatewayConnection : mVcnGatewayConnections.values()) { Loading @@ -353,7 +351,7 @@ public class Vcn extends Handler { } private void handleSafeModeStatusChanged() { Slog.d(getLogTag(), "VcnGatewayConnection safe mode status changed"); logDbg("VcnGatewayConnection safe mode status changed"); boolean hasSafeModeGatewayConnection = false; // If any VcnGatewayConnection is in safe mode, mark the entire VCN as being in safe mode Loading @@ -369,24 +367,19 @@ public class Vcn extends Handler { hasSafeModeGatewayConnection ? VCN_STATUS_CODE_SAFE_MODE : VCN_STATUS_CODE_ACTIVE; if (oldStatus != mCurrentStatus) { mVcnCallback.onSafeModeStatusChanged(hasSafeModeGatewayConnection); Slog.d( getLogTag(), logDbg( "Safe mode " + (mCurrentStatus == VCN_STATUS_CODE_SAFE_MODE ? "entered" : "exited")); } } private void handleNetworkRequested(@NonNull NetworkRequest request) { if (VDBG) { Slog.v(getLogTag(), "Received request " + request); } logVdbg("Received request " + request); // If preexisting VcnGatewayConnection(s) satisfy request, return for (VcnGatewayConnectionConfig gatewayConnectionConfig : mVcnGatewayConnections.keySet()) { if (isRequestSatisfiedByGatewayConnectionConfig(request, gatewayConnectionConfig)) { Slog.d( getLogTag(), "Request already satisfied by existing VcnGatewayConnection: " + request); logDbg("Request already satisfied by existing VcnGatewayConnection: " + request); return; } } Loading @@ -396,7 +389,7 @@ public class Vcn extends Handler { for (VcnGatewayConnectionConfig gatewayConnectionConfig : mConfig.getGatewayConnectionConfigs()) { if (isRequestSatisfiedByGatewayConnectionConfig(request, gatewayConnectionConfig)) { Slog.d(getLogTag(), "Bringing up new VcnGatewayConnection for request " + request); 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. Loading @@ -407,7 +400,8 @@ public class Vcn extends Handler { // pre-existing VcnGatewayConnections that satisfy a given request, but if state // that affects the satsifying of requests changes, this is theoretically possible. if (mVcnGatewayConnections.containsKey(gatewayConnectionConfig)) { Slog.wtf(getLogTag(), "Attempted to bring up VcnGatewayConnection for config " logWtf( "Attempted to bring up VcnGatewayConnection for config " + "with existing VcnGatewayConnection"); return; } Loading @@ -426,9 +420,7 @@ public class Vcn extends Handler { } } if (VDBG) { Slog.v(getLogTag(), "Request could not be fulfilled by VCN: " + request); } logVdbg("Request could not be fulfilled by VCN: " + request); } private Set<Integer> getExposedCapabilitiesForMobileDataState( Loading @@ -445,7 +437,7 @@ public class Vcn extends Handler { } private void handleGatewayConnectionQuit(VcnGatewayConnectionConfig config) { Slog.d(getLogTag(), "VcnGatewayConnection quit: " + config); logDbg("VcnGatewayConnection quit: " + config); mVcnGatewayConnections.remove(config); // Trigger a re-evaluation of all NetworkRequests (to make sure any that can be satisfied Loading Loading @@ -480,9 +472,7 @@ public class Vcn extends Handler { if (exposedCaps.contains(NET_CAPABILITY_INTERNET) || exposedCaps.contains(NET_CAPABILITY_DUN)) { if (gatewayConnection == null) { Slog.wtf( getLogTag(), "Found gatewayConnectionConfig without GatewayConnection"); logWtf("Found gatewayConnectionConfig without" + " GatewayConnection"); } else { // TODO(b/184868850): Optimize by restarting NetworkAgents without teardown. gatewayConnection.teardownAsynchronously(); Loading @@ -493,7 +483,7 @@ public class Vcn extends Handler { // Trigger re-evaluation of all requests; mobile data state impacts supported caps. mVcnContext.getVcnNetworkProvider().resendAllRequests(mRequestListener); Slog.d(getLogTag(), "Mobile data " + (mIsMobileDataEnabled ? "enabled" : "disabled")); logDbg("Mobile data " + (mIsMobileDataEnabled ? "enabled" : "disabled")); } } Loading Loading @@ -522,8 +512,38 @@ public class Vcn extends Handler { return request.canBeSatisfiedBy(builder.build()); } private String getLogTag() { return TAG + " [" + mSubscriptionGroup.hashCode() + "]"; private String getLogPrefix() { return "[" + LogUtils.getHashedSubscriptionGroup(mSubscriptionGroup) + "]: "; } private void logVdbg(String msg) { if (VDBG) { Slog.v(TAG, getLogPrefix() + msg); } } private void logDbg(String msg) { Slog.d(TAG, getLogPrefix() + msg); } private void logDbg(String msg, Throwable tr) { Slog.d(TAG, getLogPrefix() + msg, tr); } private void logErr(String msg) { Slog.e(TAG, getLogPrefix() + msg); } private void logErr(String msg, Throwable tr) { Slog.e(TAG, getLogPrefix() + msg, tr); } private void logWtf(String msg) { Slog.wtf(TAG, getLogPrefix() + msg); } private void logWtf(String msg, Throwable tr) { Slog.wtf(TAG, getLogPrefix() + msg, tr); } /** Loading services/core/java/com/android/server/vcn/VcnGatewayConnection.java +102 −92 File changed.Preview size limit exceeded, changes collapsed. Show changes services/core/java/com/android/server/vcn/util/LogUtils.java 0 → 100644 +39 −0 Original line number Diff line number Diff line /* * Copyright (C) 2021 The Android Open Source Project * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. */ package com.android.server.vcn.util; import android.annotation.Nullable; import android.os.ParcelUuid; import com.android.internal.util.HexDump; /** @hide */ public class LogUtils { /** * Returns the hash of the subscription group in hexadecimal format. * * @return the hexadecimal encoded string if uuid was non-null, else {@code null} */ @Nullable public static String getHashedSubscriptionGroup(@Nullable ParcelUuid uuid) { if (uuid == null) { return null; } return HexDump.toHexString(uuid.hashCode()); } } Loading
services/core/java/com/android/server/vcn/Vcn.java +49 −29 Original line number Diff line number Diff line Loading @@ -50,6 +50,7 @@ import com.android.internal.annotations.VisibleForTesting.Visibility; import com.android.internal.util.IndentingPrintWriter; import com.android.server.VcnManagementService.VcnCallback; import com.android.server.vcn.TelephonySubscriptionTracker.TelephonySubscriptionSnapshot; import com.android.server.vcn.util.LogUtils; import java.util.Arrays; import java.util.Collections; Loading Loading @@ -305,15 +306,13 @@ public class Vcn extends Handler { handleTeardown(); break; default: Slog.wtf(getLogTag(), "Unknown msg.what: " + msg.what); logWtf("Unknown msg.what: " + msg.what); } } private void handleConfigUpdated(@NonNull VcnConfig config) { // TODO: Add a dump function in VcnConfig that omits PII. Until then, use hashCode() Slog.d( getLogTag(), "Config updated: old = " + mConfig.hashCode() + "; new = " + config.hashCode()); logDbg("Config updated: old = " + mConfig.hashCode() + "; new = " + config.hashCode()); mConfig = config; Loading @@ -328,8 +327,7 @@ public class Vcn extends Handler { // connection details may have changed). if (!mConfig.getGatewayConnectionConfigs().contains(gatewayConnectionConfig)) { if (gatewayConnection == null) { Slog.wtf( getLogTag(), "Found gatewayConnectionConfig without GatewayConnection"); logWtf("Found gatewayConnectionConfig without GatewayConnection"); } else { gatewayConnection.teardownAsynchronously(); } Loading @@ -342,7 +340,7 @@ public class Vcn extends Handler { } private void handleTeardown() { Slog.d(getLogTag(), "Tearing down"); logDbg("Tearing down"); mVcnContext.getVcnNetworkProvider().unregisterListener(mRequestListener); for (VcnGatewayConnection gatewayConnection : mVcnGatewayConnections.values()) { Loading @@ -353,7 +351,7 @@ public class Vcn extends Handler { } private void handleSafeModeStatusChanged() { Slog.d(getLogTag(), "VcnGatewayConnection safe mode status changed"); logDbg("VcnGatewayConnection safe mode status changed"); boolean hasSafeModeGatewayConnection = false; // If any VcnGatewayConnection is in safe mode, mark the entire VCN as being in safe mode Loading @@ -369,24 +367,19 @@ public class Vcn extends Handler { hasSafeModeGatewayConnection ? VCN_STATUS_CODE_SAFE_MODE : VCN_STATUS_CODE_ACTIVE; if (oldStatus != mCurrentStatus) { mVcnCallback.onSafeModeStatusChanged(hasSafeModeGatewayConnection); Slog.d( getLogTag(), logDbg( "Safe mode " + (mCurrentStatus == VCN_STATUS_CODE_SAFE_MODE ? "entered" : "exited")); } } private void handleNetworkRequested(@NonNull NetworkRequest request) { if (VDBG) { Slog.v(getLogTag(), "Received request " + request); } logVdbg("Received request " + request); // If preexisting VcnGatewayConnection(s) satisfy request, return for (VcnGatewayConnectionConfig gatewayConnectionConfig : mVcnGatewayConnections.keySet()) { if (isRequestSatisfiedByGatewayConnectionConfig(request, gatewayConnectionConfig)) { Slog.d( getLogTag(), "Request already satisfied by existing VcnGatewayConnection: " + request); logDbg("Request already satisfied by existing VcnGatewayConnection: " + request); return; } } Loading @@ -396,7 +389,7 @@ public class Vcn extends Handler { for (VcnGatewayConnectionConfig gatewayConnectionConfig : mConfig.getGatewayConnectionConfigs()) { if (isRequestSatisfiedByGatewayConnectionConfig(request, gatewayConnectionConfig)) { Slog.d(getLogTag(), "Bringing up new VcnGatewayConnection for request " + request); 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. Loading @@ -407,7 +400,8 @@ public class Vcn extends Handler { // pre-existing VcnGatewayConnections that satisfy a given request, but if state // that affects the satsifying of requests changes, this is theoretically possible. if (mVcnGatewayConnections.containsKey(gatewayConnectionConfig)) { Slog.wtf(getLogTag(), "Attempted to bring up VcnGatewayConnection for config " logWtf( "Attempted to bring up VcnGatewayConnection for config " + "with existing VcnGatewayConnection"); return; } Loading @@ -426,9 +420,7 @@ public class Vcn extends Handler { } } if (VDBG) { Slog.v(getLogTag(), "Request could not be fulfilled by VCN: " + request); } logVdbg("Request could not be fulfilled by VCN: " + request); } private Set<Integer> getExposedCapabilitiesForMobileDataState( Loading @@ -445,7 +437,7 @@ public class Vcn extends Handler { } private void handleGatewayConnectionQuit(VcnGatewayConnectionConfig config) { Slog.d(getLogTag(), "VcnGatewayConnection quit: " + config); logDbg("VcnGatewayConnection quit: " + config); mVcnGatewayConnections.remove(config); // Trigger a re-evaluation of all NetworkRequests (to make sure any that can be satisfied Loading Loading @@ -480,9 +472,7 @@ public class Vcn extends Handler { if (exposedCaps.contains(NET_CAPABILITY_INTERNET) || exposedCaps.contains(NET_CAPABILITY_DUN)) { if (gatewayConnection == null) { Slog.wtf( getLogTag(), "Found gatewayConnectionConfig without GatewayConnection"); logWtf("Found gatewayConnectionConfig without" + " GatewayConnection"); } else { // TODO(b/184868850): Optimize by restarting NetworkAgents without teardown. gatewayConnection.teardownAsynchronously(); Loading @@ -493,7 +483,7 @@ public class Vcn extends Handler { // Trigger re-evaluation of all requests; mobile data state impacts supported caps. mVcnContext.getVcnNetworkProvider().resendAllRequests(mRequestListener); Slog.d(getLogTag(), "Mobile data " + (mIsMobileDataEnabled ? "enabled" : "disabled")); logDbg("Mobile data " + (mIsMobileDataEnabled ? "enabled" : "disabled")); } } Loading Loading @@ -522,8 +512,38 @@ public class Vcn extends Handler { return request.canBeSatisfiedBy(builder.build()); } private String getLogTag() { return TAG + " [" + mSubscriptionGroup.hashCode() + "]"; private String getLogPrefix() { return "[" + LogUtils.getHashedSubscriptionGroup(mSubscriptionGroup) + "]: "; } private void logVdbg(String msg) { if (VDBG) { Slog.v(TAG, getLogPrefix() + msg); } } private void logDbg(String msg) { Slog.d(TAG, getLogPrefix() + msg); } private void logDbg(String msg, Throwable tr) { Slog.d(TAG, getLogPrefix() + msg, tr); } private void logErr(String msg) { Slog.e(TAG, getLogPrefix() + msg); } private void logErr(String msg, Throwable tr) { Slog.e(TAG, getLogPrefix() + msg, tr); } private void logWtf(String msg) { Slog.wtf(TAG, getLogPrefix() + msg); } private void logWtf(String msg, Throwable tr) { Slog.wtf(TAG, getLogPrefix() + msg, tr); } /** Loading
services/core/java/com/android/server/vcn/VcnGatewayConnection.java +102 −92 File changed.Preview size limit exceeded, changes collapsed. Show changes
services/core/java/com/android/server/vcn/util/LogUtils.java 0 → 100644 +39 −0 Original line number Diff line number Diff line /* * Copyright (C) 2021 The Android Open Source Project * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. */ package com.android.server.vcn.util; import android.annotation.Nullable; import android.os.ParcelUuid; import com.android.internal.util.HexDump; /** @hide */ public class LogUtils { /** * Returns the hash of the subscription group in hexadecimal format. * * @return the hexadecimal encoded string if uuid was non-null, else {@code null} */ @Nullable public static String getHashedSubscriptionGroup(@Nullable ParcelUuid uuid) { if (uuid == null) { return null; } return HexDump.toHexString(uuid.hashCode()); } }