mirror of
https://github.com/servo/servo.git
synced 2025-06-21 07:38:59 +01:00
Accepting empty deviceName, when requesting a BluetoothDevice.
This commit is contained in:
parent
2b4829b89a
commit
4ed461c6e5
6 changed files with 10 additions and 22 deletions
|
@ -106,8 +106,8 @@ fn matches_filter(device: &BluetoothDevice, filter: &BluetoothScanfilter) -> boo
|
||||||
}
|
}
|
||||||
|
|
||||||
// Step 1.
|
// Step 1.
|
||||||
if !filter.get_name().is_empty() {
|
if let Some(name) = filter.get_name() {
|
||||||
if device.get_name().ok() != Some(filter.get_name().to_string()) {
|
if device.get_name().ok() != Some(name.to_string()) {
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -25,7 +25,7 @@ impl ServiceUUIDSequence {
|
||||||
|
|
||||||
#[derive(Deserialize, Serialize)]
|
#[derive(Deserialize, Serialize)]
|
||||||
pub struct BluetoothScanfilter {
|
pub struct BluetoothScanfilter {
|
||||||
name: String,
|
name: Option<String>,
|
||||||
name_prefix: String,
|
name_prefix: String,
|
||||||
services: ServiceUUIDSequence,
|
services: ServiceUUIDSequence,
|
||||||
manufacturer_id: Option<u16>,
|
manufacturer_id: Option<u16>,
|
||||||
|
@ -33,7 +33,7 @@ pub struct BluetoothScanfilter {
|
||||||
}
|
}
|
||||||
|
|
||||||
impl BluetoothScanfilter {
|
impl BluetoothScanfilter {
|
||||||
pub fn new(name: String,
|
pub fn new(name: Option<String>,
|
||||||
name_prefix: String,
|
name_prefix: String,
|
||||||
services: Vec<String>,
|
services: Vec<String>,
|
||||||
manufacturer_id: Option<u16>,
|
manufacturer_id: Option<u16>,
|
||||||
|
@ -48,8 +48,8 @@ impl BluetoothScanfilter {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
pub fn get_name(&self) -> &str {
|
pub fn get_name(&self) -> Option<&str> {
|
||||||
&self.name
|
self.name.as_ref().map(|s| s.as_str())
|
||||||
}
|
}
|
||||||
|
|
||||||
pub fn get_name_prefix(&self) -> &str {
|
pub fn get_name_prefix(&self) -> &str {
|
||||||
|
@ -69,12 +69,12 @@ impl BluetoothScanfilter {
|
||||||
}
|
}
|
||||||
|
|
||||||
pub fn is_empty_or_invalid(&self) -> bool {
|
pub fn is_empty_or_invalid(&self) -> bool {
|
||||||
(self.name.is_empty() &&
|
(self.name.is_none() &&
|
||||||
self.name_prefix.is_empty() &&
|
self.name_prefix.is_empty() &&
|
||||||
self.get_services().is_empty() &&
|
self.get_services().is_empty() &&
|
||||||
self.manufacturer_id.is_none() &&
|
self.manufacturer_id.is_none() &&
|
||||||
self.service_data_uuid.is_empty()) ||
|
self.service_data_uuid.is_empty()) ||
|
||||||
self.name.len() > MAX_NAME_LENGTH ||
|
self.get_name().unwrap_or("").len() > MAX_NAME_LENGTH ||
|
||||||
self.name_prefix.len() > MAX_NAME_LENGTH
|
self.name_prefix.len() > MAX_NAME_LENGTH
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -217,9 +217,9 @@ fn canonicalize_filter(filter: &BluetoothRequestDeviceFilter) -> Fallible<Blueto
|
||||||
}
|
}
|
||||||
|
|
||||||
// Step 2.4.4.2.
|
// Step 2.4.4.2.
|
||||||
name.to_string()
|
Some(name.to_string())
|
||||||
},
|
},
|
||||||
None => String::new(),
|
None => None,
|
||||||
};
|
};
|
||||||
|
|
||||||
// Step 2.4.5.
|
// Step 2.4.5.
|
||||||
|
|
|
@ -1,4 +0,0 @@
|
||||||
[name-empty-device-from-name-empty-filter.html]
|
|
||||||
type: testharness
|
|
||||||
[An empty name device can be obtained by empty name filter.]
|
|
||||||
expected: FAIL
|
|
|
@ -1,4 +0,0 @@
|
||||||
[name-empty-filter.html]
|
|
||||||
type: testharness
|
|
||||||
[A named device is not matched by a filter with an empty name.]
|
|
||||||
expected: FAIL
|
|
|
@ -1,4 +0,0 @@
|
||||||
[name-missing-device-from-name-empty-filter.html]
|
|
||||||
type: testharness
|
|
||||||
[An unnamed device can not be obtained by empty name filter.]
|
|
||||||
expected: FAIL
|
|
Loading…
Add table
Add a link
Reference in a new issue