Put auto-increment for IMEI2 behind a feature
Make it possible to disable the IMEI2 = (IMEI+1) fallback behaviour.
Equivalent to the `#ifndef KEYMASTER_NO_AUTO_SECOND_IMEI` in the C++
code.
Bug: 244732345
Test: VtsAidlKeyMintTargetTest
Change-Id: I89de08d1d51bedda68a10a90b975ff04178161ea
diff --git a/rules.mk b/rules.mk
index 09bff8f..ef05620 100644
--- a/rules.mk
+++ b/rules.mk
@@ -47,6 +47,7 @@
MODULE_RUSTFLAGS += \
--cfg 'feature="soft_attestation_fallback"' \
+ --cfg 'feature="auto_second_imei"' \
MODULE_RUST_TESTS := true
diff --git a/secure_storage_manager.rs b/secure_storage_manager.rs
index 55d094d..443ba1a 100644
--- a/secure_storage_manager.rs
+++ b/secure_storage_manager.rs
@@ -259,13 +259,15 @@
let manufacturer = attestation_ids_pb.take_manufacturer();
let model = attestation_ids_pb.take_model();
- // Pixel devices are provisioned with two consecutive IMEI values, in earlier devices only the
- // first one was stored. Use the storage imei if it exists, otherwise generate it based on the
- // first imei.
let imei2 = if attestation_ids_pb.has_second_imei() {
+ // A second IMEI has been explicitly provisioned, so use that.
attestation_ids_pb.take_second_imei()
- } else {
+ } else if cfg!(feature = "auto_second_imei") {
+ // No second IMEI has been explicitly provisioned, but dual-SIM devices typically ship with
+ // two sequential IMEIs, so treat (IMEI+1) as the second IMEI.
kmr_common::tag::increment_imei(&imei)
+ } else {
+ Vec::new()
};
Ok(AttestationIdInfo { brand, device, product, serial, imei, imei2, meid, manufacturer, model })