summaryrefslogtreecommitdiff
path: root/libs
diff options
context:
space:
mode:
authorQuang Luong <qal@google.com>2020-04-09 16:36:37 +0000
committerAndroid (Google) Code Review <android-gerrit@google.com>2020-04-09 16:36:37 +0000
commit1a1b2b8f0fa7231f76136632e4bdc8b674fbdb02 (patch)
tree4db7f4b9501ccc363b67a97a08eff524cd3dc1b7 /libs
parente452e6a22830d3ff9e1b86cd6437afcb8df3e4d7 (diff)
parent866a2bf1ee41cc991e1588088a3562d0ef7614a9 (diff)
Merge "[WifiTrackerLib] Display "Available via..." summary for suggestions" into rvc-dev
Diffstat (limited to 'libs')
-rw-r--r--libs/WifiTrackerLib/src/com/android/wifitrackerlib/StandardWifiEntry.java24
-rw-r--r--libs/WifiTrackerLib/src/com/android/wifitrackerlib/Utils.java8
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 "";
}