Low power scan results in the background will be delivered via Intent
6911
PendingIntent getScanCallbackIntent() {
        Intent intent = new Intent(mContext, StartupBroadcastReceiver.class);
        intent.putExtra("o-scan", true);
        return PendingIntent.getBroadcast(mContext,0, intent, PendingIntent.FLAG_UPDATE_CURRENT);
    }
1740
def scan(backend, timeout=10):
    
    result = []
    for (mac, name) in backend.scan_for_devices(timeout):
        if (name is not None and name.lower() in VALID_DEVICE_NAMES) or \
                mac is not None and mac.upper().startswith(DEVICE_PREFIX):
            result.append(mac.upper())
    return result
377767
def probe_sync(self):
        """"""

        done = threading.Event()
        result = {}

        def probe_done(adapter_id, status, reason):
            result['success'] = status
            result['failure_reason'] = reason
            done.set()

        self.probe_async(probe_done)
        done.wait()

        return result
75793
def click_signal(target_usage, target_vendor_id):
    """"""
    # usually you'll find and open the target device, here we'll browse for the
    # current connected devices
    all_devices = hid.HidDeviceFilter(vendor_id = target_vendor_id).get_devices()

    if not all_devices:
        print("Can't find target device (vendor_id = 0x%04x)!" % target_vendor_id)
    else:
        # search for our target usage
        # target pageId, usageId

        for device in all_devices:
            try:
                device.open()
                # browse output reports, we could search over feature reports also,
                # changing find_output_reports() to find_feature_reports()
                for report in device.find_output_reports():
                    if target_usage in report:
                        # found out target!
                        report[target_usage] = 1 # yes, changing values is that easy
                        # at this point you could change different usages at a time...
                        # and finally send the prepared output report
                        report.send()
                        # now toggle back the signal
                        report[target_usage] = 0
                        report.send()
                        print("\nUsage clicked!\n")
                        return
            finally:
                device.close()
        print("The target device was found, but the requested usage does not exist!\n")
1142882
function (successCallback, errorCallback) {
			if (!winble.deviceManager.isScanning) {
				winble.deviceManager.scanSuccessCallback = successCallback;
				winble.deviceManager.scanErrorCallback = errorCallback;
				winble.deviceManager.isScanning = true;
				setTimeout(function () {
					winble.deviceManager.scanDevices(successCallback, errorCallback);
				}, 500);
			}
		}
1366795
def __callback (self, scan):
        '''
        

        '''
        laser = laserScan2LaserData(scan)

        self.lock.acquire()
        self.data = laser
        self.lock.release()
654572
def scanned(self):
        """"""
        if self.request["Select"] == "COUNT":
            while not self.exhausted:
                next(self, None)
        return self._scanned
316201
def run_active_scan(self, target_url, recursive=False, context_name=None, user_name=None):
        """"""
        self.logger.debug('Scanning target {0}...'.format(target_url))

        context_id, user_id = self._get_context_and_user_ids(context_name, user_name)

        if user_id:
            self.logger.debug('Scanning in context {0} as user {1}'.format(context_id, user_id))
            scan_id = self.zap.ascan.scan_as_user(target_url, context_id, user_id, recursive)
        else:
            scan_id = self.zap.ascan.scan(target_url, recurse=recursive)

        if not scan_id:
            raise ZAPError('Error running active scan.')
        elif not scan_id.isdigit():
            raise ZAPError(('Error running active scan: "{0}". Make sure the URL is in the site ' +
                            'tree by using the open-url or scanner commands before running an active ' +
                            'scan.').format(scan_id))

        self.logger.debug('Started scan with ID {0}...'.format(scan_id))

        while int(self.zap.ascan.status()) < 100:
            self.logger.debug('Scan progress %: {0}'.format(self.zap.ascan.status()))
            time.sleep(self._status_check_sleep)

        self.logger.debug('Scan #{0} completed'.format(scan_id))
632668
async def scan_for_apple_tvs(loop, timeout=5, abort_on_found=False,
                             device_ip=None, only_usable=True,
                             protocol=None):
    """"""
    semaphore = asyncio.Semaphore(value=0, loop=loop)
    listener = _ServiceListener(
        loop, abort_on_found, device_ip, protocol, semaphore)
    zeroconf = Zeroconf()
    try:
        ServiceBrowser(zeroconf, HOMESHARING_SERVICE, listener)
        ServiceBrowser(zeroconf, DEVICE_SERVICE, listener)
        ServiceBrowser(zeroconf, MEDIAREMOTE_SERVICE, listener)
        ServiceBrowser(zeroconf, AIRPLAY_SERVICE, listener)
        _LOGGER.debug('Discovering devices for %d seconds', timeout)
        await asyncio.wait_for(semaphore.acquire(), timeout, loop=loop)
    except concurrent.futures.TimeoutError:
        pass  # Will happen when timeout occurs (totally normal)
    finally:
        zeroconf.close()

    def _should_include(atv):
        if not only_usable:
            return True

        return atv.is_usable()

    return list(filter(_should_include, listener.found_devices.values()))
195584
public void setActiveScan(ActiveScan scan) {
        this.scan = scan;

        if (scan == null) {
            return;
        }
        getHostSelect().removeAll();
        for (HostProcess hp : scan.getHostProcesses()) {
        	getHostSelect().addItem(hp.getHostAndPort());
        }

        Thread thread = new Thread() {
            @Override
            public void run() {
                while (!stopThread) {
                	SwingUtilities.invokeLater(new Runnable(){
						@Override
						public void run() {
							updateProgress();
						}});
                    
                    try {
                        sleep(200);
                        
                    } catch (InterruptedException e) {
                        // Ignore
                    }
                }
            }
        };
        
        thread.start();
    }
1040170
def _run_get_data_background(macs, queue, shared_data, bt_device):
    

    run_flag = RunFlag()

    def add_data(data):
        if not shared_data['run_flag']:
            run_flag.running = False

        data[1]['time'] = datetime.utcnow().isoformat()
        queue.put(data)

    RuuviTagSensor.get_datas(add_data, macs, run_flag, bt_device)
674189
def start_scan(self, active):
        """"""
        self._command_task.sync_command(['_start_scan', active])
        self.scanning = True
1108876
public static int getWidthOfScanningRectangleInPxOrZero(Intent intent) {
    if (intent == null) return 0;
    return intent.getIntExtra(Intents.Scan.WIDTH, 0);
  }
508260
void scan() {
        if (acquireScanLock()) {
            boolean scheduleRescan = false;
            try {
                scheduleRescan = scan(false, deploymentOperations);
            } finally {
                try {
                    if (scheduleRescan) {
                        synchronized (this) {
                            if (scanEnabled) {
                                rescanIncompleteTask = scheduledExecutor.schedule(scanRunnable, 200, TimeUnit.MILLISECONDS);
                            }
                        }
                    }
                } finally {
                    releaseScanLock();
                }
            }
        }
    }
123836
def toggle_scan(self, enable, filter_duplicates=False):
        """"""
        command = struct.pack(">BB", enable, filter_duplicates)
        self.bluez.hci_send_cmd(self.socket, OGF_LE_CTL, OCF_LE_SET_SCAN_ENABLE, command)
1280284
@Override
	public void deliverResult(Cursor cursor) {
		if (isReset()) {
			// An async query came in while the loader is stopped
			if (cursor != null) {
				cursor.close();
			}
			return;
		}
		Cursor oldCursor = mCursor;
		mCursor = cursor;

		if (isStarted()) {
			super.deliverResult(cursor);
		}

		if (oldCursor != null && oldCursor != cursor && !oldCursor.isClosed()) {
			oldCursor.close();
		}
	}
958526
void notifyWhenStateChanged(Runnable callback, Executor executor, ConnectivityState source) {
    checkNotNull(callback, "callback");
    checkNotNull(executor, "executor");
    checkNotNull(source, "source");

    Listener stateChangeListener = new Listener(callback, executor);
    if (state != source) {
      stateChangeListener.runInExecutor();
    } else {
      listeners.add(stateChangeListener);
    }
  }