Merge "Move staging value application logic to persistent_properties and add unit tests" into main
diff --git a/debuggerd/libdebuggerd/utility.cpp b/debuggerd/libdebuggerd/utility.cpp
index d71fc6c..15f09b3 100644
--- a/debuggerd/libdebuggerd/utility.cpp
+++ b/debuggerd/libdebuggerd/utility.cpp
@@ -382,8 +382,10 @@
return "SEGV_MTEAERR";
case SEGV_MTESERR:
return "SEGV_MTESERR";
+ case SEGV_CPERR:
+ return "SEGV_CPERR";
}
- static_assert(NSIGSEGV == SEGV_MTESERR, "missing SEGV_* si_code");
+ static_assert(NSIGSEGV == SEGV_CPERR, "missing SEGV_* si_code");
break;
case SIGSYS:
switch (si->si_code) {
diff --git a/fastboot/Android.bp b/fastboot/Android.bp
index 56cac88..f85d1de 100644
--- a/fastboot/Android.bp
+++ b/fastboot/Android.bp
@@ -446,3 +446,14 @@
host_supported: true,
export_include_dirs: ["."],
}
+
+python_test_host {
+ name: "fastboot_integration_test",
+ main: "test_fastboot.py",
+ srcs: ["test_fastboot.py"],
+ data: [":fastboot"],
+ test_config: "fastboot_integration_test.xml",
+ test_options: {
+ unit_test: false,
+ },
+}
diff --git a/fastboot/fastboot.cpp b/fastboot/fastboot.cpp
index 56b90b9..ac2a20f 100644
--- a/fastboot/fastboot.cpp
+++ b/fastboot/fastboot.cpp
@@ -1053,8 +1053,10 @@
return false;
}
sparse_file_destroy(s);
+ buf->file_type = FB_BUFFER_SPARSE;
} else {
buf->image_size = sz;
+ buf->file_type = FB_BUFFER_FD;
}
lseek(fd.get(), 0, SEEK_SET);
@@ -1191,6 +1193,15 @@
should_flash_in_userspace(source, partition)) {
return;
}
+
+ // If the image is sparse, moving the footer will simply corrupt the sparse
+ // format, so currently we don't support moving the footer on sparse files.
+ if (buf->file_type == FB_BUFFER_SPARSE) {
+ LOG(ERROR) << "Warning: skip copying " << partition << " image avb footer due to sparse "
+ << "image.";
+ return;
+ }
+
// If overflows and negative, it should be < buf->sz.
int64_t partition_size = static_cast<int64_t>(get_partition_size(partition));
diff --git a/fastboot/fastboot.h b/fastboot/fastboot.h
index 2c40890..6a49970 100644
--- a/fastboot/fastboot.h
+++ b/fastboot/fastboot.h
@@ -57,7 +57,8 @@
};
struct fastboot_buffer {
- enum fb_buffer_type type;
+ fb_buffer_type type;
+ fb_buffer_type file_type;
std::vector<SparsePtr> files;
int64_t sz;
unique_fd fd;
diff --git a/fastboot/fastboot_integration_test.xml b/fastboot/fastboot_integration_test.xml
new file mode 100644
index 0000000..ad14cab
--- /dev/null
+++ b/fastboot/fastboot_integration_test.xml
@@ -0,0 +1,19 @@
+<?xml version="1.0" encoding="utf-8"?>
+<!-- Copyright (C) 2023 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.
+-->
+<configuration description="Config to run fastboot integration tests">
+ <option name="test-suite-tag" value="fastboot_unittests" />
+ <test class="com.android.tradefed.testtype.python.PythonBinaryHostTest" >
+ <option name="par-file-name" value="fastboot_integration_test" />
+ <option name="test-timeout" value="1m" />
+ </test>
+</configuration>
\ No newline at end of file
diff --git a/fastboot/test_fastboot.py b/fastboot/test_fastboot.py
new file mode 100644
index 0000000..adcaec7
--- /dev/null
+++ b/fastboot/test_fastboot.py
@@ -0,0 +1,53 @@
+#!/usr/bin/env python3
+#
+# Copyright (C) 2023 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.
+#
+"""Tests for the fastboot command line utility.
+"""
+
+import re
+import subprocess
+import unittest
+
+
+class DevicesTest(unittest.TestCase):
+ """Tests for `fastboot devices`."""
+
+
+ def test_devices(self):
+ """Ensure that the format of `fastboot devices` does not change.
+
+ `fastboot devices` should alternate between a line containing the
+ device's serial number and fastboot state and an empty line
+ """
+ output = subprocess.check_output(["fastboot", "devices"])
+
+ previous_line_was_empty = True
+ for line in output.decode().splitlines():
+ if previous_line_was_empty:
+ if not re.match(r"[a-zA-Z\d]+\s+(bootloader|fastbootd)", line):
+ self.fail("%s does not match the expected format <serial no>\\s+(bootloader|fastbootd)" % line)
+ previous_line_was_empty = False
+ else:
+ if line:
+ self.fail("Expected an empty line. Received '%s'" % line)
+ previous_line_was_empty = True
+
+ if len(output) == 0:
+ self.fail("Output is empty. Are any devices connected?")
+
+
+if __name__ == '__main__':
+ unittest.main()
diff --git a/fs_mgr/fs_mgr_remount.cpp b/fs_mgr/fs_mgr_remount.cpp
index 18892f9..7ba4d2b 100644
--- a/fs_mgr/fs_mgr_remount.cpp
+++ b/fs_mgr/fs_mgr_remount.cpp
@@ -158,15 +158,25 @@
// not checkpointing.
auto vold = GetVold();
bool checkpointing = false;
- if (!vold->isCheckpointing(&checkpointing).isOk()) {
- LOG(ERROR) << "Could not determine checkpointing status.";
- return false;
- }
- if (checkpointing) {
- LOG(ERROR) << "Cannot use remount when a checkpoint is in progress.";
- LOG(ERROR) << "To force end checkpointing, call 'vdc checkpoint commitChanges'";
- LOG(ERROR) << "Warning: this can lead to data corruption if rolled back.";
- return false;
+ bool show_help = true;
+
+ while (true) {
+ if (!vold->isCheckpointing(&checkpointing).isOk()) {
+ LOG(ERROR) << "Could not determine checkpointing status.";
+ return false;
+ }
+ if (!checkpointing) {
+ break;
+ }
+ if (show_help) {
+ show_help = false;
+ std::cerr << "WARNING: Userdata checkpoint is in progress. To force end checkpointing, "
+ "call 'vdc checkpoint commitChanges'. This can lead to data corruption if "
+ "rolled back."
+ << std::endl;
+ LOG(INFO) << "Waiting for checkpoint to complete and then continue remount.";
+ }
+ std::this_thread::sleep_for(4s);
}
return true;
}
diff --git a/fs_mgr/fs_mgr_vendor_overlay.cpp b/fs_mgr/fs_mgr_vendor_overlay.cpp
index bacfa4b..6b742e5 100644
--- a/fs_mgr/fs_mgr_vendor_overlay.cpp
+++ b/fs_mgr/fs_mgr_vendor_overlay.cpp
@@ -112,6 +112,7 @@
// properties are loaded.
static const auto vndk_version = android::base::GetProperty(kVndkVersionPropertyName, "");
if (vndk_version.empty()) {
+ // Vendor overlay is disabled from VNDK deprecated devices.
LINFO << "vendor overlay: vndk version not defined";
return false;
}
diff --git a/fs_mgr/liblp/fuzzer/liblp_apis_fuzzer.cpp b/fs_mgr/liblp/fuzzer/liblp_apis_fuzzer.cpp
index b6fbc14..a15bc89 100644
--- a/fs_mgr/liblp/fuzzer/liblp_apis_fuzzer.cpp
+++ b/fs_mgr/liblp/fuzzer/liblp_apis_fuzzer.cpp
@@ -198,13 +198,13 @@
[&]() {
uint32_t groupVectorSize = metadata->groups.size();
uint32_t randomGroupIndex =
- mFdp.ConsumeIntegralInRange<uint32_t>(0, groupVectorSize);
+ mFdp.ConsumeIntegralInRange<uint32_t>(0, groupVectorSize - 1);
GetPartitionGroupName(metadata->groups[randomGroupIndex]);
},
[&]() {
uint32_t blockDeviceVectorSize = metadata->block_devices.size();
uint32_t randomBlockDeviceIndex =
- mFdp.ConsumeIntegralInRange<uint32_t>(0, blockDeviceVectorSize);
+ mFdp.ConsumeIntegralInRange<uint32_t>(0, blockDeviceVectorSize - 1);
GetBlockDevicePartitionName(
metadata->block_devices[randomBlockDeviceIndex]);
},
@@ -224,7 +224,7 @@
[&]() {
uint32_t partitionVectorSize = metadata->partitions.size();
uint32_t randomPartitionIndex =
- mFdp.ConsumeIntegralInRange<uint32_t>(0, partitionVectorSize);
+ mFdp.ConsumeIntegralInRange<uint32_t>(0, partitionVectorSize - 1);
GetPartitionName(metadata->partitions[randomPartitionIndex]);
},
[&]() { GetTotalSuperPartitionSize(metadataValue); },
diff --git a/fs_mgr/libsnapshot/include/libsnapshot/cow_reader.h b/fs_mgr/libsnapshot/include/libsnapshot/cow_reader.h
index 2721937..debaf36 100644
--- a/fs_mgr/libsnapshot/include/libsnapshot/cow_reader.h
+++ b/fs_mgr/libsnapshot/include/libsnapshot/cow_reader.h
@@ -172,7 +172,7 @@
android::base::unique_fd owned_fd_;
android::base::borrowed_fd fd_;
- CowHeader header_;
+ CowHeaderV3 header_;
std::optional<CowFooter> footer_;
uint64_t fd_size_;
std::optional<uint64_t> last_label_;
@@ -188,7 +188,10 @@
uint8_t compression_type_ = kCowCompressNone;
};
-bool ReadCowHeader(android::base::borrowed_fd fd, CowHeader* header);
+// Though this function takes in a CowHeaderV3, the struct could be populated as a v1/v2 CowHeader.
+// The extra fields will just be filled as 0. V3 header is strictly a superset of v1/v2 header and
+// contains all of the latter's field
+bool ReadCowHeader(android::base::borrowed_fd fd, CowHeaderV3* header);
} // namespace snapshot
} // namespace android
diff --git a/fs_mgr/libsnapshot/libsnapshot_cow/cow_reader.cpp b/fs_mgr/libsnapshot/libsnapshot_cow/cow_reader.cpp
index 607d610..3b84c95 100644
--- a/fs_mgr/libsnapshot/libsnapshot_cow/cow_reader.cpp
+++ b/fs_mgr/libsnapshot/libsnapshot_cow/cow_reader.cpp
@@ -28,12 +28,13 @@
#include <zlib.h>
#include "cow_decompress.h"
+#include "libsnapshot/cow_format.h"
#include "parser_v2.h"
namespace android {
namespace snapshot {
-bool ReadCowHeader(android::base::borrowed_fd fd, CowHeader* header) {
+bool ReadCowHeader(android::base::borrowed_fd fd, CowHeaderV3* header) {
if (lseek(fd.get(), 0, SEEK_SET) < 0) {
PLOG(ERROR) << "lseek header failed";
return false;
@@ -49,9 +50,9 @@
<< "Expected: " << kCowMagicNumber;
return false;
}
- if (header->prefix.header_size > sizeof(CowHeader)) {
+ if (header->prefix.header_size > sizeof(CowHeaderV3)) {
LOG(ERROR) << "Unknown CowHeader size (got " << header->prefix.header_size
- << " bytes, expected at most " << sizeof(CowHeader) << " bytes)";
+ << " bytes, expected at most " << sizeof(CowHeaderV3) << " bytes)";
return false;
}
diff --git a/fs_mgr/libsnapshot/libsnapshot_cow/inspect_cow.cpp b/fs_mgr/libsnapshot/libsnapshot_cow/inspect_cow.cpp
index 83b5a12..a291469 100644
--- a/fs_mgr/libsnapshot/libsnapshot_cow/inspect_cow.cpp
+++ b/fs_mgr/libsnapshot/libsnapshot_cow/inspect_cow.cpp
@@ -90,7 +90,7 @@
}
static bool ShowRawOpStream(borrowed_fd fd) {
- CowHeader header;
+ CowHeaderV3 header;
if (!ReadCowHeader(fd, &header)) {
LOG(ERROR) << "parse header failed";
return false;
diff --git a/fs_mgr/libsnapshot/libsnapshot_cow/test_v3.cpp b/fs_mgr/libsnapshot/libsnapshot_cow/test_v3.cpp
index 2373d4d..cc8dd83 100644
--- a/fs_mgr/libsnapshot/libsnapshot_cow/test_v3.cpp
+++ b/fs_mgr/libsnapshot/libsnapshot_cow/test_v3.cpp
@@ -26,7 +26,9 @@
#include <libsnapshot/cow_writer.h>
#include "cow_decompress.h"
#include "libsnapshot/cow_format.h"
+#include "writer_v2.h"
#include "writer_v3.h"
+
using android::base::unique_fd;
using testing::AssertionFailure;
using testing::AssertionResult;
@@ -49,5 +51,27 @@
std::unique_ptr<TemporaryFile> cow_;
};
+TEST_F(CowOperationV3Test, CowHeaderV2Test) {
+ CowOptions options;
+ options.cluster_ops = 5;
+ options.num_merge_ops = 1;
+ options.block_size = 4096;
+ std::string data = "This is some data, believe it";
+ data.resize(options.block_size, '\0');
+ auto writer_v2 = std::make_unique<CowWriterV2>(options, GetCowFd());
+ ASSERT_TRUE(writer_v2->Initialize());
+ ASSERT_TRUE(writer_v2->Finalize());
+
+ CowReader reader;
+ ASSERT_TRUE(reader.Parse(cow_->fd));
+
+ const auto& header = reader.GetHeader();
+ ASSERT_EQ(header.prefix.magic, kCowMagicNumber);
+ ASSERT_EQ(header.prefix.major_version, kCowVersionMajor);
+ ASSERT_EQ(header.prefix.minor_version, kCowVersionMinor);
+ ASSERT_EQ(header.block_size, options.block_size);
+ ASSERT_EQ(header.cluster_ops, options.cluster_ops);
+}
+
} // namespace snapshot
} // namespace android
\ No newline at end of file
diff --git a/fs_mgr/libsnapshot/libsnapshot_cow/writer_v2.cpp b/fs_mgr/libsnapshot/libsnapshot_cow/writer_v2.cpp
index 63bed07..83a9b1b 100644
--- a/fs_mgr/libsnapshot/libsnapshot_cow/writer_v2.cpp
+++ b/fs_mgr/libsnapshot/libsnapshot_cow/writer_v2.cpp
@@ -269,9 +269,11 @@
}
bool CowWriterV2::OpenForAppend(uint64_t label) {
- if (!ReadCowHeader(fd_, &header_)) {
+ CowHeaderV3 header_v3;
+ if (!ReadCowHeader(fd_, &header_v3)) {
return false;
}
+ header_ = header_v3;
CowParserV2 parser;
if (!parser.Parse(fd_, header_, {label})) {
diff --git a/fs_mgr/libsnapshot/snapshot.cpp b/fs_mgr/libsnapshot/snapshot.cpp
index f5732fc..c639e43 100644
--- a/fs_mgr/libsnapshot/snapshot.cpp
+++ b/fs_mgr/libsnapshot/snapshot.cpp
@@ -3513,6 +3513,11 @@
return Return::Error();
}
+ if (!android::fs_mgr::WaitForFile(cow_path, 6s)) {
+ LOG(ERROR) << "Timed out waiting for device to appear: " << cow_path;
+ return Return::Error();
+ }
+
if (it->second.using_snapuserd()) {
unique_fd fd(open(cow_path.c_str(), O_RDWR | O_CLOEXEC));
if (fd < 0) {
@@ -3658,7 +3663,7 @@
return nullptr;
}
- CowHeader header;
+ CowHeaderV3 header;
if (!ReadCowHeader(cow_fd, &header)) {
LOG(ERROR) << "OpenCompressedSnapshotWriter: read header failed";
return nullptr;
diff --git a/fs_mgr/tests/src/com/android/tests/vendoroverlay/VendorOverlayHostTest.java b/fs_mgr/tests/src/com/android/tests/vendoroverlay/VendorOverlayHostTest.java
index f08cab2..91f235c 100644
--- a/fs_mgr/tests/src/com/android/tests/vendoroverlay/VendorOverlayHostTest.java
+++ b/fs_mgr/tests/src/com/android/tests/vendoroverlay/VendorOverlayHostTest.java
@@ -21,10 +21,8 @@
import com.android.tradefed.testtype.junit4.BaseHostJUnit4Test;
import com.android.tradefed.util.CommandResult;
import com.android.tradefed.util.CommandStatus;
-
import java.util.regex.Matcher;
import java.util.regex.Pattern;
-
import org.junit.After;
import org.junit.Assert;
import org.junit.Assume;
@@ -38,9 +36,15 @@
@RunWith(DeviceJUnit4ClassRunner.class)
public class VendorOverlayHostTest extends BaseHostJUnit4Test {
boolean wasRoot = false;
+ String vndkVersion = null;
@Before
public void setup() throws DeviceNotAvailableException {
+ vndkVersion = getDevice().executeShellV2Command("getprop ro.vndk.version").getStdout();
+ Assume.assumeTrue(
+ "Vendor Overlay is disabled for VNDK deprecated devices",
+ vndkVersion != null && !vndkVersion.trim().isEmpty());
+
wasRoot = getDevice().isAdbRoot();
if (!wasRoot) {
Assume.assumeTrue("Test requires root", getDevice().enableAdbRoot());
@@ -74,8 +78,6 @@
*/
@Test
public void testVendorOverlay() throws DeviceNotAvailableException {
- String vndkVersion = getDevice().executeShellV2Command("getprop ro.vndk.version").getStdout();
-
// Create files and modify policy
CommandResult result = getDevice().executeShellV2Command(
"echo '/(product|system/product)/vendor_overlay/" + vndkVersion +
diff --git a/fs_mgr/tests/vts_fs_test.cpp b/fs_mgr/tests/vts_fs_test.cpp
index 32947b5..8f15220 100644
--- a/fs_mgr/tests/vts_fs_test.cpp
+++ b/fs_mgr/tests/vts_fs_test.cpp
@@ -32,6 +32,24 @@
return android::base::GetIntProperty("ro.vendor.api_level", -1);
}
+// Returns true iff the device has the specified feature.
+bool DeviceSupportsFeature(const char* feature) {
+ bool device_supports_feature = false;
+ FILE* p = popen("pm list features", "re");
+ if (p) {
+ char* line = NULL;
+ size_t len = 0;
+ while (getline(&line, &len, p) > 0) {
+ if (strstr(line, feature)) {
+ device_supports_feature = true;
+ break;
+ }
+ }
+ pclose(p);
+ }
+ return device_supports_feature;
+}
+
TEST(fs, ErofsSupported) {
// T-launch GKI kernels and higher must support EROFS.
if (GetVsrLevel() < __ANDROID_API_T__) {
@@ -82,7 +100,8 @@
ASSERT_TRUE(android::base::Readlink("/dev/block/by-name/userdata", &userdata_bdev));
std::vector<std::string> must_be_f2fs = {"/data"};
- if (vsr_level >= __ANDROID_API_U__) {
+ if (vsr_level >= __ANDROID_API_U__ &&
+ !DeviceSupportsFeature("android.hardware.type.automotive")) {
must_be_f2fs.emplace_back("/metadata");
}
diff --git a/init/property_service.cpp b/init/property_service.cpp
index 87fc4c7..bd74358 100644
--- a/init/property_service.cpp
+++ b/init/property_service.cpp
@@ -76,6 +76,10 @@
#include "system/core/init/property_service.pb.h"
#include "util.h"
+static constexpr char APPCOMPAT_OVERRIDE_PROP_FOLDERNAME[] =
+ "/dev/__properties__/appcompat_override";
+static constexpr char APPCOMPAT_OVERRIDE_PROP_TREE_FILE[] =
+ "/dev/__properties__/appcompat_override/property_info";
using namespace std::literals;
using android::base::ErrnoError;
@@ -1279,11 +1283,17 @@
return;
}
- constexpr static const char kPropertyInfosPath[] = "/dev/__properties__/property_info";
- if (!WriteStringToFile(serialized_contexts, kPropertyInfosPath, 0444, 0, 0, false)) {
+ if (!WriteStringToFile(serialized_contexts, PROP_TREE_FILE, 0444, 0, 0, false)) {
PLOG(ERROR) << "Unable to write serialized property infos to file";
}
- selinux_android_restorecon(kPropertyInfosPath, 0);
+ selinux_android_restorecon(PROP_TREE_FILE, 0);
+
+ mkdir(APPCOMPAT_OVERRIDE_PROP_FOLDERNAME, S_IRWXU | S_IXGRP | S_IXOTH);
+ if (!WriteStringToFile(serialized_contexts, APPCOMPAT_OVERRIDE_PROP_TREE_FILE, 0444, 0, 0,
+ false)) {
+ PLOG(ERROR) << "Unable to write vendor overrides to file";
+ }
+ selinux_android_restorecon(APPCOMPAT_OVERRIDE_PROP_TREE_FILE, 0);
}
static void ExportKernelBootProps() {
diff --git a/libutils/Android.bp b/libutils/Android.bp
index b3ddda3..4d4294b 100644
--- a/libutils/Android.bp
+++ b/libutils/Android.bp
@@ -68,13 +68,6 @@
"-Wno-exit-time-destructors",
"-DANDROID_UTILS_REF_BASE_DISABLE_IMPLICIT_CONSTRUCTION",
],
- header_libs: [
- "libbase_headers",
- "libutils_headers",
- ],
- export_header_lib_headers: [
- "libutils_headers",
- ],
shared_libs: [
"libcutils",
@@ -134,6 +127,14 @@
whole_static_libs: ["libutils_binder"],
+ header_libs: [
+ "libbase_headers",
+ "libutils_headers",
+ ],
+ export_header_lib_headers: [
+ "libutils_headers",
+ ],
+
srcs: [
"FileMap.cpp",
"JenkinsHash.cpp",
@@ -221,6 +222,14 @@
support_system_process: true,
},
+ header_libs: [
+ "libbase_headers",
+ "libutils_headers",
+ ],
+ export_header_lib_headers: [
+ "libutils_headers",
+ ],
+
srcs: [
"CallStack.cpp",
],
diff --git a/libutils/binder/Android.bp b/libutils/binder/Android.bp
index e2eddb3..a049f3d 100644
--- a/libutils/binder/Android.bp
+++ b/libutils/binder/Android.bp
@@ -10,6 +10,7 @@
],
native_bridge_supported: true,
+ export_include_dirs: ["include"],
srcs: [
"Errors.cpp",
"RefBase.cpp",
diff --git a/libutils/binder/RefBase.cpp b/libutils/binder/RefBase.cpp
index c7055fb..2d2e40b 100644
--- a/libutils/binder/RefBase.cpp
+++ b/libutils/binder/RefBase.cpp
@@ -20,8 +20,6 @@
#include <memory>
#include <mutex>
-#include <android-base/macros.h>
-
#include <fcntl.h>
#include <log/log.h>
@@ -57,15 +55,17 @@
// log all reference counting operations
#define PRINT_REFS 0
+#if !defined(ANDROID_UTILS_CALLSTACK_ENABLED)
#if defined(__linux__)
// CallStack is only supported on linux type platforms.
-#define CALLSTACK_ENABLED 1
+#define ANDROID_UTILS_CALLSTACK_ENABLED 1
#else
-#define CALLSTACK_ENABLED 0
-#endif
+#define ANDROID_UTILS_CALLSTACK_ENABLED 0
+#endif // defined(__linux__)
+#endif // !defined(ANDROID_UTILS_CALLSTACK_ENABLED)
-#if CALLSTACK_ENABLED
-#include <utils/CallStack.h>
+#if ANDROID_UTILS_CALLSTACK_ENABLED
+#include "../../include/utils/CallStack.h"
#endif
// ---------------------------------------------------------------------------
@@ -232,7 +232,7 @@
while (refs) {
char inc = refs->ref >= 0 ? '+' : '-';
ALOGD("\t%c ID %p (ref %d):", inc, refs->id, refs->ref);
-#if DEBUG_REFS_CALLSTACK_ENABLED && CALLSTACK_ENABLED
+#if DEBUG_REFS_CALLSTACK_ENABLED && ANDROID_UTILS_CALLSTACK_ENABLED
CallStack::logStack(LOG_TAG, refs->stack.get());
#endif
refs = refs->next;
@@ -246,7 +246,7 @@
while (refs) {
char inc = refs->ref >= 0 ? '+' : '-';
ALOGD("\t%c ID %p (ref %d):", inc, refs->id, refs->ref);
-#if DEBUG_REFS_CALLSTACK_ENABLED && CALLSTACK_ENABLED
+#if DEBUG_REFS_CALLSTACK_ENABLED && ANDROID_UTILS_CALLSTACK_ENABLED
CallStack::logStack(LOG_TAG, refs->stack.get());
#endif
refs = refs->next;
@@ -254,7 +254,7 @@
}
if (dumpStack) {
ALOGE("above errors at:");
-#if CALLSTACK_ENABLED
+#if ANDROID_UTILS_CALLSTACK_ENABLED
CallStack::logStack(LOG_TAG);
#endif
}
@@ -343,7 +343,7 @@
{
ref_entry* next;
const void* id;
-#if DEBUG_REFS_CALLSTACK_ENABLED && CALLSTACK_ENABLED
+#if DEBUG_REFS_CALLSTACK_ENABLED && ANDROID_UTILS_CALLSTACK_ENABLED
CallStack::CallStackUPtr stack;
#endif
int32_t ref;
@@ -360,7 +360,7 @@
// decrement the reference count.
ref->ref = mRef;
ref->id = id;
-#if DEBUG_REFS_CALLSTACK_ENABLED && CALLSTACK_ENABLED
+#if DEBUG_REFS_CALLSTACK_ENABLED && ANDROID_UTILS_CALLSTACK_ENABLED
ref->stack = CallStack::getCurrent(2);
#endif
ref->next = *refs;
@@ -396,7 +396,7 @@
ref = ref->next;
}
-#if CALLSTACK_ENABLED
+#if ANDROID_UTILS_CALLSTACK_ENABLED
CallStack::logStack(LOG_TAG);
#endif
}
@@ -424,7 +424,7 @@
snprintf(buf, sizeof(buf), "\t%c ID %p (ref %d):\n",
inc, refs->id, refs->ref);
out->append(buf);
-#if DEBUG_REFS_CALLSTACK_ENABLED && CALLSTACK_ENABLED
+#if DEBUG_REFS_CALLSTACK_ENABLED && ANDROID_UTILS_CALLSTACK_ENABLED
out->append(CallStack::stackToString("\t\t", refs->stack.get()));
#else
out->append("\t\t(call stacks disabled)");
@@ -536,7 +536,7 @@
case INITIAL_STRONG_VALUE:
refs->mStrong.fetch_sub(INITIAL_STRONG_VALUE,
std::memory_order_relaxed);
- FALLTHROUGH_INTENDED;
+ [[fallthrough]];
case 0:
refs->mBase->onFirstRef();
}
@@ -790,7 +790,7 @@
"object.",
mRefs->mWeak.load(), this);
-#if CALLSTACK_ENABLED
+#if ANDROID_UTILS_CALLSTACK_ENABLED
CallStack::logStack(LOG_TAG);
#endif
} else if (strongs != 0) {
diff --git a/libutils/binder/String8.cpp b/libutils/binder/String8.cpp
index 6a75484..749bfcb 100644
--- a/libutils/binder/String8.cpp
+++ b/libutils/binder/String8.cpp
@@ -19,7 +19,6 @@
#include <utils/String8.h>
-#include <utils/Compat.h>
#include <log/log.h>
#include <utils/String16.h>
@@ -430,6 +429,13 @@
// ---------------------------------------------------------------------------
// Path functions
+// TODO: we should remove all the path functions from String8
+#if defined(_WIN32)
+#define OS_PATH_SEPARATOR '\\'
+#else
+#define OS_PATH_SEPARATOR '/'
+#endif
+
String8 String8::getPathDir(void) const
{
const char* cp;
diff --git a/libutils/binder/Unicode.cpp b/libutils/binder/Unicode.cpp
index 364a177..2ed2d4f 100644
--- a/libutils/binder/Unicode.cpp
+++ b/libutils/binder/Unicode.cpp
@@ -16,7 +16,6 @@
#define LOG_TAG "unicode"
-#include <android-base/macros.h>
#include <limits.h>
#include <utils/Unicode.h>
@@ -92,11 +91,11 @@
switch (bytes)
{ /* note: everything falls through. */
case 4: *--dstP = (uint8_t)((srcChar | kByteMark) & kByteMask); srcChar >>= 6;
- FALLTHROUGH_INTENDED;
+ [[fallthrough]];
case 3: *--dstP = (uint8_t)((srcChar | kByteMark) & kByteMask); srcChar >>= 6;
- FALLTHROUGH_INTENDED;
+ [[fallthrough]];
case 2: *--dstP = (uint8_t)((srcChar | kByteMark) & kByteMask); srcChar >>= 6;
- FALLTHROUGH_INTENDED;
+ [[fallthrough]];
case 1: *--dstP = (uint8_t)(srcChar | kFirstByteMark[bytes]);
}
}
@@ -304,15 +303,15 @@
while (in < end) {
char16_t w = *in++;
- if (LIKELY(w < 0x0080)) {
+ if (w < 0x0080) [[likely]] {
utf8_len += 1;
continue;
}
- if (LIKELY(w < 0x0800)) {
+ if (w < 0x0800) [[likely]] {
utf8_len += 2;
continue;
}
- if (LIKELY(!is_any_surrogate(w))) {
+ if (!is_any_surrogate(w)) [[likely]] {
utf8_len += 3;
continue;
}
@@ -345,20 +344,20 @@
while (in < in_end) {
char16_t w = *in++;
- if (LIKELY(w < 0x0080)) {
+ if (w < 0x0080) [[likely]] {
if (out + 1 > out_end)
return err_out();
*out++ = (char)(w & 0xff);
continue;
}
- if (LIKELY(w < 0x0800)) {
+ if (w < 0x0800) [[likely]] {
if (out + 2 > out_end)
return err_out();
*out++ = (char)(0xc0 | ((w >> 6) & 0x1f));
*out++ = (char)(0x80 | ((w >> 0) & 0x3f));
continue;
}
- if (LIKELY(!is_any_surrogate(w))) {
+ if (!is_any_surrogate(w)) [[likely]] {
if (out + 3 > out_end)
return err_out();
*out++ = (char)(0xe0 | ((w >> 12) & 0xf));
@@ -420,25 +419,25 @@
while (in < in_end) {
uint8_t c = *in;
utf16_len++;
- if (LIKELY((c & 0x80) == 0)) {
+ if ((c & 0x80) == 0) [[likely]] {
in++;
continue;
}
- if (UNLIKELY(c < 0xc0)) {
+ if (c < 0xc0) [[unlikely]] {
ALOGW("Invalid UTF-8 leading byte: 0x%02x", c);
in++;
continue;
}
- if (LIKELY(c < 0xe0)) {
+ if (c < 0xe0) [[likely]] {
in += 2;
continue;
}
- if (LIKELY(c < 0xf0)) {
+ if (c < 0xf0) [[likely]] {
in += 3;
continue;
} else {
uint8_t c2, c3, c4;
- if (UNLIKELY(c >= 0xf8)) {
+ if (c >= 0xf8) [[unlikely]] {
ALOGW("Invalid UTF-8 leading byte: 0x%02x", c);
}
c2 = in[1]; c3 = in[2]; c4 = in[3];
@@ -487,25 +486,25 @@
while (in < in_end && out < out_end) {
c = *in++;
- if (LIKELY((c & 0x80) == 0)) {
+ if ((c & 0x80) == 0) [[likely]] {
*out++ = (char16_t)(c);
continue;
}
- if (UNLIKELY(c < 0xc0)) {
+ if (c < 0xc0) [[unlikely]] {
ALOGW("Invalid UTF-8 leading byte: 0x%02x", c);
*out++ = (char16_t)(c);
continue;
}
- if (LIKELY(c < 0xe0)) {
- if (UNLIKELY(in + 1 > in_end)) {
+ if (c < 0xe0) [[likely]] {
+ if (in + 1 > in_end) [[unlikely]] {
return err_in();
}
c2 = *in++;
*out++ = (char16_t)(((c & 0x1f) << 6) | (c2 & 0x3f));
continue;
}
- if (LIKELY(c < 0xf0)) {
- if (UNLIKELY(in + 2 > in_end)) {
+ if (c < 0xf0) [[likely]] {
+ if (in + 2 > in_end) [[unlikely]] {
return err_in();
}
c2 = *in++; c3 = *in++;
@@ -513,19 +512,19 @@
((c2 & 0x3f) << 6) | (c3 & 0x3f));
continue;
} else {
- if (UNLIKELY(in + 3 > in_end)) {
+ if (in + 3 > in_end) [[unlikely]] {
return err_in();
}
- if (UNLIKELY(c >= 0xf8)) {
+ if (c >= 0xf8) [[unlikely]] {
ALOGW("Invalid UTF-8 leading byte: 0x%02x", c);
}
// Multiple UTF16 characters with surrogates
c2 = *in++; c3 = *in++; c4 = *in++;
w = utf8_4b_to_utf32(c, c2, c3, c4);
- if (UNLIKELY(w < 0x10000)) {
+ if (w < 0x10000) [[unlikely]] {
*out++ = (char16_t)(w);
} else {
- if (UNLIKELY(out + 2 > out_end)) {
+ if (out + 2 > out_end) [[unlikely]] {
// Ooops.... not enough room for this surrogate pair.
return out;
}
diff --git a/libutils/include/utils/LightRefBase.h b/libutils/binder/include/utils/LightRefBase.h
similarity index 100%
rename from libutils/include/utils/LightRefBase.h
rename to libutils/binder/include/utils/LightRefBase.h
diff --git a/libutils/include/utils/TypeHelpers.h b/libutils/binder/include/utils/TypeHelpers.h
similarity index 100%
rename from libutils/include/utils/TypeHelpers.h
rename to libutils/binder/include/utils/TypeHelpers.h
diff --git a/libutils/include/utils/LightRefBase.h b/libutils/include/utils/LightRefBase.h
new file mode 120000
index 0000000..9da2cf0
--- /dev/null
+++ b/libutils/include/utils/LightRefBase.h
@@ -0,0 +1 @@
+../../binder/include/utils/LightRefBase.h
\ No newline at end of file
diff --git a/libutils/include/utils/TypeHelpers.h b/libutils/include/utils/TypeHelpers.h
new file mode 120000
index 0000000..848f6d7
--- /dev/null
+++ b/libutils/include/utils/TypeHelpers.h
@@ -0,0 +1 @@
+../../binder/include/utils/TypeHelpers.h
\ No newline at end of file
diff --git a/property_service/libpropertyinfoparser/include/property_info_parser/property_info_parser.h b/property_service/libpropertyinfoparser/include/property_info_parser/property_info_parser.h
index 0548021..65705ac 100644
--- a/property_service/libpropertyinfoparser/include/property_info_parser/property_info_parser.h
+++ b/property_service/libpropertyinfoparser/include/property_info_parser/property_info_parser.h
@@ -20,6 +20,8 @@
#include <stdint.h>
#include <stdlib.h>
+static constexpr char PROP_TREE_FILE[] = "/dev/__properties__/property_info";
+
namespace android {
namespace properties {