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

Commit ac517216 authored by Meng Wang's avatar Meng Wang Committed by Android (Google) Code Review
Browse files

Merge "Add API setAllowedCarriers, getAllowedCarriers to TelephonyManager" into nyc-mr1-dev

parents f2f98674 64997623
Loading
Loading
Loading
Loading
+9 −0
Original line number Diff line number Diff line
@@ -126,4 +126,13 @@ public class CarrierIdentifier implements Parcelable {
        mGid1 = in.readString();
        mGid2 = in.readString();
    }

    /** @hide */
    public interface MatchType {
        int ALL = 0;
        int SPN = 1;
        int IMSI_PREFIX = 2;
        int GID1 = 3;
        int GID2 = 4;
    }
}
+42 −0
Original line number Diff line number Diff line
@@ -34,6 +34,7 @@ import android.os.Bundle;
import android.os.RemoteException;
import android.os.ServiceManager;
import android.os.SystemProperties;
import android.service.carrier.CarrierIdentifier;
import android.telecom.PhoneAccount;
import android.telecom.PhoneAccountHandle;
import android.telephony.TelephonyHistogram;
@@ -51,6 +52,7 @@ import com.android.internal.telephony.TelephonyProperties;

import java.io.FileInputStream;
import java.io.IOException;
import java.util.ArrayList;
import java.util.Collections;
import java.util.List;
import java.util.regex.Matcher;
@@ -5458,4 +5460,44 @@ public class TelephonyManager {
        }
        return null;
    }

    /**
     * Set the allowed carrier list for slotId
     * Require system privileges. In the future we may add this to carrier APIs.
     *
     * @return The number of carriers set successfully. Should be length of
     * carrierList on success; -1 on error.
     * @hide
     */
    public int setAllowedCarriers(int slotId, List<CarrierIdentifier> carriers) {
        try {
            ITelephony service = getITelephony();
            if (service != null) {
                return service.setAllowedCarriers(slotId, carriers);
            }
        } catch (RemoteException e) {
            Log.e(TAG, "Error calling ITelephony#setAllowedCarriers", e);
        }
        return -1;
    }

    /**
     * Get the allowed carrier list for slotId.
     * Require system privileges. In the future we may add this to carrier APIs.
     *
     * @return List of {@link android.telephony.CarrierIdentifier}; empty list
     * means all carriers are allowed.
     * @hide
     */
    public List<CarrierIdentifier> getAllowedCarriers(int slotId) {
        try {
            ITelephony service = getITelephony();
            if (service != null) {
                return service.getAllowedCarriers(slotId);
            }
        } catch (RemoteException e) {
            Log.e(TAG, "Error calling ITelephony#getAllowedCarriers", e);
        }
        return new ArrayList<CarrierIdentifier>(0);
    }
}
+19 −0
Original line number Diff line number Diff line
@@ -20,6 +20,7 @@ import android.content.Intent;
import android.os.Bundle;
import android.os.ResultReceiver;
import android.net.Uri;
import android.service.carrier.CarrierIdentifier;
import android.telecom.PhoneAccount;
import android.telecom.PhoneAccountHandle;
import android.telephony.CellInfo;
@@ -1118,4 +1119,22 @@ interface ITelephony {
     * Or the calling app has carrier privileges.
     */
    List<TelephonyHistogram> getTelephonyHistograms();

    /**
     * Set the allowed carrier list for slotId
     * Require system privileges. In the future we may add this to carrier APIs.
     *
     * @return The number of carriers set successfully. Should match length of
     * carriers on success.
     */
    int setAllowedCarriers(int slotId, in List<CarrierIdentifier> carriers);

    /**
     * Get the allowed carrier list for slotId.
     * Require system privileges. In the future we may add this to carrier APIs.
     *
     * @return List of {@link android.service.carrier.CarrierIdentifier}; empty list
     * means all carriers are allowed.
     */
    List<CarrierIdentifier> getAllowedCarriers(int slotId);
}
+2 −0
Original line number Diff line number Diff line
@@ -409,6 +409,8 @@ cat include/telephony/ril.h | \
    int RIL_REQUEST_STOP_LCE = 133;
    int RIL_REQUEST_PULL_LCEDATA = 134;
    int RIL_REQUEST_GET_ACTIVITY_INFO = 135;
    int RIL_REQUEST_SET_ALLOWED_CARRIERS = 136;
    int RIL_REQUEST_GET_ALLOWED_CARRIERS = 137;

    int RIL_RESPONSE_ACKNOWLEDGEMENT = 800;