am 3656975e: Merge "Run callbacks from fingerprintd through handler." into mnc-dr-dev

* commit '3656975ef879175aa81cf6362a6a7ffc4a5a99fc':
  Run callbacks from fingerprintd through handler.
This commit is contained in:
Jim Miller
2015-08-29 01:26:21 +00:00
committed by Android Git Automerger

View File

@@ -129,7 +129,7 @@ public class FingerprintService extends SystemService implements IBinder.DeathRe
public void binderDied() { public void binderDied() {
Slog.v(TAG, "fingerprintd died"); Slog.v(TAG, "fingerprintd died");
mDaemon = null; mDaemon = null;
dispatchError(mHalDeviceId, FingerprintManager.FINGERPRINT_ERROR_HW_UNAVAILABLE); handleError(mHalDeviceId, FingerprintManager.FINGERPRINT_ERROR_HW_UNAVAILABLE);
} }
public IFingerprintDaemon getFingerprintDaemon() { public IFingerprintDaemon getFingerprintDaemon() {
@@ -157,7 +157,7 @@ public class FingerprintService extends SystemService implements IBinder.DeathRe
return mDaemon; return mDaemon;
} }
protected void dispatchEnumerate(long deviceId, int[] fingerIds, int[] groupIds) { protected void handleEnumerate(long deviceId, int[] fingerIds, int[] groupIds) {
if (fingerIds.length != groupIds.length) { if (fingerIds.length != groupIds.length) {
Slog.w(TAG, "fingerIds and groupIds differ in length: f[]=" Slog.w(TAG, "fingerIds and groupIds differ in length: f[]="
+ fingerIds + ", g[]=" + groupIds); + fingerIds + ", g[]=" + groupIds);
@@ -167,7 +167,7 @@ public class FingerprintService extends SystemService implements IBinder.DeathRe
// TODO: update fingerprint/name pairs // TODO: update fingerprint/name pairs
} }
protected void dispatchRemoved(long deviceId, int fingerId, int groupId) { protected void handleRemoved(long deviceId, int fingerId, int groupId) {
final ClientMonitor client = mRemoveClient; final ClientMonitor client = mRemoveClient;
if (fingerId != 0) { if (fingerId != 0) {
removeTemplateForUser(mRemoveClient, fingerId); removeTemplateForUser(mRemoveClient, fingerId);
@@ -177,7 +177,7 @@ public class FingerprintService extends SystemService implements IBinder.DeathRe
} }
} }
protected void dispatchError(long deviceId, int error) { protected void handleError(long deviceId, int error) {
if (mEnrollClient != null) { if (mEnrollClient != null) {
final IBinder token = mEnrollClient.token; final IBinder token = mEnrollClient.token;
if (mEnrollClient.sendError(error)) { if (mEnrollClient.sendError(error)) {
@@ -193,7 +193,7 @@ public class FingerprintService extends SystemService implements IBinder.DeathRe
} }
} }
protected void dispatchAuthenticated(long deviceId, int fingerId, int groupId) { protected void handleAuthenticated(long deviceId, int fingerId, int groupId) {
if (mAuthClient != null) { if (mAuthClient != null) {
final IBinder token = mAuthClient.token; final IBinder token = mAuthClient.token;
if (mAuthClient.sendAuthenticated(fingerId, groupId)) { if (mAuthClient.sendAuthenticated(fingerId, groupId)) {
@@ -203,7 +203,7 @@ public class FingerprintService extends SystemService implements IBinder.DeathRe
} }
} }
protected void dispatchAcquired(long deviceId, int acquiredInfo) { protected void handleAcquired(long deviceId, int acquiredInfo) {
if (mEnrollClient != null) { if (mEnrollClient != null) {
if (mEnrollClient.sendAcquired(acquiredInfo)) { if (mEnrollClient.sendAcquired(acquiredInfo)) {
removeClient(mEnrollClient); removeClient(mEnrollClient);
@@ -215,16 +215,7 @@ public class FingerprintService extends SystemService implements IBinder.DeathRe
} }
} }
private void userActivity() { protected void handleEnrollResult(long deviceId, int fingerId, int groupId, int remaining) {
long now = SystemClock.uptimeMillis();
mPowerManager.userActivity(now, PowerManager.USER_ACTIVITY_EVENT_TOUCH, 0);
}
void handleUserSwitching(int userId) {
updateActiveGroup(userId);
}
protected void dispatchEnrollResult(long deviceId, int fingerId, int groupId, int remaining) {
if (mEnrollClient != null) { if (mEnrollClient != null) {
if (mEnrollClient.sendEnrollResult(fingerId, groupId, remaining)) { if (mEnrollClient.sendEnrollResult(fingerId, groupId, remaining)) {
if (remaining == 0) { if (remaining == 0) {
@@ -235,6 +226,15 @@ public class FingerprintService extends SystemService implements IBinder.DeathRe
} }
} }
private void userActivity() {
long now = SystemClock.uptimeMillis();
mPowerManager.userActivity(now, PowerManager.USER_ACTIVITY_EVENT_TOUCH, 0);
}
void handleUserSwitching(int userId) {
updateActiveGroup(userId);
}
private void removeClient(ClientMonitor client) { private void removeClient(ClientMonitor client) {
if (client == null) return; if (client == null) return;
client.destroy(); client.destroy();
@@ -298,7 +298,7 @@ public class FingerprintService extends SystemService implements IBinder.DeathRe
final int result = daemon.enroll(cryptoToken, groupId, timeout); final int result = daemon.enroll(cryptoToken, groupId, timeout);
if (result != 0) { if (result != 0) {
Slog.w(TAG, "startEnroll failed, result=" + result); Slog.w(TAG, "startEnroll failed, result=" + result);
dispatchError(mHalDeviceId, FingerprintManager.FINGERPRINT_ERROR_HW_UNAVAILABLE); handleError(mHalDeviceId, FingerprintManager.FINGERPRINT_ERROR_HW_UNAVAILABLE);
} }
} catch (RemoteException e) { } catch (RemoteException e) {
Slog.e(TAG, "startEnroll failed", e); Slog.e(TAG, "startEnroll failed", e);
@@ -392,7 +392,7 @@ public class FingerprintService extends SystemService implements IBinder.DeathRe
final int result = daemon.authenticate(opId, groupId); final int result = daemon.authenticate(opId, groupId);
if (result != 0) { if (result != 0) {
Slog.w(TAG, "startAuthentication failed, result=" + result); Slog.w(TAG, "startAuthentication failed, result=" + result);
dispatchError(mHalDeviceId, FingerprintManager.FINGERPRINT_ERROR_HW_UNAVAILABLE); handleError(mHalDeviceId, FingerprintManager.FINGERPRINT_ERROR_HW_UNAVAILABLE);
} }
} catch (RemoteException e) { } catch (RemoteException e) {
Slog.e(TAG, "startAuthentication failed", e); Slog.e(TAG, "startAuthentication failed", e);
@@ -442,7 +442,7 @@ public class FingerprintService extends SystemService implements IBinder.DeathRe
final int result = daemon.remove(fingerId, userId); final int result = daemon.remove(fingerId, userId);
if (result != 0) { if (result != 0) {
Slog.w(TAG, "startRemove with id = " + fingerId + " failed, result=" + result); Slog.w(TAG, "startRemove with id = " + fingerId + " failed, result=" + result);
dispatchError(mHalDeviceId, FingerprintManager.FINGERPRINT_ERROR_HW_UNAVAILABLE); handleError(mHalDeviceId, FingerprintManager.FINGERPRINT_ERROR_HW_UNAVAILABLE);
} }
} catch (RemoteException e) { } catch (RemoteException e) {
Slog.e(TAG, "startRemove failed", e); Slog.e(TAG, "startRemove failed", e);
@@ -657,33 +657,64 @@ public class FingerprintService extends SystemService implements IBinder.DeathRe
private IFingerprintDaemonCallback mDaemonCallback = new IFingerprintDaemonCallback.Stub() { private IFingerprintDaemonCallback mDaemonCallback = new IFingerprintDaemonCallback.Stub() {
@Override @Override
public void onEnrollResult(long deviceId, int fingerId, int groupId, int remaining) { public void onEnrollResult(final long deviceId, final int fingerId, final int groupId,
dispatchEnrollResult(deviceId, fingerId, groupId, remaining); final int remaining) {
mHandler.post(new Runnable() {
@Override
public void run() {
handleEnrollResult(deviceId, fingerId, groupId, remaining);
}
});
} }
@Override @Override
public void onAcquired(long deviceId, int acquiredInfo) { public void onAcquired(final long deviceId, final int acquiredInfo) {
dispatchAcquired(deviceId, acquiredInfo); mHandler.post(new Runnable() {
@Override
public void run() {
handleAcquired(deviceId, acquiredInfo);
}
});
} }
@Override @Override
public void onAuthenticated(long deviceId, int fingerId, int groupId) { public void onAuthenticated(final long deviceId, final int fingerId, final int groupId) {
dispatchAuthenticated(deviceId, fingerId, groupId); mHandler.post(new Runnable() {
@Override
public void run() {
handleAuthenticated(deviceId, fingerId, groupId);
}
});
} }
@Override @Override
public void onError(long deviceId, int error) { public void onError(final long deviceId, final int error) {
dispatchError(deviceId, error); mHandler.post(new Runnable() {
@Override
public void run() {
handleError(deviceId, error);
}
});
} }
@Override @Override
public void onRemoved(long deviceId, int fingerId, int groupId) { public void onRemoved(final long deviceId, final int fingerId, final int groupId) {
dispatchRemoved(deviceId, fingerId, groupId); mHandler.post(new Runnable() {
@Override
public void run() {
handleRemoved(deviceId, fingerId, groupId);
}
});
} }
@Override @Override
public void onEnumerate(long deviceId, int[] fingerIds, int[] groupIds) { public void onEnumerate(final long deviceId, final int[] fingerIds, final int[] groupIds) {
dispatchEnumerate(deviceId, fingerIds, groupIds); mHandler.post(new Runnable() {
@Override
public void run() {
handleEnumerate(deviceId, fingerIds, groupIds);
}
});
} }
}; };