Merge "storaged: lower capabilities in init"
diff --git a/base/Android.bp b/base/Android.bp
index 7b0ba11..12b3969 100644
--- a/base/Android.bp
+++ b/base/Android.bp
@@ -124,6 +124,7 @@
"errors_test.cpp",
"file_test.cpp",
"logging_test.cpp",
+ "macros_test.cpp",
"parsedouble_test.cpp",
"parseint_test.cpp",
"parsenetaddress_test.cpp",
diff --git a/base/include/android-base/macros.h b/base/include/android-base/macros.h
index 25f2ff4..fd6efb2 100644
--- a/base/include/android-base/macros.h
+++ b/base/include/android-base/macros.h
@@ -20,6 +20,8 @@
#include <stddef.h> // for size_t
#include <unistd.h> // for TEMP_FAILURE_RETRY
+#include <utility>
+
// bionic and glibc both have TEMP_FAILURE_RETRY, but eg Mac OS' libc doesn't.
#ifndef TEMP_FAILURE_RETRY
#define TEMP_FAILURE_RETRY(exp) \
@@ -114,6 +116,8 @@
((sizeof(a) / sizeof(*(a))) / \
static_cast<size_t>(!(sizeof(a) % sizeof(*(a)))))
+#define SIZEOF_MEMBER(t, f) sizeof(std::declval<t>().f)
+
// Changing this definition will cause you a lot of pain. A majority of
// vendor code defines LIKELY and UNLIKELY this way, and includes
// this header through an indirect path.
diff --git a/base/macros_test.cpp b/base/macros_test.cpp
new file mode 100644
index 0000000..2b522db
--- /dev/null
+++ b/base/macros_test.cpp
@@ -0,0 +1,30 @@
+/*
+ * Copyright (C) 2018 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.
+ */
+
+#include "android-base/macros.h"
+
+#include <stdint.h>
+
+#include <gtest/gtest.h>
+
+TEST(macros, SIZEOF_MEMBER_macro) {
+ struct S {
+ int32_t i32;
+ double d;
+ };
+ ASSERT_EQ(4U, SIZEOF_MEMBER(S, i32));
+ ASSERT_EQ(8U, SIZEOF_MEMBER(S, d));
+}
diff --git a/fastboot/Android.mk b/fastboot/Android.mk
index a142b3e..9bd0628 100644
--- a/fastboot/Android.mk
+++ b/fastboot/Android.mk
@@ -66,7 +66,7 @@
LOCAL_CFLAGS_darwin := $(fastboot_cflags_darwin)
LOCAL_CXX_STL := $(fastboot_stl)
LOCAL_HEADER_LIBRARIES := bootimg_headers
-LOCAL_LDLIBS_darwin := $(fastboot_ldflags_darwin)
+LOCAL_LDLIBS_darwin := $(fastboot_ldlibs_darwin)
LOCAL_LDLIBS_windows := $(fastboot_ldlibs_windows)
LOCAL_SHARED_LIBRARIES := $(fastboot_shared_libs)
LOCAL_STATIC_LIBRARIES := $(fastboot_static_libs)
@@ -83,7 +83,8 @@
LOCAL_CFLAGS := $(fastboot_cflags)
LOCAL_CFLAGS_darwin := $(fastboot_cflags_darwin)
LOCAL_CXX_STL := $(fastboot_stl)
-LOCAL_LDLIBS_darwin := $(fastboot_ldflags_darwin)
+LOCAL_HEADER_LIBRARIES := bootimg_headers
+LOCAL_LDLIBS_darwin := $(fastboot_ldlibs_darwin)
LOCAL_LDLIBS_windows := $(fastboot_ldlibs_windows)
LOCAL_REQUIRED_MODULES := mke2fs make_f2fs
LOCAL_REQUIRED_MODULES_darwin := e2fsdroid mke2fs.conf sload_f2fs
@@ -93,8 +94,6 @@
LOCAL_SHARED_LIBRARIES := $(fastboot_shared_libs)
LOCAL_SHARED_LIBRARIES_windows := AdbWinApi
LOCAL_STATIC_LIBRARIES := libfastboot $(fastboot_static_libs)
-LOCAL_STATIC_LIBRARIES_darwin := libselinux
-LOCAL_STATIC_LIBRARIES_linux := libselinux
include $(BUILD_HOST_EXECUTABLE)
#
@@ -120,8 +119,10 @@
include $(CLEAR_VARS)
LOCAL_MODULE := fastboot_test
LOCAL_MODULE_HOST_OS := darwin linux windows
+LOCAL_MODULE_HOST_CROSS_ARCH := x86 # Avoid trying to build for win64.
LOCAL_SRC_FILES := \
+ fastboot_test.cpp \
socket_mock.cpp \
socket_test.cpp \
tcp_test.cpp \
@@ -130,7 +131,10 @@
LOCAL_CFLAGS := $(fastboot_cflags)
LOCAL_CFLAGS_darwin := $(fastboot_cflags_darwin)
LOCAL_CXX_STL := $(fastboot_stl)
-LOCAL_LDLIBS_darwin := $(fastboot_ldflags_darwin)
+LOCAL_HEADER_LIBRARIES := bootimg_headers
+LOCAL_LDLIBS_darwin := $(fastboot_ldlibs_darwin)
LOCAL_LDLIBS_windows := $(fastboot_ldlibs_windows)
+LOCAL_SHARED_LIBRARIES := $(fastboot_shared_libs)
+LOCAL_SHARED_LIBRARIES_windows := AdbWinApi
LOCAL_STATIC_LIBRARIES := libfastboot $(fastboot_static_libs)
include $(BUILD_HOST_NATIVE_TEST)
diff --git a/fastboot/bootimg_utils.cpp b/fastboot/bootimg_utils.cpp
index feacaa1..c9814e4 100644
--- a/fastboot/bootimg_utils.cpp
+++ b/fastboot/bootimg_utils.cpp
@@ -44,7 +44,7 @@
const boot_img_hdr_v1& src, int64_t* bootimg_size) {
const size_t page_mask = src.page_size - 1;
- int64_t header_actual = sizeof(boot_img_hdr_v1) & (~page_mask);
+ int64_t header_actual = (sizeof(boot_img_hdr_v1) + page_mask) & (~page_mask);
int64_t kernel_actual = (kernel_size + page_mask) & (~page_mask);
int64_t ramdisk_actual = (ramdisk_size + page_mask) & (~page_mask);
int64_t second_actual = (second_size + page_mask) & (~page_mask);
diff --git a/fastboot/fastboot.cpp b/fastboot/fastboot.cpp
index 42f4fbb..3a3503e 100644
--- a/fastboot/fastboot.cpp
+++ b/fastboot/fastboot.cpp
@@ -77,7 +77,6 @@
static const char* serial = nullptr;
-static unsigned short vendor_id = 0;
static bool g_long_listing = false;
// Don't resparse files in too-big chunks.
// libsparse will support INT_MAX, but this results in large allocations, so
@@ -190,11 +189,6 @@
}
static int match_fastboot_with_serial(usb_ifc_info* info, const char* local_serial) {
- // Require a matching vendor id if the user specified one with -i.
- if (vendor_id != 0 && info->dev_vendor != vendor_id) {
- return -1;
- }
-
if (info->ifc_class != 0xff || info->ifc_subclass != 0x42 || info->ifc_protocol != 0x03) {
return -1;
}
@@ -381,8 +375,6 @@
" -w Wipe userdata.\n"
" -s SERIAL Specify a USB device.\n"
" -s tcp|udp:HOST[:PORT] Specify a network device.\n"
- // TODO: remove -i?
- " -i VENDOR_ID Filter devices by USB vendor id.\n"
" -S SIZE[K|M|G] Use sparse files above this limit (0 to disable).\n"
" --slot SLOT Use SLOT; 'all' for both slots, 'other' for\n"
" non-current slot (default: current active slot).\n"
@@ -881,46 +873,18 @@
}
}
-static std::string get_current_slot(Transport* transport)
-{
+static std::string get_current_slot(Transport* transport) {
std::string current_slot;
- if (fb_getvar(transport, "current-slot", ¤t_slot)) {
- if (current_slot == "_a") return "a"; // Legacy support
- if (current_slot == "_b") return "b"; // Legacy support
- return current_slot;
- }
- return "";
-}
-
-// Legacy support
-static std::vector<std::string> get_suffixes_obsolete(Transport* transport) {
- std::vector<std::string> suffixes;
- std::string suffix_list;
- if (!fb_getvar(transport, "slot-suffixes", &suffix_list)) {
- return suffixes;
- }
- suffixes = android::base::Split(suffix_list, ",");
- // Unfortunately some devices will return an error message in the
- // guise of a valid value. If we only see only one suffix, it's probably
- // not real.
- if (suffixes.size() == 1) {
- suffixes.clear();
- }
- return suffixes;
-}
-
-// Legacy support
-static bool supports_AB_obsolete(Transport* transport) {
- return !get_suffixes_obsolete(transport).empty();
+ if (!fb_getvar(transport, "current-slot", ¤t_slot)) return "";
+ return current_slot;
}
static int get_slot_count(Transport* transport) {
std::string var;
- int count;
- if (!fb_getvar(transport, "slot-count", &var)) {
- if (supports_AB_obsolete(transport)) return 2; // Legacy support
+ int count = 0;
+ if (!fb_getvar(transport, "slot-count", &var) || !android::base::ParseInt(var, &count)) {
+ return 0;
}
- if (!android::base::ParseInt(var, &count)) return 0;
return count;
}
@@ -950,8 +914,6 @@
static std::string verify_slot(Transport* transport, const std::string& slot_name, bool allow_all) {
std::string slot = slot_name;
- if (slot == "_a") slot = "a"; // Legacy support
- if (slot == "_b") slot = "b"; // Legacy support
if (slot == "all") {
if (allow_all) {
return "all";
@@ -1063,20 +1025,14 @@
// Sets slot_override as the active slot. If slot_override is blank,
// set current slot as active instead. This clears slot-unbootable.
static void set_active(Transport* transport, const std::string& slot_override) {
- std::string separator = "";
- if (!supports_AB(transport)) {
- if (supports_AB_obsolete(transport)) {
- separator = "_"; // Legacy support
- } else {
- return;
- }
- }
+ if (!supports_AB(transport)) return;
+
if (slot_override != "") {
- fb_set_active(separator + slot_override);
+ fb_set_active(slot_override);
} else {
std::string current_slot = get_current_slot(transport);
if (current_slot != "") {
- fb_set_active(separator + current_slot);
+ fb_set_active(current_slot);
}
}
}
@@ -1459,7 +1415,7 @@
serial = getenv("ANDROID_SERIAL");
int c;
- while ((c = getopt_long(argc, argv, "a::hi:ls:S:vw", longopts, &longindex)) != -1) {
+ while ((c = getopt_long(argc, argv, "a::hls:S:vw", longopts, &longindex)) != -1) {
if (c == 0) {
std::string name{longopts[longindex].name};
if (name == "base") {
@@ -1475,24 +1431,9 @@
} else if (name == "kernel-offset") {
g_boot_img_hdr.kernel_addr = strtoul(optarg, 0, 16);
} else if (name == "os-patch-level") {
- unsigned year, month, day;
- if (sscanf(optarg, "%u-%u-%u", &year, &month, &day) != 3) {
- syntax_error("OS patch level should be YYYY-MM-DD: %s", optarg);
- }
- if (year < 2000 || year >= 2128) syntax_error("year out of range: %d", year);
- if (month < 1 || month > 12) syntax_error("month out of range: %d", month);
- g_boot_img_hdr.SetOsPatchLevel(year, month);
+ ParseOsPatchLevel(&g_boot_img_hdr, optarg);
} else if (name == "os-version") {
- unsigned major = 0, minor = 0, patch = 0;
- std::vector<std::string> versions = android::base::Split(optarg, ".");
- if (versions.size() < 1 || versions.size() > 3 ||
- (versions.size() >= 1 && !android::base::ParseUint(versions[0], &major)) ||
- (versions.size() >= 2 && !android::base::ParseUint(versions[1], &minor)) ||
- (versions.size() == 3 && !android::base::ParseUint(versions[2], &patch)) ||
- (major > 0x7f || minor > 0x7f || patch > 0x7f)) {
- syntax_error("bad OS version: %s", optarg);
- }
- g_boot_img_hdr.SetOsVersion(major, minor, patch);
+ ParseOsVersion(&g_boot_img_hdr, optarg);
} else if (name == "page-size") {
g_boot_img_hdr.page_size = strtoul(optarg, nullptr, 0);
if (g_boot_img_hdr.page_size == 0) die("invalid page size");
@@ -1529,16 +1470,6 @@
break;
case 'h':
return show_help();
- case 'i':
- {
- char *endptr = nullptr;
- unsigned long val = strtoul(optarg, &endptr, 0);
- if (!endptr || *endptr != '\0' || (val & ~0xffff)) {
- die("invalid vendor id '%s'", optarg);
- }
- vendor_id = (unsigned short)val;
- break;
- }
case 'l':
g_long_listing = true;
break;
@@ -1584,9 +1515,6 @@
const double start = now();
- if (!supports_AB(transport) && supports_AB_obsolete(transport)) {
- fprintf(stderr, "Warning: Device A/B support is outdated. Bootloader update required.\n");
- }
if (slot_override != "") slot_override = verify_slot(transport, slot_override);
if (next_active != "") next_active = verify_slot(transport, next_active, false);
@@ -1730,15 +1658,6 @@
wants_reboot = true;
} else if (command == "set_active") {
std::string slot = verify_slot(transport, next_arg(&args), false);
-
- // Legacy support: verify_slot() removes leading underscores, we need to put them back
- // in for old bootloaders. Legacy bootloaders do not have the slot-count variable but
- // do have slot-suffixes.
- std::string var;
- if (!fb_getvar(transport, "slot-count", &var) &&
- fb_getvar(transport, "slot-suffixes", &var)) {
- slot = "_" + slot;
- }
fb_set_active(slot);
} else if (command == "stage") {
std::string filename = next_arg(&args);
@@ -1801,3 +1720,26 @@
fprintf(stderr, "Finished. Total time: %.3fs\n", (now() - start));
return status;
}
+
+void FastBoot::ParseOsPatchLevel(boot_img_hdr_v1* hdr, const char* arg) {
+ unsigned year, month, day;
+ if (sscanf(arg, "%u-%u-%u", &year, &month, &day) != 3) {
+ syntax_error("OS patch level should be YYYY-MM-DD: %s", arg);
+ }
+ if (year < 2000 || year >= 2128) syntax_error("year out of range: %d", year);
+ if (month < 1 || month > 12) syntax_error("month out of range: %d", month);
+ hdr->SetOsPatchLevel(year, month);
+}
+
+void FastBoot::ParseOsVersion(boot_img_hdr_v1* hdr, const char* arg) {
+ unsigned major = 0, minor = 0, patch = 0;
+ std::vector<std::string> versions = android::base::Split(arg, ".");
+ if (versions.size() < 1 || versions.size() > 3 ||
+ (versions.size() >= 1 && !android::base::ParseUint(versions[0], &major)) ||
+ (versions.size() >= 2 && !android::base::ParseUint(versions[1], &minor)) ||
+ (versions.size() == 3 && !android::base::ParseUint(versions[2], &patch)) ||
+ (major > 0x7f || minor > 0x7f || patch > 0x7f)) {
+ syntax_error("bad OS version: %s", arg);
+ }
+ hdr->SetOsVersion(major, minor, patch);
+}
diff --git a/fastboot/fastboot.h b/fastboot/fastboot.h
index 3d5a261..2935eb5 100644
--- a/fastboot/fastboot.h
+++ b/fastboot/fastboot.h
@@ -26,14 +26,15 @@
* SUCH DAMAGE.
*/
-#ifndef _FASTBOOT_H_
-#define _FASTBOOT_H_
+#pragma once
#include <inttypes.h>
#include <stdlib.h>
#include <string>
+#include <bootimg.h>
+
class Transport;
struct sparse_file;
@@ -99,6 +100,7 @@
class FastBoot {
public:
int Main(int argc, char* argv[]);
-};
-#endif
+ void ParseOsPatchLevel(boot_img_hdr_v1*, const char*);
+ void ParseOsVersion(boot_img_hdr_v1*, const char*);
+};
diff --git a/fastboot/fastboot_test.cpp b/fastboot/fastboot_test.cpp
new file mode 100644
index 0000000..1681427
--- /dev/null
+++ b/fastboot/fastboot_test.cpp
@@ -0,0 +1,61 @@
+/*
+ * Copyright (C) 2018 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.
+ */
+
+#include "fastboot.h"
+
+#include <gtest/gtest.h>
+
+TEST(FastBoot, ParseOsPatchLevel) {
+ FastBoot fb;
+ boot_img_hdr_v1 hdr;
+
+ hdr = {};
+ fb.ParseOsPatchLevel(&hdr, "2018-01-05");
+ ASSERT_EQ(2018U, 2000U + ((hdr.os_version >> 4) & 0x7f));
+ ASSERT_EQ(1U, ((hdr.os_version >> 0) & 0xf));
+
+ EXPECT_DEATH(fb.ParseOsPatchLevel(&hdr, "2018"), "should be YYYY-MM-DD");
+ EXPECT_DEATH(fb.ParseOsPatchLevel(&hdr, "2018-01"), "should be YYYY-MM-DD");
+ EXPECT_DEATH(fb.ParseOsPatchLevel(&hdr, "2128-01-05"), "year out of range");
+ EXPECT_DEATH(fb.ParseOsPatchLevel(&hdr, "2018-13-05"), "month out of range");
+}
+
+TEST(FastBoot, ParseOsVersion) {
+ FastBoot fb;
+ boot_img_hdr_v1 hdr;
+
+ hdr = {};
+ fb.ParseOsVersion(&hdr, "1.2.3");
+ ASSERT_EQ(1U, ((hdr.os_version >> 25) & 0x7f));
+ ASSERT_EQ(2U, ((hdr.os_version >> 18) & 0x7f));
+ ASSERT_EQ(3U, ((hdr.os_version >> 11) & 0x7f));
+
+ fb.ParseOsVersion(&hdr, "1.2");
+ ASSERT_EQ(1U, ((hdr.os_version >> 25) & 0x7f));
+ ASSERT_EQ(2U, ((hdr.os_version >> 18) & 0x7f));
+ ASSERT_EQ(0U, ((hdr.os_version >> 11) & 0x7f));
+
+ fb.ParseOsVersion(&hdr, "1");
+ ASSERT_EQ(1U, ((hdr.os_version >> 25) & 0x7f));
+ ASSERT_EQ(0U, ((hdr.os_version >> 18) & 0x7f));
+ ASSERT_EQ(0U, ((hdr.os_version >> 11) & 0x7f));
+
+ EXPECT_DEATH(fb.ParseOsVersion(&hdr, ""), "bad OS version");
+ EXPECT_DEATH(fb.ParseOsVersion(&hdr, "1.2.3.4"), "bad OS version");
+ EXPECT_DEATH(fb.ParseOsVersion(&hdr, "128.2.3"), "bad OS version");
+ EXPECT_DEATH(fb.ParseOsVersion(&hdr, "1.128.3"), "bad OS version");
+ EXPECT_DEATH(fb.ParseOsVersion(&hdr, "1.2.128"), "bad OS version");
+}
diff --git a/fastboot/fs.cpp b/fastboot/fs.cpp
index a1e1677..14dabaa 100644
--- a/fastboot/fs.cpp
+++ b/fastboot/fs.cpp
@@ -20,6 +20,7 @@
#include <android-base/errors.h>
#include <android-base/file.h>
+#include <android-base/macros.h>
#include <android-base/stringprintf.h>
#include <android-base/unique_fd.h>
diff --git a/fastboot/fs.h b/fastboot/fs.h
index c6baa7f..331100d 100644
--- a/fastboot/fs.h
+++ b/fastboot/fs.h
@@ -1,5 +1,4 @@
-#ifndef _FS_H_
-#define _FS_H_
+#pragma once
#include <string>
#include <stdint.h>
@@ -9,5 +8,3 @@
const struct fs_generator* fs_get_generator(const std::string& fs_type);
int fs_generator_generate(const struct fs_generator* gen, const char* fileName, long long partSize,
const std::string& initial_dir, unsigned eraseBlkSize = 0, unsigned logicalBlkSize = 0);
-
-#endif
diff --git a/fastboot/protocol.cpp b/fastboot/protocol.cpp
index 133a2d0..a089567 100644
--- a/fastboot/protocol.cpp
+++ b/fastboot/protocol.cpp
@@ -57,10 +57,10 @@
}
static int64_t check_response(Transport* transport, uint32_t size, char* response) {
- char status[65];
+ char status[FB_RESPONSE_SZ + 1];
while (true) {
- int r = transport->Read(status, 64);
+ int r = transport->Read(status, FB_RESPONSE_SZ);
if (r < 0) {
g_error = android::base::StringPrintf("status read failed (%s)", strerror(errno));
transport->Close();
@@ -75,13 +75,13 @@
}
if (!memcmp(status, "INFO", 4)) {
- verbose("received INFO %s", status + 4);
+ verbose("received INFO \"%s\"", status + 4);
fprintf(stderr, "(bootloader) %s\n", status + 4);
continue;
}
if (!memcmp(status, "OKAY", 4)) {
- verbose("received OKAY %s", status + 4);
+ verbose("received OKAY \"%s\"", status + 4);
if (response) {
strcpy(response, status + 4);
}
@@ -89,7 +89,7 @@
}
if (!memcmp(status, "FAIL", 4)) {
- verbose("received FAIL %s", status + 4);
+ verbose("received FAIL \"%s\"", status + 4);
if (r > 4) {
g_error = android::base::StringPrintf("remote: %s", status + 4);
} else {
@@ -120,7 +120,7 @@
static int64_t _command_start(Transport* transport, const std::string& cmd, uint32_t size,
char* response) {
- if (cmd.size() > 64) {
+ if (cmd.size() > FB_COMMAND_SZ) {
g_error = android::base::StringPrintf("command too large (%zu)", cmd.size());
return -1;
}
diff --git a/fastboot/socket.h b/fastboot/socket.h
index 7eaa0ab..e791f2c 100644
--- a/fastboot/socket.h
+++ b/fastboot/socket.h
@@ -30,8 +30,7 @@
// engine should not be using this interface directly, but instead should use a higher-level
// interface that enforces the fastboot protocol.
-#ifndef SOCKET_H_
-#define SOCKET_H_
+#pragma once
#include <functional>
#include <memory>
@@ -125,5 +124,3 @@
DISALLOW_COPY_AND_ASSIGN(Socket);
};
-
-#endif // SOCKET_H_
diff --git a/fastboot/socket_mock.h b/fastboot/socket_mock.h
index eacd6bb..6e95b16 100644
--- a/fastboot/socket_mock.h
+++ b/fastboot/socket_mock.h
@@ -26,8 +26,7 @@
* SUCH DAMAGE.
*/
-#ifndef SOCKET_MOCK_H_
-#define SOCKET_MOCK_H_
+#pragma once
#include <memory>
#include <queue>
@@ -97,5 +96,3 @@
DISALLOW_COPY_AND_ASSIGN(SocketMock);
};
-
-#endif // SOCKET_MOCK_H_
diff --git a/fastboot/tcp.h b/fastboot/tcp.h
index aa3ef13..8b638a4 100644
--- a/fastboot/tcp.h
+++ b/fastboot/tcp.h
@@ -26,8 +26,7 @@
* SUCH DAMAGE.
*/
-#ifndef TCP_H_
-#define TCP_H_
+#pragma once
#include <memory>
#include <string>
@@ -55,5 +54,3 @@
} // namespace internal
} // namespace tcp
-
-#endif // TCP_H_
diff --git a/fastboot/transport.h b/fastboot/transport.h
index 67d01f9..96b90d2 100644
--- a/fastboot/transport.h
+++ b/fastboot/transport.h
@@ -14,8 +14,7 @@
* limitations under the License.
*/
-#ifndef TRANSPORT_H_
-#define TRANSPORT_H_
+#pragma once
#include <android-base/macros.h>
@@ -44,5 +43,3 @@
private:
DISALLOW_COPY_AND_ASSIGN(Transport);
};
-
-#endif // TRANSPORT_H_
diff --git a/fastboot/udp.h b/fastboot/udp.h
index 14f5b35..8d37b84 100644
--- a/fastboot/udp.h
+++ b/fastboot/udp.h
@@ -26,8 +26,7 @@
* SUCH DAMAGE.
*/
-#ifndef UDP_H_
-#define UDP_H_
+#pragma once
#include <memory>
#include <string>
@@ -77,5 +76,3 @@
} // namespace internal
} // namespace udp
-
-#endif // UDP_H_
diff --git a/fastboot/usb.h b/fastboot/usb.h
index 4acf12d..5b44468 100644
--- a/fastboot/usb.h
+++ b/fastboot/usb.h
@@ -26,8 +26,7 @@
* SUCH DAMAGE.
*/
-#ifndef _USB_H_
-#define _USB_H_
+#pragma once
#include "transport.h"
@@ -56,5 +55,3 @@
typedef int (*ifc_match_func)(usb_ifc_info *ifc);
Transport* usb_open(ifc_match_func callback);
-
-#endif
diff --git a/libutils/SharedBuffer.h b/libutils/SharedBuffer.h
index 48358cd..81cadff 100644
--- a/libutils/SharedBuffer.h
+++ b/libutils/SharedBuffer.h
@@ -139,7 +139,7 @@
return (mRefs.load(std::memory_order_acquire) == 1);
}
-}; // namespace android
+} // namespace android
// ---------------------------------------------------------------------------
diff --git a/libutils/include/utils/AndroidThreads.h b/libutils/include/utils/AndroidThreads.h
index 4c2dd49..dab888d 100644
--- a/libutils/include/utils/AndroidThreads.h
+++ b/libutils/include/utils/AndroidThreads.h
@@ -118,7 +118,7 @@
}
// ----------------------------------------------------------------------------
-}; // namespace android
+} // namespace android
#endif // __cplusplus
// ----------------------------------------------------------------------------
diff --git a/libutils/include/utils/CallStack.h b/libutils/include/utils/CallStack.h
index 27e89f4..9622142 100644
--- a/libutils/include/utils/CallStack.h
+++ b/libutils/include/utils/CallStack.h
@@ -67,6 +67,6 @@
Vector<String8> mFrameLines;
};
-}; // namespace android
+} // namespace android
#endif // ANDROID_CALLSTACK_H
diff --git a/libutils/include/utils/Condition.h b/libutils/include/utils/Condition.h
index 9bf82eb..c8da67c 100644
--- a/libutils/include/utils/Condition.h
+++ b/libutils/include/utils/Condition.h
@@ -159,7 +159,7 @@
#endif // !defined(_WIN32)
// ---------------------------------------------------------------------------
-}; // namespace android
+} // namespace android
// ---------------------------------------------------------------------------
#endif // _LIBS_UTILS_CONDITON_H
diff --git a/libutils/include/utils/Debug.h b/libutils/include/utils/Debug.h
index 4cbb462..96bd70e 100644
--- a/libutils/include/utils/Debug.h
+++ b/libutils/include/utils/Debug.h
@@ -35,6 +35,6 @@
CompileTimeAssert<( _exp )>();
// ---------------------------------------------------------------------------
-}; // namespace android
+} // namespace android
#endif // ANDROID_UTILS_DEBUG_H
diff --git a/libutils/include/utils/FileMap.h b/libutils/include/utils/FileMap.h
index 7d372e1..8d402a3 100644
--- a/libutils/include/utils/FileMap.h
+++ b/libutils/include/utils/FileMap.h
@@ -124,6 +124,6 @@
static long mPageSize;
};
-}; // namespace android
+} // namespace android
#endif // __LIBS_FILE_MAP_H
diff --git a/libutils/include/utils/Flattenable.h b/libutils/include/utils/Flattenable.h
index 675e211..0a19019 100644
--- a/libutils/include/utils/Flattenable.h
+++ b/libutils/include/utils/Flattenable.h
@@ -198,8 +198,6 @@
}
};
-
-}; // namespace android
-
+} // namespace android
#endif /* ANDROID_UTILS_FLATTENABLE_H */
diff --git a/libutils/include/utils/Functor.h b/libutils/include/utils/Functor.h
index 3182a9c..c0c8d57 100644
--- a/libutils/include/utils/Functor.h
+++ b/libutils/include/utils/Functor.h
@@ -32,6 +32,6 @@
virtual status_t operator ()(int /*what*/, void* /*data*/) { return NO_ERROR; }
};
-}; // namespace android
+} // namespace android
#endif // ANDROID_FUNCTOR_H
diff --git a/libutils/include/utils/KeyedVector.h b/libutils/include/utils/KeyedVector.h
index 03bfe27..7bda99b 100644
--- a/libutils/include/utils/KeyedVector.h
+++ b/libutils/include/utils/KeyedVector.h
@@ -211,7 +211,7 @@
return i >= 0 ? KeyedVector<KEY,VALUE>::valueAt(i) : mDefault;
}
-}; // namespace android
+} // namespace android
// ---------------------------------------------------------------------------
diff --git a/libutils/include/utils/List.h b/libutils/include/utils/List.h
index daca016..25b56fd 100644
--- a/libutils/include/utils/List.h
+++ b/libutils/include/utils/List.h
@@ -329,6 +329,6 @@
return *this;
}
-}; // namespace android
+} // namespace android
#endif // _LIBS_UTILS_LIST_H
diff --git a/libutils/include/utils/Mutex.h b/libutils/include/utils/Mutex.h
index af6076c..1228df4 100644
--- a/libutils/include/utils/Mutex.h
+++ b/libutils/include/utils/Mutex.h
@@ -212,7 +212,7 @@
typedef Mutex::Autolock AutoMutex;
// ---------------------------------------------------------------------------
-}; // namespace android
+} // namespace android
// ---------------------------------------------------------------------------
#endif // _LIBS_UTILS_MUTEX_H
diff --git a/libutils/include/utils/Printer.h b/libutils/include/utils/Printer.h
index bb66287..a6f6928 100644
--- a/libutils/include/utils/Printer.h
+++ b/libutils/include/utils/Printer.h
@@ -114,6 +114,6 @@
const char* mPrefix;
};
-}; // namespace android
+} // namespace android
#endif // ANDROID_PRINTER_H
diff --git a/libutils/include/utils/ProcessCallStack.h b/libutils/include/utils/ProcessCallStack.h
index 32458b8..b5f2edc 100644
--- a/libutils/include/utils/ProcessCallStack.h
+++ b/libutils/include/utils/ProcessCallStack.h
@@ -74,6 +74,6 @@
struct tm mTimeUpdated;
};
-}; // namespace android
+} // namespace android
#endif // ANDROID_PROCESS_CALLSTACK_H
diff --git a/libutils/include/utils/RWLock.h b/libutils/include/utils/RWLock.h
index d5b81d3..7d43e69 100644
--- a/libutils/include/utils/RWLock.h
+++ b/libutils/include/utils/RWLock.h
@@ -120,7 +120,7 @@
#endif // !defined(_WIN32)
// ---------------------------------------------------------------------------
-}; // namespace android
+} // namespace android
// ---------------------------------------------------------------------------
#endif // _LIBS_UTILS_RWLOCK_H
diff --git a/libutils/include/utils/Singleton.h b/libutils/include/utils/Singleton.h
index bc47a5c..2dd5a47 100644
--- a/libutils/include/utils/Singleton.h
+++ b/libutils/include/utils/Singleton.h
@@ -95,7 +95,7 @@
// ---------------------------------------------------------------------------
-}; // namespace android
+} // namespace android
#endif // ANDROID_UTILS_SINGLETON_H
diff --git a/libutils/include/utils/SortedVector.h b/libutils/include/utils/SortedVector.h
index 47c1376..394db12 100644
--- a/libutils/include/utils/SortedVector.h
+++ b/libutils/include/utils/SortedVector.h
@@ -288,8 +288,7 @@
return compare_type( *reinterpret_cast<const TYPE*>(lhs), *reinterpret_cast<const TYPE*>(rhs) );
}
-}; // namespace android
-
+} // namespace android
// ---------------------------------------------------------------------------
diff --git a/libutils/include/utils/StopWatch.h b/libutils/include/utils/StopWatch.h
index 76d78d0..9b14ac8 100644
--- a/libutils/include/utils/StopWatch.h
+++ b/libutils/include/utils/StopWatch.h
@@ -52,9 +52,7 @@
int mNumLaps;
};
-
-}; // namespace android
-
+} // namespace android
// ---------------------------------------------------------------------------
diff --git a/libutils/include/utils/SystemClock.h b/libutils/include/utils/SystemClock.h
index 01db340..f816fba 100644
--- a/libutils/include/utils/SystemClock.h
+++ b/libutils/include/utils/SystemClock.h
@@ -26,7 +26,7 @@
int64_t elapsedRealtime();
int64_t elapsedRealtimeNano();
-}; // namespace android
+} // namespace android
#endif // ANDROID_UTILS_SYSTEMCLOCK_H
diff --git a/libutils/include/utils/Thread.h b/libutils/include/utils/Thread.h
index 598298d..3525138 100644
--- a/libutils/include/utils/Thread.h
+++ b/libutils/include/utils/Thread.h
@@ -110,8 +110,7 @@
#endif
};
-
-}; // namespace android
+} // namespace android
// ---------------------------------------------------------------------------
#endif // _LIBS_UTILS_THREAD_H
diff --git a/libutils/include/utils/ThreadDefs.h b/libutils/include/utils/ThreadDefs.h
index ae091e4..8eb3d1c 100644
--- a/libutils/include/utils/ThreadDefs.h
+++ b/libutils/include/utils/ThreadDefs.h
@@ -66,9 +66,8 @@
};
// ---------------------------------------------------------------------------
-}; // namespace android
+} // namespace android
#endif // __cplusplus
// ---------------------------------------------------------------------------
-
#endif // _LIBS_UTILS_THREAD_DEFS_H
diff --git a/libutils/include/utils/Trace.h b/libutils/include/utils/Trace.h
index 5e9229c..4b9c91e 100644
--- a/libutils/include/utils/Trace.h
+++ b/libutils/include/utils/Trace.h
@@ -49,7 +49,7 @@
uint64_t mTag;
};
-}; // namespace android
+} // namespace android
#else // !__ANDROID__
diff --git a/libutils/include/utils/Vector.h b/libutils/include/utils/Vector.h
index a1a0234..ddf71de 100644
--- a/libutils/include/utils/Vector.h
+++ b/libutils/include/utils/Vector.h
@@ -425,8 +425,7 @@
move_backward_type( reinterpret_cast<TYPE*>(dest), reinterpret_cast<const TYPE*>(from), num );
}
-}; // namespace android
-
+} // namespace android
// ---------------------------------------------------------------------------
diff --git a/libutils/include/utils/VectorImpl.h b/libutils/include/utils/VectorImpl.h
index 4dd91fd..55d5d98 100644
--- a/libutils/include/utils/VectorImpl.h
+++ b/libutils/include/utils/VectorImpl.h
@@ -175,8 +175,7 @@
ssize_t replaceAt(const void* item, size_t index);
};
-}; // namespace android
-
+} // namespace android
// ---------------------------------------------------------------------------
diff --git a/logwrapper/Android.bp b/logwrapper/Android.bp
index f163f57..54506dc 100644
--- a/logwrapper/Android.bp
+++ b/logwrapper/Android.bp
@@ -1,10 +1,17 @@
-
+cc_defaults {
+ name: "logwrapper_defaults",
+ cflags: [
+ "-Werror",
+ ],
+}
// ========================================================
// Static and shared library
// ========================================================
+
cc_library {
name: "liblogwrap",
+ defaults: ["logwrapper_defaults"],
srcs: ["logwrap.c"],
shared_libs: [
"libcutils",
@@ -12,32 +19,45 @@
],
export_include_dirs: ["include"],
local_include_dirs: ["include"],
- cflags: [
- "-Werror",
- ],
}
// ========================================================
// Executable
// ========================================================
+
+cc_defaults {
+ name: "logwrapper_common",
+ defaults: ["logwrapper_defaults"],
+ local_include_dirs: ["include"],
+ srcs: [
+ "logwrap.c",
+ "logwrapper.c",
+ ],
+ shared_libs: ["libcutils", "liblog"],
+}
+
cc_binary {
name: "logwrapper",
- srcs: ["logwrapper.c"],
- static_libs: [
- "liblog",
- "liblogwrap",
- "libcutils",
- ],
- cflags: [
- "-Werror",
- ],
+ defaults: ["logwrapper_common"],
+}
+
+// Build vendor logwrapper.
+// TODO: Add vendor_available to "logwrapper" module and remove "logwrapper_vendor" module
+// when vendor_available is fully supported.
+cc_binary {
+ name: "logwrapper_vendor",
+ stem: "logwrapper",
+ vendor: true,
+ defaults: ["logwrapper_common"],
}
// ========================================================
// Benchmark
// ========================================================
+
cc_benchmark {
name: "android_fork_execvp_ext_benchmark",
+ defaults: ["logwrapper_defaults"],
srcs: [
"android_fork_execvp_ext_benchmark.cpp",
],
@@ -47,7 +67,4 @@
"liblog",
"liblogwrap",
],
- cflags: [
- "-Werror",
- ],
}
diff --git a/logwrapper/logwrap.c b/logwrapper/logwrap.c
index 7076078..8621993 100644
--- a/logwrapper/logwrap.c
+++ b/logwrapper/logwrap.c
@@ -31,7 +31,6 @@
#include <cutils/klog.h>
#include <log/log.h>
#include <logwrap/logwrap.h>
-#include <private/android_filesystem_config.h>
#define ARRAY_SIZE(x) (sizeof(x) / sizeof(*(x)))
#define MIN(a,b) (((a)<(b))?(a):(b))
diff --git a/shell_and_utilities/Android.bp b/shell_and_utilities/Android.bp
index 3ccb92f..2e42b70 100644
--- a/shell_and_utilities/Android.bp
+++ b/shell_and_utilities/Android.bp
@@ -6,6 +6,8 @@
"bzip2",
"grep",
"grep_vendor",
+ "logwrapper",
+ "logwrapper_vendor",
"mkshrc",
"mkshrc_vendor",
"reboot",
diff --git a/storaged/OWNERS b/storaged/OWNERS
index c6feee8..d033f00 100644
--- a/storaged/OWNERS
+++ b/storaged/OWNERS
@@ -1,2 +1,2 @@
-jinqian@google.com
salyzyn@google.com
+dvander@google.com