Android development
Raiting:
3

Secret codes or how I wrote my application for an Android


I think most people who have a device-based on Android OS heard about the secret codes.
There are some very powerful codes, for example one of the codes on my Samsung Galaxy Tab allows me to set up the GPS, which speeds up the search of satellites, the other code allows me to set up the mode connection with the network (GPRS, EDGE, 3G ...) that allows saving the battery between mode jumps in places with unstable connection.
I am going to talk in this article about the device analysis of running applications on the codes in Android OS, and how to find all the codes and applications, and as well I will explain how to make an application that will respond to its code.
In addition, I will give 6 pictures, some code and lots of text.

Introduction


I have heard about the Android codes a long time. The most common is *#*#4636#*#* that is information about the phone, battery, network status, etc.
image
Recently, I have installed Autostarts program, then I did search through the installed applications, and I saw something strange, namely it said “Secret Code Entered”. A whole bunch of applications responded to it! This fact roused me to a deeper search on this topic. That's what I found:

Part 1. Events in Android


As you know, every Android application contains the manifest. This specially generated XML file contains the information, such as OS version target, resolution features for an application, etc. The most interesting things are the sections describing BroadcastReceiver'y in this manifest. These are classes that react to certain events. There are many events, for example, an outgoing call is made (android.intent.action.NEW_OUTGOING_CALL), flight mode is changed (android.intent.action.ACTION_AIRPLANE_MODE_CHANGED)… The official list can be seen on the Android website.
However, the list is not complete, because each application can create its event. This brings some chaos in the documentation when you try to figure out what the application can respond to.

The event is hidden in this chaos, which is of great interest: android.provider.Telephony.SECRET_CODE

When the source codes were opened in Android, it showed when something is entered in a device that starting from *#*# and ending with #*#*, in the dialer is run search and transfer of a message to BroadcastRecever'y that responds to this particular code (that is between *#*# and #*#*).

Part 2. Responding to the code


Now let's take a look what is required from the application in order to respond to the occurrence of this event:

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

where:
<receiver android:name=".receivers.DebugReceiver"> - beginning of a section BroadcastReceiver and an indication of what kind of Receiver must be called when the event occurs.
<action android:name=«android.provider.Telephony.SECRET_CODE» /> - the actual event to which the receiver responds is a set of code.
<data android:scheme=«android_secret_code» android:host=«727» /> - and here is the most interesting place. Data block is responsible for the additional parameters of the event, and it is required for the event of a secret code. The field of android:host here means exactly the code.
In order to run the Receiver ".receivers.DebugReceiver", (the application from manifest of this block), it is needed to dial *#*#727#*#*

It is evident that to add hidden features in the Android applications is very easy.

Part 3. Searching for the Receivers


Let’s move on to Receivers search that respond to for(int i=0;i<10000;i++)

{
Intent intent = new Intent("android.provider.Telephony.SECRET_CODE",
Uri.parse("android_secret_code://"+ i.toString()));
ComponentName cn = intent.resolveActivity(pm);
....
}

I do not remember exactly the code, because it was found a better solution. This solution simply searches through all the codes from 0 to 10000, the range where is a significant part of the codes, but not all codes.
Namely this roused me to more detailed searches and led to a new solution:
1) We get a list of all installed applications through PackageManager:

List<android.content.pm.PackageInfo> pil = pm.getInstalledPackages(PackageManager.GET_DISABLED_COMPONENTS);
2) We take out its manifest from each packet:

AssetManager am = context.createPackageContext(p.packageName, 0).getAssets();
xml = assets.openXmlResourceParser("AndroidManifest.xml");

3) It is a simple magic with the manifest analysis and the search for the right Receivers, IntentFilters, Actions.

4) Profit.

This method has only one flaw: It has been noticed in SuperUser application from ChainsDD. The fact is that this application has an incomplete manifest that looks like this:

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

As you can see, it does not specify a response code, and the Receiver is called when any code is entered. When I decompile this program I realized that it was a mistake, because I did not want to keep a log of all input codes, as inside of the Receiver is checked the code equality of the specified value, and if the code is not equal, then nothing happens there.

Final part is for the most patient people


I left the final part for the presentation of results.
The result of my seeking was wonderful program, which is Secret Codes.

In addition to the above features to search the secret codes the program also allows:
- Launch found codes
- Add / read comments from other users of the codes. This is done in order that some people who are afraid of FactoryFormat could make sure that the code is safe to run it. I personally had run all the available codes for Samsung Galaxy Tab 7”.
- Assign icon codes for a greater clarity of the list of codes.

Here are 6 screenshots:

Main Activity:
image
Code search activity:
image
Code search is completed:
image
List of codes:
image
Code activity:
image
Some available icons to indicate the code:
image
That's QR:
image
xially 20 june 2012, 14:50
Vote for this post
Bring it to the Main Page
 

Comments

0 LavonnaKitz November 2, 2013, 4:42
great post, very informative. You should continue your writing. I am sure, you have a huge readers' base already!

Leave a Reply

B
I
U
S
Help
Avaible tags
  • <b>...</b>highlighting important text on the page in bold
  • <i>..</i>highlighting important text on the page in italic
  • <u>...</u>allocated with tag <u> text shownas underlined
  • <s>...</s>allocated with tag <s> text shown as strikethrough
  • <sup>...</sup>, <sub>...</sub>text in the tag <sup> appears as a superscript, <sub> - subscript
  • <blockquote>...</blockquote>For  highlight citation, use the tag <blockquote>
  • <code lang="lang">...</code>highlighting the program code (supported by bash, cpp, cs, css, xml, html, java, javascript, lisp, lua, php, perl, python, ruby, sql, scala, text)
  • <a href="http://...">...</a>link, specify the desired Internet address in the href attribute
  • <img src="http://..." alt="text" />specify the full path of image in the src attribute