diff options
author | TreeHugger Robot <treehugger-gerrit@google.com> | 2020-08-10 21:53:57 +0000 |
---|---|---|
committer | Android (Google) Code Review <android-gerrit@google.com> | 2020-08-10 21:53:57 +0000 |
commit | 5f0cfd680826a539c862772a5c864b52f14c25ac (patch) | |
tree | b0205abd72582a634f12a2e442db4eafc91a19f3 /libs | |
parent | 8b4c38fad28348588becfbc7b9a4b3c06b4d21e5 (diff) | |
parent | 6ae159b62a595ca7dc4e121be4df175d15b49014 (diff) |
Merge "[WifiTrackerLib] Use SSID as title for Osu entries with no friendly name" into rvc-qpr-dev
Diffstat (limited to 'libs')
-rw-r--r-- | libs/WifiTrackerLib/src/com/android/wifitrackerlib/OsuWifiEntry.java | 33 |
1 files changed, 24 insertions, 9 deletions
diff --git a/libs/WifiTrackerLib/src/com/android/wifitrackerlib/OsuWifiEntry.java b/libs/WifiTrackerLib/src/com/android/wifitrackerlib/OsuWifiEntry.java index 134ceef96..b1d7d4ae1 100644 --- a/libs/WifiTrackerLib/src/com/android/wifitrackerlib/OsuWifiEntry.java +++ b/libs/WifiTrackerLib/src/com/android/wifitrackerlib/OsuWifiEntry.java @@ -24,6 +24,7 @@ import static com.android.wifitrackerlib.WifiEntry.ConnectCallback.CONNECT_STATU import android.annotation.MainThread; import android.content.Context; import android.net.NetworkInfo; +import android.net.Uri; import android.net.wifi.ScanResult; import android.net.wifi.WifiConfiguration; import android.net.wifi.WifiInfo; @@ -60,11 +61,12 @@ class OsuWifiEntry extends WifiEntry { @NonNull private final String mKey; @NonNull private final Context mContext; @NonNull private OsuProvider mOsuProvider; + private String mSsid; private String mOsuStatusString; private boolean mIsAlreadyProvisioned = false; /** - * Create n OsuWifiEntry with the associated OsuProvider + * Create an OsuWifiEntry with the associated OsuProvider */ OsuWifiEntry(@NonNull Context context, @NonNull Handler callbackHandler, @NonNull OsuProvider osuProvider, @@ -87,7 +89,18 @@ class OsuWifiEntry extends WifiEntry { @Override public String getTitle() { - return mOsuProvider.getFriendlyName(); + final String friendlyName = mOsuProvider.getFriendlyName(); + if (!TextUtils.isEmpty(friendlyName)) { + return friendlyName; + } + if (!TextUtils.isEmpty(mSsid)) { + return mSsid; + } + final Uri serverUri = mOsuProvider.getServerUri(); + if (serverUri != null) { + return serverUri.toString(); + } + return ""; } @Override @@ -105,8 +118,7 @@ class OsuWifiEntry extends WifiEntry { @Override public String getSsid() { - // TODO(b/70983952): Fill this method in in case we need the SSID for verbose logging - return ""; + return mSsid; } @Override @@ -267,10 +279,13 @@ class OsuWifiEntry extends WifiEntry { } final ScanResult bestScanResult = getBestScanResultByLevel(scanResults); - if (getConnectedState() == CONNECTED_STATE_DISCONNECTED) { - mLevel = bestScanResult != null - ? mWifiManager.calculateSignalLevel(bestScanResult.level) - : WIFI_LEVEL_UNREACHABLE; + if (bestScanResult != null) { + mSsid = bestScanResult.SSID; + if (getConnectedState() == CONNECTED_STATE_DISCONNECTED) { + mLevel = mWifiManager.calculateSignalLevel(bestScanResult.level); + } + } else { + mLevel = WIFI_LEVEL_UNREACHABLE; } notifyOnUpdated(); } @@ -336,7 +351,7 @@ class OsuWifiEntry extends WifiEntry { case OSU_STATUS_WAITING_FOR_REDIRECT_RESPONSE: newStatusString = String.format(mContext.getString( R.string.osu_opening_provider), - mOsuProvider.getFriendlyName()); + getTitle()); break; case OSU_STATUS_REDIRECT_RESPONSE_RECEIVED: case OSU_STATUS_SECOND_SOAP_EXCHANGE: |