android

Install Google Services, Superuser, Busybox in Android Emulator

Posted on

This post will help you to install the required Google Play Store, Superuser and Busybox binary in your Emulator.

Download the required files from the following URL
GOOGLE SERVICEShttp://www.mediafire.com/download/7cps3k7qgyjcpsp/Google%20Services.zip
SUPERUSER BINARYhttp://www.mediafire.com/download/bgy1et6e3vytge7/Superuser%2520binaries.zip
BUSYBOX BINARYhttp://www.mediafire.com/download/mye5qcejxk54e6v/Busybox%2520binary.zip

The following urls contains a zip file which after extracting would find “install.bat” file. This bat file contains the necessary scripts for installing the corresponding apps and binaries.

The commands present in script file are given below.

1:Installing Google Play Store

adb shell mount -o remount,rw -t yaffs2 /dev/block/mtdblock0 /system
adb shell chmod 777 /system/app
adb push GoogleLoginService.apk /system/app/
adb push GoogleServicesFramework.apk /system/app/
adb push Vending.apk /system/app/
adb shell rm /system/app/SdkSetup*

2:Installing Superuser binary

adb shell mount -o rw, remount -t yaffs2 /dev/block/mtdblock0 /system
adb push su /system/bin/
adb push Superuser.apk /system/app/
adb shell chmod 06755 /system/bin/su
adb exit

3:Installing Busybox Binary

adb shell mount -o rw,remount -t yaffs2 /dev/block/mtdblock0 /system
adb push busybox /system/xbin/
adb shell chmod 06755 /system/xbin/busybox

Please note that once the emulator has been closed the the above files will be deleted. So again the process should be repeated when the emulator is started once again.

IMEI and Custom ROMs

Posted on Updated on

Recently Android KitKat (4.4) has been released and now available in Google’s flagship device NEXUS 5. On every Android update there comes the introduction of CyanogenMod custom ROM or simply CM. The latest release of CM is v11. But CM11 has been released only for few devices. For my luck I could find CM11 or Android KitKat ported on my device (SGS I9003) that too an unofficial version in XDA forum. Let me personally thank the person behind porting CM11 on SGS I9003 (http://forum.xda-developers.com/showthread.php?t=2534312) . So as usual I installed the ROM using the steps specified in the forum and I could successfully boot into the new OS.   The very first moment I entered the home screen after some registration procedures I could find few random changes compared to Jelly Bean starting right from the dock menu to settings page. Anyways the new OS is looking too cool and thought of keeping the device for testing overnight before using the new OS for regular use.

After 24hrs of use I could find that the phone doesn’t connect to network provider. So I started to figure out the cause. From my observation I found that the device is having data connectivity but no telephony services. Later I replaced the SIM with another one but still the problem persists. Suddenly something caught in my eyes that the IMEI number has been changed when the new OS has been installed. The following is the new IMEI generated in my device when the OS (CM 11) has been installed.

                                                               ” 004999010640000

Here is the issue, I will give a brief explanation which I found in XDA forum ( http://forum.xda-developers.com/showthread.php?t=859914) . This could be really useful for those who really prefer to install custom ROM rather than stock OS. (THIS IS ONLY FOR SAMSUNG DEVICES)

Samsung uses RFS as their default file system. The IMEI number is stored in /efs folder found in the root directory.  This is a very sensitive system folder that contains Phone-specific information such as the IMEI , wireless devices MAC addresses, product code, and much more.The file system used by custom ROMs are YAFFS (Yet Another Flash File System). When custom ROMs are installed the filesystem will be changed to YAFFS and hence the RFS file system cannot be accessed since it is  proprietary of Samsung. So for as result the default device sensitive information are not available. To overcome this issue please use the following steps to recover back your lost IMEI number once custom ROM has been installed.

Step 1: Creating backup of the IMEI before flashing the stock ROM

  • While in stock ROM create a backup of the efs folder using the following command either in ADB or terminal emulator
                  ADB command prompt: su tar zcvf /sdcard/efs-backup.tar.gz /efs 
                  Terminal Emulator: busybox tar zcvf /sdcard/efs-backup.tar.gz /efs
  • The above command will create a backup of “efs” folder in your internal memory. Please copy the backup file to your sdcard.

Step 2: After installing custom ROM and restoring back the IMEI

  • Now extract the contents of the backup to your sdcard and perform the following commands using Terminal Emulator App
                      cp /sdcard/nv_data.bin /efs/nv_data.bin 
                      rm -rf /efs/nv_data.bin.md5
  • The first commands will copy the backup file “nv_data.bin” to your efs folder. And the second command will delete the existing “nv_data.bin.md5” since we have replaced the another file for “nv_data.bin” and the hash signature has been changed. Reboot the device and the system will generate a new “nv_data.bin.md5” file. Make sure you have rebooted the device after executing the above commands.
  • Now after rebooting the device use the following command in Terminal Emulator app to change the ownership of the file
                       chown 1001:1001 /efs/nv_data.bin
  • Cheers!! You have successfully replaced your default IMEI number.

OBD2 CAN-BUS scanner

Posted on Updated on

Finally after a long wait I received the order for OBD2 Bluetooth scanner. It looks quite bulky as I thought but it quite fits perfectly into my cars OBD port.

IMG_20130803_103257

Once successfully connected to OBD port I paired my phone with the OBD scanner using Bluetooth connection. I installed a couple of most popular OBD2 scanner apps for Android and the output which I found was far more amazing. I could really communicate with my car and read the data from car ECU.

Untitled-1

Does Android has anything to do with an automobile?

Posted on Updated on

My question is whether Android has anything to do with an automobile????

OK folks lets dive into something interesting topic..This time I have got something fishy stuff which I found in the web few days back… As usual I was searching for new updates and new apps published in Android Play Store but suddenly something got stuck to my attention regarding OBD Bluetooth, OBD Console etc etc. But then I just had a look on those apps and could find something similar to speedometer apps found in the market. Later doing small research I could understand that those are diagnostic tools for cars. Once again Android has proved that its not a mere OS built for making calls, sending sms etc it has capabilities beyond a standalone mobile OS.

OK I was taking abt OBD OBD!! Any idea?? Well I am not an automobile mechanic but I would explain what I found on the web.. OBD stands for On Board Diagnostics. It is in fact used for self diagnostics and trouble shooting in automobiles. For more info http://en.wikipedia.org/wiki/On-board_diagnostics  On Board Diagnostics are done via OBD port found in cars. Say for example the one found after a long search inside my car

2013-06-08 13.15.08

ODB port usually contains 16pins. From the above figure you could find that only six pins are enabled. Here is the complete pin out diagram

obdii_port1070929671

(Ref: http://mbed.org/media/uploads/fossum_13/obdii_port1070929671.jpg)

OBD ports are usually present in most of the modern cars. You could have a small search beneath the steering column or under the hood.

Ok lets return back to our topic..we were discussing what Android can do with these ports. In fact we could create an interface with our Android device using OBDII Bluetooth connector. The Bluetooth connector looks something similar to this

312EZKI6M+L

The one featured above is ELM327 Bluetooth OBDII OBD2 Diagnostic Scanner readily available in amazon. If we are able to create an interface between our car and  Android device then there opens a whole new world of apps that could convert an Android device into something a different tool for vehicle diagnostics and monitoring such as speed monitoring, fuel statistics, engine temperature etc etc. I think geeks have already started rolling out apps for On Board Diagnostics. Here are few

and lots more……..

Service- Does it serves as a background thread?

Posted on Updated on

Services are one of the important application components in Android that helps to execute long running operations in background. In fact what I thought was, Services would execute as a background thread without interrupting the main thread. But soon I found that my assumption was wrong, in fact Service also run in the main thread of the application  where the UI operations occur. Therefore, if we perform a long task in onStartCommand() method, it will block the main thread the end result is, unresponsive application . So to avoid the problem, you have to execute the complex task into a separate thread. this can be achieved with the help of

  • Asynctask
  • Declaring seperate Thread

Additionally there two memory management techniques as well. Declaring the return statement in onStartCommand() method.

START_STICKY: Notifies the OS to recreate the service after it has enough memory and call onStartCommand() again with a null intent.

START_NOT_STICKY: Notifies the OS  not to recreating the service again.

Threat to mobile developers and server side programmers

Posted on Updated on

Well, its year 2012 we all know that technology has no limits especially in the field of IT. We can see innovations emerging from every nook and corner. In the case of IT the programming world has expanded like anything  where we can find new programming languages being developed for every single piece of software or for large systems. Anyways today I would like to share some interesting stuff that may pose threat to mobile developers and server side programmers. First I would discuss about the threat that mobile developers gonna to face in future.

  • In fact I would rather say mobile developers are the one who is gonna to get a hard kick on their back. Nowadays there are many cross platform SDK’s available online. The benefit of using cross platform SDK’s are many. One of the advantage is that the code can be executed on different platforms such as iOS, Android, Blackberry, Windows mobile etc. Another advantage is that the developer need not to know indepth of mobile programming. Apart from these advantages there are disadvantages as well. The apps created using cross platform SDK are poor in performance. Say for example the touch events, scrolling etc. They couldn’t directly access the core hardware layers of the device. In short cross platform SDKs are more focused for web developers rather than mobile developers. Such SDK’s are not using any native functionality provided by the OS vendors. Rather they use Javascript, HTML5, JQuery for the development. Mobile development knowledge is only required for integrating the components. Some of the popular cross platform SDK’s are PhoneGap, Titanuim, Sencha Touch etc. These are only few examples you could find many other on web. I am rather confused why people prefer cross platform SDKs when you could get fully function native SDK from their respective developers. Lets see what happens next.
  • Ok lets dive  into server side programming and see whats gonna to hamper their future. First of all let me say I am not a server side programmer and I doubt whatever things that I am gonna to say is right or wrong. Yes, lets continue. Rrecently I came across a SDK known as “Parser”. For more info https://parse.com/. I am not elongating much, in short the SDK allows our application data to be stored on cloud rather than on servers. This SDK is meant for mobile developers who need not to know the server side programming such as PHP, JQuery whatever.  Knowledge in mobile development is mandatory. You have complete control over your application data. Only thing you have is an account in parse. It supports mobile OSes such as Android,iOS  and Windows. The SDK has got a very good documentation where you can get started with your server side coding for your app.  Maybe it might have disadvantages as well.

END NOTE:

Whatever cross platform SDKs or ready made clouds are available still the native technologies on which the systems are built are more suitable at any situations.

Iphone development from the view of an Android Developer

Posted on Updated on

Well, it’s been long that I have published posts in here. Things happen when people are engaged in other work or maybe not having time to manage things or being lazy all time whatever. Ok anyways this time I have come up with an interesting topic which may give some idea on how iphone programming is similar to android.  

First of all let’s start with the application structure of both the platforms

 (Iphone Project Files )                                                                                                                                             (Android Project Files)

When you first create an iphone project in XCODE the following default directories are created

  • Classes: Contains the class files required for the project (Same as src folder in android). The class files are of three types
    • .h file: Header file
    • .m file: Objective-C source file
    • .xib file: Interface Builder file (Same as the XML layout file found in the res->layout folder in android project)
    • Other Sources: Contains the main file required for the project. The app starts by executing the main file.
    • Resources: Contains the resources required for the project such as Image, Sound, Video etc (Same as the res and asset folder in android).
    • Frameworks: Contains the package required for the project (Same as lib file in android)
    • Products: Contains the final compiled app ending with extension .app whereas for android the final product name ends with .apk extension(Same as the apk file generated in bin folder of android project)

Android project contains a file named “AndroidManifest.xml” which forms the skeleton of an android app. It contains information about the SDK version, permissions, Class names, app version etc. In an iphone app there is no such file named manifest. Instead all the above said parameters are defined in a neatly but complicated user interface known as BUILD SETTINGS.

 

Now let’s discuss about the application life cycle in both the platforms because life cycle methods defines how the application should behave according to various conditions. In iphone project two files are created along with the class files known as ClassnameAppDelegate.h and the corresponding counterpart .m file. The app delegate has two roles in here, it defines the various lifecycle of an app and also acts as the Application object class same how we declare variables and getter/setter methods in android application class. The various lifecycle methods defined in iphone appdelegate class are

•             – (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions

•             – (void)applicationWillResignActive:(UIApplication *)application : Same as onRestart() in android

•             – (void)applicationDidEnterBackground:(UIApplication *)application: Same as onPause() in android

•             – (void)applicationWillEnterForeground:(UIApplication *)application: Same as onResume() in android

•             – (void)applicationDidBecomeActive:(UIApplication *)application: Same as onStart() in android

•             – (void)applicationWillTerminate:(UIApplication *)application: Same as onDestroy() in android

Other similarities as of development scenario. Both the OSes have excellent IDEs and SDKs for development with rich in features and the appropriate emulators and simulators. When the variable declaration and coding style comes both the programming languages differs a lot. Objective-C is actually a highly customized C programming language. In fact apple might have developed such a customized language so that it won’t hamper the smooth functioning of iphone nor to cause any memory overflow or CPU load.  Now in the case of declaring variables and methods iphone uses datatypes declared in Foundation class (jus google out regarding Foundation class too lazy to explain thats why J ). For example for declaring a String variable we use “NSString *variable;

Now defining a method the syntax in Java is “functionName(String  value);” but as of Objective-C the syntax is [self functionName:NSString *value];

Now regarding access specifiers. In java we use private, public and protected. In objective-C we use the same notations except for @ symbol as prefix i.e, @public, @private and @protected.

If we say about exception handling Objective-C applies the same syntax as that of java. i.e,

@try
{
//some code
}
@catch
{
//catch block
}
@finally
{
//finally exececute some code
}

Another similarity is the use of “this” pointer. In Objective-C the “this” pointer is declared as “self” and every overriden methods in java are defined in delegates in objective-c. Say for example if you have ListView in android and the ListView will have set of predefined overridden methods similarly in the case of iphone say for example the overridden methods for a Tableview are defined in their corresponding delegates.

One more important factor to be considered while programming in iphone. Iphone doesn’t have automatic garbage collection technique. So this means whatever variable you have declared should be released after use otherwise beware of MEMORY OVERFLOW.

Hope my little briefing might have helped you in understanding the similarities and differences in both the platforms in some way or the other. So keeping visiting my blog  for more updates. Happy coding!!