|
| 1 | +#!/bin/sh |
| 2 | +# Name: Check OTA Status |
| 3 | +# Author: neura |
| 4 | +# Icon: |
| 5 | +# Created: jan-08-2025 |
| 6 | +# Modified: jan-09-2025 |
| 7 | +# Version: 1.1 |
| 8 | +# Description: This scriptlet checks the status of OTA (Over-The-Air) update binaries on Kindle devices and informs the user whether updates are enabled or blocked. |
| 9 | +# |
| 10 | +# Changelog: |
| 11 | +# - jan-09-2025: added dynamic touch device detection in order to increase the compatibility across devices. |
| 12 | +# - jan-08-2025: first working version (works on KT4 using event2 device). |
| 13 | + |
| 14 | +# Check the status of OTA binaries |
| 15 | +if [ -f /usr/bin/otaupd.bck ] && [ -f /usr/bin/otav3.bck ]; then |
| 16 | + MESSAGE1="OTA blocking is enabled." |
| 17 | + MESSAGE2="Your Kindle will NOT update." |
| 18 | + MESSAGE3="Your jailbreak is safe." |
| 19 | + MESSAGE4="Wanna restore OTA? Enable Airplane mode." |
| 20 | + |
| 21 | +elif [ -f /usr/bin/otaupd ] && [ -f /usr/bin/otav3 ]; then |
| 22 | + MESSAGE1="OTA blocking is disabled." |
| 23 | + MESSAGE2="Your Kindle can be updated." |
| 24 | + MESSAGE3="Your jailbreak is in danger." |
| 25 | + MESSAGE4="Rename OTA binaries to keep jailbreak." |
| 26 | + |
| 27 | +else |
| 28 | + MESSAGE1="OTA binaries are corrupted." |
| 29 | + MESSAGE2="Check manually." |
| 30 | + MESSAGE3="" # No third message |
| 31 | + MESSAGE4="" # No fourth message |
| 32 | +fi |
| 33 | + |
| 34 | +# Function to force a full screen refresh |
| 35 | +force_refresh() { |
| 36 | + eips -c > /dev/null 2>&1 # Clear the screen silently |
| 37 | + eips -c > /dev/null 2>&1 # Double clear to ensure full refresh |
| 38 | + sleep 1 # Use integer value for sleep |
| 39 | +} |
| 40 | + |
| 41 | +# Function to detect the correct touch device |
| 42 | +detect_touch_device() { |
| 43 | + awk '{ |
| 44 | + if ($1 == "Section" && $2 == "\"InputDevice\"") { isInput=1 }; |
| 45 | + if ($2 == "\"Device\"" && isInput) { inputDevice=$3; hasInputDevice=1 }; |
| 46 | + if ($2 == "\"CorePointer\"" && hasInputDevice && isInput) { |
| 47 | + gsub(/\"/, "", inputDevice); |
| 48 | + print inputDevice |
| 49 | + } |
| 50 | + }' /etc/xorg.conf |
| 51 | +} |
| 52 | + |
| 53 | +# Set the correct touch device dynamically |
| 54 | +TOUCH_DEVICE=$(detect_touch_device) |
| 55 | +if [ -z "$TOUCH_DEVICE" ]; then |
| 56 | + echo "Error: Could not detect touch device." |
| 57 | + exit 1 |
| 58 | +fi |
| 59 | + |
| 60 | +# Print the detected touch device (uncomment for debugging) |
| 61 | +# echo "[ DEBUG ] Detected touch device: $TOUCH_DEVICE" |
| 62 | + |
| 63 | +# Display the messages with forced refresh |
| 64 | +force_refresh |
| 65 | +eips 0 0 "$MESSAGE1" > /dev/null 2>&1 # Display the first message |
| 66 | +eips 0 1 "$MESSAGE2" > /dev/null 2>&1 # Display the second message |
| 67 | +if [ -n "$MESSAGE3" ]; then # Check if there's a third message |
| 68 | + eips 0 2 "$MESSAGE3" > /dev/null 2>&1 |
| 69 | +fi |
| 70 | +if [ -n "$MESSAGE4" ]; then # Check if there's a fourth message |
| 71 | + eips 0 3 "$MESSAGE4" > /dev/null 2>&1 |
| 72 | +fi |
| 73 | +eips 0 5 "Tap the screen to exit." > /dev/null 2>&1 # Display instructions |
| 74 | + |
| 75 | +# Wait for a tap |
| 76 | +while :; do |
| 77 | + # Refresh the screen periodically to keep messages visible |
| 78 | + force_refresh |
| 79 | + eips 0 0 "$MESSAGE1" > /dev/null 2>&1 |
| 80 | + eips 0 1 "$MESSAGE2" > /dev/null 2>&1 |
| 81 | + if [ -n "$MESSAGE3" ]; then |
| 82 | + eips 0 2 "$MESSAGE3" > /dev/null 2>&1 |
| 83 | + fi |
| 84 | + if [ -n "$MESSAGE4" ]; then |
| 85 | + eips 0 3 "$MESSAGE4" > /dev/null 2>&1 |
| 86 | + fi |
| 87 | + eips 0 5 "Tap the screen to exit." > /dev/null 2>&1 |
| 88 | + |
| 89 | + # Wait for a touch event to occur |
| 90 | + dd if="$TOUCH_DEVICE" bs=16 count=1 2>/dev/null | grep -q . |
| 91 | + if [ $? -eq 0 ]; then |
| 92 | + break |
| 93 | + fi |
| 94 | + |
| 95 | + sleep 1 # Reduce CPU usage |
| 96 | +done |
| 97 | + |
| 98 | +# Clear the screen and return to home |
| 99 | +force_refresh |
| 100 | +lipc-set-prop com.lab126.appmgrd start app://com.lab126.booklet.home |
0 commit comments