Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit 1fbc8223 authored by Treehugger Robot's avatar Treehugger Robot Committed by Gerrit Code Review
Browse files

Merge "[Manual] Rename non-public non-static variables to mCamelCase"

parents 4c3fd4ec 9a5b1ff6
Loading
Loading
Loading
Loading
+18 −18
Original line number Diff line number Diff line
@@ -45,7 +45,7 @@ import android.util.Log;
 * In both cases the {@link ObexServerSockets} object have terminated, and a new must be created.
 */
public class ObexServerSockets {
    private final String TAG;
    private final String mTag;
    private static final String STAG = "ObexServerSockets";
    private static final boolean D = true; // TODO: set to false!
    private static final int NUMBER_OF_SOCKET_TYPES = 2; // increment if LE will be supported
@@ -68,7 +68,7 @@ public class ObexServerSockets {
        mConHandler = conHandler;
        mRfcommSocket = rfcommSocket;
        mL2capSocket = l2capSocket;
        TAG = "ObexServerSockets" + sInstanceCounter++;
        mTag = "ObexServerSockets" + sInstanceCounter++;
    }

    /**
@@ -198,7 +198,7 @@ public class ObexServerSockets {
     * the {@link IObexConnectionValidator#onConnect()}, at which point both threads will exit.
     */
    private void startAccept() {
        if(D) Log.d(TAG,"startAccept()");
        if(D) Log.d(mTag,"startAccept()");
        prepareForNewConnect();

        mRfcommThread = new SocketAcceptThread(mRfcommSocket);
@@ -213,7 +213,7 @@ public class ObexServerSockets {
     * Signaled through {@link IObexConnectionValidator#onConnect()};
     */
    public synchronized void prepareForNewConnect() {
        if(D) Log.d(TAG, "prepareForNewConnect()");
        if(D) Log.d(mTag, "prepareForNewConnect()");
        mConAccepted = false;
    }

@@ -227,7 +227,7 @@ public class ObexServerSockets {
     * @return true if the connection is accepted, false otherwise.
     */
    private synchronized boolean onConnect(BluetoothDevice device, BluetoothSocket conSocket) {
        if(D) Log.d(TAG, "onConnect() socket: " + conSocket + " mConAccepted = " + mConAccepted);
        if(D) Log.d(mTag, "onConnect() socket: " + conSocket + " mConAccepted = " + mConAccepted);
        if(!mConAccepted && mConHandler.onConnect(device, conSocket)) {
            mConAccepted = true; // TODO: Reset this when ready to accept new connection
            /* Signal the remaining threads to stop.
@@ -244,7 +244,7 @@ public class ObexServerSockets {
        shutdown(false);
        BluetoothAdapter mAdapter = BluetoothAdapter.getDefaultAdapter();
        if ((mAdapter != null) && (mAdapter.getState() == BluetoothAdapter.STATE_ON)) {
            Log.d(TAG, "onAcceptFailed() calling shutdown...");
            Log.d(mTag, "onAcceptFailed() calling shutdown...");
            mConHandler.onAcceptFailed();
        }
    }
@@ -255,7 +255,7 @@ public class ObexServerSockets {
     * has ended execution
     */
    public synchronized void shutdown(boolean block) {
        if(D) Log.d(TAG, "shutdown(block = " + block + ")");
        if(D) Log.d(mTag, "shutdown(block = " + block + ")");
        if(mRfcommThread != null) {
            mRfcommThread.shutdown();
        }
@@ -274,7 +274,7 @@ public class ObexServerSockets {
                        mL2capThread = null;
                    }
                } catch (InterruptedException e) {
                    Log.i(TAG, "shutdown() interrupted, continue waiting...", e);
                    Log.i(mTag, "shutdown() interrupted, continue waiting...", e);
                }
            }
        } else {
@@ -319,24 +319,24 @@ public class ObexServerSockets {
                    BluetoothDevice device;

                    try {
                        if (D) Log.d(TAG, "Accepting socket connection...");
                        if (D) Log.d(mTag, "Accepting socket connection...");

                        connSocket = mServerSocket.accept();
                        if (D) Log.d(TAG, "Accepted socket connection from: " + mServerSocket);
                        if (D) Log.d(mTag, "Accepted socket connection from: " + mServerSocket);

                       if (connSocket == null) {
                           // TODO: Do we need a max error count, to avoid spinning?
                            Log.w(TAG, "connSocket is null - reattempt accept");
                            Log.w(mTag, "connSocket is null - reattempt accept");
                            continue;
                        }
                        device = connSocket.getRemoteDevice();

                        if (device == null) {
                            Log.i(TAG, "getRemoteDevice() = null - reattempt accept");
                            Log.i(mTag, "getRemoteDevice() = null - reattempt accept");
                            try{
                                connSocket.close();
                            } catch (IOException e) {
                                Log.w(TAG, "Error closing the socket. ignoring...",e );
                                Log.w(mTag, "Error closing the socket. ignoring...",e );
                            }
                            continue;
                        }
@@ -349,7 +349,7 @@ public class ObexServerSockets {
                            /* Close connection if we already have a connection with another device
                             * by responding to the OBEX connect request.
                             */
                            Log.i(TAG, "RemoteDevice is invalid - creating ObexRejectServer.");
                            Log.i(mTag, "RemoteDevice is invalid - creating ObexRejectServer.");
                            BluetoothObexTransport obexTrans =
                                    new BluetoothObexTransport(connSocket);
                            // Create and detach a selfdestructing ServerSession to respond to any
@@ -367,7 +367,7 @@ public class ObexServerSockets {
                        if(mStopped) {
                            // Expected exception because of shutdown.
                        } else {
                            Log.w(TAG, "Accept exception for " +
                            Log.w(mTag, "Accept exception for " +
                                    mServerSocket, ex);
                            ObexServerSockets.this.onAcceptFailed();
                        }
@@ -375,7 +375,7 @@ public class ObexServerSockets {
                    }
                } // End while()
            } finally {
                if (D) Log.d(TAG, "AcceptThread ended for: " + mServerSocket);
                if (D) Log.d(mTag, "AcceptThread ended for: " + mServerSocket);
            }
        }

@@ -393,14 +393,14 @@ public class ObexServerSockets {
                try {
                     mServerSocket.close();
                } catch (IOException e) {
                    if(D) Log.d(TAG, "Exception while thread shutdown:", e);
                    if(D) Log.d(mTag, "Exception while thread shutdown:", e);
                }
            }
            // If called from another thread, interrupt the thread
            if(!Thread.currentThread().equals(this)){
                // TODO: Will this interrupt the thread if it is blocked in synchronized?
                // Else: change to use InterruptableLock
                if(D) Log.d(TAG, "shutdown called from another thread - interrupt().");
                if(D) Log.d(mTag, "shutdown called from another thread - interrupt().");
                interrupt();
            }
        }
+3 −3
Original line number Diff line number Diff line
@@ -962,9 +962,9 @@ final class A2dpStateMachine extends StateMachine {
    }

    private class StackEvent {
        int type = EVENT_TYPE_NONE;
        int valueInt = 0;
        BluetoothDevice device = null;
        public int type = EVENT_TYPE_NONE;
        public int valueInt = 0;
        public BluetoothDevice device = null;

        private StackEvent(int type) {
            this.type = type;
+4 −4
Original line number Diff line number Diff line
@@ -810,10 +810,10 @@ public class A2dpSinkStateMachine extends StateMachine {
    }

    private class StackEvent {
        int type = EVENT_TYPE_NONE;
        int valueInt = 0;
        BluetoothDevice device = null;
        BluetoothAudioConfig audioConfig = null;
        public int type = EVENT_TYPE_NONE;
        public int valueInt = 0;
        public BluetoothDevice device = null;
        public BluetoothAudioConfig audioConfig = null;

        private StackEvent(int type) {
            this.type = type;
+5 −3
Original line number Diff line number Diff line
@@ -89,9 +89,11 @@ public class A2dpMediaBrowserService extends MediaBrowserService {
    private static final int MSG_FOLDER_LIST = 9;

    // Custom actions for PTS testing.
    private String CUSTOM_ACTION_VOL_UP = "com.android.bluetooth.a2dpsink.mbs.CUSTOM_ACTION_VOL_UP";
    private String CUSTOM_ACTION_VOL_DN = "com.android.bluetooth.a2dpsink.mbs.CUSTOM_ACTION_VOL_DN";
    private String CUSTOM_ACTION_GET_PLAY_STATUS_NATIVE =
    private static final String CUSTOM_ACTION_VOL_UP =
            "com.android.bluetooth.a2dpsink.mbs.CUSTOM_ACTION_VOL_UP";
    private static final String CUSTOM_ACTION_VOL_DN =
            "com.android.bluetooth.a2dpsink.mbs.CUSTOM_ACTION_VOL_DN";
    private static final String CUSTOM_ACTION_GET_PLAY_STATUS_NATIVE =
        "com.android.bluetooth.a2dpsink.mbs.CUSTOM_ACTION_GET_PLAY_STATUS_NATIVE";

    private MediaSession mSession;
+49 −52
Original line number Diff line number Diff line
@@ -20,7 +20,6 @@ import android.annotation.NonNull;
import android.annotation.Nullable;
import android.bluetooth.BluetoothA2dp;
import android.bluetooth.BluetoothAvrcp;
import android.bluetooth.BluetoothDevice;
import android.content.BroadcastReceiver;
import android.content.ComponentName;
import android.content.Context;
@@ -36,9 +35,7 @@ import android.media.AudioManager;
import android.media.AudioPlaybackConfiguration;
import android.media.MediaDescription;
import android.media.MediaMetadata;
import android.media.browse.MediaBrowser;
import android.media.session.MediaSession;
import android.media.session.MediaSession.QueueItem;
import android.media.session.MediaSessionManager;
import android.media.session.PlaybackState;
import android.os.Bundle;
@@ -902,14 +899,14 @@ public final class Avrcp {
    }

    class MediaAttributes {
        private boolean exists;
        private String title;
        private String artistName;
        private String albumName;
        private String mediaNumber;
        private String mediaTotalNumber;
        private String genre;
        private long playingTimeMs;
        private boolean mExists;
        private String mTitle;
        private String mArtistName;
        private String mAlbumName;
        private String mMediaNumber;
        private String mMediaTotalNumber;
        private String mGenre;
        private long mPlayingTimeMs;

        private static final int ATTR_TITLE = 1;
        private static final int ATTR_ARTIST_NAME = 2;
@@ -921,74 +918,74 @@ public final class Avrcp {


        MediaAttributes(MediaMetadata data) {
            exists = data != null;
            if (!exists)
            mExists = data != null;
            if (!mExists)
                return;

            artistName = stringOrBlank(data.getString(MediaMetadata.METADATA_KEY_ARTIST));
            albumName = stringOrBlank(data.getString(MediaMetadata.METADATA_KEY_ALBUM));
            mediaNumber = longStringOrBlank(data.getLong(MediaMetadata.METADATA_KEY_TRACK_NUMBER));
            mediaTotalNumber = longStringOrBlank(data.getLong(MediaMetadata.METADATA_KEY_NUM_TRACKS));
            genre = stringOrBlank(data.getString(MediaMetadata.METADATA_KEY_GENRE));
            playingTimeMs = data.getLong(MediaMetadata.METADATA_KEY_DURATION);
            mArtistName = stringOrBlank(data.getString(MediaMetadata.METADATA_KEY_ARTIST));
            mAlbumName = stringOrBlank(data.getString(MediaMetadata.METADATA_KEY_ALBUM));
            mMediaNumber = longStringOrBlank(data.getLong(MediaMetadata.METADATA_KEY_TRACK_NUMBER));
            mMediaTotalNumber = longStringOrBlank(data.getLong(MediaMetadata.METADATA_KEY_NUM_TRACKS));
            mGenre = stringOrBlank(data.getString(MediaMetadata.METADATA_KEY_GENRE));
            mPlayingTimeMs = data.getLong(MediaMetadata.METADATA_KEY_DURATION);

            // Try harder for the title.
            title = data.getString(MediaMetadata.METADATA_KEY_TITLE);
            mTitle = data.getString(MediaMetadata.METADATA_KEY_TITLE);

            if (title == null) {
            if (mTitle == null) {
                MediaDescription desc = data.getDescription();
                if (desc != null) {
                    CharSequence val = desc.getDescription();
                    if (val != null)
                        title = val.toString();
                        mTitle = val.toString();
                }
            }

            if (title == null)
                title = new String();
            if (mTitle == null)
                mTitle = new String();
        }

        public long getLength() {
            if (!exists) return 0L;
            return playingTimeMs;
            if (!mExists) return 0L;
            return mPlayingTimeMs;
        }

        public boolean equals(MediaAttributes other) {
            if (other == null)
                return false;

            if (exists != other.exists)
            if (mExists != other.mExists)
                return false;

            if (!exists)
            if (!mExists)
                return true;

            return (title.equals(other.title)) && (artistName.equals(other.artistName))
                    && (albumName.equals(other.albumName))
                    && (mediaNumber.equals(other.mediaNumber))
                    && (mediaTotalNumber.equals(other.mediaTotalNumber))
                    && (genre.equals(other.genre)) && (playingTimeMs == other.playingTimeMs);
            return (mTitle.equals(other.mTitle)) && (mArtistName.equals(other.mArtistName))
                    && (mAlbumName.equals(other.mAlbumName))
                    && (mMediaNumber.equals(other.mMediaNumber))
                    && (mMediaTotalNumber.equals(other.mMediaTotalNumber))
                    && (mGenre.equals(other.mGenre)) && (mPlayingTimeMs == other.mPlayingTimeMs);
        }

        public String getString(int attrId) {
            if (!exists)
            if (!mExists)
                return new String();

            switch (attrId) {
                case ATTR_TITLE:
                    return title;
                    return mTitle;
                case ATTR_ARTIST_NAME:
                    return artistName;
                    return mArtistName;
                case ATTR_ALBUM_NAME:
                    return albumName;
                    return mAlbumName;
                case ATTR_MEDIA_NUMBER:
                    return mediaNumber;
                    return mMediaNumber;
                case ATTR_MEDIA_TOTAL_NUMBER:
                    return mediaTotalNumber;
                    return mMediaTotalNumber;
                case ATTR_GENRE:
                    return genre;
                    return mGenre;
                case ATTR_PLAYING_TIME_MS:
                    return Long.toString(playingTimeMs);
                    return Long.toString(mPlayingTimeMs);
                default:
                    return new String();
            }
@@ -1004,23 +1001,23 @@ public final class Avrcp {

        @Override
        public String toString() {
            if (!exists) {
            if (!mExists) {
                return "[MediaAttributes: none]";
            }

            return "[MediaAttributes: " + title + " - " + albumName + " by " + artistName + " ("
                    + playingTimeMs + " " + mediaNumber + "/" + mediaTotalNumber + ") " + genre
            return "[MediaAttributes: " + mTitle + " - " + mAlbumName + " by " + mArtistName + " ("
                    + mPlayingTimeMs + " " + mMediaNumber + "/" + mMediaTotalNumber + ") " + mGenre
                    + "]";
        }

        public String toRedactedString() {
            if (!exists) {
            if (!mExists) {
                return "[MediaAttributes: none]";
            }

            return "[MediaAttributes: " + Utils.ellipsize(title) + " - "
                    + Utils.ellipsize(albumName) + " by " + Utils.ellipsize(artistName) + " ("
                    + playingTimeMs + " " + mediaNumber + "/" + mediaTotalNumber + ") " + genre
            return "[MediaAttributes: " + Utils.ellipsize(mTitle) + " - "
                    + Utils.ellipsize(mAlbumName) + " by " + Utils.ellipsize(mArtistName) + " ("
                    + mPlayingTimeMs + " " + mMediaNumber + "/" + mMediaTotalNumber + ") " + mGenre
                    + "]";
        }
    }
@@ -1208,7 +1205,7 @@ public final class Avrcp {
        // for non-browsable players or no player
        if (info != null && !info.isBrowseSupported()) {
            byte[] track = AvrcpConstants.TRACK_IS_SELECTED;
            if (!mMediaAttributes.exists) track = AvrcpConstants.NO_TRACK_SELECTED;
            if (!mMediaAttributes.mExists) track = AvrcpConstants.NO_TRACK_SELECTED;
            registerNotificationRspTrackChangeNative(mTrackChangedNT, track);
            return;
        }
@@ -2172,7 +2169,7 @@ public final class Avrcp {
        }
        if (DEBUG) Log.d(TAG, "handleMediaPlayerListRsp: sending " + rspObj.mNumItems + " players");
        mediaPlayerListRspNative(folderObj.mAddress, rspObj.mStatus, rspObj.mUIDCounter,
                rspObj.itemType, rspObj.mNumItems, rspObj.mPlayerIds, rspObj.mPlayerTypes,
                rspObj.mItemType, rspObj.mNumItems, rspObj.mPlayerIds, rspObj.mPlayerTypes,
                rspObj.mPlayerSubTypes, rspObj.mPlayStatusValues, rspObj.mFeatureBitMaskValues,
                rspObj.mPlayerNameList);
    }
@@ -2430,7 +2427,7 @@ public final class Avrcp {
    }

    public class AvrcpBrowseManager {
        Map<String, BrowsedMediaPlayer> connList = new HashMap<String, BrowsedMediaPlayer>();
        public Map<String, BrowsedMediaPlayer> connList = new HashMap<String, BrowsedMediaPlayer>();
        private AvrcpMediaRspInterface mMediaInterface;
        private Context mContext;

@@ -2518,7 +2515,7 @@ public final class Avrcp {
        @Override
        public void mediaPlayerListRsp(byte[] address, int rspStatus, MediaPlayerListRsp rspObj) {
            if (rspObj != null && rspStatus == AvrcpConstants.RSP_NO_ERROR) {
                if (!mediaPlayerListRspNative(address, rspStatus, sUIDCounter, rspObj.itemType,
                if (!mediaPlayerListRspNative(address, rspStatus, sUIDCounter, rspObj.mItemType,
                            rspObj.mNumItems, rspObj.mPlayerIds, rspObj.mPlayerTypes,
                            rspObj.mPlayerSubTypes, rspObj.mPlayStatusValues,
                            rspObj.mFeatureBitMaskValues, rspObj.mPlayerNameList))
Loading