Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit 65290802 authored by Daniel Kim's avatar Daniel Kim Committed by Daniel
Browse files

Revert "Revert "Refactor ProximityUpdateCallbackInternal to inte..."

Revert submission 19600381-revert-17936037-hotword_proximity-ZZIDPDULZP

Test: atest CtsVoiceInteractionTestCases, atest CtsVoiceInteractionTestCases:android.voiceinteraction.cts.AlwaysOnHotwordDetectorTest#testAlwaysOnHotwordDetector_startRecognitionWithData -- --abi x86_64
Reason for revert: Including the fix for broken tests
Reverted Changes:
Ibfc659015:Revert "Refactor ProximityUpdateCallbackInternal t...
I1a03c21d5:Revert "Verify that proximity key is added to the ...
I6b79d9400:Revert "Add proximity state to the HotwordDetected...

Change-Id: Iee6ab086ccc3f27b95ee601d6be11231f300170c
parent e601349c
Loading
Loading
Loading
Loading
+2 −2
Original line number Diff line number Diff line
@@ -83,11 +83,11 @@ public abstract class AttentionManagerInternal {
    }

    /** Internal interface for proximity callback. */
    public abstract static class ProximityUpdateCallbackInternal {
    public interface ProximityUpdateCallbackInternal {
        /**
         * @param distance the estimated distance of the user (in meter)
         * The distance will be PROXIMITY_UNKNOWN if the proximity sensing was inconclusive.
         */
        public abstract void onProximityUpdate(double distance);
        void onProximityUpdate(double distance);
    }
}
+2 −4
Original line number Diff line number Diff line
@@ -856,9 +856,6 @@ public class AttentionManagerService extends SystemService {
    @GuardedBy("mLock")
    private void cancelAndUnbindLocked() {
        synchronized (mLock) {
            if (mCurrentAttentionCheck == null && mCurrentProximityUpdate == null) {
                return;
            }
            if (mCurrentAttentionCheck != null) {
                cancel();
            }
@@ -940,7 +937,7 @@ public class AttentionManagerService extends SystemService {
            }
        }

        class TestableProximityUpdateCallbackInternal extends ProximityUpdateCallbackInternal {
        class TestableProximityUpdateCallbackInternal implements ProximityUpdateCallbackInternal {
            private double mLastCallbackCode = PROXIMITY_UNKNOWN;

            @Override
@@ -1072,6 +1069,7 @@ public class AttentionManagerService extends SystemService {
        private void resetStates() {
            synchronized (mLock) {
                mCurrentProximityUpdate = null;
                cancelAndUnbindLocked();
            }
            mComponentName = resolveAttentionService(mContext);
        }
+7 −8
Original line number Diff line number Diff line
@@ -192,14 +192,7 @@ final class HotwordDetectionConnection {
    @Nullable final AttentionManagerInternal mAttentionManagerInternal;

    final AttentionManagerInternal.ProximityUpdateCallbackInternal mProximityCallbackInternal =
            new AttentionManagerInternal.ProximityUpdateCallbackInternal() {
        @Override
        public void onProximityUpdate(double distance) {
            synchronized (mLock) {
                mProximityMeters = distance;
            }
        }
    };
            this::setProximityMeters;


    volatile HotwordDetectionServiceIdentity mIdentity;
@@ -1194,6 +1187,12 @@ final class HotwordDetectionConnection {
        }
    }

    private void setProximityMeters(double proximityMeters) {
        synchronized (mLock) {
            mProximityMeters = proximityMeters;
        }
    }

    private static void bestEffortClose(Closeable... closeables) {
        for (Closeable closeable : closeables) {
            bestEffortClose(closeable);