Search in sources :

Example 11 with I18Name

use of com.android.anqp.I18Name in project android_frameworks_base by crdroidandroid.

the class OSUInfo method getServiceDescription.

public String getServiceDescription(Locale locale) {
    List<ScoreEntry<String>> scoreList = new ArrayList<>();
    for (I18Name service : mOSUProvider.getServiceDescriptions()) {
        if (locale == null || service.getLocale().equals(locale)) {
            return service.getText();
        }
        scoreList.add(new ScoreEntry<>(service.getText(), languageScore(service.getLanguage(), locale)));
    }
    Collections.sort(scoreList);
    return scoreList.isEmpty() ? null : scoreList.iterator().next().getData();
}
Also used : I18Name(com.android.anqp.I18Name) ArrayList(java.util.ArrayList)

Example 12 with I18Name

use of com.android.anqp.I18Name in project platform_frameworks_base by android.

the class SPVerifier method checkName.

private void checkName(Asn1Constructed altName) throws IOException {
    Map<String, I18Name> friendlyNames = new HashMap<>();
    for (Asn1Object name : altName.getChildren()) {
        if (name.getAsn1Class() == Asn1Class.Context && name.getTag() == OtherName) {
            Asn1Constructed otherName = (Asn1Constructed) name;
            Iterator<Asn1Object> children = otherName.getChildren().iterator();
            if (children.hasNext()) {
                Asn1Object oidObject = children.next();
                if (OidMappings.sIdWfaHotspotFriendlyName.equals(oidObject) && children.hasNext()) {
                    Asn1Constructed value = castObject(children.next(), Asn1Constructed.class);
                    String text = castObject(value.getChildren().iterator().next(), Asn1String.class).getString();
                    I18Name friendlyName = new I18Name(text);
                    friendlyNames.put(friendlyName.getLanguage(), friendlyName);
                }
            }
        }
    }
    Log.d(OSUManager.TAG, "Friendly names: " + friendlyNames.values());
    for (I18Name osuName : mOSUInfo.getOSUProvider().getNames()) {
        I18Name friendlyName = friendlyNames.get(osuName.getLanguage());
        if (!osuName.equals(friendlyName)) {
            throw new IOException("Friendly name '" + osuName + " not in certificate");
        }
    }
}
Also used : Asn1Constructed(com.android.hotspot2.asn1.Asn1Constructed) HashMap(java.util.HashMap) I18Name(com.android.anqp.I18Name) Asn1String(com.android.hotspot2.asn1.Asn1String) Asn1String(com.android.hotspot2.asn1.Asn1String) IOException(java.io.IOException) Asn1Object(com.android.hotspot2.asn1.Asn1Object)

Example 13 with I18Name

use of com.android.anqp.I18Name in project android_frameworks_base by AOSPA.

the class SPVerifier method checkName.

private void checkName(Asn1Constructed altName) throws IOException {
    Map<String, I18Name> friendlyNames = new HashMap<>();
    for (Asn1Object name : altName.getChildren()) {
        if (name.getAsn1Class() == Asn1Class.Context && name.getTag() == OtherName) {
            Asn1Constructed otherName = (Asn1Constructed) name;
            Iterator<Asn1Object> children = otherName.getChildren().iterator();
            if (children.hasNext()) {
                Asn1Object oidObject = children.next();
                if (OidMappings.sIdWfaHotspotFriendlyName.equals(oidObject) && children.hasNext()) {
                    Asn1Constructed value = castObject(children.next(), Asn1Constructed.class);
                    String text = castObject(value.getChildren().iterator().next(), Asn1String.class).getString();
                    I18Name friendlyName = new I18Name(text);
                    friendlyNames.put(friendlyName.getLanguage(), friendlyName);
                }
            }
        }
    }
    Log.d(OSUManager.TAG, "Friendly names: " + friendlyNames.values());
    for (I18Name osuName : mOSUInfo.getOSUProvider().getNames()) {
        I18Name friendlyName = friendlyNames.get(osuName.getLanguage());
        if (!osuName.equals(friendlyName)) {
            throw new IOException("Friendly name '" + osuName + " not in certificate");
        }
    }
}
Also used : Asn1Constructed(com.android.hotspot2.asn1.Asn1Constructed) HashMap(java.util.HashMap) I18Name(com.android.anqp.I18Name) Asn1String(com.android.hotspot2.asn1.Asn1String) Asn1String(com.android.hotspot2.asn1.Asn1String) IOException(java.io.IOException) Asn1Object(com.android.hotspot2.asn1.Asn1Object)

Example 14 with I18Name

use of com.android.anqp.I18Name in project android_frameworks_base by crdroidandroid.

the class SPVerifier method checkName.

private void checkName(Asn1Constructed altName) throws IOException {
    Map<String, I18Name> friendlyNames = new HashMap<>();
    for (Asn1Object name : altName.getChildren()) {
        if (name.getAsn1Class() == Asn1Class.Context && name.getTag() == OtherName) {
            Asn1Constructed otherName = (Asn1Constructed) name;
            Iterator<Asn1Object> children = otherName.getChildren().iterator();
            if (children.hasNext()) {
                Asn1Object oidObject = children.next();
                if (OidMappings.sIdWfaHotspotFriendlyName.equals(oidObject) && children.hasNext()) {
                    Asn1Constructed value = castObject(children.next(), Asn1Constructed.class);
                    String text = castObject(value.getChildren().iterator().next(), Asn1String.class).getString();
                    I18Name friendlyName = new I18Name(text);
                    friendlyNames.put(friendlyName.getLanguage(), friendlyName);
                }
            }
        }
    }
    Log.d(OSUManager.TAG, "Friendly names: " + friendlyNames.values());
    for (I18Name osuName : mOSUInfo.getOSUProvider().getNames()) {
        I18Name friendlyName = friendlyNames.get(osuName.getLanguage());
        if (!osuName.equals(friendlyName)) {
            throw new IOException("Friendly name '" + osuName + " not in certificate");
        }
    }
}
Also used : Asn1Constructed(com.android.hotspot2.asn1.Asn1Constructed) HashMap(java.util.HashMap) I18Name(com.android.anqp.I18Name) Asn1String(com.android.hotspot2.asn1.Asn1String) Asn1String(com.android.hotspot2.asn1.Asn1String) IOException(java.io.IOException) Asn1Object(com.android.hotspot2.asn1.Asn1Object)

Example 15 with I18Name

use of com.android.anqp.I18Name in project android_frameworks_base by crdroidandroid.

the class OSUInfo method getName.

public String getName(Locale locale) {
    List<ScoreEntry<String>> scoreList = new ArrayList<>();
    for (I18Name name : mOSUProvider.getNames()) {
        if (locale == null || name.getLocale().equals(locale)) {
            return name.getText();
        }
        scoreList.add(new ScoreEntry<String>(name.getText(), languageScore(name.getLanguage(), locale)));
    }
    Collections.sort(scoreList);
    return scoreList.isEmpty() ? null : scoreList.iterator().next().getData();
}
Also used : I18Name(com.android.anqp.I18Name) ArrayList(java.util.ArrayList)

Aggregations

I18Name (com.android.anqp.I18Name)15 ArrayList (java.util.ArrayList)10 Asn1Constructed (com.android.hotspot2.asn1.Asn1Constructed)5 Asn1Object (com.android.hotspot2.asn1.Asn1Object)5 Asn1String (com.android.hotspot2.asn1.Asn1String)5 IOException (java.io.IOException)5 HashMap (java.util.HashMap)5