use of android.net.wifi.hotspot2.pps.HomeSp in project android_frameworks_base by crdroidandroid.
the class MOManager method modifySP.
public HomeSP modifySP(HomeSP homeSP, Collection<MOData> mods, OSUManager osuManager) throws IOException {
Log.d(OSUManager.TAG, "modifying SP: " + mods);
MOTree moTree;
int ppsMods = 0;
int updateIdentifier = 0;
try (BufferedInputStream in = new BufferedInputStream(new FileInputStream(mPpsFile))) {
moTree = MOTree.unmarshal(in);
// moTree is PPS/?/provider-data
OMAConstructed targetTree = findTargetTree(moTree, homeSP.getFQDN());
if (targetTree == null) {
throw new IOException("Failed to find PPS tree for " + homeSP.getFQDN());
}
OMAConstructed instance = getInstanceNode(targetTree);
for (MOData mod : mods) {
LinkedList<String> tailPath = getTailPath(mod.getBaseURI(), TAG_PerProviderSubscription);
OMAConstructed modRoot = mod.getMOTree().getRoot();
if (tailPath.getFirst().equals(TAG_UpdateIdentifier)) {
updateIdentifier = getInteger(modRoot.getChildren().iterator().next());
OMANode oldUdi = targetTree.getChild(TAG_UpdateIdentifier);
if (getInteger(oldUdi) != updateIdentifier) {
ppsMods++;
}
if (oldUdi != null) {
targetTree.replaceNode(oldUdi, modRoot.getChild(TAG_UpdateIdentifier));
} else {
targetTree.addChild(modRoot.getChild(TAG_UpdateIdentifier));
}
} else {
// Drop the instance
tailPath.removeFirst();
OMANode current = instance.getListValue(tailPath.iterator());
if (current == null) {
throw new IOException("No previous node for " + tailPath + " in " + homeSP.getFQDN());
}
for (OMANode newNode : modRoot.getChildren()) {
// newNode is something like Credential
// current is the same existing node
OMANode old = current.getParent().replaceNode(current, newNode);
ppsMods++;
}
}
}
}
writeMO(moTree, mPpsFile, osuManager);
if (ppsMods == 0) {
// HomeSP not modified.
return null;
}
// Return a new rebuilt HomeSP
List<HomeSP> sps = buildSPs(moTree);
if (sps != null) {
for (HomeSP sp : sps) {
if (sp.getFQDN().equals(homeSP.getFQDN())) {
return sp;
}
}
} else {
throw new OMAException("Failed to build HomeSP");
}
return null;
}
use of android.net.wifi.hotspot2.pps.HomeSp in project android_frameworks_base by crdroidandroid.
the class OSUManager method deauth.
public void deauth(long bssid, boolean ess, int delay, String url) throws MalformedURLException {
Log.d(TAG, String.format("De-auth imminent on %s, delay %ss to '%s'", ess ? "ess" : "bss", delay, url));
mWifiNetworkAdapter.setHoldoffTime(delay * Constants.MILLIS_IN_A_SEC, ess);
HomeSP homeSP = mWifiNetworkAdapter.getCurrentSP();
String spName = homeSP != null ? homeSP.getFriendlyName() : "unknown";
mAppBridge.showDeauth(spName, ess, delay, url);
}
use of android.net.wifi.hotspot2.pps.HomeSp in project platform_frameworks_base by android.
the class MOManager method fqdnList.
private static String fqdnList(Collection<HomeSP> sps) {
StringBuilder sb = new StringBuilder();
boolean first = true;
for (HomeSP sp : sps) {
if (first) {
first = false;
} else {
sb.append(", ");
}
sb.append(sp.getFQDN());
}
return sb.toString();
}
use of android.net.wifi.hotspot2.pps.HomeSp in project platform_frameworks_base by android.
the class MOManager method addSP.
public HomeSP addSP(MOTree instanceTree, OSUManager osuManager) throws IOException {
List<HomeSP> spList = buildSPs(instanceTree);
if (spList.size() != 1) {
throw new OMAException("Expected exactly one HomeSP, got " + spList.size());
}
HomeSP sp = spList.iterator().next();
String fqdn = sp.getFQDN();
if (mSPs.put(fqdn, sp) != null) {
throw new OMAException("SP " + fqdn + " already exists");
}
OMAConstructed pps = (OMAConstructed) instanceTree.getRoot().getChild(TAG_PerProviderSubscription);
try {
addSP(pps, osuManager);
} catch (FileNotFoundException fnfe) {
MOTree tree = new MOTree(instanceTree.getUrn(), instanceTree.getDtdRev(), instanceTree.getRoot());
writeMO(tree, mPpsFile, osuManager);
}
return sp;
}
use of android.net.wifi.hotspot2.pps.HomeSp in project platform_frameworks_base by android.
the class OSUManager method deauth.
public void deauth(long bssid, boolean ess, int delay, String url) throws MalformedURLException {
Log.d(TAG, String.format("De-auth imminent on %s, delay %ss to '%s'", ess ? "ess" : "bss", delay, url));
mWifiNetworkAdapter.setHoldoffTime(delay * Constants.MILLIS_IN_A_SEC, ess);
HomeSP homeSP = mWifiNetworkAdapter.getCurrentSP();
String spName = homeSP != null ? homeSP.getFriendlyName() : "unknown";
mAppBridge.showDeauth(spName, ess, delay, url);
}
Aggregations