Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit 63364fe2 authored by Wenting Xiong's avatar Wenting Xiong Committed by Toshiya Ikenaga
Browse files

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: I0428ba1749bdb884d210f1ff02cdf86b376a0ca8
parent e72b6f0d
Loading
Loading
Loading
Loading
+2 −2
Original line number Diff line number Diff line
@@ -300,7 +300,7 @@ public class MobileSignalController extends SignalController<
                && !mCurrentState.carrierNetworkChangeMode
                && mCurrentState.activityOut;
        showDataIcon &= mCurrentState.isDefault || dataDisabled;
        int typeIcon = showDataIcon ? icons.mDataType : 0;
        int typeIcon = (showDataIcon || mConfig.alwaysShowDataRatIcon) ? icons.mDataType : 0;
        callback.setMobileDataIndicators(statusIcon, qsIcon, typeIcon, qsTypeIcon,
                activityIn, activityOut, dataContentDescription, description, icons.mIsWide,
                mSubscriptionInfo.getSubscriptionId(), mCurrentState.roaming);
@@ -460,7 +460,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) {
+20 −0
Original line number Diff line number Diff line
@@ -29,7 +29,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.SignalStrength;
import android.telephony.SubscriptionInfo;
@@ -246,6 +248,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;

@@ -434,6 +437,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);
@@ -959,6 +970,7 @@ public class NetworkControllerImpl extends BroadcastReceiver
        boolean hideLtePlus = false;
        boolean hspaDataDistinguishable;
        boolean inflateSignalStrengths = false;
        boolean alwaysShowDataRatIcon = false;

        static Config readConfig(Context context) {
            Config config = new Config();
@@ -972,6 +984,14 @@ public class NetworkControllerImpl extends BroadcastReceiver
                    res.getBoolean(R.bool.config_hspa_data_distinguishable);
            config.hideLtePlus = res.getBoolean(R.bool.config_hideLtePlus);
            config.inflateSignalStrengths = res.getBoolean(R.bool.config_inflateSignalStrength);

            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;
        }
    }
+17 −0
Original line number Diff line number Diff line
@@ -142,6 +142,23 @@ public class NetworkControllerDataTest extends NetworkControllerBaseTest {
        verifyDataIndicators(0, 0);
    }

    @Test
    @Ignore("Flaky")
    public void testAlwaysShowDataRatIcon() {
        setupDefaultSignal();
        when(mMockTm.getDataEnabled(mSubId)).thenReturn(false);
        updateDataConnectionState(TelephonyManager.DATA_DISCONNECTED,
                TelephonyManager.NETWORK_TYPE_GSM);

        // Switch to showing data RAT icon when data is disconnected
        // and re-initialize the NetworkController.
        mConfig.alwaysShowDataRatIcon = true;
        mNetworkController.handleConfigurationChanged();

        verifyDataIndicators(TelephonyIcons.ICON_G,
                TelephonyIcons.QS_DATA_G);
    }

    @Test
    @Ignore("Flaky")
    public void test4gDataIconConfigChange() {
+7 −0
Original line number Diff line number Diff line
@@ -947,6 +947,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.
@@ -1925,6 +1931,7 @@ public class CarrierConfigManager {
        sDefaults.putStringArray(KEY_FEATURE_ACCESS_CODES_STRING_ARRAY, null);
        sDefaults.putBoolean(KEY_IDENTIFY_HIGH_DEFINITION_CALLS_IN_CALL_LOG_BOOL, false);
        sDefaults.putBoolean(KEY_SPN_DISPLAY_RULE_USE_ROAMING_FROM_SERVICE_STATE_BOOL, false);
        sDefaults.putBoolean(KEY_ALWAYS_SHOW_DATA_RAT_ICON_BOOL, false);
    }

    /**