Skip to content

Commit

Permalink
Fixes after rebase
Browse files Browse the repository at this point in the history
  • Loading branch information
HTRamsey committed Apr 15, 2024
1 parent 2c188a0 commit 4068d97
Show file tree
Hide file tree
Showing 11 changed files with 54 additions and 82 deletions.
4 changes: 0 additions & 4 deletions QGCCommon.pri
Original file line number Diff line number Diff line change
Expand Up @@ -242,11 +242,7 @@ AndroidBuild {

message(Android version info: $${ANDROID_VERSION_CODE} bitness:$${ANDROID_VERSION_BITNESS} major:$${MAJOR_VERSION} minor:$${MINOR_VERSION} patch:$${PATCH_VERSION} dev:$${DEV_VERSION})

<<<<<<< HEAD
ANDROID_VERSION_NAME = $${APP_VERSION_STR}
=======
ANDROID_VERSION_NAME = $$APP_VERSION_STR
>>>>>>> aad28aa40 (separate android init code)

QMAKE_LFLAGS += -Wl,-Bsymbolic
}
Expand Down
9 changes: 3 additions & 6 deletions android/android.pri
Original file line number Diff line number Diff line change
Expand Up @@ -111,16 +111,13 @@ DISTFILES += \
$$ANDROID_PACKAGE_QGC_SOURCE_DIR/src/org/mavlink/qgroundcontrol/UsbIoManager.java

SOURCES += \
$$ANDROID_PACKAGE_QGC_SOURCE_DIR/src/AndroidInterface.cc
$$ANDROID_PACKAGE_QGC_SOURCE_DIR/src/AndroidInit.cpp
$$ANDROID_PACKAGE_QGC_SOURCE_DIR/src/AndroidInit.cpp \
$$ANDROID_PACKAGE_QGC_SOURCE_DIR/src/AndroidInterface.cc \
$$ANDROID_PACKAGE_QGC_SOURCE_DIR/src/AndroidSerial.cpp

HEADERS += \
$$ANDROID_PACKAGE_QGC_SOURCE_DIR/src/AndroidInterface.h
$$ANDROID_PACKAGE_QGC_SOURCE_DIR/src/AndroidInterface.h \
$$ANDROID_PACKAGE_QGC_SOURCE_DIR/src/AndroidSerial.h

HEADERS += \
$$PWD/src/AndroidInterface.h \

INCLUDEPATH += \
$$ANDROID_PACKAGE_QGC_SOURCE_DIR/src
26 changes: 0 additions & 26 deletions android/gradle.properties

This file was deleted.

9 changes: 9 additions & 0 deletions android/package/gradle.properties
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
# Project-wide Gradle settings.
# For more details on how to configure your build environment visit
# http://www.gradle.org/docs/current/userguide/build_environment.html

# Specifies the JVM arguments used for the daemon process.
# The setting is particularly useful for tweaking memory settings.
org.gradle.jvmargs=-Xmx2500m -XX:MaxMetaspaceSize=512m -XX:+HeapDumpOnOutOfMemoryError -Dfile.encoding=UTF-8
Expand All @@ -12,6 +13,14 @@ org.gradle.parallel=true
# build with the same inputs. However, over time, the cache size will
# grow. Uncomment the following line to enable it.
#org.gradle.caching=true
#org.gradle.configuration-cache=true

# Allow AndroidX usage
android.useAndroidX=true

#androidCompileSdkVersion=34
#androidBuildToolsVersion=34.0.0
#androidNdkVersion=26.1.10909125

#qtMinSdkVersion=23
#qtTargetSdkVersion=34
File renamed without changes.
Original file line number Diff line number Diff line change
Expand Up @@ -89,6 +89,11 @@ else if(action.equals(BluetoothDevice.ACTION_ACL_DISCONNECTED))
IntentFilter bluetoothFilter = new IntentFilter();
bluetoothFilter.addAction(BluetoothDevice.ACTION_ACL_CONNECTED);
bluetoothFilter.addAction(BluetoothDevice.ACTION_ACL_DISCONNECTED);
// if(android.os.Build.VERSION.SDK_INT >= android.os.Build.VERSION_CODES.TIRAMISU) {
// _instance.registerReceiver(_instance._usbReceiver, filter, RECEIVER_EXPORTED);
// } else {
// _instance.registerReceiver(_instance._usbReceiver, filter);
// }
registerReceiver(receiver, bluetoothFilter);

_usbSerialInterface = new UsbSerialInterface(this);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -65,6 +65,11 @@ else if (action.equals(UsbManager.ACTION_USB_DEVICE_ATTACHED))
usbFilter.addAction(UsbManager.ACTION_USB_DEVICE_DETACHED);
usbFilter.addAction(ACTION_USB_PERMISSION);
context.registerReceiver(receiver, usbFilter);
// if(android.os.Build.VERSION.SDK_INT >= android.os.Build.VERSION_CODES.TIRAMISU) {
// _instance.registerReceiver(_instance._usbReceiver, filter, RECEIVER_EXPORTED);
// } else {
// _instance.registerReceiver(_instance._usbReceiver, filter);
// }

_usbDrivers = new ArrayList<UsbSerialDriver>();

Expand Down
44 changes: 22 additions & 22 deletions android/src/AndroidSerial.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -39,13 +39,13 @@ QList<QSerialPortInfo> AndroidSerial::availableDevices()
env->DeleteLocalRef(string);

QSerialPortInfoPrivate priv;
priv.portName = strList.get(0);
priv.device = strList.get(0);
priv.portName = strList.at(0);
priv.device = strList.at(0);
priv.description = "";
priv.manufacturer = strList.get(1);
priv.manufacturer = strList.at(1);
priv.serialNumber = "";
priv.vendorIdentifier = strList.get(3).toInt();
priv.productIdentifier = strList.get(2).toInt();
priv.vendorIdentifier = strList.at(3).toInt();
priv.productIdentifier = strList.at(2).toInt();
priv.hasVendorIdentifier = (priv.vendorIdentifier != 0) ? true: false;
priv.hasProductIdentifier = (priv.productIdentifier != 0) ? true: false;

Expand Down Expand Up @@ -157,55 +157,55 @@ void AndroidSerial::setParameters(int deviceId, int baudRate, int dataBits, int
AndroidInterface::cleanJavaException();
}

int AndroidSerial::getCarrierDetect(int deviceId)
bool AndroidSerial::getCarrierDetect(int deviceId)
{
AndroidInterface::cleanJavaException();
const int result = QJniObject::callStaticMethod<jint>(
const bool result = QJniObject::callStaticMethod<jint>(
AndroidInterface::getQGCActivityClassName(),
"getCarrierDetect",
"(I)I",
"(I)Z",
deviceId
);
AndroidInterface::cleanJavaException();

return result;
}

int AndroidSerial::getClearToSend(int deviceId)
bool AndroidSerial::getClearToSend(int deviceId)
{
AndroidInterface::cleanJavaException();
const int result = QJniObject::callStaticMethod<jint>(
const bool result = QJniObject::callStaticMethod<jint>(
AndroidInterface::getQGCActivityClassName(),
"getClearToSend",
"(I)I",
"(I)Z",
deviceId
);
AndroidInterface::cleanJavaException();

return result;
}

int AndroidSerial::getDataSetReady(int deviceId)
bool AndroidSerial::getDataSetReady(int deviceId)
{
AndroidInterface::cleanJavaException();
const int result = QJniObject::callStaticMethod<jint>(
const bool result = QJniObject::callStaticMethod<jint>(
AndroidInterface::getQGCActivityClassName(),
"getDataSetReady",
"(I)I",
"(I)Z",
deviceId
);
AndroidInterface::cleanJavaException();

return result;
}

int AndroidSerial::getDataTerminalReady(int deviceId)
bool AndroidSerial::getDataTerminalReady(int deviceId)
{
AndroidInterface::cleanJavaException();
const int result = QJniObject::callStaticMethod<jint>(
const bool result = QJniObject::callStaticMethod<jint>(
AndroidInterface::getQGCActivityClassName(),
"getDataTerminalReady",
"(I)I",
"(I)Z",
deviceId
);
AndroidInterface::cleanJavaException();
Expand All @@ -226,13 +226,13 @@ void AndroidSerial::setDataTerminalReady(int deviceId, bool set)
AndroidInterface::cleanJavaException();
}

int AndroidSerial::getRequestToSend(int deviceId)
bool AndroidSerial::getRequestToSend(int deviceId)
{
AndroidInterface::cleanJavaException();
const int result = QJniObject::callStaticMethod<jint>(
const bool result = QJniObject::callStaticMethod<jint>(
AndroidInterface::getQGCActivityClassName(),
"getRequestToSend",
"(I)I",
"(I)Z",
deviceId
);
AndroidInterface::cleanJavaException();
Expand Down Expand Up @@ -275,7 +275,7 @@ void AndroidSerial::setBreak(int deviceId, bool set)
"setBreak",
"(IZ)V",
deviceId,
input,
set
);
AndroidInterface::cleanJavaException();
}
}
6 changes: 3 additions & 3 deletions android/src/AndroidSerial.h
Original file line number Diff line number Diff line change
Expand Up @@ -9,9 +9,9 @@ class AndroidSerial
public:
static void onNewData(int deviceId, QByteArray data);
static QList<QSerialPortInfo> availableDevices();
static int open(int deviceId);
static void close(int deviceId);
static bool isOpen(int deviceId);
static int open(QString portName);
static void close(QString portName);
static bool isOpen(QString portName);
static QByteArray read(int deviceId, int length, int timeout);
static void write(int deviceId, QByteArrayView data, int length, int timeout, bool async);
static void setParameters(int deviceId, int baudRate, int dataBits, int stopBits, int parity);
Expand Down
13 changes: 5 additions & 8 deletions android/src/CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -1,10 +1,10 @@
find_package(Qt6 REQUIRED COMPONENTS Core)
find_package(Qt6 REQUIRED COMPONENTS Core SerialPort)

qt_add_library(qgcandroid
STATIC
${CMAKE_CURRENT_SOURCE_DIR}/AndroidInit.cpp
${CMAKE_CURRENT_SOURCE_DIR}/AndroidInterface.cc ${CMAKE_CURRENT_SOURCE_DIR}/AndroidInterface.h
${CMAKE_CURRENT_SOURCE_DIR}/AndroidSerial.cpp ${CMAKE_CURRENT_SOURCE_DIR}/AndroidSerial.h
AndroidInit.cpp
AndroidInterface.cc AndroidInterface.h
AndroidSerial.cpp AndroidSerial.h
)

target_link_libraries(qgcandroid
Expand All @@ -16,7 +16,4 @@ target_link_libraries(qgcandroid
Qt6::SerialPort
)

target_include_directories(qgcandroid
PUBLIC
${CMAKE_CURRENT_SOURCE_DIR}
)
target_include_directories(qgcandroid PUBLIC ${CMAKE_CURRENT_SOURCE_DIR})
15 changes: 2 additions & 13 deletions src/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -85,19 +85,8 @@ target_link_libraries(qgc
target_include_directories(qgc PUBLIC ${CMAKE_CURRENT_SOURCE_DIR})

if(ANDROID)
target_sources(qgc
PUBLIC
${CMAKE_SOURCE_DIR}/android/src/AndroidInit.cpp
${CMAKE_SOURCE_DIR}/android/src/AndroidInterface.cc
${CMAKE_SOURCE_DIR}/android/src/AndroidInterface.h
)

target_link_libraries(qgc
PUBLIC
qtandroidserialport
)

target_include_directories(qgc PUBLIC ${CMAKE_SOURCE_DIR}/android/src)
add_subdirectory(${CMAKE_SOURCE_DIR}/android qgcandroid.build)
target_link_libraries(qgc PUBLIC qgcandroid)
else()
target_sources(qgc
PRIVATE
Expand Down

0 comments on commit 4068d97

Please sign in to comment.