diff options
author | Quang Luong <qal@google.com> | 2020-04-09 16:47:34 +0000 |
---|---|---|
committer | Automerger Merge Worker <android-build-automerger-merge-worker@system.gserviceaccount.com> | 2020-04-09 16:47:34 +0000 |
commit | 16c0cec50d205f89a489c1961b3c7dc88f370644 (patch) | |
tree | 3ac3dbf1e61a385093fde81f96c66de35a0d348f /libs | |
parent | e99ff09a0d921ea4f4e9787f4a92c284d8056baf (diff) | |
parent | 1a1b2b8f0fa7231f76136632e4bdc8b674fbdb02 (diff) |
Merge "[WifiTrackerLib] Display "Available via..." summary for suggestions" into rvc-dev am: 1a1b2b8f0f
Change-Id: I1f08bef1e8d18713bfc9d1191fa48b5f7499c597
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 ""; } |