diff options
author | Val Doroshchuk <valentyn.doroshchuk@qt.io> | 2019-11-13 11:05:48 +0100 |
---|---|---|
committer | Val Doroshchuk <valentyn.doroshchuk@qt.io> | 2019-11-15 12:27:24 +0100 |
commit | 72fdf4b20e916ea87b334be1a35235ac1023e0d8 (patch) | |
tree | dbda2c7df41e137edd9d30fc594ac6ec2842ca52 /src/plugins/android/src/mediacapture/qandroidcamerasession.cpp | |
parent | 1d17e3973dda183545025e6d8f99dc3f219344e5 (diff) |
Android: Don't close camera when recording permission is asked
If camera permission is granted and recording is requested
it also requires recording audio permission.
If it was not granted before the popup will be shown
to ask the user to grant the permission
and the app goes to inactive state,
which destroys the camera handlers.
When the camera is loaded but the app requires additional permissions,
it should not destroy the camera.
Change-Id: Iee3662a7ac3381b0eb29190779b0116f9f64304f
Fixes: QTBUG-79909
Reviewed-by: Volker Hilsheimer <volker.hilsheimer@qt.io>
Diffstat (limited to 'src/plugins/android/src/mediacapture/qandroidcamerasession.cpp')
-rw-r--r-- | src/plugins/android/src/mediacapture/qandroidcamerasession.cpp | 11 |
1 files changed, 10 insertions, 1 deletions
diff --git a/src/plugins/android/src/mediacapture/qandroidcamerasession.cpp b/src/plugins/android/src/mediacapture/qandroidcamerasession.cpp index 6a30e5300..9de3330c7 100644 --- a/src/plugins/android/src/mediacapture/qandroidcamerasession.cpp +++ b/src/plugins/android/src/mediacapture/qandroidcamerasession.cpp @@ -78,6 +78,7 @@ QAndroidCameraSession::QAndroidCameraSession(QObject *parent) , m_captureCanceled(false) , m_currentImageCaptureId(-1) , m_previewCallback(0) + , m_keepActive(false) { m_mediaStorageLocation.addStorageLocation( QMediaStorageLocation::Pictures, @@ -913,7 +914,7 @@ void QAndroidCameraSession::onApplicationStateChanged(Qt::ApplicationState state { switch (state) { case Qt::ApplicationInactive: - if (m_state != QCamera::UnloadedState) { + if (!m_keepActive && m_state != QCamera::UnloadedState) { m_savedState = m_state; close(); m_state = QCamera::UnloadedState; @@ -931,4 +932,12 @@ void QAndroidCameraSession::onApplicationStateChanged(Qt::ApplicationState state } } +bool QAndroidCameraSession::requestRecordingPermission() +{ + m_keepActive = true; + const bool result = qt_androidRequestRecordingPermission(); + m_keepActive = false; + return result; +} + QT_END_NAMESPACE |