diff options
| author | Po Lu | 2024-07-12 14:31:33 +0800 |
|---|---|---|
| committer | Po Lu | 2024-07-12 14:31:33 +0800 |
| commit | b22ab99f0a85f73a1aec582f7aba0e6b5101b953 (patch) | |
| tree | ce345c2327bc764c0a9b40065ffe5e4484ad95eb /src | |
| parent | a5ef9e25680d490e2a453e5ed518aba8f4560b2d (diff) | |
| download | emacs-b22ab99f0a85f73a1aec582f7aba0e6b5101b953.tar.gz emacs-b22ab99f0a85f73a1aec582f7aba0e6b5101b953.zip | |
Render more Android functions safe to execute in a batch session
* src/androidfns.c (Fx_display_mm_width, Fx_display_mm_height)
(Fandroid_display_monitor_attributes_list)
(Fandroid_external_storage_available_p)
(Fandroid_request_storage_access): Verify that a display
connection or service object is available.
* src/androidselect.c (Fandroid_get_clipboard)
(Fandroid_browse_url_internal, Fandroid_get_clipboard_targets)
(Fandroid_get_clipboard_data, Fandroid_notifications_notify):
Moderate tone of error messages.
Diffstat (limited to 'src')
| -rw-r--r-- | src/androidfns.c | 11 | ||||
| -rw-r--r-- | src/androidselect.c | 10 |
2 files changed, 16 insertions, 5 deletions
diff --git a/src/androidfns.c b/src/androidfns.c index 7595e176618..af2247ad962 100644 --- a/src/androidfns.c +++ b/src/androidfns.c | |||
| @@ -1374,6 +1374,7 @@ DEFUN ("x-display-mm-width", Fx_display_mm_width, Sx_display_mm_width, | |||
| 1374 | error ("Android cross-compilation stub called!"); | 1374 | error ("Android cross-compilation stub called!"); |
| 1375 | return Qnil; | 1375 | return Qnil; |
| 1376 | #else | 1376 | #else |
| 1377 | check_android_display_info (terminal); | ||
| 1377 | return make_fixnum (android_get_mm_width ()); | 1378 | return make_fixnum (android_get_mm_width ()); |
| 1378 | #endif | 1379 | #endif |
| 1379 | } | 1380 | } |
| @@ -1386,6 +1387,7 @@ DEFUN ("x-display-mm-height", Fx_display_mm_height, Sx_display_mm_height, | |||
| 1386 | error ("Android cross-compilation stub called!"); | 1387 | error ("Android cross-compilation stub called!"); |
| 1387 | return Qnil; | 1388 | return Qnil; |
| 1388 | #else | 1389 | #else |
| 1390 | check_android_display_info (terminal); | ||
| 1389 | return make_fixnum (android_get_mm_height ()); | 1391 | return make_fixnum (android_get_mm_height ()); |
| 1390 | #endif | 1392 | #endif |
| 1391 | } | 1393 | } |
| @@ -1469,6 +1471,7 @@ Internal use only, use `display-monitor-attributes-list' instead. */) | |||
| 1469 | #else | 1471 | #else |
| 1470 | struct MonitorInfo monitor; | 1472 | struct MonitorInfo monitor; |
| 1471 | 1473 | ||
| 1474 | check_android_display_info (terminal); | ||
| 1472 | memset (&monitor, 0, sizeof monitor); | 1475 | memset (&monitor, 0, sizeof monitor); |
| 1473 | monitor.geom.width = android_get_screen_width (); | 1476 | monitor.geom.width = android_get_screen_width (); |
| 1474 | monitor.geom.height = android_get_screen_height (); | 1477 | monitor.geom.height = android_get_screen_height (); |
| @@ -3270,6 +3273,11 @@ External storage on Android encompasses the `/sdcard' and | |||
| 3270 | absent these permissions. */) | 3273 | absent these permissions. */) |
| 3271 | (void) | 3274 | (void) |
| 3272 | { | 3275 | { |
| 3276 | /* Implement a rather undependable fallback when no GUI is | ||
| 3277 | available. */ | ||
| 3278 | if (!android_init_gui) | ||
| 3279 | return Ffile_accessible_directory_p (build_string ("/sdcard")); | ||
| 3280 | |||
| 3273 | return android_external_storage_available_p () ? Qt : Qnil; | 3281 | return android_external_storage_available_p () ? Qt : Qnil; |
| 3274 | } | 3282 | } |
| 3275 | 3283 | ||
| @@ -3284,6 +3292,9 @@ Use `android-external-storage-available-p' (which see) to verify | |||
| 3284 | whether Emacs has actually received such access permissions. */) | 3292 | whether Emacs has actually received such access permissions. */) |
| 3285 | (void) | 3293 | (void) |
| 3286 | { | 3294 | { |
| 3295 | if (!android_init_gui) | ||
| 3296 | return Qnil; | ||
| 3297 | |||
| 3287 | android_request_storage_access (); | 3298 | android_request_storage_access (); |
| 3288 | return Qnil; | 3299 | return Qnil; |
| 3289 | } | 3300 | } |
diff --git a/src/androidselect.c b/src/androidselect.c index d5783b75417..cbd163c6c9f 100644 --- a/src/androidselect.c +++ b/src/androidselect.c | |||
| @@ -189,7 +189,7 @@ Alternatively, return nil if the clipboard is empty. */) | |||
| 189 | const char *data; | 189 | const char *data; |
| 190 | 190 | ||
| 191 | if (!android_init_gui) | 191 | if (!android_init_gui) |
| 192 | error ("No Android display connection!"); | 192 | error ("No Android display connection"); |
| 193 | 193 | ||
| 194 | method = clipboard_class.get_clipboard; | 194 | method = clipboard_class.get_clipboard; |
| 195 | text | 195 | text |
| @@ -258,7 +258,7 @@ for. Use `android-browse-url' instead. */) | |||
| 258 | Lisp_Object value; | 258 | Lisp_Object value; |
| 259 | 259 | ||
| 260 | if (!android_init_gui) | 260 | if (!android_init_gui) |
| 261 | error ("No Android display connection!"); | 261 | error ("No Android display connection"); |
| 262 | 262 | ||
| 263 | CHECK_STRING (url); | 263 | CHECK_STRING (url); |
| 264 | value = android_browse_url (url, send); | 264 | value = android_browse_url (url, send); |
| @@ -290,7 +290,7 @@ data type available from the clipboard. */) | |||
| 290 | Lisp_Object targets, tem; | 290 | Lisp_Object targets, tem; |
| 291 | 291 | ||
| 292 | if (!android_init_gui) | 292 | if (!android_init_gui) |
| 293 | error ("No Android display connection!"); | 293 | error ("No Android display connection"); |
| 294 | 294 | ||
| 295 | targets = Qnil; | 295 | targets = Qnil; |
| 296 | block_input (); | 296 | block_input (); |
| @@ -544,7 +544,7 @@ does not have any corresponding data. In that case, use | |||
| 544 | char *buffer, *start; | 544 | char *buffer, *start; |
| 545 | 545 | ||
| 546 | if (!android_init_gui) | 546 | if (!android_init_gui) |
| 547 | error ("No Android display connection!"); | 547 | error ("No Android display connection"); |
| 548 | 548 | ||
| 549 | CHECK_STRING (type); | 549 | CHECK_STRING (type); |
| 550 | 550 | ||
| @@ -1003,7 +1003,7 @@ usage: (android-notifications-notify &rest ARGS) */) | |||
| 1003 | AUTO_STRING (default_icon, "ic_dialog_alert"); | 1003 | AUTO_STRING (default_icon, "ic_dialog_alert"); |
| 1004 | 1004 | ||
| 1005 | if (!android_init_gui) | 1005 | if (!android_init_gui) |
| 1006 | error ("No Android display connection!"); | 1006 | error ("No Android display connection"); |
| 1007 | 1007 | ||
| 1008 | /* Clear each variable above. */ | 1008 | /* Clear each variable above. */ |
| 1009 | title = body = replaces_id = group = icon = urgency = actions = Qnil; | 1009 | title = body = replaces_id = group = icon = urgency = actions = Qnil; |