项目备份,MIUI优化工具
import os import time # 欢迎语 def print_welcome(): print("欢迎使用fast玩机2.0经济版!") # 执行ADB命令 def run_adb_command(command): os.system(f'adb {command}') # 显示进度条 def show_progress(total, current): progress = int((current / total) * 100) print(f'进度:{progress}%') # ADB命令,并显示进度条 def run_adb_command_with_progress(command): process = os.popen(f'adb {command}') output = process.readlines() total_lines = len(output) for i, line in enumerate(output): time.sleep(0.1) # 模拟耗时操作 show_progress(total_lines, i+1) print(line.strip()) process.close() # 刷入第三方recovery def flash_custom_recovery(): recovery_image_path = input("请输入要刷入的第三方recovery镜像文件路径:") run_adb_command('reboot bootloader') run_adb_command_with_progress(f'fastboot flash recovery {recovery_image_path}') # 禁用系统更新 def disable_system_update(): run_adb_command('shell settings put global package_verifier_enable 0') run_adb_command('shell settings put global auto_update_mode 2') # 进入fastboot模式 def enter_fastboot_mode(): run_adb_command('reboot bootloader') # 优化系统动画 def optimize_animation(): run_adb_command('shell settings put global window_animation_scale 0.0') run_adb_command('shell settings put global transition_animation_scale 0.0') run_adb_command('shell settings put global animator_duration_scale 0.0') # 禁用系统应用 def disable_system_apps(package_names): for package_name in package_names: run_adb_command(f'shell pm disable {package_name}') # 设置系统进程为墓碑进程 def set_system_process_as_tombstone(process_name): run_adb_command(f'shell am set-tombstone {process_name}') # 禁用温控 def disable_thermal(): run_adb_command('shell setprop persist.sys.thermal-engine 0') # 解除锁屏密码 def remove_screen_lock(): run_adb_command('shell rm /data/system/gesture.key') # 恢复系统更新 def enable_system_update(): run_adb_command('shell settings put global auto_update_mode 0') # 恢复系统动画 def restore_animation(): run_adb_command('shell settings put global window_animation_scale 1.0') run_adb_command('shell settings put global transition_animation_scale 1.0') run_adb_command('shell settings put global animator_duration_scale 1.0') # 恢复禁用的系统应用 def enable_system_apps(package_names): for package_name in package_names: run_adb_command(f'shell pm enable {package_name}') # 恢复温控 def enable_thermal(): run_adb_command('shell setprop persist.sys.thermal-engine 1') # 恢复锁屏密码 def restore_screen_lock(): run_adb_command('shell rm -rf /data/system/gesture.key*') # 错误处理 def handle_error(): print("发生错误,请重试。") # 主程序 def main(): print_welcome() while True: print("请选择功能:") print("1. 刷入第三方recovery") print("2. 禁止系统更新") print("3. 进入fastboot模式") print("4. 流畅系统") print("5. 解除温控") print("6. 解除锁屏密码") print("7. 恢复系统更新") print("8. 恢复系统动画") print("9. 恢复禁用的系统应用") print("10. 恢复温控") print("11. 恢复锁屏密码") print("0. 退出程序") choice = input("请输入对应数字:") try: if choice == '1': flash_custom_recovery() elif choice == '2': disable_system_update() elif choice == '3': enter_fastboot_mode() elif choice == '4': optimize_animation() disable_system_apps(['com.android.camera', 'com.android.calendar', 'com.android.email']) set_system_process_as_tombstone('system_process') elif choice == '5': disable_thermal() elif choice == '6': remove_screen_lock() elif choice == '7': enable_system_update() elif choice == '8': restore_animation() elif choice == '9': enable_system_apps(['com.android.camera', 'com.android.calendar', 'com.android.email']) elif choice == '10': enable_thermal() elif choice == '11': restore_screen_lock() elif choice == '0': break else: print("无效的选择,请重新输入。\n") if __name__ == '__main__': print_welcome() while True: main()