Sunday, May 26, 2013

Upgrading Samsung Galaxy Tab2 to JellyBean



To my surprise, the Samsung Galaxy Tab2 PT5100 I bought was having Android ICS. So started the experiments on how to get it upgraded to JellyBean.

First what I tried was using the Samsung Kies software available in my laptop for upgrading the firmware, but that was not even recognizing the device!

As any good user of Microsoft Windows does, I too uninstalled Kies completely and installed again the latest version downloaded from Kies download link . Started the new Kies application thinking that will magically upgrade my Tab to JellyBean. But life is never that easy when it comes to Samsung Kies software.

It started giving the error "the ordinal 9272 could not be located in the ..."
After some research - came to the possible solution of installing the latest '.Net' framework
.Net Framework

 The moment I see such 'for programmer' error message from any software, I know things will not be smooth. Here also, on restart Kies started giving another error "

The ordinal 7426 could not be located in the dynamic link library mfc90u.dll"

This time possible solution was updating the VisualC++ libraries from here VisualC++ download
Also have a look at this Microsoft discussion thread discussion forum.

Luckily the problems with the Kies disappeared now(Frankly I was expecting to see couple of more cryptic error messages). But the Kies proudly reported that my Tab is having the latest software and no upgrade is available!
With this I stopped my efforts to upgrade the software using Kies.
But luckily the next day , a notification appeared in Tab indicating that an "Upgrade is available", I jumped and accepted the notification before it disappears. In around 20 min the device was upgraded to Android 4.1.2 JellyBean. Looks like we can still believe in miracles in this world!

A request to Samsung -
If the intention behind creating Kies is helping the customers in tasks like upgrading Firmware, then there are multiple areas which needs improvement. Starting with the first perception point of executing the software successfully. 
But if the intention is teaching customers about what kind of 'ordinals' are in the mfc dll then it is doing the job beautifully.


  

Sunday, April 28, 2013

Kanban Board Digital


Recently I attended a short meeting explaining the benefits of adopting Kanban, it was impressive.
What Wikipedia tells about Kanban -
Kanban is a method for developing software products and processes with an emphasis on just-in-time delivery while not overloading the software developers. In this approach, the process, from definition of a task to its delivery to the customer, is displayed for participants to see and developers pull work from a queue.

Over all I think the Kanban implementation will help the scrum teams in managing the Feature Components in a more efficient way.

Since having some free time now (having short vacation ;) ), I thought of developing a digital Kanban Board.

  1. This is a Java Swing based tool. No third party libraries used.
  2. No installation is required.
  3. Completely Free to use. 

You can download the tool from here.
Contents of the zip file are -
  • BacklogNames.txt
    • The names of the backlogs you want to have in the KanbanBoard. Feel free to edit the content.
  • KanbanBoard.jar
    • Jar file containing all Java code. You can execute this by 'double clicking ' on it or by executing the command 'java -jar KanbanBoard.jar' without quotes in a command prompt.
  • run.bat
    • Batch file to execute the program in windows machines.  Execute the batch file file double clicking on it.
Complete source code is available here 
Please note: This is provide AsIs and there is no guarantee on the quality. Please use it at your own risk.

Look at the video of the tool 

Screenshot#1

Screenshot#2

Current version of the tool uses the file system for persisting the data. But it can be easily enhanced to use database if required.

In the next version I will provide the option to integrate with any database. 

Friday, March 1, 2013

Creating SoS Android Application in 30 minutes using TelephonyManager


There are number of free and paid 'SoS' applications in the Android market , which will help the user to send a message with location details to pre-configured numbers.

Let us check here how to develop such an Android application in less than 30 minutes.

Development Environment :
Android Development Tools Bundle
Build - v21.0.1-543035

We can start by creating an 'Android Application Project'



Click 'next' on this and the next two screens.
Select 'FullScreenActivity' in the 'Create Activity' page


Give the activity name as 'BachaoActivity' and click on 'Finish'
The generated activity will have some code for using systemUiHider, we can remove these as the functionality is not required.

After doing the cleanup , the activity code will be like below


package com.team.bachao;
package com.team.bachao;

import com.team.bachao.util.BachaoUtility;
import android.app.Activity;
import android.os.Bundle;
import android.view.View;
import android.widget.Toast;

/**
 * An example full-screen activity that shows and hides the system UI (i.e.
 * status bar and navigation/system bar) with user interaction.
 * 
 */
public class BachaoActivity extends Activity {

 @Override
 protected void onCreate(Bundle savedInstanceState) {
  super.onCreate(savedInstanceState);

  setContentView(R.layout.activity_bachao);
 }

 @Override
 protected void onPostCreate(Bundle savedInstanceState) {
  super.onPostCreate(savedInstanceState);

 }

}

Next we need a add a on click listener to the button. This can be done by using android:onClick
Complete activity_bachao.xml layout content is given below

<FrameLayout xmlns:android="http://schemas.android.com/apk/res/android"
    xmlns:tools="http://schemas.android.com/tools"
    android:layout_width="match_parent"
    android:layout_height="match_parent"
    android:background="#0099cc"
    tools:context=".BachaoActivity" >

    <!--
         This FrameLayout insets its children based on system windows using
         android:fitsSystemWindows.
    -->

    <FrameLayout
        android:layout_width="match_parent"
        android:layout_height="match_parent"
        android:fitsSystemWindows="true" >

        <LinearLayout
            android:id="@+id/fullscreen_content_controls"
            style="?buttonBarStyle"
            android:layout_width="match_parent"
            android:layout_height="wrap_content"
            android:layout_gravity="center_vertical|center_horizontal"
            android:background="@color/black_overlay"
            android:orientation="horizontal"
            tools:ignore="UselessParent" >

            <Button
                android:id="@+id/dummy_button"
                style="?buttonBarButtonStyle"
                android:layout_width="0dp"
                android:layout_height="wrap_content"
                android:layout_weight="1"
                android:text="@string/dummy_button"
                android:onClick="onBachao" />
        </LinearLayout>
    </FrameLayout>

</FrameLayout>

Now the basic stuff is available. Let us look at what needs to be done when user clicks on the SoS button.
First we need to read the network information like country code, operator ID and operator name, for this we  can use the TelephonyManager provided by android.


TelephonyManager telephonyManager = (TelephonyManager) context.getSystemService(Context.TELEPHONY_SERVICE);
  if (telephonyManager != null) {
   operatorInfo.countryCode = telephonyManager.getNetworkCountryIso(); 
   operatorInfo.operatorID = telephonyManager.getNetworkOperator();
   operatorInfo.operatorName = telephonyManager.getNetworkOperatorName();
  } else {
   Toast.makeText(context, "Unable to read telephony manager"  
      , Toast.LENGTH_SHORT).show();
  }


Another information which will be useful to collect will be the cell location. But this will be possible only for the GSM connections

if (telephonyManager.getPhoneType() == TelephonyManager.PHONE_TYPE_GSM) {
    GsmCellLocation cellLocation = (GsmCellLocation)telephonyManager.getCellLocation();
    operatorInfo.cellID = cellLocation.getCid();
    operatorInfo.locationAreaCode = cellLocation.getLac();
   }


Next information we want to read is the location coordinates like Lat and Lon For this we can use the LocationManager provided by Android
final LocationManager locationManager;
locationManager = (LocationManager) context.getSystemService(Context.LOCATION_SERVICE);

Using the location manager instance, we can find the list of location providers available in the device. Some of the possible providers are GPS_PROVIDER - Use GPS to find the location NETWORK_PROVIDER - Use Network to find the location PASSIVE_PROVIDER - This is of not much use to us in this context.
List<String> providerNames = locationManager.getProviders(true);
  
  String providerName = null;
  if (providerNames != null && providerNames.size() > 0) {
   if (providerNames.contains(LocationManager.GPS_PROVIDER)) {
    providerName = LocationManager.GPS_PROVIDER;
   } else if (providerNames.contains(LocationManager.NETWORK_PROVIDER)) {
    providerName = LocationManager.NETWORK_PROVIDER;
   }
  }


We can also find the provider from location manager which is matching a set of conditions.
Criteria criteria = new Criteria();
criteria.setAccuracy(Criteria.ACCURACY_COARSE);
criteria.setAltitudeRequired(false);
criteria.setPowerRequirement(Criteria.POWER_LOW);
String providerName = locationManager.getBestProvider(criteria, true);

Once the provider is available we can request for the current location information. But for this we need to use a location listener.
location = locationManager.getLastKnownLocation(providerName);
   
   LocationListener locationListener = new LocationListener() {

   public void onLocationChanged(Location location) {
    Toast.makeText(context, "on location changed " , Toast.LENGTH_SHORT).show();
    
    locationManager.removeUpdates(this);
    processLocation(context, location);
   }

   public void onProviderDisabled(String arg0) {
    Log.e("WTF", "provider disabled!");
    Toast.makeText(context, "disabled " , Toast.LENGTH_SHORT).show();
   }

   public void onProviderEnabled(String arg0) {
    // do nothing.
   }

   public void onStatusChanged(String arg0, int arg1, Bundle arg2) {
    // Do nothing.
   }
   
  };
  
  locationManager.requestLocationUpdates(providerName, 0, 0, locationListener);

onLocationChanged method will be called when the new location is available from the provider.

Now we have all the information available to send to the emergency contacts. So let us send an SMS with this information. For this we can use the SmsManager provided by Android
StringBuilder sb = new StringBuilder();
  sb.append("Emergency! Please reach out\n");
  if (location != null) {
   sb.append("Lat : " + location.getLatitude() + " Lon : " + location.getLongitude());
  }
  sb.append(" CountryCode : " + operatorInfo.countryCode);
  sb.append(" OperatorID : " + operatorInfo.operatorID);
  sb.append(" OperatorName : " + operatorInfo.operatorName);
  sb.append(" \nCellID : " + operatorInfo.cellID);
  sb.append(" LocationAreaCode : " + operatorInfo.locationAreaCode);

  SmsManager smsManager = SmsManager.getDefault();
  smsManager.sendTextMessage("%emergencyContactNumber%", null, sb.toString(), null, null);


Replace %emergencyContactNumber% with actual mobile number. Another way to send SMS is through using Intent, but this will only open the default SMS application with the message , will not send it.
Intent smsIntent = new Intent(Intent.ACTION_SENDTO, Uri.parse("sms:%emergencyContactNumber%"));
smsIntent.putExtra("sms_body", sb.toString());
context.startActivity(smsIntent);


But before we use test this application, required permission requests must be added in the AndroidManifest file
<uses-permission android:name="android.permission.ACCESS_FINE_LOCATION">
<uses-permission android:name="android.permission.ACCESS_COARSE_LOCATION">
<uses-permission android:name="android.permission.READ_PHONE_STATE">
<uses-permission android:name="android.permission.SEND_SMS">
</uses-permission></uses-permission></uses-permission></uses-permission>


Complete code for BachaoActivity.java
package com.team.bachao;

import com.team.bachao.util.BachaoUtility;
import com.team.bachao.util.SystemUiHider;

import android.annotation.TargetApi;
import android.app.Activity;
import android.os.Build;
import android.os.Bundle;
import android.os.Handler;
import android.view.MotionEvent;
import android.view.View;
import android.widget.Toast;

/**
 * An example full-screen activity that shows and hides the system UI (i.e.
 * status bar and navigation/system bar) with user interaction.
 * 
 * @see SystemUiHider
 */
public class BachaoActivity extends Activity {
 private BachaoUtility handler;

 @Override
 protected void onCreate(Bundle savedInstanceState) {
  super.onCreate(savedInstanceState);

  setContentView(R.layout.activity_bachao);
  handler = new BachaoUtility(BachaoActivity.this);
  Toast.makeText(BachaoActivity.this, "Initialized", Toast.LENGTH_LONG).show();
 }

 @Override
 protected void onPostCreate(Bundle savedInstanceState) {
  super.onPostCreate(savedInstanceState);

 }

 public void onBachao(View view) {
  handler.bachao();
 }
 
}

Complete code for BachaoUtility.java
package com.team.bachao.util;

import java.util.List;

import com.team.bachao.BachaoActivity;

import android.content.Context;
import android.location.Location;
import android.location.LocationListener;
import android.location.LocationManager;
import android.os.Bundle;
import android.telephony.SmsManager;
import android.telephony.TelephonyManager;
import android.telephony.gsm.GsmCellLocation;
import android.util.Log;
import android.widget.Toast;

public class BachaoUtility {
 
 private Location location;
 private OperatorInfo operatorInfo;
 private BachaoActivity context;
 
 public BachaoUtility(BachaoActivity context) {
  this.context = context;
 }
 
 public void bachao() {
  operatorInfo = new OperatorInfo(); 
  TelephonyManager telephonyManager = (TelephonyManager) context.getSystemService(Context.TELEPHONY_SERVICE);
  if (telephonyManager != null) {
   operatorInfo.countryCode = telephonyManager.getNetworkCountryIso(); 
   operatorInfo.operatorID = telephonyManager.getNetworkOperator();
   operatorInfo.operatorName = telephonyManager.getNetworkOperatorName();
   if (telephonyManager.getPhoneType() == TelephonyManager.PHONE_TYPE_GSM) {
    GsmCellLocation cellLocation = (GsmCellLocation)telephonyManager.getCellLocation();
    operatorInfo.cellID = cellLocation.getCid();
    operatorInfo.locationAreaCode = cellLocation.getLac();
   }
  } else {
   Toast.makeText(context, "Unable to read telephony manager"  
      , Toast.LENGTH_SHORT).show();
  }
  
  //
  // Get the location service.
  
  final LocationManager locationManager;
  locationManager = (LocationManager) context.getSystemService(Context.LOCATION_SERVICE);
  
  
  //
  // Get location coordinates
//  Criteria criteria = new Criteria();
//  criteria.setAccuracy(Criteria.ACCURACY_COARSE);
//  criteria.setAltitudeRequired(false);
//  criteria.setPowerRequirement(Criteria.POWER_LOW);
//  String providerName = locationManager.getBestProvider(criteria, true);
  List<String> providerNames = locationManager.getProviders(true);
  
  String providerName = null;
  if (providerNames != null && providerNames.size() > 0) {
   if (providerNames.contains(LocationManager.GPS_PROVIDER)) {
    providerName = LocationManager.GPS_PROVIDER;
   } else if (providerNames.contains(LocationManager.NETWORK_PROVIDER)) {
    providerName = LocationManager.NETWORK_PROVIDER;
   }
  }

   
  if (providerName != null) {
   location = locationManager.getLastKnownLocation(providerName);
   
   LocationListener locationListener = new LocationListener() {

   public void onLocationChanged(Location location) {
    Toast.makeText(context, "on location changed " , Toast.LENGTH_SHORT).show();
    
    locationManager.removeUpdates(this);
    processLocation(context, location);
   }

   public void onProviderDisabled(String arg0) {
    Log.e("WTF", "provider disabled!");
    Toast.makeText(context, "disabled " , Toast.LENGTH_SHORT).show();
   }

   public void onProviderEnabled(String arg0) {
    // do nothing.
   }

   public void onStatusChanged(String arg0, int arg1, Bundle arg2) {
    // Do nothing.
   }
   
  };
  
  locationManager.requestLocationUpdates(providerName, 0, 0, locationListener);
  }
  
  sendMessage();

  //
  // Send facebook update
  
  //
  // Send twitter update
  
  //
  // record audio
  
  //
  // record video
  
  //
  // Send mail
 }
 
 public void processLocation(BachaoActivity context, Location location) {
  Toast.makeText(context, "Lat : " + location.getLatitude()
    + "\n Lon : " + location.getLatitude(), Toast.LENGTH_LONG).show();
  this.location = location;
  //
  // Send message
  sendMessage();
  
 }

 private void sendMessage() {
  StringBuilder sb = new StringBuilder();
  sb.append("Emergency! Please reach out\n");
  if (location != null) {
   sb.append("Lat : " + location.getLatitude() + " Lon : " + location.getLongitude());
  }
  sb.append(" CountryCode : " + operatorInfo.countryCode);
  sb.append(" OperatorID : " + operatorInfo.operatorID);
  sb.append(" OperatorName : " + operatorInfo.operatorName);
  sb.append(" \nCellID : " + operatorInfo.cellID);
  sb.append(" LocationAreaCode : " + operatorInfo.locationAreaCode);

//  Intent smsIntent = new Intent(Intent.ACTION_SENDTO, Uri.parse("sms:%emergencyContactNumber%"));
//  smsIntent.putExtra("sms_body", sb.toString());
//  context.startActivity(smsIntent);
  
  SmsManager smsManager = SmsManager.getDefault();
  smsManager.sendTextMessage("%emergencyContactNumber%", null, sb.toString(), null, null);
 }
}

In the next version I will integrate audio/ video recording, sending the data via mail , updating in facebook/twitter.

Saturday, June 30, 2012

Lunch @ Fisherman's Wharf Bangalore

Recently heard about "The Fisherman's Wharf" and thought of trying it today. After the usual Saturday shopping went to the restaurant for Launch buffet.

For me the initial and most important perception points when visiting any restaurant are :

  • Car Parking
  • Time to get seated
  • Time to take the first order

Car parking was well organized and assistant was also available. Front desk staff was really quick and got a good table with in minutes. The restaurant was crowded. Luckily I thought of calling in advance otherwise wait for the table could have been long.

There was a Kannada star in the adjacent table (I think it was Sudeep). luckily he, staff and other guests were acting normally.

Rating : The ambiance is very good
9/10

Food is good. Options for Welcome drink was beer or mock-tail. Only Fosters was available, I hope they will add more varieties.
8/10

http://thefishermanswharf.in


Monday, June 25, 2012

TwLauncher 'Force Stop' issue

Yesterday I realized that the desktops in my Samsung Galaxy S is full and for most of the applications there are 3 to 4 links in the desktop (thanks to my daughter). So started a cleanup work by moving the unnecessary links to the recycle bin.
I was hoping that the phone may be faster once I finish the cleanup, but to my surprise phone stopped responding !!

'Force Close' error message for the TwLauncher started coming continuously. It was not possible to access any applications, settings etc but phone functionality/ contacts was ok. The smartphone almost became a brick.

From Android experience I knew that some how if I reset data for the TwLauncher things should work but the problem was that it was not possible to go to the 'Manage Applications' link.

But finally after couple of painful hours I managed to make my phone work again.
Following are the steps (for other urfortunate guys using TwLauncher)
  1. Try to invoke google search box. This can be done by pressing and holding the context menu button.
    But you will have to really fight with the 'Force Close' messages as they will be repeatedly appearing.
    Keep on trying this , if you are lucky after sometime the search box will appear.

  2. Ensure that the mode of the search box is 'Apps' (mode can be changed by clicking the button to the left of search box ).

  3. Search for "setting ", this will launch the Settings

  4. In Settings, go to 'Applications' -> 'Manage Applications' -> 'All' tab

  5. Select TwLauncher app from the list and click 'Clear Data', this will recover the phone.

Other options considered are
i. Install another launcher like 'GO Launcher'
   This may not help if the issue already occured, but it will be a good idea to install such alternate launcher to help in future.
'Go Launcher' is available for free from Google Play 

ii. Cleaning the TwLauncher data in USB mode
Try connecting the phone to Laptop in USB mode, if this works then the Launcher data can be cleared.

iii. Factory reset
This is the last option if nothing else works.

Note: Your custom screens may be lost once you clear the TwLauncher data.

Are you looking for good free Android educational application for Preschoolers?
Try this - https://play.google.com/store/apps/details?id=com.fortytwo.mathapps.kidsnumberlearning.activity
Review is available here - http://crashingnhanging.blogspot.in/2013/08/android-free-preschooler-number.html


Saturday, June 23, 2012

g|days in India

Finally google days event in India !
Venues are Chennai, Bangalore, Hyderabad, Delhi and Mumbai

Since the space is limited , register today itself.
For details visit : https://sites.google.com/site/gindia12/

Tuesday, January 31, 2012

Introduction

JMock is the famous library which can be used for working with Mock Objects.
(Please check www.MockObjects.com to know more about Mock Objects.) . How ever you might be excited to know that Mock Objects are not just Stubs!! They give a different approach to unit testing.
So finally testing is also becoming as interesting as Coding.
In simple words we can say that a mock object is something which can be used for testing the behavior of other objects. It will mimic the behavior of an actual class / interface.
A Mock object can also observe how other objects uses its methods and compare with the expected behavior. (I will explain this in detail with code sample.)

This means that we can test and verify how our class uses the available environment. 
Let's assume you are developing a Customer class which has to interact with a BookShopclass. But unfortunately BookShop class your friend is developing and as usual it is not available yet. So naturally we will decide to use a Mock Object of BookShop instead of an actual instance. 
Customer has function doTransaction().
BookShop has methods pay(Money) , Book getBook()
Using JMock we will be able to specify that getBook() is always called only after pay().
So if anywhere in our doTransaction method if getBook is called with out pay() it will result in an error with bright red colour while testing it. 
This way we can ensure that our class uses the available interface in the desired way.
In a TestDrivenDevelopment environment this means that interface problems can be found even before the actual coding of it starts.
JMock makes our life easier by creating mock objects dynamically and providing features to specify expectations (How it should behave, etc).


Download Link

The JMock jar/zip can be downloaded from www.JMock.org
This can be added as external jar file in your Eclipse project.

Using JMock

Here comes the interesting part!
Lets develop as class called DispFile , which is a highly useful class for displaying a given file in console.
DispFile class uses the IFileHandler interface for the file operations .
Code for IFileHandler

public interface IFileHandler {   public void open(String filename) ;   public void close() ;   public String read() ;    } 

Code for DispFile 
public class DispFile {     public DispFile()  {     }    
     /**      * Business method to display the given file line by line      */     public boolean display(String filename)  {         
  Boolean status = true;         
  try   {             
   IFileHandler fileIntf = new FileHandler();             
   fileIntf.open(filename);             
   String line = null;             
   while ((line = fileIntf.read()) != null)    {                 
    System.out.println(line);             
   }            
   fileIntf.close();         } catch (Exception e)    {             
  Status = false;         
 }        
 return status;     } } 

 Here the line "new FileHandler" is the problem! We know the actual implementation is not yet available. So we have to use a MockObject for IFileHandler instead of an actual instance.  We must change the class to make it testable . The changes are minimal and it is a low price to pay for getting the testability with Mock Objects. This refactoring also makes the design cleaner.  The modified code is given below. 


public class DispFile {   
... /** Business method to display the given file line by line */   
public boolean display(String filename) {    
Boolean status = true; 
Try {     
IFileHandler fileIntf = getFileHandler();     
 ....       
}catch (Exception e) { 
Status = false 
}     
return status;  
 }   
/**   Its true that this method seems nonsense, but it is very important forUnit testing with Mock Object technology. */ 
protected IFileHandler getFileHandler() {  
return new FileHandler(); 
}    
} 

Code for Test Class 
package chkJMock;  
import junit.framework.TestCase;  
import org.jmock.*;  
public class DispFileTest extends MockObjectTestCase {   
/ *    * Test method for 'chkJMock. DispFile.display(fileName)'    */   
public void testDisplay() { ....   }  
} 

We will check the code             required in testDisplay method in detail. 


//set up the Mock Object .
//First we have to set up the context             in which our test will execute.
//We have to create a DispFile to test. We             have to create a mock IFileHandler that       
//should receive the message. We then             register the mock  IFileHandler with the DispFile.
Mock mockFileHandler = mock(IFileHandler.class); 
final IFileHandler intf = (IFileHandler) mockFileHandler.proxy();     
DispFile df = new DispFile() {      
protected IFileHandler getFileHandler() {        
// I hope now the use of silly looking getFileHandler method is clear.          
return intf;
// expectations     
// Here we specify how DispFile class is expected to use the IFileHandler interface.      
//     
// The method open should be called only once with the argument file (String            // containing name of the file to display).     
String file = "E:\\@Com XML CorbaTask.xml";     
mockFileInterface.expects(once()).method("open").with(eq(file));         
//     
// The method close should be called only once and it must be called after the method       
// open . (Unless you want to close a file which is not yet opened! ).     
mockFileInterface.expects(once()).method("close").after("open");      
// The method read should be called one or more times (we are reading lines in a loop.)     
// It should return a null string when it is invoked.     
mockFileInterface.expects(atLeastOnce()).method("read").withNoArguments()     .will(returnValue(null));         
// execute     
// Call the business method we were waiting for     
boolean status;     
status = lf.list(file);     
assertTrue("Error displaying file : " + file, status);  
This when executed ensures that the methods in the interface (Mock object ) are invoked in correct order and in specified way. If anything is violated (e.g- if close is called without calling open , open called multiple times ) , it will result in test error.  

Note :

To mock concrete class jmock-cglib extension and cglib jar should be added to the eclipse project. Testcase should derive from cglib.MockObjectTestCase.
Eg:-          
Mock mockTaskDetailsClient = mock(TaskDetailsClient.class,"mockTaskDetailsClient");  
final TaskDetailsClient taskDetailsClient = (TaskDetailsClient)mockTaskDetailsClient.proxy() ;   
ctr with args. mock(TaskDetailsClient.class,"mockTaskDetailsClient", class[],Object[]); 
There are many tools/ services available now which will help in generating unit test for the existing legacy code base. One such service is www.UnitTestFactory.com