在开机的时候,默认开启USB调试,这对开发来说提供了方便。至于如何做到开机开启USB调试,进行如下操作:
1. 修改Android SDK/frameworks/base/services/java/com/android/server/usb/UsbDeviceManager.java
public void systemReady() {
if (DEBUG) Slog.d(TAG, "systemReady");
mNotificationManager = (NotificationManager)
mContext.getSystemService(Context.NOTIFICATION_SERVICE);
// We do not show the USB notification if the primary volume supports mass storage.
// The legacy mass storage UI will be used instead.
boolean massStorageSupported = false;
final StorageManager storageManager = StorageManager.from(mContext);
final StorageVolume primary = storageManager.getPrimaryVolume();
massStorageSupported = primary != null && primary.allowMassStorage();
mUseUsbNotification = !massStorageSupported;
// make sure the ADB_ENABLED setting value matches the current state
//Settings.Global.putInt(mContentResolver, Settings.Global.ADB_ENABLED, mAdbEnabled ? 1 : 0);
//modify by skm@2014 support usb dbg on boot
Settings.Global.putInt(mContentResolver, Settings.Global.ADB_ENABLED, 1); //开机默认开启usb调试
mHandler.sendEmptyMessage(MSG_SYSTEM_READY);
}
2. 重新编译
#cd Android SDK/frameworks/base/services/java
#mm
重新生成新的service.jar,将service.jar拷贝到设备的/system/framework/目录下,替换原来的,重新开机即可自动开启usb调试
3. adb 使用小插曲
I. adb USB连接
#adb devices //查看当前连接上的adb 设备
#adb shell //如果只有一台设备,则直接连接上去,如有多台设备,需要执行#adb -s xxx shell
II. adb 网络连接
1. 通过串口到设备终端设置adb网络连接属性,这个需要以root权限进入
#setprop service.adb.tcp.port 5555
#stop adbd
#start adbd
#buxybox ifconfig //查看设备端的ip地址
2. 在windows上打开命令行终端
#adb connect 192.168.1.xxx //设备地址
#adb get-state //查看连接是否成功
#adb shell //进行连接
个人开发来说,比较喜欢用网络进行连接,adb网络连接就可以避开用豌豆荚,百度助手这种工具,没有用这种工具直接用adb shell连接不上,估计是没有设置好驱动的原因,使用第三方工具总是往里面安装些乱七八糟的东西,不方便调试。