Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Using SECRET_CODE from android.provider.Telephony

Tags:

android

I want to implement a basic idea to make a balance sheet in android. If I write *#*#1234#*#* on my number dial screen then it must simply increment 34 in my app(or maybe in a text file). In search to implement this idea, I came across android.provider.Telephony.SECRET_CODE.

What I want is to read any number like *#*#<number>#*#* from the dialpad of phone. So I want my code to run in a way such that it identifies any code of this format as the secret code: *#*#12$$#*#*. I suppose it is hard to think if there is any way in which it can work, but if anybody knows anything, I would be very curious to know. Thanks a lot in advance!

like image 355
subtleseeker Avatar asked Jan 24 '18 07:01

subtleseeker


People also ask

What is the use of * * 4636 * *?

*#*#4636#*#* Displays information about the phone, battery, and various network statistics.

What is Android provider telephony?

provider. Telephony is part of the Open Source releases, but never included as part of the Official SDK. Meaning you are free to view it, to gain a understanding of how the underlying system works, but you can't actually reference and compile against it in your Android application(s).


1 Answers

http://blog.udinic.com/2013/05/17/create-a-secret-doorway-to-your-app

Check this link out.

Here is a sample piece of code. In your manifest, declare your receiver and with a secret code for example: 111222

<receiver android:name=".receiver.DiagnoserReceiver">
    <intent-filter>
        <action android:name="android.provider.Telephony.SECRET_CODE"/>
        <data android:scheme="android_secret_code" android:host="111222"/>
    </intent-filter>
</receiver>

Then create the receiver:

public class DiagnoserReceiver extends BroadcastReceiver {

    public void onReceive(Context context, Intent intent) {
        if ("android.provider.Telephony.SECRET_CODE".equals(intent.getAction())) {
            //Do your increment here
        }
    }
}

I suppose if you want multiple numbers, you can add the variants of codes that your app will listen for:

<intent-filter>
    <action android:name="android.provider.Telephony.SECRET_CODE"/>
    <data android:scheme="android_secret_code" android:host="111222"/>
    <data android:scheme="android_secret_code" android:host="1234"/>
    <data android:scheme="android_secret_code" android:host="1235"/>
    <data android:scheme="android_secret_code" android:host="1236"/>
    <data android:scheme="android_secret_code" android:host="1237"/>
</intent-filter>

EDIT:

You can try this SO post I found

only to match the beginning of host. The rules are these:

  • Put * as the first character of the host.
  • Write the rest of of the host until the end.
android:host="*site.com"
android:pathPattern=".*"
android:scheme="http" />

It will catch links of:

  • www.site.com
  • site.com
  • mail.site.com

So you should be able to wildcard the font of the

<data android:scheme="android_secret_code" android:pathPattern="*" android:host="*34"/>

In theory it should work for 0034 ... 9934

**CAUTION: **

Anyone can decompile your app and see the codes in the manifest file. So whatever you do, make sure it is secured. IE. If you open an activity from the receiver, make sure the activity asks for a password first.

OR

Another way to be more safe is to register the broadcast receiver in your MainApplication class in onCreate - add intentFilters to your liking, this way your codes are not exposed in the android manifest file but it will not work if your app is completely closed or swiped away. Simply open the app, (wait for the broadcast receiver to register), minimise it, type in your code, and voila.

like image 190
Pierre Avatar answered Sep 29 '22 11:09

Pierre