tufanbarisyildirim / php-apk-parser

Read basic info about an application from .apk file.
http://tufanbarisyildirim.github.io/php-apk-parser/
Other
342 stars 119 forks source link

Extracting XML with the strings decoded #105

Open videostormdev opened 2 years ago

videostormdev commented 2 years ago

I am trying to extract the APP_RESTRICTIONS from an APK

These are listed in the manifest as meta-data, pointing to an XML file (typically res/xml/app_restrictions.xml)

The following code is how I get the XML file using php-apk-parser (awesome tool btw) However, the XML file still has the resource IDs instead of the corresponding strings for most fields (name, description, etc)

$metaconf = $manifest->getMetaData('android.content.APP_RESTRICTIONS');
if (($metaconf != null)&&(strlen($metaconf)>1)){
    // metaconf is the resource id for the xml file
    $managedconfig = 1;
    if ($getresource){
        $mcarr = $apk->getResources($metaconf);
        //error_log("Supports managedconfig, values = " . count($mcarr));
        $managedconfigxmlfile = $mcarr[0];
        //$managedconfigxml = stream_get_contents($apk->getStream($managedconfigxmlfile));

        // below works, but extracted xml has resource ids in it (not decoded)
        $mcstr = new \ApkParser\Stream($apk->getStream($managedconfigxmlfile));
        $mcxml = new \ApkParser\XmlParser($mcstr);
        $managedconfigxml = $mcxml->getXmlString();
         }
}

Is there a straightforward way to get the XML text with all resource strings decoded?

tufanbarisyildirim commented 1 year ago

hi @videostormdev can I have an example APK somehow?

videostormdev commented 1 year ago

Yes, please see https://www.lumi-tv.com/help/splashtiles_v2p3p0.apk

The description field in the app_restrictions.xml will always contain the resource id, not the decoded version. Of course this is to allow for localization of the strings, but it would be handy to have an easy way to set your localization and get the corresponded decoded string directly.