Bug 1227440 - Reject pin reply by cancelling bond to trigger BondStateChangedNotification, in order to inform gaia setting app, r=shuang

This commit is contained in:
Ben Tian 2015-11-26 16:31:42 +08:00
parent 83b65d05d1
commit cdd3762041
2 changed files with 31 additions and 2 deletions

View File

@ -1268,6 +1268,28 @@ private:
BluetoothReplyRunnable* mRunnable;
};
class BluetoothServiceBluedroid::CancelBondResultHandler final
: public BluetoothCoreResultHandler
{
public:
CancelBondResultHandler(BluetoothReplyRunnable* aRunnable)
: mRunnable(aRunnable)
{ }
void CancelBond() override
{
DispatchReplySuccess(mRunnable);
}
void OnError(BluetoothStatus aStatus) override
{
DispatchReplyError(mRunnable, aStatus);
}
private:
BluetoothReplyRunnable* mRunnable;
};
void
BluetoothServiceBluedroid::PinReplyInternal(
const BluetoothAddress& aDeviceAddress, bool aAccept,
@ -1277,8 +1299,14 @@ BluetoothServiceBluedroid::PinReplyInternal(
ENSURE_BLUETOOTH_IS_ENABLED_VOID(aRunnable);
sBtCoreInterface->PinReply(aDeviceAddress, aAccept, aPinCode,
new PinReplyResultHandler(aRunnable));
if (aAccept) {
sBtCoreInterface->PinReply(aDeviceAddress, aAccept, aPinCode,
new PinReplyResultHandler(aRunnable));
} else {
// Call CancelBond to trigger BondStateChangedNotification
sBtCoreInterface->CancelBond(aDeviceAddress,
new CancelBondResultHandler(aRunnable));
}
}
void

View File

@ -20,6 +20,7 @@ class BluetoothServiceBluedroid
, public BluetoothCoreNotificationHandler
, public BluetoothNotificationHandler
{
class CancelBondResultHandler;
class CleanupResultHandler;
class DisableResultHandler;
class DispatchReplyErrorResultHandler;