Merge "Remove non-system modules from generic_system_image" into main
diff --git a/core/Makefile b/core/Makefile
index 90668a1..81ae6f7 100644
--- a/core/Makefile
+++ b/core/Makefile
@@ -4010,6 +4010,21 @@
     $(filter $(TARGET_OUT_PRODUCT)/%,\
       $(ALL_DEFAULT_INSTALLED_MODULES))
 
+# Install product/etc/linker.config.pb with PRODUCT_PRODUCT_LINKER_CONFIG_FRAGMENTS
+product_linker_config_file := $(TARGET_OUT_PRODUCT)/etc/linker.config.pb
+$(product_linker_config_file): private_linker_config_fragments := $(PRODUCT_PRODUCT_LINKER_CONFIG_FRAGMENTS)
+$(product_linker_config_file): $(INTERNAL_PRODUCTIMAGE_FILES) | $(HOST_OUT_EXECUTABLES)/conv_linker_config
+	@echo Creating linker config: $@
+	@mkdir -p $(dir $@)
+	@rm -f $@
+	$(HOST_OUT_EXECUTABLES)/conv_linker_config proto \
+		--source $(call normalize-path-list,$(private_linker_config_fragments)) \
+		--output $@
+$(call define declare-1p-target,$(product_linker_config_file),)
+INTERNAL_PRODUCTIMAGE_FILES += $(product_linker_config_file)
+ALL_DEFAULT_INSTALLED_MODULES += $(product_linker_config_file)
+
+
 INSTALLED_FILES_FILE_PRODUCT := $(PRODUCT_OUT)/installed-files-product.txt
 INSTALLED_FILES_JSON_PRODUCT := $(INSTALLED_FILES_FILE_PRODUCT:.txt=.json)
 $(INSTALLED_FILES_FILE_PRODUCT): .KATI_IMPLICIT_OUTPUTS := $(INSTALLED_FILES_JSON_PRODUCT)
@@ -7985,9 +8000,14 @@
 # Desktop pack update image hook.
 ifneq (,$(strip $(PACK_DESKTOP_UPDATE_IMAGE)))
 PACK_UPDATE_IMAGE_TARGET := $(PRODUCT_OUT)/android-desktop_update_image.bin
+PACK_UPDATE_IMAGE_ARGS := --noarchive --update
+
+ifneq (,$(strip $(PACK_UPDATE_IMAGE_EXPERIMENTAL)))
+PACK_UPDATE_IMAGE_ARGS += --experimental
+endif # PACK_UPDATE_IMAGE_EXPERIMENTAL
 
 $(PACK_UPDATE_IMAGE_TARGET): $(IMAGES) $(PACK_IMAGE_SCRIPT)
-	$(PACK_IMAGE_SCRIPT) --out_dir $(PRODUCT_OUT) --noarchive --update
+	$(PACK_IMAGE_SCRIPT) --out_dir $(PRODUCT_OUT) $(PACK_UPDATE_IMAGE_ARGS)
 
 PACKED_UPDATE_IMAGE_ARCHIVE_TARGET := $(PACK_UPDATE_IMAGE_TARGET).gz
 
diff --git a/core/android_soong_config_vars.mk b/core/android_soong_config_vars.mk
index f66bdd9..19d9c22 100644
--- a/core/android_soong_config_vars.mk
+++ b/core/android_soong_config_vars.mk
@@ -30,9 +30,12 @@
 $(call soong_config_set_bool,ANDROID,BOARD_USES_RECOVERY_AS_BOOT,$(BOARD_USES_RECOVERY_AS_BOOT))
 $(call soong_config_set_bool,ANDROID,BOARD_MOVE_GSI_AVB_KEYS_TO_VENDOR_BOOT,$(BOARD_MOVE_GSI_AVB_KEYS_TO_VENDOR_BOOT))
 $(call add_soong_config_var,ANDROID,CHECK_DEV_TYPE_VIOLATIONS)
+$(call soong_config_set_bool,ANDROID,HAS_BOARD_SYSTEM_EXT_PREBUILT_DIR,$(if $(BOARD_SYSTEM_EXT_PREBUILT_DIR),true,false))
+$(call soong_config_set_bool,ANDROID,HAS_BOARD_PRODUCT_PREBUILT_DIR,$(if $(BOARD_PRODUCT_PREBUILT_DIR),true,false))
 $(call add_soong_config_var,ANDROID,PLATFORM_SEPOLICY_VERSION)
 $(call add_soong_config_var,ANDROID,PLATFORM_SEPOLICY_COMPAT_VERSIONS)
 $(call add_soong_config_var,ANDROID,PRODUCT_INSTALL_DEBUG_POLICY_TO_SYSTEM_EXT)
+$(call soong_config_set_bool,ANDROID,RELEASE_BOARD_API_LEVEL_FROZEN,$(RELEASE_BOARD_API_LEVEL_FROZEN))
 $(call add_soong_config_var,ANDROID,TARGET_DYNAMIC_64_32_DRMSERVER)
 $(call add_soong_config_var,ANDROID,TARGET_ENABLE_MEDIADRM_64)
 $(call add_soong_config_var,ANDROID,TARGET_DYNAMIC_64_32_MEDIASERVER)
@@ -204,3 +207,7 @@
 
 # Export target_board_platform to soong for hardware/google/graphics/common/libmemtrack:memtrack.$(TARGET_BOARD_PLATFORM)
 $(call soong_config_set,ANDROID,target_board_platform,$(TARGET_BOARD_PLATFORM))
+
+# Export board_uses_scaler_m2m1shot and board_uses_align_restriction to soong for hardware/google/graphics/common/libscaler:libexynosscaler
+$(call soong_config_set_bool,google_graphics,board_uses_scaler_m2m1shot,$(if $(filter true,$(BOARD_USES_SCALER_M2M1SHOT)),true,false))
+$(call soong_config_set_bool,google_graphics,board_uses_align_restriction,$(if $(filter true,$(BOARD_USES_ALIGN_RESTRICTION)),true,false))
diff --git a/core/main.mk b/core/main.mk
index 5bbe1b1..c59de8e 100644
--- a/core/main.mk
+++ b/core/main.mk
@@ -981,7 +981,8 @@
 # Returns modules included automatically as a result of certain BoardConfig
 # variables being set.
 define auto-included-modules
-  llndk_in_system \
+  $(filter-out $(LLNDK_MOVED_TO_APEX_LIBRARIES),$(LLNDK_LIBRARIES)) \
+  llndk.libraries.txt \
   $(if $(DEVICE_MANIFEST_FILE),vendor_manifest.xml) \
   $(if $(DEVICE_MANIFEST_SKUS),$(foreach sku, $(DEVICE_MANIFEST_SKUS),vendor_manifest_$(sku).xml)) \
   $(if $(ODM_MANIFEST_FILES),odm_manifest.xml) \
diff --git a/core/product.mk b/core/product.mk
index 93a656d..8fc40f8 100644
--- a/core/product.mk
+++ b/core/product.mk
@@ -422,8 +422,9 @@
 # If true, the cgroup v2 hierarchy will be split into apps/system subtrees
 _product_single_value_vars += PRODUCT_CGROUP_V2_SYS_APP_ISOLATION_ENABLED
 
-# List of .json files to be merged/compiled into vendor/etc/linker.config.pb
+# List of .json files to be merged/compiled into vendor/etc/linker.config.pb and product/etc/linker.config.pb
 _product_list_vars += PRODUCT_VENDOR_LINKER_CONFIG_FRAGMENTS
+_product_list_vars += PRODUCT_PRODUCT_LINKER_CONFIG_FRAGMENTS
 
 # Whether to use userfaultfd GC.
 # Possible values are:
diff --git a/core/project_definitions.mk b/core/project_definitions.mk
index 5728b67..184b03e 100644
--- a/core/project_definitions.mk
+++ b/core/project_definitions.mk
@@ -22,3 +22,6 @@
 # Include definitions for prebuilt SDK, if present.
 #
 -include prebuilts/sdk/current/definitions.mk
+
+# SDV-specific config.
+-include system/software_defined_vehicle/platform/config.mk
diff --git a/core/robolectric_test_config_template.xml b/core/robolectric_test_config_template.xml
index b1d0c2f..257c820 100644
--- a/core/robolectric_test_config_template.xml
+++ b/core/robolectric_test_config_template.xml
@@ -33,5 +33,15 @@
         <option name="java-flags" value="--add-opens=java.base/jdk.internal.util.random=ALL-UNNAMED"/>
         <!-- b/251387255 -->
         <option name="java-flags" value="--add-opens=java.base/java.io=ALL-UNNAMED"/>
+        <option name="java-flags" value="--add-opens=java.base/java.net=ALL-UNNAMED"/>
+        <option name="java-flags" value="--add-opens=java.base/java.nio=ALL-UNNAMED"/> <!-- required for ShadowVMRuntime -->
+        <option name="java-flags" value="--add-opens=java.base/java.security=ALL-UNNAMED"/>
+        <option name="java-flags" value="--add-opens=java.base/java.text=ALL-UNNAMED"/>
+        <option name="java-flags" value="--add-opens=java.base/java.util=ALL-UNNAMED"/>
+        <option name="java-flags" value="--add-opens=java.base/jdk.internal.access=ALL-UNNAMED"/>
+        <option name="java-flags" value="--add-opens=java.desktop/java.awt.font=ALL-UNNAMED"/>
+        <option name="java-flags" value="--add-opens=jdk.compiler/com.sun.tools.javac.api=ALL-UNNAMED"/>
+        <option name="java-flags" value="--add-opens=jdk.compiler/com.sun.tools.javac.main=ALL-UNNAMED"/>
+        <option name="java-flags" value="--add-opens=jdk.compiler/com.sun.tools.javac.util=ALL-UNNAMED"/>
     </test>
 </configuration>
diff --git a/core/soong_config.mk b/core/soong_config.mk
index 0421e19..8c57ce6 100644
--- a/core/soong_config.mk
+++ b/core/soong_config.mk
@@ -316,6 +316,8 @@
 
 $(call add_json_str,  ProductManufacturer, $(PRODUCT_MANUFACTURER))
 $(call add_json_str,  ProductBrand,        $(PRODUCT_BRAND))
+$(call add_json_str,  ProductDevice,       $(PRODUCT_DEVICE))
+$(call add_json_str,  ProductModel,        $(PRODUCT_MODEL))
 
 $(call add_json_str, ReleaseVersion,    $(_RELEASE_VERSION))
 $(call add_json_list, ReleaseAconfigValueSets,    $(RELEASE_ACONFIG_VALUE_SETS))
@@ -348,6 +350,8 @@
 $(call add_json_list, ProductPropFiles, $(TARGET_PRODUCT_PROP))
 $(call add_json_list, OdmPropFiles, $(TARGET_ODM_PROP))
 
+$(call add_json_str, ExtraAllowedDepsTxt, $(EXTRA_ALLOWED_DEPS_TXT))
+
 # Do not set ArtTargetIncludeDebugBuild into any value if PRODUCT_ART_TARGET_INCLUDE_DEBUG_BUILD is not set,
 # to have the same behavior from runtime_libart.mk.
 ifneq ($(PRODUCT_ART_TARGET_INCLUDE_DEBUG_BUILD),)
@@ -364,6 +368,8 @@
 $(call add_json_list, BoardAvbSystemAddHashtreeFooterArgs, $(BOARD_AVB_SYSTEM_ADD_HASHTREE_FOOTER_ARGS))
 $(call add_json_bool, BoardAvbEnable, $(filter true,$(BOARD_AVB_ENABLE)))
 
+$(call add_json_str, AdbKeys, $(PRODUCT_ADB_KEYS))
+
 $(call add_json_map, PartitionVarsForSoongMigrationOnlyDoNotUse)
   $(call add_json_str,  ProductDirectory,    $(dir $(INTERNAL_PRODUCT)))
 
diff --git a/core/tasks/prebuilt_tradefed.mk b/core/tasks/prebuilt_tradefed.mk
new file mode 100644
index 0000000..96c57d5
--- /dev/null
+++ b/core/tasks/prebuilt_tradefed.mk
@@ -0,0 +1,22 @@
+# Copyright (C) 2020 The Android Open Source Project
+#
+# Licensed under the Apache License, Version 2.0 (the "License");
+# you may not use this file except in compliance with the License.
+# You may obtain a copy of the License at
+#
+#      http://www.apache.org/licenses/LICENSE-2.0
+#
+# Unless required by applicable law or agreed to in writing, software
+# distributed under the License is distributed on an "AS IS" BASIS,
+# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+# See the License for the specific language governing permissions and
+# limitations under the License.
+
+ifeq (,$(wildcard tools/tradefederation/core))
+.PHONY: tradefed-core
+tradefed-core: tradefed atest_tradefed.sh
+.PHONY: tradefed-all
+tradefed-all: tradefed atest_tradefed.sh
+
+$(call dist-for-goals, tradefed, $(HOST_OUT)/etc/tradefed.zip)
+endif
diff --git a/core/tasks/tools/update_bootloader_radio_image.mk b/core/tasks/tools/update_bootloader_radio_image.mk
index 0ebf247..adb86ea 100644
--- a/core/tasks/tools/update_bootloader_radio_image.mk
+++ b/core/tasks/tools/update_bootloader_radio_image.mk
@@ -15,3 +15,12 @@
 ifeq ($(USES_DEVICE_GOOGLE_ZUMA),true)
     -include vendor/google_devices/zuma/prebuilts/misc_bins/update_bootloader_radio_image.mk
 endif
+ifeq ($(USES_DEVICE_GOOGLE_ZUMAPRO),true)
+    -include vendor/google_devices/zumapro/prebuilts/misc_bins/update_bootloader_radio_image.mk
+endif
+ifeq ($(USES_DEVICE_GOOGLE_LAGUNA),true)
+    -include vendor/google_devices/laguna/prebuilts/misc_bins/update_bootloader_radio_image.mk
+endif
+ifeq ($(USES_DEVICE_GOOGLE_MALIBU),true)
+    -include vendor/google_devices/malibu/prebuilts/misc_bins/update_bootloader_radio_image.mk
+endif
diff --git a/target/product/base_system.mk b/target/product/base_system.mk
index 563511f..74ed82d 100644
--- a/target/product/base_system.mk
+++ b/target/product/base_system.mk
@@ -504,6 +504,10 @@
     unwind_reg_info \
     unwind_symbols \
 
+# For Remotely Provisioned Certificate Processor
+PRODUCT_SYSTEM_PROPERTIES += \
+    remote_provisioning.use_cert_processor=false
+
 # The set of packages whose code can be loaded by the system server.
 PRODUCT_SYSTEM_SERVER_APPS += \
     SettingsProvider \
diff --git a/target/product/base_vendor.mk b/target/product/base_vendor.mk
index a80e0b3..3f85941 100644
--- a/target/product/base_vendor.mk
+++ b/target/product/base_vendor.mk
@@ -17,7 +17,6 @@
 # Base modules and settings for recovery.
 PRODUCT_PACKAGES += \
     adbd.recovery \
-    android.hardware.health@2.0-impl-default.recovery \
     build_flag_vendor \
     cgroups.recovery.json \
     charger.recovery \
diff --git a/target/product/generic/Android.bp b/target/product/generic/Android.bp
index 929e4c5..8923ca1 100644
--- a/target/product/generic/Android.bp
+++ b/target/product/generic/Android.bp
@@ -72,6 +72,10 @@
         target: "/storage/self/primary",
         name: "sdcard",
     },
+    {
+        target: "/product/etc/security/adb_keys",
+        name: "adb_keys",
+    },
 ]
 
 filegroup {
@@ -574,6 +578,7 @@
                 "ContactsProvider", // base_system
                 "CredentialManager", // handheld_system
                 "DeviceAsWebcam", // handheld_system
+                "DeviceDiagnostics", // handheld_system - internal
                 "DocumentsUI", // handheld_system
                 "DownloadProvider", // base_system
                 "DownloadProviderUi", // handheld_system
diff --git a/target/product/gsi/Android.mk b/target/product/gsi/Android.mk
index 7291059..cdd5008 100644
--- a/target/product/gsi/Android.mk
+++ b/target/product/gsi/Android.mk
@@ -121,20 +121,3 @@
 LOCAL_NOTICE_FILE := build/soong/licenses/LICENSE
 LOCAL_REQUIRED_MODULES := $(foreach vndk_ver,$(PRODUCT_EXTRA_VNDK_VERSIONS),com.android.vndk.v$(vndk_ver))
 include $(BUILD_PHONY_PACKAGE)
-
-#####################################################################
-# Define Phony module to install LLNDK modules which are installed in
-# the system image
-include $(CLEAR_VARS)
-LOCAL_MODULE := llndk_in_system
-LOCAL_LICENSE_KINDS := SPDX-license-identifier-Apache-2.0
-LOCAL_LICENSE_CONDITIONS := notice
-LOCAL_NOTICE_FILE := build/soong/licenses/LICENSE
-
-# Filter LLNDK libs moved to APEX to avoid pulling them into /system/LIB
-LOCAL_REQUIRED_MODULES := \
-    $(filter-out $(LLNDK_MOVED_TO_APEX_LIBRARIES),$(LLNDK_LIBRARIES)) \
-    llndk.libraries.txt
-
-
-include $(BUILD_PHONY_PACKAGE)
diff --git a/target/product/security/Android.bp b/target/product/security/Android.bp
index 0d7b35e..69d19a3 100644
--- a/target/product/security/Android.bp
+++ b/target/product/security/Android.bp
@@ -37,3 +37,7 @@
     relative_install_path: "security",
     filename: "otacerts.zip",
 }
+
+adb_keys {
+    name: "adb_keys",
+}
diff --git a/target/product/security/Android.mk b/target/product/security/Android.mk
deleted file mode 100644
index 138e5bb..0000000
--- a/target/product/security/Android.mk
+++ /dev/null
@@ -1,17 +0,0 @@
-LOCAL_PATH:= $(call my-dir)
-
-#######################################
-# adb key, if configured via PRODUCT_ADB_KEYS
-ifdef PRODUCT_ADB_KEYS
-  ifneq ($(filter eng userdebug,$(TARGET_BUILD_VARIANT)),)
-    include $(CLEAR_VARS)
-    LOCAL_MODULE := adb_keys
-    LOCAL_LICENSE_KINDS := SPDX-license-identifier-Apache-2.0
-    LOCAL_LICENSE_CONDITIONS := notice
-    LOCAL_NOTICE_FILE := build/soong/licenses/LICENSE
-    LOCAL_MODULE_CLASS := ETC
-    LOCAL_MODULE_PATH := $(TARGET_OUT_PRODUCT_ETC)/security
-    LOCAL_PREBUILT_MODULE_FILE := $(PRODUCT_ADB_KEYS)
-    include $(BUILD_PREBUILT)
-  endif
-endif
diff --git a/tools/aconfig/aconfig/src/codegen/rust.rs b/tools/aconfig/aconfig/src/codegen/rust.rs
index 7bc34d6..d318b96 100644
--- a/tools/aconfig/aconfig/src/codegen/rust.rs
+++ b/tools/aconfig/aconfig/src/codegen/rust.rs
@@ -295,7 +295,10 @@
                                 get_boolean_flag_value(&flag_val_map, offset + 1)
                                     .map_err(|err| format!("failed to get flag: {err}"))
                             },
-                            None => Err("no context found for package 'com.android.aconfig.test'".to_string())
+                            None => {
+                                log!(Level::Error, "no context found for package com.android.aconfig.test");
+                                Ok(false)
+                            }
                         }
                     })
                 });
@@ -339,7 +342,10 @@
                                 get_boolean_flag_value(&flag_val_map, offset + 2)
                                     .map_err(|err| format!("failed to get flag: {err}"))
                             },
-                            None => Err("no context found for package 'com.android.aconfig.test'".to_string())
+                            None => {
+                                log!(Level::Error, "no context found for package com.android.aconfig.test");
+                                Ok(false)
+                            }
                         }
                     })
                 });
@@ -383,7 +389,10 @@
                                 get_boolean_flag_value(&flag_val_map, offset + 3)
                                     .map_err(|err| format!("failed to get flag: {err}"))
                             },
-                            None => Err("no context found for package 'com.android.aconfig.test'".to_string())
+                            None => {
+                                log!(Level::Error, "no context found for package com.android.aconfig.test");
+                                Ok(false)
+                            }
                         }
                     })
                 });
@@ -428,7 +437,10 @@
                                 get_boolean_flag_value(&flag_val_map, offset + 8)
                                     .map_err(|err| format!("failed to get flag: {err}"))
                             },
-                            None => Err("no context found for package 'com.android.aconfig.test'".to_string())
+                            None => {
+                                log!(Level::Error, "no context found for package com.android.aconfig.test");
+                                Ok(true)
+                            }
                         }
                     })
                 });
diff --git a/tools/aconfig/aconfig/templates/cpp_source_file.template b/tools/aconfig/aconfig/templates/cpp_source_file.template
index 852b905..eaaf86f 100644
--- a/tools/aconfig/aconfig/templates/cpp_source_file.template
+++ b/tools/aconfig/aconfig/templates/cpp_source_file.template
@@ -76,7 +76,8 @@
             : boolean_start_index_()
             {{ -endif }}
             , flag_value_file_(nullptr)
-            , read_from_new_storage_(false) \{
+            , read_from_new_storage_(false)
+            , package_exists_in_storage_(true) \{
 
             if (access("/metadata/aconfig/boot/enable_only_new_storage", F_OK) == 0) \{
                read_from_new_storage_ = true;
@@ -99,6 +100,11 @@
                 ALOGE("error: failed to get package read context: %s", context.error().c_str());
             }
 
+            if (!(context->package_exists)) \{
+               package_exists_in_storage_ = false;
+               return;
+            }
+
             // cache package boolean flag start index
             boolean_start_index_ = context->boolean_start_index;
 
@@ -126,6 +132,10 @@
             if (cache_[{item.readwrite_idx}] == -1) \{
             {{ if allow_instrumentation- }}
                 if (read_from_new_storage_) \{
+                    if (!package_exists_in_storage_) \{
+                       return {item.default_value};
+                    }
+
                     auto value = aconfig_storage::get_boolean_flag_value(
                         *flag_value_file_,
                         boolean_start_index_ + {item.flag_offset});
@@ -168,6 +178,8 @@
         std::unique_ptr<aconfig_storage::MappedStorageFile> flag_value_file_;
 
         bool read_from_new_storage_;
+
+        bool package_exists_in_storage_;
     {{ -endif }}
     {{ -endif }}
 
diff --git a/tools/aconfig/aconfig/templates/rust.template b/tools/aconfig/aconfig/templates/rust.template
index c2f162f..6456360 100644
--- a/tools/aconfig/aconfig/templates/rust.template
+++ b/tools/aconfig/aconfig/templates/rust.template
@@ -51,7 +51,10 @@
                                 get_boolean_flag_value(&flag_val_map, offset + {flag.flag_offset})
                                     .map_err(|err| format!("failed to get flag: \{err}"))
                             },
-                            None => Err("no context found for package '{package}'".to_string())
+                            None => \{
+                                 log!(Level::Error, "no context found for package {package}");
+                                 Ok({flag.default_value})
+                            }
                         }
                     })
                 });
diff --git a/tools/aconfig/aconfig_storage_file/tests/Android.bp b/tools/aconfig/aconfig_storage_file/tests/Android.bp
index 12e4aca..13d3214 100644
--- a/tools/aconfig/aconfig_storage_file/tests/Android.bp
+++ b/tools/aconfig/aconfig_storage_file/tests/Android.bp
@@ -10,10 +10,10 @@
         "libbase",
     ],
     data: [
-        "package.map",
-        "flag.map",
-        "flag.val",
-        "flag.info",
+        "data/v1/package.map",
+        "data/v1/flag.map",
+        "data/v1/flag.val",
+        "data/v1/flag.info",
     ],
     test_suites: [
         "device-tests",
@@ -35,10 +35,10 @@
     test_config: "AndroidStorageJaveTest.xml",
     sdk_version: "test_current",
     data: [
-        "package.map",
-        "flag.map",
-        "flag.val",
-        "flag.info",
+        "data/v1/package.map",
+        "data/v1/flag.map",
+        "data/v1/flag.val",
+        "data/v1/flag.info",
     ],
     test_suites: [
         "general-tests",
diff --git a/tools/aconfig/aconfig_storage_file/tests/flag.info b/tools/aconfig/aconfig_storage_file/tests/data/v1/flag.info
similarity index 100%
rename from tools/aconfig/aconfig_storage_file/tests/flag.info
rename to tools/aconfig/aconfig_storage_file/tests/data/v1/flag.info
Binary files differ
diff --git a/tools/aconfig/aconfig_storage_file/tests/flag.map b/tools/aconfig/aconfig_storage_file/tests/data/v1/flag.map
similarity index 100%
rename from tools/aconfig/aconfig_storage_file/tests/flag.map
rename to tools/aconfig/aconfig_storage_file/tests/data/v1/flag.map
Binary files differ
diff --git a/tools/aconfig/aconfig_storage_file/tests/flag.val b/tools/aconfig/aconfig_storage_file/tests/data/v1/flag.val
similarity index 100%
rename from tools/aconfig/aconfig_storage_file/tests/flag.val
rename to tools/aconfig/aconfig_storage_file/tests/data/v1/flag.val
Binary files differ
diff --git a/tools/aconfig/aconfig_storage_file/tests/package.map b/tools/aconfig/aconfig_storage_file/tests/data/v1/package.map
similarity index 100%
rename from tools/aconfig/aconfig_storage_file/tests/package.map
rename to tools/aconfig/aconfig_storage_file/tests/data/v1/package.map
Binary files differ
diff --git a/tools/aconfig/aconfig_storage_file/tests/storage_file_test.cpp b/tools/aconfig/aconfig_storage_file/tests/storage_file_test.cpp
index ebd1dd8..3626f72 100644
--- a/tools/aconfig/aconfig_storage_file/tests/storage_file_test.cpp
+++ b/tools/aconfig/aconfig_storage_file/tests/storage_file_test.cpp
@@ -53,7 +53,8 @@
 }
 
 TEST(AconfigStorageFileTest, test_list_flag) {
-  auto const test_dir = GetExecutableDirectory();
+  auto const test_base_dir = GetExecutableDirectory();
+  auto const test_dir = test_base_dir + "/data/v1";
   auto const package_map = test_dir + "/package.map";
   auto const flag_map = test_dir + "/flag.map";
   auto const flag_val = test_dir + "/flag.val";
@@ -82,7 +83,8 @@
 }
 
 TEST(AconfigStorageFileTest, test_list_flag_with_info) {
-  auto const test_dir = GetExecutableDirectory();
+  auto const base_test_dir = GetExecutableDirectory();
+  auto const test_dir = base_test_dir + "/data/v1";
   auto const package_map = test_dir + "/package.map";
   auto const flag_map = test_dir + "/flag.map";
   auto const flag_val = test_dir + "/flag.val";
diff --git a/tools/aconfig/aconfig_storage_read_api/Android.bp b/tools/aconfig/aconfig_storage_read_api/Android.bp
index 6ae34f3..80b8ece 100644
--- a/tools/aconfig/aconfig_storage_read_api/Android.bp
+++ b/tools/aconfig/aconfig_storage_read_api/Android.bp
@@ -36,10 +36,10 @@
         "librand",
     ],
     data: [
-        "tests/package.map",
-        "tests/flag.map",
-        "tests/flag.val",
-        "tests/flag.info",
+        "tests/data/v1/package.map",
+        "tests/data/v1/flag.map",
+        "tests/data/v1/flag.val",
+        "tests/data/v1/flag.info",
     ],
 }
 
diff --git a/tools/aconfig/aconfig_storage_read_api/src/lib.rs b/tools/aconfig/aconfig_storage_read_api/src/lib.rs
index 988ce63..884f148 100644
--- a/tools/aconfig/aconfig_storage_read_api/src/lib.rs
+++ b/tools/aconfig/aconfig_storage_read_api/src/lib.rs
@@ -412,10 +412,10 @@
         let flag_map = storage_dir.clone() + "/maps/mockup.flag.map";
         let flag_val = storage_dir.clone() + "/boot/mockup.val";
         let flag_info = storage_dir.clone() + "/boot/mockup.info";
-        fs::copy("./tests/package.map", &package_map).unwrap();
-        fs::copy("./tests/flag.map", &flag_map).unwrap();
-        fs::copy("./tests/flag.val", &flag_val).unwrap();
-        fs::copy("./tests/flag.info", &flag_info).unwrap();
+        fs::copy("./tests/data/v1/package.map", &package_map).unwrap();
+        fs::copy("./tests/data/v1/flag.map", &flag_map).unwrap();
+        fs::copy("./tests/data/v1/flag.val", &flag_val).unwrap();
+        fs::copy("./tests/data/v1/flag.info", &flag_info).unwrap();
 
         return storage_dir;
     }
@@ -507,9 +507,9 @@
     #[test]
     // this test point locks down flag storage file version number query api
     fn test_storage_version_query() {
-        assert_eq!(get_storage_file_version("./tests/package.map").unwrap(), 1);
-        assert_eq!(get_storage_file_version("./tests/flag.map").unwrap(), 1);
-        assert_eq!(get_storage_file_version("./tests/flag.val").unwrap(), 1);
-        assert_eq!(get_storage_file_version("./tests/flag.info").unwrap(), 1);
+        assert_eq!(get_storage_file_version("./tests/data/v1/package.map").unwrap(), 1);
+        assert_eq!(get_storage_file_version("./tests/data/v1/flag.map").unwrap(), 1);
+        assert_eq!(get_storage_file_version("./tests/data/v1/flag.val").unwrap(), 1);
+        assert_eq!(get_storage_file_version("./tests/data/v1/flag.info").unwrap(), 1);
     }
 }
diff --git a/tools/aconfig/aconfig_storage_read_api/src/mapped_file.rs b/tools/aconfig/aconfig_storage_read_api/src/mapped_file.rs
index 5a16645..32dbed8 100644
--- a/tools/aconfig/aconfig_storage_read_api/src/mapped_file.rs
+++ b/tools/aconfig/aconfig_storage_read_api/src/mapped_file.rs
@@ -97,10 +97,10 @@
         let flag_map = storage_dir.clone() + "/maps/mockup.flag.map";
         let flag_val = storage_dir.clone() + "/boot/mockup.val";
         let flag_info = storage_dir.clone() + "/boot/mockup.info";
-        fs::copy("./tests/package.map", &package_map).unwrap();
-        fs::copy("./tests/flag.map", &flag_map).unwrap();
-        fs::copy("./tests/flag.val", &flag_val).unwrap();
-        fs::copy("./tests/flag.info", &flag_info).unwrap();
+        fs::copy("./tests/data/v1/package.map", &package_map).unwrap();
+        fs::copy("./tests/data/v1/flag.map", &flag_map).unwrap();
+        fs::copy("./tests/data/v1/flag.val", &flag_val).unwrap();
+        fs::copy("./tests/data/v1/flag.info", &flag_info).unwrap();
 
         return storage_dir;
     }
@@ -108,9 +108,9 @@
     #[test]
     fn test_mapped_file_contents() {
         let storage_dir = create_test_storage_files();
-        map_and_verify(&storage_dir, StorageFileType::PackageMap, "./tests/package.map");
-        map_and_verify(&storage_dir, StorageFileType::FlagMap, "./tests/flag.map");
-        map_and_verify(&storage_dir, StorageFileType::FlagVal, "./tests/flag.val");
-        map_and_verify(&storage_dir, StorageFileType::FlagInfo, "./tests/flag.info");
+        map_and_verify(&storage_dir, StorageFileType::PackageMap, "./tests/data/v1/package.map");
+        map_and_verify(&storage_dir, StorageFileType::FlagMap, "./tests/data/v1/flag.map");
+        map_and_verify(&storage_dir, StorageFileType::FlagVal, "./tests/data/v1/flag.val");
+        map_and_verify(&storage_dir, StorageFileType::FlagInfo, "./tests/data/v1/flag.info");
     }
 }
diff --git a/tools/aconfig/aconfig_storage_read_api/tests/Android.bp b/tools/aconfig/aconfig_storage_read_api/tests/Android.bp
index ed0c728..b8e510d 100644
--- a/tools/aconfig/aconfig_storage_read_api/tests/Android.bp
+++ b/tools/aconfig/aconfig_storage_read_api/tests/Android.bp
@@ -1,9 +1,10 @@
 filegroup {
     name: "read_api_test_storage_files",
-    srcs: ["package.map",
-        "flag.map",
-        "flag.val",
-        "flag.info"
+    srcs: [
+        "data/v1/package.map",
+        "data/v1/flag.map",
+        "data/v1/flag.val",
+        "data/v1/flag.info",
     ],
 }
 
diff --git a/tools/aconfig/aconfig_storage_read_api/tests/flag.info b/tools/aconfig/aconfig_storage_read_api/tests/data/v1/flag.info
similarity index 100%
rename from tools/aconfig/aconfig_storage_read_api/tests/flag.info
rename to tools/aconfig/aconfig_storage_read_api/tests/data/v1/flag.info
Binary files differ
diff --git a/tools/aconfig/aconfig_storage_read_api/tests/flag.map b/tools/aconfig/aconfig_storage_read_api/tests/data/v1/flag.map
similarity index 100%
rename from tools/aconfig/aconfig_storage_read_api/tests/flag.map
rename to tools/aconfig/aconfig_storage_read_api/tests/data/v1/flag.map
Binary files differ
diff --git a/tools/aconfig/aconfig_storage_read_api/tests/flag.val b/tools/aconfig/aconfig_storage_read_api/tests/data/v1/flag.val
similarity index 100%
rename from tools/aconfig/aconfig_storage_read_api/tests/flag.val
rename to tools/aconfig/aconfig_storage_read_api/tests/data/v1/flag.val
Binary files differ
diff --git a/tools/aconfig/aconfig_storage_read_api/tests/package.map b/tools/aconfig/aconfig_storage_read_api/tests/data/v1/package.map
similarity index 100%
rename from tools/aconfig/aconfig_storage_read_api/tests/package.map
rename to tools/aconfig/aconfig_storage_read_api/tests/data/v1/package.map
Binary files differ
diff --git a/tools/aconfig/aconfig_storage_read_api/tests/storage_read_api_test.cpp b/tools/aconfig/aconfig_storage_read_api/tests/storage_read_api_test.cpp
index 6d29045..7537643 100644
--- a/tools/aconfig/aconfig_storage_read_api/tests/storage_read_api_test.cpp
+++ b/tools/aconfig/aconfig_storage_read_api/tests/storage_read_api_test.cpp
@@ -45,7 +45,8 @@
   }
 
   void SetUp() override {
-    auto const test_dir = android::base::GetExecutableDirectory();
+    auto const test_base_dir = android::base::GetExecutableDirectory();
+    auto const test_dir = test_base_dir + "/data/v1";
     storage_dir = std::string(root_dir.path);
     auto maps_dir = storage_dir + "/maps";
     auto boot_dir = storage_dir + "/boot";
diff --git a/tools/aconfig/aconfig_storage_read_api/tests/storage_read_api_test.rs b/tools/aconfig/aconfig_storage_read_api/tests/storage_read_api_test.rs
index afc44d4..0d943f8 100644
--- a/tools/aconfig/aconfig_storage_read_api/tests/storage_read_api_test.rs
+++ b/tools/aconfig/aconfig_storage_read_api/tests/storage_read_api_test.rs
@@ -26,10 +26,10 @@
         let flag_map = storage_dir.clone() + "/maps/mockup.flag.map";
         let flag_val = storage_dir.clone() + "/boot/mockup.val";
         let flag_info = storage_dir.clone() + "/boot/mockup.info";
-        fs::copy("./package.map", package_map).unwrap();
-        fs::copy("./flag.map", flag_map).unwrap();
-        fs::copy("./flag.val", flag_val).unwrap();
-        fs::copy("./flag.info", flag_info).unwrap();
+        fs::copy("./data/v1/package.map", package_map).unwrap();
+        fs::copy("./data/v1/flag.map", flag_map).unwrap();
+        fs::copy("./data/v1/flag.val", flag_val).unwrap();
+        fs::copy("./data/v1/flag.info", flag_info).unwrap();
 
         storage_dir
     }
@@ -200,9 +200,9 @@
 
     #[test]
     fn test_storage_version_query() {
-        assert_eq!(get_storage_file_version("./package.map").unwrap(), 1);
-        assert_eq!(get_storage_file_version("./flag.map").unwrap(), 1);
-        assert_eq!(get_storage_file_version("./flag.val").unwrap(), 1);
-        assert_eq!(get_storage_file_version("./flag.info").unwrap(), 1);
+        assert_eq!(get_storage_file_version("./data/v1/package.map").unwrap(), 1);
+        assert_eq!(get_storage_file_version("./data/v1/flag.map").unwrap(), 1);
+        assert_eq!(get_storage_file_version("./data/v1/flag.val").unwrap(), 1);
+        assert_eq!(get_storage_file_version("./data/v1/flag.info").unwrap(), 1);
     }
 }
diff --git a/tools/aconfig/aflags/Cargo.toml b/tools/aconfig/aflags/Cargo.toml
index 7efce6d..d31e232 100644
--- a/tools/aconfig/aflags/Cargo.toml
+++ b/tools/aconfig/aflags/Cargo.toml
@@ -9,10 +9,10 @@
 protobuf = "3.2.0"
 regex = "1.10.3"
 aconfig_protos = { path = "../aconfig_protos" }
-aconfigd_protos = { version = "0.1.0", path = "../../../../../system/server_configurable_flags/aconfigd"}
+aconfigd_protos = { version = "0.1.0", path = "../../../../../packages/modules/ConfigInfrastructure/aconfigd/proto"}
 nix = { version = "0.28.0", features = ["user"] }
 aconfig_storage_file = { version = "0.1.0", path = "../aconfig_storage_file" }
 aconfig_storage_read_api = { version = "0.1.0", path = "../aconfig_storage_read_api" }
 clap = {version = "4.5.2" }
 aconfig_device_paths = { version = "0.1.0", path = "../aconfig_device_paths" }
-aconfig_flags = { version = "0.1.0", path = "../aconfig_flags" }
\ No newline at end of file
+aconfig_flags = { version = "0.1.0", path = "../aconfig_flags" }
diff --git a/tools/edit_monitor/daemon_manager.py b/tools/edit_monitor/daemon_manager.py
index 445d849..892c292 100644
--- a/tools/edit_monitor/daemon_manager.py
+++ b/tools/edit_monitor/daemon_manager.py
@@ -70,6 +70,10 @@
       logging.warning("Block sign found, exiting...")
       return
 
+    if self.binary_path.startswith('/google/cog/'):
+      logging.warning("Edit monitor for cog is not supported, exiting...")
+      return
+
     self._stop_any_existing_instance()
     self._write_pid_to_pidfile()
     self._start_daemon_process()
diff --git a/tools/edit_monitor/daemon_manager_test.py b/tools/edit_monitor/daemon_manager_test.py
index d62eade..72442c6 100644
--- a/tools/edit_monitor/daemon_manager_test.py
+++ b/tools/edit_monitor/daemon_manager_test.py
@@ -131,6 +131,13 @@
     # Verify no daemon process is started.
     self.assertIsNone(dm.daemon_process)
 
+  def test_start_return_directly_if_in_cog_env(self):
+    dm = daemon_manager.DaemonManager(
+        '/google/cog/cloud/user/workspace/edit_monitor')
+    dm.start()
+    # Verify no daemon process is started.
+    self.assertIsNone(dm.daemon_process)
+
   @mock.patch('os.kill')
   def test_start_failed_to_kill_existing_instance(self, mock_kill):
     mock_kill.side_effect = OSError('Unknown OSError')
diff --git a/tools/filelistdiff/allowlist_next b/tools/filelistdiff/allowlist_next
index d7078f5..8f91c9f 100644
--- a/tools/filelistdiff/allowlist_next
+++ b/tools/filelistdiff/allowlist_next
@@ -7,9 +7,3 @@
 framework/oat/x86_64/apex@com.android.compos@javalib@service-compos.jar@classes.odex.fsv_meta
 framework/oat/x86_64/apex@com.android.compos@javalib@service-compos.jar@classes.vdex
 framework/oat/x86_64/apex@com.android.compos@javalib@service-compos.jar@classes.vdex.fsv_meta
-
-# Soong only installed files
-etc/aconfig/flag.info
-etc/aconfig/flag.map
-etc/aconfig/flag.val
-etc/aconfig/package.map
diff --git a/tools/filelistdiff/file_list_diff.py b/tools/filelistdiff/file_list_diff.py
index 951325f..fbbfedf 100644
--- a/tools/filelistdiff/file_list_diff.py
+++ b/tools/filelistdiff/file_list_diff.py
@@ -31,10 +31,14 @@
             allowed_files.update(set(filter(lambda x: len(x), map(lambda x: x.lstrip().split('#',1)[0].rstrip() , allowlist_file.read().split('\n')))))
 
     def is_unknown_diff(filepath):
-        return not filepath in allowed_files
+        return filepath not in allowed_files
+
+    def is_unnecessary_allowlist(filepath):
+        return filepath not in kati_files.symmetric_difference(soong_files)
 
     unique_in_kati = set(filter(is_unknown_diff, kati_files - soong_files))
     unique_in_soong = set(filter(is_unknown_diff, soong_files - kati_files))
+    unnecessary_allowlists = set(filter(is_unnecessary_allowlist, allowed_files))
 
     if unique_in_kati:
         print('')
@@ -53,7 +57,15 @@
         for item in sorted(unique_in_soong):
             print('  '+item)
 
-    if unique_in_kati or unique_in_soong:
+    if unnecessary_allowlists:
+        print('')
+        print(f'{COLOR_ERROR}Unnecessary files in allowlist.{COLOR_NORMAL}')
+        print('Please remove these entries from build/make/tools/filelistdiff/allowlist')
+        for item in sorted(unnecessary_allowlists):
+            print('  '+item)
+
+
+    if unique_in_kati or unique_in_soong or unnecessary_allowlists:
         print('')
         sys.exit(1)
 
diff --git a/tools/ide_query/ide_query.go b/tools/ide_query/ide_query.go
index 89ac78f..ec937fe 100644
--- a/tools/ide_query/ide_query.go
+++ b/tools/ide_query/ide_query.go
@@ -341,6 +341,8 @@
 			Id:              moduleName,
 			Language:        pb.Language_LANGUAGE_JAVA,
 			SourceFilePaths: m.Srcs,
+			GeneratedFiles:  genFiles(env, m),
+			DependencyIds:   m.Deps,
 		}
 		unitsById[u.Id] = u
 
@@ -355,14 +357,10 @@
 				continue
 			}
 
-			var paths []string
-			paths = append(paths, mod.Srcs...)
-			paths = append(paths, mod.SrcJars...)
-			paths = append(paths, mod.Jars...)
 			unitsById[name] = &pb.BuildableUnit{
 				Id:              name,
 				SourceFilePaths: mod.Srcs,
-				GeneratedFiles:  genFiles(env, paths),
+				GeneratedFiles:  genFiles(env, mod),
 				DependencyIds:   mod.Deps,
 			}
 
@@ -380,8 +378,13 @@
 }
 
 // genFiles returns the generated files (paths that start with outDir/) for the
-// given paths. Generated files that do not exist are ignored.
-func genFiles(env Env, paths []string) []*pb.GeneratedFile {
+// given module. Generated files that do not exist are ignored.
+func genFiles(env Env, mod *javaModule) []*pb.GeneratedFile {
+	var paths []string
+	paths = append(paths, mod.Srcs...)
+	paths = append(paths, mod.SrcJars...)
+	paths = append(paths, mod.Jars...)
+
 	prefix := env.OutDir + "/"
 	var ret []*pb.GeneratedFile
 	for _, p := range paths {