Merge "Load {default,build}.prop from /{system,vendor,odm}/etc/"
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/client/main.cpp b/adb/client/main.cpp
index bd9ad01..62798cd 100644
--- a/adb/client/main.cpp
+++ b/adb/client/main.cpp
@@ -125,6 +125,11 @@
});
#endif
+ if (is_daemon) {
+ close_stdin();
+ setup_daemon_logging();
+ }
+
android::base::at_quick_exit(adb_server_cleanup);
init_transport_registration();
@@ -148,11 +153,6 @@
std::this_thread::sleep_for(100ms);
}
- if (is_daemon) {
- close_stdin();
- setup_daemon_logging();
- }
-
adb_auth_init();
if (is_daemon) {
diff --git a/adb/transport.cpp b/adb/transport.cpp
index 13cfaa1..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;
@@ -1050,27 +1051,24 @@
[usb](atransport* t) { return t->usb == usb && t->GetConnectionState() == kCsNoPerm; });
}
-int check_header(apacket* p, atransport* t) {
+bool check_header(apacket* p, atransport* t) {
if (p->msg.magic != (p->msg.command ^ 0xffffffff)) {
VLOG(RWX) << "check_header(): invalid magic command = " << std::hex << p->msg.command
<< ", magic = " << p->msg.magic;
- return -1;
+ return false;
}
if (p->msg.data_length > t->get_max_payload()) {
VLOG(RWX) << "check_header(): " << p->msg.data_length
<< " atransport::max_payload = " << t->get_max_payload();
- return -1;
+ return false;
}
- return 0;
+ return true;
}
-int check_data(apacket* p) {
- if (calculate_apacket_checksum(p) != p->msg.data_check) {
- return -1;
- }
- return 0;
+bool check_data(apacket* p) {
+ return calculate_apacket_checksum(p) == p->msg.data_check;
}
#if ADB_HOST
diff --git a/adb/transport.h b/adb/transport.h
index 006aaf4..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:
@@ -221,8 +223,8 @@
// This should only be used for transports with connection_state == kCsNoPerm.
void unregister_usb_transport(usb_handle* usb);
-int check_header(apacket* p, atransport* t);
-int check_data(apacket* p);
+bool check_header(apacket* p, atransport* t);
+bool check_data(apacket* p);
void close_usb_devices();
void close_usb_devices(std::function<bool(const atransport*)> predicate);
diff --git a/adb/transport_local.cpp b/adb/transport_local.cpp
index 3ee286a..a9e583f 100644
--- a/adb/transport_local.cpp
+++ b/adb/transport_local.cpp
@@ -62,22 +62,22 @@
static int remote_read(apacket *p, atransport *t)
{
- if(!ReadFdExactly(t->sfd, &p->msg, sizeof(amessage))){
+ if (!ReadFdExactly(t->sfd, &p->msg, sizeof(amessage))) {
D("remote local: read terminated (message)");
return -1;
}
- if(check_header(p, t)) {
+ if (!check_header(p, t)) {
D("bad header: terminated (data)");
return -1;
}
- if(!ReadFdExactly(t->sfd, p->data, p->msg.data_length)){
+ if (!ReadFdExactly(t->sfd, p->data, p->msg.data_length)) {
D("remote local: terminated (data)");
return -1;
}
- if(check_data(p)) {
+ if (!check_data(p)) {
D("bad data: terminated (data)");
return -1;
}
diff --git a/adb/transport_usb.cpp b/adb/transport_usb.cpp
index 885d723..47094b8 100644
--- a/adb/transport_usb.cpp
+++ b/adb/transport_usb.cpp
@@ -72,7 +72,7 @@
D("remote usb: read terminated (message)");
return -1;
}
- if (static_cast<size_t>(n) != sizeof(p->msg) || check_header(p, t)) {
+ if (static_cast<size_t>(n) != sizeof(p->msg) || !check_header(p, t)) {
D("remote usb: check_header failed, skip it");
goto err_msg;
}
@@ -95,7 +95,7 @@
goto err_msg;
}
}
- if (check_data(p)) {
+ if (!check_data(p)) {
D("remote usb: check_data failed, skip it");
goto err_msg;
}
@@ -124,19 +124,19 @@
return -1;
}
- if(check_header(p, t)) {
+ if (!check_header(p, t)) {
D("remote usb: check_header failed");
return -1;
}
- if(p->msg.data_length) {
+ if (p->msg.data_length) {
if (usb_read(t->usb, p->data, p->msg.data_length)) {
D("remote usb: terminated (data)");
return -1;
}
}
- if(check_data(p)) {
+ if (!check_data(p)) {
D("remote usb: check_data failed");
return -1;
}
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/debuggerd/Android.bp b/debuggerd/Android.bp
index 37d54d7..3a80b50 100644
--- a/debuggerd/Android.bp
+++ b/debuggerd/Android.bp
@@ -11,12 +11,32 @@
local_include_dirs: ["include"],
}
-// Utility library to tombstoned and get an output fd.
-cc_library_static {
+cc_library_shared {
name: "libtombstoned_client",
defaults: ["debuggerd_defaults"],
srcs: [
- "tombstoned_client.cpp",
+ "tombstoned/tombstoned_client.cpp",
+ "util.cpp",
+ ],
+
+ static_libs: [
+ "libasync_safe"
+ ],
+
+ shared_libs: [
+ "libcutils",
+ "libbase",
+ ],
+
+ export_include_dirs: ["tombstoned/include"]
+}
+
+// Utility library to tombstoned and get an output fd.
+cc_library_static {
+ name: "libtombstoned_client_static",
+ defaults: ["debuggerd_defaults"],
+ srcs: [
+ "tombstoned/tombstoned_client.cpp",
"util.cpp",
],
@@ -25,6 +45,8 @@
"libcutils",
"libbase",
],
+
+ export_include_dirs: ["tombstoned/include"]
}
// Core implementation, linked into libdebuggerd_handler and the dynamic linker.
@@ -64,7 +86,7 @@
whole_static_libs: [
"libdebuggerd_handler_core",
- "libtombstoned_client",
+ "libtombstoned_client_static",
"libasync_safe",
"libbase",
"libdebuggerd",
@@ -159,10 +181,8 @@
srcs: [
"client/debuggerd_client_test.cpp",
"debuggerd_test.cpp",
- "tombstoned_client.cpp",
- "util.cpp"
],
- static_libs: ["libasync_safe"],
+ static_libs: ["libasync_safe", "libtombstoned_client_static"],
},
},
@@ -171,6 +191,7 @@
"libbase",
"libcutils",
"libdebuggerd_client",
+ "liblog"
],
static_libs: [
@@ -211,7 +232,7 @@
},
static_libs: [
- "libtombstoned_client",
+ "libtombstoned_client_static",
"libdebuggerd",
"libcutils",
],
diff --git a/debuggerd/client/debuggerd_client.cpp b/debuggerd/client/debuggerd_client.cpp
index 2be13c6..4ce038c 100644
--- a/debuggerd/client/debuggerd_client.cpp
+++ b/debuggerd/client/debuggerd_client.cpp
@@ -31,9 +31,10 @@
#include <android-base/stringprintf.h>
#include <android-base/unique_fd.h>
#include <cutils/sockets.h>
-#include <debuggerd/handler.h>
-#include <debuggerd/protocol.h>
-#include <debuggerd/util.h>
+
+#include "debuggerd/handler.h"
+#include "protocol.h"
+#include "util.h"
using namespace std::chrono_literals;
diff --git a/debuggerd/client/debuggerd_client_test.cpp b/debuggerd/client/debuggerd_client_test.cpp
index aff03e5..8f97db1 100644
--- a/debuggerd/client/debuggerd_client_test.cpp
+++ b/debuggerd/client/debuggerd_client_test.cpp
@@ -31,7 +31,7 @@
#include <android-base/strings.h>
#include <android-base/unique_fd.h>
-#include <debuggerd/util.h>
+#include "util.h"
using namespace std::chrono_literals;
using android::base::unique_fd;
diff --git a/debuggerd/crash_dump.cpp b/debuggerd/crash_dump.cpp
index d2a4239..be28079 100644
--- a/debuggerd/crash_dump.cpp
+++ b/debuggerd/crash_dump.cpp
@@ -48,9 +48,9 @@
#include "utility.h"
#include "debuggerd/handler.h"
-#include "debuggerd/protocol.h"
-#include "debuggerd/tombstoned.h"
-#include "debuggerd/util.h"
+#include "protocol.h"
+#include "tombstoned/tombstoned.h"
+#include "util.h"
using android::base::unique_fd;
using android::base::ReadFileToString;
diff --git a/debuggerd/debuggerd.cpp b/debuggerd/debuggerd.cpp
index 492e9f0..4997dd6 100644
--- a/debuggerd/debuggerd.cpp
+++ b/debuggerd/debuggerd.cpp
@@ -27,8 +27,8 @@
#include <android-base/parseint.h>
#include <android-base/unique_fd.h>
#include <debuggerd/client.h>
-#include <debuggerd/util.h>
#include <selinux/selinux.h>
+#include "util.h"
using android::base::unique_fd;
diff --git a/debuggerd/debuggerd_test.cpp b/debuggerd/debuggerd_test.cpp
index 0b4bbfb..f17724a 100644
--- a/debuggerd/debuggerd_test.cpp
+++ b/debuggerd/debuggerd_test.cpp
@@ -35,12 +35,13 @@
#include <android-base/strings.h>
#include <android-base/unique_fd.h>
#include <cutils/sockets.h>
-#include <debuggerd/handler.h>
-#include <debuggerd/protocol.h>
-#include <debuggerd/tombstoned.h>
-#include <debuggerd/util.h>
#include <gtest/gtest.h>
+#include "debuggerd/handler.h"
+#include "protocol.h"
+#include "tombstoned/tombstoned.h"
+#include "util.h"
+
using namespace std::chrono_literals;
using android::base::unique_fd;
diff --git a/debuggerd/handler/debuggerd_fallback.cpp b/debuggerd/handler/debuggerd_fallback.cpp
index 47c98d1..a9c9862 100644
--- a/debuggerd/handler/debuggerd_fallback.cpp
+++ b/debuggerd/handler/debuggerd_fallback.cpp
@@ -42,8 +42,8 @@
#include <async_safe/log.h>
#include "debuggerd/handler.h"
-#include "debuggerd/tombstoned.h"
-#include "debuggerd/util.h"
+#include "tombstoned/tombstoned.h"
+#include "util.h"
#include "backtrace.h"
#include "tombstone.h"
diff --git a/debuggerd/include/debuggerd/protocol.h b/debuggerd/protocol.h
similarity index 100%
rename from debuggerd/include/debuggerd/protocol.h
rename to debuggerd/protocol.h
diff --git a/debuggerd/include/debuggerd/tombstoned.h b/debuggerd/tombstoned/include/tombstoned/tombstoned.h
similarity index 100%
rename from debuggerd/include/debuggerd/tombstoned.h
rename to debuggerd/tombstoned/include/tombstoned/tombstoned.h
diff --git a/debuggerd/tombstoned/intercept_manager.cpp b/debuggerd/tombstoned/intercept_manager.cpp
index dff942c..4d4eb9e 100644
--- a/debuggerd/tombstoned/intercept_manager.cpp
+++ b/debuggerd/tombstoned/intercept_manager.cpp
@@ -28,8 +28,8 @@
#include <android-base/unique_fd.h>
#include <cutils/sockets.h>
-#include "debuggerd/protocol.h"
-#include "debuggerd/util.h"
+#include "protocol.h"
+#include "util.h"
using android::base::unique_fd;
diff --git a/debuggerd/tombstoned/tombstoned.cpp b/debuggerd/tombstoned/tombstoned.cpp
index 80dbef5..05df9f2 100644
--- a/debuggerd/tombstoned/tombstoned.cpp
+++ b/debuggerd/tombstoned/tombstoned.cpp
@@ -35,8 +35,8 @@
#include <cutils/sockets.h>
#include "debuggerd/handler.h"
-#include "debuggerd/protocol.h"
-#include "debuggerd/util.h"
+#include "protocol.h"
+#include "util.h"
#include "intercept_manager.h"
diff --git a/debuggerd/tombstoned_client.cpp b/debuggerd/tombstoned/tombstoned_client.cpp
similarity index 96%
rename from debuggerd/tombstoned_client.cpp
rename to debuggerd/tombstoned/tombstoned_client.cpp
index e878b6a..39dc6eb 100644
--- a/debuggerd/tombstoned_client.cpp
+++ b/debuggerd/tombstoned/tombstoned_client.cpp
@@ -14,7 +14,7 @@
* limitations under the License.
*/
-#include "debuggerd/tombstoned.h"
+#include "tombstoned/tombstoned.h"
#include <fcntl.h>
#include <unistd.h>
@@ -25,8 +25,8 @@
#include <async_safe/log.h>
#include <cutils/sockets.h>
-#include "debuggerd/protocol.h"
-#include "debuggerd/util.h"
+#include "protocol.h"
+#include "util.h"
using android::base::unique_fd;
diff --git a/debuggerd/util.cpp b/debuggerd/util.cpp
index 32d2f18..c6a997b 100644
--- a/debuggerd/util.cpp
+++ b/debuggerd/util.cpp
@@ -14,7 +14,7 @@
* limitations under the License.
*/
-#include "debuggerd/util.h"
+#include "util.h"
#include <sys/socket.h>
@@ -22,7 +22,7 @@
#include <android-base/unique_fd.h>
#include <cutils/sockets.h>
-#include <debuggerd/protocol.h>
+#include "protocol.h"
using android::base::unique_fd;
diff --git a/debuggerd/include/debuggerd/util.h b/debuggerd/util.h
similarity index 100%
rename from debuggerd/include/debuggerd/util.h
rename to debuggerd/util.h
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/Android.bp b/init/Android.bp
new file mode 100644
index 0000000..80d5c42
--- /dev/null
+++ b/init/Android.bp
@@ -0,0 +1,164 @@
+//
+// Copyright (C) 2017 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.
+//
+
+cc_defaults {
+ name: "init_defaults",
+ cpp_std: "experimental",
+ sanitize: {
+ misc_undefined: ["integer"],
+ },
+ tidy_checks: ["-misc-forwarding-reference-overload"],
+ cppflags: [
+ "-DLOG_UEVENTS=0",
+ "-Wall",
+ "-Wextra",
+ "-Wno-unused-parameter",
+ "-Werror",
+ "-DALLOW_LOCAL_PROP_OVERRIDE=0",
+ "-DALLOW_PERMISSIVE_SELINUX=0",
+ "-DREBOOT_BOOTLOADER_ON_PANIC=0",
+ "-DWORLD_WRITABLE_KMSG=0",
+ "-DDUMP_ON_UMOUNT_FAILURE=0",
+ "-DSHUTDOWN_ZERO_TIMEOUT=0",
+ ],
+ product_variables: {
+ debuggable: {
+ cppflags: [
+ "-UALLOW_LOCAL_PROP_OVERRIDE",
+ "-DALLOW_LOCAL_PROP_OVERRIDE=1",
+ "-UALLOW_PERMISSIVE_SELINUX",
+ "-DALLOW_PERMISSIVE_SELINUX=1",
+ "-UREBOOT_BOOTLOADER_ON_PANIC",
+ "-DREBOOT_BOOTLOADER_ON_PANIC=1",
+ "-UWORLD_WRITABLE_KMSG",
+ "-DWORLD_WRITABLE_KMSG=1",
+ "-UDUMP_ON_UMOUNT_FAILURE",
+ "-DDUMP_ON_UMOUNT_FAILURE=1",
+ ],
+ },
+ eng: {
+ cppflags: [
+ "-USHUTDOWN_ZERO_TIMEOUT",
+ "-DSHUTDOWN_ZERO_TIMEOUT=1",
+ ],
+ },
+ },
+}
+
+cc_library_static {
+ name: "libinit",
+ defaults: ["init_defaults"],
+ srcs: [
+ "action.cpp",
+ "capabilities.cpp",
+ "descriptors.cpp",
+ "devices.cpp",
+ "import_parser.cpp",
+ "init_parser.cpp",
+ "log.cpp",
+ "parser.cpp",
+ "service.cpp",
+ "util.cpp",
+ ],
+ whole_static_libs: ["libcap"],
+ static_libs: [
+ "libbase",
+ "libselinux",
+ "liblog",
+ "libprocessgroup",
+ ],
+}
+
+/*
+This is not yet ready, see the below TODOs for what is missing
+
+cc_binary {
+ // TODO: Missing,
+ //LOCAL_MODULE_PATH := $(TARGET_ROOT_OUT)
+ //LOCAL_UNSTRIPPED_PATH := $(TARGET_ROOT_OUT_UNSTRIPPED)
+
+ name: "init",
+ defaults: ["init_defaults"],
+ static_executable: true,
+ srcs: [
+ "bootchart.cpp",
+ "builtins.cpp",
+ "init.cpp",
+ "init_first_stage.cpp",
+ "keychords.cpp",
+ "property_service.cpp",
+ "reboot.cpp",
+ "signal_handler.cpp",
+ "ueventd.cpp",
+ "watchdogd.cpp",
+ ],
+ include_dirs: [
+ "system/core/mkbootimg"
+ ],
+ static_libs: [
+ "libinit",
+ "libbootloader_message",
+ "libfs_mgr",
+ "libfec",
+ "libfec_rs",
+ "libsquashfs_utils",
+ "liblogwrap",
+ "libext4_utils",
+ "libcutils",
+ "libbase",
+ "libc",
+ "libselinux",
+ "liblog",
+ "libcrypto_utils",
+ "libcrypto",
+ "libc++_static",
+ "libdl",
+ "libsparse",
+ "libz",
+ "libprocessgroup",
+ "libavb",
+ "libkeyutils",
+ ],
+ symlinks: [
+ "sbin/ueventd",
+ "sbin/watchdogd",
+ ],
+}
+*/
+
+// Tests
+// ------------------------------------------------------------------------------
+
+cc_test {
+ name: "init_tests",
+ defaults: ["init_defaults"],
+ srcs: [
+ "devices_test.cpp",
+ "init_parser_test.cpp",
+ "init_test.cpp",
+ "property_service_test.cpp",
+ "service_test.cpp",
+ "util_test.cpp",
+ ],
+ shared_libs: [
+ "libbase",
+ "libcutils",
+ "libselinux",
+ ],
+ static_libs: ["libinit"],
+}
+
+subdirs = ["*"]
diff --git a/init/Android.mk b/init/Android.mk
index 0db65cb..489d076 100644
--- a/init/Android.mk
+++ b/init/Android.mk
@@ -39,50 +39,6 @@
# --
-# If building on Linux, then build unit test for the host.
-ifeq ($(HOST_OS),linux)
-include $(CLEAR_VARS)
-LOCAL_CPPFLAGS := $(init_cflags)
-LOCAL_SRC_FILES:= \
- parser/tokenizer.cpp \
-
-LOCAL_MODULE := libinit_parser
-LOCAL_CLANG := true
-include $(BUILD_HOST_STATIC_LIBRARY)
-
-include $(CLEAR_VARS)
-LOCAL_MODULE := init_parser_tests
-LOCAL_SRC_FILES := \
- parser/tokenizer_test.cpp \
-
-LOCAL_STATIC_LIBRARIES := libinit_parser
-LOCAL_CLANG := true
-include $(BUILD_HOST_NATIVE_TEST)
-endif
-
-include $(CLEAR_VARS)
-# b/38002385, work around clang-tidy segmentation fault.
-LOCAL_TIDY_CHECKS := -misc-forwarding-reference-overload
-LOCAL_CPPFLAGS := $(init_cflags)
-LOCAL_SRC_FILES:= \
- action.cpp \
- capabilities.cpp \
- descriptors.cpp \
- devices.cpp \
- import_parser.cpp \
- init_parser.cpp \
- log.cpp \
- parser.cpp \
- service.cpp \
- util.cpp \
-
-LOCAL_STATIC_LIBRARIES := libbase libselinux liblog libprocessgroup
-LOCAL_WHOLE_STATIC_LIBRARIES := libcap
-LOCAL_MODULE := libinit
-LOCAL_SANITIZE := integer
-LOCAL_CLANG := true
-include $(BUILD_STATIC_LIBRARY)
-
include $(CLEAR_VARS)
# b/38002385, work around clang-tidy segmentation fault.
LOCAL_TIDY_CHECKS := -misc-forwarding-reference-overload
@@ -139,34 +95,3 @@
LOCAL_SANITIZE := integer
LOCAL_CLANG := true
include $(BUILD_EXECUTABLE)
-
-
-# Unit tests.
-# =========================================================
-include $(CLEAR_VARS)
-# b/38002385, work around clang-tidy segmentation fault.
-LOCAL_TIDY_CHECKS := -misc-forwarding-reference-overload
-LOCAL_MODULE := init_tests
-LOCAL_SRC_FILES := \
- devices_test.cpp \
- init_parser_test.cpp \
- init_test.cpp \
- property_service_test.cpp \
- service_test.cpp \
- util_test.cpp \
-
-LOCAL_SHARED_LIBRARIES += \
- libbase \
- libcutils \
- libselinux \
-
-LOCAL_STATIC_LIBRARIES := libinit
-LOCAL_SANITIZE := integer
-LOCAL_CLANG := true
-LOCAL_CPPFLAGS := -Wall -Wextra -Werror -std=gnu++1z
-include $(BUILD_NATIVE_TEST)
-
-
-# Include targets in subdirs.
-# =========================================================
-include $(call all-makefiles-under,$(LOCAL_PATH))
diff --git a/init/test_service/Android.bp b/init/test_service/Android.bp
new file mode 100644
index 0000000..9bd6f27
--- /dev/null
+++ b/init/test_service/Android.bp
@@ -0,0 +1,22 @@
+//
+// Copyright (C) 2017 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.
+//
+
+cc_binary {
+ name: "test_service",
+ srcs: ["test_service.cpp"],
+ shared_libs: ["libbase"],
+ init_rc: ["test_service.rc"],
+}
diff --git a/init/test_service/Android.mk b/init/test_service/Android.mk
deleted file mode 100644
index 30c9e9d..0000000
--- a/init/test_service/Android.mk
+++ /dev/null
@@ -1,27 +0,0 @@
-# Copyright (C) 2016 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.
-
-LOCAL_PATH := $(call my-dir)
-
-# Sample service for testing.
-# =========================================================
-include $(CLEAR_VARS)
-LOCAL_MODULE := test_service
-LOCAL_SRC_FILES := test_service.cpp
-
-LOCAL_SHARED_LIBRARIES += libbase
-
-LOCAL_INIT_RC := test_service.rc
-
-include $(BUILD_EXECUTABLE)
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) {
diff --git a/shell_and_utilities/Android.bp b/shell_and_utilities/Android.bp
index 81cf315..4f4fc5d 100644
--- a/shell_and_utilities/Android.bp
+++ b/shell_and_utilities/Android.bp
@@ -5,9 +5,12 @@
"grep",
"gzip",
"mkshrc",
+ "mkshrc_vendor",
"reboot",
"sh",
+ "sh_vendor",
"toolbox",
"toybox",
+ "toybox_vendor",
],
}
diff --git a/toolbox/Android.bp b/toolbox/Android.bp
new file mode 100644
index 0000000..1c9fb20
--- /dev/null
+++ b/toolbox/Android.bp
@@ -0,0 +1,44 @@
+common_cflags = [
+ "-Werror",
+ "-Wno-unused-parameter",
+ "-Wno-unused-const-variable",
+ "-include bsd-compatibility.h"
+]
+
+cc_library_static {
+ srcs: [
+ "upstream-netbsd/bin/dd/args.c",
+ "upstream-netbsd/bin/dd/conv.c",
+ "upstream-netbsd/bin/dd/dd.c",
+ "upstream-netbsd/bin/dd/dd_hostops.c",
+ "upstream-netbsd/bin/dd/misc.c",
+ "upstream-netbsd/bin/dd/position.c",
+ "upstream-netbsd/lib/libc/gen/getbsize.c",
+ "upstream-netbsd/lib/libc/gen/humanize_number.c",
+ "upstream-netbsd/lib/libc/stdlib/strsuftoll.c",
+ "upstream-netbsd/lib/libc/string/swab.c",
+ "upstream-netbsd/lib/libutil/raise_default_signal.c",
+ ],
+ cflags: common_cflags + [
+ "-Dmain=dd_main",
+ "-DNO_CONV",
+ ],
+ local_include_dirs: ["upstream-netbsd/include/"],
+ name: "libtoolbox_dd",
+}
+
+// We build BSD grep separately, so it can provide egrep and fgrep too.
+cc_binary {
+ name: "grep",
+ srcs: [
+ "upstream-netbsd/usr.bin/grep/fastgrep.c",
+ "upstream-netbsd/usr.bin/grep/file.c",
+ "upstream-netbsd/usr.bin/grep/grep.c",
+ "upstream-netbsd/usr.bin/grep/queue.c",
+ "upstream-netbsd/usr.bin/grep/util.c",
+ ],
+ cflags: common_cflags,
+ local_include_dirs: ["upstream-netbsd/include/"],
+ symlinks: ["egrep", "fgrep"],
+
+}
diff --git a/toolbox/Android.mk b/toolbox/Android.mk
index d6ead1a..94029d8 100644
--- a/toolbox/Android.mk
+++ b/toolbox/Android.mk
@@ -1,30 +1,9 @@
LOCAL_PATH:= $(call my-dir)
-
common_cflags := \
-Werror -Wno-unused-parameter -Wno-unused-const-variable \
-include bsd-compatibility.h \
-
-include $(CLEAR_VARS)
-LOCAL_SRC_FILES := \
- upstream-netbsd/bin/dd/args.c \
- upstream-netbsd/bin/dd/conv.c \
- upstream-netbsd/bin/dd/dd.c \
- upstream-netbsd/bin/dd/dd_hostops.c \
- upstream-netbsd/bin/dd/misc.c \
- upstream-netbsd/bin/dd/position.c \
- upstream-netbsd/lib/libc/gen/getbsize.c \
- upstream-netbsd/lib/libc/gen/humanize_number.c \
- upstream-netbsd/lib/libc/stdlib/strsuftoll.c \
- upstream-netbsd/lib/libc/string/swab.c \
- upstream-netbsd/lib/libutil/raise_default_signal.c
-LOCAL_CFLAGS += $(common_cflags) -Dmain=dd_main -DNO_CONV
-LOCAL_C_INCLUDES += $(LOCAL_PATH)/upstream-netbsd/include/
-LOCAL_MODULE := libtoolbox_dd
-include $(BUILD_STATIC_LIBRARY)
-
-
include $(CLEAR_VARS)
BSD_TOOLS := \
@@ -80,18 +59,3 @@
$(INPUT_H_LABELS_H): $(LOCAL_PATH)/Android.mk $(LOCAL_PATH)/generate-input.h-labels.py $(UAPI_INPUT_EVENT_CODES_H)
$(INPUT_H_LABELS_H):
$(transform-generated-source)
-
-
-# We build BSD grep separately, so it can provide egrep and fgrep too.
-include $(CLEAR_VARS)
-LOCAL_SRC_FILES := \
- upstream-netbsd/usr.bin/grep/fastgrep.c \
- upstream-netbsd/usr.bin/grep/file.c \
- upstream-netbsd/usr.bin/grep/grep.c \
- upstream-netbsd/usr.bin/grep/queue.c \
- upstream-netbsd/usr.bin/grep/util.c
-LOCAL_CFLAGS += $(common_cflags)
-LOCAL_C_INCLUDES += $(LOCAL_PATH)/upstream-netbsd/include/
-LOCAL_MODULE := grep
-LOCAL_POST_INSTALL_CMD := $(hide) $(foreach t,egrep fgrep,ln -sf grep $(TARGET_OUT)/bin/$(t);)
-include $(BUILD_EXECUTABLE)