From 07969aeeab3a0caebef26d1b2921d53845101f56 Mon Sep 17 00:00:00 2001 From: Steven Liu Date: Fri, 23 Aug 2019 15:20:15 -0700 Subject: Change system language, passpoint R2 failed to connect The comparing of friendly names from AP are mismatched with subject names from OSU server certificate. it shouldn't use system default locale, the languages and names broadcasted by AP should be used. Bug: 139854572 Test: Change the device language to Chinese, connect to passpoint network; unit test. Change-Id: I7ac6dbc00c3701010d9643df46ac78a5de665876 --- .../server/wifi/hotspot2/OsuServerConnection.java | 20 +++++++++----------- .../server/wifi/hotspot2/PasspointProvisioner.java | 2 +- 2 files changed, 10 insertions(+), 12 deletions(-) (limited to 'service') diff --git a/service/java/com/android/server/wifi/hotspot2/OsuServerConnection.java b/service/java/com/android/server/wifi/hotspot2/OsuServerConnection.java index 94f584f72..92560932c 100644 --- a/service/java/com/android/server/wifi/hotspot2/OsuServerConnection.java +++ b/service/java/com/android/server/wifi/hotspot2/OsuServerConnection.java @@ -188,27 +188,25 @@ public class OsuServerConnection { * Validates the service provider by comparing its identities found in OSU Server cert * to the friendlyName obtained from ANQP exchange that is displayed to the user. * - * @param locale a {@link Locale} object used for matching the friendly name in - * subjectAltName section of the certificate along with - * {@param friendlyName}. - * @param friendlyName a string of the friendly name used for finding the same name in - * subjectAltName section of the certificate. + * @param friendlyNames the friendly names used for finding the same name in + * subjectAltName section of the certificate, which is a map of language + * codes from ISO-639 and names. * @return boolean true if friendlyName shows up as one of the identities in the cert */ - public boolean validateProvider(Locale locale, - String friendlyName) { + public boolean validateProvider( + Map friendlyNames) { - if (locale == null || TextUtils.isEmpty(friendlyName)) { + if (friendlyNames.size() == 0) { return false; } for (Pair identity : ServiceProviderVerifier.getProviderNames( mTrustManager.getProviderCert())) { - if (identity.first == null) continue; + if (identity.first == null || TextUtils.isEmpty(identity.second)) continue; // Compare the language code for ISO-639. - if (identity.first.getISO3Language().equals(locale.getISO3Language()) && - TextUtils.equals(identity.second, friendlyName)) { + if (TextUtils.equals(identity.second, + friendlyNames.get(identity.first.getISO3Language()))) { if (mVerboseLoggingEnabled) { Log.v(TAG, "OSU certificate is valid for " + identity.first.getISO3Language() + "/" + identity.second); diff --git a/service/java/com/android/server/wifi/hotspot2/PasspointProvisioner.java b/service/java/com/android/server/wifi/hotspot2/PasspointProvisioner.java index bdd035fe4..137d9fa19 100644 --- a/service/java/com/android/server/wifi/hotspot2/PasspointProvisioner.java +++ b/service/java/com/android/server/wifi/hotspot2/PasspointProvisioner.java @@ -366,7 +366,7 @@ public class PasspointProvisioner { return; } if (!mOsuServerConnection.validateProvider( - Locale.getDefault(), mOsuProvider.getFriendlyName())) { + mOsuProvider.getFriendlyNameList())) { Log.e(TAG, "OSU Server certificate does not have the one matched with the selected " + "Service Name: " -- cgit v1.2.3