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

Commit da8ca7f8 authored by Michele Berionne's avatar Michele Berionne Committed by android-build-merger
Browse files

Merge "Carrier restriction enhancements for Android Q" am: 98391daa

am: 941ad71f

Change-Id: I1c9e816516eeb25d775d71fae8684af25e22fefb
parents 61e22fed 941ad71f
Loading
Loading
Loading
Loading
+31 −2
Original line number Original line Diff line number Diff line
@@ -5112,6 +5112,30 @@ package android.telephony {
    field public static final java.lang.String KEY_CARRIER_SETUP_APP_STRING = "carrier_setup_app_string";
    field public static final java.lang.String KEY_CARRIER_SETUP_APP_STRING = "carrier_setup_app_string";
  }
  }


  public final class CarrierRestrictionRules implements android.os.Parcelable {
    method public int describeContents();
    method public java.util.List<android.service.carrier.CarrierIdentifier> getAllowedCarriers();
    method public int getDefaultCarrierRestriction();
    method public java.util.List<android.service.carrier.CarrierIdentifier> getExcludedCarriers();
    method public int getMultiSimPolicy();
    method public boolean isAllCarriersAllowed();
    method public void writeToParcel(android.os.Parcel, int);
    field public static final int CARRIER_RESTRICTION_DEFAULT_ALLOWED = 1; // 0x1
    field public static final int CARRIER_RESTRICTION_DEFAULT_NOT_ALLOWED = 0; // 0x0
    field public static final android.os.Parcelable.Creator<android.telephony.CarrierRestrictionRules> CREATOR;
    field public static final int MULTISIM_POLICY_NONE = 0; // 0x0
    field public static final int MULTISIM_POLICY_ONE_VALID_SIM_MUST_BE_PRESENT = 1; // 0x1
  }

  public static class CarrierRestrictionRules.Builder {
    method public android.telephony.CarrierRestrictionRules build();
    method public android.telephony.CarrierRestrictionRules.Builder setAllCarriersAllowed();
    method public android.telephony.CarrierRestrictionRules.Builder setAllowedCarriers(java.util.List<android.service.carrier.CarrierIdentifier>);
    method public android.telephony.CarrierRestrictionRules.Builder setDefaultCarrierRestriction(int);
    method public android.telephony.CarrierRestrictionRules.Builder setExcludedCarriers(java.util.List<android.service.carrier.CarrierIdentifier>);
    method public android.telephony.CarrierRestrictionRules.Builder setMultiSimPolicy(int);
  }

  public final class DataFailCause {
  public final class DataFailCause {
    field public static final int ACTIVATION_REJECT_GGSN = 30; // 0x1e
    field public static final int ACTIVATION_REJECT_GGSN = 30; // 0x1e
    field public static final int ACTIVATION_REJECT_UNSPECIFIED = 31; // 0x1f
    field public static final int ACTIVATION_REJECT_UNSPECIFIED = 31; // 0x1f
@@ -5607,10 +5631,11 @@ package android.telephony {
    method public boolean enableDataConnectivity();
    method public boolean enableDataConnectivity();
    method public void enableVideoCalling(boolean);
    method public void enableVideoCalling(boolean);
    method public java.lang.String getAidForAppType(int);
    method public java.lang.String getAidForAppType(int);
    method public java.util.List<android.service.carrier.CarrierIdentifier> getAllowedCarriers(int);
    method public deprecated java.util.List<android.service.carrier.CarrierIdentifier> getAllowedCarriers(int);
    method public int getCardIdForDefaultEuicc();
    method public int getCardIdForDefaultEuicc();
    method public java.util.List<java.lang.String> getCarrierPackageNamesForIntent(android.content.Intent);
    method public java.util.List<java.lang.String> getCarrierPackageNamesForIntent(android.content.Intent);
    method public java.util.List<java.lang.String> getCarrierPackageNamesForIntentAndPhone(android.content.Intent, int);
    method public java.util.List<java.lang.String> getCarrierPackageNamesForIntentAndPhone(android.content.Intent, int);
    method public android.telephony.CarrierRestrictionRules getCarrierRestrictionRules();
    method public java.lang.String getCdmaMdn();
    method public java.lang.String getCdmaMdn();
    method public java.lang.String getCdmaMdn(int);
    method public java.lang.String getCdmaMdn(int);
    method public java.lang.String getCdmaMin();
    method public java.lang.String getCdmaMin();
@@ -5648,8 +5673,9 @@ package android.telephony {
    method public void requestCellInfoUpdate(android.os.WorkSource, java.util.concurrent.Executor, android.telephony.TelephonyManager.CellInfoCallback);
    method public void requestCellInfoUpdate(android.os.WorkSource, java.util.concurrent.Executor, android.telephony.TelephonyManager.CellInfoCallback);
    method public void requestNumberVerification(android.telephony.PhoneNumberRange, long, java.util.concurrent.Executor, android.telephony.NumberVerificationCallback);
    method public void requestNumberVerification(android.telephony.PhoneNumberRange, long, java.util.concurrent.Executor, android.telephony.NumberVerificationCallback);
    method public boolean resetRadioConfig();
    method public boolean resetRadioConfig();
    method public int setAllowedCarriers(int, java.util.List<android.service.carrier.CarrierIdentifier>);
    method public deprecated int setAllowedCarriers(int, java.util.List<android.service.carrier.CarrierIdentifier>);
    method public void setCarrierDataEnabled(boolean);
    method public void setCarrierDataEnabled(boolean);
    method public int setCarrierRestrictionRules(android.telephony.CarrierRestrictionRules);
    method public void setDataActivationState(int);
    method public void setDataActivationState(int);
    method public deprecated void setDataEnabled(int, boolean);
    method public deprecated void setDataEnabled(int, boolean);
    method public void setDataRoamingEnabled(boolean);
    method public void setDataRoamingEnabled(boolean);
@@ -5700,6 +5726,9 @@ package android.telephony {
    field public static final int RADIO_POWER_OFF = 0; // 0x0
    field public static final int RADIO_POWER_OFF = 0; // 0x0
    field public static final int RADIO_POWER_ON = 1; // 0x1
    field public static final int RADIO_POWER_ON = 1; // 0x1
    field public static final int RADIO_POWER_UNAVAILABLE = 2; // 0x2
    field public static final int RADIO_POWER_UNAVAILABLE = 2; // 0x2
    field public static final int SET_CARRIER_RESTRICTION_ERROR = 2; // 0x2
    field public static final int SET_CARRIER_RESTRICTION_NOT_SUPPORTED = 1; // 0x1
    field public static final int SET_CARRIER_RESTRICTION_SUCCESS = 0; // 0x0
    field public static final int SIM_ACTIVATION_STATE_ACTIVATED = 2; // 0x2
    field public static final int SIM_ACTIVATION_STATE_ACTIVATED = 2; // 0x2
    field public static final int SIM_ACTIVATION_STATE_ACTIVATING = 1; // 0x1
    field public static final int SIM_ACTIVATION_STATE_ACTIVATING = 1; // 0x1
    field public static final int SIM_ACTIVATION_STATE_DEACTIVATED = 3; // 0x3
    field public static final int SIM_ACTIVATION_STATE_DEACTIVATED = 3; // 0x3
+20 −0
Original line number Original line Diff line number Diff line
/*
 * Copyright 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.
 */

/** @hide */
package android.telephony;

parcelable CarrierRestrictionRules;
+277 −0
Original line number Original line 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 android.telephony;

import android.annotation.IntDef;
import android.annotation.NonNull;
import android.annotation.SystemApi;
import android.os.Parcel;
import android.os.Parcelable;
import android.service.carrier.CarrierIdentifier;

import java.lang.annotation.Retention;
import java.lang.annotation.RetentionPolicy;
import java.util.ArrayList;
import java.util.List;

/**
 * Contains the list of carrier restrictions.
 * Allowed list: it indicates the list of carriers that are allowed.
 * Excluded list: it indicates the list of carriers that are excluded.
 * Default carrier restriction: it indicates the default behavior and the priority between the two
 * lists:
 *  - not allowed: the device only allows usage of carriers that are present in the allowed list
 *    and not present in the excluded list. This implies that if a carrier is not present in either
 *    list, it is not allowed.
 *  - allowed: the device allows all carriers, except those present in the excluded list and not
 *    present in the allowed list. This implies that if a carrier is not present in either list,
 *    it is allowed.
 * MultiSim policy: it indicates the behavior in case of devices with two or more SIM cards.
 *  - MULTISIM_POLICY_NONE: the same configuration is applied to all SIM slots independently. This
 *    is the default value if none is set.
 *  - MULTISIM_POLICY_ONE_VALID_SIM_MUST_BE_PRESENT: it indicates that any SIM card can be used
 *    as far as one SIM card matching the configuration is present in the device.
 *
 * Both lists support the character '?' as wild character. For example, an entry indicating
 * MCC=310 and MNC=??? will match all networks with MCC=310.
 *
 * Example 1: Allowed list contains MCC and MNC of operator A. Excluded list contains operator B,
 *            which has same MCC and MNC, but also GID1 value. The priority allowed list is set
 *            to true. Only SIM cards of operator A are allowed, but not those of B or any other
 *            operator.
 * Example 2: Allowed list contains MCC and MNC of operator A. Excluded list contains an entry
 *            with same MCC, and '???' as MNC. The priority allowed list is set to false.
 *            SIM cards of operator A and all SIM cards with a different MCC value are allowed.
 *            SIM cards of operators with same MCC value and different MNC are not allowed.
 * @hide
 */
@SystemApi
public final class CarrierRestrictionRules implements Parcelable {
    /**
     * The device only allows usage of carriers that are present in the allowed list and not
     * present in the excluded list. This implies that if a carrier is not present in either list,
     * it is not allowed.
     */
    public static final int CARRIER_RESTRICTION_DEFAULT_NOT_ALLOWED = 0;

    /**
     * The device allows all carriers, except those present in the excluded list and not present
     * in the allowed list. This implies that if a carrier is not present in either list, it is
     * allowed.
     */
    public static final int CARRIER_RESTRICTION_DEFAULT_ALLOWED = 1;

    /** The same configuration is applied to all SIM slots independently. */
    public static final int MULTISIM_POLICY_NONE = 0;

    /** Any SIM card can be used as far as one SIM card matching the configuration is present. */
    public static final int MULTISIM_POLICY_ONE_VALID_SIM_MUST_BE_PRESENT = 1;

    /** @hide */
    @Retention(RetentionPolicy.SOURCE)
    @IntDef(prefix = "MULTISIM_POLICY_",
            value = {MULTISIM_POLICY_NONE, MULTISIM_POLICY_ONE_VALID_SIM_MUST_BE_PRESENT})
    public @interface MultiSimPolicy {}

    /** @hide */
    @Retention(RetentionPolicy.SOURCE)
    @IntDef(prefix = "CARRIER_RESTRICTION_DEFAULT_",
            value = {CARRIER_RESTRICTION_DEFAULT_NOT_ALLOWED, CARRIER_RESTRICTION_DEFAULT_ALLOWED})
    public @interface CarrierRestrictionDefault {}

    private List<CarrierIdentifier> mAllowedCarriers;
    private List<CarrierIdentifier> mExcludedCarriers;
    @CarrierRestrictionDefault
    private int mCarrierRestrictionDefault;
    @MultiSimPolicy
    private int mMultiSimPolicy;

    private CarrierRestrictionRules() {
        mAllowedCarriers = new ArrayList<CarrierIdentifier>();
        mExcludedCarriers = new ArrayList<CarrierIdentifier>();
        mCarrierRestrictionDefault = CARRIER_RESTRICTION_DEFAULT_NOT_ALLOWED;
        mMultiSimPolicy = MULTISIM_POLICY_NONE;
    }

    private CarrierRestrictionRules(Parcel in) {
        mAllowedCarriers = new ArrayList<CarrierIdentifier>();
        mExcludedCarriers = new ArrayList<CarrierIdentifier>();

        in.readTypedList(mAllowedCarriers, CarrierIdentifier.CREATOR);
        in.readTypedList(mExcludedCarriers, CarrierIdentifier.CREATOR);
        mCarrierRestrictionDefault = in.readInt();
        mMultiSimPolicy = in.readInt();
    }

    /**
     * Creates a new builder for this class
     * @hide
     */
    public static Builder newBuilder() {
        return new Builder();
    }

    /**
     * Indicates if all carriers are allowed
     */
    public boolean isAllCarriersAllowed() {
        return (mAllowedCarriers.isEmpty() && mExcludedCarriers.isEmpty()
                && mCarrierRestrictionDefault == CARRIER_RESTRICTION_DEFAULT_ALLOWED);
    }

    /**
     * Retrieves list of allowed carriers
     *
     * @return the list of allowed carriers
     */
    public @NonNull List<CarrierIdentifier> getAllowedCarriers() {
        return mAllowedCarriers;
    }

    /**
     * Retrieves list of excluded carriers
     *
     * @return the list of excluded carriers
     */
    public @NonNull List<CarrierIdentifier> getExcludedCarriers() {
        return mExcludedCarriers;
    }

    /**
     * Retrieves the default behavior of carrier restrictions
     */
    public @CarrierRestrictionDefault int getDefaultCarrierRestriction() {
        return mCarrierRestrictionDefault;
    }

    /**
     * @return The policy used for multi-SIM devices
     */
    public @MultiSimPolicy int getMultiSimPolicy() {
        return mMultiSimPolicy;
    }

    /**
     * {@link Parcelable#writeToParcel}
     */
    @Override
    public void writeToParcel(Parcel out, int flags) {
        out.writeTypedList(mAllowedCarriers);
        out.writeTypedList(mExcludedCarriers);
        out.writeInt(mCarrierRestrictionDefault);
        out.writeInt(mMultiSimPolicy);
    }

    /**
     * {@link Parcelable#describeContents}
     */
    @Override
    public int describeContents() {
        return 0;
    }

    /**
     * {@link Parcelable.Creator}
     */
    public static final Creator<CarrierRestrictionRules> CREATOR =
            new Creator<CarrierRestrictionRules>() {
        @Override
        public CarrierRestrictionRules createFromParcel(Parcel in) {
            return new CarrierRestrictionRules(in);
        }

        @Override
        public CarrierRestrictionRules[] newArray(int size) {
            return new CarrierRestrictionRules[size];
        }
    };

    @Override
    public String toString() {
        return "CarrierRestrictionRules(allowed:" + mAllowedCarriers + ", excluded:"
                + mExcludedCarriers + ", default:" + mCarrierRestrictionDefault
                + ", multisim policy:" + mMultiSimPolicy + ")";
    }

    /**
     * Builder for a {@link CarrierRestrictionRules}.
     */
    public static class Builder {
        private final CarrierRestrictionRules mRules;

        /** {@hide} */
        public Builder() {
            mRules = new CarrierRestrictionRules();
        }

        /** build command */
        public CarrierRestrictionRules build() {
            return mRules;
        }

        /**
         * Indicate that all carriers are allowed.
         */
        public Builder setAllCarriersAllowed() {
            mRules.mAllowedCarriers.clear();
            mRules.mExcludedCarriers.clear();
            mRules.mCarrierRestrictionDefault = CARRIER_RESTRICTION_DEFAULT_ALLOWED;
            return this;
        }

        /**
         * Set list of allowed carriers.
         *
         * @param allowedCarriers list of allowed carriers
         */
        public Builder setAllowedCarriers(List<CarrierIdentifier> allowedCarriers) {
            mRules.mAllowedCarriers = new ArrayList<CarrierIdentifier>(allowedCarriers);
            return this;
        }

        /**
         * Set list of excluded carriers.
         *
         * @param excludedCarriers list of excluded carriers
         */
        public Builder setExcludedCarriers(List<CarrierIdentifier> excludedCarriers) {
            mRules.mExcludedCarriers = new ArrayList<CarrierIdentifier>(excludedCarriers);
            return this;
        }

        /**
         * Set the default behavior of the carrier restrictions
         *
         * @param carrierRestrictionDefault prioritized carrier list
         */
        public Builder setDefaultCarrierRestriction(
                @CarrierRestrictionDefault int carrierRestrictionDefault) {
            mRules.mCarrierRestrictionDefault = carrierRestrictionDefault;
            return this;
        }

        /**
         * Set the policy to be used for multi-SIM devices
         *
         * @param multiSimPolicy multi SIM policy
         */
        public Builder setMultiSimPolicy(@MultiSimPolicy int multiSimPolicy) {
            mRules.mMultiSimPolicy = multiSimPolicy;
            return this;
        }
    }
}
+107 −5
Original line number Original line Diff line number Diff line
@@ -8707,6 +8707,8 @@ public class TelephonyManager {
     * <p>This method works only on devices with {@link
     * <p>This method works only on devices with {@link
     * android.content.pm.PackageManager#FEATURE_TELEPHONY_CARRIERLOCK} enabled.
     * android.content.pm.PackageManager#FEATURE_TELEPHONY_CARRIERLOCK} enabled.
     *
     *
     * @deprecated use setCarrierRestrictionRules instead
     *
     * @return The number of carriers set successfully. Should be length of
     * @return The number of carriers set successfully. Should be length of
     * carrierList on success; -1 if carrierList null or on error.
     * carrierList on success; -1 if carrierList null or on error.
     * @hide
     * @hide
@@ -8714,44 +8716,144 @@ public class TelephonyManager {
    @SystemApi
    @SystemApi
    @RequiresPermission(android.Manifest.permission.MODIFY_PHONE_STATE)
    @RequiresPermission(android.Manifest.permission.MODIFY_PHONE_STATE)
    public int setAllowedCarriers(int slotIndex, List<CarrierIdentifier> carriers) {
    public int setAllowedCarriers(int slotIndex, List<CarrierIdentifier> carriers) {
        // Execute the method setCarrierRestrictionRules with an empty excluded list and
        // indicating priority for the allowed list.
        CarrierRestrictionRules carrierRestrictionRules = CarrierRestrictionRules.newBuilder()
                .setAllowedCarriers(carriers)
                .setDefaultCarrierRestriction(
                    CarrierRestrictionRules.CARRIER_RESTRICTION_DEFAULT_NOT_ALLOWED)
                .build();

        int result = setCarrierRestrictionRules(carrierRestrictionRules);

        // Convert boolean result into int, as required by this method.
        if (result == SET_CARRIER_RESTRICTION_SUCCESS) {
            return carriers.size();
        } else {
            return -1;
        }
    }

    /**
     * The carrier restrictions were successfully set.
     * @hide
     */
    @SystemApi
    public static final int SET_CARRIER_RESTRICTION_SUCCESS = 0;

    /**
     * The carrier restrictions were not set due to lack of support in the modem. This can happen
     * if the modem does not support setting the carrier restrictions or if the configuration
     * passed in the {@code setCarrierRestrictionRules} is not supported by the modem.
     * @hide
     */
    @SystemApi
    public static final int SET_CARRIER_RESTRICTION_NOT_SUPPORTED = 1;

    /**
     * The setting of carrier restrictions failed.
     * @hide
     */
    @SystemApi
    public static final int SET_CARRIER_RESTRICTION_ERROR = 2;

    /** @hide */
    @Retention(RetentionPolicy.SOURCE)
    @IntDef(prefix = {"SET_CARRIER_RESTRICTION_"},
            value = {
                    SET_CARRIER_RESTRICTION_SUCCESS,
                    SET_CARRIER_RESTRICTION_NOT_SUPPORTED,
                    SET_CARRIER_RESTRICTION_ERROR
            })
    public @interface SetCarrierRestrictionResult {}

    /**
     * Set the allowed carrier list and the excluded carrier list indicating the priority between
     * the two lists.
     * Requires system privileges.
     *
     * <p>Requires Permission:
     *   {@link android.Manifest.permission#MODIFY_PHONE_STATE}
     *
     * <p>This method works only on devices with {@link
     * android.content.pm.PackageManager#FEATURE_TELEPHONY_CARRIERLOCK} enabled.
     *
     * @return {@link #SET_CARRIER_RESTRICTION_SUCCESS} in case of success.
     * {@link #SET_CARRIER_RESTRICTION_NOT_SUPPORTED} if the modem does not support the
     * configuration. {@link #SET_CARRIER_RESTRICTION_ERROR} in all other error cases.
     * @hide
     */
    @SystemApi
    @RequiresPermission(android.Manifest.permission.MODIFY_PHONE_STATE)
    @SetCarrierRestrictionResult
    public int setCarrierRestrictionRules(@NonNull CarrierRestrictionRules rules) {
        try {
        try {
            ITelephony service = getITelephony();
            ITelephony service = getITelephony();
            if (service != null) {
            if (service != null) {
                return service.setAllowedCarriers(slotIndex, carriers);
                return service.setAllowedCarriers(rules);
            }
            }
        } catch (RemoteException e) {
        } catch (RemoteException e) {
            Log.e(TAG, "Error calling ITelephony#setAllowedCarriers", e);
            Log.e(TAG, "Error calling ITelephony#setAllowedCarriers", e);
        } catch (NullPointerException e) {
        } catch (NullPointerException e) {
            Log.e(TAG, "Error calling ITelephony#setAllowedCarriers", e);
            Log.e(TAG, "Error calling ITelephony#setAllowedCarriers", e);
        }
        }
        return -1;
        return SET_CARRIER_RESTRICTION_ERROR;
    }
    }


    /**
    /**
     * Get the allowed carrier list for slotIndex.
     * Get the allowed carrier list for slotIndex.
     * Require system privileges. In the future we may add this to carrier APIs.
     * Requires system privileges.
     *
     *
     * <p>This method returns valid data on devices with {@link
     * <p>This method returns valid data on devices with {@link
     * android.content.pm.PackageManager#FEATURE_TELEPHONY_CARRIERLOCK} enabled.
     * android.content.pm.PackageManager#FEATURE_TELEPHONY_CARRIERLOCK} enabled.
     *
     *
     * @deprecated Apps should use {@link getCarriersRestrictionRules} to retrieve the list of
     * allowed and excliuded carriers, as the result of this API is valid only when the excluded
     * list is empty. This API could return an empty list, even if some restrictions are present.
     *
     * @return List of {@link android.telephony.CarrierIdentifier}; empty list
     * @return List of {@link android.telephony.CarrierIdentifier}; empty list
     * means all carriers are allowed.
     * means all carriers are allowed.
     * @hide
     * @hide
     */
     */
    @Deprecated
    @SystemApi
    @SystemApi
    @RequiresPermission(android.Manifest.permission.READ_PRIVILEGED_PHONE_STATE)
    @RequiresPermission(android.Manifest.permission.READ_PRIVILEGED_PHONE_STATE)
    public List<CarrierIdentifier> getAllowedCarriers(int slotIndex) {
    public List<CarrierIdentifier> getAllowedCarriers(int slotIndex) {
        CarrierRestrictionRules carrierRestrictionRule = getCarrierRestrictionRules();
        if (carrierRestrictionRule != null) {
            return carrierRestrictionRule.getAllowedCarriers();
        }
        return new ArrayList<CarrierIdentifier>(0);
    }

    /**
     * Get the allowed carrier list and the excluded carrier list indicating the priority between
     * the two lists.
     * Require system privileges. In the future we may add this to carrier APIs.
     *
     * <p>This method returns valid data on devices with {@link
     * android.content.pm.PackageManager#FEATURE_TELEPHONY_CARRIERLOCK} enabled.
     *
     * @return {@link CarrierRestrictionRules} which contains the allowed carrier list and the
     * excluded carrier list with the priority between the two lists. Returns {@code null}
     * in case of error.
     * @hide
     */
    @SystemApi
    @RequiresPermission(android.Manifest.permission.READ_PRIVILEGED_PHONE_STATE)
    @Nullable
    public CarrierRestrictionRules getCarrierRestrictionRules() {
        try {
        try {
            ITelephony service = getITelephony();
            ITelephony service = getITelephony();
            if (service != null) {
            if (service != null) {
                return service.getAllowedCarriers(slotIndex);
                return service.getAllowedCarriers();
            }
            }
        } catch (RemoteException e) {
        } catch (RemoteException e) {
            Log.e(TAG, "Error calling ITelephony#getAllowedCarriers", e);
            Log.e(TAG, "Error calling ITelephony#getAllowedCarriers", e);
        } catch (NullPointerException e) {
        } catch (NullPointerException e) {
            Log.e(TAG, "Error calling ITelephony#getAllowedCarriers", e);
            Log.e(TAG, "Error calling ITelephony#getAllowedCarriers", e);
        }
        }
        return new ArrayList<CarrierIdentifier>(0);
        return null;
    }
    }


    /**
    /**
+16 −10
Original line number Original line Diff line number Diff line
@@ -28,6 +28,7 @@ import android.net.Uri;
import android.service.carrier.CarrierIdentifier;
import android.service.carrier.CarrierIdentifier;
import android.telecom.PhoneAccount;
import android.telecom.PhoneAccount;
import android.telecom.PhoneAccountHandle;
import android.telecom.PhoneAccountHandle;
import android.telephony.CarrierRestrictionRules;
import android.telephony.CellInfo;
import android.telephony.CellInfo;
import android.telephony.ClientRequestStats;
import android.telephony.ClientRequestStats;
import android.telephony.IccOpenLogicalChannelResponse;
import android.telephony.IccOpenLogicalChannelResponse;
@@ -1292,22 +1293,27 @@ interface ITelephony {
    List<TelephonyHistogram> getTelephonyHistograms();
    List<TelephonyHistogram> getTelephonyHistograms();


    /**
    /**
     * Set the allowed carrier list for slotIndex
     * Set the allowed carrier list and the excluded carrier list, indicating the priority between
     * Require system privileges. In the future we may add this to carrier APIs.
     * the two lists.
     *
     *
     * @return The number of carriers set successfully. Should match length of
     * <p>Requires system privileges. In the future we may add this to carrier APIs.
     * carriers on success.
     *
     * @return {@link #SET_CARRIER_RESTRICTION_SUCCESS} in case of success.
     * {@link #SET_CARRIER_RESTRICTION_NOT_SUPPORTED} if the modem does not support the
     * configuration. {@link #SET_CARRIER_RESTRICTION_ERROR} in all other error cases.
     */
     */
    int setAllowedCarriers(int slotIndex, in List<CarrierIdentifier> carriers);
    int setAllowedCarriers(in CarrierRestrictionRules carrierRestrictionRules);


    /**
    /**
     * Get the allowed carrier list for slotIndex.
     * Get the allowed carrier list and the excluded carrier list indicating the priority between
     * Require system privileges. In the future we may add this to carrier APIs.
     * the two lists.
     *
     * <p>Requires system privileges. In the future we may add this to carrier APIs.
     *
     *
     * @return List of {@link android.service.carrier.CarrierIdentifier}; empty list
     * @return {@link CarrierRestrictionRules}; empty lists mean all carriers are allowed. It
     * means all carriers are allowed.
     * returns null in case of error.
     */
     */
    List<CarrierIdentifier> getAllowedCarriers(int slotIndex);
    CarrierRestrictionRules getAllowedCarriers();


   /**
   /**
     * Returns carrier id of the given subscription.
     * Returns carrier id of the given subscription.