Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
Q
qgroundcontrol
Project
Project
Details
Activity
Releases
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Boards
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
Valentin Platzgummer
qgroundcontrol
Commits
b166e283
Commit
b166e283
authored
Feb 20, 2016
by
Gus Grubba
Browse files
Options
Browse Files
Download
Plain Diff
Merge pull request #2859 from dogmaphobic/androidStayOn
Android stay on
parents
5850df93
2b23d05c
Changes
3
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
50 additions
and
2 deletions
+50
-2
AndroidManifest.xml
android/AndroidManifest.xml
+1
-1
UsbDeviceJNI.java
android/src/org/qgroundcontrol/qgchelper/UsbDeviceJNI.java
+23
-1
MultiVehicleManager.cc
src/Vehicle/MultiVehicleManager.cc
+26
-0
No files found.
android/AndroidManifest.xml
View file @
b166e283
<?xml version="1.0"?>
<manifest
package=
"org.mavlink.qgroundcontrol"
xmlns:android=
"http://schemas.android.com/apk/res/android"
android:versionName=
"2.8.0"
android:versionCode=
"2152"
android:installLocation=
"auto"
>
<application
android:hardwareAccelerated=
"true"
android:name=
"org.qtproject.qt5.android.bindings.QtApplication"
android:label=
"-- %%INSERT_APP_NAME%% --"
android:icon=
"@drawable/icon"
>
<activity
android:configChanges=
"orientation|uiMode|screenLayout|screenSize|smallestScreenSize|locale|fontScale|keyboard|keyboardHidden|navigation"
android:name=
"org.qgroundcontrol.qgchelper.UsbDeviceJNI"
android:label=
"-- %%INSERT_APP_NAME%% --"
android:screenOrientation=
"sensorLandscape"
android:launchMode=
"singleTask"
>
<activity
android:configChanges=
"orientation|uiMode|screenLayout|screenSize|smallestScreenSize|locale|fontScale|keyboard|keyboardHidden|navigation"
android:name=
"org.qgroundcontrol.qgchelper.UsbDeviceJNI"
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.LAUNCHER"
/>
...
...
android/src/org/qgroundcontrol/qgchelper/UsbDeviceJNI.java
View file @
b166e283
...
...
@@ -43,6 +43,7 @@ import android.content.IntentFilter;
import
android.hardware.usb.*
;
import
android.widget.Toast
;
import
android.util.Log
;
import
android.os.PowerManager
;
//-- Text To Speech
import
android.os.Bundle
;
import
android.speech.tts.TextToSpeech
;
...
...
@@ -53,7 +54,7 @@ import org.qtproject.qt5.android.bindings.QtApplication;
public
class
UsbDeviceJNI
extends
QtActivity
implements
TextToSpeech
.
OnInitListener
{
public
static
int
BAD_PORT
=
0
;
public
static
int
BAD_PORT
=
0
;
private
static
UsbDeviceJNI
m_instance
;
private
static
UsbManager
m_manager
;
// ANDROID USB HOST CLASS
private
static
List
<
UsbSerialDriver
>
m_devices
;
// LIST OF CURRENT DEVICES
...
...
@@ -65,6 +66,7 @@ public class UsbDeviceJNI extends QtActivity implements TextToSpeech.OnInitListe
private
final
static
ExecutorService
m_Executor
=
Executors
.
newSingleThreadExecutor
();
private
static
final
String
TAG
=
"QGC_UsbDeviceJNI"
;
private
static
TextToSpeech
m_tts
;
private
static
PowerManager
.
WakeLock
m_wl
;
private
final
static
UsbIoManager
.
Listener
m_Listener
=
new
UsbIoManager
.
Listener
()
...
...
@@ -113,6 +115,8 @@ public class UsbDeviceJNI extends QtActivity implements TextToSpeech.OnInitListe
public
void
onCreate
(
Bundle
savedInstanceState
)
{
super
.
onCreate
(
savedInstanceState
);
m_tts
=
new
TextToSpeech
(
this
,
this
);
PowerManager
pm
=
(
PowerManager
)
m_instance
.
getSystemService
(
Context
.
POWER_SERVICE
);
m_wl
=
pm
.
newWakeLock
(
PowerManager
.
SCREEN_BRIGHT_WAKE_LOCK
,
"QGroundControl"
);
}
@Override
...
...
@@ -130,6 +134,24 @@ public class UsbDeviceJNI extends QtActivity implements TextToSpeech.OnInitListe
m_tts
.
speak
(
msg
,
TextToSpeech
.
QUEUE_FLUSH
,
null
);
}
public
static
void
keepScreenOn
()
{
if
(
m_wl
!=
null
)
{
m_wl
.
acquire
();
Log
.
i
(
TAG
,
"SCREEN_BRIGHT_WAKE_LOCK acquired."
);
}
else
{
Log
.
i
(
TAG
,
"SCREEN_BRIGHT_WAKE_LOCK not acquired!!!"
);
}
}
public
static
void
restoreScreenOn
()
{
if
(
m_wl
!=
null
)
{
m_wl
.
release
();
Log
.
i
(
TAG
,
"SCREEN_BRIGHT_WAKE_LOCK released."
);
}
}
/////////////////////////////////////////////////////////////////////////////////////////////////////////
//
// Find all current devices that match the device filter described in the androidmanifest.xml and the
...
...
src/Vehicle/MultiVehicleManager.cc
View file @
b166e283
...
...
@@ -32,10 +32,19 @@
#include <QQmlEngine>
#if defined __android__
#include <QtAndroidExtras/QtAndroidExtras>
#include <QtAndroidExtras/QAndroidJniObject>
#endif
QGC_LOGGING_CATEGORY
(
MultiVehicleManagerLog
,
"MultiVehicleManagerLog"
)
const
char
*
MultiVehicleManager
::
_gcsHeartbeatEnabledKey
=
"gcsHeartbeatEnabled"
;
#if defined __android__
static
const
char
*
kJniClassName
=
"org/qgroundcontrol/qgchelper/UsbDeviceJNI"
;
#endif
MultiVehicleManager
::
MultiVehicleManager
(
QGCApplication
*
app
)
:
QGCTool
(
app
)
,
_activeVehicleAvailable
(
false
)
...
...
@@ -110,6 +119,15 @@ void MultiVehicleManager::_vehicleHeartbeatInfo(LinkInterface* link, int vehicle
emit
vehicleAdded
(
vehicle
);
setActiveVehicle
(
vehicle
);
#if defined __android__
if
(
_vehicles
.
count
()
==
1
)
{
//-- Once a vehicle is connected, keep Android screen from going off
qCDebug
(
MultiVehicleManagerLog
)
<<
"QAndroidJniObject::keepScreenOn"
;
QAndroidJniObject
::
callStaticMethod
<
void
>
(
kJniClassName
,
"keepScreenOn"
,
"()V"
);
}
#endif
}
/// This slot is connected to the Vehicle::allLinksDestroyed signal such that the Vehicle is deleted
...
...
@@ -143,6 +161,14 @@ void MultiVehicleManager::_deleteVehiclePhase1(Vehicle* vehicle)
emit
parameterReadyVehicleAvailableChanged
(
false
);
emit
vehicleRemoved
(
vehicle
);
#if defined __android__
if
(
_vehicles
.
count
()
==
0
)
{
//-- Once no vehicles are connected, we no longer need to keep Android screen from going off
qCDebug
(
MultiVehicleManagerLog
)
<<
"QAndroidJniObject::restoreScreenOn"
;
QAndroidJniObject
::
callStaticMethod
<
void
>
(
kJniClassName
,
"restoreScreenOn"
,
"()V"
);
}
#endif
// We must let the above signals flow through the system as well as get back to the main loop event queue
// before we can actually delete the Vehicle. The reason is that Qml may be holding on the references to it.
// Even though the above signals should unload any Qml which has references, that Qml will not be destroyed
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment