Loading packages/SettingsLib/src/com/android/settingslib/bluetooth/CachedBluetoothDevice.java +21 −35 Original line number Diff line number Diff line Loading @@ -262,13 +262,28 @@ public class CachedBluetoothDevice implements Comparable<CachedBluetoothDevice> } } /** * Connect this device. * * @param connectAllProfiles {@code true} to connect all profile, {@code false} otherwise. * * @deprecated use {@link #connect()} instead. */ @Deprecated public void connect(boolean connectAllProfiles) { connect(); } /** * Connect this device. */ public void connect() { if (!ensurePaired()) { return; } mConnectAttempted = SystemClock.elapsedRealtime(); connectWithoutResettingTimer(connectAllProfiles); connectAllEnabledProfiles(); } public long getHiSyncId() { Loading @@ -289,10 +304,10 @@ public class CachedBluetoothDevice implements Comparable<CachedBluetoothDevice> void onBondingDockConnect() { // Attempt to connect if UUIDs are available. Otherwise, // we will connect when the ACTION_UUID intent arrives. connect(false); connect(); } private void connectWithoutResettingTimer(boolean connectAllProfiles) { private void connectAllEnabledProfiles() { synchronized (mProfileLock) { // Try to initialize the profiles if they were not. if (mProfiles.isEmpty()) { Loading @@ -307,36 +322,7 @@ public class CachedBluetoothDevice implements Comparable<CachedBluetoothDevice> return; } int preferredProfiles = 0; for (LocalBluetoothProfile profile : mProfiles) { if (connectAllProfiles ? profile.accessProfileEnabled() : profile.isAutoConnectable()) { if (profile.isPreferred(mDevice)) { ++preferredProfiles; connectInt(profile); } } } if (BluetoothUtils.D) Log.d(TAG, "Preferred profiles = " + preferredProfiles); if (preferredProfiles == 0) { connectAutoConnectableProfiles(); } } } private void connectAutoConnectableProfiles() { if (!ensurePaired()) { return; } synchronized (mProfileLock) { for (LocalBluetoothProfile profile : mProfiles) { if (profile.isAutoConnectable()) { profile.setPreferred(mDevice, true); connectInt(profile); } } mLocalAdapter.connectAllEnabledProfiles(mDevice); } } Loading Loading @@ -703,7 +689,7 @@ public class CachedBluetoothDevice implements Comparable<CachedBluetoothDevice> */ if (!mProfiles.isEmpty() && ((mConnectAttempted + timeout) > SystemClock.elapsedRealtime())) { connectWithoutResettingTimer(false); connectAllEnabledProfiles(); } dispatchAttributesChanged(); Loading @@ -722,7 +708,7 @@ public class CachedBluetoothDevice implements Comparable<CachedBluetoothDevice> refresh(); if (bondState == BluetoothDevice.BOND_BONDED && mDevice.isBondingInitiatedLocally()) { connect(false); connect(); } } Loading packages/SettingsLib/src/com/android/settingslib/media/LocalMediaManager.java +1 −1 Original line number Diff line number Diff line Loading @@ -122,7 +122,7 @@ public class LocalMediaManager implements BluetoothCallback { final CachedBluetoothDevice cachedDevice = ((BluetoothMediaDevice) device).getCachedDevice(); if (!cachedDevice.isConnected() && !cachedDevice.isBusy()) { cachedDevice.connect(true); cachedDevice.connect(); return; } } Loading packages/SettingsLib/tests/robotests/src/com/android/settingslib/media/LocalMediaManagerTest.java +1 −1 Original line number Diff line number Diff line Loading @@ -127,7 +127,7 @@ public class LocalMediaManagerTest { mLocalMediaManager.registerCallback(mCallback); mLocalMediaManager.connectDevice(device); verify(cachedDevice).connect(true); verify(cachedDevice).connect(); } @Test Loading Loading
packages/SettingsLib/src/com/android/settingslib/bluetooth/CachedBluetoothDevice.java +21 −35 Original line number Diff line number Diff line Loading @@ -262,13 +262,28 @@ public class CachedBluetoothDevice implements Comparable<CachedBluetoothDevice> } } /** * Connect this device. * * @param connectAllProfiles {@code true} to connect all profile, {@code false} otherwise. * * @deprecated use {@link #connect()} instead. */ @Deprecated public void connect(boolean connectAllProfiles) { connect(); } /** * Connect this device. */ public void connect() { if (!ensurePaired()) { return; } mConnectAttempted = SystemClock.elapsedRealtime(); connectWithoutResettingTimer(connectAllProfiles); connectAllEnabledProfiles(); } public long getHiSyncId() { Loading @@ -289,10 +304,10 @@ public class CachedBluetoothDevice implements Comparable<CachedBluetoothDevice> void onBondingDockConnect() { // Attempt to connect if UUIDs are available. Otherwise, // we will connect when the ACTION_UUID intent arrives. connect(false); connect(); } private void connectWithoutResettingTimer(boolean connectAllProfiles) { private void connectAllEnabledProfiles() { synchronized (mProfileLock) { // Try to initialize the profiles if they were not. if (mProfiles.isEmpty()) { Loading @@ -307,36 +322,7 @@ public class CachedBluetoothDevice implements Comparable<CachedBluetoothDevice> return; } int preferredProfiles = 0; for (LocalBluetoothProfile profile : mProfiles) { if (connectAllProfiles ? profile.accessProfileEnabled() : profile.isAutoConnectable()) { if (profile.isPreferred(mDevice)) { ++preferredProfiles; connectInt(profile); } } } if (BluetoothUtils.D) Log.d(TAG, "Preferred profiles = " + preferredProfiles); if (preferredProfiles == 0) { connectAutoConnectableProfiles(); } } } private void connectAutoConnectableProfiles() { if (!ensurePaired()) { return; } synchronized (mProfileLock) { for (LocalBluetoothProfile profile : mProfiles) { if (profile.isAutoConnectable()) { profile.setPreferred(mDevice, true); connectInt(profile); } } mLocalAdapter.connectAllEnabledProfiles(mDevice); } } Loading Loading @@ -703,7 +689,7 @@ public class CachedBluetoothDevice implements Comparable<CachedBluetoothDevice> */ if (!mProfiles.isEmpty() && ((mConnectAttempted + timeout) > SystemClock.elapsedRealtime())) { connectWithoutResettingTimer(false); connectAllEnabledProfiles(); } dispatchAttributesChanged(); Loading @@ -722,7 +708,7 @@ public class CachedBluetoothDevice implements Comparable<CachedBluetoothDevice> refresh(); if (bondState == BluetoothDevice.BOND_BONDED && mDevice.isBondingInitiatedLocally()) { connect(false); connect(); } } Loading
packages/SettingsLib/src/com/android/settingslib/media/LocalMediaManager.java +1 −1 Original line number Diff line number Diff line Loading @@ -122,7 +122,7 @@ public class LocalMediaManager implements BluetoothCallback { final CachedBluetoothDevice cachedDevice = ((BluetoothMediaDevice) device).getCachedDevice(); if (!cachedDevice.isConnected() && !cachedDevice.isBusy()) { cachedDevice.connect(true); cachedDevice.connect(); return; } } Loading
packages/SettingsLib/tests/robotests/src/com/android/settingslib/media/LocalMediaManagerTest.java +1 −1 Original line number Diff line number Diff line Loading @@ -127,7 +127,7 @@ public class LocalMediaManagerTest { mLocalMediaManager.registerCallback(mCallback); mLocalMediaManager.connectDevice(device); verify(cachedDevice).connect(true); verify(cachedDevice).connect(); } @Test Loading