Ejemplo n.º 1
0
    def restore_default_comma(self):
        print('Selected to restore Comma-Default theme. Continue?')
        print('Process is fully automagic!')
        if not is_affirmative():
            print('Not restoring...')
            time.sleep(1.5)
            self.backup_reinstaller_loop()

        os.system('cp {} {}'.format(BOOT_LOGO_PATH,
                                    self.backup_dir))  # Make Backup
        os.system('dd if=./{}/{}/{} of={}'.format(CONTRIB_THEMES,
                                                  self.selected_backup,
                                                  BOOT_LOGO_THEME_PATH,
                                                  BOOT_LOGO_PATH))  # Replace
        print(
            'Factory Boot Logo restored successfully! Custom file(s) backed up to {}\n'
            .format(self.backup_dir))

        os.system('mount -o remount,rw /system'
                  )  # /system read only, must mount as r/w
        os.system('mv /system/media/bootanimation.zip {}'.format(
            self.backup_dir))  # backup
        os.system(
            'cp ./{}/{}/bootanimation.zip /system/media/bootanimation.zip'.
            format(
                CONTRIB_THEMES,
                self.selected_backup,
            ))  # replace
        os.system('chmod 666 /system/media/bootanimation.zip')
        print(
            'Factory Boot Animation restored successfully! Custom file(s) backed up to {}\n'
            .format(self.backup_dir))
        print('Thank you come again!')
        exit()
Ejemplo n.º 2
0
    def backup_reinstall_function(self):      # Backuo re-installer program, prompts user on what they want to do
        while 1:
            options = list(BACKUP_OPTIONS)      # this only contains available options from self.get_available_options
            if not len(options):
                print('The selected backup has no resources available for your device! Try another.')
                time.sleep(2)
                return
        
            print('What resources do you want to install for the {} backup?'.format(self.selected_backup))
            for idx, theme in enumerate(options):
                print('{}. {}'.format(idx + 1, theme))
            indexChoice = int(input("Enter Index Value: "))
            indexChoice -= 1 

            selected_option = BACKUP_OPTIONS[indexChoice]

            if selected_option == 'Boot Logo':
                print('Selected to install the Boot Logo backup. Continue?')
                if not is_affirmative():
                    print('Not installing...')
                    time.sleep(1.5)
                    continue
                os.system('cp {} {}'.format(BOOT_LOGO_PATH, self.backup_dir))      # Make Backup
                os.system('dd if={}/{}/{} of={}'.format(BACKUPS_DIR, self.selected_backup, BOOT_LOGO_NAME, BOOT_LOGO_PATH))   # Replace
                print('\nBoot Logo re-installed successfully! Original backed up to {}'.format(self.backup_dir))
                print('Press enter to continue!')
                mark_self_installed()       # Create flag in /sdcard so auto installer knows there is a self installation
                input()
            elif selected_option == 'Boot Animation':
                print('Selected to install the Boot Animation backup. Continue?')
                if not is_affirmative():
                    print('Not installing...')
                    time.sleep(1.5)
                    continue
              
                os.system('mount -o remount,rw /system')  # /system read only, must mount as r/w
                os.system('mv /system/media/bootanimation.zip {}'.format(self.backup_dir))  # backup
                os.system('cp {}/{}/bootanimation.zip /system/media/bootanimation.zip'.format(BACKUPS_DIR, self.selected_backup))  # replace
                os.system('chmod 666 /system/media/bootanimation.zip')
                print('\nBoot Animation re-installed successfully! Original backed up to {}'.format(self.backup_dir))
                print('Press enter to continue!')
                mark_self_installed()       # Create flag in /sdcard so auto installer knows there is a self installation
                input()
            elif selected_option == 'OpenPilot Spinner':
                #Confirm user wants to install Spinner
                print('Selected to install the {} OP Spinner backup. Continue?'.format(self.selected_theme))
                if not is_affirmative():
                    print('Not installing...')
                    time.sleep(1.5)
                    continue
        
                #Check if there was a backup already this session to prevent accidental overwrites
                if path.exists('{}/spinner'.format(self.backup_dir)):                  
                    print('It appears you already made a spinner backup this session') 
                    print('continuing will overwrite last spinner backup!')
                    print('Would you like to continue and overwrite previous?')
                    if not is_affirmative():
                        print('Not installed, exiting session..... Please re-run program')
                        exit()      #Exit program if user does not want to overwrite, so they can start a new session
                else:
                    os.mkdir('{}/spinner'.format(self.backup_dir))

                #Ask user if their OP directory is custom (like arnepilot / dragonpilot)
                print('Do you have an OP fork with a custom directory name? (ex. arnepilot, dragonpilot)')  # Ask the user if their OP fork used a diffrent directory.
                if is_affirmative():  # Yes there is a custom OP dir
                    print('What is the OP directory name? (case matters, not including /data/)')
                    opdir = '/data/{}'.format(input('> ').strip('/'))  # get custom dir name, strip slashes for safety
                    print('Your openpilot directory is {}'.format(opdir))
                    input('*** Please enter to continue, or Ctrl+C to abort if this is incorrect! ***')
                else:
                    opdir = 'openpilot'                                #op directory is not custom so openpilot

                #Backup files
                os.system('mv /data/{}/selfdrive/assets/img_spinner_comma.png {}/spinner'.format(opdir, self.backup_dir)) #Backup logo
                os.system('mv /data/{}/selfdrive/assets/img_spinner_track.png {}/spinner'.format(opdir, self.backup_dir)) #backup sprinner track
                os.system('mv /data/{}/selfdrive/common/spinner.c {}/spinner'.format(opdir, self.backup_dir))             #backup spinner.c

                #Copy in new files
                os.system('cp {}/{}/spinner/img_spinner_comma.png /data/{}/selfdrive/assets'.format(BACKUPS_DIR, self.selected_backup, opdir)) #Replace logo
                os.system('cp {}/{}/spinner/img_spinner_track.png /data/{}/selfdrive/assets'.format(BACKUPS_DIR, self.selected_backup, opdir)) #Replace sprinner
                os.system('cp {}/{}/spinner/spinner.c /data/{}/selfdrive/common'.format(BACKUPS_DIR, self.selected_backup, opdir))             #Replace spinner.c

                #Final make new spinner & finish
                os.system('cd /data/{}/selfdrive/ui/spinner && make'.format(opdir))
                print('\n{} spinner re-installed successfully! Original backed up to {}'.format(opdir, self.backup_dir))
                print('Press enter to continue!')
                mark_self_installed()        # Create flag in /sdcard so auto installer knows there is a self installation
                input()
            elif selected_option == 'Additional Resources':  # additional features
                print('Additional Resources are not an active feature')
                time.sleep(5)
            elif selected_option == '-Main Menu-' or selected_option is None:
                return
            elif selected_option == '-Reboot-':
                print('Rebooting.... Enjoy your old theme!!!')
                os.system('am start -a android.intent.action.REBOOT') #create an android action to reboot
                exit()
            elif selected_option == '-Quit-':
                print('Thank you come again! You will see your changes next reboot!')
                exit()
Ejemplo n.º 3
0
    def install_function(
            self
    ):  # Self installer program, prompts user on what they want to do
        while 1:
            options = list(
                self.theme_options
            )  # this only contains available options from self.get_available_options
            if not len(options):
                print(
                    'The selected theme has no resources available for your device! Try another.'
                )
                time.sleep(2)
                return

            print('What resources do you want to install for the {} theme?'.
                  format(self.selected_theme))
            for idx, theme in enumerate(options):
                print('{}. {}'.format(idx + 1, theme))
            indexChoice = int(input("Enter Index Value: "))
            indexChoice -= 1

            selected_option = self.theme_options[indexChoice]

            if selected_option == 'Boot Logo':
                #Confirm user wants to install bootlogo
                print(
                    '\nSelected to install the {} Boot Logo. Continue?'.format(
                        self.selected_theme))
                if not is_affirmative():
                    print('Not installing...')
                    time.sleep(1.5)
                    continue

                #Check if there was an Boot logo backup already this session to prevent accidental overwrites
                #Returns true if okay to proceed. Gets self.backup_dir & asset type name
                if backup_overide_check(self.backup_dir, 'logo') == True:
                    exit()

                #Backup & install new
                os.system('cp {} {}/logo'.format(
                    BOOT_LOGO_PATH, self.backup_dir))  # Make Backup
                os.system('dd if={}/{}/{} of={}'.format(
                    CONTRIB_THEMES, self.selected_theme, BOOT_LOGO_THEME_PATH,
                    BOOT_LOGO_PATH))  # Replace
                print(
                    '\nBoot Logo installed successfully! Original file(s) backed up to {}/logo'
                    .format(self.backup_dir))
                mark_self_installed(
                )  # Create flag in /sdcard so auto installer knows there is a self installation
                print('Press enter to continue!')
                input()

            elif selected_option == 'OpenPilot Spinner':
                ##Confirm user wants to install Spinner
                print('\nSelected to install the {} OP Spinner. Continue?'.
                      format(self.selected_theme))
                if not is_affirmative():
                    print('Not installing...')
                    time.sleep(1.5)
                    continue

                ##Check if there was a spinner backup already this session to prevent accidental overwrites
                #Returns false if okay to proceed. Gets self.backup_dir & asset type name
                if backup_overide_check(self.backup_dir, 'spinner') == True:
                    exit()

                ##Ask user if their OP directory is custom (like arnepilot / dragonpilot)
                opdir = op_dir_finder()

                ##Ask user if they want @shaneSmiskol rave rainbow spinner
                raveRainbow = ask_rainbow_spinner()

                ##Backup files
                os.system(
                    'mv /data/{}/selfdrive/assets/img_spinner_comma.png {}/spinner'
                    .format(opdir, self.backup_dir))  #Backup logo
                os.system(
                    'mv /data/{}/selfdrive/assets/img_spinner_track.png {}/spinner'
                    .format(opdir, self.backup_dir))  #backup spinner track
                os.system(
                    'mv /data/{}/selfdrive/common/spinner.c {}/spinner'.format(
                        opdir, self.backup_dir))  #backup spinner.c

                ##Copy in new files
                # Check if theme contributer provided a spinner logo
                if path.exists('{}/{}/spinner/img_spinner_comma.png'.format(
                        CONTRIB_THEMES,
                        self.selected_theme)):  #Contibuter Did Provide
                    os.system(
                        'cp {}/{}/spinner/img_spinner_comma.png /data/{}/selfdrive/assets'
                        .format(CONTRIB_THEMES, self.selected_theme,
                                opdir))  #Replace spinner logo supplied custom
                else:  #Contibuter Did Not Provide
                    os.system(
                        'cp ./support/spinner/img_spinner_comma.png /data/{}/selfdrive/assets'
                        .format(opdir))  #Replace spinner logo with standard

                # Check if theme contributer provided a spinner track
                if path.exists('{}/{}/spinner/img_spinner_track.png'.format(
                        CONTRIB_THEMES,
                        self.selected_theme)):  #Contibuter Did Provide
                    os.system(
                        'cp {}/{}/spinner/img_spinner_track.png /data/{}/selfdrive/assets'
                        .format(CONTRIB_THEMES, self.selected_theme,
                                opdir))  #Replace spinner track supplied custom
                else:  #Contibuter Did Not Provide
                    os.system(
                        'cp ./support/spinner/img_spinner_track.png /data/{}/selfdrive/assets'
                        .format(opdir))  #Replace spinner track with standard

                # Check if user wants rave rainbow spinner or if theme contributer provided a spinner.c
                if raveRainbow == True:  #User wants rave rainbow
                    os.system(
                        'cp ./support/spinner/rainbow_spinner.c /data/{}/selfdrive/common/spinner.c'
                        .format(opdir)
                    )  #Replace spinner.c with rave rainbow spinner.c
                elif path.exists('{}/{}/spinner/spinner.c'.format(
                        CONTRIB_THEMES, self.selected_theme
                )) and raveRainbow == False:  #Contibuter Did Provide
                    os.system(
                        'cp {}/{}/spinner/spinner.c /data/{}/selfdrive/common'.
                        format(CONTRIB_THEMES, self.selected_theme,
                               opdir))  #Replace spinner.c with supplied custom
                else:  #Contibuter Did Not Provide
                    os.system(
                        'cp ./support/spinner/spinner.c /data/{}/selfdrive/common'
                        .format(opdir))  #Replace spinner.c with standard file

                #Hack to keep OpenPilot from overriding
                print('=========== NOTICE ===========')
                print(
                    '\nImplementing hack to prevent git from overwriting....')
                print(
                    'If comma ever updates spinner files (unlikely) when you git pull it will'
                )
                print(
                    'conflict, just "git stash && git pull" you may need to reinstall this spinner after!'
                )
                print('==============================')
                os.system(
                    'cd /data/{} && git update-index --assume-unchanged ./selfdrive/assets/img_spinner_comma.png'
                    .format(opdir))
                os.system(
                    'cd /data/{} && git update-index --assume-unchanged ./selfdrive/assets/img_spinner_track.png'
                    .format(opdir))
                os.system(
                    'cd /data/{} && git update-index --assume-unchanged ./selfdrive/common/spinner.c'
                    .format(opdir))

                #Final make new spinner & finish
                print(
                    '\nBuilding new spinner files, please wait..... This should take under a minute....'
                )
                os.system(
                    'cd /data/openpilot/selfdrive/ui/spinner && make{}'.format(
                        self.con_output))
                print(
                    '\n{} spinner installed successfully! Original file(s) backed up to {}'
                    .format(opdir, self.backup_dir))
                mark_self_installed(
                )  # Create flag in /sdcard so auto installer knows there is a self installation
                print('Press enter to continue!')
                input()

            # elif selected_option == 'APK' or selected_option == 'Kumar-Nightmode-APK':
            #   # Hack to get apk & kumar-nightmode-apk in same installer
            #   if selected_option== 'Kumar-Nightmode-APK':
            #     local_selected_theme = 'Kumar-Nightmode-APK'  # make a locally used selected_theme using Kumar to hax program
            #     show_apk = ''       #Another hack so in print statments, it doesnt say 'Kumar-Nightmode-APK apk' cuz OCD. YES I AM that OCD!!
            #   else:
            #     local_selected_theme = self.selected_theme    # make a locally used selected_theme from global
            #     show_apk = ' APK'   #Another hack so in print statments, it doesnt say 'Kumar-Nightmode-APK apk' cuz OCD. YES I AM that OCD!!

            #   #Confirm user wants to install Kumar Nightmode APK
            #   #print('\n\n**PLEASE NOTE** ')
            #   print("Unfortunatly this process is difficult to fully automize")
            #   print('And requires some manual labor. One of the files that needs edited')
            #   print('for the full expericence is a core file to OpenPilot and is frequently')
            #   print('changed; or you may be on a different version. It would be a futal')
            #   print('task to constantly play catchup / support all possible commits & versions')

            #   print("\nMay I suggest runing my OpenPilot Fork? It's stock or you can choose with Comma Junk removed")
            #   print('It comes default with the Kumar-Nightmode-APK and better intergration with custom themes!')
            #   print('                    https://github.com/Coltonton/openpilot.git')

            #   print('If you have a fork like ArnePilot, or any other with')
            #   print('a modified UI DO NOT USE THIS!! OpenPilot will fail to run!! \n')
            #   print('Instead refer to the DEVREADME located in this project')
            #   print("at ./developer, in the 'APK' section for more info!!\n")
            #   print('Selected to install the {}{}. Continue?'.format(local_selected_theme, show_apk))
            #   if not is_affirmative():
            #     print('Not installing...')
            #     time.sleep(1.5)
            #     continue

            #   op_ver = get_op_ver()

            #   #Check if there was an APK backup already this session to prevent accidental overwrites
            #   #Returns false if okay to proceed. Gets self.backup_dir & asset type name
            #   if backup_overide_check(self.backup_dir, 'apk') == True:
            #     exit()

            #   #Ask user if their OP directory is custom (like arnepilot / dragonpilot)
            #   opdir = op_dir_finder()

            #   #Backup files
            #   os.system('mv /data/{}/apk/ai.comma.plus.offroad.apk {}/apk'.format(opdir, self.backup_dir)) # Backup apk
            #   os.system('mv /data/{}/selfdrive/ui/ui.hpp {}/apk'.format(opdir, self.backup_dir))           # backup ui.hpp

            #   #Copy in new files
            #   os.system('cp {}/{}/apk/ai.comma.plus.offroad.apk /data/{}/apk'.format(CONTRIB_THEMES, local_selected_theme, opdir)) # Copy APK
            #   os.system('cp {}/{}/apk/ui.hpp /data/{}/selfdrive/ui'.format(CONTRIB_THEMES, local_selected_theme, opdir))           # Copy ui.hpp

            #   #Build
            #   print('\nBuilding new APK files, please wait..... This should take under a minute....')
            #   print('Please note, {} will trigger a full re-compile next reboot'.format(opdir))
            #   os.system('cd /data/{}/selfdrive/ui/ && scons -u{}'.format(opdir, self.con_output))

            #   # Finish
            #   print('\n{}{} installed successfully! Original file(s) backed up to {}'.format(local_selected_theme, show_apk, self.backup_dir))
            #   mark_self_installed()        # Create flag in /sdcard so auto installer knows there is a self installation
            #   print('Press enter to continue!')
            #   input()

            elif selected_option == '-Main Menu-' or selected_option is None:
                return

            elif selected_option == '-Reboot-':
                print('\nRebooting.... Thank You, Come Again!!!')
                os.system(
                    'am start -a android.intent.action.REBOOT'
                )  # reboot intent is safer (reboot sometimes causes corruption)
                return 'exit'

            elif selected_option == '-Quit-' or selected_option is None:
                print(
                    '\nThank you come again! You will see your changes next reboot!\n'
                )
                exit()

            elif selected_option == 'Boot Animation' or 'Color Boot Animation' or 'White Boot Animation':
                #Confirm user wants to install bootlogo
                print('\nSelected to install the {} {}. Continue?'.format(
                    self.selected_theme, selected_option))
                if not is_affirmative():
                    print('Not installing...')
                    time.sleep(1.5)
                    continue

                #Check if there was an APK backup already this session to prevent accidental overwrites
                #Returns true if okay to proceed. Gets self.backup_dir & asset type name
                if backup_overide_check(self.backup_dir,
                                        'bootanimation') == True:
                    exit()

                #Set bootAniColor based off the selected option - if 'white_', 'color_', or standard bootanimation
                if selected_option == 'Boot Animation':
                    bootAniColor = ""
                elif selected_option == 'Color Boot Animation':
                    bootAniColor = "color_"
                elif selected_option == 'White Boot Animation':
                    bootAniColor = "white_"

                #Backup And install new bootanimation
                os.system('mount -o remount,rw /system'
                          )  # /system read only, must mount as r/w
                os.system('mv /system/media/bootanimation.zip {}'.format(
                    self.backup_dir))  # backup
                os.system(
                    'cp {}/{}/{}bootanimation.zip /system/media/bootanimation.zip'
                    .format(CONTRIB_THEMES, self.selected_theme,
                            bootAniColor))  # replace
                os.system('chmod 666 /system/media/bootanimation.zip'
                          )  #Need to chmod and edet permissions to 666
                print(
                    '\nBoot Animation installed successfully! Original file(s) backed up to {}'
                    .format(self.backup_dir))
                mark_self_installed(
                )  # Create flag in /sdcard so auto installer knows there is a self installation
                print('Press enter to continue!')
                input()
Ejemplo n.º 4
0
  def install_function(self):  # Self installer program, prompts user on what they want to do
    while 1:
      options = list(self.theme_options)  # this only contains available options from self.get_available_options
      if not len(options):
        print('The selected theme has no resources available for your device! Try another.')
        time.sleep(2)
        return

      options += ['-Main Menu-', '-Reboot-']
      
      print('What resources do you want to install for the {} theme?'.format(self.selected_theme))
      for idx, theme in enumerate(options):
        print('{}. {}'.format(idx + 1, theme))
      indexChoice = int(input("Enter Index Value: "))
      indexChoice -= 1 

      selected_option = self.theme_options[indexChoice]

      if selected_option == 'Boot Logo':
        print('Selected to install the {} Boot Logo. Continue?'.format(self.selected_theme))
        if not is_affirmative():
          print('Not installing...')
          time.sleep(1.5)
          continue
        os.system('cp {} {}'.format(BOOT_LOGO_PATH, self.backup_dir))  # Make Backup
        os.system('dd if={}/{}/{} of={}'.format(CONTRIB_THEMES, self.selected_theme, BOOT_LOGO_THEME_PATH, BOOT_LOGO_PATH))  # Replace
        print('\nBoot Logo installed successfully! Original backed up to {}'.format(self.backup_dir))
        print('Press enter to continue!')
        input()

      elif selected_option == 'Boot Animation':
        print('Selected to install the {} Boot Animation. Continue?'.format(self.selected_theme))
        if not is_affirmative():
          print('Not installing...')
          time.sleep(1.5)
          continue
        os.system('mount -o remount,rw /system')  # /system read only, must mount as r/w
        os.system('mv /system/media/bootanimation.zip {}'.format(self.backup_dir))  # backup
        os.system('cp {}/{}/bootanimation.zip /system/media'.format(CONTRIB_THEMES, self.selected_theme))  # replace
        os.system('chmod 666 /system/media/bootanimation.zip')
        print('\nBoot Animation installed successfully! Original backed up to {}'.format(self.backup_dir))
        print('Press enter to continue!')
        input()

      elif selected_option == 'OP Spinner':
        print('Selected to install the {} OP Spinner. Continue?'.format(self.selected_theme))
        if not is_affirmative():
          print('Not installing...')
          time.sleep(1.5)
          continue
        print('Do you have an OP fork with a custom directory name? (ex. arnepilot, dragonpilot)')  # Ask the user if their OP fork used a diffrent directory.
        if is_affirmative():  # Yes there is a custom OP dir
          print('What is the OP directory name? (case matters, not including /data/)')
          op_dir = '/data/{}'.format(input('> ').strip('/'))  # get custom dir name, strip slashes for safety
          print('Your openpilot directory is {}'.format(op_dir))
          input('*** Please enter to continue, or Ctrl+C to abort if this is incorrect! ***')

          os.system('mv {}/selfdrive/ui/spinner/spinner {}'.format(op_dir, self.backup_dir))
          os.system('cp {}/{}/spinner {}/selfdrive/ui/spinner'.format(CONTRIB_THEMES, self.selected_theme, op_dir))
          print('\n{} spinner installed successfully! Original backed up to {}'.format(op_dir.split('/')[2], self.backup_dir))
        else:  # there is not custom OP dir
          os.system('mv /data/openpilot/selfdrive/ui/spinner/spinner {}'.format(self.backup_dir))
          os.system('cp {}/{}/spinner /data/openpilot/selfdrive/ui/spinner'.format(CONTRIB_THEMES, self.selected_theme))
          print('\nopenpilot spinner installed successfully! Original backed up to {}'.format(self.backup_dir))
        print('Press enter to continue!')
        input()

      elif selected_option == 'Additional Resources':  # additional features
        print('Additional Resources are not an active feature')
        time.sleep(5)

      elif selected_option == '-Main Menu-' or selected_option is None:
        return

      elif selected_option == '-Reboot-':
        print('Rebooting.... Enjoy your new theme!!!')
        os.system('am start -a android.intent.action.REBOOT')  # reboot intent is safer (reboot sometimes causes corruption)
        return 'exit'
Ejemplo n.º 5
0
os.chdir(os.path.dirname(os.path.realpath(__file__)))  # __file__ is safer since it doesn't change based on where this file is called from
print_welcome_text()

# Crude device detection, *shrug* it works! LeEco does not have tristate!
if path.exists('/sys/devices/virtual/switch/tri-state-key'):
  print('\n*** OnePlus EON Device Detected ***')
  BOOT_LOGO_THEME_PATH = 'OP3T-Logo/LOGO'  # Set the boot logo theme path for 3T
  BOOT_LOGO_PATH = '/dev/block/sde17'  # Set the boot logo directory for 3T
else:
  print('\n*** LeEco EON Device Detected ***\n')
  BOOT_LOGO_THEME_PATH = 'LeEco-Logo/SPLASH'  # Set the boot logo theme path for Leo
  BOOT_LOGO_PATH = '/dev/block/bootdevice/by-name/splash'  # Set the boot logo directory for Leo

print('IMPORTANT: Soft-bricking is likely if this detection is incorrect. Is this correct?')
if not is_affirmative():
  exit()


class ThemeInstaller:
  def __init__(self):
    self.backup_dir = datetime.now().strftime('backups/backup.%m-%d-%y--%I.%M.%S-%p')  # Get current datetime and store
    os.mkdir(self.backup_dir)  # Create the session backup folder

    if IS_AUTO_INSTALL:
      assert check_auto_installability(), 'Auto install has already been performed!'
      self.auto_installer()
    else:
      self.start_loop()

  def start_loop(self):