summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--res/values/strings.xml20
-rw-r--r--src/com/android/settings/DockSettings.java1
-rw-r--r--src/com/android/settings/bluetooth/BluetoothDevicePreference.java7
-rw-r--r--src/com/android/settings/bluetooth/BluetoothEnabler.java1
-rw-r--r--src/com/android/settings/bluetooth/BluetoothEventRedirector.java32
-rw-r--r--src/com/android/settings/bluetooth/BluetoothProfilePreference.java14
-rw-r--r--src/com/android/settings/bluetooth/BluetoothSettings.java13
-rw-r--r--src/com/android/settings/bluetooth/CachedBluetoothDevice.java33
-rw-r--r--src/com/android/settings/bluetooth/CachedBluetoothDeviceManager.java10
-rw-r--r--src/com/android/settings/bluetooth/DeviceProfilesSettings.java21
-rw-r--r--src/com/android/settings/bluetooth/DockEventReceiver.java3
-rw-r--r--src/com/android/settings/bluetooth/DockService.java1
-rw-r--r--src/com/android/settings/bluetooth/LocalBluetoothManager.java12
-rw-r--r--src/com/android/settings/bluetooth/LocalBluetoothProfileManager.java54
-rw-r--r--src/com/android/settings/bluetooth/RequestPermissionActivity.java2
-rw-r--r--src/com/android/settings/bluetooth/SettingsBtStatus.java2
16 files changed, 100 insertions, 126 deletions
diff --git a/res/values/strings.xml b/res/values/strings.xml
index e550345..f1745ac 100644
--- a/res/values/strings.xml
+++ b/res/values/strings.xml
@@ -254,6 +254,9 @@
<!-- Strings for msg to display to user while bluetooth is turning on -->
<string name="bluetooth_turning_on">"Turning on Bluetooth\u2026"</string>
+ <!-- Strings for device profile auto connect setting -->
+ <string name="bluetooth_auto_connect">Auto connect</string>
+
<!-- Date & time settings screen title -->
<string name="date_and_time">Date &amp; time settings</string>
<!-- Date/time settings. Summary of the checkbox for choosing between 12 hour time or 24 hour time. Sample of 12-hour time -->
@@ -809,19 +812,6 @@
<!-- Bluetooth settings. The user-visible string that is used whenever referring to the PAN profile. [CHAR LIMIT=25]-->
<string name="bluetooth_profile_pan">Tethering</string>
- <!-- Bluetooth settings. The summary string when a device is connected to the A2DP profile. -->
- <string name="bluetooth_summary_connected_to_a2dp">Connected to media audio</string>
- <!-- Bluetooth settings. The summary string when a device is connected to the headset profile. -->
- <string name="bluetooth_summary_connected_to_headset" product="tablet">Connected to tablet audio</string>
- <!-- Bluetooth settings. The summary string when a device is connected to the headset profile. -->
- <string name="bluetooth_summary_connected_to_headset" product="default">Connected to phone audio</string>
- <!-- Bluetooth settings. The summary string when a device is connected to the A2DP and headset profiles. -->
- <string name="bluetooth_summary_connected_to_a2dp_headset">Connected to phone and media audio</string>
- <!-- Bluetooth settings. The summary string when a device is connected to the HID profile. -->
- <string name="bluetooth_summary_connected_to_hid">Connected to input device</string>
- <!-- Bluetooth settings. The summary string when a device is connected to the PAN profile. [CHAR LIMIT=35]-->
- <string name="bluetooth_summary_connected_to_pan">Tethered</string>
-
<!-- Bluetooth settings. Message for disconnecting from the A2DP profile. -->
<string name="bluetooth_disconnect_a2dp_profile"><xliff:g id="device_name">%1$s</xliff:g> will be disconnected from media audio.</string>
<!-- Bluetooth settings. Message for disconnecting from the headset profile. -->
@@ -868,6 +858,10 @@
for the HID checkbox preference that describes how checking it
will set the HID profile as preferred. -->
<string name="bluetooth_hid_profile_summary_use_for">Use for input</string>
+ <!-- Bluetooth settings. Connection options screen. The summary
+ for the PAN checkbox preference that describes how checking it
+ will set the PAN profile as preferred. -->
+ <string name="bluetooth_pan_profile_summary_use_for">Use for Internet access</string>
<!-- Bluetooth settings. Dock Setting Title -->
<string name="bluetooth_dock_settings">Dock Settings</string>
diff --git a/src/com/android/settings/DockSettings.java b/src/com/android/settings/DockSettings.java
index b368640..3b3402f 100644
--- a/src/com/android/settings/DockSettings.java
+++ b/src/com/android/settings/DockSettings.java
@@ -53,7 +53,6 @@ public class DockSettings extends SettingsPreferenceFragment {
@Override
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
- ContentResolver resolver = getContentResolver();
addPreferencesFromResource(R.xml.dock_settings);
initDockSettings();
diff --git a/src/com/android/settings/bluetooth/BluetoothDevicePreference.java b/src/com/android/settings/bluetooth/BluetoothDevicePreference.java
index dfaf60d..fc40bc1 100644
--- a/src/com/android/settings/bluetooth/BluetoothDevicePreference.java
+++ b/src/com/android/settings/bluetooth/BluetoothDevicePreference.java
@@ -42,8 +42,7 @@ public class BluetoothDevicePreference extends Preference implements
private static int sDimAlpha = Integer.MIN_VALUE;
- private CachedBluetoothDevice mCachedDevice;
- private int mAccessibleProfile;
+ private final CachedBluetoothDevice mCachedDevice;
private ImageView mDeviceSettings;
@@ -55,8 +54,7 @@ public class BluetoothDevicePreference extends Preference implements
*/
private boolean mIsBusy;
- public BluetoothDevicePreference(Context context, CachedBluetoothDevice cachedDevice,
- int accessibleProfile) {
+ public BluetoothDevicePreference(Context context, CachedBluetoothDevice cachedDevice) {
super(context);
if (sDimAlpha == Integer.MIN_VALUE) {
@@ -66,7 +64,6 @@ public class BluetoothDevicePreference extends Preference implements
}
mCachedDevice = cachedDevice;
- mAccessibleProfile = accessibleProfile;
setWidgetLayoutResource(R.layout.preference_bluetooth);
diff --git a/src/com/android/settings/bluetooth/BluetoothEnabler.java b/src/com/android/settings/bluetooth/BluetoothEnabler.java
index eb8382e..a7b9d71 100644
--- a/src/com/android/settings/bluetooth/BluetoothEnabler.java
+++ b/src/com/android/settings/bluetooth/BluetoothEnabler.java
@@ -27,7 +27,6 @@ import android.content.IntentFilter;
import android.preference.Preference;
import android.preference.CheckBoxPreference;
import android.provider.Settings;
-import android.text.TextUtils;
import android.widget.Toast;
/**
diff --git a/src/com/android/settings/bluetooth/BluetoothEventRedirector.java b/src/com/android/settings/bluetooth/BluetoothEventRedirector.java
index 57e359d..757e1a2 100644
--- a/src/com/android/settings/bluetooth/BluetoothEventRedirector.java
+++ b/src/com/android/settings/bluetooth/BluetoothEventRedirector.java
@@ -44,7 +44,7 @@ import java.util.concurrent.TimeUnit;
* API and dispatches the event on the UI thread to the right class in the
* Settings.
*/
-public class BluetoothEventRedirector {
+class BluetoothEventRedirector {
private static final String TAG = "BluetoothEventRedirector";
/* package */ final LocalBluetoothManager mManager;
@@ -142,20 +142,20 @@ public class BluetoothEventRedirector {
Profile.HID, newState);
} else if (action.equals(BluetoothPan.ACTION_PAN_STATE_CHANGED)) {
- // TODO: uncomment and execute for reverse tethering only
-/*
- final int newState = intent.getIntExtra(
- BluetoothPan.EXTRA_PAN_STATE, 0);
- final int oldState = intent.getIntExtra(
- BluetoothPan.EXTRA_PREVIOUS_PAN_STATE, 0);
- if (newState == BluetoothPan.STATE_DISCONNECTED &&
- oldState == BluetoothPan.STATE_CONNECTING) {
- Log.i(TAG, "Failed to connect BT PAN");
+ final int role = intent.getIntExtra(
+ BluetoothPan.EXTRA_LOCAL_ROLE, 0);
+ if (role == BluetoothPan.LOCAL_PANU_ROLE) {
+ final int newState = intent.getIntExtra(
+ BluetoothPan.EXTRA_PAN_STATE, 0);
+ final int oldState = intent.getIntExtra(
+ BluetoothPan.EXTRA_PREVIOUS_PAN_STATE, 0);
+ if (newState == BluetoothPan.STATE_DISCONNECTED &&
+ oldState == BluetoothPan.STATE_CONNECTING) {
+ Log.i(TAG, "Failed to connect BT PAN");
+ }
+ mManager.getCachedDeviceManager().onProfileStateChanged(device,
+ Profile.PAN, newState);
}
- mManager.getCachedDeviceManager().onProfileStateChanged(device,
- Profile.PAN, newState);
-*/
-
} else if (action.equals(BluetoothDevice.ACTION_CLASS_CHANGED)) {
mManager.getCachedDeviceManager().onBtClassChanged(device);
@@ -164,7 +164,7 @@ public class BluetoothEventRedirector {
} else if (action.equals(BluetoothDevice.ACTION_PAIRING_CANCEL)) {
int errorMsg = R.string.bluetooth_pairing_error_message;
- mManager.showError(device, R.string.bluetooth_error_title, errorMsg);
+ mManager.showError(device, errorMsg);
} else if (action.equals(Intent.ACTION_DOCK_EVENT)) {
// Remove if unpair device upon undocking
@@ -183,7 +183,7 @@ public class BluetoothEventRedirector {
mManager = localBluetoothManager;
}
- public void start() {
+ public void registerReceiver() {
IntentFilter filter = new IntentFilter();
// Bluetooth on/off broadcasts
diff --git a/src/com/android/settings/bluetooth/BluetoothProfilePreference.java b/src/com/android/settings/bluetooth/BluetoothProfilePreference.java
index bd28995..6be1480 100644
--- a/src/com/android/settings/bluetooth/BluetoothProfilePreference.java
+++ b/src/com/android/settings/bluetooth/BluetoothProfilePreference.java
@@ -22,9 +22,7 @@ import com.android.settings.R;
import android.content.Context;
import android.graphics.drawable.Drawable;
import android.preference.Preference;
-import android.view.LayoutInflater;
import android.view.View;
-import android.view.ViewGroup;
import android.view.View.OnClickListener;
import android.widget.ImageView;
@@ -39,7 +37,7 @@ public class BluetoothProfilePreference extends Preference implements OnClickLis
private Drawable mProfileDrawable;
private boolean mExpanded;
private ImageView mProfileExpandView;
- private Profile mProfile;
+ private final Profile mProfile;
private OnClickListener mOnExpandClickListener;
@@ -77,11 +75,15 @@ public class BluetoothProfilePreference extends Preference implements OnClickLis
btProfile.setImageDrawable(mProfileDrawable);
mProfileExpandView = (ImageView) view.findViewById(R.id.profileExpand);
- mProfileExpandView.setOnClickListener(this);
- mProfileExpandView.setTag(mProfile);
+ if (mProfile == Profile.PAN) {
+ mProfileExpandView.setVisibility(View.GONE);
+ } else {
+ mProfileExpandView.setOnClickListener(this);
+ mProfileExpandView.setTag(mProfile);
- mProfileExpandView.setImageResource(mExpanded ? R.drawable.ic_preferences_expanded
+ mProfileExpandView.setImageResource(mExpanded ? R.drawable.ic_preferences_expanded
: R.drawable.ic_preferences_collapsed);
+ }
}
public void onClick(View v) {
diff --git a/src/com/android/settings/bluetooth/BluetoothSettings.java b/src/com/android/settings/bluetooth/BluetoothSettings.java
index 89efd72..aa5decb 100644
--- a/src/com/android/settings/bluetooth/BluetoothSettings.java
+++ b/src/com/android/settings/bluetooth/BluetoothSettings.java
@@ -16,23 +16,19 @@
package com.android.settings.bluetooth;
-import com.android.settings.bluetooth.LocalBluetoothProfileManager.Profile;
import com.android.settings.ProgressCategory;
import com.android.settings.R;
import com.android.settings.SettingsPreferenceFragment;
import com.android.settings.UserLeaveHintListener;
import android.app.Activity;
-import android.app.AlertDialog;
import android.bluetooth.BluetoothAdapter;
import android.bluetooth.BluetoothClass;
import android.bluetooth.BluetoothDevice;
import android.bluetooth.BluetoothDevicePicker;
-import android.bluetooth.BluetoothPan;
import android.bluetooth.BluetoothUuid;
import android.content.BroadcastReceiver;
import android.content.Context;
-import android.content.DialogInterface;
import android.content.Intent;
import android.content.IntentFilter;
import android.os.Bundle;
@@ -62,7 +58,6 @@ public class BluetoothSettings extends SettingsPreferenceFragment
private static final String KEY_BT_DEVICE_LIST = "bt_device_list";
private static final String KEY_BT_NAME = "bt_name";
private static final String KEY_BT_SCAN = "bt_scan";
- private static final String KEY_BT_FIND_NEARBY = "bt_find_nearby";
private static final int SCREEN_TYPE_SETTINGS = 0;
private static final int SCREEN_TYPE_DEVICEPICKER = 1;
@@ -119,11 +114,6 @@ public class BluetoothSettings extends SettingsPreferenceFragment
};
@Override
- public void onCreate(Bundle savedInstanceState) {
- super.onCreate(savedInstanceState);
- }
-
- @Override
public void onActivityCreated(Bundle savedInstanceState) {
// We delay calling super.onActivityCreated(). See WifiSettings.java for more info.
@@ -376,8 +366,7 @@ public class BluetoothSettings extends SettingsPreferenceFragment
private void createDevicePreference(CachedBluetoothDevice cachedDevice) {
BluetoothDevicePreference preference = new BluetoothDevicePreference(
- getActivity(), cachedDevice,
- CachedBluetoothDevice.OTHER_PROFILES);
+ getActivity(), cachedDevice);
if (mScreenType == SCREEN_TYPE_SETTINGS) {
preference.setOnSettingsClickListener(this);
diff --git a/src/com/android/settings/bluetooth/CachedBluetoothDevice.java b/src/com/android/settings/bluetooth/CachedBluetoothDevice.java
index df455b3..c31f49d 100644
--- a/src/com/android/settings/bluetooth/CachedBluetoothDevice.java
+++ b/src/com/android/settings/bluetooth/CachedBluetoothDevice.java
@@ -25,7 +25,6 @@ import android.app.AlertDialog;
import android.bluetooth.BluetoothAdapter;
import android.bluetooth.BluetoothClass;
import android.bluetooth.BluetoothDevice;
-import android.bluetooth.BluetoothUuid;
import android.content.Context;
import android.content.DialogInterface;
import android.content.res.Resources;
@@ -36,8 +35,6 @@ import android.preference.Preference;
import android.preference.PreferenceActivity;
import android.text.TextUtils;
import android.util.Log;
-import android.view.Menu;
-import android.view.MenuItem;
import java.util.ArrayList;
import java.util.HashMap;
@@ -50,15 +47,12 @@ import java.util.Map;
* functionality that can be performed on the device (connect, pair, disconnect,
* etc.).
*/
-public class CachedBluetoothDevice implements Comparable<CachedBluetoothDevice> {
+class CachedBluetoothDevice implements Comparable<CachedBluetoothDevice> {
private static final String TAG = "CachedBluetoothDevice";
private static final boolean D = LocalBluetoothManager.D;
private static final boolean V = LocalBluetoothManager.V;
private static final boolean DEBUG = false;
- public static final int PAN_PROFILE = 1;
- public static final int OTHER_PROFILES = 2;
-
private final BluetoothDevice mDevice;
private String mName;
private short mRssi;
@@ -275,7 +269,7 @@ public class CachedBluetoothDevice implements Comparable<CachedBluetoothDevice>
mConnectAttempted = SystemClock.elapsedRealtime();
- connectWithoutResettingTimer();
+ connectWithoutResettingTimer(true);
}
/*package*/ void onBondingDockConnect() {
@@ -284,7 +278,7 @@ public class CachedBluetoothDevice implements Comparable<CachedBluetoothDevice>
connect();
}
- private void connectWithoutResettingTimer() {
+ private void connectWithoutResettingTimer(boolean connectAllProfiles) {
// Try to initialize the profiles if there were not.
if (mProfiles.size() == 0) {
if (!updateProfiles()) {
@@ -300,7 +294,7 @@ public class CachedBluetoothDevice implements Comparable<CachedBluetoothDevice>
int preferredProfiles = 0;
for (Profile profile : mProfiles) {
- if (isConnectableProfile(profile)) {
+ if (connectAllProfiles ? profile.isConnectable() : profile.isAutoConnectable()) {
LocalBluetoothProfileManager profileManager = LocalBluetoothProfileManager
.getProfileManager(mLocalManager, profile);
if (profileManager.isPreferred(mDevice)) {
@@ -313,18 +307,18 @@ public class CachedBluetoothDevice implements Comparable<CachedBluetoothDevice>
if (DEBUG) Log.d(TAG, "Preferred profiles = " + preferredProfiles);
if (preferredProfiles == 0) {
- connectAllProfiles();
+ connectAllAutoConnectableProfiles();
}
}
- private void connectAllProfiles() {
+ private void connectAllAutoConnectableProfiles() {
if (!ensurePaired()) return;
// Reset the only-show-one-error-dialog tracking variable
mIsConnectingErrorPossible = true;
for (Profile profile : mProfiles) {
- if (isConnectableProfile(profile)) {
+ if (profile.isAutoConnectable()) {
LocalBluetoothProfileManager profileManager = LocalBluetoothProfileManager
.getProfileManager(mLocalManager, profile);
profileManager.setPreferred(mDevice, true);
@@ -378,7 +372,7 @@ public class CachedBluetoothDevice implements Comparable<CachedBluetoothDevice>
if (!mIsConnectingErrorPossible) return;
mIsConnectingErrorPossible = false;
- mLocalManager.showError(mDevice, R.string.bluetooth_error_title,
+ mLocalManager.showError(mDevice,
R.string.bluetooth_connecting_error_message);
}
@@ -400,7 +394,7 @@ public class CachedBluetoothDevice implements Comparable<CachedBluetoothDevice>
}
if (!mDevice.createBond()) {
- mLocalManager.showError(mDevice, R.string.bluetooth_error_title,
+ mLocalManager.showError(mDevice,
R.string.bluetooth_pairing_error_message);
return;
}
@@ -635,7 +629,7 @@ public class CachedBluetoothDevice implements Comparable<CachedBluetoothDevice>
if (mProfiles.size() > 0
&& (mConnectAttempted + MAX_UUID_DELAY_FOR_AUTO_CONNECT) > SystemClock
.elapsedRealtime()) {
- connectWithoutResettingTimer();
+ connectWithoutResettingTimer(false);
}
dispatchAttributesChanged();
}
@@ -699,18 +693,13 @@ public class CachedBluetoothDevice implements Comparable<CachedBluetoothDevice>
public List<Profile> getConnectableProfiles() {
ArrayList<Profile> connectableProfiles = new ArrayList<Profile>();
for (Profile profile : mProfiles) {
- if (isConnectableProfile(profile)) {
+ if (profile.isConnectable()) {
connectableProfiles.add(profile);
}
}
return connectableProfiles;
}
- private boolean isConnectableProfile(Profile profile) {
- return profile.equals(Profile.HEADSET) || profile.equals(Profile.A2DP) ||
- profile.equals(Profile.HID);
- }
-
public void onClickedAdvancedOptions(SettingsPreferenceFragment fragment) {
// TODO: Verify if there really is a case when there's no foreground
// activity
diff --git a/src/com/android/settings/bluetooth/CachedBluetoothDeviceManager.java b/src/com/android/settings/bluetooth/CachedBluetoothDeviceManager.java
index 67d7f54..3ee8bc2 100644
--- a/src/com/android/settings/bluetooth/CachedBluetoothDeviceManager.java
+++ b/src/com/android/settings/bluetooth/CachedBluetoothDeviceManager.java
@@ -32,7 +32,7 @@ import java.util.Set;
/**
* CachedBluetoothDeviceManager manages the set of remote Bluetooth devices.
*/
-public class CachedBluetoothDeviceManager {
+class CachedBluetoothDeviceManager {
private static final String TAG = "CachedBluetoothDeviceManager";
final LocalBluetoothManager mLocalManager;
@@ -207,22 +207,22 @@ public class CachedBluetoothDeviceManager {
switch(reason) {
case BluetoothDevice.UNBOND_REASON_AUTH_FAILED:
errorMsg = R.string.bluetooth_pairing_pin_error_message;
- mLocalManager.showError(device, R.string.bluetooth_error_title, errorMsg);
+ mLocalManager.showError(device, errorMsg);
break;
case BluetoothDevice.UNBOND_REASON_AUTH_REJECTED:
errorMsg = R.string.bluetooth_pairing_rejected_error_message;
- mLocalManager.showError(device, R.string.bluetooth_error_title, errorMsg);
+ mLocalManager.showError(device, errorMsg);
break;
case BluetoothDevice.UNBOND_REASON_REMOTE_DEVICE_DOWN:
errorMsg = R.string.bluetooth_pairing_device_down_error_message;
- mLocalManager.showError(device, R.string.bluetooth_error_title, errorMsg);
+ mLocalManager.showError(device, errorMsg);
break;
case BluetoothDevice.UNBOND_REASON_DISCOVERY_IN_PROGRESS:
case BluetoothDevice.UNBOND_REASON_AUTH_TIMEOUT:
case BluetoothDevice.UNBOND_REASON_REPEATED_ATTEMPTS:
case BluetoothDevice.UNBOND_REASON_REMOTE_AUTH_CANCELED:
errorMsg = R.string.bluetooth_pairing_error_message;
- mLocalManager.showError(device, R.string.bluetooth_error_title, errorMsg);
+ mLocalManager.showError(device, errorMsg);
break;
default:
Log.w(TAG, "showUnbondMessage: Not displaying any message for reason:" + reason);
diff --git a/src/com/android/settings/bluetooth/DeviceProfilesSettings.java b/src/com/android/settings/bluetooth/DeviceProfilesSettings.java
index 50ebadd..7961281 100644
--- a/src/com/android/settings/bluetooth/DeviceProfilesSettings.java
+++ b/src/com/android/settings/bluetooth/DeviceProfilesSettings.java
@@ -20,9 +20,7 @@ import com.android.settings.R;
import com.android.settings.SettingsPreferenceFragment;
import com.android.settings.bluetooth.LocalBluetoothProfileManager.Profile;
-import android.app.FragmentTransaction;
import android.bluetooth.BluetoothDevice;
-import android.bluetooth.BluetoothProfile;
import android.os.Bundle;
import android.preference.CheckBoxPreference;
import android.preference.EditTextPreference;
@@ -59,7 +57,7 @@ public class DeviceProfilesSettings extends SettingsPreferenceFragment
private PreferenceGroup mProfileContainer;
private CheckBoxPreference mAllowIncomingPref;
private EditTextPreference mDeviceNamePref;
- private HashMap<String,CheckBoxPreference> mAutoConnectPrefs
+ private final HashMap<String,CheckBoxPreference> mAutoConnectPrefs
= new HashMap<String,CheckBoxPreference>();
@Override
@@ -156,6 +154,14 @@ public class DeviceProfilesSettings extends SettingsPreferenceFragment
pref.setOrder(getProfilePreferenceIndex(profile));
pref.setOnExpandClickListener(this);
+ LocalBluetoothProfileManager profileManager =
+ LocalBluetoothProfileManager.getProfileManager(mManager, profile);
+ int iconResource = profileManager.getDrawableResource();
+ if (iconResource != 0) {
+ pref.setProfileDrawable(mManager.getContext()
+ .getResources().getDrawable(iconResource));
+ }
+
/**
* Gray out profile while connecting and disconnecting
*/
@@ -302,6 +308,8 @@ public class DeviceProfilesSettings extends SettingsPreferenceFragment
return R.string.bluetooth_headset_profile_summary_use_for;
case HID:
return R.string.bluetooth_hid_profile_summary_use_for;
+ case PAN:
+ return R.string.bluetooth_pan_profile_summary_use_for;
default:
return 0;
}
@@ -315,7 +323,7 @@ public class DeviceProfilesSettings extends SettingsPreferenceFragment
autoConnectPref = new CheckBoxPreference(getActivity());
autoConnectPref.setLayoutResource(com.android.internal.R.layout.preference_child);
autoConnectPref.setKey(prof.toString());
- autoConnectPref.setTitle(getCheckBoxTitle(prof));
+ autoConnectPref.setTitle(R.string.bluetooth_auto_connect);
autoConnectPref.setOrder(getProfilePreferenceIndex(prof) + 1);
autoConnectPref.setChecked(getAutoConnect(prof));
autoConnectPref.setOnPreferenceChangeListener(this);
@@ -356,11 +364,6 @@ public class DeviceProfilesSettings extends SettingsPreferenceFragment
return true;
}
- private String getCheckBoxTitle(Profile prof) {
- // TODO: Use resources and base it on profile if necessary
- return "Auto connect";
- }
-
private boolean getAutoConnect(Profile prof) {
return LocalBluetoothProfileManager.getProfileManager(mManager, prof)
.isPreferred(mCachedDevice.getDevice());
diff --git a/src/com/android/settings/bluetooth/DockEventReceiver.java b/src/com/android/settings/bluetooth/DockEventReceiver.java
index 88bc02f..0410998 100644
--- a/src/com/android/settings/bluetooth/DockEventReceiver.java
+++ b/src/com/android/settings/bluetooth/DockEventReceiver.java
@@ -16,8 +16,6 @@
package com.android.settings.bluetooth;
-import com.android.settings.bluetooth.LocalBluetoothProfileManager.Profile;
-
import android.app.Service;
import android.bluetooth.BluetoothA2dp;
import android.bluetooth.BluetoothAdapter;
@@ -27,7 +25,6 @@ import android.bluetooth.BluetoothProfile;
import android.content.BroadcastReceiver;
import android.content.Context;
import android.content.Intent;
-import android.content.IntentFilter;
import android.os.PowerManager;
import android.util.Log;
diff --git a/src/com/android/settings/bluetooth/DockService.java b/src/com/android/settings/bluetooth/DockService.java
index 0641a03..d165f9b 100644
--- a/src/com/android/settings/bluetooth/DockService.java
+++ b/src/com/android/settings/bluetooth/DockService.java
@@ -27,7 +27,6 @@ import android.bluetooth.BluetoothA2dp;
import android.bluetooth.BluetoothAdapter;
import android.bluetooth.BluetoothDevice;
import android.bluetooth.BluetoothHeadset;
-import android.bluetooth.BluetoothProfile;
import android.content.Context;
import android.content.DialogInterface;
import android.content.Intent;
diff --git a/src/com/android/settings/bluetooth/LocalBluetoothManager.java b/src/com/android/settings/bluetooth/LocalBluetoothManager.java
index 22390c6..f3c5e6f 100644
--- a/src/com/android/settings/bluetooth/LocalBluetoothManager.java
+++ b/src/com/android/settings/bluetooth/LocalBluetoothManager.java
@@ -57,12 +57,11 @@ public class LocalBluetoothManager {
private BluetoothAdapter mAdapter;
private CachedBluetoothDeviceManager mCachedDeviceManager;
- private BluetoothEventRedirector mEventRedirector;
private BluetoothA2dp mBluetoothA2dp;
private int mState = BluetoothAdapter.ERROR;
- private List<Callback> mCallbacks = new ArrayList<Callback>();
+ private final List<Callback> mCallbacks = new ArrayList<Callback>();
private static final int SCAN_EXPIRATION_MS = 5 * 60 * 1000; // 5 mins
@@ -111,15 +110,14 @@ public class LocalBluetoothManager {
mCachedDeviceManager = new CachedBluetoothDeviceManager(this);
- mEventRedirector = new BluetoothEventRedirector(this);
- mEventRedirector.start();
+ new BluetoothEventRedirector(this).registerReceiver();
mAdapter.getProfileProxy(mContext, mProfileListener, BluetoothProfile.A2DP);
return true;
}
- private BluetoothProfile.ServiceListener mProfileListener =
+ private final BluetoothProfile.ServiceListener mProfileListener =
new BluetoothProfile.ServiceListener() {
public void onServiceConnected(int profile, BluetoothProfile proxy) {
mBluetoothA2dp = (BluetoothA2dp) proxy;
@@ -286,7 +284,7 @@ public class LocalBluetoothManager {
}
}
- public void showError(BluetoothDevice device, int titleResId, int messageResId) {
+ public void showError(BluetoothDevice device, int messageResId) {
CachedBluetoothDevice cachedDevice = mCachedDeviceManager.findDevice(device);
String name = null;
if (cachedDevice == null) {
@@ -304,7 +302,7 @@ public class LocalBluetoothManager {
// Need an activity context to show a dialog
mErrorDialog = new AlertDialog.Builder(mForegroundActivity)
.setIcon(android.R.drawable.ic_dialog_alert)
- .setTitle(titleResId)
+ .setTitle(R.string.bluetooth_error_title)
.setMessage(message)
.setPositiveButton(android.R.string.ok, null)
.show();
diff --git a/src/com/android/settings/bluetooth/LocalBluetoothProfileManager.java b/src/com/android/settings/bluetooth/LocalBluetoothProfileManager.java
index f177ed0..5c8d868 100644
--- a/src/com/android/settings/bluetooth/LocalBluetoothProfileManager.java
+++ b/src/com/android/settings/bluetooth/LocalBluetoothProfileManager.java
@@ -40,7 +40,7 @@ import java.util.Map;
* LocalBluetoothProfileManager is an abstract class defining the basic
* functionality related to a profile.
*/
-public abstract class LocalBluetoothProfileManager {
+abstract class LocalBluetoothProfileManager {
private static final String TAG = "LocalBluetoothProfileManager";
/* package */ static final ParcelUuid[] HEADSET_PROFILE_UUIDS = new ParcelUuid[] {
@@ -97,10 +97,10 @@ public abstract class LocalBluetoothProfileManager {
}
// TODO: close profiles when we're shutting down
- private static Map<Profile, LocalBluetoothProfileManager> sProfileMap =
+ private static final Map<Profile, LocalBluetoothProfileManager> sProfileMap =
new HashMap<Profile, LocalBluetoothProfileManager>();
- protected LocalBluetoothManager mLocalManager;
+ protected final LocalBluetoothManager mLocalManager;
public static void init(LocalBluetoothManager localManager) {
synchronized (sProfileMap) {
@@ -141,14 +141,10 @@ public abstract class LocalBluetoothProfileManager {
sProfileMap.remove(Profile.OPP);
}
- if (!BluetoothUuid.containsAnyUuid(uuids, PANU_PROFILE_UUIDS)) {
- sProfileMap.remove(Profile.PAN);
- }
-
// There is no local SDP record for HID and Settings app doesn't control PBAP
}
- private static LinkedList<ServiceListener> mServiceListeners =
+ private static final LinkedList<ServiceListener> mServiceListeners =
new LinkedList<ServiceListener>();
public static void addServiceListener(ServiceListener l) {
@@ -225,7 +221,7 @@ public abstract class LocalBluetoothProfileManager {
profiles.add(Profile.HID);
}
- if (BluetoothUuid.containsAnyUuid(uuids, PANU_PROFILE_UUIDS) &&
+ if (BluetoothUuid.containsAnyUuid(uuids, NAP_PROFILE_UUIDS) &&
sProfileMap.containsKey(Profile.PAN)) {
profiles.add(Profile.PAN);
}
@@ -259,21 +255,32 @@ public abstract class LocalBluetoothProfileManager {
public abstract boolean isProfileReady();
- public int getDrawableResource() {
- return R.drawable.ic_bt_headphones_a2dp;
- }
+ public abstract int getDrawableResource();
public static enum Profile {
- HEADSET(R.string.bluetooth_profile_headset),
- A2DP(R.string.bluetooth_profile_a2dp),
- OPP(R.string.bluetooth_profile_opp),
- HID(R.string.bluetooth_profile_hid),
- PAN(R.string.bluetooth_profile_pan);
+ HEADSET(R.string.bluetooth_profile_headset, true, true),
+ A2DP(R.string.bluetooth_profile_a2dp, true, true),
+ OPP(R.string.bluetooth_profile_opp, false, false),
+ HID(R.string.bluetooth_profile_hid, true, true),
+ PAN(R.string.bluetooth_profile_pan, true, false);
public final int localizedString;
+ private final boolean mConnectable;
+ private final boolean mAutoConnectable;
- private Profile(int localizedString) {
+ private Profile(int localizedString, boolean connectable,
+ boolean autoConnectable) {
this.localizedString = localizedString;
+ this.mConnectable = connectable;
+ this.mAutoConnectable = autoConnectable;
+ }
+
+ public boolean isConnectable() {
+ return mConnectable;
+ }
+
+ public boolean isAutoConnectable() {
+ return mAutoConnectable;
}
}
@@ -401,7 +408,7 @@ public abstract class LocalBluetoothProfileManager {
private static class HeadsetProfileManager extends LocalBluetoothProfileManager
implements BluetoothProfile.ServiceListener {
private BluetoothHeadset mService;
- private Handler mUiHandler = new Handler();
+ private final Handler mUiHandler = new Handler();
private boolean profileReady = false;
// TODO(): The calls must get queued if mService becomes null.
@@ -623,7 +630,7 @@ public abstract class LocalBluetoothProfileManager {
}
private static class HidProfileManager extends LocalBluetoothProfileManager {
- private BluetoothInputDevice mService;
+ private final BluetoothInputDevice mService;
public HidProfileManager(LocalBluetoothManager localManager) {
super(localManager);
@@ -711,7 +718,7 @@ public abstract class LocalBluetoothProfileManager {
}
private static class PanProfileManager extends LocalBluetoothProfileManager {
- private BluetoothPan mService;
+ private final BluetoothPan mService;
public PanProfileManager(LocalBluetoothManager localManager) {
super(localManager);
@@ -777,17 +784,18 @@ public abstract class LocalBluetoothProfileManager {
@Override
public boolean isPreferred(BluetoothDevice device) {
- return false;
+ return true;
}
@Override
public void setPreferred(BluetoothDevice device, boolean preferred) {
+ // ignore: isPreferred is always true for PAN
return;
}
@Override
public int getDrawableResource() {
- // TODO:
+ // TODO: return PAN icon resource ID
return 0;
}
}
diff --git a/src/com/android/settings/bluetooth/RequestPermissionActivity.java b/src/com/android/settings/bluetooth/RequestPermissionActivity.java
index dd802f3..97ec017 100644
--- a/src/com/android/settings/bluetooth/RequestPermissionActivity.java
+++ b/src/com/android/settings/bluetooth/RequestPermissionActivity.java
@@ -72,7 +72,7 @@ public class RequestPermissionActivity extends Activity implements
private AlertDialog mDialog = null;
- private BroadcastReceiver mReceiver = new BroadcastReceiver() {
+ private final BroadcastReceiver mReceiver = new BroadcastReceiver() {
@Override
public void onReceive(Context context, Intent intent) {
diff --git a/src/com/android/settings/bluetooth/SettingsBtStatus.java b/src/com/android/settings/bluetooth/SettingsBtStatus.java
index c6ec23b..2407b53 100644
--- a/src/com/android/settings/bluetooth/SettingsBtStatus.java
+++ b/src/com/android/settings/bluetooth/SettingsBtStatus.java
@@ -24,7 +24,7 @@ import com.android.settings.R;
* SettingsBtStatus is a helper class that contains constants for various status
* codes.
*/
-public class SettingsBtStatus {
+class SettingsBtStatus {
private static final String TAG = "SettingsBtStatus";
// Connection status