Blacklisted items are removed when calling getServices/Characteristics/Descriptors.

This commit is contained in:
fokinv 2016-10-10 09:35:59 +02:00 committed by zakorgyula
parent dd733f6994
commit d30bcbd339
14 changed files with 20 additions and 15 deletions

View file

@ -19,6 +19,7 @@ use bluetooth_traits::{BluetoothCharacteristicMsg, BluetoothCharacteristicsMsg};
use bluetooth_traits::{BluetoothDescriptorMsg, BluetoothDescriptorsMsg};
use bluetooth_traits::{BluetoothDeviceMsg, BluetoothError, BluetoothMethodMsg};
use bluetooth_traits::{BluetoothResult, BluetoothServiceMsg, BluetoothServicesMsg};
use bluetooth_traits::blacklist::{uuid_is_blacklisted, Blacklist};
use bluetooth_traits::scanfilter::{BluetoothScanfilter, BluetoothScanfilterSequence, RequestDeviceoptions};
use device::bluetooth::{BluetoothAdapter, BluetoothDevice, BluetoothGATTCharacteristic};
use device::bluetooth::{BluetoothGATTDescriptor, BluetoothGATTService};
@ -681,7 +682,8 @@ impl BluetoothManager {
}
}
}
services_vec.retain(|s| self.allowed_services
services_vec.retain(|s| !uuid_is_blacklisted(&s.uuid, Blacklist::All) &&
self.allowed_services
.get(&device_id)
.map_or(false, |uuids| uuids.contains(&s.uuid)));
if services_vec.is_empty() {
@ -758,6 +760,7 @@ impl BluetoothManager {
if let Some(uuid) = uuid {
services_vec.retain(|ref s| s.uuid == uuid);
}
services_vec.retain(|s| !uuid_is_blacklisted(&s.uuid, Blacklist::All));
if services_vec.is_empty() {
return drop(sender.send(Err(BluetoothError::NotFound)));
}
@ -834,6 +837,7 @@ impl BluetoothManager {
});
}
}
characteristics_vec.retain(|c| !uuid_is_blacklisted(&c.uuid, Blacklist::All));
if characteristics_vec.is_empty() {
return drop(sender.send(Err(BluetoothError::NotFound)));
}
@ -888,6 +892,7 @@ impl BluetoothManager {
});
}
}
descriptors_vec.retain(|d| !uuid_is_blacklisted(&d.uuid, Blacklist::All));
if descriptors_vec.is_empty() {
return drop(sender.send(Err(BluetoothError::NotFound)));
}

View file

@ -11,5 +11,7 @@ path = "lib.rs"
[dependencies]
ipc-channel = "0.5"
regex = "0.1.43"
serde = "0.8"
serde_derive = "0.8"
util = {path = "../util"}

View file

@ -5,9 +5,12 @@
#![feature(proc_macro)]
extern crate ipc_channel;
extern crate regex;
#[macro_use]
extern crate serde_derive;
extern crate util;
pub mod blacklist;
pub mod scanfilter;
use ipc_channel::ipc::IpcSender;

View file

@ -2,8 +2,8 @@
* License, v. 2.0. If a copy of the MPL was not distributed with this
* file, You can obtain one at http://mozilla.org/MPL/2.0/. */
use bluetooth_blacklist::{Blacklist, uuid_is_blacklisted};
use bluetooth_traits::{BluetoothError, BluetoothMethodMsg};
use bluetooth_traits::blacklist::{Blacklist, uuid_is_blacklisted};
use bluetooth_traits::scanfilter::{BluetoothScanfilter, BluetoothScanfilterSequence};
use bluetooth_traits::scanfilter::{RequestDeviceoptions, ServiceUUIDSequence};
use core::clone::Clone;

View file

@ -2,8 +2,8 @@
* License, v. 2.0. If a copy of the MPL was not distributed with this
* file, You can obtain one at http://mozilla.org/MPL/2.0/. */
use bluetooth_blacklist::{Blacklist, uuid_is_blacklisted};
use bluetooth_traits::BluetoothMethodMsg;
use bluetooth_traits::blacklist::{Blacklist, uuid_is_blacklisted};
use dom::bindings::cell::DOMRefCell;
use dom::bindings::codegen::Bindings::BluetoothCharacteristicPropertiesBinding::
BluetoothCharacteristicPropertiesMethods;

View file

@ -2,8 +2,8 @@
* License, v. 2.0. If a copy of the MPL was not distributed with this
* file, You can obtain one at http://mozilla.org/MPL/2.0/. */
use bluetooth_blacklist::{Blacklist, uuid_is_blacklisted};
use bluetooth_traits::BluetoothMethodMsg;
use bluetooth_traits::blacklist::{Blacklist, uuid_is_blacklisted};
use dom::bindings::cell::DOMRefCell;
use dom::bindings::codegen::Bindings::BluetoothDeviceBinding::BluetoothDeviceMethods;
use dom::bindings::codegen::Bindings::BluetoothRemoteGATTCharacteristicBinding::

View file

@ -2,8 +2,8 @@
* License, v. 2.0. If a copy of the MPL was not distributed with this
* file, You can obtain one at http://mozilla.org/MPL/2.0/. */
use bluetooth_blacklist::{Blacklist, uuid_is_blacklisted};
use bluetooth_traits::BluetoothMethodMsg;
use bluetooth_traits::blacklist::{Blacklist, uuid_is_blacklisted};
use dom::bindings::codegen::Bindings::BluetoothDeviceBinding::BluetoothDeviceMethods;
use dom::bindings::codegen::Bindings::BluetoothRemoteGATTServerBinding;
use dom::bindings::codegen::Bindings::BluetoothRemoteGATTServerBinding::BluetoothRemoteGATTServerMethods;

View file

@ -2,8 +2,8 @@
* License, v. 2.0. If a copy of the MPL was not distributed with this
* file, You can obtain one at http://mozilla.org/MPL/2.0/. */
use bluetooth_blacklist::{Blacklist, uuid_is_blacklisted};
use bluetooth_traits::BluetoothMethodMsg;
use bluetooth_traits::blacklist::{Blacklist, uuid_is_blacklisted};
use dom::bindings::codegen::Bindings::BluetoothDeviceBinding::BluetoothDeviceMethods;
use dom::bindings::codegen::Bindings::BluetoothRemoteGATTServerBinding::BluetoothRemoteGATTServerMethods;
use dom::bindings::codegen::Bindings::BluetoothRemoteGATTServiceBinding;

View file

@ -96,7 +96,6 @@ extern crate webrender_traits;
extern crate websocket;
extern crate xml5ever;
pub mod bluetooth_blacklist;
mod body;
pub mod clipboard_provider;
mod devtools;

View file

@ -207,8 +207,10 @@ name = "bluetooth_traits"
version = "0.0.1"
dependencies = [
"ipc-channel 0.5.1 (registry+https://github.com/rust-lang/crates.io-index)",
"regex 0.1.76 (registry+https://github.com/rust-lang/crates.io-index)",
"serde 0.8.17 (registry+https://github.com/rust-lang/crates.io-index)",
"serde_derive 0.8.17 (registry+https://github.com/rust-lang/crates.io-index)",
"util 0.0.1",
]
[[package]]

2
ports/cef/Cargo.lock generated
View file

@ -178,8 +178,10 @@ name = "bluetooth_traits"
version = "0.0.1"
dependencies = [
"ipc-channel 0.5.1 (registry+https://github.com/rust-lang/crates.io-index)",
"regex 0.1.76 (registry+https://github.com/rust-lang/crates.io-index)",
"serde 0.8.17 (registry+https://github.com/rust-lang/crates.io-index)",
"serde_derive 0.8.17 (registry+https://github.com/rust-lang/crates.io-index)",
"util 0.0.1",
]
[[package]]

View file

@ -1,4 +0,0 @@
[blacklisted-characteristics.html]
type: testharness
[The Device Information service is composed of blacklisted characteristics so we shouldn't find any.]
expected: FAIL

View file

@ -1,4 +0,0 @@
[blacklisted-descriptors.html]
type: testharness
[The descriptors are blacklisted.]
expected: FAIL