install_temp/lib/$(ANDROID_ABI)
endif
-install_temp/assets/directory-tree: $(libsrc)/asset-directory-tool install_temp
+install_temp/assets/directory-tree: $(libsrc)/asset-directory-tool \
+ install_temp install_temp/assets/version
$(AM_V_GEN) $(libsrc)/asset-directory-tool install_temp/assets \
install_temp/assets/directory-tree
+install_temp/assets/version: install_temp
+ $(AM_V_GEN) { (git rev-parse HEAD || echo "Unknown") \
+ && (git rev-parse --abbrev-ref HEAD \
+ || echo "Unknown") } 2> /dev/null > $@
+
emacs.apk-in: install_temp install_temp/assets/directory-tree \
- AndroidManifest.xml
+ install_temp/assets/version AndroidManifest.xml
# Package everything. Specifying the assets on this command line is
# necessary for AAssetManager_getNextFileName to work on old versions
# of Android. Make sure not to generate R.java, as it's already been
(defconst emacs-build-number
(if versions (1+ (apply #'max versions)) 1))))
+;; Just set the repository branch during initial dumping on Android.
+(if (and (eq system-type 'android)
+ (not (pdumper-stats)))
+ (setq emacs-repository-version
+ (ignore-errors (emacs-repository-get-version))
+ emacs-repository-branch
+ (ignore-errors (emacs-repository-get-branch))))
(message "Finding pointers to doc strings...")
(if (and (or (and (fboundp 'dump-emacs)
"', version "
(mapconcat #'number-to-string (x-server-version) ".") "\n")
(error t)))
+ (when (and (boundp 'android-build-fingerprint)
+ (symbol-value 'android-build-fingerprint))
+ ;; This is used on Android.
+ (insert "Android version and manufacturer: "
+ (symbol-value 'android-build-fingerprint)
+ "\n"))
(let ((os (ignore-errors (report-emacs-bug--os-description))))
(if (stringp os)
(insert "System Description: " os "\n\n")))
(looking-at "[[:xdigit:]]\\{40\\}"))
(match-string 0)))))
+(defun emacs-repository-version-android ()
+ "Return the Emacs repository revision Emacs was built from.
+Value is nil if Emacs was not built from a repository checkout.
+Use information from the `/assets/version' special file."
+ (with-temp-buffer
+ (insert-file-contents "/assets/version")
+ (let ((string (buffer-substring 1 (line-end-position))))
+ (and (not (equal string "Unknown")) string))))
+
(defun emacs-repository-get-version (&optional dir _external)
"Try to return as a string the repository revision of the Emacs sources.
The format of the returned string is dependent on the VCS in use.
+
+If Emacs is built for Android, use the version information
+embedded in the Emacs installation package.
+
Value is nil if the sources do not seem to be under version
control, or if we could not determine the revision. Note that
this reports on the current state of the sources, which may not
Optional argument DIR is a directory to use instead of `source-directory'.
Optional argument EXTERNAL is ignored."
- (emacs-repository-version-git (or dir source-directory)))
+ (cond ((eq system-type 'android)
+ (emacs-repository-version-android))
+ (t (emacs-repository-version-git
+ (or dir source-directory)))))
(defvar emacs-repository-branch nil
"String giving the repository branch from which this Emacs was built.
Value is nil if Emacs was not built from a repository checkout,
or if we could not determine the branch.")
+(defun emacs-repository-branch-android ()
+ "Return the Emacs repository branch Emacs was built from.
+Value is nil if Emacs was not built from a repository checkout.
+Use information from the `/assets/version' special file."
+ (with-temp-buffer
+ (insert-file-contents "/assets/version")
+ (end-of-line)
+ (forward-char)
+ (let ((string (buffer-substring (point) (line-end-position))))
+ (and (not (equal string "Unknown")) string))))
+
(defun emacs-repository-branch-git (dir)
"Ask git itself for the branch information for directory DIR."
(message "Waiting for git...")
(defun emacs-repository-get-branch (&optional dir)
"Try to return as a string the repository branch of the Emacs sources.
The format of the returned string is dependent on the VCS in use.
+
+If Emacs is built for Android, use the version information
+embedded in the Emacs installation package.
+
Value is nil if the sources do not seem to be under version
control, or if we could not determine the branch. Note that
this reports on the current state of the sources, which may not
correspond to the running Emacs.
Optional argument DIR is a directory to use instead of `source-directory'."
- (emacs-repository-branch-git (or dir source-directory)))
+ (cond ((eq system-type 'android)
+ (emacs-repository-branch-android))
+ (t (emacs-repository-branch-git
+ (or dir source-directory)))))
;;; version.el ends here
#include "window.h"
#include "textconv.h"
#include "coding.h"
+#include "pdumper.h"
/* This is a chain of structures for all the X displays currently in
use. */
\f
+/* Set Vandroid_build_fingerprint to a reasonable value. */
+
+static void
+android_set_build_fingerprint (void)
+{
+#ifdef ANDROID_STUBIFY
+ Vandroid_build_fingerprint = Qnil;
+#else
+ jclass class;
+ jfieldID field;
+ jobject string;
+ const char *data;
+
+ /* Set class to NULL so freeing an uninitialized local ref can be
+ avoided. */
+ class = NULL;
+
+ /* Likewise for string. */
+ string = NULL;
+
+ if (!android_init_gui)
+ goto fail;
+ else
+ {
+ /* Obtain Build.FINGERPRINT. Clear exceptions after each query;
+ JNI can't find Build.FINGERPRIN on some systems. */
+
+ class = (*android_java_env)->FindClass (android_java_env,
+ "android/os/Build");
+ (*android_java_env)->ExceptionClear (android_java_env);
+
+ if (!class)
+ goto fail;
+
+ field = (*android_java_env)->GetStaticFieldID (android_java_env,
+ class,
+ "FINGERPRINT",
+ "Ljava/lang/String;");
+ (*android_java_env)->ExceptionClear (android_java_env);
+
+ if (!field)
+ goto fail;
+
+ string
+ = (*android_java_env)->GetStaticObjectField (android_java_env,
+ class, field);
+ (*android_java_env)->ExceptionClear (android_java_env);
+
+ if (!string)
+ goto fail;
+
+ data = (*android_java_env)->GetStringUTFChars (android_java_env,
+ string, NULL);
+ (*android_java_env)->ExceptionClear (android_java_env);
+
+ if (!data)
+ goto fail;
+
+ Vandroid_build_fingerprint = build_string_from_utf8 (data);
+ (*android_java_env)->ReleaseStringUTFChars (android_java_env,
+ string, data);
+ }
+
+ if (string)
+ ANDROID_DELETE_LOCAL_REF (string);
+
+ ANDROID_DELETE_LOCAL_REF (class);
+
+ return;
+
+ fail:
+ if (class)
+ ANDROID_DELETE_LOCAL_REF (class);
+
+ Vandroid_build_fingerprint = Qnil;
+#endif
+}
+
void
syms_of_androidterm (void)
{
x_underline_at_descent_line,
doc: /* SKIP: real doc in xterm.c. */);
x_underline_at_descent_line = false;
+
+ DEFVAR_LISP ("android-build-fingerprint", Vandroid_build_fingerprint,
+ doc: /* String identifying the device's OS version.
+This is a string that uniquely identifies the version of Android
+Emacs is running on. */);
+
+ /* Avoid dumping Vandroid_build_fingerprint. */
+ pdumper_do_now_and_after_load (android_set_build_fingerprint);
+
DEFSYM (Qx_underline_at_descent_line, "x-underline-at-descent-line");
}