Skip to content

Commit

Permalink
fix positioning auto test - do not work with BT permissions on deskto…
Browse files Browse the repository at this point in the history
…p builds
  • Loading branch information
tomasMizera committed Nov 30, 2023
1 parent d96c863 commit e026508
Showing 1 changed file with 20 additions and 8 deletions.
28 changes: 20 additions & 8 deletions app/position/providers/bluetoothpositionprovider.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,10 @@
#include "coreutils.h"
#include "androidutils.h"
#include "inpututils.h"

#ifdef ANDROID
#include <QPermissions>
#endif

NmeaParser::NmeaParser() : QgsNmeaConnection( new QBluetoothSocket() )
{
Expand Down Expand Up @@ -134,9 +137,11 @@ void BluetoothPositionProvider::startReconnectionTime()

void BluetoothPositionProvider::handleLostConnection()
{
// we want to reconnect, but only to devices that are paired
// first, check the permission status (Android-only)
Qt::PermissionStatus permissionStatus = Qt::PermissionStatus::Granted;

#ifdef ANDROID
QBluetoothPermission btPermission;
Qt::PermissionStatus permissionStatus;

if ( qApp && ( permissionStatus = qApp->checkPermission( btPermission ) ) != Qt::PermissionStatus::Granted )
{
Expand All @@ -150,13 +155,20 @@ void BluetoothPositionProvider::handleLostConnection()
setState( tr( "Bluetooth permission disabled" ), State::NoConnection ); // permanent error
}
}
else if ( mReceiverDevice->pairingStatus( mTargetAddress ) == QBluetoothLocalDevice::Unpaired )
{
setState( tr( "Could not connect to device, not paired" ), State::NoConnection );
}
else if ( mState != WaitingToReconnect && mState != Connecting )

#endif

if ( permissionStatus == Qt::PermissionStatus::Granted )
{
startReconnectionTime();
// we want to reconnect, but only to devices that are paired
if ( mReceiverDevice->pairingStatus( mTargetAddress ) == QBluetoothLocalDevice::Unpaired )
{
setState( tr( "Could not connect to device, not paired" ), State::NoConnection );
}
else if ( mState != WaitingToReconnect && mState != Connecting )
{
startReconnectionTime();
}
}

// let's also invalidate current position since we no longer have connection
Expand Down

1 comment on commit e026508

@inputapp-bot
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

iOS - version 23.11.491311 just submitted!

Please sign in to comment.