From cbc1bdba591589f37a0cad306ddafe4b3d7ad72a Mon Sep 17 00:00:00 2001 From: Howard Chen Date: Tue, 14 Sep 2021 14:40:59 +0800 Subject: [PATCH] Make the deleteAllKey feature aware of the DSU mode Currently, the vold detects the factory reset by checking the metadata encryption key. This logic is only valid when the device is not in DSU mode. Bug: 199222795 Test: run DSU installation on a Pixel device Change-Id: Ib40bd44d2ef7c872eba177c9ccfefac8934a49e6 --- MetadataCrypt.cpp | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/MetadataCrypt.cpp b/MetadataCrypt.cpp index 277a908..2f11c8b 100644 --- a/MetadataCrypt.cpp +++ b/MetadataCrypt.cpp @@ -113,7 +113,9 @@ static bool read_key(const std::string& metadata_key_dir, const KeyGeneration& g auto dir = metadata_key_dir + "/key"; LOG(DEBUG) << "metadata_key_dir/key: " << dir; if (!MkdirsSync(dir, 0700)) return false; - if (!pathExists(dir)) { + auto in_dsu = android::base::GetBoolProperty("ro.gsid.image_running", false); + // !pathExists(dir) does not imply there's a factory reset when in DSU mode. + if (!pathExists(dir) && !in_dsu) { auto delete_all = android::base::GetBoolProperty( "ro.crypto.metadata_init_delete_all_keys.enabled", false); if (delete_all) {