diff options
author | Nate Jiang <qiangjiang@google.com> | 2020-04-17 11:47:21 -0700 |
---|---|---|
committer | Nate Jiang <qiangjiang@google.com> | 2020-04-17 15:17:47 -0700 |
commit | 1aa59ac094935325892f10acd7bedad19c3749e4 (patch) | |
tree | 16fa73ece73710c040d9e831e809852e0c97d041 /service | |
parent | 63da7f604a87743c33f9d0bcf18a87eb5c8e05ec (diff) |
Add metrics for WifiNetworkSuggestion Api App usage
Add app count for each type of app with different privilege.
Bug: 123362619
Test: atest com.android.server.wifi
Change-Id: If6119caa9a5123322e5286a0a44c26c117aef0c0
Diffstat (limited to 'service')
-rw-r--r-- | service/java/com/android/server/wifi/WifiMetrics.java | 36 | ||||
-rw-r--r-- | service/java/com/android/server/wifi/WifiNetworkSuggestionsManager.java | 12 | ||||
-rw-r--r-- | service/proto/src/metrics.proto | 21 |
3 files changed, 68 insertions, 1 deletions
diff --git a/service/java/com/android/server/wifi/WifiMetrics.java b/service/java/com/android/server/wifi/WifiMetrics.java index 031c495cc..e7fbf59ef 100644 --- a/service/java/com/android/server/wifi/WifiMetrics.java +++ b/service/java/com/android/server/wifi/WifiMetrics.java @@ -83,6 +83,7 @@ import com.android.server.wifi.proto.nano.WifiMetricsProto.WifiLinkLayerUsageSta import com.android.server.wifi.proto.nano.WifiMetricsProto.WifiLockStats; import com.android.server.wifi.proto.nano.WifiMetricsProto.WifiNetworkRequestApiLog; import com.android.server.wifi.proto.nano.WifiMetricsProto.WifiNetworkSuggestionApiLog; +import com.android.server.wifi.proto.nano.WifiMetricsProto.WifiNetworkSuggestionApiLog.SuggestionAppCount; import com.android.server.wifi.proto.nano.WifiMetricsProto.WifiToggleStats; import com.android.server.wifi.proto.nano.WifiMetricsProto.WifiUsabilityStats; import com.android.server.wifi.proto.nano.WifiMetricsProto.WifiUsabilityStatsEntry; @@ -410,6 +411,7 @@ public class WifiMetrics { {5, 20, 50, 100, 500}; private final IntHistogram mWifiNetworkSuggestionApiListSizeHistogram = new IntHistogram(NETWORK_SUGGESTION_API_LIST_SIZE_HISTOGRAM_BUCKETS); + private final IntCounter mWifiNetworkSuggestionApiAppTypeCounter = new IntCounter(); private final WifiLockStats mWifiLockStats = new WifiLockStats(); private static final int[] WIFI_LOCK_SESSION_DURATION_HISTOGRAM_BUCKETS = {1, 10, 60, 600, 3600}; @@ -3619,7 +3621,9 @@ public class WifiMetrics { + mWifiNetworkRequestApiMatchSizeHistogram); pw.println("mWifiNetworkSuggestionApiLog:\n" + mWifiNetworkSuggestionApiLog); pw.println("mWifiNetworkSuggestionApiMatchSizeHistogram:\n" - + mWifiNetworkRequestApiMatchSizeHistogram); + + mWifiNetworkSuggestionApiListSizeHistogram); + pw.println("mWifiNetworkSuggestionApiAppTypeCounter:\n" + + mWifiNetworkSuggestionApiAppTypeCounter); pw.println("mNetworkIdToNominatorId:\n" + mNetworkIdToNominatorId); pw.println("mWifiLockStats:\n" + mWifiLockStats); pw.println("mWifiLockHighPerfAcqDurationSecHistogram:\n" @@ -4236,6 +4240,14 @@ public class WifiMetrics { mWifiNetworkSuggestionApiLog.networkListSizeHistogram = mWifiNetworkSuggestionApiListSizeHistogram.toProto(); + mWifiNetworkSuggestionApiLog.appCountPerType = + mWifiNetworkSuggestionApiAppTypeCounter.toProto(SuggestionAppCount.class, + (key, count) -> { + SuggestionAppCount entry = new SuggestionAppCount(); + entry.appType = key; + entry.count = count; + return entry; + }); mWifiLogProto.wifiNetworkSuggestionApiLog = mWifiNetworkSuggestionApiLog; mWifiLockStats.highPerfLockAcqDurationSecHistogram = @@ -4500,6 +4512,7 @@ public class WifiMetrics { mWifiNetworkSuggestionApiLog.clear(); mWifiNetworkRequestApiMatchSizeHistogram.clear(); mWifiNetworkSuggestionApiListSizeHistogram.clear(); + mWifiNetworkSuggestionApiAppTypeCounter.clear(); mWifiLockHighPerfAcqDurationSecHistogram.clear(); mWifiLockLowLatencyAcqDurationSecHistogram.clear(); mWifiLockHighPerfActiveSessionDurationSecHistogram.clear(); @@ -5856,6 +5869,27 @@ public class WifiMetrics { } } + /** Increment number of app add suggestion with different privilege */ + public void incrementNetworkSuggestionApiUsageNumOfAppInType(int appType) { + int typeCode; + synchronized (mLock) { + switch (appType) { + case WifiNetworkSuggestionsManager.APP_TYPE_CARRIER_PRIVILEGED: + typeCode = WifiNetworkSuggestionApiLog.TYPE_CARRIER_PRIVILEGED; + break; + case WifiNetworkSuggestionsManager.APP_TYPE_NETWORK_PROVISIONING: + typeCode = WifiNetworkSuggestionApiLog.TYPE_NETWORK_PROVISIONING; + break; + case WifiNetworkSuggestionsManager.APP_TYPE_NON_PRIVILEGED: + typeCode = WifiNetworkSuggestionApiLog.TYPE_NON_PRIVILEGED; + break; + default: + typeCode = WifiNetworkSuggestionApiLog.TYPE_UNKNOWN; + } + } + mWifiNetworkSuggestionApiAppTypeCounter.increment(typeCode); + } + /** * Sets the nominator for a network (i.e. which entity made the suggestion to connect) * @param networkId the ID of the network, from its {@link WifiConfiguration} diff --git a/service/java/com/android/server/wifi/WifiNetworkSuggestionsManager.java b/service/java/com/android/server/wifi/WifiNetworkSuggestionsManager.java index 28cf627b5..685df0757 100644 --- a/service/java/com/android/server/wifi/WifiNetworkSuggestionsManager.java +++ b/service/java/com/android/server/wifi/WifiNetworkSuggestionsManager.java @@ -105,6 +105,10 @@ public class WifiNetworkSuggestionsManager { public static final String EXTRA_UID = "com.android.server.wifi.extra.NetworkSuggestion.UID"; + public static final int APP_TYPE_CARRIER_PRIVILEGED = 1; + public static final int APP_TYPE_NETWORK_PROVISIONING = 2; + public static final int APP_TYPE_NON_PRIVILEGED = 3; + /** * Limit number of hidden networks attach to scan */ @@ -824,19 +828,27 @@ public class WifiNetworkSuggestionsManager { if (mWifiPermissionsUtil.checkNetworkCarrierProvisioningPermission(uid)) { Log.i(TAG, "Setting the carrier provisioning app approved"); perAppInfo.hasUserApproved = true; + mWifiMetrics.incrementNetworkSuggestionApiUsageNumOfAppInType( + APP_TYPE_NETWORK_PROVISIONING); } else if (carrierId != TelephonyManager.UNKNOWN_CARRIER_ID) { Log.i(TAG, "Setting the carrier privileged app approved"); perAppInfo.carrierId = carrierId; + mWifiMetrics.incrementNetworkSuggestionApiUsageNumOfAppInType( + APP_TYPE_CARRIER_PRIVILEGED); } else if (perAppInfo.packageName.equals(activeScorerPackage)) { Log.i(TAG, "Exempting the active scorer app"); // nothing more to do, user approval related checks are done at network selection // time (which also takes care of any dynamic changes in active scorer). + mWifiMetrics.incrementNetworkSuggestionApiUsageNumOfAppInType( + APP_TYPE_NON_PRIVILEGED); } else { if (isSuggestionFromForegroundApp(packageName)) { sendUserApprovalDialog(packageName, uid); } else { sendUserApprovalNotification(packageName, uid); } + mWifiMetrics.incrementNetworkSuggestionApiUsageNumOfAppInType( + APP_TYPE_NON_PRIVILEGED); } } // If PerAppInfo is upgrade from pre-R, uid may not be set. diff --git a/service/proto/src/metrics.proto b/service/proto/src/metrics.proto index d1dd39e49..627c24529 100644 --- a/service/proto/src/metrics.proto +++ b/service/proto/src/metrics.proto @@ -2897,6 +2897,24 @@ message WifiNetworkRequestApiLog { // NetworkSuggestion API metrics. message WifiNetworkSuggestionApiLog { + enum SuggestionAppTypeCode { + // UNKNOWN type suggestion app. + TYPE_UNKNOWN = 0; + // Suggestion app with carrier privilege. + TYPE_CARRIER_PRIVILEGED = 1; + // Suggestion app with network provisioning permission(NETWORK_CARRIER_PROVISIONING). + TYPE_NETWORK_PROVISIONING = 2; + // Suggestion app without special privilege. + TYPE_NON_PRIVILEGED = 3; + } + + message SuggestionAppCount { + // Suggestion app type. + optional SuggestionAppTypeCode app_type = 1; + // Num of app in this type. + optional int32 count = 2; + } + // Number of modifications to their suggestions by apps. optional int32 num_modification = 1; @@ -2908,6 +2926,9 @@ message WifiNetworkSuggestionApiLog { // Histogram for size of the network lists provided by various apps on the device. repeated HistogramBucketInt32 network_list_size_histogram = 4; + + // Count of app using suggestion API with different privilege. + repeated SuggestionAppCount app_count_per_type = 5; } // WifiLock metrics |