diff options
author | Po Lu <luangruo@yahoo.com> | 2023-10-05 11:57:26 +0800 |
---|---|---|
committer | Po Lu <luangruo@yahoo.com> | 2023-10-05 11:57:26 +0800 |
commit | 253f1aff1ab00e9794f3cfcf50e86e335f411242 (patch) | |
tree | 8a232f9683100875bac890832ee7c3af5ec07a3d /java | |
parent | 511acc2ed827dd039eee1c6d70c77153825d5c67 (diff) | |
download | emacs-253f1aff1ab00e9794f3cfcf50e86e335f411242.tar.gz |
Port Emacs to Android 34
* configure.ac: Detect and require Android 34 headers.
* doc/emacs/android.texi (Android Environment): Mention new
permissions mandated by Android 34.
* java/AndroidManifest.xml.in: Introduce new permissions and
foreground service types prerequisite for background execution under
Android 34.
* java/INSTALL: Update installation documentation.
* java/org/gnu/emacs/EmacsSdk7FontDriver.java (Sdk7FontEntity)
(Sdk7FontObject):
* java/org/gnu/emacs/EmacsService.java (onCreate): Silence deprecation
warnings.
* src/android.c: Update documentation.
Diffstat (limited to 'java')
-rw-r--r-- | java/AndroidManifest.xml.in | 7 | ||||
-rw-r--r-- | java/INSTALL | 10 | ||||
-rw-r--r-- | java/org/gnu/emacs/EmacsSdk7FontDriver.java | 2 | ||||
-rw-r--r-- | java/org/gnu/emacs/EmacsService.java | 17 |
4 files changed, 29 insertions, 7 deletions
diff --git a/java/AndroidManifest.xml.in b/java/AndroidManifest.xml.in index 9ba9dabde81..2749f43c245 100644 --- a/java/AndroidManifest.xml.in +++ b/java/AndroidManifest.xml.in @@ -73,8 +73,12 @@ along with GNU Emacs. If not, see <https://www.gnu.org/licenses/>. --> <uses-permission android:name="android.permission.POST_NOTIFICATIONS"/> + <!-- Under Android 14 or later to run within the background. --> + + <uses-permission android:name="android.permission.FOREGROUND_SERVICE_SPECIAL_USE"/> + <uses-sdk android:minSdkVersion="@ANDROID_MIN_SDK@" - android:targetSdkVersion="33"/> + android:targetSdkVersion="34"/> <application android:name="org.gnu.emacs.EmacsApplication" android:label="Emacs" @@ -190,6 +194,7 @@ along with GNU Emacs. If not, see <https://www.gnu.org/licenses/>. --> android:directBootAware="false" android:enabled="true" android:exported="false" + android:foregroundServiceType="specialUse" android:label="GNU Emacs service"/> </application> </manifest> diff --git a/java/INSTALL b/java/INSTALL index fb235af1346..b6c31483dd3 100644 --- a/java/INSTALL +++ b/java/INSTALL @@ -39,7 +39,7 @@ script like so: Replacing the paths in the command line above with: - the path to the `android.jar' headers which come with the Android - SDK. They must correspond to Android version 13 (API level 33). + SDK. They must correspond to Android version 14 (API level 34). - the path to the C compiler in the Android NDK, for the kind of CPU you are building Emacs to run on. @@ -87,13 +87,13 @@ necessary for compiling Emacs. It is imperative that Emacs is compiled using the headers for the exact API level that it is written for. This is currently API level -33, so the correct android.jar archive is located within a directory -whose name begins with `android-33'. Minor revisions to the headers +34, so the correct android.jar archive is located within a directory +whose name begins with `android-34'. Minor revisions to the headers are inconsequential towards the Emacs compilation process; if there is -a directory named `android-33-extN' (where N represents a revision to +a directory named `android-34-extN' (where N represents a revision to the Android SDK), whether you provide `configure' with that directory's android.jar or the android.jar contained within the -directory named `android-33' is of no special importance. +directory named `android-34' is of no special importance. The ndk directory contains one subdirectory for each version of the Android NDK installed. This directory in turn contains the C and C++ diff --git a/java/org/gnu/emacs/EmacsSdk7FontDriver.java b/java/org/gnu/emacs/EmacsSdk7FontDriver.java index 21ae159d5bd..33d6ee34fa4 100644 --- a/java/org/gnu/emacs/EmacsSdk7FontDriver.java +++ b/java/org/gnu/emacs/EmacsSdk7FontDriver.java @@ -99,6 +99,7 @@ public class EmacsSdk7FontDriver extends EmacsFontDriver /* The typeface. */ public Sdk7Typeface typeface; + @SuppressWarnings ("deprecation") public Sdk7FontEntity (Sdk7Typeface typeface) { @@ -120,6 +121,7 @@ public class EmacsSdk7FontDriver extends EmacsFontDriver /* The typeface. */ public Sdk7Typeface typeface; + @SuppressWarnings ("deprecation") public Sdk7FontObject (Sdk7Typeface typeface, int pixelSize) { diff --git a/java/org/gnu/emacs/EmacsService.java b/java/org/gnu/emacs/EmacsService.java index 997c6923fcc..28b725d0cd0 100644 --- a/java/org/gnu/emacs/EmacsService.java +++ b/java/org/gnu/emacs/EmacsService.java @@ -223,6 +223,21 @@ public final class EmacsService extends Service } } + /* Return the display density, adjusted in accord with the user's + text scaling preferences. */ + + @SuppressWarnings ("deprecation") + private static float + getScaledDensity (DisplayMetrics metrics) + { + /* The scaled density has been made obsolete by the introduction + of non-linear text scaling in Android 34, where there is no + longer a fixed relation between point and pixel sizes, but + remains useful, considering that Emacs does not support + non-linear text scaling. */ + return metrics.scaledDensity; + } + @Override public void onCreate () @@ -242,7 +257,7 @@ public final class EmacsService extends Service metrics = getResources ().getDisplayMetrics (); pixelDensityX = metrics.xdpi; pixelDensityY = metrics.ydpi; - tempScaledDensity = ((metrics.scaledDensity + tempScaledDensity = ((getScaledDensity (metrics) / metrics.density) * pixelDensityX); resolver = getContentResolver (); |