=== modified file 'debian/control'
--- debian/control	2016-05-25 06:02:03 +0000
+++ debian/control	2016-06-15 11:06:00 +0000
@@ -65,7 +65,7 @@
 Depends: ${misc:Depends},
          ${shlibs:Depends},
          accountsservice,
-         accountsservice-ubuntu-schemas (>= 0.0.5),
+         accountsservice-ubuntu-schemas (>= 0.0.7),
          aethercast [amd64 armhf i386],
          bluez (>= 5.23),
          click | ubuntu-snappy-cli,
@@ -78,6 +78,7 @@
          indicator-power (>= 12.10.6+15.04.20150130),
          powerd (>= 0.15) | gnome-settings-daemon,
          qmenumodel-qml,
+         qml-module-biometryd,
          qml-module-qt-labs-folderlistmodel,
          qml-module-ubuntu-connectivity (>= 0.7.1),
          qml-module-qtmultimedia | qml-module-qtmultimedia-gles,

=== modified file 'plugins/security-privacy/LockSecurity.qml'
--- plugins/security-privacy/LockSecurity.qml	2016-05-17 23:28:16 +0000
+++ plugins/security-privacy/LockSecurity.qml	2016-06-15 11:06:00 +0000
@@ -1,9 +1,10 @@
 /*
  * This file is part of system-settings
  *
- * Copyright (C) 2013 Canonical Ltd.
+ * Copyright (C) 2013-2015 Canonical Ltd.
  *
  * Contact: Iain Lane <iain.lane@canonical.com>
+ *          Jonas G. Drange <jonas.drange@canonical.com>
  *
  * This program is free software: you can redistribute it and/or modify it
  * under the terms of the GNU General Public License version 3, as published
@@ -17,13 +18,14 @@
  * You should have received a copy of the GNU General Public License along
  * with this program.  If not, see <http://www.gnu.org/licenses/>.
  */
-
+import Biometryd 0.0
 import GSettings 1.0
 import QtQuick 2.4
 import QtQuick.Layouts 1.1
 import Ubuntu.Components 1.3
 import Ubuntu.Components.ListItems 1.3 as ListItem
 import Ubuntu.Components.Popups 1.3
+import Ubuntu.Settings.Fingerprint 0.1
 import Ubuntu.SystemSettings.SecurityPrivacy 1.0
 import SystemSettings 1.0
 
@@ -49,7 +51,8 @@
     }
 
     property var dialog: null
-
+    property int enrolledFingerprints: 0
+    onEnrolledFingerprintsChanged: console.warn(enrolledFingerprints)
     UbuntuSecurityPrivacyPanel {
         id: securityPrivacy
     }
@@ -62,6 +65,8 @@
                 return 1
             case UbuntuSecurityPrivacyPanel.Passphrase:
                 return 2
+            case UbuntuSecurityPrivacyPanel.Fingerprint:
+                return 3
         }
     }
 
@@ -73,6 +78,8 @@
                 return UbuntuSecurityPrivacyPanel.Passcode
             case 2:
                 return UbuntuSecurityPrivacyPanel.Passphrase
+            case 3:
+                return UbuntuSecurityPrivacyPanel.Fingerprint
         }
     }
 
@@ -355,9 +362,14 @@
                     Layout.fillWidth: true
                     text: i18n.tr("Cancel")
                     onClicked: {
-                        PopupUtils.close(changeSecurityDialog)
-                        unlockMethod.selectedIndex =
-                                methodToIndex(securityPrivacy.securityType)
+                        PopupUtils.close(changeSecurityDialog);
+                        var newSelectedIndex;
+                        if (securityPrivacy.enableFingerprintIdentification) {
+                            newSelectedIndex = methodToIndex(UbuntuSecurityPrivacyPanel.Fingerprint);
+                        } else {
+                            newSelectedIndex = methodToIndex(securityPrivacy.securityType);
+                        }
+                        unlockMethod.selectedIndex = newSelectedIndex;
                     }
                 }
 
@@ -416,6 +428,10 @@
                             currentInput.forceActiveFocus()
                             currentInput.selectAll()
                             changeSecurityDialog.enabled = true
+
+                            // We can always safely disable FP ident here, but
+                            // in some cases it is required.
+                            securityPrivacy.enableFingerprintIdentification = false;
                         } else {
                             PopupUtils.close(changeSecurityDialog)
                         }
@@ -448,12 +464,13 @@
                 property string swipe: i18n.tr("Swipe (no security)")
                 property string passcode: i18n.tr("4-digit passcode")
                 property string passphrase: i18n.tr("Passphrase")
+                property string fingerprint: i18n.tr("Fingerprint")
                 property string swipeAlt: i18n.tr("Swipe (no security)… ")
                 property string passcodeAlt: i18n.tr("4-digit passcode…")
                 property string passphraseAlt: i18n.tr("Passphrase…")
 
                 id: unlockMethod
-                model: 3
+                model: Biometryd.available ? 4 : 3
                 delegate: OptionSelectorDelegate {
                     objectName: {
                         switch (index) {
@@ -463,19 +480,58 @@
                                 return "method_code";
                             case 2:
                                 return "method_phrase";
+                            case 3:
+                                return "method_finger";
                             default:
                                 return "method_unknown";
                         }
                     }
-                    text: index == 0 ? (unlockMethod.selectedIndex == 0 ? unlockMethod.swipe : unlockMethod.swipeAlt) :
-                         (index == 1 ? (unlockMethod.selectedIndex == 1 ? unlockMethod.passcode : unlockMethod.passcodeAlt) :
-                                       (unlockMethod.selectedIndex == 2 ? unlockMethod.passphrase : unlockMethod.passphraseAlt))
+                    text: {
+                        var si = unlockMethod.selectedIndex;
+                        switch (index) {
+                        case 0:
+                            return si == 0 ? unlockMethod.swipe : unlockMethod.swipeAlt;
+                        case 1:
+                            return si == 1 ? unlockMethod.passcode : unlockMethod.passcodeAlt;
+                        case 2:
+                            return si == 2 ? unlockMethod.passphrase : unlockMethod.passphraseAlt;
+                        case 3:
+                            return unlockMethod.fingerprint;
+                        }
+                    }
+                    enabled: {
+                        // Fingerprint is the only one we disable, unless the user
+                        // has chosen FP ident and there are more than 0 enrolled
+                        // FPs and there's a pass{code|phrase} set.
+                        var passSet = (securityPrivacy.securityType ===
+                                       UbuntuSecurityPrivacyPanel.Passcode
+                                       || securityPrivacy.securityType ===
+                                       UbuntuSecurityPrivacyPanel.Passphrase);
+                        var haveFps = page.enrolledFingerprints > 0;
+                        return index !== 3 || (haveFps && passSet);
+                    }
                 }
                 expanded: true
                 onDelegateClicked: {
                     if (selectedIndex === index && !changeControl.visible)
                         return // nothing to do
 
+                    // This check is needed for when FP is the chosen method,
+                    // but the user wants to disable FP in favour of the
+                    // securityType already set, for which  there is nothing
+                    // to do, except turn off FP ident.
+                    if (methodToIndex(securityPrivacy.securityType) === index) {
+                        securityPrivacy.enableFingerprintIdentification = false;
+                        return
+                    }
+
+                    // Bail if we enabled FP ident.
+                    if (index === 3) {
+                        // Toggle FP ident.
+                        securityPrivacy.enableFingerprintIdentification = true;
+                        return;
+                    }
+
                     selectedIndex = index
                     openDialog()
                 }
@@ -483,14 +539,22 @@
             Binding {
                 target: unlockMethod
                 property: "selectedIndex"
-                value: methodToIndex(securityPrivacy.securityType)
+                value: {
+                    if (securityPrivacy.enableFingerprintIdentification) {
+                        return methodToIndex(UbuntuSecurityPrivacyPanel.Fingerprint);
+                    } else {
+                        return methodToIndex(securityPrivacy.securityType);
+                    }
+                }
             }
 
             ListItem.SingleControl {
 
                 id: changeControl
-                visible: securityPrivacy.securityType !==
-                            UbuntuSecurityPrivacyPanel.Swipe
+                visible: securityPrivacy.securityType ===
+                         UbuntuSecurityPrivacyPanel.Passcode &&
+                         securityPrivacy.securityType ===
+                         UbuntuSecurityPrivacyPanel.Passphrase
 
                 control: Button {
                     property string changePasscode: i18n.tr("Change passcode…")
@@ -511,4 +575,52 @@
             }
         }
     }
+
+    // This observer is used to decide whether or not to enabled Fingerprint ID
+    // to be selected by the user as a security method.
+    Observer {
+        id: sizeObserver
+        onFailed: {
+            page.enrolledFingerprints = 0;
+            op = null;
+        }
+        onSucceeded: {
+            // FIXME(jgdx): use result, not hard coded value
+            page.enrolledFingerprints = result;
+            op = null;
+        }
+
+        function start () {
+            console.warn('start');
+            op = Biometryd.defaultDevice.templateStore.size(user);
+            op.start(sizeObserver);
+        }
+
+        property var op: null
+
+        Component.onCompleted: {
+            if (Biometryd.available)
+                start();
+        }
+        Component.onDestruction: op && op.cancel();
+    }
+
+    Connections {
+        target: Biometryd
+        onAvailableChanged: {
+            console.warn("onAvailableChanged");
+            if (available) {
+                sizeObserver.start();
+            }
+        }
+    }
+
+    User {
+        id: user
+        uid: fp.uid
+    }
+
+    UbuntuSettingsFingerprint {
+        id: fp
+    }
 }

=== modified file 'plugins/security-privacy/PageComponent.qml'
--- plugins/security-privacy/PageComponent.qml	2016-02-18 15:42:16 +0000
+++ plugins/security-privacy/PageComponent.qml	2016-06-15 11:06:00 +0000
@@ -18,12 +18,14 @@
  * with this program.  If not, see <http://www.gnu.org/licenses/>.
  */
 
+import Biometryd 0.0
 import GSettings 1.0
 import QMenuModel 0.1
 import QtQuick 2.4
 import Ubuntu.Components 1.3
 import Ubuntu.Components.ListItems 1.3 as ListItem
 import SystemSettings 1.0
+import Ubuntu.Settings.Fingerprint 0.1
 import Ubuntu.SystemSettings.Battery 1.0
 import Ubuntu.SystemSettings.Diagnostics 1.0
 import Ubuntu.SystemSettings.SecurityPrivacy 1.0
@@ -151,11 +153,35 @@
                 text: i18n.tr("Security")
             }
             ListItem.SingleValue {
+                id: fingerprintControl
+                objectName: "fingerprintControl"
+                text: i18n.tr("Fingerprint ID")
+                progression: true
+                onClicked: pageStack.push(fingeprintPage, {
+                    passcodeSet: securityPrivacy.securityType !== UbuntuSecurityPrivacyPanel.Swipe
+                })
+                visible: Biometryd.available
+            }
+
+            Component {
+                id: fingeprintPage
+                Fingerprint {
+                    onRequestPasscode: {
+                        pageStack.pop();
+                        pageStack.push(Qt.resolvedUrl("LockSecurity.qml"));
+                    }
+                }
+            }
+
+            ListItem.SingleValue {
                 id: lockingControl
                 objectName: "lockingControl"
                 text: i18n.tr("Locking and unlocking")
                 progression: true
-                onClicked: pageStack.push(Qt.resolvedUrl("PhoneLocking.qml"), {usePowerd: usePowerd, powerSettings: powerSettings})
+                onClicked: pageStack.push(Qt.resolvedUrl("PhoneLocking.qml"), {
+                    usePowerd: usePowerd,
+                    powerSettings: powerSettings
+                })
             }
             ListItem.SingleValue {
                 id: simControl

=== modified file 'plugins/security-privacy/PhoneLocking.qml'
--- plugins/security-privacy/PhoneLocking.qml	2016-05-13 14:10:23 +0000
+++ plugins/security-privacy/PhoneLocking.qml	2016-06-15 11:06:00 +0000
@@ -31,7 +31,7 @@
     title: i18n.tr("Locking and unlocking")
 
     property bool usePowerd
-    property variant powerSettings
+    property var powerSettings
 
     UbuntuSecurityPrivacyPanel {
         id: securityPrivacy
@@ -56,10 +56,13 @@
                 property string swipe: i18n.ctr("Unlock with swipe", "None")
                 property string passcode: i18n.tr("Passcode")
                 property string passphrase: i18n.tr("Passphrase")
+                property string fingerprint: i18n.tr("Fingerprint")
 
                 objectName: "lockSecurity"
                 text: i18n.tr("Lock security")
                 value: {
+                    if (securityPrivacy.enableFingerprintIdentification)
+                        return fingerprint
                     switch (securityPrivacy.securityType) {
                         case UbuntuSecurityPrivacyPanel.Swipe:
                             return swipe
@@ -67,6 +70,8 @@
                             return passcode
                         case UbuntuSecurityPrivacyPanel.Passphrase:
                             return passphrase
+                        case UbuntuSecurityPrivacyPanel.Fingerprint:
+                            return fingerprint
                     }
                 }
                 progression: true

=== modified file 'plugins/security-privacy/securityprivacy.cpp'
--- plugins/security-privacy/securityprivacy.cpp	2015-01-28 15:02:09 +0000
+++ plugins/security-privacy/securityprivacy.cpp	2016-06-15 11:06:00 +0000
@@ -99,6 +99,8 @@
             Q_EMIT enableLauncherWhileLockedChanged();
         } else if (property == "EnableIndicatorsWhileLocked") {
             Q_EMIT enableIndicatorsWhileLockedChanged();
+        } else if (property == "EnableFingerprintIdentification") {
+            Q_EMIT enableFingerprintIdentificationChanged();
         }
     } else if (interface == AS_TOUCH_INTERFACE) {
         if (property == "MessagesWelcomeScreen") {
@@ -118,6 +120,7 @@
 void SecurityPrivacy::slotNameOwnerChanged()
 {
     // Tell QML so that it refreshes its view of the property
+    Q_EMIT enableFingerprintIdentificationChanged();
     Q_EMIT messagesWelcomeScreenChanged();
     Q_EMIT statsWelcomeScreenChanged();
     Q_EMIT enableLauncherWhileLockedChanged();
@@ -126,6 +129,23 @@
     Q_EMIT hereLicensePathChanged();
 }
 
+bool SecurityPrivacy::getEnableFingerprintIdentification()
+{
+    return m_accountsService.getUserProperty(AS_INTERFACE,
+                                             "EnableFingerprintIdentification").toBool();
+}
+
+void SecurityPrivacy::setEnableFingerprintIdentification(bool enabled)
+{
+    if (enabled == getEnableFingerprintIdentification())
+        return;
+
+    m_accountsService.setUserProperty(AS_INTERFACE,
+                                      "EnableFingerprintIdentification",
+                                      QVariant::fromValue(enabled));
+    Q_EMIT(enableFingerprintIdentificationChanged());
+}
+
 bool SecurityPrivacy::getStatsWelcomeScreen()
 {
     return m_accountsService.getUserProperty(AS_TOUCH_INTERFACE,
@@ -381,6 +401,9 @@
         if (!setPasswordModeWithPolicykit(type, oldValue)) {
             setDisplayHint(oldType);
             return badPasswordMessage(oldType);
+        } else {
+            // Successfully enabling Swipe must disable fingerprint auth.
+            setEnableFingerprintIdentification(false);
         }
     } else {
         QString errorText = setPassword(oldValue, value);

=== modified file 'plugins/security-privacy/securityprivacy.h'
--- plugins/security-privacy/securityprivacy.h	2015-01-28 15:02:09 +0000
+++ plugins/security-privacy/securityprivacy.h	2016-06-15 11:06:00 +0000
@@ -40,6 +40,10 @@
 {
     Q_OBJECT
     Q_ENUMS(SecurityType)
+    Q_PROPERTY (bool enableFingerprintIdentification
+                READ getEnableFingerprintIdentification
+                WRITE setEnableFingerprintIdentification
+                NOTIFY enableFingerprintIdentificationChanged)
     Q_PROPERTY (bool statsWelcomeScreen
                 READ getStatsWelcomeScreen
                 WRITE setStatsWelcomeScreen
@@ -71,12 +75,15 @@
     enum SecurityType {
          Swipe,
          Passcode,
-         Passphrase
+         Passphrase,
+         Fingerprint
     };
 
     explicit SecurityPrivacy(QObject *parent = 0);
     virtual ~SecurityPrivacy();
 
+    bool getEnableFingerprintIdentification();
+    void setEnableFingerprintIdentification(bool enabled);
     bool getStatsWelcomeScreen();
     void setStatsWelcomeScreen(bool enabled);
     bool getMessagesWelcomeScreen();
@@ -99,6 +106,7 @@
     void slotNameOwnerChanged();
 
 Q_SIGNALS:
+    void enableFingerprintIdentificationChanged();
     void statsWelcomeScreenChanged();
     void messagesWelcomeScreenChanged();
     void enableLauncherWhileLockedChanged();

