| Index: components/proximity_auth/proximity_monitor_impl.h
|
| diff --git a/components/proximity_auth/proximity_monitor_impl.h b/components/proximity_auth/proximity_monitor_impl.h
|
| index 11cffd36006d3178c009912bcd35beb82be099b4..968ef783524ec1bfb95c5e79648a92a773b8297c 100644
|
| --- a/components/proximity_auth/proximity_monitor_impl.h
|
| +++ b/components/proximity_auth/proximity_monitor_impl.h
|
| @@ -11,6 +11,7 @@
|
| #include "base/memory/ref_counted.h"
|
| #include "base/memory/weak_ptr.h"
|
| #include "base/observer_list.h"
|
| +#include "components/cryptauth/connection.h"
|
| #include "components/cryptauth/remote_device.h"
|
| #include "components/proximity_auth/proximity_monitor.h"
|
| #include "device/bluetooth/bluetooth_device.h"
|
| @@ -31,41 +32,20 @@ class ProximityMonitorObserver;
|
| // The concrete implemenation of the proximity monitor interface.
|
| class ProximityMonitorImpl : public ProximityMonitor {
|
| public:
|
| - // The |observer| is not owned, and must outlive |this| instance.
|
| - ProximityMonitorImpl(const cryptauth::RemoteDevice& remote_device,
|
| + // The |connection| is not owned, and must outlive |this| instance.
|
| + ProximityMonitorImpl(cryptauth::Connection* connection,
|
| std::unique_ptr<base::TickClock> clock);
|
| ~ProximityMonitorImpl() override;
|
|
|
| // ProximityMonitor:
|
| void Start() override;
|
| void Stop() override;
|
| - Strategy GetStrategy() const override;
|
| bool IsUnlockAllowed() const override;
|
| - bool IsInRssiRange() const override;
|
| void RecordProximityMetricsOnAuthSuccess() override;
|
| void AddObserver(ProximityMonitorObserver* observer) override;
|
| void RemoveObserver(ProximityMonitorObserver* observer) override;
|
|
|
| - protected:
|
| - // Sets the proximity detection strategy. Exposed for testing.
|
| - // TODO(isherman): Stop exposing this for testing once prefs are properly
|
| - // hooked up.
|
| - virtual void SetStrategy(Strategy strategy);
|
| -
|
| private:
|
| - struct TransmitPowerReading {
|
| - TransmitPowerReading(int transmit_power, int max_transmit_power);
|
| -
|
| - // Returns true if |this| transmit power reading indicates proximity.
|
| - bool IsInProximity() const;
|
| -
|
| - // The current transmit power.
|
| - int transmit_power;
|
| -
|
| - // The maximum possible transmit power.
|
| - int max_transmit_power;
|
| - };
|
| -
|
| // Callback for asynchronous initialization of the Bluetooth adpater.
|
| void OnAdapterInitialized(scoped_refptr<device::BluetoothAdapter> adapter);
|
|
|
| @@ -95,7 +75,7 @@ class ProximityMonitorImpl : public ProximityMonitor {
|
| void ClearProximityState();
|
|
|
| // Updates the proximity state with a new |connection_info| sample of the
|
| - // current RSSI and Tx power, and the device's maximum Tx power.
|
| + // current RSSI.
|
| void AddSample(
|
| const device::BluetoothDevice::ConnectionInfo& connection_info);
|
|
|
| @@ -103,8 +83,9 @@ class ProximityMonitorImpl : public ProximityMonitor {
|
| // samples. Notifies |observers_| on a change.
|
| void CheckForProximityStateChange();
|
|
|
| - // The remote device being monitored.
|
| - const cryptauth::RemoteDevice remote_device_;
|
| + // The current connection being monitored. Not owned and must outlive this
|
| + // instance.
|
| + cryptauth::Connection* connection_;
|
|
|
| // The observers attached to the ProximityMonitor.
|
| base::ObserverList<ProximityMonitorObserver> observers_;
|
| @@ -112,9 +93,6 @@ class ProximityMonitorImpl : public ProximityMonitor {
|
| // The Bluetooth adapter that will be polled for connection info.
|
| scoped_refptr<device::BluetoothAdapter> bluetooth_adapter_;
|
|
|
| - // The strategy used to determine whether the remote device is in proximity.
|
| - Strategy strategy_;
|
| -
|
| // Whether the remote device is currently in close proximity to the local
|
| // device.
|
| bool remote_device_is_in_proximity_;
|
| @@ -129,11 +107,6 @@ class ProximityMonitorImpl : public ProximityMonitor {
|
| // measurement.
|
| std::unique_ptr<double> rssi_rolling_average_;
|
|
|
| - // The last TX power reading. Null if the monitor is inactive, has not
|
| - // recently observed a TX power reading, or the most recent connection info
|
| - // included an invalid measurement.
|
| - std::unique_ptr<TransmitPowerReading> last_transmit_power_reading_;
|
| -
|
| // The timestamp of the last zero RSSI reading. An RSSI value of 0 is special
|
| // because both devices adjust their transmit powers such that the RSSI is in
|
| // this golden range, if possible. Null if the monitor is inactive, has not
|
|
|