WebView: defend against null array

This guards against iterating over a null array. This scenario should
never happen on user devices, however we know it can happen if you
install a trunk-staging build of the settings app on top of a nextfood
device configuration. This happens because of a flag mismatch
(updateServiceIpcWrapper is enabled in the trunk-staging app but the
service is not implemented by a nextfood platform build).

This is a low risk change since we know users cannot usually get into
this state.

Fixed: 391725109
Test: N/A - this bug is not possible in any configuration we test
Flag: EXEMPT bugfix
Change-Id: I654e0be5ad94e769cd8325ce5d20d241a4a13c13
This commit is contained in:
Nate Fischer
2025-03-18 14:11:55 -07:00
parent 4bc471f61e
commit c11576fe2d

View File

@@ -61,7 +61,7 @@ public class WebViewUpdateServiceWrapper {
* validity of a package is not dependent on whether the package is installed/enabled.
*/
public List<ApplicationInfo> getValidWebViewApplicationInfos(Context context) {
WebViewProviderInfo[] providers = null;
WebViewProviderInfo[] providers = new WebViewProviderInfo[0];
try {
if (android.webkit.Flags.updateServiceIpcWrapper()) {
providers = context.getSystemService(WebViewUpdateManager.class)