Commit b3becbb3 authored by Don Gagne's avatar Don Gagne

Merge pull request #3016 from DonLakeFlyer/iosScreenSleep

Turn off screen sleep if Vehicle connected
parents 3570965f f0529fd1
......@@ -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>
static const char* kJniClassName = "org/qgroundcontrol/qgchelper/UsbDeviceJNI";
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,21 +30,16 @@
#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";
#if defined __android__
static const char* kJniClassName = "org/qgroundcontrol/qgchelper/UsbDeviceJNI";
#endif
MultiVehicleManager::MultiVehicleManager(QGCApplication* app)
: QGCTool(app)
, _activeVehicleAvailable(false)
......@@ -126,11 +121,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 +162,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
......
......@@ -32,17 +32,19 @@ Rectangle {
color: qgcPal.window
anchors.fill: parent
readonly property real _margins: ScreenTools.defaultFontPixelHeight
QGCPalette { id: qgcPal; colorGroupEnabled: true }
QGCFlickable {
anchors.fill: parent
contentWidth: column.width
contentHeight: column.height
contentWidth: column.width + (_margins * 2)
contentHeight: column.height + (_margins * 2)
clip: true
Column {
id: column
anchors.margins: ScreenTools.defaultFontPixelHeight
anchors.margins: _margins
anchors.left: parent.left
anchors.top: parent.top
spacing: ScreenTools.defaultFontPixelHeight
......
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