Loading android/app/src/com/android/bluetooth/a2dpsink/mbs/A2dpMediaBrowserService.java +39 −32 Original line number Diff line number Diff line Loading @@ -66,6 +66,9 @@ import java.util.Map; */ public class A2dpMediaBrowserService extends MediaBrowserService { private static final String TAG = "A2dpMediaBrowserService"; private static final boolean DBG = false; private static final boolean VDBG = false; private static final String UNKNOWN_BT_AUDIO = "__UNKNOWN_BT_AUDIO__"; private static final float PLAYBACK_SPEED = 1.0f; Loading Loading @@ -161,7 +164,7 @@ public class A2dpMediaBrowserService extends MediaBrowserService { @Override public void onCreate() { Log.d(TAG, "onCreate"); if (DBG) Log.d(TAG, "onCreate"); super.onCreate(); mSession = new MediaSession(this, TAG); Loading @@ -188,7 +191,7 @@ public class A2dpMediaBrowserService extends MediaBrowserService { @Override public void onDestroy() { Log.d(TAG, "onDestroy"); if (DBG) Log.d(TAG, "onDestroy"); mSession.release(); unregisterReceiver(mBtReceiver); super.onDestroy(); Loading @@ -203,12 +206,12 @@ public class A2dpMediaBrowserService extends MediaBrowserService { public synchronized void onLoadChildren(final String parentMediaId, final Result<List<MediaItem>> result) { if (mAvrcpCtrlSrvc == null) { Log.e(TAG, "AVRCP not yet connected."); Log.w(TAG, "AVRCP not yet connected."); result.sendResult(Collections.emptyList()); return; } Log.d(TAG, "onLoadChildren parentMediaId=" + parentMediaId); if (DBG) Log.d(TAG, "onLoadChildren parentMediaId=" + parentMediaId); if (!mAvrcpCtrlSrvc.getChildren(mA2dpDevice, parentMediaId, 0, 0xff)) { result.sendResult(Collections.emptyList()); return; Loading @@ -230,7 +233,7 @@ public class A2dpMediaBrowserService extends MediaBrowserService { private MediaSession.Callback mSessionCallbacks = new MediaSession.Callback() { @Override public void onPlay() { Log.d(TAG, "onPlay"); if (DBG) Log.d(TAG, "onPlay"); mAvrcpCommandQueue.obtainMessage(MSG_AVRCP_PASSTHRU, AvrcpControllerService.PASS_THRU_CMD_ID_PLAY).sendToTarget(); // TRACK_EVENT should be fired eventually and the UI should be hence updated. Loading @@ -238,7 +241,7 @@ public class A2dpMediaBrowserService extends MediaBrowserService { @Override public void onPause() { Log.d(TAG, "onPause"); if (DBG) Log.d(TAG, "onPause"); mAvrcpCommandQueue.obtainMessage(MSG_AVRCP_PASSTHRU, AvrcpControllerService.PASS_THRU_CMD_ID_PAUSE).sendToTarget(); // TRACK_EVENT should be fired eventually and the UI should be hence updated. Loading @@ -246,7 +249,7 @@ public class A2dpMediaBrowserService extends MediaBrowserService { @Override public void onSkipToNext() { Log.d(TAG, "onSkipToNext"); if (DBG) Log.d(TAG, "onSkipToNext"); mAvrcpCommandQueue.obtainMessage(MSG_AVRCP_PASSTHRU, AvrcpControllerService.PASS_THRU_CMD_ID_FORWARD).sendToTarget(); // TRACK_EVENT should be fired eventually and the UI should be hence updated. Loading @@ -254,8 +257,7 @@ public class A2dpMediaBrowserService extends MediaBrowserService { @Override public void onSkipToPrevious() { Log.d(TAG, "onSkipToPrevious"); if (DBG) Log.d(TAG, "onSkipToPrevious"); mAvrcpCommandQueue.obtainMessage(MSG_AVRCP_PASSTHRU, AvrcpControllerService.PASS_THRU_CMD_ID_BACKWARD).sendToTarget(); // TRACK_EVENT should be fired eventually and the UI should be hence updated. Loading @@ -263,14 +265,14 @@ public class A2dpMediaBrowserService extends MediaBrowserService { @Override public void onStop() { Log.d(TAG, "onStop"); if (DBG) Log.d(TAG, "onStop"); mAvrcpCommandQueue.obtainMessage(MSG_AVRCP_PASSTHRU, AvrcpControllerService.PASS_THRU_CMD_ID_STOP).sendToTarget(); } @Override public void onPrepare() { Log.d(TAG, "onPrepare"); if (DBG) Log.d(TAG, "onPrepare"); if (mA2dpSinkService != null) { mA2dpSinkService.requestAudioFocus(mA2dpDevice, true); } Loading @@ -278,7 +280,7 @@ public class A2dpMediaBrowserService extends MediaBrowserService { @Override public void onRewind() { Log.d(TAG, "onRewind"); if (DBG) Log.d(TAG, "onRewind"); mAvrcpCommandQueue.obtainMessage(MSG_AVRCP_PASSTHRU, AvrcpControllerService.PASS_THRU_CMD_ID_REWIND).sendToTarget(); // TRACK_EVENT should be fired eventually and the UI should be hence updated. Loading @@ -286,7 +288,7 @@ public class A2dpMediaBrowserService extends MediaBrowserService { @Override public void onFastForward() { Log.d(TAG, "onFastForward"); if (DBG) Log.d(TAG, "onFastForward"); mAvrcpCommandQueue.obtainMessage(MSG_AVRCP_PASSTHRU, AvrcpControllerService.PASS_THRU_CMD_ID_FF).sendToTarget(); // TRACK_EVENT should be fired eventually and the UI should be hence updated. Loading @@ -308,7 +310,7 @@ public class A2dpMediaBrowserService extends MediaBrowserService { // Support VOL UP and VOL DOWN events for PTS testing. @Override public void onCustomAction(String action, Bundle extras) { Log.d(TAG, "onCustomAction " + action); if (DBG) Log.d(TAG, "onCustomAction " + action); if (CUSTOM_ACTION_VOL_UP.equals(action)) { mAvrcpCommandQueue.obtainMessage(MSG_AVRCP_PASSTHRU, AvrcpControllerService.PASS_THRU_CMD_ID_VOL_UP).sendToTarget(); Loading @@ -326,14 +328,17 @@ public class A2dpMediaBrowserService extends MediaBrowserService { private BroadcastReceiver mBtReceiver = new BroadcastReceiver() { @Override public void onReceive(Context context, Intent intent) { Log.d(TAG, "onReceive intent=" + intent); if (DBG) Log.d(TAG, "onReceive intent=" + intent); String action = intent.getAction(); BluetoothDevice btDev = (BluetoothDevice) intent.getParcelableExtra(BluetoothDevice.EXTRA_DEVICE); int state = intent.getIntExtra(BluetoothProfile.EXTRA_STATE, -1); if (BluetoothAvrcpController.ACTION_CONNECTION_STATE_CHANGED.equals(action)) { Log.d(TAG, "handleConnectionStateChange: newState=" + state + " btDev=" + btDev); if (DBG) { Log.d(TAG, "handleConnectionStateChange: newState=" + state + " btDev=" + btDev); } // Connected state will be handled when AVRCP BluetoothProfile gets connected. if (state == BluetoothProfile.STATE_CONNECTED) { Loading Loading @@ -370,7 +375,7 @@ public class A2dpMediaBrowserService extends MediaBrowserService { }; private synchronized void msgDeviceConnect(BluetoothDevice device) { Log.d(TAG, "msgDeviceConnect"); if (DBG) Log.d(TAG, "msgDeviceConnect"); // We are connected to a new device via A2DP now. mA2dpDevice = device; mAvrcpCtrlSrvc = AvrcpControllerService.getAvrcpControllerService(); Loading @@ -385,7 +390,7 @@ public class A2dpMediaBrowserService extends MediaBrowserService { // Refresh the UI if we have a connected device and AVRCP is initialized. private synchronized void refreshInitialPlayingState() { if (mA2dpDevice == null) { Log.d(TAG, "device " + mA2dpDevice); if (DBG) Log.d(TAG, "device " + mA2dpDevice); return; } Loading @@ -396,7 +401,7 @@ public class A2dpMediaBrowserService extends MediaBrowserService { } if (mA2dpDevice != null && !mA2dpDevice.equals(devices.get(0))) { Log.e(TAG, "A2dp device : " + mA2dpDevice + " avrcp device " + devices.get(0)); Log.w(TAG, "A2dp device : " + mA2dpDevice + " avrcp device " + devices.get(0)); return; } mA2dpDevice = devices.get(0); Loading @@ -408,13 +413,15 @@ public class A2dpMediaBrowserService extends MediaBrowserService { playbackState = pbb.setActions(mTransportControlFlags).build(); MediaMetadata mediaMetadata = mAvrcpCtrlSrvc.getMetaData(mA2dpDevice); if (VDBG) { Log.d(TAG, "Media metadata " + mediaMetadata + " playback state " + playbackState); } mSession.setMetadata(mAvrcpCtrlSrvc.getMetaData(mA2dpDevice)); mSession.setPlaybackState(playbackState); } private void msgDeviceDisconnect(BluetoothDevice device) { Log.d(TAG, "msgDeviceDisconnect"); if (DBG) Log.d(TAG, "msgDeviceDisconnect"); if (mA2dpDevice == null) { Log.w(TAG, "Already disconnected - nothing to do here."); return; Loading @@ -440,7 +447,7 @@ public class A2dpMediaBrowserService extends MediaBrowserService { } private void msgTrack(PlaybackState pb, MediaMetadata mmd) { Log.d(TAG, "msgTrack: playback: " + pb + " mmd: " + mmd); if (VDBG) Log.d(TAG, "msgTrack: playback: " + pb + " mmd: " + mmd); // Log the current track position/content. MediaController controller = mSession.getController(); PlaybackState prevPS = controller.getPlaybackState(); Loading @@ -453,16 +460,16 @@ public class A2dpMediaBrowserService extends MediaBrowserService { if (prevMM != null) { String title = prevMM.getString(MediaMetadata.METADATA_KEY_TITLE); long trackLen = prevMM.getLong(MediaMetadata.METADATA_KEY_DURATION); Log.d(TAG, "prev MM title " + title + " track len " + trackLen); if (VDBG) Log.d(TAG, "prev MM title " + title + " track len " + trackLen); } if (mmd != null) { Log.d(TAG, "msgTrack() mmd " + mmd.getDescription()); if (VDBG) Log.d(TAG, "msgTrack() mmd " + mmd.getDescription()); mSession.setMetadata(mmd); } if (pb != null) { Log.d(TAG, "msgTrack() playbackstate " + pb); if (DBG) Log.d(TAG, "msgTrack() playbackstate " + pb); PlaybackState.Builder pbb = new PlaybackState.Builder(pb); pb = pbb.setActions(mTransportControlFlags).build(); mSession.setPlaybackState(pb); Loading @@ -476,10 +483,10 @@ public class A2dpMediaBrowserService extends MediaBrowserService { } private synchronized void msgPassThru(int cmd) { Log.d(TAG, "msgPassThru " + cmd); if (DBG) Log.d(TAG, "msgPassThru " + cmd); if (mA2dpDevice == null) { // We should have already disconnected - ignore this message. Log.e(TAG, "Already disconnected ignoring."); Log.w(TAG, "Already disconnected ignoring."); return; } Loading @@ -491,10 +498,10 @@ public class A2dpMediaBrowserService extends MediaBrowserService { } private synchronized void msgGetPlayStatusNative() { Log.d(TAG, "msgGetPlayStatusNative"); if (DBG) Log.d(TAG, "msgGetPlayStatusNative"); if (mA2dpDevice == null) { // We should have already disconnected - ignore this message. Log.e(TAG, "Already disconnected ignoring."); Log.w(TAG, "Already disconnected ignoring."); return; } Loading @@ -503,7 +510,7 @@ public class A2dpMediaBrowserService extends MediaBrowserService { } private void msgDeviceBrowseConnect(BluetoothDevice device) { Log.d(TAG, "msgDeviceBrowseConnect device " + device); if (DBG) Log.d(TAG, "msgDeviceBrowseConnect device " + device); // We should already be connected to this device over A2DP. if (!device.equals(mA2dpDevice)) { Log.e(TAG, "Browse connected over different device a2dp " + mA2dpDevice + " browse " Loading @@ -526,7 +533,7 @@ public class A2dpMediaBrowserService extends MediaBrowserService { } String id = intent.getStringExtra(AvrcpControllerService.EXTRA_FOLDER_ID); Log.d(TAG, "Parent: " + id + " Folder list: " + folderList); if (VDBG) Log.d(TAG, "Parent: " + id + " Folder list: " + folderList); synchronized (this) { // If we have a result object then we should send the result back // to client since it is blocking otherwise we may have gotten more items Loading @@ -542,7 +549,7 @@ public class A2dpMediaBrowserService extends MediaBrowserService { } private void msgDeviceBrowseDisconnect(BluetoothDevice device) { Log.d(TAG, "msgDeviceBrowseDisconnect device " + device); if (DBG) Log.d(TAG, "msgDeviceBrowseDisconnect device " + device); // Disconnect only if mA2dpDevice is non null if (!device.equals(mA2dpDevice)) { Log.w(TAG, "Browse disconnecting from different device a2dp " + mA2dpDevice + " browse " Loading android/app/src/com/android/bluetooth/avrcpcontroller/AvrcpControllerService.java +8 −8 Original line number Diff line number Diff line Loading @@ -44,8 +44,8 @@ import java.util.UUID; */ public class AvrcpControllerService extends ProfileService { static final String TAG = "AvrcpControllerService"; static final boolean DBG = true; static final boolean VDBG = Log.isLoggable(TAG, Log.VERBOSE); static final boolean DBG = false; static final boolean VDBG = false; /* * Play State Values from JNI */ Loading Loading @@ -834,7 +834,7 @@ public class AvrcpControllerService extends ProfileService { } List<String> attrValList = Arrays.asList(attribVals); TrackInfo trackInfo = new TrackInfo(attrList, attrValList); if (DBG) { if (VDBG) { Log.d(TAG, "onTrackChanged " + trackInfo); } Message msg = mAvrcpCtSm.obtainMessage( Loading Loading @@ -943,7 +943,7 @@ public class AvrcpControllerService extends ProfileService { } for (MediaItem item : items) { if (DBG) { if (VDBG) { Log.d(TAG, "media item: " + item + " uid: " + item.getDescription().getMediaId()); } } Loading @@ -961,7 +961,7 @@ public class AvrcpControllerService extends ProfileService { Log.d(TAG, "handleGetFolderItemsRsp called with " + items.length + " items."); } for (AvrcpPlayer item : items) { if (DBG) { if (VDBG) { Log.d(TAG, "bt player item: " + item); } } Loading @@ -978,7 +978,7 @@ public class AvrcpControllerService extends ProfileService { // JNI Helper functions to convert native objects to java. MediaItem createFromNativeMediaItem(byte[] uid, int type, String name, int[] attrIds, String[] attrVals) { if (DBG) { if (VDBG) { Log.d(TAG, "createFromNativeMediaItem uid: " + uid + " type " + type + " name " + name + " attrids " + attrIds + " attrVals " + attrVals); } Loading @@ -1002,7 +1002,7 @@ public class AvrcpControllerService extends ProfileService { } MediaItem createFromNativeFolderItem(byte[] uid, int type, String name, int playable) { if (DBG) { if (VDBG) { Log.d(TAG, "createFromNativeFolderItem uid: " + uid + " type " + type + " name " + name + " playable " + playable); } Loading @@ -1026,7 +1026,7 @@ public class AvrcpControllerService extends ProfileService { AvrcpPlayer createFromNativePlayerItem(int id, String name, byte[] transportFlags, int playStatus, int playerType) { if (DBG) { if (VDBG) { Log.d(TAG, "createFromNativePlayerItem name: " + name + " transportFlags " + transportFlags + " play status " + playStatus + " player type " + playerType); Loading android/app/src/com/android/bluetooth/avrcpcontroller/AvrcpControllerStateMachine.java +42 −32 Original line number Diff line number Diff line Loading @@ -104,7 +104,7 @@ class AvrcpControllerStateMachine extends StateMachine { private static final String TAG = "AvrcpControllerSM"; private static final boolean DBG = true; private static final boolean VDBG = true; private static final boolean VDBG = false; private final Context mContext; private final AudioManager mAudioManager; Loading Loading @@ -178,7 +178,7 @@ class AvrcpControllerStateMachine extends StateMachine { @Override public boolean processMessage(Message msg) { Log.d(TAG, " HandleMessage: " + dumpMessageString(msg.what)); if (DBG) Log.d(TAG, " HandleMessage: " + dumpMessageString(msg.what)); switch (msg.what) { case MESSAGE_PROCESS_CONNECTION_CHANGE: if (msg.arg1 == BluetoothProfile.STATE_CONNECTED) { Loading Loading @@ -213,7 +213,7 @@ class AvrcpControllerStateMachine extends StateMachine { class Connected extends State { @Override public boolean processMessage(Message msg) { Log.d(TAG, " HandleMessage: " + dumpMessageString(msg.what)); if (DBG) Log.d(TAG, " HandleMessage: " + dumpMessageString(msg.what)); A2dpSinkService a2dpSinkService = A2dpSinkService.getA2dpSinkService(); synchronized (mLock) { switch (msg.what) { Loading @@ -238,7 +238,7 @@ class AvrcpControllerStateMachine extends StateMachine { AvrcpControllerService.sendPassThroughCommandNative( Utils.getByteAddress(device), msg.arg1, msg.arg2); if (a2dpSinkService != null) { Log.d(TAG, " inform AVRCP Commands to A2DP Sink "); if (DBG) Log.d(TAG, " inform AVRCP Commands to A2DP Sink "); a2dpSinkService.informAvrcpPassThroughCmd(device, msg.arg1, msg.arg2); } break; Loading Loading @@ -390,8 +390,10 @@ class AvrcpControllerStateMachine extends StateMachine { mRemoteDevice.setNotificationLabel(msg.arg1); mRemoteDevice.setAbsVolNotificationRequested(true); int percentageVol = getVolumePercentage(); if (DBG) { Log.d(TAG, " Sending Interim Response = " + percentageVol + " label " + msg.arg1); } AvrcpControllerService.sendRegisterAbsVolRspNative( mRemoteDevice.getBluetoothAddress(), NOTIFICATION_RSP_TYPE_INTERIM, percentageVol, mRemoteDevice.getNotificationLabel()); Loading Loading @@ -479,7 +481,7 @@ class AvrcpControllerStateMachine extends StateMachine { @Override public boolean processMessage(Message msg) { Log.d(STATE_TAG, "processMessage " + msg); if (DBG) Log.d(STATE_TAG, "processMessage " + msg.what); switch (msg.what) { case MESSAGE_INTERNAL_BROWSE_DEPTH_INCREMENT: mTmpIncrDirection = msg.arg1; Loading @@ -487,8 +489,10 @@ class AvrcpControllerStateMachine extends StateMachine { case MESSAGE_PROCESS_FOLDER_PATH: { // Fetch the listing of objects in this folder. if (DBG) { Log.d(STATE_TAG, "MESSAGE_PROCESS_FOLDER_PATH returned " + msg.arg1 + " elements"); } // Update the folder depth. if (mTmpIncrDirection Loading @@ -500,7 +504,7 @@ class AvrcpControllerStateMachine extends StateMachine { } else { throw new IllegalStateException("incorrect nav " + mTmpIncrDirection); } Log.d(STATE_TAG, "New browse depth " + mBrowseDepth); if (DBG) Log.d(STATE_TAG, "New browse depth " + mBrowseDepth); if (msg.arg1 > 0) { sendMessage(MESSAGE_GET_FOLDER_LIST, 0, msg.arg1 - 1, mID); Loading @@ -522,7 +526,9 @@ class AvrcpControllerStateMachine extends StateMachine { break; default: Log.d(STATE_TAG, "deferring message " + msg + " to Connected state."); if (DBG) { Log.d(STATE_TAG, "deferring message " + msg.what + " to Connected state."); } deferMessage(msg); } return true; Loading Loading @@ -557,7 +563,7 @@ class AvrcpControllerStateMachine extends StateMachine { } public void setFolder(String id) { Log.d(STATE_TAG, "Setting folder to " + id); if (DBG) Log.d(STATE_TAG, "Setting folder to " + id); mID = id; } Loading @@ -571,7 +577,7 @@ class AvrcpControllerStateMachine extends StateMachine { @Override public boolean processMessage(Message msg) { Log.d(STATE_TAG, "processMessage " + msg); Log.d(STATE_TAG, "processMessage " + msg.what); switch (msg.what) { case MESSAGE_PROCESS_GET_FOLDER_ITEMS: ArrayList<MediaItem> folderList = (ArrayList<MediaItem>) msg.obj; Loading Loading @@ -617,7 +623,7 @@ class AvrcpControllerStateMachine extends StateMachine { break; default: Log.d(STATE_TAG, "deferring message " + msg + " to connected!"); if (DBG) Log.d(STATE_TAG, "deferring message " + msg.what + " to connected!"); deferMessage(msg); } return true; Loading Loading @@ -674,7 +680,7 @@ class AvrcpControllerStateMachine extends StateMachine { @Override public boolean processMessage(Message msg) { Log.d(STATE_TAG, "processMessage " + msg); if (DBG) Log.d(STATE_TAG, "processMessage " + msg.what); switch (msg.what) { case MESSAGE_PROCESS_GET_PLAYER_ITEMS: List<AvrcpPlayer> playerList = (List<AvrcpPlayer>) msg.obj; Loading @@ -697,7 +703,7 @@ class AvrcpControllerStateMachine extends StateMachine { break; default: Log.d(STATE_TAG, "deferring message " + msg + " to connected!"); if (DBG) Log.d(STATE_TAG, "deferring message " + msg.what + " to connected!"); deferMessage(msg); } return true; Loading @@ -709,7 +715,7 @@ class AvrcpControllerStateMachine extends StateMachine { private String mID = ""; public void setFolder(String id) { Log.d(STATE_TAG, "setFolder " + id); if (DBG) Log.d(STATE_TAG, "setFolder " + id); mID = id; } Loading @@ -725,7 +731,9 @@ class AvrcpControllerStateMachine extends StateMachine { @Override public boolean processMessage(Message msg) { Log.d(STATE_TAG, "processMessage " + msg + " browse depth " + mBrowseDepth); if (DBG) { Log.d(STATE_TAG, "processMessage " + msg.what + " browse depth " + mBrowseDepth); } switch (msg.what) { case MESSAGE_INTERNAL_MOVE_N_LEVELS_UP: if (mBrowseDepth == 0) { Loading @@ -742,7 +750,7 @@ class AvrcpControllerStateMachine extends StateMachine { case MESSAGE_PROCESS_FOLDER_PATH: mBrowseDepth -= 1; Log.d(STATE_TAG, "New browse depth " + mBrowseDepth); if (DBG) Log.d(STATE_TAG, "New browse depth " + mBrowseDepth); if (mBrowseDepth < 0) { throw new IllegalArgumentException("Browse depth negative!"); } Loading @@ -756,7 +764,7 @@ class AvrcpControllerStateMachine extends StateMachine { break; default: Log.d(STATE_TAG, "deferring message " + msg + " to connected!"); if (DBG) Log.d(STATE_TAG, "deferring message " + msg.what + " to connected!"); deferMessage(msg); } return true; Loading @@ -773,11 +781,11 @@ class AvrcpControllerStateMachine extends StateMachine { @Override public boolean processMessage(Message msg) { Log.d(STATE_TAG, "processMessage " + msg); if (DBG) Log.d(STATE_TAG, "processMessage " + msg.what); switch (msg.what) { case MESSAGE_PROCESS_SET_BROWSED_PLAYER: // Set the new depth. Log.d(STATE_TAG, "player depth " + msg.arg2); if (DBG) Log.d(STATE_TAG, "player depth " + msg.arg2); mBrowseDepth = msg.arg2; // If we already on top of player and there is no content. Loading @@ -802,7 +810,7 @@ class AvrcpControllerStateMachine extends StateMachine { break; default: Log.d(STATE_TAG, "deferring message " + msg + " to connected!"); if (DBG) Log.d(STATE_TAG, "deferring message " + msg.what + " to connected!"); deferMessage(msg); } return true; Loading @@ -823,7 +831,7 @@ class AvrcpControllerStateMachine extends StateMachine { @Override public boolean processMessage(Message msg) { Log.d(STATE_TAG, "processMessage " + msg); if (DBG) Log.d(STATE_TAG, "processMessage " + msg.what); switch (msg.what) { case MESSAGE_PROCESS_SET_ADDRESSED_PLAYER: // Set the new addressed player. Loading @@ -843,7 +851,7 @@ class AvrcpControllerStateMachine extends StateMachine { break; default: Log.d(STATE_TAG, "deferring message " + msg + " to connected!"); if (DBG) Log.d(STATE_TAG, "deferring message " + msg.what + " to connected!"); deferMessage(msg); } return true; Loading Loading @@ -988,7 +996,7 @@ class AvrcpControllerStateMachine extends StateMachine { if (!isNowPlayingToRoot) { // Find the direction of traversal. int direction = -1; Log.d(TAG, "Browse direction " + currFol + " " + bn + " = " + btDirection); if (DBG) Log.d(TAG, "Browse direction " + currFol + " " + bn + " = " + btDirection); if (btDirection == BrowseTree.DIRECTION_UNKNOWN) { Log.w(TAG, "parent " + bn + " is not a direct " + "successor or predeccessor of current folder " + currFol); Loading Loading @@ -1022,7 +1030,7 @@ class AvrcpControllerStateMachine extends StateMachine { public void fetchAttrAndPlayItem(String uid) { BrowseTree.BrowseNode currItem = mBrowseTree.findFolderByIDLocked(uid); BrowseTree.BrowseNode currFolder = mBrowseTree.getCurrentBrowsedFolder(); Log.d(TAG, "fetchAttrAndPlayItem mediaId=" + uid + " node=" + currItem); if (DBG) Log.d(TAG, "fetchAttrAndPlayItem mediaId=" + uid + " node=" + currItem); if (currItem != null) { int scope = currFolder.isNowPlaying() ? AvrcpControllerService.BROWSE_SCOPE_NOW_PLAYING : AvrcpControllerService.BROWSE_SCOPE_VFS; Loading @@ -1036,7 +1044,7 @@ class AvrcpControllerStateMachine extends StateMachine { private void broadcastMetaDataChanged(MediaMetadata metadata) { Intent intent = new Intent(AvrcpControllerService.ACTION_TRACK_EVENT); intent.putExtra(AvrcpControllerService.EXTRA_METADATA, metadata); if (DBG) { if (VDBG) { Log.d(TAG, " broadcastMetaDataChanged = " + metadata.getDescription()); } mContext.sendBroadcast(intent, ProfileService.BLUETOOTH_PERM); Loading @@ -1044,7 +1052,7 @@ class AvrcpControllerStateMachine extends StateMachine { private void broadcastFolderList(String id, ArrayList<MediaItem> items) { Intent intent = new Intent(AvrcpControllerService.ACTION_FOLDER_LIST); Log.d(TAG, "broadcastFolderList id " + id + " items " + items); if (VDBG) Log.d(TAG, "broadcastFolderList id " + id + " items " + items); intent.putExtra(AvrcpControllerService.EXTRA_FOLDER_ID, id); intent.putParcelableArrayListExtra(AvrcpControllerService.EXTRA_FOLDER_LIST, items); mContext.sendBroadcast(intent, ProfileService.BLUETOOTH_PERM); Loading @@ -1066,8 +1074,10 @@ class AvrcpControllerStateMachine extends StateMachine { // and amplifier volume. if (mRemoteDevice.getFirstAbsVolCmdRecvd()) { int newIndex = (maxVolume * absVol) / ABS_VOL_BASE; Log.d(TAG, " setAbsVolume =" + absVol + " maxVol = " + maxVolume + " cur = " + currIndex + " new = " + newIndex); if (DBG) { Log.d(TAG, " setAbsVolume =" + absVol + " maxVol = " + maxVolume + " cur = " + currIndex + " new = " + newIndex); } /* * In some cases change in percentage is not sufficient enough to warrant * change in index values which are in range of 0-15. For such cases Loading @@ -1080,7 +1090,7 @@ class AvrcpControllerStateMachine extends StateMachine { } else { mRemoteDevice.setFirstAbsVolCmdRecvd(); absVol = (currIndex * ABS_VOL_BASE) / maxVolume; Log.d(TAG, " SetAbsVol recvd for first time, respond with " + absVol); if (DBG) Log.d(TAG, " SetAbsVol recvd for first time, respond with " + absVol); } AvrcpControllerService.sendAbsVolRspNative(mRemoteDevice.getBluetoothAddress(), absVol, label); Loading android/app/src/com/android/bluetooth/avrcpcontroller/BrowseTree.java +10 −6 File changed.Preview size limit exceeded, changes collapsed. Show changes android/app/src/com/android/bluetooth/avrcpcontroller/TrackInfo.java +2 −2 Original line number Diff line number Diff line Loading @@ -32,7 +32,7 @@ import java.util.Map; */ class TrackInfo { private static final String TAG = "AvrcpTrackInfo"; private static final boolean DBG = true; private static final boolean VDBG = false; /* * Default values for each of the items from JNI Loading Loading @@ -103,7 +103,7 @@ class TrackInfo { } public MediaMetadata getMediaMetaData() { if (DBG) { if (VDBG) { Log.d(TAG, " TrackInfo " + toString()); } MediaMetadata.Builder mMetaDataBuilder = new MediaMetadata.Builder(); Loading Loading
android/app/src/com/android/bluetooth/a2dpsink/mbs/A2dpMediaBrowserService.java +39 −32 Original line number Diff line number Diff line Loading @@ -66,6 +66,9 @@ import java.util.Map; */ public class A2dpMediaBrowserService extends MediaBrowserService { private static final String TAG = "A2dpMediaBrowserService"; private static final boolean DBG = false; private static final boolean VDBG = false; private static final String UNKNOWN_BT_AUDIO = "__UNKNOWN_BT_AUDIO__"; private static final float PLAYBACK_SPEED = 1.0f; Loading Loading @@ -161,7 +164,7 @@ public class A2dpMediaBrowserService extends MediaBrowserService { @Override public void onCreate() { Log.d(TAG, "onCreate"); if (DBG) Log.d(TAG, "onCreate"); super.onCreate(); mSession = new MediaSession(this, TAG); Loading @@ -188,7 +191,7 @@ public class A2dpMediaBrowserService extends MediaBrowserService { @Override public void onDestroy() { Log.d(TAG, "onDestroy"); if (DBG) Log.d(TAG, "onDestroy"); mSession.release(); unregisterReceiver(mBtReceiver); super.onDestroy(); Loading @@ -203,12 +206,12 @@ public class A2dpMediaBrowserService extends MediaBrowserService { public synchronized void onLoadChildren(final String parentMediaId, final Result<List<MediaItem>> result) { if (mAvrcpCtrlSrvc == null) { Log.e(TAG, "AVRCP not yet connected."); Log.w(TAG, "AVRCP not yet connected."); result.sendResult(Collections.emptyList()); return; } Log.d(TAG, "onLoadChildren parentMediaId=" + parentMediaId); if (DBG) Log.d(TAG, "onLoadChildren parentMediaId=" + parentMediaId); if (!mAvrcpCtrlSrvc.getChildren(mA2dpDevice, parentMediaId, 0, 0xff)) { result.sendResult(Collections.emptyList()); return; Loading @@ -230,7 +233,7 @@ public class A2dpMediaBrowserService extends MediaBrowserService { private MediaSession.Callback mSessionCallbacks = new MediaSession.Callback() { @Override public void onPlay() { Log.d(TAG, "onPlay"); if (DBG) Log.d(TAG, "onPlay"); mAvrcpCommandQueue.obtainMessage(MSG_AVRCP_PASSTHRU, AvrcpControllerService.PASS_THRU_CMD_ID_PLAY).sendToTarget(); // TRACK_EVENT should be fired eventually and the UI should be hence updated. Loading @@ -238,7 +241,7 @@ public class A2dpMediaBrowserService extends MediaBrowserService { @Override public void onPause() { Log.d(TAG, "onPause"); if (DBG) Log.d(TAG, "onPause"); mAvrcpCommandQueue.obtainMessage(MSG_AVRCP_PASSTHRU, AvrcpControllerService.PASS_THRU_CMD_ID_PAUSE).sendToTarget(); // TRACK_EVENT should be fired eventually and the UI should be hence updated. Loading @@ -246,7 +249,7 @@ public class A2dpMediaBrowserService extends MediaBrowserService { @Override public void onSkipToNext() { Log.d(TAG, "onSkipToNext"); if (DBG) Log.d(TAG, "onSkipToNext"); mAvrcpCommandQueue.obtainMessage(MSG_AVRCP_PASSTHRU, AvrcpControllerService.PASS_THRU_CMD_ID_FORWARD).sendToTarget(); // TRACK_EVENT should be fired eventually and the UI should be hence updated. Loading @@ -254,8 +257,7 @@ public class A2dpMediaBrowserService extends MediaBrowserService { @Override public void onSkipToPrevious() { Log.d(TAG, "onSkipToPrevious"); if (DBG) Log.d(TAG, "onSkipToPrevious"); mAvrcpCommandQueue.obtainMessage(MSG_AVRCP_PASSTHRU, AvrcpControllerService.PASS_THRU_CMD_ID_BACKWARD).sendToTarget(); // TRACK_EVENT should be fired eventually and the UI should be hence updated. Loading @@ -263,14 +265,14 @@ public class A2dpMediaBrowserService extends MediaBrowserService { @Override public void onStop() { Log.d(TAG, "onStop"); if (DBG) Log.d(TAG, "onStop"); mAvrcpCommandQueue.obtainMessage(MSG_AVRCP_PASSTHRU, AvrcpControllerService.PASS_THRU_CMD_ID_STOP).sendToTarget(); } @Override public void onPrepare() { Log.d(TAG, "onPrepare"); if (DBG) Log.d(TAG, "onPrepare"); if (mA2dpSinkService != null) { mA2dpSinkService.requestAudioFocus(mA2dpDevice, true); } Loading @@ -278,7 +280,7 @@ public class A2dpMediaBrowserService extends MediaBrowserService { @Override public void onRewind() { Log.d(TAG, "onRewind"); if (DBG) Log.d(TAG, "onRewind"); mAvrcpCommandQueue.obtainMessage(MSG_AVRCP_PASSTHRU, AvrcpControllerService.PASS_THRU_CMD_ID_REWIND).sendToTarget(); // TRACK_EVENT should be fired eventually and the UI should be hence updated. Loading @@ -286,7 +288,7 @@ public class A2dpMediaBrowserService extends MediaBrowserService { @Override public void onFastForward() { Log.d(TAG, "onFastForward"); if (DBG) Log.d(TAG, "onFastForward"); mAvrcpCommandQueue.obtainMessage(MSG_AVRCP_PASSTHRU, AvrcpControllerService.PASS_THRU_CMD_ID_FF).sendToTarget(); // TRACK_EVENT should be fired eventually and the UI should be hence updated. Loading @@ -308,7 +310,7 @@ public class A2dpMediaBrowserService extends MediaBrowserService { // Support VOL UP and VOL DOWN events for PTS testing. @Override public void onCustomAction(String action, Bundle extras) { Log.d(TAG, "onCustomAction " + action); if (DBG) Log.d(TAG, "onCustomAction " + action); if (CUSTOM_ACTION_VOL_UP.equals(action)) { mAvrcpCommandQueue.obtainMessage(MSG_AVRCP_PASSTHRU, AvrcpControllerService.PASS_THRU_CMD_ID_VOL_UP).sendToTarget(); Loading @@ -326,14 +328,17 @@ public class A2dpMediaBrowserService extends MediaBrowserService { private BroadcastReceiver mBtReceiver = new BroadcastReceiver() { @Override public void onReceive(Context context, Intent intent) { Log.d(TAG, "onReceive intent=" + intent); if (DBG) Log.d(TAG, "onReceive intent=" + intent); String action = intent.getAction(); BluetoothDevice btDev = (BluetoothDevice) intent.getParcelableExtra(BluetoothDevice.EXTRA_DEVICE); int state = intent.getIntExtra(BluetoothProfile.EXTRA_STATE, -1); if (BluetoothAvrcpController.ACTION_CONNECTION_STATE_CHANGED.equals(action)) { Log.d(TAG, "handleConnectionStateChange: newState=" + state + " btDev=" + btDev); if (DBG) { Log.d(TAG, "handleConnectionStateChange: newState=" + state + " btDev=" + btDev); } // Connected state will be handled when AVRCP BluetoothProfile gets connected. if (state == BluetoothProfile.STATE_CONNECTED) { Loading Loading @@ -370,7 +375,7 @@ public class A2dpMediaBrowserService extends MediaBrowserService { }; private synchronized void msgDeviceConnect(BluetoothDevice device) { Log.d(TAG, "msgDeviceConnect"); if (DBG) Log.d(TAG, "msgDeviceConnect"); // We are connected to a new device via A2DP now. mA2dpDevice = device; mAvrcpCtrlSrvc = AvrcpControllerService.getAvrcpControllerService(); Loading @@ -385,7 +390,7 @@ public class A2dpMediaBrowserService extends MediaBrowserService { // Refresh the UI if we have a connected device and AVRCP is initialized. private synchronized void refreshInitialPlayingState() { if (mA2dpDevice == null) { Log.d(TAG, "device " + mA2dpDevice); if (DBG) Log.d(TAG, "device " + mA2dpDevice); return; } Loading @@ -396,7 +401,7 @@ public class A2dpMediaBrowserService extends MediaBrowserService { } if (mA2dpDevice != null && !mA2dpDevice.equals(devices.get(0))) { Log.e(TAG, "A2dp device : " + mA2dpDevice + " avrcp device " + devices.get(0)); Log.w(TAG, "A2dp device : " + mA2dpDevice + " avrcp device " + devices.get(0)); return; } mA2dpDevice = devices.get(0); Loading @@ -408,13 +413,15 @@ public class A2dpMediaBrowserService extends MediaBrowserService { playbackState = pbb.setActions(mTransportControlFlags).build(); MediaMetadata mediaMetadata = mAvrcpCtrlSrvc.getMetaData(mA2dpDevice); if (VDBG) { Log.d(TAG, "Media metadata " + mediaMetadata + " playback state " + playbackState); } mSession.setMetadata(mAvrcpCtrlSrvc.getMetaData(mA2dpDevice)); mSession.setPlaybackState(playbackState); } private void msgDeviceDisconnect(BluetoothDevice device) { Log.d(TAG, "msgDeviceDisconnect"); if (DBG) Log.d(TAG, "msgDeviceDisconnect"); if (mA2dpDevice == null) { Log.w(TAG, "Already disconnected - nothing to do here."); return; Loading @@ -440,7 +447,7 @@ public class A2dpMediaBrowserService extends MediaBrowserService { } private void msgTrack(PlaybackState pb, MediaMetadata mmd) { Log.d(TAG, "msgTrack: playback: " + pb + " mmd: " + mmd); if (VDBG) Log.d(TAG, "msgTrack: playback: " + pb + " mmd: " + mmd); // Log the current track position/content. MediaController controller = mSession.getController(); PlaybackState prevPS = controller.getPlaybackState(); Loading @@ -453,16 +460,16 @@ public class A2dpMediaBrowserService extends MediaBrowserService { if (prevMM != null) { String title = prevMM.getString(MediaMetadata.METADATA_KEY_TITLE); long trackLen = prevMM.getLong(MediaMetadata.METADATA_KEY_DURATION); Log.d(TAG, "prev MM title " + title + " track len " + trackLen); if (VDBG) Log.d(TAG, "prev MM title " + title + " track len " + trackLen); } if (mmd != null) { Log.d(TAG, "msgTrack() mmd " + mmd.getDescription()); if (VDBG) Log.d(TAG, "msgTrack() mmd " + mmd.getDescription()); mSession.setMetadata(mmd); } if (pb != null) { Log.d(TAG, "msgTrack() playbackstate " + pb); if (DBG) Log.d(TAG, "msgTrack() playbackstate " + pb); PlaybackState.Builder pbb = new PlaybackState.Builder(pb); pb = pbb.setActions(mTransportControlFlags).build(); mSession.setPlaybackState(pb); Loading @@ -476,10 +483,10 @@ public class A2dpMediaBrowserService extends MediaBrowserService { } private synchronized void msgPassThru(int cmd) { Log.d(TAG, "msgPassThru " + cmd); if (DBG) Log.d(TAG, "msgPassThru " + cmd); if (mA2dpDevice == null) { // We should have already disconnected - ignore this message. Log.e(TAG, "Already disconnected ignoring."); Log.w(TAG, "Already disconnected ignoring."); return; } Loading @@ -491,10 +498,10 @@ public class A2dpMediaBrowserService extends MediaBrowserService { } private synchronized void msgGetPlayStatusNative() { Log.d(TAG, "msgGetPlayStatusNative"); if (DBG) Log.d(TAG, "msgGetPlayStatusNative"); if (mA2dpDevice == null) { // We should have already disconnected - ignore this message. Log.e(TAG, "Already disconnected ignoring."); Log.w(TAG, "Already disconnected ignoring."); return; } Loading @@ -503,7 +510,7 @@ public class A2dpMediaBrowserService extends MediaBrowserService { } private void msgDeviceBrowseConnect(BluetoothDevice device) { Log.d(TAG, "msgDeviceBrowseConnect device " + device); if (DBG) Log.d(TAG, "msgDeviceBrowseConnect device " + device); // We should already be connected to this device over A2DP. if (!device.equals(mA2dpDevice)) { Log.e(TAG, "Browse connected over different device a2dp " + mA2dpDevice + " browse " Loading @@ -526,7 +533,7 @@ public class A2dpMediaBrowserService extends MediaBrowserService { } String id = intent.getStringExtra(AvrcpControllerService.EXTRA_FOLDER_ID); Log.d(TAG, "Parent: " + id + " Folder list: " + folderList); if (VDBG) Log.d(TAG, "Parent: " + id + " Folder list: " + folderList); synchronized (this) { // If we have a result object then we should send the result back // to client since it is blocking otherwise we may have gotten more items Loading @@ -542,7 +549,7 @@ public class A2dpMediaBrowserService extends MediaBrowserService { } private void msgDeviceBrowseDisconnect(BluetoothDevice device) { Log.d(TAG, "msgDeviceBrowseDisconnect device " + device); if (DBG) Log.d(TAG, "msgDeviceBrowseDisconnect device " + device); // Disconnect only if mA2dpDevice is non null if (!device.equals(mA2dpDevice)) { Log.w(TAG, "Browse disconnecting from different device a2dp " + mA2dpDevice + " browse " Loading
android/app/src/com/android/bluetooth/avrcpcontroller/AvrcpControllerService.java +8 −8 Original line number Diff line number Diff line Loading @@ -44,8 +44,8 @@ import java.util.UUID; */ public class AvrcpControllerService extends ProfileService { static final String TAG = "AvrcpControllerService"; static final boolean DBG = true; static final boolean VDBG = Log.isLoggable(TAG, Log.VERBOSE); static final boolean DBG = false; static final boolean VDBG = false; /* * Play State Values from JNI */ Loading Loading @@ -834,7 +834,7 @@ public class AvrcpControllerService extends ProfileService { } List<String> attrValList = Arrays.asList(attribVals); TrackInfo trackInfo = new TrackInfo(attrList, attrValList); if (DBG) { if (VDBG) { Log.d(TAG, "onTrackChanged " + trackInfo); } Message msg = mAvrcpCtSm.obtainMessage( Loading Loading @@ -943,7 +943,7 @@ public class AvrcpControllerService extends ProfileService { } for (MediaItem item : items) { if (DBG) { if (VDBG) { Log.d(TAG, "media item: " + item + " uid: " + item.getDescription().getMediaId()); } } Loading @@ -961,7 +961,7 @@ public class AvrcpControllerService extends ProfileService { Log.d(TAG, "handleGetFolderItemsRsp called with " + items.length + " items."); } for (AvrcpPlayer item : items) { if (DBG) { if (VDBG) { Log.d(TAG, "bt player item: " + item); } } Loading @@ -978,7 +978,7 @@ public class AvrcpControllerService extends ProfileService { // JNI Helper functions to convert native objects to java. MediaItem createFromNativeMediaItem(byte[] uid, int type, String name, int[] attrIds, String[] attrVals) { if (DBG) { if (VDBG) { Log.d(TAG, "createFromNativeMediaItem uid: " + uid + " type " + type + " name " + name + " attrids " + attrIds + " attrVals " + attrVals); } Loading @@ -1002,7 +1002,7 @@ public class AvrcpControllerService extends ProfileService { } MediaItem createFromNativeFolderItem(byte[] uid, int type, String name, int playable) { if (DBG) { if (VDBG) { Log.d(TAG, "createFromNativeFolderItem uid: " + uid + " type " + type + " name " + name + " playable " + playable); } Loading @@ -1026,7 +1026,7 @@ public class AvrcpControllerService extends ProfileService { AvrcpPlayer createFromNativePlayerItem(int id, String name, byte[] transportFlags, int playStatus, int playerType) { if (DBG) { if (VDBG) { Log.d(TAG, "createFromNativePlayerItem name: " + name + " transportFlags " + transportFlags + " play status " + playStatus + " player type " + playerType); Loading
android/app/src/com/android/bluetooth/avrcpcontroller/AvrcpControllerStateMachine.java +42 −32 Original line number Diff line number Diff line Loading @@ -104,7 +104,7 @@ class AvrcpControllerStateMachine extends StateMachine { private static final String TAG = "AvrcpControllerSM"; private static final boolean DBG = true; private static final boolean VDBG = true; private static final boolean VDBG = false; private final Context mContext; private final AudioManager mAudioManager; Loading Loading @@ -178,7 +178,7 @@ class AvrcpControllerStateMachine extends StateMachine { @Override public boolean processMessage(Message msg) { Log.d(TAG, " HandleMessage: " + dumpMessageString(msg.what)); if (DBG) Log.d(TAG, " HandleMessage: " + dumpMessageString(msg.what)); switch (msg.what) { case MESSAGE_PROCESS_CONNECTION_CHANGE: if (msg.arg1 == BluetoothProfile.STATE_CONNECTED) { Loading Loading @@ -213,7 +213,7 @@ class AvrcpControllerStateMachine extends StateMachine { class Connected extends State { @Override public boolean processMessage(Message msg) { Log.d(TAG, " HandleMessage: " + dumpMessageString(msg.what)); if (DBG) Log.d(TAG, " HandleMessage: " + dumpMessageString(msg.what)); A2dpSinkService a2dpSinkService = A2dpSinkService.getA2dpSinkService(); synchronized (mLock) { switch (msg.what) { Loading @@ -238,7 +238,7 @@ class AvrcpControllerStateMachine extends StateMachine { AvrcpControllerService.sendPassThroughCommandNative( Utils.getByteAddress(device), msg.arg1, msg.arg2); if (a2dpSinkService != null) { Log.d(TAG, " inform AVRCP Commands to A2DP Sink "); if (DBG) Log.d(TAG, " inform AVRCP Commands to A2DP Sink "); a2dpSinkService.informAvrcpPassThroughCmd(device, msg.arg1, msg.arg2); } break; Loading Loading @@ -390,8 +390,10 @@ class AvrcpControllerStateMachine extends StateMachine { mRemoteDevice.setNotificationLabel(msg.arg1); mRemoteDevice.setAbsVolNotificationRequested(true); int percentageVol = getVolumePercentage(); if (DBG) { Log.d(TAG, " Sending Interim Response = " + percentageVol + " label " + msg.arg1); } AvrcpControllerService.sendRegisterAbsVolRspNative( mRemoteDevice.getBluetoothAddress(), NOTIFICATION_RSP_TYPE_INTERIM, percentageVol, mRemoteDevice.getNotificationLabel()); Loading Loading @@ -479,7 +481,7 @@ class AvrcpControllerStateMachine extends StateMachine { @Override public boolean processMessage(Message msg) { Log.d(STATE_TAG, "processMessage " + msg); if (DBG) Log.d(STATE_TAG, "processMessage " + msg.what); switch (msg.what) { case MESSAGE_INTERNAL_BROWSE_DEPTH_INCREMENT: mTmpIncrDirection = msg.arg1; Loading @@ -487,8 +489,10 @@ class AvrcpControllerStateMachine extends StateMachine { case MESSAGE_PROCESS_FOLDER_PATH: { // Fetch the listing of objects in this folder. if (DBG) { Log.d(STATE_TAG, "MESSAGE_PROCESS_FOLDER_PATH returned " + msg.arg1 + " elements"); } // Update the folder depth. if (mTmpIncrDirection Loading @@ -500,7 +504,7 @@ class AvrcpControllerStateMachine extends StateMachine { } else { throw new IllegalStateException("incorrect nav " + mTmpIncrDirection); } Log.d(STATE_TAG, "New browse depth " + mBrowseDepth); if (DBG) Log.d(STATE_TAG, "New browse depth " + mBrowseDepth); if (msg.arg1 > 0) { sendMessage(MESSAGE_GET_FOLDER_LIST, 0, msg.arg1 - 1, mID); Loading @@ -522,7 +526,9 @@ class AvrcpControllerStateMachine extends StateMachine { break; default: Log.d(STATE_TAG, "deferring message " + msg + " to Connected state."); if (DBG) { Log.d(STATE_TAG, "deferring message " + msg.what + " to Connected state."); } deferMessage(msg); } return true; Loading Loading @@ -557,7 +563,7 @@ class AvrcpControllerStateMachine extends StateMachine { } public void setFolder(String id) { Log.d(STATE_TAG, "Setting folder to " + id); if (DBG) Log.d(STATE_TAG, "Setting folder to " + id); mID = id; } Loading @@ -571,7 +577,7 @@ class AvrcpControllerStateMachine extends StateMachine { @Override public boolean processMessage(Message msg) { Log.d(STATE_TAG, "processMessage " + msg); Log.d(STATE_TAG, "processMessage " + msg.what); switch (msg.what) { case MESSAGE_PROCESS_GET_FOLDER_ITEMS: ArrayList<MediaItem> folderList = (ArrayList<MediaItem>) msg.obj; Loading Loading @@ -617,7 +623,7 @@ class AvrcpControllerStateMachine extends StateMachine { break; default: Log.d(STATE_TAG, "deferring message " + msg + " to connected!"); if (DBG) Log.d(STATE_TAG, "deferring message " + msg.what + " to connected!"); deferMessage(msg); } return true; Loading Loading @@ -674,7 +680,7 @@ class AvrcpControllerStateMachine extends StateMachine { @Override public boolean processMessage(Message msg) { Log.d(STATE_TAG, "processMessage " + msg); if (DBG) Log.d(STATE_TAG, "processMessage " + msg.what); switch (msg.what) { case MESSAGE_PROCESS_GET_PLAYER_ITEMS: List<AvrcpPlayer> playerList = (List<AvrcpPlayer>) msg.obj; Loading @@ -697,7 +703,7 @@ class AvrcpControllerStateMachine extends StateMachine { break; default: Log.d(STATE_TAG, "deferring message " + msg + " to connected!"); if (DBG) Log.d(STATE_TAG, "deferring message " + msg.what + " to connected!"); deferMessage(msg); } return true; Loading @@ -709,7 +715,7 @@ class AvrcpControllerStateMachine extends StateMachine { private String mID = ""; public void setFolder(String id) { Log.d(STATE_TAG, "setFolder " + id); if (DBG) Log.d(STATE_TAG, "setFolder " + id); mID = id; } Loading @@ -725,7 +731,9 @@ class AvrcpControllerStateMachine extends StateMachine { @Override public boolean processMessage(Message msg) { Log.d(STATE_TAG, "processMessage " + msg + " browse depth " + mBrowseDepth); if (DBG) { Log.d(STATE_TAG, "processMessage " + msg.what + " browse depth " + mBrowseDepth); } switch (msg.what) { case MESSAGE_INTERNAL_MOVE_N_LEVELS_UP: if (mBrowseDepth == 0) { Loading @@ -742,7 +750,7 @@ class AvrcpControllerStateMachine extends StateMachine { case MESSAGE_PROCESS_FOLDER_PATH: mBrowseDepth -= 1; Log.d(STATE_TAG, "New browse depth " + mBrowseDepth); if (DBG) Log.d(STATE_TAG, "New browse depth " + mBrowseDepth); if (mBrowseDepth < 0) { throw new IllegalArgumentException("Browse depth negative!"); } Loading @@ -756,7 +764,7 @@ class AvrcpControllerStateMachine extends StateMachine { break; default: Log.d(STATE_TAG, "deferring message " + msg + " to connected!"); if (DBG) Log.d(STATE_TAG, "deferring message " + msg.what + " to connected!"); deferMessage(msg); } return true; Loading @@ -773,11 +781,11 @@ class AvrcpControllerStateMachine extends StateMachine { @Override public boolean processMessage(Message msg) { Log.d(STATE_TAG, "processMessage " + msg); if (DBG) Log.d(STATE_TAG, "processMessage " + msg.what); switch (msg.what) { case MESSAGE_PROCESS_SET_BROWSED_PLAYER: // Set the new depth. Log.d(STATE_TAG, "player depth " + msg.arg2); if (DBG) Log.d(STATE_TAG, "player depth " + msg.arg2); mBrowseDepth = msg.arg2; // If we already on top of player and there is no content. Loading @@ -802,7 +810,7 @@ class AvrcpControllerStateMachine extends StateMachine { break; default: Log.d(STATE_TAG, "deferring message " + msg + " to connected!"); if (DBG) Log.d(STATE_TAG, "deferring message " + msg.what + " to connected!"); deferMessage(msg); } return true; Loading @@ -823,7 +831,7 @@ class AvrcpControllerStateMachine extends StateMachine { @Override public boolean processMessage(Message msg) { Log.d(STATE_TAG, "processMessage " + msg); if (DBG) Log.d(STATE_TAG, "processMessage " + msg.what); switch (msg.what) { case MESSAGE_PROCESS_SET_ADDRESSED_PLAYER: // Set the new addressed player. Loading @@ -843,7 +851,7 @@ class AvrcpControllerStateMachine extends StateMachine { break; default: Log.d(STATE_TAG, "deferring message " + msg + " to connected!"); if (DBG) Log.d(STATE_TAG, "deferring message " + msg.what + " to connected!"); deferMessage(msg); } return true; Loading Loading @@ -988,7 +996,7 @@ class AvrcpControllerStateMachine extends StateMachine { if (!isNowPlayingToRoot) { // Find the direction of traversal. int direction = -1; Log.d(TAG, "Browse direction " + currFol + " " + bn + " = " + btDirection); if (DBG) Log.d(TAG, "Browse direction " + currFol + " " + bn + " = " + btDirection); if (btDirection == BrowseTree.DIRECTION_UNKNOWN) { Log.w(TAG, "parent " + bn + " is not a direct " + "successor or predeccessor of current folder " + currFol); Loading Loading @@ -1022,7 +1030,7 @@ class AvrcpControllerStateMachine extends StateMachine { public void fetchAttrAndPlayItem(String uid) { BrowseTree.BrowseNode currItem = mBrowseTree.findFolderByIDLocked(uid); BrowseTree.BrowseNode currFolder = mBrowseTree.getCurrentBrowsedFolder(); Log.d(TAG, "fetchAttrAndPlayItem mediaId=" + uid + " node=" + currItem); if (DBG) Log.d(TAG, "fetchAttrAndPlayItem mediaId=" + uid + " node=" + currItem); if (currItem != null) { int scope = currFolder.isNowPlaying() ? AvrcpControllerService.BROWSE_SCOPE_NOW_PLAYING : AvrcpControllerService.BROWSE_SCOPE_VFS; Loading @@ -1036,7 +1044,7 @@ class AvrcpControllerStateMachine extends StateMachine { private void broadcastMetaDataChanged(MediaMetadata metadata) { Intent intent = new Intent(AvrcpControllerService.ACTION_TRACK_EVENT); intent.putExtra(AvrcpControllerService.EXTRA_METADATA, metadata); if (DBG) { if (VDBG) { Log.d(TAG, " broadcastMetaDataChanged = " + metadata.getDescription()); } mContext.sendBroadcast(intent, ProfileService.BLUETOOTH_PERM); Loading @@ -1044,7 +1052,7 @@ class AvrcpControllerStateMachine extends StateMachine { private void broadcastFolderList(String id, ArrayList<MediaItem> items) { Intent intent = new Intent(AvrcpControllerService.ACTION_FOLDER_LIST); Log.d(TAG, "broadcastFolderList id " + id + " items " + items); if (VDBG) Log.d(TAG, "broadcastFolderList id " + id + " items " + items); intent.putExtra(AvrcpControllerService.EXTRA_FOLDER_ID, id); intent.putParcelableArrayListExtra(AvrcpControllerService.EXTRA_FOLDER_LIST, items); mContext.sendBroadcast(intent, ProfileService.BLUETOOTH_PERM); Loading @@ -1066,8 +1074,10 @@ class AvrcpControllerStateMachine extends StateMachine { // and amplifier volume. if (mRemoteDevice.getFirstAbsVolCmdRecvd()) { int newIndex = (maxVolume * absVol) / ABS_VOL_BASE; Log.d(TAG, " setAbsVolume =" + absVol + " maxVol = " + maxVolume + " cur = " + currIndex + " new = " + newIndex); if (DBG) { Log.d(TAG, " setAbsVolume =" + absVol + " maxVol = " + maxVolume + " cur = " + currIndex + " new = " + newIndex); } /* * In some cases change in percentage is not sufficient enough to warrant * change in index values which are in range of 0-15. For such cases Loading @@ -1080,7 +1090,7 @@ class AvrcpControllerStateMachine extends StateMachine { } else { mRemoteDevice.setFirstAbsVolCmdRecvd(); absVol = (currIndex * ABS_VOL_BASE) / maxVolume; Log.d(TAG, " SetAbsVol recvd for first time, respond with " + absVol); if (DBG) Log.d(TAG, " SetAbsVol recvd for first time, respond with " + absVol); } AvrcpControllerService.sendAbsVolRspNative(mRemoteDevice.getBluetoothAddress(), absVol, label); Loading
android/app/src/com/android/bluetooth/avrcpcontroller/BrowseTree.java +10 −6 File changed.Preview size limit exceeded, changes collapsed. Show changes
android/app/src/com/android/bluetooth/avrcpcontroller/TrackInfo.java +2 −2 Original line number Diff line number Diff line Loading @@ -32,7 +32,7 @@ import java.util.Map; */ class TrackInfo { private static final String TAG = "AvrcpTrackInfo"; private static final boolean DBG = true; private static final boolean VDBG = false; /* * Default values for each of the items from JNI Loading Loading @@ -103,7 +103,7 @@ class TrackInfo { } public MediaMetadata getMediaMetaData() { if (DBG) { if (VDBG) { Log.d(TAG, " TrackInfo " + toString()); } MediaMetadata.Builder mMetaDataBuilder = new MediaMetadata.Builder(); Loading