Merge "logwrap: add missing O_CLOEXEC" into rvc-dev
diff --git a/adb/Android.bp b/adb/Android.bp
index fea8c78..af118f4 100644
--- a/adb/Android.bp
+++ b/adb/Android.bp
@@ -418,6 +418,12 @@
srcs: [
"daemon/usb_dummy.cpp",
]
+ },
+ recovery: {
+ exclude_shared_libs: [
+ "libadb_pairing_auth",
+ "libadb_pairing_connection",
+ ],
}
},
}
@@ -477,6 +483,10 @@
exclude_srcs: [
"daemon/abb_service.cpp",
],
+ exclude_shared_libs: [
+ "libadb_pairing_auth",
+ "libadb_pairing_connection",
+ ],
},
},
}
@@ -512,6 +522,15 @@
"libselinux",
],
+ target: {
+ recovery: {
+ exclude_shared_libs: [
+ "libadb_pairing_auth",
+ "libadb_pairing_connection",
+ ],
+ }
+ },
+
static_libs: [
"libadbd_services",
"libcutils_sockets",
@@ -544,6 +563,8 @@
},
static_libs: [
+ "libadb_crypto",
+ "libadb_tls_connection",
"libadbconnection_server",
"libadbd",
"libadbd_services",
@@ -561,15 +582,22 @@
],
shared_libs: [
- "libadb_crypto",
"libadb_pairing_connection",
"libadb_protos",
- "libadb_tls_connection",
"libadbd_auth",
"libadbd_fs",
"libcrypto",
],
+ target: {
+ recovery: {
+ exclude_shared_libs: [
+ "libadb_pairing_auth",
+ "libadb_pairing_connection",
+ ],
+ }
+ },
+
required: [
"libadbd_auth",
"libadbd_fs",
diff --git a/adb/crypto/Android.bp b/adb/crypto/Android.bp
index b7f75ed..ce1de4a 100644
--- a/adb/crypto/Android.bp
+++ b/adb/crypto/Android.bp
@@ -45,8 +45,6 @@
host_supported: true,
recovery_available: true,
- stl: "libc++_static",
-
shared_libs: [
"libadb_protos",
"libbase",
diff --git a/adb/pairing_auth/Android.bp b/adb/pairing_auth/Android.bp
index 0850047..a43f4d0 100644
--- a/adb/pairing_auth/Android.bp
+++ b/adb/pairing_auth/Android.bp
@@ -47,7 +47,7 @@
use_version_lib: false,
host_supported: true,
- recovery_available: true,
+ recovery_available: false,
stl: "libc++_static",
diff --git a/adb/pairing_connection/Android.bp b/adb/pairing_connection/Android.bp
index c053854..bcde7b1 100644
--- a/adb/pairing_connection/Android.bp
+++ b/adb/pairing_connection/Android.bp
@@ -52,7 +52,7 @@
stl: "libc++_static",
host_supported: true,
- recovery_available: true,
+ recovery_available: false,
static_libs: [
"libbase",
@@ -131,7 +131,7 @@
],
host_supported: true,
- recovery_available: true,
+ recovery_available: false,
stl: "libc++_static",
diff --git a/adb/tls/Android.bp b/adb/tls/Android.bp
index 49833ff..f2837e1 100644
--- a/adb/tls/Android.bp
+++ b/adb/tls/Android.bp
@@ -42,12 +42,8 @@
"//system/core/adb:__subpackages__",
],
- stl: "libc++_static",
-
- static_libs: [
- "libbase",
- ],
shared_libs: [
+ "libbase",
"libcrypto",
"liblog",
"libssl",
diff --git a/fs_mgr/fs_mgr.cpp b/fs_mgr/fs_mgr.cpp
index 8840e7d..7bc4559 100644
--- a/fs_mgr/fs_mgr.cpp
+++ b/fs_mgr/fs_mgr.cpp
@@ -512,8 +512,7 @@
// Enable casefold if needed.
static void tune_casefold(const std::string& blk_device, const struct ext4_super_block* sb,
int* fs_stat) {
- bool has_casefold =
- (sb->s_feature_ro_compat & cpu_to_le32(EXT4_FEATURE_INCOMPAT_CASEFOLD)) != 0;
+ bool has_casefold = (sb->s_feature_incompat & cpu_to_le32(EXT4_FEATURE_INCOMPAT_CASEFOLD)) != 0;
bool wants_casefold = android::base::GetBoolProperty("ro.emulated_storage.casefold", false);
if (!wants_casefold || has_casefold) return;
diff --git a/fs_mgr/fs_mgr_fstab.cpp b/fs_mgr/fs_mgr_fstab.cpp
index e4bb092..a36934a 100644
--- a/fs_mgr/fs_mgr_fstab.cpp
+++ b/fs_mgr/fs_mgr_fstab.cpp
@@ -30,6 +30,7 @@
#include <android-base/file.h>
#include <android-base/parseint.h>
+#include <android-base/properties.h>
#include <android-base/stringprintf.h>
#include <android-base/strings.h>
#include <libgsi/libgsi.h>
@@ -654,6 +655,21 @@
}
}
+void EnableMandatoryFlags(Fstab* fstab) {
+ // Devices launched in R and after should enable fs_verity on userdata. The flag causes tune2fs
+ // to enable the feature. A better alternative would be to enable on mkfs at the beginning.
+ if (android::base::GetIntProperty("ro.product.first_api_level", 0) >= 30) {
+ std::vector<FstabEntry*> data_entries = GetEntriesForMountPoint(fstab, "/data");
+ for (auto&& entry : data_entries) {
+ // Besides ext4, f2fs is also supported. But the image is already created with verity
+ // turned on when it was first introduced.
+ if (entry->fs_type == "ext4") {
+ entry->fs_mgr_flags.fs_verity = true;
+ }
+ }
+ }
+}
+
bool ReadFstabFromFile(const std::string& path, Fstab* fstab) {
auto fstab_file = std::unique_ptr<FILE, decltype(&fclose)>{fopen(path.c_str(), "re"), fclose};
if (!fstab_file) {
@@ -674,6 +690,7 @@
}
SkipMountingPartitions(fstab);
+ EnableMandatoryFlags(fstab);
return true;
}
diff --git a/init/reboot.cpp b/init/reboot.cpp
index 048c1e7..08b99ab 100644
--- a/init/reboot.cpp
+++ b/init/reboot.cpp
@@ -96,8 +96,10 @@
return ret;
}
-static void PersistRebootReason(const char* reason) {
- SetProperty(LAST_REBOOT_REASON_PROPERTY, reason);
+static void PersistRebootReason(const char* reason, bool write_to_property) {
+ if (write_to_property) {
+ SetProperty(LAST_REBOOT_REASON_PROPERTY, reason);
+ }
WriteStringToFile(reason, LAST_REBOOT_REASON_FILE);
}
@@ -535,14 +537,6 @@
Timer t;
LOG(INFO) << "Reboot start, reason: " << reason << ", reboot_target: " << reboot_target;
- // If /data isn't mounted then we can skip the extra reboot steps below, since we don't need to
- // worry about unmounting it.
- if (!IsDataMounted()) {
- sync();
- RebootSystem(cmd, reboot_target);
- abort();
- }
-
// Ensure last reboot reason is reduced to canonical
// alias reported in bootloader or system boot reason.
size_t skip = 0;
@@ -552,9 +546,17 @@
reasons[1] == "hard" || reasons[1] == "warm")) {
skip = strlen("reboot,");
}
- PersistRebootReason(reason.c_str() + skip);
+ PersistRebootReason(reason.c_str() + skip, true);
sync();
+ // If /data isn't mounted then we can skip the extra reboot steps below, since we don't need to
+ // worry about unmounting it.
+ if (!IsDataMounted()) {
+ sync();
+ RebootSystem(cmd, reboot_target);
+ abort();
+ }
+
bool is_thermal_shutdown = cmd == ANDROID_RB_THERMOFF;
auto shutdown_timeout = 0ms;
@@ -833,7 +835,8 @@
if (!WaitForProperty("sys.boot_completed", "1", timeout)) {
LOG(ERROR) << "Failed to boot in " << timeout.count() << "ms. Switching to full reboot";
// In this case device is in a boot loop. Only way to recover is to do dirty reboot.
- PersistRebootReason("userspace_failed,watchdog_triggered");
+ // Since init might be wedged, don't try to write reboot reason into a persistent property.
+ PersistRebootReason("userspace_failed,watchdog_triggered", false);
RebootSystem(ANDROID_RB_RESTART2, "userspace_failed,watchdog_triggered");
}
LOG(INFO) << "Device booted, stopping userspace reboot watchdog";
diff --git a/libstats/pull/Android.bp b/libstats/pull/Android.bp
index d74a36b..1a9cb92 100644
--- a/libstats/pull/Android.bp
+++ b/libstats/pull/Android.bp
@@ -17,8 +17,8 @@
// ==========================================================
// Native library to register a pull atom callback with statsd
// ==========================================================
-cc_library_shared {
- name: "libstatspull",
+cc_defaults {
+ name: "libstatspull_defaults",
srcs: [
"stats_pull_atom_callback.cpp",
],
@@ -31,12 +31,16 @@
"libbinder_ndk",
"liblog",
"statsd-aidl-ndk_platform",
+ "libstatssocket",
],
static_libs: [
"libutils",
- // TODO(b/149340100): Clean this up when libstatssocket is moved to the apex.
- "libstatssocket",
- "libcutils",
+ ],
+}
+cc_library_shared {
+ name: "libstatspull",
+ defaults: [
+ "libstatspull_defaults"
],
// enumerate stable entry points for APEX use
stubs: {
@@ -50,3 +54,14 @@
"test_com.android.os.statsd",
],
}
+
+// ONLY USE IN TESTS.
+cc_library_static {
+ name: "libstatspull_private",
+ defaults: [
+ "libstatspull_defaults",
+ ],
+ visibility: [
+ "//frameworks/base/apex/statsd/tests/libstatspull",
+ ],
+}
diff --git a/libstats/socket/Android.bp b/libstats/socket/Android.bp
index 437879b..b02ab42 100644
--- a/libstats/socket/Android.bp
+++ b/libstats/socket/Android.bp
@@ -17,23 +17,43 @@
// =========================================================================
// Native library to write stats log to statsd socket on Android R and later
// =========================================================================
-cc_library {
- name: "libstatssocket",
+cc_defaults {
+ name: "libstatssocket_defaults",
srcs: [
"stats_buffer_writer.c",
"stats_event.c",
"stats_socket.c",
"statsd_writer.c",
],
- host_supported: true,
- cflags: [
- "-Wall",
- "-Werror",
- ],
export_include_dirs: ["include"],
static_libs: [
"libcutils", // does not expose a stable C API
],
+ cflags: [
+ "-Wall",
+ "-Werror",
+ ],
+}
+
+cc_library {
+ name: "libstatssocket",
+ defaults: [
+ "libstatssocket_defaults",
+ ],
+ host_supported: true,
+ target: {
+ // On android, libstatssocket should only be linked as a shared lib
+ android: {
+ static: {
+ enabled: false,
+ },
+ },
+ host: {
+ shared: {
+ enabled: false,
+ },
+ },
+ },
// enumerate stable entry points for APEX use
stubs: {
@@ -43,13 +63,23 @@
],
},
apex_available: [
- //TODO(b/149340100): Remove this once libstatssocket is only linked as shared.
- "//apex_available:platform",
"com.android.os.statsd",
"test_com.android.os.statsd",
],
}
+//TODO (b/149842105): Figure out if there is a better solution for this.
+cc_test_library {
+ name: "libstatssocket_private",
+ defaults: [
+ "libstatssocket_defaults",
+ ],
+ visibility: [
+ "//frameworks/base/apex/statsd/tests/libstatspull",
+ "//frameworks/base/cmds/statsd",
+ ],
+}
+
cc_library_headers {
name: "libstatssocket_headers",
export_include_dirs: ["include"],
@@ -67,7 +97,7 @@
"-Werror",
],
static_libs: [
- "libstatssocket",
+ "libstatssocket_private",
],
shared_libs: [
"libcutils",
@@ -84,7 +114,7 @@
],
static_libs: [
"libgmock",
- "libstatssocket",
+ "libstatssocket_private",
],
shared_libs: [
"libcutils",