Limit btsnoop file size (1/9)
am: 15b70a56fb -s ours
Change-Id: I914ecb0b9c3ed2d76d01b0c93de8f4df3f210f1c
diff --git a/include/hardware/audio_alsaops.h b/include/hardware/audio_alsaops.h
index e994924..6a17a35 100644
--- a/include/hardware/audio_alsaops.h
+++ b/include/hardware/audio_alsaops.h
@@ -22,7 +22,8 @@
#ifndef ANDROID_AUDIO_ALSAOPS_H
#define ANDROID_AUDIO_ALSAOPS_H
-#include <cutils/log.h>
+#include <log/log.h>
+
#include <system/audio.h>
#include <tinyalsa/asoundlib.h>
diff --git a/include/hardware/ble_advertiser.h b/include/hardware/ble_advertiser.h
index 8abca00..02d553f 100644
--- a/include/hardware/ble_advertiser.h
+++ b/include/hardware/ble_advertiser.h
@@ -57,6 +57,9 @@
/** Registers an advertiser with the stack */
virtual void RegisterAdvertiser(IdStatusCallback) = 0;
+ using GetAddressCallback = base::Callback<void(uint8_t /* address_type*/, bt_bdaddr_t /*address*/)>;
+ virtual void GetOwnAddress(uint8_t advertiser_id, GetAddressCallback cb) = 0;
+
/* Set the parameters as per spec, user manual specified values */
virtual void SetParameters(uint8_t advertiser_id, AdvertiseParameters params,
ParametersCallback cb) = 0;
diff --git a/include/hardware/bt_gatt_client.h b/include/hardware/bt_gatt_client.h
index ec8dd16..33a6825 100644
--- a/include/hardware/bt_gatt_client.h
+++ b/include/hardware/bt_gatt_client.h
@@ -224,8 +224,13 @@
bt_status_t (*search_service)(int conn_id, bt_uuid_t *filter_uuid );
/** Read a characteristic on a remote device */
- bt_status_t (*read_characteristic)( int conn_id, uint16_t handle,
- int auth_req );
+ bt_status_t (*read_characteristic)(int conn_id, uint16_t handle,
+ int auth_req);
+
+ /** Read a characteristic on a remote device */
+ bt_status_t (*read_using_characteristic_uuid)(
+ int conn_id, bt_uuid_t *uuid, uint16_t s_handle,
+ uint16_t e_handle, int auth_req);
/** Write a remote characteristic */
bt_status_t (*write_characteristic)(int conn_id, uint16_t handle,
diff --git a/include/hardware/fingerprint.h b/include/hardware/fingerprint.h
index 6e08d6c..86ced9b 100644
--- a/include/hardware/fingerprint.h
+++ b/include/hardware/fingerprint.h
@@ -17,8 +17,8 @@
#ifndef ANDROID_INCLUDE_HARDWARE_FINGERPRINT_H
#define ANDROID_INCLUDE_HARDWARE_FINGERPRINT_H
-#include <hardware/hw_auth_token.h>
#include <hardware/hardware.h>
+#include <hardware/hw_auth_token.h>
#define FINGERPRINT_MODULE_API_VERSION_1_0 HARDWARE_MODULE_API_VERSION(1, 0)
#define FINGERPRINT_MODULE_API_VERSION_2_0 HARDWARE_MODULE_API_VERSION(2, 0)
diff --git a/modules/audio/audio_hw.c b/modules/audio/audio_hw.c
index 43d13a9..8f73f11 100644
--- a/modules/audio/audio_hw.c
+++ b/modules/audio/audio_hw.c
@@ -21,13 +21,16 @@
#include <malloc.h>
#include <pthread.h>
#include <stdint.h>
-#include <sys/time.h>
+#include <stdlib.h>
+#include <string.h>
+#include <time.h>
+#include <unistd.h>
#include <log/log.h>
+#include <hardware/audio.h>
#include <hardware/hardware.h>
#include <system/audio.h>
-#include <hardware/audio.h>
struct stub_audio_device {
struct audio_hw_device device;
diff --git a/modules/audio_remote_submix/audio_hw.cpp b/modules/audio_remote_submix/audio_hw.cpp
index d47cfba..6c538ce 100644
--- a/modules/audio_remote_submix/audio_hw.cpp
+++ b/modules/audio_remote_submix/audio_hw.cpp
@@ -26,9 +26,10 @@
#include <sys/limits.h>
#include <cutils/compiler.h>
-#include <cutils/log.h>
#include <cutils/properties.h>
#include <cutils/str_parms.h>
+#include <log/log.h>
+#include <utils/String8.h>
#include <hardware/audio.h>
#include <hardware/hardware.h>
@@ -39,8 +40,6 @@
#include <media/nbaio/MonoPipe.h>
#include <media/nbaio/MonoPipeReader.h>
-#include <utils/String8.h>
-
#define LOG_STREAMS_TO_FILES 0
#if LOG_STREAMS_TO_FILES
#include <fcntl.h>
diff --git a/modules/camera/3_0/Camera.cpp b/modules/camera/3_0/Camera.cpp
index de3ae78..dc7ffa5 100644
--- a/modules/camera/3_0/Camera.cpp
+++ b/modules/camera/3_0/Camera.cpp
@@ -13,25 +13,30 @@
* See the License for the specific language governing permissions and
* limitations under the License.
*/
+//#define LOG_NDEBUG 0
+#define LOG_TAG "Camera"
+
+#include <errno.h>
+#include <stdint.h>
+#include <stdio.h>
+#include <string.h>
#include <cstdlib>
-#include <stdio.h>
+
+#include <log/log.h>
+#include <utils/Mutex.h>
+
+#define ATRACE_TAG (ATRACE_TAG_CAMERA | ATRACE_TAG_HAL)
+#include <utils/Trace.h>
+
#include <hardware/camera3.h>
#include <sync/sync.h>
#include <system/camera_metadata.h>
#include <system/graphics.h>
-#include <utils/Mutex.h>
#include "CameraHAL.h"
#include "Metadata.h"
#include "Stream.h"
-//#define LOG_NDEBUG 0
-#define LOG_TAG "Camera"
-#include <cutils/log.h>
-
-#define ATRACE_TAG (ATRACE_TAG_CAMERA | ATRACE_TAG_HAL)
-#include <utils/Trace.h>
-
#include "Camera.h"
#define CAMERA_SYNC_TIMEOUT 5000 // in msecs
diff --git a/modules/camera/3_0/CameraHAL.cpp b/modules/camera/3_0/CameraHAL.cpp
index e395ce5..2d1d763 100644
--- a/modules/camera/3_0/CameraHAL.cpp
+++ b/modules/camera/3_0/CameraHAL.cpp
@@ -13,20 +13,20 @@
* See the License for the specific language governing permissions and
* limitations under the License.
*/
+//#define LOG_NDEBUG 0
+#define LOG_TAG "DefaultCameraHAL"
#include <cstdlib>
+
+#include <log/log.h>
+#define ATRACE_TAG (ATRACE_TAG_CAMERA | ATRACE_TAG_HAL)
+#include <cutils/trace.h>
+
#include <hardware/camera_common.h>
#include <hardware/hardware.h>
#include "ExampleCamera.h"
#include "VendorTags.h"
-//#define LOG_NDEBUG 0
-#define LOG_TAG "DefaultCameraHAL"
-#include <cutils/log.h>
-
-#define ATRACE_TAG (ATRACE_TAG_CAMERA | ATRACE_TAG_HAL)
-#include <cutils/trace.h>
-
#include "CameraHAL.h"
/*
diff --git a/modules/camera/3_0/ExampleCamera.cpp b/modules/camera/3_0/ExampleCamera.cpp
index d060d35..473cb60 100644
--- a/modules/camera/3_0/ExampleCamera.cpp
+++ b/modules/camera/3_0/ExampleCamera.cpp
@@ -13,17 +13,18 @@
* See the License for the specific language governing permissions and
* limitations under the License.
*/
-
-#include <system/camera_metadata.h>
-#include "Camera.h"
-
//#define LOG_NDEBUG 0
#define LOG_TAG "ExampleCamera"
-#include <cutils/log.h>
+
+#include <stdint.h>
+
+#include <log/log.h>
#define ATRACE_TAG (ATRACE_TAG_CAMERA | ATRACE_TAG_HAL)
#include <utils/Trace.h>
+#include <system/camera_metadata.h>
+#include "Camera.h"
#include "ExampleCamera.h"
#define ARRAY_SIZE(a) (sizeof(a) / sizeof((a)[0]))
diff --git a/modules/camera/3_0/Metadata.cpp b/modules/camera/3_0/Metadata.cpp
index 18e5239..440da5f 100644
--- a/modules/camera/3_0/Metadata.cpp
+++ b/modules/camera/3_0/Metadata.cpp
@@ -13,12 +13,12 @@
* See the License for the specific language governing permissions and
* limitations under the License.
*/
+//#define LOG_NDEBUG 0
+#define LOG_TAG "Metadata"
#include <system/camera_metadata.h>
-//#define LOG_NDEBUG 0
-#define LOG_TAG "Metadata"
-#include <cutils/log.h>
+#include <log/log.h>
#define ATRACE_TAG (ATRACE_TAG_CAMERA | ATRACE_TAG_HAL)
#include <utils/Trace.h>
diff --git a/modules/camera/3_0/Stream.cpp b/modules/camera/3_0/Stream.cpp
index e0099b6..a38b590 100644
--- a/modules/camera/3_0/Stream.cpp
+++ b/modules/camera/3_0/Stream.cpp
@@ -13,20 +13,21 @@
* See the License for the specific language governing permissions and
* limitations under the License.
*/
-
-#include <stdio.h>
-#include <hardware/camera3.h>
-#include <hardware/gralloc.h>
-#include <system/graphics.h>
-#include <utils/Mutex.h>
-
//#define LOG_NDEBUG 0
#define LOG_TAG "Stream"
-#include <cutils/log.h>
+
+#include <stdio.h>
+
+#include <log/log.h>
+#include <utils/Mutex.h>
#define ATRACE_TAG (ATRACE_TAG_CAMERA | ATRACE_TAG_HAL)
#include <utils/Trace.h>
+#include <hardware/camera3.h>
+#include <hardware/gralloc.h>
+#include <system/graphics.h>
+
#include "Stream.h"
namespace default_camera_hal {
diff --git a/modules/camera/3_0/VendorTags.cpp b/modules/camera/3_0/VendorTags.cpp
index 48c1a46..9a34dc9 100644
--- a/modules/camera/3_0/VendorTags.cpp
+++ b/modules/camera/3_0/VendorTags.cpp
@@ -13,17 +13,19 @@
* See the License for the specific language governing permissions and
* limitations under the License.
*/
-
-#include <system/camera_metadata.h>
-#include "Metadata.h"
-
//#define LOG_NDEBUG 0
#define LOG_TAG "VendorTags"
-#include <cutils/log.h>
+
+#include <stdint.h>
+
+#include <log/log.h>
#define ATRACE_TAG (ATRACE_TAG_CAMERA | ATRACE_TAG_HAL)
#include <utils/Trace.h>
+#include <system/camera_metadata.h>
+#include "Metadata.h"
+
#include "VendorTags.h"
namespace default_camera_hal {
diff --git a/modules/consumerir/consumerir.c b/modules/consumerir/consumerir.c
index 2af6b89..f2cc623 100644
--- a/modules/consumerir/consumerir.c
+++ b/modules/consumerir/consumerir.c
@@ -17,10 +17,14 @@
#include <errno.h>
#include <malloc.h>
+#include <stdlib.h>
#include <string.h>
+#include <unistd.h>
+
#include <log/log.h>
-#include <hardware/hardware.h>
+
#include <hardware/consumerir.h>
+#include <hardware/hardware.h>
#define ARRAY_SIZE(a) (sizeof(a) / sizeof((a)[0]))
diff --git a/modules/fingerprint/fingerprint.c b/modules/fingerprint/fingerprint.c
index 08b112b..8f4bca6 100644
--- a/modules/fingerprint/fingerprint.c
+++ b/modules/fingerprint/fingerprint.c
@@ -17,10 +17,13 @@
#include <errno.h>
#include <malloc.h>
+#include <stdint.h>
#include <string.h>
-#include <cutils/log.h>
-#include <hardware/hardware.h>
+
+#include <log/log.h>
+
#include <hardware/fingerprint.h>
+#include <hardware/hardware.h>
static int fingerprint_close(hw_device_t *dev)
{
diff --git a/modules/gralloc/framebuffer.cpp b/modules/gralloc/framebuffer.cpp
index eadcdaa..7ef8098 100644
--- a/modules/gralloc/framebuffer.cpp
+++ b/modules/gralloc/framebuffer.cpp
@@ -14,24 +14,20 @@
* limitations under the License.
*/
+#include <dlfcn.h>
+#include <errno.h>
+#include <fcntl.h>
+#include <stdlib.h>
+#include <string.h>
+#include <sys/ioctl.h>
#include <sys/mman.h>
-#include <dlfcn.h>
-
#include <cutils/ashmem.h>
-#include <cutils/log.h>
-
-#include <hardware/hardware.h>
-#include <hardware/gralloc.h>
-
-#include <fcntl.h>
-#include <errno.h>
-#include <sys/ioctl.h>
-#include <string.h>
-#include <stdlib.h>
-
-#include <cutils/log.h>
#include <cutils/atomic.h>
+#include <log/log.h>
+
+#include <hardware/gralloc.h>
+#include <hardware/hardware.h>
#ifdef __ANDROID__
#include <linux/fb.h>
diff --git a/modules/gralloc/gralloc.cpp b/modules/gralloc/gralloc.cpp
index 84133fd..07bbfba 100644
--- a/modules/gralloc/gralloc.cpp
+++ b/modules/gralloc/gralloc.cpp
@@ -14,25 +14,24 @@
* limitations under the License.
*/
-#include <limits.h>
-#include <unistd.h>
-#include <fcntl.h>
#include <errno.h>
+#include <fcntl.h>
+#include <limits.h>
#include <pthread.h>
#include <stdlib.h>
#include <string.h>
-
+#include <sys/ioctl.h>
#include <sys/mman.h>
#include <sys/stat.h>
#include <sys/types.h>
-#include <sys/ioctl.h>
+#include <unistd.h>
#include <cutils/ashmem.h>
-#include <cutils/log.h>
#include <cutils/atomic.h>
+#include <log/log.h>
-#include <hardware/hardware.h>
#include <hardware/gralloc.h>
+#include <hardware/hardware.h>
#include "gralloc_priv.h"
#include "gr.h"
diff --git a/modules/gralloc/mapper.cpp b/modules/gralloc/mapper.cpp
index 20d9841..ee3e40e 100644
--- a/modules/gralloc/mapper.cpp
+++ b/modules/gralloc/mapper.cpp
@@ -14,18 +14,17 @@
* limitations under the License.
*/
-#include <limits.h>
#include <errno.h>
+#include <limits.h>
#include <pthread.h>
-#include <unistd.h>
#include <string.h>
-
#include <sys/mman.h>
#include <sys/stat.h>
#include <sys/types.h>
+#include <unistd.h>
-#include <cutils/log.h>
#include <cutils/atomic.h>
+#include <log/log.h>
#include <hardware/hardware.h>
#include <hardware/gralloc.h>
diff --git a/modules/hwcomposer/hwcomposer.cpp b/modules/hwcomposer/hwcomposer.cpp
index 7b2e278..fd4e90d 100644
--- a/modules/hwcomposer/hwcomposer.cpp
+++ b/modules/hwcomposer/hwcomposer.cpp
@@ -14,15 +14,14 @@
* limitations under the License.
*/
-#include <hardware/hardware.h>
-
#include <errno.h>
#include <fcntl.h>
#include <malloc.h>
-#include <cutils/log.h>
#include <cutils/atomic.h>
+#include <log/log.h>
+#include <hardware/hardware.h>
#include <hardware/hwcomposer.h>
#include <EGL/egl.h>
diff --git a/modules/local_time/local_time_hw.c b/modules/local_time/local_time_hw.c
index 899c38a..b38d8a5 100644
--- a/modules/local_time/local_time_hw.c
+++ b/modules/local_time/local_time_hw.c
@@ -23,7 +23,7 @@
#include <string.h>
#include <sys/time.h>
-#include <cutils/log.h>
+#include <log/log.h>
#include <hardware/hardware.h>
#include <hardware/local_time_hal.h>
diff --git a/modules/nfc-nci/nfc_nci_example.c b/modules/nfc-nci/nfc_nci_example.c
index ea5eb47..f3f60f6 100644
--- a/modules/nfc-nci/nfc_nci_example.c
+++ b/modules/nfc-nci/nfc_nci_example.c
@@ -17,11 +17,11 @@
#include <malloc.h>
#include <string.h>
-#include <cutils/log.h>
+#include <log/log.h>
+
#include <hardware/hardware.h>
#include <hardware/nfc.h>
-
/*
* We want to silence the "unused argument" that gcc and clang give.
* Other compilers generating this warning will need to provide their
diff --git a/modules/radio/Android.bp b/modules/radio/Android.bp
new file mode 100644
index 0000000..01dc035
--- /dev/null
+++ b/modules/radio/Android.bp
@@ -0,0 +1,48 @@
+// 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.
+
+// Stub radio HAL module, used for tests
+cc_library_shared {
+ name: "radio.fm.default",
+ relative_install_path: "hw",
+ vendor: true,
+ srcs: ["radio_hw.c"],
+ cflags: [
+ "-Wall",
+ "-Wno-unused-parameter",
+ "-Werror",
+ ],
+ shared_libs: [
+ "liblog",
+ "libcutils",
+ "libradio_metadata",
+ ],
+}
+
+// Stub radio tool that can be run in native.
+cc_binary {
+ name: "radio_hal_tool",
+ srcs: ["radio_hal_tool.c"],
+ cflags: [
+ "-Wall",
+ "-Wno-unused-parameter",
+ "-Werror",
+ ],
+ shared_libs: [
+ "libcutils",
+ "libhardware",
+ "liblog",
+ "libradio_metadata",
+ ],
+}
diff --git a/modules/radio/Android.mk b/modules/radio/Android.mk
deleted file mode 100644
index 6f11169..0000000
--- a/modules/radio/Android.mk
+++ /dev/null
@@ -1,41 +0,0 @@
-# Copyright (C) 2015 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)
-
-# Stub radio HAL module, used for tests
-include $(CLEAR_VARS)
-
-LOCAL_MULTILIB := $(AUDIOSERVER_MULTILIB)
-
-LOCAL_MODULE := radio.fm.default
-LOCAL_MODULE_RELATIVE_PATH := hw
-LOCAL_PROPRIETARY_MODULE := true
-LOCAL_SRC_FILES := radio_hw.c
-LOCAL_SHARED_LIBRARIES := liblog libcutils libradio_metadata
-LOCAL_MODULE_TAGS := optional
-
-include $(BUILD_SHARED_LIBRARY)
-
-# Stub radio tool that can be run in native.
-include $(CLEAR_VARS)
-
-LOCAL_MULTILIB := $(AUDIOSERVER_MULTILIB)
-
-LOCAL_MODULE := radio_hal_tool
-LOCAL_SRC_FILES := radio_hal_tool.c
-LOCAL_CFLAGS := -Wall -Wno-unused-parameter -Werror
-LOCAL_SHARED_LIBRARIES := libcutils libhardware liblog libradio_metadata
-
-include $(BUILD_EXECUTABLE)
diff --git a/modules/radio/radio_hal_tool.c b/modules/radio/radio_hal_tool.c
index 6c40739..0117f28 100644
--- a/modules/radio/radio_hal_tool.c
+++ b/modules/radio/radio_hal_tool.c
@@ -16,16 +16,18 @@
#define LOG_TAG "radio_hal_tool"
+#include <stdio.h>
#include <stdlib.h>
#include <string.h>
+#include <unistd.h>
-#include <cutils/log.h>
+#include <log/log.h>
+
#include <hardware/hardware.h>
#include <hardware/radio.h>
#include <system/radio.h>
#include <system/radio_metadata.h>
-
// Global state variables.
const struct radio_tuner *hal_tuner = NULL;
diff --git a/modules/radio/radio_hw.c b/modules/radio/radio_hw.c
index 4010507..964a8b6 100644
--- a/modules/radio/radio_hw.c
+++ b/modules/radio/radio_hw.c
@@ -17,22 +17,26 @@
#define LOG_TAG "radio_hw_stub"
#define LOG_NDEBUG 0
-#include <string.h>
-#include <stdlib.h>
#include <errno.h>
+#include <fcntl.h>
#include <pthread.h>
+#include <stdio.h>
+#include <stdlib.h>
+#include <string.h>
#include <sys/prctl.h>
+#include <sys/stat.h>
#include <sys/time.h>
#include <sys/types.h>
-#include <sys/stat.h>
-#include <fcntl.h>
+#include <time.h>
#include <unistd.h>
-#include <cutils/log.h>
+
#include <cutils/list.h>
-#include <system/radio.h>
-#include <system/radio_metadata.h>
+#include <log/log.h>
+
#include <hardware/hardware.h>
#include <hardware/radio.h>
+#include <system/radio.h>
+#include <system/radio_metadata.h>
static const radio_hal_properties_t hw_properties = {
.class_id = RADIO_CLASS_AM_FM,
@@ -633,8 +637,6 @@
static int rdev_get_properties(const struct radio_hw_device *dev,
radio_hal_properties_t *properties)
{
- struct stub_radio_device *rdev = (struct stub_radio_device *)dev;
-
ALOGI("%s", __func__);
if (properties == NULL)
return -EINVAL;
@@ -749,7 +751,6 @@
hw_device_t** device)
{
struct stub_radio_device *rdev;
- int ret;
if (strcmp(name, RADIO_HARDWARE_DEVICE) != 0)
return -EINVAL;
diff --git a/modules/sensors/SensorEventQueue.cpp b/modules/sensors/SensorEventQueue.cpp
index f6144f8..0d4d64a 100644
--- a/modules/sensors/SensorEventQueue.cpp
+++ b/modules/sensors/SensorEventQueue.cpp
@@ -14,11 +14,13 @@
* limitations under the License.
*/
-#include <hardware/sensors.h>
-#include <algorithm>
#include <pthread.h>
-#include <cutils/log.h>
+#include <algorithm>
+
+#include <log/log.h>
+
+#include <hardware/sensors.h>
#include "SensorEventQueue.h"
SensorEventQueue::SensorEventQueue(int capacity) {
diff --git a/modules/sensors/dynamic_sensor/ConnectionDetector.cpp b/modules/sensors/dynamic_sensor/ConnectionDetector.cpp
index 67a6f27..c51e912 100644
--- a/modules/sensors/dynamic_sensor/ConnectionDetector.cpp
+++ b/modules/sensors/dynamic_sensor/ConnectionDetector.cpp
@@ -105,30 +105,35 @@
// FileConnectionDetector functions
FileConnectionDetector::FileConnectionDetector (
BaseDynamicSensorDaemon *d, const std::string &path, const std::string ®ex)
- : ConnectionDetector(d), Thread(false /*callCallJava*/), mPath(path), mRegex(regex) {
+ : ConnectionDetector(d), Thread(false /*callCallJava*/), mPath(path), mRegex(regex),
+ mLooper(new Looper(true /*allowNonCallback*/)), mInotifyFd(-1) {
+ if (mLooper == nullptr) {
+ return;
+ }
+
mInotifyFd = ::inotify_init1(IN_NONBLOCK);
if (mInotifyFd < 0) {
ALOGE("Cannot init inotify");
return;
}
- int wd = ::inotify_add_watch(mInotifyFd, path.c_str(), IN_CREATE | IN_DELETE | IN_MOVED_FROM);
- if (wd < 0) {
+ int wd = ::inotify_add_watch(mInotifyFd, path.c_str(), IN_CREATE | IN_DELETE);
+ if (wd < 0 || !mLooper->addFd(mInotifyFd, POLL_IDENT, Looper::EVENT_INPUT, nullptr, nullptr)) {
::close(mInotifyFd);
mInotifyFd = -1;
ALOGE("Cannot setup watch on dir %s", path.c_str());
return;
}
- mPollFd.fd = wd;
- mPollFd.events = POLLIN;
-
+ // mLooper != null && mInotifyFd added to looper
run("ddad_file");
}
FileConnectionDetector::~FileConnectionDetector() {
- if (mInotifyFd) {
- requestExitAndWait();
+ if (mInotifyFd > 0) {
+ requestExit();
+ mLooper->wake();
+ join();
::close(mInotifyFd);
}
}
@@ -153,63 +158,81 @@
::closedir(dirp);
}
-bool FileConnectionDetector::threadLoop() {
- struct {
- struct inotify_event e;
- uint8_t padding[NAME_MAX + 1];
- } ev;
+void FileConnectionDetector::handleInotifyData(ssize_t len, const char *data) {
+ const char *dataEnd = data + len;
+ const struct inotify_event *ev;
- processExistingFiles();
-
- while (!Thread::exitPending()) {
- int pollNum = ::poll(&mPollFd, 1, -1);
- if (pollNum == -1) {
- if (errno == EINTR)
- continue;
- ALOGE("inotify poll error: %s", ::strerror(errno));
+ // inotify adds paddings to guarantee the next read is aligned
+ for (; data < dataEnd; data += sizeof(struct inotify_event) + ev->len) {
+ ev = reinterpret_cast<const struct inotify_event*>(data);
+ if (ev->mask & IN_ISDIR) {
+ continue;
}
- if (pollNum > 0) {
- if (! (mPollFd.revents & POLLIN)) {
- continue;
+ const std::string name(ev->name);
+ if (matches(name)) {
+ if (ev->mask & IN_CREATE) {
+ mDaemon->onConnectionChange(getFullName(name), true /*connected*/);
}
+ if (ev->mask & IN_DELETE) {
+ mDaemon->onConnectionChange(getFullName(name), false /*connected*/);
+ }
+ }
+ }
+}
- /* Inotify events are available */
- while (true) {
- /* Read some events. */
- ssize_t len = ::read(mInotifyFd, &ev, sizeof ev);
- if (len == -1 && errno != EAGAIN) {
- ALOGE("read error: %s", ::strerror(errno));
- requestExit();
- break;
- }
+bool FileConnectionDetector::readInotifyData() {
+ struct {
+ struct inotify_event ev;
+ char padding[NAME_MAX + 1];
+ } buffer;
- /* If the nonblocking read() found no events to read, then
- it returns -1 with errno set to EAGAIN. In that case,
- we exit the loop. */
- if (len <= 0) {
- break;
- }
+ bool ret = true;
+ while (true) {
+ ssize_t len = ::read(mInotifyFd, &buffer, sizeof(buffer));
+ if (len == -1 && errno == EAGAIN) {
+ // no more data
+ break;
+ } else if (len > static_cast<ssize_t>(sizeof(struct inotify_event))) {
+ handleInotifyData(len, reinterpret_cast<char*>(&buffer));
+ } else if (len < 0) {
+ ALOGE("read error: %s", ::strerror(errno));
+ ret = false;
+ break;
+ } else {
+ // 0 <= len <= sizeof(struct inotify_event)
+ ALOGE("read return %zd, shorter than inotify_event size %zu",
+ len, sizeof(struct inotify_event));
+ ret = false;
+ break;
+ }
+ }
+ return ret;
+}
- if (ev.e.len && !(ev.e.mask & IN_ISDIR)) {
- const std::string name(ev.e.name);
- ALOGV("device %s state changed", name.c_str());
- if (matches(name)) {
- if (ev.e.mask & IN_CREATE) {
- mDaemon->onConnectionChange(getFullName(name), true /* connected*/);
- }
+bool FileConnectionDetector::threadLoop() {
+ Looper::setForThread(mLooper);
+ processExistingFiles();
+ while(!Thread::exitPending()) {
+ int ret = mLooper->pollOnce(-1);
- if (ev.e.mask & IN_DELETE || ev.e.mask & IN_MOVED_FROM) {
- mDaemon->onConnectionChange(getFullName(name), false /* connected*/);
- }
- }
- }
+ if (ret != Looper::POLL_WAKE && ret != POLL_IDENT) {
+ ALOGE("Unexpected value %d from pollOnce, quit", ret);
+ requestExit();
+ break;
+ }
+
+ if (ret == POLL_IDENT) {
+ if (!readInotifyData()) {
+ requestExit();
}
}
}
+ mLooper->removeFd(mInotifyFd);
ALOGD("FileConnectionDetection thread exited");
return false;
}
+
} // namespace SensorHalExt
} // namespace android
diff --git a/modules/sensors/dynamic_sensor/ConnectionDetector.h b/modules/sensors/dynamic_sensor/ConnectionDetector.h
index 712d832..0ee1df2 100644
--- a/modules/sensors/dynamic_sensor/ConnectionDetector.h
+++ b/modules/sensors/dynamic_sensor/ConnectionDetector.h
@@ -19,6 +19,7 @@
#include "BaseDynamicSensorDaemon.h"
#include <utils/Thread.h>
+#include <utils/Looper.h>
#include <regex>
@@ -62,17 +63,20 @@
BaseDynamicSensorDaemon *d, const std::string &path, const std::string ®ex);
virtual ~FileConnectionDetector();
private:
+ static constexpr int POLL_IDENT = 1;
// implement virtual of Thread
virtual bool threadLoop();
bool matches(const std::string &name) const;
void processExistingFiles() const;
+ void handleInotifyData(ssize_t len, const char *data);
+ bool readInotifyData();
std::string getFullName(const std::string name) const;
std::string mPath;
std::regex mRegex;
+ sp<Looper> mLooper;
int mInotifyFd;
- struct pollfd mPollFd;
};
} // namespace SensorHalExt
diff --git a/modules/sensors/dynamic_sensor/HidRawSensorDevice.cpp b/modules/sensors/dynamic_sensor/HidRawSensorDevice.cpp
index 16e9060..8aa4cf9 100644
--- a/modules/sensors/dynamic_sensor/HidRawSensorDevice.cpp
+++ b/modules/sensors/dynamic_sensor/HidRawSensorDevice.cpp
@@ -37,7 +37,7 @@
sp<HidRawSensorDevice> HidRawSensorDevice::create(const std::string &devName) {
sp<HidRawSensorDevice> device(new HidRawSensorDevice(devName));
- // remove +1 strong count added by constructor
+ // offset +1 strong count added by constructor
device->decStrong(device.get());
if (device->mValid) {
@@ -50,13 +50,15 @@
HidRawSensorDevice::HidRawSensorDevice(const std::string &devName)
: RefBase(), HidRawDevice(devName, sInterested),
Thread(false /*canCallJava*/), mValid(false) {
- if (!HidRawDevice::isValid()) {
- return;
- }
// create HidRawSensor objects from digest
// HidRawSensor object will take sp<HidRawSensorDevice> as parameter, so increment strong count
// to prevent "this" being destructed.
this->incStrong(this);
+
+ if (!HidRawDevice::isValid()) {
+ return;
+ }
+
for (const auto &digest : mDigestVector) { // for each usage - vec<ReportPacket> pair
uint32_t usage = static_cast<uint32_t>(digest.fullUsage);
sp<HidRawSensor> s(new HidRawSensor(this, usage, digest.packets));
diff --git a/modules/sensors/multihal.cpp b/modules/sensors/multihal.cpp
index 2810118..887a4ba 100644
--- a/modules/sensors/multihal.cpp
+++ b/modules/sensors/multihal.cpp
@@ -500,15 +500,32 @@
* The vector must not be null.
*/
static void get_so_paths(std::vector<std::string> *so_paths) {
- std::string line;
- std::ifstream conf_file(MULTI_HAL_CONFIG_FILE_PATH);
+ const std::vector<const char *> config_path_list(
+ { MULTI_HAL_CONFIG_FILE_PATH, DEPRECATED_MULTI_HAL_CONFIG_FILE_PATH });
- if(!conf_file) {
- ALOGW("No multihal config file found at %s", MULTI_HAL_CONFIG_FILE_PATH);
+ std::ifstream stream;
+ const char *path = nullptr;
+ for (auto i : config_path_list) {
+ std::ifstream f(i);
+ if (f) {
+ stream = std::move(f);
+ path = i;
+ break;
+ }
+ }
+ if(!stream) {
+ ALOGW("No multihal config file found");
return;
}
- ALOGV("Multihal config file found at %s", MULTI_HAL_CONFIG_FILE_PATH);
- while (std::getline(conf_file, line)) {
+
+ ALOGE_IF(strcmp(path, DEPRECATED_MULTI_HAL_CONFIG_FILE_PATH) == 0,
+ "Multihal configuration file path %s is not compatible with Treble "
+ "requirements. Please move it to %s.",
+ path, MULTI_HAL_CONFIG_FILE_PATH);
+
+ ALOGV("Multihal config file found at %s", path);
+ std::string line;
+ while (std::getline(stream, line)) {
ALOGV("config file line: '%s'", line.c_str());
so_paths->push_back(line);
}
diff --git a/modules/sensors/multihal.h b/modules/sensors/multihal.h
index 210c7cc..234f2f0 100644
--- a/modules/sensors/multihal.h
+++ b/modules/sensors/multihal.h
@@ -19,7 +19,10 @@
#include <hardware/sensors.h>
#include <hardware/hardware.h>
-static const char* MULTI_HAL_CONFIG_FILE_PATH = "/system/etc/sensors/hals.conf";
+static const char* MULTI_HAL_CONFIG_FILE_PATH = "/vendor/etc/sensors/hals.conf";
+
+// Depracated because system partition HAL config file does not satisfy treble requirements.
+static const char* DEPRECATED_MULTI_HAL_CONFIG_FILE_PATH = "/system/etc/sensors/hals.conf";
struct sensors_module_t *get_multi_hal_module_info(void);
diff --git a/modules/soundtrigger/sound_trigger_hw.c b/modules/soundtrigger/sound_trigger_hw.c
index 20d97f2..0089f98 100644
--- a/modules/soundtrigger/sound_trigger_hw.c
+++ b/modules/soundtrigger/sound_trigger_hw.c
@@ -51,21 +51,20 @@
#define ERROR_BAD_COMMAND "Bad command"
+#include <arpa/inet.h>
#include <errno.h>
+#include <pthread.h>
+#include <netinet/in.h>
#include <stdarg.h>
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
-#include <unistd.h>
-#include <arpa/inet.h>
-#include <sys/types.h>
-#include <netinet/in.h>
-#include <sys/socket.h>
-
-#include <errno.h>
-#include <pthread.h>
#include <sys/prctl.h>
-#include <cutils/log.h>
+#include <sys/types.h>
+#include <sys/socket.h>
+#include <unistd.h>
+
+#include <log/log.h>
#include <hardware/hardware.h>
#include <system/sound_trigger.h>
diff --git a/modules/tv_input/tv_input.cpp b/modules/tv_input/tv_input.cpp
index ddace28..4c42518 100644
--- a/modules/tv_input/tv_input.cpp
+++ b/modules/tv_input/tv_input.cpp
@@ -18,8 +18,8 @@
#include <fcntl.h>
#include <malloc.h>
-#include <cutils/log.h>
#include <cutils/native_handle.h>
+#include <log/log.h>
#include <hardware/tv_input.h>
diff --git a/modules/usbaudio/audio_hal.c b/modules/usbaudio/audio_hal.c
index 6a3c5da..df4bc0f 100644
--- a/modules/usbaudio/audio_hal.c
+++ b/modules/usbaudio/audio_hal.c
@@ -933,7 +933,7 @@
struct audio_config *config,
struct audio_stream_in **stream_in,
audio_input_flags_t flags __unused,
- const char *address /*__unused*/,
+ const char *address,
audio_source_t source __unused)
{
ALOGV("adev_open_input_stream() rate:%" PRIu32 ", chanMask:0x%" PRIX32 ", fmt:%" PRIu8,
@@ -989,7 +989,7 @@
ret = config->sample_rate != in->adev->device_sample_rate ? -EINVAL : 0;
proxy_config.rate = config->sample_rate = in->adev->device_sample_rate;
} else if (profile_is_sample_rate_valid(in->profile, config->sample_rate)) {
- in->adev->device_sample_rate = proxy_config.rate = config->sample_rate;
+ proxy_config.rate = config->sample_rate;
} else {
proxy_config.rate = config->sample_rate = profile_get_default_sample_rate(in->profile);
ret = -EINVAL;
@@ -1053,18 +1053,29 @@
// and store THAT in proxy_config.channels
proxy_config.channels =
profile_get_closest_channel_count(in->profile, in->hal_channel_count);
- proxy_prepare(&in->proxy, in->profile, &proxy_config);
+ ret = proxy_prepare(&in->proxy, in->profile, &proxy_config);
+ if (ret == 0) {
+ in->standby = true;
- in->standby = true;
+ in->conversion_buffer = NULL;
+ in->conversion_buffer_size = 0;
- in->conversion_buffer = NULL;
- in->conversion_buffer_size = 0;
+ *stream_in = &in->stream;
- *stream_in = &in->stream;
+ /* Save this for adev_dump() */
+ adev_add_stream_to_list(in->adev, &in->adev->input_stream_list, &in->list_node);
+ } else {
+ ALOGW("proxy_prepare error %d", ret);
+ unsigned channel_count = proxy_get_channel_count(&in->proxy);
+ config->channel_mask = channel_count <= FCC_2
+ ? audio_channel_in_mask_from_count(channel_count)
+ : audio_channel_mask_for_index_assignment_from_count(channel_count);
+ config->format = audio_format_from_pcm_format(proxy_get_format(&in->proxy));
+ config->sample_rate = proxy_get_sample_rate(&in->proxy);
+ }
+ }
- /* Save this for adev_dump() */
- adev_add_stream_to_list(in->adev, &in->adev->input_stream_list, &in->list_node);
- } else {
+ if (ret != 0) {
// Deallocate this stream on error, because AudioFlinger won't call
// adev_close_input_stream() in this case.
*stream_in = NULL;
diff --git a/modules/usbcamera/Camera.cpp b/modules/usbcamera/Camera.cpp
index b396291..0324da8 100644
--- a/modules/usbcamera/Camera.cpp
+++ b/modules/usbcamera/Camera.cpp
@@ -16,21 +16,28 @@
//#define LOG_NDEBUG 0
#define LOG_TAG "Camera"
-#include <cutils/log.h>
+
+#include <errno.h>
+#include <stdio.h>
+#include <string.h>
+#include <time.h>
#include <cstdlib>
-#include <stdio.h>
-#include <hardware/camera3.h>
-#include <system/camera_metadata.h>
-#include <system/graphics.h>
+
+#include <log/log.h>
#include <utils/Mutex.h>
-#include "CameraHAL.h"
-#include "Metadata.h"
-#include "Stream.h"
#define ATRACE_TAG (ATRACE_TAG_CAMERA | ATRACE_TAG_HAL)
#include <utils/Trace.h>
+#include <hardware/camera3.h>
+#include <system/camera_metadata.h>
+#include <system/graphics.h>
+
+#include "CameraHAL.h"
+#include "Metadata.h"
+#include "Stream.h"
+
#include "Camera.h"
namespace usb_camera_hal {
diff --git a/modules/usbcamera/CameraHAL.cpp b/modules/usbcamera/CameraHAL.cpp
index c54283b..1a5eb3a 100644
--- a/modules/usbcamera/CameraHAL.cpp
+++ b/modules/usbcamera/CameraHAL.cpp
@@ -16,13 +16,17 @@
//#define LOG_NDEBUG 0
#define LOG_TAG "UsbCameraHAL"
-#include <cutils/log.h>
#include <cstdlib>
+
+#include <log/log.h>
+#include <utils/Mutex.h>
+
#include <hardware/camera_common.h>
#include <hardware/hardware.h>
-#include "UsbCamera.h"
+
#include "CameraHAL.h"
+#include "UsbCamera.h"
/*
* This file serves as the entry point to the HAL. It contains the module
diff --git a/modules/usbcamera/HotplugThread.cpp b/modules/usbcamera/HotplugThread.cpp
index 02e7167..6188ede 100644
--- a/modules/usbcamera/HotplugThread.cpp
+++ b/modules/usbcamera/HotplugThread.cpp
@@ -16,7 +16,8 @@
//#define LOG_NDEBUG 0
#define LOG_TAG "HotplugThread"
-#include <cutils/log.h>
+
+#include <log/log.h>
#include "HotplugThread.h"
diff --git a/modules/usbcamera/Metadata.cpp b/modules/usbcamera/Metadata.cpp
index f243834..78318f3 100644
--- a/modules/usbcamera/Metadata.cpp
+++ b/modules/usbcamera/Metadata.cpp
@@ -16,13 +16,14 @@
//#define LOG_NDEBUG 0
#define LOG_TAG "Metadata"
-#include <cutils/log.h>
-#include <system/camera_metadata.h>
+#include <log/log.h>
#define ATRACE_TAG (ATRACE_TAG_CAMERA | ATRACE_TAG_HAL)
#include <utils/Trace.h>
+#include <system/camera_metadata.h>
+
#include "Metadata.h"
namespace usb_camera_hal {
diff --git a/modules/usbcamera/Stream.cpp b/modules/usbcamera/Stream.cpp
index 2b83421..d418798 100644
--- a/modules/usbcamera/Stream.cpp
+++ b/modules/usbcamera/Stream.cpp
@@ -16,17 +16,19 @@
//#define LOG_NDEBUG 0
#define LOG_TAG "Stream"
-#include <cutils/log.h>
#include <stdio.h>
-#include <hardware/camera3.h>
-#include <hardware/gralloc.h>
-#include <system/graphics.h>
+
+#include <log/log.h>
#include <utils/Mutex.h>
#define ATRACE_TAG (ATRACE_TAG_CAMERA | ATRACE_TAG_HAL)
#include <utils/Trace.h>
+#include <hardware/camera3.h>
+#include <hardware/gralloc.h>
+#include <system/graphics.h>
+
#include "Stream.h"
namespace usb_camera_hal {
diff --git a/modules/usbcamera/UsbCamera.cpp b/modules/usbcamera/UsbCamera.cpp
index 9d53fc6..65cbec9 100644
--- a/modules/usbcamera/UsbCamera.cpp
+++ b/modules/usbcamera/UsbCamera.cpp
@@ -16,13 +16,16 @@
//#define LOG_NDEBUG 0
#define LOG_TAG "UsbCameraDevice"
-#include <cutils/log.h>
-#include <system/camera_metadata.h>
+#include <stdint.h>
+
+#include <log/log.h>
#define ATRACE_TAG (ATRACE_TAG_CAMERA | ATRACE_TAG_HAL)
#include <utils/Trace.h>
+#include <system/camera_metadata.h>
+
#include "Camera.h"
#include "UsbCamera.h"
diff --git a/modules/vehicle/vehicle.c b/modules/vehicle/vehicle.c
index 2d945fd..66e29c0 100644
--- a/modules/vehicle/vehicle.c
+++ b/modules/vehicle/vehicle.c
@@ -31,7 +31,7 @@
#include <sys/time.h>
#include <time.h>
-#include <cutils/log.h>
+#include <log/log.h>
#include <system/radio.h>
#include <hardware/hardware.h>
#include <hardware/vehicle.h>
diff --git a/modules/vibrator/vibrator.c b/modules/vibrator/vibrator.c
index 92c46e2..950bc59 100644
--- a/modules/vibrator/vibrator.c
+++ b/modules/vibrator/vibrator.c
@@ -14,19 +14,19 @@
* limitations under the License.
*/
-#include <hardware/vibrator.h>
#include <hardware/hardware.h>
+#include <hardware/vibrator.h>
-#include <cutils/log.h>
-
+#include <errno.h>
+#include <fcntl.h>
#include <malloc.h>
-#include <stdio.h>
+#include <math.h>
#include <stdbool.h>
+#include <stdio.h>
#include <string.h>
#include <unistd.h>
-#include <fcntl.h>
-#include <errno.h>
-#include <math.h>
+
+#include <log/log.h>
#define TIMEOUT_STR_LEN 20
diff --git a/tests/nusensors/nusensors.cpp b/tests/nusensors/nusensors.cpp
index 55b7785..a063959 100644
--- a/tests/nusensors/nusensors.cpp
+++ b/tests/nusensors/nusensors.cpp
@@ -17,14 +17,15 @@
#include <inttypes.h>
#include <string.h>
#include <stdint.h>
+#include <stdio.h>
#include <string.h>
#include <sys/cdefs.h>
#include <sys/types.h>
-#include <cutils/log.h>
+#include <log/log.h>
+#include <utils/Timers.h>
#include <hardware/sensors.h>
-#include <utils/Timers.h>
char const* getSensorName(int type) {
switch(type) {
diff --git a/tests/vehicle/vehicle-hal-tool.c b/tests/vehicle/vehicle-hal-tool.c
index e85df62..94624d3 100644
--- a/tests/vehicle/vehicle-hal-tool.c
+++ b/tests/vehicle/vehicle-hal-tool.c
@@ -17,13 +17,15 @@
#define LOG_TAG "vehicle-hal-tool"
#include <inttypes.h>
+#include <stdio.h>
#include <stdlib.h>
#include <string.h>
+
+#include <log/log.h>
+
#include <hardware/hardware.h>
#include <hardware/vehicle.h>
-#include <cutils/log.h>
-
void usage() {
printf("Usage: "
"./vehicle-hal-tool [-l] [-m -p -t [-v]]\n"