Merge "Create build target to pull adb test scripts."
diff --git a/adb/adb.cpp b/adb/adb.cpp
index 808d8ff..a7706a0 100644
--- a/adb/adb.cpp
+++ b/adb/adb.cpp
@@ -1140,6 +1140,7 @@
if (should_use_libusb()) {
features.insert(kFeatureLibusb);
}
+ features.insert(kFeaturePushSync);
SendOkay(reply_fd, FeatureSetToString(features));
return 0;
}
diff --git a/adb/bugreport.cpp b/adb/bugreport.cpp
index d0cc072..372a3b4 100644
--- a/adb/bugreport.cpp
+++ b/adb/bugreport.cpp
@@ -149,7 +149,7 @@
int progress = std::stoi(line.substr(idx1, (idx2 - idx1)));
int total = std::stoi(line.substr(idx2 + 1));
int progress_percentage = (progress * 100 / total);
- if (progress_percentage <= last_progress_percentage_) {
+ if (progress_percentage != 0 && progress_percentage <= last_progress_percentage_) {
// Ignore.
return;
}
diff --git a/adb/bugreport_test.cpp b/adb/bugreport_test.cpp
index 2b368d7..d3787b4 100644
--- a/adb/bugreport_test.cpp
+++ b/adb/bugreport_test.cpp
@@ -311,6 +311,29 @@
ASSERT_EQ(0, br_.DoIt(kTransportLocal, "HannibalLecter", 2, args));
}
+// Tests 'adb bugreport file.zip' when it succeeds and displays the initial progress of 0%
+TEST_F(BugreportTest, OkProgressZeroPercentIsNotIgnored) {
+ ExpectBugreportzVersion("1.1");
+ ExpectProgress(0);
+ ExpectProgress(1);
+ // clang-format off
+ EXPECT_CALL(br_, SendShellCommand(kTransportLocal, "HannibalLecter", "bugreportz -p", false, _))
+ // NOTE: DoAll accepts at most 10 arguments, and we're almost reached that limit...
+ .WillOnce(DoAll(
+ WithArg<4>(WriteOnStdout("BEGIN:/device/bugreport.zip\n")),
+ WithArg<4>(WriteOnStdout("PROGRESS:1/100000\n")),
+ WithArg<4>(WriteOnStdout("PROGRESS:1/100\n")), // 1%
+ WithArg<4>(WriteOnStdout("OK:/device/bugreport.zip")),
+ WithArg<4>(ReturnCallbackDone())));
+ // clang-format on
+ EXPECT_CALL(br_, DoSyncPull(ElementsAre(StrEq("/device/bugreport.zip")), StrEq("file.zip"),
+ true, StrEq("pulling file.zip")))
+ .WillOnce(Return(true));
+
+ const char* args[] = {"bugreport", "file.zip"};
+ ASSERT_EQ(0, br_.DoIt(kTransportLocal, "HannibalLecter", 2, args));
+}
+
// Tests 'adb bugreport dir' when it succeeds and destination is a directory.
TEST_F(BugreportTest, OkDirectory) {
ExpectBugreportzVersion("1.1");
diff --git a/adb/transport.cpp b/adb/transport.cpp
index 24e90cf..308ee8d 100644
--- a/adb/transport.cpp
+++ b/adb/transport.cpp
@@ -55,6 +55,7 @@
const char* const kFeatureCmd = "cmd";
const char* const kFeatureStat2 = "stat_v2";
const char* const kFeatureLibusb = "libusb";
+const char* const kFeaturePushSync = "push_sync";
static std::string dump_packet(const char* name, const char* func, apacket* p) {
unsigned command = p->msg.command;
diff --git a/adb/transport.h b/adb/transport.h
index 7304404..57fc988 100644
--- a/adb/transport.h
+++ b/adb/transport.h
@@ -51,6 +51,8 @@
extern const char* const kFeatureStat2;
// The server is running with libusb enabled.
extern const char* const kFeatureLibusb;
+// The server supports `push --sync`.
+extern const char* const kFeaturePushSync;
class atransport {
public:
diff --git a/bootstat/.clang-format b/bootstat/.clang-format
new file mode 120000
index 0000000..fd0645f
--- /dev/null
+++ b/bootstat/.clang-format
@@ -0,0 +1 @@
+../.clang-format-2
\ No newline at end of file
diff --git a/bootstat/bootstat.cpp b/bootstat/bootstat.cpp
index 6f25d96..d4e215e 100644
--- a/bootstat/bootstat.cpp
+++ b/bootstat/bootstat.cpp
@@ -221,19 +221,24 @@
}
}
-// Parses and records the set of bootloader stages and associated boot times
-// from the ro.boot.boottime system property.
-void RecordBootloaderTimings(BootEventRecordStore* boot_event_store) {
- // |ro.boot.boottime| is of the form 'stage1:time1,...,stageN:timeN'.
+// A map from bootloader timing stage to the time that stage took during boot.
+typedef std::map<std::string, int32_t> BootloaderTimingMap;
+
+// Returns a mapping from bootloader stage names to the time those stages
+// took to boot.
+const BootloaderTimingMap GetBootLoaderTimings() {
+ BootloaderTimingMap timings;
+
+ // |ro.boot.boottime| is of the form 'stage1:time1,...,stageN:timeN',
+ // where timeN is in milliseconds.
std::string value = GetProperty("ro.boot.boottime");
if (value.empty()) {
// ro.boot.boottime is not reported on all devices.
- return;
+ return BootloaderTimingMap();
}
- int32_t total_time = 0;
auto stages = android::base::Split(value, ",");
- for (auto const &stageTiming : stages) {
+ for (const auto& stageTiming : stages) {
// |stageTiming| is of the form 'stage:time'.
auto stageTimingValues = android::base::Split(stageTiming, ":");
DCHECK_EQ(2, stageTimingValues.size());
@@ -241,23 +246,53 @@
std::string stageName = stageTimingValues[0];
int32_t time_ms;
if (android::base::ParseInt(stageTimingValues[1], &time_ms)) {
- total_time += time_ms;
- boot_event_store->AddBootEventWithValue(
- "boottime.bootloader." + stageName, time_ms);
+ timings[stageName] = time_ms;
}
}
+ return timings;
+}
+
+// Parses and records the set of bootloader stages and associated boot times
+// from the ro.boot.boottime system property.
+void RecordBootloaderTimings(BootEventRecordStore* boot_event_store,
+ const BootloaderTimingMap& bootloader_timings) {
+ int32_t total_time = 0;
+ for (const auto& timing : bootloader_timings) {
+ total_time += timing.second;
+ boot_event_store->AddBootEventWithValue("boottime.bootloader." + timing.first, timing.second);
+ }
+
boot_event_store->AddBootEventWithValue("boottime.bootloader.total", total_time);
}
+// Records the closest estimation to the absolute device boot time, i.e.,
+// from power on to boot_complete, including bootloader times.
+void RecordAbsoluteBootTime(BootEventRecordStore* boot_event_store,
+ const BootloaderTimingMap& bootloader_timings,
+ std::chrono::milliseconds uptime) {
+ int32_t bootloader_time_ms = 0;
+
+ for (const auto& timing : bootloader_timings) {
+ if (timing.first.compare("SW") != 0) {
+ bootloader_time_ms += timing.second;
+ }
+ }
+
+ auto bootloader_duration = std::chrono::milliseconds(bootloader_time_ms);
+ auto absolute_total =
+ std::chrono::duration_cast<std::chrono::seconds>(bootloader_duration + uptime);
+ boot_event_store->AddBootEventWithValue("absolute_boot_time", absolute_total.count());
+}
+
// Records several metrics related to the time it takes to boot the device,
// including disambiguating boot time on encrypted or non-encrypted devices.
void RecordBootComplete() {
BootEventRecordStore boot_event_store;
BootEventRecordStore::BootEventRecord record;
- auto uptime = std::chrono::duration_cast<std::chrono::seconds>(
- android::base::boot_clock::now().time_since_epoch());
+ auto time_since_epoch = android::base::boot_clock::now().time_since_epoch();
+ auto uptime = std::chrono::duration_cast<std::chrono::seconds>(time_since_epoch);
time_t current_time_utc = time(nullptr);
if (boot_event_store.GetBootEvent("last_boot_time_utc", &record)) {
@@ -290,7 +325,6 @@
std::chrono::seconds boot_complete = std::chrono::seconds(uptime.count() - record.second);
boot_event_store.AddBootEventWithValue(boot_complete_prefix + "_post_decrypt",
boot_complete.count());
-
} else {
boot_event_store.AddBootEventWithValue(boot_complete_prefix + "_no_encryption",
uptime.count());
@@ -304,7 +338,11 @@
RecordInitBootTimeProp(&boot_event_store, "ro.boottime.init.selinux");
RecordInitBootTimeProp(&boot_event_store, "ro.boottime.init.cold_boot_wait");
- RecordBootloaderTimings(&boot_event_store);
+ const BootloaderTimingMap bootloader_timings = GetBootLoaderTimings();
+ RecordBootloaderTimings(&boot_event_store, bootloader_timings);
+
+ auto uptime_ms = std::chrono::duration_cast<std::chrono::milliseconds>(time_since_epoch);
+ RecordAbsoluteBootTime(&boot_event_store, bootloader_timings, uptime_ms);
}
// Records the boot_reason metric by querying the ro.boot.bootreason system
diff --git a/fs_mgr/fs_mgr.cpp b/fs_mgr/fs_mgr.cpp
index df3c300..73bdc7a 100644
--- a/fs_mgr/fs_mgr.cpp
+++ b/fs_mgr/fs_mgr.cpp
@@ -949,16 +949,20 @@
}
encryptable = FS_MGR_MNTALL_DEV_MIGHT_BE_ENCRYPTED;
} else {
+ // fs_options might be null so we cannot use PERROR << directly.
+ // Use StringPrintf to output "(null)" instead.
if (fs_mgr_is_nofail(&fstab->recs[attempted_idx])) {
- PERROR << "Ignoring failure to mount an un-encryptable or wiped partition on"
- << fstab->recs[attempted_idx].blk_device << " at "
- << fstab->recs[attempted_idx].mount_point << " options: "
- << fstab->recs[attempted_idx].fs_options;
+ PERROR << android::base::StringPrintf(
+ "Ignoring failure to mount an un-encryptable or wiped "
+ "partition on %s at %s options: %s",
+ fstab->recs[attempted_idx].blk_device, fstab->recs[attempted_idx].mount_point,
+ fstab->recs[attempted_idx].fs_options);
} else {
- PERROR << "Failed to mount an un-encryptable or wiped partition on"
- << fstab->recs[attempted_idx].blk_device << " at "
- << fstab->recs[attempted_idx].mount_point << " options: "
- << fstab->recs[attempted_idx].fs_options;
+ PERROR << android::base::StringPrintf(
+ "Failed to mount an un-encryptable or wiped partition "
+ "on %s at %s options: %s",
+ fstab->recs[attempted_idx].blk_device, fstab->recs[attempted_idx].mount_point,
+ fstab->recs[attempted_idx].fs_options);
++error_count;
}
continue;
diff --git a/init/property_service.cpp b/init/property_service.cpp
index 18e47e3..7fa37c8 100644
--- a/init/property_service.cpp
+++ b/init/property_service.cpp
@@ -443,7 +443,7 @@
}
}
-static void load_properties_from_file(const char *, const char *);
+static bool load_properties_from_file(const char *, const char *);
/*
* Filter is used to decide which properties to load: NULL loads all keys,
@@ -507,17 +507,18 @@
// Filter is used to decide which properties to load: NULL loads all keys,
// "ro.foo.*" is a prefix match, and "ro.foo.bar" is an exact match.
-static void load_properties_from_file(const char* filename, const char* filter) {
+static bool load_properties_from_file(const char* filename, const char* filter) {
Timer t;
std::string data;
std::string err;
if (!ReadFile(filename, &data, &err)) {
- PLOG(WARNING) << "Couldn't load property file: " << err;
- return;
+ PLOG(WARNING) << "Couldn't load property file: " << filename << ": " << err;
+ return false;
}
data.push_back('\n');
load_properties(&data[0], filter);
LOG(VERBOSE) << "(Loading properties from " << filename << " took " << t << ".)";
+ return true;
}
static void load_persistent_properties() {
@@ -592,16 +593,21 @@
}
void property_load_boot_defaults() {
- load_properties_from_file("/default.prop", NULL);
- load_properties_from_file("/odm/default.prop", NULL);
- load_properties_from_file("/vendor/default.prop", NULL);
+ if (!load_properties_from_file("/system/etc/prop.default", nullptr)) {
+ // for legacy devices
+ if (!load_properties_from_file("/default.prop", nullptr)) {
+ PLOG(ERROR) << "Failed to load default prop";
+ }
+ }
+ load_properties_from_file("/odm/etc/prop.default", nullptr);
+ load_properties_from_file("/vendor/etc/prop.default", nullptr);
update_sys_usb_config();
}
static void load_override_properties() {
if (ALLOW_LOCAL_PROP_OVERRIDE) {
- load_properties_from_file("/data/local.prop", NULL);
+ load_properties_from_file("/data/local.prop", nullptr);
}
}
@@ -649,9 +655,15 @@
}
void load_system_props() {
- load_properties_from_file("/system/build.prop", NULL);
- load_properties_from_file("/odm/build.prop", NULL);
- load_properties_from_file("/vendor/build.prop", NULL);
+ if (!load_properties_from_file("/system/etc/prop.build", nullptr)) {
+ // for legacy devices
+ load_properties_from_file("/system/build.prop", nullptr);
+ }
+ load_properties_from_file("/odm/etc/prop.build", nullptr);
+ if (!load_properties_from_file("/vendor/etc/prop.build", nullptr)) {
+ // for legacy devices
+ load_properties_from_file("/vendor/build.prop", nullptr);
+ }
load_properties_from_file("/factory/factory.prop", "ro.*");
load_recovery_id_prop();
}
diff --git a/libcutils/fs_config.cpp b/libcutils/fs_config.cpp
index 919b65b..dd1ad3a 100644
--- a/libcutils/fs_config.cpp
+++ b/libcutils/fs_config.cpp
@@ -134,9 +134,10 @@
{ 00640, AID_ROOT, AID_SHELL, 0, "data/nativetest64/tests.txt" },
{ 00750, AID_ROOT, AID_SHELL, 0, "data/nativetest/*" },
{ 00750, AID_ROOT, AID_SHELL, 0, "data/nativetest64/*" },
- { 00600, AID_ROOT, AID_ROOT, 0, "default.prop" },
- { 00600, AID_ROOT, AID_ROOT, 0, "odm/build.prop" },
- { 00600, AID_ROOT, AID_ROOT, 0, "odm/default.prop" },
+ { 00600, AID_ROOT, AID_ROOT, 0, "default.prop" }, // legacy
+ { 00600, AID_ROOT, AID_ROOT, 0, "system/etc/prop.default" },
+ { 00600, AID_ROOT, AID_ROOT, 0, "odm/etc/prop.build" },
+ { 00600, AID_ROOT, AID_ROOT, 0, "odm/etc/prop.default" },
{ 00444, AID_ROOT, AID_ROOT, 0, odm_conf_dir + 1 },
{ 00444, AID_ROOT, AID_ROOT, 0, odm_conf_file + 1 },
{ 00444, AID_ROOT, AID_ROOT, 0, oem_conf_dir + 1 },
@@ -148,7 +149,8 @@
{ 00750, AID_ROOT, AID_ROOT, 0, "system/bin/install-recovery.sh" },
{ 00700, AID_ROOT, AID_ROOT, 0, "system/bin/secilc" },
{ 00750, AID_ROOT, AID_ROOT, 0, "system/bin/uncrypt" },
- { 00600, AID_ROOT, AID_ROOT, 0, "system/build.prop" },
+ { 00600, AID_ROOT, AID_ROOT, 0, "system/build.prop" }, // legacy
+ { 00600, AID_ROOT, AID_ROOT, 0, "system/etc/prop.build" },
{ 00444, AID_ROOT, AID_ROOT, 0, sys_conf_dir + 1 },
{ 00444, AID_ROOT, AID_ROOT, 0, sys_conf_file + 1 },
{ 00440, AID_ROOT, AID_SHELL, 0, "system/etc/init.goldfish.rc" },
@@ -157,8 +159,9 @@
{ 00555, AID_ROOT, AID_ROOT, 0, "system/etc/ppp/*" },
{ 00555, AID_ROOT, AID_ROOT, 0, "system/etc/rc.*" },
{ 00440, AID_ROOT, AID_ROOT, 0, "system/etc/recovery.img" },
- { 00600, AID_ROOT, AID_ROOT, 0, "vendor/build.prop" },
- { 00600, AID_ROOT, AID_ROOT, 0, "vendor/default.prop" },
+ { 00600, AID_ROOT, AID_ROOT, 0, "vendor/build.prop" }, // legacy
+ { 00600, AID_ROOT, AID_ROOT, 0, "vendor/etc/prop.build" },
+ { 00600, AID_ROOT, AID_ROOT, 0, "vendor/etc/prop.default" },
{ 00444, AID_ROOT, AID_ROOT, 0, ven_conf_dir + 1 },
{ 00444, AID_ROOT, AID_ROOT, 0, ven_conf_file + 1 },
diff --git a/libcutils/include/private/android_filesystem_config.h b/libcutils/include/private/android_filesystem_config.h
index 48b50a5..02141d6 100644
--- a/libcutils/include/private/android_filesystem_config.h
+++ b/libcutils/include/private/android_filesystem_config.h
@@ -130,6 +130,7 @@
#define AID_MEDIA_OBB 1059 /* GID for OBB files on internal media storage */
#define AID_ESE 1060 /* embedded secure element (eSE) subsystem */
#define AID_OTA_UPDATE 1061 /* resource tracking UID for OTA updates */
+#define AID_AUTOMOTIVE_EVS 1062 /* Automotive rear and surround view system */
/* Changes to this file must be made in AOSP, *not* in internal branches. */
#define AID_SHELL 2000 /* adb and debug shell user */
diff --git a/liblog/tests/liblog_test.cpp b/liblog/tests/liblog_test.cpp
index ec32da0..71f74ab 100644
--- a/liblog/tests/liblog_test.cpp
+++ b/liblog/tests/liblog_test.cpp
@@ -36,6 +36,7 @@
#endif
#include <gtest/gtest.h>
#include <log/log_event_list.h>
+#include <log/log_properties.h>
#include <log/log_transport.h>
#include <log/logprint.h>
#include <private/android_filesystem_config.h>
@@ -1786,6 +1787,12 @@
stderr,
"WARNING: test conditions request being run as root and not AID=%d\n",
getuid());
+ if (!__android_log_is_debuggable()) {
+ fprintf(
+ stderr,
+ "WARNING: can not run test on a \"user\" build, bypassing test\n");
+ return;
+ }
}
system((getuid() == AID_ROOT) ? "stop logd" : "su 0 stop logd");
diff --git a/liblog/tests/log_read_test.cpp b/liblog/tests/log_read_test.cpp
index a63ab8e..6ed568a 100644
--- a/liblog/tests/log_read_test.cpp
+++ b/liblog/tests/log_read_test.cpp
@@ -23,6 +23,7 @@
#include <android-base/stringprintf.h>
#include <android/log.h> // minimal logging API
#include <gtest/gtest.h>
+#include <log/log_properties.h>
// Test the APIs in this standalone include file
#include <log/log_read.h>
// Do not use anything in log/log_time.h despite side effects of the above.
@@ -97,9 +98,12 @@
/* security buffer is allowed to be denied */
if (strcmp("security", name)) {
EXPECT_LT(0, get_log_size);
- /* crash buffer is allowed to be empty, that is actually healthy! */
- EXPECT_LE((strcmp("crash", name)) != 0,
- android_logger_get_log_readable_size(logger));
+ // crash buffer is allowed to be empty, that is actually healthy!
+ // kernel buffer is allowed to be empty on "user" builds
+ EXPECT_LE( // boolean 1 or 0 depending on expected content or empty
+ !!((strcmp("crash", name) != 0) &&
+ ((strcmp("kernel", name) != 0) || __android_log_is_debuggable())),
+ android_logger_get_log_readable_size(logger));
} else {
EXPECT_NE(0, get_log_size);
if (get_log_size < 0) {