Merge "Fingerprint: Add Set Active Group" into mnc-dev

This commit is contained in:
Jim Miller
2015-05-12 01:22:13 +00:00
committed by Android (Google) Code Review
2 changed files with 25 additions and 0 deletions

View File

@@ -16,10 +16,12 @@
package com.android.server.fingerprint;
import android.app.ActivityManager;
import android.app.AppOpsManager;
import android.content.ContentResolver;
import android.content.Context;
import android.os.Binder;
import android.os.Environment;
import android.os.Handler;
import android.os.IBinder;
import android.os.Looper;
@@ -38,6 +40,7 @@ import android.hardware.fingerprint.IFingerprintServiceReceiver;
import static android.Manifest.permission.MANAGE_FINGERPRINT;
import static android.Manifest.permission.USE_FINGERPRINT;
import java.io.File;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.Collections;
@@ -116,6 +119,7 @@ public class FingerprintService extends SystemService {
static native int nativeCloseHal();
static native void nativeInit(MessageQueue queue, FingerprintService service);
static native long nativeGetAuthenticatorId();
static native int nativeSetActiveGroup(int gid, byte[] storePath);
static final class FpHalMsg {
int type; // Type of the message. One of the constants in fingerprint.h
@@ -628,6 +632,11 @@ public class FingerprintService extends SystemService {
public void onStart() {
publishBinderService(Context.FINGERPRINT_SERVICE, new FingerprintServiceWrapper());
mHalDeviceId = nativeOpenHal();
if (mHalDeviceId != 0) {
int userId = ActivityManager.getCurrentUser();
File path = Environment.getUserSystemDirectory(userId);
nativeSetActiveGroup(0, path.getAbsolutePath().getBytes());
}
if (DEBUG) Slog.v(TAG, "Fingerprint HAL id: " + mHalDeviceId);
}

View File

@@ -181,6 +181,21 @@ static jlong nativeGetAuthenticatorId(JNIEnv *, jobject clazz) {
return gContext.device->get_authenticator_id(gContext.device);
}
static jint nativeSetActiveGroup(JNIEnv *env, jobject clazz, jint gid, jbyteArray path) {
const int pathSize = env->GetArrayLength(path);
jbyte* pathData = env->GetByteArrayElements(path, 0);
if (pathSize >= PATH_MAX) {
ALOGE("Path name is too long\n");
return -1;
}
char path_name[PATH_MAX] = {0};
memcpy(path_name, pathData, pathSize);
ALOG(LOG_VERBOSE, LOG_TAG, "nativeSetActiveGroup() path: %s, gid: %d\n", path_name, gid);
int result = gContext.device->set_active_group(gContext.device, gid, path_name);
env->ReleaseByteArrayElements(path, pathData, 0);
return result;
}
static jint nativeOpenHal(JNIEnv* env, jobject clazz) {
ALOG(LOG_VERBOSE, LOG_TAG, "nativeOpenHal()\n");
int err;
@@ -242,6 +257,7 @@ static const JNINativeMethod g_methods[] = {
{ "nativeAuthenticate", "(JI)I", (void*)nativeAuthenticate },
{ "nativeStopAuthentication", "()I", (void*)nativeStopAuthentication },
{ "nativeEnroll", "([BII)I", (void*)nativeEnroll },
{ "nativeSetActiveGroup", "(I[B)I", (void*)nativeSetActiveGroup },
{ "nativePreEnroll", "()J", (void*)nativePreEnroll },
{ "nativeStopEnrollment", "()I", (void*)nativeStopEnrollment },
{ "nativeRemove", "(II)I", (void*)nativeRemove },