Files
android_bootable_recovery/crypto/vold_decrypt/vold_decrypt.h
nijel8 2c821a8c0a vold_decrypt: Add android 9.0 support
* build modified vdc_pie binary with 'checkpw' command support
  if building with Android 9.0 platform. That command and others
  we don't care about, are removed from Pie vdc. Our vdc_pie will
  run if system sdk version is > 27, otherwise system vdc is used.
  Code adapted from Android 9.0 system/vold/vdc.

* include prebuilt vdc_pie(arm, arm64) binary if building with lower
  than Android 9.0 platform - vdc_pie cannot be build from source
  with those platforms without additional imports from Android 9.0

* skip vdc "getpwtype" command for Pie - vds communicates with vold
  directly, no need for connection retries first

* add /system/bin/servicemanager to required services

* mount per-devive additional partitions needed for decryption
  listed with device BoardConfig.mk TW_CRYPTO_SYSTEM_VOLD_MOUNT
  flag like(space separated):
  TW_CRYPTO_SYSTEM_VOLD_MOUNT := vendor cust odm

* add function to backup crypto footer before running vdc commands
  and restore it after - on Xiaomi Mi Max 3 both Oreo and Pie stock
  roms vold alters cripto footer when decrypting data in recovery
  which causes system to ask for crypto password at next reboot
  although password stays unchanged. Crypto footer backup/restore
  added as workaround for systems whit ro.build.version.sdk > 25.
  Also to preserve crypto footer integrity decryption attempts are
  skipped if footer backup fails to ensure no data loss.
  Code adapted from
  https://gerrit.omnirom.org/#/c/android_bootable_recovery/+/31206/

Change-Id: I0a383f3843578fa55595cfea3b7c9c4431646a1a
2019-02-01 21:36:23 -05:00

44 lines
1.3 KiB
C++

/*
Copyright 2017 TeamWin
This file is part of TWRP/TeamWin Recovery Project.
TWRP is free software: you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation, either version 3 of the License, or
(at your option) any later version.
TWRP is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with TWRP. If not, see <http://www.gnu.org/licenses/>.
*/
#ifndef _VOLD_DECRYPT_H
#define _VOLD_DECRYPT_H
#include <string>
// -_-
enum {
VD_SUCCESS = 0,
VD_ERR_DECRYPTION_FAILED = -1,
VD_ERR_UNABLE_TO_MOUNT_SYSTEM = -2,
VD_ERR_MISSING_VOLD = -3,
VD_ERR_MISSING_VDC = -4,
VD_ERR_VDC_FAILED_TO_CONNECT = -5,
VD_ERR_VOLD_FAILED_TO_START = -6,
VD_ERR_VOLD_UNEXPECTED_RESPONSE = -7,
VD_ERR_VOLD_OPERATION_TIMEDOUT = -8,
VD_ERR_FORK_EXECL_ERROR = -9,
VD_ERR_PASSWORD_EMPTY = -10,
VD_ERR_UNABLE_TO_MOUNT_EXTRA = -11,
};
int vold_decrypt(const std::string& Password);
#endif // _VOLD_DECRYPT_H