Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #!/usr/bin/python
- ### HALF ASSED ONE PLUS ONE TOOLKIT v1.0 OFFICIAL RELEASE!
- ##### AUTHOR: vvn
- ##### RELEASE DATE: august 18, 2014
- ##### this is a very half-assed project and i cannot guarantee fast or frequent updates.
- ##### USE AT YOUR OWN RISK. i am not responsible for any damage to your device.
- ##### IMPORTANT!!! ***requires pyadb.py (also on my pastebin)***
- ##### GET PYADB (pyadb.py) HERE: http://pastebin.com/g2Z08JN1
- ##### for #8 custom recovery flash, download files (filehost + filename) and put in script directory:
- ##### filehost: notworth (dot) it / opo / opotoolkit /
- ##### filenames: twrp.img, philz.img, cwm.img
- ##### download ZIP file containing scripts, superSU, custom recoveries, and adb/fastboot binaries for OSX/windows:
- ##### filehost: notworth (dot) it / opo /
- ##### filename: 1plus1-halfassedtoolkit_v1.zip
- ##### for #8 flash options, download + unzip (filehost + filename):
- ##### filehost: notworth (dot) it / opo /
- ##### filenames: XNPH25R.zip, XNPH30O.zip
- ##### unzip files as subdirectories inside script location: /scripthome/XNPH25R /scripthome/XNPH30O
- ##### to report bugs or suggestions, email me: vvn (at) eudemonics (dot) org
- ##### feel free to share, modify, or whatever.
- ##### you can use this with any android device, not just the oneplus one. just change out the files.
- ##### some credit would be nice since i worked pretty hard on this.
- ##### but what would be even better is if you bought my EP!
- ##### stream and buy it here: dreamcorp.bandcamp.com or any major online digital retailer
- ##### to run, save this file as opotoolkit.py and save pyadb.py (link above) in same directory
- ##### make sure you have the android SDK installed.
- ##### download android SDK here: https://developer.android.com/sdk/
- ##### you can either put the scripts in the same directory as your android SDK,
- ##### or create an environmental path variable for your android SDK directory
- ##### python 2.7 is also required. download python here: https://www.python.org/downloads/
- import subprocess, sys, re, os, os.path, time, datetime
- from pyadb import *
- def main():
- """menu output user input"""
- quotes = [
- '\nvvn@notworth.it\n'
- ]
- print ('''\033[34m
- *************************************************
- *** \033[36mHALF-ASSED ONE PLUS ONE TOOLKIT v1.0 BETA \033[34m***
- ******************** \033[35mby vvn \033[34m*********************
- ************* \033[32mUSE AT YOUR OWN RISK! \033[34m*************
- ********** \033[37msupport my work: buy my EP! \033[34m**********
- ********* \033[37mhttp://dreamcorp.bandcamp.com \033[34m*********
- *************************************************\033[0m\n''')
- print("\033[33mDEVICE MUST BE CONNECTED VIA USB WITH ANDROID DEBUGGING ENABLED. \033[0m\n")
- print ('''\033[32mMAIN MENU:\033[0m
- -\033[31m[1]\033[37m reboot into android, bootloader, or recovery\033[0m
- -\033[31m[2]\033[37m wipe device\033[0m
- -\033[31m[3]\033[37m boot once into custom recovery without flashing\033[0m
- -\033[31m[4]\033[37m install or uninstall APK\033[0m
- -\033[31m[5]\033[37m copy files between computer and device, or sync\033[0m
- -\033[31m[6]\033[37m backup or restore device\033[0m
- -\033[31m[7]\033[37m root device and/or install ZIP in fastboot\033[0m
- -\033[31m[8]\033[37m unlock bootloader and/or flash custom image\033[0m
- -\033[31m[9]\033[37m run shell command on device\033[0m
- -\033[31m[0]\033[37m quit \033[0m\n''')
- global option
- option = raw_input('Select an option 0-9 --> ')
- while not re.search(r'^[0-9]$', option):
- option = raw_input('Invalid selection. Please select an option 0-9 --> ')
- if option:
- obj = pyADB()
- if option == '1': #reboot
- rboption = raw_input("please enter 1 to reboot into android. enter 2 to reboot to bootloader. enter 3 to reboot to recovery. --> ")
- while not re.search(r'^[123]$', rboption):
- rboption = raw_input("invalid selection. please enter 1 to reboot into android, 2 for bootloader, and 3 for recovery. --> ")
- rbtype = "android"
- if rboption == '1':
- rbtype = "android"
- elif rboption == '2':
- rbtype = "bootloader"
- elif rboption == '3':
- rbtype ="recovery"
- checkdev = obj.get_state()
- listdev = obj.attached_devices()
- fastdev = obj.fastboot_devices()
- if checkdev is not None:
- print("adb get-status: " + str(checkdev) + "\n")
- print("rebooting via ADB..\n")
- obj.reboot(rbtype)
- time.sleep(0.9)
- main()
- elif listdev >= 0:
- print("adb devices: " + str(listdev) + "\n")
- print("rebooting via ADB...\n")
- obj.reboot(rbtype)
- time.sleep(0.9)
- main()
- elif listdev == 0 and fastdev is not None:
- print("adb devices: " + str(listdev) + "\n")
- print("rebooting via fastboot..\n")
- if rboption == '3':
- rbtype = "bootloader"
- obj.fastreboot(rbtype)
- time.sleep(0.9)
- main()
- elif [[ len(str(fastdev)) > 5 | fastdev > 0 ]] and fastdev is not None:
- print("fastboot devices: " + str(fastdev) + "\n")
- print("rebooting via fastboot...\n")
- if rboption == '3':
- rbtype = "bootloader"
- obj.fastreboot(rbtype)
- time.sleep(0.9)
- main()
- else:
- print("rebooting via fastboot...\n")
- if rboption == '3':
- rbtype = "bootloader"
- fastreboot = obj.fastreboot(rbtype)
- if not fastreboot:
- print("rebooting via ADB after fastboot... \n")
- obj.reboot(rtype)
- if "error" in str(fastreboot):
- print("rebooting via fastboot second time...\n")
- obj.fastreboot(rbtype)
- time.sleep(0.9)
- main()
- elif option == '2': #wipe
- print("\033[35m***WIPING SOME PARTITIONS WILL ERASE YOUR DATA.***\n please make sure to back up any important data before proceeding!\n\n")
- print('''\033[36mCHOOSE AN OPTION 1-8:\033[32m\n
- [1]\033[37m perform a full system wipe [system, data, and cache partitions]\033[32m
- [2]\033[37m wipe only the system partition\033[32m
- [3]\033[37m wipe only the data partition\033[32m
- [4]\033[37m wipe only the cache partition\033[32m
- [5]\033[37m wipe only the boot partition\033[32m
- [6]\033[37m wipe only the recovery partition\033[32m
- [7]\033[37m flash device to factory images [flash system, boot, and recovery]\033[32m
- [8]\033[37m return to main menu\n\n\033[0m''')
- confirmwipe = raw_input("please enter an option 1-8 --> ")
- while not re.search(r'^[1-8]$', confirmwipe):
- confirmwipe = raw_input('not a valid option. please enter a selection between 1-8 from above choices -->')
- if confirmwipe == '1':
- obj.wipe('all')
- raw_input("press ENTER to continue.")
- time.sleep(0.9)
- main()
- elif confirmwipe == '2':
- obj.wipe('system')
- raw_input("press ENTER to continue.")
- time.sleep(0.9)
- main()
- elif confirmwipe == '3':
- obj.wipe('data')
- raw_input("press ENTER to continue.")
- time.sleep(0.9)
- main()
- elif confirmwipe == '4':
- obj.wipe('cache')
- raw_input("press ENTER to continue.")
- time.sleep(0.9)
- main()
- elif confirmwipe == '5':
- obj.wipe('boot')
- raw_input("press ENTER to continue.")
- time.sleep(0.9)
- main()
- elif confirmwipe == '6':
- obj.wipe('recovery')
- raw_input("press ENTER to continue.")
- time.sleep(0.9)
- main()
- elif confirmwipe == '7':
- obj.wipe('flashall')
- raw_input("press ENTER to continue.")
- time.sleep(0.9)
- main()
- elif confirmwipe == '8':
- time.sleep(0.9)
- main()
- else:
- print("there was a problem connecting to the device. returning to menu..\n")
- time.sleep(0.9)
- main()
- elif option == '3': #boot custom recovery
- recovery = raw_input("enter 1 for TWRP, 2 for ClockworkMod, or 3 for Philz recovery --> ")
- while not re.search(r'^[1-3]$', recovery):
- recovery = raw_input("invalid selection. please choose 1 for TWRP, 2 for CWM, or 3 for Philz --> ")
- obj.reboot("bootloader")
- if recovery == '1':
- obj.bootimg("twrp.img")
- elif recovery == '2':
- obj.bootimg("cwm.img")
- elif recovery == '3':
- obj.bootimg("philz.img")
- else:
- print("unable to connect to device.\n")
- time.sleep(0.9)
- main()
- elif option == '4': #install or uninstall APK
- whichinstall = raw_input("please enter 1 to install, 2 to uninstall, or 3 to return to main menu. --> ")
- while not re.search(r'^[1-3]$', whichinstall):
- whichinstall = raw_input("invalid selection. please enter 1 to install, 2 to uninstall, or 3 to return to main menu. --> ")
- if not os.path.exists('apps'):
- os.mkdirs('apps')
- if whichinstall == '1':
- getapk = raw_input("place the APK file to install in the \"apps\" subdirectory, then type the filename --> ")
- apkfile = os.path.join('apps', getapk)
- while not os.path.isfile(apkfile):
- print("\033[37mfile does not exist. please make sure the APK file is in the \"apps\" subdirectory.\033[0m\n")
- getapk = raw_input("enter valid filename for the APK you want to install -->")
- apkfile = os.path.join('apps', getapk)
- print("installing \033[36m" + getapk + "\033[0m...")
- obj.install(apkfile)
- raw_input("press ENTER to continue...")
- time.sleep(0.9)
- main()
- if whichinstall == '2':
- getunapk = raw_input("place the APK file you wish to uninstall in the \"apps\" subdirectory, then enter filename --> ")
- unapkfile = os.path.join('apps', getunapk)
- while not os.path.isfile(unapkfile):
- print("\033[37mfile does not exist. please make sure the APK file is in the \"apps\" subdirectory.\033[0m\n")
- getunapk = raw_input("enter valid filename for the APK you want to uninstall -->")
- unapkfile = os.path.join('apps', getunapk)
- keepcheck = raw_input("would you like to keep your app data? Y or N --> ")
- while not re.search(r'^[nyNY]$', keepcheck):
- keepcheck = raw_input("invalid selection. please enter Y to keep app data or N to erase --> ")
- keepargs = "no"
- if re.match(r'(?i)Y', keepcheck):
- keepargs = "keep"
- print("uninstalling \033[36m" + getunapk + "\033[0m...")
- obj.uninstall(unapkfile, keepargs)
- uninstcmd = "pm uninstall -k " + unapkfile
- obj.shell(uninstcmd)
- raw_input("press ENTER to continue...")
- time.sleep(0.9)
- main()
- if whichinstall == '3':
- main()
- else:
- print("could not connect to device.\n")
- time.sleep(0.9)
- main()
- elif option == '5': #copy
- copytype = raw_input("to push file from computer to device, enter T. to pull file from device to computer, enter F. to sync, enter S --> ")
- matchT = re.search(r'(?i)T', copytype)
- matchF = re.search(r'(?i)F', copytype)
- matchS = re.search(r'(?i)S', copytype)
- while not re.search(r'^[(?i)T|(?i)F|(?i)S]$', copytype):
- copytype = raw_input("invalid option. please enter T to push file, F to pull file, or S to sync --> ")
- if matchT:
- getpushfile = raw_input("please enter relative path for the file or directory on your computer to copy --> ")
- while not os.path.exists(getpushfile):
- getpushfile = raw_input("file does not exist. please enter valid path --> ")
- getpushremote = raw_input("please enter destination path for copied file(s) on the device --> ")
- obj.push(getpushfile, getpushremote)
- raw_input("press ENTER to continue...")
- elif matchF:
- getpullfile = raw_input("please enter path for the file or directory on your device to copy --> ")
- getpulllocal = raw_input("please enter destination path for copied file(s) on your computer --> ")
- if not os.path.exists(getpulllocal):
- os.mkdirs(getpulllocal)
- obj.pull(getpullfile, getpulllocal)
- raw_input("press ENTER to continue...")
- elif matchS:
- syncargs = raw_input("enter 1 to set sync directory, or 2 to sync the default system and data directories. --> ")
- while not re.search(r'^[12]$', syncargs):
- syncargs = raw_input("invalid selection. please enter 1 to set sync directory, or 2 to use default. --> ")
- if syncargs == '1':
- syncdir = raw_input("please enter path to the local directory you wish to sync --> ")
- while not os.path.exists(syncdir):
- syncdir = raw_input("the directory you entered does not exist. please enter valid path --> ")
- obj.sync(syncdir)
- raw_input("press ENTER to continue...")
- elif syncargs == '2':
- obj.sync()
- raw_input("press ENTER to continue...")
- else:
- print("could not connect to device.\n")
- else:
- print("could not connect to device.\n")
- time.sleep(0.9)
- main()
- elif option == '6': #backup
- whichbackup = raw_input("to backup, enter 1. to restore, enter 2 --> ")
- while not re.search(r'^[12]$', whichbackup):
- whichbackup = raw_input("invalid selection. please enter 1 to backup or 2 to restore. --> ")
- if whichbackup == '1':
- backupfile = 'backup-' + str(datetime.date.today()) + '.ab'
- obj.backup(backupfile)
- elif whichbackup == '2':
- restorefile = raw_input("please enter path to backup file on your computer --> ")
- while not os.path.isfile(restorefile):
- restorefile = raw_input("file does not exist. please enter valid path --> ")
- obj.restore(restorefile)
- time.sleep(0.9)
- main()
- elif option == '7': #root
- def suroot():
- superSU = 'UPDATE-SuperSU-v2.01.zip'
- remotesuperSU = '/sdcard/UPDATE-SuperSU-v2.01.zip'
- obj.push(superSU, remotesuperSU)
- obj.reboot("bootloader")
- time.sleep(0.9)
- obj.bootimg("twrp.img")
- print("on device, choose INSTALL from TWRP menu, then select file \033[36m" + superSU + "\033[0m in the \033[36m/sdcard\033[0m directory.\n")
- raw_input("if install is successful, select REBOOT from TWRP menu on device. press ENTER to continue.")
- def towroot():
- obj.install("apps/tr.apk")
- print("\033[36m\nif APK installed successfully, locate TR [towelroot] in app drawer on device and run.\n\033[0m")
- raw_input("tap on MAKE IT RAIN. the results should appear shortly. follow instructions on device, then press ENTER to continue..")
- print("\033[36mif the firmware release date for your device is before june 2014, there is a chance the towelroot exploit may work.\n")
- print("\033[32mhowever, superSU is a much safer and more widely confirmed root method for the oneplus one. ATTEMPT AT YOUR OWN RISK!\033[0m\n\n")
- rootcheck = raw_input("which root method would you like to try? enter 1 for towelroot or 2 for superSU [recommended for oneplus one]. --> ")
- while not re.search(r'^[12]$', rootcheck):
- rootcheck = raw_input("invalid selection. enter 1 to install towelroot exploit, or 2 to install superSU package. --> ")
- if rootcheck == '1':
- towroot()
- trysuroot = raw_input("if towelroot failed, press 1 to launch superSU method. otherwise, press ENTER to return to main menu. --> ")
- if trysuroot == '1':
- suroot()
- time.sleep(0.9)
- main()
- else:
- time.sleep(0.9)
- main()
- elif rootcheck == '2':
- bootcustom = raw_input("press 1 to install superSU in TWRP recovery, or 2 to install in fastboot [lower success rate]. --> ")
- while not re.search(r'^[12]$', bootcustom):
- bootcustom = raw_input("invalid choice. please enter 1 to load TWRP or 2 for fastboot. --> ")
- if bootcustom == '1':
- suroot()
- elif bootcustom == '2':
- updatewhich = raw_input("to try installing superSU in fastboot, press 1. else, enter name of ZIP file to install --> ")
- if updatewhich == '1':
- print("\033[35mattempting to install superSU via fastboot...\n\033[0m")
- obj.update(superSU)
- failsu = raw_input("if installation failed, press 1 to try sideload method. otherwise, press ENTER to continue...")
- if failsu == '1':
- obj.fastreboot("android")
- time.sleep(0.9)
- raw_input("\033[32mmake sure your computer is authorized to access your device over ADB, then press ENTER.\033[0m")
- obj.reboot("recovery")
- raw_input("in recovery menu on device, please select APPLY UPDATE, then APPLY FROM ADB. press ENTER when ready.")
- obj.sideload("UPDATE-SuperSU-v2.01.zip")
- superfail = raw_input("if update successful, choose REBOOT SYSTEM from device menu then press ENTER key. else, press 1 to install superSU from TWRP -->" )
- if superfail == '1':
- suroot()
- else:
- obj.get_state()
- time.sleep(0.9)
- main()
- else:
- print("attempting to install " + updatewhich + "...\n\n")
- while not os.path.isfile(updatewhich):
- updatewhich = raw_input("invalid file path. please enter correct path of ZIP file to install --> ")
- obj.update(updatewhich)
- raw_input("please press ENTER to continue...")
- else:
- print("failed to connect to device. returning to main menu.. \n\n")
- else:
- print("failed to connect to device. returning to main menu.. \n\n")
- time.sleep(0.9)
- main()
- elif option == '8': #flash stock images/partitions
- def flashmenu():
- print ('''\n\033[35mSTOCK IMAGES AVAILABLE TO FLASH - THIS WILL REPLACE YOUR CURRENT PARTITION!\n
- \033[36m***IF POSSIBLE, FLASH IN SEQUENTIAL ORDER - BOOT.IMG SHOULD GO FIRST***\n
- \033[33mLATEST UPDATE XNPH30O SELECTIONS IN YELLOW\n\033[0m
- -\033[31m[1]\033[37m XNPH25R stock BOOT.IMG \033[0m
- -\033[31m[2]\033[37m XNPH25R stock USERDATA(_64).IMG \033[35m[WIPES USER DATA!]\033[0m
- -\033[31m[3]\033[37m XNPH25R stock SYSTEM.IMG \033[0m
- -\033[31m[4]\033[37m XNPH25R stock RECOVERY.IMG \033[0m
- -\033[31m[5]\033[37m XNPH25R stock CACHE.IMG \033[0m
- -\033[31m[6]\033[37m XNPH25R stock radio, modem, aboot, & more \033[34m[flash-radio.sh]\033[0m
- -\033[31m[7]\033[33m XNPH30O stock radio, modem, sbl1, aboot \033[34m[flash-extras.sh]\033[0m
- -\033[31m[8]\033[33m XNPH30O stock OTA UPDATE #1 \033[0m
- -\033[31m[9]\033[33m XNPH30O stock OTA UPDATE #2 - FLASH UPDATE #1 FIRST! \033[0m
- -\033[31m[0]\033[37m quit\033[0m\n''')
- flashsel = raw_input("\033[32mselect a choice between 0 through 9 from menu \033[0m--> ")
- while not re.search(r'^[0-9]$', flashsel):
- flashsel = raw_input("invalid selection. please choose an option between 0 through 9 --> ")
- print("\n\033[34mrebooting into bootloader...\033[0m\n")
- obj.reboot("bootloader")
- if flashsel == '1':
- obj.flashf("boot", "XNPH25R/boot.img")
- raw_input("press ENTER key to continue...")
- flashmenu()
- elif flashsel == '2':
- whichsize = raw_input("IMPORTANT!! choose correct storage capacity: enter 1 for 16gb device, or 2 for 64gb device. --> ")
- while not re.search(r'^[12]$', whichsize):
- whichsize = raw_input("invalid selection. enter 1 for 16gb device, or 2 for 64gb device. --> ")
- if whichsize == '1':
- obj.flashf("userdata", "XNPH25R/userdata.img")
- elif whichsize == '2':
- obj.flashf("userdata", "XNPH25R/userdata_64G.img")
- else:
- print("ERROR: unable to connect to device.\n")
- raw_input("press ENTER key to return to flash menu...")
- flashmenu()
- elif flashsel == '3':
- obj.flashf("system", "XNPH25R/system.img")
- raw_input("press ENTER key to continue...")
- flashmenu()
- elif flashsel == '4':
- obj.flashf("recovery", "XNPH25R/recovery.img")
- raw_input("press ENTER key to continue...")
- flashmenu()
- elif flashsel == '5':
- obj.flashf("cache", "XNPH25R/cache.img")
- raw_input("press ENTER key to continue...")
- flashmenu()
- elif flashsel == '6':
- subprocess.check_call(["./flash-radio.sh"], cwd="/XNPH25R")
- raw_input("press ENTER key to continue...")
- flashmenu()
- elif flashsel == '7':
- subprocess.check_call(["./flash-extras.sh"], cwd="/XNPH30O")
- raw_input("press ENTER key to continue...")
- flashmenu()
- elif flashsel == '8':
- obj.update("XNPH30O/XNPH30O-update1-signed.zip")
- failupd = raw_input("if update failed, press 1 to try sideload option. otherwise, press ENTER key to continue...")
- if failupd == '1':
- obj.fastreboot("android")
- raw_input("make sure your device is unlocked and your PC is authenticated for ADB access. press ENTER to continue.")
- print("\033[32mpushing first XNPH30O OTA update file to device..\033[0m\n")
- obj.push("XNPH30O/XNPH30O-update1-signed.zip", "/sdcard/XNPH30O-update1-signed.zip")
- raw_input("press ENTER to reboot into recovery.")
- obj.reboot("recovery")
- print("choose APPLY UPDATE from recovery menu and select APPLY FROM ADB.\n\n")
- raw_input("press ENTER to install the *first* XNPH30O OTA update now.")
- obj.sideload("XNPH30O/XNPH30O-update1-signed.zip")
- failside = raw_input("if update did not succeed, press 1 to install from device. otherwise, press ENTER to continue..")
- if failside == '1':
- print("choose APPLY UPDATE from recovery menu, then select CHOOSE FROM INTERNAL STORAGE.\n")
- print("select XNPH30O-update1-signed.zip from root of SDCARD directory and install file.\n\n")
- print("\033[35mif update failed, return to main menu and select option 3 to boot into custom recovery.\033[0m\n\n")
- menusel = raw_input("press 1 if update was successful, or 2 to return to main menu.")
- while not re.search(r'^[12]$',menusel):
- menusel = raw_input("invalid selection. press 1 for flash menu, or 2 to return to main menu.")
- if menusel == '1':
- obj.shell("rm -rf /sdcard/XNPH30O-update1-signed.zip")
- time.sleep(0.9)
- flashmenu()
- elif menusel == '2':
- time.sleep(0.9)
- main()
- else:
- print("error connecting to device. returning to main menu...\n")
- time.sleep(0.9)
- main()
- else:
- obj.shell("rm -rf /sdcard/XNPH30O-update1-signed.zip")
- print("\033[32mreturning to flash menu..\033[0m\n\n")
- else:
- print("\033[32mreturning to flash menu..\033[0m\n\n")
- time.sleep(0.9)
- flashmenu()
- elif flashsel == '9':
- obj.update("XNPH30O/XNPH30O-update2-signed.zip")
- failupd = raw_input("if update failed, press 1. otherwise, press ENTER key to continue. --> ")
- if failupd == '1':
- obj.fastreboot("android")
- obj.push("XNPH30O/XNPH30O-update2-signed.zip", "/sdcard/XNPH30O-update2-signed.zip")
- time.sleep(2.5)
- print("\033[34mrebooting into recovery...\n\033[0m")
- obj.reboot("recovery")
- print("choose APPLY UPDATE from recovery menu and select APPLY FROM ADB.\n\n")
- raw_input("press ENTER to install the *second* XNPH30O OTA update now.")
- obj.sideload("XNPH30O/XNPH30O-update2-signed.zip")
- failside = raw_input("if update failed, press 1 to update from device storage. otherwise, press ENTER to continue. --> ")
- if failside == '1':
- print("choose APPLY UPDATE from recovery menu, then select CHOOSE FROM INTERNAL STORAGE.\n")
- print("select XNPH30O-update2-signed.zip from root of SDCARD directory and install file.\n\n")
- print("\033[35mif update fails again, return to main menu and reboot into custom recovery.\033[0m\n\n")
- menusel = raw_input("press 1 to return to flash menu, or 2 to return to main menu. --> ")
- while not re.search(r'^[12]$',menusel):
- menusel = raw_input("invalid selection. press 1 for flash menu, or 2 to return to main menu. --> ")
- if menusel == '1':
- time.sleep(0.9)
- flashmenu()
- elif menusel == '2':
- time.sleep(0.9)
- main()
- else:
- print("error connecting to device. returning to main menu...\n")
- time.sleep(0.9)
- main()
- else:
- obj.shell("rm -rf /sdcard/XNPH30O-update2-signed.zip")
- print("\033[32mreturning to flash menu..\033[0m\n\n")
- time.sleep(0.9)
- flashmenu()
- else:
- print("\033[32mreturning to flash menu..\033[0m\n\n")
- time.sleep(0.9)
- flashmenu()
- flashmenu()
- elif flashsel == '0':
- main()
- else:
- print("unable to connect to device.\n")
- def recovflash():
- print("\n")
- flashcont = raw_input("select 1 to continue flashing recovery. select 2 to flash a stock partition image. select 3 to return to flash menu. --> ")
- while not re.search(r'^[123]$', flashcont):
- flashcont = raw_input("invalid selection. select 1 to continue flashing recovery. select 2 to flash a stock partition image. select 3 to return to flash menu. --> ")
- if flashcont == '1':
- recovchoice = raw_input("enter 1 for TWRP, 2 for ClockworkMod, or 3 for Philz recovery --> ")
- while not re.search(r'^[1-3]$', recovchoice):
- recovchoice = raw_input("invalid selection. please choose 1 for TWRP, 2 for CWM, or 3 for Philz --> ")
- obj.reboot("bootloader")
- if recovchoice == '1':
- obj.flashf("recovery","twrp.img")
- elif recovchoice == '2':
- obj.flashf("recovery","cwm.img")
- elif recovchoice == '3':
- obj.flashf("recovery","philz.img")
- else:
- print("unable to connect to device.\n")
- elif flashcont == '2':
- flashmenu()
- elif flashcont == '3':
- main()
- else:
- print("unable to connect to device.\n")
- time.sleep(0.9)
- flashmenu()
- print("\n\033[36mFlashing a CUSTOM RECOVERY requires an UNLOCKED BOOTLOADER.\033[0m\n")
- print("\033[33m***UNLOCKING YOUR BOOTLOADER WILL WIPE YOUR DEVICE!!!***\033[0m\n")
- print("\033[35mIF YOUR DEVICE HOLDS IMPORTANT DATA, BACK UP DEVICE BEFORE YOU CONTINUE!\033[0m\n")
- print("\033[35mIMPORTANT: if you have already unlocked your device and are re-unlocking, you MUST be running the XNPH25R stock firmware or older.\n")
- print("\033[32mif you are running XNPH30O or newer, YOUR RE-UNLOCK ATTEMPTS WILL FAIL. you must return to the previous menu and flash the XNPH25R images to your device.\033[0m\n")
- bunlock = raw_input("enter 1 to continue unlocking bootloader. enter 2 to skip to flashing custom recovery or images.\n enter 3 to re-lock bootloader. or enter 4 to return to menu. --> ")
- while not re.search(r'^[123]$', bunlock):
- bunlock = raw_input("invalid selection. enter 1 to unlock bootloader and wipe device. enter 2 to skip to flashing custom recovery or images.\n enter 3 to re-lock bootloader. or enter 4 to return to menu. --> ")
- if bunlock == '1':
- obj.reboot("bootloader")
- obj.unlockboot()
- print("your device should reboot after successfully unlocking the bootloader.\n")
- raw_input("press ENTER to continue...")
- recovflash()
- elif bunlock == '2':
- recovflash()
- elif bunlock == '3':
- print("\033[33mREMINDER: to unlock your device again, you MUST downgrade to firmware release XNPH25R or earlier!\033[0m\n")
- btlockconfirm = raw_input("press ENTER to continue, or 1 to exit to the previous menu --> ")
- if btlockconfirm == '1':
- flashmenu()
- else:
- obj.reboot("bootloader")
- obj.lockboot()
- raw_input("press ENTER to reboot your device")
- obj.fastreboot("android")
- else:
- flashmenu()
- time.sleep(0.9)
- main()
- elif option == '9': #run shell command
- shellcmd = raw_input("enter shell command --> ")
- while shellcmd:
- obj.shell(shellcmd)
- shellcmd = raw_input("enter another shell command, or press ENTER to continue --> ")
- time.sleep(0.9)
- main()
- elif option == '0': #quit
- sys.exit()
- else:
- print '\n\033[32man unhandled exception occurred. returning to main menu..\033[0m\n'
- time.sleep(0.9)
- main()
- main()
- sys.exit()
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement