Android7.1默认打开mtp(mtk)

直接贴修改记录代码:

diff --git a/frameworks/base/services/usb/java/com/android/server/usb/UsbDeviceManager.java b/frameworks/b
index 23c60bb..8bb7604 100644
--- a/frameworks/base/services/usb/java/com/android/server/usb/UsbDeviceManager.java
+++ b/frameworks/base/services/usb/java/com/android/server/usb/UsbDeviceManager.java
@@ -455,7 +455,7 @@ functions = addFunction(functions, UsbManager.USB_FUNCTION_ACM);
         private boolean mSourcePower;
         private boolean mSinkPower;
         private boolean mConfigured;
-        private boolean mUsbDataUnlocked;
+        private boolean mUsbDataUnlocked = true;
         private String mCurrentFunctions;
         private String mDefaultFunctions;
         private boolean mCurrentFunctionsApplied;
@@ -1374,7 +1374,7 @@ functions = addFunction(functions, UsbManager.USB_FUNCTION_ACM);
                     mUsbConfigured = mConfigured;
                     if (!mConnected) {
                         // When a disconnect occurs, relock access to sensitive user data
-                        mUsbDataUnlocked = false;
+                        mUsbDataUnlocked = true;
                     }
                     updateUsbNotification();
                     updateAdbNotification();
@@ -1383,7 +1383,7 @@ functions = addFunction(functions, UsbManager.USB_FUNCTION_ACM);
                         updateCurrentAccessory();
                     } else if (!mConnected) {
                         // restore defaults when USB is disconnected
-                        setEnabledFunctions(null, false);
+                        setEnabledFunctions(null, true);
                     }
                     if (mBootCompleted) {
                         updateUsbStateBroadcastIfNeeded();
diff --git a/packages/apps/Settings/src/com/android/settings/deviceinfo/UsbModeChooserActivity.java b/pack
index 7da4a3b..01f3d2f 100644
--- a/packages/apps/Settings/src/com/android/settings/deviceinfo/UsbModeChooserActivity.java
+++ b/packages/apps/Settings/src/com/android/settings/deviceinfo/UsbModeChooserActivity.java
@@ -54,7 +54,7 @@ public class UsbModeChooserActivity extends Activity {
         UsbBackend.MODE_POWER_SOURCE | UsbBackend.MODE_DATA_NONE,
         UsbBackend.MODE_POWER_SINK | UsbBackend.MODE_DATA_MTP,
         UsbBackend.MODE_POWER_SINK | UsbBackend.MODE_DATA_PTP,
-        UsbBackend.MODE_POWER_SINK | UsbBackend.MODE_DATA_MIDI,
+        //UsbBackend.MODE_POWER_SINK | UsbBackend.MODE_DATA_MIDI,
         /// M: Add for Built-in CD-ROM and USB Mass Storage @{
         UsbBackend.MODE_POWER_SINK | UsbBackend.MODE_DATA_MASS_STORAGE,

你可能感兴趣的:(mtk_android)