diff options
author | 2017-03-06 15:05:04 -0800 | |
---|---|---|
committer | 2017-03-07 11:21:29 -0800 | |
commit | 801ea093b0e923a61b832f2adba698a273479880 (patch) | |
tree | 97edcd253848107bdf1d8d0fabb522426943369a | |
parent | 9257845ae16aa6aceedec627cec2e1fce912947c (diff) |
split libsensor our of libgui
Test: compile & run
Bug: treble cleanup
Change-Id: I5b2c2a14f7d3b364d25695cf0901c5b08cfb0fc9
42 files changed, 439 insertions, 109 deletions
diff --git a/include/gui/BitTube.h b/include/private/gui/BitTube.h index 9d65fad228..9d65fad228 100644 --- a/include/gui/BitTube.h +++ b/include/private/gui/BitTube.h diff --git a/libs/gui/Android.bp b/libs/gui/Android.bp index 8f9c38a652..a1b4abc1dc 100644 --- a/libs/gui/Android.bp +++ b/libs/gui/Android.bp @@ -38,10 +38,6 @@ cc_library_shared { // Don't warn about struct padding "-Wno-padded", - // android/sensors.h uses nested anonymous unions and anonymous structs - "-Wno-nested-anon-types", - "-Wno-gnu-anonymous-struct", - // We are aware of the risks inherent in comparing floats for equality "-Wno-float-equal", @@ -61,8 +57,6 @@ cc_library_shared { }, srcs: [ - "IGraphicBufferConsumer.cpp", - "IConsumerListener.cpp", "BitTube.cpp", "BufferItem.cpp", "BufferItemConsumer.cpp", @@ -79,18 +73,15 @@ cc_library_shared { "GraphicBufferAlloc.cpp", "GuiConfig.cpp", "IDisplayEventConnection.cpp", + "IConsumerListener.cpp", "IGraphicBufferAlloc.cpp", + "IGraphicBufferConsumer.cpp", "IGraphicBufferProducer.cpp", "IProducerListener.cpp", - "ISensorEventConnection.cpp", - "ISensorServer.cpp", "ISurfaceComposer.cpp", "ISurfaceComposerClient.cpp", "LayerState.cpp", "OccupancyTracker.cpp", - "Sensor.cpp", - "SensorEventQueue.cpp", - "SensorManager.cpp", "StreamSplitter.cpp", "Surface.cpp", "SurfaceControl.cpp", diff --git a/libs/gui/BitTube.cpp b/libs/gui/BitTube.cpp index b653c5b69c..51a8d67118 100644 --- a/libs/gui/BitTube.cpp +++ b/libs/gui/BitTube.cpp @@ -14,6 +14,8 @@ * limitations under the License. */ +#include <private/gui/BitTube.h> + #include <stdint.h> #include <sys/types.h> #include <sys/socket.h> @@ -25,7 +27,6 @@ #include <binder/Parcel.h> -#include <gui/BitTube.h> namespace android { // ---------------------------------------------------------------------------- diff --git a/libs/gui/DisplayEventReceiver.cpp b/libs/gui/DisplayEventReceiver.cpp index 9973e8daef..07e07e058b 100644 --- a/libs/gui/DisplayEventReceiver.cpp +++ b/libs/gui/DisplayEventReceiver.cpp @@ -18,13 +18,14 @@ #include <utils/Errors.h> -#include <gui/BitTube.h> #include <gui/DisplayEventReceiver.h> #include <gui/IDisplayEventConnection.h> #include <gui/ISurfaceComposer.h> #include <private/gui/ComposerService.h> +#include <private/gui/BitTube.h> + // --------------------------------------------------------------------------- namespace android { diff --git a/libs/gui/IDisplayEventConnection.cpp b/libs/gui/IDisplayEventConnection.cpp index b1d3b00dbb..e5c3c48248 100644 --- a/libs/gui/IDisplayEventConnection.cpp +++ b/libs/gui/IDisplayEventConnection.cpp @@ -15,17 +15,15 @@ */ #include <stdint.h> -#include <sys/types.h> #include <utils/Errors.h> #include <utils/RefBase.h> -#include <utils/Timers.h> #include <binder/Parcel.h> -#include <binder/IInterface.h> #include <gui/IDisplayEventConnection.h> -#include <gui/BitTube.h> + +#include <private/gui/BitTube.h> namespace android { // ---------------------------------------------------------------------------- diff --git a/libs/gui/tests/Android.bp b/libs/gui/tests/Android.bp index 5944110815..4492a081e7 100644 --- a/libs/gui/tests/Android.bp +++ b/libs/gui/tests/Android.bp @@ -14,7 +14,6 @@ cc_test { "GLTest.cpp", "IGraphicBufferProducer_test.cpp", "MultiTextureConsumer_test.cpp", - "Sensor_test.cpp", "StreamSplitter_test.cpp", "SurfaceTextureClient_test.cpp", "SurfaceTextureFBO_test.cpp", diff --git a/libs/sensor/Android.bp b/libs/sensor/Android.bp new file mode 100644 index 0000000000..171a627c7e --- /dev/null +++ b/libs/sensor/Android.bp @@ -0,0 +1,61 @@ +// Copyright 2010 The Android Open Source Project +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. + +cc_library_shared { + name: "libsensor", + + clang: true, + cppflags: [ + "-Weverything", + "-Werror", + + // The static constructors and destructors in this library have not been noted to + // introduce significant overheads + "-Wno-exit-time-destructors", + "-Wno-global-constructors", + + // We only care about compiling as C++14 + "-Wno-c++98-compat-pedantic", + + // android/sensors.h uses nested anonymous unions and anonymous structs + "-Wno-nested-anon-types", + "-Wno-gnu-anonymous-struct", + + // Don't warn about struct padding + "-Wno-padded", + ], + + srcs: [ + "BitTube.cpp", + "ISensorEventConnection.cpp", + "ISensorServer.cpp", + "Sensor.cpp", + "SensorEventQueue.cpp", + "SensorManager.cpp", + ], + + shared_libs: [ + "libbinder", + "libcutils", + "libutils", + "liblog", + "libhardware", + ], + + export_include_dirs: ["include"], + + export_shared_lib_headers: ["libbinder", "libhardware"], +} + +subdirs = ["tests"] diff --git a/libs/sensor/BitTube.cpp b/libs/sensor/BitTube.cpp new file mode 100644 index 0000000000..93555c8a3a --- /dev/null +++ b/libs/sensor/BitTube.cpp @@ -0,0 +1,174 @@ +/* + * Copyright (C) 2010 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 <sensor/BitTube.h> + +#include <stdint.h> +#include <sys/types.h> +#include <sys/socket.h> + +#include <fcntl.h> +#include <unistd.h> + +#include <binder/Parcel.h> + +namespace android { +// ---------------------------------------------------------------------------- + +// Socket buffer size. The default is typically about 128KB, which is much larger than +// we really need. So we make it smaller. +static const size_t DEFAULT_SOCKET_BUFFER_SIZE = 4 * 1024; + + +BitTube::BitTube() + : mSendFd(-1), mReceiveFd(-1) +{ + init(DEFAULT_SOCKET_BUFFER_SIZE, DEFAULT_SOCKET_BUFFER_SIZE); +} + +BitTube::BitTube(size_t bufsize) + : mSendFd(-1), mReceiveFd(-1) +{ + init(bufsize, bufsize); +} + +BitTube::BitTube(const Parcel& data) + : mSendFd(-1), mReceiveFd(-1) +{ + mReceiveFd = dup(data.readFileDescriptor()); + if (mReceiveFd < 0) { + mReceiveFd = -errno; + ALOGE("BitTube(Parcel): can't dup filedescriptor (%s)", + strerror(-mReceiveFd)); + } +} + +BitTube::~BitTube() +{ + if (mSendFd >= 0) + close(mSendFd); + + if (mReceiveFd >= 0) + close(mReceiveFd); +} + +void BitTube::init(size_t rcvbuf, size_t sndbuf) { + int sockets[2]; + if (socketpair(AF_UNIX, SOCK_SEQPACKET, 0, sockets) == 0) { + size_t size = DEFAULT_SOCKET_BUFFER_SIZE; + setsockopt(sockets[0], SOL_SOCKET, SO_RCVBUF, &rcvbuf, sizeof(rcvbuf)); + setsockopt(sockets[1], SOL_SOCKET, SO_SNDBUF, &sndbuf, sizeof(sndbuf)); + // sine we don't use the "return channel", we keep it small... + setsockopt(sockets[0], SOL_SOCKET, SO_SNDBUF, &size, sizeof(size)); + setsockopt(sockets[1], SOL_SOCKET, SO_RCVBUF, &size, sizeof(size)); + fcntl(sockets[0], F_SETFL, O_NONBLOCK); + fcntl(sockets[1], F_SETFL, O_NONBLOCK); + mReceiveFd = sockets[0]; + mSendFd = sockets[1]; + } else { + mReceiveFd = -errno; + ALOGE("BitTube: pipe creation failed (%s)", strerror(-mReceiveFd)); + } +} + +status_t BitTube::initCheck() const +{ + if (mReceiveFd < 0) { + return status_t(mReceiveFd); + } + return NO_ERROR; +} + +int BitTube::getFd() const +{ + return mReceiveFd; +} + +int BitTube::getSendFd() const +{ + return mSendFd; +} + +ssize_t BitTube::write(void const* vaddr, size_t size) +{ + ssize_t err, len; + do { + len = ::send(mSendFd, vaddr, size, MSG_DONTWAIT | MSG_NOSIGNAL); + // cannot return less than size, since we're using SOCK_SEQPACKET + err = len < 0 ? errno : 0; + } while (err == EINTR); + return err == 0 ? len : -err; +} + +ssize_t BitTube::read(void* vaddr, size_t size) +{ + ssize_t err, len; + do { + len = ::recv(mReceiveFd, vaddr, size, MSG_DONTWAIT); + err = len < 0 ? errno : 0; + } while (err == EINTR); + if (err == EAGAIN || err == EWOULDBLOCK) { + // EAGAIN means that we have non-blocking I/O but there was + // no data to be read. Nothing the client should care about. + return 0; + } + return err == 0 ? len : -err; +} + +status_t BitTube::writeToParcel(Parcel* reply) const +{ + if (mReceiveFd < 0) + return -EINVAL; + + status_t result = reply->writeDupFileDescriptor(mReceiveFd); + close(mReceiveFd); + mReceiveFd = -1; + return result; +} + + +ssize_t BitTube::sendObjects(const sp<BitTube>& tube, + void const* events, size_t count, size_t objSize) +{ + const char* vaddr = reinterpret_cast<const char*>(events); + ssize_t size = tube->write(vaddr, count*objSize); + + // should never happen because of SOCK_SEQPACKET + LOG_ALWAYS_FATAL_IF((size >= 0) && (size % static_cast<ssize_t>(objSize)), + "BitTube::sendObjects(count=%zu, size=%zu), res=%zd (partial events were sent!)", + count, objSize, size); + + //ALOGE_IF(size<0, "error %d sending %d events", size, count); + return size < 0 ? size : size / static_cast<ssize_t>(objSize); +} + +ssize_t BitTube::recvObjects(const sp<BitTube>& tube, + void* events, size_t count, size_t objSize) +{ + char* vaddr = reinterpret_cast<char*>(events); + ssize_t size = tube->read(vaddr, count*objSize); + + // should never happen because of SOCK_SEQPACKET + LOG_ALWAYS_FATAL_IF((size >= 0) && (size % static_cast<ssize_t>(objSize)), + "BitTube::recvObjects(count=%zu, size=%zu), res=%zd (partial events were received!)", + count, objSize, size); + + //ALOGE_IF(size<0, "error %d receiving %d events", size, count); + return size < 0 ? size : size / static_cast<ssize_t>(objSize); +} + +// ---------------------------------------------------------------------------- +}; // namespace android diff --git a/libs/gui/ISensorEventConnection.cpp b/libs/sensor/ISensorEventConnection.cpp index 8af51c534b..8a3a623983 100644 --- a/libs/gui/ISensorEventConnection.cpp +++ b/libs/sensor/ISensorEventConnection.cpp @@ -14,6 +14,8 @@ * limitations under the License. */ +#include <sensor/ISensorEventConnection.h> + #include <stdint.h> #include <sys/types.h> @@ -24,8 +26,7 @@ #include <binder/Parcel.h> #include <binder/IInterface.h> -#include <gui/ISensorEventConnection.h> -#include <gui/BitTube.h> +#include <sensor/BitTube.h> namespace android { // ---------------------------------------------------------------------------- diff --git a/libs/gui/ISensorServer.cpp b/libs/sensor/ISensorServer.cpp index aea7403636..f41f187136 100644 --- a/libs/gui/ISensorServer.cpp +++ b/libs/sensor/ISensorServer.cpp @@ -14,6 +14,8 @@ * limitations under the License. */ +#include <sensor/ISensorServer.h> + #include <stdint.h> #include <sys/types.h> @@ -26,9 +28,8 @@ #include <binder/Parcel.h> #include <binder/IInterface.h> -#include <gui/Sensor.h> -#include <gui/ISensorServer.h> -#include <gui/ISensorEventConnection.h> +#include <sensor/Sensor.h> +#include <sensor/ISensorEventConnection.h> namespace android { // ---------------------------------------------------------------------------- diff --git a/libs/gui/Sensor.cpp b/libs/sensor/Sensor.cpp index e2f733a41a..c2d477e4b5 100644 --- a/libs/gui/Sensor.cpp +++ b/libs/sensor/Sensor.cpp @@ -14,19 +14,13 @@ * limitations under the License. */ +#include <sensor/Sensor.h> + #include <inttypes.h> -#include <stdint.h> -#include <sys/limits.h> -#include <sys/types.h> #include <binder/AppOpsManager.h> +#include <binder/IPermissionController.h> #include <binder/IServiceManager.h> -#include <gui/Sensor.h> -#include <hardware/sensors.h> -#include <log/log.h> -#include <utils/Errors.h> -#include <utils/String8.h> -#include <utils/Flattenable.h> // ---------------------------------------------------------------------------- namespace android { @@ -51,7 +45,7 @@ Sensor::Sensor(struct sensor_t const& hwSensor, const uuid_t& uuid, int halVersi mHandle = hwSensor.handle; mType = hwSensor.type; mMinValue = 0; // FIXME: minValue - mMaxValue = hwSensor.maxRange; // FIXME: maxValue + mMaxValue = hwSensor.maxRange; // FIXME: maxValue mResolution = hwSensor.resolution; mPower = hwSensor.power; mMinDelay = hwSensor.minDelay; diff --git a/libs/gui/SensorEventQueue.cpp b/libs/sensor/SensorEventQueue.cpp index 6d698390c1..8ba3ebe17d 100644 --- a/libs/gui/SensorEventQueue.cpp +++ b/libs/sensor/SensorEventQueue.cpp @@ -16,20 +16,17 @@ #define LOG_TAG "Sensors" +#include <sensor/SensorEventQueue.h> + #include <algorithm> -#include <stdint.h> -#include <sys/types.h> #include <sys/socket.h> -#include <linux/errno.h> -#include <utils/Errors.h> #include <utils/RefBase.h> #include <utils/Looper.h> -#include <gui/Sensor.h> -#include <gui/BitTube.h> -#include <gui/SensorEventQueue.h> -#include <gui/ISensorEventConnection.h> +#include <sensor/Sensor.h> +#include <sensor/BitTube.h> +#include <sensor/ISensorEventConnection.h> #include <android/sensor.h> diff --git a/libs/gui/SensorManager.cpp b/libs/sensor/SensorManager.cpp index 513b889b18..b6e9fa1c72 100644 --- a/libs/gui/SensorManager.cpp +++ b/libs/sensor/SensorManager.cpp @@ -16,6 +16,8 @@ #define LOG_TAG "Sensors" +#include <sensor/SensorManager.h> + #include <stdint.h> #include <sys/types.h> @@ -27,11 +29,10 @@ #include <binder/IBinder.h> #include <binder/IServiceManager.h> -#include <gui/ISensorServer.h> -#include <gui/ISensorEventConnection.h> -#include <gui/Sensor.h> -#include <gui/SensorManager.h> -#include <gui/SensorEventQueue.h> +#include <sensor/ISensorServer.h> +#include <sensor/ISensorEventConnection.h> +#include <sensor/Sensor.h> +#include <sensor/SensorEventQueue.h> // ---------------------------------------------------------------------------- namespace android { diff --git a/libs/sensor/include/sensor/BitTube.h b/libs/sensor/include/sensor/BitTube.h new file mode 100644 index 0000000000..c1fabe83ed --- /dev/null +++ b/libs/sensor/include/sensor/BitTube.h @@ -0,0 +1,90 @@ +/* + * Copyright (C) 2010 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. + */ + +#pragma once + +#include <stdint.h> +#include <sys/types.h> + +#include <utils/Errors.h> +#include <utils/RefBase.h> + +namespace android { +// ---------------------------------------------------------------------------- +class Parcel; + +class BitTube : public RefBase +{ +public: + + // creates a BitTube with a default (4KB) send buffer + BitTube(); + + // creates a BitTube with a a specified send and receive buffer size + explicit BitTube(size_t bufsize); + + explicit BitTube(const Parcel& data); + virtual ~BitTube(); + + // check state after construction + status_t initCheck() const; + + // get receive file-descriptor + int getFd() const; + + // get the send file-descriptor. + int getSendFd() const; + + // send objects (sized blobs). All objects are guaranteed to be written or the call fails. + template <typename T> + static ssize_t sendObjects(const sp<BitTube>& tube, + T const* events, size_t count) { + return sendObjects(tube, events, count, sizeof(T)); + } + + // receive objects (sized blobs). If the receiving buffer isn't large enough, + // excess messages are silently discarded. + template <typename T> + static ssize_t recvObjects(const sp<BitTube>& tube, + T* events, size_t count) { + return recvObjects(tube, events, count, sizeof(T)); + } + + // parcels this BitTube + status_t writeToParcel(Parcel* reply) const; + +private: + void init(size_t rcvbuf, size_t sndbuf); + + // send a message. The write is guaranteed to send the whole message or fail. + ssize_t write(void const* vaddr, size_t size); + + // receive a message. the passed buffer must be at least as large as the + // write call used to send the message, excess data is silently discarded. + ssize_t read(void* vaddr, size_t size); + + int mSendFd; + mutable int mReceiveFd; + + static ssize_t sendObjects(const sp<BitTube>& tube, + void const* events, size_t count, size_t objSize); + + static ssize_t recvObjects(const sp<BitTube>& tube, + void* events, size_t count, size_t objSize); +}; + +// ---------------------------------------------------------------------------- +}; // namespace android diff --git a/include/gui/ISensorEventConnection.h b/libs/sensor/include/sensor/ISensorEventConnection.h index 2ccd832c52..07cc7e84ad 100644 --- a/include/gui/ISensorEventConnection.h +++ b/libs/sensor/include/sensor/ISensorEventConnection.h @@ -14,14 +14,14 @@ * limitations under the License. */ -#ifndef ANDROID_GUI_ISENSOR_EVENT_CONNECTION_H -#define ANDROID_GUI_ISENSOR_EVENT_CONNECTION_H +#pragma once #include <stdint.h> #include <sys/types.h> #include <utils/Errors.h> -#include <utils/RefBase.h> +#include <utils/StrongPointer.h> +#include <utils/Timers.h> #include <binder/IInterface.h> @@ -29,6 +29,7 @@ namespace android { // ---------------------------------------------------------------------------- class BitTube; +class Parcel; class ISensorEventConnection : public IInterface { @@ -56,5 +57,3 @@ public: // ---------------------------------------------------------------------------- }; // namespace android - -#endif // ANDROID_GUI_ISENSOR_EVENT_CONNECTION_H diff --git a/include/gui/ISensorServer.h b/libs/sensor/include/sensor/ISensorServer.h index 0c36c9920f..f922307e33 100644 --- a/include/gui/ISensorServer.h +++ b/libs/sensor/include/sensor/ISensorServer.h @@ -14,14 +14,14 @@ * limitations under the License. */ -#ifndef ANDROID_GUI_ISENSORSERVER_H -#define ANDROID_GUI_ISENSORSERVER_H +#pragma once #include <stdint.h> #include <sys/types.h> #include <utils/Errors.h> -#include <utils/RefBase.h> +#include <utils/StrongPointer.h> +#include <utils/Vector.h> #include <binder/IInterface.h> @@ -30,9 +30,11 @@ typedef struct native_handle native_handle_t; namespace android { // ---------------------------------------------------------------------------- -class Sensor; class ISensorEventConnection; +class Parcel; +class Sensor; class String8; +class String16; class ISensorServer : public IInterface { @@ -63,5 +65,3 @@ public: // ---------------------------------------------------------------------------- }; // namespace android - -#endif // ANDROID_GUI_ISENSORSERVER_H diff --git a/include/gui/Sensor.h b/libs/sensor/include/sensor/Sensor.h index d886b2bc85..043e6352a7 100644 --- a/include/gui/Sensor.h +++ b/libs/sensor/include/sensor/Sensor.h @@ -14,8 +14,7 @@ * limitations under the License. */ -#ifndef ANDROID_GUI_SENSOR_H -#define ANDROID_GUI_SENSOR_H +#pragma once #include <stdint.h> #include <sys/types.h> @@ -25,10 +24,11 @@ #include <utils/String8.h> #include <utils/Timers.h> -#include <hardware/sensors.h> - +// FIXME: including from android/ breaks layering, as libandroid ultimately depends on libsensors #include <android/sensor.h> +#include <hardware/sensors.h> + // ---------------------------------------------------------------------------- // Concrete types for the NDK struct ASensor { }; @@ -138,5 +138,3 @@ private: // ---------------------------------------------------------------------------- }; // namespace android - -#endif // ANDROID_GUI_SENSOR_H diff --git a/include/gui/SensorEventQueue.h b/libs/sensor/include/sensor/SensorEventQueue.h index 4ee7c0284a..84b6ab25de 100644 --- a/include/gui/SensorEventQueue.h +++ b/libs/sensor/include/sensor/SensorEventQueue.h @@ -14,8 +14,7 @@ * limitations under the License. */ -#ifndef ANDROID_SENSOR_EVENT_QUEUE_H -#define ANDROID_SENSOR_EVENT_QUEUE_H +#pragma once #include <stdint.h> #include <sys/types.h> @@ -23,9 +22,9 @@ #include <utils/Errors.h> #include <utils/RefBase.h> #include <utils/Timers.h> -#include <utils/String16.h> +#include <utils/Mutex.h> -#include <gui/BitTube.h> +#include <sensor/BitTube.h> // ---------------------------------------------------------------------------- #define WAKE_UP_SENSOR_EVENT_NEEDS_ACK (1U << 31) @@ -107,5 +106,3 @@ private: // ---------------------------------------------------------------------------- }; // namespace android - -#endif // ANDROID_SENSOR_EVENT_QUEUE_H diff --git a/include/gui/SensorManager.h b/libs/sensor/include/sensor/SensorManager.h index 5b34ff4b8c..a3d9741e85 100644 --- a/include/gui/SensorManager.h +++ b/libs/sensor/include/sensor/SensorManager.h @@ -18,6 +18,7 @@ #define ANDROID_GUI_SENSOR_MANAGER_H #include <map> +#include <unordered_map> #include <stdint.h> #include <sys/types.h> @@ -27,14 +28,11 @@ #include <binder/IServiceManager.h> #include <utils/Errors.h> -#include <utils/RefBase.h> -#include <utils/Singleton.h> +#include <utils/StrongPointer.h> #include <utils/Vector.h> #include <utils/String8.h> -#include <gui/SensorEventQueue.h> - -#include <unordered_map> +#include <sensor/SensorEventQueue.h> // ---------------------------------------------------------------------------- // Concrete types for the NDK @@ -52,8 +50,7 @@ class Sensor; class SensorEventQueue; // ---------------------------------------------------------------------------- -class SensorManager : - public ASensorManager +class SensorManager : public ASensorManager { public: static SensorManager& getInstanceForPackage(const String16& packageName); diff --git a/libs/sensor/tests/Android.bp b/libs/sensor/tests/Android.bp new file mode 100644 index 0000000000..9d530fc5fa --- /dev/null +++ b/libs/sensor/tests/Android.bp @@ -0,0 +1,29 @@ +// Copyright 2017 The Android Open Source Project +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. + +cc_test { + name: "libsensor_test", + + clang: true, + + srcs: [ + "Sensor_test.cpp", + ], + + shared_libs: [ + "liblog", + "libsensor", + "libutils", + ], +} diff --git a/libs/gui/tests/Sensor_test.cpp b/libs/sensor/tests/Sensor_test.cpp index fbf282d1cf..ede20c93f4 100644 --- a/libs/gui/tests/Sensor_test.cpp +++ b/libs/sensor/tests/Sensor_test.cpp @@ -16,7 +16,7 @@ #define LOG_TAG "Sensor_test" -#include <gui/Sensor.h> +#include <sensor/Sensor.h> #include <hardware/sensors.h> #include <utils/Errors.h> diff --git a/services/sensorservice/Android.mk b/services/sensorservice/Android.mk index d61f26fe84..cfb72310d5 100644 --- a/services/sensorservice/Android.mk +++ b/services/sensorservice/Android.mk @@ -33,8 +33,7 @@ LOCAL_SHARED_LIBRARIES := \ libutils \ liblog \ libbinder \ - libui \ - libgui \ + libsensor \ libcrypto \ libbase \ libhidlbase \ @@ -45,6 +44,10 @@ LOCAL_SHARED_LIBRARIES := \ LOCAL_STATIC_LIBRARIES := \ android.hardware.sensors@1.0-convert +# our public headers depend on libsensor +LOCAL_EXPORT_SHARED_LIBRARY_HEADERS := \ + libsensor \ + LOCAL_MODULE:= libsensorservice include $(BUILD_SHARED_LIBRARY) diff --git a/services/sensorservice/CorrectedGyroSensor.h b/services/sensorservice/CorrectedGyroSensor.h index 68acd43fd9..1d49e013f0 100644 --- a/services/sensorservice/CorrectedGyroSensor.h +++ b/services/sensorservice/CorrectedGyroSensor.h @@ -20,7 +20,7 @@ #include <stdint.h> #include <sys/types.h> -#include <gui/Sensor.h> +#include <sensor/Sensor.h> #include "SensorInterface.h" diff --git a/services/sensorservice/GravitySensor.h b/services/sensorservice/GravitySensor.h index 8e33a73a78..483f468f9a 100644 --- a/services/sensorservice/GravitySensor.h +++ b/services/sensorservice/GravitySensor.h @@ -20,7 +20,7 @@ #include <stdint.h> #include <sys/types.h> -#include <gui/Sensor.h> +#include <sensor/Sensor.h> #include "SensorInterface.h" diff --git a/services/sensorservice/LinearAccelerationSensor.h b/services/sensorservice/LinearAccelerationSensor.h index 428baa6995..aa4e54a047 100644 --- a/services/sensorservice/LinearAccelerationSensor.h +++ b/services/sensorservice/LinearAccelerationSensor.h @@ -20,7 +20,7 @@ #include <stdint.h> #include <sys/types.h> -#include <gui/Sensor.h> +#include <sensor/Sensor.h> #include "SensorInterface.h" #include "GravitySensor.h" diff --git a/services/sensorservice/OrientationSensor.h b/services/sensorservice/OrientationSensor.h index 30ff226364..a3f2a99136 100644 --- a/services/sensorservice/OrientationSensor.h +++ b/services/sensorservice/OrientationSensor.h @@ -20,7 +20,7 @@ #include <stdint.h> #include <sys/types.h> -#include <gui/Sensor.h> +#include <sensor/Sensor.h> #include "SensorInterface.h" diff --git a/services/sensorservice/RotationVectorSensor.h b/services/sensorservice/RotationVectorSensor.h index 265b4c410e..34deaa9baa 100644 --- a/services/sensorservice/RotationVectorSensor.h +++ b/services/sensorservice/RotationVectorSensor.h @@ -20,7 +20,7 @@ #include <stdint.h> #include <sys/types.h> -#include <gui/Sensor.h> +#include <sensor/Sensor.h> #include "SensorDevice.h" #include "SensorInterface.h" diff --git a/services/sensorservice/SensorDevice.h b/services/sensorservice/SensorDevice.h index 7f95429b75..818656c1f2 100644 --- a/services/sensorservice/SensorDevice.h +++ b/services/sensorservice/SensorDevice.h @@ -19,7 +19,7 @@ #include "SensorServiceUtils.h" -#include <gui/Sensor.h> +#include <sensor/Sensor.h> #include <stdint.h> #include <sys/types.h> #include <utils/KeyedVector.h> diff --git a/services/sensorservice/SensorDirectConnection.h b/services/sensorservice/SensorDirectConnection.h index 692ef0dcc4..27458d4a2f 100644 --- a/services/sensorservice/SensorDirectConnection.h +++ b/services/sensorservice/SensorDirectConnection.h @@ -22,10 +22,10 @@ #include <binder/BinderService.h> -#include <gui/Sensor.h> -#include <gui/BitTube.h> -#include <gui/ISensorServer.h> -#include <gui/ISensorEventConnection.h> +#include <sensor/Sensor.h> +#include <sensor/BitTube.h> +#include <sensor/ISensorServer.h> +#include <sensor/ISensorEventConnection.h> #include "SensorService.h" diff --git a/services/sensorservice/SensorEventConnection.cpp b/services/sensorservice/SensorEventConnection.cpp index d84d36ebb6..fad046cf53 100644 --- a/services/sensorservice/SensorEventConnection.cpp +++ b/services/sensorservice/SensorEventConnection.cpp @@ -17,7 +17,7 @@ #include <sys/socket.h> #include <utils/threads.h> -#include <gui/SensorEventQueue.h> +#include <sensor/SensorEventQueue.h> #include "vec.h" #include "SensorEventConnection.h" diff --git a/services/sensorservice/SensorEventConnection.h b/services/sensorservice/SensorEventConnection.h index cd81dddab5..c81e015dbe 100644 --- a/services/sensorservice/SensorEventConnection.h +++ b/services/sensorservice/SensorEventConnection.h @@ -31,10 +31,10 @@ #include <binder/BinderService.h> -#include <gui/Sensor.h> -#include <gui/BitTube.h> -#include <gui/ISensorServer.h> -#include <gui/ISensorEventConnection.h> +#include <sensor/Sensor.h> +#include <sensor/BitTube.h> +#include <sensor/ISensorServer.h> +#include <sensor/ISensorEventConnection.h> #include "SensorService.h" diff --git a/services/sensorservice/SensorFusion.h b/services/sensorservice/SensorFusion.h index ad636d5dad..8c0fbf9a6e 100644 --- a/services/sensorservice/SensorFusion.h +++ b/services/sensorservice/SensorFusion.h @@ -24,7 +24,7 @@ #include <utils/Singleton.h> #include <utils/String8.h> -#include <gui/Sensor.h> +#include <sensor/Sensor.h> #include "Fusion.h" diff --git a/services/sensorservice/SensorInterface.h b/services/sensorservice/SensorInterface.h index 0867dc278b..b5375cb9ed 100644 --- a/services/sensorservice/SensorInterface.h +++ b/services/sensorservice/SensorInterface.h @@ -17,7 +17,7 @@ #ifndef ANDROID_SENSOR_INTERFACE_H #define ANDROID_SENSOR_INTERFACE_H -#include <gui/Sensor.h> +#include <sensor/Sensor.h> #include <utils/RefBase.h> // --------------------------------------------------------------------------- diff --git a/services/sensorservice/SensorList.h b/services/sensorservice/SensorList.h index 8209d96815..6b90ad99f9 100644 --- a/services/sensorservice/SensorList.h +++ b/services/sensorservice/SensorList.h @@ -20,7 +20,7 @@ #include "SensorInterface.h" #include "SensorServiceUtils.h" -#include <gui/Sensor.h> +#include <sensor/Sensor.h> #include <utils/String8.h> #include <utils/Vector.h> diff --git a/services/sensorservice/SensorService.cpp b/services/sensorservice/SensorService.cpp index 143a3c5746..c11df13c8a 100644 --- a/services/sensorservice/SensorService.cpp +++ b/services/sensorservice/SensorService.cpp @@ -22,7 +22,7 @@ #include <binder/PermissionCache.h> #include <cutils/ashmem.h> -#include <gui/SensorEventQueue.h> +#include <sensor/SensorEventQueue.h> #include <hardware/sensors.h> #include <hardware_legacy/power.h> diff --git a/services/sensorservice/SensorService.h b/services/sensorservice/SensorService.h index eeedd4a53a..5583dad53f 100644 --- a/services/sensorservice/SensorService.h +++ b/services/sensorservice/SensorService.h @@ -22,9 +22,9 @@ #include <binder/BinderService.h> #include <cutils/compiler.h> -#include <gui/ISensorServer.h> -#include <gui/ISensorEventConnection.h> -#include <gui/Sensor.h> +#include <sensor/ISensorServer.h> +#include <sensor/ISensorEventConnection.h> +#include <sensor/Sensor.h> #include <utils/AndroidThreads.h> #include <utils/KeyedVector.h> diff --git a/services/sensorservice/tests/Android.mk b/services/sensorservice/tests/Android.mk index 45296dd6c0..e894655f79 100644 --- a/services/sensorservice/tests/Android.mk +++ b/services/sensorservice/tests/Android.mk @@ -5,7 +5,7 @@ LOCAL_SRC_FILES:= \ sensorservicetest.cpp LOCAL_SHARED_LIBRARIES := \ - libcutils libutils libui libgui + libutils libsensor libandroid LOCAL_MODULE:= test-sensorservice diff --git a/services/sensorservice/tests/sensorservicetest.cpp b/services/sensorservice/tests/sensorservicetest.cpp index 186b60cb1e..1cb0489f00 100644 --- a/services/sensorservice/tests/sensorservicetest.cpp +++ b/services/sensorservice/tests/sensorservicetest.cpp @@ -16,9 +16,9 @@ #include <inttypes.h> #include <android/sensor.h> -#include <gui/Sensor.h> -#include <gui/SensorManager.h> -#include <gui/SensorEventQueue.h> +#include <sensor/Sensor.h> +#include <sensor/SensorManager.h> +#include <sensor/SensorEventQueue.h> #include <utils/Looper.h> using namespace android; diff --git a/services/surfaceflinger/EventThread.cpp b/services/surfaceflinger/EventThread.cpp index d1bc7eb8cd..486bce4930 100644 --- a/services/surfaceflinger/EventThread.cpp +++ b/services/surfaceflinger/EventThread.cpp @@ -21,7 +21,7 @@ #include <cutils/compiler.h> -#include <gui/BitTube.h> +#include <private/gui/BitTube.h> #include <gui/IDisplayEventConnection.h> #include <gui/DisplayEventReceiver.h> diff --git a/services/surfaceflinger/MessageQueue.cpp b/services/surfaceflinger/MessageQueue.cpp index 974c7a340e..debea58e55 100644 --- a/services/surfaceflinger/MessageQueue.cpp +++ b/services/surfaceflinger/MessageQueue.cpp @@ -25,7 +25,7 @@ #include <utils/Log.h> #include <gui/IDisplayEventConnection.h> -#include <gui/BitTube.h> +#include <private/gui/BitTube.h> #include "MessageQueue.h" #include "EventThread.h" diff --git a/services/surfaceflinger/SurfaceFlinger.cpp b/services/surfaceflinger/SurfaceFlinger.cpp index daeac2755b..0dc3034e4e 100644 --- a/services/surfaceflinger/SurfaceFlinger.cpp +++ b/services/surfaceflinger/SurfaceFlinger.cpp @@ -40,7 +40,6 @@ #include <ui/DisplayInfo.h> #include <ui/DisplayStatInfo.h> -#include <gui/BitTube.h> #include <gui/BufferQueue.h> #include <gui/GuiConfig.h> #include <gui/IDisplayEventConnection.h> diff --git a/services/surfaceflinger/SurfaceFlinger_hwc1.cpp b/services/surfaceflinger/SurfaceFlinger_hwc1.cpp index fe8dd0ced5..6cd715297b 100644 --- a/services/surfaceflinger/SurfaceFlinger_hwc1.cpp +++ b/services/surfaceflinger/SurfaceFlinger_hwc1.cpp @@ -38,7 +38,6 @@ #include <ui/DisplayInfo.h> #include <ui/DisplayStatInfo.h> -#include <gui/BitTube.h> #include <gui/BufferQueue.h> #include <gui/GuiConfig.h> #include <gui/IDisplayEventConnection.h> |