summaryrefslogtreecommitdiff
path: root/service
diff options
context:
space:
mode:
authorRoshan Pius <rpius@google.com>2017-06-20 16:19:19 -0700
committerRoshan Pius <rpius@google.com>2017-07-07 14:23:49 -0700
commitce1de180e7652e2b2313b401451ca3d9d027b372 (patch)
tree42007c5f827f8a7610999a2eb32e026638b9b281 /service
parent61ad35a3ee80c0602bb6d4bfc20e49177aca8a9a (diff)
WifiStateMachine: Increment startup failure metrics
Increment the metrics for wifi native start failure reasons. WifiNative.setupForClientMode() and WifiNative.setupForSoftApMode() have been modified to return the reason for failure. WifiStateMachine can now use these reason codes to increment the corresponding metrics. Bug: 38457087 Test: Unit tests Change-Id: I94c4283bac1566c1edd3985d96e6f39b7dd56910
Diffstat (limited to 'service')
-rw-r--r--service/java/com/android/server/wifi/WifiNative.java32
-rw-r--r--service/java/com/android/server/wifi/WifiStateMachine.java28
2 files changed, 48 insertions, 12 deletions
diff --git a/service/java/com/android/server/wifi/WifiNative.java b/service/java/com/android/server/wifi/WifiNative.java
index aca32bc31..20c9bad26 100644
--- a/service/java/com/android/server/wifi/WifiNative.java
+++ b/service/java/com/android/server/wifi/WifiNative.java
@@ -29,6 +29,7 @@ import android.net.wifi.WifiScanner;
import android.net.wifi.WifiWakeReasonAndCounts;
import android.os.SystemClock;
import android.util.Log;
+import android.util.Pair;
import android.util.SparseArray;
import com.android.internal.annotations.Immutable;
@@ -90,6 +91,9 @@ public class WifiNative {
/********************************************************
* Native Initialization/Deinitialization
********************************************************/
+ public static final int SETUP_SUCCESS = 0;
+ public static final int SETUP_FAILURE_HAL = 1;
+ public static final int SETUP_FAILURE_WIFICOND = 2;
/**
* Setup wifi native for Client mode operations.
@@ -98,15 +102,19 @@ public class WifiNative {
* 2. Setup Wificond to operate in client mode and retrieve the handle to use for client
* operations.
*
- * @return An IClientInterface as wificond client interface binder handler.
- * Returns null on failure.
+ * @return Pair of <Integer, IClientInterface> to indicate the status and the associated wificond
+ * client interface binder handler (will be null on failure).
*/
- public IClientInterface setupForClientMode() {
+ public Pair<Integer, IClientInterface> setupForClientMode() {
if (!startHalIfNecessary(true)) {
Log.e(mTAG, "Failed to start HAL for client mode");
- return null;
+ return Pair.create(SETUP_FAILURE_HAL, null);
+ }
+ IClientInterface iClientInterface = mWificondControl.setupDriverForClientMode();
+ if (iClientInterface == null) {
+ return Pair.create(SETUP_FAILURE_WIFICOND, null);
}
- return mWificondControl.setupDriverForClientMode();
+ return Pair.create(SETUP_SUCCESS, iClientInterface);
}
/**
@@ -115,15 +123,19 @@ public class WifiNative {
* 1. Starts the Wifi HAL and configures it in AP mode.
* 2. Setup Wificond to operate in AP mode and retrieve the handle to use for ap operations.
*
- * @return An IApInterface as wificond Ap interface binder handler.
- * Returns null on failure.
+ * @return Pair of <Integer, IApInterface> to indicate the status and the associated wificond
+ * AP interface binder handler (will be null on failure).
*/
- public IApInterface setupForSoftApMode() {
+ public Pair<Integer, IApInterface> setupForSoftApMode() {
if (!startHalIfNecessary(false)) {
Log.e(mTAG, "Failed to start HAL for AP mode");
- return null;
+ return Pair.create(SETUP_FAILURE_HAL, null);
+ }
+ IApInterface iApInterface = mWificondControl.setupDriverForSoftApMode();
+ if (iApInterface == null) {
+ return Pair.create(SETUP_FAILURE_WIFICOND, null);
}
- return mWificondControl.setupDriverForSoftApMode();
+ return Pair.create(SETUP_SUCCESS, iApInterface);
}
/**
diff --git a/service/java/com/android/server/wifi/WifiStateMachine.java b/service/java/com/android/server/wifi/WifiStateMachine.java
index 0fb61df17..3b6ff817c 100644
--- a/service/java/com/android/server/wifi/WifiStateMachine.java
+++ b/service/java/com/android/server/wifi/WifiStateMachine.java
@@ -96,6 +96,7 @@ import android.provider.Settings;
import android.telephony.TelephonyManager;
import android.text.TextUtils;
import android.util.Log;
+import android.util.Pair;
import android.util.SparseArray;
import com.android.internal.R;
@@ -3721,6 +3722,17 @@ public class WifiStateMachine extends StateMachine implements WifiNative.WifiRss
}
}
+ /**
+ * Helper function to increment the appropriate setup failure metrics.
+ */
+ private void incrementMetricsForSetupFailure(int failureReason) {
+ if (failureReason == WifiNative.SETUP_FAILURE_HAL) {
+ mWifiMetrics.incrementNumWifiOnFailureDueToHal();
+ } else if (failureReason == WifiNative.SETUP_FAILURE_WIFICOND) {
+ mWifiMetrics.incrementNumWifiOnFailureDueToWificond();
+ }
+ }
+
/********************************************************
* HSM states
*******************************************************/
@@ -4075,7 +4087,13 @@ public class WifiStateMachine extends StateMachine implements WifiNative.WifiRss
logStateAndMessage(message, this);
switch (message.what) {
case CMD_START_SUPPLICANT:
- mClientInterface = mWifiNative.setupForClientMode();
+ Pair<Integer, IClientInterface> statusAndInterface =
+ mWifiNative.setupForClientMode();
+ if (statusAndInterface.first == WifiNative.SETUP_SUCCESS) {
+ mClientInterface = statusAndInterface.second;
+ } else {
+ incrementMetricsForSetupFailure(statusAndInterface.first);
+ }
if (mClientInterface == null
|| !mDeathRecipient.linkToDeath(mClientInterface.asBinder())) {
setWifiState(WifiManager.WIFI_STATE_UNKNOWN);
@@ -6772,7 +6790,13 @@ public class WifiStateMachine extends StateMachine implements WifiNative.WifiRss
SoftApModeConfiguration config = (SoftApModeConfiguration) message.obj;
mMode = config.getTargetMode();
- IApInterface apInterface = mWifiNative.setupForSoftApMode();
+ IApInterface apInterface = null;
+ Pair<Integer, IApInterface> statusAndInterface = mWifiNative.setupForSoftApMode();
+ if (statusAndInterface.first == WifiNative.SETUP_SUCCESS) {
+ apInterface = statusAndInterface.second;
+ } else {
+ incrementMetricsForSetupFailure(statusAndInterface.first);
+ }
if (apInterface == null) {
setWifiApState(WIFI_AP_STATE_FAILED,
WifiManager.SAP_START_FAILURE_GENERAL, null, mMode);