Merge "Have FingerprintService keep the device awake on relevant events." into mnc-dev
This commit is contained in:
@@ -26,7 +26,7 @@ import java.util.List;
|
|||||||
*/
|
*/
|
||||||
interface IFingerprintService {
|
interface IFingerprintService {
|
||||||
// Authenticate the given sessionId with a fingerprint
|
// Authenticate the given sessionId with a fingerprint
|
||||||
void authenticate(IBinder token, long sessionId, int groupId,
|
void authenticate(IBinder token, long sessionId, int userId,
|
||||||
IFingerprintServiceReceiver receiver, int flags, String opPackageName);
|
IFingerprintServiceReceiver receiver, int flags, String opPackageName);
|
||||||
|
|
||||||
// Cancel authentication for the given sessionId
|
// Cancel authentication for the given sessionId
|
||||||
|
|||||||
@@ -30,9 +30,11 @@ import android.os.IBinder;
|
|||||||
import android.os.IRemoteCallback;
|
import android.os.IRemoteCallback;
|
||||||
import android.os.Looper;
|
import android.os.Looper;
|
||||||
import android.os.MessageQueue;
|
import android.os.MessageQueue;
|
||||||
|
import android.os.PowerManager;
|
||||||
import android.os.RemoteException;
|
import android.os.RemoteException;
|
||||||
import android.os.SELinux;
|
import android.os.SELinux;
|
||||||
import android.os.ServiceManager;
|
import android.os.ServiceManager;
|
||||||
|
import android.os.SystemClock;
|
||||||
import android.os.UserHandle;
|
import android.os.UserHandle;
|
||||||
import android.util.Slog;
|
import android.util.Slog;
|
||||||
|
|
||||||
@@ -70,6 +72,7 @@ public class FingerprintService extends SystemService implements IBinder.DeathRe
|
|||||||
private static final int MSG_USER_SWITCHING = 10;
|
private static final int MSG_USER_SWITCHING = 10;
|
||||||
private static final int ENROLLMENT_TIMEOUT_MS = 60 * 1000; // 1 minute
|
private static final int ENROLLMENT_TIMEOUT_MS = 60 * 1000; // 1 minute
|
||||||
|
|
||||||
|
private boolean mIsKeyguard; // true if the authentication client is keyguard
|
||||||
private ClientMonitor mAuthClient = null;
|
private ClientMonitor mAuthClient = null;
|
||||||
private ClientMonitor mEnrollClient = null;
|
private ClientMonitor mEnrollClient = null;
|
||||||
private ClientMonitor mRemoveClient = null;
|
private ClientMonitor mRemoveClient = null;
|
||||||
@@ -78,6 +81,7 @@ public class FingerprintService extends SystemService implements IBinder.DeathRe
|
|||||||
private static final long MS_PER_SEC = 1000;
|
private static final long MS_PER_SEC = 1000;
|
||||||
private static final long FAIL_LOCKOUT_TIMEOUT_MS = 30*1000;
|
private static final long FAIL_LOCKOUT_TIMEOUT_MS = 30*1000;
|
||||||
private static final int MAX_FAILED_ATTEMPTS = 5;
|
private static final int MAX_FAILED_ATTEMPTS = 5;
|
||||||
|
private static final int FINGERPRINT_ACQUIRED_GOOD = 0;
|
||||||
|
|
||||||
Handler mHandler = new Handler() {
|
Handler mHandler = new Handler() {
|
||||||
public void handleMessage(android.os.Message msg) {
|
public void handleMessage(android.os.Message msg) {
|
||||||
@@ -97,6 +101,7 @@ public class FingerprintService extends SystemService implements IBinder.DeathRe
|
|||||||
private long mHalDeviceId;
|
private long mHalDeviceId;
|
||||||
private int mFailedAttempts;
|
private int mFailedAttempts;
|
||||||
private IFingerprintDaemon mDaemon;
|
private IFingerprintDaemon mDaemon;
|
||||||
|
private PowerManager mPowerManager;
|
||||||
|
|
||||||
private final Runnable mLockoutReset = new Runnable() {
|
private final Runnable mLockoutReset = new Runnable() {
|
||||||
@Override
|
@Override
|
||||||
@@ -109,6 +114,7 @@ public class FingerprintService extends SystemService implements IBinder.DeathRe
|
|||||||
super(context);
|
super(context);
|
||||||
mContext = context;
|
mContext = context;
|
||||||
mAppOps = context.getSystemService(AppOpsManager.class);
|
mAppOps = context.getSystemService(AppOpsManager.class);
|
||||||
|
mPowerManager = (PowerManager) mContext.getSystemService(Context.POWER_SERVICE);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
@@ -191,7 +197,11 @@ public class FingerprintService extends SystemService implements IBinder.DeathRe
|
|||||||
removeClient(mAuthClient);
|
removeClient(mAuthClient);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
private void userActivity() {
|
||||||
|
long now = SystemClock.uptimeMillis();
|
||||||
|
mPowerManager.userActivity(now, PowerManager.USER_ACTIVITY_EVENT_TOUCH, 0);
|
||||||
}
|
}
|
||||||
|
|
||||||
void handleUserSwitching(int userId) {
|
void handleUserSwitching(int userId) {
|
||||||
@@ -498,9 +508,10 @@ public class FingerprintService extends SystemService implements IBinder.DeathRe
|
|||||||
*/
|
*/
|
||||||
private boolean sendAuthenticated(int fpId, int groupId) {
|
private boolean sendAuthenticated(int fpId, int groupId) {
|
||||||
boolean result = false;
|
boolean result = false;
|
||||||
|
boolean authenticated = fpId != 0;
|
||||||
if (receiver != null) {
|
if (receiver != null) {
|
||||||
try {
|
try {
|
||||||
if (fpId == 0) {
|
if (!authenticated) {
|
||||||
receiver.onAuthenticationFailed(mHalDeviceId);
|
receiver.onAuthenticationFailed(mHalDeviceId);
|
||||||
} else {
|
} else {
|
||||||
Fingerprint fp = !restricted ?
|
Fingerprint fp = !restricted ?
|
||||||
@@ -522,6 +533,11 @@ public class FingerprintService extends SystemService implements IBinder.DeathRe
|
|||||||
result |= true; // we have a valid fingerprint
|
result |= true; // we have a valid fingerprint
|
||||||
mLockoutReset.run();
|
mLockoutReset.run();
|
||||||
}
|
}
|
||||||
|
// For fingerprint devices that support touch-to-wake, this will ensure the device
|
||||||
|
// wakes up and turns the screen on when fingerprint is authenticated.
|
||||||
|
if (mIsKeyguard && authenticated) {
|
||||||
|
mPowerManager.wakeUp(SystemClock.uptimeMillis());
|
||||||
|
}
|
||||||
return result;
|
return result;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -537,6 +553,12 @@ public class FingerprintService extends SystemService implements IBinder.DeathRe
|
|||||||
Slog.w(TAG, "Failed to invoke sendAcquired:", e);
|
Slog.w(TAG, "Failed to invoke sendAcquired:", e);
|
||||||
return true; // client failed
|
return true; // client failed
|
||||||
}
|
}
|
||||||
|
finally {
|
||||||
|
// Good scans will keep the device awake
|
||||||
|
if (acquiredInfo == FINGERPRINT_ACQUIRED_GOOD) {
|
||||||
|
userActivity();
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/*
|
/*
|
||||||
@@ -589,6 +611,8 @@ public class FingerprintService extends SystemService implements IBinder.DeathRe
|
|||||||
};
|
};
|
||||||
|
|
||||||
private final class FingerprintServiceWrapper extends IFingerprintService.Stub {
|
private final class FingerprintServiceWrapper extends IFingerprintService.Stub {
|
||||||
|
private static final String KEYGUARD_PACKAGE = "com.android.systemui";
|
||||||
|
|
||||||
@Override // Binder call
|
@Override // Binder call
|
||||||
public long preEnroll(IBinder token) {
|
public long preEnroll(IBinder token) {
|
||||||
checkPermission(MANAGE_FINGERPRINT);
|
checkPermission(MANAGE_FINGERPRINT);
|
||||||
@@ -638,7 +662,8 @@ public class FingerprintService extends SystemService implements IBinder.DeathRe
|
|||||||
|
|
||||||
@Override // Binder call
|
@Override // Binder call
|
||||||
public void authenticate(final IBinder token, final long opId, final int groupId,
|
public void authenticate(final IBinder token, final long opId, final int groupId,
|
||||||
final IFingerprintServiceReceiver receiver, final int flags, String opPackageName) {
|
final IFingerprintServiceReceiver receiver, final int flags,
|
||||||
|
final String opPackageName) {
|
||||||
|
|
||||||
if (!canUseFingerprint(opPackageName)) {
|
if (!canUseFingerprint(opPackageName)) {
|
||||||
return;
|
return;
|
||||||
@@ -647,6 +672,7 @@ public class FingerprintService extends SystemService implements IBinder.DeathRe
|
|||||||
mHandler.post(new Runnable() {
|
mHandler.post(new Runnable() {
|
||||||
@Override
|
@Override
|
||||||
public void run() {
|
public void run() {
|
||||||
|
mIsKeyguard = KEYGUARD_PACKAGE.equals(opPackageName);
|
||||||
startAuthentication(token, opId, groupId, receiver, flags, restricted);
|
startAuthentication(token, opId, groupId, receiver, flags, restricted);
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|||||||
@@ -3117,7 +3117,7 @@ public final class PowerManagerService extends SystemService
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (eventTime > SystemClock.uptimeMillis()) {
|
if (eventTime > now) {
|
||||||
throw new IllegalArgumentException("event time must not be in the future");
|
throw new IllegalArgumentException("event time must not be in the future");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user