use of android.hardware.fingerprint.Fingerprint in project android_frameworks_base by DirtyUnicorns.
the class FingerprintsUserState method doWriteState.
private void doWriteState() {
AtomicFile destination = new AtomicFile(mFile);
ArrayList<Fingerprint> fingerprints;
synchronized (this) {
fingerprints = getCopy(mFingerprints);
}
FileOutputStream out = null;
try {
out = destination.startWrite();
XmlSerializer serializer = Xml.newSerializer();
serializer.setOutput(out, "utf-8");
serializer.setFeature("http://xmlpull.org/v1/doc/features.html#indent-output", true);
serializer.startDocument(null, true);
serializer.startTag(null, TAG_FINGERPRINTS);
final int count = fingerprints.size();
for (int i = 0; i < count; i++) {
Fingerprint fp = fingerprints.get(i);
serializer.startTag(null, TAG_FINGERPRINT);
serializer.attribute(null, ATTR_FINGER_ID, Integer.toString(fp.getFingerId()));
serializer.attribute(null, ATTR_NAME, fp.getName().toString());
serializer.attribute(null, ATTR_GROUP_ID, Integer.toString(fp.getGroupId()));
serializer.attribute(null, ATTR_DEVICE_ID, Long.toString(fp.getDeviceId()));
serializer.endTag(null, TAG_FINGERPRINT);
}
serializer.endTag(null, TAG_FINGERPRINTS);
serializer.endDocument();
destination.finishWrite(out);
// Any error while writing is fatal.
} catch (Throwable t) {
Slog.wtf(TAG, "Failed to write settings, restoring backup", t);
destination.failWrite(out);
throw new IllegalStateException("Failed to write fingerprints", t);
} finally {
IoUtils.closeQuietly(out);
}
}
use of android.hardware.fingerprint.Fingerprint in project android_frameworks_base by DirtyUnicorns.
the class FingerprintsUserState method renameFingerprint.
public void renameFingerprint(int fingerId, CharSequence name) {
synchronized (this) {
for (int i = 0; i < mFingerprints.size(); i++) {
if (mFingerprints.get(i).getFingerId() == fingerId) {
Fingerprint old = mFingerprints.get(i);
mFingerprints.set(i, new Fingerprint(name, old.getGroupId(), old.getFingerId(), old.getDeviceId()));
scheduleWriteStateLocked();
break;
}
}
}
}
use of android.hardware.fingerprint.Fingerprint in project android_frameworks_base by DirtyUnicorns.
the class FingerprintsUserState method getCopy.
private ArrayList<Fingerprint> getCopy(ArrayList<Fingerprint> array) {
ArrayList<Fingerprint> result = new ArrayList<Fingerprint>(array.size());
for (int i = 0; i < array.size(); i++) {
Fingerprint fp = array.get(i);
result.add(new Fingerprint(fp.getName(), fp.getGroupId(), fp.getFingerId(), fp.getDeviceId()));
}
return result;
}
use of android.hardware.fingerprint.Fingerprint in project android_frameworks_base by DirtyUnicorns.
the class AuthenticationClient method onAuthenticated.
@Override
public boolean onAuthenticated(int fingerId, int groupId) {
boolean result = false;
boolean authenticated = fingerId != 0;
IFingerprintServiceReceiver receiver = getReceiver();
if (receiver != null) {
try {
MetricsLogger.action(getContext(), MetricsEvent.ACTION_FINGERPRINT_AUTH, authenticated);
if (!authenticated) {
receiver.onAuthenticationFailed(getHalDeviceId());
} else {
if (DEBUG) {
Slog.v(TAG, "onAuthenticated(owner=" + getOwnerString() + ", id=" + fingerId + ", gp=" + groupId + ")");
}
Fingerprint fp = !getIsRestricted() ? new Fingerprint("", /* TODO */
groupId, fingerId, getHalDeviceId()) : null;
receiver.onAuthenticationSucceeded(getHalDeviceId(), fp, getTargetUserId());
}
} catch (RemoteException e) {
Slog.w(TAG, "Failed to notify Authenticated:", e);
// client failed
result = true;
}
} else {
// client not listening
result = true;
}
if (!authenticated) {
if (receiver != null) {
FingerprintUtils.vibrateFingerprintError(getContext());
}
// allow system-defined limit of number of attempts before giving up
boolean inLockoutMode = handleFailedAttempt();
// send lockout event in case driver doesn't enforce it.
if (inLockoutMode) {
try {
Slog.w(TAG, "Forcing lockout (fp driver code should do this!)");
receiver.onError(getHalDeviceId(), FingerprintManager.FINGERPRINT_ERROR_LOCKOUT);
} catch (RemoteException e) {
Slog.w(TAG, "Failed to notify lockout:", e);
}
}
result |= inLockoutMode;
} else {
if (receiver != null) {
FingerprintUtils.vibrateFingerprintSuccess(getContext());
}
// we have a valid fingerprint, done
result |= true;
resetFailedAttempts();
}
return result;
}
use of android.hardware.fingerprint.Fingerprint in project android_frameworks_base by DirtyUnicorns.
the class FingerprintService method startEnrollment.
private void startEnrollment(IBinder token, byte[] cryptoToken, int userId, IFingerprintServiceReceiver receiver, int flags, boolean restricted, String opPackageName) {
updateActiveGroup(userId, opPackageName);
// default group for fingerprint enrollment
final int groupId = userId;
EnrollClient client = new EnrollClient(getContext(), mHalDeviceId, token, receiver, userId, groupId, cryptoToken, restricted, opPackageName) {
@Override
public IFingerprintDaemon getFingerprintDaemon() {
return FingerprintService.this.getFingerprintDaemon();
}
@Override
public void notifyUserActivity() {
FingerprintService.this.userActivity();
}
};
startClient(client, true);
}
Aggregations