Wednesday, June 18, 2014

Should you root your Android Phone?

There are many settings that can be tweaked in an Android device; however, these tweaks are restricted to what the manufacturer permits. Rooting an Android device or gaining root access allows tweaking the device at a very deep level. But, is it OK to root your Android? Lets checkout the good and the bad.

Having the freedom to tweak your OS has been and will always be of great importance for any open source geek. With Google backing the porting of Linux-based operating systems to handheld and portable devices, this freedom has increased manifold. Companies building up mobile phones and handheld devices have had to give in to Android’s growing popularity as it’s competing head-to-head for space with other popular mobile operating systems such as the iOS, Blackberry OS and other proprietary operating systems. A number of tweaks and functionalities have been added to the most recent version, Android KitKat, which was released at the end of October 2013. However, a number of users continue to be on earlier Android versions such as Jelly Bean (on devices with low hardware configurations).

As with other open source desktop operating systems, it is possible for Android users to tweak or change any part of the system within the limitations set by the open source community and by the licences. Although there are several apps available on the famous Google Play store, Android primarily doesn’t allow its users to make any changes to the system. This can, however, be achieved by using a method commonly referred to as the rooting of an Android device. A device that has undergone this procedure is referred to as a rooted phone or tablet. The name is derived from the term ‘root access’, which is actually the ability to attain permissions only restricted to super-users or administrators. Rooting allows you to perform a number of operations that would have been otherwise impossible because of the limitations set by the carriers or phone manufacturers.

Although rooting your device might sound like a great idea, there are several disadvantages that negate its advantages. Before I go ahead with the procedure for rooting an Android device, let us look at the factors that will affect your decision on rooting.

What you might lose?
Bricking your phone
When you’re tampering with your phone’s operating system, you should be aware that one wrong move could damage the device’s software, turning the phone into a useless brick. So if you are wary of taking risks, please refrain from trying this procedure. Although the risk is minimal, rooting your device is still quite a risky business. So, you need to be absolutely sure of what you do.

Manufacturer’s warranty
The process of rooting in almost all cases challenges several clauses in the agreement with the hardware manufacturer and results in the warranty becoming invalid.

Legality
Rooting a phone is allowed legally almost everywhere in the world. In fact, in some European countries, replacing the original operating system with another does not void the statutory warranty that covers the hardware of the device.

Security concerns
Rooting essentially allows applications to perform actions that require administrative privileges. The real reason for disallowing all applications from obtaining these privileges is to ensure air-tight security in this amazing operating system. Although Android has not been plagued by viruses, Trojans, spyware, malware and other members of the digital disease-causing pathogens, it is only a matter of time before anti-social elements try to exploit the innocent. Rooting your device is like giving ammunition to these elements on a silver platter.

What do you gain?
Despite these drawbacks, a number of users continue to root their phones or tabs. The gains are listed below.

Delete those pesky apps
Did your manufacturer bundle your phone with promotional applications and games that cannot be deleted? Geeks refer to these apps as bloatware, as they usually take too much space on the device’s memory. So, it is always advisable to remove all that you are never likely to use. However, you have to be especially careful not to delete any system app that can affect the basic functionality of your device. What you can safely remove are games and apps that have the manufacturer’s brand name.

Take essential back-ups
Rooting your device takes the performance of system and data back-ups to a completely new level. In addition to backing up user data, you can also back up applications and settings. Also, rooting allows you to take Nandroid back-ups, which is essentially a back-up of the complete operating system. The name Nandroid is a portmanteau of NAND, which is the widely used Flash memory on these devices, and Android.

Apps galore!
If you think that 1,000,000 (a million) apps and 50,000,000 downloads would be enough for open source enthusiasts, you are sorely mistaken. In addition to Google Play, there are several app distributors and stores available online. The most famous among these is F-Droid, an alternative software repository comprising only free, open source software. A quick search would reveal that most of the apps available on these stores require super-user permissions.

Playing dress-up
Almost every hardware manufacturer bundles Android devices with tones, themes and skins that are specific to their organisation. However, you are not allowed customisation beyond a certain level. By rooting the device, not only can you change the way your system sounds or looks, you can also use the customisation options provided by other companies.

Staying up-to-date
As manufacturers come up with newer devices, it is customary for them to stop providing updates for the older ones. Also, there are several devices that possess the hardware specifications to run newer versions of the Android operating system but are stuck without any updates because of the business gimmicks of these manufacturers. Rooting allows you to install not only the new features but a tweaked kernel or a new operating system altogether.

Custom ROMs
Almost all phone and tablet manufacturers modify the Android operating system and bundle the device with a custom made OS with their own branding. The basic Android version specific to a device is known as a stock ROM. Most stock ROMs are also bundled with useful software, specific to the device’s manufacturer. Custom ROMs are modified versions of the Android operating system, created for a specific device by a third-party developer. Several developers have taken great pains to make it possible for users with low-end phones to enjoy the benefits of the latest developments in the Android world. Several companies such as Cyanogenmod sprang up to cater to people facing such limitations with their own fork of the Android operating system. Although rooting is strictly not essential in order to install a stock or custom ROM, it provides you the ability to take customisation and personalisation to a whole new level.

Automation
With automation touching every aspect of life, it would be natural to also want our phones to think and act as per our wishes. There are several apps available on Google Play and other app stores that allow you to automate devices. One of the best applications for this is Tasker, which helps you create tasks for greater automation. With such apps, you can have your phone switch from data to Wi-Fi, based on location. You can combine task killer apps and ensure that your tablet consumes the least possible battery, especially when you’re not using it. Rooting lifts the software restrictions and renders anything that’s within the limitations of the hardware possible.

The preparations
Before you actually go ahead with rooting your device, there are several steps to be followed. The most important is to ensure that you install the latest drivers for your device on the computer to be used in this process. You must also download and install the latest Android SDK from the https://developer.android.com/sdk/index.html website. In addition, you need to put your phone into the USB debugging mode. To do so, enter the Developer Options in the system settings. You will be required to enable Developer Options and then enable USB debugging. A USB cable will also be required.


The real deal
I recommend you take a back-up of all your personal information on the memory card or a computer before you move forward with the actual rooting procedure. The process for rooting a phone or tablet varies greatly, depending on the device and the operating system of the computer used in the process.
There are several third-party applications, especially for the Windows, Mac and Linux operating systems, which allow you to connect the device and root without much intervention. Some of the popular applications for this process are Once Click Root, CF-Auto-Root and Super One Click. Most of these applications provide step-by-step instructions (sometimes with images) on how to root your device. Based on your device, the process will require you to press several buttons and reboot. As the steps vary from device to device, you need to search the Internet to find the best application-one that has had the most success with your device. Almost all these applications install the Superuser app that helps in granting super-user permissions or root access to other apps. There are also several ways to root a device using terminal commands from a Linux distribution. However, this procedure is only for experts. To verify if you have gained root access of your device, you can use apps such as Root Checker by joeykrim and Check Root by Avarna Software.

What happens next?
Once the rooting procedure is complete, you will see an app named Superuser, SuperSU or something similar among other installed apps on your device. Open the Superuser app and update it to obtain the latest version.

Superuser and SuperSU
As and when another app requests for super user permissions, the SuperSU app gives you a pop-up to ask whether or not you want to grant such access. Based on the option you choose, you can have SuperSU prompt you at a later time or not prompt you for access till the app is updated. Ensure that you provide root access only to trusted apps and revoke permissions for those you are unsure of. In addition, it is a good practice to have an app ask for permissions every time. This allows you to keep track of the apps yourself, in addition to the logs maintained by SuperSU. Superuser, SuperSU and other similar apps also allow you to unlock additional paid features and improve the functionality further. However, for a basic user, the free features would suffice.

Busybox
Called the Swiss army knife of embedded Linux operating systems, Busybox is actually a stripped down version of powerful Linux tools made available for the Android operating system. You can visit http://www.busybox.net/ for more information on this project. If you’re into tweaking the device even further, you will need to make use of the several tools provided in this bundle. Some custom ROMs provide Busybox just as they do with SuperSU or Superuser. If not, there are several Busybox installers available on the Google Play app store, the most popular one being the BusyBox app by Stephen (Stericson). Most of the commands are the same as their counterparts on other operating systems.

SQLite
If you’re into heavy duty tinkering, you will require specialised tools. SQLite is a relational database management system that is used by several apps running on Android. There are several apps available on the Google Play store and on F-Droid that allow you to install the SQLite3 binary application on your device. Once this is installed, you can use database viewers and editors as per your convenience. I would like to recommend the ‘SQLite Installer for Root’ app by Ptsoft in case you plan to use a stable and secure installer.

The terminal
People with knowledge of the Linux command line will feel right at home in the terminal emulators available for Android. The Google Play app store showcases several terminal emulator apps that allow you to run shell level commands in Android. Some of the best terminal emulators are available on F-Droid, an open source repository of Android apps. Terminal emulators are also useful for running Busybox commands.

File explorers
Several file explorers, such as Root Explorer, allow users to view and edit Android system files if you grant them super-user permissions. You can also change file and folder permissions with the help of such applications. Most of these apps also allow you to connect to cloud storage and seamlessly work with archives and other such files.

Bye bye bloatware!
As discussed before, rooting allows you to remove the bloatware provided by your hardware manufacturer that you couldn’t get rid of previously. Apps such as Root App Delete are available on the Google Play store and help you free up space. However, you are advised not to remove or disable system apps as they may hamper the functionality of your device. Similar to bloatware, unwanted ads is another problem that most people face. To block ads, these apps require root access to write into the hosts’ folder in the Android system.
In addition to the above mentioned entities, there are many more avenues to be explored. Rooting, if done responsibly, opens new doors and adds tons of functionality to your devices

Tuesday, April 15, 2014

[Android] How to Set Status at facebook


We live in a social network world more than in real world. And so android applications also need to provide sharing links for the Social network Giants Facebook and Twitter. The big Question comes: HOW!!

Well, I am an android developer, and faced a similar issue when it came to share at facebook.

Here, I will be demonstrating using a third-party SDK: easyfacebook (Official site here).

Reason for using third party tool: Facebook's official SDK needs Facebook app to be installed in the phone. If it is not, it won't work. But my app requirements were to be the least dependent-on-others app. EasyFacebook SDK does not need Facebook app to be installed.

No. 2 reason can also be stated as I was not able to get how to implement Facebook's Official SDK. The tutorials I found on the internet or via stackoverflow were outdated. The basic classes that those tutorials used were deprecated in the new version. So, I was even confused on how to use it. But I will post the tutorial with the latest Facebook SDK soon. (As soon as I complete my current project update)

However, EasyFacebook though not upgraded since ages. It was last updated far back to 2011. But still, it works. N the best thing, works without any pre-requisite of Facebook app. I love being independent as possible (Indian by heart.. <3)

Steps to implementation:

1. Make Facebook Application. To connect your app to Facebook, you must have an application at Facebook. Go to developers.facebook.com, If your visiting for the first time, it may ask you to register. Register with your facebook account.

Now as seen in image: Click on Create a new app.


Now, You will get a window for creating a new app. Type in your Application name and namespace. Choose the category and click on "Create App"

Here you go! You will get a Dashboard. Just copy your APP ID. It will be used in your application.


Now, last step at Facebook application: Register your Android App details. To do that, you first need your Key Hash. To find the key hash of your working system, follow these steps:

To generate Key Hash signature you need openssl installed in your PC. You can download it from here. Open Command prompt. Run the command:

 keytool -exportcert -alias androiddebugkey -keystore "C:\Users\Ravi\.android\debug.keystore" | openssl sha1 -binary | openssl base64  


It will ask you for your a password. Give password as "android" removing quotes. If it does not, make sure the path of keystore. The path mentioned here is generally the default, However, it may vary.

You will get an output with some big code and possibly "=" in the last. Copy the key hash.

Now, moving back to your Facebook Developer Portal. Go to settings. and fill in the following as shown in figure:



Click Add Platform, Select Android. Fill in the details. as shown. N click Save Changes.

Half work over. Really? Naa... It was just 25% yet!


Now, lets come to your facebook app. Download easyfacebook SDK from this link. 2.3 is the latest while writing this blog. Although it was last updated in far back 2011. But still can't say if the developer updates it.

So, after downloading .jar file, keep it in your lib folder of your android project. Open Eclipse, Go to your project--> libs Right Click easyandroidfacebooksdk2.3.jar --> Build Path --> Add to Build Path

Now, for newbies: Keep in mind, To make a share program, you have to create a new Intent for that. So, create an activity first, Here in tutorial, I am using "Fb.java"

Here is the code for your Fb intent:


 package com.innovativejumbo.androidFb;  
 import android.app.Activity;  
 import android.os.Bundle;  
 import android.util.Log;  
 import com.easy.facebook.android.apicall.GraphApi;  
 import com.easy.facebook.android.data.User;  
 import com.easy.facebook.android.error.EasyFacebookError;  
 import com.easy.facebook.android.facebook.FBLoginManager;  
 import com.easy.facebook.android.facebook.Facebook;  
 import com.easy.facebook.android.facebook.LoginListener;  
 public class Fb extends Activity implements LoginListener {  
      private FBLoginManager fbLoginManager;  
       //Add here your own Facebook App ID  
       public final String APP_ID = "insert_your_app_id";  
       @Override  
       public void onCreate(Bundle savedInstanceState) {  
       super.onCreate(savedInstanceState);  
       connectToFacebook();  
       }  
       public void connectToFacebook(){  
       //read about Facebook Permissions here:  
       //http://developers.facebook.com/docs/reference/api/permissions/  
       String permissions[] = {  
        "publish_stream",  
        "publish_actions"  
        };  
       fbLoginManager = new FBLoginManager(this,  
        R.layout.activity_fb,   
        APP_ID,   
        permissions);  
       if(fbLoginManager.existsSavedFacebook()){  
        fbLoginManager.loadFacebook();  
       }  
       else{  
        fbLoginManager.login();  
       }  
       }  
       @Override  
       protected void onActivityResult(int requestCode, int resultCode, android.content.Intent data){  
       fbLoginManager.loginSuccess(data);  
       }  
       public void loginSuccess(Facebook facebook) {  
  final GraphApi graphApi = new GraphApi(facebook);  
            Thread myThread = new Thread(new Runnable() {  
                @Override  
                public void run() {  
                     // TODO Auto-generated method stub  
                     User user = new User();  
                      try{  
                       user = graphApi.getMyAccountInfo();  
        graphApi.setStatus("Hello World!");  
                      } catch(EasyFacebookError e){  
                            Log.d("TAG: ", e.toString());  
                           }  
                     }  
                });  
                 myThread.start();  
            fbLoginManager.displayToast("Posted to Facebook successfully");  
          //finish this intent activity after posting.  
            finish();  
       }  
       public void logoutSuccess() {  
       fbLoginManager.displayToast("Logout Success!");  
       }  
       public void loginFail() {  
       fbLoginManager.displayToast("Login Epic Failed!");  
       }  
 }  

Call this Intent whenever you want to set the status.

If the user is logged is not logged in, a window will appear to login to Facebook.

If you are using this for the first time, the application may ask your granting the request to post to Timeline. Click OK and it will be posted. Next time, it will be posted automatically as the intent is being called.

You have many more Facebook functions also to play with in this SDK. Check here and try them out as needed. However, it lacks the documentation on how and what these methods do. Still, many of the functions are clear by their names. Give a try and enjoy.

Innovative Jumbo!