question: public void discoverable ( BluetoothAdapter adapter ) { int mask = BluetoothReceiver . SCAN_MODE_CONNECTABLE_DISCOVERABLE_FLAG ; if ( ! adapter . isEnabled ( ) ) { fail ( "discoverable() bluetooth not enabled" ) ; } int scanMode = adapter . getScanMode ( ) ; if ( scanMode == BluetoothAdapter . SCAN_MODE_CONNECTABLE_DISCOVERABLE ) { return ; } BluetoothReceiver receiver = getBluetoothReceiver ( mask ) ; assertEquals ( BluetoothAdapter . SCAN_MODE_CONNECTABLE , scanMode ) ; long start = System . currentTimeMillis ( ) ; assertTrue ( adapter . setScanMode ( BluetoothAdapter . SCAN_MODE_CONNECTABLE_DISCOVERABLE ) ) ; while ( System . currentTimeMillis ( ) - start < DISCOVERABLE_UNDISCOVERABLE_TIMEOUT ) { scanMode = adapter . getScanMode ( ) ; if ( scanMode == BluetoothAdapter . SCAN_MODE_CONNECTABLE_DISCOVERABLE && ( receiver . getFiredFlags ( ) & mask ) == mask ) { writeOutput ( String . format ( "discoverable() completed in %d ms" , ( receiver . getCompletedTime ( ) - start ) ) ) ; removeReceiver ( receiver ) ; return ; } sleep ( POLL_TIME ) ; } int firedFlags = receiver . getFiredFlags ( ) ; removeReceiver ( receiver ) ; fail ( String . format ( "discoverable() timeout: scanMode=%d (expected %d), flags=0x%x " + "(expected 0x%x)" , scanMode , BluetoothAdapter . SCAN_MODE_CONNECTABLE_DISCOVERABLE , firedFlags , mask ) ) ; }
target:  Puts the local device into discoverable mode and checks to make sure that the local device is in discoverable mode and that the correct actions were broadcast.