Sunday, April 14, 2013

Why StagefrightPlayer and AwesomePlayers are available? why the application cant directly calling the AwesomePlayer instead of StagefrightPlayer and internally how Stagefrightplayer is calling AwesomePlayer ???

In OpenCore also, as similar to AwesomePlayer we will have PlayerDriver.
All things will be routed via PlayerDriver from PvPlayer class.

  AwesomePlayer is a proxy to stagefrightPlayer . It is using pimpl design pattern.This is to reduce the header file resources needed.
If we have to use AwesomePlayer directly we need to include more header files related with Awesomeplayer. This is covered in stagefright player.So the user can use stagefrightplayer.h header file without
adding multiple headers files in libmediaplayer/mediaplayer.cpp

 To know more about PIMPL design pattern:
http://www.codeproject.com/Articles/17536/Use-of-PIMPL-Design-Pattern

Labels: , ,

Adding custom return type for marshalling/unmarshalling the data type in AIDL:

In Android application, while working with AIDL, I faced this problem.

If I am going to return any custom datatype or class in interface's functions, then we need to write .aidl and .java file.

For example from my AIDL interface function, I am going to return Rect custom class. Then I have to do the following:


Rect.aidl:
=========
package android.graphics;

// Declare Rect so AIDL can find it and knows that it implements
// the parcelable protocol.
parcelable Rect;


Rect.java
==============


import android.os.Parcel;
import android.os.Parcelable;

public final class Rect implements Parcelable {
    public int left;
    public int top;
    public int right;
    public int bottom;

    public static final Parcelable.Creator<Rect> CREATOR = new
Parcelable.Creator<Rect>() {
        public Rect createFromParcel(Parcel in) {
            return new Rect(in);
        }

        public Rect[] newArray(int size) {
            return new Rect[size];
        }
    };

    public Rect() {
    }

    private Rect(Parcel in) {
        readFromParcel(in);
    }

    public void writeToParcel(Parcel out) {
        out.writeInt(left);
        out.writeInt(top);
        out.writeInt(right);
        out.writeInt(bottom);
    }

    public void readFromParcel(Parcel in) {
        left = in.readInt();
        top = in.readInt();
        right = in.readInt();
        bottom = in.readInt();
    }
}

I have to include this Rect.java in android compilation make file [make];

we should not include the .aidl file in Android.mk for this scenario.

This can happen when we are using NDK compilation. In NDK case, we will include java/include files in Android.mk.

Error:

* in my Android.mk file, I have added:
LOCAL_SRC_FILES += \
        src/com/mycompany/mypackage/Rect.aidl \

But when we compile we will
Aidl: Test <= src/com/mycompany/mypackage//Rect.aidl
src/com/mycompany/mypackage/Rect.aidl:19 aidl can only generate
code for interfaces, not parcelables,
src/com/mycompany/mypackage/Rect.aidl:19 .aidl files that only
declare parcelables don't need to go in the Makefile.

Labels: , ,

Android Application AIDL error:

In android application, while working with AIDL, I observed an error.
My function is returning the class Employee. But I got the below error

Aidl: huey <= external/testapp/IMyService.aidl
external/testapp/Ioffice.aidl:16: couldn't find import for class com.sundar.Employee
make: *** [out/target/common/obj/JAVA_LIBRARIES/MyService_intermediates/src/com/IMyService.java] Error 1


IMyService.aidl

interface IOffice
{
 Employee get();
};


I have added the Employee.java which is derived from Parcelable class. I have also added this java file in make file.
But still I got this error.

How to resolve it:
I created the Employee.aidl and copied the below contents

package com.MyService;
parcelable Employee;

I copied the Employee.aidl and copied to the folder where Employee.java is there.Afterwards, it is compiling fine without any error.
 But Employee.aidl is not at all added in Android.mk

Labels: , , ,

What is cyclomatic complexity ?

Testing is the process by which all the code should be executed once to identify the bugs/errors in a product/system.
In testing there is a concept called cylomatic complexity through which we can identify all the executable path/flow.

Will it be useful only for testing ?

  while testing, we can try with all inputs which satify all the executable paths in a code.
we have to test with all the inputs which will cover all the executable paths. This will ensure that
code in a product/system executed only once.

Will it be useful for development?

It will be useful for enhancing the existing product/integrate new components to the existing product. On such a development case,
we can idenfity the executable paths and inputs. After the enhancement/adding new component, we can test with previously identified executable paths and inputs also we have
to add new executable paths and inputs for the  addition of new components/enhancements.


Labels: ,

Saturday, April 13, 2013

How to get result from an activity:
=====================================

The following program snippet depicts how we can get result from an activity in an android application.

To launch an activity:
===========================
    Intent pickIntent= new Intent(this,PickServerActivity.class);
    //To launch an activity use below command:
    startActivityForResult(pickIntent, REQUEST_CODE_PICK_SERVER);

within activity, how to set result:
====================================
  Intent intent = new Intent();
  // start intent
   if(bServerSelected)
   {   
      intent.putExtra(ServerIntents.EXTRA_SERVER_NAME, selectedServerName);
      setResult(RESULT_OK, intent);
    } else {
          setResult(RESULT_CANCELED, intent);
     }

To get result from an activity:
====================================

    @Override
    protected void onActivityResult(int requestCode, int resultCode, Intent data) {
        if (requestCode == REQUEST_CODE_PICK_SERVER) {
            if (resultCode == RESULT_OK) {
                Bundle extras = data.getExtras();
                if (extras != null) {
                    mServerName = extras.getString(EXTRA_SERVER_NAME);
            //Display Selected server from the activity   
                }
           
            }
        }
    }
   

Labels: , , ,

How to use bundle in Android Application:
===============================
    /** bundle got from intent. */
    private Bundle mExtras = null;

    if (mExtras == null) {
           mExtras = new Bundle();
     }
     mExtras.putString(MESSGAGE,
                    "Hello World");

Other end:
     message = mExtras.getString( MESSAGE);

Labels: ,