summaryrefslogtreecommitdiff
path: root/framework/java/android/bluetooth/BluetoothAvrcpController.java
diff options
context:
space:
mode:
Diffstat (limited to 'framework/java/android/bluetooth/BluetoothAvrcpController.java')
-rw-r--r--framework/java/android/bluetooth/BluetoothAvrcpController.java87
1 files changed, 43 insertions, 44 deletions
diff --git a/framework/java/android/bluetooth/BluetoothAvrcpController.java b/framework/java/android/bluetooth/BluetoothAvrcpController.java
index 0261b1b35e..1a0ae149f1 100644
--- a/framework/java/android/bluetooth/BluetoothAvrcpController.java
+++ b/framework/java/android/bluetooth/BluetoothAvrcpController.java
@@ -20,8 +20,6 @@ import android.content.ComponentName;
import android.content.Context;
import android.content.Intent;
import android.content.ServiceConnection;
-import android.media.MediaMetadata;
-import android.media.session.PlaybackState;
import android.os.Binder;
import android.os.IBinder;
import android.os.RemoteException;
@@ -34,7 +32,7 @@ import java.util.List;
* This class provides the public APIs to control the Bluetooth AVRCP Controller. It currently
* supports player information, playback support and track metadata.
*
- *<p>BluetoothAvrcpController is a proxy object for controlling the Bluetooth AVRCP
+ * <p>BluetoothAvrcpController is a proxy object for controlling the Bluetooth AVRCP
* Service via IPC. Use {@link BluetoothAdapter#getProfileProxy} to get
* the BluetoothAvrcpController proxy object.
*
@@ -51,9 +49,9 @@ public final class BluetoothAvrcpController implements BluetoothProfile {
*
* <p>This intent will have 3 extras:
* <ul>
- * <li> {@link #EXTRA_STATE} - The current state of the profile. </li>
- * <li> {@link #EXTRA_PREVIOUS_STATE}- The previous state of the profile.</li>
- * <li> {@link BluetoothDevice#EXTRA_DEVICE} - The remote device. </li>
+ * <li> {@link #EXTRA_STATE} - The current state of the profile. </li>
+ * <li> {@link #EXTRA_PREVIOUS_STATE}- The previous state of the profile.</li>
+ * <li> {@link BluetoothDevice#EXTRA_DEVICE} - The remote device. </li>
* </ul>
*
* <p>{@link #EXTRA_STATE} or {@link #EXTRA_PREVIOUS_STATE} can be any of
@@ -64,19 +62,19 @@ public final class BluetoothAvrcpController implements BluetoothProfile {
* receive.
*/
public static final String ACTION_CONNECTION_STATE_CHANGED =
- "android.bluetooth.avrcp-controller.profile.action.CONNECTION_STATE_CHANGED";
+ "android.bluetooth.avrcp-controller.profile.action.CONNECTION_STATE_CHANGED";
/**
* Intent used to broadcast the change in player application setting state on AVRCP AG.
*
* <p>This intent will have the following extras:
* <ul>
- * <li> {@link #EXTRA_PLAYER_SETTING} - {@link BluetoothAvrcpPlayerSettings} containing the
- * most recent player setting. </li>
+ * <li> {@link #EXTRA_PLAYER_SETTING} - {@link BluetoothAvrcpPlayerSettings} containing the
+ * most recent player setting. </li>
* </ul>
*/
public static final String ACTION_PLAYER_SETTING =
- "android.bluetooth.avrcp-controller.profile.action.PLAYER_SETTING";
+ "android.bluetooth.avrcp-controller.profile.action.PLAYER_SETTING";
public static final String EXTRA_PLAYER_SETTING =
"android.bluetooth.avrcp-controller.profile.extra.PLAYER_SETTING";
@@ -87,38 +85,37 @@ public final class BluetoothAvrcpController implements BluetoothProfile {
private BluetoothAdapter mAdapter;
final private IBluetoothStateChangeCallback mBluetoothStateChangeCallback =
- new IBluetoothStateChangeCallback.Stub() {
- public void onBluetoothStateChange(boolean up) {
- if (DBG) Log.d(TAG, "onBluetoothStateChange: up=" + up);
- if (!up) {
- if (VDBG) Log.d(TAG,"Unbinding service...");
- synchronized (mConnection) {
- try {
- mService = null;
- mContext.unbindService(mConnection);
- } catch (Exception re) {
- Log.e(TAG,"",re);
+ new IBluetoothStateChangeCallback.Stub() {
+ public void onBluetoothStateChange(boolean up) {
+ if (DBG) Log.d(TAG, "onBluetoothStateChange: up=" + up);
+ if (!up) {
+ if (VDBG) Log.d(TAG, "Unbinding service...");
+ synchronized (mConnection) {
+ try {
+ mService = null;
+ mContext.unbindService(mConnection);
+ } catch (Exception re) {
+ Log.e(TAG, "", re);
+ }
}
- }
- } else {
- synchronized (mConnection) {
- try {
- if (mService == null) {
- if (VDBG) Log.d(TAG,"Binding service...");
- doBind();
+ } else {
+ synchronized (mConnection) {
+ try {
+ if (mService == null) {
+ if (VDBG) Log.d(TAG, "Binding service...");
+ doBind();
+ }
+ } catch (Exception re) {
+ Log.e(TAG, "", re);
}
- } catch (Exception re) {
- Log.e(TAG,"",re);
}
}
}
- }
- };
+ };
/**
* Create a BluetoothAvrcpController proxy object for interacting with the local
* Bluetooth AVRCP service.
- *
*/
/*package*/ BluetoothAvrcpController(Context context, ServiceListener l) {
mContext = context;
@@ -129,7 +126,7 @@ public final class BluetoothAvrcpController implements BluetoothProfile {
try {
mgr.registerStateChangeCallback(mBluetoothStateChangeCallback);
} catch (RemoteException e) {
- Log.e(TAG,"",e);
+ Log.e(TAG, "", e);
}
}
@@ -155,7 +152,7 @@ public final class BluetoothAvrcpController implements BluetoothProfile {
try {
mgr.unregisterStateChangeCallback(mBluetoothStateChangeCallback);
} catch (Exception e) {
- Log.e(TAG,"",e);
+ Log.e(TAG, "", e);
}
}
@@ -165,7 +162,7 @@ public final class BluetoothAvrcpController implements BluetoothProfile {
mService = null;
mContext.unbindService(mConnection);
} catch (Exception re) {
- Log.e(TAG,"",re);
+ Log.e(TAG, "", re);
}
}
}
@@ -215,7 +212,7 @@ public final class BluetoothAvrcpController implements BluetoothProfile {
public int getConnectionState(BluetoothDevice device) {
if (VDBG) log("getState(" + device + ")");
if (mService != null && isEnabled()
- && isValidDevice(device)) {
+ && isValidDevice(device)) {
try {
return mService.getConnectionState(device);
} catch (RemoteException e) {
@@ -269,7 +266,8 @@ public final class BluetoothAvrcpController implements BluetoothProfile {
* possible keycode values: next_grp, previous_grp defined above
*/
public void sendGroupNavigationCmd(BluetoothDevice device, int keyCode, int keyState) {
- Log.d(TAG, "sendGroupNavigationCmd dev = " + device + " key " + keyCode + " State = " + keyState);
+ Log.d(TAG, "sendGroupNavigationCmd dev = " + device + " key " + keyCode + " State = "
+ + keyState);
if (mService != null && isEnabled()) {
try {
mService.sendGroupNavigationCmd(device, keyCode, keyState);
@@ -292,6 +290,7 @@ public final class BluetoothAvrcpController implements BluetoothProfile {
BluetoothAvrcpController.this);
}
}
+
public void onServiceDisconnected(ComponentName className) {
if (DBG) Log.d(TAG, "Proxy object disconnected");
mService = null;
@@ -302,18 +301,18 @@ public final class BluetoothAvrcpController implements BluetoothProfile {
};
private boolean isEnabled() {
- if (mAdapter.getState() == BluetoothAdapter.STATE_ON) return true;
- return false;
+ if (mAdapter.getState() == BluetoothAdapter.STATE_ON) return true;
+ return false;
}
private boolean isValidDevice(BluetoothDevice device) {
- if (device == null) return false;
+ if (device == null) return false;
- if (BluetoothAdapter.checkBluetoothAddress(device.getAddress())) return true;
- return false;
+ if (BluetoothAdapter.checkBluetoothAddress(device.getAddress())) return true;
+ return false;
}
private static void log(String msg) {
- Log.d(TAG, msg);
+ Log.d(TAG, msg);
}
}