implement PackageManager.resolveContentProvider()

This commit is contained in:
Julian Winkler
2024-03-20 22:20:28 +01:00
parent 7d6eae5fa5
commit e0b3975eb7
2 changed files with 21 additions and 6 deletions

View File

@@ -210,7 +210,7 @@ public class PackageItemInfo {
* assigned as the given meta-data. If the meta-data name is not defined
* or the XML resource could not be found, null is returned.
*/
public XmlResourceParser loadXmlMetaData(PackageManager pm, String name) {
public XmlResourceParser loadXmlMetaData(PackageManager pm, String name) throws Exception {
if (metaData != null) {
int resid = metaData.getInt(name);
if (resid != 0) {

View File

@@ -38,6 +38,7 @@ import java.util.ArrayList;
import java.util.List;
import com.reandroid.arsc.chunk.xml.AndroidManifestBlock;
import com.reandroid.arsc.chunk.xml.ResXmlAttribute;
import com.reandroid.arsc.chunk.xml.ResXmlElement;
class IPackageInstallObserver {}
@@ -2421,9 +2422,23 @@ public class PackageManager {
* @return ContentProviderInfo Information about the provider, if found,
* else null.
*/
public ProviderInfo resolveContentProvider(String name,
int flags) {
return null;
public ProviderInfo resolveContentProvider(String authority, int flags) {
ProviderInfo providerInfo = new ProviderInfo();
List<ResXmlElement> providers = Context.manifest.getApplicationElement().listElements(AndroidManifestBlock.TAG_provider);
for (ResXmlElement providerElement : providers) {
String providerAuthority = providerElement.searchAttributeByResourceId(AndroidManifestBlock.ID_authorities).getValueAsString();
if (providerAuthority.startsWith("."))
providerAuthority = Context.manifest.getPackageName() + providerAuthority;
if (!providerAuthority.equals(authority))
continue;
for (ResXmlElement metaData : providerElement.listElements(AndroidManifestBlock.TAG_meta_data)) {
ResXmlAttribute metaName = metaData.searchAttributeByResourceId(AndroidManifestBlock.ID_name);
ResXmlAttribute metaRes = metaData.searchAttributeByResourceId(AndroidManifestBlock.ID_resource);
providerInfo.metaData.putInt(metaName.getValueAsString(), metaRes.getData());
}
break;
}
return providerInfo;
}
/**
@@ -2709,8 +2724,8 @@ public class PackageManager {
* data. Returns null if the xml resource could not be found for any
* reason.
*/
public XmlResourceParser getXml(String packageName, int resid, ApplicationInfo appInfo) {
return null;
public XmlResourceParser getXml(String packageName, int resid, ApplicationInfo appInfo) throws Exception {
return Context.this_application.getResources().getXml(resid);
}
/**