Merge "Building IMSI encryption support." into oc-mr1-dev
This commit is contained in:
committed by
Android (Google) Code Review
commit
94fa7ee972
@@ -1173,8 +1173,6 @@ public class CarrierConfigManager {
|
|||||||
/** @hide */
|
/** @hide */
|
||||||
public static final int CDMA_ROAMING_MODE_AFFILIATED = 1;
|
public static final int CDMA_ROAMING_MODE_AFFILIATED = 1;
|
||||||
/** @hide */
|
/** @hide */
|
||||||
public static final int IMSI_ENCRYPTION_DAYS_TIME_DISABLED = -1;
|
|
||||||
/** @hide */
|
|
||||||
public static final int CDMA_ROAMING_MODE_ANY = 2;
|
public static final int CDMA_ROAMING_MODE_ANY = 2;
|
||||||
/**
|
/**
|
||||||
* Boolean indicating if support is provided for directly dialing FDN number from FDN list.
|
* Boolean indicating if support is provided for directly dialing FDN number from FDN list.
|
||||||
@@ -1533,14 +1531,15 @@ public class CarrierConfigManager {
|
|||||||
public static final String IMSI_KEY_DOWNLOAD_URL_STRING = "imsi_key_download_url_string";
|
public static final String IMSI_KEY_DOWNLOAD_URL_STRING = "imsi_key_download_url_string";
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Time in days, after which the key will expire, and a new key will need to be downloaded.
|
* Identifies if the key is available for WLAN or EPDG or both. The value is a bitmask.
|
||||||
* default value is {@link IMSI_ENCRYPTION_DAYS_TIME_DISABLED}, and indicates that IMSI
|
* 0 indicates that neither EPDG or WLAN is enabled.
|
||||||
* encryption is not enabled by default for a carrier. Value of 0 indicates that the key
|
* 1 indicates that key type {@link TelephonyManager#KEY_TYPE_EPDG} is enabled.
|
||||||
* does not expire.
|
* 2 indicates that key type {@link TelephonyManager#KEY_TYPE_WLAN} is enabled.
|
||||||
|
* 3 indicates that both are enabled.
|
||||||
* @hide
|
* @hide
|
||||||
*/
|
*/
|
||||||
public static final String IMSI_KEY_EXPIRATION_DAYS_TIME_INT =
|
public static final String IMSI_KEY_AVAILABILITY_INT = "imsi_key_availability_int";
|
||||||
"imsi_key_expiration_days_time_int";
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Key identifying if the CDMA Caller ID presentation and suppression MMI codes
|
* Key identifying if the CDMA Caller ID presentation and suppression MMI codes
|
||||||
@@ -1814,7 +1813,7 @@ public class CarrierConfigManager {
|
|||||||
sDefaults.putInt(KEY_LTE_EARFCNS_RSRP_BOOST_INT, 0);
|
sDefaults.putInt(KEY_LTE_EARFCNS_RSRP_BOOST_INT, 0);
|
||||||
sDefaults.putStringArray(KEY_BOOSTED_LTE_EARFCNS_STRING_ARRAY, null);
|
sDefaults.putStringArray(KEY_BOOSTED_LTE_EARFCNS_STRING_ARRAY, null);
|
||||||
sDefaults.putBoolean(KEY_DISABLE_VOICE_BARRING_NOTIFICATION_BOOL, false);
|
sDefaults.putBoolean(KEY_DISABLE_VOICE_BARRING_NOTIFICATION_BOOL, false);
|
||||||
sDefaults.putInt(IMSI_KEY_EXPIRATION_DAYS_TIME_INT, IMSI_ENCRYPTION_DAYS_TIME_DISABLED);
|
sDefaults.putInt(IMSI_KEY_AVAILABILITY_INT, 0);
|
||||||
sDefaults.putString(IMSI_KEY_DOWNLOAD_URL_STRING, null);
|
sDefaults.putString(IMSI_KEY_DOWNLOAD_URL_STRING, null);
|
||||||
sDefaults.putBoolean(KEY_CONVERT_CDMA_CALLER_ID_MMI_CODES_WHILE_ROAMING_ON_3GPP_BOOL,
|
sDefaults.putBoolean(KEY_CONVERT_CDMA_CALLER_ID_MMI_CODES_WHILE_ROAMING_ON_3GPP_BOOL,
|
||||||
false);
|
false);
|
||||||
|
|||||||
@@ -137,7 +137,7 @@ public class TelephonyManager {
|
|||||||
|
|
||||||
|
|
||||||
/** @hide */
|
/** @hide */
|
||||||
static public final int KEY_TYPE_EPDDG = 1;
|
static public final int KEY_TYPE_EPDG = 1;
|
||||||
|
|
||||||
/** @hide */
|
/** @hide */
|
||||||
static public final int KEY_TYPE_WLAN = 2;
|
static public final int KEY_TYPE_WLAN = 2;
|
||||||
@@ -2373,33 +2373,75 @@ public class TelephonyManager {
|
|||||||
* Requires Permission:
|
* Requires Permission:
|
||||||
* {@link android.Manifest.permission#READ_PHONE_STATE READ_PHONE_STATE}
|
* {@link android.Manifest.permission#READ_PHONE_STATE READ_PHONE_STATE}
|
||||||
* @param keyType whether the key is being used for wlan or epdg. Valid key types are
|
* @param keyType whether the key is being used for wlan or epdg. Valid key types are
|
||||||
* {@link TelephonyManager#KEY_TYPE_EPDDG} or
|
* {@link TelephonyManager#KEY_TYPE_EPDG} or
|
||||||
* {@link TelephonyManager#KEY_TYPE_WLAN}.
|
* {@link TelephonyManager#KEY_TYPE_WLAN}.
|
||||||
* @return ImsiEncryptionInfo Carrier specific information that will be used to encrypt the
|
* @return ImsiEncryptionInfo Carrier specific information that will be used to encrypt the
|
||||||
* IMSI and IMPI. This includes the public key and the key identifier. This information
|
* IMSI and IMPI. This includes the public key and the key identifier. This information
|
||||||
* will be stored in the device keystore.
|
* will be stored in the device keystore. The system will return a null when no key was
|
||||||
|
* found, and the carrier does not require a key. The system will throw the following
|
||||||
|
* exceptions:
|
||||||
|
* 1. IllegalArgumentException when an invalid key is sent.
|
||||||
|
* 2. RuntimeException if the key is required but not found; and also if there was an
|
||||||
|
* internal exception.
|
||||||
* @hide
|
* @hide
|
||||||
*/
|
*/
|
||||||
public ImsiEncryptionInfo getCarrierInfoForImsiEncryption(int keyType) {
|
public ImsiEncryptionInfo getCarrierInfoForImsiEncryption(int keyType) {
|
||||||
try {
|
try {
|
||||||
IPhoneSubInfo info = getSubscriberInfo();
|
IPhoneSubInfo info = getSubscriberInfo();
|
||||||
if (info == null) return null;
|
if (info == null) {
|
||||||
int subId = getSubId(SubscriptionManager.getDefaultDataSubscriptionId());
|
throw new RuntimeException("IMSI error: Subscriber Info is null");
|
||||||
if (keyType != KEY_TYPE_EPDDG && keyType != KEY_TYPE_WLAN) {
|
|
||||||
throw new IllegalArgumentException("Invalid key type");
|
|
||||||
}
|
}
|
||||||
return info.getCarrierInfoForImsiEncryption(subId, keyType,
|
int subId = getSubId(SubscriptionManager.getDefaultDataSubscriptionId());
|
||||||
mContext.getOpPackageName());
|
if (keyType != KEY_TYPE_EPDG && keyType != KEY_TYPE_WLAN) {
|
||||||
|
throw new IllegalArgumentException("IMSI error: Invalid key type");
|
||||||
|
}
|
||||||
|
ImsiEncryptionInfo imsiEncryptionInfo = info.getCarrierInfoForImsiEncryption(
|
||||||
|
subId, keyType, mContext.getOpPackageName());
|
||||||
|
if (imsiEncryptionInfo == null
|
||||||
|
&& isImsiEncryptionRequired(subId, keyType)) {
|
||||||
|
Rlog.e(TAG, "IMSI error: key is required but not found");
|
||||||
|
throw new RuntimeException("IMSI error: key is required but not found");
|
||||||
|
}
|
||||||
|
return imsiEncryptionInfo;
|
||||||
} catch (RemoteException ex) {
|
} catch (RemoteException ex) {
|
||||||
Rlog.e(TAG, "getCarrierInfoForImsiEncryption RemoteException", ex);
|
Rlog.e(TAG, "getCarrierInfoForImsiEncryption RemoteException" + ex);
|
||||||
return null;
|
throw new RuntimeException("IMSI error: Remote Exception");
|
||||||
} catch (NullPointerException ex) {
|
} catch (NullPointerException ex) {
|
||||||
// This could happen before phone restarts due to crashing
|
// This could happen before phone restarts due to crashing
|
||||||
Rlog.e(TAG, "getCarrierInfoForImsiEncryption NullPointerException", ex);
|
Rlog.e(TAG, "getCarrierInfoForImsiEncryption NullPointerException" + ex);
|
||||||
return null;
|
throw new RuntimeException("IMSI error: Null Pointer exception");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @param keyAvailability bitmask that defines the availabilty of keys for a type.
|
||||||
|
* @param keyType the key type which is being checked. (WLAN, EPDG)
|
||||||
|
* @return true if the digit at position keyType is 1, else false.
|
||||||
|
* @hide
|
||||||
|
*/
|
||||||
|
private static boolean isKeyEnabled(int keyAvailability, int keyType) {
|
||||||
|
int returnValue = (keyAvailability >> (keyType - 1)) & 1;
|
||||||
|
return (returnValue == 1) ? true : false;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* If Carrier requires Imsi to be encrypted.
|
||||||
|
* @hide
|
||||||
|
*/
|
||||||
|
private boolean isImsiEncryptionRequired(int subId, int keyType) {
|
||||||
|
CarrierConfigManager configManager =
|
||||||
|
(CarrierConfigManager) mContext.getSystemService(Context.CARRIER_CONFIG_SERVICE);
|
||||||
|
if (configManager == null) {
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
PersistableBundle pb = configManager.getConfigForSubId(subId);
|
||||||
|
if (pb == null) {
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
int keyAvailability = pb.getInt(CarrierConfigManager.IMSI_KEY_AVAILABILITY_INT);
|
||||||
|
return isKeyEnabled(keyAvailability, keyType);
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Sets the Carrier specific information that will be used to encrypt the IMSI and IMPI.
|
* Sets the Carrier specific information that will be used to encrypt the IMSI and IMPI.
|
||||||
* This includes the public key and the key identifier. This information will be stored in the
|
* This includes the public key and the key identifier. This information will be stored in the
|
||||||
|
|||||||
Reference in New Issue
Block a user