Ensure Bluetooth is turned on.

@throws IllegalStateException If {@code adapter} is null or Bluetooth state is not
{@link BluetoothAdapter#STATE_ON}.
760477
@RequiresPermission(Manifest.permission.BLUETOOTH)
	static void checkAdapterStateOn(@Nullable final BluetoothAdapter adapter) {
		if (adapter == null || adapter.getState() != BluetoothAdapter.STATE_ON) {
			throw new IllegalStateException("BT Adapter is not turned ON");
		}
	}
1006669
private void notifyAdditionalOnScrollStateChangedListener(AbsListView view, int scrollState) {
        if (mAdditionalOnScrollListener != null) {
            mAdditionalOnScrollListener.onScrollStateChanged(view, scrollState);
        }
    }
1071441
public boolean addWifiStateChangedListener(
			NetworkStateChangedListener listener) {
		synchronized (this) {
			if (listeners.contains(listener)) {
				return true;
			}
			return listeners.add(listener);
		}
	}
786718
private <T> Observable<T> bluetoothAdapterOffExceptionObservable() {
        return rxBleAdapterStateObservable
                .filter(new Predicate<BleAdapterState>() {
                    @Override
                    public boolean test(BleAdapterState state) throws Exception {
                        return state != BleAdapterState.STATE_ON;
                    }
                })
                .firstElement()
                .flatMap(new Function<BleAdapterState, MaybeSource<T>>() {
                    @Override
                    public MaybeSource<T> apply(BleAdapterState bleAdapterState) throws Exception {
                        return Maybe.error(new BleScanException(BleScanException.BLUETOOTH_DISABLED));
                    }
                })
                .toObservable();
    }
685556
public synchronized void checkState(State requiredState) throws IllegalStateException {
        if (requiredState != currentState) {
            throw new IllegalStateException(String.format(Locale.US,
                    "Expected state %s, but in state %s", requiredState, currentState));
        }
    }
240561
@Override
	public void start(
		Callback<? super Socket> onStart,
		Callback<? super Exception> onError
	) throws IllegalStateException {
		if(isClosed()) throw new IllegalStateException("Socket is closed");
		startImpl(onStart, onError);
	}
433287
private synchronized void onStateChange(PrimitiveState state) {
    if (this.state != state) {
      if (state == PrimitiveState.EXPIRED) {
        if (connected) {
          onStateChange(PrimitiveState.SUSPENDED);
          recover();
        } else {
          log.debug("State changed: {}", state);
          this.state = state;
          stateChangeListeners.forEach(l -> l.accept(state));
        }
      } else {
        log.debug("State changed: {}", state);
        this.state = state;
        stateChangeListeners.forEach(l -> l.accept(state));
        if (state == PrimitiveState.CLOSED) {
          connectFuture = Futures.exceptionalFuture(new PrimitiveException.ClosedSession());
          session = null;
        }
      }
    }
  }
277455
public void setAdapter(SpinnerAdapter adapter) {
		if(mAdapter != null)
			mAdapter.unregisterDataSetObserver(mDataSetObserver);

        mRecycler.clear();

		mAdapter = adapter;
		mAdapter.registerDataSetObserver(mDataSetObserver);
		onDataChanged();

        if (mPopup != null)
            mPopup.setAdapter(new DropDownAdapter(adapter));
        else
            mTempAdapter = new DropDownAdapter(adapter);
	}
1205456
def add_adapter(self, adapter):
        """"""

        if self._started:
            raise InternalError("New adapters cannot be added after start() is called")

        if isinstance(adapter, DeviceAdapter):
            self._logger.warning("Wrapping legacy device adapter %s in async wrapper", adapter)
            adapter = AsynchronousModernWrapper(adapter, loop=self._loop)

        self.adapters.append(adapter)

        adapter_callback = functools.partial(self.handle_adapter_event,
                                             len(self.adapters) - 1)
        events = ['device_seen', 'broadcast', 'report', 'connection',
                  'disconnection', 'trace', 'progress']

        adapter.register_monitor([None], events, adapter_callback)
554830
public BaseAttacher start() {

        if(mAdapterView == null) {
            throw new IllegalStateException("Adapter View cannot be null");
        }

        if(mMugenCallbacks == null) {
            throw new IllegalStateException("MugenCallbacks cannot be null");
        }

        if(mLoadMoreOffset <= 0) {
            throw new IllegalStateException("Trigger Offset must be > 0");
        }
        mIsLoadMoreEnabled = true;
        init();
        return this;
    }
842614
public static void waitWhileState(final DeviceProxy proxy, final DevState waitState, final long timeout,
	    final long pollingTime) throws DevFailed, TimeoutException {
	final long time0 = System.currentTimeMillis();

	while (proxy.state().equals(waitState)) {
	    if (System.currentTimeMillis() - time0 > timeout) {
		throw new TimeoutException(
			"Stateutilities.waitWhileState : timeout reached while waiting end of state "
				+ TangoConst.Tango_DevStateName[waitState.value()]);
	    }
	    try {
		Thread.sleep(pollingTime);
	    } catch (final InterruptedException e) {
		// ignore
	    }
	}

    }
3018
public synchronized void connected(BluetoothSocket socket, BluetoothDevice
            device, final String socketType) {
        // Cancel the thread that completed the connection
        if (mConnectThread != null) {mConnectThread.cancel(); mConnectThread = null;}

        // Cancel any thread currently running a connection
        if (mConnectedThread != null) {mConnectedThread.cancel(); mConnectedThread = null;}

        // Cancel the accept thread because we only want to tryConnect to one device
        if (mSecureAcceptThread != null) {
            mSecureAcceptThread.cancel();
            mSecureAcceptThread = null;
        }

        // Start the thread to manage the connection and perform transmissions
        mConnectedThread = new ConnectedThread(socket, socketType);
        mConnectedThread.start();

        // Send the name of the connected device back to the UI Activity
        Message msg = mHandler.obtainMessage(MESSAGE_DEVICE_NAME);
        mHandler.sendMessage(msg);

        setState(BluetoothService.STATE_CONNECTED);
    }
956311
@Override
    public void start() throws Exception {

        if (dependency == null) {
            throw new IllegalStateException("Dependency was not injected!");
        }

        vertx.eventBus().consumer(EB_ADDRESS, this);

        super.start();
    }
705275
public void setAdapter(RecyclerView.Adapter adapter) {
        if (mWrappedAdapter != null && mWrappedAdapter.getItemCount() > 0) {
            notifyItemRangeRemoved(getHeaderCount(), mWrappedAdapter.getItemCount());
        }
        setWrappedAdapter(adapter);
        notifyItemRangeInserted(getHeaderCount(), mWrappedAdapter.getItemCount());
    }
535039
boolean isAsynchConsumerRunning()
  {
    if (TraceComponent.isAnyTracingEnabled() && tc.isEntryEnabled())
    {
      SibTr.entry(tc, "isAsynchConsumerRunning");
      SibTr.exit(tc, "isAsynchConsumerRunning",
                 new Boolean(asynchConsumerRunning));
    }
      
    return asynchConsumerRunning;
    
  }
708394
function (successCallback, errorCallback) {

			// Windows does not provide a way to programmatically disable/enable the Bluetooth stack,
			// so we need to ask the user to do it for us. Display a dialog telling the user we're having trouble,
			// ask them to please toggle Bluetooth off-and-on on the next screen, and then take them to the
			// Bluetooth Settings screen.
			var dialogCallback = function (buttonNumber) {
				winble.logger.logDebug("turnBluetoothOffAndOn", "User clicked " + buttonNumber);
				if (buttonNumber == 1) {
					var uri = new Windows.Foundation.Uri("ms-settings-bluetooth:");
					Windows.System.Launcher.launchUriAsync(uri).done(
						function (launchSucceeded) {
							winble.logger.logDebug("turnBluetoothOffAndOn", "launchUriAsync returned " + launchSucceeded);
							successCallback();
						});
				} else {
					errorCallback("User declined to reset device");
				}
			};
			var prompt = "This device is having trouble communicating with your external Bluetooth devices;";
			prompt += " turning Bluetooth off and back on again in the Bluetooth Settings panel may fix the problem.";
			prompt += " Do you want to try that now?";
			navigator.notification.confirm(prompt, dialogCallback, "Reset Bluetooth?", ["Yes", "No"]);
		}
68049
public SolrTransactionSynchronizationAdapter withDefaultBehaviour() {

		this.adapter.registerCompletionDelegate(TransactionSynchronization.STATUS_COMMITTED,
				new SolrTransactionSynchronizationAdapter.CommitTransaction(this.collectionName));
		this.adapter.registerCompletionDelegate(TransactionSynchronization.STATUS_ROLLED_BACK,
				new SolrTransactionSynchronizationAdapter.RollbackTransaction(this.collectionName));

		return this.adapter;
	}