diff options
author | Quang Luong <qal@google.com> | 2020-04-02 15:37:33 -0700 |
---|---|---|
committer | Quang Luong <qal@google.com> | 2020-04-08 14:45:46 -0700 |
commit | 866a2bf1ee41cc991e1588088a3562d0ef7614a9 (patch) | |
tree | f3f3fe70161f185ef596f402f21787ccede32b56 /libs | |
parent | edbd063552857947211a0cae78ffc57ce707f8dd (diff) |
[WifiTrackerLib] Display "Available via..." summary for suggestions
Suggestion networks should display "Available via..." in their summary,
followed by the carrier name if it is a carrier suggested network, or
the name of the app that suggested it.
Bug: 153029289
Test: manual visual verification of wifi picker with suggestions
installed
Change-Id: I620e412d0daa631376e6ef455d77049d1aa954f2
Diffstat (limited to 'libs')
-rw-r--r-- | libs/WifiTrackerLib/src/com/android/wifitrackerlib/StandardWifiEntry.java | 24 | ||||
-rw-r--r-- | libs/WifiTrackerLib/src/com/android/wifitrackerlib/Utils.java | 8 |
2 files changed, 26 insertions, 6 deletions
diff --git a/libs/WifiTrackerLib/src/com/android/wifitrackerlib/StandardWifiEntry.java b/libs/WifiTrackerLib/src/com/android/wifitrackerlib/StandardWifiEntry.java index 5f8d44ddd..a6c322656 100644 --- a/libs/WifiTrackerLib/src/com/android/wifitrackerlib/StandardWifiEntry.java +++ b/libs/WifiTrackerLib/src/com/android/wifitrackerlib/StandardWifiEntry.java @@ -22,14 +22,17 @@ import static androidx.core.util.Preconditions.checkNotNull; import static com.android.wifitrackerlib.Utils.getAppLabel; import static com.android.wifitrackerlib.Utils.getAppLabelForSavedNetwork; +import static com.android.wifitrackerlib.Utils.getAppLabelForWifiConfiguration; import static com.android.wifitrackerlib.Utils.getAutoConnectDescription; import static com.android.wifitrackerlib.Utils.getBestScanResultByLevel; +import static com.android.wifitrackerlib.Utils.getCarrierNameForSubId; import static com.android.wifitrackerlib.Utils.getCurrentNetworkCapabilitiesInformation; import static com.android.wifitrackerlib.Utils.getDisconnectedStateDescription; import static com.android.wifitrackerlib.Utils.getMeteredDescription; import static com.android.wifitrackerlib.Utils.getNetworkDetailedState; import static com.android.wifitrackerlib.Utils.getSecurityTypeFromWifiConfiguration; import static com.android.wifitrackerlib.Utils.getSpeedDescription; +import static com.android.wifitrackerlib.Utils.getSubIdForConfig; import static com.android.wifitrackerlib.Utils.getVerboseLoggingDescription; import android.content.Context; @@ -194,8 +197,17 @@ public class StandardWifiEntry extends WifiEntry { if (TextUtils.isEmpty(disconnectDescription)) { if (concise) { sj.add(mContext.getString(R.string.wifi_disconnected)); - } else if (!mForSavedNetworksPage && isSaved()) { - sj.add(mContext.getString(R.string.wifi_remembered)); + } else if (!mForSavedNetworksPage) { + // Summary for unconnected suggested network + if (mWifiConfig != null && mWifiConfig.fromWifiNetworkSuggestion) { + String carrierName = getCarrierNameForSubId(mContext, + getSubIdForConfig(mContext, mWifiConfig)); + sj.add(mContext.getString(R.string.available_via_app, carrierName != null + ? carrierName + : getAppLabelForWifiConfiguration(mContext, mWifiConfig))); + } else if (isSaved()) { + sj.add(mContext.getString(R.string.wifi_remembered)); + } } } else { sj.add(disconnectDescription); @@ -242,8 +254,12 @@ public class StandardWifiEntry extends WifiEntry { final String suggestionOrSpecifierPackageName = mWifiInfo != null ? mWifiInfo.getRequestingPackageName() : null; if (!TextUtils.isEmpty(suggestionOrSpecifierPackageName)) { - return mContext.getString(R.string.connected_via_app, - getAppLabel(mContext, suggestionOrSpecifierPackageName)); + String carrierName = mWifiConfig != null + ? getCarrierNameForSubId(mContext, getSubIdForConfig(mContext, mWifiConfig)) + : null; + return mContext.getString(R.string.connected_via_app, carrierName != null + ? carrierName + : getAppLabel(mContext, suggestionOrSpecifierPackageName)); } String networkCapabilitiesinformation = diff --git a/libs/WifiTrackerLib/src/com/android/wifitrackerlib/Utils.java b/libs/WifiTrackerLib/src/com/android/wifitrackerlib/Utils.java index 47fc9ed57..382fe02c4 100644 --- a/libs/WifiTrackerLib/src/com/android/wifitrackerlib/Utils.java +++ b/libs/WifiTrackerLib/src/com/android/wifitrackerlib/Utils.java @@ -307,8 +307,12 @@ class Utils { static CharSequence getAppLabelForSavedNetwork(@NonNull Context context, @NonNull WifiEntry wifiEntry) { - final WifiConfiguration config = wifiEntry.getWifiConfiguration(); - if (context == null || wifiEntry == null || config == null) { + return getAppLabelForWifiConfiguration(context, wifiEntry.getWifiConfiguration()); + } + + static CharSequence getAppLabelForWifiConfiguration(@NonNull Context context, + @NonNull WifiConfiguration config) { + if (context == null || config == null) { return ""; } |