ChannelReplace.py 61 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891892893894895896897898899900901902903904905906907908909910911912913914915916917918919920921922923924925926927928929930931932933934935936937938939940941942943944945946947948949950951952953954955956957958959960961962963964965966967968969970971972973974975976977978979980981982983984985986987988989990991992993994995996997998999100010011002100310041005100610071008100910101011101210131014101510161017101810191020102110221023102410251026102710281029103010311032103310341035103610371038103910401041104210431044104510461047104810491050105110521053105410551056105710581059106010611062106310641065106610671068106910701071107210731074107510761077107810791080108110821083108410851086108710881089109010911092109310941095109610971098109911001101110211031104110511061107110811091110111111121113111411151116111711181119112011211122112311241125112611271128112911301131113211331134113511361137113811391140114111421143114411451146114711481149115011511152115311541155115611571158115911601161116211631164116511661167116811691170117111721173117411751176117711781179118011811182118311841185118611871188118911901191119211931194119511961197119811991200120112021203120412051206120712081209121012111212121312141215121612171218121912201221122212231224122512261227122812291230123112321233123412351236123712381239124012411242124312441245124612471248124912501251125212531254125512561257125812591260126112621263126412651266126712681269127012711272127312741275127612771278127912801281128212831284128512861287128812891290129112921293129412951296129712981299130013011302130313041305130613071308130913101311131213131314131513161317131813191320132113221323132413251326132713281329133013311332133313341335133613371338133913401341134213431344134513461347134813491350135113521353135413551356135713581359136013611362136313641365136613671368136913701371137213731374137513761377137813791380138113821383138413851386138713881389139013911392139313941395139613971398139914001401140214031404140514061407140814091410141114121413141414151416141714181419142014211422142314241425142614271428142914301431143214331434143514361437143814391440144114421443144414451446144714481449145014511452145314541455145614571458145914601461146214631464146514661467146814691470147114721473147414751476147714781479148014811482148314841485148614871488148914901491149214931494149514961497149814991500150115021503150415051506150715081509151015111512151315141515151615171518
  1. # -*-coding:utf-8-*-
  2. import os
  3. import xml.etree.ElementTree as ET
  4. import re
  5. import hashlib
  6. import shutil
  7. import json
  8. from V1.PrintLog import printlog
  9. from V1 import Contants, File, GeneralModifySmali, Replace, Aapt_Util, apk_utils
  10. from xml.etree.ElementTree import Element
  11. # 联想
  12. def LenovoReplace(prj_path, dir_split, key, value):
  13. if (key == "OPENAPPID"):
  14. # 替换联想id
  15. replaceLeonovoIdShell = 'sed -i "1,\\$s/lenovo_id/%s/g" %s/AndroidManifest.xml ' % (value, prj_path)
  16. printlog("replaceLeonovoIdShell: %s" % replaceLeonovoIdShell)
  17. os.system(replaceLeonovoIdShell)
  18. manifestRootExt = r'<application android:networkSecurityConfig="@xml/network_security_config"'
  19. replacePkgNameShell = "sed -i 's!<application!%s!g' %s/AndroidManifest.xml" % (manifestRootExt, prj_path)
  20. printlog("LenovoReplace replace add application root point shell: %s" % replacePkgNameShell)
  21. os.system(replacePkgNameShell)
  22. pass
  23. # 豌豆荚
  24. def WandoujiaReplace(prj_path, dir_split, key, value):
  25. printlog("specail replace : wdj")
  26. if (key == "APPKEY_ID"):
  27. prj_am_path = prj_path + dir_split + "AndroidManifest.xml"
  28. printlog("prj_am_path :%s" % prj_am_path)
  29. lines = open(prj_am_path).readlines()
  30. fp = open(prj_am_path, 'w')
  31. for s in lines:
  32. if (s.find("Wandoujia-PaySdk-") != -1):
  33. printlog("replace Wandoujia-PaySdk-%s" % value)
  34. s = re.sub('Wandoujia-PaySdk-.*\"', 'Wandoujia-PaySdk-' + value + '\"', s)
  35. fp.write(s)
  36. fp.close()
  37. pass
  38. # 虫虫
  39. def ChongchongReplace(prj_path, dir_split, key, value):
  40. printlog("specail replace : Chongchong")
  41. if (key == "app_id"):
  42. prj_am_path = prj_path + dir_split + "AndroidManifest.xml"
  43. printlog("prj_am_path :%s" % prj_am_path)
  44. lines = open(prj_am_path).readlines()
  45. fp = open(prj_am_path, 'w')
  46. for s in lines:
  47. if (s.find("qqPay") != -1):
  48. printlog("replace qqPay:%s" % value)
  49. s = re.sub('qqPay.*\"', 'qqPay' + value + '\"', s);
  50. fp.write(s)
  51. fp.close()
  52. # 360
  53. def QihuReplace(prj_path, dir_split, key, value):
  54. global appkey
  55. printlog("specail replace : 360")
  56. if (key == "QHOPENSDK_APPKEY"):
  57. replacePkgNameShell = 'sed -i "s/qihu_appkey/%s/g" %s/AndroidManifest.xml' % (value, prj_path)
  58. printlog("QihuReplace replace qihu_appkey shell: %s" % replacePkgNameShell)
  59. os.system(replacePkgNameShell)
  60. if (key == "QHOPENSDK_APPSECRET"):
  61. prj_param = "%s/assets/YyrhParam.cnf" % prj_path
  62. prj_am_path = "%s/AndroidManifest.xml" % prj_path
  63. appsecret = value
  64. metadatas = ET.parse(prj_am_path).getroot().find("application").findall("meta-data")
  65. for meta in metadatas:
  66. if (meta.attrib["{http://schemas.android.com/apk/res/android}name"] == "QHOPENSDK_APPKEY"):
  67. appkey = meta.attrib["{http://schemas.android.com/apk/res/android}value"]
  68. printlog("prj_am_path:%s" % prj_am_path)
  69. m = hashlib.md5()
  70. printlog("appsecret :%s" % appsecret)
  71. printlog("appkey: %s" % appkey)
  72. md5value = "%s#%s" % (appsecret, appkey)
  73. printlog("md5value :%s" % md5value)
  74. m.update(md5value.encode('utf-8'))
  75. privatekey = m.hexdigest()
  76. printlog("privatekey:%s" % privatekey)
  77. Replace.replaceAM_Meta_data(prj_am_path, 'QHOPENSDK_PRIVATEKEY', privatekey)
  78. manifestRootExt = r'<application android:networkSecurityConfig="@xml/network_security_config"'
  79. replacePkgNameShell = "sed -i 's!<application!%s!g' %s/AndroidManifest.xml" % (manifestRootExt, prj_path)
  80. printlog("qihu360 replace add application root point shell: %s" % replacePkgNameShell)
  81. os.system(replacePkgNameShell)
  82. pass
  83. def OppoReplace(prj_path, dir_split, key, value):
  84. printlog("specail replace : oppo")
  85. if (key == "APPKEY"):
  86. prj_am_path = prj_path + dir_split + "AndroidManifest.xml"
  87. printlog("prj_am_path: %s" % prj_am_path)
  88. # 替换app_key
  89. Replace.replaceAM_Meta_data(prj_am_path, 'app_key', value)
  90. printlog("appkey: %s" % value)
  91. pass
  92. def OppoMlReplace(prj_path, dir_split, key, value):
  93. printlog("specail replace : oppoml")
  94. if (key == "APPKEY"):
  95. prj_am_path = prj_path + dir_split + "AndroidManifest.xml"
  96. printlog("prj_am_path: %s" % prj_am_path)
  97. # 替换app_key
  98. Replace.replaceAM_Meta_data(prj_am_path, 'app_key', value)
  99. printlog("appkey: %s" % value)
  100. pass
  101. def downjoyReplace(prj_path, dir_split, key, value):
  102. printlog("specail replace : downjoy")
  103. if (key == "APP_ID"):
  104. splash_activity = "com.downjoy.activity.SdkLoadActivity"
  105. prj_am_path = "%s/AndroidManifest.xml" % prj_path
  106. game_activity = Replace.replaceGameActivityLaunchAttribute(splash_activity, prj_am_path)
  107. printlog(game_activity)
  108. Replace.replaceAM_Meta_data(prj_am_path, 'CP_ACTIVITY', game_activity)
  109. lines = open(prj_am_path).readlines()
  110. fp = open(prj_am_path, 'w')
  111. for s in lines:
  112. if (s.find("dcnngsdk") != -1):
  113. printlog("replace dcnngsdk:%s" % value)
  114. s = re.sub('dcnngsdk.*\"', 'dcnngsdk' + value + '\"', s)
  115. fp.write(s)
  116. fp.close()
  117. pass
  118. def YYBReplace(prj_path, dir_split, key, value):
  119. if (key == "QQ_APP_ID"):
  120. # 替换qq app id
  121. replaceQQAPPIDShell = 'sed -i "s/qq_app_id/%s/g" %s/AndroidManifest.xml' % (value, prj_path)
  122. printlog("yingyongbao qq app id shell: %s" % replaceQQAPPIDShell)
  123. os.system(replaceQQAPPIDShell)
  124. # 替换ysdkconf.ini
  125. printlog("path ysdkconfig.ini:%s/assets/ysdkconf.ini" % prj_path)
  126. Replace.replaceAssets_Param("%s/assets/ysdkconf.ini" % prj_path, key, value)
  127. Replace.replaceAssets_Param("%s/assets/ysdkconf.ini" % prj_path, "OFFER_ID", value)
  128. prj_am_path = "%s/AndroidManifest.xml" % prj_path
  129. game_activity = Replace.getLauchActivityName(prj_path)
  130. Replace.replaceAM_Meta_data(prj_am_path, 'MAIN_ACTIVITY', game_activity)
  131. if (key == "WX_APP_ID"):
  132. replaceWXAPPIDShell = 'sed -i "s/wx_app_id/%s/g" %s/AndroidManifest.xml' % (value, prj_path)
  133. printlog("yingyongbao wx app id shell: %s" % replaceWXAPPIDShell)
  134. os.system(replaceWXAPPIDShell)
  135. # 替换ysdkconf.ini
  136. Replace.replaceAssets_Param("%s/assets/ysdkconf.ini" % prj_path, key, value)
  137. if (key == "IS_SAND_BOX"):
  138. ysdk_sand_url = "https://ysdktest.qq.com"
  139. ysdk_online_url = "https://ysdk.qq.com"
  140. if value == "1":
  141. ysdk_url = ysdk_sand_url
  142. else:
  143. ysdk_url = ysdk_online_url
  144. Replace.replaceAssets_Param("%s/assets/ysdkconf.ini" % prj_path, "YSDK_URL", ysdk_url)
  145. pass
  146. def HuaweiReplace(prj_path, dir_split, key, value):
  147. if (key == "APP_ID"):
  148. replaceAppidShell = '/bin/sed -i "s/APP_ID/%s/g" %s/AndroidManifest.xml' % (value, prj_path)
  149. printlog("huawei replace appid shell: %s" % replaceAppidShell)
  150. os.system(replaceAppidShell)
  151. GeneralModifySmali.modifyRfileIdSmali(prj_path, "/smali/com/huawei/android/hms/app")
  152. GeneralModifySmali.modifyRfileIdSmali(prj_path, "/smali/com/huawei/android/hms/game")
  153. GeneralModifySmali.modifyRfileIdSmali(prj_path, "/smali/com/huawei/hms/base/hmscoreinstaller")
  154. if (key == "PAY_ID"):
  155. replacePayidShell = '/bin/sed -i "s/PAY_ID/%s/g" %s/AndroidManifest.xml' % (value, prj_path)
  156. printlog("huawei replace payid shell: %s" % replacePayidShell)
  157. os.system(replacePayidShell)
  158. pass
  159. def AnzhiReplace(prj_path, dir_split, key, value):
  160. printlog("specail replace : anzhi")
  161. prj_am_path = "%s/AndroidManifest.xml" % prj_path
  162. pkgName = ET.parse(prj_am_path).getroot().attrib["package"]
  163. if (key == "APP_KEY"):
  164. lines = open(prj_am_path).readlines()
  165. fp = open(prj_am_path, 'w')
  166. for s in lines:
  167. if (s.find("packagename") != -1):
  168. s = re.sub('packagename', pkgName, s);
  169. fp.write(s)
  170. fp.close()
  171. pass
  172. def GuopanReplace(prj_path, dir_split, key, value):
  173. printlog("specail replace : guopan")
  174. prj_am_path = "%s/AndroidManifest.xml" % prj_path
  175. pkgName = ET.parse(prj_am_path).getroot().attrib["package"]
  176. if (key == "APP_ID"):
  177. lines = open(prj_am_path).readlines()
  178. fp = open(prj_am_path, 'w')
  179. for s in lines:
  180. if (s.find("gp_packagename") != -1):
  181. s = re.sub('gp_packagename', pkgName + ".StubContentProvider", s);
  182. fp.write(s)
  183. fp.close()
  184. pass
  185. def LeshiReplace(prj_path, dir_split, key, value):
  186. printlog("specail replace : leshi")
  187. prj_am_path = prj_path + dir_split + "AndroidManifest.xml"
  188. if (key == "LEPAY_APPID"):
  189. Replace.replaceAM_Meta_data(prj_am_path, 'lepay_appid', value)
  190. if (key == "LEPAY_APPKEY"):
  191. Replace.replaceAM_Meta_data(prj_am_path, 'lepay_appkey', value)
  192. pass
  193. def QuickReplace(prj_path, dir_split, key, value):
  194. printlog("specail replace : Quick")
  195. if (key == "PRODUCT_CODE"):
  196. splashactivity = "com.yythird.sdk.SplashActivity"
  197. prj_am_path = prj_path + dir_split + "AndroidManifest.xml"
  198. prj_param = "%s/assets/YyrhParam.cnf" % prj_path
  199. game_activity = Replace.replaceGameActivityLaunchAttribute(splashactivity, prj_am_path)
  200. printlog("GAMEACTIVITY :%s" % game_activity)
  201. Replace.replaceAssets_Param(prj_param, "GAMEACTIVITY", game_activity)
  202. if (key == "SDK_TYPE"):
  203. printlog("merge qitian Smali")
  204. if value == "qitian":
  205. printlog("merge qitian Smali")
  206. sdk_root_dir = apk_utils.getCutSdkRootHome()
  207. ret = 0
  208. ret = ret | File.mergeDir("%s/quick/quick/qitian_smali" % sdk_root_dir, "%s/smali" % prj_path)
  209. pass
  210. def LjsdkReplace(prj_path, dir_split, key, value):
  211. printlog("specail replace : LjsdkReplace")
  212. if (key == "XMGAME_PRODUCT_CODE"):
  213. prj_param = "%s/assets/param.cnf" % prj_path
  214. prj_am_path = prj_path + dir_split + "AndroidManifest.xml"
  215. splashactivity = "third.sdk.SplashActivity"
  216. game_activity = Replace.replaceGameActivityLaunchAttribute(splashactivity, prj_am_path)
  217. printlog("GAMEACTIVITY :%s" % game_activity)
  218. Replace.replaceAssets_Param(prj_param, "GAMEACTIVITY", game_activity)
  219. pkgName = ET.parse(prj_am_path).getroot().attrib["package"]
  220. pkgLine = 'package="' + pkgName + '"'
  221. printlog("pkgValue :%s" % pkgLine)
  222. addPkgLine = ' xmlns:tools="http://schemas.android.com/tools" '
  223. addPerLine = ' tools:ignore="ProtectedPermissions" '
  224. permissionName = 'android:name="android.permission.PACKAGE_USAGE_STATS"'
  225. lines = open(prj_am_path).readlines()
  226. fp = open(prj_am_path, 'w')
  227. for s in lines:
  228. if (s.find(pkgLine) != -1):
  229. s = re.sub(pkgLine, pkgLine + addPkgLine, s);
  230. printlog("pkgLine :%s" % s)
  231. if (s.find(permissionName) != -1):
  232. s = re.sub(permissionName, permissionName + addPerLine, s);
  233. printlog("permissionName :%s" % s)
  234. fp.write(s)
  235. fp.close()
  236. pass
  237. def UcsdkReplace(prj_path, dir_split, key, value):
  238. printlog("specail replace : UcsdkReplace")
  239. if (key == "GAME_ID"):
  240. replaceGidShell = 'sed -i "s/GAME_ID/%s/g" %s/AndroidManifest.xml' % (value, prj_path)
  241. printlog("uc replace GAME_ID shell: %s" % replaceGidShell)
  242. os.system(replaceGidShell)
  243. # GeneralModifySmali.modifyLauchSmali(prj_path)
  244. pass
  245. def XiaomisdkReplace(prj_path, dir_split, key, value):
  246. printlog("specail replace : XiaomisdkReplace")
  247. if (key == "APP_ID"):
  248. # 获取包名
  249. sdk_root_dir = apk_utils.getCutSdkRootHome()
  250. Replace.modifyRfileSmaliPath("xiaomi", prj_path);
  251. printlog(" xiaomi begin replace game package v4 smali -------------------------------")
  252. pkgV4Path = "%s/smali/android/support/v4" % prj_path
  253. printlog("pkgV4Path:%s" % pkgV4Path)
  254. sdkV4Path = "%s/xiaomi/xiaomi/smali/android/support/v4" % sdk_root_dir
  255. printlog("sdkV4Path:%s" % sdkV4Path)
  256. if os.path.exists(pkgV4Path):
  257. File.copyAllFile(sdkV4Path, pkgV4Path)
  258. pkgAnnotation = "%s/smali/android/support/annotation" % prj_path
  259. printlog("pkgV4Path:%s" % pkgAnnotation)
  260. sdkAnnotation = "%s/xiaomi/xiaomi/smali/android/support/annotation" % sdk_root_dir
  261. if os.path.exists(pkgAnnotation):
  262. File.copyAllFile(sdkAnnotation, pkgAnnotation)
  263. pass
  264. # 百度
  265. def BaiduReplace(prj_path, dir_split, key, value):
  266. printlog("specail replace : baidu")
  267. if (key == "APP_ID"):
  268. GeneralModifySmali.modifyLauchSmali(prj_path)
  269. pass
  270. # 圣本
  271. def ShengbensdkReplace(prj_path, dir_split, key, value):
  272. printlog("specail replace : ShengbensdkReplace")
  273. if (key == "AGENT"):
  274. jsonFilePath = prj_path + dir_split + "assets" + dir_split + "hnsb_config.json"
  275. printlog("path hnsb_config.json :%s" % jsonFilePath)
  276. with open(jsonFilePath, 'r') as fp:
  277. jsonData = json.load(fp)
  278. jsonData['sdk']["ver"] = value
  279. newJsonData = jsonData
  280. fp.close()
  281. with open(jsonFilePath, 'w') as fp:
  282. json.dump(newJsonData, fp)
  283. fp.close()
  284. if (key == "APP_ID"):
  285. jsonFilePath = prj_path + dir_split + "assets" + dir_split + "hnsb_config.json"
  286. with open(jsonFilePath, 'r') as fp:
  287. jsonData = json.load(fp)
  288. jsonData['sdk']["appid"] = value
  289. newJsonData = jsonData
  290. fp.close()
  291. with open(jsonFilePath, 'w') as fp:
  292. json.dump(newJsonData, fp)
  293. fp.close()
  294. pass
  295. def JinkuosdkReplace(prj_path, dir_split, key, value):
  296. printlog("specail replace : JinkuosdkReplace")
  297. printlog("path yy.properties :%s/assets/u8_developer_config.properties" % prj_path)
  298. Replace.replaceAssets_Param("%s/assets/u8_developer_config.properties" % prj_path, key, value)
  299. pass
  300. def HdhdsdkReplace(prj_path, dir_split, key, value):
  301. printlog("specail replace : HdhdsdkReplace")
  302. if (key == "APP_ID"):
  303. GeneralModifySmali.modifyLauchSmali(prj_path)
  304. pass
  305. def SamsungReplace(prj_path, dir_split, key, value):
  306. printlog("specail replace : SamsungReplace")
  307. if (key == "APPV_KEY"):
  308. ptKey = value[0:99]
  309. pvData = value[99:len(value)]
  310. prj_am_path = prj_path + dir_split + "AndroidManifest.xml"
  311. printlog("prj_am_path: %s" % prj_am_path)
  312. # 替换app_key
  313. Replace.replaceAM_Meta_data(prj_am_path, 'ptKey', ptKey)
  314. prj_param = "%s/assets/YyrhParam.cnf" % prj_path
  315. Replace.replaceAssets_Param(prj_param, "pvData", pvData)
  316. pass
  317. def TTReplace(prj_path, dir_split, key, value):
  318. printlog("specail replace : TTReplace")
  319. if (key == "GAME_ID"):
  320. Replace.replaceAssets_Param("%s/assets/tt_game_sdk_opt.properties" % prj_path, "gameId", value)
  321. if (key == "GAME_KEY"):
  322. replaceKeyShell = 'sed -i "s/@WSX3edc/%s/g" %s/assets/TTGameSDKConfig.cfg' % (value, prj_path)
  323. printlog("replaceMainLineShell:%s" % replaceKeyShell)
  324. os.system(replaceKeyShell)
  325. pass
  326. def YXFReplace(prj_path, dir_split, key, value):
  327. printlog("specail replace : YXFReplace")
  328. if (key == "YGAPPID"):
  329. replacePkgNameShell = '/bin/sed -i "1,\\$s/YXFAPPID/%s/g" %s/AndroidManifest.xml' % (value, prj_path)
  330. printlog("replacePkgNameShell:%s" % replacePkgNameShell)
  331. os.system(replacePkgNameShell)
  332. manifestRootExt = r'<application android:usesCleartextTraffic="true"'
  333. replacePkgNameShell = "sed -i 's!<application!%s!g' %s/AndroidManifest.xml" % (manifestRootExt, prj_path)
  334. printlog("youxiFan replace add application root point shell: %s" % replacePkgNameShell)
  335. os.system(replacePkgNameShell)
  336. if (key == "IS_SPLASH"):
  337. if (value == "0"):
  338. GeneralModifySmali.modifyYXFLauchSmali(prj_path)
  339. if (key == "screenOrientation"):
  340. sdk_root_dir = apk_utils.getCutSdkRootHome()
  341. if (value == "screenOrientation:0"):
  342. splash = "%s/yxf/yxf/extension/sp_landscape.png" % sdk_root_dir
  343. apkres = "%s/res/drawable/crash_screen.png" % prj_path
  344. shutil.copy(splash, apkres)
  345. if (value == "screenOrientation:1"):
  346. splash = "%s/yxf/yxf/extension/sp_portrait.png" % sdk_root_dir
  347. apkres = "%s/res/drawable/crash_screen.png" % prj_path
  348. shutil.copy(splash, apkres)
  349. pass
  350. def VivosdkReplace(prj_path, dir_split, key, value):
  351. printlog("specail replace : VivosdkReplace")
  352. if (key == "APP_ID"):
  353. printlog("path supplierconfig.json :%s/assets/supplierconfig.json" % prj_path)
  354. replaceConfigShell = '/bin/sed -i "1,\\$s/APP_ID/%s/g" %s/assets/supplierconfig.json' % (value, prj_path)
  355. printlog("replaceConfigShell APP_ID:%s" % replaceConfigShell)
  356. os.system(replaceConfigShell)
  357. jsonFilePath = prj_path + dir_split + "assets" + dir_split + "supplierconfig.json"
  358. printlog("path supplierconfig.json :%s" % jsonFilePath)
  359. with open(jsonFilePath, 'r') as fp:
  360. jsonData = json.load(fp)
  361. jsonData['supplier']["vivo"]["appid"] = value
  362. newJsonData = jsonData
  363. fp.close()
  364. with open(jsonFilePath, 'w') as fp:
  365. json.dump(newJsonData, fp)
  366. fp.close()
  367. pass
  368. def XTsdkReplace(prj_path, dir_split, key, value):
  369. printlog("specail replace : Xiantu3011sdkReplace")
  370. if (key == "GAME_ID"):
  371. # 获取包名
  372. Replace.modifyRfileSmaliPath("3011", prj_path);
  373. pass
  374. def DDTsdkReplace(prj_path, dir_split, key, value):
  375. printlog("specail replace : DDTsdkReplace")
  376. if (key == "APP_ID"):
  377. prj_am_path = prj_path + dir_split + "AndroidManifest.xml"
  378. splashactivity = "com.ddtsdk.ui.activity.MHPerActivity"
  379. game_activity = Replace.replaceGameActivityLaunchAttribute(splashactivity, prj_am_path)
  380. printlog("GAMEACTIVITY :%s" % game_activity)
  381. Replace.replaceAM_Meta_data(prj_am_path, "mainAct", game_activity)
  382. if (key == "agent"):
  383. Replace.replaceAssets_Param("%s/assets/ddt.properties" % prj_path, key, value)
  384. pass
  385. def QiyuReplace(prj_path, dir_split, key, value):
  386. if (key == "APP_ID"):
  387. manifestRootExt = r'<application android:usesCleartextTraffic="true"'
  388. replacePkgNameShell = "sed -i 's!<application!%s!g' %s/AndroidManifest.xml" % (manifestRootExt, prj_path)
  389. printlog("QiyuReplace add application root point shell: %s" % replacePkgNameShell)
  390. os.system(replacePkgNameShell)
  391. pass
  392. def WankaReplace(prj_path, dir_split, key, value):
  393. if (key == "APPID"):
  394. prj_am_path = prj_path + dir_split + "AndroidManifest.xml"
  395. namespace = '{http://schemas.android.com/apk/res/android}'
  396. manifestRootExt = r'<application xmlns:tools="http://schemas.android.com/tools" tools:replace="android:theme,android:name"'
  397. replacePkgNameShell = "sed -i 's!<application!%s!g' %s/AndroidManifest.xml" % (manifestRootExt, prj_path)
  398. printlog("WankaReplace replace add application root point shell: %s" % replacePkgNameShell)
  399. os.system(replacePkgNameShell)
  400. tree = ET.parse(prj_am_path)
  401. activitys = tree.getroot().find("application").findall("activity")
  402. for activity in activitys:
  403. filters = activity.findall('intent-filter')
  404. for filter in filters:
  405. categorys = filter.findall('category')
  406. for category in categorys:
  407. categoryname = category.attrib[namespace + "name"]
  408. if (categoryname == "android.intent.category.LAUNCHER"):
  409. element = Element('intent-filter')
  410. el1 = Element('action android:name="android.intent.action.VIEW"')
  411. el2 = Element('category android:name="android.intent.category.DEFAULT"')
  412. el3 = Element('category android:name="android.intent.category.BROWSABLE"')
  413. el4_value = 'data android:scheme="app%s"' % value
  414. el4 = Element(el4_value)
  415. element.append(el1)
  416. element.append(el2)
  417. element.append(el3)
  418. element.append(el4)
  419. activity.append(element)
  420. activity.set(namespace + 'launchMode', "singleTask")
  421. tree.write(prj_am_path, "UTF-8", xml_declaration=True, method='xml')
  422. pkgName = ET.parse(prj_am_path).getroot().attrib["package"]
  423. Aapt_Util.createRFile(prj_path, False, pkgName)
  424. sdkRpath = "android/support/v7/appcompat"
  425. pkgRpath = pkgName.replace(".", "/")
  426. sdkAbsoluteRpath = "%s/smali/%s" % (prj_path, sdkRpath)
  427. pkgAbsoluteRpath = "%s/smali/%s" % (prj_path, pkgRpath)
  428. Replace.createRFile2Sdk(pkgAbsoluteRpath, sdkAbsoluteRpath, pkgRpath, sdkRpath)
  429. pass
  430. def DDDReplace(prj_path, dir_split, key, value):
  431. if (key == "channelId"):
  432. Replace.replaceAssets_Param("%s/assets/dingdd.properties" % prj_path, 'channelId', value)
  433. if (key == "adId"):
  434. Replace.replaceAssets_Param("%s/assets/dingdd.properties" % prj_path, 'adId', value)
  435. if (key == "adFlag"):
  436. Replace.replaceAssets_Param("%s/assets/dingdd.properties" % prj_path, 'adFlag', value)
  437. pass
  438. def LZYXReplace(prj_path, dir_split, key, value):
  439. if (key == "ML_Channel"):
  440. Replace.replaceAssets_Param("%s/assets/mlgame_developer_config.properties" % prj_path, 'ML_Channel', value)
  441. if (key == "ML_APPKEY"):
  442. Replace.replaceAssets_Param("%s/assets/mlgame_developer_config.properties" % prj_path, 'ML_APPKEY', value)
  443. pass
  444. def WSReplace(prj_path, dir_split, key, value):
  445. if (key == "HS_APPID"):
  446. manifestRootExt = r'<application android:networkSecurityConfig="@xml/huosdk_network_security_config"'
  447. replacePkgNameShell = "sed -i 's!<application!%s!g' %s/AndroidManifest.xml" % (manifestRootExt, prj_path)
  448. printlog("qihu360 replace add application root point shell: %s" % replacePkgNameShell)
  449. os.system(replacePkgNameShell)
  450. pass
  451. def XBReplace(prj_path, dir_split, key, value):
  452. if (key == "GID"):
  453. printlog("path gameshaiApp.ini :%s/assets/gameshaiApp.ini" % prj_path)
  454. Replace.replaceAssets_Param("%s/assets/gameshaiApp.ini" % prj_path, 'gid', value)
  455. if (key == "PID"):
  456. printlog("path gameshaiApp.ini :%s/assets/gameshaiApp.ini" % prj_path)
  457. Replace.replaceAssets_Param("%s/assets/gameshaiApp.ini" % prj_path, 'pid', value)
  458. pass
  459. def YoudianReplace(prj_path, dir_split, key, value):
  460. if (key == "APPID"):
  461. apkPkgDir = ET.parse("%s/AndroidManifest.xml" % prj_path).getroot().attrib["package"].replace(".", "/")
  462. apkRfilePath = "%s/smali/%s" % (prj_path, apkPkgDir)
  463. Replace.modifyRfileSmaliPath("youdian", prj_path);
  464. publicXml = "%s/res/values/public.xml" % prj_path
  465. sdk_jar_dir = apk_utils.getToolsJarHome()
  466. jarPath = "%s/MergeSamli.jar" % sdk_jar_dir
  467. javaMerCm = 'java -jar %s %s %s' % (jarPath, publicXml, apkRfilePath)
  468. printlog("javaMerCm:%s" % javaMerCm)
  469. os.system(javaMerCm)
  470. pass
  471. def Xiao7Replace(prj_path, dir_split, key, value):
  472. if (key == "APPKEY"):
  473. apkRfilePath = "%s/smali_classes2/com/smwl/smsdk" % prj_path
  474. publicXml = "%s/res/values/public.xml" % prj_path
  475. sdk_jar_dir = apk_utils.getToolsJarHome()
  476. jarPath = "%s/MergeSamli.jar" % sdk_jar_dir
  477. javaMerCm = 'java -jar %s %s %s' % (jarPath, publicXml, apkRfilePath)
  478. printlog("javaMerCm:%s" % javaMerCm)
  479. os.system(javaMerCm)
  480. printlog(" Xiao7Replace begin replace game package v4 smali -------------------------------")
  481. sdk_root_dir = apk_utils.getCutSdkRootHome()
  482. pkgV4Path = "%s/smali/android/support/v4" % prj_path
  483. printlog("pkgV4Path:%s" % pkgV4Path)
  484. sdkV4Path = "%s/x7sy/x7sy/smali/android/support/v4" % sdk_root_dir
  485. printlog("sdkV4Path:%s" % sdkV4Path)
  486. if os.path.exists(pkgV4Path):
  487. File.copyAllFile(sdkV4Path, pkgV4Path)
  488. pkgName = ET.parse("%s/AndroidManifest.xml" % prj_path).getroot().attrib["package"]
  489. Aapt_Util.createRFile(prj_path, False, pkgName)
  490. pkgName = "android.support.constraint"
  491. Aapt_Util.createRFile(prj_path, False, pkgName)
  492. prj_am_path = prj_path + dir_split + "AndroidManifest.xml"
  493. prj_param = "%s/assets/YyrhParam.cnf" % prj_path
  494. splashactivity = "com.yythird.sdk.SplashActivity"
  495. game_activity = Replace.replaceGameActivityLaunchAttribute(splashactivity, prj_am_path)
  496. Replace.replaceAssets_Param(prj_param, "GAME_ACTIVITY", game_activity)
  497. printlog("xiaoqi GAME_ACTIVITY :%s" % game_activity)
  498. pass
  499. def NwanKaReplace(prj_path, dir_split, key, value):
  500. if (key == "channelId"):
  501. Replace.replaceAcom.yythird.sdkssets_Param("%s/assets/wk.properties" % prj_path, 'channelId', value)
  502. if (key == "adId"):
  503. Replace.replaceAssets_Param("%s/assets/wk.properties" % prj_path, 'adId', value)
  504. if (key == "adFlag"):
  505. Replace.replaceAssets_Param("%s/assets/wk.properties" % prj_path, 'adFlag', value)
  506. manifestRootExt = r'<application xmlns:tools="http://schemas.android.com/tools" tools:replace="android:theme,android:name"'
  507. replacePkgNameShell = "sed -i 's!<application!%s!g' %s/AndroidManifest.xml" % (manifestRootExt, prj_path)
  508. printlog("WankaReplace replace add application root point shell: %s" % replacePkgNameShell)
  509. os.system(replacePkgNameShell)
  510. pass
  511. def MBaiduReplace(prj_path, dir_split, key, value):
  512. if (key == "APP_ID"):
  513. manifestRootExt = r'<application android:networkSecurityConfig="@xml/network_security_config"'
  514. replacePkgNameShell = "sed -i 's!<application!%s!g' %s/AndroidManifest.xml" % (manifestRootExt, prj_path)
  515. printlog("MbaiduReplace replace add application root point shell: %s" % replacePkgNameShell)
  516. os.system(replacePkgNameShell)
  517. GeneralModifySmali.modifyRfileIdSmali(prj_path, "/smali/com/baidu/passport/sapi2")
  518. pass
  519. def ShenshouReplace(prj_path, dir_split, key, value):
  520. if (key == "BALANCENAME"):
  521. prj_style_path = prj_path + dir_split + "res/values-v28/styles.xml"
  522. printlog("prj_style_path: %s" % prj_style_path)
  523. File.safeFileDelete(prj_style_path)
  524. pass
  525. def DaYanReplace(prj_path, dir_split, key, value):
  526. if (key == "GD"):
  527. filepath = "%s/assets/sdkchannel.txt" % prj_path
  528. replacePdShell = 'sed -i "s#%s#%s#g" %s' % ("PD", value, filepath)
  529. printlog(replacePdShell)
  530. os.system(replacePdShell)
  531. pass
  532. def DaLanReplace(prj_path, dir_split, key, value):
  533. printlog("specail replace : DaLanReplace")
  534. prj_am_path = prj_path + dir_split + "AndroidManifest.xml"
  535. if (key == "DL_APPID"):
  536. splashactivity = "com.dalan.dl_assembly.SplashScreenActivity"
  537. game_activity = Replace.replaceGameActivityLaunchAttribute(splashactivity, prj_am_path)
  538. printlog("GAMEACTIVITY :%s" % game_activity)
  539. Replace.replaceAM_Meta_data(prj_am_path, "dalan_union_main_activity", game_activity)
  540. pass
  541. def KSyxReplace(prj_path, dir_split, key, value):
  542. if (key == "kwai_app_id"):
  543. Replace.replaceAssets_Param("%s/assets/allin_developer_config.properties" % prj_path, 'kwai_app_id', value)
  544. printlog(" KSyxReplace begin replace game package v4 smali -------------------------------")
  545. sdk_root_dir = apk_utils.getCutSdkRootHome()
  546. pkgV4Path = "%s/smali/android/support/v4" % prj_path
  547. printlog("pkgV4Path:%s" % pkgV4Path)
  548. sdkV4Path = "%s/ksyx/ksyx/smali/android/support/v4" % sdk_root_dir
  549. printlog("sdkV4Path:%s" % sdkV4Path)
  550. if os.path.exists(pkgV4Path):
  551. File.copyAllFile(sdkV4Path, pkgV4Path)
  552. prj_am_path = prj_path + dir_split + "AndroidManifest.xml"
  553. Replace.replaceAM_AllowBackup(prj_am_path)
  554. pass
  555. def LlhyReplace(prj_path, dir_split, key, value):
  556. printlog("specail replace : LlhyReplace")
  557. if (key == "LLHY_APP_ID"):
  558. metaKey = "unityplayer.SkipPermissionsDialog"
  559. Replace.replaceAM_Meta_data("%s/AndroidManifest.xml" % prj_path, metaKey,
  560. "true")
  561. pass
  562. def HnqsReplace(prj_path, dir_split, key, value):
  563. printlog("specail replace : HnqsReplace")
  564. if (key == "agent"):
  565. Replace.replaceAssets_Param("%s/assets/jmhy.properties" % prj_path, 'agent', value)
  566. metaKey = "unityplayer.SkipPermissionsDialog"
  567. Replace.replaceAM_Meta_data("%s/AndroidManifest.xml" % prj_path, metaKey,
  568. "true")
  569. sdk_root_dir = apk_utils.getCutSdkRootHome()
  570. sdk_smali_dir = "%s/hnqs/hnqs/extension/yyrh" % sdk_root_dir
  571. temp_old_smali_dir = "%s/smali/com/yyrh" % prj_path
  572. if os.path.exists(sdk_smali_dir):
  573. File.copyAllFile(sdk_smali_dir, temp_old_smali_dir)
  574. pass
  575. def SogouReplace(prj_path, dir_split, key, value):
  576. if (key == "GID"):
  577. printlog(" SogouReplace begin replace game package v4 smali -------------------------------")
  578. sdk_root_dir = apk_utils.getCutSdkRootHome()
  579. pkgV4Path = "%s/smali/android/support/v4" % prj_path
  580. printlog("pkgV4Path:%s" % pkgV4Path)
  581. sdkV4Path = "%s/sogou/sogou/smali/android/support/v4" % sdk_root_dir
  582. printlog("sdkV4Path:%s" % sdkV4Path)
  583. if os.path.exists(pkgV4Path):
  584. File.copyAllFile(sdkV4Path, pkgV4Path)
  585. prj_am_path = prj_path + dir_split + "AndroidManifest.xml"
  586. Replace.replaceAM_AllowBackup(prj_am_path)
  587. pass
  588. def JinRiTouTiaoReplace(prj_path, dir_split, key, value):
  589. jsonFilePath = prj_path + dir_split + "assets" + dir_split + "config.json"
  590. if key == 'APP_ID':
  591. with open(jsonFilePath, 'r') as fp:
  592. jsonData = json.load(fp)
  593. jsonData['app']["app_id"] = value
  594. jsonData['app']['main_activity'] = GeneralModifySmali.getLauchActivityName(prj_path)
  595. orientation = GeneralModifySmali.getLauchActivityScreenOrientation(prj_path)
  596. if orientation == "landscape" or orientation == "sensorLandscape":
  597. screen_orientation = "sensorLandscape"
  598. else:
  599. screen_orientation = "sensorPortrait"
  600. jsonData['app']['screen_orientation'] = screen_orientation
  601. newJsonData = jsonData
  602. fp.close()
  603. with open(jsonFilePath, 'w') as fp:
  604. json.dump(newJsonData, fp)
  605. fp.close()
  606. GeneralModifySmali.modifyRfileIdSmali(prj_path, "/smali/game_sdk/packers/rocket_sdk")
  607. GeneralModifySmali.modifyRfileIdSmali(prj_path, "/smali_classes2/game_sdk/packers/rocket_sdk")
  608. GeneralModifySmali.modifyRfileIdSmali(prj_path, "/smali/androidx/navigation/ui")
  609. GeneralModifySmali.modifyRfileIdSmali(prj_path, "/smali_classes3/android/support/design")
  610. GeneralModifySmali.modifyRfileIdSmali(prj_path, "/smali_classes3/android/support/v7/appcompat")
  611. # GeneralModifySmali.replaceSdkV4Smali(prj_path,"jrtt/jrtt/smali/android/support/v4")
  612. sdk_root_dir = apk_utils.getCutSdkRootHome()
  613. pkgV4Path = "%s/smali/android/support/v4" % prj_path
  614. printlog("pkgV4Path:%s" % pkgV4Path)
  615. sdkV4Path = "%s/jrtt/jrtt/smali_classes3/android/support/v4" % sdk_root_dir
  616. printlog("sdkV4Path:%s" % sdkV4Path)
  617. if os.path.exists(pkgV4Path):
  618. File.copyAllFile(sdkV4Path, pkgV4Path)
  619. GeneralModifySmali.modifyJrttV7ResIdSmali(prj_path)
  620. else:
  621. Replace.replaceJsonValue(jsonFilePath, "app", key, value)
  622. pass
  623. def FengQiReplace(prj_path, dir_split, key, value):
  624. if (key == "channelId") or (key == "adId") or (key == "adFlag"):
  625. # 替换fq.properties
  626. printlog("path fq.properties:%s/assets/fq.properties" % prj_path)
  627. Replace.replaceAssets_Param("%s/assets/fq.properties" % prj_path, key, value)
  628. pass
  629. pass
  630. def BlueStackReplace(prj_path, dir_split, key, value):
  631. if key == "APP_ID":
  632. replaceBlueStackIdShell = 'sed -i "1,\\$s/APP_ID/%s/g" %s/assets/BSSDKConfig.xml ' % (value, prj_path)
  633. printlog("replaceBlueStackIdShell: %s" % replaceBlueStackIdShell)
  634. os.system(replaceBlueStackIdShell)
  635. pass
  636. # 司墨
  637. def SiMoReplace(prj_path, dir_split, key, value):
  638. if key == "APP_ID":
  639. config_path = prj_path + '/assets/SIMgame_config.xml'
  640. tree = ET.parse(config_path)
  641. root = tree.getroot()
  642. for elem in root.iter('appid'):
  643. elem.text = value
  644. tree.write(config_path, "UTF-8", xml_declaration=True, method='xml')
  645. pass
  646. # 乘龙
  647. def ChenLongReplace(prj_path, dir_split, key, value):
  648. if key == "CL_PID":
  649. Replace.replaceAssets_Param("%s/assets/_cl_developer_config.properties" % prj_path, 'CL_PID', value)
  650. if key == "CL_KEY":
  651. Replace.replaceAssets_Param("%s/assets/_cl_developer_config.properties" % prj_path, 'CL_KEY', value)
  652. if key == "CL_DEBUG_GD":
  653. Replace.replaceAssets_Param("%s/assets/_cl_developer_config.properties" % prj_path, 'CL_DEBUG_GD', value)
  654. pass
  655. def JiuZiReplace(prj_path, dir_split, key, value):
  656. printlog("specail replace : JiuZiReplace")
  657. if (key == "gid"):
  658. prj_param = "%s/assets/YyrhParam.cnf" % prj_path
  659. prj_am_path = prj_path + dir_split + "AndroidManifest.xml"
  660. splash_activity = "com.yythird.sdk.SplashActivity"
  661. game_activity = Replace.replaceGameActivityLaunchAttribute(splash_activity, prj_am_path)
  662. printlog("GAMEACTIVITY :%s" % game_activity)
  663. Replace.replaceAssets_Param(prj_param, "GAMEACTIVITY", game_activity)
  664. pkgName = ET.parse(prj_am_path).getroot().attrib["package"]
  665. Aapt_Util.createRFile(prj_path, False, pkgName)
  666. apkRfilePath = "%s/smali/com/jzyx/sdk" % prj_path
  667. printlog("apkRfilePath:%s" % apkRfilePath)
  668. publicXml = "%s/res/values/public.xml" % prj_path
  669. sdk_jar_dir = apk_utils.getToolsJarHome()
  670. jarPath = "%s/MergeSamli.jar" % sdk_jar_dir
  671. javaMerCm = 'java -jar %s %s %s' % (jarPath, publicXml, apkRfilePath)
  672. printlog("javaMerCm:%s" % javaMerCm)
  673. os.system(javaMerCm)
  674. pass
  675. def BingNiaoReplace(prj_path, dir_split, key, value):
  676. printlog("specail replace : DaLanReplace")
  677. if (key == "YH_GAME_ID"):
  678. prj_am_path = prj_path + dir_split + "AndroidManifest.xml"
  679. splashactivity = "prj.iyinghun.platform.sdk.SplashScreenActivity"
  680. game_activity = Replace.replaceGameActivityLaunchAttribute(splashactivity, prj_am_path)
  681. printlog("GAMEACTIVITY :%s" % game_activity)
  682. Replace.replaceAM_Meta_data(prj_am_path, "prj.chameleon.intent.main", game_activity)
  683. pass
  684. def BingChengReplace(prj_path, dir_split, key, value):
  685. prj_am_path = prj_path + dir_split + "AndroidManifest.xml"
  686. namespace = '{http://schemas.android.com/apk/res/android}'
  687. ET.register_namespace('android', "http://schemas.android.com/apk/res/android")
  688. if (key == "BC_GAME_ID"):
  689. tree = ET.parse(prj_am_path)
  690. pkgName = tree.getroot().attrib["package"]
  691. activitys = tree.getroot().find("application").findall("activity")
  692. for activity in activitys:
  693. filters = activity.findall('intent-filter')
  694. for filter in filters:
  695. categorys = filter.findall('category')
  696. for category in categorys:
  697. categoryname = category.attrib[namespace + "name"]
  698. if (categoryname == "android.intent.category.LAUNCHER"):
  699. element = Element('intent-filter')
  700. el1 = Element('action android:name="android.intent.action.VIEW"')
  701. el2 = Element('category android:name="android.intent.category.DEFAULT"')
  702. el3 = Element('category android:name="android.intent.category.BROWSABLE"')
  703. el4_value = 'data android:host="%s" android:scheme="%s"' % (value, pkgName)
  704. el4 = Element(el4_value)
  705. element.append(el1)
  706. element.append(el2)
  707. element.append(el3)
  708. element.append(el4)
  709. activity.append(element)
  710. tree.write(prj_am_path, "UTF-8", xml_declaration=True, method='xml')
  711. def SuixingHuYuReplace(prj_path, dir_split, key, value):
  712. if (key == "game_id"):
  713. Replace.replaceAssets_Param("%s/assets/suixin/suixin_sdk.ini" % prj_path, key, value)
  714. if (key == "pid"):
  715. Replace.replaceAssets_Param("%s/assets/suixin/suixin_sdk.ini" % prj_path, key, value)
  716. if (key == "is_land"):
  717. Replace.replaceAssets_Param("%s/assets/suixin/suixin_sdk.ini" % prj_path, key, value)
  718. pass
  719. def ShouQuReplace(prj_path, dir_split, key, value):
  720. config_path = "%s/assets/sqsdk_config" % prj_path
  721. with open(config_path, "r") as f:
  722. content = f.read()
  723. json_data = json.loads(content)
  724. json_data[key] = value
  725. with open(config_path, "w") as f:
  726. f.write(json.dumps(json_data))
  727. if key == "app_key":
  728. manifest_path = prj_path + dir_split + "AndroidManifest.xml"
  729. param_cnf = "%s/assets/YyrhParam.cnf" % prj_path
  730. splash_activity = "com.yythird.sdk.SplashActivity"
  731. game_activity = Replace.replaceGameActivityLaunchAttribute(splash_activity, manifest_path)
  732. Replace.replaceAssets_Param(param_cnf, "GAMEACTIVITY", game_activity)
  733. printlog("GAMEACTIVITY :%s" % game_activity)
  734. def HaiNanQiJingReplace(prj_path, dir_split, key, value):
  735. if key == "PACKAGE_TAG":
  736. sdk_root_dir = apk_utils.getCutSdkRootHome()
  737. sdkSmaliPath = "%s/hnqj/hnqj/smali/com" % sdk_root_dir
  738. pkgSmaliPath = "%s/smali/com" % prj_path
  739. printlog("sdkSmaliPath :%s" % sdkSmaliPath)
  740. printlog("pkgSmaliPath :%s" % pkgSmaliPath)
  741. if os.path.exists(pkgSmaliPath):
  742. File.copyAllFile(sdkSmaliPath, pkgSmaliPath)
  743. if Contants.isTestEnvironment():
  744. key = "https://fxsy.qijinghao.com"
  745. value = "http://testsdkapi.yyxxgame.com"
  746. file = "%s/smali/com/yyrh/c/a.smali" % prj_path
  747. Replace.replaceKeyword(key, value, file)
  748. file = "%s/smali/com/yyrh/ui/a.smali" % prj_path
  749. Replace.replaceKeyword(key, value, file)
  750. file = "%s/smali/com/yyrh/a/d.smali" % prj_path
  751. Replace.replaceKeyword(key, value, file)
  752. file = "%s/smali/com/yyrh/sdk/SDKEntry.smali" % prj_path
  753. Replace.replaceKeyword(key, value, file)
  754. pass
  755. def HongGuoReplace(prj_path, dir_split, key, value):
  756. config_path = "%s/assets/gameInfo.json" % prj_path
  757. with open(config_path, "r") as f:
  758. content = f.read()
  759. json_data = json.loads(content)
  760. json_data[key] = value
  761. with open(config_path, "w") as f:
  762. f.write(json.dumps(json_data))
  763. if key == "game_id":
  764. manifest_path = prj_path + dir_split + "AndroidManifest.xml"
  765. param_cnf = "%s/assets/YyrhParam.cnf" % prj_path
  766. splash_activity = "com.yythird.sdk.SplashActivity"
  767. game_activity = Replace.replaceGameActivityLaunchAttribute(splash_activity, manifest_path)
  768. Replace.replaceAssets_Param(param_cnf, "GAMEACTIVITY", game_activity)
  769. sdk_root_dir = apk_utils.getCutSdkRootHome()
  770. printlog(" HongGuoReplace begin replace game package v4 smali -------------------------------")
  771. pkgV4Path = "%s/smali/android/support/v4" % prj_path
  772. printlog("pkgV4Path:%s" % pkgV4Path)
  773. sdkV4Path = "%s/hg/hg/smali/android/support/v4" % sdk_root_dir
  774. printlog("sdkV4Path:%s" % sdkV4Path)
  775. if os.path.exists(pkgV4Path):
  776. File.copyAllFile(sdkV4Path, pkgV4Path)
  777. pass
  778. def BaizeReplace(prj_path, dir_split, key, value):
  779. if key == "APP_ID":
  780. prj_am_path = prj_path + dir_split + "AndroidManifest.xml"
  781. param_cnf = "%s/assets/YyrhParam.cnf" % prj_path
  782. splashactivity = "com.yythird.sdk.SplashActivity"
  783. game_activity = Replace.replaceGameActivityLaunchAttribute(splashactivity, prj_am_path)
  784. printlog("GAMEACTIVITY :%s" % game_activity)
  785. Replace.replaceAssets_Param(param_cnf, "GAMEACTIVITY", game_activity)
  786. pass
  787. def YanXinReplace(prj_path, dir_split, key, value):
  788. if key == "ProductCode":
  789. Replace.modifyRfileSmaliPath("yx", prj_path)
  790. pass
  791. def ZhangShangHuYuReplace(prj_path, dir_split, key, value):
  792. Replace.replaceAssets_Param("%s/assets/yy.properties" % prj_path, key, value)
  793. if key == "channelId":
  794. sdk_root_dir = apk_utils.getCutSdkRootHome()
  795. printlog(" ZhangShangHuYuReplace begin replace game package v4 smali -------------------------------")
  796. pkgV4Path = "%s/smali/android/support/v7" % prj_path
  797. printlog("pkgV4Path:%s" % pkgV4Path)
  798. sdkV4Path = "%s/zshy/zshy/smali/android/support/v7" % sdk_root_dir
  799. printlog("sdkV4Path:%s" % sdkV4Path)
  800. if os.path.exists(pkgV4Path):
  801. File.copyAllFile(sdkV4Path, pkgV4Path)
  802. GeneralModifySmali.modifyRfileIdSmali(prj_path, "/smali/android/support/v7/cardview")
  803. printlog(" HongGuoReplace begin replace game package v4 smali -------------------------------")
  804. pkgV4Path = "%s/smali/android/support/v4" % prj_path
  805. printlog("pkgV4Path:%s" % pkgV4Path)
  806. sdkV4Path = "%s/zshy/zshy/smali/android/support/v4" % sdk_root_dir
  807. printlog("sdkV4Path:%s" % sdkV4Path)
  808. if os.path.exists(pkgV4Path):
  809. File.copyAllFile(sdkV4Path, pkgV4Path)
  810. apkRfilePath = "%s/smali/com/zshy/zshysdk" % prj_path
  811. printlog("apkRfilePath:%s" % apkRfilePath)
  812. publicXml = "%s/res/values/public.xml" % prj_path
  813. sdk_jar_dir = apk_utils.getToolsJarHome()
  814. jarPath = "%s/MergeSamli.jar" % sdk_jar_dir
  815. javaMerCm = 'java -jar %s %s %s' % (jarPath, publicXml, apkRfilePath)
  816. printlog("javaMerCm:%s" % javaMerCm)
  817. os.system(javaMerCm)
  818. Replace.modifyRfileSmaliPath("zshy", prj_path);
  819. pass
  820. def XiYouWangReplace(prj_path, dir_split, key, value):
  821. Replace.replaceAssets_Param("%s/assets/xy_developer_config.properties" % prj_path, key, value)
  822. if key == "XY_APP_ID":
  823. splash_activity = "com.xiyou.sdk.XiYouSplashActivity"
  824. manifest_path = prj_path + dir_split + "AndroidManifest.xml"
  825. game_activity = Replace.replaceGameActivityLaunchAttribute(splash_activity, manifest_path)
  826. Replace.replaceAM_Meta_data(manifest_path, 'XY_GAME_MAIN_ACTIVITY_NAME', game_activity)
  827. sdk_root_dir = apk_utils.getCutSdkRootHome()
  828. printlog(" xiyouwang begin replace game package v4 smali -------------------------------")
  829. pkgV4Path = "%s/smali/android/support/v4" % prj_path
  830. printlog("pkgV4Path:%s" % pkgV4Path)
  831. sdkV4Path = "%s/xiyou/xiyou/smali/android/support/v4" % sdk_root_dir
  832. printlog("sdkV4Path:%s" % sdkV4Path)
  833. if os.path.exists(pkgV4Path):
  834. File.copyAllFile(sdkV4Path, pkgV4Path)
  835. prj_am_path = "%s/AndroidManifest.xml" % prj_path
  836. pkgName = ET.parse(prj_am_path).getroot().attrib["package"]
  837. Aapt_Util.createRFile(prj_path, False, pkgName)
  838. pass
  839. def XunLeiReplace(prj_path, dir_split, key, value):
  840. prj_am_path = prj_path + dir_split + "AndroidManifest.xml"
  841. namespace = '{http://schemas.android.com/apk/res/android}'
  842. ET.register_namespace('android', "http://schemas.android.com/apk/res/android")
  843. if (key == "schemeCallback"):
  844. tree = ET.parse(prj_am_path)
  845. activitys = tree.getroot().find("application").findall("activity")
  846. for activity in activitys:
  847. activityName = activity.attrib[namespace + "name"]
  848. printlog("activityName:%s" % activityName)
  849. if (activityName == "com.xovs.common.auth.processor.XLAuthBackActivity"):
  850. filters = activity.findall('intent-filter')
  851. for filter in filters:
  852. datas = filter.findall('data')
  853. for data in datas:
  854. printlog("data:%s" % data)
  855. data.set(namespace + "scheme", value)
  856. tree.write(prj_am_path, "UTF-8", xml_declaration=True, method='xml')
  857. pass
  858. def CanLongReplace(prj_path, dir_split, key, value):
  859. if key == "PRODUCT_CODE":
  860. Replace.modifyRfileSmaliPath("canlong", prj_path);
  861. pass
  862. def ShangHaiXiYuanReplace(prj_path, dir_split, key, value):
  863. if key == "PACKAGE_TAG":
  864. sdk_root_dir = apk_utils.getCutSdkRootHome()
  865. sdkSmaliPath = "%s/shxy/shxy/smali/com/yyrh" % sdk_root_dir
  866. pkgSmaliPath = "%s/smali/com/yyrh" % prj_path
  867. printlog("sdkSmaliPath :%s" % sdkSmaliPath)
  868. printlog("pkgSmaliPath :%s" % pkgSmaliPath)
  869. if os.path.exists(pkgSmaliPath):
  870. File.copyAllFile(sdkSmaliPath, pkgSmaliPath)
  871. if Contants.isTestEnvironment():
  872. key = "https://sdkapi.bklinok.com"
  873. value = "http://testsdkapi.yyxxgame.com"
  874. file = "%s/smali/com/yyrh/c/a.smali" % prj_path
  875. Replace.replaceKeyword(key, value, file)
  876. file = "%s/smali/com/yyrh/a/d.smali" % prj_path
  877. Replace.replaceKeyword(key, value, file)
  878. file = "%s/smali/com/yyrh/sdk/SDKEntry.smali" % prj_path
  879. Replace.replaceKeyword(key, value, file)
  880. pass
  881. def YuanYouRongHeReplace(prj_path, dir_split, key, value):
  882. if key == "PACKAGE_TAG":
  883. sdk_root_dir = apk_utils.getCutSdkRootHome()
  884. sdkSmaliPath = "%s/mixsdk/mixsdk/smali/com/yyrh" % sdk_root_dir
  885. pkgSmaliPath = "%s/smali/com/yyrh" % prj_path
  886. printlog("sdkSmaliPath :%s" % sdkSmaliPath)
  887. printlog("pkgSmaliPath :%s" % pkgSmaliPath)
  888. if os.path.exists(pkgSmaliPath):
  889. File.copyAllFile(sdkSmaliPath, pkgSmaliPath)
  890. sdkSmaliPath = "%s/mixsdk/mixsdk/smali/com/yythird/base" % sdk_root_dir
  891. pkgSmaliPath = "%s/smali/com/yythird/base" % prj_path
  892. printlog("sdkSmaliPath :%s" % sdkSmaliPath)
  893. printlog("pkgSmaliPath :%s" % pkgSmaliPath)
  894. if os.path.exists(pkgSmaliPath):
  895. File.copyAllFile(sdkSmaliPath, pkgSmaliPath)
  896. if Contants.isTestEnvironment():
  897. key = "https://sdkapi.yyxxgame.com"
  898. value = "http://testsdkapi.yyxxgame.com"
  899. file = "%s/smali/com/yyrh/c/a.smali" % prj_path
  900. Replace.replaceKeyword(key, value, file)
  901. file = "%s/smali/com/yyrh/sdk/SDKEntry.smali" % prj_path
  902. Replace.replaceKeyword(key, value, file)
  903. pass
  904. def BaLeReplace(prj_path, dir_split, key, value):
  905. if key == "CHANNEL_ID":
  906. GeneralModifySmali.modifyRfileIdSmali(prj_path, "/smali/com/sdk/douyou")
  907. pass
  908. def QiPaReplace(prj_path, dir_split, key, value):
  909. if key == "Super_Game_ID":
  910. splash_activity = "com.supersdk.application.MySplashActivity"
  911. prj_am_path = "%s/AndroidManifest.xml" % prj_path
  912. game_activity = Replace.replaceGameActivityLaunchAttribute(splash_activity, prj_am_path)
  913. tree = ET.parse(prj_am_path)
  914. activitys = tree.getroot().find("application").findall("activity")
  915. for activity in activitys:
  916. namespace = '{http://schemas.android.com/apk/res/android}'
  917. xml_activity_name = activity.attrib[namespace + "name"]
  918. if xml_activity_name == game_activity:
  919. filter = activity.find('intent-filter')
  920. el1 = Element('action android:name="com.super.sdk.MAIN"')
  921. filter.append(el1)
  922. tree.write(prj_am_path, "UTF-8", xml_declaration=True, method='xml')
  923. pass
  924. def DouyinReplace(prj_path, dir_split, key, value):
  925. jsonFilePath = prj_path + dir_split + "assets" + dir_split + "config.json"
  926. if key == 'app_id':
  927. with open(jsonFilePath, 'r') as fp:
  928. jsonData = json.load(fp)
  929. jsonData["app_id"] = value
  930. jsonData['screen_orientation'] = GeneralModifySmali.getLauchActivityName(prj_path)
  931. orientation = GeneralModifySmali.getLauchActivityScreenOrientation(prj_path)
  932. if orientation == "landscape" or orientation == "sensorLandscape":
  933. screen_orientation = "sensorLandscape"
  934. else:
  935. screen_orientation = "sensorPortrait"
  936. jsonData['screen_orientation'] = screen_orientation
  937. newJsonData = jsonData
  938. fp.close()
  939. with open(jsonFilePath, 'w') as fp:
  940. json.dump(newJsonData, fp)
  941. fp.close()
  942. printlog(" douyin begin replace game package v4 smali -------------------------------")
  943. pkgV4Path = "%s/smali/android/support/v4" % prj_path
  944. printlog("pkgV4Path:%s" % pkgV4Path)
  945. File.del_file(pkgV4Path)
  946. prj_am_path = "%s/AndroidManifest.xml" % prj_path
  947. pkgName = ET.parse(prj_am_path).getroot().attrib["package"]
  948. Aapt_Util.createRFile(prj_path, False, pkgName)
  949. sdkRpath = "android/support/v7/appcompat"
  950. pkgRpath = pkgName.replace(".", "/")
  951. sdkAbsoluteRpath = "%s/smali_classes3/%s" % (prj_path, sdkRpath)
  952. pkgAbsoluteRpath = "%s/smali/%s" % (prj_path, pkgRpath)
  953. Replace.createRFile2Sdk(pkgAbsoluteRpath, sdkAbsoluteRpath, pkgRpath, sdkRpath)
  954. pass
  955. def MoMoYuReplace(prj_path, dir_split, key, value):
  956. xml_path = "%s/res/values/strings.xml" % prj_path
  957. Replace.replaceXmlValue(xml_path, key, value)
  958. pass
  959. def QuxuanReplace(prj_path, dir_split, key, value):
  960. if key == "app_id":
  961. prj_am_path = "%s/AndroidManifest.xml" % prj_path
  962. value = "Qdazzle_%s" % value
  963. Replace.replaceAM_Meta_data(prj_am_path, "CommonSDK_AppID", value)
  964. GeneralModifySmali.modifyRfileIdSmali(prj_path, "/smali/com/qdazzle/sdk")
  965. if key == "app_key":
  966. prj_am_path = "%s/AndroidManifest.xml" % prj_path
  967. value = "Qdazzle_%s" % value
  968. Replace.replaceAM_Meta_data(prj_am_path, "CommonSDK_AppKey", value)
  969. pass
  970. def MuMuReplace(prj_path, dir_split, key, value):
  971. if key == "YOFUN_APP_ID":
  972. printlog("specail replace : MuMuReplace")
  973. splashactivity = "com.yythird.sdk.SplashActivity"
  974. prj_am_path = prj_path + dir_split + "AndroidManifest.xml"
  975. prj_param = "%s/assets/YyrhParam.cnf" % prj_path
  976. game_activity = Replace.replaceGameActivityLaunchAttribute(splashactivity, prj_am_path)
  977. printlog("GAMEACTIVITY :%s" % game_activity)
  978. Replace.replaceAssets_Param(prj_param, "GAMEACTIVITY", game_activity)
  979. pass
  980. def HeFengReplace(prj_path, dir_split, key, value):
  981. if key == "ver":
  982. printlog("specail replace : HeFengReplace")
  983. printlog("path hf.properties :%s/assets/hf.properties" % prj_path)
  984. Replace.replaceAssets_Param("%s/assets/hf.properties" % prj_path, "agent", value)
  985. pass
  986. def ShengBenFuliReplace(prj_path, dir_split, key, value):
  987. if key == "appid":
  988. printlog("specail replace : ShengBenFuliReplace")
  989. splash_activity = "com.fysdk.activity.FyGuideActivity"
  990. prj_am_path = prj_path + dir_split + "AndroidManifest.xml"
  991. namespace = '{http://schemas.android.com/apk/res/android}'
  992. ET.register_namespace('android', "http://schemas.android.com/apk/res/android")
  993. tree = ET.parse(prj_am_path)
  994. activitys = tree.getroot().find("application").findall("activity")
  995. for activity in activitys:
  996. filters = activity.findall('intent-filter')
  997. for filter in filters:
  998. categorys = filter.findall('category')
  999. actions = filter.findall('action')
  1000. for category in categorys:
  1001. category_name = category.attrib[namespace + "name"]
  1002. if category_name == "android.intent.category.LAUNCHER":
  1003. action_name = activity.attrib[namespace + "name"]
  1004. if action_name != splash_activity:
  1005. printlog("delete :%s" % category_name)
  1006. category.attrib[namespace + "name"] = "android.intent.category.DEFAULT"
  1007. printlog("LAUNCHER replace DEFAULT :%s" % category.attrib[namespace + "name"])
  1008. for action in actions:
  1009. action_name = action.attrib[namespace + "name"]
  1010. if action_name == "android.intent.action.MAIN":
  1011. printlog("delete :%s" % action_name)
  1012. action.attrib[namespace + "name"] = "game.MAIN"
  1013. tree.write(prj_am_path, "UTF-8", xml_declaration=True, method='xml')
  1014. pass
  1015. def MuXueReplace(prj_path, dir_split, key, value):
  1016. printlog("specail replace : MuXueReplace")
  1017. Replace.replaceAssets_Param("%s/assets/gs.properties" % prj_path, key, value)
  1018. pass
  1019. def QiYouReplace(prj_path, dir_split, key, value):
  1020. if (key == "blgame_gameid"):
  1021. prj_am_path = prj_path + dir_split + "AndroidManifest.xml"
  1022. pkgName = ET.parse(prj_am_path).getroot().attrib["package"]
  1023. sdk_root_dir = apk_utils.getCutSdkRootHome()
  1024. pkgV4Path = "%s/smali/android/support/design" % prj_path
  1025. printlog("pkgV4Path:%s" % pkgV4Path)
  1026. sdkV4Path = "%s/7you/7you/smali/android/support/design" % sdk_root_dir
  1027. printlog("sdkV4Path:%s" % sdkV4Path)
  1028. if os.path.exists(pkgV4Path):
  1029. File.copyAllFile(sdkV4Path, pkgV4Path)
  1030. Aapt_Util.createRFile(prj_path, False, pkgName)
  1031. GeneralModifySmali.modifyRfileIdSmali(prj_path, "/smali/android/support/v7/appcompat")
  1032. GeneralModifySmali.modifyRfileIdSmali(prj_path, "/smali/android/support/design")
  1033. GeneralModifySmali.modifyRfileIdSmali(prj_path, "/smali/android/support/v7/cardview")
  1034. pass
  1035. def YueWanReplace(prj_path, dir_split, key, value):
  1036. printlog("specail replace : YueWanReplace")
  1037. if (key == "J_GAME_ID"):
  1038. sdk_root_dir = apk_utils.getCutSdkRootHome()
  1039. printlog(" YueWanReplace begin replace game package v4 smali -------------------------------")
  1040. pkgV4Path = "%s/smali/android/support/v4" % prj_path
  1041. printlog("pkgV4Path:%s" % pkgV4Path)
  1042. sdkV4Path = "%s/yuewan/yuewan/smali/android/support/v4" % sdk_root_dir
  1043. printlog("sdkV4Path:%s" % sdkV4Path)
  1044. if os.path.exists(pkgV4Path):
  1045. File.copyAllFile(sdkV4Path, pkgV4Path)
  1046. pass
  1047. def ShengYueReplace(prj_path, dir_split, key, value):
  1048. printlog("specail replace : ShengYueReplace")
  1049. jsonFilePath = prj_path + dir_split + "assets" + dir_split + "UUConfig.json"
  1050. Replace.replaceJsonValue(jsonFilePath, "", key, value)
  1051. pass
  1052. def JiZhiHuiReplace(prj_path, dir_split, key, value):
  1053. printlog("specail replace : JiZhiHuiReplace")
  1054. config_path = "%s/assets/xggameinfo.txt" % prj_path
  1055. with open(config_path, "r") as f:
  1056. content = f.read()
  1057. json_data = json.loads(content)
  1058. json_data[key] = value
  1059. with open(config_path, "w") as f:
  1060. f.write(json.dumps(json_data))
  1061. def JiMiReplace(prj_path, dir_split, key, value):
  1062. Replace.replaceAssets_Param("%s/assets/jmhy.properties" % prj_path, key, value)
  1063. def DangLesdkReplace(prj_path, dir_split, key, value):
  1064. printlog("specail replace : DangLesdkReplace")
  1065. if key == "RH_APPID":
  1066. prj_am_path = prj_path + dir_split + "AndroidManifest.xml"
  1067. splashactivity = "com.rhsdk.SplashActivity"
  1068. game_activity = Replace.replaceGameActivityLaunchAttribute(splashactivity, prj_am_path)
  1069. printlog("GAMEACTIVITY :%s" % game_activity)
  1070. Replace.replaceAM_Meta_data(prj_am_path, "RH_GAME_ACTIVITY", game_activity)
  1071. rh_developer_config = "%s/assets/rh_developer_config.xml" % prj_path
  1072. tree = ET.parse(rh_developer_config)
  1073. metadatas = tree.getroot().findall("param")
  1074. for meta in metadatas:
  1075. if meta.attrib["name"] == key:
  1076. meta.attrib["value"] = value
  1077. tree.write(rh_developer_config, "UTF-8", xml_declaration=True, method='xml')
  1078. elif key == "RH_APPKEY":
  1079. rh_developer_config = "%s/assets/rh_developer_config.xml" % prj_path
  1080. tree = ET.parse(rh_developer_config)
  1081. metadatas = tree.getroot().findall("param")
  1082. for meta in metadatas:
  1083. if meta.attrib["name"] == key:
  1084. meta.attrib["value"] = value
  1085. tree.write(rh_developer_config, "UTF-8", xml_declaration=True, method='xml')
  1086. pass
  1087. def PinBangsdkReplace(prj_path, dir_split, key, value):
  1088. if key == 'xggameinfo.txt':
  1089. if os.path.exists(value):
  1090. printlog('replace pinbang xggameinfo.txt:%s' % value)
  1091. pb_sdk_config_path = os.path.join(prj_path, 'assets', key)
  1092. printlog('replace pinbang pb_sdk_config_path:%s' % pb_sdk_config_path)
  1093. shutil.copy(value, pb_sdk_config_path)
  1094. pass
  1095. def JianDaoReplace(prj_path, dir_split, key, value):
  1096. if key == "JIANDAO_GAMEID":
  1097. splashactivity = "com.yythird.sdk.SplashActivity"
  1098. prj_param = "%s/assets/YyrhParam.cnf" % prj_path
  1099. prj_am_path = prj_path + dir_split + "AndroidManifest.xml"
  1100. game_activity = Replace.replaceGameActivityLaunchAttribute(splashactivity, prj_am_path)
  1101. Replace.replaceAssets_Param(prj_param, "GAME_ACTIVITY", game_activity)
  1102. printlog("JianDaoReplace GAME_ACTIVITY :%s" % game_activity)
  1103. sdk_root_dir = apk_utils.getCutSdkRootHome()
  1104. pkgV4Path = "%s/smali/android/support/v4" % prj_path
  1105. printlog("pkgV4Path:%s" % pkgV4Path)
  1106. sdkV4Path = "%s/jiandao/jiandao/smali/android/support/v4" % sdk_root_dir
  1107. printlog("sdkV4Path:%s" % sdkV4Path)
  1108. if os.path.exists(pkgV4Path):
  1109. File.copyAllFile(sdkV4Path, pkgV4Path)
  1110. def MengHuReplace(prj_path, dir_split, key, value):
  1111. if key == "appid":
  1112. prj_am_path = "%s/AndroidManifest.xml" % prj_path
  1113. pkgName = ET.parse(prj_am_path).getroot().attrib["package"]
  1114. Aapt_Util.createRFile(prj_path, False, pkgName)
  1115. pass
  1116. def MengHu2Replace(prj_path, dir_split, key, value):
  1117. if key == "appid":
  1118. prj_am_path = "%s/AndroidManifest.xml" % prj_path
  1119. pkgName = ET.parse(prj_am_path).getroot().attrib["package"]
  1120. Aapt_Util.createRFile(prj_path, False, pkgName)
  1121. def MengHu3Replace(prj_path, dir_split, key, value):
  1122. config_path = "%s/assets/cd_super_sdk.json" % prj_path
  1123. with open(config_path, "r") as f:
  1124. content = f.read()
  1125. json_data = json.loads(content)
  1126. json_data[key] = value
  1127. with open(config_path, "w") as f:
  1128. f.write(json.dumps(json_data))
  1129. def baUReplace(prj_path, dir_split, key, value):
  1130. if key == "appid":
  1131. splashactivity = "com.yythird.sdk.SplashActivity"
  1132. prj_param = "%s/assets/YyrhParam.cnf" % prj_path
  1133. prj_am_path = prj_path + dir_split + "AndroidManifest.xml"
  1134. game_activity = Replace.replaceGameActivityLaunchAttribute(splashactivity, prj_am_path)
  1135. Replace.replaceAssets_Param(prj_param, "GAME_ACTIVITY", game_activity)
  1136. printlog("baUReplace GAME_ACTIVITY :%s" % game_activity)
  1137. pass
  1138. def ZhongXingReplace(prj_path, dir_split, key, value):
  1139. if key == 'Gamble_cfg':
  1140. printlog('replace ZhongXing Gamble_cfg')
  1141. config_path = os.path.join(prj_path, 'assets', key)
  1142. shutil.copy(value, config_path)
  1143. pass
  1144. specialReplace = {
  1145. "lenovo": LenovoReplace,
  1146. "baidu": BaiduReplace,
  1147. "wandoujia": WandoujiaReplace,
  1148. "qh360": QihuReplace,
  1149. "oppo": OppoReplace,
  1150. "oppoml": OppoMlReplace,
  1151. "chongchong": ChongchongReplace,
  1152. "yingyongbao": YYBReplace,
  1153. "downjoy": downjoyReplace,
  1154. "huawei": HuaweiReplace,
  1155. "anzhi": AnzhiReplace,
  1156. "leshi": LeshiReplace,
  1157. "quick": QuickReplace,
  1158. "guopan": GuopanReplace,
  1159. "ljsdk": LjsdkReplace,
  1160. "uc": UcsdkReplace,
  1161. "xiaomi": XiaomisdkReplace,
  1162. "hnshengben": ShengbensdkReplace,
  1163. "jk": JinkuosdkReplace,
  1164. "hd": HdhdsdkReplace,
  1165. "samsung": SamsungReplace,
  1166. "ttyy": TTReplace,
  1167. "yxf": YXFReplace,
  1168. "vivo": VivosdkReplace,
  1169. "3011": XTsdkReplace,
  1170. "ddt": DDTsdkReplace,
  1171. "wanka": WankaReplace,
  1172. "ddd": DDDReplace,
  1173. "lzyx": LZYXReplace,
  1174. "ws": WSReplace,
  1175. "xb": XBReplace,
  1176. "youdian": YoudianReplace,
  1177. "x7sy": Xiao7Replace,
  1178. "nwanka": NwanKaReplace,
  1179. "mbaidu": MBaiduReplace,
  1180. "shenshou": ShenshouReplace,
  1181. "dyyx": DaYanReplace,
  1182. "dl": DaLanReplace,
  1183. "ksyx": KSyxReplace,
  1184. "llhy": LlhyReplace,
  1185. "hnqs": HnqsReplace,
  1186. "sogou": SogouReplace,
  1187. "jrtt": JinRiTouTiaoReplace,
  1188. "fq": FengQiReplace,
  1189. "bs": BlueStackReplace,
  1190. "simo": SiMoReplace,
  1191. "cl": ChenLongReplace,
  1192. "qianmian": JinRiTouTiaoReplace,
  1193. "jiuzi": JiuZiReplace,
  1194. "bingniao": BingNiaoReplace,
  1195. "bingcheng": BingChengReplace,
  1196. "sxhy": SuixingHuYuReplace,
  1197. "shouqu": ShouQuReplace,
  1198. "hnqj": HaiNanQiJingReplace,
  1199. "hg": HongGuoReplace,
  1200. "baize": BaizeReplace,
  1201. "yx": YanXinReplace,
  1202. "zshy": ZhangShangHuYuReplace,
  1203. "xiyou": XiYouWangReplace,
  1204. "xunlei": XunLeiReplace,
  1205. "canlong": CanLongReplace,
  1206. "shxy": ShangHaiXiYuanReplace,
  1207. "mixsdk": YuanYouRongHeReplace,
  1208. "bale": BaLeReplace,
  1209. "7pa": QiPaReplace,
  1210. "dymmy": MoMoYuReplace,
  1211. "dyly": DouyinReplace,
  1212. "qx": QuxuanReplace,
  1213. "wymumu": MuMuReplace,
  1214. "hf": HeFengReplace,
  1215. "sbfl": ShengBenFuliReplace,
  1216. "muxue": MuXueReplace,
  1217. "7you": QiYouReplace,
  1218. "yuewan": YueWanReplace,
  1219. "shengyue": ShengYueReplace,
  1220. "jzh": JiZhiHuiReplace,
  1221. "jmhy": JiMiReplace,
  1222. "dangle": DangLesdkReplace,
  1223. "pinbang": PinBangsdkReplace,
  1224. "jiandao": JianDaoReplace,
  1225. "menghu": MengHuReplace,
  1226. "8uyx": baUReplace,
  1227. "menghu2": MengHu2Replace,
  1228. "menghu3": MengHu3Replace,
  1229. "zx":ZhongXingReplace
  1230. }
  1231. def getSpecilReplace(sdk_name):
  1232. if sdk_name in specialReplace:
  1233. return specialReplace[sdk_name]
  1234. else:
  1235. return None
  1236. pass