Merge remote-tracking branch 'aosp/upstream-master' into aosp/master.
Merge Chromium ToT to AOSP:
git fetch aosp upstream-master
git merge -X patience aosp/upstream-master
Bug: 112326236
Test: libbrillo_test
Change-Id: I35fbbddad556b051ce12b9cdd95bb2afef3cf6af
diff --git a/Android.bp b/Android.bp
new file mode 100644
index 0000000..6b4b64e
--- /dev/null
+++ b/Android.bp
@@ -0,0 +1,296 @@
+// 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.
+
+// Default values for the USE flags. Override these USE flags from your product
+// by setting BRILLO_USE_* values. Note that we define local variables like
+// local_use_* to prevent leaking our default setting for other packages.
+
+libbrillo_core_sources = [
+ "brillo/backoff_entry.cc",
+ "brillo/data_encoding.cc",
+ "brillo/errors/error.cc",
+ "brillo/errors/error_codes.cc",
+ "brillo/flag_helper.cc",
+ "brillo/imageloader/manifest.cc",
+ "brillo/key_value_store.cc",
+ "brillo/message_loops/base_message_loop.cc",
+ "brillo/message_loops/message_loop.cc",
+ "brillo/message_loops/message_loop_utils.cc",
+ "brillo/mime_utils.cc",
+ "brillo/osrelease_reader.cc",
+ "brillo/process.cc",
+ "brillo/process_information.cc",
+ "brillo/secure_blob.cc",
+ "brillo/strings/string_utils.cc",
+ "brillo/syslog_logging.cc",
+ "brillo/type_name_undecorate.cc",
+ "brillo/url_utils.cc",
+ "brillo/userdb_utils.cc",
+ "brillo/value_conversion.cc",
+]
+
+libbrillo_linux_sources = [
+ "brillo/asynchronous_signal_handler.cc",
+ "brillo/daemons/daemon.cc",
+ "brillo/file_utils.cc",
+ "brillo/process_reaper.cc",
+]
+
+libbrillo_binder_sources = ["brillo/binder_watcher.cc"]
+
+libbrillo_http_sources = [
+ "brillo/http/curl_api.cc",
+ "brillo/http/http_connection_curl.cc",
+ "brillo/http/http_form_data.cc",
+ "brillo/http/http_request.cc",
+ "brillo/http/http_transport.cc",
+ "brillo/http/http_transport_curl.cc",
+ "brillo/http/http_utils.cc",
+]
+
+libbrillo_policy_sources = [
+ "policy/device_policy.cc",
+ "policy/libpolicy.cc",
+]
+
+libbrillo_stream_sources = [
+ "brillo/streams/file_stream.cc",
+ "brillo/streams/input_stream_set.cc",
+ "brillo/streams/memory_containers.cc",
+ "brillo/streams/memory_stream.cc",
+ "brillo/streams/openssl_stream_bio.cc",
+ "brillo/streams/stream.cc",
+ "brillo/streams/stream_errors.cc",
+ "brillo/streams/stream_utils.cc",
+ "brillo/streams/tls_stream.cc",
+]
+
+libbrillo_test_helpers_sources = [
+ "brillo/http/http_connection_fake.cc",
+ "brillo/http/http_transport_fake.cc",
+ "brillo/message_loops/fake_message_loop.cc",
+ "brillo/streams/fake_stream.cc",
+ "brillo/unittest_utils.cc",
+]
+
+libbrillo_test_sources = [
+ "brillo/asynchronous_signal_handler_unittest.cc",
+ "brillo/backoff_entry_unittest.cc",
+ "brillo/data_encoding_unittest.cc",
+ "brillo/enum_flags_unittest.cc",
+ "brillo/errors/error_codes_unittest.cc",
+ "brillo/errors/error_unittest.cc",
+ "brillo/file_utils_unittest.cc",
+ "brillo/flag_helper_unittest.cc",
+ "brillo/http/http_connection_curl_unittest.cc",
+ "brillo/http/http_form_data_unittest.cc",
+ "brillo/http/http_request_unittest.cc",
+ "brillo/http/http_transport_curl_unittest.cc",
+ "brillo/http/http_utils_unittest.cc",
+ "brillo/imageloader/manifest_unittest.cc",
+ "brillo/key_value_store_unittest.cc",
+ "brillo/map_utils_unittest.cc",
+ "brillo/message_loops/base_message_loop_unittest.cc",
+ "brillo/message_loops/fake_message_loop_unittest.cc",
+ "brillo/mime_utils_unittest.cc",
+ "brillo/osrelease_reader_unittest.cc",
+ "brillo/process_reaper_unittest.cc",
+ "brillo/process_unittest.cc",
+ "brillo/secure_blob_unittest.cc",
+ "brillo/streams/fake_stream_unittest.cc",
+ "brillo/streams/file_stream_unittest.cc",
+ "brillo/streams/input_stream_set_unittest.cc",
+ "brillo/streams/memory_containers_unittest.cc",
+ "brillo/streams/memory_stream_unittest.cc",
+ "brillo/streams/openssl_stream_bio_unittests.cc",
+ "brillo/streams/stream_unittest.cc",
+ "brillo/streams/stream_utils_unittest.cc",
+ "brillo/strings/string_utils_unittest.cc",
+ "brillo/unittest_utils.cc",
+ "brillo/url_utils_unittest.cc",
+ "brillo/value_conversion_unittest.cc",
+]
+
+libbrillo_CFLAGS = [
+ "-Wall",
+ "-Werror",
+]
+
+libbrillo_shared_libraries = ["libchrome"]
+
+// Main library, shared and static for host and target
+// ========================================================
+cc_library {
+ name: "libbrillo",
+ host_supported: true,
+ srcs: libbrillo_core_sources,
+ shared_libs: libbrillo_shared_libraries,
+ static_libs: [
+ "libmodpb64",
+ "libgtest_prod",
+ ],
+ cflags: libbrillo_CFLAGS,
+ export_include_dirs: ["."],
+
+ target: {
+ host: {
+ cppflags: ["-D__ANDROID_HOST__"],
+ },
+ android: {
+ srcs: libbrillo_linux_sources,
+ },
+ darwin: {
+ enabled: false
+ }
+ },
+}
+
+// Shared binder library for target
+// ========================================================
+cc_library_shared {
+ name: "libbrillo-binder",
+ srcs: libbrillo_binder_sources,
+ shared_libs: libbrillo_shared_libraries + [
+ "libbinder",
+ "libbrillo",
+ "libutils",
+ ],
+ static_libs: ["libgtest_prod"],
+ cflags: libbrillo_CFLAGS,
+ export_include_dirs: ["."],
+}
+
+// Shared minijail library for target
+// ========================================================
+cc_library_shared {
+ name: "libbrillo-minijail",
+ srcs: [
+ "brillo/minijail/minijail.cc",
+ ],
+ shared_libs: [
+ "libchrome",
+ "libbrillo",
+ "libminijail",
+ ],
+ static_libs: ["libgtest_prod"],
+ cflags: libbrillo_CFLAGS,
+ export_include_dirs: ["."],
+}
+
+// Shared and static stream library for target and host
+// ========================================================
+cc_library {
+ name: "libbrillo-stream",
+ srcs: libbrillo_stream_sources,
+ shared_libs: libbrillo_shared_libraries + [
+ "libbrillo",
+ "libcrypto",
+ "libssl",
+ ],
+ static_libs: ["libgtest_prod"],
+ cflags: libbrillo_CFLAGS,
+ export_include_dirs: ["."],
+
+ host_supported: true,
+ target: {
+ darwin: {
+ enabled: false,
+ },
+ windows: {
+ enabled: false,
+ },
+ },
+}
+
+// Shared http library for target and host
+// ========================================================
+cc_library_shared {
+ name: "libbrillo-http",
+ srcs: libbrillo_http_sources,
+ shared_libs: libbrillo_shared_libraries + [
+ "libbrillo",
+ "libbrillo-stream",
+ "libcurl",
+ ],
+ static_libs: ["libgtest_prod"],
+ cflags: libbrillo_CFLAGS,
+ export_include_dirs: ["."],
+
+ host_supported: true,
+ target: {
+ darwin: {
+ enabled: false,
+ },
+ windows: {
+ enabled: false,
+ },
+ },
+}
+
+// Shared policy library for target
+// ========================================================
+cc_library_shared {
+ name: "libbrillo-policy",
+ srcs: libbrillo_policy_sources,
+ shared_libs: libbrillo_shared_libraries,
+ static_libs: ["libgtest_prod"],
+ cflags: libbrillo_CFLAGS,
+ export_include_dirs: ["."],
+}
+
+
+// Static test-helpers library for target
+// ========================================================
+cc_library_static {
+ name: "libbrillo-test-helpers",
+ srcs: libbrillo_test_helpers_sources,
+ static_libs: [
+ "libgtest",
+ "libgmock",
+ ],
+ shared_libs: libbrillo_shared_libraries + [
+ "libbrillo",
+ "libcurl",
+ "libbrillo-http",
+ "libbrillo-stream",
+ "libcrypto",
+ ],
+ cflags: libbrillo_CFLAGS,
+ cppflags: ["-Wno-sign-compare"],
+ export_include_dirs: ["."],
+}
+
+// Unit tests.
+// ========================================================
+cc_test {
+ name: "libbrillo_test",
+ srcs: libbrillo_test_sources,
+ static_libs: [
+ "libgtest",
+ "libchrome_test_helpers",
+ "libbrillo-test-helpers",
+ "libgmock",
+ "libBionicGtestMain",
+ ],
+ shared_libs: libbrillo_shared_libraries + [
+ "libbrillo",
+ "libcurl",
+ "libbrillo-http",
+ "libbrillo-stream",
+ "libcrypto",
+ "libprotobuf-cpp-lite",
+ ],
+ cflags: libbrillo_CFLAGS,
+ cppflags: ["-Wno-sign-compare"],
+}
diff --git a/Android.mk b/Android.mk
index 0c03883..af20a2f 100644
--- a/Android.mk
+++ b/Android.mk
@@ -12,378 +12,12 @@
# See the License for the specific language governing permissions and
# limitations under the License.
-# Default values for the USE flags. Override these USE flags from your product
-# by setting BRILLO_USE_* values. Note that we define local variables like
-# local_use_* to prevent leaking our default setting for other packages.
-local_use_dbus := $(if $(BRILLO_USE_DBUS),$(BRILLO_USE_DBUS),1)
-
-LOCAL_PATH := $(call my-dir)
-
-libbrillo_cpp_extension := .cc
-libbrillo_core_sources := \
- brillo/backoff_entry.cc \
- brillo/data_encoding.cc \
- brillo/errors/error.cc \
- brillo/errors/error_codes.cc \
- brillo/flag_helper.cc \
- brillo/key_value_store.cc \
- brillo/message_loops/base_message_loop.cc \
- brillo/message_loops/message_loop.cc \
- brillo/message_loops/message_loop_utils.cc \
- brillo/mime_utils.cc \
- brillo/osrelease_reader.cc \
- brillo/process.cc \
- brillo/process_information.cc \
- brillo/secure_blob.cc \
- brillo/strings/string_utils.cc \
- brillo/syslog_logging.cc \
- brillo/type_name_undecorate.cc \
- brillo/url_utils.cc \
- brillo/userdb_utils.cc \
- brillo/value_conversion.cc \
-
-libbrillo_linux_sources := \
- brillo/asynchronous_signal_handler.cc \
- brillo/daemons/daemon.cc \
- brillo/file_utils.cc \
- brillo/process_reaper.cc \
-
-libbrillo_binder_sources := \
- brillo/binder_watcher.cc \
-
-libbrillo_dbus_sources := \
- brillo/any.cc \
- brillo/daemons/dbus_daemon.cc \
- brillo/dbus/async_event_sequencer.cc \
- brillo/dbus/data_serialization.cc \
- brillo/dbus/dbus_connection.cc \
- brillo/dbus/dbus_method_invoker.cc \
- brillo/dbus/dbus_method_response.cc \
- brillo/dbus/dbus_object.cc \
- brillo/dbus/dbus_service_watcher.cc \
- brillo/dbus/dbus_signal.cc \
- brillo/dbus/exported_object_manager.cc \
- brillo/dbus/exported_property_set.cc \
- brillo/dbus/utils.cc \
-
-libbrillo_http_sources := \
- brillo/http/curl_api.cc \
- brillo/http/http_connection_curl.cc \
- brillo/http/http_form_data.cc \
- brillo/http/http_request.cc \
- brillo/http/http_transport.cc \
- brillo/http/http_transport_curl.cc \
- brillo/http/http_utils.cc \
-
-libbrillo_policy_sources := \
- policy/device_policy.cc \
- policy/libpolicy.cc \
-
-libbrillo_stream_sources := \
- brillo/streams/file_stream.cc \
- brillo/streams/input_stream_set.cc \
- brillo/streams/memory_containers.cc \
- brillo/streams/memory_stream.cc \
- brillo/streams/openssl_stream_bio.cc \
- brillo/streams/stream.cc \
- brillo/streams/stream_errors.cc \
- brillo/streams/stream_utils.cc \
- brillo/streams/tls_stream.cc \
-
-libbrillo_test_helpers_sources := \
- brillo/http/http_connection_fake.cc \
- brillo/http/http_transport_fake.cc \
- brillo/message_loops/fake_message_loop.cc \
- brillo/streams/fake_stream.cc \
- brillo/unittest_utils.cc \
-
-libbrillo_test_sources := \
- brillo/asynchronous_signal_handler_unittest.cc \
- brillo/backoff_entry_unittest.cc \
- brillo/data_encoding_unittest.cc \
- brillo/enum_flags_unittest.cc \
- brillo/errors/error_codes_unittest.cc \
- brillo/errors/error_unittest.cc \
- brillo/file_utils_unittest.cc \
- brillo/flag_helper_unittest.cc \
- brillo/http/http_connection_curl_unittest.cc \
- brillo/http/http_form_data_unittest.cc \
- brillo/http/http_request_unittest.cc \
- brillo/http/http_transport_curl_unittest.cc \
- brillo/http/http_utils_unittest.cc \
- brillo/key_value_store_unittest.cc \
- brillo/map_utils_unittest.cc \
- brillo/message_loops/base_message_loop_unittest.cc \
- brillo/message_loops/fake_message_loop_unittest.cc \
- brillo/mime_utils_unittest.cc \
- brillo/osrelease_reader_unittest.cc \
- brillo/process_reaper_unittest.cc \
- brillo/process_unittest.cc \
- brillo/secure_blob_unittest.cc \
- brillo/streams/fake_stream_unittest.cc \
- brillo/streams/file_stream_unittest.cc \
- brillo/streams/input_stream_set_unittest.cc \
- brillo/streams/memory_containers_unittest.cc \
- brillo/streams/memory_stream_unittest.cc \
- brillo/streams/openssl_stream_bio_unittests.cc \
- brillo/streams/stream_unittest.cc \
- brillo/streams/stream_utils_unittest.cc \
- brillo/strings/string_utils_unittest.cc \
- brillo/type_name_undecorate_unittest.cc \
- brillo/unittest_utils.cc \
- brillo/url_utils_unittest.cc \
- brillo/value_conversion_unittest.cc \
-
-libbrillo_dbus_test_sources := \
- brillo/any_unittest.cc \
- brillo/any_internal_impl_unittest.cc \
- brillo/dbus/async_event_sequencer_unittest.cc \
- brillo/dbus/data_serialization_unittest.cc \
- brillo/dbus/dbus_method_invoker_unittest.cc \
- brillo/dbus/dbus_object_unittest.cc \
- brillo/dbus/dbus_param_reader_unittest.cc \
- brillo/dbus/dbus_param_writer_unittest.cc \
- brillo/dbus/dbus_signal_handler_unittest.cc \
- brillo/dbus/exported_object_manager_unittest.cc \
- brillo/dbus/exported_property_set_unittest.cc \
- brillo/dbus/test.proto \
- brillo/variant_dictionary_unittest.cc \
-
-libbrillo_CFLAGS := \
- -Wall \
- -Werror \
- -DUSE_DBUS=$(local_use_dbus)
-libbrillo_CPPFLAGS :=
-libbrillo_includes := external/gtest/include
-libbrillo_shared_libraries := libchrome
-
-# Shared library for target
-# ========================================================
-include $(CLEAR_VARS)
-LOCAL_CPP_EXTENSION := $(libbrillo_cpp_extension)
-LOCAL_MODULE := libbrillo
-LOCAL_SRC_FILES := $(libbrillo_core_sources) $(libbrillo_linux_sources)
-LOCAL_C_INCLUDES := $(libbrillo_includes)
-LOCAL_SHARED_LIBRARIES := $(libbrillo_shared_libraries)
-LOCAL_STATIC_LIBRARIES := libmodpb64
-LOCAL_CFLAGS := $(libbrillo_CFLAGS)
-LOCAL_CPPFLAGS := $(libbrillo_CPPFLAGS)
-LOCAL_CLANG := true
-LOCAL_EXPORT_C_INCLUDE_DIRS := $(LOCAL_PATH)
-include $(BUILD_SHARED_LIBRARY)
-
-# Shared binder library for target
-# ========================================================
-include $(CLEAR_VARS)
-LOCAL_CPP_EXTENSION := $(libbrillo_cpp_extension)
-LOCAL_MODULE := libbrillo-binder
-LOCAL_SRC_FILES := $(libbrillo_binder_sources)
-LOCAL_C_INCLUDES := $(libbrillo_includes)
-LOCAL_SHARED_LIBRARIES := \
- $(libbrillo_shared_libraries) \
- libbinder \
- libbrillo \
- libutils
-LOCAL_CFLAGS := $(libbrillo_CFLAGS)
-LOCAL_CPPFLAGS := $(libbrillo_CPPFLAGS)
-LOCAL_CLANG := true
-LOCAL_EXPORT_C_INCLUDE_DIRS := $(LOCAL_PATH)
-include $(BUILD_SHARED_LIBRARY)
-
-ifeq ($(local_use_dbus),1)
-
-# Shared dbus library for target
-# ========================================================
-include $(CLEAR_VARS)
-LOCAL_CPP_EXTENSION := $(libbrillo_cpp_extension)
-LOCAL_MODULE := libbrillo-dbus
-LOCAL_SRC_FILES := $(libbrillo_dbus_sources)
-LOCAL_C_INCLUDES := $(libbrillo_includes)
-LOCAL_SHARED_LIBRARIES := $(libbrillo_shared_libraries) libbrillo \
- libchrome-dbus libdbus
-LOCAL_CFLAGS := $(libbrillo_CFLAGS)
-LOCAL_CPPFLAGS := $(libbrillo_CPPFLAGS)
-LOCAL_CLANG := true
-LOCAL_EXPORT_C_INCLUDE_DIRS := $(LOCAL_PATH) external/dbus
-include $(BUILD_SHARED_LIBRARY)
-
-endif # local_use_dbus == 1
-
-# Shared minijail library for target
-# ========================================================
-include $(CLEAR_VARS)
-LOCAL_CPP_EXTENSION := $(libbrillo_cpp_extension)
-LOCAL_MODULE := libbrillo-minijail
-LOCAL_SRC_FILES := brillo/minijail/minijail.cc \
-
-LOCAL_C_INCLUDES := $(libbrillo_includes)
-LOCAL_SHARED_LIBRARIES := $(libbrillo_shared_libraries) libbrillo \
- libminijail
-LOCAL_CFLAGS := $(libbrillo_CFLAGS)
-LOCAL_CPPFLAGS := $(libbrillo_CPPFLAGS)
-LOCAL_CLANG := true
-LOCAL_EXPORT_C_INCLUDE_DIRS := $(LOCAL_PATH)
-include $(BUILD_SHARED_LIBRARY)
-
-# Shared stream library for target
-# ========================================================
-include $(CLEAR_VARS)
-LOCAL_CPP_EXTENSION := $(libbrillo_cpp_extension)
-LOCAL_MODULE := libbrillo-stream
-LOCAL_SRC_FILES := $(libbrillo_stream_sources)
-LOCAL_C_INCLUDES := $(libbrillo_includes)
-LOCAL_SHARED_LIBRARIES := $(libbrillo_shared_libraries) libbrillo \
- libcrypto libssl
-LOCAL_CFLAGS := $(libbrillo_CFLAGS)
-LOCAL_CPPFLAGS := $(libbrillo_CPPFLAGS)
-LOCAL_CLANG := true
-LOCAL_EXPORT_C_INCLUDE_DIRS := $(LOCAL_PATH)
-include $(BUILD_SHARED_LIBRARY)
-
-# Shared http library for target
-# ========================================================
-include $(CLEAR_VARS)
-LOCAL_CPP_EXTENSION := $(libbrillo_cpp_extension)
-LOCAL_MODULE := libbrillo-http
-LOCAL_SRC_FILES := $(libbrillo_http_sources)
-LOCAL_C_INCLUDES := $(libbrillo_includes)
-LOCAL_SHARED_LIBRARIES := $(libbrillo_shared_libraries) libbrillo \
- libbrillo-stream libcurl
-LOCAL_CFLAGS := $(libbrillo_CFLAGS)
-LOCAL_CPPFLAGS := $(libbrillo_CPPFLAGS)
-LOCAL_CLANG := true
-LOCAL_EXPORT_C_INCLUDE_DIRS := $(LOCAL_PATH)
-include $(BUILD_SHARED_LIBRARY)
-
-# Shared policy library for target
-# ========================================================
-include $(CLEAR_VARS)
-LOCAL_CPP_EXTENSION := $(libbrillo_cpp_extension)
-LOCAL_MODULE := libbrillo-policy
-LOCAL_SRC_FILES := $(libbrillo_policy_sources)
-LOCAL_C_INCLUDES := $(libbrillo_includes)
-LOCAL_SHARED_LIBRARIES := $(libbrillo_shared_libraries)
-LOCAL_CFLAGS := $(libbrillo_CFLAGS)
-LOCAL_CPPFLAGS := $(libbrillo_CPPFLAGS)
-LOCAL_CLANG := true
-LOCAL_EXPORT_C_INCLUDE_DIRS := $(LOCAL_PATH)
-include $(BUILD_SHARED_LIBRARY)
-
-# Static library for target
-# ========================================================
-include $(CLEAR_VARS)
-LOCAL_CPP_EXTENSION := $(libbrillo_cpp_extension)
-LOCAL_MODULE := libbrillo
-LOCAL_SRC_FILES := $(libbrillo_core_sources) $(libbrillo_linux_sources)
-LOCAL_C_INCLUDES := $(libbrillo_includes)
-LOCAL_SHARED_LIBRARIES := $(libbrillo_shared_libraries)
-LOCAL_STATIC_LIBRARIES := libmodpb64
-LOCAL_CFLAGS := $(libbrillo_CFLAGS)
-LOCAL_CPPFLAGS := $(libbrillo_CPPFLAGS)
-LOCAL_CLANG := true
-LOCAL_EXPORT_C_INCLUDE_DIRS := $(LOCAL_PATH)
-include $(BUILD_STATIC_LIBRARY)
-
-# Static test-helpers library for target
-# ========================================================
-include $(CLEAR_VARS)
-LOCAL_CPP_EXTENSION := $(libbrillo_cpp_extension)
-LOCAL_MODULE := libbrillo-test-helpers
-LOCAL_SRC_FILES := $(libbrillo_test_helpers_sources)
-LOCAL_C_INCLUDES := $(libbrillo_includes)
-LOCAL_STATIC_LIBRARIES := libgtest libgmock
-LOCAL_SHARED_LIBRARIES := $(libbrillo_shared_libraries) libbrillo libcurl \
- libbrillo-http libbrillo-stream libcrypto
-LOCAL_CFLAGS := $(libbrillo_CFLAGS)
-LOCAL_CPPFLAGS := $(libbrillo_CPPFLAGS) -Wno-sign-compare
-LOCAL_CLANG := true
-LOCAL_EXPORT_C_INCLUDE_DIRS := $(LOCAL_PATH)
-include $(BUILD_STATIC_LIBRARY)
-
-# Shared library for host
-# ========================================================
-include $(CLEAR_VARS)
-LOCAL_CPP_EXTENSION := $(libbrillo_cpp_extension)
-LOCAL_MODULE := libbrillo
-LOCAL_SRC_FILES := $(libbrillo_core_sources)
-LOCAL_C_INCLUDES := $(libbrillo_includes)
-LOCAL_SHARED_LIBRARIES := $(libbrillo_shared_libraries)
-LOCAL_STATIC_LIBRARIES := libmodpb64-host
-LOCAL_CFLAGS := $(libbrillo_CFLAGS)
-LOCAL_CPPFLAGS := \
- -D__ANDROID_HOST__ \
- $(libbrillo_CPPFLAGS)
-LOCAL_CLANG := true
-LOCAL_EXPORT_C_INCLUDE_DIRS := $(LOCAL_PATH)
-include $(BUILD_HOST_SHARED_LIBRARY)
-
-ifeq ($(HOST_OS),linux)
-
-# Shared stream library for host
-# ========================================================
-include $(CLEAR_VARS)
-LOCAL_CPP_EXTENSION := $(libbrillo_cpp_extension)
-LOCAL_MODULE := libbrillo-stream
-LOCAL_SRC_FILES := $(libbrillo_stream_sources)
-LOCAL_C_INCLUDES := $(libbrillo_includes)
-LOCAL_SHARED_LIBRARIES := $(libbrillo_shared_libraries) libbrillo \
- libcrypto-host libssl-host
-LOCAL_CFLAGS := $(libbrillo_CFLAGS)
-LOCAL_CPPFLAGS := $(libbrillo_CPPFLAGS)
-LOCAL_CLANG := true
-LOCAL_EXPORT_C_INCLUDE_DIRS := $(LOCAL_PATH)
-include $(BUILD_HOST_SHARED_LIBRARY)
-
-# Shared http library for host
-# ========================================================
-include $(CLEAR_VARS)
-LOCAL_CPP_EXTENSION := $(libbrillo_cpp_extension)
-LOCAL_MODULE := libbrillo-http
-LOCAL_SRC_FILES := $(libbrillo_http_sources)
-LOCAL_C_INCLUDES := $(libbrillo_includes)
-LOCAL_SHARED_LIBRARIES := $(libbrillo_shared_libraries) libbrillo \
- libbrillo-stream libcurl-host
-LOCAL_CFLAGS := $(libbrillo_CFLAGS)
-LOCAL_CPPFLAGS := $(libbrillo_CPPFLAGS)
-LOCAL_CLANG := true
-LOCAL_EXPORT_C_INCLUDE_DIRS := $(LOCAL_PATH)
-include $(BUILD_HOST_SHARED_LIBRARY)
-
-endif # HOST_OS == linux
-
-# Unit tests.
-# ========================================================
-include $(CLEAR_VARS)
-LOCAL_CPP_EXTENSION := $(libbrillo_cpp_extension)
-LOCAL_MODULE := libbrillo_test
-LOCAL_MODULE_CLASS := EXECUTABLES
-ifdef BRILLO
- LOCAL_MODULE_TAGS := eng
-endif
-generated_sources_dir := $(call local-generated-sources-dir)
-LOCAL_SRC_FILES := $(libbrillo_test_sources)
-LOCAL_C_INCLUDES := \
- $(libbrillo_includes) \
- $(generated_sources_dir)/proto/external/libbrillo
-LOCAL_STATIC_LIBRARIES := libgtest libchrome_test_helpers \
- libbrillo-test-helpers libgmock libBionicGtestMain
-LOCAL_SHARED_LIBRARIES := $(libbrillo_shared_libraries) libbrillo libcurl \
- libbrillo-http libbrillo-stream libcrypto libprotobuf-cpp-lite
-ifeq ($(local_use_dbus),1)
-LOCAL_SRC_FILES += $(libbrillo_dbus_test_sources)
-LOCAL_STATIC_LIBRARIES += libchrome_dbus_test_helpers
-LOCAL_SHARED_LIBRARIES += libbrillo-dbus libchrome-dbus libdbus
-endif # local_use_dbus == 1
-LOCAL_CFLAGS := $(libbrillo_CFLAGS)
-LOCAL_CPPFLAGS := $(libbrillo_CPPFLAGS) -Wno-sign-compare
-LOCAL_CLANG := true
-include $(BUILD_NATIVE_TEST)
-
# Run unit tests on target
# ========================================================
# We su shell because process tests try setting "illegal"
# uid/gids and expecting failures, but root can legally
# set those to any value.
+.PHONY: runtargettests
runtargettests: libbrillo_test
adb sync
adb shell su shell /data/nativetest/libbrillo_test/libbrillo_test
diff --git a/OWNERS b/OWNERS
index 6f082dc..6cee318 100644
--- a/OWNERS
+++ b/OWNERS
@@ -1,4 +1,13 @@
set noparent
-derat@chromium.org
-vapier@chromium.org
-ejcaruso@chromium.org
+
+# Android owners
+avakulenko@google.com
+dpursell@google.com
+senj@google.com
+stevefung@google.com
+
+# Chromium owners
+benchan@google.com
+derat@google.com
+vapier@google.com
+ejcaruso@google.com
diff --git a/brillo/any_internal_impl.h b/brillo/any_internal_impl.h
index 0154d4d..9309f5d 100644
--- a/brillo/any_internal_impl.h
+++ b/brillo/any_internal_impl.h
@@ -69,7 +69,8 @@
// IntWrapper when both overloads are provided.
// Also this constructor must NOT be explicit.
// NOLINTNEXTLINE(runtime/explicit)
- IntWrapper(int /* dummy */) {} // do nothing
+ // NOLINT: Allow implicit conversion from int.
+ IntWrapper(int /* dummy */) {} // do nothing, NOLINT
};
// Here is an obscure trick to determine if a type U has operator==().
diff --git a/brillo/bind_lambda.h b/brillo/bind_lambda.h
index 18c3212..50ac095 100644
--- a/brillo/bind_lambda.h
+++ b/brillo/bind_lambda.h
@@ -30,7 +30,7 @@
class LambdaAdapter<Lambda, R(Lambda::*)(Args... args)> {
public:
typedef R(RunType)(Args...);
- LambdaAdapter(Lambda lambda) : lambda_(lambda) {}
+ explicit LambdaAdapter(Lambda lambda) : lambda_(lambda) {}
R Run(Args... args) { return lambda_(std::forward<Args>(args)...); }
private:
@@ -42,7 +42,7 @@
class LambdaAdapter<Lambda, R(Lambda::*)(Args... args) const> {
public:
typedef R(RunType)(Args...);
- LambdaAdapter(Lambda lambda) : lambda_(lambda) {}
+ explicit LambdaAdapter(Lambda lambda) : lambda_(lambda) {}
R Run(Args... args) { return lambda_(std::forward<Args>(args)...); }
private:
diff --git a/brillo/dbus/data_serialization.h b/brillo/dbus/data_serialization.h
index bad1f6f..1600919 100644
--- a/brillo/dbus/data_serialization.h
+++ b/brillo/dbus/data_serialization.h
@@ -60,6 +60,7 @@
#include <base/files/scoped_file.h>
#include <base/logging.h>
+#include <base/files/scoped_file.h>
#include <brillo/brillo_export.h>
#include <brillo/dbus/file_descriptor.h>
#include <brillo/type_name_undecorate.h>
diff --git a/brillo/dbus/data_serialization_unittest.cc b/brillo/dbus/data_serialization_unittest.cc
index 1b6975d..c7d5e0f 100644
--- a/brillo/dbus/data_serialization_unittest.cc
+++ b/brillo/dbus/data_serialization_unittest.cc
@@ -6,6 +6,7 @@
#include <limits>
+#include <base/files/scoped_file.h>
#include <brillo/variant_dictionary.h>
#include <gtest/gtest.h>
diff --git a/brillo/dbus/dbus_method_invoker.h b/brillo/dbus/dbus_method_invoker.h
index 8ce4b50..f8b6990 100644
--- a/brillo/dbus/dbus_method_invoker.h
+++ b/brillo/dbus/dbus_method_invoker.h
@@ -175,7 +175,7 @@
ErrorPtr* error,
std::tuple<ResultTypes...>* val_tuple) {
auto callback = [val_tuple](const ResultTypes&... params) {
- *val_tuple = std::forward_as_tuple(internal::HackMove(params)...);
+ *val_tuple = std::forward_as_tuple(params...);
};
return DBusParamReader<false, ResultTypes...>::Invoke(
callback, reader, error);
@@ -188,7 +188,7 @@
ErrorPtr* error,
std::tuple<ResultTypes&...>* ref_tuple) {
auto callback = [ref_tuple](const ResultTypes&... params) {
- *ref_tuple = std::forward_as_tuple(internal::HackMove(params)...);
+ *ref_tuple = std::forward_as_tuple(params...);
};
return DBusParamReader<false, ResultTypes...>::Invoke(
callback, reader, error);
diff --git a/brillo/dbus/dbus_method_invoker_unittest.cc b/brillo/dbus/dbus_method_invoker_unittest.cc
index 4dc1f49..34f4c6f 100644
--- a/brillo/dbus/dbus_method_invoker_unittest.cc
+++ b/brillo/dbus/dbus_method_invoker_unittest.cc
@@ -6,6 +6,7 @@
#include <string>
+#include <base/files/scoped_file.h>
#include <brillo/bind_lambda.h>
#include <dbus/mock_bus.h>
#include <dbus/mock_object_proxy.h>
diff --git a/brillo/dbus/dbus_object.cc b/brillo/dbus/dbus_object.cc
index 83c4c09..512cd6f 100644
--- a/brillo/dbus/dbus_object.cc
+++ b/brillo/dbus/dbus_object.cc
@@ -125,7 +125,7 @@
return;
}
object_manager->ClaimInterface(object_path, interface_name_, writer);
- release_interface_cb_.Reset(
+ release_interface_cb_.ReplaceClosure(
base::Bind(&ExportedObjectManager::ReleaseInterface,
object_manager, object_path, interface_name_));
}
diff --git a/brillo/dbus/dbus_object_internal_impl.h b/brillo/dbus/dbus_object_internal_impl.h
index 5f174d4..3c5e8d7 100644
--- a/brillo/dbus/dbus_object_internal_impl.h
+++ b/brillo/dbus/dbus_object_internal_impl.h
@@ -341,7 +341,7 @@
public:
// A constructor that takes a |handler| to be called when HandleMethod()
// virtual function is invoked.
- RawDBusInterfaceMethodHandler(
+ explicit RawDBusInterfaceMethodHandler(
const base::Callback<void(dbus::MethodCall*, ResponseSender)>& handler)
: handler_(handler) {}
diff --git a/brillo/dbus/dbus_signal_handler.h b/brillo/dbus/dbus_signal_handler.h
index 5bf1d1c..15cdae1 100644
--- a/brillo/dbus/dbus_signal_handler.h
+++ b/brillo/dbus/dbus_signal_handler.h
@@ -38,29 +38,31 @@
const std::string& signal_name,
base::Callback<void(Args...)> signal_callback,
dbus::ObjectProxy::OnConnectedCallback on_connected_callback) {
- // DBusParamReader::Invoke() needs a functor object, not a base::Callback.
- // Wrap the callback with lambda so we can redirect the call.
- auto signal_callback_wrapper = [signal_callback](const Args&... args) {
- if (!signal_callback.is_null()) {
- signal_callback.Run(args...);
- }
- };
-
// Raw signal handler stub method. When called, unpacks the signal arguments
// from |signal| message buffer and redirects the call to
// |signal_callback_wrapper| which, in turn, would call the user-provided
// |signal_callback|.
- auto dbus_signal_callback = [](std::function<void(const Args&...)> callback,
- dbus::Signal* signal) {
+ auto dbus_signal_callback = [](
+ const base::Callback<void(Args...)>& signal_callback,
+ dbus::Signal* signal) {
+ // DBusParamReader::Invoke() needs a functor object, not a base::Callback.
+ // Wrap the callback with lambda so we can redirect the call.
+ auto signal_callback_wrapper = [signal_callback](const Args&... args) {
+ if (!signal_callback.is_null()) {
+ signal_callback.Run(args...);
+ }
+ };
+
dbus::MessageReader reader(signal);
- DBusParamReader<false, Args...>::Invoke(callback, &reader, nullptr);
+ DBusParamReader<false, Args...>::Invoke(
+ signal_callback_wrapper, &reader, nullptr);
};
// Register our stub handler with D-Bus ObjectProxy.
object_proxy->ConnectToSignal(
interface_name,
signal_name,
- base::Bind(dbus_signal_callback, signal_callback_wrapper),
+ base::Bind(dbus_signal_callback, signal_callback),
on_connected_callback);
}
diff --git a/brillo/flag_helper.h b/brillo/flag_helper.h
index 47f7018..810a00c 100644
--- a/brillo/flag_helper.h
+++ b/brillo/flag_helper.h
@@ -204,7 +204,7 @@
// for defining bool flags
#define DEFINE_bool(name, value, help) \
bool FLAGS_##name = value; \
- bool FLAGS_no##name = !value; \
+ bool FLAGS_no##name = !(value); \
brillo::FlagHelper::GetInstance()->AddFlag( \
std::unique_ptr<brillo::Flag>(new brillo::BoolFlag( \
#name, &FLAGS_##name, &FLAGS_no##name, #value, help, true))); \
diff --git a/brillo/http/http_connection_fake.cc b/brillo/http/http_connection_fake.cc
index 0e14c7d..15e5181 100644
--- a/brillo/http/http_connection_fake.cc
+++ b/brillo/http/http_connection_fake.cc
@@ -68,9 +68,11 @@
const ErrorCallback& error_callback) {
connection->FinishRequestAsyncHelper(success_callback, error_callback);
};
- transport_->RunCallbackAsync(
- FROM_HERE,
- base::Bind(callback, connection, success_callback, error_callback));
+ transport_->RunCallbackAsync(FROM_HERE,
+ base::Bind(callback,
+ base::Passed(&connection),
+ success_callback,
+ error_callback));
return 1;
}
diff --git a/brillo/http/http_form_data.h b/brillo/http/http_form_data.h
index 55ec150..e12d3d8 100644
--- a/brillo/http/http_form_data.h
+++ b/brillo/http/http_form_data.h
@@ -155,7 +155,7 @@
// content_type: valid content type. If omitted, "multipart/mixed" is used.
// boundary: multipart boundary separator.
// If omitted/empty, a random string is generated.
- MultiPartFormField(const std::string& name,
+ explicit MultiPartFormField(const std::string& name,
const std::string& content_type = {},
const std::string& boundary = {});
diff --git a/brillo/http/http_transport_curl.cc b/brillo/http/http_transport_curl.cc
index 1bce6fa..e0d78d5 100644
--- a/brillo/http/http_transport_curl.cc
+++ b/brillo/http/http_transport_curl.cc
@@ -362,8 +362,8 @@
poll_data->GetWatcher()->StopWatchingFileDescriptor();
// This method can be called indirectly from SocketPollData::OnSocketReady,
// so delay destruction of SocketPollData object till the next loop cycle.
- base::MessageLoopForIO::current()->task_runner()->DeleteSoon(
- FROM_HERE, poll_data);
+ base::MessageLoopForIO::current()->task_runner()->DeleteSoon(FROM_HERE,
+ poll_data);
return 0;
}
diff --git a/brillo/http/http_transport_fake.cc b/brillo/http/http_transport_fake.cc
index ad74173..cda885f 100644
--- a/brillo/http/http_transport_fake.cc
+++ b/brillo/http/http_transport_fake.cc
@@ -121,14 +121,15 @@
int status_code,
const std::string& reply_text,
const std::string& mime_type) {
- auto handler = [](
- int status_code, const std::string& reply_text,
- const std::string& mime_type, const ServerRequest& /* request */,
- ServerResponse* response) {
+ auto handler = [](int status_code,
+ const std::string& reply_text,
+ const std::string& mime_type,
+ const ServerRequest& /* request */,
+ ServerResponse* response) {
response->ReplyText(status_code, reply_text, mime_type);
};
- AddHandler(url, method,
- base::Bind(handler, status_code, reply_text, mime_type));
+ AddHandler(
+ url, method, base::Bind(handler, status_code, reply_text, mime_type));
}
Transport::HandlerCallback Transport::GetHandler(
diff --git a/brillo/http/http_utils_unittest.cc b/brillo/http/http_utils_unittest.cc
index d619bb3..376ba53 100644
--- a/brillo/http/http_utils_unittest.cc
+++ b/brillo/http/http_utils_unittest.cc
@@ -68,15 +68,14 @@
// Test binary data round-tripping.
std::vector<uint8_t> custom_data{0xFF, 0x00, 0x80, 0x40, 0xC0, 0x7F};
- auto success_callback =
- base::Bind([](const std::vector<uint8_t>& custom_data,
- RequestID /* id */,
- std::unique_ptr<http::Response> response) {
+ auto success_callback = [](const std::vector<uint8_t>& custom_data,
+ RequestID /* id */,
+ std::unique_ptr<http::Response> response) {
EXPECT_TRUE(response->IsSuccessful());
EXPECT_EQ(brillo::mime::application::kOctet_stream,
response->GetContentType());
EXPECT_EQ(custom_data, response->ExtractData());
- }, custom_data);
+ };
auto error_callback = [](RequestID /* id */, const Error* /* error */) {
FAIL() << "This callback shouldn't have been called";
};
@@ -87,7 +86,7 @@
brillo::mime::application::kOctet_stream,
{},
transport,
- success_callback,
+ base::Bind(success_callback, custom_data),
base::Bind(error_callback));
}
@@ -301,21 +300,22 @@
TEST(HttpUtils, PostText) {
std::string fake_data = "Some data";
- auto post_handler = base::Bind([](const std::string& data,
- const fake::ServerRequest& request,
- fake::ServerResponse* response) {
+ auto PostHandler = [](const std::string& fake_data,
+ const fake::ServerRequest& request,
+ fake::ServerResponse* response) {
EXPECT_EQ(request_type::kPost, request.GetMethod());
- EXPECT_EQ(data.size(),
+ EXPECT_EQ(fake_data.size(),
std::stoul(request.GetHeader(request_header::kContentLength)));
EXPECT_EQ(brillo::mime::text::kPlain,
request.GetHeader(request_header::kContentType));
response->ReplyText(status_code::Ok,
request.GetDataAsString(),
brillo::mime::text::kPlain);
- }, fake_data);
+ };
std::shared_ptr<fake::Transport> transport(new fake::Transport);
- transport->AddHandler(kFakeUrl, request_type::kPost, post_handler);
+ transport->AddHandler(
+ kFakeUrl, request_type::kPost, base::Bind(PostHandler, fake_data));
auto response = http::PostTextAndBlock(kFakeUrl,
fake_data,
diff --git a/brillo/location_logging.h b/brillo/location_logging.h
index 1a9929b..9fb3716 100644
--- a/brillo/location_logging.h
+++ b/brillo/location_logging.h
@@ -9,21 +9,16 @@
#include <base/logging.h>
-#define VLOG_LOC_STREAM(from_here, verbose_level) \
- logging::LogMessage(from_here.file_name(), from_here.line_number(), \
- -verbose_level).stream()
+#define VLOG_LOC_STREAM(from_here, verbose_level) \
+ logging::LogMessage((from_here).file_name(), (from_here).line_number(), \
+ -(verbose_level)).stream()
-#define VLOG_LOC(from_here, verbose_level) \
- LAZY_STREAM(VLOG_LOC_STREAM(from_here, verbose_level), \
+#define VLOG_LOC(from_here, verbose_level) \
+ LAZY_STREAM(VLOG_LOC_STREAM(from_here, verbose_level), \
VLOG_IS_ON(verbose_level))
-#if DCHECK_IS_ON()
+#define DVLOG_LOC(from_here, verbose_level) \
+ LAZY_STREAM(VLOG_LOC_STREAM(from_here, verbose_level), \
+ DCHECK_IS_ON() && VLOG_IS_ON(verbose_level))
-#define DVLOG_LOC(from_here, verbose_level) VLOG_LOC(from_here, verbose_level)
-
-#else // DCHECK_IS_ON()
-
-#define DVLOG_LOC(from_here, verbose_level) EAT_STREAM_PARAMETERS
-
-#endif // DCHECK_IS_ON()
#endif // LIBBRILLO_BRILLO_LOCATION_LOGGING_H_
diff --git a/brillo/message_loops/base_message_loop.cc b/brillo/message_loops/base_message_loop.cc
index ec85a75..500c29b 100644
--- a/brillo/message_loops/base_message_loop.cc
+++ b/brillo/message_loops/base_message_loop.cc
@@ -9,6 +9,10 @@
#include <sys/types.h>
#include <unistd.h>
+#ifndef __APPLE__
+#include <sys/sysmacros.h>
+#endif
+
#ifndef __ANDROID_HOST__
// Used for MISC_MAJOR. Only required for the target and not always available
// for the host.
diff --git a/brillo/message_loops/fake_message_loop_unittest.cc b/brillo/message_loops/fake_message_loop_unittest.cc
index f73b65a..7dc54f7 100644
--- a/brillo/message_loops/fake_message_loop_unittest.cc
+++ b/brillo/message_loops/fake_message_loop_unittest.cc
@@ -45,17 +45,16 @@
TEST_F(FakeMessageLoopTest, PostDelayedTaskRunsInOrder) {
vector<int> order;
- loop_->PostDelayedTask(Bind([](vector<int>* order) { order->push_back(1); },
- &order),
+ auto callback = [](std::vector<int>* order, int value) {
+ order->push_back(value);
+ };
+ loop_->PostDelayedTask(Bind(callback, base::Unretained(&order), 1),
TimeDelta::FromSeconds(1));
- loop_->PostDelayedTask(Bind([](vector<int>* order) { order->push_back(4); },
- &order),
+ loop_->PostDelayedTask(Bind(callback, base::Unretained(&order), 4),
TimeDelta::FromSeconds(4));
- loop_->PostDelayedTask(Bind([](vector<int>* order) { order->push_back(3); },
- &order),
+ loop_->PostDelayedTask(Bind(callback, base::Unretained(&order), 3),
TimeDelta::FromSeconds(3));
- loop_->PostDelayedTask(Bind([](vector<int>* order) { order->push_back(2); },
- &order),
+ loop_->PostDelayedTask(Bind(callback, base::Unretained(&order), 2),
TimeDelta::FromSeconds(2));
// Run until all the tasks are run.
loop_->Run();
@@ -93,7 +92,7 @@
int called = 0;
TaskId task_id = loop_->WatchFileDescriptor(
FROM_HERE, fd, MessageLoop::kWatchRead, false,
- Bind([](int* called) { (*called)++; }, &called));
+ Bind([](int* called) { (*called)++; }, base::Unretained(&called)));
EXPECT_NE(MessageLoop::kTaskIdNull, task_id);
EXPECT_NE(MessageLoop::kTaskIdNull,
diff --git a/brillo/message_loops/message_loop_utils.cc b/brillo/message_loops/message_loop_utils.cc
index d58711b..9ebe865 100644
--- a/brillo/message_loops/message_loop_utils.cc
+++ b/brillo/message_loops/message_loop_utils.cc
@@ -17,7 +17,7 @@
MessageLoop::TaskId task_id = loop->PostDelayedTask(
FROM_HERE,
base::Bind([](bool* timeout_called) { *timeout_called = true; },
- &timeout_called),
+ base::Unretained(&timeout_called)),
timeout);
while (!timeout_called && (terminate.is_null() || !terminate.Run()))
loop->RunOnce(true);
diff --git a/brillo/minijail/minijail.cc b/brillo/minijail/minijail.cc
index 4d47c05..305f073 100644
--- a/brillo/minijail/minijail.cc
+++ b/brillo/minijail/minijail.cc
@@ -11,15 +11,14 @@
namespace brillo {
-static base::LazyInstance<Minijail> g_minijail = LAZY_INSTANCE_INITIALIZER;
-
Minijail::Minijail() {}
Minijail::~Minijail() {}
// static
Minijail* Minijail::GetInstance() {
- return g_minijail.Pointer();
+ static Minijail* minijail = new Minijail();
+ return minijail;
}
struct minijail* Minijail::New() {
diff --git a/brillo/minijail/minijail.h b/brillo/minijail/minijail.h
index 4c1431d..15167cf 100644
--- a/brillo/minijail/minijail.h
+++ b/brillo/minijail/minijail.h
@@ -12,10 +12,10 @@
#include <sys/types.h>
}
-#include <base/lazy_instance.h>
-
#include <libminijail.h>
+#include "base/macros.h"
+
namespace brillo {
// A Minijail abstraction allowing Minijail mocking in tests.
@@ -108,8 +108,6 @@
Minijail();
private:
- friend struct base::DefaultLazyInstanceTraits<Minijail>;
-
DISALLOW_COPY_AND_ASSIGN(Minijail);
};
diff --git a/brillo/osrelease_reader.cc b/brillo/osrelease_reader.cc
index 6e4bf90..c8f660e 100644
--- a/brillo/osrelease_reader.cc
+++ b/brillo/osrelease_reader.cc
@@ -41,9 +41,8 @@
path = enumerator.Next()) {
std::string content;
if (!base::ReadFileToString(path, &content)) {
- // The only way to fail is if a file exist in /etc/os-release.d but we
- // cannot read it.
- PLOG(FATAL) << "Could not read " << path.value();
+ PLOG(ERROR) << "Could not read " << path.value();
+ continue;
}
// There might be a trailing new line. Strip it to keep only the first line
// of the file.
diff --git a/brillo/process.cc b/brillo/process.cc
index 7768894..8773244 100644
--- a/brillo/process.cc
+++ b/brillo/process.cc
@@ -18,6 +18,7 @@
#include <base/files/file_path.h>
#include <base/files/file_util.h>
#include <base/logging.h>
+#include <base/memory/ptr_util.h>
#include <base/posix/eintr_wrapper.h>
#include <base/process/process_metrics.h>
#include <base/strings/string_number_conversions.h>
diff --git a/brillo/streams/fake_stream_unittest.cc b/brillo/streams/fake_stream_unittest.cc
index b198b17..2404514 100644
--- a/brillo/streams/fake_stream_unittest.cc
+++ b/brillo/streams/fake_stream_unittest.cc
@@ -288,10 +288,12 @@
(*error_count)++;
};
- EXPECT_TRUE(stream_->ReadAllAsync(buffer.data(), buffer.size(),
- base::Bind(on_success, &success_count),
- base::Bind(on_failure, &error_count),
- nullptr));
+ EXPECT_TRUE(stream_->ReadAllAsync(
+ buffer.data(),
+ buffer.size(),
+ base::Bind(on_success, base::Unretained(&success_count)),
+ base::Bind(on_failure, base::Unretained(&error_count)),
+ nullptr));
mock_loop_.Run();
EXPECT_EQ(1, success_count);
EXPECT_EQ(0, error_count);
@@ -443,10 +445,12 @@
(*error_count)++;
};
- EXPECT_TRUE(stream_->WriteAllAsync(output_data.data(), output_data.size(),
- base::Bind(on_success, &success_count),
- base::Bind(on_failure, &error_count),
- nullptr));
+ EXPECT_TRUE(stream_->WriteAllAsync(
+ output_data.data(),
+ output_data.size(),
+ base::Bind(on_success, base::Unretained(&success_count)),
+ base::Bind(on_failure, base::Unretained(&error_count)),
+ nullptr));
mock_loop_.Run();
EXPECT_EQ(1, success_count);
EXPECT_EQ(0, error_count);
@@ -459,12 +463,12 @@
auto two_sec_delay = base::TimeDelta::FromSeconds(2);
int call_count = 0;
- auto callback = base::Bind([](int* call_count,
- Stream::AccessMode mode,
- Stream::AccessMode expected_mode) {
+ auto callback = [](int* call_count,
+ Stream::AccessMode mode,
+ Stream::AccessMode expected_mode) {
(*call_count)++;
EXPECT_EQ(static_cast<int>(expected_mode), static_cast<int>(mode));
- }, &call_count);
+ };
stream_->AddReadPacketString(one_sec_delay, "foo");
stream_->ExpectWritePacketString(two_sec_delay, "bar");
@@ -472,6 +476,7 @@
EXPECT_CALL(mock_loop_, PostDelayedTask(_, _, one_sec_delay)).Times(1);
EXPECT_TRUE(stream_->WaitForData(Stream::AccessMode::READ_WRITE,
base::Bind(callback,
+ base::Unretained(&call_count),
Stream::AccessMode::READ),
nullptr));
mock_loop_.Run();
@@ -483,6 +488,7 @@
EXPECT_CALL(mock_loop_, PostDelayedTask(_, _, one_sec_delay)).Times(1);
EXPECT_TRUE(stream_->WaitForData(Stream::AccessMode::READ_WRITE,
base::Bind(callback,
+ base::Unretained(&call_count),
Stream::AccessMode::WRITE),
nullptr));
mock_loop_.Run();
@@ -493,6 +499,7 @@
EXPECT_CALL(mock_loop_, PostDelayedTask(_, _, zero_delay)).Times(1);
EXPECT_TRUE(stream_->WaitForData(Stream::AccessMode::READ_WRITE,
base::Bind(callback,
+ base::Unretained(&call_count),
Stream::AccessMode::READ_WRITE),
nullptr));
mock_loop_.Run();
@@ -506,6 +513,7 @@
EXPECT_CALL(mock_loop_, PostDelayedTask(_, _, one_sec_delay)).Times(1);
EXPECT_TRUE(stream_->WaitForData(Stream::AccessMode::READ_WRITE,
base::Bind(callback,
+ base::Unretained(&call_count),
Stream::AccessMode::READ_WRITE),
nullptr));
mock_loop_.Run();
diff --git a/brillo/streams/file_stream_unittest.cc b/brillo/streams/file_stream_unittest.cc
index 5f79dc9..210725e 100644
--- a/brillo/streams/file_stream_unittest.cc
+++ b/brillo/streams/file_stream_unittest.cc
@@ -1068,7 +1068,9 @@
};
MessageLoopRunUntil(&brillo_loop,
base::TimeDelta::FromSeconds(1),
- base::Bind(end_condition, &failed, &succeeded));
+ base::Bind(end_condition,
+ base::Unretained(&failed),
+ base::Unretained(&succeeded)));
EXPECT_TRUE(succeeded);
EXPECT_FALSE(failed);
@@ -1088,8 +1090,10 @@
ASSERT_EQ(0, pipe(fds));
- auto success_callback = [](bool* succeeded, const std::string& data,
- int read_fd, size_t /* size */) {
+ auto success_callback = [](bool* succeeded,
+ const std::string& data,
+ int read_fd,
+ size_t /* size */) {
char buffer[100];
EXPECT_TRUE(base::ReadFromFD(read_fd, buffer, data.size()));
EXPECT_EQ(data, (std::string{buffer, buffer + data.size()}));
@@ -1099,16 +1103,20 @@
StreamPtr stream = FileStream::FromFileDescriptor(fds[1], true, nullptr);
EXPECT_TRUE(stream->WriteAsync(
- data.data(), data.size(),
- base::Bind(success_callback, &succeeded, data, fds[0]),
- base::Bind(&SetToTrue, &failed), nullptr));
+ data.data(),
+ data.size(),
+ base::Bind(success_callback, base::Unretained(&succeeded), data, fds[0]),
+ base::Bind(&SetToTrue, &failed),
+ nullptr));
auto end_condition = [](bool* failed, bool* succeeded) {
return *failed || *succeeded;
};
MessageLoopRunUntil(&brillo_loop,
base::TimeDelta::FromSeconds(1),
- base::Bind(end_condition, &failed, &succeeded));
+ base::Bind(end_condition,
+ base::Unretained(&failed),
+ base::Unretained(&succeeded)));
EXPECT_TRUE(succeeded);
EXPECT_FALSE(failed);
diff --git a/brillo/value_conversion.h b/brillo/value_conversion.h
index dcf1d4d..d681f76 100644
--- a/brillo/value_conversion.h
+++ b/brillo/value_conversion.h
@@ -73,7 +73,7 @@
return false;
out_value->clear();
out_value->reserve(list->GetSize());
- for (const base::Value* item : *list) {
+ for (const auto& item : *list) {
T value{};
if (!FromValue(*item, &value))
return false;
diff --git a/policy/libpolicy.cc b/policy/libpolicy.cc
index a4fc380..a0b7640 100644
--- a/policy/libpolicy.cc
+++ b/policy/libpolicy.cc
@@ -24,8 +24,14 @@
PolicyProvider::PolicyProvider(std::unique_ptr<DevicePolicy> device_policy)
: device_policy_(std::move(device_policy)),
+#ifdef __ANDROID__
+ device_policy_is_loaded_(true) {
+}
+#else
device_policy_is_loaded_(true),
- install_attributes_reader_(std::make_unique<InstallAttributesReader>()) {}
+ install_attributes_reader_(std::make_unique<InstallAttributesReader>()) {
+}
+#endif // __ANDROID__
PolicyProvider::~PolicyProvider() {}
@@ -50,13 +56,17 @@
}
bool PolicyProvider::IsConsumerDevice() const {
+#ifdef __ANDROID__
+ return true;
+#else
if (!install_attributes_reader_->IsLocked())
return false;
const std::string& device_mode = install_attributes_reader_->GetAttribute(
InstallAttributesReader::kAttrMode);
return device_mode != InstallAttributesReader::kDeviceModeEnterprise &&
- device_mode != InstallAttributesReader::kDeviceModeEnterpriseAD;
+ device_mode != InstallAttributesReader::kDeviceModeEnterpriseAD;
+#endif // __ANDROID__
}
void PolicyProvider::SetDevicePolicyForTesting(
diff --git a/policy/tests/libpolicy_unittest.cc b/policy/tests/libpolicy_unittest.cc
index 6fc7258..aaf497c 100644
--- a/policy/tests/libpolicy_unittest.cc
+++ b/policy/tests/libpolicy_unittest.cc
@@ -193,6 +193,9 @@
EXPECT_EQ(3, intervals[1].end_day_of_week);
EXPECT_EQ(base::TimeDelta::FromMinutes(20), intervals[1].end_time);
+ ASSERT_TRUE(policy.GetAutoLaunchedKioskAppId(&string_value));
+ ASSERT_EQ("my_kiosk_app", string_value);
+
// Reloading the protobuf should succeed.
EXPECT_TRUE(provider.Reload());
}