Fix disabled WebView packages being shown as enabled in Dev Setting.
WebView packages that cannot be chosen as WebView implementation should be shown as disabled in the 'WebView Implementation' Dev Setting. Simplify the logic in DefaultAppInfo a little bit to avoid special-casing for the WebView Dev setting. Also add tests to ensure we are correctly disabling WebView packages in the Dev setting and showing their disabled-reasons. Bug: 35707106 Test: 'make RunSettingsRoboTests' Test: Ensure disabled WebView packages show up as being disabled in the 'WebView Implementation' Dev Setting. Change-Id: Ic2f5265c3451b6396e55b7bc29689c3d889ddb5e
This commit is contained in:
@@ -24,6 +24,7 @@ import android.content.pm.ApplicationInfo;
|
||||
import android.content.pm.PackageInfo;
|
||||
import android.content.Context;
|
||||
import android.support.annotation.VisibleForTesting;
|
||||
import android.text.TextUtils;
|
||||
|
||||
import com.android.internal.logging.nano.MetricsProto.MetricsEvent;
|
||||
import com.android.settings.R;
|
||||
@@ -58,7 +59,7 @@ public class WebViewAppPicker extends DefaultAppPickerFragment {
|
||||
List<ApplicationInfo> pkgs =
|
||||
getWebViewUpdateServiceWrapper().getValidWebViewApplicationInfos(getContext());
|
||||
for (ApplicationInfo ai : pkgs) {
|
||||
packageInfoList.add(new DefaultAppInfo(ai,
|
||||
packageInfoList.add(createDefaultAppInfo(ai,
|
||||
getDisabledReason(getWebViewUpdateServiceWrapper(),
|
||||
getContext(), ai.packageName)));
|
||||
}
|
||||
@@ -92,7 +93,6 @@ public class WebViewAppPicker extends DefaultAppPickerFragment {
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
private WebViewUpdateServiceWrapper createDefaultWebViewUpdateServiceWrapper() {
|
||||
return new WebViewUpdateServiceWrapper();
|
||||
}
|
||||
@@ -107,6 +107,13 @@ public class WebViewAppPicker extends DefaultAppPickerFragment {
|
||||
return MetricsEvent.WEBVIEW_IMPLEMENTATION;
|
||||
}
|
||||
|
||||
@VisibleForTesting
|
||||
DefaultAppInfo createDefaultAppInfo(
|
||||
ApplicationInfo applicationInfo, String disabledReason) {
|
||||
return new DefaultAppInfo(applicationInfo, disabledReason,
|
||||
TextUtils.isEmpty(disabledReason) /* enabled */);
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns the reason why a package cannot be used as WebView implementation.
|
||||
* This is either because of it being disabled, uninstalled, or hidden for any user.
|
||||
|
Reference in New Issue
Block a user