Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit 3a6ec217 authored by Yi-yo Chiang's avatar Yi-yo Chiang Committed by Gerrit Code Review
Browse files

Merge "adb-remount-test: Refactor restore()"

parents 447aa1af 8f8d9205
Loading
Loading
Loading
Loading
+37 −37
Original line number Diff line number Diff line
@@ -985,46 +985,53 @@ adb_sh ls -l /dev/block/by-name/ /dev/block/mapper/ </dev/null 2>/dev/null |
      LOG INFO "partition ${name} device ${device} size ${size}K"
  done

# If reboot too soon after fresh flash, could trip device update failure logic
if ${screen_wait}; then
  LOG WARNING "waiting for screen to come up. Consider --no-wait-screen option"
fi
if ! wait_for_screen && ${screen_wait}; then
  screen_wait=false
  LOG WARNING "not healthy, no launcher, skipping wait for screen"
fi

# Can we test remount -R command?
overlayfs_supported=true
if [ "orange" != "`get_property ro.boot.verifiedbootstate`" -o \
     "2" != "`get_property partition.system.verified`" ]; then
can_restore_verity=false

restore() {
  LOG INFO "restoring device"
  ${overlayfs_supported} || return 0
  inFastboot &&
    fastboot reboot &&
      adb_wait ${ADB_WAIT} ||
    adb_wait "${ADB_WAIT}" ||
    true
    if inAdb; then
  if ! inAdb; then
    LOG ERROR "expect adb device"
    return 1
  fi
  adb_root || true
  local reboot=false
  if surgically_wipe_overlayfs; then
        adb_reboot &&
        adb_wait ${ADB_WAIT}
    reboot=true
  fi
  if ${can_restore_verity}; then
    if ! adb enable-verity; then
      LOG ERROR "adb enable-verity"
      return 1
    fi
  }
else
  restore() {
    ${overlayfs_supported} || return 0
    inFastboot &&
      fastboot reboot &&
      adb_wait ${ADB_WAIT} ||
      true
    inAdb &&
      adb_root &&
      adb enable-verity >/dev/null 2>/dev/null &&
    LOG INFO "restored verity"
    reboot=true
  fi >&2
  if ${reboot}; then
    adb_reboot &&
      adb_wait ${ADB_WAIT}
      adb_wait "${ADB_WAIT}"
  fi
}

# If reboot too soon after fresh flash, could trip device update failure logic
if ${screen_wait}; then
  LOG WARNING "waiting for screen to come up. Consider --no-wait-screen option"
fi
if ! wait_for_screen && ${screen_wait}; then
  screen_wait=false
  LOG WARNING "not healthy, no launcher, skipping wait for screen"
fi

# Can we test remount -R command?
if [ "orange" = "$(get_property ro.boot.verifiedbootstate)" ] &&
   [ "2" = "$(get_property partition.system.verified)" ]; then
  can_restore_verity=true

  LOG RUN "Testing adb shell su root remount -R command"

  avc_check
@@ -1118,14 +1125,7 @@ echo "${D}" >&2
if [ X"${D}" = X"${D##* 100[%] }" ] && ${no_dedupe} ; then
  overlayfs_needed=false
  # if device does not need overlays, then adb enable-verity will brick device
  restore() {
    ${overlayfs_supported} || return 0
    inFastboot &&
      fastboot reboot &&
      adb_wait ${ADB_WAIT}
    inAdb &&
      adb_wait ${ADB_WAIT}
  }
  can_restore_verity=false
elif ! ${overlayfs_supported}; then
  die "need overlayfs, but do not have it"
fi