Merge "Use -Werror in frameworks/native/services/inputflinger"
diff --git a/cmds/dumpstate/DumpstateInternal.cpp b/cmds/dumpstate/DumpstateInternal.cpp
index 0343277..0b42647 100644
--- a/cmds/dumpstate/DumpstateInternal.cpp
+++ b/cmds/dumpstate/DumpstateInternal.cpp
@@ -18,6 +18,7 @@
#include "DumpstateInternal.h"
+#include <errno.h>
#include <stdint.h>
#include <stdio.h>
#include <string.h>
diff --git a/cmds/dumpstate/utils.cpp b/cmds/dumpstate/utils.cpp
index 91deb36..bd0e110 100644
--- a/cmds/dumpstate/utils.cpp
+++ b/cmds/dumpstate/utils.cpp
@@ -96,8 +96,9 @@
"android.hardware.bluetooth@1.0::IBluetoothHci",
"android.hardware.camera.provider@2.4::ICameraProvider",
"android.hardware.graphics.composer@2.1::IComposer",
- "android.hardware.vr@1.0::IVr",
"android.hardware.media.omx@1.0::IOmx",
+ "android.hardware.sensors@1.0::ISensors",
+ "android.hardware.vr@1.0::IVr",
NULL,
};
diff --git a/cmds/installd/InstalldNativeService.cpp b/cmds/installd/InstalldNativeService.cpp
index 60c89a9..bac83a4 100644
--- a/cmds/installd/InstalldNativeService.cpp
+++ b/cmds/installd/InstalldNativeService.cpp
@@ -519,6 +519,9 @@
if (access(path.c_str(), F_OK) == 0) {
if (delete_dir_contents(path) != 0) {
res = error("Failed to delete contents of " + path);
+ } else if ((flags & (FLAG_CLEAR_CACHE_ONLY | FLAG_CLEAR_CODE_CACHE_ONLY)) == 0) {
+ remove_path_xattr(path, kXattrInodeCache);
+ remove_path_xattr(path, kXattrInodeCodeCache);
}
}
}
diff --git a/cmds/installd/utils.cpp b/cmds/installd/utils.cpp
index 7c05417..8a0e137 100644
--- a/cmds/installd/utils.cpp
+++ b/cmds/installd/utils.cpp
@@ -733,6 +733,12 @@
}
}
+void remove_path_xattr(const std::string& path, const char* inode_xattr) {
+ if (removexattr(path.c_str(), inode_xattr) && errno != ENODATA) {
+ PLOG(ERROR) << "Failed to remove xattr " << inode_xattr << " at " << path;
+ }
+}
+
/**
* Validate that the path is valid in the context of the provided directory.
* The path is allowed to have at most one subdirectory and no indirections
diff --git a/cmds/installd/utils.h b/cmds/installd/utils.h
index 070da84..ac6a488 100644
--- a/cmds/installd/utils.h
+++ b/cmds/installd/utils.h
@@ -120,6 +120,7 @@
int write_path_inode(const std::string& parent, const char* name, const char* inode_xattr);
std::string read_path_inode(const std::string& parent, const char* name, const char* inode_xattr);
+void remove_path_xattr(const std::string& path, const char* inode_xattr);
int validate_system_app_path(const char* path);
bool validate_secondary_dex_path(const std::string& pkgname, const std::string& dex_path,
diff --git a/libs/binder/MemoryDealer.cpp b/libs/binder/MemoryDealer.cpp
index 2a15773..1cfe02a 100644
--- a/libs/binder/MemoryDealer.cpp
+++ b/libs/binder/MemoryDealer.cpp
@@ -289,7 +289,15 @@
SimpleBestFitAllocator::~SimpleBestFitAllocator()
{
while(!mList.isEmpty()) {
- delete mList.remove(mList.head());
+ chunk_t* removed = mList.remove(mList.head());
+#ifdef __clang_analyzer__
+ // Clang static analyzer gets confused in this loop
+ // and generates a false positive warning about accessing
+ // memory that is already freed.
+ // Add an "assert" to avoid the confusion.
+ LOG_ALWAYS_FATAL_IF(mList.head() == removed);
+#endif
+ delete removed;
}
}
diff --git a/libs/diskusage/Android.bp b/libs/diskusage/Android.bp
index 156ddff..a826306 100644
--- a/libs/diskusage/Android.bp
+++ b/libs/diskusage/Android.bp
@@ -15,4 +15,5 @@
cc_library_static {
name: "libdiskusage",
srcs: ["dirsize.c"],
+ cflags: ["-Wall", "-Werror"],
}
diff --git a/libs/graphicsenv/Android.bp b/libs/graphicsenv/Android.bp
index f2686d5..9f99538 100644
--- a/libs/graphicsenv/Android.bp
+++ b/libs/graphicsenv/Android.bp
@@ -19,6 +19,8 @@
"GraphicsEnv.cpp",
],
+ cflags: ["-Wall", "-Werror"],
+
shared_libs: [
"libnativeloader",
"liblog",
diff --git a/libs/gui/ConsumerBase.cpp b/libs/gui/ConsumerBase.cpp
index c2b10a9..54d4eab 100644
--- a/libs/gui/ConsumerBase.cpp
+++ b/libs/gui/ConsumerBase.cpp
@@ -335,16 +335,25 @@
return OK;
}
- auto status = mSlots[slot].mFence->getStatus();
-
- if (status == Fence::Status::Invalid) {
- CB_LOGE("fence has invalid state");
+ // Check status of fences first because merging is expensive.
+ // Merging an invalid fence with any other fence results in an
+ // invalid fence.
+ auto currentStatus = mSlots[slot].mFence->getStatus();
+ if (currentStatus == Fence::Status::Invalid) {
+ CB_LOGE("Existing fence has invalid state");
return BAD_VALUE;
}
- if (status == Fence::Status::Signaled) {
+ auto incomingStatus = fence->getStatus();
+ if (incomingStatus == Fence::Status::Invalid) {
+ CB_LOGE("New fence has invalid state");
mSlots[slot].mFence = fence;
- } else { // status == Fence::Status::Unsignaled
+ return BAD_VALUE;
+ }
+
+ // If both fences are signaled or both are unsignaled, we need to merge
+ // them to get an accurate timestamp.
+ if (currentStatus == incomingStatus) {
char fenceName[32] = {};
snprintf(fenceName, 32, "%.28s:%d", mName.string(), slot);
sp<Fence> mergedFence = Fence::merge(
@@ -357,7 +366,17 @@
return BAD_VALUE;
}
mSlots[slot].mFence = mergedFence;
+ } else if (incomingStatus == Fence::Status::Unsignaled) {
+ // If one fence has signaled and the other hasn't, the unsignaled
+ // fence will approximately correspond with the correct timestamp.
+ // There's a small race if both fences signal at about the same time
+ // and their statuses are retrieved with unfortunate timing. However,
+ // by this point, they will have both signaled and only the timestamp
+ // will be slightly off; any dependencies after this point will
+ // already have been met.
+ mSlots[slot].mFence = fence;
}
+ // else if (currentStatus == Fence::Status::Unsignaled) is a no-op.
return OK;
}
diff --git a/libs/hwc2on1adapter/Android.bp b/libs/hwc2on1adapter/Android.bp
index ec9cbf8..420a1f6 100644
--- a/libs/hwc2on1adapter/Android.bp
+++ b/libs/hwc2on1adapter/Android.bp
@@ -17,9 +17,13 @@
vendor: true,
clang: true,
+ cflags: [
+ "-Wall",
+ "-Werror",
+ "-Wno-user-defined-warnings",
+ ],
cppflags: [
"-Weverything",
- "-Wall",
"-Wunused",
"-Wunreachable-code",
diff --git a/libs/input/tests/Android.bp b/libs/input/tests/Android.bp
index 029a420..0028655 100644
--- a/libs/input/tests/Android.bp
+++ b/libs/input/tests/Android.bp
@@ -7,6 +7,12 @@
"InputEvent_test.cpp",
"InputPublisherAndConsumer_test.cpp",
],
+ cflags: [
+ "-Wall",
+ "-Werror",
+ "-Wno-error=sign-compare", // to fix later
+ "-Wno-unused-variable",
+ ],
shared_libs: [
"libinput",
"libcutils",
@@ -24,5 +30,7 @@
srcs: ["StructLayout_test.cpp"],
cflags: [
"-O0",
+ "-Wall",
+ "-Werror",
],
}
diff --git a/libs/math/tests/Android.bp b/libs/math/tests/Android.bp
index 0ed24a2..0184f56 100644
--- a/libs/math/tests/Android.bp
+++ b/libs/math/tests/Android.bp
@@ -18,22 +18,26 @@
name: "vec_test",
srcs: ["vec_test.cpp"],
static_libs: ["libmath"],
+ cflags: ["-Wall", "-Werror"],
}
cc_test {
name: "mat_test",
srcs: ["mat_test.cpp"],
static_libs: ["libmath"],
+ cflags: ["-Wall", "-Werror"],
}
cc_test {
name: "half_test",
srcs: ["half_test.cpp"],
static_libs: ["libmath"],
+ cflags: ["-Wall", "-Werror"],
}
cc_test {
name: "quat_test",
srcs: ["quat_test.cpp"],
static_libs: ["libmath"],
+ cflags: ["-Wall", "-Werror"],
}
diff --git a/libs/sensor/Android.bp b/libs/sensor/Android.bp
index 171a627..940ff5a 100644
--- a/libs/sensor/Android.bp
+++ b/libs/sensor/Android.bp
@@ -16,9 +16,12 @@
name: "libsensor",
clang: true,
+ cflags: [
+ "-Wall",
+ "-Werror",
+ ],
cppflags: [
"-Weverything",
- "-Werror",
// The static constructors and destructors in this library have not been noted to
// introduce significant overheads
diff --git a/libs/sensor/tests/Android.bp b/libs/sensor/tests/Android.bp
index 9d530fc..9fd84bc 100644
--- a/libs/sensor/tests/Android.bp
+++ b/libs/sensor/tests/Android.bp
@@ -17,6 +17,8 @@
clang: true,
+ cflags: ["-Wall", "-Werror"],
+
srcs: [
"Sensor_test.cpp",
],
diff --git a/libs/vr/libbufferhub/Android.bp b/libs/vr/libbufferhub/Android.bp
index 452bad0..17725f8 100644
--- a/libs/vr/libbufferhub/Android.bp
+++ b/libs/vr/libbufferhub/Android.bp
@@ -40,7 +40,8 @@
srcs: sourceFiles,
cflags: [
"-DLOG_TAG=\"libbufferhub\"",
- "-DTRACE=0"
+ "-DTRACE=0",
+ "-DATRACE_TAG=ATRACE_TAG_GRAPHICS",
],
export_include_dirs: localIncludeFiles,
static_libs: staticLibraries,
diff --git a/libs/vr/libbufferhubqueue/Android.bp b/libs/vr/libbufferhubqueue/Android.bp
index a587f95..a7c33ee 100644
--- a/libs/vr/libbufferhubqueue/Android.bp
+++ b/libs/vr/libbufferhubqueue/Android.bp
@@ -47,6 +47,7 @@
cflags: [
"-DLOG_TAG=\"libbufferhubqueue\"",
"-DTRACE=0",
+ "-DATRACE_TAG=ATRACE_TAG_GRAPHICS",
],
srcs: sourceFiles,
export_include_dirs: includeFiles,
diff --git a/libs/vr/libdvr/Android.bp b/libs/vr/libdvr/Android.bp
index fa78b1c..7a7c8aa 100644
--- a/libs/vr/libdvr/Android.bp
+++ b/libs/vr/libdvr/Android.bp
@@ -21,6 +21,7 @@
cflags = [
"-DLOG_TAG=\"libdvr\"",
+ "-DTRACE=0",
]
srcs = [
diff --git a/opengl/libs/EGL/BlobCache.cpp b/opengl/libs/EGL/BlobCache.cpp
index f1b30c7..0624b60 100644
--- a/opengl/libs/EGL/BlobCache.cpp
+++ b/opengl/libs/EGL/BlobCache.cpp
@@ -18,6 +18,7 @@
#include "BlobCache.h"
+#include <errno.h>
#include <inttypes.h>
#include <cutils/properties.h>
diff --git a/opengl/tests/Android.bp b/opengl/tests/Android.bp
new file mode 100644
index 0000000..bf7aeb1
--- /dev/null
+++ b/opengl/tests/Android.bp
@@ -0,0 +1,4 @@
+subdirs = [
+ "hwc",
+ "lib",
+]
diff --git a/opengl/tests/Android.mk b/opengl/tests/Android.mk
index 3ae3b4e..92d223c 100644
--- a/opengl/tests/Android.mk
+++ b/opengl/tests/Android.mk
@@ -12,7 +12,6 @@
gl_perf \
gl_yuvtex \
gralloc \
- hwc \
include \
lib \
linetex \
diff --git a/opengl/tests/hwc/Android.bp b/opengl/tests/hwc/Android.bp
new file mode 100644
index 0000000..b6e6f0e
--- /dev/null
+++ b/opengl/tests/hwc/Android.bp
@@ -0,0 +1,102 @@
+// 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_defaults {
+
+ name: "hwc_tests_defaults",
+ cflags: [
+ "-DGL_GLEXT_PROTOTYPES",
+ "-DEGL_EGLEXT_PROTOTYPES",
+ "-Wall",
+ "-Wextra",
+ "-Werror",
+ ],
+}
+
+cc_library_static {
+
+ name: "libhwcTest",
+ srcs: ["hwcTestLib.cpp"],
+
+ static_libs: [
+ "libarect",
+ "libglTest",
+ "libtestUtil",
+ ],
+ defaults: ["hwc_tests_defaults"],
+}
+
+cc_defaults {
+
+ name: "hwc_lib_defaults",
+ shared_libs: [
+ "libcutils",
+ "libEGL",
+ "libGLESv2",
+ "libhardware",
+ "liblog",
+ "libui",
+ "libutils",
+ ],
+
+ static_libs: [
+ "libglTest",
+ "libhwcTest",
+ "libtestUtil",
+ ],
+}
+
+cc_test {
+
+ name: "hwcStress",
+ srcs: ["hwcStress.cpp"],
+
+ defaults: [
+ "hwc_lib_defaults",
+ "hwc_tests_defaults",
+ ],
+}
+
+cc_test {
+
+ name: "hwcRects",
+ srcs: ["hwcRects.cpp"],
+
+ defaults: [
+ "hwc_lib_defaults",
+ "hwc_tests_defaults",
+ ],
+}
+
+cc_test {
+
+ name: "hwcColorEquiv",
+ srcs: ["hwcColorEquiv.cpp"],
+
+ defaults: [
+ "hwc_lib_defaults",
+ "hwc_tests_defaults",
+ ],
+}
+
+cc_test {
+
+ name: "hwcCommit",
+ srcs: ["hwcCommit.cpp"],
+
+ defaults: [
+ "hwc_lib_defaults",
+ "hwc_tests_defaults",
+ ],
+}
diff --git a/opengl/tests/hwc/Android.mk b/opengl/tests/hwc/Android.mk
deleted file mode 100644
index 13337c2..0000000
--- a/opengl/tests/hwc/Android.mk
+++ /dev/null
@@ -1,150 +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_ADDITIONAL_DEPENDENCIES := $(LOCAL_PATH)/Android.mk
-
-LOCAL_MODULE_TAGS := tests
-LOCAL_MODULE:= libhwcTest
-LOCAL_CFLAGS := -DGL_GLEXT_PROTOTYPES -DEGL_EGLEXT_PROTOTYPES -Wall -Wextra -Werror
-LOCAL_CXX_STL := libc++
-LOCAL_SRC_FILES:= hwcTestLib.cpp
-LOCAL_C_INCLUDES += system/extras/tests/include \
- $(call include-path-for, opengl-tests-includes) \
-
-LOCAL_STATIC_LIBRARIES := libarect
-
-include $(BUILD_STATIC_LIBRARY)
-
-include $(CLEAR_VARS)
-LOCAL_ADDITIONAL_DEPENDENCIES := $(LOCAL_PATH)/Android.mk
-
-LOCAL_MODULE:= hwcStress
-LOCAL_MODULE_TAGS := tests
-LOCAL_CFLAGS := -DGL_GLEXT_PROTOTYPES -DEGL_EGLEXT_PROTOTYPES -Wall -Wextra -Werror
-LOCAL_CXX_STL := libc++
-LOCAL_SRC_FILES:= hwcStress.cpp
-
-LOCAL_SHARED_LIBRARIES := \
- libcutils \
- libEGL \
- libGLESv2 \
- libutils \
- liblog \
- libui \
- libhardware \
-
-LOCAL_STATIC_LIBRARIES := \
- libtestUtil \
- libglTest \
- libhwcTest \
-
-LOCAL_C_INCLUDES += \
- system/extras/tests/include \
- hardware/libhardware/include \
- $(call include-path-for, opengl-tests-includes) \
-
-include $(BUILD_NATIVE_TEST)
-
-include $(CLEAR_VARS)
-LOCAL_ADDITIONAL_DEPENDENCIES := $(LOCAL_PATH)/Android.mk
-
-LOCAL_MODULE:= hwcRects
-LOCAL_MODULE_TAGS := tests
-LOCAL_CFLAGS := -DGL_GLEXT_PROTOTYPES -DEGL_EGLEXT_PROTOTYPES -Wall -Wextra -Werror
-LOCAL_CXX_STL := libc++
-LOCAL_SRC_FILES:= hwcRects.cpp
-
-LOCAL_SHARED_LIBRARIES := \
- libcutils \
- libEGL \
- libGLESv2 \
- libutils \
- liblog \
- libui \
- libhardware \
-
-LOCAL_STATIC_LIBRARIES := \
- libtestUtil \
- libglTest \
- libhwcTest \
-
-LOCAL_C_INCLUDES += \
- system/extras/tests/include \
- hardware/libhardware/include \
- $(call include-path-for, opengl-tests-includes) \
-
-include $(BUILD_NATIVE_TEST)
-
-include $(CLEAR_VARS)
-LOCAL_ADDITIONAL_DEPENDENCIES := $(LOCAL_PATH)/Android.mk
-
-LOCAL_MODULE:= hwcColorEquiv
-LOCAL_MODULE_TAGS := tests
-LOCAL_CFLAGS := -DGL_GLEXT_PROTOTYPES -DEGL_EGLEXT_PROTOTYPES -Wall -Wextra -Werror
-LOCAL_CXX_STL := libc++
-LOCAL_SRC_FILES:= hwcColorEquiv.cpp
-
-LOCAL_SHARED_LIBRARIES := \
- libcutils \
- libEGL \
- libGLESv2 \
- libutils \
- liblog \
- libui \
- libhardware \
-
-LOCAL_STATIC_LIBRARIES := \
- libtestUtil \
- libglTest \
- libhwcTest \
-
-LOCAL_C_INCLUDES += \
- system/extras/tests/include \
- hardware/libhardware/include \
- $(call include-path-for, opengl-tests-includes) \
-
-include $(BUILD_NATIVE_TEST)
-
-include $(CLEAR_VARS)
-LOCAL_ADDITIONAL_DEPENDENCIES := $(LOCAL_PATH)/Android.mk
-
-LOCAL_MODULE:= hwcCommit
-LOCAL_MODULE_TAGS := tests
-LOCAL_CFLAGS := -DGL_GLEXT_PROTOTYPES -DEGL_EGLEXT_PROTOTYPES -Wall -Wextra -Werror
-LOCAL_CXX_STL := libc++
-LOCAL_SRC_FILES:= hwcCommit.cpp
-
-LOCAL_SHARED_LIBRARIES := \
- libcutils \
- libEGL \
- libGLESv2 \
- libutils \
- liblog \
- libui \
- libhardware \
-
-LOCAL_STATIC_LIBRARIES := \
- libtestUtil \
- libglTest \
- libhwcTest \
-
-LOCAL_C_INCLUDES += \
- system/extras/tests/include \
- hardware/libhardware/include \
- $(call include-path-for, opengl-tests-includes) \
-
-include $(BUILD_NATIVE_TEST)
diff --git a/opengl/tests/include/EGLUtils.h b/opengl/tests/include/EGLUtils.h
deleted file mode 100644
index 014c261..0000000
--- a/opengl/tests/include/EGLUtils.h
+++ /dev/null
@@ -1,144 +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.
- */
-
-
-#ifndef ANDROID_UI_EGLUTILS_H
-#define ANDROID_UI_EGLUTILS_H
-
-#include <stdint.h>
-#include <stdlib.h>
-
-#include <system/window.h>
-#include <utils/Errors.h>
-#include <EGL/egl.h>
-
-
-// ----------------------------------------------------------------------------
-namespace android {
-// ----------------------------------------------------------------------------
-
-class EGLUtils
-{
-public:
-
- static inline const char *strerror(EGLint err);
-
- static inline status_t selectConfigForPixelFormat(
- EGLDisplay dpy,
- EGLint const* attrs,
- int32_t format,
- EGLConfig* outConfig);
-
- static inline status_t selectConfigForNativeWindow(
- EGLDisplay dpy,
- EGLint const* attrs,
- EGLNativeWindowType window,
- EGLConfig* outConfig);
-};
-
-// ----------------------------------------------------------------------------
-
-const char *EGLUtils::strerror(EGLint err)
-{
- switch (err){
- case EGL_SUCCESS: return "EGL_SUCCESS";
- case EGL_NOT_INITIALIZED: return "EGL_NOT_INITIALIZED";
- case EGL_BAD_ACCESS: return "EGL_BAD_ACCESS";
- case EGL_BAD_ALLOC: return "EGL_BAD_ALLOC";
- case EGL_BAD_ATTRIBUTE: return "EGL_BAD_ATTRIBUTE";
- case EGL_BAD_CONFIG: return "EGL_BAD_CONFIG";
- case EGL_BAD_CONTEXT: return "EGL_BAD_CONTEXT";
- case EGL_BAD_CURRENT_SURFACE: return "EGL_BAD_CURRENT_SURFACE";
- case EGL_BAD_DISPLAY: return "EGL_BAD_DISPLAY";
- case EGL_BAD_MATCH: return "EGL_BAD_MATCH";
- case EGL_BAD_NATIVE_PIXMAP: return "EGL_BAD_NATIVE_PIXMAP";
- case EGL_BAD_NATIVE_WINDOW: return "EGL_BAD_NATIVE_WINDOW";
- case EGL_BAD_PARAMETER: return "EGL_BAD_PARAMETER";
- case EGL_BAD_SURFACE: return "EGL_BAD_SURFACE";
- case EGL_CONTEXT_LOST: return "EGL_CONTEXT_LOST";
- default: return "UNKNOWN";
- }
-}
-
-status_t EGLUtils::selectConfigForPixelFormat(
- EGLDisplay dpy,
- EGLint const* attrs,
- int32_t format,
- EGLConfig* outConfig)
-{
- EGLint numConfigs = -1, n=0;
-
- if (!attrs)
- return BAD_VALUE;
-
- if (outConfig == NULL)
- return BAD_VALUE;
-
- // Get all the "potential match" configs...
- if (eglGetConfigs(dpy, NULL, 0, &numConfigs) == EGL_FALSE)
- return BAD_VALUE;
-
- EGLConfig* const configs = (EGLConfig*)malloc(sizeof(EGLConfig)*numConfigs);
- if (eglChooseConfig(dpy, attrs, configs, numConfigs, &n) == EGL_FALSE) {
- free(configs);
- return BAD_VALUE;
- }
-
- int i;
- EGLConfig config = NULL;
- for (i=0 ; i<n ; i++) {
- EGLint nativeVisualId = 0;
- eglGetConfigAttrib(dpy, configs[i], EGL_NATIVE_VISUAL_ID, &nativeVisualId);
- if (nativeVisualId>0 && format == nativeVisualId) {
- config = configs[i];
- break;
- }
- }
-
- free(configs);
-
- if (i<n) {
- *outConfig = config;
- return NO_ERROR;
- }
-
- return NAME_NOT_FOUND;
-}
-
-status_t EGLUtils::selectConfigForNativeWindow(
- EGLDisplay dpy,
- EGLint const* attrs,
- EGLNativeWindowType window,
- EGLConfig* outConfig)
-{
- int err;
- int format;
-
- if (!window)
- return BAD_VALUE;
-
- if ((err = window->query(window, NATIVE_WINDOW_FORMAT, &format)) < 0) {
- return err;
- }
-
- return selectConfigForPixelFormat(dpy, attrs, format, outConfig);
-}
-
-// ----------------------------------------------------------------------------
-}; // namespace android
-// ----------------------------------------------------------------------------
-
-#endif /* ANDROID_UI_EGLUTILS_H */
diff --git a/opengl/tests/lib/Android.bp b/opengl/tests/lib/Android.bp
new file mode 100644
index 0000000..2f6095d
--- /dev/null
+++ b/opengl/tests/lib/Android.bp
@@ -0,0 +1,38 @@
+// 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: "libglTest",
+ srcs: [
+ "glTestLib.cpp",
+ "WindowSurface.cpp",
+ ],
+ export_include_dirs: ["include"],
+
+ cflags: [
+ "-DGL_GLEXT_PROTOTYPES",
+ "-DEGL_EGLEXT_PROTOTYPES",
+ "-Wall",
+ "-Wextra",
+ "-Werror",
+ ],
+
+ shared_libs: ["libgui"],
+ static_libs: [
+ "libarect",
+ "libtestUtil",
+ ],
+
+}
diff --git a/opengl/tests/lib/Android.mk b/opengl/tests/lib/Android.mk
deleted file mode 100644
index ea94bc1..0000000
--- a/opengl/tests/lib/Android.mk
+++ /dev/null
@@ -1,30 +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_ADDITIONAL_DEPENDENCIES := $(LOCAL_PATH)/Android.mk
-LOCAL_MODULE_TAGS := tests
-LOCAL_MODULE:= libglTest
-LOCAL_SRC_FILES:= glTestLib.cpp WindowSurface.cpp
-LOCAL_C_INCLUDES += system/extras/tests/include \
- $(call include-path-for, opengl-tests-includes)
-
-LOCAL_CFLAGS := -DGL_GLEXT_PROTOTYPES -DEGL_EGLEXT_PROTOTYPES -Wall -Wextra -Werror
-
-LOCAL_SHARED_LIBRARIES += libgui
-LOCAL_STATIC_LIBRARIES := libarect
-
-include $(BUILD_STATIC_LIBRARY)
diff --git a/opengl/tests/include/WindowSurface.h b/opengl/tests/lib/include/WindowSurface.h
similarity index 100%
rename from opengl/tests/include/WindowSurface.h
rename to opengl/tests/lib/include/WindowSurface.h
diff --git a/opengl/tests/include/glTestLib.h b/opengl/tests/lib/include/glTestLib.h
similarity index 100%
rename from opengl/tests/include/glTestLib.h
rename to opengl/tests/lib/include/glTestLib.h
diff --git a/services/Android.bp b/services/Android.bp
deleted file mode 100644
index 7a8ee5d..0000000
--- a/services/Android.bp
+++ /dev/null
@@ -1 +0,0 @@
-subdirs = [ "*" ]
diff --git a/services/schedulerservice/Android.bp b/services/schedulerservice/Android.bp
index ca91b8e..0227164 100644
--- a/services/schedulerservice/Android.bp
+++ b/services/schedulerservice/Android.bp
@@ -3,6 +3,7 @@
srcs: [
"SchedulingPolicyService.cpp",
],
+ cflags: ["-Wall", "-Werror"],
shared_libs: [
"libhidlbase",
"libhidltransport",
diff --git a/services/schedulerservice/SchedulingPolicyService.cpp b/services/schedulerservice/SchedulingPolicyService.cpp
index 1f6ed57..a1106cf 100644
--- a/services/schedulerservice/SchedulingPolicyService.cpp
+++ b/services/schedulerservice/SchedulingPolicyService.cpp
@@ -17,6 +17,8 @@
#include "SchedulingPolicyService.h"
+#include <private/android_filesystem_config.h> // for AID_CAMERASERVER
+
#include <log/log.h>
#include <hwbinder/IPCThreadState.h>
#include <mediautils/SchedulingPolicyService.h>
@@ -28,8 +30,9 @@
namespace implementation {
bool SchedulingPolicyService::isAllowed() {
- // TODO(b/37291237)
- return true;
+ using ::android::hardware::IPCThreadState;
+
+ return IPCThreadState::self()->getCallingUid() == AID_CAMERASERVER;
}
Return<bool> SchedulingPolicyService::requestPriority(int32_t pid, int32_t tid, int32_t priority) {
diff --git a/services/sensorservice/Android.bp b/services/sensorservice/Android.bp
index 8d381b1..a7f3a52 100644
--- a/services/sensorservice/Android.bp
+++ b/services/sensorservice/Android.bp
@@ -14,6 +14,7 @@
"RecentEventLogger.cpp",
"RotationVectorSensor.cpp",
"SensorDevice.cpp",
+ "SensorDeviceUtils.cpp",
"SensorDirectConnection.cpp",
"SensorEventConnection.cpp",
"SensorFusion.cpp",
diff --git a/services/sensorservice/SensorDevice.cpp b/services/sensorservice/SensorDevice.cpp
index da3b275..fdb69d3 100644
--- a/services/sensorservice/SensorDevice.cpp
+++ b/services/sensorservice/SensorDevice.cpp
@@ -26,11 +26,10 @@
#include <cinttypes>
#include <thread>
-using android::hardware::hidl_vec;
-
using namespace android::hardware::sensors::V1_0;
using namespace android::hardware::sensors::V1_0::implementation;
-
+using android::hardware::hidl_vec;
+using android::SensorDeviceUtils::HidlServiceRegistrationWaiter;
namespace android {
// ---------------------------------------------------------------------------
@@ -52,7 +51,8 @@
}
}
-SensorDevice::SensorDevice() : mHidlTransportErrors(20) {
+SensorDevice::SensorDevice()
+ : mHidlTransportErrors(20), mRestartWaiter(new HidlServiceRegistrationWaiter()) {
if (!connectHidlService()) {
return;
}
@@ -87,35 +87,29 @@
}
bool SensorDevice::connectHidlService() {
- // SensorDevice may wait upto 100ms * 10 = 1s for hidl service.
- constexpr auto RETRY_DELAY = std::chrono::milliseconds(100);
+ // SensorDevice will wait for HAL service to start if HAL is declared in device manifest.
size_t retry = 10;
- while (true) {
- int initStep = 0;
+ while (retry-- > 0) {
mSensors = ISensors::getService();
- if (mSensors != nullptr) {
- ++initStep;
- // Poke ISensor service. If it has lingering connection from previous generation of
- // system server, it will kill itself. There is no intention to handle the poll result,
- // which will be done since the size is 0.
- if(mSensors->poll(0, [](auto, const auto &, const auto &) {}).isOk()) {
- // ok to continue
- break;
- }
- // hidl service is restarting, pointer is invalid.
- mSensors = nullptr;
- }
-
- if (--retry <= 0) {
- ALOGE("Cannot connect to ISensors hidl service!");
+ if (mSensors == nullptr) {
+ // no sensor hidl service found
break;
}
- // Delay 100ms before retry, hidl service is expected to come up in short time after
- // crash.
- ALOGI("%s unsuccessful, try again soon (remaining retry %zu).",
- (initStep == 0) ? "getService()" : "poll() check", retry);
- std::this_thread::sleep_for(RETRY_DELAY);
+
+ mRestartWaiter->reset();
+ // Poke ISensor service. If it has lingering connection from previous generation of
+ // system server, it will kill itself. There is no intention to handle the poll result,
+ // which will be done since the size is 0.
+ if(mSensors->poll(0, [](auto, const auto &, const auto &) {}).isOk()) {
+ // ok to continue
+ break;
+ }
+
+ // hidl service is restarting, pointer is invalid.
+ mSensors = nullptr;
+ ALOGI("%s unsuccessful, remaining retry %zu.", __FUNCTION__, retry);
+ mRestartWaiter->wait();
}
return (mSensors != nullptr);
}
@@ -173,7 +167,7 @@
}
status_t SensorDevice::initCheck() const {
- return mSensors != NULL ? NO_ERROR : NO_INIT;
+ return mSensors != nullptr ? NO_ERROR : NO_INIT;
}
ssize_t SensorDevice::poll(sensors_event_t* buffer, size_t count) {
diff --git a/services/sensorservice/SensorDevice.h b/services/sensorservice/SensorDevice.h
index fd6cee6..6d75051 100644
--- a/services/sensorservice/SensorDevice.h
+++ b/services/sensorservice/SensorDevice.h
@@ -17,6 +17,7 @@
#ifndef ANDROID_SENSOR_DEVICE_H
#define ANDROID_SENSOR_DEVICE_H
+#include "SensorDeviceUtils.h"
#include "SensorServiceUtils.h"
#include <sensor/Sensor.h>
@@ -39,12 +40,9 @@
namespace android {
// ---------------------------------------------------------------------------
-using SensorServiceUtil::Dumpable;
-using hardware::Return;
-class SensorDevice : public Singleton<SensorDevice>, public Dumpable {
+class SensorDevice : public Singleton<SensorDevice>, public SensorServiceUtil::Dumpable {
public:
-
class HidlTransportErrorLog {
public:
@@ -105,7 +103,7 @@
private:
friend class Singleton<SensorDevice>;
- sp<android::hardware::sensors::V1_0::ISensors> mSensors;
+ sp<hardware::sensors::V1_0::ISensors> mSensors;
Vector<sensor_t> mSensorList;
std::unordered_map<int32_t, sensor_t*> mConnectedDynamicSensors;
@@ -174,6 +172,8 @@
}
return std::move(ret);
}
+ //TODO(b/67425500): remove waiter after bug is resolved.
+ sp<SensorDeviceUtils::HidlServiceRegistrationWaiter> mRestartWaiter;
bool isClientDisabled(void* ident);
bool isClientDisabledLocked(void* ident);
diff --git a/services/sensorservice/SensorDeviceUtils.cpp b/services/sensorservice/SensorDeviceUtils.cpp
new file mode 100644
index 0000000..b1344be
--- /dev/null
+++ b/services/sensorservice/SensorDeviceUtils.cpp
@@ -0,0 +1,70 @@
+/*
+ * Copyright (C) 2017 The Android Open Source Project
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+#include "SensorDeviceUtils.h"
+
+#include <android/hardware/sensors/1.0/ISensors.h>
+#include <utils/Log.h>
+
+#include <chrono>
+#include <thread>
+
+using ::android::hardware::Void;
+using namespace android::hardware::sensors::V1_0;
+
+namespace android {
+namespace SensorDeviceUtils {
+
+HidlServiceRegistrationWaiter::HidlServiceRegistrationWaiter()
+ : mRegistered(ISensors::registerForNotifications("default", this)) {
+}
+
+Return<void> HidlServiceRegistrationWaiter::onRegistration(
+ const hidl_string &fqName, const hidl_string &name, bool preexisting) {
+ ALOGV("onRegistration fqName %s, name %s, preexisting %d",
+ fqName.c_str(), name.c_str(), preexisting);
+
+ {
+ std::lock_guard<std::mutex> lk(mLock);
+ mRestartObserved = true;
+ }
+ mCondition.notify_all();
+ return Void();
+}
+
+void HidlServiceRegistrationWaiter::reset() {
+ std::lock_guard<std::mutex> lk(mLock);
+ mRestartObserved = false;
+}
+
+bool HidlServiceRegistrationWaiter::wait() {
+ constexpr int DEFAULT_WAIT_MS = 100;
+ constexpr int TIMEOUT_MS = 1000;
+
+ if (!mRegistered) {
+ ALOGW("Cannot register service notification, use default wait(%d ms)", DEFAULT_WAIT_MS);
+ std::this_thread::sleep_for(std::chrono::milliseconds(DEFAULT_WAIT_MS));
+ // not sure if service is actually restarted
+ return false;
+ }
+
+ std::unique_lock<std::mutex> lk(mLock);
+ return mCondition.wait_for(lk, std::chrono::milliseconds(TIMEOUT_MS),
+ [this]{return mRestartObserved;});
+}
+
+} // namespace SensorDeviceUtils
+} // namespace android
diff --git a/services/sensorservice/SensorDeviceUtils.h b/services/sensorservice/SensorDeviceUtils.h
new file mode 100644
index 0000000..da36928
--- /dev/null
+++ b/services/sensorservice/SensorDeviceUtils.h
@@ -0,0 +1,60 @@
+/*
+ * Copyright (C) 2017 The Android Open Source Project
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+#ifndef ANDROID_SENSOR_DEVICE_UTIL
+#define ANDROID_SENSOR_DEVICE_UTIL
+
+#include <android/hidl/manager/1.0/IServiceNotification.h>
+
+#include <condition_variable>
+#include <thread>
+
+using ::android::hardware::hidl_string;
+using ::android::hardware::Return;
+using ::android::hidl::manager::V1_0::IServiceNotification;
+
+namespace android {
+namespace SensorDeviceUtils {
+
+class HidlServiceRegistrationWaiter : public IServiceNotification {
+public:
+
+ HidlServiceRegistrationWaiter();
+
+ Return<void> onRegistration(const hidl_string &fqName,
+ const hidl_string &name,
+ bool preexisting) override;
+
+ void reset();
+
+ /**
+ * Wait for service restart
+ *
+ * @return true if service is restart since last reset(); false otherwise.
+ */
+ bool wait();
+private:
+ const bool mRegistered;
+
+ std::mutex mLock;
+ std::condition_variable mCondition;
+ bool mRestartObserved;
+};
+
+} // namespace SensorDeviceUtils
+} // namespace android;
+
+#endif // ANDROID_SENSOR_SERVICE_UTIL