Search in sources :

Example 41 with Fingerprint

use of android.hardware.fingerprint.Fingerprint in project android_frameworks_base by ResurrectionRemix.

the class FingerprintService method dumpInternal.

private void dumpInternal(PrintWriter pw) {
    JSONObject dump = new JSONObject();
    try {
        dump.put("service", "Fingerprint Manager");
        JSONArray sets = new JSONArray();
        for (UserInfo user : UserManager.get(getContext()).getUsers()) {
            final int userId = user.getUserHandle().getIdentifier();
            final int N = mFingerprintUtils.getFingerprintsForUser(mContext, userId).size();
            PerformanceStats stats = mPerformanceMap.get(userId);
            PerformanceStats cryptoStats = mCryptoPerformanceMap.get(userId);
            JSONObject set = new JSONObject();
            set.put("id", userId);
            set.put("count", N);
            set.put("accept", (stats != null) ? stats.accept : 0);
            set.put("reject", (stats != null) ? stats.reject : 0);
            set.put("acquire", (stats != null) ? stats.acquire : 0);
            set.put("lockout", (stats != null) ? stats.lockout : 0);
            // cryptoStats measures statistics about secure fingerprint transactions
            // (e.g. to unlock password storage, make secure purchases, etc.)
            set.put("acceptCrypto", (cryptoStats != null) ? cryptoStats.accept : 0);
            set.put("rejectCrypto", (cryptoStats != null) ? cryptoStats.reject : 0);
            set.put("acquireCrypto", (cryptoStats != null) ? cryptoStats.acquire : 0);
            set.put("lockoutCrypto", (cryptoStats != null) ? cryptoStats.lockout : 0);
            sets.put(set);
        }
        dump.put("prints", sets);
    } catch (JSONException e) {
        Slog.e(TAG, "dump formatting failure", e);
    }
    pw.println(dump);
}
Also used : JSONObject(org.json.JSONObject) JSONArray(org.json.JSONArray) JSONException(org.json.JSONException) UserInfo(android.content.pm.UserInfo) Fingerprint(android.hardware.fingerprint.Fingerprint)

Example 42 with Fingerprint

use of android.hardware.fingerprint.Fingerprint in project android_packages_apps_Settings by LineageOS.

the class FingerprintSettings method getFingerprintPreferenceForUser.

public static Preference getFingerprintPreferenceForUser(Context context, final int userId) {
    final FingerprintManager fpm = Utils.getFingerprintManagerOrNull(context);
    if (fpm == null || !fpm.isHardwareDetected()) {
        Log.v(TAG, "No fingerprint hardware detected!!");
        return null;
    }
    Preference fingerprintPreference = new Preference(context);
    fingerprintPreference.setKey(KEY_FINGERPRINT_SETTINGS);
    fingerprintPreference.setTitle(R.string.security_settings_fingerprint_preference_title);
    final List<Fingerprint> items = fpm.getEnrolledFingerprints(userId);
    final int fingerprintCount = items != null ? items.size() : 0;
    final String clazz;
    if (fingerprintCount > 0) {
        fingerprintPreference.setSummary(context.getResources().getQuantityString(R.plurals.security_settings_fingerprint_preference_summary, fingerprintCount, fingerprintCount));
        clazz = FingerprintSettings.class.getName();
    } else {
        fingerprintPreference.setSummary(R.string.security_settings_fingerprint_preference_summary_none);
        clazz = FingerprintEnrollIntroduction.class.getName();
    }
    fingerprintPreference.setOnPreferenceClickListener(new OnPreferenceClickListener() {

        @Override
        public boolean onPreferenceClick(Preference preference) {
            final Context context = preference.getContext();
            final UserManager userManager = UserManager.get(context);
            if (Utils.startQuietModeDialogIfNecessary(context, userManager, userId)) {
                return false;
            }
            Intent intent = new Intent();
            intent.setClassName("com.android.settings", clazz);
            intent.putExtra(Intent.EXTRA_USER_ID, userId);
            context.startActivity(intent);
            return true;
        }
    });
    return fingerprintPreference;
}
Also used : Context(android.content.Context) Fingerprint(android.hardware.fingerprint.Fingerprint) Intent(android.content.Intent) SpannableString(android.text.SpannableString) TextPaint(android.text.TextPaint) Fingerprint(android.hardware.fingerprint.Fingerprint) OnPreferenceClickListener(android.support.v7.preference.Preference.OnPreferenceClickListener) FooterPreference(com.android.settingslib.widget.FooterPreference) TwoTargetPreference(com.android.settingslib.TwoTargetPreference) Preference(android.support.v7.preference.Preference) FingerprintManager(android.hardware.fingerprint.FingerprintManager) UserManager(android.os.UserManager)

Example 43 with Fingerprint

use of android.hardware.fingerprint.Fingerprint in project platform_frameworks_base by android.

the class FingerprintsUserState method parseFingerprintsLocked.

private void parseFingerprintsLocked(XmlPullParser parser) throws IOException, XmlPullParserException {
    final int outerDepth = parser.getDepth();
    int type;
    while ((type = parser.next()) != XmlPullParser.END_DOCUMENT && (type != XmlPullParser.END_TAG || parser.getDepth() > outerDepth)) {
        if (type == XmlPullParser.END_TAG || type == XmlPullParser.TEXT) {
            continue;
        }
        String tagName = parser.getName();
        if (tagName.equals(TAG_FINGERPRINT)) {
            String name = parser.getAttributeValue(null, ATTR_NAME);
            String groupId = parser.getAttributeValue(null, ATTR_GROUP_ID);
            String fingerId = parser.getAttributeValue(null, ATTR_FINGER_ID);
            String deviceId = parser.getAttributeValue(null, ATTR_DEVICE_ID);
            mFingerprints.add(new Fingerprint(name, Integer.parseInt(groupId), Integer.parseInt(fingerId), Integer.parseInt(deviceId)));
        }
    }
}
Also used : Fingerprint(android.hardware.fingerprint.Fingerprint) Fingerprint(android.hardware.fingerprint.Fingerprint)

Example 44 with Fingerprint

use of android.hardware.fingerprint.Fingerprint in project platform_frameworks_base by android.

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);
    }
}
Also used : Fingerprint(android.hardware.fingerprint.Fingerprint) AtomicFile(android.util.AtomicFile) FileOutputStream(java.io.FileOutputStream) Fingerprint(android.hardware.fingerprint.Fingerprint) XmlSerializer(org.xmlpull.v1.XmlSerializer)

Example 45 with Fingerprint

use of android.hardware.fingerprint.Fingerprint in project platform_frameworks_base by android.

the class FingerprintsUserState method addFingerprint.

public void addFingerprint(int fingerId, int groupId) {
    synchronized (this) {
        mFingerprints.add(new Fingerprint(getUniqueName(), groupId, fingerId, 0));
        scheduleWriteStateLocked();
    }
}
Also used : Fingerprint(android.hardware.fingerprint.Fingerprint)

Aggregations

Fingerprint (android.hardware.fingerprint.Fingerprint)55 Context (android.content.Context)7 Intent (android.content.Intent)7 FingerprintManager (android.hardware.fingerprint.FingerprintManager)7 UserManager (android.os.UserManager)7 Preference (android.support.v7.preference.Preference)7 OnPreferenceClickListener (android.support.v7.preference.Preference.OnPreferenceClickListener)7 SpannableString (android.text.SpannableString)7 TextPaint (android.text.TextPaint)7 RemoteException (android.os.RemoteException)6 TwoTargetPreference (com.android.settingslib.TwoTargetPreference)6 FooterPreference (com.android.settingslib.widget.FooterPreference)6 UserInfo (android.content.pm.UserInfo)5 IFingerprintServiceReceiver (android.hardware.fingerprint.IFingerprintServiceReceiver)5 AtomicFile (android.util.AtomicFile)5 FileOutputStream (java.io.FileOutputStream)5 ArrayList (java.util.ArrayList)5 JSONArray (org.json.JSONArray)5 JSONException (org.json.JSONException)5 JSONObject (org.json.JSONObject)5