1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26 #ifndef _ANDROID_H_
27 #ifndef ANDROID_STUBIFY
28 #include <jni.h>
29 #include <pwd.h>
30
31 #include <sys/stat.h>
32 #include <dirent.h>
33 #include <stdio.h>
34
35 #include <android/bitmap.h>
36
37 #include "androidgui.h"
38 #include "lisp.h"
39 #endif
40
41 extern bool android_init_gui;
42
43 #ifndef ANDROID_STUBIFY
44
45 extern char *android_cache_dir;
46
47 extern int android_emacs_init (int, char **, char *);
48 extern int android_select (int, fd_set *, fd_set *, fd_set *,
49 struct timespec *);
50 extern char *android_user_full_name (struct passwd *);
51
52
53
54
55
56
57 extern const char *android_is_special_directory (const char *, const char *);
58 extern const char *android_get_home_directory (void);
59
60 extern void android_vfs_init (JNIEnv *, jobject);
61
62 extern int android_open (const char *, int, mode_t);
63 extern int android_fstat (int, struct stat *);
64 extern int android_fstatat (int, const char *restrict,
65 struct stat *restrict, int);
66 extern int android_faccessat (int, const char *, int, int);
67 extern int android_close (int);
68 extern FILE *android_fdopen (int, const char *);
69 extern int android_fclose (FILE *);
70 extern int android_unlink (const char *);
71 extern int android_symlink (const char *, const char *);
72 extern int android_rmdir (const char *);
73 extern int android_mkdir (const char *, mode_t);
74 extern int android_renameat_noreplace (int, const char *,
75 int, const char *);
76 extern int android_rename (const char *, const char *);
77 extern int android_fchmodat (int, const char *, mode_t, int);
78 extern ssize_t android_readlinkat (int, const char *restrict, char *restrict,
79 size_t);
80
81
82
83 extern double android_pixel_density_x, android_pixel_density_y;
84 extern double android_scaled_pixel_density;
85
86 enum android_handle_type
87 {
88 ANDROID_HANDLE_WINDOW,
89 ANDROID_HANDLE_GCONTEXT,
90 ANDROID_HANDLE_PIXMAP,
91 ANDROID_HANDLE_CURSOR,
92 };
93
94 extern jobject android_resolve_handle (android_handle,
95 enum android_handle_type);
96 extern unsigned char *android_lock_bitmap (android_drawable,
97 AndroidBitmapInfo *,
98 jobject *);
99 extern void android_damage_window (android_window,
100 struct android_rectangle *);
101 extern int android_get_screen_width (void);
102 extern int android_get_screen_height (void);
103 extern int android_get_mm_width (void);
104 extern int android_get_mm_height (void);
105 extern bool android_detect_mouse (void);
106
107 extern void android_set_dont_focus_on_map (android_window, bool);
108 extern void android_set_dont_accept_focus (android_window, bool);
109
110 extern int android_verify_jni_string (const char *);
111 extern jstring android_build_string (Lisp_Object);
112 extern jstring android_build_jstring (const char *);
113 extern void android_exception_check (void);
114 extern void android_exception_check_1 (jobject);
115 extern void android_exception_check_2 (jobject, jobject);
116 extern void android_exception_check_3 (jobject, jobject, jobject);
117 extern void android_exception_check_4 (jobject, jobject, jobject, jobject);
118 extern void android_exception_check_nonnull (void *, jobject);
119 extern void android_exception_check_nonnull_1 (void *, jobject, jobject);
120
121 extern void android_get_keysym_name (int, char *, size_t);
122 extern void android_wait_event (void);
123 extern void android_toggle_on_screen_keyboard (android_window, bool);
124 extern _Noreturn void android_restart_emacs (void);
125 extern int android_request_directory_access (void);
126 extern int android_get_current_api_level (void)
127 __attribute__ ((pure));
128
129
130
131
132 #define android_get_current_api_level() \
133 ({ int value; \
134 \
135 value = (android_get_current_api_level) (); \
136 eassume (value >= __ANDROID_API__); value; })
137
138
139
140
141
142 struct android_vdir;
143
144 extern struct android_vdir *android_opendir (const char *);
145 extern int android_dirfd (struct android_vdir *);
146 extern struct dirent *android_readdir (struct android_vdir *);
147 extern void android_closedir (struct android_vdir *);
148
149
150
151
152
153 struct android_fd_or_asset
154 {
155
156 int fd;
157
158
159 void *asset;
160 };
161
162 extern struct android_fd_or_asset android_open_asset (const char *,
163 int, mode_t);
164 extern int android_close_asset (struct android_fd_or_asset);
165 extern ssize_t android_asset_read_quit (struct android_fd_or_asset,
166 void *, size_t);
167 extern ssize_t android_asset_read (struct android_fd_or_asset,
168 void *, size_t);
169 extern off_t android_asset_lseek (struct android_fd_or_asset, off_t, int);
170 extern int android_asset_fstat (struct android_fd_or_asset,
171 struct stat *);
172
173
174
175
176
177 struct android_battery_state
178 {
179
180 intmax_t capacity;
181
182
183 intmax_t charge_counter;
184
185
186 intmax_t current_average;
187
188
189 intmax_t current_now;
190
191
192
193 intmax_t remaining;
194
195
196
197
198
199
200
201
202
203 int status;
204
205
206
207
208
209
210
211
212 int plugged;
213
214
215 int temperature;
216 };
217
218 extern Lisp_Object android_browse_url (Lisp_Object, Lisp_Object);
219 extern int android_query_battery (struct android_battery_state *);
220 extern void android_display_toast (const char *);
221
222
223
224
225
226 extern void android_check_query_urgent (void);
227 extern int android_run_in_emacs_thread (void (*) (void *), void *);
228 extern void android_write_event (union android_event *);
229
230 extern unsigned int event_serial;
231
232
233
234
235 extern int android_rewrite_spawn_argv (const char ***);
236
237 #else
238
239
240
241 #define android_is_special_directory(name, dir) ((const char *) NULL)
242
243 #endif
244
245
246
247
248 #ifndef ANDROID_STUBIFY
249 #include <jni.h>
250
251 struct android_emacs_service
252 {
253 jclass class;
254 jmethodID fill_rectangle;
255 jmethodID fill_polygon;
256 jmethodID draw_rectangle;
257 jmethodID draw_line;
258 jmethodID draw_point;
259 jmethodID clear_window;
260 jmethodID clear_area;
261 jmethodID ring_bell;
262 jmethodID query_tree;
263 jmethodID get_screen_width;
264 jmethodID get_screen_height;
265 jmethodID detect_mouse;
266 jmethodID name_keysym;
267 jmethodID browse_url;
268 jmethodID restart_emacs;
269 jmethodID update_ic;
270 jmethodID reset_ic;
271 jmethodID open_content_uri;
272 jmethodID check_content_uri;
273 jmethodID query_battery;
274 jmethodID update_extracted_text;
275 jmethodID update_cursor_anchor_info;
276 jmethodID get_document_authorities;
277 jmethodID request_directory_access;
278 jmethodID get_document_trees;
279 jmethodID document_id_from_name;
280 jmethodID get_tree_uri;
281 jmethodID stat_document;
282 jmethodID access_document;
283 jmethodID open_document_directory;
284 jmethodID read_directory_entry;
285 jmethodID open_document;
286 jmethodID create_document;
287 jmethodID create_directory;
288 jmethodID delete_document;
289 jmethodID rename_document;
290 jmethodID move_document;
291 jmethodID valid_authority;
292 };
293
294 extern JNIEnv *android_java_env;
295
296
297 extern jobject emacs_service;
298
299
300 extern struct android_emacs_service service_class;
301
302 #define ANDROID_DELETE_LOCAL_REF(ref) \
303 ((*android_java_env)->DeleteLocalRef (android_java_env, \
304 (ref)))
305
306 #define NATIVE_NAME(name) Java_org_gnu_emacs_EmacsNative_##name
307
308
309
310
311 #if defined __i386__
312 extern void *unused_pointer;
313
314 #define JNI_STACK_ALIGNMENT_PROLOGUE \
315 __attribute__ ((aligned (32))) char stack_align_buffer[32]; \
316 \
317 \
318 unused_pointer = stack_align_buffer;
319
320 #else
321 #define JNI_STACK_ALIGNMENT_PROLOGUE ((void) 0)
322 #endif
323
324 #endif
325 #endif