WebView implementation Dev setting: Show the version number after name
Show the package version of each WebView implementation after their package name in the WebView Implementation Dev Setting. Showing a package version is useful for debugging purposes. Bug: 35621558 Test: run make RunSettingsRoboTests Test: Ensure package version is shown in titles of items in WebView Implementation Dev Setting. Change-Id: If195dd87aebeac1783600b7c9f376ff8e791c3be
This commit is contained in:
@@ -21,7 +21,9 @@ import static android.provider.Settings.ACTION_WEBVIEW_SETTINGS;
|
||||
import android.app.Activity;
|
||||
import android.content.Intent;
|
||||
import android.content.pm.ApplicationInfo;
|
||||
import android.content.pm.PackageItemInfo;
|
||||
import android.content.pm.PackageInfo;
|
||||
import android.content.pm.PackageManager;
|
||||
import android.content.Context;
|
||||
import android.support.annotation.VisibleForTesting;
|
||||
import android.text.TextUtils;
|
||||
@@ -60,8 +62,8 @@ public class WebViewAppPicker extends DefaultAppPickerFragment {
|
||||
getWebViewUpdateServiceWrapper().getValidWebViewApplicationInfos(getContext());
|
||||
for (ApplicationInfo ai : pkgs) {
|
||||
packageInfoList.add(createDefaultAppInfo(ai,
|
||||
getDisabledReason(getWebViewUpdateServiceWrapper(),
|
||||
getContext(), ai.packageName)));
|
||||
getDisabledReason(getWebViewUpdateServiceWrapper(),
|
||||
getContext(), ai.packageName)));
|
||||
}
|
||||
return packageInfoList;
|
||||
}
|
||||
@@ -107,10 +109,26 @@ public class WebViewAppPicker extends DefaultAppPickerFragment {
|
||||
return MetricsEvent.WEBVIEW_IMPLEMENTATION;
|
||||
}
|
||||
|
||||
private static class WebViewAppInfo extends DefaultAppInfo {
|
||||
public WebViewAppInfo(PackageItemInfo packageItemInfo, String summary, boolean enabled) {
|
||||
super(packageItemInfo, summary, enabled);
|
||||
}
|
||||
|
||||
@Override
|
||||
public CharSequence loadLabel(PackageManager pm) {
|
||||
String versionName = "";
|
||||
try {
|
||||
versionName = pm.getPackageInfo(packageItemInfo.packageName, 0).versionName;
|
||||
} catch (PackageManager.NameNotFoundException e) {
|
||||
}
|
||||
return String.format("%s %s", super.loadLabel(pm), versionName);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@VisibleForTesting
|
||||
DefaultAppInfo createDefaultAppInfo(
|
||||
ApplicationInfo applicationInfo, String disabledReason) {
|
||||
return new DefaultAppInfo(applicationInfo, disabledReason,
|
||||
DefaultAppInfo createDefaultAppInfo(PackageItemInfo packageItemInfo, String disabledReason) {
|
||||
return new WebViewAppInfo(packageItemInfo, disabledReason,
|
||||
TextUtils.isEmpty(disabledReason) /* enabled */);
|
||||
}
|
||||
|
||||
|
Reference in New Issue
Block a user