bluetooth/btstack/linkmgr/physicallinks.cpp
branchRCL_3
changeset 11 20fda83a6398
parent 10 8a27654f7b62
child 12 9b6d3ca0c601
equal deleted inserted replaced
10:8a27654f7b62 11:20fda83a6398
   507 		// Only bind a PIN code to the device if we receive a link key based on it.
   507 		// Only bind a PIN code to the device if we receive a link key based on it.
   508 		iNewPinCodeValid = EFalse;
   508 		iNewPinCodeValid = EFalse;
   509 		iDevice.SetPassKey(iNewPinCode);
   509 		iDevice.SetPassKey(iNewPinCode);
   510 		}
   510 		}
   511 
   511 
       
   512 	if (iLinksMan.SecMan().IsDedicatedBondingAttempted(iDevice.Address()))
       
   513 		{
       
   514 		iLinkKeyObtainedThroughDedicatedBonding = ETrue;
       
   515 		}
   512 
   516 
   513 	SetLinkKey(aLinkKey, linkKeyType);	// keeps a copy in our 'cache', updates paired list in PHYs mananger
   517 	SetLinkKey(aLinkKey, linkKeyType);	// keeps a copy in our 'cache', updates paired list in PHYs mananger
   514 
   518 
   515 	TRAP_IGNORE(StoreDeviceL(EFalse)); //EFalse: new meaning - do not prevent addition
   519 	TRAP_IGNORE(StoreDeviceL(EFalse)); //EFalse: new meaning - do not prevent addition
   516 	// if that errored we just have to keep it here - but it won't be in registry
   520 	// if that errored we just have to keep it here - but it won't be in registry
   570 		{
   574 		{
   571 		device.SetDeviceClass(iDevice.DeviceClass());
   575 		device.SetDeviceClass(iDevice.DeviceClass());
   572 		}
   576 		}
   573 	if(iDevice.IsValidLinkKey() && !iPreventLinkKeyUpdateReg)
   577 	if(iDevice.IsValidLinkKey() && !iPreventLinkKeyUpdateReg)
   574 		{
   578 		{
   575 		if(!(iIOCapsReceived && (iAuthenticationRequirement == EMitmNotReqNoBonding || iAuthenticationRequirement == EMitmReqNoBonding)))
   579 		// We store the link key if it was obtained through dedicated bonding, even if the remote device indicated "no bonding"
       
   580 		// This fixes issues with a lot of remote stacks, and we'll let the UI delete the link key if they want to.
       
   581 		if(iLinkKeyObtainedThroughDedicatedBonding ||
       
   582 			!(iIOCapsReceived && (iAuthenticationRequirement == EMitmNotReqNoBonding || iAuthenticationRequirement == EMitmReqNoBonding)))
   576 			{
   583 			{
   577 			LOG(_L("!!! Storing Link Key in Registry"));
   584 			LOG(_L("!!! Storing Link Key in Registry"));
   578 			device.SetLinkKey(iDevice.LinkKey(), iDevice.LinkKeyType());
   585 			device.SetLinkKey(iDevice.LinkKey(), iDevice.LinkKeyType());
   579 			}
   586 			}
   580 		}
   587 		}
   857 		{
   864 		{
   858 		iRequireAuthenticatedLinkKey = aRequireAuthenticatedLinkKey;
   865 		iRequireAuthenticatedLinkKey = aRequireAuthenticatedLinkKey;
   859 		TRAP(err, iLinksMan.HCIFacade().AuthenticateL(Handle()));
   866 		TRAP(err, iLinksMan.HCIFacade().AuthenticateL(Handle()));
   860 		if(err == KErrNone)
   867 		if(err == KErrNone)
   861 			{
   868 			{
       
   869 			iLinkKeyReturnedInThisAuthentication = EFalse;
   862 			SetAuthenticationPending(EAuthenticationRequestPending);
   870 			SetAuthenticationPending(EAuthenticationRequestPending);
   863 			}
   871 			}
   864 		}
   872 		}
   865 	return err;
   873 	return err;
   866 	}
   874 	}
  2939 		|| iLinkState.Authenticated() 
  2947 		|| iLinkState.Authenticated() 
  2940 		|| locallyInitiatedLogicalLink
  2948 		|| locallyInitiatedLogicalLink
  2941 		|| iLinksMan.SecMan().IsDedicatedBondingAttempted(iDevice.Address());
  2949 		|| iLinksMan.SecMan().IsDedicatedBondingAttempted(iDevice.Address());
  2942 	}
  2950 	}
  2943 
  2951 
       
  2952 TBool CPhysicalLink::IsPairingExpected() const
       
  2953 	{
       
  2954 	LOG_FUNC
       
  2955 	return !(IsAuthenticationPending() && iLinkKeyReturnedInThisAuthentication);
       
  2956 	}
       
  2957 
  2944 void CPhysicalLink::DeleteLinkKeyL()
  2958 void CPhysicalLink::DeleteLinkKeyL()
  2945 /**
  2959 /**
  2946 ensure that the LinkKey is removed from the device in the registry
  2960 ensure that the LinkKey is removed from the device in the registry
  2947 **/
  2961 **/
  2948 	{
  2962 	{
  3646 	{
  3660 	{
  3647 	LOG_FUNC
  3661 	LOG_FUNC
  3648 	iPasskeyEntry->KeyPressed(aKey);
  3662 	iPasskeyEntry->KeyPressed(aKey);
  3649 	}
  3663 	}
  3650 
  3664 
       
  3665 void CPhysicalLink::NewUserConfirmerL(const TBTDevAddr aAddr,
       
  3666  										  CBTSecMan& aSecMan,
       
  3667  										  TBool	aInternallyInitiated)
       
  3668    	{
       
  3669 	LOG_FUNC
       
  3670  	__ASSERT_DEBUG(aAddr == BDAddr(), Panic(EBTConnectionBadDeviceAddress));
       
  3671   	iUserConfirmer = CBTUserConfirmer::NewL(aAddr, aSecMan, aInternallyInitiated);
       
  3672    	}
       
  3673 
       
  3674 CBTUserConfirmer* CPhysicalLink::InstanceUserConfirmer() const
       
  3675 	{
       
  3676 	LOG_FUNC
       
  3677 	return iUserConfirmer;
       
  3678 	}
       
  3679 
       
  3680 TBool CPhysicalLink::IsUserConfirmerActive()const
       
  3681 	{
       
  3682 	LOG_FUNC
       
  3683 	return iUserConfirmer->IsActive();
       
  3684 	}
       
  3685 
       
  3686 void CPhysicalLink::DeleteUserConfirmer()
       
  3687 	{
       
  3688 	LOG_FUNC
       
  3689 	delete iUserConfirmer;
       
  3690 	iUserConfirmer = NULL;
       
  3691 	}
       
  3692 
       
  3693 void CPhysicalLink::CancelUserConfirmer()
       
  3694 	{
       
  3695 	LOG_FUNC
       
  3696 	iUserConfirmer->Cancel();
       
  3697 	}
       
  3698 
  3651 
  3699 
  3652 TBasebandTime CPhysicalLink::GetSniffInterval() const
  3700 TBasebandTime CPhysicalLink::GetSniffInterval() const
  3653 	{
  3701 	{
  3654 	return iSniffInterval;
  3702 	return iSniffInterval;
  3655 	}
  3703 	}
  3738 
  3786 
  3739 	if(aPositive)
  3787 	if(aPositive)
  3740 		{
  3788 		{
  3741 		LOG(_L("CPhysicalLink: Providing link key to HC..."))
  3789 		LOG(_L("CPhysicalLink: Providing link key to HC..."))
  3742 		ASSERT_DEBUG(iDevice.IsValidLinkKey());
  3790 		ASSERT_DEBUG(iDevice.IsValidLinkKey());
       
  3791 		if (IsAuthenticationPending())
       
  3792 			{
       
  3793 			iLinkKeyReturnedInThisAuthentication = ETrue;
       
  3794 			}
  3743 		iAuthenticationCtrl.LinkKeyRequestReply(iDevice.Address(), iDevice.LinkKey());
  3795 		iAuthenticationCtrl.LinkKeyRequestReply(iDevice.Address(), iDevice.LinkKey());
  3744 		}
  3796 		}
  3745 	else
  3797 	else
  3746 		{
  3798 		{
  3747 		LOG(_L("CPhysicalLink: Indicating no link key to HC..."));
  3799 		LOG(_L("CPhysicalLink: Indicating no link key to HC..."));