diff options
author | TreeHugger Robot <treehugger-gerrit@google.com> | 2020-05-13 06:00:20 +0000 |
---|---|---|
committer | Automerger Merge Worker <android-build-automerger-merge-worker@system.gserviceaccount.com> | 2020-05-13 06:00:20 +0000 |
commit | 850149af67e6bfc46b990ca3daae31967ea62646 (patch) | |
tree | d136b741a58a98e2cfa01f364934868fa2032512 /libs | |
parent | fa786b55f344df0beb69bae8d227c59ca6aa41e0 (diff) | |
parent | 5dce925016cdb9958faf7828e076007595d13443 (diff) |
Merge "[WifiTrackerLib] Fix Saved Networks page showing "Saved by <package>"" into rvc-dev am: 963670b2d9 am: 5dce925016
Change-Id: Ieb43c5d91e20b6517a610ff33f4c56171240d806
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 ""; } } |