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
79
80
81 extern double android_pixel_density_x, android_pixel_density_y;
82 extern double android_scaled_pixel_density;
83
84 enum android_handle_type
85 {
86 ANDROID_HANDLE_WINDOW,
87 ANDROID_HANDLE_GCONTEXT,
88 ANDROID_HANDLE_PIXMAP,
89 ANDROID_HANDLE_CURSOR,
90 };
91
92 extern jobject android_resolve_handle (android_handle,
93 enum android_handle_type);
94 extern unsigned char *android_lock_bitmap (android_drawable,
95 AndroidBitmapInfo *,
96 jobject *);
97 extern void android_damage_window (android_window,
98 struct android_rectangle *);
99 extern int android_get_screen_width (void);
100 extern int android_get_screen_height (void);
101 extern int android_get_mm_width (void);
102 extern int android_get_mm_height (void);
103 extern bool android_detect_mouse (void);
104
105 extern void android_set_dont_focus_on_map (android_window, bool);
106 extern void android_set_dont_accept_focus (android_window, bool);
107
108 extern int android_verify_jni_string (const char *);
109 extern jstring android_build_string (Lisp_Object);
110 extern jstring android_build_jstring (const char *);
111 extern void android_exception_check (void);
112 extern void android_exception_check_1 (jobject);
113 extern void android_exception_check_2 (jobject, jobject);
114 extern void android_exception_check_3 (jobject, jobject, jobject);
115 extern void android_exception_check_4 (jobject, jobject, jobject, jobject);
116 extern void android_exception_check_nonnull (void *, jobject);
117 extern void android_exception_check_nonnull_1 (void *, jobject, jobject);
118
119 extern void android_get_keysym_name (int, char *, size_t);
120 extern void android_wait_event (void);
121 extern void android_toggle_on_screen_keyboard (android_window, bool);
122 extern _Noreturn void android_restart_emacs (void);
123 extern int android_request_directory_access (void);
124 extern int android_get_current_api_level (void)
125 __attribute__ ((pure));
126
127
128
129
130 #define android_get_current_api_level() \
131 ({ int value; \
132 \
133 value = (android_get_current_api_level) (); \
134 eassume (value >= __ANDROID_API__); value; })
135
136
137
138
139
140 struct android_vdir;
141
142 extern struct android_vdir *android_opendir (const char *);
143 extern int android_dirfd (struct android_vdir *);
144 extern struct dirent *android_readdir (struct android_vdir *);
145 extern void android_closedir (struct android_vdir *);
146
147
148
149
150
151 struct android_fd_or_asset
152 {
153
154 int fd;
155
156
157 void *asset;
158 };
159
160 extern struct android_fd_or_asset android_open_asset (const char *,
161 int, mode_t);
162 extern int android_close_asset (struct android_fd_or_asset);
163 extern ssize_t android_asset_read_quit (struct android_fd_or_asset,
164 void *, size_t);
165 extern ssize_t android_asset_read (struct android_fd_or_asset,
166 void *, size_t);
167 extern off_t android_asset_lseek (struct android_fd_or_asset, off_t, int);
168 extern int android_asset_fstat (struct android_fd_or_asset,
169 struct stat *);
170
171
172
173
174
175 struct android_battery_state
176 {
177
178 intmax_t capacity;
179
180
181 intmax_t charge_counter;
182
183
184 intmax_t current_average;
185
186
187 intmax_t current_now;
188
189
190
191 intmax_t remaining;
192
193
194
195
196
197
198
199
200
201 int status;
202
203
204
205
206
207
208
209
210 int plugged;
211
212
213 int temperature;
214 };
215
216 extern Lisp_Object android_browse_url (Lisp_Object, Lisp_Object);
217 extern int android_query_battery (struct android_battery_state *);
218 extern void android_display_toast (const char *);
219
220
221
222
223
224 extern void android_check_query_urgent (void);
225 extern int android_run_in_emacs_thread (void (*) (void *), void *);
226 extern void android_write_event (union android_event *);
227
228 extern unsigned int event_serial;
229
230
231
232
233 extern int android_rewrite_spawn_argv (const char ***);
234
235 #else
236
237
238
239 #define android_is_special_directory(name, dir) ((const char *) NULL)
240
241 #endif
242
243
244
245
246 #ifndef ANDROID_STUBIFY
247 #include <jni.h>
248
249 struct android_emacs_service
250 {
251 jclass class;
252 jmethodID fill_rectangle;
253 jmethodID fill_polygon;
254 jmethodID draw_rectangle;
255 jmethodID draw_line;
256 jmethodID draw_point;
257 jmethodID clear_window;
258 jmethodID clear_area;
259 jmethodID ring_bell;
260 jmethodID query_tree;
261 jmethodID get_screen_width;
262 jmethodID get_screen_height;
263 jmethodID detect_mouse;
264 jmethodID name_keysym;
265 jmethodID browse_url;
266 jmethodID restart_emacs;
267 jmethodID update_ic;
268 jmethodID reset_ic;
269 jmethodID open_content_uri;
270 jmethodID check_content_uri;
271 jmethodID query_battery;
272 jmethodID update_extracted_text;
273 jmethodID update_cursor_anchor_info;
274 jmethodID get_document_authorities;
275 jmethodID request_directory_access;
276 jmethodID get_document_trees;
277 jmethodID document_id_from_name;
278 jmethodID get_tree_uri;
279 jmethodID stat_document;
280 jmethodID access_document;
281 jmethodID open_document_directory;
282 jmethodID read_directory_entry;
283 jmethodID open_document;
284 jmethodID create_document;
285 jmethodID create_directory;
286 jmethodID delete_document;
287 jmethodID rename_document;
288 jmethodID move_document;
289 jmethodID valid_authority;
290 };
291
292 extern JNIEnv *android_java_env;
293
294
295 extern jobject emacs_service;
296
297
298 extern struct android_emacs_service service_class;
299
300 #define ANDROID_DELETE_LOCAL_REF(ref) \
301 ((*android_java_env)->DeleteLocalRef (android_java_env, \
302 (ref)))
303
304 #define NATIVE_NAME(name) Java_org_gnu_emacs_EmacsNative_##name
305
306
307
308
309 #if defined __i386__
310 extern void *unused_pointer;
311
312 #define JNI_STACK_ALIGNMENT_PROLOGUE \
313 __attribute__ ((aligned (32))) char stack_align_buffer[32]; \
314 \
315 \
316 unused_pointer = stack_align_buffer;
317
318 #else
319 #define JNI_STACK_ALIGNMENT_PROLOGUE ((void) 0)
320 #endif
321
322 #endif
323 #endif