summaryrefslogtreecommitdiff
path: root/libs
diff options
context:
space:
mode:
Diffstat (limited to 'libs')
-rw-r--r--libs/binder/Android.bp76
-rw-r--r--libs/binder/Android.mk72
-rw-r--r--libs/binder/AppOpsManager.cpp39
-rw-r--r--libs/binder/Binder.cpp4
-rw-r--r--libs/binder/BufferedTextOutput.cpp2
-rw-r--r--libs/binder/IAppOpsCallback.cpp2
-rw-r--r--libs/binder/IAppOpsService.cpp2
-rw-r--r--libs/binder/IBatteryStats.cpp2
-rw-r--r--libs/binder/IMemory.cpp54
-rw-r--r--libs/binder/IPCThreadState.cpp18
-rw-r--r--libs/binder/IPermissionController.cpp2
-rw-r--r--libs/binder/IProcessInfoService.cpp2
-rw-r--r--libs/binder/IServiceManager.cpp7
-rw-r--r--libs/binder/MemoryDealer.cpp2
-rw-r--r--libs/binder/Parcel.cpp120
-rw-r--r--libs/binder/PersistableBundle.cpp82
-rw-r--r--libs/binder/ProcessState.cpp11
-rw-r--r--libs/binder/Static.cpp2
-rw-r--r--libs/binder/Status.cpp15
-rw-r--r--libs/binder/TextOutput.cpp101
-rw-r--r--libs/binder/tests/Android.bp63
-rw-r--r--libs/binder/tests/Android.mk42
-rw-r--r--libs/binder/tests/binderDriverInterfaceTest.cpp7
-rw-r--r--libs/binder/tests/binderLibTest.cpp20
-rw-r--r--libs/binder/tests/binderTextOutputTest.cpp176
-rw-r--r--libs/diskusage/Android.bp18
-rw-r--r--libs/diskusage/Android.mk24
-rw-r--r--libs/gui/Android.bp111
-rw-r--r--libs/gui/Android.mk101
-rw-r--r--libs/gui/BufferItem.cpp44
-rw-r--r--libs/gui/BufferQueueConsumer.cpp10
-rw-r--r--libs/gui/BufferQueueCore.cpp25
-rw-r--r--libs/gui/BufferQueueProducer.cpp3
-rw-r--r--libs/gui/ConsumerBase.cpp8
-rw-r--r--libs/gui/IConsumerListener.cpp3
-rw-r--r--libs/gui/IDisplayEventConnection.cpp2
-rw-r--r--libs/gui/IGraphicBufferAlloc.cpp4
-rw-r--r--libs/gui/IGraphicBufferConsumer.cpp6
-rw-r--r--libs/gui/IGraphicBufferProducer.cpp2
-rw-r--r--libs/gui/IProducerListener.cpp6
-rw-r--r--libs/gui/ISensorEventConnection.cpp2
-rw-r--r--libs/gui/ISensorServer.cpp2
-rw-r--r--libs/gui/ISurfaceComposer.cpp2
-rw-r--r--libs/gui/ISurfaceComposerClient.cpp2
-rw-r--r--libs/gui/SensorManager.cpp2
-rw-r--r--libs/gui/Surface.cpp2
-rw-r--r--libs/gui/SurfaceComposerClient.cpp2
-rw-r--r--libs/gui/tests/Android.bp42
-rw-r--r--libs/gui/tests/Android.mk52
-rw-r--r--libs/gui/tests/BufferQueue_test.cpp2
-rw-r--r--libs/gui/tests/CpuConsumer_test.cpp2
-rw-r--r--libs/gui/tests/Sensor_test.cpp88
-rw-r--r--libs/gui/tests/SurfaceTextureClient_test.cpp2
-rw-r--r--libs/gui/tests/SurfaceTextureGL_test.cpp4
-rw-r--r--libs/input/Android.bp62
-rw-r--r--libs/input/Android.mk82
-rw-r--r--libs/input/IInputFlinger.cpp2
-rw-r--r--libs/input/tests/Android.bp28
-rw-r--r--libs/input/tests/Android.mk40
-rw-r--r--libs/input/tests/StructLayout_test.cpp2
-rw-r--r--libs/ui/Android.bp68
-rw-r--r--libs/ui/Android.mk75
-rw-r--r--libs/ui/Region.cpp25
-rw-r--r--libs/ui/UiConfig.cpp12
-rw-r--r--libs/ui/tests/Android.bp31
-rw-r--r--libs/ui/tests/Android.mk36
66 files changed, 1125 insertions, 834 deletions
diff --git a/libs/binder/Android.bp b/libs/binder/Android.bp
new file mode 100644
index 0000000000..4780757f59
--- /dev/null
+++ b/libs/binder/Android.bp
@@ -0,0 +1,76 @@
+// Copyright (C) 2009 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 {
+ name: "libbinder",
+
+ srcs: [
+ "AppOpsManager.cpp",
+ "Binder.cpp",
+ "BpBinder.cpp",
+ "BufferedTextOutput.cpp",
+ "Debug.cpp",
+ "IAppOpsCallback.cpp",
+ "IAppOpsService.cpp",
+ "IBatteryStats.cpp",
+ "IInterface.cpp",
+ "IMediaResourceMonitor.cpp",
+ "IMemory.cpp",
+ "IPCThreadState.cpp",
+ "IPermissionController.cpp",
+ "IProcessInfoService.cpp",
+ "IResultReceiver.cpp",
+ "IServiceManager.cpp",
+ "MemoryBase.cpp",
+ "MemoryDealer.cpp",
+ "MemoryHeapBase.cpp",
+ "Parcel.cpp",
+ "PermissionCache.cpp",
+ "PersistableBundle.cpp",
+ "ProcessInfoService.cpp",
+ "ProcessState.cpp",
+ "Static.cpp",
+ "Status.cpp",
+ "TextOutput.cpp",
+ ],
+
+ cflags: [
+ "-Wall",
+ "-Wextra",
+ "-Werror",
+ ],
+ product_variables: {
+ binder32bit: {
+ cflags: ["-DBINDER_IPC_32BIT=1"],
+ },
+ },
+
+ shared_libs: [
+ "libbase",
+ "liblog",
+ "libcutils",
+ "libutils",
+ ],
+ export_shared_lib_headers: [
+ "libbase",
+ "libutils",
+ ],
+
+ clang: true,
+ sanitize: {
+ misc_undefined: ["integer"],
+ },
+}
+
+subdirs = ["tests"]
diff --git a/libs/binder/Android.mk b/libs/binder/Android.mk
deleted file mode 100644
index 14be920d2e..0000000000
--- a/libs/binder/Android.mk
+++ /dev/null
@@ -1,72 +0,0 @@
-# Copyright (C) 2009 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.
-
-# we have the common sources, plus some device-specific stuff
-sources := \
- AppOpsManager.cpp \
- Binder.cpp \
- BpBinder.cpp \
- BufferedTextOutput.cpp \
- Debug.cpp \
- IAppOpsCallback.cpp \
- IAppOpsService.cpp \
- IBatteryStats.cpp \
- IInterface.cpp \
- IMediaResourceMonitor.cpp \
- IMemory.cpp \
- IPCThreadState.cpp \
- IPermissionController.cpp \
- IProcessInfoService.cpp \
- IResultReceiver.cpp \
- IServiceManager.cpp \
- MemoryBase.cpp \
- MemoryDealer.cpp \
- MemoryHeapBase.cpp \
- Parcel.cpp \
- PermissionCache.cpp \
- PersistableBundle.cpp \
- ProcessInfoService.cpp \
- ProcessState.cpp \
- Static.cpp \
- Status.cpp \
- TextOutput.cpp \
-
-LOCAL_PATH:= $(call my-dir)
-
-include $(CLEAR_VARS)
-LOCAL_MODULE := libbinder
-LOCAL_SHARED_LIBRARIES := liblog libcutils libutils
-
-LOCAL_CLANG := true
-LOCAL_SANITIZE := integer
-LOCAL_SRC_FILES := $(sources)
-ifneq ($(TARGET_USES_64_BIT_BINDER),true)
-ifneq ($(TARGET_IS_64_BIT),true)
-LOCAL_CFLAGS += -DBINDER_IPC_32BIT=1
-endif
-endif
-LOCAL_CFLAGS += -Werror
-include $(BUILD_SHARED_LIBRARY)
-
-include $(CLEAR_VARS)
-LOCAL_MODULE := libbinder
-LOCAL_STATIC_LIBRARIES += libutils
-LOCAL_SRC_FILES := $(sources)
-ifneq ($(TARGET_USES_64_BIT_BINDER),true)
-ifneq ($(TARGET_IS_64_BIT),true)
-LOCAL_CFLAGS += -DBINDER_IPC_32BIT=1
-endif
-endif
-LOCAL_CFLAGS += -Werror
-include $(BUILD_STATIC_LIBRARY)
diff --git a/libs/binder/AppOpsManager.cpp b/libs/binder/AppOpsManager.cpp
index 9a061a0ceb..f3b86ae311 100644
--- a/libs/binder/AppOpsManager.cpp
+++ b/libs/binder/AppOpsManager.cpp
@@ -14,6 +14,7 @@
* limitations under the License.
*/
+#include <mutex>
#include <binder/AppOpsManager.h>
#include <binder/Binder.h>
#include <binder/IServiceManager.h>
@@ -22,6 +23,19 @@
namespace android {
+namespace {
+
+#if defined(__BRILLO__)
+// Because Brillo has no application model, security policy is managed
+// statically (at build time) with SELinux controls.
+// As a consequence, it also never runs the AppOpsManager service.
+const int APP_OPS_MANAGER_UNAVAILABLE_MODE = AppOpsManager::MODE_ALLOWED;
+#else
+const int APP_OPS_MANAGER_UNAVAILABLE_MODE = AppOpsManager::MODE_IGNORED;
+#endif // defined(__BRILLO__)
+
+} // namespace
+
static String16 _appops("appops");
static pthread_mutex_t gTokenMutex = PTHREAD_MUTEX_INITIALIZER;
static sp<IBinder> gToken;
@@ -39,10 +53,15 @@ AppOpsManager::AppOpsManager()
{
}
+#if defined(__BRILLO__)
+// There is no AppOpsService on Brillo
+sp<IAppOpsService> AppOpsManager::getService() { return NULL; }
+#else
sp<IAppOpsService> AppOpsManager::getService()
{
+
+ std::lock_guard<Mutex> scoped_lock(mLock);
int64_t startTime = 0;
- mLock.lock();
sp<IAppOpsService> service = mService;
while (service == NULL || !IInterface::asBinder(service)->isBinderAlive()) {
sp<IBinder> binder = defaultServiceManager()->checkService(_appops);
@@ -53,7 +72,8 @@ sp<IAppOpsService> AppOpsManager::getService()
ALOGI("Waiting for app ops service");
} else if ((uptimeMillis()-startTime) > 10000) {
ALOGW("Waiting too long for app ops service, giving up");
- return NULL;
+ service = NULL;
+ break;
}
sleep(1);
} else {
@@ -61,25 +81,30 @@ sp<IAppOpsService> AppOpsManager::getService()
mService = service;
}
}
- mLock.unlock();
return service;
}
+#endif // defined(__BRILLO__)
int32_t AppOpsManager::checkOp(int32_t op, int32_t uid, const String16& callingPackage)
{
sp<IAppOpsService> service = getService();
- return service != NULL ? service->checkOperation(op, uid, callingPackage) : MODE_IGNORED;
+ return service != NULL
+ ? service->checkOperation(op, uid, callingPackage)
+ : APP_OPS_MANAGER_UNAVAILABLE_MODE;
}
int32_t AppOpsManager::noteOp(int32_t op, int32_t uid, const String16& callingPackage) {
sp<IAppOpsService> service = getService();
- return service != NULL ? service->noteOperation(op, uid, callingPackage) : MODE_IGNORED;
+ return service != NULL
+ ? service->noteOperation(op, uid, callingPackage)
+ : APP_OPS_MANAGER_UNAVAILABLE_MODE;
}
int32_t AppOpsManager::startOp(int32_t op, int32_t uid, const String16& callingPackage) {
sp<IAppOpsService> service = getService();
- return service != NULL ? service->startOperation(getToken(service), op, uid, callingPackage)
- : MODE_IGNORED;
+ return service != NULL
+ ? service->startOperation(getToken(service), op, uid, callingPackage)
+ : APP_OPS_MANAGER_UNAVAILABLE_MODE;
}
void AppOpsManager::finishOp(int32_t op, int32_t uid, const String16& callingPackage) {
diff --git a/libs/binder/Binder.cpp b/libs/binder/Binder.cpp
index c4d47caede..7ce2a318a9 100644
--- a/libs/binder/Binder.cpp
+++ b/libs/binder/Binder.cpp
@@ -237,6 +237,10 @@ status_t BBinder::onTransact(
// XXX can't add virtuals until binaries are updated.
//return shellCommand(in, out, err, args, resultReceiver);
+ (void)in;
+ (void)out;
+ (void)err;
+
if (resultReceiver != NULL) {
resultReceiver->send(INVALID_OPERATION);
}
diff --git a/libs/binder/BufferedTextOutput.cpp b/libs/binder/BufferedTextOutput.cpp
index 1339a67e62..a2443c081f 100644
--- a/libs/binder/BufferedTextOutput.cpp
+++ b/libs/binder/BufferedTextOutput.cpp
@@ -34,7 +34,7 @@ namespace android {
struct BufferedTextOutput::BufferState : public RefBase
{
- BufferState(int32_t _seq)
+ explicit BufferState(int32_t _seq)
: seq(_seq)
, buffer(NULL)
, bufferPos(0)
diff --git a/libs/binder/IAppOpsCallback.cpp b/libs/binder/IAppOpsCallback.cpp
index 2aaf56679e..f9ec593f77 100644
--- a/libs/binder/IAppOpsCallback.cpp
+++ b/libs/binder/IAppOpsCallback.cpp
@@ -31,7 +31,7 @@ namespace android {
class BpAppOpsCallback : public BpInterface<IAppOpsCallback>
{
public:
- BpAppOpsCallback(const sp<IBinder>& impl)
+ explicit BpAppOpsCallback(const sp<IBinder>& impl)
: BpInterface<IAppOpsCallback>(impl)
{
}
diff --git a/libs/binder/IAppOpsService.cpp b/libs/binder/IAppOpsService.cpp
index 9558376dbf..638ae5c8ac 100644
--- a/libs/binder/IAppOpsService.cpp
+++ b/libs/binder/IAppOpsService.cpp
@@ -31,7 +31,7 @@ namespace android {
class BpAppOpsService : public BpInterface<IAppOpsService>
{
public:
- BpAppOpsService(const sp<IBinder>& impl)
+ explicit BpAppOpsService(const sp<IBinder>& impl)
: BpInterface<IAppOpsService>(impl)
{
}
diff --git a/libs/binder/IBatteryStats.cpp b/libs/binder/IBatteryStats.cpp
index e32c628679..ad1e69faeb 100644
--- a/libs/binder/IBatteryStats.cpp
+++ b/libs/binder/IBatteryStats.cpp
@@ -29,7 +29,7 @@ namespace android {
class BpBatteryStats : public BpInterface<IBatteryStats>
{
public:
- BpBatteryStats(const sp<IBinder>& impl)
+ explicit BpBatteryStats(const sp<IBinder>& impl)
: BpInterface<IBatteryStats>(impl)
{
}
diff --git a/libs/binder/IMemory.cpp b/libs/binder/IMemory.cpp
index 5f345cf7b7..790fa8c931 100644
--- a/libs/binder/IMemory.cpp
+++ b/libs/binder/IMemory.cpp
@@ -16,6 +16,7 @@
#define LOG_TAG "IMemory"
+#include <atomic>
#include <stdint.h>
#include <stdio.h>
#include <stdlib.h>
@@ -29,7 +30,6 @@
#include <cutils/log.h>
#include <utils/KeyedVector.h>
#include <utils/threads.h>
-#include <utils/Atomic.h>
#include <binder/Parcel.h>
#include <utils/CallStack.h>
@@ -56,12 +56,15 @@ private:
struct heap_info_t {
sp<IMemoryHeap> heap;
int32_t count;
+ // Note that this cannot be meaningfully copied.
};
void free_heap(const wp<IBinder>& binder);
- Mutex mHeapCacheLock;
+ Mutex mHeapCacheLock; // Protects entire vector below.
KeyedVector< wp<IBinder>, heap_info_t > mHeapCache;
+ // We do not use the copy-on-write capabilities of KeyedVector.
+ // TODO: Reimplemement based on standard C++ container?
};
static sp<HeapCache> gHeapCache = new HeapCache();
@@ -75,7 +78,7 @@ enum {
class BpMemoryHeap : public BpInterface<IMemoryHeap>
{
public:
- BpMemoryHeap(const sp<IBinder>& impl);
+ explicit BpMemoryHeap(const sp<IBinder>& impl);
virtual ~BpMemoryHeap();
virtual int getHeapID() const;
@@ -105,7 +108,7 @@ private:
void assertMapped() const;
void assertReallyMapped() const;
- mutable volatile int32_t mHeapId;
+ mutable std::atomic<int32_t> mHeapId;
mutable void* mBase;
mutable size_t mSize;
mutable uint32_t mFlags;
@@ -123,7 +126,7 @@ enum {
class BpMemory : public BpInterface<IMemory>
{
public:
- BpMemory(const sp<IBinder>& impl);
+ explicit BpMemory(const sp<IBinder>& impl);
virtual ~BpMemory();
virtual sp<IMemoryHeap> getMemory(ssize_t* offset=0, size_t* size=0) const;
@@ -248,8 +251,9 @@ BpMemoryHeap::BpMemoryHeap(const sp<IBinder>& impl)
}
BpMemoryHeap::~BpMemoryHeap() {
- if (mHeapId != -1) {
- close(mHeapId);
+ int32_t heapId = mHeapId.load(memory_order_relaxed);
+ if (heapId != -1) {
+ close(heapId);
if (mRealHeap) {
// by construction we're the last one
if (mBase != MAP_FAILED) {
@@ -257,7 +261,7 @@ BpMemoryHeap::~BpMemoryHeap() {
if (VERBOSE) {
ALOGD("UNMAPPING binder=%p, heap=%p, size=%zu, fd=%d",
- binder.get(), this, mSize, mHeapId);
+ binder.get(), this, mSize, heapId);
CallStack stack(LOG_TAG);
}
@@ -273,17 +277,21 @@ BpMemoryHeap::~BpMemoryHeap() {
void BpMemoryHeap::assertMapped() const
{
- if (mHeapId == -1) {
+ int32_t heapId = mHeapId.load(memory_order_acquire);
+ if (heapId == -1) {
sp<IBinder> binder(IInterface::asBinder(const_cast<BpMemoryHeap*>(this)));
sp<BpMemoryHeap> heap(static_cast<BpMemoryHeap*>(find_heap(binder).get()));
heap->assertReallyMapped();
if (heap->mBase != MAP_FAILED) {
Mutex::Autolock _l(mLock);
- if (mHeapId == -1) {
+ if (mHeapId.load(memory_order_relaxed) == -1) {
mBase = heap->mBase;
mSize = heap->mSize;
mOffset = heap->mOffset;
- android_atomic_write( dup( heap->mHeapId ), &mHeapId );
+ int fd = dup(heap->mHeapId.load(memory_order_relaxed));
+ ALOGE_IF(fd==-1, "cannot dup fd=%d",
+ heap->mHeapId.load(memory_order_relaxed));
+ mHeapId.store(fd, memory_order_release);
}
} else {
// something went wrong
@@ -294,7 +302,8 @@ void BpMemoryHeap::assertMapped() const
void BpMemoryHeap::assertReallyMapped() const
{
- if (mHeapId == -1) {
+ int32_t heapId = mHeapId.load(memory_order_acquire);
+ if (heapId == -1) {
// remote call without mLock held, worse case scenario, we end up
// calling transact() from multiple threads, but that's not a problem,
@@ -313,7 +322,7 @@ void BpMemoryHeap::assertReallyMapped() const
parcel_fd, size, err, strerror(-err));
Mutex::Autolock _l(mLock);
- if (mHeapId == -1) {
+ if (mHeapId.load(memory_order_relaxed) == -1) {
int fd = dup( parcel_fd );
ALOGE_IF(fd==-1, "cannot dup fd=%d, size=%zd, err=%d (%s)",
parcel_fd, size, err, strerror(errno));
@@ -322,7 +331,6 @@ void BpMemoryHeap::assertReallyMapped() const
if (!(flags & READ_ONLY)) {
access |= PROT_WRITE;
}
-
mRealHeap = true;
mBase = mmap(0, size, access, MAP_SHARED, fd, offset);
if (mBase == MAP_FAILED) {
@@ -333,7 +341,7 @@ void BpMemoryHeap::assertReallyMapped() const
mSize = size;
mFlags = flags;
mOffset = offset;
- android_atomic_write(fd, &mHeapId);
+ mHeapId.store(fd, memory_order_release);
}
}
}
@@ -341,7 +349,8 @@ void BpMemoryHeap::assertReallyMapped() const
int BpMemoryHeap::getHeapID() const {
assertMapped();
- return mHeapId;
+ // We either stored mHeapId ourselves, or loaded it with acquire semantics.
+ return mHeapId.load(memory_order_relaxed);
}
void* BpMemoryHeap::getBase() const {
@@ -418,9 +427,10 @@ sp<IMemoryHeap> HeapCache::find_heap(const sp<IBinder>& binder)
"found binder=%p, heap=%p, size=%zu, fd=%d, count=%d",
binder.get(), info.heap.get(),
static_cast<BpMemoryHeap*>(info.heap.get())->mSize,
- static_cast<BpMemoryHeap*>(info.heap.get())->mHeapId,
+ static_cast<BpMemoryHeap*>(info.heap.get())
+ ->mHeapId.load(memory_order_relaxed),
info.count);
- android_atomic_inc(&info.count);
+ ++info.count;
return info.heap;
} else {
heap_info_t info;
@@ -445,13 +455,13 @@ void HeapCache::free_heap(const wp<IBinder>& binder)
ssize_t i = mHeapCache.indexOfKey(binder);
if (i>=0) {
heap_info_t& info(mHeapCache.editValueAt(i));
- int32_t c = android_atomic_dec(&info.count);
- if (c == 1) {
+ if (--info.count == 0) {
ALOGD_IF(VERBOSE,
"removing binder=%p, heap=%p, size=%zu, fd=%d, count=%d",
binder.unsafe_get(), info.heap.get(),
static_cast<BpMemoryHeap*>(info.heap.get())->mSize,
- static_cast<BpMemoryHeap*>(info.heap.get())->mHeapId,
+ static_cast<BpMemoryHeap*>(info.heap.get())
+ ->mHeapId.load(memory_order_relaxed),
info.count);
rel = mHeapCache.valueAt(i).heap;
mHeapCache.removeItemsAt(i);
@@ -482,7 +492,7 @@ void HeapCache::dump_heaps()
ALOGD("hey=%p, heap=%p, count=%d, (fd=%d, base=%p, size=%zu)",
mHeapCache.keyAt(i).unsafe_get(),
info.heap.get(), info.count,
- h->mHeapId, h->mBase, h->mSize);
+ h->mHeapId.load(memory_order_relaxed), h->mBase, h->mSize);
}
}
diff --git a/libs/binder/IPCThreadState.cpp b/libs/binder/IPCThreadState.cpp
index d90798f51e..02b4232257 100644
--- a/libs/binder/IPCThreadState.cpp
+++ b/libs/binder/IPCThreadState.cpp
@@ -64,10 +64,6 @@
namespace android {
-static const char* getReturnString(size_t idx);
-static const void* printReturnCommand(TextOutput& out, const void* _cmd);
-static const void* printCommand(TextOutput& out, const void* _cmd);
-
// Static const and functions will be optimized out if not used,
// when LOG_NDEBUG and references in IF_LOG_COMMANDS() are optimized out.
static const char *kReturnStrings[] = {
@@ -111,8 +107,9 @@ static const char *kCommandStrings[] = {
"BC_DEAD_BINDER_DONE"
};
-static const char* getReturnString(size_t idx)
+static const char* getReturnString(uint32_t cmd)
{
+ size_t idx = cmd & 0xff;
if (idx < sizeof(kReturnStrings) / sizeof(kReturnStrings[0]))
return kReturnStrings[idx];
else
@@ -330,6 +327,7 @@ void IPCThreadState::shutdown()
delete st;
pthread_setspecific(gTLS, NULL);
}
+ pthread_key_delete(gTLS);
gHaveTLS = false;
}
}
@@ -525,8 +523,8 @@ void IPCThreadState::joinThreadPool(bool isMain)
}
} while (result != -ECONNREFUSED && result != -EBADF);
- LOG_THREADPOOL("**** THREAD %p (PID %d) IS LEAVING THE THREAD POOL err=%p\n",
- (void*)pthread_self(), getpid(), (void*)result);
+ LOG_THREADPOOL("**** THREAD %p (PID %d) IS LEAVING THE THREAD POOL err=%d\n",
+ (void*)pthread_self(), getpid(), result);
mOut.writeInt32(BC_EXIT_LOOPER);
talkWithDriver(false);
@@ -668,7 +666,7 @@ status_t IPCThreadState::attemptIncStrongHandle(int32_t handle)
waitForResponse(NULL, &result);
#if LOG_REFCOUNTS
- printf("IPCThreadState::attemptIncStrongHandle(%ld) = %s\n",
+ ALOGV("IPCThreadState::attemptIncStrongHandle(%ld) = %s\n",
handle, result == NO_ERROR ? "SUCCESS" : "FAILURE");
#endif
@@ -683,7 +681,7 @@ status_t IPCThreadState::attemptIncStrongHandle(int32_t handle)
void IPCThreadState::expungeHandle(int32_t handle, IBinder* binder)
{
#if LOG_REFCOUNTS
- printf("IPCThreadState::expungeHandle(%ld)\n", handle);
+ ALOGV("IPCThreadState::expungeHandle(%ld)\n", handle);
#endif
self()->mProcess->expungeHandle(handle, binder);
}
@@ -1170,7 +1168,7 @@ status_t IPCThreadState::executeCommand(int32_t cmd)
break;
default:
- printf("*** BAD COMMAND %d received from Binder driver\n", cmd);
+ ALOGE("*** BAD COMMAND %d received from Binder driver\n", cmd);
result = UNKNOWN_ERROR;
break;
}
diff --git a/libs/binder/IPermissionController.cpp b/libs/binder/IPermissionController.cpp
index 6bba9968bc..674bddf218 100644
--- a/libs/binder/IPermissionController.cpp
+++ b/libs/binder/IPermissionController.cpp
@@ -31,7 +31,7 @@ namespace android {
class BpPermissionController : public BpInterface<IPermissionController>
{
public:
- BpPermissionController(const sp<IBinder>& impl)
+ explicit BpPermissionController(const sp<IBinder>& impl)
: BpInterface<IPermissionController>(impl)
{
}
diff --git a/libs/binder/IProcessInfoService.cpp b/libs/binder/IProcessInfoService.cpp
index 76508b88bf..96e1a8c239 100644
--- a/libs/binder/IProcessInfoService.cpp
+++ b/libs/binder/IProcessInfoService.cpp
@@ -25,7 +25,7 @@ namespace android {
class BpProcessInfoService : public BpInterface<IProcessInfoService> {
public:
- BpProcessInfoService(const sp<IBinder>& impl)
+ explicit BpProcessInfoService(const sp<IBinder>& impl)
: BpInterface<IProcessInfoService>(impl) {}
virtual status_t getProcessStatesFromPids(size_t length, /*in*/ int32_t* pids,
diff --git a/libs/binder/IServiceManager.cpp b/libs/binder/IServiceManager.cpp
index 61f24d6805..2062b3b509 100644
--- a/libs/binder/IServiceManager.cpp
+++ b/libs/binder/IServiceManager.cpp
@@ -67,11 +67,6 @@ bool checkCallingPermission(const String16& permission, int32_t* outPid, int32_t
bool checkPermission(const String16& permission, pid_t pid, uid_t uid)
{
-#ifdef __BRILLO__
- // Brillo doesn't currently run ActivityManager or support framework permissions.
- return true;
-#endif
-
sp<IPermissionController> pc;
gDefaultServiceManagerLock.lock();
pc = gPermissionController;
@@ -131,7 +126,7 @@ bool checkPermission(const String16& permission, pid_t pid, uid_t uid)
class BpServiceManager : public BpInterface<IServiceManager>
{
public:
- BpServiceManager(const sp<IBinder>& impl)
+ explicit BpServiceManager(const sp<IBinder>& impl)
: BpInterface<IServiceManager>(impl)
{
}
diff --git a/libs/binder/MemoryDealer.cpp b/libs/binder/MemoryDealer.cpp
index 51eac1104b..2a15773aa3 100644
--- a/libs/binder/MemoryDealer.cpp
+++ b/libs/binder/MemoryDealer.cpp
@@ -126,7 +126,7 @@ class SimpleBestFitAllocator
PAGE_ALIGNED = 0x00000001
};
public:
- SimpleBestFitAllocator(size_t size);
+ explicit SimpleBestFitAllocator(size_t size);
~SimpleBestFitAllocator();
size_t allocate(size_t size, uint32_t flags = 0);
diff --git a/libs/binder/Parcel.cpp b/libs/binder/Parcel.cpp
index e88ae29518..061cb08fde 100644
--- a/libs/binder/Parcel.cpp
+++ b/libs/binder/Parcel.cpp
@@ -100,32 +100,6 @@ enum {
BLOB_ASHMEM_MUTABLE = 2,
};
-static dev_t ashmem_rdev()
-{
- static dev_t __ashmem_rdev;
- static pthread_mutex_t __ashmem_rdev_lock = PTHREAD_MUTEX_INITIALIZER;
-
- pthread_mutex_lock(&__ashmem_rdev_lock);
-
- dev_t rdev = __ashmem_rdev;
- if (!rdev) {
- int fd = TEMP_FAILURE_RETRY(open("/dev/ashmem", O_RDONLY));
- if (fd >= 0) {
- struct stat st;
-
- int ret = TEMP_FAILURE_RETRY(fstat(fd, &st));
- close(fd);
- if ((ret >= 0) && S_ISCHR(st.st_mode)) {
- rdev = __ashmem_rdev = st.st_rdev;
- }
- }
- }
-
- pthread_mutex_unlock(&__ashmem_rdev_lock);
-
- return rdev;
-}
-
void acquire_object(const sp<ProcessState>& proc,
const flat_binder_object& obj, const void* who, size_t* outAshmemSize)
{
@@ -154,15 +128,11 @@ void acquire_object(const sp<ProcessState>& proc,
return;
}
case BINDER_TYPE_FD: {
- if ((obj.cookie != 0) && (outAshmemSize != NULL)) {
- struct stat st;
- int ret = fstat(obj.handle, &st);
- if (!ret && S_ISCHR(st.st_mode) && (st.st_rdev == ashmem_rdev())) {
- // If we own an ashmem fd, keep track of how much memory it refers to.
- int size = ashmem_get_size_region(obj.handle);
- if (size > 0) {
- *outAshmemSize += size;
- }
+ if ((obj.cookie != 0) && (outAshmemSize != NULL) && ashmem_valid(obj.handle)) {
+ // If we own an ashmem fd, keep track of how much memory it refers to.
+ int size = ashmem_get_size_region(obj.handle);
+ if (size > 0) {
+ *outAshmemSize += size;
}
}
return;
@@ -207,14 +177,10 @@ static void release_object(const sp<ProcessState>& proc,
}
case BINDER_TYPE_FD: {
if (obj.cookie != 0) { // owned
- if (outAshmemSize != NULL) {
- struct stat st;
- int ret = fstat(obj.handle, &st);
- if (!ret && S_ISCHR(st.st_mode) && (st.st_rdev == ashmem_rdev())) {
- int size = ashmem_get_size_region(obj.handle);
- if (size > 0) {
- *outAshmemSize -= size;
- }
+ if ((outAshmemSize != NULL) && ashmem_valid(obj.handle)) {
+ int size = ashmem_get_size_region(obj.handle);
+ if (size > 0) {
+ *outAshmemSize -= size;
}
}
@@ -784,7 +750,7 @@ status_t Parcel::writeUtf8AsUtf16(const std::string& str) {
const uint8_t* strData = (uint8_t*)str.data();
const size_t strLen= str.length();
const ssize_t utf16Len = utf8_to_utf16_length(strData, strLen);
- if (utf16Len < 0 || utf16Len> std::numeric_limits<int32_t>::max()) {
+ if (utf16Len < 0 || utf16Len > std::numeric_limits<int32_t>::max()) {
return BAD_VALUE;
}
@@ -799,7 +765,7 @@ status_t Parcel::writeUtf8AsUtf16(const std::string& str) {
return NO_MEMORY;
}
- utf8_to_utf16(strData, strLen, (char16_t*)dst);
+ utf8_to_utf16(strData, strLen, (char16_t*)dst, (size_t) utf16Len + 1);
return NO_ERROR;
}
@@ -1112,7 +1078,7 @@ status_t Parcel::writeStrongBinderVector(const std::unique_ptr<std::vector<sp<IB
}
status_t Parcel::readStrongBinderVector(std::unique_ptr<std::vector<sp<IBinder>>>* val) const {
- return readNullableTypedVector(val, &Parcel::readStrongBinder);
+ return readNullableTypedVector(val, &Parcel::readNullableStrongBinder);
}
status_t Parcel::readStrongBinderVector(std::vector<sp<IBinder>>* val) const {
@@ -1187,15 +1153,15 @@ status_t Parcel::writeDupFileDescriptor(int fd)
return err;
}
-status_t Parcel::writeUniqueFileDescriptor(const ScopedFd& fd) {
+status_t Parcel::writeUniqueFileDescriptor(const base::unique_fd& fd) {
return writeDupFileDescriptor(fd.get());
}
-status_t Parcel::writeUniqueFileDescriptorVector(const std::vector<ScopedFd>& val) {
+status_t Parcel::writeUniqueFileDescriptorVector(const std::vector<base::unique_fd>& val) {
return writeTypedVector(val, &Parcel::writeUniqueFileDescriptor);
}
-status_t Parcel::writeUniqueFileDescriptorVector(const std::unique_ptr<std::vector<ScopedFd>>& val) {
+status_t Parcel::writeUniqueFileDescriptorVector(const std::unique_ptr<std::vector<base::unique_fd>>& val) {
return writeNullableTypedVector(val, &Parcel::writeUniqueFileDescriptor);
}
@@ -1842,13 +1808,37 @@ const char* Parcel::readCString() const
String8 Parcel::readString8() const
{
- int32_t size = readInt32();
- // watch for potential int overflow adding 1 for trailing NUL
- if (size > 0 && size < INT32_MAX) {
- const char* str = (const char*)readInplace(size+1);
- if (str) return String8(str, size);
+ String8 retString;
+ status_t status = readString8(&retString);
+ if (status != OK) {
+ // We don't care about errors here, so just return an empty string.
+ return String8();
}
- return String8();
+ return retString;
+}
+
+status_t Parcel::readString8(String8* pArg) const
+{
+ int32_t size;
+ status_t status = readInt32(&size);
+ if (status != OK) {
+ return status;
+ }
+ // watch for potential int overflow from size+1
+ if (size < 0 || size >= INT32_MAX) {
+ return BAD_VALUE;
+ }
+ // |writeString8| writes nothing for empty string.
+ if (size == 0) {
+ *pArg = String8();
+ return OK;
+ }
+ const char* str = (const char*)readInplace(size + 1);
+ if (str == NULL) {
+ return BAD_VALUE;
+ }
+ pArg->setTo(str, size);
+ return OK;
}
String16 Parcel::readString16() const
@@ -1913,13 +1903,25 @@ const char16_t* Parcel::readString16Inplace(size_t* outLen) const
status_t Parcel::readStrongBinder(sp<IBinder>* val) const
{
+ status_t status = readNullableStrongBinder(val);
+ if (status == OK && !val->get()) {
+ status = UNEXPECTED_NULL;
+ }
+ return status;
+}
+
+status_t Parcel::readNullableStrongBinder(sp<IBinder>* val) const
+{
return unflatten_binder(ProcessState::self(), *this, val);
}
sp<IBinder> Parcel::readStrongBinder() const
{
sp<IBinder> val;
- readStrongBinder(&val);
+ // Note that a lot of code in Android reads binders by hand with this
+ // method, and that code has historically been ok with getting nullptr
+ // back (while ignoring error codes).
+ readNullableStrongBinder(&val);
return val;
}
@@ -1994,7 +1996,7 @@ int Parcel::readFileDescriptor() const
return BAD_TYPE;
}
-status_t Parcel::readUniqueFileDescriptor(ScopedFd* val) const
+status_t Parcel::readUniqueFileDescriptor(base::unique_fd* val) const
{
int got = readFileDescriptor();
@@ -2012,11 +2014,11 @@ status_t Parcel::readUniqueFileDescriptor(ScopedFd* val) const
}
-status_t Parcel::readUniqueFileDescriptorVector(std::unique_ptr<std::vector<ScopedFd>>* val) const {
+status_t Parcel::readUniqueFileDescriptorVector(std::unique_ptr<std::vector<base::unique_fd>>* val) const {
return readNullableTypedVector(val, &Parcel::readUniqueFileDescriptor);
}
-status_t Parcel::readUniqueFileDescriptorVector(std::vector<ScopedFd>* val) const {
+status_t Parcel::readUniqueFileDescriptorVector(std::vector<base::unique_fd>* val) const {
return readTypedVector(val, &Parcel::readUniqueFileDescriptor);
}
diff --git a/libs/binder/PersistableBundle.cpp b/libs/binder/PersistableBundle.cpp
index aef791c37b..e7078baa82 100644
--- a/libs/binder/PersistableBundle.cpp
+++ b/libs/binder/PersistableBundle.cpp
@@ -32,6 +32,9 @@ using android::Parcel;
using android::sp;
using android::status_t;
using android::UNEXPECTED_NULL;
+using std::map;
+using std::set;
+using std::vector;
enum {
// Keep in sync with BUNDLE_MAGIC in frameworks/base/core/java/android/os/BaseBundle.java.
@@ -55,12 +58,22 @@ enum {
namespace {
template <typename T>
-bool getValue(const android::String16& key, T* out, const std::map<android::String16, T>& map) {
+bool getValue(const android::String16& key, T* out, const map<android::String16, T>& map) {
const auto& it = map.find(key);
if (it == map.end()) return false;
*out = it->second;
return true;
}
+
+template <typename T>
+set<android::String16> getKeys(const map<android::String16, T>& map) {
+ if (map.empty()) return set<android::String16>();
+ set<android::String16> keys;
+ for (const auto& key_value_pair : map) {
+ keys.emplace(key_value_pair.first);
+ }
+ return keys;
+}
} // namespace
namespace android {
@@ -78,7 +91,7 @@ namespace os {
#define RETURN_IF_ENTRY_ERASED(map, key) \
{ \
- size_t num_erased = map.erase(key); \
+ size_t num_erased = (map).erase(key); \
if (num_erased) { \
ALOGE("Failed at %s:%d (%s)", __FILE__, __LINE__, __func__); \
return num_erased; \
@@ -188,27 +201,27 @@ void PersistableBundle::putString(const String16& key, const String16& value) {
mStringMap[key] = value;
}
-void PersistableBundle::putBooleanVector(const String16& key, const std::vector<bool>& value) {
+void PersistableBundle::putBooleanVector(const String16& key, const vector<bool>& value) {
erase(key);
mBoolVectorMap[key] = value;
}
-void PersistableBundle::putIntVector(const String16& key, const std::vector<int32_t>& value) {
+void PersistableBundle::putIntVector(const String16& key, const vector<int32_t>& value) {
erase(key);
mIntVectorMap[key] = value;
}
-void PersistableBundle::putLongVector(const String16& key, const std::vector<int64_t>& value) {
+void PersistableBundle::putLongVector(const String16& key, const vector<int64_t>& value) {
erase(key);
mLongVectorMap[key] = value;
}
-void PersistableBundle::putDoubleVector(const String16& key, const std::vector<double>& value) {
+void PersistableBundle::putDoubleVector(const String16& key, const vector<double>& value) {
erase(key);
mDoubleVectorMap[key] = value;
}
-void PersistableBundle::putStringVector(const String16& key, const std::vector<String16>& value) {
+void PersistableBundle::putStringVector(const String16& key, const vector<String16>& value) {
erase(key);
mStringVectorMap[key] = value;
}
@@ -238,23 +251,23 @@ bool PersistableBundle::getString(const String16& key, String16* out) const {
return getValue(key, out, mStringMap);
}
-bool PersistableBundle::getBooleanVector(const String16& key, std::vector<bool>* out) const {
+bool PersistableBundle::getBooleanVector(const String16& key, vector<bool>* out) const {
return getValue(key, out, mBoolVectorMap);
}
-bool PersistableBundle::getIntVector(const String16& key, std::vector<int32_t>* out) const {
+bool PersistableBundle::getIntVector(const String16& key, vector<int32_t>* out) const {
return getValue(key, out, mIntVectorMap);
}
-bool PersistableBundle::getLongVector(const String16& key, std::vector<int64_t>* out) const {
+bool PersistableBundle::getLongVector(const String16& key, vector<int64_t>* out) const {
return getValue(key, out, mLongVectorMap);
}
-bool PersistableBundle::getDoubleVector(const String16& key, std::vector<double>* out) const {
+bool PersistableBundle::getDoubleVector(const String16& key, vector<double>* out) const {
return getValue(key, out, mDoubleVectorMap);
}
-bool PersistableBundle::getStringVector(const String16& key, std::vector<String16>* out) const {
+bool PersistableBundle::getStringVector(const String16& key, vector<String16>* out) const {
return getValue(key, out, mStringVectorMap);
}
@@ -262,6 +275,50 @@ bool PersistableBundle::getPersistableBundle(const String16& key, PersistableBun
return getValue(key, out, mPersistableBundleMap);
}
+set<String16> PersistableBundle::getBooleanKeys() const {
+ return getKeys(mBoolMap);
+}
+
+set<String16> PersistableBundle::getIntKeys() const {
+ return getKeys(mIntMap);
+}
+
+set<String16> PersistableBundle::getLongKeys() const {
+ return getKeys(mLongMap);
+}
+
+set<String16> PersistableBundle::getDoubleKeys() const {
+ return getKeys(mDoubleMap);
+}
+
+set<String16> PersistableBundle::getStringKeys() const {
+ return getKeys(mStringMap);
+}
+
+set<String16> PersistableBundle::getBooleanVectorKeys() const {
+ return getKeys(mBoolVectorMap);
+}
+
+set<String16> PersistableBundle::getIntVectorKeys() const {
+ return getKeys(mIntVectorMap);
+}
+
+set<String16> PersistableBundle::getLongVectorKeys() const {
+ return getKeys(mLongVectorMap);
+}
+
+set<String16> PersistableBundle::getDoubleVectorKeys() const {
+ return getKeys(mDoubleVectorMap);
+}
+
+set<String16> PersistableBundle::getStringVectorKeys() const {
+ return getKeys(mStringVectorMap);
+}
+
+set<String16> PersistableBundle::getPersistableBundleKeys() const {
+ return getKeys(mPersistableBundleMap);
+}
+
status_t PersistableBundle::writeToParcelInner(Parcel* parcel) const {
/*
* To keep this implementation in sync with writeArrayMapInternal() in
@@ -363,7 +420,6 @@ status_t PersistableBundle::readFromParcelInner(const Parcel* parcel, size_t len
RETURN_IF_FAILED(parcel->readInt32(&num_entries));
for (; num_entries > 0; --num_entries) {
- size_t start_pos = parcel->dataPosition();
String16 key;
int32_t value_type;
RETURN_IF_FAILED(parcel->readString16(&key));
diff --git a/libs/binder/ProcessState.cpp b/libs/binder/ProcessState.cpp
index f13f49fe93..d42bb82415 100644
--- a/libs/binder/ProcessState.cpp
+++ b/libs/binder/ProcessState.cpp
@@ -16,8 +16,6 @@
#define LOG_TAG "ProcessState"
-#include <cutils/process_name.h>
-
#include <binder/ProcessState.h>
#include <utils/Atomic.h>
@@ -52,7 +50,7 @@ namespace android {
class PoolThread : public Thread
{
public:
- PoolThread(bool isMain)
+ explicit PoolThread(bool isMain)
: mIsMain(isMain)
{
}
@@ -366,6 +364,13 @@ ProcessState::ProcessState()
ProcessState::~ProcessState()
{
+ if (mDriverFD >= 0) {
+ if (mVMStart != MAP_FAILED) {
+ munmap(mVMStart, BINDER_VM_SIZE);
+ }
+ close(mDriverFD);
+ }
+ mDriverFD = -1;
}
}; // namespace android
diff --git a/libs/binder/Static.cpp b/libs/binder/Static.cpp
index cd9509f707..f0613d1631 100644
--- a/libs/binder/Static.cpp
+++ b/libs/binder/Static.cpp
@@ -48,7 +48,7 @@ protected:
class FdTextOutput : public BufferedTextOutput
{
public:
- FdTextOutput(int fd) : BufferedTextOutput(MULTITHREADED), mFD(fd) { }
+ explicit FdTextOutput(int fd) : BufferedTextOutput(MULTITHREADED), mFD(fd) { }
virtual ~FdTextOutput() { };
protected:
diff --git a/libs/binder/Status.cpp b/libs/binder/Status.cpp
index d3520d62e9..8466863865 100644
--- a/libs/binder/Status.cpp
+++ b/libs/binder/Status.cpp
@@ -32,6 +32,11 @@ Status Status::fromExceptionCode(int32_t exceptionCode,
return Status(exceptionCode, OK, message);
}
+Status Status::fromExceptionCode(int32_t exceptionCode,
+ const char* message) {
+ return fromExceptionCode(exceptionCode, String8(message));
+}
+
Status Status::fromServiceSpecificError(int32_t serviceSpecificErrorCode) {
return Status(EX_SERVICE_SPECIFIC, serviceSpecificErrorCode);
}
@@ -41,6 +46,11 @@ Status Status::fromServiceSpecificError(int32_t serviceSpecificErrorCode,
return Status(EX_SERVICE_SPECIFIC, serviceSpecificErrorCode, message);
}
+Status Status::fromServiceSpecificError(int32_t serviceSpecificErrorCode,
+ const char* message) {
+ return fromServiceSpecificError(serviceSpecificErrorCode, String8(message));
+}
+
Status Status::fromStatusT(status_t status) {
Status ret;
ret.setFromStatusT(status);
@@ -158,5 +168,10 @@ String8 Status::toString8() const {
return ret;
}
+std::stringstream& operator<< (std::stringstream& stream, const Status& s) {
+ stream << s.toString8().string();
+ return stream;
+}
+
} // namespace binder
} // namespace android
diff --git a/libs/binder/TextOutput.cpp b/libs/binder/TextOutput.cpp
index 2ed51887b1..101eba318f 100644
--- a/libs/binder/TextOutput.cpp
+++ b/libs/binder/TextOutput.cpp
@@ -29,111 +29,14 @@ namespace android {
// ---------------------------------------------------------------------------
-TextOutput::TextOutput() {
+TextOutput::TextOutput() {
}
-TextOutput::~TextOutput() {
+TextOutput::~TextOutput() {
}
// ---------------------------------------------------------------------------
-TextOutput& operator<<(TextOutput& to, bool val)
-{
- if (val) to.print("true", 4);
- else to.print("false", 5);
- return to;
-}
-
-TextOutput& operator<<(TextOutput& to, int val)
-{
- char buf[16];
- sprintf(buf, "%d", val);
- to.print(buf, strlen(buf));
- return to;
-}
-
-TextOutput& operator<<(TextOutput& to, long val)
-{
- char buf[16];
- sprintf(buf, "%ld", val);
- to.print(buf, strlen(buf));
- return to;
-}
-
-TextOutput& operator<<(TextOutput& to, unsigned int val)
-{
- char buf[16];
- sprintf(buf, "%u", val);
- to.print(buf, strlen(buf));
- return to;
-}
-
-TextOutput& operator<<(TextOutput& to, unsigned long val)
-{
- char buf[16];
- sprintf(buf, "%lu", val);
- to.print(buf, strlen(buf));
- return to;
-}
-
-TextOutput& operator<<(TextOutput& to, long long val)
-{
- char buf[32];
- sprintf(buf, "%Ld", val);
- to.print(buf, strlen(buf));
- return to;
-}
-
-TextOutput& operator<<(TextOutput& to, unsigned long long val)
-{
- char buf[32];
- sprintf(buf, "%Lu", val);
- to.print(buf, strlen(buf));
- return to;
-}
-
-static TextOutput& print_float(TextOutput& to, double value)
-{
- char buf[64];
- sprintf(buf, "%g", value);
- if( !strchr(buf, '.') && !strchr(buf, 'e') &&
- !strchr(buf, 'E') ) {
- strncat(buf, ".0", sizeof(buf)-1);
- }
- to.print(buf, strlen(buf));
- return to;
-}
-
-TextOutput& operator<<(TextOutput& to, float val)
-{
- return print_float(to,val);
-}
-
-TextOutput& operator<<(TextOutput& to, double val)
-{
- return print_float(to,val);
-}
-
-TextOutput& operator<<(TextOutput& to, const void* val)
-{
- char buf[32];
- snprintf(buf, sizeof(buf), "%p", val);
- to.print(buf, strlen(buf));
- return to;
-}
-
-TextOutput& operator<<(TextOutput& to, const String8& val)
-{
- to << val.string();
- return to;
-}
-
-TextOutput& operator<<(TextOutput& to, const String16& val)
-{
- to << String8(val).string();
- return to;
-}
-
static void textOutputPrinter(void* cookie, const char* txt)
{
((TextOutput*)cookie)->print(txt, strlen(txt));
diff --git a/libs/binder/tests/Android.bp b/libs/binder/tests/Android.bp
new file mode 100644
index 0000000000..2152206a2a
--- /dev/null
+++ b/libs/binder/tests/Android.bp
@@ -0,0 +1,63 @@
+//
+// Copyright (C) 2014 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 {
+ product_variables: {
+ binder32bit: {
+ cflags: ["-DBINDER_IPC_32BIT=1"],
+ },
+ },
+
+ name: "binderDriverInterfaceTest",
+ srcs: ["binderDriverInterfaceTest.cpp"],
+}
+
+cc_test {
+ name: "binderLibTest",
+ srcs: ["binderLibTest.cpp"],
+ shared_libs: [
+ "libbinder",
+ "libutils",
+ ],
+}
+
+cc_test {
+ name: "binderThroughputTest",
+ srcs: ["binderThroughputTest.cpp"],
+ shared_libs: [
+ "libbinder",
+ "libutils",
+ ],
+ clang: true,
+ cflags: [
+ "-g",
+ "-Wall",
+ "-Werror",
+ "-Wno-missing-field-initializers",
+ "-Wno-sign-compare",
+ "-O3",
+ ],
+}
+
+cc_test {
+ name: "binderTextOutputTest",
+ srcs: ["binderTextOutputTest.cpp"],
+ shared_libs: [
+ "libbinder",
+ "libutils",
+ "libbase",
+ ],
+}
diff --git a/libs/binder/tests/Android.mk b/libs/binder/tests/Android.mk
deleted file mode 100644
index a40523d4b3..0000000000
--- a/libs/binder/tests/Android.mk
+++ /dev/null
@@ -1,42 +0,0 @@
-#
-# Copyright (C) 2014 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)
-
-include $(CLEAR_VARS)
-ifneq ($(TARGET_USES_64_BIT_BINDER),true)
-ifneq ($(TARGET_IS_64_BIT),true)
-LOCAL_CFLAGS += -DBINDER_IPC_32BIT=1
-endif
-endif
-
-LOCAL_MODULE := binderDriverInterfaceTest
-LOCAL_SRC_FILES := binderDriverInterfaceTest.cpp
-include $(BUILD_NATIVE_TEST)
-
-include $(CLEAR_VARS)
-LOCAL_MODULE := binderLibTest
-LOCAL_SRC_FILES := binderLibTest.cpp
-LOCAL_SHARED_LIBRARIES := libbinder libutils
-include $(BUILD_NATIVE_TEST)
-
-include $(CLEAR_VARS)
-LOCAL_MODULE := binderThroughputTest
-LOCAL_SRC_FILES := binderThroughputTest.cpp
-LOCAL_SHARED_LIBRARIES := libbinder libutils
-LOCAL_CLANG := true
-LOCAL_CFLAGS += -g -Wall -Werror -std=c++11 -Wno-missing-field-initializers -Wno-sign-compare -O3
-include $(BUILD_NATIVE_TEST)
diff --git a/libs/binder/tests/binderDriverInterfaceTest.cpp b/libs/binder/tests/binderDriverInterfaceTest.cpp
index 0277550258..ff5912fbe1 100644
--- a/libs/binder/tests/binderDriverInterfaceTest.cpp
+++ b/libs/binder/tests/binderDriverInterfaceTest.cpp
@@ -20,7 +20,7 @@
#include <stdlib.h>
#include <gtest/gtest.h>
-#include <linux/binder.h>
+#include <linux/android/binder.h>
#include <binder/IBinder.h>
#include <sys/mman.h>
#include <poll.h>
@@ -229,7 +229,9 @@ TEST_F(BinderDriverInterfaceTest, Transaction) {
.sender_euid = 0,
.data_size = 0,
.offsets_size = 0,
- .data = {0, 0},
+ .data = {
+ .ptr = {0, 0},
+ },
},
};
struct {
@@ -350,4 +352,3 @@ int main(int argc, char **argv) {
return RUN_ALL_TESTS();
}
-
diff --git a/libs/binder/tests/binderLibTest.cpp b/libs/binder/tests/binderLibTest.cpp
index 3df3acf9db..54e12b6f37 100644
--- a/libs/binder/tests/binderLibTest.cpp
+++ b/libs/binder/tests/binderLibTest.cpp
@@ -34,6 +34,7 @@ using namespace android;
static testing::Environment* binder_env;
static char *binderservername;
+static char *binderserversuffix;
static char binderserverarg[] = "--binderserver";
static String16 binderLibTestServiceName = String16("test.binderLib");
@@ -70,6 +71,7 @@ pid_t start_server_process(int arg2)
binderserverarg,
stri,
strpipefd1,
+ binderserversuffix,
NULL
};
@@ -252,14 +254,10 @@ class BinderLibTestEvent
int ret;
pthread_mutex_lock(&m_waitMutex);
if (!m_eventTriggered) {
-#if defined(HAVE_PTHREAD_COND_TIMEDWAIT_RELATIVE)
- pthread_cond_timeout_np(&m_waitCond, &m_waitMutex, timeout_s * 1000);
-#else
struct timespec ts;
clock_gettime(CLOCK_REALTIME, &ts);
ts.tv_sec += timeout_s;
pthread_cond_timedwait(&m_waitCond, &m_waitMutex, &ts);
-#endif
}
ret = m_eventTriggered ? NO_ERROR : TIMED_OUT;
pthread_mutex_unlock(&m_waitMutex);
@@ -739,14 +737,10 @@ class BinderLibTestService : public BBinder
}
if (ret > 0) {
if (m_serverStartRequested) {
-#if defined(HAVE_PTHREAD_COND_TIMEDWAIT_RELATIVE)
- ret = pthread_cond_timeout_np(&m_serverWaitCond, &m_serverWaitMutex, 5000);
-#else
struct timespec ts;
clock_gettime(CLOCK_REALTIME, &ts);
ts.tv_sec += 5;
ret = pthread_cond_timedwait(&m_serverWaitCond, &m_serverWaitMutex, &ts);
-#endif
}
if (m_serverStartRequested) {
m_serverStartRequested = false;
@@ -906,6 +900,8 @@ class BinderLibTestService : public BBinder
int run_server(int index, int readypipefd)
{
+ binderLibTestServiceName += String16(binderserversuffix);
+
status_t ret;
sp<IServiceManager> sm = defaultServiceManager();
{
@@ -936,15 +932,19 @@ int run_server(int index, int readypipefd)
int main(int argc, char **argv) {
int ret;
- if (argc == 3 && !strcmp(argv[1], "--servername")) {
+ if (argc == 4 && !strcmp(argv[1], "--servername")) {
binderservername = argv[2];
} else {
binderservername = argv[0];
}
- if (argc == 4 && !strcmp(argv[1], binderserverarg)) {
+ if (argc == 5 && !strcmp(argv[1], binderserverarg)) {
+ binderserversuffix = argv[4];
return run_server(atoi(argv[2]), atoi(argv[3]));
}
+ binderserversuffix = new char[16];
+ snprintf(binderserversuffix, 16, "%d", getpid());
+ binderLibTestServiceName += String16(binderserversuffix);
::testing::InitGoogleTest(&argc, argv);
binder_env = AddGlobalTestEnvironment(new BinderLibTestEnv());
diff --git a/libs/binder/tests/binderTextOutputTest.cpp b/libs/binder/tests/binderTextOutputTest.cpp
new file mode 100644
index 0000000000..f6dd22d798
--- /dev/null
+++ b/libs/binder/tests/binderTextOutputTest.cpp
@@ -0,0 +1,176 @@
+/*
+ * Copyright (C) 2016 The Android Open Source Project
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+#include <fcntl.h>
+#include <stdio.h>
+#include <stdlib.h>
+#include <limits>
+#include <cstddef>
+
+#include "android-base/file.h"
+#include "android-base/test_utils.h"
+#include <gtest/gtest.h>
+
+#include <binder/Parcel.h>
+#include <binder/TextOutput.h>
+#include <binder/Debug.h>
+
+static void CheckMessage(const CapturedStderr& cap,
+ const char* expected,
+ bool singleline) {
+ std::string output;
+ ASSERT_EQ(0, lseek(cap.fd(), 0, SEEK_SET));
+ android::base::ReadFdToString(cap.fd(), &output);
+ if (singleline)
+ output.erase(std::remove(output.begin(), output.end(), '\n'));
+ ASSERT_STREQ(output.c_str(), expected);
+}
+
+#define CHECK_LOG_(input, expect, singleline) \
+{ \
+ CapturedStderr cap; \
+ android::aerr << input << android::endl; \
+ CheckMessage(cap, expect, singleline); \
+} \
+
+#define CHECK_VAL_(val, singleline) \
+{ \
+ std::stringstream ss; \
+ ss << val; \
+ std::string s = ss.str(); \
+ CHECK_LOG_(val, s.c_str(), singleline); \
+} \
+
+#define CHECK_LOG(input, expect) CHECK_LOG_(input, expect, true)
+#define CHECK_VAL(val) CHECK_VAL_(val, true)
+
+TEST(TextOutput, HandlesStdEndl) {
+ CapturedStderr cap;
+ android::aerr << "foobar" << std::endl;
+ std::string output;
+ ASSERT_EQ(0, lseek(cap.fd(), 0, SEEK_SET));
+ android::base::ReadFdToString(cap.fd(), &output);
+ ASSERT_STREQ(output.c_str(), "foobar\n");
+}
+
+TEST(TextOutput, HandlesCEndl) {
+ CapturedStderr cap;
+ android::aerr << "foobar" << "\n";
+ std::string output;
+ ASSERT_EQ(0, lseek(cap.fd(), 0, SEEK_SET));
+ android::base::ReadFdToString(cap.fd(), &output);
+ ASSERT_STREQ(output.c_str(), "foobar\n");
+}
+
+TEST(TextOutput, HandlesAndroidEndl) {
+ CapturedStderr cap;
+ android::aerr << "foobar" << android::endl;
+ std::string output;
+ ASSERT_EQ(0, lseek(cap.fd(), 0, SEEK_SET));
+ android::base::ReadFdToString(cap.fd(), &output);
+ ASSERT_STREQ(output.c_str(), "foobar\n");
+}
+
+TEST(TextOutput, HandleEmptyString) {
+ CHECK_LOG("", "");
+}
+
+TEST(TextOutput, HandleString) {
+ CHECK_LOG("foobar", "foobar");
+}
+
+TEST(TextOutput, HandleNum) {
+ CHECK_LOG(12345, "12345");
+}
+
+TEST(TextOutput, HandleBool) {
+ CHECK_LOG(false, "false");
+}
+
+TEST(TextOutput, HandleChar) {
+ CHECK_LOG('T', "T");
+}
+
+TEST(TextOutput, HandleParcel) {
+ android::Parcel val;
+ CHECK_LOG(val, "Parcel(NULL)");
+}
+
+TEST(TextOutput, HandleHexDump) {
+ const char buf[16] = {0,1,2,3,4,5,6,7,8,9,10,11,12,13,14,15};
+ android::HexDump val(buf, sizeof(buf));
+ CHECK_LOG(val, "03020100 07060504 0b0a0908 0f0e0d0c '................'");
+}
+
+TEST(TextOutput, HandleHexDumpCustom) {
+ const char buf[4] = {0x11,0x22,0x33,0x44};
+ android::HexDump val(buf, sizeof(buf), 4);
+ CHECK_LOG(val, "11 22 33 44 '.\"3D'");
+}
+
+TEST(TextOutput, HandleTypeCode) {
+ android::TypeCode val(1234);
+ CHECK_LOG(val, "'\\x04\\xd2'");
+}
+
+TEST(TextOutput, HandleCookie) {
+ int32_t val = 321; //0x141
+ CHECK_LOG((void*)(long)val, "0x141");
+}
+
+TEST(TextOutput, HandleString8) {
+ android::String8 val("foobar");
+ CHECK_LOG(val, "foobar");
+}
+
+TEST(TextOutput, HandleString16) {
+ android::String16 val("foobar");
+ CHECK_LOG(val, "foobar");
+}
+
+template <typename T>
+class TextTest : public testing::Test {};
+
+typedef testing::Types<short, unsigned short,
+ int, unsigned int,
+ long, unsigned long,
+ long long, unsigned long long,
+ float, double, long double> TestTypes;
+TYPED_TEST_CASE(TextTest, TestTypes);
+
+TYPED_TEST(TextTest, TextMax)
+{
+ TypeParam max = std::numeric_limits<TypeParam>::max();
+ CHECK_VAL(max);
+}
+
+TYPED_TEST(TextTest, TestMin)
+{
+ TypeParam min = std::numeric_limits<TypeParam>::min();
+ CHECK_VAL(min);
+}
+
+TYPED_TEST(TextTest, TestDenom)
+{
+ TypeParam min = std::numeric_limits<TypeParam>::denorm_min();
+ CHECK_VAL(min);
+}
+
+TYPED_TEST(TextTest, TestEpsilon)
+{
+ TypeParam eps = std::numeric_limits<TypeParam>::epsilon();
+ CHECK_VAL(eps);
+}
diff --git a/libs/diskusage/Android.bp b/libs/diskusage/Android.bp
new file mode 100644
index 0000000000..156ddff2c6
--- /dev/null
+++ b/libs/diskusage/Android.bp
@@ -0,0 +1,18 @@
+// 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.
+
+cc_library_static {
+ name: "libdiskusage",
+ srcs: ["dirsize.c"],
+}
diff --git a/libs/diskusage/Android.mk b/libs/diskusage/Android.mk
deleted file mode 100644
index d54f8adf60..0000000000
--- a/libs/diskusage/Android.mk
+++ /dev/null
@@ -1,24 +0,0 @@
-# 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.
-
-LOCAL_PATH:= $(call my-dir)
-include $(CLEAR_VARS)
-
-LOCAL_MODULE := libdiskusage
-
-LOCAL_MODULE_TAGS := optional
-
-LOCAL_SRC_FILES := dirsize.c
-
-include $(BUILD_STATIC_LIBRARY) \ No newline at end of file
diff --git a/libs/gui/Android.bp b/libs/gui/Android.bp
new file mode 100644
index 0000000000..8e8bb802b3
--- /dev/null
+++ b/libs/gui/Android.bp
@@ -0,0 +1,111 @@
+// 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: "libgui",
+
+ 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",
+
+ // We don't need to enumerate every case in a switch as long as a default case
+ // is present
+ "-Wno-switch-enum",
+
+ // Allow calling variadic macros without a __VA_ARGS__ list
+ "-Wno-gnu-zero-variadic-macro-arguments",
+
+ // 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",
+
+ "-DDEBUG_ONLY_CODE=0",
+ ],
+
+ product_variables: {
+ brillo: {
+ cflags: ["-DHAVE_NO_SURFACE_FLINGER"],
+ },
+ debuggable: {
+ cppflags: [
+ "-UDEBUG_ONLY_CODE",
+ "-DDEBUG_ONLY_CODE=1",
+ ],
+ },
+ },
+
+ srcs: [
+ "IGraphicBufferConsumer.cpp",
+ "IConsumerListener.cpp",
+ "BitTube.cpp",
+ "BufferItem.cpp",
+ "BufferItemConsumer.cpp",
+ "BufferQueue.cpp",
+ "BufferQueueConsumer.cpp",
+ "BufferQueueCore.cpp",
+ "BufferQueueProducer.cpp",
+ "BufferSlot.cpp",
+ "ConsumerBase.cpp",
+ "CpuConsumer.cpp",
+ "DisplayEventReceiver.cpp",
+ "GLConsumer.cpp",
+ "GraphicBufferAlloc.cpp",
+ "GuiConfig.cpp",
+ "IDisplayEventConnection.cpp",
+ "IGraphicBufferAlloc.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",
+ "SurfaceComposerClient.cpp",
+ "SyncFeatures.cpp",
+ ],
+
+ shared_libs: [
+ "libbinder",
+ "libcutils",
+ "libEGL",
+ "libGLESv2",
+ "libsync",
+ "libui",
+ "libutils",
+ "liblog",
+ ],
+
+ export_shared_lib_headers: ["libbinder"],
+}
+
+subdirs = ["tests"]
diff --git a/libs/gui/Android.mk b/libs/gui/Android.mk
deleted file mode 100644
index 46feb1cc36..0000000000
--- a/libs/gui/Android.mk
+++ /dev/null
@@ -1,101 +0,0 @@
-# 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.
-
-LOCAL_PATH := $(call my-dir)
-include $(CLEAR_VARS)
-
-LOCAL_CLANG := true
-LOCAL_CPPFLAGS := -std=c++1y -Weverything -Werror
-
-# The static constructors and destructors in this library have not been noted to
-# introduce significant overheads
-LOCAL_CPPFLAGS += -Wno-exit-time-destructors
-LOCAL_CPPFLAGS += -Wno-global-constructors
-
-# We only care about compiling as C++14
-LOCAL_CPPFLAGS += -Wno-c++98-compat-pedantic
-
-# We don't need to enumerate every case in a switch as long as a default case
-# is present
-LOCAL_CPPFLAGS += -Wno-switch-enum
-
-# Allow calling variadic macros without a __VA_ARGS__ list
-LOCAL_CPPFLAGS += -Wno-gnu-zero-variadic-macro-arguments
-
-# Don't warn about struct padding
-LOCAL_CPPFLAGS += -Wno-padded
-
-LOCAL_CPPFLAGS += -DDEBUG_ONLY_CODE=$(if $(filter userdebug eng,$(TARGET_BUILD_VARIANT)),1,0)
-
-LOCAL_SRC_FILES := \
- IGraphicBufferConsumer.cpp \
- IConsumerListener.cpp \
- BitTube.cpp \
- BufferItem.cpp \
- BufferItemConsumer.cpp \
- BufferQueue.cpp \
- BufferQueueConsumer.cpp \
- BufferQueueCore.cpp \
- BufferQueueProducer.cpp \
- BufferSlot.cpp \
- ConsumerBase.cpp \
- CpuConsumer.cpp \
- DisplayEventReceiver.cpp \
- GLConsumer.cpp \
- GraphicBufferAlloc.cpp \
- GuiConfig.cpp \
- IDisplayEventConnection.cpp \
- IGraphicBufferAlloc.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 \
- SurfaceComposerClient.cpp \
- SyncFeatures.cpp \
-
-LOCAL_SHARED_LIBRARIES := \
- libbinder \
- libcutils \
- libEGL \
- libGLESv2 \
- libsync \
- libui \
- libutils \
- liblog
-
-
-LOCAL_MODULE := libgui
-
-ifeq ($(TARGET_BOARD_PLATFORM), tegra)
- LOCAL_CFLAGS += -DDONT_USE_FENCE_SYNC
-endif
-ifeq ($(TARGET_BOARD_PLATFORM), tegra3)
- LOCAL_CFLAGS += -DDONT_USE_FENCE_SYNC
-endif
-
-include $(BUILD_SHARED_LIBRARY)
-
-ifeq (,$(ONE_SHOT_MAKEFILE))
-include $(call first-makefiles-under,$(LOCAL_PATH))
-endif
diff --git a/libs/gui/BufferItem.cpp b/libs/gui/BufferItem.cpp
index 5e3924a7ee..1357a4aa1a 100644
--- a/libs/gui/BufferItem.cpp
+++ b/libs/gui/BufferItem.cpp
@@ -23,6 +23,21 @@
namespace android {
+template<typename T>
+static inline constexpr uint32_t low32(const T n) {
+ return static_cast<uint32_t>(static_cast<uint64_t>(n));
+}
+
+template<typename T>
+static inline constexpr uint32_t high32(const T n) {
+ return static_cast<uint32_t>(static_cast<uint64_t>(n)>>32);
+}
+
+template<typename T>
+static inline constexpr T to64(const uint32_t lo, const uint32_t hi) {
+ return static_cast<T>(static_cast<uint64_t>(hi)<<32 | lo);
+}
+
BufferItem::BufferItem() :
mGraphicBuffer(NULL),
mFence(NULL),
@@ -56,12 +71,12 @@ size_t BufferItem::getPodSize() const {
addAligned(size, mCrop);
addAligned(size, mTransform);
addAligned(size, mScalingMode);
- addAligned(size, mTimestampLo);
- addAligned(size, mTimestampHi);
+ addAligned(size, low32(mTimestamp));
+ addAligned(size, high32(mTimestamp));
addAligned(size, mIsAutoTimestamp);
addAligned(size, mDataSpace);
- addAligned(size, mFrameNumberLo);
- addAligned(size, mFrameNumberHi);
+ addAligned(size, low32(mFrameNumber));
+ addAligned(size, high32(mFrameNumber));
addAligned(size, mSlot);
addAligned(size, mIsDroppable);
addAligned(size, mAcquireCalled);
@@ -141,12 +156,12 @@ status_t BufferItem::flatten(
writeAligned(buffer, size, mCrop);
writeAligned(buffer, size, mTransform);
writeAligned(buffer, size, mScalingMode);
- writeAligned(buffer, size, mTimestampLo);
- writeAligned(buffer, size, mTimestampHi);
+ writeAligned(buffer, size, low32(mTimestamp));
+ writeAligned(buffer, size, high32(mTimestamp));
writeAligned(buffer, size, mIsAutoTimestamp);
writeAligned(buffer, size, mDataSpace);
- writeAligned(buffer, size, mFrameNumberLo);
- writeAligned(buffer, size, mFrameNumberHi);
+ writeAligned(buffer, size, low32(mFrameNumber));
+ writeAligned(buffer, size, high32(mFrameNumber));
writeAligned(buffer, size, mSlot);
writeAligned(buffer, size, mIsDroppable);
writeAligned(buffer, size, mAcquireCalled);
@@ -194,15 +209,20 @@ status_t BufferItem::unflatten(
return NO_MEMORY;
}
+ uint32_t timestampLo = 0, timestampHi = 0;
+ uint32_t frameNumberLo = 0, frameNumberHi = 0;
+
readAligned(buffer, size, mCrop);
readAligned(buffer, size, mTransform);
readAligned(buffer, size, mScalingMode);
- readAligned(buffer, size, mTimestampLo);
- readAligned(buffer, size, mTimestampHi);
+ readAligned(buffer, size, timestampLo);
+ readAligned(buffer, size, timestampHi);
+ mTimestamp = to64<int64_t>(timestampLo, timestampHi);
readAligned(buffer, size, mIsAutoTimestamp);
readAligned(buffer, size, mDataSpace);
- readAligned(buffer, size, mFrameNumberLo);
- readAligned(buffer, size, mFrameNumberHi);
+ readAligned(buffer, size, frameNumberLo);
+ readAligned(buffer, size, frameNumberHi);
+ mFrameNumber = to64<uint64_t>(frameNumberLo, frameNumberHi);
readAligned(buffer, size, mSlot);
readAligned(buffer, size, mIsDroppable);
readAligned(buffer, size, mAcquireCalled);
diff --git a/libs/gui/BufferQueueConsumer.cpp b/libs/gui/BufferQueueConsumer.cpp
index 73d2042983..ee4c58cfce 100644
--- a/libs/gui/BufferQueueConsumer.cpp
+++ b/libs/gui/BufferQueueConsumer.cpp
@@ -259,7 +259,8 @@ status_t BufferQueueConsumer::acquireBuffer(BufferItem* outBuffer,
// decrease.
mCore->mDequeueCondition.broadcast();
- ATRACE_INT(mCore->mConsumerName.string(), mCore->mQueue.size());
+ ATRACE_INT(mCore->mConsumerName.string(),
+ static_cast<int32_t>(mCore->mQueue.size()));
mCore->mOccupancyTracker.registerOccupancyChange(mCore->mQueue.size());
VALIDATE_CONSISTENCY();
@@ -732,7 +733,7 @@ status_t BufferQueueConsumer::discardFreeBuffers() {
return NO_ERROR;
}
-void BufferQueueConsumer::dump(String8& result, const char* prefix) const {
+void BufferQueueConsumer::dumpState(String8& result, const char* prefix) const {
const IPCThreadState* ipc = IPCThreadState::self();
const pid_t pid = ipc->getCallingPid();
const uid_t uid = ipc->getCallingUid();
@@ -741,9 +742,10 @@ void BufferQueueConsumer::dump(String8& result, const char* prefix) const {
"android.permission.DUMP"), pid, uid)) {
result.appendFormat("Permission Denial: can't dump BufferQueueConsumer "
"from pid=%d, uid=%d\n", pid, uid);
- android_errorWriteWithInfoLog(0x534e4554, "27046057", uid, NULL, 0);
+ android_errorWriteWithInfoLog(0x534e4554, "27046057",
+ static_cast<int32_t>(uid), NULL, 0);
} else {
- mCore->dump(result, prefix);
+ mCore->dumpState(result, prefix);
}
}
diff --git a/libs/gui/BufferQueueCore.cpp b/libs/gui/BufferQueueCore.cpp
index fd85c43b6d..d74d32c06d 100644
--- a/libs/gui/BufferQueueCore.cpp
+++ b/libs/gui/BufferQueueCore.cpp
@@ -28,8 +28,11 @@
#include <inttypes.h>
+#include <cutils/properties.h>
+
#include <gui/BufferItem.h>
#include <gui/BufferQueueCore.h>
+#include <gui/GraphicBufferAlloc.h>
#include <gui/IConsumerListener.h>
#include <gui/IGraphicBufferAlloc.h>
#include <gui/IProducerListener.h>
@@ -93,8 +96,24 @@ BufferQueueCore::BufferQueueCore(const sp<IGraphicBufferAlloc>& allocator) :
mUniqueId(getUniqueId())
{
if (allocator == NULL) {
- sp<ISurfaceComposer> composer(ComposerService::getComposerService());
- mAllocator = composer->createGraphicBufferAlloc();
+
+#ifdef HAVE_NO_SURFACE_FLINGER
+ // Without a SurfaceFlinger, allocate in-process. This only makes
+ // sense in systems with static SELinux configurations and no
+ // applications (since applications need dynamic SELinux policy).
+ mAllocator = new GraphicBufferAlloc();
+#else
+ // Run time check for headless, where we also allocate in-process.
+ char value[PROPERTY_VALUE_MAX];
+ property_get("config.headless", value, "0");
+ if (atoi(value) == 1) {
+ mAllocator = new GraphicBufferAlloc();
+ } else {
+ sp<ISurfaceComposer> composer(ComposerService::getComposerService());
+ mAllocator = composer->createGraphicBufferAlloc();
+ }
+#endif // HAVE_NO_SURFACE_FLINGER
+
if (mAllocator == NULL) {
BQ_LOGE("createGraphicBufferAlloc failed");
}
@@ -112,7 +131,7 @@ BufferQueueCore::BufferQueueCore(const sp<IGraphicBufferAlloc>& allocator) :
BufferQueueCore::~BufferQueueCore() {}
-void BufferQueueCore::dump(String8& result, const char* prefix) const {
+void BufferQueueCore::dumpState(String8& result, const char* prefix) const {
Mutex::Autolock lock(mMutex);
String8 fifo;
diff --git a/libs/gui/BufferQueueProducer.cpp b/libs/gui/BufferQueueProducer.cpp
index b2169c84c7..13b900c837 100644
--- a/libs/gui/BufferQueueProducer.cpp
+++ b/libs/gui/BufferQueueProducer.cpp
@@ -905,7 +905,8 @@ status_t BufferQueueProducer::queueBuffer(int slot,
static_cast<uint32_t>(mCore->mQueue.size()),
mCore->mFrameCounter + 1);
- ATRACE_INT(mCore->mConsumerName.string(), mCore->mQueue.size());
+ ATRACE_INT(mCore->mConsumerName.string(),
+ static_cast<int32_t>(mCore->mQueue.size()));
mCore->mOccupancyTracker.registerOccupancyChange(mCore->mQueue.size());
// Take a ticket for the callback functions
diff --git a/libs/gui/ConsumerBase.cpp b/libs/gui/ConsumerBase.cpp
index 65e4feefde..3cf3078345 100644
--- a/libs/gui/ConsumerBase.cpp
+++ b/libs/gui/ConsumerBase.cpp
@@ -254,11 +254,11 @@ status_t ConsumerBase::discardFreeBuffers() {
return mConsumer->discardFreeBuffers();
}
-void ConsumerBase::dump(String8& result) const {
- dump(result, "");
+void ConsumerBase::dumpState(String8& result) const {
+ dumpState(result, "");
}
-void ConsumerBase::dump(String8& result, const char* prefix) const {
+void ConsumerBase::dumpState(String8& result, const char* prefix) const {
Mutex::Autolock _l(mMutex);
dumpLocked(result, prefix);
}
@@ -267,7 +267,7 @@ void ConsumerBase::dumpLocked(String8& result, const char* prefix) const {
result.appendFormat("%smAbandoned=%d\n", prefix, int(mAbandoned));
if (!mAbandoned) {
- mConsumer->dump(result, prefix);
+ mConsumer->dumpState(result, prefix);
}
}
diff --git a/libs/gui/IConsumerListener.cpp b/libs/gui/IConsumerListener.cpp
index 9a06011ce0..ff7b83a7d6 100644
--- a/libs/gui/IConsumerListener.cpp
+++ b/libs/gui/IConsumerListener.cpp
@@ -37,7 +37,7 @@ enum {
class BpConsumerListener : public BpInterface<IConsumerListener>
{
public:
- BpConsumerListener(const sp<IBinder>& impl)
+ explicit BpConsumerListener(const sp<IBinder>& impl)
: BpInterface<IConsumerListener>(impl) {
}
@@ -153,6 +153,7 @@ status_t BnConsumerListener::onTransact(
return BBinder::onTransact(code, data, reply, flags);
}
+ConsumerListener::~ConsumerListener() = default;
// ---------------------------------------------------------------------------
}; // namespace android
diff --git a/libs/gui/IDisplayEventConnection.cpp b/libs/gui/IDisplayEventConnection.cpp
index 9890f44ef7..b1d3b00dbb 100644
--- a/libs/gui/IDisplayEventConnection.cpp
+++ b/libs/gui/IDisplayEventConnection.cpp
@@ -39,7 +39,7 @@ enum {
class BpDisplayEventConnection : public BpInterface<IDisplayEventConnection>
{
public:
- BpDisplayEventConnection(const sp<IBinder>& impl)
+ explicit BpDisplayEventConnection(const sp<IBinder>& impl)
: BpInterface<IDisplayEventConnection>(impl)
{
}
diff --git a/libs/gui/IGraphicBufferAlloc.cpp b/libs/gui/IGraphicBufferAlloc.cpp
index 7b3b7c1dc5..2fb380ccd1 100644
--- a/libs/gui/IGraphicBufferAlloc.cpp
+++ b/libs/gui/IGraphicBufferAlloc.cpp
@@ -37,7 +37,7 @@ enum {
class BpGraphicBufferAlloc : public BpInterface<IGraphicBufferAlloc>
{
public:
- BpGraphicBufferAlloc(const sp<IBinder>& impl)
+ explicit BpGraphicBufferAlloc(const sp<IBinder>& impl)
: BpInterface<IGraphicBufferAlloc>(impl)
{
}
@@ -96,7 +96,7 @@ status_t BnGraphicBufferAlloc::onTransact(
class BufferReference : public BBinder {
sp<GraphicBuffer> mBuffer;
public:
- BufferReference(const sp<GraphicBuffer>& buffer) : mBuffer(buffer) {}
+ explicit BufferReference(const sp<GraphicBuffer>& buffer) : mBuffer(buffer) {}
};
diff --git a/libs/gui/IGraphicBufferConsumer.cpp b/libs/gui/IGraphicBufferConsumer.cpp
index c8eff00e3f..240146455e 100644
--- a/libs/gui/IGraphicBufferConsumer.cpp
+++ b/libs/gui/IGraphicBufferConsumer.cpp
@@ -60,7 +60,7 @@ enum {
class BpGraphicBufferConsumer : public BpInterface<IGraphicBufferConsumer>
{
public:
- BpGraphicBufferConsumer(const sp<IBinder>& impl)
+ explicit BpGraphicBufferConsumer(const sp<IBinder>& impl)
: BpInterface<IGraphicBufferConsumer>(impl)
{
}
@@ -302,7 +302,7 @@ public:
return result;
}
- virtual void dump(String8& result, const char* prefix) const {
+ virtual void dumpState(String8& result, const char* prefix) const {
Parcel data, reply;
data.writeInterfaceToken(IGraphicBufferConsumer::getInterfaceDescriptor());
data.writeString8(result);
@@ -480,7 +480,7 @@ status_t BnGraphicBufferConsumer::onTransact(
CHECK_INTERFACE(IGraphicBufferConsumer, data, reply);
String8 result = data.readString8();
String8 prefix = data.readString8();
- static_cast<IGraphicBufferConsumer*>(this)->dump(result, prefix);
+ static_cast<IGraphicBufferConsumer*>(this)->dumpState(result, prefix);
reply->writeString8(result);
return NO_ERROR;
}
diff --git a/libs/gui/IGraphicBufferProducer.cpp b/libs/gui/IGraphicBufferProducer.cpp
index f4ba3bf15f..846c205c00 100644
--- a/libs/gui/IGraphicBufferProducer.cpp
+++ b/libs/gui/IGraphicBufferProducer.cpp
@@ -61,7 +61,7 @@ enum {
class BpGraphicBufferProducer : public BpInterface<IGraphicBufferProducer>
{
public:
- BpGraphicBufferProducer(const sp<IBinder>& impl)
+ explicit BpGraphicBufferProducer(const sp<IBinder>& impl)
: BpInterface<IGraphicBufferProducer>(impl)
{
}
diff --git a/libs/gui/IProducerListener.cpp b/libs/gui/IProducerListener.cpp
index da54ce1c2b..62abfa81c4 100644
--- a/libs/gui/IProducerListener.cpp
+++ b/libs/gui/IProducerListener.cpp
@@ -28,7 +28,7 @@ enum {
class BpProducerListener : public BpInterface<IProducerListener>
{
public:
- BpProducerListener(const sp<IBinder>& impl)
+ explicit BpProducerListener(const sp<IBinder>& impl)
: BpInterface<IProducerListener>(impl) {}
virtual ~BpProducerListener();
@@ -78,6 +78,10 @@ status_t BnProducerListener::onTransact(uint32_t code, const Parcel& data,
return BBinder::onTransact(code, data, reply, flags);
}
+ProducerListener::~ProducerListener() = default;
+
+DummyProducerListener::~DummyProducerListener() = default;
+
bool BnProducerListener::needsReleaseNotify() {
return true;
}
diff --git a/libs/gui/ISensorEventConnection.cpp b/libs/gui/ISensorEventConnection.cpp
index dc7a35cef9..59ecee7501 100644
--- a/libs/gui/ISensorEventConnection.cpp
+++ b/libs/gui/ISensorEventConnection.cpp
@@ -40,7 +40,7 @@ enum {
class BpSensorEventConnection : public BpInterface<ISensorEventConnection>
{
public:
- BpSensorEventConnection(const sp<IBinder>& impl)
+ explicit BpSensorEventConnection(const sp<IBinder>& impl)
: BpInterface<ISensorEventConnection>(impl)
{
}
diff --git a/libs/gui/ISensorServer.cpp b/libs/gui/ISensorServer.cpp
index 3a4c7e4edc..07c507a082 100644
--- a/libs/gui/ISensorServer.cpp
+++ b/libs/gui/ISensorServer.cpp
@@ -42,7 +42,7 @@ enum {
class BpSensorServer : public BpInterface<ISensorServer>
{
public:
- BpSensorServer(const sp<IBinder>& impl)
+ explicit BpSensorServer(const sp<IBinder>& impl)
: BpInterface<ISensorServer>(impl)
{
}
diff --git a/libs/gui/ISurfaceComposer.cpp b/libs/gui/ISurfaceComposer.cpp
index f0b0ada270..0a8e6a555e 100644
--- a/libs/gui/ISurfaceComposer.cpp
+++ b/libs/gui/ISurfaceComposer.cpp
@@ -49,7 +49,7 @@ class IDisplayEventConnection;
class BpSurfaceComposer : public BpInterface<ISurfaceComposer>
{
public:
- BpSurfaceComposer(const sp<IBinder>& impl)
+ explicit BpSurfaceComposer(const sp<IBinder>& impl)
: BpInterface<ISurfaceComposer>(impl)
{
}
diff --git a/libs/gui/ISurfaceComposerClient.cpp b/libs/gui/ISurfaceComposerClient.cpp
index dd5b169dba..47cb0473e8 100644
--- a/libs/gui/ISurfaceComposerClient.cpp
+++ b/libs/gui/ISurfaceComposerClient.cpp
@@ -48,7 +48,7 @@ enum {
class BpSurfaceComposerClient : public BpInterface<ISurfaceComposerClient>
{
public:
- BpSurfaceComposerClient(const sp<IBinder>& impl)
+ explicit BpSurfaceComposerClient(const sp<IBinder>& impl)
: BpInterface<ISurfaceComposerClient>(impl) {
}
diff --git a/libs/gui/SensorManager.cpp b/libs/gui/SensorManager.cpp
index 9fcf9ab2e3..57c3073bf4 100644
--- a/libs/gui/SensorManager.cpp
+++ b/libs/gui/SensorManager.cpp
@@ -139,7 +139,7 @@ status_t SensorManager::assertStateLocked() {
mSensorManager.sensorManagerDied();
}
public:
- DeathObserver(SensorManager& mgr) : mSensorManager(mgr) { }
+ explicit DeathObserver(SensorManager& mgr) : mSensorManager(mgr) { }
};
LOG_ALWAYS_FATAL_IF(mSensorServer.get() == NULL, "getService(SensorService) NULL");
diff --git a/libs/gui/Surface.cpp b/libs/gui/Surface.cpp
index 08382908ba..8e6ab1c73b 100644
--- a/libs/gui/Surface.cpp
+++ b/libs/gui/Surface.cpp
@@ -408,7 +408,7 @@ int Surface::queueBuffer(android_native_buffer_t* buffer, int fenceFd) {
timestamp = systemTime(SYSTEM_TIME_MONOTONIC);
isAutoTimestamp = true;
ALOGV("Surface::queueBuffer making up timestamp: %.2f ms",
- timestamp / 1000000.f);
+ timestamp / 1000000.0);
} else {
timestamp = mTimestamp;
}
diff --git a/libs/gui/SurfaceComposerClient.cpp b/libs/gui/SurfaceComposerClient.cpp
index b78de2ea59..43506e9191 100644
--- a/libs/gui/SurfaceComposerClient.cpp
+++ b/libs/gui/SurfaceComposerClient.cpp
@@ -69,7 +69,7 @@ void ComposerService::connectLocked() {
mComposerService.composerServiceDied();
}
public:
- DeathObserver(ComposerService& mgr) : mComposerService(mgr) { }
+ explicit DeathObserver(ComposerService& mgr) : mComposerService(mgr) { }
};
mDeathObserver = new DeathObserver(*const_cast<ComposerService*>(this));
diff --git a/libs/gui/tests/Android.bp b/libs/gui/tests/Android.bp
new file mode 100644
index 0000000000..3c7958fc85
--- /dev/null
+++ b/libs/gui/tests/Android.bp
@@ -0,0 +1,42 @@
+// Build the unit tests,
+
+// Build the binary to $(TARGET_OUT_DATA_NATIVE_TESTS)/$(LOCAL_MODULE)
+// to integrate with auto-test framework.
+cc_test {
+ name: "libgui_test",
+
+ clang: true,
+
+ srcs: [
+ "BufferQueue_test.cpp",
+ "CpuConsumer_test.cpp",
+ "FillBuffer.cpp",
+ "GLTest.cpp",
+ "IGraphicBufferProducer_test.cpp",
+ "MultiTextureConsumer_test.cpp",
+ "Sensor_test.cpp",
+ "SRGB_test.cpp",
+ "StreamSplitter_test.cpp",
+ "SurfaceTextureClient_test.cpp",
+ "SurfaceTextureFBO_test.cpp",
+ "SurfaceTextureGLThreadToGL_test.cpp",
+ "SurfaceTextureGLToGL_test.cpp",
+ "SurfaceTextureGL_test.cpp",
+ "SurfaceTextureMultiContextGL_test.cpp",
+ "Surface_test.cpp",
+ "TextureRenderer.cpp",
+ ],
+
+ shared_libs: [
+ "liblog",
+ "libEGL",
+ "libGLESv1_CM",
+ "libGLESv2",
+ "libbinder",
+ "libcutils",
+ "libgui",
+ "libsync",
+ "libui",
+ "libutils",
+ ],
+}
diff --git a/libs/gui/tests/Android.mk b/libs/gui/tests/Android.mk
deleted file mode 100644
index 6ad9986220..0000000000
--- a/libs/gui/tests/Android.mk
+++ /dev/null
@@ -1,52 +0,0 @@
-# Build the unit tests,
-LOCAL_PATH:= $(call my-dir)
-include $(CLEAR_VARS)
-LOCAL_ADDITIONAL_DEPENDENCIES := $(LOCAL_PATH)/Android.mk
-
-LOCAL_CLANG := true
-
-LOCAL_MODULE := libgui_test
-
-LOCAL_MODULE_TAGS := tests
-
-LOCAL_SRC_FILES := \
- BufferQueue_test.cpp \
- CpuConsumer_test.cpp \
- FillBuffer.cpp \
- GLTest.cpp \
- IGraphicBufferProducer_test.cpp \
- MultiTextureConsumer_test.cpp \
- SRGB_test.cpp \
- StreamSplitter_test.cpp \
- SurfaceTextureClient_test.cpp \
- SurfaceTextureFBO_test.cpp \
- SurfaceTextureGLThreadToGL_test.cpp \
- SurfaceTextureGLToGL_test.cpp \
- SurfaceTextureGL_test.cpp \
- SurfaceTextureMultiContextGL_test.cpp \
- Surface_test.cpp \
- TextureRenderer.cpp \
-
-LOCAL_SHARED_LIBRARIES := \
- libEGL \
- libGLESv1_CM \
- libGLESv2 \
- libbinder \
- libcutils \
- libgui \
- libsync \
- libui \
- libutils \
-
-# Build the binary to $(TARGET_OUT_DATA_NATIVE_TESTS)/$(LOCAL_MODULE)
-# to integrate with auto-test framework.
-include $(BUILD_NATIVE_TEST)
-
-# Include subdirectory makefiles
-# ============================================================
-
-# If we're building with ONE_SHOT_MAKEFILE (mm, mmm), then what the framework
-# team really wants is to build the stuff defined by this makefile.
-ifeq (,$(ONE_SHOT_MAKEFILE))
-include $(call first-makefiles-under,$(LOCAL_PATH))
-endif
diff --git a/libs/gui/tests/BufferQueue_test.cpp b/libs/gui/tests/BufferQueue_test.cpp
index 8a9eeeec21..65df7dc991 100644
--- a/libs/gui/tests/BufferQueue_test.cpp
+++ b/libs/gui/tests/BufferQueue_test.cpp
@@ -1044,7 +1044,7 @@ TEST_F(BufferQueueTest, TestDiscardFreeBuffers) {
// Check no free buffers in dump
String8 dumpString;
- mConsumer->dump(dumpString, nullptr);
+ mConsumer->dumpState(dumpString, nullptr);
// Parse the dump to ensure that all buffer slots that are FREE also
// have a null GraphicBuffer
diff --git a/libs/gui/tests/CpuConsumer_test.cpp b/libs/gui/tests/CpuConsumer_test.cpp
index 289cc74039..9c2e838b09 100644
--- a/libs/gui/tests/CpuConsumer_test.cpp
+++ b/libs/gui/tests/CpuConsumer_test.cpp
@@ -160,7 +160,7 @@ protected:
};
#define ASSERT_NO_ERROR(err, msg) \
- ASSERT_EQ(NO_ERROR, err) << msg << strerror(-err)
+ ASSERT_EQ(NO_ERROR, err) << (msg) << strerror(-(err))
void checkPixel(const CpuConsumer::LockedBuffer &buf,
uint32_t x, uint32_t y, uint32_t r, uint32_t g=0, uint32_t b=0) {
diff --git a/libs/gui/tests/Sensor_test.cpp b/libs/gui/tests/Sensor_test.cpp
new file mode 100644
index 0000000000..fbf282d1cf
--- /dev/null
+++ b/libs/gui/tests/Sensor_test.cpp
@@ -0,0 +1,88 @@
+/*
+ * Copyright (C) 2012 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.
+ */
+
+#define LOG_TAG "Sensor_test"
+
+#include <gui/Sensor.h>
+#include <hardware/sensors.h>
+#include <utils/Errors.h>
+
+#include <gtest/gtest.h>
+
+namespace android {
+
+// Returns true if the two sensors have the same attributes. Does not compare
+// UUID since that should not be transmitted via flatten/unflatten.
+static bool sensorsMatch(const Sensor& a, const Sensor& b) {
+ return a.getName() == b.getName () &&
+ a.getVendor() == b.getVendor () &&
+ a.getHandle() == b.getHandle () &&
+ a.getType() == b.getType () &&
+ a.getMinValue() == b.getMinValue () &&
+ a.getMaxValue() == b.getMaxValue () &&
+ a.getResolution() == b.getResolution () &&
+ a.getPowerUsage() == b.getPowerUsage () &&
+ a.getMinDelay() == b.getMinDelay () &&
+ a.getMinDelayNs() == b.getMinDelayNs () &&
+ a.getVersion() == b.getVersion () &&
+ a.getFifoReservedEventCount() == b.getFifoReservedEventCount () &&
+ a.getFifoMaxEventCount() == b.getFifoMaxEventCount () &&
+ a.getStringType() == b.getStringType () &&
+ a.getRequiredPermission() == b.getRequiredPermission () &&
+ a.isRequiredPermissionRuntime() == b.isRequiredPermissionRuntime () &&
+ a.getRequiredAppOp() == b.getRequiredAppOp () &&
+ a.getMaxDelay() == b.getMaxDelay () &&
+ a.getFlags() == b.getFlags () &&
+ a.isWakeUpSensor() == b.isWakeUpSensor () &&
+ a.isDynamicSensor() == b.isDynamicSensor () &&
+ a.hasAdditionalInfo() == b.hasAdditionalInfo () &&
+ a.getReportingMode() == b.getReportingMode();
+}
+
+// Creates and returns a sensor_t struct with some default values filled in.
+static sensor_t getTestSensorT() {
+ sensor_t hwSensor = {};
+ hwSensor.name = "Test Sensor";
+ hwSensor.vendor = "Test Vendor";
+ hwSensor.version = 1;
+ hwSensor.handle = 2;
+ hwSensor.type = SENSOR_TYPE_ACCELEROMETER;
+ hwSensor.maxRange = 10.f;
+ hwSensor.resolution = 1.f;
+ hwSensor.power = 5.f;
+ hwSensor.minDelay = 1000;
+ hwSensor.fifoReservedEventCount = 50;
+ hwSensor.fifoMaxEventCount = 100;
+ hwSensor.stringType = SENSOR_STRING_TYPE_ACCELEROMETER;
+ hwSensor.requiredPermission = "";
+ hwSensor.maxDelay = 5000;
+ hwSensor.flags = SENSOR_FLAG_CONTINUOUS_MODE;
+ return hwSensor;
+}
+
+TEST(SensorTest, FlattenAndUnflatten) {
+ sensor_t hwSensor = getTestSensorT();
+ Sensor sensor1(&hwSensor, SENSORS_DEVICE_API_VERSION_1_4);
+ Sensor sensor2;
+
+ std::vector<uint8_t> buffer(sensor1.getFlattenedSize());
+ ASSERT_EQ(OK, sensor1.flatten(buffer.data(), buffer.size()));
+ ASSERT_EQ(OK, sensor2.unflatten(buffer.data(), buffer.size()));
+
+ EXPECT_TRUE(sensorsMatch(sensor1, sensor2));
+}
+
+} // namespace android
diff --git a/libs/gui/tests/SurfaceTextureClient_test.cpp b/libs/gui/tests/SurfaceTextureClient_test.cpp
index a1578f671e..b10d4ebde7 100644
--- a/libs/gui/tests/SurfaceTextureClient_test.cpp
+++ b/libs/gui/tests/SurfaceTextureClient_test.cpp
@@ -535,7 +535,7 @@ TEST_F(SurfaceTextureClientTest, DISABLED_SurfaceTextureSyncModeWaitRetire) {
return false;
}
public:
- MyThread(const sp<GLConsumer>& mST)
+ explicit MyThread(const sp<GLConsumer>& mST)
: mST(mST), mBufferRetired(false) {
ctx = eglGetCurrentContext();
sur = eglGetCurrentSurface(EGL_DRAW);
diff --git a/libs/gui/tests/SurfaceTextureGL_test.cpp b/libs/gui/tests/SurfaceTextureGL_test.cpp
index 5311c5957e..308bd7d69c 100644
--- a/libs/gui/tests/SurfaceTextureGL_test.cpp
+++ b/libs/gui/tests/SurfaceTextureGL_test.cpp
@@ -437,7 +437,7 @@ TEST_F(SurfaceTextureGLTest, DisconnectStressTest) {
class ProducerThread : public Thread {
public:
- ProducerThread(const sp<ANativeWindow>& anw):
+ explicit ProducerThread(const sp<ANativeWindow>& anw):
mANW(anw) {
}
@@ -620,7 +620,7 @@ TEST_F(SurfaceTextureGLTest, CroppedScalingMode) {
TEST_F(SurfaceTextureGLTest, AbandonUnblocksDequeueBuffer) {
class ProducerThread : public Thread {
public:
- ProducerThread(const sp<ANativeWindow>& anw):
+ explicit ProducerThread(const sp<ANativeWindow>& anw):
mANW(anw),
mDequeueError(NO_ERROR) {
}
diff --git a/libs/input/Android.bp b/libs/input/Android.bp
new file mode 100644
index 0000000000..bd28af14fc
--- /dev/null
+++ b/libs/input/Android.bp
@@ -0,0 +1,62 @@
+// Copyright (C) 2013 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.
+
+// libinput is partially built for the host (used by build time keymap validation tool)
+
+cc_library {
+ name: "libinput",
+ host_supported: true,
+
+ srcs: [
+ "Input.cpp",
+ "InputDevice.cpp",
+ "Keyboard.cpp",
+ "KeyCharacterMap.cpp",
+ "KeyLayoutMap.cpp",
+ "VirtualKeyMap.cpp",
+ ],
+
+ clang: true,
+ sanitize: {
+ misc_undefined: ["integer"],
+ },
+
+ shared_libs: [
+ "liblog",
+ "libcutils",
+ ],
+
+ target: {
+ android: {
+ srcs: [
+ "IInputFlinger.cpp",
+ "InputTransport.cpp",
+ "VelocityControl.cpp",
+ "VelocityTracker.cpp",
+ ],
+
+ shared_libs: [
+ "libutils",
+ "libbinder",
+ ],
+ },
+ host: {
+ shared: {
+ enabled: false,
+ },
+ },
+ },
+}
+
+subdirs = ["tests"]
diff --git a/libs/input/Android.mk b/libs/input/Android.mk
deleted file mode 100644
index 746de66d62..0000000000
--- a/libs/input/Android.mk
+++ /dev/null
@@ -1,82 +0,0 @@
-# Copyright (C) 2013 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)
-
-# libinput is partially built for the host (used by build time keymap validation tool)
-# These files are common to host and target builds.
-
-commonSources := \
- Input.cpp \
- InputDevice.cpp \
- Keyboard.cpp \
- KeyCharacterMap.cpp \
- KeyLayoutMap.cpp \
- VirtualKeyMap.cpp
-
-deviceSources := \
- $(commonSources) \
- IInputFlinger.cpp \
- InputTransport.cpp \
- VelocityControl.cpp \
- VelocityTracker.cpp
-
-hostSources := \
- $(commonSources)
-
-# For the host
-# =====================================================
-
-include $(CLEAR_VARS)
-
-LOCAL_SRC_FILES:= $(hostSources)
-
-LOCAL_MODULE:= libinput
-
-LOCAL_MODULE_TAGS := optional
-
-include $(BUILD_HOST_STATIC_LIBRARY)
-
-
-# For the device
-# =====================================================
-
-include $(CLEAR_VARS)
-
-LOCAL_SRC_FILES:= $(deviceSources)
-
-LOCAL_CLANG := true
-LOCAL_SANITIZE := integer
-
-LOCAL_SHARED_LIBRARIES := \
- liblog \
- libcutils \
- libutils \
- libbinder
-
-LOCAL_MODULE:= libinput
-
-LOCAL_MODULE_TAGS := optional
-
-include $(BUILD_SHARED_LIBRARY)
-
-
-# Include subdirectory makefiles
-# ============================================================
-
-# If we're building with ONE_SHOT_MAKEFILE (mm, mmm), then what the framework
-# team really wants is to build the stuff defined by this makefile.
-ifeq (,$(ONE_SHOT_MAKEFILE))
-include $(call first-makefiles-under,$(LOCAL_PATH))
-endif
diff --git a/libs/input/IInputFlinger.cpp b/libs/input/IInputFlinger.cpp
index e00973149c..003e73dae6 100644
--- a/libs/input/IInputFlinger.cpp
+++ b/libs/input/IInputFlinger.cpp
@@ -28,7 +28,7 @@ namespace android {
class BpInputFlinger : public BpInterface<IInputFlinger> {
public:
- BpInputFlinger(const sp<IBinder>& impl) :
+ explicit BpInputFlinger(const sp<IBinder>& impl) :
BpInterface<IInputFlinger>(impl) { }
virtual status_t doSomething() {
diff --git a/libs/input/tests/Android.bp b/libs/input/tests/Android.bp
new file mode 100644
index 0000000000..029a42091e
--- /dev/null
+++ b/libs/input/tests/Android.bp
@@ -0,0 +1,28 @@
+// Build the unit tests.
+cc_test {
+ name: "libinput_tests",
+ test_per_src: true,
+ srcs: [
+ "InputChannel_test.cpp",
+ "InputEvent_test.cpp",
+ "InputPublisherAndConsumer_test.cpp",
+ ],
+ shared_libs: [
+ "libinput",
+ "libcutils",
+ "libutils",
+ "libbinder",
+ "libui",
+ ]
+}
+
+// NOTE: This is a compile time test, and does not need to be
+// run. All assertions are static_asserts and will fail during
+// buildtime if something's wrong.
+cc_library_static {
+ name: "StructLayout_test",
+ srcs: ["StructLayout_test.cpp"],
+ cflags: [
+ "-O0",
+ ],
+}
diff --git a/libs/input/tests/Android.mk b/libs/input/tests/Android.mk
deleted file mode 100644
index 5bfa3d4808..0000000000
--- a/libs/input/tests/Android.mk
+++ /dev/null
@@ -1,40 +0,0 @@
-# Build the unit tests.
-LOCAL_PATH:= $(call my-dir)
-
-# Build the unit tests.
-test_src_files := \
- InputChannel_test.cpp \
- InputEvent_test.cpp \
- InputPublisherAndConsumer_test.cpp
-
-shared_libraries := \
- libinput \
- libcutils \
- libutils \
- libbinder \
- libui \
-
-$(foreach file,$(test_src_files), \
- $(eval include $(CLEAR_VARS)) \
- $(eval LOCAL_ADDITIONAL_DEPENDENCIES := $(LOCAL_PATH)/Android.mk) \
- $(eval LOCAL_SHARED_LIBRARIES := $(shared_libraries)) \
- $(eval LOCAL_STATIC_LIBRARIES := $(static_libraries)) \
- $(eval LOCAL_SRC_FILES := $(file)) \
- $(eval LOCAL_MODULE := $(notdir $(file:%.cpp=%))) \
- $(eval include $(BUILD_NATIVE_TEST)) \
-)
-
-# NOTE: This is a compile time test, and does not need to be
-# run. All assertions are static_asserts and will fail during
-# buildtime if something's wrong.
-include $(CLEAR_VARS)
-LOCAL_ADDITIONAL_DEPENDENCIES := $(LOCAL_PATH)/Android.mk
-LOCAL_SRC_FILES := StructLayout_test.cpp
-LOCAL_MODULE := StructLayout_test
-LOCAL_CFLAGS := -std=c++11 -O0
-LOCAL_MULTILIB := both
-include $(BUILD_STATIC_LIBRARY)
-
-
-# Build the manual test programs.
-include $(call all-makefiles-under, $(LOCAL_PATH))
diff --git a/libs/input/tests/StructLayout_test.cpp b/libs/input/tests/StructLayout_test.cpp
index 8d73f453e0..81b99531c1 100644
--- a/libs/input/tests/StructLayout_test.cpp
+++ b/libs/input/tests/StructLayout_test.cpp
@@ -20,7 +20,7 @@
namespace android {
#define CHECK_OFFSET(type, member, expected_offset) \
- static_assert((offsetof(type, member) == expected_offset), "")
+ static_assert((offsetof(type, member) == (expected_offset)), "")
struct Foo {
uint32_t dummy;
diff --git a/libs/ui/Android.bp b/libs/ui/Android.bp
new file mode 100644
index 0000000000..d5ff75325b
--- /dev/null
+++ b/libs/ui/Android.bp
@@ -0,0 +1,68 @@
+// 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.
+
+cc_library_shared {
+ name: "libui",
+
+ 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",
+
+ // We use four-character constants for the GraphicBuffer header, and don't care
+ // that they're non-portable as long as they're consistent within one execution
+ "-Wno-four-char-constants",
+
+ // Don't warn about struct padding
+ "-Wno-padded",
+ ],
+
+ sanitize: {
+ //misc_undefined: ["integer"],
+ },
+
+ srcs: [
+ "Fence.cpp",
+ "FrameStats.cpp",
+ "Gralloc1.cpp",
+ "Gralloc1On0Adapter.cpp",
+ "GraphicBuffer.cpp",
+ "GraphicBufferAllocator.cpp",
+ "GraphicBufferMapper.cpp",
+ "HdrCapabilities.cpp",
+ "PixelFormat.cpp",
+ "Rect.cpp",
+ "Region.cpp",
+ "UiConfig.cpp",
+ ],
+
+ shared_libs: [
+ "libbinder",
+ "libcutils",
+ "libhardware",
+ "libsync",
+ "libutils",
+ "liblog",
+ ],
+}
+
+subdirs = ["tests"]
diff --git a/libs/ui/Android.mk b/libs/ui/Android.mk
deleted file mode 100644
index e690ede195..0000000000
--- a/libs/ui/Android.mk
+++ /dev/null
@@ -1,75 +0,0 @@
-# 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.
-
-LOCAL_PATH := $(call my-dir)
-include $(CLEAR_VARS)
-
-LOCAL_CLANG := true
-LOCAL_CPPFLAGS := -std=c++1y -Weverything -Werror
-# LOCAL_SANITIZE := integer
-
-# The static constructors and destructors in this library have not been noted to
-# introduce significant overheads
-LOCAL_CPPFLAGS += -Wno-exit-time-destructors
-LOCAL_CPPFLAGS += -Wno-global-constructors
-
-# We only care about compiling as C++14
-LOCAL_CPPFLAGS += -Wno-c++98-compat-pedantic
-
-# We use four-character constants for the GraphicBuffer header, and don't care
-# that they're non-portable as long as they're consistent within one execution
-LOCAL_CPPFLAGS += -Wno-four-char-constants
-
-# Don't warn about struct padding
-LOCAL_CPPFLAGS += -Wno-padded
-
-LOCAL_SRC_FILES := \
- Fence.cpp \
- FrameStats.cpp \
- Gralloc1.cpp \
- Gralloc1On0Adapter.cpp \
- GraphicBuffer.cpp \
- GraphicBufferAllocator.cpp \
- GraphicBufferMapper.cpp \
- HdrCapabilities.cpp \
- PixelFormat.cpp \
- Rect.cpp \
- Region.cpp \
- UiConfig.cpp
-
-LOCAL_SHARED_LIBRARIES := \
- libbinder \
- libcutils \
- libhardware \
- libsync \
- libutils \
- liblog
-
-ifneq ($(BOARD_FRAMEBUFFER_FORCE_FORMAT),)
-LOCAL_CFLAGS += -DFRAMEBUFFER_FORCE_FORMAT=$(BOARD_FRAMEBUFFER_FORCE_FORMAT)
-endif
-
-LOCAL_MODULE := libui
-
-include $(BUILD_SHARED_LIBRARY)
-
-
-# Include subdirectory makefiles
-# ============================================================
-
-# If we're building with ONE_SHOT_MAKEFILE (mm, mmm), then what the framework
-# team really wants is to build the stuff defined by this makefile.
-ifeq (,$(ONE_SHOT_MAKEFILE))
-include $(call first-makefiles-under,$(LOCAL_PATH))
-endif
diff --git a/libs/ui/Region.cpp b/libs/ui/Region.cpp
index ee152bf91c..b53c563624 100644
--- a/libs/ui/Region.cpp
+++ b/libs/ui/Region.cpp
@@ -294,7 +294,7 @@ Region& Region::andSelf(const Rect& r) {
Region& Region::subtractSelf(const Rect& r) {
return operationSelf(r, op_nand);
}
-Region& Region::operationSelf(const Rect& r, int op) {
+Region& Region::operationSelf(const Rect& r, uint32_t op) {
Region lhs(*this);
boolean_operation(op, *this, lhs, r);
return *this;
@@ -314,7 +314,7 @@ Region& Region::andSelf(const Region& rhs) {
Region& Region::subtractSelf(const Region& rhs) {
return operationSelf(rhs, op_nand);
}
-Region& Region::operationSelf(const Region& rhs, int op) {
+Region& Region::operationSelf(const Region& rhs, uint32_t op) {
Region lhs(*this);
boolean_operation(op, *this, lhs, rhs);
return *this;
@@ -339,7 +339,7 @@ const Region Region::intersect(const Rect& rhs) const {
const Region Region::subtract(const Rect& rhs) const {
return operation(rhs, op_nand);
}
-const Region Region::operation(const Rect& rhs, int op) const {
+const Region Region::operation(const Rect& rhs, uint32_t op) const {
Region result;
boolean_operation(op, result, *this, rhs);
return result;
@@ -359,7 +359,7 @@ const Region Region::intersect(const Region& rhs) const {
const Region Region::subtract(const Region& rhs) const {
return operation(rhs, op_nand);
}
-const Region Region::operation(const Region& rhs, int op) const {
+const Region Region::operation(const Region& rhs, uint32_t op) const {
Region result;
boolean_operation(op, result, *this, rhs);
return result;
@@ -385,7 +385,7 @@ Region& Region::andSelf(const Region& rhs, int dx, int dy) {
Region& Region::subtractSelf(const Region& rhs, int dx, int dy) {
return operationSelf(rhs, dx, dy, op_nand);
}
-Region& Region::operationSelf(const Region& rhs, int dx, int dy, int op) {
+Region& Region::operationSelf(const Region& rhs, int dx, int dy, uint32_t op) {
Region lhs(*this);
boolean_operation(op, *this, lhs, rhs, dx, dy);
return *this;
@@ -405,7 +405,7 @@ const Region Region::intersect(const Region& rhs, int dx, int dy) const {
const Region Region::subtract(const Region& rhs, int dx, int dy) const {
return operation(rhs, dx, dy, op_nand);
}
-const Region Region::operation(const Region& rhs, int dx, int dy, int op) const {
+const Region Region::operation(const Region& rhs, int dx, int dy, uint32_t op) const {
Region result;
boolean_operation(op, result, *this, rhs, dx, dy);
return result;
@@ -424,7 +424,7 @@ class Region::rasterizer : public region_operator<Rect>::region_rasterizer
Vector<Rect> span;
Rect* cur;
public:
- rasterizer(Region& reg)
+ explicit rasterizer(Region& reg)
: bounds(INT_MAX, 0, INT_MIN, 0), storage(reg.mStorage), head(), tail(), cur() {
storage.clear();
}
@@ -489,7 +489,8 @@ void Region::rasterizer::flushSpan()
merge = false;
break;
}
- p++, q++;
+ p++;
+ q++;
}
}
}
@@ -582,7 +583,7 @@ bool Region::validate(const Region& reg, const char* name, bool silent)
return result;
}
-void Region::boolean_operation(int op, Region& dst,
+void Region::boolean_operation(uint32_t op, Region& dst,
const Region& lhs,
const Region& rhs, int dx, int dy)
{
@@ -692,7 +693,7 @@ void Region::boolean_operation(int op, Region& dst,
#endif
}
-void Region::boolean_operation(int op, Region& dst,
+void Region::boolean_operation(uint32_t op, Region& dst,
const Region& lhs,
const Rect& rhs, int dx, int dy)
{
@@ -721,13 +722,13 @@ void Region::boolean_operation(int op, Region& dst,
#endif
}
-void Region::boolean_operation(int op, Region& dst,
+void Region::boolean_operation(uint32_t op, Region& dst,
const Region& lhs, const Region& rhs)
{
boolean_operation(op, dst, lhs, rhs, 0, 0);
}
-void Region::boolean_operation(int op, Region& dst,
+void Region::boolean_operation(uint32_t op, Region& dst,
const Region& lhs, const Rect& rhs)
{
boolean_operation(op, dst, lhs, rhs, 0, 0);
diff --git a/libs/ui/UiConfig.cpp b/libs/ui/UiConfig.cpp
index 9e7ba8e886..7730690cfd 100644
--- a/libs/ui/UiConfig.cpp
+++ b/libs/ui/UiConfig.cpp
@@ -18,20 +18,10 @@
namespace android {
-#ifdef FRAMEBUFFER_FORCE_FORMAT
-// We need the two-level macro to stringify the contents of a macro argument
-#define STRINGIFY(x) #x
-#define TOSTRING(x) STRINGIFY(x)
-#endif
-
void appendUiConfigString(String8& configStr)
{
static const char* config =
- " [libui"
-#ifdef FRAMEBUFFER_FORCE_FORMAT
- " FRAMEBUFFER_FORCE_FORMAT=" TOSTRING(FRAMEBUFFER_FORCE_FORMAT)
-#endif
- "]";
+ " [libui]";
configStr.append(config);
}
diff --git a/libs/ui/tests/Android.bp b/libs/ui/tests/Android.bp
new file mode 100644
index 0000000000..8cdab8ccf8
--- /dev/null
+++ b/libs/ui/tests/Android.bp
@@ -0,0 +1,31 @@
+//
+// Copyright (C) 2014 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: "Region_test",
+ shared_libs: ["libui"],
+ srcs: ["Region_test.cpp"],
+}
+
+cc_test {
+ name: "vec_test",
+ srcs: ["vec_test.cpp"],
+}
+
+cc_test {
+ name: "mat_test",
+ srcs: ["mat_test.cpp"],
+}
diff --git a/libs/ui/tests/Android.mk b/libs/ui/tests/Android.mk
deleted file mode 100644
index 6438b1f9a4..0000000000
--- a/libs/ui/tests/Android.mk
+++ /dev/null
@@ -1,36 +0,0 @@
-#
-# Copyright (C) 2014 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)
-
-include $(CLEAR_VARS)
-LOCAL_ADDITIONAL_DEPENDENCIES := $(LOCAL_PATH)/Android.mk
-LOCAL_SHARED_LIBRARIES := libui
-LOCAL_SRC_FILES := Region_test.cpp
-LOCAL_MODULE := Region_test
-include $(BUILD_NATIVE_TEST)
-
-include $(CLEAR_VARS)
-LOCAL_ADDITIONAL_DEPENDENCIES := $(LOCAL_PATH)/Android.mk
-LOCAL_SRC_FILES := vec_test.cpp
-LOCAL_MODULE := vec_test
-include $(BUILD_NATIVE_TEST)
-
-include $(CLEAR_VARS)
-LOCAL_ADDITIONAL_DEPENDENCIES := $(LOCAL_PATH)/Android.mk
-LOCAL_SRC_FILES := mat_test.cpp
-LOCAL_MODULE := mat_test
-include $(BUILD_NATIVE_TEST)