From 6def4475cc62f9205892cd5edf85212b51342e3e Mon Sep 17 00:00:00 2001 From: althafvly Date: Mon, 2 Jun 2025 20:06:35 +0530 Subject: [PATCH] Browser: add support for our webapk --- .../Browser-Add-support-for-eOS-webapk.patch | 45 ++++++++++++ ...heck-for-webapk-and-system-signature.patch | 68 +++++++++++++++++++ build/e_patches_list.txt | 2 + 3 files changed, 115 insertions(+) create mode 100644 build/e_patches/Browser-Add-support-for-eOS-webapk.patch create mode 100644 build/e_patches/Browser-Check-for-webapk-and-system-signature.patch diff --git a/build/e_patches/Browser-Add-support-for-eOS-webapk.patch b/build/e_patches/Browser-Add-support-for-eOS-webapk.patch new file mode 100644 index 00000000..8ee86f39 --- /dev/null +++ b/build/e_patches/Browser-Add-support-for-eOS-webapk.patch @@ -0,0 +1,45 @@ +From 3977a8ca23a92ca27040e7c4e090ae110314f4d8 Mon Sep 17 00:00:00 2001 +From: althafvly +Date: Thu, 29 May 2025 19:49:11 +0530 +Subject: Browser: Add support for /e/OS webapk + +--- + .../components/webapk/lib/client/WebApkValidator.java | 4 +++- + .../components/webapk/lib/common/WebApkConstants.java | 1 + + 2 files changed, 4 insertions(+), 1 deletion(-) + +diff --git a/components/webapk/android/libs/client/src/org/chromium/components/webapk/lib/client/WebApkValidator.java b/components/webapk/android/libs/client/src/org/chromium/components/webapk/lib/client/WebApkValidator.java +index 3c01521024120..8bd8467c8b4eb 100644 +--- a/components/webapk/android/libs/client/src/org/chromium/components/webapk/lib/client/WebApkValidator.java ++++ b/components/webapk/android/libs/client/src/org/chromium/components/webapk/lib/client/WebApkValidator.java +@@ -6,6 +6,7 @@ package org.chromium.components.webapk.lib.client; + + import static org.chromium.build.NullUtil.assumeNonNull; + import static org.chromium.components.webapk.lib.common.WebApkConstants.WEBAPK_PACKAGE_PREFIX; ++import static org.chromium.components.webapk.lib.common.WebApkConstants.E_WEBAPK_PACKAGE_PREFIX; + import static org.chromium.components.webapk.lib.common.WebApkMetaDataKeys.SCOPE; + import static org.chromium.components.webapk.lib.common.WebApkMetaDataKeys.START_URL; + import static org.chromium.components.webapk.lib.common.WebApkMetaDataKeys.WEB_MANIFEST_URL; +@@ -422,7 +423,8 @@ public class WebApkValidator { + private static boolean verifyV1WebApk(PackageInfo packageInfo, String webappPackageName) { + if (packageInfo.signatures == null + || packageInfo.signatures.length != 2 +- || !webappPackageName.startsWith(WEBAPK_PACKAGE_PREFIX)) { ++ || !(webappPackageName.startsWith(WEBAPK_PACKAGE_PREFIX) ++ || webappPackageName.startsWith(E_WEBAPK_PACKAGE_PREFIX))) { + return false; + } + for (Signature signature : packageInfo.signatures) { +diff --git a/components/webapk/android/libs/common/src/org/chromium/components/webapk/lib/common/WebApkConstants.java b/components/webapk/android/libs/common/src/org/chromium/components/webapk/lib/common/WebApkConstants.java +index dc63f37ad40b1..d83407803058b 100644 +--- a/components/webapk/android/libs/common/src/org/chromium/components/webapk/lib/common/WebApkConstants.java ++++ b/components/webapk/android/libs/common/src/org/chromium/components/webapk/lib/common/WebApkConstants.java +@@ -10,4 +10,5 @@ import org.chromium.build.annotations.NullMarked; + @NullMarked + public final class WebApkConstants { + public static final String WEBAPK_PACKAGE_PREFIX = "org.chromium.webapk"; ++ public static final String E_WEBAPK_PACKAGE_PREFIX = "foundation.e.webapk"; + } +-- +2.34.1 + diff --git a/build/e_patches/Browser-Check-for-webapk-and-system-signature.patch b/build/e_patches/Browser-Check-for-webapk-and-system-signature.patch new file mode 100644 index 00000000..1b9faa26 --- /dev/null +++ b/build/e_patches/Browser-Check-for-webapk-and-system-signature.patch @@ -0,0 +1,68 @@ +From 74cc04e57f5810393700f050c7874b0d68b6af12 Mon Sep 17 00:00:00 2001 +From: althafvly +Date: Thu, 29 May 2025 17:12:54 +0530 +Subject: Browser: Check for webapk and system signature + +--- + .../webapk/lib/client/WebApkValidator.java | 32 +++++++++++++++++++ + 1 file changed, 32 insertions(+) + +diff --git a/components/webapk/android/libs/client/src/org/chromium/components/webapk/lib/client/WebApkValidator.java b/components/webapk/android/libs/client/src/org/chromium/components/webapk/lib/client/WebApkValidator.java +index 5f63e80bc1a2e..3c01521024120 100644 +--- a/components/webapk/android/libs/client/src/org/chromium/components/webapk/lib/client/WebApkValidator.java ++++ b/components/webapk/android/libs/client/src/org/chromium/components/webapk/lib/client/WebApkValidator.java +@@ -65,6 +65,8 @@ public class WebApkValidator { + private static @Nullable PublicKey sCommentSignedPublicKey; + private static boolean sOverrideValidation; + ++ private static final String BROWSER_PACKAGE_NAME = "foundation.e.browser"; ++ + @IntDef({ + ValidationResult.FAILURE, + ValidationResult.V1_WEB_APK, +@@ -340,12 +342,42 @@ public class WebApkValidator { + + return ValidationResult.MAPS_LITE; + } ++ if (isSignedTrusted(packageInfo, context)) { ++ return ValidationResult.COMMENT_SIGNED; ++ } + if (verifyCommentSignedWebApk(packageInfo)) { + return ValidationResult.COMMENT_SIGNED; + } + return ValidationResult.FAILURE; + } + ++ public static boolean isSignedTrusted(PackageInfo packageInfo, Context context) { ++ try { ++ if (packageInfo == null || packageInfo.signatures == null) { ++ return false; ++ } ++ ++ PackageInfo browserPackageInfo = context.getPackageManager().getPackageInfo( ++ BROWSER_PACKAGE_NAME, PackageManager.GET_SIGNATURES); ++ ++ if (browserPackageInfo == null || browserPackageInfo.signatures == null) { ++ return false; ++ } ++ ++ for (Signature sig1 : packageInfo.signatures) { ++ for (Signature sig2 : browserPackageInfo.signatures) { ++ if (sig1.equals(sig2)) { ++ return true; ++ } ++ } ++ } ++ } catch (Exception e) { ++ Log.e(TAG, "Exception while comparing signatures", e); ++ } ++ ++ return false; ++ } ++ + /** + * @param url A Url that might launch a WebApk. + * @param applicationPackage The package of the WebApk to restrict the launch to. +-- +2.34.1 + diff --git a/build/e_patches_list.txt b/build/e_patches_list.txt index c11a4f68..71e35a56 100644 --- a/build/e_patches_list.txt +++ b/build/e_patches_list.txt @@ -65,3 +65,5 @@ Migrate-to-murena-search-from-spot.patch updater-disable-updater-pings.patch Disable-Component-Updates.patch Browser-Move-to-Murena-Qwant-from-QwanteSpot.patch +Browser-Check-for-webapk-and-system-signature.patch +Browser-Add-support-for-eOS-webapk.patch -- GitLab