Merge "adbd: improve thread names."
diff --git a/CleanSpec.mk b/CleanSpec.mk
index 5b5eff4..304ce4e 100644
--- a/CleanSpec.mk
+++ b/CleanSpec.mk
@@ -60,3 +60,4 @@
$(call add-clean-step, rm -rf $(PRODUCT_OUT)/system/lib64/hw/gatekeeper.$(TARGET_DEVICE).so)
$(call add-clean-step, rm -rf $(PRODUCT_OUT)/root/vendor)
$(call add-clean-step, rm -rf $(PRODUCT_OUT)/root/init.rc)
+$(call add-clean-step, rm -rf $(PRODUCT_OUT)/root/root)
diff --git a/bootstat/bootstat.cpp b/bootstat/bootstat.cpp
index 7c0b15e..17986b9 100644
--- a/bootstat/bootstat.cpp
+++ b/bootstat/bootstat.cpp
@@ -204,6 +204,7 @@
{"reboot,shell", 66},
{"reboot,adb", 67},
{"reboot,userrequested", 68},
+ {"shutdown,container", 69}, // Host OS asking Android Container to shutdown
};
// Converts a string value representing the reason the system booted to an
diff --git a/fs_mgr/fs_mgr_fstab.cpp b/fs_mgr/fs_mgr_fstab.cpp
index 31c8803..bce245c 100644
--- a/fs_mgr/fs_mgr_fstab.cpp
+++ b/fs_mgr/fs_mgr_fstab.cpp
@@ -779,47 +779,21 @@
}
/*
- * Returns the 1st matching fstab_rec that follows the start_rec.
- * start_rec is the result of a previous search or NULL.
+ * Returns the fstab_rec* whose mount_point is path.
+ * Returns nullptr if not found.
*/
-struct fstab_rec* fs_mgr_get_entry_for_mount_point_after(struct fstab_rec* start_rec,
- struct fstab* fstab,
- const std::string& path) {
- int i;
+struct fstab_rec* fs_mgr_get_entry_for_mount_point(struct fstab* fstab, const std::string& path) {
if (!fstab) {
return nullptr;
}
-
- if (start_rec) {
- for (i = 0; i < fstab->num_entries; i++) {
- if (&fstab->recs[i] == start_rec) {
- i++;
- break;
- }
- }
- } else {
- i = 0;
- }
-
- for (; i < fstab->num_entries; i++) {
+ for (int i = 0; i < fstab->num_entries; i++) {
if (fstab->recs[i].mount_point && path == fstab->recs[i].mount_point) {
return &fstab->recs[i];
}
}
-
return nullptr;
}
-/*
- * Returns the 1st matching mount point.
- * There might be more. To look for others, use fs_mgr_get_entry_for_mount_point_after()
- * and give the fstab_rec from the previous search.
- */
-struct fstab_rec *fs_mgr_get_entry_for_mount_point(struct fstab *fstab, const char *path)
-{
- return fs_mgr_get_entry_for_mount_point_after(NULL, fstab, path);
-}
-
int fs_mgr_is_voldmanaged(const struct fstab_rec *fstab)
{
return fstab->fs_mgr_flags & MF_VOLDMANAGED;
diff --git a/fs_mgr/include_fstab/fstab/fstab.h b/fs_mgr/include_fstab/fstab/fstab.h
index 8a18ec0..ef51724 100644
--- a/fs_mgr/include_fstab/fstab/fstab.h
+++ b/fs_mgr/include_fstab/fstab/fstab.h
@@ -70,7 +70,6 @@
int fs_mgr_add_entry(struct fstab* fstab, const char* mount_point, const char* fs_type,
const char* blk_device);
-struct fstab_rec* fs_mgr_get_entry_for_mount_point(struct fstab* fstab, const char* path);
int fs_mgr_is_voldmanaged(const struct fstab_rec* fstab);
int fs_mgr_is_nonremovable(const struct fstab_rec* fstab);
int fs_mgr_is_verified(const struct fstab_rec* fstab);
@@ -95,6 +94,7 @@
// TODO: move this into separate header files under include/fs_mgr/*.h
#ifdef __cplusplus
std::string fs_mgr_get_slot_suffix();
+struct fstab_rec* fs_mgr_get_entry_for_mount_point(struct fstab* fstab, const std::string& path);
#endif
#endif /* __CORE_FS_TAB_H */
diff --git a/init/init.cpp b/init/init.cpp
index e611f18..ad045b1 100644
--- a/init/init.cpp
+++ b/init/init.cpp
@@ -417,8 +417,7 @@
return;
}
- LOG(INFO) << "Handling SIGTERM, shutting system down";
- HandlePowerctlMessage("shutdown");
+ HandlePowerctlMessage("shutdown,container");
}
static void InstallSigtermHandler() {
diff --git a/init/persistent_properties.cpp b/init/persistent_properties.cpp
index 71f2355..21adce9 100644
--- a/init/persistent_properties.cpp
+++ b/init/persistent_properties.cpp
@@ -43,7 +43,6 @@
namespace {
-constexpr const uint32_t kMagic = 0x8495E0B4;
constexpr const char kLegacyPersistentPropertyDir[] = "/data/property";
void AddPersistentProperty(const std::string& name, const std::string& value,
@@ -140,85 +139,6 @@
return persistent_properties;
}
-class PersistentPropertyFileParser {
- public:
- PersistentPropertyFileParser(const std::string& contents) : contents_(contents), position_(0) {}
- Result<PersistentProperties> Parse();
-
- private:
- Result<std::string> ReadString();
- Result<uint32_t> ReadUint32();
-
- const std::string& contents_;
- size_t position_;
-};
-
-Result<PersistentProperties> PersistentPropertyFileParser::Parse() {
- if (auto magic = ReadUint32(); magic) {
- if (*magic != kMagic) {
- return Error() << "Magic value '0x" << std::hex << *magic
- << "' does not match expected value '0x" << kMagic << "'";
- }
- } else {
- return Error() << "Could not read magic value: " << magic.error();
- }
-
- if (auto version = ReadUint32(); version) {
- if (*version != 1) {
- return Error() << "Version '" << *version
- << "' does not match any compatible version: (1)";
- }
- } else {
- return Error() << "Could not read version: " << version.error();
- }
-
- auto num_properties = ReadUint32();
- if (!num_properties) {
- return Error() << "Could not read num_properties: " << num_properties.error();
- }
-
- PersistentProperties result;
- while (position_ < contents_.size()) {
- auto name = ReadString();
- if (!name) {
- return Error() << "Could not read name: " << name.error();
- }
- if (!StartsWith(*name, "persist.")) {
- return Error() << "Property '" << *name << "' does not starts with 'persist.'";
- }
- auto value = ReadString();
- if (!value) {
- return Error() << "Could not read value: " << value.error();
- }
- AddPersistentProperty(*name, *value, &result);
- }
-
- return result;
-}
-
-Result<std::string> PersistentPropertyFileParser::ReadString() {
- auto string_length = ReadUint32();
- if (!string_length) {
- return Error() << "Could not read size for string";
- }
-
- if (position_ + *string_length > contents_.size()) {
- return Error() << "String size would cause it to overflow the input buffer";
- }
- auto result = std::string(contents_, position_, *string_length);
- position_ += *string_length;
- return result;
-}
-
-Result<uint32_t> PersistentPropertyFileParser::ReadUint32() {
- if (position_ + 3 > contents_.size()) {
- return Error() << "Input buffer not large enough to read uint32_t";
- }
- uint32_t result = *reinterpret_cast<const uint32_t*>(&contents_[position_]);
- position_ += sizeof(uint32_t);
- return result;
-}
-
Result<std::string> ReadPersistentPropertyFile() {
const std::string temp_filename = persistent_property_filename + ".tmp";
if (access(temp_filename.c_str(), F_OK) == 0) {
@@ -240,24 +160,13 @@
auto file_contents = ReadPersistentPropertyFile();
if (!file_contents) return file_contents.error();
- // Check the intermediate "I should have used protobufs from the start" format.
- // TODO: Remove this.
- auto parsed_contents = PersistentPropertyFileParser(*file_contents).Parse();
- if (parsed_contents) {
- LOG(INFO) << "Intermediate format persistent property file found, converting to protobuf";
-
- // Update to the protobuf format
- WritePersistentPropertyFile(*parsed_contents);
- return parsed_contents;
- }
-
PersistentProperties persistent_properties;
if (persistent_properties.ParseFromString(*file_contents)) return persistent_properties;
// If the file cannot be parsed in either format, then we don't have any recovery
// mechanisms, so we delete it to allow for future writes to take place successfully.
unlink(persistent_property_filename.c_str());
- return Error() << "Unable to parse persistent property file: " << parsed_contents.error();
+ return Error() << "Unable to parse persistent property file: Could not parse protobuf";
}
Result<Success> WritePersistentPropertyFile(const PersistentProperties& persistent_properties) {
@@ -288,25 +197,24 @@
// Persistent properties are not written often, so we rather not keep any data in memory and read
// then rewrite the persistent property file for each update.
void WritePersistentProperty(const std::string& name, const std::string& value) {
- auto file_contents = ReadPersistentPropertyFile();
- PersistentProperties persistent_properties;
+ auto persistent_properties = LoadPersistentPropertyFile();
- if (!file_contents || !persistent_properties.ParseFromString(*file_contents)) {
+ if (!persistent_properties) {
LOG(ERROR) << "Recovering persistent properties from memory: "
- << (!file_contents ? file_contents.error_string() : "Could not parse protobuf");
+ << persistent_properties.error();
persistent_properties = LoadPersistentPropertiesFromMemory();
}
- auto it = std::find_if(persistent_properties.mutable_properties()->begin(),
- persistent_properties.mutable_properties()->end(),
+ auto it = std::find_if(persistent_properties->mutable_properties()->begin(),
+ persistent_properties->mutable_properties()->end(),
[&name](const auto& record) { return record.name() == name; });
- if (it != persistent_properties.mutable_properties()->end()) {
+ if (it != persistent_properties->mutable_properties()->end()) {
it->set_name(name);
it->set_value(value);
} else {
- AddPersistentProperty(name, value, &persistent_properties);
+ AddPersistentProperty(name, value, &persistent_properties.value());
}
- if (auto result = WritePersistentPropertyFile(persistent_properties); !result) {
+ if (auto result = WritePersistentPropertyFile(*persistent_properties); !result) {
LOG(ERROR) << "Could not store persistent property: " << result.error();
}
}
diff --git a/libcutils/fs_config.cpp b/libcutils/fs_config.cpp
index 1185040..bab095e 100644
--- a/libcutils/fs_config.cpp
+++ b/libcutils/fs_config.cpp
@@ -80,7 +80,6 @@
{ 00775, AID_ROOT, AID_ROOT, 0, "data/preloads" },
{ 00771, AID_SYSTEM, AID_SYSTEM, 0, "data" },
{ 00755, AID_ROOT, AID_SYSTEM, 0, "mnt" },
- { 00755, AID_ROOT, AID_ROOT, 0, "root" },
{ 00750, AID_ROOT, AID_SHELL, 0, "sbin" },
{ 00777, AID_ROOT, AID_ROOT, 0, "sdcard" },
{ 00751, AID_ROOT, AID_SDCARD_R, 0, "storage" },
diff --git a/libsparse/Android.bp b/libsparse/Android.bp
index 6ec0991..b894656 100644
--- a/libsparse/Android.bp
+++ b/libsparse/Android.bp
@@ -15,19 +15,11 @@
cflags: ["-Werror"],
local_include_dirs: ["include"],
export_include_dirs: ["include"],
+ shared_libs: [
+ "libz",
+ "libbase",
+ ],
target: {
- host: {
- shared_libs: [
- "libz-host",
- "libbase",
- ],
- },
- android: {
- shared_libs: [
- "libz",
- "libbase",
- ],
- },
windows: {
enabled: true,
},
diff --git a/libziparchive/Android.bp b/libziparchive/Android.bp
index f395c74..e3faee3 100644
--- a/libziparchive/Android.bp
+++ b/libziparchive/Android.bp
@@ -69,11 +69,11 @@
shared_libs: [
"liblog",
"libbase",
+ "libz",
],
target: {
android: {
shared_libs: [
- "libz",
"libutils",
],
},
@@ -81,18 +81,8 @@
static_libs: ["libutils"],
},
linux_bionic: {
- static_libs: ["libz"],
enabled: true,
},
- linux: {
- shared_libs: ["libz-host"],
- },
- darwin: {
- shared_libs: ["libz-host"],
- },
- windows: {
- shared_libs: ["libz-host"],
- },
},
}
@@ -105,7 +95,7 @@
"libziparchive_defaults",
"libziparchive_flags",
],
- shared_libs: ["libz-host"],
+ shared_libs: ["libz"],
static_libs: ["libutils"],
}
diff --git a/rootdir/Android.mk b/rootdir/Android.mk
index 48a46c6..e199ed4 100644
--- a/rootdir/Android.mk
+++ b/rootdir/Android.mk
@@ -127,7 +127,7 @@
#
# create some directories (some are mount points) and symlinks
LOCAL_POST_INSTALL_CMD := mkdir -p $(addprefix $(TARGET_ROOT_OUT)/, \
- sbin dev proc sys system data oem acct config storage mnt root $(BOARD_ROOT_EXTRA_FOLDERS)); \
+ sbin dev proc sys system data oem acct config storage mnt $(BOARD_ROOT_EXTRA_FOLDERS)); \
ln -sf /system/etc $(TARGET_ROOT_OUT)/etc; \
ln -sf /data/user_de/0/com.android.shell/files/bugreports $(TARGET_ROOT_OUT)/bugreports; \
ln -sf /sys/kernel/debug $(TARGET_ROOT_OUT)/d; \