1
Fork 0
mirror of git://git.sv.gnu.org/emacs.git synced 2026-04-22 05:51:11 -07:00

Update Android port

* INSTALL.android: Update.
* build-aux/ndk-build-helper-1.mk: Fix typo.
* configure.ac: Enable --with-json on Android.
* cross/ndk-build/ndk-build-shared-library.mk:
(NDK_CFLAGS_$(LOCAL_MODULE)):
(LOCAL_MODULE_FILENAME):
* cross/ndk-build/ndk-build-static-library.mk:
(ALL_OBJECT_FILES$(LOCAL_MODULE)):
(LOCAL_MODULE_FILENAME): Recursively resolve dependencies.
* cross/ndk-build/ndk-resolve.mk: New function.

* doc/emacs/android.texi (Android Startup): Document how Emacs
is dumped during initial startup.

* java/Makefile.in (filename): Fix build with multiple shared
libraries.
* java/README: Improve commentary.
* java/org/gnu/emacs/EmacsApplication.java (onCreate): Look and
set dump file.
* java/org/gnu/emacs/EmacsNative.java (EmacsNative): New
function getFingerprint.
* java/org/gnu/emacs/EmacsPreferencesActivity.java (onCreate):
Add option to erase the dump file.
* java/org/gnu/emacs/EmacsService.java (browseUrl): New
function.
* java/org/gnu/emacs/EmacsThread.java (run): Specify dump file
if found.
* lisp/loadup.el: Always dump during loadup on Android.

* lisp/net/browse-url.el (browse-url--browser-defcustom-type):
(browse-url-default-browser):
(browse-url-default-android-browser): New browse url type.

* m4/ndk-build.m4 (ndk_package_map): Map jansson to libjansson.
* src/android.c (struct android_emacs_service): New method
`browse_url'.
(getFingerprint): New function.
(android_init_emacs_service): Initialize new method.
(android_browse_url): New function.

* src/android.h: Update prototypes.

* src/androidselect.c (Fandroid_browse_url): New function.
(syms_of_androidselect): Define it.

* src/emacs.c (load_pdump): Don't look in fancy places on
Android.
* src/pdumper.c (Fdump_emacs_portable): Allow dumping while
interactive on Android.
(syms_of_pdumper): New variable `pdumper-fingerprint'.

* src/sfntfont-android.c (sfntfont_android_composite_bitmap):
Fix unused variables.
This commit is contained in:
Po Lu 2023-01-24 17:31:16 +08:00
parent 3267a2d6d2
commit 56e55a8008
23 changed files with 518 additions and 102 deletions

View file

@ -19,9 +19,59 @@ along with GNU Emacs. If not, see <https://www.gnu.org/licenses/>. */
package org.gnu.emacs;
import android.app.Application;
import java.io.File;
import java.io.FileFilter;
public class EmacsApplication extends Application
import android.app.Application;
import android.util.Log;
public class EmacsApplication extends Application implements FileFilter
{
/* This class currently does nothing. */
private static final String TAG = "EmacsApplication";
/* The name of the dump file to use. */
public static String dumpFileName;
@Override
public boolean
accept (File file)
{
return (!file.isDirectory ()
&& file.getName ().endsWith (".pdmp"));
}
@Override
public void
onCreate ()
{
File filesDirectory;
File[] allFiles;
String wantedDumpFile;
int i;
wantedDumpFile = ("emacs-" + EmacsNative.getFingerprint ()
+ ".pdmp");
Log.d (TAG, "onCreate: looking for " + wantedDumpFile);
/* Obtain a list of all files ending with ``.pdmp''. Then, look
for a file named ``emacs-<fingerprint>.pdmp'' and delete the
rest. */
filesDirectory = getFilesDir ();
allFiles = filesDirectory.listFiles (this);
/* Now try to find the right dump file. */
for (i = 0; i < allFiles.length; ++i)
{
if (allFiles[i].getName ().equals (wantedDumpFile))
dumpFileName = allFiles[i].getAbsolutePath ();
else
/* Delete this outdated dump file. */
allFiles[i].delete ();
}
Log.d (TAG, "onCreate: found " + dumpFileName);
super.onCreate ();
}
};

View file

@ -25,6 +25,10 @@ import android.content.res.AssetManager;
public class EmacsNative
{
/* Obtain the fingerprint of this build of Emacs. The fingerprint
can be used to determine the dump file name. */
public static native String getFingerprint ();
/* Set certain parameters before initializing Emacs. This proves
that libemacs.so is being loaded from Java code.

View file

@ -19,6 +19,8 @@ along with GNU Emacs. If not, see <https://www.gnu.org/licenses/>. */
package org.gnu.emacs;
import java.io.File;
import android.app.Activity;
import android.content.Intent;
import android.os.Bundle;
@ -93,6 +95,31 @@ public class EmacsPreferencesActivity extends Activity
});
layout.addView (textView);
textView = new TextView (this);
textView.setPadding (8, 20, 20, 8);
params = new LinearLayout.LayoutParams (LayoutParams.MATCH_PARENT,
LayoutParams.WRAP_CONTENT);
textView.setLayoutParams (params);
textView.setText ("Erase dump file");
textView.setOnClickListener (new View.OnClickListener () {
@Override
public void
onClick (View view)
{
String wantedDumpFile;
File file;
wantedDumpFile = ("emacs-" + EmacsNative.getFingerprint ()
+ ".pdmp");
file = new File (getFilesDir (), wantedDumpFile);
if (file.exists ())
file.delete ();
}
});
layout.addView (textView);
super.onCreate (savedInstanceState);
}
};

View file

@ -43,6 +43,8 @@ import android.content.Context;
import android.content.Intent;
import android.content.res.AssetManager;
import android.net.Uri;
import android.os.Build;
import android.os.Looper;
import android.os.IBinder;
@ -504,4 +506,27 @@ public class EmacsService extends Service
EmacsService.class));
}
}
/* Ask the system to open the specified URL.
Value is NULL upon success, or a string describing the error
upon failure. */
public String
browseUrl (String url)
{
Intent intent;
try
{
intent = new Intent (Intent.ACTION_VIEW, Uri.parse (url));
intent.setFlags (Intent.FLAG_ACTIVITY_NEW_TASK);
startActivity (intent);
}
catch (Exception e)
{
return e.toString ();
}
return null;
}
};

View file

@ -38,10 +38,23 @@ public class EmacsThread extends Thread
{
String args[];
if (!startDashQ)
args = new String[] { "libandroid-emacs.so", };
if (EmacsApplication.dumpFileName == null)
{
if (!startDashQ)
args = new String[] { "libandroid-emacs.so", };
else
args = new String[] { "libandroid-emacs.so", "-Q", };
}
else
args = new String[] { "libandroid-emacs.so", "-Q", };
{
if (!startDashQ)
args = new String[] { "libandroid-emacs.so", "--dump-file",
EmacsApplication.dumpFileName, };
else
args = new String[] { "libandroid-emacs.so", "-Q",
"--dump-file",
EmacsApplication.dumpFileName, };
}
/* Run the native code now. */
EmacsNative.initEmacs (args);