Loading packages/SettingsLib/src/com/android/settingslib/bluetooth/MapProfile.java +27 −26 Original line number Diff line number Diff line Loading @@ -32,11 +32,10 @@ import java.util.ArrayList; import java.util.List; /** * MapProfile handles Bluetooth MAP profile. * MapProfile handles the Bluetooth MAP MSE role */ public class MapProfile implements LocalBluetoothProfile { private static final String TAG = "MapProfile"; private static boolean V = true; private BluetoothMap mService; private boolean mIsProfileReady; Loading @@ -60,7 +59,7 @@ public class MapProfile implements LocalBluetoothProfile { implements BluetoothProfile.ServiceListener { public void onServiceConnected(int profile, BluetoothProfile proxy) { if (V) Log.d(TAG,"Bluetooth service connected"); Log.d(TAG, "Bluetooth service connected"); mService = (BluetoothMap) proxy; // We just bound to the service, so refresh the UI for any connected MAP devices. List<BluetoothDevice> deviceList = mService.getConnectedDevices(); Loading @@ -82,14 +81,14 @@ public class MapProfile implements LocalBluetoothProfile { } public void onServiceDisconnected(int profile) { if (V) Log.d(TAG,"Bluetooth service disconnected"); Log.d(TAG, "Bluetooth service disconnected"); mProfileManager.callServiceDisconnectedListeners(); mIsProfileReady=false; } } public boolean isProfileReady() { if(V) Log.d(TAG,"isProfileReady(): "+ mIsProfileReady); Log.d(TAG, "isProfileReady(): " + mIsProfileReady); return mIsProfileReady; } Loading Loading @@ -117,45 +116,45 @@ public class MapProfile implements LocalBluetoothProfile { } public boolean connect(BluetoothDevice device) { if(V)Log.d(TAG,"connect() - should not get called"); Log.d(TAG, "connect() - should not get called"); return false; // MAP never connects out } public boolean disconnect(BluetoothDevice device) { if (mService == null) return false; List<BluetoothDevice> deviceList = mService.getConnectedDevices(); if (!deviceList.isEmpty() && deviceList.get(0).equals(device)) { if (mService == null) { return false; } if (mService.getPriority(device) > BluetoothProfile.PRIORITY_ON) { mService.setPriority(device, BluetoothProfile.PRIORITY_ON); } return mService.disconnect(device); } else { return false; } } public int getConnectionStatus(BluetoothDevice device) { if (mService == null) return BluetoothProfile.STATE_DISCONNECTED; List<BluetoothDevice> deviceList = mService.getConnectedDevices(); if(V) Log.d(TAG,"getConnectionStatus: status is: "+ mService.getConnectionState(device)); return !deviceList.isEmpty() && deviceList.get(0).equals(device) ? mService.getConnectionState(device) : BluetoothProfile.STATE_DISCONNECTED; if (mService == null) { return BluetoothProfile.STATE_DISCONNECTED; } return mService.getConnectionState(device); } public boolean isPreferred(BluetoothDevice device) { if (mService == null) return false; if (mService == null) { return false; } return mService.getPriority(device) > BluetoothProfile.PRIORITY_OFF; } public int getPreferred(BluetoothDevice device) { if (mService == null) return BluetoothProfile.PRIORITY_OFF; if (mService == null) { return BluetoothProfile.PRIORITY_OFF; } return mService.getPriority(device); } public void setPreferred(BluetoothDevice device, boolean preferred) { if (mService == null) return; if (mService == null) { return; } if (preferred) { if (mService.getPriority(device) < BluetoothProfile.PRIORITY_ON) { mService.setPriority(device, BluetoothProfile.PRIORITY_ON); Loading @@ -166,7 +165,9 @@ public class MapProfile implements LocalBluetoothProfile { } public List<BluetoothDevice> getConnectedDevices() { if (mService == null) return new ArrayList<BluetoothDevice>(0); if (mService == null) { return new ArrayList<BluetoothDevice>(0); } return mService.getDevicesMatchingConnectionStates( new int[] {BluetoothProfile.STATE_CONNECTED, BluetoothProfile.STATE_CONNECTING, Loading Loading @@ -204,7 +205,7 @@ public class MapProfile implements LocalBluetoothProfile { } protected void finalize() { if (V) Log.d(TAG, "finalize()"); Log.d(TAG, "finalize()"); if (mService != null) { try { BluetoothAdapter.getDefaultAdapter().closeProfileProxy(BluetoothProfile.MAP, Loading Loading
packages/SettingsLib/src/com/android/settingslib/bluetooth/MapProfile.java +27 −26 Original line number Diff line number Diff line Loading @@ -32,11 +32,10 @@ import java.util.ArrayList; import java.util.List; /** * MapProfile handles Bluetooth MAP profile. * MapProfile handles the Bluetooth MAP MSE role */ public class MapProfile implements LocalBluetoothProfile { private static final String TAG = "MapProfile"; private static boolean V = true; private BluetoothMap mService; private boolean mIsProfileReady; Loading @@ -60,7 +59,7 @@ public class MapProfile implements LocalBluetoothProfile { implements BluetoothProfile.ServiceListener { public void onServiceConnected(int profile, BluetoothProfile proxy) { if (V) Log.d(TAG,"Bluetooth service connected"); Log.d(TAG, "Bluetooth service connected"); mService = (BluetoothMap) proxy; // We just bound to the service, so refresh the UI for any connected MAP devices. List<BluetoothDevice> deviceList = mService.getConnectedDevices(); Loading @@ -82,14 +81,14 @@ public class MapProfile implements LocalBluetoothProfile { } public void onServiceDisconnected(int profile) { if (V) Log.d(TAG,"Bluetooth service disconnected"); Log.d(TAG, "Bluetooth service disconnected"); mProfileManager.callServiceDisconnectedListeners(); mIsProfileReady=false; } } public boolean isProfileReady() { if(V) Log.d(TAG,"isProfileReady(): "+ mIsProfileReady); Log.d(TAG, "isProfileReady(): " + mIsProfileReady); return mIsProfileReady; } Loading Loading @@ -117,45 +116,45 @@ public class MapProfile implements LocalBluetoothProfile { } public boolean connect(BluetoothDevice device) { if(V)Log.d(TAG,"connect() - should not get called"); Log.d(TAG, "connect() - should not get called"); return false; // MAP never connects out } public boolean disconnect(BluetoothDevice device) { if (mService == null) return false; List<BluetoothDevice> deviceList = mService.getConnectedDevices(); if (!deviceList.isEmpty() && deviceList.get(0).equals(device)) { if (mService == null) { return false; } if (mService.getPriority(device) > BluetoothProfile.PRIORITY_ON) { mService.setPriority(device, BluetoothProfile.PRIORITY_ON); } return mService.disconnect(device); } else { return false; } } public int getConnectionStatus(BluetoothDevice device) { if (mService == null) return BluetoothProfile.STATE_DISCONNECTED; List<BluetoothDevice> deviceList = mService.getConnectedDevices(); if(V) Log.d(TAG,"getConnectionStatus: status is: "+ mService.getConnectionState(device)); return !deviceList.isEmpty() && deviceList.get(0).equals(device) ? mService.getConnectionState(device) : BluetoothProfile.STATE_DISCONNECTED; if (mService == null) { return BluetoothProfile.STATE_DISCONNECTED; } return mService.getConnectionState(device); } public boolean isPreferred(BluetoothDevice device) { if (mService == null) return false; if (mService == null) { return false; } return mService.getPriority(device) > BluetoothProfile.PRIORITY_OFF; } public int getPreferred(BluetoothDevice device) { if (mService == null) return BluetoothProfile.PRIORITY_OFF; if (mService == null) { return BluetoothProfile.PRIORITY_OFF; } return mService.getPriority(device); } public void setPreferred(BluetoothDevice device, boolean preferred) { if (mService == null) return; if (mService == null) { return; } if (preferred) { if (mService.getPriority(device) < BluetoothProfile.PRIORITY_ON) { mService.setPriority(device, BluetoothProfile.PRIORITY_ON); Loading @@ -166,7 +165,9 @@ public class MapProfile implements LocalBluetoothProfile { } public List<BluetoothDevice> getConnectedDevices() { if (mService == null) return new ArrayList<BluetoothDevice>(0); if (mService == null) { return new ArrayList<BluetoothDevice>(0); } return mService.getDevicesMatchingConnectionStates( new int[] {BluetoothProfile.STATE_CONNECTED, BluetoothProfile.STATE_CONNECTING, Loading Loading @@ -204,7 +205,7 @@ public class MapProfile implements LocalBluetoothProfile { } protected void finalize() { if (V) Log.d(TAG, "finalize()"); Log.d(TAG, "finalize()"); if (mService != null) { try { BluetoothAdapter.getDefaultAdapter().closeProfileProxy(BluetoothProfile.MAP, Loading