=== added file 'src/aalcamerainfocontrol.cpp'
--- src/aalcamerainfocontrol.cpp	1970-01-01 00:00:00 +0000
+++ src/aalcamerainfocontrol.cpp	2016-02-17 11:01:22 +0000
@@ -0,0 +1,35 @@
+/*
+ * Copyright (C) 2016 Canonical, Ltd.
+ *
+ * This program is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU Lesser General Public License as published by
+ * the Free Software Foundation; version 3.
+ *
+ * This program 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 Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public License
+ * along with this program.  If not, see <http://www.gnu.org/licenses/>.
+ */
+
+#include "aalcamerainfocontrol.h"
+
+#include <QCameraInfo>
+
+AalCameraInfoControl::AalCameraInfoControl(QObject *parent) : QCameraInfoControl(parent)
+{
+}
+
+QCamera::Position AalCameraInfoControl::cameraPosition(const QString &deviceName) const
+{
+    qWarning() << "REQUESTING position info for " << deviceName << QCameraInfo::availableCameras();
+    return QCameraInfo(deviceName.toLatin1()).position();
+}
+
+int AalCameraInfoControl::cameraOrientation(const QString &deviceName) const
+{
+    qWarning() << "REQUESTING orientation info for " << deviceName << QCameraInfo::availableCameras();
+    return QCameraInfo(deviceName.toLatin1()).orientation();
+}

=== added file 'src/aalcamerainfocontrol.h'
--- src/aalcamerainfocontrol.h	1970-01-01 00:00:00 +0000
+++ src/aalcamerainfocontrol.h	2016-02-17 11:01:22 +0000
@@ -0,0 +1,32 @@
+/*
+ * Copyright (C) 2016 Canonical, Ltd.
+ *
+ * This program is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU Lesser General Public License as published by
+ * the Free Software Foundation; version 3.
+ *
+ * This program 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 Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public License
+ * along with this program.  If not, see <http://www.gnu.org/licenses/>.
+ */
+
+#ifndef AALCAMERAINFOCONTROL_H
+#define AALCAMERAINFOCONTROL_H
+
+#include <QCameraInfoControl>
+
+class AalCameraInfoControl : public QCameraInfoControl
+{
+    Q_OBJECT
+public:
+    AalCameraInfoControl(QObject *parent = 0);
+
+    QCamera::Position cameraPosition(const QString &deviceName) const;
+    int cameraOrientation(const QString &deviceName) const;
+};
+
+#endif // AALCAMERAINFOCONTROL_H

=== modified file 'src/aalcameraservice.cpp'
--- src/aalcameraservice.cpp	2016-01-12 12:04:31 +0000
+++ src/aalcameraservice.cpp	2016-02-17 11:01:22 +0000
@@ -27,6 +27,7 @@
 #include "aalvideoencodersettingscontrol.h"
 #include "aalvideorenderercontrol.h"
 #include "aalviewfindersettingscontrol.h"
+#include "aalcamerainfocontrol.h"
 #include "storagemanager.h"
 #include "aalcameraexposurecontrol.h"
 
@@ -60,6 +61,7 @@
     m_videoOutput = new AalVideoRendererControl(this);
     m_viewfinderControl = new AalViewfinderSettingsControl(this);
     m_exposureControl = new AalCameraExposureControl(this);
+    m_infoControl = new AalCameraInfoControl(this);
 
     QGuiApplication* application = qobject_cast<QGuiApplication*>(QGuiApplication::instance());
     m_previousApplicationState = application->applicationState();
@@ -84,6 +86,7 @@
     delete m_videoOutput;
     delete m_viewfinderControl;
     delete m_exposureControl;
+    delete m_infoControl;
     if (m_androidControl)
         android_camera_delete(m_androidControl);
     delete m_storageManager;
@@ -130,6 +133,9 @@
     if (qstrcmp(name, QCameraExposureControl_iid) == 0)
         return m_exposureControl;
 
+    if (qstrcmp(name, QCameraInfoControl_iid) == 0)
+        return m_infoControl;
+
     return 0;
 }
 
@@ -153,21 +159,17 @@
     if (m_androidControl)
         return true;
 
-    CameraType device = BACK_FACING_CAMERA_TYPE;
-    if (!isBackCameraUsed())
-        device = FRONT_FACING_CAMERA_TYPE;
-
     m_androidListener = new CameraControlListener;
     memset(m_androidListener, 0, sizeof(*m_androidListener));
 
-    m_androidControl = android_camera_connect_to(device, m_androidListener);
-
-    // fallback if there is only one camera
-    if (!m_androidControl && m_deviceSelectControl->deviceCount() == 1) {
-        if (device == BACK_FACING_CAMERA_TYPE)
+    // if there is only one camera fallback directly to the ID of whatever device we have
+    if (m_deviceSelectControl->deviceCount() == 1) {
+        android_camera_connect_by_id(m_deviceSelectControl->selectedDevice(), m_androidListener);
+    } else {
+        CameraType device = BACK_FACING_CAMERA_TYPE;
+        if (!isBackCameraUsed())
             device = FRONT_FACING_CAMERA_TYPE;
-        else
-            device = BACK_FACING_CAMERA_TYPE;
+
         m_androidControl = android_camera_connect_to(device, m_androidListener);
     }
 
@@ -232,7 +234,9 @@
 
 bool AalCameraService::isBackCameraUsed() const
 {
-    return m_deviceSelectControl->selectedDevice() == 0;
+    int deviceIndex = m_deviceSelectControl->selectedDevice();
+    QString deviceName = m_deviceSelectControl->deviceName(deviceIndex);
+    return m_infoControl->cameraPosition(deviceName) == QCamera::BackFace;
 }
 
 /*!

=== modified file 'src/aalcameraservice.h'
--- src/aalcameraservice.h	2015-12-16 11:22:04 +0000
+++ src/aalcameraservice.h	2016-02-17 11:01:22 +0000
@@ -34,6 +34,7 @@
 class AalVideoRendererControl;
 class AalViewfinderSettingsControl;
 class AalCameraExposureControl;
+class AalCameraInfoControl;
 class QCameraControl;
 
 struct CameraControl;
@@ -64,6 +65,7 @@
     AalVideoRendererControl *videoOutputControl() const { return m_videoOutput; }
     AalViewfinderSettingsControl *viewfinderControl() const { return m_viewfinderControl; }
     AalCameraExposureControl *exposureControl() const { return m_exposureControl; }
+    AalCameraInfoControl *infoControl() const { return m_infoControl; }
 
     CameraControl *androidControl();
 
@@ -110,6 +112,7 @@
     AalVideoRendererControl *m_videoOutput;
     AalViewfinderSettingsControl *m_viewfinderControl;
     AalCameraExposureControl *m_exposureControl;
+    AalCameraInfoControl *m_infoControl;
 
     CameraControl *m_androidControl;
     CameraControlListener *m_androidListener;

=== modified file 'src/aalcameraserviceplugin.cpp'
--- src/aalcameraserviceplugin.cpp	2013-03-12 16:17:37 +0000
+++ src/aalcameraserviceplugin.cpp	2016-02-17 11:01:22 +0000
@@ -21,6 +21,10 @@
 #include <QMetaType>
 #include <qgl.h>
 
+#include <hybris/camera/camera_compatibility_layer.h>
+#include <hybris/camera/camera_compatibility_layer_capabilities.h>
+
+
 AalServicePlugin::AalServicePlugin()
 {
 }
@@ -42,13 +46,65 @@
 
 QList<QByteArray> AalServicePlugin::devices(const QByteArray &service) const
 {
-    Q_UNUSED(service);
-    return QList<QByteArray>();
+    QList<QByteArray> deviceList;
+
+    if (QString::fromLatin1(service) != QLatin1String(Q_MEDIASERVICE_CAMERA)) {
+        return deviceList;
+    }
+
+    // Devices are identified in android only by their index, so we do the same
+    int cameras = android_camera_get_number_of_devices();
+    for (int deviceId = 0; deviceId < cameras; deviceId++) {
+        QString camera("%1");
+        camera = camera.arg(deviceId);
+        deviceList.append(camera.toLatin1());
+    }
+
+    return deviceList;
 }
 
 QString AalServicePlugin::deviceDescription(const QByteArray &service, const QByteArray &device)
 {
-    Q_UNUSED(service);
-    Q_UNUSED(device);
-    return QString();
+    if (QString::fromLatin1(service) != QLatin1String(Q_MEDIASERVICE_CAMERA)) {
+        return QString();
+    }
+
+    // Android does not provice a descriptive identifier for devices, so we just send back the index
+    // after checking that it is a valid one.
+    bool ok;
+    int deviceID = device.toInt(&ok, 10);
+    if (!ok || deviceID >= android_camera_get_number_of_devices()) {
+        qWarning() << "Requested description for invalid device ID:" << device;
+        return QString();
+    } else {
+        return QString("Camera %1").arg(QLatin1String(device));
+    }
+}
+
+int AalServicePlugin::cameraOrientation(const QByteArray & device) const
+{
+    int facing;
+    int orientation;
+
+    bool ok;
+    int deviceID = device.toInt(&ok, 10);
+    if (!ok) return 0;
+
+    int result = android_camera_get_device_info(deviceID, &facing, &orientation);
+    return (result != 0) ? 0 : orientation;
+}
+
+QCamera::Position AalServicePlugin::cameraPosition(const QByteArray & device) const
+{
+    int facing;
+    int orientation;
+
+    bool ok;
+    int deviceID = device.toInt(&ok, 10);
+    if (!ok) return QCamera::UnspecifiedPosition;
+
+    int result = android_camera_get_device_info(deviceID, &facing, &orientation);
+    return (result != 0) ? QCamera::UnspecifiedPosition :
+                           (facing == BACK_FACING_CAMERA_TYPE ? QCamera::BackFace :
+                                                                QCamera::FrontFace);
 }

=== modified file 'src/aalcameraserviceplugin.h'
--- src/aalcameraserviceplugin.h	2013-02-11 15:56:21 +0000
+++ src/aalcameraserviceplugin.h	2016-02-17 11:01:22 +0000
@@ -20,10 +20,12 @@
 #include <QMediaServiceProviderPlugin>
 
 class AalServicePlugin : public QMediaServiceProviderPlugin,
-                         public QMediaServiceSupportedDevicesInterface
+                         public QMediaServiceSupportedDevicesInterface,
+                         public QMediaServiceCameraInfoInterface
 {
     Q_OBJECT
     Q_INTERFACES(QMediaServiceSupportedDevicesInterface)
+    Q_INTERFACES(QMediaServiceCameraInfoInterface)
     Q_PLUGIN_METADATA(IID "org.qt-project.qt.mediaserviceproviderfactory/5.0" FILE "aalcamera.json")
 
 public:
@@ -34,6 +36,8 @@
 
     QList<QByteArray> devices(const QByteArray &service) const;
     QString deviceDescription(const QByteArray &service, const QByteArray &device);
+    int cameraOrientation(const QByteArray & device) const;
+    QCamera::Position cameraPosition(const QByteArray & device) const;
 };
 
 #endif

=== modified file 'src/aalvideodeviceselectorcontrol.cpp'
--- src/aalvideodeviceselectorcontrol.cpp	2015-12-07 15:16:51 +0000
+++ src/aalvideodeviceselectorcontrol.cpp	2016-02-17 11:01:22 +0000
@@ -23,6 +23,7 @@
 
 #include <QDebug>
 #include <QtMultimedia/QCamera>
+#include <QtMultimedia/QCameraInfo>
 
 #include <hybris/camera/camera_compatibility_layer_capabilities.h>
 
@@ -41,28 +42,17 @@
 
 int AalVideoDeviceSelectorControl::deviceCount() const
 {
-    if (m_numberOfCameras < 0)
-        m_numberOfCameras = android_camera_get_number_of_devices();
-
-    return m_numberOfCameras;
+    return QCameraInfo::availableCameras().count();
 }
 
 QString AalVideoDeviceSelectorControl::deviceDescription(int index) const
 {
-    switch (index) {
-    case 0: return QLatin1String("Back camera");
-    case 1: return QLatin1String("Front camera");
-    default: return QLatin1String("");
-    }
+    return QCameraInfo::availableCameras().value(index).description();
 }
 
 QString AalVideoDeviceSelectorControl::deviceName(int index) const
 {
-    switch (index) {
-    case 0: return QLatin1String("Back");
-    case 1: return QLatin1String("Front");
-    default: return QLatin1String("");
-    }
+    return QCameraInfo::availableCameras().value(index).deviceName();
 }
 
 int AalVideoDeviceSelectorControl::selectedDevice() const

=== modified file 'src/src.pro'
--- src/src.pro	2015-11-12 10:32:24 +0000
+++ src/src.pro	2016-02-17 11:01:22 +0000
@@ -29,6 +29,7 @@
     aalvideoencodersettingscontrol.h \
     aalvideorenderercontrol.h \
     aalviewfindersettingscontrol.h \
+    aalcamerainfocontrol.h \
     audiocapture.h \
     aalcameraexposurecontrol.h \
     storagemanager.h
@@ -48,6 +49,7 @@
     aalvideoencodersettingscontrol.cpp \
     aalvideorenderercontrol.cpp \
     aalviewfindersettingscontrol.cpp \
+    aalcamerainfocontrol.cpp \
     audiocapture.cpp \
     aalcameraexposurecontrol.cpp \
     storagemanager.cpp

