summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-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 "";
}
}