Commit 6af9a170 authored by dogmaphobic's avatar dogmaphobic

More Android work...

parent db135056
...@@ -60,6 +60,7 @@ public class UsbDeviceJNI extends QtActivity ...@@ -60,6 +60,7 @@ public class UsbDeviceJNI extends QtActivity
// USED TO DETECT WHEN A DEVICE HAS BEEN UNPLUGGED // USED TO DETECT WHEN A DEVICE HAS BEEN UNPLUGGED
private BroadcastReceiver m_UsbReceiver = null; private BroadcastReceiver m_UsbReceiver = null;
private final static ExecutorService m_Executor = Executors.newSingleThreadExecutor(); private final static ExecutorService m_Executor = Executors.newSingleThreadExecutor();
private static final String TAG = "QGC_UsbDeviceJNI";
private final static UsbIoManager.Listener m_Listener = private final static UsbIoManager.Listener m_Listener =
new UsbIoManager.Listener() new UsbIoManager.Listener()
...@@ -67,6 +68,7 @@ public class UsbDeviceJNI extends QtActivity ...@@ -67,6 +68,7 @@ public class UsbDeviceJNI extends QtActivity
@Override @Override
public void onRunError(Exception eA, int userDataA) public void onRunError(Exception eA, int userDataA)
{ {
Log.e(TAG, "onRunError Exception");
nativeDeviceException(userDataA, eA.getMessage()); nativeDeviceException(userDataA, eA.getMessage());
} }
...@@ -77,7 +79,6 @@ public class UsbDeviceJNI extends QtActivity ...@@ -77,7 +79,6 @@ public class UsbDeviceJNI extends QtActivity
} }
}; };
private static final String TAG = "QGC_UsbDeviceJNI";
// NATIVE C++ FUNCTION THAT WILL BE CALLED IF THE DEVICE IS UNPLUGGED // NATIVE C++ FUNCTION THAT WILL BE CALLED IF THE DEVICE IS UNPLUGGED
private static native void nativeDeviceHasDisconnected(int userDataA); private static native void nativeDeviceHasDisconnected(int userDataA);
...@@ -120,7 +121,6 @@ public class UsbDeviceJNI extends QtActivity ...@@ -120,7 +121,6 @@ public class UsbDeviceJNI extends QtActivity
return true; return true;
} }
///////////////////////////////////////////////////////////////////////////////////////////////////////// /////////////////////////////////////////////////////////////////////////////////////////////////////////
// //
// List all available devices that are not already open. It returns the serial port info // List all available devices that are not already open. It returns the serial port info
......
...@@ -48,6 +48,8 @@ QT_BEGIN_NAMESPACE ...@@ -48,6 +48,8 @@ QT_BEGIN_NAMESPACE
static const char V_jniClassName[] {"org/qgroundcontrol/qgchelper/UsbDeviceJNI"}; static const char V_jniClassName[] {"org/qgroundcontrol/qgchelper/UsbDeviceJNI"};
static const char V_TAG[] {"QGC_QSerialPortInfo"}; static const char V_TAG[] {"QGC_QSerialPortInfo"};
extern void cleanJavaException();
QList<QSerialPortInfo> availablePortsByFiltersOfDevices(bool &ok) QList<QSerialPortInfo> availablePortsByFiltersOfDevices(bool &ok)
{ {
QList<QSerialPortInfo> serialPortInfoList; QList<QSerialPortInfo> serialPortInfoList;
...@@ -117,22 +119,26 @@ QList<qint32> QSerialPortInfo::standardBaudRates() ...@@ -117,22 +119,26 @@ QList<qint32> QSerialPortInfo::standardBaudRates()
bool QSerialPortInfo::isBusy() const bool QSerialPortInfo::isBusy() const
{ {
QAndroidJniObject jstrL = QAndroidJniObject::fromString(d_ptr->portName); QAndroidJniObject jstrL = QAndroidJniObject::fromString(d_ptr->portName);
cleanJavaException();
jboolean resultL = QAndroidJniObject::callStaticMethod<jboolean>( jboolean resultL = QAndroidJniObject::callStaticMethod<jboolean>(
V_jniClassName, V_jniClassName,
"isDeviceNameOpen", "isDeviceNameOpen",
"(Ljava/lang/String;)Z", "(Ljava/lang/String;)Z",
jstrL.object<jstring>()); jstrL.object<jstring>());
cleanJavaException();
return resultL; return resultL;
} }
bool QSerialPortInfo::isValid() const bool QSerialPortInfo::isValid() const
{ {
QAndroidJniObject jstrL = QAndroidJniObject::fromString(d_ptr->portName); QAndroidJniObject jstrL = QAndroidJniObject::fromString(d_ptr->portName);
cleanJavaException();
jboolean resultL = QAndroidJniObject::callStaticMethod<jboolean>( jboolean resultL = QAndroidJniObject::callStaticMethod<jboolean>(
V_jniClassName, V_jniClassName,
"isDeviceNameValid", "isDeviceNameValid",
"(Ljava/lang/String;)Z", "(Ljava/lang/String;)Z",
jstrL.object<jstring>()); jstrL.object<jstring>());
cleanJavaException();
return resultL; return resultL;
} }
......
...@@ -104,7 +104,9 @@ QGCApplication::QGCApplication(int &argc, char* argv[], bool unitTesting) : ...@@ -104,7 +104,9 @@ QGCApplication::QGCApplication(int &argc, char* argv[], bool unitTesting) :
_app = this; _app = this;
// This prevents usage of QQuickWidget to fail since it doesn't support native widget siblings // This prevents usage of QQuickWidget to fail since it doesn't support native widget siblings
#ifndef __android__
setAttribute(Qt::AA_DontCreateNativeWidgetSiblings); setAttribute(Qt::AA_DontCreateNativeWidgetSiblings);
#endif
#ifdef QT_DEBUG #ifdef QT_DEBUG
// First thing we want to do is set up the qtlogging.ini file. If it doesn't already exist we copy // First thing we want to do is set up the qtlogging.ini file. If it doesn't already exist we copy
......
...@@ -217,10 +217,10 @@ void QGCFileDialog::_validate(Options& options) ...@@ -217,10 +217,10 @@ void QGCFileDialog::_validate(Options& options)
Q_ASSERT(qgcApp()); Q_ASSERT(qgcApp());
Q_ASSERT_X(QThread::currentThread() == qgcApp()->thread(), "Threading issue", "QGCFileDialog can only be called from main thread"); Q_ASSERT_X(QThread::currentThread() == qgcApp()->thread(), "Threading issue", "QGCFileDialog can only be called from main thread");
#ifndef __android__
// On OSX native dialog can hang so we always use Qt dialogs // On OSX native dialog can hang so we always use Qt dialogs
options |= DontUseNativeDialog; options |= DontUseNativeDialog;
#endif
if (MainWindow::instance()) { if (MainWindow::instance()) {
MainWindow::instance()->hideSplashScreen(); MainWindow::instance()->hideSplashScreen();
} }
......
...@@ -183,8 +183,10 @@ MainWindow::MainWindow(QSplashScreen* splashScreen) ...@@ -183,8 +183,10 @@ MainWindow::MainWindow(QSplashScreen* splashScreen)
// Qt 4 on Ubuntu does place the native menubar correctly so on Linux we revert back to in-window menu bar. // Qt 4 on Ubuntu does place the native menubar correctly so on Linux we revert back to in-window menu bar.
// TODO: Check that this is still necessary on Qt5 on Ubuntu // TODO: Check that this is still necessary on Qt5 on Ubuntu
#ifdef Q_OS_LINUX #ifdef Q_OS_LINUX
#ifndef __android__
menuBar()->setNativeMenuBar(false); menuBar()->setNativeMenuBar(false);
#endif #endif
#endif
#ifdef UNITTEST_BUILD #ifdef UNITTEST_BUILD
QAction* qmlTestAction = new QAction("Test QML palette and controls", NULL); QAction* qmlTestAction = new QAction("Test QML palette and controls", NULL);
......
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