diff options
author | TreeHugger Robot <treehugger-gerrit@google.com> | 2020-05-13 11:03:14 +0000 |
---|---|---|
committer | Automerger Merge Worker <android-build-automerger-merge-worker@system.gserviceaccount.com> | 2020-05-13 11:03:14 +0000 |
commit | 06a7de0ffd076ab62c796f9f578dac53b03665fb (patch) | |
tree | afc837a48ae5991e0f795cce6a3a52eba2904932 /service | |
parent | 5dce925016cdb9958faf7828e076007595d13443 (diff) | |
parent | 61c22b90db0d4be53a23ca85938ea014e388bb2d (diff) |
Merge "Add metrics for user approve carrier" into rvc-dev am: 61c22b90db
Change-Id: I57b1d6d38d0ccd944ceeccd3e92a85f41f7ee40d
Diffstat (limited to 'service')
5 files changed, 148 insertions, 55 deletions
diff --git a/service/java/com/android/server/wifi/WifiCarrierInfoManager.java b/service/java/com/android/server/wifi/WifiCarrierInfoManager.java index f35f59047..d483047d2 100644 --- a/service/java/com/android/server/wifi/WifiCarrierInfoManager.java +++ b/service/java/com/android/server/wifi/WifiCarrierInfoManager.java @@ -16,6 +16,7 @@ package com.android.server.wifi; +import android.annotation.IntDef; import android.annotation.NonNull; import android.app.AlertDialog; import android.app.Notification; @@ -53,6 +54,8 @@ import com.android.wifi.resources.R; import java.io.FileDescriptor; import java.io.PrintWriter; +import java.lang.annotation.Retention; +import java.lang.annotation.RetentionPolicy; import java.security.InvalidKeyException; import java.security.NoSuchAlgorithmException; import java.security.PublicKey; @@ -111,6 +114,18 @@ public class WifiCarrierInfoManager { EAP_METHOD_PREFIX.put(WifiEnterpriseConfig.Eap.AKA_PRIME, "6"); } + public static final int ACTION_USER_ALLOWED_CARRIER = 1; + public static final int ACTION_USER_DISALLOWED_CARRIER = 2; + public static final int ACTION_USER_DISMISS = 3; + + @IntDef(prefix = { "ACTION_USER_" }, value = { + ACTION_USER_ALLOWED_CARRIER, + ACTION_USER_DISALLOWED_CARRIER, + ACTION_USER_DISMISS + }) + @Retention(RetentionPolicy.SOURCE) + public @interface UserActionCode { } + /** * 3GPP TS 11.11 2G_authentication command/response * Input: [RAND] @@ -130,6 +145,7 @@ public class WifiCarrierInfoManager { private final TelephonyManager mTelephonyManager; private final SubscriptionManager mSubscriptionManager; private final NotificationManager mNotificationManager; + private final WifiMetrics mWifiMetrics; /** * Intent filter for processing notification actions. @@ -149,6 +165,7 @@ public class WifiCarrierInfoManager { private boolean mUserApprovalUiActive = false; private boolean mHasNewDataToSerialize = false; private boolean mUserDataLoaded = false; + private boolean mIsLastUserApprovalUiDialog = false; /** * Interface for other modules to listen to the user approve IMSI protection exemption. @@ -229,18 +246,25 @@ public class WifiCarrierInfoManager { private void handleUserDismissAction() { Log.i(TAG, "User dismissed the notification"); mUserApprovalUiActive = false; + mWifiMetrics.addUserApprovalCarrierUiReaction(ACTION_USER_DISMISS, + mIsLastUserApprovalUiDialog); } private void handleUserAllowCarrierExemptionAction(String carrierName, int carrierId) { Log.i(TAG, "User clicked to allow carrier:" + carrierName); setHasUserApprovedImsiPrivacyExemptionForCarrier(true, carrierId); mUserApprovalUiActive = false; + mWifiMetrics.addUserApprovalCarrierUiReaction(ACTION_USER_ALLOWED_CARRIER, + mIsLastUserApprovalUiDialog); + } private void handleUserDisallowCarrierExemptionAction(String carrierName, int carrierId) { Log.i(TAG, "User clicked to disallow carrier:" + carrierName); setHasUserApprovedImsiPrivacyExemptionForCarrier(false, carrierId); mUserApprovalUiActive = false; + mWifiMetrics.addUserApprovalCarrierUiReaction( + ACTION_USER_DISALLOWED_CARRIER, mIsLastUserApprovalUiDialog); } /** @@ -256,7 +280,8 @@ public class WifiCarrierInfoManager { @NonNull FrameworkFacade frameworkFacade, @NonNull WifiContext context, @NonNull WifiConfigStore configStore, - @NonNull Handler handler) { + @NonNull Handler handler, + @NonNull WifiMetrics wifiMetrics) { mTelephonyManager = telephonyManager; mContext = context; mResources = mContext.getResources(); @@ -264,7 +289,7 @@ public class WifiCarrierInfoManager { mHandler = handler; mSubscriptionManager = subscriptionManager; mFrameworkFacade = frameworkFacade; - + mWifiMetrics = wifiMetrics; mNotificationManager = (NotificationManager) context.getSystemService(Context.NOTIFICATION_SERVICE); // Register broadcast receiver for UI interactions. @@ -1438,9 +1463,12 @@ public class WifiCarrierInfoManager { mNotificationManager.notify( SystemMessageProto.SystemMessage.NOTE_NETWORK_SUGGESTION_AVAILABLE, notification); mUserApprovalUiActive = true; + mIsLastUserApprovalUiDialog = false; } private void sendImsiPrivacyConfirmationDialog(@NonNull String carrierName, int carrierId) { + mWifiMetrics.addUserApprovalCarrierUiReaction(ACTION_USER_ALLOWED_CARRIER, + mIsLastUserApprovalUiDialog); AlertDialog dialog = mFrameworkFacade.makeAlertDialogBuilder(mContext) .setTitle(mResources.getString( R.string.wifi_suggestion_imsi_privacy_exemption_confirmation_title)) @@ -1468,6 +1496,7 @@ public class WifiCarrierInfoManager { WindowManager.LayoutParams.SYSTEM_FLAG_SHOW_FOR_ALL_USERS); dialog.show(); mUserApprovalUiActive = true; + mIsLastUserApprovalUiDialog = true; } /** diff --git a/service/java/com/android/server/wifi/WifiInjector.java b/service/java/com/android/server/wifi/WifiInjector.java index 5dc3296c9..8f6465b00 100644 --- a/service/java/com/android/server/wifi/WifiInjector.java +++ b/service/java/com/android/server/wifi/WifiInjector.java @@ -261,7 +261,7 @@ public class WifiInjector { mContext.getSystemService(SubscriptionManager.class); mWifiCarrierInfoManager = new WifiCarrierInfoManager(makeTelephonyManager(), subscriptionManager, this, mFrameworkFacade, mContext, - mWifiConfigStore, wifiHandler); + mWifiConfigStore, wifiHandler, mWifiMetrics); String l2KeySeed = Secure.getString(mContext.getContentResolver(), Secure.ANDROID_ID); mWifiScoreCard = new WifiScoreCard(mClock, l2KeySeed, mDeviceConfigFacade); mWifiMetrics.setWifiScoreCard(mWifiScoreCard); diff --git a/service/java/com/android/server/wifi/WifiMetrics.java b/service/java/com/android/server/wifi/WifiMetrics.java index 8aa027c60..383659e4d 100644 --- a/service/java/com/android/server/wifi/WifiMetrics.java +++ b/service/java/com/android/server/wifi/WifiMetrics.java @@ -82,13 +82,14 @@ import com.android.server.wifi.proto.nano.WifiMetricsProto.StaEvent; import com.android.server.wifi.proto.nano.WifiMetricsProto.StaEvent.ConfigInfo; import com.android.server.wifi.proto.nano.WifiMetricsProto.TargetNetworkInfo; import com.android.server.wifi.proto.nano.WifiMetricsProto.UserActionEvent; +import com.android.server.wifi.proto.nano.WifiMetricsProto.UserReactionToApprovalUiEvent; +import com.android.server.wifi.proto.nano.WifiMetricsProto.UserReactionToApprovalUiEvent.UserReaction; import com.android.server.wifi.proto.nano.WifiMetricsProto.WifiIsUnusableEvent; import com.android.server.wifi.proto.nano.WifiMetricsProto.WifiLinkLayerUsageStats; 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.WifiNetworkSuggestionApiLog.UserReaction; 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; @@ -417,7 +418,9 @@ public class WifiMetrics { private final IntHistogram mWifiNetworkSuggestionApiListSizeHistogram = new IntHistogram(NETWORK_SUGGESTION_API_LIST_SIZE_HISTOGRAM_BUCKETS); private final IntCounter mWifiNetworkSuggestionApiAppTypeCounter = new IntCounter(); - private final List<UserReaction> mWifiNetworkSuggestionUserApprovalAppUiReaction = + private final List<UserReaction> mUserApprovalSuggestionAppUiReactionList = + new ArrayList<>(); + private final List<UserReaction> mUserApprovalCarrierUiReactionList = new ArrayList<>(); private final WifiLockStats mWifiLockStats = new WifiLockStats(); @@ -3595,7 +3598,8 @@ public class WifiMetrics { + mWifiNetworkSuggestionApiListSizeHistogram); pw.println("mWifiNetworkSuggestionApiAppTypeCounter:\n" + mWifiNetworkSuggestionApiAppTypeCounter); - printSuggestionUserApprovalAppReaction(pw); + printUserApprovalSuggestionAppReaction(pw); + printUserApprovalCarrierReaction(pw); pw.println("mNetworkIdToNominatorId:\n" + mNetworkIdToNominatorId); pw.println("mWifiLockStats:\n" + mWifiLockStats); pw.println("mWifiLockHighPerfAcqDurationSecHistogram:\n" @@ -3702,9 +3706,16 @@ public class WifiMetrics { pw.println(line.toString()); } - private void printSuggestionUserApprovalAppReaction(PrintWriter pw) { - pw.println("mWifiNetworkSuggestionApprovalAppUiUserReaction:"); - for (UserReaction event : mWifiNetworkSuggestionUserApprovalAppUiReaction) { + private void printUserApprovalSuggestionAppReaction(PrintWriter pw) { + pw.println("mUserApprovalSuggestionAppUiUserReaction:"); + for (UserReaction event : mUserApprovalSuggestionAppUiReactionList) { + pw.println(event); + } + } + + private void printUserApprovalCarrierReaction(PrintWriter pw) { + pw.println("mUserApprovalCarrierUiUserReaction:"); + for (UserReaction event : mUserApprovalCarrierUiReactionList) { pw.println(event); } } @@ -4227,11 +4238,15 @@ public class WifiMetrics { entry.count = count; return entry; }); - mWifiNetworkSuggestionApiLog.userApprovalAppUiReaction = - mWifiNetworkSuggestionUserApprovalAppUiReaction - .toArray(new UserReaction[0]); mWifiLogProto.wifiNetworkSuggestionApiLog = mWifiNetworkSuggestionApiLog; + UserReactionToApprovalUiEvent events = new UserReactionToApprovalUiEvent(); + events.userApprovalAppUiReaction = mUserApprovalSuggestionAppUiReactionList + .toArray(new UserReaction[0]); + events.userApprovalCarrierUiReaction = mUserApprovalCarrierUiReactionList + .toArray(new UserReaction[0]); + mWifiLogProto.userReactionToApprovalUiEvent = events; + mWifiLockStats.highPerfLockAcqDurationSecHistogram = mWifiLockHighPerfAcqDurationSecHistogram.toProto(); @@ -4496,7 +4511,8 @@ public class WifiMetrics { mWifiNetworkRequestApiMatchSizeHistogram.clear(); mWifiNetworkSuggestionApiListSizeHistogram.clear(); mWifiNetworkSuggestionApiAppTypeCounter.clear(); - mWifiNetworkSuggestionUserApprovalAppUiReaction.clear(); + mUserApprovalSuggestionAppUiReactionList.clear(); + mUserApprovalCarrierUiReactionList.clear(); mWifiLockHighPerfAcqDurationSecHistogram.clear(); mWifiLockLowLatencyAcqDurationSecHistogram.clear(); mWifiLockHighPerfActiveSessionDurationSecHistogram.clear(); @@ -5986,29 +6002,57 @@ public class WifiMetrics { } } - /** Add user action to the approval app UI */ - public void addNetworkSuggestionUserApprovalAppUiReaction(int actionType, boolean isDialog) { + /** Add user action to the approval suggestion app UI */ + public void addUserApprovalSuggestionAppUiReaction(@WifiNetworkSuggestionsManager.UserActionCode + int actionType, boolean isDialog) { int actionCode; + switch (actionType) { + case WifiNetworkSuggestionsManager.ACTION_USER_ALLOWED_APP: + actionCode = UserReactionToApprovalUiEvent.ACTION_ALLOWED; + break; + case WifiNetworkSuggestionsManager.ACTION_USER_DISALLOWED_APP: + actionCode = UserReactionToApprovalUiEvent.ACTION_DISALLOWED; + break; + case WifiNetworkSuggestionsManager.ACTION_USER_DISMISS: + actionCode = UserReactionToApprovalUiEvent.ACTION_DISMISS; + break; + default: + actionCode = UserReactionToApprovalUiEvent.ACTION_UNKNOWN; + } UserReaction event = new UserReaction(); + event.userAction = actionCode; + event.isDialog = isDialog; synchronized (mLock) { - switch (actionType) { - case WifiNetworkSuggestionsManager.ACTION_USER_ALLOWED_APP: - actionCode = WifiNetworkSuggestionApiLog.ACTION_ALLOWED; - break; - case WifiNetworkSuggestionsManager.ACTION_USER_DISALLOWED_APP: - actionCode = WifiNetworkSuggestionApiLog.ACTION_DISALLOWED; - break; - case WifiNetworkSuggestionsManager.ACTION_USER_DISMISS: - actionCode = WifiNetworkSuggestionApiLog.ACTION_DISMISS; - break; - default: - actionCode = WifiNetworkSuggestionApiLog.ACTION_UNKNOWN; - } - event.userAction = actionCode; - event.isDialog = isDialog; - mWifiNetworkSuggestionUserApprovalAppUiReaction.add(event); + mUserApprovalSuggestionAppUiReactionList.add(event); + } + } + + /** Add user action to the approval Carrier Imsi protection exemption UI */ + public void addUserApprovalCarrierUiReaction(@WifiCarrierInfoManager.UserActionCode + int actionType, boolean isDialog) { + int actionCode; + switch (actionType) { + case WifiCarrierInfoManager.ACTION_USER_ALLOWED_CARRIER: + actionCode = UserReactionToApprovalUiEvent.ACTION_ALLOWED; + break; + case WifiCarrierInfoManager.ACTION_USER_DISALLOWED_CARRIER: + actionCode = UserReactionToApprovalUiEvent.ACTION_DISALLOWED; + break; + case WifiCarrierInfoManager.ACTION_USER_DISMISS: + actionCode = UserReactionToApprovalUiEvent.ACTION_DISMISS; + break; + default: + actionCode = UserReactionToApprovalUiEvent.ACTION_UNKNOWN; + } + UserReaction event = new UserReaction(); + event.userAction = actionCode; + event.isDialog = isDialog; + + synchronized (mLock) { + mUserApprovalCarrierUiReactionList.add(event); } } + /** * 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 678676ce6..f470039a7 100644 --- a/service/java/com/android/server/wifi/WifiNetworkSuggestionsManager.java +++ b/service/java/com/android/server/wifi/WifiNetworkSuggestionsManager.java @@ -19,6 +19,7 @@ package com.android.server.wifi; import static android.app.AppOpsManager.MODE_IGNORED; import static android.app.AppOpsManager.OPSTR_CHANGE_WIFI_STATE; +import android.annotation.IntDef; import android.annotation.NonNull; import android.annotation.Nullable; import android.app.ActivityManager; @@ -64,6 +65,8 @@ import com.android.wifi.resources.R; import java.io.FileDescriptor; import java.io.PrintWriter; +import java.lang.annotation.Retention; +import java.lang.annotation.RetentionPolicy; import java.util.ArrayList; import java.util.Collection; import java.util.Collections; @@ -113,6 +116,14 @@ public class WifiNetworkSuggestionsManager { public static final int ACTION_USER_DISALLOWED_APP = 2; public static final int ACTION_USER_DISMISS = 3; + @IntDef(prefix = { "ACTION_USER_" }, value = { + ACTION_USER_ALLOWED_APP, + ACTION_USER_DISALLOWED_APP, + ACTION_USER_DISMISS + }) + @Retention(RetentionPolicy.SOURCE) + public @interface UserActionCode { } + /** * Limit number of hidden networks attach to scan */ @@ -489,7 +500,7 @@ public class WifiNetworkSuggestionsManager { // Set the user approved flag. setHasUserApprovedForApp(true, packageName); mUserApprovalUiActive = false; - mWifiMetrics.addNetworkSuggestionUserApprovalAppUiReaction( + mWifiMetrics.addUserApprovalSuggestionAppUiReaction( ACTION_USER_ALLOWED_APP, mIsLastUserApprovalUiDialog); } @@ -502,7 +513,7 @@ public class WifiNetworkSuggestionsManager { mAppOps.setMode(AppOpsManager.OPSTR_CHANGE_WIFI_STATE, uid, packageName, MODE_IGNORED); mUserApprovalUiActive = false; - mWifiMetrics.addNetworkSuggestionUserApprovalAppUiReaction( + mWifiMetrics.addUserApprovalSuggestionAppUiReaction( ACTION_USER_DISALLOWED_APP, mIsLastUserApprovalUiDialog); } @@ -510,7 +521,7 @@ public class WifiNetworkSuggestionsManager { private void handleUserDismissAction() { Log.i(TAG, "User dismissed the notification"); mUserApprovalUiActive = false; - mWifiMetrics.addNetworkSuggestionUserApprovalAppUiReaction( + mWifiMetrics.addUserApprovalSuggestionAppUiReaction( ACTION_USER_DISMISS, mIsLastUserApprovalUiDialog); } diff --git a/service/proto/src/metrics.proto b/service/proto/src/metrics.proto index 531d64b17..2fb6df13f 100644 --- a/service/proto/src/metrics.proto +++ b/service/proto/src/metrics.proto @@ -703,6 +703,9 @@ message WifiLog { // Does the user have wifi wake enabled. optional bool is_wifi_wake_enabled = 197; + + // User reaction to the carrier or suggestion app approval UI. + optional UserReactionToApprovalUiEvent userReactionToApprovalUiEvent = 198; } // Information that gets logged for every WiFi connection. @@ -2895,16 +2898,6 @@ message WifiNetworkSuggestionApiLog { // Suggestion app without special privilege. TYPE_NON_PRIVILEGED = 3; } - enum UserActionCode { - // UNKNOWN user action. - ACTION_UNKNOWN = 0; - // Action user allowed. - ACTION_ALLOWED = 1; - // Action user disallowed. - ACTION_DISALLOWED = 2; - // Action user dismiss. - ACTION_DISMISS = 3; - } message SuggestionAppCount { // Suggestion app type. @@ -2913,13 +2906,6 @@ message WifiNetworkSuggestionApiLog { optional int32 count = 2; } - message UserReaction { - // User action to the UI. - optional UserActionCode user_action = 1; - // Is UI a dialog or notification. - optional bool is_dialog = 3; - } - // Number of modifications to their suggestions by apps. optional int32 num_modification = 1; @@ -2935,11 +2921,8 @@ message WifiNetworkSuggestionApiLog { // Count of app using suggestion API with different privilege. repeated SuggestionAppCount app_count_per_type = 5; - // Event of user reaction to the UI. - repeated UserReaction user_approval_app_ui_reaction = 6; - // Number of user revoke app's permission from settings or disallowed from UI. - optional int32 user_revoke_app_suggestion_permission = 7; + optional int32 user_revoke_app_suggestion_permission = 6; } // WifiLock metrics @@ -3274,3 +3257,29 @@ message InitPartialScanStats { // Histogram of number of channels used in a failed partial scan repeated HistogramBucketInt32 failed_scan_channel_count_histogram = 5; } + +// User reaction to the carrier IMSI protection exemption UI +message UserReactionToApprovalUiEvent { + enum UserActionCode { + // UNKNOWN user action. + ACTION_UNKNOWN = 0; + // Action user allowed. + ACTION_ALLOWED = 1; + // Action user disallowed. + ACTION_DISALLOWED = 2; + // Action user dismiss. + ACTION_DISMISS = 3; + } + message UserReaction { + // User action to the UI. + optional UserActionCode user_action = 1; + // Is UI a dialog or notification. + optional bool is_dialog = 2; + } + + // Event of user reaction to the app approval UI. + repeated UserReaction user_approval_app_ui_reaction = 1; + + // Event of user reaction to the carrier approval UI. + repeated UserReaction user_approval_carrier_ui_reaction = 2; +} |