Merge "Add appcompat system properties flag to soong" into main
diff --git a/core/Makefile b/core/Makefile
index d09f54f..e6a5bc0 100644
--- a/core/Makefile
+++ b/core/Makefile
@@ -1128,10 +1128,15 @@
 
 BOARD_VENDOR_RAMDISK_FRAGMENT.16K.PREBUILT := $(BUILT_RAMDISK_16K_TARGET)
 
+ifndef BOARD_KERNEL_MODULES_LOAD_16K
+  BOARD_KERNEL_MODULES_LOAD_16K := $(BOARD_KERNEL_MODULES_16K)
+endif
+
 $(BUILT_RAMDISK_16K_TARGET): $(DEPMOD) $(MKBOOTFS) $(EXTRACT_KERNEL) $(COMPRESSION_COMMAND_DEPS)
 $(BUILT_RAMDISK_16K_TARGET): $(foreach file,$(BOARD_KERNEL_MODULES_16K),$(RAMDISK_16K_STAGING_DIR)/lib/modules/0.0/$(notdir $(file)))
 	$(DEPMOD) -b $(RAMDISK_16K_STAGING_DIR) 0.0
-	for MODULE in $(BOARD_KERNEL_MODULES_16K); do \
+	rm -f $(RAMDISK_16K_STAGING_DIR)/lib/modules/0.0/modules.load
+	for MODULE in $(BOARD_KERNEL_MODULES_LOAD_16K); do \
 		basename $$MODULE >> $(RAMDISK_16K_STAGING_DIR)/lib/modules/0.0/modules.load ; \
 	done;
 	rm -rf $(TARGET_OUT_RAMDISK_16K)/lib/modules
diff --git a/core/android_soong_config_vars.mk b/core/android_soong_config_vars.mk
index 5dfe5cc..56da574 100644
--- a/core/android_soong_config_vars.mk
+++ b/core/android_soong_config_vars.mk
@@ -26,13 +26,17 @@
 
 # Add variables to the namespace below:
 
-$(call add_soong_config_var,ANDROID,TARGET_DYNAMIC_64_32_MEDIASERVER)
-$(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,BOARD_USES_ODMIMAGE)
 $(call add_soong_config_var,ANDROID,BOARD_USES_RECOVERY_AS_BOOT)
 $(call add_soong_config_var,ANDROID,CHECK_DEV_TYPE_VIOLATIONS)
+$(call add_soong_config_var,ANDROID,PLATFORM_SEPOLICY_COMPAT_VERSIONS)
 $(call add_soong_config_var,ANDROID,PRODUCT_INSTALL_DEBUG_POLICY_TO_SYSTEM_EXT)
+$(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)
+
+# PRODUCT_PRECOMPILED_SEPOLICY defaults to true. Explicitly check if it's "false" or not.
+$(call add_soong_config_var_value,ANDROID,PRODUCT_PRECOMPILED_SEPOLICY,$(if $(filter false,$(PRODUCT_PRECOMPILED_SEPOLICY)),false,true))
 
 # Default behavior for the tree wrt building modules or using prebuilts. This
 # can always be overridden by setting the environment variable
@@ -74,34 +78,6 @@
   $(call add_soong_config_var_value, ANDROID, target_board_auto, $(TARGET_BOARD_AUTO))
 endif
 
-# Ensure that those mainline modules who have individually toggleable prebuilts
-# are controlled by the MODULE_BUILD_FROM_SOURCE environment variable by
-# default.
-INDIVIDUALLY_TOGGLEABLE_PREBUILT_MODULES := \
-  adservices \
-  appsearch \
-  btservices \
-  devicelock \
-  configinfrastructure \
-  conscrypt \
-  healthfitness \
-  ipsec \
-  media \
-  mediaprovider \
-  ondevicepersonalization \
-  permission \
-  rkpd \
-  scheduling \
-  sdkext \
-  statsd \
-  tethering \
-  uwb \
-  wifi \
-
-$(foreach m, $(INDIVIDUALLY_TOGGLEABLE_PREBUILT_MODULES),\
-  $(if $(call soong_config_get,$(m)_module,source_build),,\
-    $(call soong_config_set,$(m)_module,source_build,$(MODULE_BUILD_FROM_SOURCE))))
-
 # Apex build mode variables
 ifdef APEX_BUILD_FOR_PRE_S_DEVICES
 $(call add_soong_config_var_value,ANDROID,library_linking_strategy,prefer_static)
diff --git a/core/main.mk b/core/main.mk
index b798b49..8182740 100644
--- a/core/main.mk
+++ b/core/main.mk
@@ -343,6 +343,10 @@
 ADDITIONAL_PRODUCT_PROPERTIES += \
     ro.product.cpu.pagesize.max=$(TARGET_MAX_PAGE_SIZE_SUPPORTED)
 
+ifeq ($(PRODUCT_NO_BIONIC_PAGE_SIZE_MACRO),true)
+ADDITIONAL_PRODUCT_PROPERTIES += ro.product.build.no_bionic_page_size_macro=true
+endif
+
 # -----------------------------------------------------------------
 ###
 ### In this section we set up the things that are different
@@ -1908,7 +1912,7 @@
   $(api_xmls):
 	$(hide) echo "Converting API file to XML: $@"
 	$(hide) mkdir -p $(dir $@)
-	$(hide) $(APICHECK_COMMAND) --input-api-jar $< --api-xml $@
+	$(hide) $(APICHECK_COMMAND) jar-to-jdiff $< $@
 
   $(foreach xml,$(sort $(api_xmls)),$(call declare-1p-target,$(xml),))
 
diff --git a/core/product.mk b/core/product.mk
index e8db0f5..f8634ef 100644
--- a/core/product.mk
+++ b/core/product.mk
@@ -478,6 +478,10 @@
 
 _product_single_value_vars += PRODUCT_EXPORT_RUNTIME_APIS
 
+# If set, determines which version of the GKI is used as guest kernel for Microdroid VMs.
+# TODO(b/325991735): link to documentation once it is done.
+_product_single_value_vars += PRODUCT_AVF_MICRODROID_GUEST_GKI_VERSION
+
 .KATI_READONLY := _product_single_value_vars _product_list_vars
 _product_var_list :=$= $(_product_single_value_vars) $(_product_list_vars)
 
diff --git a/core/tasks/meta-lic.mk b/core/tasks/meta-lic.mk
index 0348844..7d1cfc3 100644
--- a/core/tasks/meta-lic.mk
+++ b/core/tasks/meta-lic.mk
@@ -14,6 +14,22 @@
 
 # Declare license metadata for non-module files released with products.
 
+# Moved here from device/generic/car/Android.mk
+$(eval $(call declare-1p-copy-files,device/generic/car,))
+
+# Moved here from device/generic/trusty/Android.mk
+$(eval $(call declare-1p-copy-files,device/generic/trusty,))
+
+# Moved here from device/generic/uml/Android.mk
+$(eval $(call declare-1p-copy-files,device/generic/uml,))
+
+# Moved here from device/google_car/common/Android.mk
+$(eval $(call declare-1p-copy-files,device/google_car/common,))
+
+# Moved here from device/google/atv/Android.mk
+$(eval $(call declare-1p-copy-files,device/google/atv,atv-component-overrides.xml))
+$(eval $(call declare-1p-copy-files,device/google/atv,tv_core_hardware.xml))
+
 # Moved here from device/sample/Android.mk
 $(eval $(call declare-1p-copy-files,device/sample,))
 
diff --git a/envsetup.sh b/envsetup.sh
index ca75132..ab43ada 100644
--- a/envsetup.sh
+++ b/envsetup.sh
@@ -1100,7 +1100,7 @@
         echo "Command adb not found; try lunch (and building) first?"
         return 1
     fi
-    $ADB "${@}"
+    run_tool_with_logging "ADB" $ADB "${@}"
 }
 
 function run_tool_with_logging() {
diff --git a/target/product/generic_system.mk b/target/product/generic_system.mk
index ad6e030..9748c7c 100644
--- a/target/product/generic_system.mk
+++ b/target/product/generic_system.mk
@@ -36,6 +36,11 @@
     Stk \
     Tag \
 
+ifeq ($(RELEASE_AVATAR_PICKER_APP),true)
+  PRODUCT_PACKAGES += \
+    AvatarPicker
+endif
+
 # OTA support
 PRODUCT_PACKAGES += \
     recovery-refresh \
diff --git a/target/product/runtime_libart.mk b/target/product/runtime_libart.mk
index a9d478d..d9c3c9a 100644
--- a/target/product/runtime_libart.mk
+++ b/target/product/runtime_libart.mk
@@ -175,15 +175,5 @@
     dalvik.vm.usap_pool_size_min?=1 \
     dalvik.vm.usap_pool_refill_delay_ms?=3000
 
-# Allow dexopt files that are side-effects of already allowlisted files.
-# This is only necessary when ART is prebuilt.
-ifeq (false,$(ART_MODULE_BUILD_FROM_SOURCE))
-  PRODUCT_ARTIFACT_PATH_REQUIREMENT_ALLOWED_LIST += \
-      system/framework/%.art \
-      system/framework/%.oat \
-      system/framework/%.odex \
-      system/framework/%.vdex
-endif
-
 PRODUCT_SYSTEM_PROPERTIES += \
     dalvik.vm.useartservice=true
diff --git a/tests/Android.bp b/tests/Android.bp
index b2ff583..d3964e5 100644
--- a/tests/Android.bp
+++ b/tests/Android.bp
@@ -14,6 +14,7 @@
 
 package {
     default_applicable_licenses: ["Android-Apache-2.0"],
+    default_team: "trendy_team_build",
 }
 
 python_test_host {
diff --git a/tools/aconfig/aconfig/src/commands.rs b/tools/aconfig/aconfig/src/commands.rs
index 7736ce7..9cb40bf 100644
--- a/tools/aconfig/aconfig/src/commands.rs
+++ b/tools/aconfig/aconfig/src/commands.rs
@@ -242,10 +242,7 @@
     let parsed_flags_vec: Vec<ProtoParsedFlags> = caches
         .into_iter()
         .map(|mut input| input.try_parse_flags())
-        .collect::<Result<Vec<_>>>()?
-        .into_iter()
-        .filter(|pfs| find_unique_container(pfs) == Some(container))
-        .collect();
+        .collect::<Result<Vec<_>>>()?;
     generate_storage_file(container, parsed_flags_vec.iter(), file)
 }
 
@@ -324,14 +321,6 @@
     Some(package)
 }
 
-fn find_unique_container(parsed_flags: &ProtoParsedFlags) -> Option<&str> {
-    let container = parsed_flags.parsed_flag.first().map(|pf| pf.container())?;
-    if parsed_flags.parsed_flag.iter().any(|pf| pf.container() != container) {
-        return None;
-    }
-    Some(container)
-}
-
 pub fn modify_parsed_flags_based_on_mode(
     parsed_flags: ProtoParsedFlags,
     codegen_mode: CodegenMode,
diff --git a/tools/aconfig/aconfig_storage_file/Android.bp b/tools/aconfig/aconfig_storage_file/Android.bp
index d60ba92..08c00b0 100644
--- a/tools/aconfig/aconfig_storage_file/Android.bp
+++ b/tools/aconfig/aconfig_storage_file/Android.bp
@@ -27,6 +27,8 @@
         "//apex_available:anyapex",
     ],
     min_sdk_version: "29",
+    vendor_available: true,
+    product_available: true,
 }
 
 rust_binary_host {
@@ -54,6 +56,8 @@
         "//apex_available:anyapex",
     ],
     min_sdk_version: "29",
+    vendor_available: true,
+    product_available: true,
 }
 
 cc_library {
@@ -68,4 +72,8 @@
         "//apex_available:anyapex",
     ],
     host_supported: true,
+    min_sdk_version: "29",
+    vendor_available: true,
+    product_available: true,
+    double_loadable: true,
 }
diff --git a/tools/aconfig/aconfig_storage_file/src/flag_info.rs b/tools/aconfig/aconfig_storage_file/src/flag_info.rs
index dc2a8d6..beac38d 100644
--- a/tools/aconfig/aconfig_storage_file/src/flag_info.rs
+++ b/tools/aconfig/aconfig_storage_file/src/flag_info.rs
@@ -91,9 +91,9 @@
 /// bit field for flag info
 #[derive(Clone, Debug, PartialEq, Eq)]
 pub enum FlagInfoBit {
-    IsSticky = 1 << 0,
+    HasServerOverride = 1 << 0,
     IsReadWrite = 1 << 1,
-    HasOverride = 1 << 2,
+    HasLocalOverride = 1 << 2,
 }
 
 /// Flag info node struct
@@ -107,10 +107,10 @@
     fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result {
         writeln!(
             f,
-            "sticky: {}, readwrite: {}, override: {}",
-            self.attributes & (FlagInfoBit::IsSticky as u8) != 0,
+            "readwrite: {}, server override: {}, local override: {}",
             self.attributes & (FlagInfoBit::IsReadWrite as u8) != 0,
-            self.attributes & (FlagInfoBit::HasOverride as u8) != 0,
+            self.attributes & (FlagInfoBit::HasServerOverride as u8) != 0,
+            self.attributes & (FlagInfoBit::HasLocalOverride as u8) != 0,
         )?;
         Ok(())
     }
diff --git a/tools/aconfig/aconfig_storage_read_api/Android.bp b/tools/aconfig/aconfig_storage_read_api/Android.bp
index a0980b6..3fb6a53 100644
--- a/tools/aconfig/aconfig_storage_read_api/Android.bp
+++ b/tools/aconfig/aconfig_storage_read_api/Android.bp
@@ -65,7 +65,14 @@
     name: "libaconfig_storage_read_api_cxx_bridge",
     crate_name: "aconfig_storage_read_api_cxx_bridge",
     host_supported: true,
+    vendor_available: true,
+    product_available: true,
     defaults: ["aconfig_storage_read_api.defaults"],
+    apex_available: [
+        "//apex_available:platform",
+        "//apex_available:anyapex",
+    ],
+    min_sdk_version: "29",
 }
 
 // flag read api cc interface
@@ -79,14 +86,21 @@
     generated_sources: ["libcxx_aconfig_storage_read_api_bridge_code"],
     whole_static_libs: ["libaconfig_storage_read_api_cxx_bridge"],
     export_include_dirs: ["include"],
+    host_supported: true,
+    vendor_available: true,
+    product_available: true,
     static_libs: [
         "libaconfig_storage_protos_cc",
         "libprotobuf-cpp-lite",
         "libbase",
+    ],
+    shared_libs: [
         "liblog",
     ],
     apex_available: [
         "//apex_available:platform",
         "//apex_available:anyapex",
     ],
+    min_sdk_version: "29",
+    double_loadable: true,
 }
diff --git a/tools/aconfig/aconfig_storage_read_api/include/aconfig_storage/aconfig_storage_read_api.hpp b/tools/aconfig/aconfig_storage_read_api/include/aconfig_storage/aconfig_storage_read_api.hpp
index 7c63ef2..0a4d5b4 100644
--- a/tools/aconfig/aconfig_storage_read_api/include/aconfig_storage/aconfig_storage_read_api.hpp
+++ b/tools/aconfig/aconfig_storage_read_api/include/aconfig_storage/aconfig_storage_read_api.hpp
@@ -32,9 +32,9 @@
 /// Flag info enum, to be consistent with the one defined in
 /// aconfig_storage_file/src/flag_info.rs
 enum FlagInfoBit {
-  IsSticky = 1<<0,
+  HasServerOverride = 1<<0,
   IsReadWrite = 1<<1,
-  HasOverride = 1<<2,
+  HasLocalOverride = 1<<2,
 };
 
 /// Mapped storage file
diff --git a/tools/aconfig/aconfig_storage_read_api/src/flag_info_query.rs b/tools/aconfig/aconfig_storage_read_api/src/flag_info_query.rs
index e593418..0087feb 100644
--- a/tools/aconfig/aconfig_storage_read_api/src/flag_info_query.rs
+++ b/tools/aconfig/aconfig_storage_read_api/src/flag_info_query.rs
@@ -56,13 +56,13 @@
     use aconfig_storage_file::{test_utils::create_test_flag_info_list, FlagInfoBit};
 
     #[test]
-    // this test point locks down query if flag is sticky
+    // this test point locks down query if flag has server override
     fn test_is_flag_sticky() {
         let flag_info_list = create_test_flag_info_list().into_bytes();
         for offset in 0..8 {
             let attribute =
                 find_flag_attribute(&flag_info_list[..], FlagValueType::Boolean, offset).unwrap();
-            assert_eq!((attribute & FlagInfoBit::IsSticky as u8) != 0u8, false);
+            assert_eq!((attribute & FlagInfoBit::HasServerOverride as u8) != 0u8, false);
         }
     }
 
@@ -82,13 +82,13 @@
     }
 
     #[test]
-    // this test point locks down query if flag has override
+    // this test point locks down query if flag has local override
     fn test_flag_has_override() {
         let flag_info_list = create_test_flag_info_list().into_bytes();
         for offset in 0..8 {
             let attribute =
                 find_flag_attribute(&flag_info_list[..], FlagValueType::Boolean, offset).unwrap();
-            assert_eq!((attribute & FlagInfoBit::HasOverride as u8) != 0u8, false);
+            assert_eq!((attribute & FlagInfoBit::HasLocalOverride as u8) != 0u8, false);
         }
     }
 
diff --git a/tools/aconfig/aconfig_storage_read_api/src/lib.rs b/tools/aconfig/aconfig_storage_read_api/src/lib.rs
index bc09112..fa8dad6 100644
--- a/tools/aconfig/aconfig_storage_read_api/src/lib.rs
+++ b/tools/aconfig/aconfig_storage_read_api/src/lib.rs
@@ -508,9 +508,9 @@
         for (offset, expected_value) in is_rw.into_iter().enumerate() {
             let attribute =
                 get_flag_attribute(&flag_info_file, FlagValueType::Boolean, offset as u32).unwrap();
-            assert!((attribute & FlagInfoBit::IsSticky as u8) == 0u8);
             assert_eq!((attribute & FlagInfoBit::IsReadWrite as u8) != 0u8, expected_value);
-            assert!((attribute & FlagInfoBit::HasOverride as u8) == 0u8);
+            assert!((attribute & FlagInfoBit::HasServerOverride as u8) == 0u8);
+            assert!((attribute & FlagInfoBit::HasLocalOverride as u8) == 0u8);
         }
     }
 
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 10f71a5..5b4d32c 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
@@ -236,10 +236,10 @@
   for (int index = 0; index < 8; ++index) {
     auto attribute = api::get_flag_attribute(*mapped_file, api::FlagValueType::Boolean, index);
     ASSERT_TRUE(attribute.ok());
-    ASSERT_EQ(*attribute & static_cast<uint8_t>(api::FlagInfoBit::IsSticky), 0);
+    ASSERT_EQ(*attribute & static_cast<uint8_t>(api::FlagInfoBit::HasServerOverride), 0);
     ASSERT_EQ((*attribute & static_cast<uint8_t>(api::FlagInfoBit::IsReadWrite)) != 0,
               expected_value[index]);
-    ASSERT_EQ(*attribute & static_cast<uint8_t>(api::FlagInfoBit::HasOverride), 0);
+    ASSERT_EQ(*attribute & static_cast<uint8_t>(api::FlagInfoBit::HasLocalOverride), 0);
   }
 }
 
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 212f734..1a8af75 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
@@ -192,9 +192,9 @@
         for (offset, expected_value) in is_rw.into_iter().enumerate() {
             let attribute =
                 get_flag_attribute(&flag_info_file, FlagValueType::Boolean, offset as u32).unwrap();
-            assert!((attribute & FlagInfoBit::IsSticky as u8) == 0u8);
+            assert!((attribute & FlagInfoBit::HasServerOverride as u8) == 0u8);
             assert_eq!((attribute & FlagInfoBit::IsReadWrite as u8) != 0u8, expected_value);
-            assert!((attribute & FlagInfoBit::HasOverride as u8) == 0u8);
+            assert!((attribute & FlagInfoBit::HasLocalOverride as u8) == 0u8);
         }
     }
 
diff --git a/tools/aconfig/aconfig_storage_write_api/aconfig_storage_write_api.cpp b/tools/aconfig/aconfig_storage_write_api/aconfig_storage_write_api.cpp
index d57ca64..f031d01 100644
--- a/tools/aconfig/aconfig_storage_write_api/aconfig_storage_write_api.cpp
+++ b/tools/aconfig/aconfig_storage_write_api/aconfig_storage_write_api.cpp
@@ -142,15 +142,15 @@
   return {};
 }
 
-/// Set if flag is sticky
-Result<void> set_flag_is_sticky(
+/// Set if flag has server override
+Result<void> set_flag_has_server_override(
     const MutableMappedStorageFile& file,
     FlagValueType value_type,
     uint32_t offset,
     bool value) {
   auto content = rust::Slice<uint8_t>(
       static_cast<uint8_t*>(file.file_ptr), file.file_size);
-  auto update_cxx = update_flag_is_sticky_cxx(
+  auto update_cxx = update_flag_has_server_override_cxx(
       content, static_cast<uint16_t>(value_type), offset, value);
   if (!update_cxx.update_success) {
     return Error() << std::string(update_cxx.error_message.c_str());
@@ -158,15 +158,15 @@
   return {};
 }
 
-/// Set if flag has override
-Result<void> set_flag_has_override(
+/// Set if flag has local override
+Result<void> set_flag_has_local_override(
     const MutableMappedStorageFile& file,
     FlagValueType value_type,
     uint32_t offset,
     bool value) {
   auto content = rust::Slice<uint8_t>(
       static_cast<uint8_t*>(file.file_ptr), file.file_size);
-  auto update_cxx = update_flag_has_override_cxx(
+  auto update_cxx = update_flag_has_local_override_cxx(
       content, static_cast<uint16_t>(value_type), offset, value);
   if (!update_cxx.update_success) {
     return Error() << std::string(update_cxx.error_message.c_str());
diff --git a/tools/aconfig/aconfig_storage_write_api/include/aconfig_storage/aconfig_storage_write_api.hpp b/tools/aconfig/aconfig_storage_write_api/include/aconfig_storage/aconfig_storage_write_api.hpp
index e9e4ebb..12b0ecc 100644
--- a/tools/aconfig/aconfig_storage_write_api/include/aconfig_storage/aconfig_storage_write_api.hpp
+++ b/tools/aconfig/aconfig_storage_write_api/include/aconfig_storage/aconfig_storage_write_api.hpp
@@ -41,15 +41,15 @@
     uint32_t offset,
     bool value);
 
-/// Set if flag is sticky
-Result<void> set_flag_is_sticky(
+/// Set if flag has server override
+Result<void> set_flag_has_server_override(
     const MutableMappedStorageFile& file,
     FlagValueType value_type,
     uint32_t offset,
     bool value);
 
-/// Set if flag has override
-Result<void> set_flag_has_override(
+/// Set if flag has local override
+Result<void> set_flag_has_local_override(
     const MutableMappedStorageFile& file,
     FlagValueType value_type,
     uint32_t offset,
diff --git a/tools/aconfig/aconfig_storage_write_api/src/flag_info_update.rs b/tools/aconfig/aconfig_storage_write_api/src/flag_info_update.rs
index 3f38705..6f03f12 100644
--- a/tools/aconfig/aconfig_storage_write_api/src/flag_info_update.rs
+++ b/tools/aconfig/aconfig_storage_write_api/src/flag_info_update.rs
@@ -61,32 +61,32 @@
     Ok((attribute, head))
 }
 
-/// Set if flag is sticky
-pub fn update_flag_is_sticky(
+/// Set if flag has server override
+pub fn update_flag_has_server_override(
     buf: &mut [u8],
     flag_type: FlagValueType,
     flag_index: u32,
     value: bool,
 ) -> Result<(), AconfigStorageError> {
     let (attribute, head) = get_flag_attribute_and_offset(buf, flag_type, flag_index)?;
-    let is_sticky = (attribute & (FlagInfoBit::IsSticky as u8)) != 0;
-    if is_sticky != value {
-        buf[head] = (attribute ^ FlagInfoBit::IsSticky as u8).to_le_bytes()[0];
+    let has_override = (attribute & (FlagInfoBit::HasServerOverride as u8)) != 0;
+    if has_override != value {
+        buf[head] = (attribute ^ FlagInfoBit::HasServerOverride as u8).to_le_bytes()[0];
     }
     Ok(())
 }
 
-/// Set if flag has override
-pub fn update_flag_has_override(
+/// Set if flag has local override
+pub fn update_flag_has_local_override(
     buf: &mut [u8],
     flag_type: FlagValueType,
     flag_index: u32,
     value: bool,
 ) -> Result<(), AconfigStorageError> {
     let (attribute, head) = get_flag_attribute_and_offset(buf, flag_type, flag_index)?;
-    let has_override = (attribute & (FlagInfoBit::HasOverride as u8)) != 0;
+    let has_override = (attribute & (FlagInfoBit::HasLocalOverride as u8)) != 0;
     if has_override != value {
-        buf[head] = (attribute ^ FlagInfoBit::HasOverride as u8).to_le_bytes()[0];
+        buf[head] = (attribute ^ FlagInfoBit::HasLocalOverride as u8).to_le_bytes()[0];
     }
     Ok(())
 }
@@ -98,32 +98,32 @@
     use aconfig_storage_read_api::flag_info_query::find_flag_attribute;
 
     #[test]
-    // this test point locks down is sticky update
-    fn test_update_flag_is_sticky() {
+    // this test point locks down has server override update
+    fn test_update_flag_has_server_override() {
         let flag_info_list = create_test_flag_info_list();
         let mut buf = flag_info_list.into_bytes();
         for i in 0..flag_info_list.header.num_flags {
-            update_flag_is_sticky(&mut buf, FlagValueType::Boolean, i, true).unwrap();
+            update_flag_has_server_override(&mut buf, FlagValueType::Boolean, i, true).unwrap();
             let attribute = find_flag_attribute(&buf, FlagValueType::Boolean, i).unwrap();
-            assert!((attribute & (FlagInfoBit::IsSticky as u8)) != 0);
-            update_flag_is_sticky(&mut buf, FlagValueType::Boolean, i, false).unwrap();
+            assert!((attribute & (FlagInfoBit::HasServerOverride as u8)) != 0);
+            update_flag_has_server_override(&mut buf, FlagValueType::Boolean, i, false).unwrap();
             let attribute = find_flag_attribute(&buf, FlagValueType::Boolean, i).unwrap();
-            assert!((attribute & (FlagInfoBit::IsSticky as u8)) == 0);
+            assert!((attribute & (FlagInfoBit::HasServerOverride as u8)) == 0);
         }
     }
 
     #[test]
-    // this test point locks down has override update
-    fn test_update_flag_has_override() {
+    // this test point locks down has local override update
+    fn test_update_flag_has_local_override() {
         let flag_info_list = create_test_flag_info_list();
         let mut buf = flag_info_list.into_bytes();
         for i in 0..flag_info_list.header.num_flags {
-            update_flag_has_override(&mut buf, FlagValueType::Boolean, i, true).unwrap();
+            update_flag_has_local_override(&mut buf, FlagValueType::Boolean, i, true).unwrap();
             let attribute = find_flag_attribute(&buf, FlagValueType::Boolean, i).unwrap();
-            assert!((attribute & (FlagInfoBit::HasOverride as u8)) != 0);
-            update_flag_has_override(&mut buf, FlagValueType::Boolean, i, false).unwrap();
+            assert!((attribute & (FlagInfoBit::HasLocalOverride as u8)) != 0);
+            update_flag_has_local_override(&mut buf, FlagValueType::Boolean, i, false).unwrap();
             let attribute = find_flag_attribute(&buf, FlagValueType::Boolean, i).unwrap();
-            assert!((attribute & (FlagInfoBit::HasOverride as u8)) == 0);
+            assert!((attribute & (FlagInfoBit::HasLocalOverride as u8)) == 0);
         }
     }
 }
diff --git a/tools/aconfig/aconfig_storage_write_api/src/lib.rs b/tools/aconfig/aconfig_storage_write_api/src/lib.rs
index 7148d06..bcddce1 100644
--- a/tools/aconfig/aconfig_storage_write_api/src/lib.rs
+++ b/tools/aconfig/aconfig_storage_write_api/src/lib.rs
@@ -75,39 +75,39 @@
     })
 }
 
-/// Set if flag is sticky thru mapped file and flush the change to file
+/// Set if flag is has server override thru mapped file and flush the change to file
 ///
 /// \input mapped_file: the mapped flag info file
 /// \input index: flag index
-/// \input value: updated flag sticky value
+/// \input value: updated flag has server override value
 /// \return a result of ()
 ///
-pub fn set_flag_is_sticky(
+pub fn set_flag_has_server_override(
     file: &mut MmapMut,
     flag_type: FlagValueType,
     index: u32,
     value: bool,
 ) -> Result<(), AconfigStorageError> {
-    crate::flag_info_update::update_flag_is_sticky(file, flag_type, index, value)?;
+    crate::flag_info_update::update_flag_has_server_override(file, flag_type, index, value)?;
     file.flush().map_err(|errmsg| {
         AconfigStorageError::MapFlushFail(anyhow!("fail to flush storage file: {}", errmsg))
     })
 }
 
-/// Set if flag has override thru mapped file and flush the change to file
+/// Set if flag has local override thru mapped file and flush the change to file
 ///
 /// \input mapped_file: the mapped flag info file
 /// \input index: flag index
-/// \input value: updated flag has override value
+/// \input value: updated flag has local override value
 /// \return a result of ()
 ///
-pub fn set_flag_has_override(
+pub fn set_flag_has_local_override(
     file: &mut MmapMut,
     flag_type: FlagValueType,
     index: u32,
     value: bool,
 ) -> Result<(), AconfigStorageError> {
-    crate::flag_info_update::update_flag_has_override(file, flag_type, index, value)?;
+    crate::flag_info_update::update_flag_has_local_override(file, flag_type, index, value)?;
     file.flush().map_err(|errmsg| {
         AconfigStorageError::MapFlushFail(anyhow!("fail to flush storage file: {}", errmsg))
     })
@@ -206,14 +206,14 @@
         pub error_message: String,
     }
 
-    // Flag is sticky update return for cc interlop
-    pub struct FlagIsStickyUpdateCXX {
+    // Flag has server override update return for cc interlop
+    pub struct FlagHasServerOverrideUpdateCXX {
         pub update_success: bool,
         pub error_message: String,
     }
 
-    // Flag has override update return for cc interlop
-    pub struct FlagHasOverrideUpdateCXX {
+    // Flag has local override update return for cc interlop
+    pub struct FlagHasLocalOverrideUpdateCXX {
         pub update_success: bool,
         pub error_message: String,
     }
@@ -232,19 +232,19 @@
             value: bool,
         ) -> BooleanFlagValueUpdateCXX;
 
-        pub fn update_flag_is_sticky_cxx(
+        pub fn update_flag_has_server_override_cxx(
             file: &mut [u8],
             flag_type: u16,
             offset: u32,
             value: bool,
-        ) -> FlagIsStickyUpdateCXX;
+        ) -> FlagHasServerOverrideUpdateCXX;
 
-        pub fn update_flag_has_override_cxx(
+        pub fn update_flag_has_local_override_cxx(
             file: &mut [u8],
             flag_type: u16,
             offset: u32,
             value: bool,
-        ) -> FlagHasOverrideUpdateCXX;
+        ) -> FlagHasLocalOverrideUpdateCXX;
 
         pub fn create_flag_info_cxx(
             package_map: &str,
@@ -270,53 +270,56 @@
     }
 }
 
-pub(crate) fn update_flag_is_sticky_cxx(
+pub(crate) fn update_flag_has_server_override_cxx(
     file: &mut [u8],
     flag_type: u16,
     offset: u32,
     value: bool,
-) -> ffi::FlagIsStickyUpdateCXX {
+) -> ffi::FlagHasServerOverrideUpdateCXX {
     match FlagValueType::try_from(flag_type) {
         Ok(value_type) => {
-            match crate::flag_info_update::update_flag_is_sticky(file, value_type, offset, value) {
-                Ok(()) => ffi::FlagIsStickyUpdateCXX {
+            match crate::flag_info_update::update_flag_has_server_override(
+                file, value_type, offset, value,
+            ) {
+                Ok(()) => ffi::FlagHasServerOverrideUpdateCXX {
                     update_success: true,
                     error_message: String::from(""),
                 },
-                Err(errmsg) => ffi::FlagIsStickyUpdateCXX {
+                Err(errmsg) => ffi::FlagHasServerOverrideUpdateCXX {
                     update_success: false,
                     error_message: format!("{:?}", errmsg),
                 },
             }
         }
-        Err(errmsg) => ffi::FlagIsStickyUpdateCXX {
+        Err(errmsg) => ffi::FlagHasServerOverrideUpdateCXX {
             update_success: false,
             error_message: format!("{:?}", errmsg),
         },
     }
 }
 
-pub(crate) fn update_flag_has_override_cxx(
+pub(crate) fn update_flag_has_local_override_cxx(
     file: &mut [u8],
     flag_type: u16,
     offset: u32,
     value: bool,
-) -> ffi::FlagHasOverrideUpdateCXX {
+) -> ffi::FlagHasLocalOverrideUpdateCXX {
     match FlagValueType::try_from(flag_type) {
         Ok(value_type) => {
-            match crate::flag_info_update::update_flag_has_override(file, value_type, offset, value)
-            {
-                Ok(()) => ffi::FlagHasOverrideUpdateCXX {
+            match crate::flag_info_update::update_flag_has_local_override(
+                file, value_type, offset, value,
+            ) {
+                Ok(()) => ffi::FlagHasLocalOverrideUpdateCXX {
                     update_success: true,
                     error_message: String::from(""),
                 },
-                Err(errmsg) => ffi::FlagHasOverrideUpdateCXX {
+                Err(errmsg) => ffi::FlagHasLocalOverrideUpdateCXX {
                     update_success: false,
                     error_message: format!("{:?}", errmsg),
                 },
             }
         }
-        Err(errmsg) => ffi::FlagHasOverrideUpdateCXX {
+        Err(errmsg) => ffi::FlagHasLocalOverrideUpdateCXX {
             update_success: false,
             error_message: format!("{:?}", errmsg),
         },
@@ -411,7 +414,7 @@
     }
 
     #[test]
-    fn test_set_flag_is_sticky() {
+    fn test_set_flag_has_server_override() {
         let flag_info_file = copy_to_temp_file("./tests/flag.info", false).unwrap();
         let flag_info_path = flag_info_file.path().display().to_string();
         let text_proto = format!(
@@ -442,20 +445,20 @@
             )
             .unwrap();
             for i in 0..8 {
-                set_flag_is_sticky(&mut file, FlagValueType::Boolean, i, true).unwrap();
+                set_flag_has_server_override(&mut file, FlagValueType::Boolean, i, true).unwrap();
                 let attribute =
                     get_flag_attribute_at_offset(&flag_info_path, FlagValueType::Boolean, i);
-                assert!((attribute & (FlagInfoBit::IsSticky as u8)) != 0);
-                set_flag_is_sticky(&mut file, FlagValueType::Boolean, i, false).unwrap();
+                assert!((attribute & (FlagInfoBit::HasServerOverride as u8)) != 0);
+                set_flag_has_server_override(&mut file, FlagValueType::Boolean, i, false).unwrap();
                 let attribute =
                     get_flag_attribute_at_offset(&flag_info_path, FlagValueType::Boolean, i);
-                assert!((attribute & (FlagInfoBit::IsSticky as u8)) == 0);
+                assert!((attribute & (FlagInfoBit::HasServerOverride as u8)) == 0);
             }
         }
     }
 
     #[test]
-    fn test_set_flag_has_override() {
+    fn test_set_flag_has_local_override() {
         let flag_info_file = copy_to_temp_file("./tests/flag.info", false).unwrap();
         let flag_info_path = flag_info_file.path().display().to_string();
         let text_proto = format!(
@@ -486,14 +489,14 @@
             )
             .unwrap();
             for i in 0..8 {
-                set_flag_has_override(&mut file, FlagValueType::Boolean, i, true).unwrap();
+                set_flag_has_local_override(&mut file, FlagValueType::Boolean, i, true).unwrap();
                 let attribute =
                     get_flag_attribute_at_offset(&flag_info_path, FlagValueType::Boolean, i);
-                assert!((attribute & (FlagInfoBit::HasOverride as u8)) != 0);
-                set_flag_has_override(&mut file, FlagValueType::Boolean, i, false).unwrap();
+                assert!((attribute & (FlagInfoBit::HasLocalOverride as u8)) != 0);
+                set_flag_has_local_override(&mut file, FlagValueType::Boolean, i, false).unwrap();
                 let attribute =
                     get_flag_attribute_at_offset(&flag_info_path, FlagValueType::Boolean, i);
-                assert!((attribute & (FlagInfoBit::HasOverride as u8)) == 0);
+                assert!((attribute & (FlagInfoBit::HasLocalOverride as u8)) == 0);
             }
         }
     }
diff --git a/tools/aconfig/aconfig_storage_write_api/tests/storage_write_api_test.cpp b/tools/aconfig/aconfig_storage_write_api/tests/storage_write_api_test.cpp
index 6de3327..ab5f0a7 100644
--- a/tools/aconfig/aconfig_storage_write_api/tests/storage_write_api_test.cpp
+++ b/tools/aconfig/aconfig_storage_write_api/tests/storage_write_api_test.cpp
@@ -156,15 +156,15 @@
             std::string("InvalidStorageFileOffset(Flag value offset goes beyond the end of the file.)"));
 }
 
-/// Test to lock down storage flag stickiness update api
-TEST_F(AconfigStorageTest, test_flag_is_sticky_update) {
+/// Test to lock down storage flag has server override update api
+TEST_F(AconfigStorageTest, test_flag_has_server_override_update) {
   auto mapped_file_result = private_api::get_mutable_mapped_file_impl(
       storage_record_pb, "mockup", api::StorageFileType::flag_info);
   ASSERT_TRUE(mapped_file_result.ok());
   auto mapped_file = *mapped_file_result;
 
   for (int offset = 0; offset < 8; ++offset) {
-    auto update_result = api::set_flag_is_sticky(
+    auto update_result = api::set_flag_has_server_override(
         mapped_file, api::FlagValueType::Boolean, offset, true);
     ASSERT_TRUE(update_result.ok());
     auto ro_mapped_file = api::MappedStorageFile();
@@ -173,9 +173,9 @@
     auto attribute = api::get_flag_attribute(
         ro_mapped_file, api::FlagValueType::Boolean, offset);
     ASSERT_TRUE(attribute.ok());
-    ASSERT_TRUE(*attribute & api::FlagInfoBit::IsSticky);
+    ASSERT_TRUE(*attribute & api::FlagInfoBit::HasServerOverride);
 
-    update_result = api::set_flag_is_sticky(
+    update_result = api::set_flag_has_server_override(
         mapped_file, api::FlagValueType::Boolean, offset, false);
     ASSERT_TRUE(update_result.ok());
     ro_mapped_file.file_ptr = mapped_file.file_ptr;
@@ -183,19 +183,19 @@
     attribute = api::get_flag_attribute(
         ro_mapped_file, api::FlagValueType::Boolean, offset);
     ASSERT_TRUE(attribute.ok());
-    ASSERT_FALSE(*attribute & api::FlagInfoBit::IsSticky);
+    ASSERT_FALSE(*attribute & api::FlagInfoBit::HasServerOverride);
   }
 }
 
-/// Test to lock down storage flag has override update api
-TEST_F(AconfigStorageTest, test_flag_has_override_update) {
+/// Test to lock down storage flag has local override update api
+TEST_F(AconfigStorageTest, test_flag_has_local_override_update) {
   auto mapped_file_result = private_api::get_mutable_mapped_file_impl(
       storage_record_pb, "mockup", api::StorageFileType::flag_info);
   ASSERT_TRUE(mapped_file_result.ok());
   auto mapped_file = *mapped_file_result;
 
   for (int offset = 0; offset < 8; ++offset) {
-    auto update_result = api::set_flag_has_override(
+    auto update_result = api::set_flag_has_local_override(
         mapped_file, api::FlagValueType::Boolean, offset, true);
     ASSERT_TRUE(update_result.ok());
     auto ro_mapped_file = api::MappedStorageFile();
@@ -204,9 +204,9 @@
     auto attribute = api::get_flag_attribute(
         ro_mapped_file, api::FlagValueType::Boolean, offset);
     ASSERT_TRUE(attribute.ok());
-    ASSERT_TRUE(*attribute & api::FlagInfoBit::HasOverride);
+    ASSERT_TRUE(*attribute & api::FlagInfoBit::HasLocalOverride);
 
-    update_result = api::set_flag_has_override(
+    update_result = api::set_flag_has_local_override(
         mapped_file, api::FlagValueType::Boolean, offset, false);
     ASSERT_TRUE(update_result.ok());
     ro_mapped_file.file_ptr = mapped_file.file_ptr;
@@ -214,6 +214,6 @@
     attribute = api::get_flag_attribute(
         ro_mapped_file, api::FlagValueType::Boolean, offset);
     ASSERT_TRUE(attribute.ok());
-    ASSERT_FALSE(*attribute & api::FlagInfoBit::HasOverride);
+    ASSERT_FALSE(*attribute & api::FlagInfoBit::HasLocalOverride);
   }
 }
diff --git a/tools/aconfig/aconfig_storage_write_api/tests/storage_write_api_test.rs b/tools/aconfig/aconfig_storage_write_api/tests/storage_write_api_test.rs
index 5dd36c4..a087c1a 100644
--- a/tools/aconfig/aconfig_storage_write_api/tests/storage_write_api_test.rs
+++ b/tools/aconfig/aconfig_storage_write_api/tests/storage_write_api_test.rs
@@ -5,8 +5,8 @@
     use aconfig_storage_read_api::flag_info_query::find_flag_attribute;
     use aconfig_storage_read_api::flag_value_query::find_boolean_flag_value;
     use aconfig_storage_write_api::{
-        mapped_file::get_mapped_file, set_boolean_flag_value, set_flag_has_override,
-        set_flag_is_sticky,
+        mapped_file::get_mapped_file, set_boolean_flag_value, set_flag_has_local_override,
+        set_flag_has_server_override,
     };
 
     use protobuf::Message;
@@ -90,8 +90,8 @@
     }
 
     #[test]
-    /// Test to lock down flag is sticky update api
-    fn test_set_flag_is_sticky() {
+    /// Test to lock down flag has server override update api
+    fn test_set_flag_has_server_override() {
         let flag_value_file = copy_to_temp_rw_file("./flag.val");
         let flag_info_file = copy_to_temp_rw_file("./flag.info");
         let flag_value_path = flag_value_file.path().display().to_string();
@@ -106,20 +106,20 @@
             get_mapped_file(&record_pb_path, "mockup", StorageFileType::FlagInfo).unwrap()
         };
         for i in 0..8 {
-            set_flag_is_sticky(&mut file, FlagValueType::Boolean, i, true).unwrap();
+            set_flag_has_server_override(&mut file, FlagValueType::Boolean, i, true).unwrap();
             let attribute =
                 get_flag_attribute_at_offset(&flag_info_path, FlagValueType::Boolean, i);
-            assert!((attribute & (FlagInfoBit::IsSticky as u8)) != 0);
-            set_flag_is_sticky(&mut file, FlagValueType::Boolean, i, false).unwrap();
+            assert!((attribute & (FlagInfoBit::HasServerOverride as u8)) != 0);
+            set_flag_has_server_override(&mut file, FlagValueType::Boolean, i, false).unwrap();
             let attribute =
                 get_flag_attribute_at_offset(&flag_info_path, FlagValueType::Boolean, i);
-            assert!((attribute & (FlagInfoBit::IsSticky as u8)) == 0);
+            assert!((attribute & (FlagInfoBit::HasServerOverride as u8)) == 0);
         }
     }
 
     #[test]
-    /// Test to lock down flag is sticky update api
-    fn test_set_flag_has_override() {
+    /// Test to lock down flag has local override update api
+    fn test_set_flag_has_local_override() {
         let flag_value_file = copy_to_temp_rw_file("./flag.val");
         let flag_info_file = copy_to_temp_rw_file("./flag.info");
         let flag_value_path = flag_value_file.path().display().to_string();
@@ -134,14 +134,14 @@
             get_mapped_file(&record_pb_path, "mockup", StorageFileType::FlagInfo).unwrap()
         };
         for i in 0..8 {
-            set_flag_has_override(&mut file, FlagValueType::Boolean, i, true).unwrap();
+            set_flag_has_local_override(&mut file, FlagValueType::Boolean, i, true).unwrap();
             let attribute =
                 get_flag_attribute_at_offset(&flag_info_path, FlagValueType::Boolean, i);
-            assert!((attribute & (FlagInfoBit::HasOverride as u8)) != 0);
-            set_flag_has_override(&mut file, FlagValueType::Boolean, i, false).unwrap();
+            assert!((attribute & (FlagInfoBit::HasLocalOverride as u8)) != 0);
+            set_flag_has_local_override(&mut file, FlagValueType::Boolean, i, false).unwrap();
             let attribute =
                 get_flag_attribute_at_offset(&flag_info_path, FlagValueType::Boolean, i);
-            assert!((attribute & (FlagInfoBit::HasOverride as u8)) == 0);
+            assert!((attribute & (FlagInfoBit::HasLocalOverride as u8)) == 0);
         }
     }
 }
diff --git a/tools/check-flagged-apis/check-flagged-apis.sh b/tools/check-flagged-apis/check-flagged-apis.sh
old mode 100644
new mode 100755
index ae671d1..cd37a2d
--- a/tools/check-flagged-apis/check-flagged-apis.sh
+++ b/tools/check-flagged-apis/check-flagged-apis.sh
@@ -1,3 +1,5 @@
+#!/bin/bash
+
 # Copyright (C) 2024 The Android Open Source Project
 #
 # Licensed under the Apache License, Version 2.0 (the "License");
@@ -15,6 +17,13 @@
 # Run check-flagged-apis for public APIs and the three @SystemApi flavours
 # Usage: lunch <your-target> && source <this script>
 
+source $(cd $(dirname $BASH_SOURCE) &> /dev/null && pwd)/../../shell_utils.sh
+require_top
+
+function m() {
+    $(gettop)/build/soong/soong_ui.bash --build-mode --all-modules --dir="$(pwd)" "$@"
+}
+
 function build() {
     m sdk dist && m \
         check-flagged-apis \
diff --git a/tools/finalization/finalize-aidl-vndk-sdk-resources.sh b/tools/finalization/finalize-aidl-vndk-sdk-resources.sh
index 671b036..75379ff 100755
--- a/tools/finalization/finalize-aidl-vndk-sdk-resources.sh
+++ b/tools/finalization/finalize-aidl-vndk-sdk-resources.sh
@@ -133,10 +133,10 @@
     sed -i -e "s/sepolicy_major_vers := .*/sepolicy_major_vers := ${FINAL_PLATFORM_SDK_VERSION}/g" "$top/build/make/core/config.mk"
     cp "$top/build/make/target/product/gsi/current.txt" "$top/build/make/target/product/gsi/$FINAL_PLATFORM_SDK_VERSION.txt"
 
-    # build/bazel
+    # build/soong
     local codename_version="\"${FINAL_PLATFORM_CODENAME}\": ${FINAL_PLATFORM_SDK_VERSION}"
-    if ! grep -q "$codename_version" "$top/build/bazel/rules/common/api_constants.bzl" ; then
-        sed -i -e "/:.*$((${FINAL_PLATFORM_SDK_VERSION}-1)),/a \\    $codename_version," "$top/build/bazel/rules/common/api_constants.bzl"
+    if ! grep -q "$codename_version" "$top/build/soong/android/api_levels.go" ; then
+        sed -i -e "/:.*$((${FINAL_PLATFORM_SDK_VERSION}-1)),/a \\\t\t$codename_version," "$top/build/soong/android/api_levels.go"
     fi
 
     # cts
diff --git a/tools/ide_query/ide_query.go b/tools/ide_query/ide_query.go
index 50264fd..de84fbe 100644
--- a/tools/ide_query/ide_query.go
+++ b/tools/ide_query/ide_query.go
@@ -304,6 +304,7 @@
 	args := []string{
 		"--make-mode",
 		"ANDROID_BUILD_ENVIRONMENT_CONFIG=googler-cog",
+		"SOONG_GEN_COMPDB=1",
 		"TARGET_PRODUCT=" + env.LunchTarget.Product,
 		"TARGET_RELEASE=" + env.LunchTarget.Release,
 		"TARGET_BUILD_VARIANT=" + env.LunchTarget.Variant,
diff --git a/tools/whichgit b/tools/whichgit
index b0bf2e4..8cf84f5 100755
--- a/tools/whichgit
+++ b/tools/whichgit
@@ -50,7 +50,7 @@
         referenced_dirs.add(d)
         prev_dir = d
         break
-  return [d[0:-1] for d in referenced_dirs]
+  return referenced_dirs
 
 
 def main(argv):
@@ -63,9 +63,11 @@
                   help="The TARGET_BUILD_VARIANTS to check. If not provided just uses whatever has"
                         + " already been built, or eng if --products is supplied")
   ap.add_argument("--modules", nargs="*",
-                  help="The build modules to check, or droid it not supplied")
+                  help="The build modules to check, or droid if not supplied")
   ap.add_argument("--why", nargs="*",
                   help="Also print the input files used in these projects, or \"*\" for all")
+  ap.add_argument("--unused", help="List the unused git projects for the given modules rather than"
+                        + "the used ones. Ignores --why", action="store_true")
   args = ap.parse_args(argv[1:])
 
   modules = args.modules if args.modules else ["droid"]
@@ -92,15 +94,21 @@
 
   sources = sorted(sources)
 
-  # Print the list of git directories that has one or more of the sources in it
-  for project in sorted(get_referenced_projects(get_git_dirs(), sources)):
-    print(project)
-    if args.why:
-      if "*" in args.why or project in args.why:
-        prefix = project + "/"
-        for f in sources:
-          if f.startswith(prefix):
-            print("  " + f)
+  if args.unused:
+    # Print the list of git directories that don't contain sources
+    used_git_dirs = set(get_git_dirs())
+    for project in sorted(used_git_dirs.difference(set(get_referenced_projects(used_git_dirs, sources)))):
+      print(project[0:-1])
+  else:
+    # Print the list of git directories that has one or more of the sources in it
+    for project in sorted(get_referenced_projects(get_git_dirs(), sources)):
+      print(project[0:-1])
+      if args.why:
+        if "*" in args.why or project[0:-1] in args.why:
+          prefix = project
+          for f in sources:
+            if f.startswith(prefix):
+              print("  " + f)
 
 
 if __name__ == "__main__":