Loading packages/SettingsLib/src/com/android/settingslib/bluetooth/CachedBluetoothDevice.java +29 −37 Original line number Original line Diff line number Diff line Loading @@ -29,8 +29,6 @@ import android.os.SystemClock; import android.text.TextUtils; import android.text.TextUtils; import android.util.Log; import android.util.Log; import androidx.annotation.VisibleForTesting; import com.android.settingslib.R; import com.android.settingslib.R; import java.util.ArrayList; import java.util.ArrayList; Loading @@ -39,6 +37,8 @@ import java.util.Collections; import java.util.HashMap; import java.util.HashMap; import java.util.List; import java.util.List; import androidx.annotation.VisibleForTesting; /** /** * CachedBluetoothDevice represents a remote Bluetooth device. It contains * CachedBluetoothDevice represents a remote Bluetooth device. It contains * attributes of the device (such as the address, name, RSSI, etc.) and * attributes of the device (such as the address, name, RSSI, etc.) and Loading @@ -48,6 +48,10 @@ import java.util.List; public class CachedBluetoothDevice implements Comparable<CachedBluetoothDevice> { public class CachedBluetoothDevice implements Comparable<CachedBluetoothDevice> { private static final String TAG = "CachedBluetoothDevice"; private static final String TAG = "CachedBluetoothDevice"; // See mConnectAttempted private static final long MAX_UUID_DELAY_FOR_AUTO_CONNECT = 5000; private static final long MAX_HOGP_DELAY_FOR_AUTO_CONNECT = 30000; private final Context mContext; private final Context mContext; private final BluetoothAdapter mLocalAdapter; private final BluetoothAdapter mLocalAdapter; private final LocalBluetoothProfileManager mProfileManager; private final LocalBluetoothProfileManager mProfileManager; Loading Loading @@ -78,17 +82,6 @@ public class CachedBluetoothDevice implements Comparable<CachedBluetoothDevice> private final static String MESSAGE_REJECTION_COUNT_PREFS_NAME = "bluetooth_message_reject"; private final static String MESSAGE_REJECTION_COUNT_PREFS_NAME = "bluetooth_message_reject"; public long getHiSyncId() { return mHiSyncId; } public void setHiSyncId(long id) { if (BluetoothUtils.D) { Log.d(TAG, "setHiSyncId: mDevice " + mDevice + ", id " + id); } mHiSyncId = id; } /** /** * Last time a bt profile auto-connect was attempted. * Last time a bt profile auto-connect was attempted. * If an ACTION_UUID intent comes in within * If an ACTION_UUID intent comes in within Loading @@ -97,14 +90,22 @@ public class CachedBluetoothDevice implements Comparable<CachedBluetoothDevice> */ */ private long mConnectAttempted; private long mConnectAttempted; // See mConnectAttempted private static final long MAX_UUID_DELAY_FOR_AUTO_CONNECT = 5000; private static final long MAX_HOGP_DELAY_FOR_AUTO_CONNECT = 30000; // Active device state // Active device state private boolean mIsActiveDeviceA2dp = false; private boolean mIsActiveDeviceA2dp = false; private boolean mIsActiveDeviceHeadset = false; private boolean mIsActiveDeviceHeadset = false; private boolean mIsActiveDeviceHearingAid = false; private boolean mIsActiveDeviceHearingAid = false; CachedBluetoothDevice(Context context, LocalBluetoothProfileManager profileManager, BluetoothDevice device) { mContext = context; mLocalAdapter = BluetoothAdapter.getDefaultAdapter(); mProfileManager = profileManager; mDevice = device; mProfileConnectionState = new HashMap<>(); fillData(); mHiSyncId = BluetoothHearingAid.HI_SYNC_ID_INVALID; } /** /** * Describes the current device and profile for logging. * Describes the current device and profile for logging. * * Loading Loading @@ -161,18 +162,6 @@ public class CachedBluetoothDevice implements Comparable<CachedBluetoothDevice> fetchActiveDevices(); fetchActiveDevices(); } } CachedBluetoothDevice(Context context, LocalBluetoothProfileManager profileManager, BluetoothDevice device) { mContext = context; mLocalAdapter = BluetoothAdapter.getDefaultAdapter(); mProfileManager = profileManager; mDevice = device; mProfileConnectionState = new HashMap<LocalBluetoothProfile, Integer>(); fillData(); mHiSyncId = BluetoothHearingAid.HI_SYNC_ID_INVALID; } public void disconnect() { public void disconnect() { for (LocalBluetoothProfile profile : mProfiles) { for (LocalBluetoothProfile profile : mProfiles) { disconnect(profile); disconnect(profile); Loading Loading @@ -204,6 +193,17 @@ public class CachedBluetoothDevice implements Comparable<CachedBluetoothDevice> connectWithoutResettingTimer(connectAllProfiles); connectWithoutResettingTimer(connectAllProfiles); } } public long getHiSyncId() { return mHiSyncId; } public void setHiSyncId(long id) { if (BluetoothUtils.D) { Log.d(TAG, "setHiSyncId: mDevice " + mDevice + ", id " + id); } mHiSyncId = id; } void onBondingDockConnect() { void onBondingDockConnect() { // Attempt to connect if UUIDs are available. Otherwise, // Attempt to connect if UUIDs are available. Otherwise, // we will connect when the ACTION_UUID intent arrives. // we will connect when the ACTION_UUID intent arrives. Loading Loading @@ -300,14 +300,6 @@ public class CachedBluetoothDevice implements Comparable<CachedBluetoothDevice> return true; return true; } } /** * Return true if user initiated pairing on this device. The message text is * slightly different for local vs. remote initiated pairing dialogs. */ boolean isUserInitiatedPairing() { return mDevice.isBondingInitiatedLocally(); } public void unpair() { public void unpair() { int state = getBondState(); int state = getBondState(); Loading Loading
packages/SettingsLib/src/com/android/settingslib/bluetooth/CachedBluetoothDevice.java +29 −37 Original line number Original line Diff line number Diff line Loading @@ -29,8 +29,6 @@ import android.os.SystemClock; import android.text.TextUtils; import android.text.TextUtils; import android.util.Log; import android.util.Log; import androidx.annotation.VisibleForTesting; import com.android.settingslib.R; import com.android.settingslib.R; import java.util.ArrayList; import java.util.ArrayList; Loading @@ -39,6 +37,8 @@ import java.util.Collections; import java.util.HashMap; import java.util.HashMap; import java.util.List; import java.util.List; import androidx.annotation.VisibleForTesting; /** /** * CachedBluetoothDevice represents a remote Bluetooth device. It contains * CachedBluetoothDevice represents a remote Bluetooth device. It contains * attributes of the device (such as the address, name, RSSI, etc.) and * attributes of the device (such as the address, name, RSSI, etc.) and Loading @@ -48,6 +48,10 @@ import java.util.List; public class CachedBluetoothDevice implements Comparable<CachedBluetoothDevice> { public class CachedBluetoothDevice implements Comparable<CachedBluetoothDevice> { private static final String TAG = "CachedBluetoothDevice"; private static final String TAG = "CachedBluetoothDevice"; // See mConnectAttempted private static final long MAX_UUID_DELAY_FOR_AUTO_CONNECT = 5000; private static final long MAX_HOGP_DELAY_FOR_AUTO_CONNECT = 30000; private final Context mContext; private final Context mContext; private final BluetoothAdapter mLocalAdapter; private final BluetoothAdapter mLocalAdapter; private final LocalBluetoothProfileManager mProfileManager; private final LocalBluetoothProfileManager mProfileManager; Loading Loading @@ -78,17 +82,6 @@ public class CachedBluetoothDevice implements Comparable<CachedBluetoothDevice> private final static String MESSAGE_REJECTION_COUNT_PREFS_NAME = "bluetooth_message_reject"; private final static String MESSAGE_REJECTION_COUNT_PREFS_NAME = "bluetooth_message_reject"; public long getHiSyncId() { return mHiSyncId; } public void setHiSyncId(long id) { if (BluetoothUtils.D) { Log.d(TAG, "setHiSyncId: mDevice " + mDevice + ", id " + id); } mHiSyncId = id; } /** /** * Last time a bt profile auto-connect was attempted. * Last time a bt profile auto-connect was attempted. * If an ACTION_UUID intent comes in within * If an ACTION_UUID intent comes in within Loading @@ -97,14 +90,22 @@ public class CachedBluetoothDevice implements Comparable<CachedBluetoothDevice> */ */ private long mConnectAttempted; private long mConnectAttempted; // See mConnectAttempted private static final long MAX_UUID_DELAY_FOR_AUTO_CONNECT = 5000; private static final long MAX_HOGP_DELAY_FOR_AUTO_CONNECT = 30000; // Active device state // Active device state private boolean mIsActiveDeviceA2dp = false; private boolean mIsActiveDeviceA2dp = false; private boolean mIsActiveDeviceHeadset = false; private boolean mIsActiveDeviceHeadset = false; private boolean mIsActiveDeviceHearingAid = false; private boolean mIsActiveDeviceHearingAid = false; CachedBluetoothDevice(Context context, LocalBluetoothProfileManager profileManager, BluetoothDevice device) { mContext = context; mLocalAdapter = BluetoothAdapter.getDefaultAdapter(); mProfileManager = profileManager; mDevice = device; mProfileConnectionState = new HashMap<>(); fillData(); mHiSyncId = BluetoothHearingAid.HI_SYNC_ID_INVALID; } /** /** * Describes the current device and profile for logging. * Describes the current device and profile for logging. * * Loading Loading @@ -161,18 +162,6 @@ public class CachedBluetoothDevice implements Comparable<CachedBluetoothDevice> fetchActiveDevices(); fetchActiveDevices(); } } CachedBluetoothDevice(Context context, LocalBluetoothProfileManager profileManager, BluetoothDevice device) { mContext = context; mLocalAdapter = BluetoothAdapter.getDefaultAdapter(); mProfileManager = profileManager; mDevice = device; mProfileConnectionState = new HashMap<LocalBluetoothProfile, Integer>(); fillData(); mHiSyncId = BluetoothHearingAid.HI_SYNC_ID_INVALID; } public void disconnect() { public void disconnect() { for (LocalBluetoothProfile profile : mProfiles) { for (LocalBluetoothProfile profile : mProfiles) { disconnect(profile); disconnect(profile); Loading Loading @@ -204,6 +193,17 @@ public class CachedBluetoothDevice implements Comparable<CachedBluetoothDevice> connectWithoutResettingTimer(connectAllProfiles); connectWithoutResettingTimer(connectAllProfiles); } } public long getHiSyncId() { return mHiSyncId; } public void setHiSyncId(long id) { if (BluetoothUtils.D) { Log.d(TAG, "setHiSyncId: mDevice " + mDevice + ", id " + id); } mHiSyncId = id; } void onBondingDockConnect() { void onBondingDockConnect() { // Attempt to connect if UUIDs are available. Otherwise, // Attempt to connect if UUIDs are available. Otherwise, // we will connect when the ACTION_UUID intent arrives. // we will connect when the ACTION_UUID intent arrives. Loading Loading @@ -300,14 +300,6 @@ public class CachedBluetoothDevice implements Comparable<CachedBluetoothDevice> return true; return true; } } /** * Return true if user initiated pairing on this device. The message text is * slightly different for local vs. remote initiated pairing dialogs. */ boolean isUserInitiatedPairing() { return mDevice.isBondingInitiatedLocally(); } public void unpair() { public void unpair() { int state = getBondState(); int state = getBondState(); Loading