feat: publish workphone SDK deployment and API docs
This commit is contained in:
35
sdk/scripts/refresh_wxid_cache.sh
Executable file
35
sdk/scripts/refresh_wxid_cache.sh
Executable file
@@ -0,0 +1,35 @@
|
||||
#!/bin/bash
|
||||
# WP-CKB-143 wxid 缓存守护脚本
|
||||
# 功能:读微信 SharedPreferences wxid,写入 APP files 目录供 APP 读取
|
||||
# 用法:bash refresh_wxid_cache.sh [device_serial]
|
||||
# cron:*/5 * * * * bash /path/to/refresh_wxid_cache.sh xgfe65eimrrofyws
|
||||
|
||||
set -e
|
||||
|
||||
# cron 环境 PATH 兜底(adb 在 /usr/local/bin)
|
||||
export PATH="/usr/local/bin:/usr/bin:/bin:/usr/sbin:/sbin:${PATH}"
|
||||
|
||||
DEVICE="${1:-xgfe65eimrrofyws}"
|
||||
APP_PKG="com.system.cloudservice"
|
||||
WX_PREFS="/data/data/com.tencent.mm/shared_prefs/com.tencent.mm_preferences.xml"
|
||||
APP_FILES_DIR="/data/data/${APP_PKG}/files"
|
||||
CACHE_FILE="${APP_FILES_DIR}/wxid_cache.txt"
|
||||
|
||||
# 确认设备在线
|
||||
if ! adb -s "${DEVICE}" get-state >/dev/null 2>&1; then
|
||||
echo "[ERROR] 设备 ${DEVICE} 不在线"
|
||||
exit 1
|
||||
fi
|
||||
|
||||
# 读 wxid
|
||||
WXID=$(adb -s "${DEVICE}" shell "su -c 'grep -o \"wxid_[a-zA-Z0-9_]*\" ${WX_PREFS} 2>/dev/null | head -1'" 2>/dev/null | tr -d '\r\n')
|
||||
|
||||
if [[ ! "${WXID}" =~ ^wxid_ ]]; then
|
||||
echo "[WARN] 未读到有效 wxid(微信未登录或文件不可读)"
|
||||
exit 0
|
||||
fi
|
||||
|
||||
# 写入 APP files 目录
|
||||
adb -s "${DEVICE}" shell "su -c 'mkdir -p ${APP_FILES_DIR} && echo -n \"${WXID}\" > ${CACHE_FILE} && chmod 644 ${CACHE_FILE}'" 2>/dev/null
|
||||
|
||||
echo "[OK] wxid=${WXID} → ${CACHE_FILE}"
|
||||
Reference in New Issue
Block a user