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

Commit c9b56254 authored by TreeHugger Robot's avatar TreeHugger Robot Committed by Android (Google) Code Review
Browse files

Merge "Update show4GForLTE config"

parents d717790c 9588d2af
Loading
Loading
Loading
Loading
+0 −57
Original line number Diff line number Diff line
/*
 * Copyright (C) 2018 The Android Open Source Project
 *
 * Licensed under the Apache License, Version 2.0 (the "License");
 * you may not use this file except in compliance with the License.
 * You may obtain a copy of the License at
 *
 *      http://www.apache.org/licenses/LICENSE-2.0
 *
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS,
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 * See the License for the specific language governing permissions and
 * limitations under the License.
 */

package com.android.settings.network.telephony;

import androidx.preference.Preference;
import androidx.preference.PreferenceFragmentCompat;
import androidx.preference.PreferenceScreen;

import com.android.settings.R;

/**
 * List of Phone-specific settings screens.
 */
public class CdmaOptions {
    private static final String LOG_TAG = "CdmaOptions";

    private static final String BUTTON_CDMA_SYSTEM_SELECT_KEY = "cdma_system_select_key";
    private static final String BUTTON_CDMA_SUBSCRIPTION_KEY = "cdma_subscription_key";

    private PreferenceFragmentCompat mPrefFragment;

    public CdmaOptions(PreferenceFragmentCompat prefFragment, PreferenceScreen prefScreen,
            int subId) {
        mPrefFragment = prefFragment;
    }

    public boolean preferenceTreeClick(Preference preference) {
        //TODO(b/114749736): handle it in preferenceController and remove this file
        if (preference.getKey().equals(BUTTON_CDMA_SYSTEM_SELECT_KEY)) {
            log("preferenceTreeClick: return BUTTON_CDMA_ROAMING_KEY true");
            return true;
        }
        if (preference.getKey().equals(BUTTON_CDMA_SUBSCRIPTION_KEY)) {
            log("preferenceTreeClick: return CDMA_SUBSCRIPTION_KEY true");
            return true;
        }
        return false;
    }

    protected void log(String s) {
        android.util.Log.d(LOG_TAG, s);
    }
}
+6 −7
Original line number Diff line number Diff line
@@ -45,7 +45,8 @@ public class EnabledNetworkModePreferenceController extends BasePreferenceContro
    private PersistableBundle mPersistableBundle;
    private int mSubId;
    private boolean mIsGlobalCdma;
    private boolean mShow4GForLTE;
    @VisibleForTesting
    boolean mShow4GForLTE;

    public EnabledNetworkModePreferenceController(Context context, String key) {
        super(context, key);
@@ -111,12 +112,10 @@ public class EnabledNetworkModePreferenceController extends BasePreferenceContro
                mTelephonyManager.getLteOnCdmaMode() == PhoneConstants.LTE_ON_CDMA_TRUE;
        mIsGlobalCdma = isLteOnCdma
                && mPersistableBundle.getBoolean(CarrierConfigManager.KEY_SHOW_CDMA_CHOICES_BOOL);
        initShow4GForLTE();
    }

    @VisibleForTesting
    void initShow4GForLTE() {
        mShow4GForLTE = MobileNetworkUtils.isShow4GForLTE(mContext);
        mShow4GForLTE = mPersistableBundle != null
                ? mPersistableBundle.getBoolean(
                CarrierConfigManager.KEY_SHOW_4G_FOR_LTE_DATA_ICON_BOOL)
                : false;
    }

    private int getPreferredNetworkMode() {
+0 −13
Original line number Diff line number Diff line
@@ -386,19 +386,6 @@ public class MobileNetworkUtils {
        return false;
    }

    public static boolean isShow4GForLTE(Context context) {
        //TODO(b/117882862): move this to framework
        try {
            Context con = context.createPackageContext("com.android.systemui", 0);
            int id = con.getResources().getIdentifier("config_show4GForLTE",
                    "bool", "com.android.systemui");
            return con.getResources().getBoolean(id);
        } catch (PackageManager.NameNotFoundException e) {
            Log.e(TAG, "NameNotFoundException for show4GFotLTE");
            return false;
        }
    }

    /**
     * Return {@code true} if Tdscdma is supported in current subscription
     */
+11 −3
Original line number Diff line number Diff line
@@ -23,7 +23,6 @@ import static com.google.common.truth.Truth.assertThat;

import static org.mockito.ArgumentMatchers.anyInt;
import static org.mockito.ArgumentMatchers.anyString;
import static org.mockito.Mockito.doNothing;
import static org.mockito.Mockito.doReturn;
import static org.mockito.Mockito.spy;

@@ -80,8 +79,7 @@ public class EnabledNetworkModePreferenceControllerTest {
        mPreference = new ListPreference(mContext);
        mPreference.setEntries(R.array.enabled_networks_choices);
        mPreference.setEntryValues(R.array.enabled_networks_values);
        mController = spy(new EnabledNetworkModePreferenceController(mContext, "enabled_network"));
        doNothing().when(mController).initShow4GForLTE();
        mController = new EnabledNetworkModePreferenceController(mContext, "enabled_network");
        mController.init(SUB_ID);
        mPreference.setKey(mController.getPreferenceKey());
    }
@@ -103,6 +101,16 @@ public class EnabledNetworkModePreferenceControllerTest {
        assertThat(mController.getAvailabilityStatus()).isEqualTo(AVAILABLE);
    }

    @Test
    public void init_initShow4GForLTE() {
        mPersistableBundle.putBoolean(CarrierConfigManager.KEY_SHOW_4G_FOR_LTE_DATA_ICON_BOOL,
                true);

        mController.init(SUB_ID);

        assertThat(mController.mShow4GForLTE).isTrue();
    }

    @Test
    public void updateState_updateByNetworkMode() {
        Settings.Global.putInt(mContext.getContentResolver(),