mirror of
https://github.com/mozilla/gecko-dev.git
synced 2025-02-04 13:07:52 +00:00
Merge b2g-inbound to m-c. a=merge
This commit is contained in:
commit
67ce0a43c0
@ -360,10 +360,10 @@ pref("layout.css.touch_action.enabled", false);
|
||||
|
||||
#ifdef MOZ_SAFE_BROWSING
|
||||
// Safe browsing does nothing unless this pref is set
|
||||
pref("browser.safebrowsing.enabled", true);
|
||||
pref("browser.safebrowsing.enabled", false);
|
||||
|
||||
// Prevent loading of pages identified as malware
|
||||
pref("browser.safebrowsing.malware.enabled", true);
|
||||
pref("browser.safebrowsing.malware.enabled", false);
|
||||
|
||||
pref("browser.safebrowsing.debug", false);
|
||||
pref("browser.safebrowsing.updateURL", "https://safebrowsing.google.com/safebrowsing/downloads?client=SAFEBROWSING_ID&appver=%VERSION%&pver=2.2&key=%GOOGLE_API_KEY%");
|
||||
|
@ -61,11 +61,11 @@ let developerHUD = {
|
||||
* observed metrics with `target.register(metric)`, and keep them up-to-date
|
||||
* with `target.update(metric, message)` when necessary.
|
||||
*/
|
||||
registerWatcher: function dwp_registerWatcher(watcher) {
|
||||
registerWatcher(watcher) {
|
||||
this._watchers.unshift(watcher);
|
||||
},
|
||||
|
||||
init: function dwp_init() {
|
||||
init() {
|
||||
if (this._client) {
|
||||
return;
|
||||
}
|
||||
@ -106,7 +106,7 @@ let developerHUD = {
|
||||
});
|
||||
},
|
||||
|
||||
uninit: function dwp_uninit() {
|
||||
uninit() {
|
||||
if (!this._client) {
|
||||
return;
|
||||
}
|
||||
@ -125,7 +125,7 @@ let developerHUD = {
|
||||
* This method will ask all registered watchers to track and update metrics
|
||||
* on an app frame.
|
||||
*/
|
||||
trackFrame: function dwp_trackFrame(frame) {
|
||||
trackFrame(frame) {
|
||||
if (this._targets.has(frame)) {
|
||||
return;
|
||||
}
|
||||
@ -140,7 +140,7 @@ let developerHUD = {
|
||||
});
|
||||
},
|
||||
|
||||
untrackFrame: function dwp_untrackFrame(frame) {
|
||||
untrackFrame(frame) {
|
||||
let target = this._targets.get(frame);
|
||||
if (target) {
|
||||
for (let w of this._watchers) {
|
||||
@ -152,7 +152,7 @@ let developerHUD = {
|
||||
}
|
||||
},
|
||||
|
||||
onFrameCreated: function (frame, isFirstAppFrame) {
|
||||
onFrameCreated(frame, isFirstAppFrame) {
|
||||
let mozapp = frame.getAttribute('mozapp');
|
||||
if (!mozapp) {
|
||||
return;
|
||||
@ -160,7 +160,7 @@ let developerHUD = {
|
||||
this.trackFrame(frame);
|
||||
},
|
||||
|
||||
onFrameDestroyed: function (frame, isLastAppFrame) {
|
||||
onFrameDestroyed(frame, isLastAppFrame) {
|
||||
let mozapp = frame.getAttribute('mozapp');
|
||||
if (!mozapp) {
|
||||
return;
|
||||
@ -168,7 +168,7 @@ let developerHUD = {
|
||||
this.untrackFrame(frame);
|
||||
},
|
||||
|
||||
log: function dwp_log(message) {
|
||||
log(message) {
|
||||
if (this._logging) {
|
||||
dump(DEVELOPER_HUD_LOG_PREFIX + ': ' + message + '\n');
|
||||
}
|
||||
@ -204,7 +204,7 @@ Target.prototype = {
|
||||
/**
|
||||
* Register a metric that can later be updated. Does not update the front-end.
|
||||
*/
|
||||
register: function target_register(metric) {
|
||||
register(metric) {
|
||||
this.metrics.set(metric, 0);
|
||||
},
|
||||
|
||||
@ -212,7 +212,7 @@ Target.prototype = {
|
||||
* Modify one of a target's metrics, and send out an event to notify relevant
|
||||
* parties (e.g. the developer HUD, automated tests, etc).
|
||||
*/
|
||||
update: function target_update(metric, message) {
|
||||
update(metric, message) {
|
||||
if (!metric.name) {
|
||||
throw new Error('Missing metric.name');
|
||||
}
|
||||
@ -251,7 +251,7 @@ Target.prototype = {
|
||||
* Nicer way to call update() when the metric value is a number that needs
|
||||
* to be incremented.
|
||||
*/
|
||||
bump: function target_bump(metric, message) {
|
||||
bump(metric, message) {
|
||||
metric.value = (this.metrics.get(metric.name) || 0) + 1;
|
||||
this.update(metric, message);
|
||||
},
|
||||
@ -260,7 +260,7 @@ Target.prototype = {
|
||||
* Void a metric value and make sure it isn't displayed on the front-end
|
||||
* anymore.
|
||||
*/
|
||||
clear: function target_clear(metric) {
|
||||
clear(metric) {
|
||||
metric.value = 0;
|
||||
this.update(metric);
|
||||
},
|
||||
@ -269,19 +269,19 @@ Target.prototype = {
|
||||
* Tear everything down, including the front-end by sending a message without
|
||||
* widgets.
|
||||
*/
|
||||
destroy: function target_destroy() {
|
||||
destroy() {
|
||||
delete this.metrics;
|
||||
this._send({});
|
||||
},
|
||||
|
||||
_send: function target_send(data) {
|
||||
_send(data) {
|
||||
let frame = this.frame;
|
||||
|
||||
shell.sendEvent(frame, 'developer-hud-update', Cu.cloneInto(data, frame));
|
||||
this._sendTelemetryEvent(data.metric);
|
||||
},
|
||||
|
||||
_sendTelemetryEvent: function target_sendTelemetryEvent(metric) {
|
||||
_sendTelemetryEvent(metric) {
|
||||
if (!developerHUD._telemetry || !metric || metric.skipTelemetry) {
|
||||
return;
|
||||
}
|
||||
@ -332,7 +332,7 @@ let consoleWatcher = {
|
||||
'CORS'
|
||||
],
|
||||
|
||||
init: function cw_init(client) {
|
||||
init(client) {
|
||||
this._client = client;
|
||||
this.consoleListener = this.consoleListener.bind(this);
|
||||
|
||||
@ -359,7 +359,7 @@ let consoleWatcher = {
|
||||
client.addListener('reflowActivity', this.consoleListener);
|
||||
},
|
||||
|
||||
trackTarget: function cw_trackTarget(target) {
|
||||
trackTarget(target) {
|
||||
target.register('reflows');
|
||||
target.register('warnings');
|
||||
target.register('errors');
|
||||
@ -374,7 +374,7 @@ let consoleWatcher = {
|
||||
});
|
||||
},
|
||||
|
||||
untrackTarget: function cw_untrackTarget(target) {
|
||||
untrackTarget(target) {
|
||||
this._client.request({
|
||||
to: target.actor.consoleActor,
|
||||
type: 'stopListeners',
|
||||
@ -384,7 +384,7 @@ let consoleWatcher = {
|
||||
this._targets.delete(target.actor.consoleActor);
|
||||
},
|
||||
|
||||
consoleListener: function cw_consoleListener(type, packet) {
|
||||
consoleListener(type, packet) {
|
||||
let target = this._targets.get(packet.from);
|
||||
let metric = {};
|
||||
let output = '';
|
||||
@ -477,7 +477,7 @@ let consoleWatcher = {
|
||||
target.bump(metric, output);
|
||||
},
|
||||
|
||||
formatSourceURL: function cw_formatSourceURL(packet) {
|
||||
formatSourceURL(packet) {
|
||||
// Abbreviate source URL
|
||||
let source = WebConsoleUtils.abbreviateSourceURL(packet.sourceURL);
|
||||
|
||||
@ -489,9 +489,7 @@ let consoleWatcher = {
|
||||
return source;
|
||||
},
|
||||
|
||||
handleTelemetryMessage:
|
||||
function cw_handleTelemetryMessage(target, packet) {
|
||||
|
||||
handleTelemetryMessage(target, packet) {
|
||||
if (!developerHUD._telemetry) {
|
||||
return;
|
||||
}
|
||||
@ -540,13 +538,13 @@ let eventLoopLagWatcher = {
|
||||
_fronts: new Map(),
|
||||
_active: false,
|
||||
|
||||
init: function(client) {
|
||||
init(client) {
|
||||
this._client = client;
|
||||
|
||||
SettingsListener.observe('hud.jank', false, this.settingsListener.bind(this));
|
||||
},
|
||||
|
||||
settingsListener: function(value) {
|
||||
settingsListener(value) {
|
||||
if (this._active == value) {
|
||||
return;
|
||||
}
|
||||
@ -565,7 +563,7 @@ let eventLoopLagWatcher = {
|
||||
}
|
||||
},
|
||||
|
||||
trackTarget: function(target) {
|
||||
trackTarget(target) {
|
||||
target.register('jank');
|
||||
|
||||
let front = new EventLoopLagFront(this._client, target.actor);
|
||||
@ -580,7 +578,7 @@ let eventLoopLagWatcher = {
|
||||
}
|
||||
},
|
||||
|
||||
untrackTarget: function(target) {
|
||||
untrackTarget(target) {
|
||||
let fronts = this._fronts;
|
||||
if (fronts.has(target)) {
|
||||
fronts.get(target).destroy();
|
||||
@ -611,7 +609,7 @@ let memoryWatcher = {
|
||||
},
|
||||
_active: false,
|
||||
|
||||
init: function mw_init(client) {
|
||||
init(client) {
|
||||
this._client = client;
|
||||
let watching = this._watching;
|
||||
|
||||
@ -624,7 +622,7 @@ let memoryWatcher = {
|
||||
}
|
||||
},
|
||||
|
||||
update: function mw_update() {
|
||||
update() {
|
||||
let watching = this._watching;
|
||||
let active = watching.appmemory || watching.uss;
|
||||
|
||||
@ -642,7 +640,7 @@ let memoryWatcher = {
|
||||
this._active = active;
|
||||
},
|
||||
|
||||
measure: function mw_measure(target) {
|
||||
measure(target) {
|
||||
let watch = this._watching;
|
||||
let front = this._fronts.get(target);
|
||||
let format = this.formatMemory;
|
||||
@ -685,11 +683,11 @@ let memoryWatcher = {
|
||||
});
|
||||
}
|
||||
|
||||
let timer = setTimeout(() => this.measure(target), 800);
|
||||
let timer = setTimeout(() => this.measure(target), 2000);
|
||||
this._timers.set(target, timer);
|
||||
},
|
||||
|
||||
formatMemory: function mw_formatMemory(bytes) {
|
||||
formatMemory(bytes) {
|
||||
var prefix = ['','K','M','G','T','P','E','Z','Y'];
|
||||
var i = 0;
|
||||
for (; bytes > 1024 && i < prefix.length; ++i) {
|
||||
@ -698,7 +696,7 @@ let memoryWatcher = {
|
||||
return (Math.round(bytes * 100) / 100) + ' ' + prefix[i] + 'B';
|
||||
},
|
||||
|
||||
trackTarget: function mw_trackTarget(target) {
|
||||
trackTarget(target) {
|
||||
target.register('uss');
|
||||
target.register('memory');
|
||||
this._fronts.set(target, MemoryFront(this._client, target.actor));
|
||||
@ -707,7 +705,7 @@ let memoryWatcher = {
|
||||
}
|
||||
},
|
||||
|
||||
untrackTarget: function mw_untrackTarget(target) {
|
||||
untrackTarget(target) {
|
||||
let front = this._fronts.get(target);
|
||||
if (front) {
|
||||
front.destroy();
|
||||
|
@ -148,12 +148,16 @@ Components.utils.import('resource://gre/modules/ctypes.jsm');
|
||||
// Get the hardware info and firmware revision from device properties.
|
||||
let hardware_info = null;
|
||||
let firmware_revision = null;
|
||||
let product_manufacturer = null;
|
||||
let product_model = null;
|
||||
let product_device = null;
|
||||
let build_number = null;
|
||||
#ifdef MOZ_WIDGET_GONK
|
||||
hardware_info = libcutils.property_get('ro.hardware');
|
||||
firmware_revision = libcutils.property_get('ro.firmware_revision');
|
||||
product_manufacturer = libcutils.property_get('ro.product.manufacturer');
|
||||
product_model = libcutils.property_get('ro.product.model');
|
||||
product_device = libcutils.property_get('ro.product.device');
|
||||
build_number = libcutils.property_get('ro.build.version.incremental');
|
||||
#endif
|
||||
|
||||
@ -173,7 +177,9 @@ Components.utils.import('resource://gre/modules/ctypes.jsm');
|
||||
'deviceinfo.platform_build_id': appInfo.platformBuildID,
|
||||
'deviceinfo.hardware': hardware_info,
|
||||
'deviceinfo.firmware_revision': firmware_revision,
|
||||
'deviceinfo.product_model': product_model
|
||||
'deviceinfo.product_manufacturer': product_manufacturer,
|
||||
'deviceinfo.product_model': product_model,
|
||||
'deviceinfo.product_device': product_device
|
||||
}
|
||||
lock.set(setting);
|
||||
}
|
||||
|
@ -15,7 +15,7 @@
|
||||
<project name="platform_build" path="build" remote="b2g" revision="e862ab9177af664f00b4522e2350f4cb13866d73">
|
||||
<copyfile dest="Makefile" src="core/root.mk"/>
|
||||
</project>
|
||||
<project name="gaia" path="gaia" remote="mozillaorg" revision="e6506d68e01489b57616f8b74e8773f938ce62b3"/>
|
||||
<project name="gaia" path="gaia" remote="mozillaorg" revision="86af137c7f4c41c1185e609339002ab47fd6c640"/>
|
||||
<project name="fake-libdvm" path="dalvik" remote="b2g" revision="d50ae982b19f42f0b66d08b9eb306be81687869f"/>
|
||||
<project name="gonk-misc" path="gonk-misc" remote="b2g" revision="3477513bcd385571aa01c0d074849e35bd5e2376"/>
|
||||
<project name="librecovery" path="librecovery" remote="b2g" revision="1b3591a50ed352fc6ddb77462b7b35d0bfa555a3"/>
|
||||
@ -23,7 +23,7 @@
|
||||
<project name="rilproxy" path="rilproxy" remote="b2g" revision="5ef30994f4778b4052e58a4383dbe7890048c87e"/>
|
||||
<project name="valgrind" path="external/valgrind" remote="b2g" revision="daa61633c32b9606f58799a3186395fd2bbb8d8c"/>
|
||||
<project name="vex" path="external/VEX" remote="b2g" revision="47f031c320888fe9f3e656602588565b52d43010"/>
|
||||
<project name="apitrace" path="external/apitrace" remote="apitrace" revision="49192a4e48d080e44a0d66f059e6897f07cf67f8"/>
|
||||
<project name="apitrace" path="external/apitrace" remote="apitrace" revision="47f48a42502b1c694db2b162011a67a2ff888c5d"/>
|
||||
<!-- Stock Android things -->
|
||||
<project groups="linux" name="platform/prebuilts/gcc/linux-x86/host/i686-linux-glibc2.7-4.6" path="prebuilts/gcc/linux-x86/host/i686-linux-glibc2.7-4.6" revision="95bb5b66b3ec5769c3de8d3f25d681787418e7d2"/>
|
||||
<project groups="linux" name="platform/prebuilts/gcc/linux-x86/host/x86_64-linux-glibc2.7-4.6" path="prebuilts/gcc/linux-x86/host/x86_64-linux-glibc2.7-4.6" revision="ebdad82e61c16772f6cd47e9f11936bf6ebe9aa0"/>
|
||||
|
@ -15,7 +15,7 @@
|
||||
<project name="platform_build" path="build" remote="b2g" revision="e862ab9177af664f00b4522e2350f4cb13866d73">
|
||||
<copyfile dest="Makefile" src="core/root.mk"/>
|
||||
</project>
|
||||
<project name="gaia" path="gaia" remote="mozillaorg" revision="e6506d68e01489b57616f8b74e8773f938ce62b3"/>
|
||||
<project name="gaia" path="gaia" remote="mozillaorg" revision="86af137c7f4c41c1185e609339002ab47fd6c640"/>
|
||||
<project name="fake-libdvm" path="dalvik" remote="b2g" revision="d50ae982b19f42f0b66d08b9eb306be81687869f"/>
|
||||
<project name="gonk-misc" path="gonk-misc" remote="b2g" revision="3477513bcd385571aa01c0d074849e35bd5e2376"/>
|
||||
<project name="librecovery" path="librecovery" remote="b2g" revision="1b3591a50ed352fc6ddb77462b7b35d0bfa555a3"/>
|
||||
@ -23,7 +23,7 @@
|
||||
<project name="rilproxy" path="rilproxy" remote="b2g" revision="5ef30994f4778b4052e58a4383dbe7890048c87e"/>
|
||||
<project name="valgrind" path="external/valgrind" remote="b2g" revision="daa61633c32b9606f58799a3186395fd2bbb8d8c"/>
|
||||
<project name="vex" path="external/VEX" remote="b2g" revision="47f031c320888fe9f3e656602588565b52d43010"/>
|
||||
<project name="apitrace" path="external/apitrace" remote="apitrace" revision="49192a4e48d080e44a0d66f059e6897f07cf67f8"/>
|
||||
<project name="apitrace" path="external/apitrace" remote="apitrace" revision="47f48a42502b1c694db2b162011a67a2ff888c5d"/>
|
||||
<!-- Stock Android things -->
|
||||
<project groups="linux" name="platform/prebuilts/gcc/linux-x86/host/i686-linux-glibc2.7-4.6" path="prebuilts/gcc/linux-x86/host/i686-linux-glibc2.7-4.6" revision="95bb5b66b3ec5769c3de8d3f25d681787418e7d2"/>
|
||||
<project groups="linux" name="platform/prebuilts/gcc/linux-x86/host/x86_64-linux-glibc2.7-4.6" path="prebuilts/gcc/linux-x86/host/x86_64-linux-glibc2.7-4.6" revision="ebdad82e61c16772f6cd47e9f11936bf6ebe9aa0"/>
|
||||
@ -101,7 +101,7 @@
|
||||
<project name="platform/external/webrtc" path="external/webrtc" revision="446452f84e9cc4c75d8e80f6f05e24793397a19d"/>
|
||||
<project name="platform/external/yaffs2" path="external/yaffs2" revision="a2cff2275e1b501ff478b03757d6e4f05fddc2db"/>
|
||||
<project name="platform/external/zlib" path="external/zlib" revision="a5c7131da47c991585a6c6ac0c063b6d7d56e3fc"/>
|
||||
<project name="platform/frameworks/base" path="frameworks/base" revision="2d12cb68a6c680e1ef50c6fbd19f782f67aec9de"/>
|
||||
<project name="platform/frameworks/base" path="frameworks/base" revision="d9d67d72dab332472d19aff19985d41d1c883763"/>
|
||||
<project name="platform/frameworks/native" path="frameworks/native" revision="8d54940d9bdad8fec3208ff58ddab590be9fe0d4"/>
|
||||
<project name="platform/frameworks/opt/emoji" path="frameworks/opt/emoji" revision="dbbe673145107e99883f62bafd70c5f43f11065c"/>
|
||||
<project name="platform/frameworks/wilhelm" path="frameworks/wilhelm" revision="aac6c4bb59a6577c97cbda68699829b507b7490d"/>
|
||||
|
@ -19,7 +19,7 @@
|
||||
<copyfile dest="Makefile" src="core/root.mk"/>
|
||||
</project>
|
||||
<project name="fake-dalvik" path="dalvik" remote="b2g" revision="ca1f327d5acc198bb4be62fa51db2c039032c9ce"/>
|
||||
<project name="gaia.git" path="gaia" remote="mozillaorg" revision="e6506d68e01489b57616f8b74e8773f938ce62b3"/>
|
||||
<project name="gaia.git" path="gaia" remote="mozillaorg" revision="86af137c7f4c41c1185e609339002ab47fd6c640"/>
|
||||
<project name="gonk-misc" path="gonk-misc" remote="b2g" revision="3477513bcd385571aa01c0d074849e35bd5e2376"/>
|
||||
<project name="rilproxy" path="rilproxy" remote="b2g" revision="5ef30994f4778b4052e58a4383dbe7890048c87e"/>
|
||||
<project name="platform_hardware_ril" path="hardware/ril" remote="b2g" revision="87a2d8ab9248540910e56921654367b78a587095"/>
|
||||
|
@ -17,10 +17,10 @@
|
||||
</project>
|
||||
<project name="rilproxy" path="rilproxy" remote="b2g" revision="5ef30994f4778b4052e58a4383dbe7890048c87e"/>
|
||||
<project name="fake-libdvm" path="dalvik" remote="b2g" revision="d50ae982b19f42f0b66d08b9eb306be81687869f"/>
|
||||
<project name="gaia" path="gaia" remote="mozillaorg" revision="e6506d68e01489b57616f8b74e8773f938ce62b3"/>
|
||||
<project name="gaia" path="gaia" remote="mozillaorg" revision="86af137c7f4c41c1185e609339002ab47fd6c640"/>
|
||||
<project name="gonk-misc" path="gonk-misc" remote="b2g" revision="3477513bcd385571aa01c0d074849e35bd5e2376"/>
|
||||
<project name="moztt" path="external/moztt" remote="b2g" revision="46da1a05ac04157669685246d70ac59d48699c9e"/>
|
||||
<project name="apitrace" path="external/apitrace" remote="apitrace" revision="49192a4e48d080e44a0d66f059e6897f07cf67f8"/>
|
||||
<project name="apitrace" path="external/apitrace" remote="apitrace" revision="47f48a42502b1c694db2b162011a67a2ff888c5d"/>
|
||||
<project name="valgrind" path="external/valgrind" remote="b2g" revision="daa61633c32b9606f58799a3186395fd2bbb8d8c"/>
|
||||
<project name="vex" path="external/VEX" remote="b2g" revision="47f031c320888fe9f3e656602588565b52d43010"/>
|
||||
<!-- Stock Android things -->
|
||||
|
@ -15,7 +15,7 @@
|
||||
<project name="platform_build" path="build" remote="b2g" revision="e862ab9177af664f00b4522e2350f4cb13866d73">
|
||||
<copyfile dest="Makefile" src="core/root.mk"/>
|
||||
</project>
|
||||
<project name="gaia" path="gaia" remote="mozillaorg" revision="e6506d68e01489b57616f8b74e8773f938ce62b3"/>
|
||||
<project name="gaia" path="gaia" remote="mozillaorg" revision="86af137c7f4c41c1185e609339002ab47fd6c640"/>
|
||||
<project name="fake-libdvm" path="dalvik" remote="b2g" revision="d50ae982b19f42f0b66d08b9eb306be81687869f"/>
|
||||
<project name="gonk-misc" path="gonk-misc" remote="b2g" revision="3477513bcd385571aa01c0d074849e35bd5e2376"/>
|
||||
<project name="librecovery" path="librecovery" remote="b2g" revision="1b3591a50ed352fc6ddb77462b7b35d0bfa555a3"/>
|
||||
@ -23,7 +23,7 @@
|
||||
<project name="rilproxy" path="rilproxy" remote="b2g" revision="5ef30994f4778b4052e58a4383dbe7890048c87e"/>
|
||||
<project name="valgrind" path="external/valgrind" remote="b2g" revision="daa61633c32b9606f58799a3186395fd2bbb8d8c"/>
|
||||
<project name="vex" path="external/VEX" remote="b2g" revision="47f031c320888fe9f3e656602588565b52d43010"/>
|
||||
<project name="apitrace" path="external/apitrace" remote="apitrace" revision="49192a4e48d080e44a0d66f059e6897f07cf67f8"/>
|
||||
<project name="apitrace" path="external/apitrace" remote="apitrace" revision="47f48a42502b1c694db2b162011a67a2ff888c5d"/>
|
||||
<!-- Stock Android things -->
|
||||
<project groups="linux" name="platform/prebuilts/gcc/linux-x86/host/i686-linux-glibc2.7-4.6" path="prebuilts/gcc/linux-x86/host/i686-linux-glibc2.7-4.6" revision="f92a936f2aa97526d4593386754bdbf02db07a12"/>
|
||||
<project groups="linux" name="platform/prebuilts/gcc/linux-x86/host/x86_64-linux-glibc2.7-4.6" path="prebuilts/gcc/linux-x86/host/x86_64-linux-glibc2.7-4.6" revision="6e47ff2790f5656b5b074407829ceecf3e6188c4"/>
|
||||
|
@ -15,7 +15,7 @@
|
||||
<project name="platform_build" path="build" remote="b2g" revision="61e82f99bb8bc78d52b5717e9a2481ec7267fa33">
|
||||
<copyfile dest="Makefile" src="core/root.mk"/>
|
||||
</project>
|
||||
<project name="gaia" path="gaia" remote="mozillaorg" revision="e6506d68e01489b57616f8b74e8773f938ce62b3"/>
|
||||
<project name="gaia" path="gaia" remote="mozillaorg" revision="86af137c7f4c41c1185e609339002ab47fd6c640"/>
|
||||
<project name="fake-libdvm" path="dalvik" remote="b2g" revision="d50ae982b19f42f0b66d08b9eb306be81687869f"/>
|
||||
<project name="gonk-misc" path="gonk-misc" remote="b2g" revision="3477513bcd385571aa01c0d074849e35bd5e2376"/>
|
||||
<project name="librecovery" path="librecovery" remote="b2g" revision="1b3591a50ed352fc6ddb77462b7b35d0bfa555a3"/>
|
||||
@ -23,7 +23,7 @@
|
||||
<project name="rilproxy" path="rilproxy" remote="b2g" revision="5ef30994f4778b4052e58a4383dbe7890048c87e"/>
|
||||
<project name="valgrind" path="external/valgrind" remote="b2g" revision="daa61633c32b9606f58799a3186395fd2bbb8d8c"/>
|
||||
<project name="vex" path="external/VEX" remote="b2g" revision="47f031c320888fe9f3e656602588565b52d43010"/>
|
||||
<project name="apitrace" path="external/apitrace" remote="apitrace" revision="49192a4e48d080e44a0d66f059e6897f07cf67f8"/>
|
||||
<project name="apitrace" path="external/apitrace" remote="apitrace" revision="47f48a42502b1c694db2b162011a67a2ff888c5d"/>
|
||||
<!-- Stock Android things -->
|
||||
<project groups="pdk,linux" name="platform/prebuilts/clang/linux-x86/host/3.5" path="prebuilts/clang/linux-x86/host/3.5" revision="ffc05a232799fe8fcb3e47b7440b52b1fb4244c0"/>
|
||||
<project groups="pdk,linux,arm" name="platform/prebuilts/gcc/linux-x86/aarch64/aarch64-linux-android-4.8" path="prebuilts/gcc/linux-x86/aarch64/aarch64-linux-android-4.8" revision="337e0ef5e40f02a1ae59b90db0548976c70a7226"/>
|
||||
|
@ -19,7 +19,7 @@
|
||||
<copyfile dest="Makefile" src="core/root.mk"/>
|
||||
</project>
|
||||
<project name="fake-dalvik" path="dalvik" remote="b2g" revision="ca1f327d5acc198bb4be62fa51db2c039032c9ce"/>
|
||||
<project name="gaia.git" path="gaia" remote="mozillaorg" revision="e6506d68e01489b57616f8b74e8773f938ce62b3"/>
|
||||
<project name="gaia.git" path="gaia" remote="mozillaorg" revision="86af137c7f4c41c1185e609339002ab47fd6c640"/>
|
||||
<project name="gonk-misc" path="gonk-misc" remote="b2g" revision="3477513bcd385571aa01c0d074849e35bd5e2376"/>
|
||||
<project name="rilproxy" path="rilproxy" remote="b2g" revision="5ef30994f4778b4052e58a4383dbe7890048c87e"/>
|
||||
<project name="platform_hardware_ril" path="hardware/ril" remote="b2g" revision="87a2d8ab9248540910e56921654367b78a587095"/>
|
||||
|
@ -15,7 +15,7 @@
|
||||
<project name="platform_build" path="build" remote="b2g" revision="e862ab9177af664f00b4522e2350f4cb13866d73">
|
||||
<copyfile dest="Makefile" src="core/root.mk"/>
|
||||
</project>
|
||||
<project name="gaia" path="gaia" remote="mozillaorg" revision="e6506d68e01489b57616f8b74e8773f938ce62b3"/>
|
||||
<project name="gaia" path="gaia" remote="mozillaorg" revision="86af137c7f4c41c1185e609339002ab47fd6c640"/>
|
||||
<project name="fake-libdvm" path="dalvik" remote="b2g" revision="d50ae982b19f42f0b66d08b9eb306be81687869f"/>
|
||||
<project name="gonk-misc" path="gonk-misc" remote="b2g" revision="3477513bcd385571aa01c0d074849e35bd5e2376"/>
|
||||
<project name="librecovery" path="librecovery" remote="b2g" revision="1b3591a50ed352fc6ddb77462b7b35d0bfa555a3"/>
|
||||
@ -23,7 +23,7 @@
|
||||
<project name="rilproxy" path="rilproxy" remote="b2g" revision="5ef30994f4778b4052e58a4383dbe7890048c87e"/>
|
||||
<project name="valgrind" path="external/valgrind" remote="b2g" revision="daa61633c32b9606f58799a3186395fd2bbb8d8c"/>
|
||||
<project name="vex" path="external/VEX" remote="b2g" revision="47f031c320888fe9f3e656602588565b52d43010"/>
|
||||
<project name="apitrace" path="external/apitrace" remote="apitrace" revision="49192a4e48d080e44a0d66f059e6897f07cf67f8"/>
|
||||
<project name="apitrace" path="external/apitrace" remote="apitrace" revision="47f48a42502b1c694db2b162011a67a2ff888c5d"/>
|
||||
<!-- Stock Android things -->
|
||||
<project groups="linux" name="platform/prebuilts/gcc/linux-x86/host/i686-linux-glibc2.7-4.6" path="prebuilts/gcc/linux-x86/host/i686-linux-glibc2.7-4.6" revision="95bb5b66b3ec5769c3de8d3f25d681787418e7d2"/>
|
||||
<project groups="linux" name="platform/prebuilts/gcc/linux-x86/host/x86_64-linux-glibc2.7-4.6" path="prebuilts/gcc/linux-x86/host/x86_64-linux-glibc2.7-4.6" revision="ebdad82e61c16772f6cd47e9f11936bf6ebe9aa0"/>
|
||||
|
@ -1,9 +1,9 @@
|
||||
{
|
||||
"git": {
|
||||
"git_revision": "e6506d68e01489b57616f8b74e8773f938ce62b3",
|
||||
"git_revision": "86af137c7f4c41c1185e609339002ab47fd6c640",
|
||||
"remote": "https://git.mozilla.org/releases/gaia.git",
|
||||
"branch": ""
|
||||
},
|
||||
"revision": "b126eb6c8cb42a881f56ed9ed9c81306858a388b",
|
||||
"revision": "e700d1e96a1185d51c9f5782e442dc0610a10d95",
|
||||
"repo_path": "integration/gaia-central"
|
||||
}
|
||||
|
@ -17,10 +17,10 @@
|
||||
</project>
|
||||
<project name="rilproxy" path="rilproxy" remote="b2g" revision="5ef30994f4778b4052e58a4383dbe7890048c87e"/>
|
||||
<project name="fake-libdvm" path="dalvik" remote="b2g" revision="d50ae982b19f42f0b66d08b9eb306be81687869f"/>
|
||||
<project name="gaia" path="gaia" remote="mozillaorg" revision="e6506d68e01489b57616f8b74e8773f938ce62b3"/>
|
||||
<project name="gaia" path="gaia" remote="mozillaorg" revision="86af137c7f4c41c1185e609339002ab47fd6c640"/>
|
||||
<project name="gonk-misc" path="gonk-misc" remote="b2g" revision="3477513bcd385571aa01c0d074849e35bd5e2376"/>
|
||||
<project name="moztt" path="external/moztt" remote="b2g" revision="46da1a05ac04157669685246d70ac59d48699c9e"/>
|
||||
<project name="apitrace" path="external/apitrace" remote="apitrace" revision="49192a4e48d080e44a0d66f059e6897f07cf67f8"/>
|
||||
<project name="apitrace" path="external/apitrace" remote="apitrace" revision="47f48a42502b1c694db2b162011a67a2ff888c5d"/>
|
||||
<project name="valgrind" path="external/valgrind" remote="b2g" revision="daa61633c32b9606f58799a3186395fd2bbb8d8c"/>
|
||||
<project name="vex" path="external/VEX" remote="b2g" revision="47f031c320888fe9f3e656602588565b52d43010"/>
|
||||
<!-- Stock Android things -->
|
||||
|
@ -15,7 +15,7 @@
|
||||
<project name="platform_build" path="build" remote="b2g" revision="61e82f99bb8bc78d52b5717e9a2481ec7267fa33">
|
||||
<copyfile dest="Makefile" src="core/root.mk"/>
|
||||
</project>
|
||||
<project name="gaia" path="gaia" remote="mozillaorg" revision="e6506d68e01489b57616f8b74e8773f938ce62b3"/>
|
||||
<project name="gaia" path="gaia" remote="mozillaorg" revision="86af137c7f4c41c1185e609339002ab47fd6c640"/>
|
||||
<project name="fake-libdvm" path="dalvik" remote="b2g" revision="d50ae982b19f42f0b66d08b9eb306be81687869f"/>
|
||||
<project name="gonk-misc" path="gonk-misc" remote="b2g" revision="3477513bcd385571aa01c0d074849e35bd5e2376"/>
|
||||
<project name="librecovery" path="librecovery" remote="b2g" revision="1b3591a50ed352fc6ddb77462b7b35d0bfa555a3"/>
|
||||
@ -23,7 +23,7 @@
|
||||
<project name="rilproxy" path="rilproxy" remote="b2g" revision="5ef30994f4778b4052e58a4383dbe7890048c87e"/>
|
||||
<project name="valgrind" path="external/valgrind" remote="b2g" revision="daa61633c32b9606f58799a3186395fd2bbb8d8c"/>
|
||||
<project name="vex" path="external/VEX" remote="b2g" revision="47f031c320888fe9f3e656602588565b52d43010"/>
|
||||
<project name="apitrace" path="external/apitrace" remote="apitrace" revision="49192a4e48d080e44a0d66f059e6897f07cf67f8"/>
|
||||
<project name="apitrace" path="external/apitrace" remote="apitrace" revision="47f48a42502b1c694db2b162011a67a2ff888c5d"/>
|
||||
<!-- Stock Android things -->
|
||||
<project groups="pdk,linux" name="platform/prebuilts/clang/linux-x86/host/3.5" path="prebuilts/clang/linux-x86/host/3.5" revision="ffc05a232799fe8fcb3e47b7440b52b1fb4244c0"/>
|
||||
<project groups="pdk,linux,arm" name="platform/prebuilts/gcc/linux-x86/aarch64/aarch64-linux-android-4.8" path="prebuilts/gcc/linux-x86/aarch64/aarch64-linux-android-4.8" revision="337e0ef5e40f02a1ae59b90db0548976c70a7226"/>
|
||||
|
@ -694,6 +694,27 @@ enum BluetoothGattCharPropBit {
|
||||
typedef uint8_t BluetoothGattCharProp;
|
||||
#define BLUETOOTH_EMPTY_GATT_CHAR_PROP static_cast<BluetoothGattCharProp>(0x00)
|
||||
|
||||
/*
|
||||
* Bluetooth GATT Attribute Permissions bit field
|
||||
*/
|
||||
enum BluetoothGattAttrPermBit {
|
||||
GATT_ATTR_PERM_BIT_READ = (1 << 0),
|
||||
GATT_ATTR_PERM_BIT_READ_ENCRYPTED = (1 << 1),
|
||||
GATT_ATTR_PERM_BIT_READ_ENCRYPTED_MITM = (1 << 2),
|
||||
GATT_ATTR_PERM_BIT_WRITE = (1 << 4),
|
||||
GATT_ATTR_PERM_BIT_WRITE_ENCRYPTED = (1 << 5),
|
||||
GATT_ATTR_PERM_BIT_WRITE_ENCRYPTED_MITM = (1 << 6),
|
||||
GATT_ATTR_PERM_BIT_WRITE_SIGNED = (1 << 7),
|
||||
GATT_ATTR_PERM_BIT_WRITE_SIGNED_MITM = (1 << 8)
|
||||
};
|
||||
|
||||
/*
|
||||
* BluetoothGattAttrPerm is used to store a bit mask value which contains
|
||||
* each corresponding bit value of each BluetoothGattAttrPermBit.
|
||||
*/
|
||||
typedef int32_t BluetoothGattAttrPerm;
|
||||
#define BLUETOOTH_EMPTY_GATT_ATTR_PERM static_cast<BluetoothGattAttrPerm>(0x00)
|
||||
|
||||
struct BluetoothGattAdvData {
|
||||
uint8_t mAdvData[62];
|
||||
};
|
||||
@ -767,6 +788,14 @@ struct BluetoothGattTestParam {
|
||||
uint16_t mU5;
|
||||
};
|
||||
|
||||
struct BluetoothGattResponse {
|
||||
uint16_t mHandle;
|
||||
uint16_t mOffset;
|
||||
uint16_t mLength;
|
||||
BluetoothGattAuthReq mAuthReq;
|
||||
uint8_t mValue[BLUETOOTH_GATT_MAX_ATTR_LEN];
|
||||
};
|
||||
|
||||
/**
|
||||
* EIR Data Type, Advertising Data Type (AD Type) and OOB Data Type Definitions
|
||||
* Please refer to https://www.bluetooth.org/en-us/specification/\
|
||||
|
@ -611,12 +611,120 @@ protected:
|
||||
class BluetoothGattServerNotificationHandler
|
||||
{
|
||||
public:
|
||||
virtual ~BluetoothGattServerNotificationHandler();
|
||||
// TODO: Add server notifications
|
||||
virtual void
|
||||
RegisterServerNotification(BluetoothGattStatus aStatus,
|
||||
int aServerIf,
|
||||
const BluetoothUuid& aAppUuid)
|
||||
{ }
|
||||
|
||||
virtual void
|
||||
ConnectionNotification(int aConnId,
|
||||
int aServerIf,
|
||||
bool aConnected,
|
||||
const nsAString& aBdAddr)
|
||||
{ }
|
||||
|
||||
virtual void
|
||||
ServiceAddedNotification(BluetoothGattStatus aStatus,
|
||||
int aServerIf,
|
||||
const BluetoothGattServiceId& aServiceId,
|
||||
int aServiceHandle)
|
||||
{ }
|
||||
|
||||
virtual void
|
||||
IncludedServiceAddedNotification(BluetoothGattStatus aStatus,
|
||||
int aServerIf,
|
||||
int aServiceHandle,
|
||||
int aIncludedServiceHandle)
|
||||
{ }
|
||||
|
||||
virtual void
|
||||
CharacteristicAddedNotification(BluetoothGattStatus aStatus,
|
||||
int aServerIf,
|
||||
const BluetoothUuid& aCharId,
|
||||
int aServiceHandle,
|
||||
int aCharacteristicHandle)
|
||||
{ }
|
||||
|
||||
virtual void
|
||||
DescriptorAddedNotification(BluetoothGattStatus aStatus,
|
||||
int aServerIf,
|
||||
const BluetoothUuid& aCharId,
|
||||
int aServiceHandle,
|
||||
int aDescriptorHandle)
|
||||
{ }
|
||||
|
||||
virtual void
|
||||
ServiceStartedNotification(BluetoothGattStatus aStatus,
|
||||
int aServerIf,
|
||||
int aServiceHandle)
|
||||
{ }
|
||||
|
||||
virtual void
|
||||
ServiceStoppedNotification(BluetoothGattStatus aStatus,
|
||||
int aServerIf,
|
||||
int aServiceHandle)
|
||||
{ }
|
||||
|
||||
virtual void
|
||||
ServiceDeletedNotification(BluetoothGattStatus aStatus,
|
||||
int aServerIf,
|
||||
int aServiceHandle)
|
||||
{ }
|
||||
|
||||
virtual void
|
||||
RequestReadNotification(int aConnId,
|
||||
int aTransId,
|
||||
const nsAString& aBdAddr,
|
||||
int aAttributeHandle,
|
||||
int aOffset,
|
||||
bool aIsLong)
|
||||
{ }
|
||||
|
||||
virtual void
|
||||
RequestWriteNotification(int aConnId,
|
||||
int aTransId,
|
||||
const nsAString& aBdAddr,
|
||||
int aAttributeHandle,
|
||||
int aOffset,
|
||||
const nsTArray<uint8_t>& aValue,
|
||||
bool aNeedResponse,
|
||||
bool aIsPrepareWrite)
|
||||
{ }
|
||||
|
||||
virtual void
|
||||
RequestExecuteWriteNotification(int aConnId,
|
||||
int aTransId,
|
||||
const nsAString& aBdAddr,
|
||||
bool aExecute) /* true: execute */
|
||||
/* false: cancel */
|
||||
{ }
|
||||
|
||||
virtual void
|
||||
ResponseConfirmationNotification(BluetoothGattStatus aStatus,
|
||||
int aHandle)
|
||||
{ }
|
||||
|
||||
virtual void
|
||||
IndicationSentNotification(int aConnId,
|
||||
BluetoothGattStatus aStatus)
|
||||
{ }
|
||||
|
||||
virtual void
|
||||
CongestionNotification(int aConnId,
|
||||
bool aCongested)
|
||||
{ }
|
||||
|
||||
virtual void
|
||||
MtuChangedNotification(int aConnId,
|
||||
int aMtu)
|
||||
{ }
|
||||
|
||||
protected:
|
||||
BluetoothGattServerNotificationHandler()
|
||||
{ }
|
||||
|
||||
virtual ~BluetoothGattServerNotificationHandler();
|
||||
};
|
||||
|
||||
class BluetoothGattNotificationHandler
|
||||
@ -688,7 +796,38 @@ protected:
|
||||
virtual ~BluetoothGattClientResultHandler() { }
|
||||
};
|
||||
|
||||
// TODO: Add GattServerResultHandler
|
||||
class BluetoothGattServerResultHandler
|
||||
{
|
||||
public:
|
||||
NS_INLINE_DECL_THREADSAFE_REFCOUNTING(BluetoothGattServerResultHandler)
|
||||
|
||||
virtual void OnError(BluetoothStatus aStatus)
|
||||
{
|
||||
BT_WARNING("Received error code %d", (int)aStatus);
|
||||
}
|
||||
|
||||
virtual void RegisterServer() { }
|
||||
virtual void UnregisterServer() { }
|
||||
|
||||
virtual void ConnectPeripheral() { }
|
||||
virtual void DisconnectPeripheral() { }
|
||||
|
||||
virtual void AddService() { }
|
||||
virtual void AddIncludedService() { }
|
||||
virtual void AddCharacteristic() { }
|
||||
virtual void AddDescriptor() { }
|
||||
|
||||
virtual void StartService() { }
|
||||
virtual void StopService() { }
|
||||
virtual void DeleteService() { }
|
||||
|
||||
virtual void SendIndication() { }
|
||||
|
||||
virtual void SendResponse() { }
|
||||
|
||||
protected:
|
||||
virtual ~BluetoothGattServerResultHandler() { }
|
||||
};
|
||||
|
||||
class BluetoothGattClientInterface
|
||||
{
|
||||
@ -827,7 +966,79 @@ protected:
|
||||
virtual ~BluetoothGattClientInterface();
|
||||
};
|
||||
|
||||
// TODO: Add GattServerInterface
|
||||
class BluetoothGattServerInterface
|
||||
{
|
||||
public:
|
||||
/* Register / Unregister */
|
||||
virtual void RegisterServer(const BluetoothUuid& aUuid,
|
||||
BluetoothGattServerResultHandler* aRes) = 0;
|
||||
virtual void UnregisterServer(int aServerIf,
|
||||
BluetoothGattServerResultHandler* aRes) = 0;
|
||||
|
||||
/* Connect / Disconnect */
|
||||
virtual void ConnectPeripheral(int aServerIf,
|
||||
const nsAString& aBdAddr,
|
||||
bool aIsDirect, /* auto connect */
|
||||
BluetoothTransport aTransport,
|
||||
BluetoothGattServerResultHandler* aRes) = 0;
|
||||
virtual void DisconnectPeripheral(int aServerIf,
|
||||
const nsAString& aBdAddr,
|
||||
int aConnId,
|
||||
BluetoothGattServerResultHandler* aRes) = 0;
|
||||
|
||||
/* Add a services / a characteristic / a descriptor */
|
||||
virtual void AddService(int aServerIf,
|
||||
const BluetoothGattServiceId& aServiceId,
|
||||
int aNumHandles,
|
||||
BluetoothGattServerResultHandler* aRes) = 0;
|
||||
virtual void AddIncludedService(int aServerIf,
|
||||
int aServiceHandle,
|
||||
int aIncludedServiceHandle,
|
||||
BluetoothGattServerResultHandler* aRes) = 0;
|
||||
virtual void AddCharacteristic(int aServerIf,
|
||||
int aServiceHandle,
|
||||
const BluetoothUuid& aUuid,
|
||||
BluetoothGattCharProp aProperties,
|
||||
BluetoothGattAttrPerm aPermissions,
|
||||
BluetoothGattServerResultHandler* aRes) = 0;
|
||||
virtual void AddDescriptor(int aServerIf,
|
||||
int aServiceHandle,
|
||||
const BluetoothUuid& aUuid,
|
||||
BluetoothGattAttrPerm aPermissions,
|
||||
BluetoothGattServerResultHandler* aRes) = 0;
|
||||
|
||||
/* Start / Stop / Delete a service */
|
||||
virtual void StartService(int aServerIf,
|
||||
int aServiceHandle,
|
||||
BluetoothTransport aTransport,
|
||||
BluetoothGattServerResultHandler* aRes) = 0;
|
||||
virtual void StopService(int aServerIf,
|
||||
int aServiceHandle,
|
||||
BluetoothGattServerResultHandler* aRes) = 0;
|
||||
virtual void DeleteService(int aServerIf,
|
||||
int aServiceHandle,
|
||||
BluetoothGattServerResultHandler* aRes) = 0;
|
||||
|
||||
/* Send an indication or a notification */
|
||||
virtual void SendIndication(int aServerIf,
|
||||
int aAttributeHandle,
|
||||
int aConnId,
|
||||
const nsTArray<uint8_t>& aValue,
|
||||
bool aConfirm, /* true: indication */
|
||||
/* false: notification */
|
||||
BluetoothGattServerResultHandler* aRes) = 0;
|
||||
|
||||
/* Send a response for an incoming indication */
|
||||
virtual void SendResponse(int aConnId,
|
||||
int aTransId,
|
||||
BluetoothGattStatus aStatus,
|
||||
const BluetoothGattResponse& aResponse,
|
||||
BluetoothGattServerResultHandler* aRes) = 0;
|
||||
|
||||
protected:
|
||||
BluetoothGattServerInterface();
|
||||
virtual ~BluetoothGattServerInterface();
|
||||
};
|
||||
|
||||
class BluetoothGattInterface
|
||||
{
|
||||
|
@ -23,6 +23,15 @@ typedef
|
||||
BluetoothStatus, BluetoothStatus>
|
||||
BluetoothGattClientHALErrorRunnable;
|
||||
|
||||
typedef
|
||||
BluetoothHALInterfaceRunnable0<BluetoothGattServerResultHandler, void>
|
||||
BluetoothGattServerHALResultRunnable;
|
||||
|
||||
typedef
|
||||
BluetoothHALInterfaceRunnable1<BluetoothGattServerResultHandler, void,
|
||||
BluetoothStatus, BluetoothStatus>
|
||||
BluetoothGattServerHALErrorRunnable;
|
||||
|
||||
typedef
|
||||
BluetoothHALInterfaceRunnable0<BluetoothGattResultHandler, void>
|
||||
BluetoothGattHALResultRunnable;
|
||||
@ -84,6 +93,29 @@ DispatchBluetoothGattClientHALResult(
|
||||
return rv;
|
||||
}
|
||||
|
||||
static nsresult
|
||||
DispatchBluetoothGattServerHALResult(
|
||||
BluetoothGattServerResultHandler* aRes,
|
||||
void (BluetoothGattServerResultHandler::*aMethod)(),
|
||||
BluetoothStatus aStatus)
|
||||
{
|
||||
MOZ_ASSERT(aRes);
|
||||
|
||||
nsRunnable* runnable;
|
||||
|
||||
if (aStatus == STATUS_SUCCESS) {
|
||||
runnable = new BluetoothGattServerHALResultRunnable(aRes, aMethod);
|
||||
} else {
|
||||
runnable = new BluetoothGattServerHALErrorRunnable(aRes,
|
||||
&BluetoothGattServerResultHandler::OnError, aStatus);
|
||||
}
|
||||
nsresult rv = NS_DispatchToMainThread(runnable);
|
||||
if (NS_FAILED(rv)) {
|
||||
BT_WARNING("NS_DispatchToMainThread failed: %X", rv);
|
||||
}
|
||||
return rv;
|
||||
}
|
||||
|
||||
static nsresult
|
||||
DispatchBluetoothGattHALResult(
|
||||
BluetoothGattResultHandler* aRes,
|
||||
@ -416,73 +448,244 @@ struct BluetoothGattServerCallback
|
||||
};
|
||||
|
||||
// Notifications
|
||||
// TODO: Add Server Notifications
|
||||
typedef BluetoothNotificationHALRunnable3<
|
||||
GattServerNotificationHandlerWrapper, void,
|
||||
BluetoothGattStatus, int, BluetoothUuid,
|
||||
BluetoothGattStatus, int, const BluetoothUuid&>
|
||||
RegisterServerNotification;
|
||||
|
||||
typedef BluetoothNotificationHALRunnable4<
|
||||
GattServerNotificationHandlerWrapper, void,
|
||||
int, int, bool, nsString,
|
||||
int, int, bool, const nsAString&>
|
||||
ConnectionNotification;
|
||||
|
||||
typedef BluetoothNotificationHALRunnable4<
|
||||
GattServerNotificationHandlerWrapper, void,
|
||||
BluetoothGattStatus, int, BluetoothGattServiceId, int,
|
||||
BluetoothGattStatus, int, const BluetoothGattServiceId&, int>
|
||||
ServiceAddedNotification;
|
||||
|
||||
typedef BluetoothNotificationHALRunnable4<
|
||||
GattServerNotificationHandlerWrapper, void,
|
||||
BluetoothGattStatus, int, int, int>
|
||||
IncludedServiceAddedNotification;
|
||||
|
||||
typedef BluetoothNotificationHALRunnable5<
|
||||
GattServerNotificationHandlerWrapper, void,
|
||||
BluetoothGattStatus, int, BluetoothUuid, int, int,
|
||||
BluetoothGattStatus, int, const BluetoothUuid&, int, int>
|
||||
CharacteristicAddedNotification;
|
||||
|
||||
typedef BluetoothNotificationHALRunnable5<
|
||||
GattServerNotificationHandlerWrapper, void,
|
||||
BluetoothGattStatus, int, BluetoothUuid, int, int,
|
||||
BluetoothGattStatus, int, const BluetoothUuid&, int, int>
|
||||
DescriptorAddedNotification;
|
||||
|
||||
typedef BluetoothNotificationHALRunnable3<
|
||||
GattServerNotificationHandlerWrapper, void,
|
||||
BluetoothGattStatus, int, int>
|
||||
ServiceStartedNotification;
|
||||
|
||||
typedef BluetoothNotificationHALRunnable3<
|
||||
GattServerNotificationHandlerWrapper, void,
|
||||
BluetoothGattStatus, int, int>
|
||||
ServiceStoppedNotification;
|
||||
|
||||
typedef BluetoothNotificationHALRunnable3<
|
||||
GattServerNotificationHandlerWrapper, void,
|
||||
BluetoothGattStatus, int, int>
|
||||
ServiceDeletedNotification;
|
||||
|
||||
typedef BluetoothNotificationHALRunnable6<
|
||||
GattServerNotificationHandlerWrapper, void,
|
||||
int, int, nsString, int, int, bool,
|
||||
int, int, const nsAString&, int, int, bool>
|
||||
RequestReadNotification;
|
||||
|
||||
typedef BluetoothNotificationHALRunnable8<
|
||||
GattServerNotificationHandlerWrapper, void,
|
||||
int, int, nsString, int, int, nsTArray<uint8_t>, bool, bool,
|
||||
int, int, const nsAString&, int, int, const nsTArray<uint8_t>&, bool, bool>
|
||||
RequestWriteNotification;
|
||||
|
||||
typedef BluetoothNotificationHALRunnable4<
|
||||
GattServerNotificationHandlerWrapper, void,
|
||||
int, int, nsString, bool,
|
||||
int, int, const nsAString&, bool>
|
||||
RequestExecuteWriteNotification;
|
||||
|
||||
typedef BluetoothNotificationHALRunnable2<
|
||||
GattServerNotificationHandlerWrapper, void,
|
||||
BluetoothGattStatus, int>
|
||||
ResponseConfirmationNotification;
|
||||
|
||||
#if ANDROID_VERSION >= 21
|
||||
typedef BluetoothNotificationHALRunnable2<
|
||||
GattServerNotificationHandlerWrapper, void,
|
||||
int, BluetoothGattStatus>
|
||||
IndicationSentNotification;
|
||||
|
||||
typedef BluetoothNotificationHALRunnable2<
|
||||
GattServerNotificationHandlerWrapper, void,
|
||||
int, bool>
|
||||
CongestionNotification;
|
||||
#endif // ANDROID_VERSION >= 21
|
||||
|
||||
#if ANDROID_VERSION >=22
|
||||
typedef BluetoothNotificationHALRunnable2<
|
||||
GattServerNotificationHandlerWrapper, void,
|
||||
int, int>
|
||||
MtuChangedNotification;
|
||||
#endif // ANDROID_VERSION >=22
|
||||
|
||||
// GATT Server callbacks
|
||||
// TODO: Implement server callbacks
|
||||
|
||||
#if ANDROID_VERSION >= 19
|
||||
static void
|
||||
RegisterServer(int aStatus, int aServerIf, bt_uuid_t* aAppUuid)
|
||||
{ }
|
||||
{
|
||||
RegisterServerNotification::Dispatch(
|
||||
&BluetoothGattServerNotificationHandler::RegisterServerNotification,
|
||||
aStatus, aServerIf, *aAppUuid);
|
||||
}
|
||||
|
||||
static void
|
||||
Connection(int aConnId, int aServerIf, int aIsConnected,
|
||||
bt_bdaddr_t* aBdAddr)
|
||||
{ }
|
||||
{
|
||||
ConnectionNotification::Dispatch(
|
||||
&BluetoothGattServerNotificationHandler::ConnectionNotification,
|
||||
aConnId, aServerIf, aIsConnected != 0, aBdAddr);
|
||||
}
|
||||
|
||||
static void
|
||||
ServiceAdded(int aStatus, int aServerIf, btgatt_srvc_id_t* aServiceId,
|
||||
int aServiceHandle)
|
||||
{ }
|
||||
{
|
||||
ServiceAddedNotification::Dispatch(
|
||||
&BluetoothGattServerNotificationHandler::ServiceAddedNotification,
|
||||
aStatus, aServerIf, *aServiceId, aServiceHandle);
|
||||
}
|
||||
|
||||
static void
|
||||
IncludedServiceAdded(int aStatus, int aServerIf, int aServiceHandle,
|
||||
int aIncludedServiceHandle)
|
||||
{ }
|
||||
{
|
||||
IncludedServiceAddedNotification::Dispatch(
|
||||
&BluetoothGattServerNotificationHandler::IncludedServiceAddedNotification,
|
||||
aStatus, aServerIf, aServiceHandle, aIncludedServiceHandle);
|
||||
}
|
||||
|
||||
static void
|
||||
CharacteristicAdded(int aStatus, int aServerIf, bt_uuid_t* aUuid,
|
||||
int aServiceHandle, int aCharHandle)
|
||||
{ }
|
||||
{
|
||||
CharacteristicAddedNotification::Dispatch(
|
||||
&BluetoothGattServerNotificationHandler::CharacteristicAddedNotification,
|
||||
aStatus, aServerIf, *aUuid, aServiceHandle, aCharHandle);
|
||||
}
|
||||
|
||||
static void
|
||||
DescriptorAdded(int aStatus, int aServerIf, bt_uuid_t* aUuid,
|
||||
int aServiceHandle, int aDescriptorHandle)
|
||||
{ }
|
||||
{
|
||||
DescriptorAddedNotification::Dispatch(
|
||||
&BluetoothGattServerNotificationHandler::DescriptorAddedNotification,
|
||||
aStatus, aServerIf, *aUuid, aServiceHandle, aDescriptorHandle);
|
||||
}
|
||||
|
||||
static void
|
||||
ServiceStarted(int aStatus, int aServerIf, int aServiceHandle)
|
||||
{ }
|
||||
{
|
||||
ServiceStartedNotification::Dispatch(
|
||||
&BluetoothGattServerNotificationHandler::ServiceStartedNotification,
|
||||
aStatus, aServerIf, aServiceHandle);
|
||||
}
|
||||
|
||||
static void
|
||||
ServiceStopped(int aStatus, int aServerIf, int aServiceHandle)
|
||||
{ }
|
||||
{
|
||||
ServiceStoppedNotification::Dispatch(
|
||||
&BluetoothGattServerNotificationHandler::ServiceStoppedNotification,
|
||||
aStatus, aServerIf, aServiceHandle);
|
||||
}
|
||||
|
||||
static void
|
||||
ServiceDeleted(int aStatus, int aServerIf, int aServiceHandle)
|
||||
{ }
|
||||
{
|
||||
ServiceDeletedNotification::Dispatch(
|
||||
&BluetoothGattServerNotificationHandler::ServiceDeletedNotification,
|
||||
aStatus, aServerIf, aServiceHandle);
|
||||
}
|
||||
|
||||
static void
|
||||
RequestRead(int aConnId, int aTransId, bt_bdaddr_t* aBdAddr,
|
||||
int aAttrHandle, int aOffset, bool aIsLong)
|
||||
{ }
|
||||
{
|
||||
RequestReadNotification::Dispatch(
|
||||
&BluetoothGattServerNotificationHandler::RequestReadNotification,
|
||||
aConnId, aTransId, *aBdAddr, aAttrHandle, aOffset, aIsLong);
|
||||
}
|
||||
|
||||
static void
|
||||
RequestWrite(int aConnId, int aTransId, bt_bdaddr_t* aBdAddr,
|
||||
int aAttrHandle, int aOffset, int aLength,
|
||||
bool aNeedRsp, bool aIsPrep, uint8_t* aValue)
|
||||
{ }
|
||||
{
|
||||
nsTArray<uint8_t> value;
|
||||
value.AppendElements(aValue, aLength);
|
||||
RequestWriteNotification::Dispatch(
|
||||
&BluetoothGattServerNotificationHandler::RequestWriteNotification,
|
||||
aConnId, aTransId, *aBdAddr, aAttrHandle, aOffset, value, aNeedRsp,
|
||||
aIsPrep);
|
||||
}
|
||||
|
||||
static void
|
||||
RequestExecWrite(int aConnId, int aTransId, bt_bdaddr_t* aBdAddr,
|
||||
int aExecWrite)
|
||||
{ }
|
||||
RequestExecuteWrite(int aConnId, int aTransId, bt_bdaddr_t* aBdAddr,
|
||||
int aExecWrite)
|
||||
{
|
||||
RequestExecuteWriteNotification::Dispatch(
|
||||
&BluetoothGattServerNotificationHandler::RequestExecuteWriteNotification,
|
||||
aConnId, aTransId, *aBdAddr, aExecWrite != 0);
|
||||
}
|
||||
|
||||
static void
|
||||
ResponseConfirmation(int aStatus, int aHandle)
|
||||
{ }
|
||||
{
|
||||
ResponseConfirmationNotification::Dispatch(
|
||||
&BluetoothGattServerNotificationHandler::ResponseConfirmationNotification,
|
||||
aStatus, aHandle);
|
||||
}
|
||||
#endif // ANDROID_VERSION >= 19
|
||||
|
||||
#if ANDROID_VERSION >= 21
|
||||
static void
|
||||
IndicationSent(int aConnId, int aStatus)
|
||||
{
|
||||
IndicationSentNotification::Dispatch(
|
||||
&BluetoothGattServerNotificationHandler::IndicationSentNotification,
|
||||
aConnId, aStatus);
|
||||
}
|
||||
|
||||
static void
|
||||
Congestion(int aConnId, bool aCongested)
|
||||
{
|
||||
CongestionNotification::Dispatch(
|
||||
&BluetoothGattServerNotificationHandler::CongestionNotification,
|
||||
aConnId, aCongested);
|
||||
}
|
||||
#endif // ANDROID_VERSION >= 21
|
||||
|
||||
#if ANDROID_VERSION >= 22
|
||||
static void
|
||||
MtuChanged(int aConnId, int aMtu)
|
||||
{
|
||||
MtuChangedNotification::Dispatch(
|
||||
&BluetoothGattServerNotificationHandler::MtuChangedNotification,
|
||||
aConnId, aMtu);
|
||||
}
|
||||
#endif // ANDROID_VERSION >= 22
|
||||
};
|
||||
|
||||
// GATT Client Interface
|
||||
@ -1119,7 +1322,341 @@ BluetoothGattClientHALInterface::TestCommand(
|
||||
|
||||
}
|
||||
|
||||
// TODO: Add GATT Server Interface
|
||||
// GATT Server Interface
|
||||
|
||||
BluetoothGattServerHALInterface::BluetoothGattServerHALInterface(
|
||||
#if ANDROID_VERSION >= 19
|
||||
const btgatt_server_interface_t* aInterface
|
||||
#endif
|
||||
)
|
||||
#if ANDROID_VERSION >= 19
|
||||
:mInterface(aInterface)
|
||||
#endif
|
||||
{
|
||||
#if ANDROID_VERSION >= 19
|
||||
MOZ_ASSERT(mInterface);
|
||||
#endif
|
||||
}
|
||||
|
||||
BluetoothGattServerHALInterface::~BluetoothGattServerHALInterface()
|
||||
{ }
|
||||
|
||||
void
|
||||
BluetoothGattServerHALInterface::RegisterServer(
|
||||
const BluetoothUuid& aUuid, BluetoothGattServerResultHandler* aRes)
|
||||
{
|
||||
int status;
|
||||
#if ANDROID_VERSION >= 19
|
||||
bt_uuid_t uuid;
|
||||
if (NS_SUCCEEDED(Convert(aUuid, uuid))) {
|
||||
status = mInterface->register_server(&uuid);
|
||||
} else {
|
||||
status = BT_STATUS_PARM_INVALID;
|
||||
}
|
||||
#else
|
||||
status = BT_STATUS_UNSUPPORTED;
|
||||
#endif
|
||||
|
||||
if (aRes) {
|
||||
DispatchBluetoothGattServerHALResult(
|
||||
aRes, &BluetoothGattServerResultHandler::RegisterServer,
|
||||
ConvertDefault(status, STATUS_FAIL));
|
||||
}
|
||||
}
|
||||
|
||||
void
|
||||
BluetoothGattServerHALInterface::UnregisterServer(
|
||||
int aServerIf, BluetoothGattServerResultHandler* aRes)
|
||||
{
|
||||
#if ANDROID_VERSION >= 19
|
||||
int status = mInterface->unregister_server(aServerIf);
|
||||
#else
|
||||
int status = BT_STATUS_UNSUPPORTED;
|
||||
#endif
|
||||
|
||||
if (aRes) {
|
||||
DispatchBluetoothGattServerHALResult(
|
||||
aRes, &BluetoothGattServerResultHandler::UnregisterServer,
|
||||
ConvertDefault(status, STATUS_FAIL));
|
||||
}
|
||||
}
|
||||
|
||||
void
|
||||
BluetoothGattServerHALInterface::ConnectPeripheral(
|
||||
int aServerIf, const nsAString& aBdAddr, bool aIsDirect, /* auto connect */
|
||||
BluetoothTransport aTransport, BluetoothGattServerResultHandler* aRes)
|
||||
{
|
||||
bt_status_t status;
|
||||
#if ANDROID_VERSION >= 21
|
||||
bt_bdaddr_t bdAddr;
|
||||
btgatt_transport_t transport;
|
||||
|
||||
if (NS_SUCCEEDED(Convert(aBdAddr, bdAddr)) &&
|
||||
NS_SUCCEEDED(Convert(aTransport, transport))) {
|
||||
status = mInterface->connect(aServerIf, &bdAddr, aIsDirect, transport);
|
||||
} else {
|
||||
status = BT_STATUS_PARM_INVALID;
|
||||
}
|
||||
#elif ANDROID_VERSION >= 19
|
||||
bt_bdaddr_t bdAddr;
|
||||
|
||||
if (NS_SUCCEEDED(Convert(aBdAddr, bdAddr))) {
|
||||
status = mInterface->connect(aServerIf, &bdAddr, aIsDirect);
|
||||
} else {
|
||||
status = BT_STATUS_PARM_INVALID;
|
||||
}
|
||||
#else
|
||||
status = BT_STATUS_UNSUPPORTED;
|
||||
#endif
|
||||
|
||||
if (aRes) {
|
||||
DispatchBluetoothGattServerHALResult(
|
||||
aRes, &BluetoothGattServerResultHandler::ConnectPeripheral,
|
||||
ConvertDefault(status, STATUS_FAIL));
|
||||
}
|
||||
}
|
||||
|
||||
void
|
||||
BluetoothGattServerHALInterface::DisconnectPeripheral(
|
||||
int aServerIf, const nsAString& aBdAddr, int aConnId,
|
||||
BluetoothGattServerResultHandler* aRes)
|
||||
{
|
||||
bt_status_t status;
|
||||
#if ANDROID_VERSION >= 19
|
||||
bt_bdaddr_t bdAddr;
|
||||
|
||||
if (NS_SUCCEEDED(Convert(aBdAddr, bdAddr))) {
|
||||
status = mInterface->disconnect(aServerIf, &bdAddr, aConnId);
|
||||
} else {
|
||||
status = BT_STATUS_PARM_INVALID;
|
||||
}
|
||||
#else
|
||||
status = BT_STATUS_UNSUPPORTED;
|
||||
#endif
|
||||
|
||||
if (aRes) {
|
||||
DispatchBluetoothGattServerHALResult(
|
||||
aRes, &BluetoothGattServerResultHandler::DisconnectPeripheral,
|
||||
ConvertDefault(status, STATUS_FAIL));
|
||||
}
|
||||
}
|
||||
|
||||
void
|
||||
BluetoothGattServerHALInterface::AddService(
|
||||
int aServerIf, const BluetoothGattServiceId& aServiceId, int aNumHandles,
|
||||
BluetoothGattServerResultHandler* aRes)
|
||||
{
|
||||
bt_status_t status;
|
||||
#if ANDROID_VERSION >= 19
|
||||
btgatt_srvc_id_t serviceId;
|
||||
|
||||
if (NS_SUCCEEDED(Convert(aServiceId, serviceId))) {
|
||||
status = mInterface->add_service(aServerIf, &serviceId, aNumHandles);
|
||||
} else {
|
||||
status = BT_STATUS_PARM_INVALID;
|
||||
}
|
||||
#else
|
||||
status = BT_STATUS_UNSUPPORTED;
|
||||
#endif
|
||||
|
||||
if (aRes) {
|
||||
DispatchBluetoothGattServerHALResult(
|
||||
aRes, &BluetoothGattServerResultHandler::AddService,
|
||||
ConvertDefault(status, STATUS_FAIL));
|
||||
}
|
||||
}
|
||||
|
||||
void
|
||||
BluetoothGattServerHALInterface::AddIncludedService(
|
||||
int aServerIf, int aServiceHandle, int aIncludedServiceHandle,
|
||||
BluetoothGattServerResultHandler* aRes)
|
||||
{
|
||||
bt_status_t status;
|
||||
#if ANDROID_VERSION >= 19
|
||||
status = mInterface->add_included_service(aServerIf, aServiceHandle,
|
||||
aIncludedServiceHandle);
|
||||
#else
|
||||
status = BT_STATUS_UNSUPPORTED;
|
||||
#endif
|
||||
|
||||
if (aRes) {
|
||||
DispatchBluetoothGattServerHALResult(
|
||||
aRes, &BluetoothGattServerResultHandler::AddIncludedService,
|
||||
ConvertDefault(status, STATUS_FAIL));
|
||||
}
|
||||
}
|
||||
|
||||
void
|
||||
BluetoothGattServerHALInterface::AddCharacteristic(
|
||||
int aServerIf, int aServiceHandle, const BluetoothUuid& aUuid,
|
||||
BluetoothGattCharProp aProperties, BluetoothGattAttrPerm aPermissions,
|
||||
BluetoothGattServerResultHandler* aRes)
|
||||
{
|
||||
bt_status_t status;
|
||||
#if ANDROID_VERSION >= 19
|
||||
bt_uuid_t uuid;
|
||||
int properties;
|
||||
int permissions;
|
||||
|
||||
if (NS_SUCCEEDED(Convert(aUuid, uuid)) &&
|
||||
NS_SUCCEEDED(Convert(aProperties, properties)) &&
|
||||
NS_SUCCEEDED(Convert(aPermissions, permissions))) {
|
||||
status = mInterface->add_characteristic(aServerIf, aServiceHandle, &uuid,
|
||||
properties, permissions);
|
||||
} else {
|
||||
status = BT_STATUS_PARM_INVALID;
|
||||
}
|
||||
#else
|
||||
status = BT_STATUS_UNSUPPORTED;
|
||||
#endif
|
||||
|
||||
if (aRes) {
|
||||
DispatchBluetoothGattServerHALResult(
|
||||
aRes, &BluetoothGattServerResultHandler::AddCharacteristic,
|
||||
ConvertDefault(status, STATUS_FAIL));
|
||||
}
|
||||
}
|
||||
|
||||
void
|
||||
BluetoothGattServerHALInterface::AddDescriptor(
|
||||
int aServerIf, int aServiceHandle, const BluetoothUuid& aUuid,
|
||||
BluetoothGattAttrPerm aPermissions, BluetoothGattServerResultHandler* aRes)
|
||||
{
|
||||
bt_status_t status;
|
||||
#if ANDROID_VERSION >= 19
|
||||
bt_uuid_t uuid;
|
||||
int permissions;
|
||||
|
||||
if (NS_SUCCEEDED(Convert(aUuid, uuid)) &&
|
||||
NS_SUCCEEDED(Convert(aPermissions, permissions))) {
|
||||
status = mInterface->add_descriptor(aServerIf, aServiceHandle, &uuid,
|
||||
permissions);
|
||||
} else {
|
||||
status = BT_STATUS_PARM_INVALID;
|
||||
}
|
||||
#else
|
||||
status = BT_STATUS_UNSUPPORTED;
|
||||
#endif
|
||||
|
||||
if (aRes) {
|
||||
DispatchBluetoothGattServerHALResult(
|
||||
aRes, &BluetoothGattServerResultHandler::AddDescriptor,
|
||||
ConvertDefault(status, STATUS_FAIL));
|
||||
}
|
||||
}
|
||||
|
||||
void
|
||||
BluetoothGattServerHALInterface::StartService(
|
||||
int aServerIf, int aServiceHandle, BluetoothTransport aTransport,
|
||||
BluetoothGattServerResultHandler* aRes)
|
||||
{
|
||||
bt_status_t status;
|
||||
#if ANDROID_VERSION >= 19
|
||||
int transport;
|
||||
|
||||
if (NS_SUCCEEDED(Convert(aTransport, transport))) {
|
||||
status = mInterface->start_service(aServerIf, aServiceHandle, transport);
|
||||
} else {
|
||||
status = BT_STATUS_PARM_INVALID;
|
||||
}
|
||||
#else
|
||||
status = BT_STATUS_UNSUPPORTED;
|
||||
#endif
|
||||
|
||||
if (aRes) {
|
||||
DispatchBluetoothGattServerHALResult(
|
||||
aRes, &BluetoothGattServerResultHandler::StartService,
|
||||
ConvertDefault(status, STATUS_FAIL));
|
||||
}
|
||||
}
|
||||
|
||||
void
|
||||
BluetoothGattServerHALInterface::StopService(
|
||||
int aServerIf, int aServiceHandle, BluetoothGattServerResultHandler* aRes)
|
||||
{
|
||||
bt_status_t status;
|
||||
#if ANDROID_VERSION >= 19
|
||||
status = mInterface->stop_service(aServerIf, aServiceHandle);
|
||||
#else
|
||||
status = BT_STATUS_UNSUPPORTED;
|
||||
#endif
|
||||
|
||||
if (aRes) {
|
||||
DispatchBluetoothGattServerHALResult(
|
||||
aRes, &BluetoothGattServerResultHandler::StopService,
|
||||
ConvertDefault(status, STATUS_FAIL));
|
||||
}
|
||||
}
|
||||
|
||||
void
|
||||
BluetoothGattServerHALInterface::DeleteService(
|
||||
int aServerIf, int aServiceHandle, BluetoothGattServerResultHandler* aRes)
|
||||
{
|
||||
bt_status_t status;
|
||||
#if ANDROID_VERSION >= 19
|
||||
status = mInterface->delete_service(aServerIf, aServiceHandle);
|
||||
#else
|
||||
status = BT_STATUS_UNSUPPORTED;
|
||||
#endif
|
||||
|
||||
if (aRes) {
|
||||
DispatchBluetoothGattServerHALResult(
|
||||
aRes, &BluetoothGattServerResultHandler::DeleteService,
|
||||
ConvertDefault(status, STATUS_FAIL));
|
||||
}
|
||||
}
|
||||
|
||||
void
|
||||
BluetoothGattServerHALInterface::SendIndication(
|
||||
int aServerIf, int aAttributeHandle, int aConnId,
|
||||
const nsTArray<uint8_t>& aValue,
|
||||
bool aConfirm, /* true: indication, false: notification */
|
||||
BluetoothGattServerResultHandler* aRes)
|
||||
{
|
||||
bt_status_t status;
|
||||
#if ANDROID_VERSION >= 19
|
||||
char* value =
|
||||
reinterpret_cast<char*>(const_cast<uint8_t*>(aValue.Elements()));
|
||||
status = mInterface->send_indication(aServerIf, aAttributeHandle, aConnId,
|
||||
aValue.Length(), aConfirm, value);
|
||||
#else
|
||||
status = BT_STATUS_UNSUPPORTED;
|
||||
#endif
|
||||
|
||||
if (aRes) {
|
||||
DispatchBluetoothGattServerHALResult(
|
||||
aRes, &BluetoothGattServerResultHandler::SendIndication,
|
||||
ConvertDefault(status, STATUS_FAIL));
|
||||
}
|
||||
}
|
||||
|
||||
void
|
||||
BluetoothGattServerHALInterface::SendResponse(
|
||||
int aConnId, int aTransId, BluetoothGattStatus aStatus,
|
||||
const BluetoothGattResponse& aResponse,
|
||||
BluetoothGattServerResultHandler* aRes)
|
||||
{
|
||||
bt_status_t status;
|
||||
#if ANDROID_VERSION >= 19
|
||||
int response_status;
|
||||
btgatt_response_t response;
|
||||
if (NS_SUCCEEDED(Convert(aStatus, response_status)) &&
|
||||
NS_SUCCEEDED(Convert(aResponse, response))) {
|
||||
status = mInterface->send_response(aConnId, aTransId, response_status,
|
||||
&response);
|
||||
} else {
|
||||
status = BT_STATUS_PARM_INVALID;
|
||||
}
|
||||
#else
|
||||
status = BT_STATUS_UNSUPPORTED;
|
||||
#endif
|
||||
|
||||
if (aRes) {
|
||||
DispatchBluetoothGattServerHALResult(
|
||||
aRes, &BluetoothGattServerResultHandler::SendResponse,
|
||||
ConvertDefault(status, STATUS_FAIL));
|
||||
}
|
||||
}
|
||||
|
||||
// GATT Interface
|
||||
|
||||
@ -1179,8 +1716,15 @@ BluetoothGattHALInterface::Init(
|
||||
BluetoothGattServerCallback::ServiceDeleted,
|
||||
BluetoothGattServerCallback::RequestRead,
|
||||
BluetoothGattServerCallback::RequestWrite,
|
||||
BluetoothGattServerCallback::RequestExecWrite,
|
||||
BluetoothGattServerCallback::ResponseConfirmation
|
||||
BluetoothGattServerCallback::RequestExecuteWrite,
|
||||
BluetoothGattServerCallback::ResponseConfirmation,
|
||||
#if ANDROID_VERSION >= 21
|
||||
BluetoothGattServerCallback::IndicationSent,
|
||||
BluetoothGattServerCallback::Congestion,
|
||||
#endif // ANDROID_VERSION >= 21
|
||||
#if ANDROID_VERSION >= 22
|
||||
BluetoothGattServerCallback::MtuChanged
|
||||
#endif // ANDROID_VERSION >= 22
|
||||
};
|
||||
|
||||
static const btgatt_callbacks_t sCallbacks = {
|
||||
@ -1245,4 +1789,25 @@ BluetoothGattHALInterface::GetBluetoothGattClientInterface()
|
||||
return sBluetoothGattClientHALInterface;
|
||||
}
|
||||
|
||||
BluetoothGattServerInterface*
|
||||
BluetoothGattHALInterface::GetBluetoothGattServerInterface()
|
||||
{
|
||||
static BluetoothGattServerHALInterface* sBluetoothGattServerHALInterface;
|
||||
|
||||
if (sBluetoothGattServerHALInterface) {
|
||||
return sBluetoothGattServerHALInterface;
|
||||
}
|
||||
|
||||
#if ANDROID_VERSION >= 19
|
||||
MOZ_ASSERT(mInterface->server);
|
||||
sBluetoothGattServerHALInterface =
|
||||
new BluetoothGattServerHALInterface(mInterface->server);
|
||||
#else
|
||||
sBluetoothGattServerHALInterface =
|
||||
new BluetoothGattServerHALInterface();
|
||||
#endif
|
||||
|
||||
return sBluetoothGattServerHALInterface;
|
||||
}
|
||||
|
||||
END_BLUETOOTH_NAMESPACE
|
||||
|
@ -160,7 +160,90 @@ private:
|
||||
#endif
|
||||
};
|
||||
|
||||
// TODO: Add server interface
|
||||
class BluetoothGattServerHALInterface final
|
||||
: public BluetoothGattServerInterface
|
||||
{
|
||||
public:
|
||||
friend class BluetoothGattHALInterface;
|
||||
|
||||
/* Register / Unregister */
|
||||
void RegisterServer(const BluetoothUuid& aUuid,
|
||||
BluetoothGattServerResultHandler* aRes);
|
||||
void UnregisterServer(int aServerIf,
|
||||
BluetoothGattServerResultHandler* aRes);
|
||||
|
||||
/* Connect / Disconnect */
|
||||
void ConnectPeripheral(int aServerIf,
|
||||
const nsAString& aBdAddr,
|
||||
bool aIsDirect, /* auto connect */
|
||||
BluetoothTransport aTransport,
|
||||
BluetoothGattServerResultHandler* aRes);
|
||||
void DisconnectPeripheral(int aServerIf,
|
||||
const nsAString& aBdAddr,
|
||||
int aConnId,
|
||||
BluetoothGattServerResultHandler* aRes);
|
||||
|
||||
/* Add a services / a characteristic / a descriptor */
|
||||
void AddService(int aServerIf,
|
||||
const BluetoothGattServiceId& aServiceId,
|
||||
int aNumHandles,
|
||||
BluetoothGattServerResultHandler* aRes);
|
||||
void AddIncludedService(int aServerIf,
|
||||
int aServiceHandle,
|
||||
int aIncludedServiceHandle,
|
||||
BluetoothGattServerResultHandler* aRes);
|
||||
void AddCharacteristic(int aServerIf,
|
||||
int aServiceHandle,
|
||||
const BluetoothUuid& aUuid,
|
||||
BluetoothGattCharProp aProperties,
|
||||
BluetoothGattAttrPerm aPermissions,
|
||||
BluetoothGattServerResultHandler* aRes);
|
||||
void AddDescriptor(int aServerIf,
|
||||
int aServiceHandle,
|
||||
const BluetoothUuid& aUuid,
|
||||
BluetoothGattAttrPerm aPermissions,
|
||||
BluetoothGattServerResultHandler* aRes);
|
||||
|
||||
/* Start / Stop / Delete a service */
|
||||
void StartService(int aServerIf,
|
||||
int aServiceHandle,
|
||||
BluetoothTransport aTransport,
|
||||
BluetoothGattServerResultHandler* aRes);
|
||||
void StopService(int aServerIf,
|
||||
int aServiceHandle,
|
||||
BluetoothGattServerResultHandler* aRes);
|
||||
void DeleteService(int aServerIf,
|
||||
int aServiceHandle,
|
||||
BluetoothGattServerResultHandler* aRes);
|
||||
|
||||
/* Send an indication or a notification */
|
||||
void SendIndication(int aServerIf,
|
||||
int aAttributeHandle,
|
||||
int aConnId,
|
||||
const nsTArray<uint8_t>& aValue,
|
||||
bool aConfirm, /* true: indication, false: notification */
|
||||
BluetoothGattServerResultHandler* aRes);
|
||||
|
||||
/* Send a response for an incoming indication */
|
||||
void SendResponse(int aConnId,
|
||||
int aTransId,
|
||||
BluetoothGattStatus aStatus,
|
||||
const BluetoothGattResponse& aResponse,
|
||||
BluetoothGattServerResultHandler* aRes);
|
||||
|
||||
protected:
|
||||
BluetoothGattServerHALInterface(
|
||||
#if ANDROID_VERSION >= 19
|
||||
const btgatt_server_interface_t* aInterface
|
||||
#endif
|
||||
);
|
||||
~BluetoothGattServerHALInterface();
|
||||
|
||||
private:
|
||||
#if ANDROID_VERSION >= 19
|
||||
const btgatt_server_interface_t* mInterface;
|
||||
#endif
|
||||
};
|
||||
|
||||
class BluetoothGattHALInterface final
|
||||
: public BluetoothGattInterface
|
||||
@ -173,6 +256,7 @@ public:
|
||||
void Cleanup(BluetoothGattResultHandler* aRes);
|
||||
|
||||
BluetoothGattClientInterface* GetBluetoothGattClientInterface();
|
||||
BluetoothGattServerInterface* GetBluetoothGattServerInterface();
|
||||
|
||||
protected:
|
||||
BluetoothGattHALInterface(
|
||||
|
@ -387,6 +387,36 @@ Convert(const BluetoothGattTestParam& aIn, btgatt_test_params_t& aOut)
|
||||
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
nsresult
|
||||
Convert(const BluetoothGattResponse& aIn, btgatt_response_t& aOut)
|
||||
{
|
||||
// Only the read response format is used in bluedroid.
|
||||
nsresult rv = Convert(
|
||||
ConvertArray<uint8_t>(aIn.mValue, sizeof(aIn.mValue)),
|
||||
aOut.attr_value.value);
|
||||
if (NS_WARN_IF(NS_FAILED(rv))) {
|
||||
return rv;
|
||||
}
|
||||
rv = Convert(aIn.mHandle, aOut.attr_value.handle);
|
||||
if (NS_WARN_IF(NS_FAILED(rv))) {
|
||||
return rv;
|
||||
}
|
||||
rv = Convert(aIn.mOffset, aOut.attr_value.offset);
|
||||
if (NS_WARN_IF(NS_FAILED(rv))) {
|
||||
return rv;
|
||||
}
|
||||
rv = Convert(aIn.mLength, aOut.attr_value.len);
|
||||
if (NS_WARN_IF(NS_FAILED(rv))) {
|
||||
return rv;
|
||||
}
|
||||
rv = Convert(aIn.mAuthReq, aOut.attr_value.auth_req);
|
||||
if (NS_WARN_IF(NS_FAILED(rv))) {
|
||||
return rv;
|
||||
}
|
||||
|
||||
return NS_OK;
|
||||
}
|
||||
#endif // ANDROID_VERSION >= 19
|
||||
|
||||
#if ANDROID_VERSION >= 21
|
||||
|
@ -793,6 +793,40 @@ Convert(int aIn, BluetoothGattStatus& aOut)
|
||||
};
|
||||
if (static_cast<uint32_t>(aIn) >= MOZ_ARRAY_LENGTH(sGattStatus)) {
|
||||
aOut = GATT_STATUS_UNKNOWN_ERROR;
|
||||
return NS_ERROR_ILLEGAL_VALUE;
|
||||
} else {
|
||||
aOut = sGattStatus[aIn];
|
||||
}
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
inline nsresult
|
||||
Convert(BluetoothGattStatus aIn, int& aOut)
|
||||
{
|
||||
/* Reference: $B2G/external/bluetooth/bluedroid/stack/include/gatt_api.h */
|
||||
static const int sGattStatus[] = {
|
||||
CONVERT(GATT_STATUS_SUCCESS, 0x0000),
|
||||
CONVERT(GATT_STATUS_INVALID_HANDLE, 0x0001),
|
||||
CONVERT(GATT_STATUS_READ_NOT_PERMITTED, 0x0002),
|
||||
CONVERT(GATT_STATUS_WRITE_NOT_PERMITTED, 0x0003),
|
||||
CONVERT(GATT_STATUS_INVALID_PDU, 0x0004),
|
||||
CONVERT(GATT_STATUS_INSUFFICIENT_AUTHENTICATION, 0x0005),
|
||||
CONVERT(GATT_STATUS_REQUEST_NOT_SUPPORTED, 0x0006),
|
||||
CONVERT(GATT_STATUS_INVALID_OFFSET, 0x0007),
|
||||
CONVERT(GATT_STATUS_INSUFFICIENT_AUTHORIZATION, 0x0008),
|
||||
CONVERT(GATT_STATUS_PREPARE_QUEUE_FULL, 0x0009),
|
||||
CONVERT(GATT_STATUS_ATTRIBUTE_NOT_FOUND, 0x000a),
|
||||
CONVERT(GATT_STATUS_ATTRIBUTE_NOT_LONG, 0x000b),
|
||||
CONVERT(GATT_STATUS_INSUFFICIENT_ENCRYPTION_KEY_SIZE, 0x000c),
|
||||
CONVERT(GATT_STATUS_INVALID_ATTRIBUTE_LENGTH, 0x000d),
|
||||
CONVERT(GATT_STATUS_UNLIKELY_ERROR, 0x000e),
|
||||
CONVERT(GATT_STATUS_INSUFFICIENT_ENCRYPTION, 0x000f),
|
||||
CONVERT(GATT_STATUS_UNSUPPORTED_GROUP_TYPE, 0x0010),
|
||||
CONVERT(GATT_STATUS_INSUFFICIENT_RESOURCES, 0x0011)
|
||||
};
|
||||
if (static_cast<uint32_t>(aIn) >= MOZ_ARRAY_LENGTH(sGattStatus)) {
|
||||
aOut = -1;
|
||||
return NS_ERROR_ILLEGAL_VALUE;
|
||||
} else {
|
||||
aOut = sGattStatus[aIn];
|
||||
}
|
||||
@ -802,6 +836,30 @@ Convert(int aIn, BluetoothGattStatus& aOut)
|
||||
nsresult
|
||||
Convert(const uint8_t* aIn, BluetoothGattAdvData& aOut);
|
||||
|
||||
inline nsresult
|
||||
Convert(BluetoothGattAttrPerm aIn, int& aOut)
|
||||
{
|
||||
/* Reference: $B2G/external/bluetooth/bluedroid/stack/include/gatt_api.h */
|
||||
static const uint16_t sGattAttrPermBit[] = {
|
||||
CONVERT(0, GATT_ATTR_PERM_BIT_READ),
|
||||
CONVERT(1, GATT_ATTR_PERM_BIT_READ_ENCRYPTED),
|
||||
CONVERT(2, GATT_ATTR_PERM_BIT_READ_ENCRYPTED_MITM),
|
||||
CONVERT(3, 0),
|
||||
CONVERT(4, GATT_ATTR_PERM_BIT_WRITE),
|
||||
CONVERT(5, GATT_ATTR_PERM_BIT_WRITE_ENCRYPTED),
|
||||
CONVERT(6, GATT_ATTR_PERM_BIT_WRITE_ENCRYPTED_MITM),
|
||||
CONVERT(7, GATT_ATTR_PERM_BIT_WRITE_SIGNED),
|
||||
CONVERT(8, GATT_ATTR_PERM_BIT_WRITE_SIGNED_MITM)
|
||||
};
|
||||
aOut = 0;
|
||||
for (uint8_t i = 0; i < MOZ_ARRAY_LENGTH(sGattAttrPermBit); i++) {
|
||||
if (aIn & sGattAttrPermBit[i]) {
|
||||
aOut |= (1 << i);
|
||||
}
|
||||
}
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
inline nsresult
|
||||
Convert(int aIn, BluetoothGattCharProp& aOut)
|
||||
{
|
||||
@ -825,6 +883,29 @@ Convert(int aIn, BluetoothGattCharProp& aOut)
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
inline nsresult
|
||||
Convert(BluetoothGattCharProp aIn, int& aOut)
|
||||
{
|
||||
/* Reference: $B2G/external/bluetooth/bluedroid/stack/include/gatt_api.h */
|
||||
static const uint8_t sGattCharPropBit[] = {
|
||||
CONVERT(0, GATT_CHAR_PROP_BIT_BROADCAST),
|
||||
CONVERT(1, GATT_CHAR_PROP_BIT_READ),
|
||||
CONVERT(2, GATT_CHAR_PROP_BIT_WRITE_NO_RESPONSE),
|
||||
CONVERT(3, GATT_CHAR_PROP_BIT_WRITE),
|
||||
CONVERT(4, GATT_CHAR_PROP_BIT_NOTIFY),
|
||||
CONVERT(5, GATT_CHAR_PROP_BIT_INDICATE),
|
||||
CONVERT(6, GATT_CHAR_PROP_BIT_SIGNED_WRITE),
|
||||
CONVERT(7, GATT_CHAR_PROP_BIT_EXTENDED_PROPERTIES)
|
||||
};
|
||||
aOut = 0;
|
||||
for (uint8_t i = 0; i < MOZ_ARRAY_LENGTH(sGattCharPropBit); i++) {
|
||||
if (aIn & sGattCharPropBit[i]) {
|
||||
aOut |= (1 << i);
|
||||
}
|
||||
}
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
inline nsresult
|
||||
Convert(BluetoothGattAuthReq aIn, int& aOut)
|
||||
{
|
||||
@ -894,11 +975,6 @@ Convert(const btgatt_notify_params_t& aIn, BluetoothGattNotifyParam& aOut);
|
||||
|
||||
nsresult
|
||||
Convert(const BluetoothGattTestParam& aIn, btgatt_test_params_t& aOut);
|
||||
#endif // ANDROID_VERSION >= 19
|
||||
|
||||
#if ANDROID_VERSION >= 21
|
||||
nsresult
|
||||
Convert(const BluetoothTransport& aIn, btgatt_transport_t& aOut);
|
||||
|
||||
inline nsresult
|
||||
Convert(BluetoothTransport aIn, int& aOut)
|
||||
@ -909,12 +985,21 @@ Convert(BluetoothTransport aIn, int& aOut)
|
||||
CONVERT(TRANSPORT_LE, 2)
|
||||
};
|
||||
if (NS_WARN_IF(aIn >= MOZ_ARRAY_LENGTH(sTransport))) {
|
||||
aOut = -1;
|
||||
return NS_ERROR_ILLEGAL_VALUE;
|
||||
}
|
||||
aOut = sTransport[aIn];
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
nsresult
|
||||
Convert(const BluetoothGattResponse& aIn, btgatt_response_t& aOut);
|
||||
#endif // ANDROID_VERSION >= 19
|
||||
|
||||
#if ANDROID_VERSION >= 21
|
||||
nsresult
|
||||
Convert(const BluetoothTransport& aIn, btgatt_transport_t& aOut);
|
||||
|
||||
nsresult
|
||||
Convert(const bt_activity_energy_info& aIn, BluetoothActivityEnergyInfo& aOut);
|
||||
|
||||
@ -1620,6 +1705,373 @@ private:
|
||||
Tin5 mArg5;
|
||||
};
|
||||
|
||||
template <typename ObjectWrapper, typename Res,
|
||||
typename Tin1, typename Tin2, typename Tin3,
|
||||
typename Tin4, typename Tin5, typename Tin6,
|
||||
typename Arg1=Tin1, typename Arg2=Tin2, typename Arg3=Tin3,
|
||||
typename Arg4=Tin4, typename Arg5=Tin5, typename Arg6=Tin6>
|
||||
class BluetoothNotificationHALRunnable6 : public nsRunnable
|
||||
{
|
||||
public:
|
||||
typedef typename ObjectWrapper::ObjectType ObjectType;
|
||||
typedef BluetoothNotificationHALRunnable6<ObjectWrapper, Res,
|
||||
Tin1, Tin2, Tin3, Tin4, Tin5, Tin6,
|
||||
Arg1, Arg2, Arg3, Arg4, Arg5, Arg6> SelfType;
|
||||
|
||||
template <typename T1, typename T2, typename T3, typename T4, typename T5,
|
||||
typename T6>
|
||||
static already_AddRefed<SelfType> Create(
|
||||
Res (ObjectType::*aMethod)(Arg1, Arg2, Arg3, Arg4, Arg5, Arg6),
|
||||
const T1& aIn1, const T2& aIn2, const T3& aIn3,
|
||||
const T4& aIn4, const T5& aIn5, const T6& aIn6)
|
||||
{
|
||||
nsRefPtr<SelfType> runnable(new SelfType(aMethod));
|
||||
|
||||
if (NS_FAILED(runnable->ConvertAndSet(aIn1, aIn2, aIn3, aIn4, aIn5,
|
||||
aIn6))) {
|
||||
return nullptr;
|
||||
}
|
||||
return runnable.forget();
|
||||
}
|
||||
|
||||
template <typename T1, typename T2, typename T3, typename T4, typename T5,
|
||||
typename T6>
|
||||
static void
|
||||
Dispatch(Res (ObjectType::*aMethod)(Arg1, Arg2, Arg3, Arg4, Arg5, Arg6),
|
||||
const T1& aIn1, const T2& aIn2, const T3& aIn3,
|
||||
const T4& aIn4, const T5& aIn5, const T6& aIn6)
|
||||
{
|
||||
nsRefPtr<SelfType> runnable = Create(aMethod,
|
||||
aIn1, aIn2, aIn3, aIn4, aIn5, aIn6);
|
||||
if (!runnable) {
|
||||
BT_WARNING("BluetoothNotificationHALRunnable6::Create failed");
|
||||
return;
|
||||
}
|
||||
nsresult rv = NS_DispatchToMainThread(runnable);
|
||||
if (NS_FAILED(rv)) {
|
||||
BT_WARNING("NS_DispatchToMainThread failed: %X", rv);
|
||||
}
|
||||
}
|
||||
|
||||
NS_METHOD
|
||||
Run() override
|
||||
{
|
||||
MOZ_ASSERT(NS_IsMainThread());
|
||||
|
||||
ObjectType* obj = ObjectWrapper::GetInstance();
|
||||
|
||||
if (!obj) {
|
||||
BT_WARNING("Notification handler not initialized");
|
||||
} else {
|
||||
((*obj).*mMethod)(mArg1, mArg2, mArg3, mArg4, mArg5, mArg6);
|
||||
}
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
private:
|
||||
BluetoothNotificationHALRunnable6(
|
||||
Res (ObjectType::*aMethod)(Arg1, Arg2, Arg3, Arg4, Arg5, Arg6))
|
||||
: mMethod(aMethod)
|
||||
{
|
||||
MOZ_ASSERT(mMethod);
|
||||
}
|
||||
|
||||
template<typename T1, typename T2, typename T3, typename T4, typename T5,
|
||||
typename T6>
|
||||
nsresult
|
||||
ConvertAndSet(const T1& aIn1, const T2& aIn2, const T3& aIn3,
|
||||
const T4& aIn4, const T5& aIn5, const T6& aIn6)
|
||||
{
|
||||
nsresult rv = Convert(aIn1, mArg1);
|
||||
if (NS_FAILED(rv)) {
|
||||
return rv;
|
||||
}
|
||||
rv = Convert(aIn2, mArg2);
|
||||
if (NS_FAILED(rv)) {
|
||||
return rv;
|
||||
}
|
||||
rv = Convert(aIn3, mArg3);
|
||||
if (NS_FAILED(rv)) {
|
||||
return rv;
|
||||
}
|
||||
rv = Convert(aIn4, mArg4);
|
||||
if (NS_FAILED(rv)) {
|
||||
return rv;
|
||||
}
|
||||
rv = Convert(aIn5, mArg5);
|
||||
if (NS_FAILED(rv)) {
|
||||
return rv;
|
||||
}
|
||||
rv = Convert(aIn6, mArg6);
|
||||
if (NS_FAILED(rv)) {
|
||||
return rv;
|
||||
}
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
Res (ObjectType::*mMethod)(Arg1, Arg2, Arg3, Arg4, Arg5, Arg6);
|
||||
Tin1 mArg1;
|
||||
Tin2 mArg2;
|
||||
Tin3 mArg3;
|
||||
Tin4 mArg4;
|
||||
Tin5 mArg5;
|
||||
Tin6 mArg6;
|
||||
};
|
||||
|
||||
template <typename ObjectWrapper, typename Res,
|
||||
typename Tin1, typename Tin2, typename Tin3,
|
||||
typename Tin4, typename Tin5, typename Tin6,
|
||||
typename Tin7,
|
||||
typename Arg1=Tin1, typename Arg2=Tin2, typename Arg3=Tin3,
|
||||
typename Arg4=Tin4, typename Arg5=Tin5, typename Arg6=Tin6,
|
||||
typename Arg7=Tin7>
|
||||
class BluetoothNotificationHALRunnable7 : public nsRunnable
|
||||
{
|
||||
public:
|
||||
typedef typename ObjectWrapper::ObjectType ObjectType;
|
||||
typedef BluetoothNotificationHALRunnable7<ObjectWrapper, Res,
|
||||
Tin1, Tin2, Tin3, Tin4, Tin5, Tin6, Tin7,
|
||||
Arg1, Arg2, Arg3, Arg4, Arg5, Arg6, Arg7> SelfType;
|
||||
|
||||
template <typename T1, typename T2, typename T3, typename T4, typename T5,
|
||||
typename T6, typename T7>
|
||||
static already_AddRefed<SelfType> Create(
|
||||
Res (ObjectType::*aMethod)(Arg1, Arg2, Arg3, Arg4, Arg5, Arg6, Arg7),
|
||||
const T1& aIn1, const T2& aIn2, const T3& aIn3,
|
||||
const T4& aIn4, const T5& aIn5, const T6& aIn6,
|
||||
const T7& aIn7)
|
||||
{
|
||||
nsRefPtr<SelfType> runnable(new SelfType(aMethod));
|
||||
|
||||
if (NS_FAILED(runnable->ConvertAndSet(aIn1, aIn2, aIn3, aIn4, aIn5,
|
||||
aIn6, aIn7))) {
|
||||
return nullptr;
|
||||
}
|
||||
return runnable.forget();
|
||||
}
|
||||
|
||||
template <typename T1, typename T2, typename T3, typename T4, typename T5,
|
||||
typename T6, typename T7>
|
||||
static void
|
||||
Dispatch(Res (ObjectType::*aMethod)(Arg1, Arg2, Arg3, Arg4, Arg5, Arg6, Arg7),
|
||||
const T1& aIn1, const T2& aIn2, const T3& aIn3,
|
||||
const T4& aIn4, const T5& aIn5, const T6& aIn6,
|
||||
const T7& aIn7)
|
||||
{
|
||||
nsRefPtr<SelfType> runnable = Create(aMethod,
|
||||
aIn1, aIn2, aIn3, aIn4, aIn5, aIn6,
|
||||
aIn7);
|
||||
if (!runnable) {
|
||||
BT_WARNING("BluetoothNotificationHALRunnable7::Create failed");
|
||||
return;
|
||||
}
|
||||
nsresult rv = NS_DispatchToMainThread(runnable);
|
||||
if (NS_FAILED(rv)) {
|
||||
BT_WARNING("NS_DispatchToMainThread failed: %X", rv);
|
||||
}
|
||||
}
|
||||
|
||||
NS_METHOD
|
||||
Run() override
|
||||
{
|
||||
MOZ_ASSERT(NS_IsMainThread());
|
||||
|
||||
ObjectType* obj = ObjectWrapper::GetInstance();
|
||||
|
||||
if (!obj) {
|
||||
BT_WARNING("Notification handler not initialized");
|
||||
} else {
|
||||
((*obj).*mMethod)(mArg1, mArg2, mArg3, mArg4, mArg5, mArg6, mArg7);
|
||||
}
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
private:
|
||||
BluetoothNotificationHALRunnable7(
|
||||
Res (ObjectType::*aMethod)(Arg1, Arg2, Arg3, Arg4, Arg5, Arg6, Arg7))
|
||||
: mMethod(aMethod)
|
||||
{
|
||||
MOZ_ASSERT(mMethod);
|
||||
}
|
||||
|
||||
template<typename T1, typename T2, typename T3, typename T4, typename T5,
|
||||
typename T6, typename T7>
|
||||
nsresult
|
||||
ConvertAndSet(const T1& aIn1, const T2& aIn2, const T3& aIn3,
|
||||
const T4& aIn4, const T5& aIn5, const T6& aIn6,
|
||||
const T7& aIn7)
|
||||
{
|
||||
nsresult rv = Convert(aIn1, mArg1);
|
||||
if (NS_FAILED(rv)) {
|
||||
return rv;
|
||||
}
|
||||
rv = Convert(aIn2, mArg2);
|
||||
if (NS_FAILED(rv)) {
|
||||
return rv;
|
||||
}
|
||||
rv = Convert(aIn3, mArg3);
|
||||
if (NS_FAILED(rv)) {
|
||||
return rv;
|
||||
}
|
||||
rv = Convert(aIn4, mArg4);
|
||||
if (NS_FAILED(rv)) {
|
||||
return rv;
|
||||
}
|
||||
rv = Convert(aIn5, mArg5);
|
||||
if (NS_FAILED(rv)) {
|
||||
return rv;
|
||||
}
|
||||
rv = Convert(aIn6, mArg6);
|
||||
if (NS_FAILED(rv)) {
|
||||
return rv;
|
||||
}
|
||||
rv = Convert(aIn7, mArg7);
|
||||
if (NS_FAILED(rv)) {
|
||||
return rv;
|
||||
}
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
Res (ObjectType::*mMethod)(Arg1, Arg2, Arg3, Arg4, Arg5, Arg6, Arg7);
|
||||
Tin1 mArg1;
|
||||
Tin2 mArg2;
|
||||
Tin3 mArg3;
|
||||
Tin4 mArg4;
|
||||
Tin5 mArg5;
|
||||
Tin6 mArg6;
|
||||
Tin7 mArg7;
|
||||
};
|
||||
|
||||
template <typename ObjectWrapper, typename Res,
|
||||
typename Tin1, typename Tin2, typename Tin3,
|
||||
typename Tin4, typename Tin5, typename Tin6,
|
||||
typename Tin7, typename Tin8,
|
||||
typename Arg1=Tin1, typename Arg2=Tin2, typename Arg3=Tin3,
|
||||
typename Arg4=Tin4, typename Arg5=Tin5, typename Arg6=Tin6,
|
||||
typename Arg7=Tin7, typename Arg8=Tin8>
|
||||
class BluetoothNotificationHALRunnable8 : public nsRunnable
|
||||
{
|
||||
public:
|
||||
typedef typename ObjectWrapper::ObjectType ObjectType;
|
||||
typedef BluetoothNotificationHALRunnable8<ObjectWrapper, Res,
|
||||
Tin1, Tin2, Tin3, Tin4, Tin5, Tin6, Tin7, Tin8,
|
||||
Arg1, Arg2, Arg3, Arg4, Arg5, Arg6, Arg7, Arg8> SelfType;
|
||||
|
||||
template <typename T1, typename T2, typename T3, typename T4, typename T5,
|
||||
typename T6, typename T7, typename T8>
|
||||
static already_AddRefed<SelfType> Create(
|
||||
Res (ObjectType::*aMethod)(Arg1, Arg2, Arg3, Arg4, Arg5, Arg6, Arg7, Arg8),
|
||||
const T1& aIn1, const T2& aIn2, const T3& aIn3,
|
||||
const T4& aIn4, const T5& aIn5, const T6& aIn6,
|
||||
const T7& aIn7, const T8& aIn8)
|
||||
{
|
||||
nsRefPtr<SelfType> runnable(new SelfType(aMethod));
|
||||
|
||||
if (NS_FAILED(runnable->ConvertAndSet(aIn1, aIn2, aIn3, aIn4, aIn5,
|
||||
aIn6, aIn7, aIn8))) {
|
||||
return nullptr;
|
||||
}
|
||||
return runnable.forget();
|
||||
}
|
||||
|
||||
template <typename T1, typename T2, typename T3, typename T4, typename T5,
|
||||
typename T6, typename T7, typename T8>
|
||||
static void
|
||||
Dispatch(Res (ObjectType::*aMethod)(Arg1, Arg2, Arg3, Arg4, Arg5, Arg6, Arg7,
|
||||
Arg8),
|
||||
const T1& aIn1, const T2& aIn2, const T3& aIn3,
|
||||
const T4& aIn4, const T5& aIn5, const T6& aIn6,
|
||||
const T7& aIn7, const T8& aIn8)
|
||||
{
|
||||
nsRefPtr<SelfType> runnable = Create(aMethod,
|
||||
aIn1, aIn2, aIn3, aIn4, aIn5, aIn6,
|
||||
aIn7, aIn8);
|
||||
if (!runnable) {
|
||||
BT_WARNING("BluetoothNotificationHALRunnable8::Create failed");
|
||||
return;
|
||||
}
|
||||
nsresult rv = NS_DispatchToMainThread(runnable);
|
||||
if (NS_FAILED(rv)) {
|
||||
BT_WARNING("NS_DispatchToMainThread failed: %X", rv);
|
||||
}
|
||||
}
|
||||
|
||||
NS_METHOD
|
||||
Run() override
|
||||
{
|
||||
MOZ_ASSERT(NS_IsMainThread());
|
||||
|
||||
ObjectType* obj = ObjectWrapper::GetInstance();
|
||||
|
||||
if (!obj) {
|
||||
BT_WARNING("Notification handler not initialized");
|
||||
} else {
|
||||
((*obj).*mMethod)(mArg1, mArg2, mArg3, mArg4, mArg5, mArg6, mArg7, mArg8);
|
||||
}
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
private:
|
||||
BluetoothNotificationHALRunnable8(
|
||||
Res (ObjectType::*aMethod)(Arg1, Arg2, Arg3, Arg4, Arg5, Arg6, Arg7, Arg8))
|
||||
: mMethod(aMethod)
|
||||
{
|
||||
MOZ_ASSERT(mMethod);
|
||||
}
|
||||
|
||||
template<typename T1, typename T2, typename T3, typename T4, typename T5,
|
||||
typename T6, typename T7, typename T8>
|
||||
nsresult
|
||||
ConvertAndSet(const T1& aIn1, const T2& aIn2, const T3& aIn3,
|
||||
const T4& aIn4, const T5& aIn5, const T6& aIn6,
|
||||
const T7& aIn7, const T8& aIn8)
|
||||
{
|
||||
nsresult rv = Convert(aIn1, mArg1);
|
||||
if (NS_FAILED(rv)) {
|
||||
return rv;
|
||||
}
|
||||
rv = Convert(aIn2, mArg2);
|
||||
if (NS_FAILED(rv)) {
|
||||
return rv;
|
||||
}
|
||||
rv = Convert(aIn3, mArg3);
|
||||
if (NS_FAILED(rv)) {
|
||||
return rv;
|
||||
}
|
||||
rv = Convert(aIn4, mArg4);
|
||||
if (NS_FAILED(rv)) {
|
||||
return rv;
|
||||
}
|
||||
rv = Convert(aIn5, mArg5);
|
||||
if (NS_FAILED(rv)) {
|
||||
return rv;
|
||||
}
|
||||
rv = Convert(aIn6, mArg6);
|
||||
if (NS_FAILED(rv)) {
|
||||
return rv;
|
||||
}
|
||||
rv = Convert(aIn7, mArg7);
|
||||
if (NS_FAILED(rv)) {
|
||||
return rv;
|
||||
}
|
||||
rv = Convert(aIn8, mArg8);
|
||||
if (NS_FAILED(rv)) {
|
||||
return rv;
|
||||
}
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
Res (ObjectType::*mMethod)(Arg1, Arg2, Arg3, Arg4, Arg5, Arg6, Arg7, Arg8);
|
||||
Tin1 mArg1;
|
||||
Tin2 mArg2;
|
||||
Tin3 mArg3;
|
||||
Tin4 mArg4;
|
||||
Tin5 mArg5;
|
||||
Tin6 mArg6;
|
||||
Tin7 mArg7;
|
||||
Tin8 mArg8;
|
||||
};
|
||||
|
||||
END_BLUETOOTH_NAMESPACE
|
||||
|
||||
#endif
|
||||
|
@ -407,12 +407,8 @@ public:
|
||||
|
||||
BT_LOGR("BluetoothInterface::Disable failed: %d", aStatus);
|
||||
|
||||
#ifndef MOZ_B2G_BT_API_V1
|
||||
BluetoothService::AcknowledgeToggleBt(true);
|
||||
#else
|
||||
// Always make progress; even on failures
|
||||
BluetoothService::AcknowledgeToggleBt(false);
|
||||
#endif
|
||||
}
|
||||
};
|
||||
|
||||
@ -1813,6 +1809,13 @@ BluetoothServiceBluedroid::AdapterStateChangedNotification(bool aState)
|
||||
|
||||
BT_LOGR("BT_STATE: %d", aState);
|
||||
|
||||
if (sIsRestart && aState) {
|
||||
// daemon restarted, reset flag
|
||||
BT_LOGR("daemon restarted, reset flag");
|
||||
sIsRestart = false;
|
||||
sIsFirstTimeToggleOffBt = false;
|
||||
}
|
||||
|
||||
sAdapterEnabled = aState;
|
||||
|
||||
if (!sAdapterEnabled) {
|
||||
@ -1892,6 +1895,13 @@ BluetoothServiceBluedroid::AdapterStateChangedNotification(bool aState)
|
||||
DispatchReplySuccess(sChangeAdapterStateRunnableArray[0]);
|
||||
sChangeAdapterStateRunnableArray.RemoveElementAt(0);
|
||||
}
|
||||
|
||||
// After ProfileManagers deinit and cleanup, now restarts bluetooth daemon
|
||||
if (sIsRestart && !aState) {
|
||||
BT_LOGR("sIsRestart and off, now restart");
|
||||
StartBluetooth(false, nullptr);
|
||||
}
|
||||
|
||||
#else
|
||||
MOZ_ASSERT(NS_IsMainThread());
|
||||
|
||||
|
@ -204,7 +204,7 @@ IsAndroidAvailable()
|
||||
return false;
|
||||
#else
|
||||
// We need android.media.MediaCodec which exists in API level 16 and higher.
|
||||
return AndroidBridge::Bridge()->GetAPIVersion() >= 16;
|
||||
return AndroidBridge::Bridge() && (AndroidBridge::Bridge()->GetAPIVersion() >= 16);
|
||||
#endif
|
||||
}
|
||||
|
||||
|
@ -819,7 +819,9 @@ void NetworkUtils::postTetherInterfaceList(CommandChain* aChain,
|
||||
|
||||
char buf[BUF_SIZE];
|
||||
NS_ConvertUTF16toUTF8 reason(aResult.mResultReason);
|
||||
memcpy(buf, reason.get(), reason.Length() + 1);
|
||||
|
||||
size_t length = reason.Length() + 1 < BUF_SIZE ? reason.Length() + 1 : BUF_SIZE;
|
||||
memcpy(buf, reason.get(), length);
|
||||
split(buf, INTERFACE_DELIMIT, GET_FIELD(mInterfaceList));
|
||||
|
||||
doCommand(command, aChain, aCallback);
|
||||
|
@ -415,7 +415,7 @@ gfxAndroidPlatform::UseAcceleratedSkiaCanvas()
|
||||
bool gfxAndroidPlatform::HaveChoiceOfHWAndSWCanvas()
|
||||
{
|
||||
#ifdef MOZ_WIDGET_ANDROID
|
||||
if (AndroidBridge::Bridge()->GetAPIVersion() < 11) {
|
||||
if (!AndroidBridge::Bridge() || AndroidBridge::Bridge()->GetAPIVersion() < 11) {
|
||||
// It's slower than software due to not having a compositing fast path
|
||||
return false;
|
||||
}
|
||||
|
@ -375,17 +375,16 @@ ProcLoaderLoadRunner::ShuffleFds()
|
||||
|
||||
MOZ_ASSERT(mFdsRemap.Length() <= kReservedFileDescriptors);
|
||||
|
||||
InjectiveMultimap fd_shuffle1, fd_shuffle2;
|
||||
fd_shuffle1.reserve(mFdsRemap.Length());
|
||||
fd_shuffle2.reserve(mFdsRemap.Length());
|
||||
InjectiveMultimap fd_shuffle;
|
||||
fd_shuffle.reserve(mFdsRemap.Length());
|
||||
|
||||
for (i = 0; i < mFdsRemap.Length(); i++) {
|
||||
const FDRemap *map = &mFdsRemap[i];
|
||||
int fd = map->fd().PlatformHandle();
|
||||
int tofd = map->mapto();
|
||||
|
||||
fd_shuffle1.push_back(InjectionArc(fd, tofd, false));
|
||||
fd_shuffle2.push_back(InjectionArc(fd, tofd, false));
|
||||
// The FD that is dup2()'d from needs to be closed after shuffling.
|
||||
fd_shuffle.push_back(InjectionArc(fd, tofd, /*in_close=*/true));
|
||||
|
||||
// Erase from sReservedFds we will use.
|
||||
for (int* toErase = sReservedFds->begin();
|
||||
@ -398,7 +397,7 @@ ProcLoaderLoadRunner::ShuffleFds()
|
||||
}
|
||||
}
|
||||
|
||||
DebugOnly<bool> ok = ShuffleFileDescriptors(&fd_shuffle1);
|
||||
DebugOnly<bool> ok = ShuffleFileDescriptors(&fd_shuffle);
|
||||
|
||||
// Close the FDs that are reserved but not used after
|
||||
// ShuffleFileDescriptors().
|
||||
|
@ -218,7 +218,8 @@ public:
|
||||
|
||||
virtual void PostDelayedTask(Task* aTask, int aDelayMs) override
|
||||
{
|
||||
MessageLoop::current()->PostDelayedTask(FROM_HERE, aTask, aDelayMs);
|
||||
(MessageLoop::current() ? MessageLoop::current() : mUILoop)->
|
||||
PostDelayedTask(FROM_HERE, aTask, aDelayMs);
|
||||
}
|
||||
|
||||
virtual bool GetTouchSensitiveRegion(CSSRect* aOutRegion) override
|
||||
|
Loading…
x
Reference in New Issue
Block a user