remove custom AndroidManifest.xml parsing and instead use PackageParser

This has the advantage, that AndroidManifest.xml is only parsed once.
This commit is contained in:
Julian Winkler
2024-06-10 23:24:29 +02:00
parent f249e1c487
commit b15bf203a7
8 changed files with 126 additions and 232 deletions

View File

@@ -2,23 +2,18 @@ package android.app;
import android.os.Bundle;
import android.content.res.Configuration;
import android.content.res.TypedArray;
import android.content.res.XmlResourceParser;
import android.R;
import android.content.Context;
import android.content.ContextWrapper;
public class Application extends ContextWrapper {
private String app_icon_path = null;
private String app_label = null;
public long native_window;
private String get_app_icon_path() {
return app_icon_path;
return getString(pkg.applicationInfo.icon);
}
private String get_app_label() {
return app_label;
return getString(pkg.applicationInfo.labelRes);
}
public interface ActivityLifecycleCallbacks {
@@ -47,19 +42,6 @@ public class Application extends ContextWrapper {
public Application() {
super(new Context());
/* TODO: is this the right place to put this? */
try (XmlResourceParser parser = getAssets().openXmlResourceParser("AndroidManifest.xml")) {
for (; parser.getEventType() != XmlResourceParser.END_DOCUMENT; parser.next()) {
if (parser.getEventType() == XmlResourceParser.START_TAG && "application".equals(parser.getName())) {
TypedArray a = getResources().obtainAttributes(parser, R.styleable.AndroidManifestApplication);
app_icon_path = a.getString(R.styleable.AndroidManifestApplication_icon);
app_label = a.getString(R.styleable.AndroidManifestApplication_label);
a.recycle();
}
}
} catch (Exception e) {
e.printStackTrace();
}
}
/**
* Called when the application is starting, before any activity, service,