I would like to give specific events when typing Bluetooth keyboard.
My app is always running as a service.
When you input a key with Bluetooth keyboard, the following log is recorded.
/? I / WCNSS_FILTER: do_write: IBS write: fc
/? I / WCNSS_FILTER: Direction (1): bytes: 19: bytes_written: 19
/? D / InputReader: Input event (15): value = 1 when = 586669729008000
/? I / InputDispatcher: Delivering key to (1099): action: 0x0 (0)
/? D / ViewRootImpl: ViewPostImeInputStage processKey 0
/? D / SecContentProvider2: query (), uri = 15 selection = getToastEnabledState
/? D / SecContentProvider2: query (), uri = 15 selection = getToastShowPackageNameState
Is there a way to get the call to 'InputReader: Input event' from the service?
or should I use another method?
Related
I am trying to get audio working on a board to which we're porting Android.
Currently, sounds played with usages such as USAGE_ALARM (4) are audible, whereas sounds played with usages such as USAGE_MEDIA (1) are silent.
For the audible usages, we can see calls to the Audio HAL:
...
D AudioFlinger: Client defaulted notificationFrames to 11025 for frameCount 22050
D AF::TrackHandle: OpPlayAudio: track:64 usage:4 not muted
D audio_hw_primary: out_set_parameters: enter: kvpairs: routing=2
D audio_hw_primary: out_set_parameters: exit: code(0)
I audio_hw_primary: start_output_stream_primary... 0xf3856000, device 2, address , mode 0
I audio_hw_primary: select_output_device(), headphone 0 ,headset 0 ,speaker 2, earpiece 0,
I audio_hw_primary: get_card_for_device adev: 0xf3828000, device: 2, flag: 0, card_index: 0xf3856158
W audio_hw_primary: card 0, port 0 device 0x2
W audio_hw_primary: rate 48000, channel 2 period_size 0xc0
W StreamHAL: Error from HAL stream in function get_presentation_position: Operation not permitted
...
Whereas for silent usages, we see only:
...
D AudioFlinger: Client defaulted notificationFrames to 11025 for frameCount 22050
D AF::TrackHandle: OpPlayAudio: track:65 usage:1 not muted
W StreamHAL: Error from HAL stream in function get_presentation_position: Operation not permitted
...
I thought that /vendor/etc/audio_policy_configuration.xml might be important. I've paired it back to just having one output, but nothing has changed.
<attachedDevices>
<item>Speaker</item>
...
<defaultOutputDevice>Speaker</defaultOutputDevice>
<mixPorts>
<mixPort name="primary output" role="source" flags="AUDIO_OUTPUT_FLAG_PRIMARY">
<profile name="" format="AUDIO_FORMAT_PCM_16_BIT"
samplingRates="48000" channelMasks="AUDIO_CHANNEL_OUT_STEREO"/>
...
<devicePorts>
<devicePort tagName="Speaker" type="AUDIO_DEVICE_OUT_SPEAKER" role="sink" >
</devicePort>
...
<routes>
<route type="mix" sink="Speaker"
sources="primary output"/>
What part of AOSP is responsible for the routing of different usages?
Why do some work and other are silent?
DUMP OF SERVICE batterystats:
Battery History (0% used, 1584 used of 256KB, 6 strings using 492):
0 (9) RESET:TIME: 2016-03-07-15-59-54
0 (2) 092 c2501424 status=not-charging health=overheat plug=none temp=373 volt=4030 +running +wake_lock +mobile_radio +audio +screen data_conn=hspa phone_signal_strength=great brightness=bright fg=1000:"com.catalina.logdump"
0 (2) 092 c2501424 top=u0a68:"com.honeywell.testtools.suspendresumetest"
0 (2) 092 c2501424 user=0:"0"
0 (2) 092 c2501424 userfg=0:"0"
+69ms (2) 092 c2501424 status=discharging
AS the battery temp=373, it is showing health=overheat, That should not happen at all. Because of this health=overheat device notification LED will blink in RED.
Can anybody give me solution please.
I got the error in the kernel as
1) <3>[18810.893554, 1] bq27000-battery bq27000-battery: error reading register 18: -1
2)<3>[19205.674407, 0] bq27000-battery bq27000-battery: error reading nominal available capacity
3) BatteryService: Battery Led Mode is null
Along with this I am attaching bugreport file.
I want to send "CTRL + W" to the Chrome for Android to close active tab. I tried lots of things but there is no success to achieve it from terminal. (If i connect a USB Keyboard with OTG, i can close the tab with CTRL+W)
Firstly i do not want to write a application for this, i only want a shell command to use it from Tasker.
I read somewhere that to achieve this (CTRL+W keypress), i have to simulate key presses like this:
Down CTRL
Down W
Up W
Up CTRL
And to achieve this from terminal, it seems i have to use "sendevent".
I can simulate all hardware keypress with "sendevent" but can not simulate the normal keys with it.
For example, to down and up to the POWER key:
sendevent /dev/input/event1 1 116 1
sendevent /dev/input/event1 0 0 0
sendevent /dev/input/event1 1 116 0
sendevent /dev/input/event1 0 0 0
i use this commands, but i can not use this commands to send normal keys. (for example a,b,c etc)
The event1 is the gpio-keys, so i'm using it. And all the other input events are sensors and one is the charging driver. (max77693-muic)
The output of the "getevent -p" says that:
add device 1: /dev/input/event9
name: "compass_sensor"
events:
REL (0002): 0000 0001 0002 0003 0004 0005 0006 0007
0008 0009
input props:
<none>
add device 2: /dev/input/event6
name: "barometer_sensor"
events:
REL (0002): 0000 0001 0002
input props:
<none>
add device 3: /dev/input/event5
name: "light_sensor"
events:
REL (0002): 0000 0001 0002 0009
input props:
<none>
add device 4: /dev/input/event4
name: "proximity_sensor"
events:
ABS (0003): 0019 : value 1, min 0, max 1, fuzz 0, flat 0, resolution 0
input props:
<none>
add device 5: /dev/input/event3
name: "gyro_sensor"
events:
REL (0002): 0003 0004 0005
input props:
<none>
could not get driver version for /dev/input/mice, Not a typewriter
add device 6: /dev/input/event7
name: "Midas_WM1811 Midas Jack"
events:
KEY (0001): 0072 0073 00e2
SW (0005): 0002 0004
input props:
<none>
add device 7: /dev/input/event1
name: "gpio-keys"
events:
KEY (0001): 0072 0073 0074 00ac
input props:
<none>
add device 8: /dev/input/event0
name: "max77693-muic"
events:
KEY (0001): 0072 0073 00a3 00a4 00a5
input props:
<none>
add device 9: /dev/input/event8
name: "sec_touchkey"
events:
KEY (0001): 008b 009e
LED (0011): 0008
input props:
<none>
add device 10: /dev/input/event2
name: "sec_touchscreen"
events:
ABS (0003): 002f : value 0, min 0, max 9, fuzz 0, flat 0, resolution 0
0030 : value 0, min 0, max 255, fuzz 0, flat 0, resolution 0
0031 : value 0, min 0, max 255, fuzz 0, flat 0, resolution 0
0032 : value 0, min 0, max 30, fuzz 0, flat 0, resolution 0
0035 : value 0, min 0, max 719, fuzz 0, flat 0, resolution 0
0036 : value 0, min 0, max 1279, fuzz 0, flat 0, resolution 0
0039 : value 0, min 0, max 65535, fuzz 0, flat 0, resolution 0
003c : value 0, min -90, max 90, fuzz 0, flat 0, resolution 0
003d : value 0, min 0, max 1, fuzz 0, flat 0, resolution 0
input props:
INPUT_PROP_DIRECT
Also my gpio-keys layout file "/system/usr/keylayout/gpio-keys.kl" like this:
key 115 VOLUME_UP WAKE
key 114 VOLUME_DOWN WAKE
key 116 POWER WAKE
key 172 HOME WAKE
I can send all normal keyevents with:
"input keyevent KEYCODE_X"
and to send more than one:
"input keyevent KEYCODE_X KEYCODE_Y"
You should think it can works like this:
"input keyevent KEYCODE_CTRL_LEFT KEYCODE W"
but keyevent down and up immediatly and i can not use it to send CTRL+W combination.
I know, the answer should be with "sendevent". But i can not find.
I also tried to adding some fake keys into the key layout file like this:
key 115 VOLUME_UP WAKE
key 114 VOLUME_DOWN WAKE
key 116 POWER WAKE
key 172 HOME WAKE
key 19 Q
i restarted the phone, then tried:
sendevent /dev/input/event1 1 19 1
sendevent /dev/input/event1 0 0 0
sendevent /dev/input/event1 1 19 0
sendevent /dev/input/event1 0 0 0
But it never writes "Q" into the any textbox.
Please help, thanks for your helps.
Oh YES!! I dont know why but whenever I feel stuck I come to stackoverflow and as soon as I start writing the question somehow I find the answer... xD
Anyways, I was able to do it by following procedure:
Go to /system/usr/keylayout/
In my case there was no gpio-keys, anyways open Generic.kl
It has all the keycodes you would need to simulate anything... such as for CTRL_RIGHT keycode is 97 and for W keycode is 17
Thats all you need, now open tasker --> New task --> Add wait 5 sec --> Run shell:
input keyevent 97
input keyevent 17
Now run the command and quickly open chrome, voila! in 5 secs you will see your tab disappearing!
Hope that helps all the future tasker pros ;)
Kudos...
The events section in getevent -p output lists all accepted key codes:
add device 7: /dev/input/event1
name: "gpio-keys"
events:
KEY (0001): 0072 0073 0074 00ac
i.e. VOLUME_UP(0x73), VOLUME_DOWN(0x72), POWER(0x74) and HOME(0xAC) in case of /dev/input/event1. Everything else gets filtered out by the linux kernel input driver long before it reaches the Android framework (where the layout files you tried to modify are used)
Can you please let me know if there are any adb commands to get the state of MediaPlayer like, Play/Pause etc.
This is what i tried like below.
c:\>adb shell dumpsys media.player
Client
pid(3764), connId(94), status(0), looping(false)
AwesomePlayer
fd(40), flags(0x00000010), bitrate(48000 bps)
Track 1
MIME(audio/mpeg), decoder(OMX.google.mp3.decoder)
AudioOutput
stream type(3), left - right volume(1.000000, 1.000000)
msec per frame(0.000000), latency (-1)
aux effect id(0), send level (0.000000)
Client
pid(3764), connId(93), status(0), looping(false)
AwesomePlayer
fd(35), flags(0x00084014), bitrate(48000 bps)
Track 1
MIME(audio/mpeg), decoder(OMX.google.mp3.decoder)
AudioOutput
stream type(3), left - right volume(1.000000, 1.000000)
msec per frame(0.022676), latency (261)
aux effect id(0), send level (0.000000)
AudioTrack::dump
stream type(3), left - right volume(1.000000, 1.000000)
format(1), channel count(2), frame count(7680)
sample rate(44100), status(0)
state(2), latency (261)
No media recorder client
Files opened and/or mapped:
/proc/749/fd/35 -> /storage/sdcard1/Music/xxx/aaaa.mp3
/proc/749/fd/40 -> /storage/sdcard1/Music/xxx/bbbb.mp3
If you are just looking if Audio is Paused or Played.
You can try using
$ adb shell dumpsys audio
Remote Control stack entries (last is top of stack):
/*....
* Some Output Here...
*/
pi: PendingIntent{42feb5a8: PendingIntentRecord{42b6b748 com.google.android.music broadcastIntent}} -- pack: com.google.android.music -- ercvr: ComponentInfo{com.google.android.music/com.google.android.music.playback.MediaButtonIntentReceiver} -- client: android.media.IRemoteControlClient$Stub$Proxy#42e544d8 -- uid: 10059 -- type: 0 state: PLAYSTATE_PAUSED, 208457ms, 1.0X
Remote Control Client stack entries (last is top of stack):
uid: -1 -- id: 1 -- type: 0 -- state: PLAYSTATE_STOPPED, PLAYBACK_POSITION_INVALID, 1.0X -- vol handling: 1 -- vol: 15 -- volMax: 15 -- volObs: null
uid: -1 -- id: 8 -- type: 0 -- state: PLAYSTATE_STOPPED, PLAYBACK_POSITION_INVALID, 1.0X -- vol handling: 1 -- vol: 15 -- volMax: 15 -- volObs: null
uid: 10059 -- id: 9 -- type: 0 -- state: PLAYSTATE_PAUSED, 208457ms, 1.0X -- vol handling: 1 -- vol: 15 -- volMax: 15 -- volObs: null
In both, it shows if state is PLAYSTATE_PAUSED, PLAYSTATE_PLAYING or PLAYSTATE_STOPPED.
I even tried it on different device,
$ adb shell dumpsys audio
Remote Control stack entries:
pi: PendingIntent{41b84660: PendingIntentRecord{42239310 com.sonyericsson.music broadcastIntent}} -- ercvr: ComponentInfo{com.sonyericsson.music/com.sonyericsson.music.proxyservice.MediaButtonReceiver} -- client: android.media.IRemoteControlClient$Stub$Proxy#428b5528 -- uid: 10049 -- type: 0 state: 2
Remote Control Client stack entries:
uid: -1 -- id: 1 -- type: 0 -- state: 1 -- vol handling: 1 -- vol: 15 -- volMax: 15 -- volObs: null
uid: -1 -- id: 2 -- type: 0 -- state: 1 -- vol handling: 1 -- vol: 15 -- volMax: 15 -- volObs: null
uid: 10049 -- id: 5 -- type: 0 -- state: 2 -- vol handling: 1 -- vol: 15 -- volMax: 15 -- volObs: null
Here it shows the state:1 or state:2,
It basically the value for that.
PLAYSTATE_PLAYING
PLAYSTATE_PAUSED
PLAYSTATE_STOPPED
You could parse the output of the above to get these values.
Hopefully this is what you looking for.
Another way to tell will be from the state present in the AudioTrack::dump.
For instance, in your case:
AudioTrack::dump
stream type(3), left - right volume(1.000000, 1.000000)
format(1), channel count(2), frame count(7680)
sample rate(44100), status(0)
state(2), latency (261)
state(2) tells us that the media is paused/stopped. state(0) would mean that the media is playing and state(1) would mean that the playing media was interrupted by some pop-up.
I have a custom Android (2.3) running on a Beagleboard xM. Currently we are trying to replace a small resistive touchscreen with a bigger, capacitive one. However we can't seem to get the touch working with our android. (The resistive always worked fine).
The kernel modules are loaded and the driver is running. The driver outputs the correct touch coordinates when the screen is pressed.
/proc/bus/input/devices contains these entries:
I: Bus=0003 Vendor=0eef Product=7458 Version=0210
N: Name="eGalax Inc. eGalaxTouch EXC7200-7458"
P: Phys=usb-ehci-omap.0-2.3/input0
S: Sysfs=/devices/platform/ehci-omap.0/usb1/1-2/1-2.3/1-2.3:1.0/input/input2
U: Uniq=
H: Handlers=
B: EV=1b
B: KEY=421 0 30001 0 0 0 0 0 0 0 0
B: ABS=100 3f
B: MSC=10
I: Bus=0006 Vendor=0eef Product=0020 Version=0001
N: Name="eGalaxTouch Virtual Device for Multi"
P: Phys=
S: Sysfs=/devices/virtual/input/input5
U: Uniq=
H: Handlers=event2
B: EV=b
B: KEY=400 0 0 0 0 0 0 0 0 0 0
B: ABS=6608000 1000003
I: Bus=0006 Vendor=0eef Product=0010 Version=0001
N: Name="eGalaxTouch Virtual Device for Single"
P: Phys=
S: Sysfs=/devices/virtual/input/input6
U: Uniq=
H: Handlers=event3
B: EV=b
B: KEY=30000 0 0 0 0 0 0 0 0
B: ABS=3
which are correct, according to the guide for the device.
When touching the screen android shows this in logcat:
V/EventHub(10978): /dev/input/event2 got: t0=1594, t1=229858, type=0, code=0, v=0
D/InputReader(10978): Input event: device=0x10002 type=0x0 scancode=0 keycode=0 value=0
V/EventHub(10978): /dev/input/touchscreen0 got: t0=1594, t1=235198, type=3, code=53, v=788
D/InputReader(10978): Input event: device=0x10001 type=0x3 scancode=53 keycode=53 value=788
V/EventHub(10978): /dev/input/event2 got: t0=1594, t1=235198, type=3, code=53, v=788
D/InputReader(10978): Input event: device=0x10002 type=0x3 scancode=53 keycode=53 value=788
V/EventHub(10978): /dev/input/touchscreen0 got: t0=1594, t1=235382, type=3, code=54, v=1512
D/InputReader(10978): Input event: device=0x10001 type=0x3 scancode=54 keycode=54 value=1512
V/EventHub(10978): /dev/input/event2 got: t0=1594, t1=235382, type=3, code=54, v=1512
D/InputReader(10978): Input event: device=0x10002 type=0x3 scancode=54 keycode=54 value=1512
V/EventHub(10978): /dev/input/touchscreen0 got: t0=1594, t1=235473, type=3, code=0, v=788
D/InputReader(10978): Input event: device=0x10001 type=0x3 scancode=0 keycode=0 value=788
This also seems to be correct, the code 53 and 54 are for the X and Y coordinates.
However the android UI is not reacting to the touch inputs. Neither is our own app, nor the pointer painter from the development tools. Are the events not forwarded to the input dispatcher? The problem seems to be on the android side, but I cannot figure it out.
I hope someone can help me there or at least tell me where I can find additional information.