Android 8.1 USB连接模式默认为MTP
最近收到项目需求,要求设备默认的USB连接模式为MTP,具体修改参照如下:
/frameworks/base/services/usb/java/com/android/server/usb/UsbDeviceManager.java
public void handleMessage(Message msg) {
switch (msg.what) {
case MSG_UPDATE_STATE:
mConnected = (msg.arg1 == 1);
mConfigured = (msg.arg2 == 1);
updateUsbNotification(false);
updateAdbNotification(false);
if (mBootCompleted) {
updateUsbStateBroadcastIfNeeded(getAppliedFunctions(mCurrentFunctions));
}
if ((mCurrentFunctions & UsbManager.FUNCTION_ACCESSORY) != 0) {
updateCurrentAccessory();
}
if (mBootCompleted) {
if (!mConnected && !hasMessages(MSG_ACCESSORY_MODE_ENTER_TIMEOUT)