Merge "charger: fix charger display stuck"
diff --git a/debuggerd/Android.bp b/debuggerd/Android.bp
index f713ff2..9ca0eba 100644
--- a/debuggerd/Android.bp
+++ b/debuggerd/Android.bp
@@ -210,6 +210,9 @@
"libcutils",
"liblog",
],
+ runtime_libs: [
+ "libdexfile", // libdexfile_support dependency
+ ],
whole_static_libs: [
"libasync_safe",
@@ -225,11 +228,17 @@
exclude_static_libs: [
"libdexfile_support",
],
+ exclude_runtime_libs: [
+ "libdexfile",
+ ],
},
vendor_ramdisk: {
exclude_static_libs: [
"libdexfile_support",
],
+ exclude_runtime_libs: [
+ "libdexfile",
+ ],
},
},
diff --git a/debuggerd/tombstoned/tombstoned.cpp b/debuggerd/tombstoned/tombstoned.cpp
index 02ded1e..50558f7 100644
--- a/debuggerd/tombstoned/tombstoned.cpp
+++ b/debuggerd/tombstoned/tombstoned.cpp
@@ -448,10 +448,8 @@
return;
}
- if (crash->output.text.fd < 0) {
- if (crash->output.text.fd == -1) {
- LOG(WARNING) << "skipping tombstone file creation due to intercept";
- }
+ if (crash->output.text.fd == -1) {
+ LOG(WARNING) << "skipping tombstone file creation due to intercept";
return;
}
diff --git a/fs_mgr/fs_mgr.cpp b/fs_mgr/fs_mgr.cpp
index 5f15aad..002b302 100644
--- a/fs_mgr/fs_mgr.cpp
+++ b/fs_mgr/fs_mgr.cpp
@@ -2231,16 +2231,16 @@
return false;
}
-std::string fs_mgr_get_hashtree_algorithm(const android::fs_mgr::FstabEntry& entry) {
+std::optional<HashtreeInfo> fs_mgr_get_hashtree_info(const android::fs_mgr::FstabEntry& entry) {
if (!entry.fs_mgr_flags.verify && !entry.fs_mgr_flags.avb) {
- return "";
+ return {};
}
DeviceMapper& dm = DeviceMapper::Instance();
std::string device = GetVerityDeviceName(entry);
std::vector<DeviceMapper::TargetInfo> table;
if (dm.GetState(device) == DmDeviceState::INVALID || !dm.GetTableInfo(device, &table)) {
- return "";
+ return {};
}
for (const auto& target : table) {
if (strcmp(target.spec.target_type, "verity") != 0) {
@@ -2256,14 +2256,15 @@
std::vector<std::string> tokens = android::base::Split(target.data, " \t\r\n");
if (tokens[0] != "0" && tokens[0] != "1") {
LOG(WARNING) << "Unrecognized device mapper version in " << target.data;
- return "";
+ return {};
}
- // Hashtree algorithm is the 8th token in the output
- return android::base::Trim(tokens[7]);
+ // Hashtree algorithm & root digest are the 8th & 9th token in the output.
+ return HashtreeInfo{.algorithm = android::base::Trim(tokens[7]),
+ .root_digest = android::base::Trim(tokens[8])};
}
- return "";
+ return {};
}
bool fs_mgr_verity_is_check_at_most_once(const android::fs_mgr::FstabEntry& entry) {
diff --git a/fs_mgr/include/fs_mgr.h b/fs_mgr/include/fs_mgr.h
index 4d3ecc9..21c9989 100644
--- a/fs_mgr/include/fs_mgr.h
+++ b/fs_mgr/include/fs_mgr.h
@@ -22,6 +22,7 @@
#include <linux/dm-ioctl.h>
#include <functional>
+#include <optional>
#include <string>
#include <fstab/fstab.h>
@@ -68,6 +69,13 @@
bool userdata_mounted;
};
+struct HashtreeInfo {
+ // The hash algorithm used to build the merkle tree.
+ std::string algorithm;
+ // The root digest of the merkle tree.
+ std::string root_digest;
+};
+
// fs_mgr_mount_all() updates fstab entries that reference device-mapper.
// Returns a |MountAllResult|. The first element is one of the FS_MNG_MNTALL_* return codes
// defined above, and the second element tells whether this call to fs_mgr_mount_all was responsible
@@ -88,9 +96,9 @@
bool fs_mgr_load_verity_state(int* mode);
// Returns true if verity is enabled on this particular FstabEntry.
bool fs_mgr_is_verity_enabled(const android::fs_mgr::FstabEntry& entry);
-// Returns the hash algorithm used to build the hashtree of this particular FstabEntry. Returns an
-// empty string if the input isn't a dm-verity entry, or if there is an error.
-std::string fs_mgr_get_hashtree_algorithm(const android::fs_mgr::FstabEntry& entry);
+// Returns the verity hashtree information of this particular FstabEntry. Returns std::nullopt
+// if the input isn't a dm-verity entry, or if there is an error.
+std::optional<HashtreeInfo> fs_mgr_get_hashtree_info(const android::fs_mgr::FstabEntry& entry);
bool fs_mgr_swapon_all(const android::fs_mgr::Fstab& fstab);
bool fs_mgr_update_logical_partition(android::fs_mgr::FstabEntry* entry);
diff --git a/fs_mgr/libsnapshot/inspect_cow.cpp b/fs_mgr/libsnapshot/inspect_cow.cpp
index ed86c87..3c0ba16 100644
--- a/fs_mgr/libsnapshot/inspect_cow.cpp
+++ b/fs_mgr/libsnapshot/inspect_cow.cpp
@@ -16,8 +16,10 @@
#include <stdio.h>
#include <unistd.h>
+#include <iomanip>
#include <iostream>
#include <string>
+#include <vector>
#include <android-base/logging.h>
#include <android-base/unique_fd.h>
@@ -39,8 +41,10 @@
LOG(ERROR) << "Usage: inspect_cow [-sd] <COW_FILE>";
LOG(ERROR) << "\t -s Run Silent";
LOG(ERROR) << "\t -d Attempt to decompress";
- LOG(ERROR) << "\t -b Show data for failed decompress\n";
- LOG(ERROR) << "\t -m Show ops in reverse merge order\n";
+ LOG(ERROR) << "\t -b Show data for failed decompress";
+ LOG(ERROR) << "\t -l Show ops";
+ LOG(ERROR) << "\t -m Show ops in reverse merge order";
+ LOG(ERROR) << "\t -o Shows sequence op block order\n";
}
enum OpIter { Normal, RevMerge };
@@ -48,7 +52,9 @@
struct Options {
bool silent;
bool decompress;
+ bool show_ops;
bool show_bad;
+ bool show_seq;
OpIter iter_type;
};
@@ -137,7 +143,7 @@
while (!iter->Done()) {
const CowOperation& op = iter->Get();
- if (!opt.silent) std::cout << op << "\n";
+ if (!opt.silent && opt.show_ops) std::cout << op << "\n";
if (opt.decompress && op.type == kCowReplaceOp && op.compression != kCowCompressNone) {
if (!reader.ReadData(op, &sink)) {
@@ -148,6 +154,24 @@
sink.Reset();
}
+ if (op.type == kCowSequenceOp && opt.show_seq) {
+ size_t read;
+ std::vector<uint32_t> merge_op_blocks;
+ size_t seq_len = op.data_length / sizeof(uint32_t);
+ merge_op_blocks.resize(seq_len);
+ if (!reader.GetRawBytes(op.source, merge_op_blocks.data(), op.data_length, &read)) {
+ PLOG(ERROR) << "Failed to read sequence op!";
+ return false;
+ }
+ if (!opt.silent) {
+ std::cout << "Sequence for " << op << " is :\n";
+ for (size_t i = 0; i < seq_len; i++) {
+ std::cout << std::setfill('0') << std::setw(6) << merge_op_blocks[i] << ", ";
+ if ((i + 1) % 10 == 0 || i + 1 == seq_len) std::cout << "\n";
+ }
+ }
+ }
+
iter->Next();
}
@@ -164,7 +188,7 @@
opt.decompress = false;
opt.show_bad = false;
opt.iter_type = android::snapshot::Normal;
- while ((ch = getopt(argc, argv, "sdbm")) != -1) {
+ while ((ch = getopt(argc, argv, "sdbmol")) != -1) {
switch (ch) {
case 's':
opt.silent = true;
@@ -178,6 +202,12 @@
case 'm':
opt.iter_type = android::snapshot::RevMerge;
break;
+ case 'o':
+ opt.show_seq = true;
+ break;
+ case 'l':
+ opt.show_ops = true;
+ break;
default:
android::snapshot::usage();
}
diff --git a/fs_mgr/libsnapshot/snapuserd/snapuserd_readahead.cpp b/fs_mgr/libsnapshot/snapuserd/snapuserd_readahead.cpp
index b868eed..3bb7a0a 100644
--- a/fs_mgr/libsnapshot/snapuserd/snapuserd_readahead.cpp
+++ b/fs_mgr/libsnapshot/snapuserd/snapuserd_readahead.cpp
@@ -194,10 +194,12 @@
std::vector<uint64_t>& blocks) {
int num_ops = *pending_ops;
int nr_consecutive = 0;
+ CHECK_NE(source_offset, nullptr);
if (!RAIterDone() && num_ops) {
// Get the first block with offset
const CowOperation* cow_op = GetRAOpIter();
+ CHECK_NE(cow_op, nullptr);
*source_offset = cow_op->source;
if (cow_op->type == kCowCopyOp) {
*source_offset *= BLOCK_SZ;
@@ -216,11 +218,12 @@
*/
while (!RAIterDone() && num_ops) {
const CowOperation* op = GetRAOpIter();
+ CHECK_NE(op, nullptr);
uint64_t next_offset = op->source;
- if (cow_op->type == kCowCopyOp) {
+ if (op->type == kCowCopyOp) {
next_offset *= BLOCK_SZ;
}
- if (next_offset != (*source_offset - nr_consecutive * BLOCK_SZ)) {
+ if (next_offset + nr_consecutive * BLOCK_SZ != *source_offset) {
break;
}
nr_consecutive += 1;
diff --git a/init/builtins.cpp b/init/builtins.cpp
index 7633d9c..994eed9 100644
--- a/init/builtins.cpp
+++ b/init/builtins.cpp
@@ -894,9 +894,11 @@
std::string partition = entry.mount_point == "/" ? "system" : Basename(entry.mount_point);
SetProperty("partition." + partition + ".verified", std::to_string(mode));
- std::string hash_alg = fs_mgr_get_hashtree_algorithm(entry);
- if (!hash_alg.empty()) {
- SetProperty("partition." + partition + ".verified.hash_alg", hash_alg);
+ auto hashtree_info = fs_mgr_get_hashtree_info(entry);
+ if (hashtree_info) {
+ SetProperty("partition." + partition + ".verified.hash_alg", hashtree_info->algorithm);
+ SetProperty("partition." + partition + ".verified.root_digest",
+ hashtree_info->root_digest);
}
}