You've already forked android_translation_layer
mirror of
https://gitlab.com/android_translation_layer/android_translation_layer.git
synced 2025-10-27 11:48:10 -07:00
src/libandroid: Add actual implementations for the stubbed ALooper functions
this was actually surprisingly easy, since it turns out these are just C ABI wrappers around the C++ class android::Looper from AOSP libutils.so, which is a dependency for art that we therefore compile and distribute alongside it
This commit is contained in:
@@ -1,22 +1,39 @@
|
|||||||
#include <stddef.h>
|
#include <stddef.h>
|
||||||
|
#include <stdio.h>
|
||||||
|
|
||||||
struct ALooper {
|
typedef void ALooper;
|
||||||
int dummy;
|
typedef int (*Looper_callbackFunc)(int fd, int events, void* data);
|
||||||
};
|
|
||||||
|
|
||||||
struct ALooper a_looper;
|
void _ZN7android6Looper12getForThreadEv(void **ret); // no clue why itanium ABI does this with return values
|
||||||
|
ALooper * ALooper_forThread()
|
||||||
struct ALooper* ALooper_forThread()
|
|
||||||
{
|
{
|
||||||
return &a_looper;
|
void *ret;
|
||||||
|
_ZN7android6Looper12getForThreadEv(&ret);
|
||||||
|
return ret;
|
||||||
}
|
}
|
||||||
|
|
||||||
struct ALooper* ALooper_prepare(int opts)
|
void _ZN7android6Looper7prepareEi(void **ret, int opts); // no clue why itanium ABI does this with return values
|
||||||
|
ALooper * ALooper_prepare(int opts)
|
||||||
{
|
{
|
||||||
return NULL;
|
void *ret;
|
||||||
|
_ZN7android6Looper7prepareEi(&ret, opts);
|
||||||
|
return ret;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
int _ZN7android6Looper7pollAllEiPiS1_PPv(void *this, int timeoutMillis, int* outFd, int* outEvents, void** outData);
|
||||||
int ALooper_pollAll(int timeoutMillis, int* outFd, int* outEvents, void** outData)
|
int ALooper_pollAll(int timeoutMillis, int* outFd, int* outEvents, void** outData)
|
||||||
{
|
{
|
||||||
return 0;
|
ALooper *looper = ALooper_forThread();
|
||||||
|
if(!looper) {
|
||||||
|
fprintf(stderr, "ALooper_pollAll: ALooper_forThread returned NULL\n");
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
return _ZN7android6Looper7pollAllEiPiS1_PPv(looper, timeoutMillis, outFd, outEvents, outData);
|
||||||
|
}
|
||||||
|
|
||||||
|
int _ZN7android6Looper5addFdEiiiPFiiiPvES1_(void *this, int fd, int ident, int events, Looper_callbackFunc callback, void* data);
|
||||||
|
int ALooper_addFd(ALooper* looper, int fd, int ident, int events, Looper_callbackFunc callback, void* data)
|
||||||
|
{
|
||||||
|
return _ZN7android6Looper5addFdEiiiPFiiiPvES1_(looper, fd, ident, events, callback, data);
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -18,12 +18,22 @@ typedef void * ALooper_callbackFunc;
|
|||||||
|
|
||||||
struct ASensorManager a_sensor_manager;
|
struct ASensorManager a_sensor_manager;
|
||||||
|
|
||||||
|
// --- sensor manager
|
||||||
|
|
||||||
struct ASensorManager* ASensorManager_getInstance()
|
struct ASensorManager* ASensorManager_getInstance()
|
||||||
{
|
{
|
||||||
return &a_sensor_manager;
|
return &a_sensor_manager;
|
||||||
}
|
}
|
||||||
|
|
||||||
// --- sensor manager
|
struct ASensorManager* ASensorManager_getInstanceForPackage(const char* packageName)
|
||||||
|
{
|
||||||
|
return &a_sensor_manager;
|
||||||
|
}
|
||||||
|
|
||||||
|
struct ASensor const* ASensorManager_getDefaultSensor(struct ASensorManager* manager, int type)
|
||||||
|
{
|
||||||
|
return NULL; // no sensor of this type exists
|
||||||
|
}
|
||||||
|
|
||||||
int ASensorManager_getSensorList(struct ASensorManager* manager, struct ASensorList* list)
|
int ASensorManager_getSensorList(struct ASensorManager* manager, struct ASensorList* list)
|
||||||
{
|
{
|
||||||
|
|||||||
Reference in New Issue
Block a user