Webview - Window already focused, ignored focus gain - android

My application has Vimeo HTML5WebView integrated. The video is working fine, when it is portrait mode(on all devices), but when the orientation is changed to landscape, the video starts to flicker.This is happening in tablets - in 7 and 10 inch tablets. When the video flickers, I get a warning in the logcat saying, the window already focused, ignored focus gain.Please refer to the logcat below.
I tried looking at various questions on StackOverflow, but couldn't get a decent solution.
12-13 14:15:11.730: D/dalvikvm(505): JIT code cache reset in 1 ms (1048548 bytes 8/0)
12-13 14:15:11.740: D/dalvikvm(505): GC_EXPLICIT freed 868K, 25% free 18906K/24960K, paused 5ms+7ms, total 131ms
12-13 14:15:12.521: W/InputMethodManagerService(505): Window already focused, ignoring focus gain of: com.android.internal.view.IInputMethodClient$Stub$Proxy#4286b2f0 attribute=null, token = android.os.BinderProxy#42458f80
12-13 14:15:12.531: V/PhoneStatusBar(587): setLightsOn(true)
12-13 14:15:12.621: V/PhoneStatusBar(587): setLightsOn(true)
12-13 14:15:16.915: I/AwesomePlayer(180): cache is running low (1.58 secs) , pausing.
12-13 14:15:16.915: W/MediaPlayer(22724): info/warning (703, 1843)
12-13 14:15:16.915: W/MediaPlayer(22724): info/warning (701, 0)
12-13 14:15:16.925: I/MediaPlayer(22724): Info (703,1843)
12-13 14:15:16.925: I/MediaPlayer(22724): Info (701,0)
12-13 14:15:19.928: D/audio_hw_primary(180): out_standby: enter: usecase(1: low-latency-playback)
12-13 14:15:19.988: D/audio_hw_primary(180): stop_output_stream: enter: usecase(1: low-latency-playback)
12-13 14:15:19.988: D/audio_hw_primary(180): disable_audio_route: reset mixer path: low-latency-playback
12-13 14:15:19.988: D/audio_hw_primary(180): disable_snd_device: snd_device(2: speaker)
12-13 14:15:19.998: D/audio_hw_primary(180): stop_output_stream: exit: status(0)
12-13 14:15:19.998: D/audio_hw_primary(180): out_standby: exit
12-13 14:15:27.916: I/AwesomePlayer(180): cache has filled up (6.09 secs), resuming.
12-13 14:15:27.916: W/MediaPlayer(22724): info/warning (702, 0)
12-13 14:15:27.936: D/audio_hw_primary(180): start_output_stream: enter: usecase(1: low-latency-playback) devices(0x2)
12-13 14:15:27.936: D/audio_hw_primary(180): select_devices: out_snd_device(2: speaker) in_snd_device(0: none)
12-13 14:15:27.936: D/audio_hw_primary(180): enable_snd_device: sending audio calibration for snd_device(2) acdb_id(14)
12-13 14:15:27.936: D/ACDB-LOADER(180): ACDB -> send_afe_cal
12-13 14:15:27.936: D/audio_hw_primary(180): enable_snd_device: snd_device(2: speaker)
12-13 14:15:27.946: D/audio_hw_primary(180): enable_audio_route: apply mixer path: low-latency-playback
12-13 14:15:27.956: D/audio_hw_primary(180): start_output_stream: exit
12-13 14:15:28.016: I/MediaPlayer(22724): Info (702,0)
12-13 14:15:29.608: I/InputReader(505): Reconfiguring input devices. changes=0x00000004
12-13 14:15:29.608: I/InputReader(505): Device reconfigured: id=6, name='elan-touchscreen', size 1200x1920, orientation 1, mode 1, display id 0
12-13 14:15:29.608: I/InputReader(505): Reconfiguring input devices. changes=0x00000004
12-13 14:15:29.608: I/InputReader(505): Device reconfigured: id=6, name='elan-touchscreen', size 1200x1920, orientation 1, mode 1, display id 0
12-13 14:15:29.608: I/ActivityManager(505): Config changes=1480 {1.0 404mcc?mnc en_US ldltr sw600dp w960dp h527dp 320dpi lrg land finger -keyb/v/h -nav/h s.51}
12-13 14:15:29.678: D/audio_hw_primary(180): adev_set_parameters: enter: rotation=90
12-13 14:15:29.678: D/audio_hw_primary(180): adev_set_parameters: exit with code(0)
12-13 14:15:29.748: D/PhoneStatusBar(587): mSettingsPanelGravity = 8388661
12-13 14:15:29.808: V/PhoneStatusBar(587): setLightsOn(true)
12-13 14:15:29.828: I/WindowManager(505): Screen frozen for +274ms due to Window{4290b200 u0 Panel:com.xx.xxx/com.xx.xxx.WebViewActivity}
12-13 14:15:29.908: E/CABL(203): MSMFB_HISTOGRAM_STOP failed!
12-13 14:15:31.970: D/dalvikvm(505): GC_EXPLICIT freed 858K, 25% free 18826K/24960K, paused 7ms+5ms, total 120ms
12-13 14:15:32.911: W/InputMethodManagerService(505): Window already focused, ignoring focus gain of: com.android.internal.view.IInputMethodClient$Stub$Proxy#4283d658 attribute=null, token = android.os.BinderProxy#42458f80
12-13 14:15:32.921: V/PhoneStatusBar(587): setLightsOn(true)
12-13 14:15:32.961: V/PhoneStatusBar(587): setLightsOn(true)
12-13 14:15:35.924: I/AwesomePlayer(180): cache is running low (1.84 secs) , pausing.
12-13 14:15:35.934: W/MediaPlayer(22724): info/warning (703, 1811)
12-13 14:15:35.934: W/MediaPlayer(22724): info/warning (701, 0)
12-13 14:15:35.934: I/MediaPlayer(22724): Info (703,1811)
12-13 14:15:35.934: I/MediaPlayer(22724): Info (701,0)
12-13 14:15:36.064: W/InputMethodManagerService(505): Window already focused, ignoring focus gain of: com.android.internal.view.IInputMethodClient$Stub$Proxy#423e5920 attribute=null, token = android.os.BinderProxy#42458f80
12-13 14:15:36.074: V/PhoneStatusBar(587): setLightsOn(true)
12-13 14:15:36.184: V/PhoneStatusBar(587): setLightsOn(true)
12-13 14:15:36.785: W/MediaPlayer(22724): info/warning (702, 0)
12-13 14:15:36.785: I/MediaPlayer(22724): Info (702,0)
12-13 14:15:37.045: I/NuCachedSource2(180): new range: offset= 32665175
12-13 14:15:38.967: D/audio_hw_primary(180): out_standby: enter: usecase(1: low-latency-playback)
12-13 14:15:39.007: D/audio_hw_primary(180): stop_output_stream: enter: usecase(1: low-latency-playback)
12-13 14:15:39.007: D/audio_hw_primary(180): disable_audio_route: reset mixer path: low-latency-playback
12-13 14:15:39.007: D/audio_hw_primary(180): disable_snd_device: snd_device(2: speaker)
12-13 14:15:39.007: D/audio_hw_primary(180): stop_output_stream: exit: status(0)
12-13 14:15:39.007: D/audio_hw_primary(180): out_standby: exit
12-13 14:15:39.978: D/audio_hw_primary(180): start_output_stream: enter: usecase(1: low-latency-playback) devices(0x2)
12-13 14:15:39.978: D/audio_hw_primary(180): select_devices: out_snd_device(2: speaker) in_snd_device(0: none)
12-13 14:15:39.978: D/audio_hw_primary(180): enable_snd_device: sending audio calibration for snd_device(2) acdb_id(14)
12-13 14:15:39.978: D/ACDB-LOADER(180): ACDB -> send_afe_cal
12-13 14:15:39.978: D/audio_hw_primary(180): enable_snd_device: snd_device(2: speaker)
12-13 14:15:39.978: D/audio_hw_primary(180): enable_audio_route: apply mixer path: low-latency-playback
12-13 14:15:39.978: I/AwesomePlayer(180): cache is running low (0.07 secs) , pausing.
12-13 14:15:39.978: W/MediaPlayer(22724): info/warning (703, 1625)
12-13 14:15:39.978: W/MediaPlayer(22724): info/warning (701, 0)
12-13 14:15:39.978: W/MediaPlayer(22724): info/warning (702, 0)
12-13 14:15:39.988: V/PhoneStatusBar(587): setLightsOn(true)
12-13 14:15:39.988: D/audio_hw_primary(180): start_output_stream: exit
12-13 14:15:40.008: V/PhoneStatusBar(587): setLightsOn(true)
12-13 14:15:40.088: I/MediaPlayer(22724): Info (703,1625)
12-13 14:15:40.088: I/MediaPlayer(22724): Info (701,0)
12-13 14:15:40.088: I/MediaPlayer(22724): Info (702,0)
12-13 14:15:40.088: W/InputMethodManagerService(505): Window already focused, ignoring focus gain of: com.android.internal.view.IInputMethodClient$Stub$Proxy#4221e640 attribute=null, token = android.os.BinderProxy#42458f80
12-13 14:15:40.969: I/AwesomePlayer(180): cache is running low (1.45 secs) , pausing.
12-13 14:15:40.969: W/MediaPlayer(22724): info/warning (703, 1625)
12-13 14:15:40.969: W/MediaPlayer(22724): info/warning (701, 0)
12-13 14:15:40.969: I/MediaPlayer(22724): Info (703,1625)
12-13 14:15:40.969: I/MediaPlayer(22724): Info (701,0)
12-13 14:15:42.640: D/dalvikvm(22724): GC_FOR_ALLOC freed 420K, 4% free 11555K/12012K, paused 24ms, total 24ms
12-13 14:15:43.101: W/InputMethodManagerService(505): Window already focused, ignoring focus gain of: com.android.internal.view.IInputMethodClient$Stub$Proxy#4215b9e0 attribute=null, token = android.os.BinderProxy#42458f80
Please let me know, if the webview code helps, and I will add it to my question. From the questions that I have seen on StackOverflow, I feel, this might be a configuration issue, and in my code for webview, I have overwritten, onConfigurationChanged() and also included, android:configChanges to WebViewActivity.
#Override
public void onConfigurationChanged(Configuration newConfig) {
super.onConfigurationChanged(newConfig);
}
<activity android:name=".WebViewActivity"
android:configChanges="keyboardHidden|orientation|screenSize"/>
Thanks for your help!!!

By placing
android:configChanges="orientation"
for your activity, you are indicating to the system that your activity will handle the orientation change. But you are not really doing anything because all you are doing is:
super.onConfigurationChanged(newConfig);
So, how to solve your issue?
You said you are having the issue when orientation changes occur only on large screens (tablets) and esp. when changing from portrait to landscape. Yo don't see the issue when orientation changes occur on phone devices.
It makes me think that the video quality might not be of good enough quality to be played in landscape mode. Is that true? i.e if you start your activity in the landscape mode initially, do you still see the flickering?
Are you sure it's not a device specific issue? i.e does this issue you described occur on all large screen devices or just one that you are testing?
You have said you are using Vimeo HTML5WebView to render the video. Have you tried on a regular WebView that the platform provides and does similar issues happen with the framework provided widget as well?
Last but not least, you can always save the state of the player (like the timestamp where the video is before orientation) and then use that state to restore your webview after orientation changes. To do that, stop handling configuration yourself and then follow the guidelines mentioned in Saving Activity State and Handling configuration changes and Handling Runtime Changes. If you are absolutely convinced you can handle config changes yourself, then go ahead and do it but don't just call super and expect the system to magically handle the activities object states for you.
Hope this helps.

Best solution every one does is during changes between modes landscape to portrait or portrait to landscape pause the video and leave foucus of webview ie set focus false to webview and after complete restore of the webview gain the focus and play the video. offcouse u need to do some extra java script coding and javascript bridge coding but solution will work.

Related

ACTION_VOICE_COMMAND doesn't do anything

I'm using this code snippet to activate voice command on android.
Intent newIntent = new Intent(Intent.ACTION_VOICE_COMMAND);
newIntent.setFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
getApplicationContext().sendBroadcast(newIntent);
it doesn't do anything, not even an error in my log cat:
06-03 13:26:24.325 203-822/? D/audio_hw_primary: out_set_parameters: enter: usecase(1: low-latency-playback) kvpairs: routing=2
06-03 13:26:24.335 203-822/? D/audio_hw_primary: select_devices: out_snd_device(2: speaker) in_snd_device(0: none)
06-03 13:26:24.335 203-822/? D/msm8974_platform: platform_send_audio_calibration: sending audio calibration for snd_device(2) acdb_id(15)
06-03 13:26:24.335 203-822/? D/audio_hw_primary: enable_snd_device: snd_device(2: speaker)
06-03 13:26:24.338 203-822/? D/audio_hw_primary: enable_audio_route: apply and update mixer path: low-latency-playback
--------- beginning of system
06-03 13:26:26.277 786-892/? D/ConnectivityService: notifyType CAP_CHANGED for NetworkAgentInfo [WIFI () - 100]
06-03 13:26:27.551 203-822/? D/audio_hw_primary: disable_audio_route: reset and update mixer path: low-latency-playback
disable_snd_device: snd_device(2: speaker)
when I run this in ADB, it brings the google assistant up:
adb shell am start -a android.intent.action.VOICE_COMMAND
which is weird, it's technically the very same thing.
is there permission i'm missing or something?
From Docs
Activity Action: Start Voice Command.
So to bring up the voice command assistant activity, Use startActivityas
getApplicationContext().startActivity(newIntent);
instead of
getApplicationContext().sendBroadcast(newIntent);
like
Intent newIntent = new Intent(Intent.ACTION_VOICE_COMMAND);
newIntent.setFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
getApplicationContext().startActivity(newIntent);
// ^^^^^^^^^^^^
is there a way for the UI not to come up and cover my UI? or at least
for google assistant to go away after it listened and acted on my
voice command?
You can use Google Assistant Service sdk and here is the android quick start guide

What is required to make Android use a new Audio HAL

I am writing a new Android Audio HAL, to let my App to feed audio to other apps, to allow my handheld remote microphone input to reach Google app. Essentially, a Virtual Audio Cable.
Its a work in progress.
I'll probably be overriding AUDIO_DEVICE_IN_BACK_MIC, but this is open for suggestions.
I have doubts on how to make sure Android uses this HAL for input.
Do I need to replace audio.primary.default.so or should I leave it as audio.vcable.default.so?
More specifically: If I am not replacing primary, how will Android know to use my HAL instead of primary?
Update:
I could really use any help in this work. Any pointers are helpful.
I have written an Audio HAL module. I have added following (bold items) to audio_policy.conf:
global:
global_configuration {
attached_output_devices AUDIO_DEVICE_OUT_SPEAKER|**AUDIO_DEVICE_OUT_LINE**
default_output_device AUDIO_DEVICE_OUT_SPEAKER
attached_input_devices AUDIO_DEVICE_IN_BUILTIN_MIC|AUDIO_DEVICE_IN_BACK_MIC|AUDIO_DEVICE_IN_REMOTE_SUBMIX|**AUDIO_DEVICE_IN_LINE**
}
and under audio_hw_modules
vloop {
inputs {
vloop {
sampling_rates 16000
channel_masks AUDIO_CHANNEL_IN_MONO
formats AUDIO_FORMAT_PCM_16_BIT
devices AUDIO_DEVICE_IN_LINE
}
}
outputs {
vloop {
sampling_rates 16000
channel_masks AUDIO_CHANNEL_OUT_STEREO
formats AUDIO_FORMAT_PCM_16_BIT
devices AUDIO_DEVICE_OUT_LINE
flags AUDIO_OUTPUT_FLAG_DIRECT
}
}
}
I also added following (bold) to AudioFlinger.cpp
static const char * const audio_interfaces[] = {
AUDIO_HARDWARE_MODULE_ID_PRIMARY,
AUDIO_HARDWARE_MODULE_ID_A2DP,
AUDIO_HARDWARE_MODULE_ID_USB,
**AUDIO_HARDWARE_MODULE_ID_VLOOP**
};
I can see that during boot, my HAL gets loaded, and I get these logs:
10-06 06:14:40.365 194-194/? I/AudioFlinger: Using default 3000 mSec as standby time.
10-06 06:14:46.664 194-194/? I/AudioPolicyService: AudioPolicyService CSTOR in new mode
10-06 06:14:46.673 194-194/? I/APM::ConfigParsingUtils: loadAudioPolicyConfig() loaded /system/etc/audio_policy.conf
10-06 06:14:46.681 194-194/? D/audio_hw_primary: adev_open: enter
10-06 06:14:46.797 194-194/? I/AudioFlinger: loadHwModule() Loaded primary audio interface from QCOM Audio HAL (audio) handle 1
10-06 06:14:46.797 194-194/? I/AudioFlinger: openOutput(), module 1 Device 2, SamplingRate 48000, Format 0x000001, Channels 3, flags 2
10-06 06:14:46.797 194-194/? I/AudioFlinger: AudioStreamOut::open(), mHalFormatIsLinearPcm = 1
10-06 06:14:46.798 194-194/? I/AudioFlinger: HAL output buffer size 240 frames, normal sink buffer size 960 frames
10-06 06:14:46.813 194-194/? I/AudioFlinger: Using module 1 has the primary audio interface
10-06 06:14:46.816 194-607/? I/AudioFlinger: AudioFlinger's thread 0xb4140000 ready to run
10-06 06:14:46.816 194-607/? D/audio_hw_primary: out_set_parameters: enter: usecase(1: low-latency-playback) kvpairs: routing=2
10-06 06:14:46.818 194-194/? I/AudioFlinger: openOutput(), module 1 Device 2, SamplingRate 48000, Format 0x000001, Channels 3, flags 8
10-06 06:14:46.818 194-194/? I/AudioFlinger: AudioStreamOut::open(), mHalFormatIsLinearPcm = 1
10-06 06:14:46.818 194-194/? I/AudioFlinger: HAL output buffer size 960 frames, normal sink buffer size 960 frames
10-06 06:14:46.818 194-608/? I/AudioFlinger: AudioFlinger's thread 0xb3dc0000 ready to run
10-06 06:14:46.818 194-607/? E/AudioFlinger: no wake lock to update!
10-06 06:14:46.818 194-608/? D/audio_hw_primary: out_set_parameters: enter: usecase(0: deep-buffer-playback) kvpairs: routing=2
10-06 06:14:46.818 194-608/? E/AudioFlinger: no wake lock to update!
10-06 06:14:46.820 194-609/? I/AudioFlinger: AudioFlinger's thread 0xb3c40000 ready to run
10-06 06:14:46.823 194-194/? I/AudioFlinger: loadHwModule() Loaded a2dp audio interface from A2DP Audio HW HAL (audio) handle 7
10-06 06:14:46.828 194-194/? I/AudioFlinger: loadHwModule() Loaded usb audio interface from USB audio HW HAL (audio) handle 8
10-06 06:14:46.832 194-194/? I/r_submix: adev_open(name=audio_hw_if)
10-06 06:14:46.832 194-194/? I/AudioFlinger: loadHwModule() Loaded r_submix audio interface from Wifi Display audio HAL (audio) handle 9
10-06 06:14:46.832 194-194/? D/r_submix: submix_audio_device_create_pipe_l(addr=0, idx=9)
10-06 06:14:46.833 194-610/? I/AudioFlinger: AudioFlinger's thread 0xb3bc0000 ready to run
10-06 06:14:46.833 194-194/? D/r_submix: submix_audio_device_release_pipe_l(idx=9) addr=0
10-06 06:14:46.833 194-194/? D/r_submix: submix_audio_device_destroy_pipe_l(): pipe destroyed
10-06 06:14:46.835 194-194/? D/audio_vloop: adev_open: audio_hw_if
10-06 06:14:46.835 194-194/? D/audio_vloop: adev_open(): 1678
10-06 06:14:46.835 194-194/? D/audio_vloop: adev_open(): 1685
10-06 06:14:46.835 194-194/? D/audio_vloop: adev_open(): 1688
10-06 06:14:46.835 194-194/? D/audio_vloop: adev_open(): 1722
10-06 06:14:46.835 194-194/? D/audio_vloop: adev_init_check(): 1252
10-06 06:14:46.835 194-194/? D/audio_vloop: adev_set_master_volume: 1.000000
10-06 06:14:46.835 194-194/? D/audio_vloop: adev_set_master_mute: 0
10-06 06:14:46.835 194-194/? I/AudioFlinger: loadHwModule() Loaded vloop audio interface from UI_audio_HW_HAL (audio) handle 11
10-06 06:14:46.835 194-194/? D/audio_vloop: adev_open_input_stream(): 1490
10-06 06:14:46.835 194-194/? D/audio_vloop: in_get_sample_rate(): 979
10-06 06:14:46.835 194-194/? D/audio_vloop: in_get_channels(): 1017
10-06 06:14:46.835 194-194/? D/audio_vloop: in_get_channels: 0x00000001
10-06 06:14:46.835 194-194/? D/audio_vloop: in_get_format(): 1029
10-06 06:14:46.836 194-194/? D/audio_vloop: in_get_format: 0x00000001
10-06 06:14:46.836 194-194/? D/audio_vloop: in_get_format(): 1029
10-06 06:14:46.836 194-194/? D/audio_vloop: in_get_format: 0x00000001
10-06 06:14:46.836 194-194/? D/audio_vloop: in_get_channels(): 1017
10-06 06:14:46.836 194-194/? D/audio_vloop: in_get_channels: 0x00000001
10-06 06:14:46.836 194-194/? D/audio_vloop: in_get_buffer_size(): 1005
10-06 06:14:46.836 194-194/? D/audio_vloop: in_get_buffer_size: 1600
10-06 06:14:46.836 194-194/? D/audio_vloop: in_get_buffer_size(): 1005
10-06 06:14:46.836 194-194/? D/audio_vloop: in_get_buffer_size: 1600
10-06 06:14:46.836 194-194/? D/audio_vloop: in_get_format(): 1029
10-06 06:14:46.836 194-194/? D/audio_vloop: in_get_format: 0x00000001
10-06 06:14:46.836 194-194/? D/audio_vloop: in_get_sample_rate(): 979
10-06 06:14:46.836 194-194/? D/audio_vloop: in_get_channels(): 1017
10-06 06:14:46.836 194-194/? D/audio_vloop: in_get_channels: 0x00000001
10-06 06:14:46.838 194-613/? I/AudioFlinger: AudioFlinger's thread 0xb3bc0000 ready to run
10-06 06:14:46.838 194-194/? D/audio_vloop: adev_close_input_stream(): 1570
10-06 06:14:46.839 194-194/? W/APM::AudioPolicyManager: Input device 00020000 unreachable
10-06 06:14:46.839 194-611/? D/audio_vloop: looper_thread(): 216: Entered
10-06 06:14:46.839 194-611/? D/audio_vloop: looper_thread(): 366: Exiting
10-06 06:15:07.137 616-616/? I/InputManager: Initializing input manager, mUseDevInputEventForAudioJack=false
10-06 06:15:10.155 616-616/? I/SystemServer: Audio Service
10-06 06:15:10.222 194-607/? E/AudioFlinger: no wake lock to update!
10-06 06:15:10.222 194-608/? E/AudioFlinger: no wake lock to update!
10-06 06:15:10.224 194-614/? D/audio_hw_primary: adev_set_mic_mute: state 0
10-06 06:15:10.224 194-614/? D/audio_vloop: adev_set_mic_mute: 0
10-06 06:15:14.061 194-614/? D/audio_hw_primary: adev_set_parameters: enter: A2dpSuspended=false
10-06 06:15:14.061 194-614/? D/audio_vloop: adev_set_parameters(): [A2dpSuspended=false]
10-06 06:15:14.084 194-194/? I/AudioFlinger: systemReady
10-06 06:15:16.308 194-194/? D/audio_hw_primary: adev_set_mic_mute: state 0
10-06 06:15:16.308 194-194/? D/audio_vloop: adev_set_mic_mute: 0
10-06 06:15:17.072 194-194/? D/audio_hw_primary: adev_set_parameters: enter: A2dpSuspended=false
10-06 06:15:17.072 194-194/? D/audio_vloop: adev_set_parameters(): [A2dpSuspended=false]
10-06 06:15:25.023 733-733/? W/AudioTrack: AUDIO_OUTPUT_FLAG_FAST denied by client; transfer 4, track 44100 Hz, output 48000 Hz
10-06 06:15:25.032 194-607/? D/audio_hw_primary: out_set_parameters: enter: usecase(1: low-latency-playback) kvpairs: routing=2
10-06 06:15:25.043 194-607/? D/audio_hw_primary: select_devices: out_snd_device(2: speaker) in_snd_device(0: none)
10-06 06:15:25.043 194-607/? D/audio_hw_primary: enable_snd_device: snd_device(2: speaker)
10-06 06:15:25.050 194-607/? D/audio_hw_primary: enable_audio_route: apply and update mixer path: low-latency-playback
10-06 06:15:26.431 1150-1298/? I/MicrophoneInputStream: mic_starting com.google.android.apps.gsa.speech.audio.ag#c6eb0e1
10-06 06:15:26.443 194-1585/? I/AudioFlinger: AudioFlinger's thread 0xb3bc0000 ready to run
10-06 06:15:26.447 1150-1298/? I/MicrophoneInputStream: mic_started com.google.android.apps.gsa.speech.audio.ag#c6eb0e1
10-06 06:15:26.457 194-1585/? D/audio_hw_primary: select_devices: out_snd_device(0: none) in_snd_device(38: voice-rec-mic)
10-06 06:15:26.457 194-1585/? D/audio_hw_primary: enable_snd_device: snd_device(38: voice-rec-mic)
10-06 06:15:26.460 194-1585/? D/audio_hw_primary: enable_audio_route: apply and update mixer path: audio-record
10-06 06:15:26.942 1150-1271/? I/AudioController: internalShutdown
10-06 06:15:26.943 1150-1271/? I/MicrophoneInputStream: mic_close com.google.android.apps.gsa.speech.audio.ag#c6eb0e1
10-06 06:15:26.943 1150-1298/? E/AudioRecord-JNI: Error -4 during AudioRecord native read
10-06 06:15:26.986 194-1585/? D/audio_hw_primary: disable_audio_route: reset and update mixer path: audio-record
10-06 06:15:26.987 194-1585/? D/audio_hw_primary: disable_snd_device: snd_device(38: voice-rec-mic)
10-06 06:15:27.066 194-607/? D/audio_hw_primary: out_set_parameters: enter: usecase(1: low-latency-playback) kvpairs: routing=2
10-06 06:15:27.100 194-607/? D/AudioFlinger: mixer(0xb4140000) throttle end: throttle time(7)
10-06 06:15:30.257 194-607/? D/audio_hw_primary: disable_audio_route: reset and update mixer path: low-latency-playback
10-06 06:15:30.257 194-607/? D/audio_hw_primary: disable_snd_device: snd_device(2: speaker)
10-06 06:15:30.262 194-607/? D/audio_hw_primary: out_set_parameters: enter: usecase(1: low-latency-playback) kvpairs: routing=2
10-06 06:15:30.272 194-607/? D/audio_hw_primary: select_devices: out_snd_device(2: speaker) in_snd_device(0: none)
10-06 06:15:30.273 194-607/? D/audio_hw_primary: enable_snd_device: snd_device(2: speaker)
10-06 06:15:30.280 194-607/? D/audio_hw_primary: enable_audio_route: apply and update mixer path: low-latency-playback
10-06 06:15:30.347 194-607/? D/AudioFlinger: mixer(0xb4140000) throttle end: throttle time(10)
10-06 06:15:31.517 194-607/? D/audio_hw_primary: out_set_parameters: enter: usecase(1: low-latency-playback) kvpairs: routing=2
10-06 06:15:31.751 1150-1298/? I/MicrophoneInputStream: mic_starting com.google.android.apps.gsa.speech.audio.ag#dd13203
10-06 06:15:31.762 194-1826/? I/AudioFlinger: AudioFlinger's thread 0xb3bc0000 ready to run
10-06 06:15:31.771 1150-1298/? I/MicrophoneInputStream: mic_started com.google.android.apps.gsa.speech.audio.ag#dd13203
10-06 06:15:31.780 194-1826/? D/audio_hw_primary: select_devices: out_snd_device(0: none) in_snd_device(38: voice-rec-mic)
10-06 06:15:31.780 194-1826/? D/audio_hw_primary: enable_snd_device: snd_device(38: voice-rec-mic)
10-06 06:15:31.783 194-1826/? D/audio_hw_primary: enable_audio_route: apply and update mixer path: audio-record
10-06 06:15:34.695 194-607/? D/audio_hw_primary: disable_audio_route: reset and update mixer path: low-latency-playback
10-06 06:15:34.695 194-607/? D/audio_hw_primary: disable_snd_device: snd_device(2: speaker)
10-06 06:15:34.850 1150-1271/? I/AudioController: internalShutdown
10-06 06:15:34.851 1150-1271/? I/MicrophoneInputStream: mic_close com.google.android.apps.gsa.speech.audio.ag#dd13203
10-06 06:15:34.851 1150-1298/? E/AudioRecord-JNI: Error -4 during AudioRecord native read
10-06 06:15:34.885 194-1826/? D/audio_hw_primary: disable_audio_route: reset and update mixer path: audio-record
10-06 06:15:34.885 194-1826/? D/audio_hw_primary: disable_snd_device: snd_device(38: voice-rec-mic)
Mine is audio_vloop. I can see that Android opens my device, then opens input stream, and then closes the input stream. It never attempts to open output stream. audio_vloop implements both input and output streams. After this, nothing in audio_vloop is ever invoked by Android.
I made a small app that plays audio (from a pcm file for now). I want to redirect this output to my HAL. To achieve this, I believe I need to do a AudioTrack.setPreferredDevice() on my audio track. I found that Audio Manager should have a list of all audio devices.
so I call :
AudioDeviceInfo aDevInfo[] = am.getDevices(AudioManager.GET_DEVICES_OUTPUTS);
It only finds 1 device, more info on this device:
10-06 06:37:01.962 3295-3663/? D/AudioPlayer: Have [1] devices
10-06 06:37:01.964 3295-3663/? D/AudioPlayer: devInfo[0]: [Landroid.media.AudioDeviceInfo;#90bd9da
10-06 06:37:01.965 3295-3663/? D/AudioPlayer: getProductName()AOSP on Flo
10-06 06:37:01.965 3295-3663/? D/AudioPlayer: getType()2
10-06 06:37:01.966 3295-3663/? D/AudioPlayer: isSink()true
10-06 06:37:01.966 3295-3663/? D/AudioPlayer: isSource()false
This seemingly is from audioPort which I have not implemented. So its not from my HAL.
I've obviously missed one or more steps before Android will allow my app to talk to my device.
I need to be able to send audio from my app into my HAL.
Later, I also need to be able to receive audio from my HAL (through AudioRecord etc).
What did I missed in integrating my HAL into Android?
Do I need to implement Audio Ports?
Is something else required?
Update 2
I found there is a typo in AOSP, in AudioPolicyManager.cpp#2922
Instead of Output, it prints Input
I had this log AudioPolicyManager: Input device 00020000 unreachable which I disregarded assuming it is talking about BT/A2DP input device.
I fixed the log for my device, and it turns out to be Line out device which we want to use. I am debugging this direction now.
Found answers.
For out stream:
Outputs that don't support AUDIO_CHANNEL_OUT_STEREO are not being opened by Android
Outputs that mention flag AUDIO_OUTPUT_FLAG_DIRECT are not opened by Android automatically. This is evident in following code in AudioPolicyManager.cpp
if ((outProfile->mFlags & AUDIO_OUTPUT_FLAG_DIRECT) != 0) {
continue;
}
from here
There may be a way to open them in programatically, but I have not found answer to that.
These two, once fixed were sufficient for Android to start using my out stream.
For in stream:
In stream was already a part of results of AudioManager.getDevices()
So it was possible to read from vloop in stream after AudioTrack.setPreferredDevice().
To ensure that other apps will read mic input from vloop, I had to declare it to implement AUDIO_DEVICE_IN_BUILTIN_MIC. For this to work, I also removed AUDIO_DEVICE_IN_BUILTIN_MIC from primary HAL in audio_policy.conf.
Additionally, I made in stream stereo only to maintain compatibility with out stream buffer format.
After these changes, I see that there are continuous read and write calls coming to vloop.
UPDATE:
I later found that above mentioned behavior is dependent on Audio Policy Manager implementation. Most of them behave same way, (e.g. most open INBUILT_MIC for VOICE_RECOGNITION input) but some may not (Nexus Player) For these outliers, either implemnent what their APMs open, or modify APMs to open what your HAL implements.

Using bluetooth create_bond_out_of_band()

I need to force an Android phone to use oob data for pairing. That means I want the Android phone to have the "OOB Data Flag" being set, when the phone sends a Pairing Request to a device.
What I've tried so far: I've identified platform/system/bt to be the current (6.0.1) Android Bluetooth implementation and platform/packages/apps/Bluetooth being a Java wrapper around BT.
platform/system/bt exposes it's interface through a bt_interface_t structure. That structure contains a function named create_bond_out_of_bandthat should do what I need. Unfortunately, that function is not exposed by the Java Wrapper.
First I've tried to use the JNI function const bt_interface_t* android::getBluetoothInterface() from libbluetooth_jni.so. I managed to lookup that function during runtime, but when I call it, it returns 0. At that point, the app used already a lot of the bluetooth API.
This led me to the conclusion, that either, the shared object was loaded a second time, or that the bluetooth library is not part of my application, but somehow implemented in a different process.
Second, I've tried to use the Android libhardware API. I've managed to get the BT module, a BT device and finally call the create_bond_out_of_band() from the bt_interface_t. The function returns 0, which indicates success, but no Pairing Request is send out. I see following messages in the logs:
02-02 15:24:38.083 5791-5824/? E/bt_btif: btif_hh_virtual_unplug: Error, device C4:BE:84:BA:DA:0B not opened.
02-02 15:24:38.083 5791-5791/? E/Gatt: createBondOutOfBand: create_bond_out_of_band(0)
02-02 15:24:38.086 490-2881/? D/audio_hw_primary: out_set_parameters: enter: usecase(1: low-latency-playback) kvpairs: routing=2
02-02 15:24:38.101 490-2881/? D/audio_hw_primary: select_devices: out_snd_device(2: speaker) in_snd_device(0: none)
02-02 15:24:38.101 490-2881/? D/msm8974_platform: platform_send_audio_calibration: sending audio calibration for snd_device(2) acdb_id(101)
02-02 15:24:38.101 490-2881/? I/soundtrigger: audio_extn_sound_trigger_update_device_status: device 0x2 of type 0 for Event 1
02-02 15:24:38.108 490-2881/? D/msm8974_platform: platform_send_audio_calibration: sending audio calibration for snd_device(69) acdb_id(102)
02-02 15:24:38.108 490-2881/? D/audio_hw_primary: enable_snd_device: snd_device(69: vi-feedback)
02-02 15:24:38.108 490-2881/? D/audio_hw_primary: enable_audio_route: apply and update mixer path: spkr-vi-record
02-02 15:24:38.132 490-2881/? D/msm8974_platform: platform_send_audio_calibration: sending audio calibration for snd_device(27) acdb_id(4)
02-02 15:24:38.132 490-2881/? I/ACDB-LOADER: ACDB AFE returned = -19
02-02 15:24:38.133 490-2881/? D/audio_hw_primary: enable_audio_route: apply and update mixer path: low-latency-playback
02-02 15:24:38.672 490-2881/? D/audio_hw_primary: disable_audio_route: reset and update mixer path: low-latency-playback
02-02 15:24:38.674 490-2881/? D/audio_hw_primary: disable_snd_device: snd_device(2: speaker)
02-02 15:24:38.690 600-600/? E/QCALOG: [MessageQ] ProcessNewMessage: [LOWI-SERVER] unknown deliver target [OS-Agent]
02-02 15:24:38.693 490-2881/? D/audio_hw_primary: disable_snd_device: snd_device(69: vi-feedback)
02-02 15:24:38.693 490-2881/? D/audio_hw_primary: disable_audio_route: reset and update mixer path: spkr-vi-record
02-02 15:24:38.696 490-2881/? I/soundtrigger: audio_extn_sound_trigger_update_device_status: device 0x2 of type 0 for Event 0
C4:BE:84:BA:DA:0B is the device, I try to pair with.
Any ideas? How I can archive my goal or at least some pointers to where an active Android community can be found?
Thanks in advance,
Torsten

Android microphone input fails while in bluetooth on some devices

I'm working on doing voice recognition using the device microphone while connected to a bluetooth speaker. This works in most cases, but in a few devices I'm getting some failures.
After a few days of debugging, the best I can find is the following log difference:
Failure Log:
V/audio_hw_primary( 270): start_input_stream: enter: usecase(7)
V/voice ( 270): voice_check_and_set_incall_rec_usecase: voice call not active
V/audio_hw_primary( 270): start_input_stream: usecase(7)
D/PreProcess( 270): new SamsungRecord
D/PreProcess( 270): new NS
I/samsungRecord( 270): [samsungrecord] SamsungRecInit
I/samsungRecord( 270): [samsungrecordMIC]Use HardCoding Values
E/samsungRecord( 270): miccalib file can't created. (/data/snd/miccalib.txt)
I/samsungRecord( 270): 1
D/SamsungRecord_NS( 270): [SamsungRecord_NS] Init SR 8000
D/SamsungRecord_NS( 270): [SamsungRecord_NS] getLevel inputsource 6, ret_level 3
V/audio_hw_primary( 270): select_devices: ENTER
V/audio_hw_primary( 270): select_devices: usecase(normal)
V/audio_hw_primary( 270): select_devices: usecase(PCM_CAPTURE)
V/msm8974_platform( 270): platform_get_input_snd_device: enter: out_device(0) in_device(0x8)
V/msm8974_platform( 270): get_INPUT_snd_device: AUDIO_MODE_IN_CALL
E/msm8974_platform( 270): platform_get_input_snd_device: No output device set for voice call
V/msm8974_platform( 270): platform_get_input_snd_device: exit: in_snd_device(none)
V/audio_hw_primary( 270): start_input_stream: Opening PCM device card_id(0) device_id(0), channels 1
E/audio_hw_primary( 270): start_input_stream: cannot open device '/dev/snd/pcmC0D0c': Invalid argument
V/audio_hw_primary( 270): stop_input_stream: enter: usecase(7: audio-record)
V/audio_hw_primary( 270): disable_audio_route: enter: usecase(7)
V/audio_hw_primary( 270): disable_audio_route: reset mixer path: audio-record
D/audio_route( 270): ++++ audio_route_update_mixer ==============
D/audio_route( 270): ------ audio_route_update_mixer ==============
V/audio_hw_primary( 270): disable_audio_route: exit
E/audio_hw_primary( 270): disable_snd_device: Invalid sound device 0
V/audio_hw_primary( 270): stop_input_stream: exit: status(0)
D/audio_hw_primary( 270): start_input_stream: exit: status(-5)
V/audio_hw_primary( 270): in_standby: enter
V/audio_hw_primary( 270): in_standby: exit: status(0)
V/audio_hw_primary( 270): in_read: read failed - sleeping for buffer duration
Successful Log:
V/audio_hw_primary( 387): start_input_stream: enter: usecase(7)
V/voice ( 387): voice_check_and_set_incall_rec_usecase: voice call not active
V/audio_hw_primary( 387): start_input_stream: usecase(7)
D/PreProcess( 387): new SamsungRecord
D/PreProcess( 387): new NS
I/samsungRecord( 387): [samsungrecord] SamsungRecInit
I/samsungRecord( 387): [samsungrecordMIC]Use HardCoding Values
E/samsungRecord( 387): miccalib file can't created. (/data/snd/miccalib.txt)
I/samsungRecord( 387): 1
D/SamsungRecord_NS( 387): [SamsungRecord_NS] Init SR 8000
D/SamsungRecord_NS( 387): [SamsungRecord_NS] getLevel inputsource 6, ret_level 3
V/audio_hw_primary( 387): select_devices: ENTER
V/audio_hw_primary( 387): select_devices: usecase(normal)
V/audio_hw_primary( 387): select_devices: usecase(PCM_CAPTURE)
V/msm8974_platform( 387): platform_get_input_snd_device: enter: out_device(0) in_device(0x8)
V/msm8974_platform( 387): get_INPUT_snd_device: check by Input_source(6)
V/msm8974_platform( 387): platform_get_input_snd_device_by_source: enter: out_device(0) in_device(0x8)
V/msm8974_platform( 387): get_INPUT_snd_device: AUDIO_SOURCE_VOICE_RECOGNITION
V/msm8974_platform( 387): platform_get_input_snd_device: exit: in_snd_device(dummy)
D/audio_hw_primary( 387): select_devices: out_snd_device(0: dummy)
D/audio_hw_primary( 387): select_devices: in_snd_device(124: dummy)
D/ACDB-LOADER( 387): ACDB -> send_audio_cal, acdb_id = 49, path = 1
D/ACDB-LOADER( 387): ACDB -> send_adm_topology
D/ACDB-LOADER( 387): ACDB -> ACDB_CMD_GET_AUDPROC_COMMON_TOPOLOGY_ID
D/ACDB-LOADER( 387): ACDB -> send_audtable
D/ACDB-LOADER( 387): ACDB -> ACDB_CMD_GET_AUDPROC_COMMON_TABLE
D/ACDB-LOADER( 387): ACDB -> AUDIO_SET_AUDPROC_CAL
D/ACDB-LOADER( 387): ACDB -> send_audvoltable
D/ACDB-LOADER( 387): ACDB -> ACDB_CMD_GET_AUDPROC_GAIN_DEP_STEP_TABLE
D/ ( 387): Failed to fetch the lookup information of the device 00000031
E/ACDB-LOADER( 387): Error: ACDB AudProc vol returned = -19
D/ACDB-LOADER( 387): ACDB -> AUDIO_SET_AUDPROC_VOL_CAL
D/ACDB-LOADER( 387): ACDB -> AUDIO_SET_AFE_CAL
V/audio_hw_primary( 387): enable_snd_device: snd_device(124: dummy, dummy)
D/audio_route( 387): ++++ audio_route_update_mixer ==============
D/audio_route( 387): ------ audio_route_update_mixer ==============
V/audio_hw_primary( 387): enable_audio_route: enter: usecase(7)
V/audio_hw_primary( 387): enable_audio_route: apply mixer path: audio-record bt-sco
D/audio_route( 387): ++++ audio_route_update_mixer ==============
D/audio_route( 387): Setting mixer control: MultiMedia1 Mixer AUX_PCM_UL_TX, value: 1
D/audio_route( 387): ------ audio_route_update_mixer ==============
V/audio_hw_primary( 387): enable_audio_route: exit
V/audio_hw_primary( 387): start_input_stream: Opening PCM device card_id(0) device_id(0), channels 1
V/xappmedia.sdk.service.GoogleSpeechRecognizer(18053): Adjusted volume level: 0.0. RMSDB: -2.12
E/Global isDisableMicrophone(18053): isDisableMixrophone:true
E/MusicService(18053): XappAds VolumeLevel Callback OnRmsChanged: rmsDb: -2.12 adjustFol: 0.0
E/NowPlayingFragment OnReceive:(18053): onReceive 1
E/NowPlayingFragment OnReceive:(18053): Mic Animation 1
E/NowPlayingFragment OnReceive:(18053): Volume Change 1
E/NowPlayingFragment OnReceive:(18053): Volume Change 2: Mic Size: 300.0
E/NowPlayingFragment OnReceive:(18053): Volume Change 2: VOl: 0.0
E/NowPlayingFragment OnReceive:(18053): Draw Mic 1
V/audio_hw_primary( 387): start_input_stream: exit
It looks to me like its failing to open an input stream off of the mic. I can't find much information on this, but I think it's probably something to do with how i'm using audio focus. Anyone have any insights?

Audiotrack stops sound randomly, but state is STATE_INITIALIZED and PLAYSTATE_PLAYING

I'm looping and audiotrack with...
audioTrack.setLoopPoints(0, length, -1);
audioTrack.play();
But after random time (several minutes), it stop sounding, but state is STATE_INITIALIZED and PLAYSTATE_PLAYING.
In that moment, I get this message ...
09-20 19:32:27.989: D/audio_hw_primary(176): out_standby: enter: usecase(1: low-latency_playback)
09-20 19:32:28.039: D/audio_hw_primary(176): stop_output_stream: enter: usecase(1: low- latency-playback)
09-20 19:32:28.049: D/audio_hw_primary(176): disable_audio_route: reset mixer path: low-latency-playback
09-20 19:32:28.049: D/audio_hw_primary(176): disable_snd_device: snd_device(2: speaker)
09-20 19:32:28.049: D/audio_hw_primary(176): stop_output_stream: exit: status(0)
09-20 19:32:28.049: D/audio_hw_primary(176): out_standby: exit
I need to loop audiotrack limitless, please, anyone knows how to solve it ?
PD: The stop seems to happen only in versions 4.1 and later.
Seems like the phone is entering stand by, when you configured your MediaPlayer, did you get a wakelock?
yourMediaPlayer.setWakeMode(getApplicationContext(), PowerManager.PARTIAL_WAKE_LOCK);
Don't forget to release your mplayer later.

Categories

Resources