permissions: Handle unknown permission statuses gracefully
If an application runs on a macOS or iOS version that introduces new permission statuses that we haven't accounted for, we don't want to crash. Replace Q_UNREACHABLE with a warning and Qt::PermissionStatus::Denied. Pick-to: 6.5 6.6 Change-Id: I063042f510caaa8936742f6195bd455d09c4d9ee Reviewed-by: Volker Hilsheimer <volker.hilsheimer@qt.io>
This commit is contained in:
parent
2736e908e9
commit
993cbef7f4
@ -31,7 +31,8 @@
|
||||
|
||||
- (Qt::PermissionStatus)currentStatus
|
||||
{
|
||||
switch (CBCentralManager.authorization) {
|
||||
auto status = CBCentralManager.authorization;
|
||||
switch (status) {
|
||||
case CBManagerAuthorizationNotDetermined:
|
||||
return Qt::PermissionStatus::Undetermined;
|
||||
case CBManagerAuthorizationRestricted:
|
||||
@ -41,7 +42,8 @@
|
||||
return Qt::PermissionStatus::Granted;
|
||||
}
|
||||
|
||||
Q_UNREACHABLE();
|
||||
qCWarning(lcPermissions) << "Unknown permission status" << status << "detected in" << self;
|
||||
return Qt::PermissionStatus::Denied;
|
||||
}
|
||||
|
||||
- (void)requestPermission:(QPermission)permission withCallback:(PermissionCallback)callback
|
||||
|
@ -18,7 +18,8 @@
|
||||
|
||||
- (Qt::PermissionStatus)currentStatus
|
||||
{
|
||||
switch ([EKEventStore authorizationStatusForEntityType:EKEntityTypeEvent]) {
|
||||
auto status = [EKEventStore authorizationStatusForEntityType:EKEntityTypeEvent];
|
||||
switch (status) {
|
||||
case EKAuthorizationStatusNotDetermined:
|
||||
return Qt::PermissionStatus::Undetermined;
|
||||
case EKAuthorizationStatusRestricted:
|
||||
@ -33,7 +34,8 @@
|
||||
#endif
|
||||
}
|
||||
|
||||
Q_UNREACHABLE();
|
||||
qCWarning(lcPermissions) << "Unknown permission status" << status << "detected in" << self;
|
||||
return Qt::PermissionStatus::Denied;
|
||||
}
|
||||
|
||||
- (QStringList)usageDescriptionsFor:(QPermission)permission
|
||||
|
@ -73,7 +73,8 @@ struct PermissionRequest
|
||||
return Qt::PermissionStatus::Denied;
|
||||
}
|
||||
|
||||
switch ([self authorizationStatus]) {
|
||||
auto status = [self authorizationStatus];
|
||||
switch (status) {
|
||||
case kCLAuthorizationStatusRestricted:
|
||||
case kCLAuthorizationStatusDenied:
|
||||
return Qt::PermissionStatus::Denied;
|
||||
@ -89,7 +90,8 @@ struct PermissionRequest
|
||||
#endif
|
||||
}
|
||||
|
||||
Q_UNREACHABLE();
|
||||
qCWarning(lcPermissions) << "Unknown permission status" << status << "detected in" << self;
|
||||
return Qt::PermissionStatus::Denied;
|
||||
}
|
||||
|
||||
- (CLAuthorizationStatus)authorizationStatus
|
||||
@ -118,7 +120,8 @@ struct PermissionRequest
|
||||
return Qt::PermissionStatus::Denied;
|
||||
}
|
||||
|
||||
Q_UNREACHABLE();
|
||||
qCWarning(lcPermissions) << "Unknown accuracy status" << status << "detected in" << self;
|
||||
return Qt::PermissionStatus::Denied;
|
||||
}
|
||||
|
||||
- (QStringList)usageDescriptionsFor:(QPermission)permission
|
||||
|
@ -83,7 +83,9 @@ Qt::PermissionStatus nativeStatusToQtStatus(NativeStatus status)
|
||||
case Converter::Undetermined:
|
||||
return Qt::PermissionStatus::Undetermined;
|
||||
}
|
||||
Q_UNREACHABLE();
|
||||
qCWarning(lcPermissions) << "Unknown permission status" << status << "detected in"
|
||||
<< QT_STRINGIFY(QT_DARWIN_PERMISSION_PLUGIN);
|
||||
return Qt::PermissionStatus::Denied;
|
||||
}
|
||||
} // namespace
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user