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

Commit a20a0e9d authored by Mohammed Althaf T's avatar Mohammed Althaf T 😊
Browse files

Merge branch '3700-a15-legacy_build' into 'a15'

Remove Trichrome script

See merge request !73
parents f7b70b8b d9988631
Loading
Loading
Loading
Loading
+0 −1
Original line number Diff line number Diff line
@@ -245,7 +245,6 @@ ifeq ($(module_run_appcompat),true)
	$(call appcompat-header, aapt2)
	$(run-appcompat)
endif  # module_run_appcompat
	$(patch-trichrome)
	$(sign-package)
	# No need for align-package because sign-package takes care of alignment
else  # LOCAL_CERTIFICATE == PRESIGNED
+0 −2
Original line number Diff line number Diff line
@@ -755,8 +755,6 @@ JETIFIER := prebuilts/sdk/tools/jetifier/jetifier-standalone/bin/jetifier-standa

EXTRACT_KERNEL := build/make/tools/extract_kernel.py

PATCH_TRICHROME := build/make/tools/chromium_trichrome_patcher.py

# Path to tools.jar
HOST_JDK_TOOLS_JAR := $(ANDROID_JAVA8_HOME)/lib/tools.jar

+0 −5
Original line number Diff line number Diff line
@@ -4125,8 +4125,3 @@ define use_soong_sdk_libraries
  $(foreach l,$(1),$(if $(filter $(l),$(SOONG_SDK_VARIANT_MODULES)),\
      $(l).sdk,$(l)))
endef

# Patch Trichrome to add cert digest at buildtime
define patch-trichrome
$(hide) $(PATCH_TRICHROME) $@ $(PRIVATE_CERTIFICATE)
endef
+0 −39
Original line number Diff line number Diff line
#!/usr/bin/env python3

import os
import subprocess
import sys
import zipfile

infilename, sign_key = sys.argv[1:]

def ExtractFingerprint(cert):
    cmd = ['openssl', 'x509', '-sha256', '-fingerprint', '-noout', '-in', cert]
    proc = subprocess.run(cmd, stdout=subprocess.PIPE)
    return proc.stdout.decode('utf-8').split('=')[1].replace(':', '')

def patch_trichrome(infilename, sign_key):
    orig_certdigest = "c8a2e9bccf597c2fb6dc66bee293fc13f2fc47ec77bc6b2b0d52c11f51192ab8"
    new_certdigest = ExtractFingerprint(sign_key).lower().rstrip()

    with zipfile.ZipFile(infilename, 'r') as zin, zipfile.ZipFile(infilename + ".patched", 'w') as zout:
        for info in zin.infolist():
            data = zin.read(info.filename)
            if info.filename == 'AndroidManifest.xml':
                # Make sure we can find the certdigest
                try:
                    data.rindex(orig_certdigest.encode('utf-16-le'))
                except:
                    pass
                # Replace it
                data = data.replace(orig_certdigest.encode('utf-16-le'), new_certdigest.encode('utf-16-le'))
            zout.writestr(info, data)

    # Delete the original file
    os.remove(infilename)

    # Rename the output file to the original file name
    os.rename(infilename + ".patched", infilename)

if "Browser_" in infilename or "BrowserWebView_" in infilename:
    patch_trichrome(infilename, sign_key)