mirror of
https://gitlab.winehq.org/wine/wine-gecko.git
synced 2024-09-13 09:24:08 -07:00
Merge b2g-inbound to m-c a=merge
This commit is contained in:
commit
5849565515
@ -15,7 +15,7 @@
|
||||
<project name="platform_build" path="build" remote="b2g" revision="3ab0d9c70f0b2e1ededc679112c392303f037361">
|
||||
<copyfile dest="Makefile" src="core/root.mk"/>
|
||||
</project>
|
||||
<project name="gaia" path="gaia" remote="mozillaorg" revision="1abe09b4925547699dfdb2d358aed019137c3aa6"/>
|
||||
<project name="gaia" path="gaia" remote="mozillaorg" revision="d695e7cdcd162e779e15594054931c84dec34a95"/>
|
||||
<project name="fake-libdvm" path="dalvik" remote="b2g" revision="d50ae982b19f42f0b66d08b9eb306be81687869f"/>
|
||||
<project name="gonk-misc" path="gonk-misc" remote="b2g" revision="45c54a55e31758f7e54e5eafe0d01d387f35897a"/>
|
||||
<project name="librecovery" path="librecovery" remote="b2g" revision="891e5069c0ad330d8191bf8c7b879c814258c89f"/>
|
||||
@ -111,7 +111,7 @@
|
||||
<project name="platform/libcore" path="libcore" revision="e195beab082c09217318fc19250caeaf4c1bd800"/>
|
||||
<project name="platform/libnativehelper" path="libnativehelper" revision="feeb36c2bd4adfe285f98f5de92e0f3771b2c115"/>
|
||||
<project name="platform/ndk" path="ndk" revision="e58ef003be4306bb53a8c11331146f39e4eab31f"/>
|
||||
<project name="platform/prebuilts/misc" path="prebuilts/misc" revision="ee724654c72825f8d732ba45caf75ca59e06975d"/>
|
||||
<project name="platform_prebuilts_misc" path="prebuilts/misc" remote="b2g" revision="0e7c060db684b409616fe67ea433ef19f5634c60"/>
|
||||
<project name="platform/prebuilts/ndk" path="prebuilts/ndk" revision="c792f0bd9fff7aea2887c60bbb3a9bbdb534ffa3"/>
|
||||
<project name="platform_prebuilts_qemu-kernel" path="prebuilts/qemu-kernel" remote="b2g" revision="c24c8871173bf6aedcf236cab075edf092a7015c"/>
|
||||
<project name="platform/prebuilts/sdk" path="prebuilts/sdk" revision="cfcef469537869947abb9aa1d656774cc2678d4c"/>
|
||||
|
@ -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="1abe09b4925547699dfdb2d358aed019137c3aa6"/>
|
||||
<project name="gaia.git" path="gaia" remote="mozillaorg" revision="d695e7cdcd162e779e15594054931c84dec34a95"/>
|
||||
<project name="gonk-misc" path="gonk-misc" remote="b2g" revision="45c54a55e31758f7e54e5eafe0d01d387f35897a"/>
|
||||
<project name="rilproxy" path="rilproxy" remote="b2g" revision="827214fcf38d6569aeb5c6d6f31cb296d1f09272"/>
|
||||
<project name="platform_hardware_ril" path="hardware/ril" remote="b2g" revision="d5d3f93914558b6f168447b805cd799c8233e300"/>
|
||||
|
@ -17,7 +17,7 @@
|
||||
</project>
|
||||
<project name="rilproxy" path="rilproxy" remote="b2g" revision="827214fcf38d6569aeb5c6d6f31cb296d1f09272"/>
|
||||
<project name="fake-libdvm" path="dalvik" remote="b2g" revision="d50ae982b19f42f0b66d08b9eb306be81687869f"/>
|
||||
<project name="gaia" path="gaia" remote="mozillaorg" revision="1abe09b4925547699dfdb2d358aed019137c3aa6"/>
|
||||
<project name="gaia" path="gaia" remote="mozillaorg" revision="d695e7cdcd162e779e15594054931c84dec34a95"/>
|
||||
<project name="gonk-misc" path="gonk-misc" remote="b2g" revision="45c54a55e31758f7e54e5eafe0d01d387f35897a"/>
|
||||
<project name="moztt" path="external/moztt" remote="b2g" revision="fe893bb760a3bb64375f62fdf4762a58c59df9ef"/>
|
||||
<project name="apitrace" path="external/apitrace" remote="apitrace" revision="6a8f8bd05043e7b8f8e26ad390c82021b995ee4d"/>
|
||||
|
@ -15,7 +15,7 @@
|
||||
<project name="platform_build" path="build" remote="b2g" revision="3ab0d9c70f0b2e1ededc679112c392303f037361">
|
||||
<copyfile dest="Makefile" src="core/root.mk"/>
|
||||
</project>
|
||||
<project name="gaia" path="gaia" remote="mozillaorg" revision="1abe09b4925547699dfdb2d358aed019137c3aa6"/>
|
||||
<project name="gaia" path="gaia" remote="mozillaorg" revision="d695e7cdcd162e779e15594054931c84dec34a95"/>
|
||||
<project name="fake-libdvm" path="dalvik" remote="b2g" revision="d50ae982b19f42f0b66d08b9eb306be81687869f"/>
|
||||
<project name="gonk-misc" path="gonk-misc" remote="b2g" revision="45c54a55e31758f7e54e5eafe0d01d387f35897a"/>
|
||||
<project name="librecovery" path="librecovery" remote="b2g" revision="891e5069c0ad330d8191bf8c7b879c814258c89f"/>
|
||||
@ -111,7 +111,7 @@
|
||||
<project name="platform/libcore" path="libcore" revision="9877ade9617bb0db6e59aa2a54719a9bc92600f3"/>
|
||||
<project name="platform/libnativehelper" path="libnativehelper" revision="46c96ace65eb1ccab05bf15b9bf8e53e443039af"/>
|
||||
<project name="platform/ndk" path="ndk" revision="cb5519af32ae7b4a9c334913a612462ecd04c5d0"/>
|
||||
<project name="platform/prebuilts/misc" path="prebuilts/misc" revision="99c9a644e84a1b0e0a5d240406753b6bc4caca54"/>
|
||||
<project name="platform_prebuilts_misc" path="prebuilts/misc" remote="b2g" revision="0e7c060db684b409616fe67ea433ef19f5634c60"/>
|
||||
<project name="platform/prebuilts/ndk" path="prebuilts/ndk" revision="6aa61f8557a22039a30b42b7f283996381fd625d"/>
|
||||
<project name="platform_prebuilts_qemu-kernel" path="prebuilts/qemu-kernel" remote="b2g" revision="c24c8871173bf6aedcf236cab075edf092a7015c"/>
|
||||
<project name="platform/prebuilts/sdk" path="prebuilts/sdk" revision="b562b01c93de9578d5db537b6a602a38e1aaa0ce"/>
|
||||
|
@ -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="1abe09b4925547699dfdb2d358aed019137c3aa6"/>
|
||||
<project name="gaia.git" path="gaia" remote="mozillaorg" revision="d695e7cdcd162e779e15594054931c84dec34a95"/>
|
||||
<project name="gonk-misc" path="gonk-misc" remote="b2g" revision="45c54a55e31758f7e54e5eafe0d01d387f35897a"/>
|
||||
<project name="rilproxy" path="rilproxy" remote="b2g" revision="827214fcf38d6569aeb5c6d6f31cb296d1f09272"/>
|
||||
<project name="platform_hardware_ril" path="hardware/ril" remote="b2g" revision="d5d3f93914558b6f168447b805cd799c8233e300"/>
|
||||
|
@ -15,7 +15,7 @@
|
||||
<project name="platform_build" path="build" remote="b2g" revision="3ab0d9c70f0b2e1ededc679112c392303f037361">
|
||||
<copyfile dest="Makefile" src="core/root.mk"/>
|
||||
</project>
|
||||
<project name="gaia" path="gaia" remote="mozillaorg" revision="1abe09b4925547699dfdb2d358aed019137c3aa6"/>
|
||||
<project name="gaia" path="gaia" remote="mozillaorg" revision="d695e7cdcd162e779e15594054931c84dec34a95"/>
|
||||
<project name="fake-libdvm" path="dalvik" remote="b2g" revision="d50ae982b19f42f0b66d08b9eb306be81687869f"/>
|
||||
<project name="gonk-misc" path="gonk-misc" remote="b2g" revision="45c54a55e31758f7e54e5eafe0d01d387f35897a"/>
|
||||
<project name="librecovery" path="librecovery" remote="b2g" revision="891e5069c0ad330d8191bf8c7b879c814258c89f"/>
|
||||
@ -111,7 +111,7 @@
|
||||
<project name="platform/libcore" path="libcore" revision="baf7d8068dd501cfa338d3a8b1b87216d6ce0571"/>
|
||||
<project name="platform/libnativehelper" path="libnativehelper" revision="50c4430e32849530ced32680fd6ee98963b3f7ac"/>
|
||||
<project name="platform/ndk" path="ndk" revision="e58ef003be4306bb53a8c11331146f39e4eab31f"/>
|
||||
<project name="platform/prebuilts/misc" path="prebuilts/misc" revision="a094aa8f160e211fb4994fdfaaac8a78aa6cc897"/>
|
||||
<project name="platform_prebuilts_misc" path="prebuilts/misc" remote="b2g" revision="0e7c060db684b409616fe67ea433ef19f5634c60"/>
|
||||
<project name="platform/prebuilts/ndk" path="prebuilts/ndk" revision="c792f0bd9fff7aea2887c60bbb3a9bbdb534ffa3"/>
|
||||
<project name="platform_prebuilts_qemu-kernel" path="prebuilts/qemu-kernel" remote="b2g" revision="c24c8871173bf6aedcf236cab075edf092a7015c"/>
|
||||
<project name="platform/prebuilts/sdk" path="prebuilts/sdk" revision="69d524e80cdf3981006627c65ac85f3a871238a3"/>
|
||||
|
@ -17,7 +17,7 @@
|
||||
</project>
|
||||
<project name="librecovery" path="librecovery" remote="b2g" revision="891e5069c0ad330d8191bf8c7b879c814258c89f"/>
|
||||
<project name="fake-libdvm" path="dalvik" remote="b2g" revision="d50ae982b19f42f0b66d08b9eb306be81687869f"/>
|
||||
<project name="gaia" path="gaia" remote="mozillaorg" revision="1abe09b4925547699dfdb2d358aed019137c3aa6"/>
|
||||
<project name="gaia" path="gaia" remote="mozillaorg" revision="d695e7cdcd162e779e15594054931c84dec34a95"/>
|
||||
<project name="gonk-misc" path="gonk-misc" remote="b2g" revision="45c54a55e31758f7e54e5eafe0d01d387f35897a"/>
|
||||
<project name="moztt" path="external/moztt" remote="b2g" revision="fe893bb760a3bb64375f62fdf4762a58c59df9ef"/>
|
||||
<project name="apitrace" path="external/apitrace" remote="apitrace" revision="6a8f8bd05043e7b8f8e26ad390c82021b995ee4d"/>
|
||||
|
@ -4,6 +4,6 @@
|
||||
"remote": "",
|
||||
"branch": ""
|
||||
},
|
||||
"revision": "936d69a5e13f39fcf9cc99bceb50c8c0de6aa0fa",
|
||||
"revision": "830d094e31350d07d6354deafbd58a19b2ac0236",
|
||||
"repo_path": "integration/gaia-central"
|
||||
}
|
||||
|
@ -17,7 +17,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="1abe09b4925547699dfdb2d358aed019137c3aa6"/>
|
||||
<project name="gaia.git" path="gaia" remote="mozillaorg" revision="d695e7cdcd162e779e15594054931c84dec34a95"/>
|
||||
<project name="gonk-misc" path="gonk-misc" remote="b2g" revision="45c54a55e31758f7e54e5eafe0d01d387f35897a"/>
|
||||
<project name="librecovery" path="librecovery" remote="b2g" revision="891e5069c0ad330d8191bf8c7b879c814258c89f"/>
|
||||
<project name="moztt" path="external/moztt" remote="b2g" revision="fe893bb760a3bb64375f62fdf4762a58c59df9ef"/>
|
||||
|
@ -15,7 +15,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="1abe09b4925547699dfdb2d358aed019137c3aa6"/>
|
||||
<project name="gaia.git" path="gaia" remote="mozillaorg" revision="d695e7cdcd162e779e15594054931c84dec34a95"/>
|
||||
<project name="gonk-misc" path="gonk-misc" remote="b2g" revision="45c54a55e31758f7e54e5eafe0d01d387f35897a"/>
|
||||
<project name="rilproxy" path="rilproxy" remote="b2g" revision="827214fcf38d6569aeb5c6d6f31cb296d1f09272"/>
|
||||
<project name="librecovery" path="librecovery" remote="b2g" revision="891e5069c0ad330d8191bf8c7b879c814258c89f"/>
|
||||
|
@ -17,7 +17,7 @@
|
||||
</project>
|
||||
<project name="rilproxy" path="rilproxy" remote="b2g" revision="827214fcf38d6569aeb5c6d6f31cb296d1f09272"/>
|
||||
<project name="fake-libdvm" path="dalvik" remote="b2g" revision="d50ae982b19f42f0b66d08b9eb306be81687869f"/>
|
||||
<project name="gaia" path="gaia" remote="mozillaorg" revision="1abe09b4925547699dfdb2d358aed019137c3aa6"/>
|
||||
<project name="gaia" path="gaia" remote="mozillaorg" revision="d695e7cdcd162e779e15594054931c84dec34a95"/>
|
||||
<project name="gonk-misc" path="gonk-misc" remote="b2g" revision="45c54a55e31758f7e54e5eafe0d01d387f35897a"/>
|
||||
<project name="moztt" path="external/moztt" remote="b2g" revision="fe893bb760a3bb64375f62fdf4762a58c59df9ef"/>
|
||||
<project name="apitrace" path="external/apitrace" remote="apitrace" revision="6a8f8bd05043e7b8f8e26ad390c82021b995ee4d"/>
|
||||
|
@ -17,7 +17,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="1abe09b4925547699dfdb2d358aed019137c3aa6"/>
|
||||
<project name="gaia.git" path="gaia" remote="mozillaorg" revision="d695e7cdcd162e779e15594054931c84dec34a95"/>
|
||||
<project name="gonk-misc" path="gonk-misc" remote="b2g" revision="45c54a55e31758f7e54e5eafe0d01d387f35897a"/>
|
||||
<project name="rilproxy" path="rilproxy" remote="b2g" revision="827214fcf38d6569aeb5c6d6f31cb296d1f09272"/>
|
||||
<project name="librecovery" path="librecovery" remote="b2g" revision="891e5069c0ad330d8191bf8c7b879c814258c89f"/>
|
||||
|
@ -146,41 +146,7 @@ BluetoothService::ToggleBtAck::ToggleBtAck(bool aEnabled)
|
||||
NS_METHOD
|
||||
BluetoothService::ToggleBtAck::Run()
|
||||
{
|
||||
MOZ_ASSERT(NS_IsMainThread());
|
||||
|
||||
// This is requested in Bug 836516. With settings this property, WLAN
|
||||
// firmware could be aware of Bluetooth has been turned on/off, so that the
|
||||
// mecahnism of handling coexistence of WIFI and Bluetooth could be started.
|
||||
//
|
||||
// In the future, we may have our own way instead of setting a system
|
||||
// property to let firmware developers be able to sense that Bluetooth has
|
||||
// been toggled.
|
||||
#if defined(MOZ_WIDGET_GONK)
|
||||
if (property_set(PROP_BLUETOOTH_ENABLED, mEnabled ? "true" : "false") != 0) {
|
||||
BT_WARNING("Failed to set bluetooth enabled property");
|
||||
}
|
||||
#endif
|
||||
|
||||
NS_ENSURE_TRUE(sBluetoothService, NS_OK);
|
||||
|
||||
if (sInShutdown) {
|
||||
sBluetoothService = nullptr;
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
// Update mEnabled of BluetoothService object since
|
||||
// StartInternal/StopInternal have been already done.
|
||||
sBluetoothService->SetEnabled(mEnabled);
|
||||
sToggleInProgress = false;
|
||||
|
||||
nsAutoString signalName;
|
||||
signalName = mEnabled ? NS_LITERAL_STRING("Enabled")
|
||||
: NS_LITERAL_STRING("Disabled");
|
||||
BluetoothSignal signal(signalName, NS_LITERAL_STRING(KEY_MANAGER), true);
|
||||
sBluetoothService->DistributeSignal(signal);
|
||||
|
||||
// Event 'AdapterAdded' has to be fired after firing 'Enabled'
|
||||
sBluetoothService->TryFiringAdapterAdded();
|
||||
BluetoothService::AcknowledgeToggleBt(mEnabled);
|
||||
|
||||
return NS_OK;
|
||||
}
|
||||
@ -803,3 +769,53 @@ BluetoothService::Notify(const BluetoothSignal& aData)
|
||||
systemMessenger->BroadcastMessage(type, value,
|
||||
JS::UndefinedHandleValue);
|
||||
}
|
||||
|
||||
void
|
||||
BluetoothService::AcknowledgeToggleBt(bool aEnabled)
|
||||
{
|
||||
MOZ_ASSERT(NS_IsMainThread());
|
||||
|
||||
#if defined(MOZ_WIDGET_GONK)
|
||||
// This is requested in Bug 836516. With settings this property, WLAN
|
||||
// firmware could be aware of Bluetooth has been turned on/off, so that
|
||||
// the mechanism of handling coexistence of WIFI and Bluetooth could be
|
||||
// started.
|
||||
//
|
||||
// In the future, we may have our own way instead of setting a system
|
||||
// property to let firmware developers be able to sense that Bluetooth
|
||||
// has been toggled.
|
||||
if (property_set(PROP_BLUETOOTH_ENABLED, aEnabled ? "true" : "false") != 0) {
|
||||
BT_WARNING("Failed to set bluetooth enabled property");
|
||||
}
|
||||
#endif
|
||||
|
||||
if (sInShutdown) {
|
||||
sBluetoothService = nullptr;
|
||||
return;
|
||||
}
|
||||
|
||||
NS_ENSURE_TRUE_VOID(sBluetoothService);
|
||||
|
||||
sBluetoothService->CompleteToggleBt(aEnabled);
|
||||
}
|
||||
|
||||
void
|
||||
BluetoothService::CompleteToggleBt(bool aEnabled)
|
||||
{
|
||||
MOZ_ASSERT(NS_IsMainThread());
|
||||
|
||||
// Update |mEnabled| of |BluetoothService| object since
|
||||
// |StartInternal| and |StopInternal| have been already
|
||||
// done.
|
||||
SetEnabled(aEnabled);
|
||||
sToggleInProgress = false;
|
||||
|
||||
nsAutoString signalName;
|
||||
signalName = aEnabled ? NS_LITERAL_STRING("Enabled")
|
||||
: NS_LITERAL_STRING("Disabled");
|
||||
BluetoothSignal signal(signalName, NS_LITERAL_STRING(KEY_MANAGER), true);
|
||||
DistributeSignal(signal);
|
||||
|
||||
// Event 'AdapterAdded' has to be fired after firing 'Enabled'
|
||||
TryFiringAdapterAdded();
|
||||
}
|
||||
|
@ -313,6 +313,8 @@ public:
|
||||
bool
|
||||
IsToggling() const;
|
||||
|
||||
static void AcknowledgeToggleBt(bool aEnabled);
|
||||
|
||||
/**
|
||||
* Below 2 function/variable are used for ensuring event 'AdapterAdded' will
|
||||
* be fired after event 'Enabled'.
|
||||
@ -393,6 +395,8 @@ protected:
|
||||
static BluetoothService*
|
||||
Create();
|
||||
|
||||
void CompleteToggleBt(bool aEnabled);
|
||||
|
||||
typedef nsClassHashtable<nsStringHashKey, BluetoothSignalObserverList >
|
||||
BluetoothSignalObserverTable;
|
||||
|
||||
|
@ -63,127 +63,11 @@ static nsTArray<nsRefPtr<BluetoothReplyRunnable> > sUnbondingRunnableArray;
|
||||
static bool sAdapterDiscoverable(false);
|
||||
static uint32_t sAdapterDiscoverableTimeout(0);
|
||||
|
||||
/**
|
||||
* Classes only used in this file
|
||||
*/
|
||||
|
||||
class SetupAfterEnabledTask MOZ_FINAL : public nsRunnable
|
||||
{
|
||||
public:
|
||||
class SetAdapterPropertyResultHandler MOZ_FINAL
|
||||
: public BluetoothResultHandler
|
||||
{
|
||||
public:
|
||||
void OnError(BluetoothStatus aStatus) MOZ_OVERRIDE
|
||||
{
|
||||
BT_LOGR("Fail to set: BT_SCAN_MODE_CONNECTABLE");
|
||||
}
|
||||
};
|
||||
|
||||
NS_IMETHOD
|
||||
Run()
|
||||
{
|
||||
MOZ_ASSERT(NS_IsMainThread());
|
||||
|
||||
// Bluetooth just enabled, clear profile controllers and runnable arrays.
|
||||
sControllerArray.Clear();
|
||||
sBondingRunnableArray.Clear();
|
||||
sGetDeviceRunnableArray.Clear();
|
||||
sSetPropertyRunnableArray.Clear();
|
||||
sUnbondingRunnableArray.Clear();
|
||||
|
||||
// Bluetooth scan mode is SCAN_MODE_CONNECTABLE by default, i.e., It should
|
||||
// be connectable and non-discoverable.
|
||||
NS_ENSURE_TRUE(sBtInterface, NS_ERROR_FAILURE);
|
||||
sBtInterface->SetAdapterProperty(
|
||||
BluetoothNamedValue(NS_ConvertUTF8toUTF16("Discoverable"), false),
|
||||
new SetAdapterPropertyResultHandler());
|
||||
|
||||
// Try to fire event 'AdapterAdded' to fit the original behaviour when
|
||||
// we used BlueZ as backend.
|
||||
BluetoothService* bs = BluetoothService::Get();
|
||||
NS_ENSURE_TRUE(bs, NS_ERROR_FAILURE);
|
||||
|
||||
bs->AdapterAddedReceived();
|
||||
bs->TryFiringAdapterAdded();
|
||||
|
||||
// Trigger BluetoothOppManager to listen
|
||||
BluetoothOppManager* opp = BluetoothOppManager::Get();
|
||||
if (!opp || !opp->Listen()) {
|
||||
BT_LOGR("Fail to start BluetoothOppManager listening");
|
||||
}
|
||||
|
||||
return NS_OK;
|
||||
}
|
||||
};
|
||||
|
||||
/* |ProfileDeinitResultHandler| collect the results of all profile
|
||||
* result handlers and calls |Proceed| after all results handlers
|
||||
* have been run.
|
||||
*/
|
||||
class ProfileDeinitResultHandler MOZ_FINAL
|
||||
: public BluetoothProfileResultHandler
|
||||
{
|
||||
public:
|
||||
ProfileDeinitResultHandler(unsigned char aNumProfiles)
|
||||
: mNumProfiles(aNumProfiles)
|
||||
{
|
||||
MOZ_ASSERT(mNumProfiles);
|
||||
}
|
||||
|
||||
void Deinit() MOZ_OVERRIDE
|
||||
{
|
||||
if (!(--mNumProfiles)) {
|
||||
Proceed();
|
||||
}
|
||||
}
|
||||
|
||||
void OnError(nsresult aResult) MOZ_OVERRIDE
|
||||
{
|
||||
if (!(--mNumProfiles)) {
|
||||
Proceed();
|
||||
}
|
||||
}
|
||||
|
||||
private:
|
||||
void Proceed() const
|
||||
{
|
||||
sBtInterface->Cleanup(nullptr);
|
||||
}
|
||||
|
||||
unsigned char mNumProfiles;
|
||||
};
|
||||
|
||||
class CleanupTask MOZ_FINAL : public nsRunnable
|
||||
{
|
||||
public:
|
||||
NS_IMETHOD
|
||||
Run()
|
||||
{
|
||||
static void (* const sDeinitManager[])(BluetoothProfileResultHandler*) = {
|
||||
BluetoothHfpManager::DeinitHfpInterface,
|
||||
BluetoothA2dpManager::DeinitA2dpInterface
|
||||
};
|
||||
|
||||
MOZ_ASSERT(NS_IsMainThread());
|
||||
|
||||
// Cleanup bluetooth interfaces after BT state becomes BT_STATE_OFF.
|
||||
nsRefPtr<ProfileDeinitResultHandler> res =
|
||||
new ProfileDeinitResultHandler(MOZ_ARRAY_LENGTH(sDeinitManager));
|
||||
|
||||
for (size_t i = 0; i < MOZ_ARRAY_LENGTH(sDeinitManager); ++i) {
|
||||
sDeinitManager[i](res);
|
||||
}
|
||||
|
||||
return NS_OK;
|
||||
}
|
||||
};
|
||||
|
||||
/**
|
||||
* Static callback functions
|
||||
*/
|
||||
static void
|
||||
ClassToIcon(uint32_t aClass, nsAString& aRetIcon)
|
||||
void
|
||||
BluetoothServiceBluedroid::ClassToIcon(uint32_t aClass, nsAString& aRetIcon)
|
||||
{
|
||||
switch ((aClass & 0x1f00) >> 8) {
|
||||
case 0x01:
|
||||
@ -273,8 +157,9 @@ ClassToIcon(uint32_t aClass, nsAString& aRetIcon)
|
||||
}
|
||||
}
|
||||
|
||||
static ControlPlayStatus
|
||||
PlayStatusStringToControlPlayStatus(const nsAString& aPlayStatus)
|
||||
ControlPlayStatus
|
||||
BluetoothServiceBluedroid::PlayStatusStringToControlPlayStatus(
|
||||
const nsAString& aPlayStatus)
|
||||
{
|
||||
ControlPlayStatus playStatus = ControlPlayStatus::PLAYSTATUS_UNKNOWN;
|
||||
if (aPlayStatus.EqualsLiteral("STOPPED")) {
|
||||
@ -297,8 +182,8 @@ PlayStatusStringToControlPlayStatus(const nsAString& aPlayStatus)
|
||||
/**
|
||||
* Static functions
|
||||
*/
|
||||
static bool
|
||||
EnsureBluetoothHalLoad()
|
||||
bool
|
||||
BluetoothServiceBluedroid::EnsureBluetoothHalLoad()
|
||||
{
|
||||
sBtInterface = BluetoothInterface::GetInstance();
|
||||
NS_ENSURE_TRUE(sBtInterface, false);
|
||||
@ -306,7 +191,8 @@ EnsureBluetoothHalLoad()
|
||||
return true;
|
||||
}
|
||||
|
||||
class EnableResultHandler MOZ_FINAL : public BluetoothResultHandler
|
||||
class BluetoothServiceBluedroid::EnableResultHandler MOZ_FINAL
|
||||
: public BluetoothResultHandler
|
||||
{
|
||||
public:
|
||||
void OnError(BluetoothStatus aStatus) MOZ_OVERRIDE
|
||||
@ -315,10 +201,7 @@ public:
|
||||
|
||||
BT_LOGR("BluetoothInterface::Enable failed: %d", aStatus);
|
||||
|
||||
nsRefPtr<nsRunnable> runnable = new BluetoothService::ToggleBtAck(false);
|
||||
if (NS_FAILED(NS_DispatchToMainThread(runnable))) {
|
||||
BT_WARNING("Failed to dispatch to main thread!");
|
||||
}
|
||||
BluetoothService::AcknowledgeToggleBt(false);
|
||||
}
|
||||
};
|
||||
|
||||
@ -326,7 +209,7 @@ public:
|
||||
* result handlers and calls |Proceed| after all results handlers
|
||||
* have been run.
|
||||
*/
|
||||
class ProfileInitResultHandler MOZ_FINAL
|
||||
class BluetoothServiceBluedroid::ProfileInitResultHandler MOZ_FINAL
|
||||
: public BluetoothProfileResultHandler
|
||||
{
|
||||
public:
|
||||
@ -359,7 +242,8 @@ private:
|
||||
unsigned char mNumProfiles;
|
||||
};
|
||||
|
||||
class InitResultHandler MOZ_FINAL : public BluetoothResultHandler
|
||||
class BluetoothServiceBluedroid::InitResultHandler MOZ_FINAL
|
||||
: public BluetoothResultHandler
|
||||
{
|
||||
public:
|
||||
void Init() MOZ_OVERRIDE
|
||||
@ -390,15 +274,12 @@ public:
|
||||
|
||||
sBtInterface = nullptr;
|
||||
|
||||
nsRefPtr<nsRunnable> runnable = new BluetoothService::ToggleBtAck(false);
|
||||
if (NS_FAILED(NS_DispatchToMainThread(runnable))) {
|
||||
BT_WARNING("Failed to dispatch to main thread!");
|
||||
}
|
||||
BluetoothService::AcknowledgeToggleBt(false);
|
||||
}
|
||||
};
|
||||
|
||||
static nsresult
|
||||
StartGonkBluetooth()
|
||||
nsresult
|
||||
BluetoothServiceBluedroid::StartGonkBluetooth()
|
||||
{
|
||||
MOZ_ASSERT(NS_IsMainThread());
|
||||
|
||||
@ -409,10 +290,7 @@ StartGonkBluetooth()
|
||||
|
||||
if (bs->IsEnabled()) {
|
||||
// Keep current enable status
|
||||
nsRefPtr<nsRunnable> runnable = new BluetoothService::ToggleBtAck(true);
|
||||
if (NS_FAILED(NS_DispatchToMainThread(runnable))) {
|
||||
BT_WARNING("Failed to dispatch to main thread!");
|
||||
}
|
||||
BluetoothService::AcknowledgeToggleBt(true);
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
@ -422,7 +300,8 @@ StartGonkBluetooth()
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
class DisableResultHandler MOZ_FINAL : public BluetoothResultHandler
|
||||
class BluetoothServiceBluedroid::DisableResultHandler MOZ_FINAL
|
||||
: public BluetoothResultHandler
|
||||
{
|
||||
public:
|
||||
void OnError(BluetoothStatus aStatus) MOZ_OVERRIDE
|
||||
@ -431,15 +310,12 @@ public:
|
||||
|
||||
BT_LOGR("BluetoothInterface::Disable failed: %d", aStatus);
|
||||
|
||||
nsRefPtr<nsRunnable> runnable = new BluetoothService::ToggleBtAck(true);
|
||||
if (NS_FAILED(NS_DispatchToMainThread(runnable))) {
|
||||
BT_WARNING("Failed to dispatch to main thread!");
|
||||
}
|
||||
BluetoothService::AcknowledgeToggleBt(true);
|
||||
}
|
||||
};
|
||||
|
||||
static nsresult
|
||||
StopGonkBluetooth()
|
||||
nsresult
|
||||
BluetoothServiceBluedroid::StopGonkBluetooth()
|
||||
{
|
||||
MOZ_ASSERT(NS_IsMainThread());
|
||||
|
||||
@ -450,10 +326,7 @@ StopGonkBluetooth()
|
||||
|
||||
if (!bs->IsEnabled()) {
|
||||
// Keep current enable status
|
||||
nsRefPtr<nsRunnable> runnable = new BluetoothService::ToggleBtAck(false);
|
||||
if (NS_FAILED(NS_DispatchToMainThread(runnable))) {
|
||||
BT_WARNING("Failed to dispatch to main thread!");
|
||||
}
|
||||
BluetoothService::AcknowledgeToggleBt(false);
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
@ -513,11 +386,7 @@ BluetoothServiceBluedroid::StartInternal()
|
||||
|
||||
nsresult ret = StartGonkBluetooth();
|
||||
if (NS_FAILED(ret)) {
|
||||
nsRefPtr<nsRunnable> runnable =
|
||||
new BluetoothService::ToggleBtAck(false);
|
||||
if (NS_FAILED(NS_DispatchToMainThread(runnable))) {
|
||||
BT_WARNING("Failed to dispatch to main thread!");
|
||||
}
|
||||
BluetoothService::AcknowledgeToggleBt(false);
|
||||
BT_LOGR("Error");
|
||||
}
|
||||
|
||||
@ -531,11 +400,7 @@ BluetoothServiceBluedroid::StopInternal()
|
||||
|
||||
nsresult ret = StopGonkBluetooth();
|
||||
if (NS_FAILED(ret)) {
|
||||
nsRefPtr<nsRunnable> runnable =
|
||||
new BluetoothService::ToggleBtAck(true);
|
||||
if (NS_FAILED(NS_DispatchToMainThread(runnable))) {
|
||||
BT_WARNING("Failed to dispatch to main thread!");
|
||||
}
|
||||
BluetoothService::AcknowledgeToggleBt(true);
|
||||
BT_LOGR("Error");
|
||||
}
|
||||
|
||||
@ -575,8 +440,8 @@ BluetoothServiceBluedroid::GetDefaultAdapterPathInternal(
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
class GetRemoteDevicePropertiesResultHandler MOZ_FINAL
|
||||
: public BluetoothResultHandler
|
||||
class BluetoothServiceBluedroid::GetRemoteDevicePropertiesResultHandler MOZ_FINAL
|
||||
: public BluetoothResultHandler
|
||||
{
|
||||
public:
|
||||
GetRemoteDevicePropertiesResultHandler(const nsAString& aDeviceAddress)
|
||||
@ -677,7 +542,8 @@ BluetoothServiceBluedroid::GetPairedDevicePropertiesInternal(
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
class StartDiscoveryResultHandler MOZ_FINAL : public BluetoothResultHandler
|
||||
class BluetoothServiceBluedroid::StartDiscoveryResultHandler MOZ_FINAL
|
||||
: public BluetoothResultHandler
|
||||
{
|
||||
public:
|
||||
StartDiscoveryResultHandler(BluetoothReplyRunnable* aRunnable)
|
||||
@ -712,7 +578,8 @@ BluetoothServiceBluedroid::StartDiscoveryInternal(
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
class CancelDiscoveryResultHandler MOZ_FINAL : public BluetoothResultHandler
|
||||
class BluetoothServiceBluedroid::CancelDiscoveryResultHandler MOZ_FINAL
|
||||
: public BluetoothResultHandler
|
||||
{
|
||||
public:
|
||||
CancelDiscoveryResultHandler(BluetoothReplyRunnable* aRunnable)
|
||||
@ -747,7 +614,8 @@ BluetoothServiceBluedroid::StopDiscoveryInternal(
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
class SetAdapterPropertyResultHandler MOZ_FINAL : public BluetoothResultHandler
|
||||
class BluetoothServiceBluedroid::SetAdapterPropertyResultHandler MOZ_FINAL
|
||||
: public BluetoothResultHandler
|
||||
{
|
||||
public:
|
||||
SetAdapterPropertyResultHandler(BluetoothReplyRunnable* aRunnable)
|
||||
@ -796,7 +664,8 @@ BluetoothServiceBluedroid::UpdateSdpRecords(
|
||||
return true;
|
||||
}
|
||||
|
||||
class CreateBondResultHandler MOZ_FINAL : public BluetoothResultHandler
|
||||
class BluetoothServiceBluedroid::CreateBondResultHandler MOZ_FINAL
|
||||
: public BluetoothResultHandler
|
||||
{
|
||||
public:
|
||||
CreateBondResultHandler(BluetoothReplyRunnable* aRunnable)
|
||||
@ -830,7 +699,8 @@ BluetoothServiceBluedroid::CreatePairedDeviceInternal(
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
class RemoveBondResultHandler MOZ_FINAL : public BluetoothResultHandler
|
||||
class BluetoothServiceBluedroid::RemoveBondResultHandler MOZ_FINAL
|
||||
: public BluetoothResultHandler
|
||||
{
|
||||
public:
|
||||
RemoveBondResultHandler(BluetoothReplyRunnable* aRunnable)
|
||||
@ -863,7 +733,8 @@ BluetoothServiceBluedroid::RemoveDeviceInternal(
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
class PinReplyResultHandler MOZ_FINAL : public BluetoothResultHandler
|
||||
class BluetoothServiceBluedroid::PinReplyResultHandler MOZ_FINAL
|
||||
: public BluetoothResultHandler
|
||||
{
|
||||
public:
|
||||
PinReplyResultHandler(BluetoothReplyRunnable* aRunnable)
|
||||
@ -907,7 +778,8 @@ BluetoothServiceBluedroid::SetPasskeyInternal(
|
||||
return true;
|
||||
}
|
||||
|
||||
class SspReplyResultHandler MOZ_FINAL : public BluetoothResultHandler
|
||||
class BluetoothServiceBluedroid::SspReplyResultHandler MOZ_FINAL
|
||||
: public BluetoothResultHandler
|
||||
{
|
||||
public:
|
||||
SspReplyResultHandler(BluetoothReplyRunnable* aRunnable)
|
||||
@ -1230,6 +1102,54 @@ BluetoothServiceBluedroid::ToggleCalls(BluetoothReplyRunnable* aRunnable)
|
||||
// Bluetooth notifications
|
||||
//
|
||||
|
||||
/* |ProfileDeinitResultHandler| collect the results of all profile
|
||||
* result handlers and calls |Proceed| after all results handlers
|
||||
* have been run.
|
||||
*/
|
||||
class BluetoothServiceBluedroid::ProfileDeinitResultHandler MOZ_FINAL
|
||||
: public BluetoothProfileResultHandler
|
||||
{
|
||||
public:
|
||||
ProfileDeinitResultHandler(unsigned char aNumProfiles)
|
||||
: mNumProfiles(aNumProfiles)
|
||||
{
|
||||
MOZ_ASSERT(mNumProfiles);
|
||||
}
|
||||
|
||||
void Deinit() MOZ_OVERRIDE
|
||||
{
|
||||
if (!(--mNumProfiles)) {
|
||||
Proceed();
|
||||
}
|
||||
}
|
||||
|
||||
void OnError(nsresult aResult) MOZ_OVERRIDE
|
||||
{
|
||||
if (!(--mNumProfiles)) {
|
||||
Proceed();
|
||||
}
|
||||
}
|
||||
|
||||
private:
|
||||
void Proceed() const
|
||||
{
|
||||
sBtInterface->Cleanup(nullptr);
|
||||
}
|
||||
|
||||
unsigned char mNumProfiles;
|
||||
};
|
||||
|
||||
class BluetoothServiceBluedroid::SetAdapterPropertyDiscoverableResultHandler
|
||||
MOZ_FINAL
|
||||
: public BluetoothResultHandler
|
||||
{
|
||||
public:
|
||||
void OnError(BluetoothStatus aStatus) MOZ_OVERRIDE
|
||||
{
|
||||
BT_LOGR("Fail to set: BT_SCAN_MODE_CONNECTABLE");
|
||||
}
|
||||
};
|
||||
|
||||
void
|
||||
BluetoothServiceBluedroid::AdapterStateChangedNotification(bool aState)
|
||||
{
|
||||
@ -1239,23 +1159,51 @@ BluetoothServiceBluedroid::AdapterStateChangedNotification(bool aState)
|
||||
|
||||
bool isBtEnabled = (aState == true);
|
||||
|
||||
if (!isBtEnabled &&
|
||||
NS_FAILED(NS_DispatchToMainThread(new CleanupTask()))) {
|
||||
BT_WARNING("Failed to dispatch to main thread!");
|
||||
return;
|
||||
if (!isBtEnabled) {
|
||||
static void (* const sDeinitManager[])(BluetoothProfileResultHandler*) = {
|
||||
BluetoothHfpManager::DeinitHfpInterface,
|
||||
BluetoothA2dpManager::DeinitA2dpInterface
|
||||
};
|
||||
|
||||
// Cleanup bluetooth interfaces after BT state becomes BT_STATE_OFF.
|
||||
nsRefPtr<ProfileDeinitResultHandler> res =
|
||||
new ProfileDeinitResultHandler(MOZ_ARRAY_LENGTH(sDeinitManager));
|
||||
|
||||
for (size_t i = 0; i < MOZ_ARRAY_LENGTH(sDeinitManager); ++i) {
|
||||
sDeinitManager[i](res);
|
||||
}
|
||||
}
|
||||
|
||||
nsRefPtr<nsRunnable> runnable =
|
||||
new BluetoothService::ToggleBtAck(isBtEnabled);
|
||||
if (NS_FAILED(NS_DispatchToMainThread(runnable))) {
|
||||
BT_WARNING("Failed to dispatch to main thread!");
|
||||
return;
|
||||
}
|
||||
BluetoothService::AcknowledgeToggleBt(isBtEnabled);
|
||||
|
||||
if (isBtEnabled &&
|
||||
NS_FAILED(NS_DispatchToMainThread(new SetupAfterEnabledTask()))) {
|
||||
BT_WARNING("Failed to dispatch to main thread!");
|
||||
return;
|
||||
if (isBtEnabled) {
|
||||
// Bluetooth just enabled, clear profile controllers and runnable arrays.
|
||||
sControllerArray.Clear();
|
||||
sBondingRunnableArray.Clear();
|
||||
sGetDeviceRunnableArray.Clear();
|
||||
sSetPropertyRunnableArray.Clear();
|
||||
sUnbondingRunnableArray.Clear();
|
||||
|
||||
// Bluetooth scan mode is SCAN_MODE_CONNECTABLE by default, i.e., It should
|
||||
// be connectable and non-discoverable.
|
||||
NS_ENSURE_TRUE_VOID(sBtInterface);
|
||||
sBtInterface->SetAdapterProperty(
|
||||
BluetoothNamedValue(NS_ConvertUTF8toUTF16("Discoverable"), false),
|
||||
new SetAdapterPropertyDiscoverableResultHandler());
|
||||
|
||||
// Try to fire event 'AdapterAdded' to fit the original behaviour when
|
||||
// we used BlueZ as backend.
|
||||
BluetoothService* bs = BluetoothService::Get();
|
||||
NS_ENSURE_TRUE_VOID(bs);
|
||||
|
||||
bs->AdapterAddedReceived();
|
||||
bs->TryFiringAdapterAdded();
|
||||
|
||||
// Trigger BluetoothOppManager to listen
|
||||
BluetoothOppManager* opp = BluetoothOppManager::Get();
|
||||
if (!opp || !opp->Listen()) {
|
||||
BT_LOGR("Fail to start BluetoothOppManager listening");
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -16,6 +16,21 @@ BEGIN_BLUETOOTH_NAMESPACE
|
||||
class BluetoothServiceBluedroid : public BluetoothService
|
||||
, public BluetoothNotificationHandler
|
||||
{
|
||||
class CancelDiscoveryResultHandler;
|
||||
class CreateBondResultHandler;
|
||||
class DisableResultHandler;
|
||||
class EnableResultHandler;
|
||||
class GetRemoteDevicePropertiesResultHandler;
|
||||
class InitResultHandler;
|
||||
class PinReplyResultHandler;
|
||||
class ProfileDeinitResultHandler;
|
||||
class ProfileInitResultHandler;
|
||||
class RemoveBondResultHandler;
|
||||
class SetAdapterPropertyDiscoverableResultHandler;
|
||||
class SetAdapterPropertyResultHandler;
|
||||
class SspReplyResultHandler;
|
||||
class StartDiscoveryResultHandler;
|
||||
|
||||
public:
|
||||
BluetoothServiceBluedroid();
|
||||
~BluetoothServiceBluedroid();
|
||||
@ -196,6 +211,16 @@ public:
|
||||
uint8_t aLen) MOZ_OVERRIDE;
|
||||
virtual void LeTestModeNotification(BluetoothStatus aStatus,
|
||||
uint16_t aNumPackets) MOZ_OVERRIDE;
|
||||
|
||||
protected:
|
||||
static nsresult StartGonkBluetooth();
|
||||
static nsresult StopGonkBluetooth();
|
||||
static bool EnsureBluetoothHalLoad();
|
||||
|
||||
static void ClassToIcon(uint32_t aClass, nsAString& aRetIcon);
|
||||
|
||||
static ControlPlayStatus PlayStatusStringToControlPlayStatus(
|
||||
const nsAString& aPlayStatus);
|
||||
};
|
||||
|
||||
END_BLUETOOTH_NAMESPACE
|
||||
|
Loading…
Reference in New Issue
Block a user