-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathGSI_Flasher.bat
67 lines (53 loc) · 2.06 KB
/
GSI_Flasher.bat
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
@echo off
setlocal enabledelayedexpansion
:: Check if ADB is in the environment variables
where adb >nul 2>nul
if %errorlevel% neq 0 (
echo ADB is not found in the environment variables.
set /p ADB_PATH="Please enter the full path to adb (e.g., C:\path\to\adb): "
) else (
set ADB_PATH=adb
echo ADB is found in the environment variables.
)
:: Check if Fastboot is in the environment variables
where fastboot >nul 2>nul
if %errorlevel% neq 0 (
echo Fastboot is not found in the environment variables.
set /p FASTBOOT_PATH="Please enter the full path to fastboot (e.g., C:\path\to\fastboot): "
) else (
set FASTBOOT_PATH=fastboot
echo Fastboot is found in the environment variables.
)
:: Run Python script to check if device is connected
echo Running device check...
python check_device.py
:: Prompt user to select the GSI image using File Explorer, filtering for .img files
echo Please select the GSI image file to flash (only .img files are supported)...
for /f "delims=" %%i in ('powershell -command "(New-Object -ComObject Shell.Application).BrowseForFolder(0, 'Select GSI Image', 0, 0).Items() | Where-Object { $_.Name -like '*.img' } | Select-Object -First 1 | ForEach-Object { $_.Path }"') do set GSI_IMAGE=%%i
:: Check if a GSI image was selected
if not defined GSI_IMAGE (
echo No GSI image selected. Exiting...
exit /b
)
:: Show selected GSI image
echo You selected: "%GSI_IMAGE%"
:: Check if ADB is working
echo Checking if ADB can detect your device...
"%ADB_PATH%" devices
:: Reboot to fastboot mode
echo Rebooting to fastboot mode...
"%ADB_PATH%" reboot bootloader
:: Wait for the device to be in fastboot mode
echo Waiting for device to enter fastboot mode...
timeout /t 5
:: Flash the GSI image
echo Flashing the GSI image...
"%FASTBOOT_PATH%" flash system "%GSI_IMAGE%"
:: Wait for the flashing process to complete
echo Waiting for the flashing process to complete...
timeout /t 5
:: Reboot the device
echo Rebooting the device...
"%FASTBOOT_PATH%" reboot
echo Flashing complete! Your device should reboot into the new system image.
pause