packages/apps/Settings
Revisão | 32c7a774f505be6aae23984ee341bede59395d68 (tree) |
---|---|
Hora | 2011-05-28 02:32:18 |
Autor | Jaikumar Ganesh <jaikumar@goog...> |
Commiter | Jaikumar Ganesh |
Changes for API of Bluetooth Discoverability. DO NOT MERGE
1. Apps can ask for any time between 0 and 3600 secs
2. O implies always discoverable
3. Any invalid values will default to the default - 120 secs.
A dialog is shown by the system to the users to accept the change
in discoverability values.
Change-Id: I34ebd907656a87508b0f0b1a4bce78134edcaebf
@@ -249,7 +249,7 @@ | ||
249 | 249 | <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> |
250 | 250 | |
251 | 251 | <!-- Strings for asking to the user whether to allow an app to enable lasting discovery mode --> |
252 | - <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> | |
252 | + <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> | |
253 | 253 | |
254 | 254 | <!-- Strings for asking to the user whether to allow an app to enable bluetooth and discovery mode --> |
255 | 255 | <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> |
@@ -56,8 +56,6 @@ public class BluetoothDiscoverableEnabler implements Preference.OnPreferenceChan | ||
56 | 56 | private static final String VALUE_DISCOVERABLE_TIMEOUT_ONE_HOUR = "onehour"; |
57 | 57 | private static final String VALUE_DISCOVERABLE_TIMEOUT_NEVER = "never"; |
58 | 58 | |
59 | - // no need for this timeout anymore since we have the listPreference default value | |
60 | - // leaving now temporary until requestpermissionactivity is modified.. | |
61 | 59 | static final int DEFAULT_DISCOVERABLE_TIMEOUT = DISCOVERABLE_TIMEOUT_TWO_MINUTES; |
62 | 60 | |
63 | 61 | private final Context mContext; |
@@ -43,7 +43,7 @@ public class RequestPermissionActivity extends Activity implements | ||
43 | 43 | |
44 | 44 | private static final String TAG = "RequestPermissionActivity"; |
45 | 45 | |
46 | - private static final int MAX_DISCOVERABLE_TIMEOUT = 300; | |
46 | + private static final int MAX_DISCOVERABLE_TIMEOUT = 3600; // 1 hr | |
47 | 47 | |
48 | 48 | // Non-error return code: BT is starting or has started successfully. Used |
49 | 49 | // by this Activity and RequestPermissionHelperActivity |
@@ -158,13 +158,12 @@ public class RequestPermissionActivity extends Activity implements | ||
158 | 158 | } else { |
159 | 159 | // Ask the user whether to turn on discovery mode or not |
160 | 160 | // For lasting discoverable mode there is a different message |
161 | - // TODO(): Revisit this when public APIs for discoverable timeout are introduced. | |
162 | 161 | if (mTimeout == BluetoothDiscoverableEnabler.DISCOVERABLE_TIMEOUT_NEVER) { |
163 | 162 | builder.setMessage( |
164 | - getString(R.string.bluetooth_ask_enablement_and_lasting_discovery)); | |
163 | + getString(R.string.bluetooth_ask_lasting_discovery)); | |
165 | 164 | } else { |
166 | 165 | builder.setMessage( |
167 | - getString(R.string.bluetooth_ask_enablement_and_discovery, mTimeout)); | |
166 | + getString(R.string.bluetooth_ask_discovery, mTimeout)); | |
168 | 167 | } |
169 | 168 | builder.setPositiveButton(getString(R.string.yes), this); |
170 | 169 | builder.setNegativeButton(getString(R.string.no), this); |
@@ -249,16 +248,9 @@ public class RequestPermissionActivity extends Activity implements | ||
249 | 248 | mTimeout = intent.getIntExtra(BluetoothAdapter.EXTRA_DISCOVERABLE_DURATION, |
250 | 249 | BluetoothDiscoverableEnabler.DEFAULT_DISCOVERABLE_TIMEOUT); |
251 | 250 | |
252 | - Log.e(TAG, "Timeout = " + mTimeout); | |
251 | + Log.d(TAG, "Setting Bluetooth Discoverable Timeout = " + mTimeout); | |
253 | 252 | |
254 | - // Right now assuming for simplicity that an app can pick any int value, | |
255 | - // and if equal to BluetoothDiscoverableEnabler.DISCOVERABLE_TIMEOUT_NEVER | |
256 | - // it will be treated as a request for lasting discoverability. | |
257 | - // Alternatively, a check can be added here for enforcing the specific allowed values | |
258 | - // as listed in BluetoothDiscoverableEnabler. | |
259 | - // We need to make all these value public. | |
260 | - | |
261 | - if (mTimeout <= 0) { | |
253 | + if (mTimeout < 0 || mTimeout > MAX_DISCOVERABLE_TIMEOUT) { | |
262 | 254 | mTimeout = BluetoothDiscoverableEnabler.DEFAULT_DISCOVERABLE_TIMEOUT; |
263 | 255 | } |
264 | 256 | } else { |