diff options
author | Matt Garnes <matt@cyngn.com> | 2016-05-10 15:30:22 -0700 |
---|---|---|
committer | Gerrit Code Review <gerrit@cyanogenmod.org> | 2016-05-11 16:17:53 -0700 |
commit | 801a2348713d5ebb819127ee81b2f2cf95aa39e0 (patch) | |
tree | 9324d0f8da22d53a4dd1abb587fa3fd2300e610b | |
parent | 256268f3d2de20ff3185d87957609d15e853fc70 (diff) | |
download | frameworks_base-801a2348713d5ebb819127ee81b2f2cf95aa39e0.zip frameworks_base-801a2348713d5ebb819127ee81b2f2cf95aa39e0.tar.gz frameworks_base-801a2348713d5ebb819127ee81b2f2cf95aa39e0.tar.bz2 |
Add hotword AudioService null check
If an application tries to start recording with the HOTWORD input before
AudioService is ready, the interface is not available to call
handleHotwordInput on. Check for null and only log if AudioService is
not available.
Change-Id: I2e693c5aed7cdce6299d8ff16341c1af8dd5b54f
Issue-Id: FOR-257
-rw-r--r-- | media/java/android/media/AudioRecord.java | 9 |
1 files changed, 8 insertions, 1 deletions
diff --git a/media/java/android/media/AudioRecord.java b/media/java/android/media/AudioRecord.java index e819b8a..c96690b 100644 --- a/media/java/android/media/AudioRecord.java +++ b/media/java/android/media/AudioRecord.java @@ -974,7 +974,14 @@ public class AudioRecord final IBinder b = ServiceManager.getService(android.content.Context.AUDIO_SERVICE); final IAudioService ias = IAudioService.Stub.asInterface(b); try { - ias.handleHotwordInput(listening); + // If the caller tries to start recording with the HOTWORD input + // before AUDIO_SERVICE has started, IAudioService may not be available. + if (ias != null) { + ias.handleHotwordInput(listening); + } else { + Log.e(TAG, "Error talking to AudioService when handling hotword input, " + + "AudioService unavailable"); + } } catch (RemoteException e) { Log.e(TAG, "Error talking to AudioService when handling hotword input.", e); } |