fixes for android-8 rebase of dalvik_standalone

detect bootclasspath jar path automatically from dalvik_standalone
This commit is contained in:
Julian Winkler
2023-05-20 12:26:19 +02:00
parent 55098136dc
commit 0baddd9fe8
7 changed files with 34 additions and 25 deletions

View File

@@ -1,7 +1,6 @@
#### directory structure #### directory structure
`src/arsc_parser/` - Java .arsc parser I found somewhere, with fixes (should eventually get replaced by C code) `src/arsc_parser/` - Java .arsc parser I found somewhere, with fixes (should eventually get replaced by C code)
`doc/` - documentation `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/` - 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/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) `src/libandroid/` - C code implementing `libandroid.so` (this is needed by most JNI libs which come with android apps)

View File

@@ -6,6 +6,7 @@ if javac.version() != '1.8.0'
endif endif
gnome = import('gnome') gnome = import('gnome')
fs = import('fs')
incdir_dep = declare_dependency(include_directories: '.') incdir_dep = declare_dependency(include_directories: '.')
add_project_dependencies(incdir_dep, language: 'c') add_project_dependencies(incdir_dep, language: 'c')
@@ -21,6 +22,15 @@ libart_dep = [
libdl_bio_dep = [ libdl_bio_dep = [
cc.find_library('dl_bio') 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', marshal_files = gnome.genmarshal('marshal',
sources: 'src/api-impl-jni/widgets/marshal.list', sources: 'src/api-impl-jni/widgets/marshal.list',

View File

@@ -109,7 +109,7 @@ public class ManifestDigest {
final int N = mDigest.length; final int N = mDigest.length;
for (int i = 0; i < N; i++) { for (int i = 0; i < N; i++) {
final byte b = mDigest[i]; final byte b = mDigest[i];
IntegralToString.appendByteAsHex(sb, b, false); sb.append(String.format("%02x", b));
sb.append(','); sb.append(',');
} }
sb.append('}'); sb.append('}');

View File

@@ -43,7 +43,7 @@ import java.io.InputStream;
import java.lang.ref.WeakReference; import java.lang.ref.WeakReference;
import java.util.Locale; import java.util.Locale;
import libcore.icu.NativePluralRules; import android.icu.text.PluralRules;
class Movie {} class Movie {}
class Drawable { class ConstantState {} } class Drawable { class ConstantState {} }
@@ -126,7 +126,7 @@ public class Resources {
/*package*/ final AssetManager mAssets; /*package*/ final AssetManager mAssets;
private final Configuration mConfiguration = new Configuration(); private final Configuration mConfiguration = new Configuration();
/*package*/ final DisplayMetrics mMetrics = new DisplayMetrics(); /*package*/ final DisplayMetrics mMetrics = new DisplayMetrics();
private NativePluralRules mPluralRule; private PluralRules mPluralRule;
private CompatibilityInfo mCompatibilityInfo = CompatibilityInfo.DEFAULT_COMPATIBILITY_INFO; private CompatibilityInfo mCompatibilityInfo = CompatibilityInfo.DEFAULT_COMPATIBILITY_INFO;
private WeakReference<IBinder> mToken; private WeakReference<IBinder> mToken;
@@ -274,9 +274,9 @@ public class Resources {
* possibly styled text information. * possibly styled text information.
*/ */
public CharSequence getQuantityText(int id, int quantity) throws NotFoundException { public CharSequence getQuantityText(int id, int quantity) throws NotFoundException {
NativePluralRules rule = getPluralRule(); PluralRules rule = getPluralRule();
CharSequence res = mAssets.getResourceBagText(id, CharSequence res = mAssets.getResourceBagText(id,
attrForQuantityCode(rule.quantityForInt(quantity))); attrForQuantityCode(rule.select(quantity)));
if (res != null) { if (res != null) {
return res; return res;
} }
@@ -286,36 +286,36 @@ public class Resources {
} }
throw new NotFoundException("Plural resource ID #0x" + Integer.toHexString(id) throw new NotFoundException("Plural resource ID #0x" + Integer.toHexString(id)
+ " quantity=" + quantity + " quantity=" + quantity
+ " item=" + stringForQuantityCode(rule.quantityForInt(quantity))); + " item=" + rule.select(quantity));
} }
private NativePluralRules getPluralRule() { private PluralRules getPluralRule() {
synchronized (sSync) { synchronized (sSync) {
if (mPluralRule == null) { if (mPluralRule == null) {
mPluralRule = NativePluralRules.forLocale(mConfiguration.locale); mPluralRule = PluralRules.forLocale(mConfiguration.locale);
} }
return mPluralRule; return mPluralRule;
} }
} }
private static int attrForQuantityCode(int quantityCode) { private static int attrForQuantityCode(String quantityCode) {
switch (quantityCode) { switch (quantityCode) {
case NativePluralRules.ZERO: return 0x01000005; case PluralRules.KEYWORD_ZERO: return 0x01000005;
case NativePluralRules.ONE: return 0x01000006; case PluralRules.KEYWORD_ONE: return 0x01000006;
case NativePluralRules.TWO: return 0x01000007; case PluralRules.KEYWORD_TWO: return 0x01000007;
case NativePluralRules.FEW: return 0x01000008; case PluralRules.KEYWORD_FEW: return 0x01000008;
case NativePluralRules.MANY: return 0x01000009; case PluralRules.KEYWORD_MANY: return 0x01000009;
default: return ID_OTHER; default: return ID_OTHER;
} }
} }
private static String stringForQuantityCode(int quantityCode) { private static String stringForQuantityCode(String quantityCode) {
switch (quantityCode) { switch (quantityCode) {
case NativePluralRules.ZERO: return "zero"; case PluralRules.KEYWORD_ZERO: return "zero";
case NativePluralRules.ONE: return "one"; case PluralRules.KEYWORD_ONE: return "one";
case NativePluralRules.TWO: return "two"; case PluralRules.KEYWORD_TWO: return "two";
case NativePluralRules.FEW: return "few"; case PluralRules.KEYWORD_FEW: return "few";
case NativePluralRules.MANY: return "many"; case PluralRules.KEYWORD_MANY: return "many";
default: return "other"; default: return "other";
} }
} }
@@ -1623,7 +1623,7 @@ public class Resources {
} }
synchronized (sSync) { synchronized (sSync) {
if (mPluralRule != null) { if (mPluralRule != null) {
mPluralRule = NativePluralRules.forLocale(config.locale); mPluralRule = PluralRules.forLocale(config.locale);
} }
} }
} }

View File

@@ -249,7 +249,7 @@ hax_jar = jar('hax', [
declare_dependency(link_with: hax_arsc_parser_jar) declare_dependency(link_with: hax_arsc_parser_jar)
], ],
java_args: [ java_args: [
'-bootclasspath', join_paths(dir_base, 'jars/core-libart-hostdex_classes.jar'), '-bootclasspath', bootclasspath,
'-source', '1.7', '-target', '1.7', '-source', '1.7', '-target', '1.7',
'-h', join_paths(dir_base, 'src/api-impl-jni/generated_headers') '-h', join_paths(dir_base, 'src/api-impl-jni/generated_headers')
]) ])

View File

@@ -20,7 +20,7 @@ hax_arsc_parser_jar = jar('hax_arsc_parser', [
'com/hq/arscresourcesparser/stream/PositionInputStream.java' 'com/hq/arscresourcesparser/stream/PositionInputStream.java'
], ],
java_args: [ java_args: [
'-bootclasspath', join_paths(dir_base, 'jars/core-libart-hostdex_classes.jar'), '-bootclasspath', bootclasspath,
'-source', '1.7', '-target', '1.7' '-source', '1.7', '-target', '1.7'
]) ])

View File

@@ -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 // some apps need the apk path since they directly read their apk
jclass context_class = (*env)->FindClass(env, "android/content/Context"); 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__WIDTH = d->window_width;
FIXME__HEIGHT = d->window_height; FIXME__HEIGHT = d->window_height;