aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorPo Lu2023-02-17 21:09:00 +0800
committerPo Lu2023-02-17 21:09:00 +0800
commitd70bb47aeb586bfa5feb29d6f3759604eb93829a (patch)
tree38817755116a2ebfa1331cc633ff955eb8a2b4c7
parent1f81186d67b2a86e6a555a7ad3323fcd13f5e257 (diff)
downloademacs-d70bb47aeb586bfa5feb29d6f3759604eb93829a.tar.gz
emacs-d70bb47aeb586bfa5feb29d6f3759604eb93829a.zip
Update emacsbug and version.el for the Android port
* java/Makefile.in (install_temp/assets/version): New generated file. * lisp/loadup.el: Set emacs versions appropriately prior to dumping on Android. * lisp/mail/emacsbug.el (emacs-build-description): Insert Android build fingerprint. * lisp/version.el (emacs-repository-version-android) (emacs-repository-get-version, emacs-repository-get-branch): Implement for Android. * src/androidterm.c (android_set_build_fingerprint): New function. (syms_of_androidterm): New variable `android-build-fingerprint'.
-rw-r--r--java/Makefile.in10
-rw-r--r--lisp/loadup.el7
-rw-r--r--lisp/mail/emacsbug.el6
-rw-r--r--lisp/version.el38
-rw-r--r--src/androidterm.c88
5 files changed, 145 insertions, 4 deletions
diff --git a/java/Makefile.in b/java/Makefile.in
index 92c03469c69..f732c9211ee 100644
--- a/java/Makefile.in
+++ b/java/Makefile.in
@@ -192,12 +192,18 @@ ifneq ($(NDK_BUILD_SHARED),)
192 install_temp/lib/$(ANDROID_ABI) 192 install_temp/lib/$(ANDROID_ABI)
193endif 193endif
194 194
195install_temp/assets/directory-tree: $(libsrc)/asset-directory-tool install_temp 195install_temp/assets/directory-tree: $(libsrc)/asset-directory-tool \
196 install_temp install_temp/assets/version
196 $(AM_V_GEN) $(libsrc)/asset-directory-tool install_temp/assets \ 197 $(AM_V_GEN) $(libsrc)/asset-directory-tool install_temp/assets \
197 install_temp/assets/directory-tree 198 install_temp/assets/directory-tree
198 199
200install_temp/assets/version: install_temp
201 $(AM_V_GEN) { (git rev-parse HEAD || echo "Unknown") \
202 && (git rev-parse --abbrev-ref HEAD \
203 || echo "Unknown") } 2> /dev/null > $@
204
199emacs.apk-in: install_temp install_temp/assets/directory-tree \ 205emacs.apk-in: install_temp install_temp/assets/directory-tree \
200 AndroidManifest.xml 206 install_temp/assets/version AndroidManifest.xml
201# Package everything. Specifying the assets on this command line is 207# Package everything. Specifying the assets on this command line is
202# necessary for AAssetManager_getNextFileName to work on old versions 208# necessary for AAssetManager_getNextFileName to work on old versions
203# of Android. Make sure not to generate R.java, as it's already been 209# of Android. Make sure not to generate R.java, as it's already been
diff --git a/lisp/loadup.el b/lisp/loadup.el
index 1747d1d960a..3b30414b146 100644
--- a/lisp/loadup.el
+++ b/lisp/loadup.el
@@ -439,6 +439,13 @@ lost after dumping")))
439 (defconst emacs-build-number 439 (defconst emacs-build-number
440 (if versions (1+ (apply #'max versions)) 1)))) 440 (if versions (1+ (apply #'max versions)) 1))))
441 441
442;; Just set the repository branch during initial dumping on Android.
443(if (and (eq system-type 'android)
444 (not (pdumper-stats)))
445 (setq emacs-repository-version
446 (ignore-errors (emacs-repository-get-version))
447 emacs-repository-branch
448 (ignore-errors (emacs-repository-get-branch))))
442 449
443(message "Finding pointers to doc strings...") 450(message "Finding pointers to doc strings...")
444(if (and (or (and (fboundp 'dump-emacs) 451(if (and (or (and (fboundp 'dump-emacs)
diff --git a/lisp/mail/emacsbug.el b/lisp/mail/emacsbug.el
index f686c04536c..68f9dcfea0b 100644
--- a/lisp/mail/emacsbug.el
+++ b/lisp/mail/emacsbug.el
@@ -408,6 +408,12 @@ copy text to your preferred mail program.\n"
408 "', version " 408 "', version "
409 (mapconcat #'number-to-string (x-server-version) ".") "\n") 409 (mapconcat #'number-to-string (x-server-version) ".") "\n")
410 (error t))) 410 (error t)))
411 (when (and (boundp 'android-build-fingerprint)
412 (symbol-value 'android-build-fingerprint))
413 ;; This is used on Android.
414 (insert "Android version and manufacturer: "
415 (symbol-value 'android-build-fingerprint)
416 "\n"))
411 (let ((os (ignore-errors (report-emacs-bug--os-description)))) 417 (let ((os (ignore-errors (report-emacs-bug--os-description))))
412 (if (stringp os) 418 (if (stringp os)
413 (insert "System Description: " os "\n\n"))) 419 (insert "System Description: " os "\n\n")))
diff --git a/lisp/version.el b/lisp/version.el
index 9cadc59237f..38a9f9c2be5 100644
--- a/lisp/version.el
+++ b/lisp/version.el
@@ -130,9 +130,22 @@ or if we could not determine the revision.")
130 (looking-at "[[:xdigit:]]\\{40\\}")) 130 (looking-at "[[:xdigit:]]\\{40\\}"))
131 (match-string 0))))) 131 (match-string 0)))))
132 132
133(defun emacs-repository-version-android ()
134 "Return the Emacs repository revision Emacs was built from.
135Value is nil if Emacs was not built from a repository checkout.
136Use information from the `/assets/version' special file."
137 (with-temp-buffer
138 (insert-file-contents "/assets/version")
139 (let ((string (buffer-substring 1 (line-end-position))))
140 (and (not (equal string "Unknown")) string))))
141
133(defun emacs-repository-get-version (&optional dir _external) 142(defun emacs-repository-get-version (&optional dir _external)
134 "Try to return as a string the repository revision of the Emacs sources. 143 "Try to return as a string the repository revision of the Emacs sources.
135The format of the returned string is dependent on the VCS in use. 144The format of the returned string is dependent on the VCS in use.
145
146If Emacs is built for Android, use the version information
147embedded in the Emacs installation package.
148
136Value is nil if the sources do not seem to be under version 149Value is nil if the sources do not seem to be under version
137control, or if we could not determine the revision. Note that 150control, or if we could not determine the revision. Note that
138this reports on the current state of the sources, which may not 151this reports on the current state of the sources, which may not
@@ -140,13 +153,27 @@ correspond to the running Emacs.
140 153
141Optional argument DIR is a directory to use instead of `source-directory'. 154Optional argument DIR is a directory to use instead of `source-directory'.
142Optional argument EXTERNAL is ignored." 155Optional argument EXTERNAL is ignored."
143 (emacs-repository-version-git (or dir source-directory))) 156 (cond ((eq system-type 'android)
157 (emacs-repository-version-android))
158 (t (emacs-repository-version-git
159 (or dir source-directory)))))
144 160
145(defvar emacs-repository-branch nil 161(defvar emacs-repository-branch nil
146 "String giving the repository branch from which this Emacs was built. 162 "String giving the repository branch from which this Emacs was built.
147Value is nil if Emacs was not built from a repository checkout, 163Value is nil if Emacs was not built from a repository checkout,
148or if we could not determine the branch.") 164or if we could not determine the branch.")
149 165
166(defun emacs-repository-branch-android ()
167 "Return the Emacs repository branch Emacs was built from.
168Value is nil if Emacs was not built from a repository checkout.
169Use information from the `/assets/version' special file."
170 (with-temp-buffer
171 (insert-file-contents "/assets/version")
172 (end-of-line)
173 (forward-char)
174 (let ((string (buffer-substring (point) (line-end-position))))
175 (and (not (equal string "Unknown")) string))))
176
150(defun emacs-repository-branch-git (dir) 177(defun emacs-repository-branch-git (dir)
151 "Ask git itself for the branch information for directory DIR." 178 "Ask git itself for the branch information for directory DIR."
152 (message "Waiting for git...") 179 (message "Waiting for git...")
@@ -162,12 +189,19 @@ or if we could not determine the branch.")
162(defun emacs-repository-get-branch (&optional dir) 189(defun emacs-repository-get-branch (&optional dir)
163 "Try to return as a string the repository branch of the Emacs sources. 190 "Try to return as a string the repository branch of the Emacs sources.
164The format of the returned string is dependent on the VCS in use. 191The format of the returned string is dependent on the VCS in use.
192
193If Emacs is built for Android, use the version information
194embedded in the Emacs installation package.
195
165Value is nil if the sources do not seem to be under version 196Value is nil if the sources do not seem to be under version
166control, or if we could not determine the branch. Note that 197control, or if we could not determine the branch. Note that
167this reports on the current state of the sources, which may not 198this reports on the current state of the sources, which may not
168correspond to the running Emacs. 199correspond to the running Emacs.
169 200
170Optional argument DIR is a directory to use instead of `source-directory'." 201Optional argument DIR is a directory to use instead of `source-directory'."
171 (emacs-repository-branch-git (or dir source-directory))) 202 (cond ((eq system-type 'android)
203 (emacs-repository-branch-android))
204 (t (emacs-repository-branch-git
205 (or dir source-directory)))))
172 206
173;;; version.el ends here 207;;; version.el ends here
diff --git a/src/androidterm.c b/src/androidterm.c
index c6f75ec9219..8a07bfa7455 100644
--- a/src/androidterm.c
+++ b/src/androidterm.c
@@ -33,6 +33,7 @@ along with GNU Emacs. If not, see <https://www.gnu.org/licenses/>. */
33#include "window.h" 33#include "window.h"
34#include "textconv.h" 34#include "textconv.h"
35#include "coding.h" 35#include "coding.h"
36#include "pdumper.h"
36 37
37/* This is a chain of structures for all the X displays currently in 38/* This is a chain of structures for all the X displays currently in
38 use. */ 39 use. */
@@ -5413,6 +5414,84 @@ android_term_init (void)
5413 5414
5414 5415
5415 5416
5417/* Set Vandroid_build_fingerprint to a reasonable value. */
5418
5419static void
5420android_set_build_fingerprint (void)
5421{
5422#ifdef ANDROID_STUBIFY
5423 Vandroid_build_fingerprint = Qnil;
5424#else
5425 jclass class;
5426 jfieldID field;
5427 jobject string;
5428 const char *data;
5429
5430 /* Set class to NULL so freeing an uninitialized local ref can be
5431 avoided. */
5432 class = NULL;
5433
5434 /* Likewise for string. */
5435 string = NULL;
5436
5437 if (!android_init_gui)
5438 goto fail;
5439 else
5440 {
5441 /* Obtain Build.FINGERPRINT. Clear exceptions after each query;
5442 JNI can't find Build.FINGERPRIN on some systems. */
5443
5444 class = (*android_java_env)->FindClass (android_java_env,
5445 "android/os/Build");
5446 (*android_java_env)->ExceptionClear (android_java_env);
5447
5448 if (!class)
5449 goto fail;
5450
5451 field = (*android_java_env)->GetStaticFieldID (android_java_env,
5452 class,
5453 "FINGERPRINT",
5454 "Ljava/lang/String;");
5455 (*android_java_env)->ExceptionClear (android_java_env);
5456
5457 if (!field)
5458 goto fail;
5459
5460 string
5461 = (*android_java_env)->GetStaticObjectField (android_java_env,
5462 class, field);
5463 (*android_java_env)->ExceptionClear (android_java_env);
5464
5465 if (!string)
5466 goto fail;
5467
5468 data = (*android_java_env)->GetStringUTFChars (android_java_env,
5469 string, NULL);
5470 (*android_java_env)->ExceptionClear (android_java_env);
5471
5472 if (!data)
5473 goto fail;
5474
5475 Vandroid_build_fingerprint = build_string_from_utf8 (data);
5476 (*android_java_env)->ReleaseStringUTFChars (android_java_env,
5477 string, data);
5478 }
5479
5480 if (string)
5481 ANDROID_DELETE_LOCAL_REF (string);
5482
5483 ANDROID_DELETE_LOCAL_REF (class);
5484
5485 return;
5486
5487 fail:
5488 if (class)
5489 ANDROID_DELETE_LOCAL_REF (class);
5490
5491 Vandroid_build_fingerprint = Qnil;
5492#endif
5493}
5494
5416void 5495void
5417syms_of_androidterm (void) 5496syms_of_androidterm (void)
5418{ 5497{
@@ -5441,6 +5520,15 @@ If set to a non-float value, there will be no wait at all. */);
5441 x_underline_at_descent_line, 5520 x_underline_at_descent_line,
5442 doc: /* SKIP: real doc in xterm.c. */); 5521 doc: /* SKIP: real doc in xterm.c. */);
5443 x_underline_at_descent_line = false; 5522 x_underline_at_descent_line = false;
5523
5524 DEFVAR_LISP ("android-build-fingerprint", Vandroid_build_fingerprint,
5525 doc: /* String identifying the device's OS version.
5526This is a string that uniquely identifies the version of Android
5527Emacs is running on. */);
5528
5529 /* Avoid dumping Vandroid_build_fingerprint. */
5530 pdumper_do_now_and_after_load (android_set_build_fingerprint);
5531
5444 DEFSYM (Qx_underline_at_descent_line, "x-underline-at-descent-line"); 5532 DEFSYM (Qx_underline_at_descent_line, "x-underline-at-descent-line");
5445} 5533}
5446 5534