diff options
author | Zhihai Xu <zhihaixu@google.com> | 2013-10-11 12:15:19 -0700 |
---|---|---|
committer | Zhihai Xu <zhihaixu@google.com> | 2013-10-11 12:15:19 -0700 |
commit | 9998639a657825babd2514fd9af9726c068544c8 (patch) | |
tree | f9b8fd58d5972044a064ec6cd17d83cac30e51ff /src/com/android/settings/bluetooth | |
parent | 6e96aff5546f02199cf4c8aba0bae132d7d35e43 (diff) | |
download | packages_apps_Settings-9998639a657825babd2514fd9af9726c068544c8.tar.gz packages_apps_Settings-9998639a657825babd2514fd9af9726c068544c8.tar.bz2 packages_apps_Settings-9998639a657825babd2514fd9af9726c068544c8.zip |
BT keeps on asking me if I want to allow car to do stuff
We can remember it as a non persist global value when user click no.
This value won't be saved when power down.
We will restore the permission choice
when we are disconnected with the remote device.
So the "no" choice selected by user will only take effect
until we are disconnected with the remote device.
bug:11176511
Change-Id: Ic0c0829587cf7a812b5fa96fbd381921f67c186f
Diffstat (limited to 'src/com/android/settings/bluetooth')
-rwxr-xr-x | src/com/android/settings/bluetooth/BluetoothPermissionActivity.java | 2 | ||||
-rwxr-xr-x | src/com/android/settings/bluetooth/CachedBluetoothDevice.java | 31 |
2 files changed, 30 insertions, 3 deletions
diff --git a/src/com/android/settings/bluetooth/BluetoothPermissionActivity.java b/src/com/android/settings/bluetooth/BluetoothPermissionActivity.java index e73857a0b..9f071cc66 100755 --- a/src/com/android/settings/bluetooth/BluetoothPermissionActivity.java +++ b/src/com/android/settings/bluetooth/BluetoothPermissionActivity.java @@ -197,7 +197,7 @@ public class BluetoothPermissionActivity extends AlertActivity implements private void onNegative() { if (DEBUG) Log.d(TAG, "onNegative"); - savePermissionChoice(mRequestType, CachedBluetoothDevice.ACCESS_UNKNOWN); + savePermissionChoice(mRequestType, CachedBluetoothDevice.ACCESS_REJECTED); sendIntentToReceiver(BluetoothDevice.ACTION_CONNECTION_ACCESS_REPLY, false, null, false // dummy value, no effect since last param is null ); diff --git a/src/com/android/settings/bluetooth/CachedBluetoothDevice.java b/src/com/android/settings/bluetooth/CachedBluetoothDevice.java index a9fd5ed71..61d793a29 100755 --- a/src/com/android/settings/bluetooth/CachedBluetoothDevice.java +++ b/src/com/android/settings/bluetooth/CachedBluetoothDevice.java @@ -130,6 +130,23 @@ final class CachedBluetoothDevice implements Comparable<CachedBluetoothDevice> { return; } mProfileConnectionState.put(profile, newProfileState); + if (newProfileState == BluetoothProfile.STATE_DISCONNECTED) { + // check whether we are disconnected with this device completely + boolean isDisconnected = true; + for (LocalBluetoothProfile pf: mProfileConnectionState.keySet()) { + if (mProfileConnectionState.get(pf) != BluetoothProfile.STATE_DISCONNECTED) { + isDisconnected = false; + break; + } + } + // if disconnected, restore permission choice. + // So ACCESS_REJECTED will take effect until we are disconnected with this device. + if (isDisconnected) { + fetchPhonebookPermissionChoice(); + fetchMessagePermissionChoice(); + } + } + if (newProfileState == BluetoothProfile.STATE_CONNECTED) { if (!mProfiles.contains(profile)) { mRemovedProfiles.remove(profile); @@ -358,6 +375,8 @@ final class CachedBluetoothDevice implements Comparable<CachedBluetoothDevice> { for (LocalBluetoothProfile profile :getProfiles()) { mProfileConnectionState.put(profile, BluetoothProfile.STATE_DISCONNECTED); } + fetchPhonebookPermissionChoice(); + fetchMessagePermissionChoice(); } // TODO: do any of these need to run async on a background thread? @@ -649,6 +668,11 @@ final class CachedBluetoothDevice implements Comparable<CachedBluetoothDevice> { } void setPhonebookPermissionChoice(int permissionChoice) { + mPhonebookPermissionChoice = permissionChoice; + + // if user reject it, don't save it to editor. + if (permissionChoice == ACCESS_REJECTED) return; + SharedPreferences.Editor editor = mContext.getSharedPreferences(PHONEBOOK_PREFS_NAME, Context.MODE_PRIVATE).edit(); if (permissionChoice == ACCESS_UNKNOWN) { @@ -657,7 +681,6 @@ final class CachedBluetoothDevice implements Comparable<CachedBluetoothDevice> { editor.putInt(mDevice.getAddress(), permissionChoice); } editor.commit(); - mPhonebookPermissionChoice = permissionChoice; } private void fetchPhonebookPermissionChoice() { @@ -673,6 +696,11 @@ final class CachedBluetoothDevice implements Comparable<CachedBluetoothDevice> { } void setMessagePermissionChoice(int permissionChoice) { + mMessagePermissionChoice = permissionChoice; + + // if user reject it, don't save it to editor. + if (permissionChoice == ACCESS_REJECTED) return; + SharedPreferences.Editor editor = mContext.getSharedPreferences(MESSAGE_PREFS_NAME, Context.MODE_PRIVATE).edit(); if (permissionChoice == ACCESS_UNKNOWN) { @@ -681,7 +709,6 @@ final class CachedBluetoothDevice implements Comparable<CachedBluetoothDevice> { editor.putInt(mDevice.getAddress(), permissionChoice); } editor.commit(); - mMessagePermissionChoice = permissionChoice; } private void fetchMessagePermissionChoice() { |