summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--service/java/com/android/server/wifi/WifiCarrierInfoManager.java33
-rw-r--r--service/java/com/android/server/wifi/WifiInjector.java2
-rw-r--r--service/java/com/android/server/wifi/WifiMetrics.java100
-rw-r--r--service/java/com/android/server/wifi/WifiNetworkSuggestionsManager.java17
-rw-r--r--service/proto/src/metrics.proto51
-rw-r--r--tests/wifitests/src/com/android/server/wifi/ClientModeImplTest.java3
-rw-r--r--tests/wifitests/src/com/android/server/wifi/WifiCarrierInfoManagerTest.java19
-rw-r--r--tests/wifitests/src/com/android/server/wifi/WifiConfigManagerTest.java3
-rw-r--r--tests/wifitests/src/com/android/server/wifi/WifiMetricsTest.java57
-rw-r--r--tests/wifitests/src/com/android/server/wifi/WifiNetworkSuggestionsManagerTest.java12
-rw-r--r--tests/wifitests/src/com/android/server/wifi/hotspot2/PasspointManagerTest.java2
11 files changed, 222 insertions, 77 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;
+}
diff --git a/tests/wifitests/src/com/android/server/wifi/ClientModeImplTest.java b/tests/wifitests/src/com/android/server/wifi/ClientModeImplTest.java
index 727922e83..db4a2d515 100644
--- a/tests/wifitests/src/com/android/server/wifi/ClientModeImplTest.java
+++ b/tests/wifitests/src/com/android/server/wifi/ClientModeImplTest.java
@@ -543,7 +543,8 @@ public class ClientModeImplTest extends WifiBaseTest {
WifiCarrierInfoManager tu = new WifiCarrierInfoManager(mTelephonyManager,
mSubscriptionManager, mWifiInjector, mock(FrameworkFacade.class),
- mock(WifiContext.class), mock(WifiConfigStore.class), mock(Handler.class));
+ mock(WifiContext.class), mock(WifiConfigStore.class), mock(Handler.class),
+ mWifiMetrics);
mWifiCarrierInfoManager = spy(tu);
// static mocking
mSession = ExtendedMockito.mockitoSession().strictness(Strictness.LENIENT)
diff --git a/tests/wifitests/src/com/android/server/wifi/WifiCarrierInfoManagerTest.java b/tests/wifitests/src/com/android/server/wifi/WifiCarrierInfoManagerTest.java
index 28bffa149..2c1c2ec91 100644
--- a/tests/wifitests/src/com/android/server/wifi/WifiCarrierInfoManagerTest.java
+++ b/tests/wifitests/src/com/android/server/wifi/WifiCarrierInfoManagerTest.java
@@ -128,6 +128,7 @@ public class WifiCarrierInfoManagerTest extends WifiBaseTest {
@Mock AlertDialog.Builder mAlertDialogBuilder;
@Mock AlertDialog mAlertDialog;
@Mock WifiCarrierInfoManager.OnUserApproveCarrierListener mListener;
+ @Mock WifiMetrics mWifiMetrics;
private List<SubscriptionInfo> mSubInfoList;
@@ -176,7 +177,7 @@ public class WifiCarrierInfoManagerTest extends WifiBaseTest {
when(mWifiInjector.getWifiConfigManager()).thenReturn(mWifiConfigManager);
mWifiCarrierInfoManager = new WifiCarrierInfoManager(mTelephonyManager,
mSubscriptionManager, mWifiInjector, mFrameworkFacade, mContext, mWifiConfigStore,
- new Handler(mLooper.getLooper()));
+ new Handler(mLooper.getLooper()), mWifiMetrics);
ArgumentCaptor<ImsiPrivacyProtectionExemptionStoreData.DataSource>
imsiDataSourceArgumentCaptor =
ArgumentCaptor.forClass(ImsiPrivacyProtectionExemptionStoreData.DataSource.class);
@@ -1535,6 +1536,8 @@ public class WifiCarrierInfoManagerTest extends WifiBaseTest {
sendBroadcastForUserActionOnImsi(NOTIFICATION_USER_ALLOWED_CARRIER_INTENT_ACTION,
CARRIER_NAME, DATA_CARRIER_ID);
verify(mNotificationManger).cancel(SystemMessage.NOTE_NETWORK_SUGGESTION_AVAILABLE);
+ verify(mWifiMetrics).addUserApprovalCarrierUiReaction(
+ WifiCarrierInfoManager.ACTION_USER_ALLOWED_CARRIER, false);
validateUserApprovalDialog(CARRIER_NAME);
// Simulate user clicking on allow in the dialog.
@@ -1553,6 +1556,8 @@ public class WifiCarrierInfoManagerTest extends WifiBaseTest {
assertTrue(mWifiCarrierInfoManager
.hasUserApprovedImsiPrivacyExemptionForCarrier(DATA_CARRIER_ID));
verify(mListener).onUserAllowed(DATA_CARRIER_ID);
+ verify(mWifiMetrics).addUserApprovalCarrierUiReaction(
+ WifiCarrierInfoManager.ACTION_USER_ALLOWED_CARRIER, true);
}
@Test
@@ -1581,6 +1586,8 @@ public class WifiCarrierInfoManagerTest extends WifiBaseTest {
assertFalse(mWifiCarrierInfoManager
.hasUserApprovedImsiPrivacyExemptionForCarrier(DATA_CARRIER_ID));
verify(mListener, never()).onUserAllowed(DATA_CARRIER_ID);
+ verify(mWifiMetrics).addUserApprovalCarrierUiReaction(
+ WifiCarrierInfoManager.ACTION_USER_DISALLOWED_CARRIER, false);
}
@Test
@@ -1601,6 +1608,8 @@ public class WifiCarrierInfoManagerTest extends WifiBaseTest {
//Simulate user dismissal the notification
sendBroadcastForUserActionOnImsi(NOTIFICATION_USER_DISMISSED_INTENT_ACTION,
CARRIER_NAME, DATA_SUBID);
+ verify(mWifiMetrics).addUserApprovalCarrierUiReaction(
+ WifiCarrierInfoManager.ACTION_USER_DISMISS, false);
reset(mNotificationManger);
// No Notification is active, should send notification again.
mWifiCarrierInfoManager.sendImsiProtectionExemptionNotificationIfRequired(DATA_CARRIER_ID);
@@ -1637,6 +1646,8 @@ public class WifiCarrierInfoManagerTest extends WifiBaseTest {
sendBroadcastForUserActionOnImsi(NOTIFICATION_USER_ALLOWED_CARRIER_INTENT_ACTION,
CARRIER_NAME, DATA_SUBID);
verify(mNotificationManger).cancel(SystemMessage.NOTE_NETWORK_SUGGESTION_AVAILABLE);
+ verify(mWifiMetrics).addUserApprovalCarrierUiReaction(
+ WifiCarrierInfoManager.ACTION_USER_ALLOWED_CARRIER, false);
validateUserApprovalDialog(CARRIER_NAME);
// Simulate user clicking on disallow in the dialog.
@@ -1655,6 +1666,8 @@ public class WifiCarrierInfoManagerTest extends WifiBaseTest {
assertFalse(mWifiCarrierInfoManager
.hasUserApprovedImsiPrivacyExemptionForCarrier(DATA_CARRIER_ID));
verify(mListener, never()).onUserAllowed(DATA_CARRIER_ID);
+ verify(mWifiMetrics).addUserApprovalCarrierUiReaction(
+ WifiCarrierInfoManager.ACTION_USER_DISALLOWED_CARRIER, true);
}
@Test
@@ -1675,6 +1688,8 @@ public class WifiCarrierInfoManagerTest extends WifiBaseTest {
sendBroadcastForUserActionOnImsi(NOTIFICATION_USER_ALLOWED_CARRIER_INTENT_ACTION,
CARRIER_NAME, DATA_SUBID);
verify(mNotificationManger).cancel(SystemMessage.NOTE_NETWORK_SUGGESTION_AVAILABLE);
+ verify(mWifiMetrics).addUserApprovalCarrierUiReaction(
+ WifiCarrierInfoManager.ACTION_USER_ALLOWED_CARRIER, false);
validateUserApprovalDialog(CARRIER_NAME);
// Simulate user clicking on dismissal in the dialog.
@@ -1698,6 +1713,8 @@ public class WifiCarrierInfoManagerTest extends WifiBaseTest {
assertFalse(mWifiCarrierInfoManager
.hasUserApprovedImsiPrivacyExemptionForCarrier(DATA_CARRIER_ID));
verify(mListener, never()).onUserAllowed(DATA_CARRIER_ID);
+ verify(mWifiMetrics).addUserApprovalCarrierUiReaction(
+ WifiCarrierInfoManager.ACTION_USER_DISMISS, true);
}
@Test
diff --git a/tests/wifitests/src/com/android/server/wifi/WifiConfigManagerTest.java b/tests/wifitests/src/com/android/server/wifi/WifiConfigManagerTest.java
index 9e9ae1cb4..d1e476b6f 100644
--- a/tests/wifitests/src/com/android/server/wifi/WifiConfigManagerTest.java
+++ b/tests/wifitests/src/com/android/server/wifi/WifiConfigManagerTest.java
@@ -230,7 +230,8 @@ public class WifiConfigManagerTest extends WifiBaseTest {
mWifiCarrierInfoManager = new WifiCarrierInfoManager(mTelephonyManager,
mSubscriptionManager, mWifiInjector, mock(FrameworkFacade.class),
- mock(WifiContext.class), mock(WifiConfigStore.class), mock(Handler.class));
+ mock(WifiContext.class), mock(WifiConfigStore.class), mock(Handler.class),
+ mWifiMetrics);
mLruConnectionTracker = new LruConnectionTracker(100, mContext);
createWifiConfigManager();
mWifiConfigManager.addOnNetworkUpdateListener(mWcmListener);
diff --git a/tests/wifitests/src/com/android/server/wifi/WifiMetricsTest.java b/tests/wifitests/src/com/android/server/wifi/WifiMetricsTest.java
index fc9dfba0a..04730bbe3 100644
--- a/tests/wifitests/src/com/android/server/wifi/WifiMetricsTest.java
+++ b/tests/wifitests/src/com/android/server/wifi/WifiMetricsTest.java
@@ -4180,9 +4180,6 @@ public class WifiMetricsTest extends WifiBaseTest {
add(60);
}});
- mWifiMetrics.addNetworkSuggestionUserApprovalAppUiReaction(1, true);
- mWifiMetrics.addNetworkSuggestionUserApprovalAppUiReaction(2, false);
-
mWifiMetrics.incrementNetworkSuggestionUserRevokePermission();
mWifiMetrics.incrementNetworkSuggestionUserRevokePermission();
@@ -4211,24 +4208,60 @@ public class WifiMetricsTest extends WifiBaseTest {
assertEquals(WifiMetricsProto.WifiNetworkSuggestionApiLog.TYPE_NON_PRIVILEGED,
mDecodedProto.wifiNetworkSuggestionApiLog.appCountPerType[2].appType);
assertEquals(3, mDecodedProto.wifiNetworkSuggestionApiLog.appCountPerType[2].count);
+ }
+
+ /**
+ * Test the generation of 'UserReactionToApprovalUiEvent' message.
+ */
+ @Test
+ public void testUserReactionToApprovalUiEvent() throws Exception {
+ mWifiMetrics.addUserApprovalSuggestionAppUiReaction(1, true);
+ mWifiMetrics.addUserApprovalSuggestionAppUiReaction(2, false);
+
+ mWifiMetrics.addUserApprovalCarrierUiReaction(
+ WifiCarrierInfoManager.ACTION_USER_ALLOWED_CARRIER, true);
+ mWifiMetrics.addUserApprovalCarrierUiReaction(
+ WifiCarrierInfoManager.ACTION_USER_DISMISS, false);
+ mWifiMetrics.addUserApprovalCarrierUiReaction(
+ WifiCarrierInfoManager.ACTION_USER_DISALLOWED_CARRIER, false);
+
+ dumpProtoAndDeserialize();
assertEquals(2,
- mDecodedProto.wifiNetworkSuggestionApiLog.userApprovalAppUiReaction.length);
- assertEquals(WifiMetricsProto.WifiNetworkSuggestionApiLog.ACTION_ALLOWED,
- mDecodedProto.wifiNetworkSuggestionApiLog.userApprovalAppUiReaction[0]
+ mDecodedProto.userReactionToApprovalUiEvent.userApprovalAppUiReaction.length);
+ assertEquals(WifiMetricsProto.UserReactionToApprovalUiEvent.ACTION_ALLOWED,
+ mDecodedProto.userReactionToApprovalUiEvent.userApprovalAppUiReaction[0]
.userAction);
assertEquals(true,
- mDecodedProto.wifiNetworkSuggestionApiLog.userApprovalAppUiReaction[0]
+ mDecodedProto.userReactionToApprovalUiEvent.userApprovalAppUiReaction[0]
.isDialog);
- assertEquals(WifiMetricsProto.WifiNetworkSuggestionApiLog.ACTION_DISALLOWED,
- mDecodedProto.wifiNetworkSuggestionApiLog.userApprovalAppUiReaction[1]
+ assertEquals(WifiMetricsProto.UserReactionToApprovalUiEvent.ACTION_DISALLOWED,
+ mDecodedProto.userReactionToApprovalUiEvent.userApprovalAppUiReaction[1]
.userAction);
assertEquals(false,
- mDecodedProto.wifiNetworkSuggestionApiLog.userApprovalAppUiReaction[1]
+ mDecodedProto.userReactionToApprovalUiEvent.userApprovalAppUiReaction[1]
.isDialog);
- assertEquals(2, mDecodedProto.wifiNetworkSuggestionApiLog
- .userRevokeAppSuggestionPermission);
+ assertEquals(3,
+ mDecodedProto.userReactionToApprovalUiEvent.userApprovalCarrierUiReaction.length);
+ assertEquals(WifiMetricsProto.UserReactionToApprovalUiEvent.ACTION_ALLOWED,
+ mDecodedProto.userReactionToApprovalUiEvent.userApprovalCarrierUiReaction[0]
+ .userAction);
+ assertEquals(true,
+ mDecodedProto.userReactionToApprovalUiEvent.userApprovalCarrierUiReaction[0]
+ .isDialog);
+ assertEquals(WifiMetricsProto.UserReactionToApprovalUiEvent.ACTION_DISMISS,
+ mDecodedProto.userReactionToApprovalUiEvent.userApprovalCarrierUiReaction[1]
+ .userAction);
+ assertEquals(false,
+ mDecodedProto.userReactionToApprovalUiEvent.userApprovalCarrierUiReaction[1]
+ .isDialog);
+ assertEquals(WifiMetricsProto.UserReactionToApprovalUiEvent.ACTION_DISALLOWED,
+ mDecodedProto.userReactionToApprovalUiEvent.userApprovalCarrierUiReaction[2]
+ .userAction);
+ assertEquals(false,
+ mDecodedProto.userReactionToApprovalUiEvent.userApprovalCarrierUiReaction[2]
+ .isDialog);
}
private NetworkSelectionExperimentDecisions findUniqueNetworkSelectionExperimentDecisions(
diff --git a/tests/wifitests/src/com/android/server/wifi/WifiNetworkSuggestionsManagerTest.java b/tests/wifitests/src/com/android/server/wifi/WifiNetworkSuggestionsManagerTest.java
index dcf7453ed..897dca341 100644
--- a/tests/wifitests/src/com/android/server/wifi/WifiNetworkSuggestionsManagerTest.java
+++ b/tests/wifitests/src/com/android/server/wifi/WifiNetworkSuggestionsManagerTest.java
@@ -2270,7 +2270,7 @@ public class WifiNetworkSuggestionsManagerTest extends WifiBaseTest {
sendBroadcastForUserActionOnApp(
NOTIFICATION_USER_DISMISSED_INTENT_ACTION, TEST_PACKAGE_1, TEST_UID_1);
reset(mNotificationManger);
- verify(mWifiMetrics).addNetworkSuggestionUserApprovalAppUiReaction(
+ verify(mWifiMetrics).addUserApprovalSuggestionAppUiReaction(
WifiNetworkSuggestionsManager.ACTION_USER_DISMISS, false);
// Simulate finding the network in scan results.
mWifiNetworkSuggestionsManager.getNetworkSuggestionsForScanDetail(
@@ -2328,7 +2328,7 @@ public class WifiNetworkSuggestionsManagerTest extends WifiBaseTest {
// Verify config store interactions.
verify(mWifiConfigManager, times(2)).saveToStore(true);
assertTrue(mDataSource.hasNewDataToSerialize());
- verify(mWifiMetrics).addNetworkSuggestionUserApprovalAppUiReaction(
+ verify(mWifiMetrics).addUserApprovalSuggestionAppUiReaction(
WifiNetworkSuggestionsManager.ACTION_USER_ALLOWED_APP, false);
reset(mNotificationManger);
@@ -2380,7 +2380,7 @@ public class WifiNetworkSuggestionsManagerTest extends WifiBaseTest {
// Verify config store interactions.
verify(mWifiConfigManager, times(2)).saveToStore(true);
assertTrue(mDataSource.hasNewDataToSerialize());
- verify(mWifiMetrics).addNetworkSuggestionUserApprovalAppUiReaction(
+ verify(mWifiMetrics).addUserApprovalSuggestionAppUiReaction(
WifiNetworkSuggestionsManager.ACTION_USER_DISALLOWED_APP, false);
reset(mNotificationManger);
@@ -2550,7 +2550,7 @@ public class WifiNetworkSuggestionsManagerTest extends WifiBaseTest {
// Verify config store interactions.
verify(mWifiConfigManager, times(2)).saveToStore(true);
assertTrue(mDataSource.hasNewDataToSerialize());
- verify(mWifiMetrics).addNetworkSuggestionUserApprovalAppUiReaction(
+ verify(mWifiMetrics).addUserApprovalSuggestionAppUiReaction(
WifiNetworkSuggestionsManager.ACTION_USER_ALLOWED_APP, true);
// We should not resend the notification next time the network is found in scan results.
@@ -2596,7 +2596,7 @@ public class WifiNetworkSuggestionsManagerTest extends WifiBaseTest {
// Verify config store interactions.
verify(mWifiConfigManager, times(2)).saveToStore(true);
assertTrue(mDataSource.hasNewDataToSerialize());
- verify(mWifiMetrics).addNetworkSuggestionUserApprovalAppUiReaction(
+ verify(mWifiMetrics).addUserApprovalSuggestionAppUiReaction(
WifiNetworkSuggestionsManager.ACTION_USER_DISALLOWED_APP, true);
// Now trigger the app-ops callback to ensure we remove all of their suggestions.
@@ -2650,7 +2650,7 @@ public class WifiNetworkSuggestionsManagerTest extends WifiBaseTest {
// Verify no new config store or app-op interactions.
verify(mWifiConfigManager).saveToStore(true); // 1 already done for add
verify(mAppOpsManager, never()).setMode(any(), anyInt(), any(), anyInt());
- verify(mWifiMetrics).addNetworkSuggestionUserApprovalAppUiReaction(
+ verify(mWifiMetrics).addUserApprovalSuggestionAppUiReaction(
WifiNetworkSuggestionsManager.ACTION_USER_DISMISS, true);
// We should resend the notification next time the network is found in scan results.
diff --git a/tests/wifitests/src/com/android/server/wifi/hotspot2/PasspointManagerTest.java b/tests/wifitests/src/com/android/server/wifi/hotspot2/PasspointManagerTest.java
index e75cefcef..885cf87a3 100644
--- a/tests/wifitests/src/com/android/server/wifi/hotspot2/PasspointManagerTest.java
+++ b/tests/wifitests/src/com/android/server/wifi/hotspot2/PasspointManagerTest.java
@@ -230,7 +230,7 @@ public class PasspointManagerTest extends WifiBaseTest {
.thenReturn(mWifiNetworkSuggestionsManager);
mWifiCarrierInfoManager = new WifiCarrierInfoManager(mTelephonyManager,
mSubscriptionManager, mWifiInjector, mock(FrameworkFacade.class),
- mock(WifiContext.class), mWifiConfigStore, mock(Handler.class));
+ mock(WifiContext.class), mWifiConfigStore, mock(Handler.class), mWifiMetrics);
mLooper = new TestLooper();
mHandler = new Handler(mLooper.getLooper());
mManager = new PasspointManager(mContext, mWifiInjector, mHandler, mWifiNative,