Merge "Access mCurrentOperation in main handler" into tm-dev am: 7cbaf98546

Original change: https://googleplex-android-review.googlesource.com/c/platform/frameworks/base/+/17888683

Change-Id: I2850177e15bef65ae9bb6c7565fc5b7b31d280eb
Signed-off-by: Automerger Merge Worker <android-build-automerger-merge-worker@system.gserviceaccount.com>
This commit is contained in:
Milton Wu
2022-04-29 16:47:38 +00:00
committed by Automerger Merge Worker
3 changed files with 61 additions and 46 deletions

View File

@@ -46,6 +46,7 @@ import java.util.Date;
import java.util.Deque; import java.util.Deque;
import java.util.List; import java.util.List;
import java.util.Locale; import java.util.Locale;
import java.util.function.Consumer;
/** /**
* A scheduler for biometric HAL operations. Maintains a queue of {@link BaseClientMonitor} * A scheduler for biometric HAL operations. Maintains a queue of {@link BaseClientMonitor}
@@ -457,22 +458,33 @@ public class BiometricScheduler {
} }
/** /**
* Get current operation <code>BaseClientMonitor</code>
* @deprecated TODO: b/229994966, encapsulate client monitors
* @return the current operation * @return the current operation
*/ */
@Deprecated
@Nullable
public BaseClientMonitor getCurrentClient() { public BaseClientMonitor getCurrentClient() {
return mCurrentOperation != null ? mCurrentOperation.getClientMonitor() : null; return mCurrentOperation != null ? mCurrentOperation.getClientMonitor() : null;
} }
/** The current operation if the requestId is set and matches. */ /**
* The current operation if the requestId is set and matches.
* @deprecated TODO: b/229994966, encapsulate client monitors
*/
@Deprecated @Deprecated
@Nullable @Nullable
public BaseClientMonitor getCurrentClientIfMatches(long requestId) { public void getCurrentClientIfMatches(long requestId,
if (mCurrentOperation != null) { @NonNull Consumer<BaseClientMonitor> clientMonitorConsumer) {
if (mCurrentOperation.isMatchingRequestId(requestId)) { mHandler.post(() -> {
return mCurrentOperation.getClientMonitor(); if (mCurrentOperation != null) {
if (mCurrentOperation.isMatchingRequestId(requestId)) {
clientMonitorConsumer.accept(mCurrentOperation.getClientMonitor());
return;
}
} }
} clientMonitorConsumer.accept(null);
return null; });
} }
public int getCurrentPendingCount() { public int getCurrentPendingCount() {

View File

@@ -582,35 +582,35 @@ public class FingerprintProvider implements IBinder.DeathRecipient, ServiceProvi
@Override @Override
public void onPointerDown(long requestId, int sensorId, int x, int y, public void onPointerDown(long requestId, int sensorId, int x, int y,
float minor, float major) { float minor, float major) {
final BaseClientMonitor client = mSensors.get(sensorId).getScheduler().getCurrentClientIfMatches(requestId, (client) -> {
mSensors.get(sensorId).getScheduler().getCurrentClientIfMatches(requestId); if (!(client instanceof Udfps)) {
if (!(client instanceof Udfps)) { Slog.e(getTag(), "onPointerDown received during client: " + client);
Slog.e(getTag(), "onPointerDown received during client: " + client); return;
return; }
} ((Udfps) client).onPointerDown(x, y, minor, major);
((Udfps) client).onPointerDown(x, y, minor, major); });
} }
@Override @Override
public void onPointerUp(long requestId, int sensorId) { public void onPointerUp(long requestId, int sensorId) {
final BaseClientMonitor client = mSensors.get(sensorId).getScheduler().getCurrentClientIfMatches(requestId, (client) -> {
mSensors.get(sensorId).getScheduler().getCurrentClientIfMatches(requestId); if (!(client instanceof Udfps)) {
if (!(client instanceof Udfps)) { Slog.e(getTag(), "onPointerUp received during client: " + client);
Slog.e(getTag(), "onPointerUp received during client: " + client); return;
return; }
} ((Udfps) client).onPointerUp();
((Udfps) client).onPointerUp(); });
} }
@Override @Override
public void onUiReady(long requestId, int sensorId) { public void onUiReady(long requestId, int sensorId) {
final BaseClientMonitor client = mSensors.get(sensorId).getScheduler().getCurrentClientIfMatches(requestId, (client) -> {
mSensors.get(sensorId).getScheduler().getCurrentClientIfMatches(requestId); if (!(client instanceof Udfps)) {
if (!(client instanceof Udfps)) { Slog.e(getTag(), "onUiReady received during client: " + client);
Slog.e(getTag(), "onUiReady received during client: " + client); return;
return; }
} ((Udfps) client).onUiReady();
((Udfps) client).onUiReady(); });
} }
@Override @Override

View File

@@ -794,32 +794,35 @@ public class Fingerprint21 implements IHwBinder.DeathRecipient, ServiceProvider
@Override @Override
public void onPointerDown(long requestId, int sensorId, int x, int y, public void onPointerDown(long requestId, int sensorId, int x, int y,
float minor, float major) { float minor, float major) {
final BaseClientMonitor client = mScheduler.getCurrentClientIfMatches(requestId); mScheduler.getCurrentClientIfMatches(requestId, (client) -> {
if (!(client instanceof Udfps)) { if (!(client instanceof Udfps)) {
Slog.w(TAG, "onFingerDown received during client: " + client); Slog.w(TAG, "onFingerDown received during client: " + client);
return; return;
} }
((Udfps) client).onPointerDown(x, y, minor, major); ((Udfps) client).onPointerDown(x, y, minor, major);
});
} }
@Override @Override
public void onPointerUp(long requestId, int sensorId) { public void onPointerUp(long requestId, int sensorId) {
final BaseClientMonitor client = mScheduler.getCurrentClientIfMatches(requestId); mScheduler.getCurrentClientIfMatches(requestId, (client) -> {
if (!(client instanceof Udfps)) { if (!(client instanceof Udfps)) {
Slog.w(TAG, "onFingerDown received during client: " + client); Slog.w(TAG, "onFingerDown received during client: " + client);
return; return;
} }
((Udfps) client).onPointerUp(); ((Udfps) client).onPointerUp();
});
} }
@Override @Override
public void onUiReady(long requestId, int sensorId) { public void onUiReady(long requestId, int sensorId) {
final BaseClientMonitor client = mScheduler.getCurrentClientIfMatches(requestId); mScheduler.getCurrentClientIfMatches(requestId, (client) -> {
if (!(client instanceof Udfps)) { if (!(client instanceof Udfps)) {
Slog.w(TAG, "onUiReady received during client: " + client); Slog.w(TAG, "onUiReady received during client: " + client);
return; return;
} }
((Udfps) client).onUiReady(); ((Udfps) client).onUiReady();
});
} }
@Override @Override