summaryrefslogtreecommitdiff
path: root/service
diff options
context:
space:
mode:
authorAhmed ElArabawy <arabawy@google.com>2020-05-31 13:20:35 +0000
committerAndroid (Google) Code Review <android-gerrit@google.com>2020-05-31 13:20:35 +0000
commit3bd823f2ca68e508a8d406a85cdc46e2d905a7e1 (patch)
treede08b0786dfed400eef75fb8d1554d341b03b0b4 /service
parent7c8441932eae9212fae6157d3ca07b480254cee1 (diff)
parent36ed29992b28fe9e313ec2818dae1b8c7d626f32 (diff)
Merge "Handle failure in softAp start gracefully" into rvc-dev
Diffstat (limited to 'service')
-rw-r--r--service/java/com/android/server/wifi/WifiServiceImpl.java43
1 files changed, 30 insertions, 13 deletions
diff --git a/service/java/com/android/server/wifi/WifiServiceImpl.java b/service/java/com/android/server/wifi/WifiServiceImpl.java
index 0772b4c80..9d12aa000 100644
--- a/service/java/com/android/server/wifi/WifiServiceImpl.java
+++ b/service/java/com/android/server/wifi/WifiServiceImpl.java
@@ -879,6 +879,14 @@ public class WifiServiceImpl extends BaseWifiService {
mLog.info("startSoftAp uid=%").c(Binder.getCallingUid()).flush();
+ SoftApConfiguration softApConfig = null;
+ if (wifiConfig != null) {
+ softApConfig = ApConfigUtil.fromWifiConfiguration(wifiConfig);
+ if (softApConfig == null) {
+ return false;
+ }
+ }
+
if (!mTetheredSoftApTracker.setEnablingIfAllowed()) {
mLog.err("Tethering is already active.").flush();
return false;
@@ -890,17 +898,14 @@ public class WifiServiceImpl extends BaseWifiService {
mLohsSoftApTracker.stopAll();
}
- if (wifiConfig != null) {
- SoftApConfiguration softApConfig = ApConfigUtil.fromWifiConfiguration(wifiConfig);
- if (softApConfig == null) return false;
- return startSoftApInternal(new SoftApModeConfiguration(
- WifiManager.IFACE_IP_MODE_TETHERED,
- softApConfig, mTetheredSoftApTracker.getSoftApCapability()));
- } else {
- return startSoftApInternal(new SoftApModeConfiguration(
- WifiManager.IFACE_IP_MODE_TETHERED, null,
- mTetheredSoftApTracker.getSoftApCapability()));
+ if (!startSoftApInternal(new SoftApModeConfiguration(
+ WifiManager.IFACE_IP_MODE_TETHERED, softApConfig,
+ mTetheredSoftApTracker.getSoftApCapability()))) {
+ mTetheredSoftApTracker.setFailedWhileEnabling();
+ return false;
}
+
+ return true;
}
private boolean validateSoftApBand(int apBand) {
@@ -951,11 +956,15 @@ public class WifiServiceImpl extends BaseWifiService {
mLohsSoftApTracker.stopAll();
}
- return startSoftApInternal(new SoftApModeConfiguration(
+ if (!startSoftApInternal(new SoftApModeConfiguration(
WifiManager.IFACE_IP_MODE_TETHERED, softApConfig,
- mTetheredSoftApTracker.getSoftApCapability()));
- }
+ mTetheredSoftApTracker.getSoftApCapability()))) {
+ mTetheredSoftApTracker.setFailedWhileEnabling();
+ return false;
+ }
+ return true;
+ }
/**
* Internal method to start softap mode. Callers of this method should have already checked
@@ -1053,6 +1062,14 @@ public class WifiServiceImpl extends BaseWifiService {
}
}
+ public void setFailedWhileEnabling() {
+ synchronized (mLock) {
+ if (mTetheredSoftApState == WIFI_AP_STATE_ENABLING) {
+ mTetheredSoftApState = WIFI_AP_STATE_FAILED;
+ }
+ }
+ }
+
public List<WifiClient> getConnectedClients() {
synchronized (mLock) {
return mTetheredSoftApConnectedClients;