Port better to Android 3.0

* java/org/gnu/emacs/EmacsNoninteractive.java (main): Use the
old getPackageInfo calling convention if it exists rather than
on Android 2.3.3 and earlier.
This commit is contained in:
Po Lu 2024-07-16 10:14:30 +08:00
parent 765cfaed77
commit 34882d5243

View file

@ -120,11 +120,11 @@ public final class EmacsNoninteractive
} }
/* Get a LoadedApk or ActivityThread.PackageInfo. How to do /* Get a LoadedApk or ActivityThread.PackageInfo. How to do
this varies by Android version. On Android 2.3.3 and this varies by Android version. On Android 3.0 and earlier,
earlier, there is no ``compatibilityInfo'' argument to there is no ``compatibilityInfo'' argument to
getPackageInfo. */ getPackageInfo. */
if (Build.VERSION.SDK_INT <= Build.VERSION_CODES.GINGERBREAD_MR1) try
{ {
method method
= activityThreadClass.getMethod ("getPackageInfo", = activityThreadClass.getMethod ("getPackageInfo",
@ -134,7 +134,7 @@ public final class EmacsNoninteractive
(Context.CONTEXT_INCLUDE_CODE (Context.CONTEXT_INCLUDE_CODE
| Context.CONTEXT_IGNORE_SECURITY)); | Context.CONTEXT_IGNORE_SECURITY));
} }
else catch (NoSuchMethodException exception)
{ {
compatibilityInfoClass compatibilityInfoClass
= Class.forName ("android.content.res.CompatibilityInfo"); = Class.forName ("android.content.res.CompatibilityInfo");