Merge "Add checkbox to enable PTP USB mode."
diff --git a/res/values/strings.xml b/res/values/strings.xml
index d709b63..23b429c 100644
--- a/res/values/strings.xml
+++ b/res/values/strings.xml
@@ -1325,7 +1325,10 @@
<string name="sd_eject">Unmount SD card</string>
<!-- SD card & phone storage settings item title that will result in the phone unmounting the SD card. This will be done before the user phyiscally removes the SD card from the phone. Kind of like the "Safely remove" on some operating systems. -->
<string name="sd_eject_summary">Unmount the SD card for safe removal</string>
-
+ <!-- SD card & phone storage settings item title for toggling PTP mode on and off. When PTP mode is on the device will appear on the USB bus as a PTP camera device instead of an MTP music player. -->
+ <string name="ptp_mode">Enable PTP mode</string>
+ <!-- SD card & phone storage settings item summary for toggling PTP mode on and off. When PTP mode is on the device will appear on the USB bus as a PTP camera device instead of an MTP music player. -->
+ <string name="ptp_mode_summary">Appear on USB as a PTP camera device instead of an MTP device</string>
<!-- SD card & phone storage settings item summary that is displayed when no SD card is inserted -->
<string name="sd_insert_summary">Insert an SD card for mounting</string>
diff --git a/res/xml/device_info_memory.xml b/res/xml/device_info_memory.xml
index c3d7a24..7bce41c 100644
--- a/res/xml/device_info_memory.xml
+++ b/res/xml/device_info_memory.xml
@@ -39,6 +39,9 @@
style="?android:attr/preferenceInformationStyle"
android:title="@string/memory_available"
android:summary="00"/>
+ <CheckBoxPreference android:key="ptp_mode_toggle"
+ android:title="@string/ptp_mode"
+ android:summary="@string/ptp_mode_summary"/>
</PreferenceCategory>
</PreferenceScreen>
diff --git a/src/com/android/settings/deviceinfo/Memory.java b/src/com/android/settings/deviceinfo/Memory.java
index 4e27837..e22c39d 100644
--- a/src/com/android/settings/deviceinfo/Memory.java
+++ b/src/com/android/settings/deviceinfo/Memory.java
@@ -31,6 +31,7 @@
import android.content.pm.ApplicationInfo;
import android.content.res.Resources;
import android.os.Bundle;
+import android.hardware.Usb;
import android.os.Environment;
import android.os.IBinder;
import android.os.RemoteException;
@@ -39,8 +40,10 @@
import android.os.storage.IMountService;
import android.os.storage.StorageEventListener;
import android.os.storage.StorageManager;
+import android.preference.CheckBoxPreference;
import android.preference.Preference;
import android.preference.PreferenceScreen;
+import android.provider.Settings;
import android.text.format.Formatter;
import android.util.Log;
import android.widget.Toast;
@@ -60,6 +63,8 @@
private static final String MEMORY_SD_FORMAT = "memory_sd_format";
+ private static final String PTP_MODE_TOGGLE = "ptp_mode_toggle";
+
private static final int DLG_CONFIRM_UNMOUNT = 1;
private static final int DLG_ERROR_UNMOUNT = 2;
@@ -69,6 +74,7 @@
private Preference mSdAvail;
private Preference mSdMountToggle;
private Preference mSdFormat;
+ private CheckBoxPreference mPtpModeToggle;
// Access using getMountService()
private IMountService mMountService = null;
@@ -91,6 +97,16 @@
mSdAvail = findPreference(MEMORY_SD_AVAIL);
mSdMountToggle = findPreference(MEMORY_SD_MOUNT_TOGGLE);
mSdFormat = findPreference(MEMORY_SD_FORMAT);
+
+ mPtpModeToggle = (CheckBoxPreference)findPreference(PTP_MODE_TOGGLE);
+ if (Usb.isFunctionSupported(Usb.USB_FUNCTION_MTP)) {
+ mPtpModeToggle.setChecked(Settings.System.getInt(
+ getContentResolver(),
+ Settings.System.USE_PTP_INTERFACE, 0) != 0);
+ } else {
+ // hide the PTP mode toggle checkbox if MTP is not supported
+ getPreferenceScreen().removePreference(mPtpModeToggle);
+ }
}
@Override
@@ -157,8 +173,13 @@
intent.setClass(getActivity(), com.android.settings.MediaFormat.class);
startActivity(intent);
return true;
+ } else if (preference == mPtpModeToggle) {
+ Settings.System.putInt(getContentResolver(),
+ Settings.System.USE_PTP_INTERFACE,
+ mPtpModeToggle.isChecked() ? 1 : 0);
+ return true;
}
-
+
return false;
}