diff options
17 files changed, 284 insertions, 161 deletions
diff --git a/core/java/android/service/carrier/CarrierIdentifier.java b/core/java/android/service/carrier/CarrierIdentifier.java index 3b71aa740fc0..4b3e7d370185 100644 --- a/core/java/android/service/carrier/CarrierIdentifier.java +++ b/core/java/android/service/carrier/CarrierIdentifier.java @@ -20,6 +20,7 @@ import android.annotation.NonNull; import android.annotation.Nullable; import android.os.Parcel; import android.os.Parcelable; +import android.telephony.Rlog; import android.telephony.TelephonyManager; import com.android.internal.telephony.uicc.IccUtils; @@ -223,7 +224,7 @@ public class CarrierIdentifier implements Parcelable { + "mcc=" + mMcc + ",mnc=" + mMnc + ",spn=" + mSpn - + ",imsi=" + mImsi + + ",imsi=" + Rlog.pii(false, mImsi) + ",gid1=" + mGid1 + ",gid2=" + mGid2 + ",carrierid=" + mCarrierId diff --git a/core/java/android/view/LayoutInflater.java b/core/java/android/view/LayoutInflater.java index 2ee72bffc9ec..ae2deb97c756 100644 --- a/core/java/android/view/LayoutInflater.java +++ b/core/java/android/view/LayoutInflater.java @@ -512,7 +512,7 @@ public abstract class LayoutInflater { String layout = res.getResourceEntryName(resource); try { - Class clazz = mPrecompiledClassLoader.loadClass("" + pkg + ".CompiledView"); + Class clazz = Class.forName("" + pkg + ".CompiledView", false, mPrecompiledClassLoader); Method inflater = clazz.getMethod(layout, Context.class, int.class); View view = (View) inflater.invoke(null, mContext, resource); @@ -731,8 +731,8 @@ public abstract class LayoutInflater { if (constructor == null) { // Class not found in the cache, see if it's real, and try to add it - clazz = mContext.getClassLoader().loadClass( - prefix != null ? (prefix + name) : name).asSubclass(View.class); + clazz = Class.forName(prefix != null ? (prefix + name) : name, false, + mContext.getClassLoader()).asSubclass(View.class); if (mFilter != null && clazz != null) { boolean allowed = mFilter.onLoadClass(clazz); @@ -750,8 +750,8 @@ public abstract class LayoutInflater { Boolean allowedState = mFilterMap.get(name); if (allowedState == null) { // New class -- remember whether it is allowed - clazz = mContext.getClassLoader().loadClass( - prefix != null ? (prefix + name) : name).asSubclass(View.class); + clazz = Class.forName(prefix != null ? (prefix + name) : name, false, + mContext.getClassLoader()).asSubclass(View.class); boolean allowed = clazz != null && mFilter.onLoadClass(clazz); mFilterMap.put(name, allowed); diff --git a/core/res/Android.bp b/core/res/Android.bp index e66f1a25e1cd..4e60f8ca025c 100644 --- a/core/res/Android.bp +++ b/core/res/Android.bp @@ -39,3 +39,12 @@ android_app { // PRODUCT-agnostic resource data like IDs and type definitions. export_package_resources: true, } + +// This logic can be removed once robolectric's transition to binary resources is complete +filegroup { + name: "robolectric_framework_raw_res_files", + srcs: [ + "assets/**/*", + "res/**/*", + ], +} diff --git a/media/jni/Android.bp b/media/jni/Android.bp index 5966192707f7..7a41c775b149 100644 --- a/media/jni/Android.bp +++ b/media/jni/Android.bp @@ -151,6 +151,8 @@ cc_library_shared { "libutils", // Have to use shared lib to make libandroid_runtime behave correctly. // Otherwise, AndroidRuntime::getJNIEnv() will return NULL. + + "libcgrouprc", // LL-NDK ], header_libs: ["libhardware_headers"], diff --git a/packages/NetworkStack/tests/Android.bp b/packages/NetworkStack/tests/Android.bp index aadf99ec37d0..f256b61fb16c 100644 --- a/packages/NetworkStack/tests/Android.bp +++ b/packages/NetworkStack/tests/Android.bp @@ -42,6 +42,7 @@ android_test { "libbinder", "libbinderthreadstate", "libc++", + "libcgrouprc", "libcrypto", "libcutils", "libdexfile", diff --git a/services/core/java/com/android/server/IpSecService.java b/services/core/java/com/android/server/IpSecService.java index 126bf6556538..2cfcecca5f99 100644 --- a/services/core/java/com/android/server/IpSecService.java +++ b/services/core/java/com/android/server/IpSecService.java @@ -96,9 +96,10 @@ public class IpSecService extends IIpSecService.Stub { new int[] {OsConstants.AF_INET, OsConstants.AF_INET6}; private static final int NETD_FETCH_TIMEOUT_MS = 5000; // ms - private static final int MAX_PORT_BIND_ATTEMPTS = 10; private static final InetAddress INADDR_ANY; + @VisibleForTesting static final int MAX_PORT_BIND_ATTEMPTS = 10; + static { try { INADDR_ANY = InetAddress.getByAddress(new byte[] {0, 0, 0, 0}); diff --git a/services/core/java/com/android/server/connectivity/PermissionMonitor.java b/services/core/java/com/android/server/connectivity/PermissionMonitor.java index da1360d59539..b6946023e870 100644 --- a/services/core/java/com/android/server/connectivity/PermissionMonitor.java +++ b/services/core/java/com/android/server/connectivity/PermissionMonitor.java @@ -469,7 +469,10 @@ public class PermissionMonitor { */ @VisibleForTesting void sendPackagePermissionsToNetd(SparseIntArray netdPermissionsAppIds) { - + if (mNetd == null) { + Log.e(TAG, "Failed to get the netd service"); + return; + } ArrayList<Integer> allPermissionAppIds = new ArrayList<>(); ArrayList<Integer> internetPermissionAppIds = new ArrayList<>(); ArrayList<Integer> updateStatsPermissionAppIds = new ArrayList<>(); diff --git a/telephony/java/android/telephony/DataSpecificRegistrationInfo.java b/telephony/java/android/telephony/DataSpecificRegistrationInfo.java index 465c2b1be3d9..2cb369d28029 100644 --- a/telephony/java/android/telephony/DataSpecificRegistrationInfo.java +++ b/telephony/java/android/telephony/DataSpecificRegistrationInfo.java @@ -78,7 +78,7 @@ public final class DataSpecificRegistrationInfo implements Parcelable { * * @hide */ - public final boolean isUsingCarrierAggregation; + public boolean mIsUsingCarrierAggregation; /** * @hide @@ -92,7 +92,7 @@ public final class DataSpecificRegistrationInfo implements Parcelable { this.isNrAvailable = isNrAvailable; this.isEnDcAvailable = isEnDcAvailable; this.mLteVopsSupportInfo = lteVops; - this.isUsingCarrierAggregation = isUsingCarrierAggregation; + this.mIsUsingCarrierAggregation = isUsingCarrierAggregation; } private DataSpecificRegistrationInfo(Parcel source) { @@ -101,7 +101,7 @@ public final class DataSpecificRegistrationInfo implements Parcelable { isNrAvailable = source.readBoolean(); isEnDcAvailable = source.readBoolean(); mLteVopsSupportInfo = LteVopsSupportInfo.CREATOR.createFromParcel(source); - isUsingCarrierAggregation = source.readBoolean(); + mIsUsingCarrierAggregation = source.readBoolean(); } @Override @@ -111,7 +111,7 @@ public final class DataSpecificRegistrationInfo implements Parcelable { dest.writeBoolean(isNrAvailable); dest.writeBoolean(isEnDcAvailable); mLteVopsSupportInfo.writeToParcel(dest, flags); - dest.writeBoolean(isUsingCarrierAggregation); + dest.writeBoolean(mIsUsingCarrierAggregation); } @Override @@ -128,7 +128,7 @@ public final class DataSpecificRegistrationInfo implements Parcelable { .append(" isNrAvailable = " + isNrAvailable) .append(" isEnDcAvailable = " + isEnDcAvailable) .append(" " + mLteVopsSupportInfo.toString()) - .append(" isUsingCarrierAggregation = " + isUsingCarrierAggregation) + .append(" mIsUsingCarrierAggregation = " + mIsUsingCarrierAggregation) .append(" }") .toString(); } @@ -136,7 +136,7 @@ public final class DataSpecificRegistrationInfo implements Parcelable { @Override public int hashCode() { return Objects.hash(maxDataCalls, isDcNrRestricted, isNrAvailable, isEnDcAvailable, - mLteVopsSupportInfo, isUsingCarrierAggregation); + mLteVopsSupportInfo, mIsUsingCarrierAggregation); } @Override @@ -151,7 +151,7 @@ public final class DataSpecificRegistrationInfo implements Parcelable { && this.isNrAvailable == other.isNrAvailable && this.isEnDcAvailable == other.isEnDcAvailable && this.mLteVopsSupportInfo.equals(other.mLteVopsSupportInfo) - && this.isUsingCarrierAggregation == other.isUsingCarrierAggregation; + && this.mIsUsingCarrierAggregation == other.mIsUsingCarrierAggregation; } public static final @NonNull Parcelable.Creator<DataSpecificRegistrationInfo> CREATOR = @@ -174,4 +174,22 @@ public final class DataSpecificRegistrationInfo implements Parcelable { public LteVopsSupportInfo getLteVopsSupportInfo() { return mLteVopsSupportInfo; } + + /** + * Set the flag indicating if using carrier aggregation. + * + * @param isUsingCarrierAggregation {@code true} if using carrier aggregation. + * @hide + */ + public void setIsUsingCarrierAggregation(boolean isUsingCarrierAggregation) { + mIsUsingCarrierAggregation = isUsingCarrierAggregation; + } + + /** + * @return {@code true} if using carrier aggregation. + * @hide + */ + public boolean isUsingCarrierAggregation() { + return mIsUsingCarrierAggregation; + } } diff --git a/telephony/java/android/telephony/NetworkRegistrationInfo.java b/telephony/java/android/telephony/NetworkRegistrationInfo.java index 2bb02e7af1e0..7b9f6d5eb8a1 100644 --- a/telephony/java/android/telephony/NetworkRegistrationInfo.java +++ b/telephony/java/android/telephony/NetworkRegistrationInfo.java @@ -368,6 +368,13 @@ public final class NetworkRegistrationInfo implements Parcelable { * @hide */ public void setAccessNetworkTechnology(@NetworkType int tech) { + if (tech == TelephonyManager.NETWORK_TYPE_LTE_CA) { + // For old device backward compatibility support + tech = TelephonyManager.NETWORK_TYPE_LTE; + if (mDataSpecificInfo != null) { + mDataSpecificInfo.setIsUsingCarrierAggregation(true); + } + } mAccessNetworkTechnology = tech; } diff --git a/telephony/java/android/telephony/PhoneNumberUtils.java b/telephony/java/android/telephony/PhoneNumberUtils.java index 549c04420ce0..b75e51577fdb 100644 --- a/telephony/java/android/telephony/PhoneNumberUtils.java +++ b/telephony/java/android/telephony/PhoneNumberUtils.java @@ -2016,7 +2016,16 @@ public class PhoneNumberUtils { private static boolean isEmergencyNumberInternal(int subId, String number, String defaultCountryIso, boolean useExactMatch) { - return TelephonyManager.getDefault().isEmergencyNumber(number); + try { + if (useExactMatch) { + return TelephonyManager.getDefault().isEmergencyNumber(number); + } else { + return TelephonyManager.getDefault().isPotentialEmergencyNumber(number); + } + } catch (RuntimeException ex) { + Rlog.e(LOG_TAG, "isEmergencyNumberInternal: RuntimeException: " + ex); + } + return false; } /** diff --git a/telephony/java/android/telephony/ServiceState.java b/telephony/java/android/telephony/ServiceState.java index caf27b79dc13..f928ba0350aa 100644 --- a/telephony/java/android/telephony/ServiceState.java +++ b/telephony/java/android/telephony/ServiceState.java @@ -312,18 +312,6 @@ public class ServiceState implements Parcelable { private boolean mIsManualNetworkSelection; private boolean mIsEmergencyOnly; - /** - * TODO: remove mRilVoiceRadioTechnology after completely migrate to - * {@link TelephonyManager.NetworkType} - */ - @RilRadioTechnology - private int mRilVoiceRadioTechnology; - /** - * TODO: remove mRilDataRadioTechnology after completely migrate to - * {@link TelephonyManager.NetworkType} - */ - @RilRadioTechnology - private int mRilDataRadioTechnology; @UnsupportedAppUsage(maxTargetSdk = Build.VERSION_CODES.P, trackingBug = 115609023) private boolean mCssIndicator; @@ -340,9 +328,6 @@ public class ServiceState implements Parcelable { @UnsupportedAppUsage(maxTargetSdk = Build.VERSION_CODES.P, trackingBug = 115609023) private int mCdmaEriIconMode; - @UnsupportedAppUsage - private boolean mIsUsingCarrierAggregation; - @FrequencyRange private int mNrFrequencyRange; private int mChannelNumber; @@ -420,8 +405,6 @@ public class ServiceState implements Parcelable { mDataOperatorAlphaShort = s.mDataOperatorAlphaShort; mDataOperatorNumeric = s.mDataOperatorNumeric; mIsManualNetworkSelection = s.mIsManualNetworkSelection; - mRilVoiceRadioTechnology = s.mRilVoiceRadioTechnology; - mRilDataRadioTechnology = s.mRilDataRadioTechnology; mCssIndicator = s.mCssIndicator; mNetworkId = s.mNetworkId; mSystemId = s.mSystemId; @@ -430,7 +413,6 @@ public class ServiceState implements Parcelable { mCdmaEriIconIndex = s.mCdmaEriIconIndex; mCdmaEriIconMode = s.mCdmaEriIconMode; mIsEmergencyOnly = s.mIsEmergencyOnly; - mIsUsingCarrierAggregation = s.mIsUsingCarrierAggregation; mChannelNumber = s.mChannelNumber; mCellBandwidths = s.mCellBandwidths == null ? null : Arrays.copyOf(s.mCellBandwidths, s.mCellBandwidths.length); @@ -457,8 +439,6 @@ public class ServiceState implements Parcelable { mDataOperatorAlphaShort = in.readString(); mDataOperatorNumeric = in.readString(); mIsManualNetworkSelection = in.readInt() != 0; - mRilVoiceRadioTechnology = in.readInt(); - mRilDataRadioTechnology = in.readInt(); mCssIndicator = (in.readInt() != 0); mNetworkId = in.readInt(); mSystemId = in.readInt(); @@ -467,7 +447,6 @@ public class ServiceState implements Parcelable { mCdmaEriIconIndex = in.readInt(); mCdmaEriIconMode = in.readInt(); mIsEmergencyOnly = in.readInt() != 0; - mIsUsingCarrierAggregation = in.readInt() != 0; mLteEarfcnRsrpBoost = in.readInt(); mNetworkRegistrationInfos = new ArrayList<>(); in.readList(mNetworkRegistrationInfos, NetworkRegistrationInfo.class.getClassLoader()); @@ -486,8 +465,6 @@ public class ServiceState implements Parcelable { out.writeString(mDataOperatorAlphaShort); out.writeString(mDataOperatorNumeric); out.writeInt(mIsManualNetworkSelection ? 1 : 0); - out.writeInt(mRilVoiceRadioTechnology); - out.writeInt(mRilDataRadioTechnology); out.writeInt(mCssIndicator ? 1 : 0); out.writeInt(mNetworkId); out.writeInt(mSystemId); @@ -496,7 +473,6 @@ public class ServiceState implements Parcelable { out.writeInt(mCdmaEriIconIndex); out.writeInt(mCdmaEriIconMode); out.writeInt(mIsEmergencyOnly ? 1 : 0); - out.writeInt(mIsUsingCarrierAggregation ? 1 : 0); out.writeInt(mLteEarfcnRsrpBoost); out.writeList(mNetworkRegistrationInfos); out.writeInt(mChannelNumber); @@ -568,7 +544,7 @@ public class ServiceState implements Parcelable { @DuplexMode public int getDuplexMode() { // only support LTE duplex mode - if (!isLte(mRilDataRadioTechnology)) { + if (!isLte(getRilDataRadioTechnology())) { return DUPLEX_MODE_UNKNOWN; } @@ -850,8 +826,6 @@ public class ServiceState implements Parcelable { mDataOperatorAlphaShort, mDataOperatorNumeric, mIsManualNetworkSelection, - mRilVoiceRadioTechnology, - mRilDataRadioTechnology, mCssIndicator, mNetworkId, mSystemId, @@ -860,7 +834,6 @@ public class ServiceState implements Parcelable { mCdmaEriIconIndex, mCdmaEriIconMode, mIsEmergencyOnly, - mIsUsingCarrierAggregation, mLteEarfcnRsrpBoost, mNetworkRegistrationInfos, mNrFrequencyRange); @@ -871,7 +844,7 @@ public class ServiceState implements Parcelable { if (!(o instanceof ServiceState)) return false; ServiceState s = (ServiceState) o; - return (mVoiceRegState == s.mVoiceRegState + return mVoiceRegState == s.mVoiceRegState && mDataRegState == s.mDataRegState && mIsManualNetworkSelection == s.mIsManualNetworkSelection && mChannelNumber == s.mChannelNumber @@ -882,8 +855,6 @@ public class ServiceState implements Parcelable { && equalsHandlesNulls(mDataOperatorAlphaLong, s.mDataOperatorAlphaLong) && equalsHandlesNulls(mDataOperatorAlphaShort, s.mDataOperatorAlphaShort) && equalsHandlesNulls(mDataOperatorNumeric, s.mDataOperatorNumeric) - && equalsHandlesNulls(mRilVoiceRadioTechnology, s.mRilVoiceRadioTechnology) - && equalsHandlesNulls(mRilDataRadioTechnology, s.mRilDataRadioTechnology) && equalsHandlesNulls(mCssIndicator, s.mCssIndicator) && equalsHandlesNulls(mNetworkId, s.mNetworkId) && equalsHandlesNulls(mSystemId, s.mSystemId) @@ -891,7 +862,6 @@ public class ServiceState implements Parcelable { && equalsHandlesNulls(mCdmaDefaultRoamingIndicator, s.mCdmaDefaultRoamingIndicator) && mIsEmergencyOnly == s.mIsEmergencyOnly - && mIsUsingCarrierAggregation == s.mIsUsingCarrierAggregation) && (mNetworkRegistrationInfos == null ? s.mNetworkRegistrationInfos == null : s.mNetworkRegistrationInfos != null && mNetworkRegistrationInfos.containsAll(s.mNetworkRegistrationInfos)) @@ -1035,27 +1005,27 @@ public class ServiceState implements Parcelable { .append(", mDataOperatorAlphaShort=").append(mDataOperatorAlphaShort) .append(", isManualNetworkSelection=").append(mIsManualNetworkSelection) .append(mIsManualNetworkSelection ? "(manual)" : "(automatic)") - .append(", mRilVoiceRadioTechnology=").append(mRilVoiceRadioTechnology) - .append("(" + rilRadioTechnologyToString(mRilVoiceRadioTechnology) + ")") - .append(", mRilDataRadioTechnology=").append(mRilDataRadioTechnology) - .append("(" + rilRadioTechnologyToString(mRilDataRadioTechnology) + ")") + .append(", getRilVoiceRadioTechnology=").append(getRilVoiceRadioTechnology()) + .append("(" + rilRadioTechnologyToString(getRilVoiceRadioTechnology()) + ")") + .append(", getRilDataRadioTechnology=").append(getRilDataRadioTechnology()) + .append("(" + rilRadioTechnologyToString(getRilDataRadioTechnology()) + ")") .append(", mCssIndicator=").append(mCssIndicator ? "supported" : "unsupported") .append(", mNetworkId=").append(mNetworkId) .append(", mSystemId=").append(mSystemId) .append(", mCdmaRoamingIndicator=").append(mCdmaRoamingIndicator) .append(", mCdmaDefaultRoamingIndicator=").append(mCdmaDefaultRoamingIndicator) .append(", mIsEmergencyOnly=").append(mIsEmergencyOnly) - .append(", mIsUsingCarrierAggregation=").append(mIsUsingCarrierAggregation) + .append(", isUsingCarrierAggregation=").append(isUsingCarrierAggregation()) .append(", mLteEarfcnRsrpBoost=").append(mLteEarfcnRsrpBoost) .append(", mNetworkRegistrationInfos=").append(mNetworkRegistrationInfos) .append(", mNrFrequencyRange=").append(mNrFrequencyRange) .append("}").toString(); } - private void setNullState(int state) { - if (DBG) Rlog.d(LOG_TAG, "[ServiceState] setNullState=" + state); - mVoiceRegState = state; - mDataRegState = state; + private void init() { + if (DBG) Rlog.d(LOG_TAG, "init"); + mVoiceRegState = STATE_OUT_OF_SERVICE; + mDataRegState = STATE_OUT_OF_SERVICE; mChannelNumber = -1; mCellBandwidths = new int[0]; mVoiceOperatorAlphaLong = null; @@ -1065,8 +1035,6 @@ public class ServiceState implements Parcelable { mDataOperatorAlphaShort = null; mDataOperatorNumeric = null; mIsManualNetworkSelection = false; - mRilVoiceRadioTechnology = 0; - mRilDataRadioTechnology = 0; mCssIndicator = false; mNetworkId = -1; mSystemId = -1; @@ -1075,18 +1043,28 @@ public class ServiceState implements Parcelable { mCdmaEriIconIndex = -1; mCdmaEriIconMode = -1; mIsEmergencyOnly = false; - mIsUsingCarrierAggregation = false; mLteEarfcnRsrpBoost = 0; - mNetworkRegistrationInfos = new ArrayList<>(); mNrFrequencyRange = FREQUENCY_RANGE_UNKNOWN; + addNetworkRegistrationInfo(new NetworkRegistrationInfo.Builder() + .setDomain(NetworkRegistrationInfo.DOMAIN_CS) + .setTransportType(AccessNetworkConstants.TRANSPORT_TYPE_WWAN) + .setRegistrationState(NetworkRegistrationInfo.REGISTRATION_STATE_UNKNOWN) + .build()); + addNetworkRegistrationInfo(new NetworkRegistrationInfo.Builder() + .setDomain(NetworkRegistrationInfo.DOMAIN_PS) + .setTransportType(AccessNetworkConstants.TRANSPORT_TYPE_WWAN) + .setRegistrationState(NetworkRegistrationInfo.REGISTRATION_STATE_UNKNOWN) + .build()); } public void setStateOutOfService() { - setNullState(STATE_OUT_OF_SERVICE); + init(); } public void setStateOff() { - setNullState(STATE_POWER_OFF); + init(); + mVoiceRegState = STATE_POWER_OFF; + mDataRegState = STATE_POWER_OFF; } public void setState(int state) { @@ -1304,8 +1282,8 @@ public class ServiceState implements Parcelable { m.putString("data-operator-alpha-short", mDataOperatorAlphaShort); m.putString("data-operator-numeric", mDataOperatorNumeric); m.putBoolean("manual", mIsManualNetworkSelection); - m.putInt("radioTechnology", mRilVoiceRadioTechnology); - m.putInt("dataRadioTechnology", mRilDataRadioTechnology); + m.putInt("radioTechnology", getRilVoiceRadioTechnology()); + m.putInt("dataRadioTechnology", getRadioTechnology()); m.putBoolean("cssIndicator", mCssIndicator); m.putInt("networkId", mNetworkId); m.putInt("systemId", mSystemId); @@ -1313,7 +1291,7 @@ public class ServiceState implements Parcelable { m.putInt("cdmaDefaultRoamingIndicator", mCdmaDefaultRoamingIndicator); m.putBoolean("emergencyOnly", mIsEmergencyOnly); m.putBoolean("isDataRoamingFromRegistration", getDataRoamingFromRegistration()); - m.putBoolean("isUsingCarrierAggregation", mIsUsingCarrierAggregation); + m.putBoolean("isUsingCarrierAggregation", isUsingCarrierAggregation()); m.putInt("LteEarfcnRsrpBoost", mLteEarfcnRsrpBoost); m.putInt("ChannelNumber", mChannelNumber); m.putIntArray("CellBandwidths", mCellBandwidths); @@ -1323,13 +1301,9 @@ public class ServiceState implements Parcelable { /** @hide */ @TestApi public void setRilVoiceRadioTechnology(@RilRadioTechnology int rt) { - if (rt == RIL_RADIO_TECHNOLOGY_LTE_CA) { - rt = RIL_RADIO_TECHNOLOGY_LTE; - } - - this.mRilVoiceRadioTechnology = rt; - - // sync to network registration state + Rlog.e(LOG_TAG, "ServiceState.setRilVoiceRadioTechnology() called. It's encouraged to " + + "use addNetworkRegistrationInfo() instead *******"); + // Sync to network registration state NetworkRegistrationInfo regState = getNetworkRegistrationInfo( NetworkRegistrationInfo.DOMAIN_CS, AccessNetworkConstants.TRANSPORT_TYPE_WWAN); if (regState == null) { @@ -1339,24 +1313,18 @@ public class ServiceState implements Parcelable { .build(); addNetworkRegistrationInfo(regState); } - regState.setAccessNetworkTechnology( - rilRadioTechnologyToNetworkType(mRilVoiceRadioTechnology)); + regState.setAccessNetworkTechnology(rilRadioTechnologyToNetworkType(rt)); } + /** @hide */ @TestApi public void setRilDataRadioTechnology(@RilRadioTechnology int rt) { - if (rt == RIL_RADIO_TECHNOLOGY_LTE_CA) { - rt = RIL_RADIO_TECHNOLOGY_LTE; - this.mIsUsingCarrierAggregation = true; - } else { - this.mIsUsingCarrierAggregation = false; - } - this.mRilDataRadioTechnology = rt; - if (VDBG) Rlog.d(LOG_TAG, "[ServiceState] setRilDataRadioTechnology=" + - mRilDataRadioTechnology); - - // sync to network registration state + Rlog.e(LOG_TAG, "ServiceState.setRilDataRadioTechnology() called. It's encouraged to " + + "use addNetworkRegistrationInfo() instead *******"); + // Sync to network registration state. Always write down the WWAN transport. For AP-assisted + // mode device, use addNetworkRegistrationInfo() to set the correct transport if RAT + // is IWLAN. NetworkRegistrationInfo regState = getNetworkRegistrationInfo( NetworkRegistrationInfo.DOMAIN_PS, AccessNetworkConstants.TRANSPORT_TYPE_WWAN); @@ -1367,18 +1335,32 @@ public class ServiceState implements Parcelable { .build(); addNetworkRegistrationInfo(regState); } - regState.setAccessNetworkTechnology( - rilRadioTechnologyToNetworkType(mRilDataRadioTechnology)); + regState.setAccessNetworkTechnology(rilRadioTechnologyToNetworkType(rt)); } /** @hide */ public boolean isUsingCarrierAggregation() { - return mIsUsingCarrierAggregation; + NetworkRegistrationInfo nri = getNetworkRegistrationInfo( + NetworkRegistrationInfo.DOMAIN_PS, AccessNetworkConstants.TRANSPORT_TYPE_WWAN); + if (nri != null) { + DataSpecificRegistrationInfo dsri = nri.getDataSpecificInfo(); + if (dsri != null) { + return dsri.isUsingCarrierAggregation(); + } + } + return false; } /** @hide */ public void setIsUsingCarrierAggregation(boolean ca) { - mIsUsingCarrierAggregation = ca; + NetworkRegistrationInfo nri = getNetworkRegistrationInfo( + NetworkRegistrationInfo.DOMAIN_PS, AccessNetworkConstants.TRANSPORT_TYPE_WWAN); + if (nri != null) { + DataSpecificRegistrationInfo dsri = nri.getDataSpecificInfo(); + if (dsri != null) { + dsri.setIsUsingCarrierAggregation(ca); + } + } } /** @@ -1435,12 +1417,29 @@ public class ServiceState implements Parcelable { /** @hide */ @UnsupportedAppUsage public int getRilVoiceRadioTechnology() { - return this.mRilVoiceRadioTechnology; + NetworkRegistrationInfo wwanRegInfo = getNetworkRegistrationInfo( + NetworkRegistrationInfo.DOMAIN_CS, AccessNetworkConstants.TRANSPORT_TYPE_WWAN); + if (wwanRegInfo != null) { + return networkTypeToRilRadioTechnology(wwanRegInfo.getAccessNetworkTechnology()); + } + return RIL_RADIO_TECHNOLOGY_UNKNOWN; } /** @hide */ @UnsupportedAppUsage public int getRilDataRadioTechnology() { - return this.mRilDataRadioTechnology; + NetworkRegistrationInfo wwanRegInfo = getNetworkRegistrationInfo( + NetworkRegistrationInfo.DOMAIN_PS, AccessNetworkConstants.TRANSPORT_TYPE_WWAN); + NetworkRegistrationInfo wlanRegInfo = getNetworkRegistrationInfo( + NetworkRegistrationInfo.DOMAIN_PS, AccessNetworkConstants.TRANSPORT_TYPE_WLAN); + if (wlanRegInfo != null + && wlanRegInfo.getAccessNetworkTechnology() == TelephonyManager.NETWORK_TYPE_IWLAN + && wlanRegInfo.getRegistrationState() + == NetworkRegistrationInfo.REGISTRATION_STATE_HOME) { + return RIL_RADIO_TECHNOLOGY_IWLAN; + } else if (wwanRegInfo != null) { + return networkTypeToRilRadioTechnology(wwanRegInfo.getAccessNetworkTechnology()); + } + return RIL_RADIO_TECHNOLOGY_UNKNOWN; } /** * @hide diff --git a/telephony/java/android/telephony/TelephonyManager.java b/telephony/java/android/telephony/TelephonyManager.java index 3d3ef98b7425..03b57f2706f1 100644 --- a/telephony/java/android/telephony/TelephonyManager.java +++ b/telephony/java/android/telephony/TelephonyManager.java @@ -1321,7 +1321,7 @@ public class TelephonyManager { /** * An int extra used with {@link #ACTION_SUBSCRIPTION_CARRIER_IDENTITY_CHANGED} to indicate the - * subscription which has changed. + * subscription which has changed; or in general whenever a subscription ID needs specified. */ public static final String EXTRA_SUBSCRIPTION_ID = "android.telephony.extra.SUBSCRIPTION_ID"; @@ -1428,13 +1428,24 @@ public class TelephonyManager { /** * Integer intent extra to be used with {@link #ACTION_PRIMARY_SUBSCRIPTION_LIST_CHANGED} - * to indicate whether a SIM selection is needed to choose default subscription. + * to indicate what type of SIM selection is needed. * * @hide */ public static final String EXTRA_DEFAULT_SUBSCRIPTION_SELECT_TYPE = "android.telephony.extra.DEFAULT_SUBSCRIPTION_SELECT_TYPE"; + /** @hide */ + @IntDef({ + EXTRA_DEFAULT_SUBSCRIPTION_SELECT_TYPE_NONE, + EXTRA_DEFAULT_SUBSCRIPTION_SELECT_TYPE_DATA, + EXTRA_DEFAULT_SUBSCRIPTION_SELECT_TYPE_VOICE, + EXTRA_DEFAULT_SUBSCRIPTION_SELECT_TYPE_SMS, + EXTRA_DEFAULT_SUBSCRIPTION_SELECT_TYPE_ALL + }) + @Retention(RetentionPolicy.SOURCE) + public @interface DefaultSubscriptionSelectType{} + /** * Used as an int value for {@link #EXTRA_DEFAULT_SUBSCRIPTION_SELECT_TYPE} * to indicate there's no need to re-select any default subscription. @@ -1466,20 +1477,11 @@ public class TelephonyManager { /** * Used as an int value for {@link #EXTRA_DEFAULT_SUBSCRIPTION_SELECT_TYPE} * to indicate user to decide whether current SIM should be preferred for all - * data / voice / sms. + * data / voice / sms. {@link #EXTRA_SUBSCRIPTION_ID} will specified to indicate + * which subscription should be the default subscription. * @hide */ - public static final int EXTRA_DEFAULT_SUBSCRIPTION_SELECT_FOR_ALL_TYPES = 4; - - /** - * Integer intent extra to be used with - * {@link #EXTRA_DEFAULT_SUBSCRIPTION_SELECT_FOR_ALL_TYPES} - * to indicate which SIM is being selected. - * - * @hide - */ - public static final String EXTRA_DEFAULT_SUBSCRIPTION_ID = - "android.telephony.extra.DEFAULT_SUBSCRIPTION_ID"; + public static final int EXTRA_DEFAULT_SUBSCRIPTION_SELECT_TYPE_ALL = 4; // // @@ -5241,6 +5243,18 @@ public class TelephonyManager { * Use this method when no subscriptions are available on the SIM and the operation must be * performed using the physical slot index. * + * This operation wraps two APDU instructions: + * <ul> + * <li>MANAGE CHANNEL to open a logical channel</li> + * <li>SELECT the given {@code AID} using the given {@code p2}</li> + * </ul> + * + * Per Open Mobile API Specification v3.2 section 6.2.7.h, only p2 values of 0x00, 0x04, 0x08, + * and 0x0C are guaranteed to be supported. + * + * If the SELECT command's status word is not '9000', '62xx', or '63xx', the status word will be + * considered an error and the channel shall not be opened. + * * Input parameters equivalent to TS 27.007 AT+CCHO command. * * <p>Requires Permission: @@ -5272,6 +5286,18 @@ public class TelephonyManager { /** * Opens a logical channel to the ICC card. * + * This operation wraps two APDU instructions: + * <ul> + * <li>MANAGE CHANNEL to open a logical channel</li> + * <li>SELECT the given {@code AID} using the given {@code p2}</li> + * </ul> + * + * Per Open Mobile API Specification v3.2 section 6.2.7.h, only p2 values of 0x00, 0x04, 0x08, + * and 0x0C are guaranteed to be supported. + * + * If the SELECT command's status word is not '9000', '62xx', or '63xx', the status word will be + * considered an error and the channel shall not be opened. + * * Input parameters equivalent to TS 27.007 AT+CCHO command. * * <p>Requires Permission: @@ -5289,6 +5315,18 @@ public class TelephonyManager { /** * Opens a logical channel to the ICC card. * + * This operation wraps two APDU instructions: + * <ul> + * <li>MANAGE CHANNEL to open a logical channel</li> + * <li>SELECT the given {@code AID} using the given {@code p2}</li> + * </ul> + * + * Per Open Mobile API Specification v3.2 section 6.2.7.h, only p2 values of 0x00, 0x04, 0x08, + * and 0x0C are guaranteed to be supported. + * + * If the SELECT command's status word is not '9000', '62xx', or '63xx', the status word will be + * considered an error and the channel shall not be opened. + * * Input parameters equivalent to TS 27.007 AT+CCHO command. * * <p>Requires Permission: diff --git a/tests/net/Android.bp b/tests/net/Android.bp index c62d85e4187e..176f54152256 100644 --- a/tests/net/Android.bp +++ b/tests/net/Android.bp @@ -7,6 +7,7 @@ android_test { // Include all test java files. srcs: ["java/**/*.java"], static_libs: [ + "FrameworksNetCommonTests", "frameworks-base-testutils", "framework-protos", "androidx.test.rules", diff --git a/tests/net/common/Android.bp b/tests/net/common/Android.bp new file mode 100644 index 000000000000..0a1ac75aac80 --- /dev/null +++ b/tests/net/common/Android.bp @@ -0,0 +1,29 @@ +// +// Copyright (C) 2019 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. +// + +// Tests in this folder are included both in unit tests and CTS. +// They must be fast and stable, and exercise public or test APIs. +java_library { + name: "FrameworksNetCommonTests", + srcs: ["java/**/*.java"], + static_libs: [ + "androidx.test.rules", + "junit", + ], + libs: [ + "android.test.base.stubs", + ], +}
\ No newline at end of file diff --git a/tests/net/java/android/net/IpPrefixTest.java b/tests/net/common/java/android/net/IpPrefixTest.java index abf019afed44..719960d48604 100644 --- a/tests/net/java/android/net/IpPrefixTest.java +++ b/tests/net/common/java/android/net/IpPrefixTest.java @@ -39,7 +39,7 @@ import java.util.Random; @SmallTest public class IpPrefixTest { - private static InetAddress Address(String addr) { + private static InetAddress address(String addr) { return InetAddress.parseNumericAddress(addr); } @@ -58,59 +58,59 @@ public class IpPrefixTest { try { p = new IpPrefix((byte[]) null, 9); fail("Expected NullPointerException: null byte array"); - } catch(RuntimeException expected) {} + } catch (RuntimeException expected) { } try { p = new IpPrefix((InetAddress) null, 10); fail("Expected NullPointerException: null InetAddress"); - } catch(RuntimeException expected) {} + } catch (RuntimeException expected) { } try { p = new IpPrefix((String) null); fail("Expected NullPointerException: null String"); - } catch(RuntimeException expected) {} + } catch (RuntimeException expected) { } try { byte[] b2 = {1, 2, 3, 4, 5}; p = new IpPrefix(b2, 29); fail("Expected IllegalArgumentException: invalid array length"); - } catch(IllegalArgumentException expected) {} + } catch (IllegalArgumentException expected) { } try { p = new IpPrefix("1.2.3.4"); fail("Expected IllegalArgumentException: no prefix length"); - } catch(IllegalArgumentException expected) {} + } catch (IllegalArgumentException expected) { } try { p = new IpPrefix("1.2.3.4/"); fail("Expected IllegalArgumentException: empty prefix length"); - } catch(IllegalArgumentException expected) {} + } catch (IllegalArgumentException expected) { } try { p = new IpPrefix("foo/32"); fail("Expected IllegalArgumentException: invalid address"); - } catch(IllegalArgumentException expected) {} + } catch (IllegalArgumentException expected) { } try { p = new IpPrefix("1/32"); fail("Expected IllegalArgumentException: deprecated IPv4 format"); - } catch(IllegalArgumentException expected) {} + } catch (IllegalArgumentException expected) { } try { p = new IpPrefix("1.2.3.256/32"); fail("Expected IllegalArgumentException: invalid IPv4 address"); - } catch(IllegalArgumentException expected) {} + } catch (IllegalArgumentException expected) { } try { p = new IpPrefix("foo/32"); fail("Expected IllegalArgumentException: non-address"); - } catch(IllegalArgumentException expected) {} + } catch (IllegalArgumentException expected) { } try { p = new IpPrefix("f00:::/32"); fail("Expected IllegalArgumentException: invalid IPv6 address"); - } catch(IllegalArgumentException expected) {} + } catch (IllegalArgumentException expected) { } } @Test @@ -132,17 +132,17 @@ public class IpPrefixTest { try { p = new IpPrefix(IPV4_BYTES, 33); fail("Expected IllegalArgumentException: invalid prefix length"); - } catch(RuntimeException expected) {} + } catch (RuntimeException expected) { } try { p = new IpPrefix(IPV4_BYTES, 128); fail("Expected IllegalArgumentException: invalid prefix length"); - } catch(RuntimeException expected) {} + } catch (RuntimeException expected) { } try { p = new IpPrefix(IPV4_BYTES, -1); fail("Expected IllegalArgumentException: negative prefix length"); - } catch(RuntimeException expected) {} + } catch (RuntimeException expected) { } p = new IpPrefix(IPV6_BYTES, 128); assertEquals("2001:db8:dead:beef:f00::a0/128", p.toString()); @@ -162,12 +162,12 @@ public class IpPrefixTest { try { p = new IpPrefix(IPV6_BYTES, -1); fail("Expected IllegalArgumentException: negative prefix length"); - } catch(RuntimeException expected) {} + } catch (RuntimeException expected) { } try { p = new IpPrefix(IPV6_BYTES, 129); fail("Expected IllegalArgumentException: negative prefix length"); - } catch(RuntimeException expected) {} + } catch (RuntimeException expected) { } } @@ -226,28 +226,28 @@ public class IpPrefixTest { @Test public void testContainsInetAddress() { IpPrefix p = new IpPrefix("2001:db8:f00::ace:d00d/127"); - assertTrue(p.contains(Address("2001:db8:f00::ace:d00c"))); - assertTrue(p.contains(Address("2001:db8:f00::ace:d00d"))); - assertFalse(p.contains(Address("2001:db8:f00::ace:d00e"))); - assertFalse(p.contains(Address("2001:db8:f00::bad:d00d"))); - assertFalse(p.contains(Address("2001:4868:4860::8888"))); - assertFalse(p.contains(Address("8.8.8.8"))); + assertTrue(p.contains(address("2001:db8:f00::ace:d00c"))); + assertTrue(p.contains(address("2001:db8:f00::ace:d00d"))); + assertFalse(p.contains(address("2001:db8:f00::ace:d00e"))); + assertFalse(p.contains(address("2001:db8:f00::bad:d00d"))); + assertFalse(p.contains(address("2001:4868:4860::8888"))); + assertFalse(p.contains(address("8.8.8.8"))); p = new IpPrefix("192.0.2.0/23"); - assertTrue(p.contains(Address("192.0.2.43"))); - assertTrue(p.contains(Address("192.0.3.21"))); - assertFalse(p.contains(Address("192.0.0.21"))); - assertFalse(p.contains(Address("8.8.8.8"))); - assertFalse(p.contains(Address("2001:4868:4860::8888"))); + assertTrue(p.contains(address("192.0.2.43"))); + assertTrue(p.contains(address("192.0.3.21"))); + assertFalse(p.contains(address("192.0.0.21"))); + assertFalse(p.contains(address("8.8.8.8"))); + assertFalse(p.contains(address("2001:4868:4860::8888"))); IpPrefix ipv6Default = new IpPrefix("::/0"); - assertTrue(ipv6Default.contains(Address("2001:db8::f00"))); - assertFalse(ipv6Default.contains(Address("192.0.2.1"))); + assertTrue(ipv6Default.contains(address("2001:db8::f00"))); + assertFalse(ipv6Default.contains(address("192.0.2.1"))); IpPrefix ipv4Default = new IpPrefix("0.0.0.0/0"); - assertTrue(ipv4Default.contains(Address("255.255.255.255"))); - assertTrue(ipv4Default.contains(Address("192.0.2.1"))); - assertFalse(ipv4Default.contains(Address("2001:db8::f00"))); + assertTrue(ipv4Default.contains(address("255.255.255.255"))); + assertTrue(ipv4Default.contains(address("192.0.2.1"))); + assertFalse(ipv4Default.contains(address("2001:db8::f00"))); } @Test @@ -315,10 +315,10 @@ public class IpPrefixTest { p = new IpPrefix(b, random.nextInt(129)); } if (p.equals(oldP)) { - assertEquals(p.hashCode(), oldP.hashCode()); + assertEquals(p.hashCode(), oldP.hashCode()); } if (p.hashCode() != oldP.hashCode()) { - assertNotEquals(p, oldP); + assertNotEquals(p, oldP); } } } @@ -332,9 +332,9 @@ public class IpPrefixTest { new IpPrefix("0.0.0.0/0"), }; for (int i = 0; i < prefixes.length; i++) { - for (int j = i + 1; j < prefixes.length; j++) { - assertNotEquals(prefixes[i].hashCode(), prefixes[j].hashCode()); - } + for (int j = i + 1; j < prefixes.length; j++) { + assertNotEquals(prefixes[i].hashCode(), prefixes[j].hashCode()); + } } } @@ -371,8 +371,8 @@ public class IpPrefixTest { } public void assertParcelingIsLossless(IpPrefix p) { - IpPrefix p2 = passThroughParcel(p); - assertEquals(p, p2); + IpPrefix p2 = passThroughParcel(p); + assertEquals(p, p2); } @Test diff --git a/tests/net/java/android/net/netlink/InetDiagSocketTest.java b/tests/net/java/android/net/netlink/InetDiagSocketTest.java index b6038aba089c..8b2b4e3cd443 100644 --- a/tests/net/java/android/net/netlink/InetDiagSocketTest.java +++ b/tests/net/java/android/net/netlink/InetDiagSocketTest.java @@ -189,7 +189,6 @@ public class InetDiagSocketTest { udp.close(); } - @Test public void testGetConnectionOwnerUid() throws Exception { checkGetConnectionOwnerUid("::", null); checkGetConnectionOwnerUid("::", "::"); diff --git a/tests/net/java/com/android/server/IpSecServiceTest.java b/tests/net/java/com/android/server/IpSecServiceTest.java index b5c3e9287467..4a35015044ff 100644 --- a/tests/net/java/com/android/server/IpSecServiceTest.java +++ b/tests/net/java/com/android/server/IpSecServiceTest.java @@ -156,10 +156,21 @@ public class IpSecServiceTest { @Test public void testOpenAndCloseUdpEncapsulationSocket() throws Exception { - int localport = findUnusedPort(); + int localport = -1; + IpSecUdpEncapResponse udpEncapResp = null; + + for (int i = 0; i < IpSecService.MAX_PORT_BIND_ATTEMPTS; i++) { + localport = findUnusedPort(); + + udpEncapResp = mIpSecService.openUdpEncapsulationSocket(localport, new Binder()); + assertNotNull(udpEncapResp); + if (udpEncapResp.status == IpSecManager.Status.OK) { + break; + } + + // Else retry to reduce possibility for port-bind failures. + } - IpSecUdpEncapResponse udpEncapResp = - mIpSecService.openUdpEncapsulationSocket(localport, new Binder()); assertNotNull(udpEncapResp); assertEquals(IpSecManager.Status.OK, udpEncapResp.status); assertEquals(localport, udpEncapResp.port); @@ -204,12 +215,11 @@ public class IpSecServiceTest { @Test public void testOpenUdpEncapsulationSocketAfterClose() throws Exception { - int localport = findUnusedPort(); IpSecUdpEncapResponse udpEncapResp = - mIpSecService.openUdpEncapsulationSocket(localport, new Binder()); + mIpSecService.openUdpEncapsulationSocket(0, new Binder()); assertNotNull(udpEncapResp); assertEquals(IpSecManager.Status.OK, udpEncapResp.status); - assertEquals(localport, udpEncapResp.port); + int localport = udpEncapResp.port; mIpSecService.closeUdpEncapsulationSocket(udpEncapResp.resourceId); udpEncapResp.fileDescriptor.close(); @@ -226,12 +236,11 @@ public class IpSecServiceTest { */ @Test public void testUdpEncapPortNotReleased() throws Exception { - int localport = findUnusedPort(); IpSecUdpEncapResponse udpEncapResp = - mIpSecService.openUdpEncapsulationSocket(localport, new Binder()); + mIpSecService.openUdpEncapsulationSocket(0, new Binder()); assertNotNull(udpEncapResp); assertEquals(IpSecManager.Status.OK, udpEncapResp.status); - assertEquals(localport, udpEncapResp.port); + int localport = udpEncapResp.port; udpEncapResp.fileDescriptor.close(); @@ -273,14 +282,11 @@ public class IpSecServiceTest { @Test public void testOpenUdpEncapsulationSocketTwice() throws Exception { - int localport = findUnusedPort(); - IpSecUdpEncapResponse udpEncapResp = - mIpSecService.openUdpEncapsulationSocket(localport, new Binder()); + mIpSecService.openUdpEncapsulationSocket(0, new Binder()); assertNotNull(udpEncapResp); assertEquals(IpSecManager.Status.OK, udpEncapResp.status); - assertEquals(localport, udpEncapResp.port); - mIpSecService.openUdpEncapsulationSocket(localport, new Binder()); + int localport = udpEncapResp.port; IpSecUdpEncapResponse testUdpEncapResp = mIpSecService.openUdpEncapsulationSocket(localport, new Binder()); |