mirror of
https://github.com/feicong/rom-course.git
synced 2025-08-29 10:44:59 +00:00
72 lines
2.2 KiB
Python
72 lines
2.2 KiB
Python
![]() |
import os
|
|||
|
import shutil
|
|||
|
import subprocess
|
|||
|
|
|||
|
# ִ<><D6B4>cmd<6D><64><EFBFBD><EFBFBD>
|
|||
|
def exec(cmd):
|
|||
|
proc = subprocess.Popen(
|
|||
|
cmd,
|
|||
|
shell=True,
|
|||
|
stdout=subprocess.PIPE,
|
|||
|
stderr=subprocess.STDOUT,
|
|||
|
stdin=subprocess.PIPE # <20>ض<EFBFBD><D8B6><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ֵ
|
|||
|
)
|
|||
|
proc.stdin.close() # <20><>Ȼû<C8BB><C3BB><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>д<EFBFBD><D0B4>ڣ<EFBFBD><DAA3>Ǿر<CDB9><D8B1><EFBFBD><EFBFBD><EFBFBD>
|
|||
|
result = proc.stdout.read() # <20><>ȡcmdִ<64>е<EFBFBD><D0B5><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>byte<74><65><EFBFBD>ͣ<EFBFBD><CDA3><EFBFBD>Ҫdecode<64><65>
|
|||
|
proc.stdout.close()
|
|||
|
return result.decode(encoding="utf-8")
|
|||
|
|
|||
|
# <20>滻ͼ<E6BBBB><CDBC>
|
|||
|
def replacePng(target,appName):
|
|||
|
# <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD>·<EFBFBD><C2B7><EFBFBD>µ<EFBFBD>ͼ<EFBFBD><CDBC>
|
|||
|
cmdRes = exec(f"find /home/king/android_src/mikrom12_gitlab/packages/ -name {target}")
|
|||
|
filePathList = cmdRes.split("\n")
|
|||
|
curpath=os.getcwd()
|
|||
|
# <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ѵ<EFBFBD><D1B5>Ľ<EFBFBD><C4BD><EFBFBD>
|
|||
|
for filepath in filePathList:
|
|||
|
if filepath=="":
|
|||
|
continue
|
|||
|
# Ϊ<>˱<EFBFBD><CBB1><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>Ӧ<EFBFBD>õ<EFBFBD>ͬ<EFBFBD><CDAC><EFBFBD>ز<EFBFBD>ͼ<EFBFBD>꣬<EFBFBD><EAA3AC><EFBFBD><EFBFBD>ʹ<EFBFBD><CAB9>appName<6D><65><EFBFBD><EFBFBD>һ<EFBFBD><D2BB>
|
|||
|
if appName not in filepath:
|
|||
|
continue
|
|||
|
print('Found file: ' + filepath)
|
|||
|
# <20>Ƚ<EFBFBD><C8BD>ļ<EFBFBD><C4BC><EFBFBD><EFBFBD>б<EFBFBD><D0B1><EFBFBD>
|
|||
|
shutil.copy(filepath,filepath+".bak")
|
|||
|
# Ȼ<><EFBFBD>ǰĿ¼<C2BC><D7BC><EFBFBD>õ<EFBFBD><C3B5>滻<EFBFBD>ļ<EFBFBD><C4BC><EFBFBD><EFBFBD>ƽ<EFBFBD>ȥ
|
|||
|
replacePath=curpath+"/images/"+target
|
|||
|
# <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ļ<EFBFBD><C4BC><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ڣ<EFBFBD><DAA3><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ļ<EFBFBD><C4BC><EFBFBD><EFBFBD>滻
|
|||
|
if os.path.exists(replacePath)==False:
|
|||
|
print("not found replace file:",replacePath)
|
|||
|
break
|
|||
|
shutil.copy(replacePath, filepath)
|
|||
|
|
|||
|
# ʹ<>ñ<EFBFBD><C3B1>ݵ<EFBFBD><DDB5>ļ<EFBFBD><C4BC><EFBFBD>ԭ<EFBFBD><D4AD>ͼ<EFBFBD><CDBC>
|
|||
|
def unReplacePng(target):
|
|||
|
# <20><><EFBFBD><EFBFBD>Ŀ<EFBFBD><C4BF><EFBFBD>ļ<EFBFBD>
|
|||
|
cmdRes = exec(f"find /home/king/android_src/mikrom12_gitlab/frameworks/base/packages/ -name {target}")
|
|||
|
filePathList = cmdRes.split("\n")
|
|||
|
# <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>н<EFBFBD><D0BD><EFBFBD>
|
|||
|
for filepath in filePathList:
|
|||
|
if filepath=="":
|
|||
|
continue
|
|||
|
print('Found file: ' + filepath)
|
|||
|
# <20><><EFBFBD><EFBFBD><EFBFBD>ļ<EFBFBD><C4BC><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ڣ<EFBFBD><DAA3><EFBFBD><EFBFBD><EFBFBD><EFBFBD>仹ԭ
|
|||
|
bakfile=filepath + ".bak"
|
|||
|
if os.path.exists(bakfile):
|
|||
|
shutil.copy(bakfile, filepath)
|
|||
|
print("unReplace file:",bakfile)
|
|||
|
|
|||
|
def main():
|
|||
|
# <20>滻Ϊ<E6BBBB><CEAA><EFBFBD>ز<EFBFBD>
|
|||
|
replacePng('ic_launcher_settings.png',"Setting")
|
|||
|
replacePng('ic_contacts_launcher.png',"Contacts")
|
|||
|
replacePng('ic_launcher_calendar.png',"Calendar")
|
|||
|
|
|||
|
# <20><>ԭ<EFBFBD>ز<EFBFBD>
|
|||
|
# unReplacePng('ic_launcher_settings.png')
|
|||
|
# unReplacePng('ic_contacts_launcher.png')
|
|||
|
# unReplacePng('ic_launcher_calendar.png')
|
|||
|
|
|||
|
if __name__ == '__main__':
|
|||
|
main()
|