Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

build a magisk module as well; also some minor fixes: #8

Merged
merged 6 commits into from
Dec 21, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
17 changes: 12 additions & 5 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,11 +2,13 @@

In order for Bromite SystemWebView to be [installed](https://github.com/bromite/bromite/wiki/Installing-SystemWebView), it must be one of the supported webviews hardcoded in the framework package. Since ROMs typically don't include Bromite SystemWebView among them, the community has developed some methods that allow the framework to be patched in order to include it.

This package makes use of a [resource overlay](https://source.android.com/docs/core/architecture/rros) to replace the list of hardcoded webviews with one that also includes the Bromite WebView. I personally find this method more straightforward and elegant, as it does not require root access nor the tedious process of installing Magisk modules or patching the system framework itself manually — if anything breaks the package can simply be removed. Moreover, the WebView itself does not need to be installed as a system app and has no potential risk of breaking SafetyNet.
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The wording here should not be modified: root access and Magisk is still not required. This change should be dropped.

Copy link
Contributor Author

@infinity0 infinity0 Dec 12, 2022

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This paragraph is about the resource overlay, whereas how to install the overlay is a separate issue. So I think it's clearer to discuss what types of root access is required, in a different paragraph.

In fact, all installation methods require some type of root access. It is misleading from a security perspective to claim any of these methods "do not require [any type of] root access". More precisely, I think what you mean is that the custom recovery method means you don't require root access on your main system. This is fair, and I've amended the wording to say this, in a paragraph further below. But it is misleading to unconditionally say it "does not require root" with no other qualifiers - when I run adb sideload in custom recovery, this is effectively giving your script root access to my system, it modifies the system partitions.

Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

You are right, what I meant was that it does not require a rooted device, so I would suggest replacing

it does not require root access

with

it does not require a rooted device

while also keeping the mention about not needing Magisk. To reach a sort of compromise between our conflicting views about Magisk, I would suggest adding a paragraph below this line mentioning that if keeping Magisk for customisation purposes is the top-most priority for the user and or if there isn't any space available on the partition a Magisk module is included for convenience only. Please also mention that I do not endorse Magisk, eventually linking to this Reddit comment.

I am very skeptical about this addition though.

This package makes use of a [resource overlay](https://source.android.com/docs/core/architecture/rros) to replace the list of hardcoded webviews with one that also includes the Bromite WebView. This method is more straightforward and elegant, as it does not require a rooted device nor the tedious process of installing Magisk modules or patching the system framework itself manually — if anything breaks the package can simply be removed. Moreover, the WebView itself does not need to be installed as a system app and has no potential risk of breaking SafetyNet — e.g. you can install it directly from F-Droid.

Some users have experienced issues with this installation process, so an overlay packaged as a [Magisk module](#magisk) is also provided. It is included for convenience only, and undergoes less frequent testing as the main developer does not endorse Magisk. The officially-endorsed and tested installation method still remains [installing via recovery](#installation).

![The WebView implementation settings with the Bromite SystemWebView Overlay installed](screenshot.png)

Although this method should work on all Android versions that support Bromite and it's WebView, **currently testing has only been done on LineageOS 19.1 for MicroG based on Android 12.1**.
Although this method should work on all Android versions that support Bromite and its WebView, **currently testing has only been done on LineageOS 19.1 for MicroG based on Android 12.1**.

## Prerequisites

Expand Down Expand Up @@ -59,6 +61,14 @@ To ensure that the package is installed for both profiles install the package vi
* If everything is ok, you should see the following message:
`org.bromite.webview is NOT installed.`

### Magisk

`BromiteSystemWebViewMagisk.zip` can be installed directly as a Magisk module. Simply copy it on your device, then install it via the normal Magisk UI.

Its main use case is for when you have Magisk already installed, where it works around an issue where some ROMs — in particular MicroG ROMs — do not have enough reserved partition space to install addons. This makes the previous installation options fail, sometimes in non-obvious ways. (Details in arovlad/bromite-webview-overlay#5 and lineageos4microg/docker-lineage-cicd#358)

It performs steps similar to the above, i.e. installs `treble-overlay-bromite-webview.apk` into `/vendor/overlay`, but as a Magisk module. The overlay is performed dynamically by Magisk at boot time, instead of directly modifying the vendor partition (until the next system update overwrites these changes). The OTA survival script is therefore not needed, as Magisk modules are not overwritten by system updates.

## Building

The following dependencies are required:
Expand All @@ -76,6 +86,3 @@ Alternatively, you can read a more in-depth guide [here](https://github.com/phhu
## Credits

* [Pierre-Hugues Husson](https://github.com/phhusson) for the guide and toolkit



35 changes: 24 additions & 11 deletions build.sh
Original file line number Diff line number Diff line change
@@ -1,22 +1,35 @@
#!/bin/bash
set -e

if [ ! -f build/build.sh ]; then
echo "Downloading toolkit"
mv .git .git.bak &> /dev/null
git init &> /dev/null
git remote add origin https://github.com/phhusson/vendor_hardware_overlay.git &> /dev/null
git fetch --depth=1 &> /dev/null
git checkout origin/pie build &> /dev/null
rm -f -r .git
mv .git.bak .git &> /dev/null
build/build.sh
echo "Building flashable package"
git clone --depth=1 https://github.com/phhusson/vendor_hardware_overlay.git
( cd vendor_hardware_overlay && git checkout origin/pie build && mv build .. )
fi

echo "Building overlay APK"
( cd build && ./build.sh ../BromiteWebView/Android.mk )

echo "Building flashable package (zip)"
mkdir build/.temp
mkdir -p build/.temp/META-INF/com/google/android
cp update-binary build/.temp/META-INF/com/google/android
echo "# Dummy file; update-binary is a shell script." > build/.temp/META-INF/com/google/android/update-script
echo "# Dummy file; update-binary is a shell script." > build/.temp/META-INF/com/google/android/updater-script
mkdir -p build/.temp/system/addon.d
cp 99-bromite-webview.sh build/.temp/system/addon.d
mkdir -p build/.temp/vendor/overlay
cp build/treble-overlay-bromite-webview.apk build/.temp/vendor/overlay
( cd build/.temp && zip -r ../BromiteSystemWebViewOverlay.zip . ) &> /dev/null
( cd build/.temp && zip -r - . > ../BromiteSystemWebViewOverlay.zip . ) &> /dev/null
rm -r build/.temp

echo "Building Magisk module (zip)"
mkdir build/.temp
mkdir -p build/.temp/META-INF/com/google/android
curl -sL https://github.com/topjohnwu/Magisk/raw/master/scripts/module_installer.sh > build/.temp/META-INF/com/google/android/update-binary
test -s build/.temp/META-INF/com/google/android/update-binary
echo "#MAGISK" > build/.temp/META-INF/com/google/android/updater-script
mkdir -p build/.temp/system/vendor/overlay
cp build/treble-overlay-bromite-webview.apk build/.temp/system/vendor/overlay
cp module.prop build/.temp/
( cd build/.temp && zip -r - . > ../BromiteSystemWebViewMagisk.zip . ) &> /dev/null
rm -r build/.temp
6 changes: 6 additions & 0 deletions module.prop
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
id=bromite-system-webview
name=Bromite System WebView Overlay
version=v0.3
versionCode=00003
author=arovlad
description=Enable the use of Bromite as the system WebView