diff options
author | Treehugger Robot <treehugger-gerrit@google.com> | 2017-12-28 02:35:07 +0000 |
---|---|---|
committer | Gerrit Code Review <noreply-gerritcodereview@google.com> | 2017-12-28 02:35:07 +0000 |
commit | 281998c825ad48d842bb653e2f462719fdb0c1d9 (patch) | |
tree | bc8bfcce809257b3ddbb423a9808082292b9f6a3 /java/com/android/dialer/app/voicemail/WiredHeadsetManager.java | |
parent | fc81a030a7b4f6d4a497f71aed593d398795e7da (diff) | |
parent | 183cb71663320f16149d83eeebaff7795a4b55f2 (diff) |
Merge "Remove field prefixes."
Diffstat (limited to 'java/com/android/dialer/app/voicemail/WiredHeadsetManager.java')
-rw-r--r-- | java/com/android/dialer/app/voicemail/WiredHeadsetManager.java | 40 |
1 files changed, 21 insertions, 19 deletions
diff --git a/java/com/android/dialer/app/voicemail/WiredHeadsetManager.java b/java/com/android/dialer/app/voicemail/WiredHeadsetManager.java index 24d4c6ff7..2873f8d5e 100644 --- a/java/com/android/dialer/app/voicemail/WiredHeadsetManager.java +++ b/java/com/android/dialer/app/voicemail/WiredHeadsetManager.java @@ -20,50 +20,52 @@ import android.content.Context; import android.content.Intent; import android.content.IntentFilter; import android.media.AudioManager; -import android.util.Log; +import com.android.dialer.common.LogUtil; /** Listens for and caches headset state. */ class WiredHeadsetManager { private static final String TAG = WiredHeadsetManager.class.getSimpleName(); - private final WiredHeadsetBroadcastReceiver mReceiver; - private boolean mIsPluggedIn; - private Listener mListener; - private Context mContext; + private final WiredHeadsetBroadcastReceiver receiver; + private boolean isPluggedIn; + private Listener listener; + private Context context; WiredHeadsetManager(Context context) { - mContext = context; - mReceiver = new WiredHeadsetBroadcastReceiver(); + this.context = context; + receiver = new WiredHeadsetBroadcastReceiver(); AudioManager audioManager = (AudioManager) context.getSystemService(Context.AUDIO_SERVICE); - mIsPluggedIn = audioManager.isWiredHeadsetOn(); + isPluggedIn = audioManager.isWiredHeadsetOn(); } void setListener(Listener listener) { - mListener = listener; + this.listener = listener; } boolean isPluggedIn() { - return mIsPluggedIn; + return isPluggedIn; } void registerReceiver() { // Register for misc other intent broadcasts. IntentFilter intentFilter = new IntentFilter(Intent.ACTION_HEADSET_PLUG); - mContext.registerReceiver(mReceiver, intentFilter); + context.registerReceiver(receiver, intentFilter); } void unregisterReceiver() { - mContext.unregisterReceiver(mReceiver); + context.unregisterReceiver(receiver); } private void onHeadsetPluggedInChanged(boolean isPluggedIn) { - if (mIsPluggedIn != isPluggedIn) { - Log.v(TAG, "onHeadsetPluggedInChanged, mIsPluggedIn: " + mIsPluggedIn + " -> " + isPluggedIn); - boolean oldIsPluggedIn = mIsPluggedIn; - mIsPluggedIn = isPluggedIn; - if (mListener != null) { - mListener.onWiredHeadsetPluggedInChanged(oldIsPluggedIn, mIsPluggedIn); + if (this.isPluggedIn != isPluggedIn) { + LogUtil.v( + TAG, + "onHeadsetPluggedInChanged, mIsPluggedIn: " + this.isPluggedIn + " -> " + isPluggedIn); + boolean oldIsPluggedIn = this.isPluggedIn; + this.isPluggedIn = isPluggedIn; + if (listener != null) { + listener.onWiredHeadsetPluggedInChanged(oldIsPluggedIn, this.isPluggedIn); } } } @@ -80,7 +82,7 @@ class WiredHeadsetManager { public void onReceive(Context context, Intent intent) { if (AudioManager.ACTION_HEADSET_PLUG.equals(intent.getAction())) { boolean isPluggedIn = intent.getIntExtra("state", 0) == 1; - Log.v(TAG, "ACTION_HEADSET_PLUG event, plugged in: " + isPluggedIn); + LogUtil.v(TAG, "ACTION_HEADSET_PLUG event, plugged in: " + isPluggedIn); onHeadsetPluggedInChanged(isPluggedIn); } } |