Wednesday, December 19, 2012

How to check whether the TV remote control's battery drained or not ?
       If the battery power is good,It will emits Infra Red rays. We can't see infrared rays normally.There is a way to see
this infrared rays. How???
Place the remote control's Infra red LED facing to the mobile camera, run the mobile camera in preview mode and press the keys in remote.
See the mobile camera's preview. If the battery charge is good, Infra red LED will emits light 

Wednesday, December 12, 2012



Competition Sites:
1) ACM ICPC
2) codeforces
3) topcoder
4) codechef
5) google code jam
6) Saratov university [espl for tricky testcases]


To do:
===========
0) Study and practice
1)Always read a chapter from algorithm and do problems in book
2)Solve the related problems in contest sites
3)Solve the related problems available in all text books
4)Always choose hard problems and try to solve it...
5)Solve interview problems related with it
6) Read topcoder articles and solve problems related with it...



1) Trees
http://codeforces.com/problemset/tags/trees
2) Graphs
http://codeforces.com/problemset/tags/graphs

3) Datastructures
heaps,segment trees,BST, HashTable
http://codeforces.com/problemset/tags/data%20structures

4)Expression Parsing
http://codeforces.com/problemset/tags/expression%20parsing

5) Hashing
http://codeforces.com/problemset/tags/hashing

6) strings
http://codeforces.com/problemset/tags/strings

7) string suffix:
http://codeforces.com/problemset/tags/string%20suffix%20structeres


8) greedy
http://codeforces.com/problemset/tags/greedy
9) dynamic programming problems list:
http://codeforces.com/blog/entry/325
http://codeforces.com/problemset/tags/dp
10)Divide and conquer
http://codeforces.com/problemset/tags/divide%20and%20conquer


11) Mathematics
http://codeforces.com/problemset/tags/math
12)geometry
http://codeforces.com/problemset/tags/geometry
13) probablilities
http://codeforces.com/problemset/tags/probabilities

14) combinatorics
http://codeforces.com/problemset/tags/combinatorics

Above are from codeforces...
Below are from topcoder
15.Recursion
16.sorting
17.String manipulation/string parsing
18.Encryption and compression
19.advanced math
20. sortings..
21.maze
22.BackTracking
23.Maximum flow problem

Best resources for competition programming preparation:
http://problemclassifier.appspot.com/
http://emiraga.wikispaces.com/Problems+by+topics
https://github.com/BrockCSC/acm-icpc/wiki/Online-Resources
http://www.stanford.edu/class/cs97si/
http://webcourse.cs.technion.ac.il/234900/Spring2012/en/ho.html


Monday, December 10, 2012

What I have done and what I have learnt from comptetition problems:

From Codeforces,I solved the following problems:

1) Files list
    Previously in OS or c program, we can have 8 characters filename and 3 characters for extension.
I felt that design in this problem
   http://codeforces.com/problemset/problem/174/B

2)cd and pwd commands
http://codeforces.com/problemset/problem/158/C
 From this problem, I learnt that how we can implement cd and pwd commands in shell.
How it will remembers the user's present working directory especially the user is doing cd ..

3)BHTML & BCSS
http://codeforces.com/problemset/problem/172/E

  From this problem, I learnt that How css is applied with HTML tags. How we can highlight the tags with user's choices.

4)Simple XML
http://codeforces.com/problemset/problem/125/B

  From this problem I learnt that How XML tags can be aligned or C/C++ source code is aligned based on {} brackets in editor

5)try... catch problem
http://codeforces.com/problemset/problem/195/C

From this problem, I learnt how compilers will execute exceptions with try ... catch blocks
It is one of awesome reallife problem.

How to change android system volume Up/Down ???

    Through AudioManager, we can set the volume up/down.


Today I faced this issue while working with media-volume-control
1)http://stackoverflow.com/questions/8446337/how-to-solve-error-this-attribute-must-be-localized-at-text-with-value-top
2) R.java:10: duplicate class error
  I just removed the R.java and compilation is going smooth

3) How to copy the eclipse project into android source code and compile it ???
 copy the application project into android source code's packages/apps/ folder
within the application project,Add Android.mk with below contents:

 LOCAL_PATH:= $(call my-dir)
 include $(CLEAR_VARS)
 LOCAL_MODULE_TAGS := optional
 LOCAL_SRC_FILES := $(call all-subdir-java-files)
 LOCAL_PACKAGE_NAME := VolumeControl_S #Target package name
 include $(BUILD_PACKAGE)

 From android folder give source build/envsetup.sh,lunch and then
 cd to packages/apps/yourApplication/ and give mm command. This will build the application code & create the APK file.

Tuesday, December 04, 2012

Problems faced while compiling android application with old version to ICS/JB:

1)http://stackoverflow.com/questions/8446337/how-to-solve-error-this-attribute-must-be-localized-at-text-with-value-top

2) I got Android APK compilation Error: R.java:10: duplicate class

Solution:  I just removed the R.java file and compilation is going smooth
How to copy the eclipse Android Application project into android source code and compile it ???

 copy the application project into android source code's packages/apps/ folder
within the application project,Add Android.mk with below contents:

 LOCAL_PATH:= $(call my-dir)
 include $(CLEAR_VARS)
 LOCAL_MODULE_TAGS := optional
 LOCAL_SRC_FILES := $(call all-subdir-java-files)
 LOCAL_PACKAGE_NAME := VolumeControl_S #Target package name
 include $(BUILD_PACKAGE)

 From android folder give source build/envsetup.sh,lunch and then
 cd to packages/apps/yourApplication/ and give mm command. This will build the application code & create the APK file.

ICS features:

From ICS onwards, Android by default handles Keyboard/mouse input events... No need to do anything extra to make it work...



To know more about how to handle keyboard events/Simulate keyboard events:
 http://thecodeartist.blogspot.in/2011/03/simulating-keyevents-on-android-device.html

Friday, November 30, 2012

ICS, JB Phone window manager difference:

while playing video on fullscreen, status bar will be hided during playback in JB. This will not happen with ICS.
In ICS, Window manager will check for the mStatusBarCanHide flag to identify whether the system is having Phone UI or Tablet UI.
If it is having Phone UI, mStatusBarCanHide flag will be set to true. Whereas in case of tablet, this flag will be set to false.
Based on this flag, window manager differentiate the Phone UI or tablet UI.
   Display 600 dp is Phone UI.
   Display 720 dp
   Display > 720dp, tablet UI or larger screen UI

In ICS, status bar hiding support is available only phone models. It is not available for tablet UIs.[Refered from android ICS release notes]
In JB, it will checks for the mHasSystemNavBar. This value indicates whether device is having tablet UI/larger screens or smaller UI/phone UI.
This flag will be set to true for tablet UI.

      One more major difference between ICS  and JB is that while playing video on fullscreen, ICS will hide the status bar by calling status bar service's collapse() method whereas in JB, it will change the window manager layout.window manager layout's display frame/navigation frame/content frame will be set the video screen. Ideally status bar will be there in screen but it wont be shown to user due to display viewport.

Thursday, November 29, 2012

How Wifi/ethernet/3G  service is working in android:
===================================


   1) while bootup, connectivity service will launch all networking services.
 
In android, most of the system services cant be directly interactable by user applications/any other medium.
 Every service will have a manager which will talks with service. For example, To interact with connectivity service, Connectivity manager is available. User/application will query for the available network connections from Connectivity manager.

   In the same way, wifi manager is available for Wifi service, Window manager is available for Window service and so on.
During bootup, System server launches connectivity service.connectivity service launches/initiates wifi/3G/ethernet services.

     To receive whether the link is up or down, ethernet connection is connected or disconnected, we will receiving notifications from
framework.[android_net_wifi.cpp/android_net_   ] This framework file watches for network connectivity by reading /proc or sys file system.

    if wifi is available then under proc/net/wireless/wlan0 interface will be created. So the framework will waits for proc/net/wireless/ file for any changes.
    More over we will get notifications from driver on link up or down information. Once the link is up, it will be updated to Mobile/Wifi/ethernet trackers. These trackers will query for the network information like DHCP IP address,netmask and so on from DHCP service/dhcp daemon.
  
   Once the wifi/mobile state tracker got an IP address and necessary information about the network it update to Connectivity manager.
Meanwhile it will also update the Wifi/Ethernet manager which will talks to wifi/ethernet/3G services  .
    
    UpdateConnectivity of connectivity manager is being called to update the CONNECTED /DISCONNECTED network information to connectivity service.
 
   while user application queries for connected network information from connectivity manager, Connectivity manager will get this information from connectivity service.
     If multiple network connections are available, Connectivity service will decides which one to choose for network connection.
For example, if we have 3G connection, we reached into Wifi area, Wifi can download more data compare to 3G. So Wifi connection will be selected for network connection, 3G connection will be teared down.
    Every network has priority based on priority it will choose the desired connection.

  In linux and all, Ethernet/Wifi connection is possible at the same time. But the kernel will make use of any one interface[wifi/ethernet] at a time.

   wifi state tracker will make use of DHCP daemon to get dhcp ip address. For Dhcp request, Some class is available which will calls system/core/libnetutils library. which will talks to dhcp daemon initiated from init.rc.

           This DHCP daemon will query the ip address and set the IP address,netmask information in system properties [dhcp.wifi.ipaddress,dhcp.wifi.netmask]. If the Wifi state tracker doesnt receive any dhcp response for a particular timeout period, it will report timed out error. If dhcp reply is received it will reads Ip address and netmask from the given interface and update it on settings.
     CONNECTIVITY_ACTION is an intent which will be used to update the network information from connectivity manager/service.
  

Saturday, November 24, 2012


How to maintain various versions with the same target binary inside android file system ???


In Android, whatever folders with Android.mk files are added to external folder in android file system,while building the android, it will be compiled.

   I faced an interesting problem.  Wifi need wpa_supplicant. There are multiple wpa_supplicants are available in external folder. I could not figure it out which one will be compiled.
   external/wpa_supplicant
   external/wpa_supplicant_6
   external/wpa_supplicant_8

Because whatever things we copied to external folder, if it has Android.mk, then that folder will be compiled.
All 3 folders are having same target binary [wpa_supplicant,wpa_cli]. If we have multiple target binary with the same name, compilation will fail.

I analysed and found that in device.../BoardConfig.mk will have the macro to specify the WPA_SUPPLICANT_VERSION=0_x_8.0

if the WPA_SUPPLICANT_VERSION is 5.0, wpa_supplicant folder will be compiled.
if the WPA_SUPPLICANT_VERSION is 6.0, wpa_supplicant_6 folder will be compiled.
if the WPA_SUPPLICANT_VERSION is 8.0, wpa_supplicant_8 folder will be compiled.

within the external/wpa_supplicant/Android.mk if the WPA_SUPPLICANT_VERSION == 0_x_5.0, then only the folder source codes will be compiled.
within the external/wpa_supplicant6/Android.mk if the WPA_SUPPLICANT_VERSION == 0_x_6.0, then only the folder source codes will be compiled.
within the external/wpa_supplicant8/Android.mk if the WPA_SUPPLICANT_VERSION == 0_x_8.0, then only the folder source codes will be compiled.
Target android board can have any supplicant version, it might be 5.0 /6.0/8.0.


   Lessons learnt:
  
   we can have multiple versions of the same binary under external folder,decide which version to be compiled based on target board.

  where I can apply:

     Assume that TI android board has various accelerators for display.Some TI boards will use x hardware accelerators for display. Some boards will use Y hardware accelerators for display. We can use same target binary  so it can either use x hardware accelerator or y hardware accelerator for display based on BoardConfig. Finaly display binary is same.

 we can not put only x hardware accelerator source code in android. It will fail while compiling for Y hardware accelerator source.
User has to take care of copying the code based hardware accelerator. Or else we can copy x and y hardware accelerator code and decide which
one to be compiled by boardconfig.mk macros .



 

Friday, November 23, 2012

Problem in static IP:
===============


I ported the android x86 ethernet support to android board.
I used the same kernel to run ICS and jellybean OS.
I faced  the problem in setting static IP. while switching from DHCP to Static IP, entire system hangs.
 Ethernet patch is storing the value in Settings. while reading the value from settings and setting the static IP, it hangs...
Since ethernet is configured in bootup time, system hangs and doesnt proceed booting android.

    I analysed and found that providers/settings data will be stored in /data/data/com.android.settings.provider/settings.db.
All android applications/providers database values will be stored under /data/data/com.android.ApplicationName.
To clear the settings value, we can format /data/ partition , So that stored information will be deleted.
Now I am able to proceed with booting android.
   But still problem is there while setting static IP.I doubted the network environments/OS/my program.

  1)Through ifconfig, I am able to set static IP address. So there is no problem in network environment.    
  2) I doubted IP settings are not allowd in jellybean, any  new services have been added to change IP address. Since I am using same kernel, there wont be any changes in kernel level.
  3) I doubted my entire program is not working. But same code was previously working with ICS.

Previously with ICS, I am able to set static IP and tested well.Same code is not working. I doubted my static Ip setting itself is not working.
 To narrow down the issue, I hardcoded the netmask value, afterwards it is able to set static IP.
  In my code, I debugged and found that it is hanging in netmask to prefix conversion which is required for setting static IP address.

 Lessons Learnt:  1) All android applications store data/database values under /data/data/com.android.ApplicationName[Package name of the android]
  2) Always document the sample inputs/environments for success cases, So in future, if the system is failing, we can try with that input.
  3) always test lower limit and upper limit values... System hangs since It is failed in lower limit

 Please refer my previous post about netmask to prefix conversion problem.
http://sundararajana.blogspot.in/2012/11/netmask-prefix-length-netmask-is-also.html




   

Thursday, November 22, 2012

Netmask , prefix length :
==========================

  netmask is also measured as prefix length. The number of bits set in netmask value is called as prefix length.
Example :   Netmask:255.255.255.0 Prefix : 24 //number of bits set in 255.255.255.0 value.

 To convert the netmask to prefix I added below code in Java:

  netmask= lookupHost("255.255.255.128");
   while ( netmask !=0)
   {
      if( netmask & 1)
        ++prefixLength;
       netmask = netmask >> 1;
    
   }

  Simple code :
     The above code is working fine for sometime. Sometimes it is not working...
    I found that netmask to prefix conversion is breaking and makes the system hangs....

 The input 255.255.255.0 is working fine. But 255.255.255.128 is breaking ...

Finally figured that the problem is with the code.

    In a 32 bit signed integer, 255.255.255.0 is not giving any problem. So LSB is stored as a first byte in memory ...

   lookupHost converts the string as 0 255 255 255[bits set] as integer..[0x00ffffff].
when it comes to 255.255.255.128, 128 255 255 255 [bits set as 0x80ffffff. So netmask will always not equal to 0, So it is in infinite loop.
>> shift operator operates on bits not on sign bit. netmask's sign bit will always 1 & it satisfies netmask != 0 condition infinitely.

Solution:
   To avoid this problem,
    1)I have to use >>> operator which will also operates on sign bit.
    2) I can also check for the maximum limit.

   Above code can be modified as below:

      
  netmask= lookupHost("255.255.255.128");
   while ( netmask !=0)
   {
      if( netmask & 1)
      {
        ++prefixLength;
         if (prefixLength == 32)
         {
           break; //exit while loop since maximum allowed value is reached for prefix length for 32 bit IP address, maximum prefix len is 32
         }
      }
       netmask = netmask >>> 1;// >>>     Unsigned right shift
         
   }

Wednesday, November 21, 2012

Practice Programming[ About Perfect Practice]:
http://codekata.pragprog.com/2007/01/code_kata_backg.html

Monday, November 19, 2012

Android logcat with Process ID and Thread ID:
         Android logs can be printed with Process ID and thread ID.

Command to print logcat with PID and TID:

   /system/bin/logcat -v threadtime

When it will be useful ?

     1)  If any crash is occured, we can identify which thread or process id is crashing. we can enable logs in all the modules. If we got any logs from crashing  thread, then crashing thread and logs  TID and PID will match . Based on it, we can localize the crashing location/thread.

  2)   PID and TID will be useful to check which  framework classes used by application.  For example, If I want to check audio track is used by application or not. I can enable logs in audio track class. While printing logs, it will show the process id and thread ID for Audio Track class.

  we can match the PID with running applications PID  to figure it out.

  otherway is we can decompile the APK binary to source code to check whether AudioTrack/framework class is used.


Android APK to java source code conversion:
==============================
Required tools for conversion:
  i) 7zip ii) dex2jar iii)jd-gui [java decompiler GUI]


1)Rename the .apk file to apk.zip.
2)unzip using 7zip software to folder.
3)unzipped folder will have classes.dex file
4)use dex2jar to by below command:
    dex2jar "D:\classes.dex"
  This will create the jar file in "D:\classes_dex2jar.jar".
5)run jd-gui and  open "D:\classes_dex2jar.jar" jar file.
    This will give you the source code of the APK.

  From jd-gui, we can do File->Save All sources . So that all sources are saved as zip file.Unzip the file to get the source code.

Sunday, November 18, 2012

Running/Launching Linux/Android OS with  same kernel, Is it possible How to do?:

In Embedded/STB devices, Mostly they will be using the Linux OS.
Now they are moving to android. How it is possible for them to move to linux???

  over the Linux kernel, Some patches/changes are applied and it is called as android kernel. They are having separate branch also.
 To run android, Below Components involved:
    bootloader, kernel,android source code compiled binaries

    we have to compile kernel with target[ARM /x86] architecture. In the same way we have to compile android source code to the target architecture[x86/ARM].

   Initially the bootloader will loads kernel. Kernel will starts init process of android.

This init process will loads init.rc, init_board.rc scripts and also launches all the android services.

   The user can load linux/android OS with same kernel.

we can have a script to launch android/linux OS or based on user choice.

In launching an android script, we have to run android init processes in background;

android_launch.sh
  ./androidbin/init & # This init binary is generated from android source code.

  The target device should have all the android binaries.
        
 Linux also have the same script.
 
linux_launch.sh
   ./linuxbin/init &

   Linux source code also has init source code. This should be invoked if we want to launch the linux.This init process will launch all linux binaries.
The device should have all the linux source code compiled binaries.

Thursday, October 18, 2012


PPPoE:
================

For internet connection we might have used DSL modem. I am using BSNL modem in my home. Internally how modem is working?

We will connect telephone connection with DSL modem to receive/send over the network. From modem, we will connect the ethernet cable with PC to get internet connection. Initially modem was connected to RS232 serial port or USB 1.1 port. But it will have very less speed. Serialport maxspeed is at max 192 kbps. To speed up internet connection, PPPoE connection was made.

PPP protocol client is running in PC. PPP server will be running in Modem.
PC 's ethernet card communicates with modem's ethernet card. It is like connection ethernet cable between two systems as like a serial cable.

PPP client is running in PC, It will interacts with modem [PPP server] to have internet connection. Usually modem internet connection will be authenticated by username and password.

Since internet connection is made through PPP protocol. If OS supports this PPP client, then it will be able to access the modem. That's why we are able to get internet connection regardless of OS .

Wireless DSL router has antennas to access wireless access points. Wireless router will have its own page settings. By giving this from PC, http://192.168.1.1 we can change the router settings.

How data is transmitted in DSL modem:

DSL modem communicates with nearest telephone exchange's device. This device is called as Digital Subscriber Line Access Multiplexer (DSLAM). Data will be transferred over the telephone exchange's optical fiber cable. Whenever we are downloading a web page, packets of webpage travel over optical fiber internet lines directly to the DSLAM at the neighborhood telephone exchange. At the DSLAM, they are split into as many as paralllel data streams, modulated onto a separate signal and sent through cable. The modem demodulates the signal to datastream also will do error correction,put the data in proper order and sends it to the computer over ethernet line.

Monday, October 15, 2012

Android ICS environment  setup issue with Ubuntu 12.04 LTS:

  I stuck up with installation problems and found the below blog is helpful to resolve the issue:

http://techblog.simoncpu.com/2011/07/required-packages-for-building-android.html
How to use Intents between two applications to pass message,data or notification:


what is Intent ? Intent is one of the mechanism to  communicate  between two application or more application.


     Assume Network status notifications are raised as Intent and whoever application handles network, he has to receive the notification and act accordingly. For example, the application which is using internet connection should receive the network connected or disconnected message.


  Sender has to send the data. Receiver application has to receive the intents and receive add filters which need to handle.
   For example, Many intents can be raised from system level. But we need to be notified for particular intents, then those intents are added in IntentFilter, registered along with broadcast receiver.
     In the below code, we are raising WiFI network state changed event from framework or application. Whatever parameters we have to pass we can use putExtra() function. From receiver we have to get the values by getXXXExtra() fns.
    We can also raise custom intents in the similar way.




Sending an intent from an application to pass data or from framework:


CONNECTED
===============
string WIFIManager.NETWORK_STATE_CHANGED_ACTION ="WiFi"

Intent sIntent = new Intent(WIFIManager.NETWORK_STATE_CHANGED_ACTION);
sIntent.putExtra("WiFiUp",true);
SendBroadcast(sIntent);
context.sendBroadcast(sIntent);

DISCONNECTED:
===========
Intent sIntent = new Intent(WIFIManager.NETWORK_STATE_CHANGED_ACTION);
sIntent.putExtra("WiFiUp",false);
context.sendBroadcast(sIntent);


Receiving  Application:
==================

    Message Receiving application should have BroadcastReceiver with Receive() function.  We have to create IntentFilter and add an action to the intentFilter and while registering the broadcast receiver, we have to pass IntentFilter too.


whenever we dont want to receive the intent, we have to unregister the receiver.



import android.content.BroadcastReceiver;

private final BroadcastReceiver mReceiver;
private final IntentFilter mWiFiStateFilter;

 mWiFiStateFilter = new IntentFilter(WIFIManager.WIFI_STATE_CHANGED_ACTION);
 mWiFiStateFilter.addAction(WIFIManager.NETWORK_ENABLED_ACTION);
//we can add many actions in an intent Filter

mReceiver = new BroadcastReceiver() {
            @Override
            public void onReceive(Context context, Intent intent) {
                handleEvent(context, intent);
            }
        };

private void handleEvent(Context context, Intent intent)
{
        String action = intent.getAction();
        if (action.equals(WIFIManager.NETWORK_STATE_CHANGED_ACTION) )
    {
        mEnabled= intent.getBooleanExtra("WiFiUp", false);
         //Receiving the WiFi status
        }
       else
        if (action.equals(WIFIManager.NETWORK_ENABLED_ACTION) )
       {
       }

   
}

 public void resume() {
         //Registering the receiver.
        //Usually receivers are registered in OnResume()
         mContext.registerReceiver(mWiFiStateReceiver,mWiFiStateFilter);
    }

 public void pause() {
       //Receivers are unregistered in OnPause() fn
         mContext.unregisterReceiver(mWiFiStateReceiver);
    }





Sunday, October 14, 2012

Kernel to user space communication in linux:
=================================

  3 different ways to communicate between kernel and userspace in Linux:

1) proc file system
2)ioctl
3) netlink
ioctl is the old mechanism. Speciality of netlink is we can send the command as multicast, so that different applications can receive the command.

 
For more refer:

http://people.ee.ethz.ch/~arkeller/linux/kernel_user_space_howto.html
TO get/set an IP address from Linux over the socket:
 
int s;
    struct ifreq ifr = {};

    s = socket(PF_INET, SOCK_DGRAM, 0);

    strncpy(ifr.ifr_name, "eth0", sizeof(ifr.ifr_name));

    if (ioctl(s, SIOCGIFADDR, &ifr) >= 0)
        printf("%s\n",
          inet_ntoa(((struct sockaddr_in *)&ifr.ifr_addr)->sin_addr));


ioctl call receives data from the kernel for SIOCGIFADDR for IP address.

In case of static IP address, we will set the IP address with ioctl( SIOCGIFADDR, socketDetails) call.
 
 
ioctl is the module which can be used for kernel/user or user to kernel communication. 
 
 For more, read Richard Steven's Unix Network Programming book
 
 
 

Difference between Static and DHCP ip address:
   In static IP address, We will configure the interface with the our IP address/netmask and so on.
 Whereas in DHCP, we will DHCP client protocol identifies the IP address from DHCP server and send the IP address to kernel via RTM_NEWADDR msg over the netlink.

  

Circular Dependency:

I added new xml to settings due to that I got "Stack overflow error" in android runtime,Settings application was not launched.
        Added xml file is ic_settings_ethernet.xml.





 

ic_settings_ethernet.xml contents:
=======================

https://groups.google.com/forum/?fromgroups=#!msg/rowboat/lP65eylKHkQ/flHykmz15xAJ

The stack overflow is caused by the the res/drawable/ic_settings_ethernet.xml file in packages/apps/Settings which references itself, creating a circular dependency. I could not find any use of this file in any of the other resource files or in the Java source code. Simply removing it allows me to start the Settings app without crashes.

How to disable the WiFi/any networking or add any network in android :
 
  In android framework, there is a file to configure available networks.
If we disabled particular network in that file, Particular network will be disabled in android.

name of the file need to be modified to disable networks:
frameworks/base/core/res/res/values/config.xml

This file contents are as below:
 
  translatable="false" name="networkAttributes">
        "wifi,1,1,1"
        "mobile,0,0,0"
        "mobile_mms,2,0,2"
        "mobile_supl,3,0,2"
        "mobile_dun,4,0,4"
        "mobile_hipri,5,0,3"
    
 
 
In android framework, Connnectivity manager/service is reponsible for handling available networks.
If I want to add new network, I have to develop a service,NetworkStateTracker  and add the content in the above file.
 
 
Let me say If I want to add ethernet support, ethernet service should be written, launched from ConnectivityService.
we need to develop our own NetworkStateTracker derived class to maintain the state of ethernet.
We also need to add new item in the above file.
   From the above file only, Android will comes to know the available networks.
Let me say if I removed the wifi item, then WiFi wont be detected. Because android framework doesnt know the wifi network is available 
 
 
 

How to display logs from android service:

By default,If we added any android service in init.rc, logs are redirected to null device. So logs wont be shown from service. Sometimes it will show sometimes it wont show logs. To display logs always from service,


we have to do the following

service serviceName /system/bin/logwrapper /system/bin/dhcpcd -BKLA -d eth0
disabled
oneshot

/system/bin/logwrapper - this will redirect the  service logs to logcat.

init.rc script is executed by init process.

How to communicate between two process /To pass information from one application to another application in android java:

 Best ways are intents. whoever wants to send message, He has to raise an intent.Whichever Application wants to receive the message, It has to implement  BroadcastStatusReceiver class.

We can raise intent like this... 

Intent sIntent = new Intent(EthernetManager.ETHERNET_STATE_CHANGED_ACTION);
sIntent.putExtra("EthUp",true) //THis is information to be passed
                                                   //Intent has different methods for string/int and   //so on


whoever[applications] wants to receive this intent they register this intent in their androidmanifest.xml, they will implement the BroadcastStatusReceiver for the same.
From the receiver application's BroadcastStatusReciever's OnReceive()
{
   if(recvdIntent.Equals(ETHERNET_STATE_CHANGED_ACTION)
   {
     boolean b=getBooleanExtra("EthUp");
    }


}


To Know the disk freespace in linux

To know the disk freespace in Linux:

=======================================

df [disk free] command


df -k -h

it will list the partition,used space and free space available.



Thursday, October 04, 2012

To Enable logs in android Java files:   

import android.util.Slog;
 private void log(String s) {
        Slog.d(TAG, s);
    }
How to detect IP address change in Linux:

http://stackoverflow.com/questions/579783/how-to-detect-ip-address-change-programmatically-in-linux
Copy all the files except one folder in Linux:

We have to run the following commands:

shopt -s extglob       #setting bash shell option to recognize regex patterns
cp -r A/!(B) dest_dir  #This will copy directory A to dest_dir and
                                 #excludes B directory
Another way of adding NDK logs in C/C++:

#include
LOCAL_LDLIBS := -llog

void LOGI(char *szMsg)
{
__android_log_write(ANDROID_LOG_ERROR,"Tag",szMsg);
}
 Read and print all arguments in C/C++:
===========================
     
  int count;
   for (count = 0; count < argc; count++)
   {
            printf ("%s\n", argv[count]);
   }
How to add logs in android C/C++ files:

#define LOG_TAG XXX   // its the tag u can see in the logcat.
#include  

LOGE("printing log %s,%d",__FILE__,__LINE__);
 

In Android.mk, Add below line :

LOCAL_SHARED_LIBRARIES := \
        libutils          \
How to Launch an activity/application  in android from commandline:
=============================================

commands to launch an application in android:

adb shell am start -a android.intent.action.MAIN -n packageName/.mainActivityName

If I want to launch one application from commandline, what things I need to do:

1)From APK's AndroidManifest.xml,we can identify the main activity.Then we can use above command

2)Another easy way is launch an application using GUI/by clicking the application At the same time take logs using "adb logcat".

ActivityManager(1132): Starting activity: Intent { cmp=com.android.providers.subscribedfeeds/com.android.settings.ManageAccountsSettings }

ActivityManager(1132): Displayed activity  com.android.providers.subscribedfeeds/com.android.settings.ManageAccountsSettings :500 ms


 we can launch this activity from commandline as below:

 adb shell am start -a android.intent.action.MAIN -n 
com.android.providers.subscribedfeeds/com.android.settings.ManageAccountsSettings
 

How to know the services currently running in Android:

     To list the running services in android

  •   Menu->Setting->Applications->Running Services 

How to mount usb in Linux:

Mount USB if there is no other way in case of embedded linux:

 
  1) insert USB
  2) give "fdisk -l" [lists the /dev/sda1 or sda5]
  3)  mount /dev/sda1 /mnt/ [mount usb,USB file contents will be available in /mnt/ folder]



  4) cp ts.txt /mnt/   #  copy files to usb 
  5) cp /mnt/ts.txt .     #copy files from usb to current folder
  6) sync #Flush buffer read/write contents
  6) umount /mnt/  #unmount usb


Tar/Untar commands in Linux:
=====================


Compress tar.gz file:
# tar -zcvf archiveName.tar.gz directoryToCompress

To decompress an archive use the following syntax:

# tar -zxvf archiveName.tar.gz

Tuesday, October 02, 2012


How to get logcat from the android device which is having IP address:

we can connect to the device with IP address by adb command.
If we are runnign the below command from system,

adb connect 10.1.20.100 #will makes the system to connect with device.

Afterwards if we are giving “adb logcat”, this will prints the logs in your system.So with adb command, we can connect to any emulator or device which is having IP address. It is possible that we can connect to any remote device and can take logs from another remote place.


Starting and stopping Android core services:

Any android core services can be started and stopped by settting properties of a core service. Application can start or stop the any service by below commands:

setprop ctl.stop serviceName
setprop ctl.start serviceName

setprop ctl.stop dhcpcd_eth0 #This will stop the dhcpcd_eth0 service
setprop ctl.start dhcpcd_eth0 #This will start the dhcpcd_eth0 service

From our system, we can communicate emulator or actual device and we can see the properties set by below commands:

>adb shell
$getprop
This will gives/lists  output of all the properties set...


How to compile ICS code in Ubuntu 12.04 64 bit OS?
In  Ubuntu 12.04 64 bit OS, while compiling android ICS code[thru make], it will give FORTIFY_SOURCE error as below:
 + FORTIFY_SOURCE error ... :0:0: warning: "_FORTIFY_SOURCE" redefined 
 Problem for this issue:
 ICS is trying to compile with gcc-4.6. ICS code is compilable in gcc-4.4 only. 
Resolution: 
While giving make{compiling android code}, we can mention the make file to use gcc-4.4 by below commands:
 make CC=gcc-4.4 CXX=g++-4.4 
or 
  export CC=gcc-4.4 CXX=g++-4.4
  make #This will use exported CC & CXX flag's value gcc/g++-4.4 version 

Use below steps to install sun-java6-jdk in Ubuntu 12.04 LTS:

sudo add-apt-repository ppa:flexiondotorg/java 
sudo apt-get update
sudo apt-get install sun-java6-jdk

Monday, September 24, 2012


Configure NFS server:
 
   Set up NFS server linux machine:
   
    NFS server machine ip address is 10.1.10.100
 we have to configure /etc/export entry as follows in NFS server machine:

root@sundar:~# cat /etc/exports | grep "/u"
/u       10.1.10.20(rw,sync,no_subtree_check)


NFS client machine [10.1.10.20] can access the NFS server's u folder with read write access:

/u       10.1.10.20(rw,sync,no_subtree_check)

   

To mount NFS in NFS client:

root@sundar:~# mount -v -t nfs 10.1.19.100:/u /mnt
mount.nfs: timeout set for Mon Sep 24 12:37:05 2012
mount.nfs: text-based options: 'addr=10.1.10.100'
10.1.10.100:/u on /mnt type nfs (rw)
++++++++++++++
 afterwards copy using
cp /mnt/file destPath

Current /etc/export entry:

+++++++++++
root@sundar:~# cat /etc/exports | grep "/u"
/u       10.1.10.20(rw,sync,no_subtree_check)
+++++++++++



In Embedded linux device, How to copy files ? Thru teraterm or NFS or via USB cable or via USB storage.
we can mount the storage, copy the files from USB and copy it to device

Create mount point:

i)Insert USB storage
ii)cd mnt
iii)cd usb [or any folder]
iv) fdisk -l - fdisk commandline tool is managing hard disk/usb partitions in linux
fdisk -l
  list all the partitions
   /dev/sda
   /dev/sda5
v) mount /dev/sda5 /mnt/usb
vi) cp /mnt/usb/file . #Do operations...
vii)umount /mnt/usb #unmount the USB


In linux, How to sort the files by modified date?
I want to list the recently modified files should be listed in top.
The files which is not accessed for long time should be listed in bottom.
Can we write script ? No Need:

we can simply use "ls" command advanced version.

we have to use below command to list the files by recently modified date order.

ls -ult

Wednesday, September 19, 2012


How to run program in server even though our login session is over?

Usually  most people run android source code building from server via putty.
whenever we are giving build or any commands, it will not be executed once the putty session is over.

To avoid this, Linux has one most powerful command. That is screen.

we can use this screen command for various purposes.

screen syntax:
screen commandToBeExecuted


One more beauty of screen command is we can run our application and command in server, we can close the putty session. when we are reopening the putty session,
we can reattach that screen command & get results in ur putty.

For example while building I am getting some errors. One of my colleague is very well known how to resolve that error.Then I will go to his place and give "screen make" command(make is to build android code) while getting errors I will ask him to resolve it. when error is resolved, I can do "screen make" from his system. After this we will get build logs in his system.Not to disturb my colleague's work, I can detach the session from server, But still compilation will be done in background.I can go back to my seat and reattach the session, now the build process logs will be shown in my system.

To summarize:

From my friend's system I will do the following:

To build android code in server, I will give

screen make and will press ctrl+a and d then screen will print some id

  detached from 2309_pts-2

From my system, I will do the following:
  1) will open new putty session
  2) type "screen -r 2309_pts-2" [reattach the session]

Now the build logs will be shown in my system.


This screen command can be used for
  1) building the code even though the client session is over
  2) any background tasks activities can be done through it
  3) any big file downloads/android source code downloads can be done through it
     [In google chrome, there is an option called downloading the file in background even though the browser session is over]
4) To download android source code in background, i will do "screen repo sync", it will download the code in screen session


To list all the screen commands running in a server/system, we can use "screen -ls" command to list all the screen sessions running.




Friday, August 31, 2012


Background Process, Linux:

  if we want to run the process as background,we have to use & symbol.

   bash>./test.sh to run it as foreground service.

 To run it in background,

   bash>./test.sh &

How to run the process as service in linux: [Always up]:

  1) while linux system is in init process, shell files available in /etc/init.d got executed

whenever the system is up,  .profilerc or .bashrc or /etc/init.d/ scripts are executed.
Add your process to run in background

 add below line in your .bashrc or in any /etc/init.d/*.sh scripts
 
  ./MyService &


In Linux, From command prompt, if I want to do some bulk copy,usually I do like this:

 i) in one command prompt, I will perform copy operation
 ii)In another command prompt, I will do other work

We can do the same thing in single command prompt... How to do it ?

 i) run copy operation in background operation
 ii) Continue your work

  >cp bigFolder folderB &
   it will immediately returns to prompt,since copy operation is performed in background.
Next line, I can do any operation.
  >

 Once the copy operation is done, It will show below message in command prompt:

 2+1 cp Done.

 

If we want to mount any folder as sdcard in android device, then we need to look for vold scripts in android


To copy the files to embedded device from Desktop/Host machine:
1.we can mount NFS folder and we can copy from NFS
2.ADB- thru ADB push the files
3.Connect Desktop & embedded device through USB, mount the USB and copy the files through USB

Friday, August 24, 2012



Software Testing:

1.Everything is better if you make your tests before you implement the features

Known testing tools are there.
QTP, LoadRunner, TestRunner

TestRunner which is based on JUnit testing framework.It is used in android CTS testcase. CTS is using XML file for configuring testcases/testcase sequence. Junit is nothing Java testcases.

Ant is a opensource tool to automate the building process. It will use XML to build.
It is similar to make .(make file).

     Android Application project creation & building without eclipse can be automated using Ant tool.


Junit reference:
http://pub.admc.com/howtos/junit3x/intro-chapt.html

Using Ant to build android application project reference:
http://developer.android.com/tools/building/building-cmdline.html
http://www.androidengineer.com/2010/06/using-ant-to-automate-building-android.html

2.Monkey runner tool -Python based module which can control the device complete.
3.Monkey tool- UI/Application excerciser which can generate touch events random generator
which can be used for UI stress tool

4.Software testing books;
  i)Testing computer software
  ii) Lessons learned software testing
  iii)Automated testing -Introduction management and performance

5.Android CTS result
   Android CTS result xml has 3 states.
 
   i)Passed Testcases
   ii)Failed Testcases
   iii)NotExecuted testcases

   Testcases are listed under "NotExecuted" if it is not executed. This can happen only when Virtual machine is crashed and CTS testsuite is not able to proceed further testcases.

 Assume we have 10 testcases.First 3 testcases are passed. while running 4th testcase java virtual machine is crashed.Then CTS tool wont be able to communicate with the VM, so CTS result xml will list as follows:

  Passed testcases:3
  Failed testcases:0
  Not Executed    :7
 
 
6.Teraterm

  Kermit- can be used for bootstrap.supports transfer of text and binary file over serial communication
  X modem -file transfer protocol with Cyclic redundancy check
  Y modem -  allows multiple batch file transfer

7.JFFS2- support for NAND flash devices
  UBIFS- successor to JFFS2, it supports write caching.
      performs better when large raw flash NAND devices,Directory contents are using B+ trees.

8.Android camera:

Android camera HAL module is available in Camera.default.so library.

 Android camera module has 4 components:
   i)Camera client
   ii)Camera service
   iii)Camera HAL module
   iv) Camera driver
  Camera client talks to the cameraservice.Cameraservice talks to camera HAL module.
Camera HAL module talks to camera driver.

reference:
http://marakana.com/static/courseware/android/Aptina-Android-Camera-Internals.pdf

9. Three Components of android adb:
   1.adb server [running on Desktop machine, adb start-server, adb kill-server to start and kill adb server, it is also called as adb host daemon]
   2.adb client [running on Desktop machine, adb logcat ]
   3.adb daemon [running on Android device which will receives data through ports from adb server, can also be mentioned as adb target daemon]
     
10. JDB which can be used to debug android applications



Wednesday, August 22, 2012


Problem solving steps:
========================
1.Log effort on what I am doing for every half an hour or 1 hour work
2.Why we are struck up with problem ?

  i) we dont know what is the problem/what we are doing/why we are doing ?
  ii) Simply try to debug the problem
         Conceptualize the problem
  iii)No clarity on what we are doing, we will do the same thing again and again

3)For every half an hour or 1 hour, Think for 10 mins on what you are upto and what you are going to do?
4)Identify the possible set of problems and localize it one by one
5)For clarity, document what are all the possible approaches tried/why it is failed ?
6)Always start from the known things.[ our task is not do well things we dont know before.To solve
problems, in front of us right now...] It will also lead to know unknown things

7)Anyone can work on known things...
    Knowledge
     I know that I know - 3 %
     I Know that I dont know=2%
     I dont know that I dont know -Unleashing this knowledge /handle this type of scenario unleashes your potential.


What to do if CTS tool is not detecting the android device but adb is detecting a device?

Sometimes if we have done any changes not compliant to android, then this problem will happen.

1) if the CTS tool is not detecting the andorid device, we need to check the
platform/tools/tradefederation source code. This is having DeviceStateMonitor module.

2) By running cts-tradefed, it will saves the logs in tmp/log_xxx.txt. we can check error logs
from here and match the platform/tools/tradefederation source code.

running cts-tradefed,
we will get CTS prompt.

cts-tf>list devices

list devices will give device and its state.

Device states are available,Unavailable and allocated.

Allocated state -Allocated state device is currently running tests.
Available state- Device is available CTS is able to detect the device
Unavailable state- Device can be

    To check "available" state, waitForDeviceAvailable() will be called from DeviceStateMonitor.java.

WaitForDeviceAvailable()
{
// A device is currently considered "available" if and only if three events are true:
        // 1. Device is online aka visible via DDMS/adb
        // 2. Device's package manager is responsive
        // 3. Device's external storage is mounted
        //

}

 waitForDeviceAvailable() function will be varying for every android version.

Tuesday, August 21, 2012


I)What is CTS ?
II)CTS components
III)How to Run CTS from end user level?
IV)How to run CTS from Windows?
V)CTS binaries and source code structure


I)Why we need CTS ?
 
CTS testcases tests whether any android apis are modified or any changes done in android that is not compliant to android standard.
Google approves binary only when all CTS testcases are successful. For google approval process,
CTS test cases are executed on device and output .xml is sent to google team.

They will also run the CTS testcases from their end. If there is no failure, then they will approve the binary for the release.
Most of the Mobile operators will expect that the binary should be approved by google.

For some failure cases, we can get a waiver from google. For example, if it is a android DTV/Setupbox, then there wont be any GPS device in it.So all the GPS testcases will fail or not applicable for that device. Waiver request should be reasonable.

II) CTS components:
    CTS is an automated testing application that includes two major components
 1)CTS test application runs on desktop & manages test execution]
 2)Junit testcases running on Mobile or emulator or android device
  JUnit testcases are written in Java and packaged in Android.apk files to run on target device[emulator or android device].
 
III)How to run CTS from end user level?
   1.CTS can be run from Source code in linux
     
 if we have android source code, android/CTS folder will be there.
 we can compile CTS by following steps

 source build/envsetup.sh
 lunch sdk-eng
 make cts 

 Once the compilation is over, we can run
 >cts-tradefed 
 from command line.
 From cts-tradefed it will gives cts prompt.In cts prompt,
 type "list devices" to list the connected devices/emulator.You can refer the android cts document for    more information on list of commands.

 [cts-tradefed binary will be available in out/host/linux-x86/bin/cts/android-cts/tools/]
 cts-tradefed is a script file to run JUnit testcases.

     
   2.CTS can be run from downloaded binary  
         we have to download android compatiblity test suite from android site.

we have to configure this folder in PATH variable
and then we can run
 cts-tradefed in commandline.
     

 IV)How to run CTS from Windows ? Is it possible ?
      It is possible to run CTS from windows.
 Reason:
 "JUnit testcases are written in Java and packaged in Android.apk files to run on target device" from android cts manual.

 cts-tradefed is a script which will configures java to run Junit testcases.

 Configure CTS in Windows OS:

 Step1: adb path should be configured in PATH variable and "adb devices" should list down the devices.
 Step 2:
    cts-tradefed script will contains the following lines:


CTS_ROOT=${ANDROID_BUILD_TOP}/out/host/${OS}/cts
    JAR_DIR=${CTS_ROOT}/android-cts/tools
JARS="ddmlib-prebuilt.jar tradefed-prebuilt.jar hosttestlib.jar cts-tradefed.jar"

for JAR in $JARS; do
checkFile ${JAR_DIR}/${JAR}
JAR_PATH=${JAR_PATH}:${JAR_DIR}/${JAR}
done

   java -cp ${JAR_PATH} -DCTS_ROOT=${CTS_ROOT} com.android.cts.tradefed.command.CtsConsole

Assume that I have downloaded "android-cts-4.0.3_r3-linux_x86-arm.zip"  and unzipped it

My folder structure will be as follows:D:\android-cts-4.0.3_r3-linux_x86-arm\android-cts\tools
The simplification of this script is as follows for windows:

java -Xmx512M -cp D:\android-cts-4.0.3_r3-linux_x86-arm\android-cts\tools\cts-tradefed.jar;D:\android-cts-4.0.3_r3-linux_x86-arm\android-cts\tools\hosttestlib.jar;D:\android-cts-4.0.3_r3-linux_x86-arm\android-cts\tools\ddmlib-prebuilt.jar;D:\android-cts-4.0.3_r3-linux_x86-arm\android-cts\tools\tradefed-prebuilt.jar -DCTS_ROOT=D:\android-cts-4.0.3_r3-linux_x86-arm\   com.android.cts.tradefed.command.CtsConsole

run this command in commandline then you will get cts prompt in windows OS too.

-cp is the class search path for the zip or jar files. whenever some class is encountered in jar file,java will look for it in class search path.
CTS_ROOT will be used internally in jar files, so we are setting CTS_ROOT by -DCTS_ROOT.
CTS_ROOT is D:\android-cts-4.0.3_r3-linux_x86-arm. not a D:\android-cts-4.0.3_r3-linux_x86-arm\android-cts.[by giving this, i got errors]


V) CTS Binaries & source code structure:
          1)cts-tradefed.jar source code path is "android_source_path/cts"
 2)hosttestlib.jar
 3)Junit.tar
          4)ddmlib-prebuilt.jar
          5)tradefed-prebuilt.jar

 ddmlib-prebuilt.jar and tradefed-prebuilt.jar is available as prebuilt binaries. No source code available

 tradefed-prebuilt.jar is a CTS component runs on Desktop machine and manages test execution. platform/tools/tradefederation is the source code folder path for tradefed-prebuilt.jar file.














     

Saturday, August 18, 2012





MPEG TS:

1)  MPEG TS file has multiple elementary [multiple audio track] streams... why ? what is the purpose of it?
I got lost once I got the info like TS can have multiple Program streams what is the purpose of it ???

Transport Stream had been originally designed for broadcast.
to carry several media over one bit stream, all the streams are muxed in to one stream and sent it over the network.
Consider DVB (digital TV): each transponder (= frequency) provides one bit stream. But you already need at least two streams for a TV channel: audio and video. And then a lot more that you'll never see carrying meta-information. So instead of transporting each of these streams on a separate frequency, they are multiplexed into one bit stream. That is the MPEG-TS (Transport Stream). A demuxer then takes this stream and separates it into substreams which carry the real information.
As to which audio stream is played: a TV channel can have several audio streams (for example, normal audio, audio with descriptions for visual impaired, another language, etc.). By default, a player will probably play the first audio stream but can switch audio streams at any time.

 TS can have multiple elementary streams which will have separate streams for video/audio/subtitle/Program timing information.


while we are using airtel/Tata sky SetTopBox, we can see the program information at what time, what is the program. This kind of information
is available in PSI of MPEG TS format.PSI means Program Specific Information. PSI contains information about @ what time and date,
what program is to be played.

For more:http://en.wikipedia.org/wiki/Program-specific_information


2)Seek functionality for MPEG TS:

If we want to add seek functionality to MPEG TS what should we need to do?

   MPEG TS fileformat is not designed for random access. So It can be viewed sequentially.
Android stagefright doesnt have a seek functionality for TS file formats.
But VLC player has added seek functionality in TS fileformat based on PCR [Program clock Reference].

3)what is PCR :

To enable a decoder to present synchronized content, such as audio tracks matching the associated video, at least once each 100 ms a Program Clock Reference, or PCR is transmitted in the adaptation field of an MPEG-2 transport stream packet.
Decoder will calculate actual system time clock.

The PCR is a clock that represents 27 Mhz clock at the encoder side. Hence each tick of PCR clock represents the 1/27 Microseconds.

The first step is to be able to parse the PCR packet. The PCR ticks are maintained by a specific PID (mostly video but can be audio or alternative packets). When the PCR is present in the packet, it is of Adaptation field, type 2 or 3. You can refer to this or wiki for understanding how to parse PCR.

Once you get the PCR value of the packet - (use a 64 bit integer) you have a timestamp P0 for that packet. Now you can seek to exactly say 10 seconds, when you get next PCR packet, with a time stamp, P1 where

P1 = P0 + 10 * 27 * 10^6

So when you see another such packet containing timestamp P1 or more you can be sure of elapsing 10 seconds.PCR may find discontinuity hence, more calculation is needed at the point PCR base shifts.


From :http://stackoverflow.com/questions/6443615/pcr-based-seek-for-mpegtsfile

4)How to generate PTS[Presentation Timestamp] from PCR ?

PCR has 33+9 bits, the PTS 33 bits. The 33 bit-portion (called PCR_base) runs at 90kHz, as does the PTS. The remaining 9 bits are called PCR_ext and run at 27MHz.
 there should be a time-offset between the PTSs of the multiplexed streams and the PCR, it's usually in the range of a few hundred ms, depending on the stream.

The respective decoder needs some time to decode the data and get it ready for presentation at the time given by the respective PTS, that's why the PTSs are always "ahead" of the PCR. ISO-13818 and some DVB specs give specifics about buffering and (de)multiplexing.

From: http://stackoverflow.com/questions/6199940/generate-pcr-from-pts


5)MPEG2 TS:
Transport Stream had been originally designed for broadcast. Later it was adapted for usage with digital video cameras, recorders and players by adding a 4-byte timecode (TC) to standard 188-byte packets, which resulted in a 192-byte packet.This is what is informally called M2TS stream.
It is used in Bluray disc  and digital video cameras.

Timecode allows quick access to the any part of the stream either from a mediaplayer or from a non-linear video editing system.


6) SetTop Box:
    i)local cable operators give cable connection that is DVB-C signal
    ii)Tata sky or Airtel digital - we have to fix antenna to receive signal- this is called DVB-S (DVB-Satellite signal standard)

7)IPTV
Internet Protocol television (IPTV) is a system through which television services are delivered using the Internet protocol suite over a packet-switched network such as the Internet, instead of being delivered through traditional terrestrial, satellite signal, and cable television formats.    

 IPTV provides  3 main services:
   i) Live TV-with or without interactivity related to the current TV show;
   ii) time-shifted television: catch-up TV (replays a TV show that was broadcast hours or days ago), start-over TV (replays the current TV show from its beginning);
   iii)video on demand (VOD): browse a catalog of videos, not related to TV programming

http://en.wikipedia.org/wiki/IPTV

8) SD or HD TV
  High Definition (HD) is swiftly replacing Standard Definition (SD) when it comes to television broadcasts. HD has a high picture resolution of 1920x1080, with 2.07million+ pixels offering 5 times more detail than SD. It has a wide aspect ratio of 16:9 better suited for our eyes which have more horizontal than vertical span, as compared to an aspect ratio of 4:3 in SD.

9) what is Trick Play:
       -Ability to receive broadcast television shows with VCR-like functions such as pause, rewind, fast forward, replay and skip, collectively known as 'trick play', all while rendering a live video stream.


 
 

Friday, August 17, 2012


Problems faced while installing android application setup:

1.First time I have opened Android sample application, I got like "Android Native supported libraries"
need to be installed. I installed Android native libraries

2.In 64 bit Windows 7, I faced this problem:
 Android SDK installer [ installer_r08-windows.exe] is not detecting JDK.

I tried the following:
  i)Set the JDK bin/ JRE Bin in PATH variable, it is not working
  ii)Android SDK installation dialog shown that JDK folder path to be set in JAVA_HOME variable
   I did that it is also not working.
solution:
  1) Copied java.exe and javaw.exe from JDK bin to c:\windows\system32 and  c:\windows\sysWOW64
 Now android sdk setup is detecting JDK.

Following steps  are needed for ICS Android application Development Setup :

1.Downloaded the JDK7 and installed it in machine
2.Downloaded installer_r20.0.3-windows.exe from google site
3.Run the "installer_r20.0.3-windows.exe"
4.Followed the below blog to download ICS SDK
http://www.android.pk/blog/tutorials/install-and-run-android-4-0-sdk-and-ice-cream-sandwich-on-pc/
Now ICS SDKs are installed.Create the AVD for for any platform which requires for application development
5.Downloaded ADT plugin from google site
6.Downloaded the Eclipse classic
7.Downloaded the android_sdk_for_windows.zip and set the tools/platform-tools  folder in PATH variable
8.Installed & Opened the Eclipse classic application
9.In Eclipse, Select    Install new software & select the localpath and add the ADT plugin zip file &
install the files
10.After the ADT plugin was installed, eclipse showed that it requires android support libraries...I installed that android support libraries too...


11.In eclipse->Preferences->Android->SDK location as "android_sdk_windows" folder path.
12.create new android application in eclipse
13.To run the application in emulator,
In Eclipse, Select Run->Run Configurations->Give Some string in "Name" box and select Launch default activity.
 In "Target" tab,select the AVD configuration to run the application





Thursday, August 16, 2012


Hyderabad is famous for following things:
1.Biryani [Hyderabadi biryani]
2.Irani chai
3.Pearls
4.Haleem [paste kind of food made of mutton meat]


Things learnt today:

1.Chrome browser is having to HTML5 support.
2.what is USB modem stack?
    USB modem client is installed in mobile/device. USB Host driver is installed in laptop or system.
with the help of USB modem stack we can take mobile's internet connection to laptop or system.
In android, this is called tethering.

3.Wifi Hotspot in android mobiles:
    Android mobiles are having Wifi hotspot support. if mobile has internet connectivity, our mobile will acts like WiFi router . we can connect device or laptop
to that WiFi hotspot.
   To provide support WiFi hotspot, WiFi chip should be available in android /mobile device.
Accessing internet via Wifi hotspot is also called as WiFi tethering.

4.VoIP phone:
A VoIP phone uses voice over IP (VoIP) technologies allowing telephone calls to be made over an IP network such as the Internet instead of the ordinary PSTN system. Calls can traverse the Internet, or a private IP network such as that of a company. The phones use control protocols such as Session Initiation Protocol (SIP), Skinny Client Control Protocol (SCCP) or one of various proprietary protocols such as that used by Skype.
From : http://en.wikipedia.org/wiki/VoIP_phone

Wednesday, August 15, 2012

In Embedded system, First we need to flash loader & then we need to install boot loader (U-BOOT).UBOOT  will configure the kernel  (also pass kernel arguments).


1. what is loader ?
A loader is the part of an operating system that is responsible for loading programs. It is one of the essential stages in the process of starting a program, as it places programs into memory and prepares them for execution. Loading a program involves reading the contents of executable file, the file containing the program text, into memory, and then carrying out other required preparatory tasks to prepare the executable for running. Once loading is complete, the operating system starts the program by passing control to the loaded program code.

2.why we are doing NAND ERASE/NAND WRITE commands for writing loader/U-BOOT/kernel in embedded linux?

In Embedded linux/devices, bootloader is flashed into flash memory.To write kernel/bootloader into flash memory, we
are using NAND ERASE/WRITE.NAND ERASE/WRITE are the commands to reprogram the ROM chips.


Flash memory is a non-volatile computer storage chip that can be electrically erased and reprogrammed. It was developed from EEPROM
(electrically erasable programmable read-only memory) and must be erased in fairly large blocks before these can be rewritten with new data.
The high density NAND type must also be programmed and read in (smaller) blocks, or pages,
while the NOR type allows a single machine word (byte) to be written or read independently.

Example for Flash memory: ROM, EPROM,EEPROM
Wiki:http://en.wikipedia.org/wiki/Flash_memory


3.what is Samba file system ?
   In windows, we can access the shared folder in a network. But in linux, if we want to share the folder across the network, we need to install the samba.
So that from any machine in the network, we can access the files as like local folder.

4.In Embedded system, First we need to flash loader & then we need to install boot loader (U-BOOT).UBOOT  will configure the kernel  (also pass kernel arguments).

5.we can use U-Boot to load kernel or other file from TFTP into RAM
6.tftp in embedded linux:
   For transfering the kernel/long files to embedded device,we can use
                 i)tftp
ii) serial port access
        But tftp will give faster data transfer of files. Reason is that tftp acts on ethernet/network.Ethernet gives 10 Mbps data transfer speed.
 Maximum data transfer in Serial port is 128Kbps or 192 kbps.
But tftp needs
          i) IP configuration [Ethernet hardware]
          ii)tftp client

7. NFS  [Network file system]:

Network file system will boot system files/libraries from the server. NFS client wont have any libraries.
It will just load the required system files/libraries from server.

  NFS use in Embedded system:
         i)In embedded system, instead of flashing binary every time to embedded device, we can just configure the development system's compiled library path in embedded device.
For every compilation, libraries got updated and embedded device will boot libraries everytime from development system.

  Things needed for accessing NFS:
    i) Ethernet[hardware for IP address]
    ii) NFS client

8. ADB CONNECT
    If we want to get logs from android mobile/consumer device, what we can do ?

   i)we can connect the android mobile consumer device to system via USB and we can get logs via "adb logcat".
   ii) For android development, if we are using putty from windows system to access the Linux server which has source code.
But my device is connected to windows system. In such a scenario, we are able to take android logs from Linux server or windows system.
(But the android device should have IP address.)
How it is possible ?

  if the android consumer device is having IP address[ethernet support],we can connect to the device via IP address
          "adb connect android_device_ipaddress" can be used to connect to android device.Next if we are putting logs,we can get logs via adb logcat.

9.Embedded linux boot sequence:
   ROM Code -> BootStrap/Loader -> U Boot -> Kernel -> RootFiles