Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

DISCOVERABLE_TIMEOUT_MS correction #2

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@

/**
* Sample usage of the A2DP sink bluetooth profile. At startup, this activity sets the Bluetooth
* adapter in pairing mode for {@link #DISCOVERABLE_TIMEOUT_MS} ms.
* adapter in pairing mode for {@link #DISCOVERABLE_TIMEOUT_S} s.
*
* To re-enable pairing mode, press "p" on an attached keyboard, use "adb shell input keyevent 44"
* or press a button attached to the GPIO pin returned by {@link BoardDefaults#getGPIOForPairing()}
Expand All @@ -57,7 +57,7 @@ public class A2DPSinkActivity extends Activity {
private static final String TAG = "A2DPSinkActivity";

private static final String ADAPTER_FRIENDLY_NAME = "My Android Things device";
private static final int DISCOVERABLE_TIMEOUT_MS = 300;
private static final int DISCOVERABLE_TIMEOUT_S = 300;
private static final int REQUEST_CODE_ENABLE_DISCOVERABLE = 100;

private static final String UTTERANCE_ID =
Expand Down Expand Up @@ -243,14 +243,14 @@ public void onServiceDisconnected(int profile) {

/**
* Enable the current {@link BluetoothAdapter} to be discovered (available for pairing) for
* the next {@link #DISCOVERABLE_TIMEOUT_MS} ms.
* the next {@link #DISCOVERABLE_TIMEOUT_S} s.
*/
private void enableDiscoverable() {
Log.d(TAG, "Registering for discovery.");
Intent discoverableIntent =
new Intent(BluetoothAdapter.ACTION_REQUEST_DISCOVERABLE);
discoverableIntent.putExtra(BluetoothAdapter.EXTRA_DISCOVERABLE_DURATION,
DISCOVERABLE_TIMEOUT_MS);
DISCOVERABLE_TIMEOUT_S);
startActivityForResult(discoverableIntent, REQUEST_CODE_ENABLE_DISCOVERABLE);
}

Expand All @@ -261,7 +261,7 @@ protected void onActivityResult(int requestCode, int resultCode, Intent data) {
Log.d(TAG, "Enable discoverable returned with result " + resultCode);

// ResultCode, as described in BluetoothAdapter.ACTION_REQUEST_DISCOVERABLE, is either
// RESULT_CANCELED or the number of milliseconds that the device will stay in
// RESULT_CANCELED or the number of seconds that the device will stay in
// discoverable mode. In a regular Android device, the user will see a popup requesting
// authorization, and if they cancel, RESULT_CANCELED is returned. In Android Things,
// on the other hand, the authorization for pairing is always given without user
Expand All @@ -273,16 +273,16 @@ protected void onActivityResult(int requestCode, int resultCode, Intent data) {
}
Log.i(TAG, "Bluetooth adapter successfully set to discoverable mode. " +
"Any A2DP source can find it with the name " + ADAPTER_FRIENDLY_NAME +
" and pair for the next " + DISCOVERABLE_TIMEOUT_MS + " ms. " +
" and pair for the next " + DISCOVERABLE_TIMEOUT_S + " s. " +
"Try looking for it on your phone, for example.");

// There is nothing else required here, since Android framework automatically handles
// A2DP Sink. Most relevant Bluetooth events, like connection/disconnection, will
// generate corresponding broadcast intents or profile proxy events that you can
// listen to and react appropriately.

speak("Bluetooth audio sink is discoverable for " + DISCOVERABLE_TIMEOUT_MS +
" milliseconds. Look for a device named " + ADAPTER_FRIENDLY_NAME);
speak("Bluetooth audio sink is discoverable for " + DISCOVERABLE_TIMEOUT_S +
" seconds. Look for a device named " + ADAPTER_FRIENDLY_NAME);

}
}
Expand Down