aboutsummaryrefslogtreecommitdiffstats
path: root/src/android.c
diff options
context:
space:
mode:
authorPo Lu2023-03-08 15:04:49 +0800
committerPo Lu2023-03-08 15:04:49 +0800
commitbb55528c7b58c5f50336ed3f2ff9759559d78680 (patch)
tree6a4422afb19dc4ac9644d62b12d2a8aaf145deb3 /src/android.c
parentfdff5442a59fd2387c23e2be2658dafa39466891 (diff)
downloademacs-bb55528c7b58c5f50336ed3f2ff9759559d78680.tar.gz
emacs-bb55528c7b58c5f50336ed3f2ff9759559d78680.zip
Update Android port
* doc/emacs/android.texi (Android File System): Document what `temp~unlinked' means in the temporary files directory. * java/org/gnu/emacs/EmacsService.java (updateExtractedText): New function. * java/org/gnu/emacs/EmacsView.java (onCreateInputConnection): Ask the input method nicely to not display the extracted text UI. * src/android.c (struct android_emacs_service): New method `updateExtractedText'. (android_hack_asset_fd_fallback): Improve naming convention. Fix typo. (android_init_emacs_service): Add new method. (android_update_extracted_text): New function. (android_open_asset): Fix typo. * src/androidgui.h: Update prototypes. * src/androidterm.c (struct android_get_extracted_text_context): New field `flags'. (android_get_extracted_text): Set flags on the frame's output data. (android_build_extracted_text): New function. (getExtractedText): Move out class structures. (android_update_selection): Send updates to extracted text if the input method asked for them. (android_reset_conversion): Clear extracted text flags. * src/androidterm.h (struct android_output): New fields for storing extracted text data.
Diffstat (limited to 'src/android.c')
-rw-r--r--src/android.c44
1 files changed, 39 insertions, 5 deletions
diff --git a/src/android.c b/src/android.c
index 11b0fa5e0f3..e620a041348 100644
--- a/src/android.c
+++ b/src/android.c
@@ -112,6 +112,7 @@ struct android_emacs_service
112 jmethodID check_content_uri; 112 jmethodID check_content_uri;
113 jmethodID query_battery; 113 jmethodID query_battery;
114 jmethodID display_toast; 114 jmethodID display_toast;
115 jmethodID update_extracted_text;
115}; 116};
116 117
117struct android_emacs_pixmap 118struct android_emacs_pixmap
@@ -1236,13 +1237,12 @@ android_hack_asset_fd_fallback (AAsset *asset)
1236 Creating an ashmem file descriptor and reading from it doesn't 1237 Creating an ashmem file descriptor and reading from it doesn't
1237 work on these old Android versions. */ 1238 work on these old Android versions. */
1238 1239
1239 snprintf (filename, PATH_MAX, "%s/%s.%d", 1240 snprintf (filename, PATH_MAX, "%s/temp~unlinked.%d",
1240 android_cache_dir, "temp-unlinked", 1241 android_cache_dir, getpid ());
1241 getpid ());
1242 fd = open (filename, O_CREAT | O_RDWR | O_TRUNC, 1242 fd = open (filename, O_CREAT | O_RDWR | O_TRUNC,
1243 S_IRUSR | S_IWUSR); 1243 S_IRUSR | S_IWUSR);
1244 1244
1245 if (fd < 1) 1245 if (fd < 0)
1246 return -1; 1246 return -1;
1247 1247
1248 if (unlink (filename)) 1248 if (unlink (filename))
@@ -2135,6 +2135,9 @@ android_init_emacs_service (void)
2135 FIND_METHOD (query_battery, "queryBattery", "()[J"); 2135 FIND_METHOD (query_battery, "queryBattery", "()[J");
2136 FIND_METHOD (display_toast, "displayToast", 2136 FIND_METHOD (display_toast, "displayToast",
2137 "(Ljava/lang/String;)V"); 2137 "(Ljava/lang/String;)V");
2138 FIND_METHOD (update_extracted_text, "updateExtractedText",
2139 "(Lorg/gnu/emacs/EmacsWindow;"
2140 "Landroid/view/inputmethod/ExtractedText;I)V");
2138#undef FIND_METHOD 2141#undef FIND_METHOD
2139} 2142}
2140 2143
@@ -5991,6 +5994,37 @@ android_reset_ic (android_window window, enum android_ic_mode mode)
5991 android_exception_check (); 5994 android_exception_check ();
5992} 5995}
5993 5996
5997/* Make updates to extracted text known to the input method on
5998 WINDOW. TEXT should be a local reference to the new
5999 extracted text. TOKEN should be the token specified by the
6000 input method. */
6001
6002void
6003android_update_extracted_text (android_window window, void *text,
6004 int token)
6005{
6006 jobject object;
6007 jmethodID method;
6008
6009 object = android_resolve_handle (window, ANDROID_HANDLE_WINDOW);
6010 method = service_class.update_extracted_text;
6011
6012 (*android_java_env)->CallNonvirtualVoidMethod (android_java_env,
6013 emacs_service,
6014 service_class.class,
6015 method, object,
6016 /* N.B. that
6017 text is not
6018 jobject,
6019 because that
6020 type is not
6021 available in
6022 androidgui.h. */
6023 (jobject) text,
6024 (jint) token);
6025 android_exception_check_1 (text);
6026}
6027
5994 6028
5995 6029
5996/* Window decoration management functions. */ 6030/* Window decoration management functions. */
@@ -6083,7 +6117,7 @@ android_open_asset (const char *filename, int oflag, mode_t mode)
6083 get a regular file descriptor. */ 6117 get a regular file descriptor. */
6084 6118
6085 fd.fd = android_open (filename, oflag, mode); 6119 fd.fd = android_open (filename, oflag, mode);
6086 if (fd.fd < 1) 6120 if (fd.fd < 0)
6087 return fd; 6121 return fd;
6088 6122
6089 /* Set fd.asset to NULL, signifying that it is a file 6123 /* Set fd.asset to NULL, signifying that it is a file