yashsingh1/xdaforums huggingface dataset:
[Galaxy S II Original Android Development] Tungstwenty:
Gokhan mentioned the problems with permissions which must be "by the book" on CM10 but I didn't have a change to test it out yet.

Instead of what you're doing, can you run this?

chown -R root /system/etc/init.d/*
chgrp -R [B]shell[/B] /system/etc/init.d/*
chmod -R 755 /system/etc/init.d/*

2000 is the numerical id for the "shell" group. I'm not sure whether it makes any difference but that was the suggested test.

As for the &, it's correct before the ")"

I'll try to test this out myself on a CM10 rom as well.
[Galaxy S II Original Android Development] Tungstwenty:
It's probably due to your busybox version I guess.

Either replace the first line with "#! /sbin/busybox sh" or run edit the conditions from this:

if ...condition...
then
do something
elif ...another_condition...
do something else
fi

to

if ...condition...
then
do something
else
if ...another_condition...
then
do something else
fi
fi

(notice the presence of an additional "fi" to close the nested "if" block.
[Galaxy S II Original Android Development] Tungstwenty:
Thanks for the tip! I'll put it up when I update the second post with some additional instructions.

Another option is using the Developer Options menu and activating "Show pointer location", although the status bar is in the way. But you get to see the traveled path as well.
[Galaxy S II Original Android Development] eduardoroeder:
Another tip for launching things with the script is the package browser on tools inside the developer options(there is a better point location Also in there). Also, the problem on the unrecognized elif is because there is no action to do, so you need to comment it, or add an action.

Im with the bootlogo bug, but it works via terminal. So i made a 3finger pinch, just for developing, here it is:

4:1:(0|150,0|150)

4:1:(130|320,250|550)

4:2:(330|480,0|150)

4:2:(130|370,250|550)

4:3:(330|480,650|800)

4:3:(130|370,250|550)

And for testing purposes you ca remove the & on the script, so you can press control c, to finalize the loops.

The pinch is when you drag from the top left corner, and top right corner, and top right bottom, to the middle. I handwritted it just on free time x.x

Keep up the good work btw

Also, bout the patents, i heard that Apple was with samsung in court bout the pinch to zoom with 2 fingers action :o care to no use anything like that, huh

PS: ill be writing more finger movements, like draw a Play icon would start your music player.

Ps2: the same tools found in developer options is found on the launcher grid as Tools. On CM 10 it isnt there anymore

Here is my current script http://paste.strictfp.com/32143

And i was wondering if adding

sleep 30

sh /sdcard/touch_gestures

At the beggining would work on init.d? Just to say, the sleep 60 didnt work D:

;D
[Galaxy S II Original Android Development] Tungstwenty:
How about some more actions that could be useful when bound to gestures?

Come on people, I'd like to see those contributions flowing :)

Here's a bunch of teasers. I won't even explain them, have fun figuring them out :laugh:

You can launch them from the command line just to check what they do - copy the line and paste on the adb shell.

( service call bluetooth 1 | grep '0 00000000' >/dev/null && service call bluetooth 3 >/dev/null ) && service call bluetooth 4 >/dev/null

( service call connectivity 18 | grep '0 00000000' >/dev/null && service call connectivity 19 i32 1 >/dev/null) || service call connectivity 19 i32 0 >/dev/null

( service call wifi 14 | grep '0 00000001' >/dev/null && service call wifi 13 i32 1 >/dev/null) || service call wifi 13 i32 0 >/dev/null

echo "run in case of emergency" >/dev/null && (while [ 1 ]; do service call vibrator 2 i32 300 i32 0;usleep 300000;service call vibrator 2 i32 300 i32 0;usleep 300000;service call vibrator 2 i32 300 i32 0; usleep 700000; service call vibrator 2 i32 600 i32 0;usleep 600000;service call vibrator 2 i32 600 i32 0;usleep 600000;service call vibrator 2 i32 600 i32 0; usleep 700000; service call vibrator 2 i32 300 i32 0;usleep 300000;service call vibrator 2 i32 300 i32 0;usleep 300000;service call vibrator 2 i32 300 i32 0; usleep 1500000; done) 2>&1 >/dev/null &

key=26; service call window 12 i32 1 i32 1 i32 5 i32 0 i32 0 i32 $key i32 0 i32 0 i32 0 i32 8 i32 0 i32 0 i32 0 i32 0; service call window 12 i32 1 i32 1 i32 5 i32 0 i32 1 i32 $key i32 0 i32 0 i32 27 i32 8 i32 0 i32 0 i32 0 i32 0

# other values to use instead of key=26:
# 26 = Power
# 3 = Home
# 24/25 = Volume up/down
# 85 = Media Play / pause
# 86 = Media stop
# 87/88 = Media next / previous
# 164 = Volume mute / unmute
# 187 = Recent apps
[Galaxy S II Original Android Development] dorimanx:
Hi, to dev! great addon! it's amazing! :)

My compliments! also thanks to GM.

I have this great addon in my last kernel version.

i have tuned the script and now it's works as planed!

please consider to mod your main script.

Camera didnt open for me, so i have added the extweaks app that GM and me use to control the kernel. and it's open instantly with 3 fingers drow from up to down!

Awesome addon to kernel :)

my point in changing the script is, if in the last section you add only description, script fail.

so i have added just dummy echo to fill something.

we dont need to sleep or seek for 0, just do the action and return to cat/wait for new gesture mach.

#!/sbin/busybox sh

#
# Sample touch gesture actions by Tungstwenty - xdaforums.com
#

(
echo "
# Gesture 1 - swipe 1 finger near the top and one near the bottom from left to right
1:1:(0|150,0|150)
1:1:(330|480,0|150)
1:2:(0|150,650|800)
1:2:(330|480,650|800)

# Gesture 2 - swipe 3 fingers from near the top to near the bottom
2:1:(0|480,0|200)2:1:(0|480,600|800)
2:2:(0|480,0|200)2:2:(0|480,600|800)
2:3:(0|480,0|200)2:3:(0|480,600|800)

# Gesture 3 - draw a Z with one finger while another is pressed on the middle left
3:1:(0|150,0|150)
3:1:(330|480,0|150)
3:1:(0|150,650|800)
3:1:(330|480,650|800)

3:2:(0|150,300|500)

" > /sys/devices/virtual/misc/touch_gestures/gesture_patterns
)&

(while [ 1 ];
do

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

if [ "$GESTURE" -eq "1" ]; then

mdnie_status=`cat /sys/class/mdnie/mdnie/negative`
if [ "$mdnie_status" -eq "0" ]; then
echo 1 > /sys/class/mdnie/mdnie/negative
else
echo 0 > /sys/class/mdnie/mdnie/negative
fi

elif [ "$GESTURE" -eq "2" ]; then

# Start the extweaks
am start -a android.intent.action.MAIN -n com.darekxan.extweaks.app/.ExTweaksActivity

elif [ "$GESTURE" -eq "3" ]; then

echo "if blank GESTURE dont remove me." > /dev/null 2>&1

# Edit and uncomment the next line to automatically start a call to the target number

# WARNING / BONUS: This will work even in the lockscreen with a PIN protection
# If that's the case, make sure you have "power to turn off call" or else you'll need
# to unlock the screen in case you try to open contacts, etc. (which won't be allowed)

### EDIT ### service call phone 2 s16 "133"

fi;

done &);
[Galaxy S II Original Android Development] Tungstwenty:
Thanks for your feedback and for the script adjustments.

Indeed I didn't notice the problem of having one entry with no instructions (because I'm using the uncommented line to establish a call).

Also, the -eq 0 is indeed not necessary at all (even the sleep shouldn't be as the cat blocks, but anyway.

About the background echo to the gesture definitions, does it make a difference?

To those experiencing problems when running as init.d

:

Can you try the script posted by dorimanx and see if it solves your booting problems?

Oh, and about the camera - it doesn't work for you because you have a different camera app? Or does it fail because of something else? Remember that it won't be brought to front if you have the screen locked.
[Galaxy S II Original Android Development] dorimanx:
we can catch one gesture each time.

the (

)&

for the gestures position is just to be safer, not really needed.

about camera this what i got :(

~ # Starting: Intent { act=android.intent.action.MAIN cat=[android.intent.category.LAUNCHER] flg=0x800000 pkg=com.sec.android.app.camera }

Error: Activity not started, unable to resolve Intent { act=android.intent.action.MAIN cat=[android.intent.category.LAUNCHER] flg=0x10800000 pkg=com.sec.android.app.camera }

i have aokp milestone 6.

probably have different build in camera app.

edit,

i have modded the script i posted, removed the else and sleep, we dont need it,

script will do the action and return to cat and wait for new one. :)
[Galaxy S II Original Android Development] eduardoroeder:
My camera works with my Piece of code, i pasted it on the strictfp, its because cm10 uses gallery3d camera.

Also, you could add a little vibration to when the gesture trigger

;D
[Galaxy S II Original Android Development] dorimanx:
:laugh: how to stop the emergency :)

had to reboot, didnt found the service that run it in ps :)
[Galaxy S II Original Android Development] Tungstwenty:
At last !!! :D

I was wondering when would someone complain :)

You could stop it by running "ps -l" to see the parent pid of the sleep instructions, for instance, and then killing the parent instead of each individual command issued.
[Galaxy S II Original Android Development] Tungstwenty:
To activate vibration, you can use this:

service call vibrator 2 i32 [COLOR="Red"][B]300[/B][/COLOR] i32 0

This example will be for 300 ms, just change it to the value you find more comfortable.

Just add that to one of the detection blocks, before actually triggering the real action you want.
[Galaxy S II Original Android Development] dorimanx:
cool, thanks,

You have made new kind of future for our device, possibility's are endless!

this has to be on xda news!

already cooking some nice stuff for my friends :)

can you please give me/us one more instruction how to calculate the gesture,

i seen the OP and the numbers from side to side, but how can i calculate the Z as you did, or any other directions...

thanks..

P.S

is there any app that you use to see the screen points and then just set them to script?

I have idea, but need your help till i learn how to :)

i want to make gesture that consist of 2 fingers,

one moving from top screen to middle and second from bottom to middle

and when they meet, then action kick in and push the power key!

now that can be great! + the screen off anim from rom, make it very cool thing.
[Galaxy S II Original Android Development] Tungstwenty:
The camera in stock builds is an app from Samsung (com.sec.android...). On AOKP / CM it will certainly be a different one.

Here's a great way to know what to launch:

- Download AppXplore from the store

- Browse to the app you want to launch

- Scroll to the area with the existing activities and the one(s) corresponding to the launcher - see screenshot

- Insert a slash between the package name and the activity. In the example from the screenshot, it would be "com.sec.android.app.camera/.Camera"

- The command to execute will be "am start com.sec.android.app.camera/.Camera"

Activities others than the launcher ones might also be useful (if they work) - it's just a matter of experimenting.

Can you confirm whether you previously had the boot hang issue and with this changes it's now gone?
[Galaxy S II Original Android Development] dorimanx:
now when script run in his own process it's should not brake boot.

just load to ram and wait.

no problem to boot, but i will add it to my cortex script, that already has while function that do lots of stuff on screen on/off see here

so i will run script on screen ON, and kill it on screen off, to save very little battery power. :)

so lots of work to be done :)

ps. full credit given to you on my OP :)

using appxplore (thanks for tip)

to start camera for aokp 4.0.4

am start com.android.camera/.Camera

# to start video

am start com.android.camera/.VideoCamera
[Galaxy S II Original Android Development] deklica:
Is there final solution/script for non boot on CM10?
[Galaxy S II Original Android Development] Tungstwenty:
You can go to Settings, Developer options, and enable "Show pointer location" if you want to see the coordinates where you touch / drag.

If you browse a few posts back, there was also a suggestion for an app that can display the touched coordinates.

Personally, I just imagine the rectangle as mentioned in the OP (it doesn't show correctly on XDA app ...) and from those coordinates think about the points (rectangles, really) that make sense.

For your specific request of the 2 fingers:

If you mean "anywhere on the top" to middle, the initial area for one of the fingers would be X between 0 (left) and 399 (right) and Y between 0 (top) and say 150 (about 1 fifth of the screen height). The ending zone for this same finger would be the same X interval (anywhere on the X axis) but Y near the center - say, 300 to 500 (200 pixels centered vertically).

For this first finger you'd therefore need 2 steps, or 2 hotspots in succession:

N:1:(0|399,0|150)
N:1:(0|399,300|500)

(where N is the gesture number you want for it)

The second finger would be the same except for the starting point - finger 2 should end in the same area around the middle, vertically, but start near the bottom:

N:2:(0|399,650|799)
N:2:(0|399,300|500)

And that's it, just combine all 4 lines and you have the definition of the <N> gesture.

Now imagine you'd want another finger to be pressed anywhere on the screen for this to be triggered. Perhaps with the left thumb or whatever.

Just add a zone for the entire area:

N:3:(0|399,0|799)

If you add this line, the gesture will only be fired if a 3rd finger is pressed anywhere on the screen while the other 2 are being pinched from top+bottom to the middle.

For this to trigger a power off, check my previous post with a few actions and use the one for keycodes, with the scan value for the POWER key:

key=26; service call window 12 i32 1 i32 1 i32 5 i32 0 i32 0 i32 $key i32 0 i32 0 i32 0 i32 8 i32 0 i32 0 i32 0 i32 0; service call window 12 i32 1 i32 1 i32 5 i32 0 i32 1 i32 $key i32 0 i32 0 i32 27 i32 8 i32 0 i32 0 i32 0 i32 0

The "Z gesture" declares one finger that should move from a box on the top left, then to a box on the top right, then on the bottom left and finally on the bottom right.

Additionally, it expects a second finger to merely be pressed on the middle left of the screen.

You should be able to map this to the lines I mentioned for that definition.
[Galaxy S II Original Android Development] cavaliere06:
welll I tried the script by @dorimanx but I'm still stock on siyah logo, also changed the

chgrp -R root /system/etc/init.d/*

to

chgrp -R shell /system/etc/init.d/*

but it didn't help

although I coud lunch the camera app // Thanks Tungstwenty :victory:

In CM10 from august 12 this is the trigger

am start com.android.gallery3d/com.android.camera.CameraLauncher
[Galaxy S II Original Android Development] paradorx:
been trying to test the gestures,

the rom booted but all the gestures has no response

im using paranoid rom 1.98 with siyah beta 6

this is the codes i have used:

#!/sbin/busybox sh

sleep 60

#
# Sample touch gesture actions by Tungstwenty - xdaforums.com
#

(
echo "
# Gesture 1 - swipe 1 finger near the top and one near the bottom from left to right
1:1:(0|150,0|150)
1:1:(330|480,0|150)
1:2:(0|150,650|800)
1:2:(330|480,650|800)

# Gesture 2 - swipe 3 fingers from near the top to near the bottom
2:1:(0|480,0|200)2:1:(0|480,600|800)
2:2:(0|480,0|200)2:2:(0|480,600|800)
2:3:(0|480,0|200)2:3:(0|480,600|800)

# Gesture 3 - draw a Z with one finger while another is pressed on the middle left
3:1:(0|150,0|150)
3:1:(330|480,0|150)
3:1:(0|150,650|800)
3:1:(330|480,650|800)
3:2:(0|150,300|500)

# Gesture 4 - pinch with 3 fingers on top left top right and bottom right to the center of screen.
4:1:(0|150,0|150)
4:1:(130|320,250|550)
4:2:(330|480,0|150)
4:2:(130|370,250|550)
4:3:(330|480,650|800)
4:3:(130|370,250|550)

# Gesture 5 - draw a play from top left corner to middle right, then bottom left corner, then top left corner again
5:1:(0|150,0|150)
5:1:(330|480,250|550)
5:1:(0|150,650|800)
5:1:(0|150,0|150)

" > /sys/devices/virtual/misc/touch_gestures/gesture_patterns
)&

(while [ 1 ];
do

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

if [ "$GESTURE" -eq "1" ]; then

mdnie_status=`cat /sys/class/mdnie/mdnie/negative`
if [ "$mdnie_status" -eq "0" ]; then
echo 1 > /sys/class/mdnie/mdnie/negative
else
echo 0 > /sys/class/mdnie/mdnie/negative
fi

elif [ "$GESTURE" -eq "2" ]; then

# Start the Camera
am start --activity-exclude-from-recents com.android.gallery3d/com.android.camera.Camera

elif [ "$GESTURE" -eq "3" ]; then

echo "if blank GESTURE dont remove me." > /dev/null 2>&1

# Edit and uncomment the next line to automatically start a call to the target number

# WARNING / BONUS: This will work even in the lockscreen with a PIN protection
# If that's the case, make sure you have "power to turn off call" or else you'll need
# to unlock the screen in case you try to open contacts, etc. (which won't be allowed)

### EDIT ### service call phone 2 s16 "133"

elif [ "$GESTURE" -eq "4" ]; then

# Start the Launcher
am start --activity-exclude-from-recents com.anddoes.launcher/.Launcher

elif [ "$GESTURE" -eq "5" ]; then

#Start the Player
am start com.maxmpz.audioplayer/.PlayerUIActivity

fi;

done &);

after copied and using this command in terminal:

chown -R root /system/etc/init.d/*
chgrp -R shell /system/etc/init.d/*
chmod -R 755 /system/etc/init.d/*
[Galaxy S II Original Android Development] ggs2:
Can anyoneconfirm it is not working on paranoid Android 1.99?? Even gesture sample is not working

Stay like this only
[Galaxy S II Original Android Development] hawkerpaul:
Tungstwenty, this is a great addition to our phone, and my hat goes off to you mate.

1st class job!!

:good:

I currently have mine set up for camera, browser, calendar and Phandroid app.

If anyone is interested, here are the calls:

am start com.android.calendar (Calendar app)

am start com.android.browser (Browser app)

am start com.blau.android.phandroidnews/.MainActivity (Phandroid app)

My gestures:

swipe 1 finger in the top half of the screen and one in bottom half from left to right

1:1:(0|150,0|390)1:1:(330|480,0|390)

1:2:(0|150,410|800)1:2:(330|480,410|800)

swipe 1 finger in the top half of the screen and one in bottom half from right to left

2:1:(330|480,0|390)2:1:(0|150,0|390)

2:2:(330|480,410|800)2:2:(0|150,410|800)

swipe 2 fingers from near the top to near the bottom

3:1:(0|480,100|300)3:1:(0|480,500|700)

3:2:(0|480,100|300)3:2:(0|480,500|700)

swipe 2 fingers from near the bottom to near the top (phandroid)

4:1:(0|480,500|700)4:1:(0|480,100|300)

4:2:(0|480,500|700)4:2:(0|480,100|300)

It may be an idea to build up your reserved post#2 (or #3) for handy system/app calls to place in the gestures script, and possibly even to list some example gesture code sequences too perhaps?
[Galaxy S II Original Android Development] cyberspaceguy:
i dont understand how to use it!!

i flashed via cwm but now??... thanks

Inviato dal mio GT-I9100 con Tapatalk 2
[Galaxy S II Original Android Development] eduardoroeder:
Ive handwritted more 5patterns, tomorrow ill write em back into my small screen.

Pinch finger 1 topleft and finger 2bottom right to center and back finger 1 to topleft and finger 2 to bottom right.

Same with top right bottm left. Also made one with finger 1-> top middle, to center of screen, then back to top, while finger 2-> bottom middle to center of screen, then back to bottom.

Made a X gesture,finger 1 from top left to bottom right, then to top right and then bottom left.

Also Ive posted the 3 finger pinch, and the play button.

Dev Tools have a Pointer Location inside it, Also an package browser.

For the developer: AM i able to put more than 10gestures on the file?

And now move 3 finger from top to bottom of the screen, you can Also do what the main post says, but for that, open the forum with a web browser, no tapatalk.

;D
[Galaxy S II Original Android Development] tufoz:
nice work ;)
[Galaxy S II Original Android Development] sefira:
Has the no boot problem been solved? I.E. the script in the O.P. can be placed in init.d?
[Galaxy S II Original Android Development] ggs2:
I am notable to run activity

...

This is the error...

Or can anyone tell other way to expand notification bar
[Galaxy S II Original Android Development] darth_mickrig:
I found some more actions. Actually you can extract them from framework-res.apk's res\values\attrs.xml

#84 = Search

#220 = Voice Search

#212 = Brightness Up

#213 = Brightness Down

#214 = Recent Apps (too)

#215 = App Drawer (allows you to jump to App Drawer from any place except for Lock screen)

Unfortunately we are only allowed to create 10 gestures, else we could also dial numbers by using gestures :D

#7 = 0

#8 = 1

#9 = 2

#10 = 3

#11 = 4

#12 = 5

#13 = 6

#14 = 7

#15 = 8

#16 = 9

and some more.
[Galaxy S II Original Android Development] Tungstwenty:
I updated the OP with several things:

- CWM installable zip ready to be flashed on primary or secondary ROM

- 8 sample gestures and actions

- attempts to launch the 3 different camera apps mentioned so far on the thread

- fixed the problem of CM10 not booting

Tested on XWLPG and CM10/ParanoidAndroid.

Could everyone that was having CM10 issues - or even not having gestures at all - test it out and provide feedback?

Thanks!

PS: The CM10 problem was related with the presence of special chars within the while block, in comments: ' ( ) ...
[Galaxy S II Original Android Development] Tungstwenty:
True, currently there's a hard-coded limit on the kernel sources to allocate only enough memory for 10 gestures (times 10 fingers, 10 steps, 2 coordinates * max/min) which is about 16Kb.

I didn't think this would become so popular :D

As someone once said - 640Kb should be more than enough for everybody :laugh:

I'll try to update the code to have some more room for additional gestures. At the same time, the number of fingers can be reduced to 5 because in practice more than that will make the touch panel become too cluttered and only report some of the fingers, causing the recognition to not match.
[Galaxy S II Original Android Development] Flint2:
Thank you very much for your awesome work!

I've implemented 'force close' editing the 3rd example from OP (one finger in middle left and Z with another) to:

am force-stop `dumpsys activity activities | grep 'Recent #0'|cut -d' ' -f 9`

That's because for now my JB ROM lacks 'force close on back long press'

Maybe there is another way to force close?
[Galaxy S II Original Android Development] kollnoll:
Nice work!
[Galaxy S II Original Android Development] karlesg:
An action that I've been using for quite a long time now with a script, and maybe someone will find it useful

Indoor - outdoor mode

-your screen will toggle between max gamma (brightness) - more intense mdnie colors for outdoor, and default gamma - default mdnie colors for indoor.

# Indoor - Outdoor mode
if [ `cat /sys/class/lcd/panel/user_gamma_adjust` != "50" ]; then
echo "50" > /sys/class/lcd/panel/user_gamma_adjust
echo 1 > /sys/class/mdnie/mdnie/outdoor
else echo "0" > /sys/class/lcd/panel/user_gamma_adjust
echo 0 > /sys/class/mdnie/mdnie/outdoor
fi

# If someone uses this script executing it with an app - Force stop foreground app - vibrate
service call activity 79 s16 `dumpsys activity top | grep '^TASK.*' | cut -d ' ' -f2`
service call vibrator 2 i32 100 i32 0

You can change "0" in the last line with your own preffered gamma shift value for indoor.

If for example you are using -5 as default gamma shift value in extweaks, then the scipt must be

# Indoor - Outdoor mode
if [ `cat /sys/class/lcd/panel/user_gamma_adjust` != "50" ]; then
echo "50" > /sys/class/lcd/panel/user_gamma_adjust
echo 1 > sys/class/mdnie/mdnie/outdoor
else echo "[COLOR="Red"]-5[/COLOR]" > /sys/class/lcd/panel/user_gamma_adjust
echo 0 > sys/class/mdnie/mdnie/outdoor
fi

# If someone uses this script executing it with an app - Force stop foreground app - vibrate
service call activity 79 s16 `dumpsys activity top | grep '^TASK.*' | cut -d ' ' -f2`
service call vibrator 2 i32 100 i32 0