diff options
author | lesl <lesl@google.com> | 2020-03-23 14:34:11 +0800 |
---|---|---|
committer | lesl <lesl@google.com> | 2020-03-24 15:35:29 +0800 |
commit | 1a0feaa49bb5c7c6145e0ee52a9a5a6ed734e3ba (patch) | |
tree | 316b59cb8f71442f67cdffd09db61a06aaa0e4cb /service | |
parent | 44f8e09fa0da59aa5d9519715635b9ec9af69e48 (diff) |
wifi: Add Softap configuration/capability metric
Bug: 152168936
Test: atest frameworks/opt/net/wifi/tests/wifitests/
Change-Id: I080cc86676181ba3e9a94e4f24ba3faca1925ea2
Diffstat (limited to 'service')
-rw-r--r-- | service/java/com/android/server/wifi/SoftApManager.java | 24 | ||||
-rw-r--r-- | service/java/com/android/server/wifi/WifiMetrics.java | 95 | ||||
-rw-r--r-- | service/proto/src/metrics.proto | 18 |
3 files changed, 132 insertions, 5 deletions
diff --git a/service/java/com/android/server/wifi/SoftApManager.java b/service/java/com/android/server/wifi/SoftApManager.java index 745214539..20d462bf7 100644 --- a/service/java/com/android/server/wifi/SoftApManager.java +++ b/service/java/com/android/server/wifi/SoftApManager.java @@ -114,6 +114,8 @@ public class SoftApManager implements ActiveModeManager { private String mStartTimestamp; + private long mDefaultShutDownTimeoutMills; + private static final SimpleDateFormat FORMATTER = new SimpleDateFormat("MM-dd HH:mm:ss.SSS"); private BaseWifiDiagnostics mWifiDiagnostics; @@ -196,6 +198,8 @@ public class SoftApManager implements ActiveModeManager { mAllowedClientList = new HashSet<>(softApConfig.getAllowedClientList()); mTimeoutEnabled = softApConfig.isAutoShutdownEnabled(); } + mDefaultShutDownTimeoutMills = mContext.getResources().getInteger( + R.integer.config_wifiFrameworkSoftApShutDownTimeoutMilliseconds); } /** @@ -602,8 +606,7 @@ public class SoftApManager implements ActiveModeManager { } long timeout = mApConfig.getSoftApConfiguration().getShutdownTimeoutMillis(); if (timeout == 0) { - timeout = mContext.getResources().getInteger( - R.integer.config_wifiFrameworkSoftApShutDownTimeoutMilliseconds); + timeout = mDefaultShutDownTimeoutMills; } mSoftApTimeoutMessage.schedule(SystemClock.elapsedRealtime() + timeout); @@ -756,7 +759,14 @@ public class SoftApManager implements ActiveModeManager { // the interface was up, but goes down sendMessage(CMD_INTERFACE_DOWN); } - mWifiMetrics.addSoftApUpChangedEvent(isUp, mApConfig.getTargetMode()); + mWifiMetrics.addSoftApUpChangedEvent(isUp, mApConfig.getTargetMode(), + mDefaultShutDownTimeoutMills); + if (isUp) { + mWifiMetrics.updateSoftApConfiguration(mApConfig.getSoftApConfiguration(), + mApConfig.getTargetMode()); + mWifiMetrics.updateSoftApCapability(mCurrentSoftApCapability, + mApConfig.getTargetMode()); + } } @Override @@ -796,7 +806,8 @@ public class SoftApManager implements ActiveModeManager { // Need this here since we are exiting |Started| state and won't handle any // future CMD_INTERFACE_STATUS_CHANGED events after this point - mWifiMetrics.addSoftApUpChangedEvent(false, mApConfig.getTargetMode()); + mWifiMetrics.addSoftApUpChangedEvent(false, mApConfig.getTargetMode(), + mDefaultShutDownTimeoutMills); updateApState(WifiManager.WIFI_AP_STATE_DISABLED, WifiManager.WIFI_AP_STATE_DISABLING, 0); @@ -904,6 +915,8 @@ public class SoftApManager implements ActiveModeManager { if (mApConfig.getTargetMode() == WifiManager.IFACE_IP_MODE_TETHERED) { SoftApCapability capability = (SoftApCapability) message.obj; mCurrentSoftApCapability = new SoftApCapability(capability); + mWifiMetrics.updateSoftApCapability(mCurrentSoftApCapability, + mApConfig.getTargetMode()); updateClientConnection(); } break; @@ -933,6 +946,9 @@ public class SoftApManager implements ActiveModeManager { cancelTimeoutMessage(); scheduleTimeoutMessage(); } + mWifiMetrics.updateSoftApConfiguration( + mApConfig.getSoftApConfiguration(), + mApConfig.getTargetMode()); } else { Log.d(TAG, "Ignore the config: " + newConfig + " update since it requires restart"); diff --git a/service/java/com/android/server/wifi/WifiMetrics.java b/service/java/com/android/server/wifi/WifiMetrics.java index 8022bd909..f1b2b7d04 100644 --- a/service/java/com/android/server/wifi/WifiMetrics.java +++ b/service/java/com/android/server/wifi/WifiMetrics.java @@ -23,6 +23,8 @@ import android.hardware.wifi.supplicant.V1_0.ISupplicantStaIfaceCallback; import android.net.wifi.EAPConstants; import android.net.wifi.IOnWifiUsabilityStatsListener; import android.net.wifi.ScanResult; +import android.net.wifi.SoftApCapability; +import android.net.wifi.SoftApConfiguration; import android.net.wifi.SupplicantState; import android.net.wifi.WifiConfiguration; import android.net.wifi.WifiEnterpriseConfig; @@ -2195,6 +2197,14 @@ public class WifiMetrics { mSoftApManagerReturnCodeCounts.put( WifiMetricsProto.SoftApReturnCodeCount.SOFT_AP_FAILED_NO_CHANNEL, count + 1); + } else if (failureCode == WifiManager.SAP_START_FAILURE_UNSUPPORTED_CONFIGURATION) { + int count = mSoftApManagerReturnCodeCounts.get( + WifiMetricsProto.SoftApReturnCodeCount + .SOFT_AP_FAILED_UNSUPPORTED_CONFIGURATION); + mSoftApManagerReturnCodeCounts.put( + WifiMetricsProto.SoftApReturnCodeCount + .SOFT_AP_FAILED_UNSUPPORTED_CONFIGURATION, + count + 1); } else { // failure mode not tracked at this time... count as a general error for now. int count = mSoftApManagerReturnCodeCounts.get( @@ -2209,11 +2219,12 @@ public class WifiMetrics { /** * Adds a record indicating the current up state of soft AP */ - public void addSoftApUpChangedEvent(boolean isUp, int mode) { + public void addSoftApUpChangedEvent(boolean isUp, int mode, long defaultShutdownTimeoutMillis) { SoftApConnectedClientsEvent event = new SoftApConnectedClientsEvent(); event.eventType = isUp ? SoftApConnectedClientsEvent.SOFT_AP_UP : SoftApConnectedClientsEvent.SOFT_AP_DOWN; event.numConnectedClients = 0; + event.defaultShutdownTimeoutSetting = defaultShutdownTimeoutMillis; addSoftApConnectedClientsEvent(event, mode); } @@ -2283,6 +2294,66 @@ public class WifiMetrics { } /** + * Updates current soft AP events with softap configuration + */ + public void updateSoftApConfiguration(SoftApConfiguration config, int mode) { + synchronized (mLock) { + List<SoftApConnectedClientsEvent> softApEventList; + switch (mode) { + case WifiManager.IFACE_IP_MODE_TETHERED: + softApEventList = mSoftApEventListTethered; + break; + case WifiManager.IFACE_IP_MODE_LOCAL_ONLY: + softApEventList = mSoftApEventListLocalOnly; + break; + default: + return; + } + + for (int index = softApEventList.size() - 1; index >= 0; index--) { + SoftApConnectedClientsEvent event = softApEventList.get(index); + + if (event != null && event.eventType == SoftApConnectedClientsEvent.SOFT_AP_UP) { + event.maxNumClientsSettingInSoftapConfiguration = + config.getMaxNumberOfClients(); + event.shutdownTimeoutSettingInSoftapConfiguration = + config.getShutdownTimeoutMillis(); + event.clientControlIsEnabled = config.isClientControlByUserEnabled(); + break; + } + } + } + } + + /** + * Updates current soft AP events with softap capability + */ + public void updateSoftApCapability(SoftApCapability capability, int mode) { + synchronized (mLock) { + List<SoftApConnectedClientsEvent> softApEventList; + switch (mode) { + case WifiManager.IFACE_IP_MODE_TETHERED: + softApEventList = mSoftApEventListTethered; + break; + case WifiManager.IFACE_IP_MODE_LOCAL_ONLY: + softApEventList = mSoftApEventListLocalOnly; + break; + default: + return; + } + + for (int index = softApEventList.size() - 1; index >= 0; index--) { + SoftApConnectedClientsEvent event = softApEventList.get(index); + if (event != null && event.eventType == SoftApConnectedClientsEvent.SOFT_AP_UP) { + event.maxNumClientsSettingInSoftapCapability = + capability.getMaxSupportedClients(); + break; + } + } + } + } + + /** * Increment number of times the HAL crashed. */ public void incrementNumHalCrashes() { @@ -2947,6 +3018,10 @@ public class WifiMetrics { WifiMetricsProto.SoftApReturnCodeCount.SOFT_AP_FAILED_GENERAL_ERROR)); pw.println(" FAILED_NO_CHANNEL: " + mSoftApManagerReturnCodeCounts.get( WifiMetricsProto.SoftApReturnCodeCount.SOFT_AP_FAILED_NO_CHANNEL)); + pw.println(" FAILED_UNSUPPORTED_CONFIGURATION: " + + mSoftApManagerReturnCodeCounts.get( + WifiMetricsProto.SoftApReturnCodeCount + .SOFT_AP_FAILED_UNSUPPORTED_CONFIGURATION)); pw.print("\n"); pw.println("mWifiLogProto.numHalCrashes=" + mWifiLogProto.numHalCrashes); @@ -3106,6 +3181,15 @@ public class WifiMetrics { eventLine.append(",num_connected_clients=" + event.numConnectedClients); eventLine.append(",channel_frequency=" + event.channelFrequency); eventLine.append(",channel_bandwidth=" + event.channelBandwidth); + eventLine.append(",max_num_clients_setting_in_softap_configuration=" + + event.maxNumClientsSettingInSoftapConfiguration); + eventLine.append(",max_num_clients_setting_in_softap_capability=" + + event.maxNumClientsSettingInSoftapCapability); + eventLine.append(",shutdown_timeout_setting_in_softap_configuration=" + + event.shutdownTimeoutSettingInSoftapConfiguration); + eventLine.append(",default_shutdown_timeout_setting=" + + event.defaultShutdownTimeoutSetting); + eventLine.append(",client_control_is_enabled=" + event.clientControlIsEnabled); pw.println(eventLine.toString()); } pw.println("mSoftApLocalOnlyEvents:"); @@ -3116,6 +3200,15 @@ public class WifiMetrics { eventLine.append(",num_connected_clients=" + event.numConnectedClients); eventLine.append(",channel_frequency=" + event.channelFrequency); eventLine.append(",channel_bandwidth=" + event.channelBandwidth); + eventLine.append(",max_num_clients_setting_in_softap_configuration=" + + event.maxNumClientsSettingInSoftapConfiguration); + eventLine.append(",max_num_clients_setting_in_softap_capability=" + + event.maxNumClientsSettingInSoftapCapability); + eventLine.append(",shutdown_timeout_setting_in_softap_configuration=" + + event.shutdownTimeoutSettingInSoftapConfiguration); + eventLine.append(",default_shutdown_timeout_setting=" + + event.defaultShutdownTimeoutSetting); + eventLine.append(",client_control_is_enabled=" + event.clientControlIsEnabled); pw.println(eventLine.toString()); } diff --git a/service/proto/src/metrics.proto b/service/proto/src/metrics.proto index 828dcaa19..0a4675d4e 100644 --- a/service/proto/src/metrics.proto +++ b/service/proto/src/metrics.proto @@ -1091,6 +1091,9 @@ message SoftApReturnCodeCount { // SoftAp failed to start due to NO_CHANNEL error SOFT_AP_FAILED_NO_CHANNEL = 3; + + // SoftAp failed to start due to unsupported configuration error + SOFT_AP_FAILED_UNSUPPORTED_CONFIGURATION = 4; } // Historical, no longer used for writing as of 01/2017. @@ -1711,6 +1714,21 @@ message SoftApConnectedClientsEvent { // Channel bandwidth used for Soft AP optional ChannelBandwidth channel_bandwidth = 5; + + // Maximum number of client setting in SoftApConfiguration + optional int32 max_num_clients_setting_in_softap_configuration = 6; + + // Maximum number of client setting in SoftApCapability + optional int32 max_num_clients_setting_in_softap_capability = 7; + + // Auto shutdown timeout setting in SoftApConfiguration + optional int64 shutdown_timeout_setting_in_softap_configuration = 8; + + // Framework default auto shutdown timeout setting + optional int64 default_shutdown_timeout_setting = 9; + + // Indicates if user enabled the client_control + optional bool client_control_is_enabled = 10; } // Wps connection metrics |