Revert "Refactor ProximityUpdateCallbackInternal to interface"
Revert submission 17936037-hotword_proximity Reason for revert: https://buganizer.corp.google.com/issues/242223069 Reverted Changes: If8c23a9c6:Refactor ProximityUpdateCallbackInternal to interf... Ib0ad1da25:Verify that proximity key is added to the hotword ... I71e9d3da9:Add proximity state to the HotwordDetectedResult Change-Id: Ibfc65901547d74d6fcfafc257653f49a17a98662
This commit is contained in:
@@ -83,11 +83,11 @@ public abstract class AttentionManagerInternal {
|
||||
}
|
||||
|
||||
/** Internal interface for proximity callback. */
|
||||
public interface ProximityUpdateCallbackInternal {
|
||||
public abstract static class ProximityUpdateCallbackInternal {
|
||||
/**
|
||||
* @param distance the estimated distance of the user (in meter)
|
||||
* The distance will be PROXIMITY_UNKNOWN if the proximity sensing was inconclusive.
|
||||
*/
|
||||
void onProximityUpdate(double distance);
|
||||
public abstract void onProximityUpdate(double distance);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -856,6 +856,9 @@ public class AttentionManagerService extends SystemService {
|
||||
@GuardedBy("mLock")
|
||||
private void cancelAndUnbindLocked() {
|
||||
synchronized (mLock) {
|
||||
if (mCurrentAttentionCheck == null && mCurrentProximityUpdate == null) {
|
||||
return;
|
||||
}
|
||||
if (mCurrentAttentionCheck != null) {
|
||||
cancel();
|
||||
}
|
||||
@@ -937,7 +940,7 @@ public class AttentionManagerService extends SystemService {
|
||||
}
|
||||
}
|
||||
|
||||
class TestableProximityUpdateCallbackInternal implements ProximityUpdateCallbackInternal {
|
||||
class TestableProximityUpdateCallbackInternal extends ProximityUpdateCallbackInternal {
|
||||
private double mLastCallbackCode = PROXIMITY_UNKNOWN;
|
||||
|
||||
@Override
|
||||
@@ -1069,7 +1072,6 @@ public class AttentionManagerService extends SystemService {
|
||||
private void resetStates() {
|
||||
synchronized (mLock) {
|
||||
mCurrentProximityUpdate = null;
|
||||
cancelAndUnbindLocked();
|
||||
}
|
||||
mComponentName = resolveAttentionService(mContext);
|
||||
}
|
||||
|
||||
@@ -192,7 +192,14 @@ final class HotwordDetectionConnection {
|
||||
final AttentionManagerInternal mAttentionManagerInternal;
|
||||
|
||||
final AttentionManagerInternal.ProximityUpdateCallbackInternal mProximityCallbackInternal =
|
||||
this::setProximityMeters;
|
||||
new AttentionManagerInternal.ProximityUpdateCallbackInternal() {
|
||||
@Override
|
||||
public void onProximityUpdate(double distance) {
|
||||
synchronized (mLock) {
|
||||
mProximityMeters = distance;
|
||||
}
|
||||
}
|
||||
};
|
||||
|
||||
|
||||
volatile HotwordDetectionServiceIdentity mIdentity;
|
||||
@@ -1183,12 +1190,6 @@ final class HotwordDetectionConnection {
|
||||
}
|
||||
}
|
||||
|
||||
private void setProximityMeters(double proximityMeters) {
|
||||
synchronized (mLock) {
|
||||
mProximityMeters = proximityMeters;
|
||||
}
|
||||
}
|
||||
|
||||
private static void bestEffortClose(Closeable... closeables) {
|
||||
for (Closeable closeable : closeables) {
|
||||
bestEffortClose(closeable);
|
||||
|
||||
Reference in New Issue
Block a user