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

Commit 51814935 authored by Lei Yu's avatar Lei Yu Committed by Android (Google) Code Review
Browse files

Merge changes I7a0845c0,I45ecbc86,I3d0203b7,I7cfc27ff

* changes:
  Refactor DataUsagePreference
  Refactor carrier settings
  Refactor CdmaApnPreference
  Refactor CdmaSubscriptionListPreference
parents c496feec 5680477b
Loading
Loading
Loading
Loading
+3 −0
Original line number Diff line number Diff line
@@ -10259,6 +10259,9 @@
    <!-- Mobile network settings screen, message asking the user to check their pricing with their Carrier, when enabling Data roaming. [CHAR LIMIT=NONE] -->
    <string name="roaming_check_price_warning">Check with your network provider for pricing.</string>
    <!-- Title for mobile data preference, to display the mobile data usage for each app. [CHAR LIMIT=NONE]-->
    <string name="mobile_data_usage_title">App data usage</string>
    <!-- Available networks screen, summary when button disallowed due to permanent automatic mode [CHAR LIMIT=NONE] -->
    <string name="manual_mode_disallowed_summary">Unavailable when connected to <xliff:g id="carrier" example="verizon">%1$s</xliff:g></string>
</resources>

res/xml/cdma_options.xml

deleted100644 → 0
+0 −45
Original line number Diff line number Diff line
<?xml version="1.0" encoding="utf-8"?>
<!--
    Copyright (C) 2008 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.
-->

<PreferenceScreen xmlns:android="http://schemas.android.com/apk/res/android">

    <com.android.settings.network.telephony.CdmaSubscriptionListPreference
        android:key="cdma_subscription_key"
        android:title="@string/cdma_subscription_title"
        android:summary="@string/cdma_subscription_summary"
        android:entries="@array/cdma_subscription_choices"
        android:entryValues="@array/cdma_subscription_values"
        android:dialogTitle="@string/cdma_subscription_dialogtitle" />

    <!--We want separate APN setting from reset of settings because-->
    <!--we want user to change it with caution.-->
    <PreferenceCategory
        android:key="category_cdma_apn_key">
        <!-- The launching Intent will be defined thru code as we need to pass some Extra -->
        <com.android.settingslib.RestrictedPreference
            android:key="button_cdma_apn_key"
            android:title="@string/apn_settings"
            android:persistent="false"/>
    </PreferenceCategory>

    <Preference
        android:key="carrier_settings_key"
        android:title="@string/carrier_settings_title">
        <!-- b/114749736, create a preference controller to build intent -->
    </Preference>

</PreferenceScreen>
+1 −1
Original line number Diff line number Diff line
@@ -27,7 +27,7 @@
            android:title="@string/select_automatically"
            android:persistent="false"/>

        <com.android.settings.mobilenetwork.NetworkSelectListPreference
        <com.android.settings.network.telephony.NetworkSelectListPreference
            android:key="button_network_select_key"
            android:title="@string/network_select_title"
            android:persistent="false"/>
+28 −2
Original line number Diff line number Diff line
@@ -38,9 +38,10 @@
        android:summaryOn="@string/roaming_enable"
        android:summaryOff="@string/roaming_disable"/>

    <com.android.settings.network.telephony.DataUsagePreference
    <Preference
        android:key="data_usage_summary"
        android:title="@string/data_usage_title" />
        android:title="@string/mobile_data_usage_title"
        settings:controller="com.android.settings.network.telephony.DataUsagePreferenceController"/>

    <SwitchPreference
        android:key="enhanced_4g_lte"
@@ -100,4 +101,29 @@
        android:dialogTitle="@string/cdma_system_select_dialogtitle"
        settings:controller="com.android.settings.network.telephony.cdma.CdmaSystemSelectPreferenceController"/>

    <ListPreference
        android:key="cdma_subscription_key"
        android:title="@string/cdma_subscription_title"
        android:summary="@string/cdma_subscription_summary"
        android:entries="@array/cdma_subscription_choices"
        android:entryValues="@array/cdma_subscription_values"
        android:dialogTitle="@string/cdma_subscription_dialogtitle"
        settings:controller="com.android.settings.network.telephony.cdma.CdmaSubscriptionPreferenceController"/>

    <!--We want separate APN setting from reset of settings because we want user to change it with caution-->
    <PreferenceCategory
        android:key="category_cdma_apn_key">
        <com.android.settingslib.RestrictedPreference
            android:key="button_cdma_apn_key"
            android:title="@string/apn_settings"
            android:persistent="false"
            settings:controller="com.android.settings.network.telephony.cdma.CdmaApnPreferenceController"/>
    </PreferenceCategory>

    <Preference
        android:key="carrier_settings_key"
        android:title="@string/carrier_settings_title"
        settings:controller="com.android.settings.network.telephony.CarrierPreferenceController">
    </Preference>

</PreferenceScreen>
+68 −0
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 android.content.Context;
import android.os.PersistableBundle;
import android.telephony.CarrierConfigManager;

import androidx.annotation.VisibleForTesting;
import androidx.preference.Preference;

import com.android.settings.core.BasePreferenceController;

/**
 * Preference controller for "Carrier Settings"
 */
public class CarrierPreferenceController extends BasePreferenceController {

    @VisibleForTesting
    CarrierConfigManager mCarrierConfigManager;
    private int mSubId;

    public CarrierPreferenceController(Context context, String key) {
        super(context, key);
        mCarrierConfigManager = new CarrierConfigManager(context);
    }

    public void init(int subId) {
        mSubId = subId;
    }

    @Override
    public int getAvailabilityStatus() {
        final PersistableBundle carrierConfig = mCarrierConfigManager.getConfigForSubId(mSubId);

        // Return available if it is in CDMA or GSM mode, and the flag is on
        return carrierConfig != null
                && carrierConfig.getBoolean(CarrierConfigManager.KEY_CARRIER_SETTINGS_ENABLE_BOOL)
                && (MobileNetworkUtils.isCdmaOptions(mContext, mSubId)
                || MobileNetworkUtils.isGsmOptions(mContext, mSubId))
                ? AVAILABLE
                : CONDITIONALLY_UNAVAILABLE;
    }

    @Override
    public boolean handlePreferenceTreeClick(Preference preference) {
        if (getPreferenceKey().equals(preference.getKey())) {
            //TODO(b/117651939): start carrier settings activity
            return true;
        }

        return false;
    }
}
Loading