[MTK][Android P]如何去掉差分包中的preloader分区

最近碰到一个问题,在进行差分升级的时候,会因为某些原因导致preloader hash值不匹配,升级失败,所以需要在差分升级的时候不升级preloader。

解决的方法,就是在制作AB分区的差分升级包的时候,把目标zip解压出来,把ab_partitions.txt中的分区名去掉,同时把preloader.img去掉

修改如下:

Project/build/tools/releasetools/ota_from_target_files.py

METADATA_NAME = 'META-INF/com/android/metadata'
POSTINSTALL_CONFIG = 'META/postinstall_config.txt'
UNZIP_PATTERN = ['IMAGES/*', 'META/*']
AB_PARTITIONS = 'META/ab_partitions.txt'
PRELOADER_STR = "preloader"

......

def RemovePreloaderFromZip(input_file):
  target_file = common.MakeTempFile(prefix="targetfiles-", suffix=".zip")
  shutil.copyfile(input_file, target_file)
  input_tmp = common.UnzipTemp(input_file,UNZIP_PATTERN)
  ab_partitions_file = os.path.join(input_tmp,*AB_PARTITIONS.split('/'))
  with open(ab_partitions_file) as f:
    ab_partitions_lines = f.readlines()
    ab_partitions = [line.strip() for line in ab_partitions_lines]
  new_ab_partitions = common.MakeTempFile(prefix="ab_partitions", suffix=".txt")
  with open(new_ab_partitions, 'w') as f:
    for partition in ab_partitions:
      if (partition.strip() == PRELOADER_STR.strip()):
          continue
      f.write(partition + "\n")
  to_delete = [AB_PARTITIONS]
  to_delete += ['IMAGES/preloader.img']
  common.ZipDelete(target_file, to_delete)
  target_zip = zipfile.ZipFile(target_file, 'a', allowZip64=True)
  common.ZipWrite(target_zip, new_ab_partitions, arcname=AB_PARTITIONS)
  common.ZipClose(target_zip)
  return target_file

def WriteABOTAPackageWithBrilloScript(target_file, output_file,
                                      source_file=None):

......

def WriteABOTAPackageWithBrilloScript(target_file, output_file,
                                      source_file=None):

  if source_file is not None:
    target_info = BuildInfo(OPTIONS.target_info_dict, OPTIONS.oem_dicts)
    source_info = BuildInfo(OPTIONS.source_info_dict, OPTIONS.oem_dicts)
    target_file = RemovePreloaderFromZip(target_file)

 else:

发布了6 篇原创文章 · 获赞 2 · 访问量 1073

猜你喜欢

转载自blog.csdn.net/thonmin/article/details/103909128
MTK
今日推荐