1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495969798991001011021031041051061071081091101111121131141151161171181191201211221231241251261271281291301311321331341351361371381391401411421431441451461471481491501511521531541551561571581591601611621631641651661671681691701711721731741751761771781791801811821831841851861871881891901911921931941951961971981992002012022032042052062072082092102112122132142152162172182192202212222232242252262272282292302312322332342352362372382392402412422432442452462472482492502512522532542552562572582592602612622632642652662672682692702712722732742752762772782792802812822832842852862872882892902912922932942952962972982993003013023033043053063073083093103113123133143153163173183193203213223233243253263273283293303313323333343353363373383393403413423433443453463473483493503513523533543553563573583593603613623633643653663673683693703713723733743753763773783793803813823833843853863873883893903913923933943953963973983994004014024034044054064074084094104114124134144154164174184194204214224234244254264274284294304314324334344354364374384394404414424434444454464474484494504514524534544554564574584594604614624634644654664674684694704714724734744754764774784794804814824834844854864874884894904914924934944954964974984995005015025035045055065075085095105115125135145155165175185195205215225235245255265275285295305315325335345355365375385395405415425435445455465475485495505515525535545555565575585595605615625635645655665675685695705715725735745755765775785795805815825835845855865875885895905915925935945955965975985996006016026036046056066076086096106116126136146156166176186196206216226236246256266276286296306316326336346356366376386396406416426436446456466476486496506516526536546556566576586596606616626636646656666676686696706716726736746756766776786796806816826836846856866876886896906916926936946956966976986997007017027037047057067077087097107117127137147157167177187197207217227237247257267277287297307317327337347357367377387397407417427437447457467477487497507517527537547557567577587597607617627637647657667677687697707717727737747757767777787797807817827837847857867877887897907917927937947957967977987998008018028038048058068078088098108118128138148158168178188198208218228238248258268278288298308318328338348358368378388398408418428438448458468478488498508518528538548558568578588598608618628638648658668678688698708718728738748758768778788798808818828838848858868878888898908918928938948958968978988999009019029039049059069079089099109119129139149159169179189199209219229239249259269279289299309319329339349359369379389399409419429439449459469479489499509519529539549559569579589599609619629639649659669679689699709719729739749759769779789799809819829839849859869879889899909919929939949959969979989991000100110021003100410051006100710081009101010111012101310141015101610171018101910201021102210231024102510261027102810291030103110321033103410351036103710381039104010411042104310441045104610471048104910501051105210531054105510561057105810591060106110621063106410651066106710681069107010711072107310741075107610771078107910801081108210831084108510861087108810891090109110921093109410951096109710981099110011011102110311041105110611071108110911101111111211131114111511161117111811191120112111221123112411251126112711281129113011311132113311341135113611371138113911401141114211431144114511461147114811491150115111521153115411551156115711581159116011611162116311641165116611671168116911701171117211731174117511761177117811791180118111821183118411851186118711881189119011911192119311941195119611971198119912001201120212031204120512061207120812091210121112121213121412151216121712181219122012211222122312241225122612271228122912301231123212331234123512361237123812391240124112421243124412451246124712481249125012511252125312541255125612571258125912601261126212631264126512661267126812691270127112721273127412751276127712781279128012811282128312841285128612871288128912901291129212931294129512961297129812991300130113021303130413051306130713081309131013111312131313141315131613171318131913201321132213231324132513261327132813291330133113321333133413351336133713381339134013411342134313441345134613471348134913501351135213531354135513561357135813591360136113621363136413651366136713681369137013711372137313741375137613771378137913801381138213831384138513861387138813891390139113921393139413951396139713981399140014011402140314041405140614071408140914101411141214131414141514161417141814191420142114221423142414251426142714281429143014311432143314341435143614371438143914401441144214431444144514461447144814491450145114521453145414551456145714581459146014611462146314641465146614671468146914701471147214731474147514761477147814791480148114821483148414851486148714881489149014911492149314941495149614971498149915001501150215031504150515061507150815091510151115121513151415151516151715181519152015211522152315241525152615271528152915301531153215331534153515361537153815391540154115421543154415451546154715481549155015511552155315541555155615571558155915601561156215631564 |
- # -*-coding:utf-8-*-
- import os
- import xml.etree.ElementTree as ET
- import re
- import hashlib
- import shutil
- import json
- from print_log import printlog
- import contants, file_utils, Replace, apk_tool
- from xml.etree.ElementTree import Element
- androidNS = 'http://schemas.android.com/apk/res/android'
- namespace = '{' + androidNS + '}'
- # 联想
- def LenovoReplace(prj_path, 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, key, value):
- printlog("specail replace : wdj")
- if key == "APPKEY_ID":
- prj_am_path = os.path.join(prj_path, '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, key, value):
- printlog("specail replace : Chongchong")
- if key == "app_id":
- prj_am_path = os.path.join(prj_path, '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, 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_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)
- file_utils.replace_manifest_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, key, value):
- printlog("specail replace : oppo")
- if key == "APPKEY":
- prj_am_path = os.path.join(prj_path, 'AndroidManifest.xml')
- printlog("prj_am_path: %s" % prj_am_path)
- # 替换app_key
- file_utils.replace_manifest_meta_data(prj_am_path, 'app_key', value)
- printlog("appkey: %s" % value)
- pass
- def OppoMlReplace(prj_path, key, value):
- printlog("specail replace : oppoml")
- if key == "APPKEY":
- prj_am_path = os.path.join(prj_path, 'AndroidManifest.xml')
- printlog("prj_am_path: %s" % prj_am_path)
- # 替换app_key
- file_utils.replace_manifest_meta_data(prj_am_path, 'app_key', value)
- printlog("appkey: %s" % value)
- pass
- def downjoyReplace(prj_path, 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.replace_game_launch_activity_attribute_to_default(splash_activity, prj_am_path)
- printlog(game_activity)
- file_utils.replace_manifest_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, 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)
- file_utils.replace_assets_param("%s/assets/ysdkconf.ini" % prj_path, key, value)
- file_utils.replace_assets_param("%s/assets/ysdkconf.ini" % prj_path, "OFFER_ID", value)
- prj_am_path = "%s/AndroidManifest.xml" % prj_path
- game_activity = Replace.get_lauch_activity_name(prj_path)
- file_utils.replace_manifest_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
- file_utils.replace_assets_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
- file_utils.replace_assets_param("%s/assets/ysdkconf.ini" % prj_path, "YSDK_URL", ysdk_url)
- pass
- def HuaweiReplace(prj_path, 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)
- Replace.modify_R_id_smali(prj_path, "/smali/com/huawei/android/hms/app")
- Replace.modify_R_id_smali(prj_path, "/smali/com/huawei/android/hms/game")
- Replace.modify_R_id_smali(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, 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, 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, key, value):
- printlog("specail replace : leshi")
- prj_am_path = os.path.join(prj_path, 'AndroidManifest.xml')
- if key == "LEPAY_APPID":
- file_utils.replace_manifest_meta_data(prj_am_path, 'lepay_appid', value)
- if key == "LEPAY_APPKEY":
- file_utils.replace_manifest_meta_data(prj_am_path, 'lepay_appkey', value)
- pass
- def QuickReplace(prj_path, key, value):
- printlog("specail replace : Quick")
- if key == "PRODUCT_CODE":
- splashactivity = "com.yythird.sdk.SplashActivity"
- prj_am_path = os.path.join(prj_path, 'AndroidManifest.xml')
- prj_param = "%s/assets/YyrhParam.cnf" % prj_path
- game_activity = Replace.replace_game_launch_activity_attribute_to_default(splashactivity, prj_am_path)
- printlog("GAMEACTIVITY :%s" % game_activity)
- file_utils.replace_assets_param(prj_param, "GAMEACTIVITY", game_activity)
- if key == "SDK_TYPE":
- printlog("merge qitian Smali")
- if value == "qitian":
- printlog("merge qitian Smali")
- sdk_root_dir = contants.channel_sdk_path
- ret = 0
- ret = ret | Replace.mergeDir("%s/quick/quick/qitian_smali" % sdk_root_dir, "%s/smali" % prj_path)
- pass
- def LjsdkReplace(prj_path, key, value):
- printlog("specail replace : LjsdkReplace")
- if key == "XMGAME_PRODUCT_CODE":
- prj_param = "%s/assets/param.cnf" % prj_path
- prj_am_path = os.path.join(prj_path, 'AndroidManifest.xml')
- splashactivity = "third.sdk.SplashActivity"
- game_activity = Replace.replace_game_launch_activity_attribute_to_default(splashactivity, prj_am_path)
- printlog("GAMEACTIVITY :%s" % game_activity)
- file_utils.replace_assets_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, 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)
- pass
- def XiaomisdkReplace(prj_path, key, value):
- printlog("specail replace : XiaomisdkReplace")
- prj_am_path = os.path.join(prj_path, 'AndroidManifest.xml')
- if key == "APP_ID":
- # 获取包名
- sdk_root_dir = contants.channel_sdk_path
- 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):
- Replace.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):
- Replace.copyAllFile(sdkAnnotation, pkgAnnotation)
- app_value = "mi_%s" % value
- file_utils.replace_manifest_meta_data(prj_am_path, 'miGameAppId', app_value)
- if key == "APP_KEY":
- key_value = "mi_%s" % value
- file_utils.replace_manifest_meta_data(prj_am_path, 'miGameAppKey', key_value)
- pass
- # 圣本
- def ShengbensdkReplace(prj_path, key, value):
- printlog("specail replace : ShengbensdkReplace")
- if key == "AGENT":
- jsonFilePath = os.path.join(prj_path, 'assets', '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 = os.path.join(prj_path, 'assets', '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, key, value):
- printlog("specail replace : JinkuosdkReplace")
- printlog("path yy.properties :%s/assets/u8_developer_config.properties" % prj_path)
- file_utils.replace_assets_param("%s/assets/u8_developer_config.properties" % prj_path, key, value)
- pass
- def SamsungReplace(prj_path, key, value):
- printlog("specail replace : SamsungReplace")
- if key == "APPV_KEY":
- ptKey = value[0:99]
- pvData = value[99:len(value)]
- prj_am_path = os.path.join(prj_path, 'AndroidManifest.xml')
- printlog("prj_am_path: %s" % prj_am_path)
- # 替换app_key
- file_utils.replace_manifest_meta_data(prj_am_path, 'ptKey', ptKey)
- prj_param = "%s/assets/YyrhParam.cnf" % prj_path
- file_utils.replace_assets_param(prj_param, "pvData", pvData)
- pass
- def TTReplace(prj_path, key, value):
- printlog("specail replace : TTReplace")
- if key == "GAME_ID":
- file_utils.replace_assets_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, 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 == "screenOrientation":
- sdk_root_dir = contants.channel_sdk_path
- 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, 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 = os.path.join(prj_path, 'assets', '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, key, value):
- printlog("specail replace : Xiantu3011sdkReplace")
- if key == "GAME_ID":
- # 获取包名
- Replace.modifyRfileSmaliPath("3011", prj_path)
- pass
- def DDTsdkReplace(prj_path, key, value):
- printlog("specail replace : DDTsdkReplace")
- if key == "APP_ID":
- prj_am_path = os.path.join(prj_path, 'AndroidManifest.xml')
- splashactivity = "com.ddtsdk.ui.activity.MHPerActivity"
- game_activity = Replace.replace_game_launch_activity_attribute_to_default(splashactivity, prj_am_path)
- printlog("GAMEACTIVITY :%s" % game_activity)
- file_utils.replace_manifest_meta_data(prj_am_path, "mainAct", game_activity)
- if key == "agent":
- file_utils.replace_assets_param("%s/assets/ddt.properties" % prj_path, key, value)
- pass
- def QiyuReplace(prj_path, 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, key, value):
- if key == "APPID":
- prj_am_path = os.path.join(prj_path, 'AndroidManifest.xml')
- 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"]
- apk_tool.create_R_file(prj_path, 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, key, value):
- if key == "channelId":
- file_utils.replace_assets_param("%s/assets/dingdd.properties" % prj_path, 'channelId', value)
- if key == "adId":
- file_utils.replace_assets_param("%s/assets/dingdd.properties" % prj_path, 'adId', value)
- if key == "adFlag":
- file_utils.replace_assets_param("%s/assets/dingdd.properties" % prj_path, 'adFlag', value)
- pass
- def LZYXReplace(prj_path, key, value):
- if key == "ML_Channel":
- file_utils.replace_assets_param("%s/assets/mlgame_developer_config.properties" % prj_path, 'ML_Channel', value)
- if key == "ML_APPKEY":
- file_utils.replace_assets_param("%s/assets/mlgame_developer_config.properties" % prj_path, 'ML_APPKEY', value)
- pass
- def WSReplace(prj_path, 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, key, value):
- if key == "GID":
- printlog("path gameshaiApp.ini :%s/assets/gameshaiApp.ini" % prj_path)
- file_utils.replace_assets_param("%s/assets/gameshaiApp.ini" % prj_path, 'gid', value)
- if key == "PID":
- printlog("path gameshaiApp.ini :%s/assets/gameshaiApp.ini" % prj_path)
- file_utils.replace_assets_param("%s/assets/gameshaiApp.ini" % prj_path, 'pid', value)
- pass
- def YoudianReplace(prj_path, key, value):
- if key == "APPID":
- apk_tool.create_R_file(prj_path, ET.parse("%s/AndroidManifest.xml" % prj_path).getroot().attrib["package"])
- pass
- def Xiao7Replace(prj_path, key, value):
- if key == "APPKEY":
- Replace.modify_R_id_smali(prj_path, "/smali_classes2/com/smwl/smsdk")
- printlog(" Xiao7Replace begin replace game package v4 smali -------------------------------")
- sdk_root_dir = contants.channel_sdk_path
- 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):
- Replace.copyAllFile(sdkV4Path, pkgV4Path)
- pkgName = ET.parse("%s/AndroidManifest.xml" % prj_path).getroot().attrib["package"]
- apk_tool.create_R_file(prj_path, pkgName)
- pkgName = "android.support.constraint"
- apk_tool.create_R_file(prj_path, pkgName)
- prj_am_path = os.path.join(prj_path, 'AndroidManifest.xml')
- prj_param = "%s/assets/YyrhParam.cnf" % prj_path
- splashactivity = "com.yythird.sdk.SplashActivity"
- game_activity = Replace.replace_game_launch_activity_attribute_to_default(splashactivity, prj_am_path)
- file_utils.replace_assets_param(prj_param, "GAME_ACTIVITY", game_activity)
- printlog("xiaoqi GAME_ACTIVITY :%s" % game_activity)
- pass
- def NwanKaReplace(prj_path, key, value):
- if key == "channelId":
- file_utils.replace_assets_param("%s/assets/wk.properties" % prj_path, 'channelId', value)
- if key == "adId":
- file_utils.replace_assets_param("%s/assets/wk.properties" % prj_path, 'adId', value)
- if key == "adFlag":
- file_utils.replace_assets_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, 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)
- Replace.modify_R_id_smali(prj_path, "/smali/com/baidu/passport/sapi2")
- pass
- def ShenshouReplace(prj_path, key, value):
- if key == "BALANCENAME":
- prj_style_path = os.path.join(prj_path, 'res', 'values-v28', 'styles.xml')
- printlog("prj_style_path: %s" % prj_style_path)
- Replace.safeFileDelete(prj_style_path)
- pass
- def DaYanReplace(prj_path, 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, key, value):
- printlog("specail replace : DaLanReplace")
- prj_am_path = os.path.join(prj_path, 'AndroidManifest.xml')
- if key == "DL_APPID":
- splashactivity = "com.dalan.dl_assembly.SplashScreenActivity"
- game_activity = Replace.replace_game_launch_activity_attribute_to_default(splashactivity, prj_am_path)
- printlog("GAMEACTIVITY :%s" % game_activity)
- file_utils.replace_manifest_meta_data(prj_am_path, "dalan_union_main_activity", game_activity)
- pass
- def KSyxReplace(prj_path, key, value):
- if key == "kwai_app_id":
- file_utils.replace_assets_param("%s/assets/allin_developer_config.properties" % prj_path, 'kwai_app_id', value)
- printlog(" KSyxReplace begin replace game package v4 smali -------------------------------")
- sdk_root_dir = contants.channel_sdk_path
- 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):
- Replace.copyAllFile(sdkV4Path, pkgV4Path)
- prj_am_path = os.path.join(prj_path, 'AndroidManifest.xml')
- Replace.replace_manifest_allow_backup(prj_am_path)
- pass
- def LlhyReplace(prj_path, key, value):
- printlog("specail replace : LlhyReplace")
- if key == "LLHY_APP_ID":
- metaKey = "unityplayer.SkipPermissionsDialog"
- file_utils.replace_manifest_meta_data("%s/AndroidManifest.xml" % prj_path, metaKey,
- "true")
- pass
- def HnqsReplace(prj_path, key, value):
- printlog("specail replace : HnqsReplace")
- if key == "agent":
- file_utils.replace_assets_param("%s/assets/jmhy.properties" % prj_path, 'agent', value)
- metaKey = "unityplayer.SkipPermissionsDialog"
- file_utils.replace_manifest_meta_data("%s/AndroidManifest.xml" % prj_path, metaKey,
- "true")
- sdk_root_dir = contants.channel_sdk_path
- 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):
- Replace.copyAllFile(sdk_smali_dir, temp_old_smali_dir)
- pass
- def SogouReplace(prj_path, key, value):
- if key == "GID":
- printlog(" SogouReplace begin replace game package v4 smali -------------------------------")
- sdk_root_dir = contants.channel_sdk_path
- 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):
- Replace.copyAllFile(sdkV4Path, pkgV4Path)
- prj_am_path = os.path.join(prj_path, 'AndroidManifest.xml')
- Replace.replace_manifest_allow_backup(prj_am_path)
- pass
- def JinRiTouTiaoReplace(prj_path, key, value):
- jsonFilePath = os.path.join(prj_path, 'assets', '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'] = Replace.get_lauch_activity_name(prj_path)
- orientation = Replace.get_lauch_activity_screen_orientation(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()
- Replace.modify_R_id_smali(prj_path, "/smali/game_sdk/packers/rocket_sdk")
- Replace.modify_R_id_smali(prj_path, "/smali_classes2/game_sdk/packers/rocket_sdk")
- Replace.modify_R_id_smali(prj_path, "/smali/androidx/navigation/ui")
- Replace.modify_R_id_smali(prj_path, "/smali_classes3/android/support/design")
- Replace.modify_R_id_smali(prj_path, "/smali_classes3/android/support/v7/appcompat")
- sdk_root_dir = contants.channel_sdk_path
- 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):
- Replace.copyAllFile(sdkV4Path, pkgV4Path)
- modifyJrttV7ResIdSmali(prj_path)
- else:
- Replace.replace_json_value(jsonFilePath, "app", key, value)
- pass
- def modifyJrttV7ResIdSmali(prj_path):
- pkgV7AttrPath = "%s/smali_classes3/android/support/v7/appcompat/R$attr.smali" % prj_path
- if os.path.exists(pkgV7AttrPath):
- pkgV7StyleablePath = r"%s/smali_classes3/android/support/v7/appcompat/R\$styleable.smali" % prj_path
- data = ["windowActionBar:I", "windowActionBarOverlay:I", "windowActionModeOverlay:I",
- "windowFixedHeightMajor:I", "windowFixedHeightMinor:I", "windowFixedWidthMajor:I",
- "windowFixedWidthMinor:I", "windowMinWidthMajor:I", "windowMinWidthMinor:I", "windowNoTitle:I"]
- with open(pkgV7AttrPath, "r") as f:
- for line in f.readlines():
- if data[0] in line:
- value = line.split("=")
- replaceShell = 'sed -i "s/0x7f040245/%s/g" %s' % (value[1].strip(), pkgV7StyleablePath)
- os.system(replaceShell)
- elif data[1] in line:
- value = line.split("=")
- replaceShell = 'sed -i "s/0x7f040246/%s/g" %s' % (value[1].strip(), pkgV7StyleablePath)
- os.system(replaceShell)
- elif data[2] in line:
- value = line.split("=")
- replaceShell = 'sed -i "s/0x7f040247/%s/g" %s' % (value[1].strip(), pkgV7StyleablePath)
- os.system(replaceShell)
- elif data[3] in line:
- value = line.split("=")
- replaceShell = 'sed -i "s/0x7f040248/%s/g" %s' % (value[1].strip(), pkgV7StyleablePath)
- os.system(replaceShell)
- elif data[4] in line:
- value = line.split("=")
- replaceShell = 'sed -i "s/0x7f040249/%s/g" %s' % (value[1].strip(), pkgV7StyleablePath)
- os.system(replaceShell)
- elif data[5] in line:
- value = line.split("=")
- replaceShell = 'sed -i "s/0x7f04024a/%s/g" %s' % (value[1].strip(), pkgV7StyleablePath)
- os.system(replaceShell)
- elif data[6] in line:
- value = line.split("=")
- replaceShell = 'sed -i "s/0x7f04024b/%s/g" %s' % (value[1].strip(), pkgV7StyleablePath)
- os.system(replaceShell)
- elif data[7] in line:
- value = line.split("=")
- replaceShell = 'sed -i "s/0x7f04024c/%s/g" %s' % (value[1].strip(), pkgV7StyleablePath)
- os.system(replaceShell)
- elif data[8] in line:
- value = line.split("=")
- replaceShell = 'sed -i "s/0x7f04024d/%s/g" %s' % (value[1].strip(), pkgV7StyleablePath)
- os.system(replaceShell)
- elif data[9] in line:
- value = line.split("=")
- replaceShell = 'sed -i "s/0x7f04024e/%s/g" %s' % (value[1].strip(), pkgV7StyleablePath)
- os.system(replaceShell)
- pass
- def FengQiReplace(prj_path, key, value):
- if key == "channelId" or key == "adId" or key == "adFlag":
- # 替换fq.properties
- printlog("path fq.properties:%s/assets/fq.properties" % prj_path)
- file_utils.replace_assets_param("%s/assets/fq.properties" % prj_path, key, value)
- pass
- pass
- def BlueStackReplace(prj_path, 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, 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, key, value):
- if key == "CL_PID":
- file_utils.replace_assets_param("%s/assets/_cl_developer_config.properties" % prj_path, 'CL_PID', value)
- if key == "CL_KEY":
- file_utils.replace_assets_param("%s/assets/_cl_developer_config.properties" % prj_path, 'CL_KEY', value)
- if key == "CL_DEBUG_GD":
- file_utils.replace_assets_param("%s/assets/_cl_developer_config.properties" % prj_path, 'CL_DEBUG_GD', value)
- pass
- def JiuZiReplace(prj_path, key, value):
- printlog("specail replace : JiuZiReplace")
- if key == "gid":
- prj_param = "%s/assets/YyrhParam.cnf" % prj_path
- prj_am_path = os.path.join(prj_path, 'AndroidManifest.xml')
- splash_activity = "com.yythird.sdk.SplashActivity"
- game_activity = Replace.replace_game_launch_activity_attribute_to_default(splash_activity, prj_am_path)
- printlog("GAMEACTIVITY :%s" % game_activity)
- file_utils.replace_assets_param(prj_param, "GAMEACTIVITY", game_activity)
- pkgName = ET.parse(prj_am_path).getroot().attrib["package"]
- apk_tool.create_R_file(prj_path, pkgName)
- Replace.modify_R_id_smali(prj_path, "/smali/com/jzyx/sdk")
- pass
- def BingNiaoReplace(prj_path, key, value):
- printlog("specail replace : DaLanReplace")
- if key == "YH_GAME_ID":
- prj_am_path = os.path.join(prj_path, 'AndroidManifest.xml')
- splashactivity = "prj.iyinghun.platform.sdk.SplashScreenActivity"
- game_activity = Replace.replace_game_launch_activity_attribute_to_default(splashactivity, prj_am_path)
- printlog("GAMEACTIVITY :%s" % game_activity)
- file_utils.replace_manifest_meta_data(prj_am_path, "prj.chameleon.intent.main", game_activity)
- pass
- def BingChengReplace(prj_path, key, value):
- prj_am_path = os.path.join(prj_path, 'AndroidManifest.xml')
- ET.register_namespace('android', androidNS)
- 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, key, value):
- if key == "game_id":
- file_utils.replace_assets_param("%s/assets/suixin/suixin_sdk.ini" % prj_path, key, value)
- if key == "pid":
- file_utils.replace_assets_param("%s/assets/suixin/suixin_sdk.ini" % prj_path, key, value)
- if key == "is_land":
- file_utils.replace_assets_param("%s/assets/suixin/suixin_sdk.ini" % prj_path, key, value)
- pass
- def ShouQuReplace(prj_path, 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 = os.path.join(prj_path, 'AndroidManifest.xml')
- param_cnf = "%s/assets/YyrhParam.cnf" % prj_path
- splash_activity = "com.yythird.sdk.SplashActivity"
- game_activity = Replace.replace_game_launch_activity_attribute_to_default(splash_activity, manifest_path)
- file_utils.replace_assets_param(param_cnf, "GAMEACTIVITY", game_activity)
- printlog("GAMEACTIVITY :%s" % game_activity)
- def HaiNanQiJingReplace(prj_path, key, value):
- if key == "PACKAGE_TAG":
- sdk_root_dir = contants.channel_sdk_path
- 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):
- Replace.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, 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 = os.path.join(prj_path, 'AndroidManifest.xml')
- param_cnf = "%s/assets/YyrhParam.cnf" % prj_path
- splash_activity = "com.yythird.sdk.SplashActivity"
- game_activity = Replace.replace_game_launch_activity_attribute_to_default(splash_activity, manifest_path)
- file_utils.replace_assets_param(param_cnf, "GAMEACTIVITY", game_activity)
- sdk_root_dir = contants.channel_sdk_path
- 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):
- Replace.copyAllFile(sdkV4Path, pkgV4Path)
- pass
- def BaizeReplace(prj_path, key, value):
- if key == "APP_ID":
- prj_am_path = os.path.join(prj_path, 'AndroidManifest.xml')
- param_cnf = "%s/assets/YyrhParam.cnf" % prj_path
- splashactivity = "com.yythird.sdk.SplashActivity"
- game_activity = Replace.replace_game_launch_activity_attribute_to_default(splashactivity, prj_am_path)
- printlog("GAMEACTIVITY :%s" % game_activity)
- file_utils.replace_assets_param(param_cnf, "GAMEACTIVITY", game_activity)
- pass
- def YanXinReplace(prj_path, key, value):
- if key == "ProductCode":
- Replace.modifyRfileSmaliPath("yx", prj_path)
- pass
- def ZhangShangHuYuReplace(prj_path, key, value):
- file_utils.replace_assets_param("%s/assets/yy.properties" % prj_path, key, value)
- if key == "channelId":
- sdk_root_dir = contants.channel_sdk_path
- 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):
- Replace.copyAllFile(sdkV4Path, pkgV4Path)
- Replace.modify_R_id_smali(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):
- Replace.copyAllFile(sdkV4Path, pkgV4Path)
- Replace.modify_R_id_smali(prj_path, "/smali/com/zshy/zshysdk")
- Replace.modifyRfileSmaliPath("zshy", prj_path)
- pass
- def XiYouWangReplace(prj_path, key, value):
- file_utils.replace_assets_param("%s/assets/xy_developer_config.properties" % prj_path, key, value)
- if key == "XY_APP_ID":
- splash_activity = "com.xiyou.sdk.XiYouSplashActivity"
- manifest_path = os.path.join(prj_path, 'AndroidManifest.xml')
- game_activity = Replace.replace_game_launch_activity_attribute_to_default(splash_activity, manifest_path)
- file_utils.replace_manifest_meta_data(manifest_path, 'XY_GAME_MAIN_ACTIVITY_NAME', game_activity)
- sdk_root_dir = contants.channel_sdk_path
- 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):
- Replace.copyAllFile(sdkV4Path, pkgV4Path)
- prj_am_path = "%s/AndroidManifest.xml" % prj_path
- pkgName = ET.parse(prj_am_path).getroot().attrib["package"]
- apk_tool.create_R_file(prj_path, pkgName)
- pass
- def XunLeiReplace(prj_path, key, value):
- prj_am_path = os.path.join(prj_path, 'AndroidManifest.xml')
- ET.register_namespace('android', androidNS)
- 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, key, value):
- if key == "PRODUCT_CODE":
- Replace.modifyRfileSmaliPath("canlong", prj_path)
- pass
- def ShangHaiXiYuanReplace(prj_path, key, value):
- if key == "PACKAGE_TAG":
- sdk_root_dir = contants.channel_sdk_path
- 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):
- Replace.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, key, value):
- if key == "PACKAGE_TAG":
- sdk_root_dir = contants.channel_sdk_path
- 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):
- Replace.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):
- Replace.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, key, value):
- if key == "CHANNEL_ID":
- Replace.modify_R_id_smali(prj_path, "/smali/com/sdk/douyou")
- pass
- def QiPaReplace(prj_path, key, value):
- if key == "Super_Game_ID":
- splash_activity = "com.supersdk.application.MySplashActivity"
- prj_am_path = "%s/AndroidManifest.xml" % prj_path
- game_activity = Replace.replace_game_launch_activity_attribute_to_default(splash_activity, prj_am_path)
- tree = ET.parse(prj_am_path)
- activitys = tree.getroot().find("application").findall("activity")
- for activity in activitys:
- 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, key, value):
- jsonFilePath = os.path.join(prj_path, 'assets', 'config.json')
- if key == 'app_id':
- with open(jsonFilePath, 'r') as fp:
- jsonData = json.load(fp)
- jsonData["app_id"] = value
- jsonData['screen_orientation'] = Replace.get_lauch_activity_name(prj_path)
- orientation = Replace.get_lauch_activity_screen_orientation(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)
- Replace.del_file(pkgV4Path)
- prj_am_path = "%s/AndroidManifest.xml" % prj_path
- pkgName = ET.parse(prj_am_path).getroot().attrib["package"]
- apk_tool.create_R_file(prj_path, 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, key, value):
- xml_path = "%s/res/values/strings.xml" % prj_path
- Replace.replace_xml_value(xml_path, key, value)
- pass
- def QuxuanReplace(prj_path, key, value):
- if key == "app_id":
- prj_am_path = "%s/AndroidManifest.xml" % prj_path
- value = "Qdazzle_%s" % value
- file_utils.replace_manifest_meta_data(prj_am_path, "CommonSDK_AppID", value)
- Replace.modify_R_id_smali(prj_path, "/smali/com/qdazzle/sdk")
- if key == "app_key":
- prj_am_path = "%s/AndroidManifest.xml" % prj_path
- value = "Qdazzle_%s" % value
- file_utils.replace_manifest_meta_data(prj_am_path, "CommonSDK_AppKey", value)
- pass
- def MuMuReplace(prj_path, key, value):
- if key == "YOFUN_APP_ID":
- printlog("specail replace : MuMuReplace")
- splashactivity = "com.yythird.sdk.SplashActivity"
- prj_am_path = os.path.join(prj_path, 'AndroidManifest.xml')
- prj_param = "%s/assets/YyrhParam.cnf" % prj_path
- game_activity = Replace.replace_game_launch_activity_attribute_to_default(splashactivity, prj_am_path)
- printlog("GAMEACTIVITY :%s" % game_activity)
- file_utils.replace_assets_param(prj_param, "GAMEACTIVITY", game_activity)
- pass
- def HeFengReplace(prj_path, key, value):
- if key == "ver":
- printlog("specail replace : HeFengReplace")
- printlog("path hf.properties :%s/assets/hf.properties" % prj_path)
- file_utils.replace_assets_param("%s/assets/hf.properties" % prj_path, "agent", value)
- pass
- def ShengBenFuliReplace(prj_path, key, value):
- if key == "appid":
- printlog("specail replace : ShengBenFuliReplace")
- splash_activity = "com.fysdk.activity.FyGuideActivity"
- prj_am_path = os.path.join(prj_path, 'AndroidManifest.xml')
- ET.register_namespace('android', androidNS)
- 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, key, value):
- printlog("specail replace : MuXueReplace")
- file_utils.replace_assets_param("%s/assets/gs.properties" % prj_path, key, value)
- pass
- def QiYouReplace(prj_path, key, value):
- if key == "blgame_gameid":
- prj_am_path = os.path.join(prj_path, 'AndroidManifest.xml')
- pkgName = ET.parse(prj_am_path).getroot().attrib["package"]
- sdk_root_dir = contants.channel_sdk_path()
- 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):
- Replace.copyAllFile(sdkV4Path, pkgV4Path)
- apk_tool.create_R_file(prj_path, pkgName)
- Replace.modify_R_id_smali(prj_path, "/smali/android/support/v7/appcompat")
- Replace.modify_R_id_smali(prj_path, "/smali/android/support/design")
- Replace.modify_R_id_smali(prj_path, "/smali/android/support/v7/cardview")
- pass
- def YueWanReplace(prj_path, key, value):
- printlog("specail replace : YueWanReplace")
- if key == "J_GAME_ID":
- sdk_root_dir = contants.channel_sdk_path
- 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):
- Replace.copyAllFile(sdkV4Path, pkgV4Path)
- pass
- def ShengYueReplace(prj_path, key, value):
- printlog("specail replace : ShengYueReplace")
- os.path.join(prj_path, 'assets', 'UUConfig.json')
- jsonFilePath = os.path.join(prj_path, 'assets', 'UUConfig.json')
- Replace.replace_json_value(jsonFilePath, "", key, value)
- pass
- def JiZhiHuiReplace(prj_path, 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, key, value):
- file_utils.replace_assets_param("%s/assets/jmhy.properties" % prj_path, key, value)
- def DangLesdkReplace(prj_path, key, value):
- printlog("specail replace : DangLesdkReplace")
- if key == "RH_APPID":
- prj_am_path = os.path.join(prj_path, 'AndroidManifest.xml')
- splashactivity = "com.rhsdk.SplashActivity"
- game_activity = Replace.replace_game_launch_activity_attribute_to_default(splashactivity, prj_am_path)
- printlog("GAMEACTIVITY :%s" % game_activity)
- file_utils.replace_manifest_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, 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, key, value):
- if key == "JIANDAO_GAMEID":
- splashactivity = "com.yythird.sdk.SplashActivity"
- prj_param = "%s/assets/YyrhParam.cnf" % prj_path
- prj_am_path = os.path.join(prj_path, 'AndroidManifest.xml')
- game_activity = Replace.replace_game_launch_activity_attribute_to_default(splashactivity, prj_am_path)
- file_utils.replace_assets_param(prj_param, "GAME_ACTIVITY", game_activity)
- printlog("JianDaoReplace GAME_ACTIVITY :%s" % game_activity)
- sdk_root_dir = contants.channel_sdk_path
- 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):
- Replace.copyAllFile(sdkV4Path, pkgV4Path)
- def MengHuReplace(prj_path, key, value):
- if key == "appid":
- prj_am_path = "%s/AndroidManifest.xml" % prj_path
- pkgName = ET.parse(prj_am_path).getroot().attrib["package"]
- apk_tool.create_R_file(prj_path, pkgName)
- pass
- def MengHu2Replace(prj_path, key, value):
- if key == "appid":
- prj_am_path = "%s/AndroidManifest.xml" % prj_path
- pkgName = ET.parse(prj_am_path).getroot().attrib["package"]
- apk_tool.create_R_file(prj_path, pkgName)
- def MengHu3Replace(prj_path, 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, key, value):
- if key == "appid":
- splashactivity = "com.yythird.sdk.SplashActivity"
- prj_param = "%s/assets/YyrhParam.cnf" % prj_path
- prj_am_path = os.path.join(prj_path, 'AndroidManifest.xml')
- game_activity = Replace.replace_game_launch_activity_attribute_to_default(splashactivity, prj_am_path)
- file_utils.replace_assets_param(prj_param, "GAME_ACTIVITY", game_activity)
- printlog("baUReplace GAME_ACTIVITY :%s" % game_activity)
- pass
- def ZhongXingReplace(prj_path, 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
- def YouXiYouReplace(prj_path, key, value):
- jsonFilePath = os.path.join(prj_path, 'assets', 'youxiyougameinfo.txt')
- printlog('replace YouXiYouReplace youxiyougameinfo.txt ,value:%s' % key)
- with open(jsonFilePath, 'r') as fp:
- jsonData = json.load(fp)
- jsonData[key] = value
- newJsonData = jsonData
- fp.close()
- with open(jsonFilePath, 'w') as fp:
- json.dump(newJsonData, fp, ensure_ascii=False)
- fp.close()
- pass
- def SiLangReplace(prj_path, key, value):
- if key == "SL_PARAMS_channelID":
- Replace.modify_R_id_smali(prj_path, "/smali/com/silang/slsdk")
- printlog(" SiLangReplace begin replace game package v4 smali -------------------------------")
- sdk_root_dir = contants.channel_sdk_path
- pkgV4Path = "%s/smali/android/support/v4" % prj_path
- printlog("pkgV4Path:%s" % pkgV4Path)
- sdkV4Path = "%s/sl/sl/smali/android/support/v4" % sdk_root_dir
- printlog("sdkV4Path:%s" % sdkV4Path)
- if os.path.exists(pkgV4Path):
- Replace.copyAllFile(sdkV4Path, pkgV4Path)
- pass
- specialReplace = {
- "lenovo": LenovoReplace,
- "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,
- "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,
- "yxy": YouXiYouReplace,
- "sl": SiLangReplace
- }
- def getSpecilReplace(sdk_name):
- if sdk_name in specialReplace:
- return specialReplace[sdk_name]
- else:
- return None
- pass
|