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

Commit 9d9e9c66 authored by android-build-team Robot's avatar android-build-team Robot
Browse files

Snap for 5364434 from 2f92cf5b to qt-release

Change-Id: Id8f9ed83fff567004466c8dd1d3356cb8f503a0a
parents f04168d8 2f92cf5b
Loading
Loading
Loading
Loading
+0 −1
Original line number Diff line number Diff line
@@ -57,7 +57,6 @@ java_library {
    static_libs: [
        "telephony-protos",
        "ecc-protos-lite",
        "android-support-annotations",
    ],

    product_variables: {
+40 −37
Original line number Diff line number Diff line
@@ -45,7 +45,6 @@ import java.io.PrintWriter;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.List;
import java.util.concurrent.atomic.AtomicInteger;

/**
 * CarrierResolver identifies the subscription carrier and returns a canonical carrier Id
@@ -71,15 +70,15 @@ public class CarrierResolver extends Handler {
    private List<CarrierMatchingRule> mCarrierMatchingRulesOnMccMnc = new ArrayList<>();
    // cached carrier Id
    private int mCarrierId = TelephonyManager.UNKNOWN_CARRIER_ID;
    // cached precise carrier Id
    private int mPreciseCarrierId = TelephonyManager.UNKNOWN_CARRIER_ID;
    // cached specific carrier Id
    private int mSpecificCarrierId = TelephonyManager.UNKNOWN_CARRIER_ID;
    // cached MNO carrier Id. mno carrier shares the same mccmnc as cid and can be solely
    // identified by mccmnc only. If there is no such mno carrier, mno carrier id equals to
    // the cid.
    private int mMnoCarrierId = TelephonyManager.UNKNOWN_CARRIER_ID;
    // cached carrier name
    private String mCarrierName;
    private String mPreciseCarrierName;
    private String mSpecificCarrierName;
    // cached preferapn name
    private String mPreferApn;
    // cached service provider name. telephonyManager API returns empty string as default value.
@@ -347,7 +346,7 @@ public class CarrierResolver extends Handler {
    }

    private void updateCarrierIdAndName(int cid, String name,
                                        int preciseCarrierId, String preciseCarrierName,
                                        int specificCarrierId, String specificCarrierName,
                                        int mnoCid) {
        boolean update = false;
        if (!equals(name, mCarrierName, true)) {
@@ -388,34 +387,34 @@ public class CarrierResolver extends Handler {
        }

        update = false;
        if (preciseCarrierId != mPreciseCarrierId) {
            logd("[updatePreciseCarrierId] from:" + mPreciseCarrierId + " to:"
                    + preciseCarrierId);
            mPreciseCarrierId = preciseCarrierId;
        if (specificCarrierId != mSpecificCarrierId) {
            logd("[updateSpecificCarrierId] from:" + mSpecificCarrierId + " to:"
                    + specificCarrierId);
            mSpecificCarrierId = specificCarrierId;
            update = true;
        }
        if (preciseCarrierName != mPreciseCarrierName) {
            logd("[updatePreciseCarrierName] from:" + mPreciseCarrierName + " to:"
                    + preciseCarrierName);
            mPreciseCarrierName = preciseCarrierName;
        if (specificCarrierName != mSpecificCarrierName) {
            logd("[updateSpecificCarrierName] from:" + mSpecificCarrierName + " to:"
                    + specificCarrierName);
            mSpecificCarrierName = specificCarrierName;
            update = true;
        }
        if (update) {
            mCarrierIdLocalLog.log("[updatePreciseCarrierIdAndName] cid:" + mPreciseCarrierId
                    + " name:" + mPreciseCarrierName);
            mCarrierIdLocalLog.log("[updateSpecificCarrierIdAndName] cid:"
                    + mSpecificCarrierId + " name:" + mSpecificCarrierName);
            final Intent intent = new Intent(TelephonyManager
                    .ACTION_SUBSCRIPTION_PRECISE_CARRIER_IDENTITY_CHANGED);
            intent.putExtra(TelephonyManager.EXTRA_PRECISE_CARRIER_ID, mPreciseCarrierId);
            intent.putExtra(TelephonyManager.EXTRA_PRECISE_CARRIER_NAME, mPreciseCarrierName);
                    .ACTION_SUBSCRIPTION_SPECIFIC_CARRIER_IDENTITY_CHANGED);
            intent.putExtra(TelephonyManager.EXTRA_SPECIFIC_CARRIER_ID, mSpecificCarrierId);
            intent.putExtra(TelephonyManager.EXTRA_SPECIFIC_CARRIER_NAME, mSpecificCarrierName);
            intent.putExtra(TelephonyManager.EXTRA_SUBSCRIPTION_ID, mPhone.getSubId());
            mContext.sendBroadcast(intent);

            // notify content observers for precise carrier id change event.
            // notify content observers for specific carrier id change event.
            ContentValues cv = new ContentValues();
            cv.put(CarrierId.PRECISE_CARRIER_ID, mPreciseCarrierId);
            cv.put(CarrierId.PRECISE_CARRIER_ID_NAME, mPreciseCarrierName);
            cv.put(CarrierId.SPECIFIC_CARRIER_ID, mSpecificCarrierId);
            cv.put(CarrierId.SPECIFIC_CARRIER_ID_NAME, mSpecificCarrierName);
            mContext.getContentResolver().update(
                    Telephony.CarrierId.getPreciseCarrierIdUriForSubscriptionId(mPhone.getSubId()),
                    Telephony.CarrierId.getSpecificCarrierIdUriForSubscriptionId(mPhone.getSubId()),
                    cv, null, null);
        }
    }
@@ -739,8 +738,8 @@ public class CarrierResolver extends Handler {
                maxRuleParent.mCid = maxRuleParent.mParentCid;
                maxRuleParent.mName = getCarrierNameFromId(maxRuleParent.mCid);
            }
            logd("[matchSubscriptionCarrier] precise cid: " + maxRule.mCid + " precise name: "
                    + maxRule.mName +" cid: " + maxRuleParent.mCid
            logd("[matchSubscriptionCarrier] specific cid: " + maxRule.mCid
                    + " specific name: " + maxRule.mName +" cid: " + maxRuleParent.mCid
                    + " name: " + maxRuleParent.mName);
            updateCarrierIdAndName(maxRuleParent.mCid, maxRuleParent.mName,
                    maxRule.mCid, maxRule.mName,
@@ -780,25 +779,29 @@ public class CarrierResolver extends Handler {
    }
    /**
     * Returns fine-grained carrier id of the current subscription. Carrier ids with a valid parent
     * id are precise carrier ids.
     * The precise carrier id can be used to further differentiate a carrier by different
     * networks, by prepaid v.s.postpaid or even by 4G v.s.3G plan. Each carrier has a unique
     * carrier id but can have multiple precise carrier id. e.g,
     * {@link #getCarrierId()} will always return Tracfone (id 2022) for a Tracfone SIM, while
     * {@link #getPreciseCarrierId()} can return Tracfone AT&T or Tracfone T-Mobile based on the
     * current underlying network.
     * id are specific carrier ids.
     *
     * A specific carrier ID can represent the fact that a carrier may be in effect an aggregation
     * of other carriers (ie in an MVNO type scenario) where each of these specific carriers which
     * are used to make up the actual carrier service may have different carrier configurations.
     * A specific carrier ID could also be used, for example, in a scenario where a carrier requires
     * different carrier configuration for different service offering such as a prepaid plan.
     * e.g, {@link #getCarrierId()} will always return Tracfone (id 2022) for a Tracfone SIM, while
     * {@link #getSpecificCarrierId()} can return Tracfone AT&T or Tracfone T-Mobile based on the
     * IMSI from the current subscription.
     *
     * For carriers without any fine-grained carrier ids, return {@link #getCarrierId()}
     */
    public int getPreciseCarrierId() {
        return mPreciseCarrierId;
    public int getSpecificCarrierId() {
        return mSpecificCarrierId;
    }

    public String getCarrierName() {
        return mCarrierName;
    }

    public String getPreciseCarrierName() {
        return mPreciseCarrierName;
    public String getSpecificCarrierName() {
        return mSpecificCarrierName;
    }

    public int getMnoCarrierId() {
@@ -960,10 +963,10 @@ public class CarrierResolver extends Handler {
        ipw.decreaseIndent();

        ipw.println("mCarrierId: " + mCarrierId);
        ipw.println("mPreciseCarrierId: " + mPreciseCarrierId);
        ipw.println("mSpecificCarrierId: " + mSpecificCarrierId);
        ipw.println("mMnoCarrierId: " + mMnoCarrierId);
        ipw.println("mCarrierName: " + mCarrierName);
        ipw.println("mPreciseCarrierName: " + mPreciseCarrierName);
        ipw.println("mSpecificCarrierName: " + mSpecificCarrierName);
        ipw.println("carrier_list_version: " + getCarrierListVersion());

        ipw.println("mCarrierMatchingRules on mccmnc: "
+96 −0
Original line number Diff line number Diff line
/*
 * Copyright 2019 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.internal.telephony;

import android.content.Context;
import android.provider.Settings;
import android.provider.Settings.SettingNotFoundException;
import android.telephony.SubscriptionManager;
import android.telephony.TelephonyManager;

/**
 * Helper class that reads and writes Global.Setting values for Telephony. It will:
 * For Single SIM case, read from or write to the singleton setting value.
 * For Multi-SIM case, read from or write to the per subscription value.
 */
public class GlobalSettingsHelper {
    /**
     * Helper function to get integer value.
     */
    public static int getInt(Context context, String settingName, int subId,
            int defaultValue) {
        settingName = getSettingName(context, settingName, subId);
        return Settings.Global.getInt(context.getContentResolver(), settingName, defaultValue);
    }

    /**
     * Helper function to get boolean value.
     */
    public static boolean getBoolean(Context context, String settingName, int subId,
            boolean defaultValue) {
        settingName = getSettingName(context, settingName, subId);
        return Settings.Global.getInt(context.getContentResolver(), settingName,
                defaultValue ? 1 : 0) == 1;
    }

    /**
     * Helper function to get boolean value or throws SettingNotFoundException if not set.
     */
    public static boolean getBoolean(Context context, String settingName, int subId)
            throws SettingNotFoundException {
        settingName = getSettingName(context, settingName, subId);
        return Settings.Global.getInt(context.getContentResolver(), settingName) == 1;
    }

    /**
     * Helper function to set integer value.
     * Returns whether the value is changed or initially set.
     */
    public static boolean setInt(Context context, String settingName, int subId, int value) {
        settingName = getSettingName(context, settingName, subId);

        boolean needChange;
        try {
            needChange = Settings.Global.getInt(context.getContentResolver(), settingName) != value;
        } catch (SettingNotFoundException exception) {
            needChange = true;
        }
        if (needChange) Settings.Global.putInt(context.getContentResolver(), settingName, value);

        return needChange;
    }

    /**
     * Helper function to set boolean value.
     * Returns whether the value is changed or initially set.
     */
    public static boolean setBoolean(Context context, String settingName, int subId,
            boolean value) {
        return setInt(context, settingName, subId, value ? 1 : 0);
    }

    private static String getSettingName(Context context, String settingName, int subId) {
        // For single SIM phones, this is a per phone property. Or if it's invalid subId, we
        // read default setting.
        if (TelephonyManager.from(context).getSimCount() > 1
                && SubscriptionManager.isValidSubscriptionId(subId)) {
            return settingName + subId;
        } else {
            return settingName;
        }
    }
}
+73 −7
Original line number Diff line number Diff line
@@ -54,6 +54,7 @@ import android.os.WorkSource;
import android.preference.PreferenceManager;
import android.provider.Settings;
import android.provider.Telephony;
import android.telecom.TelecomManager;
import android.telecom.VideoProfile;
import android.telephony.AccessNetworkConstants.TransportType;
import android.telephony.CarrierConfigManager;
@@ -268,6 +269,8 @@ public class GsmCdmaPhone extends Phone {
        mSettingsObserver.observe(
                Settings.Global.getUriFor(Settings.Global.DEVICE_PROVISIONING_MOBILE_DATA_ENABLED),
                EVENT_DEVICE_PROVISIONING_DATA_SETTING_CHANGE);

        loadTtyMode();
        logd("GsmCdmaPhone: constructor: sub = " + mPhoneId);
    }

@@ -275,8 +278,17 @@ public class GsmCdmaPhone extends Phone {
        @Override
        public void onReceive(Context context, Intent intent) {
            Rlog.d(LOG_TAG, "mBroadcastReceiver: action " + intent.getAction());
            if (intent.getAction().equals(CarrierConfigManager.ACTION_CARRIER_CONFIG_CHANGED)) {
            String action = intent.getAction();
            if (CarrierConfigManager.ACTION_CARRIER_CONFIG_CHANGED.equals(action)) {
                sendMessage(obtainMessage(EVENT_CARRIER_CONFIG_CHANGED));
            } else if (TelecomManager.ACTION_CURRENT_TTY_MODE_CHANGED.equals(action)) {
                int ttyMode = intent.getIntExtra(
                        TelecomManager.EXTRA_CURRENT_TTY_MODE, TelecomManager.TTY_MODE_OFF);
                updateTtyMode(ttyMode);
            } else if (TelecomManager.ACTION_TTY_PREFERRED_MODE_CHANGED.equals(action)) {
                int newPreferredTtyMode = intent.getIntExtra(
                        TelecomManager.EXTRA_TTY_PREFERRED_MODE, TelecomManager.TTY_MODE_OFF);
                updateUiTtyMode(newPreferredTtyMode);
            }
        }
    };
@@ -327,8 +339,12 @@ public class GsmCdmaPhone extends Phone {

        mCi.registerForRilConnected(this, EVENT_RIL_CONNECTED, null);
        mCi.registerForVoiceRadioTechChanged(this, EVENT_VOICE_RADIO_TECH_CHANGED, null);
        mContext.registerReceiver(mBroadcastReceiver, new IntentFilter(
                CarrierConfigManager.ACTION_CARRIER_CONFIG_CHANGED));
        IntentFilter filter = new IntentFilter(
                CarrierConfigManager.ACTION_CARRIER_CONFIG_CHANGED);
        filter.addAction(TelecomManager.ACTION_CURRENT_TTY_MODE_CHANGED);
        filter.addAction(TelecomManager.ACTION_TTY_PREFERRED_MODE_CHANGED);
        mContext.registerReceiver(mBroadcastReceiver, filter);

        mCDM = new CarrierKeyDownloadManager(this);
        mCIM = new CarrierInfoManager();
    }
@@ -1639,13 +1655,13 @@ public class GsmCdmaPhone extends Phone {
    }

    @Override
    public int getPreciseCarrierId() {
        return mCarrierResolver.getPreciseCarrierId();
    public int getSpecificCarrierId() {
        return mCarrierResolver.getSpecificCarrierId();
    }

    @Override
    public String getPreciseCarrierName() {
        return mCarrierResolver.getPreciseCarrierName();
    public String getSpecificCarrierName() {
        return mCarrierResolver.getSpecificCarrierName();
    }

    @Override
@@ -1711,6 +1727,13 @@ public class GsmCdmaPhone extends Phone {
            IccRecords r = mIccRecords.get();
            return (r != null) ? r.getMsisdnNumber() : null;
        } else {
            CarrierConfigManager configManager = (CarrierConfigManager)
                    mContext.getSystemService(Context.CARRIER_CONFIG_SERVICE);
            boolean use_usim = configManager.getConfigForSubId(getSubId()).getBoolean(
                    CarrierConfigManager.KEY_USE_USIM_BOOL);
            if (use_usim) {
                return (mSimRecords != null) ? mSimRecords.getMsisdnNumber() : null;
            }
            return mSST.getMdnNumber();
        }
    }
@@ -3875,4 +3898,47 @@ public class GsmCdmaPhone extends Phone {
        }
        return currentConfig;
    }

    private void updateTtyMode(int ttyMode) {
        logi(String.format("updateTtyMode ttyMode=%d", ttyMode));
        setTTYMode(telecomModeToPhoneMode(ttyMode), null);
    }
    private void updateUiTtyMode(int ttyMode) {
        logi(String.format("updateUiTtyMode ttyMode=%d", ttyMode));
        setUiTTYMode(telecomModeToPhoneMode(ttyMode), null);
    }

    /**
     * Given a telecom TTY mode, convert to a Telephony mode equivalent.
     * @param telecomMode Telecom TTY mode.
     * @return Telephony phone TTY mode.
     */
    private static int telecomModeToPhoneMode(int telecomMode) {
        switch (telecomMode) {
            // AT command only has 0 and 1, so mapping VCO
            // and HCO to FULL
            case TelecomManager.TTY_MODE_FULL:
            case TelecomManager.TTY_MODE_VCO:
            case TelecomManager.TTY_MODE_HCO:
                return Phone.TTY_MODE_FULL;
            default:
                return Phone.TTY_MODE_OFF;
        }
    }

    /**
     * Load the current TTY mode in GsmCdmaPhone based on Telecom and UI settings.
     */
    private void loadTtyMode() {
        int ttyMode = TelecomManager.TTY_MODE_OFF;
        TelecomManager telecomManager = TelecomManager.from(mContext);
        if (telecomManager != null) {
            ttyMode = telecomManager.getCurrentTtyMode();
        }
        updateTtyMode(ttyMode);
        //Get preferred TTY mode from settings as UI Tty mode is always user preferred Tty mode.
        ttyMode = Settings.Secure.getInt(mContext.getContentResolver(),
                Settings.Secure.PREFERRED_TTY_MODE, TelecomManager.TTY_MODE_OFF);
        updateUiTtyMode(ttyMode);
    }
}
+338 −0

File added.

Preview size limit exceeded, changes collapsed.

Loading