-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
2 changed files
with
87 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,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 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,20 @@ | ||
import subprocess | ||
import sys | ||
|
||
def check_device(): | ||
# Run adb devices command | ||
result = subprocess.run(['adb', 'devices'], capture_output=True, text=True) | ||
|
||
# Check if device is listed | ||
if 'device' in result.stdout: | ||
print("Device detected.") | ||
return True | ||
else: | ||
print("No devices found.") | ||
return False | ||
|
||
if __name__ == "__main__": | ||
if not check_device(): | ||
sys.exit("Exiting... No device detected.") | ||
else: | ||
print("Device is ready for flashing.") |