def on_run(self, *params) -> bool: ec_dir = self.cfg.cfgProgramDir if os.path.exists(ec_dir): return self.cd(ec_dir) else: Printer.red_line('ec path not exists. path: %s' % ec_dir) return False
def on_run(self, *params) -> bool: out_dir = self.cfg.cfgProjectOutDir if os.path.exists(out_dir): return self.cd(out_dir) else: Printer.red_line('out path not exists. path: %s' % out_dir) return False
def on_run(self, *params) -> bool: backup_dir = self.cfg.cfgProjectBackupDir if os.path.exists(backup_dir): return self.cd(backup_dir) else: Printer.red_line('backup path not exists. path: %s' % backup_dir) return False
def on_run(self, *params) -> bool: target_product = self.cfg.cfgProjectName current_product = os.environ.get('ENV_PRODUCT') if current_product == target_product: Printer.yellow_line('Already initialized for %s!!!' % current_product) return True elif current_product is not None and current_product != '': Printer.red_line( 'Already initialized for [%s]. Please start a new terminal.' % current_product) return False else: # notify start Printer.green_line('Initializing for [%s] ...' % target_product) # begin env setup self.shell('source %s' % self.cfg.cfgProjectEnvSetup) self.shell('%s' % self.cfg.cfgProjectEnvConfig) # save current product self.shell('export ENV_PRODUCT=%s' % target_product) # notify done Printer.green_line('Done => Current Project: [%s]' % target_product) return True
def on_run(self, *params) -> bool: root_dir = self.cfg.cfgProjectRootDir if os.path.exists(root_dir): return self.cd(root_dir) else: Printer.red_line('root path not exists. path: %s' % root_dir) return False
def on_run(self, *params) -> bool: if len(params) < 1: Printer.red_line('please input the module to clean') help() return False if len(params) > 1: Printer.red_line('only one module is supported') help() return False module = params[0] root = self.cfg.cfgProjectRootDir name = self.cfg.cfgProjectName out = self.cfg.cfgProjectOutDir # app temp out folder self.remove('%s/out/target/common/obj/APPS/%s_intermediates' % (root, module)) # custpack out folder for old platform self.remove('%s/out/target/common/jrdResCust/packages/apps/%s' % (root, module)) # custpack out folder for packages/apps self.remove( '%s/out/target/perso/%s/jrdResAssetsCust/packages/apps/%s' % (root, name, module)) # custpack out folder for vendor/tct/source/apps self.remove( '%s/out/target/perso/%s/jrdResAssetsCust/vendor/tct/source/apps/%s' % (root, name, module)) # custpack out folder for frameworks/base/packages self.remove( '%s/out/target/perso/%s/jrdResAssetsCust/frameworks/base/packages/%s' % (root, name, module)) # custpack out folder for frameworks/base/services self.remove( '%s/out/target/perso/%s/jrdResAssetsCust/frameworks/base/services/%s' % (root, name, module)) # custpack out folder for packages/providers self.remove( '%s/out/target/perso/%s/jrdResAssetsCust/packages/providers/%s' % (root, name, module)) # apk under system/app self.remove('%s/system/app/%s' % (out, module)) # apk under system/priv-app self.remove('%s/system/priv-app/%s' % (out, module)) return True
def on_run(self, *params) -> bool: self.cmd('root') gms_list = self.get_gms_pkg_list() for pkg in gms_list: code = self.shell('adb shell pm disable %s' % pkg) if code != 0: Printer.red_line('Disable gms pkg: %s FAILED' % pkg) return True
def on_run(self, *params) -> bool: # assign path flash_path = self.cfg.cfgProjectOutDir if len(params) > 0 and (params[0] == '--path' or params[0] == '-p'): if len(params) < 2: Printer.red_line('invalid format of command') self.help() return False flash_path = os.path.abspath(params[1]) params = params[2:] # get flash list flash_dict = self.cfg.cfgProjectFlashMap if len(params) > 0: tmp_dict = dict() for p in params: if p in flash_dict: tmp_dict[p] = flash_dict[p] else: Printer.red_line('unknown partition: %s' % p) self.help() return False flash_dict = tmp_dict # do flash flashed = False self.shell('sudo adb reboot bootloader') for partition, img in flash_dict.items(): path = '%s/%s' % (flash_path, img) if os.path.exists(path): flashed = True Printer.green_line('flashing [%s] ...' % img) self.shell('sudo fastboot flash %s %s' % (partition, path)) Printer.green_line('Done') self.shell('sudo fastboot reboot') # warning for not flash if not flashed: Printer.yellow_line('No img found to be flashed!!') return True
def on_run(self, *params) -> bool: count = len(params) if count <= 0: Printer.red_line('please input a command for help.') self.help() return False elif count > 1: Printer.red_line('only 1 command is accepted.') self.help() return False else: # count == 1 if params[0] not in self.cfg.cfgProgramCmdList: Printer.red_line('invalid command.') self.help() return False # get command cmd = self.env.load_cmd(params[0]) cmd.cfg = self.cfg cmd.help() return True
def on_run(self, *params) -> bool: if len(params) < 1: Printer.red_line('please input the module to push') help() return False if len(params) > 1: Printer.red_line('only one module is supported') help() return False # root device self.shell('adb root') self.shell('adb wait-for-device') self.shell('adb shell setenforce 0') self.shell('adb disable-verity') self.shell('adb remount') # push out_dir = self.cfg.cfgProjectOutDir module = params[0] self.adb_push('[/system/app] APK', '%s/system/app/%s/%s.apk' % (out_dir, module, module), '/system/app/%s' % module) self.adb_push( '[/system/app] ODEX', '%s/system/app/%s/oat/arm64/%s.odex' % (out_dir, module, module), '/system/app/%s/oat/arm64' % module) self.adb_push( '[/system/priv-app] APK', '%s/system/priv-app/%s/%s.apk' % (out_dir, module, module), '/system/priv-app/%s' % module) self.adb_push( '[/system/priv-app] ODEX', '%s/system/priv-app/%s/oat/arm64/%s.odex' % (out_dir, module, module), '/system/priv-app/%s/oat/arm64' % module) self.adb_push('[/system/framework] JAR', '%s/system/framework/%s.jar' % (out_dir, module), '/system/framework') self.adb_push('[/system/framework] APK', '%s/system/framework/%s.apk' % (out_dir, module), '/system/framework') self.adb_push( '[/system/framework] ODEX', '%s/system/framework/oat/arm64/%s.odex' % (out_dir, module), '/system/framework/oat/arm64') self.adb_push( '[/system/vendor/app] APK', '%s/system/vendor/app/%s/%s.apk' % (out_dir, module, module), '/system/vendor/app/%s' % module) self.adb_push( '[/system/vendor/app] ODEX', '%s/system/vendor/app/%s/oat/arm64/%s.odex' % (out_dir, module, module), '/system/vendor/app/%s/oat/arm64' % module) self.adb_push('[system/bin] BIN', '%s/system/bin/%s' % (out_dir, module), '/system/bin') if module == 'framework': self.adb_push( '[/system/framework] ART', '%s/dex_bootjars/system/framework/arm/boot.art' % out_dir, '/system/framework/arm') self.adb_push( '[/system/framework] ART64', '%s/dex_bootjars/system/framework/arm64/boot.art' % out_dir, '/system/framework/arm64') return True
def e(tag: str, msg: str): Printer.red_line(Log._make_message(tag, msg))
def on_run(self, *params) -> bool: project_root = os.path.abspath(self.cfg.cfgProjectRootDir) project_root_dir = '%s/' % project_root # get pwd pwd = os.path.abspath(self.pwd()) if len(params) == 1: pwd = os.path.abspath('%s/%s' % (self.cfg.cfgProjectRootDir, params[0])) if not os.path.exists(pwd): Printer.red_line('Path to push not exists') Printer.red_line(' Path: %s' % pwd) self.help() return False # check pwd if not pwd.startswith(project_root_dir): Printer.red_line( 'Current path is not valid. Please enter the dir of repository to push' ) Printer.red_line(' Current path: %s' % pwd) Printer.red_line(' Project path: %s' % project_root) self.help() return False # get local path under project root dir local_path = pwd.replace(project_root_dir, '') # check manifest manifest = '%s/.repo/manifest.xml' % project_root if not os.path.exists(manifest): Printer.red_line('manifest not exists.') Printer.red_line(' Path: %s' % manifest) self.help() return False # search in manifest remote_path = None with open(manifest, 'r') as file: for line in file: match = self._LINE_PATTERN.fullmatch(line) if match is None: continue git_remote_path = match[1].strip() git_local_path = match[2].strip() if git_local_path == local_path: remote_path = git_remote_path break # check remote path if remote_path is None: Printer.red_line('Path not find in manifest.') Printer.red_line(' Path: %s' % local_path) self.help() return False # do push push_url = '%s/%s.git' % (self.cfg.cfgProjectUrlRepoPush, remote_path) head = 'HEAD:refs/for/%s' % self.cfg.cfgProjectBranch self.shell('git push %s %s' % (push_url, head)) return True
def shell(self, argv): shell = Shell() with shell: # ignore program path argv = argv[1:] # check argv if len(argv) <= 0: Printer.red_line('No project input!!!') self.help() return # get print flag do_print = False print_flag = argv[0].strip() if print_flag == '--print' or print_flag == '-p': do_print = True shell.fake_exec(True) argv = argv[1:] # check argv if len(argv) <= 0: Printer.red_line('No project input!!!') self.help() return # get project project = argv[0].strip() if do_print else print_flag # get command command = ' '.join(argv[1:]).strip() # parser argv cmd_list = list(map(str.strip, command.split(','))) # env env = Env() # load cfg cfg = env.load_cfg(project) if cfg is None: Printer.red_line('invalid project: %s' % project) Printer.yellow_line('available project: %s' % env.cfgProgramCfgList) return # check cmd cmd_checked = [] for c in cmd_list: cmd_parts = list(map(str.strip, c.split(' '))) cmd_name = cmd_parts[0] cmd_params = cmd_parts[1:] cmd = env.load_cmd(cmd_name) if cmd is None: Printer.red_line('invalid command: %s.' % cmd_name) Printer.yellow_line('available cmd: %s' % env.cfgProgramCmdList) return else: cmd_checked.append({'cmd': cmd, 'params': cmd_params}) # run cmd for c in cmd_checked: c['cmd'].run(shell, cfg, *tuple(c['params']))