Wednesday, 18 September 2013

how to grabb version name,version code, package name and minsdk level of an apk using php

how to grabb version name,version code, package name and minsdk level of
an apk using php

i need a class or maybe a function for get version name,version code,
package name and minsdk level from and apk file...
i found apk parser php class but in server it do not work good....
i found this function too but this function has error too...
function apps_infosfromapk($file)
{
global $AAPT_DIR;
$infos=array();
$retour = array();
exec ($AAPT_DIR." l -a ".realpath($file),$retour);
$txt = "";
for($i = 0; $i < sizeof ($retour); $i++)
$txt .= $retour[$i];
$t1 = explode('android:versionName(0x0101021c)="',$txt);
$t3 = explode('"',$t1[1]);
$version = $t3[0];
$t2 = explode ('package="', $txt);
$t4 = explode ('"', $t2[1]);
$package = $t4[0];
$t5 = explode('A: android:minSdkVersion(0x0101020c)=(type 0x10)0x',$txt);
$t6 = explode(' ',$t5[1]);
$minSdk = intval($t6[0]);
$txt2=explode('android:name(0x01010003)="android.permission.',$txt);
$it=0;
$permissions="";
for($i=1;$i<sizeof($txt2);$i++)
{
$tmp=explode('"',$txt2[$i]);
if($it==0)
$permissions.=$tmp[0];
else
$permissions.=";".$tmp[0];
$it++;
}
$infos[0]=$version;
$infos[1]=$package;
$infos[2]=$minSdk;
$infos[3]=$permissions;
return $infos;
}

No comments:

Post a Comment