api-impl/android/content/pm/PackageInfo: make some items not stubs

This commit is contained in:
Mis012
2023-08-12 13:06:10 +02:00
parent c936333c74
commit a1aa38c7b8

View File

@@ -16,11 +16,17 @@
package android.content.pm; package android.content.pm;
import com.reandroid.arsc.chunk.xml.AndroidManifestBlock;
import java.io.InputStream;
import java.io.IOException;
/** /**
* Overall information about the contents of a package. This corresponds * Overall information about the contents of a package. This corresponds
* to all of the information collected from AndroidManifest.xml. * to all of the information collected from AndroidManifest.xml.
*/ */
public class PackageInfo { public class PackageInfo {
private static AndroidManifestBlock manifest = null; // TODO: only ever load this once, in one place
/** /**
* The name of this package. From the <manifest> tag's "name" * The name of this package. From the <manifest> tag's "name"
* attribute. * attribute.
@@ -230,7 +236,20 @@ public class PackageInfo {
*/ */
public String requiredAccountType; public String requiredAccountType;
static {
InputStream inStream = ClassLoader.getSystemClassLoader().getResourceAsStream("AndroidManifest.xml");
try {
manifest = AndroidManifestBlock.load(inStream);
} catch (IOException e) {
e.printStackTrace();
}
}
public PackageInfo() { public PackageInfo() {
packageName = manifest.getPackageName();
versionCode = manifest.getVersionCode();
versionName = manifest.getVersionName();
System.out.println("PackageInfo(): packageName: >"+packageName+"<, versionCode: >"+versionCode+"<, versionName: >"+versionName+"<");
} }
public String toString() { public String toString() {