From 6f6060a3583ac6e06375cc88798865bf2c360ee9 Mon Sep 17 00:00:00 2001 From: Cole Faust Date: Thu, 5 May 2022 11:38:26 -0700 Subject: Add function for flattening 2d lists Bug: 226974242 Test: ./out/rbcrun ./build/make/tests/run.rbc Change-Id: Iae977b34ca0ac156ec795c54f4951c769fa994dd --- core/product_config.rbc | 9 ++++++++- tests/run.rbc | 6 +++++- 2 files changed, 13 insertions(+), 2 deletions(-) diff --git a/core/product_config.rbc b/core/product_config.rbc index f67ba8e8df..7a5e50110b 100644 --- a/core/product_config.rbc +++ b/core/product_config.rbc @@ -619,6 +619,12 @@ def _last_word(input): return "" return input[l-1] +def _flatten_2d_list(list): + result = [] + for x in list: + result += x + return result + def _dir(paths): """Equivalent to the GNU make function $(dir). @@ -785,7 +791,7 @@ def _mkstrip(s): if t == "list": s = " ".join(s) elif t != "string": - fail("Argument to mkstrip must be a string or list.") + fail("Argument to mkstrip must be a string or list, got: "+t) result = "" was_space = False for ch in s.strip().elems(): @@ -879,6 +885,7 @@ rblf = struct( findstring = _findstring, first_word = _first_word, last_word = _last_word, + flatten_2d_list = _flatten_2d_list, inherit = _inherit, indirect = _indirect, mk2rbc_error = _mk2rbc_error, diff --git a/tests/run.rbc b/tests/run.rbc index 107be0995a..c6dfeba405 100644 --- a/tests/run.rbc +++ b/tests/run.rbc @@ -43,7 +43,7 @@ assert_eq(["a", "b", "c"], rblf.mksort(["b", "a", "c", "c"])) assert_eq("", rblf.mkstrip(" \n \t ")) assert_eq("a b c", rblf.mkstrip(" a b \n c \t")) -assert_eq(1, rblf.mkstrip(1)) +assert_eq("1", rblf.mkstrip("1 ")) assert_eq("b1 b2", rblf.mksubst("a", "b", "a1 a2")) assert_eq(["b1", "x2"], rblf.mksubst("a", "b", ["a1", "x2"])) @@ -90,6 +90,10 @@ assert_eq("bar", rblf.last_word(["foo", "bar"])) assert_eq("", rblf.last_word("")) assert_eq("", rblf.last_word([])) +assert_eq(["foo", "bar"], rblf.flatten_2d_list([["foo", "bar"]])) +assert_eq(["foo", "bar"], rblf.flatten_2d_list([["foo"], ["bar"]])) +assert_eq([], rblf.flatten_2d_list([])) + assert_eq( ["build/make/tests/board.rbc", "build/make/tests/board_input_vars.rbc"], rblf.expand_wildcard("build/make/tests/board*.rbc") -- cgit v1.2.3 From 9a698e6a9fc5d52046226a102962601efc9e7d21 Mon Sep 17 00:00:00 2001 From: Kelvin Zhang Date: Mon, 9 May 2022 10:20:52 -0700 Subject: Temporary hack for making T->S downgrade work Downgrade OTA was broken because generic_ramdisk was removed from boot partition in android T. Neither does O6 have init_boot. O6 also doesn't include generic ramdisk in vendor boot, so no way for otatools to locate contents of generic ramdisk. As a hack, omit boot partition timestamp if we can't find ramdisk. Test: generate T->S downgrade OTA for O6 Bug: 231656318 Change-Id: I9f5359462332aadadc324348873a3a4b2b126068 --- tools/releasetools/ota_from_target_files.py | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/tools/releasetools/ota_from_target_files.py b/tools/releasetools/ota_from_target_files.py index c55631b556..5384699323 100755 --- a/tools/releasetools/ota_from_target_files.py +++ b/tools/releasetools/ota_from_target_files.py @@ -1068,10 +1068,11 @@ def GeneratePartitionTimestampFlagsDowngrade( pre_partition_state, post_partition_state): assert pre_partition_state is not None partition_timestamps = {} - for part in pre_partition_state: - partition_timestamps[part.partition_name] = part.version for part in post_partition_state: - partition_timestamps[part.partition_name] = \ + partition_timestamps[part.partition_name] = part.version + for part in pre_partition_state: + if part.partition_name in partition_timestamps: + partition_timestamps[part.partition_name] = \ max(part.version, partition_timestamps[part.partition_name]) return [ "--partition_timestamps", -- cgit v1.2.3 From 4edc0b30ff7bfbc115ca10f284bd7d4f0d637c00 Mon Sep 17 00:00:00 2001 From: Cole Faust Date: Tue, 10 May 2022 15:39:10 -0700 Subject: Remove all_product_makefiles It was unused, along with all_product_configs. Bug: 228518445 Test: Presubmits Change-Id: Ibd105241581f8b03254b8fee382d916ea3a98890 --- core/product_config.mk | 3 --- 1 file changed, 3 deletions(-) diff --git a/core/product_config.mk b/core/product_config.mk index 35f018daea..540289a609 100644 --- a/core/product_config.mk +++ b/core/product_config.mk @@ -210,7 +210,6 @@ $(foreach f,$(android_products_makefiles), \ # Dedup, extract product names, etc. product_paths := $(sort $(product_paths)) all_named_products := $(sort $(call _first,$(product_paths),:)) -all_product_makefiles := $(sort $(call _second,$(product_paths),:)) current_product_makefile := $(call _second,$(filter $(TARGET_PRODUCT):%,$(product_paths)),:) COMMON_LUNCH_CHOICES := $(sort $(common_lunch_choices)) @@ -273,8 +272,6 @@ endif ############################################################################ current_product_makefile := -all_product_makefiles := -all_product_configs := ############################################################################# # Quick check and assign default values -- cgit v1.2.3 From 26e9dd30a4c389a31de92f58f5ef5a7fa70510fb Mon Sep 17 00:00:00 2001 From: Jeongik Cha Date: Wed, 11 May 2022 01:25:19 +0000 Subject: Remove -j1 for aidl-freeze-api Because bpmodify is safe in multi-process env. Bug: 190577319 Bug: 229413853 Test: aidl-freeze-api Change-Id: Ie47afc25e2259bbcbbff50f98fa9d36887558d27 --- finalize_branch_for_release.sh | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/finalize_branch_for_release.sh b/finalize_branch_for_release.sh index 8587b3aabc..c942eb2e54 100755 --- a/finalize_branch_for_release.sh +++ b/finalize_branch_for_release.sh @@ -17,8 +17,7 @@ set -x # Update references in the codebase to new API version (TODO) # ... -# Adding -j1 option because of file(Android.bp) race condition. -AIDL_TRANSITIVE_FREEZE=true m aidl-freeze-api -j1 +AIDL_TRANSITIVE_FREEZE=true m aidl-freeze-api m check-vndk-list || update-vndk-list.sh # for new versions of AIDL interfaces -- cgit v1.2.3 From a9203e6d8778ac6aed05e27f3ed7bb71de6b9b22 Mon Sep 17 00:00:00 2001 From: Colin Cross Date: Fri, 8 Apr 2022 10:55:59 -0700 Subject: Remove HOST_DALVIK_* There are no more BUILD_HOST_DALVIK_* modules, remove the host dalvik support. The equivalent support in Soong just copies the device dex file to the host dalvik location. Test: m checkbuild Change-Id: I4bcf916518317b28d3217994b2fe9ee95d7f50d6 --- core/config.mk | 2 - core/definitions.mk | 2 - core/deprecation.mk | 4 +- core/host_dalvik_java_library.mk | 191 -------------------------------- core/host_dalvik_static_java_library.mk | 28 ----- 5 files changed, 2 insertions(+), 225 deletions(-) delete mode 100644 core/host_dalvik_java_library.mk delete mode 100644 core/host_dalvik_static_java_library.mk diff --git a/core/config.mk b/core/config.mk index 4db33f155e..247103de22 100644 --- a/core/config.mk +++ b/core/config.mk @@ -226,8 +226,6 @@ BUILD_NATIVE_TEST :=$= $(BUILD_SYSTEM)/native_test.mk BUILD_FUZZ_TEST :=$= $(BUILD_SYSTEM)/fuzz_test.mk BUILD_NOTICE_FILE :=$= $(BUILD_SYSTEM)/notice_files.mk -BUILD_HOST_DALVIK_JAVA_LIBRARY :=$= $(BUILD_SYSTEM)/host_dalvik_java_library.mk -BUILD_HOST_DALVIK_STATIC_JAVA_LIBRARY :=$= $(BUILD_SYSTEM)/host_dalvik_static_java_library.mk include $(BUILD_SYSTEM)/deprecation.mk diff --git a/core/definitions.mk b/core/definitions.mk index 8fe5edbf06..e424bc27f9 100644 --- a/core/definitions.mk +++ b/core/definitions.mk @@ -3360,8 +3360,6 @@ STATS.MODULE_TYPE := \ STATIC_TEST_LIBRARY \ HOST_STATIC_TEST_LIBRARY \ NOTICE_FILE \ - HOST_DALVIK_JAVA_LIBRARY \ - HOST_DALVIK_STATIC_JAVA_LIBRARY \ base_rules \ HEADER_LIBRARY \ HOST_TEST_CONFIG \ diff --git a/core/deprecation.mk b/core/deprecation.mk index 2b7a869914..ed4215e67d 100644 --- a/core/deprecation.mk +++ b/core/deprecation.mk @@ -3,8 +3,6 @@ AVAILABLE_BUILD_MODULE_TYPES :=$= \ BUILD_EXECUTABLE \ BUILD_FUZZ_TEST \ BUILD_HEADER_LIBRARY \ - BUILD_HOST_DALVIK_JAVA_LIBRARY \ - BUILD_HOST_DALVIK_STATIC_JAVA_LIBRARY \ BUILD_HOST_JAVA_LIBRARY \ BUILD_HOST_PREBUILT \ BUILD_JAVA_LIBRARY \ @@ -39,6 +37,8 @@ DEFAULT_ERROR_BUILD_MODULE_TYPES :=$= \ OBSOLETE_BUILD_MODULE_TYPES :=$= \ BUILD_AUX_EXECUTABLE \ BUILD_AUX_STATIC_LIBRARY \ + BUILD_HOST_DALVIK_JAVA_LIBRARY \ + BUILD_HOST_DALVIK_STATIC_JAVA_LIBRARY \ BUILD_HOST_FUZZ_TEST \ BUILD_HOST_NATIVE_TEST \ BUILD_HOST_SHARED_TEST_LIBRARY \ diff --git a/core/host_dalvik_java_library.mk b/core/host_dalvik_java_library.mk deleted file mode 100644 index 5eeb8ac91d..0000000000 --- a/core/host_dalvik_java_library.mk +++ /dev/null @@ -1,191 +0,0 @@ -# -# Copyright (C) 2013 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. -# -$(call record-module-type,HOST_DALVIK_JAVA_LIBRARY) - -# -# Rules for building a host dalvik java library. These libraries -# are meant to be used by a dalvik VM instance running on the host. -# They will be compiled against libcore and not the host JRE. -# - -ifeq ($(HOST_OS),linux) -USE_CORE_LIB_BOOTCLASSPATH := true - -####################################### -include $(BUILD_SYSTEM)/host_java_library_common.mk -####################################### - -full_classes_turbine_jar := $(intermediates.COMMON)/classes-turbine.jar -full_classes_header_jarjar := $(intermediates.COMMON)/classes-header-jarjar.jar -full_classes_header_jar := $(intermediates.COMMON)/classes-header.jar -full_classes_compiled_jar := $(intermediates.COMMON)/classes-full-debug.jar -full_classes_combined_jar := $(intermediates.COMMON)/classes-combined.jar -full_classes_jarjar_jar := $(intermediates.COMMON)/classes-jarjar.jar -full_classes_jar := $(intermediates.COMMON)/classes.jar -built_dex := $(intermediates.COMMON)/classes.dex -java_source_list_file := $(intermediates.COMMON)/java-source-list - -LOCAL_INTERMEDIATE_TARGETS += \ - $(full_classes_turbine_jar) \ - $(full_classes_compiled_jar) \ - $(full_classes_combined_jar) \ - $(full_classes_jarjar_jar) \ - $(full_classes_jar) \ - $(built_dex) \ - $(java_source_list_file) - -# See comment in java.mk -ifndef LOCAL_CHECKED_MODULE -ifeq ($(LOCAL_IS_STATIC_JAVA_LIBRARY),true) -LOCAL_CHECKED_MODULE := $(full_classes_compiled_jar) -else -LOCAL_CHECKED_MODULE := $(built_dex) -endif -endif - -####################################### -include $(BUILD_SYSTEM)/base_rules.mk -####################################### -java_sources := $(addprefix $(LOCAL_PATH)/, $(filter %.java,$(LOCAL_SRC_FILES))) \ - $(filter %.java,$(LOCAL_GENERATED_SOURCES)) -all_java_sources := $(java_sources) - -include $(BUILD_SYSTEM)/java_common.mk - -include $(BUILD_SYSTEM)/sdk_check.mk - -$(cleantarget): PRIVATE_CLEAN_FILES += $(intermediates.COMMON) - -# List of dependencies for anything that needs all java sources in place -java_sources_deps := \ - $(java_sources) \ - $(java_resource_sources) \ - $(LOCAL_SRCJARS) \ - $(LOCAL_ADDITIONAL_DEPENDENCIES) - -$(java_source_list_file): $(java_sources_deps) - $(write-java-source-list) - -# TODO(b/143658984): goma can't handle the --system argument to javac. -#$(full_classes_compiled_jar): .KATI_NINJA_POOL := $(GOMA_POOL) -$(full_classes_compiled_jar): PRIVATE_JAVA_LAYERS_FILE := $(layers_file) -$(full_classes_compiled_jar): PRIVATE_JAVACFLAGS := $(LOCAL_JAVACFLAGS) $(annotation_processor_flags) -$(full_classes_compiled_jar): PRIVATE_JAR_EXCLUDE_FILES := -$(full_classes_compiled_jar): PRIVATE_JAR_PACKAGES := -$(full_classes_compiled_jar): PRIVATE_JAR_EXCLUDE_PACKAGES := -$(full_classes_compiled_jar): PRIVATE_SRCJARS := $(LOCAL_SRCJARS) -$(full_classes_compiled_jar): PRIVATE_SRCJAR_LIST_FILE := $(intermediates.COMMON)/srcjar-list -$(full_classes_compiled_jar): PRIVATE_SRCJAR_INTERMEDIATES_DIR := $(intermediates.COMMON)/srcjars -$(full_classes_compiled_jar): \ - $(java_source_list_file) \ - $(java_sources_deps) \ - $(full_java_header_libs) \ - $(full_java_bootclasspath_libs) \ - $(full_java_system_modules_deps) \ - $(annotation_processor_deps) \ - $(NORMALIZE_PATH) \ - $(JAR_ARGS) \ - $(ZIPSYNC) \ - $(SOONG_ZIP) \ - | $(SOONG_JAVAC_WRAPPER) - $(transform-host-java-to-dalvik-package) - -ifneq ($(TURBINE_ENABLED),false) - -$(full_classes_turbine_jar): PRIVATE_JAVACFLAGS := $(LOCAL_JAVACFLAGS) $(annotation_processor_flags) -$(full_classes_turbine_jar): PRIVATE_SRCJARS := $(LOCAL_SRCJARS) -$(full_classes_turbine_jar): \ - $(java_source_list_file) \ - $(java_sources_deps) \ - $(full_java_header_libs) \ - $(full_java_bootclasspath_libs) \ - $(NORMALIZE_PATH) \ - $(JAR_ARGS) \ - $(ZIPTIME) \ - | $(TURBINE) \ - $(MERGE_ZIPS) - $(transform-java-to-header.jar) - -.KATI_RESTAT: $(full_classes_turbine_jar) - -# Run jarjar before generate classes-header.jar if necessary. -ifneq ($(strip $(LOCAL_JARJAR_RULES)),) -$(full_classes_header_jarjar): PRIVATE_JARJAR_RULES := $(LOCAL_JARJAR_RULES) -$(full_classes_header_jarjar): $(full_classes_turbine_jar) $(LOCAL_JARJAR_RULES) | $(JARJAR) - $(call transform-jarjar) -else -full_classes_header_jarjar := $(full_classes_turbine_jar) -endif - -$(eval $(call copy-one-file,$(full_classes_header_jarjar),$(full_classes_header_jar))) - -endif # TURBINE_ENABLED != false - -$(full_classes_combined_jar): PRIVATE_DONT_DELETE_JAR_META_INF := $(LOCAL_DONT_DELETE_JAR_META_INF) -$(full_classes_combined_jar): $(full_classes_compiled_jar) \ - $(jar_manifest_file) \ - $(full_static_java_libs) | $(MERGE_ZIPS) - $(if $(PRIVATE_JAR_MANIFEST), $(hide) sed -e "s/%BUILD_NUMBER%/$(BUILD_NUMBER_FROM_FILE)/" \ - $(PRIVATE_JAR_MANIFEST) > $(dir $@)/manifest.mf) - $(MERGE_ZIPS) -j --ignore-duplicates $(if $(PRIVATE_JAR_MANIFEST),-m $(dir $@)/manifest.mf) \ - $(if $(PRIVATE_DONT_DELETE_JAR_META_INF),,-stripDir META-INF -zipToNotStrip $<) \ - $@ $< $(PRIVATE_STATIC_JAVA_LIBRARIES) - -# Run jarjar if necessary, otherwise just copy the file. -ifneq ($(strip $(LOCAL_JARJAR_RULES)),) -$(full_classes_jarjar_jar): PRIVATE_JARJAR_RULES := $(LOCAL_JARJAR_RULES) -$(full_classes_jarjar_jar): $(full_classes_combined_jar) $(LOCAL_JARJAR_RULES) | $(JARJAR) - $(call transform-jarjar) -else -full_classes_jarjar_jar := $(full_classes_combined_jar) -endif - -$(eval $(call copy-one-file,$(full_classes_jarjar_jar),$(full_classes_jar))) - -ifeq ($(LOCAL_IS_STATIC_JAVA_LIBRARY),true) -# No dex; all we want are the .class files with resources. -$(LOCAL_BUILT_MODULE) : $(java_resource_sources) -$(LOCAL_BUILT_MODULE) : $(full_classes_jar) - @echo "host Static Jar: $(PRIVATE_MODULE) ($@)" - $(copy-file-to-target) - -else # !LOCAL_IS_STATIC_JAVA_LIBRARY -$(built_dex): PRIVATE_INTERMEDIATES_DIR := $(intermediates.COMMON) -$(built_dex): PRIVATE_DX_FLAGS := $(LOCAL_DX_FLAGS) -$(built_dex): $(full_classes_jar) $(DX) $(ZIP2ZIP) - $(transform-classes.jar-to-dex) - -$(LOCAL_BUILT_MODULE): PRIVATE_DEX_FILE := $(built_dex) -$(LOCAL_BUILT_MODULE): PRIVATE_SOURCE_ARCHIVE := $(full_classes_jarjar_jar) -$(LOCAL_BUILT_MODULE): $(MERGE_ZIPS) $(SOONG_ZIP) $(ZIP2ZIP) -$(LOCAL_BUILT_MODULE): $(built_dex) $(java_resource_sources) - @echo "Host Jar: $(PRIVATE_MODULE) ($@)" - rm -rf $@.parts - mkdir -p $@.parts - $(call create-dex-jar,$@.parts/dex.zip,$(PRIVATE_DEX_FILE)) - $(call extract-resources-jar,$@.parts/res.zip,$(PRIVATE_SOURCE_ARCHIVE)) - $(MERGE_ZIPS) -j $@ $@.parts/dex.zip $@.parts/res.zip - rm -rf $@.parts - -endif # !LOCAL_IS_STATIC_JAVA_LIBRARY - -$(LOCAL_INTERMEDIATE_TARGETS): PRIVATE_DEFAULT_APP_TARGET_SDK := $(call module-target-sdk-version) -$(LOCAL_INTERMEDIATE_TARGETS): PRIVATE_SDK_VERSION := $(call module-sdk-version) -$(LOCAL_INTERMEDIATE_TARGETS): PRIVATE_MIN_SDK_VERSION := $(call codename-or-sdk-to-sdk,$(call module-min-sdk-version)) - -USE_CORE_LIB_BOOTCLASSPATH := - -endif diff --git a/core/host_dalvik_static_java_library.mk b/core/host_dalvik_static_java_library.mk deleted file mode 100644 index 78faf73a56..0000000000 --- a/core/host_dalvik_static_java_library.mk +++ /dev/null @@ -1,28 +0,0 @@ -# -# Copyright (C) 2013 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. -# -$(call record-module-type,HOST_DALVIK_STATIC_JAVA_LIBRARY) - -# -# Rules for building a host dalvik static java library. -# These libraries will be compiled against libcore and not the host -# JRE. -# -LOCAL_UNINSTALLABLE_MODULE := true -LOCAL_IS_STATIC_JAVA_LIBRARY := true - -include $(BUILD_SYSTEM)/host_dalvik_java_library.mk - -LOCAL_IS_STATIC_JAVA_LIBRARY := -- cgit v1.2.3 From 2f8aad4f7f306f37e7d0dc77178bc9e4ed66e174 Mon Sep 17 00:00:00 2001 From: Michael Groover Date: Fri, 9 Jul 2021 16:12:11 -0700 Subject: Add support for -providerArg in signapk signapk currently accepts a Provider class that can be instantiated and inserted before the signing. This commit adds support to specify a -providerArg parameter that can be used to configure the Provider. Prior to JDK 9 a Provider would accept a providerArg in a constructor accepting a String; in JDK 9+ a Provider should first be instantiated with the zero-arg constructor, then the configure method should be called with the providerArg. Bug: 142334653 Bug: 190974913 Fixes: 232134730 Test: Manually verified new Provider can be inserted with pre- and post-JDK 9 behavior. Change-Id: I96f027640c59d3357e8dcf656626d1601bfef861 --- tools/signapk/src/com/android/signapk/SignApk.java | 62 +++++++++++++++------- 1 file changed, 42 insertions(+), 20 deletions(-) diff --git a/tools/signapk/src/com/android/signapk/SignApk.java b/tools/signapk/src/com/android/signapk/SignApk.java index c127dbe9de..36a220cc0f 100644 --- a/tools/signapk/src/com/android/signapk/SignApk.java +++ b/tools/signapk/src/com/android/signapk/SignApk.java @@ -901,7 +901,7 @@ class SignApk { * Tries to load a JSE Provider by class name. This is for custom PrivateKey * types that might be stored in PKCS#11-like storage. */ - private static void loadProviderIfNecessary(String providerClassName) { + private static void loadProviderIfNecessary(String providerClassName, String providerArg) { if (providerClassName == null) { return; } @@ -920,27 +920,41 @@ class SignApk { return; } - Constructor constructor = null; - for (Constructor c : klass.getConstructors()) { - if (c.getParameterTypes().length == 0) { - constructor = c; - break; + Constructor constructor; + Object o = null; + if (providerArg == null) { + try { + constructor = klass.getConstructor(); + o = constructor.newInstance(); + } catch (ReflectiveOperationException e) { + e.printStackTrace(); + System.err.println("Unable to instantiate " + providerClassName + + " with a zero-arg constructor"); + System.exit(1); + } + } else { + try { + constructor = klass.getConstructor(String.class); + o = constructor.newInstance(providerArg); + } catch (ReflectiveOperationException e) { + // This is expected from JDK 9+; the single-arg constructor accepting the + // configuration has been replaced with a configure(String) method to be invoked + // after instantiating the Provider with the zero-arg constructor. + try { + constructor = klass.getConstructor(); + o = constructor.newInstance(); + // The configure method will return either the modified Provider or a new + // Provider if this one cannot be configured in-place. + o = klass.getMethod("configure", String.class).invoke(o, providerArg); + } catch (ReflectiveOperationException roe) { + roe.printStackTrace(); + System.err.println("Unable to instantiate " + providerClassName + + " with the provided argument " + providerArg); + System.exit(1); + } } - } - if (constructor == null) { - System.err.println("No zero-arg constructor found for " + providerClassName); - System.exit(1); - return; } - final Object o; - try { - o = constructor.newInstance(); - } catch (Exception e) { - e.printStackTrace(); - System.exit(1); - return; - } if (!(o instanceof Provider)) { System.err.println("Not a Provider class: " + providerClassName); System.exit(1); @@ -1049,6 +1063,7 @@ class SignApk { "[-a ] " + "[--align-file-size] " + "[-providerClass ] " + + "[-providerArg ] " + "[-loadPrivateKeysFromKeyStore ]" + "[-keyStorePin ]" + "[--min-sdk-version ] " + @@ -1073,6 +1088,7 @@ class SignApk { boolean signWholeFile = false; String providerClass = null; + String providerArg = null; String keyStoreName = null; String keyStorePin = null; int alignment = 4; @@ -1093,6 +1109,12 @@ class SignApk { } providerClass = args[++argstart]; ++argstart; + } else if("-providerArg".equals(args[argstart])) { + if (argstart + 1 >= args.length) { + usage(); + } + providerArg = args[++argstart]; + ++argstart; } else if ("-loadPrivateKeysFromKeyStore".equals(args[argstart])) { if (argstart + 1 >= args.length) { usage(); @@ -1153,7 +1175,7 @@ class SignApk { System.exit(2); } - loadProviderIfNecessary(providerClass); + loadProviderIfNecessary(providerClass, providerArg); String inputFilename = args[numArgsExcludeV4FilePath - 2]; String outputFilename = args[numArgsExcludeV4FilePath - 1]; -- cgit v1.2.3