Skip to content

Instantly share code, notes, and snippets.

@Miuzarte
Created March 20, 2026 16:11
Show Gist options
  • Select an option

  • Save Miuzarte/9062915f1615d5eebd363c759fda496c to your computer and use it in GitHub Desktop.

Select an option

Save Miuzarte/9062915f1615d5eebd363c759fda496c to your computer and use it in GitHub Desktop.
Magisk/KernelSU 模块实现开机自动启用 adb
#!/system/bin/sh
setprop service.adb.tcp.port 5555
stop adbd
start adbd
id=module.miuzarte.adb
name=Wireless Adb Auto Enabler
version=0.0.1
versionCode=1
author=Miuzarte
description=As the name
@a06ggg

a06ggg commented Mar 24, 2026

Copy link
Copy Markdown

对于没有SIM卡的设备,可以用模块打开USB调试(安全设置)

#!/system/bin/sh

# ==========================================
# 1. 修改系统底层属性 (Prop)
# ==========================================
# 允许通过 ADB 模拟点击和滑动 (安全设置)
setprop persist.security.adbinput 1
# 允许通过 ADB 静默安装应用 (USB安装)可选
# setprop persist.security.adbinstall 1

# ==========================================
# 2. 修改安全中心底层 XML 配置文件 - 永久欺骗看门狗
# ==========================================
XML_FILE="/data/data/com.miui.securitycenter/shared_prefs/remote_provider_preferences.xml"

# 判断配置文件是否存在 (boot-completed 阶段 data 分区已挂载)
if [ -f "$XML_FILE" ]; then
    # 如果配置项存在但值为 false,将其强行替换为 true
    sed -i 's/"security_adb_input_enable" value="false"/"security_adb_input_enable" value="true"/g' $XML_FILE
    # 如果配置项压根不存在,则在文件末尾的 </map> 前插入该配置项
    if ! grep -q 'name="security_adb_input_enable"' $XML_FILE; then
		sed -i 's/<\/map>/    <boolean name="security_adb_input_enable" value="true" \/>\n<\/map>/' $XML_FILE
    fi
fi

# ==========================================
# 3. 开启网络 ADB 监听 (5555端口)
# ==========================================
setprop service.adb.tcp.port 5555
stop adbd
start adbd

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment