MythTV master
mythscreensaverandroid.cpp
Go to the documentation of this file.
3#if QT_VERSION < QT_VERSION_CHECK(6,0,0)
4#include <QtAndroidExtras>
5#else
6#include <QCoreApplication>
7#include <QJniObject>
8#define QAndroidJniObject QJniObject
9#endif
10
11// call in java is :
12//
13// getWindow().addFlags(
14// WindowManager.
15// LayoutParams.FLAG_FULLSCREEN |
16// WindowManager.LayoutParams.FLAG_KEEP_SCREEN_ON);
17
18#define LOC QString("ScreenSaverAndroid: ")
19
21 : MythScreenSaver(Parent)
22{
23}
24
26{
28}
29
31{
32#if QT_VERSION < QT_VERSION_CHECK(6,0,0)
33 QAndroidJniObject activity = QtAndroid::androidActivity();
34#else
35 QJniObject activity = QNativeInterface::QAndroidApplication::context();
36#endif
37 if (!activity.isValid())
38 {
39 LOG(VB_GENERAL, LOG_ERR, LOC + "Screen Saver Disable: activity is not valid");
40 return;
41 }
42 QAndroidJniObject::callStaticMethod<void>(
43 "org/mythtv/Utility",
44 "setSuspendSleep",
45 "(Landroid/app/Activity;)V",
46 activity.object()
47 );
48 LOG(VB_GENERAL, LOG_INFO, LOC + "Screen Saver Disabled");
49}
50
52{
53#if QT_VERSION < QT_VERSION_CHECK(6,0,0)
54 QAndroidJniObject activity = QtAndroid::androidActivity();
55#else
56 QJniObject activity = QNativeInterface::QAndroidApplication::context();
57#endif
58 if (!activity.isValid())
59 {
60 LOG(VB_GENERAL, LOG_ERR, LOC + "Screen Saver Restore: activity is not valid");
61 return;
62 }
63 QAndroidJniObject::callStaticMethod<void>(
64 "org/mythtv/Utility",
65 "setAllowSleep",
66 "(Landroid/app/Activity;)V",
67 activity.object()
68 );
69 LOG(VB_GENERAL, LOG_INFO, LOC + "Screen Saver Restored");
70}
71
73{
74 // Wake up the screen saver now.
75 LOG(VB_GENERAL, LOG_INFO, LOC + "reset");
76}
77
79{
80 return false;
81}
82
83#include "moc_mythscreensaverandroid.cpp"
MythScreenSaverAndroid(QObject *Parent)
Base Class for screensavers.
#define LOG(_MASK_, _LEVEL_, _QSTRING_)
Definition: mythlogging.h:39
#define LOC
#define QAndroidJniObject