What is required to make Android use a new Audio HAL - android

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.

Related

Play the ToneGenerator cause ANR

When click the dialerpad, play the ToneGenerator, but cause ANR。
The log:
01-02 04:02:48.209 392 2548 E audio_hw_primary: out_write: error -5, cannot write stream data: I/O error
01-02 04:02:48.209 392 2548 D audio_hw_primary: out_standby: enter: stream (0xae38a800) usecase(0: deep-buffer-playback)
01-02 04:02:48.249 392 3038 E audio_hw_primary: out_write: error -5, cannot write stream data: I/O error
01-02 04:02:48.249 392 3038 D audio_hw_primary: out_standby: enter: stream (0xae3ed000) usecase(1: low-latency-playback)
01-02 04:02:48.772 423 1116 W AudioFlinger: write blocked for 10554 msecs, 50 delayed writes, thread 0xae883ec0
01-02 04:02:48.772 423 1116 D AudioFlinger: mixer(0xae883ec0) throttle end: throttle time(19)
01-02 04:02:49.579 1767 1767 E ToneGenerator: — Stop timed out
01-02 04:02:52.639 1767 1767 E ToneGenerator: — Delayed start timed out, status -110
01-02 04:02:52.639 1767 1767 W ToneGenerator: Tone start failed!!!, time 8178550
You can check the code: DialpadFragment.java--ToneGenerator:
private void playTone(int tone, int durationMs)
private void stopTone()
The ToneGenerator stop timed out cause the ANR. But what did ToneGenerator cause to stop timed out? How to analyze and fix this issue?
you can simply use and its work for me
ToneGenerator toneG = new ToneGenerator(AudioManager.STREAM_ALARM, 100);
toneG.startTone(ToneGenerator.TONE_CDMA_ALERT_CALL_GUARD, 200);

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

Android new project app crashes in debug mode

I just created a new empty project in Android Studio, and right away ran the app on my phone - it worked perfectly fine. But when I debug the project, it crashes as soon as the breakpoint reaches the end of the code.
Here's the code:
package app.harc.zhp.delete2;
import android.support.v7.app.AppCompatActivity;
import android.os.Bundle;
public class MainActivity extends AppCompatActivity {
#Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_main);
}
}
Could anyone help, or at least try to debug a new project on Android Studio 2.2 and tell if it's any different?
Everything is fine on a Virtual Device though.
Log:
10-06 23:43:52.029 D/DefContainer(32406): Copying /data/local/tmp/app.harc.zhp.delete2 to base.apk
10-06 23:43:52.466 I/PackageManager.DexOptimizer(894): Running dexopt (dex2oat) on: /data/app/vmdl735784381.tmp/base.apk pkg=app.harc.zhp.delete2 isa=arm vmSafeMode=false debuggable=true oatDir = /data/app/vmdl735784381.tmp/oat bootComplete=true
10-06 23:43:52.670 I/ActivityManager(894): Force stopping app.harc.zhp.delete2 appid=10166 user=-1: uninstall pkg
10-06 23:43:52.845 I/PackageManager(894): Package app.harc.zhp.delete2 codePath changed from /data/app/app.harc.zhp.delete2-1 to /data/app/app.harc.zhp.delete2-2; Retaining data and using new
10-06 23:43:52.845 I/ActivityManager(894): Force stopping app.harc.zhp.delete2 appid=10166 user=-1: replace pkg
10-06 23:43:52.846 W/PackageManager(894): Code path for app.harc.zhp.delete2 changing from /data/app/app.harc.zhp.delete2-1 to /data/app/app.harc.zhp.delete2-2
10-06 23:43:52.846 W/PackageManager(894): Resource path for app.harc.zhp.delete2 changing from /data/app/app.harc.zhp.delete2-1 to /data/app/app.harc.zhp.delete2-2
10-06 23:43:53.242 W/PackageManager(894): Couldn't remove dex file for package: at location /data/app/app.harc.zhp.delete2-1/base.apk, retcode=-1
10-06 23:43:53.254 I/ActivityManager(894): Force stopping app.harc.zhp.delete2 appid=10166 user=0: pkg removed
10-06 23:43:54.974 E/Drive.UninstallOperation(1390): Package still installed app.harc.zhp.delete2
10-06 23:43:55.261 I/ActivityManager(894): Force stopping app.harc.zhp.delete2 appid=10166 user=-1: set debug app
10-06 23:43:55.262 I/ActivityManager(894): START u0 {act=android.intent.action.MAIN cat=[android.intent.category.LAUNCHER] flg=0x10000000 cmp=app.harc.zhp.delete2/.MainActivity} from uid 2000 on display 0
10-06 23:43:55.591 I/ActivityManager(894): Start proc 32594:app.harc.zhp.delete2/u0a166 for activity app.harc.zhp.delete2/.MainActivity
10-06 23:43:55.659 W/ActivityThread(32594): Application app.harc.zhp.delete2 is waiting for the debugger on port 8100...
10-06 23:43:57.327 W/System (32594): ClassLoader referenced unknown path: /data/app/app.harc.zhp.delete2-2/lib/arm
10-06 23:43:57.332 I/InstantRun(32594): Instant Run Runtime started. Android package is app.harc.zhp.delete2, real application class is null.
10-06 23:43:58.147 I/Finsky (22410): [1] com.google.android.finsky.utils.PermissionPolicies$PermissionPolicyService.onStartCommand(117): post-install permissions check for app.harc.zhp.delete2
10-06 23:43:58.158 I/Finsky (22410): [1] com.google.android.finsky.utils.bn.run(1302): Package state data is missing for app.harc.zhp.delete2
10-06 23:43:58.368 W/System (32594): ClassLoader referenced unknown path: /data/app/app.harc.zhp.delete2-2/lib/arm
10-06 23:43:59.414 V/ApplicationReceiver:onReceive(32675): 2016-10-06 21:43:59-null-ApplicationReceiver detectes the installation of package:app.harc.zhp.delete2 ver:1.2.0
10-06 23:43:59.509 I/UpdateIcingCorporaServi(31885): Updating corpora: APPS=app.harc.zhp.delete2, CONTACTS=MAYBE
10-06 23:44:02.550 D/OnUpgrade(585): onReceive --- > package name (data string): package:app.harc.zhp.delete2
10-06 23:44:34.162 I/ActivityManager(894): Process app.harc.zhp.delete2 (pid 32594) has died
10-06 23:44:34.201 I/ActivityManager(894): Start proc 1898:app.harc.zhp.delete2/u0a166 for activity app.harc.zhp.delete2/.MainActivity
10-06 23:44:34.332 W/System (1898): ClassLoader referenced unknown path: /data/app/app.harc.zhp.delete2-2/lib/arm
10-06 23:44:34.334 I/InstantRun(1898): Instant Run Runtime started. Android package is app.harc.zhp.delete2, real application class is null.
10-06 23:44:34.493 W/System (1898): ClassLoader referenced unknown path: /data/app/app.harc.zhp.delete2-2/lib/arm
10-06 23:44:35.208 I/ActivityManager(894): Displayed app.harc.zhp.delete2/.MainActivity: +39s636ms
10-06 23:44:35.594 I/ActivityManager(894): Force stopping app.harc.zhp.delete2 appid=10166 user=0: from pid 1895
10-06 23:44:35.594 I/ActivityManager(894): Killing 1898:app.harc.zhp.delete2/u0a166 (adj 0): stop app.harc.zhp.delete2
10-06 23:44:35.606 I/WindowState(894): WIN DEATH: Window{92da02e u0 app.harc.zhp.delete2/app.harc.zhp.delete2.MainActivity}
10-06 23:44:35.694 W/ActivityManager(894): Force removing ActivityRecord{5907531 u0 app.harc.zhp.delete2/.MainActivity t2575}: app died, no saved state
10-06 23:44:35.726 W/ActivityManager(894): Spurious death for ProcessRecord{984b1eb 0:app.harc.zhp.delete2/u0a166}, curProc for 1898: null
10-06 23:44:44.631 I/ActivityManager(894): START u0 {act=android.intent.action.MAIN cat=[android.intent.category.LAUNCHER] flg=0x10200000 cmp=app.harc.zhp.delete2/.MainActivity (has extras)} from uid 10070 on display 0
10-06 23:44:44.700 I/ActivityManager(894): Start proc 2259:app.harc.zhp.delete2/u0a166 for activity app.harc.zhp.delete2/.MainActivity
10-06 23:44:44.853 W/System (2259): ClassLoader referenced unknown path: /data/app/app.harc.zhp.delete2-2/lib/arm
10-06 23:44:44.861 I/InstantRun(2259): Instant Run Runtime started. Android package is app.harc.zhp.delete2, real application class is null.
10-06 23:44:45.085 W/System (2259): ClassLoader referenced unknown path: /data/app/app.harc.zhp.delete2-2/lib/arm
10-06 23:44:45.774 I/ActivityManager(894): Displayed app.harc.zhp.delete2/.MainActivity: +1s100ms
10-06 23:44:48.343 I/WindowState(894): WIN DEATH: Window{cded2e4 u0 app.harc.zhp.delete2/app.harc.zhp.delete2.MainActivity EXITING}
10-06 23:44:48.383 I/ActivityManager(894): Process app.harc.zhp.delete2 (pid 2259) has died
10-06 23:45:20.869 I/ActivityManager(894): Force stopping app.harc.zhp.delete2 appid=10166 user=-1: set debug app
10-06 23:45:20.869 I/ActivityManager(894): START u0 {act=android.intent.action.MAIN cat=[android.intent.category.LAUNCHER] flg=0x10000000 cmp=app.harc.zhp.delete2/.MainActivity} from uid 2000 on display 0
10-06 23:45:20.909 I/ActivityManager(894): Start proc 3464:app.harc.zhp.delete2/u0a166 for activity app.harc.zhp.delete2/.MainActivity
10-06 23:45:20.963 W/ActivityThread(3464): Application app.harc.zhp.delete2 is waiting for the debugger on port 8100...
10-06 23:45:22.785 W/System (3464): ClassLoader referenced unknown path: /data/app/app.harc.zhp.delete2-2/lib/arm
10-06 23:45:22.790 I/InstantRun(3464): Instant Run Runtime started. Android package is app.harc.zhp.delete2, real application class is null.
10-06 23:45:22.971 W/System (3464): ClassLoader referenced unknown path: /data/app/app.harc.zhp.delete2-2/lib/arm
10-06 23:45:39.892 I/ActivityManager(894): Process app.harc.zhp.delete2 (pid 3464) has died
10-06 23:45:39.931 I/ActivityManager(894): Start proc 3892:app.harc.zhp.delete2/u0a166 for activity app.harc.zhp.delete2/.MainActivity
10-06 23:45:40.016 W/System (3892): ClassLoader referenced unknown path: /data/app/app.harc.zhp.delete2-2/lib/arm
10-06 23:45:40.021 I/InstantRun(3892): Instant Run Runtime started. Android package is app.harc.zhp.delete2, real application class is null.
10-06 23:45:40.166 W/System (3892): ClassLoader referenced unknown path: /data/app/app.harc.zhp.delete2-2/lib/arm
10-06 23:45:40.845 I/ActivityManager(894): Displayed app.harc.zhp.delete2/.MainActivity: +19s949ms
10-06 23:45:40.931 I/ActivityManager(894): Force stopping app.harc.zhp.delete2 appid=10166 user=0: from pid 3889
10-06 23:45:40.931 I/ActivityManager(894): Killing 3892:app.harc.zhp.delete2/u0a166 (adj 0): stop app.harc.zhp.delete2
10-06 23:45:40.946 I/WindowState(894): WIN DEATH: Window{39b6bfc u0 app.harc.zhp.delete2/app.harc.zhp.delete2.MainActivity}
10-06 23:45:40.983 W/ActivityManager(894): Force removing ActivityRecord{2ef5a72 u0 app.harc.zhp.delete2/.MainActivity t2577}: app died, no saved state
10-06 23:45:40.992 W/ActivityManager(894): Spurious death for ProcessRecord{481683 0:app.harc.zhp.delete2/u0a166}, curProc for 3892: null
10-06 23:46:02.406 I/ActivityManager(894): Force stopping app.harc.zhp.delete2 appid=10166 user=-1: set debug app
10-06 23:46:02.406 I/ActivityManager(894): START u0 {act=android.intent.action.MAIN cat=[android.intent.category.LAUNCHER] flg=0x10000000 cmp=app.harc.zhp.delete2/.MainActivity} from uid 2000 on display 0
10-06 23:46:02.425 I/ActivityManager(894): Start proc 4463:app.harc.zhp.delete2/u0a166 for activity app.harc.zhp.delete2/.MainActivity
10-06 23:46:02.473 W/ActivityThread(4463): Application app.harc.zhp.delete2 is waiting for the debugger on port 8100...
10-06 23:46:04.288 W/System (4463): ClassLoader referenced unknown path: /data/app/app.harc.zhp.delete2-2/lib/arm
10-06 23:46:04.291 I/InstantRun(4463): Instant Run Runtime started. Android package is app.harc.zhp.delete2, real application class is null.
10-06 23:46:04.533 W/System (4463): ClassLoader referenced unknown path: /data/app/app.harc.zhp.delete2-2/lib/arm
10-06 23:46:31.003 I/ActivityManager(894): Process app.harc.zhp.delete2 (pid 4463) has died
10-06 23:46:31.021 I/ActivityManager(894): Start proc 4979:app.harc.zhp.delete2/u0a166 for activity app.harc.zhp.delete2/.MainActivity
10-06 23:46:31.113 W/System (4979): ClassLoader referenced unknown path: /data/app/app.harc.zhp.delete2-2/lib/arm
10-06 23:46:31.115 I/InstantRun(4979): Instant Run Runtime started. Android package is app.harc.zhp.delete2, real application class is null.
10-06 23:46:31.297 W/System (4979): ClassLoader referenced unknown path: /data/app/app.harc.zhp.delete2-2/lib/arm
10-06 23:46:31.882 I/ActivityManager(894): Displayed app.harc.zhp.delete2/.MainActivity: +29s467ms
10-06 23:46:31.996 I/ActivityManager(894): Force stopping app.harc.zhp.delete2 appid=10166 user=0: from pid 4992
10-06 23:46:31.996 I/ActivityManager(894): Killing 4979:app.harc.zhp.delete2/u0a166 (adj 0): stop app.harc.zhp.delete2
10-06 23:46:32.011 I/WindowState(894): WIN DEATH: Window{7271944 u0 app.harc.zhp.delete2/app.harc.zhp.delete2.MainActivity}
10-06 23:46:32.083 W/ActivityManager(894): Force removing ActivityRecord{b4396be u0 app.harc.zhp.delete2/.MainActivity t2578}: app died, no saved state
10-06 23:46:32.098 W/ActivityManager(894): Spurious death for ProcessRecord{dabc29 0:app.harc.zhp.delete2/u0a166}, curProc for 4979: null
add this in dependencies --
'compile 'com.android.support:multidex:1.0.1'
and also add below code in application class --
MultiDex.install(this);

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

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