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
This commit is contained in:
Jake Hamby
2011-01-11 19:27:17 -08:00
parent 055c20e576
commit 55b7d27936

View File

@@ -20,8 +20,11 @@ import com.android.settings.R;
import com.android.settings.SettingsPreferenceFragment; import com.android.settings.SettingsPreferenceFragment;
import com.android.settings.bluetooth.LocalBluetoothProfileManager.Profile; import com.android.settings.bluetooth.LocalBluetoothProfileManager.Profile;
import android.bluetooth.BluetoothClass;
import android.bluetooth.BluetoothDevice; import android.bluetooth.BluetoothDevice;
import android.bluetooth.BluetoothUuid;
import android.os.Bundle; import android.os.Bundle;
import android.os.ParcelUuid;
import android.preference.CheckBoxPreference; import android.preference.CheckBoxPreference;
import android.preference.EditTextPreference; import android.preference.EditTextPreference;
import android.preference.Preference; import android.preference.Preference;
@@ -75,6 +78,7 @@ public class DeviceProfilesSettings extends SettingsPreferenceFragment
if (device == null) { if (device == null) {
Log.w(TAG, "Activity started without a remote Bluetooth device"); Log.w(TAG, "Activity started without a remote Bluetooth device");
finish(); finish();
return;
} }
mManager = LocalBluetoothManager.getInstance(getActivity()); mManager = LocalBluetoothManager.getInstance(getActivity());
@@ -82,6 +86,7 @@ public class DeviceProfilesSettings extends SettingsPreferenceFragment
if (mCachedDevice == null) { if (mCachedDevice == null) {
Log.w(TAG, "Device not found, cannot connect to it"); Log.w(TAG, "Device not found, cannot connect to it");
finish(); finish();
return;
} }
addPreferencesFromResource(R.xml.bluetooth_device_advanced); addPreferencesFromResource(R.xml.bluetooth_device_advanced);
@@ -89,8 +94,16 @@ public class DeviceProfilesSettings extends SettingsPreferenceFragment
mProfileContainer = (PreferenceGroup) findPreference(KEY_PROFILE_CONTAINER); mProfileContainer = (PreferenceGroup) findPreference(KEY_PROFILE_CONTAINER);
mAllowIncomingPref = (CheckBoxPreference) findPreference(KEY_ALLOW_INCOMING); 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 = (EditTextPreference) findPreference(KEY_RENAME_DEVICE);
mDeviceNamePref.setSummary(mCachedDevice.getName()); mDeviceNamePref.setSummary(mCachedDevice.getName());
@@ -105,6 +118,15 @@ public class DeviceProfilesSettings extends SettingsPreferenceFragment
addPreferencesForProfiles(); 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 @Override
public void onSaveInstanceState(Bundle outState) { public void onSaveInstanceState(Bundle outState) {
super.onSaveInstanceState(outState); super.onSaveInstanceState(outState);