[Android] Survey the Ethernet Support in Android-x86

最近花點時間看看 Android-x86 的 Ethernet 是怎麼去做的,透過 Android-x86 project 的實作,可以學到許多的內容,因為此 project 是以 Apache License, Version 2.0 方式釋出,所以開發者在基於授權內容的條件下,不用開源就可以任意修改、再散佈。下面是簡單的整理與解釋。

架構上可以分成三個層次,最上層是 Setttings UI 應用程式,然後是 Android Framework 及 Android Runtime,最後則是 Build System。Android Framework  及 Android Runtime 提供一些服務機制及低階操作,讓應用程式可以使用,配合 Settings UI 應用程式裡的實作方式。而 Building System 部份是針對部份編譯時期需要的設定檔作修改,以支援新加入的 Ethernet AIDL 檔案。Ethernet Setting Application 提供使用者可以設定網路,如 IP Address 或是 DNS 等。

This is a survey for supporting the Ethernet in Android.
The implementation refers to the Android-x86 project. You can obtain these files from the project and to modify the files for your use, because the project is released by Apache License, Version 2.0.
In this article, I give a simply illustration of where the files are added and modified.

The architecture can be simply divided into three regions – Android Framework, Settings Application, and Building System. The Android Framework provides the native service and low-level operations for Android application which is like Settings UI application. The Building System is just for supporting the action that adds the Ethernet AIDL interface. The Ethernet Setting Application is for user to enable or to disable the Ethernet interface. This application also provides the settings for user such as IP address, DNS, netmask, etc.

@ Android Framework & Android Runtime
– frameworks/base/ethernet/java/android/net/ethernet
EthernetDevInfo.aidl
EthernetDevInfo.java
EthernetManager.java
EthernetMonitor.java
EthernetNative.java
EthernetStateTracker.java
IEthernetManager.aidl

– frameworks/base/core/jni
android_net_ethernet.cpp
# Implement the Ethernet JNI methods

AndroidRuntime.cpp
# Register the EthernetManager JNI methods.
# extern int register_android_net_ethernet_EthernetManager(JNIEnv* env);

– frameworks/base/core/java/android/app
ContextImpl.java
# Create the EthernetManager for up-level application by getSystemService.
# getEthernetManager

– frameworks/base/core/java/android/provider
Settings.java
# Define the Ethernet settings for system such as ETHERNET_ON and ETHERNET_IP.

– frameworks/base/core/java/android/content
Context.java
# Define the Ethernet Service Symbol.
# public static final String ETHERNET_SERVICE = “ethernet”;

– frameworks/base/core/java/android/net
ConnectivityManager.java
# Define the connectivity type for system.
# public static final int TYPE_ETHERNET    = 7;

– frameworks/base/services/java/com/android/server
EthernetService.java
# Some Ethernet operations related with native JNI methods. It also implements the
# IEthernetManager interface.
# It also creates a EtherentMonitor to listen for Etherent-related events.

ConnectivityService.java
# Catch the Ethernet Service in “private ConnectivityService(Context context)” method.

– frameworks/base/services/java/com/android/server/status
StatusBarPolicy.java
# Handle the Ethernet actions for updating the Ethernet state.
# Ethernet States:
# EthernetStateTracker.EVENT_HW_CONNECTED
# EthernetStateTracker.EVENT_INTERFACE_CONFIGURATION_SUCCEEDED
# EthernetStateTracker.EVENT_HW_DISCONNECTED
# EthernetStateTracker.EVENT_INTERFACE_CONFIGURATION_FAILED

@ Ethernet Setting Application
– packages/apps/Settings
AndroidManifest.xml
# You should add the Ethernet Controls (three activities ) in this file.
# EthernetSettings, .ethernet.EthernetEnabler, .ethernet.EthernetConfigure

– packages/apps/Settings/src/com/android/settings
EthernetSettings.java
# The implementation of Ethernet Settings.

– packages/apps/Settings/src/com/android/settings/ethernet
EthernetConfigDialog.java
EthernetEnabler.java
EthernetLayer.java

– packages/apps/Settings/res/xml
ethernet_settings.xml
settings.xml

– packages/apps/Settings/res/layout
eth_configure.xml

– packages/apps/Settings/res/value
string.xml

@ Building System
– build/core
pathmap.mk
# Because the AIDL interface is implemented in the framework/base/ethernet directory, you have
# to add the ethernet directory item into FRAMEWORKS_BASE_SUBDIRS variable in the
# pathmap.mk.

發佈留言