Friday, September 6, 2013

Tasker to prevent fraud or promotion call

Tasker to prevent fraud or promotion call


Hi, guys, i have been stuck at work for days, didn't have time to update or spend on tasker indeed.

actually at some point, i am lacking of inspiration or new idea of creative.

however, i did have a new idea these days. so would like to share with you people here along.

okay, let us get started.


in our daily lives, usually we would easily become the target getting promotion call or even worse getting the fraud call, that happens probably because we sometimes left our contact phone number in social networking sites or some other online shopping sites, etc. that is mainly how they got our contact phone number.

it is sorta annoying if you are getting a promotion call especially when you are busy with something, and it is very dangerious if you are getting a fraud call from a con group.

so if we are able to see the search results from the search engine of the caller phone number while we are getting a call, it would be some sort helpful if they are already flagged in the internet.


well, i guess you know what i am about to do next.

1st, we will need to set up a scene in tasker, then create 3 profiles to get this work done.

tasker-scene-create a new scene, named it whatever you like, (e.g. reverse lookup) then edit the scene, add a webview element:

name: leave it default
mode: URL
source: leave it blank
allow phone access: uncheck
self handle links: checked

at last, remember to add a button element to destory the scene in the scene.


profile 1: (caller reversal)

context:

state-phone-call, type: incoming, number: !C:ANY  -----!C:ANY means the exception from contacts list.

task:

action 1: variable-variable set, name: %CALLREVERSAL, to: http://www.google.com/search?newwindow=1&q=%CNUM&cad=h

action 2: scene-show scene, name: reverse lookup, display as: dialog dim behind heavy, show exit button: unchecked      -------------dialog dim behind heavy can disable the system keyguard lock automatically and show up the scene always at the top. so you may take a peek at the web search results and determine to answer or not. if yes, you will need to close the scene first then to tap to answer the call.

action 3: scene-element web control, scene name: reverse lookup, element: webview 1, mode: load url, value: %CALLREVERSAL



profile 2:

context:

event-phone-phone idel

task:

action: scene-destory scene, name: reverse lookup



profile 3: (missed call lookup)

context:

event-phone-missed call, caller: !C:ANY

task:

action 1: variable-variable set, name: %CALLREVERSAL, to: http://www.google.com/search?newwindow=1&q=%CNUM&cad=h

action 2: task-wait, 6 seconds       ------------ this action is set because while your phone is done from a call, profile 2 will destory the scene, but it seems the tasker phone idle context reacts a little bit slower than the missed call context trigger, so it would destory the scene triggered by profile 3. of course, you may create another scene to avoid this issue. but i am getting lazy, pardon me @_@!!

action 3: scene-show scene, name: reverse lookup, display as: overlap, blocking, full window, show exit button: unchecked     -------note: don't use dialog effect, it could cause your screen staying dim, cannot go into sleep.

action 4: scene-element web control, scene name: reverse lookup, element: webview 1, mode: load url, value: %CALLREVERSAL


Done!


well, via these 3 profiles, you are able to determine at some point if the caller is worth picking up or not. of course, the profiles would never trigger while you are getting calls from the contacts.

it would show up while you are getting a call from a stranger, and automatically closeup if you don't do anything(e.g. you were not with the phone or didn't hear the ringing ATM.), also it would display on screen while you noticed there is a missed call and unlocked the phone.

but there is only 1 defect, for missed call part, if you have got 2 or more different calls from different strangers one by one, the scene would only display the latest caller phone number reverse lookup results.


does it sound attracting?

why not take action now.............

enjoy and have fun

:)



Tuesday, May 21, 2013

Popup sms notifier via tasker scene

Popup sms notifier via tasker scene



in my previous posts, i have mentioned that it is not significant to make popup sms notifier via tasker scene, cause it could only display 1 sms message(latest or oldest) which is not capable to deal with multiple situations.

however, during these days, i did discover a workaround which could fix this problem.

after done with my instructions below, you will be able to check every incoming unread sms messages just within 1 scene by pressing "next" or "previous" button, of course you will still need to activate another scene to fulfill the reply job which gives you full sceen input layout.

wondering how?

no rush, please read on.

please excuse me if you feel it is sorta messy below. let us consider it is a nice testing for your DIY ability.

^_^!!.....




ultimate effect: (FYI)







##############################################


profile 1: (popup sms notifier)

context: event-receive text, type: sms

task:

action: variable clear, name: %SMSBODY

action: variable set, name: %SMSJOIN1, to: %SMSRD

action: variable set, name: %SMSJOIN2, to: %SMSRT

action: variable set, name: %SMSJOIN3, to: %SMSRN

action: variable set, name: %SMSJOIN4, to: %SMSRF

action: variable set, name: %SMSJOIN5, to: %SMSRB

action: variable set, name: %SMSUNREAD, to: %SMSCOUNT+1, do maths, checked

action: variable join, name: %SMSJOIN, joiner: ; to: %SMSDATA

action: variable set, name: %SMSPOPUP,to: %SMSUNREAD{%SMSDATA}, append checked

action: variable search replace, variable: %SMSPOPUP, search: %SMSUNREAD.\w+.\w+.\w+.\w+.\w+.\w+.\w+. store matches in: %SMSSHOW, ignore case, checked (in order to match the regex, the format should be like: 2{2013-3-15;13.30;Cat;2053959909},{........... }

aciton: variable split, name: %SMSSHOW, splitter: %SMSUNREAD{

aciton: variable split, name: %SMSSHOW2, splitter: }

aciton: variable split, name: %SMSSHOW21, splitter: ;

action: variable set, name: %SMSDATE, to: %SMSSHOW211

action: variable set, name: %SMSTIME, to: %SMSSHOW212

action: variable set, name: %SMSNAME, to: %SMSSHOW213

action: variable set, name: %SMSNUM, to: %SMSSHOW214

action: variable set, name: %SMSBODY, to: %SMSSHOW215








profile 2:

context: variable value, name: %SMSBODY, OP: is set


task:

action: show scene, name: Popup sms notifier, display as: dialog, dim behind heavy, show exit button uncheck, continue task immediately, checked

action: misc-test,type: contact photo url, data: %SMSRF, store result in %CONTACTPHOTO

action: scene-element image, scene name: Popup sms notifier, element: Image1, image: %CONTACTPHOTO




In tasker variable tab, creat 2 global variables:

variable name: %SMSCOUNT, to: 0

variable name: %SMSINDEX, to: 1



(scene)
close button task:

tap:

action: scene-destroy scene, name: Popup sms notifier
action: variable clear, name: %SMSBODY



(scene)
next button task:

tap:

action: variable set, name: %SMSPOSITION, to: %SMSINDEX+1, do maths, checked

action: variable search replace, variable: %SMSPOPUP, search: %SMSPOSITION.\w+.\w+.\w+.\w+.\w+.\w+.\w+. store matches in: %SMSSHOW, ignore case, checked, if %SMSPOSITION !~ 1

aciton: variable split, name: %SMSSHOW, splitter: %SMSUNREAD{

aciton: variable split, name: %SMSSHOW2, splitter: }

aciton: variable split, name: %SMSSHOW21, splitter: ;

action: variable set, name: %SMSDATE, to: %SMSSHOW211

action: variable set, name: %SMSTIME, to: %SMSSHOW212

action: variable set, name: %SMSNAME, to: %SMSSHOW213

action: variable set, name: %SMSNUM, to: %SMSSHOW214

action: variable set, name: %SMSBODY, to: %SMSSHOW215



(scene)
previous button task:

tap:

action: variable set, name: %SMSREWIND, to: %SMSPOSITION-1, do maths, checked

action: variable search replace, variable: %SMSPOPUP, search: %SMSREWIND.\w+.\w+.\w+.\w+.\w+.\w+.\w+. store matches in: %SMSSHOW, ignore case, checked

aciton: variable split, name: %SMSSHOW, splitter: %SMSUNREAD{

aciton: variable split, name: %SMSSHOW2, splitter: }

aciton: variable split, name: %SMSSHOW21, splitter: ;

action: variable set, name: %SMSDATE, to: %SMSSHOW211

action: variable set, name: %SMSTIME, to: %SMSSHOW212

action: variable set, name: %SMSNAME, to: %SMSSHOW213

action: variable set, name: %SMSNUM, to: %SMSSHOW214

action: variable set, name: %SMSBODY, to: %SMSSHOW215




(scene)

mark as read button:

####please refer to my previous relevant posts to get the python sl4a script content.




(scene)

delet button:

####please refer to my previous relevant posts to get the python sl4a script content.




(scene)

reply button:

tap:

action: show scene, name: Popup reply, display as dialog dim heavy,  show exit button uncheck, continue task immediately, checked


(scene 2)

send button:

tap:

action: phone-send sms, number: %SMSNUM, message: %newval



profile 3:

context: unread text, invert

task:

action: variable clear, name: %SMSPOPUP

action: variable clear, name: %SMSUNREAD




Profile 4: (Kill scene)  ## Kill the scene once it got hidden in background, which means you no longer need it.

Context: unread text
Context: display off

Task:

Action: wait 5 minutes

Action: scene-element test, type: status, store result in % ELEMENTTEST, If %PACTIVE ~ kill scene

Action: destroy scene, name: Popup sms notifier, if  % ELEMENTTEST  ~ hidden

action: variable clear, name: % ELEMENTTEST




Tasker scene 1: (Popup sms notifier)

you may now add an image element to the any position you prefer within the scene, you may pick a picture as the default image if the sender doesn't have a contact photo in the contacts database.

previous, next, close, mark as read, delete, reply, buttons.

and the message body text viewer( you better choose text editor element instead, cause it could give you the drawable ability to pull up and down to see the full message if it is pretty long enough.)


Tasker scene 2: (Popup reply)

it could much easier to create this scene since you have got skillful of creating the 1st one. so, i guess i don't need to say too much about how to.


Sunday, May 12, 2013

New project----via tasker to get live status view of your contacts while calling them

New project----via tasker to get live status view of your contacts while calling them



i have been spending a couple days on this new project, some details still need to be polished though.

it is to get the contacts live status view while you are dialing them. tasker would detect automatically whom you are dialing and get the live status of this contacts.

that sounds awesome, right?

and you actually don't have to manually trigger any live profile at all, just set up some specific live status profiles in tasker, eg. wifi connected home wireless router (home mode), wife not connected home WIFI (out of home). likewise, for work mode.

and there is more than that. read on, please.

.............

.........

.....

...

.

calling status--on the phone mode

phone status--sleep mode, car mode.......

location update--cell near report(outside mode plus)

live emotion status--totol customization by end user(updated on a text widget or scene on launcher desktop)

outside mode: once you left the pre-defined specific wifi network(work or home), it would auto switch to outside mode. saying i am outside........

once you are getting a phone call, right after you answer the phone call, (offhook event) tasker could popup notify you if you wanna share your current location info, if yes, it would auto collect your current location information and auto update your status to show up to the caller.

once you press dail button, then tasker could take care of the rest of work, which getting access to the local database and the remote server to fetch the updated live status data of the recipient you are calling.

if the recipient is currently under outside mode, once tasker recognizes it then will wait a few seconds the re-get http data from his dropbox to get his location information if available.



hereinafter it is some snapshots which i took on my HTC droid FYI.


in-call live view----- this is what you will see while calling the recipient.

 contacts live view widget---- you may get their updates anytime, no need to call to fetch it.

 and you may even have the options to call or text them conveniently.

 my live feed widget---- this is the live view of my own, easliy to get updated on the launcher desktop.



how to make it?


(to be continued........)   ^_^!!




Monday, April 29, 2013

Python script to get android phone vibrate while is being answered II

I happen to find that for GSM standard phone, call duration would be created into sql database only if the outgoing call is being answered, or after hanging up if it is not being answered.

So i guess this method is meant for CDMA android phone only. cause we could not detect if outgoing call is offhook by the callee via tasker or sl4a.

Java code would be the solution i think, by monitoring the phone state.


in my earlier entry, i have mentioned the method about how to get it done by python script.

however it doesn't work on android phone but android pad.

i guess the reason is the contacts dabase is encrypted by default, most likely not encrypted in android pad, since it doesn't actually have mobile communication modules built-in.

well, i have been thinking if there is another way to solve this still via python script?

after some testings, problem finally solved.

if you are interested, please read on.



#### script content ###############


import android
droid = android.Android()
import time
time.sleep(3)
a = droid.queryContent('content://call_log/calls',['duration'],'type <= 2',None,None).result  ## returns a list of dictionary
while a is not None:
  b =a[-1]  
  c = b.get('duration')
  d = int(c)      
  if d == 1 or d == 2:
    break
droid.vibrate(200)


How to get contact phone number via contact name?

in some specific situations, if we got a bunch of contacts names, how can we get the matched phone number from the database?

the answer is yes, we may get it done by python sl4a script or sqlite3 command.

for sqlite3 command requirement, please check my previous entry for sure.

hereinafter it is the specific command to get the matches mobile phone number by name.

## type represents the phone number type, 2 means mobile phone number.

## LIMIT 1, cause there might be more than 1 mobile phone number for this contact person.

### %Contact_name is the variable set from tasker

sqlite3 /data/data/com.android.providers.contacts/databases/contacts2.db 'SELECT number FROM view_v1_phones WHERE name="%Contact_name" AND type=2 LIMIT 1';



via python sl4a script, it is also simple that way. if you wanna sepcify the search result for mobile phone number only, you may use for statement combined with find function with regex match.

### %Contact_name is the variable set from tasker
#### script content ###########

import android
droid = android.Android()
contacts = droid.queryContent('content://com.android.contacts/data/phones',['data1'],'display_name = "%Contact_name"',None,None).result
a = contacts[0]['data1']
print a
## returns specific phone number in interger

SL4A python script to manage android default sms message

SL4A python script to manage android default sms message


since i have been studying on sl4a python script these days, i think it could be helpful if i post how sl4a script manages android default sms message.

in my earlier entry, i already posted the script about how to mark specific sms as read via keyword and sender phone number.

if you are interested, you may take a look as well.





## unread sms count  ####


import android
droid = android.Android()

count = droid.smsGetMessageCount(True).result
print count         ## you will see the unread sms count result in there




## send sms ###


# coding:utf-8
import android
droid = android.Android()

number = "........."
message = "........."
droid.smsSend(number, message.encode("utf-8"))




## mark all unread sms as read ####


import android
droid = android.Android()

msgIDs = droid.smsGetMessageIds(True, 'inbox').result
if msgIDs > 0:
  droid.smsMarkMessageRead(megIDs, 1)





### delete all unread sms #######


import android
droid = android.Android()

msgIDs = droid.smsGetMessageIds(True, 'inbox').result
if msgIDs > 0:
  for msgID in msgIDs:
    droid.smsDeleteMessage(msgID)




#### delete specific message in outbox ####

# coding:utf-8
import android
droid = android.Android()

msgIDs = droid.smsGetMessageIds(False, 'sent').result
if msgIDs > 0:
  for msgID in msgIDs:
    message = droid.smsGetMessageById(msgID, ['address','body']).result
    str1 = message['address'].encode('utf-8')
    str2 = message['body'].encode('utf-8')
    if str1.find('XXXXX') >= 0 and str2.find('YYYY') >= 0:    ##XXXX reprents phone number, YYYY represents message keywords
       droid.smsDeleteMessage(msgID)




#### delete specific message in inbox and outbox ####


# coding:utf-8
import android
droid = android.Android()

msgIDs = droid.smsGetMessageIds(False, 'inbox').result
msgIDs.extend(droid.smsGetMessageIds(False, 'sent').result
if msgIDs > 0:
  for msgID in msgIDs:
    message = droid.smsGetMessageById(msgID, ['address','body']).result
    str1 = message['address'].encode('utf-8')
    str2 = message['body'].encode('utf-8')
    if str1.find('XXXX') >= 0 and str2.find('YYYY') >= 0:         ##XXXX reprents phone number, YYYY represents message keywords
       droid.smsDeleteMessage(msgID)
        


Sunday, April 28, 2013

Another version of my Popup SMS notifier

in my earlier entry, i have posted the script about how to make the popup sms notifier via python sl4a script.

and i also said i am wanting to improve it with full screen reply inputting layout.

i am sure python sl4a script can make it, but to do that, i will have to learn how to make the layout done by javascript first.

it is not gonna be easy, since i don't have too much time, so i have to get another easier way.

according to a suggestion of my friend, i have done some modifications for the reply message part.

now you will see full screen layout by then. below it is the screenshot to show you the demostration.

here you go~~~~


 this is the first part you will see while there is any incoming sms messaages.

 this is what happens while you press reply button.