[RK3399][Android7.1-tvbox] Ethernet:机器通过交换机连接路由器,重启路由器后,机器无法获取ip的问题

测试平台

Platform: RK3399
OS: Android 7.1.1

现象

机器通过交换机连接路由器,重启路由器后,机器无法获取ip的问题

解决方案

commit 14d08d038eb19fca308970e5bbca5d7c26790303
Author: lkd <service@t-firefly.com>
Date:   Wed Apr 18 10:55:49 2018 +0800

    Android->eth: when callback IpReachabilityMonitor, notify reset ethernet

diff --git a/frameworks/base/services/net/java/android/net/ip/IpManager.java b/frameworks/base/services/net/java/android/net/ip/IpManager.java
index 35d2870..53e91e2 100755
--- a/frameworks/base/services/net/java/android/net/ip/IpManager.java
+++ b/frameworks/base/services/net/java/android/net/ip/IpManager.java
@@ -144,6 +144,7 @@ public class IpManager extends StateMachine {
         @Override
         public void onProvisioningSuccess(LinkProperties newLp) {
             synchronized (this) {
+                Log.d("sjfn", "onProvisioningSuccess");
                 mCallbackLinkProperties = newLp;
                 notify();
             }
@@ -152,6 +153,7 @@ public class IpManager extends StateMachine {
         @Override
         public void onProvisioningFailure(LinkProperties newLp) {
             synchronized (this) {
+                Log.d("sjfn", "onProvisioningFailure");
                 mCallbackLinkProperties = null;
                 notify();
             }
@@ -436,6 +438,7 @@ public class IpManager extends StateMachine {
 
         mContext = context;
         mInterfaceName = ifName;
+        Log.v("sjfn","mInterfaceName:"+mInterfaceName);
         mClatInterfaceName = CLAT_PREFIX + ifName;
         mCallback = new LoggingCallbackWrapper(callback);
         mNwService = nwService;
@@ -1048,7 +1051,10 @@ public class IpManager extends StateMachine {
                     new IpReachabilityMonitor.Callback() {
                         @Override
                         public void notifyLost(InetAddress ip, String logMsg) {
+                            Log.v("sjfn","notifyLost:"+logMsg);
                             mCallback.onReachabilityLost(logMsg);
+                            Log.v("sjfn","mInterfaceName:"+mInterfaceName+",mClatInterfaceName:"+mClatInterfaceName);
+                            stopAllIP();
                         }
                     },
                     mAvoidBadWifiTracker);
diff --git a/frameworks/base/services/net/java/android/net/ip/IpReachabilityMonitor.java b/frameworks/base/services/net/java/android/net/ip/IpReachabilityMonitor.java
index a6bb40c..afc0ec9 100644
--- a/frameworks/base/services/net/java/android/net/ip/IpReachabilityMonitor.java
+++ b/frameworks/base/services/net/java/android/net/ip/IpReachabilityMonitor.java
@@ -135,8 +135,8 @@ import java.util.Set;
  */
 public class IpReachabilityMonitor {
     private static final String TAG = "IpReachabilityMonitor";
-    private static final boolean DBG = false;
-    private static final boolean VDBG = false;
+    private static final boolean DBG = true;
+    private static final boolean VDBG = true;
 
     public interface Callback {
         // This callback function must execute as quickly as possible as it is
diff --git a/frameworks/opt/net/ethernet/java/com/android/server/ethernet/EthernetNetworkFactory.java b/frameworks/opt/net/ethernet/java/com/android/server/ethernet/EthernetNetworkFactory.java
index d6050aa..6d4c3e9 100755
--- a/frameworks/opt/net/ethernet/java/com/android/server/ethernet/EthernetNetworkFactory.java
+++ b/frameworks/opt/net/ethernet/java/com/android/server/ethernet/EthernetNetworkFactory.java
@@ -495,6 +495,8 @@ class EthernetNetworkFactory {
                         @Override
                         public void onLinkPropertiesChange(LinkProperties newLp) {
                             Log.d(TAG, "onLinkPropertiesChange: lp = " + newLp);
+
+                            Log.d("sjfn", "onLinkPropertiesChange: lp = " + newLp);
                             synchronized(EthernetNetworkFactory.this) {
                                 if (mNetworkAgent != null && mNetworkInfo.isConnected()) {
                                     mLinkProperties = newLp;
@@ -502,6 +504,15 @@ class EthernetNetworkFactory {
                                 }
                             }
                         }
+
+                        @Override
+                        public void onProvisioningFailure(LinkProperties newLp) {
+                            Log.d("sjfn", "onProvisioningFailure: lp = " + newLp);
+                            synchronized(EthernetNetworkFactory.this) {
+                                setInterfaceDown();
+                                setInterfaceUp();
+                            }
+                        }
                     };
 
                     synchronized(EthernetNetworkFactory.this) {


你可能感兴趣的:(Android)