[Merge] lp:~ricmm/platform-api/module-override-and-sensor-events into lp:platform-api
Jim Hodapp
jim.hodapp at canonical.com
Thu Jan 22 19:12:05 UTC 2015
Review: Needs Fixing code
2 minor changes inline.
Diff comments:
> === modified file 'CMakeLists.txt'
> --- CMakeLists.txt 2014-11-14 15:30:22 +0000
> +++ CMakeLists.txt 2015-01-21 15:47:57 +0000
> @@ -3,7 +3,7 @@
> project(ubuntu-platform-api)
>
> set(UBUNTU_PLATFORM_API_VERSION_MAJOR 2)
> -set(UBUNTU_PLATFORM_API_VERSION_MINOR 6)
> +set(UBUNTU_PLATFORM_API_VERSION_MINOR 7)
> set(UBUNTU_PLATFORM_API_VERSION_PATCH 0)
>
> set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -fvisibility=hidden")
>
> === modified file 'src/bridge/bridge.h'
> --- src/bridge/bridge.h 2014-05-20 14:58:53 +0000
> +++ src/bridge/bridge.h 2015-01-21 15:47:57 +0000
> @@ -42,14 +42,23 @@
> return bridge;
> }
>
> - void* resolve_symbol(const char* symbol) const
> + void* resolve_symbol(const char* symbol, const char* module = "") const
> {
> - return Scope::dlsym_fn(lib_handle, symbol);
> + static const char* test_modules = secure_getenv("UBUNTU_PLATFORM_API_TEST_OVERRIDE");
> + if (test_modules && strstr(test_modules, module)) {
> + printf("Platform API: INFO: Overriding symbol '%s' with test version\n", symbol);
> + return Scope::dlsym_fn(lib_override_handle, symbol);
> + } else {
> + return Scope::dlsym_fn(lib_handle, symbol);
> + }
> }
>
> protected:
> - Bridge() : lib_handle(Scope::dlopen_fn(Scope::path(), RTLD_LAZY))
> + Bridge()
> + : lib_handle(Scope::dlopen_fn(Scope::path(), RTLD_LAZY))
> {
> + if (Scope::override_path())
> + lib_override_handle = (Scope::dlopen_fn(Scope::override_path(), RTLD_LAZY));
> }
>
> ~Bridge()
> @@ -57,6 +66,7 @@
> }
>
> void* lib_handle;
> + void* lib_override_handle;
> };
> }
>
>
> === modified file 'src/bridge/bridge_defs.h'
> --- src/bridge/bridge_defs.h 2014-05-20 10:26:18 +0000
> +++ src/bridge/bridge_defs.h 2015-01-21 15:47:57 +0000
> @@ -31,102 +31,102 @@
>
> // this allows DLSYM to return NULL (happens if the backend is not available),
> // and returns NULL in that case; return_type must be a pointer!
> -#define IMPLEMENT_CTOR0(return_type, symbol) \
> +#define IMPLEMENT_CTOR0(module, return_type, symbol) \
> return_type symbol() \
> { \
> static return_type (*f)() = NULL; \
> - DLSYM(&f, #symbol); \
> + DLSYM(&f, #symbol, #module); \
> return f ? f() : NULL;}
>
> -#define IMPLEMENT_FUNCTION0(return_type, symbol) \
> +#define IMPLEMENT_FUNCTION0(module, return_type, symbol) \
> return_type symbol() \
> { \
> static return_type (*f)() = NULL; \
> - DLSYM(&f, #symbol); \
> + DLSYM(&f, #symbol, #module); \
> return f();}
>
> -#define IMPLEMENT_VOID_FUNCTION0(symbol) \
> +#define IMPLEMENT_VOID_FUNCTION0(module, symbol) \
> void symbol() \
> { \
> static void (*f)() = NULL; \
> - DLSYM(&f, #symbol); \
> + DLSYM(&f, #symbol, #module); \
> f();}
>
> -#define IMPLEMENT_FUNCTION1(return_type, symbol, arg1) \
> +#define IMPLEMENT_FUNCTION1(module, return_type, symbol, arg1) \
> return_type symbol(arg1 _1) \
> { \
> static return_type (*f)(arg1) = NULL; \
> - DLSYM(&f, #symbol); \
> + DLSYM(&f, #symbol, #module); \
> return f(_1); }
>
> -#define IMPLEMENT_VOID_FUNCTION1(symbol, arg1) \
> +#define IMPLEMENT_VOID_FUNCTION1(module, symbol, arg1) \
> void symbol(arg1 _1) \
> { \
> static void (*f)(arg1) = NULL; \
> - DLSYM(&f, #symbol); \
> + DLSYM(&f, #symbol, #module); \
> f(_1); }
>
> -#define IMPLEMENT_FUNCTION2(return_type, symbol, arg1, arg2) \
> +#define IMPLEMENT_FUNCTION2(module, return_type, symbol, arg1, arg2) \
> return_type symbol(arg1 _1, arg2 _2) \
> { \
> static return_type (*f)(arg1, arg2) = NULL; \
> - DLSYM(&f, #symbol); \
> + DLSYM(&f, #symbol, #module); \
> return f(_1, _2); }
>
> -#define IMPLEMENT_VOID_FUNCTION2(symbol, arg1, arg2) \
> +#define IMPLEMENT_VOID_FUNCTION2(module, symbol, arg1, arg2) \
> void symbol(arg1 _1, arg2 _2) \
> { \
> static void (*f)(arg1, arg2) = NULL; \
> - DLSYM(&f, #symbol); \
> + DLSYM(&f, #symbol, #module); \
> f(_1, _2); }
>
> -#define IMPLEMENT_FUNCTION3(return_type, symbol, arg1, arg2, arg3) \
> +#define IMPLEMENT_FUNCTION3(module, return_type, symbol, arg1, arg2, arg3) \
> return_type symbol(arg1 _1, arg2 _2, arg3 _3) \
> { \
> static return_type (*f)(arg1, arg2, arg3) = NULL; \
> - DLSYM(&f, #symbol); \
> + DLSYM(&f, #symbol, #module); \
> return f(_1, _2, _3); }
>
> -#define IMPLEMENT_VOID_FUNCTION3(symbol, arg1, arg2, arg3) \
> +#define IMPLEMENT_VOID_FUNCTION3(module, symbol, arg1, arg2, arg3) \
> void symbol(arg1 _1, arg2 _2, arg3 _3) \
> { \
> static void (*f)(arg1, arg2, arg3) = NULL; \
> - DLSYM(&f, #symbol); \
> + DLSYM(&f, #symbol, #module); \
> f(_1, _2, _3); }
>
> -#define IMPLEMENT_VOID_FUNCTION4(symbol, arg1, arg2, arg3, arg4) \
> +#define IMPLEMENT_VOID_FUNCTION4(module, symbol, arg1, arg2, arg3, arg4) \
> void symbol(arg1 _1, arg2 _2, arg3 _3, arg4 _4) \
> { \
> static void (*f)(arg1, arg2, arg3, arg4) = NULL; \
> - DLSYM(&f, #symbol); \
> + DLSYM(&f, #symbol, #module); \
> f(_1, _2, _3, _4); }
>
> -#define IMPLEMENT_FUNCTION4(return_type, symbol, arg1, arg2, arg3, arg4) \
> +#define IMPLEMENT_FUNCTION4(module, return_type, symbol, arg1, arg2, arg3, arg4) \
> return_type symbol(arg1 _1, arg2 _2, arg3 _3, arg4 _4) \
> { \
> static return_type (*f)(arg1, arg2, arg3, arg4) = NULL; \
> - DLSYM(&f, #symbol); \
> + DLSYM(&f, #symbol, #module); \
> return f(_1, _2, _3, _4); }
>
> -#define IMPLEMENT_FUNCTION6(return_type, symbol, arg1, arg2, arg3, arg4, arg5, arg6) \
> +#define IMPLEMENT_FUNCTION6(module, return_type, symbol, arg1, arg2, arg3, arg4, arg5, arg6) \
> return_type symbol(arg1 _1, arg2 _2, arg3 _3, arg4 _4, arg5 _5, arg6 _6) \
> { \
> static return_type (*f)(arg1, arg2, arg3, arg4, arg5, arg6) = NULL; \
> - DLSYM(&f, #symbol); \
> + DLSYM(&f, #symbol, #module); \
> return f(_1, _2, _3, _4, _5, _6); }
>
> -#define IMPLEMENT_VOID_FUNCTION7(symbol, arg1, arg2, arg3, arg4, arg5, arg6, arg7) \
> +#define IMPLEMENT_VOID_FUNCTION7(module, symbol, arg1, arg2, arg3, arg4, arg5, arg6, arg7) \
> void symbol(arg1 _1, arg2 _2, arg3 _3, arg4 _4, arg5 _5, arg6 _6, arg7 _7) \
> { \
> static void (*f)(arg1, arg2, arg3, arg4, arg5, arg6, arg7) = NULL; \
> - DLSYM(&f, #symbol); \
> + DLSYM(&f, #symbol, #module); \
> f(_1, _2, _3, _4, _5, _6, _7); }
>
> -#define IMPLEMENT_VOID_FUNCTION8(symbol, arg1, arg2, arg3, arg4, arg5, arg6, arg7, arg8) \
> +#define IMPLEMENT_VOID_FUNCTION8(module, symbol, arg1, arg2, arg3, arg4, arg5, arg6, arg7, arg8) \
> void symbol(arg1 _1, arg2 _2, arg3 _3, arg4 _4, arg5 _5, arg6 _6, arg7 _7, arg8 _8) \
> { \
> static void (*f)(arg1, arg2, arg3, arg4, arg5, arg6, arg7, arg8) = NULL; \
> - DLSYM(&f, #symbol); \
> + DLSYM(&f, #symbol, #module); \
> f(_1, _2, _3, _4, _5, _6, _7, _8); }
>
> #ifdef __cplusplus
>
> === added file 'src/bridge/hybris_bridge_defs.h'
> --- src/bridge/hybris_bridge_defs.h 1970-01-01 00:00:00 +0000
> +++ src/bridge/hybris_bridge_defs.h 2015-01-21 15:47:57 +0000
> @@ -0,0 +1,136 @@
> +/*
> + * Copyright (C) 2012 Canonical Ltd
> + *
> + * This program is free software: you can redistribute it and/or modify
> + * it under the terms of the GNU Lesser General Public License version 3 as
> + * published by the Free Software Foundation.
> + *
> + * This program is distributed in the hope that it will be useful,
> + * but WITHOUT ANY WARRANTY; without even the implied warranty of
> + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
> + * GNU Lesser General Public License for more details.
> + *
> + * You should have received a copy of the GNU Lesser General Public License
> + * along with this program. If not, see <http://www.gnu.org/licenses/>.
> + *
> + * Authored by: Thomas Voss <thomas.voss at canonical.com>
> + * Ricardo Mendoza <ricardo.mendoza at canonical.com>
> + */
> +#ifndef HYBRIS_BRIDGE_DEFS_H_
> +#define HYBRIS_BRIDGE_DEFS_H_
> +
> +// Must be included afterthe Bridge class is defined
Typo in "afterthe"
> +
> +#ifdef __cplusplus
> +extern "C" {
> +#endif
> +
> +/**********************************************************/
> +/*********** Implementation starts here *******************/
> +/**********************************************************/
> +
> +// this allows DLSYM to return NULL (happens if the backend is not available),
> +// and returns NULL in that case; return_type must be a pointer!
> +#define IMPLEMENT_CTOR0(return_type, symbol) \
> + return_type symbol() \
> + { \
> + static return_type (*f)() = NULL; \
> + DLSYM(&f, #symbol); \
> + return f ? f() : NULL;}
> +
> +#define IMPLEMENT_FUNCTION0(return_type, symbol) \
> + return_type symbol() \
> + { \
> + static return_type (*f)() = NULL; \
> + DLSYM(&f, #symbol); \
> + return f();}
> +
> +#define IMPLEMENT_VOID_FUNCTION0(symbol) \
> + void symbol() \
> + { \
> + static void (*f)() = NULL; \
> + DLSYM(&f, #symbol); \
> + f();}
> +
> +#define IMPLEMENT_FUNCTION1(return_type, symbol, arg1) \
> + return_type symbol(arg1 _1) \
> + { \
> + static return_type (*f)(arg1) = NULL; \
> + DLSYM(&f, #symbol); \
> + return f(_1); }
> +
> +#define IMPLEMENT_VOID_FUNCTION1(symbol, arg1) \
> + void symbol(arg1 _1) \
> + { \
> + static void (*f)(arg1) = NULL; \
> + DLSYM(&f, #symbol); \
> + f(_1); }
> +
> +#define IMPLEMENT_FUNCTION2(return_type, symbol, arg1, arg2) \
> + return_type symbol(arg1 _1, arg2 _2) \
> + { \
> + static return_type (*f)(arg1, arg2) = NULL; \
> + DLSYM(&f, #symbol); \
> + return f(_1, _2); }
> +
> +#define IMPLEMENT_VOID_FUNCTION2(symbol, arg1, arg2) \
> + void symbol(arg1 _1, arg2 _2) \
> + { \
> + static void (*f)(arg1, arg2) = NULL; \
> + DLSYM(&f, #symbol); \
> + f(_1, _2); }
> +
> +#define IMPLEMENT_FUNCTION3(return_type, symbol, arg1, arg2, arg3) \
> + return_type symbol(arg1 _1, arg2 _2, arg3 _3) \
> + { \
> + static return_type (*f)(arg1, arg2, arg3) = NULL; \
> + DLSYM(&f, #symbol); \
> + return f(_1, _2, _3); }
> +
> +#define IMPLEMENT_VOID_FUNCTION3(symbol, arg1, arg2, arg3) \
> + void symbol(arg1 _1, arg2 _2, arg3 _3) \
> + { \
> + static void (*f)(arg1, arg2, arg3) = NULL; \
> + DLSYM(&f, #symbol); \
> + f(_1, _2, _3); }
> +
> +#define IMPLEMENT_VOID_FUNCTION4(symbol, arg1, arg2, arg3, arg4) \
> + void symbol(arg1 _1, arg2 _2, arg3 _3, arg4 _4) \
> + { \
> + static void (*f)(arg1, arg2, arg3, arg4) = NULL; \
> + DLSYM(&f, #symbol); \
> + f(_1, _2, _3, _4); }
> +
> +#define IMPLEMENT_FUNCTION4(return_type, symbol, arg1, arg2, arg3, arg4) \
> + return_type symbol(arg1 _1, arg2 _2, arg3 _3, arg4 _4) \
> + { \
> + static return_type (*f)(arg1, arg2, arg3, arg4) = NULL; \
> + DLSYM(&f, #symbol); \
> + return f(_1, _2, _3, _4); }
> +
> +#define IMPLEMENT_FUNCTION6(return_type, symbol, arg1, arg2, arg3, arg4, arg5, arg6) \
> + return_type symbol(arg1 _1, arg2 _2, arg3 _3, arg4 _4, arg5 _5, arg6 _6) \
> + { \
> + static return_type (*f)(arg1, arg2, arg3, arg4, arg5, arg6) = NULL; \
> + DLSYM(&f, #symbol); \
> + return f(_1, _2, _3, _4, _5, _6); }
> +
> +#define IMPLEMENT_VOID_FUNCTION7(symbol, arg1, arg2, arg3, arg4, arg5, arg6, arg7) \
> + void symbol(arg1 _1, arg2 _2, arg3 _3, arg4 _4, arg5 _5, arg6 _6, arg7 _7) \
> + { \
> + static void (*f)(arg1, arg2, arg3, arg4, arg5, arg6, arg7) = NULL; \
> + DLSYM(&f, #symbol); \
> + f(_1, _2, _3, _4, _5, _6, _7); }
> +
> +#define IMPLEMENT_VOID_FUNCTION8(symbol, arg1, arg2, arg3, arg4, arg5, arg6, arg7, arg8) \
> + void symbol(arg1 _1, arg2 _2, arg3 _3, arg4 _4, arg5 _5, arg6 _6, arg7 _7, arg8 _8) \
> + { \
> + static void (*f)(arg1, arg2, arg3, arg4, arg5, arg6, arg7, arg8) = NULL; \
> + DLSYM(&f, #symbol); \
> + f(_1, _2, _3, _4, _5, _6, _7, _8); }
> +
> +#ifdef __cplusplus
> +}
> +#endif
> +
> +#endif // HYBRIS_BRIDGE_DEFS_H_
>
> === modified file 'src/ubuntu/application/base_module.h'
> --- src/ubuntu/application/base_module.h 2014-11-14 15:30:22 +0000
> +++ src/ubuntu/application/base_module.h 2015-01-21 15:47:57 +0000
> @@ -28,7 +28,7 @@
> */
>
> #define API_VERSION_MAJOR "2"
> -#define API_VERSION_MINOR "6"
> +#define API_VERSION_MINOR "7"
> #define API_VERSION_PATCH "0"
> #define SO_SUFFIX ".so." API_VERSION_MAJOR "." API_VERSION_MINOR "." API_VERSION_PATCH
>
> @@ -77,10 +77,23 @@
>
> return path;
> }
> +
> + static const char* override_path()
> + {
> + // Hardcoded for the testbackend
> + const char *testlib = "test";
> + static char path[64];
> +
> + strcpy(path, "libubuntu_application_api_");
> + strcat(path, testlib);
> + strcat(path, SO_SUFFIX);
> +
> + return path;
> + }
>
> static void exit_module(const char* msg)
> {
> - printf("Ubuntu Platform API: %s -- Aborting\n", msg);
> + fprintf(stderr, "Ubuntu Platform API: %s -- Aborting\n", msg);
> abort();
> }
>
> @@ -100,7 +113,7 @@
> };
> }
>
> -#define DLSYM(fptr, sym) if (*(fptr) == NULL) { *((void**)fptr) = (void *) internal::Bridge<internal::ToBackend>::instance().resolve_symbol(sym); }
> +#define DLSYM(fptr, sym, module) if (*(fptr) == NULL) { *((void**)fptr) = (void *) internal::Bridge<internal::ToBackend>::instance().resolve_symbol(sym, module); }
>
> #include <bridge_defs.h>
>
>
> === modified file 'src/ubuntu/application/desktop/module_version.h'
> --- src/ubuntu/application/desktop/module_version.h 2014-11-14 15:30:22 +0000
> +++ src/ubuntu/application/desktop/module_version.h 2015-01-21 15:47:57 +0000
> @@ -1,3 +1,3 @@
> #define MODULE_VERSION_MAJOR 2
> -#define MODULE_VERSION_MINOR 6
> +#define MODULE_VERSION_MINOR 7
> #define MODULE_VERSION_PATCH 0
>
> === modified file 'src/ubuntu/application/testbackend/module_version.h'
> --- src/ubuntu/application/testbackend/module_version.h 2014-11-14 15:30:22 +0000
> +++ src/ubuntu/application/testbackend/module_version.h 2015-01-21 15:47:57 +0000
> @@ -1,3 +1,3 @@
> #define MODULE_VERSION_MAJOR 2
> -#define MODULE_VERSION_MINOR 6
> +#define MODULE_VERSION_MINOR 7
> #define MODULE_VERSION_PATCH 0
>
> === modified file 'src/ubuntu/application/testbackend/ubuntu_application_sensors.cpp'
> --- src/ubuntu/application/testbackend/ubuntu_application_sensors.cpp 2014-06-24 14:00:24 +0000
> +++ src/ubuntu/application/testbackend/ubuntu_application_sensors.cpp 2015-01-21 15:47:57 +0000
> @@ -14,8 +14,14 @@
> * along with this program. If not, see <http://www.gnu.org/licenses/>.
> *
> * Authored by: Martin Pitt <martin.pitti at ubuntu.com>
> + * Ricardo Mendoza <ricardo.mendoza at canonical.com>
> */
>
> +#include <sys/types.h>
> +#include <sys/stat.h>
> +#include <unistd.h>
> +#include <fcntl.h>
> +
> #include <ubuntu/application/sensors/accelerometer.h>
> #include <ubuntu/application/sensors/proximity.h>
> #include <ubuntu/application/sensors/light.h>
> @@ -34,6 +40,9 @@
> #include <chrono>
> #include <map>
> #include <memory>
> +#include <mutex>
> +#include <condition_variable>
> +#include <thread>
>
> using namespace std;
>
> @@ -114,8 +123,20 @@
> }
>
> // Return TestSensor of given type, or NULL if it doesn't exist
> - TestSensor* get(ubuntu_sensor_type type)
> + TestSensor* get(ubuntu_sensor_type type, bool no_block = false)
> {
> + if (!no_block && dynamic) {
> + unique_lock<mutex> lk(create_mtx);
> + create_cv.wait(lk, [this, type]{
> + try {
> + sensors.at(type).get();
> + return true;
> + } catch (const out_of_range&) {
> + cerr << "TestSensor WARNING: Requested sensor " << name_from_type(type) << " not yet created, blocking thread until create event received" << endl;
> + return false;
> + }
> + });
> + }
> try {
> return sensors.at(type).get();
> } catch (const out_of_range&) {
> @@ -125,6 +146,8 @@
>
> private:
> SensorController();
> + ~SensorController();
> + bool fifo_take_command();
> bool next_command();
> bool process_create_command();
> void process_event_command();
> @@ -144,8 +167,30 @@
> abort();
> }
>
> + static const char* name_from_type(ubuntu_sensor_type type)
> + {
> + if (type == ubuntu_sensor_type_light)
> + return "light";
> + if (type == ubuntu_sensor_type_proximity)
> + return "proximity";
> + if (type == ubuntu_sensor_type_accelerometer)
> + return "accelerometer";
> +
> + return "ERROR_TYPE";
> + }
> +
> map<ubuntu_sensor_type, shared_ptr<TestSensor>> sensors;
> ifstream data;
> + bool dynamic;
> + int fifo_fd;
> + string fifo_path;
> + bool block;
> + condition_variable comm_cv;
> + mutex mtx;
> + thread worker;
> + condition_variable create_cv;
> + mutex create_mtx;
> + bool exit;
>
> // current command/event
> string current_command;
> @@ -155,31 +200,119 @@
> };
>
> SensorController::SensorController()
> + : dynamic(true),
> + fifo_fd(-1),
> + block(false),
> + exit(false)
> {
> const char* path = getenv("UBUNTU_PLATFORM_API_SENSOR_TEST");
> -
> - if (path == NULL) {
> - cerr << "TestSensor ERROR: Need $UBUNTU_PLATFORM_API_SENSOR_TEST to point to a data file\n";
> - abort();
> - }
> -
> - //cout << "SensorController ctor: opening " << path << endl;
> -
> - data.open(path);
> - if (!data.is_open()) {
> - cerr << "TestSensor ERROR: Failed to open data file " << path << ": " << strerror(errno) << endl;
> - abort();
> - }
> -
> - // process all "create" commands
> - while (next_command()) {
> - if (!process_create_command())
> + if (path != NULL)
> + dynamic = false;
> +
> + if (dynamic) {
I'd like to see a comment of what the main difference between dynamic and non-dynamic is. It would help this code a lot for another developer not familiar with this already.
> + // create named pipe for event injection
> + stringstream ss;
> + ss << "/tmp/sensor-fifo-" << getpid();
> + fifo_path = ss.str();
> +
> + int ret = mkfifo(fifo_path.c_str(), S_IFIFO | 0666);
> + if (ret < 0) {
> + cerr << "TestSensor ERROR: Failed to create named pipe at " << fifo_path << endl;
> + abort();
> + }
> +
> + fifo_fd = open(fifo_path.c_str(), O_RDWR);
> + if (fifo_fd < 0) {
> + cerr << "TestSensor ERROR: Failed to open named pipe at " << fifo_path << endl;
> + abort();
> + }
> + cout << "TestSensor INFO: Setup for DYNAMIC event injection over named pipe " << fifo_path << endl;
> +
> + worker = move(thread([this] {
> + while (fifo_take_command()) {
> + if (current_command.find("create") == string::npos)
> + process_event_command();
> + else
> + process_create_command();
> +
> + if (exit)
> + break;
> + }
> + }));
> + } else {
> + data.open(path);
> + if (!data.is_open()) {
> + cerr << "TestSensor ERROR: Failed to open data file " << path << ": " << strerror(errno) << endl;
> + abort();
> + }
> +
> + cout << "TestSensor INFO: Setup for STATIC event injection reading from " << path << endl;
> +
> + // process all "create" commands
> + while (next_command()) {
> + if (!process_create_command())
> + break;
> + }
> +
> + // start event processing
> + if (!data.eof())
> + process_event_command();
> + }
> +}
> +
> +SensorController::~SensorController()
> +{
> + if (dynamic) {
> + exit = true;
> + if (worker.joinable())
> + worker.join();
> +
> + unlink(fifo_path.c_str());
> + }
> +}
> +
> +bool
> +SensorController::fifo_take_command()
> +{
> + char buf;
> + int size;
> + string tmp = "";
> +
> + // block until last event has fired
> + unique_lock<mutex> lk(mtx);
> + comm_cv.wait(lk, [this] { if (block) { return false; } else { block = true; return true; }});
> +
> + tmp.clear();
> + while (read(fifo_fd, &buf, sizeof(char))) {
> + if (buf == '\n' || buf == '#')
> break;
> - }
> -
> - // start event processing
> - if (!data.eof())
> - process_event_command();
> + tmp.append(1, buf);
> + }
> + if (buf == '#') { // comment input (from piped file)
> + // consume rest of line
> + while (read(fifo_fd, &buf, sizeof(char))) {
> + if (buf == '\n')
> + break;
> + }
> + if (tmp.size() == 0) {
> + block = false;
> + return true;
> + }
> + }
> +
> + tmp.erase(0, tmp.find_first_not_of(" \t"));
> + tmp.erase(tmp.find_last_not_of(" \t") + 1);
> +
> + if (tmp.size() == 0)
> + return true;
> +
> + // if create command, dont block
> + if (tmp.find("create") != string::npos)
> + block = false;
> +
> + current_command = tmp;
> +
> + return true;
> }
>
> bool
> @@ -211,9 +344,9 @@
> ss >> token;
> ubuntu_sensor_type type = type_from_name(token);
>
> - if (get(type) != NULL) {
> + if (get(type, true) != NULL) {
> cerr << "TestSensor ERROR: duplicate creation of sensor type " << token << endl;
> - abort();
> + return false;
> }
>
> float min = 0, max = 0, resolution = 0;
> @@ -232,9 +365,8 @@
> }
> }
>
> - //cout << "SensorController::process_create_command: type " << type << " min " << min << " max " << max << " res " << resolution << endl;
> -
> sensors[type] = make_shared<TestSensor>(type, min, max, resolution);
> + create_cv.notify_all();
> return true;
> }
>
> @@ -257,7 +389,7 @@
> string token;
> ss >> token;
> ubuntu_sensor_type type = type_from_name(token);
> - event_sensor = get(type);
> + event_sensor = get(type, true);
> if (event_sensor == NULL) {
> cerr << "TestSensor ERROR: sensor does not exist, you need to create it: " << token << endl;
> abort();
> @@ -354,10 +486,15 @@
> }
>
> // read/process next event
> - if (sc.next_command())
> - sc.process_event_command();
> - else {
> - //cout << "TestSensor: script ended, no further commands\n";
> + if (sc.dynamic) {
> + sc.block = false;
> + sc.comm_cv.notify_one();
> + } else {
> + if (sc.next_command())
> + sc.process_event_command();
> + else {
> + //cout << "TestSensor: script ended, no further commands\n";
> + }
> }
> }
>
>
> === modified file 'src/ubuntu/application/touch/hybris/hybris_module.h'
> --- src/ubuntu/application/touch/hybris/hybris_module.h 2014-05-21 08:16:14 +0000
> +++ src/ubuntu/application/touch/hybris/hybris_module.h 2015-01-21 15:47:57 +0000
> @@ -42,6 +42,11 @@
> return cache;
> }
>
> + static const char* override_path()
> + {
> + return NULL;
> + }
> +
> static void* dlopen_fn(const char* path, int flags)
> {
> return android_dlopen(path, flags);
> @@ -56,6 +61,6 @@
>
> #define DLSYM(fptr, sym) if (*(fptr) == NULL) { *((void**)fptr) = (void *) internal::Bridge<internal::ToHybris>::instance().resolve_symbol(sym); }
>
> -#include <bridge_defs.h>
> +#include <hybris_bridge_defs.h>
>
> #endif // HYBRIS_MODULE_H_
>
> === modified file 'src/ubuntu/application/touch/module_version.h'
> --- src/ubuntu/application/touch/module_version.h 2014-11-14 15:30:22 +0000
> +++ src/ubuntu/application/touch/module_version.h 2015-01-21 15:47:57 +0000
> @@ -1,3 +1,3 @@
> #define MODULE_VERSION_MAJOR 2
> -#define MODULE_VERSION_MINOR 6
> +#define MODULE_VERSION_MINOR 7
> #define MODULE_VERSION_PATCH 0
>
> === modified file 'src/ubuntu/application/ubuntu_application_api.cpp'
> --- src/ubuntu/application/ubuntu_application_api.cpp 2014-09-29 19:56:49 +0000
> +++ src/ubuntu/application/ubuntu_application_api.cpp 2015-01-21 15:47:57 +0000
> @@ -46,207 +46,207 @@
> #endif
>
> // Application Module Config
> -IMPLEMENT_VOID_FUNCTION3(u_application_module_version, uint32_t*, uint32_t*, uint32_t*);
> -IMPLEMENT_VOID_FUNCTION1(u_application_init, void*);
> -IMPLEMENT_VOID_FUNCTION0(u_application_finish);
> +IMPLEMENT_VOID_FUNCTION3(init, u_application_module_version, uint32_t*, uint32_t*, uint32_t*);
> +IMPLEMENT_VOID_FUNCTION1(init, u_application_init, void*);
> +IMPLEMENT_VOID_FUNCTION0(init, u_application_finish);
>
> // Session helpers
> -IMPLEMENT_FUNCTION0(UAUiSessionProperties*, ua_ui_session_properties_new);
> -IMPLEMENT_VOID_FUNCTION2(ua_ui_session_properties_set_type, UAUiSessionProperties*, UAUiSessionType);
> -IMPLEMENT_VOID_FUNCTION2(ua_ui_session_properties_set_remote_pid, UAUiSessionProperties*, uint32_t);
> -IMPLEMENT_FUNCTION1(UAUiSession*, ua_ui_session_new_with_properties, UAUiSessionProperties*);
> +IMPLEMENT_FUNCTION0(session, UAUiSessionProperties*, ua_ui_session_properties_new);
> +IMPLEMENT_VOID_FUNCTION2(session, ua_ui_session_properties_set_type, UAUiSessionProperties*, UAUiSessionType);
> +IMPLEMENT_VOID_FUNCTION2(session, ua_ui_session_properties_set_remote_pid, UAUiSessionProperties*, uint32_t);
> +IMPLEMENT_FUNCTION1(session, UAUiSession*, ua_ui_session_new_with_properties, UAUiSessionProperties*);
>
> // Lifecycle helpers
> -IMPLEMENT_FUNCTION0(UApplicationLifecycleDelegate*, u_application_lifecycle_delegate_new);
> -IMPLEMENT_VOID_FUNCTION2(u_application_lifecycle_delegate_set_context, UApplicationLifecycleDelegate*, void*);
> -IMPLEMENT_VOID_FUNCTION1(u_application_lifecycle_delegate_ref, UApplicationLifecycleDelegate*);
> -IMPLEMENT_VOID_FUNCTION1(u_application_lifecycle_delegate_unref, UApplicationLifecycleDelegate*);
> -IMPLEMENT_VOID_FUNCTION2(u_application_lifecycle_delegate_set_application_resumed_cb, UApplicationLifecycleDelegate*, u_on_application_resumed);
> -IMPLEMENT_VOID_FUNCTION2(u_application_lifecycle_delegate_set_application_about_to_stop_cb, UApplicationLifecycleDelegate*, u_on_application_about_to_stop);
> +IMPLEMENT_FUNCTION0(lifecycle, UApplicationLifecycleDelegate*, u_application_lifecycle_delegate_new);
> +IMPLEMENT_VOID_FUNCTION2(lifecycle, u_application_lifecycle_delegate_set_context, UApplicationLifecycleDelegate*, void*);
> +IMPLEMENT_VOID_FUNCTION1(lifecycle, u_application_lifecycle_delegate_ref, UApplicationLifecycleDelegate*);
> +IMPLEMENT_VOID_FUNCTION1(lifecycle, u_application_lifecycle_delegate_unref, UApplicationLifecycleDelegate*);
> +IMPLEMENT_VOID_FUNCTION2(lifecycle, u_application_lifecycle_delegate_set_application_resumed_cb, UApplicationLifecycleDelegate*, u_on_application_resumed);
> +IMPLEMENT_VOID_FUNCTION2(lifecycle, u_application_lifecycle_delegate_set_application_about_to_stop_cb, UApplicationLifecycleDelegate*, u_on_application_about_to_stop);
>
> -// Application Helpers
> +// Application Instance Helpers
>
> // UApplicationId
> -IMPLEMENT_FUNCTION2(UApplicationId*, u_application_id_new_from_stringn, const char*, size_t);
> -IMPLEMENT_VOID_FUNCTION1(u_application_id_destroy, UApplicationId*);
> -IMPLEMENT_FUNCTION2(int, u_application_id_compare, UApplicationId*, UApplicationId*);
> +IMPLEMENT_FUNCTION2(instance, UApplicationId*, u_application_id_new_from_stringn, const char*, size_t);
> +IMPLEMENT_VOID_FUNCTION1(instance, u_application_id_destroy, UApplicationId*);
> +IMPLEMENT_FUNCTION2(instance, int, u_application_id_compare, UApplicationId*, UApplicationId*);
>
> // UApplicationDescription
> -IMPLEMENT_FUNCTION0(UApplicationDescription*, u_application_description_new);
> -IMPLEMENT_VOID_FUNCTION1(u_application_description_destroy, UApplicationDescription*);
> -IMPLEMENT_VOID_FUNCTION2(u_application_description_set_application_id, UApplicationDescription*, UApplicationId*);
> -IMPLEMENT_VOID_FUNCTION2(u_application_description_set_application_lifecycle_delegate, UApplicationDescription*, UApplicationLifecycleDelegate*);
> +IMPLEMENT_FUNCTION0(instance, UApplicationDescription*, u_application_description_new);
> +IMPLEMENT_VOID_FUNCTION1(instance, u_application_description_destroy, UApplicationDescription*);
> +IMPLEMENT_VOID_FUNCTION2(instance, u_application_description_set_application_id, UApplicationDescription*, UApplicationId*);
> +IMPLEMENT_VOID_FUNCTION2(instance, u_application_description_set_application_lifecycle_delegate, UApplicationDescription*, UApplicationLifecycleDelegate*);
>
> // UApplicationOptions
> -IMPLEMENT_FUNCTION2(UApplicationOptions*, u_application_options_new_from_cmd_line, int, char**);
> -IMPLEMENT_VOID_FUNCTION1(u_application_options_destroy, UApplicationOptions*);
> -IMPLEMENT_FUNCTION1(UAUiFormFactor, u_application_options_get_form_factor, UApplicationOptions*);
> -IMPLEMENT_FUNCTION1(UAUiStage, u_application_options_get_stage, UApplicationOptions*);
> +IMPLEMENT_FUNCTION2(instance, UApplicationOptions*, u_application_options_new_from_cmd_line, int, char**);
> +IMPLEMENT_VOID_FUNCTION1(instance, u_application_options_destroy, UApplicationOptions*);
> +IMPLEMENT_FUNCTION1(instance, UAUiFormFactor, u_application_options_get_form_factor, UApplicationOptions*);
> +IMPLEMENT_FUNCTION1(instance, UAUiStage, u_application_options_get_stage, UApplicationOptions*);
>
> // UApplicationInstance
> -IMPLEMENT_FUNCTION2(UApplicationInstance*, u_application_instance_new_from_description_with_options, UApplicationDescription*, UApplicationOptions*);
> +IMPLEMENT_FUNCTION2(instance, UApplicationInstance*, u_application_instance_new_from_description_with_options, UApplicationDescription*, UApplicationOptions*);
>
> // Application Ui Helpers
>
> // Clipboard
> -IMPLEMENT_VOID_FUNCTION2(ua_ui_set_clipboard_content, void*, size_t);
> -IMPLEMENT_VOID_FUNCTION2(ua_ui_get_clipboard_content, void**, size_t*);
> +IMPLEMENT_VOID_FUNCTION2(clipboard, ua_ui_set_clipboard_content, void*, size_t);
> +IMPLEMENT_VOID_FUNCTION2(clipboard, ua_ui_get_clipboard_content, void**, size_t*);
>
> // UAUiDisplay
> -IMPLEMENT_FUNCTION1(UAUiDisplay*, ua_ui_display_new_with_index, size_t);
> -IMPLEMENT_VOID_FUNCTION1(ua_ui_display_destroy, UAUiDisplay*);
> -IMPLEMENT_FUNCTION1(uint32_t, ua_ui_display_query_horizontal_res, UAUiDisplay*);
> -IMPLEMENT_FUNCTION1(uint32_t, ua_ui_display_query_vertical_res, UAUiDisplay*);
> -IMPLEMENT_FUNCTION1(EGLNativeDisplayType, ua_ui_display_get_native_type, UAUiDisplay*);
> +IMPLEMENT_FUNCTION1(ui_display, UAUiDisplay*, ua_ui_display_new_with_index, size_t);
> +IMPLEMENT_VOID_FUNCTION1(ui_display, ua_ui_display_destroy, UAUiDisplay*);
> +IMPLEMENT_FUNCTION1(ui_display, uint32_t, ua_ui_display_query_horizontal_res, UAUiDisplay*);
> +IMPLEMENT_FUNCTION1(ui_display, uint32_t, ua_ui_display_query_vertical_res, UAUiDisplay*);
> +IMPLEMENT_FUNCTION1(ui_display, EGLNativeDisplayType, ua_ui_display_get_native_type, UAUiDisplay*);
>
>
> // UAUiWindowProperties
> -IMPLEMENT_FUNCTION0(UAUiWindowProperties*, ua_ui_window_properties_new_for_normal_window);
> -IMPLEMENT_VOID_FUNCTION1(ua_ui_window_properties_destroy, UAUiWindowProperties*);
> -IMPLEMENT_VOID_FUNCTION3(ua_ui_window_properties_set_titlen, UAUiWindowProperties*, const char*, size_t);
> -IMPLEMENT_FUNCTION1(const char*, ua_ui_window_properties_get_title, UAUiWindowProperties*);
> -IMPLEMENT_VOID_FUNCTION2(ua_ui_window_properties_set_role, UAUiWindowProperties*, UAUiWindowRole);
> -IMPLEMENT_VOID_FUNCTION3(ua_ui_window_properties_set_input_cb_and_ctx, UAUiWindowProperties*, UAUiWindowInputEventCb, void*);
> -IMPLEMENT_VOID_FUNCTION3(ua_ui_window_properties_set_event_cb_and_ctx, UAUiWindowProperties*, UAUiWindowEventCb, void*);
> -IMPLEMENT_VOID_FUNCTION3(ua_ui_window_properties_set_dimensions, UAUiWindowProperties*, uint32_t, uint32_t);
> +IMPLEMENT_FUNCTION0(ui_window, UAUiWindowProperties*, ua_ui_window_properties_new_for_normal_window);
> +IMPLEMENT_VOID_FUNCTION1(ui_window, ua_ui_window_properties_destroy, UAUiWindowProperties*);
> +IMPLEMENT_VOID_FUNCTION3(ui_window, ua_ui_window_properties_set_titlen, UAUiWindowProperties*, const char*, size_t);
> +IMPLEMENT_FUNCTION1(ui_window, const char*, ua_ui_window_properties_get_title, UAUiWindowProperties*);
> +IMPLEMENT_VOID_FUNCTION2(ui_window, ua_ui_window_properties_set_role, UAUiWindowProperties*, UAUiWindowRole);
> +IMPLEMENT_VOID_FUNCTION3(ui_window, ua_ui_window_properties_set_input_cb_and_ctx, UAUiWindowProperties*, UAUiWindowInputEventCb, void*);
> +IMPLEMENT_VOID_FUNCTION3(ui_window, ua_ui_window_properties_set_event_cb_and_ctx, UAUiWindowProperties*, UAUiWindowEventCb, void*);
> +IMPLEMENT_VOID_FUNCTION3(ui_window, ua_ui_window_properties_set_dimensions, UAUiWindowProperties*, uint32_t, uint32_t);
>
> // UAUiWindow
> -IMPLEMENT_FUNCTION2(UAUiWindow*, ua_ui_window_new_for_application_with_properties, UApplicationInstance*, UAUiWindowProperties*);
> -IMPLEMENT_VOID_FUNCTION1(ua_ui_window_destroy, UAUiWindow*);
> -IMPLEMENT_VOID_FUNCTION3(ua_ui_window_get_size, UAUiWindow*, uint32_t*, uint32_t*);
> -IMPLEMENT_FUNCTION1(int, ua_ui_window_is_focused, UAUiWindow*);
> -IMPLEMENT_FUNCTION3(UStatus, ua_ui_window_move, UAUiWindow*, uint32_t, uint32_t);
> -IMPLEMENT_FUNCTION3(UStatus, ua_ui_window_resize, UAUiWindow*, uint32_t, uint32_t);
> -IMPLEMENT_FUNCTION1(UStatus, ua_ui_window_hide, UAUiWindow*);
> -IMPLEMENT_FUNCTION1(UStatus, ua_ui_window_show, UAUiWindow*);
> -IMPLEMENT_VOID_FUNCTION1(ua_ui_window_request_fullscreen, UAUiWindow*);
> -IMPLEMENT_FUNCTION1(EGLNativeWindowType, ua_ui_window_get_native_type, UAUiWindow*);
> -IMPLEMENT_FUNCTION1(UApplicationUiWindowOrientation, ua_ui_window_get_orientation, UAUiWindow*);
> -IMPLEMENT_FUNCTION2(void, ua_ui_window_request_state, UAUiWindow*, UApplicationUiWindowState);
> +IMPLEMENT_FUNCTION2(ui_window, UAUiWindow*, ua_ui_window_new_for_application_with_properties, UApplicationInstance*, UAUiWindowProperties*);
> +IMPLEMENT_VOID_FUNCTION1(ui_window, ua_ui_window_destroy, UAUiWindow*);
> +IMPLEMENT_VOID_FUNCTION3(ui_window, ua_ui_window_get_size, UAUiWindow*, uint32_t*, uint32_t*);
> +IMPLEMENT_FUNCTION1(ui_window, int, ua_ui_window_is_focused, UAUiWindow*);
> +IMPLEMENT_FUNCTION3(ui_window, UStatus, ua_ui_window_move, UAUiWindow*, uint32_t, uint32_t);
> +IMPLEMENT_FUNCTION3(ui_window, UStatus, ua_ui_window_resize, UAUiWindow*, uint32_t, uint32_t);
> +IMPLEMENT_FUNCTION1(ui_window, UStatus, ua_ui_window_hide, UAUiWindow*);
> +IMPLEMENT_FUNCTION1(ui_window, UStatus, ua_ui_window_show, UAUiWindow*);
> +IMPLEMENT_VOID_FUNCTION1(ui_window, ua_ui_window_request_fullscreen, UAUiWindow*);
> +IMPLEMENT_FUNCTION1(ui_window, EGLNativeWindowType, ua_ui_window_get_native_type, UAUiWindow*);
> +IMPLEMENT_FUNCTION1(ui_window, UApplicationUiWindowOrientation, ua_ui_window_get_orientation, UAUiWindow*);
> +IMPLEMENT_FUNCTION2(ui_window, void, ua_ui_window_request_state, UAUiWindow*, UApplicationUiWindowState);
>
> // Ubuntu Application Sensors
>
> // Acceleration Sensor
> -IMPLEMENT_CTOR0(UASensorsAccelerometer*, ua_sensors_accelerometer_new);
> -IMPLEMENT_FUNCTION1(UStatus, ua_sensors_accelerometer_enable, UASensorsAccelerometer*);
> -IMPLEMENT_FUNCTION1(UStatus, ua_sensors_accelerometer_disable, UASensorsAccelerometer*);
> -IMPLEMENT_FUNCTION1(uint32_t, ua_sensors_accelerometer_get_min_delay, UASensorsAccelerometer*);
> -IMPLEMENT_FUNCTION2(UStatus, ua_sensors_accelerometer_get_min_value, UASensorsAccelerometer*, float*);
> -IMPLEMENT_FUNCTION2(UStatus, ua_sensors_accelerometer_get_max_value, UASensorsAccelerometer*, float*);
> -IMPLEMENT_FUNCTION2(UStatus, ua_sensors_accelerometer_get_resolution, UASensorsAccelerometer*, float*);
> -IMPLEMENT_VOID_FUNCTION3(ua_sensors_accelerometer_set_reading_cb, UASensorsAccelerometer*, on_accelerometer_event_cb, void*);
> -IMPLEMENT_FUNCTION2(UStatus, ua_sensors_accelerometer_set_event_rate, UASensorsAccelerometer*, uint32_t);
> +IMPLEMENT_CTOR0(sensors, UASensorsAccelerometer*, ua_sensors_accelerometer_new);
> +IMPLEMENT_FUNCTION1(sensors, UStatus, ua_sensors_accelerometer_enable, UASensorsAccelerometer*);
> +IMPLEMENT_FUNCTION1(sensors, UStatus, ua_sensors_accelerometer_disable, UASensorsAccelerometer*);
> +IMPLEMENT_FUNCTION1(sensors, uint32_t, ua_sensors_accelerometer_get_min_delay, UASensorsAccelerometer*);
> +IMPLEMENT_FUNCTION2(sensors, UStatus, ua_sensors_accelerometer_get_min_value, UASensorsAccelerometer*, float*);
> +IMPLEMENT_FUNCTION2(sensors, UStatus, ua_sensors_accelerometer_get_max_value, UASensorsAccelerometer*, float*);
> +IMPLEMENT_FUNCTION2(sensors, UStatus, ua_sensors_accelerometer_get_resolution, UASensorsAccelerometer*, float*);
> +IMPLEMENT_VOID_FUNCTION3(sensors, ua_sensors_accelerometer_set_reading_cb, UASensorsAccelerometer*, on_accelerometer_event_cb, void*);
> +IMPLEMENT_FUNCTION2(sensors, UStatus, ua_sensors_accelerometer_set_event_rate, UASensorsAccelerometer*, uint32_t);
>
> // Acceleration Sensor Event
> -IMPLEMENT_FUNCTION1(uint64_t, uas_accelerometer_event_get_timestamp, UASAccelerometerEvent*);
> -IMPLEMENT_FUNCTION2(UStatus, uas_accelerometer_event_get_acceleration_x, UASAccelerometerEvent*, float*);
> -IMPLEMENT_FUNCTION2(UStatus, uas_accelerometer_event_get_acceleration_y, UASAccelerometerEvent*, float*);
> -IMPLEMENT_FUNCTION2(UStatus, uas_accelerometer_event_get_acceleration_z, UASAccelerometerEvent*, float*);
> +IMPLEMENT_FUNCTION1(sensors, uint64_t, uas_accelerometer_event_get_timestamp, UASAccelerometerEvent*);
> +IMPLEMENT_FUNCTION2(sensors, UStatus, uas_accelerometer_event_get_acceleration_x, UASAccelerometerEvent*, float*);
> +IMPLEMENT_FUNCTION2(sensors, UStatus, uas_accelerometer_event_get_acceleration_y, UASAccelerometerEvent*, float*);
> +IMPLEMENT_FUNCTION2(sensors, UStatus, uas_accelerometer_event_get_acceleration_z, UASAccelerometerEvent*, float*);
>
> // Proximity Sensor
> -IMPLEMENT_CTOR0(UASensorsProximity*, ua_sensors_proximity_new);
> -IMPLEMENT_FUNCTION1(UStatus, ua_sensors_proximity_enable, UASensorsProximity*);
> -IMPLEMENT_FUNCTION1(UStatus, ua_sensors_proximity_disable, UASensorsProximity*);
> -IMPLEMENT_FUNCTION1(uint32_t, ua_sensors_proximity_get_min_delay, UASensorsProximity*);
> -IMPLEMENT_FUNCTION2(UStatus, ua_sensors_proximity_get_min_value, UASensorsProximity*, float*);
> -IMPLEMENT_FUNCTION2(UStatus, ua_sensors_proximity_get_max_value, UASensorsProximity*, float*);
> -IMPLEMENT_FUNCTION2(UStatus, ua_sensors_proximity_get_resolution, UASensorsProximity*, float*);
> -IMPLEMENT_VOID_FUNCTION3(ua_sensors_proximity_set_reading_cb, UASensorsProximity*, on_proximity_event_cb, void*);
> -IMPLEMENT_FUNCTION2(UStatus, ua_sensors_proximity_set_event_rate, UASensorsProximity*, uint32_t);
> +IMPLEMENT_CTOR0(sensors, UASensorsProximity*, ua_sensors_proximity_new);
> +IMPLEMENT_FUNCTION1(sensors, UStatus, ua_sensors_proximity_enable, UASensorsProximity*);
> +IMPLEMENT_FUNCTION1(sensors, UStatus, ua_sensors_proximity_disable, UASensorsProximity*);
> +IMPLEMENT_FUNCTION1(sensors, uint32_t, ua_sensors_proximity_get_min_delay, UASensorsProximity*);
> +IMPLEMENT_FUNCTION2(sensors, UStatus, ua_sensors_proximity_get_min_value, UASensorsProximity*, float*);
> +IMPLEMENT_FUNCTION2(sensors, UStatus, ua_sensors_proximity_get_max_value, UASensorsProximity*, float*);
> +IMPLEMENT_FUNCTION2(sensors, UStatus, ua_sensors_proximity_get_resolution, UASensorsProximity*, float*);
> +IMPLEMENT_VOID_FUNCTION3(sensors, ua_sensors_proximity_set_reading_cb, UASensorsProximity*, on_proximity_event_cb, void*);
> +IMPLEMENT_FUNCTION2(sensors, UStatus, ua_sensors_proximity_set_event_rate, UASensorsProximity*, uint32_t);
>
> // Proximity Sensor Event
> -IMPLEMENT_FUNCTION1(uint64_t, uas_proximity_event_get_timestamp, UASProximityEvent*);
> -IMPLEMENT_FUNCTION1(UASProximityDistance, uas_proximity_event_get_distance, UASProximityEvent*);
> +IMPLEMENT_FUNCTION1(sensors, uint64_t, uas_proximity_event_get_timestamp, UASProximityEvent*);
> +IMPLEMENT_FUNCTION1(sensors, UASProximityDistance, uas_proximity_event_get_distance, UASProximityEvent*);
>
> // Ambient Light Sensor
> -IMPLEMENT_CTOR0(UASensorsLight*, ua_sensors_light_new);
> -IMPLEMENT_FUNCTION1(UStatus, ua_sensors_light_enable, UASensorsLight*);
> -IMPLEMENT_FUNCTION1(UStatus, ua_sensors_light_disable, UASensorsLight*);
> -IMPLEMENT_FUNCTION1(uint32_t, ua_sensors_light_get_min_delay, UASensorsLight*);
> -IMPLEMENT_FUNCTION2(UStatus, ua_sensors_light_get_min_value, UASensorsLight*, float*);
> -IMPLEMENT_FUNCTION2(UStatus, ua_sensors_light_get_max_value, UASensorsLight*, float*);
> -IMPLEMENT_FUNCTION2(UStatus, ua_sensors_light_get_resolution, UASensorsLight*, float*);
> -IMPLEMENT_VOID_FUNCTION3(ua_sensors_light_set_reading_cb, UASensorsLight*, on_light_event_cb, void*);
> -IMPLEMENT_FUNCTION2(UStatus, ua_sensors_light_set_event_rate, UASensorsLight*, uint32_t);
> +IMPLEMENT_CTOR0(sensors, UASensorsLight*, ua_sensors_light_new);
> +IMPLEMENT_FUNCTION1(sensors, UStatus, ua_sensors_light_enable, UASensorsLight*);
> +IMPLEMENT_FUNCTION1(sensors, UStatus, ua_sensors_light_disable, UASensorsLight*);
> +IMPLEMENT_FUNCTION1(sensors, uint32_t, ua_sensors_light_get_min_delay, UASensorsLight*);
> +IMPLEMENT_FUNCTION2(sensors, UStatus, ua_sensors_light_get_min_value, UASensorsLight*, float*);
> +IMPLEMENT_FUNCTION2(sensors, UStatus, ua_sensors_light_get_max_value, UASensorsLight*, float*);
> +IMPLEMENT_FUNCTION2(sensors, UStatus, ua_sensors_light_get_resolution, UASensorsLight*, float*);
> +IMPLEMENT_VOID_FUNCTION3(sensors, ua_sensors_light_set_reading_cb, UASensorsLight*, on_light_event_cb, void*);
> +IMPLEMENT_FUNCTION2(sensors, UStatus, ua_sensors_light_set_event_rate, UASensorsLight*, uint32_t);
>
> // Ambient Light Sensor Event
> -IMPLEMENT_FUNCTION1(uint64_t, uas_light_event_get_timestamp, UASLightEvent*);
> -IMPLEMENT_FUNCTION2(UStatus, uas_light_event_get_light, UASLightEvent*, float*);
> +IMPLEMENT_FUNCTION1(sensors, uint64_t, uas_light_event_get_timestamp, UASLightEvent*);
> +IMPLEMENT_FUNCTION2(sensors, UStatus, uas_light_event_get_light, UASLightEvent*, float*);
>
> // Haptic Sensor
> -IMPLEMENT_CTOR0(UASensorsHaptic*, ua_sensors_haptic_new);
> -IMPLEMENT_FUNCTION1(UStatus, ua_sensors_haptic_enable, UASensorsHaptic*);
> -IMPLEMENT_FUNCTION1(UStatus, ua_sensors_haptic_disable, UASensorsHaptic*);
> -IMPLEMENT_FUNCTION2(UStatus, ua_sensors_haptic_vibrate_once, UASensorsHaptic*, uint32_t);
> -IMPLEMENT_FUNCTION3(UStatus, ua_sensors_haptic_vibrate_with_pattern, UASensorsHaptic*, uint32_t*, uint32_t);
> +IMPLEMENT_CTOR0(sensors, UASensorsHaptic*, ua_sensors_haptic_new);
> +IMPLEMENT_FUNCTION1(sensors, UStatus, ua_sensors_haptic_enable, UASensorsHaptic*);
> +IMPLEMENT_FUNCTION1(sensors, UStatus, ua_sensors_haptic_disable, UASensorsHaptic*);
> +IMPLEMENT_FUNCTION2(sensors, UStatus, ua_sensors_haptic_vibrate_once, UASensorsHaptic*, uint32_t);
> +IMPLEMENT_FUNCTION3(sensors, UStatus, ua_sensors_haptic_vibrate_with_pattern, UASensorsHaptic*, uint32_t*, uint32_t);
>
> // Orientation Sensor
> -IMPLEMENT_CTOR0(UASensorsOrientation*, ua_sensors_orientation_new);
> -IMPLEMENT_FUNCTION1(UStatus, ua_sensors_orientation_enable, UASensorsOrientation*);
> -IMPLEMENT_FUNCTION1(UStatus, ua_sensors_orientation_disable, UASensorsOrientation*);
> -IMPLEMENT_FUNCTION1(uint32_t, ua_sensors_orientation_get_min_delay, UASensorsOrientation*);
> -IMPLEMENT_FUNCTION2(UStatus, ua_sensors_orientation_get_min_value, UASensorsOrientation*, float*);
> -IMPLEMENT_FUNCTION2(UStatus, ua_sensors_orientation_get_max_value, UASensorsOrientation*, float*);
> -IMPLEMENT_FUNCTION2(UStatus, ua_sensors_orientation_get_resolution, UASensorsOrientation*, float*);
> -IMPLEMENT_VOID_FUNCTION3(ua_sensors_orientation_set_reading_cb, UASensorsOrientation*, on_orientation_event_cb, void*);
> -IMPLEMENT_FUNCTION2(UStatus, ua_sensors_orientation_set_event_rate, UASensorsOrientation*, uint32_t);
> +IMPLEMENT_CTOR0(sensors, UASensorsOrientation*, ua_sensors_orientation_new);
> +IMPLEMENT_FUNCTION1(sensors, UStatus, ua_sensors_orientation_enable, UASensorsOrientation*);
> +IMPLEMENT_FUNCTION1(sensors, UStatus, ua_sensors_orientation_disable, UASensorsOrientation*);
> +IMPLEMENT_FUNCTION1(sensors, uint32_t, ua_sensors_orientation_get_min_delay, UASensorsOrientation*);
> +IMPLEMENT_FUNCTION2(sensors, UStatus, ua_sensors_orientation_get_min_value, UASensorsOrientation*, float*);
> +IMPLEMENT_FUNCTION2(sensors, UStatus, ua_sensors_orientation_get_max_value, UASensorsOrientation*, float*);
> +IMPLEMENT_FUNCTION2(sensors, UStatus, ua_sensors_orientation_get_resolution, UASensorsOrientation*, float*);
> +IMPLEMENT_VOID_FUNCTION3(sensors, ua_sensors_orientation_set_reading_cb, UASensorsOrientation*, on_orientation_event_cb, void*);
> +IMPLEMENT_FUNCTION2(sensors, UStatus, ua_sensors_orientation_set_event_rate, UASensorsOrientation*, uint32_t);
>
> // Orientation Sensor Event
> -IMPLEMENT_FUNCTION1(uint64_t, uas_orientation_event_get_timestamp, UASOrientationEvent*);
> -IMPLEMENT_FUNCTION2(UStatus, uas_orientation_event_get_azimuth, UASOrientationEvent*, float*);
> -IMPLEMENT_FUNCTION2(UStatus, uas_orientation_event_get_pitch, UASOrientationEvent*, float*);
> -IMPLEMENT_FUNCTION2(UStatus, uas_orientation_event_get_roll, UASOrientationEvent*, float*);
> +IMPLEMENT_FUNCTION1(sensors, uint64_t, uas_orientation_event_get_timestamp, UASOrientationEvent*);
> +IMPLEMENT_FUNCTION2(sensors, UStatus, uas_orientation_event_get_azimuth, UASOrientationEvent*, float*);
> +IMPLEMENT_FUNCTION2(sensors, UStatus, uas_orientation_event_get_pitch, UASOrientationEvent*, float*);
> +IMPLEMENT_FUNCTION2(sensors, UStatus, uas_orientation_event_get_roll, UASOrientationEvent*, float*);
>
> // Location
>
> -IMPLEMENT_VOID_FUNCTION1(ua_location_service_controller_ref, UALocationServiceController*);
> -IMPLEMENT_VOID_FUNCTION1(ua_location_service_controller_unref, UALocationServiceController*);
> -IMPLEMENT_VOID_FUNCTION3(ua_location_service_controller_set_status_changed_handler, UALocationServiceController*, UALocationServiceStatusChangedHandler, void*);
> -IMPLEMENT_FUNCTION2(UStatus, ua_location_service_controller_query_status, UALocationServiceController*, UALocationServiceStatusFlags*);
> -IMPLEMENT_FUNCTION1(UStatus, ua_location_service_controller_enable_service, UALocationServiceController*);
> -IMPLEMENT_FUNCTION1(UStatus, ua_location_service_controller_disable_service, UALocationServiceController*);
> -IMPLEMENT_FUNCTION1(UStatus, ua_location_service_controller_enable_gps, UALocationServiceController*);
> -IMPLEMENT_FUNCTION1(UStatus, ua_location_service_controller_disable_gps, UALocationServiceController*);
> -IMPLEMENT_VOID_FUNCTION1(ua_location_heading_update_ref, UALocationHeadingUpdate*);
> -IMPLEMENT_VOID_FUNCTION1(ua_location_heading_update_unref, UALocationHeadingUpdate*);
> -IMPLEMENT_FUNCTION1(uint64_t, ua_location_heading_update_get_timestamp, UALocationHeadingUpdate*);
> -IMPLEMENT_FUNCTION1(double, ua_location_heading_update_get_heading_in_degree, UALocationHeadingUpdate*);
> -IMPLEMENT_VOID_FUNCTION1(ua_location_position_update_ref, UALocationPositionUpdate*);
> -IMPLEMENT_VOID_FUNCTION1(ua_location_position_update_unref, UALocationPositionUpdate*);
> -IMPLEMENT_FUNCTION1(uint64_t, ua_location_position_update_get_timestamp, UALocationPositionUpdate*);
> -IMPLEMENT_FUNCTION1(double, ua_location_position_update_get_latitude_in_degree, UALocationPositionUpdate*);
> -IMPLEMENT_FUNCTION1(double, ua_location_position_update_get_longitude_in_degree, UALocationPositionUpdate*);
> -IMPLEMENT_FUNCTION1(bool, ua_location_position_update_has_altitude, UALocationPositionUpdate*);
> -IMPLEMENT_FUNCTION1(double, ua_location_position_update_get_altitude_in_meter, UALocationPositionUpdate*);
> -IMPLEMENT_FUNCTION1(bool, ua_location_position_update_has_horizontal_accuracy, UALocationPositionUpdate*);
> -IMPLEMENT_FUNCTION1(double, ua_location_position_update_get_horizontal_accuracy_in_meter, UALocationPositionUpdate*);
> -IMPLEMENT_FUNCTION1(bool, ua_location_position_update_has_vertical_accuracy, UALocationPositionUpdate*);
> -IMPLEMENT_FUNCTION1(double, ua_location_position_update_get_vertical_accuracy_in_meter, UALocationPositionUpdate*);
> -IMPLEMENT_FUNCTION1(UALocationServiceSession*, ua_location_service_create_session_for_low_accuracy, UALocationServiceRequirementsFlags);
> -IMPLEMENT_FUNCTION2(UALocationServiceSession*, ua_location_service_try_create_session_for_low_accuracy, UALocationServiceRequirementsFlags, UALocationServiceError*);
> -IMPLEMENT_FUNCTION1(UALocationServiceSession*, ua_location_service_create_session_for_high_accuracy, UALocationServiceRequirementsFlags);
> -IMPLEMENT_FUNCTION2(UALocationServiceSession*, ua_location_service_try_create_session_for_high_accuracy, UALocationServiceRequirementsFlags, UALocationServiceError*);
> -IMPLEMENT_CTOR0(UALocationServiceController*, ua_location_service_create_controller);
> -IMPLEMENT_VOID_FUNCTION1(ua_location_service_session_ref, UALocationServiceSession*);
> -IMPLEMENT_VOID_FUNCTION1(ua_location_service_session_unref, UALocationServiceSession*);
> -IMPLEMENT_VOID_FUNCTION3(ua_location_service_session_set_position_updates_handler, UALocationServiceSession*, UALocationServiceSessionPositionUpdatesHandler, void*);
> -IMPLEMENT_VOID_FUNCTION3(ua_location_service_session_set_heading_updates_handler, UALocationServiceSession*, UALocationServiceSessionHeadingUpdatesHandler, void*);
> -IMPLEMENT_VOID_FUNCTION3(ua_location_service_session_set_velocity_updates_handler, UALocationServiceSession*, UALocationServiceSessionVelocityUpdatesHandler, void*);
> -IMPLEMENT_FUNCTION1(UStatus, ua_location_service_session_start_position_updates, UALocationServiceSession*);
> -IMPLEMENT_VOID_FUNCTION1(ua_location_service_session_stop_position_updates, UALocationServiceSession*);
> -IMPLEMENT_FUNCTION1(UStatus, ua_location_service_session_start_heading_updates, UALocationServiceSession*);
> -IMPLEMENT_VOID_FUNCTION1(ua_location_service_session_stop_heading_updates, UALocationServiceSession*);
> -IMPLEMENT_FUNCTION1(UStatus, ua_location_service_session_start_velocity_updates, UALocationServiceSession*);
> -IMPLEMENT_VOID_FUNCTION1(ua_location_service_session_stop_velocity_updates, UALocationServiceSession*);
> -IMPLEMENT_VOID_FUNCTION1(ua_location_velocity_update_ref, UALocationVelocityUpdate*);
> -IMPLEMENT_VOID_FUNCTION1(ua_location_velocity_update_unref, UALocationVelocityUpdate*);
> -IMPLEMENT_FUNCTION1(uint64_t, ua_location_velocity_update_get_timestamp, UALocationVelocityUpdate*);
> -IMPLEMENT_FUNCTION1(double, ua_location_velocity_update_get_velocity_in_meters_per_second, UALocationVelocityUpdate*);
> +IMPLEMENT_VOID_FUNCTION1(location, ua_location_service_controller_ref, UALocationServiceController*);
> +IMPLEMENT_VOID_FUNCTION1(location, ua_location_service_controller_unref, UALocationServiceController*);
> +IMPLEMENT_VOID_FUNCTION3(location, ua_location_service_controller_set_status_changed_handler, UALocationServiceController*, UALocationServiceStatusChangedHandler, void*);
> +IMPLEMENT_FUNCTION2(location, UStatus, ua_location_service_controller_query_status, UALocationServiceController*, UALocationServiceStatusFlags*);
> +IMPLEMENT_FUNCTION1(location, UStatus, ua_location_service_controller_enable_service, UALocationServiceController*);
> +IMPLEMENT_FUNCTION1(location, UStatus, ua_location_service_controller_disable_service, UALocationServiceController*);
> +IMPLEMENT_FUNCTION1(location, UStatus, ua_location_service_controller_enable_gps, UALocationServiceController*);
> +IMPLEMENT_FUNCTION1(location, UStatus, ua_location_service_controller_disable_gps, UALocationServiceController*);
> +IMPLEMENT_VOID_FUNCTION1(location, ua_location_heading_update_ref, UALocationHeadingUpdate*);
> +IMPLEMENT_VOID_FUNCTION1(location, ua_location_heading_update_unref, UALocationHeadingUpdate*);
> +IMPLEMENT_FUNCTION1(location, uint64_t, ua_location_heading_update_get_timestamp, UALocationHeadingUpdate*);
> +IMPLEMENT_FUNCTION1(location, double, ua_location_heading_update_get_heading_in_degree, UALocationHeadingUpdate*);
> +IMPLEMENT_VOID_FUNCTION1(location, ua_location_position_update_ref, UALocationPositionUpdate*);
> +IMPLEMENT_VOID_FUNCTION1(location, ua_location_position_update_unref, UALocationPositionUpdate*);
> +IMPLEMENT_FUNCTION1(location, uint64_t, ua_location_position_update_get_timestamp, UALocationPositionUpdate*);
> +IMPLEMENT_FUNCTION1(location, double, ua_location_position_update_get_latitude_in_degree, UALocationPositionUpdate*);
> +IMPLEMENT_FUNCTION1(location, double, ua_location_position_update_get_longitude_in_degree, UALocationPositionUpdate*);
> +IMPLEMENT_FUNCTION1(location, bool, ua_location_position_update_has_altitude, UALocationPositionUpdate*);
> +IMPLEMENT_FUNCTION1(location, double, ua_location_position_update_get_altitude_in_meter, UALocationPositionUpdate*);
> +IMPLEMENT_FUNCTION1(location, bool, ua_location_position_update_has_horizontal_accuracy, UALocationPositionUpdate*);
> +IMPLEMENT_FUNCTION1(location, double, ua_location_position_update_get_horizontal_accuracy_in_meter, UALocationPositionUpdate*);
> +IMPLEMENT_FUNCTION1(location, bool, ua_location_position_update_has_vertical_accuracy, UALocationPositionUpdate*);
> +IMPLEMENT_FUNCTION1(location, double, ua_location_position_update_get_vertical_accuracy_in_meter, UALocationPositionUpdate*);
> +IMPLEMENT_FUNCTION1(location, UALocationServiceSession*, ua_location_service_create_session_for_low_accuracy, UALocationServiceRequirementsFlags);
> +IMPLEMENT_FUNCTION2(location, UALocationServiceSession*, ua_location_service_try_create_session_for_low_accuracy, UALocationServiceRequirementsFlags, UALocationServiceError*);
> +IMPLEMENT_FUNCTION1(location, UALocationServiceSession*, ua_location_service_create_session_for_high_accuracy, UALocationServiceRequirementsFlags);
> +IMPLEMENT_FUNCTION2(location, UALocationServiceSession*, ua_location_service_try_create_session_for_high_accuracy, UALocationServiceRequirementsFlags, UALocationServiceError*);
> +IMPLEMENT_CTOR0(location, UALocationServiceController*, ua_location_service_create_controller);
> +IMPLEMENT_VOID_FUNCTION1(location, ua_location_service_session_ref, UALocationServiceSession*);
> +IMPLEMENT_VOID_FUNCTION1(location, ua_location_service_session_unref, UALocationServiceSession*);
> +IMPLEMENT_VOID_FUNCTION3(location, ua_location_service_session_set_position_updates_handler, UALocationServiceSession*, UALocationServiceSessionPositionUpdatesHandler, void*);
> +IMPLEMENT_VOID_FUNCTION3(location, ua_location_service_session_set_heading_updates_handler, UALocationServiceSession*, UALocationServiceSessionHeadingUpdatesHandler, void*);
> +IMPLEMENT_VOID_FUNCTION3(location, ua_location_service_session_set_velocity_updates_handler, UALocationServiceSession*, UALocationServiceSessionVelocityUpdatesHandler, void*);
> +IMPLEMENT_FUNCTION1(location, UStatus, ua_location_service_session_start_position_updates, UALocationServiceSession*);
> +IMPLEMENT_VOID_FUNCTION1(location, ua_location_service_session_stop_position_updates, UALocationServiceSession*);
> +IMPLEMENT_FUNCTION1(location, UStatus, ua_location_service_session_start_heading_updates, UALocationServiceSession*);
> +IMPLEMENT_VOID_FUNCTION1(location, ua_location_service_session_stop_heading_updates, UALocationServiceSession*);
> +IMPLEMENT_FUNCTION1(location, UStatus, ua_location_service_session_start_velocity_updates, UALocationServiceSession*);
> +IMPLEMENT_VOID_FUNCTION1(location, ua_location_service_session_stop_velocity_updates, UALocationServiceSession*);
> +IMPLEMENT_VOID_FUNCTION1(location, ua_location_velocity_update_ref, UALocationVelocityUpdate*);
> +IMPLEMENT_VOID_FUNCTION1(location, ua_location_velocity_update_unref, UALocationVelocityUpdate*);
> +IMPLEMENT_FUNCTION1(location, uint64_t, ua_location_velocity_update_get_timestamp, UALocationVelocityUpdate*);
> +IMPLEMENT_FUNCTION1(location, double, ua_location_velocity_update_get_velocity_in_meters_per_second, UALocationVelocityUpdate*);
>
> // URL Dispatcher
>
> -IMPLEMENT_CTOR0(UAUrlDispatcherSession*, ua_url_dispatcher_session);
> -IMPLEMENT_VOID_FUNCTION4(ua_url_dispatcher_session_open, UAUrlDispatcherSession*, const char*, UAUrlDispatcherSessionDispatchHandler, void*);
> +IMPLEMENT_CTOR0(url_dispatcher, UAUrlDispatcherSession*, ua_url_dispatcher_session);
> +IMPLEMENT_VOID_FUNCTION4(url_dispatcher, ua_url_dispatcher_session_open, UAUrlDispatcherSession*, const char*, UAUrlDispatcherSessionDispatchHandler, void*);
>
> #ifdef __cplusplus
> }
>
> === modified file 'src/ubuntu/hardware/android_hw_module.h'
> --- src/ubuntu/hardware/android_hw_module.h 2014-05-22 07:27:16 +0000
> +++ src/ubuntu/hardware/android_hw_module.h 2015-01-21 15:47:57 +0000
> @@ -42,6 +42,11 @@
> return cache;
> }
>
> + static const char* override_path()
> + {
> + return NULL;
> + }
> +
> static void* dlopen_fn(const char* path, int flags)
> {
> return android_dlopen(path, flags);
> @@ -56,6 +61,6 @@
>
> #define DLSYM(fptr, sym) if (*(fptr) == NULL) { *((void**)fptr) = (void *) internal::Bridge<internal::ToHybris>::instance().resolve_symbol(sym); }
>
> -#include <bridge_defs.h>
> +#include <hybris_bridge_defs.h>
>
> #endif // ANDROID_HW_MODULE_H_
>
--
https://code.launchpad.net/~ricmm/platform-api/module-override-and-sensor-events/+merge/247162
Your team Ubuntu Phablet Team is subscribed to branch lp:platform-api.
More information about the Ubuntu-reviews
mailing list