Browse Source

Fix write storage permission problem

QGC4.4
Don Gagne 6 years ago
parent
commit
821f08c824
  1. 2
      android/AndroidManifest.xml
  2. 2
      src/QmlControls/AppMessages.cc
  3. 1
      src/QmlControls/AppMessages.qml
  4. 19
      src/main.cc

2
android/AndroidManifest.xml

@ -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. -->

2
src/QmlControls/AppMessages.cc

@ -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);
}); });

1
src/QmlControls/AppMessages.qml

@ -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

19
src/main.cc

@ -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[])
} else } else
#endif #endif
{ {
#ifdef __android__
checkAndroidWritePermission();
#endif
if (!app->_initForNormalAppBoot()) { if (!app->_initForNormalAppBoot()) {
return -1; return -1;
} }

Loading…
Cancel
Save