Skip to content

Commit

Permalink
Android support for serial/bluetooth disabling
Browse files Browse the repository at this point in the history
  • Loading branch information
DonLakeFlyer committed Aug 8, 2023
1 parent 7b49824 commit f9ac752
Show file tree
Hide file tree
Showing 4 changed files with 32 additions and 11 deletions.
4 changes: 4 additions & 0 deletions QGCCommon.pri
Original file line number Diff line number Diff line change
Expand Up @@ -141,6 +141,10 @@ linux|macx|ios {
}
}

NoSerialBuild {
message("Serial port support disabled")
}

!MacBuild:!AndroidBuild {
# See QGCPostLinkCommon.pri for details on why MacBuild doesn't use DESTDIR
DESTDIR = staging
Expand Down
21 changes: 19 additions & 2 deletions android.pri
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,9 @@ QT += androidextras

ANDROID_PACKAGE_SOURCE_DIR = $$PWD/android

android_source_dir_target.commands = echo Updating Android Manifest
android_source_dir_target.depends = FORCE

exists($$PWD/custom/android) {
message("Merging $$PWD/custom/android/ -> $$PWD/android/")

Expand All @@ -12,11 +15,25 @@ exists($$PWD/custom/android) {
PRE_TARGETDEPS += $$android_source_dir_target.target
QMAKE_EXTRA_TARGETS += android_source_dir_target

android_source_dir_target.commands = $$QMAKE_MKDIR $$ANDROID_PACKAGE_SOURCE_DIR && \
android_source_dir_target.commands = $$android_source_dir_target.commands && \
$$QMAKE_MKDIR $$ANDROID_PACKAGE_SOURCE_DIR && \
$$QMAKE_COPY_DIR $$PWD/android/* $$OUT_PWD/ANDROID_PACKAGE_SOURCE_DIR && \
$$QMAKE_COPY_DIR $$PWD/custom/android/* $$OUT_PWD/ANDROID_PACKAGE_SOURCE_DIR && \
$$QMAKE_STREAM_EDITOR -i \"s/package=\\\"org.mavlink.qgroundcontrol\\\"/package=\\\"$$QGC_ANDROID_PACKAGE\\\"/\" $$ANDROID_PACKAGE_SOURCE_DIR/AndroidManifest.xml
android_source_dir_target.depends = FORCE
}

NoSerialBuild {
# No need to add anything to manifest
android_source_dir_target.commands = $$android_source_dir_target.commands && \
$$QMAKE_STREAM_EDITOR -i \"s/<!-- %%QGC_INSERT_ACTIVITY_INTENT_FILTER -->//\" $$ANDROID_PACKAGE_SOURCE_DIR/AndroidManifest.xml
android_source_dir_target.commands = $$android_source_dir_target.commands && \
$$QMAKE_STREAM_EDITOR -i \"s/<!-- %%QGC_INSERT_ACTIVITY_META_DATA -->//\" $$ANDROID_PACKAGE_SOURCE_DIR/AndroidManifest.xml
} else {
# Updates the manifest for usb device support
android_source_dir_target.commands = $$android_source_dir_target.commands && \
$$QMAKE_STREAM_EDITOR -i \"s/<!-- %%QGC_INSERT_ACTIVITY_INTENT_FILTER -->/<action android:name=\\\"android.hardware.usb.action.USB_DEVICE_ATTACHED\\\"\\\/>\r\n<action android:name=\\\"android.hardware.usb.action.USB_DEVICE_DETACHED\\\"\\\/>\r\n<action android:name=\\\"android.hardware.usb.action.USB_ACCESSORY_ATTACHED\\\"\\\/>/\" $$ANDROID_PACKAGE_SOURCE_DIR/AndroidManifest.xml
android_source_dir_target.commands = $$android_source_dir_target.commands && \
$$QMAKE_STREAM_EDITOR -i \"s/<!-- %%QGC_INSERT_ACTIVITY_META_DATA -->/<meta-data android:resource=\\\"@xml\\\/device_filter\\\" android:name=\\\"android.hardware.usb.action.USB_DEVICE_ATTACHED\\\"\\\/>\r\n<meta-data android:resource=\\\"@xml\\\/device_filter\\\" android:name=\\\"android.hardware.usb.action.USB_DEVICE_DETACHED\\\"\\\/>\r\n<meta-data android:resource=\\\"@xml\\\/device_filter\\\" android:name=\\\"android.hardware.usb.action.USB_ACCESSORY_ATTACHED\\\"\\\/>/\" $$ANDROID_PACKAGE_SOURCE_DIR/AndroidManifest.xml
}

exists($$PWD/custom/android/AndroidManifest.xml) {
Expand Down
13 changes: 7 additions & 6 deletions android/AndroidManifest.xml
Original file line number Diff line number Diff line change
Expand Up @@ -13,16 +13,17 @@
<activity android:configChanges="orientation|uiMode|screenLayout|screenSize|smallestScreenSize|layoutDirection|locale|fontScale|keyboard|keyboardHidden|navigation|mcc|mnc|density" android:name="org.mavlink.qgroundcontrol.QGCActivity" android:label="-- %%INSERT_APP_NAME%% --" android:screenOrientation="sensorLandscape" android:launchMode="singleTask" android:keepScreenOn="true">
<intent-filter>
<action android:name="android.intent.action.MAIN"/>
<category android:name="android.intent.category.HOME"/>
<category android:name="android.intent.category.DEFAULT"/>
<category android:name="android.intent.category.LAUNCHER"/>
<action android:name="android.hardware.usb.action.USB_DEVICE_ATTACHED"/>
<action android:name="android.hardware.usb.action.USB_DEVICE_DETACHED"/>
<action android:name="android.bluetooth.device.action.ACL_CONNECTED"/>
<action android:name="android.bluetooth.device.action.ACL_DISCONNECTED"/>
<action android:name="android.hardware.usb.action.USB_ACCESSORY_ATTACHED"/>

<!-- %%QGC_INSERT_ACTIVITY_INTENT_FILTER -->
</intent-filter>
<meta-data android:resource="@xml/device_filter" android:name="android.hardware.usb.action.USB_DEVICE_ATTACHED"/>
<meta-data android:resource="@xml/device_filter" android:name="android.hardware.usb.action.USB_DEVICE_DETACHED"/>
<meta-data android:resource="@xml/device_filter" android:name="android.hardware.usb.action.USB_ACCESSORY_ATTACHED"/>

<!-- %%QGC_INSERT_ACTIVITY_META_DATA -->

<!-- Application arguments -->
<!-- meta-data android:name="android.app.arguments" android:value="arg1 arg2 arg3"/ -->
<!-- Application arguments -->
Expand Down
5 changes: 2 additions & 3 deletions qgroundcontrol.pro
Original file line number Diff line number Diff line change
Expand Up @@ -182,13 +182,12 @@ contains (CONFIG, QGC_DISABLE_PX4_PLUGIN_FACTORY) {

# Bluetooth
contains (DEFINES, QGC_DISABLE_BLUETOOTH) {
message("Skipping support for Bluetooth (manual override from command line)")
message("Bluetooth support disabled (manual override from command line)")
DEFINES -= QGC_ENABLE_BLUETOOTH
} else:exists(user_config.pri):infile(user_config.pri, DEFINES, QGC_DISABLE_BLUETOOTH) {
message("Skipping support for Bluetooth (manual override from user_config.pri)")
message("Bluetooth support disabled (manual override from user_config.pri)")
DEFINES -= QGC_ENABLE_BLUETOOTH
} else:exists(user_config.pri):infile(user_config.pri, DEFINES, QGC_ENABLE_BLUETOOTH) {
message("Including support for Bluetooth (manual override from user_config.pri)")
DEFINES += QGC_ENABLE_BLUETOOTH
}

Expand Down

0 comments on commit f9ac752

Please sign in to comment.