Merge "Some cleanups for Tethering"
diff --git a/core/java/android/net/ConnectivityManager.java b/core/java/android/net/ConnectivityManager.java
index 6ba4a30..2906710 100644
--- a/core/java/android/net/ConnectivityManager.java
+++ b/core/java/android/net/ConnectivityManager.java
@@ -2617,7 +2617,7 @@
/**
* Start listening to tethering change events. Any new added callback will receive the last
- * tethering status right away. If callback is registered when tethering loses its upstream or
+ * tethering status right away. If callback is registered when tethering has no upstream or
* disabled, {@link OnTetheringEventCallback#onUpstreamChanged} will immediately be called
* with a null argument. The same callback object cannot be registered twice.
*
diff --git a/services/core/java/com/android/server/connectivity/tethering/EntitlementManager.java b/services/core/java/com/android/server/connectivity/tethering/EntitlementManager.java
index 764a6eb..b0bbd72 100644
--- a/services/core/java/com/android/server/connectivity/tethering/EntitlementManager.java
+++ b/services/core/java/com/android/server/connectivity/tethering/EntitlementManager.java
@@ -52,7 +52,6 @@
import android.provider.Settings;
import android.telephony.CarrierConfigManager;
import android.util.ArraySet;
-import android.util.Log;
import android.util.SparseIntArray;
import com.android.internal.annotations.VisibleForTesting;
@@ -231,7 +230,7 @@
private void handleNotifyUpstream(boolean isCellular) {
if (DBG) {
- Log.d(TAG, "notifyUpstream: " + isCellular
+ mLog.i("notifyUpstream: " + isCellular
+ ", mCellularUpstreamPermitted: " + mCellularUpstreamPermitted
+ ", mNeedReRunProvisioningUi: " + mNeedReRunProvisioningUi);
}
@@ -294,7 +293,7 @@
* masterHandler to avoid race conditions.
*/
public void reevaluateSimCardProvisioning() {
- if (DBG) Log.d(TAG, "reevaluateSimCardProvisioning");
+ if (DBG) mLog.i("reevaluateSimCardProvisioning");
if (!mHandler.getLooper().isCurrentThread()) {
// Except for test, this log should not appear in normal flow.
@@ -351,7 +350,7 @@
* @param type tethering type from ConnectivityManager.TETHERING_{@code *}
*/
protected void runSilentTetherProvisioning(int type) {
- if (DBG) Log.d(TAG, "runSilentTetherProvisioning: " + type);
+ if (DBG) mLog.i("runSilentTetherProvisioning: " + type);
// For silent provisioning, settings would stop tethering when entitlement fail.
ResultReceiver receiver = buildProxyReceiver(type,
false/* notifyFail */, null);
@@ -382,7 +381,7 @@
@VisibleForTesting
protected void runUiTetherProvisioning(int type, ResultReceiver receiver) {
- if (DBG) Log.d(TAG, "runUiTetherProvisioning: " + type);
+ if (DBG) mLog.i("runUiTetherProvisioning: " + type);
Intent intent = new Intent(Settings.ACTION_TETHER_PROVISIONING);
intent.putExtra(EXTRA_ADD_TETHER_TYPE, type);
@@ -428,7 +427,7 @@
|| mCellularPermitted.indexOfValue(TETHER_ERROR_NO_ERROR) > -1);
if (DBG) {
- Log.d(TAG, "Cellular permission change from " + oldPermitted
+ mLog.i("Cellular permission change from " + oldPermitted
+ " to " + mCellularUpstreamPermitted);
}
@@ -453,10 +452,8 @@
* @param resultCode Provisioning result
*/
protected void addDownstreamMapping(int type, int resultCode) {
- if (DBG) {
- Log.d(TAG, "addDownstreamMapping: " + type + ", result: " + resultCode
- + " ,TetherTypeRequested: " + mCurrentTethers.contains(type));
- }
+ mLog.i("addDownstreamMapping: " + type + ", result: " + resultCode
+ + " ,TetherTypeRequested: " + mCurrentTethers.contains(type));
if (!mCurrentTethers.contains(type)) return;
mCellularPermitted.put(type, resultCode);
@@ -468,7 +465,7 @@
* @param type tethering type from ConnectivityManager.TETHERING_{@code *}
*/
protected void removeDownstreamMapping(int type) {
- if (DBG) Log.d(TAG, "removeDownstreamMapping: " + type);
+ mLog.i("removeDownstreamMapping: " + type);
mCellularPermitted.delete(type);
evaluateCellularPermission();
}
@@ -617,7 +614,7 @@
*/
private int updateEntitlementCacheValue(int type, int resultCode) {
if (DBG) {
- Log.d(TAG, "updateEntitlementCacheValue: " + type + ", result: " + resultCode);
+ mLog.i("updateEntitlementCacheValue: " + type + ", result: " + resultCode);
}
if (resultCode == TETHER_ERROR_NO_ERROR) {
mEntitlementCacheValue.put(type, resultCode);
diff --git a/tests/net/java/com/android/server/connectivity/tethering/TetheringConfigurationTest.java b/tests/net/java/com/android/server/connectivity/tethering/TetheringConfigurationTest.java
index 36a1b7c..2140322 100644
--- a/tests/net/java/com/android/server/connectivity/tethering/TetheringConfigurationTest.java
+++ b/tests/net/java/com/android/server/connectivity/tethering/TetheringConfigurationTest.java
@@ -122,7 +122,7 @@
mMockContext = new MockContext(mContext);
}
- private TetheringConfiguration getTetheringConfiguration(int[] legacyTetherUpstreamTypes) {
+ private TetheringConfiguration getTetheringConfiguration(int... legacyTetherUpstreamTypes) {
when(mResources.getIntArray(config_tether_upstream_types)).thenReturn(
legacyTetherUpstreamTypes);
return new TetheringConfiguration(mMockContext, mLog, INVALID_SUBSCRIPTION_ID);
@@ -143,13 +143,13 @@
public void testDunFromTelephonyManagerMeansDun() {
when(mTelephonyManager.getTetherApnRequired()).thenReturn(true);
- final TetheringConfiguration cfgWifi = getTetheringConfiguration(new int[]{TYPE_WIFI});
+ final TetheringConfiguration cfgWifi = getTetheringConfiguration(TYPE_WIFI);
final TetheringConfiguration cfgMobileWifiHipri = getTetheringConfiguration(
- new int[]{TYPE_MOBILE, TYPE_WIFI, TYPE_MOBILE_HIPRI});
+ TYPE_MOBILE, TYPE_WIFI, TYPE_MOBILE_HIPRI);
final TetheringConfiguration cfgWifiDun = getTetheringConfiguration(
- new int[]{TYPE_WIFI, TYPE_MOBILE_DUN});
+ TYPE_WIFI, TYPE_MOBILE_DUN);
final TetheringConfiguration cfgMobileWifiHipriDun = getTetheringConfiguration(
- new int[]{TYPE_MOBILE, TYPE_WIFI, TYPE_MOBILE_HIPRI, TYPE_MOBILE_DUN});
+ TYPE_MOBILE, TYPE_WIFI, TYPE_MOBILE_HIPRI, TYPE_MOBILE_DUN);
for (TetheringConfiguration cfg : Arrays.asList(cfgWifi, cfgMobileWifiHipri,
cfgWifiDun, cfgMobileWifiHipriDun)) {
@@ -167,20 +167,20 @@
public void testDunNotRequiredFromTelephonyManagerMeansNoDun() {
when(mTelephonyManager.getTetherApnRequired()).thenReturn(false);
- final TetheringConfiguration cfgWifi = getTetheringConfiguration(new int[]{TYPE_WIFI});
+ final TetheringConfiguration cfgWifi = getTetheringConfiguration(TYPE_WIFI);
final TetheringConfiguration cfgMobileWifiHipri = getTetheringConfiguration(
- new int[]{TYPE_MOBILE, TYPE_WIFI, TYPE_MOBILE_HIPRI});
+ TYPE_MOBILE, TYPE_WIFI, TYPE_MOBILE_HIPRI);
final TetheringConfiguration cfgWifiDun = getTetheringConfiguration(
- new int[]{TYPE_WIFI, TYPE_MOBILE_DUN});
+ TYPE_WIFI, TYPE_MOBILE_DUN);
final TetheringConfiguration cfgWifiMobile = getTetheringConfiguration(
- new int[]{TYPE_WIFI, TYPE_MOBILE});
+ TYPE_WIFI, TYPE_MOBILE);
final TetheringConfiguration cfgWifiHipri = getTetheringConfiguration(
- new int[]{TYPE_WIFI, TYPE_MOBILE_HIPRI});
+ TYPE_WIFI, TYPE_MOBILE_HIPRI);
final TetheringConfiguration cfgMobileWifiHipriDun = getTetheringConfiguration(
- new int[]{TYPE_MOBILE, TYPE_WIFI, TYPE_MOBILE_HIPRI, TYPE_MOBILE_DUN});
+ TYPE_MOBILE, TYPE_WIFI, TYPE_MOBILE_HIPRI, TYPE_MOBILE_DUN);
String msg;
- // TYPE_MOBILE_DUN should not be present in all of the combinations.
+ // TYPE_MOBILE_DUN should be present in none of the combinations.
// TYPE_WIFI should not be affected.
for (TetheringConfiguration cfg : Arrays.asList(cfgWifi, cfgMobileWifiHipri, cfgWifiDun,
cfgWifiMobile, cfgWifiHipri, cfgMobileWifiHipriDun)) {