am 55b7d279: Only show "Allow incoming file transfer" option if device supports OPP

* commit '55b7d27936f39c2d6e609c15b1086e9698dbbcfd':
  Only show "Allow incoming file transfer" option if device supports OPP
This commit is contained in:
Jake Hamby
2011-01-11 20:06:07 -08:00
committed by Android Git Automerger

View File

@@ -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);