yashsingh1/xdaforums huggingface dataset:
[Galaxy S II Original Android Development] Tungstwenty:
I had also taken a look at that some time ago, in fact it was one of the first things I wanted to play around with after getting the kernel to compile and understanding what the heck a kernel was :)

I got into the wakelocks engine, the suspend / resume logic, etc. and did try to make the touch device go to sleep without powering down the led so it would keep displaying, if the BLN was active. Unfortunately, I didn't manage to make it work and from what I talked to GM about it, there were some issues with the power regulators, considering that they are chained and even if the one for the led is kept turned on, perhaps the parent ones would need to be kept on as well.

I think I'll revisit this when I have some free time, but I'm not too confident that it's feasible without letting a fair number of power drainers (screen, leds, proximity) on instead of only the led. Perhaps I can find someone who deeply understands the power regulators chains and how can it be controlled in a proper way so that only the actual led is wasting energy and still keep the device in deep sleep.
[Galaxy S II Original Android Development] rakeshishere:
It would be biggest breakthrough if Siyah implements BLN without wakelock
[Galaxy S II Original Android Development] janreiviardo:
Guys! I have made a thread which will allow you to create gestures easier. If you like it just hit thanks!

Link to thread
[Galaxy S II Original Android Development] Tungstwenty:
Thanks for a great visual guide!

I've updated the 2nd post with a link to your thread. :highfive:
[Galaxy S II Original Android Development] janreiviardo:
Glad to be of help. Infact this is a great feature and I love it! If I manage to have some time I might also make an app to automate the gestures.:highfive:
[Galaxy S II Original Android Development] zelenko:
Its posible to make script to enable/disable 2g/3g only ?
[Galaxy S II Original Android Development] Mahdi786:
Hi Tungtwenty, would your feature be hard to port to i9000? Like semaphore kernel?
[Galaxy S II Original Android Development] Tungstwenty:
I have searched the public and private APIs but didn't find any way to directly do it.

Also, when searching Google Play I didn't find any app that directly changed it - all of them only take you directly to the screen where you must manually change the setting.
[Galaxy S II Original Android Development] Tungstwenty:
It should be pretty straightforward; any i9000 kernel developer should be able to easily take my changes from this commit and apply them on his kernel. Some adjustments might be needed if the driver is not the same, but no big deal.

After that commit, I did this small adjustment in order to have more gestures.
[Galaxy S II Original Android Development] Mahdi786:
Cheers, I'm gonna have a word with them see if they can do it, excellent feature by the way.
[Galaxy S II Original Android Development] rakeshishere:
+1

I'll buy it on day 1 itself. It would give S2 a whole new capability
[Galaxy S II Original Android Development] ellimist87:
Keyevents

Hi Tungstwenty, first off thanks for the great work, this is really amazing, especially its implementation at the kernel level :)

Was just wondering, in regards to keyevents (I use mainly home, power and recent apps), my gestures don't seem to go through at times. Gestures directed at other actions (mdnie toggle or call toggle) seem to work flawlessly without fail. Keyevents however do stop responding occasionally for me.

Am on CM9.1 with Siyah of course. Was wondering if this is normal?
[Galaxy S II Original Android Development] Mahdi786:
I had the same problem, I stopped using keyevent and changed the code to sendevent, check the first page for the example.

# Long press power button

sendevent /dev/input/event1 1 116 1

sendevent /dev/input/event1 0 0 0

usleep 500000

sendevent /dev/input/event1 1 116 0

sendevent /dev/input/event1 0 0 0

# Simulate key press - Power

sendevent /dev/input/event1 1 116 1

sendevent /dev/input/event1 1 116 0

sendevent /dev/input/event1 0 0 0

# Simulate key press - Volume down

sendevent /dev/input/event1 1 114 1

sendevent /dev/input/event1 1 114 0

sendevent /dev/input/event1 0 0 0

# Simulate key press - Volume up

sendevent /dev/input/event1 1 115 1

sendevent /dev/input/event1 1 115 0

sendevent /dev/input/event1 0 0 0

# Simulate key press - Home

sendevent /dev/input/event1 1 102 1

sendevent /dev/input/event1 1 102 0

sendevent /dev/input/event1 0 0 0

sendevent work a lot faster than keyevent
[Galaxy S II Original Android Development] gaetanolip:
hi

wich are send event for home button and recent apps for sgs3??

thanks
[Galaxy S II Original Android Development] Mahdi786:
Recents would a long home button press, I'm not sure if its different on the gs3, maybe cm9 might have different codes to cm10, did you try the code above?

Hit thanks if I helped you :)
[Galaxy S II Original Android Development] Tungstwenty:
keyevent can send a lot of "special keys" that might not even exist physically - like Previous/Next Track, Recent Apps, for instance.

However, as reported by some of you, this doesn't always work.

Using sendevent, on the other hand, simulates physical interaction with the things that do exist: hard buttons, touch buttons, even touch screen coordinates.

To achieve recent apps, you'll need to queue the events of the hard home button Down for a certain time, before reporting it as Released. For Search, the same with the menu button. And so on. The "getevent" command can help you inspect what's going on when you manually interact with the several input sensors.

Please check the existing examples (including what I mentioned in the 3rd post about inspecting the events being generated) and see if it works for you.

As for the "mis-detection", if you want to make sure that the gesture is being detected and it's the triggering of the action that might be failing, you can request a small vibration whenever a gesture is fired, in order to know that at least that part is ok. Example:

GESTURE=`cat /sys/devices/virtual/misc/touch_gestures/wait_for_gesture`

[COLOR="Green"]# Feedback that a gesture was detected - 300ms vibration
service call vibrator 2 i32 300 i32 0
[/COLOR]
# Handle the actions
if [ "$GESTURE" -eq "1" ] ...
[Galaxy S II Original Android Development] gaetanolip:
Yes, recent apps is home long button. But what is the code of send event home button in ics and jelly bean sgs3 stock rom?

Inviato dal mio GT-I9300 con Tapatalk 2
[Galaxy S II Original Android Development] Tungstwenty:
Run "getevent" on a shell and after the initial lines interrupt (else you'll see lots of events related with the compass being updated). You'll get something like this (on my S2):

getevent
add device 1: /dev/input/event8
name: "compass_sensor"
add device 2: /dev/input/event7
name: "sec_touchkey"
add device 3: /dev/input/event6
name: "gyro_sensor"
add device 4: /dev/input/event5
name: "light_sensor"
add device 5: /dev/input/event4
name: "proximity_sensor"
add device 6: /dev/input/event3
name: "sii9234_rcp"
add device 7: /dev/input/event2
name: "sec_touchscreen"
add device 8: /dev/input/event1
name: "gpio-keys"
add device 9: /dev/input/event0
name: "max8997-muic"

In my case, I'd be monitoring the "/dev/input/event1" reported entries, since it's for "gpio-keys" (or physical keys). I'd then run "getevent | grep event1". The output would be this one, when playing around with physical keys:

# HOME key down
/dev/input/event1: 0001 0066 00000001
/dev/input/event1: 0000 0000 00000000

# HOME key up
/dev/input/event1: 0001 0066 00000000
/dev/input/event1: 0000 0000 00000000

# HOME key down
/dev/input/event1: 0001 0066 00000001
/dev/input/event1: 0000 0000 00000000

# HOME key up
/dev/input/event1: 0001 0066 00000000
/dev/input/event1: 0000 0000 00000000

# Power key down
/dev/input/event1: 0001 0074 00000001
/dev/input/event1: 0000 0000 00000000

# Power key up
/dev/input/event1: 0001 0074 00000000
/dev/input/event1: 0000 0000 00000000

# Power key down
/dev/input/event1: 0001 0074 00000001
/dev/input/event1: 0000 0000 00000000

# Power key up
/dev/input/event1: 0001 0074 00000000
/dev/input/event1: 0000 0000 00000000

(The blank lines and comments were inserted by me for clarity)

So on S2, to emulate the HOME key I'll need to send the code 102 (decimal of 0x66) with the 4 lines, with a proper delay between down and up, to ..../event1.

On the S3, the keycode and the name of the device might be different.

I hope this example can help you get the data for the S3, in case it's different.
[Galaxy S II Original Android Development] gaetanolip:
I run getevent but it shows continuous line, how to interrupt?

Inviato dal mio GT-I9300 con Tapatalk 2
[Galaxy S II Original Android Development] Tungstwenty:
Press Control+C to abort the running command, or if you like run "getevent | more" so you can do it more calmly. That way the output will pause after a number of lines, and you can press Enter to proceed with some more or press Control+C to abort.

If you're running this on a terminal app instead of a PC through adb, you need to check how to send Ctrl+C. Probably with VolumeDown + C or something similar.

After finding out which of the device names is the one for gpio-keys, run "getevent | grep <...device_name...>" to get the events only for that device, or "getevent | grep <...device_name...> | more" if you want to pause its output as well.
[Galaxy S II Original Android Development] gaetanolip:
Something. Wrong :

export PATH=/data/local/bin:$PATH

app_115@android:/ $ export PATH=/data/local/bin:$PATH

app_115@android:/ $ su

app_115@android:/ # getevent | more

could not get driver version for /dev/input/mice, Not a typewriter

add device 1: /dev/input/event10

name: "compass_sensor"

add device 2: /dev/input/event7

name: "light_sensor"

add device 3: /dev/input/event6

name: "proximity_sensor"

add device 4: /dev/input/event5

name: "barometer_sensor"

add device 5: /dev/input/event4

name: "gyro_sensor"

add device 6: /dev/input/event3

name: "sii9234_rcp"

add device 7: /dev/input/event8

name: "Midas_WM1811 Midas Jack"

add device 8: /dev/input/event1

name: "gpio-keys"

add device 9: /dev/input/event0

name: "max77693-muic"

add device 10: /dev/input/event9

name: "sec_touchkey"

add device 11: /dev/input/event2

name: "sec_touchscreen"

/dev/input/event10: 0002 0000 0000000b

/dev/input/event10: 0002 0001 000003e3

/dev/input/event10: 0002 0002 00000168

/dev/input/event10: 0000 0000 00000000

--More--

Then i open another terminal on phone

app_115@android:/ $ export PATH=/data/local/bin:$PATH

app_115@android:/ $ su

app_115@android:/ # getevent | grep event1 | more

could not get driver version for /dev/input/mice, Not a typewriter

add device 1: /dev/input/event10

add device 8: /dev/input/event1

/dev/input/event10: 0002 0000 00000034

/dev/input/event10: 0002 0001 000003e0

/dev/input/event10: 0002 0002 00000183

/dev/input/event10: 0000 0000 00000000

/dev/input/event10: 0002 0000 0000002f

/dev/input/event10: 0002 0001 000003e0

/dev/input/event10: 0002 0002 00000175

/dev/input/event10: 0000 0000 00000000

/dev/input/event10: 0002 0000 00000039

/dev/input/event10: 0002 0001 000003e3

/dev/input/event10: 0002 0002 00000167

/dev/input/event10: 0000 0000 00000000

/dev/input/event10: 0002 0000 0000003a

/dev/input/event10: 0002 0001 000003e4

/dev/input/event10: 0002 0002 00000156

/dev/input/event10: 0000 0000 00000000

/dev/input/event10: 0002 0000 00000037

/dev/input/event10: 0002 0001 000003ec

/dev/input/event10: 0002 0002 0000014c

/dev/input/event10: 0000 0000 00000000

/dev/input/event10: 0002 0000 0000002e

/dev/input/event10: 0002 0001 000003ee

/dev/input/event10: 0002 0002 00000144

/dev/input/event10: 0000 0000 00000000

--More--

what is wrong.?

Inviato dal mio GT-I9300 con Tapatalk 2
[Galaxy S II Original Android Development] Tungstwenty:
"... grep event1 ..." is capturing both /dev/input/event1 and /dev/input/event10 (the gyroscopic sensor, with lots of events.

Use "grep event1:" instead - the ":" will make it discard the event10 entries.
[Galaxy S II Original Android Development] ellimist87:
Thanks for the input, using sendevent now, works like a charm :)

Ah thanks for the explanation. Missed your example in post 3, see it now, sorry for that :)

Guess I'll stick to sendevent where hardware buttons exist, and use keyevent for stuff like media button and what nots
[Galaxy S II Original Android Development] Chillmann:
I have the same problem here and I couldn't get "send event" working at all. (maybe cause of rom depending event codes) Along with the input keyevent a broadcast intent:

am broadcast -a net.dinglisch.android.tasker.ACTION_TASK -e task_name "Task_name"

to call a Tasker task, stops working too. After adding a vibration feedback, I could verify that the gestures are detected correctly, but some actions like am broadcast and input keyevent are not executed sometimes. Any guesses on the cause of that?
[Galaxy S II Original Android Development] Tungstwenty:
Can you replicate that intermittent behavior using an adb console?

Also, I'm not sure whether for the task you need "am broadcast" or the more usual "am start". Did you attempt both?
[Galaxy S II Original Android Development] Chillmann:
When I use terminal emulator, am broadcast and input keyevent works fine.

Replacing am broadcast by am start didn't work to launch the task.

I used to use LMT-launcher from http://xdaforums.com/showthread.php?t=1330150

which never failed performing input keyevent or launching a script which uses am broadcast to call on a Taskers task.
[Galaxy S II Original Android Development] sibero80:
Alternative task kill

Hey there people, I tried using the task kill on the OP's post, but didnt work for me, after a lot of thinkering this worked like a charm:

kill `dumpsys activity top | awk 'match($0,"pid="){print substr($0,RSTART+4,5)}'`

On a side note, I also wanted to ask for help with an issue.

I've tried assigning an activity to launch the APP DRAWER,

The icon in the APEX LAUNCHER DB states as follows:

#Intent;action=com.anddoes.launcher.ACTION;component=com.anddoes.launcher/.Launcher;S.LAUNCHER_ACTION=APP_DRAWER;end

I tried using this activity without success:

com.anddoes.launcher/.Launcher

The point is, that if I use the gesture, in ANY app, the APP DRAWER will open... insted with that activity, it takes me to the home screen... and doesnt open the app drawer...

any ideas?
[Galaxy S II Original Android Development] sibero80:
It worked! thanks a lot! Didnt know the AM START was that picky! hehehe

Back to the Kill APP command...

I gave the Service Call Activity 79 another chance... and it doesnt work with all apps..

For example with ColorNote it returns:

Result: Parcel(00000000 '......')

What could be happening?
[Galaxy S II Original Android Development] Cyb0rgz:
Hi,

I'm not sure if its right thread to post this. But I found this is very very informative in xda. Great work tungstwenty. Really appreciate it. Your script can be useful in many many things other than kernel also. Just help me to get things done..

Instead of using application to clear cache, is there any script available to clear all application cache, browser cache.?

Instead of using task killer, I would like to use some script to kill. Yes, I have gone through the op, but I can't understand. Sorry I'm just started to learning script.

If need to kill some app say, gtalk whats the script I need to run.

Could you please guide me in detail or any links PDF for scripting would be much helpful.

Thanks.
[Galaxy S II Original Android Development] Tungstwenty:
I'm not sure what might be wrong. You could try fetching the pid of the running app (using "dumpsys activity ..." to find it) and then doing either "kill <pid>" or if even that doesn't work, the more drastic "kill -9 <pid>".

The app won't have a chance to shut down gracefully, however.
[Galaxy S II Original Android Development] Tungstwenty:
I haven't tried it, but perhaps the package service can be used, to call the transaction deleteApplicationCacheFiles (58 on 4.0.3) through "service call package 58 s16 com.android.???.browser i32 ... i32 ...".

The code that interprets the parameters is here. What I'm not sure is which parameters are required after the s16 with the string, to appear on the service as a null binder for the callback ...

If you want to kill apps, you can check the 3rd post and in particular the example "Force-stopping an activity".

"service call activity 79 s16 com.swype.android.inputmethod" will stop swype if it's running. For gtalk, you just need to check the package name, for instance finding its folder under /data/data. It should be "com.android.google.talk", I think.
[Galaxy S II Original Android Development] Frostyeo:
Hi I'm trying to edit the wait_for_gestures door but it always force closed when I try to open it with a text editor in root explorer. Editing the touch gestures in this way had no issues, is there something I'm doing wrong?
[Galaxy S II Original Android Development] Tungstwenty:
The wait_for_gestures "file" is a special virtual file, and if you try to read it, the read operation will block until one of the gestures is actually triggered. This is a good thing for the scripts (which will be completely frozen until there's something to do, thus not consuming CPU) but not meant for an interactive editor which will appear to hang and be FC'd in 20s or so as it won't be responding.

It's best if you don't read that file interactively, and if you do want to see what comes out of it and when, open a shell and type "cat /path/of/the/file/wait_for_gestures". It will appear frozen but will output a line with a number as soon as your fingers satisfy one of the configured gestures.
[Galaxy S II Original Android Development] rakeshishere:
Quick question - Is it possible to implement any of the SGS3 gestures (e.g - palm swipe to take screenshot)? I think this makes use of proximity sensor along with the touchscreen?

I'm not quite sure but anyone has any idea?
[Galaxy S II Original Android Development] Tungstwenty:
I don't know how that's triggered in the S3, but if it does involve the proximity sensor instead of the actual touch screen, then you'll need to find some other way to query that.

On the s2, you can read /sys/devices/virtual/proximity/proximity/proximity_state but:

1) it doesn't block (you can't have a script wait for it to reach a certain value)

2) it always returns 0 unless you're in the middle of a call

There must be some way to enable the sensor so it starts outputting the true measurements, I'm not sure how the phone app does it.

Anyway, after you decide how you want to trigger it, requesting a snapshot is as easy as executing:

am broadcast -a android.intent.action.TOUCH_CAPTURE_BTN
[Galaxy S II Original Android Development] hetn:
I can change the content of S50GestureActions file in the init.d folder, but how can I get it to work? I have changed the coordinates, but the gestures are working like before my modifications. So, how can I say to my phone : please change the "gestures system" according the content of S50GesturesActions modified by me? (GS2)
[Galaxy S II Original Android Development] Tungstwenty:
Did you reboot after changing the file?

The new settings won't be applied until the new script is executed. And since it also starts an infinite loop in the background, it's not a good idea to execute it manually else it will create a second loop without stopping the first one.

Please post what happens after a reboot.
[Galaxy S II Original Android Development] wuyuanyi:
great work,

thanks

i wonder how to launch samsung ROM's clipboard manager(in ICS it can only be called in native programs while in 2.3 works anywhere).

and can i launch IME keyboard with gesture ? thx!
[Galaxy S II Original Android Development] hetn:
I deleted all things from S50GestureActions except the camera starting part and I modified the coordinates to see the difference. After restart the original (I have downloaded from OP before) script started to work again.

I have understood your explanation not to start second loop. Please explain me: what is the common mode to change the script?
[Galaxy S II Original Android Development] Many40:
Did you save the changes? This is how I make changes to the script (step by step): open zip flashable file on PC with Winrar then go to the S50GestureActions file inside the archive with Notepad++, make changes, then save and close the file, then a pop up message appears (something like): "The file has been changed inside the archive, would you like to update the archive?", I confirm YES. Afterwords I flash again zip file in CWM recovery. Takes time but works well.
[Galaxy S II Original Android Development] Tungstwenty:
I have the impression that neither of those can be done.

They both expect to be launched in the context o a running application, so that if the app is dismissed, hidden, etc. then those dialogs are also part of it.

You can't just simply show the keyboard if it isn't attached to anything to consume what's typed.
[Galaxy S II Original Android Development] hetn:
Tungstwenty and Many40 thanks for your support

It works finally. I found my mistake: I had to set back the properties of "zipping method" as default in my computer.

Thanks again
[Galaxy S II Original Android Development] carlos67:
Can anyone help?

I hate using the home button on s3 (it was ok on s2) but I must use it (by long pressing) to bring up the recent apps list in touchwiz :(

So, how can I make it so that by swiping from middle bottom to middle middle will launch the recent apps list? It would have to mimick long pressing the home button.

Would really appreciate a little help to get started on this. The sooner I can stop using the home button, the better for me.

Thanks. :)
[Galaxy S II Original Android Development] Tungstwenty:
The dimensions of the S3 screen are 1280 height and 720 width.

The coordinates of the point in the middle of the bottom edge are x=360 (half of 720) and y=1279. To have a box with a certain height and width to catch that area, let's say we use a 100px margin. You can consider that touch area as starting at x=310 and ending at x=410, and with y between 1180 and 1190.

Following the same logic for the point in the middle of the screen (x=360, y=640), you should have x between 310 and 410 and y between 590 and 690.

The gesture definition text, if you choose it as gesture number 5, would be:

5:1:(310|410,1180|1190)
5:1:(310|410,590|690)

That's it.

Personally, I think this will probably raise too many false positives and would choose a movement such as bottom-middle-bottom-middle-bottom-middle, so it is unlikely to happen by mistake. That would be:

5:1:(310|410,1180|1190)
5:1:(310|410,590|690)
5:1:(310|410,1180|1190)
5:1:(310|410,590|690)
5:1:(310|410,1180|1190)
5:1:(310|410,590|690)

As for the action to be triggered when the gesture number 5 is detected, check post #3 and choose accordingly.
[Galaxy S II Original Android Development] carlos67:
Thank you very much! I'm impressed with the detail of your answer. This is right on the edge of my comfort zone but do-able for me.

Keep up the great work you do on here :angel::good:
[Galaxy S II Original Android Development] hetn:
The Gestures system works properly.

I have a wish, I would like to launch the Dialer with gesture (to hide the Phone icon from Home screen)

I have found the Phone package details in AppXplore, but I do not know which activity do I have to choose.

(GS2 rooted LPX)
[Galaxy S II Original Android Development] Tungstwenty:
It can be somewhat tricky figuring out the required intent / activity to do something, even with the app explorers :(

An easy way at least for things like merely opening an app, is to:

- connect an adb shell

- open the desired app on your phone

- run "dumpsys activity top" on the shell

This will show you the activity on the foreground, which is the info you need for launching it through "am".

In this particular case, it's "am start com.android.contacts/.activities.DialtactsActivity"

PS: Pressing the green dial button doesn't always take you to the number pad, but will show the log or favorites if that was the last active tab.

Even passing the -S parameter (force stop before relaunching) won't bypass this behavior.