From 55b7d27936f39c2d6e609c15b1086e9698dbbcfd Mon Sep 17 00:00:00 2001 From: Jake Hamby Date: Tue, 11 Jan 2011 19:27:17 -0800 Subject: [PATCH] Only show "Allow incoming file transfer" option if device supports OPP In the Bluetooth profiles settings screen for a device, the "Allow incoming file transfer" item should only be shown if the device supports the Object Push Profile. Bug: 3297633 Change-Id: I4bbe66ef901feef9dd8a3916fb9827120c1fdfc0 --- .../bluetooth/DeviceProfilesSettings.java | 26 +++++++++++++++++-- 1 file changed, 24 insertions(+), 2 deletions(-) diff --git a/src/com/android/settings/bluetooth/DeviceProfilesSettings.java b/src/com/android/settings/bluetooth/DeviceProfilesSettings.java index 79612816a17..479cbe0c8be 100644 --- a/src/com/android/settings/bluetooth/DeviceProfilesSettings.java +++ b/src/com/android/settings/bluetooth/DeviceProfilesSettings.java @@ -20,8 +20,11 @@ import com.android.settings.R; import com.android.settings.SettingsPreferenceFragment; import com.android.settings.bluetooth.LocalBluetoothProfileManager.Profile; +import android.bluetooth.BluetoothClass; import android.bluetooth.BluetoothDevice; +import android.bluetooth.BluetoothUuid; import android.os.Bundle; +import android.os.ParcelUuid; import android.preference.CheckBoxPreference; import android.preference.EditTextPreference; import android.preference.Preference; @@ -75,6 +78,7 @@ public class DeviceProfilesSettings extends SettingsPreferenceFragment if (device == null) { Log.w(TAG, "Activity started without a remote Bluetooth device"); finish(); + return; } mManager = LocalBluetoothManager.getInstance(getActivity()); @@ -82,6 +86,7 @@ public class DeviceProfilesSettings extends SettingsPreferenceFragment if (mCachedDevice == null) { Log.w(TAG, "Device not found, cannot connect to it"); finish(); + return; } addPreferencesFromResource(R.xml.bluetooth_device_advanced); @@ -89,8 +94,16 @@ public class DeviceProfilesSettings extends SettingsPreferenceFragment mProfileContainer = (PreferenceGroup) findPreference(KEY_PROFILE_CONTAINER); mAllowIncomingPref = (CheckBoxPreference) findPreference(KEY_ALLOW_INCOMING); - mAllowIncomingPref.setChecked(isIncomingFileTransfersAllowed()); - mAllowIncomingPref.setOnPreferenceChangeListener(this); + + // Configure incoming file transfer preference if device supports OPP + // or else remove the preference item + if (isObjectPushSupported(device)) { + mAllowIncomingPref.setChecked(isIncomingFileTransfersAllowed()); + mAllowIncomingPref.setOnPreferenceChangeListener(this); + } else { + getPreferenceScreen().removePreference(mAllowIncomingPref); + mAllowIncomingPref = null; + } mDeviceNamePref = (EditTextPreference) findPreference(KEY_RENAME_DEVICE); mDeviceNamePref.setSummary(mCachedDevice.getName()); @@ -105,6 +118,15 @@ public class DeviceProfilesSettings extends SettingsPreferenceFragment addPreferencesForProfiles(); } + private boolean isObjectPushSupported(BluetoothDevice device) { + ParcelUuid[] uuids = device.getUuids(); + BluetoothClass bluetoothClass = device.getBluetoothClass(); + return (uuids != null && BluetoothUuid.containsAnyUuid(uuids, + LocalBluetoothProfileManager.OPP_PROFILE_UUIDS)) || + (bluetoothClass != null && bluetoothClass.doesClassMatch( + BluetoothClass.PROFILE_OPP)); + } + @Override public void onSaveInstanceState(Bundle outState) { super.onSaveInstanceState(outState);