25'ten fazla konu seçemezsiniz
Konular bir harf veya rakamla başlamalı, kısa çizgiler ('-') içerebilir ve en fazla 35 karakter uzunluğunda olabilir.
|
- #!/bin/sh
-
- set -x
-
- unlock() {
- ### Activates the screen and unlocks the phone
- # Reads the current screen state eturns any combination of ON/OFF and
- # LOCKED/UNLOCKED (i.e. OFF_LOCKED).
- # Works only on NFC enabled phones but alternative methods exist.
- IFS='_' read -ra screenstate <<< $(adb shell dumpsys nfc | awk -F'=' \
- '/mScreenState/ {print $2}')
- # Emulate Power-Button press if screen is OFF.
- [ "${screenstate[0]}" == "OFF" ] && adb shell input keyevent 26 && \
- echo Screen activated
- # Emulate Menu-button press if phone is locked. Requires the phone to
- # unlock without PIN or password.
- [ "${screenstate[1]}" == "LOCKED" ] && adb shell input keyevent 82 && \
- echo Device unlocked
- }
-
- blank() {
- ### Blanks the screen (optionally wait X seconds)
- [ -z "${1}" ] && sleep "${1}"
- IFS='_' read -ra screenstate <<< $(adb shell dumpsys nfc | awk -F'=' \
- '/mScreenState/ {print $2}')
- [ "${screenstate[0]}" == "ON" ] && adb shell input keyevent 26 && \
- echo Screen deactivated
- }
-
- run() {
- # Unlock phone
- unlock
- # Start intent
- [ -z "${1}" ] && APP="com.dev47apps.obsdroidcam" || APP="${1}"
- adb shell am start -n "${APP}/.MainActivity"
- blank 5
- }
-
- usage() {
- echo "Usage: ${0} [-u|b] [-r INTENT]
-
- -u unlock device (default if no option is given)
- -b blank device screen
- -r INTENT unlock device, run given intent and blank device screen
- -h this help"
- }
-
- while getopts ":ubr:h" opt; do
- case "${opt}" in
- u) unlock ;;
- b) blank ;;
- r) run "${OPTARG}" ;;
- h) usage ;;
- *) unlock ;;
- esac
- done
|