Saturday 17 May 2014

My exclusive article in College Magazine



Wednesday 26 March 2014

Porting Android to Devices


Porting Android to Devices


Android provides you with the freedom to implement your own device specifications and the drivers to support them. The hardware abstraction layer (HAL) gives you a standard way to create software hooks in between the Android platform stack and your hardware. In addition, the Android operating system is open-sourced to help you through your device's bringup.
To ensure that your devices maintain a high level of quality and offers a consistent experience for your users, they must must also pass the tests in the compatibility test suite (CTS). CTS ensures that anyone building a device meets a quality standard that ensures apps run reliabaly well and gives users a good experience. For more information, see the Compatibility section.

Android Low-Level System Architecture


Before you begin porting Android to your hardware, it is important to have an understanding of how Android works at a high level. Because your drivers and HAL code interact with many layers of Android code, this understanding can help you find your way through the many layers of code that are available to you through the AOSP (Android Open Source Project) source tree. The following diagram shows a system level view of how Android works:

Figure 1. Android System Architecture

Application framework

This is the level that most application developers concern themselves with. You should be aware of the APIs available to developers as many of them map 1:1 to the underlying HAL interfaces and can provide information as to how to implement your driver.

Binder IPC

The Binder Inter-Process Communication mechanism allows the application framework to cross process boundaries and call into the Android system services code. This basically allows high level framework APIs to interact with Android's system services. At the application framework level, all of this communication is hidden from the developer and things appear to "just work."

System services

Most of the functionality exposed through the application framework APIs must communicate with some sort of system service to access the underlying hardware. Services are divided into modular components with focused functionality such as the Window Manager, Search Service, or Notification Manager. System services are grouped into two buckets: system and media. The system services include things such as the Window or Notification Manager. The media services include all the services involved in playing and recording media.

Hardware abstraction layer (HAL)

The HAL serves as a standard interface that allows the Android system to call into the device driver layer while being agnostic about the lower-level implementations of your drivers and hardware. You must implement the corresponding HAL (and driver) for the particular piece of hardware that your product provides. Android does not mandate a standard interaction between your HAL implementation and your device drivers, so you have free reign to do what is best for your situation. However, you must abide by the contract defined in each hardware-specific HAL interface for the Android system to be able to correctly interact with your hardware. HAL implementations are typically built into shared library modules (.so files).

Linux Kernel

For the most part, developing your device drivers is the same as developing a typical Linux device driver. Android uses a specialized version of the Linux kernel with a few special additions such as wakelocks, a memory management system that is more agressive in preserving memory, the Binder IPC driver, and other features that are important for a mobile embedded platform like Android. These additions have less to do with driver development than with the system's functionality. You can use any version of the kernel that you want as long as it supports the required features, such as the binder driver. However, we recommend using the latest version of the Android kernel. For the latest Android kernel, see Building Kernels.

Reference:
http://s.android.com/devices/index.html

Friday 21 March 2014

HOW TO SEARCH ON GOOGLE

Inspired by Yesterday's Lesson, This Article helps many people.
.
HOW TO SEARCH ON GOOGLE?

DROPBOX LINK
https://www.dropbox.com/s/a8guiy94hz2yqbg/Search-on-google.jpg


Monday 28 October 2013

ALL THE DOTNET PROGRAM WHICH ARE TAUGHT IN MY SEMESTER: I MIGHT HELP YOU ALL THE CODERS.


EACH PROGRAMME ENDS WITH THE SEPRATOR.
USE FIND OPTION TO FIND THE KEY WORD OF YOUR RESPECTIVE CODE.
IN SOME PROGRAMME YOU MIGHT NEED TO CHANGE THE PATH.


----------------------------------------------------------------------

using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace abstract_class_program
{
   abstract class Program
    {
        abstract public void show();
      //  {
        //    Console.WriteLine("this method is base class method");
     //   }

        static void Main(string[] args)
        {
           // Program pro1 = new Program();
            Derive PD = new Derive();
            Program pro2 = new Derive();

          //  pro1.show();
            PD.show();
            pro2.show();

            Console.ReadLine();
        }
    }

    class Derive : Program
    {
        public override void show()
        {
            Console.WriteLine("This is derived Class"); //this will still shows the BASE CLASS TEXT IN THE THIRD LINE in RUN.

        }
    }
}
-------------------------------------------------------------
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace anoymonous_delegate_example
{
    delegate void anmdel(string s);

    class Program
    {
        static void Main(string[] args)
        {
            anmdel andel = delegate(string s)
                {
                    Console.WriteLine(s.ToUpper());

                };
                andel("hello");
                Console.ReadLine();

        }
    }
}

---------------------------------------------------------------
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace Array_with_for_loop
{
    class Program
    {
        static void Main(string[] args)
        {
            int[] arr = new int[3];
            arr[0] = 1;
            arr[1] = 20;
            arr[2] = 30;

            foreach (int i in arr)
            {
                Console.WriteLine(i);
            }

            Console.ReadLine();


        }
    }
}

--------------------------------------------------------------
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Threading;

namespace bank_example_threading    //FOR SYNCRONIZATION
{
    class bank_account
    {
        public int ac_id;
        public string customer_name;
        public float balance;

        bank_account(int i, string n, float b)
        {
            ac_id = i;
            customer_name = n;
            balance = b;

        }

        public void debit(float amt)
        {
            float cur_bal = 0;
            Console.WriteLine("Balance" + balance);

            Thread.Sleep(1000);

            cur_bal = balance + amt;

            balance = cur_bal;

            Thread.Sleep(1000);

            Console.WriteLine("After Balance" + balance);
        }

        public void credit(float amt)
        {
            float cur_bal = 0;
            Console.WriteLine("Balance" + balance);

            Thread.Sleep(1000);

            cur_bal = balance - amt;

            balance = cur_bal;

            Thread.Sleep(1000);

            Console.WriteLine("After Balance" + balance);
        }

        enum operation { debit, credit }

        class account_user
        {
            bank_account acc;
            operation oper;
            float amt;

            public account_user(bank_account ac, operation o, float a)
            {
                this.acc = ac;
                this.oper = o;
                this.amt = a;
            }

            public void Run()
            {
                lock (acc)
                {
                    if (oper == operation.debit)
                        acc.debit(amt);
                    else
                        acc.credit(amt);
                }
            }


            class program
            {

            }
            static void Main(string[] args)
            {
                bank_account ac = new bank_account(101, "karmu", 5000);
                account_user user1 = new account_user(ac, operation.debit, 1000);
                account_user user2 = new account_user(ac, operation.credit, 500);

                Thread threaduser1 = new Thread(new ThreadStart(user1.Run));
                Thread threaduser2 = new Thread(new ThreadStart(user2.Run));

                threaduser1.Start();
                threaduser2.Start();

                threaduser1.Join();
                threaduser2.Join();

                Console.WriteLine("Final Balance" + ac.balance);

                Console.ReadLine();

            }
        }
    }
}

----------------------------------------------------------------------------------------
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;


namespace collection_generic_example

{

    class Program
    {
        static void Main(string[] args)
        {
            List<string> L = new List<String>();
         
            L.Add("ABC");
            L.Add("BAM BAM BHOLE");
            L.Add("CHIMPU");
            L.Add("KARMENDRA");

             Console.WriteLine(L.Contains("CHIMPU"));// This is for Checking wheather ABC is in LIST or not
            //L.Remove("ABC");                              //This is for removing

            foreach (String s in L)
            {
                Console.WriteLine(s);
            }

            Console.ReadLine();
        }
    }
}
--------------------------------------------------------
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Collections;


namespace Collection_non_generic_example
{

    class Program
    {
        static void Main(string[] args)
        {
            ArrayList arr = new ArrayList();
            arr.Add(10);
            arr.Add("ABC");
            arr.Add(12.5);
            arr.Add(25);

           // Console.WriteLine(arr.Contains(10));        // This is for Checking wheather 10 is in arr or not
            arr.Remove(10);                              //This is for removing

            foreach (object o in arr)
            {
                Console.WriteLine(o);
            }

            Console.ReadLine();
        }
    }
}

--------------------------------------------------------------
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Xml;


namespace ConsoleApplication2
{
    class Program
    {
        static void Main(string[] args)
        {
            XmlTextReader reader = new XmlTextReader("d:\\Xml\\data.xml");
            while (reader.Read())
            {
                switch (reader.NodeType)
                {
                    case XmlNodeType.Element:
                        Console.WriteLine("<{0}>", reader.Name);
                        break;

                    case XmlNodeType.Text:
                        Console.WriteLine(reader.Value);
                        break;

                    case XmlNodeType.EndElement:
                        Console.WriteLine("<{0}>", reader.Name);
                        break;
                }
            }
            Console.ReadLine();
        }
    }
}

---------------------------------------------------------------
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace Delegates_example
{
    delegate string StringDelegate(string s);

    class Program
    {
        public string reverseString(string s)
        {

            string temp = "";
            for (int i = s.Length-1 ; i >= 0; i--)
            {
                temp = temp + s[i];
            }

            return temp;
        }

        static void Main(string[] args)
        {
            Program pro = new Program();
            StringDelegate strdel = new StringDelegate(pro.reverseString);
            string result = strdel("Hello");
            Console.WriteLine(result);
            Console.ReadLine();

        }
    }
}
-----------------------------------------------------------------
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace Demo10sept
{
    class Program
    {
           
        public int add(int p, int q)
        {
            int s = p + q;
            return s;

        }

        public double add(double t, double u)
        {
            double s = t + u;
            return s;

        }

        public int sub(int p, int q)
        {
            int s = p - q;
            return s;

        }
        public int mul(int p, int q)
        {
            int s = p * q;
            return s;

        }
        public int div(int p, int q)
        {
            int s = p / q;
            return s;

        }

        static void Main(string[] args)
        {
            int p, q, result;
            double t, u, res;

            Console.WriteLine("enter the value of p");
            p= Convert.ToInt32(Console.ReadLine());
         
            Console.WriteLine("enter the value of q");
            q = Convert.ToInt32(Console.ReadLine());

            Console.WriteLine("enter the value of t");
            t = Convert.ToDouble(Console.ReadLine());

            Console.WriteLine("enter the value of u");
            u = Convert.ToDouble(Console.ReadLine());


            Program pro = new Program();
         
            result = pro.add(p,q);
            Console.WriteLine("result of addition  " + result);

            res = pro.add(t, u);
            Console.WriteLine("result of double addition  " + res);


            result = pro.sub(p, q);
            Console.WriteLine("result of substraction  " + result);
            result = pro.mul(p,q);
            Console.WriteLine("result of Multiplication  " + result);
            result = pro.div(p,q);
            Console.WriteLine("result of Division  " + result);

           

            Console.ReadLine();

        }
    }
}

----------------------------------------------------------------

using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace dictionary_generic_example
{

    class Program
    {
        static void Main(string[] args)
        {
            Dictionary<int, string> D = new Dictionary<int, string>();
         
            D.Add(1, "ABC");
            D.Add(2, "AVINASH");
            D.Add(3,"CHIMPU");
            D.Add(4, "KARMENDA");

            // Console.WriteLine(D.Contains("CHIMPU"));      //   This is for Checking wheather ABC is in LIST or not
            // L.Remove("ABC");                              //   This is for removing

          
           /* foreach (int o in D.Keys)
            {
                Console.WriteLine(o);
               
            } */
           
           
           
             foreach (KeyValuePair<int, string> kvp in D)
            {
                Console.WriteLine(kvp.Key);
                Console.WriteLine(kvp.Value);
            }

            Console.ReadLine();
        }
    }
}

----------------------------------------------------------------------
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.IO;

namespace Directory_info
{
    class Program
    {
        static void Main(string[] args)
        {
            DirectoryInfo d = new DirectoryInfo("c:\\windows");
            foreach (FileInfo f in d.GetFiles("*.txt"))
            {
                Console.WriteLine("file Name is " + f.Name);
                Console.WriteLine("file size is " + f.Length);
                Console.WriteLine("Creation Time " + f.CreationTime);
            }
            Console.ReadLine();
        }
    }
}

------------------------------------------------------------------
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace Enum
{
    enum weekday {sun, mon, tue, wed, thu, fri, sat = 1}

    class Program
    {
       
        static void Main(string[] args)
        {
            weekday d = weekday.mon;

            switch (d)
            {
                case weekday.mon:
                    Console.WriteLine("It is Monday");
                    break;

                case weekday.sun:
                    Console.WriteLine("It is Sunday");
                    break;

                default:
                    Console.WriteLine("NO DAY");
                    break;

                   
        }
            Console.ReadLine();
        }
    }
}

-------------------------------------------------------------------
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace example_for_properties
{
    class Program
    {
        int i;
        int ID
    {
    get
    {
        return i ;
    }
    set
{
    i = value;
}
}
        static void Main(string[] args)
        {
            Program pro = new Program();
            pro.ID = 10;
            Console.WriteLine(pro.ID);

            Console.ReadLine();
        }

       
    }
}

--------------------------------------------------------------------
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.IO;

namespace file_handeling_stream_reader_writer
{
    class Program
    {
        static void Main(string[] args)
        {
            StreamWriter sw = new StreamWriter("D:\\MyDirectory\\Testfile.txt");
            sw.WriteLine("YO YO HONEY SINGH");
            sw.Close();
            StreamReader sr = File.OpenText("D:\\MyDirectory\\Testfile.txt");
            string txt;
      
            while((txt = sr.ReadLine()) != null)
            {
                Console.WriteLine(txt);
            }
            Console.WriteLine("END OF STREAM");
            sr.Close();
            Console.ReadLine();
        }
    }
}

---------------------------------------------------------------------
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.IO;


namespace file_handeling
{
    class Program
    {
        static void Main(string[] args)
        {
            string Directoryname = @"D:\MyDirectory";
            if (Directory.Exists(Directoryname))
            {
                Console.WriteLine("Exists");
            }

            else
            {
                Directory.CreateDirectory(Directoryname);
                Console.WriteLine("Created");
            }

            Console.ReadLine();

        }
    }
}

----------------------------------------------------------------------
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.IO;

namespace file_handeling_create
{
    class Program
    {
        static void Main(string[] args)
        {

            string FileName = @"D:\\MyDirectory\\MyFile.txt";
            if (File.Exists(FileName))
            {
                Console.WriteLine("Exits");
            }

            else
            {
                File.Create(FileName);
                Console.WriteLine("created");
            }
            Console.ReadLine();

        }
    }
}

---------------------------------------------------------------------
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.IO;


namespace file_handeling_Stream
{
    class Program
    {
        static void Main(string[] args)
        {
           FileStream fs = new FileStream(@"D:\MyDirectory\FileIO.txt", FileMode.Create, FileAccess.Write);
               BinaryWriter bw= new BinaryWriter(fs);
               bw.Write(" yo yo");
               bw.Close();
               fs.Close();

               fs = new FileStream(@"D:\MyDirectory\FileIO.txt", FileMode.Open, FileAccess.Read);
               BinaryReader br = new BinaryReader(fs);
               Console.WriteLine(br.ReadString().ToString());
            br.Close();
            fs.Close();
            Console.ReadLine();


        }
    }
}

-------------------------------------------------------------------
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.IO;

namespace File_handelling_non_static
{
    class Program
    {
        static void Main(string[] args)
        {
            string Directoryname = @"D:\MyDirectory";
            if (Directory.Exists(Directoryname))
            {
                Console.WriteLine("Exists");
            }

            else
            {
                DirectoryInfo d = new DirectoryInfo(Directoryname);
                d.Create();
                Console.WriteLine("Created");
            }

            Console.ReadLine();

        }
    }
}


-----------------------------------------------------------------------
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace Interface_example
{
    public interface Idemo
    {
        void show();
    }

    class Program : Idemo
    {
        public void show()
        {
            Console.WriteLine("This is interface Class demo");
        }

        static void Main(string[] args)
        {
            Program pro = new Program();
            pro.show();
       
            Console.ReadLine();
       
        }
    }
}

-------------------------------------------------------------------
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace jacked_array_example
{
    class Program
    {
        static void Main(string[] args)
        {
           

            int [][] arr = new int [2][];

            arr[0] = new int [2];
            arr[0][0] = 10;
            arr[0][1] = 20;

            arr [1] = new int [3];
            arr[1][0]= 30;
            arr[1][1] = 40;
            arr[1][2] = 50;
           
            for (int i = 0; i< arr.Length; i++)
            {

            int[] inner_array = arr[i];

                for(int j=0; j<inner_array.Length; j++)
                {
                    Console.Write(arr[i][j] + "         ");
                }

                Console.WriteLine();
            }

            Console.ReadLine();
        }

    }
}

-----------------------------------------------------------------
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace method_over_riding
{
    class Program
    {
        virtual public void show()
        {
            Console.WriteLine("this method is base class method");
        }

   
  
        static void Main(string[] args)
        {
            Program pro1 = new Program();
            Derive PD = new Derive();
            Program pro2 = new Derive();

            pro1.show();
            PD.show();
            pro2.show();

            Console.ReadLine();
        }
    }

    class Derive : Program
    {
        public override void show()
        {
            Console.WriteLine("This is derived Class");

        }
    }

}


-----------------------------------------------------------------
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace multicast_delegate_examples
{
    delegate void  multideligate(int x, int y);
    class Program
    {
        public void add(int x, int y)
        {
            int a = x+y;
            Console.WriteLine("Addition of two no. is " + a);

        }

            public void sub(int x, int y)
            {
                int a = x-y;
                Console.WriteLine("Subtraction of two no. is " + a);
            }

            public void mul(int x, int y)
            {
                int a = x * y;
                Console.WriteLine("multiplication of two no. is " + a);

            }
        static void Main(string[] args)
        {
            Program pro = new Program();
            multideligate delobject;
            multideligate adddel = new multideligate(pro.add);
            multideligate subdel = new multideligate(pro.sub);
            multideligate muldel = new multideligate(pro.mul);
            delobject = adddel;
            delobject += subdel;
            delobject += muldel;
            Delegate[] delegatelist = delobject.GetInvocationList();
            for (int i = 0; i < delegatelist.Length; i++)
            {
                ((multideligate)(delegatelist[i])).Invoke(20, 10);

            }
            Console.ReadLine();

        }
    }
}

--------------------------------------------------------------------
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace operator_overloading
{
    class Program
    {
        int a;
        int b;

        public Program()
        {
            a = 0;
            b = 0;

        }
        public Program(int x, int y)
    {
        a = x;
        b = y;

    }

        public static Program operator + (Program p1, Program p2 )
        {
            Program temp = new Program();
            temp.a = p1.a + p2.a;
            temp.b = p1.b + p2.b;

            return temp;

        }
        static void Main(string[] args)
        {
            Program pro1 = new Program(10, 20);
            Program pro2 = new Program(30, 40);

            Program pro3 = pro1 + pro2;

            Console.WriteLine(pro3.a);
            Console.WriteLine(pro3.b);
            Console.ReadLine();
        }
    }
}

----------------------------------------------------------------------
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace method_over_riding
{
    class Program
    {
        virtual public void show()
        {
            Console.WriteLine("this method is base class method");
        }

   
  
        static void Main(string[] args)
        {
            Program pro1 = new Program();
            Derive PD = new Derive();
            Program pro2 = new Derive();

            pro1.show();
            PD.show();
            pro2.show();

            Console.ReadLine();
        }
    }

    class Derive : Program
    {
        public new void show()
        {
            Console.WriteLine("This is derived Class"); //this will still shows the BASE CLASS TEXT IN THE THIRD LINE in RUN.

        }
    }

}

---------------------------------------------------------------------------------------------------
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Threading;

namespace Threading_with_Console_Application
{
    class threaddemo
    {
        private string fname;
        private string lname;

        public threaddemo(string f, string l)
        {
            fname = f;
            lname = l;

        }

        public void run()
        {
            try
            {
                Console.WriteLine("first name is " + fname);

               // Thread.Sleep(500);
                Console.WriteLine("last name is" + lname);
            }
            catch (Exception ex)
            {
                Console.WriteLine(ex.Message);
            }
        }


        static void Main(string[] args)
        {
            threaddemo t1 = new threaddemo("PARAG" , "Verma");
            threaddemo t2 = new threaddemo("Avinash" , "Michael");

            Thread first = new Thread(new ThreadStart(t1.run));
            Thread second = new Thread(new ThreadStart(t2.run));

            first.IsBackground = true;
            second.IsBackground = true;

            first.Start();
            second.Start();



            Console.ReadLine();
        }
    }
}

------------------------------------------------------------------
using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;

public partial class index : System.Web.UI.Page
{
    protected void Page_Load(object sender, EventArgs e)
    {
        int cnt = 0;
        if (!IsPostBack)
        {
            ViewState["counter"] = cnt.ToString();
        }
        else
        {
            cnt = Convert.ToInt32(ViewState["counter"]);
            cnt = cnt + 1;
            ViewState["counter"] = cnt.ToString();

        }
    }
    protected void btn_submit_Click(object sender, EventArgs e)
    {
        txt_id.Text = ViewState["counter"].ToString();
    }
}
----------------------------------------------------------------------------------------------
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Xml;

namespace xml_prog
{
    class Program
    {
        static void Main(string[] args)
        {
            XmlTextWriter writer = new XmlTextWriter("d:\\xml\\data.xml", null);

            writer.WriteStartDocument();
            writer.WriteStartElement("car");
            writer.WriteStartElement("cars");
            writer.WriteStartElement("make");

            writer.WriteAttributeString("foreign", "true");
            writer.WriteString("honda");
            writer.WriteEndElement();
            writer.WriteElementString("model", "acord");
            writer.WriteElementString("color", "black");
            writer.WriteElementString("year", "1998");
            writer.WriteEndElement();
            writer.WriteEndElement();
            writer.Flush();
            writer.Close();
               
        }
    }
}
---------------------------------------------------------------------