Skip to content

Commit

Permalink
android - log warning if permissions are missing (only)
Browse files Browse the repository at this point in the history
  • Loading branch information
Consti10 committed Nov 7, 2023
1 parent 310b388 commit a5d79c8
Showing 1 changed file with 18 additions and 14 deletions.
32 changes: 18 additions & 14 deletions app/main.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -170,6 +170,22 @@ static void write_platform_context_properties(QQmlApplicationEngine& engine){
#endif
}

static void android_check_permissions(){
#if defined(__android__)
qDebug()<<"Android request permissions";
for(const QString &permission : permissions) {
auto result = QtAndroid::checkPermission(permission);
if (result == QtAndroid::PermissionResult::Denied) {
auto resultHash = QtAndroid::requestPermissionsSync(QStringList({permission}));
if (resultHash[permission] == QtAndroid::PermissionResult::Denied) {
LogMessagesModel::instanceGround().add_message_warn("QOpenHD","Android - missing permissions");
return;
}
}
}
#endif
}


int main(int argc, char *argv[]) {

Expand Down Expand Up @@ -235,20 +251,8 @@ int main(int argc, char *argv[]) {
applePlatform->registerNotifications();
#endif

QOpenHD::instance().keep_screen_on(true);
#if defined(__android__)
qDebug()<<"Android request permissions";
for(const QString &permission : permissions) {
auto result = QtAndroid::checkPermission(permission);
if (result == QtAndroid::PermissionResult::Denied) {
auto resultHash = QtAndroid::requestPermissionsSync(QStringList({permission}));
if (resultHash[permission] == QtAndroid::PermissionResult::Denied) {
return 0;
}
}
}
#endif

QOpenHD::instance().keep_screen_on(true);
android_check_permissions();
load_fonts();

qmlRegisterType<SpeedLadder>("OpenHD", 1, 0, "SpeedLadder");
Expand Down

0 comments on commit a5d79c8

Please sign in to comment.