From 0baddd9fe81208cb62c83276f3a1ebbe2c3c01f2 Mon Sep 17 00:00:00 2001 From: Julian Winkler Date: Sat, 20 May 2023 12:26:19 +0200 Subject: [PATCH] fixes for android-8 rebase of dalvik_standalone detect bootclasspath jar path automatically from dalvik_standalone --- doc/Architecture.md | 1 - meson.build | 10 +++++ .../android/content/pm/ManifestDigest.java | 2 +- .../android/content/res/Resources.java | 40 +++++++++---------- src/api-impl/meson.build | 2 +- src/arsc_parser/meson.build | 2 +- src/main-executable/main.c | 2 +- 7 files changed, 34 insertions(+), 25 deletions(-) diff --git a/doc/Architecture.md b/doc/Architecture.md index 944a70bb..586508bd 100644 --- a/doc/Architecture.md +++ b/doc/Architecture.md @@ -1,7 +1,6 @@ #### directory structure `src/arsc_parser/` - Java .arsc parser I found somewhere, with fixes (should eventually get replaced by C code) `doc/` - documentation -`jars/` - contains core-libart-hostdex_classes.jar which we use as compile-time bootclasspath (TODO: have art-dev package install this system-wide) `src/api-impl/` - Java code implementing the android APIs `src/api-impl-jni/` - C code implementing things which it doesn't make sense to do in Java (ideally this would be most things) `src/libandroid/` - C code implementing `libandroid.so` (this is needed by most JNI libs which come with android apps) diff --git a/meson.build b/meson.build index 14cbc54a..9421efc8 100644 --- a/meson.build +++ b/meson.build @@ -6,6 +6,7 @@ if javac.version() != '1.8.0' endif gnome = import('gnome') +fs = import('fs') incdir_dep = declare_dependency(include_directories: '.') add_project_dependencies(incdir_dep, language: 'c') @@ -21,6 +22,15 @@ libart_dep = [ libdl_bio_dep = [ cc.find_library('dl_bio') ] +if fs.is_file('/usr' / get_option('libdir') / 'java/core-all_classes.jar') + bootclasspath = '/usr' / get_option('libdir') / 'java/core-all_classes.jar' +elif fs.is_file('/usr/local' / get_option('libdir') / 'java/core-all_classes.jar') + bootclasspath = '/usr/local' / get_option('libdir') / 'java/core-all_classes.jar' +elif fs.is_file(get_option('prefix') / get_option('libdir') / 'java/core-all_classes.jar') + bootclasspath = get_option('prefix') / get_option('libdir') / 'java/core-all_classes.jar' +else + error('bootclasspath "core-all_classes.jar" not found') +endif marshal_files = gnome.genmarshal('marshal', sources: 'src/api-impl-jni/widgets/marshal.list', diff --git a/src/api-impl/android/content/pm/ManifestDigest.java b/src/api-impl/android/content/pm/ManifestDigest.java index b22818be..d81568b5 100644 --- a/src/api-impl/android/content/pm/ManifestDigest.java +++ b/src/api-impl/android/content/pm/ManifestDigest.java @@ -109,7 +109,7 @@ public class ManifestDigest { final int N = mDigest.length; for (int i = 0; i < N; i++) { final byte b = mDigest[i]; - IntegralToString.appendByteAsHex(sb, b, false); + sb.append(String.format("%02x", b)); sb.append(','); } sb.append('}'); diff --git a/src/api-impl/android/content/res/Resources.java b/src/api-impl/android/content/res/Resources.java index 8e66e85e..f495dd40 100644 --- a/src/api-impl/android/content/res/Resources.java +++ b/src/api-impl/android/content/res/Resources.java @@ -43,7 +43,7 @@ import java.io.InputStream; import java.lang.ref.WeakReference; import java.util.Locale; -import libcore.icu.NativePluralRules; +import android.icu.text.PluralRules; class Movie {} class Drawable { class ConstantState {} } @@ -126,7 +126,7 @@ public class Resources { /*package*/ final AssetManager mAssets; private final Configuration mConfiguration = new Configuration(); /*package*/ final DisplayMetrics mMetrics = new DisplayMetrics(); - private NativePluralRules mPluralRule; + private PluralRules mPluralRule; private CompatibilityInfo mCompatibilityInfo = CompatibilityInfo.DEFAULT_COMPATIBILITY_INFO; private WeakReference mToken; @@ -274,9 +274,9 @@ public class Resources { * possibly styled text information. */ public CharSequence getQuantityText(int id, int quantity) throws NotFoundException { - NativePluralRules rule = getPluralRule(); + PluralRules rule = getPluralRule(); CharSequence res = mAssets.getResourceBagText(id, - attrForQuantityCode(rule.quantityForInt(quantity))); + attrForQuantityCode(rule.select(quantity))); if (res != null) { return res; } @@ -286,36 +286,36 @@ public class Resources { } throw new NotFoundException("Plural resource ID #0x" + Integer.toHexString(id) + " quantity=" + quantity - + " item=" + stringForQuantityCode(rule.quantityForInt(quantity))); + + " item=" + rule.select(quantity)); } - private NativePluralRules getPluralRule() { + private PluralRules getPluralRule() { synchronized (sSync) { if (mPluralRule == null) { - mPluralRule = NativePluralRules.forLocale(mConfiguration.locale); + mPluralRule = PluralRules.forLocale(mConfiguration.locale); } return mPluralRule; } } - private static int attrForQuantityCode(int quantityCode) { + private static int attrForQuantityCode(String quantityCode) { switch (quantityCode) { - case NativePluralRules.ZERO: return 0x01000005; - case NativePluralRules.ONE: return 0x01000006; - case NativePluralRules.TWO: return 0x01000007; - case NativePluralRules.FEW: return 0x01000008; - case NativePluralRules.MANY: return 0x01000009; + case PluralRules.KEYWORD_ZERO: return 0x01000005; + case PluralRules.KEYWORD_ONE: return 0x01000006; + case PluralRules.KEYWORD_TWO: return 0x01000007; + case PluralRules.KEYWORD_FEW: return 0x01000008; + case PluralRules.KEYWORD_MANY: return 0x01000009; default: return ID_OTHER; } } - private static String stringForQuantityCode(int quantityCode) { + private static String stringForQuantityCode(String quantityCode) { switch (quantityCode) { - case NativePluralRules.ZERO: return "zero"; - case NativePluralRules.ONE: return "one"; - case NativePluralRules.TWO: return "two"; - case NativePluralRules.FEW: return "few"; - case NativePluralRules.MANY: return "many"; + case PluralRules.KEYWORD_ZERO: return "zero"; + case PluralRules.KEYWORD_ONE: return "one"; + case PluralRules.KEYWORD_TWO: return "two"; + case PluralRules.KEYWORD_FEW: return "few"; + case PluralRules.KEYWORD_MANY: return "many"; default: return "other"; } } @@ -1623,7 +1623,7 @@ public class Resources { } synchronized (sSync) { if (mPluralRule != null) { - mPluralRule = NativePluralRules.forLocale(config.locale); + mPluralRule = PluralRules.forLocale(config.locale); } } } diff --git a/src/api-impl/meson.build b/src/api-impl/meson.build index ddd0dbcd..f6896677 100644 --- a/src/api-impl/meson.build +++ b/src/api-impl/meson.build @@ -249,7 +249,7 @@ hax_jar = jar('hax', [ declare_dependency(link_with: hax_arsc_parser_jar) ], java_args: [ - '-bootclasspath', join_paths(dir_base, 'jars/core-libart-hostdex_classes.jar'), + '-bootclasspath', bootclasspath, '-source', '1.7', '-target', '1.7', '-h', join_paths(dir_base, 'src/api-impl-jni/generated_headers') ]) diff --git a/src/arsc_parser/meson.build b/src/arsc_parser/meson.build index e8bd8f15..711f2347 100644 --- a/src/arsc_parser/meson.build +++ b/src/arsc_parser/meson.build @@ -20,7 +20,7 @@ hax_arsc_parser_jar = jar('hax_arsc_parser', [ 'com/hq/arscresourcesparser/stream/PositionInputStream.java' ], java_args: [ - '-bootclasspath', join_paths(dir_base, 'jars/core-libart-hostdex_classes.jar'), + '-bootclasspath', bootclasspath, '-source', '1.7', '-target', '1.7' ]) diff --git a/src/main-executable/main.c b/src/main-executable/main.c index 0783aea4..5d9e754e 100644 --- a/src/main-executable/main.c +++ b/src/main-executable/main.c @@ -296,7 +296,7 @@ static void open(GtkApplication *app, GFile** files, gint nfiles, const gchar* h // some apps need the apk path since they directly read their apk jclass context_class = (*env)->FindClass(env, "android/content/Context"); - _SET_STATIC_OBJ_FIELD(context_class, "apk_path", "java/lang/String", _JSTRING(apk_classpath)); + _SET_STATIC_OBJ_FIELD(context_class, "apk_path", "Ljava/lang/String;", _JSTRING(apk_classpath)); FIXME__WIDTH = d->window_width; FIXME__HEIGHT = d->window_height;