Merge cherrypicks of [2686350, 2686440] into oc-r4-release

Change-Id: I2398535d2be0bd039cf9ea5417b15933515f405f
diff --git a/src/com/android/providers/media/MtpReceiver.java b/src/com/android/providers/media/MtpReceiver.java
index 0895c5e..5f38018 100644
--- a/src/com/android/providers/media/MtpReceiver.java
+++ b/src/com/android/providers/media/MtpReceiver.java
@@ -36,6 +36,10 @@
     public void onReceive(Context context, Intent intent) {
         final String action = intent.getAction();
         if (Intent.ACTION_BOOT_COMPLETED.equals(action)) {
+            // If we somehow fail to configure after boot, it becomes difficult to
+            // recover usb state. Thus we always configure once on boot, but it
+            // has no effect if Mtp is disabled or already configured.
+            MtpServer.configure(false);
             final Intent usbState = context.registerReceiver(
                     null, new IntentFilter(UsbManager.ACTION_USB_STATE));
             if (usbState != null) {