diff options
author | Jan Nordqvist <jannq@google.com> | 2015-05-29 13:33:01 -0700 |
---|---|---|
committer | Vinit Deshpande <vinitd@google.com> | 2015-06-01 22:06:28 +0000 |
commit | 31891afce40b903ada9b24ec12e3648ae6aa27b2 (patch) | |
tree | 014e2468e6f0f139f3b93295e9d8e9dd4a1ac38a /service/java/com/android/server/wifi/hotspot2/omadm | |
parent | fce249dbb4390a13f61148680ffe9ade03d584b4 (diff) | |
download | android_frameworks_opt_net_wifi-31891afce40b903ada9b24ec12e3648ae6aa27b2.tar.gz android_frameworks_opt_net_wifi-31891afce40b903ada9b24ec12e3648ae6aa27b2.tar.bz2 android_frameworks_opt_net_wifi-31891afce40b903ada9b24ec12e3648ae6aa27b2.zip |
Minor fixes from comments.
Bug: 21306404
Bug: 21283355
Bug: 21171957
Fixed trust cert validation.
Fixed bad network history saving and reading.
Bug: 21022868
Bug in domain matcher, fixed some log levels.
Finished HS2.0/legacy network persistence consistency.
Change-Id: Ic93093a41dd87d70a386909bdea744b5810c7299
Diffstat (limited to 'service/java/com/android/server/wifi/hotspot2/omadm')
-rw-r--r-- | service/java/com/android/server/wifi/hotspot2/omadm/MOManager.java | 49 |
1 files changed, 45 insertions, 4 deletions
diff --git a/service/java/com/android/server/wifi/hotspot2/omadm/MOManager.java b/service/java/com/android/server/wifi/hotspot2/omadm/MOManager.java index 9869fa27f..bc49bd7d7 100644 --- a/service/java/com/android/server/wifi/hotspot2/omadm/MOManager.java +++ b/service/java/com/android/server/wifi/hotspot2/omadm/MOManager.java @@ -132,7 +132,7 @@ public class MOManager { } public Map<String, HomeSP> getLoadedSPs() { - return mSPs; + return Collections.unmodifiableMap(mSPs); } public List<HomeSP> loadAllSPs() throws IOException { @@ -206,13 +206,18 @@ public class MOManager { return sp; } - public void saveAllSps(Collection<HomeSP> homeSPs) throws IOException { + public HomeSP getHomeSP(String fqdn) { + return mSPs.get(fqdn); + } + + public void saveAllSps(Map<String, HomeSP> homeSPs) throws IOException { Map<String, HomeSP> obsolete = new HashMap<>(mSPs); + List<HomeSP> resultSet = new ArrayList<>(homeSPs.size()); int additions = 0; - for (HomeSP newSP : homeSPs) { + for (HomeSP newSP : homeSPs.values()) { HomeSP existing = obsolete.remove(newSP.getFQDN()); if (existing == null) { resultSet.add(newSP); @@ -226,7 +231,7 @@ public class MOManager { if (!obsolete.isEmpty() || additions > 0) { Log.d(Utils.hs2LogTag(getClass()), String.format("MO change: %s -> %s: %s", - fqdnList(mSPs.values()), fqdnList(homeSPs), fqdnList(resultSet))); + fqdnList(mSPs.values()), fqdnList(homeSPs.values()), fqdnList(resultSet))); rewriteMO(resultSet, mSPs, mPpsFile); } else { @@ -234,6 +239,26 @@ public class MOManager { } } + public void addSP(HomeSP homeSP) throws IOException { + if (mSPs.containsKey(homeSP.getFQDN())) { + Log.d(Utils.hs2LogTag(getClass()), "HS20 profile for " + + homeSP.getFQDN() + " already exists"); + return; + } + Log.d(Utils.hs2LogTag(getClass()), "Adding new HS20 profile for " + homeSP.getFQDN()); + mSPs.put(homeSP.getFQDN(), homeSP); + writeMO(mSPs.values(), mPpsFile); + } + + public void removeSP(String fqdn) throws IOException { + if (mSPs.remove(fqdn) == null) { + Log.d(Utils.hs2LogTag(getClass()), "No HS20 profile to delete for " + fqdn); + return; + } + Log.d(Utils.hs2LogTag(getClass()), "Deleting HS20 profile for " + fqdn); + writeMO(mSPs.values(), mPpsFile); + } + public void updateAndSaveAllSps(Collection<HomeSP> homeSPs) throws IOException { boolean dirty = false; @@ -293,6 +318,22 @@ public class MOManager { } } + private static void writeMO(Collection<HomeSP> homeSPs, File f) throws IOException { + + OMAConstructed ppsNode = new OMAConstructed(null, TAG_PerProviderSubscription, null); + int instance = 0; + for (HomeSP homeSP : homeSPs) { + buildHomeSPTree(homeSP, ppsNode, instance++); + } + + MOTree tree = new MOTree(OMAConstants.LOC_PPS + ":1.0", "1.2", ppsNode); + try (BufferedOutputStream out = + new BufferedOutputStream(new FileOutputStream(f, false))) { + tree.marshal(out); + out.flush(); + } + } + private static String fqdnList(Collection<HomeSP> sps) { StringBuilder sb = new StringBuilder(); boolean first = true; |