Merge "Re-expose raw data roaming state"
diff --git a/Android.bp b/Android.bp
index 7267595..21d4c0f 100644
--- a/Android.bp
+++ b/Android.bp
@@ -71,6 +71,7 @@
srcs: [
":opt-telephony-common-srcs",
":framework-telephony-stack-shared-srcs",
+ ":net-utils-telephony-common-srcs",
"src/java/**/I*.aidl",
"src/java/**/*.logtags",
],
@@ -99,6 +100,7 @@
"ecc-protos-lite",
"libphonenumber-nogeocoder",
"PlatformProperties",
+ "net-utils-framework-common",
"telephony-protos",
],
diff --git a/jarjar-rules-shared.txt b/jarjar-rules-shared.txt
index a6e5412..65171e9 100644
--- a/jarjar-rules-shared.txt
+++ b/jarjar-rules-shared.txt
@@ -1,3 +1,4 @@
+rule android.net.NetworkFactory* com.android.internal.telephony.NetworkFactory@1
rule android.os.BasicShellCommandHandler* com.android.internal.telephony.BasicShellCommandHandler@1
rule android.os.RegistrantList* com.android.internal.telephony.RegistrantList@1
rule android.os.Registrant* com.android.internal.telephony.Registrant@1
@@ -7,6 +8,7 @@
rule android.util.TimeUtils* com.android.internal.telephony.TimeUtils@1
rule com.android.internal.os.SomeArgs* com.android.internal.telephony.SomeArgs@1
rule com.android.internal.util.AsyncChannel* com.android.internal.telephony.AsyncChannel@1
+rule com.android.internal.util.AsyncService* com.android.internal.telephony.AsyncService@1
rule com.android.internal.util.BitwiseInputStream* com.android.internal.telephony.BitwiseInputStream@1
rule com.android.internal.util.FastXmlSerializer* com.android.internal.telephony.FastXmlSerializer@1
rule com.android.internal.util.HexDump* com.android.internal.telephony.HexDump@1
diff --git a/src/java/com/android/internal/telephony/BaseCommands.java b/src/java/com/android/internal/telephony/BaseCommands.java
index b7eeaf4..2ac2ce8 100644
--- a/src/java/com/android/internal/telephony/BaseCommands.java
+++ b/src/java/com/android/internal/telephony/BaseCommands.java
@@ -102,6 +102,7 @@
protected RegistrantList mLceInfoRegistrants = new RegistrantList();
protected RegistrantList mEmergencyNumberListRegistrants = new RegistrantList();
protected RegistrantList mUiccApplicationsEnablementRegistrants = new RegistrantList();
+ protected RegistrantList mBarringInfoChangedRegistrants = new RegistrantList();
@UnsupportedAppUsage
protected Registrant mGsmSmsRegistrant;
@@ -1027,4 +1028,26 @@
public void unregisterUiccApplicationEnablementChanged(Handler h) {
mUiccApplicationsEnablementRegistrants.remove(h);
}
+
+ /**
+ * Registers the handler for RIL_UNSOL_BARRING_INFO_CHANGED events.
+ *
+ * @param h Handler for notification message.
+ * @param what User-defined message code.
+ * @param obj User object.
+ */
+ @Override
+ public void registerForBarringInfoChanged(Handler h, int what, Object obj) {
+ mBarringInfoChangedRegistrants.addUnique(h, what, obj);
+ }
+
+ /**
+ * Unregisters the handler for RIL_UNSOL_BARRING_INFO_CHANGED events.
+ *
+ * @param h Handler for notification message.
+ */
+ @Override
+ public void unregisterForBarringInfoChanged(Handler h) {
+ mBarringInfoChangedRegistrants.remove(h);
+ }
}
diff --git a/src/java/com/android/internal/telephony/CarrierSignalAgent.java b/src/java/com/android/internal/telephony/CarrierSignalAgent.java
index ba0e4c1..fd5175a 100644
--- a/src/java/com/android/internal/telephony/CarrierSignalAgent.java
+++ b/src/java/com/android/internal/telephony/CarrierSignalAgent.java
@@ -33,7 +33,6 @@
import android.os.PersistableBundle;
import android.os.UserHandle;
import android.telephony.CarrierConfigManager;
-import com.android.telephony.Rlog;
import android.telephony.SubscriptionManager;
import android.telephony.TelephonyManager;
import android.text.TextUtils;
@@ -42,6 +41,7 @@
import com.android.internal.telephony.util.ArrayUtils;
import com.android.internal.util.IndentingPrintWriter;
+import com.android.telephony.Rlog;
import java.io.FileDescriptor;
import java.io.PrintWriter;
@@ -316,8 +316,7 @@
continue;
}
- signal.putExtra(SubscriptionManager.EXTRA_SUBSCRIPTION_INDEX, mPhone.getSubId());
- signal.putExtra(PhoneConstants.SUBSCRIPTION_KEY, mPhone.getSubId());
+ SubscriptionManager.putSubscriptionIdExtra(signal, mPhone.getSubId());
signal.addFlags(Intent.FLAG_RECEIVER_FOREGROUND);
if (!wakeup) signal.setFlags(Intent.FLAG_EXCLUDE_STOPPED_PACKAGES);
diff --git a/src/java/com/android/internal/telephony/CellularNetworkValidator.java b/src/java/com/android/internal/telephony/CellularNetworkValidator.java
index 48a90ea..0530312 100644
--- a/src/java/com/android/internal/telephony/CellularNetworkValidator.java
+++ b/src/java/com/android/internal/telephony/CellularNetworkValidator.java
@@ -21,6 +21,7 @@
import android.net.Network;
import android.net.NetworkCapabilities;
import android.net.NetworkRequest;
+import android.net.TelephonyNetworkSpecifier;
import android.os.Handler;
import android.telephony.SubscriptionManager;
import android.util.Log;
@@ -193,7 +194,8 @@
return new NetworkRequest.Builder()
.addCapability(NetworkCapabilities.NET_CAPABILITY_INTERNET)
.addTransportType(NetworkCapabilities.TRANSPORT_CELLULAR)
- .setNetworkSpecifier(String.valueOf(mSubId))
+ .setNetworkSpecifier(new TelephonyNetworkSpecifier.Builder()
+ .setSubscriptionId(mSubId).build())
.build();
}
diff --git a/src/java/com/android/internal/telephony/CommandsInterface.java b/src/java/com/android/internal/telephony/CommandsInterface.java
index 126b83b..650ea6b 100644
--- a/src/java/com/android/internal/telephony/CommandsInterface.java
+++ b/src/java/com/android/internal/telephony/CommandsInterface.java
@@ -2448,4 +2448,21 @@
default List<ClientRequestStats> getClientRequestStats() {
return null;
}
+
+ /**
+ * Registers the handler for RIL_UNSOL_BARRING_INFO_CHANGED events.
+ *
+ * @param h Handler for notification message.
+ * @param what User-defined message code.
+ * @param obj User object.
+ */
+ default void registerForBarringInfoChanged(Handler h, int what, Object obj) {};
+
+ /**
+ * Unregisters the handler for RIL_UNSOL_BARRING_INFO_CHANGED events.
+ *
+ * @param h Handler for notification message.
+ */
+ default void unregisterForBarringInfoChanged(Handler h) {};
+
}
diff --git a/src/java/com/android/internal/telephony/Connection.java b/src/java/com/android/internal/telephony/Connection.java
index 5d4fad9..835b2b4 100755
--- a/src/java/com/android/internal/telephony/Connection.java
+++ b/src/java/com/android/internal/telephony/Connection.java
@@ -30,6 +30,7 @@
import com.android.ims.internal.ConferenceParticipant;
import com.android.internal.annotations.VisibleForTesting;
import com.android.internal.telephony.emergency.EmergencyNumberTracker;
+import com.android.internal.telephony.util.TelephonyUtils;
import java.util.ArrayList;
import java.util.List;
@@ -1029,7 +1030,7 @@
int previousCount = mExtras.size();
// Prevent vendors from passing in extras other than primitive types and android API
// parcelables.
- mExtras = mExtras.filterValues();
+ mExtras = TelephonyUtils.filterValues(mExtras);
int filteredCount = mExtras.size();
if (filteredCount != previousCount) {
Rlog.i(TAG, "setConnectionExtras: filtering " + (previousCount - filteredCount)
diff --git a/src/java/com/android/internal/telephony/DefaultPhoneNotifier.java b/src/java/com/android/internal/telephony/DefaultPhoneNotifier.java
index a9bc73c..1cc5a08 100644
--- a/src/java/com/android/internal/telephony/DefaultPhoneNotifier.java
+++ b/src/java/com/android/internal/telephony/DefaultPhoneNotifier.java
@@ -23,6 +23,7 @@
import android.telephony.Annotation.DataFailureCause;
import android.telephony.Annotation.RadioPowerState;
import android.telephony.Annotation.SrvccState;
+import android.telephony.BarringInfo;
import android.telephony.CallQuality;
import android.telephony.CellIdentity;
import android.telephony.CellInfo;
@@ -271,6 +272,12 @@
cellIdentity, chosenPlmn, domain, causeCode, additionalCauseCode);
}
+ @Override
+ public void notifyBarringInfoChanged(Phone sender, BarringInfo barringInfo) {
+ mTelephonyRegistryMgr.notifyBarringInfoChanged(sender.getPhoneId(), sender.getSubId(),
+ barringInfo);
+ }
+
/**
* Convert the {@link DataActivityState} enum into the TelephonyManager.DATA_* constants for the
* public API.
diff --git a/src/java/com/android/internal/telephony/GsmCdmaCallTracker.java b/src/java/com/android/internal/telephony/GsmCdmaCallTracker.java
index 2b2ff7a..e5029e4 100755
--- a/src/java/com/android/internal/telephony/GsmCdmaCallTracker.java
+++ b/src/java/com/android/internal/telephony/GsmCdmaCallTracker.java
@@ -34,7 +34,6 @@
import android.telephony.CellLocation;
import android.telephony.DisconnectCause;
import android.telephony.PhoneNumberUtils;
-import com.android.telephony.Rlog;
import android.telephony.ServiceState.RilRadioTechnology;
import android.telephony.TelephonyManager;
import android.telephony.cdma.CdmaCellLocation;
@@ -45,6 +44,7 @@
import com.android.internal.annotations.VisibleForTesting;
import com.android.internal.telephony.cdma.CdmaCallWaitingNotification;
import com.android.internal.telephony.metrics.TelephonyMetrics;
+import com.android.telephony.Rlog;
import java.io.FileDescriptor;
import java.io.PrintWriter;
@@ -119,7 +119,8 @@
if (intent.getAction().equals(
TelephonyIntents.ACTION_EMERGENCY_CALLBACK_MODE_CHANGED)) {
- boolean isInEcm = intent.getBooleanExtra(PhoneConstants.PHONE_IN_ECM_STATE, false);
+ boolean isInEcm = intent.getBooleanExtra(
+ TelephonyManager.EXTRA_PHONE_IN_ECM_STATE, false);
log("Received ACTION_EMERGENCY_CALLBACK_MODE_CHANGED isInEcm = " + isInEcm);
// If we exit ECM mode, notify all connections.
diff --git a/src/java/com/android/internal/telephony/GsmCdmaPhone.java b/src/java/com/android/internal/telephony/GsmCdmaPhone.java
index db2c426..65310d0 100644
--- a/src/java/com/android/internal/telephony/GsmCdmaPhone.java
+++ b/src/java/com/android/internal/telephony/GsmCdmaPhone.java
@@ -58,6 +58,7 @@
import android.telecom.TelecomManager;
import android.telecom.VideoProfile;
import android.telephony.AccessNetworkConstants;
+import android.telephony.BarringInfo;
import android.telephony.CarrierConfigManager;
import android.telephony.CellIdentity;
import android.telephony.DataFailCause;
@@ -65,7 +66,6 @@
import android.telephony.NetworkScanRequest;
import android.telephony.PhoneNumberUtils;
import android.telephony.PreciseDataConnectionState;
-import com.android.telephony.Rlog;
import android.telephony.ServiceState;
import android.telephony.ServiceState.RilRadioTechnology;
import android.telephony.SignalThresholdInfo;
@@ -104,6 +104,7 @@
import com.android.internal.telephony.uicc.UiccProfile;
import com.android.internal.telephony.uicc.UiccSlot;
import com.android.internal.telephony.util.ArrayUtils;
+import com.android.telephony.Rlog;
import java.io.FileDescriptor;
import java.io.PrintWriter;
@@ -332,6 +333,7 @@
null);
mCi.setOnSuppServiceNotification(this, EVENT_SSN, null);
mCi.setOnRegistrationFailed(this, EVENT_REGISTRATION_FAILED, null);
+ mCi.registerForBarringInfoChanged(this, EVENT_BARRING_INFO_CHANGED, null);
//GSM
mCi.setOnUSSD(this, EVENT_USSD, null);
@@ -387,8 +389,7 @@
mIsPhoneInEcmState = getInEcmMode();
if (mIsPhoneInEcmState) {
// Send a message which will invoke handleExitEmergencyCallbackMode
- mCi.exitEmergencyCallbackMode(
- obtainMessage(EVENT_EXIT_EMERGENCY_CALLBACK_RESPONSE));
+ mCi.exitEmergencyCallbackMode(null);
}
mCi.setPhoneType(PhoneConstants.PHONE_TYPE_CDMA);
@@ -774,7 +775,7 @@
private void sendEmergencyCallbackModeChange(){
//Send an Intent
Intent intent = new Intent(TelephonyIntents.ACTION_EMERGENCY_CALLBACK_MODE_CHANGED);
- intent.putExtra(PhoneConstants.PHONE_IN_ECM_STATE, isInEcm());
+ intent.putExtra(TelephonyManager.EXTRA_PHONE_IN_ECM_STATE, isInEcm());
SubscriptionManager.putPhoneIdAndSubIdExtra(intent, getPhoneId());
mContext.sendStickyBroadcastAsUser(intent, UserHandle.ALL);
logi("sendEmergencyCallbackModeChange");
@@ -789,7 +790,7 @@
}
if (mBroadcastEmergencyCallStateChanges) {
Intent intent = new Intent(TelephonyIntents.ACTION_EMERGENCY_CALL_STATE_CHANGED);
- intent.putExtra(PhoneConstants.PHONE_IN_EMERGENCY_CALL, callActive);
+ intent.putExtra(TelephonyManager.EXTRA_PHONE_IN_EMERGENCY_CALL, callActive);
SubscriptionManager.putPhoneIdAndSubIdExtra(intent, getPhoneId());
mContext.sendStickyBroadcastAsUser(intent, UserHandle.ALL);
if (DBG) Rlog.d(LOG_TAG, "sendEmergencyCallStateChange: callActive " + callActive);
@@ -1316,11 +1317,12 @@
"cannot dial voice call in airplane mode");
}
// Check for service before placing non emergency CS voice call.
- // Allow dial only if either CS is camped on any RAT (or) PS is in LTE service.
+ // Allow dial only if either CS is camped on any RAT (or) PS is in LTE/NR service.
if (mSST != null
&& mSST.mSS.getState() == ServiceState.STATE_OUT_OF_SERVICE /* CS out of service */
&& !(mSST.mSS.getDataRegistrationState() == ServiceState.STATE_IN_SERVICE
- && ServiceState.isLte(mSST.mSS.getRilDataRadioTechnology())) /* PS not in LTE */
+ && ServiceState.isPsOnlyTech(
+ mSST.mSS.getRilDataRadioTechnology())) /* PS not in LTE/NR */
&& !VideoProfile.isVideo(dialArgs.videoState) /* voice call */
&& !isEmergency /* non-emergency call */) {
throw new CallStateException(
@@ -2766,6 +2768,13 @@
rfe.domain, rfe.causeCode, rfe.additionalCauseCode);
break;
+ case EVENT_BARRING_INFO_CHANGED:
+ logd("Event BarringInfoChanged Received");
+ ar = (AsyncResult) msg.obj;
+ BarringInfo barringInfo = (BarringInfo) ar.result;
+ mNotifier.notifyBarringInfoChanged(this, barringInfo);
+ break;
+
case EVENT_SET_CALL_FORWARD_DONE:
ar = (AsyncResult)msg.obj;
IccRecords r = mIccRecords.get();
@@ -3293,8 +3302,7 @@
if (mWakeLock.isHeld()) {
mWakeLock.release();
}
- // Send a message which will invoke handleExitEmergencyCallbackMode
- mCi.exitEmergencyCallbackMode(obtainMessage(EVENT_EXIT_EMERGENCY_CALLBACK_RESPONSE));
+ mCi.exitEmergencyCallbackMode(null);
}
}
@@ -3632,8 +3640,8 @@
private void phoneObjectUpdater(int newVoiceRadioTech) {
logd("phoneObjectUpdater: newVoiceRadioTech=" + newVoiceRadioTech);
- // Check for a voice over lte replacement
- if (ServiceState.isLte(newVoiceRadioTech)
+ // Check for a voice over LTE/NR replacement
+ if (ServiceState.isPsOnlyTech(newVoiceRadioTech)
|| (newVoiceRadioTech == ServiceState.RIL_RADIO_TECHNOLOGY_UNKNOWN)) {
CarrierConfigManager configMgr = (CarrierConfigManager)
getContext().getSystemService(Context.CARRIER_CONFIG_SERVICE);
@@ -3934,7 +3942,8 @@
private static final int[] VOICE_PS_CALL_RADIO_TECHNOLOGY = {
ServiceState.RIL_RADIO_TECHNOLOGY_LTE,
ServiceState.RIL_RADIO_TECHNOLOGY_LTE_CA,
- ServiceState.RIL_RADIO_TECHNOLOGY_IWLAN
+ ServiceState.RIL_RADIO_TECHNOLOGY_IWLAN,
+ ServiceState.RIL_RADIO_TECHNOLOGY_NR
};
/**
diff --git a/src/java/com/android/internal/telephony/InboundSmsHandler.java b/src/java/com/android/internal/telephony/InboundSmsHandler.java
index a21ea93..38eb804 100644
--- a/src/java/com/android/internal/telephony/InboundSmsHandler.java
+++ b/src/java/com/android/internal/telephony/InboundSmsHandler.java
@@ -1155,14 +1155,18 @@
// override the subId value in the intent with the values from tracker as they can be
// different, specifically if the message is coming from SmsBroadcastUndelivered
if (SubscriptionManager.isValidSubscriptionId(subId)) {
- intent.putExtra(PhoneConstants.SUBSCRIPTION_KEY, subId);
- intent.putExtra(SubscriptionManager.EXTRA_SUBSCRIPTION_INDEX, subId);
+ SubscriptionManager.putSubscriptionIdExtra(intent, subId);
}
if (user.equals(UserHandle.ALL)) {
// Get a list of currently started users.
int[] users = null;
final List<UserHandle> userHandles = mUserManager.getUserHandles(false);
+ for (UserHandle handle : userHandles) {
+ if (!mUserManager.isUserRunning(handle)) {
+ userHandles.remove(handle);
+ }
+ }
if (userHandles.isEmpty()) {
users = new int[] {user.getIdentifier()};
} else {
diff --git a/src/java/com/android/internal/telephony/MccTable.java b/src/java/com/android/internal/telephony/MccTable.java
index 2735207..56e84bf 100644
--- a/src/java/com/android/internal/telephony/MccTable.java
+++ b/src/java/com/android/internal/telephony/MccTable.java
@@ -21,20 +21,17 @@
import android.annotation.UnsupportedAppUsage;
import android.app.ActivityManager;
import android.content.Context;
-import android.content.res.Configuration;
import android.os.Build;
-import android.os.RemoteException;
import android.os.SystemProperties;
-import com.android.telephony.Rlog;
import android.text.TextUtils;
+import android.timezone.TelephonyLookup;
+import android.timezone.TelephonyNetwork;
+import android.timezone.TelephonyNetworkFinder;
import com.android.internal.annotations.GuardedBy;
import com.android.internal.annotations.VisibleForTesting;
import com.android.internal.telephony.util.TelephonyUtils;
-
-import libcore.timezone.TelephonyLookup;
-import libcore.timezone.TelephonyNetwork;
-import libcore.timezone.TelephonyNetworkFinder;
+import com.android.telephony.Rlog;
import java.util.ArrayList;
import java.util.Collections;
@@ -286,35 +283,27 @@
}
if (!TextUtils.isEmpty(mccmnc)) {
- int mcc, mnc;
-
+ int mccInt;
try {
- mcc = Integer.parseInt(mccmnc.substring(0, 3));
- mnc = Integer.parseInt(mccmnc.substring(3));
+ mccInt = Integer.parseInt(mccmnc.substring(0, 3));
} catch (NumberFormatException | StringIndexOutOfBoundsException ex) {
- Rlog.e(LOG_TAG, "Error parsing IMSI: " + mccmnc + ". ex=" + ex);
+ Rlog.e(LOG_TAG, "Error parsing mccmnc: " + mccmnc + ". ex=" + ex);
return;
}
-
- Rlog.d(LOG_TAG, "updateMccMncConfiguration: mcc=" + mcc + ", mnc=" + mnc);
-
- try {
- Configuration config = new Configuration();
- boolean updateConfig = false;
- if (mcc != 0) {
- config.mcc = mcc;
- config.mnc = mnc == 0 ? Configuration.MNC_ZERO : mnc;
- updateConfig = true;
- }
-
- if (updateConfig) {
- Rlog.d(LOG_TAG, "updateMccMncConfiguration updateConfig config=" + config);
- ActivityManager.getService().updateConfiguration(config);
+ if (mccInt != 0) {
+ ActivityManager activityManager = (ActivityManager) context.getSystemService(
+ Context.ACTIVITY_SERVICE);
+ if (!activityManager.updateMccMncConfiguration(
+ mccmnc.substring(0, 3), mccmnc.substring(3))) {
+ Rlog.d(LOG_TAG, "updateMccMncConfiguration: update mccmnc="
+ + mccmnc + " failure");
+ return;
} else {
- Rlog.d(LOG_TAG, "updateMccMncConfiguration nothing to update");
+ Rlog.d(LOG_TAG, "updateMccMncConfiguration: update mccmnc="
+ + mccmnc + " success");
}
- } catch (RemoteException e) {
- Rlog.e(LOG_TAG, "Can't update configuration", e);
+ } else {
+ Rlog.d(LOG_TAG, "updateMccMncConfiguration nothing to update");
}
}
}
diff --git a/src/java/com/android/internal/telephony/NitzStateMachineImpl.java b/src/java/com/android/internal/telephony/NitzStateMachineImpl.java
index 04c6c71..ad21196 100644
--- a/src/java/com/android/internal/telephony/NitzStateMachineImpl.java
+++ b/src/java/com/android/internal/telephony/NitzStateMachineImpl.java
@@ -20,15 +20,15 @@
import android.content.Context;
import android.os.PowerManager;
import android.os.TimestampedValue;
-import com.android.telephony.Rlog;
import android.text.TextUtils;
+import android.timezone.CountryTimeZones.OffsetResult;
import android.util.LocalLog;
import com.android.internal.annotations.VisibleForTesting;
import com.android.internal.telephony.TimeZoneLookupHelper.CountryResult;
-import com.android.internal.telephony.TimeZoneLookupHelper.OffsetResult;
import com.android.internal.telephony.metrics.TelephonyMetrics;
import com.android.internal.util.IndentingPrintWriter;
+import com.android.telephony.Rlog;
import java.io.FileDescriptor;
import java.io.PrintWriter;
diff --git a/src/java/com/android/internal/telephony/Phone.java b/src/java/com/android/internal/telephony/Phone.java
index 448197f..2c4534f 100644
--- a/src/java/com/android/internal/telephony/Phone.java
+++ b/src/java/com/android/internal/telephony/Phone.java
@@ -205,8 +205,9 @@
protected static final int EVENT_GET_UICC_APPS_ENABLEMENT_DONE = 54;
protected static final int EVENT_REAPPLY_UICC_APPS_ENABLEMENT_DONE = 55;
protected static final int EVENT_REGISTRATION_FAILED = 56;
+ protected static final int EVENT_BARRING_INFO_CHANGED = 57;
- protected static final int EVENT_LAST = EVENT_REGISTRATION_FAILED;
+ protected static final int EVENT_LAST = EVENT_BARRING_INFO_CHANGED;
// For shared prefs.
private static final String GSM_ROAMING_LIST_OVERRIDE_PREFIX = "gsm_roaming_list_";
diff --git a/src/java/com/android/internal/telephony/PhoneInternalInterface.java b/src/java/com/android/internal/telephony/PhoneInternalInterface.java
index b4d861b..4d94270 100644
--- a/src/java/com/android/internal/telephony/PhoneInternalInterface.java
+++ b/src/java/com/android/internal/telephony/PhoneInternalInterface.java
@@ -193,9 +193,12 @@
int CDMA_RM_ANY = TelephonyManager.CDMA_ROAMING_MODE_ANY;
// Used for CDMA subscription mode
- static final int CDMA_SUBSCRIPTION_UNKNOWN =-1; // Unknown
- static final int CDMA_SUBSCRIPTION_RUIM_SIM = 0; // RUIM/SIM (default)
- static final int CDMA_SUBSCRIPTION_NV = 1; // NV -> non-volatile memory
+ // Unknown
+ static final int CDMA_SUBSCRIPTION_UNKNOWN = TelephonyManager.CDMA_SUBSCRIPTION_UNKNOWN;
+ // RUIM/SIM (default)
+ static final int CDMA_SUBSCRIPTION_RUIM_SIM = TelephonyManager.CDMA_SUBSCRIPTION_RUIM_SIM;
+ // NV -> non-volatile memory
+ static final int CDMA_SUBSCRIPTION_NV = TelephonyManager.CDMA_SUBSCRIPTION_NV;
static final int PREFERRED_CDMA_SUBSCRIPTION = CDMA_SUBSCRIPTION_RUIM_SIM;
diff --git a/src/java/com/android/internal/telephony/PhoneNotifier.java b/src/java/com/android/internal/telephony/PhoneNotifier.java
index 36fad5e..a762951 100644
--- a/src/java/com/android/internal/telephony/PhoneNotifier.java
+++ b/src/java/com/android/internal/telephony/PhoneNotifier.java
@@ -21,6 +21,7 @@
import android.telephony.Annotation.DataFailureCause;
import android.telephony.Annotation.RadioPowerState;
import android.telephony.Annotation.SrvccState;
+import android.telephony.BarringInfo;
import android.telephony.CallQuality;
import android.telephony.CellIdentity;
import android.telephony.CellInfo;
@@ -105,7 +106,10 @@
/** Notify of a change to the call quality of an active foreground call. */
void notifyCallQualityChanged(Phone sender, CallQuality callQuality, int callNetworkType);
- /** Notify registration failed*/
+ /** Notify registration failed */
void notifyRegistrationFailed(Phone sender, @NonNull CellIdentity cellIdentity,
@NonNull String chosenPlmn, int domain, int causeCode, int additionalCauseCode);
+
+ /** Notify barring info has changed */
+ void notifyBarringInfoChanged(Phone sender, @NonNull BarringInfo barringInfo);
}
diff --git a/src/java/com/android/internal/telephony/PhoneSwitcher.java b/src/java/com/android/internal/telephony/PhoneSwitcher.java
index 9fba4df..d675aac 100644
--- a/src/java/com/android/internal/telephony/PhoneSwitcher.java
+++ b/src/java/com/android/internal/telephony/PhoneSwitcher.java
@@ -39,7 +39,7 @@
import android.net.NetworkFactory;
import android.net.NetworkRequest;
import android.net.NetworkSpecifier;
-import android.net.StringNetworkSpecifier;
+import android.net.TelephonyNetworkSpecifier;
import android.os.AsyncResult;
import android.os.Handler;
import android.os.Looper;
@@ -1000,22 +1000,10 @@
if (specifier == null) {
return DEFAULT_SUBSCRIPTION_ID;
}
-
- int subId;
-
- if (specifier instanceof StringNetworkSpecifier) {
- try {
- subId = Integer.parseInt(((StringNetworkSpecifier) specifier).specifier);
- } catch (NumberFormatException e) {
- Rlog.e(LOG_TAG, "NumberFormatException on "
- + ((StringNetworkSpecifier) specifier).specifier);
- return INVALID_SUBSCRIPTION_ID;
- }
- } else {
- return INVALID_SUBSCRIPTION_ID;
+ if (specifier instanceof TelephonyNetworkSpecifier) {
+ return ((TelephonyNetworkSpecifier) specifier).getSubscriptionId();
}
-
- return subId;
+ return INVALID_SUBSCRIPTION_ID;
}
private int getSubIdForDefaultNetworkRequests() {
diff --git a/src/java/com/android/internal/telephony/RIL.java b/src/java/com/android/internal/telephony/RIL.java
index faf3d97..9671238 100644
--- a/src/java/com/android/internal/telephony/RIL.java
+++ b/src/java/com/android/internal/telephony/RIL.java
@@ -52,6 +52,7 @@
import android.hardware.radio.V1_4.SimLockMultiSimPolicy;
import android.hardware.radio.V1_5.AccessNetwork;
import android.hardware.radio.deprecated.V1_0.IOemHook;
+import android.net.InetAddresses;
import android.net.KeepalivePacketData;
import android.net.LinkAddress;
import android.net.LinkProperties;
@@ -84,7 +85,6 @@
import android.telephony.PhoneNumberUtils;
import android.telephony.RadioAccessFamily;
import android.telephony.RadioAccessSpecifier;
-import com.android.telephony.Rlog;
import android.telephony.ServiceState;
import android.telephony.SignalStrength;
import android.telephony.SignalThresholdInfo;
@@ -112,8 +112,7 @@
import com.android.internal.telephony.nano.TelephonyProto.SmsSession;
import com.android.internal.telephony.uicc.IccUtils;
import com.android.internal.telephony.util.TelephonyUtils;
-
-import libcore.net.InetAddressUtils;
+import com.android.telephony.Rlog;
import java.io.ByteArrayInputStream;
import java.io.DataInputStream;
@@ -5993,6 +5992,8 @@
return "RIL_UNSOL_UICC_APPLICATIONS_ENABLEMENT_CHANGED";
case RIL_UNSOL_REGISTRATION_FAILED:
return "RIL_UNSOL_REGISTRATION_FAILED";
+ case RIL_UNSOL_BARRING_INFO_CHANGED:
+ return "RIL_UNSOL_BARRING_INFO_CHANGED";
default:
return "<unknown response>";
}
@@ -6361,7 +6362,7 @@
ifname = result.ifname;
//addresses = result.addresses.stream().toArray(String[]::new);
laList = result.addresses.stream().map(a -> new LinkAddress(
- InetAddressUtils.parseNumericAddress(a.address), 0, a.properties, 0))
+ InetAddresses.parseNumericAddress(a.address), 0, a.properties, 0))
.collect(Collectors.toList());
dnses = result.dnses.stream().toArray(String[]::new);
gateways = result.gateways.stream().toArray(String[]::new);
@@ -6387,7 +6388,7 @@
if (address.split("/").length == 2) {
la = new LinkAddress(address);
} else {
- InetAddress ia = InetAddressUtils.parseNumericAddress(address);
+ InetAddress ia = InetAddresses.parseNumericAddress(address);
la = new LinkAddress(ia, (ia instanceof Inet4Address) ? 32 : 128);
}
@@ -6406,7 +6407,7 @@
dns = dns.trim();
InetAddress ia;
try {
- ia = InetAddressUtils.parseNumericAddress(dns);
+ ia = InetAddresses.parseNumericAddress(dns);
dnsList.add(ia);
} catch (IllegalArgumentException e) {
Rlog.e(RILJ_LOG_TAG, "Unknown dns: " + dns, e);
@@ -6421,7 +6422,7 @@
gateway = gateway.trim();
InetAddress ia;
try {
- ia = InetAddressUtils.parseNumericAddress(gateway);
+ ia = InetAddresses.parseNumericAddress(gateway);
gatewayList.add(ia);
} catch (IllegalArgumentException e) {
Rlog.e(RILJ_LOG_TAG, "Unknown gateway: " + gateway, e);
@@ -6436,7 +6437,7 @@
pcscf = pcscf.trim();
InetAddress ia;
try {
- ia = InetAddressUtils.parseNumericAddress(pcscf);
+ ia = InetAddresses.parseNumericAddress(pcscf);
pcscfList.add(ia);
} catch (IllegalArgumentException e) {
Rlog.e(RILJ_LOG_TAG, "Unknown pcscf: " + pcscf, e);
diff --git a/src/java/com/android/internal/telephony/RadioIndication.java b/src/java/com/android/internal/telephony/RadioIndication.java
index ede5854..6a7b6d2 100644
--- a/src/java/com/android/internal/telephony/RadioIndication.java
+++ b/src/java/com/android/internal/telephony/RadioIndication.java
@@ -88,6 +88,7 @@
import android.os.AsyncResult;
import android.sysprop.TelephonyProperties;
import android.telephony.Annotation.RadioPowerState;
+import android.telephony.BarringInfo;
import android.telephony.CellIdentity;
import android.telephony.CellInfo;
import android.telephony.NetworkRegistrationInfo;
@@ -1000,6 +1001,25 @@
}
/**
+ * Indicate that BarringInfo has changed for the current cell and user.
+ *
+ * @param cellIdentity a CellIdentity the CellIdentity of the Cell
+ * @param barringInfos the updated barring information from the current cell, filtered for the
+ * current PLMN and access class / access category.
+ */
+ public void barringInfoChanged(int indicationType,
+ android.hardware.radio.V1_5.CellIdentity cellIdentity,
+ List<android.hardware.radio.V1_5.BarringInfo> barringInfos) {
+ mRil.processIndication(indicationType);
+
+ CellIdentity ci = CellIdentity.create(cellIdentity);
+ BarringInfo cbi = BarringInfo.create(cellIdentity, barringInfos);
+
+ mRil.mBarringInfoChangedRegistrants.notifyRegistrants(
+ new AsyncResult(null, cbi, null));
+ }
+
+ /**
* @param stateInt
* @return {@link RadioPowerState RadioPowerState}
*/
diff --git a/src/java/com/android/internal/telephony/ServiceStateTracker.java b/src/java/com/android/internal/telephony/ServiceStateTracker.java
index 8c13d42..adee879 100755
--- a/src/java/com/android/internal/telephony/ServiceStateTracker.java
+++ b/src/java/com/android/internal/telephony/ServiceStateTracker.java
@@ -1895,9 +1895,9 @@
// Use default
mNewSS.setCdmaRoamingIndicator(mDefaultRoamingIndicator);
} else if (namMatch && !mIsInPrl) {
- // TODO this will be removed when we handle roaming on LTE on CDMA+LTE phones
- if (ServiceState.isLte(mNewSS.getRilVoiceRadioTechnology())) {
- log("Turn off roaming indicator as voice is LTE");
+ // TODO: remove when we handle roaming on LTE/NR on CDMA+LTE phones
+ if (ServiceState.isPsOnlyTech(mNewSS.getRilVoiceRadioTechnology())) {
+ log("Turn off roaming indicator as voice is LTE or NR");
mNewSS.setCdmaRoamingIndicator(EriInfo.ROAMING_INDICATOR_OFF);
} else {
mNewSS.setCdmaRoamingIndicator(EriInfo.ROAMING_INDICATOR_FLASH);
@@ -2197,16 +2197,17 @@
} else {
// If the unsolicited signal strength comes just before data RAT family changes
- // (i.e. from UNKNOWN to LTE, CDMA to LTE, LTE to CDMA), the signal bar might
- // display the wrong information until the next unsolicited signal strength
- // information coming from the modem, which might take a long time to come or
- // even not come at all. In order to provide the best user experience, we
- // query the latest signal information so it will show up on the UI on time.
+ // (i.e. from UNKNOWN to LTE/NR, CDMA to LTE/NR, LTE/NR to CDMA), the signal bar
+ // might display the wrong information until the next unsolicited signal
+ // strength information coming from the modem, which might take a long time to
+ // come or even not come at all. In order to provide the best user experience,
+ // we query the latest signal information so it will show up on the UI on time.
int oldDataRAT = getRilDataRadioTechnologyForWwan(mSS);
if (((oldDataRAT == ServiceState.RIL_RADIO_TECHNOLOGY_UNKNOWN)
&& (newDataRat != ServiceState.RIL_RADIO_TECHNOLOGY_UNKNOWN))
- || (ServiceState.isCdma(oldDataRAT) && ServiceState.isLte(newDataRat))
- || (ServiceState.isLte(oldDataRAT)
+ || (ServiceState.isCdma(oldDataRAT)
+ && ServiceState.isPsOnlyTech(newDataRat))
+ || (ServiceState.isPsOnlyTech(oldDataRAT)
&& ServiceState.isCdma(newDataRat))) {
mCi.getSignalStrength(obtainMessage(EVENT_GET_SIGNAL_STRENGTH));
}
@@ -3226,16 +3227,14 @@
final int wwanDataRat = getRilDataRadioTechnologyForWwan(mSS);
final int newWwanDataRat = getRilDataRadioTechnologyForWwan(mNewSS);
has4gHandoff = mNewSS.getDataRegistrationState() == ServiceState.STATE_IN_SERVICE
- && ((ServiceState.isLte(wwanDataRat)
+ && ((ServiceState.isPsOnlyTech(wwanDataRat)
&& (newWwanDataRat == ServiceState.RIL_RADIO_TECHNOLOGY_EHRPD))
- ||
- ((wwanDataRat == ServiceState.RIL_RADIO_TECHNOLOGY_EHRPD)
- && ServiceState.isLte(newWwanDataRat)));
+ || ((wwanDataRat == ServiceState.RIL_RADIO_TECHNOLOGY_EHRPD)
+ && ServiceState.isPsOnlyTech(newWwanDataRat)));
- hasMultiApnSupport = ((ServiceState.isLte(newWwanDataRat)
+ hasMultiApnSupport = ((ServiceState.isPsOnlyTech(newWwanDataRat)
|| (newWwanDataRat == ServiceState.RIL_RADIO_TECHNOLOGY_EHRPD))
- &&
- (!ServiceState.isLte(wwanDataRat)
+ && (!ServiceState.isPsOnlyTech(wwanDataRat)
&& (wwanDataRat != ServiceState.RIL_RADIO_TECHNOLOGY_EHRPD)));
hasLostMultiApnSupport = ((newWwanDataRat >= ServiceState.RIL_RADIO_TECHNOLOGY_IS95A)
@@ -3545,7 +3544,7 @@
mUiccController.getUiccCard(getPhoneId()).getOperatorBrandOverride() != null;
if (!hasBrandOverride && (mCi.getRadioState() == TelephonyManager.RADIO_POWER_ON)
&& (mEriManager.isEriFileLoaded())
- && (!ServiceState.isLte(mSS.getRilVoiceRadioTechnology())
+ && (!ServiceState.isPsOnlyTech(mSS.getRilVoiceRadioTechnology())
|| mPhone.getContext().getResources().getBoolean(com.android.internal.R
.bool.config_LTE_eri_for_network_name))) {
// Only when CDMA is in service, ERI will take effect
@@ -3570,7 +3569,7 @@
if (mUiccApplcation != null && mUiccApplcation.getState() == AppState.APPSTATE_READY &&
mIccRecords != null && getCombinedRegState(mSS) == ServiceState.STATE_IN_SERVICE
- && !ServiceState.isLte(mSS.getRilVoiceRadioTechnology())) {
+ && !ServiceState.isPsOnlyTech(mSS.getRilVoiceRadioTechnology())) {
// SIM is found on the device. If ERI roaming is OFF, and SID/NID matches
// one configured in SIM, use operator name from CSIM record. Note that ERI, SID,
// and NID are CDMA only, not applicable to LTE.
diff --git a/src/java/com/android/internal/telephony/SubscriptionController.java b/src/java/com/android/internal/telephony/SubscriptionController.java
index c276423..1c5c086 100644
--- a/src/java/com/android/internal/telephony/SubscriptionController.java
+++ b/src/java/com/android/internal/telephony/SubscriptionController.java
@@ -43,7 +43,6 @@
import android.telecom.TelecomManager;
import android.telephony.CarrierConfigManager;
import android.telephony.RadioAccessFamily;
-import com.android.telephony.Rlog;
import android.telephony.SubscriptionInfo;
import android.telephony.SubscriptionManager;
import android.telephony.SubscriptionManager.SimDisplayNameSource;
@@ -65,6 +64,7 @@
import com.android.internal.telephony.uicc.UiccController;
import com.android.internal.telephony.util.ArrayUtils;
import com.android.internal.telephony.util.TelephonyUtils;
+import com.android.telephony.Rlog;
import java.io.FileDescriptor;
import java.io.PrintWriter;
@@ -2217,8 +2217,7 @@
Intent intent = new Intent(SubscriptionManager.ACTION_DEFAULT_SMS_SUBSCRIPTION_CHANGED);
intent.addFlags(Intent.FLAG_RECEIVER_REPLACE_PENDING
| Intent.FLAG_RECEIVER_INCLUDE_BACKGROUND);
- intent.putExtra(PhoneConstants.SUBSCRIPTION_KEY, subId);
- intent.putExtra(SubscriptionManager.EXTRA_SUBSCRIPTION_INDEX, subId);
+ SubscriptionManager.putSubscriptionIdExtra(intent, subId);
mContext.sendStickyBroadcastAsUser(intent, UserHandle.ALL);
}
@@ -2279,8 +2278,7 @@
Intent intent = new Intent(TelephonyIntents.ACTION_DEFAULT_VOICE_SUBSCRIPTION_CHANGED);
intent.addFlags(Intent.FLAG_RECEIVER_REPLACE_PENDING
| Intent.FLAG_RECEIVER_INCLUDE_BACKGROUND);
- intent.putExtra(PhoneConstants.SUBSCRIPTION_KEY, subId);
- intent.putExtra(SubscriptionManager.EXTRA_SUBSCRIPTION_INDEX, subId);
+ SubscriptionManager.putSubscriptionIdExtra(intent, subId);
mContext.sendStickyBroadcastAsUser(intent, UserHandle.ALL);
}
@@ -2380,8 +2378,7 @@
Intent intent = new Intent(TelephonyIntents.ACTION_DEFAULT_DATA_SUBSCRIPTION_CHANGED);
intent.addFlags(Intent.FLAG_RECEIVER_REPLACE_PENDING
| Intent.FLAG_RECEIVER_INCLUDE_BACKGROUND);
- intent.putExtra(PhoneConstants.SUBSCRIPTION_KEY, subId);
- intent.putExtra(SubscriptionManager.EXTRA_SUBSCRIPTION_INDEX, subId);
+ SubscriptionManager.putSubscriptionIdExtra(intent, subId);
mContext.sendStickyBroadcastAsUser(intent, UserHandle.ALL);
}
diff --git a/src/java/com/android/internal/telephony/TimeZoneLookupHelper.java b/src/java/com/android/internal/telephony/TimeZoneLookupHelper.java
index de2417b..79342dd 100644
--- a/src/java/com/android/internal/telephony/TimeZoneLookupHelper.java
+++ b/src/java/com/android/internal/telephony/TimeZoneLookupHelper.java
@@ -24,10 +24,10 @@
import android.annotation.Nullable;
import android.icu.util.TimeZone;
import android.text.TextUtils;
-
-import libcore.timezone.CountryTimeZones;
-import libcore.timezone.CountryTimeZones.TimeZoneMapping;
-import libcore.timezone.TimeZoneFinder;
+import android.timezone.CountryTimeZones;
+import android.timezone.CountryTimeZones.OffsetResult;
+import android.timezone.CountryTimeZones.TimeZoneMapping;
+import android.timezone.TimeZoneFinder;
import java.lang.annotation.Retention;
import java.lang.annotation.RetentionPolicy;
@@ -41,65 +41,6 @@
public class TimeZoneLookupHelper {
/**
- * The result of looking up a time zone using offset information (and possibly more).
- */
- public static final class OffsetResult {
-
- /** A zone that matches the supplied criteria. See also {@link #mIsOnlyMatch}. */
- @NonNull
- private final TimeZone mTimeZone;
-
- /** True if there is only one matching time zone for the supplied criteria. */
- private final boolean mIsOnlyMatch;
-
- public OffsetResult(@NonNull TimeZone timeZone, boolean isOnlyMatch) {
- mTimeZone = Objects.requireNonNull(timeZone);
- mIsOnlyMatch = isOnlyMatch;
- }
-
- /**
- * Returns a time zone that matches the supplied criteria.
- */
- @NonNull
- public TimeZone getTimeZone() {
- return mTimeZone;
- }
-
- /**
- * Returns {@code true} if there is only one matching time zone for the supplied criteria.
- */
- public boolean getIsOnlyMatch() {
- return mIsOnlyMatch;
- }
-
- @Override
- public boolean equals(Object o) {
- if (this == o) {
- return true;
- }
- if (o == null || getClass() != o.getClass()) {
- return false;
- }
- OffsetResult that = (OffsetResult) o;
- return mIsOnlyMatch == that.mIsOnlyMatch
- && mTimeZone.getID().equals(that.mTimeZone.getID());
- }
-
- @Override
- public int hashCode() {
- return Objects.hash(mTimeZone, mIsOnlyMatch);
- }
-
- @Override
- public String toString() {
- return "OffsetResult{"
- + "mTimeZone(Id)=" + mTimeZone.getID()
- + ", mIsOnlyMatch=" + mIsOnlyMatch
- + '}';
- }
- }
-
- /**
* The result of looking up a time zone using country information.
*/
public static final class CountryResult {
@@ -194,13 +135,9 @@
Integer dstAdjustmentMillis = nitzData.getDstAdjustmentMillis();
Boolean isDst = dstAdjustmentMillis == null ? null : dstAdjustmentMillis != 0;
Integer dstAdjustmentMillisToMatch = null; // Don't try to match the precise DST offset.
- CountryTimeZones.OffsetResult offsetResult = countryTimeZones.lookupByOffsetWithBias(
+ return countryTimeZones.lookupByOffsetWithBias(
nitzData.getLocalOffsetMillis(), isDst, dstAdjustmentMillisToMatch,
nitzData.getCurrentTimeInMillis(), bias);
- if (offsetResult == null) {
- return null;
- }
- return new OffsetResult(offsetResult.mTimeZone, offsetResult.mOneMatch);
}
/**
@@ -257,7 +194,7 @@
String debugInfo;
int matchQuality;
- if (countryTimeZones.getDefaultTimeZoneBoost()) {
+ if (countryTimeZones.isDefaultTimeZoneBoosted()) {
matchQuality = CountryResult.QUALITY_DEFAULT_BOOSTED;
debugInfo = "Country default is boosted";
} else {
@@ -291,7 +228,7 @@
String countryDefaultId = countryDefaultZone.getID();
int countryDefaultOffset = countryDefaultZone.getOffset(whenMillis);
for (TimeZoneMapping timeZoneMapping : effectiveTimeZoneMappings) {
- if (timeZoneMapping.timeZoneId.equals(countryDefaultId)) {
+ if (timeZoneMapping.getTimeZoneId().equals(countryDefaultId)) {
continue;
}
diff --git a/src/java/com/android/internal/telephony/cdma/CdmaSMSDispatcher.java b/src/java/com/android/internal/telephony/cdma/CdmaSMSDispatcher.java
index b9acbfa..1ed08c8 100755
--- a/src/java/com/android/internal/telephony/cdma/CdmaSMSDispatcher.java
+++ b/src/java/com/android/internal/telephony/cdma/CdmaSMSDispatcher.java
@@ -20,7 +20,6 @@
import android.compat.annotation.UnsupportedAppUsage;
import android.os.Message;
-import com.android.telephony.Rlog;
import android.telephony.ServiceState;
import android.telephony.TelephonyManager;
import android.util.Pair;
@@ -35,6 +34,7 @@
import com.android.internal.telephony.SmsHeader;
import com.android.internal.telephony.SmsMessageBase;
import com.android.internal.telephony.util.SMSDispatcherUtil;
+import com.android.telephony.Rlog;
public class CdmaSMSDispatcher extends SMSDispatcher {
@@ -147,11 +147,13 @@
int currentDataNetwork = mPhone.getServiceState().getDataNetworkType();
boolean imsSmsDisabled = (currentDataNetwork == TelephonyManager.NETWORK_TYPE_EHRPD
- || (ServiceState.isLte(currentDataNetwork)
- && !mPhone.getServiceStateTracker().isConcurrentVoiceAndDataAllowed()))
- && mPhone.getServiceState().getVoiceNetworkType()
- == TelephonyManager.NETWORK_TYPE_1xRTT
- && ((GsmCdmaPhone) mPhone).mCT.mState != PhoneConstants.State.IDLE;
+ || (currentDataNetwork == TelephonyManager.NETWORK_TYPE_LTE
+ || currentDataNetwork == TelephonyManager.NETWORK_TYPE_LTE_CA
+ || currentDataNetwork == TelephonyManager.NETWORK_TYPE_NR)
+ && !mPhone.getServiceStateTracker().isConcurrentVoiceAndDataAllowed())
+ && mPhone.getServiceState().getVoiceNetworkType()
+ == TelephonyManager.NETWORK_TYPE_1xRTT
+ && ((GsmCdmaPhone) mPhone).mCT.mState != PhoneConstants.State.IDLE;
// sms over cdma is used:
// if sms over IMS is not supported AND
diff --git a/src/java/com/android/internal/telephony/dataconnection/DataConnection.java b/src/java/com/android/internal/telephony/dataconnection/DataConnection.java
index e5d81eb..726c2e9 100644
--- a/src/java/com/android/internal/telephony/dataconnection/DataConnection.java
+++ b/src/java/com/android/internal/telephony/dataconnection/DataConnection.java
@@ -37,7 +37,7 @@
import android.net.ProxyInfo;
import android.net.RouteInfo;
import android.net.SocketKeepalive;
-import android.net.StringNetworkSpecifier;
+import android.net.TelephonyNetworkSpecifier;
import android.os.AsyncResult;
import android.os.Message;
import android.os.PersistableBundle;
@@ -87,8 +87,6 @@
import com.android.internal.util.StateMachine;
import com.android.telephony.Rlog;
-import libcore.net.InetAddressUtils;
-
import java.io.FileDescriptor;
import java.io.PrintWriter;
import java.io.StringWriter;
@@ -1330,7 +1328,8 @@
result.setLinkUpstreamBandwidthKbps(up);
result.setLinkDownstreamBandwidthKbps(down);
- result.setNetworkSpecifier(new StringNetworkSpecifier(Integer.toString(mSubId)));
+ result.setNetworkSpecifier(new TelephonyNetworkSpecifier.Builder()
+ .setSubscriptionId(mSubId).build());
result.setCapability(NetworkCapabilities.NET_CAPABILITY_NOT_ROAMING,
!mPhone.getServiceState().getDataRoaming());
@@ -1395,7 +1394,7 @@
if (address.startsWith("[") && address.endsWith("]") && address.indexOf(':') != -1) {
address = address.substring(1, address.length() - 1);
}
- return InetAddressUtils.isNumericAddress(address);
+ return InetAddresses.isNumericAddress(address);
}
private SetupResult setLinkProperties(DataCallResponse response,
diff --git a/src/java/com/android/internal/telephony/dataconnection/DcController.java b/src/java/com/android/internal/telephony/dataconnection/DcController.java
index 62dbdca..4104013 100644
--- a/src/java/com/android/internal/telephony/dataconnection/DcController.java
+++ b/src/java/com/android/internal/telephony/dataconnection/DcController.java
@@ -19,8 +19,9 @@
import android.content.Context;
import android.hardware.radio.V1_4.DataConnActiveStatus;
import android.net.LinkAddress;
-import android.net.LinkProperties.CompareResult;
-import android.net.NetworkUtils;
+import android.net.util.LinkPropertiesUtils;
+import android.net.util.LinkPropertiesUtils.CompareResult;
+import android.net.util.NetUtils;
import android.os.AsyncResult;
import android.os.Handler;
import android.os.Message;
@@ -322,15 +323,21 @@
if (result.oldLp.equals(result.newLp)) {
if (DBG) log("onDataStateChanged: no change");
} else {
- if (result.oldLp.isIdenticalInterfaceName(result.newLp)) {
- if (! result.oldLp.isIdenticalDnses(result.newLp) ||
- ! result.oldLp.isIdenticalRoutes(result.newLp) ||
- ! result.oldLp.isIdenticalHttpProxy(result.newLp) ||
- ! result.oldLp.isIdenticalAddresses(result.newLp)) {
+ if (LinkPropertiesUtils.isIdenticalInterfaceName(
+ result.oldLp, result.newLp)) {
+ if (!LinkPropertiesUtils.isIdenticalDnses(
+ result.oldLp, result.newLp)
+ || !LinkPropertiesUtils.isIdenticalRoutes(
+ result.oldLp, result.newLp)
+ || !LinkPropertiesUtils.isIdenticalHttpProxy(
+ result.oldLp, result.newLp)
+ || !LinkPropertiesUtils.isIdenticalAddresses(
+ result.oldLp, result.newLp)) {
// If the same address type was removed and
// added we need to cleanup
CompareResult<LinkAddress> car =
- result.oldLp.compareAddresses(result.newLp);
+ LinkPropertiesUtils.compareAddresses(result.oldLp,
+ result.newLp);
if (DBG) {
log("onDataStateChanged: oldLp=" + result.oldLp +
" newLp=" + result.newLp + " car=" + car);
@@ -338,7 +345,7 @@
boolean needToClean = false;
for (LinkAddress added : car.added) {
for (LinkAddress removed : car.removed) {
- if (NetworkUtils.addressTypeMatches(
+ if (NetUtils.addressTypeMatches(
removed.getAddress(),
added.getAddress())) {
needToClean = true;
diff --git a/src/java/com/android/internal/telephony/dataconnection/DcNetworkAgent.java b/src/java/com/android/internal/telephony/dataconnection/DcNetworkAgent.java
index c2f01a9..8998686 100644
--- a/src/java/com/android/internal/telephony/dataconnection/DcNetworkAgent.java
+++ b/src/java/com/android/internal/telephony/dataconnection/DcNetworkAgent.java
@@ -72,7 +72,7 @@
super(dc.getHandler().getLooper(), phone.getContext(), "DcNetworkAgent", ni,
dc.getNetworkCapabilities(), dc.getLinkProperties(), score, config,
factorySerialNumber);
- mTag = "DcNetworkAgent" + "-" + netId;
+ mTag = "DcNetworkAgent" + "-" + network.netId;
mPhone = phone;
mNetworkCapabilities = dc.getNetworkCapabilities();
mTransportType = transportType;
diff --git a/src/java/com/android/internal/telephony/dataconnection/TelephonyNetworkFactory.java b/src/java/com/android/internal/telephony/dataconnection/TelephonyNetworkFactory.java
index 274205f..30461da 100644
--- a/src/java/com/android/internal/telephony/dataconnection/TelephonyNetworkFactory.java
+++ b/src/java/com/android/internal/telephony/dataconnection/TelephonyNetworkFactory.java
@@ -21,7 +21,7 @@
import android.net.NetworkCapabilities;
import android.net.NetworkFactory;
import android.net.NetworkRequest;
-import android.net.StringNetworkSpecifier;
+import android.net.TelephonyNetworkSpecifier;
import android.os.AsyncResult;
import android.os.Bundle;
import android.os.Handler;
@@ -145,7 +145,8 @@
nc.addCapability(NetworkCapabilities.NET_CAPABILITY_EIMS);
nc.addCapability(NetworkCapabilities.NET_CAPABILITY_NOT_RESTRICTED);
nc.addCapability(NetworkCapabilities.NET_CAPABILITY_INTERNET);
- nc.setNetworkSpecifier(new StringNetworkSpecifier(String.valueOf(subscriptionId)));
+ nc.setNetworkSpecifier(new TelephonyNetworkSpecifier.Builder()
+ .setSubscriptionId(subscriptionId).build());
return nc;
}
diff --git a/src/java/com/android/internal/telephony/imsphone/ImsPhone.java b/src/java/com/android/internal/telephony/imsphone/ImsPhone.java
index 6798145..62275bc 100644
--- a/src/java/com/android/internal/telephony/imsphone/ImsPhone.java
+++ b/src/java/com/android/internal/telephony/imsphone/ImsPhone.java
@@ -65,7 +65,6 @@
import android.telephony.CarrierConfigManager;
import android.telephony.NetworkRegistrationInfo;
import android.telephony.PhoneNumberUtils;
-import com.android.telephony.Rlog;
import android.telephony.ServiceState;
import android.telephony.SubscriptionManager;
import android.telephony.TelephonyManager;
@@ -112,6 +111,7 @@
import com.android.internal.telephony.uicc.IccRecords;
import com.android.internal.telephony.util.NotificationChannelController;
import com.android.internal.util.IndentingPrintWriter;
+import com.android.telephony.Rlog;
import java.io.FileDescriptor;
import java.io.PrintWriter;
@@ -1717,7 +1717,7 @@
private void sendEmergencyCallbackModeChange() {
// Send an Intent
Intent intent = new Intent(TelephonyIntents.ACTION_EMERGENCY_CALLBACK_MODE_CHANGED);
- intent.putExtra(PhoneConstants.PHONE_IN_ECM_STATE, isInEcm());
+ intent.putExtra(TelephonyManager.EXTRA_PHONE_IN_ECM_STATE, isInEcm());
SubscriptionManager.putPhoneIdAndSubIdExtra(intent, getPhoneId());
mContext.sendStickyBroadcastAsUser(intent, UserHandle.ALL);
if (DBG) logd("sendEmergencyCallbackModeChange: isInEcm=" + isInEcm());
diff --git a/src/java/com/android/internal/telephony/nitz/TimeZoneSuggesterImpl.java b/src/java/com/android/internal/telephony/nitz/TimeZoneSuggesterImpl.java
index adefcd3..c17c864 100644
--- a/src/java/com/android/internal/telephony/nitz/TimeZoneSuggesterImpl.java
+++ b/src/java/com/android/internal/telephony/nitz/TimeZoneSuggesterImpl.java
@@ -22,8 +22,8 @@
import android.annotation.Nullable;
import android.app.timezonedetector.PhoneTimeZoneSuggestion;
import android.os.TimestampedValue;
-import com.android.telephony.Rlog;
import android.text.TextUtils;
+import android.timezone.CountryTimeZones.OffsetResult;
import com.android.internal.annotations.VisibleForTesting;
import com.android.internal.telephony.NitzData;
@@ -31,6 +31,7 @@
import com.android.internal.telephony.TimeZoneLookupHelper;
import com.android.internal.telephony.TimeZoneLookupHelper.CountryResult;
import com.android.internal.telephony.nitz.NewNitzStateMachineImpl.TimeZoneSuggester;
+import com.android.telephony.Rlog;
import java.util.Objects;
@@ -142,7 +143,7 @@
PhoneTimeZoneSuggestion.Builder suggestionBuilder =
new PhoneTimeZoneSuggestion.Builder(phoneId);
suggestionBuilder.addDebugInfo("findTimeZoneForTestNetwork: nitzSignal=" + nitzSignal);
- TimeZoneLookupHelper.OffsetResult lookupResult =
+ OffsetResult lookupResult =
mTimeZoneLookupHelper.lookupByNitz(nitzData);
if (lookupResult == null) {
suggestionBuilder.addDebugInfo("findTimeZoneForTestNetwork: No zone found");
@@ -150,7 +151,7 @@
suggestionBuilder.setZoneId(lookupResult.getTimeZone().getID());
suggestionBuilder.setMatchType(
PhoneTimeZoneSuggestion.MATCH_TYPE_TEST_NETWORK_OFFSET_ONLY);
- int quality = lookupResult.getIsOnlyMatch()
+ int quality = lookupResult.isOnlyMatch()
? PhoneTimeZoneSuggestion.QUALITY_SINGLE_ZONE
: PhoneTimeZoneSuggestion.QUALITY_MULTIPLE_ZONES_WITH_SAME_OFFSET;
suggestionBuilder.setQuality(quality);
@@ -183,13 +184,13 @@
}
// Try to find a match using both country + NITZ signal.
- TimeZoneLookupHelper.OffsetResult lookupResult =
+ OffsetResult lookupResult =
mTimeZoneLookupHelper.lookupByNitzCountry(nitzData, countryIsoCode);
if (lookupResult != null) {
suggestionBuilder.setZoneId(lookupResult.getTimeZone().getID());
suggestionBuilder.setMatchType(
PhoneTimeZoneSuggestion.MATCH_TYPE_NETWORK_COUNTRY_AND_OFFSET);
- int quality = lookupResult.getIsOnlyMatch()
+ int quality = lookupResult.isOnlyMatch()
? PhoneTimeZoneSuggestion.QUALITY_SINGLE_ZONE
: PhoneTimeZoneSuggestion.QUALITY_MULTIPLE_ZONES_WITH_SAME_OFFSET;
suggestionBuilder.setQuality(quality);
diff --git a/tests/telephonytests/src/com/android/internal/telephony/BarringInfoTest.java b/tests/telephonytests/src/com/android/internal/telephony/BarringInfoTest.java
new file mode 100644
index 0000000..6720b41
--- /dev/null
+++ b/tests/telephonytests/src/com/android/internal/telephony/BarringInfoTest.java
@@ -0,0 +1,147 @@
+/*
+ * Copyright (C) 2020 The Android Open Source Project
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package com.android.internal.telephony;
+
+import static android.telephony.BarringInfo.BarringServiceInfo;
+
+import static org.junit.Assert.assertEquals;
+import static org.junit.Assert.assertFalse;
+import static org.junit.Assert.assertNotEquals;
+import static org.junit.Assert.assertNotNull;
+import static org.junit.Assert.assertTrue;
+
+import android.os.Parcel;
+import android.telephony.BarringInfo;
+import android.util.SparseArray;
+
+import org.junit.Test;
+
+/** Unit test for {@link android.telephony.BarringInfo}. */
+public class BarringInfoTest {
+
+ public static final int CONDITIONAL_BARRING_TIME_SECONDS = 20;
+ public static final int CONDITIONAL_BARRING_FACTOR_PERCENT = 50;
+
+
+ private static final int[] sServices = new int[] {
+ BarringInfo.BARRING_SERVICE_TYPE_CS_SERVICE,
+ BarringInfo.BARRING_SERVICE_TYPE_PS_SERVICE,
+ BarringInfo.BARRING_SERVICE_TYPE_CS_VOICE,
+ BarringInfo.BARRING_SERVICE_TYPE_MO_SIGNALLING,
+ BarringInfo.BARRING_SERVICE_TYPE_MO_DATA,
+ BarringInfo.BARRING_SERVICE_TYPE_CS_FALLBACK,
+ BarringInfo.BARRING_SERVICE_TYPE_MMTEL_VOICE,
+ BarringInfo.BARRING_SERVICE_TYPE_MMTEL_VIDEO,
+ BarringInfo.BARRING_SERVICE_TYPE_EMERGENCY,
+ BarringInfo.BARRING_SERVICE_TYPE_SMS,
+ };
+
+ /** Return a dummy set of barring info */
+ private static SparseArray<BarringServiceInfo> getBarringServiceInfos() {
+ return getBarringServiceInfos(false);
+ }
+
+ /** Return a dummy set of barring info
+ *
+ * @param isConditionallyBarred set the flag for whether the conditionally barred service has
+ * been evaluated and is actually barred based on the conditional barring parameters.
+ */
+ private static SparseArray<BarringServiceInfo>
+ getBarringServiceInfos(boolean isConditionallyBarred) {
+ SparseArray<BarringServiceInfo> serviceInfos = new SparseArray<>();
+ serviceInfos.put(BarringInfo.BARRING_SERVICE_TYPE_MO_DATA,
+ new BarringServiceInfo(BarringServiceInfo.BARRING_TYPE_UNCONDITIONAL, false, 0, 0));
+ serviceInfos.put(BarringInfo.BARRING_SERVICE_TYPE_MMTEL_VIDEO,
+ new BarringServiceInfo(
+ BarringServiceInfo.BARRING_TYPE_CONDITIONAL, isConditionallyBarred,
+ CONDITIONAL_BARRING_FACTOR_PERCENT, CONDITIONAL_BARRING_TIME_SECONDS));
+ return serviceInfos;
+ }
+
+ /** Test that parceling works correctly */
+ @Test
+ public void testParcel() {
+ BarringInfo info = new BarringInfo(null, getBarringServiceInfos());
+
+ Parcel parcel = Parcel.obtain();
+ info.writeToParcel(parcel, 0 /* flags */);
+ parcel.setDataPosition(0);
+
+ BarringInfo fromParcel = BarringInfo.CREATOR.createFromParcel(parcel);
+
+ assertEquals(fromParcel, info);
+ }
+
+ /** Test that an empty constructor returns valid barring service info that's all not barred */
+ @Test
+ public void testEmptyConstructor() {
+ BarringInfo b = new BarringInfo();
+ for (int service : sServices) {
+ BarringServiceInfo bsi = b.getBarringServiceInfo(service);
+ assertNotNull(bsi);
+ assertEquals(bsi.getBarringType(), BarringServiceInfo.BARRING_TYPE_UNKNOWN);
+ assertFalse(bsi.isBarred());
+ }
+ }
+
+ /** Test that barring service info is stored properly by the constructor */
+ @Test
+ public void testBarringService() {
+ BarringInfo b = new BarringInfo(null, getBarringServiceInfos());
+
+ // Check that the MO data barring info matches the info provided in getBarringServiceInfos()
+ BarringServiceInfo bsi = b.getBarringServiceInfo(BarringInfo.BARRING_SERVICE_TYPE_MO_DATA);
+ assertEquals(bsi.getBarringType(), BarringServiceInfo.BARRING_TYPE_UNCONDITIONAL);
+
+ // Check that the MMTEL barring info matches the info provided in getBarringServiceInfos()
+ bsi = b.getBarringServiceInfo(BarringInfo.BARRING_SERVICE_TYPE_MMTEL_VIDEO);
+ assertEquals(bsi.getBarringType(), BarringServiceInfo.BARRING_TYPE_CONDITIONAL);
+ assertFalse(bsi.isConditionallyBarred());
+ assertEquals(bsi.getConditionalBarringFactor(), CONDITIONAL_BARRING_FACTOR_PERCENT);
+ assertEquals(bsi.getConditionalBarringTimeSeconds(), CONDITIONAL_BARRING_TIME_SECONDS);
+
+ // Because BarringInfo is available, services that aren't reported as barred are
+ // automatically reported as unbarred.
+ bsi = b.getBarringServiceInfo(BarringInfo.BARRING_SERVICE_TYPE_SMS);
+ assertEquals(bsi.getBarringType(), BarringServiceInfo.BARRING_TYPE_NONE);
+ assertFalse(bsi.isConditionallyBarred());
+ assertEquals(bsi.getConditionalBarringFactor(), 0);
+ assertEquals(bsi.getConditionalBarringTimeSeconds(), 0);
+ }
+
+ /** Test that equality checks are correctly implemented */
+ @Test
+ public void testEquals() {
+ BarringInfo lhs = new BarringInfo(null, getBarringServiceInfos(false));
+ BarringInfo rhs = new BarringInfo(null, getBarringServiceInfos(false));
+ assertEquals(lhs, rhs);
+
+ rhs = new BarringInfo(null, getBarringServiceInfos(true));
+ assertNotEquals(lhs, rhs);
+ }
+
+ /** Test that when conditional barring is active, the service is considered barred */
+ @Test
+ public void testConditionalBarringCheck() {
+ BarringInfo condInfo = new BarringInfo(null, getBarringServiceInfos(false));
+ assertFalse(condInfo.getBarringServiceInfo(BarringInfo.BARRING_SERVICE_TYPE_MMTEL_VIDEO)
+ .isBarred());
+
+ condInfo = new BarringInfo(null, getBarringServiceInfos(true));
+ assertTrue(condInfo.getBarringServiceInfo(BarringInfo.BARRING_SERVICE_TYPE_MMTEL_VIDEO)
+ .isBarred());
+ }
+}
diff --git a/tests/telephonytests/src/com/android/internal/telephony/CellularNetworkValidatorTest.java b/tests/telephonytests/src/com/android/internal/telephony/CellularNetworkValidatorTest.java
index 470482b..155e3ea 100644
--- a/tests/telephonytests/src/com/android/internal/telephony/CellularNetworkValidatorTest.java
+++ b/tests/telephonytests/src/com/android/internal/telephony/CellularNetworkValidatorTest.java
@@ -27,6 +27,7 @@
import android.net.Network;
import android.net.NetworkCapabilities;
import android.net.NetworkRequest;
+import android.net.TelephonyNetworkSpecifier;
import android.telephony.PhoneCapability;
import android.telephony.SubscriptionManager;
import android.test.suitebuilder.annotation.SmallTest;
@@ -95,7 +96,8 @@
NetworkRequest expectedRequest = new NetworkRequest.Builder()
.addCapability(NetworkCapabilities.NET_CAPABILITY_INTERNET)
.addTransportType(NetworkCapabilities.TRANSPORT_CELLULAR)
- .setNetworkSpecifier(String.valueOf(subId))
+ .setNetworkSpecifier(new TelephonyNetworkSpecifier.Builder()
+ .setSubscriptionId(subId).build())
.build();
mValidatorUT.validate(subId, timeout, true, mCallback);
@@ -128,7 +130,8 @@
NetworkRequest expectedRequest = new NetworkRequest.Builder()
.addCapability(NetworkCapabilities.NET_CAPABILITY_INTERNET)
.addTransportType(NetworkCapabilities.TRANSPORT_CELLULAR)
- .setNetworkSpecifier(String.valueOf(subId))
+ .setNetworkSpecifier(new TelephonyNetworkSpecifier.Builder()
+ .setSubscriptionId(subId).build())
.build();
mValidatorUT.validate(subId, timeout, true, mCallback);
@@ -162,7 +165,8 @@
NetworkRequest expectedRequest = new NetworkRequest.Builder()
.addCapability(NetworkCapabilities.NET_CAPABILITY_INTERNET)
.addTransportType(NetworkCapabilities.TRANSPORT_CELLULAR)
- .setNetworkSpecifier(String.valueOf(subId))
+ .setNetworkSpecifier(new TelephonyNetworkSpecifier.Builder()
+ .setSubscriptionId(subId).build())
.build();
mValidatorUT.validate(subId, timeout, true, mCallback);
@@ -194,7 +198,8 @@
NetworkRequest expectedRequest = new NetworkRequest.Builder()
.addCapability(NetworkCapabilities.NET_CAPABILITY_INTERNET)
.addTransportType(NetworkCapabilities.TRANSPORT_CELLULAR)
- .setNetworkSpecifier(String.valueOf(subId))
+ .setNetworkSpecifier(new TelephonyNetworkSpecifier.Builder()
+ .setSubscriptionId(subId).build())
.build();
mValidatorUT.validate(subId, timeout, true, mCallback);
diff --git a/tests/telephonytests/src/com/android/internal/telephony/ContextFixture.java b/tests/telephonytests/src/com/android/internal/telephony/ContextFixture.java
index 4b19c72..6baa6aa 100644
--- a/tests/telephonytests/src/com/android/internal/telephony/ContextFixture.java
+++ b/tests/telephonytests/src/com/android/internal/telephony/ContextFixture.java
@@ -27,6 +27,7 @@
import static org.mockito.Mockito.spy;
import static org.mockito.Mockito.when;
+import android.app.ActivityManager;
import android.app.AlarmManager;
import android.app.AppOpsManager;
import android.app.DownloadManager;
@@ -54,6 +55,7 @@
import android.database.Cursor;
import android.database.MatrixCursor;
import android.net.ConnectivityManager;
+import android.net.Network;
import android.net.Uri;
import android.net.wifi.WifiManager;
import android.os.BatteryManager;
@@ -226,6 +228,8 @@
switch (name) {
case Context.TELEPHONY_SERVICE:
return mTelephonyManager;
+ case Context.ACTIVITY_SERVICE:
+ return mActivityManager;
case Context.APP_OPS_SERVICE:
return mAppOpsManager;
case Context.NOTIFICATION_SERVICE:
@@ -594,6 +598,7 @@
private final ApplicationInfo mApplicationInfo = mock(ApplicationInfo.class);
private final PackageManager mPackageManager = mock(PackageManager.class);
private final TelephonyManager mTelephonyManager = mock(TelephonyManager.class);
+ private final ActivityManager mActivityManager = mock(ActivityManager.class);
private final DownloadManager mDownloadManager = mock(DownloadManager.class);
private final AppOpsManager mAppOpsManager = mock(AppOpsManager.class);
private final NotificationManager mNotificationManager = mock(NotificationManager.class);
@@ -663,6 +668,9 @@
//doReturn(mBundle).when(mCarrierConfigManager).getConfig(anyInt());
doReturn(mBundle).when(mCarrierConfigManager).getConfig();
+ doReturn(mock(Network.class)).when(mConnectivityManager).registerNetworkAgent(
+ any(), any(), any(), any(), anyInt(), any(), anyInt());
+
doReturn(true).when(mEuiccManager).isEnabled();
mConfiguration.locale = Locale.US;
diff --git a/tests/telephonytests/src/com/android/internal/telephony/GsmCdmaPhoneTest.java b/tests/telephonytests/src/com/android/internal/telephony/GsmCdmaPhoneTest.java
index 0724864..c5369e7 100644
--- a/tests/telephonytests/src/com/android/internal/telephony/GsmCdmaPhoneTest.java
+++ b/tests/telephonytests/src/com/android/internal/telephony/GsmCdmaPhoneTest.java
@@ -884,7 +884,8 @@
Intent intent = intentArgumentCaptor.getValue();
assertEquals(TelephonyIntents.ACTION_EMERGENCY_CALLBACK_MODE_CHANGED, intent.getAction());
- assertEquals(true, intent.getBooleanExtra(PhoneConstants.PHONE_IN_ECM_STATE, false));
+ assertEquals(true, intent.getBooleanExtra(
+ TelephonyManager.EXTRA_PHONE_IN_ECM_STATE, false));
assertEquals(true, mPhoneUT.isInEcm());
// verify that wakeLock is acquired in ECM
@@ -907,7 +908,8 @@
intent = intentArgumentCaptor.getValue();
assertEquals(TelephonyIntents.ACTION_EMERGENCY_CALLBACK_MODE_CHANGED, intent.getAction());
- assertEquals(false, intent.getBooleanExtra(PhoneConstants.PHONE_IN_ECM_STATE, true));
+ assertEquals(false, intent.getBooleanExtra(
+ TelephonyManager.EXTRA_PHONE_IN_ECM_STATE, true));
assertEquals(false, mPhoneUT.isInEcm());
ArgumentCaptor<Message> messageArgumentCaptor = ArgumentCaptor.forClass(Message.class);
@@ -950,7 +952,8 @@
Intent intent = intentArgumentCaptor.getValue();
assertEquals(TelephonyIntents.ACTION_EMERGENCY_CALLBACK_MODE_CHANGED, intent.getAction());
- assertEquals(true, intent.getBooleanExtra(PhoneConstants.PHONE_IN_ECM_STATE, false));
+ assertEquals(true, intent.getBooleanExtra(
+ TelephonyManager.EXTRA_PHONE_IN_ECM_STATE, false));
assertEquals(true, mPhoneUT.isInEcm());
// verify that wakeLock is acquired in ECM
@@ -973,7 +976,8 @@
intent = intentArgumentCaptor.getValue();
assertEquals(TelephonyIntents.ACTION_EMERGENCY_CALLBACK_MODE_CHANGED, intent.getAction());
- assertEquals(false, intent.getBooleanExtra(PhoneConstants.PHONE_IN_ECM_STATE, true));
+ assertEquals(false, intent.getBooleanExtra(
+ TelephonyManager.EXTRA_PHONE_IN_ECM_STATE, true));
assertEquals(false, mPhoneUT.isInEcm());
ArgumentCaptor<Message> messageArgumentCaptor = ArgumentCaptor.forClass(Message.class);
diff --git a/tests/telephonytests/src/com/android/internal/telephony/NitzStateMachineImplTest.java b/tests/telephonytests/src/com/android/internal/telephony/NitzStateMachineImplTest.java
index 59b10f8..79140e4 100644
--- a/tests/telephonytests/src/com/android/internal/telephony/NitzStateMachineImplTest.java
+++ b/tests/telephonytests/src/com/android/internal/telephony/NitzStateMachineImplTest.java
@@ -36,10 +36,10 @@
import android.app.timedetector.PhoneTimeSuggestion;
import android.icu.util.TimeZone;
import android.os.TimestampedValue;
+import android.timezone.CountryTimeZones.OffsetResult;
import com.android.internal.telephony.NitzStateMachineTestSupport.FakeDeviceState;
import com.android.internal.telephony.NitzStateMachineTestSupport.Scenario;
-import com.android.internal.telephony.TimeZoneLookupHelper.OffsetResult;
import org.junit.After;
import org.junit.Before;
@@ -1166,7 +1166,7 @@
String expectedZoneId = result.getTimeZone().getID();
// All our scenarios should return multiple matches. The only cases where this wouldn't be
// true are places that use offsets like XX:15, XX:30 and XX:45.
- assertFalse(result.getIsOnlyMatch());
+ assertFalse(result.isOnlyMatch());
assertSameOffset(scenario.getActualTimeMillis(), expectedZoneId, scenario.getTimeZoneId());
return expectedZoneId;
}
diff --git a/tests/telephonytests/src/com/android/internal/telephony/NitzStateMachineTestSupportTest.java b/tests/telephonytests/src/com/android/internal/telephony/NitzStateMachineTestSupportTest.java
index 4df0adf..dfeafee 100644
--- a/tests/telephonytests/src/com/android/internal/telephony/NitzStateMachineTestSupportTest.java
+++ b/tests/telephonytests/src/com/android/internal/telephony/NitzStateMachineTestSupportTest.java
@@ -38,8 +38,9 @@
import static org.junit.Assert.assertFalse;
import static org.junit.Assert.assertTrue;
+import android.timezone.CountryTimeZones.OffsetResult;
+
import com.android.internal.telephony.TimeZoneLookupHelper.CountryResult;
-import com.android.internal.telephony.TimeZoneLookupHelper.OffsetResult;
import org.junit.Before;
import org.junit.Test;
@@ -115,7 +116,7 @@
NON_UNIQUE_US_ZONE_SCENARIO.getNetworkCountryIsoCode());
List<String> possibleZones = Arrays.asList(NON_UNIQUE_US_ZONE_SCENARIO_ZONES);
assertTrue(possibleZones.contains(actualLookupResult.getTimeZone().getID()));
- assertFalse(actualLookupResult.getIsOnlyMatch());
+ assertFalse(actualLookupResult.isOnlyMatch());
}
}
diff --git a/tests/telephonytests/src/com/android/internal/telephony/PhoneFactoryTest.java b/tests/telephonytests/src/com/android/internal/telephony/PhoneFactoryTest.java
index 2f03537..d1aea03 100644
--- a/tests/telephonytests/src/com/android/internal/telephony/PhoneFactoryTest.java
+++ b/tests/telephonytests/src/com/android/internal/telephony/PhoneFactoryTest.java
@@ -18,7 +18,6 @@
import static org.junit.Assert.fail;
-import android.net.NetworkFactory;
import android.test.suitebuilder.annotation.SmallTest;
import org.junit.Test;
@@ -28,25 +27,25 @@
@SmallTest
public void testBeforeMakePhone() {
try {
- Phone phone = PhoneFactory.getDefaultPhone();
+ PhoneFactory.getDefaultPhone();
fail("Expecting IllegalStateException");
} catch (IllegalStateException e) {
}
try {
- Phone phone = PhoneFactory.getPhone(0);
+ PhoneFactory.getPhone(0);
fail("Expecting IllegalStateException");
} catch (IllegalStateException e) {
}
try {
- Phone[] phone = PhoneFactory.getPhones();
+ PhoneFactory.getPhones();
fail("Expecting IllegalStateException");
} catch (IllegalStateException e) {
}
try {
- NetworkFactory factory = PhoneFactory.getNetworkFactory(0);
+ PhoneFactory.getNetworkFactory(0);
fail("Expecting IllegalStateException");
} catch (IllegalStateException e) {
}
diff --git a/tests/telephonytests/src/com/android/internal/telephony/PhoneSwitcherTest.java b/tests/telephonytests/src/com/android/internal/telephony/PhoneSwitcherTest.java
index 50fe0b6..443eb4d 100644
--- a/tests/telephonytests/src/com/android/internal/telephony/PhoneSwitcherTest.java
+++ b/tests/telephonytests/src/com/android/internal/telephony/PhoneSwitcherTest.java
@@ -49,7 +49,7 @@
import android.net.NetworkCapabilities;
import android.net.NetworkProvider;
import android.net.NetworkRequest;
-import android.net.StringNetworkSpecifier;
+import android.net.TelephonyNetworkSpecifier;
import android.os.AsyncResult;
import android.os.Handler;
import android.os.Looper;
@@ -1165,7 +1165,8 @@
}
if (subId != null) {
- netCap.setNetworkSpecifier(new StringNetworkSpecifier(Integer.toString(subId)));
+ netCap.setNetworkSpecifier(new TelephonyNetworkSpecifier.Builder()
+ .setSubscriptionId(subId).build());
}
NetworkRequest networkRequest = new NetworkRequest(netCap, ConnectivityManager.TYPE_NONE,
0, NetworkRequest.Type.REQUEST);
@@ -1188,9 +1189,9 @@
.addCapability(NetworkCapabilities.NET_CAPABILITY_MMS)
.addCapability(NetworkCapabilities.NET_CAPABILITY_NOT_RESTRICTED)
.addTransportType(NetworkCapabilities.TRANSPORT_CELLULAR);
- netCap.setNetworkSpecifier(new StringNetworkSpecifier(Integer.toString(subId)));
if (subId != null) {
- netCap.setNetworkSpecifier(new StringNetworkSpecifier(Integer.toString(subId)));
+ netCap.setNetworkSpecifier(new TelephonyNetworkSpecifier.Builder()
+ .setSubscriptionId(subId).build());
}
NetworkRequest networkRequest = new NetworkRequest(netCap, ConnectivityManager.TYPE_NONE,
1, NetworkRequest.Type.REQUEST);
diff --git a/tests/telephonytests/src/com/android/internal/telephony/ServiceStateTest.java b/tests/telephonytests/src/com/android/internal/telephony/ServiceStateTest.java
index a4ad189..8fad853 100644
--- a/tests/telephonytests/src/com/android/internal/telephony/ServiceStateTest.java
+++ b/tests/telephonytests/src/com/android/internal/telephony/ServiceStateTest.java
@@ -165,6 +165,7 @@
rats.add(new Pair<Integer, Boolean>(ServiceState.RIL_RADIO_TECHNOLOGY_GSM, false));
rats.add(new Pair<Integer, Boolean>(ServiceState.RIL_RADIO_TECHNOLOGY_TD_SCDMA, false));
rats.add(new Pair<Integer, Boolean>(ServiceState.RIL_RADIO_TECHNOLOGY_IWLAN, false));
+ rats.add(new Pair<Integer, Boolean>(ServiceState.RIL_RADIO_TECHNOLOGY_NR, false));
for (Pair<Integer, Boolean> rat : rats) {
boolean isCdma = rat.second;
diff --git a/tests/telephonytests/src/com/android/internal/telephony/SubscriptionInfoUpdaterTest.java b/tests/telephonytests/src/com/android/internal/telephony/SubscriptionInfoUpdaterTest.java
index 5e08080..e28e824 100644
--- a/tests/telephonytests/src/com/android/internal/telephony/SubscriptionInfoUpdaterTest.java
+++ b/tests/telephonytests/src/com/android/internal/telephony/SubscriptionInfoUpdaterTest.java
@@ -315,6 +315,8 @@
.getSubInfoUsingSlotIndexPrivileged(eq(FAKE_SUB_ID_1));
doReturn("89012604200000000000").when(mIccRecord).getFullIccId();
doReturn(FAKE_MCC_MNC_1).when(mTelephonyManager).getSimOperatorNumeric(FAKE_SUB_ID_1);
+ when(mActivityManager.updateMccMncConfiguration(anyString(), anyString())).thenReturn(
+ true);
mUpdater.updateInternalIccState(
IccCardConstants.INTENT_VALUE_ICC_LOADED, null, FAKE_SUB_ID_1, false);
@@ -445,6 +447,8 @@
doReturn(FAKE_SUB_ID_2).when(mSubscriptionController).getPhoneId(eq(FAKE_SUB_ID_2));
doReturn(2).when(mTelephonyManager).getPhoneCount();
doReturn(2).when(mTelephonyManager).getActiveModemCount();
+ when(mActivityManager.updateMccMncConfiguration(anyString(), anyString())).thenReturn(
+ true);
doReturn(FAKE_MCC_MNC_1).when(mTelephonyManager).getSimOperatorNumeric(eq(FAKE_SUB_ID_1));
doReturn(FAKE_MCC_MNC_2).when(mTelephonyManager).getSimOperatorNumeric(eq(FAKE_SUB_ID_2));
verify(mSubscriptionController, times(0)).clearSubInfo();
diff --git a/tests/telephonytests/src/com/android/internal/telephony/TelephonyTest.java b/tests/telephonytests/src/com/android/internal/telephony/TelephonyTest.java
index b861a26..a928b58 100644
--- a/tests/telephonytests/src/com/android/internal/telephony/TelephonyTest.java
+++ b/tests/telephonytests/src/com/android/internal/telephony/TelephonyTest.java
@@ -268,6 +268,7 @@
@Mock
protected IccCard mIccCard;
+ protected ActivityManager mActivityManager;
protected ImsCallProfile mImsCallProfile;
protected TelephonyManager mTelephonyManager;
protected TelephonyRegistryManager mTelephonyRegistryManager;
@@ -383,7 +384,6 @@
protected void setUp(String tag) throws Exception {
TAG = tag;
MockitoAnnotations.initMocks(this);
- TelephonyManager.disableServiceHandleCaching();
mPhones = new Phone[] {mPhone};
mImsCallProfile = new ImsCallProfile();
@@ -399,6 +399,7 @@
doReturn(mUiccProfile).when(mUiccCard).getUiccProfile();
mTelephonyManager = (TelephonyManager) mContext.getSystemService(Context.TELEPHONY_SERVICE);
+ mActivityManager = (ActivityManager) mContext.getSystemService(Context.ACTIVITY_SERVICE);
mTelephonyRegistryManager = (TelephonyRegistryManager) mContext.getSystemService(
Context.TELEPHONY_REGISTRY_SERVICE);
mSubscriptionManager = (SubscriptionManager) mContext.getSystemService(
@@ -646,7 +647,6 @@
sharedPreferences.edit().clear().commit();
restoreInstances();
- TelephonyManager.enableServiceHandleCaching();
}
protected static void logd(String s) {
diff --git a/tests/telephonytests/src/com/android/internal/telephony/TimeZoneLookupHelperTest.java b/tests/telephonytests/src/com/android/internal/telephony/TimeZoneLookupHelperTest.java
index 2a1befb..1d00bac 100644
--- a/tests/telephonytests/src/com/android/internal/telephony/TimeZoneLookupHelperTest.java
+++ b/tests/telephonytests/src/com/android/internal/telephony/TimeZoneLookupHelperTest.java
@@ -29,9 +29,9 @@
import android.icu.util.GregorianCalendar;
import android.icu.util.TimeZone;
+import android.timezone.CountryTimeZones.OffsetResult;
import com.android.internal.telephony.TimeZoneLookupHelper.CountryResult;
-import com.android.internal.telephony.TimeZoneLookupHelper.OffsetResult;
import org.junit.Before;
import org.junit.Test;
@@ -161,7 +161,7 @@
// The zone chosen is a side effect of zone ordering in the data files so we just check
// the isOnlyMatch value.
OffsetResult offsetResult = mTimeZoneLookupHelper.lookupByNitzCountry(nitzData, usIso);
- assertFalse(offsetResult.getIsOnlyMatch());
+ assertFalse(offsetResult.isOnlyMatch());
}
// Try MDT / -6 hours in summer after America/North_Dakota/Beulah switched to central time.
@@ -169,7 +169,7 @@
String nitzString = "11/11/05,00:00:00-24,1"; // 2011-11-05 00:00:00 UTC, UTC-6, DST
NitzData nitzData = NitzData.parse(nitzString);
OffsetResult offsetResult = mTimeZoneLookupHelper.lookupByNitzCountry(nitzData, usIso);
- assertTrue(offsetResult.getIsOnlyMatch());
+ assertTrue(offsetResult.isOnlyMatch());
}
}
@@ -184,7 +184,7 @@
String nitzString = "15/06/01,00:00:00-24,1"; // 2015-06-01 00:00:00 UTC, UTC-6, DST
NitzData nitzData = NitzData.parse(nitzString);
OffsetResult offsetResult = mTimeZoneLookupHelper.lookupByNitzCountry(nitzData, usIso);
- assertTrue(offsetResult.getIsOnlyMatch());
+ assertTrue(offsetResult.isOnlyMatch());
}
// Try MST for a recent summer date: No ambiguity here.
@@ -192,7 +192,7 @@
String nitzString = "15/06/01,00:00:00-28,0"; // 2015-06-01 00:00:00 UTC, UTC-7, not DST
NitzData nitzData = NitzData.parse(nitzString);
OffsetResult offsetResult = mTimeZoneLookupHelper.lookupByNitzCountry(nitzData, usIso);
- assertTrue(offsetResult.getIsOnlyMatch());
+ assertTrue(offsetResult.isOnlyMatch());
}
// Try MST for a recent winter date: There are multiple zones to pick from because of the
@@ -201,7 +201,7 @@
String nitzString = "15/01/01,00:00:00-28,0"; // 2015-01-01 00:00:00 UTC, UTC-7, not DST
NitzData nitzData = NitzData.parse(nitzString);
OffsetResult offsetResult = mTimeZoneLookupHelper.lookupByNitzCountry(nitzData, usIso);
- assertFalse(offsetResult.getIsOnlyMatch());
+ assertFalse(offsetResult.isOnlyMatch());
}
}
@@ -376,7 +376,7 @@
OffsetResult majorityOffsetResult =
mTimeZoneLookupHelper.lookupByNitzCountry(majorityNitzData, countryIsoCode);
assertEquals(zone("Pacific/Auckland"), majorityOffsetResult.getTimeZone());
- assertTrue(majorityOffsetResult.getIsOnlyMatch());
+ assertTrue(majorityOffsetResult.isOnlyMatch());
// Data correct for the Chatham Islands.
int chathamWinterOffset = majorityWinterOffset + ((int) TimeUnit.MINUTES.toMillis(45));
@@ -385,7 +385,7 @@
OffsetResult chathamOffsetResult =
mTimeZoneLookupHelper.lookupByNitzCountry(chathamNitzData, countryIsoCode);
assertEquals(zone("Pacific/Chatham"), chathamOffsetResult.getTimeZone());
- assertTrue(chathamOffsetResult.getIsOnlyMatch());
+ assertTrue(chathamOffsetResult.isOnlyMatch());
// NITZ data that makes no sense for NZ results in no match.
int nonsenseOffset = (int) TimeUnit.HOURS.toMillis(5);
@@ -416,7 +416,7 @@
OffsetResult chuukOffsetResult =
mTimeZoneLookupHelper.lookupByNitzCountry(chuukNitzData, countryIsoCode);
assertEquals(zone("Pacific/Chuuk"), chuukOffsetResult.getTimeZone());
- assertTrue(chuukOffsetResult.getIsOnlyMatch());
+ assertTrue(chuukOffsetResult.isOnlyMatch());
// NITZ data that makes no sense for FM: no boost means we should get nothing.
int nonsenseOffset = (int) TimeUnit.HOURS.toMillis(5);
@@ -470,7 +470,7 @@
}
private static void assertOffsetResultMetadata(boolean isOnlyMatch, OffsetResult lookupResult) {
- assertEquals(isOnlyMatch, lookupResult.getIsOnlyMatch());
+ assertEquals(isOnlyMatch, lookupResult.isOnlyMatch());
}
private static long createUtcTime(
diff --git a/tests/telephonytests/src/com/android/internal/telephony/dataconnection/TelephonyNetworkFactoryTest.java b/tests/telephonytests/src/com/android/internal/telephony/dataconnection/TelephonyNetworkFactoryTest.java
index e9d360c..54d4c70 100644
--- a/tests/telephonytests/src/com/android/internal/telephony/dataconnection/TelephonyNetworkFactoryTest.java
+++ b/tests/telephonytests/src/com/android/internal/telephony/dataconnection/TelephonyNetworkFactoryTest.java
@@ -16,9 +16,8 @@
package com.android.internal.telephony.dataconnection;
-import static android.net.NetworkFactory.CMD_CANCEL_REQUEST;
-import static android.net.NetworkFactory.CMD_REQUEST_NETWORK;
-
+import static com.android.internal.telephony.NetworkFactory.CMD_CANCEL_REQUEST;
+import static com.android.internal.telephony.NetworkFactory.CMD_REQUEST_NETWORK;
import static com.android.internal.telephony.dataconnection.TelephonyNetworkFactory.EVENT_ACTIVE_PHONE_SWITCH;
import static org.junit.Assert.assertEquals;
@@ -34,7 +33,7 @@
import android.net.NetworkCapabilities;
import android.net.NetworkRequest;
-import android.net.StringNetworkSpecifier;
+import android.net.TelephonyNetworkSpecifier;
import android.os.AsyncResult;
import android.os.Handler;
import android.os.Looper;
@@ -93,7 +92,8 @@
addCapability(NetworkCapabilities.NET_CAPABILITY_INTERNET).
addCapability(NetworkCapabilities.NET_CAPABILITY_NOT_RESTRICTED).
addTransportType(NetworkCapabilities.TRANSPORT_CELLULAR);
- netCap.setNetworkSpecifier(new StringNetworkSpecifier(Integer.toString(subId)));
+ netCap.setNetworkSpecifier(new TelephonyNetworkSpecifier.Builder()
+ .setSubscriptionId(subId).build());
NetworkRequest networkRequest = new NetworkRequest(netCap, -1,
mRequestId++, NetworkRequest.Type.REQUEST);
mTelephonyNetworkFactoryUT.obtainMessage(CMD_REQUEST_NETWORK, 0, 0, networkRequest)
@@ -118,7 +118,8 @@
addCapability(NetworkCapabilities.NET_CAPABILITY_MMS).
addCapability(NetworkCapabilities.NET_CAPABILITY_NOT_RESTRICTED).
addTransportType(NetworkCapabilities.TRANSPORT_CELLULAR);
- netCap.setNetworkSpecifier(new StringNetworkSpecifier(Integer.toString(subId)));
+ netCap.setNetworkSpecifier(new TelephonyNetworkSpecifier.Builder()
+ .setSubscriptionId(subId).build());
NetworkRequest networkRequest = new NetworkRequest(netCap, -1,
mRequestId++, NetworkRequest.Type.REQUEST);
mTelephonyNetworkFactoryUT.obtainMessage(CMD_REQUEST_NETWORK, 0, 0, networkRequest)
diff --git a/tests/telephonytests/src/com/android/internal/telephony/gsm/GsmInboundSmsHandlerTest.java b/tests/telephonytests/src/com/android/internal/telephony/gsm/GsmInboundSmsHandlerTest.java
index 90610c7..016421c 100644
--- a/tests/telephonytests/src/com/android/internal/telephony/gsm/GsmInboundSmsHandlerTest.java
+++ b/tests/telephonytests/src/com/android/internal/telephony/gsm/GsmInboundSmsHandlerTest.java
@@ -198,6 +198,7 @@
UserManager userManager = (UserManager)mContext.getSystemService(Context.USER_SERVICE);
doReturn(true).when(userManager).isUserUnlocked();
+ doReturn(true).when(userManager).isUserRunning(any(UserHandle.class));
List<UserHandle> userHandles = new ArrayList();
userHandles.add(UserHandle.SYSTEM);
diff --git a/tests/telephonytests/src/com/android/internal/telephony/imsphone/ImsPhoneTest.java b/tests/telephonytests/src/com/android/internal/telephony/imsphone/ImsPhoneTest.java
index 60961e7..cc668bd 100644
--- a/tests/telephonytests/src/com/android/internal/telephony/imsphone/ImsPhoneTest.java
+++ b/tests/telephonytests/src/com/android/internal/telephony/imsphone/ImsPhoneTest.java
@@ -54,6 +54,7 @@
import android.sysprop.TelephonyProperties;
import android.telephony.CarrierConfigManager;
import android.telephony.ServiceState;
+import android.telephony.TelephonyManager;
import android.telephony.ims.ImsCallProfile;
import android.telephony.ims.ImsReasonInfo;
import android.telephony.ims.RegistrationManager;
@@ -584,7 +585,8 @@
Intent intent = intentArgumentCaptor.getValue();
assertEquals(TelephonyIntents.ACTION_EMERGENCY_CALLBACK_MODE_CHANGED, intent.getAction());
- assertEquals(true, intent.getBooleanExtra(PhoneConstants.PHONE_IN_ECM_STATE, false));
+ assertEquals(true, intent.getBooleanExtra(
+ TelephonyManager.EXTRA_PHONE_IN_ECM_STATE, false));
// verify that wakeLock is acquired in ECM
assertEquals(true, mImsPhoneUT.getWakeLock().isHeld());
@@ -612,7 +614,8 @@
intent = intentArgumentCaptor.getValue();
assertEquals(TelephonyIntents.ACTION_EMERGENCY_CALLBACK_MODE_CHANGED, intent.getAction());
- assertEquals(false, intent.getBooleanExtra(PhoneConstants.PHONE_IN_ECM_STATE, true));
+ assertEquals(false, intent.getBooleanExtra(
+ TelephonyManager.EXTRA_PHONE_IN_ECM_STATE, true));
ArgumentCaptor<Message> messageArgumentCaptor = ArgumentCaptor.forClass(Message.class);