Android: howto pick up automatically when a certain number calls? - java

I want to create a program for Android which picks up automatically when a certain number calls and answer with dtmf tone. Is this possible in Android Java?

If you just wanted to be aware that a certain number had called and then do some non call action, such as log the call, send a notification to a server etc then you can simply use the Android TelephonyManager () and create a BroadcastReceiver to listen for incoming call events. There are quite a few examples of how to use it to detect incoming calls available with a quick search.
If you want to actually answer the call then strictly speaking in 'standard' Android terms you can't. However, take a look at this excellent answer (not mine...) for some workarounds which may possibly work for you depending on your particular solution (whether your target devices are rooted etc):
https://stackoverflow.com/a/27084305/334402

Related

Why is "getUserSelectedOutgoingPhoneAccount()" not callable from my telecom manager instance?

So I am trying to set up a system for multiple phones being connected to a device that handles phonecalls. In order to do so, I've been investigating the getUserSelectedOutgoingPhoneAccount() method, which should help me differentiate between the phone making the calls and the rest of the phones that are connected.
However, when I try to use that method with my instance of a Telecom Manager, it does not appear in the list of callable methods. I can see things like "getDefaultOutgoingPhoneAccount()" and "getCallCapablePhoneAccounts()", but nothing about getting or setting the user's selection. According to the android documentation, it's public and callable from a Telecom Manager. This manager is already set up in such a way that it can make phonecalls and such just fine, so I assumed this method would appear.
EDIT: This is how the telecom manager is initially defined; could this be why I'm not able to use the method in question?
Should I use a new telecom manager instance? Is it possible I'm missing something else, like an import? The current import for Telecom Manager is "android.telecom.TelecomManager".
Answer:
After looking into it some more, it appears my application is running on a lower API Level than this method has been implemented in (Android 8.1.0, which is API Level 27). This method requires API Level 29 or higher in order to call it.

Is there a way to trigger a specific code block when a REST API updates its values

I'm curious if it's possible to trigger a specific piece of code when a REST API its values changes. Actually a sort of realtime update a mechanism.
If it's not possible, what's a better to do it?
The idea is when I push on a button (on my android device) a text will appear in a game (Java Desktop).
Thank you!
Your question is not clear please rephrase it.
As you said you want that has to be done realtime.
Possible three approaches:
In android there are connection APIs with which you can connect your desktop(must have WiFi enabled) with phone. Then you can send or receive files and messages directly.
The other way is to have Push notifications but it's not guarantees realtime fast some time gets delayed otherwise performs good always.
Other way is to keep the connected socket open for listening changes from phone side to desktop side once connected but it's more costly.
Hope this gives you a direction, rest you can search over internet.
Why not just make a simple setter?
When you get a rest command to update something (for example some int value) you can do:
public void setValue(int newValue)
{
value = newValue;
doAction(newValue);
}
define the doAction as you want
If you need asynchronous update, use the thread. Learn multithreading
Check the link to see if your requirement could be completed with the java thread concepts. http://www.javatpoint.com/multithreading-in-java

Making Android Keyboard Resilient against KeyLogger attacks [closed]

Closed. This question needs to be more focused. It is not currently accepting answers.
Want to improve this question? Update the question so it focuses on one problem only by editing this post.
Closed 7 years ago.
Improve this question
Being a victim of a Key Logger attack on android, I want to develop a solution for KeyLogger attacks for android. I know basic java and a little about android and very little about Information Security. I am also aware that whatever knowledge I have is not enough to figure out and to develop a solution. I just like to discuss my idea and to see if it is feasible.
Here is what I have:
An android application, which wants to secure user input, must provide a secret key(which can be obtained from server, for a specific user or session) when invoking the android keyboard.
Android keyboard will receive the secret key and use it to encrypt user input and broadcast KEYPRESS event(or whatever event android keyboard broadcasts) with encrypted value.
When an application receives KEYPRESS event, it decrypt's the value in KEYPRESS even to get the actual user input.
I just came to realize that, screenshot can be used to get what user types with latest image-2-text software's. But that is completely a different domain, IMHO.
So, what do you think about it? Is it possible to do it?
Update
I was completely wrong about my phone got owned. Actually, it was never got hacked. But, what really got hacked was me. Yes, I have something in my body, which just copies everything that my brain can receive. And it also capable of receiving and making my brain to do it. I still dont know, why I am able to write this update. May be, who ever put that thing in my body using me as a marketing material. Thanks for answers for my dumb question.
Not realistically.
Few programmers are dealing with low-level input themselves. That is usually handled by other things. Web developers, for example, rarely get involved on a keystroke-by-keystroke basis, even for finding out when those events occur (e.g., for real-time validation), let alone for manually processing that input (e.g., putting the next character typed after the cursor of the field and advancing the cursor by one position).
Moreover, users are not in the habit of changing their input methods frequently. I do not plug in a different USB keyboard when I am visiting Stack Overflow versus when I am visiting Tweetdeck, for example. In the world of Android, this means that the user is going to expect their input method editor to work on all apps and not have to keep changing input method editors just to make some people happy.
Furthermore, you cannot magically change the protocol between input method editor (a.k.a., soft keyboard) and the Android OS. Your keyboard will raise key events. You are welcome to say that your keyboard offers up substitutions for those events as an "encryption" mechanism, but that would be more of a crude substitution cipher (e.g., "whenever the user types A, send over ;"), as you cannot unilaterally decide to expand the key event space.
As a result, not only will you need to write your input method editor, but you will need to write your own custom ROM with a custom Android framework that can handle the "decryption". Or, you would have to force all the worlds' developers to rewrite their apps. And in either case, a keylogger could trivially detect that yours is the input method editor and note that fact, so whoever is using the logs can do some trivial decryption to convert ; back into A.
Now, if you are writing some app where you want to avoid a rogue input method editor, you are welcome to bake in your own data entry keyboard into that app. Then, you will merely anger many of the users of your app, as your in-app keyboard is not the one that they want to use, or lacks features that they are used to (e.g., support for blind users, support for their particular language).
Here is what I would do to implement a secure input method paradigm - as expressed in the question - for Android:
First of all, I am assuming that you have read and understood the "Security" section for InputMethodManager here:
InputMethodManager
So, what we need to develop is an Input Method (IME) which is an Android service, which, along wth the custom keypad view, implements two interfaces:
InputMethod
InputMethodSession
As per the security section in the documentation referred to above, the user need to willingly accept your IME as the system IME. Also, Android will make sure that only system will bind to your service and use the InputMethod interface which is used to show/hide the keyboard etc. So, here things are pretty secure for you and all apps that uses your keyboard.
Now, coming to the security framework that you want to implement:
Lets call it as Secure Input Method - SIM - and lets define our security domain as your IME and the applications that wishes to use your SIM. Here is the significance of the second Interface InputMethodSession
The most important - and often ignored method of this interface is the key of this solution and it is called: appPrivateCommand. This interface allows a private command sent from the application to the IME. As per the documentation, this method can be used to provide domain-specific features that are only known between IME and their clients - and this is exactly what you need for your SIM.
So, using this interface, the apps in your security domain can pass any security information (say, some form of credentials) they want to hand over to your IME. It is up to you to define a method where your service can communicate with a authentication server which processes the client app submitted credentials and approves it. Now if the encryption keys are derived by both your IME and the client, you have established a secure channel of communication between your SIM and its client app (say, via encryption using a derived key from these credentialsd).
You can even customize this whole mechanism by defining some key sequences (like Control+Alt+Del in Windows) which initiates the whole thing by user himself and you can even provide a visual indication (say, a shining green icon) on your keyboard that the input channel is secured... Possibilities are many :)
Hope this helps.
You can do this only if you are developing your own keypad and configure Android to use it. It is not that hard with some experience in Android programming.
Just search in Google for "custom keypad for android" for more inputs.

Best way to implement rule check while communicating with GPS device

We are developing a vehicle tracking system. Like every VTS, we have GPS devices fitted into the vehicles which keep sending location information to the server. On server, our TCP communicator process keeps reading that data and saves it into the database
Now, we need to check for some set of rule to trigger alerts for the vehicles, e.g We need alert when vehicle reaches to a particular location, if vehicle crosses specific speed-limit,etc.
Can you please suggest the best way to implement it?
We have thought of some ways to implement it,
1. Our TCP communicator, when receives the location, should check for the alerts.
2. There will be a process which will keep running every 15 minutes and check the location details in that 15 minutes for alerts.
I am looking for the suggestions to implement it, logic-wise as well as technology-wise. e.g. Whether we should use Drools or not?, etc.
Somebody from FedEx actually presented something like this in a JavaOne conference I attended a couple of years back.
Basically, the idea was, yes, using Drools Expert + Fusion to perform CEP (complex events processing) on vehicle location data.
As far as I can recall, a vehicle would periodically (every couple of seconds even) send its GPS coordinates to the engine (an event) which would then be digested by the rules engine, and depending on the rules could trigger certain actions such as raising alerts ("vehicle is stalled" or "out of course") or sending notifications ("vehicle will arrive at destination in ~15 minutes").
(Google for "drools fusion cep vehicle tracking" uncovers this presentation which should give you few more details or at least provide some insight.)
the way Drools work, is that you fill in alot of objects into the "Working Memory" of Drools. While you fill in the objects, Drools will find out which rules "fires" on the objects and stores the objects in a Rete-Tree. When you are finished putting the objects in the memory and you fire all rules, Drools will process the code you wrote corresponding to the rule.
I would suggest, that you make an object with all the data recieved from the vehicle necessary for your rules and put it in the working memory.
In Drools you should make many small rules, each just checking one thing and acting on the result.
It is not a good practice to let Drools get data needed for evaluation, but I can't see any problems in letting Drools trigger some events, that send messages to a vehicle or some other system. (I guess that should happen async, so that you don't slow down Drools) In fact, Drools offers you to hook up an eventlistener.
There's no reason to run every 15 minutes. That will introduce delay in the triggers and also result in bursts of load every 15 minutes followed be periods of no load.
You can have a flag in your database for new alert rules and new location data. When you scan for events, you can use a two-pass approach. Check all new rules against all location data and mark them no longer new. Then check all new location data against existing rules and mark them no longer new.
You can run this as often as you like. Ideally, you wouldn't wait that long because the longer you wait, the more work you accumulate.
As for having the TCP communicator check for relevant alerts over the scan the database periodically approach, the main advantage would be alerts would be immediate. The disadvantage would be that alert processing would slow down the TCP communicator path and you would be locked into a "one update means one check for alerts" model.
In the "scan the database" approach, if load gets too high, you can wind up checking for alerts only on every so many updates from high-frequency update sources. This naturally deals with load by reducing the amount of work needed, but it could result in a missed alert.
I think all the approaches you're considering will work fine.

How to Filter calls in NOKIA N73

I am am new to mobile app development. But i would like to know if this is possible to intercept incoming calls on my N73 using code like Java or C++?
My second question is if this is possible then can we prevent the phone from ringing with a specified phone number from a black listed contact???
I've seen a lot of apps doing this task but i am interested in knowing if this is feasible & how this is accomplished.
Thanks in Advance.
In C++ you can use CTelephony from etel3rdparty. Use NotifyChange() to subscribe to EVoiceLineStatusChange events. On an EStatusRinging event you can call GetCallInfo() to retrieve the remote party information, including phone number, and then decide whether to reject the call or let it keep ringing.
As far as I know, the CTelephony API does not have a direct method of rejecting a call but you can achieve almost the same with AnswerIncomingCall() followed by HangUp(). Your executable will need the NetworkServices capability.
A more hackish way to reject the call could be to use RWsSession to simulate pressing the red key (end key): call SimulateRawEvent() to send TRawEvent::EKeyDown and EKeyUp events on EStdKeyNo, with some delay between the events. In this case your executable will also need the SwEvent capability.

Categories