亲测有效! 在展锐sl8541e android8.1代码包上面测试,只需修改两点
1.默认为debug打开模式,默认ro.debuggable=1(默认允许debug)
build/make/core/main.mk
ifeq (true,$(strip $(enable_target_debugging)))
INCLUDE_TEST_OTA_KEYS := true
else # !enable_target_debugging
# Target is less debuggable and adbd is off by default
- ADDITIONAL_DEFAULT_PROPERTIES += ro.debuggable=0
+ ADDITIONAL_DEFAULT_PROPERTIES += ro.debuggable=1
endif # !enable_target_debugging
2.去掉? ?连上USB线之后,界面弹出是否授权连接的弹出框,并默认授权连接
public void onReceive(Context content, Intent intent) {
String action = intent.getAction();
if (!UsbManager.ACTION_USB_STATE.equals(action)) {
return;
}
//boolean connected = intent.getBooleanExtra(UsbManager.USB_CONNECTED, false);
boolean connected = false; //default set false
if (!connected) {
mActivity.finish();
}
//add begin
try {
IBinder b = ServiceManager.getService(USB_SERVICE);
IUsbManager service = IUsbManager.Stub.asInterface(b);
service.allowUsbDebugging(true, mKey);
}
catch (Exception e) {
Log.e(TAG, "Unable to notify Usb service", e);
}
//add end
}
|