From 64997623bfa04e80064b6056fab0fb23144acb44 Mon Sep 17 00:00:00 2001 From: Meng Wang Date: Thu, 5 May 2016 09:36:47 -0700 Subject: [PATCH] Add API setAllowedCarriers, getAllowedCarriers to TelephonyManager Also: Add RIL constants RIL_REQUEST_SET_ALLOWED_CARRIERS, RIL_REQUEST_GET_ALLOWED_CARRIERS Bug: 28564314 Change-Id: Iaf6c40de633e767309c4088249a5c13cb0988c5c --- .../service/carrier/CarrierIdentifier.java | 9 ++++ .../android/telephony/TelephonyManager.java | 42 +++++++++++++++++++ .../internal/telephony/ITelephony.aidl | 19 +++++++++ .../internal/telephony/RILConstants.java | 2 + 4 files changed, 72 insertions(+) diff --git a/core/java/android/service/carrier/CarrierIdentifier.java b/core/java/android/service/carrier/CarrierIdentifier.java index a70c24d6886b2..b47e872d47f83 100644 --- a/core/java/android/service/carrier/CarrierIdentifier.java +++ b/core/java/android/service/carrier/CarrierIdentifier.java @@ -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; + } } diff --git a/telephony/java/android/telephony/TelephonyManager.java b/telephony/java/android/telephony/TelephonyManager.java index 3f47b61aebef3..6f9d571af5bf0 100644 --- a/telephony/java/android/telephony/TelephonyManager.java +++ b/telephony/java/android/telephony/TelephonyManager.java @@ -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 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 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(0); + } } diff --git a/telephony/java/com/android/internal/telephony/ITelephony.aidl b/telephony/java/com/android/internal/telephony/ITelephony.aidl index a44a094e82bc2..74b6e1449ed58 100644 --- a/telephony/java/com/android/internal/telephony/ITelephony.aidl +++ b/telephony/java/com/android/internal/telephony/ITelephony.aidl @@ -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 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 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 getAllowedCarriers(int slotId); } diff --git a/telephony/java/com/android/internal/telephony/RILConstants.java b/telephony/java/com/android/internal/telephony/RILConstants.java index cfc5305c01dce..64626541a2d3c 100644 --- a/telephony/java/com/android/internal/telephony/RILConstants.java +++ b/telephony/java/com/android/internal/telephony/RILConstants.java @@ -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;