Commit a8635fdc authored by Sarah Hu's avatar Sarah Hu Committed by Commit Bot

cros: Advance fingerprint progress bar when receive a non-ideal scan.

In case of a non-ideal scan (user puts the same area of their finger
over and over again), the percentage goes up and we should advance
progress bar in UI to match Android's behavior.

Bug: 880105, b:112692311
Change-Id: I031eca6c2b2450f651784866ffb7ffa105a25ef1
Reviewed-on: https://chromium-review.googlesource.com/1217912Reviewed-by: default avatarSteven Bennetts <stevenjb@chromium.org>
Commit-Queue: Xiaoyin Hu <xiaoyinh@chromium.org>
Cr-Commit-Position: refs/heads/master@{#590373}
parent 66593c81
...@@ -81,17 +81,9 @@ Polymer({ ...@@ -81,17 +81,9 @@ Polymer({
// First tap on the sensor to start fingerprint enrollment. // First tap on the sensor to start fingerprint enrollment.
if (this.getActiveScreen_() === this.$.placeFinger) { if (this.getActiveScreen_() === this.$.placeFinger) {
this.showScreen_('startFingerprintEnroll'); this.showScreen_('startFingerprintEnroll');
return;
} }
// The fingerprint subsystem has internal limit on the number of attempts this.percentComplete_ = percentComplete;
// no matter successful or failed.
// So it always increases "percentComplete", even if touch attempt was
// unsuccessful. We do not want to modify displayed progress on failed
// scans, so we only advance on success.
if (scanResult === FingerprintResultType.SUCCESS)
this.percentComplete_ = percentComplete;
this.scanResult_ = scanResult; this.scanResult_ = scanResult;
}, },
......
...@@ -53,6 +53,20 @@ Polymer({ ...@@ -53,6 +53,20 @@ Polymer({
* @private * @private
*/ */
step_: {type: Number, value: settings.FingerprintSetupStep.LOCATE_SCANNER}, step_: {type: Number, value: settings.FingerprintSetupStep.LOCATE_SCANNER},
/**
* The percentage of completion that has been received during setup.
* This is used to approximate the progress of the setup.
* The value within [0, 100] represents the percent of enrollment
* completion.
* @type {number}
* @private
*/
percentComplete_: {
type: Number,
value: 0,
observer: 'onProgressChanged_',
},
}, },
/** /**
...@@ -66,15 +80,6 @@ Polymer({ ...@@ -66,15 +80,6 @@ Polymer({
/** @private {?settings.FingerprintBrowserProxy}*/ /** @private {?settings.FingerprintBrowserProxy}*/
browserProxy_: null, browserProxy_: null,
/**
* The percentage of completion that has been received during setup.
* This is used to approximate the progress of the setup.
* The value within [0, 100] represents the percent of enrollment completion.
* @type {number}
* @private
*/
percentComplete_: 0,
/** @override */ /** @override */
attached: function() { attached: function() {
this.addWebUIListener( this.addWebUIListener(
...@@ -117,7 +122,6 @@ Polymer({ ...@@ -117,7 +122,6 @@ Polymer({
reset_: function() { reset_: function() {
this.step_ = settings.FingerprintSetupStep.LOCATE_SCANNER; this.step_ = settings.FingerprintSetupStep.LOCATE_SCANNER;
this.percentComplete_ = 0; this.percentComplete_ = 0;
this.$.arc.reset();
this.clearSensorMessageTimeout_(); this.clearSensorMessageTimeout_();
}, },
...@@ -141,28 +145,19 @@ Polymer({ ...@@ -141,28 +145,19 @@ Polymer({
case settings.FingerprintSetupStep.LOCATE_SCANNER: case settings.FingerprintSetupStep.LOCATE_SCANNER:
this.$.arc.reset(); this.$.arc.reset();
this.step_ = settings.FingerprintSetupStep.MOVE_FINGER; this.step_ = settings.FingerprintSetupStep.MOVE_FINGER;
this.percentComplete_ = 0; this.percentComplete_ = scan.percentComplete;
this.setProblem_(scan.result);
break; break;
case settings.FingerprintSetupStep.MOVE_FINGER: case settings.FingerprintSetupStep.MOVE_FINGER:
if (scan.isComplete) { if (scan.isComplete) {
this.problemMessage_ = ''; this.problemMessage_ = '';
this.step_ = settings.FingerprintSetupStep.READY; this.step_ = settings.FingerprintSetupStep.READY;
this.$.arc.setProgress(
this.percentComplete_, 100 /*currPercentComplete*/,
true /*isComplete*/);
this.clearSensorMessageTimeout_(); this.clearSensorMessageTimeout_();
this.fire('add-fingerprint'); this.fire('add-fingerprint');
} else { } else {
this.setProblem_(scan.result); this.setProblem_(scan.result);
if (scan.result == settings.FingerprintResultType.SUCCESS) {
if (scan.percentComplete > this.percentComplete_) {
this.$.arc.setProgress(
this.percentComplete_, scan.percentComplete,
false /*isComplete*/);
this.percentComplete_ = scan.percentComplete;
}
}
} }
this.percentComplete_ = scan.percentComplete;
break; break;
case settings.FingerprintSetupStep.READY: case settings.FingerprintSetupStep.READY:
break; break;
...@@ -286,5 +281,19 @@ Polymer({ ...@@ -286,5 +281,19 @@ Polymer({
return this.step_ == settings.FingerprintSetupStep.MOVE_FINGER || return this.step_ == settings.FingerprintSetupStep.MOVE_FINGER ||
this.step_ == settings.FingerprintSetupStep.READY; this.step_ == settings.FingerprintSetupStep.READY;
}, },
/**
* Observer for percentComplete_.
* @private
*/
onProgressChanged_: function(newValue, oldValue) {
// Start a new enrollment, so reset all enrollment related states.
if (newValue === 0) {
this.$.arc.reset();
return;
}
this.$.arc.setProgress(oldValue, newValue, newValue === 100);
},
}); });
})(); })();
...@@ -168,7 +168,7 @@ suite('settings-fingerprint-list', function() { ...@@ -168,7 +168,7 @@ suite('settings-fingerprint-list', function() {
// First tap on the sensor to start fingerprint enrollment. // First tap on the sensor to start fingerprint enrollment.
browserProxy.scanReceived( browserProxy.scanReceived(
settings.FingerprintResultType.SUCCESS, false, 20 /* percent */); settings.FingerprintResultType.SUCCESS, false, 20 /* percent */);
assertEquals(0, dialog.percentComplete_); assertEquals(20, dialog.percentComplete_);
assertEquals(settings.FingerprintSetupStep.MOVE_FINGER, dialog.step_); assertEquals(settings.FingerprintSetupStep.MOVE_FINGER, dialog.step_);
assertTrue(dialog.$$('#scannerLocation').hidden); assertTrue(dialog.$$('#scannerLocation').hidden);
assertFalse(dialog.$$('#arc').hidden); assertFalse(dialog.$$('#arc').hidden);
...@@ -177,7 +177,7 @@ suite('settings-fingerprint-list', function() { ...@@ -177,7 +177,7 @@ suite('settings-fingerprint-list', function() {
// problem message should be visible. // problem message should be visible.
browserProxy.scanReceived( browserProxy.scanReceived(
settings.FingerprintResultType.TOO_FAST, false, 20 /* percent */); settings.FingerprintResultType.TOO_FAST, false, 20 /* percent */);
assertEquals(0, dialog.percentComplete_); assertEquals(20, dialog.percentComplete_);
assertEquals( assertEquals(
'visible', 'visible',
window.getComputedStyle(dialog.$$('#messageDiv')).visibility); window.getComputedStyle(dialog.$$('#messageDiv')).visibility);
......
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