Filter devices by UUID and then class.
The settings app has been updated to use UUIDs. When there is a filter type set for device picket UI, use the UUIDs first and then the class bits. Change-Id: Ifde5dbc3a1cf25babce4c686002315aa3933de59
This commit is contained in:
@@ -16,16 +16,12 @@
|
|||||||
|
|
||||||
package com.android.settings.bluetooth;
|
package com.android.settings.bluetooth;
|
||||||
|
|
||||||
import com.android.settings.ProgressCategory;
|
|
||||||
import com.android.settings.R;
|
|
||||||
import com.android.settings.bluetooth.LocalBluetoothProfileManager.Profile;
|
|
||||||
|
|
||||||
import java.util.List;
|
|
||||||
import java.util.WeakHashMap;
|
|
||||||
|
|
||||||
import android.bluetooth.BluetoothAdapter;
|
import android.bluetooth.BluetoothAdapter;
|
||||||
|
import android.bluetooth.BluetoothClass;
|
||||||
import android.bluetooth.BluetoothDevice;
|
import android.bluetooth.BluetoothDevice;
|
||||||
import android.bluetooth.BluetoothDevicePicker;
|
import android.bluetooth.BluetoothDevicePicker;
|
||||||
|
import android.bluetooth.BluetoothUuid;
|
||||||
|
import android.bluetooth.ParcelUuid;
|
||||||
import android.content.BroadcastReceiver;
|
import android.content.BroadcastReceiver;
|
||||||
import android.content.Context;
|
import android.content.Context;
|
||||||
import android.content.Intent;
|
import android.content.Intent;
|
||||||
@@ -41,7 +37,13 @@ import android.view.MenuItem;
|
|||||||
import android.view.View;
|
import android.view.View;
|
||||||
import android.view.ContextMenu.ContextMenuInfo;
|
import android.view.ContextMenu.ContextMenuInfo;
|
||||||
import android.widget.AdapterView.AdapterContextMenuInfo;
|
import android.widget.AdapterView.AdapterContextMenuInfo;
|
||||||
import android.util.Log;
|
|
||||||
|
import com.android.settings.ProgressCategory;
|
||||||
|
import com.android.settings.R;
|
||||||
|
import com.android.settings.bluetooth.LocalBluetoothProfileManager.Profile;
|
||||||
|
|
||||||
|
import java.util.List;
|
||||||
|
import java.util.WeakHashMap;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* BluetoothSettings is the Settings screen for Bluetooth configuration and
|
* BluetoothSettings is the Settings screen for Bluetooth configuration and
|
||||||
@@ -304,20 +306,43 @@ public class BluetoothSettings extends PreferenceActivity
|
|||||||
throw new IllegalStateException("Got onDeviceAdded, but cachedDevice already exists");
|
throw new IllegalStateException("Got onDeviceAdded, but cachedDevice already exists");
|
||||||
}
|
}
|
||||||
|
|
||||||
List<Profile> profiles = cachedDevice.getProfiles();
|
if (addDevicePreference(cachedDevice)) {
|
||||||
if (mFilterType == BluetoothDevicePicker.FILTER_TYPE_TRANSFER){
|
|
||||||
if(profiles.contains(Profile.OPP)){
|
|
||||||
createDevicePreference(cachedDevice);
|
|
||||||
}
|
|
||||||
} else if (mFilterType == BluetoothDevicePicker.FILTER_TYPE_AUDIO) {
|
|
||||||
if((profiles.contains(Profile.A2DP)) || (profiles.contains(Profile.HEADSET))){
|
|
||||||
createDevicePreference(cachedDevice);
|
|
||||||
}
|
|
||||||
} else {
|
|
||||||
createDevicePreference(cachedDevice);
|
createDevicePreference(cachedDevice);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private boolean addDevicePreference(CachedBluetoothDevice cachedDevice) {
|
||||||
|
ParcelUuid[] uuids = cachedDevice.getDevice().getUuids();
|
||||||
|
BluetoothClass bluetoothClass = cachedDevice.getDevice().getBluetoothClass();
|
||||||
|
|
||||||
|
switch(mFilterType) {
|
||||||
|
case BluetoothDevicePicker.FILTER_TYPE_TRANSFER:
|
||||||
|
if (uuids != null) {
|
||||||
|
if (BluetoothUuid.containsAnyUuid(uuids,
|
||||||
|
LocalBluetoothProfileManager.OPP_PROFILE_UUIDS)) return true;
|
||||||
|
} else {
|
||||||
|
if (bluetoothClass.doesClassMatch(BluetoothClass.PROFILE_OPP)) return true;
|
||||||
|
}
|
||||||
|
break;
|
||||||
|
case BluetoothDevicePicker.FILTER_TYPE_AUDIO:
|
||||||
|
if (uuids != null) {
|
||||||
|
if (BluetoothUuid.containsAnyUuid(uuids,
|
||||||
|
LocalBluetoothProfileManager.A2DP_PROFILE_UUIDS)) return true;
|
||||||
|
|
||||||
|
if (BluetoothUuid.containsAnyUuid(uuids,
|
||||||
|
LocalBluetoothProfileManager.HEADSET_PROFILE_UUIDS)) return true;
|
||||||
|
} else {
|
||||||
|
if (bluetoothClass.doesClassMatch(BluetoothClass.PROFILE_A2DP)) return true;
|
||||||
|
|
||||||
|
if (bluetoothClass.doesClassMatch(BluetoothClass.PROFILE_HEADSET)) return true;
|
||||||
|
}
|
||||||
|
break;
|
||||||
|
default:
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
private void createDevicePreference(CachedBluetoothDevice cachedDevice) {
|
private void createDevicePreference(CachedBluetoothDevice cachedDevice) {
|
||||||
BluetoothDevicePreference preference = new BluetoothDevicePreference(this, cachedDevice);
|
BluetoothDevicePreference preference = new BluetoothDevicePreference(this, cachedDevice);
|
||||||
mDeviceList.addPreference(preference);
|
mDeviceList.addPreference(preference);
|
||||||
|
@@ -37,17 +37,17 @@ import java.util.Set;
|
|||||||
public abstract class LocalBluetoothProfileManager {
|
public abstract class LocalBluetoothProfileManager {
|
||||||
private static final String TAG = "LocalBluetoothProfileManager";
|
private static final String TAG = "LocalBluetoothProfileManager";
|
||||||
|
|
||||||
private static final ParcelUuid[] HEADSET_PROFILE_UUIDS = new ParcelUuid[] {
|
/* package */ static final ParcelUuid[] HEADSET_PROFILE_UUIDS = new ParcelUuid[] {
|
||||||
BluetoothUuid.HSP,
|
BluetoothUuid.HSP,
|
||||||
BluetoothUuid.Handsfree,
|
BluetoothUuid.Handsfree,
|
||||||
};
|
};
|
||||||
|
|
||||||
private static final ParcelUuid[] A2DP_PROFILE_UUIDS = new ParcelUuid[] {
|
/* package */ static final ParcelUuid[] A2DP_PROFILE_UUIDS = new ParcelUuid[] {
|
||||||
BluetoothUuid.AudioSink,
|
BluetoothUuid.AudioSink,
|
||||||
BluetoothUuid.AdvAudioDist,
|
BluetoothUuid.AdvAudioDist,
|
||||||
};
|
};
|
||||||
|
|
||||||
private static final ParcelUuid[] OPP_PROFILE_UUIDS = new ParcelUuid[] {
|
/* package */ static final ParcelUuid[] OPP_PROFILE_UUIDS = new ParcelUuid[] {
|
||||||
BluetoothUuid.ObexObjectPush
|
BluetoothUuid.ObexObjectPush
|
||||||
};
|
};
|
||||||
|
|
||||||
|
Reference in New Issue
Block a user