diff options
author | TreeHugger Robot <treehugger-gerrit@google.com> | 2020-04-21 19:32:33 +0000 |
---|---|---|
committer | Android (Google) Code Review <android-gerrit@google.com> | 2020-04-21 19:32:33 +0000 |
commit | a6153ba33006c65b5507f847d7a5b847ebef001d (patch) | |
tree | 82267d827d77e6af9963ec1f8bf31c54f87e955f /service | |
parent | e4fce8a805927c19dbbf2fc6e0ff41017ae1000f (diff) | |
parent | 98b20b3a66d83c71befac7788a32268d2f2b9114 (diff) |
Merge changes from topic "userActionEventMetric" into rvc-dev
* changes:
Add UserActionEvent for disconnect
Add UserActionEvent for connect
Add UserActionEvent for allowAutoJoin
Diffstat (limited to 'service')
4 files changed, 47 insertions, 16 deletions
diff --git a/service/java/com/android/server/wifi/WifiConfigManager.java b/service/java/com/android/server/wifi/WifiConfigManager.java index 0fb7745f2..209044a65 100644 --- a/service/java/com/android/server/wifi/WifiConfigManager.java +++ b/service/java/com/android/server/wifi/WifiConfigManager.java @@ -2689,12 +2689,13 @@ public class WifiConfigManager { * @param network Input can be SSID or FQDN. And caller must ensure that the SSID passed thru * this API matched the WifiConfiguration.SSID rules, and thus be surrounded by * quotes. + * uid UID of the calling process. */ - public void userTemporarilyDisabledNetwork(String network) { + public void userTemporarilyDisabledNetwork(String network, int uid) { mUserTemporarilyDisabledList.add(network, USER_DISCONNECT_NETWORK_BLOCK_EXPIRY_MS); - Log.d(TAG, "Temporarily disable network: " + network + " num=" + Log.d(TAG, "Temporarily disable network: " + network + " uid=" + uid + " num=" + mUserTemporarilyDisabledList.size()); - removeUserChoiceFromDisabledNetwork(network); + removeUserChoiceFromDisabledNetwork(network, uid); } /** @@ -2708,9 +2709,13 @@ public class WifiConfigManager { } private void removeUserChoiceFromDisabledNetwork( - @NonNull String network) { + @NonNull String network, int uid) { for (WifiConfiguration config : getInternalConfiguredNetworks()) { if (TextUtils.equals(config.SSID, network) || TextUtils.equals(config.FQDN, network)) { + if (mWifiPermissionsUtil.checkNetworkSettingsPermission(uid)) { + mWifiInjector.getWifiMetrics().logUserActionEvent( + UserActionEvent.EVENT_DISCONNECT_WIFI, config.networkId); + } removeConnectChoiceFromAllNetworks(config.getKey()); } } diff --git a/service/java/com/android/server/wifi/WifiServiceImpl.java b/service/java/com/android/server/wifi/WifiServiceImpl.java index 6e339044a..e6e5f2b36 100644 --- a/service/java/com/android/server/wifi/WifiServiceImpl.java +++ b/service/java/com/android/server/wifi/WifiServiceImpl.java @@ -112,7 +112,7 @@ import com.android.internal.annotations.VisibleForTesting; import com.android.internal.util.AsyncChannel; import com.android.server.wifi.hotspot2.PasspointManager; import com.android.server.wifi.hotspot2.PasspointProvider; -import com.android.server.wifi.proto.nano.WifiMetricsProto; +import com.android.server.wifi.proto.nano.WifiMetricsProto.UserActionEvent; import com.android.server.wifi.util.ApConfigUtil; import com.android.server.wifi.util.ExternalCallbackTracker; import com.android.server.wifi.util.RssiUtil; @@ -2552,7 +2552,16 @@ public class WifiServiceImpl extends BaseWifiService { } // even for Suggestion, modify the current ephemeral configuration so that // existing configuration auto-connection is updated correctly - mWifiConfigManager.allowAutojoin(netId, choice); + if (choice != config.allowAutojoin) { + mWifiConfigManager.allowAutojoin(netId, choice); + // do not log this metrics for passpoint networks again here since it's already + // logged in PasspointManager. + if (!config.isPasspoint()) { + mWifiMetrics.logUserActionEvent(choice + ? UserActionEvent.EVENT_CONFIGURE_AUTO_CONNECT_ON + : UserActionEvent.EVENT_CONFIGURE_AUTO_CONNECT_OFF, netId); + } + } }); } @@ -3051,7 +3060,8 @@ public class WifiServiceImpl extends BaseWifiService { return; } mLog.info("disableEphemeralNetwork uid=%").c(Binder.getCallingUid()).flush(); - mWifiThreadRunner.post(() -> mWifiConfigManager.userTemporarilyDisabledNetwork(network)); + mWifiThreadRunner.post(() -> mWifiConfigManager.userTemporarilyDisabledNetwork(network, + Binder.getCallingUid())); } private final BroadcastReceiver mReceiver = new BroadcastReceiver() { @@ -4062,12 +4072,15 @@ public class WifiServiceImpl extends BaseWifiService { @Override public void connect(WifiConfiguration config, int netId, IBinder binder, @Nullable IActionListener callback, int callbackIdentifier) { - if (!isPrivileged(Binder.getCallingPid(), Binder.getCallingUid())) { + int uid = Binder.getCallingUid(); + if (!isPrivileged(Binder.getCallingPid(), uid)) { throw new SecurityException(TAG + ": Permission denied"); } - mLog.info("connect uid=%").c(Binder.getCallingUid()).flush(); - mClientModeImpl.connect( - config, netId, binder, callback, callbackIdentifier, Binder.getCallingUid()); + mLog.info("connect uid=%").c(uid).flush(); + mClientModeImpl.connect(config, netId, binder, callback, callbackIdentifier, uid); + if (mWifiPermissionsUtil.checkNetworkSettingsPermission(uid)) { + mWifiMetrics.logUserActionEvent(UserActionEvent.EVENT_MANUAL_CONNECT, netId); + } } /** @@ -4099,8 +4112,7 @@ public class WifiServiceImpl extends BaseWifiService { if (mWifiPermissionsUtil.checkNetworkSettingsPermission(uid)) { // It's important to log this metric before the actual forget executes because // the netId becomes invalid after the forget operation. - mWifiMetrics.logUserActionEvent(WifiMetricsProto.UserActionEvent.EVENT_FORGET_WIFI, - netId); + mWifiMetrics.logUserActionEvent(UserActionEvent.EVENT_FORGET_WIFI, netId); } mClientModeImpl.forget(netId, binder, callback, callbackIdentifier, uid); } diff --git a/service/java/com/android/server/wifi/hotspot2/PasspointManager.java b/service/java/com/android/server/wifi/hotspot2/PasspointManager.java index ba89bce2c..7ccca0625 100644 --- a/service/java/com/android/server/wifi/hotspot2/PasspointManager.java +++ b/service/java/com/android/server/wifi/hotspot2/PasspointManager.java @@ -629,7 +629,12 @@ public class PasspointManager { Log.e(TAG, "Config doesn't exist"); return false; } - provider.setAutojoinEnabled(enableAutojoin); + if (provider.setAutojoinEnabled(enableAutojoin)) { + mWifiMetrics.logUserActionEvent(enableAutojoin + ? UserActionEvent.EVENT_CONFIGURE_AUTO_CONNECT_ON + : UserActionEvent.EVENT_CONFIGURE_AUTO_CONNECT_OFF, + provider.isFromSuggestion(), true); + } mWifiConfigManager.saveToStore(true); return true; } @@ -640,7 +645,12 @@ public class PasspointManager { // FQDN provided, loop through all profiles with matching FQDN for (PasspointProvider provider : passpointProviders) { if (TextUtils.equals(provider.getConfig().getHomeSp().getFqdn(), fqdn)) { - provider.setAutojoinEnabled(enableAutojoin); + if (provider.setAutojoinEnabled(enableAutojoin)) { + mWifiMetrics.logUserActionEvent(enableAutojoin + ? UserActionEvent.EVENT_CONFIGURE_AUTO_CONNECT_ON + : UserActionEvent.EVENT_CONFIGURE_AUTO_CONNECT_OFF, + provider.isFromSuggestion(), true); + } found = true; } } diff --git a/service/java/com/android/server/wifi/hotspot2/PasspointProvider.java b/service/java/com/android/server/wifi/hotspot2/PasspointProvider.java index 45fa39502..9174534c7 100644 --- a/service/java/com/android/server/wifi/hotspot2/PasspointProvider.java +++ b/service/java/com/android/server/wifi/hotspot2/PasspointProvider.java @@ -212,9 +212,13 @@ public class PasspointProvider { /** * Enable/disable the auto-join configuration of the corresponding passpoint configuration. + * + * @return true if the setting has changed */ - public void setAutojoinEnabled(boolean autoJoinEnabled) { + public boolean setAutojoinEnabled(boolean autoJoinEnabled) { + boolean changed = mConfig.isAutojoinEnabled() != autoJoinEnabled; mConfig.setAutojoinEnabled(autoJoinEnabled); + return changed; } public boolean isAutojoinEnabled() { |