Created
March 17, 2025 09:52
-
-
Save TimoPtr/e3403a752224b0d1596020a8aba78bc8 to your computer and use it in GitHub Desktop.
Find webview in google repository for a given API
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
#!/bin/bash | |
# Define the number of commits to reset | |
NUM_COMMITS=100 | |
PLATFORM=arm64 | |
ANDROID_EMULATOR_SERIAL="Pixel_3_API_21" # run `emulator -list-avds` to get the serial of the emulator | |
CHROMIUM_WEBVIEW_DIR="/Users/timo/Documents/ha/chromium-webview" | |
# Define color codes | |
RED='\033[0;31m' | |
GREEN='\033[0;32m' | |
YELLOW='\033[1;33m' | |
NC='\033[0m' # No Color | |
pushd "$CHROMIUM_WEBVIEW_DIR" | |
# Check if we are in the correct directory | |
if [ $? -ne 0 ]; then | |
printf "${RED}Fail to change directory %s${NC}\n" "$CHROMIUM_WEBVIEW_DIR" | |
exit 1 | |
fi | |
# Iterate through the commits and reset one by one | |
for ((i=0; i<NUM_COMMITS; i++)); do | |
printf "==============================\n" | |
printf "Progress %s over %s\n" "$((i+1))" "$NUM_COMMITS" | |
printf "Reseting git HEAD\n" | |
# Reset to the previous commit | |
git reset --hard HEAD~1 | |
# Check if the reset was successful | |
if [ $? -ne 0 ]; then | |
printf "${RED}Fail to reset commit number %s${NC}\n" "$i" | |
exit 1 | |
fi | |
commit_details=$(git log -1 --pretty=format:'%H - %s (%ci)') | |
printf "Current commit details: %s\n" "$commit_details" | |
webview_apk=$(find . -path "*/${PLATFORM}/webview.apk") | |
# Check if the APK exists | |
if [ -z "$webview_apk" ]; then | |
printf "${YELLOW}webview.apk not found, continue looking.${NC}\n" | |
continue | |
fi | |
printf "Current webview.apk: %s\n" "$webview_apk" | |
adb_output=$(adb install -r "$webview_apk") | |
printf "ADB output: %s\n" "$adb_output" | |
# Check if the install was successful | |
if echo "$adb_output" | grep -q "Failure"; then | |
printf "${YELLOW}Failed to install the APK, continue looking.${NC}\n" | |
else | |
printf "${GREEN}Installation success, we found the APK that works for our ADB device.${NC}\n" | |
exit 0 | |
fi | |
done | |
echo "Completed resetting $NUM_COMMITS commits." |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
For more context check https://stackoverflow.com/questions/30019960/how-to-upgrade-androids-webview-in-emulator-android-5 It basically iterate over commits available in google public repo.