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

Commit 57f9181b authored by Ahmed Harhash's avatar Ahmed Harhash Committed by Jonathan Klee
Browse files

Merge branch '7141-t-check_unlock' into 'v1-t'

flash_FP4_factory.sh Check if phone is unlocked

See merge request !144
parents 496e968a 0f8daa12
Loading
Loading
Loading
Loading
+0 −2
Original line number Original line Diff line number Diff line
@@ -19,9 +19,7 @@ PRODUCT_ARTIFACT_PATH_REQUIREMENT_ALLOWED_LIST += \


# /e/ OS packages
# /e/ OS packages
PRODUCT_PACKAGES += \
PRODUCT_PACKAGES += \
    GmsCore \
    GsfProxy \
    GsfProxy \
    FakeStore \
    Mail \
    Mail \
    BlissLauncher3 \
    BlissLauncher3 \
    BlissWeather \
    BlissWeather \
+36 −6
Original line number Original line Diff line number Diff line
@@ -7,7 +7,7 @@
##########
##########


##########
##########
# This script flashes a software release and complete wipes the device.
# This script flashes a software release and completely wipes the device.
#
#
##########
##########


@@ -56,7 +56,6 @@ find_device() {
        ;;
        ;;
      1)
      1)
        echo "INFO: One ${PRODUCT} in fastboot mode found (serial number: ${sn})."
        echo "INFO: One ${PRODUCT} in fastboot mode found (serial number: ${sn})."

        DEVICE_FOUND="true"
        DEVICE_FOUND="true"
        break
        break
        ;;
        ;;
@@ -82,9 +81,38 @@ find_device() {
  done
  done
}
}


# Check if the device is properly unlocked
check_unlock_status() {
  PHONE_IS_READY=true
  if (fastboot getvar is-userspace 2>&1 | grep -q yes); then
    echo "Info: Your phone is in fastbootD mode."
    if (fastboot getvar unlocked 2>&1 | grep -q no); then
      echo "Error: Your phone is still locked."
      echo "Did you execute 'fastboot flashing unlock'?"
      PHONE_IS_READY=false
    fi
  else
    echo "Info: Your phone is in regular bootloader mode."
    if (fastboot getvar unlocked 2>&1 | grep -q no); then
      echo "Error: Your phone is still locked."
      echo "Did you execute 'fastboot flashing unlock'?"
      PHONE_IS_READY=false
    fi
    if (fastboot oem device-info 2>&1 | grep -q "critical unlocked: false"); then
      echo "Error: Critical partitions are still locked."
      echo "Did you execute 'fastboot flashing unlock_critical'?"
      PHONE_IS_READY=false
    fi
  fi

  if [ "$PHONE_IS_READY" = "false" ]; then
    echo "Error: Your phone is not ready for flashing yet (see above), aborting..."
    exit 1
  fi
}

# Flash (or manipulate) relevant partitions
# Flash (or manipulate) relevant partitions
flash_device() {
flash_device() {

  flash_image_ab_or_abort "${sn}" bluetooth "${IMAGES_DIR}/bluetooth.img"
  flash_image_ab_or_abort "${sn}" bluetooth "${IMAGES_DIR}/bluetooth.img"
  flash_image_ab_or_abort "${sn}" devcfg "${IMAGES_DIR}/devcfg.img"
  flash_image_ab_or_abort "${sn}" devcfg "${IMAGES_DIR}/devcfg.img"
  flash_image_ab_or_abort "${sn}" dsp "${IMAGES_DIR}/dsp.img"
  flash_image_ab_or_abort "${sn}" dsp "${IMAGES_DIR}/dsp.img"
@@ -115,7 +143,6 @@ flash_device() {
  "$FASTBOOT_BIN" -s "${sn}" erase metadata
  "$FASTBOOT_BIN" -s "${sn}" erase metadata


  "$FASTBOOT_BIN" -s "${sn}" --set-active=a
  "$FASTBOOT_BIN" -s "${sn}" --set-active=a

}
}


# Flash an image to a partition. Abort on failure.
# Flash an image to a partition. Abort on failure.
@@ -137,7 +164,7 @@ flash_image_or_abort() {
  fi
  fi
}
}


# Flash an image to both A and B slot of partition. Abort on failure.
# Flash an image to both A and B slots of a partition. Abort on failure.
# Arguments: <device serial number> <partition name without slot> <image file>
# Arguments: <device serial number> <partition name without slot> <image file>
flash_image_ab_or_abort() {
flash_image_ab_or_abort() {
  flash_image_or_abort "${1}" "${2}_a" "${3}"
  flash_image_or_abort "${1}" "${2}_a" "${3}"
@@ -192,6 +219,9 @@ os_checks
# If only one device is found $sn will store its serial number
# If only one device is found $sn will store its serial number
find_device
find_device


# Check if the device is properly unlocked
check_unlock_status

# Flash the device
# Flash the device
flash_device
flash_device