diff options
| author | Po Lu | 2023-02-25 19:11:07 +0800 |
|---|---|---|
| committer | Po Lu | 2023-02-25 19:11:07 +0800 |
| commit | 8e4c5db193dc7baee5846520fe8b63d8bea99148 (patch) | |
| tree | 595eb65601d38b7895ae1d00ec9a71a947cd1af7 /src/androidfns.c | |
| parent | d5cccfdc564f1486431f9674503c794df33d7fbc (diff) | |
| download | emacs-8e4c5db193dc7baee5846520fe8b63d8bea99148.tar.gz emacs-8e4c5db193dc7baee5846520fe8b63d8bea99148.zip | |
Update Android port
* doc/emacs/android.texi (Android Startup, Android File System)
(Android Environment, Android Windowing, Android
Troubleshooting): Improve documentation; fix typos.
* doc/lispref/commands.texi (Misc Events): Likewise.
* java/org/gnu/emacs/EmacsService.java (queryBattery): New
function.
* lisp/battery.el (battery-status-function): Set appropriately
for Android.
(battery-android): New function.
* src/android.c (struct android_emacs_service): New method
`query_battery'.
(android_check_content_access): Improve exception checking.
(android_init_emacs_service): Look up new method.
(android_destroy_handle, android_create_window)
(android_init_android_rect_class, android_init_emacs_gc_class)
(android_set_clip_rectangles)
(android_create_pixmap_from_bitmap_data, android_fill_polygon)
(android_get_image, android_put_image, android_bell)
(android_set_input_focus, android_raise_window)
(android_lower_window, android_query_tree, android_get_geometry)
(android_translate_coordinates, android_wc_lookup_string)
(android_damage_window, android_build_string)
(android_build_jstring, android_exception_check_1)
(android_exception_check_2): New functions.
(android_browse_url): Improve exception handling. Always use
android_exception_check and don't leak local refs.
(android_query_battery): New function.
* src/android.h (struct android_battery_state): New struct.
* src/androidfns.c (Fandroid_query_battery, syms_of_androidfns):
New function.
* src/androidfont.c (androidfont_from_lisp, DO_SYMBOL_FIELD)
(DO_CARDINAL_FIELD, androidfont_list, androidfont_match)
(androidfont_draw, androidfont_open_font)
(androidfont_close_font):
* src/androidselect.c (Fandroid_set_clipboard)
(Fandroid_get_clipboard):
* src/sfnt.c (sfnt_map_glyf_table):
* src/sfntfont.c (sfntfont_free_outline_cache)
(sfntfont_free_raster_cache, sfntfont_close): Allow font close
functions to be called twice.
Diffstat (limited to 'src/androidfns.c')
| -rw-r--r-- | src/androidfns.c | 43 |
1 files changed, 42 insertions, 1 deletions
diff --git a/src/androidfns.c b/src/androidfns.c index b5b88df4fe5..dc68cef8a02 100644 --- a/src/androidfns.c +++ b/src/androidfns.c | |||
| @@ -2783,6 +2783,46 @@ frame_parm_handler android_frame_parm_handlers[] = | |||
| 2783 | NULL, | 2783 | NULL, |
| 2784 | }; | 2784 | }; |
| 2785 | 2785 | ||
| 2786 | |||
| 2787 | |||
| 2788 | /* Battery information support. */ | ||
| 2789 | |||
| 2790 | DEFUN ("android-query-battery", Fandroid_query_battery, | ||
| 2791 | Sandroid_query_battery, 0, 0, 0, | ||
| 2792 | doc: /* Perform a query for battery information. | ||
| 2793 | This function will not work before Android 5.0. | ||
| 2794 | Value is nil upon failure, or a list of the form: | ||
| 2795 | |||
| 2796 | (CAPACITY CHARGE-COUNTER CURRENT-AVERAGE CURRENT-NOW STATUS | ||
| 2797 | REMAINING) | ||
| 2798 | |||
| 2799 | See the documentation at | ||
| 2800 | |||
| 2801 | https://developer.android.com/reference/android/os/BatteryManager | ||
| 2802 | |||
| 2803 | for more details about these values. */) | ||
| 2804 | (void) | ||
| 2805 | { | ||
| 2806 | struct android_battery_state state; | ||
| 2807 | |||
| 2808 | /* Make sure the Android libraries have been initialized. */ | ||
| 2809 | |||
| 2810 | if (!android_init_gui) | ||
| 2811 | return Qnil; | ||
| 2812 | |||
| 2813 | /* Perform the query. */ | ||
| 2814 | |||
| 2815 | if (android_query_battery (&state)) | ||
| 2816 | return Qnil; | ||
| 2817 | |||
| 2818 | return listn (6, make_int (state.capacity), | ||
| 2819 | make_int (state.charge_counter), | ||
| 2820 | make_int (state.current_average), | ||
| 2821 | make_int (state.current_now), | ||
| 2822 | make_int (state.status), | ||
| 2823 | make_int (state.remaining)); | ||
| 2824 | } | ||
| 2825 | |||
| 2786 | #endif | 2826 | #endif |
| 2787 | 2827 | ||
| 2788 | 2828 | ||
| @@ -2837,8 +2877,9 @@ syms_of_androidfns (void) | |||
| 2837 | defsubr (&Sx_hide_tip); | 2877 | defsubr (&Sx_hide_tip); |
| 2838 | defsubr (&Sandroid_detect_mouse); | 2878 | defsubr (&Sandroid_detect_mouse); |
| 2839 | defsubr (&Sandroid_toggle_on_screen_keyboard); | 2879 | defsubr (&Sandroid_toggle_on_screen_keyboard); |
| 2840 | |||
| 2841 | #ifndef ANDROID_STUBIFY | 2880 | #ifndef ANDROID_STUBIFY |
| 2881 | defsubr (&Sandroid_query_battery); | ||
| 2882 | |||
| 2842 | tip_timer = Qnil; | 2883 | tip_timer = Qnil; |
| 2843 | staticpro (&tip_timer); | 2884 | staticpro (&tip_timer); |
| 2844 | tip_frame = Qnil; | 2885 | tip_frame = Qnil; |