Merge "Changes for API of Bluetooth Discoverability. DO NOT MERGE" into gingerbread

This commit is contained in:
Jaikumar Ganesh
2011-05-27 13:28:49 -07:00
committed by Android (Google) Code Review
3 changed files with 6 additions and 16 deletions

View File

@@ -249,7 +249,7 @@
<string name="bluetooth_ask_discovery">"An application on your phone is requesting permission to make your phone discoverable by other Bluetooth devices for <xliff:g id="timeout">%1$d</xliff:g> seconds. Do you want to do this?"</string> <string name="bluetooth_ask_discovery">"An application on your phone is requesting permission to make your phone discoverable by other Bluetooth devices for <xliff:g id="timeout">%1$d</xliff:g> seconds. Do you want to do this?"</string>
<!-- Strings for asking to the user whether to allow an app to enable lasting discovery mode --> <!-- Strings for asking to the user whether to allow an app to enable lasting discovery mode -->
<string name="bluetooth_ask_lasting_discovery">"An application on your phone is requesting permission to make your phone always discoverable by other Bluetooth devices. Do you want to do this?"</string> <string name="bluetooth_ask_lasting_discovery">"An application on your phone is requesting permission to make your phone \u201calways discoverable\u201d by other Bluetooth devices. Do you want to do this?"</string>
<!-- Strings for asking to the user whether to allow an app to enable bluetooth and discovery mode --> <!-- Strings for asking to the user whether to allow an app to enable bluetooth and discovery mode -->
<string name="bluetooth_ask_enablement_and_discovery">"An application on your phone is requesting permission to turn on Bluetooth and to make your phone discoverable by other devices for <xliff:g id="timeout">%1$d</xliff:g> seconds. Do you want to do this?"</string> <string name="bluetooth_ask_enablement_and_discovery">"An application on your phone is requesting permission to turn on Bluetooth and to make your phone discoverable by other devices for <xliff:g id="timeout">%1$d</xliff:g> seconds. Do you want to do this?"</string>

View File

@@ -56,8 +56,6 @@ public class BluetoothDiscoverableEnabler implements Preference.OnPreferenceChan
private static final String VALUE_DISCOVERABLE_TIMEOUT_ONE_HOUR = "onehour"; private static final String VALUE_DISCOVERABLE_TIMEOUT_ONE_HOUR = "onehour";
private static final String VALUE_DISCOVERABLE_TIMEOUT_NEVER = "never"; private static final String VALUE_DISCOVERABLE_TIMEOUT_NEVER = "never";
// no need for this timeout anymore since we have the listPreference default value
// leaving now temporary until requestpermissionactivity is modified..
static final int DEFAULT_DISCOVERABLE_TIMEOUT = DISCOVERABLE_TIMEOUT_TWO_MINUTES; static final int DEFAULT_DISCOVERABLE_TIMEOUT = DISCOVERABLE_TIMEOUT_TWO_MINUTES;
private final Context mContext; private final Context mContext;

View File

@@ -43,7 +43,7 @@ public class RequestPermissionActivity extends Activity implements
private static final String TAG = "RequestPermissionActivity"; private static final String TAG = "RequestPermissionActivity";
private static final int MAX_DISCOVERABLE_TIMEOUT = 300; private static final int MAX_DISCOVERABLE_TIMEOUT = 3600; // 1 hr
// Non-error return code: BT is starting or has started successfully. Used // Non-error return code: BT is starting or has started successfully. Used
// by this Activity and RequestPermissionHelperActivity // by this Activity and RequestPermissionHelperActivity
@@ -158,13 +158,12 @@ public class RequestPermissionActivity extends Activity implements
} else { } else {
// Ask the user whether to turn on discovery mode or not // Ask the user whether to turn on discovery mode or not
// For lasting discoverable mode there is a different message // For lasting discoverable mode there is a different message
// TODO(): Revisit this when public APIs for discoverable timeout are introduced.
if (mTimeout == BluetoothDiscoverableEnabler.DISCOVERABLE_TIMEOUT_NEVER) { if (mTimeout == BluetoothDiscoverableEnabler.DISCOVERABLE_TIMEOUT_NEVER) {
builder.setMessage( builder.setMessage(
getString(R.string.bluetooth_ask_enablement_and_lasting_discovery)); getString(R.string.bluetooth_ask_lasting_discovery));
} else { } else {
builder.setMessage( builder.setMessage(
getString(R.string.bluetooth_ask_enablement_and_discovery, mTimeout)); getString(R.string.bluetooth_ask_discovery, mTimeout));
} }
builder.setPositiveButton(getString(R.string.yes), this); builder.setPositiveButton(getString(R.string.yes), this);
builder.setNegativeButton(getString(R.string.no), this); builder.setNegativeButton(getString(R.string.no), this);
@@ -249,16 +248,9 @@ public class RequestPermissionActivity extends Activity implements
mTimeout = intent.getIntExtra(BluetoothAdapter.EXTRA_DISCOVERABLE_DURATION, mTimeout = intent.getIntExtra(BluetoothAdapter.EXTRA_DISCOVERABLE_DURATION,
BluetoothDiscoverableEnabler.DEFAULT_DISCOVERABLE_TIMEOUT); BluetoothDiscoverableEnabler.DEFAULT_DISCOVERABLE_TIMEOUT);
Log.e(TAG, "Timeout = " + mTimeout); Log.d(TAG, "Setting Bluetooth Discoverable Timeout = " + mTimeout);
// Right now assuming for simplicity that an app can pick any int value, if (mTimeout < 0 || mTimeout > MAX_DISCOVERABLE_TIMEOUT) {
// and if equal to BluetoothDiscoverableEnabler.DISCOVERABLE_TIMEOUT_NEVER
// it will be treated as a request for lasting discoverability.
// Alternatively, a check can be added here for enforcing the specific allowed values
// as listed in BluetoothDiscoverableEnabler.
// We need to make all these value public.
if (mTimeout <= 0) {
mTimeout = BluetoothDiscoverableEnabler.DEFAULT_DISCOVERABLE_TIMEOUT; mTimeout = BluetoothDiscoverableEnabler.DEFAULT_DISCOVERABLE_TIMEOUT;
} }
} else { } else {