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

Commit 81861849 authored by vince-bourgmayer's avatar vince-bourgmayer
Browse files

add wait-download.bat and wait-recovery.bat (not over). Update wait-reboot.bat

parent 3228817d
Loading
Loading
Loading
Loading
+35 −0
Original line number Diff line number Diff line
::!/bin/bash

:: Copyright (C) 2019 ECORP SAS - Author: Romain Hunault
::
:: 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?

:: Exit status
:: - 0 : Device in download mode detected
:: - 1 : Error


:heimdall_detect
heimdall detect >nul 2>&1
if errorLevel EQU 1 (
	timeout 1 >nul
	goto :heimdall_detect
) 


call heimdall_detect

timeout 5 >nul
+1 −3
Original line number Diff line number Diff line
@@ -29,9 +29,7 @@ set "DEVICE_ID=%1"
if not defined %DEVICE_ID ( exit /b 10)

:device_in_recovery
{
	adb devices | findstr recovery | grep %DEVICE_ID% 2>&1 >nul
}

if not call :device_in_recovery ( exit /b 101 )

+79 −0
Original line number Diff line number Diff line
::!/bin/bash

:: Copyright (C) 2019 ECORP SAS - Author: Romain Hunault
::
:: 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: test if a device go from "sideload" mode to recovery

:: Parameter
:: $1: DEVICES_LOCKED_PATH temp folder where are stored locked devices
:: $2: DEVICE_ID ID of the device to wait

:: Return
:: - displayed: DEVICE_ID device detected

:: Exit status
:: - 0 : New device detected
:: - 1 : Error
:: - 101 : DEVICES_LOCKED_PATH missing

set "DEVICES_LOCKED_PATH=%1"
set "DEVICE_ID=%2"

if not defined %DEVICES_LOCKED_PATH (
  exit /b 101
)

:no_device_id
    adb devices | findstr --perl-regex "%DEVICE_ID%\trecovery"
    if not errorLevel 1 (
      adb -s %DEVICE_ID% shell twrp mount system
      exit /b 0
    )
    else (GOTO :no_device_id)


if not defined %DEVICE_ID (
  call :no_device_id
)

:newDevice
{
  ::replace for loop
  for device in $(adb devices | findstr recovery | sed 's/\(.*\)\s*recovery/\1/')
  do
    if [ ! -f %DEVICES_LOCKED_PATH%/%device% ] (
      echo %device%
    )
  done
}

set "new_device=false"


:not_new_device
if not %newDevice (
  SET DEVICE_ID=$(newDevice)
  if defined %DEVICE_ID (
    set "new_device=true"
  )
  timeout 1 >nul
)else (GOTO :not_new_device)

call :not_new_device

adb -s %DEVICE_ID% shell twrp mount system

echo %DEVICE_ID%