Bluetooth MAP profile - sms and mms support initial check-in
bug:10116530 Change-Id: I3f50e66420e53bf21a1ecba06aed6b8261ff3064
This commit is contained in:
@@ -36,12 +36,12 @@
|
|||||||
android:gravity="center_horizontal"
|
android:gravity="center_horizontal"
|
||||||
android:textAppearance="?android:attr/textAppearanceMedium" />
|
android:textAppearance="?android:attr/textAppearanceMedium" />
|
||||||
|
|
||||||
<CheckBox android:id="@+id/bluetooth_pb_remember_choice"
|
<CheckBox android:id="@+id/bluetooth_remember_choice"
|
||||||
style="?android:attr/textAppearanceMedium"
|
style="?android:attr/textAppearanceMedium"
|
||||||
android:layout_width="match_parent"
|
android:layout_width="match_parent"
|
||||||
android:layout_height="wrap_content"
|
android:layout_height="wrap_content"
|
||||||
android:layout_marginTop="2dip"
|
android:layout_marginTop="2dip"
|
||||||
android:text="@string/bluetooth_pb_remember_choice" />
|
android:text="@string/bluetooth_remember_choice" />
|
||||||
|
|
||||||
</LinearLayout>
|
</LinearLayout>
|
||||||
|
|
@@ -355,8 +355,19 @@
|
|||||||
<string name="bluetooth_pb_acceptance_dialog_text">%1$s wants to access your contacts and call history. Give access to %2$s?</string>
|
<string name="bluetooth_pb_acceptance_dialog_text">%1$s wants to access your contacts and call history. Give access to %2$s?</string>
|
||||||
|
|
||||||
<!-- Bluetooth phone book permission Alert Activity checkbox text [CHAR LIMIT=none] -->
|
<!-- Bluetooth phone book permission Alert Activity checkbox text [CHAR LIMIT=none] -->
|
||||||
|
<string name="bluetooth_remember_choice">Don\'t ask again</string>
|
||||||
|
<!--FIXME SHOULD BE REMOVED AND ALL LANG VERSIONS FIXED TO ABOVE NAME -->
|
||||||
<string name="bluetooth_pb_remember_choice">Don\'t ask again</string>
|
<string name="bluetooth_pb_remember_choice">Don\'t ask again</string>
|
||||||
|
|
||||||
|
<!-- Activity label of BluetoothMessagePermissionActivity, also used as Strings in the permission dialog [CHAR LIMIT=none] -->
|
||||||
|
<string name="bluetooth_map_request">"Message request"</string>
|
||||||
|
|
||||||
|
<!-- Bluetooth message permission Alert Activity text [CHAR LIMIT=none] -->
|
||||||
|
<string name="bluetooth_map_acceptance_dialog_text">%1$s wants to access your messages. Give access to %2$s?</string>
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
<!-- Date & time settings screen title -->
|
<!-- Date & time settings screen title -->
|
||||||
<string name="date_and_time">Date & time settings</string>
|
<string name="date_and_time">Date & time settings</string>
|
||||||
<!-- The title of the activity to pick a time zone. -->
|
<!-- The title of the activity to pick a time zone. -->
|
||||||
|
@@ -58,7 +58,7 @@ public class BluetoothPermissionActivity extends AlertActivity implements
|
|||||||
|
|
||||||
private CheckBox mRememberChoice;
|
private CheckBox mRememberChoice;
|
||||||
private boolean mRememberChoiceValue = false;
|
private boolean mRememberChoiceValue = false;
|
||||||
|
private int mRequestType = 0;
|
||||||
private BroadcastReceiver mReceiver = new BroadcastReceiver() {
|
private BroadcastReceiver mReceiver = new BroadcastReceiver() {
|
||||||
@Override
|
@Override
|
||||||
public void onReceive(Context context, Intent intent) {
|
public void onReceive(Context context, Intent intent) {
|
||||||
@@ -91,15 +91,18 @@ public class BluetoothPermissionActivity extends AlertActivity implements
|
|||||||
mDevice = i.getParcelableExtra(BluetoothDevice.EXTRA_DEVICE);
|
mDevice = i.getParcelableExtra(BluetoothDevice.EXTRA_DEVICE);
|
||||||
mReturnPackage = i.getStringExtra(BluetoothDevice.EXTRA_PACKAGE_NAME);
|
mReturnPackage = i.getStringExtra(BluetoothDevice.EXTRA_PACKAGE_NAME);
|
||||||
mReturnClass = i.getStringExtra(BluetoothDevice.EXTRA_CLASS_NAME);
|
mReturnClass = i.getStringExtra(BluetoothDevice.EXTRA_CLASS_NAME);
|
||||||
int requestType = i.getIntExtra(BluetoothDevice.EXTRA_ACCESS_REQUEST_TYPE,
|
mRequestType = i.getIntExtra(BluetoothDevice.EXTRA_ACCESS_REQUEST_TYPE,
|
||||||
BluetoothDevice.REQUEST_TYPE_PHONEBOOK_ACCESS);
|
BluetoothDevice.REQUEST_TYPE_PHONEBOOK_ACCESS);
|
||||||
|
|
||||||
if (requestType == BluetoothDevice.REQUEST_TYPE_PROFILE_CONNECTION) {
|
if (mRequestType == BluetoothDevice.REQUEST_TYPE_PROFILE_CONNECTION) {
|
||||||
showConnectionDialog();
|
showDialog(getString(R.string.bluetooth_connection_permission_request), mRequestType);
|
||||||
} else if (requestType == BluetoothDevice.REQUEST_TYPE_PHONEBOOK_ACCESS) {
|
} else if (mRequestType == BluetoothDevice.REQUEST_TYPE_PHONEBOOK_ACCESS) {
|
||||||
showPhonebookDialog();
|
showDialog(getString(R.string.bluetooth_phonebook_request), mRequestType);
|
||||||
} else {
|
} else if (mRequestType == BluetoothDevice.REQUEST_TYPE_MESSAGE_ACCESS) {
|
||||||
Log.e(TAG, "Error: bad request type: " + requestType);
|
showDialog(getString(R.string.bluetooth_map_request), mRequestType);
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
Log.e(TAG, "Error: bad request type: " + mRequestType);
|
||||||
finish();
|
finish();
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
@@ -108,62 +111,57 @@ public class BluetoothPermissionActivity extends AlertActivity implements
|
|||||||
mReceiverRegistered = true;
|
mReceiverRegistered = true;
|
||||||
}
|
}
|
||||||
|
|
||||||
private void showConnectionDialog() {
|
|
||||||
|
private void showDialog(String title, int requestType)
|
||||||
|
{
|
||||||
final AlertController.AlertParams p = mAlertParams;
|
final AlertController.AlertParams p = mAlertParams;
|
||||||
p.mIconId = android.R.drawable.ic_dialog_info;
|
p.mIconId = android.R.drawable.ic_dialog_info;
|
||||||
p.mTitle = getString(R.string.bluetooth_connection_permission_request);
|
p.mTitle = title;
|
||||||
p.mView = createConnectionDialogView();
|
switch(requestType)
|
||||||
|
{
|
||||||
|
case BluetoothDevice.REQUEST_TYPE_PROFILE_CONNECTION:
|
||||||
|
p.mView = createConnectionDialogView();
|
||||||
|
break;
|
||||||
|
case BluetoothDevice.REQUEST_TYPE_PHONEBOOK_ACCESS:
|
||||||
|
p.mView = createPhonebookDialogView();
|
||||||
|
break;
|
||||||
|
case BluetoothDevice.REQUEST_TYPE_MESSAGE_ACCESS:
|
||||||
|
p.mView = createMapDialogView();
|
||||||
|
break;
|
||||||
|
}
|
||||||
p.mPositiveButtonText = getString(R.string.yes);
|
p.mPositiveButtonText = getString(R.string.yes);
|
||||||
p.mPositiveButtonListener = this;
|
p.mPositiveButtonListener = this;
|
||||||
p.mNegativeButtonText = getString(R.string.no);
|
p.mNegativeButtonText = getString(R.string.no);
|
||||||
p.mNegativeButtonListener = this;
|
p.mNegativeButtonListener = this;
|
||||||
mOkButton = mAlert.getButton(DialogInterface.BUTTON_POSITIVE);
|
mOkButton = mAlert.getButton(DialogInterface.BUTTON_POSITIVE);
|
||||||
setupAlert();
|
setupAlert();
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
private void showPhonebookDialog() {
|
private String createDisplayText(String message) {
|
||||||
final AlertController.AlertParams p = mAlertParams;
|
String mMessage1 = message;
|
||||||
p.mIconId = android.R.drawable.ic_dialog_info;
|
|
||||||
p.mTitle = getString(R.string.bluetooth_phonebook_request);
|
|
||||||
p.mView = createPhonebookDialogView();
|
|
||||||
p.mPositiveButtonText = getString(android.R.string.yes);
|
|
||||||
p.mPositiveButtonListener = this;
|
|
||||||
p.mNegativeButtonText = getString(android.R.string.no);
|
|
||||||
p.mNegativeButtonListener = this;
|
|
||||||
mOkButton = mAlert.getButton(DialogInterface.BUTTON_POSITIVE);
|
|
||||||
setupAlert();
|
|
||||||
}
|
|
||||||
|
|
||||||
private String createConnectionDisplayText() {
|
|
||||||
String mRemoteName = mDevice != null ? mDevice.getAliasName() : null;
|
|
||||||
|
|
||||||
if (mRemoteName == null) mRemoteName = getString(R.string.unknown);
|
|
||||||
String mMessage1 = getString(R.string.bluetooth_connection_dialog_text,
|
|
||||||
mRemoteName);
|
|
||||||
return mMessage1;
|
return mMessage1;
|
||||||
}
|
}
|
||||||
|
|
||||||
private String createPhonebookDisplayText() {
|
private String createRemoteName()
|
||||||
|
{
|
||||||
String mRemoteName = mDevice != null ? mDevice.getAliasName() : null;
|
String mRemoteName = mDevice != null ? mDevice.getAliasName() : null;
|
||||||
|
|
||||||
if (mRemoteName == null) mRemoteName = getString(R.string.unknown);
|
if (mRemoteName == null) mRemoteName = getString(R.string.unknown);
|
||||||
String mMessage1 = getString(R.string.bluetooth_pb_acceptance_dialog_text,
|
return mRemoteName;
|
||||||
mRemoteName, mRemoteName);
|
|
||||||
return mMessage1;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
private View createConnectionDialogView() {
|
private View createConnectionDialogView() {
|
||||||
|
String mRemoteName = createRemoteName();
|
||||||
mView = getLayoutInflater().inflate(R.layout.bluetooth_connection_access, null);
|
mView = getLayoutInflater().inflate(R.layout.bluetooth_connection_access, null);
|
||||||
messageView = (TextView)mView.findViewById(R.id.message);
|
messageView = (TextView)mView.findViewById(R.id.message);
|
||||||
messageView.setText(createConnectionDisplayText());
|
messageView.setText(createDisplayText(getString(R.string.bluetooth_connection_dialog_text,
|
||||||
|
mRemoteName)));
|
||||||
return mView;
|
return mView;
|
||||||
}
|
}
|
||||||
|
|
||||||
private View createPhonebookDialogView() {
|
private void createCheckbox(int viewId)
|
||||||
mView = getLayoutInflater().inflate(R.layout.bluetooth_pb_access, null);
|
{
|
||||||
messageView = (TextView)mView.findViewById(R.id.message);
|
mRememberChoice = (CheckBox)mView.findViewById(viewId);
|
||||||
messageView.setText(createPhonebookDisplayText());
|
|
||||||
mRememberChoice = (CheckBox)mView.findViewById(R.id.bluetooth_pb_remember_choice);
|
|
||||||
mRememberChoice.setChecked(false);
|
mRememberChoice.setChecked(false);
|
||||||
mRememberChoice.setOnCheckedChangeListener(new OnCheckedChangeListener() {
|
mRememberChoice.setOnCheckedChangeListener(new OnCheckedChangeListener() {
|
||||||
public void onCheckedChanged(CompoundButton buttonView, boolean isChecked) {
|
public void onCheckedChanged(CompoundButton buttonView, boolean isChecked) {
|
||||||
@@ -174,26 +172,42 @@ public class BluetoothPermissionActivity extends AlertActivity implements
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
}
|
||||||
|
private View createPhonebookDialogView() {
|
||||||
|
String mRemoteName = createRemoteName();
|
||||||
|
mView = getLayoutInflater().inflate(R.layout.bluetooth_access, null);
|
||||||
|
messageView = (TextView)mView.findViewById(R.id.message);
|
||||||
|
messageView.setText(createDisplayText(getString(R.string.bluetooth_pb_acceptance_dialog_text,
|
||||||
|
mRemoteName, mRemoteName)));
|
||||||
|
createCheckbox(R.id.bluetooth_remember_choice);
|
||||||
|
return mView;
|
||||||
|
}
|
||||||
|
private View createMapDialogView() {
|
||||||
|
String mRemoteName = createRemoteName();
|
||||||
|
mView = getLayoutInflater().inflate(R.layout.bluetooth_access, null);
|
||||||
|
messageView = (TextView)mView.findViewById(R.id.message);
|
||||||
|
messageView.setText(createDisplayText(getString(R.string.bluetooth_map_acceptance_dialog_text,
|
||||||
|
mRemoteName, mRemoteName)));
|
||||||
|
createCheckbox(R.id.bluetooth_remember_choice);
|
||||||
return mView;
|
return mView;
|
||||||
}
|
}
|
||||||
|
|
||||||
private void onPositive() {
|
private void onPositive() {
|
||||||
if (DEBUG) Log.d(TAG, "onPositive mRememberChoiceValue: " + mRememberChoiceValue);
|
if (DEBUG) Log.d(TAG, "onPositive mRememberChoiceValue: " + mRememberChoiceValue);
|
||||||
|
if (mRememberChoiceValue)
|
||||||
|
savePermissionChoice(mRequestType, CachedBluetoothDevice.ACCESS_ALLOWED);
|
||||||
|
|
||||||
if (mRememberChoiceValue) {
|
|
||||||
savePhonebookPermissionChoice(CachedBluetoothDevice.PHONEBOOK_ACCESS_ALLOWED);
|
|
||||||
}
|
|
||||||
sendIntentToReceiver(BluetoothDevice.ACTION_CONNECTION_ACCESS_REPLY, true,
|
sendIntentToReceiver(BluetoothDevice.ACTION_CONNECTION_ACCESS_REPLY, true,
|
||||||
BluetoothDevice.EXTRA_ALWAYS_ALLOWED, mRememberChoiceValue);
|
BluetoothDevice.EXTRA_ALWAYS_ALLOWED, mRememberChoiceValue);
|
||||||
finish();
|
finish();
|
||||||
}
|
}
|
||||||
|
|
||||||
private void onNegative() {
|
private void onNegative() {
|
||||||
if (DEBUG) Log.d(TAG, "onNegative mRememberChoiceValue: " + mRememberChoiceValue);
|
if (DEBUG) Log.d(TAG, "onNegative mRememberChoiceValue: " + mRememberChoiceValue);
|
||||||
|
|
||||||
if (mRememberChoiceValue) {
|
if (mRememberChoiceValue)
|
||||||
savePhonebookPermissionChoice(CachedBluetoothDevice.PHONEBOOK_ACCESS_REJECTED);
|
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
|
||||||
);
|
);
|
||||||
@@ -246,18 +260,23 @@ public class BluetoothPermissionActivity extends AlertActivity implements
|
|||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
private void savePhonebookPermissionChoice(int permissionChoice) {
|
private void savePermissionChoice(int permissionType, int permissionChoice) {
|
||||||
LocalBluetoothManager bluetoothManager = LocalBluetoothManager.getInstance(this);
|
LocalBluetoothManager bluetoothManager = LocalBluetoothManager.getInstance(this);
|
||||||
CachedBluetoothDeviceManager cachedDeviceManager =
|
CachedBluetoothDeviceManager cachedDeviceManager =
|
||||||
bluetoothManager.getCachedDeviceManager();
|
bluetoothManager.getCachedDeviceManager();
|
||||||
CachedBluetoothDevice cachedDevice = cachedDeviceManager.findDevice(mDevice);
|
CachedBluetoothDevice cachedDevice = cachedDeviceManager.findDevice(mDevice);
|
||||||
if (cachedDevice != null ) {
|
if (DEBUG) Log.d(TAG, "savePermissionChoice permissionType: " + permissionType);
|
||||||
cachedDevice.setPhonebookPermissionChoice(permissionChoice);
|
if (cachedDevice == null ) {
|
||||||
} else {
|
|
||||||
cachedDevice = cachedDeviceManager.addDevice(bluetoothManager.getBluetoothAdapter(),
|
cachedDevice = cachedDeviceManager.addDevice(bluetoothManager.getBluetoothAdapter(),
|
||||||
bluetoothManager.getProfileManager(),
|
bluetoothManager.getProfileManager(),
|
||||||
mDevice);
|
mDevice);
|
||||||
cachedDevice.setPhonebookPermissionChoice(permissionChoice);
|
|
||||||
}
|
}
|
||||||
|
if (permissionType == BluetoothDevice.REQUEST_TYPE_PHONEBOOK_ACCESS){
|
||||||
|
cachedDevice.setPhonebookPermissionChoice(permissionChoice);
|
||||||
|
}else if (permissionType == BluetoothDevice.REQUEST_TYPE_MESSAGE_ACCESS){
|
||||||
|
cachedDevice.setMessagePermissionChoice(permissionChoice);
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
@@ -128,8 +128,10 @@ public final class BluetoothPermissionRequest extends BroadcastReceiver {
|
|||||||
private boolean checkUserChoice() {
|
private boolean checkUserChoice() {
|
||||||
boolean processed = false;
|
boolean processed = false;
|
||||||
|
|
||||||
// we only remember PHONEBOOK permission
|
// ignore if it is something else than phonebook/message settings it wants us to remember
|
||||||
if (mRequestType != BluetoothDevice.REQUEST_TYPE_PHONEBOOK_ACCESS) {
|
if (mRequestType != BluetoothDevice.REQUEST_TYPE_PHONEBOOK_ACCESS
|
||||||
|
&& mRequestType != BluetoothDevice.REQUEST_TYPE_MESSAGE_ACCESS) {
|
||||||
|
if (DEBUG) Log.d(TAG, "Unknown RequestType: " + mRequestType);
|
||||||
return processed;
|
return processed;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -143,23 +145,45 @@ public final class BluetoothPermissionRequest extends BroadcastReceiver {
|
|||||||
bluetoothManager.getProfileManager(), mDevice);
|
bluetoothManager.getProfileManager(), mDevice);
|
||||||
}
|
}
|
||||||
|
|
||||||
int phonebookPermission = cachedDevice.getPhonebookPermissionChoice();
|
if(mRequestType == BluetoothDevice.REQUEST_TYPE_PHONEBOOK_ACCESS) {
|
||||||
|
|
||||||
if (phonebookPermission == CachedBluetoothDevice.PHONEBOOK_ACCESS_UNKNOWN) {
|
int phonebookPermission = cachedDevice.getPhonebookPermissionChoice();
|
||||||
return processed;
|
|
||||||
}
|
|
||||||
|
|
||||||
String intentName = BluetoothDevice.ACTION_CONNECTION_ACCESS_REPLY;
|
if (phonebookPermission == CachedBluetoothDevice.ACCESS_UNKNOWN) {
|
||||||
if (phonebookPermission == CachedBluetoothDevice.PHONEBOOK_ACCESS_ALLOWED) {
|
return processed;
|
||||||
sendIntentToReceiver(intentName, true, BluetoothDevice.EXTRA_ALWAYS_ALLOWED, true);
|
}
|
||||||
processed = true;
|
|
||||||
} else if (phonebookPermission == CachedBluetoothDevice.PHONEBOOK_ACCESS_REJECTED) {
|
String intentName = BluetoothDevice.ACTION_CONNECTION_ACCESS_REPLY;
|
||||||
sendIntentToReceiver(intentName, false,
|
if (phonebookPermission == CachedBluetoothDevice.ACCESS_ALLOWED) {
|
||||||
null, false // dummy value, no effect since previous param is null
|
sendIntentToReceiver(intentName, true, BluetoothDevice.EXTRA_ALWAYS_ALLOWED, true);
|
||||||
);
|
processed = true;
|
||||||
processed = true;
|
} else if (phonebookPermission == CachedBluetoothDevice.ACCESS_REJECTED) {
|
||||||
} else {
|
sendIntentToReceiver(intentName, false,
|
||||||
Log.e(TAG, "Bad phonebookPermission: " + phonebookPermission);
|
null, false ); // dummy value, no effect since previous param is null
|
||||||
|
processed = true;
|
||||||
|
} else {
|
||||||
|
Log.e(TAG, "Bad phonebookPermission: " + phonebookPermission);
|
||||||
|
}
|
||||||
|
|
||||||
|
} else if(mRequestType == BluetoothDevice.REQUEST_TYPE_MESSAGE_ACCESS) {
|
||||||
|
|
||||||
|
int messagePermission = cachedDevice.getMessagePermissionChoice();
|
||||||
|
|
||||||
|
if (messagePermission == CachedBluetoothDevice.ACCESS_UNKNOWN) {
|
||||||
|
return processed;
|
||||||
|
}
|
||||||
|
|
||||||
|
String intentName = BluetoothDevice.ACTION_CONNECTION_ACCESS_REPLY;
|
||||||
|
if (messagePermission == CachedBluetoothDevice.ACCESS_ALLOWED) {
|
||||||
|
sendIntentToReceiver(intentName, true, BluetoothDevice.EXTRA_ALWAYS_ALLOWED, true);
|
||||||
|
processed = true;
|
||||||
|
} else if (messagePermission == CachedBluetoothDevice.ACCESS_REJECTED) {
|
||||||
|
sendIntentToReceiver(intentName, false,
|
||||||
|
null, false); // dummy value, no effect since previous param is null
|
||||||
|
processed = true;
|
||||||
|
} else {
|
||||||
|
Log.e(TAG, "Bad messagePermission: " + messagePermission);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
return processed;
|
return processed;
|
||||||
}
|
}
|
||||||
|
@@ -66,17 +66,22 @@ final class CachedBluetoothDevice implements Comparable<CachedBluetoothDevice> {
|
|||||||
|
|
||||||
private int mPhonebookPermissionChoice;
|
private int mPhonebookPermissionChoice;
|
||||||
|
|
||||||
|
private int mMessagePermissionChoice;
|
||||||
|
|
||||||
|
|
||||||
private final Collection<Callback> mCallbacks = new ArrayList<Callback>();
|
private final Collection<Callback> mCallbacks = new ArrayList<Callback>();
|
||||||
|
|
||||||
// Following constants indicate the user's choices of Phone book access settings
|
// Following constants indicate the user's choices of Phone book/message access settings
|
||||||
// User hasn't made any choice or settings app has wiped out the memory
|
// User hasn't made any choice or settings app has wiped out the memory
|
||||||
final static int PHONEBOOK_ACCESS_UNKNOWN = 0;
|
final static int ACCESS_UNKNOWN = 0;
|
||||||
// User has accepted the connection and let Settings app remember the decision
|
// User has accepted the connection and let Settings app remember the decision
|
||||||
final static int PHONEBOOK_ACCESS_ALLOWED = 1;
|
final static int ACCESS_ALLOWED = 1;
|
||||||
// User has rejected the connection and let Settings app remember the decision
|
// User has rejected the connection and let Settings app remember the decision
|
||||||
final static int PHONEBOOK_ACCESS_REJECTED = 2;
|
final static int ACCESS_REJECTED = 2;
|
||||||
|
|
||||||
|
|
||||||
private final static String PHONEBOOK_PREFS_NAME = "bluetooth_phonebook_permission";
|
private final static String PHONEBOOK_PREFS_NAME = "bluetooth_phonebook_permission";
|
||||||
|
private final static String MESSAGE_PREFS_NAME = "bluetooth_message_permission";
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* When we connect to multiple profiles, we only want to display a single
|
* When we connect to multiple profiles, we only want to display a single
|
||||||
@@ -349,6 +354,7 @@ final class CachedBluetoothDevice implements Comparable<CachedBluetoothDevice> {
|
|||||||
fetchBtClass();
|
fetchBtClass();
|
||||||
updateProfiles();
|
updateProfiles();
|
||||||
fetchPhonebookPermissionChoice();
|
fetchPhonebookPermissionChoice();
|
||||||
|
fetchMessagePermissionChoice();
|
||||||
|
|
||||||
mVisible = false;
|
mVisible = false;
|
||||||
dispatchAttributesChanged();
|
dispatchAttributesChanged();
|
||||||
@@ -513,7 +519,8 @@ final class CachedBluetoothDevice implements Comparable<CachedBluetoothDevice> {
|
|||||||
if (bondState == BluetoothDevice.BOND_NONE) {
|
if (bondState == BluetoothDevice.BOND_NONE) {
|
||||||
mProfiles.clear();
|
mProfiles.clear();
|
||||||
mConnectAfterPairing = false; // cancel auto-connect
|
mConnectAfterPairing = false; // cancel auto-connect
|
||||||
setPhonebookPermissionChoice(PHONEBOOK_ACCESS_UNKNOWN);
|
setPhonebookPermissionChoice(ACCESS_UNKNOWN);
|
||||||
|
setMessagePermissionChoice(ACCESS_UNKNOWN);
|
||||||
}
|
}
|
||||||
|
|
||||||
refresh();
|
refresh();
|
||||||
@@ -632,7 +639,7 @@ final class CachedBluetoothDevice implements Comparable<CachedBluetoothDevice> {
|
|||||||
void setPhonebookPermissionChoice(int permissionChoice) {
|
void setPhonebookPermissionChoice(int permissionChoice) {
|
||||||
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 == PHONEBOOK_ACCESS_UNKNOWN) {
|
if (permissionChoice == ACCESS_UNKNOWN) {
|
||||||
editor.remove(mDevice.getAddress());
|
editor.remove(mDevice.getAddress());
|
||||||
} else {
|
} else {
|
||||||
editor.putInt(mDevice.getAddress(), permissionChoice);
|
editor.putInt(mDevice.getAddress(), permissionChoice);
|
||||||
@@ -645,7 +652,31 @@ final class CachedBluetoothDevice implements Comparable<CachedBluetoothDevice> {
|
|||||||
SharedPreferences preference = mContext.getSharedPreferences(PHONEBOOK_PREFS_NAME,
|
SharedPreferences preference = mContext.getSharedPreferences(PHONEBOOK_PREFS_NAME,
|
||||||
Context.MODE_PRIVATE);
|
Context.MODE_PRIVATE);
|
||||||
mPhonebookPermissionChoice = preference.getInt(mDevice.getAddress(),
|
mPhonebookPermissionChoice = preference.getInt(mDevice.getAddress(),
|
||||||
PHONEBOOK_ACCESS_UNKNOWN);
|
ACCESS_UNKNOWN);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
int getMessagePermissionChoice() {
|
||||||
|
return mMessagePermissionChoice;
|
||||||
|
}
|
||||||
|
|
||||||
|
void setMessagePermissionChoice(int permissionChoice) {
|
||||||
|
SharedPreferences.Editor editor =
|
||||||
|
mContext.getSharedPreferences(MESSAGE_PREFS_NAME, Context.MODE_PRIVATE).edit();
|
||||||
|
if (permissionChoice == ACCESS_UNKNOWN) {
|
||||||
|
editor.remove(mDevice.getAddress());
|
||||||
|
} else {
|
||||||
|
editor.putInt(mDevice.getAddress(), permissionChoice);
|
||||||
|
}
|
||||||
|
editor.commit();
|
||||||
|
mMessagePermissionChoice = permissionChoice;
|
||||||
|
}
|
||||||
|
|
||||||
|
private void fetchMessagePermissionChoice() {
|
||||||
|
SharedPreferences preference = mContext.getSharedPreferences(MESSAGE_PREFS_NAME,
|
||||||
|
Context.MODE_PRIVATE);
|
||||||
|
mMessagePermissionChoice = preference.getInt(mDevice.getAddress(),
|
||||||
|
ACCESS_UNKNOWN);
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
Reference in New Issue
Block a user