summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
author chen xu <fionaxu@google.com> 2018-11-11 19:01:50 -0800
committer chen xu <fionaxu@google.com> 2018-11-21 11:09:40 -0800
commited7a2e1e41e0ad7d6b237fedf96e098eb915b84d (patch)
treeb142c4d9228fbbaca7e5d1c5083387f0fe170f36
parentbef825878c1c5885c3fb87c8940a8ab06692a7e3 (diff)
integrate carrier id to carrier config
add carrierId and preciseCarrierId in CarrierIdentifier which will be passed to carrier service to decide which carrier info to look up Bug: 110559381 Change-Id: I1b4a44dd32148ebdf5aa437c5938cb89656c27c2
-rw-r--r--core/java/android/service/carrier/CarrierIdentifier.java82
-rw-r--r--core/java/android/service/carrier/CarrierService.java6
-rw-r--r--telephony/java/android/telephony/TelephonyManager.java20
-rw-r--r--telephony/java/com/android/internal/telephony/ITelephony.aidl11
4 files changed, 99 insertions, 20 deletions
diff --git a/core/java/android/service/carrier/CarrierIdentifier.java b/core/java/android/service/carrier/CarrierIdentifier.java
index 09bba4b459f6..e930f401ecd5 100644
--- a/core/java/android/service/carrier/CarrierIdentifier.java
+++ b/core/java/android/service/carrier/CarrierIdentifier.java
@@ -19,6 +19,7 @@ package android.service.carrier;
import android.annotation.Nullable;
import android.os.Parcel;
import android.os.Parcelable;
+import android.telephony.TelephonyManager;
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
- * 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 {
@@ -49,15 +53,40 @@ public class CarrierIdentifier implements Parcelable {
private @Nullable String mImsi;
private @Nullable String mGid1;
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,
@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;
mMnc = mnc;
mSpn = spn;
mImsi = imsi;
mGid1 = gid1;
mGid2 = gid2;
+ mCarrierId = carrierid;
+ mPreciseCarrierId = preciseCarrierId;
}
/**
@@ -125,6 +154,22 @@ public class CarrierIdentifier implements Parcelable {
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
public boolean equals(Object obj) {
if (this == obj) {
@@ -140,19 +185,14 @@ public class CarrierIdentifier implements Parcelable {
&& Objects.equals(mSpn, that.mSpn)
&& Objects.equals(mImsi, that.mImsi)
&& 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
- public int hashCode() {
- int result = 1;
- 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;
+ public int hashCode(){
+ return Objects.hash(mMcc, mMnc, mSpn, mImsi, mGid1, mGid2, mCarrierId, mPreciseCarrierId);
}
@Override
@@ -168,18 +208,22 @@ public class CarrierIdentifier implements Parcelable {
out.writeString(mImsi);
out.writeString(mGid1);
out.writeString(mGid2);
+ out.writeInt(mCarrierId);
+ out.writeInt(mPreciseCarrierId);
}
@Override
public String toString() {
return "CarrierIdentifier{"
- + "mcc=" + mMcc
- + ",mnc=" + mMnc
- + ",spn=" + mSpn
- + ",imsi=" + mImsi
- + ",gid1=" + mGid1
- + ",gid2=" + mGid2
- + "}";
+ + "mcc=" + mMcc
+ + ",mnc=" + mMnc
+ + ",spn=" + mSpn
+ + ",imsi=" + mImsi
+ + ",gid1=" + mGid1
+ + ",gid2=" + mGid2
+ + ",carrierid=" + mCarrierId
+ + ",mPreciseCarrierId=" + mPreciseCarrierId
+ + "}";
}
/** @hide */
@@ -190,6 +234,8 @@ public class CarrierIdentifier implements Parcelable {
mImsi = in.readString();
mGid1 = in.readString();
mGid2 = in.readString();
+ mCarrierId = in.readInt();
+ mPreciseCarrierId = in.readInt();
}
/** @hide */
diff --git a/core/java/android/service/carrier/CarrierService.java b/core/java/android/service/carrier/CarrierService.java
index b94ccf9e8223..c351d891bc61 100644
--- a/core/java/android/service/carrier/CarrierService.java
+++ b/core/java/android/service/carrier/CarrierService.java
@@ -93,7 +93,11 @@ public abstract class CarrierService extends Service {
* </p>
*
* @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
* values should be used.
*/
diff --git a/telephony/java/android/telephony/TelephonyManager.java b/telephony/java/android/telephony/TelephonyManager.java
index a188ef63e3ed..c86bc93c9375 100644
--- a/telephony/java/android/telephony/TelephonyManager.java
+++ b/telephony/java/android/telephony/TelephonyManager.java
@@ -8469,6 +8469,26 @@ public class TelephonyManager {
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}.
* All uicc applications are uniquely identified by application ID. See ETSI 102.221 and 101.220
diff --git a/telephony/java/com/android/internal/telephony/ITelephony.aidl b/telephony/java/com/android/internal/telephony/ITelephony.aidl
index 3aaa32344e0b..a8fcc0b5b207 100644
--- a/telephony/java/com/android/internal/telephony/ITelephony.aidl
+++ b/telephony/java/com/android/internal/telephony/ITelephony.aidl
@@ -1354,6 +1354,15 @@ interface ITelephony {
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
* Permissions android.Manifest.permission.MODIFY_PHONE_STATE is required
* @param subId the subscription ID that this action applies to.
@@ -1686,7 +1695,7 @@ interface ITelephony {
* Identify if the number is emergency number, based on all the active subscriptions.
*/
boolean isCurrentEmergencyNumber(String number);
-
+
/**
* Return a list of certs in hex string from loaded carrier privileges access rules.
*/