diff --git a/android/AndroidManifest.xml b/android/AndroidManifest.xml index 735d27fc0975e8bdc5452f88e9052d0be20b3e90..28751cdc99aca2a34347ebdcc355e0deae7dd780 100644 --- a/android/AndroidManifest.xml +++ b/android/AndroidManifest.xml @@ -69,6 +69,8 @@ + + diff --git a/src/QmlControls/AppMessages.cc b/src/QmlControls/AppMessages.cc index fab8b7bd6e1fbaf012b66a9006b70f4da313d2d8..0b7bcf4588eebef402d351b0b889eeedc7551f72 100644 --- a/src/QmlControls/AppMessages.cc +++ b/src/QmlControls/AppMessages.cc @@ -76,6 +76,8 @@ void AppLogModel::writeMessages(const QString dest_file) QTextStream out(&file); out << writebuffer; success = out.status() == QTextStream::Ok; + } else { + qWarning() << "AppLogModel::writeMessages write failed:" << file.errorString(); } emit debug_model->writeFinished(success); }); diff --git a/src/QmlControls/AppMessages.qml b/src/QmlControls/AppMessages.qml index af00cceeddd7ca1220090f31e243351e2306e1ae..29a70c1981474bc2c128938e25461e6db674de54 100644 --- a/src/QmlControls/AppMessages.qml +++ b/src/QmlControls/AppMessages.qml @@ -133,6 +133,7 @@ QGCView { id: writeDialog folder: QGroundControl.settingsManager.appSettings.logSavePath nameFilters: [qsTr("Log files (*.txt)"), qsTr("All Files (*)")] + fileExtension: qsTr("txt") selectExisting: false title: qsTr("Select log save file") qgcView: _qgcView diff --git a/src/main.cc b/src/main.cc index 62457d0149adf48fbbf431d4e84818df5b479816..62012d36cdc3379274959f9dab23c6a4233a46cf 100644 --- a/src/main.cc +++ b/src/main.cc @@ -97,6 +97,21 @@ jint JNI_OnLoad(JavaVM* vm, void* reserved) } #endif +#ifdef __android__ +#include +bool checkAndroidWritePermission() { + QtAndroid::PermissionResult r = QtAndroid::checkPermission("android.permission.WRITE_EXTERNAL_STORAGE"); + if(r == QtAndroid::PermissionResult::Denied) { + QtAndroid::requestPermissionsSync( QStringList() << "android.permission.WRITE_EXTERNAL_STORAGE" ); + r = QtAndroid::checkPermission("android.permission.WRITE_EXTERNAL_STORAGE"); + if(r == QtAndroid::PermissionResult::Denied) { + return false; + } + } + return true; +} +#endif + /** * @brief Starts the application * @@ -254,6 +269,10 @@ int main(int argc, char *argv[]) } else #endif { + +#ifdef __android__ + checkAndroidWritePermission(); +#endif if (!app->_initForNormalAppBoot()) { return -1; }