Merge "Don't crash Tethering service when WiFi feature is missing" am: 736f8ec55a am: 5278b64768
Original change: https://android-review.googlesource.com/c/platform/packages/modules/Connectivity/+/1577289 MUST ONLY BE SUBMITTED BY AUTOMERGER Change-Id: Ice05e20436c5bab99e72f61179df055c657cc248
This commit is contained in:
@@ -1689,12 +1689,14 @@ public class Tethering {
|
|||||||
// If this is a Wi-Fi interface, tell WifiManager of any errors
|
// If this is a Wi-Fi interface, tell WifiManager of any errors
|
||||||
// or the inactive serving state.
|
// or the inactive serving state.
|
||||||
if (who.interfaceType() == TETHERING_WIFI) {
|
if (who.interfaceType() == TETHERING_WIFI) {
|
||||||
if (who.lastError() != TETHER_ERROR_NO_ERROR) {
|
final WifiManager mgr = getWifiManager();
|
||||||
getWifiManager().updateInterfaceIpState(
|
final String iface = who.interfaceName();
|
||||||
who.interfaceName(), IFACE_IP_MODE_CONFIGURATION_ERROR);
|
if (mgr == null) {
|
||||||
|
Log.wtf(TAG, "Skipping WifiManager notification about inactive tethering");
|
||||||
|
} else if (who.lastError() != TETHER_ERROR_NO_ERROR) {
|
||||||
|
mgr.updateInterfaceIpState(iface, IFACE_IP_MODE_CONFIGURATION_ERROR);
|
||||||
} else {
|
} else {
|
||||||
getWifiManager().updateInterfaceIpState(
|
mgr.updateInterfaceIpState(iface, IFACE_IP_MODE_UNSPECIFIED);
|
||||||
who.interfaceName(), IFACE_IP_MODE_UNSPECIFIED);
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -2421,6 +2423,19 @@ public class Tethering {
|
|||||||
mLog.log(iface + " is not a tetherable iface, ignoring");
|
mLog.log(iface + " is not a tetherable iface, ignoring");
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
final PackageManager pm = mContext.getPackageManager();
|
||||||
|
if ((interfaceType == TETHERING_WIFI || interfaceType == TETHERING_WIGIG)
|
||||||
|
&& !pm.hasSystemFeature(PackageManager.FEATURE_WIFI)) {
|
||||||
|
mLog.log(iface + " is not tetherable, because WiFi feature is disabled");
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
if (interfaceType == TETHERING_WIFI_P2P
|
||||||
|
&& !pm.hasSystemFeature(PackageManager.FEATURE_WIFI_DIRECT)) {
|
||||||
|
mLog.log(iface + " is not tetherable, because WiFi Direct feature is disabled");
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
maybeTrackNewInterfaceLocked(iface, interfaceType);
|
maybeTrackNewInterfaceLocked(iface, interfaceType);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -586,6 +586,9 @@ public class TetheringTest {
|
|||||||
ArgumentCaptor.forClass(SoftApCallback.class);
|
ArgumentCaptor.forClass(SoftApCallback.class);
|
||||||
verify(mWifiManager).registerSoftApCallback(any(), softApCallbackCaptor.capture());
|
verify(mWifiManager).registerSoftApCallback(any(), softApCallbackCaptor.capture());
|
||||||
mSoftApCallback = softApCallbackCaptor.getValue();
|
mSoftApCallback = softApCallbackCaptor.getValue();
|
||||||
|
|
||||||
|
when(mPackageManager.hasSystemFeature(PackageManager.FEATURE_WIFI)).thenReturn(true);
|
||||||
|
when(mPackageManager.hasSystemFeature(PackageManager.FEATURE_WIFI_DIRECT)).thenReturn(true);
|
||||||
}
|
}
|
||||||
|
|
||||||
private void setTetheringSupported(final boolean supported) {
|
private void setTetheringSupported(final boolean supported) {
|
||||||
|
|||||||
Reference in New Issue
Block a user