init: do not load persistent properties from temporary /data

With full disk encryption, a temporary /data partition is mounted to
start a minimum subset of the frameworks.  Later, once /data can be
decrypted it is mounted again.  load_persist_props is called both when
the temporary /data partition is mounted and again after the real
/data is mounted; this is a mistake.

This change checks to see if we're a FDE device and if so, returns the
first time load_persist_props is called.

Test: boot bullhead (FDE) with and without boot pin and check that
      persistent properties are loaded
Test: boot sailfish (FBE) and check that persistent properties are loaded
Change-Id: I6ed725072bdb27d80bfa6575d0a4876b08c6a4bc
This commit is contained in:
Tom Cherry 2017-08-24 14:01:25 -07:00
parent 2732a7e023
commit 9951b792b1
1 changed files with 11 additions and 0 deletions

View File

@ -690,6 +690,17 @@ static void load_override_properties() {
* has mounted /data.
*/
void load_persist_props(void) {
// Devices with FDE have load_persist_props called twice; the first time when the temporary
// /data partition is mounted and then again once /data is truly mounted. We do not want to
// read persistent properties from the temporary /data partition or mark persistent properties
// as having been loaded during the first call, so we return in that case.
std::string crypto_state = android::base::GetProperty("ro.crypto.state", "");
std::string crypto_type = android::base::GetProperty("ro.crypto.type", "");
if (crypto_state == "encrypted" && crypto_type == "block") {
static size_t num_calls = 0;
if (++num_calls == 1) return;
}
load_override_properties();
/* Read persistent properties after all default values have been loaded. */
load_persistent_properties();