2022-10-02 23:06:56 +02:00
|
|
|
#ifndef _UTILS_H_
|
|
|
|
|
#define _UTILS_H_
|
|
|
|
|
|
|
|
|
|
#include <jni.h>
|
|
|
|
|
|
|
|
|
|
#include "defines.h"
|
|
|
|
|
|
|
|
|
|
struct handle_cache {
|
|
|
|
|
struct {
|
|
|
|
|
jclass class;
|
|
|
|
|
jmethodID onCreate;
|
2024-10-05 16:52:53 +02:00
|
|
|
jmethodID onPostCreate;
|
2022-11-08 21:12:41 +01:00
|
|
|
jmethodID onStart;
|
2022-10-26 18:39:04 +02:00
|
|
|
jmethodID onResume;
|
2024-10-05 16:52:53 +02:00
|
|
|
jmethodID onPostResume;
|
2022-10-02 23:06:56 +02:00
|
|
|
jmethodID onWindowFocusChanged;
|
|
|
|
|
jmethodID onDestroy;
|
2023-08-11 18:09:17 +02:00
|
|
|
jmethodID onStop;
|
|
|
|
|
jmethodID onPause;
|
2024-11-15 08:15:04 +01:00
|
|
|
jmethodID onBackPressed;
|
2023-09-25 19:53:20 +02:00
|
|
|
} activity;
|
2022-10-02 23:06:56 +02:00
|
|
|
struct {
|
|
|
|
|
jclass class;
|
|
|
|
|
jmethodID getAttributeValue_string;
|
|
|
|
|
jmethodID getAttributeValue_int;
|
|
|
|
|
} attribute_set;
|
|
|
|
|
struct {
|
|
|
|
|
jclass class;
|
|
|
|
|
jmethodID add;
|
|
|
|
|
jmethodID remove;
|
|
|
|
|
jmethodID get;
|
|
|
|
|
jmethodID size;
|
|
|
|
|
jmethodID clear;
|
|
|
|
|
} array_list;
|
|
|
|
|
struct {
|
|
|
|
|
jclass class;
|
|
|
|
|
jmethodID getColor;
|
|
|
|
|
} paint;
|
|
|
|
|
struct {
|
|
|
|
|
jclass class;
|
|
|
|
|
jmethodID constructor;
|
2025-01-13 15:54:21 +01:00
|
|
|
jmethodID constructor_single;
|
2022-10-02 23:06:56 +02:00
|
|
|
} motion_event;
|
2024-03-16 15:04:02 +01:00
|
|
|
struct {
|
|
|
|
|
jclass class;
|
|
|
|
|
jmethodID constructor;
|
|
|
|
|
} sensor_event;
|
2022-10-02 23:06:56 +02:00
|
|
|
struct {
|
|
|
|
|
jclass class;
|
|
|
|
|
jmethodID onPeriodicNotification;
|
|
|
|
|
} audio_track_periodic_listener;
|
2022-11-11 19:18:21 +01:00
|
|
|
struct {
|
|
|
|
|
jclass class;
|
|
|
|
|
jmethodID onInputQueueCreated;
|
|
|
|
|
} input_queue_callback;
|
2022-12-27 17:14:30 +01:00
|
|
|
struct {
|
|
|
|
|
jclass class;
|
|
|
|
|
jmethodID surfaceCreated;
|
2023-10-20 20:54:37 +02:00
|
|
|
jmethodID surfaceChanged;
|
|
|
|
|
} surface_view;
|
2022-10-02 23:06:56 +02:00
|
|
|
struct {
|
|
|
|
|
jclass class;
|
|
|
|
|
jmethodID setLayoutParams;
|
2023-07-14 17:53:12 +02:00
|
|
|
jmethodID onDraw;
|
2024-11-27 14:59:37 +01:00
|
|
|
jmethodID dispatchDraw;
|
2024-05-19 15:04:15 +02:00
|
|
|
jmethodID draw;
|
2023-07-14 17:53:12 +02:00
|
|
|
jmethodID onMeasure;
|
2023-08-22 14:18:33 +02:00
|
|
|
jmethodID onLayout;
|
|
|
|
|
jmethodID getMeasuredWidth;
|
|
|
|
|
jmethodID getMeasuredHeight;
|
|
|
|
|
jmethodID getSuggestedMinimumWidth;
|
|
|
|
|
jmethodID getSuggestedMinimumHeight;
|
|
|
|
|
jmethodID setMeasuredDimension;
|
2023-08-22 18:08:16 +02:00
|
|
|
jmethodID onGenericMotionEvent;
|
2023-09-01 12:13:24 +02:00
|
|
|
jmethodID computeScroll;
|
|
|
|
|
jmethodID getScrollX;
|
|
|
|
|
jmethodID getScrollY;
|
2023-09-01 12:19:45 +02:00
|
|
|
jmethodID performClick;
|
2023-10-17 21:33:59 +02:00
|
|
|
jmethodID onTouchEvent;
|
2024-11-27 14:59:37 +01:00
|
|
|
jmethodID dispatchTouchEvent;
|
2024-02-24 18:50:03 +01:00
|
|
|
jmethodID onInterceptTouchEvent;
|
2023-10-28 22:38:43 +02:00
|
|
|
jmethodID layoutInternal;
|
2023-10-31 22:56:22 +01:00
|
|
|
jmethodID measure;
|
2024-07-26 21:47:08 +02:00
|
|
|
jmethodID performLongClick;
|
2024-11-17 15:59:53 +01:00
|
|
|
jmethodID getId;
|
|
|
|
|
jmethodID getIdName;
|
|
|
|
|
jmethodID getAllSuperClasses;
|
2024-11-30 17:46:43 +01:00
|
|
|
jmethodID dispatchKeyEvent;
|
2022-10-02 23:06:56 +02:00
|
|
|
} view;
|
2023-05-20 18:53:20 +02:00
|
|
|
struct {
|
|
|
|
|
jclass class;
|
|
|
|
|
jmethodID extractFromAPK;
|
|
|
|
|
} asset_manager;
|
2023-08-12 13:09:33 +02:00
|
|
|
struct {
|
|
|
|
|
jclass class;
|
|
|
|
|
jmethodID get_package_name;
|
|
|
|
|
} context;
|
|
|
|
|
struct {
|
|
|
|
|
jclass class;
|
|
|
|
|
jmethodID get_app_icon_path;
|
|
|
|
|
} application;
|
2023-10-08 15:31:55 +02:00
|
|
|
struct {
|
|
|
|
|
jclass class;
|
|
|
|
|
jmethodID loop;
|
|
|
|
|
jmethodID prepareMainLooper;
|
|
|
|
|
} looper;
|
2023-11-08 18:00:31 +01:00
|
|
|
struct {
|
|
|
|
|
jclass class;
|
|
|
|
|
jmethodID constructor;
|
|
|
|
|
} key_event;
|
2024-03-24 21:01:47 +01:00
|
|
|
struct {
|
|
|
|
|
jclass class;
|
|
|
|
|
jmethodID draw;
|
|
|
|
|
jmethodID setBounds;
|
|
|
|
|
} drawable;
|
2024-05-22 12:24:11 +02:00
|
|
|
struct {
|
|
|
|
|
jclass class;
|
2024-11-30 18:57:03 +01:00
|
|
|
jmethodID constructor;
|
2024-05-22 12:24:11 +02:00
|
|
|
jmethodID putExtraCharSequence;
|
|
|
|
|
} intent;
|
2024-10-03 22:42:12 +02:00
|
|
|
struct {
|
|
|
|
|
jclass class;
|
|
|
|
|
jmethodID internalGetAssetManager;
|
2024-10-03 22:43:42 +02:00
|
|
|
jmethodID internalLoadChanged;
|
2024-10-03 22:42:12 +02:00
|
|
|
} webview;
|
2024-11-30 18:57:03 +01:00
|
|
|
struct {
|
|
|
|
|
jclass class;
|
|
|
|
|
jmethodID onCreate;
|
|
|
|
|
jmethodID start;
|
|
|
|
|
} instrumentation;
|
2025-02-19 20:40:37 +01:00
|
|
|
struct {
|
|
|
|
|
jclass class;
|
|
|
|
|
jmethodID drawText;
|
|
|
|
|
} canvas;
|
2022-10-02 23:06:56 +02:00
|
|
|
};
|
|
|
|
|
|
|
|
|
|
extern struct handle_cache handle_cache;
|
|
|
|
|
|
2023-08-11 18:09:17 +02:00
|
|
|
JNIEnv * get_jni_env(void);
|
|
|
|
|
|
2022-10-02 23:06:56 +02:00
|
|
|
const char * attribute_set_get_string(JNIEnv *env, jobject attrs, char *attribute, char *schema);
|
|
|
|
|
int attribute_set_get_int(JNIEnv *env, jobject attrs, char *attribute, char *schema, int default_value);
|
2023-08-08 10:16:17 +02:00
|
|
|
void set_up_handle_cache(JNIEnv *env);
|
2023-05-20 18:53:20 +02:00
|
|
|
void extract_from_apk(const char *path, const char *target);
|
2024-03-18 14:37:56 +01:00
|
|
|
char *get_app_data_dir();
|
2022-10-02 23:06:56 +02:00
|
|
|
|
2023-08-08 10:16:17 +02:00
|
|
|
void prepare_main_looper(JNIEnv* env);
|
|
|
|
|
|
2023-09-06 17:42:24 +02:00
|
|
|
/* we don't (currently?) install the headers for liblog */
|
|
|
|
|
typedef enum {
|
|
|
|
|
LOG_ID_MAIN = 0,
|
|
|
|
|
LOG_ID_RADIO = 1,
|
|
|
|
|
LOG_ID_EVENTS = 2,
|
|
|
|
|
LOG_ID_SYSTEM = 3,
|
|
|
|
|
|
|
|
|
|
LOG_ID_MAX
|
|
|
|
|
} log_id_t;
|
|
|
|
|
|
|
|
|
|
typedef enum android_LogPriority {
|
|
|
|
|
ANDROID_LOG_UNKNOWN = 0,
|
|
|
|
|
ANDROID_LOG_DEFAULT, /* only for SetMinPriority() */
|
|
|
|
|
ANDROID_LOG_VERBOSE,
|
|
|
|
|
ANDROID_LOG_DEBUG,
|
|
|
|
|
ANDROID_LOG_INFO,
|
|
|
|
|
ANDROID_LOG_WARN,
|
|
|
|
|
ANDROID_LOG_ERROR,
|
|
|
|
|
ANDROID_LOG_FATAL,
|
|
|
|
|
ANDROID_LOG_SILENT, /* only for SetMinPriority(); must be last */
|
|
|
|
|
} android_LogPriority;
|
|
|
|
|
|
|
|
|
|
/* TODO: do we really need the bufID, or can we use our function below which has a stderr fallback */
|
|
|
|
|
int __android_log_buf_write(int bufID, int prio, const char *tag, const char *text);
|
|
|
|
|
|
|
|
|
|
/* defined in util.c */
|
|
|
|
|
int android_log_printf(android_LogPriority prio, const char *tag, const char *fmt, ...);
|
|
|
|
|
|
2023-10-08 16:09:27 +02:00
|
|
|
void *get_nio_buffer(JNIEnv *env, jobject buffer, jarray *array_ref, jbyte **array);
|
|
|
|
|
void release_nio_buffer(JNIEnv *env, jarray array_ref, jbyte *array);
|
|
|
|
|
int get_nio_buffer_size(JNIEnv *env, jobject buffer);
|
|
|
|
|
|
2022-10-02 23:06:56 +02:00
|
|
|
#endif
|