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

This commit is contained in:
Meng Wang
2016-05-20 22:17:10 +00:00
committed by Android (Google) Code Review
4 changed files with 72 additions and 0 deletions

View File

@@ -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;
}
}

View File

@@ -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);
}
}

View File

@@ -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);
}

View File

@@ -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;