From 8daf38a7195b4e366d6346d8c041817169cef0b9 Mon Sep 17 00:00:00 2001 From: Wenting Xiong Date: Tue, 7 Feb 2017 19:12:27 +0800 Subject: [PATCH] DO NOT MERGE. SystemUI: Display RAT icon when data is off Introduce customization and implementation to display RAT icon in status bar even when data is off. Since some carriers require, this feature is necessary. Test: Test with simulated RIL Bug: 28805511 Change-Id: I412a407b8bcfeb9b3caf265bc7e0331a88433725 --- .../policy/MobileSignalController.java | 5 ++--- .../policy/NetworkControllerImpl.java | 20 +++++++++++++++++++ .../policy/NetworkControllerDataTest.java | 15 ++++++++++++++ .../telephony/CarrierConfigManager.java | 7 +++++++ 4 files changed, 44 insertions(+), 3 deletions(-) diff --git a/packages/SystemUI/src/com/android/systemui/statusbar/policy/MobileSignalController.java b/packages/SystemUI/src/com/android/systemui/statusbar/policy/MobileSignalController.java index 03c46e8b37263..024c1a089ef26 100644 --- a/packages/SystemUI/src/com/android/systemui/statusbar/policy/MobileSignalController.java +++ b/packages/SystemUI/src/com/android/systemui/statusbar/policy/MobileSignalController.java @@ -223,8 +223,7 @@ public class MobileSignalController extends SignalController< String contentDescription = getStringIfExists(getContentDescription()); String dataContentDescription = getStringIfExists(icons.mDataContentDescription); - final boolean dataDisabled = mCurrentState.iconGroup == TelephonyIcons.DATA_DISABLED - && mCurrentState.userSetup; + final boolean dataDisabled = isDataDisabled() && mCurrentState.userSetup; // Show icon in QS when we are connected or data is disabled. boolean showDataIcon = mCurrentState.dataConnected || dataDisabled; @@ -404,7 +403,7 @@ public class MobileSignalController extends SignalController< mCurrentState.roaming = isRoaming(); if (isCarrierNetworkChangeActive()) { mCurrentState.iconGroup = TelephonyIcons.CARRIER_NETWORK_CHANGE; - } else if (isDataDisabled()) { + } else if (isDataDisabled() && !mConfig.alwaysShowDataRatIcon) { mCurrentState.iconGroup = TelephonyIcons.DATA_DISABLED; } if (isEmergencyOnly() != mCurrentState.isEmergency) { diff --git a/packages/SystemUI/src/com/android/systemui/statusbar/policy/NetworkControllerImpl.java b/packages/SystemUI/src/com/android/systemui/statusbar/policy/NetworkControllerImpl.java index 2f7cd0033f4c8..dd1a4c5ed8c3e 100644 --- a/packages/SystemUI/src/com/android/systemui/statusbar/policy/NetworkControllerImpl.java +++ b/packages/SystemUI/src/com/android/systemui/statusbar/policy/NetworkControllerImpl.java @@ -28,7 +28,9 @@ import android.os.AsyncTask; import android.os.Bundle; import android.os.Handler; import android.os.Looper; +import android.os.PersistableBundle; import android.provider.Settings; +import android.telephony.CarrierConfigManager; import android.telephony.ServiceState; import android.telephony.SubscriptionInfo; import android.telephony.SubscriptionManager; @@ -219,6 +221,7 @@ public class NetworkControllerImpl extends BroadcastReceiver filter.addAction(ConnectivityManager.CONNECTIVITY_ACTION); filter.addAction(ConnectivityManager.INET_CONDITION_ACTION); filter.addAction(Intent.ACTION_AIRPLANE_MODE_CHANGED); + filter.addAction(CarrierConfigManager.ACTION_CARRIER_CONFIG_CHANGED); mContext.registerReceiver(this, filter, null, mReceiverHandler); mListening = true; @@ -396,6 +399,14 @@ public class NetworkControllerImpl extends BroadcastReceiver // emergency state. recalculateEmergency(); } + } else if (action.equals(CarrierConfigManager.ACTION_CARRIER_CONFIG_CHANGED)) { + mConfig = Config.readConfig(mContext); + mReceiverHandler.post(new Runnable() { + @Override + public void run() { + handleConfigurationChanged(); + } + }); } else { int subId = intent.getIntExtra(PhoneConstants.SUBSCRIPTION_KEY, SubscriptionManager.INVALID_SUBSCRIPTION_ID); @@ -904,6 +915,7 @@ public class NetworkControllerImpl extends BroadcastReceiver boolean show4gForLte = false; boolean hideLtePlus = false; boolean hspaDataDistinguishable; + boolean alwaysShowDataRatIcon = false; static Config readConfig(Context context) { Config config = new Config(); @@ -916,6 +928,14 @@ public class NetworkControllerImpl extends BroadcastReceiver config.hspaDataDistinguishable = res.getBoolean(R.bool.config_hspa_data_distinguishable); config.hideLtePlus = res.getBoolean(R.bool.config_hideLtePlus); + + CarrierConfigManager configMgr = (CarrierConfigManager) + context.getSystemService(Context.CARRIER_CONFIG_SERVICE); + PersistableBundle b = configMgr.getConfig(); + if (b != null) { + config.alwaysShowDataRatIcon = b.getBoolean( + CarrierConfigManager.KEY_ALWAYS_SHOW_DATA_RAT_ICON_BOOL); + } return config; } } diff --git a/packages/SystemUI/tests/src/com/android/systemui/statusbar/policy/NetworkControllerDataTest.java b/packages/SystemUI/tests/src/com/android/systemui/statusbar/policy/NetworkControllerDataTest.java index fce1172ff6251..93e1e6ca8af85 100644 --- a/packages/SystemUI/tests/src/com/android/systemui/statusbar/policy/NetworkControllerDataTest.java +++ b/packages/SystemUI/tests/src/com/android/systemui/statusbar/policy/NetworkControllerDataTest.java @@ -110,6 +110,21 @@ public class NetworkControllerDataTest extends NetworkControllerBaseTest { verifyDataIndicators(0, 0); } + public void testAlwaysShowDataRatIcon() { + setupDefaultSignal(); + Mockito.when(mMockTm.getDataEnabled(mSubId)).thenReturn(false); + updateDataConnectionState(TelephonyManager.DATA_DISCONNECTED, + TelephonyManager.NETWORK_TYPE_GSM); + + // Switch to showing data RAT icon when data is diconnected + // and re-initialize the NetworkController. + mConfig.alwaysShowDataRatIcon = true; + mNetworkController.handleConfigurationChanged(); + + verifyDataIndicators(TelephonyIcons.DATA_G[1][0 /* No direction */], + TelephonyIcons.QS_DATA_G); + } + public void test4gDataIconConfigChange() { setupDefaultSignal(); updateDataConnectionState(TelephonyManager.DATA_CONNECTED, diff --git a/telephony/java/android/telephony/CarrierConfigManager.java b/telephony/java/android/telephony/CarrierConfigManager.java index 8800f8e67d353..8cae5b1fe5f5d 100644 --- a/telephony/java/android/telephony/CarrierConfigManager.java +++ b/telephony/java/android/telephony/CarrierConfigManager.java @@ -828,6 +828,12 @@ public class CarrierConfigManager { public static final String KEY_STK_DISABLE_LAUNCH_BROWSER_BOOL = "stk_disable_launch_browser_bool"; + /** + * Boolean indicating if show data RAT icon on status bar even when data is disabled + * @hide + */ + public static final String KEY_ALWAYS_SHOW_DATA_RAT_ICON_BOOL = + "always_show_data_rat_icon_bool"; // These variables are used by the MMS service and exposed through another API, {@link // SmsManager}. The variable names and string values are copied from there. @@ -1480,6 +1486,7 @@ public class CarrierConfigManager { sDefaults.putInt(KEY_LTE_EARFCNS_RSRP_BOOST_INT, 0); sDefaults.putStringArray(KEY_BOOSTED_LTE_EARFCNS_STRING_ARRAY, null); sDefaults.putBoolean(KEY_DISABLE_VOICE_BARRING_NOTIFICATION_BOOL, false); + sDefaults.putBoolean(KEY_ALWAYS_SHOW_DATA_RAT_ICON_BOOL, false); } /**