Пример #1
0
        public void HandleScreenChanged(bool active)
        {
            lock (m_clientSync)
            {
                if (m_client == null)
                {
                    return;
                }

                if (active)
                {
                    if (m_clientPaused)
                    {
                        m_clientPaused = false;

                        LogsManager.Instance.Debug("Client has been paused, trying resume VPN...");

                        if (m_client.Resume())
                        {
                            LogsManager.Instance.Debug("Client resumed");
                        }
                        else
                        {
                            LogsManager.Instance.Error("Client resume failed");
                        }
                    }
                }
                else
                {
                    if (OptionsManager.SystemBatterySaver)
                    {
                        LogsManager.Instance.Debug("Battery saver is on, trying to pause VPN...");

                        if (m_client.Pause("screen_off"))
                        {
                            m_clientPaused = true;

                            LogsManager.Instance.Debug("Client paused");
                        }
                        else
                        {
                            LogsManager.Instance.Debug("Client pause failed");
                        }
                    }
                }
            }
        }