Merge "Revert "Revert "Lock down String8|16.string() usage""" into main
diff --git a/fastboot/fastboot.cpp b/fastboot/fastboot.cpp
index 21df729..3ce8141 100644
--- a/fastboot/fastboot.cpp
+++ b/fastboot/fastboot.cpp
@@ -28,7 +28,6 @@
#include "fastboot.h"
-#include <ctype.h>
#include <errno.h>
#include <fcntl.h>
#include <getopt.h>
@@ -44,12 +43,10 @@
#include <unistd.h>
#include <chrono>
-#include <fstream>
#include <functional>
#include <iostream>
#include <memory>
#include <regex>
-#include <sstream>
#include <string>
#include <thread>
#include <utility>
@@ -79,7 +76,6 @@
#include "fastboot_driver_interface.h"
#include "fs.h"
#include "storage.h"
-#include "super_flash_helper.h"
#include "task.h"
#include "tcp.h"
#include "transport.h"
@@ -93,7 +89,6 @@
using android::base::Split;
using android::base::Trim;
using android::base::unique_fd;
-using namespace std::string_literals;
using namespace std::placeholders;
#define FASTBOOT_INFO_VERSION 1
@@ -350,8 +345,7 @@
//
// The returned Transport is a singleton, so multiple calls to this function will return the same
// object, and the caller should not attempt to delete the returned Transport.
-static std::unique_ptr<Transport> open_device(const char* local_serial,
- bool wait_for_device = true,
+static std::unique_ptr<Transport> open_device(const char* local_serial, bool wait_for_device = true,
bool announce = true) {
const Result<NetworkSerial, FastbootError> network_serial = ParseNetworkSerial(local_serial);
@@ -1191,9 +1185,10 @@
return partition_size;
}
-static void copy_avb_footer(const std::string& partition, struct fastboot_buffer* buf) {
+static void copy_avb_footer(const ImageSource* source, const std::string& partition,
+ struct fastboot_buffer* buf) {
if (buf->sz < AVB_FOOTER_SIZE || is_logical(partition) ||
- should_flash_in_userspace(partition)) {
+ should_flash_in_userspace(source, partition)) {
return;
}
// If overflows and negative, it should be < buf->sz.
@@ -1250,9 +1245,9 @@
}
}
-static void flash_buf(const std::string& partition, struct fastboot_buffer* buf,
- const bool apply_vbmeta) {
- copy_avb_footer(partition, buf);
+static void flash_buf(const ImageSource* source, const std::string& partition,
+ struct fastboot_buffer* buf, const bool apply_vbmeta) {
+ copy_avb_footer(source, partition, buf);
// Rewrite vbmeta if that's what we're flashing and modification has been requested.
if (g_disable_verity || g_disable_verification) {
@@ -1419,12 +1414,19 @@
}
}
-bool is_retrofit_device(fastboot::IFastBootDriver* fb) {
- std::string value;
- if (fb->GetVar("super-partition-name", &value) != fastboot::SUCCESS) {
+bool is_retrofit_device(const ImageSource* source) {
+ // Does this device use dynamic partitions at all?
+ std::vector<char> contents;
+ if (!source->ReadFile("super_empty.img", &contents)) {
return false;
}
- return android::base::StartsWith(value, "system_");
+ auto metadata = android::fs_mgr::ReadFromImageBlob(contents.data(), contents.size());
+ for (const auto& partition : metadata->partitions) {
+ if (partition.attributes & LP_PARTITION_ATTR_SLOT_SUFFIXED) {
+ return true;
+ }
+ }
+ return false;
}
// Fetch a partition from the device to a given fd. This is a wrapper over FetchToFd to fetch
@@ -1523,7 +1525,7 @@
fb->ResizePartition(pname, std::to_string(buf.image_size));
}
std::string flash_pname = repack_ramdisk(pname, &buf, fp->fb);
- flash_buf(flash_pname, &buf, apply_vbmeta);
+ flash_buf(fp->source, flash_pname, &buf, apply_vbmeta);
}
// Sets slot_override as the active slot. If slot_override is blank,
@@ -1806,9 +1808,9 @@
tasks = CollectTasksFromImageList();
}
if (fp_->exclude_dynamic_partitions) {
- auto is_non_static_flash_task = [](const auto& task) -> bool {
+ auto is_non_static_flash_task = [&](const auto& task) -> bool {
if (auto flash_task = task->AsFlashTask()) {
- if (!should_flash_in_userspace(flash_task->GetPartitionAndSlot())) {
+ if (!should_flash_in_userspace(fp_->source, flash_task->GetPartitionAndSlot())) {
return false;
}
}
@@ -1882,12 +1884,11 @@
// On these devices, secondary slots must be flashed as physical
// partitions (otherwise they would not mount on first boot). To enforce
// this, we delete any logical partitions for the "other" slot.
- if (is_retrofit_device(fp_->fb)) {
- std::string partition_name = image->part_name + "_"s + slot;
- if (image->IsSecondary() && should_flash_in_userspace(partition_name)) {
- fp_->fb->DeletePartition(partition_name);
+ if (is_retrofit_device(fp_->source)) {
+ std::string partition_name = image->part_name + "_" + slot;
+ if (image->IsSecondary() && should_flash_in_userspace(fp_->source, partition_name)) {
+ tasks.emplace_back(std::make_unique<DeleteTask>(fp_, partition_name));
}
- tasks.emplace_back(std::make_unique<DeleteTask>(fp_, partition_name));
}
}
@@ -2087,7 +2088,8 @@
if (!load_buf_fd(std::move(fd), &buf, fp)) {
die("Cannot read image: %s", strerror(errno));
}
- flash_buf(partition, &buf, is_vbmeta_partition(partition));
+
+ flash_buf(fp->source, partition, &buf, is_vbmeta_partition(partition));
return;
failed:
@@ -2101,18 +2103,26 @@
}
}
-bool should_flash_in_userspace(const std::string& partition_name) {
- if (!get_android_product_out()) {
+bool should_flash_in_userspace(const ImageSource* source, const std::string& partition_name) {
+ if (!source) {
+ if (!get_android_product_out()) {
+ return false;
+ }
+ auto path = find_item_given_name("super_empty.img");
+ if (path.empty() || access(path.c_str(), R_OK)) {
+ return false;
+ }
+ auto metadata = android::fs_mgr::ReadFromImageFile(path);
+ if (!metadata) {
+ return false;
+ }
+ return should_flash_in_userspace(*metadata.get(), partition_name);
+ }
+ std::vector<char> contents;
+ if (!source->ReadFile("super_empty.img", &contents)) {
return false;
}
- auto path = find_item_given_name("super_empty.img");
- if (path.empty() || access(path.c_str(), R_OK)) {
- return false;
- }
- auto metadata = android::fs_mgr::ReadFromImageFile(path);
- if (!metadata) {
- return false;
- }
+ auto metadata = android::fs_mgr::ReadFromImageBlob(contents.data(), contents.size());
return should_flash_in_userspace(*metadata.get(), partition_name);
}
@@ -2136,7 +2146,7 @@
if (metadata.block_devices.size() > 1) {
ok = WriteSplitImageFiles(temp_dir.path, metadata, block_size, {}, true);
} else {
- auto image_path = temp_dir.path + "/"s + super_bdev_name + ".img";
+ auto image_path = std::string(temp_dir.path) + "/" + std::string(super_bdev_name) + ".img";
ok = WriteToImageFile(image_path, metadata, block_size, {}, true);
}
if (!ok) {
@@ -2155,7 +2165,7 @@
image_name = partition + ".img";
}
- auto image_path = temp_dir.path + "/"s + image_name;
+ auto image_path = std::string(temp_dir.path) + "/" + image_name;
auto flash = [&](const std::string& partition_name) {
do_flash(partition_name.c_str(), image_path.c_str(), false, fp);
};
diff --git a/fastboot/fastboot.h b/fastboot/fastboot.h
index 35deea7..4859ceb 100644
--- a/fastboot/fastboot.h
+++ b/fastboot/fastboot.h
@@ -148,7 +148,7 @@
};
char* get_android_product_out();
-bool should_flash_in_userspace(const std::string& partition_name);
+bool should_flash_in_userspace(const ImageSource* source, const std::string& partition_name);
bool is_userspace_fastboot();
void do_flash(const char* pname, const char* fname, const bool apply_vbmeta,
const FlashingPlan* fp);
@@ -187,7 +187,7 @@
std::vector<SparsePtr> resparse_file(sparse_file* s, int64_t max_size);
bool supports_AB(fastboot::IFastBootDriver* fb);
-bool is_retrofit_device(fastboot::IFastBootDriver* fb);
+bool is_retrofit_device(const ImageSource* source);
bool is_logical(const std::string& partition);
void fb_perform_format(const std::string& partition, int skip_if_not_supported,
const std::string& type_override, const std::string& size_override,
diff --git a/fastboot/task.cpp b/fastboot/task.cpp
index f13dd55..4b2b9e3 100644
--- a/fastboot/task.cpp
+++ b/fastboot/task.cpp
@@ -41,7 +41,8 @@
void FlashTask::Run() {
auto flash = [&](const std::string& partition) {
- if (should_flash_in_userspace(partition) && !is_userspace_fastboot() && !fp_->force_flash) {
+ if (should_flash_in_userspace(fp_->source, partition) && !is_userspace_fastboot() &&
+ !fp_->force_flash) {
die("The partition you are trying to flash is dynamic, and "
"should be flashed via fastbootd. Please run:\n"
"\n"
diff --git a/fs_mgr/libsnapshot/include/libsnapshot/cow_format.h b/fs_mgr/libsnapshot/include/libsnapshot/cow_format.h
index c9a4dee..9359b9e 100644
--- a/fs_mgr/libsnapshot/include/libsnapshot/cow_format.h
+++ b/fs_mgr/libsnapshot/include/libsnapshot/cow_format.h
@@ -49,7 +49,9 @@
// | Footer (fixed) |
// +-----------------------+
//
-// The operations begin immediately after the header, and the "raw data"
+// After the header is a 2mb scratch space that is used to read ahead data during merge operations
+//
+// The operations begin immediately after the scratch space, and the "raw data"
// immediately follows the operation which refers to it. While streaming
// an OTA, we can immediately write the op and data, syncing after each pair,
// while storing operation metadata in memory. At the end, we compute data and
@@ -143,6 +145,42 @@
uint64_t source;
} __attribute__((packed));
+// The on disk format of cow (currently == CowOperation)
+struct CowOperationV2 {
+ // The operation code (see the constants and structures below).
+ uint8_t type;
+
+ // If this operation reads from the data section of the COW, this contains
+ // the compression type of that data (see constants below).
+ uint8_t compression;
+
+ // If this operation reads from the data section of the COW, this contains
+ // the length.
+ uint16_t data_length;
+
+ // The block of data in the new image that this operation modifies.
+ uint64_t new_block;
+
+ // The value of |source| depends on the operation code.
+ //
+ // For copy operations, this is a block location in the source image.
+ //
+ // For replace operations, this is a byte offset within the COW's data
+ // sections (eg, not landing within the header or metadata). It is an
+ // absolute position within the image.
+ //
+ // For zero operations (replace with all zeroes), this is unused and must
+ // be zero.
+ //
+ // For Label operations, this is the value of the applied label.
+ //
+ // For Cluster operations, this is the length of the following data region
+ //
+ // For Xor operations, this is the byte location in the source image.
+ uint64_t source;
+} __attribute__((packed));
+
+static_assert(sizeof(CowOperationV2) == sizeof(CowOperation));
static_assert(sizeof(CowOperation) == sizeof(CowFooterOperation));
static constexpr uint8_t kCowCopyOp = 1;
diff --git a/fs_mgr/libsnapshot/include/libsnapshot/cow_reader.h b/fs_mgr/libsnapshot/include/libsnapshot/cow_reader.h
index f4ce52f..67d301d 100644
--- a/fs_mgr/libsnapshot/include/libsnapshot/cow_reader.h
+++ b/fs_mgr/libsnapshot/include/libsnapshot/cow_reader.h
@@ -165,7 +165,6 @@
void UpdateMergeOpsCompleted(int num_merge_ops) { header_.num_merge_ops += num_merge_ops; }
private:
- bool ParseOps(std::optional<uint64_t> label);
bool PrepMergeOps();
uint64_t FindNumCopyops();
uint8_t GetCompressionType(const CowOperation* op);
diff --git a/fs_mgr/libsnapshot/libsnapshot_cow/create_cow.cpp b/fs_mgr/libsnapshot/libsnapshot_cow/create_cow.cpp
index 4e07fe3..efb1035 100644
--- a/fs_mgr/libsnapshot/libsnapshot_cow/create_cow.cpp
+++ b/fs_mgr/libsnapshot/libsnapshot_cow/create_cow.cpp
@@ -240,9 +240,11 @@
SHA256(bufptr, BLOCK_SZ, checksum);
std::string hash = ToHexString(checksum, sizeof(checksum));
- if (create_snapshot_patch_ && !WriteSnapshot(bufptr, blkindex, hash)) {
- LOG(ERROR) << "WriteSnapshot failed for block: " << blkindex;
- return false;
+ if (create_snapshot_patch_) {
+ if (!WriteSnapshot(bufptr, blkindex, hash)) {
+ LOG(ERROR) << "WriteSnapshot failed for block: " << blkindex;
+ return false;
+ }
} else {
std::lock_guard<std::mutex> lock(source_block_hash_lock_);
{
@@ -256,7 +258,7 @@
num_blocks -= 1;
}
- file_offset += (skip_blocks * kBlockSizeToRead);
+ file_offset += (skip_blocks * to_read);
if (file_offset >= dev_sz) {
break;
}
diff --git a/fs_mgr/libsnapshot/libsnapshot_cow/writer_v2.cpp b/fs_mgr/libsnapshot/libsnapshot_cow/writer_v2.cpp
index ee445a2..699529b 100644
--- a/fs_mgr/libsnapshot/libsnapshot_cow/writer_v2.cpp
+++ b/fs_mgr/libsnapshot/libsnapshot_cow/writer_v2.cpp
@@ -636,10 +636,8 @@
}
bool CowWriterV2::WriteOperation(const CowOperation& op, const void* data, size_t size) {
- if (!EnsureSpaceAvailable(next_op_pos_ + sizeof(op))) {
- return false;
- }
- if (!EnsureSpaceAvailable(next_data_pos_ + size)) {
+ if (!EnsureSpaceAvailable(next_op_pos_ + sizeof(op)) ||
+ !EnsureSpaceAvailable(next_data_pos_ + size)) {
return false;
}
diff --git a/fs_mgr/libsnapshot/snapuserd/Android.bp b/fs_mgr/libsnapshot/snapuserd/Android.bp
index e56ffbe..47a8685 100644
--- a/fs_mgr/libsnapshot/snapuserd/Android.bp
+++ b/fs_mgr/libsnapshot/snapuserd/Android.bp
@@ -74,6 +74,11 @@
"user-space-merge/worker.cpp",
"utility.cpp",
],
+ cflags: [
+ "-D_FILE_OFFSET_BITS=64",
+ "-Wall",
+ "-Werror",
+ ],
static_libs: [
"libbase",
"libdm",
@@ -104,6 +109,12 @@
"user-space-merge/snapuserd_server.cpp",
],
+ cflags: [
+ "-D_FILE_OFFSET_BITS=64",
+ "-Wall",
+ "-Werror",
+ ],
+
static_libs: [
"libbase",
"libbrotli",
@@ -226,6 +237,11 @@
"testing/host_harness.cpp",
"user-space-merge/snapuserd_test.cpp",
],
+ cflags: [
+ "-D_FILE_OFFSET_BITS=64",
+ "-Wall",
+ "-Werror",
+ ],
shared_libs: [
"libbase",
"liblog",
diff --git a/fs_mgr/libsnapshot/snapuserd/user-space-merge/snapuserd_core.h b/fs_mgr/libsnapshot/snapuserd/user-space-merge/snapuserd_core.h
index 622fc50..e401c11 100644
--- a/fs_mgr/libsnapshot/snapuserd/user-space-merge/snapuserd_core.h
+++ b/fs_mgr/libsnapshot/snapuserd/user-space-merge/snapuserd_core.h
@@ -249,6 +249,7 @@
};
std::ostream& operator<<(std::ostream& os, MERGE_IO_TRANSITION value);
+static_assert(sizeof(off_t) == sizeof(uint64_t));
} // namespace snapshot
} // namespace android
diff --git a/fs_mgr/libsnapshot/snapuserd/user-space-merge/snapuserd_test.cpp b/fs_mgr/libsnapshot/snapuserd/user-space-merge/snapuserd_test.cpp
index 01fe06f..620ecbd 100644
--- a/fs_mgr/libsnapshot/snapuserd/user-space-merge/snapuserd_test.cpp
+++ b/fs_mgr/libsnapshot/snapuserd/user-space-merge/snapuserd_test.cpp
@@ -714,10 +714,12 @@
}
ASSERT_NO_FATAL_FAILURE(SetupDefault());
// Issue I/O before merge begins
- std::async(std::launch::async, &SnapuserdTest::ReadSnapshotDeviceAndValidate, this);
+ auto read_future =
+ std::async(std::launch::async, &SnapuserdTest::ReadSnapshotDeviceAndValidate, this);
// Start the merge
ASSERT_TRUE(Merge());
ValidateMerge();
+ read_future.wait();
}
TEST_F(SnapuserdTest, Snapshot_MERGE_IO_TEST_1) {
@@ -728,9 +730,11 @@
// Start the merge
ASSERT_TRUE(StartMerge());
// Issue I/O in parallel when merge is in-progress
- std::async(std::launch::async, &SnapuserdTest::ReadSnapshotDeviceAndValidate, this);
+ auto read_future =
+ std::async(std::launch::async, &SnapuserdTest::ReadSnapshotDeviceAndValidate, this);
CheckMergeCompletion();
ValidateMerge();
+ read_future.wait();
}
TEST_F(SnapuserdTest, Snapshot_Merge_Resume) {
diff --git a/healthd/BatteryMonitor.cpp b/healthd/BatteryMonitor.cpp
index e4cf582..0c97632 100644
--- a/healthd/BatteryMonitor.cpp
+++ b/healthd/BatteryMonitor.cpp
@@ -432,7 +432,7 @@
}
if (readFromFile(mHealthdConfig->batteryTechnologyPath, &buf) > 0)
- mHealthInfo->batteryTechnology = String8(buf.c_str());
+ mHealthInfo->batteryTechnology = buf;
if (readFromFile(mHealthdConfig->chargingPolicyPath, &buf) > 0)
mHealthInfo->chargingPolicy = getBatteryChargingPolicy(buf.c_str());
@@ -786,39 +786,35 @@
path.clear();
path.appendFormat("%s/%s/status", POWER_SUPPLY_SYSFS_PATH,
name);
- if (access(path, R_OK) == 0)
- mHealthdConfig->batteryStatusPath = path;
+ if (access(path.c_str(), R_OK) == 0) mHealthdConfig->batteryStatusPath = path;
}
if (mHealthdConfig->batteryHealthPath.empty()) {
path.clear();
path.appendFormat("%s/%s/health", POWER_SUPPLY_SYSFS_PATH,
name);
- if (access(path, R_OK) == 0)
- mHealthdConfig->batteryHealthPath = path;
+ if (access(path.c_str(), R_OK) == 0) mHealthdConfig->batteryHealthPath = path;
}
if (mHealthdConfig->batteryPresentPath.empty()) {
path.clear();
path.appendFormat("%s/%s/present", POWER_SUPPLY_SYSFS_PATH,
name);
- if (access(path, R_OK) == 0)
- mHealthdConfig->batteryPresentPath = path;
+ if (access(path.c_str(), R_OK) == 0) mHealthdConfig->batteryPresentPath = path;
}
if (mHealthdConfig->batteryCapacityPath.empty()) {
path.clear();
path.appendFormat("%s/%s/capacity", POWER_SUPPLY_SYSFS_PATH,
name);
- if (access(path, R_OK) == 0)
- mHealthdConfig->batteryCapacityPath = path;
+ if (access(path.c_str(), R_OK) == 0) mHealthdConfig->batteryCapacityPath = path;
}
if (mHealthdConfig->batteryVoltagePath.empty()) {
path.clear();
path.appendFormat("%s/%s/voltage_now",
POWER_SUPPLY_SYSFS_PATH, name);
- if (access(path, R_OK) == 0) {
+ if (access(path.c_str(), R_OK) == 0) {
mHealthdConfig->batteryVoltagePath = path;
}
}
@@ -827,7 +823,7 @@
path.clear();
path.appendFormat("%s/%s/charge_full",
POWER_SUPPLY_SYSFS_PATH, name);
- if (access(path, R_OK) == 0)
+ if (access(path.c_str(), R_OK) == 0)
mHealthdConfig->batteryFullChargePath = path;
}
@@ -835,7 +831,7 @@
path.clear();
path.appendFormat("%s/%s/current_now",
POWER_SUPPLY_SYSFS_PATH, name);
- if (access(path, R_OK) == 0)
+ if (access(path.c_str(), R_OK) == 0)
mHealthdConfig->batteryCurrentNowPath = path;
}
@@ -843,27 +839,29 @@
path.clear();
path.appendFormat("%s/%s/cycle_count",
POWER_SUPPLY_SYSFS_PATH, name);
- if (access(path, R_OK) == 0)
+ if (access(path.c_str(), R_OK) == 0)
mHealthdConfig->batteryCycleCountPath = path;
}
if (mHealthdConfig->batteryCapacityLevelPath.empty()) {
path.clear();
path.appendFormat("%s/%s/capacity_level", POWER_SUPPLY_SYSFS_PATH, name);
- if (access(path, R_OK) == 0) mHealthdConfig->batteryCapacityLevelPath = path;
+ if (access(path.c_str(), R_OK) == 0) {
+ mHealthdConfig->batteryCapacityLevelPath = path;
+ }
}
if (mHealthdConfig->batteryChargeTimeToFullNowPath.empty()) {
path.clear();
path.appendFormat("%s/%s/time_to_full_now", POWER_SUPPLY_SYSFS_PATH, name);
- if (access(path, R_OK) == 0)
+ if (access(path.c_str(), R_OK) == 0)
mHealthdConfig->batteryChargeTimeToFullNowPath = path;
}
if (mHealthdConfig->batteryFullChargeDesignCapacityUahPath.empty()) {
path.clear();
path.appendFormat("%s/%s/charge_full_design", POWER_SUPPLY_SYSFS_PATH, name);
- if (access(path, R_OK) == 0)
+ if (access(path.c_str(), R_OK) == 0)
mHealthdConfig->batteryFullChargeDesignCapacityUahPath = path;
}
@@ -871,7 +869,7 @@
path.clear();
path.appendFormat("%s/%s/current_avg",
POWER_SUPPLY_SYSFS_PATH, name);
- if (access(path, R_OK) == 0)
+ if (access(path.c_str(), R_OK) == 0)
mHealthdConfig->batteryCurrentAvgPath = path;
}
@@ -879,7 +877,7 @@
path.clear();
path.appendFormat("%s/%s/charge_counter",
POWER_SUPPLY_SYSFS_PATH, name);
- if (access(path, R_OK) == 0)
+ if (access(path.c_str(), R_OK) == 0)
mHealthdConfig->batteryChargeCounterPath = path;
}
@@ -887,7 +885,7 @@
path.clear();
path.appendFormat("%s/%s/temp", POWER_SUPPLY_SYSFS_PATH,
name);
- if (access(path, R_OK) == 0) {
+ if (access(path.c_str(), R_OK) == 0) {
mHealthdConfig->batteryTemperaturePath = path;
}
}
@@ -896,19 +894,19 @@
path.clear();
path.appendFormat("%s/%s/technology",
POWER_SUPPLY_SYSFS_PATH, name);
- if (access(path, R_OK) == 0)
+ if (access(path.c_str(), R_OK) == 0)
mHealthdConfig->batteryTechnologyPath = path;
}
if (mHealthdConfig->batteryStateOfHealthPath.empty()) {
path.clear();
path.appendFormat("%s/%s/state_of_health", POWER_SUPPLY_SYSFS_PATH, name);
- if (access(path, R_OK) == 0) {
+ if (access(path.c_str(), R_OK) == 0) {
mHealthdConfig->batteryStateOfHealthPath = path;
} else {
path.clear();
path.appendFormat("%s/%s/health_index", POWER_SUPPLY_SYSFS_PATH, name);
- if (access(path, R_OK) == 0)
+ if (access(path.c_str(), R_OK) == 0)
mHealthdConfig->batteryStateOfHealthPath = path;
}
}
@@ -916,32 +914,36 @@
if (mHealthdConfig->batteryHealthStatusPath.empty()) {
path.clear();
path.appendFormat("%s/%s/health_status", POWER_SUPPLY_SYSFS_PATH, name);
- if (access(path, R_OK) == 0) mHealthdConfig->batteryHealthStatusPath = path;
+ if (access(path.c_str(), R_OK) == 0) {
+ mHealthdConfig->batteryHealthStatusPath = path;
+ }
}
if (mHealthdConfig->batteryManufacturingDatePath.empty()) {
path.clear();
path.appendFormat("%s/%s/manufacturing_date", POWER_SUPPLY_SYSFS_PATH, name);
- if (access(path, R_OK) == 0)
+ if (access(path.c_str(), R_OK) == 0)
mHealthdConfig->batteryManufacturingDatePath = path;
}
if (mHealthdConfig->batteryFirstUsageDatePath.empty()) {
path.clear();
path.appendFormat("%s/%s/first_usage_date", POWER_SUPPLY_SYSFS_PATH, name);
- if (access(path, R_OK) == 0) mHealthdConfig->batteryFirstUsageDatePath = path;
+ if (access(path.c_str(), R_OK) == 0) {
+ mHealthdConfig->batteryFirstUsageDatePath = path;
+ }
}
if (mHealthdConfig->chargingStatePath.empty()) {
path.clear();
path.appendFormat("%s/%s/charging_state", POWER_SUPPLY_SYSFS_PATH, name);
- if (access(path, R_OK) == 0) mHealthdConfig->chargingStatePath = path;
+ if (access(path.c_str(), R_OK) == 0) mHealthdConfig->chargingStatePath = path;
}
if (mHealthdConfig->chargingPolicyPath.empty()) {
path.clear();
path.appendFormat("%s/%s/charging_policy", POWER_SUPPLY_SYSFS_PATH, name);
- if (access(path, R_OK) == 0) mHealthdConfig->chargingPolicyPath = path;
+ if (access(path.c_str(), R_OK) == 0) mHealthdConfig->chargingPolicyPath = path;
}
break;
diff --git a/healthd/BatteryMonitor_v1.cpp b/healthd/BatteryMonitor_v1.cpp
index 686c338..2e0cfc9 100644
--- a/healthd/BatteryMonitor_v1.cpp
+++ b/healthd/BatteryMonitor_v1.cpp
@@ -352,7 +352,7 @@
mHealthInfo->batteryHealth = getBatteryHealth(buf.c_str());
if (readFromFile(mHealthdConfig->batteryTechnologyPath, &buf) > 0)
- mHealthInfo->batteryTechnology = String8(buf.c_str());
+ mHealthInfo->batteryTechnology = buf;
double MaxPower = 0;
@@ -639,39 +639,35 @@
path.clear();
path.appendFormat("%s/%s/status", POWER_SUPPLY_SYSFS_PATH,
name);
- if (access(path, R_OK) == 0)
- mHealthdConfig->batteryStatusPath = path;
+ if (access(path.c_str(), R_OK) == 0) mHealthdConfig->batteryStatusPath = path;
}
if (mHealthdConfig->batteryHealthPath.empty()) {
path.clear();
path.appendFormat("%s/%s/health", POWER_SUPPLY_SYSFS_PATH,
name);
- if (access(path, R_OK) == 0)
- mHealthdConfig->batteryHealthPath = path;
+ if (access(path.c_str(), R_OK) == 0) mHealthdConfig->batteryHealthPath = path;
}
if (mHealthdConfig->batteryPresentPath.empty()) {
path.clear();
path.appendFormat("%s/%s/present", POWER_SUPPLY_SYSFS_PATH,
name);
- if (access(path, R_OK) == 0)
- mHealthdConfig->batteryPresentPath = path;
+ if (access(path.c_str(), R_OK) == 0) mHealthdConfig->batteryPresentPath = path;
}
if (mHealthdConfig->batteryCapacityPath.empty()) {
path.clear();
path.appendFormat("%s/%s/capacity", POWER_SUPPLY_SYSFS_PATH,
name);
- if (access(path, R_OK) == 0)
- mHealthdConfig->batteryCapacityPath = path;
+ if (access(path.c_str(), R_OK) == 0) mHealthdConfig->batteryCapacityPath = path;
}
if (mHealthdConfig->batteryVoltagePath.empty()) {
path.clear();
path.appendFormat("%s/%s/voltage_now",
POWER_SUPPLY_SYSFS_PATH, name);
- if (access(path, R_OK) == 0) {
+ if (access(path.c_str(), R_OK) == 0) {
mHealthdConfig->batteryVoltagePath = path;
}
}
@@ -680,7 +676,7 @@
path.clear();
path.appendFormat("%s/%s/charge_full",
POWER_SUPPLY_SYSFS_PATH, name);
- if (access(path, R_OK) == 0)
+ if (access(path.c_str(), R_OK) == 0)
mHealthdConfig->batteryFullChargePath = path;
}
@@ -688,7 +684,7 @@
path.clear();
path.appendFormat("%s/%s/current_now",
POWER_SUPPLY_SYSFS_PATH, name);
- if (access(path, R_OK) == 0)
+ if (access(path.c_str(), R_OK) == 0)
mHealthdConfig->batteryCurrentNowPath = path;
}
@@ -696,27 +692,29 @@
path.clear();
path.appendFormat("%s/%s/cycle_count",
POWER_SUPPLY_SYSFS_PATH, name);
- if (access(path, R_OK) == 0)
+ if (access(path.c_str(), R_OK) == 0)
mHealthdConfig->batteryCycleCountPath = path;
}
if (mHealthdConfig->batteryCapacityLevelPath.empty()) {
path.clear();
path.appendFormat("%s/%s/capacity_level", POWER_SUPPLY_SYSFS_PATH, name);
- if (access(path, R_OK) == 0) mHealthdConfig->batteryCapacityLevelPath = path;
+ if (access(path.c_str(), R_OK) == 0) {
+ mHealthdConfig->batteryCapacityLevelPath = path;
+ }
}
if (mHealthdConfig->batteryChargeTimeToFullNowPath.empty()) {
path.clear();
path.appendFormat("%s/%s/time_to_full_now", POWER_SUPPLY_SYSFS_PATH, name);
- if (access(path, R_OK) == 0)
+ if (access(path.c_str(), R_OK) == 0)
mHealthdConfig->batteryChargeTimeToFullNowPath = path;
}
if (mHealthdConfig->batteryFullChargeDesignCapacityUahPath.empty()) {
path.clear();
path.appendFormat("%s/%s/charge_full_design", POWER_SUPPLY_SYSFS_PATH, name);
- if (access(path, R_OK) == 0)
+ if (access(path.c_str(), R_OK) == 0)
mHealthdConfig->batteryFullChargeDesignCapacityUahPath = path;
}
@@ -724,7 +722,7 @@
path.clear();
path.appendFormat("%s/%s/current_avg",
POWER_SUPPLY_SYSFS_PATH, name);
- if (access(path, R_OK) == 0)
+ if (access(path.c_str(), R_OK) == 0)
mHealthdConfig->batteryCurrentAvgPath = path;
}
@@ -732,7 +730,7 @@
path.clear();
path.appendFormat("%s/%s/charge_counter",
POWER_SUPPLY_SYSFS_PATH, name);
- if (access(path, R_OK) == 0)
+ if (access(path.c_str(), R_OK) == 0)
mHealthdConfig->batteryChargeCounterPath = path;
}
@@ -740,7 +738,7 @@
path.clear();
path.appendFormat("%s/%s/temp", POWER_SUPPLY_SYSFS_PATH,
name);
- if (access(path, R_OK) == 0) {
+ if (access(path.c_str(), R_OK) == 0) {
mHealthdConfig->batteryTemperaturePath = path;
}
}
@@ -749,7 +747,7 @@
path.clear();
path.appendFormat("%s/%s/technology",
POWER_SUPPLY_SYSFS_PATH, name);
- if (access(path, R_OK) == 0)
+ if (access(path.c_str(), R_OK) == 0)
mHealthdConfig->batteryTechnologyPath = path;
}
diff --git a/init/builtins.cpp b/init/builtins.cpp
index a70e866..a95a4a3 100644
--- a/init/builtins.cpp
+++ b/init/builtins.cpp
@@ -475,8 +475,6 @@
{ 0, 0 },
};
-#define DATA_MNT_POINT "/data"
-
/* mount <type> <device> <path> <flags ...> <options> */
static Result<void> do_mount(const BuiltinArguments& args) {
const char* options = nullptr;
diff --git a/init/first_stage_init.cpp b/init/first_stage_init.cpp
index c6a287a..e48fa15 100644
--- a/init/first_stage_init.cpp
+++ b/init/first_stage_init.cpp
@@ -239,8 +239,12 @@
module_dirs.emplace_back(entry->d_name);
break;
}
- // Ignore _16k/_64k module dirs on 4K kernels
- if (GetPageSizeSuffix(entry->d_name) != page_size_suffix) {
+ // Is a directory does not have page size suffix, it does not mean this directory is for 4K
+ // kernels. Certain 16K kernel builds put all modules in /lib/modules/`uname -r` without any
+ // suffix. Therefore, only ignore a directory if it has _16k/_64k suffix and the suffix does
+ // not match system page size.
+ const auto dir_page_size_suffix = GetPageSizeSuffix(entry->d_name);
+ if (!dir_page_size_suffix.empty() && dir_page_size_suffix != page_size_suffix) {
continue;
}
int dir_major = 0, dir_minor = 0;
diff --git a/init/security.cpp b/init/security.cpp
index 6e616be..0c73fae 100644
--- a/init/security.cpp
+++ b/init/security.cpp
@@ -106,21 +106,17 @@
// uml does not support mmap_rnd_bits
return {};
#elif defined(__aarch64__)
- // arm64 architecture supports 18 - 33 rnd bits depending on pagesize and
- // VA_SIZE. However the kernel might have been compiled with a narrower
- // range using CONFIG_ARCH_MMAP_RND_BITS_MIN/MAX. To use the maximum
- // supported number of bits, we start from the theoretical maximum of 33
- // bits and try smaller values until we reach 24 bits which is the
- // Android-specific minimum. Don't go lower even if the configured maximum
- // is smaller than 24.
+ // arm64 supports 14 - 33 rnd bits depending on page size and ARM64_VA_BITS.
+ // The kernel (6.5) still defaults to 39 va bits for 4KiB pages, so shipping
+ // devices are only getting 24 bits of randomness in practice.
if (SetMmapRndBitsMin(33, 24, false) && (!Has32BitAbi() || SetMmapRndBitsMin(16, 16, true))) {
return {};
}
#elif defined(__riscv)
- // TODO: sv48 and sv57 were both added to the kernel this year, so we
- // probably just need some kernel fixes to enable higher ASLR randomization,
- // but for now 24 is the maximum that the kernel supports.
- if (SetMmapRndBitsMin(24, 18, false)) {
+ // TODO: sv48 and sv57 have both been added to the kernel, but the kernel
+ // still doesn't support more than 24 bits.
+ // https://github.com/google/android-riscv64/issues/1
+ if (SetMmapRndBitsMin(24, 24, false)) {
return {};
}
#elif defined(__x86_64__)
diff --git a/libcutils/Android.bp b/libcutils/Android.bp
index 55a8694..8ae7d9e 100644
--- a/libcutils/Android.bp
+++ b/libcutils/Android.bp
@@ -171,11 +171,15 @@
"libasync_safe",
],
},
+ linux: {
+ srcs: [
+ "canned_fs_config.cpp",
+ "fs_config.cpp",
+ ],
+ },
not_windows: {
srcs: libcutils_nonwindows_sources + [
"ashmem-host.cpp",
- "canned_fs_config.cpp",
- "fs_config.cpp",
"trace-host.cpp",
],
},
@@ -201,8 +205,6 @@
srcs: libcutils_nonwindows_sources + [
"android_reboot.cpp",
"ashmem-dev.cpp",
- "canned_fs_config.cpp",
- "fs_config.cpp",
"klog.cpp",
"partition_utils.cpp",
"qtaguid.cpp",
diff --git a/libcutils/arch-x86/cache.h b/libcutils/arch-x86/cache.h
deleted file mode 100644
index 1c22fea..0000000
--- a/libcutils/arch-x86/cache.h
+++ /dev/null
@@ -1,28 +0,0 @@
-/*
- * Copyright (C) 2010 The Android Open Source Project
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-#if defined(__slm__)
-/* Values are optimized for Silvermont */
-#define SHARED_CACHE_SIZE (1024*1024) /* Silvermont L2 Cache */
-#define DATA_CACHE_SIZE (24*1024) /* Silvermont L1 Data Cache */
-#else
-/* Values are optimized for Atom */
-#define SHARED_CACHE_SIZE (512*1024) /* Atom L2 Cache */
-#define DATA_CACHE_SIZE (24*1024) /* Atom L1 Data Cache */
-#endif
-
-#define SHARED_CACHE_SIZE_HALF (SHARED_CACHE_SIZE / 2)
-#define DATA_CACHE_SIZE_HALF (DATA_CACHE_SIZE / 2)
diff --git a/libcutils/arch-x86_64/cache.h b/libcutils/arch-x86_64/cache.h
deleted file mode 100644
index f144309..0000000
--- a/libcutils/arch-x86_64/cache.h
+++ /dev/null
@@ -1,22 +0,0 @@
-/*
- * Copyright (C) 2014 The Android Open Source Project
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-/* Values are optimized for Silvermont */
-#define SHARED_CACHE_SIZE (1024*1024) /* Silvermont L2 Cache */
-#define DATA_CACHE_SIZE (24*1024) /* Silvermont L1 Data Cache */
-
-#define SHARED_CACHE_SIZE_HALF (SHARED_CACHE_SIZE / 2)
-#define DATA_CACHE_SIZE_HALF (DATA_CACHE_SIZE / 2)
diff --git a/libcutils/ashmem-dev.cpp b/libcutils/ashmem-dev.cpp
index 6a27f9a..410dbfd 100644
--- a/libcutils/ashmem-dev.cpp
+++ b/libcutils/ashmem-dev.cpp
@@ -44,16 +44,6 @@
#include <android-base/strings.h>
#include <android-base/unique_fd.h>
-/* Will be added to UAPI once upstream change is merged */
-#define F_SEAL_FUTURE_WRITE 0x0010
-
-/*
- * The minimum vendor API level at and after which it is safe to use memfd.
- * This is to facilitate deprecation of ashmem.
- */
-#define MIN_MEMFD_VENDOR_API_LEVEL 29
-#define MIN_MEMFD_VENDOR_API_LEVEL_CHAR 'Q'
-
/* ashmem identity */
static dev_t __ashmem_rdev;
/*
@@ -91,55 +81,17 @@
/* Determine if vendor processes would be ok with memfd in the system:
*
- * If VNDK is using older libcutils, don't use memfd. This is so that the
- * same shared memory mechanism is used across binder transactions between
- * vendor partition processes and system partition processes.
+ * Previously this function checked if memfd is supported by checking if
+ * vendor VNDK version is greater than Q. As we can assume all treblelized
+ * device using this code is up to date enough to use memfd, memfd is allowed
+ * if the device is treblelized.
*/
static bool check_vendor_memfd_allowed() {
- std::string vndk_version = android::base::GetProperty("ro.vndk.version", "");
+ static bool is_treblelized = android::base::GetBoolProperty("ro.treble.enabled", false);
- if (vndk_version == "") {
- ALOGE("memfd: ro.vndk.version not defined or invalid (%s), this is mandated since P.\n",
- vndk_version.c_str());
- return false;
- }
-
- /* No issues if vendor is targetting current Dessert */
- if (vndk_version == "current") {
- return false;
- }
-
- /* Check if VNDK version is a number and act on it */
- char* p;
- long int vers = strtol(vndk_version.c_str(), &p, 10);
- if (*p == 0) {
- if (vers < MIN_MEMFD_VENDOR_API_LEVEL) {
- ALOGI("memfd: device VNDK version (%s) is < Q so using ashmem.\n",
- vndk_version.c_str());
- return false;
- }
-
- return true;
- }
-
- // Non-numeric should be a single ASCII character. Characters after the
- // first are ignored.
- if (tolower(vndk_version[0]) < 'a' || tolower(vndk_version[0]) > 'z') {
- ALOGE("memfd: ro.vndk.version not defined or invalid (%s), this is mandated since P.\n",
- vndk_version.c_str());
- return false;
- }
-
- if (tolower(vndk_version[0]) < tolower(MIN_MEMFD_VENDOR_API_LEVEL_CHAR)) {
- ALOGI("memfd: device is using VNDK version (%s) which is less than Q. Use ashmem only.\n",
- vndk_version.c_str());
- return false;
- }
-
- return true;
+ return is_treblelized;
}
-
/* Determine if memfd can be supported. This is just one-time hardwork
* which will be cached by the caller.
*/
diff --git a/libcutils/fs_config.cpp b/libcutils/fs_config.cpp
index 26ac576..919be2f 100644
--- a/libcutils/fs_config.cpp
+++ b/libcutils/fs_config.cpp
@@ -41,10 +41,6 @@
#include "fs_config.h"
-#ifndef O_BINARY
-#define O_BINARY 0
-#endif
-
using android::base::EndsWith;
using android::base::StartsWith;
@@ -257,12 +253,12 @@
len = strip(target_out_path, len, "/");
len = strip(target_out_path, len, "/system");
if (asprintf(&name, "%.*s%s", (int)len, target_out_path, conf[which][dir]) != -1) {
- fd = TEMP_FAILURE_RETRY(open(name, O_RDONLY | O_BINARY));
+ fd = TEMP_FAILURE_RETRY(open(name, O_RDONLY));
free(name);
}
}
if (fd < 0) {
- fd = TEMP_FAILURE_RETRY(open(conf[which][dir], O_RDONLY | O_BINARY));
+ fd = TEMP_FAILURE_RETRY(open(conf[which][dir], O_RDONLY));
}
return fd;
}
diff --git a/libcutils/include/private/android_filesystem_capability.h b/libcutils/include/private/android_filesystem_capability.h
deleted file mode 100644
index 0227b1d..0000000
--- a/libcutils/include/private/android_filesystem_capability.h
+++ /dev/null
@@ -1,119 +0,0 @@
-/*
- * Copyright (C) 2013 The Android Open Source Project
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-/*
- * Taken from linux/capability.h, with minor modifications
- */
-
-#ifndef _SYSTEM_CORE_INCLUDE_PRIVATE_ANDROID_FILESYSTEM_CAPABILITY_H
-#define _SYSTEM_CORE_INCLUDE_PRIVATE_ANDROID_FILESYSTEM_CAPABILITY_H
-
-#include <stdint.h>
-
-#define __user
-#define __u32 uint32_t
-#define __le32 uint32_t
-
-#define _LINUX_CAPABILITY_VERSION_1 0x19980330
-#define _LINUX_CAPABILITY_U32S_1 1
-#define _LINUX_CAPABILITY_VERSION_2 0x20071026
-#define _LINUX_CAPABILITY_U32S_2 2
-#define _LINUX_CAPABILITY_VERSION_3 0x20080522
-#define _LINUX_CAPABILITY_U32S_3 2
-
-typedef struct __user_cap_header_struct {
- __u32 version;
- int pid;
-} __user* cap_user_header_t;
-
-typedef struct __user_cap_data_struct {
- __u32 effective;
- __u32 permitted;
- __u32 inheritable;
-} __user* cap_user_data_t;
-
-#define VFS_CAP_REVISION_MASK 0xFF000000
-#define VFS_CAP_REVISION_SHIFT 24
-#define VFS_CAP_FLAGS_MASK ~VFS_CAP_REVISION_MASK
-#define VFS_CAP_FLAGS_EFFECTIVE 0x000001
-#define VFS_CAP_REVISION_1 0x01000000
-#define VFS_CAP_U32_1 1
-#define XATTR_CAPS_SZ_1 (sizeof(__le32) * (1 + 2 * VFS_CAP_U32_1))
-#define VFS_CAP_REVISION_2 0x02000000
-#define VFS_CAP_U32_2 2
-#define XATTR_CAPS_SZ_2 (sizeof(__le32) * (1 + 2 * VFS_CAP_U32_2))
-#define XATTR_CAPS_SZ XATTR_CAPS_SZ_2
-#define VFS_CAP_U32 VFS_CAP_U32_2
-#define VFS_CAP_REVISION VFS_CAP_REVISION_2
-
-struct vfs_cap_data {
- __le32 magic_etc;
- struct {
- __le32 permitted;
- __le32 inheritable;
- } data[VFS_CAP_U32];
-};
-
-#define _LINUX_CAPABILITY_VERSION _LINUX_CAPABILITY_VERSION_1
-#define _LINUX_CAPABILITY_U32S _LINUX_CAPABILITY_U32S_1
-#define CAP_CHOWN 0
-#define CAP_DAC_OVERRIDE 1
-#define CAP_DAC_READ_SEARCH 2
-#define CAP_FOWNER 3
-#define CAP_FSETID 4
-#define CAP_KILL 5
-#define CAP_SETGID 6
-#define CAP_SETUID 7
-#define CAP_SETPCAP 8
-#define CAP_LINUX_IMMUTABLE 9
-#define CAP_NET_BIND_SERVICE 10
-#define CAP_NET_BROADCAST 11
-#define CAP_NET_ADMIN 12
-#define CAP_NET_RAW 13
-#define CAP_IPC_LOCK 14
-#define CAP_IPC_OWNER 15
-#define CAP_SYS_MODULE 16
-#define CAP_SYS_RAWIO 17
-#define CAP_SYS_CHROOT 18
-#define CAP_SYS_PTRACE 19
-#define CAP_SYS_PACCT 20
-#define CAP_SYS_ADMIN 21
-#define CAP_SYS_BOOT 22
-#define CAP_SYS_NICE 23
-#define CAP_SYS_RESOURCE 24
-#define CAP_SYS_TIME 25
-#define CAP_SYS_TTY_CONFIG 26
-#define CAP_MKNOD 27
-#define CAP_LEASE 28
-#define CAP_AUDIT_WRITE 29
-#define CAP_AUDIT_CONTROL 30
-#define CAP_SETFCAP 31
-#define CAP_MAC_OVERRIDE 32
-#define CAP_MAC_ADMIN 33
-#define CAP_SYSLOG 34
-#define CAP_WAKE_ALARM 35
-#define CAP_BLOCK_SUSPEND 36
-#define CAP_AUDIT_READ 37
-#define CAP_LAST_CAP CAP_AUDIT_READ
-#define cap_valid(x) ((x) >= 0 && (x) <= CAP_LAST_CAP)
-#define CAP_TO_INDEX(x) ((x) >> 5)
-#define CAP_TO_MASK(x) (1 << ((x)&31))
-
-#undef __user
-#undef __u32
-#undef __le32
-
-#endif
diff --git a/libcutils/include/private/fs_config.h b/libcutils/include/private/fs_config.h
index 8a9a1ff..45f46e5 100644
--- a/libcutils/include/private/fs_config.h
+++ b/libcutils/include/private/fs_config.h
@@ -24,11 +24,7 @@
#include <stdint.h>
#include <sys/cdefs.h>
-#if defined(__BIONIC__)
#include <linux/capability.h>
-#else // defined(__BIONIC__)
-#include <private/android_filesystem_capability.h>
-#endif // defined(__BIONIC__)
/* Rules for directories and files has moved to system/code/libcutils/fs_config.c */
diff --git a/libcutils/iosched_policy.cpp b/libcutils/iosched_policy.cpp
index 012c537..f7c724d 100644
--- a/libcutils/iosched_policy.cpp
+++ b/libcutils/iosched_policy.cpp
@@ -24,8 +24,7 @@
#include <unistd.h>
#if defined(__ANDROID__)
-#define IOPRIO_WHO_PROCESS (1)
-#define IOPRIO_CLASS_SHIFT (13)
+#include <linux/ioprio.h>
#include <sys/syscall.h>
#define __android_unused
#else
diff --git a/libutils/CallStack.cpp b/libutils/CallStack.cpp
index 4dcb35b..11f2c92 100644
--- a/libutils/CallStack.cpp
+++ b/libutils/CallStack.cpp
@@ -82,7 +82,7 @@
void CallStack::print(Printer& printer) const {
for (size_t i = 0; i < mFrameLines.size(); i++) {
- printer.printLine(mFrameLines[i]);
+ printer.printLine(mFrameLines[i].c_str());
}
}
diff --git a/libutils/String16_fuzz.cpp b/libutils/String16_fuzz.cpp
index a271aee..8f9781b 100644
--- a/libutils/String16_fuzz.cpp
+++ b/libutils/String16_fuzz.cpp
@@ -13,7 +13,9 @@
* See the License for the specific language governing permissions and
* limitations under the License.
*/
+#include <functional>
#include <iostream>
+#include <vector>
#include "fuzzer/FuzzedDataProvider.h"
#include "utils/String16.h"
diff --git a/libutils/String16_test.cpp b/libutils/String16_test.cpp
index c6e6f74..6f4642e 100644
--- a/libutils/String16_test.cpp
+++ b/libutils/String16_test.cpp
@@ -33,50 +33,50 @@
TEST(String16Test, FromChar16_t) {
String16 tmp(u"Verify me");
- EXPECT_STR16EQ(u"Verify me", tmp);
+ EXPECT_STR16EQ(u"Verify me", tmp.c_str());
}
TEST(String16Test, FromChar16_tSized) {
String16 tmp(u"Verify me", 7);
- EXPECT_STR16EQ(u"Verify ", tmp);
+ EXPECT_STR16EQ(u"Verify ", tmp.c_str());
}
TEST(String16Test, FromChar) {
String16 tmp("Verify me");
- EXPECT_STR16EQ(u"Verify me", tmp);
+ EXPECT_STR16EQ(u"Verify me", tmp.c_str());
}
TEST(String16Test, FromCharSized) {
String16 tmp("Verify me", 7);
- EXPECT_STR16EQ(u"Verify ", tmp);
+ EXPECT_STR16EQ(u"Verify ", tmp.c_str());
}
TEST(String16Test, Copy) {
String16 tmp("Verify me");
String16 another = tmp;
- EXPECT_STR16EQ(u"Verify me", tmp);
- EXPECT_STR16EQ(u"Verify me", another);
+ EXPECT_STR16EQ(u"Verify me", tmp.c_str());
+ EXPECT_STR16EQ(u"Verify me", another.c_str());
}
TEST(String16Test, CopyAssign) {
String16 tmp("Verify me");
String16 another;
another = tmp;
- EXPECT_STR16EQ(u"Verify me", tmp);
- EXPECT_STR16EQ(u"Verify me", another);
+ EXPECT_STR16EQ(u"Verify me", tmp.c_str());
+ EXPECT_STR16EQ(u"Verify me", another.c_str());
}
TEST(String16Test, Move) {
String16 tmp("Verify me");
String16 another(std::move(tmp));
- EXPECT_STR16EQ(u"Verify me", another);
+ EXPECT_STR16EQ(u"Verify me", another.c_str());
}
TEST(String16Test, MoveAssign) {
String16 tmp("Verify me");
String16 another;
another = std::move(tmp);
- EXPECT_STR16EQ(u"Verify me", another);
+ EXPECT_STR16EQ(u"Verify me", another.c_str());
}
TEST(String16Test, Size) {
@@ -88,27 +88,27 @@
String16 tmp("Verify me");
tmp.setTo(u"New content");
EXPECT_EQ(11U, tmp.size());
- EXPECT_STR16EQ(u"New content", tmp);
+ EXPECT_STR16EQ(u"New content", tmp.c_str());
}
TEST(String16Test, Append) {
String16 tmp("Verify me");
tmp.append(String16("Hello"));
EXPECT_EQ(14U, tmp.size());
- EXPECT_STR16EQ(u"Verify meHello", tmp);
+ EXPECT_STR16EQ(u"Verify meHello", tmp.c_str());
}
TEST(String16Test, Insert) {
String16 tmp("Verify me");
tmp.insert(6, u"Insert");
EXPECT_EQ(15U, tmp.size());
- EXPECT_STR16EQ(u"VerifyInsert me", tmp);
+ EXPECT_STR16EQ(u"VerifyInsert me", tmp.c_str());
}
TEST(String16Test, ReplaceAll) {
String16 tmp("Verify verify Verify");
tmp.replaceAll(u'r', u'!');
- EXPECT_STR16EQ(u"Ve!ify ve!ify Ve!ify", tmp);
+ EXPECT_STR16EQ(u"Ve!ify ve!ify Ve!ify", tmp.c_str());
}
TEST(String16Test, Compare) {
@@ -127,8 +127,8 @@
TEST(String16Test, StaticStringCopy) {
StaticString16 tmp(u"Verify me");
String16 another = tmp;
- EXPECT_STR16EQ(u"Verify me", tmp);
- EXPECT_STR16EQ(u"Verify me", another);
+ EXPECT_STR16EQ(u"Verify me", tmp.c_str());
+ EXPECT_STR16EQ(u"Verify me", another.c_str());
EXPECT_TRUE(tmp.isStaticString());
EXPECT_TRUE(another.isStaticString());
}
@@ -136,7 +136,7 @@
TEST(String16Test, StaticStringMove) {
StaticString16 tmp(u"Verify me");
String16 another(std::move(tmp));
- EXPECT_STR16EQ(u"Verify me", another);
+ EXPECT_STR16EQ(u"Verify me", another.c_str());
EXPECT_TRUE(another.isStaticString());
}
@@ -157,7 +157,7 @@
StaticString16 tmp(u"Verify me");
tmp.append(String16("Hello"));
EXPECT_EQ(14U, tmp.size());
- EXPECT_STR16EQ(u"Verify meHello", tmp);
+ EXPECT_STR16EQ(u"Verify meHello", tmp.c_str());
EXPECT_FALSE(tmp.isStaticString());
}
@@ -165,14 +165,14 @@
StaticString16 tmp(u"Verify me");
tmp.insert(6, u"Insert");
EXPECT_EQ(15U, tmp.size());
- EXPECT_STR16EQ(u"VerifyInsert me", tmp);
+ EXPECT_STR16EQ(u"VerifyInsert me", tmp.c_str());
EXPECT_FALSE(tmp.isStaticString());
}
TEST(String16Test, StaticStringReplaceAll) {
StaticString16 tmp(u"Verify verify Verify");
tmp.replaceAll(u'r', u'!');
- EXPECT_STR16EQ(u"Ve!ify ve!ify Ve!ify", tmp);
+ EXPECT_STR16EQ(u"Ve!ify ve!ify Ve!ify", tmp.c_str());
EXPECT_FALSE(tmp.isStaticString());
}
@@ -185,17 +185,17 @@
StaticString16 tmp(u"Verify me");
String16 another(u"nonstatic");
another = tmp;
- EXPECT_STR16EQ(u"Verify me", tmp);
- EXPECT_STR16EQ(u"Verify me", another);
+ EXPECT_STR16EQ(u"Verify me", tmp.c_str());
+ EXPECT_STR16EQ(u"Verify me", another.c_str());
}
TEST(String16Test, StringCopyAssignFromStaticString) {
StaticString16 tmp(u"Verify me");
String16 another(u"nonstatic");
another = tmp;
- EXPECT_STR16EQ(u"Verify me", another);
+ EXPECT_STR16EQ(u"Verify me", another.c_str());
EXPECT_TRUE(another.isStaticString());
- EXPECT_STR16EQ(u"Verify me", tmp);
+ EXPECT_STR16EQ(u"Verify me", tmp.c_str());
EXPECT_TRUE(tmp.isStaticString());
}
@@ -203,7 +203,7 @@
StaticString16 tmp(u"Verify me");
String16 another(u"nonstatic");
another = std::move(tmp);
- EXPECT_STR16EQ(u"Verify me", another);
+ EXPECT_STR16EQ(u"Verify me", another.c_str());
EXPECT_TRUE(another.isStaticString());
}
@@ -221,19 +221,19 @@
TEST(String16Test, ValidUtf8Conversion) {
String16 another("abcdef");
EXPECT_EQ(6U, another.size());
- EXPECT_STR16EQ(another, u"abcdef");
+ EXPECT_STR16EQ(another.c_str(), u"abcdef");
}
TEST(String16Test, append) {
String16 s;
EXPECT_EQ(OK, s.append(String16(u"foo")));
- EXPECT_STR16EQ(u"foo", s);
+ EXPECT_STR16EQ(u"foo", s.c_str());
EXPECT_EQ(OK, s.append(String16(u"bar")));
- EXPECT_STR16EQ(u"foobar", s);
+ EXPECT_STR16EQ(u"foobar", s.c_str());
EXPECT_EQ(OK, s.append(u"baz", 0));
- EXPECT_STR16EQ(u"foobar", s);
+ EXPECT_STR16EQ(u"foobar", s.c_str());
EXPECT_EQ(NO_MEMORY, s.append(u"baz", SIZE_MAX));
- EXPECT_STR16EQ(u"foobar", s);
+ EXPECT_STR16EQ(u"foobar", s.c_str());
}
TEST(String16Test, insert) {
@@ -241,19 +241,19 @@
// Inserting into the empty string inserts at the start.
EXPECT_EQ(OK, s.insert(123, u"foo"));
- EXPECT_STR16EQ(u"foo", s);
+ EXPECT_STR16EQ(u"foo", s.c_str());
// Inserting zero characters at any position is okay, but won't expand the string.
EXPECT_EQ(OK, s.insert(123, u"foo", 0));
- EXPECT_STR16EQ(u"foo", s);
+ EXPECT_STR16EQ(u"foo", s.c_str());
// Inserting past the end of a non-empty string appends.
EXPECT_EQ(OK, s.insert(123, u"bar"));
- EXPECT_STR16EQ(u"foobar", s);
+ EXPECT_STR16EQ(u"foobar", s.c_str());
EXPECT_EQ(OK, s.insert(3, u"!"));
- EXPECT_STR16EQ(u"foo!bar", s);
+ EXPECT_STR16EQ(u"foo!bar", s.c_str());
EXPECT_EQ(NO_MEMORY, s.insert(3, u"", SIZE_MAX));
- EXPECT_STR16EQ(u"foo!bar", s);
+ EXPECT_STR16EQ(u"foo!bar", s.c_str());
}
diff --git a/libutils/String8_test.cpp b/libutils/String8_test.cpp
index 9c12cb1..e1fd13a 100644
--- a/libutils/String8_test.cpp
+++ b/libutils/String8_test.cpp
@@ -100,19 +100,19 @@
TEST_F(String8Test, ValidUtf16Conversion) {
char16_t tmp[] = u"abcdef";
String8 valid = String8(String16(tmp));
- EXPECT_STREQ(valid, "abcdef");
+ EXPECT_STREQ(valid.c_str(), "abcdef");
}
TEST_F(String8Test, append) {
String8 s;
EXPECT_EQ(OK, s.append("foo"));
- EXPECT_STREQ("foo", s);
+ EXPECT_STREQ("foo", s.c_str());
EXPECT_EQ(OK, s.append("bar"));
- EXPECT_STREQ("foobar", s);
+ EXPECT_STREQ("foobar", s.c_str());
EXPECT_EQ(OK, s.append("baz", 0));
- EXPECT_STREQ("foobar", s);
+ EXPECT_STREQ("foobar", s.c_str());
EXPECT_EQ(NO_MEMORY, s.append("baz", SIZE_MAX));
- EXPECT_STREQ("foobar", s);
+ EXPECT_STREQ("foobar", s.c_str());
}
TEST_F(String8Test, removeAll) {
@@ -123,12 +123,12 @@
// expect to return true and string content should remain unchanged
EXPECT_TRUE(s.removeAll(""));
- EXPECT_STREQ("Hello, world!", s);
+ EXPECT_STREQ("Hello, world!", s.c_str());
// expect to return false
EXPECT_FALSE(s.removeAll("x"));
- EXPECT_STREQ("Hello, world!", s);
+ EXPECT_STREQ("Hello, world!", s.c_str());
EXPECT_TRUE(s.removeAll("o"));
- EXPECT_STREQ("Hell, wrld!", s);
+ EXPECT_STREQ("Hell, wrld!", s.c_str());
}
diff --git a/rootdir/init.rc b/rootdir/init.rc
index 487e5da..8eec16c 100644
--- a/rootdir/init.rc
+++ b/rootdir/init.rc
@@ -610,7 +610,6 @@
restorecon_recursive /metadata/apex
mkdir /metadata/staged-install 0770 root system
- mkdir /metadata/sepolicy 0700 root root
on late-fs
# Ensure that tracefs has the correct permissions.
# This does not work correctly if it is called in post-fs.
diff --git a/trusty/apploader/apploader.cpp b/trusty/apploader/apploader.cpp
index 17d083c..f782d2a 100644
--- a/trusty/apploader/apploader.cpp
+++ b/trusty/apploader/apploader.cpp
@@ -19,6 +19,7 @@
#include <BufferAllocator/BufferAllocator.h>
#include <android-base/logging.h>
#include <android-base/unique_fd.h>
+#include <assert.h>
#include <fcntl.h>
#include <getopt.h>
#include <stdbool.h>
diff --git a/trusty/keymaster/TEST_MAPPING b/trusty/keymaster/TEST_MAPPING
index 0475e04..4f082d8 100644
--- a/trusty/keymaster/TEST_MAPPING
+++ b/trusty/keymaster/TEST_MAPPING
@@ -10,13 +10,15 @@
"name": "RkpdAppUnitTests"
},
{
- "name": "RkpdAppGoogleUnitTests"
+ "name": "RkpdAppGoogleUnitTests",
+ "keywords": ["internal"]
},
{
"name": "RkpdAppIntegrationTests"
},
{
- "name": "RkpdAppGoogleIntegrationTests"
+ "name": "RkpdAppGoogleIntegrationTests",
+ "keywords": ["internal"]
}
]
}
diff --git a/trusty/stats/test/stats_test.cpp b/trusty/stats/test/stats_test.cpp
index 1edddeb..1d6eb34 100644
--- a/trusty/stats/test/stats_test.cpp
+++ b/trusty/stats/test/stats_test.cpp
@@ -252,20 +252,20 @@
::testing::AnyOf(::testing::Eq(TrustyAtoms::TrustyAppCrashed),
::testing::Eq(TrustyAtoms::TrustyError),
::testing::Eq(TrustyAtoms::TrustyStorageError)));
- ASSERT_STREQ(String8(vendorAtom.reverseDomainName), "google.android.trusty");
+ ASSERT_EQ(String8(vendorAtom.reverseDomainName), "google.android.trusty");
switch (vendorAtom.atomId) {
case TrustyAtoms::TrustyAppCrashed:
++atomAppCrashedCnt;
- ASSERT_STREQ(String8(vendorAtom.values[0].get<VendorAtomValue::stringValue>()),
- "5247d19b-cf09-4272-a450-3ef20dbefc14");
+ ASSERT_EQ(String8(vendorAtom.values[0].get<VendorAtomValue::stringValue>()),
+ "5247d19b-cf09-4272-a450-3ef20dbefc14");
break;
case TrustyAtoms::TrustyStorageError:
++atomStorageErrorCnt;
ASSERT_EQ(vendorAtom.values[0].get<VendorAtomValue::intValue>(), 5);
- ASSERT_STREQ(String8(vendorAtom.values[1].get<VendorAtomValue::stringValue>()),
- "5247d19b-cf09-4272-a450-3ef20dbefc14");
- ASSERT_STREQ(String8(vendorAtom.values[2].get<VendorAtomValue::stringValue>()),
- "5247d19b-cf09-4272-a450-3ef20dbefc14");
+ ASSERT_EQ(String8(vendorAtom.values[1].get<VendorAtomValue::stringValue>()),
+ "5247d19b-cf09-4272-a450-3ef20dbefc14");
+ ASSERT_EQ(String8(vendorAtom.values[2].get<VendorAtomValue::stringValue>()),
+ "5247d19b-cf09-4272-a450-3ef20dbefc14");
ASSERT_EQ(vendorAtom.values[3].get<VendorAtomValue::intValue>(), 1);
ASSERT_EQ(vendorAtom.values[4].get<VendorAtomValue::intValue>(), 3);
ASSERT_EQ(vendorAtom.values[5].get<VendorAtomValue::longValue>(),
@@ -330,13 +330,13 @@
::testing::AnyOf(::testing::Eq(TrustyAtoms::TrustyAppCrashed),
::testing::Eq(TrustyAtoms::TrustyError),
::testing::Eq(TrustyAtoms::TrustyStorageError)));
- ASSERT_STREQ(String8(vendorAtom.reverseDomainName), "google.android.trusty");
+ ASSERT_EQ(String8(vendorAtom.reverseDomainName), "google.android.trusty");
switch (vendorAtom.atomId) {
case TrustyAtoms::TrustyAppCrashed:
++atomAppCrashedCnt;
- ASSERT_STREQ(String8(vendorAtom.values[0].get<VendorAtomValue::stringValue>()),
- kTrustyCrasherUuid);
+ ASSERT_EQ(String8(vendorAtom.values[0].get<VendorAtomValue::stringValue>()),
+ kTrustyCrasherUuid);
atomCrashReasons.push_back(vendorAtom.values[1].get<VendorAtomValue::intValue>());
break;
case TrustyAtoms::TrustyStorageError:
@@ -344,7 +344,7 @@
break;
case TrustyAtoms::TrustyError:
++atomTrustyErrorCnt;
- ASSERT_STREQ(String8(vendorAtom.values[1].get<VendorAtomValue::stringValue>()), "");
+ ASSERT_EQ(String8(vendorAtom.values[1].get<VendorAtomValue::stringValue>()), "");
break;
default:
FAIL() << "Unknown vendor atom ID: " << vendorAtom.atomId;