Last active
October 18, 2025 15:10
-
-
Save pexcn/53ba5e4e609495c1fff64c39946f141f to your computer and use it in GitHub Desktop.
Keep xiaomi camera connected
This file contains hidden or 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
| #!/system/bin/sh | |
| until [ -d "/sdcard/Android" ]; do | |
| sleep 3 | |
| done | |
| sleep 10 | |
| sh /sdcard/xiaomi-camera-checker.sh >>/sdcard/xiaomi-camera-checker.log 2>&1 |
This file contains hidden or 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
| #!/system/bin/sh | |
| # | |
| # Usage: | |
| # sh /sdcard/xiaomi-camera-checker.sh &> /sdcard/xiaomi-camera-checker.log & | |
| # | |
| info() { | |
| printf "[$(date '+%Y-%m-%d %T')]: %s\n" "$*" | |
| } | |
| is_disconnect() { | |
| local screenshot_1="/tmp/screenshot_1.png" | |
| local screenshot_2="/tmp/screenshot_2.png" | |
| screencap -p $screenshot_1 | |
| screencap -p $screenshot_2 | |
| cmp -s $screenshot_1 $screenshot_2 | |
| } | |
| while true; do | |
| if is_disconnect; then | |
| info "camera is disconnected, try restart to re-connect..." | |
| info "$(am force-stop com.xiaomi.smarthome 2>&1 </dev/null)" | |
| sleep 1 | |
| info "$(am start -n com.xiaomi.smarthome/.SmartHomeMainActivity 2>&1 </dev/null)" | |
| sleep 5 | |
| info "$(am start -n com.xiaomi.smarthome/.listcamera.CameraHorizontalActivity --es did 0000000000 --ez isAutoPlay true --ez isMute false --ez isQuickPass false 2>&1 </dev/null)" | |
| sleep 1 | |
| info "$(input tap 1785 780 2>&1 </dev/null)" | |
| fi | |
| sleep 10 | |
| done |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment