summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
author Meng Wang <mewan@google.com> 2020-01-08 02:26:44 +0000
committer Android (Google) Code Review <android-gerrit@google.com> 2020-01-08 02:26:44 +0000
commit1ce0f39441f7740bf6fc4c29c8d6fba9ea4664f0 (patch)
treed6921615eaa4e220bca0c8f1922bdeb5180d0925
parentceac080656a2750e018c27415a398d5065440147 (diff)
parentdd43acc58fd53792eab07d4e9bb21b4b6a8be72b (diff)
Merge "ANY_DATA_CONNECTION_STATE_CHANGED: define locally"
-rw-r--r--core/java/android/telephony/TelephonyRegistryManager.java9
-rw-r--r--core/java/com/android/internal/telephony/ITelephonyRegistry.aidl4
-rw-r--r--services/core/java/com/android/server/TelephonyRegistry.java78
3 files changed, 67 insertions, 24 deletions
diff --git a/core/java/android/telephony/TelephonyRegistryManager.java b/core/java/android/telephony/TelephonyRegistryManager.java
index b94475ac05ce..9387a2c79c6c 100644
--- a/core/java/android/telephony/TelephonyRegistryManager.java
+++ b/core/java/android/telephony/TelephonyRegistryManager.java
@@ -24,6 +24,7 @@ import android.content.Context;
import android.os.Binder;
import android.os.RemoteException;
import android.os.ServiceManager;
+import android.telephony.Annotation.ApnType;
import android.telephony.Annotation.CallState;
import android.telephony.Annotation.DataActivityType;
import android.telephony.Annotation.DataFailureCause;
@@ -352,7 +353,7 @@ public class TelephonyRegistryManager {
* @param subId for which data connection state changed.
* @param slotIndex for which data connections state changed. Can be derived from subId except
* when subId is invalid.
- * @param apnType the APN type that triggered this update
+ * @param apnType the apn type bitmask, defined with {@code ApnSetting#TYPE_*} flags.
* @param preciseState the PreciseDataConnectionState
*
* @see android.telephony.PreciseDataConnection
@@ -360,7 +361,7 @@ public class TelephonyRegistryManager {
* @hide
*/
public void notifyDataConnectionForSubscriber(int slotIndex, int subId,
- String apnType, PreciseDataConnectionState preciseState) {
+ @ApnType int apnType, PreciseDataConnectionState preciseState) {
try {
sRegistry.notifyDataConnectionForSubscriber(
slotIndex, subId, apnType, preciseState);
@@ -553,13 +554,13 @@ public class TelephonyRegistryManager {
* @param subId for which data connection failed.
* @param slotIndex for which data conenction failed. Can be derived from subId except when
* subId is invalid.
- * @param apnType the apnType, "ims" for IMS APN, "emergency" for EMERGENCY APN.
+ * @param apnType the apn type bitmask, defined with {@code ApnSetting#TYPE_*} flags.
* @param apn the APN {@link ApnSetting#getApnName()} of this data connection.
* @param failCause data fail cause.
*
* @hide
*/
- public void notifyPreciseDataConnectionFailed(int subId, int slotIndex, String apnType,
+ public void notifyPreciseDataConnectionFailed(int subId, int slotIndex, @ApnType int apnType,
String apn, @DataFailureCause int failCause) {
try {
sRegistry.notifyPreciseDataConnectionFailed(slotIndex, subId, apnType, apn, failCause);
diff --git a/core/java/com/android/internal/telephony/ITelephonyRegistry.aidl b/core/java/com/android/internal/telephony/ITelephonyRegistry.aidl
index 6933f166a06d..8e97ae1e4bd1 100644
--- a/core/java/com/android/internal/telephony/ITelephonyRegistry.aidl
+++ b/core/java/com/android/internal/telephony/ITelephonyRegistry.aidl
@@ -63,7 +63,7 @@ interface ITelephonyRegistry {
void notifyDataActivity(int state);
void notifyDataActivityForSubscriber(in int subId, int state);
void notifyDataConnectionForSubscriber(
- int phoneId, int subId, String apnType, in PreciseDataConnectionState preciseState);
+ int phoneId, int subId, int apnType, in PreciseDataConnectionState preciseState);
@UnsupportedAppUsage
void notifyDataConnectionFailed(String apnType);
// Uses CellIdentity which is Parcelable here; will convert to CellLocation in client.
@@ -75,7 +75,7 @@ interface ITelephonyRegistry {
int foregroundCallState, int backgroundCallState);
void notifyDisconnectCause(int phoneId, int subId, int disconnectCause,
int preciseDisconnectCause);
- void notifyPreciseDataConnectionFailed(int phoneId, int subId, String apnType, String apn,
+ void notifyPreciseDataConnectionFailed(int phoneId, int subId, int apnType, String apn,
int failCause);
void notifyCellInfoForSubscriber(in int subId, in List<CellInfo> cellInfo);
void notifySrvccStateChanged(in int subId, in int lteState);
diff --git a/services/core/java/com/android/server/TelephonyRegistry.java b/services/core/java/com/android/server/TelephonyRegistry.java
index 25bad641adf9..3e6ccb572860 100644
--- a/services/core/java/com/android/server/TelephonyRegistry.java
+++ b/services/core/java/com/android/server/TelephonyRegistry.java
@@ -42,6 +42,7 @@ import android.os.Message;
import android.os.RemoteException;
import android.os.UserHandle;
import android.telephony.Annotation;
+import android.telephony.Annotation.ApnType;
import android.telephony.Annotation.DataFailureCause;
import android.telephony.Annotation.RadioPowerState;
import android.telephony.Annotation.SrvccState;
@@ -82,7 +83,6 @@ import com.android.internal.app.IBatteryStats;
import com.android.internal.telephony.IOnSubscriptionsChangedListener;
import com.android.internal.telephony.IPhoneStateListener;
import com.android.internal.telephony.ITelephonyRegistry;
-import com.android.internal.telephony.PhoneConstants;
import com.android.internal.telephony.TelephonyIntents;
import com.android.internal.telephony.TelephonyPermissions;
import com.android.internal.util.ArrayUtils;
@@ -269,8 +269,8 @@ public class TelephonyRegistry extends ITelephonyRegistry.Stub {
private final LocalLog mListenLog = new LocalLog(100);
// Per-phoneMap of APN Type to DataConnectionState
- private List<Map<String, PreciseDataConnectionState>> mPreciseDataConnectionStates =
- new ArrayList<Map<String, PreciseDataConnectionState>>();
+ private List<Map<Integer, PreciseDataConnectionState>> mPreciseDataConnectionStates =
+ new ArrayList<Map<Integer, PreciseDataConnectionState>>();
// Nothing here yet, but putting it here in case we want to add more in the future.
static final int ENFORCE_COARSE_LOCATION_PERMISSION_MASK = 0;
@@ -467,7 +467,7 @@ public class TelephonyRegistry extends ITelephonyRegistry.Stub {
mRingingCallState[i] = PreciseCallState.PRECISE_CALL_STATE_IDLE;
mForegroundCallState[i] = PreciseCallState.PRECISE_CALL_STATE_IDLE;
mBackgroundCallState[i] = PreciseCallState.PRECISE_CALL_STATE_IDLE;
- mPreciseDataConnectionStates.add(new HashMap<String, PreciseDataConnectionState>());
+ mPreciseDataConnectionStates.add(new HashMap<Integer, PreciseDataConnectionState>());
}
}
@@ -551,7 +551,7 @@ public class TelephonyRegistry extends ITelephonyRegistry.Stub {
mRingingCallState[i] = PreciseCallState.PRECISE_CALL_STATE_IDLE;
mForegroundCallState[i] = PreciseCallState.PRECISE_CALL_STATE_IDLE;
mBackgroundCallState[i] = PreciseCallState.PRECISE_CALL_STATE_IDLE;
- mPreciseDataConnectionStates.add(new HashMap<String, PreciseDataConnectionState>());
+ mPreciseDataConnectionStates.add(new HashMap<Integer, PreciseDataConnectionState>());
}
mAppOps = mContext.getSystemService(AppOpsManager.class);
@@ -1496,11 +1496,12 @@ public class TelephonyRegistry extends ITelephonyRegistry.Stub {
*
* @param phoneId the phoneId carrying the data connection
* @param subId the subscriptionId for the data connection
- * @param apnType the APN type that triggered a change in the data connection
+ * @param apnType the apn type bitmask, defined with {@code ApnSetting#TYPE_*} flags.
* @param preciseState a PreciseDataConnectionState that has info about the data connection
*/
+ @Override
public void notifyDataConnectionForSubscriber(
- int phoneId, int subId, String apnType, PreciseDataConnectionState preciseState) {
+ int phoneId, int subId, @ApnType int apnType, PreciseDataConnectionState preciseState) {
if (!checkNotifyPermission("notifyDataConnection()" )) {
return;
}
@@ -1526,7 +1527,7 @@ public class TelephonyRegistry extends ITelephonyRegistry.Stub {
synchronized (mRecords) {
if (validatePhoneId(phoneId)) {
// We only call the callback when the change is for default APN type.
- if (PhoneConstants.APN_TYPE_DEFAULT.equals(apnType)
+ if ((ApnSetting.TYPE_DEFAULT & apnType) != 0
&& (mDataConnectionState[phoneId] != state
|| mDataConnectionNetworkType[phoneId] != networkType)) {
String str = "onDataConnectionStateChanged("
@@ -1595,7 +1596,7 @@ public class TelephonyRegistry extends ITelephonyRegistry.Stub {
loge("This function should not be invoked");
}
- private void notifyDataConnectionFailedForSubscriber(int phoneId, int subId, String apnType) {
+ private void notifyDataConnectionFailedForSubscriber(int phoneId, int subId, int apnType) {
if (!checkNotifyPermission("notifyDataConnectionFailed()")) {
return;
}
@@ -1610,7 +1611,7 @@ public class TelephonyRegistry extends ITelephonyRegistry.Stub {
new PreciseDataConnectionState(
TelephonyManager.DATA_UNKNOWN,
TelephonyManager.NETWORK_TYPE_UNKNOWN,
- ApnSetting.getApnTypesBitmaskFromString(apnType), null, null,
+ apnType, null, null,
DataFailCause.NONE, null));
for (Record r : mRecords) {
if (r.matchPhoneStateListenerEvent(
@@ -1779,7 +1780,8 @@ public class TelephonyRegistry extends ITelephonyRegistry.Stub {
}
}
- public void notifyPreciseDataConnectionFailed(int phoneId, int subId, String apnType,
+ @Override
+ public void notifyPreciseDataConnectionFailed(int phoneId, int subId, @ApnType int apnType,
String apn, @DataFailureCause int failCause) {
if (!checkNotifyPermission("notifyPreciseDataConnectionFailed()")) {
return;
@@ -1795,7 +1797,7 @@ public class TelephonyRegistry extends ITelephonyRegistry.Stub {
new PreciseDataConnectionState(
TelephonyManager.DATA_UNKNOWN,
TelephonyManager.NETWORK_TYPE_UNKNOWN,
- ApnSetting.getApnTypesBitmaskFromString(apnType), null, null,
+ apnType, null, null,
failCause, null));
for (Record r : mRecords) {
if (r.matchPhoneStateListenerEvent(
@@ -2177,10 +2179,19 @@ public class TelephonyRegistry extends ITelephonyRegistry.Stub {
/** Fired when a subscription's phone state changes. */
private static final String ACTION_SUBSCRIPTION_PHONE_STATE_CHANGED =
"android.intent.action.SUBSCRIPTION_PHONE_STATE";
+ /**
+ * Broadcast Action: The data connection state has changed for any one of the
+ * phone's mobile data connections (eg, default, MMS or GPS specific connection).
+ */
+ private static final String ACTION_ANY_DATA_CONNECTION_STATE_CHANGED =
+ "android.intent.action.ANY_DATA_STATE";
// Legacy intent extra keys, copied from PhoneConstants.
// Used in legacy intents sent here, for backward compatibility.
+ private static final String PHONE_CONSTANTS_DATA_APN_TYPE_KEY = "apnType";
+ private static final String PHONE_CONSTANTS_DATA_APN_KEY = "apn";
private static final String PHONE_CONSTANTS_SLOT_KEY = "slot";
+ private static final String PHONE_CONSTANTS_STATE_KEY = "state";
private static final String PHONE_CONSTANTS_SUBSCRIPTION_KEY = "subscription";
private void broadcastServiceStateChanged(ServiceState state, int phoneId, int subId) {
@@ -2318,19 +2329,50 @@ public class TelephonyRegistry extends ITelephonyRegistry.Stub {
}
private void broadcastDataConnectionStateChanged(int state, String apn,
- String apnType, int subId) {
+ int apnType, int subId) {
// Note: not reporting to the battery stats service here, because the
// status bar takes care of that after taking into account all of the
// required info.
- Intent intent = new Intent(TelephonyIntents.ACTION_ANY_DATA_CONNECTION_STATE_CHANGED);
- intent.putExtra(TelephonyManager.EXTRA_STATE, dataStateToString(state));
-
- intent.putExtra(PhoneConstants.DATA_APN_KEY, apn);
- intent.putExtra(PhoneConstants.DATA_APN_TYPE_KEY, apnType);
+ Intent intent = new Intent(ACTION_ANY_DATA_CONNECTION_STATE_CHANGED);
+ intent.putExtra(PHONE_CONSTANTS_STATE_KEY, dataStateToString(state));
+ intent.putExtra(PHONE_CONSTANTS_DATA_APN_KEY, apn);
+ intent.putExtra(PHONE_CONSTANTS_DATA_APN_TYPE_KEY, getApnTypesStringFromBitmask(apnType));
intent.putExtra(PHONE_CONSTANTS_SUBSCRIPTION_KEY, subId);
mContext.sendStickyBroadcastAsUser(intent, UserHandle.ALL);
}
+ private static final Map<Integer, String> APN_TYPE_INT_MAP;
+ static {
+ APN_TYPE_INT_MAP = new android.util.ArrayMap<Integer, String>();
+ APN_TYPE_INT_MAP.put(ApnSetting.TYPE_DEFAULT, "default");
+ APN_TYPE_INT_MAP.put(ApnSetting.TYPE_MMS, "mms");
+ APN_TYPE_INT_MAP.put(ApnSetting.TYPE_SUPL, "supl");
+ APN_TYPE_INT_MAP.put(ApnSetting.TYPE_DUN, "dun");
+ APN_TYPE_INT_MAP.put(ApnSetting.TYPE_HIPRI, "hipri");
+ APN_TYPE_INT_MAP.put(ApnSetting.TYPE_FOTA, "fota");
+ APN_TYPE_INT_MAP.put(ApnSetting.TYPE_IMS, "ims");
+ APN_TYPE_INT_MAP.put(ApnSetting.TYPE_CBS, "cbs");
+ APN_TYPE_INT_MAP.put(ApnSetting.TYPE_IA, "ia");
+ APN_TYPE_INT_MAP.put(ApnSetting.TYPE_EMERGENCY, "emergency");
+ APN_TYPE_INT_MAP.put(ApnSetting.TYPE_MCX, "mcx");
+ APN_TYPE_INT_MAP.put(ApnSetting.TYPE_XCAP, "xcap");
+ }
+
+ /**
+ * Copy of ApnSetting#getApnTypesStringFromBitmask for legacy broadcast.
+ * @param apnTypeBitmask bitmask of APN types.
+ * @return comma delimited list of APN types.
+ */
+ private static String getApnTypesStringFromBitmask(int apnTypeBitmask) {
+ List<String> types = new ArrayList<>();
+ for (Integer type : APN_TYPE_INT_MAP.keySet()) {
+ if ((apnTypeBitmask & type) == type) {
+ types.add(APN_TYPE_INT_MAP.get(type));
+ }
+ }
+ return android.text.TextUtils.join(",", types);
+ }
+
private void enforceNotifyPermissionOrCarrierPrivilege(String method) {
if (checkNotifyPermission()) {
return;