Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Unverified Commit d20a3d90 authored by LuK1337's avatar LuK1337 Committed by Michael Bestas
Browse files

webkit: SystemImpl: Filter out unavailable providers

Change-Id: Ibb70503caeeeabd35dbb0e9c54223e306b3dbdca
parent e60b2615
Loading
Loading
Loading
Loading
+13 −1
Original line number Diff line number Diff line
@@ -49,6 +49,7 @@ import org.xmlpull.v1.XmlPullParserException;

import java.io.IOException;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.Collections;
import java.util.List;

@@ -150,7 +151,9 @@ public class SystemImpl implements SystemInterface {
     * */
    @Override
    public WebViewProviderInfo[] getWebViewPackages() {
        return mWebViewProviderPackages;
        return Arrays.stream(mWebViewProviderPackages)
                .filter(x -> isProviderAvailable(x.packageName))
                .toArray(WebViewProviderInfo[]::new);
    }

    public long getFactoryPackageVersion(String packageName) throws NameNotFoundException {
@@ -159,6 +162,15 @@ public class SystemImpl implements SystemInterface {
                .getLongVersionCode();
    }

    private boolean isProviderAvailable(String packageName) {
        try {
            getFactoryPackageVersion(packageName);
            return true;
        } catch (NameNotFoundException e) {
            return false;
        }
    }

    /**
     * Reads all signatures at the current depth (within the current provider) from the XML parser.
     */