summaryrefslogtreecommitdiffstats
path: root/core/java/android/server/BluetoothA2dpService.java
diff options
context:
space:
mode:
authorZhu Lan <mtcb47@motorola.com>2009-06-24 10:51:57 +0800
committerNick Pelly <npelly@google.com>2009-09-29 20:50:02 -0700
commitf9bbe1e71a502fe7bd1f4a23ba5bbe4dde0d9d57 (patch)
tree977b54b1b64af47b68c1121a5085fa8356350209 /core/java/android/server/BluetoothA2dpService.java
parent4c232c5b3f7fcbea73cd3cec2d3befe06e85c068 (diff)
downloadframeworks_base-f9bbe1e71a502fe7bd1f4a23ba5bbe4dde0d9d57.zip
frameworks_base-f9bbe1e71a502fe7bd1f4a23ba5bbe4dde0d9d57.tar.gz
frameworks_base-f9bbe1e71a502fe7bd1f4a23ba5bbe4dde0d9d57.tar.bz2
Bluetooth A2DP suspend/resume functionality
Change-Id: I8366852fa9b6ff9dacf18db00ea1c2be0c00ff34
Diffstat (limited to 'core/java/android/server/BluetoothA2dpService.java')
-rw-r--r--core/java/android/server/BluetoothA2dpService.java44
1 files changed, 44 insertions, 0 deletions
diff --git a/core/java/android/server/BluetoothA2dpService.java b/core/java/android/server/BluetoothA2dpService.java
index 0fc2e7e..4a5f431 100644
--- a/core/java/android/server/BluetoothA2dpService.java
+++ b/core/java/android/server/BluetoothA2dpService.java
@@ -325,6 +325,48 @@ public class BluetoothA2dpService extends IBluetoothA2dp.Stub {
}
}
+ public synchronized boolean suspendSink(BluetoothDevice device) {
+ mContext.enforceCallingOrSelfPermission(BLUETOOTH_ADMIN_PERM,
+ "Need BLUETOOTH_ADMIN permission");
+ if (DBG) log("suspendSink(" + device + ")");
+ if (device == null || mAudioDevices == null) {
+ return false;
+ }
+ String path = mBluetoothService.getObjectPathFromAddress(device.getAddress());
+ if (path == null) {
+ return false;
+ }
+ switch (mAudioDevices.get(device)) {
+ case BluetoothA2dp.STATE_CONNECTED:
+ return true;
+ case BluetoothA2dp.STATE_PLAYING:
+ return suspendSinkNative(path);
+ default:
+ return false;
+ }
+ }
+
+ public synchronized boolean resumeSink(BluetoothDevice device) {
+ mContext.enforceCallingOrSelfPermission(BLUETOOTH_ADMIN_PERM,
+ "Need BLUETOOTH_ADMIN permission");
+ if (DBG) log("resumeSink(" + device + ")");
+ if (device == null || mAudioDevices == null) {
+ return false;
+ }
+ String path = mBluetoothService.getObjectPathFromAddress(device.getAddress());
+ if (path == null) {
+ return false;
+ }
+ switch (mAudioDevices.get(device)) {
+ case BluetoothA2dp.STATE_PLAYING:
+ return true;
+ case BluetoothA2dp.STATE_CONNECTED:
+ return resumeSinkNative(path);
+ default:
+ return false;
+ }
+ }
+
public synchronized BluetoothDevice[] getConnectedSinks() {
mContext.enforceCallingOrSelfPermission(BLUETOOTH_PERM, "Need BLUETOOTH permission");
Set<BluetoothDevice> sinks = lookupSinksMatchingStates(
@@ -445,5 +487,7 @@ public class BluetoothA2dpService extends IBluetoothA2dp.Stub {
private native void cleanupNative();
private synchronized native boolean connectSinkNative(String path);
private synchronized native boolean disconnectSinkNative(String path);
+ private synchronized native boolean suspendSinkNative(String path);
+ private synchronized native boolean resumeSinkNative(String path);
private synchronized native Object []getSinkPropertiesNative(String path);
}