[RK3399][Android7.1.1][4G]开机4G显示无信号,但是可以正常上网

测试平台

Platform: RK3399
OS: Android 7.1 /8.1

现象

机器开机4G显示无信号,但是可以正常上网。开关一次飞行模式后显示正常.

原因

通过排查代码由于4G加载的比较晚,而状态栏也没有监听TelephonyIntents.ACTION_SERVICE_STATE_CHANGED的广播,所以导致状态无法实时更新.

解决办法

Android7.1.1:

diff --git a/frameworks/base/packages/SystemUI/src/com/android/systemui/statusbar/policy/MobileSignalController.java b/frameworks/base/packages/SystemUI/src/com/android/systemui/statusbar/policy/MobileSignalController.java
index 03c46e8b37..694599206e 100644
--- a/frameworks/base/packages/SystemUI/src/com/android/systemui/statusbar/policy/MobileSignalController.java
+++ b/frameworks/base/packages/SystemUI/src/com/android/systemui/statusbar/policy/MobileSignalController.java
@@ -316,8 +316,16 @@ public class MobileSignalController extends SignalController<
         } else if (action.equals(TelephonyIntents.ACTION_DEFAULT_DATA_SUBSCRIPTION_CHANGED)) {
             updateDataSim();
             notifyListenersIfNecessary();
-        }
-    }
+        }else if(action.equals(TelephonyIntents.ACTION_SERVICE_STATE_CHANGED)){
+                        ServiceState mLastServiceState = ServiceState.newFromBundle(intent.getExtras());
+
+                        if(mLastServiceState != null && (mServiceState == null || mServiceState.getVoiceRegState() != mLastServiceState.getVoiceRegState())){
+                                        //Log.v(TAG,"handleBroadcast mLastServiceState:"+mLastServiceState.getVoiceRegState());
+                               mServiceState = mLastServiceState;
+                                       updateTelephony();
+                       }
+               }
+       }
 
     private void updateDataSim() {
         int defaultDataSub = mDefaults.getDefaultDataSubId();

diff --git a/frameworks/base/packages/SystemUI/src/com/android/systemui/statusbar/policy/NetworkControllerImpl.java b/frameworks/base/packages/SystemUI/src/com/android/systemui/statusbar/policy/NetworkControllerImpl.java
index 622595f765..2fd0cce8ed 100644
--- a/frameworks/base/packages/SystemUI/src/com/android/systemui/statusbar/policy/NetworkControllerImpl.java
+++ b/frameworks/base/packages/SystemUI/src/com/android/systemui/statusbar/policy/NetworkControllerImpl.java
@@ -396,6 +396,11 @@ public class NetworkControllerImpl extends BroadcastReceiver
                 // emergency state.
                 recalculateEmergency();
             }
+                       
+                       for (MobileSignalController controller : mMobileSignalControllers.values()) {
+                                       controller.handleBroadcast(intent);
+                       }
+
         } else {
             int subId = intent.getIntExtra(PhoneConstants.SUBSCRIPTION_KEY,
                     SubscriptionManager.INVALID_SUBSCRIPTION_ID);

Android8.1:

diff --git a/frameworks/base/packages/SystemUI/src/com/android/systemui/statusbar/policy/MobileSignalController.java b/frameworks/base/packages/SystemUI/src/com/android/systemui/statusbar/policy/MobileSignalController.java
index 03c46e8b37..694599206e 100644
--- a/frameworks/base/packages/SystemUI/src/com/android/systemui/statusbar/policy/MobileSignalController.java
+++ b/frameworks/base/packages/SystemUI/src/com/android/systemui/statusbar/policy/MobileSignalController.java
@@ -316,8 +316,16 @@ public class MobileSignalController extends SignalController<
         } else if (action.equals(TelephonyIntents.ACTION_DEFAULT_DATA_SUBSCRIPTION_CHANGED)) {
             updateDataSim();
             notifyListenersIfNecessary();
-        }
-    }
+        }else if(action.equals(TelephonyIntents.ACTION_SERVICE_STATE_CHANGED)){
+                        ServiceState mLastServiceState = ServiceState.newFromBundle(intent.getExtras());
+
+                        if(mLastServiceState != null && (mServiceState == null || mServiceState.getVoiceRegState() != mLastServiceState.getVoiceRegState())){
+                                        //Log.v(TAG,"handleBroadcast mLastServiceState:"+mLastServiceState.getVoiceRegState());
+                               mServiceState = mLastServiceState;
+                                       updateTelephony();
+                       }
+               }
+       }
 
     private void updateDataSim() {
         int defaultDataSub = mDefaults.getDefaultDataSubId();

diff --git a/frameworks/base/packages/SystemUI/src/com/android/systemui/statusbar/policy/NetworkControllerImpl.java b/frameworks/base/packages/SystemUI/src/com/android/systemui/statusbar/policy/NetworkControllerImpl.java
index 622595f765..2fd0cce8ed 100644
--- a/frameworks/base/packages/SystemUI/src/com/android/systemui/statusbar/policy/NetworkControllerImpl.java
+++ b/frameworks/base/packages/SystemUI/src/com/android/systemui/statusbar/policy/NetworkControllerImpl.java
@@ -396,6 +396,11 @@ public class NetworkControllerImpl extends BroadcastReceiver
                 // emergency state.
                 recalculateEmergency();
             }
+                       
+                       for (MobileSignalController controller : mMobileSignalControllers.values()) {
+                                       controller.handleBroadcast(intent);
+                       }
+
         } else {
             int subId = intent.getIntExtra(PhoneConstants.SUBSCRIPTION_KEY,
                     SubscriptionManager.INVALID_SUBSCRIPTION_ID);

你可能感兴趣的:(Android)