From dc6361c58a4eb2e7dd931ffe1cc0fb5129f004c9 Mon Sep 17 00:00:00 2001 From: Peter Qiu Date: Tue, 15 Nov 2016 08:52:54 -0800 Subject: hotspot2: maintain a copy of PasspointConfiguration in PasspointProvider This avoids the Passpoint configuration maintained in PasspointProvider from being updated by others. Bug: 32714562 Test: frameworks/opt/net/wifi/tests/wifitests/runtests.sh Change-Id: I7101ae0c1bcf70585343e6da5608d7fe1267e689 --- service/java/com/android/server/wifi/hotspot2/PasspointManager.java | 4 ---- .../java/com/android/server/wifi/hotspot2/PasspointProvider.java | 6 ++++-- 2 files changed, 4 insertions(+), 6 deletions(-) (limited to 'service') diff --git a/service/java/com/android/server/wifi/hotspot2/PasspointManager.java b/service/java/com/android/server/wifi/hotspot2/PasspointManager.java index 2344440f2..3e668a76d 100644 --- a/service/java/com/android/server/wifi/hotspot2/PasspointManager.java +++ b/service/java/com/android/server/wifi/hotspot2/PasspointManager.java @@ -156,8 +156,6 @@ public class PasspointManager { mProviders.remove(existingProvider.getConfig().homeSp.fqdn); } - // TODO(b/32714562): create/use a copy of configuration to avoid others from modifying it, - // since others might still have reference to it? mProviders.put(config.homeSp.fqdn, new PasspointProvider(config)); // TODO(b/31065385): Persist updated providers configuration to the persistent storage. @@ -195,8 +193,6 @@ public class PasspointManager { List configs = new ArrayList<>(); for (Map.Entry entry : mProviders.entrySet()) { - // TODO(zqiu): return a copy of the configuration instead, to prevent others from - // modifying it? configs.add(entry.getValue().getConfig()); } return configs; diff --git a/service/java/com/android/server/wifi/hotspot2/PasspointProvider.java b/service/java/com/android/server/wifi/hotspot2/PasspointProvider.java index 2cf8c9f68..9c38ac725 100644 --- a/service/java/com/android/server/wifi/hotspot2/PasspointProvider.java +++ b/service/java/com/android/server/wifi/hotspot2/PasspointProvider.java @@ -26,10 +26,12 @@ public class PasspointProvider { private final PasspointConfiguration mConfig; public PasspointProvider(PasspointConfiguration config) { - mConfig = config; + // Maintain a copy of the configuration to avoid it being updated by others. + mConfig = new PasspointConfiguration(config); } public PasspointConfiguration getConfig() { - return mConfig; + // Return a copy of the configuration to avoid it being updated by others. + return new PasspointConfiguration(mConfig); } } -- cgit v1.2.3