Friday, January 27, 2012

Android Hidden API's



Following are some Examples for hidden api..
ReadSMS code example
This is a small code example that shows how an application can read the internal SMS database. The hidden part here is the content URI to the SMS database: “content://sms/inbox”. This code example only requires the following permission to read SMS: “android.permission.READ_SMS”.
Tethering code example
This code example demonstrates how an app can use Wi-Fi with the Java reflection methods. This code example must be signed with a system certificate, and it must also share the User Id with the system. The system User Id is declared shared by declaration in the Android manifest:
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
package="com.sonyericsson.tetheringdemo"
android:sharedUserId=="android.uid.system"
android:versionCode="1"
android:versionName="1.0">
This code example also requires a set of Wi-Fi permissions:
<uses-permission android:name="android.permission.CHANGE_NETWORK_STATE" />
<uses-permission android:name="android.permission.CHANGE_WIFI_STATE" />
<uses-permission android:name="android.permission.CHANGE_WIFI_MULTICAST_STATE" />
<uses-permission android:name="android.permission.ACCESS_NETWORK_STATE" />
<uses-permission android:name="android.permission.ACCESS_WIFI_STATE" />
<uses-permission android:name="android.permission.WRITE_APN_SETTINGS" />
The hidden API here is the broadcast intent: “android.net.wifi.WIFI_AP_STATE_CHANGED”. This is received by the broadcast receiver in the project. The hidden method in this class is called setWifiApConfiguration and it is reached using the Java reflection method in that class.
WifiConfiguration config = new WifiConfiguration();
config.SSID = "EriksOpenWifi";
config.allowedKeyManagement.set(WifiConfiguration.KeyMgmt.NONE);
String setWifiApConfigurationMethodName = "setWifiApConfiguration";
Method setWifiApConfigurationMethod = wifiManager.getClass().getMethod(setWifiApConfigurationMethodName, WifiConfiguration.class);
result = (Boolean) setWifiApConfigurationMethod.invoke(wifiManager, config);
This code snippet is used to reach this code:
public boolean setWifiApConfiguration(WifiConfiguration wifiConfig) {
try {
mService.setWifiApConfiguration(wifiConfig);
return true;
} catch (RemoteException e) {
return false;
}
}
Overlay and Touch input code examples 
These two code examples work together in order to demonstrate how to do touch input and how to draw a window on top of the currently active window. These code examples need system permissions, and must be run as system user.
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
android:sharedUserId="android.uid.system"
package="com.sonyericsson.overlaydemo"
android:versionCode="1"
android:versionName="1.0">
The two things requiring system privileges are the permission “.provider.Telephony.SMS_RECEIVED” and the direct interface to the window manager. To use the code example requiring the system certificate, you need to sign your apps with the keys of the system certificate. To try this, you can use a phone with a custom ROM.
Other then this there are so many api which are hidden in android,but by doing some R&D you use them also........

No comments:

Post a Comment