DiscoveryManagerSettings extends AbstractSettings { @Override public void resetDefaults() { Log.i(TAG, "resetDefaults"); setAutomateBluetoothMacAddressResolution(DEFAULT_AUTOMATE_BLUETOOTH_MAC_ADDRESS_RESOLUTION); setProvideBluetoothMacAddressTimeout(DEFAULT_PROVIDE_BLUETOOTH_MAC_ADDRESS_TIMEOUT_IN_MILLISECONDS); setBluetoothMacAddress(null); setDiscoveryMode(DEFAULT_DISCOVERY_MODE, true); setPeerExpiration(DEFAULT_PEER_EXPIRATION_IN_MILLISECONDS); setManufacturerId(DEFAULT_MANUFACTURER_ID); setBeaconAdLengthAndType(DEFAULT_BEACON_AD_LENGTH_AND_TYPE); setBeaconAdExtraInformation(DEFAULT_BEACON_AD_EXTRA_INFORMATION); setAdvertisementDataType(DEFAULT_ADVERTISEMENT_DATA_TYPE); setAdvertiseMode(DEFAULT_ADVERTISE_MODE); setAdvertiseTxPowerLevel(DEFAULT_ADVERTISE_TX_POWER_LEVEL); setScanMode(DEFAULT_SCAN_MODE); setScanReportDelay(DEFAULT_SCAN_REPORT_DELAY_IN_FOREGROUND_IN_MILLISECONDS); } private  DiscoveryManagerSettings(Context context); private  DiscoveryManagerSettings(Context context, SharedPreferences preferences); static DiscoveryManagerSettings getInstance(Context context); static DiscoveryManagerSettings getInstance(Context context, SharedPreferences preferences); boolean getAutomateBluetoothMacAddressResolution(); void setAutomateBluetoothMacAddressResolution(boolean automate); long getProvideBluetoothMacAddressTimeout(); void setProvideBluetoothMacAddressTimeout(long provideBluetoothMacAddressTimeoutInMilliseconds); String getBluetoothMacAddress(); void setBluetoothMacAddress(String bluetoothMacAddress); void clearBluetoothMacAddress(); DiscoveryMode getDiscoveryMode(); boolean setDiscoveryMode(final DiscoveryMode discoveryMode, boolean startIfNotRunning); boolean setDiscoveryMode(final DiscoveryMode discoveryMode); long getPeerExpiration(); void setPeerExpiration(long peerExpirationInMilliseconds); int getManufacturerId(); void setManufacturerId(int manufacturerId); int getBeaconAdLengthAndType(); void setBeaconAdLengthAndType(int beaconAdLengthAndType); int getBeaconAdExtraInformation(); void setBeaconAdExtraInformation(int beaconAdExtraInformation); AdvertisementDataType getAdvertisementDataType(); void setAdvertisementDataType(AdvertisementDataType advertisementDataType); int getAdvertiseMode(); void setAdvertiseMode(int advertiseMode); int getAdvertiseTxPowerLevel(); void setAdvertiseTxPowerLevel(int advertiseTxPowerLevel); int getScanMode(); void setScanMode(int scanMode); long getScanReportDelay(); void setScanReportDelay(long scanReportDelayInMilliseconds); void setAdvertiseScanModeAndTxPowerLevel(int advertiseMode, int advertiseTxPowerLevel, int scanMode); @Override void load(); @Override void resetDefaults(); static final boolean DEFAULT_AUTOMATE_BLUETOOTH_MAC_ADDRESS_RESOLUTION; static final long DEFAULT_PROVIDE_BLUETOOTH_MAC_ADDRESS_TIMEOUT_IN_MILLISECONDS; static final int DEFAULT_DEVICE_DISCOVERABLE_DURATION_IN_SECONDS; static final DiscoveryMode DEFAULT_DISCOVERY_MODE; static final long DEFAULT_PEER_EXPIRATION_IN_MILLISECONDS; static final int DEFAULT_MANUFACTURER_ID; static final int DEFAULT_BEACON_AD_LENGTH_AND_TYPE; static final int DEFAULT_BEACON_AD_EXTRA_INFORMATION; static final AdvertisementDataType DEFAULT_ADVERTISEMENT_DATA_TYPE; static final int DEFAULT_ADVERTISE_MODE; static final int DEFAULT_ADVERTISE_TX_POWER_LEVEL; static final int DEFAULT_SCAN_MODE; static final long DEFAULT_SCAN_REPORT_DELAY_IN_FOREGROUND_IN_MILLISECONDS; static final long DEFAULT_SCAN_REPORT_DELAY_IN_BACKGROUND_IN_MILLISECONDS; }
@Test public void testResetDefaults() throws Exception { mDiscoveryManagerSettings.resetDefaults(); assertThat("Default Bluetooth MAC address automation is set", mDiscoveryManagerSettings.getAutomateBluetoothMacAddressResolution(), is(equalTo(DiscoveryManagerSettings.DEFAULT_AUTOMATE_BLUETOOTH_MAC_ADDRESS_RESOLUTION))); assertThat("Default maximum duration of \"Provide Bluetooth MAC address\" is set", mDiscoveryManagerSettings.getProvideBluetoothMacAddressTimeout(), is(equalTo(DiscoveryManagerSettings.DEFAULT_PROVIDE_BLUETOOTH_MAC_ADDRESS_TIMEOUT_IN_MILLISECONDS))); assertThat("Default Bluetooth MAC address of this device is set", mDiscoveryManagerSettings.getBluetoothMacAddress(), is(equalTo(null))); assertThat("Default discovery mode is set", mDiscoveryManagerSettings.getDiscoveryMode(), is(equalTo(DiscoveryManager.DiscoveryMode.BLE))); assertThat("Default peer expiration time in milliseconds is set", mDiscoveryManagerSettings.getPeerExpiration(), is(equalTo(DiscoveryManagerSettings.DEFAULT_PEER_EXPIRATION_IN_MILLISECONDS))); assertThat("Default Bluetooth LE advertise model is set", mDiscoveryManagerSettings.getAdvertiseMode(), is(equalTo(DiscoveryManagerSettings.DEFAULT_ADVERTISE_MODE))); assertThat("Default Bluetooth LE advertise TX power level is set", mDiscoveryManagerSettings.getAdvertiseTxPowerLevel(), is(equalTo(DiscoveryManagerSettings.DEFAULT_ADVERTISE_TX_POWER_LEVEL))); assertThat("Default Bluetooth LE scan mode is set", mDiscoveryManagerSettings.getScanMode(), is(equalTo(DiscoveryManagerSettings.DEFAULT_SCAN_MODE))); assertThat("Default scan report delay is set", mDiscoveryManagerSettings.getScanReportDelay(), is(equalTo(DiscoveryManagerSettings.DEFAULT_SCAN_REPORT_DELAY_IN_FOREGROUND_IN_MILLISECONDS))); }