]> git.eshelyaron.com Git - emacs.git/commitdiff
Port better to Android 3.0
authorPo Lu <luangruo@yahoo.com>
Tue, 16 Jul 2024 02:14:30 +0000 (10:14 +0800)
committerEshel Yaron <me@eshelyaron.com>
Thu, 18 Jul 2024 06:29:26 +0000 (08:29 +0200)
* 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.

(cherry picked from commit 34882d524328638e2198952578638e0ffe0697c5)

java/org/gnu/emacs/EmacsNoninteractive.java

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