Update connect/disconnect Bluetooth api am: 01e574ab74 am: 39a73b3955
Change-Id: I74026a38ae917875d592d5434b326b7ad8f81a9a
This commit is contained in:
@@ -16,6 +16,9 @@
|
|||||||
|
|
||||||
package com.android.settingslib.bluetooth;
|
package com.android.settingslib.bluetooth;
|
||||||
|
|
||||||
|
import static android.bluetooth.BluetoothProfile.CONNECTION_POLICY_ALLOWED;
|
||||||
|
import static android.bluetooth.BluetoothProfile.CONNECTION_POLICY_FORBIDDEN;
|
||||||
|
|
||||||
import android.bluetooth.BluetoothA2dp;
|
import android.bluetooth.BluetoothA2dp;
|
||||||
import android.bluetooth.BluetoothAdapter;
|
import android.bluetooth.BluetoothAdapter;
|
||||||
import android.bluetooth.BluetoothClass;
|
import android.bluetooth.BluetoothClass;
|
||||||
@@ -148,17 +151,18 @@ public class A2dpProfile implements LocalBluetoothProfile {
|
|||||||
}
|
}
|
||||||
|
|
||||||
public boolean connect(BluetoothDevice device) {
|
public boolean connect(BluetoothDevice device) {
|
||||||
if (mService == null) return false;
|
if (mService == null) {
|
||||||
return mService.connect(device);
|
return false;
|
||||||
|
}
|
||||||
|
return mService.setConnectionPolicy(device, CONNECTION_POLICY_ALLOWED);
|
||||||
}
|
}
|
||||||
|
|
||||||
public boolean disconnect(BluetoothDevice device) {
|
public boolean disconnect(BluetoothDevice device) {
|
||||||
if (mService == null) return false;
|
if (mService == null) {
|
||||||
// Downgrade priority as user is disconnecting the headset.
|
return false;
|
||||||
if (mService.getConnectionPolicy(device) > BluetoothProfile.CONNECTION_POLICY_ALLOWED) {
|
|
||||||
mService.setConnectionPolicy(device, BluetoothProfile.CONNECTION_POLICY_ALLOWED);
|
|
||||||
}
|
}
|
||||||
return mService.disconnect(device);
|
|
||||||
|
return mService.setConnectionPolicy(device, CONNECTION_POLICY_FORBIDDEN);
|
||||||
}
|
}
|
||||||
|
|
||||||
public int getConnectionStatus(BluetoothDevice device) {
|
public int getConnectionStatus(BluetoothDevice device) {
|
||||||
@@ -182,12 +186,12 @@ public class A2dpProfile implements LocalBluetoothProfile {
|
|||||||
if (mService == null) {
|
if (mService == null) {
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
return mService.getConnectionPolicy(device) > BluetoothProfile.CONNECTION_POLICY_FORBIDDEN;
|
return mService.getConnectionPolicy(device) > CONNECTION_POLICY_FORBIDDEN;
|
||||||
}
|
}
|
||||||
|
|
||||||
public int getPreferred(BluetoothDevice device) {
|
public int getPreferred(BluetoothDevice device) {
|
||||||
if (mService == null) {
|
if (mService == null) {
|
||||||
return BluetoothProfile.CONNECTION_POLICY_FORBIDDEN;
|
return CONNECTION_POLICY_FORBIDDEN;
|
||||||
}
|
}
|
||||||
return mService.getConnectionPolicy(device);
|
return mService.getConnectionPolicy(device);
|
||||||
}
|
}
|
||||||
@@ -197,11 +201,11 @@ public class A2dpProfile implements LocalBluetoothProfile {
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
if (preferred) {
|
if (preferred) {
|
||||||
if (mService.getConnectionPolicy(device) < BluetoothProfile.CONNECTION_POLICY_ALLOWED) {
|
if (mService.getConnectionPolicy(device) < CONNECTION_POLICY_ALLOWED) {
|
||||||
mService.setConnectionPolicy(device, BluetoothProfile.CONNECTION_POLICY_ALLOWED);
|
mService.setConnectionPolicy(device, CONNECTION_POLICY_ALLOWED);
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
mService.setConnectionPolicy(device, BluetoothProfile.CONNECTION_POLICY_FORBIDDEN);
|
mService.setConnectionPolicy(device, CONNECTION_POLICY_FORBIDDEN);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
boolean isA2dpPlaying() {
|
boolean isA2dpPlaying() {
|
||||||
|
|||||||
@@ -16,6 +16,9 @@
|
|||||||
|
|
||||||
package com.android.settingslib.bluetooth;
|
package com.android.settingslib.bluetooth;
|
||||||
|
|
||||||
|
import static android.bluetooth.BluetoothProfile.CONNECTION_POLICY_ALLOWED;
|
||||||
|
import static android.bluetooth.BluetoothProfile.CONNECTION_POLICY_FORBIDDEN;
|
||||||
|
|
||||||
import android.bluetooth.BluetoothA2dpSink;
|
import android.bluetooth.BluetoothA2dpSink;
|
||||||
import android.bluetooth.BluetoothAdapter;
|
import android.bluetooth.BluetoothAdapter;
|
||||||
import android.bluetooth.BluetoothClass;
|
import android.bluetooth.BluetoothClass;
|
||||||
@@ -116,18 +119,15 @@ final class A2dpSinkProfile implements LocalBluetoothProfile {
|
|||||||
if (mService == null) {
|
if (mService == null) {
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
return mService.connect(device);
|
return mService.setConnectionPolicy(device, CONNECTION_POLICY_ALLOWED);
|
||||||
}
|
}
|
||||||
|
|
||||||
public boolean disconnect(BluetoothDevice device) {
|
public boolean disconnect(BluetoothDevice device) {
|
||||||
if (mService == null) {
|
if (mService == null) {
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
// Downgrade priority as user is disconnecting the headset.
|
|
||||||
if (mService.getConnectionPolicy(device) > BluetoothProfile.CONNECTION_POLICY_ALLOWED) {
|
return mService.setConnectionPolicy(device, CONNECTION_POLICY_FORBIDDEN);
|
||||||
mService.setConnectionPolicy(device, BluetoothProfile.CONNECTION_POLICY_ALLOWED);
|
|
||||||
}
|
|
||||||
return mService.disconnect(device);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public int getConnectionStatus(BluetoothDevice device) {
|
public int getConnectionStatus(BluetoothDevice device) {
|
||||||
@@ -141,12 +141,12 @@ final class A2dpSinkProfile implements LocalBluetoothProfile {
|
|||||||
if (mService == null) {
|
if (mService == null) {
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
return mService.getConnectionPolicy(device) > BluetoothProfile.CONNECTION_POLICY_FORBIDDEN;
|
return mService.getConnectionPolicy(device) > CONNECTION_POLICY_FORBIDDEN;
|
||||||
}
|
}
|
||||||
|
|
||||||
public int getPreferred(BluetoothDevice device) {
|
public int getPreferred(BluetoothDevice device) {
|
||||||
if (mService == null) {
|
if (mService == null) {
|
||||||
return BluetoothProfile.CONNECTION_POLICY_FORBIDDEN;
|
return CONNECTION_POLICY_FORBIDDEN;
|
||||||
}
|
}
|
||||||
return mService.getConnectionPolicy(device);
|
return mService.getConnectionPolicy(device);
|
||||||
}
|
}
|
||||||
@@ -156,11 +156,11 @@ final class A2dpSinkProfile implements LocalBluetoothProfile {
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
if (preferred) {
|
if (preferred) {
|
||||||
if (mService.getConnectionPolicy(device) < BluetoothProfile.CONNECTION_POLICY_ALLOWED) {
|
if (mService.getConnectionPolicy(device) < CONNECTION_POLICY_ALLOWED) {
|
||||||
mService.setConnectionPolicy(device, BluetoothProfile.CONNECTION_POLICY_ALLOWED);
|
mService.setConnectionPolicy(device, CONNECTION_POLICY_ALLOWED);
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
mService.setConnectionPolicy(device, BluetoothProfile.CONNECTION_POLICY_FORBIDDEN);
|
mService.setConnectionPolicy(device, CONNECTION_POLICY_FORBIDDEN);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -16,6 +16,9 @@
|
|||||||
|
|
||||||
package com.android.settingslib.bluetooth;
|
package com.android.settingslib.bluetooth;
|
||||||
|
|
||||||
|
import static android.bluetooth.BluetoothProfile.CONNECTION_POLICY_ALLOWED;
|
||||||
|
import static android.bluetooth.BluetoothProfile.CONNECTION_POLICY_FORBIDDEN;
|
||||||
|
|
||||||
import android.bluetooth.BluetoothAdapter;
|
import android.bluetooth.BluetoothAdapter;
|
||||||
import android.bluetooth.BluetoothClass;
|
import android.bluetooth.BluetoothClass;
|
||||||
import android.bluetooth.BluetoothDevice;
|
import android.bluetooth.BluetoothDevice;
|
||||||
@@ -112,18 +115,15 @@ public class HeadsetProfile implements LocalBluetoothProfile {
|
|||||||
if (mService == null) {
|
if (mService == null) {
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
return mService.connect(device);
|
return mService.setConnectionPolicy(device, CONNECTION_POLICY_ALLOWED);
|
||||||
}
|
}
|
||||||
|
|
||||||
public boolean disconnect(BluetoothDevice device) {
|
public boolean disconnect(BluetoothDevice device) {
|
||||||
if (mService == null) {
|
if (mService == null) {
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
// Downgrade priority as user is disconnecting the headset.
|
|
||||||
if (mService.getConnectionPolicy(device) > BluetoothProfile.CONNECTION_POLICY_ALLOWED) {
|
return mService.setConnectionPolicy(device, CONNECTION_POLICY_FORBIDDEN);
|
||||||
mService.setConnectionPolicy(device, BluetoothProfile.CONNECTION_POLICY_ALLOWED);
|
|
||||||
}
|
|
||||||
return mService.disconnect(device);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public int getConnectionStatus(BluetoothDevice device) {
|
public int getConnectionStatus(BluetoothDevice device) {
|
||||||
@@ -165,12 +165,12 @@ public class HeadsetProfile implements LocalBluetoothProfile {
|
|||||||
if (mService == null) {
|
if (mService == null) {
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
return mService.getConnectionPolicy(device) > BluetoothProfile.CONNECTION_POLICY_FORBIDDEN;
|
return mService.getConnectionPolicy(device) > CONNECTION_POLICY_FORBIDDEN;
|
||||||
}
|
}
|
||||||
|
|
||||||
public int getPreferred(BluetoothDevice device) {
|
public int getPreferred(BluetoothDevice device) {
|
||||||
if (mService == null) {
|
if (mService == null) {
|
||||||
return BluetoothProfile.CONNECTION_POLICY_FORBIDDEN;
|
return CONNECTION_POLICY_FORBIDDEN;
|
||||||
}
|
}
|
||||||
return mService.getConnectionPolicy(device);
|
return mService.getConnectionPolicy(device);
|
||||||
}
|
}
|
||||||
@@ -180,11 +180,11 @@ public class HeadsetProfile implements LocalBluetoothProfile {
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
if (preferred) {
|
if (preferred) {
|
||||||
if (mService.getConnectionPolicy(device) < BluetoothProfile.CONNECTION_POLICY_ALLOWED) {
|
if (mService.getConnectionPolicy(device) < CONNECTION_POLICY_ALLOWED) {
|
||||||
mService.setConnectionPolicy(device, BluetoothProfile.CONNECTION_POLICY_ALLOWED);
|
mService.setConnectionPolicy(device, CONNECTION_POLICY_ALLOWED);
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
mService.setConnectionPolicy(device, BluetoothProfile.CONNECTION_POLICY_FORBIDDEN);
|
mService.setConnectionPolicy(device, CONNECTION_POLICY_FORBIDDEN);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -16,6 +16,9 @@
|
|||||||
|
|
||||||
package com.android.settingslib.bluetooth;
|
package com.android.settingslib.bluetooth;
|
||||||
|
|
||||||
|
import static android.bluetooth.BluetoothProfile.CONNECTION_POLICY_ALLOWED;
|
||||||
|
import static android.bluetooth.BluetoothProfile.CONNECTION_POLICY_FORBIDDEN;
|
||||||
|
|
||||||
import android.bluetooth.BluetoothAdapter;
|
import android.bluetooth.BluetoothAdapter;
|
||||||
import android.bluetooth.BluetoothClass;
|
import android.bluetooth.BluetoothClass;
|
||||||
import android.bluetooth.BluetoothDevice;
|
import android.bluetooth.BluetoothDevice;
|
||||||
@@ -146,17 +149,18 @@ public class HearingAidProfile implements LocalBluetoothProfile {
|
|||||||
}
|
}
|
||||||
|
|
||||||
public boolean connect(BluetoothDevice device) {
|
public boolean connect(BluetoothDevice device) {
|
||||||
if (mService == null) return false;
|
if (mService == null) {
|
||||||
return mService.connect(device);
|
return false;
|
||||||
|
}
|
||||||
|
return mService.setConnectionPolicy(device, CONNECTION_POLICY_ALLOWED);
|
||||||
}
|
}
|
||||||
|
|
||||||
public boolean disconnect(BluetoothDevice device) {
|
public boolean disconnect(BluetoothDevice device) {
|
||||||
if (mService == null) return false;
|
if (mService == null) {
|
||||||
// Downgrade priority as user is disconnecting the hearing aid.
|
return false;
|
||||||
if (mService.getConnectionPolicy(device) > BluetoothProfile.CONNECTION_POLICY_ALLOWED) {
|
|
||||||
mService.setConnectionPolicy(device, BluetoothProfile.CONNECTION_POLICY_ALLOWED);
|
|
||||||
}
|
}
|
||||||
return mService.disconnect(device);
|
|
||||||
|
return mService.setConnectionPolicy(device, CONNECTION_POLICY_FORBIDDEN);
|
||||||
}
|
}
|
||||||
|
|
||||||
public int getConnectionStatus(BluetoothDevice device) {
|
public int getConnectionStatus(BluetoothDevice device) {
|
||||||
@@ -180,12 +184,12 @@ public class HearingAidProfile implements LocalBluetoothProfile {
|
|||||||
if (mService == null) {
|
if (mService == null) {
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
return mService.getConnectionPolicy(device) > BluetoothProfile.CONNECTION_POLICY_FORBIDDEN;
|
return mService.getConnectionPolicy(device) > CONNECTION_POLICY_FORBIDDEN;
|
||||||
}
|
}
|
||||||
|
|
||||||
public int getPreferred(BluetoothDevice device) {
|
public int getPreferred(BluetoothDevice device) {
|
||||||
if (mService == null) {
|
if (mService == null) {
|
||||||
return BluetoothProfile.CONNECTION_POLICY_FORBIDDEN;
|
return CONNECTION_POLICY_FORBIDDEN;
|
||||||
}
|
}
|
||||||
return mService.getConnectionPolicy(device);
|
return mService.getConnectionPolicy(device);
|
||||||
}
|
}
|
||||||
@@ -195,11 +199,11 @@ public class HearingAidProfile implements LocalBluetoothProfile {
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
if (preferred) {
|
if (preferred) {
|
||||||
if (mService.getConnectionPolicy(device) < BluetoothProfile.CONNECTION_POLICY_ALLOWED) {
|
if (mService.getConnectionPolicy(device) < CONNECTION_POLICY_ALLOWED) {
|
||||||
mService.setConnectionPolicy(device, BluetoothProfile.CONNECTION_POLICY_ALLOWED);
|
mService.setConnectionPolicy(device, CONNECTION_POLICY_ALLOWED);
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
mService.setConnectionPolicy(device, BluetoothProfile.CONNECTION_POLICY_FORBIDDEN);
|
mService.setConnectionPolicy(device, CONNECTION_POLICY_FORBIDDEN);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -16,6 +16,9 @@
|
|||||||
|
|
||||||
package com.android.settingslib.bluetooth;
|
package com.android.settingslib.bluetooth;
|
||||||
|
|
||||||
|
import static android.bluetooth.BluetoothProfile.CONNECTION_POLICY_ALLOWED;
|
||||||
|
import static android.bluetooth.BluetoothProfile.CONNECTION_POLICY_FORBIDDEN;
|
||||||
|
|
||||||
import android.bluetooth.BluetoothAdapter;
|
import android.bluetooth.BluetoothAdapter;
|
||||||
import android.bluetooth.BluetoothClass;
|
import android.bluetooth.BluetoothClass;
|
||||||
import android.bluetooth.BluetoothDevice;
|
import android.bluetooth.BluetoothDevice;
|
||||||
@@ -126,7 +129,7 @@ final class HfpClientProfile implements LocalBluetoothProfile {
|
|||||||
if (mService == null) {
|
if (mService == null) {
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
return mService.connect(device);
|
return mService.setConnectionPolicy(device, CONNECTION_POLICY_ALLOWED);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
@@ -134,11 +137,8 @@ final class HfpClientProfile implements LocalBluetoothProfile {
|
|||||||
if (mService == null) {
|
if (mService == null) {
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
// Downgrade priority as user is disconnecting the headset.
|
|
||||||
if (mService.getConnectionPolicy(device) > BluetoothProfile.CONNECTION_POLICY_ALLOWED) {
|
return mService.setConnectionPolicy(device, CONNECTION_POLICY_FORBIDDEN);
|
||||||
mService.setConnectionPolicy(device, BluetoothProfile.CONNECTION_POLICY_ALLOWED);
|
|
||||||
}
|
|
||||||
return mService.disconnect(device);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
@@ -154,13 +154,13 @@ final class HfpClientProfile implements LocalBluetoothProfile {
|
|||||||
if (mService == null) {
|
if (mService == null) {
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
return mService.getConnectionPolicy(device) > BluetoothProfile.CONNECTION_POLICY_FORBIDDEN;
|
return mService.getConnectionPolicy(device) > CONNECTION_POLICY_FORBIDDEN;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public int getPreferred(BluetoothDevice device) {
|
public int getPreferred(BluetoothDevice device) {
|
||||||
if (mService == null) {
|
if (mService == null) {
|
||||||
return BluetoothProfile.CONNECTION_POLICY_FORBIDDEN;
|
return CONNECTION_POLICY_FORBIDDEN;
|
||||||
}
|
}
|
||||||
return mService.getConnectionPolicy(device);
|
return mService.getConnectionPolicy(device);
|
||||||
}
|
}
|
||||||
@@ -171,11 +171,11 @@ final class HfpClientProfile implements LocalBluetoothProfile {
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
if (preferred) {
|
if (preferred) {
|
||||||
if (mService.getConnectionPolicy(device) < BluetoothProfile.CONNECTION_POLICY_ALLOWED) {
|
if (mService.getConnectionPolicy(device) < CONNECTION_POLICY_ALLOWED) {
|
||||||
mService.setConnectionPolicy(device, BluetoothProfile.CONNECTION_POLICY_ALLOWED);
|
mService.setConnectionPolicy(device, CONNECTION_POLICY_ALLOWED);
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
mService.setConnectionPolicy(device, BluetoothProfile.CONNECTION_POLICY_FORBIDDEN);
|
mService.setConnectionPolicy(device, CONNECTION_POLICY_FORBIDDEN);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -16,6 +16,9 @@
|
|||||||
|
|
||||||
package com.android.settingslib.bluetooth;
|
package com.android.settingslib.bluetooth;
|
||||||
|
|
||||||
|
import static android.bluetooth.BluetoothProfile.CONNECTION_POLICY_ALLOWED;
|
||||||
|
import static android.bluetooth.BluetoothProfile.CONNECTION_POLICY_FORBIDDEN;
|
||||||
|
|
||||||
import android.bluetooth.BluetoothAdapter;
|
import android.bluetooth.BluetoothAdapter;
|
||||||
import android.bluetooth.BluetoothClass;
|
import android.bluetooth.BluetoothClass;
|
||||||
import android.bluetooth.BluetoothDevice;
|
import android.bluetooth.BluetoothDevice;
|
||||||
@@ -99,13 +102,17 @@ public class HidProfile implements LocalBluetoothProfile {
|
|||||||
}
|
}
|
||||||
|
|
||||||
public boolean connect(BluetoothDevice device) {
|
public boolean connect(BluetoothDevice device) {
|
||||||
if (mService == null) return false;
|
if (mService == null) {
|
||||||
return mService.connect(device);
|
return false;
|
||||||
|
}
|
||||||
|
return mService.setConnectionPolicy(device, CONNECTION_POLICY_ALLOWED);
|
||||||
}
|
}
|
||||||
|
|
||||||
public boolean disconnect(BluetoothDevice device) {
|
public boolean disconnect(BluetoothDevice device) {
|
||||||
if (mService == null) return false;
|
if (mService == null) {
|
||||||
return mService.disconnect(device);
|
return false;
|
||||||
|
}
|
||||||
|
return mService.setConnectionPolicy(device, CONNECTION_POLICY_FORBIDDEN);
|
||||||
}
|
}
|
||||||
|
|
||||||
public int getConnectionStatus(BluetoothDevice device) {
|
public int getConnectionStatus(BluetoothDevice device) {
|
||||||
@@ -119,12 +126,12 @@ public class HidProfile implements LocalBluetoothProfile {
|
|||||||
if (mService == null) {
|
if (mService == null) {
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
return mService.getConnectionPolicy(device) != BluetoothProfile.CONNECTION_POLICY_FORBIDDEN;
|
return mService.getConnectionPolicy(device) != CONNECTION_POLICY_FORBIDDEN;
|
||||||
}
|
}
|
||||||
|
|
||||||
public int getPreferred(BluetoothDevice device) {
|
public int getPreferred(BluetoothDevice device) {
|
||||||
if (mService == null) {
|
if (mService == null) {
|
||||||
return BluetoothProfile.CONNECTION_POLICY_FORBIDDEN;
|
return CONNECTION_POLICY_FORBIDDEN;
|
||||||
}
|
}
|
||||||
return mService.getConnectionPolicy(device);
|
return mService.getConnectionPolicy(device);
|
||||||
}
|
}
|
||||||
@@ -132,11 +139,11 @@ public class HidProfile implements LocalBluetoothProfile {
|
|||||||
public void setPreferred(BluetoothDevice device, boolean preferred) {
|
public void setPreferred(BluetoothDevice device, boolean preferred) {
|
||||||
if (mService == null) return;
|
if (mService == null) return;
|
||||||
if (preferred) {
|
if (preferred) {
|
||||||
if (mService.getConnectionPolicy(device) < BluetoothProfile.CONNECTION_POLICY_ALLOWED) {
|
if (mService.getConnectionPolicy(device) < CONNECTION_POLICY_ALLOWED) {
|
||||||
mService.setConnectionPolicy(device, BluetoothProfile.CONNECTION_POLICY_ALLOWED);
|
mService.setConnectionPolicy(device, CONNECTION_POLICY_ALLOWED);
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
mService.setConnectionPolicy(device, BluetoothProfile.CONNECTION_POLICY_FORBIDDEN);
|
mService.setConnectionPolicy(device, CONNECTION_POLICY_FORBIDDEN);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -16,6 +16,9 @@
|
|||||||
|
|
||||||
package com.android.settingslib.bluetooth;
|
package com.android.settingslib.bluetooth;
|
||||||
|
|
||||||
|
import static android.bluetooth.BluetoothProfile.CONNECTION_POLICY_ALLOWED;
|
||||||
|
import static android.bluetooth.BluetoothProfile.CONNECTION_POLICY_FORBIDDEN;
|
||||||
|
|
||||||
import android.bluetooth.BluetoothAdapter;
|
import android.bluetooth.BluetoothAdapter;
|
||||||
import android.bluetooth.BluetoothClass;
|
import android.bluetooth.BluetoothClass;
|
||||||
import android.bluetooth.BluetoothDevice;
|
import android.bluetooth.BluetoothDevice;
|
||||||
@@ -115,18 +118,15 @@ public final class MapClientProfile implements LocalBluetoothProfile {
|
|||||||
if (mService == null) {
|
if (mService == null) {
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
return mService.connect(device);
|
return mService.setConnectionPolicy(device, CONNECTION_POLICY_ALLOWED);
|
||||||
}
|
}
|
||||||
|
|
||||||
public boolean disconnect(BluetoothDevice device) {
|
public boolean disconnect(BluetoothDevice device) {
|
||||||
if (mService == null) {
|
if (mService == null) {
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
// Downgrade priority as user is disconnecting.
|
|
||||||
if (mService.getConnectionPolicy(device) > BluetoothProfile.CONNECTION_POLICY_ALLOWED) {
|
return mService.setConnectionPolicy(device, CONNECTION_POLICY_FORBIDDEN);
|
||||||
mService.setConnectionPolicy(device, BluetoothProfile.CONNECTION_POLICY_ALLOWED);
|
|
||||||
}
|
|
||||||
return mService.disconnect(device);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public int getConnectionStatus(BluetoothDevice device) {
|
public int getConnectionStatus(BluetoothDevice device) {
|
||||||
@@ -140,12 +140,12 @@ public final class MapClientProfile implements LocalBluetoothProfile {
|
|||||||
if (mService == null) {
|
if (mService == null) {
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
return mService.getConnectionPolicy(device) > BluetoothProfile.CONNECTION_POLICY_FORBIDDEN;
|
return mService.getConnectionPolicy(device) > CONNECTION_POLICY_FORBIDDEN;
|
||||||
}
|
}
|
||||||
|
|
||||||
public int getPreferred(BluetoothDevice device) {
|
public int getPreferred(BluetoothDevice device) {
|
||||||
if (mService == null) {
|
if (mService == null) {
|
||||||
return BluetoothProfile.CONNECTION_POLICY_FORBIDDEN;
|
return CONNECTION_POLICY_FORBIDDEN;
|
||||||
}
|
}
|
||||||
return mService.getConnectionPolicy(device);
|
return mService.getConnectionPolicy(device);
|
||||||
}
|
}
|
||||||
@@ -155,11 +155,11 @@ public final class MapClientProfile implements LocalBluetoothProfile {
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
if (preferred) {
|
if (preferred) {
|
||||||
if (mService.getConnectionPolicy(device) < BluetoothProfile.CONNECTION_POLICY_ALLOWED) {
|
if (mService.getConnectionPolicy(device) < CONNECTION_POLICY_ALLOWED) {
|
||||||
mService.setConnectionPolicy(device, BluetoothProfile.CONNECTION_POLICY_ALLOWED);
|
mService.setConnectionPolicy(device, CONNECTION_POLICY_ALLOWED);
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
mService.setConnectionPolicy(device, BluetoothProfile.CONNECTION_POLICY_FORBIDDEN);
|
mService.setConnectionPolicy(device, CONNECTION_POLICY_FORBIDDEN);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -16,6 +16,8 @@
|
|||||||
|
|
||||||
package com.android.settingslib.bluetooth;
|
package com.android.settingslib.bluetooth;
|
||||||
|
|
||||||
|
import static android.bluetooth.BluetoothProfile.CONNECTION_POLICY_FORBIDDEN;
|
||||||
|
|
||||||
import android.bluetooth.BluetoothAdapter;
|
import android.bluetooth.BluetoothAdapter;
|
||||||
import android.bluetooth.BluetoothClass;
|
import android.bluetooth.BluetoothClass;
|
||||||
import android.bluetooth.BluetoothDevice;
|
import android.bluetooth.BluetoothDevice;
|
||||||
@@ -119,10 +121,8 @@ public class MapProfile implements LocalBluetoothProfile {
|
|||||||
if (mService == null) {
|
if (mService == null) {
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
if (mService.getConnectionPolicy(device) > BluetoothProfile.CONNECTION_POLICY_ALLOWED) {
|
|
||||||
mService.setConnectionPolicy(device, BluetoothProfile.CONNECTION_POLICY_ALLOWED);
|
return mService.setConnectionPolicy(device, CONNECTION_POLICY_FORBIDDEN);
|
||||||
}
|
|
||||||
return mService.disconnect(device);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public int getConnectionStatus(BluetoothDevice device) {
|
public int getConnectionStatus(BluetoothDevice device) {
|
||||||
@@ -136,12 +136,12 @@ public class MapProfile implements LocalBluetoothProfile {
|
|||||||
if (mService == null) {
|
if (mService == null) {
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
return mService.getConnectionPolicy(device) > BluetoothProfile.CONNECTION_POLICY_FORBIDDEN;
|
return mService.getConnectionPolicy(device) > CONNECTION_POLICY_FORBIDDEN;
|
||||||
}
|
}
|
||||||
|
|
||||||
public int getPreferred(BluetoothDevice device) {
|
public int getPreferred(BluetoothDevice device) {
|
||||||
if (mService == null) {
|
if (mService == null) {
|
||||||
return BluetoothProfile.CONNECTION_POLICY_FORBIDDEN;
|
return CONNECTION_POLICY_FORBIDDEN;
|
||||||
}
|
}
|
||||||
return mService.getConnectionPolicy(device);
|
return mService.getConnectionPolicy(device);
|
||||||
}
|
}
|
||||||
@@ -155,7 +155,7 @@ public class MapProfile implements LocalBluetoothProfile {
|
|||||||
mService.setConnectionPolicy(device, BluetoothProfile.CONNECTION_POLICY_ALLOWED);
|
mService.setConnectionPolicy(device, BluetoothProfile.CONNECTION_POLICY_ALLOWED);
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
mService.setConnectionPolicy(device, BluetoothProfile.CONNECTION_POLICY_FORBIDDEN);
|
mService.setConnectionPolicy(device, CONNECTION_POLICY_FORBIDDEN);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -16,6 +16,9 @@
|
|||||||
|
|
||||||
package com.android.settingslib.bluetooth;
|
package com.android.settingslib.bluetooth;
|
||||||
|
|
||||||
|
import static android.bluetooth.BluetoothProfile.CONNECTION_POLICY_ALLOWED;
|
||||||
|
import static android.bluetooth.BluetoothProfile.CONNECTION_POLICY_FORBIDDEN;
|
||||||
|
|
||||||
import android.bluetooth.BluetoothAdapter;
|
import android.bluetooth.BluetoothAdapter;
|
||||||
import android.bluetooth.BluetoothClass;
|
import android.bluetooth.BluetoothClass;
|
||||||
import android.bluetooth.BluetoothDevice;
|
import android.bluetooth.BluetoothDevice;
|
||||||
@@ -129,7 +132,7 @@ public final class PbapClientProfile implements LocalBluetoothProfile {
|
|||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
Log.d(TAG,"PBAPClientProfile attempting to connect to " + device.getAddress());
|
Log.d(TAG,"PBAPClientProfile attempting to connect to " + device.getAddress());
|
||||||
return mService.connect(device);
|
return mService.setConnectionPolicy(device, CONNECTION_POLICY_ALLOWED);
|
||||||
}
|
}
|
||||||
|
|
||||||
public boolean disconnect(BluetoothDevice device) {
|
public boolean disconnect(BluetoothDevice device) {
|
||||||
@@ -137,7 +140,7 @@ public final class PbapClientProfile implements LocalBluetoothProfile {
|
|||||||
if (mService == null) {
|
if (mService == null) {
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
return mService.disconnect(device);
|
return mService.setConnectionPolicy(device, CONNECTION_POLICY_FORBIDDEN);
|
||||||
}
|
}
|
||||||
|
|
||||||
public int getConnectionStatus(BluetoothDevice device) {
|
public int getConnectionStatus(BluetoothDevice device) {
|
||||||
@@ -151,12 +154,12 @@ public final class PbapClientProfile implements LocalBluetoothProfile {
|
|||||||
if (mService == null) {
|
if (mService == null) {
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
return mService.getConnectionPolicy(device) > BluetoothProfile.CONNECTION_POLICY_FORBIDDEN;
|
return mService.getConnectionPolicy(device) > CONNECTION_POLICY_FORBIDDEN;
|
||||||
}
|
}
|
||||||
|
|
||||||
public int getPreferred(BluetoothDevice device) {
|
public int getPreferred(BluetoothDevice device) {
|
||||||
if (mService == null) {
|
if (mService == null) {
|
||||||
return BluetoothProfile.CONNECTION_POLICY_FORBIDDEN;
|
return CONNECTION_POLICY_FORBIDDEN;
|
||||||
}
|
}
|
||||||
return mService.getConnectionPolicy(device);
|
return mService.getConnectionPolicy(device);
|
||||||
}
|
}
|
||||||
@@ -166,11 +169,11 @@ public final class PbapClientProfile implements LocalBluetoothProfile {
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
if (preferred) {
|
if (preferred) {
|
||||||
if (mService.getConnectionPolicy(device) < BluetoothProfile.CONNECTION_POLICY_ALLOWED) {
|
if (mService.getConnectionPolicy(device) < CONNECTION_POLICY_ALLOWED) {
|
||||||
mService.setConnectionPolicy(device, BluetoothProfile.CONNECTION_POLICY_ALLOWED);
|
mService.setConnectionPolicy(device, CONNECTION_POLICY_ALLOWED);
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
mService.setConnectionPolicy(device, BluetoothProfile.CONNECTION_POLICY_FORBIDDEN);
|
mService.setConnectionPolicy(device, CONNECTION_POLICY_FORBIDDEN);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -16,6 +16,8 @@
|
|||||||
|
|
||||||
package com.android.settingslib.bluetooth;
|
package com.android.settingslib.bluetooth;
|
||||||
|
|
||||||
|
import static android.bluetooth.BluetoothProfile.CONNECTION_POLICY_FORBIDDEN;
|
||||||
|
|
||||||
import android.bluetooth.BluetoothAdapter;
|
import android.bluetooth.BluetoothAdapter;
|
||||||
import android.bluetooth.BluetoothClass;
|
import android.bluetooth.BluetoothClass;
|
||||||
import android.bluetooth.BluetoothDevice;
|
import android.bluetooth.BluetoothDevice;
|
||||||
@@ -96,8 +98,10 @@ public class PbapServerProfile implements LocalBluetoothProfile {
|
|||||||
}
|
}
|
||||||
|
|
||||||
public boolean disconnect(BluetoothDevice device) {
|
public boolean disconnect(BluetoothDevice device) {
|
||||||
if (mService == null) return false;
|
if (mService == null) {
|
||||||
return mService.disconnect(device);
|
return false;
|
||||||
|
}
|
||||||
|
return mService.setConnectionPolicy(device, CONNECTION_POLICY_FORBIDDEN);
|
||||||
}
|
}
|
||||||
|
|
||||||
public int getConnectionStatus(BluetoothDevice device) {
|
public int getConnectionStatus(BluetoothDevice device) {
|
||||||
|
|||||||
@@ -16,6 +16,9 @@
|
|||||||
|
|
||||||
package com.android.settingslib.bluetooth;
|
package com.android.settingslib.bluetooth;
|
||||||
|
|
||||||
|
import static android.bluetooth.BluetoothProfile.CONNECTION_POLICY_ALLOWED;
|
||||||
|
import static android.bluetooth.BluetoothProfile.CONNECTION_POLICY_FORBIDDEN;
|
||||||
|
|
||||||
import android.bluetooth.BluetoothAdapter;
|
import android.bluetooth.BluetoothAdapter;
|
||||||
import android.bluetooth.BluetoothClass;
|
import android.bluetooth.BluetoothClass;
|
||||||
import android.bluetooth.BluetoothDevice;
|
import android.bluetooth.BluetoothDevice;
|
||||||
@@ -112,17 +115,15 @@ final class SapProfile implements LocalBluetoothProfile {
|
|||||||
if (mService == null) {
|
if (mService == null) {
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
return mService.connect(device);
|
return mService.setConnectionPolicy(device, CONNECTION_POLICY_ALLOWED);
|
||||||
}
|
}
|
||||||
|
|
||||||
public boolean disconnect(BluetoothDevice device) {
|
public boolean disconnect(BluetoothDevice device) {
|
||||||
if (mService == null) {
|
if (mService == null) {
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
if (mService.getConnectionPolicy(device) > BluetoothProfile.CONNECTION_POLICY_ALLOWED) {
|
|
||||||
mService.setConnectionPolicy(device, BluetoothProfile.CONNECTION_POLICY_ALLOWED);
|
return mService.setConnectionPolicy(device, CONNECTION_POLICY_FORBIDDEN);
|
||||||
}
|
|
||||||
return mService.disconnect(device);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public int getConnectionStatus(BluetoothDevice device) {
|
public int getConnectionStatus(BluetoothDevice device) {
|
||||||
@@ -136,12 +137,12 @@ final class SapProfile implements LocalBluetoothProfile {
|
|||||||
if (mService == null) {
|
if (mService == null) {
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
return mService.getConnectionPolicy(device) > BluetoothProfile.CONNECTION_POLICY_FORBIDDEN;
|
return mService.getConnectionPolicy(device) > CONNECTION_POLICY_FORBIDDEN;
|
||||||
}
|
}
|
||||||
|
|
||||||
public int getPreferred(BluetoothDevice device) {
|
public int getPreferred(BluetoothDevice device) {
|
||||||
if (mService == null) {
|
if (mService == null) {
|
||||||
return BluetoothProfile.CONNECTION_POLICY_FORBIDDEN;
|
return CONNECTION_POLICY_FORBIDDEN;
|
||||||
}
|
}
|
||||||
return mService.getConnectionPolicy(device);
|
return mService.getConnectionPolicy(device);
|
||||||
}
|
}
|
||||||
@@ -151,11 +152,11 @@ final class SapProfile implements LocalBluetoothProfile {
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
if (preferred) {
|
if (preferred) {
|
||||||
if (mService.getConnectionPolicy(device) < BluetoothProfile.CONNECTION_POLICY_ALLOWED) {
|
if (mService.getConnectionPolicy(device) < CONNECTION_POLICY_ALLOWED) {
|
||||||
mService.setConnectionPolicy(device, BluetoothProfile.CONNECTION_POLICY_ALLOWED);
|
mService.setConnectionPolicy(device, CONNECTION_POLICY_ALLOWED);
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
mService.setConnectionPolicy(device, BluetoothProfile.CONNECTION_POLICY_FORBIDDEN);
|
mService.setConnectionPolicy(device, CONNECTION_POLICY_FORBIDDEN);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -16,6 +16,9 @@
|
|||||||
|
|
||||||
package com.android.settingslib.bluetooth;
|
package com.android.settingslib.bluetooth;
|
||||||
|
|
||||||
|
import static android.bluetooth.BluetoothProfile.CONNECTION_POLICY_ALLOWED;
|
||||||
|
import static android.bluetooth.BluetoothProfile.CONNECTION_POLICY_FORBIDDEN;
|
||||||
|
|
||||||
import static com.google.common.truth.Truth.assertThat;
|
import static com.google.common.truth.Truth.assertThat;
|
||||||
|
|
||||||
import static org.mockito.Mockito.verify;
|
import static org.mockito.Mockito.verify;
|
||||||
@@ -67,13 +70,13 @@ public class A2dpSinkProfileTest {
|
|||||||
@Test
|
@Test
|
||||||
public void connect_shouldConnectBluetoothA2dpSink() {
|
public void connect_shouldConnectBluetoothA2dpSink() {
|
||||||
mProfile.connect(mBluetoothDevice);
|
mProfile.connect(mBluetoothDevice);
|
||||||
verify(mService).connect(mBluetoothDevice);
|
verify(mService).setConnectionPolicy(mBluetoothDevice, CONNECTION_POLICY_ALLOWED);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void disconnect_shouldDisconnectBluetoothA2dpSink() {
|
public void disconnect_shouldDisconnectBluetoothA2dpSink() {
|
||||||
mProfile.disconnect(mBluetoothDevice);
|
mProfile.disconnect(mBluetoothDevice);
|
||||||
verify(mService).disconnect(mBluetoothDevice);
|
verify(mService).setConnectionPolicy(mBluetoothDevice, CONNECTION_POLICY_FORBIDDEN);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
|
|||||||
@@ -16,6 +16,9 @@
|
|||||||
|
|
||||||
package com.android.settingslib.bluetooth;
|
package com.android.settingslib.bluetooth;
|
||||||
|
|
||||||
|
import static android.bluetooth.BluetoothProfile.CONNECTION_POLICY_ALLOWED;
|
||||||
|
import static android.bluetooth.BluetoothProfile.CONNECTION_POLICY_FORBIDDEN;
|
||||||
|
|
||||||
import static com.google.common.truth.Truth.assertThat;
|
import static com.google.common.truth.Truth.assertThat;
|
||||||
|
|
||||||
import static org.mockito.Mockito.verify;
|
import static org.mockito.Mockito.verify;
|
||||||
@@ -67,13 +70,13 @@ public class HfpClientProfileTest {
|
|||||||
@Test
|
@Test
|
||||||
public void connect_shouldConnectBluetoothHeadsetClient() {
|
public void connect_shouldConnectBluetoothHeadsetClient() {
|
||||||
mProfile.connect(mBluetoothDevice);
|
mProfile.connect(mBluetoothDevice);
|
||||||
verify(mService).connect(mBluetoothDevice);
|
verify(mService).setConnectionPolicy(mBluetoothDevice, CONNECTION_POLICY_ALLOWED);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void disconnect_shouldDisconnectBluetoothHeadsetClient() {
|
public void disconnect_shouldDisconnectBluetoothHeadsetClient() {
|
||||||
mProfile.disconnect(mBluetoothDevice);
|
mProfile.disconnect(mBluetoothDevice);
|
||||||
verify(mService).disconnect(mBluetoothDevice);
|
verify(mService).setConnectionPolicy(mBluetoothDevice, CONNECTION_POLICY_FORBIDDEN);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
|
|||||||
@@ -16,6 +16,9 @@
|
|||||||
|
|
||||||
package com.android.settingslib.bluetooth;
|
package com.android.settingslib.bluetooth;
|
||||||
|
|
||||||
|
import static android.bluetooth.BluetoothProfile.CONNECTION_POLICY_ALLOWED;
|
||||||
|
import static android.bluetooth.BluetoothProfile.CONNECTION_POLICY_FORBIDDEN;
|
||||||
|
|
||||||
import static com.google.common.truth.Truth.assertThat;
|
import static com.google.common.truth.Truth.assertThat;
|
||||||
|
|
||||||
import static org.mockito.Mockito.verify;
|
import static org.mockito.Mockito.verify;
|
||||||
@@ -67,13 +70,13 @@ public class MapClientProfileTest {
|
|||||||
@Test
|
@Test
|
||||||
public void connect_shouldConnectBluetoothMapClient() {
|
public void connect_shouldConnectBluetoothMapClient() {
|
||||||
mProfile.connect(mBluetoothDevice);
|
mProfile.connect(mBluetoothDevice);
|
||||||
verify(mService).connect(mBluetoothDevice);
|
verify(mService).setConnectionPolicy(mBluetoothDevice, CONNECTION_POLICY_ALLOWED);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void disconnect_shouldDisconnectBluetoothMapClient() {
|
public void disconnect_shouldDisconnectBluetoothMapClient() {
|
||||||
mProfile.disconnect(mBluetoothDevice);
|
mProfile.disconnect(mBluetoothDevice);
|
||||||
verify(mService).disconnect(mBluetoothDevice);
|
verify(mService).setConnectionPolicy(mBluetoothDevice, CONNECTION_POLICY_FORBIDDEN);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
|
|||||||
@@ -16,6 +16,9 @@
|
|||||||
|
|
||||||
package com.android.settingslib.bluetooth;
|
package com.android.settingslib.bluetooth;
|
||||||
|
|
||||||
|
import static android.bluetooth.BluetoothProfile.CONNECTION_POLICY_ALLOWED;
|
||||||
|
import static android.bluetooth.BluetoothProfile.CONNECTION_POLICY_FORBIDDEN;
|
||||||
|
|
||||||
import static com.google.common.truth.Truth.assertThat;
|
import static com.google.common.truth.Truth.assertThat;
|
||||||
|
|
||||||
import static org.mockito.Mockito.verify;
|
import static org.mockito.Mockito.verify;
|
||||||
@@ -67,13 +70,13 @@ public class PbapClientProfileTest {
|
|||||||
@Test
|
@Test
|
||||||
public void connect_shouldConnectBluetoothPbapClient() {
|
public void connect_shouldConnectBluetoothPbapClient() {
|
||||||
mProfile.connect(mBluetoothDevice);
|
mProfile.connect(mBluetoothDevice);
|
||||||
verify(mService).connect(mBluetoothDevice);
|
verify(mService).setConnectionPolicy(mBluetoothDevice, CONNECTION_POLICY_ALLOWED);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void disconnect_shouldDisconnectBluetoothPbapClient() {
|
public void disconnect_shouldDisconnectBluetoothPbapClient() {
|
||||||
mProfile.disconnect(mBluetoothDevice);
|
mProfile.disconnect(mBluetoothDevice);
|
||||||
verify(mService).disconnect(mBluetoothDevice);
|
verify(mService).setConnectionPolicy(mBluetoothDevice, CONNECTION_POLICY_FORBIDDEN);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
|
|||||||
@@ -16,6 +16,9 @@
|
|||||||
|
|
||||||
package com.android.settingslib.bluetooth;
|
package com.android.settingslib.bluetooth;
|
||||||
|
|
||||||
|
import static android.bluetooth.BluetoothProfile.CONNECTION_POLICY_ALLOWED;
|
||||||
|
import static android.bluetooth.BluetoothProfile.CONNECTION_POLICY_FORBIDDEN;
|
||||||
|
|
||||||
import static com.google.common.truth.Truth.assertThat;
|
import static com.google.common.truth.Truth.assertThat;
|
||||||
|
|
||||||
import static org.mockito.Mockito.verify;
|
import static org.mockito.Mockito.verify;
|
||||||
@@ -66,13 +69,13 @@ public class SapProfileTest {
|
|||||||
@Test
|
@Test
|
||||||
public void connect_shouldConnectBluetoothSap() {
|
public void connect_shouldConnectBluetoothSap() {
|
||||||
mProfile.connect(mBluetoothDevice);
|
mProfile.connect(mBluetoothDevice);
|
||||||
verify(mService).connect(mBluetoothDevice);
|
verify(mService).setConnectionPolicy(mBluetoothDevice, CONNECTION_POLICY_ALLOWED);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void disconnect_shouldDisconnectBluetoothSap() {
|
public void disconnect_shouldDisconnectBluetoothSap() {
|
||||||
mProfile.disconnect(mBluetoothDevice);
|
mProfile.disconnect(mBluetoothDevice);
|
||||||
verify(mService).disconnect(mBluetoothDevice);
|
verify(mService).setConnectionPolicy(mBluetoothDevice, CONNECTION_POLICY_FORBIDDEN);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
|
|||||||
Reference in New Issue
Block a user