Unverified Commit 9765125d authored by Don Gagne's avatar Don Gagne Committed by GitHub

Merge pull request #7172 from DonLakeFlyer/AndroidWriteStorage

Android: Fix write storage permission problem
parents dff88c80 821f08c8
...@@ -69,6 +69,8 @@ ...@@ -69,6 +69,8 @@
<uses-feature android:name="android.hardware.location" android:required="false"/> <uses-feature android:name="android.hardware.location" android:required="false"/>
<uses-permission android:name="android.permission.INTERNET" /> <uses-permission android:name="android.permission.INTERNET" />
<uses-permission android:name="android.permission.WRITE_INTERNAL_STORAGE" />
<uses-permission android:name="android.permission.WRITE_EXTERNAL_STORAGE" />
<!-- The following comment will be replaced upon deployment with default features based on the dependencies of the application. <!-- The following comment will be replaced upon deployment with default features based on the dependencies of the application.
Remove the comment if you do not require these default features. --> Remove the comment if you do not require these default features. -->
......
...@@ -76,6 +76,8 @@ void AppLogModel::writeMessages(const QString dest_file) ...@@ -76,6 +76,8 @@ void AppLogModel::writeMessages(const QString dest_file)
QTextStream out(&file); QTextStream out(&file);
out << writebuffer; out << writebuffer;
success = out.status() == QTextStream::Ok; success = out.status() == QTextStream::Ok;
} else {
qWarning() << "AppLogModel::writeMessages write failed:" << file.errorString();
} }
emit debug_model->writeFinished(success); emit debug_model->writeFinished(success);
}); });
......
...@@ -133,6 +133,7 @@ QGCView { ...@@ -133,6 +133,7 @@ QGCView {
id: writeDialog id: writeDialog
folder: QGroundControl.settingsManager.appSettings.logSavePath folder: QGroundControl.settingsManager.appSettings.logSavePath
nameFilters: [qsTr("Log files (*.txt)"), qsTr("All Files (*)")] nameFilters: [qsTr("Log files (*.txt)"), qsTr("All Files (*)")]
fileExtension: qsTr("txt")
selectExisting: false selectExisting: false
title: qsTr("Select log save file") title: qsTr("Select log save file")
qgcView: _qgcView qgcView: _qgcView
......
...@@ -97,6 +97,21 @@ jint JNI_OnLoad(JavaVM* vm, void* reserved) ...@@ -97,6 +97,21 @@ jint JNI_OnLoad(JavaVM* vm, void* reserved)
} }
#endif #endif
#ifdef __android__
#include <QtAndroid>
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 * @brief Starts the application
* *
...@@ -254,6 +269,10 @@ int main(int argc, char *argv[]) ...@@ -254,6 +269,10 @@ int main(int argc, char *argv[])
} else } else
#endif #endif
{ {
#ifdef __android__
checkAndroidWritePermission();
#endif
if (!app->_initForNormalAppBoot()) { if (!app->_initForNormalAppBoot()) {
return -1; return -1;
} }
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment