Merge "aconfig: add missing string header to template" into main
diff --git a/core/version_util.mk b/core/version_util.mk
index 4b069db..0cc3442 100644
--- a/core/version_util.mk
+++ b/core/version_util.mk
@@ -92,11 +92,21 @@
# this variable also includes future codenames. For example, while AOSP is still
# merging into U, but V development has started, ALL_CODENAMES will only be U,
# but ALL_PREVIEW_CODENAMES will be U and V.
+#
+# REL is filtered out of the list. The codename of the current release is
+# replaced by "REL" when the build is configured as a release rather than a
+# preview. For example, PLATFORM_VERSION_CODENAME.UpsideDownCake will be "REL"
+# rather than UpsideDownCake in a -next target when the upcoming release is
+# UpsideDownCake. "REL" is a codename (and android.os.Build relies on this:
+# https://cs.android.com/android/platform/superproject/main/+/main:frameworks/base/core/java/android/os/Build.java;l=484-487;drc=316e3d16c9f34212f3beace7695289651d15a071),
+# so it should be in PLATFORM_VERSION_ALL_CODENAMES, but it definitely is not a
+# preview codename.
PLATFORM_VERSION_ALL_PREVIEW_CODENAMES :=
$(foreach version,$(ALL_VERSIONS),\
$(eval _codename := $(PLATFORM_VERSION_CODENAME.$(version)))\
- $(if $(filter $(_codename),$(PLATFORM_VERSION_ALL_PREVIEW_CODENAMES)),,\
- $(eval PLATFORM_VERSION_ALL_PREVIEW_CODENAMES += $(_codename))))
+ $(if $(filter REL,$(_codename)),,\
+ $(if $(filter $(_codename),$(PLATFORM_VERSION_ALL_PREVIEW_CODENAMES)),,\
+ $(eval PLATFORM_VERSION_ALL_PREVIEW_CODENAMES += $(_codename)))))
# And convert from space separated to comma separated.
PLATFORM_VERSION_ALL_CODENAMES := \
diff --git a/target/product/AndroidProducts.mk b/target/product/AndroidProducts.mk
index 473a275..8787c59 100644
--- a/target/product/AndroidProducts.mk
+++ b/target/product/AndroidProducts.mk
@@ -66,14 +66,11 @@
$(LOCAL_DIR)/mainline_system_x86_64.mk \
$(LOCAL_DIR)/mainline_system_x86_arm.mk \
$(LOCAL_DIR)/ndk.mk \
- $(LOCAL_DIR)/sdk_arm64.mk \
$(LOCAL_DIR)/sdk.mk \
$(LOCAL_DIR)/sdk_phone_arm64.mk \
$(LOCAL_DIR)/sdk_phone_armv7.mk \
$(LOCAL_DIR)/sdk_phone_x86_64.mk \
$(LOCAL_DIR)/sdk_phone_x86.mk \
- $(LOCAL_DIR)/sdk_x86_64.mk \
- $(LOCAL_DIR)/sdk_x86.mk \
endif
diff --git a/target/product/sdk.mk b/target/product/sdk.mk
index e4cb7ff..fff8d4c 100644
--- a/target/product/sdk.mk
+++ b/target/product/sdk.mk
@@ -14,8 +14,19 @@
# limitations under the License.
#
-# Don't modify this file - It's just an alias!
+# This is a simple product that uses configures the minimum amount
+# needed to build the SDK (without the emulator).
-$(call inherit-product, $(SRC_TARGET_DIR)/product/sdk_x86.mk)
+# In order to build the bootclasspath sources, the bootclasspath needs to
+# be setup via default_art_config.mk. The sources only really make sense
+# together with a device (e.g. the emulator). So if the SDK sources change
+# to be built with the device, this could be removed.
+$(call inherit-product, $(SRC_TARGET_DIR)/product/default_art_config.mk)
+
+$(call inherit-product, $(SRC_TARGET_DIR)/product/languages_default.mk)
PRODUCT_NAME := sdk
+PRODUCT_BRAND := Android
+PRODUCT_DEVICE := mainline_x86
+
+PRODUCT_NEXT_RELEASE_HIDE_FLAGGED_API := true
diff --git a/target/product/sdk_arm64.mk b/target/product/sdk_arm64.mk
deleted file mode 100644
index 3eb9304..0000000
--- a/target/product/sdk_arm64.mk
+++ /dev/null
@@ -1,26 +0,0 @@
-#
-# Copyright (C) 2014 The Android Open Source Project
-#
-# Licensed under the Apache License, Version 2.0 (the "License");
-# you may not use this file except in compliance with the License.
-# You may obtain a copy of the License at
-#
-# http://www.apache.org/licenses/LICENSE-2.0
-#
-# Unless required by applicable law or agreed to in writing, software
-# distributed under the License is distributed on an "AS IS" BASIS,
-# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
-# See the License for the specific language governing permissions and
-# limitations under the License.
-#
-
-$(call inherit-product, $(SRC_TARGET_DIR)/product/languages_default.mk)
-
-TARGET_SUPPORTS_32_BIT_APPS := true
-TARGET_SUPPORTS_64_BIT_APPS := true
-
-PRODUCT_NAME := sdk_arm64
-PRODUCT_BRAND := Android
-PRODUCT_DEVICE := mainline_arm64
-
-PRODUCT_NEXT_RELEASE_HIDE_FLAGGED_API := true
diff --git a/target/product/sdk_x86.mk b/target/product/sdk_x86.mk
deleted file mode 100644
index a6e3bcd..0000000
--- a/target/product/sdk_x86.mk
+++ /dev/null
@@ -1,26 +0,0 @@
-#
-# Copyright (C) 2014 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.
-#
-
-# This is a simple product that uses configures the minimum amount
-# needed to build the SDK (without the emulator).
-
-$(call inherit-product, $(SRC_TARGET_DIR)/product/languages_default.mk)
-
-PRODUCT_NAME := sdk_x86_64
-PRODUCT_BRAND := Android
-PRODUCT_DEVICE := mainline_x86
-
-PRODUCT_NEXT_RELEASE_HIDE_FLAGGED_API := true
diff --git a/target/product/sdk_x86_64.mk b/target/product/sdk_x86_64.mk
deleted file mode 100644
index af73007..0000000
--- a/target/product/sdk_x86_64.mk
+++ /dev/null
@@ -1,29 +0,0 @@
-#
-# Copyright (C) 2014 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.
-#
-
-# This is a simple product that uses configures the minimum amount
-# needed to build the SDK (without the emulator).
-
-$(call inherit-product, $(SRC_TARGET_DIR)/product/languages_default.mk)
-
-TARGET_SUPPORTS_32_BIT_APPS := true
-TARGET_SUPPORTS_64_BIT_APPS := true
-
-PRODUCT_NAME := sdk_x86_64
-PRODUCT_BRAND := Android
-PRODUCT_DEVICE := mainline_x86_64
-
-PRODUCT_NEXT_RELEASE_HIDE_FLAGGED_API := true
diff --git a/tools/aconfig/printflags/src/main.rs b/tools/aconfig/printflags/src/main.rs
index 88fdea9..4110317 100644
--- a/tools/aconfig/printflags/src/main.rs
+++ b/tools/aconfig/printflags/src/main.rs
@@ -18,7 +18,7 @@
use aconfig_protos::aconfig::Flag_state as State;
use aconfig_protos::aconfig::Parsed_flags as ProtoParsedFlags;
-use anyhow::{bail, Result};
+use anyhow::{bail, Context, Result};
use regex::Regex;
use std::collections::HashMap;
use std::process::Command;
@@ -39,6 +39,19 @@
flags
}
+fn xxd(bytes: &[u8]) -> String {
+ let n = 8.min(bytes.len());
+ let mut v = Vec::with_capacity(n);
+ for byte in bytes.iter().take(n) {
+ v.push(format!("{:02x}", byte));
+ }
+ let trailer = match bytes.len() {
+ 0..=8 => "",
+ _ => " ..",
+ };
+ format!("[{}{}]", v.join(" "), trailer)
+}
+
fn main() -> Result<()> {
// read device_config
let output = Command::new("/system/bin/device_config").arg("list").output()?;
@@ -60,7 +73,10 @@
eprintln!("warning: failed to read {}", path);
continue;
};
- let parsed_flags: ProtoParsedFlags = protobuf::Message::parse_from_bytes(&bytes)?;
+ let parsed_flags: ProtoParsedFlags = protobuf::Message::parse_from_bytes(&bytes)
+ .with_context(|| {
+ format!("failed to parse {} ({}, {} byte(s))", path, xxd(&bytes), bytes.len())
+ })?;
for flag in parsed_flags.parsed_flag {
let key = format!("{}/{}.{}", flag.namespace(), flag.package(), flag.name());
let value = format!("{:?} + {:?} ({})", flag.permission(), flag.state(), partition);
@@ -85,7 +101,7 @@
use super::*;
#[test]
- fn test_foo() {
+ fn test_parse_device_config() {
let input = r#"
namespace_one/com.foo.bar.flag_one=true
namespace_one/com.foo.bar.flag_two=false
@@ -107,4 +123,16 @@
let actual = parse_device_config(input);
assert_eq!(expected, actual);
}
+
+ #[test]
+ fn test_xxd() {
+ let input = [0x0, 0x1, 0x2, 0x3, 0x4, 0x5, 0x6, 0x7, 0x8, 0x9];
+ assert_eq!("[]", &xxd(&input[0..0]));
+ assert_eq!("[00]", &xxd(&input[0..1]));
+ assert_eq!("[00 01]", &xxd(&input[0..2]));
+ assert_eq!("[00 01 02 03 04 05 06]", &xxd(&input[0..7]));
+ assert_eq!("[00 01 02 03 04 05 06 07]", &xxd(&input[0..8]));
+ assert_eq!("[00 01 02 03 04 05 06 07 ..]", &xxd(&input[0..9]));
+ assert_eq!("[00 01 02 03 04 05 06 07 ..]", &xxd(&input));
+ }
}
diff --git a/tools/aconfig/src/codegen_java.rs b/tools/aconfig/src/codegen_java.rs
index c4fc405..43c2ecf 100644
--- a/tools/aconfig/src/codegen_java.rs
+++ b/tools/aconfig/src/codegen_java.rs
@@ -118,21 +118,30 @@
const EXPECTED_FEATUREFLAGS_COMMON_CONTENT: &str = r#"
package com.android.aconfig.test;
+ // TODO(b/303773055): Remove the annotation after access issue is resolved.
+ import android.compat.annotation.UnsupportedAppUsage;
/** @hide */
public interface FeatureFlags {
@com.android.aconfig.annotations.AssumeFalseForR8
+ @UnsupportedAppUsage
boolean disabledRo();
+ @UnsupportedAppUsage
boolean disabledRw();
@com.android.aconfig.annotations.AssumeTrueForR8
+ @UnsupportedAppUsage
boolean enabledFixedRo();
@com.android.aconfig.annotations.AssumeTrueForR8
+ @UnsupportedAppUsage
boolean enabledRo();
+ @UnsupportedAppUsage
boolean enabledRw();
}
"#;
const EXPECTED_FLAG_COMMON_CONTENT: &str = r#"
package com.android.aconfig.test;
+ // TODO(b/303773055): Remove the annotation after access issue is resolved.
+ import android.compat.annotation.UnsupportedAppUsage;
/** @hide */
public final class Flags {
/** @hide */
@@ -147,20 +156,25 @@
public static final String FLAG_ENABLED_RW = "com.android.aconfig.test.enabled_rw";
@com.android.aconfig.annotations.AssumeFalseForR8
+ @UnsupportedAppUsage
public static boolean disabledRo() {
return FEATURE_FLAGS.disabledRo();
}
+ @UnsupportedAppUsage
public static boolean disabledRw() {
return FEATURE_FLAGS.disabledRw();
}
@com.android.aconfig.annotations.AssumeTrueForR8
+ @UnsupportedAppUsage
public static boolean enabledFixedRo() {
return FEATURE_FLAGS.enabledFixedRo();
}
@com.android.aconfig.annotations.AssumeTrueForR8
+ @UnsupportedAppUsage
public static boolean enabledRo() {
return FEATURE_FLAGS.enabledRo();
}
+ @UnsupportedAppUsage
public static boolean enabledRw() {
return FEATURE_FLAGS.enabledRw();
}
@@ -168,6 +182,8 @@
const EXPECTED_FAKEFEATUREFLAGSIMPL_CONTENT: &str = r#"
package com.android.aconfig.test;
+ // TODO(b/303773055): Remove the annotation after access issue is resolved.
+ import android.compat.annotation.UnsupportedAppUsage;
import java.util.HashMap;
import java.util.Map;
/** @hide */
@@ -176,22 +192,27 @@
resetAll();
}
@Override
+ @UnsupportedAppUsage
public boolean disabledRo() {
return getValue(Flags.FLAG_DISABLED_RO);
}
@Override
+ @UnsupportedAppUsage
public boolean disabledRw() {
return getValue(Flags.FLAG_DISABLED_RW);
}
@Override
+ @UnsupportedAppUsage
public boolean enabledFixedRo() {
return getValue(Flags.FLAG_ENABLED_FIXED_RO);
}
@Override
+ @UnsupportedAppUsage
public boolean enabledRo() {
return getValue(Flags.FLAG_ENABLED_RO);
}
@Override
+ @UnsupportedAppUsage
public boolean enabledRw() {
return getValue(Flags.FLAG_ENABLED_RW);
}
@@ -241,14 +262,18 @@
let expect_featureflagsimpl_content = r#"
package com.android.aconfig.test;
+ // TODO(b/303773055): Remove the annotation after access issue is resolved.
+ import android.compat.annotation.UnsupportedAppUsage;
import android.provider.DeviceConfig;
/** @hide */
public final class FeatureFlagsImpl implements FeatureFlags {
@Override
+ @UnsupportedAppUsage
public boolean disabledRo() {
return false;
}
@Override
+ @UnsupportedAppUsage
public boolean disabledRw() {
return getValue(
"aconfig_test",
@@ -257,14 +282,17 @@
);
}
@Override
+ @UnsupportedAppUsage
public boolean enabledFixedRo() {
return true;
}
@Override
+ @UnsupportedAppUsage
public boolean enabledRo() {
return true;
}
@Override
+ @UnsupportedAppUsage
public boolean enabledRw() {
return getValue(
"aconfig_test",
@@ -346,29 +374,36 @@
"#;
let expect_featureflagsimpl_content = r#"
package com.android.aconfig.test;
+ // TODO(b/303773055): Remove the annotation after access issue is resolved.
+ import android.compat.annotation.UnsupportedAppUsage;
/** @hide */
public final class FeatureFlagsImpl implements FeatureFlags {
@Override
+ @UnsupportedAppUsage
public boolean disabledRo() {
throw new UnsupportedOperationException(
"Method is not implemented.");
}
@Override
+ @UnsupportedAppUsage
public boolean disabledRw() {
throw new UnsupportedOperationException(
"Method is not implemented.");
}
@Override
+ @UnsupportedAppUsage
public boolean enabledFixedRo() {
throw new UnsupportedOperationException(
"Method is not implemented.");
}
@Override
+ @UnsupportedAppUsage
public boolean enabledRo() {
throw new UnsupportedOperationException(
"Method is not implemented.");
}
@Override
+ @UnsupportedAppUsage
public boolean enabledRw() {
throw new UnsupportedOperationException(
"Method is not implemented.");
diff --git a/tools/aconfig/templates/FakeFeatureFlagsImpl.java.template b/tools/aconfig/templates/FakeFeatureFlagsImpl.java.template
index d2cea95..72a896f 100644
--- a/tools/aconfig/templates/FakeFeatureFlagsImpl.java.template
+++ b/tools/aconfig/templates/FakeFeatureFlagsImpl.java.template
@@ -1,4 +1,6 @@
package {package_name};
+// TODO(b/303773055): Remove the annotation after access issue is resolved.
+import android.compat.annotation.UnsupportedAppUsage;
import java.util.HashMap;
import java.util.Map;
@@ -11,6 +13,7 @@
{{ for item in class_elements}}
@Override
+ @UnsupportedAppUsage
public boolean {item.method_name}() \{
return getValue(Flags.FLAG_{item.flag_name_constant_suffix});
}
diff --git a/tools/aconfig/templates/FeatureFlags.java.template b/tools/aconfig/templates/FeatureFlags.java.template
index 9350d60..02305e6 100644
--- a/tools/aconfig/templates/FeatureFlags.java.template
+++ b/tools/aconfig/templates/FeatureFlags.java.template
@@ -1,4 +1,6 @@
package {package_name};
+// TODO(b/303773055): Remove the annotation after access issue is resolved.
+import android.compat.annotation.UnsupportedAppUsage;
/** @hide */
public interface FeatureFlags \{
@@ -10,6 +12,7 @@
@com.android.aconfig.annotations.AssumeFalseForR8
{{ -endif- }}
{{ endif }}
+ @UnsupportedAppUsage
boolean {item.method_name}();
{{ endfor }}
}
diff --git a/tools/aconfig/templates/FeatureFlagsImpl.java.template b/tools/aconfig/templates/FeatureFlagsImpl.java.template
index 3913fa4..1620dfe 100644
--- a/tools/aconfig/templates/FeatureFlagsImpl.java.template
+++ b/tools/aconfig/templates/FeatureFlagsImpl.java.template
@@ -1,4 +1,6 @@
package {package_name};
+// TODO(b/303773055): Remove the annotation after access issue is resolved.
+import android.compat.annotation.UnsupportedAppUsage;
{{ if not is_test_mode }}
{{ if is_read_write- }}
import android.provider.DeviceConfig;
@@ -7,6 +9,7 @@
public final class FeatureFlagsImpl implements FeatureFlags \{
{{ for item in class_elements}}
@Override
+ @UnsupportedAppUsage
public boolean {item.method_name}() \{
{{ -if item.is_read_write }}
return getValue(
@@ -49,6 +52,7 @@
public final class FeatureFlagsImpl implements FeatureFlags \{
{{ for item in class_elements}}
@Override
+ @UnsupportedAppUsage
public boolean {item.method_name}() \{
throw new UnsupportedOperationException(
"Method is not implemented.");
diff --git a/tools/aconfig/templates/Flags.java.template b/tools/aconfig/templates/Flags.java.template
index 39024a8..66c4c5a 100644
--- a/tools/aconfig/templates/Flags.java.template
+++ b/tools/aconfig/templates/Flags.java.template
@@ -1,5 +1,8 @@
package {package_name};
+// TODO(b/303773055): Remove the annotation after access issue is resolved.
+import android.compat.annotation.UnsupportedAppUsage;
+
/** @hide */
public final class Flags \{
{{- for item in class_elements}}
@@ -14,6 +17,7 @@
@com.android.aconfig.annotations.AssumeFalseForR8
{{ -endif- }}
{{ endif }}
+ @UnsupportedAppUsage
public static boolean {item.method_name}() \{
return FEATURE_FLAGS.{item.method_name}();
}
diff --git a/tools/releasetools/ota_from_target_files.py b/tools/releasetools/ota_from_target_files.py
index d4420c9..7be9876 100755
--- a/tools/releasetools/ota_from_target_files.py
+++ b/tools/releasetools/ota_from_target_files.py
@@ -827,6 +827,15 @@
return ExtractTargetFiles(target_file)
+def ValidateCompressinParam(target_info):
+ vabc_compression_param = OPTIONS.vabc_compression_param
+ if vabc_compression_param:
+ minimum_api_level_required = VABC_COMPRESSION_PARAM_SUPPORT[vabc_compression_param]
+ if target_info.vendor_api_level < minimum_api_level_required:
+ raise ValueError("Specified VABC compression param {} is only supported for API level >= {}, device is on API level {}".format(
+ vabc_compression_param, minimum_api_level_required, target_info.vendor_api_level))
+
+
def GenerateAbOtaPackage(target_file, output_file, source_file=None):
"""Generates an Android OTA package that has A/B update payload."""
# If input target_files are directories, create a copy so that we can modify
@@ -834,6 +843,8 @@
target_info = common.BuildInfo(OPTIONS.info_dict, OPTIONS.oem_dicts)
if OPTIONS.disable_vabc and target_info.is_release_key:
raise ValueError("Disabling VABC on release-key builds is not supported.")
+ ValidateCompressinParam(target_info)
+ vabc_compression_param = target_info.vabc_compression_param
target_file = ExtractOrCopyTargetFiles(target_file)
if source_file is not None:
@@ -862,10 +873,11 @@
if not source_info.is_vabc or not target_info.is_vabc:
logger.info("Either source or target does not support VABC, disabling.")
OPTIONS.disable_vabc = True
- if source_info.vabc_compression_param != target_info.vabc_compression_param:
+ if OPTIONS.vabc_compression_param is None and \
+ source_info.vabc_compression_param != target_info.vabc_compression_param:
logger.info("Source build and target build use different compression methods {} vs {}, default to source builds parameter {}".format(
source_info.vabc_compression_param, target_info.vabc_compression_param, source_info.vabc_compression_param))
- OPTIONS.vabc_compression_param = source_info.vabc_compression_param
+ vabc_compression_param = source_info.vabc_compression_param
# Virtual AB Compression was introduced in Androd S.
# Later, we backported VABC to Android R. But verity support was not
@@ -879,9 +891,9 @@
assert "ab_partitions" in OPTIONS.info_dict, \
"META/ab_partitions.txt is required for ab_update."
source_info = None
- if target_info.vabc_compression_param:
+ if OPTIONS.vabc_compression_param is None and vabc_compression_param:
minimum_api_level_required = VABC_COMPRESSION_PARAM_SUPPORT[
- target_info.vabc_compression_param]
+ vabc_compression_param]
if target_info.vendor_api_level < minimum_api_level_required:
logger.warning(
"This full OTA is configured to use VABC compression algorithm"
@@ -891,10 +903,10 @@
" served to a device running old build, OTA might fail due to "
"unsupported compression parameter. For safety, gz is used because "
"it's supported since day 1.".format(
- target_info.vabc_compression_param,
+ vabc_compression_param,
minimum_api_level_required,
target_info.vendor_api_level))
- OPTIONS.vabc_compression_param = "gz"
+ vabc_compression_param = "gz"
if OPTIONS.partial == []:
logger.info(
@@ -950,6 +962,9 @@
logger.error("VABC XOR not supported on this vendor, disabling")
OPTIONS.enable_vabc_xor = False
+ if OPTIONS.vabc_compression_param:
+ vabc_compression_param = OPTIONS.vabc_compression_param
+
additional_args = []
# Prepare custom images.
@@ -964,9 +979,9 @@
elif OPTIONS.partial:
target_file = GetTargetFilesZipForPartialUpdates(target_file,
OPTIONS.partial)
- if OPTIONS.vabc_compression_param:
+ if vabc_compression_param != target_info.vabc_compression_param:
target_file = GetTargetFilesZipForCustomVABCCompression(
- target_file, OPTIONS.vabc_compression_param)
+ target_file, vabc_compression_param)
if OPTIONS.skip_postinstall:
target_file = GetTargetFilesZipWithoutPostinstallConfig(target_file)
# Target_file may have been modified, reparse ab_partitions