Strip names out of externally supplied WorkSources to WifiManager (b/10710007).
Change-Id: I69bd7ce9e942c2f9327415b2821d805e1b50a1a4
diff --git a/core/java/android/os/WorkSource.java b/core/java/android/os/WorkSource.java
index b79bdee..30d535b 100644
--- a/core/java/android/os/WorkSource.java
+++ b/core/java/android/os/WorkSource.java
@@ -97,6 +97,16 @@
}
/**
+ * Clear names from this WorkSource. Uids are left intact.
+ *
+ * <p>Useful when combining with another WorkSource that doesn't have names.
+ * @hide
+ */
+ public void clearNames() {
+ mNames = null;
+ }
+
+ /**
* Clear this WorkSource to be empty.
*/
public void clear() {
diff --git a/services/java/com/android/server/wifi/WifiService.java b/services/java/com/android/server/wifi/WifiService.java
index 46f100e..5a24ebb 100644
--- a/services/java/com/android/server/wifi/WifiService.java
+++ b/services/java/com/android/server/wifi/WifiService.java
@@ -342,6 +342,9 @@
enforceChangePermission();
if (workSource != null) {
enforceWorkSourcePermission();
+ // WifiManager currently doesn't use names, so need to clear names out of the
+ // supplied WorkSource to allow future WorkSource combining.
+ workSource.clearNames();
}
mWifiStateMachine.startScan(Binder.getCallingUid(), workSource);
}