diff options
author | TreeHugger Robot <treehugger-gerrit@google.com> | 2020-05-13 05:44:10 +0000 |
---|---|---|
committer | Automerger Merge Worker <android-build-automerger-merge-worker@system.gserviceaccount.com> | 2020-05-13 05:44:10 +0000 |
commit | 5dce925016cdb9958faf7828e076007595d13443 (patch) | |
tree | 41f7b0ae224b08ed9e19f08c7c73a4b035f0fcba /libs | |
parent | c16ea099626a7afe0d368cf68d1a1a61cff7c3b2 (diff) | |
parent | 963670b2d95f139f40a5f3b54545e0d0b3dac2b9 (diff) |
Merge "[WifiTrackerLib] Fix Saved Networks page showing "Saved by <package>"" into rvc-dev am: 963670b2d9
Change-Id: Iaa772cf58ed6f2b07c8d2c09b5e9de2a5f66c928
Diffstat (limited to 'libs')
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 ""; } } |