* INSTALL.android: Explain how to build selinux.
* configure.ac: Enable selinux on Android.
* cross/ndk-build/ndk-build-shared-library.mk: ($(call
objname,$(LOCAL_MODULE),$(basename $(1))))::($$(error
Unsupported suffix)::(NDK_CFLAGS_$(LOCAL_MODULE)):
* cross/ndk-build/ndk-build-static-library.mk: ($(call
objname,$(LOCAL_MODULE),$(basename $(1))))::($$(error
Unsupported suffix)::(NDK_CFLAGS_$(LOCAL_MODULE)): Correctly
handle files with a .cc suffix, and clang-specific asflags.
* cross/ndk-build/ndk-clear-vars.mk: Handle AOSP extensions
LOCAL_ADDITIONAL_DEPENDENCIES,
LOCAL_CLANG_ASFLAGS_$(NDK_BUILD_ARCH) and LOCAL_IS_HOST_MODULE.
* doc/emacs/android.texi (Android Startup): Explain emacsclient
wrapper.
* java/org/gnu/emacs/EmacsView.java (EmacsView): New flag
`isCurrentlyTextEditor'.
(showOnScreenKeyboard, hideOnScreenKeyboard): Set as
appropriate.
(onCheckIsTextEditor): Return its value.
* lisp/touch-screen.el (touch-screen-handle-scroll): Don't ding
at buffer limits.
* m4/ndk-build.m4: Improve doc.
* src/Makefile.in (LIBSELINUX_CFLAGS): New variable.
(EMACS_CFLAGS): Add it.
sqlite3 - https://android.googlesource.com/platform/external/sqlite/
(You must apply the patch at the end of this file, and add the `dist'
directory to ``--with-ndk-path''.)
+ libselinux - https://android.googlesource.com/platform/external/libselinux
+ (You must apply the patches at the end of the file, and obtain
+ the following three dependencies.)
+ libpackagelistparser
+ https://android.googlesource.com/platform/system/core/+/refs/heads/nougat-mr1-dev/libpackagelistparser/
+ libpcre - https://android.googlesource.com/platform/external/pcre
+ libcrypto - https://android.googlesource.com/platform/external/boringssl
Many of these dependencies have been migrated over to the
``Android.bp'' build system now used to build Android itself.
else
NEON := c
endif
+
+PATCHES FOR SELINUX
+
+diff --git a/Android.mk b/Android.mk
+index 659232e..1e64fd6 100644
+--- a/Android.mk
++++ b/Android.mk
+@@ -116,3 +116,7 @@ LOCAL_STATIC_LIBRARIES := libselinux
+ LOCAL_WHOLE_STATIC_LIBRARIES := libpcre
+ LOCAL_C_INCLUDES := external/pcre
+ include $(BUILD_HOST_EXECUTABLE)
++
++$(call import-module,libpcre)
++$(call import-module,libpackagelistparser)
++$(call import-module,libcrypto)
+
+diff --git a/src/android.c b/src/android.c
+index 5206a9f..b351ffc 100644
+--- a/src/android.c
++++ b/src/android.c
+@@ -21,8 +21,7 @@
+ #include <selinux/label.h>
+ #include <selinux/avc.h>
+ #include <openssl/sha.h>
+-#include <private/android_filesystem_config.h>
+-#include <log/log.h>
++#include <android/log.h>
+ #include "policy.h"
+ #include "callbacks.h"
+ #include "selinux_internal.h"
+@@ -686,6 +685,7 @@ static int seapp_context_lookup(enum seapp_kind kind,
+ seinfo = parsedseinfo;
+ }
+
++#if 0
+ userid = uid / AID_USER;
+ isOwner = (userid == 0);
+ appid = uid % AID_USER;
+@@ -702,9 +702,13 @@ static int seapp_context_lookup(enum seapp_kind kind,
+ username = "_app";
+ appid -= AID_APP;
+ } else {
++#endif
+ username = "_isolated";
++ appid = 0;
++#if 0
+ appid -= AID_ISOLATED_START;
+ }
++#endif
+
+ if (appid >= CAT_MAPPING_MAX_ID || userid >= CAT_MAPPING_MAX_ID)
+ goto err;
+@@ -1662,8 +1666,10 @@ int selinux_log_callback(int type, const char *fmt, ...)
+
+ va_start(ap, fmt);
+ if (vasprintf(&strp, fmt, ap) != -1) {
++#if 0
+ LOG_PRI(priority, "SELinux", "%s", strp);
+ LOG_EVENT_STRING(AUDITD_LOG_TAG, strp);
++#endif
+ free(strp);
+ }
+ va_end(ap);
passthrough="$passthrough --with-sqlite3=$with_sqlite3"
passthrough="$passthrough --with-gnutls=$with_gnutls"
passthrough="$passthrough --with-tiff=$with_tiff"
+ passthrough="$passthrough --with-selinux=$with_selinux"
AS_IF([XCONFIGURE=android ANDROID_CC="$ANDROID_CC" \
ANDROID_SDK="$android_sdk" android_abi=$android_abi \
with_sqlite3=no
with_gnutls=no
with_tiff=no
+ with_selinux=no
fi
with_rsvg=no
with_gpm=no
with_dbus=no
with_gsettings=no
- with_selinux=no
with_modules=no
with_threads=no
fi
AC_SUBST([USE_STARTUP_NOTIFICATION])
-dnl SELinux is available for GNU/Linux only.
+dnl SELinux is available for Linux kernel based systems only.
+dnl These include GNU/Linux and Android.
HAVE_LIBSELINUX=no
LIBSELINUX_LIBS=
+LIBSELINUX_CFLAGS=
if test "${with_selinux}" = "yes"; then
- AC_CHECK_LIB([selinux], [lgetfilecon],
- [HAVE_LIBSELINUX=yes],
- [HAVE_LIBSELINUX=no])
+ if test "$REALLY_ANDROID" = "yes"; then
+ ndk_SEARCH_MODULE([libselinux], [LIBSELINUX],
+ [HAVE_LIBSELINUX=yes])
+ else
+ AC_CHECK_LIB([selinux], [lgetfilecon],
+ [HAVE_LIBSELINUX=yes],
+ [HAVE_LIBSELINUX=no])
+ fi
if test "$HAVE_LIBSELINUX" = yes; then
AC_DEFINE([HAVE_LIBSELINUX], [1], [Define to 1 if using SELinux.])
- LIBSELINUX_LIBS=-lselinux
+ if test "$REALLY_ANDROID" != "yes"; then
+ LIBSELINUX_LIBS=-lselinux
+ fi
fi
fi
AC_SUBST([LIBSELINUX_LIBS])
+AC_SUBST([LIBSELINUX_CFLAGS])
HAVE_GNUTLS=no
if test "${with_gnutls}" != "no" ; then
else
ifneq (x$(suffix $(1)),x.asm)
+ifeq (x$(suffix $(1)),x.cc)
+
+$(call objname,$(LOCAL_MODULE),$(basename $(1))): $(LOCAL_PATH)/$(1)
+ $(NDK_BUILD_CC) -c $$< -o $$@ $(NDK_CFLAGS_$(LOCAL_MODULE)) $(NDK_CXXFLAGS_$(LOCAL_MODULE))
+
+else
$$(error Unsupported suffix: $(suffix $(1)))
+endif
else
ifneq (x$(LOCAL_ASM_RULE_DEFINED),x)
# Call this function to define a rule that will generate $(1) from
# $(LOCAL_PATH).
NDK_CFLAGS_$(LOCAL_MODULE) := $(addprefix -I,$(LOCAL_C_INCLUDES))
NDK_CFLAGS_$(LOCAL_MODULE) += -fPIC -iquote $(LOCAL_PATH) $(LOCAL_EXPORT_CFLAGS) $(LOCAL_CFLAGS) $(LOCAL_CFLAGS_$(NDK_BUILD_ARCH))
-NDK_ASFLAGS_$(LOCAL_MODULE) := $(LOCAL_ASFLAGS) $(LOCAL_ASFLAGS_$(NDK_BUILD_ARCH))
+NDK_ASFLAGS_$(LOCAL_MODULE) := $(LOCAL_ASFLAGS) $(LOCAL_ASFLAGS_$(NDK_BUILD_ARCH)) $(and $(findstring clang,$(NDK_BUILD_CC)),$(LOCAL_CLANG_ASFLAGS_$(NDK_BUILD_ARCH)))
NDK_LDFLAGS_$(LOCAL_MODULE) := $(LOCAL_LDLIBS) $(LOCAL_LDFLAGS)
NDK_CXXFLAGS_$(LOCAL_MODULE) := $(LOCAL_CPPFLAGS) $(LOCAL_RTTI_FLAG)
else
ifneq (x$(suffix $(1)),x.asm)
+ifeq (x$(suffix $(1)),x.cc)
+
+$(call objname,$(LOCAL_MODULE),$(basename $(1))): $(LOCAL_PATH)/$(1)
+ $(NDK_BUILD_CC) -c $$< -o $$@ $(NDK_CFLAGS_$(LOCAL_MODULE)) $(NDK_CXXFLAGS_$(LOCAL_MODULE))
+
+else
$$(error Unsupported suffix: $(suffix $(1)))
+endif
else
ifneq (x$(LOCAL_ASM_RULE_DEFINED),x)
# Call this function to define a rule that will generate $(1) from
NDK_CFLAGS_$(LOCAL_MODULE) := $(addprefix -I,$(LOCAL_C_INCLUDES))
NDK_CFLAGS_$(LOCAL_MODULE) += -fPIC -iquote $(LOCAL_PATH) $(LOCAL_EXPORT_CFLAGS) $(LOCAL_CFLAGS) $(LOCAL_CFLAGS_$(NDK_BUILD_ARCH))
-NDK_ASFLAGS_$(LOCAL_MODULE) := $(LOCAL_ASFLAGS) $(LOCAL_ASFLAGS_$(NDK_BUILD_ARCH))
+NDK_ASFLAGS_$(LOCAL_MODULE) := $(LOCAL_ASFLAGS) $(LOCAL_ASFLAGS_$(NDK_BUILD_ARCH)) $(and $(findstring clang,$(NDK_BUILD_CC)),$(LOCAL_CLANG_ASFLAGS_$(NDK_BUILD_ARCH)))
NDK_LDFLAGS_$(LOCAL_MODULE) := $(LOCAL_LDLIBS) $(LOCAL_LDFLAGS)
NDK_CXXFLAGS_$(LOCAL_MODULE) := $(LOCAL_CPPFLAGS) $(LOCAL_RTTI_FLAG)
ALL_OBJECT_FILES$(LOCAL_MODULE) :=
undefine LOCAL_EXPORT_LDFLAGS
undefine LOCAL_EXPORT_LDLIBS
+# AOSP extensions.
undefine LOCAL_SRC_FILES_$(NDK_BUILD_ARCH)
undefine LOCAL_ASFLAGS_$(NDK_BUILD_ARCH)
undefine LOCAL_CFLAGS_$(NDK_BUILD_ARCH)
+undefine LOCAL_ADDITIONAL_DEPENDENCIES
+undefine LOCAL_CLANG_ASFLAGS_$(NDK_BUILD_ARCH)
+undefine LOCAL_IS_HOST_MODULE
# Emacs extensions!
undefine LOCAL_ASM_RULE_DEFINED
the Emacs files directory can be erased through the same preferences
screen.
+@cindex emacsclient wrapper, android
+ Since there is no other way to start the @cmd{emacsclient} program
+(@pxref{Emacs Server}) from another Android program, Emacs provides a
+wrapper around the @cmd{emacsclient} program, which is registered with
+the system as an application that can open all text files.
+
+ When that wrapper is selected as the program with which to open a
+file, it invokes @cmd{emacsclient} with the options
+@cmd{--reuse-frame}, @cmd{--timeout=10}, @cmd{--no-wait}, and the name
+of the file being opened. Then, upon success, the focus is
+transferred to any open Emacs frame.
+
+It is sadly impossible to open certain kinds of files which are
+provided by a ``content provider''. When that is the case, a dialog
+is displayed with an explanation of the error.
+
@node Android File System
@section What files Emacs can access under Android
@cindex /assets directory, android
/* Whether or not this view is attached to a window. */
public boolean isAttachedToWindow;
+ /* Whether or not this view should have the on screen keyboard
+ displayed whenever possible. */
+ public boolean isCurrentlyTextEditor;
+
public
EmacsView (EmacsWindow window)
{
/* Specifying no flags at all tells the system the user asked for
the input method to be displayed. */
imManager.showSoftInput (this, 0);
+ isCurrentlyTextEditor = true;
}
public void
{
imManager.hideSoftInputFromWindow (this.getWindowToken (),
0);
+ isCurrentlyTextEditor = false;
}
public void
screen keyboard to work correctly. */
return null;
}
+
+ @Override
+ public boolean
+ onCheckIsTextEditor ()
+ {
+ /* If value is true, then the system will display the on screen
+ keyboard. */
+ return isCurrentlyTextEditor;
+ }
};
Perform vertical scrolling by DY, using `pixel-scroll-precision'
if `touch-screen-precision-scroll' is enabled. Next, perform
horizontal scrolling according to the movement in DX."
- ;; Perform vertical scrolling first.
- (if touch-screen-precision-scroll
- (if (> dy 0)
- (pixel-scroll-precision-scroll-down-page dy)
- (pixel-scroll-precision-scroll-up-page (- dy)))
- ;; Start conventional scrolling. First, determine the direction
- ;; in which the scrolling is taking place. Load the accumulator
- ;; value.
- (let ((accumulator (or (nth 5 touch-screen-current-tool) 0))
- (window (cadr touch-screen-current-tool))
- (lines-vscrolled (or (nth 7 touch-screen-current-tool) 0)))
- (setq accumulator (+ accumulator dy)) ; Add dy.
- ;; Figure out how much it has scrolled and how much remains on
- ;; the top or bottom of the window.
- (while (catch 'again
- (let* ((line-height (window-default-line-height window)))
- (if (and (< accumulator 0)
- (>= (- accumulator) line-height))
- (progn
- (setq accumulator (+ accumulator line-height))
- (scroll-down 1)
- (setq lines-vscrolled (1+ lines-vscrolled))
- (when (not (zerop accumulator))
- ;; If there is still an outstanding amount to
- ;; scroll, do this again.
- (throw 'again t)))
- (when (and (> accumulator 0)
- (>= accumulator line-height))
- (setq accumulator (- accumulator line-height))
- (scroll-up 1)
- (setq lines-vscrolled (1+ lines-vscrolled))
- (when (not (zerop accumulator))
- ;; If there is still an outstanding amount to
- ;; scroll, do this again.
- (throw 'again t)))))
- ;; Scrolling is done. Move the accumulator back to
- ;; touch-screen-current-tool and break out of the loop.
- (setcar (nthcdr 5 touch-screen-current-tool) accumulator)
- (setcar (nthcdr 7 touch-screen-current-tool)
- lines-vscrolled)
- nil))))
+ ;; Perform vertical scrolling first. Do not ding at buffer limits.
+ ;; Show a message instead.
+ (condition-case nil
+ (if touch-screen-precision-scroll
+ (if (> dy 0)
+ (pixel-scroll-precision-scroll-down-page dy)
+ (pixel-scroll-precision-scroll-up-page (- dy)))
+ ;; Start conventional scrolling. First, determine the
+ ;; direction in which the scrolling is taking place. Load the
+ ;; accumulator value.
+ (let ((accumulator (or (nth 5 touch-screen-current-tool) 0))
+ (window (cadr touch-screen-current-tool))
+ (lines-vscrolled (or (nth 7 touch-screen-current-tool) 0)))
+ (setq accumulator (+ accumulator dy)) ; Add dy.
+ ;; Figure out how much it has scrolled and how much remains
+ ;; on the top or bottom of the window.
+ (while (catch 'again
+ (let* ((line-height (window-default-line-height window)))
+ (if (and (< accumulator 0)
+ (>= (- accumulator) line-height))
+ (progn
+ (setq accumulator (+ accumulator line-height))
+ (scroll-down 1)
+ (setq lines-vscrolled (1+ lines-vscrolled))
+ (when (not (zerop accumulator))
+ ;; If there is still an outstanding
+ ;; amount to scroll, do this again.
+ (throw 'again t)))
+ (when (and (> accumulator 0)
+ (>= accumulator line-height))
+ (setq accumulator (- accumulator line-height))
+ (scroll-up 1)
+ (setq lines-vscrolled (1+ lines-vscrolled))
+ (when (not (zerop accumulator))
+ ;; If there is still an outstanding amount
+ ;; to scroll, do this again.
+ (throw 'again t)))))
+ ;; Scrolling is done. Move the accumulator back to
+ ;; touch-screen-current-tool and break out of the
+ ;; loop.
+ (setcar (nthcdr 5 touch-screen-current-tool) accumulator)
+ (setcar (nthcdr 7 touch-screen-current-tool)
+ lines-vscrolled)
+ nil))))
+ (beginning-of-buffer
+ (message (error-message-string '(beginning-of-buffer))))
+ (end-of-buffer
+ (message (error-message-string '(end-of-buffer)))))
;; Perform horizontal scrolling by DX, as this does not signal at
;; the beginning of the buffer.
done
}
+# ndk_parse_pkg_config_string PKG_CONFIG_STRING
+# ---------------------------------------------
# Parse a pkg-config style list of modules. Place the resulting list
# in ndk_modules.
done
}
-# Resolve $1, a single import. Prepend its makefile to ndk_MAKEFILES
-# if found. Also, prepend all includes to the variable
+# ndk_resolve_import_module MODULE
+# --------------------------------
+# Resolve MODULE, a single import. Prepend its makefile to
+# ndk_MAKEFILES if found. Also, prepend all includes to the variable
# ndk_import_includes.
ndk_resolve_import_module () {
LIBGPM = @LIBGPM@
LIBSELINUX_LIBS = @LIBSELINUX_LIBS@
+LIBSELINUX_CFLAGS = @LIBSELINUX_CFLAGS@
LIBGNUTLS_LIBS = @LIBGNUTLS_LIBS@
LIBGNUTLS_CFLAGS = @LIBGNUTLS_CFLAGS@
$(LIBGNUTLS_CFLAGS) $(NOTIFY_CFLAGS) $(CAIRO_CFLAGS) \
$(WERROR_CFLAGS) $(HAIKU_CFLAGS) $(XCOMPOSITE_CFLAGS) $(XSHAPE_CFLAGS) \
$(ANDROID_CFLAGS) $(GIF_CFLAGS) $(JPEG_CFLAGS) $(SQLITE3_CFLAGS) \
- $(LIBGMP_CFLAGS) $(TIFF_CFLAGS)
+ $(LIBGMP_CFLAGS) $(TIFF_CFLAGS) $(LIBSELINUX_CFLAGS)
ALL_CFLAGS = $(EMACS_CFLAGS) $(WARN_CFLAGS) $(CFLAGS)
ALL_OBJC_CFLAGS = $(EMACS_CFLAGS) \
$(filter-out $(NON_OBJC_CFLAGS),$(WARN_CFLAGS)) $(CFLAGS) \