From 29d7f4d08e28ca78485444e30c14b27a8923ee7d Mon Sep 17 00:00:00 2001 From: Alexander Frick Date: Sun, 25 Jun 2023 14:17:29 -0500 Subject: [PATCH] android rebase --- build_android.sh | 17 - setup.sh | 13 + src/chrome/android/BUILD.gn | 544 +++------ src/chrome/android/chrome_public_apk_tmpl.gni | 1034 ++++++++--------- src/chrome/android/chrome_test_apk_tmpl.gni | 121 -- 5 files changed, 656 insertions(+), 1073 deletions(-) delete mode 100644 src/chrome/android/chrome_test_apk_tmpl.gni diff --git a/build_android.sh b/build_android.sh index c2d10766..5c1c7136 100644 --- a/build_android.sh +++ b/build_android.sh @@ -42,23 +42,6 @@ printf "${YEL}Building Thorium for Android...\n" && printf "${YEL}Note: You may want ADB installed.${c0}\n" && printf "${CYA}\n" && -# Workaround for branding dir -cd ${CR_SRC_DIR} && -rm -v -r -f chrome/android/java/res_base/drawable-v26/ic_launcher.xml && -rm -v -r -f chrome/android/java/res_base/drawable-v26/ic_launcher_round.xml && -rm -v -r -f chrome/android/java/res_chromium_base/mipmap-mdpi/layered_app_icon_background.png && -rm -v -r -f chrome/android/java/res_chromium_base/mipmap-mdpi/layered_app_icon.png && -rm -v -r -f chrome/android/java/res_chromium_base/mipmap-xhdpi/layered_app_icon_background.png && -rm -v -r -f chrome/android/java/res_chromium_base/mipmap-xhdpi/layered_app_icon.png && -rm -v -r -f chrome/android/java/res_chromium_base/mipmap-xxxhdpi/layered_app_icon_background.png && -rm -v -r -f chrome/android/java/res_chromium_base/mipmap-xxxhdpi/layered_app_icon.png && -rm -v -r -f chrome/android/java/res_chromium_base/mipmap-nodpi/layered_app_icon_foreground.xml && -rm -v -r -f chrome/android/java/res_chromium_base/mipmap-hdpi/layered_app_icon_background.png && -rm -v -r -f chrome/android/java/res_chromium_base/mipmap-hdpi/layered_app_icon.png && -rm -v -r -f chrome/android/java/res_chromium_base/mipmap-xxhdpi/layered_app_icon_background.png && -rm -v -r -f chrome/android/java/res_chromium_base/mipmap-xxhdpi/layered_app_icon.png && -cd $HOME/thorium && - buildARM32 () { # Build Thorium for ARM32 export NINJA_SUMMARIZE_BUILD=1 && diff --git a/setup.sh b/setup.sh index 730b189e..684ac080 100755 --- a/setup.sh +++ b/setup.sh @@ -173,6 +173,19 @@ copyAndroid () { cp -r -v arm/build/config/* ${CR_SRC_DIR}/build/config/ && cp -r -v arm/android/* ${CR_SRC_DIR}/ && cp -r -v arm/android/third_party/* ${CR_SRC_DIR}/third_party/ && + rm -v -r -f ${CR_SRC_DIR}/chrome/android/java/res_base/drawable-v26/ic_launcher.xml && + rm -v -r -f ${CR_SRC_DIR}/chrome/android/java/res_base/drawable-v26/ic_launcher_round.xml && + rm -v -r -f ${CR_SRC_DIR}/chrome/android/java/res_chromium_base/mipmap-mdpi/layered_app_icon_background.png && + rm -v -r -f ${CR_SRC_DIR}/chrome/android/java/res_chromium_base/mipmap-mdpi/layered_app_icon.png && + rm -v -r -f ${CR_SRC_DIR}/chrome/android/java/res_chromium_base/mipmap-xhdpi/layered_app_icon_background.png && + rm -v -r -f ${CR_SRC_DIR}/chrome/android/java/res_chromium_base/mipmap-xhdpi/layered_app_icon.png && + rm -v -r -f ${CR_SRC_DIR}/chrome/android/java/res_chromium_base/mipmap-xxxhdpi/layered_app_icon_background.png && + rm -v -r -f ${CR_SRC_DIR}/chrome/android/java/res_chromium_base/mipmap-xxxhdpi/layered_app_icon.png && + rm -v -r -f ${CR_SRC_DIR}/chrome/android/java/res_chromium_base/mipmap-nodpi/layered_app_icon_foreground.xml && + rm -v -r -f ${CR_SRC_DIR}/chrome/android/java/res_chromium_base/mipmap-hdpi/layered_app_icon_background.png && + rm -v -r -f ${CR_SRC_DIR}/chrome/android/java/res_chromium_base/mipmap-hdpi/layered_app_icon.png && + rm -v -r -f ${CR_SRC_DIR}/chrome/android/java/res_chromium_base/mipmap-xxhdpi/layered_app_icon_background.png && + rm -v -r -f ${CR_SRC_DIR}/chrome/android/java/res_chromium_base/mipmap-xxhdpi/layered_app_icon.png && printf "\n" } case $1 in diff --git a/src/chrome/android/BUILD.gn b/src/chrome/android/BUILD.gn index 30d3a951..fc5a24dc 100644 --- a/src/chrome/android/BUILD.gn +++ b/src/chrome/android/BUILD.gn @@ -6,16 +6,15 @@ import("//build/android/resource_sizes.gni") import("//build/config/android/config.gni") import("//build/config/android/rules.gni") import("//build/config/android/system_image.gni") +import("//build/config/cronet/config.gni") import("//build/config/python.gni") import("//build/util/process_version.gni") import("//chrome/android/chrome_common_shared_library.gni") import("//chrome/android/chrome_java_resources.gni") import("//chrome/android/chrome_public_apk_tmpl.gni") -import("//chrome/android/chrome_test_apk_tmpl.gni") import("//chrome/android/expectations/expectations.gni") import("//chrome/android/features/dev_ui/dev_ui_module.gni") import("//chrome/android/features/start_surface/start_surface_java_sources.gni") -import("//chrome/android/features/tab_ui/buildflags.gni") import("//chrome/android/features/tab_ui/tab_management_java_sources.gni") import("//chrome/android/features/vr/public_vr_java_sources.gni") import("//chrome/android/feed/feed_java_sources.gni") @@ -43,6 +42,8 @@ import("java_sources.gni") import("static_initializers.gni") import("trichrome.gni") +assert(!is_cronet_build) + if (android_64bit_target_cpu && skip_secondary_abi_for_cq) { assert(current_toolchain != android_secondary_abi_toolchain) } @@ -57,12 +58,6 @@ if (current_toolchain == default_toolchain) { app_hooks_impl = "java/src/org/chromium/chrome/browser/AppHooksImpl.java" - # Exclude it from JNI registration if VR is not enabled. - chrome_jni_file_exclusions = [] - if (!enable_vr) { - chrome_jni_file_exclusions += [ "//chrome/android/features/vr/java/src/org/chromium/chrome/browser/vr/VrModuleProvider.java" ] - } - jinja_template("chrome_public_android_feature_vr_manifest") { input = "features/vr/java/AndroidManifest.xml" output = feature_module_vr_android_manifest_path @@ -99,19 +94,7 @@ if (current_toolchain == default_toolchain) { android_resources("chrome_app_java_resources") { sources = chrome_java_resources - sources += [ - "//chrome/android/java/res_app/layout/main.xml", - "//chrome/android/java/res_chromium/drawable-hdpi/fre_product_logo.png", - "//chrome/android/java/res_chromium/drawable-hdpi/product_logo_name.png", - "//chrome/android/java/res_chromium/drawable-mdpi/fre_product_logo.png", - "//chrome/android/java/res_chromium/drawable-mdpi/product_logo_name.png", - "//chrome/android/java/res_chromium/drawable-xhdpi/fre_product_logo.png", - "//chrome/android/java/res_chromium/drawable-xhdpi/product_logo_name.png", - "//chrome/android/java/res_chromium/drawable-xxhdpi/fre_product_logo.png", - "//chrome/android/java/res_chromium/drawable-xxhdpi/product_logo_name.png", - "//chrome/android/java/res_chromium/drawable-xxxhdpi/fre_product_logo.png", - "//chrome/android/java/res_chromium/drawable-xxxhdpi/product_logo_name.png", - ] + sources += [ "//chrome/android/java/res_app/layout/main.xml" ] deps = [ ":chrome_base_module_resources", @@ -131,6 +114,7 @@ if (current_toolchain == default_toolchain) { "//chrome/browser/signin/services/android:java_resources", "//chrome/browser/tab:java_resources", "//chrome/browser/ui/android/appmenu:java_resources", + "//chrome/browser/ui/android/device_lock:java_resources", "//chrome/browser/ui/android/favicon:java_resources", "//chrome/browser/ui/android/management:java_resources", "//chrome/browser/ui/android/omnibox:java_resources", @@ -174,23 +158,6 @@ if (current_toolchain == default_toolchain) { ] } - if (enable_vr) { - # TODO(crbug.com/935982): Currently, adding multiple resource folders to a - # resource target may clobber some resources. Once that is fixed we should add - # the VR resources to chrome_app_java_resources. - android_resources("chrome_vr_java_resources") { - # Overrides 'gvr_vr_mode_component' in //third_party/gvr-android-sdk:gvr_common_java - # in tests. - resource_overlay = true - sources = [ - "//chrome/android/java/res_vr/values-v17/styles.xml", - "//chrome/android/java/res_vr/values-vrheadset-v26/styles.xml", - "//chrome/android/java/res_vr/values/values.xml", - ] - deps = [ ":chrome_app_java_resources" ] - } - } - android_library("app_hooks_java") { sources = [ app_hooks_impl ] deps = [ ":chrome_java" ] @@ -202,6 +169,7 @@ if (current_toolchain == default_toolchain) { ":app_hooks_java", "//chrome/browser/accessibility/hierarchysnapshotter/android:delegate_public_impl_java", "//chrome/browser/feed/android:hooks_public_impl_java", + "//chrome/browser/feedback/android:delegate_public_impl_java", "//chrome/browser/lens:delegate_public_impl_java", "//chrome/browser/locale:delegate_public_impl_java", "//chrome/browser/partnerbookmarks:delegate_public_impl_java", @@ -216,13 +184,6 @@ if (current_toolchain == default_toolchain) { ] } - java_cpp_template("vr_build_config") { - sources = [ "//chrome/android/java/src/org/chromium/chrome/browser/vr/VrBuildConfig.template" ] - if (enable_vr) { - defines = [ "ENABLE_VR" ] - } - } - android_library("chrome_java") { deps = [ ":base_module_java", @@ -242,6 +203,7 @@ if (current_toolchain == default_toolchain) { "$google_play_services_package:google_play_services_vision_java", "//base:jni_java", "//cc:cc_java", + "//cc/mojom:mojom_java", "//chrome/android/features/keyboard_accessory:public_java", "//chrome/android/features/start_surface:java_resources", "//chrome/android/features/start_surface:public_java", @@ -279,6 +241,7 @@ if (current_toolchain == default_toolchain) { "//chrome/browser/creator/android:java", "//chrome/browser/dependency_injection:java", "//chrome/browser/device:java", + "//chrome/browser/device_reauth/android:java", "//chrome/browser/download/android:factory_java", "//chrome/browser/download/android:file_provider_java", "//chrome/browser/download/android:java", @@ -291,6 +254,7 @@ if (current_toolchain == default_toolchain) { "//chrome/browser/first_run/android:java", "//chrome/browser/flags:java", "//chrome/browser/fullscreen/android:java", + "//chrome/browser/gesturenav/android:java", "//chrome/browser/gsa:java", "//chrome/browser/history_clusters:java", "//chrome/browser/history_clusters:java_resources", @@ -303,10 +267,8 @@ if (current_toolchain == default_toolchain) { "//chrome/browser/locale:java", "//chrome/browser/metrics_settings/android:java", "//chrome/browser/notifications/chime/android:java", - "//chrome/browser/offline_pages/android:java", "//chrome/browser/omaha/android:java", "//chrome/browser/optimization_guide/android:java", - "//chrome/browser/page_annotations/android:java", "//chrome/browser/paint_preview/android:java", "//chrome/browser/partnerbookmarks:delegate_java", "//chrome/browser/partnercustomizations:delegate_java", @@ -323,6 +285,8 @@ if (current_toolchain == default_toolchain) { "//chrome/browser/privacy_sandbox/android:java", "//chrome/browser/profiles/android:java", "//chrome/browser/quick_delete:java", + "//chrome/browser/recent_tabs:factory_java", + "//chrome/browser/recent_tabs:java", "//chrome/browser/safe_browsing/android:java", "//chrome/browser/safety_check/android:java", "//chrome/browser/search_engines/android:java", @@ -343,6 +307,9 @@ if (current_toolchain == default_toolchain) { "//chrome/browser/ui/android/appmenu:factory_java", "//chrome/browser/ui/android/appmenu:java", "//chrome/browser/ui/android/default_browser_promo:java", + "//chrome/browser/ui/android/device_lock:java", + "//chrome/browser/ui/android/edge_to_edge:factory_java", + "//chrome/browser/ui/android/edge_to_edge:java", "//chrome/browser/ui/android/fast_checkout:java", "//chrome/browser/ui/android/favicon:java", "//chrome/browser/ui/android/layouts:java", @@ -367,6 +334,7 @@ if (current_toolchain == default_toolchain) { "//chrome/browser/version:java", "//chrome/browser/video_tutorials:factory_java", "//chrome/browser/video_tutorials:java", + "//chrome/browser/video_tutorials:java_resources", "//chrome/browser/webapps/android:java", "//chrome/browser/webauthn/android:java", "//chrome/browser/xsurface:java", @@ -397,15 +365,17 @@ if (current_toolchain == default_toolchain) { "//components/browser_ui/util/android:java", "//components/browser_ui/webshare/android:java", "//components/browser_ui/widget/android:java", + "//components/browsing_data/core:java", "//components/commerce/core:proto_java", "//components/commerce/core/android:core_java", "//components/component_updater/android:background_task_update_scheduler_java", "//components/content_capture/android:java", + "//components/content_relationship_verification/android:java", "//components/content_settings/android:content_settings_enums_java", "//components/content_settings/android:java", "//components/crash/android:anr_collector_java", "//components/crash/android:java", - "//components/digital_asset_links/android:java", + "//components/device_reauth:device_reauth_java_enums", "//components/digital_goods/mojom:mojom_java", "//components/dom_distiller/content/browser/android:dom_distiller_content_java", "//components/dom_distiller/core/android:dom_distiller_core_java", @@ -503,7 +473,7 @@ if (current_toolchain == default_toolchain) { "//components/webapps/common/android:webapk_install_java", "//components/webauthn/android:java", "//components/webrtc/android:java", - "//components/webxr/android:ar_java_interfaces", + "//components/webxr/android:xr_java", "//components/zoom/android:java", "//content/public/android:content_java", "//content/public/common:common_java", @@ -517,6 +487,7 @@ if (current_toolchain == default_toolchain) { "//mojo/public/java/system:system_impl_java", "//mojo/public/mojom/base:base_java", "//net/android:net_java", + "//services/audio/public/java:audio_feature_list_java", "//services/data_decoder/public/cpp/android:safe_json_java", "//services/device/public/java:device_feature_list_java", "//services/device/public/mojom:mojom_java", @@ -542,6 +513,7 @@ if (current_toolchain == default_toolchain) { "//third_party/android_media:android_media_java", "//third_party/android_swipe_refresh:android_swipe_refresh_java", "//third_party/androidx:androidx_activity_activity_java", + "//third_party/androidx:androidx_annotation_annotation_experimental_java", "//third_party/androidx:androidx_asynclayoutinflater_asynclayoutinflater_appcompat_java", "//third_party/androidx:androidx_browser_browser_java", "//third_party/androidx:androidx_collection_collection_java", @@ -577,21 +549,18 @@ if (current_toolchain == default_toolchain) { ":chrome_android_java_google_api_keys_srcjar", ":chrome_strict_mode_switch", ":resource_id_javagen", - ":vr_build_config", "//chrome:offline_pages_enum_javagen", "//chrome:partner_bookmarks_javagen", - "//chrome:supervised_user_url_filter_enum_javagen", "//chrome/browser:screenshot_mode_enum", "//chrome/browser:sharing_dialog_type_generated_enum", "//chrome/browser:sharing_send_message_result_generated_enum", "//chrome/browser/notifications/scheduler/public:jni_enums", "//chrome/browser/ui:duplicate_download_enums_java", - "//components/browsing_data/core:browsing_data_utils_java", - "//components/browsing_data/core:clear_browsing_data_tab_java", "//components/contextual_search/core/browser:quick_action_category_enum_javagen", "//components/dom_distiller/core:distiller_type_java", "//components/ntp_tiles:ntp_tiles_enums_java", "//components/offline_pages/core:offline_page_model_enums_java", + "//components/supervised_user/core/browser:supervised_user_url_filter_enum_javagen", "//net:effective_connection_type_java", ] @@ -604,25 +573,15 @@ if (current_toolchain == default_toolchain) { sources += public_vr_java_sources - # Include sources from public_tab_management_java_sources.gni. + # Include sources from tab_management_java_sources.gni. sources += public_tab_management_java_sources + + # TODO(crbug/1422324): Make tab_ui/ a module so that these sources can be included in "chrome_all_java". + sources += internal_tab_management_java_sources + + # Include sources for start_surface_java_sources.gni sources += start_surface_java_sources - if (enable_arcore) { - deps += [ - "//components/webxr/android:ar_java_base", - "//components/webxr/android:webxr_android_enums_java", - ] - } - - if (enable_cardboard) { - deps += [ "//third_party/cardboard:cardboard_java" ] - } - - if (enable_vr) { - deps += [ ":chrome_vr_java_resources" ] - } - srcjar_deps += [ ":chrome_vr_android_java_enums_srcjar" ] # Add the actual implementation where necessary so that downstream targets @@ -715,16 +674,17 @@ if (current_toolchain == default_toolchain) { "//chrome/browser/commerce/merchant_viewer/android:java", "//chrome/browser/content_creation/notes/internal/android:java", "//chrome/browser/download/internal/android:java", - "//chrome/browser/page_annotations/android:java", "//chrome/browser/password_check:internal_java", "//chrome/browser/password_edit_dialog/android:java", "//chrome/browser/password_entry_edit/android/internal:java", + "//chrome/browser/recent_tabs/internal:java", "//chrome/browser/tabmodel/internal:java", "//chrome/browser/touch_to_fill/android/internal:java", "//chrome/browser/touch_to_fill/common/android:java", "//chrome/browser/touch_to_fill/payments/android/internal:java", "//chrome/browser/ui/android/appmenu/internal:java", "//chrome/browser/ui/android/autofill/internal:java", + "//chrome/browser/ui/android/edge_to_edge/internal:java", "//chrome/browser/ui/android/fast_checkout/internal:java", "//chrome/browser/ui/android/webid/internal:java", "//chrome/browser/video_tutorials/internal:java", @@ -732,13 +692,6 @@ if (current_toolchain == default_toolchain) { "//components/messages/android/internal:java", "//components/segmentation_platform/internal:internal_java", ] - - if (disable_tab_ui_dfm) { - deps += [ - "//chrome/android/features/tab_ui:java", - "//chrome/android/features/tab_ui:module_desc_java", - ] - } } action_with_pydeps("chrome_android_java_google_api_keys_srcjar") { @@ -757,6 +710,7 @@ if (current_toolchain == default_toolchain) { "//chrome/browser/android/policy/policy_auditor.cc", "//chrome/browser/android/webapk/webapk_installer.h", "//chrome/browser/long_screenshots/long_screenshots_tab_service.h", + "//chrome/browser/metrics/metrics_reporting_state.h", "//chrome/browser/notifications/notification_handler.h", "//chrome/browser/notifications/notification_platform_bridge_android.cc", ] @@ -806,8 +760,6 @@ if (current_toolchain == default_toolchain) { # This target OOMs with the default 1G (also OOMS with 2G). max_heap_size = "4G" - data_deps = [ "//testing/buildbot/filters:chrome_junit_tests_filters" ] - package_name = chrome_public_manifest_package # From java_sources.gni. @@ -833,17 +785,17 @@ if (current_toolchain == default_toolchain) { "$google_play_services_package:google_play_services_cast_java", "$google_play_services_package:google_play_services_gcm_java", "//base:base_java_test_support", + "//base:base_java_test_support_uncommon", "//base:base_junit_test_support", "//base/test:test_support_java", - "//build/config/android/test/classpath_order:junit_tests", "//cc:cc_java", + "//cc/mojom:mojom_java", "//chrome/android:update_proto_java", "//chrome/android:usage_stats_proto_java", "//chrome/android/features/android_library_factory:junit_tests", "//chrome/android/features/keyboard_accessory:internal_java", "//chrome/android/features/start_surface:java_resources", "//chrome/android/features/start_surface:public_java", - "//chrome/android/features/tab_ui:java", "//chrome/android/features/tab_ui:tab_suggestions_java", "//chrome/android/features/tab_ui/public:java", "//chrome/android/modules/image_editor/provider:java", @@ -909,7 +861,6 @@ if (current_toolchain == default_toolchain) { "//chrome/browser/notifications:junit_tests", "//chrome/browser/omaha/android:java", "//chrome/browser/optimization_guide/android:java", - "//chrome/browser/page_annotations/test/android:junit", "//chrome/browser/partnercustomizations:java", "//chrome/browser/password_edit_dialog/android:junit", "//chrome/browser/password_entry_edit/android/internal:junit", @@ -922,6 +873,11 @@ if (current_toolchain == default_toolchain) { "//chrome/browser/privacy_guide/android:java", "//chrome/browser/privacy_guide/android:junit", "//chrome/browser/profiles/android:java", + "//chrome/browser/profiles/android:junit", + "//chrome/browser/quick_delete:java", + "//chrome/browser/quick_delete:junit", + "//chrome/browser/recent_tabs:java", + "//chrome/browser/recent_tabs/internal:junit", "//chrome/browser/safety_check/android:java", "//chrome/browser/safety_check/android:junit", "//chrome/browser/search_engines/android:java", @@ -931,6 +887,7 @@ if (current_toolchain == default_toolchain) { "//chrome/browser/share:java", "//chrome/browser/signin/services/android:java", "//chrome/browser/signin/services/android:junit", + "//chrome/browser/supervised_user:junit", "//chrome/browser/sync/android:java", "//chrome/browser/tab:java", "//chrome/browser/tab:junit", @@ -949,6 +906,8 @@ if (current_toolchain == default_toolchain) { "//chrome/browser/ui/android/autofill/internal:junit", "//chrome/browser/ui/android/default_browser_promo:java", "//chrome/browser/ui/android/default_browser_promo:junit", + "//chrome/browser/ui/android/device_lock:junit", + "//chrome/browser/ui/android/edge_to_edge/internal:junit", "//chrome/browser/ui/android/fast_checkout/internal:junit", "//chrome/browser/ui/android/favicon:java", "//chrome/browser/ui/android/layouts:java", @@ -989,6 +948,7 @@ if (current_toolchain == default_toolchain) { "//chrome/test:sync_integration_test_support_java", "//chrome/test/android:chrome_java_unit_test_support", "//components/autofill/android:main_autofill_java", + "//components/autofill/android:prefeditor_autofill_java", "//components/background_task_scheduler:background_task_scheduler_java", "//components/background_task_scheduler:background_task_scheduler_task_ids_java", "//components/bookmarks/common/android:bookmarks_java", @@ -1012,9 +972,9 @@ if (current_toolchain == default_toolchain) { "//components/commerce/core:proto_java", "//components/commerce/core/android:core_java", "//components/content_capture/android:java", + "//components/content_relationship_verification/android:java", + "//components/content_relationship_verification/android:junit_test_support", "//components/content_settings/android:content_settings_enums_java", - "//components/digital_asset_links/android:java", - "//components/digital_asset_links/android:junit_test_support", "//components/digital_goods/mojom:mojom_java", "//components/dom_distiller/core/android:dom_distiller_core_java", "//components/embedder_support/android:content_view_java", @@ -1053,6 +1013,7 @@ if (current_toolchain == default_toolchain) { "//components/search_engines/android:java", "//components/security_state/content/android:java", "//components/security_state/core:security_state_enums_java", + "//components/segmentation_platform/public:junit", "//components/segmentation_platform/public:public_java", "//components/signin/core/browser:signin_enums_java", "//components/signin/public/android:java", @@ -1087,8 +1048,6 @@ if (current_toolchain == default_toolchain) { "//third_party/android_deps:guava_android_java", "//third_party/android_deps:material_design_java", "//third_party/android_deps:protobuf_lite_runtime_java", - "//third_party/android_support_test_runner:rules_java", - "//third_party/android_support_test_runner:runner_java", "//third_party/androidx:androidx_activity_activity_java", "//third_party/androidx:androidx_appcompat_appcompat_java", "//third_party/androidx:androidx_browser_browser_java", @@ -1098,7 +1057,6 @@ if (current_toolchain == default_toolchain) { "//third_party/androidx:androidx_swiperefreshlayout_swiperefreshlayout_java", "//third_party/androidx:androidx_test_core_java", "//third_party/androidx:androidx_test_ext_junit_java", - "//third_party/androidx:androidx_test_runner_java", "//third_party/blink/public:blink_headers_java", "//third_party/blink/public/mojom:android_mojo_bindings_java", "//third_party/blink/public/mojom:mojom_core_java", @@ -1133,6 +1091,7 @@ if (current_toolchain == default_toolchain) { # Files used by chrome integration and unit javatests. android_library("chrome_unit_test_util_java") { testonly = true + resources_package = "org.chromium.chrome" sources = [ "javatests/src/org/chromium/chrome/browser/compositor/bottombar/OverlayPanelManagerWrapper.java", @@ -1152,9 +1111,9 @@ if (current_toolchain == default_toolchain) { "//components/offline_items_collection/core:core_java", "//content/public/android:content_main_dex_java", "//content/public/test/android:content_java_test_support", - "//third_party/android_support_test_runner:runner_java", "//third_party/androidx:androidx_annotation_annotation_java", "//third_party/androidx:androidx_browser_browser_java", + "//third_party/androidx:androidx_test_monitor_java", "//third_party/junit:junit", "//url:gurl_java", ] @@ -1163,6 +1122,7 @@ if (current_toolchain == default_toolchain) { # Files used for both chrome tests and VR/AR tests android_library("chrome_test_util_java") { testonly = true + resources_package = "org.chromium.chrome" sources = [ "javatests/src/org/chromium/chrome/browser/FederatedIdentityTestUtils.java", @@ -1179,6 +1139,7 @@ if (current_toolchain == default_toolchain) { deps = [ ":browser_java_test_support", + ":chrome_app_java_resources", "//base:base_java", "//base:base_java_test_support", "//base:jni_java", @@ -1193,6 +1154,7 @@ if (current_toolchain == default_toolchain) { "//chrome/test/android:chrome_java_integration_test_support", "//components/autofill/android:prefeditor_autofill_java", "//components/payments/content/android:java", + "//components/payments/content/android:java_resources", "//components/payments/content/android:service_java", "//components/payments/mojom:mojom_java", "//content/public/android:content_java", @@ -1200,9 +1162,10 @@ if (current_toolchain == default_toolchain) { "//net/android:net_java_test_support", "//third_party/android_deps:espresso_java", "//third_party/android_media:android_media_resources", - "//third_party/android_support_test_runner:runner_java", "//third_party/androidx:androidx_annotation_annotation_java", "//third_party/androidx:androidx_browser_browser_java", + "//third_party/androidx:androidx_test_core_java", + "//third_party/androidx:androidx_test_monitor_java", "//third_party/blink/public/mojom:android_mojo_bindings_java", "//third_party/hamcrest:hamcrest_java", "//third_party/junit:junit", @@ -1220,13 +1183,13 @@ if (current_toolchain == default_toolchain) { android_library("chrome_unit_test_java") { testonly = true - resources_package = "org.chromium.chrome.test" + resources_package = "org.chromium.chrome" sources = [ "javatests/src/org/chromium/chrome/browser/IntentFilterUnitTest.java", "javatests/src/org/chromium/chrome/browser/IntentHandlerUnitTest.java", "javatests/src/org/chromium/chrome/browser/autofill/AutofillUnitTest.java", - "javatests/src/org/chromium/chrome/browser/bookmarks/BookmarkActionBarTest.java", "javatests/src/org/chromium/chrome/browser/bookmarks/BookmarkItemRowTest.java", + "javatests/src/org/chromium/chrome/browser/bookmarks/BookmarkToolbarTest.java", "javatests/src/org/chromium/chrome/browser/bookmarks/PowerBookmarkShoppingItemRowTest.java", "javatests/src/org/chromium/chrome/browser/bookmarks/PowerBookmarkUtilsTest.java", "javatests/src/org/chromium/chrome/browser/compositor/bottombar/OverlayPanelBaseTest.java", @@ -1262,7 +1225,6 @@ if (current_toolchain == default_toolchain) { "javatests/src/org/chromium/chrome/browser/tab/WebContentsStateBridgeTest.java", "javatests/src/org/chromium/chrome/browser/tab/state/FilePersistedTabDataStorageTest.java", "javatests/src/org/chromium/chrome/browser/tab/state/PersistedTabDataTest.java", - "javatests/src/org/chromium/chrome/browser/tab/state/PriceDropMetricsLoggerTest.java", "javatests/src/org/chromium/chrome/browser/tabmodel/AsyncTabCreationParamsManagerTest.java", "javatests/src/org/chromium/chrome/browser/tabmodel/RestoreMigrateTest.java", "javatests/src/org/chromium/chrome/browser/tabmodel/TabPersistentStoreUnitTest.java", @@ -1345,11 +1307,11 @@ if (current_toolchain == default_toolchain) { "//third_party/android_deps:guava_android_java", "//third_party/android_sdk:android_test_base_java", "//third_party/android_sdk:android_test_mock_java", - "//third_party/android_support_test_runner:rules_java", - "//third_party/android_support_test_runner:runner_java", "//third_party/androidx:androidx_annotation_annotation_java", "//third_party/androidx:androidx_browser_browser_java", "//third_party/androidx:androidx_core_core_java", + "//third_party/androidx:androidx_test_core_java", + "//third_party/androidx:androidx_test_monitor_java", "//third_party/androidx:androidx_test_runner_java", "//third_party/blink/public:blink_headers_java", "//third_party/hamcrest:hamcrest_core_java", @@ -1393,6 +1355,7 @@ if (current_toolchain == default_toolchain) { "$google_play_services_package:google_play_services_tasks_java", "//base:base_java", "//base:base_java_test_support", + "//base:base_java_test_support_uncommon", "//base:jni_java", "//base/test:test_support_java", "//build/android:build_java", @@ -1401,7 +1364,6 @@ if (current_toolchain == default_toolchain) { "//chrome/android/features/keyboard_accessory/public:public_java", "//chrome/android/features/start_surface:java_resources", "//chrome/android/features/start_surface:public_java", - "//chrome/android/features/tab_ui:java", "//chrome/android/features/tab_ui:java_resources", "//chrome/android/features/tab_ui:tab_suggestions_java", "//chrome/android/features/tab_ui:test_support_javalib", @@ -1434,6 +1396,7 @@ if (current_toolchain == default_toolchain) { "//chrome/browser/contextmenu:java", "//chrome/browser/dependency_injection:java", "//chrome/browser/device:java", + "//chrome/browser/device_reauth/android:java", "//chrome/browser/download/android:file_provider_java", "//chrome/browser/download/android:java", "//chrome/browser/endpoint_fetcher:java", @@ -1458,12 +1421,9 @@ if (current_toolchain == default_toolchain) { "//chrome/browser/locale:java", "//chrome/browser/notifications:java", "//chrome/browser/notifications:javatests", - "//chrome/browser/offline_pages/android:java", "//chrome/browser/omaha/android:java", "//chrome/browser/optimization_guide/android:java", "//chrome/browser/optimization_guide/android:javatests", - "//chrome/browser/page_annotations/android:java", - "//chrome/browser/page_annotations/test/android:javatests", "//chrome/browser/paint_preview/android:java", "//chrome/browser/paint_preview/android:javatests", "//chrome/browser/partnercustomizations:delegate_java", @@ -1482,6 +1442,8 @@ if (current_toolchain == default_toolchain) { "//chrome/browser/privacy_sandbox/android:java", "//chrome/browser/privacy_sandbox/android:javatests", "//chrome/browser/profiles/android:java", + "//chrome/browser/quick_delete:java", + "//chrome/browser/quick_delete:javatests", "//chrome/browser/safe_browsing/android:java", "//chrome/browser/safe_browsing/android:javatests", "//chrome/browser/safety_check/android:java", @@ -1506,8 +1468,12 @@ if (current_toolchain == default_toolchain) { "//chrome/browser/tabpersistence:java", "//chrome/browser/thumbnail:java", "//chrome/browser/thumbnail:javatests", + "//chrome/browser/touch_to_fill/payments/android/internal:java_resources", "//chrome/browser/ui/android/appmenu:java", "//chrome/browser/ui/android/appmenu/test:test_support_java", + "//chrome/browser/ui/android/device_lock:java", + "//chrome/browser/ui/android/device_lock:java_resources", + "//chrome/browser/ui/android/device_lock:javatests", "//chrome/browser/ui/android/favicon:java", "//chrome/browser/ui/android/layouts:java", "//chrome/browser/ui/android/layouts/test:java", @@ -1546,6 +1512,7 @@ if (current_toolchain == default_toolchain) { "//components/browser_ui/display_cutout/android:java", "//components/browser_ui/media/android:java", "//components/browser_ui/modaldialog/android:java", + "//components/browser_ui/modaldialog/android:java_test_resources", "//components/browser_ui/modaldialog/android:test_support_java", "//components/browser_ui/notifications/android:java", "//components/browser_ui/notifications/android:test_support_java", @@ -1555,12 +1522,14 @@ if (current_toolchain == default_toolchain) { "//components/browser_ui/share/android:javatests", "//components/browser_ui/site_settings/android:constants_java", "//components/browser_ui/site_settings/android:java", + "//components/browser_ui/site_settings/android:java_resources", "//components/browser_ui/site_settings/android:javatests", "//components/browser_ui/sms/android:java", "//components/browser_ui/styles/android:java", "//components/browser_ui/util/android:java", "//components/browser_ui/widget/android:java", "//components/browser_ui/widget/android:test_support_java", + "//components/browsing_data/core:java", "//components/commerce/core:proto_java", "//components/commerce/core/android:core_java", "//components/content_settings/android:content_settings_enums_java", @@ -1598,13 +1567,13 @@ if (current_toolchain == default_toolchain) { "//components/media_router/browser/android:test_support_java", "//components/messages/android:java", "//components/messages/android/internal:java", + "//components/messages/android/internal:java_resources", "//components/messages/android/test:test_support_java", "//components/metrics:metrics_java", "//components/minidump_uploader:minidump_uploader_java", "//components/minidump_uploader:minidump_uploader_java_test_support", "//components/navigation_interception/android:navigation_interception_java", "//components/offline_items_collection/core:core_java", - "//components/offline_pages/core/prefetch:offline_prefetch_proto_java", "//components/omnibox/browser:browser_java", "//components/omnibox/browser:junit_test_support", "//components/optimization_guide/proto:optimization_guide_proto_java", @@ -1636,6 +1605,7 @@ if (current_toolchain == default_toolchain) { "//components/signin/core/browser:signin_enums_java", "//components/signin/public/android:java", "//components/signin/public/android:signin_java_test_support", + "//components/signin/public/android:signin_test_resources", "//components/site_engagement/content/android:java", "//components/sync/android:sync_java", "//components/sync/protocol:protocol_java", @@ -1676,12 +1646,13 @@ if (current_toolchain == default_toolchain) { "//third_party/android_sdk:android_test_base_java", "//third_party/android_sdk:android_test_mock_java", "//third_party/android_sdk:android_test_runner_java", - "//third_party/android_support_test_runner:rules_java", - "//third_party/android_support_test_runner:runner_java", "//third_party/androidx:androidx_activity_activity_java", "//third_party/androidx:androidx_browser_browser_java", "//third_party/androidx:androidx_collection_collection_java", "//third_party/androidx:androidx_preference_preference_java", + "//third_party/androidx:androidx_test_core_java", + "//third_party/androidx:androidx_test_monitor_java", + "//third_party/androidx:androidx_test_rules_java", "//third_party/androidx:androidx_test_runner_java", "//third_party/androidx:androidx_test_uiautomator_uiautomator_java", "//third_party/androidx:androidx_viewpager2_viewpager2_java", @@ -1794,10 +1765,10 @@ if (current_toolchain == default_toolchain) { "//content/public/android:content_java", "//content/public/test/android:content_java_test_support", "//net/android:net_java_test_support", - "//third_party/android_support_test_runner:rules_java", - "//third_party/android_support_test_runner:runner_java", "//third_party/androidx:androidx_annotation_annotation_java", "//third_party/androidx:androidx_browser_browser_java", + "//third_party/androidx:androidx_test_monitor_java", + "//third_party/androidx:androidx_test_rules_java", "//third_party/androidx:androidx_test_runner_java", "//third_party/androidx:androidx_test_uiautomator_uiautomator_java", "//third_party/junit", @@ -1836,6 +1807,7 @@ if (current_toolchain == default_toolchain) { # All files necessary for VR instrumentation tests android_library("chrome_test_vr_java") { testonly = true + resources_package = "org.chromium.chrome.vr" sources = [ "javatests/src/org/chromium/chrome/browser/vr/EmulatedVrController.java", @@ -1865,7 +1837,9 @@ if (current_toolchain == default_toolchain) { deps = chrome_test_xr_java_deps + [ ":chrome_test_util_java", + "//base:base_java_test_support_uncommon", "//chrome/android:chrome_test_xr_java", + "//chrome/android/features/vr:java_resources", "//chrome/browser/profiles/android:java", "//chrome/browser/settings:java", "//chrome/browser/tabmodel:java", @@ -1922,26 +1896,6 @@ if (current_toolchain == default_toolchain) { } } - # Overrides icon / name defined in chrome_app_java_resources. - android_resources("chrome_public_apk_resources") { - resource_overlay = true - sources = [ - "java/res_chromium/drawable-hdpi/fre_product_logo.png", - "java/res_chromium/drawable-hdpi/product_logo_name.png", - "java/res_chromium/drawable-mdpi/fre_product_logo.png", - "java/res_chromium/drawable-mdpi/product_logo_name.png", - "java/res_chromium/drawable-xhdpi/fre_product_logo.png", - "java/res_chromium/drawable-xhdpi/product_logo_name.png", - "java/res_chromium/drawable-xxhdpi/fre_product_logo.png", - "java/res_chromium/drawable-xxhdpi/product_logo_name.png", - "java/res_chromium/drawable-xxxhdpi/fre_product_logo.png", - "java/res_chromium/drawable-xxxhdpi/product_logo_name.png", - ] - - # Dep needed to ensure override works properly. - deps = [ ":chrome_app_java_resources" ] - } - # Overrides icon / name defined in chrome_base_module_resources. android_resources("chrome_public_apk_base_module_resources") { resource_overlay = true @@ -2004,47 +1958,6 @@ if (current_toolchain == default_toolchain) { variables = [ "manifest_package=$chrome_public_test_manifest_package" ] } - generate_jni_registration("chrome_jni_registration") { - targets = [ ":chrome_public_base_module_java" ] - if (enable_vr) { - targets += [ "//chrome/android/features/vr:java" ] - } - manual_jni_registration = true - file_exclusions = chrome_jni_file_exclusions - if (allow_jni_multiplexing) { - enable_jni_multiplexing = true - } - } - - # The test apks do not use chromium linker, but using manual JNI registration - # helps ensure that the correct classes are marked with @MainDex. - generate_jni_registration("chrome_jni_for_test_registration") { - testonly = true - targets = [ ":chrome_public_base_module_java_for_test" ] - if (enable_vr) { - targets += [ "//chrome/android/features/vr:java" ] - } - manual_jni_registration = true - file_exclusions = chrome_jni_file_exclusions - if (allow_jni_multiplexing) { - enable_jni_multiplexing = true - } - } - - if (allow_jni_multiplexing) { - generate_jni_registration("monochrome_jni_registration") { - targets = [ - ":monochrome_java", - ":chrome_all_java", - ] - if (enable_vr) { - targets += [ "//chrome/android/features/vr:java" ] - } - file_exclusions = chrome_jni_file_exclusions - enable_jni_multiplexing = true - } - } - # This template instantiates targets responsible for generating pak # resources. The generated target names are derived from input variables. # @@ -2293,8 +2206,6 @@ if (current_toolchain == default_toolchain) { sources = [ "javatests/src/org/chromium/chrome/browser/ServicificationBackgroundService.java", "javatests/src/org/chromium/chrome/browser/offlinepages/OfflineTestUtil.java", - "javatests/src/org/chromium/chrome/browser/offlinepages/prefetch/PrefetchTestBridge.java", - "javatests/src/org/chromium/chrome/browser/query_tiles/QueryTileFakeServer.java", "javatests/src/org/chromium/chrome/browser/sync/FakeServerHelper.java", "javatests/src/org/chromium/chrome/browser/test/MockCertVerifierRuleAndroid.java", ] @@ -2306,8 +2217,6 @@ if (current_toolchain == default_toolchain) { sources = [ "javatests/src/org/chromium/chrome/browser/ServicificationBackgroundService.java", "javatests/src/org/chromium/chrome/browser/offlinepages/OfflineTestUtil.java", - "javatests/src/org/chromium/chrome/browser/offlinepages/prefetch/PrefetchTestBridge.java", - "javatests/src/org/chromium/chrome/browser/query_tiles/QueryTileFakeServer.java", "javatests/src/org/chromium/chrome/browser/sync/FakeServerHelper.java", "javatests/src/org/chromium/chrome/browser/test/MockCertVerifierRuleAndroid.java", ] @@ -2345,8 +2254,6 @@ if (current_toolchain == default_toolchain) { "../browser/android/ssl/mock_cert_verifier_rule_android.cc", "../browser/android/ssl/mock_cert_verifier_rule_android.h", "../browser/offline_pages/android/offline_test_util_jni.cc", - "../browser/offline_pages/android/prefetch_test_bridge.cc", - "../browser/query_tiles/query_tile_fake_server.cc", "../browser/sync/android/fake_server_helper_android.cc", ] deps = [ @@ -2365,54 +2272,11 @@ if (current_toolchain == default_toolchain) { ] } - # Defines a target that derives from the chrome public application. This - # can be either an APK or an app bundle module. This supports - # chrome_public_xxx targets (for Android L-M). For Android N+, see instead - # monochrome_public_apk_or_module_tmpl() below. - # - # Variables: - # target_type: Determines the final target type. Should be one of - # 'android_apk', or 'android_app_bundle_module'. - # apk_name: For 'android_apk' target types, name of the final APK without - # an .apk suffix (e.g. 'ChromePublic'). - # is_base_module: For 'android_app_bundle_module' target types only, - # set to true to indicate that this is a base application module - # (instead of a feature module). - template("chrome_public_apk_or_module_tmpl") { - _is_bundle_module = invoker.target_type == "android_app_bundle_module" - chrome_public_common_apk_or_module_tmpl(target_name) { - forward_variables_from(invoker, - [ - "add_view_trace_events", - "apk_name", - "bundle_target", - "is_base_module", - "target_type", - "enable_lint", - "enable_multidex", - "lint_baseline_file", - "lint_suppressions_dep", - "lint_suppressions_file", - "manual_jni_registration", - ]) - deps = chrome_public_shared_deps - - if (_is_bundle_module) { - deps += [ ":chrome_bundle_module_pak_assets" ] - } else { - deps += [ ":chrome_apk_pak_assets" ] - } - - shared_libraries = [ ":libchrome" ] - - version_name = chrome_version_name - } - } - chrome_public_apk_or_module_tmpl("chrome_public_apk") { target_type = "android_apk" apk_name = "ChromePublic" enable_multidex = is_java_debug + baseline_profile_path = "//chrome/android/baseline_profiles/profile.txt" } android_library("monochrome_java") { @@ -2561,83 +2425,6 @@ if (current_toolchain == default_toolchain) { annotation_processor_deps = [ "//base/android/jni_generator:jni_processor" ] } - # Defines a target that derives from the monochrome public application. This - # can be either an APK or an app bundle module. Note that these only work - # on Android N+ devices, see chrome_public_apk_or_module_tmpl() for a template - # that supports generating targets for older Android releases. - # - # Variables: - # target_type: Either 'android_apk' or 'android_app_bundle_module'. - # apk_name: For APK target types, the final APK name without an .apk - # suffix (e.g. "MonochromePublic"). - # is_base_module: For module target types, a boolean indicating whether - # this is a base bundle module (instead of a feature one). - # is_64_bit_browser: When compiling in a 64-bit configuration, a boolean - # indicating whether the browser is 64-bit or 32-bit. - # include_32_bit_webview: When compiling a 64-bit browser configuration, if - # true, a 32-bit WebView library will also be built and included. - template("monochrome_public_apk_or_module_tmpl") { - _is_trichrome = defined(invoker.is_trichrome) && invoker.is_trichrome - _is_bundle = invoker.target_type == "android_app_bundle_module" - - monochrome_public_common_apk_or_module_tmpl(target_name) { - forward_variables_from(invoker, - [ - "add_view_trace_events", - "apk_name", - "bundle_target", - "expected_android_manifest", - "include_32_bit_webview", - "include_64_bit_webview", - "is_64_bit_browser", - "is_base_module", - "is_trichrome", - "resource_ids_provider_dep", - "static_library_provider", - "target_type", - "use_chromium_linker", - ]) - - if (!_is_trichrome) { - # Resource allowlist used when generating R.java files and causes - # only the webview subset of resources to be marked as non-final. - # Strings in this target will also be kept in the base apk rather than placed in the language splits. - shared_resources_allowlist_target = - "//android_webview:system_webview_no_weblayer_apk" - - # Ensure the localized resources for all locales are used, even when - # a smaller set is specified through aapt_locale_allowlist. - shared_resources_allowlist_locales = platform_pak_locales - } - - deps = [] - if (_is_bundle) { - deps += [ - "//chrome/android:chrome_base_module_resources", - - # deps in delegate_public_impl_java are put into the Chrome module, but the language deps - # are needed by the base module. - "//components/language/android:ulp_delegate_public_java", - ] - } else { - deps += [ ":delegate_public_impl_java" ] - } - if (!_is_trichrome) { - deps += [ - "//android_webview:platform_service_bridge_upstream_implementation_java", - "//android_webview/nonembedded:icon_resources", - "//android_webview/nonembedded:monochrome_devui_launcher_icon_resources", - ] - if (!_is_bundle) { - deps += [ ":monochrome_java" ] - } - if (webview_includes_weblayer) { - deps += [ "//weblayer/browser/java:upstream_java" ] - } - } - } - } - if (android_64bit_target_cpu && skip_secondary_abi_for_cq) { group("trichrome_library_apk") { deps = [ ":trichrome_library_64_apk" ] @@ -2646,7 +2433,8 @@ if (current_toolchain == default_toolchain) { deps = [ ":monochrome_64_public_apk" ] } } else { - monochrome_public_apk_or_module_tmpl("monochrome_public_apk") { + chrome_public_apk_or_module_tmpl("monochrome_public_apk") { + is_monochrome = true apk_name = "MonochromePublic" target_type = "android_apk" if (android_64bit_target_cpu) { @@ -2685,7 +2473,8 @@ if (current_toolchain == default_toolchain) { } if (android_64bit_target_cpu) { - monochrome_public_apk_or_module_tmpl("monochrome_64_public_apk") { + chrome_public_apk_or_module_tmpl("monochrome_64_public_apk") { + is_monochrome = true apk_name = "MonochromePublic64" target_type = "android_apk" is_64_bit_browser = true @@ -2729,9 +2518,8 @@ if (current_toolchain == default_toolchain) { # that require on device capabilities. These tests are smaller, more tightly # scoped, and do not leave lingering state after execution. # TODO(crbug.com/1238057): Set clear rules for what tests can be added here. - chrome_test_apk_tmpl("chrome_public_unit_test_apk") { + chrome_public_test_apk_tmpl("chrome_public_unit_test_apk") { apk_name = "ChromePublicUnitTest" - shared_libraries = [ ":libchromefortest" ] deps = [ ":chrome_unit_test_java", "//build/config/android/test/resource_overlay:unit_device_javatests", @@ -2789,12 +2577,11 @@ if (current_toolchain == default_toolchain) { } # TODO(crbug.com/1238057): Rename to chrome_public_integration_test_apk - chrome_test_apk_tmpl("chrome_public_test_apk") { + chrome_public_test_apk_tmpl("chrome_public_test_apk") { # TODO(wnwen): Re-enable when new lint failures are disabled for test targets. #enable_lint = true apk_name = "ChromePublicTest" - shared_libraries = [ ":libchromefortest" ] deps = [ ":chrome_test_apk_template_resources", ":chrome_test_java", @@ -2837,9 +2624,9 @@ if (current_toolchain == default_toolchain) { } if (enable_vr) { - chrome_test_apk_tmpl("chrome_public_test_vr_apk") { + # //chrome/android/javatests/src/org/chromium/chrome/browser/vr/README.md + chrome_public_test_apk_tmpl("chrome_public_test_vr_apk") { apk_name = "ChromePublicTestVr" - shared_libraries = [ ":libchromefortest" ] manifest_package = chrome_public_manifest_package deps = [ @@ -2857,55 +2644,19 @@ if (current_toolchain == default_toolchain) { } if (enable_arcore) { - monochrome_test_apk_tmpl("monochrome_public_test_ar_apk") { + # In order to run this test, first run: + # DOWNLOAD_VR_TEST_APKS=1 third_party/arcore-android-sdk/test-apks/update.py + # See also: //chrome/android/javatests/src/org/chromium/chrome/browser/vr/README.md + chrome_public_test_apk_tmpl("monochrome_public_test_ar_apk") { apk_name = "MonochromePublicTestAr" - min_sdk_version = 24 - target_sdk_version = android_sdk_version - - if (android_64bit_target_cpu) { - is_64_bit_browser = skip_secondary_abi_for_cq - include_32_bit_webview = !skip_secondary_abi_for_cq - } - - # This is where we would add the shared_libraries entry for - # :libchromefortest in the non-Monochrome version. However, doing so in the - # Monochrome version causes Chrome to crash on startup due to being unable - # to load the library, and looking at the libraries included in the APK - # shows both libchromefortest and libmonochrome, when only one should be - # present. The tests currently work fine with just libmonochrome, so keep - # it this way until we actually need the test-only library. This may be - # related to monochrome_public_common_apk_or_module_tmpl adding its own - # shared libraries, but chrome_public_common_apk_or_module_tmpl not. See - # https://crbug.com/974017. - deps = [ - ":chrome_test_ar_java", - "//third_party/android_sdk:android_test_mock_java", + deps = [ ":chrome_test_ar_java" ] + extra_args = [ + "--additional-apk", + rebase_path( + "//third_party/arcore-android-sdk/test-apks/arcore/arcore_current.apk", + root_build_dir), + "--remove-system-package=com.google.ar.core", ] - - # Include ArCore files directly instead of using bundles. - deps += [ - "//components/webxr/android:ar_java", - "//third_party/arcore-android-sdk-client:com_google_ar_core_java", - "//third_party/arcore-android-sdk-client:com_google_ar_core_java__ignored_manifest", - ] - - _libarcore_dir = get_label_info( - "//third_party/arcore-android-sdk-client:com_google_ar_core_java($default_toolchain)", - "target_out_dir") + "/com_google_ar_core_java/jni" - - # We store this as a separate .so in the APK and only load as needed. - if (android_64bit_target_cpu) { - if (skip_secondary_abi_for_cq) { - loadable_modules = [ "$_libarcore_dir/arm64-v8a/libarcore_sdk_c.so" ] - } else { - secondary_abi_loadable_modules = - [ "$_libarcore_dir/armeabi-v7a/libarcore_sdk_c.so" ] - } - } else { - loadable_modules = [ "$_libarcore_dir/armeabi-v7a/libarcore_sdk_c.so" ] - } - - additional_apks = [ "//net/android:net_test_support_apk" ] } } @@ -2919,11 +2670,14 @@ if (current_toolchain == default_toolchain) { testonly = true sources = [ "javatests/src/org/chromium/chrome/test/smoke/ChromeSmokeTest.java" ] + data = [ "javatests/src/org/chromium/chrome/test/smoke/test.html" ] deps = [ "//base:base_java_test_support", "//chrome/test/android:chrome_java_test_pagecontroller", "//content/public/test/android:content_java_test_support", - "//third_party/android_support_test_runner:runner_java", + "//net/android:net_java_test_support", + "//third_party/androidx:androidx_test_core_java", + "//third_party/androidx:androidx_test_monitor_java", "//third_party/androidx:androidx_test_runner_java", "//third_party/androidx:androidx_test_uiautomator_uiautomator_java", "//third_party/hamcrest:hamcrest_library_java", @@ -2942,6 +2696,7 @@ if (current_toolchain == default_toolchain) { instrumentation_test_runner("chrome_public_smoke_test") { apk_under_test = ":chrome_public_apk" android_test_apk = ":chrome_smoke_test_apk" + additional_apks = [ "//net/android:net_test_support_apk" ] if (!is_java_debug) { proguard_mapping_path = "$root_build_dir/apks/ChromePublic.apk.mapping" } @@ -2966,6 +2721,7 @@ if (current_toolchain == default_toolchain) { } } android_test_apk = ":chrome_smoke_test_apk" + additional_apks = [ "//net/android:net_test_support_apk" ] never_incremental = true extra_args = _common_smoke_test_args } @@ -2987,7 +2743,8 @@ if (current_toolchain == default_toolchain) { "//base:base_java_test_support", "//chrome/test/android:chrome_java_test_pagecontroller", "//content/public/test/android:content_java_test_support", - "//third_party/android_support_test_runner:runner_java", + "//third_party/androidx:androidx_test_core_java", + "//third_party/androidx:androidx_test_monitor_java", "//third_party/androidx:androidx_test_runner_java", "//third_party/junit", ] @@ -3124,26 +2881,17 @@ if (current_toolchain == default_toolchain) { ] } - template("monochrome_or_trichrome_public_bundle_tmpl") { + template("chrome_bundle_tmpl") { + _is_monochrome = defined(invoker.is_monochrome) && invoker.is_monochrome + _base_module_target_name = "${invoker.target_name}__base_bundle_module" - _is_trichrome = defined(invoker.is_trichrome) && invoker.is_trichrome - - if (_is_trichrome) { - _bundle_name = "TrichromeChrome${invoker.bundle_suffix}" - _min_sdk_version = 29 - _module_descs = trichrome_module_descs - } else { - _bundle_name = "MonochromePublic${invoker.bundle_suffix}" - _min_sdk_version = 24 - _module_descs = monochrome_module_descs - } - - monochrome_public_apk_or_module_tmpl(_base_module_target_name) { + chrome_public_apk_or_module_tmpl(_base_module_target_name) { forward_variables_from(invoker, [ "add_view_trace_events", "expected_android_manifest", "is_64_bit_browser", + "is_monochrome", "is_trichrome", "include_32_bit_webview", "include_64_bit_webview", @@ -3151,7 +2899,6 @@ if (current_toolchain == default_toolchain) { "resource_ids_provider_dep", ]) target_type = "android_app_bundle_module" - is_base_module = true bundle_target = ":${invoker.target_name}" if (defined(invoker.expected_android_manifest_template)) { @@ -3166,10 +2913,13 @@ if (current_toolchain == default_toolchain) { forward_variables_from(invoker, [ "add_view_trace_events", + "baseline_profile_path", + "bundle_name", "enable_lint", "include_32_bit_webview", "include_64_bit_webview", "is_64_bit_browser", + "is_monochrome", "is_trichrome", "lint_baseline_file", "lint_min_sdk_version", @@ -3179,20 +2929,14 @@ if (current_toolchain == default_toolchain) { "expected_libs_and_assets", "expected_proguard_config", ]) - is_monochrome = !_is_trichrome base_module_target = ":$_base_module_target_name" - bundle_name = _bundle_name manifest_package = chrome_public_manifest_package - min_sdk_version = _min_sdk_version - module_descs = _module_descs + if (_is_monochrome) { + module_descs = monochrome_module_descs + } else { + module_descs = chrome_module_descs + } chrome_deps = [ ":delegate_public_impl_java" ] - if (!_is_trichrome) { - chrome_deps += [ "//chrome/android:monochrome_java" ] - } - - if (!is_java_debug) { - proguard_android_sdk_dep = webview_framework_dep - } } } @@ -3218,7 +2962,10 @@ if (current_toolchain == default_toolchain) { } else { # Public webview targets don't work with non-public sdks. # https://crbug.com/1000763 - monochrome_or_trichrome_public_bundle_tmpl("monochrome_public_bundle") { + chrome_bundle_tmpl("monochrome_public_bundle") { + is_monochrome = true + bundle_name = "MonochromePublic" + # Monochrome bundle is used as our unified lint target, so it needs to set the # lowest shipping minSdkVersion to catch all potential NewApi errors. lint_min_sdk_version = default_min_sdk_version @@ -3227,7 +2974,6 @@ if (current_toolchain == default_toolchain) { lint_suppressions_file = "expectations/lint-suppressions.xml" add_view_trace_events = true - bundle_suffix = "" if (android_64bit_target_cpu) { is_64_bit_browser = false include_64_bit_webview = true @@ -3258,11 +3004,12 @@ if (current_toolchain == default_toolchain) { } } - monochrome_or_trichrome_public_bundle_tmpl("trichrome_chrome_bundle") { - bundle_suffix = "" + chrome_bundle_tmpl("trichrome_chrome_bundle") { is_trichrome = true + bundle_name = "TrichromeChrome" static_library_provider = ":trichrome_library_apk" add_view_trace_events = true + baseline_profile_path = "//chrome/android/baseline_profiles/profile.txt" if (android_64bit_target_cpu) { is_64_bit_browser = false include_64_bit_webview = true @@ -3371,15 +3118,16 @@ if (current_toolchain == default_toolchain) { } if (android_64bit_target_cpu) { - monochrome_or_trichrome_public_bundle_tmpl("monochrome_64_public_bundle") { - bundle_suffix = "64" + chrome_bundle_tmpl("monochrome_64_public_bundle") { + is_monochrome = true + bundle_name = "MonochromePublic64" is_64_bit_browser = true include_32_bit_webview = false } - monochrome_or_trichrome_public_bundle_tmpl("trichrome_chrome_64_bundle") { + chrome_bundle_tmpl("trichrome_chrome_64_bundle") { is_trichrome = true - bundle_suffix = "64" + bundle_name = "TrichromeChrome64" is_64_bit_browser = true include_32_bit_webview = false static_library_provider = ":trichrome_library_64_apk" @@ -3390,24 +3138,23 @@ if (current_toolchain == default_toolchain) { } if (!skip_secondary_abi_for_cq) { - monochrome_or_trichrome_public_bundle_tmpl( - "monochrome_32_public_bundle") { - bundle_suffix = "32" + chrome_bundle_tmpl("monochrome_32_public_bundle") { + is_monochrome = true + bundle_name = "MonochromePublic32" is_64_bit_browser = false include_64_bit_webview = false } - monochrome_or_trichrome_public_bundle_tmpl( - "monochrome_64_32_public_bundle") { - bundle_suffix = "6432" + chrome_bundle_tmpl("monochrome_64_32_public_bundle") { + is_monochrome = true + bundle_name = "MonochromePublic6432" is_64_bit_browser = true include_32_bit_webview = true } - monochrome_or_trichrome_public_bundle_tmpl( - "trichrome_chrome_64_32_bundle") { + chrome_bundle_tmpl("trichrome_chrome_64_32_bundle") { is_trichrome = true - bundle_suffix = "6432" + bundle_name = "TrichromeChrome6432" is_64_bit_browser = true include_32_bit_webview = true static_library_provider = ":trichrome_library_64_32_apk" @@ -3416,9 +3163,9 @@ if (current_toolchain == default_toolchain) { "expectations/$target_name.$target_cpu.libs_and_assets.expected" } } - monochrome_or_trichrome_public_bundle_tmpl("trichrome_chrome_32_bundle") { + chrome_bundle_tmpl("trichrome_chrome_32_bundle") { is_trichrome = true - bundle_suffix = "32" + bundle_name = "TrichromeChrome32" is_64_bit_browser = false include_64_bit_webview = false static_library_provider = ":trichrome_library_32_apk" @@ -3435,7 +3182,6 @@ generate_jni("chrome_jni_headers") { sources = [ # Files under a feature's public/ dir are included in chrome_java's source # files, so include these files in chrome_jni_headers. - "java/src/org/chromium/chrome/browser/AppHooks.java", "java/src/org/chromium/chrome/browser/ApplicationLifetime.java", "java/src/org/chromium/chrome/browser/ChromeBackupAgentImpl.java", "java/src/org/chromium/chrome/browser/ChromeBackupWatcher.java", @@ -3561,7 +3307,6 @@ generate_jni("chrome_jni_headers") { "java/src/org/chromium/chrome/browser/notifications/PushMessagingServiceBridge.java", "java/src/org/chromium/chrome/browser/notifications/scheduler/DisplayAgent.java", "java/src/org/chromium/chrome/browser/notifications/scheduler/NotificationSchedulerTask.java", - "java/src/org/chromium/chrome/browser/ntp/ForeignSessionHelper.java", "java/src/org/chromium/chrome/browser/ntp/RecentTabsPagePrefs.java", "java/src/org/chromium/chrome/browser/ntp/RecentlyClosedBridge.java", "java/src/org/chromium/chrome/browser/offlinepages/AutoFetchNotifier.java", @@ -3572,8 +3317,6 @@ generate_jni("chrome_jni_headers") { "java/src/org/chromium/chrome/browser/offlinepages/RequestCoordinatorBridge.java", "java/src/org/chromium/chrome/browser/offlinepages/SavePageRequest.java", "java/src/org/chromium/chrome/browser/offlinepages/downloads/OfflinePageDownloadBridge.java", - "java/src/org/chromium/chrome/browser/offlinepages/prefetch/PrefetchBackgroundTask.java", - "java/src/org/chromium/chrome/browser/offlinepages/prefetch/PrefetchBackgroundTaskScheduler.java", "java/src/org/chromium/chrome/browser/page_info/PageInfoAboutThisSiteController.java", "java/src/org/chromium/chrome/browser/partnerbookmarks/PartnerBookmarksReader.java", "java/src/org/chromium/chrome/browser/password_manager/AccountChooserDialog.java", @@ -3702,7 +3445,7 @@ group("jni_headers") { "//chrome/browser/ui/messages/android:jni_headers", "//chrome/browser/util:jni_headers", "//chrome/browser/webauthn/android:jni_headers", - "//components/digital_asset_links/android:jni_headers", + "//components/content_relationship_verification/android:jni_headers", "//components/image_fetcher:jni_headers", "//components/media_router/browser/android:jni_headers", "//components/ukm/android:jni_headers", @@ -3714,7 +3457,7 @@ group("jni_headers") { template("libchrome_impl") { chrome_common_shared_library(target_name) { sources = [ "../browser/android/chrome_entry_point.cc" ] - deps = [ ":chrome_jni_registration($default_toolchain)" ] + deps = [] if (allow_jni_multiplexing) { enable_jni_multiplexing = true } @@ -3753,7 +3496,6 @@ chrome_common_shared_library("libchromefortest") { sources = [ "../browser/android/chrome_entry_point_for_test.cc" ] deps = [ ":browser_test_support", - ":chrome_jni_for_test_registration($default_toolchain)", ":chrome_test_util_jni", "//base/test:test_support", "//chrome:chrome_android_core", @@ -3806,8 +3548,6 @@ template("libmonochrome_apk_or_bundle_tmpl") { } if (allow_jni_multiplexing) { - defines += [ "JNI_REGISTRATION_REQUIRED" ] - deps += [ ":monochrome_jni_registration($default_toolchain)" ] enable_jni_multiplexing = true } diff --git a/src/chrome/android/chrome_public_apk_tmpl.gni b/src/chrome/android/chrome_public_apk_tmpl.gni index bb9cb36c..d4ac2f52 100644 --- a/src/chrome/android/chrome_public_apk_tmpl.gni +++ b/src/chrome/android/chrome_public_apk_tmpl.gni @@ -36,20 +36,18 @@ declare_args() { } } +chrome_public_test_manifest_package = "org.chromium.thorium.tests" + default_chrome_public_jinja_variables = [ "channel=$android_channel", "enable_cardboard=$enable_cardboard", "enable_vr=$enable_vr", - "include_arcore_manifest_flag=false", + "enable_arcore=$enable_arcore", "zygote_preload_class=org.chromium.content_public.app.ZygotePreload", ] -monochrome_android_manifest_jinja_variables = [ - "sandboxed_service_exported=true", - - # TODO(crbug.com/1411557): Remove. - use_32bit_abi_jinja_variable, -] +monochrome_android_manifest_jinja_variables = + [ "sandboxed_service_exported=true" ] # Generates an AndroidManifest.xml along with an optional second manifest # dependent on the original. @@ -110,8 +108,6 @@ template("split_manifest_template") { # Variables: # target_type: Either 'android_apk' or 'android_app_bundle_module'. # apk_name: For APK target types, the final APK name without a suffix. -# is_base_module: For bundle module target types, true iff this is a base -# application module, instead of a feature module. # shared_libraries: List of native shared libraries targets to include in # the final target (e.g. [ ":libchrome" ]). # is_monochrome: Indicates that this target contains chrome and webview @@ -125,29 +121,44 @@ template("split_manifest_template") { # Plus all other variables accepted by android_apk() or # android_app_bundle_module(), depending on the target type. # -template("chrome_public_common_apk_or_module_tmpl") { - assert( - invoker.target_type == "android_apk" || - invoker.target_type == "android_app_bundle_module" || - invoker.target_type == "instrumentation_test_apk", - "Invalid target_type definition, should be 'android_apk' or 'android_app_bundle_module'") +template("chrome_common_apk_or_module_tmpl") { + forward_variables_from(invoker, TESTONLY_AND_VISIBILITY) + + _target_type = invoker.target_type + assert(_target_type == "android_apk" || + _target_type == "android_app_bundle_module" || + _target_type == "instrumentation_test_apk") _is_monochrome = defined(invoker.is_monochrome) && invoker.is_monochrome _is_trichrome = defined(invoker.is_trichrome) && invoker.is_trichrome - _is_bundle = invoker.target_type == "android_app_bundle_module" + _is_bundle = _target_type == "android_app_bundle_module" + _is_test = _target_type == "instrumentation_test_apk" + assert(!(_is_test && _is_monochrome), "Unsupported configuration") + assert(!(_is_test && _is_trichrome), "Unsupported configuration") + if (_is_test) { + testonly = true + } + + _is_64_bit_browser = + android_64bit_target_cpu && + (!defined(invoker.is_64_bit_browser) || invoker.is_64_bit_browser) if (_is_trichrome || _is_monochrome) { _include_64_bit_webview = android_64bit_target_cpu && (!defined(invoker.include_64_bit_webview) || invoker.include_64_bit_webview) _include_32_bit_webview = !defined(invoker.include_32_bit_webview) || invoker.include_32_bit_webview + _include_primary_abi = !android_64bit_target_cpu || _is_64_bit_browser || + _include_64_bit_webview + _include_secondary_abi = android_64bit_target_cpu && + (!_is_64_bit_browser || _include_32_bit_webview) + if (_include_secondary_abi) { + _secondary_out_dir = + get_label_info("X($android_secondary_abi_toolchain)", "root_out_dir") + not_needed([ "_secondary_out_dir" ]) + } } - _is_64_bit_browser = - android_64bit_target_cpu && - (!defined(invoker.is_64_bit_browser) || invoker.is_64_bit_browser) - _is_secondary_abi_primary = !_is_64_bit_browser && android_64bit_target_cpu - not_needed([ "_is_secondary_abi_primary" ]) assert(!(_is_monochrome && _is_trichrome), "Cannot be both trichrome and monochrome!") @@ -155,125 +166,145 @@ template("chrome_public_common_apk_or_module_tmpl") { "If trichrome library is used, static_library_provider must be set " + "so that a dep can be added on the library APK.") - if (!defined(invoker.target_type)) { - _target_type = "android_apk" - } else { - _target_type = invoker.target_type - } - if (_is_trichrome) { _version_code = TRICHROME_VERSION_MAP["${android_64bit_target_cpu}_${_is_64_bit_browser}_${_include_64_bit_webview}_${_include_32_bit_webview}"] } else if (_is_monochrome) { _version_code = MONOCHROME_VERSION_MAP["${android_64bit_target_cpu}_${_is_64_bit_browser}_${_include_64_bit_webview}_${_include_32_bit_webview}"] } else { - # TODO(agrieve): Merge chrome_modern_version_code with chrome_version_code. - _version_code = chrome_modern_version_code + _version_code = chrome_version_code } - # TODO(crbug.com/1411557): Remove option for custom manifest. - if (!defined(invoker.android_manifest)) { - if (defined(invoker.manifest_package)) { - _manifest_package = invoker.manifest_package - } else { - _manifest_package = chrome_public_manifest_package - } + if (defined(invoker.manifest_package)) { + _manifest_package = invoker.manifest_package + } else if (_is_test) { + _manifest_package = chrome_public_test_manifest_package + } else { + _manifest_package = chrome_public_manifest_package + } - _android_manifest = "$target_gen_dir/$target_name/AndroidManifest.xml" - - # TODO(crbug.com/1411557): Move out of manifest/ when downstream is updated. - # _split.xml is used in chrome_bundle template. - _split_android_manifest = - "$target_gen_dir/manifest/$target_name/AndroidManifest_split.xml" - _android_manifest_target_name = "${target_name}__android_manifest" - split_manifest_template(_android_manifest_target_name) { - definitions_in_split = _is_bundle - split_input = "//chrome/android/java/AndroidManifest_split.xml" - split_output = _split_android_manifest - includes = [] - output = _android_manifest - variables = default_chrome_public_jinja_variables + - [ "manifest_package=$_manifest_package" ] - if (_is_trichrome) { - input = "//chrome/android/java/AndroidManifest_trichrome_chrome.xml" - includes = [ "//chrome/android/java/AndroidManifest.xml" ] - variables += - trichrome_jinja_variables + [ "trichrome_version=$_version_code" ] - } else if (_is_monochrome) { - input = "//chrome/android/java/AndroidManifest_monochrome.xml" - includes = [ - "//android_webview/nonembedded/java/AndroidManifest.xml", - "//chrome/android/java/AndroidManifest.xml", - ] - variables += monochrome_android_manifest_jinja_variables - if (_is_64_bit_browser) { - variables += [ "webview_library=libmonochrome_64.so" ] - } else { - variables += [ "webview_library=libmonochrome.so" ] - } + _android_manifest = "$target_gen_dir/$target_name/AndroidManifest.xml" + _split_android_manifest = + "$target_gen_dir/$target_name/AndroidManifest_split.xml" + _android_manifest_target_name = "${target_name}__android_manifest" + split_manifest_template(_android_manifest_target_name) { + definitions_in_split = _is_bundle + split_input = "//chrome/android/java/AndroidManifest_split.xml" + split_output = _split_android_manifest + includes = [] + output = _android_manifest + variables = default_chrome_public_jinja_variables + + [ "manifest_package=$_manifest_package" ] + if (_is_trichrome) { + input = "//chrome/android/java/AndroidManifest_trichrome_chrome.xml" + includes = [ "//chrome/android/java/AndroidManifest.xml" ] + variables += + trichrome_jinja_variables + [ "trichrome_version=$_version_code" ] + } else if (_is_monochrome) { + input = "//chrome/android/java/AndroidManifest_monochrome.xml" + includes = [ + "//android_webview/nonembedded/java/AndroidManifest.xml", + "//chrome/android/java/AndroidManifest.xml", + ] + variables += monochrome_android_manifest_jinja_variables + if (_is_64_bit_browser) { + variables += [ "webview_library=libmonochrome_64.so" ] } else { - input = "//chrome/android/java/AndroidManifest.xml" - } - if (_is_monochrome || _is_trichrome) { - _force_32_bit = _include_32_bit_webview && _include_64_bit_webview && - !_is_64_bit_browser - variables += [ - "force_32_bit=$_force_32_bit", - "include_arcore_manifest_flag=$enable_arcore", - ] - - # TODO(crbug.com/1411557): Remove block. - if (_is_64_bit_browser) { - variables -= [ use_32bit_abi_jinja_variable ] - } - } - if (defined(invoker.jinja_input)) { - includes += [ input ] - input = invoker.jinja_input - } - if (defined(invoker.jinja_extra_variables)) { - variables += invoker.jinja_extra_variables - } - if (defined(invoker.jinja_extra_includes)) { - includes += invoker.jinja_extra_includes + variables += [ "webview_library=libmonochrome.so" ] } + } else { + input = "//chrome/android/java/AndroidManifest.xml" + } + if (_is_monochrome || _is_trichrome) { + _force_32_bit = _include_32_bit_webview && _include_64_bit_webview && + !_is_64_bit_browser + variables += [ "force_32_bit=$_force_32_bit" ] + } + if (_is_test) { + includes += [ input ] + input = "//chrome/android/javatests/AndroidManifest.xml" + } + if (defined(invoker.jinja_input)) { + includes += [ input ] + input = invoker.jinja_input + } + if (defined(invoker.jinja_extra_variables)) { + variables += invoker.jinja_extra_variables + } + if (defined(invoker.jinja_extra_includes)) { + includes += invoker.jinja_extra_includes } } target(_target_type, target_name) { - forward_variables_from(invoker, "*", TESTONLY_AND_VISIBILITY) - forward_variables_from(invoker, TESTONLY_AND_VISIBILITY) + android_manifest = _android_manifest + android_manifest_dep = ":$_android_manifest_target_name" + manifest_package = _manifest_package - if (!defined(assert_no_deps)) { - assert_no_deps = [] + if (defined(invoker.min_sdk_version)) { + min_sdk_version = invoker.min_sdk_version + } else if (_is_trichrome) { + min_sdk_version = 29 } - - # https://crbug.com/1415351 - assert_no_deps += [ - "//third_party/androidx:androidx_window_extensions_core_core_java", - "//third_party/androidx:androidx_window_sidecar_sidecar_java", - "//third_party/androidx:androidx_window_window_java_java", - ] - - # TODO(crbug.com/1411557): Do not allows custom manifest dep. - if (defined(_android_manifest_target_name)) { - android_manifest = _android_manifest - android_manifest_dep = ":$_android_manifest_target_name" - manifest_package = _manifest_package + if (defined(invoker.version_name)) { + version_name = invoker.version_name + } else { + version_name = chrome_version_name } - - if (!defined(min_sdk_version)) { - if (_is_trichrome) { - min_sdk_version = 29 - } else if (_is_monochrome) { - min_sdk_version = 24 - } else { - min_sdk_version = default_min_sdk_version - } + if (defined(invoker.version_code)) { + # Override for the actual versionCode, but not for trichrome_version. + version_code = invoker.version_code + } else { + version_code = _version_code } - if (defined(expected_android_manifest)) { + if (defined(invoker.expected_android_manifest)) { expected_android_manifest_version_code_offset = chrome_version_code expected_android_manifest_library_version_offset = chrome_version_code } + if (_target_type == "android_apk") { + command_line_flags_file = "chrome-command-line" + } + + if (_is_bundle) { + is_base_module = true + + # Sets ISOLATED_SPLITS_ENABLED in BuildConfig.java. + isolated_splits_enabled = true + } + + product_config_java_packages = [ "org.chromium.chrome.browser" ] + + if (_is_monochrome) { + alternative_android_sdk_dep = webview_framework_dep + app_as_shared_lib = true + + # Resource allowlist used when generating R.java files and causes + # only the webview subset of resources to be marked as non-final. + # Strings in this target will also be kept in the base apk rather than placed in the language splits. + shared_resources_allowlist_target = + "//android_webview:system_webview_no_weblayer_apk" + + # Ensure the localized resources for all locales are used, even when + # a smaller set is specified through aapt_locale_allowlist. + shared_resources_allowlist_locales = platform_pak_locales + + product_config_java_packages += [ webview_product_config_java_package ] + + if (webview_includes_weblayer) { + product_config_java_packages += [ weblayer_product_config_java_package ] + } + } + + if (enable_silent_java_assert_reporting) { + custom_assertion_handler = crash_reporting_assertion_handler + } + + if (allow_jni_multiplexing) { + enable_jni_multiplexing = true + } + + # Include resource strings files only for supported locales. + aapt_locale_allowlist = platform_pak_locales + resource_exclusion_regex = common_resource_exclusion_regex resource_exclusion_exceptions = common_resource_exclusion_exceptions @@ -283,7 +314,7 @@ template("chrome_public_common_apk_or_module_tmpl") { "*ic_lock.*", # Bottom edge seems misaligned. ] - # Note most of these, with the exception of resource_exclusion_exceptions, + # Most of these, with the exception of resource_exclusion_exceptions, # are currently duplicated in system_webview_apk_tmpl.gni. # Used only by alert dialog on tiny screens. @@ -297,256 +328,269 @@ template("chrome_public_common_apk_or_module_tmpl") { # Instead of manually filtering, unused resource removal would be better: # https://crbug.com/636448 resource_exclusion_regex += "|${_material_package}/xml.*badge_" - _material_package = "*com_google_android_material*" - if (!_is_monochrome) { - product_config_java_packages = [ "org.chromium.chrome.browser" ] - } + if (!is_java_debug) { + # TODO(crbug.com/993340): Update test goldens with webp versions of images. + if (!_is_test) { + png_to_webp = true + } - # Android supports webp transparent resources properly since API level 18, - # so this can only be activated for modern ones (which target API >= 21). - if (!defined(png_to_webp)) { - png_to_webp = !is_java_debug - } + proguard_enabled = true + proguard_configs = [ "//chrome/android/proguard/main.flags" ] + if (_is_monochrome) { + proguard_configs += + [ "//android_webview/nonembedded/java/proguard.flags" ] + } + if (_is_test) { + proguard_configs += [ "//chrome/android/proguard/apk_for_test.flags" ] + } + if (defined(invoker.proguard_configs)) { + proguard_configs += invoker.proguard_configs + } - # We only optimize resources for bundles since APKs are not shipped. - # Resources only live in the base module atm as such we only need to set - # these on the base module - if (_is_bundle) { - # Removes metadata needed for Resources.getIdentifier("resource_name"). - strip_resource_names = !is_java_debug + # We only optimize resources for bundles since APKs are not shipped. + # Resources only live in the base module atm as such we only need to set + # these on the base module + if (_is_bundle) { + # Removes metadata needed for Resources.getIdentifier("resource_name"). + strip_resource_names = true - # Shortens resource file names in apk eg: res/drawable/button.xml -> res/a.xml - short_resource_paths = !is_java_debug + # Shortens resource file names in apk eg: res/drawable/button.xml -> res/a.xml + short_resource_paths = true - # Removes unused resources from the apk. Only enabled on official builds - # since it adds a slow step and serializes the build graph causing fewer - # expensive tasks (eg: proguarding, resource optimization) to be run in - # parallel by adding dependencies between them (adds around 10-20 - # seconds on my machine). - strip_unused_resources = is_official_build - } + # Removes unused resources from the apk. Only enabled on official builds + # since it adds a slow step and serializes the build graph causing fewer + # expensive tasks (eg: proguarding, resource optimization) to be run in + # parallel by adding dependencies between them (adds around 10-20 + # seconds on my machine). + strip_unused_resources = is_official_build - if (!defined(aapt_locale_allowlist)) { - # Include resource strings files only for supported locales. - aapt_locale_allowlist = platform_pak_locales - } - - if (!defined(use_chromium_linker)) { - # The Chromium Linker depends on ASharedMemory_create() introduced in O. - use_chromium_linker = chromium_linker_supported && _is_trichrome - } - - if (_is_trichrome) { - static_library_provider_use_secondary_abi = _is_secondary_abi_primary - - # http://crbug.com/1042107. - if (is_component_build) { - if (android_64bit_target_cpu && _is_64_bit_browser) { - main_component_library = "libmonochrome_64.cr.so" - } else { - main_component_library = "libmonochrome.cr.so" + # Resources config for blocklisting resource names from obfuscation + resources_config_paths = [ "//chrome/android/aapt2.config" ] + if (_is_monochrome || _is_trichrome) { + resources_config_paths += [ "//android_webview/aapt2.config" ] + } + if (defined(invoker.resources_config_paths)) { + resources_config_paths += invoker.resources_config_paths } } } - if (!_is_monochrome && !_is_trichrome) { + deps = [ + "//chrome/android:chrome_base_module_resources", + "//chrome/android:chrome_public_non_pak_assets", + ] + + # TODO(agrieve): Make unconditional when moving to trampoline. + if (_is_monochrome || _is_trichrome) { + deps += [ "//components/crash/android:handler_java" ] + } + if (_is_monochrome) { + deps += [ "//chrome/android:base_monochrome_module_java" ] + } else { + deps += [ "//chrome/android:base_module_java" ] + } + if (defined(invoker.deps)) { + deps += invoker.deps + } + + if (!_is_trichrome) { + # These go in trichrome library. deps += [ - "//components/crash/core/app:chrome_crashpad_handler_named_as_so", "//gin:v8_snapshot_assets", "//third_party/icu:icu_assets", ] - if (!defined(loadable_modules)) { - loadable_modules = [] - } - loadable_modules += [ "$root_out_dir/libchrome_crashpad_handler.so" ] - if (!defined(library_always_compress)) { - library_always_compress = [] - } - library_always_compress += [ - "libchrome_crashpad_handler.so", - "libchromium_android_linker.so", - ] - } - if (dfmify_dev_ui && !_is_bundle) { - # Dev UI is a feature in a DFM, and APKs don't use DFMs. To make the code - # available for APKs add a dependency on it. - deps += [ "//chrome/android/features/dev_ui:java" ] - } - if (enable_vr && !_is_bundle) { - # VR is a feature in a DFM, and APKs don't use DFMs, but we - # unconditionally include vr code in our native library. To make the code - # available for APKs, add a dependency on it. - deps += [ "//chrome/android/features/vr:java" ] - } - - if (!is_java_debug) { - proguard_enabled = true - if (!defined(proguard_configs)) { - proguard_configs = [] - } - proguard_configs += [ "//chrome/android/proguard/main.flags" ] - } - - if (use_chromium_linker) { - if (_is_secondary_abi_primary) { - _secondary_linker = "//base/android/linker:chromium_android_linker($android_secondary_abi_toolchain)" - deps += [ _secondary_linker ] - _secondary_out_dir = get_label_info(_secondary_linker, "root_out_dir") - secondary_abi_loadable_modules += - [ "$_secondary_out_dir/libchromium_android_linker$shlib_extension" ] - } else { - deps += [ "//base/android/linker:chromium_android_linker" ] - loadable_modules += - [ "$root_out_dir/libchromium_android_linker$shlib_extension" ] - } - } - if (build_with_internal_optimization_guide) { - if (_is_secondary_abi_primary) { - _secondary_optimization_guide = "//components/optimization_guide/internal:optimization_guide_internal($android_secondary_abi_toolchain)" - deps += [ _secondary_optimization_guide ] - _secondary_out_dir = - get_label_info(_secondary_optimization_guide, "root_out_dir") - secondary_abi_loadable_modules += - [ "$_secondary_out_dir/liboptimization_guide_internal.so" ] - } else { - deps += [ "//components/optimization_guide/internal:optimization_guide_internal" ] - loadable_modules += - [ "$root_out_dir/liboptimization_guide_internal.so" ] - } - } - if (_target_type == "android_apk") { - command_line_flags_file = "chrome-command-line" - } - if (!_is_trichrome) { + # TODO(agrieve): This is excluded from trichrome in preparation for + # "synchronized proguarding", which we've since abandoned. Enable for + # trichrome, or just remove the version check altogether. build_config_include_product_version_resource = true deps += [ "//chrome/android:product_version_resources" ] } - if (!_is_bundle || !(_is_monochrome || _is_trichrome)) { - deps += [ "//chrome/android:chrome_all_java" ] - } - if (_is_bundle) { # Required to support macro resources. # See https://crbug.com/1278419 deps += [ ":${target_name}__all_dfm_resources" ] + } else { + # For bundles, this exists in the "chrome" split. + deps += [ "//chrome/android:chrome_all_java" ] + + if (dfmify_dev_ui) { + # For bundles, Dev UI is a feature in a DFM. + deps += [ "//chrome/android/features/dev_ui:java" ] + } + if (enable_vr) { + # For bundles, VR is a feature in a DFM. + deps += [ "//chrome/android/features/vr:java" ] + } + } + + if (_is_monochrome) { + deps += [ + "//android_webview/glue:glue_java", + "//android_webview/nonembedded:monochrome_devui_launcher_icon_resources", + "//android_webview/nonembedded:nonembedded_java", + ] + + # For bundles, this lives in chrome split. + if (!_is_bundle) { + deps += [ "//chrome/android:monochrome_java" ] + } + + if (_include_primary_abi) { + deps += [ "//android_webview:monochrome_webview_primary_abi_assets" ] + } + if (_include_secondary_abi) { + deps += [ "//android_webview:monochrome_webview_secondary_abi_assets" ] + } + } + + if (_is_bundle && _is_monochrome) { + deps += [ "//chrome/android:monochrome_bundle_module_pak_assets" ] + } else if (_is_bundle && _is_trichrome) { + deps += [ "//chrome/android:trichrome_chrome_bundle_module_pak_assets" ] + } else if (_is_bundle) { + deps += [ "//chrome/android:chrome_bundle_module_pak_assets" ] + } else if (_is_monochrome) { + deps += [ "//chrome/android:monochrome_apk_pak_assets" ] + } else { + assert(!_is_trichrome) + deps += [ "//chrome/android:chrome_apk_pak_assets" ] + } + + if (defined(invoker.add_upstream_only_deps) && + invoker.add_upstream_only_deps) { + if (_is_monochrome) { + deps += upstream_only_webview_deps + } else if (!_is_trichrome) { + deps += [ + "//chrome/android:chrome_public_apk_base_module_resources", + "//chrome/android:chrome_public_base_module_java", + "//chrome/android:chrome_public_non_pak_assets", + "//components/browser_ui/styles/android:chrome_public_apk_resources", + ] + } + if (_is_bundle) { + deps += [ + # deps in delegate_public_impl_java are put into the Chrome module, but the language deps + # are needed by the base module. + "//components/language/android:ulp_delegate_public_java", + ] + } else { + deps += [ "//chrome/android:delegate_public_impl_java" ] + } + if (_is_test) { + deps += [ "//chrome/android:chrome_public_base_module_java_for_test" ] + } + } + + # https://crbug.com/1415351 + assert_no_deps = [ + "//third_party/androidx:androidx_window_extensions_core_core_java", + "//third_party/androidx:androidx_window_sidecar_sidecar_java", + "//third_party/androidx:androidx_window_window_java_java", + ] + if (defined(invoker.assert_no_deps)) { + assert_no_deps += invoker.assert_no_deps } # Unwind tables are included in the stack_unwinder DFM on Android, so they # aren't needed for bundle builds. However, we keep them for non-bundle # builds, such as test and development apks (e.g. chrome_public_apk), to # allow tests and developers to use them directly. - if (!_is_bundle && add_unwind_tables_in_chrome_32bit_apk) { - _needs_32bit_lib = - target_cpu == "arm" || ((_is_monochrome || _is_trichrome) && - target_cpu == "arm64" && !_is_64_bit_browser) - - if (_needs_32bit_lib) { - if (_is_monochrome || _is_trichrome) { - deps += [ "//chrome/android:libmonochrome_unwind_table_assets" ] - } else { - deps += [ "//chrome/android:libchrome_unwind_table_assets" ] - } + if (!defined(invoker.shared_libraries) && !_is_bundle && + add_unwind_tables_in_chrome_32bit_apk && + (target_cpu == "arm" || + (target_cpu == "arm64" && !_is_64_bit_browser))) { + if (_is_test) { + deps += [ "//chrome/android:libchromefortest_unwind_table_assets" ] + } else if (_is_monochrome || _is_trichrome) { + deps += [ "//chrome/android:libmonochrome_unwind_table_assets" ] + } else { + deps += [ "//chrome/android:libchrome_unwind_table_assets" ] } } + data_deps = [] + if (defined(invoker.data_deps)) { + data_deps += invoker.data_deps + } + # Prefer to add this data_dep on the final target instead of java targets # like chrome_all_java so that all other targets can build in parallel with # lint. if (!disable_android_lint) { - if (!defined(data_deps)) { - data_deps = [] - } data_deps += [ "//chrome/android:android_lint" ] } - if (enable_silent_java_assert_reporting) { - custom_assertion_handler = crash_reporting_assertion_handler - } - - if (allow_jni_multiplexing) { - enable_jni_multiplexing = true - } - - if (!defined(version_name)) { - version_name = chrome_version_name - } - version_code = _version_code - - # Override for the actual versionCode, but not for trichrome_version. - if (defined(invoker.version_code)) { - version_code = invoker.version_code - } - } -} - -# The equivalent of chrome_common_apk_or_module_tmpl for all builds of -# monochrome and trichrome chrome. -template("monochrome_public_common_apk_or_module_tmpl") { - chrome_public_common_apk_or_module_tmpl(target_name) { - _overrides = { - _is_bundle_module = defined(invoker.target_type) && - invoker.target_type == "android_app_bundle_module" - - if (_is_bundle_module) { - assert( - defined(invoker.is_base_module), - "_is_bundle_module is true but the invoker does not define is_base_module!") - } - - is_trichrome = defined(invoker.is_trichrome) && invoker.is_trichrome - is_monochrome = !is_trichrome - - shared_libraries = [] - if (defined(invoker.shared_libraries)) { - shared_libraries += invoker.shared_libraries - } + shared_libraries = [] + loadable_modules = [] + if (android_64bit_target_cpu) { secondary_abi_shared_libraries = [] - if (defined(invoker.secondary_abi_shared_libraries)) { - secondary_abi_shared_libraries += invoker.secondary_abi_shared_libraries - } - loadable_modules = [] - if (defined(invoker.loadable_modules)) { - loadable_modules = invoker.loadable_modules - } secondary_abi_loadable_modules = [] - if (defined(invoker.secondary_abi_loadable_modules)) { - secondary_abi_loadable_modules = invoker.secondary_abi_loadable_modules - } - native_lib_placeholders = [] - if (defined(invoker.native_lib_placeholders)) { - native_lib_placeholders = invoker.native_lib_placeholders - } - secondary_native_lib_placeholders = [] - if (defined(invoker.secondary_native_lib_placeholders)) { - secondary_native_lib_placeholders = - invoker.secondary_native_lib_placeholders - } + } + if (defined(invoker.loadable_modules)) { + loadable_modules = invoker.loadable_modules + } + if (defined(invoker.secondary_abi_loadable_modules)) { + secondary_abi_loadable_modules = invoker.secondary_abi_loadable_modules + } - deps = [ - "//chrome/android:chrome_public_non_pak_assets", - "//components/crash/android:handler_java", + if (_is_64_bit_browser && build_hwasan_splits) { + _hwasan_toolchain = "//build/toolchain/android:android_clang_arm64_hwasan" + } + + if (defined(invoker.shared_libraries)) { + shared_libraries += invoker.shared_libraries + } else if (_is_test) { + shared_libraries += [ "//chrome/android:libchromefortest" ] + } else if (_is_monochrome) { + if (android_64bit_target_cpu) { + # Build //android_webview:monochrome with the opposite bitness that + # Chrome runs in. + if (_is_64_bit_browser) { + shared_libraries += [ "//chrome/android:libmonochrome_64" ] + if (_include_32_bit_webview) { + secondary_abi_shared_libraries += [ "//android_webview:monochrome_64($android_secondary_abi_toolchain)" ] + } + if (build_hwasan_splits) { + shared_libraries += + [ "//chrome/android:libmonochrome_64($_hwasan_toolchain)" ] + } + } else { + if (_include_64_bit_webview) { + shared_libraries += [ "//android_webview:monochrome" ] + } + secondary_abi_shared_libraries += [ + "//chrome/android:libmonochrome($android_secondary_abi_toolchain)", + ] + } + } else { + shared_libraries += [ "//chrome/android:libmonochrome" ] + } + } else if (!_is_trichrome) { + shared_libraries += [ "//chrome/android:libchrome" ] + } + + if (enable_arcore) { + # The arcore manifest needs to be merged into the base module because + # the Play Store verifies the com.google.ar.core.min_apk_version + # meta-data tag is in the base manifest. + deps += [ + "//third_party/arcore-android-sdk-client:arcore_base_manifest_java", ] - if (defined(invoker.deps)) { - deps += invoker.deps - } - if (_is_bundle_module && invoker.is_base_module && enable_arcore && - is_monochrome) { - # AR DFM is disabled - set the loadable_modules / - # secondary_abi_loadable_modules to what would be brought in by the - # module. The AR Java will be brought in by the chrome_bundle target. - # This needs to happen for monochrome builds of base module if ARCore is - # enabled. For Trichrome, the native library is added to - # TrichromeLibrary.apk so it's not needed here. - _libarcore_dir = get_label_info( - "//third_party/arcore-android-sdk-client:com_google_ar_core_java($default_toolchain)", - "target_out_dir") + "/com_google_ar_core_java/jni" + # For Trichrome, the primary abi arcore library is added to + # TrichromeLibrary.apk, so it's not needed here. + if (!_is_trichrome) { + _arcore_target = "//third_party/arcore-android-sdk-client:com_google_ar_core_J__unpack_aar" + deps += [ _arcore_target ] + _libarcore_dir = get_label_info(_arcore_target, "target_out_dir") + + "/com_google_ar_core_java/jni" if (android_64bit_target_cpu) { - if (invoker.is_64_bit_browser) { + if (_is_64_bit_browser) { loadable_modules += [ "$_libarcore_dir/arm64-v8a/libarcore_sdk_c.so" ] } else { @@ -558,234 +602,158 @@ template("monochrome_public_common_apk_or_module_tmpl") { [ "$_libarcore_dir/armeabi-v7a/libarcore_sdk_c.so" ] } } + } + library_always_compress = [] + if (defined(invoker.library_always_compress)) { + library_always_compress = invoker.library_always_compress + } - if (_is_bundle_module) { - # Sets ISOLATED_SPLITS_ENABLED in BuildConfig.java. - isolated_splits_enabled = true - } - - if (_is_bundle_module && invoker.is_base_module) { - # The arcore manifest needs to be merged into the base module because - # the Play Store verifies the com.google.ar.core.min_apk_version - # meta-data tag is in the base manifest. - if (enable_arcore) { - deps += [ - "//third_party/arcore-android-sdk-client:com_google_ar_core_java", - "//third_party/arcore-android-sdk-client:com_google_ar_core_java__ignored_manifest", - ] - } - - if (is_monochrome) { - deps += [ "//chrome/android:base_monochrome_module_java" ] - } else { - deps += [ "//chrome/android:base_module_java" ] - } - } - - if (android_64bit_target_cpu && (is_monochrome || is_trichrome)) { - _include_64_bit_webview = !defined(invoker.include_64_bit_webview) || - invoker.include_64_bit_webview - _include_32_bit_webview = !defined(invoker.include_32_bit_webview) || - invoker.include_32_bit_webview - } - if (is_monochrome) { - product_config_java_packages = [ - "org.chromium.chrome.browser", - webview_product_config_java_package, - ] - - if (webview_includes_weblayer) { - product_config_java_packages += - [ weblayer_product_config_java_package ] - } - - # Flag whether additional deps and libs should be included for each ABI. - _include_primary_support = false - _include_secondary_support = false - - if (android_64bit_target_cpu) { - # Build //android_webview:monochrome with the opposite bitness that - # Chrome runs in. - if (invoker.is_64_bit_browser) { - _include_primary_support = true - shared_libraries += [ "//chrome/android:libmonochrome_64" ] - if (_include_32_bit_webview) { - secondary_abi_shared_libraries += [ "//android_webview:monochrome_64($android_secondary_abi_toolchain)" ] - _include_secondary_support = true - } - } else { - secondary_abi_shared_libraries += - [ "//chrome/android:monochrome_secondary_abi_lib" ] - _include_secondary_support = true - if (_include_64_bit_webview) { - shared_libraries += [ "//android_webview:monochrome" ] - _include_primary_support = true - } - } - } else { - shared_libraries += [ "//chrome/android:libmonochrome" ] - _include_primary_support = true - } - + # TODO(agrieve): Use Crashpad trampoline in chrome_public_apk. + if (!_is_monochrome && !_is_trichrome) { + deps += + [ "//components/crash/core/app:chrome_crashpad_handler_named_as_so" ] + loadable_modules += [ "$root_out_dir/libchrome_crashpad_handler.so" ] + library_always_compress += [ "libchrome_crashpad_handler.so" ] + } else if (!_is_trichrome) { + # Crashpad trampoline lives in TrichromeLibrary.apk. + # https://chromium.googlesource.com/chromium/src/+/main/docs/android_native_libraries.md#Crashpad-Packaging + if (_include_primary_abi) { deps += [ - "//android_webview/glue:glue_java", - "//android_webview/nonembedded:nonembedded_java", + "//third_party/crashpad/crashpad/handler:crashpad_handler_trampoline", ] - if (!_is_bundle_module) { - deps += [ "//chrome/android:monochrome_java" ] - } - - if (_include_primary_support) { - deps += [ - "//android_webview:monochrome_webview_primary_abi_assets", - "//third_party/crashpad/crashpad/handler:crashpad_handler_trampoline", - ] - loadable_modules += - [ "$root_out_dir/libcrashpad_handler_trampoline.so" ] - } - if (_include_secondary_support) { - _trampoline = - "//third_party/crashpad/crashpad/handler:" + - "crashpad_handler_trampoline($android_secondary_abi_toolchain)" - - deps += [ - "//android_webview:monochrome_webview_secondary_abi_assets", - _trampoline, - ] - - _secondary_out_dir = get_label_info(_trampoline, "root_out_dir") - secondary_abi_loadable_modules += - [ "$_secondary_out_dir/libcrashpad_handler_trampoline.so" ] - } - - if (defined(invoker.alternative_android_sdk_dep)) { - alternative_android_sdk_dep = invoker.alternative_android_sdk_dep - } else { - alternative_android_sdk_dep = webview_framework_dep - } - if (defined(invoker.app_as_shared_lib)) { - app_as_shared_lib = invoker.app_as_shared_lib - } else { - app_as_shared_lib = true - } - _pak_prefix = "monochrome" + loadable_modules += + [ "$root_out_dir/libcrashpad_handler_trampoline.so" ] } - if (is_trichrome) { - # Include placeholder libraries to make Chrome multiarch in the same way - # as Monochrome, even though Chrome only runs with one of the two - # bitnesses. This allows the "32-bit" and "64-bit" versions of Chrome to - # depend on their respective versions of the shared library APK even - # though they're functionally the same. - if (android_64bit_target_cpu) { - if (invoker.is_64_bit_browser) { - native_lib_placeholders += [ "libdummy.so" ] - if (_include_32_bit_webview) { - secondary_native_lib_placeholders += [ "libdummy.so" ] - } - } else { - secondary_native_lib_placeholders += [ "libdummy.so" ] - if (_include_64_bit_webview) { - native_lib_placeholders += [ "libdummy.so" ] - } - } - } else { - native_lib_placeholders += [ "libdummy.so" ] - } - - _pak_prefix = "trichrome_chrome" + if (_include_secondary_abi) { + deps += [ "//third_party/crashpad/crashpad/handler:crashpad_handler_trampoline($android_secondary_abi_toolchain)" ] + secondary_abi_loadable_modules += + [ "$_secondary_out_dir/libcrashpad_handler_trampoline.so" ] } + } - # The Chromium Linker depends on ASharedMemory_create() introduced in O. - use_chromium_linker = is_trichrome && chromium_linker_supported + # The Chromium Linker depends on ASharedMemory_create() introduced in O. + use_chromium_linker = chromium_linker_supported && _is_trichrome - if (build_hwasan_splits && android_64bit_target_cpu && - invoker.is_64_bit_browser) { - _hwasan_toolchain = - "//build/toolchain/android:android_clang_arm64_hwasan" - shared_libraries += - [ "//chrome/android:libmonochrome_64($_hwasan_toolchain)" ] - - if (use_chromium_linker) { - shared_libraries += [ - "//base/android/linker:chromium_android_linker($_hwasan_toolchain)", - ] - } + if (use_chromium_linker) { + if (android_64bit_target_cpu && !_is_64_bit_browser) { + deps += [ "//base/android/linker:chromium_android_linker($android_secondary_abi_toolchain)" ] + secondary_abi_loadable_modules += + [ "$_secondary_out_dir/libchromium_android_linker$shlib_extension" ] + } else { + deps += [ "//base/android/linker:chromium_android_linker" ] + loadable_modules += + [ "$root_out_dir/libchromium_android_linker$shlib_extension" ] } - - # We only optimize resources in bundles. - if (_is_bundle_module) { - # Resources config for blocklisting resource names from obfuscation - resources_config_paths = [ - "//android_webview/aapt2.config", - "//chrome/android/aapt2.config", + if (_is_64_bit_browser && build_hwasan_splits) { + deps += [ + "//base/android/linker:chromium_android_linker($_hwasan_toolchain)", ] - if (defined(invoker.resources_config_paths)) { - resources_config_paths += invoker.resources_config_paths - } + _hwasan_outdir = get_label_info(":($_hwasan_toolchain)", "root_out_dir") + loadable_modules += + [ "$_hwasan_outdir/libchromium_android_linker$shlib_extension" ] } + } - if (defined(invoker.never_incremental)) { - never_incremental = invoker.never_incremental - } else if (!defined(invoker.target_type) || - invoker.target_type == "android_apk") { - # Incremental install doesn't work for monochrome. See crbug.com/663492. - } - - # Strip xml namespaces for monochrome. This should only be done for apks - # targeting API > 21 which for chrome is only Monochrome. This is due to - # how android public and private resource ids are namespaced. - if (defined(invoker.no_xml_namespaces)) { - no_xml_namespaces = invoker.no_xml_namespaces + if (build_with_internal_optimization_guide) { + if (android_64bit_target_cpu && !_is_64_bit_browser) { + _secondary_optimization_guide = "//components/optimization_guide/internal:optimization_guide_internal($android_secondary_abi_toolchain)" + deps += [ _secondary_optimization_guide ] + secondary_abi_loadable_modules += + [ "$_secondary_out_dir/liboptimization_guide_internal.so" ] } else { - no_xml_namespaces = true + deps += [ "//components/optimization_guide/internal:optimization_guide_internal" ] + loadable_modules += + [ "$root_out_dir/liboptimization_guide_internal.so" ] + } + } + + if (_is_trichrome) { + if (android_64bit_target_cpu && !_is_64_bit_browser) { + static_library_provider_use_secondary_abi = true } - if (_is_bundle_module) { - _pak_prefix += "_bundle_module" - } else { - _pak_prefix += "_apk" + # Include placeholder libraries to make Chrome multiarch in the same way + # as Monochrome, even though Chrome only runs with one of the two + # bitnesses. This allows the "32-bit" and "64-bit" versions of Chrome to + # depend on their respective versions of the shared library APK even + # though they're functionally the same. + if (_include_primary_abi && loadable_modules == []) { + native_lib_placeholders = [ "libdummy.so" ] + } + if (_include_secondary_abi && secondary_abi_loadable_modules == []) { + secondary_native_lib_placeholders = [ "libdummy.so" ] } - deps += [ "//chrome/android:${_pak_prefix}_pak_assets" ] - if (!is_java_debug) { - proguard_configs = [] - if (defined(invoker.proguard_configs)) { - proguard_configs += invoker.proguard_configs - } - if (is_monochrome) { - proguard_configs += - [ "//android_webview/nonembedded/java/proguard.flags" ] + # http://crbug.com/1042107. + if (is_component_build) { + if (_is_64_bit_browser) { + main_component_library = "libmonochrome_64.cr.so" + } else { + main_component_library = "libmonochrome.cr.so" } } } - # The _overrides scope is used to ensure that: - # * Values set in invoker cannot accidentally clobber values set in - # _overrides. - # * Values set in _overrides cannot accidentaly clobber values set in - # invoker (since the forward_variables_from will fail). - _override_args = [ - "alternative_android_sdk_dep", - "app_as_shared_lib", - "deps", - "is_monochrome", - "is_trichrome", - "isolated_splits_enabled", - "loadable_modules", - "native_lib_placeholders", - "never_incremental", - "no_xml_namespaces", - "product_config_java_packages", - "proguard_configs", - "resources_config_paths", - "secondary_abi_loadable_modules", - "secondary_abi_shared_libraries", - "secondary_native_lib_placeholders", - "shared_libraries", - "use_chromium_linker", - "webview_product_config_java_package", - ] - forward_variables_from(invoker, "*", _override_args) - forward_variables_from(_overrides, _override_args) + if (_is_test) { + bundles_supported = true + deps += [ "//third_party/androidx:androidx_test_runner_java" ] + + # For EmbeddedTestServer. + additional_apks = [ "//net/android:net_test_support_apk" ] + if (defined(invoker.additional_apks)) { + additional_apks += invoker.additional_apks + } + } + + forward_variables_from(invoker, + "*", + TESTONLY_AND_VISIBILITY + [ + "additional_apks", + "assert_no_deps", + "data_deps", + "deps", + "loadable_modules", + "manifest_package", + "proguard_configs", + "resources_config_paths", + "secondary_abi_loadable_modules", + "secondary_abi_shared_libraries", + "shared_libraries", + "version_code", + "version_name", + ]) + } +} + +# For creating chrome targets without internal customizations. +template("chrome_public_apk_or_module_tmpl") { + chrome_common_apk_or_module_tmpl(target_name) { + add_upstream_only_deps = true + forward_variables_from(invoker, TESTONLY_AND_VISIBILITY) + forward_variables_from(invoker, "*", TESTONLY_AND_VISIBILITY) + } +} + +template("chrome_public_test_apk_tmpl") { + chrome_common_apk_or_module_tmpl(target_name) { + add_upstream_only_deps = true + target_type = "instrumentation_test_apk" + forward_variables_from(invoker, TESTONLY_AND_VISIBILITY) + forward_variables_from(invoker, "*", TESTONLY_AND_VISIBILITY) + } +} + +# TODO(https://crbug.com/1427610): Remove. +template("monochrome_public_common_apk_or_module_tmpl") { + chrome_common_apk_or_module_tmpl(target_name) { + forward_variables_from(invoker, "*") + if (!defined(is_monochrome)) { + is_trichrome = true + } + } +} +template("chrome_public_common_apk_or_module_tmpl") { + chrome_common_apk_or_module_tmpl(target_name) { + forward_variables_from(invoker, "*") } } diff --git a/src/chrome/android/chrome_test_apk_tmpl.gni b/src/chrome/android/chrome_test_apk_tmpl.gni deleted file mode 100644 index 9aacf1f6..00000000 --- a/src/chrome/android/chrome_test_apk_tmpl.gni +++ /dev/null @@ -1,121 +0,0 @@ -# Copyright 2023 The Chromium Authors -# Use of this source code is governed by a BSD-style license that can be -# found in the LICENSE file. - -import("//chrome/android/chrome_public_apk_tmpl.gni") - -# Dependencies that are common to any chrome_public derivative targets. -chrome_public_shared_deps = [ - "//chrome/android:chrome_public_apk_base_module_resources", - "//chrome/android:chrome_public_apk_resources", - "//chrome/android:chrome_public_base_module_java", - "//chrome/android:chrome_public_non_pak_assets", - "//gin:v8_snapshot_assets", - "//third_party/icu:icu_assets", -] - -chrome_public_test_manifest_package = "org.chromium.thorium.tests" - -template("chrome_test_apk_tmpl") { - chrome_public_common_apk_or_module_tmpl(target_name) { - testonly = true - target_type = "instrumentation_test_apk" - bundles_supported = true - jinja_input = "//chrome/android/javatests/AndroidManifest.xml" - manifest_package = chrome_public_test_manifest_package - - deps = chrome_public_shared_deps + invoker.deps + [ - "//chrome/android:chrome_apk_pak_assets", - "//chrome/android:chrome_public_base_module_java_for_test", - "//third_party/android_sdk:android_test_base_java", - "//third_party/android_sdk:android_test_mock_java", - "//third_party/android_sdk:android_test_runner_java", - "//third_party/android_support_test_runner:runner_java", - ] - if (add_unwind_tables_in_chrome_32bit_apk && current_cpu == "arm") { - deps += [ "//chrome/android:libchromefortest_unwind_table_assets" ] - } - if (enable_vr) { - # Contains VrFirstRunActivity, which is referenced by AndroidManifest.xml. - deps += [ "//chrome/android/features/vr:java" ] - } - - additional_apks = [ "//net/android:net_test_support_apk" ] - if (defined(invoker.additional_apks)) { - additional_apks += invoker.additional_apks - } - if (!is_java_debug) { - proguard_enabled = true - proguard_configs = [ "//chrome/android/proguard/apk_for_test.flags" ] - if (defined(invoker.proguard_configs)) { - proguard_configs += invoker.proguard_configs - } - } - - # TODO(crbug.com/993340): Update test goldens with webp versions of images. - png_to_webp = false - - forward_variables_from(invoker, TESTONLY_AND_VISIBILITY) - forward_variables_from(invoker, - "*", - TESTONLY_AND_VISIBILITY + [ - "additional_apks", - "deps", - "proguard_configs", - ]) - } -} - -template("monochrome_test_apk_tmpl") { - monochrome_public_common_apk_or_module_tmpl(target_name) { - forward_variables_from(invoker, - [ - "apk_name", - "data_deps", - "is_64_bit_browser", - "include_64_bit_webview", - "include_32_bit_webview", - "loadable_modules", - "min_sdk_version", - "proguard_configs", - "secondary_abi_loadable_modules", - "shared_libraries", - "target_sdk_version", - ]) - testonly = true - target_type = "instrumentation_test_apk" - - # TODO(agrieve): Add: manifest_package = chrome_public_test_manifest_package - - jinja_input = "//chrome/android/javatests/AndroidManifest_monochrome.xml" - jinja_extra_includes = [ "//chrome/android/javatests/AndroidManifest.xml" ] - jinja_extra_variables = - [ "test_manifest_package=$chrome_public_test_manifest_package" ] - - deps = chrome_public_shared_deps + invoker.deps + [ - "//android_webview:platform_service_bridge_upstream_implementation_java", - "//chrome/android:chrome_public_base_module_java_for_test", - "//chrome/android:monochrome_apk_pak_assets", - "//third_party/android_sdk:android_test_base_java", - "//third_party/android_sdk:android_test_mock_java", - "//third_party/android_sdk:android_test_runner_java", - "//third_party/android_support_test_runner:runner_java", - ] - - if (webview_includes_weblayer) { - deps += [ "//weblayer/browser/java:upstream_java" ] - } - - additional_apks = [ "//net/android:net_test_support_apk" ] - if (defined(invoker.additional_apks)) { - additional_apks += invoker.additional_apks - } - if (!is_java_debug) { - if (!defined(proguard_configs)) { - proguard_configs = [] - } - proguard_enabled = true - proguard_configs += [ "//chrome/android/proguard/apk_for_test.flags" ] - } - } -}