diff options
author | PauloftheWest <paulofthewest@google.com> | 2014-07-25 06:15:10 -0700 |
---|---|---|
committer | PauloftheWest <paulofthewest@google.com> | 2014-07-30 08:39:46 -0700 |
commit | 361d870e5415f8642cb106b4329d194673b4dd02 (patch) | |
tree | 111909e6035339d4cb71950561b1912e8704ed7a /src/com | |
parent | c8a1db191207e38b7ad0acdfd276651e4911e812 (diff) | |
download | packages_apps_Settings-361d870e5415f8642cb106b4329d194673b4dd02.zip packages_apps_Settings-361d870e5415f8642cb106b4329d194673b4dd02.tar.gz packages_apps_Settings-361d870e5415f8642cb106b4329d194673b4dd02.tar.bz2 |
Added ability for user to automatically accept/deny Bluetooth Phonebook Syncs
Bug: 16040292
Change-Id: Ieeaa014052f53787cf7057578e0b2ac048dc6eb1
Diffstat (limited to 'src/com')
3 files changed, 28 insertions, 7 deletions
diff --git a/src/com/android/settings/bluetooth/CachedBluetoothDevice.java b/src/com/android/settings/bluetooth/CachedBluetoothDevice.java index 1263797..3b64ade 100755 --- a/src/com/android/settings/bluetooth/CachedBluetoothDevice.java +++ b/src/com/android/settings/bluetooth/CachedBluetoothDevice.java @@ -76,11 +76,11 @@ final class CachedBluetoothDevice implements Comparable<CachedBluetoothDevice> { // 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 - final static int ACCESS_UNKNOWN = 0; + public final static int ACCESS_UNKNOWN = 0; // User has accepted the connection and let Settings app remember the decision - final static int ACCESS_ALLOWED = 1; + public final static int ACCESS_ALLOWED = 1; // User has rejected the connection and let Settings app remember the decision - final static int ACCESS_REJECTED = 2; + public final static int ACCESS_REJECTED = 2; // how many times did User reject the connection to make the rejected persist. final static int PERSIST_REJECTED_TIMES_LIMIT = 2; diff --git a/src/com/android/settings/bluetooth/DeviceProfilesSettings.java b/src/com/android/settings/bluetooth/DeviceProfilesSettings.java index b50d2b4..fb7668f 100755 --- a/src/com/android/settings/bluetooth/DeviceProfilesSettings.java +++ b/src/com/android/settings/bluetooth/DeviceProfilesSettings.java @@ -55,6 +55,7 @@ public final class DeviceProfilesSettings extends SettingsPreferenceFragment private static final String KEY_RENAME_DEVICE = "rename_device"; private static final String KEY_PROFILE_CONTAINER = "profile_container"; private static final String KEY_UNPAIR = "unpair"; + private static final String KEY_PBAP_SERVER = "PBAP Server"; public static final String EXTRA_DEVICE = "device"; private RenameEditTextPreference mRenameDeviceNamePref; @@ -181,6 +182,16 @@ public final class DeviceProfilesSettings extends SettingsPreferenceFragment Preference pref = createProfilePreference(profile); mProfileContainer.addPreference(pref); } + + final int pbapPermission = mCachedDevice.getPhonebookPermissionChoice(); + // Only provide PBAP cabability if the client device has requested PBAP. + if (pbapPermission != CachedBluetoothDevice.ACCESS_UNKNOWN) { + final PbapServerProfile psp = mManager.getProfileManager().getPbapProfile(); + CheckBoxPreference pbapPref = createProfilePreference(psp); + pbapPref.setChecked(pbapPermission == CachedBluetoothDevice.ACCESS_ALLOWED); + mProfileContainer.addPreference(pbapPref); + } + showOrHideProfileGroup(); } @@ -205,6 +216,7 @@ public final class DeviceProfilesSettings extends SettingsPreferenceFragment */ private CheckBoxPreference createProfilePreference(LocalBluetoothProfile profile) { CheckBoxPreference pref = new CheckBoxPreference(getActivity()); + pref.setLayoutResource(R.layout.preference_start_widget); pref.setKey(profile.toString()); pref.setTitle(profile.getNameResource(mCachedDevice.getDevice())); pref.setPersistent(false); @@ -265,6 +277,15 @@ public final class DeviceProfilesSettings extends SettingsPreferenceFragment private void onProfileClicked(LocalBluetoothProfile profile, CheckBoxPreference profilePref) { BluetoothDevice device = mCachedDevice.getDevice(); + if (profilePref.getKey().equals(KEY_PBAP_SERVER)) { + final int newPermission = mCachedDevice.getPhonebookPermissionChoice() + == CachedBluetoothDevice.ACCESS_ALLOWED ? CachedBluetoothDevice.ACCESS_REJECTED + : CachedBluetoothDevice.ACCESS_ALLOWED; + mCachedDevice.setPhonebookPermissionChoice(newPermission); + profilePref.setChecked(newPermission == CachedBluetoothDevice.ACCESS_ALLOWED); + return; + } + int status = profile.getConnectionStatus(device); boolean isConnected = status == BluetoothProfile.STATE_CONNECTED; @@ -351,7 +372,6 @@ public final class DeviceProfilesSettings extends SettingsPreferenceFragment */ profilePref.setEnabled(!mCachedDevice.isBusy()); profilePref.setChecked(profile.isPreferred(device)); - profilePref.setSummary(profile.getSummaryResourceForDevice(device)); } private LocalBluetoothProfile getProfileOf(Preference pref) { diff --git a/src/com/android/settings/bluetooth/PbapServerProfile.java b/src/com/android/settings/bluetooth/PbapServerProfile.java index 1f5ca32..87e51a5 100755 --- a/src/com/android/settings/bluetooth/PbapServerProfile.java +++ b/src/com/android/settings/bluetooth/PbapServerProfile.java @@ -118,16 +118,17 @@ final class PbapServerProfile implements LocalBluetoothProfile { } public int getNameResource(BluetoothDevice device) { - return 0; + return R.string.bluetooth_profile_pbap; } public int getSummaryResourceForDevice(BluetoothDevice device) { - return 0; + return R.string.bluetooth_profile_pbap_summary; } public int getDrawableResource(BluetoothClass btClass) { - return 0; + return R.drawable.ic_bt_cellphone; } + protected void finalize() { if (V) Log.d(TAG, "finalize()"); if (mService != null) { |