跳到主要内容
安卓主板 · 触摸显示屏 · 固件 — 始于 2013 年

Debug switches

Static methodsSetters broadcast · Getters read settings

Turn ADB access on or off from code, capture logs, and — unusually for this API — read some of that state back.

USB ADB​

public static void setUsbDebug(Context context, boolean enable)
public static boolean getUsbDebugStatus(Context context) // returns real state
ItempApiPub.setUsbDebug(context, true);
boolean on = ItempApiPub.getUsbDebugStatus(context);

Network ADB​

public static void setNetworkDebug(Context context, boolean enable)
public static boolean getNetworkDebugStatus(Context context)
ItempApiPub.setNetworkDebug(context, true);
if (ItempApiPub.getNetworkDebugStatus(context)) {
// adb connect <device-ip>:5555 is now possible
}

Network ADB is how you reach a deployed board that has no USB port exposed. Turn it off again once provisioning is done.

Log capture​

public static void autoLogCatch(Context context, boolean enable)
ItempApiPub.autoLogCatch(context, true); // start capturing logs to storage

Notes​

The getters actually work. getUsbDebugStatus and getNetworkDebugStatus read a system setting and return the real boolean — one of the few places in this API you can confirm state directly rather than inferring it.

Leaving network ADB on is a security hole. Anyone on the LAN can connect. Enable it for provisioning, verify with the getter, disable it before the device goes into service.

Log capture fills storage. autoLogCatch(true) writes continuously. Turn it off when you are done or it will eventually fill the device.