Added ability for user to automatically accept/deny Bluetooth Phonebook Syncs
Bug: 16040292 Change-Id: Ieeaa014052f53787cf7057578e0b2ac048dc6eb1
This commit is contained in:
65
res/layout/preference_start_widget.xml
Normal file
65
res/layout/preference_start_widget.xml
Normal file
@@ -0,0 +1,65 @@
|
|||||||
|
<?xml version="1.0" encoding="utf-8"?>
|
||||||
|
<!-- Copyright (C) 2014 The Android Open Source Project
|
||||||
|
|
||||||
|
Licensed under the Apache License, Version 2.0 (the "License");
|
||||||
|
you may not use this file except in compliance with the License.
|
||||||
|
You may obtain a copy of the License at
|
||||||
|
|
||||||
|
http://www.apache.org/licenses/LICENSE-2.0
|
||||||
|
|
||||||
|
Unless required by applicable law or agreed to in writing, software
|
||||||
|
distributed under the License is distributed on an "AS IS" BASIS,
|
||||||
|
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||||
|
See the License for the specific language governing permissions and
|
||||||
|
limitations under the License.
|
||||||
|
-->
|
||||||
|
|
||||||
|
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
|
||||||
|
android:layout_width="match_parent"
|
||||||
|
android:layout_height="wrap_content"
|
||||||
|
android:minHeight="?android:attr/listPreferredItemHeightSmall"
|
||||||
|
android:gravity="center_vertical"
|
||||||
|
android:paddingStart="?android:attr/listPreferredItemPaddingStart"
|
||||||
|
android:paddingEnd="?android:attr/listPreferredItemPaddingEnd"
|
||||||
|
android:background="?android:attr/selectableItemBackground">
|
||||||
|
|
||||||
|
<LinearLayout
|
||||||
|
android:id="@android:id/widget_frame"
|
||||||
|
android:layout_width="wrap_content"
|
||||||
|
android:layout_height="wrap_content"
|
||||||
|
android:minWidth="@dimen/checkbox_widget_min_width"
|
||||||
|
android:gravity="center"
|
||||||
|
android:orientation="horizontal" />
|
||||||
|
|
||||||
|
<RelativeLayout
|
||||||
|
android:layout_width="wrap_content"
|
||||||
|
android:layout_height="wrap_content"
|
||||||
|
android:layout_weight="1"
|
||||||
|
android:paddingTop="@dimen/checkbox_layout_padding"
|
||||||
|
android:paddingBottom="@dimen/checkbox_layout_padding">
|
||||||
|
|
||||||
|
<TextView
|
||||||
|
android:id="@+android:id/title"
|
||||||
|
android:layout_width="wrap_content"
|
||||||
|
android:layout_height="wrap_content"
|
||||||
|
android:singleLine="true"
|
||||||
|
android:textAppearance="@android:style/TextAppearance.Material.Subhead"
|
||||||
|
android:textColor="?android:attr/textColorPrimary"
|
||||||
|
android:ellipsize="marquee"
|
||||||
|
android:fadingEdge="horizontal" />
|
||||||
|
|
||||||
|
<TextView
|
||||||
|
android:id="@android:id/summary"
|
||||||
|
android:layout_width="wrap_content"
|
||||||
|
android:layout_height="wrap_content"
|
||||||
|
android:layout_below="@android:id/title"
|
||||||
|
android:layout_alignStart="@android:id/title"
|
||||||
|
android:visibility="gone"
|
||||||
|
android:textAlignment="viewStart"
|
||||||
|
android:textAppearance="@android:style/TextAppearance.Material.Body1"
|
||||||
|
android:textColor="?android:attr/textColorSecondary"
|
||||||
|
android:maxLines="10" />
|
||||||
|
|
||||||
|
</RelativeLayout>
|
||||||
|
|
||||||
|
</LinearLayout>
|
@@ -204,4 +204,8 @@
|
|||||||
<!-- Diameter of a round user icon -->
|
<!-- Diameter of a round user icon -->
|
||||||
<dimen name="user_icon_diameter">56dp</dimen>
|
<dimen name="user_icon_diameter">56dp</dimen>
|
||||||
|
|
||||||
|
<!-- CheckBoxPreference -->
|
||||||
|
<dimen name="checkbox_widget_min_width">58dip</dimen>
|
||||||
|
<dimen name="checkbox_layout_padding">16dip</dimen>
|
||||||
|
|
||||||
</resources>
|
</resources>
|
||||||
|
@@ -390,9 +390,6 @@
|
|||||||
<!-- Bluetooth message permission Alert Activity text [CHAR LIMIT=none] -->
|
<!-- 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>
|
<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</string>
|
<string name="date_and_time">Date & time</string>
|
||||||
<!-- The title of the activity to pick a time zone. -->
|
<!-- The title of the activity to pick a time zone. -->
|
||||||
@@ -1175,8 +1172,6 @@
|
|||||||
<string name="bluetooth_preference_paired_dialog_title">Paired device</string>
|
<string name="bluetooth_preference_paired_dialog_title">Paired device</string>
|
||||||
<!-- Bluetooth settings: Name label [CHAR LIMIT=40] -->
|
<!-- Bluetooth settings: Name label [CHAR LIMIT=40] -->
|
||||||
<string name="bluetooth_preference_paired_dialog_name_label">Name</string>
|
<string name="bluetooth_preference_paired_dialog_name_label">Name</string>
|
||||||
<!-- Bluetooth settings: Use for label [CHAR LIMIT=40] -->
|
|
||||||
<string name="bluetooth_preference_paired_dialog_use_label">Use for</string>
|
|
||||||
<!-- Bluetooth settings: Checkbox label for enable/disable internet connection. [CHAR LIMIT=40] -->
|
<!-- Bluetooth settings: Checkbox label for enable/disable internet connection. [CHAR LIMIT=40] -->
|
||||||
<string name="bluetooth_preference_paired_dialog_internet_option">Internet connection</string>
|
<string name="bluetooth_preference_paired_dialog_internet_option">Internet connection</string>
|
||||||
<!-- Bluetooth settings: Checkbox label for enable/disable keyboard connection. [CHAR LIMIT=40] -->
|
<!-- Bluetooth settings: Checkbox label for enable/disable keyboard connection. [CHAR LIMIT=40] -->
|
||||||
@@ -1230,9 +1225,13 @@
|
|||||||
<string name="bluetooth_profile_opp">File transfer</string>
|
<string name="bluetooth_profile_opp">File transfer</string>
|
||||||
<!-- Bluetooth settings. The user-visible string that is used whenever referring to the HID profile. -->
|
<!-- Bluetooth settings. The user-visible string that is used whenever referring to the HID profile. -->
|
||||||
<string name="bluetooth_profile_hid">Input device</string>
|
<string name="bluetooth_profile_hid">Input device</string>
|
||||||
<!-- Bluetooth settings. The user-visible string that is used whenever referring to the PAN profile (accessing Internet through remote device). [CHAR LIMIT=40]-->
|
<!-- Bluetooth settings. The user-visible string that is used whenever referring to the PAN profile (accessing Internet through remote device). [CHAR LIMIT=40] -->
|
||||||
<string name="bluetooth_profile_pan">Internet access</string>
|
<string name="bluetooth_profile_pan">Internet access</string>
|
||||||
<!-- Bluetooth settings. The user-visible string that is used whenever referring to the PAN profile (sharing this device's Internet connection). [CHAR LIMIT=40]-->
|
<!-- Bluetooth settings. The user-visible string that is used whenever referring to the PBAP profile. [CHAR LIMIT=40] -->
|
||||||
|
<string name="bluetooth_profile_pbap">Contact sharing</string>
|
||||||
|
<!-- Bluetooth settings. The user-visible summary string that is used whenever referring to the PBAP profile (sharing contacts). [CHAR LIMIT=60] -->
|
||||||
|
<string name="bluetooth_profile_pbap_summary">Use for contact sharing</string>
|
||||||
|
<!-- Bluetooth settings. The user-visible string that is used whenever referring to the PAN profile (sharing this device's Internet connection). [CHAR LIMIT=40] -->
|
||||||
<string name="bluetooth_profile_pan_nap">Internet connection sharing</string>
|
<string name="bluetooth_profile_pan_nap">Internet connection sharing</string>
|
||||||
<!-- Bluetooth settings. The user-visible string that is used whenever referring to the map profile. -->
|
<!-- Bluetooth settings. The user-visible string that is used whenever referring to the map profile. -->
|
||||||
<string name="bluetooth_profile_map">Message Access</string>
|
<string name="bluetooth_profile_map">Message Access</string>
|
||||||
@@ -1257,7 +1256,7 @@
|
|||||||
<!-- Bluetooth settings. Connection options screen. The summary of the online mode checkbox. This describes what the setting does in the context of the screen. -->
|
<!-- Bluetooth settings. Connection options screen. The summary of the online mode checkbox. This describes what the setting does in the context of the screen. -->
|
||||||
<string name="bluetooth_device_advanced_online_mode_summary">Connect to Bluetooth device</string>
|
<string name="bluetooth_device_advanced_online_mode_summary">Connect to Bluetooth device</string>
|
||||||
<!-- Bluetooth settings. Connection options screen. The title of the header that is above all of the profiles. -->
|
<!-- Bluetooth settings. Connection options screen. The title of the header that is above all of the profiles. -->
|
||||||
<string name="bluetooth_device_advanced_profile_header_title">Profiles</string>
|
<string name="bluetooth_device_advanced_profile_header_title">Use for</string>
|
||||||
<!-- Bluetooth settings. Connection options screen. Title for option to rename the device. [CHAR LIMIT=30] -->
|
<!-- Bluetooth settings. Connection options screen. Title for option to rename the device. [CHAR LIMIT=30] -->
|
||||||
<string name="bluetooth_device_advanced_rename_device">Rename</string>
|
<string name="bluetooth_device_advanced_rename_device">Rename</string>
|
||||||
<!-- Bluetooth settings. Connection options screen. Title for checkbox to enable incoming file transfers [CHAR LIMIT=30] -->
|
<!-- Bluetooth settings. Connection options screen. Title for checkbox to enable incoming file transfers [CHAR LIMIT=30] -->
|
||||||
|
@@ -76,11 +76,11 @@ final class CachedBluetoothDevice implements Comparable<CachedBluetoothDevice> {
|
|||||||
|
|
||||||
// Following constants indicate the user's choices of Phone book/message 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 ACCESS_UNKNOWN = 0;
|
public 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 ACCESS_ALLOWED = 1;
|
public 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 ACCESS_REJECTED = 2;
|
public final static int ACCESS_REJECTED = 2;
|
||||||
|
|
||||||
// how many times did User reject the connection to make the rejected persist.
|
// how many times did User reject the connection to make the rejected persist.
|
||||||
final static int PERSIST_REJECTED_TIMES_LIMIT = 2;
|
final static int PERSIST_REJECTED_TIMES_LIMIT = 2;
|
||||||
|
@@ -55,6 +55,7 @@ public final class DeviceProfilesSettings extends SettingsPreferenceFragment
|
|||||||
private static final String KEY_RENAME_DEVICE = "rename_device";
|
private static final String KEY_RENAME_DEVICE = "rename_device";
|
||||||
private static final String KEY_PROFILE_CONTAINER = "profile_container";
|
private static final String KEY_PROFILE_CONTAINER = "profile_container";
|
||||||
private static final String KEY_UNPAIR = "unpair";
|
private static final String KEY_UNPAIR = "unpair";
|
||||||
|
private static final String KEY_PBAP_SERVER = "PBAP Server";
|
||||||
|
|
||||||
public static final String EXTRA_DEVICE = "device";
|
public static final String EXTRA_DEVICE = "device";
|
||||||
private RenameEditTextPreference mRenameDeviceNamePref;
|
private RenameEditTextPreference mRenameDeviceNamePref;
|
||||||
@@ -181,6 +182,16 @@ public final class DeviceProfilesSettings extends SettingsPreferenceFragment
|
|||||||
Preference pref = createProfilePreference(profile);
|
Preference pref = createProfilePreference(profile);
|
||||||
mProfileContainer.addPreference(pref);
|
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();
|
showOrHideProfileGroup();
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -205,6 +216,7 @@ public final class DeviceProfilesSettings extends SettingsPreferenceFragment
|
|||||||
*/
|
*/
|
||||||
private CheckBoxPreference createProfilePreference(LocalBluetoothProfile profile) {
|
private CheckBoxPreference createProfilePreference(LocalBluetoothProfile profile) {
|
||||||
CheckBoxPreference pref = new CheckBoxPreference(getActivity());
|
CheckBoxPreference pref = new CheckBoxPreference(getActivity());
|
||||||
|
pref.setLayoutResource(R.layout.preference_start_widget);
|
||||||
pref.setKey(profile.toString());
|
pref.setKey(profile.toString());
|
||||||
pref.setTitle(profile.getNameResource(mCachedDevice.getDevice()));
|
pref.setTitle(profile.getNameResource(mCachedDevice.getDevice()));
|
||||||
pref.setPersistent(false);
|
pref.setPersistent(false);
|
||||||
@@ -265,6 +277,15 @@ public final class DeviceProfilesSettings extends SettingsPreferenceFragment
|
|||||||
private void onProfileClicked(LocalBluetoothProfile profile, CheckBoxPreference profilePref) {
|
private void onProfileClicked(LocalBluetoothProfile profile, CheckBoxPreference profilePref) {
|
||||||
BluetoothDevice device = mCachedDevice.getDevice();
|
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);
|
int status = profile.getConnectionStatus(device);
|
||||||
boolean isConnected =
|
boolean isConnected =
|
||||||
status == BluetoothProfile.STATE_CONNECTED;
|
status == BluetoothProfile.STATE_CONNECTED;
|
||||||
@@ -351,7 +372,6 @@ public final class DeviceProfilesSettings extends SettingsPreferenceFragment
|
|||||||
*/
|
*/
|
||||||
profilePref.setEnabled(!mCachedDevice.isBusy());
|
profilePref.setEnabled(!mCachedDevice.isBusy());
|
||||||
profilePref.setChecked(profile.isPreferred(device));
|
profilePref.setChecked(profile.isPreferred(device));
|
||||||
profilePref.setSummary(profile.getSummaryResourceForDevice(device));
|
|
||||||
}
|
}
|
||||||
|
|
||||||
private LocalBluetoothProfile getProfileOf(Preference pref) {
|
private LocalBluetoothProfile getProfileOf(Preference pref) {
|
||||||
|
@@ -118,16 +118,17 @@ final class PbapServerProfile implements LocalBluetoothProfile {
|
|||||||
}
|
}
|
||||||
|
|
||||||
public int getNameResource(BluetoothDevice device) {
|
public int getNameResource(BluetoothDevice device) {
|
||||||
return 0;
|
return R.string.bluetooth_profile_pbap;
|
||||||
}
|
}
|
||||||
|
|
||||||
public int getSummaryResourceForDevice(BluetoothDevice device) {
|
public int getSummaryResourceForDevice(BluetoothDevice device) {
|
||||||
return 0;
|
return R.string.bluetooth_profile_pbap_summary;
|
||||||
}
|
}
|
||||||
|
|
||||||
public int getDrawableResource(BluetoothClass btClass) {
|
public int getDrawableResource(BluetoothClass btClass) {
|
||||||
return 0;
|
return R.drawable.ic_bt_cellphone;
|
||||||
}
|
}
|
||||||
|
|
||||||
protected void finalize() {
|
protected void finalize() {
|
||||||
if (V) Log.d(TAG, "finalize()");
|
if (V) Log.d(TAG, "finalize()");
|
||||||
if (mService != null) {
|
if (mService != null) {
|
||||||
|
Reference in New Issue
Block a user