am cf71c2d3
: am 83936d96
: Merge "BT keeps on asking me if I want to allow car to do stuff" into klp-dev
* commit 'cf71c2d3e31375fa68fd65f1ec39fcce62a4b4c3': BT keeps on asking me if I want to allow car to do stuff
This commit is contained in:
@@ -197,7 +197,7 @@ public class BluetoothPermissionActivity extends AlertActivity implements
|
|||||||
|
|
||||||
private void onNegative() {
|
private void onNegative() {
|
||||||
if (DEBUG) Log.d(TAG, "onNegative");
|
if (DEBUG) Log.d(TAG, "onNegative");
|
||||||
savePermissionChoice(mRequestType, CachedBluetoothDevice.ACCESS_UNKNOWN);
|
savePermissionChoice(mRequestType, CachedBluetoothDevice.ACCESS_REJECTED);
|
||||||
sendIntentToReceiver(BluetoothDevice.ACTION_CONNECTION_ACCESS_REPLY, false,
|
sendIntentToReceiver(BluetoothDevice.ACTION_CONNECTION_ACCESS_REPLY, false,
|
||||||
null, false // dummy value, no effect since last param is null
|
null, false // dummy value, no effect since last param is null
|
||||||
);
|
);
|
||||||
|
@@ -130,6 +130,23 @@ final class CachedBluetoothDevice implements Comparable<CachedBluetoothDevice> {
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
mProfileConnectionState.put(profile, newProfileState);
|
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 (newProfileState == BluetoothProfile.STATE_CONNECTED) {
|
||||||
if (!mProfiles.contains(profile)) {
|
if (!mProfiles.contains(profile)) {
|
||||||
mRemovedProfiles.remove(profile);
|
mRemovedProfiles.remove(profile);
|
||||||
@@ -358,6 +375,8 @@ final class CachedBluetoothDevice implements Comparable<CachedBluetoothDevice> {
|
|||||||
for (LocalBluetoothProfile profile :getProfiles()) {
|
for (LocalBluetoothProfile profile :getProfiles()) {
|
||||||
mProfileConnectionState.put(profile, BluetoothProfile.STATE_DISCONNECTED);
|
mProfileConnectionState.put(profile, BluetoothProfile.STATE_DISCONNECTED);
|
||||||
}
|
}
|
||||||
|
fetchPhonebookPermissionChoice();
|
||||||
|
fetchMessagePermissionChoice();
|
||||||
}
|
}
|
||||||
|
|
||||||
// TODO: do any of these need to run async on a background thread?
|
// 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) {
|
void setPhonebookPermissionChoice(int permissionChoice) {
|
||||||
|
mPhonebookPermissionChoice = permissionChoice;
|
||||||
|
|
||||||
|
// if user reject it, don't save it to editor.
|
||||||
|
if (permissionChoice == ACCESS_REJECTED) return;
|
||||||
|
|
||||||
SharedPreferences.Editor editor =
|
SharedPreferences.Editor editor =
|
||||||
mContext.getSharedPreferences(PHONEBOOK_PREFS_NAME, Context.MODE_PRIVATE).edit();
|
mContext.getSharedPreferences(PHONEBOOK_PREFS_NAME, Context.MODE_PRIVATE).edit();
|
||||||
if (permissionChoice == ACCESS_UNKNOWN) {
|
if (permissionChoice == ACCESS_UNKNOWN) {
|
||||||
@@ -657,7 +681,6 @@ final class CachedBluetoothDevice implements Comparable<CachedBluetoothDevice> {
|
|||||||
editor.putInt(mDevice.getAddress(), permissionChoice);
|
editor.putInt(mDevice.getAddress(), permissionChoice);
|
||||||
}
|
}
|
||||||
editor.commit();
|
editor.commit();
|
||||||
mPhonebookPermissionChoice = permissionChoice;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
private void fetchPhonebookPermissionChoice() {
|
private void fetchPhonebookPermissionChoice() {
|
||||||
@@ -673,6 +696,11 @@ final class CachedBluetoothDevice implements Comparable<CachedBluetoothDevice> {
|
|||||||
}
|
}
|
||||||
|
|
||||||
void setMessagePermissionChoice(int permissionChoice) {
|
void setMessagePermissionChoice(int permissionChoice) {
|
||||||
|
mMessagePermissionChoice = permissionChoice;
|
||||||
|
|
||||||
|
// if user reject it, don't save it to editor.
|
||||||
|
if (permissionChoice == ACCESS_REJECTED) return;
|
||||||
|
|
||||||
SharedPreferences.Editor editor =
|
SharedPreferences.Editor editor =
|
||||||
mContext.getSharedPreferences(MESSAGE_PREFS_NAME, Context.MODE_PRIVATE).edit();
|
mContext.getSharedPreferences(MESSAGE_PREFS_NAME, Context.MODE_PRIVATE).edit();
|
||||||
if (permissionChoice == ACCESS_UNKNOWN) {
|
if (permissionChoice == ACCESS_UNKNOWN) {
|
||||||
@@ -681,7 +709,6 @@ final class CachedBluetoothDevice implements Comparable<CachedBluetoothDevice> {
|
|||||||
editor.putInt(mDevice.getAddress(), permissionChoice);
|
editor.putInt(mDevice.getAddress(), permissionChoice);
|
||||||
}
|
}
|
||||||
editor.commit();
|
editor.commit();
|
||||||
mMessagePermissionChoice = permissionChoice;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
private void fetchMessagePermissionChoice() {
|
private void fetchMessagePermissionChoice() {
|
||||||
|
Reference in New Issue
Block a user