Merge "Don't show UI on default encryption" into mnc-dr-dev
diff --git a/Disk.cpp b/Disk.cpp
index 1e76bee..d5f3e5d 100644
--- a/Disk.cpp
+++ b/Disk.cpp
@@ -340,10 +340,24 @@
}
status_t Disk::partitionPublic() {
+ int res;
+
// TODO: improve this code
destroyAllVolumes();
mJustPartitioned = true;
+ // First nuke any existing partition table
+ std::vector<std::string> cmd;
+ cmd.push_back(kSgdiskPath);
+ cmd.push_back("--zap-all");
+ cmd.push_back(mDevPath);
+
+ // Zap sometimes returns an error when it actually succeeded, so
+ // just log as warning and keep rolling forward.
+ if ((res = ForkExecvp(cmd)) != 0) {
+ LOG(WARNING) << "Failed to zap; status " << res;
+ }
+
struct disk_info dinfo;
memset(&dinfo, 0, sizeof(dinfo));
diff --git a/TrimTask.cpp b/TrimTask.cpp
index 1c6eb1f..94bd097 100644
--- a/TrimTask.cpp
+++ b/TrimTask.cpp
@@ -37,7 +37,7 @@
/* From a would-be kernel header */
#define FIDTRIM _IOWR('f', 128, struct fstrim_range) /* Deep discard trim */
-#define BENCHMARK_ENABLED 0
+#define BENCHMARK_ENABLED 1
using android::base::StringPrintf;
diff --git a/cryptfs.c b/cryptfs.c
index 1828ece..47acbc3 100644
--- a/cryptfs.c
+++ b/cryptfs.c
@@ -2445,11 +2445,19 @@
goto errout;
}
- if ( (data.cryptofd = open(crypto_blkdev, O_WRONLY|O_CLOEXEC)) < 0) {
- SLOGE("Error opening crypto_blkdev %s for ext4 inplace encrypt. err=%d(%s)\n",
- crypto_blkdev, errno, strerror(errno));
- rc = ENABLE_INPLACE_ERR_DEV;
- goto errout;
+ // Wait until the block device appears. Re-use the mount retry values since it is reasonable.
+ int retries = RETRY_MOUNT_ATTEMPTS;
+ while ((data.cryptofd = open(crypto_blkdev, O_WRONLY|O_CLOEXEC)) < 0) {
+ if (--retries) {
+ SLOGE("Error opening crypto_blkdev %s for ext4 inplace encrypt. err=%d(%s), retrying\n",
+ crypto_blkdev, errno, strerror(errno));
+ sleep(RETRY_MOUNT_DELAY_SECONDS);
+ } else {
+ SLOGE("Error opening crypto_blkdev %s for ext4 inplace encrypt. err=%d(%s)\n",
+ crypto_blkdev, errno, strerror(errno));
+ rc = ENABLE_INPLACE_ERR_DEV;
+ goto errout;
+ }
}
if (setjmp(setjmp_env)) {