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

Commit 06e27907 authored by Jack Yu's avatar Jack Yu Committed by Android (Google) Code Review
Browse files

Merge "Removed more CDMA codes" into main

parents b1a389df e77745b8
Loading
Loading
Loading
Loading
+1 −2
Original line number Diff line number Diff line
@@ -70,8 +70,7 @@ import java.util.regex.Pattern;
 * </a> element in your manifest that declares the {@code "android.hardware.telephony"} hardware
 * feature. Alternatively, you can check for telephony availability at runtime using either
 * {@link android.content.pm.PackageManager#hasSystemFeature
 * hasSystemFeature(PackageManager.FEATURE_TELEPHONY)} or {@link
 * android.telephony.TelephonyManager#getPhoneType}.</p>
 * hasSystemFeature(PackageManager.FEATURE_TELEPHONY)}.</p>
 *
 * <h3>Creating an SMS app</h3>
 *
+0 −163
Original line number Diff line number Diff line
/*
 * Copyright (C) 2014 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.ContentResolver;
import android.content.Context;
import android.database.Cursor;
import android.util.Log;

import com.android.internal.telephony.HbpcdLookup.ArbitraryMccSidMatch;
import com.android.internal.telephony.HbpcdLookup.MccIdd;
import com.android.internal.telephony.HbpcdLookup.MccLookup;
import com.android.internal.telephony.HbpcdLookup.MccSidConflicts;
import com.android.internal.telephony.HbpcdLookup.MccSidRange;

public final class HbpcdUtils {
    private static final String LOG_TAG = "HbpcdUtils";
    private static final boolean DBG = false;
    private ContentResolver resolver = null;

    public HbpcdUtils(Context context) {
        resolver = context.getContentResolver();
    }

    /**
     *  Resolves the unknown MCC with SID and Timezone information.
    */
    public int getMcc(int sid, int tz, int DSTflag, boolean isNitzTimeZone) {
        int tmpMcc = 0;

        // check if SID exists in arbitrary_mcc_sid_match table.
        // these SIDs are assigned to more than 1 operators, but they are known to
        // be used by a specific operator, other operators having the same SID are
        // not using it currently, if that SID is in this table, we don't need to
        // check other tables.
        String projection2[] = {ArbitraryMccSidMatch.MCC};
        Cursor c2 = resolver.query(ArbitraryMccSidMatch.CONTENT_URI, projection2,
                            ArbitraryMccSidMatch.SID + "=" + sid, null, null);

        if (c2 != null) {
            int c2Counter = c2.getCount();
            if (DBG) {
                Log.d(LOG_TAG, "Query unresolved arbitrary table, entries are " + c2Counter);
            }
            if (c2Counter == 1) {
                if (DBG) {
                    Log.d(LOG_TAG, "Query Unresolved arbitrary returned the cursor " + c2);
                }
                c2.moveToFirst();
                tmpMcc = c2.getInt(0);
                if (DBG) {
                    Log.d(LOG_TAG, "MCC found in arbitrary_mcc_sid_match: " + tmpMcc);
                }
                c2.close();
                return tmpMcc;
            }
            c2.close();
        }

        // Then check if SID exists in mcc_sid_conflict table.
        // and use the timezone in mcc_lookup table to check which MCC matches.
        String projection3[] = {MccSidConflicts.MCC};
        Cursor c3 = resolver.query(MccSidConflicts.CONTENT_URI, projection3,
                MccSidConflicts.SID_CONFLICT + "=" + sid + " and (((" +
                MccLookup.GMT_OFFSET_LOW + "<=" + tz + ") and (" + tz + "<=" +
                MccLookup.GMT_OFFSET_HIGH + ") and (" + "0=" + DSTflag + ")) or ((" +
                MccLookup.GMT_DST_LOW + "<=" + tz + ") and (" + tz + "<=" +
                MccLookup.GMT_DST_HIGH + ") and (" + "1=" + DSTflag + ")))",
                        null, null);
        if (c3 != null) {
            int c3Counter = c3.getCount();
            if (c3Counter > 0) {
                if (c3Counter > 1) {
                    Log.w(LOG_TAG, "something wrong, get more results for 1 conflict SID: " + c3);
                }
                if (DBG) Log.d(LOG_TAG, "Query conflict sid returned the cursor " + c3);
                c3.moveToFirst();
                tmpMcc = c3.getInt(0);
                if (DBG) {
                    Log.d(LOG_TAG, "MCC found in mcc_lookup_table. Return tmpMcc = " + tmpMcc);
                }
                if (!isNitzTimeZone) {
                    // time zone is not accurate, it may get wrong mcc, ignore it.
                    if (DBG) {
                        Log.d(LOG_TAG, "time zone is not accurate, mcc may be " + tmpMcc);
                    }
                    tmpMcc = 0;
                }
                c3.close();
                return tmpMcc;
            } else {
                c3.close();
            }
        }

        // if there is no conflict, then check if SID is in mcc_sid_range.
        String projection5[] = {MccSidRange.MCC};
        Cursor c5 = resolver.query(MccSidRange.CONTENT_URI, projection5,
                MccSidRange.RANGE_LOW + "<=" + sid + " and " +
                MccSidRange.RANGE_HIGH + ">=" + sid,
                null, null);
        if (c5 != null) {
            if (c5.getCount() > 0) {
                if (DBG) Log.d(LOG_TAG, "Query Range returned the cursor " + c5);
                c5.moveToFirst();
                tmpMcc = c5.getInt(0);
                if (DBG) Log.d(LOG_TAG, "SID found in mcc_sid_range. Return tmpMcc = " + tmpMcc);
                c5.close();
                return tmpMcc;
            }
            c5.close();
        }
        if (DBG) Log.d(LOG_TAG, "SID NOT found in mcc_sid_range.");

        if (DBG) Log.d(LOG_TAG, "Exit getMccByOtherFactors. Return tmpMcc =  " + tmpMcc);
        // If unknown MCC still could not be resolved,
        return tmpMcc;
    }

    /**
     *  Gets country information with given MCC.
    */
    public String getIddByMcc(int mcc) {
        if (DBG) Log.d(LOG_TAG, "Enter getHbpcdInfoByMCC.");
        String idd = "";

        Cursor c = null;

        String projection[] = {MccIdd.IDD};
        Cursor cur = resolver.query(MccIdd.CONTENT_URI, projection,
                MccIdd.MCC + "=" + mcc, null, null);
        if (cur != null) {
            if (cur.getCount() > 0) {
                if (DBG) Log.d(LOG_TAG, "Query Idd returned the cursor " + cur);
                // TODO: for those country having more than 1 IDDs, need more information
                // to decide which IDD would be used. currently just use the first 1.
                cur.moveToFirst();
                idd = cur.getString(0);
                if (DBG) Log.d(LOG_TAG, "IDD = " + idd);

            }
            cur.close();
        }
        if (c != null) c.close();

        if (DBG) Log.d(LOG_TAG, "Exit getHbpcdInfoByMCC.");
        return idd;
    }
}
+5 −145
Original line number Diff line number Diff line
@@ -265,16 +265,6 @@ public class ServiceState implements Parcelable {
     */
    private static final int NEXT_RIL_RADIO_TECHNOLOGY = 21;

    /** @hide */
    public static final int RIL_RADIO_CDMA_TECHNOLOGY_BITMASK =
            (1 << (RIL_RADIO_TECHNOLOGY_IS95A - 1))
                    | (1 << (RIL_RADIO_TECHNOLOGY_IS95B - 1))
                    | (1 << (RIL_RADIO_TECHNOLOGY_1xRTT - 1))
                    | (1 << (RIL_RADIO_TECHNOLOGY_EVDO_0 - 1))
                    | (1 << (RIL_RADIO_TECHNOLOGY_EVDO_A - 1))
                    | (1 << (RIL_RADIO_TECHNOLOGY_EVDO_B - 1))
                    | (1 << (RIL_RADIO_TECHNOLOGY_EHRPD - 1));

    private int mVoiceRegState = STATE_OUT_OF_SERVICE;
    private int mDataRegState = STATE_OUT_OF_SERVICE;

@@ -336,19 +326,6 @@ public class ServiceState implements Parcelable {

    @UnsupportedAppUsage(maxTargetSdk = Build.VERSION_CODES.P, trackingBug = 115609023)
    private boolean mCssIndicator;
    @UnsupportedAppUsage(maxTargetSdk = Build.VERSION_CODES.P)
    private int mNetworkId;
    @UnsupportedAppUsage(maxTargetSdk = Build.VERSION_CODES.P)
    private int mSystemId;
    @UnsupportedAppUsage(maxTargetSdk = Build.VERSION_CODES.P, trackingBug = 115609023)
    private int mCdmaRoamingIndicator;
    @UnsupportedAppUsage(maxTargetSdk = Build.VERSION_CODES.P, trackingBug = 115609023)
    private int mCdmaDefaultRoamingIndicator;
    @UnsupportedAppUsage(maxTargetSdk = Build.VERSION_CODES.P, trackingBug = 115609023)
    private int mCdmaEriIconIndex;
    @UnsupportedAppUsage(maxTargetSdk = Build.VERSION_CODES.P, trackingBug = 115609023)
    private int mCdmaEriIconMode;

    @FrequencyRange
    private int mNrFrequencyRange;
    private int mChannelNumber;
@@ -432,12 +409,6 @@ public class ServiceState implements Parcelable {
        mOperatorNumeric = s.mOperatorNumeric;
        mIsManualNetworkSelection = s.mIsManualNetworkSelection;
        mCssIndicator = s.mCssIndicator;
        mNetworkId = s.mNetworkId;
        mSystemId = s.mSystemId;
        mCdmaRoamingIndicator = s.mCdmaRoamingIndicator;
        mCdmaDefaultRoamingIndicator = s.mCdmaDefaultRoamingIndicator;
        mCdmaEriIconIndex = s.mCdmaEriIconIndex;
        mCdmaEriIconMode = s.mCdmaEriIconMode;
        mIsEmergencyOnly = s.mIsEmergencyOnly;
        mChannelNumber = s.mChannelNumber;
        mCellBandwidths = s.mCellBandwidths == null ? null :
@@ -471,12 +442,6 @@ public class ServiceState implements Parcelable {
        mOperatorNumeric = in.readString();
        mIsManualNetworkSelection = in.readInt() != 0;
        mCssIndicator = (in.readInt() != 0);
        mNetworkId = in.readInt();
        mSystemId = in.readInt();
        mCdmaRoamingIndicator = in.readInt();
        mCdmaDefaultRoamingIndicator = in.readInt();
        mCdmaEriIconIndex = in.readInt();
        mCdmaEriIconMode = in.readInt();
        mIsEmergencyOnly = in.readInt() != 0;
        mArfcnRsrpBoost = in.readInt();
        synchronized (mNetworkRegistrationInfos) {
@@ -499,13 +464,8 @@ public class ServiceState implements Parcelable {
        out.writeString(mOperatorNumeric);
        out.writeInt(mIsManualNetworkSelection ? 1 : 0);
        out.writeInt(mCssIndicator ? 1 : 0);
        out.writeInt(mNetworkId);
        out.writeInt(mSystemId);
        out.writeInt(mCdmaRoamingIndicator);
        out.writeInt(mCdmaDefaultRoamingIndicator);
        out.writeInt(mCdmaEriIconIndex);
        out.writeInt(mCdmaEriIconMode);
        out.writeInt(mIsEmergencyOnly ? 1 : 0);

        out.writeInt(mArfcnRsrpBoost);
        synchronized (mNetworkRegistrationInfos) {
            out.writeList(mNetworkRegistrationInfos);
@@ -730,38 +690,6 @@ public class ServiceState implements Parcelable {
        return mIsEmergencyOnly;
    }

    /**
     * @hide
     */
    @UnsupportedAppUsage
    public int getCdmaRoamingIndicator(){
        return this.mCdmaRoamingIndicator;
    }

    /**
     * @hide
     */
    @UnsupportedAppUsage
    public int getCdmaDefaultRoamingIndicator(){
        return this.mCdmaDefaultRoamingIndicator;
    }

    /**
     * @hide
     */
    @UnsupportedAppUsage
    public int getCdmaEriIconIndex() {
        return this.mCdmaEriIconIndex;
    }

    /**
     * @hide
     */
    @UnsupportedAppUsage
    public int getCdmaEriIconMode() {
        return this.mCdmaEriIconMode;
    }

    /**
     * Get current registered operator name in long alphanumeric format.
     *
@@ -981,12 +909,6 @@ public class ServiceState implements Parcelable {
                    mOperatorNumeric,
                    mIsManualNetworkSelection,
                    mCssIndicator,
                    mNetworkId,
                    mSystemId,
                    mCdmaRoamingIndicator,
                    mCdmaDefaultRoamingIndicator,
                    mCdmaEriIconIndex,
                    mCdmaEriIconMode,
                    mIsEmergencyOnly,
                    mArfcnRsrpBoost,
                    mNetworkRegistrationInfos,
@@ -1013,11 +935,6 @@ public class ServiceState implements Parcelable {
                    && equalsHandlesNulls(mOperatorAlphaShort, s.mOperatorAlphaShort)
                    && equalsHandlesNulls(mOperatorNumeric, s.mOperatorNumeric)
                    && equalsHandlesNulls(mCssIndicator, s.mCssIndicator)
                    && equalsHandlesNulls(mNetworkId, s.mNetworkId)
                    && equalsHandlesNulls(mSystemId, s.mSystemId)
                    && equalsHandlesNulls(mCdmaRoamingIndicator, s.mCdmaRoamingIndicator)
                    && equalsHandlesNulls(mCdmaDefaultRoamingIndicator,
                    s.mCdmaDefaultRoamingIndicator)
                    && mIsEmergencyOnly == s.mIsEmergencyOnly
                    && equalsHandlesNulls(mOperatorAlphaLongRaw, s.mOperatorAlphaLongRaw)
                    && equalsHandlesNulls(mOperatorAlphaShortRaw, s.mOperatorAlphaShortRaw)
@@ -1194,10 +1111,6 @@ public class ServiceState implements Parcelable {
                    .append(", getRilDataRadioTechnology=").append(getRilDataRadioTechnology())
                    .append("(" + rilRadioTechnologyToString(getRilDataRadioTechnology()) + ")")
                    .append(", mCssIndicator=").append(mCssIndicator ? "supported" : "unsupported")
                    .append(", mNetworkId=").append(mNetworkId)
                    .append(", mSystemId=").append(mSystemId)
                    .append(", mCdmaRoamingIndicator=").append(mCdmaRoamingIndicator)
                    .append(", mCdmaDefaultRoamingIndicator=").append(mCdmaDefaultRoamingIndicator)
                    .append(", mIsEmergencyOnly=").append(mIsEmergencyOnly)
                    .append(", isUsingCarrierAggregation=").append(isUsingCarrierAggregation())
                    .append(", mArfcnRsrpBoost=").append(mArfcnRsrpBoost)
@@ -1229,12 +1142,6 @@ public class ServiceState implements Parcelable {
        mOperatorNumeric = null;
        mIsManualNetworkSelection = false;
        mCssIndicator = false;
        mNetworkId = -1;
        mSystemId = -1;
        mCdmaRoamingIndicator = -1;
        mCdmaDefaultRoamingIndicator = -1;
        mCdmaEriIconIndex = -1;
        mCdmaEriIconMode = -1;
        mIsEmergencyOnly = false;
        mArfcnRsrpBoost = 0;
        mNrFrequencyRange = FREQUENCY_RANGE_UNKNOWN;
@@ -1372,38 +1279,6 @@ public class ServiceState implements Parcelable {
        mIsEmergencyOnly = emergencyOnly;
    }

    /**
     * @hide
     */
    @UnsupportedAppUsage(maxTargetSdk = Build.VERSION_CODES.P, trackingBug = 115609023)
    public void setCdmaRoamingIndicator(int roaming) {
        this.mCdmaRoamingIndicator = roaming;
    }

    /**
     * @hide
     */
    @UnsupportedAppUsage(maxTargetSdk = Build.VERSION_CODES.P, trackingBug = 115609023)
    public void setCdmaDefaultRoamingIndicator (int roaming) {
        this.mCdmaDefaultRoamingIndicator = roaming;
    }

    /**
     * @hide
     */
    @UnsupportedAppUsage(maxTargetSdk = Build.VERSION_CODES.P, trackingBug = 115609023)
    public void setCdmaEriIconIndex(int index) {
        this.mCdmaEriIconIndex = index;
    }

    /**
     * @hide
     */
    @UnsupportedAppUsage(maxTargetSdk = Build.VERSION_CODES.P, trackingBug = 115609023)
    public void setCdmaEriIconMode(int mode) {
        this.mCdmaEriIconMode = mode;
    }

    public void setOperatorName(String longName, String shortName, String numeric) {
        mOperatorAlphaLong = longName;
        mOperatorAlphaShort = shortName;
@@ -1480,10 +1355,6 @@ public class ServiceState implements Parcelable {
        m.putInt("radioTechnology", getRilVoiceRadioTechnology());
        m.putInt("dataRadioTechnology", getRilDataRadioTechnology());
        m.putBoolean("cssIndicator", mCssIndicator);
        m.putInt("networkId", mNetworkId);
        m.putInt("systemId", mSystemId);
        m.putInt("cdmaRoamingIndicator", mCdmaRoamingIndicator);
        m.putInt("cdmaDefaultRoamingIndicator", mCdmaDefaultRoamingIndicator);
        m.putBoolean("emergencyOnly", mIsEmergencyOnly);
        m.putBoolean("isDataRoamingFromRegistration", getDataRoamingFromRegistration());
        m.putBoolean("isUsingCarrierAggregation", isUsingCarrierAggregation());
@@ -1596,8 +1467,6 @@ public class ServiceState implements Parcelable {
    /** @hide */
    @TestApi
    public void setCdmaSystemAndNetworkId(int systemId, int networkId) {
        this.mSystemId = systemId;
        this.mNetworkId = networkId;
    }

    /** @hide */
@@ -1821,14 +1690,14 @@ public class ServiceState implements Parcelable {
     * {@link android.Manifest.permission#ACCESS_COARSE_LOCATION}. Otherwise return
     * {@link #UNKNOWN_ID}.
     *
     * @return The CDMA NID or {@link #UNKNOWN_ID} if not available.
     * @return {@link #UNKNOWN_ID} as CDMA is no longer supported.
     */
    @RequiresPermission(anyOf = {
            android.Manifest.permission.ACCESS_FINE_LOCATION,
            android.Manifest.permission.ACCESS_COARSE_LOCATION
    })
    public int getCdmaNetworkId() {
        return this.mNetworkId;
        return UNKNOWN_ID;
    }

    /**
@@ -1839,14 +1708,14 @@ public class ServiceState implements Parcelable {
     * {@link android.Manifest.permission#ACCESS_COARSE_LOCATION}. Otherwise return
     * {@link #UNKNOWN_ID}.
     *
     * @return The CDMA SID or {@link #UNKNOWN_ID} if not available.
     * @return {@link #UNKNOWN_ID} as CDMA is no longer supported.
     */
    @RequiresPermission(anyOf = {
            android.Manifest.permission.ACCESS_FINE_LOCATION,
            android.Manifest.permission.ACCESS_COARSE_LOCATION
    })
    public int getCdmaSystemId() {
        return this.mSystemId;
        return UNKNOWN_ID;
    }

    /** @hide */
@@ -1887,13 +1756,6 @@ public class ServiceState implements Parcelable {
                || radioTechnology == RIL_RADIO_TECHNOLOGY_NR;
    }

    /** @hide */
    @UnsupportedAppUsage(maxTargetSdk = Build.VERSION_CODES.P, trackingBug = 115609023)
    public static boolean bearerBitmapHasCdma(int networkTypeBitmask) {
        return (RIL_RADIO_CDMA_TECHNOLOGY_BITMASK
                & convertNetworkTypeBitmaskToBearerBitmask(networkTypeBitmask)) != 0;
    }

    /** @hide */
    @UnsupportedAppUsage(maxTargetSdk = Build.VERSION_CODES.R, trackingBug = 170729553)
    public static boolean bitmaskHasTech(int bearerBitmask, int radioTech) {
@@ -2136,8 +1998,6 @@ public class ServiceState implements Parcelable {
        state.mOperatorAlphaLong = null;
        state.mOperatorAlphaShort = null;
        state.mOperatorNumeric = null;
        state.mSystemId = UNKNOWN_ID;
        state.mNetworkId = UNKNOWN_ID;

        return state;
    }
+12 −206

File changed.

Preview size limit exceeded, changes collapsed.

+0 −51
Original line number Diff line number Diff line
@@ -395,22 +395,6 @@ interface ITelephony {
     */
    int getDataStateForSubId(int subId);

    /**
     * Returns the current active phone type as integer.
     * Returns TelephonyManager.PHONE_TYPE_CDMA if RILConstants.CDMA_PHONE
     * and TelephonyManager.PHONE_TYPE_GSM if RILConstants.GSM_PHONE
     */
    @UnsupportedAppUsage
    int getActivePhoneType();

    /**
     * Returns the current active phone type as integer for particular slot.
     * Returns TelephonyManager.PHONE_TYPE_CDMA if RILConstants.CDMA_PHONE
     * and TelephonyManager.PHONE_TYPE_GSM if RILConstants.GSM_PHONE
     * @param slotIndex - slot to query.
     */
    int getActivePhoneTypeForSlot(int slotIndex);

    /**
     * Sets the voicemail number for a particular subscriber.
     */
@@ -531,30 +515,6 @@ interface ITelephony {
     */
    boolean hasIccCardUsingSlotIndex(int slotIndex);

    /**
     * Return if the current radio is LTE on CDMA. This
     * is a tri-state return value as for a period of time
     * the mode may be unknown.
     *
     * @param callingPackage the name of the calling package
     * @param callingFeatureId The feature in the package.
     * @return {@link Phone#LTE_ON_CDMA_UNKNOWN}, {@link Phone#LTE_ON_CDMA_FALSE}
     * or {@link PHone#LTE_ON_CDMA_TRUE}
     */
    int getLteOnCdmaMode(String callingPackage, String callingFeatureId);

    /**
     * Return if the current radio is LTE on CDMA. This
     * is a tri-state return value as for a period of time
     * the mode may be unknown.
     *
     * @param callingPackage the name of the calling package
     * @param callingFeatureId The feature in the package.
     * @return {@link Phone#LTE_ON_CDMA_UNKNOWN}, {@link Phone#LTE_ON_CDMA_FALSE}
     * or {@link PHone#LTE_ON_CDMA_TRUE}
     */
    int getLteOnCdmaModeForSubscriber(int subId, String callingPackage, String callingFeatureId);

    /**
     * Returns all observed cell information of the device.
     */
@@ -1368,17 +1328,6 @@ interface ITelephony {
     */
    String getAidForAppType(int subId, int appType);

    /**
    * Return the Electronic Serial Number.
    *
    * Requires that the calling app has READ_PRIVILEGED_PHONE_STATE permission
    *
    * @param subId the subscription ID that this request applies to.
    * @return ESN or null if error.
    * @hide
    */
    String getEsn(int subId);

    /**
     * Get snapshot of Telephony histograms
     * @return List of Telephony histograms
Loading