BleAdvertiser extends AdvertiseCallback { void setAdvertiseData(AdvertiseData advertiseData) { Log.d(TAG, "setAdvertiseData: " + ThreadUtils.currentThreadToString()); if (advertiseData != null) { Log.d(TAG, "setAdvertiseData: " + advertiseData.toString() + ". " + ThreadUtils.currentThreadToString()); boolean wasStarted = isStarted(); Log.d(TAG, "setAdvertiseData: was started = " + wasStarted); if (wasStarted) { stop(false); } Log.d(TAG, "setAdvertiseData: advertiseData = " + advertiseData.toString()); mAdvertiseData = advertiseData; if (wasStarted) { start(); } } else { throw new IllegalArgumentException("The given advertise data is null"); } Log.d(TAG, "setAdvertiseData finished: " + ThreadUtils.currentThreadToString()); } BleAdvertiser(Listener listener, BluetoothAdapter bluetoothAdapter);   BleAdvertiser(Listener listener, BluetoothAdapter bluetoothAdapter,
                  AdvertiseSettings.Builder builder, DiscoveryManagerSettings settings); void setAdvertiseSettings(AdvertiseSettings advertiseSettings); boolean isStarted(); synchronized boolean start(); synchronized void stop(boolean notifyStateChanged); @Override void onStartFailure(int errorCode); @Override void onStartSuccess(AdvertiseSettings settingsInEffect);  }
@Test public void testSetAdvertiseData_exception() throws Exception { thrown.expect(IllegalArgumentException.class); mBleAdvertiser.setAdvertiseData(null); }