Merge "integrate carrier id to carrier config"

This commit is contained in:
Chen Xu
2018-11-22 05:06:55 +00:00
committed by Gerrit Code Review
4 changed files with 98 additions and 19 deletions

View File

@@ -19,6 +19,7 @@ package android.service.carrier;
import android.annotation.Nullable; import android.annotation.Nullable;
import android.os.Parcel; import android.os.Parcel;
import android.os.Parcelable; import android.os.Parcelable;
import android.telephony.TelephonyManager;
import com.android.internal.telephony.uicc.IccUtils; import com.android.internal.telephony.uicc.IccUtils;
@@ -26,7 +27,10 @@ import java.util.Objects;
/** /**
* Used to pass info to CarrierConfigService implementations so they can decide what values to * Used to pass info to CarrierConfigService implementations so they can decide what values to
* return. * return. Instead of passing mcc, mnc, gid1, gid2, spn, imsi to locate carrier information,
* CarrierIdentifier also include carrier id {@link TelephonyManager#getSimCarrierId()},
* a platform-wide unique identifier for each carrier. CarrierConfigService can directly use
* carrier id as the key to look up the carrier info.
*/ */
public class CarrierIdentifier implements Parcelable { public class CarrierIdentifier implements Parcelable {
@@ -49,15 +53,40 @@ public class CarrierIdentifier implements Parcelable {
private @Nullable String mImsi; private @Nullable String mImsi;
private @Nullable String mGid1; private @Nullable String mGid1;
private @Nullable String mGid2; private @Nullable String mGid2;
private int mCarrierId = TelephonyManager.UNKNOWN_CARRIER_ID;
private int mPreciseCarrierId = TelephonyManager.UNKNOWN_CARRIER_ID;
public CarrierIdentifier(String mcc, String mnc, @Nullable String spn, @Nullable String imsi, public CarrierIdentifier(String mcc, String mnc, @Nullable String spn, @Nullable String imsi,
@Nullable String gid1, @Nullable String gid2) { @Nullable String gid1, @Nullable String gid2) {
this(mcc, mnc, spn, imsi, gid1, gid2, TelephonyManager.UNKNOWN_CARRIER_ID,
TelephonyManager.UNKNOWN_CARRIER_ID);
}
/**
* @param mcc mobile country code
* @param mnc mobile network code
* @param spn service provider name
* @param imsi International Mobile Subscriber Identity {@link TelephonyManager#getSubscriberId()}
* @param gid1 group id level 1 {@link TelephonyManager#getGroupIdLevel1()}
* @param gid2 group id level 2
* @param carrierid carrier unique identifier {@link TelephonyManager#getSimCarrierId()}, used
* to uniquely identify the carrier and look up the carrier configurations.
* @param preciseCarrierId precise carrier identifier {@link TelephonyManager#getSimPreciseCarrierId()}
* @hide
*
* TODO: expose this to public API
*/
public CarrierIdentifier(String mcc, String mnc, @Nullable String spn,
@Nullable String imsi, @Nullable String gid1, @Nullable String gid2,
int carrierid, int preciseCarrierId) {
mMcc = mcc; mMcc = mcc;
mMnc = mnc; mMnc = mnc;
mSpn = spn; mSpn = spn;
mImsi = imsi; mImsi = imsi;
mGid1 = gid1; mGid1 = gid1;
mGid2 = gid2; mGid2 = gid2;
mCarrierId = carrierid;
mPreciseCarrierId = preciseCarrierId;
} }
/** /**
@@ -125,6 +154,22 @@ public class CarrierIdentifier implements Parcelable {
return mGid2; return mGid2;
} }
/**
* Get the carrier id {@link TelephonyManager#getSimCarrierId() }
* @hide
*/
public int getCarrierId() {
return mCarrierId;
}
/**
* Get the precise carrier id {@link TelephonyManager#getSimPreciseCarrierId()}
* @hide
*/
public int getPreciseCarrierId() {
return mPreciseCarrierId;
}
@Override @Override
public boolean equals(Object obj) { public boolean equals(Object obj) {
if (this == obj) { if (this == obj) {
@@ -140,19 +185,14 @@ public class CarrierIdentifier implements Parcelable {
&& Objects.equals(mSpn, that.mSpn) && Objects.equals(mSpn, that.mSpn)
&& Objects.equals(mImsi, that.mImsi) && Objects.equals(mImsi, that.mImsi)
&& Objects.equals(mGid1, that.mGid1) && Objects.equals(mGid1, that.mGid1)
&& Objects.equals(mGid2, that.mGid2); && Objects.equals(mGid2, that.mGid2)
&& Objects.equals(mCarrierId, that.mCarrierId)
&& Objects.equals(mPreciseCarrierId, that.mPreciseCarrierId);
} }
@Override @Override
public int hashCode() { public int hashCode(){
int result = 1; return Objects.hash(mMcc, mMnc, mSpn, mImsi, mGid1, mGid2, mCarrierId, mPreciseCarrierId);
result = 31 * result + Objects.hashCode(mMcc);
result = 31 * result + Objects.hashCode(mMnc);
result = 31 * result + Objects.hashCode(mSpn);
result = 31 * result + Objects.hashCode(mImsi);
result = 31 * result + Objects.hashCode(mGid1);
result = 31 * result + Objects.hashCode(mGid2);
return result;
} }
@Override @Override
@@ -168,18 +208,22 @@ public class CarrierIdentifier implements Parcelable {
out.writeString(mImsi); out.writeString(mImsi);
out.writeString(mGid1); out.writeString(mGid1);
out.writeString(mGid2); out.writeString(mGid2);
out.writeInt(mCarrierId);
out.writeInt(mPreciseCarrierId);
} }
@Override @Override
public String toString() { public String toString() {
return "CarrierIdentifier{" return "CarrierIdentifier{"
+ "mcc=" + mMcc + "mcc=" + mMcc
+ ",mnc=" + mMnc + ",mnc=" + mMnc
+ ",spn=" + mSpn + ",spn=" + mSpn
+ ",imsi=" + mImsi + ",imsi=" + mImsi
+ ",gid1=" + mGid1 + ",gid1=" + mGid1
+ ",gid2=" + mGid2 + ",gid2=" + mGid2
+ "}"; + ",carrierid=" + mCarrierId
+ ",mPreciseCarrierId=" + mPreciseCarrierId
+ "}";
} }
/** @hide */ /** @hide */
@@ -190,6 +234,8 @@ public class CarrierIdentifier implements Parcelable {
mImsi = in.readString(); mImsi = in.readString();
mGid1 = in.readString(); mGid1 = in.readString();
mGid2 = in.readString(); mGid2 = in.readString();
mCarrierId = in.readInt();
mPreciseCarrierId = in.readInt();
} }
/** @hide */ /** @hide */

View File

@@ -93,7 +93,11 @@ public abstract class CarrierService extends Service {
* </p> * </p>
* *
* @param id contains details about the current carrier that can be used do decide what * @param id contains details about the current carrier that can be used do decide what
* configuration values to return. * configuration values to return. Instead of using details like MCCMNC to decide
* current carrier, it also contains subscription carrier id
* {@link android.telephony.TelephonyManager#getSimCarrierId()}, a platform-wide
* unique identifier for each carrier, CarrierConfigService can directly use carrier
* id as the key to look up the carrier info.
* @return a {@link PersistableBundle} object containing the configuration or null if default * @return a {@link PersistableBundle} object containing the configuration or null if default
* values should be used. * values should be used.
*/ */

View File

@@ -8536,6 +8536,26 @@ public class TelephonyManager {
return UNKNOWN_CARRIER_ID; return UNKNOWN_CARRIER_ID;
} }
/**
* Returns carrier id based on MCCMNC only. This is for fallback when exact carrier id
* {@link #getSimCarrierId()} configurations are not found
*
* @return matching carrier id from passing mccmnc.
* @hide
*/
@RequiresPermission(android.Manifest.permission.READ_PRIVILEGED_PHONE_STATE)
public int getCarrierIdFromMccMnc(String mccmnc) {
try {
ITelephony service = getITelephony();
if (service != null) {
return service.getCarrierIdFromMccMnc(getSlotIndex(), mccmnc);
}
} catch (RemoteException ex) {
// This could happen if binder process crashes.
}
return UNKNOWN_CARRIER_ID;
}
/** /**
* Return the application ID for the uicc application type like {@link #APPTYPE_CSIM}. * Return the application ID for the uicc application type like {@link #APPTYPE_CSIM}.
* All uicc applications are uniquely identified by application ID. See ETSI 102.221 and 101.220 * All uicc applications are uniquely identified by application ID. See ETSI 102.221 and 101.220

View File

@@ -1371,6 +1371,15 @@ interface ITelephony {
*/ */
String getSubscriptionPreciseCarrierName(int subId); String getSubscriptionPreciseCarrierName(int subId);
/**
* Returns carrier id based on MCCMNC only. This will return a MNO carrier id used for fallback
* check when exact carrier id {@link #getSimCarrierId()} configurations are not found
*
* @return carrier id from passing mccmnc.
* @hide
*/
int getCarrierIdFromMccMnc(int slotIndex, String mccmnc);
/** /**
* Action set from carrier signalling broadcast receivers to enable/disable metered apns * Action set from carrier signalling broadcast receivers to enable/disable metered apns
* Permissions android.Manifest.permission.MODIFY_PHONE_STATE is required * Permissions android.Manifest.permission.MODIFY_PHONE_STATE is required