Add checkbox to enable PTP USB mode.
Change-Id: Icb139cc3d1077565fb8dbe9917d87c7337f59797 Signed-off-by: Mike Lockwood <lockwood@android.com>
This commit is contained in:
@@ -1325,7 +1325,10 @@
|
|||||||
<string name="sd_eject">Unmount SD card</string>
|
<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. -->
|
<!-- 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>
|
<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 -->
|
<!-- 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>
|
<string name="sd_insert_summary">Insert an SD card for mounting</string>
|
||||||
|
@@ -39,6 +39,9 @@
|
|||||||
style="?android:attr/preferenceInformationStyle"
|
style="?android:attr/preferenceInformationStyle"
|
||||||
android:title="@string/memory_available"
|
android:title="@string/memory_available"
|
||||||
android:summary="00"/>
|
android:summary="00"/>
|
||||||
|
<CheckBoxPreference android:key="ptp_mode_toggle"
|
||||||
|
android:title="@string/ptp_mode"
|
||||||
|
android:summary="@string/ptp_mode_summary"/>
|
||||||
</PreferenceCategory>
|
</PreferenceCategory>
|
||||||
|
|
||||||
</PreferenceScreen>
|
</PreferenceScreen>
|
||||||
|
@@ -31,6 +31,7 @@ import android.content.DialogInterface.OnCancelListener;
|
|||||||
import android.content.pm.ApplicationInfo;
|
import android.content.pm.ApplicationInfo;
|
||||||
import android.content.res.Resources;
|
import android.content.res.Resources;
|
||||||
import android.os.Bundle;
|
import android.os.Bundle;
|
||||||
|
import android.hardware.Usb;
|
||||||
import android.os.Environment;
|
import android.os.Environment;
|
||||||
import android.os.IBinder;
|
import android.os.IBinder;
|
||||||
import android.os.RemoteException;
|
import android.os.RemoteException;
|
||||||
@@ -39,8 +40,10 @@ import android.os.StatFs;
|
|||||||
import android.os.storage.IMountService;
|
import android.os.storage.IMountService;
|
||||||
import android.os.storage.StorageEventListener;
|
import android.os.storage.StorageEventListener;
|
||||||
import android.os.storage.StorageManager;
|
import android.os.storage.StorageManager;
|
||||||
|
import android.preference.CheckBoxPreference;
|
||||||
import android.preference.Preference;
|
import android.preference.Preference;
|
||||||
import android.preference.PreferenceScreen;
|
import android.preference.PreferenceScreen;
|
||||||
|
import android.provider.Settings;
|
||||||
import android.text.format.Formatter;
|
import android.text.format.Formatter;
|
||||||
import android.util.Log;
|
import android.util.Log;
|
||||||
import android.widget.Toast;
|
import android.widget.Toast;
|
||||||
@@ -60,6 +63,8 @@ public class Memory extends SettingsPreferenceFragment implements OnCancelListen
|
|||||||
|
|
||||||
private static final String MEMORY_SD_FORMAT = "memory_sd_format";
|
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_CONFIRM_UNMOUNT = 1;
|
||||||
private static final int DLG_ERROR_UNMOUNT = 2;
|
private static final int DLG_ERROR_UNMOUNT = 2;
|
||||||
|
|
||||||
@@ -69,6 +74,7 @@ public class Memory extends SettingsPreferenceFragment implements OnCancelListen
|
|||||||
private Preference mSdAvail;
|
private Preference mSdAvail;
|
||||||
private Preference mSdMountToggle;
|
private Preference mSdMountToggle;
|
||||||
private Preference mSdFormat;
|
private Preference mSdFormat;
|
||||||
|
private CheckBoxPreference mPtpModeToggle;
|
||||||
|
|
||||||
// Access using getMountService()
|
// Access using getMountService()
|
||||||
private IMountService mMountService = null;
|
private IMountService mMountService = null;
|
||||||
@@ -91,6 +97,16 @@ public class Memory extends SettingsPreferenceFragment implements OnCancelListen
|
|||||||
mSdAvail = findPreference(MEMORY_SD_AVAIL);
|
mSdAvail = findPreference(MEMORY_SD_AVAIL);
|
||||||
mSdMountToggle = findPreference(MEMORY_SD_MOUNT_TOGGLE);
|
mSdMountToggle = findPreference(MEMORY_SD_MOUNT_TOGGLE);
|
||||||
mSdFormat = findPreference(MEMORY_SD_FORMAT);
|
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
|
@Override
|
||||||
@@ -157,6 +173,11 @@ public class Memory extends SettingsPreferenceFragment implements OnCancelListen
|
|||||||
intent.setClass(getActivity(), com.android.settings.MediaFormat.class);
|
intent.setClass(getActivity(), com.android.settings.MediaFormat.class);
|
||||||
startActivity(intent);
|
startActivity(intent);
|
||||||
return true;
|
return true;
|
||||||
|
} else if (preference == mPtpModeToggle) {
|
||||||
|
Settings.System.putInt(getContentResolver(),
|
||||||
|
Settings.System.USE_PTP_INTERFACE,
|
||||||
|
mPtpModeToggle.isChecked() ? 1 : 0);
|
||||||
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
return false;
|
return false;
|
||||||
|
Reference in New Issue
Block a user