summaryrefslogtreecommitdiffstats
path: root/core
diff options
context:
space:
mode:
authorJorim Jaggi <jjaggi@google.com>2015-05-13 20:32:30 +0000
committerAndroid (Google) Code Review <android-gerrit@google.com>2015-05-13 20:32:31 +0000
commit131a19ee6f55d95d747d3d1ed62537b1db5a2e69 (patch)
tree163fcc18f15a89eaf9596d92f97559080d54ea31 /core
parentd90bf46264615159e1e16ee69e78a8651e126d6e (diff)
parentee77cebc1a54a0bee1a1d538db0abed00aa9cb4e (diff)
downloadframeworks_base-131a19ee6f55d95d747d3d1ed62537b1db5a2e69.zip
frameworks_base-131a19ee6f55d95d747d3d1ed62537b1db5a2e69.tar.gz
frameworks_base-131a19ee6f55d95d747d3d1ed62537b1db5a2e69.tar.bz2
Merge "Persist fingerprint names" into mnc-dev
Diffstat (limited to 'core')
-rw-r--r--core/java/android/hardware/fingerprint/FingerprintUtils.java126
-rw-r--r--core/java/android/provider/Settings.java6
-rw-r--r--core/res/res/values/strings.xml3
-rwxr-xr-xcore/res/res/values/symbols.xml1
4 files changed, 4 insertions, 132 deletions
diff --git a/core/java/android/hardware/fingerprint/FingerprintUtils.java b/core/java/android/hardware/fingerprint/FingerprintUtils.java
deleted file mode 100644
index 525f254..0000000
--- a/core/java/android/hardware/fingerprint/FingerprintUtils.java
+++ /dev/null
@@ -1,126 +0,0 @@
-/**
- * Copyright (C) 2014 The Android Open Source Project
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-package android.hardware.fingerprint;
-
-import android.content.ContentResolver;
-import android.content.Context;
-import android.os.Vibrator;
-import android.provider.Settings;
-import android.text.TextUtils;
-import android.util.Log;
-
-import com.android.internal.util.ArrayUtils;
-
-import java.util.ArrayList;
-import java.util.Arrays;
-import java.util.List;
-
-/**
- * Utility class for dealing with fingerprints and fingerprint settings.
- * @hide
- */
-public
-class FingerprintUtils {
- private static final boolean DEBUG = true;
- private static final String TAG = "FingerprintUtils";
- private static final long[] FP_ERROR_VIBRATE_PATTERN = new long[] {0, 30, 100, 30};
- private static final long[] FP_SUCCESS_VIBRATE_PATTERN = new long[] {0, 30};
-
- private static int[] toIntArray(List<Integer> list) {
- if (list == null) {
- return null;
- }
- int[] arr = new int[list.size()];
- int i = 0;
- for (int elem : list) {
- arr[i] = elem;
- i++;
- }
- return arr;
- }
-
- public static int[] getFingerprintIdsForUser(ContentResolver res, int userId) {
- String fingerIdsRaw = Settings.Secure.getStringForUser(res,
- Settings.Secure.USER_FINGERPRINT_IDS, userId);
- ArrayList<Integer> tmp = new ArrayList<Integer>();
- if (!TextUtils.isEmpty(fingerIdsRaw)) {
- String[] fingerStringIds = fingerIdsRaw.replace("[","").replace("]","").split(", ");
- int length = fingerStringIds.length;
- for (int i = 0; i < length; i++) {
- try {
- tmp.add(Integer.decode(fingerStringIds[i]));
- } catch (NumberFormatException e) {
- if (DEBUG) Log.w(TAG, "Error parsing finger id: '" + fingerStringIds[i] + "'");
- }
- }
- }
- return toIntArray(tmp);
- }
-
- public static void addFingerprintIdForUser(ContentResolver res, int fingerId, int userId) {
- // FingerId 0 has special meaning.
- if (fingerId == 0) {
- Log.w(TAG, "Tried to add fingerId 0");
- return;
- }
-
- int[] fingerIds = getFingerprintIdsForUser(res, userId);
-
- // Don't allow dups
- if (ArrayUtils.contains(fingerIds, fingerId)) {
- Log.w(TAG, "finger already added " + fingerId);
- return;
- }
- int[] newList = Arrays.copyOf(fingerIds, fingerIds.length + 1);
- newList[fingerIds.length] = fingerId;
- Settings.Secure.putStringForUser(res, Settings.Secure.USER_FINGERPRINT_IDS,
- Arrays.toString(newList), userId);
- }
-
- public static boolean removeFingerprintIdForUser(int fingerId, ContentResolver res, int userId)
- {
- // FingerId 0 has special meaning. The HAL layer is supposed to remove each finger one
- // at a time and invoke notify() for each fingerId. If we get called with 0 here, it means
- // something bad has happened.
- if (fingerId == 0) throw new IllegalArgumentException("fingerId can't be 0");
-
- final int[] fingerIds = getFingerprintIdsForUser(res, userId);
- if (ArrayUtils.contains(fingerIds, fingerId)) {
- final int[] result = ArrayUtils.removeInt(fingerIds, fingerId);
- Settings.Secure.putStringForUser(res, Settings.Secure.USER_FINGERPRINT_IDS,
- Arrays.toString(result), userId);
- return true;
- }
- return false;
- }
-
- public static void vibrateFingerprintError(Context context) {
- Vibrator vibrator = context.getSystemService(Vibrator.class);
- if (vibrator != null) {
- vibrator.vibrate(FP_ERROR_VIBRATE_PATTERN, -1);
- }
- }
-
- public static void vibrateFingerprintSuccess(Context context) {
- Vibrator vibrator = context.getSystemService(Vibrator.class);
- if (vibrator != null) {
- vibrator.vibrate(FP_SUCCESS_VIBRATE_PATTERN, -1);
- }
- }
-
-};
-
diff --git a/core/java/android/provider/Settings.java b/core/java/android/provider/Settings.java
index d3a5561..c514180 100644
--- a/core/java/android/provider/Settings.java
+++ b/core/java/android/provider/Settings.java
@@ -4363,12 +4363,6 @@ public final class Settings {
"lock_screen_appwidget_ids";
/**
- * List of enrolled fingerprint identifiers (comma-delimited).
- * @hide
- */
- public static final String USER_FINGERPRINT_IDS = "user_fingerprint_ids";
-
- /**
* Id of the appwidget shown on the lock screen when appwidgets are disabled.
* @hide
*/
diff --git a/core/res/res/values/strings.xml b/core/res/res/values/strings.xml
index 47ff16b..bd4d73d 100644
--- a/core/res/res/values/strings.xml
+++ b/core/res/res/values/strings.xml
@@ -1255,6 +1255,9 @@
<!-- Generic error message shown when the fingerprint hardware can't recognize the fingerprint -->
<string name="fingerprint_error_unable_to_process">Try again.</string>
+ <!-- Template to be used to name enrolled fingerprints by default. -->
+ <string name="fingerprint_name_template">Finger <xliff:g id="fingerId" example="1">%d</xliff:g></string>
+
<!-- Array containing custom error messages from vendor. Vendor is expected to add and translate these strings -->
<string-array name="fingerprint_error_vendor">
</string-array>
diff --git a/core/res/res/values/symbols.xml b/core/res/res/values/symbols.xml
index 1f6e861..8292e23 100755
--- a/core/res/res/values/symbols.xml
+++ b/core/res/res/values/symbols.xml
@@ -2112,6 +2112,7 @@
<java-symbol type="array" name="fingerprint_acquired_vendor" />
<java-symbol type="string" name="fingerprint_error_canceled" />
<java-symbol type="string" name="fingerprint_error_lockout" />
+ <java-symbol type="string" name="fingerprint_name_template" />
<!-- From various Material changes -->
<java-symbol type="attr" name="titleTextAppearance" />