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