How to set ethernet static IP in android 2.3?

キャンセル
次の結果を表示 
表示  限定  | 次の代わりに検索 
もしかして: 

How to set ethernet static IP in android 2.3?

ソリューションへジャンプ
7,915件の閲覧回数
DeanHuang
Contributor III

In adeneo 4.3 BSP (Android 2.3 for imx53 QSB), there is not this option in "Settings".

I had tried  a patch file for x86-android 2.3, but it has many compiling and symbol error.

Had anyone ever tried this?

ラベル(2)
0 件の賞賛
返信
1 解決策
2,931件の閲覧回数
DeanHuang
Contributor III

Weidong, Thanks.

I had done this feature according to android2.3-x86 ethernet patch

元の投稿で解決策を見る

0 件の賞賛
返信
6 返答(返信)
2,932件の閲覧回数
DeanHuang
Contributor III

Weidong, Thanks.

I had done this feature according to android2.3-x86 ethernet patch

0 件の賞賛
返信
2,931件の閲覧回数
weidong_sun
NXP TechSupport
NXP TechSupport

Hello,Dean,

     By default, we can't set static IP for ethernet on android platform. But android supplies SDK for user to realize it. we can add "Ethernet parameters setting" item in "Settings" menu, then load NetwokUtils and EthnetNative to set neccessary parameter.

     For more detailed information, you can look into the corresponding documnets and get more usages on your purpose.

Regards,

Weidong

0 件の賞賛
返信
2,931件の閲覧回数
DeanHuang
Contributor III

Hi Weidong,

we can add "Ethernet parameters setting" item in "Settings" menu, then load NetwokUtils and EthnetNative to set neccessary parameter.

Do you mean that we don't need to modify framework, and we just need to add a option in "Settings" or using other APKs to load NetwokUtils and EthnetNative?

BRs.

Dean

0 件の賞賛
返信
2,931件の閲覧回数
weidong_sun
NXP TechSupport
NXP TechSupport

Hello,Dean,

      I checked API in networkutils:

private native static boolean configureNative(

        String interfaceName, int ipAddress, int netmask, int gateway, int dns1, int dns2);

      I think if you load it in your setting program, static ip should be configured. I got a section of code from internet, but i didn't test, you can test it if it is OK:

ConnectivityManager mService = (ConnectivityManager) getSystemService(Context.CONNECTIVITY_SERVICE);

  EthernetManager mEthManager = (EthernetManager) getSystemService(Context.ETHERNET_SERVICE);

  if(mEthManager.getState() == EthernetManager.ETHERNET_STATE_ENABLED) {

   EthernetDevInfo mInterfaceInfo = mEthManager.getSavedConfig();

   String mIp;

   String mMask;

   String mGw;

   String mDns;

   mIp = "192.168.0.118";

   mMask = "255.255.255.0";

   mGw = "192.168.0.1";

   mDns = "192.168.0.1";

   mInterfaceInfo.setConnectMode(EthernetDevInfo.ETHERNET_CONN_MODE_MANUAL);

   mInterfaceInfo.setIpAddress(mIp);

   mInterfaceInfo.setNetMask(mMask);

   mInterfaceInfo.setDnsAddr(mDns);

   mInterfaceInfo.setGateWay(mGw);

   try{

    mEthManager.updateDevInfo(mInterfaceInfo);

                                Thread.sleep(500);  

   }catch(Exception e){

    e.printStackTrace();

   }

                } else {

   Toast.makeText(this, "Ethernet state disabled!", 5000).show();

                }

Regards,

Weidong

2,931件の閲覧回数
DeanHuang
Contributor III

Hi Weidong,

     Thanks for your suggestion.

     I didn't test this yet, but Android source code seems to use networkutils.configureInteface() instead of networkutils.native(), right?

     According to your sample, you use updateDevInfo().

     Main flow is EthernetManager.updateDevInfo() -> EthernetService.updateDevInfo()  -> EthernetStateTracker.resetInterface() -> networkutils.configureInterface().


     But there is no these classes before doing ethernet patch. Can I use networkutils.configureInterface() directly?


0 件の賞賛
返信
2,931件の閲覧回数
weidong_sun
NXP TechSupport
NXP TechSupport

Hello,Dean,

      Yes, you can try. the above code I gave you is for android 4.0. not android 2.3. but you should find corresponding class in android 2.3 SDK.

Regards,

Weidong

0 件の賞賛
返信