summaryrefslogtreecommitdiff
path: root/libs
diff options
context:
space:
mode:
authorQuang Luong <qal@google.com>2020-05-12 00:19:19 -0700
committerQuang Luong <qal@google.com>2020-05-12 14:50:11 -0700
commite719e79d35ce97b6f18860a4c3cd98e0fbd70157 (patch)
tree273042911aa72a45b628f522744f3485f33af611 /libs
parentddc1ace90c9e6450047f2ae29bf13fdb91890798 (diff)
[WifiTrackerLib] Fix Saved Networks page showing "Saved by <package>"
Fix Saved Networks mistakenly showing "Saved by <package>" for networks that do not have a valid app label to display. Bug: 156324411 Test: manual visual verification that the mistaken string does not appear in Saved Networks page Change-Id: Ife31f095bc318edc92be6b84575cdc938e185807
Diffstat (limited to 'libs')
-rw-r--r--libs/WifiTrackerLib/src/com/android/wifitrackerlib/PasspointWifiEntry.java14
-rw-r--r--libs/WifiTrackerLib/src/com/android/wifitrackerlib/StandardWifiEntry.java16
-rw-r--r--libs/WifiTrackerLib/src/com/android/wifitrackerlib/Utils.java11
3 files changed, 28 insertions, 13 deletions
diff --git a/libs/WifiTrackerLib/src/com/android/wifitrackerlib/PasspointWifiEntry.java b/libs/WifiTrackerLib/src/com/android/wifitrackerlib/PasspointWifiEntry.java
index 8b66fd5e8..ef17166b9 100644
--- a/libs/WifiTrackerLib/src/com/android/wifitrackerlib/PasspointWifiEntry.java
+++ b/libs/WifiTrackerLib/src/com/android/wifitrackerlib/PasspointWifiEntry.java
@@ -164,9 +164,14 @@ public class PasspointWifiEntry extends WifiEntry {
if (mWifiConfig != null && mWifiConfig.fromWifiNetworkSuggestion) {
String carrierName = getCarrierNameForSubId(mContext,
getSubIdForConfig(mContext, mWifiConfig));
+ String suggestorLabel = getAppLabel(mContext, mWifiConfig.creatorName);
+ if (TextUtils.isEmpty(suggestorLabel)) {
+ // Fall-back to the package name in case the app label is missing
+ suggestorLabel = mWifiConfig.creatorName;
+ }
sj.add(mContext.getString(R.string.available_via_app, carrierName != null
? carrierName
- : getAppLabel(mContext, mWifiConfig.creatorName)));
+ : suggestorLabel));
} else {
sj.add(mContext.getString(R.string.wifi_remembered));
}
@@ -215,9 +220,14 @@ public class PasspointWifiEntry extends WifiEntry {
String carrierName = mWifiConfig != null
? getCarrierNameForSubId(mContext, getSubIdForConfig(mContext, mWifiConfig))
: null;
+ String suggestorLabel = getAppLabel(mContext, mWifiConfig.creatorName);
+ if (TextUtils.isEmpty(suggestorLabel)) {
+ // Fall-back to the package name in case the app label is missing
+ suggestorLabel = mWifiConfig.creatorName;
+ }
return mContext.getString(R.string.connected_via_app, carrierName != null
? carrierName
- : getAppLabel(mContext, suggestionOrSpecifierPackageName));
+ : suggestorLabel);
}
String networkCapabilitiesinformation =
getCurrentNetworkCapabilitiesInformation(mContext, mNetworkCapabilities);
diff --git a/libs/WifiTrackerLib/src/com/android/wifitrackerlib/StandardWifiEntry.java b/libs/WifiTrackerLib/src/com/android/wifitrackerlib/StandardWifiEntry.java
index 5518a39bb..5a06c8f11 100644
--- a/libs/WifiTrackerLib/src/com/android/wifitrackerlib/StandardWifiEntry.java
+++ b/libs/WifiTrackerLib/src/com/android/wifitrackerlib/StandardWifiEntry.java
@@ -210,9 +210,13 @@ public class StandardWifiEntry extends WifiEntry {
if (isSuggestion()) {
String carrierName = getCarrierNameForSubId(mContext,
getSubIdForConfig(mContext, mWifiConfig));
+ String suggestorName = getAppLabel(mContext, mWifiConfig.creatorName);
+ if (TextUtils.isEmpty(suggestorName)) {
+ // Fall-back to the package name in case the app label is missing
+ suggestorName = mWifiConfig.creatorName;
+ }
sj.add(mContext.getString(R.string.available_via_app, carrierName != null
- ? carrierName
- : getAppLabel(mContext, mWifiConfig.creatorName)));
+ ? carrierName : suggestorName));
} else if (isSaved()) {
sj.add(mContext.getString(R.string.wifi_remembered));
}
@@ -270,9 +274,13 @@ public class StandardWifiEntry extends WifiEntry {
String carrierName = mWifiConfig != null
? getCarrierNameForSubId(mContext, getSubIdForConfig(mContext, mWifiConfig))
: null;
+ String suggestorName = getAppLabel(mContext, suggestionOrSpecifierPackageName);
+ if (TextUtils.isEmpty(suggestorName)) {
+ // Fall-back to the package name in case the app label is missing
+ suggestorName = mWifiConfig.creatorName;
+ }
return mContext.getString(R.string.connected_via_app, carrierName != null
- ? carrierName
- : getAppLabel(mContext, suggestionOrSpecifierPackageName));
+ ? carrierName : suggestorName);
}
String networkCapabilitiesinformation =
diff --git a/libs/WifiTrackerLib/src/com/android/wifitrackerlib/Utils.java b/libs/WifiTrackerLib/src/com/android/wifitrackerlib/Utils.java
index 1125e086c..62bbe0f96 100644
--- a/libs/WifiTrackerLib/src/com/android/wifitrackerlib/Utils.java
+++ b/libs/WifiTrackerLib/src/com/android/wifitrackerlib/Utils.java
@@ -369,9 +369,9 @@ class Utils {
}
/**
- * Get the app label for a suggestion/specifier package name.
+ * Get the app label for a suggestion/specifier package name, or an empty String if none exist
*/
- static CharSequence getAppLabel(Context context, String packageName) {
+ static String getAppLabel(Context context, String packageName) {
try {
String openWifiPackageName = Settings.Global.getString(context.getContentResolver(),
Settings.Global.USE_OPEN_WIFI_PACKAGE);
@@ -384,12 +384,9 @@ class Utils {
packageName,
0 /* flags */,
UserHandle.getUserId(UserHandle.USER_CURRENT));
- return appInfo.loadLabel(context.getPackageManager());
+ return appInfo.loadLabel(context.getPackageManager()).toString();
} catch (PackageManager.NameNotFoundException e) {
- // The packageName should come from a suggestion/specifier which is guaranteed to
- // have an associated app label. If there is a concurrency issue between the current
- // connection and the suggestion being removed, we should fall back to the packageName.
- return packageName;
+ return "";
}
}