#-*- coding:utf-8-*-
__author__ = 'Andy'
from CheckProtect.AnalysisXML.AXML import AXML
class Xml():
    def start(self, a_file):
        axml_analysis = AXML(a_file)
        if axml_analysis.get_filename_abs() == 'AndroidManifest':
            ######################################################## 基本信息 ###############################################
            #getLog(log, separator("基本信息:"), '')
            print "文件路径: ", axml_analysis.get_filename()
            print "文件大小: ", axml_analysis.get_size() + " 字节"
            print "文件包名: ", axml_analysis.get_package()
            print "版本: ", axml_analysis.get_androidversion_name()
            print "版本号: ", axml_analysis.get_androidversion_code()
            print "系统要求: ", axml_analysis.getMinSdkVersion()
            print "-" * 55, ""
            print "ManifestMd5: ", axml_analysis.get_md5()
            print "ManifestSha1: ", axml_analysis.get_sha1()
            print "ManifestSha256: ", axml_analysis.get_sha256()
            print "ManifestDigest: ", axml_analysis.get_digest()
            mainfast = axml_analysis.get_xml()
            print mainfast
            #packagename = self.getpackagename()
            packagename = "andy"
            xml_content = mainfast.split("<application")[1:]
            info_list = xml_content[0].split("<activity")[1:]
            activity = {}
            for tmp in info_list:
                activityinfo = ""
                tmp = tmp.split('android:name=')[1]
                tmp = tmp.split('" ')[0].replace('"', "")
                if tmp.startswith("."):
                    activity[packagename + tmp] = ""
                elif tmp.startswith(packagename):
                    activity[tmp] = ""
                else:
                    activity[packagename + '.' + tmp] = ""
            return activity
            print mainfast


if __name__ == "__main__":
    path = r"d:\sample_tx\9.09\-app-jiagu-apk-packed-com_andy_StudentManager_3f92f1002052a9c9929828de7dfa9a1a_unsigned\AndroidManifest.xml"
    print path
    obj = Xml()
    obj.start(path)
