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
ae04500d
Commit
ae04500d
authored
Jun 28, 2017
by
Gus Grubba
Committed by
GitHub
Jun 28, 2017
Browse files
Options
Browse Files
Download
Plain Diff
Merge pull request #5355 from dogmaphobic/androidScreenOn
Keep Android screen from sleeping while QGC is running.
parents
30579165
d35a77c1
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
20 additions
and
26 deletions
+20
-26
QGCActivity.java
android/src/org/mavlink/qgroundcontrol/QGCActivity.java
+17
-19
MobileScreenMgr.cc
src/MobileScreenMgr.cc
+3
-7
No files found.
android/src/org/mavlink/qgroundcontrol/QGCActivity.java
View file @
ae04500d
...
...
@@ -44,6 +44,7 @@ import android.hardware.usb.*;
import
android.widget.Toast
;
import
android.util.Log
;
import
android.os.PowerManager
;
import
android.view.WindowManager
;
//-- Text To Speech
import
android.os.Bundle
;
import
android.speech.tts.TextToSpeech
;
...
...
@@ -123,12 +124,27 @@ public class QGCActivity extends QtActivity implements TextToSpeech.OnInitListen
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"
);
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!!!"
);
}
m_instance
.
getWindow
().
addFlags
(
WindowManager
.
LayoutParams
.
FLAG_KEEP_SCREEN_ON
);
}
@Override
protected
void
onDestroy
()
{
try
{
if
(
m_wl
!=
null
)
{
m_wl
.
release
();
Log
.
i
(
TAG
,
"SCREEN_BRIGHT_WAKE_LOCK released."
);
}
m_tts
.
shutdown
();
}
catch
(
Exception
e
)
{
Log
.
e
(
TAG
,
"Exception onDestroy()"
);
}
super
.
onDestroy
();
m_tts
.
shutdown
();
}
public
void
onInit
(
int
status
)
{
...
...
@@ -140,24 +156,6 @@ public class QGCActivity extends QtActivity implements TextToSpeech.OnInitListen
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/MobileScreenMgr.cc
View file @
ae04500d
...
...
@@ -13,13 +13,9 @@
#include <QtAndroidExtras/QtAndroidExtras>
#include <QtAndroidExtras/QAndroidJniObject>
static
const
char
*
kJniClassName
=
"org/mavlink/qgroundcontrol/QGCActivity"
;
//
static const char* kJniClassName = "org/mavlink/qgroundcontrol/QGCActivity";
void
MobileScreenMgr
::
setKeepScreenOn
(
bool
keepScreenOn
)
void
MobileScreenMgr
::
setKeepScreenOn
(
bool
/*keepScreenOn*/
)
{
if
(
keepScreenOn
)
{
QAndroidJniObject
::
callStaticMethod
<
void
>
(
kJniClassName
,
"keepScreenOn"
,
"()V"
);
}
else
{
QAndroidJniObject
::
callStaticMethod
<
void
>
(
kJniClassName
,
"restoreScreenOn"
,
"()V"
);
}
//-- Screen is locked on while QGC is running on Android
}
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