123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891892893894895896897898899900901902903904905906907908909910911912913914915916917918919920921922923924925926927928929930931932933934935936937938939940941942943944945946947948949950951952953954955956957958959960961962963964965966967968969970971972973974975976977978979980981982983984985986987988989990991992993994995996997998999100010011002100310041005100610071008100910101011101210131014101510161017101810191020102110221023102410251026102710281029103010311032103310341035103610371038103910401041104210431044104510461047104810491050105110521053105410551056105710581059106010611062106310641065106610671068106910701071107210731074107510761077107810791080108110821083108410851086108710881089109010911092109310941095109610971098109911001101110211031104110511061107110811091110111111121113111411151116111711181119112011211122112311241125112611271128112911301131113211331134113511361137113811391140114111421143114411451146114711481149115011511152115311541155115611571158115911601161116211631164116511661167116811691170117111721173117411751176117711781179118011811182118311841185118611871188118911901191119211931194119511961197119811991200120112021203120412051206120712081209121012111212121312141215121612171218121912201221122212231224122512261227122812291230123112321233123412351236123712381239124012411242124312441245124612471248124912501251125212531254125512561257125812591260126112621263126412651266126712681269127012711272127312741275127612771278127912801281128212831284128512861287128812891290129112921293129412951296129712981299130013011302130313041305130613071308130913101311131213131314131513161317131813191320132113221323132413251326132713281329133013311332133313341335133613371338133913401341134213431344134513461347134813491350135113521353135413551356135713581359136013611362136313641365136613671368136913701371137213731374137513761377137813791380138113821383138413851386138713881389139013911392139313941395139613971398139914001401140214031404140514061407140814091410141114121413141414151416141714181419142014211422142314241425142614271428142914301431143214331434143514361437143814391440144114421443144414451446144714481449145014511452145314541455145614571458145914601461146214631464146514661467146814691470147114721473147414751476147714781479148014811482148314841485148614871488148914901491149214931494149514961497149814991500150115021503150415051506150715081509151015111512151315141515151615171518 |
- # -*-coding:utf-8-*-
- import os
- import xml.etree.ElementTree as ET
- import re
- import hashlib
- import shutil
- import json
- from V1.PrintLog import printlog
- from V1 import Contants, File, GeneralModifySmali, Replace, Aapt_Util, apk_utils
- from xml.etree.ElementTree import Element
- # 联想
- def LenovoReplace(prj_path, dir_split, key, value):
- if (key == "OPENAPPID"):
- # 替换联想id
- replaceLeonovoIdShell = 'sed -i "1,\\$s/lenovo_id/%s/g" %s/AndroidManifest.xml ' % (value, prj_path)
- printlog("replaceLeonovoIdShell: %s" % replaceLeonovoIdShell)
- os.system(replaceLeonovoIdShell)
- manifestRootExt = r'<application android:networkSecurityConfig="@xml/network_security_config"'
- replacePkgNameShell = "sed -i 's!<application!%s!g' %s/AndroidManifest.xml" % (manifestRootExt, prj_path)
- printlog("LenovoReplace replace add application root point shell: %s" % replacePkgNameShell)
- os.system(replacePkgNameShell)
- pass
- # 豌豆荚
- def WandoujiaReplace(prj_path, dir_split, key, value):
- printlog("specail replace : wdj")
- if (key == "APPKEY_ID"):
- prj_am_path = prj_path + dir_split + "AndroidManifest.xml"
- printlog("prj_am_path :%s" % prj_am_path)
- lines = open(prj_am_path).readlines()
- fp = open(prj_am_path, 'w')
- for s in lines:
- if (s.find("Wandoujia-PaySdk-") != -1):
- printlog("replace Wandoujia-PaySdk-%s" % value)
- s = re.sub('Wandoujia-PaySdk-.*\"', 'Wandoujia-PaySdk-' + value + '\"', s)
- fp.write(s)
- fp.close()
- pass
- # 虫虫
- def ChongchongReplace(prj_path, dir_split, key, value):
- printlog("specail replace : Chongchong")
- if (key == "app_id"):
- prj_am_path = prj_path + dir_split + "AndroidManifest.xml"
- printlog("prj_am_path :%s" % prj_am_path)
- lines = open(prj_am_path).readlines()
- fp = open(prj_am_path, 'w')
- for s in lines:
- if (s.find("qqPay") != -1):
- printlog("replace qqPay:%s" % value)
- s = re.sub('qqPay.*\"', 'qqPay' + value + '\"', s);
- fp.write(s)
- fp.close()
- # 360
- def QihuReplace(prj_path, dir_split, key, value):
- global appkey
- printlog("specail replace : 360")
- if (key == "QHOPENSDK_APPKEY"):
- replacePkgNameShell = 'sed -i "s/qihu_appkey/%s/g" %s/AndroidManifest.xml' % (value, prj_path)
- printlog("QihuReplace replace qihu_appkey shell: %s" % replacePkgNameShell)
- os.system(replacePkgNameShell)
- if (key == "QHOPENSDK_APPSECRET"):
- prj_param = "%s/assets/YyrhParam.cnf" % prj_path
- prj_am_path = "%s/AndroidManifest.xml" % prj_path
- appsecret = value
- metadatas = ET.parse(prj_am_path).getroot().find("application").findall("meta-data")
- for meta in metadatas:
- if (meta.attrib["{http://schemas.android.com/apk/res/android}name"] == "QHOPENSDK_APPKEY"):
- appkey = meta.attrib["{http://schemas.android.com/apk/res/android}value"]
- printlog("prj_am_path:%s" % prj_am_path)
- m = hashlib.md5()
- printlog("appsecret :%s" % appsecret)
- printlog("appkey: %s" % appkey)
- md5value = "%s#%s" % (appsecret, appkey)
- printlog("md5value :%s" % md5value)
- m.update(md5value.encode('utf-8'))
- privatekey = m.hexdigest()
- printlog("privatekey:%s" % privatekey)
- Replace.replaceAM_Meta_data(prj_am_path, 'QHOPENSDK_PRIVATEKEY', privatekey)
- manifestRootExt = r'<application android:networkSecurityConfig="@xml/network_security_config"'
- replacePkgNameShell = "sed -i 's!<application!%s!g' %s/AndroidManifest.xml" % (manifestRootExt, prj_path)
- printlog("qihu360 replace add application root point shell: %s" % replacePkgNameShell)
- os.system(replacePkgNameShell)
- pass
- def OppoReplace(prj_path, dir_split, key, value):
- printlog("specail replace : oppo")
- if (key == "APPKEY"):
- prj_am_path = prj_path + dir_split + "AndroidManifest.xml"
- printlog("prj_am_path: %s" % prj_am_path)
- # 替换app_key
- Replace.replaceAM_Meta_data(prj_am_path, 'app_key', value)
- printlog("appkey: %s" % value)
- pass
- def OppoMlReplace(prj_path, dir_split, key, value):
- printlog("specail replace : oppoml")
- if (key == "APPKEY"):
- prj_am_path = prj_path + dir_split + "AndroidManifest.xml"
- printlog("prj_am_path: %s" % prj_am_path)
- # 替换app_key
- Replace.replaceAM_Meta_data(prj_am_path, 'app_key', value)
- printlog("appkey: %s" % value)
- pass
- def downjoyReplace(prj_path, dir_split, key, value):
- printlog("specail replace : downjoy")
- if (key == "APP_ID"):
- splash_activity = "com.downjoy.activity.SdkLoadActivity"
- prj_am_path = "%s/AndroidManifest.xml" % prj_path
- game_activity = Replace.replaceGameActivityLaunchAttribute(splash_activity, prj_am_path)
- printlog(game_activity)
- Replace.replaceAM_Meta_data(prj_am_path, 'CP_ACTIVITY', game_activity)
- lines = open(prj_am_path).readlines()
- fp = open(prj_am_path, 'w')
- for s in lines:
- if (s.find("dcnngsdk") != -1):
- printlog("replace dcnngsdk:%s" % value)
- s = re.sub('dcnngsdk.*\"', 'dcnngsdk' + value + '\"', s)
- fp.write(s)
- fp.close()
- pass
- def YYBReplace(prj_path, dir_split, key, value):
- if (key == "QQ_APP_ID"):
- # 替换qq app id
- replaceQQAPPIDShell = 'sed -i "s/qq_app_id/%s/g" %s/AndroidManifest.xml' % (value, prj_path)
- printlog("yingyongbao qq app id shell: %s" % replaceQQAPPIDShell)
- os.system(replaceQQAPPIDShell)
- # 替换ysdkconf.ini
- printlog("path ysdkconfig.ini:%s/assets/ysdkconf.ini" % prj_path)
- Replace.replaceAssets_Param("%s/assets/ysdkconf.ini" % prj_path, key, value)
- Replace.replaceAssets_Param("%s/assets/ysdkconf.ini" % prj_path, "OFFER_ID", value)
- prj_am_path = "%s/AndroidManifest.xml" % prj_path
- game_activity = Replace.getLauchActivityName(prj_path)
- Replace.replaceAM_Meta_data(prj_am_path, 'MAIN_ACTIVITY', game_activity)
- if (key == "WX_APP_ID"):
- replaceWXAPPIDShell = 'sed -i "s/wx_app_id/%s/g" %s/AndroidManifest.xml' % (value, prj_path)
- printlog("yingyongbao wx app id shell: %s" % replaceWXAPPIDShell)
- os.system(replaceWXAPPIDShell)
- # 替换ysdkconf.ini
- Replace.replaceAssets_Param("%s/assets/ysdkconf.ini" % prj_path, key, value)
- if (key == "IS_SAND_BOX"):
- ysdk_sand_url = "https://ysdktest.qq.com"
- ysdk_online_url = "https://ysdk.qq.com"
- if value == "1":
- ysdk_url = ysdk_sand_url
- else:
- ysdk_url = ysdk_online_url
- Replace.replaceAssets_Param("%s/assets/ysdkconf.ini" % prj_path, "YSDK_URL", ysdk_url)
- pass
- def HuaweiReplace(prj_path, dir_split, key, value):
- if (key == "APP_ID"):
- replaceAppidShell = '/bin/sed -i "s/APP_ID/%s/g" %s/AndroidManifest.xml' % (value, prj_path)
- printlog("huawei replace appid shell: %s" % replaceAppidShell)
- os.system(replaceAppidShell)
- GeneralModifySmali.modifyRfileIdSmali(prj_path, "/smali/com/huawei/android/hms/app")
- GeneralModifySmali.modifyRfileIdSmali(prj_path, "/smali/com/huawei/android/hms/game")
- GeneralModifySmali.modifyRfileIdSmali(prj_path, "/smali/com/huawei/hms/base/hmscoreinstaller")
- if (key == "PAY_ID"):
- replacePayidShell = '/bin/sed -i "s/PAY_ID/%s/g" %s/AndroidManifest.xml' % (value, prj_path)
- printlog("huawei replace payid shell: %s" % replacePayidShell)
- os.system(replacePayidShell)
- pass
- def AnzhiReplace(prj_path, dir_split, key, value):
- printlog("specail replace : anzhi")
- prj_am_path = "%s/AndroidManifest.xml" % prj_path
- pkgName = ET.parse(prj_am_path).getroot().attrib["package"]
- if (key == "APP_KEY"):
- lines = open(prj_am_path).readlines()
- fp = open(prj_am_path, 'w')
- for s in lines:
- if (s.find("packagename") != -1):
- s = re.sub('packagename', pkgName, s);
- fp.write(s)
- fp.close()
- pass
- def GuopanReplace(prj_path, dir_split, key, value):
- printlog("specail replace : guopan")
- prj_am_path = "%s/AndroidManifest.xml" % prj_path
- pkgName = ET.parse(prj_am_path).getroot().attrib["package"]
- if (key == "APP_ID"):
- lines = open(prj_am_path).readlines()
- fp = open(prj_am_path, 'w')
- for s in lines:
- if (s.find("gp_packagename") != -1):
- s = re.sub('gp_packagename', pkgName + ".StubContentProvider", s);
- fp.write(s)
- fp.close()
- pass
- def LeshiReplace(prj_path, dir_split, key, value):
- printlog("specail replace : leshi")
- prj_am_path = prj_path + dir_split + "AndroidManifest.xml"
- if (key == "LEPAY_APPID"):
- Replace.replaceAM_Meta_data(prj_am_path, 'lepay_appid', value)
- if (key == "LEPAY_APPKEY"):
- Replace.replaceAM_Meta_data(prj_am_path, 'lepay_appkey', value)
- pass
- def QuickReplace(prj_path, dir_split, key, value):
- printlog("specail replace : Quick")
- if (key == "PRODUCT_CODE"):
- splashactivity = "com.yythird.sdk.SplashActivity"
- prj_am_path = prj_path + dir_split + "AndroidManifest.xml"
- prj_param = "%s/assets/YyrhParam.cnf" % prj_path
- game_activity = Replace.replaceGameActivityLaunchAttribute(splashactivity, prj_am_path)
- printlog("GAMEACTIVITY :%s" % game_activity)
- Replace.replaceAssets_Param(prj_param, "GAMEACTIVITY", game_activity)
- if (key == "SDK_TYPE"):
- printlog("merge qitian Smali")
- if value == "qitian":
- printlog("merge qitian Smali")
- sdk_root_dir = apk_utils.getCutSdkRootHome()
- ret = 0
- ret = ret | File.mergeDir("%s/quick/quick/qitian_smali" % sdk_root_dir, "%s/smali" % prj_path)
- pass
- def LjsdkReplace(prj_path, dir_split, key, value):
- printlog("specail replace : LjsdkReplace")
- if (key == "XMGAME_PRODUCT_CODE"):
- prj_param = "%s/assets/param.cnf" % prj_path
- prj_am_path = prj_path + dir_split + "AndroidManifest.xml"
- splashactivity = "third.sdk.SplashActivity"
- game_activity = Replace.replaceGameActivityLaunchAttribute(splashactivity, prj_am_path)
- printlog("GAMEACTIVITY :%s" % game_activity)
- Replace.replaceAssets_Param(prj_param, "GAMEACTIVITY", game_activity)
- pkgName = ET.parse(prj_am_path).getroot().attrib["package"]
- pkgLine = 'package="' + pkgName + '"'
- printlog("pkgValue :%s" % pkgLine)
- addPkgLine = ' xmlns:tools="http://schemas.android.com/tools" '
- addPerLine = ' tools:ignore="ProtectedPermissions" '
- permissionName = 'android:name="android.permission.PACKAGE_USAGE_STATS"'
- lines = open(prj_am_path).readlines()
- fp = open(prj_am_path, 'w')
- for s in lines:
- if (s.find(pkgLine) != -1):
- s = re.sub(pkgLine, pkgLine + addPkgLine, s);
- printlog("pkgLine :%s" % s)
- if (s.find(permissionName) != -1):
- s = re.sub(permissionName, permissionName + addPerLine, s);
- printlog("permissionName :%s" % s)
- fp.write(s)
- fp.close()
- pass
- def UcsdkReplace(prj_path, dir_split, key, value):
- printlog("specail replace : UcsdkReplace")
- if (key == "GAME_ID"):
- replaceGidShell = 'sed -i "s/GAME_ID/%s/g" %s/AndroidManifest.xml' % (value, prj_path)
- printlog("uc replace GAME_ID shell: %s" % replaceGidShell)
- os.system(replaceGidShell)
- # GeneralModifySmali.modifyLauchSmali(prj_path)
- pass
- def XiaomisdkReplace(prj_path, dir_split, key, value):
- printlog("specail replace : XiaomisdkReplace")
- if (key == "APP_ID"):
- # 获取包名
- sdk_root_dir = apk_utils.getCutSdkRootHome()
- Replace.modifyRfileSmaliPath("xiaomi", prj_path);
- printlog(" xiaomi begin replace game package v4 smali -------------------------------")
- pkgV4Path = "%s/smali/android/support/v4" % prj_path
- printlog("pkgV4Path:%s" % pkgV4Path)
- sdkV4Path = "%s/xiaomi/xiaomi/smali/android/support/v4" % sdk_root_dir
- printlog("sdkV4Path:%s" % sdkV4Path)
- if os.path.exists(pkgV4Path):
- File.copyAllFile(sdkV4Path, pkgV4Path)
- pkgAnnotation = "%s/smali/android/support/annotation" % prj_path
- printlog("pkgV4Path:%s" % pkgAnnotation)
- sdkAnnotation = "%s/xiaomi/xiaomi/smali/android/support/annotation" % sdk_root_dir
- if os.path.exists(pkgAnnotation):
- File.copyAllFile(sdkAnnotation, pkgAnnotation)
- pass
- # 百度
- def BaiduReplace(prj_path, dir_split, key, value):
- printlog("specail replace : baidu")
- if (key == "APP_ID"):
- GeneralModifySmali.modifyLauchSmali(prj_path)
- pass
- # 圣本
- def ShengbensdkReplace(prj_path, dir_split, key, value):
- printlog("specail replace : ShengbensdkReplace")
- if (key == "AGENT"):
- jsonFilePath = prj_path + dir_split + "assets" + dir_split + "hnsb_config.json"
- printlog("path hnsb_config.json :%s" % jsonFilePath)
- with open(jsonFilePath, 'r') as fp:
- jsonData = json.load(fp)
- jsonData['sdk']["ver"] = value
- newJsonData = jsonData
- fp.close()
- with open(jsonFilePath, 'w') as fp:
- json.dump(newJsonData, fp)
- fp.close()
- if (key == "APP_ID"):
- jsonFilePath = prj_path + dir_split + "assets" + dir_split + "hnsb_config.json"
- with open(jsonFilePath, 'r') as fp:
- jsonData = json.load(fp)
- jsonData['sdk']["appid"] = value
- newJsonData = jsonData
- fp.close()
- with open(jsonFilePath, 'w') as fp:
- json.dump(newJsonData, fp)
- fp.close()
- pass
- def JinkuosdkReplace(prj_path, dir_split, key, value):
- printlog("specail replace : JinkuosdkReplace")
- printlog("path yy.properties :%s/assets/u8_developer_config.properties" % prj_path)
- Replace.replaceAssets_Param("%s/assets/u8_developer_config.properties" % prj_path, key, value)
- pass
- def HdhdsdkReplace(prj_path, dir_split, key, value):
- printlog("specail replace : HdhdsdkReplace")
- if (key == "APP_ID"):
- GeneralModifySmali.modifyLauchSmali(prj_path)
- pass
- def SamsungReplace(prj_path, dir_split, key, value):
- printlog("specail replace : SamsungReplace")
- if (key == "APPV_KEY"):
- ptKey = value[0:99]
- pvData = value[99:len(value)]
- prj_am_path = prj_path + dir_split + "AndroidManifest.xml"
- printlog("prj_am_path: %s" % prj_am_path)
- # 替换app_key
- Replace.replaceAM_Meta_data(prj_am_path, 'ptKey', ptKey)
- prj_param = "%s/assets/YyrhParam.cnf" % prj_path
- Replace.replaceAssets_Param(prj_param, "pvData", pvData)
- pass
- def TTReplace(prj_path, dir_split, key, value):
- printlog("specail replace : TTReplace")
- if (key == "GAME_ID"):
- Replace.replaceAssets_Param("%s/assets/tt_game_sdk_opt.properties" % prj_path, "gameId", value)
- if (key == "GAME_KEY"):
- replaceKeyShell = 'sed -i "s/@WSX3edc/%s/g" %s/assets/TTGameSDKConfig.cfg' % (value, prj_path)
- printlog("replaceMainLineShell:%s" % replaceKeyShell)
- os.system(replaceKeyShell)
- pass
- def YXFReplace(prj_path, dir_split, key, value):
- printlog("specail replace : YXFReplace")
- if (key == "YGAPPID"):
- replacePkgNameShell = '/bin/sed -i "1,\\$s/YXFAPPID/%s/g" %s/AndroidManifest.xml' % (value, prj_path)
- printlog("replacePkgNameShell:%s" % replacePkgNameShell)
- os.system(replacePkgNameShell)
- manifestRootExt = r'<application android:usesCleartextTraffic="true"'
- replacePkgNameShell = "sed -i 's!<application!%s!g' %s/AndroidManifest.xml" % (manifestRootExt, prj_path)
- printlog("youxiFan replace add application root point shell: %s" % replacePkgNameShell)
- os.system(replacePkgNameShell)
- if (key == "IS_SPLASH"):
- if (value == "0"):
- GeneralModifySmali.modifyYXFLauchSmali(prj_path)
- if (key == "screenOrientation"):
- sdk_root_dir = apk_utils.getCutSdkRootHome()
- if (value == "screenOrientation:0"):
- splash = "%s/yxf/yxf/extension/sp_landscape.png" % sdk_root_dir
- apkres = "%s/res/drawable/crash_screen.png" % prj_path
- shutil.copy(splash, apkres)
- if (value == "screenOrientation:1"):
- splash = "%s/yxf/yxf/extension/sp_portrait.png" % sdk_root_dir
- apkres = "%s/res/drawable/crash_screen.png" % prj_path
- shutil.copy(splash, apkres)
- pass
- def VivosdkReplace(prj_path, dir_split, key, value):
- printlog("specail replace : VivosdkReplace")
- if (key == "APP_ID"):
- printlog("path supplierconfig.json :%s/assets/supplierconfig.json" % prj_path)
- replaceConfigShell = '/bin/sed -i "1,\\$s/APP_ID/%s/g" %s/assets/supplierconfig.json' % (value, prj_path)
- printlog("replaceConfigShell APP_ID:%s" % replaceConfigShell)
- os.system(replaceConfigShell)
- jsonFilePath = prj_path + dir_split + "assets" + dir_split + "supplierconfig.json"
- printlog("path supplierconfig.json :%s" % jsonFilePath)
- with open(jsonFilePath, 'r') as fp:
- jsonData = json.load(fp)
- jsonData['supplier']["vivo"]["appid"] = value
- newJsonData = jsonData
- fp.close()
- with open(jsonFilePath, 'w') as fp:
- json.dump(newJsonData, fp)
- fp.close()
- pass
- def XTsdkReplace(prj_path, dir_split, key, value):
- printlog("specail replace : Xiantu3011sdkReplace")
- if (key == "GAME_ID"):
- # 获取包名
- Replace.modifyRfileSmaliPath("3011", prj_path);
- pass
- def DDTsdkReplace(prj_path, dir_split, key, value):
- printlog("specail replace : DDTsdkReplace")
- if (key == "APP_ID"):
- prj_am_path = prj_path + dir_split + "AndroidManifest.xml"
- splashactivity = "com.ddtsdk.ui.activity.MHPerActivity"
- game_activity = Replace.replaceGameActivityLaunchAttribute(splashactivity, prj_am_path)
- printlog("GAMEACTIVITY :%s" % game_activity)
- Replace.replaceAM_Meta_data(prj_am_path, "mainAct", game_activity)
- if (key == "agent"):
- Replace.replaceAssets_Param("%s/assets/ddt.properties" % prj_path, key, value)
- pass
- def QiyuReplace(prj_path, dir_split, key, value):
- if (key == "APP_ID"):
- manifestRootExt = r'<application android:usesCleartextTraffic="true"'
- replacePkgNameShell = "sed -i 's!<application!%s!g' %s/AndroidManifest.xml" % (manifestRootExt, prj_path)
- printlog("QiyuReplace add application root point shell: %s" % replacePkgNameShell)
- os.system(replacePkgNameShell)
- pass
- def WankaReplace(prj_path, dir_split, key, value):
- if (key == "APPID"):
- prj_am_path = prj_path + dir_split + "AndroidManifest.xml"
- namespace = '{http://schemas.android.com/apk/res/android}'
- manifestRootExt = r'<application xmlns:tools="http://schemas.android.com/tools" tools:replace="android:theme,android:name"'
- replacePkgNameShell = "sed -i 's!<application!%s!g' %s/AndroidManifest.xml" % (manifestRootExt, prj_path)
- printlog("WankaReplace replace add application root point shell: %s" % replacePkgNameShell)
- os.system(replacePkgNameShell)
- tree = ET.parse(prj_am_path)
- activitys = tree.getroot().find("application").findall("activity")
- for activity in activitys:
- filters = activity.findall('intent-filter')
- for filter in filters:
- categorys = filter.findall('category')
- for category in categorys:
- categoryname = category.attrib[namespace + "name"]
- if (categoryname == "android.intent.category.LAUNCHER"):
- element = Element('intent-filter')
- el1 = Element('action android:name="android.intent.action.VIEW"')
- el2 = Element('category android:name="android.intent.category.DEFAULT"')
- el3 = Element('category android:name="android.intent.category.BROWSABLE"')
- el4_value = 'data android:scheme="app%s"' % value
- el4 = Element(el4_value)
- element.append(el1)
- element.append(el2)
- element.append(el3)
- element.append(el4)
- activity.append(element)
- activity.set(namespace + 'launchMode', "singleTask")
- tree.write(prj_am_path, "UTF-8", xml_declaration=True, method='xml')
- pkgName = ET.parse(prj_am_path).getroot().attrib["package"]
- Aapt_Util.createRFile(prj_path, False, pkgName)
- sdkRpath = "android/support/v7/appcompat"
- pkgRpath = pkgName.replace(".", "/")
- sdkAbsoluteRpath = "%s/smali/%s" % (prj_path, sdkRpath)
- pkgAbsoluteRpath = "%s/smali/%s" % (prj_path, pkgRpath)
- Replace.createRFile2Sdk(pkgAbsoluteRpath, sdkAbsoluteRpath, pkgRpath, sdkRpath)
- pass
- def DDDReplace(prj_path, dir_split, key, value):
- if (key == "channelId"):
- Replace.replaceAssets_Param("%s/assets/dingdd.properties" % prj_path, 'channelId', value)
- if (key == "adId"):
- Replace.replaceAssets_Param("%s/assets/dingdd.properties" % prj_path, 'adId', value)
- if (key == "adFlag"):
- Replace.replaceAssets_Param("%s/assets/dingdd.properties" % prj_path, 'adFlag', value)
- pass
- def LZYXReplace(prj_path, dir_split, key, value):
- if (key == "ML_Channel"):
- Replace.replaceAssets_Param("%s/assets/mlgame_developer_config.properties" % prj_path, 'ML_Channel', value)
- if (key == "ML_APPKEY"):
- Replace.replaceAssets_Param("%s/assets/mlgame_developer_config.properties" % prj_path, 'ML_APPKEY', value)
- pass
- def WSReplace(prj_path, dir_split, key, value):
- if (key == "HS_APPID"):
- manifestRootExt = r'<application android:networkSecurityConfig="@xml/huosdk_network_security_config"'
- replacePkgNameShell = "sed -i 's!<application!%s!g' %s/AndroidManifest.xml" % (manifestRootExt, prj_path)
- printlog("qihu360 replace add application root point shell: %s" % replacePkgNameShell)
- os.system(replacePkgNameShell)
- pass
- def XBReplace(prj_path, dir_split, key, value):
- if (key == "GID"):
- printlog("path gameshaiApp.ini :%s/assets/gameshaiApp.ini" % prj_path)
- Replace.replaceAssets_Param("%s/assets/gameshaiApp.ini" % prj_path, 'gid', value)
- if (key == "PID"):
- printlog("path gameshaiApp.ini :%s/assets/gameshaiApp.ini" % prj_path)
- Replace.replaceAssets_Param("%s/assets/gameshaiApp.ini" % prj_path, 'pid', value)
- pass
- def YoudianReplace(prj_path, dir_split, key, value):
- if (key == "APPID"):
- apkPkgDir = ET.parse("%s/AndroidManifest.xml" % prj_path).getroot().attrib["package"].replace(".", "/")
- apkRfilePath = "%s/smali/%s" % (prj_path, apkPkgDir)
- Replace.modifyRfileSmaliPath("youdian", prj_path);
- publicXml = "%s/res/values/public.xml" % prj_path
- sdk_jar_dir = apk_utils.getToolsJarHome()
- jarPath = "%s/MergeSamli.jar" % sdk_jar_dir
- javaMerCm = 'java -jar %s %s %s' % (jarPath, publicXml, apkRfilePath)
- printlog("javaMerCm:%s" % javaMerCm)
- os.system(javaMerCm)
- pass
- def Xiao7Replace(prj_path, dir_split, key, value):
- if (key == "APPKEY"):
- apkRfilePath = "%s/smali_classes2/com/smwl/smsdk" % prj_path
- publicXml = "%s/res/values/public.xml" % prj_path
- sdk_jar_dir = apk_utils.getToolsJarHome()
- jarPath = "%s/MergeSamli.jar" % sdk_jar_dir
- javaMerCm = 'java -jar %s %s %s' % (jarPath, publicXml, apkRfilePath)
- printlog("javaMerCm:%s" % javaMerCm)
- os.system(javaMerCm)
- printlog(" Xiao7Replace begin replace game package v4 smali -------------------------------")
- sdk_root_dir = apk_utils.getCutSdkRootHome()
- pkgV4Path = "%s/smali/android/support/v4" % prj_path
- printlog("pkgV4Path:%s" % pkgV4Path)
- sdkV4Path = "%s/x7sy/x7sy/smali/android/support/v4" % sdk_root_dir
- printlog("sdkV4Path:%s" % sdkV4Path)
- if os.path.exists(pkgV4Path):
- File.copyAllFile(sdkV4Path, pkgV4Path)
- pkgName = ET.parse("%s/AndroidManifest.xml" % prj_path).getroot().attrib["package"]
- Aapt_Util.createRFile(prj_path, False, pkgName)
- pkgName = "android.support.constraint"
- Aapt_Util.createRFile(prj_path, False, pkgName)
- prj_am_path = prj_path + dir_split + "AndroidManifest.xml"
- prj_param = "%s/assets/YyrhParam.cnf" % prj_path
- splashactivity = "com.yythird.sdk.SplashActivity"
- game_activity = Replace.replaceGameActivityLaunchAttribute(splashactivity, prj_am_path)
- Replace.replaceAssets_Param(prj_param, "GAME_ACTIVITY", game_activity)
- printlog("xiaoqi GAME_ACTIVITY :%s" % game_activity)
- pass
- def NwanKaReplace(prj_path, dir_split, key, value):
- if (key == "channelId"):
- Replace.replaceAcom.yythird.sdkssets_Param("%s/assets/wk.properties" % prj_path, 'channelId', value)
- if (key == "adId"):
- Replace.replaceAssets_Param("%s/assets/wk.properties" % prj_path, 'adId', value)
- if (key == "adFlag"):
- Replace.replaceAssets_Param("%s/assets/wk.properties" % prj_path, 'adFlag', value)
- manifestRootExt = r'<application xmlns:tools="http://schemas.android.com/tools" tools:replace="android:theme,android:name"'
- replacePkgNameShell = "sed -i 's!<application!%s!g' %s/AndroidManifest.xml" % (manifestRootExt, prj_path)
- printlog("WankaReplace replace add application root point shell: %s" % replacePkgNameShell)
- os.system(replacePkgNameShell)
- pass
- def MBaiduReplace(prj_path, dir_split, key, value):
- if (key == "APP_ID"):
- manifestRootExt = r'<application android:networkSecurityConfig="@xml/network_security_config"'
- replacePkgNameShell = "sed -i 's!<application!%s!g' %s/AndroidManifest.xml" % (manifestRootExt, prj_path)
- printlog("MbaiduReplace replace add application root point shell: %s" % replacePkgNameShell)
- os.system(replacePkgNameShell)
- GeneralModifySmali.modifyRfileIdSmali(prj_path, "/smali/com/baidu/passport/sapi2")
- pass
- def ShenshouReplace(prj_path, dir_split, key, value):
- if (key == "BALANCENAME"):
- prj_style_path = prj_path + dir_split + "res/values-v28/styles.xml"
- printlog("prj_style_path: %s" % prj_style_path)
- File.safeFileDelete(prj_style_path)
- pass
- def DaYanReplace(prj_path, dir_split, key, value):
- if (key == "GD"):
- filepath = "%s/assets/sdkchannel.txt" % prj_path
- replacePdShell = 'sed -i "s#%s#%s#g" %s' % ("PD", value, filepath)
- printlog(replacePdShell)
- os.system(replacePdShell)
- pass
- def DaLanReplace(prj_path, dir_split, key, value):
- printlog("specail replace : DaLanReplace")
- prj_am_path = prj_path + dir_split + "AndroidManifest.xml"
- if (key == "DL_APPID"):
- splashactivity = "com.dalan.dl_assembly.SplashScreenActivity"
- game_activity = Replace.replaceGameActivityLaunchAttribute(splashactivity, prj_am_path)
- printlog("GAMEACTIVITY :%s" % game_activity)
- Replace.replaceAM_Meta_data(prj_am_path, "dalan_union_main_activity", game_activity)
- pass
- def KSyxReplace(prj_path, dir_split, key, value):
- if (key == "kwai_app_id"):
- Replace.replaceAssets_Param("%s/assets/allin_developer_config.properties" % prj_path, 'kwai_app_id', value)
- printlog(" KSyxReplace begin replace game package v4 smali -------------------------------")
- sdk_root_dir = apk_utils.getCutSdkRootHome()
- pkgV4Path = "%s/smali/android/support/v4" % prj_path
- printlog("pkgV4Path:%s" % pkgV4Path)
- sdkV4Path = "%s/ksyx/ksyx/smali/android/support/v4" % sdk_root_dir
- printlog("sdkV4Path:%s" % sdkV4Path)
- if os.path.exists(pkgV4Path):
- File.copyAllFile(sdkV4Path, pkgV4Path)
- prj_am_path = prj_path + dir_split + "AndroidManifest.xml"
- Replace.replaceAM_AllowBackup(prj_am_path)
- pass
- def LlhyReplace(prj_path, dir_split, key, value):
- printlog("specail replace : LlhyReplace")
- if (key == "LLHY_APP_ID"):
- metaKey = "unityplayer.SkipPermissionsDialog"
- Replace.replaceAM_Meta_data("%s/AndroidManifest.xml" % prj_path, metaKey,
- "true")
- pass
- def HnqsReplace(prj_path, dir_split, key, value):
- printlog("specail replace : HnqsReplace")
- if (key == "agent"):
- Replace.replaceAssets_Param("%s/assets/jmhy.properties" % prj_path, 'agent', value)
- metaKey = "unityplayer.SkipPermissionsDialog"
- Replace.replaceAM_Meta_data("%s/AndroidManifest.xml" % prj_path, metaKey,
- "true")
- sdk_root_dir = apk_utils.getCutSdkRootHome()
- sdk_smali_dir = "%s/hnqs/hnqs/extension/yyrh" % sdk_root_dir
- temp_old_smali_dir = "%s/smali/com/yyrh" % prj_path
- if os.path.exists(sdk_smali_dir):
- File.copyAllFile(sdk_smali_dir, temp_old_smali_dir)
- pass
- def SogouReplace(prj_path, dir_split, key, value):
- if (key == "GID"):
- printlog(" SogouReplace begin replace game package v4 smali -------------------------------")
- sdk_root_dir = apk_utils.getCutSdkRootHome()
- pkgV4Path = "%s/smali/android/support/v4" % prj_path
- printlog("pkgV4Path:%s" % pkgV4Path)
- sdkV4Path = "%s/sogou/sogou/smali/android/support/v4" % sdk_root_dir
- printlog("sdkV4Path:%s" % sdkV4Path)
- if os.path.exists(pkgV4Path):
- File.copyAllFile(sdkV4Path, pkgV4Path)
- prj_am_path = prj_path + dir_split + "AndroidManifest.xml"
- Replace.replaceAM_AllowBackup(prj_am_path)
- pass
- def JinRiTouTiaoReplace(prj_path, dir_split, key, value):
- jsonFilePath = prj_path + dir_split + "assets" + dir_split + "config.json"
- if key == 'APP_ID':
- with open(jsonFilePath, 'r') as fp:
- jsonData = json.load(fp)
- jsonData['app']["app_id"] = value
- jsonData['app']['main_activity'] = GeneralModifySmali.getLauchActivityName(prj_path)
- orientation = GeneralModifySmali.getLauchActivityScreenOrientation(prj_path)
- if orientation == "landscape" or orientation == "sensorLandscape":
- screen_orientation = "sensorLandscape"
- else:
- screen_orientation = "sensorPortrait"
- jsonData['app']['screen_orientation'] = screen_orientation
- newJsonData = jsonData
- fp.close()
- with open(jsonFilePath, 'w') as fp:
- json.dump(newJsonData, fp)
- fp.close()
- GeneralModifySmali.modifyRfileIdSmali(prj_path, "/smali/game_sdk/packers/rocket_sdk")
- GeneralModifySmali.modifyRfileIdSmali(prj_path, "/smali_classes2/game_sdk/packers/rocket_sdk")
- GeneralModifySmali.modifyRfileIdSmali(prj_path, "/smali/androidx/navigation/ui")
- GeneralModifySmali.modifyRfileIdSmali(prj_path, "/smali_classes3/android/support/design")
- GeneralModifySmali.modifyRfileIdSmali(prj_path, "/smali_classes3/android/support/v7/appcompat")
- # GeneralModifySmali.replaceSdkV4Smali(prj_path,"jrtt/jrtt/smali/android/support/v4")
- sdk_root_dir = apk_utils.getCutSdkRootHome()
- pkgV4Path = "%s/smali/android/support/v4" % prj_path
- printlog("pkgV4Path:%s" % pkgV4Path)
- sdkV4Path = "%s/jrtt/jrtt/smali_classes3/android/support/v4" % sdk_root_dir
- printlog("sdkV4Path:%s" % sdkV4Path)
- if os.path.exists(pkgV4Path):
- File.copyAllFile(sdkV4Path, pkgV4Path)
- GeneralModifySmali.modifyJrttV7ResIdSmali(prj_path)
- else:
- Replace.replaceJsonValue(jsonFilePath, "app", key, value)
- pass
- def FengQiReplace(prj_path, dir_split, key, value):
- if (key == "channelId") or (key == "adId") or (key == "adFlag"):
- # 替换fq.properties
- printlog("path fq.properties:%s/assets/fq.properties" % prj_path)
- Replace.replaceAssets_Param("%s/assets/fq.properties" % prj_path, key, value)
- pass
- pass
- def BlueStackReplace(prj_path, dir_split, key, value):
- if key == "APP_ID":
- replaceBlueStackIdShell = 'sed -i "1,\\$s/APP_ID/%s/g" %s/assets/BSSDKConfig.xml ' % (value, prj_path)
- printlog("replaceBlueStackIdShell: %s" % replaceBlueStackIdShell)
- os.system(replaceBlueStackIdShell)
- pass
- # 司墨
- def SiMoReplace(prj_path, dir_split, key, value):
- if key == "APP_ID":
- config_path = prj_path + '/assets/SIMgame_config.xml'
- tree = ET.parse(config_path)
- root = tree.getroot()
- for elem in root.iter('appid'):
- elem.text = value
- tree.write(config_path, "UTF-8", xml_declaration=True, method='xml')
- pass
- # 乘龙
- def ChenLongReplace(prj_path, dir_split, key, value):
- if key == "CL_PID":
- Replace.replaceAssets_Param("%s/assets/_cl_developer_config.properties" % prj_path, 'CL_PID', value)
- if key == "CL_KEY":
- Replace.replaceAssets_Param("%s/assets/_cl_developer_config.properties" % prj_path, 'CL_KEY', value)
- if key == "CL_DEBUG_GD":
- Replace.replaceAssets_Param("%s/assets/_cl_developer_config.properties" % prj_path, 'CL_DEBUG_GD', value)
- pass
- def JiuZiReplace(prj_path, dir_split, key, value):
- printlog("specail replace : JiuZiReplace")
- if (key == "gid"):
- prj_param = "%s/assets/YyrhParam.cnf" % prj_path
- prj_am_path = prj_path + dir_split + "AndroidManifest.xml"
- splash_activity = "com.yythird.sdk.SplashActivity"
- game_activity = Replace.replaceGameActivityLaunchAttribute(splash_activity, prj_am_path)
- printlog("GAMEACTIVITY :%s" % game_activity)
- Replace.replaceAssets_Param(prj_param, "GAMEACTIVITY", game_activity)
- pkgName = ET.parse(prj_am_path).getroot().attrib["package"]
- Aapt_Util.createRFile(prj_path, False, pkgName)
- apkRfilePath = "%s/smali/com/jzyx/sdk" % prj_path
- printlog("apkRfilePath:%s" % apkRfilePath)
- publicXml = "%s/res/values/public.xml" % prj_path
- sdk_jar_dir = apk_utils.getToolsJarHome()
- jarPath = "%s/MergeSamli.jar" % sdk_jar_dir
- javaMerCm = 'java -jar %s %s %s' % (jarPath, publicXml, apkRfilePath)
- printlog("javaMerCm:%s" % javaMerCm)
- os.system(javaMerCm)
- pass
- def BingNiaoReplace(prj_path, dir_split, key, value):
- printlog("specail replace : DaLanReplace")
- if (key == "YH_GAME_ID"):
- prj_am_path = prj_path + dir_split + "AndroidManifest.xml"
- splashactivity = "prj.iyinghun.platform.sdk.SplashScreenActivity"
- game_activity = Replace.replaceGameActivityLaunchAttribute(splashactivity, prj_am_path)
- printlog("GAMEACTIVITY :%s" % game_activity)
- Replace.replaceAM_Meta_data(prj_am_path, "prj.chameleon.intent.main", game_activity)
- pass
- def BingChengReplace(prj_path, dir_split, key, value):
- prj_am_path = prj_path + dir_split + "AndroidManifest.xml"
- namespace = '{http://schemas.android.com/apk/res/android}'
- ET.register_namespace('android', "http://schemas.android.com/apk/res/android")
- if (key == "BC_GAME_ID"):
- tree = ET.parse(prj_am_path)
- pkgName = tree.getroot().attrib["package"]
- activitys = tree.getroot().find("application").findall("activity")
- for activity in activitys:
- filters = activity.findall('intent-filter')
- for filter in filters:
- categorys = filter.findall('category')
- for category in categorys:
- categoryname = category.attrib[namespace + "name"]
- if (categoryname == "android.intent.category.LAUNCHER"):
- element = Element('intent-filter')
- el1 = Element('action android:name="android.intent.action.VIEW"')
- el2 = Element('category android:name="android.intent.category.DEFAULT"')
- el3 = Element('category android:name="android.intent.category.BROWSABLE"')
- el4_value = 'data android:host="%s" android:scheme="%s"' % (value, pkgName)
- el4 = Element(el4_value)
- element.append(el1)
- element.append(el2)
- element.append(el3)
- element.append(el4)
- activity.append(element)
- tree.write(prj_am_path, "UTF-8", xml_declaration=True, method='xml')
- def SuixingHuYuReplace(prj_path, dir_split, key, value):
- if (key == "game_id"):
- Replace.replaceAssets_Param("%s/assets/suixin/suixin_sdk.ini" % prj_path, key, value)
- if (key == "pid"):
- Replace.replaceAssets_Param("%s/assets/suixin/suixin_sdk.ini" % prj_path, key, value)
- if (key == "is_land"):
- Replace.replaceAssets_Param("%s/assets/suixin/suixin_sdk.ini" % prj_path, key, value)
- pass
- def ShouQuReplace(prj_path, dir_split, key, value):
- config_path = "%s/assets/sqsdk_config" % prj_path
- with open(config_path, "r") as f:
- content = f.read()
- json_data = json.loads(content)
- json_data[key] = value
- with open(config_path, "w") as f:
- f.write(json.dumps(json_data))
- if key == "app_key":
- manifest_path = prj_path + dir_split + "AndroidManifest.xml"
- param_cnf = "%s/assets/YyrhParam.cnf" % prj_path
- splash_activity = "com.yythird.sdk.SplashActivity"
- game_activity = Replace.replaceGameActivityLaunchAttribute(splash_activity, manifest_path)
- Replace.replaceAssets_Param(param_cnf, "GAMEACTIVITY", game_activity)
- printlog("GAMEACTIVITY :%s" % game_activity)
- def HaiNanQiJingReplace(prj_path, dir_split, key, value):
- if key == "PACKAGE_TAG":
- sdk_root_dir = apk_utils.getCutSdkRootHome()
- sdkSmaliPath = "%s/hnqj/hnqj/smali/com" % sdk_root_dir
- pkgSmaliPath = "%s/smali/com" % prj_path
- printlog("sdkSmaliPath :%s" % sdkSmaliPath)
- printlog("pkgSmaliPath :%s" % pkgSmaliPath)
- if os.path.exists(pkgSmaliPath):
- File.copyAllFile(sdkSmaliPath, pkgSmaliPath)
- if Contants.isTestEnvironment():
- key = "https://fxsy.qijinghao.com"
- value = "http://testsdkapi.yyxxgame.com"
- file = "%s/smali/com/yyrh/c/a.smali" % prj_path
- Replace.replaceKeyword(key, value, file)
- file = "%s/smali/com/yyrh/ui/a.smali" % prj_path
- Replace.replaceKeyword(key, value, file)
- file = "%s/smali/com/yyrh/a/d.smali" % prj_path
- Replace.replaceKeyword(key, value, file)
- file = "%s/smali/com/yyrh/sdk/SDKEntry.smali" % prj_path
- Replace.replaceKeyword(key, value, file)
- pass
- def HongGuoReplace(prj_path, dir_split, key, value):
- config_path = "%s/assets/gameInfo.json" % prj_path
- with open(config_path, "r") as f:
- content = f.read()
- json_data = json.loads(content)
- json_data[key] = value
- with open(config_path, "w") as f:
- f.write(json.dumps(json_data))
- if key == "game_id":
- manifest_path = prj_path + dir_split + "AndroidManifest.xml"
- param_cnf = "%s/assets/YyrhParam.cnf" % prj_path
- splash_activity = "com.yythird.sdk.SplashActivity"
- game_activity = Replace.replaceGameActivityLaunchAttribute(splash_activity, manifest_path)
- Replace.replaceAssets_Param(param_cnf, "GAMEACTIVITY", game_activity)
- sdk_root_dir = apk_utils.getCutSdkRootHome()
- printlog(" HongGuoReplace begin replace game package v4 smali -------------------------------")
- pkgV4Path = "%s/smali/android/support/v4" % prj_path
- printlog("pkgV4Path:%s" % pkgV4Path)
- sdkV4Path = "%s/hg/hg/smali/android/support/v4" % sdk_root_dir
- printlog("sdkV4Path:%s" % sdkV4Path)
- if os.path.exists(pkgV4Path):
- File.copyAllFile(sdkV4Path, pkgV4Path)
- pass
- def BaizeReplace(prj_path, dir_split, key, value):
- if key == "APP_ID":
- prj_am_path = prj_path + dir_split + "AndroidManifest.xml"
- param_cnf = "%s/assets/YyrhParam.cnf" % prj_path
- splashactivity = "com.yythird.sdk.SplashActivity"
- game_activity = Replace.replaceGameActivityLaunchAttribute(splashactivity, prj_am_path)
- printlog("GAMEACTIVITY :%s" % game_activity)
- Replace.replaceAssets_Param(param_cnf, "GAMEACTIVITY", game_activity)
- pass
- def YanXinReplace(prj_path, dir_split, key, value):
- if key == "ProductCode":
- Replace.modifyRfileSmaliPath("yx", prj_path)
- pass
- def ZhangShangHuYuReplace(prj_path, dir_split, key, value):
- Replace.replaceAssets_Param("%s/assets/yy.properties" % prj_path, key, value)
- if key == "channelId":
- sdk_root_dir = apk_utils.getCutSdkRootHome()
- printlog(" ZhangShangHuYuReplace begin replace game package v4 smali -------------------------------")
- pkgV4Path = "%s/smali/android/support/v7" % prj_path
- printlog("pkgV4Path:%s" % pkgV4Path)
- sdkV4Path = "%s/zshy/zshy/smali/android/support/v7" % sdk_root_dir
- printlog("sdkV4Path:%s" % sdkV4Path)
- if os.path.exists(pkgV4Path):
- File.copyAllFile(sdkV4Path, pkgV4Path)
- GeneralModifySmali.modifyRfileIdSmali(prj_path, "/smali/android/support/v7/cardview")
- printlog(" HongGuoReplace begin replace game package v4 smali -------------------------------")
- pkgV4Path = "%s/smali/android/support/v4" % prj_path
- printlog("pkgV4Path:%s" % pkgV4Path)
- sdkV4Path = "%s/zshy/zshy/smali/android/support/v4" % sdk_root_dir
- printlog("sdkV4Path:%s" % sdkV4Path)
- if os.path.exists(pkgV4Path):
- File.copyAllFile(sdkV4Path, pkgV4Path)
- apkRfilePath = "%s/smali/com/zshy/zshysdk" % prj_path
- printlog("apkRfilePath:%s" % apkRfilePath)
- publicXml = "%s/res/values/public.xml" % prj_path
- sdk_jar_dir = apk_utils.getToolsJarHome()
- jarPath = "%s/MergeSamli.jar" % sdk_jar_dir
- javaMerCm = 'java -jar %s %s %s' % (jarPath, publicXml, apkRfilePath)
- printlog("javaMerCm:%s" % javaMerCm)
- os.system(javaMerCm)
- Replace.modifyRfileSmaliPath("zshy", prj_path);
- pass
- def XiYouWangReplace(prj_path, dir_split, key, value):
- Replace.replaceAssets_Param("%s/assets/xy_developer_config.properties" % prj_path, key, value)
- if key == "XY_APP_ID":
- splash_activity = "com.xiyou.sdk.XiYouSplashActivity"
- manifest_path = prj_path + dir_split + "AndroidManifest.xml"
- game_activity = Replace.replaceGameActivityLaunchAttribute(splash_activity, manifest_path)
- Replace.replaceAM_Meta_data(manifest_path, 'XY_GAME_MAIN_ACTIVITY_NAME', game_activity)
- sdk_root_dir = apk_utils.getCutSdkRootHome()
- printlog(" xiyouwang begin replace game package v4 smali -------------------------------")
- pkgV4Path = "%s/smali/android/support/v4" % prj_path
- printlog("pkgV4Path:%s" % pkgV4Path)
- sdkV4Path = "%s/xiyou/xiyou/smali/android/support/v4" % sdk_root_dir
- printlog("sdkV4Path:%s" % sdkV4Path)
- if os.path.exists(pkgV4Path):
- File.copyAllFile(sdkV4Path, pkgV4Path)
- prj_am_path = "%s/AndroidManifest.xml" % prj_path
- pkgName = ET.parse(prj_am_path).getroot().attrib["package"]
- Aapt_Util.createRFile(prj_path, False, pkgName)
- pass
- def XunLeiReplace(prj_path, dir_split, key, value):
- prj_am_path = prj_path + dir_split + "AndroidManifest.xml"
- namespace = '{http://schemas.android.com/apk/res/android}'
- ET.register_namespace('android', "http://schemas.android.com/apk/res/android")
- if (key == "schemeCallback"):
- tree = ET.parse(prj_am_path)
- activitys = tree.getroot().find("application").findall("activity")
- for activity in activitys:
- activityName = activity.attrib[namespace + "name"]
- printlog("activityName:%s" % activityName)
- if (activityName == "com.xovs.common.auth.processor.XLAuthBackActivity"):
- filters = activity.findall('intent-filter')
- for filter in filters:
- datas = filter.findall('data')
- for data in datas:
- printlog("data:%s" % data)
- data.set(namespace + "scheme", value)
- tree.write(prj_am_path, "UTF-8", xml_declaration=True, method='xml')
- pass
- def CanLongReplace(prj_path, dir_split, key, value):
- if key == "PRODUCT_CODE":
- Replace.modifyRfileSmaliPath("canlong", prj_path);
- pass
- def ShangHaiXiYuanReplace(prj_path, dir_split, key, value):
- if key == "PACKAGE_TAG":
- sdk_root_dir = apk_utils.getCutSdkRootHome()
- sdkSmaliPath = "%s/shxy/shxy/smali/com/yyrh" % sdk_root_dir
- pkgSmaliPath = "%s/smali/com/yyrh" % prj_path
- printlog("sdkSmaliPath :%s" % sdkSmaliPath)
- printlog("pkgSmaliPath :%s" % pkgSmaliPath)
- if os.path.exists(pkgSmaliPath):
- File.copyAllFile(sdkSmaliPath, pkgSmaliPath)
- if Contants.isTestEnvironment():
- key = "https://sdkapi.bklinok.com"
- value = "http://testsdkapi.yyxxgame.com"
- file = "%s/smali/com/yyrh/c/a.smali" % prj_path
- Replace.replaceKeyword(key, value, file)
- file = "%s/smali/com/yyrh/a/d.smali" % prj_path
- Replace.replaceKeyword(key, value, file)
- file = "%s/smali/com/yyrh/sdk/SDKEntry.smali" % prj_path
- Replace.replaceKeyword(key, value, file)
- pass
- def YuanYouRongHeReplace(prj_path, dir_split, key, value):
- if key == "PACKAGE_TAG":
- sdk_root_dir = apk_utils.getCutSdkRootHome()
- sdkSmaliPath = "%s/mixsdk/mixsdk/smali/com/yyrh" % sdk_root_dir
- pkgSmaliPath = "%s/smali/com/yyrh" % prj_path
- printlog("sdkSmaliPath :%s" % sdkSmaliPath)
- printlog("pkgSmaliPath :%s" % pkgSmaliPath)
- if os.path.exists(pkgSmaliPath):
- File.copyAllFile(sdkSmaliPath, pkgSmaliPath)
- sdkSmaliPath = "%s/mixsdk/mixsdk/smali/com/yythird/base" % sdk_root_dir
- pkgSmaliPath = "%s/smali/com/yythird/base" % prj_path
- printlog("sdkSmaliPath :%s" % sdkSmaliPath)
- printlog("pkgSmaliPath :%s" % pkgSmaliPath)
- if os.path.exists(pkgSmaliPath):
- File.copyAllFile(sdkSmaliPath, pkgSmaliPath)
- if Contants.isTestEnvironment():
- key = "https://sdkapi.yyxxgame.com"
- value = "http://testsdkapi.yyxxgame.com"
- file = "%s/smali/com/yyrh/c/a.smali" % prj_path
- Replace.replaceKeyword(key, value, file)
- file = "%s/smali/com/yyrh/sdk/SDKEntry.smali" % prj_path
- Replace.replaceKeyword(key, value, file)
- pass
- def BaLeReplace(prj_path, dir_split, key, value):
- if key == "CHANNEL_ID":
- GeneralModifySmali.modifyRfileIdSmali(prj_path, "/smali/com/sdk/douyou")
- pass
- def QiPaReplace(prj_path, dir_split, key, value):
- if key == "Super_Game_ID":
- splash_activity = "com.supersdk.application.MySplashActivity"
- prj_am_path = "%s/AndroidManifest.xml" % prj_path
- game_activity = Replace.replaceGameActivityLaunchAttribute(splash_activity, prj_am_path)
- tree = ET.parse(prj_am_path)
- activitys = tree.getroot().find("application").findall("activity")
- for activity in activitys:
- namespace = '{http://schemas.android.com/apk/res/android}'
- xml_activity_name = activity.attrib[namespace + "name"]
- if xml_activity_name == game_activity:
- filter = activity.find('intent-filter')
- el1 = Element('action android:name="com.super.sdk.MAIN"')
- filter.append(el1)
- tree.write(prj_am_path, "UTF-8", xml_declaration=True, method='xml')
- pass
- def DouyinReplace(prj_path, dir_split, key, value):
- jsonFilePath = prj_path + dir_split + "assets" + dir_split + "config.json"
- if key == 'app_id':
- with open(jsonFilePath, 'r') as fp:
- jsonData = json.load(fp)
- jsonData["app_id"] = value
- jsonData['screen_orientation'] = GeneralModifySmali.getLauchActivityName(prj_path)
- orientation = GeneralModifySmali.getLauchActivityScreenOrientation(prj_path)
- if orientation == "landscape" or orientation == "sensorLandscape":
- screen_orientation = "sensorLandscape"
- else:
- screen_orientation = "sensorPortrait"
- jsonData['screen_orientation'] = screen_orientation
- newJsonData = jsonData
- fp.close()
- with open(jsonFilePath, 'w') as fp:
- json.dump(newJsonData, fp)
- fp.close()
- printlog(" douyin begin replace game package v4 smali -------------------------------")
- pkgV4Path = "%s/smali/android/support/v4" % prj_path
- printlog("pkgV4Path:%s" % pkgV4Path)
- File.del_file(pkgV4Path)
- prj_am_path = "%s/AndroidManifest.xml" % prj_path
- pkgName = ET.parse(prj_am_path).getroot().attrib["package"]
- Aapt_Util.createRFile(prj_path, False, pkgName)
- sdkRpath = "android/support/v7/appcompat"
- pkgRpath = pkgName.replace(".", "/")
- sdkAbsoluteRpath = "%s/smali_classes3/%s" % (prj_path, sdkRpath)
- pkgAbsoluteRpath = "%s/smali/%s" % (prj_path, pkgRpath)
- Replace.createRFile2Sdk(pkgAbsoluteRpath, sdkAbsoluteRpath, pkgRpath, sdkRpath)
- pass
- def MoMoYuReplace(prj_path, dir_split, key, value):
- xml_path = "%s/res/values/strings.xml" % prj_path
- Replace.replaceXmlValue(xml_path, key, value)
- pass
- def QuxuanReplace(prj_path, dir_split, key, value):
- if key == "app_id":
- prj_am_path = "%s/AndroidManifest.xml" % prj_path
- value = "Qdazzle_%s" % value
- Replace.replaceAM_Meta_data(prj_am_path, "CommonSDK_AppID", value)
- GeneralModifySmali.modifyRfileIdSmali(prj_path, "/smali/com/qdazzle/sdk")
- if key == "app_key":
- prj_am_path = "%s/AndroidManifest.xml" % prj_path
- value = "Qdazzle_%s" % value
- Replace.replaceAM_Meta_data(prj_am_path, "CommonSDK_AppKey", value)
- pass
- def MuMuReplace(prj_path, dir_split, key, value):
- if key == "YOFUN_APP_ID":
- printlog("specail replace : MuMuReplace")
- splashactivity = "com.yythird.sdk.SplashActivity"
- prj_am_path = prj_path + dir_split + "AndroidManifest.xml"
- prj_param = "%s/assets/YyrhParam.cnf" % prj_path
- game_activity = Replace.replaceGameActivityLaunchAttribute(splashactivity, prj_am_path)
- printlog("GAMEACTIVITY :%s" % game_activity)
- Replace.replaceAssets_Param(prj_param, "GAMEACTIVITY", game_activity)
- pass
- def HeFengReplace(prj_path, dir_split, key, value):
- if key == "ver":
- printlog("specail replace : HeFengReplace")
- printlog("path hf.properties :%s/assets/hf.properties" % prj_path)
- Replace.replaceAssets_Param("%s/assets/hf.properties" % prj_path, "agent", value)
- pass
- def ShengBenFuliReplace(prj_path, dir_split, key, value):
- if key == "appid":
- printlog("specail replace : ShengBenFuliReplace")
- splash_activity = "com.fysdk.activity.FyGuideActivity"
- prj_am_path = prj_path + dir_split + "AndroidManifest.xml"
- namespace = '{http://schemas.android.com/apk/res/android}'
- ET.register_namespace('android', "http://schemas.android.com/apk/res/android")
- tree = ET.parse(prj_am_path)
- activitys = tree.getroot().find("application").findall("activity")
- for activity in activitys:
- filters = activity.findall('intent-filter')
- for filter in filters:
- categorys = filter.findall('category')
- actions = filter.findall('action')
- for category in categorys:
- category_name = category.attrib[namespace + "name"]
- if category_name == "android.intent.category.LAUNCHER":
- action_name = activity.attrib[namespace + "name"]
- if action_name != splash_activity:
- printlog("delete :%s" % category_name)
- category.attrib[namespace + "name"] = "android.intent.category.DEFAULT"
- printlog("LAUNCHER replace DEFAULT :%s" % category.attrib[namespace + "name"])
- for action in actions:
- action_name = action.attrib[namespace + "name"]
- if action_name == "android.intent.action.MAIN":
- printlog("delete :%s" % action_name)
- action.attrib[namespace + "name"] = "game.MAIN"
- tree.write(prj_am_path, "UTF-8", xml_declaration=True, method='xml')
- pass
- def MuXueReplace(prj_path, dir_split, key, value):
- printlog("specail replace : MuXueReplace")
- Replace.replaceAssets_Param("%s/assets/gs.properties" % prj_path, key, value)
- pass
- def QiYouReplace(prj_path, dir_split, key, value):
- if (key == "blgame_gameid"):
- prj_am_path = prj_path + dir_split + "AndroidManifest.xml"
- pkgName = ET.parse(prj_am_path).getroot().attrib["package"]
- sdk_root_dir = apk_utils.getCutSdkRootHome()
- pkgV4Path = "%s/smali/android/support/design" % prj_path
- printlog("pkgV4Path:%s" % pkgV4Path)
- sdkV4Path = "%s/7you/7you/smali/android/support/design" % sdk_root_dir
- printlog("sdkV4Path:%s" % sdkV4Path)
- if os.path.exists(pkgV4Path):
- File.copyAllFile(sdkV4Path, pkgV4Path)
- Aapt_Util.createRFile(prj_path, False, pkgName)
- GeneralModifySmali.modifyRfileIdSmali(prj_path, "/smali/android/support/v7/appcompat")
- GeneralModifySmali.modifyRfileIdSmali(prj_path, "/smali/android/support/design")
- GeneralModifySmali.modifyRfileIdSmali(prj_path, "/smali/android/support/v7/cardview")
- pass
- def YueWanReplace(prj_path, dir_split, key, value):
- printlog("specail replace : YueWanReplace")
- if (key == "J_GAME_ID"):
- sdk_root_dir = apk_utils.getCutSdkRootHome()
- printlog(" YueWanReplace begin replace game package v4 smali -------------------------------")
- pkgV4Path = "%s/smali/android/support/v4" % prj_path
- printlog("pkgV4Path:%s" % pkgV4Path)
- sdkV4Path = "%s/yuewan/yuewan/smali/android/support/v4" % sdk_root_dir
- printlog("sdkV4Path:%s" % sdkV4Path)
- if os.path.exists(pkgV4Path):
- File.copyAllFile(sdkV4Path, pkgV4Path)
- pass
- def ShengYueReplace(prj_path, dir_split, key, value):
- printlog("specail replace : ShengYueReplace")
- jsonFilePath = prj_path + dir_split + "assets" + dir_split + "UUConfig.json"
- Replace.replaceJsonValue(jsonFilePath, "", key, value)
- pass
- def JiZhiHuiReplace(prj_path, dir_split, key, value):
- printlog("specail replace : JiZhiHuiReplace")
- config_path = "%s/assets/xggameinfo.txt" % prj_path
- with open(config_path, "r") as f:
- content = f.read()
- json_data = json.loads(content)
- json_data[key] = value
- with open(config_path, "w") as f:
- f.write(json.dumps(json_data))
- def JiMiReplace(prj_path, dir_split, key, value):
- Replace.replaceAssets_Param("%s/assets/jmhy.properties" % prj_path, key, value)
- def DangLesdkReplace(prj_path, dir_split, key, value):
- printlog("specail replace : DangLesdkReplace")
- if key == "RH_APPID":
- prj_am_path = prj_path + dir_split + "AndroidManifest.xml"
- splashactivity = "com.rhsdk.SplashActivity"
- game_activity = Replace.replaceGameActivityLaunchAttribute(splashactivity, prj_am_path)
- printlog("GAMEACTIVITY :%s" % game_activity)
- Replace.replaceAM_Meta_data(prj_am_path, "RH_GAME_ACTIVITY", game_activity)
- rh_developer_config = "%s/assets/rh_developer_config.xml" % prj_path
- tree = ET.parse(rh_developer_config)
- metadatas = tree.getroot().findall("param")
- for meta in metadatas:
- if meta.attrib["name"] == key:
- meta.attrib["value"] = value
- tree.write(rh_developer_config, "UTF-8", xml_declaration=True, method='xml')
- elif key == "RH_APPKEY":
- rh_developer_config = "%s/assets/rh_developer_config.xml" % prj_path
- tree = ET.parse(rh_developer_config)
- metadatas = tree.getroot().findall("param")
- for meta in metadatas:
- if meta.attrib["name"] == key:
- meta.attrib["value"] = value
- tree.write(rh_developer_config, "UTF-8", xml_declaration=True, method='xml')
- pass
- def PinBangsdkReplace(prj_path, dir_split, key, value):
- if key == 'xggameinfo.txt':
- if os.path.exists(value):
- printlog('replace pinbang xggameinfo.txt:%s' % value)
- pb_sdk_config_path = os.path.join(prj_path, 'assets', key)
- printlog('replace pinbang pb_sdk_config_path:%s' % pb_sdk_config_path)
- shutil.copy(value, pb_sdk_config_path)
- pass
- def JianDaoReplace(prj_path, dir_split, key, value):
- if key == "JIANDAO_GAMEID":
- splashactivity = "com.yythird.sdk.SplashActivity"
- prj_param = "%s/assets/YyrhParam.cnf" % prj_path
- prj_am_path = prj_path + dir_split + "AndroidManifest.xml"
- game_activity = Replace.replaceGameActivityLaunchAttribute(splashactivity, prj_am_path)
- Replace.replaceAssets_Param(prj_param, "GAME_ACTIVITY", game_activity)
- printlog("JianDaoReplace GAME_ACTIVITY :%s" % game_activity)
- sdk_root_dir = apk_utils.getCutSdkRootHome()
- pkgV4Path = "%s/smali/android/support/v4" % prj_path
- printlog("pkgV4Path:%s" % pkgV4Path)
- sdkV4Path = "%s/jiandao/jiandao/smali/android/support/v4" % sdk_root_dir
- printlog("sdkV4Path:%s" % sdkV4Path)
- if os.path.exists(pkgV4Path):
- File.copyAllFile(sdkV4Path, pkgV4Path)
- def MengHuReplace(prj_path, dir_split, key, value):
- if key == "appid":
- prj_am_path = "%s/AndroidManifest.xml" % prj_path
- pkgName = ET.parse(prj_am_path).getroot().attrib["package"]
- Aapt_Util.createRFile(prj_path, False, pkgName)
- pass
- def MengHu2Replace(prj_path, dir_split, key, value):
- if key == "appid":
- prj_am_path = "%s/AndroidManifest.xml" % prj_path
- pkgName = ET.parse(prj_am_path).getroot().attrib["package"]
- Aapt_Util.createRFile(prj_path, False, pkgName)
- def MengHu3Replace(prj_path, dir_split, key, value):
- config_path = "%s/assets/cd_super_sdk.json" % prj_path
- with open(config_path, "r") as f:
- content = f.read()
- json_data = json.loads(content)
- json_data[key] = value
- with open(config_path, "w") as f:
- f.write(json.dumps(json_data))
- def baUReplace(prj_path, dir_split, key, value):
- if key == "appid":
- splashactivity = "com.yythird.sdk.SplashActivity"
- prj_param = "%s/assets/YyrhParam.cnf" % prj_path
- prj_am_path = prj_path + dir_split + "AndroidManifest.xml"
- game_activity = Replace.replaceGameActivityLaunchAttribute(splashactivity, prj_am_path)
- Replace.replaceAssets_Param(prj_param, "GAME_ACTIVITY", game_activity)
- printlog("baUReplace GAME_ACTIVITY :%s" % game_activity)
- pass
- def ZhongXingReplace(prj_path, dir_split, key, value):
- if key == 'Gamble_cfg':
- printlog('replace ZhongXing Gamble_cfg')
- config_path = os.path.join(prj_path, 'assets', key)
- shutil.copy(value, config_path)
- pass
- specialReplace = {
- "lenovo": LenovoReplace,
- "baidu": BaiduReplace,
- "wandoujia": WandoujiaReplace,
- "qh360": QihuReplace,
- "oppo": OppoReplace,
- "oppoml": OppoMlReplace,
- "chongchong": ChongchongReplace,
- "yingyongbao": YYBReplace,
- "downjoy": downjoyReplace,
- "huawei": HuaweiReplace,
- "anzhi": AnzhiReplace,
- "leshi": LeshiReplace,
- "quick": QuickReplace,
- "guopan": GuopanReplace,
- "ljsdk": LjsdkReplace,
- "uc": UcsdkReplace,
- "xiaomi": XiaomisdkReplace,
- "hnshengben": ShengbensdkReplace,
- "jk": JinkuosdkReplace,
- "hd": HdhdsdkReplace,
- "samsung": SamsungReplace,
- "ttyy": TTReplace,
- "yxf": YXFReplace,
- "vivo": VivosdkReplace,
- "3011": XTsdkReplace,
- "ddt": DDTsdkReplace,
- "wanka": WankaReplace,
- "ddd": DDDReplace,
- "lzyx": LZYXReplace,
- "ws": WSReplace,
- "xb": XBReplace,
- "youdian": YoudianReplace,
- "x7sy": Xiao7Replace,
- "nwanka": NwanKaReplace,
- "mbaidu": MBaiduReplace,
- "shenshou": ShenshouReplace,
- "dyyx": DaYanReplace,
- "dl": DaLanReplace,
- "ksyx": KSyxReplace,
- "llhy": LlhyReplace,
- "hnqs": HnqsReplace,
- "sogou": SogouReplace,
- "jrtt": JinRiTouTiaoReplace,
- "fq": FengQiReplace,
- "bs": BlueStackReplace,
- "simo": SiMoReplace,
- "cl": ChenLongReplace,
- "qianmian": JinRiTouTiaoReplace,
- "jiuzi": JiuZiReplace,
- "bingniao": BingNiaoReplace,
- "bingcheng": BingChengReplace,
- "sxhy": SuixingHuYuReplace,
- "shouqu": ShouQuReplace,
- "hnqj": HaiNanQiJingReplace,
- "hg": HongGuoReplace,
- "baize": BaizeReplace,
- "yx": YanXinReplace,
- "zshy": ZhangShangHuYuReplace,
- "xiyou": XiYouWangReplace,
- "xunlei": XunLeiReplace,
- "canlong": CanLongReplace,
- "shxy": ShangHaiXiYuanReplace,
- "mixsdk": YuanYouRongHeReplace,
- "bale": BaLeReplace,
- "7pa": QiPaReplace,
- "dymmy": MoMoYuReplace,
- "dyly": DouyinReplace,
- "qx": QuxuanReplace,
- "wymumu": MuMuReplace,
- "hf": HeFengReplace,
- "sbfl": ShengBenFuliReplace,
- "muxue": MuXueReplace,
- "7you": QiYouReplace,
- "yuewan": YueWanReplace,
- "shengyue": ShengYueReplace,
- "jzh": JiZhiHuiReplace,
- "jmhy": JiMiReplace,
- "dangle": DangLesdkReplace,
- "pinbang": PinBangsdkReplace,
- "jiandao": JianDaoReplace,
- "menghu": MengHuReplace,
- "8uyx": baUReplace,
- "menghu2": MengHu2Replace,
- "menghu3": MengHu3Replace,
- "zx":ZhongXingReplace
- }
- def getSpecilReplace(sdk_name):
- if sdk_name in specialReplace:
- return specialReplace[sdk_name]
- else:
- return None
- pass
|