From 2cfb9a95378f81a316324fb64a89e2751d6afe8e Mon Sep 17 00:00:00 2001 From: Kamal Negi <kamaln@codeaurora.org> Date: Wed, 22 Feb 2017 17:45:38 +0530 Subject: [PATCH] FM: Fix null pointer exception Check if variable is null before making a call to avoid the null pointer exception. Change-Id: I23f271d6c1f32416aa10a9113273dde477b8a0d8 --- fmapp2/src/com/caf/fmradio/FMRadioService.java | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/fmapp2/src/com/caf/fmradio/FMRadioService.java b/fmapp2/src/com/caf/fmradio/FMRadioService.java index d6f46da..e5a7d83 100644 --- a/fmapp2/src/com/caf/fmradio/FMRadioService.java +++ b/fmapp2/src/com/caf/fmradio/FMRadioService.java @@ -1586,7 +1586,8 @@ public class FMRadioService extends Service switch (msg.arg1) { case AudioManager.AUDIOFOCUS_LOSS_TRANSIENT: Log.v(LOGTAG, "AudioFocus: received AUDIOFOCUS_LOSS_TRANSIENT"); - mReceiver.EnableSlimbus(RESET_SLIMBUS_DATA_PORT); + if (mReceiver != null) + mReceiver.EnableSlimbus(RESET_SLIMBUS_DATA_PORT); if (true == isFmRecordingOn()) stopRecording(); case AudioManager.AUDIOFOCUS_LOSS_TRANSIENT_CAN_DUCK: @@ -1599,7 +1600,8 @@ public class FMRadioService extends Service case AudioManager.AUDIOFOCUS_LOSS: Log.v(LOGTAG, "AudioFocus: received AUDIOFOCUS_LOSS"); //intentional fall through. - mReceiver.EnableSlimbus(RESET_SLIMBUS_DATA_PORT); + if (mReceiver != null) + mReceiver.EnableSlimbus(RESET_SLIMBUS_DATA_PORT); if (mSpeakerPhoneOn) { mSpeakerDisableHandler.removeCallbacks(mSpeakerDisableTask); -- GitLab