janbar / osmin

GPS Navigator On-Road/Off-Road for Android and Linux devices

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Pinephone does not stay awake in navigation mode.

AndyM48 opened this issue · comments

I checked the operation in navigation mode: cross hairs turned blue, no route set, and the Pinephone continues to go to sleep.

Pinephone 1.2
Linux 6.4.7
PostmarketOS v28

{sleep-inhibitor} /usr/bin/python3 /usr/bin/sleep-inhibitor

I don't know of any mechanism that allows us to prohibit programmatically sleep on this OS. For instance I implemented that only for Android OS. In Android I had to code a call using JNI.

void PlatformExtras::setPreventBlanking(bool on)
{
  m_preventBlanking = on;

#ifdef Q_OS_ANDROID
  {
    QtAndroid::runOnAndroidThread([on]
    {
      static const int FLAG_KEEP_SCREEN_ON = QAndroidJniObject::getStaticField<jint>("android/view/WindowManager$LayoutParams", "FLAG_KEEP_SCREEN_ON");
      auto window = QtAndroid::androidActivity().callObjectMethod("getWindow", "()Landroid/view/Window;");
      if (on)
        window.callMethod<void>("addFlags", "(I)V", FLAG_KEEP_SCREEN_ON);
      else
        window.callMethod<void>("clearFlags", "(I)V", FLAG_KEEP_SCREEN_ON);
    });
  }
#endif
}

I haven't any device on Pinphone, and so cannot test. But first we have to find the way to do that on this OS.

Having a look in the python script sleep-inhibitor, seems they launch a dummy process with systemd-inihibit or elogind-inhibit, depending of the platform. It is a way, but is the good way ...

See link https://www.freedesktop.org/wiki/Software/systemd/inhibit/
Seems to be the best way, because that uses [logind D-Bus API].

Seems to be working fine now on my system (see above)