Commit 69c7ebb5 authored by Don Gagne's avatar Don Gagne

Screen sleep control for iOS

parent 0d7fd3ce
......@@ -109,7 +109,6 @@ iOSBuild {
BUNDLE.files = $$files($$PWD/ios/AppIcon*.png) $$PWD/ios/QGCLaunchScreen.xib
QMAKE_BUNDLE_DATA += BUNDLE
LIBS += -framework AVFoundation
OBJECTIVE_SOURCES += src/audio/QGCAudioWorker_iOS.mm
#-- Info.plist (need an "official" one for the App Store)
ForAppStore {
message(App Store Build)
......@@ -365,6 +364,16 @@ HEADERS += \
src/ViewWidgets/ViewWidgetController.h \
}
iOSBuild {
OBJECTIVE_SOURCES += \
src/audio/QGCAudioWorker_iOS.mm \
src/MobileScreenMgr.mm \
}
androidBuild {
SOURCES += src/MobileScreenMgr.cc \
}
SOURCES += \
src/audio/QGCAudioWorker.cpp \
src/CmdLineOptParser.cc \
......
/*=====================================================================
QGroundControl Open Source Ground Control Station
(c) 2009 - 2014 QGROUNDCONTROL PROJECT <http://www.qgroundcontrol.org>
This file is part of the QGROUNDCONTROL project
QGROUNDCONTROL is free software: you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation, either version 3 of the License, or
(at your option) any later version.
QGROUNDCONTROL is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with QGROUNDCONTROL. If not, see <http://www.gnu.org/licenses/>.
======================================================================*/
#include "MobileScreenMgr.h"
#include <QtAndroidExtras/QtAndroidExtras>
#include <QtAndroidExtras/QAndroidJniObject>
void MobileScreenMgr::setKeepScreenOn(bool keepScreenOn)
{
if (keepScreenOn) {
QAndroidJniObject::callStaticMethod<void>(kJniClassName, "keepScreenOn", "()V");
} else {
QAndroidJniObject::callStaticMethod<void>(kJniClassName, "restoreScreenOn", "()V");
}
}
/*=====================================================================
QGroundControl Open Source Ground Control Station
(c) 2009 - 2014 QGROUNDCONTROL PROJECT <http://www.qgroundcontrol.org>
This file is part of the QGROUNDCONTROL project
QGROUNDCONTROL is free software: you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation, either version 3 of the License, or
(at your option) any later version.
QGROUNDCONTROL is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with QGROUNDCONTROL. If not, see <http://www.gnu.org/licenses/>.
======================================================================*/
#ifndef MobileScreenMgr_H
#define MobileScreenMgr_H
#ifdef __mobile__
class MobileScreenMgr {
public:
/// Turns on/off screen sleep on mobile devices
static void setKeepScreenOn(bool keepScreenOn);
};
#endif
#endif
/*=====================================================================
QGroundControl Open Source Ground Control Station
(c) 2009 - 2014 QGROUNDCONTROL PROJECT <http://www.qgroundcontrol.org>
This file is part of the QGROUNDCONTROL project
QGROUNDCONTROL is free software: you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation, either version 3 of the License, or
(at your option) any later version.
QGROUNDCONTROL is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with QGROUNDCONTROL. If not, see <http://www.gnu.org/licenses/>.
======================================================================*/
#include "MobileScreenMgr.h"
#import <Foundation/Foundation.h>
#import <UIKit/UIKit.h>
void MobileScreenMgr::setKeepScreenOn(bool keepScreenOn)
{
[[UIApplication sharedApplication] setIdleTimerDisabled: (keepScreenOn ? YES : NO)];
}
......@@ -30,13 +30,12 @@
#include "UAS.h"
#include "QGCApplication.h"
#include <QQmlEngine>
#if defined __android__
#include <QtAndroidExtras/QtAndroidExtras>
#include <QtAndroidExtras/QAndroidJniObject>
#ifdef __mobile__
#include "MobileScreenMgr.h"
#endif
#include <QQmlEngine>
QGC_LOGGING_CATEGORY(MultiVehicleManagerLog, "MultiVehicleManagerLog")
const char* MultiVehicleManager::_gcsHeartbeatEnabledKey = "gcsHeartbeatEnabled";
......@@ -126,11 +125,11 @@ void MultiVehicleManager::_vehicleHeartbeatInfo(LinkInterface* link, int vehicle
// Mark link as active
link->setActive(true);
#if defined __android__
#ifdef __mobile__
if(_vehicles.count() == 1) {
//-- Once a vehicle is connected, keep Android screen from going off
//-- Once a vehicle is connected, keep screen from going off
qCDebug(MultiVehicleManagerLog) << "QAndroidJniObject::keepScreenOn";
QAndroidJniObject::callStaticMethod<void>(kJniClassName, "keepScreenOn", "()V");
MobileScreenMgr::setKeepScreenOn(true);
}
#endif
......@@ -167,11 +166,11 @@ void MultiVehicleManager::_deleteVehiclePhase1(Vehicle* vehicle)
emit parameterReadyVehicleAvailableChanged(false);
emit vehicleRemoved(vehicle);
#if defined __android__
#ifdef __mobile__
if(_vehicles.count() == 0) {
//-- Once no vehicles are connected, we no longer need to keep Android screen from going off
//-- Once no vehicles are connected, we no longer need to keep screen from going off
qCDebug(MultiVehicleManagerLog) << "QAndroidJniObject::restoreScreenOn";
QAndroidJniObject::callStaticMethod<void>(kJniClassName, "restoreScreenOn", "()V");
MobileScreenMgr::setKeepScreenOn(true);
}
#endif
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment