Commit 1a1a7f61 authored by Sarah Hu's avatar Sarah Hu Committed by Commit Bot

adopt pref value to enable/disable fingerprint authentication

Bug: 834424
Change-Id: I66544344b31a2fa37ca7ef58cefbc3ffd3beaac0
Reviewed-on: https://chromium-review.googlesource.com/1033797
Commit-Queue: Xiaoyin Hu <xiaoyinh@chromium.org>
Reviewed-by: default avatarAlexander Alekseev <alemate@chromium.org>
Cr-Commit-Position: refs/heads/master@{#554851}
parent 54400200
...@@ -23,7 +23,8 @@ FingerprintStorage::FingerprintStorage(PrefService* pref_service) ...@@ -23,7 +23,8 @@ FingerprintStorage::FingerprintStorage(PrefService* pref_service)
FingerprintStorage::~FingerprintStorage() {} FingerprintStorage::~FingerprintStorage() {}
bool FingerprintStorage::IsFingerprintAuthenticationAvailable() const { bool FingerprintStorage::IsFingerprintAuthenticationAvailable() const {
return !ExceededUnlockAttempts() && IsFingerprintEnabled() && HasRecord(); return !ExceededUnlockAttempts() && IsFingerprintEnabled() &&
AuthenticationEnabled() && HasRecord();
} }
bool FingerprintStorage::HasRecord() const { bool FingerprintStorage::HasRecord() const {
...@@ -42,5 +43,9 @@ bool FingerprintStorage::ExceededUnlockAttempts() const { ...@@ -42,5 +43,9 @@ bool FingerprintStorage::ExceededUnlockAttempts() const {
return unlock_attempt_count() >= kMaximumUnlockAttempts; return unlock_attempt_count() >= kMaximumUnlockAttempts;
} }
bool FingerprintStorage::AuthenticationEnabled() const {
return pref_service_->GetBoolean(prefs::kEnableQuickUnlockFingerprint);
}
} // namespace quick_unlock } // namespace quick_unlock
} // namespace chromeos } // namespace chromeos
...@@ -40,6 +40,9 @@ class FingerprintStorage { ...@@ -40,6 +40,9 @@ class FingerprintStorage {
// Returns true if the user has exceeded fingerprint unlock attempts. // Returns true if the user has exceeded fingerprint unlock attempts.
bool ExceededUnlockAttempts() const; bool ExceededUnlockAttempts() const;
// Returns true if user has enabled fingerprint to unlock device.
bool AuthenticationEnabled() const;
int unlock_attempt_count() const { return unlock_attempt_count_; } int unlock_attempt_count() const { return unlock_attempt_count_; }
private: private:
......
...@@ -30,6 +30,11 @@ class FingerprintStorageUnitTest : public testing::Test { ...@@ -30,6 +30,11 @@ class FingerprintStorageUnitTest : public testing::Test {
records_number); records_number);
} }
void SetAuthenticationPref(bool enabled) {
profile_->GetPrefs()->SetBoolean(prefs::kEnableQuickUnlockFingerprint,
enabled);
}
content::TestBrowserThreadBundle thread_bundle_; content::TestBrowserThreadBundle thread_bundle_;
std::unique_ptr<TestingProfile> profile_; std::unique_ptr<TestingProfile> profile_;
...@@ -77,8 +82,9 @@ TEST_F(FingerprintStorageUnitTest, UnlockAttemptCount) { ...@@ -77,8 +82,9 @@ TEST_F(FingerprintStorageUnitTest, UnlockAttemptCount) {
} }
// Verifies that authentication is not available when // Verifies that authentication is not available when
// 1. No fingerprint records registered // 1. Authentication pref is disabled.
// 2. Too many authentication attempts // 2. No fingerprint records registered.
// 3. Too many authentication attempts.
TEST_F(FingerprintStorageUnitTest, AuthenticationUnAvailable) { TEST_F(FingerprintStorageUnitTest, AuthenticationUnAvailable) {
quick_unlock::FingerprintStorage* fingerprint_storage = quick_unlock::FingerprintStorage* fingerprint_storage =
quick_unlock::QuickUnlockFactory::GetForProfile(profile_.get()) quick_unlock::QuickUnlockFactory::GetForProfile(profile_.get())
...@@ -89,6 +95,10 @@ TEST_F(FingerprintStorageUnitTest, AuthenticationUnAvailable) { ...@@ -89,6 +95,10 @@ TEST_F(FingerprintStorageUnitTest, AuthenticationUnAvailable) {
SetRecords(1); SetRecords(1);
EXPECT_TRUE(fingerprint_storage->HasRecord()); EXPECT_TRUE(fingerprint_storage->HasRecord());
EXPECT_EQ(0, fingerprint_storage->unlock_attempt_count()); EXPECT_EQ(0, fingerprint_storage->unlock_attempt_count());
// Authentication pref is disabled by default.
EXPECT_FALSE(test_api.IsFingerprintAuthenticationAvailable());
SetAuthenticationPref(true /*enabled*/);
EXPECT_TRUE(test_api.IsFingerprintAuthenticationAvailable()); EXPECT_TRUE(test_api.IsFingerprintAuthenticationAvailable());
// No fingerprint records registered makes fingerprint authentication // No fingerprint records registered makes fingerprint authentication
......
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