From 28b6a02300745d97bb658250eb21f68dccf36f88 Mon Sep 17 00:00:00 2001 From: Avichal Rakesh Date: Wed, 25 Jan 2023 14:55:31 -0800 Subject: [PATCH 1/4] Add DeviceAsWebcam to general handheld_system DeviceAsWebcam is a new service that lets an Android Device be used as a UVC webcam. The logic in DeviceAsWebcam is protected behind the vendor property `ro.usb.uvc.enabled`. Vendors who support UVC will need to set the property to `true` using something like ``` PRODUCT_VENDOR_PROPERTIES += \ ro.usb.uvc.enabled?=true ``` Bug: 242344221 Test: Manually tested that the makefile is correctly inherited from. Change-Id: I9b8444406f1c02fc8b76caee3e961016d9430a0a --- target/product/handheld_system.mk | 1 + 1 file changed, 1 insertion(+) diff --git a/target/product/handheld_system.mk b/target/product/handheld_system.mk index 2da1395c99..3009d6a4dd 100644 --- a/target/product/handheld_system.mk +++ b/target/product/handheld_system.mk @@ -43,6 +43,7 @@ PRODUCT_PACKAGES += \ CaptivePortalLogin \ CertInstaller \ CredentialManager \ + DeviceAsWebcam \ DocumentsUI \ DownloadProviderUi \ EasterEgg \ From c8ff84b21979002a0397bc7955dd7d4183f47576 Mon Sep 17 00:00:00 2001 From: Kelvin Zhang Date: Wed, 15 Feb 2023 16:52:46 -0800 Subject: [PATCH 2/4] Use zip2zip to copy zipfiles ZipDelete() works by copying every non-deleted entry to a new zipfile. Current implementation uses python's zipfile module to perform entry copying, which is inefficient, as every entry must be decompressed and then re-compressed. Instead, use zip2zip which avoid re-compression. Improvement: deleting META/dynamic_partitions_info.txt from raven-target_files-9465001.zip improved from 500+ seconds to 13 seconds. Change-Id: I0548255bc29380303314763f6d81e74bf3dbb76e --- tools/releasetools/common.py | 13 +++++++------ 1 file changed, 7 insertions(+), 6 deletions(-) diff --git a/tools/releasetools/common.py b/tools/releasetools/common.py index 9919029854..2ae39649b2 100644 --- a/tools/releasetools/common.py +++ b/tools/releasetools/common.py @@ -302,6 +302,8 @@ def RunAndCheckOutput(args, verbose=None, **kwargs): Raises: ExternalError: On non-zero exit from the command. """ + if verbose is None: + verbose = OPTIONS.verbose proc = Run(args, verbose=verbose, **kwargs) output, _ = proc.communicate() if output is None: @@ -2893,13 +2895,12 @@ def ZipDelete(zip_filename, entries, force=False): fd, new_zipfile = tempfile.mkstemp(dir=os.path.dirname(zip_filename)) os.close(fd) + cmd = ["zip2zip", "-i", zip_filename, "-o", new_zipfile] + for entry in entries: + cmd.append("-x") + cmd.append(entry) + RunAndCheckOutput(cmd) - with zipfile.ZipFile(new_zipfile, 'w') as zout: - for item in zin.infolist(): - if item.filename in entries: - continue - buffer = zin.read(item.filename) - zout.writestr(item, buffer) os.replace(new_zipfile, zip_filename) From 881461fb90c0031647705a688f65b13a91742e64 Mon Sep 17 00:00:00 2001 From: Yihan Dong Date: Wed, 30 Nov 2022 18:06:20 +0800 Subject: [PATCH 3/4] Tool for generating GTS open-sourced report The report contains: 1. whether gts-verifier need to be open-sourced 2. gts test modules that need to be open-sourced Test: m gts Change-Id: I1ce48f7e612556162d5ce1c76b3168ee7f35f826 Merged-In: I1ce48f7e612556162d5ce1c76b3168ee7f35f826 --- tools/Android.bp | 5 ++ tools/generate_gts_shared_report.py | 128 ++++++++++++++++++++++++++++ 2 files changed, 133 insertions(+) create mode 100644 tools/generate_gts_shared_report.py diff --git a/tools/Android.bp b/tools/Android.bp index 1f0d406566..f446973bbc 100644 --- a/tools/Android.bp +++ b/tools/Android.bp @@ -64,3 +64,8 @@ python_binary_host { name: "check_elf_file", srcs: ["check_elf_file.py"], } + +python_binary_host { + name: "generate_gts_shared_report", + srcs: ["generate_gts_shared_report.py"], +} diff --git a/tools/generate_gts_shared_report.py b/tools/generate_gts_shared_report.py new file mode 100644 index 0000000000..11c9364189 --- /dev/null +++ b/tools/generate_gts_shared_report.py @@ -0,0 +1,128 @@ +#!/usr/bin/env python3 +# +# Copyright (C) 2022 The Android Open Source Project +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. +""" +Checks and generates a report for gts modules that should be open-sourced. + +Usage: + generate_gts_open_source_report.py + --gtsv-metalic [gts-verifier meta_lic] + --gts-test-metalic [android-gts meta_lic] + --checkshare [COMPLIANCE_CHECKSHARE] + --gts-test-dir [directory of android-gts] + --output [output file] + +Output example: + GTS-Verifier: PASS/FAIL + GTS-Modules: PASS/FAIL + GtsIncrementalInstallTestCases_BackgroundProcess + GtsUnsignedNetworkStackTestCases +""" +import sys +import argparse +import subprocess +import re + +def _get_args(): + """Parses input arguments.""" + parser = argparse.ArgumentParser() + parser.add_argument( + '--gtsv-metalic', required=True, + help='license meta_lic file path of gts-verifier.zip') + parser.add_argument( + '--gts-test-metalic', required=True, + help='license meta_lic file path of android-gts.zip') + parser.add_argument( + '--checkshare', required=True, + help='path of the COMPLIANCE_CHECKSHARE tool') + parser.add_argument( + '--gts-test-dir', required=True, + help='directory of android-gts') + parser.add_argument( + '-o', '--output', required=True, + help='file path of the output report') + return parser.parse_args() + +def _check_gtsv(checkshare: str, gtsv_metalic: str) -> str: + """Checks gts-verifier license. + + Args: + checkshare: path of the COMPLIANCE_CHECKSHARE tool + gtsv_metalic: license meta_lic file path of gts-verifier.zip + + Returns: + PASS when gts-verifier.zip doesn't need to be shared, and FAIL + when gts-verifier.zip need to be shared. + """ + cmd = f'{checkshare} {gtsv_metalic}' + proc = subprocess.Popen(cmd, shell=True, stdout=subprocess.PIPE, + stderr=subprocess.PIPE) + proc.communicate() + return 'PASS' if proc.returncode == 0 else 'FAIL' + +def _check_gts_test(checkshare: str, gts_test_metalic: str, + gts_test_dir: str) -> tuple[str, set[str]]: + """Checks android-gts license. + + Args: + checkshare: path of the COMPLIANCE_CHECKSHARE tool + gts_test_metalic: license meta_lic file path of android-gts.zip + gts_test_dir: directory of android-gts + + Returns: + Check result (PASS when android-gts doesn't need to be shared, + FAIL when some gts modules need to be shared) and gts modules + that need to be shared. + """ + cmd = f'{checkshare} {gts_test_metalic}' + proc = subprocess.Popen(cmd, shell=True, stdout=subprocess.PIPE, + stderr=subprocess.PIPE) + _, str_stderr = map(lambda b: b.decode(), proc.communicate()) + if proc.returncode == 0: + return 'PASS', [] + open_source_modules = set() + for error_line in str_stderr.split('\n'): + # Skip the empty liness + if not error_line: + continue + module_meta_lic = error_line.strip().split()[0] + groups = re.fullmatch( + re.compile(f'.*/{gts_test_dir}/(.*)'), module_meta_lic) + if groups: + open_source_modules.add( + groups[1].removesuffix('.meta_lic')) + return 'FAIL', open_source_modules + + +def main(argv): + args = _get_args() + + gtsv_metalic = args.gtsv_metalic + gts_test_metalic = args.gts_test_metalic + output_file = args.output + checkshare = args.checkshare + gts_test_dir = args.gts_test_dir + + with open(output_file, 'w') as file: + result = _check_gtsv(checkshare, gtsv_metalic) + file.write(f'GTS-Verifier: {result}\n') + result, open_source_modules = _check_gts_test( + checkshare, gts_test_metalic, gts_test_dir) + file.write(f'GTS-Modules: {result}\n') + for open_source_module in open_source_modules: + file.write(f'\t{open_source_module}\n') + +if __name__ == "__main__": + main(sys.argv) \ No newline at end of file From 32ce1381ca8b5f9a8a51d18aa132c25adf524d51 Mon Sep 17 00:00:00 2001 From: Alex Buynytskyy Date: Fri, 17 Feb 2023 12:48:53 -0800 Subject: [PATCH 4/4] Move final script to the new folder. Bug: 264308911 Test: run locally Change-Id: Ice954b7d5ff6c1831e9899c9028e8fd6555ab050 --- tools/finalization/build-step-1.sh | 22 ++++++++++++++++++++++ 1 file changed, 22 insertions(+) create mode 100755 tools/finalization/build-step-1.sh diff --git a/tools/finalization/build-step-1.sh b/tools/finalization/build-step-1.sh new file mode 100755 index 0000000000..0f562b487c --- /dev/null +++ b/tools/finalization/build-step-1.sh @@ -0,0 +1,22 @@ +#!/bin/bash + +set -ex + +function finalize_main() { + local top="$(dirname "$0")"/../.. + + # default target to modify tree and build SDK + local m="$top/build/soong/soong_ui.bash --make-mode TARGET_PRODUCT=aosp_arm64 TARGET_BUILD_VARIANT=userdebug" + + # Build finalization artifacts. + source $top/build/make/tools/finalization/finalize-aidl-vndk-sdk-resources.sh + + # This command tests: + # The release state for AIDL. + # ABI difference between user and userdebug builds. + # Resource/SDK finalization. + AIDL_FROZEN_REL=true $m +} + +finalize_main +