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

Verified Commit 8ef7c951 authored by Nicolas Gelot's avatar Nicolas Gelot
Browse files

Revert "FP5: Initialize"

This reverts commit fd9a0f21.
parent 6348f8c3
Loading
Loading
Loading
Loading
+0 −270
Original line number Diff line number Diff line
#!/bin/bash

# Copyright (C) 2020 - Author: Ingo; update and adoption to FP4, 2022 by ff2u
#
# This program is free software: you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
# the Free Software Foundation, either version 3 of the License, or
# (at your option) any later version.
#
# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
# GNU General Public License for more details.
#
# You should have received a copy of the GNU General Public License
# along with this program.  If not, see <https://www.gnu.org/licenses/>.

# Parameter
# $1: ARCHIVE_PATH path to the /e/ archive to flash
# $2: FASTBOOT_FOLDER_PATH: the path where runnable fastboot is stored
# $3: JAVA_FOLDER_PATH: the path where runnable jar is stored (to unpack ZIP file)

# Exit status
# - 0 : /e/ installed
# - 1 : erasing userdata or metadata failed
# - 2 : flashing of a non-critical partition failed
# - 4 : setting active slot to a failed
# - 5 : flashing of a critical partition failed
#       namely: {devcfg_ab, xbl_ab, tz_ab, hyp_ab, keymaster_ab, abl_ab, aop_ab, imagefv_ab, multiimgoem_ab, qupfw_ab, uefisecapp_ab, xbl_config_ab}
# - 101 : ARCHIVE_PATH missing
# - 102 : archive could not be unpacked

ARCHIVE_PATH=$1
ARCHIVE_FOLDER_PATH=$(dirname "$1")"/"
FASTBOOT_FOLDER_PATH=$2
FASTBOOT_PATH=${FASTBOOT_FOLDER_PATH}"fastboot"
JAVA_FOLDER_PATH=$3
JAR_PATH=${JAVA_FOLDER_PATH}"/bin/jar"

echo "archive path : $ARCHIVE_PATH"
echo "archive folder path : $ARCHIVE_FOLDER_PATH"
echo "fastboot path : $FASTBOOT_PATH"
echo "jar path : $JAR_PATH"

if [ -z "$ARCHIVE_PATH" ]
then
  exit 101
fi

cd "$ARCHIVE_FOLDER_PATH"
sleep 1

if ! "$JAR_PATH" -x -v -f "$ARCHIVE_PATH" ;
then
  exit 102
fi

echo "unpacked archive"
sleep 1

echo "=== Flash slot a ==="

if ! "$FASTBOOT_PATH" flash bluetooth_a bluetooth.img ; then exit 2 ; fi
echo "flashed bluetooth_a"
sleep 1

if ! "$FASTBOOT_PATH" flash devcfg_a devcfg.img ; then exit 5 ; fi
echo "flashed devcfg_a"
sleep 1

if ! "$FASTBOOT_PATH" flash dsp_a dsp.img ; then exit 2 ; fi
echo "flashed dsp_a"
sleep 1

if ! "$FASTBOOT_PATH" flash modem_a modem.img ; then exit 2 ; fi
echo "flashed modem_a"
sleep 1

if ! "$FASTBOOT_PATH" flash xbl_a xbl.img ; then exit 5 ; fi
echo "flashed xbl_a"
sleep 1

if ! "$FASTBOOT_PATH" flash tz_a tz.img ; then exit 5 ; fi
echo "flashed tz_a"
sleep 1

if ! "$FASTBOOT_PATH" flash hyp_a hyp.img ; then exit 5 ; fi
echo "flashed hyp_a"
sleep 1

if ! "$FASTBOOT_PATH" flash keymaster_a keymaster.img ; then exit 5 ; fi
echo "flashed keymaster_a"
sleep 1


if ! "$FASTBOOT_PATH" flash abl_a abl.img ; then exit 5 ; fi
echo "flashed abl_a"
sleep 1

if ! "$FASTBOOT_PATH" flash boot_a boot.img ; then exit 2 ; fi
echo "flashed boot_a"
sleep 1

if ! "$FASTBOOT_PATH" flash dtbo_a dtbo.img ; then exit 2 ; fi
echo "flashed dtbo_a"
sleep 1

if ! "$FASTBOOT_PATH" flash vendor_boot_a vendor_boot.img ; then exit 2 ; fi
echo "flashed vendor_boot_a"
sleep 1

if ! "$FASTBOOT_PATH" flash vbmeta_system_a vbmeta_system.img ; then exit 2 ; fi
echo "flashed vbmeta_system_a"
sleep 1

if ! "$FASTBOOT_PATH" flash vbmeta_a vbmeta.img ; then exit 2 ; fi
echo "flashed vbmeta_a"
sleep 1

if ! "$FASTBOOT_PATH" flash super super.img ; then exit 2 ; fi
echo "flashed super"
sleep 1


if ! "$FASTBOOT_PATH" flash aop_a aop.img ; then exit 5 ; fi
echo "flashed aop_a"
sleep 1

if ! "$FASTBOOT_PATH" flash featenabler_a featenabler.img ; then exit 2 ; fi
echo "flashed featenabler_a"
sleep 1

if ! "$FASTBOOT_PATH" flash imagefv_a imagefv.img ; then exit 5 ; fi
echo "flashed imagefv_a"
sleep 1

if ! "$FASTBOOT_PATH" flash multiimgoem_a multiimgoem.img ; then exit 5 ; fi
echo "flashed multiimgoem_a"
sleep 1

if ! "$FASTBOOT_PATH" flash qupfw_a qupfw.img ; then exit 5 ; fi
echo "flashed qupfw_a"
sleep 1

if ! "$FASTBOOT_PATH" flash uefisecapp_a uefisecapp.img ; then exit 5 ; fi
echo "flashed uefisecapp_a"
sleep 1

if ! "$FASTBOOT_PATH" flash xbl_config_a xbl_config.img ; then exit 5 ; fi
echo "flashed xbl_config_a"
sleep 1

if ! "$FASTBOOT_PATH" flash cpucp_a cpucp.img ; then exit 2 ; fi
echo "flashed cpucp_a"
sleep 1

if ! "$FASTBOOT_PATH" flash shrm_a shrm.img ; then exit 2 ; fi
echo "flashed shrm_a"
sleep 1


echo "=== Flash slot b ==="

if ! "$FASTBOOT_PATH" flash bluetooth_b bluetooth.img ; then exit 2 ; fi
echo "flashed bluetooth_b"
sleep 1

if ! "$FASTBOOT_PATH" flash devcfg_b devcfg.img ; then exit 5 ; fi
echo "flashed devcfg_b"
sleep 1

if ! "$FASTBOOT_PATH" flash dsp_b dsp.img ; then exit 2 ; fi
echo "flashed dsp_b"
sleep 1

if ! "$FASTBOOT_PATH" flash modem_b modem.img ; then exit 2 ; fi
echo "flashed modem_b"
sleep 1

if ! "$FASTBOOT_PATH" flash xbl_b xbl.img ; then exit 5 ; fi
echo "flashed xbl_b"
sleep 1

if ! "$FASTBOOT_PATH" flash tz_b tz.img ; then exit 5 ; fi
echo "flashed tz_b"
sleep 1

if ! "$FASTBOOT_PATH" flash hyp_b hyp.img ; then exit 5 ; fi
echo "flashed hyp_b"
sleep 1

if ! "$FASTBOOT_PATH" flash keymaster_b keymaster.img ; then exit 5 ; fi
echo "flashed keymaster_b"
sleep 1


if ! "$FASTBOOT_PATH" flash abl_b abl.img ; then exit 5 ; fi
echo "flashed abl_b"
sleep 1

if ! "$FASTBOOT_PATH" flash boot_b boot.img ; then exit 2 ; fi
echo "flashed boot_b"
sleep 1

if ! "$FASTBOOT_PATH" flash dtbo_b dtbo.img ; then exit 2 ; fi
echo "flashed dtbo_b"
sleep 1

if ! "$FASTBOOT_PATH" flash vendor_boot_b vendor_boot.img ; then exit 2 ; fi
echo "flashed vendor_boot_b"
sleep 1

if ! "$FASTBOOT_PATH" flash vbmeta_system_b vbmeta_system.img ; then exit 2 ; fi
echo "flashed vbmeta_system_b"
sleep 1

if ! "$FASTBOOT_PATH" flash vbmeta_b vbmeta.img ; then exit 2 ; fi
echo "flashed vbmeta_b"
sleep 1

if ! "$FASTBOOT_PATH" flash aop_b aop.img ; then exit 5 ; fi
echo "flashed aop_b"
sleep 1

if ! "$FASTBOOT_PATH" flash featenabler_b featenabler.img ; then exit 2 ; fi
echo "flashed featenabler_b"
sleep 1

if ! "$FASTBOOT_PATH" flash imagefv_b imagefv.img ; then exit 5 ; fi
echo "flashed imagefv_b"
sleep 1

if ! "$FASTBOOT_PATH" flash multiimgoem_b multiimgoem.img ; then exit 5 ; fi
echo "flashed multiimgoem_b"
sleep 1

if ! "$FASTBOOT_PATH" flash qupfw_b qupfw.img ; then exit 5 ; fi
echo "flashed qupfw_b"
sleep 1

if ! "$FASTBOOT_PATH" flash uefisecapp_b uefisecapp.img ; then exit 5 ; fi
echo "flashed uefisecapp_b"
sleep 1

if ! "$FASTBOOT_PATH" flash xbl_config_b xbl_config.img ; then exit 5 ; fi
echo "flashed xbl_config_b"
sleep 1

if ! "$FASTBOOT_PATH" flash cpucp_b cpucp.img ; then exit 2 ; fi
echo "flashed cpucp_b"
sleep 1

if ! "$FASTBOOT_PATH" flash shrm_b shrm.img ; then exit 2 ; fi
echo "flashed shrm_b"
sleep 1

echo "=== Wiping userdata and metadata ==="
sleep 3

if ! "$FASTBOOT_PATH" erase userdata ; then exit 1 ; fi
echo  "wiped userdata"
sleep 1

if ! "$FASTBOOT_PATH" erase metadata ; then exit 1 ; fi
echo "wiped metadata"
sleep 3

echo "=== Setting active slot to a ==="
if ! "$FASTBOOT_PATH" --set-active=a ; then exit 4 ; fi
echo "switched to slot a"
+0 −75
Original line number Diff line number Diff line
#!/bin/bash

# Copyright (C) 2022 - Author: Frank
#
# This program is free software: you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
# the Free Software Foundation, either version 3 of the License, or
# (at your option) any later version.
#
# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
# GNU General Public License for more details.
#
# You should have received a copy of the GNU General Public License
# along with this program.  If not, see <https://www.gnu.org/licenses/>.

# TODO: What if 2 devices detected?
# Parameter
# $1: The folder where fastboot runnable is stored

# Exit status
# - 0 : Device in fastboot mode detected
# - 1 : Error (adb)
# - 2 : Error (device locked)

# Store ROM information on the file system 

FASTBOOT_FOLDER_PATH=$1
ADB_PATH=${FASTBOOT_FOLDER_PATH}"adb"

ARCHIVE_PATH=$2
ARCHIVE_FOLDER_PATH=$(dirname "$2")"/"

echo "Archive Path="$ARCHIVE_FOLDER_PATH

device_model=$3

echo "Model="$device_model


if ! "$ADB_PATH" shell getprop ro.build.version.security_patch
then
    exit 1
fi

SECURITY_PATCH=${ARCHIVE_FOLDER_PATH}""${device_model}"-security-patch"
DEVICE_STATE=${ARCHIVE_FOLDER_PATH}""${device_model}"-device-state"
MURENA_ROM_INFO=${ARCHIVE_FOLDER_PATH}""${device_model}"-rom-info"

curl -o $MURENA_ROM_INFO https://images.ecloud.global/stable/FP5/e-latest-t-FP5.zip.prop

MURENA__SECURITY_PATCH=`sed -n 's/^ro.build.version.security_patch=//p' $MURENA_ROM_INFO`
expr "$MURENA__SECURITY_PATCH" : '\(^[0-9]\{4\}-\(0[1-9]\|1[012]\)-\(0[1-9]\|[12][0-9]\|3[01]\)$\)' && echo "MURENA__SECURITY_PATCH is valid!" || exit 1

echo "MURENA__SECURITY_PATCH=$MURENA__SECURITY_PATCH"

# For FP4 on stock ROM the key [ro.build.flavor] returns [qssi-user].
# On Murena OS: returns [lineage_FP4-userdebug]
# This seems to be the most sane way to assert if we are on stock ROM
echo "" > $SECURITY_PATCH
if "$ADB_PATH" shell getprop ro.build.flavor 2>&1 | grep "qssi-user"
then
	if "$ADB_PATH" shell getprop ro.boot.vbmeta.device_state 2>&1 | grep "unlocked"
	then
		echo "Device is unlocked"
	else
		echo "Device is locked"
		# Device is locked and on stock ROM. The prop will NOT be spoofed and can be trusted.
		# NOTE: In case of an empty result we will skip locking later.
		"$ADB_PATH" shell getprop ro.build.version.security_patch> $SECURITY_PATCH
	fi
fi

exit 0
+0 −325
Original line number Diff line number Diff line
:: Copyright (C) 2020 - Author: Ingo; update and adoption to FP4, 2022 by ff2u
:: Copyright (C) 2020 ECORP SAS - Author: Vincent Bourgmayer
::
:: This program is free software: you can redistribute it and/or modify
:: it under the terms of the GNU General Public License as published by
:: the Free Software Foundation, either version 3 of the License, or
:: (at your option) any later version.
::
:: This program is distributed in the hope that it will be useful,
:: but WITHOUT ANY WARRANTY; without even the implied warranty of
:: MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
:: GNU General Public License for more details.
::
:: You should have received a copy of the GNU General Public License
:: along with this program.  If not, see <https://www.gnu.org/licenses/>.

:: Parameter
:: $1: ARCHIVE_PATH path to the /e/ archive to flash
:: $2: FASTBOOT_FOLDER_PATH: the path where runnable fastboot is stored
:: $3: JAVA_FOLDER_PATH: the path where runnable jar is stored (to unpack ZIP file)

:: Exit status
:: - 0 : /e/ installed
:: - 1 : erasing userdata or metadata failed
:: - 2 : flashing of a non-critical partition failed
:: - 4 : setting active slot to a failed
:: - 5 : flashing of a critical partition failed
::       namely: {devcfg_ab, xbl_ab, tz_ab, hyp_ab, keymaster_ab, abl_ab, aop_ab, imagefv_ab, multiimgoem_ab, qupfw_ab, uefisecapp_ab, xbl_config_ab}
:: - 101 : ARCHIVE_PATH missing
:: - 102 : archive could not be unpacked

set ARCHIVE_PATH=%~1
set FASTBOOT_FOLDER_PATH=%~2
set FASTBOOT_PATH="%FASTBOOT_FOLDER_PATH%fastboot"
set JAVA_FOLDER_PATH=%~3
set JAR_PATH="%JAVA_FOLDER_PATH%\bin\jar"

if not defined %ARCHIVE_PATH (
  exit /b 101
)

for %%a in ("%ARCHIVE_PATH%") do (
	set ARCHIVE_NAME="%%~na"
)

for %%a in ("%ARCHIVE_PATH%") do (
	set ARCHIVE_FOLDER_PATH="%%~dpa"
)

echo "archive path : "%ARCHIVE_PATH%
echo "archive folder path : "%ARCHIVE_FOLDER_PATH%
echo "fastboot path : "%FASTBOOT_PATH%
echo "jar path : "%JAR_PATH%

cd "%ARCHIVE_FOLDER_PATH%"
waitfor /t 1 pause 2>nul

%JAR_PATH% -x -v -f "%ARCHIVE_PATH%"
if errorLevel 1 ( exit /b 102 )
echo "unpacked archive"
waitfor /t 1 pause 2>nul

echo "=== Flash slot a ==="

%FASTBOOT_PATH% flash bluetooth_a bluetooth.img
if errorLevel 1 ( exit /b 2 )
echo "flashed bluetooth_a"
waitfor /t 1 pause 2>nul

%FASTBOOT_PATH% flash devcfg_a devcfg.img
if errorLevel 1 ( exit /b 5 )
echo "flashed devcfg_a"
waitfor /t 1 pause 2>nul

%FASTBOOT_PATH% flash dsp_a dsp.img
if errorLevel 1 ( exit /b 2 )
echo "flashed dsp_a"
waitfor /t 1 pause 2>nul

%FASTBOOT_PATH% flash modem_a modem.img
if errorLevel 1 ( exit /b 2 )
echo "flashed modem_a"
waitfor /t 1 pause 2>nul

%FASTBOOT_PATH% flash xbl_a xbl.img
if errorLevel 1 ( exit /b 5 )
echo "flashed xbl_a"
waitfor /t 1 pause 2>nul

%FASTBOOT_PATH% flash tz_a tz.img
if errorLevel 1 ( exit /b 5 )
echo "flashed tz_a"
waitfor /t 1 pause 2>nul

%FASTBOOT_PATH% flash hyp_a hyp.img
if errorLevel 1 ( exit /b 5 )
echo "flashed hyp_a"
waitfor /t 1 pause 2>nul

%FASTBOOT_PATH% flash keymaster_a keymaster.img
if errorLevel 1 ( exit /b 5 )
echo "flashed keymaster_a"
waitfor /t 1 pause 2>nul


%FASTBOOT_PATH% flash abl_a abl.img
if errorLevel 1 ( exit /b 5 )
echo "flashed abl_a"
waitfor /t 1 pause 2>nul

%FASTBOOT_PATH% flash boot_a boot.img
if errorLevel 1 ( exit /b 2 )
echo "flashed boot_a"
waitfor /t 1 pause 2>nul

%FASTBOOT_PATH% flash dtbo_a dtbo.img
if errorLevel 1 ( exit /b 2 )
echo "flashed dtbo"
waitfor /t 1 pause 2>nul

%FASTBOOT_PATH% flash vendor_boot_a vendor_boot.img
if errorLevel 1 ( exit /b 2 )
echo "flashed vendor_boot_a"
waitfor /t 1 pause 2>nul

%FASTBOOT_PATH% flash vbmeta_system_a vbmeta_system.img
if errorLevel 1 ( exit /b 2 )
echo "flashed vbmeta_system_a"
waitfor /t 1 pause 2>nul

%FASTBOOT_PATH% flash vbmeta_a vbmeta.img
if errorLevel 1 ( exit /b 2 )
echo "flashed vbmeta_a"
waitfor /t 1 pause 2>nul

%FASTBOOT_PATH% flash super super.img
if errorLevel 1 ( exit /b 2 )
echo "flashed super"
waitfor /t 1 pause 2>nul


%FASTBOOT_PATH% flash aop_a aop.img
if errorLevel 1 ( exit /b 5 )
echo "flashed aop_a"
waitfor /t 1 pause 2>nul

%FASTBOOT_PATH% flash featenabler_a featenabler.img
if errorLevel 1 ( exit /b 2 )
echo "flashed featenabler_a"
waitfor /t 1 pause 2>nul

%FASTBOOT_PATH% flash imagefv_a imagefv.img
if errorLevel 1 ( exit /b 5 )
echo "flashed imagefv_a"
waitfor /t 1 pause 2>nul

%FASTBOOT_PATH% flash multiimgoem_a multiimgoem.img
if errorLevel 1 ( exit /b 5 )
echo "flashed multiimgoem_a"
waitfor /t 1 pause 2>nul

%FASTBOOT_PATH% flash qupfw_a qupfw.img
if errorLevel 1 ( exit /b 5 )
echo "flashed qupfw_a"
waitfor /t 1 pause 2>nul

%FASTBOOT_PATH% flash uefisecapp_a uefisecapp.img
if errorLevel 1 ( exit /b 5 )
echo "flashed uefisecapp_a"
waitfor /t 1 pause 2>nul

%FASTBOOT_PATH% flash xbl_config_a xbl_config.img
if errorLevel 1 ( exit /b 5 )
echo "flashed xbl_config_a"
waitfor /t 1 pause 2>nul

%FASTBOOT_PATH% flash cpucp_a cpucp.img
if errorLevel 1 ( exit /b 2 )
echo "flashed cpucp_b"
waitfor /t 1 pause 2>nul

%FASTBOOT_PATH% flash shrm_a shrm.img
if errorLevel 1 ( exit /b 2 )
echo "flashed shrm_b"
waitfor /t 1 pause 2>nul


echo "=== Flash slot b ==="

%FASTBOOT_PATH% flash bluetooth_b bluetooth.img
if errorLevel 1 ( exit /b 2 )
echo "flashed bluetooth_b"
waitfor /t 1 pause 2>nul

%FASTBOOT_PATH% flash devcfg_b devcfg.img
if errorLevel 1 ( exit /b 5 )
echo "flashed devcfg_b"
waitfor /t 1 pause 2>nul

%FASTBOOT_PATH% flash dsp_b dsp.img
if errorLevel 1 ( exit /b 2 )
echo "flashed dsp_b"
waitfor /t 1 pause 2>nul

%FASTBOOT_PATH% flash modem_b modem.img
if errorLevel 1 ( exit /b 2 )
echo "flashed modem_b"
waitfor /t 1 pause 2>nul

%FASTBOOT_PATH% flash xbl_b xbl.img
if errorLevel 1 ( exit /b 5 )
echo "flashed xbl_b"
waitfor /t 1 pause 2>nul

%FASTBOOT_PATH% flash tz_b tz.img
if errorLevel 1 ( exit /b 5 )
echo "flashed tz_b"
waitfor /t 1 pause 2>nul

%FASTBOOT_PATH% flash hyp_b hyp.img
if errorLevel 1 ( exit /b 5 )
echo "flashed hyp_b"
waitfor /t 1 pause 2>nul

%FASTBOOT_PATH% flash keymaster_b keymaster.img
if errorLevel 1 ( exit /b 5 )
echo "flashed keymaster_b"
waitfor /t 1 pause 2>nul


%FASTBOOT_PATH% flash abl_b abl.img
if errorLevel 1 ( exit /b 5 )
echo "flashed abl_b"
waitfor /t 1 pause 2>nul

%FASTBOOT_PATH% flash boot_b boot.img
if errorLevel 1 ( exit /b 2 )
echo "flashed boot_b"
waitfor /t 1 pause 2>nul

%FASTBOOT_PATH% flash dtbo_b dtbo.img
if errorLevel 1 ( exit /b 2 )
echo "flashed dtbo_b"
waitfor /t 1 pause 2>nul

%FASTBOOT_PATH% flash vendor_boot_b vendor_boot.img
if errorLevel 1 ( exit /b 2 )
echo "flashed vendor_boot_b"
waitfor /t 1 pause 2>nul

%FASTBOOT_PATH% flash vbmeta_system_b vbmeta_system.img
if errorLevel 1 ( exit /b 2 )
echo "flashed vbmeta_system_b"
waitfor /t 1 pause 2>nul

%FASTBOOT_PATH% flash vbmeta_b vbmeta.img
if errorLevel 1 ( exit /b 2 )
echo "flashed vbmeta_b"
waitfor /t 1 pause 2>nul

%FASTBOOT_PATH% flash aop_b aop.img
if errorLevel 1 ( exit /b 5 )
echo "flashed aop_b"
waitfor /t 1 pause 2>nul

%FASTBOOT_PATH% flash featenabler_b featenabler.img
if errorLevel 1 ( exit /b 2 )
echo "flashed featenabler_b"
waitfor /t 1 pause 2>nul

%FASTBOOT_PATH% flash imagefv_b imagefv.img
if errorLevel 1 ( exit /b 5 )
echo "flashed imagefv_b"
waitfor /t 1 pause 2>nul

%FASTBOOT_PATH% flash multiimgoem_b multiimgoem.img
if errorLevel 1 ( exit /b 5 )
echo "flashed multiimgoem_b"
waitfor /t 1 pause 2>nul

%FASTBOOT_PATH% flash qupfw_b qupfw.img
if errorLevel 1 ( exit /b 5 )
echo "flashed qupfw_b"
waitfor /t 1 pause 2>nul

%FASTBOOT_PATH% flash uefisecapp_b uefisecapp.img
if errorLevel 1 ( exit /b 5 )
echo "flashed uefisecapp_b"
waitfor /t 1 pause 2>nul

%FASTBOOT_PATH% flash xbl_config_b xbl_config.img
if errorLevel 1 ( exit /b 5 )
echo "flashed xbl_config_b"
waitfor /t 1 pause 2>nul

%FASTBOOT_PATH% flash cpucp_b cpucp.img
if errorLevel 1 ( exit /b 2 )
echo "flashed cpucp_b"
waitfor /t 1 pause 2>nul

%FASTBOOT_PATH% flash shrm_b shrm.img
if errorLevel 1 ( exit /b 2 )
echo "flashed shrm_b"
waitfor /t 1 pause 2>nul

echo "=== Wiping userdata and metadata ==="
waitfor /t 3 pause 2>nul

%FASTBOOT_PATH% erase userdata
if errorLevel 1 ( exit /b 1 )
echo "wiped userdata"
waitfor /t 1 pause 2>nul

%FASTBOOT_PATH% erase metadata
if errorLevel 1 ( exit /b 1 )
echo "wiped metadata"
waitfor /t 3 pause 2>nul

echo "=== Setting active slot to a ==="
%FASTBOOT_PATH% --set-active=a
if errorLevel 1 ( exit /b 4 )
echo "switched slot to a"
waitfor /t 1 pause 2>nul

exit /b 0
+0 −83
Original line number Diff line number Diff line
:: Copyright (C) 2022 - Author: Frank
::
:: This program is free software: you can redistribute it and/or modify
:: it under the terms of the GNU General Public License as published by
:: the Free Software Foundation, either version 3 of the License, or
:: (at your option) any later version.
::
:: This program is distributed in the hope that it will be useful,
:: but WITHOUT ANY WARRANTY; without even the implied warranty of
:: MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
:: GNU General Public License for more details.
::
:: You should have received a copy of the GNU General Public License
:: along with this program.  If not, see <https://www.gnu.org/licenses/>.
::
:: TODO: What if 2 devices detected?
:: Parameter
:: $1: The folder where fastboot runnable is stored
:: $2: The archive folder 
:: $3: The device model
::
:: Exit status
:: - 0 : Device in fastboot mode detected
:: - 1 : Error (adb)
:: - 2 : Error (device locked)

:: Store ROM information on the file system 

@echo OFF



set FASTBOOT_FOLDER_PATH=%~1
set ADB_PATH="%FASTBOOT_FOLDER_PATH%adb"

echo "adb command=%ADB_PATH%""

set ARCHIVE_PATH=%~2
echo "Archive Path=%ARCHIVE_PATH%"
for %%a in ("%ARCHIVE_PATH%") do (
	set ARCHIVE_FOLDER_PATH="%%~dpa
)

echo "Archive Folder Path="%ARCHIVE_FOLDER_PATH%

set device_model=%~3

echo "Model=%device_model%"

%ADB_PATH% shell getprop ro.build.version.security_patch

if errorLevel 1 (
	echo "adb error (1)"
    exit /b 1
)

set SECURITY_PATCH=%ARCHIVE_FOLDER_PATH%%device_model%-security-patch"
set DEVICE_STATE=%ARCHIVE_FOLDER_PATH%%device_model%-device-state"
set MURENA_ROM_INFO=%ARCHIVE_FOLDER_PATH%%device_model%-rom-info"

bitsadmin.exe /transfer "RomInfo" https://images.ecloud.global/stable/FP5/e-latest-t-FP5.zip.prop %MURENA_ROM_INFO% > nul

:: For FP4 on stock ROM the key [ro.build.flavor] returns [qssi-user].
:: On Murena OS: returns [lineage_FP4-userdebug]
:: This seems to be the most sane way to assert if we are on stock ROM
copy /y NUL %SECURITY_PATCH% >NUL 

%ADB_PATH% shell getprop ro.build.flavor 2>&1 | findstr  "qssi-user"
if errorLevel 1 (
	::We are NOT on a stock ROM let's assume the job (unlock) is done and continue the process.
	echo "Custom ROM case"
	exit /b 0
)

echo "Stock ROM"
%ADB_PATH% shell  getprop ro.boot.vbmeta.device_state 2>&1 | findstr "unlocked"
if errorLevel 1 (
	echo "The device is locked"
	%ADB_PATH% shell getprop ro.build.version.security_patch> %SECURITY_PATCH%
)

exit /b 0
+0 −243

File deleted.

Preview size limit exceeded, changes collapsed.

Loading