Migrate Slog to Log used in connectivity service module

Connectivity service module uses Slog which is @hide so
migrate to Log, which is public, to remove hidden API usage.

Bug: 172050541
Test: FrameworksNetTests
      check log is moved from system buffer to main buffer.
Change-Id: I0dcc0e169b892cc872ed4510f699642cb81b633a
This commit is contained in:
Aaron Huang
2020-10-30 22:04:25 +08:00
parent e794a09bb7
commit 6616df39b9
5 changed files with 80 additions and 77 deletions

View File

@@ -170,7 +170,6 @@ import android.util.ArraySet;
import android.util.LocalLog; import android.util.LocalLog;
import android.util.Log; import android.util.Log;
import android.util.Pair; import android.util.Pair;
import android.util.Slog;
import android.util.SparseArray; import android.util.SparseArray;
import android.util.SparseIntArray; import android.util.SparseIntArray;
import android.util.Xml; import android.util.Xml;
@@ -1972,7 +1971,7 @@ public class ConnectivityService extends IConnectivityManager.Stub
private void registerNetdEventCallback() { private void registerNetdEventCallback() {
final IIpConnectivityMetrics ipConnectivityMetrics = mDeps.getIpConnectivityMetrics(); final IIpConnectivityMetrics ipConnectivityMetrics = mDeps.getIpConnectivityMetrics();
if (ipConnectivityMetrics == null) { if (ipConnectivityMetrics == null) {
Slog.wtf(TAG, "Missing IIpConnectivityMetrics"); Log.wtf(TAG, "Missing IIpConnectivityMetrics");
return; return;
} }
@@ -2438,7 +2437,7 @@ public class ConnectivityService extends IConnectivityManager.Stub
if (VDBG || DDBG) log("Setting MTU size: " + iface + ", " + mtu); if (VDBG || DDBG) log("Setting MTU size: " + iface + ", " + mtu);
mNetd.interfaceSetMtu(iface, mtu); mNetd.interfaceSetMtu(iface, mtu);
} catch (RemoteException | ServiceSpecificException e) { } catch (RemoteException | ServiceSpecificException e) {
Slog.e(TAG, "exception in interfaceSetMtu()" + e); loge("exception in interfaceSetMtu()" + e);
} }
} }
@@ -2460,7 +2459,7 @@ public class ConnectivityService extends IConnectivityManager.Stub
if (tcpBufferSizes.equals(mCurrentTcpBufferSizes)) return; if (tcpBufferSizes.equals(mCurrentTcpBufferSizes)) return;
try { try {
if (VDBG || DDBG) Slog.d(TAG, "Setting tx/rx TCP buffers to " + tcpBufferSizes); if (VDBG || DDBG) log("Setting tx/rx TCP buffers to " + tcpBufferSizes);
String rmemValues = String.join(" ", values[0], values[1], values[2]); String rmemValues = String.join(" ", values[0], values[1], values[2]);
String wmemValues = String.join(" ", values[3], values[4], values[5]); String wmemValues = String.join(" ", values[3], values[4], values[5]);
@@ -2761,7 +2760,7 @@ public class ConnectivityService extends IConnectivityManager.Stub
case NetworkAgent.EVENT_NETWORK_CAPABILITIES_CHANGED: { case NetworkAgent.EVENT_NETWORK_CAPABILITIES_CHANGED: {
NetworkCapabilities networkCapabilities = (NetworkCapabilities) msg.obj; NetworkCapabilities networkCapabilities = (NetworkCapabilities) msg.obj;
if (networkCapabilities.hasConnectivityManagedCapability()) { if (networkCapabilities.hasConnectivityManagedCapability()) {
Slog.wtf(TAG, "BUG: " + nai + " has CS-managed capability."); Log.wtf(TAG, "BUG: " + nai + " has CS-managed capability.");
} }
if (networkCapabilities.hasTransport(TRANSPORT_TEST)) { if (networkCapabilities.hasTransport(TRANSPORT_TEST)) {
// Make sure the original object is not mutated. NetworkAgent normally // Make sure the original object is not mutated. NetworkAgent normally
@@ -3066,7 +3065,7 @@ public class ConnectivityService extends IConnectivityManager.Stub
// Legacy version of notifyNetworkTestedWithExtras. // Legacy version of notifyNetworkTestedWithExtras.
// Would only be called if the system has a NetworkStack module older than the // Would only be called if the system has a NetworkStack module older than the
// framework, which does not happen in practice. // framework, which does not happen in practice.
Slog.wtf(TAG, "Deprecated notifyNetworkTested called: no action taken"); Log.wtf(TAG, "Deprecated notifyNetworkTested called: no action taken");
} }
@Override @Override
@@ -3543,7 +3542,7 @@ public class ConnectivityService extends IConnectivityManager.Stub
numRequests = nai.numForegroundNetworkRequests(); numRequests = nai.numForegroundNetworkRequests();
break; break;
default: default:
Slog.wtf(TAG, "Invalid reason. Cannot happen."); Log.wtf(TAG, "Invalid reason. Cannot happen.");
return true; return true;
} }
@@ -3705,7 +3704,7 @@ public class ConnectivityService extends IConnectivityManager.Stub
synchronized (mUidToNetworkRequestCount) { synchronized (mUidToNetworkRequestCount) {
final int requests = mUidToNetworkRequestCount.get(nri.mUid, 0); final int requests = mUidToNetworkRequestCount.get(nri.mUid, 0);
if (requests < 1) { if (requests < 1) {
Slog.wtf(TAG, "BUG: too small request count " + requests + " for UID " + nri.mUid); Log.wtf(TAG, "BUG: too small request count " + requests + " for UID " + nri.mUid);
} else if (requests == 1) { } else if (requests == 1) {
mUidToNetworkRequestCount.removeAt(mUidToNetworkRequestCount.indexOfKey(nri.mUid)); mUidToNetworkRequestCount.removeAt(mUidToNetworkRequestCount.indexOfKey(nri.mUid));
} else { } else {
@@ -3750,7 +3749,7 @@ public class ConnectivityService extends IConnectivityManager.Stub
} }
if (!nai.networkAgentConfig.explicitlySelected) { if (!nai.networkAgentConfig.explicitlySelected) {
Slog.wtf(TAG, "BUG: setAcceptUnvalidated non non-explicitly selected network"); Log.wtf(TAG, "BUG: setAcceptUnvalidated non non-explicitly selected network");
} }
if (accept != nai.networkAgentConfig.acceptUnvalidated) { if (accept != nai.networkAgentConfig.acceptUnvalidated) {
@@ -4020,7 +4019,7 @@ public class ConnectivityService extends IConnectivityManager.Stub
highPriority = nai.networkAgentConfig.explicitlySelected; highPriority = nai.networkAgentConfig.explicitlySelected;
break; break;
default: default:
Slog.wtf(TAG, "Unknown notification type " + type); Log.wtf(TAG, "Unknown notification type " + type);
return; return;
} }
@@ -4342,7 +4341,7 @@ public class ConnectivityService extends IConnectivityManager.Stub
synchronized (this) { synchronized (this) {
if (!mNetTransitionWakeLock.isHeld()) { if (!mNetTransitionWakeLock.isHeld()) {
mWakelockLogs.log(String.format("RELEASE: already released (%s)", event)); mWakelockLogs.log(String.format("RELEASE: already released (%s)", event));
Slog.w(TAG, "expected Net Transition WakeLock to be held"); Log.w(TAG, "expected Net Transition WakeLock to be held");
return; return;
} }
mNetTransitionWakeLock.release(); mNetTransitionWakeLock.release();
@@ -4514,7 +4513,7 @@ public class ConnectivityService extends IConnectivityManager.Stub
@Override @Override
public void onChange(boolean selfChange) { public void onChange(boolean selfChange) {
Slog.wtf(TAG, "Should never be reached."); Log.wtf(TAG, "Should never be reached.");
} }
@Override @Override
@@ -4529,15 +4528,19 @@ public class ConnectivityService extends IConnectivityManager.Stub
} }
private static void log(String s) { private static void log(String s) {
Slog.d(TAG, s); Log.d(TAG, s);
}
private static void logw(String s) {
Log.w(TAG, s);
} }
private static void loge(String s) { private static void loge(String s) {
Slog.e(TAG, s); Log.e(TAG, s);
} }
private static void loge(String s, Throwable t) { private static void loge(String s, Throwable t) {
Slog.e(TAG, s, t); Log.e(TAG, s, t);
} }
/** /**
@@ -4833,7 +4836,7 @@ public class ConnectivityService extends IConnectivityManager.Stub
@Override @Override
public boolean updateLockdownVpn() { public boolean updateLockdownVpn() {
if (Binder.getCallingUid() != Process.SYSTEM_UID) { if (Binder.getCallingUid() != Process.SYSTEM_UID) {
Slog.w(TAG, "Lockdown VPN only available to AID_SYSTEM"); logw("Lockdown VPN only available to AID_SYSTEM");
return false; return false;
} }
@@ -4843,21 +4846,21 @@ public class ConnectivityService extends IConnectivityManager.Stub
if (mLockdownEnabled) { if (mLockdownEnabled) {
byte[] profileTag = mKeyStore.get(Credentials.LOCKDOWN_VPN); byte[] profileTag = mKeyStore.get(Credentials.LOCKDOWN_VPN);
if (profileTag == null) { if (profileTag == null) {
Slog.e(TAG, "Lockdown VPN configured but cannot be read from keystore"); loge("Lockdown VPN configured but cannot be read from keystore");
return false; return false;
} }
String profileName = new String(profileTag); String profileName = new String(profileTag);
final VpnProfile profile = VpnProfile.decode( final VpnProfile profile = VpnProfile.decode(
profileName, mKeyStore.get(Credentials.VPN + profileName)); profileName, mKeyStore.get(Credentials.VPN + profileName));
if (profile == null) { if (profile == null) {
Slog.e(TAG, "Lockdown VPN configured invalid profile " + profileName); loge("Lockdown VPN configured invalid profile " + profileName);
setLockdownTracker(null); setLockdownTracker(null);
return true; return true;
} }
int user = UserHandle.getUserId(Binder.getCallingUid()); int user = UserHandle.getUserId(Binder.getCallingUid());
Vpn vpn = mVpns.get(user); Vpn vpn = mVpns.get(user);
if (vpn == null) { if (vpn == null) {
Slog.w(TAG, "VPN for user " + user + " not ready yet. Skipping lockdown"); logw("VPN for user " + user + " not ready yet. Skipping lockdown");
return false; return false;
} }
setLockdownTracker(new LockdownVpnTracker(mContext, this, mHandler, vpn, profile)); setLockdownTracker(new LockdownVpnTracker(mContext, this, mHandler, vpn, profile));
@@ -4917,7 +4920,7 @@ public class ConnectivityService extends IConnectivityManager.Stub
if (vpn == null) { if (vpn == null) {
// Shouldn't happen as all code paths that point here should have checked the Vpn // Shouldn't happen as all code paths that point here should have checked the Vpn
// exists already. // exists already.
Slog.wtf(TAG, "User " + userId + " has no Vpn configuration"); Log.wtf(TAG, "User " + userId + " has no Vpn configuration");
return false; return false;
} }
@@ -4933,7 +4936,7 @@ public class ConnectivityService extends IConnectivityManager.Stub
synchronized (mVpns) { synchronized (mVpns) {
Vpn vpn = mVpns.get(userId); Vpn vpn = mVpns.get(userId);
if (vpn == null) { if (vpn == null) {
Slog.w(TAG, "User " + userId + " has no Vpn configuration"); logw("User " + userId + " has no Vpn configuration");
return false; return false;
} }
return vpn.isAlwaysOnPackageSupported(packageName, mKeyStore); return vpn.isAlwaysOnPackageSupported(packageName, mKeyStore);
@@ -4954,7 +4957,7 @@ public class ConnectivityService extends IConnectivityManager.Stub
Vpn vpn = mVpns.get(userId); Vpn vpn = mVpns.get(userId);
if (vpn == null) { if (vpn == null) {
Slog.w(TAG, "User " + userId + " has no Vpn configuration"); logw("User " + userId + " has no Vpn configuration");
return false; return false;
} }
if (!vpn.setAlwaysOnPackage(packageName, lockdown, lockdownWhitelist, mKeyStore)) { if (!vpn.setAlwaysOnPackage(packageName, lockdown, lockdownWhitelist, mKeyStore)) {
@@ -4976,7 +4979,7 @@ public class ConnectivityService extends IConnectivityManager.Stub
synchronized (mVpns) { synchronized (mVpns) {
Vpn vpn = mVpns.get(userId); Vpn vpn = mVpns.get(userId);
if (vpn == null) { if (vpn == null) {
Slog.w(TAG, "User " + userId + " has no Vpn configuration"); logw("User " + userId + " has no Vpn configuration");
return null; return null;
} }
return vpn.getAlwaysOnPackage(); return vpn.getAlwaysOnPackage();
@@ -4991,7 +4994,7 @@ public class ConnectivityService extends IConnectivityManager.Stub
synchronized (mVpns) { synchronized (mVpns) {
Vpn vpn = mVpns.get(userId); Vpn vpn = mVpns.get(userId);
if (vpn == null) { if (vpn == null) {
Slog.w(TAG, "User " + userId + " has no Vpn configuration"); logw("User " + userId + " has no Vpn configuration");
return false; return false;
} }
return vpn.getLockdown(); return vpn.getLockdown();
@@ -5006,7 +5009,7 @@ public class ConnectivityService extends IConnectivityManager.Stub
synchronized (mVpns) { synchronized (mVpns) {
Vpn vpn = mVpns.get(userId); Vpn vpn = mVpns.get(userId);
if (vpn == null) { if (vpn == null) {
Slog.w(TAG, "User " + userId + " has no Vpn configuration"); logw("User " + userId + " has no Vpn configuration");
return null; return null;
} }
return vpn.getLockdownAllowlist(); return vpn.getLockdownAllowlist();
@@ -5197,7 +5200,7 @@ public class ConnectivityService extends IConnectivityManager.Stub
private void onPackageReplaced(String packageName, int uid) { private void onPackageReplaced(String packageName, int uid) {
if (TextUtils.isEmpty(packageName) || uid < 0) { if (TextUtils.isEmpty(packageName) || uid < 0) {
Slog.wtf(TAG, "Invalid package in onPackageReplaced: " + packageName + " | " + uid); Log.wtf(TAG, "Invalid package in onPackageReplaced: " + packageName + " | " + uid);
return; return;
} }
final int userId = UserHandle.getUserId(uid); final int userId = UserHandle.getUserId(uid);
@@ -5208,7 +5211,7 @@ public class ConnectivityService extends IConnectivityManager.Stub
} }
// Legacy always-on VPN won't be affected since the package name is not set. // Legacy always-on VPN won't be affected since the package name is not set.
if (TextUtils.equals(vpn.getAlwaysOnPackage(), packageName)) { if (TextUtils.equals(vpn.getAlwaysOnPackage(), packageName)) {
Slog.d(TAG, "Restarting always-on VPN package " + packageName + " for user " log("Restarting always-on VPN package " + packageName + " for user "
+ userId); + userId);
vpn.startAlwaysOnVpn(mKeyStore); vpn.startAlwaysOnVpn(mKeyStore);
} }
@@ -5217,7 +5220,7 @@ public class ConnectivityService extends IConnectivityManager.Stub
private void onPackageRemoved(String packageName, int uid, boolean isReplacing) { private void onPackageRemoved(String packageName, int uid, boolean isReplacing) {
if (TextUtils.isEmpty(packageName) || uid < 0) { if (TextUtils.isEmpty(packageName) || uid < 0) {
Slog.wtf(TAG, "Invalid package in onPackageRemoved: " + packageName + " | " + uid); Log.wtf(TAG, "Invalid package in onPackageRemoved: " + packageName + " | " + uid);
return; return;
} }
@@ -5229,7 +5232,7 @@ public class ConnectivityService extends IConnectivityManager.Stub
} }
// Legacy always-on VPN won't be affected since the package name is not set. // Legacy always-on VPN won't be affected since the package name is not set.
if (TextUtils.equals(vpn.getAlwaysOnPackage(), packageName) && !isReplacing) { if (TextUtils.equals(vpn.getAlwaysOnPackage(), packageName) && !isReplacing) {
Slog.d(TAG, "Removing always-on VPN package " + packageName + " for user " log("Removing always-on VPN package " + packageName + " for user "
+ userId); + userId);
vpn.setAlwaysOnPackage(null, false, null, mKeyStore); vpn.setAlwaysOnPackage(null, false, null, mKeyStore);
} }
@@ -5845,7 +5848,7 @@ public class ConnectivityService extends IConnectivityManager.Stub
// Avoid creating duplicates. even if an app makes a direct AIDL call. // Avoid creating duplicates. even if an app makes a direct AIDL call.
// This will never happen if an app calls ConnectivityManager#registerNetworkProvider, // This will never happen if an app calls ConnectivityManager#registerNetworkProvider,
// as that will throw if a duplicate provider is registered. // as that will throw if a duplicate provider is registered.
Slog.e(TAG, "Attempt to register existing NetworkProviderInfo " loge("Attempt to register existing NetworkProviderInfo "
+ mNetworkProviderInfos.get(npi.messenger).name); + mNetworkProviderInfos.get(npi.messenger).name);
return; return;
} }
@@ -6402,7 +6405,7 @@ public class ConnectivityService extends IConnectivityManager.Stub
// stop being matched by the updated agent. // stop being matched by the updated agent.
String diff = nai.networkCapabilities.describeImmutableDifferences(nc); String diff = nai.networkCapabilities.describeImmutableDifferences(nc);
if (!TextUtils.isEmpty(diff)) { if (!TextUtils.isEmpty(diff)) {
Slog.wtf(TAG, "BUG: " + nai + " lost immutable capabilities:" + diff); Log.wtf(TAG, "BUG: " + nai + " lost immutable capabilities:" + diff);
} }
} }
@@ -6962,7 +6965,7 @@ public class ConnectivityService extends IConnectivityManager.Stub
} }
newSatisfier.unlingerRequest(nri.request); newSatisfier.unlingerRequest(nri.request);
if (!newSatisfier.addRequest(nri.request)) { if (!newSatisfier.addRequest(nri.request)) {
Slog.wtf(TAG, "BUG: " + newSatisfier.toShortString() + " already has " Log.wtf(TAG, "BUG: " + newSatisfier.toShortString() + " already has "
+ nri.request); + nri.request);
} }
} else { } else {
@@ -7310,7 +7313,7 @@ public class ConnectivityService extends IConnectivityManager.Stub
networkAgent.everConnected = true; networkAgent.everConnected = true;
if (networkAgent.linkProperties == null) { if (networkAgent.linkProperties == null) {
Slog.wtf(TAG, networkAgent.toShortString() + " connected with null LinkProperties"); Log.wtf(TAG, networkAgent.toShortString() + " connected with null LinkProperties");
} }
// NetworkCapabilities need to be set before sending the private DNS config to // NetworkCapabilities need to be set before sending the private DNS config to

View File

@@ -45,8 +45,8 @@ import android.os.ServiceSpecificException;
import android.os.UserHandle; import android.os.UserHandle;
import android.provider.Settings; import android.provider.Settings;
import android.text.TextUtils; import android.text.TextUtils;
import android.util.Log;
import android.util.Pair; import android.util.Pair;
import android.util.Slog;
import java.net.InetAddress; import java.net.InetAddress;
import java.util.Arrays; import java.util.Arrays;
@@ -279,7 +279,7 @@ public class DnsManager {
} }
public PrivateDnsConfig updatePrivateDns(Network network, PrivateDnsConfig cfg) { public PrivateDnsConfig updatePrivateDns(Network network, PrivateDnsConfig cfg) {
Slog.w(TAG, "updatePrivateDns(" + network + ", " + cfg + ")"); Log.w(TAG, "updatePrivateDns(" + network + ", " + cfg + ")");
return (cfg != null) return (cfg != null)
? mPrivateDnsMap.put(network.netId, cfg) ? mPrivateDnsMap.put(network.netId, cfg)
: mPrivateDnsMap.remove(network.netId); : mPrivateDnsMap.remove(network.netId);
@@ -389,7 +389,7 @@ public class DnsManager {
mPrivateDnsValidationMap.remove(netId); mPrivateDnsValidationMap.remove(netId);
} }
Slog.d(TAG, String.format("sendDnsConfigurationForNetwork(%d, %s, %s, %d, %d, %d, %d, " Log.d(TAG, String.format("sendDnsConfigurationForNetwork(%d, %s, %s, %d, %d, %d, %d, "
+ "%d, %d, %s, %s)", paramsParcel.netId, Arrays.toString(paramsParcel.servers), + "%d, %d, %s, %s)", paramsParcel.netId, Arrays.toString(paramsParcel.servers),
Arrays.toString(paramsParcel.domains), paramsParcel.sampleValiditySeconds, Arrays.toString(paramsParcel.domains), paramsParcel.sampleValiditySeconds,
paramsParcel.successThreshold, paramsParcel.minSamples, paramsParcel.successThreshold, paramsParcel.minSamples,
@@ -400,7 +400,7 @@ public class DnsManager {
try { try {
mDnsResolver.setResolverConfiguration(paramsParcel); mDnsResolver.setResolverConfiguration(paramsParcel);
} catch (RemoteException | ServiceSpecificException e) { } catch (RemoteException | ServiceSpecificException e) {
Slog.e(TAG, "Error setting DNS configuration: " + e); Log.e(TAG, "Error setting DNS configuration: " + e);
return; return;
} }
} }
@@ -431,8 +431,8 @@ public class DnsManager {
DNS_RESOLVER_SAMPLE_VALIDITY_SECONDS, DNS_RESOLVER_SAMPLE_VALIDITY_SECONDS,
DNS_RESOLVER_DEFAULT_SAMPLE_VALIDITY_SECONDS); DNS_RESOLVER_DEFAULT_SAMPLE_VALIDITY_SECONDS);
if (mSampleValidity < 0 || mSampleValidity > 65535) { if (mSampleValidity < 0 || mSampleValidity > 65535) {
Slog.w(TAG, "Invalid sampleValidity=" + mSampleValidity + ", using default=" + Log.w(TAG, "Invalid sampleValidity=" + mSampleValidity + ", using default="
DNS_RESOLVER_DEFAULT_SAMPLE_VALIDITY_SECONDS); + DNS_RESOLVER_DEFAULT_SAMPLE_VALIDITY_SECONDS);
mSampleValidity = DNS_RESOLVER_DEFAULT_SAMPLE_VALIDITY_SECONDS; mSampleValidity = DNS_RESOLVER_DEFAULT_SAMPLE_VALIDITY_SECONDS;
} }
@@ -440,17 +440,17 @@ public class DnsManager {
DNS_RESOLVER_SUCCESS_THRESHOLD_PERCENT, DNS_RESOLVER_SUCCESS_THRESHOLD_PERCENT,
DNS_RESOLVER_DEFAULT_SUCCESS_THRESHOLD_PERCENT); DNS_RESOLVER_DEFAULT_SUCCESS_THRESHOLD_PERCENT);
if (mSuccessThreshold < 0 || mSuccessThreshold > 100) { if (mSuccessThreshold < 0 || mSuccessThreshold > 100) {
Slog.w(TAG, "Invalid successThreshold=" + mSuccessThreshold + ", using default=" + Log.w(TAG, "Invalid successThreshold=" + mSuccessThreshold + ", using default="
DNS_RESOLVER_DEFAULT_SUCCESS_THRESHOLD_PERCENT); + DNS_RESOLVER_DEFAULT_SUCCESS_THRESHOLD_PERCENT);
mSuccessThreshold = DNS_RESOLVER_DEFAULT_SUCCESS_THRESHOLD_PERCENT; mSuccessThreshold = DNS_RESOLVER_DEFAULT_SUCCESS_THRESHOLD_PERCENT;
} }
mMinSamples = getIntSetting(DNS_RESOLVER_MIN_SAMPLES, DNS_RESOLVER_DEFAULT_MIN_SAMPLES); mMinSamples = getIntSetting(DNS_RESOLVER_MIN_SAMPLES, DNS_RESOLVER_DEFAULT_MIN_SAMPLES);
mMaxSamples = getIntSetting(DNS_RESOLVER_MAX_SAMPLES, DNS_RESOLVER_DEFAULT_MAX_SAMPLES); mMaxSamples = getIntSetting(DNS_RESOLVER_MAX_SAMPLES, DNS_RESOLVER_DEFAULT_MAX_SAMPLES);
if (mMinSamples < 0 || mMinSamples > mMaxSamples || mMaxSamples > 64) { if (mMinSamples < 0 || mMinSamples > mMaxSamples || mMaxSamples > 64) {
Slog.w(TAG, "Invalid sample count (min, max)=(" + mMinSamples + ", " + mMaxSamples + Log.w(TAG, "Invalid sample count (min, max)=(" + mMinSamples + ", " + mMaxSamples
"), using default=(" + DNS_RESOLVER_DEFAULT_MIN_SAMPLES + ", " + + "), using default=(" + DNS_RESOLVER_DEFAULT_MIN_SAMPLES + ", "
DNS_RESOLVER_DEFAULT_MAX_SAMPLES + ")"); + DNS_RESOLVER_DEFAULT_MAX_SAMPLES + ")");
mMinSamples = DNS_RESOLVER_DEFAULT_MIN_SAMPLES; mMinSamples = DNS_RESOLVER_DEFAULT_MIN_SAMPLES;
mMaxSamples = DNS_RESOLVER_DEFAULT_MAX_SAMPLES; mMaxSamples = DNS_RESOLVER_DEFAULT_MAX_SAMPLES;
} }

View File

@@ -30,7 +30,7 @@ import android.net.RouteInfo;
import android.os.INetworkManagementService; import android.os.INetworkManagementService;
import android.os.RemoteException; import android.os.RemoteException;
import android.os.ServiceSpecificException; import android.os.ServiceSpecificException;
import android.util.Slog; import android.util.Log;
import com.android.internal.annotations.VisibleForTesting; import com.android.internal.annotations.VisibleForTesting;
import com.android.internal.util.ArrayUtils; import com.android.internal.util.ArrayUtils;
@@ -176,7 +176,7 @@ public class Nat464Xlat extends BaseNetworkObserver {
try { try {
mNMService.registerObserver(this); mNMService.registerObserver(this);
} catch (RemoteException e) { } catch (RemoteException e) {
Slog.e(TAG, "Can't register iface observer for clat on " + mNetwork.toShortString()); Log.e(TAG, "Can't register iface observer for clat on " + mNetwork.toShortString());
return; return;
} }
@@ -185,7 +185,7 @@ public class Nat464Xlat extends BaseNetworkObserver {
try { try {
addrStr = mNetd.clatdStart(baseIface, mNat64PrefixInUse.toString()); addrStr = mNetd.clatdStart(baseIface, mNat64PrefixInUse.toString());
} catch (RemoteException | ServiceSpecificException e) { } catch (RemoteException | ServiceSpecificException e) {
Slog.e(TAG, "Error starting clatd on " + baseIface + ": " + e); Log.e(TAG, "Error starting clatd on " + baseIface + ": " + e);
} }
mIface = CLAT_PREFIX + baseIface; mIface = CLAT_PREFIX + baseIface;
mBaseIface = baseIface; mBaseIface = baseIface;
@@ -193,7 +193,7 @@ public class Nat464Xlat extends BaseNetworkObserver {
try { try {
mIPv6Address = (Inet6Address) InetAddresses.parseNumericAddress(addrStr); mIPv6Address = (Inet6Address) InetAddresses.parseNumericAddress(addrStr);
} catch (ClassCastException | IllegalArgumentException | NullPointerException e) { } catch (ClassCastException | IllegalArgumentException | NullPointerException e) {
Slog.e(TAG, "Invalid IPv6 address " + addrStr); Log.e(TAG, "Invalid IPv6 address " + addrStr);
} }
if (mPrefixDiscoveryRunning && !isPrefixDiscoveryNeeded()) { if (mPrefixDiscoveryRunning && !isPrefixDiscoveryNeeded()) {
stopPrefixDiscovery(); stopPrefixDiscovery();
@@ -218,7 +218,7 @@ public class Nat464Xlat extends BaseNetworkObserver {
try { try {
mNMService.unregisterObserver(this); mNMService.unregisterObserver(this);
} catch (RemoteException | IllegalStateException e) { } catch (RemoteException | IllegalStateException e) {
Slog.e(TAG, "Error unregistering clatd observer on " + mBaseIface + ": " + e); Log.e(TAG, "Error unregistering clatd observer on " + mBaseIface + ": " + e);
} }
mNat64PrefixInUse = null; mNat64PrefixInUse = null;
mIface = null; mIface = null;
@@ -242,37 +242,37 @@ public class Nat464Xlat extends BaseNetworkObserver {
@VisibleForTesting @VisibleForTesting
protected void start() { protected void start() {
if (isStarted()) { if (isStarted()) {
Slog.e(TAG, "startClat: already started"); Log.e(TAG, "startClat: already started");
return; return;
} }
if (mNetwork.linkProperties == null) { if (mNetwork.linkProperties == null) {
Slog.e(TAG, "startClat: Can't start clat with null LinkProperties"); Log.e(TAG, "startClat: Can't start clat with null LinkProperties");
return; return;
} }
String baseIface = mNetwork.linkProperties.getInterfaceName(); String baseIface = mNetwork.linkProperties.getInterfaceName();
if (baseIface == null) { if (baseIface == null) {
Slog.e(TAG, "startClat: Can't start clat on null interface"); Log.e(TAG, "startClat: Can't start clat on null interface");
return; return;
} }
// TODO: should we only do this if mNetd.clatdStart() succeeds? // TODO: should we only do this if mNetd.clatdStart() succeeds?
Slog.i(TAG, "Starting clatd on " + baseIface); Log.i(TAG, "Starting clatd on " + baseIface);
enterStartingState(baseIface); enterStartingState(baseIface);
} }
@VisibleForTesting @VisibleForTesting
protected void stop() { protected void stop() {
if (!isStarted()) { if (!isStarted()) {
Slog.e(TAG, "stopClat: already stopped"); Log.e(TAG, "stopClat: already stopped");
return; return;
} }
Slog.i(TAG, "Stopping clatd on " + mBaseIface); Log.i(TAG, "Stopping clatd on " + mBaseIface);
try { try {
mNetd.clatdStop(mBaseIface); mNetd.clatdStop(mBaseIface);
} catch (RemoteException | ServiceSpecificException e) { } catch (RemoteException | ServiceSpecificException e) {
Slog.e(TAG, "Error stopping clatd on " + mBaseIface + ": " + e); Log.e(TAG, "Error stopping clatd on " + mBaseIface + ": " + e);
} }
String iface = mIface; String iface = mIface;
@@ -294,7 +294,7 @@ public class Nat464Xlat extends BaseNetworkObserver {
try { try {
mDnsResolver.startPrefix64Discovery(getNetId()); mDnsResolver.startPrefix64Discovery(getNetId());
} catch (RemoteException | ServiceSpecificException e) { } catch (RemoteException | ServiceSpecificException e) {
Slog.e(TAG, "Error starting prefix discovery on netId " + getNetId() + ": " + e); Log.e(TAG, "Error starting prefix discovery on netId " + getNetId() + ": " + e);
} }
mPrefixDiscoveryRunning = true; mPrefixDiscoveryRunning = true;
} }
@@ -303,7 +303,7 @@ public class Nat464Xlat extends BaseNetworkObserver {
try { try {
mDnsResolver.stopPrefix64Discovery(getNetId()); mDnsResolver.stopPrefix64Discovery(getNetId());
} catch (RemoteException | ServiceSpecificException e) { } catch (RemoteException | ServiceSpecificException e) {
Slog.e(TAG, "Error stopping prefix discovery on netId " + getNetId() + ": " + e); Log.e(TAG, "Error stopping prefix discovery on netId " + getNetId() + ": " + e);
} }
mPrefixDiscoveryRunning = false; mPrefixDiscoveryRunning = false;
} }
@@ -320,7 +320,7 @@ public class Nat464Xlat extends BaseNetworkObserver {
try { try {
mDnsResolver.setPrefix64(getNetId(), prefixString); mDnsResolver.setPrefix64(getNetId(), prefixString);
} catch (RemoteException | ServiceSpecificException e) { } catch (RemoteException | ServiceSpecificException e) {
Slog.e(TAG, "Error setting NAT64 prefix on netId " + getNetId() + " to " Log.e(TAG, "Error setting NAT64 prefix on netId " + getNetId() + " to "
+ prefix + ": " + e); + prefix + ": " + e);
} }
} }
@@ -328,7 +328,7 @@ public class Nat464Xlat extends BaseNetworkObserver {
private void maybeHandleNat64PrefixChange() { private void maybeHandleNat64PrefixChange() {
final IpPrefix newPrefix = selectNat64Prefix(); final IpPrefix newPrefix = selectNat64Prefix();
if (!Objects.equals(mNat64PrefixInUse, newPrefix)) { if (!Objects.equals(mNat64PrefixInUse, newPrefix)) {
Slog.d(TAG, "NAT64 prefix changed from " + mNat64PrefixInUse + " to " Log.d(TAG, "NAT64 prefix changed from " + mNat64PrefixInUse + " to "
+ newPrefix); + newPrefix);
stop(); stop();
// It's safe to call update here, even though this method is called from update, because // It's safe to call update here, even though this method is called from update, because
@@ -418,7 +418,7 @@ public class Nat464Xlat extends BaseNetworkObserver {
return; return;
} }
Slog.d(TAG, "clatd running, updating NAI for " + mIface); Log.d(TAG, "clatd running, updating NAI for " + mIface);
for (LinkProperties stacked: oldLp.getStackedLinks()) { for (LinkProperties stacked: oldLp.getStackedLinks()) {
if (Objects.equals(mIface, stacked.getInterfaceName())) { if (Objects.equals(mIface, stacked.getInterfaceName())) {
lp.addStackedLink(stacked); lp.addStackedLink(stacked);
@@ -451,7 +451,7 @@ public class Nat464Xlat extends BaseNetworkObserver {
return new LinkAddress( return new LinkAddress(
InetAddresses.parseNumericAddress(config.ipv4Addr), config.prefixLength); InetAddresses.parseNumericAddress(config.ipv4Addr), config.prefixLength);
} catch (IllegalArgumentException | RemoteException | ServiceSpecificException e) { } catch (IllegalArgumentException | RemoteException | ServiceSpecificException e) {
Slog.e(TAG, "Error getting link properties: " + e); Log.e(TAG, "Error getting link properties: " + e);
return null; return null;
} }
} }
@@ -480,11 +480,11 @@ public class Nat464Xlat extends BaseNetworkObserver {
LinkAddress clatAddress = getLinkAddress(iface); LinkAddress clatAddress = getLinkAddress(iface);
if (clatAddress == null) { if (clatAddress == null) {
Slog.e(TAG, "clatAddress was null for stacked iface " + iface); Log.e(TAG, "clatAddress was null for stacked iface " + iface);
return; return;
} }
Slog.i(TAG, String.format("interface %s is up, adding stacked link %s on top of %s", Log.i(TAG, String.format("interface %s is up, adding stacked link %s on top of %s",
mIface, mIface, mBaseIface)); mIface, mIface, mBaseIface));
enterRunningState(); enterRunningState();
LinkProperties lp = new LinkProperties(mNetwork.linkProperties); LinkProperties lp = new LinkProperties(mNetwork.linkProperties);
@@ -503,7 +503,7 @@ public class Nat464Xlat extends BaseNetworkObserver {
return; return;
} }
Slog.i(TAG, "interface " + iface + " removed"); Log.i(TAG, "interface " + iface + " removed");
// If we're running, and the interface was removed, then we didn't call stop(), and it's // If we're running, and the interface was removed, then we didn't call stop(), and it's
// likely that clatd crashed. Ensure we call stop() so we can start clatd again. Calling // likely that clatd crashed. Ensure we call stop() so we can start clatd again. Calling
// stop() will also update LinkProperties, and if clatd crashed, the LinkProperties update // stop() will also update LinkProperties, and if clatd crashed, the LinkProperties update

View File

@@ -35,7 +35,7 @@ import android.os.UserHandle;
import android.telephony.SubscriptionManager; import android.telephony.SubscriptionManager;
import android.telephony.TelephonyManager; import android.telephony.TelephonyManager;
import android.text.TextUtils; import android.text.TextUtils;
import android.util.Slog; import android.util.Log;
import android.util.SparseArray; import android.util.SparseArray;
import android.util.SparseIntArray; import android.util.SparseIntArray;
import android.widget.Toast; import android.widget.Toast;
@@ -175,7 +175,7 @@ public class NetworkNotificationManager {
final int previousEventId = mNotificationTypeMap.get(id); final int previousEventId = mNotificationTypeMap.get(id);
final NotificationType previousNotifyType = NotificationType.getFromId(previousEventId); final NotificationType previousNotifyType = NotificationType.getFromId(previousEventId);
if (priority(previousNotifyType) > priority(notifyType)) { if (priority(previousNotifyType) > priority(notifyType)) {
Slog.d(TAG, String.format( Log.d(TAG, String.format(
"ignoring notification %s for network %s with existing notification %s", "ignoring notification %s for network %s with existing notification %s",
notifyType, id, previousNotifyType)); notifyType, id, previousNotifyType));
return; return;
@@ -183,7 +183,7 @@ public class NetworkNotificationManager {
clearNotification(id); clearNotification(id);
if (DBG) { if (DBG) {
Slog.d(TAG, String.format( Log.d(TAG, String.format(
"showNotification tag=%s event=%s transport=%s name=%s highPriority=%s", "showNotification tag=%s event=%s transport=%s name=%s highPriority=%s",
tag, nameOf(eventId), getTransportName(transportType), name, highPriority)); tag, nameOf(eventId), getTransportName(transportType), name, highPriority));
} }
@@ -253,7 +253,7 @@ public class NetworkNotificationManager {
// are sent, but they are not implemented yet. // are sent, but they are not implemented yet.
return; return;
} else { } else {
Slog.wtf(TAG, "Unknown notification type " + notifyType + " on network transport " Log.wtf(TAG, "Unknown notification type " + notifyType + " on network transport "
+ getTransportName(transportType)); + getTransportName(transportType));
return; return;
} }
@@ -294,7 +294,7 @@ public class NetworkNotificationManager {
try { try {
mNotificationManager.notify(tag, eventId, notification); mNotificationManager.notify(tag, eventId, notification);
} catch (NullPointerException npe) { } catch (NullPointerException npe) {
Slog.d(TAG, "setNotificationVisible: visible notificationManager error", npe); Log.d(TAG, "setNotificationVisible: visible notificationManager error", npe);
} }
} }
@@ -317,13 +317,13 @@ public class NetworkNotificationManager {
final String tag = tagFor(id); final String tag = tagFor(id);
final int eventId = mNotificationTypeMap.get(id); final int eventId = mNotificationTypeMap.get(id);
if (DBG) { if (DBG) {
Slog.d(TAG, String.format("clearing notification tag=%s event=%s", tag, Log.d(TAG, String.format("clearing notification tag=%s event=%s", tag,
nameOf(eventId))); nameOf(eventId)));
} }
try { try {
mNotificationManager.cancel(tag, eventId); mNotificationManager.cancel(tag, eventId);
} catch (NullPointerException npe) { } catch (NullPointerException npe) {
Slog.d(TAG, String.format( Log.d(TAG, String.format(
"failed to clear notification tag=%s event=%s", tag, nameOf(eventId)), npe); "failed to clear notification tag=%s event=%s", tag, nameOf(eventId)), npe);
} }
mNotificationTypeMap.delete(id); mNotificationTypeMap.delete(id);

View File

@@ -35,7 +35,7 @@ import android.os.Handler;
import android.os.UserHandle; import android.os.UserHandle;
import android.provider.Settings; import android.provider.Settings;
import android.text.TextUtils; import android.text.TextUtils;
import android.util.Slog; import android.util.Log;
import com.android.internal.annotations.GuardedBy; import com.android.internal.annotations.GuardedBy;
@@ -168,7 +168,7 @@ public class ProxyTracker {
proxyProperties = new ProxyInfo(host, port, exclList); proxyProperties = new ProxyInfo(host, port, exclList);
} }
if (!proxyProperties.isValid()) { if (!proxyProperties.isValid()) {
if (DBG) Slog.d(TAG, "Invalid proxy properties, ignoring: " + proxyProperties); if (DBG) Log.d(TAG, "Invalid proxy properties, ignoring: " + proxyProperties);
return; return;
} }
@@ -223,7 +223,7 @@ public class ProxyTracker {
if (mPacManager.setCurrentProxyScriptUrl(proxyInfo) == PacManager.DONT_SEND_BROADCAST) { if (mPacManager.setCurrentProxyScriptUrl(proxyInfo) == PacManager.DONT_SEND_BROADCAST) {
return; return;
} }
if (DBG) Slog.d(TAG, "sending Proxy Broadcast for " + proxyInfo); if (DBG) Log.d(TAG, "sending Proxy Broadcast for " + proxyInfo);
Intent intent = new Intent(Proxy.PROXY_CHANGE_ACTION); Intent intent = new Intent(Proxy.PROXY_CHANGE_ACTION);
intent.addFlags(Intent.FLAG_RECEIVER_REPLACE_PENDING | intent.addFlags(Intent.FLAG_RECEIVER_REPLACE_PENDING |
Intent.FLAG_RECEIVER_REGISTERED_ONLY_BEFORE_BOOT); Intent.FLAG_RECEIVER_REGISTERED_ONLY_BEFORE_BOOT);
@@ -255,7 +255,7 @@ public class ProxyTracker {
if (proxyInfo != null && (!TextUtils.isEmpty(proxyInfo.getHost()) || if (proxyInfo != null && (!TextUtils.isEmpty(proxyInfo.getHost()) ||
!Uri.EMPTY.equals(proxyInfo.getPacFileUrl()))) { !Uri.EMPTY.equals(proxyInfo.getPacFileUrl()))) {
if (!proxyInfo.isValid()) { if (!proxyInfo.isValid()) {
if (DBG) Slog.d(TAG, "Invalid proxy properties, ignoring: " + proxyInfo); if (DBG) Log.d(TAG, "Invalid proxy properties, ignoring: " + proxyInfo);
return; return;
} }
mGlobalProxy = new ProxyInfo(proxyInfo); mGlobalProxy = new ProxyInfo(proxyInfo);
@@ -296,7 +296,7 @@ public class ProxyTracker {
synchronized (mProxyLock) { synchronized (mProxyLock) {
if (Objects.equals(mDefaultProxy, proxyInfo)) return; if (Objects.equals(mDefaultProxy, proxyInfo)) return;
if (proxyInfo != null && !proxyInfo.isValid()) { if (proxyInfo != null && !proxyInfo.isValid()) {
if (DBG) Slog.d(TAG, "Invalid proxy properties, ignoring: " + proxyInfo); if (DBG) Log.d(TAG, "Invalid proxy properties, ignoring: " + proxyInfo);
return; return;
} }