MythTV  master
screensaver-android.cpp
Go to the documentation of this file.
1 #include "screensaver-android.h"
2 #include <QtAndroidExtras>
3 #include <mythlogging.h>
4 
5 // call in java is :
6 //
7 // getWindow().addFlags(
8 // WindowManager.
9 // LayoutParams.FLAG_FULLSCREEN |
10 // WindowManager.LayoutParams.FLAG_KEEP_SCREEN_ON);
11 
12 #define LOC QString("ScreenSaverAndroid: ")
13 
14 #define MODE 1
16 {
17  //jint keepScreenOn = QAndroidJniObject::getStaticObjectField<jint>("android/view/WindowManager/", "ACTION_CALL");
18 }
19 
21 {
23 }
24 
26 {
27  QAndroidJniObject activity = QtAndroid::androidActivity();
28  LOG(VB_GENERAL, LOG_INFO, LOC + "disable");
29  if (activity.isValid()) {
30  LOG(VB_GENERAL, LOG_INFO, LOC + "disable 1");
31 #if MODE
32  activity.callMethod<void>("setSuspendSleep", "()V");
33 #else
34  QAndroidJniObject window = activity.callObjectMethod("getWindow", "()Landroid/view/Window;");
35 
36  if (window.isValid()) {
37  const int FLAG_KEEP_SCREEN_ON = 128;
38  //QAndroidJniObject keepScreenOn = QAndroidJniObject::fromString("WindowManager.LayoutParams.FLAG_KEEP_SCREEN_ON");
39  window.callObjectMethod("addFlags", "(I)V", FLAG_KEEP_SCREEN_ON);
40  //window.callMethod<void>("addFlags", "(I)V", FLAG_KEEP_SCREEN_ON);
41  LOG(VB_GENERAL, LOG_INFO, LOC + "disable 2");
42  }
43 #endif
44  }
45 }
46 
48 {
49  QAndroidJniObject activity = QtAndroid::androidActivity();
50  LOG(VB_GENERAL, LOG_INFO, LOC + "restore");
51  if (activity.isValid()) {
52  LOG(VB_GENERAL, LOG_INFO, LOC + "restore 1");
53 #if MODE
54  activity.callMethod<void>("setAllowSleep", "()V");
55 #else
56  QAndroidJniObject window = activity.callObjectMethod("getWindow", "()Landroid/view/Window;");
57  if (window.isValid()) {
58  const int FLAG_KEEP_SCREEN_ON = 128;
59  //QAndroidJniObject keepScreenOn = QAndroidJniObject::fromString("WindowManager.LayoutParams.FLAG_KEEP_SCREEN_ON");
60  window.callObjectMethod("clearFlags", "(I)V", FLAG_KEEP_SCREEN_ON);
61  //window.callMethod<void>("clearFlags", "(I)V", FLAG_KEEP_SCREEN_ON);
62  LOG(VB_GENERAL, LOG_INFO, LOC + "restore 2");
63  }
64 #endif
65  }
66 }
67 
69 {
70  // Wake up the screen saver now.
71  LOG(VB_GENERAL, LOG_INFO, LOC + "reset");
72 }
73 
75 {
76  return false;
77 }
78 
ScreenSaverAndroid::Restore
void Restore(void) override
Definition: screensaver-android.cpp:47
ScreenSaverAndroid::Asleep
bool Asleep(void) override
Definition: screensaver-android.cpp:74
LOG
#define LOG(_MASK_, _LEVEL_, _QSTRING_)
Definition: mythlogging.h:23
ScreenSaverAndroid::~ScreenSaverAndroid
~ScreenSaverAndroid() override
Definition: screensaver-android.cpp:20
mythlogging.h
screensaver-android.h
LOC
#define LOC
Definition: screensaver-android.cpp:12
ScreenSaverAndroid::Reset
void Reset(void) override
Definition: screensaver-android.cpp:68
ScreenSaverAndroid::Disable
void Disable(void) override
Definition: screensaver-android.cpp:25
ScreenSaverAndroid::ScreenSaverAndroid
ScreenSaverAndroid()
Definition: screensaver-android.cpp:15