망고100 보드로 놀아보자-19 Android Ethernet 분석

Slides:



Advertisements
Similar presentations
1 Android Introduction Hello Threads. 2 Goal Create an application that uses a background thread as a UDP server to receive messages from the UDP client.
Advertisements

J0 1 Marco Ronchetti - Web architectures – Laurea Specialistica in Informatica – Università di Trento Java XML parsing.
Bluetooth. Wireless networking technology Limited broadcast range (< 10 meters) Example uses include Connecting headsets to phones, keyboard/mouse to.
Software Engineering Implementation Lecture 3 ASPI8-4 Anders P. Ravn, Feb 2004.
1 Data Structures - CSCI 102 CS102 C++ Operator Overloading Prof Tejada.
The Singleton Pattern II Recursive Linked Structures.
Public class ABC { private int information = 0; private char moreInformation = ‘ ‘; public ABC ( int newInfo, char moreNewInfo) { } public ABC () {} public.
Problem Solving 5 Using Java API for Searching and Sorting Applications ICS-201 Introduction to Computing II Semester 071.
Programming with Java. Problem Solving The purpose of writing a program is to solve a problem The general steps in problem solving are: –Understand the.
Written by: Dr. JJ Shepherd
© 2008 Cisco Systems, Inc. All rights reserved.Cisco ConfidentialPresentation_ID 1 Chapter 10: DHCP Routing and Switching Essentials.
IntroductionIntroduction  Computer program: an ordered sequence of statements whose objective is to accomplish a task.  Programming: process of planning.
Principles of Object-Oriented Software Development The language Java.
COMP 14: Intro. to Intro. to Programming May 23, 2000 Nick Vallidis.
Cosc 5/4730 A little on threads and Messages: Handler class.
Principles of Computer Programming (using Java) Review Haidong Xue Summer 2011, at GSU.
JAVA PROGRAMMING PART II.
University of Limerick1 Work with API’s. University of Limerick2 Learning OO programming u Learning a programming language can be broadly split into two.
1 Identifiers  Identifiers are the words a programmer uses in a program  An identifier can be made up of letters, digits, the underscore character (
What is Android NDK ● A toolset that lets you embed in you app native source code ● C, C++(recently supported December 2010) and assembly(?) ● It is supported.
Java: Chapter 1 Computer Systems Computer Programming II.
Codec,battery,powermanager 커널 드라이버
P2P communication Using the GTalk Service API. Introduction Peer-to-Peer communication highly used in mobile devices. Very efficient to when certain factors.
Gaël ALLOYER, Marc CABOCEL, Romain CASTAGNET, Pascal CLEMENT, Pierre LEROY, Guillaume LESNE, Nicolas PEPIN Bring mobility for a connecting world… Tutors:
ACE Address Configuration Executive. Why ACE? ACE provides access to several address resolution protocols under a single API ACE is the only API available.
Java Introduction to JNI Prepared by Humaira Siddiqui.
Introduction to Programming David Goldschmidt, Ph.D. Computer Science The College of Saint Rose Java Fundamentals (Comments, Variables, etc.)
Hello.java Program Output 1 public class Hello { 2 public static void main( String [] args ) 3 { 4 System.out.println( “Hello!" ); 5 } // end method main.
망고 100 보드로 놀아보자 -18 Android 메뉴 생성 및 아이콘 생성 (SPDIF,WM8960)
9-1 JXTA Discovery Learning Objectives This module will help you... – Understand how JXTA advertisements are published, cached, and.
Android JNI and JAR Library JNI Library 1. JNI *.c sources file must include jni header file jni.h #include 2. In Make file CFLAGS must add -I $(NDK_INC)/
Dynamic Architectures (Component Reconfiguration) with Fractal.
Instructor: Alexander Stoytchev CprE 185: Intro to Problem Solving (using C)
@2010 Mihail L. Sichitiu1 Android Introduction Hello Threads.
1 Command Processor II. 2 Command Processor Example Let's look at a simple example of a command processor using states and cities. Get initial information.
NetTech Solutions Common Connectivity Problems Lesson Eight.
CISCO NETWORKING ACADEMY Chabot College ELEC Windows IP Configuration Information.
Recursive Objects (Part 2) 1. Adding to the front of the list  adding to the front of the list  t.addFirst('z') or t.add(0, 'z') 2 'a' 'x' LinkedList.
Quick Review of OOP Constructs Classes:  Data types for structured data and behavior  fields and methods Objects:  Variables whose data type is a class.
© 2009 IBM Corporation Tianhong Wang 2012/06/28 Android’s udev —— Vold.
Written by: Dr. JJ Shepherd
1 Advanced Programming Examples Output. Show the exact output produced by the following code segment. char[,] pic = new char[6,6]; for (int i = 0; i
Custom Widget 2 UNIT 27 로봇 SW 콘텐츠 교육원 조용수. 학습 목표 Custom Widget –Canvas 를 이용하여 Custom Widget 을 만든다. 2.
Connection Pooling 2001/4/3 Kang Seungwoo. Connection Pooling Database Connection cost is very high Connection Pool DB 와 연결된 여러 개의 Connection 객체를 미리 확보.
Int fact (int n) { If (n == 0) return 1; else return n * fact (n – 1); } 5 void main () { Int Sum; : Sum = fact (5); : } Factorial Program Using Recursion.
Chapter 11: Threaded Programs Situations where the program is following multiple execution paths (how to stop one?) Thread: a line of execution Thread.
Introduction to Java Programming by Laurie Murphy Revised 09/08/2016.
OIC Open Source Work Group. 1 Architecture IoTivity v1.0 CA API CA Control Network Config. Network Config. CoAP Protocol CoAP Protocol Interface Controller.
Content Coverity Static Analysis Use cases of Coverity Examples
Chapter 7-Android HAL 中国科学技术大学软件学院.
Lecture 2: Data Types, Variables, Operators, and Expressions
University of Central Florida COP 3330 Object Oriented Programming
Android Introduction Camera.
Reserved Words.
null, true, and false are also reserved.
Introduction to Java Programming
An overview of Java, Data types and variables
Instructor: Alexander Stoytchev
Units with – James tedder
Units with – James tedder
Java Decompiler.
JavaScript Reserved Words
Instructor: Alexander Stoytchev
Introduction to Static Analyzer
Module 2 - Part 1 Variables, Assignment, and Data Types
Programming Language C Language.
Instructor: Alexander Stoytchev
Service Services.
Character Arrays char string1[] = “first”;
Agenda Types and identifiers Practice Assignment Keywords in Java
Presentation transcript:

망고100 보드로 놀아보자-19 Android Ethernet 분석 http://cafe.naver.com/embeddedcrazyboys http://www.mangoboard.com

Android Activity Lifecycle

안드로이드 Ethernet Config 추가

안드로이드 Ethernet Config 추가

Setting.xml 과 IconPreferenceScreen <com.android.settings.IconPreferenceScreen android:title="@string/eth_radio_ctrl_title" settings:icon="@drawable/ic_settings_ethernet"> <intent android:action="android.intent.action.MAIN" android:targetPackage="com.android.settings" android:targetClass="com.android.settings.EthernetSettings" /> </com.android.settings.IconPreferenceScreen>

XML과 EthernetSettings class관계 <com.android.settings.IconPreferenceScreen android:title="@string/eth_radio_ctrl_title" settings:icon="@drawable/ic_settings_ethernet"> <intent android:action="android.intent.action.MAIN" android:targetPackage="com.android.settings" android:targetClass="com.android.settings.EthernetSettings" /> </com.android.settings.IconPreferenceScreen>

Ethernet Service 초기화 (EthernetManager) getSystemService(ETH_SERVICE), ./packages/apps/Settings/src/com/android/settings/EthernetSettings.java }else if (ETH_SERVICE.equals(name)) { return getEthernetManager(); ./frameworks/base/core/java/android/app/ApplicationContext.java private EthernetManager getEthernetManager() { synchronized (sSync) { if (sEthManager == null) { IBinder b = ServiceManager.getService(ETH_SERVICE); IEthernetManager service = IEthernetManager.Stub.asInterface(b); sEthManager = new EthernetManager(service, mMainThread.getHandler()); ./frameworks/base/core/java/android/app/ApplicationContext.java

Service Manager Ethernet 등록 private EthernetManager getEthernetManager() { synchronized (sSync) { if (sEthManager == null) { IBinder b = ServiceManager.getService(ETH_SERVICE); IEthernetManager service = IEthernetManager.Stub.asInterface(b); sEthManager = new EthernetManager(service, mMainThread.getHandler()); ./frameworks/base/core/java/android/app/ApplicationContext.java Connectivity service에서 등록 private ConnectivityService(Context context) { …. ServiceManager.addService(Context.ETH_SERVICE, ethService); ./frameworks/base/services/java/com/android/server/ConnectivityService.java

CONNECTIVITY_SERVICE Service Manager 역할 Service manager POWER_SERVICE ETH_SERVICE … CONNECTIVITY_SERVICE

Connectivity Service Connectivity service wifi mms …. ethernet

Ethernet service (부팅 시) private ConnectivityService(Context context) { if (DBG) Log.v(TAG, "ConnectivityService starting up"); if (DBG) Log.v(TAG, "Starting Ethernet Service"); mEthernetStateTracker = new EthernetStateTracker(context,mHandler); EthernetService ethService = new EthernetService(context, mEthernetStateTracker); ServiceManager.addService(Context.ETH_SERVICE, ethService); mNetTrackers[ConnectivityManager.TYPE_ETH] = mEthernetStateTracker;

Ethernet service (부팅 시) super는 자손클래스에서 조상클래스로부터 상속받은 멤버를 참조하는데 사용되는 참조변수 public EthernetStateTracker(Context context, Handler target) { super(context, target, ConnectivityManager.TYPE_ETH, 0, "ETH", ""); Log.i(TAG,"Starts..."); if(EthernetNative.initEthernetNative() != 0 ) { Log.e(TAG,"Can not init ethernet device layers"); return; }

Ethernet service (부팅 시) static JNINativeMethod gEthernetMethods[] = { {"waitForEvent", "()Ljava/lang/String;“, (void *)android_net_ethernet_waitForEvent}, {"getInterfaceName", "(I)Ljava/lang/String;“, void )android_net_ethernet_getInterfaceName}, {"initEthernetNative", "()I“, (void *)android_net_ethernet_initEthernetNative}, {"getInterfaceCnt","()I“, (void *)android_net_ethernet_getInterfaceCnt} }; static jint android_net_ethernet_initEthernetNative(JNIEnv *env, jobject clazz) { if ((ret = netlink_init_interfaces_list()) < 0) {

Ethernet service (부팅 시) static int netlink_init_interfaces_list(void) { .. if ((netdir = opendir(SYSFS_CLASS_NET)) != NULL) { while((de = readdir(netdir))!=NULL) { snprintf(path, SYSFS_PATH_MAX,"%s/%s/ifindex",SYSFS_CLASS_NET,de->d_name); if ((ifidx = fopen(path,"r")) != NULL ) { static const char SYSFS_CLASS_NET[] = "/sys/class/net";

Ethernet service (부팅 시)

Ethernet Service 등록 Flow private ConnectivityService(Context context) { … if (DBG) Log.v(TAG, "Starting Ethernet Service"); mEthernetStateTracker = new EthernetStateTracker(context,mHandler); EthernetService ethService = new EthernetService(context, mEthernetStateTracker); public EthernetService(Context context, EthernetStateTracker Tracker){ mTracker = Tracker; mContext = context; isEthEnabled = getPersistedState(); Log.i(TAG,"Ethernet dev enabled " + isEthEnabled ); getDeviceNameList(); setEthState(isEthEnabled); Log.i(TAG, "Trigger the ethernet monitor"); mTracker.StartPolling(); }

Ethernet Service 등록 Flow(계속) public EthernetService(Context context, EthernetStateTracker Tracker){ … getDeviceNameList(); } public String[] getDeviceNameList() { if (scanEthDevice() > 0 ) return DevName; else return null; }

Ethernet Service 등록 Flow(계속) private int scanEthDevice() { int i = 0,j; if ((i = EthernetNative.getInterfaceCnt()) != 0) { Log.i(TAG, "total found "+i+ " net devices"); DevName = new String[i]; } else return i; for (j = 0; j < i; j++) { DevName[j] = EthernetNative.getInterfaceName(j); if (DevName[j] == null) break; Log.i(TAG,"device " + j + " name " + DevName[j]);

Ethernet Service 등록 Flow(계속) static jint android_net_ethernet_getInterfaceCnt() { return total_int; } static jint android_net_ethernet_initEthernetNative(JNIEnv *env, jobject clazz) netlink_init_interfaces_list() LOGI("interface %s:%d found",intfinfo->name,intfinfo->i); add_int_to_list(intfinfo);//에서 total_int ++

Ethernet Service 등록 Flow(계속) static jstring android_net_ethernet_getInterfaceName(JNIEnv *env, jobject clazz, jint index) { info= interfaces; if (total_int != 0 && index <= (total_int -1)) { while (info != NULL) { if (index == i) { LOGI("Found :%s",info->name); return env->NewStringUTF(info->name); } static jint android_net_ethernet_initEthernetNative(JNIEnv *env, jobject clazz) netlink_init_interfaces_list() LOGI("interface %s:%d found",intfinfo->name,intfinfo->i); add_int_to_list(intfinfo);//에서 Node 생성

Ethernet Event 처리 쓰레드 생성 public EthernetService(Context context, EthernetStateTracker Tracker){ Log.i(TAG, "Trigger the ethernet monitor"); mTracker.StartPolling(); 쓰레드 생성 static jstring android_net_ethernet_waitForEvent(JNIEnv *env, jobject clazz) {

EthernetStateTracker 이더넷이 연결된 경우(DHCP) MonitorThread EthernetMonitor EthernetStateTracker ConnectivityService

이더넷이 연결된 경우(DHCP) static jstring android_net_ethernet_waitForEvent(JNIEnv *env, jobject clazz) { if((len = recvmsg(nl_socket_poll, &msg, 0))>= 0) { MonitorThread.run . } else if (cmd == NEW_LINK) { event = PHYUP; handleEvent(events[i],event);

이더넷이 연결된 경우(DHCP) void handleEvent(String ifname,int event) { switch (event) { case PHYUP: mTracker.notifyPhyConnected(ifname);); break; public void notifyPhyConnected(String ifname) { if synchronized(this) { this.sendEmptyMessage(EVENT_HW_PHYCONNECTED); MonitorThread

이더넷이 연결된 경우(DHCP) public void handleMessage(Message msg) { .. case EVENT_HW_PHYCONNECTED: try { configureInterface(info); } private boolean configureInterface(EthernetDevInfo info) throws UnknownHostException { if (info.getConnectMode().equals(EthernetDevInfo.ETH_CONN_MODE_DHCP)) { mDhcpTarget.sendEmptyMessage(EVENT_DHCP_START); DHCP Handler

이더넷이 연결된 경우(DHCP) public void handleMessage(Message msg) { .. switch (msg.what) { case EVENT_DHCP_START: if (NetworkUtils.runDhcp(mInterfaceName, mDhcpInfo)) {} static jboolean android_net_utils_runDhcp(JNIEnv* env, jobject clazz, jstring ifname, jobject info) { result = ::dhcp_do_request(nameStr, &ipaddr, &gateway, &mask, &dns1, &dns2, &server, &lease);