diff options
329 files changed, 5095 insertions, 3742 deletions
diff --git a/Android.bp b/Android.bp index 589685174698..523e35637f84 100644 --- a/Android.bp +++ b/Android.bp @@ -696,10 +696,6 @@ java_defaults { "android.hardware.radio-V1.2-java", "android.hardware.radio-V1.3-java", "android.hardware.radio-V1.4-java", - "android.hardware.radio.config-V1.0-java", - "android.hardware.radio.config-V1.1-java", - "android.hardware.radio.config-V1.2-java", - "android.hardware.radio.deprecated-V1.0-java", "android.hardware.thermal-V1.0-java-constants", "android.hardware.tv.input-V1.0-java-constants", "android.hardware.usb-V1.0-java-constants", @@ -709,8 +705,6 @@ java_defaults { "android.hardware.vibrator-V1.1-java", "android.hardware.vibrator-V1.2-java", "android.hardware.wifi-V1.0-java-constants", - "networkstack-aidl-framework-java", - "netd_aidl_parcelables-java", ], required: [ @@ -820,66 +814,6 @@ gensrcs { output_extension: "srcjar", } -// AIDL interfaces between the core system and the networking mainline module. -aidl_interface { - name: "networkstack-aidl-interfaces", - local_include_dir: "core/java", - srcs: [ - "core/java/android/net/ApfCapabilitiesParcelable.aidl", - "core/java/android/net/DhcpResultsParcelable.aidl", - "core/java/android/net/INetworkMonitor.aidl", - "core/java/android/net/INetworkMonitorCallbacks.aidl", - "core/java/android/net/INetworkStackConnector.aidl", - "core/java/android/net/INetworkStackStatusCallback.aidl", - "core/java/android/net/InitialConfigurationParcelable.aidl", - "core/java/android/net/PrivateDnsConfigParcel.aidl", - "core/java/android/net/ProvisioningConfigurationParcelable.aidl", - "core/java/android/net/StaticIpConfigurationParcelable.aidl", - "core/java/android/net/TcpKeepalivePacketDataParcelable.aidl", - "core/java/android/net/dhcp/DhcpServingParamsParcel.aidl", - "core/java/android/net/dhcp/IDhcpServer.aidl", - "core/java/android/net/dhcp/IDhcpServerCallbacks.aidl", - "core/java/android/net/ip/IIpClient.aidl", - "core/java/android/net/ip/IIpClientCallbacks.aidl", - "core/java/android/net/IIpMemoryStore.aidl", - "core/java/android/net/IIpMemoryStoreCallbacks.aidl", - "core/java/android/net/ipmemorystore/**/*.aidl", - ], - backend: { - ndk: { - enabled: false, - }, - cpp: { - enabled: false, - }, - }, - api_dir: "aidl/networkstack", -} - -aidl_interface { - name: "ipmemorystore-aidl-interfaces", - local_include_dir: "core/java", - srcs: [ - "core/java/android/net/IIpMemoryStore.aidl", - "core/java/android/net/IIpMemoryStoreCallbacks.aidl", - "core/java/android/net/ipmemorystore/**/*.aidl", - ], -} - -aidl_interface { - name: "networkstack-aidl-framework", - local_include_dir: "core/java", - srcs: [ - "core/java/android/net/TcpKeepalivePacketDataParcelable.aidl", - ], - api_dir: "aidl/networkstack", - backend: { - java: { - sdk_version: "28", - }, - }, -} - filegroup { name: "framework-annotations", srcs: [ @@ -1617,6 +1551,8 @@ droidstubs { srcs: [ ":openjdk_java_files", ":non_openjdk_java_files", + ":opt-telephony-common-srcs", + "core/java/**/*.java", ], arg_files: [ "core/res/AndroidManifest.xml", diff --git a/api/current.txt b/api/current.txt index 733dd0c0ca59..37a542d80b34 100755 --- a/api/current.txt +++ b/api/current.txt @@ -54,6 +54,7 @@ package android { field public static final String BROADCAST_SMS = "android.permission.BROADCAST_SMS"; field public static final String BROADCAST_STICKY = "android.permission.BROADCAST_STICKY"; field public static final String BROADCAST_WAP_PUSH = "android.permission.BROADCAST_WAP_PUSH"; + field public static final String CALL_COMPANION_APP = "android.permission.CALL_COMPANION_APP"; field public static final String CALL_PHONE = "android.permission.CALL_PHONE"; field public static final String CALL_PRIVILEGED = "android.permission.CALL_PRIVILEGED"; field public static final String CAMERA = "android.permission.CAMERA"; @@ -27116,7 +27117,7 @@ package android.net { public class ConnectivityManager { method public void addDefaultNetworkActiveListener(android.net.ConnectivityManager.OnNetworkActiveListener); method public boolean bindProcessToNetwork(@Nullable android.net.Network); - method public android.net.SocketKeepalive createSocketKeepalive(@NonNull android.net.Network, @NonNull android.net.IpSecManager.UdpEncapsulationSocket, @NonNull java.net.InetAddress, @NonNull java.net.InetAddress, @NonNull java.util.concurrent.Executor, @NonNull android.net.SocketKeepalive.Callback); + method @NonNull public android.net.SocketKeepalive createSocketKeepalive(@NonNull android.net.Network, @NonNull android.net.IpSecManager.UdpEncapsulationSocket, @NonNull java.net.InetAddress, @NonNull java.net.InetAddress, @NonNull java.util.concurrent.Executor, @NonNull android.net.SocketKeepalive.Callback); method @RequiresPermission(android.Manifest.permission.ACCESS_NETWORK_STATE) @Nullable public android.net.Network getActiveNetwork(); method @Deprecated @Nullable @RequiresPermission(android.Manifest.permission.ACCESS_NETWORK_STATE) public android.net.NetworkInfo getActiveNetworkInfo(); method @Deprecated @NonNull @RequiresPermission(android.Manifest.permission.ACCESS_NETWORK_STATE) public android.net.NetworkInfo[] getAllNetworkInfo(); @@ -27194,7 +27195,7 @@ package android.net { public static class ConnectivityManager.NetworkCallback { ctor public ConnectivityManager.NetworkCallback(); method public void onAvailable(android.net.Network); - method public void onBlockedStatusChanged(android.net.Network, boolean); + method public void onBlockedStatusChanged(@NonNull android.net.Network, boolean); method public void onCapabilitiesChanged(android.net.Network, android.net.NetworkCapabilities); method public void onLinkPropertiesChanged(android.net.Network, android.net.LinkProperties); method public void onLosing(android.net.Network, int); @@ -27228,8 +27229,8 @@ package android.net { public final class DnsResolver { method @NonNull public static android.net.DnsResolver getInstance(); - method public <T> void query(@Nullable android.net.Network, @NonNull byte[], int, @NonNull java.util.concurrent.Executor, @NonNull android.net.DnsResolver.AnswerCallback<T>); - method public <T> void query(@Nullable android.net.Network, @NonNull String, int, int, int, @NonNull java.util.concurrent.Executor, @NonNull android.net.DnsResolver.AnswerCallback<T>); + method public <T> void query(@Nullable android.net.Network, @NonNull byte[], int, @NonNull java.util.concurrent.Executor, @Nullable android.os.CancellationSignal, @NonNull android.net.DnsResolver.AnswerCallback<T>); + method public <T> void query(@Nullable android.net.Network, @NonNull String, int, int, int, @NonNull java.util.concurrent.Executor, @Nullable android.os.CancellationSignal, @NonNull android.net.DnsResolver.AnswerCallback<T>); field public static final int CLASS_IN = 1; // 0x1 field public static final int FLAG_EMPTY = 0; // 0x0 field public static final int FLAG_NO_CACHE_LOOKUP = 4; // 0x4 @@ -27348,16 +27349,25 @@ package android.net { } public final class LinkProperties implements android.os.Parcelable { + ctor public LinkProperties(); + method public boolean addRoute(@NonNull android.net.RouteInfo); + method public void clear(); method public int describeContents(); - method public java.util.List<java.net.InetAddress> getDnsServers(); - method public String getDomains(); - method public android.net.ProxyInfo getHttpProxy(); + method @NonNull public java.util.List<java.net.InetAddress> getDnsServers(); + method @Nullable public String getDomains(); + method @Nullable public android.net.ProxyInfo getHttpProxy(); method @Nullable public String getInterfaceName(); - method public java.util.List<android.net.LinkAddress> getLinkAddresses(); + method @NonNull public java.util.List<android.net.LinkAddress> getLinkAddresses(); method public int getMtu(); method @Nullable public String getPrivateDnsServerName(); - method public java.util.List<android.net.RouteInfo> getRoutes(); + method @NonNull public java.util.List<android.net.RouteInfo> getRoutes(); method public boolean isPrivateDnsActive(); + method public void setDnsServers(@NonNull java.util.Collection<java.net.InetAddress>); + method public void setDomains(@Nullable String); + method public void setHttpProxy(@Nullable android.net.ProxyInfo); + method public void setInterfaceName(@Nullable String); + method public void setLinkAddresses(@NonNull java.util.Collection<android.net.LinkAddress>); + method public void setMtu(int); method public void writeToParcel(android.os.Parcel, int); field public static final android.os.Parcelable.Creator<android.net.LinkProperties> CREATOR; } @@ -27465,6 +27475,7 @@ package android.net { method public int describeContents(); method public int getLinkDownstreamBandwidthKbps(); method public int getLinkUpstreamBandwidthKbps(); + method public int getSignalStrength(); method @Nullable public android.net.TransportInfo getTransportInfo(); method public boolean hasCapability(int); method public boolean hasTransport(int); @@ -27493,6 +27504,7 @@ package android.net { field public static final int NET_CAPABILITY_VALIDATED = 16; // 0x10 field public static final int NET_CAPABILITY_WIFI_P2P = 6; // 0x6 field public static final int NET_CAPABILITY_XCAP = 9; // 0x9 + field public static final int SIGNAL_STRENGTH_UNSPECIFIED = -2147483648; // 0x80000000 field public static final int TRANSPORT_BLUETOOTH = 2; // 0x2 field public static final int TRANSPORT_CELLULAR = 0; // 0x0 field public static final int TRANSPORT_ETHERNET = 3; // 0x3 @@ -27504,7 +27516,7 @@ package android.net { @Deprecated public class NetworkInfo implements android.os.Parcelable { method @Deprecated public int describeContents(); - method @Deprecated public android.net.NetworkInfo.DetailedState getDetailedState(); + method @Deprecated @NonNull public android.net.NetworkInfo.DetailedState getDetailedState(); method @Deprecated public String getExtraInfo(); method @Deprecated public String getReason(); method @Deprecated public android.net.NetworkInfo.State getState(); @@ -27639,7 +27651,7 @@ package android.net { method public final void start(@IntRange(from=0xa, to=0xe10) int); method public final void stop(); field public static final int ERROR_HARDWARE_ERROR = -31; // 0xffffffe1 - field public static final int ERROR_HARDWARE_UNSUPPORTED = -30; // 0xffffffe2 + field public static final int ERROR_INSUFFICIENT_RESOURCES = -32; // 0xffffffe0 field public static final int ERROR_INVALID_INTERVAL = -24; // 0xffffffe8 field public static final int ERROR_INVALID_IP_ADDRESS = -21; // 0xffffffeb field public static final int ERROR_INVALID_LENGTH = -23; // 0xffffffe9 @@ -27647,6 +27659,7 @@ package android.net { field public static final int ERROR_INVALID_PORT = -22; // 0xffffffea field public static final int ERROR_INVALID_SOCKET = -25; // 0xffffffe7 field public static final int ERROR_SOCKET_NOT_IDLE = -26; // 0xffffffe6 + field public static final int ERROR_UNSUPPORTED = -30; // 0xffffffe2 } public static class SocketKeepalive.Callback { @@ -40424,12 +40437,12 @@ package android.system { method public static java.io.FileDescriptor accept(java.io.FileDescriptor, java.net.InetSocketAddress) throws android.system.ErrnoException, java.net.SocketException; method public static boolean access(String, int) throws android.system.ErrnoException; method public static void bind(java.io.FileDescriptor, java.net.InetAddress, int) throws android.system.ErrnoException, java.net.SocketException; - method public static void bind(java.io.FileDescriptor, java.net.SocketAddress) throws android.system.ErrnoException, java.net.SocketException; + method public static void bind(@NonNull java.io.FileDescriptor, @NonNull java.net.SocketAddress) throws android.system.ErrnoException, java.net.SocketException; method public static void chmod(String, int) throws android.system.ErrnoException; method public static void chown(String, int, int) throws android.system.ErrnoException; method public static void close(java.io.FileDescriptor) throws android.system.ErrnoException; method public static void connect(java.io.FileDescriptor, java.net.InetAddress, int) throws android.system.ErrnoException, java.net.SocketException; - method public static void connect(java.io.FileDescriptor, java.net.SocketAddress) throws android.system.ErrnoException, java.net.SocketException; + method public static void connect(@NonNull java.io.FileDescriptor, @NonNull java.net.SocketAddress) throws android.system.ErrnoException, java.net.SocketException; method public static java.io.FileDescriptor dup(java.io.FileDescriptor) throws android.system.ErrnoException; method public static java.io.FileDescriptor dup2(java.io.FileDescriptor, int) throws android.system.ErrnoException; method public static String[] environ(); @@ -40494,7 +40507,7 @@ package android.system { method public static long sendfile(java.io.FileDescriptor, java.io.FileDescriptor, android.system.Int64Ref, long) throws android.system.ErrnoException; method public static int sendto(java.io.FileDescriptor, java.nio.ByteBuffer, int, java.net.InetAddress, int) throws android.system.ErrnoException, java.net.SocketException; method public static int sendto(java.io.FileDescriptor, byte[], int, int, int, java.net.InetAddress, int) throws android.system.ErrnoException, java.net.SocketException; - method public static int sendto(java.io.FileDescriptor, byte[], int, int, int, java.net.SocketAddress) throws android.system.ErrnoException, java.net.SocketException; + method public static int sendto(@NonNull java.io.FileDescriptor, @NonNull byte[], int, int, int, @Nullable java.net.SocketAddress) throws android.system.ErrnoException, java.net.SocketException; method @Deprecated public static void setegid(int) throws android.system.ErrnoException; method public static void setenv(String, String, boolean) throws android.system.ErrnoException; method @Deprecated public static void seteuid(int) throws android.system.ErrnoException; @@ -41946,6 +41959,7 @@ package android.telecom { field public static final String EXTRA_INCOMING_CALL_EXTRAS = "android.telecom.extra.INCOMING_CALL_EXTRAS"; field public static final String EXTRA_INCOMING_VIDEO_STATE = "android.telecom.extra.INCOMING_VIDEO_STATE"; field public static final String EXTRA_IS_DEFAULT_CALL_SCREENING_APP = "android.telecom.extra.IS_DEFAULT_CALL_SCREENING_APP"; + field public static final String EXTRA_IS_ENABLED = "android.telecom.extra.IS_ENABLED"; field public static final String EXTRA_NOTIFICATION_COUNT = "android.telecom.extra.NOTIFICATION_COUNT"; field public static final String EXTRA_NOTIFICATION_PHONE_NUMBER = "android.telecom.extra.NOTIFICATION_PHONE_NUMBER"; field public static final String EXTRA_OUTGOING_CALL_EXTRAS = "android.telecom.extra.OUTGOING_CALL_EXTRAS"; @@ -41957,6 +41971,7 @@ package android.telecom { field public static final String GATEWAY_PROVIDER_PACKAGE = "android.telecom.extra.GATEWAY_PROVIDER_PACKAGE"; field public static final String METADATA_INCLUDE_EXTERNAL_CALLS = "android.telecom.INCLUDE_EXTERNAL_CALLS"; field public static final String METADATA_INCLUDE_SELF_MANAGED_CALLS = "android.telecom.INCLUDE_SELF_MANAGED_CALLS"; + field public static final String METADATA_IN_CALL_SERVICE_CAR_MODE_UI = "android.telecom.IN_CALL_SERVICE_CAR_MODE_UI"; field public static final String METADATA_IN_CALL_SERVICE_RINGING = "android.telecom.IN_CALL_SERVICE_RINGING"; field public static final String METADATA_IN_CALL_SERVICE_UI = "android.telecom.IN_CALL_SERVICE_UI"; field public static final int PRESENTATION_ALLOWED = 1; // 0x1 @@ -42202,6 +42217,7 @@ package android.telephony { field public static final String KEY_EDITABLE_ENHANCED_4G_LTE_BOOL = "editable_enhanced_4g_lte_bool"; field public static final String KEY_EDITABLE_VOICEMAIL_NUMBER_BOOL = "editable_voicemail_number_bool"; field public static final String KEY_EDITABLE_VOICEMAIL_NUMBER_SETTING_BOOL = "editable_voicemail_number_setting_bool"; + field public static final String KEY_EMERGENCY_NUMBER_PREFIX_STRING_ARRAY = "emergency_number_prefix_string_array"; field public static final String KEY_ENABLE_DIALER_KEY_VIBRATION_BOOL = "enable_dialer_key_vibration_bool"; field public static final String KEY_ENHANCED_4G_LTE_ON_BY_DEFAULT_BOOL = "enhanced_4g_lte_on_by_default_bool"; field public static final String KEY_FORCE_HOME_NETWORK_BOOL = "force_home_network_bool"; @@ -42351,12 +42367,12 @@ package android.telephony { } public final class CellIdentityNr extends android.telephony.CellIdentity { - method public String getMccString(); - method public String getMncString(); + method @Nullable public String getMccString(); + method @Nullable public String getMncString(); method public long getNci(); - method public int getNrarfcn(); - method public int getPci(); - method public int getTac(); + method @IntRange(from=0, to=3279165) public int getNrarfcn(); + method @IntRange(from=0, to=1007) public int getPci(); + method @IntRange(from=0, to=65535) public int getTac(); method public void writeToParcel(android.os.Parcel, int); field public static final android.os.Parcelable.Creator<android.telephony.CellIdentityNr> CREATOR; } @@ -42370,7 +42386,7 @@ package android.telephony { method @Nullable public String getMobileNetworkOperator(); method public int getUarfcn(); method public void writeToParcel(android.os.Parcel, int); - field public static final android.os.Parcelable.Creator<android.telephony.CellIdentityTdscdma> CREATOR; + field @NonNull public static final android.os.Parcelable.Creator<android.telephony.CellIdentityTdscdma> CREATOR; } public final class CellIdentityWcdma extends android.telephony.CellIdentity { @@ -42423,12 +42439,19 @@ package android.telephony { } public final class CellInfoNr extends android.telephony.CellInfo { - method public android.telephony.CellIdentity getCellIdentity(); - method public android.telephony.CellSignalStrength getCellSignalStrength(); + method @NonNull public android.telephony.CellIdentity getCellIdentity(); + method @NonNull public android.telephony.CellSignalStrength getCellSignalStrength(); method public void writeToParcel(android.os.Parcel, int); field public static final android.os.Parcelable.Creator<android.telephony.CellInfoNr> CREATOR; } + public final class CellInfoTdscdma extends android.telephony.CellInfo implements android.os.Parcelable { + method @NonNull public android.telephony.CellIdentityTdscdma getCellIdentity(); + method @NonNull public android.telephony.CellSignalStrengthTdscdma getCellSignalStrength(); + method public void writeToParcel(android.os.Parcel, int); + field @NonNull public static final android.os.Parcelable.Creator<android.telephony.CellInfoTdscdma> CREATOR; + } + public final class CellInfoWcdma extends android.telephony.CellInfo implements android.os.Parcelable { method public android.telephony.CellIdentityWcdma getCellIdentity(); method public android.telephony.CellSignalStrengthWcdma getCellSignalStrength(); @@ -42512,6 +42535,16 @@ package android.telephony { field public static final android.os.Parcelable.Creator<android.telephony.CellSignalStrengthNr> CREATOR; } + public final class CellSignalStrengthTdscdma extends android.telephony.CellSignalStrength implements android.os.Parcelable { + method public int describeContents(); + method public int getAsuLevel(); + method public int getDbm(); + method public int getLevel(); + method public int getRscp(); + method public void writeToParcel(android.os.Parcel, int); + field @NonNull public static final android.os.Parcelable.Creator<android.telephony.CellSignalStrengthTdscdma> CREATOR; + } + public final class CellSignalStrengthWcdma extends android.telephony.CellSignalStrength implements android.os.Parcelable { method public int describeContents(); method public int getAsuLevel(); @@ -42931,7 +42964,7 @@ package android.telephony { method public String getCountryIso(); method public int getDataRoaming(); method public CharSequence getDisplayName(); - method public String getGroupUuid(); + method @Nullable public String getGroupUuid(); method public String getIccId(); method public int getIconTint(); method @Deprecated public int getMcc(); @@ -42972,7 +43005,7 @@ package android.telephony { method public boolean isNetworkRoaming(int); method public static boolean isUsableSubscriptionId(int); method public static boolean isValidSubscriptionId(int); - method public void removeOnOpportunisticSubscriptionsChangedListener(android.telephony.SubscriptionManager.OnOpportunisticSubscriptionsChangedListener); + method public void removeOnOpportunisticSubscriptionsChangedListener(@NonNull android.telephony.SubscriptionManager.OnOpportunisticSubscriptionsChangedListener); method public void removeOnSubscriptionsChangedListener(android.telephony.SubscriptionManager.OnSubscriptionsChangedListener); method @RequiresPermission(android.Manifest.permission.MODIFY_PHONE_STATE) public boolean removeSubscriptionsFromGroup(@NonNull int[]); method @RequiresPermission(android.Manifest.permission.MODIFY_PHONE_STATE) public boolean setMetered(boolean, int); @@ -42981,7 +43014,7 @@ package android.telephony { method public void setSubscriptionOverrideCongested(int, boolean, long); method public void setSubscriptionOverrideUnmetered(int, boolean, long); method public void setSubscriptionPlans(int, @NonNull java.util.List<android.telephony.SubscriptionPlan>); - method @RequiresPermission("android.permission.WRITE_EMBEDDED_SUBSCRIPTIONS") public void switchToSubscription(int, android.app.PendingIntent); + method @RequiresPermission("android.permission.WRITE_EMBEDDED_SUBSCRIPTIONS") public void switchToSubscription(int, @NonNull android.app.PendingIntent); field public static final String ACTION_DEFAULT_SMS_SUBSCRIPTION_CHANGED = "android.telephony.action.DEFAULT_SMS_SUBSCRIPTION_CHANGED"; field public static final String ACTION_DEFAULT_SUBSCRIPTION_CHANGED = "android.telephony.action.DEFAULT_SUBSCRIPTION_CHANGED"; field public static final String ACTION_MANAGE_SUBSCRIPTION_PLANS = "android.telephony.action.MANAGE_SUBSCRIPTION_PLANS"; @@ -43109,7 +43142,7 @@ package android.telephony { method @RequiresPermission(anyOf={android.Manifest.permission.ACCESS_NETWORK_STATE, android.Manifest.permission.READ_PHONE_STATE}) public boolean isDataRoamingEnabled(); method public boolean isEmergencyNumber(@NonNull String); method public boolean isHearingAidCompatibilitySupported(); - method @RequiresPermission(android.Manifest.permission.READ_PHONE_STATE) public boolean isMultisimSupported(); + method @RequiresPermission(android.Manifest.permission.READ_PHONE_STATE) public int isMultiSimSupported(); method public boolean isNetworkRoaming(); method public boolean isRttSupported(); method public boolean isSmsCapable(); @@ -43188,6 +43221,9 @@ package android.telephony { field public static final String EXTRA_SUBSCRIPTION_ID = "android.telephony.extra.SUBSCRIPTION_ID"; field public static final String EXTRA_VOICEMAIL_NUMBER = "android.telephony.extra.VOICEMAIL_NUMBER"; field public static final String METADATA_HIDE_VOICEMAIL_SETTINGS_MENU = "android.telephony.HIDE_VOICEMAIL_SETTINGS_MENU"; + field public static final int MULTISIM_ALLOWED = 0; // 0x0 + field public static final int MULTISIM_NOT_SUPPORTED_BY_CARRIER = 2; // 0x2 + field public static final int MULTISIM_NOT_SUPPORTED_BY_HARDWARE = 1; // 0x1 field public static final int NETWORK_TYPE_1xRTT = 7; // 0x7 field public static final int NETWORK_TYPE_CDMA = 4; // 0x4 field public static final int NETWORK_TYPE_EDGE = 2; // 0x2 @@ -43397,26 +43433,26 @@ package android.telephony.data { public static class ApnSetting.Builder { ctor public ApnSetting.Builder(); method public android.telephony.data.ApnSetting build(); - method @NonNull public android.telephony.data.ApnSetting.Builder setApnName(String); + method @NonNull public android.telephony.data.ApnSetting.Builder setApnName(@Nullable String); method @NonNull public android.telephony.data.ApnSetting.Builder setApnTypeBitmask(int); method @NonNull public android.telephony.data.ApnSetting.Builder setAuthType(int); method @NonNull public android.telephony.data.ApnSetting.Builder setCarrierEnabled(boolean); method @NonNull public android.telephony.data.ApnSetting.Builder setCarrierId(int); - method @NonNull public android.telephony.data.ApnSetting.Builder setEntryName(String); + method @NonNull public android.telephony.data.ApnSetting.Builder setEntryName(@Nullable String); method @Deprecated public android.telephony.data.ApnSetting.Builder setMmsProxyAddress(java.net.InetAddress); - method @NonNull public android.telephony.data.ApnSetting.Builder setMmsProxyAddress(String); + method @NonNull public android.telephony.data.ApnSetting.Builder setMmsProxyAddress(@Nullable String); method @NonNull public android.telephony.data.ApnSetting.Builder setMmsProxyPort(int); - method @NonNull public android.telephony.data.ApnSetting.Builder setMmsc(android.net.Uri); + method @NonNull public android.telephony.data.ApnSetting.Builder setMmsc(@Nullable android.net.Uri); method @NonNull public android.telephony.data.ApnSetting.Builder setMvnoType(int); method @NonNull public android.telephony.data.ApnSetting.Builder setNetworkTypeBitmask(int); - method @NonNull public android.telephony.data.ApnSetting.Builder setOperatorNumeric(String); - method @NonNull public android.telephony.data.ApnSetting.Builder setPassword(String); + method @NonNull public android.telephony.data.ApnSetting.Builder setOperatorNumeric(@Nullable String); + method @NonNull public android.telephony.data.ApnSetting.Builder setPassword(@Nullable String); method @NonNull public android.telephony.data.ApnSetting.Builder setProtocol(int); method @Deprecated public android.telephony.data.ApnSetting.Builder setProxyAddress(java.net.InetAddress); - method @NonNull public android.telephony.data.ApnSetting.Builder setProxyAddress(String); + method @NonNull public android.telephony.data.ApnSetting.Builder setProxyAddress(@Nullable String); method @NonNull public android.telephony.data.ApnSetting.Builder setProxyPort(int); method @NonNull public android.telephony.data.ApnSetting.Builder setRoamingProtocol(int); - method @NonNull public android.telephony.data.ApnSetting.Builder setUser(String); + method @NonNull public android.telephony.data.ApnSetting.Builder setUser(@Nullable String); } } diff --git a/api/system-current.txt b/api/system-current.txt index 413e79e0efea..1717382272f3 100644 --- a/api/system-current.txt +++ b/api/system-current.txt @@ -95,6 +95,7 @@ package android { field public static final String MODIFY_PARENTAL_CONTROLS = "android.permission.MODIFY_PARENTAL_CONTROLS"; field public static final String MODIFY_QUIET_MODE = "android.permission.MODIFY_QUIET_MODE"; field public static final String MOVE_PACKAGE = "android.permission.MOVE_PACKAGE"; + field public static final String NETWORK_SCAN = "android.permission.NETWORK_SCAN"; field public static final String NETWORK_SETUP_WIZARD = "android.permission.NETWORK_SETUP_WIZARD"; field public static final String NOTIFICATION_DURING_SETUP = "android.permission.NOTIFICATION_DURING_SETUP"; field public static final String NOTIFY_TV_INPUTS = "android.permission.NOTIFY_TV_INPUTS"; @@ -835,7 +836,7 @@ package android.content { method public abstract void sendBroadcast(android.content.Intent, @Nullable String, @Nullable android.os.Bundle); method @RequiresPermission(android.Manifest.permission.INTERACT_ACROSS_USERS) public abstract void sendBroadcastAsUser(@RequiresPermission android.content.Intent, android.os.UserHandle, @Nullable String, @Nullable android.os.Bundle); method public abstract void sendOrderedBroadcast(@NonNull android.content.Intent, @Nullable String, @Nullable android.os.Bundle, @Nullable android.content.BroadcastReceiver, @Nullable android.os.Handler, int, @Nullable String, @Nullable android.os.Bundle); - method @RequiresPermission(android.Manifest.permission.INTERACT_ACROSS_USERS_FULL) public void startActivityAsUser(@RequiresPermission android.content.Intent, android.os.UserHandle); + method @RequiresPermission(android.Manifest.permission.INTERACT_ACROSS_USERS_FULL) public void startActivityAsUser(@RequiresPermission @NonNull android.content.Intent, @NonNull android.os.UserHandle); field public static final String BACKUP_SERVICE = "backup"; field public static final String CONTEXTHUB_SERVICE = "contexthub"; field public static final String DYNAMIC_ANDROID_SERVICE = "dynamic_android"; @@ -3085,8 +3086,7 @@ package android.metrics { package android.net { public class CaptivePortal implements android.os.Parcelable { - ctor public CaptivePortal(android.os.IBinder); - method public void logEvent(int, String); + method public void logEvent(int, @NonNull String); method public void useNetwork(); field public static final int APP_RETURN_DISMISSED = 0; // 0x0 field public static final int APP_RETURN_UNWANTED = 1; // 0x1 @@ -3094,15 +3094,15 @@ package android.net { } public class ConnectivityManager { - method @RequiresPermission(android.Manifest.permission.PACKET_KEEPALIVE_OFFLOAD) public android.net.SocketKeepalive createNattKeepalive(@NonNull android.net.Network, @NonNull java.io.FileDescriptor, @NonNull java.net.InetAddress, @NonNull java.net.InetAddress, @NonNull java.util.concurrent.Executor, @NonNull android.net.SocketKeepalive.Callback); - method @RequiresPermission(android.Manifest.permission.PACKET_KEEPALIVE_OFFLOAD) public android.net.SocketKeepalive createSocketKeepalive(@NonNull android.net.Network, @NonNull java.net.Socket, @NonNull java.util.concurrent.Executor, @NonNull android.net.SocketKeepalive.Callback); - method public boolean getAvoidBadWifi(); + method @NonNull @RequiresPermission(android.Manifest.permission.PACKET_KEEPALIVE_OFFLOAD) public android.net.SocketKeepalive createNattKeepalive(@NonNull android.net.Network, @NonNull android.os.ParcelFileDescriptor, @NonNull java.net.InetAddress, @NonNull java.net.InetAddress, @NonNull java.util.concurrent.Executor, @NonNull android.net.SocketKeepalive.Callback); + method @NonNull @RequiresPermission(android.Manifest.permission.PACKET_KEEPALIVE_OFFLOAD) public android.net.SocketKeepalive createSocketKeepalive(@NonNull android.net.Network, @NonNull java.net.Socket, @NonNull java.util.concurrent.Executor, @NonNull android.net.SocketKeepalive.Callback); method @RequiresPermission(android.Manifest.permission.LOCAL_MAC_ADDRESS) public String getCaptivePortalServerUrl(); method @RequiresPermission(android.Manifest.permission.TETHER_PRIVILEGED) public void getLatestTetheringEntitlementResult(int, boolean, @NonNull java.util.concurrent.Executor, @NonNull android.net.ConnectivityManager.OnTetheringEntitlementResultListener); method @RequiresPermission(anyOf={android.Manifest.permission.TETHER_PRIVILEGED, android.Manifest.permission.WRITE_SETTINGS}) public boolean isTetheringSupported(); method @RequiresPermission(android.Manifest.permission.TETHER_PRIVILEGED) public void registerTetheringEventCallback(@NonNull java.util.concurrent.Executor, @NonNull android.net.ConnectivityManager.OnTetheringEventCallback); method @RequiresPermission(anyOf={"android.permission.NETWORK_SETTINGS", android.Manifest.permission.NETWORK_SETUP_WIZARD, "android.permission.NETWORK_STACK"}) public void setAirplaneMode(boolean); - method @RequiresPermission(android.net.NetworkStack.PERMISSION_MAINLINE_NETWORK_STACK) public void startCaptivePortalApp(android.net.Network, android.os.Bundle); + method @RequiresPermission(anyOf={android.net.NetworkStack.PERMISSION_MAINLINE_NETWORK_STACK, "android.permission.NETWORK_STACK"}) public boolean shouldAvoidBadWifi(); + method @RequiresPermission(android.net.NetworkStack.PERMISSION_MAINLINE_NETWORK_STACK) public void startCaptivePortalApp(@NonNull android.net.Network, @NonNull android.os.Bundle); method @RequiresPermission(android.Manifest.permission.TETHER_PRIVILEGED) public void startTethering(int, boolean, android.net.ConnectivityManager.OnStartTetheringCallback); method @RequiresPermission(android.Manifest.permission.TETHER_PRIVILEGED) public void startTethering(int, boolean, android.net.ConnectivityManager.OnStartTetheringCallback, android.os.Handler); method @RequiresPermission(android.Manifest.permission.TETHER_PRIVILEGED) public void stopTethering(int); @@ -3133,65 +3133,55 @@ package android.net { } public final class IpPrefix implements android.os.Parcelable { - ctor public IpPrefix(java.net.InetAddress, int); - ctor public IpPrefix(String); + ctor public IpPrefix(@NonNull java.net.InetAddress, int); + ctor public IpPrefix(@NonNull String); } public class LinkAddress implements android.os.Parcelable { ctor public LinkAddress(java.net.InetAddress, int, int, int); ctor public LinkAddress(@NonNull java.net.InetAddress, int); ctor public LinkAddress(@NonNull String); - ctor public LinkAddress(String, int, int); + ctor public LinkAddress(@NonNull String, int, int); method public boolean isGlobalPreferred(); - method public boolean isIPv4(); - method public boolean isIPv6(); - method public boolean isSameAddressAs(android.net.LinkAddress); + method public boolean isIpv4(); + method public boolean isIpv6(); + method public boolean isSameAddressAs(@Nullable android.net.LinkAddress); } public final class LinkProperties implements android.os.Parcelable { - ctor public LinkProperties(); - ctor public LinkProperties(android.net.LinkProperties); - method public boolean addDnsServer(java.net.InetAddress); - method public boolean addLinkAddress(android.net.LinkAddress); - method public boolean addRoute(android.net.RouteInfo); - method public void clear(); + ctor public LinkProperties(@Nullable android.net.LinkProperties); + method public boolean addDnsServer(@NonNull java.net.InetAddress); + method public boolean addLinkAddress(@NonNull android.net.LinkAddress); method @Nullable public android.net.IpPrefix getNat64Prefix(); - method public java.util.List<java.net.InetAddress> getPcscfServers(); - method public String getTcpBufferSizes(); - method public java.util.List<java.net.InetAddress> getValidatedPrivateDnsServers(); - method public boolean hasGlobalIPv6Address(); - method public boolean hasIPv4Address(); - method public boolean hasIPv6DefaultRoute(); - method public boolean isIPv4Provisioned(); - method public boolean isIPv6Provisioned(); + method @NonNull public java.util.List<java.net.InetAddress> getPcscfServers(); + method @Nullable public String getTcpBufferSizes(); + method @NonNull public java.util.List<java.net.InetAddress> getValidatedPrivateDnsServers(); + method public boolean hasGlobalIpv6Address(); + method public boolean hasIpv4Address(); + method public boolean hasIpv6DefaultRoute(); + method public boolean isIpv4Provisioned(); + method public boolean isIpv6Provisioned(); method public boolean isProvisioned(); - method public boolean isReachable(java.net.InetAddress); - method public boolean removeDnsServer(java.net.InetAddress); - method public boolean removeLinkAddress(android.net.LinkAddress); - method public boolean removeRoute(android.net.RouteInfo); - method public void setDnsServers(java.util.Collection<java.net.InetAddress>); - method public void setDomains(String); - method public void setHttpProxy(android.net.ProxyInfo); - method public void setInterfaceName(String); - method public void setLinkAddresses(java.util.Collection<android.net.LinkAddress>); - method public void setMtu(int); - method public void setNat64Prefix(android.net.IpPrefix); - method public void setPcscfServers(java.util.Collection<java.net.InetAddress>); + method public boolean isReachable(@NonNull java.net.InetAddress); + method public boolean removeDnsServer(@NonNull java.net.InetAddress); + method public boolean removeLinkAddress(@NonNull android.net.LinkAddress); + method public boolean removeRoute(@NonNull android.net.RouteInfo); + method public void setNat64Prefix(@Nullable android.net.IpPrefix); + method public void setPcscfServers(@NonNull java.util.Collection<java.net.InetAddress>); method public void setPrivateDnsServerName(@Nullable String); - method public void setTcpBufferSizes(String); + method public void setTcpBufferSizes(@Nullable String); method public void setUsePrivateDns(boolean); - method public void setValidatedPrivateDnsServers(java.util.Collection<java.net.InetAddress>); + method public void setValidatedPrivateDnsServers(@NonNull java.util.Collection<java.net.InetAddress>); } public class Network implements android.os.Parcelable { - ctor public Network(android.net.Network); - method public android.net.Network getPrivateDnsBypassingCopy(); + ctor public Network(@NonNull android.net.Network); + method @NonNull public android.net.Network getPrivateDnsBypassingCopy(); } public final class NetworkCapabilities implements android.os.Parcelable { - method public int getSignalStrength(); - method public int[] getTransportTypes(); - method public boolean satisfiedByNetworkCapabilities(android.net.NetworkCapabilities); + method @NonNull public int[] getTransportTypes(); + method public boolean satisfiedByNetworkCapabilities(@Nullable android.net.NetworkCapabilities); field public static final int NET_CAPABILITY_OEM_PAID = 22; // 0x16 field public static final int NET_CAPABILITY_PARTIAL_CONNECTIVITY = 24; // 0x18 } @@ -3213,7 +3203,7 @@ package android.net { } public static class NetworkRequest.Builder { - method public android.net.NetworkRequest.Builder setSignalStrength(int); + method @NonNull public android.net.NetworkRequest.Builder setSignalStrength(int); } public class NetworkScoreManager { @@ -3237,7 +3227,7 @@ package android.net { } public final class RouteInfo implements android.os.Parcelable { - ctor public RouteInfo(android.net.IpPrefix, java.net.InetAddress, String, int); + ctor public RouteInfo(@Nullable android.net.IpPrefix, @Nullable java.net.InetAddress, @Nullable String, int); method public int getType(); field public static final int RTN_THROW = 9; // 0x9 field public static final int RTN_UNICAST = 1; // 0x1 @@ -3277,18 +3267,18 @@ package android.net { public final class StaticIpConfiguration implements android.os.Parcelable { ctor public StaticIpConfiguration(); - ctor public StaticIpConfiguration(android.net.StaticIpConfiguration); - method public void addDnsServer(java.net.InetAddress); + ctor public StaticIpConfiguration(@Nullable android.net.StaticIpConfiguration); + method public void addDnsServer(@NonNull java.net.InetAddress); method public void clear(); method public int describeContents(); - method public java.util.List<java.net.InetAddress> getDnsServers(); - method public String getDomains(); - method public java.net.InetAddress getGateway(); - method public android.net.LinkAddress getIpAddress(); - method public java.util.List<android.net.RouteInfo> getRoutes(String); - method public void setDomains(String); - method public void setGateway(java.net.InetAddress); - method public void setIpAddress(android.net.LinkAddress); + method @NonNull public java.util.List<java.net.InetAddress> getDnsServers(); + method @Nullable public String getDomains(); + method @Nullable public java.net.InetAddress getGateway(); + method @Nullable public android.net.LinkAddress getIpAddress(); + method @NonNull public java.util.List<android.net.RouteInfo> getRoutes(@Nullable String); + method public void setDomains(@Nullable String); + method public void setGateway(@Nullable java.net.InetAddress); + method public void setIpAddress(@Nullable android.net.LinkAddress); method public void writeToParcel(android.os.Parcel, int); field public static final android.os.Parcelable.Creator<android.net.StaticIpConfiguration> CREATOR; } @@ -3323,11 +3313,14 @@ package android.net { package android.net.apf { - public class ApfCapabilities { + public final class ApfCapabilities implements android.os.Parcelable { ctor public ApfCapabilities(int, int, int); - method public static boolean getApfDrop8023Frames(android.content.Context); - method public static int[] getApfEthTypeBlackList(android.content.Context); + method public int describeContents(); + method public static boolean getApfDrop8023Frames(@NonNull android.content.Context); + method @NonNull public static int[] getApfEthTypeBlackList(@NonNull android.content.Context); method public boolean hasDataAccess(); + method public void writeToParcel(android.os.Parcel, int); + field public static final android.os.Parcelable.Creator<android.net.apf.ApfCapabilities> CREATOR; field public final int apfPacketFormat; field public final int apfVersionSupported; field public final int maximumApfProgramSize; @@ -3339,28 +3332,28 @@ package android.net.captiveportal { public final class CaptivePortalProbeResult { ctor public CaptivePortalProbeResult(int); - ctor public CaptivePortalProbeResult(int, String, String); - ctor public CaptivePortalProbeResult(int, String, String, android.net.captiveportal.CaptivePortalProbeSpec); + ctor public CaptivePortalProbeResult(int, @Nullable String, @Nullable String); + ctor public CaptivePortalProbeResult(int, @Nullable String, @Nullable String, @Nullable android.net.captiveportal.CaptivePortalProbeSpec); method public boolean isFailed(); method public boolean isPartialConnectivity(); method public boolean isPortal(); method public boolean isSuccessful(); - field public static final android.net.captiveportal.CaptivePortalProbeResult FAILED; + field @NonNull public static final android.net.captiveportal.CaptivePortalProbeResult FAILED; field public static final int FAILED_CODE = 599; // 0x257 field public static final android.net.captiveportal.CaptivePortalProbeResult PARTIAL; field public static final int PORTAL_CODE = 302; // 0x12e - field public static final android.net.captiveportal.CaptivePortalProbeResult SUCCESS; + field @NonNull public static final android.net.captiveportal.CaptivePortalProbeResult SUCCESS; field public static final int SUCCESS_CODE = 204; // 0xcc - field public final String detectUrl; + field @Nullable public final String detectUrl; field @Nullable public final android.net.captiveportal.CaptivePortalProbeSpec probeSpec; - field public final String redirectUrl; + field @Nullable public final String redirectUrl; } public abstract class CaptivePortalProbeSpec { - method public String getEncodedSpec(); - method public abstract android.net.captiveportal.CaptivePortalProbeResult getResult(int, @Nullable String); - method public java.net.URL getUrl(); - method public static java.util.Collection<android.net.captiveportal.CaptivePortalProbeSpec> parseCaptivePortalProbeSpecs(String); + method @NonNull public String getEncodedSpec(); + method @NonNull public abstract android.net.captiveportal.CaptivePortalProbeResult getResult(int, @Nullable String); + method @NonNull public java.net.URL getUrl(); + method @NonNull public static java.util.Collection<android.net.captiveportal.CaptivePortalProbeSpec> parseCaptivePortalProbeSpecs(@NonNull String); method @Nullable public static android.net.captiveportal.CaptivePortalProbeSpec parseSpecOrNull(@Nullable String); } @@ -3371,78 +3364,78 @@ package android.net.metrics { public final class ApfProgramEvent implements android.net.metrics.IpConnectivityLog.Event { } - public static class ApfProgramEvent.Builder { + public static final class ApfProgramEvent.Builder { ctor public ApfProgramEvent.Builder(); - method public android.net.metrics.ApfProgramEvent build(); - method public android.net.metrics.ApfProgramEvent.Builder setActualLifetime(long); - method public android.net.metrics.ApfProgramEvent.Builder setCurrentRas(int); - method public android.net.metrics.ApfProgramEvent.Builder setFilteredRas(int); - method public android.net.metrics.ApfProgramEvent.Builder setFlags(boolean, boolean); - method public android.net.metrics.ApfProgramEvent.Builder setLifetime(long); - method public android.net.metrics.ApfProgramEvent.Builder setProgramLength(int); + method @NonNull public android.net.metrics.ApfProgramEvent build(); + method @NonNull public android.net.metrics.ApfProgramEvent.Builder setActualLifetime(long); + method @NonNull public android.net.metrics.ApfProgramEvent.Builder setCurrentRas(int); + method @NonNull public android.net.metrics.ApfProgramEvent.Builder setFilteredRas(int); + method @NonNull public android.net.metrics.ApfProgramEvent.Builder setFlags(boolean, boolean); + method @NonNull public android.net.metrics.ApfProgramEvent.Builder setLifetime(long); + method @NonNull public android.net.metrics.ApfProgramEvent.Builder setProgramLength(int); } public final class ApfStats implements android.net.metrics.IpConnectivityLog.Event { } - public static class ApfStats.Builder { + public static final class ApfStats.Builder { ctor public ApfStats.Builder(); - method public android.net.metrics.ApfStats build(); - method public android.net.metrics.ApfStats.Builder setDroppedRas(int); - method public android.net.metrics.ApfStats.Builder setDurationMs(long); - method public android.net.metrics.ApfStats.Builder setMatchingRas(int); - method public android.net.metrics.ApfStats.Builder setMaxProgramSize(int); - method public android.net.metrics.ApfStats.Builder setParseErrors(int); - method public android.net.metrics.ApfStats.Builder setProgramUpdates(int); - method public android.net.metrics.ApfStats.Builder setProgramUpdatesAll(int); - method public android.net.metrics.ApfStats.Builder setProgramUpdatesAllowingMulticast(int); - method public android.net.metrics.ApfStats.Builder setReceivedRas(int); - method public android.net.metrics.ApfStats.Builder setZeroLifetimeRas(int); + method @NonNull public android.net.metrics.ApfStats build(); + method @NonNull public android.net.metrics.ApfStats.Builder setDroppedRas(int); + method @NonNull public android.net.metrics.ApfStats.Builder setDurationMs(long); + method @NonNull public android.net.metrics.ApfStats.Builder setMatchingRas(int); + method @NonNull public android.net.metrics.ApfStats.Builder setMaxProgramSize(int); + method @NonNull public android.net.metrics.ApfStats.Builder setParseErrors(int); + method @NonNull public android.net.metrics.ApfStats.Builder setProgramUpdates(int); + method @NonNull public android.net.metrics.ApfStats.Builder setProgramUpdatesAll(int); + method @NonNull public android.net.metrics.ApfStats.Builder setProgramUpdatesAllowingMulticast(int); + method @NonNull public android.net.metrics.ApfStats.Builder setReceivedRas(int); + method @NonNull public android.net.metrics.ApfStats.Builder setZeroLifetimeRas(int); } public final class DhcpClientEvent implements android.net.metrics.IpConnectivityLog.Event { } - public static class DhcpClientEvent.Builder { + public static final class DhcpClientEvent.Builder { ctor public DhcpClientEvent.Builder(); - method public android.net.metrics.DhcpClientEvent build(); - method public android.net.metrics.DhcpClientEvent.Builder setDurationMs(int); - method public android.net.metrics.DhcpClientEvent.Builder setMsg(String); + method @NonNull public android.net.metrics.DhcpClientEvent build(); + method @NonNull public android.net.metrics.DhcpClientEvent.Builder setDurationMs(int); + method @NonNull public android.net.metrics.DhcpClientEvent.Builder setMsg(String); } public final class DhcpErrorEvent implements android.net.metrics.IpConnectivityLog.Event { ctor public DhcpErrorEvent(int); method public static int errorCodeWithOption(int, int); - field public static final int BOOTP_TOO_SHORT; - field public static final int BUFFER_UNDERFLOW; - field public static final int DHCP_BAD_MAGIC_COOKIE; + field public static final int BOOTP_TOO_SHORT = 67174400; // 0x4010000 + field public static final int BUFFER_UNDERFLOW = 83951616; // 0x5010000 + field public static final int DHCP_BAD_MAGIC_COOKIE = 67239936; // 0x4020000 field public static final int DHCP_ERROR = 4; // 0x4 - field public static final int DHCP_INVALID_OPTION_LENGTH; - field public static final int DHCP_NO_COOKIE; - field public static final int DHCP_NO_MSG_TYPE; - field public static final int DHCP_UNKNOWN_MSG_TYPE; + field public static final int DHCP_INVALID_OPTION_LENGTH = 67305472; // 0x4030000 + field public static final int DHCP_NO_COOKIE = 67502080; // 0x4060000 + field public static final int DHCP_NO_MSG_TYPE = 67371008; // 0x4040000 + field public static final int DHCP_UNKNOWN_MSG_TYPE = 67436544; // 0x4050000 field public static final int L2_ERROR = 1; // 0x1 - field public static final int L2_TOO_SHORT; - field public static final int L2_WRONG_ETH_TYPE; + field public static final int L2_TOO_SHORT = 16842752; // 0x1010000 + field public static final int L2_WRONG_ETH_TYPE = 16908288; // 0x1020000 field public static final int L3_ERROR = 2; // 0x2 - field public static final int L3_INVALID_IP; - field public static final int L3_NOT_IPV4; - field public static final int L3_TOO_SHORT; + field public static final int L3_INVALID_IP = 33751040; // 0x2030000 + field public static final int L3_NOT_IPV4 = 33685504; // 0x2020000 + field public static final int L3_TOO_SHORT = 33619968; // 0x2010000 field public static final int L4_ERROR = 3; // 0x3 - field public static final int L4_NOT_UDP; - field public static final int L4_WRONG_PORT; + field public static final int L4_NOT_UDP = 50397184; // 0x3010000 + field public static final int L4_WRONG_PORT = 50462720; // 0x3020000 field public static final int MISC_ERROR = 5; // 0x5 - field public static final int PARSING_ERROR; - field public static final int RECEIVE_ERROR; + field public static final int PARSING_ERROR = 84082688; // 0x5030000 + field public static final int RECEIVE_ERROR = 84017152; // 0x5020000 } public class IpConnectivityLog { ctor public IpConnectivityLog(); - method public boolean log(long, android.net.metrics.IpConnectivityLog.Event); - method public boolean log(String, android.net.metrics.IpConnectivityLog.Event); - method public boolean log(android.net.Network, int[], android.net.metrics.IpConnectivityLog.Event); - method public boolean log(int, int[], android.net.metrics.IpConnectivityLog.Event); - method public boolean log(android.net.metrics.IpConnectivityLog.Event); + method public boolean log(long, @NonNull android.net.metrics.IpConnectivityLog.Event); + method public boolean log(@NonNull String, @NonNull android.net.metrics.IpConnectivityLog.Event); + method public boolean log(@NonNull android.net.Network, @NonNull int[], @NonNull android.net.metrics.IpConnectivityLog.Event); + method public boolean log(int, @NonNull int[], @NonNull android.net.metrics.IpConnectivityLog.Event); + method public boolean log(@NonNull android.net.metrics.IpConnectivityLog.Event); } public static interface IpConnectivityLog.Event extends android.os.Parcelable { @@ -3490,19 +3483,19 @@ package android.net.metrics { public final class RaEvent implements android.net.metrics.IpConnectivityLog.Event { } - public static class RaEvent.Builder { + public static final class RaEvent.Builder { ctor public RaEvent.Builder(); - method public android.net.metrics.RaEvent build(); - method public android.net.metrics.RaEvent.Builder updateDnsslLifetime(long); - method public android.net.metrics.RaEvent.Builder updatePrefixPreferredLifetime(long); - method public android.net.metrics.RaEvent.Builder updatePrefixValidLifetime(long); - method public android.net.metrics.RaEvent.Builder updateRdnssLifetime(long); - method public android.net.metrics.RaEvent.Builder updateRouteInfoLifetime(long); - method public android.net.metrics.RaEvent.Builder updateRouterLifetime(long); + method @NonNull public android.net.metrics.RaEvent build(); + method @NonNull public android.net.metrics.RaEvent.Builder updateDnsslLifetime(long); + method @NonNull public android.net.metrics.RaEvent.Builder updatePrefixPreferredLifetime(long); + method @NonNull public android.net.metrics.RaEvent.Builder updatePrefixValidLifetime(long); + method @NonNull public android.net.metrics.RaEvent.Builder updateRdnssLifetime(long); + method @NonNull public android.net.metrics.RaEvent.Builder updateRouteInfoLifetime(long); + method @NonNull public android.net.metrics.RaEvent.Builder updateRouterLifetime(long); } public final class ValidationProbeEvent implements android.net.metrics.IpConnectivityLog.Event { - method public static String getProbeName(int); + method @NonNull public static String getProbeName(int); field public static final int DNS_FAILURE = 0; // 0x0 field public static final int DNS_SUCCESS = 1; // 0x1 field public static final int PROBE_DNS = 0; // 0x0 @@ -3513,12 +3506,12 @@ package android.net.metrics { field public static final int PROBE_PRIVDNS = 5; // 0x5 } - public static class ValidationProbeEvent.Builder { + public static final class ValidationProbeEvent.Builder { ctor public ValidationProbeEvent.Builder(); - method public android.net.metrics.ValidationProbeEvent build(); - method public android.net.metrics.ValidationProbeEvent.Builder setDurationMs(long); - method public android.net.metrics.ValidationProbeEvent.Builder setProbeType(int, boolean); - method public android.net.metrics.ValidationProbeEvent.Builder setReturnCode(int); + method @NonNull public android.net.metrics.ValidationProbeEvent build(); + method @NonNull public android.net.metrics.ValidationProbeEvent.Builder setDurationMs(long); + method @NonNull public android.net.metrics.ValidationProbeEvent.Builder setProbeType(int, boolean); + method @NonNull public android.net.metrics.ValidationProbeEvent.Builder setReturnCode(int); } } @@ -4252,7 +4245,7 @@ package android.os { } public class ServiceSpecificException extends java.lang.RuntimeException { - ctor public ServiceSpecificException(int, String); + ctor public ServiceSpecificException(int, @Nullable String); ctor public ServiceSpecificException(int); field public final int errorCode; } @@ -5923,11 +5916,11 @@ package android.telephony { field public static final int VSNCP_TIMEOUT = 2236; // 0x8bc } - public final class DataSpecificRegistrationStates implements android.os.Parcelable { + public final class DataSpecificRegistrationInfo implements android.os.Parcelable { method public int describeContents(); method @NonNull public android.telephony.LteVopsSupportInfo getLteVopsSupportInfo(); method public void writeToParcel(android.os.Parcel, int); - field public static final android.os.Parcelable.Creator<android.telephony.DataSpecificRegistrationStates> CREATOR; + field @NonNull public static final android.os.Parcelable.Creator<android.telephony.DataSpecificRegistrationInfo> CREATOR; } public final class DisconnectCause { @@ -6031,69 +6024,67 @@ package android.telephony { field public static final String MBMS_STREAMING_SERVICE_ACTION = "android.telephony.action.EmbmsStreaming"; } - public class NetworkRegistrationState implements android.os.Parcelable { - ctor public NetworkRegistrationState(int, int, int, int, int, boolean, @NonNull int[], @Nullable android.telephony.CellIdentity); + public final class NetworkRegistrationInfo implements android.os.Parcelable { method public int describeContents(); method public int getAccessNetworkTechnology(); - method @NonNull public int[] getAvailableServices(); + method @NonNull public java.util.List<java.lang.Integer> getAvailableServices(); method @Nullable public android.telephony.CellIdentity getCellIdentity(); - method @Nullable public android.telephony.DataSpecificRegistrationStates getDataSpecificStates(); + method @Nullable public android.telephony.DataSpecificRegistrationInfo getDataSpecificInfo(); method public int getDomain(); - method public int getRegState(); + method public int getRegistrationState(); method public int getRejectCause(); method public int getRoamingType(); method public int getTransportType(); method public boolean isEmergencyEnabled(); method public boolean isRoaming(); method public void writeToParcel(android.os.Parcel, int); - field public static final android.os.Parcelable.Creator<android.telephony.NetworkRegistrationState> CREATOR; + field @NonNull public static final android.os.Parcelable.Creator<android.telephony.NetworkRegistrationInfo> CREATOR; field public static final int DOMAIN_CS = 1; // 0x1 field public static final int DOMAIN_PS = 2; // 0x2 - field public static final int REG_STATE_DENIED = 3; // 0x3 - field public static final int REG_STATE_HOME = 1; // 0x1 - field public static final int REG_STATE_NOT_REG_NOT_SEARCHING = 0; // 0x0 - field public static final int REG_STATE_NOT_REG_SEARCHING = 2; // 0x2 - field public static final int REG_STATE_ROAMING = 5; // 0x5 - field public static final int REG_STATE_UNKNOWN = 4; // 0x4 + field public static final int REGISTRATION_STATE_DENIED = 3; // 0x3 + field public static final int REGISTRATION_STATE_HOME = 1; // 0x1 + field public static final int REGISTRATION_STATE_NOT_REGISTERED_OR_SEARCHING = 0; // 0x0 + field public static final int REGISTRATION_STATE_NOT_REGISTERED_SEARCHING = 2; // 0x2 + field public static final int REGISTRATION_STATE_ROAMING = 5; // 0x5 + field public static final int REGISTRATION_STATE_UNKNOWN = 4; // 0x4 field public static final int SERVICE_TYPE_DATA = 2; // 0x2 field public static final int SERVICE_TYPE_EMERGENCY = 5; // 0x5 field public static final int SERVICE_TYPE_SMS = 3; // 0x3 + field public static final int SERVICE_TYPE_UNKNOWN = 0; // 0x0 field public static final int SERVICE_TYPE_VIDEO = 4; // 0x4 field public static final int SERVICE_TYPE_VOICE = 1; // 0x1 } - public static class NetworkRegistrationState.Builder { - ctor public NetworkRegistrationState.Builder(); - method @NonNull public android.telephony.NetworkRegistrationState build(); - method @NonNull public android.telephony.NetworkRegistrationState.Builder setAccessNetworkTechnology(int); - method @NonNull public android.telephony.NetworkRegistrationState.Builder setAvailableServices(@NonNull int[]); - method @NonNull public android.telephony.NetworkRegistrationState.Builder setCellIdentity(@Nullable android.telephony.CellIdentity); - method @NonNull public android.telephony.NetworkRegistrationState.Builder setDomain(int); - method @NonNull public android.telephony.NetworkRegistrationState.Builder setEmergencyOnly(boolean); - method @NonNull public android.telephony.NetworkRegistrationState.Builder setNrStatus(int); - method @NonNull public android.telephony.NetworkRegistrationState.Builder setRegState(int); - method @NonNull public android.telephony.NetworkRegistrationState.Builder setRejectCause(int); - method @NonNull public android.telephony.NetworkRegistrationState.Builder setRoamingType(int); - method @NonNull public android.telephony.NetworkRegistrationState.Builder setTransportType(int); + public static final class NetworkRegistrationInfo.Builder { + ctor public NetworkRegistrationInfo.Builder(); + method @NonNull public android.telephony.NetworkRegistrationInfo build(); + method @NonNull public android.telephony.NetworkRegistrationInfo.Builder setAccessNetworkTechnology(int); + method @NonNull public android.telephony.NetworkRegistrationInfo.Builder setAvailableServices(@NonNull java.util.List<java.lang.Integer>); + method @NonNull public android.telephony.NetworkRegistrationInfo.Builder setCellIdentity(@Nullable android.telephony.CellIdentity); + method @NonNull public android.telephony.NetworkRegistrationInfo.Builder setDomain(int); + method @NonNull public android.telephony.NetworkRegistrationInfo.Builder setEmergencyOnly(boolean); + method @NonNull public android.telephony.NetworkRegistrationInfo.Builder setRegistrationState(int); + method @NonNull public android.telephony.NetworkRegistrationInfo.Builder setRejectCause(int); + method @NonNull public android.telephony.NetworkRegistrationInfo.Builder setTransportType(int); } public abstract class NetworkService extends android.app.Service { ctor public NetworkService(); method public android.os.IBinder onBind(android.content.Intent); method @Nullable public abstract android.telephony.NetworkService.NetworkServiceProvider onCreateNetworkServiceProvider(int); - field public static final String NETWORK_SERVICE_INTERFACE = "android.telephony.NetworkService"; + field public static final String SERVICE_INTERFACE = "android.telephony.NetworkService"; } public abstract class NetworkService.NetworkServiceProvider implements java.lang.AutoCloseable { ctor public NetworkService.NetworkServiceProvider(int); method public abstract void close(); - method public void getNetworkRegistrationState(int, @NonNull android.telephony.NetworkServiceCallback); method public final int getSlotIndex(); - method public final void notifyNetworkRegistrationStateChanged(); + method public final void notifyNetworkRegistrationInfoChanged(); + method public void requestNetworkRegistrationInfo(int, @NonNull android.telephony.NetworkServiceCallback); } public class NetworkServiceCallback { - method public void onGetNetworkRegistrationStateComplete(int, @Nullable android.telephony.NetworkRegistrationState); + method public void onRequestNetworkRegistrationInfoComplete(int, @Nullable android.telephony.NetworkRegistrationInfo); field public static final int RESULT_ERROR_BUSY = 3; // 0x3 field public static final int RESULT_ERROR_FAILED = 5; // 0x5 field public static final int RESULT_ERROR_ILLEGAL_STATE = 4; // 0x4 @@ -6268,12 +6259,10 @@ package android.telephony { } public class ServiceState implements android.os.Parcelable { - method @Nullable public android.telephony.NetworkRegistrationState getNetworkRegistrationState(int, int); - method @NonNull public java.util.List<android.telephony.NetworkRegistrationState> getNetworkRegistrationStates(); - method @Deprecated @NonNull public java.util.List<android.telephony.NetworkRegistrationState> getNetworkRegistrationStates(int); - method @Deprecated @Nullable public android.telephony.NetworkRegistrationState getNetworkRegistrationStates(int, int); - method @NonNull public java.util.List<android.telephony.NetworkRegistrationState> getNetworkRegistrationStatesForDomain(int); - method @NonNull public java.util.List<android.telephony.NetworkRegistrationState> getNetworkRegistrationStatesForTransportType(int); + method @Nullable public android.telephony.NetworkRegistrationInfo getNetworkRegistrationInfo(int, int); + method @NonNull public java.util.List<android.telephony.NetworkRegistrationInfo> getNetworkRegistrationInfoList(); + method @NonNull public java.util.List<android.telephony.NetworkRegistrationInfo> getNetworkRegistrationInfoListForDomain(int); + method @NonNull public java.util.List<android.telephony.NetworkRegistrationInfo> getNetworkRegistrationInfoListForTransportType(int); field public static final int ROAMING_TYPE_DOMESTIC = 2; // 0x2 field public static final int ROAMING_TYPE_INTERNATIONAL = 3; // 0x3 field public static final int ROAMING_TYPE_NOT_ROAMING = 0; // 0x0 @@ -6385,7 +6374,7 @@ package android.telephony { method @Nullable @RequiresPermission(android.Manifest.permission.READ_PRIVILEGED_PHONE_STATE) public String getIsimIst(); method @NonNull @RequiresPermission(android.Manifest.permission.READ_PRIVILEGED_PHONE_STATE) public java.util.Map<java.lang.Integer,java.lang.Integer> getLogicalToPhysicalSlotMapping(); method public static long getMaxNumberVerificationTimeoutMillis(); - method @RequiresPermission(android.Manifest.permission.READ_PRIVILEGED_PHONE_STATE) public long getPreferredNetworkTypeBitmap(); + method @RequiresPermission(android.Manifest.permission.READ_PRIVILEGED_PHONE_STATE) public long getPreferredNetworkTypeBitmask(); method @RequiresPermission(anyOf={android.Manifest.permission.READ_PRIVILEGED_PHONE_STATE, android.Manifest.permission.READ_PHONE_STATE}) public int getRadioPowerState(); method public int getSimApplicationState(); method public int getSimCardState(); @@ -6397,7 +6386,7 @@ package android.telephony { method @RequiresPermission(android.Manifest.permission.READ_PRIVILEGED_PHONE_STATE) public int getVoiceActivationState(); method @RequiresPermission(android.Manifest.permission.MODIFY_PHONE_STATE) public boolean handlePinMmi(String); method @RequiresPermission(android.Manifest.permission.MODIFY_PHONE_STATE) public boolean handlePinMmiForSubscriber(int, String); - method @Nullable @RequiresPermission(android.Manifest.permission.MODIFY_PHONE_STATE) public boolean iccCloseLogicalChannelBySlot(int, int); + method @RequiresPermission(android.Manifest.permission.MODIFY_PHONE_STATE) public boolean iccCloseLogicalChannelBySlot(int, int); method @Nullable @RequiresPermission(android.Manifest.permission.MODIFY_PHONE_STATE) public android.telephony.IccOpenLogicalChannelResponse iccOpenLogicalChannelBySlot(int, @Nullable String, int); method @NonNull @RequiresPermission(android.Manifest.permission.MODIFY_PHONE_STATE) public String iccTransmitApduBasicChannelBySlot(int, int, int, int, int, int, @Nullable String); method @Nullable @RequiresPermission(android.Manifest.permission.MODIFY_PHONE_STATE) public String iccTransmitApduLogicalChannelBySlot(int, int, int, int, int, int, int, @Nullable String); @@ -6421,8 +6410,8 @@ package android.telephony { method @RequiresPermission(android.Manifest.permission.MODIFY_PHONE_STATE) public void setDataActivationState(int); method @Deprecated @RequiresPermission(android.Manifest.permission.MODIFY_PHONE_STATE) public void setDataEnabled(int, boolean); method @RequiresPermission(android.Manifest.permission.MODIFY_PHONE_STATE) public void setDataRoamingEnabled(boolean); - method @RequiresPermission(android.Manifest.permission.MODIFY_PHONE_STATE) public void setMultisimCarrierRestriction(boolean); - method @RequiresPermission(android.Manifest.permission.MODIFY_PHONE_STATE) public boolean setPreferredNetworkTypeBitmap(long); + method @RequiresPermission(android.Manifest.permission.MODIFY_PHONE_STATE) public void setMultiSimCarrierRestriction(boolean); + method @RequiresPermission(android.Manifest.permission.MODIFY_PHONE_STATE) public boolean setPreferredNetworkTypeBitmask(long); method @RequiresPermission(android.Manifest.permission.MODIFY_PHONE_STATE) public boolean setRadio(boolean); method @RequiresPermission(android.Manifest.permission.MODIFY_PHONE_STATE) public boolean setRadioPower(boolean); method @RequiresPermission(android.Manifest.permission.MODIFY_PHONE_STATE) public void setSimPowerState(int); @@ -6528,72 +6517,111 @@ package android.telephony { package android.telephony.data { public final class DataCallResponse implements android.os.Parcelable { - ctor public DataCallResponse(int, int, int, int, int, @Nullable String, @Nullable java.util.List<android.net.LinkAddress>, @Nullable java.util.List<java.net.InetAddress>, @Nullable java.util.List<java.net.InetAddress>, @Nullable java.util.List<java.lang.String>, int); method public int describeContents(); - method public int getActive(); method @NonNull public java.util.List<android.net.LinkAddress> getAddresses(); - method public int getCallId(); - method @NonNull public java.util.List<java.net.InetAddress> getDnses(); - method @NonNull public java.util.List<java.net.InetAddress> getGateways(); - method @NonNull public String getIfname(); + method public int getCause(); + method @NonNull public java.util.List<java.net.InetAddress> getDnsAddresses(); + method @NonNull public java.util.List<java.net.InetAddress> getGatewayAddresses(); + method public int getId(); + method @NonNull public String getInterfaceName(); + method public int getLinkStatus(); method public int getMtu(); - method @NonNull public java.util.List<java.lang.String> getPcscfs(); + method @NonNull public java.util.List<java.net.InetAddress> getPcscfAddresses(); method public int getProtocolType(); - method public int getStatus(); method public int getSuggestedRetryTime(); method public void writeToParcel(android.os.Parcel, int); - field public static final android.os.Parcelable.Creator<android.telephony.data.DataCallResponse> CREATOR; + field @NonNull public static final android.os.Parcelable.Creator<android.telephony.data.DataCallResponse> CREATOR; + field public static final int LINK_STATUS_ACTIVE = 2; // 0x2 + field public static final int LINK_STATUS_DORMANT = 1; // 0x1 + field public static final int LINK_STATUS_INACTIVE = 0; // 0x0 + field public static final int LINK_STATUS_UNKNOWN = -1; // 0xffffffff + } + + public static final class DataCallResponse.Builder { + ctor public DataCallResponse.Builder(); + method @NonNull public android.telephony.data.DataCallResponse build(); + method @NonNull public android.telephony.data.DataCallResponse.Builder setAddresses(@NonNull java.util.List<android.net.LinkAddress>); + method @NonNull public android.telephony.data.DataCallResponse.Builder setCause(int); + method @NonNull public android.telephony.data.DataCallResponse.Builder setDnsAddresses(@NonNull java.util.List<java.net.InetAddress>); + method @NonNull public android.telephony.data.DataCallResponse.Builder setGatewayAddresses(@NonNull java.util.List<java.net.InetAddress>); + method @NonNull public android.telephony.data.DataCallResponse.Builder setId(int); + method @NonNull public android.telephony.data.DataCallResponse.Builder setInterfaceName(@NonNull String); + method @NonNull public android.telephony.data.DataCallResponse.Builder setLinkStatus(int); + method @NonNull public android.telephony.data.DataCallResponse.Builder setMtu(int); + method @NonNull public android.telephony.data.DataCallResponse.Builder setPcscfAddresses(@NonNull java.util.List<java.net.InetAddress>); + method @NonNull public android.telephony.data.DataCallResponse.Builder setProtocolType(int); + method @NonNull public android.telephony.data.DataCallResponse.Builder setSuggestedRetryTime(int); } public final class DataProfile implements android.os.Parcelable { - method public String getApn(); + method public int describeContents(); + method @NonNull public String getApn(); method public int getAuthType(); - method public int getBearerBitmap(); - method public int getMaxConns(); - method public int getMaxConnsTime(); + method public int getBearerBitmask(); method public int getMtu(); - method public String getPassword(); + method @Nullable public String getPassword(); method public int getProfileId(); - method public int getProtocol(); - method public int getRoamingProtocol(); - method public int getSupportedApnTypesBitmap(); + method public int getProtocolType(); + method public int getRoamingProtocolType(); + method public int getSupportedApnTypesBitmask(); method public int getType(); - method public String getUserName(); - method public int getWaitTime(); + method @Nullable public String getUserName(); method public boolean isEnabled(); method public boolean isPersistent(); method public boolean isPreferred(); + method public void writeToParcel(android.os.Parcel, int); + field @NonNull public static final android.os.Parcelable.Creator<android.telephony.data.DataProfile> CREATOR; field public static final int TYPE_3GPP = 1; // 0x1 field public static final int TYPE_3GPP2 = 2; // 0x2 field public static final int TYPE_COMMON = 0; // 0x0 } + public static final class DataProfile.Builder { + ctor public DataProfile.Builder(); + method @NonNull public android.telephony.data.DataProfile build(); + method @NonNull public android.telephony.data.DataProfile.Builder enable(boolean); + method @NonNull public android.telephony.data.DataProfile.Builder setApn(@NonNull String); + method @NonNull public android.telephony.data.DataProfile.Builder setAuthType(int); + method @NonNull public android.telephony.data.DataProfile.Builder setBearerBitmask(int); + method @NonNull public android.telephony.data.DataProfile.Builder setMtu(int); + method @NonNull public android.telephony.data.DataProfile.Builder setPassword(@NonNull String); + method @NonNull public android.telephony.data.DataProfile.Builder setPersistent(boolean); + method @NonNull public android.telephony.data.DataProfile.Builder setPreferred(boolean); + method @NonNull public android.telephony.data.DataProfile.Builder setProfileId(int); + method @NonNull public android.telephony.data.DataProfile.Builder setProtocolType(int); + method @NonNull public android.telephony.data.DataProfile.Builder setRoamingProtocolType(int); + method @NonNull public android.telephony.data.DataProfile.Builder setSupportedApnTypesBitmask(int); + method @NonNull public android.telephony.data.DataProfile.Builder setType(int); + method @NonNull public android.telephony.data.DataProfile.Builder setUserName(@NonNull String); + } + public abstract class DataService extends android.app.Service { ctor public DataService(); method public android.os.IBinder onBind(android.content.Intent); method @Nullable public abstract android.telephony.data.DataService.DataServiceProvider onCreateDataServiceProvider(int); - field public static final String DATA_SERVICE_INTERFACE = "android.telephony.data.DataService"; field public static final int REQUEST_REASON_HANDOVER = 3; // 0x3 field public static final int REQUEST_REASON_NORMAL = 1; // 0x1 field public static final int REQUEST_REASON_SHUTDOWN = 2; // 0x2 + field public static final int REQUEST_REASON_UNKNOWN = 0; // 0x0 + field public static final String SERVICE_INTERFACE = "android.telephony.data.DataService"; } public abstract class DataService.DataServiceProvider implements java.lang.AutoCloseable { ctor public DataService.DataServiceProvider(int); method public abstract void close(); method public void deactivateDataCall(int, int, @Nullable android.telephony.data.DataServiceCallback); - method public void getDataCallList(@NonNull android.telephony.data.DataServiceCallback); method public final int getSlotIndex(); method public final void notifyDataCallListChanged(java.util.List<android.telephony.data.DataCallResponse>); - method public void setDataProfile(@NonNull java.util.List<android.telephony.data.DataProfile>, boolean, @Nullable android.telephony.data.DataServiceCallback); - method public void setInitialAttachApn(@NonNull android.telephony.data.DataProfile, boolean, @Nullable android.telephony.data.DataServiceCallback); - method public void setupDataCall(int, @NonNull android.telephony.data.DataProfile, boolean, boolean, int, @Nullable android.net.LinkProperties, @Nullable android.telephony.data.DataServiceCallback); + method public void requestDataCallList(@NonNull android.telephony.data.DataServiceCallback); + method public void setDataProfile(@NonNull java.util.List<android.telephony.data.DataProfile>, boolean, @NonNull android.telephony.data.DataServiceCallback); + method public void setInitialAttachApn(@NonNull android.telephony.data.DataProfile, boolean, @NonNull android.telephony.data.DataServiceCallback); + method public void setupDataCall(int, @NonNull android.telephony.data.DataProfile, boolean, boolean, int, @Nullable android.net.LinkProperties, @NonNull android.telephony.data.DataServiceCallback); } public class DataServiceCallback { method public void onDataCallListChanged(@NonNull java.util.List<android.telephony.data.DataCallResponse>); method public void onDeactivateDataCallComplete(int); - method public void onGetDataCallListComplete(int, @NonNull java.util.List<android.telephony.data.DataCallResponse>); + method public void onRequestDataCallListComplete(int, @NonNull java.util.List<android.telephony.data.DataCallResponse>); method public void onSetDataProfileComplete(int); method public void onSetInitialAttachApnComplete(int); method public void onSetupDataCallComplete(int, @Nullable android.telephony.data.DataCallResponse); @@ -6606,15 +6634,15 @@ package android.telephony.data { public abstract class QualifiedNetworksService extends android.app.Service { ctor public QualifiedNetworksService(); - method @NonNull public abstract android.telephony.data.QualifiedNetworksService.NetworkAvailabilityUpdater createNetworkAvailabilityUpdater(int); + method @NonNull public abstract android.telephony.data.QualifiedNetworksService.NetworkAvailabilityProvider onCreateNetworkAvailabilityProvider(int); field public static final String QUALIFIED_NETWORKS_SERVICE_INTERFACE = "android.telephony.data.QualifiedNetworksService"; } - public abstract class QualifiedNetworksService.NetworkAvailabilityUpdater implements java.lang.AutoCloseable { - ctor public QualifiedNetworksService.NetworkAvailabilityUpdater(int); + public abstract class QualifiedNetworksService.NetworkAvailabilityProvider implements java.lang.AutoCloseable { + ctor public QualifiedNetworksService.NetworkAvailabilityProvider(int); method public abstract void close(); method public final int getSlotIndex(); - method public final void updateQualifiedNetworkTypes(int, @Nullable int[]); + method public final void updateQualifiedNetworkTypes(int, @NonNull java.util.List<java.lang.Integer>); } } @@ -6700,6 +6728,7 @@ package android.telephony.euicc { field public static final int EUICC_OTA_SUCCEEDED = 3; // 0x3 field public static final String EXTRA_EMBEDDED_SUBSCRIPTION_DOWNLOADABLE_SUBSCRIPTIONS = "android.telephony.euicc.extra.EMBEDDED_SUBSCRIPTION_DOWNLOADABLE_SUBSCRIPTIONS"; field public static final String EXTRA_ENABLE_SUBSCRIPTION = "android.telephony.euicc.extra.ENABLE_SUBSCRIPTION"; + field public static final String EXTRA_FROM_SUBSCRIPTION_ID = "android.telephony.euicc.extra.FROM_SUBSCRIPTION_ID"; field public static final String EXTRA_SUBSCRIPTION_ID = "android.telephony.euicc.extra.SUBSCRIPTION_ID"; field public static final String EXTRA_SUBSCRIPTION_NICKNAME = "android.telephony.euicc.extra.SUBSCRIPTION_NICKNAME"; } @@ -6919,7 +6948,7 @@ package android.telephony.ims { field public final java.util.HashMap<java.lang.String,android.os.Bundle> mParticipants; } - public class ImsException extends java.lang.Exception { + public final class ImsException extends java.lang.Exception { ctor public ImsException(@Nullable String); ctor public ImsException(@Nullable String, int); ctor public ImsException(@Nullable String, int, @Nullable Throwable); @@ -7450,8 +7479,8 @@ package android.telephony.ims.feature { field public static final int STATE_UNAVAILABLE = 0; // 0x0 } - public static class ImsFeature.Capabilities { - field protected int mCapabilities; + @Deprecated public static class ImsFeature.Capabilities { + field @Deprecated protected int mCapabilities; } protected static class ImsFeature.CapabilityCallbackProxy { diff --git a/api/system-removed.txt b/api/system-removed.txt index 478ec2873efc..2ac7fb992e7e 100644 --- a/api/system-removed.txt +++ b/api/system-removed.txt @@ -154,3 +154,11 @@ package android.telephony { } +package android.telephony.data { + + public final class DataCallResponse implements android.os.Parcelable { + ctor public DataCallResponse(int, int, int, int, int, @Nullable String, @Nullable java.util.List<android.net.LinkAddress>, @Nullable java.util.List<java.net.InetAddress>, @Nullable java.util.List<java.net.InetAddress>, @Nullable java.util.List<java.net.InetAddress>, int); + } + +} + diff --git a/api/test-current.txt b/api/test-current.txt index bf5ccd0c2646..ca7410931a50 100644 --- a/api/test-current.txt +++ b/api/test-current.txt @@ -602,8 +602,7 @@ package android.media.audiofx { package android.net { public class CaptivePortal implements android.os.Parcelable { - ctor public CaptivePortal(android.os.IBinder); - method public void logEvent(int, String); + method public void logEvent(int, @NonNull String); method public void useNetwork(); field public static final int APP_RETURN_DISMISSED = 0; // 0x0 field public static final int APP_RETURN_UNWANTED = 1; // 0x1 @@ -611,14 +610,14 @@ package android.net { } public class ConnectivityManager { - method @RequiresPermission(android.net.NetworkStack.PERMISSION_MAINLINE_NETWORK_STACK) public void startCaptivePortalApp(android.net.Network, android.os.Bundle); + method @RequiresPermission(android.net.NetworkStack.PERMISSION_MAINLINE_NETWORK_STACK) public void startCaptivePortalApp(@NonNull android.net.Network, @NonNull android.os.Bundle); field public static final String EXTRA_CAPTIVE_PORTAL_PROBE_SPEC = "android.net.extra.CAPTIVE_PORTAL_PROBE_SPEC"; field public static final String EXTRA_CAPTIVE_PORTAL_USER_AGENT = "android.net.extra.CAPTIVE_PORTAL_USER_AGENT"; } public final class IpPrefix implements android.os.Parcelable { - ctor public IpPrefix(java.net.InetAddress, int); - ctor public IpPrefix(String); + ctor public IpPrefix(@NonNull java.net.InetAddress, int); + ctor public IpPrefix(@NonNull String); } public final class IpSecManager { @@ -629,48 +628,48 @@ package android.net { ctor public LinkAddress(java.net.InetAddress, int, int, int); ctor public LinkAddress(@NonNull java.net.InetAddress, int); ctor public LinkAddress(@NonNull String); - ctor public LinkAddress(String, int, int); + ctor public LinkAddress(@NonNull String, int, int); method public boolean isGlobalPreferred(); - method public boolean isIPv4(); - method public boolean isIPv6(); - method public boolean isSameAddressAs(android.net.LinkAddress); + method public boolean isIpv4(); + method public boolean isIpv6(); + method public boolean isSameAddressAs(@Nullable android.net.LinkAddress); } public final class LinkProperties implements android.os.Parcelable { - ctor public LinkProperties(android.net.LinkProperties); - method public boolean addDnsServer(java.net.InetAddress); - method public boolean addLinkAddress(android.net.LinkAddress); + ctor public LinkProperties(@Nullable android.net.LinkProperties); + method public boolean addDnsServer(@NonNull java.net.InetAddress); + method public boolean addLinkAddress(@NonNull android.net.LinkAddress); method @Nullable public android.net.IpPrefix getNat64Prefix(); - method public java.util.List<java.net.InetAddress> getPcscfServers(); - method public String getTcpBufferSizes(); - method public java.util.List<java.net.InetAddress> getValidatedPrivateDnsServers(); - method public boolean hasGlobalIPv6Address(); - method public boolean hasIPv4Address(); - method public boolean hasIPv6DefaultRoute(); - method public boolean isIPv4Provisioned(); - method public boolean isIPv6Provisioned(); + method @NonNull public java.util.List<java.net.InetAddress> getPcscfServers(); + method @Nullable public String getTcpBufferSizes(); + method @NonNull public java.util.List<java.net.InetAddress> getValidatedPrivateDnsServers(); + method public boolean hasGlobalIpv6Address(); + method public boolean hasIpv4Address(); + method public boolean hasIpv6DefaultRoute(); + method public boolean isIpv4Provisioned(); + method public boolean isIpv6Provisioned(); method public boolean isProvisioned(); - method public boolean isReachable(java.net.InetAddress); - method public boolean removeDnsServer(java.net.InetAddress); - method public boolean removeLinkAddress(android.net.LinkAddress); - method public boolean removeRoute(android.net.RouteInfo); - method public void setNat64Prefix(android.net.IpPrefix); - method public void setPcscfServers(java.util.Collection<java.net.InetAddress>); + method public boolean isReachable(@NonNull java.net.InetAddress); + method public boolean removeDnsServer(@NonNull java.net.InetAddress); + method public boolean removeLinkAddress(@NonNull android.net.LinkAddress); + method public boolean removeRoute(@NonNull android.net.RouteInfo); + method public void setNat64Prefix(@Nullable android.net.IpPrefix); + method public void setPcscfServers(@NonNull java.util.Collection<java.net.InetAddress>); method public void setPrivateDnsServerName(@Nullable String); - method public void setTcpBufferSizes(String); + method public void setTcpBufferSizes(@Nullable String); method public void setUsePrivateDns(boolean); - method public void setValidatedPrivateDnsServers(java.util.Collection<java.net.InetAddress>); + method public void setValidatedPrivateDnsServers(@NonNull java.util.Collection<java.net.InetAddress>); } public class Network implements android.os.Parcelable { - ctor public Network(android.net.Network); - method public android.net.Network getPrivateDnsBypassingCopy(); + ctor public Network(@NonNull android.net.Network); + method @NonNull public android.net.Network getPrivateDnsBypassingCopy(); } public final class NetworkCapabilities implements android.os.Parcelable { method public int[] getCapabilities(); - method public int[] getTransportTypes(); - method public boolean satisfiedByNetworkCapabilities(android.net.NetworkCapabilities); + method @NonNull public int[] getTransportTypes(); + method public boolean satisfiedByNetworkCapabilities(@Nullable android.net.NetworkCapabilities); field public static final int TRANSPORT_TEST = 7; // 0x7 } @@ -679,7 +678,7 @@ package android.net { } public final class RouteInfo implements android.os.Parcelable { - ctor public RouteInfo(android.net.IpPrefix, java.net.InetAddress, String, int); + ctor public RouteInfo(@Nullable android.net.IpPrefix, @Nullable java.net.InetAddress, @Nullable String, int); method public int getType(); field public static final int RTN_THROW = 9; // 0x9 field public static final int RTN_UNICAST = 1; // 0x1 @@ -688,18 +687,18 @@ package android.net { public final class StaticIpConfiguration implements android.os.Parcelable { ctor public StaticIpConfiguration(); - ctor public StaticIpConfiguration(android.net.StaticIpConfiguration); - method public void addDnsServer(java.net.InetAddress); + ctor public StaticIpConfiguration(@Nullable android.net.StaticIpConfiguration); + method public void addDnsServer(@NonNull java.net.InetAddress); method public void clear(); method public int describeContents(); - method public java.util.List<java.net.InetAddress> getDnsServers(); - method public String getDomains(); - method public java.net.InetAddress getGateway(); - method public android.net.LinkAddress getIpAddress(); - method public java.util.List<android.net.RouteInfo> getRoutes(String); - method public void setDomains(String); - method public void setGateway(java.net.InetAddress); - method public void setIpAddress(android.net.LinkAddress); + method @NonNull public java.util.List<java.net.InetAddress> getDnsServers(); + method @Nullable public String getDomains(); + method @Nullable public java.net.InetAddress getGateway(); + method @Nullable public android.net.LinkAddress getIpAddress(); + method @NonNull public java.util.List<android.net.RouteInfo> getRoutes(@Nullable String); + method public void setDomains(@Nullable String); + method public void setGateway(@Nullable java.net.InetAddress); + method public void setIpAddress(@Nullable android.net.LinkAddress); method public void writeToParcel(android.os.Parcel, int); field public static final android.os.Parcelable.Creator<android.net.StaticIpConfiguration> CREATOR; } @@ -733,11 +732,14 @@ package android.net { package android.net.apf { - public class ApfCapabilities { + public final class ApfCapabilities implements android.os.Parcelable { ctor public ApfCapabilities(int, int, int); - method public static boolean getApfDrop8023Frames(android.content.Context); - method public static int[] getApfEthTypeBlackList(android.content.Context); + method public int describeContents(); + method public static boolean getApfDrop8023Frames(@NonNull android.content.Context); + method @NonNull public static int[] getApfEthTypeBlackList(@NonNull android.content.Context); method public boolean hasDataAccess(); + method public void writeToParcel(android.os.Parcel, int); + field public static final android.os.Parcelable.Creator<android.net.apf.ApfCapabilities> CREATOR; field public final int apfPacketFormat; field public final int apfVersionSupported; field public final int maximumApfProgramSize; @@ -749,28 +751,28 @@ package android.net.captiveportal { public final class CaptivePortalProbeResult { ctor public CaptivePortalProbeResult(int); - ctor public CaptivePortalProbeResult(int, String, String); - ctor public CaptivePortalProbeResult(int, String, String, android.net.captiveportal.CaptivePortalProbeSpec); + ctor public CaptivePortalProbeResult(int, @Nullable String, @Nullable String); + ctor public CaptivePortalProbeResult(int, @Nullable String, @Nullable String, @Nullable android.net.captiveportal.CaptivePortalProbeSpec); method public boolean isFailed(); method public boolean isPartialConnectivity(); method public boolean isPortal(); method public boolean isSuccessful(); - field public static final android.net.captiveportal.CaptivePortalProbeResult FAILED; + field @NonNull public static final android.net.captiveportal.CaptivePortalProbeResult FAILED; field public static final int FAILED_CODE = 599; // 0x257 field public static final android.net.captiveportal.CaptivePortalProbeResult PARTIAL; field public static final int PORTAL_CODE = 302; // 0x12e - field public static final android.net.captiveportal.CaptivePortalProbeResult SUCCESS; + field @NonNull public static final android.net.captiveportal.CaptivePortalProbeResult SUCCESS; field public static final int SUCCESS_CODE = 204; // 0xcc - field public final String detectUrl; + field @Nullable public final String detectUrl; field @Nullable public final android.net.captiveportal.CaptivePortalProbeSpec probeSpec; - field public final String redirectUrl; + field @Nullable public final String redirectUrl; } public abstract class CaptivePortalProbeSpec { - method public String getEncodedSpec(); - method public abstract android.net.captiveportal.CaptivePortalProbeResult getResult(int, @Nullable String); - method public java.net.URL getUrl(); - method public static java.util.Collection<android.net.captiveportal.CaptivePortalProbeSpec> parseCaptivePortalProbeSpecs(String); + method @NonNull public String getEncodedSpec(); + method @NonNull public abstract android.net.captiveportal.CaptivePortalProbeResult getResult(int, @Nullable String); + method @NonNull public java.net.URL getUrl(); + method @NonNull public static java.util.Collection<android.net.captiveportal.CaptivePortalProbeSpec> parseCaptivePortalProbeSpecs(@NonNull String); method @Nullable public static android.net.captiveportal.CaptivePortalProbeSpec parseSpecOrNull(@Nullable String); } @@ -781,78 +783,78 @@ package android.net.metrics { public final class ApfProgramEvent implements android.net.metrics.IpConnectivityLog.Event { } - public static class ApfProgramEvent.Builder { + public static final class ApfProgramEvent.Builder { ctor public ApfProgramEvent.Builder(); - method public android.net.metrics.ApfProgramEvent build(); - method public android.net.metrics.ApfProgramEvent.Builder setActualLifetime(long); - method public android.net.metrics.ApfProgramEvent.Builder setCurrentRas(int); - method public android.net.metrics.ApfProgramEvent.Builder setFilteredRas(int); - method public android.net.metrics.ApfProgramEvent.Builder setFlags(boolean, boolean); - method public android.net.metrics.ApfProgramEvent.Builder setLifetime(long); - method public android.net.metrics.ApfProgramEvent.Builder setProgramLength(int); + method @NonNull public android.net.metrics.ApfProgramEvent build(); + method @NonNull public android.net.metrics.ApfProgramEvent.Builder setActualLifetime(long); + method @NonNull public android.net.metrics.ApfProgramEvent.Builder setCurrentRas(int); + method @NonNull public android.net.metrics.ApfProgramEvent.Builder setFilteredRas(int); + method @NonNull public android.net.metrics.ApfProgramEvent.Builder setFlags(boolean, boolean); + method @NonNull public android.net.metrics.ApfProgramEvent.Builder setLifetime(long); + method @NonNull public android.net.metrics.ApfProgramEvent.Builder setProgramLength(int); } public final class ApfStats implements android.net.metrics.IpConnectivityLog.Event { } - public static class ApfStats.Builder { + public static final class ApfStats.Builder { ctor public ApfStats.Builder(); - method public android.net.metrics.ApfStats build(); - method public android.net.metrics.ApfStats.Builder setDroppedRas(int); - method public android.net.metrics.ApfStats.Builder setDurationMs(long); - method public android.net.metrics.ApfStats.Builder setMatchingRas(int); - method public android.net.metrics.ApfStats.Builder setMaxProgramSize(int); - method public android.net.metrics.ApfStats.Builder setParseErrors(int); - method public android.net.metrics.ApfStats.Builder setProgramUpdates(int); - method public android.net.metrics.ApfStats.Builder setProgramUpdatesAll(int); - method public android.net.metrics.ApfStats.Builder setProgramUpdatesAllowingMulticast(int); - method public android.net.metrics.ApfStats.Builder setReceivedRas(int); - method public android.net.metrics.ApfStats.Builder setZeroLifetimeRas(int); + method @NonNull public android.net.metrics.ApfStats build(); + method @NonNull public android.net.metrics.ApfStats.Builder setDroppedRas(int); + method @NonNull public android.net.metrics.ApfStats.Builder setDurationMs(long); + method @NonNull public android.net.metrics.ApfStats.Builder setMatchingRas(int); + method @NonNull public android.net.metrics.ApfStats.Builder setMaxProgramSize(int); + method @NonNull public android.net.metrics.ApfStats.Builder setParseErrors(int); + method @NonNull public android.net.metrics.ApfStats.Builder setProgramUpdates(int); + method @NonNull public android.net.metrics.ApfStats.Builder setProgramUpdatesAll(int); + method @NonNull public android.net.metrics.ApfStats.Builder setProgramUpdatesAllowingMulticast(int); + method @NonNull public android.net.metrics.ApfStats.Builder setReceivedRas(int); + method @NonNull public android.net.metrics.ApfStats.Builder setZeroLifetimeRas(int); } public final class DhcpClientEvent implements android.net.metrics.IpConnectivityLog.Event { } - public static class DhcpClientEvent.Builder { + public static final class DhcpClientEvent.Builder { ctor public DhcpClientEvent.Builder(); - method public android.net.metrics.DhcpClientEvent build(); - method public android.net.metrics.DhcpClientEvent.Builder setDurationMs(int); - method public android.net.metrics.DhcpClientEvent.Builder setMsg(String); + method @NonNull public android.net.metrics.DhcpClientEvent build(); + method @NonNull public android.net.metrics.DhcpClientEvent.Builder setDurationMs(int); + method @NonNull public android.net.metrics.DhcpClientEvent.Builder setMsg(String); } public final class DhcpErrorEvent implements android.net.metrics.IpConnectivityLog.Event { ctor public DhcpErrorEvent(int); method public static int errorCodeWithOption(int, int); - field public static final int BOOTP_TOO_SHORT; - field public static final int BUFFER_UNDERFLOW; - field public static final int DHCP_BAD_MAGIC_COOKIE; + field public static final int BOOTP_TOO_SHORT = 67174400; // 0x4010000 + field public static final int BUFFER_UNDERFLOW = 83951616; // 0x5010000 + field public static final int DHCP_BAD_MAGIC_COOKIE = 67239936; // 0x4020000 field public static final int DHCP_ERROR = 4; // 0x4 - field public static final int DHCP_INVALID_OPTION_LENGTH; - field public static final int DHCP_NO_COOKIE; - field public static final int DHCP_NO_MSG_TYPE; - field public static final int DHCP_UNKNOWN_MSG_TYPE; + field public static final int DHCP_INVALID_OPTION_LENGTH = 67305472; // 0x4030000 + field public static final int DHCP_NO_COOKIE = 67502080; // 0x4060000 + field public static final int DHCP_NO_MSG_TYPE = 67371008; // 0x4040000 + field public static final int DHCP_UNKNOWN_MSG_TYPE = 67436544; // 0x4050000 field public static final int L2_ERROR = 1; // 0x1 - field public static final int L2_TOO_SHORT; - field public static final int L2_WRONG_ETH_TYPE; + field public static final int L2_TOO_SHORT = 16842752; // 0x1010000 + field public static final int L2_WRONG_ETH_TYPE = 16908288; // 0x1020000 field public static final int L3_ERROR = 2; // 0x2 - field public static final int L3_INVALID_IP; - field public static final int L3_NOT_IPV4; - field public static final int L3_TOO_SHORT; + field public static final int L3_INVALID_IP = 33751040; // 0x2030000 + field public static final int L3_NOT_IPV4 = 33685504; // 0x2020000 + field public static final int L3_TOO_SHORT = 33619968; // 0x2010000 field public static final int L4_ERROR = 3; // 0x3 - field public static final int L4_NOT_UDP; - field public static final int L4_WRONG_PORT; + field public static final int L4_NOT_UDP = 50397184; // 0x3010000 + field public static final int L4_WRONG_PORT = 50462720; // 0x3020000 field public static final int MISC_ERROR = 5; // 0x5 - field public static final int PARSING_ERROR; - field public static final int RECEIVE_ERROR; + field public static final int PARSING_ERROR = 84082688; // 0x5030000 + field public static final int RECEIVE_ERROR = 84017152; // 0x5020000 } public class IpConnectivityLog { ctor public IpConnectivityLog(); - method public boolean log(long, android.net.metrics.IpConnectivityLog.Event); - method public boolean log(String, android.net.metrics.IpConnectivityLog.Event); - method public boolean log(android.net.Network, int[], android.net.metrics.IpConnectivityLog.Event); - method public boolean log(int, int[], android.net.metrics.IpConnectivityLog.Event); - method public boolean log(android.net.metrics.IpConnectivityLog.Event); + method public boolean log(long, @NonNull android.net.metrics.IpConnectivityLog.Event); + method public boolean log(@NonNull String, @NonNull android.net.metrics.IpConnectivityLog.Event); + method public boolean log(@NonNull android.net.Network, @NonNull int[], @NonNull android.net.metrics.IpConnectivityLog.Event); + method public boolean log(int, @NonNull int[], @NonNull android.net.metrics.IpConnectivityLog.Event); + method public boolean log(@NonNull android.net.metrics.IpConnectivityLog.Event); } public static interface IpConnectivityLog.Event extends android.os.Parcelable { @@ -900,19 +902,19 @@ package android.net.metrics { public final class RaEvent implements android.net.metrics.IpConnectivityLog.Event { } - public static class RaEvent.Builder { + public static final class RaEvent.Builder { ctor public RaEvent.Builder(); - method public android.net.metrics.RaEvent build(); - method public android.net.metrics.RaEvent.Builder updateDnsslLifetime(long); - method public android.net.metrics.RaEvent.Builder updatePrefixPreferredLifetime(long); - method public android.net.metrics.RaEvent.Builder updatePrefixValidLifetime(long); - method public android.net.metrics.RaEvent.Builder updateRdnssLifetime(long); - method public android.net.metrics.RaEvent.Builder updateRouteInfoLifetime(long); - method public android.net.metrics.RaEvent.Builder updateRouterLifetime(long); + method @NonNull public android.net.metrics.RaEvent build(); + method @NonNull public android.net.metrics.RaEvent.Builder updateDnsslLifetime(long); + method @NonNull public android.net.metrics.RaEvent.Builder updatePrefixPreferredLifetime(long); + method @NonNull public android.net.metrics.RaEvent.Builder updatePrefixValidLifetime(long); + method @NonNull public android.net.metrics.RaEvent.Builder updateRdnssLifetime(long); + method @NonNull public android.net.metrics.RaEvent.Builder updateRouteInfoLifetime(long); + method @NonNull public android.net.metrics.RaEvent.Builder updateRouterLifetime(long); } public final class ValidationProbeEvent implements android.net.metrics.IpConnectivityLog.Event { - method public static String getProbeName(int); + method @NonNull public static String getProbeName(int); field public static final int DNS_FAILURE = 0; // 0x0 field public static final int DNS_SUCCESS = 1; // 0x1 field public static final int PROBE_DNS = 0; // 0x0 @@ -923,12 +925,12 @@ package android.net.metrics { field public static final int PROBE_PRIVDNS = 5; // 0x5 } - public static class ValidationProbeEvent.Builder { + public static final class ValidationProbeEvent.Builder { ctor public ValidationProbeEvent.Builder(); - method public android.net.metrics.ValidationProbeEvent build(); - method public android.net.metrics.ValidationProbeEvent.Builder setDurationMs(long); - method public android.net.metrics.ValidationProbeEvent.Builder setProbeType(int, boolean); - method public android.net.metrics.ValidationProbeEvent.Builder setReturnCode(int); + method @NonNull public android.net.metrics.ValidationProbeEvent build(); + method @NonNull public android.net.metrics.ValidationProbeEvent.Builder setDurationMs(long); + method @NonNull public android.net.metrics.ValidationProbeEvent.Builder setProbeType(int, boolean); + method @NonNull public android.net.metrics.ValidationProbeEvent.Builder setReturnCode(int); } } @@ -1482,10 +1484,34 @@ package android.telecom { package android.telephony { + public final class AccessNetworkConstants { + field public static final int TRANSPORT_TYPE_WLAN = 2; // 0x2 + field public static final int TRANSPORT_TYPE_WWAN = 1; // 0x1 + } + public class CarrierConfigManager { method @RequiresPermission(android.Manifest.permission.MODIFY_PHONE_STATE) public void overrideConfig(int, @Nullable android.os.PersistableBundle); } + public final class DataSpecificRegistrationInfo implements android.os.Parcelable { + method public int describeContents(); + method @NonNull public android.telephony.LteVopsSupportInfo getLteVopsSupportInfo(); + method public void writeToParcel(android.os.Parcel, int); + field @NonNull public static final android.os.Parcelable.Creator<android.telephony.DataSpecificRegistrationInfo> CREATOR; + } + + public final class LteVopsSupportInfo implements android.os.Parcelable { + ctor public LteVopsSupportInfo(int, int); + method public int describeContents(); + method public int getEmcBearerSupport(); + method public int getVopsSupport(); + method public void writeToParcel(android.os.Parcel, int); + field public static final android.os.Parcelable.Creator<android.telephony.LteVopsSupportInfo> CREATOR; + field public static final int LTE_STATUS_NOT_AVAILABLE = 1; // 0x1 + field public static final int LTE_STATUS_NOT_SUPPORTED = 3; // 0x3 + field public static final int LTE_STATUS_SUPPORTED = 2; // 0x2 + } + public class MbmsDownloadSession implements java.lang.AutoCloseable { field public static final String MBMS_DOWNLOAD_SERVICE_OVERRIDE_METADATA = "mbms-download-service-override"; } @@ -1498,12 +1524,59 @@ package android.telephony { field public static final String MBMS_STREAMING_SERVICE_OVERRIDE_METADATA = "mbms-streaming-service-override"; } + public final class NetworkRegistrationInfo implements android.os.Parcelable { + method public int describeContents(); + method public int getAccessNetworkTechnology(); + method @NonNull public java.util.List<java.lang.Integer> getAvailableServices(); + method @Nullable public android.telephony.CellIdentity getCellIdentity(); + method @Nullable public android.telephony.DataSpecificRegistrationInfo getDataSpecificInfo(); + method public int getDomain(); + method public int getRegistrationState(); + method public int getRejectCause(); + method public int getRoamingType(); + method public int getTransportType(); + method public boolean isEmergencyEnabled(); + method public boolean isRoaming(); + method public void writeToParcel(android.os.Parcel, int); + field @NonNull public static final android.os.Parcelable.Creator<android.telephony.NetworkRegistrationInfo> CREATOR; + field public static final int DOMAIN_CS = 1; // 0x1 + field public static final int DOMAIN_PS = 2; // 0x2 + field public static final int REGISTRATION_STATE_DENIED = 3; // 0x3 + field public static final int REGISTRATION_STATE_HOME = 1; // 0x1 + field public static final int REGISTRATION_STATE_NOT_REGISTERED_OR_SEARCHING = 0; // 0x0 + field public static final int REGISTRATION_STATE_NOT_REGISTERED_SEARCHING = 2; // 0x2 + field public static final int REGISTRATION_STATE_ROAMING = 5; // 0x5 + field public static final int REGISTRATION_STATE_UNKNOWN = 4; // 0x4 + field public static final int SERVICE_TYPE_DATA = 2; // 0x2 + field public static final int SERVICE_TYPE_EMERGENCY = 5; // 0x5 + field public static final int SERVICE_TYPE_SMS = 3; // 0x3 + field public static final int SERVICE_TYPE_UNKNOWN = 0; // 0x0 + field public static final int SERVICE_TYPE_VIDEO = 4; // 0x4 + field public static final int SERVICE_TYPE_VOICE = 1; // 0x1 + } + + public static final class NetworkRegistrationInfo.Builder { + ctor public NetworkRegistrationInfo.Builder(); + method @NonNull public android.telephony.NetworkRegistrationInfo build(); + method @NonNull public android.telephony.NetworkRegistrationInfo.Builder setAccessNetworkTechnology(int); + method @NonNull public android.telephony.NetworkRegistrationInfo.Builder setAvailableServices(@NonNull java.util.List<java.lang.Integer>); + method @NonNull public android.telephony.NetworkRegistrationInfo.Builder setCellIdentity(@Nullable android.telephony.CellIdentity); + method @NonNull public android.telephony.NetworkRegistrationInfo.Builder setDomain(int); + method @NonNull public android.telephony.NetworkRegistrationInfo.Builder setEmergencyOnly(boolean); + method @NonNull public android.telephony.NetworkRegistrationInfo.Builder setRegistrationState(int); + method @NonNull public android.telephony.NetworkRegistrationInfo.Builder setRejectCause(int); + method @NonNull public android.telephony.NetworkRegistrationInfo.Builder setTransportType(int); + } + public class ServiceState implements android.os.Parcelable { + method public void addNetworkRegistrationInfo(android.telephony.NetworkRegistrationInfo); method public void setCdmaSystemAndNetworkId(int, int); method public void setCellBandwidths(int[]); method public void setChannelNumber(int); + method public void setDataRoamingType(int); method public void setRilDataRadioTechnology(int); method public void setRilVoiceRadioTechnology(int); + method public void setVoiceRoamingType(int); } public class TelephonyManager { diff --git a/cmds/statsd/src/atoms.proto b/cmds/statsd/src/atoms.proto index 47eccdbc8c1f..9ab7c215d82d 100644 --- a/cmds/statsd/src/atoms.proto +++ b/cmds/statsd/src/atoms.proto @@ -32,6 +32,7 @@ import "frameworks/base/core/proto/android/net/networkcapabilities.proto"; import "frameworks/base/core/proto/android/os/enums.proto"; import "frameworks/base/core/proto/android/server/connectivity/data_stall_event.proto"; import "frameworks/base/core/proto/android/server/enums.proto"; +import "frameworks/base/core/proto/android/stats/connectivity/network_stack.proto"; import "frameworks/base/core/proto/android/stats/launcher/launcher.proto"; import "frameworks/base/core/proto/android/telecomm/enums.proto"; import "frameworks/base/core/proto/android/telephony/enums.proto"; @@ -164,6 +165,7 @@ message Atom { BluetoothSmpPairingEventReported bluetooth_smp_pairing_event_reported = 167; ProcessStartTime process_start_time = 169; BluetoothSocketConnectionStateChanged bluetooth_socket_connection_state_changed = 171; + NetworkStackReported network_stack_reported = 182; } // Pulled events will start at field 10000. @@ -1714,6 +1716,9 @@ message BluetoothClassicPairingEventReported { // HCI reason code associated with this event // Default: STATUS_UNKNOWN optional android.bluetooth.hci.StatusEnum reason_code = 6; + // A status value related to this specific event + // Default: 0 + optional int64 event_value = 7; } /** @@ -3049,3 +3054,14 @@ message ProcessStartTime { optional string hosting_name = 9; } +/** + * Push network stack events. + * + * Log from: + * frameworks/base/packages/NetworkStack/ + */ +message NetworkStackReported { + optional int32 eventId = 1; + optional android.stats.connectivity.NetworkStackEventData network_stack_event = 2 [(log_mode) = MODE_BYTES]; +} + diff --git a/config/hiddenapi-greylist.txt b/config/hiddenapi-greylist.txt index c3d057b66be8..7efadf20c3e4 100644 --- a/config/hiddenapi-greylist.txt +++ b/config/hiddenapi-greylist.txt @@ -157,7 +157,6 @@ Landroid/bluetooth/IBluetoothStateChangeCallback$Stub;-><init>()V Landroid/companion/ICompanionDeviceDiscoveryService$Stub;-><init>()V Landroid/companion/ICompanionDeviceDiscoveryServiceCallback;->onDeviceSelected(Ljava/lang/String;ILjava/lang/String;)V Landroid/companion/ICompanionDeviceDiscoveryServiceCallback;->onDeviceSelectionCancel()V -Landroid/companion/IFindDeviceCallback;->onSuccess(Landroid/app/PendingIntent;)V Landroid/content/IClipboard$Stub$Proxy;-><init>(Landroid/os/IBinder;)V Landroid/content/IClipboard$Stub;->asInterface(Landroid/os/IBinder;)Landroid/content/IClipboard; Landroid/content/IContentService$Stub$Proxy;-><init>(Landroid/os/IBinder;)V @@ -239,7 +238,6 @@ Landroid/database/IContentObserver$Stub;->asInterface(Landroid/os/IBinder;)Landr Landroid/database/IContentObserver;->onChange(ZLandroid/net/Uri;I)V Landroid/database/sqlite/SQLiteConnectionPool;->$assertionsDisabled:Z Landroid/database/sqlite/SQLiteDatabase;->$assertionsDisabled:Z -Landroid/filterfw/GraphEnvironment;->addReferences([Ljava/lang/Object;)V Landroid/hardware/camera2/CameraCharacteristics;->CONTROL_AVAILABLE_HIGH_SPEED_VIDEO_CONFIGURATIONS:Landroid/hardware/camera2/CameraCharacteristics$Key; Landroid/hardware/camera2/CameraCharacteristics;->CONTROL_MAX_REGIONS:Landroid/hardware/camera2/CameraCharacteristics$Key; Landroid/hardware/camera2/CameraCharacteristics;->DEPTH_AVAILABLE_DEPTH_MIN_FRAME_DURATIONS:Landroid/hardware/camera2/CameraCharacteristics$Key; @@ -293,7 +291,6 @@ Landroid/hardware/camera2/CaptureResult;->SYNC_FRAME_NUMBER:Landroid/hardware/ca Landroid/hardware/camera2/CaptureResult;->TONEMAP_CURVE_BLUE:Landroid/hardware/camera2/CaptureResult$Key; Landroid/hardware/camera2/CaptureResult;->TONEMAP_CURVE_GREEN:Landroid/hardware/camera2/CaptureResult$Key; Landroid/hardware/camera2/CaptureResult;->TONEMAP_CURVE_RED:Landroid/hardware/camera2/CaptureResult$Key; -Landroid/hardware/camera2/utils/HashCodeHelpers;->hashCode([I)I Landroid/hardware/display/IDisplayManager$Stub;->asInterface(Landroid/os/IBinder;)Landroid/hardware/display/IDisplayManager; Landroid/hardware/fingerprint/IFingerprintService$Stub$Proxy;-><init>(Landroid/os/IBinder;)V Landroid/hardware/fingerprint/IFingerprintService$Stub;->asInterface(Landroid/os/IBinder;)Landroid/hardware/fingerprint/IFingerprintService; @@ -305,8 +302,6 @@ Landroid/hardware/location/IActivityRecognitionHardwareClient$Stub;-><init>()V Landroid/hardware/location/IContextHubService$Stub;->asInterface(Landroid/os/IBinder;)Landroid/hardware/location/IContextHubService; Landroid/hardware/usb/IUsbManager$Stub$Proxy;-><init>(Landroid/os/IBinder;)V Landroid/hardware/usb/IUsbManager$Stub;->asInterface(Landroid/os/IBinder;)Landroid/hardware/usb/IUsbManager; -Landroid/inputmethodservice/IInputMethodSessionWrapper;->mCaller:Lcom/android/internal/os/HandlerCaller; -Landroid/inputmethodservice/IInputMethodWrapper;->mCaller:Lcom/android/internal/os/HandlerCaller; Landroid/location/ICountryDetector$Stub;->asInterface(Landroid/os/IBinder;)Landroid/location/ICountryDetector; Landroid/location/ICountryListener$Stub;-><init>()V Landroid/location/IGeocodeProvider$Stub;-><init>()V @@ -321,7 +316,6 @@ Landroid/location/ILocationManager$Stub;->asInterface(Landroid/os/IBinder;)Landr Landroid/location/ILocationManager$Stub;->TRANSACTION_getAllProviders:I Landroid/location/INetInitiatedListener$Stub;-><init>()V Landroid/location/LocationManager$ListenerTransport;-><init>(Landroid/location/LocationManager;Landroid/location/LocationListener;Landroid/os/Looper;)V -Landroid/media/effect/SingleFilterEffect;-><init>(Landroid/media/effect/EffectContext;Ljava/lang/String;Ljava/lang/Class;Ljava/lang/String;Ljava/lang/String;[Ljava/lang/Object;)V Landroid/media/IAudioRoutesObserver$Stub;-><init>()V Landroid/media/IAudioService$Stub$Proxy;-><init>(Landroid/os/IBinder;)V Landroid/media/IAudioService$Stub;-><init>()V @@ -366,7 +360,6 @@ Landroid/net/InterfaceConfiguration;-><init>()V Landroid/net/LinkProperties$ProvisioningChange;->values()[Landroid/net/LinkProperties$ProvisioningChange; Landroid/net/MobileLinkQualityInfo;-><init>()V Landroid/net/nsd/INsdManager$Stub;->asInterface(Landroid/os/IBinder;)Landroid/net/nsd/INsdManager; -Landroid/net/nsd/INsdManager;->getMessenger()Landroid/os/Messenger; Landroid/net/sip/ISipSession$Stub;->asInterface(Landroid/os/IBinder;)Landroid/net/sip/ISipSession; Landroid/net/SntpClient;-><init>()V Landroid/net/wifi/IWifiManager$Stub$Proxy;-><init>(Landroid/os/IBinder;)V @@ -411,7 +404,6 @@ Landroid/os/storage/IObbActionListener$Stub;-><init>()V Landroid/os/storage/IStorageManager$Stub$Proxy;-><init>(Landroid/os/IBinder;)V Landroid/os/storage/IStorageManager$Stub;->asInterface(Landroid/os/IBinder;)Landroid/os/storage/IStorageManager; Landroid/os/storage/StorageEventListener;-><init>()V -Landroid/preference/PreferenceGroupAdapter;->getItem(I)Landroid/preference/Preference; Landroid/R$styleable;->ActionBar:[I Landroid/R$styleable;->ActionBar_background:I Landroid/R$styleable;->ActionBar_backgroundSplit:I @@ -677,17 +669,6 @@ Landroid/R$styleable;->Window:[I Landroid/R$styleable;->Window_windowBackground:I Landroid/R$styleable;->Window_windowFrame:I Landroid/security/IKeyChainService$Stub;->asInterface(Landroid/os/IBinder;)Landroid/security/IKeyChainService; -Landroid/security/keymaster/KeymasterBlobArgument;-><init>(ILandroid/os/Parcel;)V -Landroid/security/keymaster/KeymasterBlobArgument;-><init>(I[B)V -Landroid/security/keymaster/KeymasterBlobArgument;->blob:[B -Landroid/security/keymaster/KeymasterBooleanArgument;-><init>(ILandroid/os/Parcel;)V -Landroid/security/keymaster/KeymasterDateArgument;-><init>(ILandroid/os/Parcel;)V -Landroid/security/keymaster/KeymasterIntArgument;-><init>(II)V -Landroid/security/keymaster/KeymasterIntArgument;-><init>(ILandroid/os/Parcel;)V -Landroid/security/keymaster/KeymasterIntArgument;->value:I -Landroid/security/keymaster/KeymasterLongArgument;-><init>(IJ)V -Landroid/security/keymaster/KeymasterLongArgument;-><init>(ILandroid/os/Parcel;)V -Landroid/security/keymaster/KeymasterLongArgument;->value:J Landroid/security/keystore/IKeystoreService$Stub;->asInterface(Landroid/os/IBinder;)Landroid/security/keystore/IKeystoreService; Landroid/security/keystore/IKeystoreService;->clear_uid(J)I Landroid/security/keystore/IKeystoreService;->del(Ljava/lang/String;I)I @@ -711,13 +692,10 @@ Landroid/service/persistentdata/IPersistentDataBlockService$Stub;->asInterface(L Landroid/service/vr/IVrManager$Stub;->asInterface(Landroid/os/IBinder;)Landroid/service/vr/IVrManager; Landroid/service/wallpaper/IWallpaperConnection$Stub;-><init>()V Landroid/service/wallpaper/IWallpaperService$Stub;->asInterface(Landroid/os/IBinder;)Landroid/service/wallpaper/IWallpaperService; -Landroid/telecom/Log;->i(Ljava/lang/String;Ljava/lang/String;[Ljava/lang/Object;)V -Landroid/telecom/Log;->w(Ljava/lang/String;Ljava/lang/String;[Ljava/lang/Object;)V Landroid/telephony/ims/compat/feature/MMTelFeature;-><init>()V Landroid/telephony/ims/compat/ImsService;-><init>()V Landroid/telephony/ims/compat/stub/ImsCallSessionImplBase;-><init>()V Landroid/telephony/ims/compat/stub/ImsUtListenerImplBase;-><init>()V -Landroid/telephony/JapanesePhoneNumberFormatter;->format(Landroid/text/Editable;)V Landroid/telephony/mbms/IMbmsStreamingSessionCallback$Stub;-><init>()V Landroid/telephony/mbms/IStreamingServiceCallback$Stub;-><init>()V Landroid/telephony/mbms/vendor/IMbmsStreamingService$Stub;->asInterface(Landroid/os/IBinder;)Landroid/telephony/mbms/vendor/IMbmsStreamingService; @@ -747,14 +725,8 @@ Landroid/telephony/SmsCbMessage;->isCmasMessage()Z Landroid/telephony/SmsCbMessage;->isEmergencyMessage()Z Landroid/telephony/TelephonyManager$MultiSimVariants;->values()[Landroid/telephony/TelephonyManager$MultiSimVariants; Landroid/util/Singleton;-><init>()V -Landroid/util/XmlPullAttributes;-><init>(Lorg/xmlpull/v1/XmlPullParser;)V -Landroid/util/XmlPullAttributes;->mParser:Lorg/xmlpull/v1/XmlPullParser; -Landroid/view/accessibility/IAccessibilityInteractionConnectionCallback;->setFindAccessibilityNodeInfoResult(Landroid/view/accessibility/AccessibilityNodeInfo;I)V -Landroid/view/accessibility/IAccessibilityInteractionConnectionCallback;->setFindAccessibilityNodeInfosResult(Ljava/util/List;I)V -Landroid/view/accessibility/IAccessibilityInteractionConnectionCallback;->setPerformAccessibilityActionResult(ZI)V Landroid/view/accessibility/IAccessibilityManager$Stub$Proxy;-><init>(Landroid/os/IBinder;)V Landroid/view/accessibility/IAccessibilityManager$Stub;->asInterface(Landroid/os/IBinder;)Landroid/view/accessibility/IAccessibilityManager; -Landroid/view/accessibility/IAccessibilityManager;->getEnabledAccessibilityServiceList(II)Ljava/util/List; Landroid/view/AccessibilityIterators$AbstractTextSegmentIterator;-><init>()V Landroid/view/autofill/IAutoFillManager$Stub$Proxy;-><init>(Landroid/os/IBinder;)V Landroid/view/autofill/IAutoFillManager$Stub;->asInterface(Landroid/os/IBinder;)Landroid/view/autofill/IAutoFillManager; @@ -822,11 +794,6 @@ Lcom/android/ims/internal/uce/presence/IPresenceService$Stub;-><init>()V Lcom/android/ims/internal/uce/uceservice/IUceListener$Stub;-><init>()V Lcom/android/ims/internal/uce/uceservice/IUceService$Stub;-><init>()V Lcom/android/internal/app/AlertActivity;-><init>()V -Lcom/android/internal/app/AlertActivity;->mAlert:Lcom/android/internal/app/AlertController; -Lcom/android/internal/app/AlertActivity;->mAlertParams:Lcom/android/internal/app/AlertController$AlertParams; -Lcom/android/internal/app/AlertActivity;->setupAlert()V -Lcom/android/internal/app/AssistUtils;-><init>(Landroid/content/Context;)V -Lcom/android/internal/app/AssistUtils;->getAssistComponentForUser(I)Landroid/content/ComponentName; Lcom/android/internal/app/ChooserActivity;-><init>()V Lcom/android/internal/app/IAppOpsCallback$Stub;-><init>()V Lcom/android/internal/app/IAppOpsService$Stub$Proxy;-><init>(Landroid/os/IBinder;)V @@ -854,34 +821,9 @@ Lcom/android/internal/app/IAppOpsService$Stub;->TRANSACTION_stopWatchingMode:I Lcom/android/internal/app/IBatteryStats$Stub$Proxy;-><init>(Landroid/os/IBinder;)V Lcom/android/internal/app/IBatteryStats$Stub;->asInterface(Landroid/os/IBinder;)Lcom/android/internal/app/IBatteryStats; Lcom/android/internal/app/IMediaContainerService$Stub;->asInterface(Landroid/os/IBinder;)Lcom/android/internal/app/IMediaContainerService; -Lcom/android/internal/app/IntentForwarderActivity;->TAG:Ljava/lang/String; Lcom/android/internal/app/IVoiceInteractionManagerService$Stub$Proxy;->showSessionFromSession(Landroid/os/IBinder;Landroid/os/Bundle;I)Z Lcom/android/internal/app/IVoiceInteractionManagerService$Stub;->asInterface(Landroid/os/IBinder;)Lcom/android/internal/app/IVoiceInteractionManagerService; -Lcom/android/internal/app/LocaleHelper$LocaleInfoComparator;-><init>(Ljava/util/Locale;Z)V -Lcom/android/internal/app/LocaleHelper$LocaleInfoComparator;->compare(Lcom/android/internal/app/LocaleStore$LocaleInfo;Lcom/android/internal/app/LocaleStore$LocaleInfo;)I -Lcom/android/internal/app/LocaleHelper;->getDisplayCountry(Ljava/util/Locale;Ljava/util/Locale;)Ljava/lang/String; -Lcom/android/internal/app/LocaleHelper;->getDisplayName(Ljava/util/Locale;Ljava/util/Locale;Z)Ljava/lang/String; -Lcom/android/internal/app/LocaleHelper;->normalizeForSearch(Ljava/lang/String;Ljava/util/Locale;)Ljava/lang/String; -Lcom/android/internal/app/LocalePicker$LocaleInfo;->getLocale()Ljava/util/Locale; -Lcom/android/internal/app/LocalePicker;->getLocales()Landroid/os/LocaleList; -Lcom/android/internal/app/LocalePicker;->updateLocale(Ljava/util/Locale;)V -Lcom/android/internal/app/LocalePicker;->updateLocales(Landroid/os/LocaleList;)V -Lcom/android/internal/app/LocaleStore$LocaleInfo;->getFullNameInUiLanguage()Ljava/lang/String; -Lcom/android/internal/app/LocaleStore$LocaleInfo;->getFullNameNative()Ljava/lang/String; -Lcom/android/internal/app/LocaleStore$LocaleInfo;->getId()Ljava/lang/String; -Lcom/android/internal/app/LocaleStore$LocaleInfo;->getLocale()Ljava/util/Locale; -Lcom/android/internal/app/LocaleStore$LocaleInfo;->getParent()Ljava/util/Locale; -Lcom/android/internal/app/LocaleStore;->fillCache(Landroid/content/Context;)V -Lcom/android/internal/app/LocaleStore;->getLevelLocales(Landroid/content/Context;Ljava/util/Set;Lcom/android/internal/app/LocaleStore$LocaleInfo;Z)Ljava/util/Set; -Lcom/android/internal/app/LocaleStore;->getLocaleInfo(Ljava/util/Locale;)Lcom/android/internal/app/LocaleStore$LocaleInfo; -Lcom/android/internal/app/NetInitiatedActivity;->handleNIVerify(Landroid/content/Intent;)V Lcom/android/internal/app/ResolverActivity;-><init>()V -Lcom/android/internal/app/ResolverActivity;->mAdapter:Lcom/android/internal/app/ResolverActivity$ResolveListAdapter; -Lcom/android/internal/app/ResolverActivity;->mPm:Landroid/content/pm/PackageManager; -Lcom/android/internal/app/ResolverActivity;->onCreate(Landroid/os/Bundle;Landroid/content/Intent;Ljava/lang/CharSequence;[Landroid/content/Intent;Ljava/util/List;Z)V -Lcom/android/internal/app/WindowDecorActionBar$TabImpl;->mCallback:Landroid/app/ActionBar$TabListener; -Lcom/android/internal/app/WindowDecorActionBar;->mTabScrollView:Lcom/android/internal/widget/ScrollingTabContainerView; -Lcom/android/internal/app/WindowDecorActionBar;->setShowHideAnimationEnabled(Z)V Lcom/android/internal/appwidget/IAppWidgetService$Stub;->asInterface(Landroid/os/IBinder;)Lcom/android/internal/appwidget/IAppWidgetService; Lcom/android/internal/appwidget/IAppWidgetService$Stub;->TRANSACTION_bindAppWidgetId:I Lcom/android/internal/backup/IBackupTransport$Stub;-><init>()V @@ -889,10 +831,6 @@ Lcom/android/internal/backup/LocalTransport;->mDataDir:Ljava/io/File; Lcom/android/internal/backup/LocalTransport;->mRestorePackage:I Lcom/android/internal/backup/LocalTransport;->mRestorePackages:[Landroid/content/pm/PackageInfo; Lcom/android/internal/content/PackageMonitor;-><init>()V -Lcom/android/internal/database/SortCursor;-><init>([Landroid/database/Cursor;Ljava/lang/String;)V -Lcom/android/internal/database/SortCursor;->mCursor:Landroid/database/Cursor; -Lcom/android/internal/database/SortCursor;->mCursors:[Landroid/database/Cursor; -Lcom/android/internal/http/HttpDateTime;->parse(Ljava/lang/String;)J Lcom/android/internal/location/GpsNetInitiatedHandler$GpsNiNotification;-><init>()V Lcom/android/internal/location/GpsNetInitiatedHandler$GpsNiNotification;->requestorId:Ljava/lang/String; Lcom/android/internal/location/GpsNetInitiatedHandler$GpsNiNotification;->requestorIdEncoding:I @@ -906,48 +844,11 @@ Lcom/android/internal/location/ILocationProvider$Stub;->asInterface(Landroid/os/ Lcom/android/internal/logging/MetricsLogger;-><init>()V Lcom/android/internal/net/LegacyVpnInfo;-><init>()V Lcom/android/internal/net/VpnConfig;-><init>()V -Lcom/android/internal/os/AndroidPrintStream;-><init>(ILjava/lang/String;)V Lcom/android/internal/os/BaseCommand;-><init>()V -Lcom/android/internal/os/BaseCommand;->mArgs:Landroid/os/ShellCommand; Lcom/android/internal/os/BatterySipper$DrainType;->values()[Lcom/android/internal/os/BatterySipper$DrainType; -Lcom/android/internal/os/BinderInternal;->getContextObject()Landroid/os/IBinder; -Lcom/android/internal/os/BinderInternal;->handleGc()V -Lcom/android/internal/os/ClassLoaderFactory;->createClassloaderNamespace(Ljava/lang/ClassLoader;ILjava/lang/String;Ljava/lang/String;ZLjava/lang/String;)Ljava/lang/String; Lcom/android/internal/os/IDropBoxManagerService$Stub;->asInterface(Landroid/os/IBinder;)Lcom/android/internal/os/IDropBoxManagerService; -Lcom/android/internal/os/ProcessCpuTracker$Stats;->name:Ljava/lang/String; -Lcom/android/internal/os/ProcessCpuTracker$Stats;->rel_stime:I -Lcom/android/internal/os/ProcessCpuTracker$Stats;->rel_uptime:J -Lcom/android/internal/os/ProcessCpuTracker$Stats;->rel_utime:I -Lcom/android/internal/os/ProcessCpuTracker;-><init>(Z)V -Lcom/android/internal/os/ProcessCpuTracker;->countWorkingStats()I -Lcom/android/internal/os/ProcessCpuTracker;->getWorkingStats(I)Lcom/android/internal/os/ProcessCpuTracker$Stats; -Lcom/android/internal/os/ProcessCpuTracker;->update()V -Lcom/android/internal/os/RuntimeInit;->commonInit()V -Lcom/android/internal/os/RuntimeInit;->getApplicationObject()Landroid/os/IBinder; -Lcom/android/internal/os/RuntimeInit;->initialized:Z -Lcom/android/internal/os/RuntimeInit;->main([Ljava/lang/String;)V -Lcom/android/internal/os/RuntimeInit;->mApplicationObject:Landroid/os/IBinder; -Lcom/android/internal/os/ZygoteConnection;->closeSocket()V -Lcom/android/internal/os/ZygoteConnection;->mSocket:Landroid/net/LocalSocket; -Lcom/android/internal/os/ZygoteConnection;->mSocketOutStream:Ljava/io/DataOutputStream; -Lcom/android/internal/os/ZygoteConnection;->peer:Landroid/net/Credentials; -Lcom/android/internal/os/ZygoteInit;->main([Ljava/lang/String;)V -Lcom/android/internal/os/ZygoteInit;->mResources:Landroid/content/res/Resources; -Lcom/android/internal/os/ZygoteSecurityException;-><init>(Ljava/lang/String;)V -Lcom/android/internal/policy/DecorView;->mLastBottomInset:I -Lcom/android/internal/policy/DecorView;->mLastLeftInset:I -Lcom/android/internal/policy/DecorView;->mLastRightInset:I -Lcom/android/internal/policy/DecorView;->mWindow:Lcom/android/internal/policy/PhoneWindow; Lcom/android/internal/policy/IKeyguardService$Stub;->asInterface(Landroid/os/IBinder;)Lcom/android/internal/policy/IKeyguardService; Lcom/android/internal/policy/IKeyguardStateCallback$Stub;->asInterface(Landroid/os/IBinder;)Lcom/android/internal/policy/IKeyguardStateCallback; -Lcom/android/internal/policy/PhoneFallbackEventHandler;-><init>(Landroid/content/Context;)V -Lcom/android/internal/policy/PhoneFallbackEventHandler;->mContext:Landroid/content/Context; -Lcom/android/internal/policy/PhoneFallbackEventHandler;->mView:Landroid/view/View; -Lcom/android/internal/policy/PhoneFallbackEventHandler;->onKeyDown(ILandroid/view/KeyEvent;)Z -Lcom/android/internal/policy/PhoneFallbackEventHandler;->onKeyUp(ILandroid/view/KeyEvent;)Z -Lcom/android/internal/policy/PhoneFallbackEventHandler;->startCallActivity()V -Lcom/android/internal/policy/PhoneWindow;-><init>(Landroid/content/Context;)V -Lcom/android/internal/policy/PhoneWindow;->mTitle:Ljava/lang/CharSequence; Lcom/android/internal/preference/YesNoPreference;-><init>(Landroid/content/Context;Landroid/util/AttributeSet;)V Lcom/android/internal/R$anim;->fade_in:I Lcom/android/internal/R$array;->config_autoBrightnessLcdBacklightValues:I @@ -1699,203 +1600,15 @@ Lcom/android/internal/telephony/uicc/IccUtils;->parseToBnW([BI)Landroid/graphics Lcom/android/internal/telephony/uicc/IccUtils;->parseToRGB([BIZ)Landroid/graphics/Bitmap; Lcom/android/internal/telephony/uicc/SIMRecords$GetSpnFsmState;->values()[Lcom/android/internal/telephony/uicc/SIMRecords$GetSpnFsmState; Lcom/android/internal/textservice/ITextServicesManager$Stub$Proxy;-><init>(Landroid/os/IBinder;)V -Lcom/android/internal/util/ArrayUtils;->appendElement(Ljava/lang/Class;[Ljava/lang/Object;Ljava/lang/Object;)[Ljava/lang/Object; -Lcom/android/internal/util/ArrayUtils;->appendInt([II)[I -Lcom/android/internal/util/ArrayUtils;->contains([II)Z -Lcom/android/internal/util/ArrayUtils;->contains([Ljava/lang/Object;Ljava/lang/Object;)Z -Lcom/android/internal/util/ArrayUtils;->emptyArray(Ljava/lang/Class;)[Ljava/lang/Object; -Lcom/android/internal/util/ArrayUtils;->indexOf([Ljava/lang/Object;Ljava/lang/Object;)I -Lcom/android/internal/util/ArrayUtils;->isEmpty([Ljava/lang/Object;)Z -Lcom/android/internal/util/ArrayUtils;->newUnpaddedArray(Ljava/lang/Class;I)[Ljava/lang/Object; -Lcom/android/internal/util/ArrayUtils;->newUnpaddedIntArray(I)[I -Lcom/android/internal/util/ArrayUtils;->removeElement(Ljava/lang/Class;[Ljava/lang/Object;Ljava/lang/Object;)[Ljava/lang/Object; -Lcom/android/internal/util/BitwiseInputStream;-><init>([B)V -Lcom/android/internal/util/BitwiseInputStream;->available()I -Lcom/android/internal/util/BitwiseInputStream;->read(I)I -Lcom/android/internal/util/BitwiseInputStream;->readByteArray(I)[B -Lcom/android/internal/util/BitwiseInputStream;->skip(I)V -Lcom/android/internal/util/BitwiseOutputStream;-><init>(I)V -Lcom/android/internal/util/BitwiseOutputStream;->toByteArray()[B -Lcom/android/internal/util/BitwiseOutputStream;->write(II)V -Lcom/android/internal/util/BitwiseOutputStream;->writeByteArray(I[B)V -Lcom/android/internal/util/CharSequences;->compareToIgnoreCase(Ljava/lang/CharSequence;Ljava/lang/CharSequence;)I -Lcom/android/internal/util/CharSequences;->equals(Ljava/lang/CharSequence;Ljava/lang/CharSequence;)Z -Lcom/android/internal/util/FastMath;->round(F)I -Lcom/android/internal/util/FastXmlSerializer;-><init>()V -Lcom/android/internal/util/GrowingArrayUtils;->append([III)[I -Lcom/android/internal/util/GrowingArrayUtils;->append([Ljava/lang/Object;ILjava/lang/Object;)[Ljava/lang/Object; -Lcom/android/internal/util/HexDump;->hexStringToByteArray(Ljava/lang/String;)[B -Lcom/android/internal/util/HexDump;->toHexString(I)Ljava/lang/String; -Lcom/android/internal/util/HexDump;->toHexString([B)Ljava/lang/String; -Lcom/android/internal/util/HexDump;->toHexString([BII)Ljava/lang/String; -Lcom/android/internal/util/HexDump;->toHexString([BZ)Ljava/lang/String; -Lcom/android/internal/util/IState;->getName()Ljava/lang/String; Lcom/android/internal/util/MemInfoReader;-><init>()V -Lcom/android/internal/util/MemInfoReader;->getCachedSize()J -Lcom/android/internal/util/MemInfoReader;->getFreeSize()J -Lcom/android/internal/util/MemInfoReader;->getRawInfo()[J -Lcom/android/internal/util/MemInfoReader;->getTotalSize()J -Lcom/android/internal/util/MemInfoReader;->readMemInfo()V -Lcom/android/internal/util/Preconditions;->checkArgument(Z)V -Lcom/android/internal/util/Preconditions;->checkArgument(ZLjava/lang/Object;)V -Lcom/android/internal/util/Preconditions;->checkArgumentInRange(IIILjava/lang/String;)I -Lcom/android/internal/util/Preconditions;->checkNotNull(Ljava/lang/Object;)Ljava/lang/Object; -Lcom/android/internal/util/Preconditions;->checkNotNull(Ljava/lang/Object;Ljava/lang/Object;)Ljava/lang/Object; -Lcom/android/internal/util/Preconditions;->checkState(Z)V -Lcom/android/internal/util/Preconditions;->checkState(ZLjava/lang/String;)V -Lcom/android/internal/util/State;-><init>()V -Lcom/android/internal/util/State;->enter()V -Lcom/android/internal/util/State;->exit()V -Lcom/android/internal/util/State;->getName()Ljava/lang/String; -Lcom/android/internal/util/State;->processMessage(Landroid/os/Message;)Z -Lcom/android/internal/util/StateMachine;-><init>(Ljava/lang/String;)V -Lcom/android/internal/util/StateMachine;-><init>(Ljava/lang/String;Landroid/os/Handler;)V -Lcom/android/internal/util/StateMachine;-><init>(Ljava/lang/String;Landroid/os/Looper;)V -Lcom/android/internal/util/StateMachine;->dump(Ljava/io/FileDescriptor;Ljava/io/PrintWriter;[Ljava/lang/String;)V -Lcom/android/internal/util/StateMachine;->obtainMessage(III)Landroid/os/Message; -Lcom/android/internal/util/StateMachine;->obtainMessage(IIILjava/lang/Object;)Landroid/os/Message; -Lcom/android/internal/util/StateMachine;->sendMessage(I)V -Lcom/android/internal/util/StateMachine;->sendMessage(II)V -Lcom/android/internal/util/StateMachine;->sendMessage(IIILjava/lang/Object;)V -Lcom/android/internal/util/StateMachine;->sendMessage(ILjava/lang/Object;)V -Lcom/android/internal/util/StateMachine;->sendMessage(Landroid/os/Message;)V -Lcom/android/internal/view/ActionBarPolicy;-><init>(Landroid/content/Context;)V -Lcom/android/internal/view/ActionBarPolicy;->get(Landroid/content/Context;)Lcom/android/internal/view/ActionBarPolicy; -Lcom/android/internal/view/ActionBarPolicy;->getEmbeddedMenuWidthLimit()I -Lcom/android/internal/view/ActionBarPolicy;->getMaxActionButtons()I -Lcom/android/internal/view/ActionBarPolicy;->getStackedTabMaxWidth()I -Lcom/android/internal/view/ActionBarPolicy;->getTabContainerHeight()I -Lcom/android/internal/view/ActionBarPolicy;->hasEmbeddedTabs()Z -Lcom/android/internal/view/ActionBarPolicy;->mContext:Landroid/content/Context; -Lcom/android/internal/view/ActionBarPolicy;->showsOverflowMenuButton()Z Lcom/android/internal/view/IInputMethodManager$Stub$Proxy;-><init>(Landroid/os/IBinder;)V Lcom/android/internal/view/IInputMethodManager$Stub;->asInterface(Landroid/os/IBinder;)Lcom/android/internal/view/IInputMethodManager; Lcom/android/internal/view/IInputMethodSession$Stub;->asInterface(Landroid/os/IBinder;)Lcom/android/internal/view/IInputMethodSession; -Lcom/android/internal/view/InputConnectionWrapper$InputContextCallback;->dispose()V -Lcom/android/internal/view/InputConnectionWrapper$InputContextCallback;->getInstance()Lcom/android/internal/view/InputConnectionWrapper$InputContextCallback; -Lcom/android/internal/view/menu/ActionMenu;-><init>(Landroid/content/Context;)V -Lcom/android/internal/view/menu/ActionMenuItem;-><init>(Landroid/content/Context;IIIILjava/lang/CharSequence;)V -Lcom/android/internal/view/menu/ContextMenuBuilder;-><init>(Landroid/content/Context;)V -Lcom/android/internal/view/menu/IconMenuItemView;->getTextAppropriateLayoutParams()Lcom/android/internal/view/menu/IconMenuView$LayoutParams; -Lcom/android/internal/view/menu/IconMenuItemView;->setIconMenuView(Lcom/android/internal/view/menu/IconMenuView;)V -Lcom/android/internal/view/menu/IconMenuItemView;->setItemInvoker(Lcom/android/internal/view/menu/MenuBuilder$ItemInvoker;)V -Lcom/android/internal/view/menu/IconMenuView$SavedState;-><init>(Landroid/os/Parcel;)V -Lcom/android/internal/view/menu/IconMenuView;->createMoreItemView()Lcom/android/internal/view/menu/IconMenuItemView; -Lcom/android/internal/view/menu/IconMenuView;->getNumActualItemsShown()I -Lcom/android/internal/view/menu/IconMenuView;->mItemBackground:Landroid/graphics/drawable/Drawable; -Lcom/android/internal/view/menu/IconMenuView;->mMaxItems:I -Lcom/android/internal/view/menu/IconMenuView;->mMenu:Lcom/android/internal/view/menu/MenuBuilder; -Lcom/android/internal/view/menu/MenuDialogHelper;-><init>(Lcom/android/internal/view/menu/MenuBuilder;)V -Lcom/android/internal/view/menu/MenuDialogHelper;->dismiss()V -Lcom/android/internal/view/menu/MenuDialogHelper;->show(Landroid/os/IBinder;)V -Lcom/android/internal/view/WindowManagerPolicyThread;->getLooper()Landroid/os/Looper; -Lcom/android/internal/widget/AbsActionBarView;->dismissPopupMenus()V -Lcom/android/internal/widget/ActionBarContextView;-><init>(Landroid/content/Context;Landroid/util/AttributeSet;)V -Lcom/android/internal/widget/ActionBarOverlayLayout;-><init>(Landroid/content/Context;Landroid/util/AttributeSet;)V -Lcom/android/internal/widget/ActionBarOverlayLayout;->setWindowCallback(Landroid/view/Window$Callback;)V -Lcom/android/internal/widget/EditableInputConnection;-><init>(Landroid/widget/TextView;)V Lcom/android/internal/widget/ILockSettings$Stub;->asInterface(Landroid/os/IBinder;)Lcom/android/internal/widget/ILockSettings; Lcom/android/internal/widget/IRemoteViewsFactory$Stub;->asInterface(Landroid/os/IBinder;)Lcom/android/internal/widget/IRemoteViewsFactory; -Lcom/android/internal/widget/LinearLayoutWithDefaultTouchRecepient;-><init>(Landroid/content/Context;)V -Lcom/android/internal/widget/LinearLayoutWithDefaultTouchRecepient;->setDefaultTouchRecepient(Landroid/view/View;)V -Lcom/android/internal/widget/LockPatternChecker;->checkPassword(Lcom/android/internal/widget/LockPatternUtils;Ljava/lang/String;ILcom/android/internal/widget/LockPatternChecker$OnCheckCallback;)Landroid/os/AsyncTask; -Lcom/android/internal/widget/LockPatternUtils$RequestThrottledException;-><init>(I)V -Lcom/android/internal/widget/LockPatternUtils$RequestThrottledException;->getTimeoutMs()I -Lcom/android/internal/widget/LockPatternUtils;-><init>(Landroid/content/Context;)V -Lcom/android/internal/widget/LockPatternUtils;->checkPassword(Ljava/lang/String;I)Z -Lcom/android/internal/widget/LockPatternUtils;->getActivePasswordQuality(I)I -Lcom/android/internal/widget/LockPatternUtils;->getDevicePolicyManager()Landroid/app/admin/DevicePolicyManager; -Lcom/android/internal/widget/LockPatternUtils;->getKeyguardStoredPasswordQuality(I)I -Lcom/android/internal/widget/LockPatternUtils;->getLockSettings()Lcom/android/internal/widget/ILockSettings; -Lcom/android/internal/widget/LockPatternUtils;->getOwnerInfo(I)Ljava/lang/String; -Lcom/android/internal/widget/LockPatternUtils;->getPowerButtonInstantlyLocks(I)Z -Lcom/android/internal/widget/LockPatternUtils;->getString(Ljava/lang/String;I)Ljava/lang/String; -Lcom/android/internal/widget/LockPatternUtils;->isDeviceEncryptionEnabled()Z -Lcom/android/internal/widget/LockPatternUtils;->isLockPasswordEnabled(I)Z -Lcom/android/internal/widget/LockPatternUtils;->isLockPatternEnabled(I)Z -Lcom/android/internal/widget/LockPatternUtils;->isLockScreenDisabled(I)Z -Lcom/android/internal/widget/LockPatternUtils;->isSecure(I)Z -Lcom/android/internal/widget/LockPatternUtils;->isTactileFeedbackEnabled()Z -Lcom/android/internal/widget/LockPatternUtils;->isVisiblePatternEnabled(I)Z -Lcom/android/internal/widget/LockPatternUtils;->mContentResolver:Landroid/content/ContentResolver; -Lcom/android/internal/widget/LockPatternUtils;->mContext:Landroid/content/Context; -Lcom/android/internal/widget/LockPatternUtils;->patternToHash(Ljava/util/List;)[B -Lcom/android/internal/widget/LockPatternUtils;->patternToString(Ljava/util/List;)Ljava/lang/String; -Lcom/android/internal/widget/LockPatternUtils;->reportFailedPasswordAttempt(I)V -Lcom/android/internal/widget/LockPatternUtils;->reportSuccessfulPasswordAttempt(I)V -Lcom/android/internal/widget/LockPatternUtils;->saveLockPassword(Ljava/lang/String;Ljava/lang/String;II)V -Lcom/android/internal/widget/LockPatternUtils;->setLockoutAttemptDeadline(II)J -Lcom/android/internal/widget/LockPatternUtils;->setLong(Ljava/lang/String;JI)V -Lcom/android/internal/widget/LockPatternUtils;->setOwnerInfo(Ljava/lang/String;I)V -Lcom/android/internal/widget/LockPatternUtils;->setOwnerInfoEnabled(ZI)V -Lcom/android/internal/widget/LockPatternUtils;->setString(Ljava/lang/String;Ljava/lang/String;I)V -Lcom/android/internal/widget/LockPatternView$Cell;->column:I -Lcom/android/internal/widget/LockPatternView$Cell;->row:I -Lcom/android/internal/widget/LockPatternView$DisplayMode;->Animate:Lcom/android/internal/widget/LockPatternView$DisplayMode; -Lcom/android/internal/widget/LockPatternView$DisplayMode;->Correct:Lcom/android/internal/widget/LockPatternView$DisplayMode; -Lcom/android/internal/widget/LockPatternView$DisplayMode;->Wrong:Lcom/android/internal/widget/LockPatternView$DisplayMode; -Lcom/android/internal/widget/LockPatternView$SavedState;-><init>(Landroid/os/Parcel;)V -Lcom/android/internal/widget/LockPatternView$SavedState;-><init>(Landroid/os/Parcelable;Ljava/lang/String;IZZZ)V -Lcom/android/internal/widget/LockPatternView;-><init>(Landroid/content/Context;Landroid/util/AttributeSet;)V -Lcom/android/internal/widget/LockPatternView;->clearPattern()V -Lcom/android/internal/widget/LockPatternView;->disableInput()V -Lcom/android/internal/widget/LockPatternView;->enableInput()V -Lcom/android/internal/widget/LockPatternView;->getCellStates()[[Lcom/android/internal/widget/LockPatternView$CellState; -Lcom/android/internal/widget/LockPatternView;->mInStealthMode:Z -Lcom/android/internal/widget/LockPatternView;->mPaint:Landroid/graphics/Paint; -Lcom/android/internal/widget/LockPatternView;->mPathPaint:Landroid/graphics/Paint; -Lcom/android/internal/widget/LockPatternView;->mPattern:Ljava/util/ArrayList; -Lcom/android/internal/widget/LockPatternView;->mPatternDisplayMode:Lcom/android/internal/widget/LockPatternView$DisplayMode; -Lcom/android/internal/widget/LockPatternView;->mPatternInProgress:Z -Lcom/android/internal/widget/LockPatternView;->mSquareHeight:F -Lcom/android/internal/widget/LockPatternView;->mSquareWidth:F -Lcom/android/internal/widget/LockPatternView;->notifyPatternDetected()V -Lcom/android/internal/widget/LockPatternView;->setDisplayMode(Lcom/android/internal/widget/LockPatternView$DisplayMode;)V -Lcom/android/internal/widget/LockPatternView;->setInStealthMode(Z)V -Lcom/android/internal/widget/LockPatternView;->setOnPatternListener(Lcom/android/internal/widget/LockPatternView$OnPatternListener;)V -Lcom/android/internal/widget/LockPatternView;->setTactileFeedbackEnabled(Z)V Lcom/android/internal/widget/PointerLocationView$PointerState;-><init>()V -Lcom/android/internal/widget/PointerLocationView$PointerState;->mCurDown:Z -Lcom/android/internal/widget/PointerLocationView;->mCurDown:Z -Lcom/android/internal/widget/PointerLocationView;->mCurNumPointers:I -Lcom/android/internal/widget/PointerLocationView;->mMaxNumPointers:I -Lcom/android/internal/widget/PointerLocationView;->mPointers:Ljava/util/ArrayList; -Lcom/android/internal/widget/PointerLocationView;->mPrintCoords:Z -Lcom/android/internal/widget/PreferenceImageView;-><init>(Landroid/content/Context;Landroid/util/AttributeSet;)V -Lcom/android/internal/widget/RecyclerView$RecycledViewPool$ScrapData;->mScrapHeap:Ljava/util/ArrayList; -Lcom/android/internal/widget/ScrollBarUtils;->getThumbLength(IIII)I -Lcom/android/internal/widget/SlidingTab$Slider;->tab:Landroid/widget/ImageView; -Lcom/android/internal/widget/SlidingTab$Slider;->text:Landroid/widget/TextView; -Lcom/android/internal/widget/SlidingTab;->mAnimationDoneListener:Landroid/view/animation/Animation$AnimationListener; -Lcom/android/internal/widget/SlidingTab;->mLeftSlider:Lcom/android/internal/widget/SlidingTab$Slider; -Lcom/android/internal/widget/SlidingTab;->mRightSlider:Lcom/android/internal/widget/SlidingTab$Slider; -Lcom/android/internal/widget/SlidingTab;->onAnimationDone()V -Lcom/android/internal/widget/SlidingTab;->resetView()V -Lcom/android/internal/widget/SlidingTab;->setHoldAfterTrigger(ZZ)V -Lcom/android/internal/widget/SlidingTab;->setLeftHintText(I)V -Lcom/android/internal/widget/SlidingTab;->setLeftTabResources(IIII)V -Lcom/android/internal/widget/SlidingTab;->setOnTriggerListener(Lcom/android/internal/widget/SlidingTab$OnTriggerListener;)V -Lcom/android/internal/widget/SlidingTab;->setRightHintText(I)V -Lcom/android/internal/widget/SlidingTab;->setRightTabResources(IIII)V -Lcom/android/internal/widget/TextViewInputDisabler;-><init>(Landroid/widget/TextView;)V -Lcom/android/internal/widget/TextViewInputDisabler;->setInputEnabled(Z)V -Lcom/android/internal/widget/ViewPager$OnPageChangeListener;->onPageScrolled(IFI)V -Lcom/android/internal/widget/ViewPager$OnPageChangeListener;->onPageScrollStateChanged(I)V -Lcom/android/internal/widget/ViewPager$OnPageChangeListener;->onPageSelected(I)V -Lcom/android/internal/widget/ViewPager;->getCurrentItem()I Lcom/android/server/net/BaseNetworkObserver;-><init>()V -Lcom/android/server/net/NetlinkTracker;-><init>(Ljava/lang/String;Lcom/android/server/net/NetlinkTracker$Callback;)V -Lcom/android/server/net/NetlinkTracker;->clearLinkProperties()V -Lcom/android/server/net/NetlinkTracker;->getLinkProperties()Landroid/net/LinkProperties; Lcom/android/server/ResettableTimeout$T;-><init>(Lcom/android/server/ResettableTimeout;)V -Lcom/android/server/ResettableTimeout;->mLock:Landroid/os/ConditionVariable; -Lcom/android/server/ResettableTimeout;->mOffAt:J -Lcom/google/android/collect/Lists;->newArrayList([Ljava/lang/Object;)Ljava/util/ArrayList; -Lcom/google/android/collect/Sets;->newArraySet()Landroid/util/ArraySet; -Lcom/google/android/collect/Sets;->newArraySet([Ljava/lang/Object;)Landroid/util/ArraySet; -Lcom/google/android/collect/Sets;->newHashSet()Ljava/util/HashSet; -Lcom/google/android/collect/Sets;->newHashSet([Ljava/lang/Object;)Ljava/util/HashSet; -Lcom/google/android/collect/Sets;->newSortedSet()Ljava/util/SortedSet; Lcom/google/android/gles_jni/EGLImpl;-><init>()V Lcom/google/android/gles_jni/GLImpl;-><init>()V Lcom/google/android/mms/ContentType;->getAudioTypes()Ljava/util/ArrayList; @@ -2178,17 +1891,7 @@ Lcom/google/android/mms/util/SqliteWrapper;->insert(Landroid/content/Context;Lan Lcom/google/android/mms/util/SqliteWrapper;->query(Landroid/content/Context;Landroid/content/ContentResolver;Landroid/net/Uri;[Ljava/lang/String;Ljava/lang/String;[Ljava/lang/String;Ljava/lang/String;)Landroid/database/Cursor; Lcom/google/android/mms/util/SqliteWrapper;->requery(Landroid/content/Context;Landroid/database/Cursor;)Z Lcom/google/android/mms/util/SqliteWrapper;->update(Landroid/content/Context;Landroid/content/ContentResolver;Landroid/net/Uri;Landroid/content/ContentValues;Ljava/lang/String;[Ljava/lang/String;)I -Lcom/google/android/util/AbstractMessageParser$Token$Type;->ACRONYM:Lcom/google/android/util/AbstractMessageParser$Token$Type; -Lcom/google/android/util/AbstractMessageParser$Token$Type;->FLICKR:Lcom/google/android/util/AbstractMessageParser$Token$Type; -Lcom/google/android/util/AbstractMessageParser$Token$Type;->FORMAT:Lcom/google/android/util/AbstractMessageParser$Token$Type; -Lcom/google/android/util/AbstractMessageParser$Token$Type;->GOOGLE_VIDEO:Lcom/google/android/util/AbstractMessageParser$Token$Type; -Lcom/google/android/util/AbstractMessageParser$Token$Type;->HTML:Lcom/google/android/util/AbstractMessageParser$Token$Type; -Lcom/google/android/util/AbstractMessageParser$Token$Type;->LINK:Lcom/google/android/util/AbstractMessageParser$Token$Type; -Lcom/google/android/util/AbstractMessageParser$Token$Type;->MUSIC:Lcom/google/android/util/AbstractMessageParser$Token$Type; -Lcom/google/android/util/AbstractMessageParser$Token$Type;->PHOTO:Lcom/google/android/util/AbstractMessageParser$Token$Type; -Lcom/google/android/util/AbstractMessageParser$Token$Type;->SMILEY:Lcom/google/android/util/AbstractMessageParser$Token$Type; Lcom/google/android/util/AbstractMessageParser$Token$Type;->values()[Lcom/google/android/util/AbstractMessageParser$Token$Type; -Lcom/google/android/util/AbstractMessageParser$Token$Type;->YOUTUBE_VIDEO:Lcom/google/android/util/AbstractMessageParser$Token$Type; Lgov/nist/core/Debug;->printStackTrace(Ljava/lang/Exception;)V Lgov/nist/core/GenericObject;-><init>()V Lgov/nist/core/GenericObject;->dbgPrint()V diff --git a/core/java/android/companion/IFindDeviceCallback.aidl b/core/java/android/companion/IFindDeviceCallback.aidl index 919e15198efa..4e9fa19e5ce5 100644 --- a/core/java/android/companion/IFindDeviceCallback.aidl +++ b/core/java/android/companion/IFindDeviceCallback.aidl @@ -20,6 +20,7 @@ import android.app.PendingIntent; /** @hide */ interface IFindDeviceCallback { + @UnsupportedAppUsage void onSuccess(in PendingIntent launcher); void onFailure(in CharSequence reason); } diff --git a/core/java/android/content/Context.java b/core/java/android/content/Context.java index 8625a04963a7..9223f71b4428 100644 --- a/core/java/android/content/Context.java +++ b/core/java/android/content/Context.java @@ -1711,7 +1711,8 @@ public abstract class Context { */ @RequiresPermission(android.Manifest.permission.INTERACT_ACROSS_USERS_FULL) @SystemApi - public void startActivityAsUser(@RequiresPermission Intent intent, UserHandle user) { + public void startActivityAsUser(@RequiresPermission @NonNull Intent intent, + @NonNull UserHandle user) { throw new RuntimeException("Not implemented. Must override in a subclass."); } diff --git a/core/java/android/content/pm/SharedLibraryInfo.java b/core/java/android/content/pm/SharedLibraryInfo.java index ad82626dd6ad..8354296b68d7 100644 --- a/core/java/android/content/pm/SharedLibraryInfo.java +++ b/core/java/android/content/pm/SharedLibraryInfo.java @@ -289,9 +289,9 @@ public final class SharedLibraryInfo implements Parcelable { @Override public String toString() { - return "SharedLibraryInfo[name:" + mName + ", type:" + typeToString(mType) + return "SharedLibraryInfo{name:" + mName + ", type:" + typeToString(mType) + ", version:" + mVersion + (!getDependentPackages().isEmpty() - ? " has dependents" : ""); + ? " has dependents" : "") + "}"; } @Override diff --git a/core/java/android/hardware/camera2/utils/HashCodeHelpers.java b/core/java/android/hardware/camera2/utils/HashCodeHelpers.java index 731da8b6a721..526f086f4baa 100644 --- a/core/java/android/hardware/camera2/utils/HashCodeHelpers.java +++ b/core/java/android/hardware/camera2/utils/HashCodeHelpers.java @@ -16,6 +16,8 @@ package android.hardware.camera2.utils; +import android.annotation.UnsupportedAppUsage; + /** * Provide hashing functions using the Modified Bernstein hash */ @@ -30,6 +32,7 @@ public final class HashCodeHelpers { * * @return the numeric hash code */ + @UnsupportedAppUsage public static int hashCode(int... array) { if (array == null) { return 0; diff --git a/core/java/android/inputmethodservice/IInputMethodSessionWrapper.java b/core/java/android/inputmethodservice/IInputMethodSessionWrapper.java index d2e3510ee3b1..40362e24ad1b 100644 --- a/core/java/android/inputmethodservice/IInputMethodSessionWrapper.java +++ b/core/java/android/inputmethodservice/IInputMethodSessionWrapper.java @@ -16,6 +16,7 @@ package android.inputmethodservice; +import android.annotation.UnsupportedAppUsage; import android.content.Context; import android.graphics.Rect; import android.os.Bundle; @@ -53,6 +54,7 @@ class IInputMethodSessionWrapper extends IInputMethodSession.Stub private static final int DO_FINISH_SESSION = 110; private static final int DO_VIEW_CLICKED = 115; + @UnsupportedAppUsage HandlerCaller mCaller; InputMethodSession mInputMethodSession; InputChannel mChannel; diff --git a/core/java/android/inputmethodservice/IInputMethodWrapper.java b/core/java/android/inputmethodservice/IInputMethodWrapper.java index 2c7e51a1db25..7b6c0fff4e7c 100644 --- a/core/java/android/inputmethodservice/IInputMethodWrapper.java +++ b/core/java/android/inputmethodservice/IInputMethodWrapper.java @@ -18,6 +18,7 @@ package android.inputmethodservice; import android.annotation.BinderThread; import android.annotation.MainThread; +import android.annotation.UnsupportedAppUsage; import android.content.Context; import android.content.pm.PackageManager; import android.os.Binder; @@ -73,6 +74,7 @@ class IInputMethodWrapper extends IInputMethod.Stub final WeakReference<AbstractInputMethodService> mTarget; final Context mContext; + @UnsupportedAppUsage final HandlerCaller mCaller; final WeakReference<InputMethod> mInputMethod; final int mTargetSdkVersion; diff --git a/core/java/android/net/CaptivePortal.java b/core/java/android/net/CaptivePortal.java index 3ab35e1eebf0..db1951520a26 100644 --- a/core/java/android/net/CaptivePortal.java +++ b/core/java/android/net/CaptivePortal.java @@ -15,6 +15,7 @@ */ package android.net; +import android.annotation.NonNull; import android.annotation.SystemApi; import android.annotation.TestApi; import android.os.IBinder; @@ -29,15 +30,33 @@ import android.os.RemoteException; * {@code ACTION_CAPTIVE_PORTAL_SIGN_IN} activity. */ public class CaptivePortal implements Parcelable { - /** @hide */ + /** + * Response code from the captive portal application, indicating that the portal was dismissed + * and the network should be re-validated. + * @see ICaptivePortal#appResponse(int) + * @see android.net.INetworkMonitor#notifyCaptivePortalAppFinished(int) + * @hide + */ @SystemApi @TestApi public static final int APP_RETURN_DISMISSED = 0; - /** @hide */ + /** + * Response code from the captive portal application, indicating that the user did not login and + * does not want to use the captive portal network. + * @see ICaptivePortal#appResponse(int) + * @see android.net.INetworkMonitor#notifyCaptivePortalAppFinished(int) + * @hide + */ @SystemApi @TestApi public static final int APP_RETURN_UNWANTED = 1; - /** @hide */ + /** + * Response code from the captive portal application, indicating that the user does not wish to + * login but wants to use the captive portal network as-is. + * @see ICaptivePortal#appResponse(int) + * @see android.net.INetworkMonitor#notifyCaptivePortalAppFinished(int) + * @hide + */ @SystemApi @TestApi public static final int APP_RETURN_WANTED_AS_IS = 2; @@ -45,9 +64,7 @@ public class CaptivePortal implements Parcelable { private final IBinder mBinder; /** @hide */ - @SystemApi - @TestApi - public CaptivePortal(IBinder binder) { + public CaptivePortal(@NonNull IBinder binder) { mBinder = binder; } @@ -124,7 +141,7 @@ public class CaptivePortal implements Parcelable { */ @SystemApi @TestApi - public void logEvent(int eventId, String packageName) { + public void logEvent(int eventId, @NonNull String packageName) { try { ICaptivePortal.Stub.asInterface(mBinder).logEvent(eventId, packageName); } catch (RemoteException e) { diff --git a/core/java/android/net/ConnectivityManager.java b/core/java/android/net/ConnectivityManager.java index e5802c23eb6f..ae93cf019776 100644 --- a/core/java/android/net/ConnectivityManager.java +++ b/core/java/android/net/ConnectivityManager.java @@ -44,6 +44,7 @@ import android.os.INetworkManagementService; import android.os.Looper; import android.os.Message; import android.os.Messenger; +import android.os.ParcelFileDescriptor; import android.os.Process; import android.os.RemoteException; import android.os.ResultReceiver; @@ -64,6 +65,8 @@ import com.android.internal.util.Protocol; import libcore.net.event.NetworkEventDispatcher; import java.io.FileDescriptor; +import java.io.IOException; +import java.io.UncheckedIOException; import java.lang.annotation.Retention; import java.lang.annotation.RetentionPolicy; import java.net.InetAddress; @@ -1345,12 +1348,15 @@ public class ConnectivityManager { } /** - * Gets the URL that should be used for resolving whether a captive portal is present. + * Gets a URL that can be used for resolving whether a captive portal is present. * 1. This URL should respond with a 204 response to a GET request to indicate no captive * portal is present. * 2. This URL must be HTTP as redirect responses are used to find captive portal * sign-in pages. Captive portals cannot respond to HTTPS requests with redirects. * + * The system network validation may be using different strategies to detect captive portals, + * so this method does not necessarily return a URL used by the system. It only returns a URL + * that may be relevant for other components trying to detect captive portals. * @hide */ @SystemApi @@ -1920,14 +1926,22 @@ public class ConnectivityManager { * @return A {@link SocketKeepalive} object that can be used to control the keepalive on the * given socket. **/ - public SocketKeepalive createSocketKeepalive(@NonNull Network network, + public @NonNull SocketKeepalive createSocketKeepalive(@NonNull Network network, @NonNull UdpEncapsulationSocket socket, @NonNull InetAddress source, @NonNull InetAddress destination, @NonNull @CallbackExecutor Executor executor, @NonNull Callback callback) { - return new NattSocketKeepalive(mService, network, socket.getFileDescriptor(), - socket.getResourceId(), source, destination, executor, callback); + ParcelFileDescriptor dup; + try { + dup = ParcelFileDescriptor.dup(socket.getFileDescriptor()); + } catch (IOException ignored) { + // Construct an invalid fd, so that if the user later calls start(), it will fail with + // ERROR_INVALID_SOCKET. + dup = new ParcelFileDescriptor(new FileDescriptor()); + } + return new NattSocketKeepalive(mService, network, dup, socket.getResourceId(), source, + destination, executor, callback); } /** @@ -1935,9 +1949,9 @@ public class ConnectivityManager { * by system apps which don't use IpSecService to create {@link UdpEncapsulationSocket}. * * @param network The {@link Network} the socket is on. - * @param fd The {@link FileDescriptor} that needs to be kept alive. The provided - * {@link FileDescriptor} must be bound to a port and the keepalives will be sent from - * that port. + * @param pfd The {@link ParcelFileDescriptor} that needs to be kept alive. The provided + * {@link ParcelFileDescriptor} must be bound to a port and the keepalives will be sent + * from that port. * @param source The source address of the {@link UdpEncapsulationSocket}. * @param destination The destination address of the {@link UdpEncapsulationSocket}. The * keepalive packets will always be sent to port 4500 of the given {@code destination}. @@ -1953,14 +1967,22 @@ public class ConnectivityManager { */ @SystemApi @RequiresPermission(android.Manifest.permission.PACKET_KEEPALIVE_OFFLOAD) - public SocketKeepalive createNattKeepalive(@NonNull Network network, - @NonNull FileDescriptor fd, + public @NonNull SocketKeepalive createNattKeepalive(@NonNull Network network, + @NonNull ParcelFileDescriptor pfd, @NonNull InetAddress source, @NonNull InetAddress destination, @NonNull @CallbackExecutor Executor executor, @NonNull Callback callback) { - return new NattSocketKeepalive(mService, network, fd, INVALID_RESOURCE_ID /* Unused */, - source, destination, executor, callback); + ParcelFileDescriptor dup; + try { + dup = pfd.dup(); + } catch (IOException ignored) { + // Construct an invalid fd, so that if the user later calls start(), it will fail with + // ERROR_INVALID_SOCKET. + dup = new ParcelFileDescriptor(new FileDescriptor()); + } + return new NattSocketKeepalive(mService, network, dup, + INVALID_RESOURCE_ID /* Unused */, source, destination, executor, callback); } /** @@ -1984,11 +2006,19 @@ public class ConnectivityManager { */ @SystemApi @RequiresPermission(android.Manifest.permission.PACKET_KEEPALIVE_OFFLOAD) - public SocketKeepalive createSocketKeepalive(@NonNull Network network, + public @NonNull SocketKeepalive createSocketKeepalive(@NonNull Network network, @NonNull Socket socket, @NonNull Executor executor, @NonNull Callback callback) { - return new TcpSocketKeepalive(mService, network, socket, executor, callback); + ParcelFileDescriptor dup; + try { + dup = ParcelFileDescriptor.fromSocket(socket); + } catch (UncheckedIOException ignored) { + // Construct an invalid fd, so that if the user later calls start(), it will fail with + // ERROR_INVALID_SOCKET. + dup = new ParcelFileDescriptor(new FileDescriptor()); + } + return new TcpSocketKeepalive(mService, network, dup, executor, callback); } /** @@ -3320,7 +3350,7 @@ public class ConnectivityManager { * @param network The {@link Network} whose blocked status has changed. * @param blocked The blocked status of this {@link Network}. */ - public void onBlockedStatusChanged(Network network, boolean blocked) {} + public void onBlockedStatusChanged(@NonNull Network network, boolean blocked) {} private NetworkRequest networkRequest; } @@ -4088,7 +4118,7 @@ public class ConnectivityManager { @SystemApi @TestApi @RequiresPermission(NetworkStack.PERMISSION_MAINLINE_NETWORK_STACK) - public void startCaptivePortalApp(Network network, Bundle appExtras) { + public void startCaptivePortalApp(@NonNull Network network, @NonNull Bundle appExtras) { try { mService.startCaptivePortalAppInternal(network, appExtras); } catch (RemoteException e) { @@ -4101,9 +4131,12 @@ public class ConnectivityManager { * @hide */ @SystemApi - public boolean getAvoidBadWifi() { + @RequiresPermission(anyOf = { + NetworkStack.PERMISSION_MAINLINE_NETWORK_STACK, + android.Manifest.permission.NETWORK_STACK}) + public boolean shouldAvoidBadWifi() { try { - return mService.getAvoidBadWifi(); + return mService.shouldAvoidBadWifi(); } catch (RemoteException e) { throw e.rethrowFromSystemServer(); } diff --git a/core/java/android/net/DnsResolver.java b/core/java/android/net/DnsResolver.java index 93b8cf801d45..59802514c7a3 100644 --- a/core/java/android/net/DnsResolver.java +++ b/core/java/android/net/DnsResolver.java @@ -16,6 +16,7 @@ package android.net; +import static android.net.NetworkUtils.resNetworkCancel; import static android.net.NetworkUtils.resNetworkQuery; import static android.net.NetworkUtils.resNetworkResult; import static android.net.NetworkUtils.resNetworkSend; @@ -26,6 +27,7 @@ import android.annotation.CallbackExecutor; import android.annotation.IntDef; import android.annotation.NonNull; import android.annotation.Nullable; +import android.os.CancellationSignal; import android.os.Looper; import android.system.ErrnoException; import android.util.Log; @@ -191,11 +193,18 @@ public final class DnsResolver { * @param query blob message * @param flags flags as a combination of the FLAGS_* constants * @param executor The {@link Executor} that the callback should be executed on. + * @param cancellationSignal used by the caller to signal if the query should be + * cancelled. May be {@code null}. * @param callback an {@link AnswerCallback} which will be called to notify the caller - * of the result of dns query. + * of the result of dns query. */ public <T> void query(@Nullable Network network, @NonNull byte[] query, @QueryFlag int flags, - @NonNull @CallbackExecutor Executor executor, @NonNull AnswerCallback<T> callback) { + @NonNull @CallbackExecutor Executor executor, + @Nullable CancellationSignal cancellationSignal, + @NonNull AnswerCallback<T> callback) { + if (cancellationSignal != null && cancellationSignal.isCanceled()) { + return; + } final FileDescriptor queryfd; try { queryfd = resNetworkSend((network != null @@ -205,6 +214,7 @@ public final class DnsResolver { return; } + maybeAddCancellationSignal(cancellationSignal, queryfd); registerFDListener(executor, queryfd, callback); } @@ -219,12 +229,19 @@ public final class DnsResolver { * @param nsType dns resource record (RR) type as one of the TYPE_* constants * @param flags flags as a combination of the FLAGS_* constants * @param executor The {@link Executor} that the callback should be executed on. + * @param cancellationSignal used by the caller to signal if the query should be + * cancelled. May be {@code null}. * @param callback an {@link AnswerCallback} which will be called to notify the caller - * of the result of dns query. + * of the result of dns query. */ public <T> void query(@Nullable Network network, @NonNull String domain, @QueryClass int nsClass, @QueryType int nsType, @QueryFlag int flags, - @NonNull @CallbackExecutor Executor executor, @NonNull AnswerCallback<T> callback) { + @NonNull @CallbackExecutor Executor executor, + @Nullable CancellationSignal cancellationSignal, + @NonNull AnswerCallback<T> callback) { + if (cancellationSignal != null && cancellationSignal.isCanceled()) { + return; + } final FileDescriptor queryfd; try { queryfd = resNetworkQuery((network != null @@ -233,6 +250,8 @@ public final class DnsResolver { callback.onQueryException(e); return; } + + maybeAddCancellationSignal(cancellationSignal, queryfd); registerFDListener(executor, queryfd, callback); } @@ -264,6 +283,17 @@ public final class DnsResolver { }); } + private void maybeAddCancellationSignal(@Nullable CancellationSignal cancellationSignal, + @NonNull FileDescriptor queryfd) { + if (cancellationSignal == null) return; + cancellationSignal.setOnCancelListener( + () -> { + Looper.getMainLooper().getQueue() + .removeOnFileDescriptorEventListener(queryfd); + resNetworkCancel(queryfd); + }); + } + private static class DnsAddressAnswer extends DnsPacket { private static final String TAG = "DnsResolver.DnsAddressAnswer"; private static final boolean DBG = false; diff --git a/core/java/android/net/IConnectivityManager.aidl b/core/java/android/net/IConnectivityManager.aidl index 24e6a855ffe8..61648dc7f1d8 100644 --- a/core/java/android/net/IConnectivityManager.aidl +++ b/core/java/android/net/IConnectivityManager.aidl @@ -182,7 +182,7 @@ interface IConnectivityManager void startCaptivePortalApp(in Network network); void startCaptivePortalAppInternal(in Network network, in Bundle appExtras); - boolean getAvoidBadWifi(); + boolean shouldAvoidBadWifi(); int getMultipathPreference(in Network Network); NetworkRequest getDefaultRequest(); diff --git a/core/java/android/net/InterfaceConfiguration.java b/core/java/android/net/InterfaceConfiguration.java index b9d49c14f6c6..61bc19f82d82 100644 --- a/core/java/android/net/InterfaceConfiguration.java +++ b/core/java/android/net/InterfaceConfiguration.java @@ -19,11 +19,9 @@ package android.net; import android.annotation.UnsupportedAppUsage; import android.os.Parcel; import android.os.Parcelable; -import android.text.TextUtils; import com.google.android.collect.Sets; -import java.net.InetAddress; import java.util.HashSet; /** @@ -117,40 +115,6 @@ public class InterfaceConfiguration implements Parcelable { } /** - * Construct InterfaceConfiguration from InterfaceConfigurationParcel. - */ - public static InterfaceConfiguration fromParcel(InterfaceConfigurationParcel p) { - InterfaceConfiguration cfg = new InterfaceConfiguration(); - cfg.setHardwareAddress(p.hwAddr); - - final InetAddress addr = NetworkUtils.numericToInetAddress(p.ipv4Addr); - cfg.setLinkAddress(new LinkAddress(addr, p.prefixLength)); - for (String flag : p.flags) { - cfg.setFlag(flag); - } - - return cfg; - } - - /** - * Convert InterfaceConfiguration to InterfaceConfigurationParcel with given ifname. - */ - public InterfaceConfigurationParcel toParcel(String iface) { - InterfaceConfigurationParcel cfgParcel = new InterfaceConfigurationParcel(); - cfgParcel.ifName = iface; - if (!TextUtils.isEmpty(mHwAddr)) { - cfgParcel.hwAddr = mHwAddr; - } else { - cfgParcel.hwAddr = ""; - } - cfgParcel.ipv4Addr = mAddr.getAddress().getHostAddress(); - cfgParcel.prefixLength = mAddr.getPrefixLength(); - cfgParcel.flags = mFlags.toArray(EMPTY_STRING_ARRAY); - - return cfgParcel; - } - - /** * This function determines if the interface is up and has a valid IP * configuration (IP address has a non zero octet). * diff --git a/core/java/android/net/IpPrefix.java b/core/java/android/net/IpPrefix.java index 175263f0adaa..b4f3a288d21f 100644 --- a/core/java/android/net/IpPrefix.java +++ b/core/java/android/net/IpPrefix.java @@ -16,6 +16,7 @@ package android.net; +import android.annotation.NonNull; import android.annotation.SystemApi; import android.annotation.TestApi; import android.os.Parcel; @@ -70,7 +71,7 @@ public final class IpPrefix implements Parcelable { * * @hide */ - public IpPrefix(byte[] address, int prefixLength) { + public IpPrefix(@NonNull byte[] address, int prefixLength) { this.address = address.clone(); this.prefixLength = prefixLength; checkAndMaskAddressAndPrefixLength(); @@ -87,7 +88,7 @@ public final class IpPrefix implements Parcelable { */ @SystemApi @TestApi - public IpPrefix(InetAddress address, int prefixLength) { + public IpPrefix(@NonNull InetAddress address, int prefixLength) { // We don't reuse the (byte[], int) constructor because it calls clone() on the byte array, // which is unnecessary because getAddress() already returns a clone. this.address = address.getAddress(); @@ -106,7 +107,7 @@ public final class IpPrefix implements Parcelable { */ @SystemApi @TestApi - public IpPrefix(String prefix) { + public IpPrefix(@NonNull String prefix) { // We don't reuse the (InetAddress, int) constructor because "error: call to this must be // first statement in constructor". We could factor out setting the member variables to an // init() method, but if we did, then we'd have to make the members non-final, or "error: diff --git a/core/java/android/net/LinkAddress.java b/core/java/android/net/LinkAddress.java index 8b0196088021..78b4665d4545 100644 --- a/core/java/android/net/LinkAddress.java +++ b/core/java/android/net/LinkAddress.java @@ -26,6 +26,7 @@ import static android.system.OsConstants.RT_SCOPE_SITE; import static android.system.OsConstants.RT_SCOPE_UNIVERSE; import android.annotation.NonNull; +import android.annotation.Nullable; import android.annotation.SystemApi; import android.annotation.TestApi; import android.annotation.UnsupportedAppUsage; @@ -107,8 +108,8 @@ public class LinkAddress implements Parcelable { * * Per RFC 4193 section 8, fc00::/7 identifies these addresses. */ - private boolean isIPv6ULA() { - if (isIPv6()) { + private boolean isIpv6ULA() { + if (isIpv6()) { byte[] bytes = address.getAddress(); return ((bytes[0] & (byte)0xfe) == (byte)0xfc); } @@ -121,17 +122,29 @@ public class LinkAddress implements Parcelable { */ @TestApi @SystemApi - public boolean isIPv6() { + public boolean isIpv6() { return address instanceof Inet6Address; } /** + * For backward compatibility. + * This was annotated with @UnsupportedAppUsage in P, so we can't remove the method completely + * just yet. + * @return true if the address is IPv6. + * @hide + */ + @UnsupportedAppUsage(maxTargetSdk = Build.VERSION_CODES.P) + public boolean isIPv6() { + return isIpv6(); + } + + /** * @return true if the address is IPv4 or is a mapped IPv4 address. * @hide */ @TestApi @SystemApi - public boolean isIPv4() { + public boolean isIpv4() { return address instanceof Inet4Address; } @@ -217,7 +230,7 @@ public class LinkAddress implements Parcelable { */ @SystemApi @TestApi - public LinkAddress(String address, int flags, int scope) { + public LinkAddress(@NonNull String address, int flags, int scope) { // This may throw an IllegalArgumentException; catching it is the caller's responsibility. // TODO: consider rejecting mapped IPv4 addresses such as "::ffff:192.0.2.5/24". Pair<InetAddress, Integer> ipAndMask = NetworkUtils.parseIpAndMask(address); @@ -276,7 +289,10 @@ public class LinkAddress implements Parcelable { */ @TestApi @SystemApi - public boolean isSameAddressAs(LinkAddress other) { + public boolean isSameAddressAs(@Nullable LinkAddress other) { + if (other == null) { + return false; + } return address.equals(other.address) && prefixLength == other.prefixLength; } @@ -331,10 +347,10 @@ public class LinkAddress implements Parcelable { * state has cleared either DAD has succeeded or failed, and both * flags are cleared regardless). */ - return (scope == RT_SCOPE_UNIVERSE && - !isIPv6ULA() && - (flags & (IFA_F_DADFAILED | IFA_F_DEPRECATED)) == 0L && - ((flags & IFA_F_TENTATIVE) == 0L || (flags & IFA_F_OPTIMISTIC) != 0L)); + return (scope == RT_SCOPE_UNIVERSE + && !isIpv6ULA() + && (flags & (IFA_F_DADFAILED | IFA_F_DEPRECATED)) == 0L + && ((flags & IFA_F_TENTATIVE) == 0L || (flags & IFA_F_OPTIMISTIC) != 0L)); } /** diff --git a/core/java/android/net/LinkProperties.java b/core/java/android/net/LinkProperties.java index 42db0fd7cb8c..03d6d48bc8f6 100644 --- a/core/java/android/net/LinkProperties.java +++ b/core/java/android/net/LinkProperties.java @@ -54,11 +54,11 @@ public final class LinkProperties implements Parcelable { // The interface described by the network link. @UnsupportedAppUsage(maxTargetSdk = Build.VERSION_CODES.P, trackingBug = 115609023) private String mIfaceName; - private ArrayList<LinkAddress> mLinkAddresses = new ArrayList<>(); - private ArrayList<InetAddress> mDnses = new ArrayList<>(); + private final ArrayList<LinkAddress> mLinkAddresses = new ArrayList<>(); + private final ArrayList<InetAddress> mDnses = new ArrayList<>(); // PCSCF addresses are addresses of SIP proxies that only exist for the IMS core service. - private ArrayList<InetAddress> mPcscfs = new ArrayList<InetAddress>(); - private ArrayList<InetAddress> mValidatedPrivateDnses = new ArrayList<>(); + private final ArrayList<InetAddress> mPcscfs = new ArrayList<InetAddress>(); + private final ArrayList<InetAddress> mValidatedPrivateDnses = new ArrayList<>(); private boolean mUsePrivateDns; private String mPrivateDnsServerName; private String mDomains; @@ -150,8 +150,8 @@ public final class LinkProperties implements Parcelable { // connections getting stuck until timeouts fire and other // baffling failures. Therefore, loss of either IPv4 or IPv6 on a // previously dual-stack network is deemed a lost of provisioning. - if ((before.isIPv4Provisioned() && !after.isIPv4Provisioned()) || - (before.isIPv6Provisioned() && !after.isIPv6Provisioned())) { + if ((before.isIpv4Provisioned() && !after.isIpv4Provisioned()) + || (before.isIpv6Provisioned() && !after.isIpv6Provisioned())) { return ProvisioningChange.LOST_PROVISIONING; } return ProvisioningChange.STILL_PROVISIONED; @@ -165,9 +165,8 @@ public final class LinkProperties implements Parcelable { } /** - * @hide + * Constructs a new {@code LinkProperties} with default values. */ - @SystemApi public LinkProperties() { } @@ -176,7 +175,7 @@ public final class LinkProperties implements Parcelable { */ @SystemApi @TestApi - public LinkProperties(LinkProperties source) { + public LinkProperties(@Nullable LinkProperties source) { if (source != null) { mIfaceName = source.mIfaceName; mLinkAddresses.addAll(source.mLinkAddresses); @@ -202,10 +201,8 @@ public final class LinkProperties implements Parcelable { * will have their interface changed to match this new value. * * @param iface The name of the network interface used for this link. - * @hide */ - @SystemApi - public void setInterfaceName(String iface) { + public void setInterfaceName(@Nullable String iface) { mIfaceName = iface; ArrayList<RouteInfo> newRoutes = new ArrayList<>(mRoutes.size()); for (RouteInfo route : mRoutes) { @@ -227,7 +224,7 @@ public final class LinkProperties implements Parcelable { * @hide */ @UnsupportedAppUsage - public List<String> getAllInterfaceNames() { + public @NonNull List<String> getAllInterfaceNames() { List<String> interfaceNames = new ArrayList<>(mStackedLinks.size() + 1); if (mIfaceName != null) interfaceNames.add(mIfaceName); for (LinkProperties stacked: mStackedLinks.values()) { @@ -247,8 +244,8 @@ public final class LinkProperties implements Parcelable { * @hide */ @UnsupportedAppUsage - public List<InetAddress> getAddresses() { - List<InetAddress> addresses = new ArrayList<>(); + public @NonNull List<InetAddress> getAddresses() { + final List<InetAddress> addresses = new ArrayList<>(); for (LinkAddress linkAddress : mLinkAddresses) { addresses.add(linkAddress.getAddress()); } @@ -260,7 +257,7 @@ public final class LinkProperties implements Parcelable { * @hide */ @UnsupportedAppUsage - public List<InetAddress> getAllAddresses() { + public @NonNull List<InetAddress> getAllAddresses() { List<InetAddress> addresses = new ArrayList<>(); for (LinkAddress linkAddress : mLinkAddresses) { addresses.add(linkAddress.getAddress()); @@ -289,7 +286,7 @@ public final class LinkProperties implements Parcelable { */ @SystemApi @TestApi - public boolean addLinkAddress(LinkAddress address) { + public boolean addLinkAddress(@NonNull LinkAddress address) { if (address == null) { return false; } @@ -318,7 +315,10 @@ public final class LinkProperties implements Parcelable { */ @SystemApi @TestApi - public boolean removeLinkAddress(LinkAddress toRemove) { + public boolean removeLinkAddress(@NonNull LinkAddress toRemove) { + if (toRemove == null) { + return false; + } int i = findLinkAddressIndex(toRemove); if (i >= 0) { mLinkAddresses.remove(i); @@ -333,7 +333,7 @@ public final class LinkProperties implements Parcelable { * * @return An unmodifiable {@link List} of {@link LinkAddress} for this link. */ - public List<LinkAddress> getLinkAddresses() { + public @NonNull List<LinkAddress> getLinkAddresses() { return Collections.unmodifiableList(mLinkAddresses); } @@ -356,10 +356,8 @@ public final class LinkProperties implements Parcelable { * * @param addresses The {@link Collection} of {@link LinkAddress} to set in this * object. - * @hide */ - @SystemApi - public void setLinkAddresses(Collection<LinkAddress> addresses) { + public void setLinkAddresses(@NonNull Collection<LinkAddress> addresses) { mLinkAddresses.clear(); for (LinkAddress address: addresses) { addLinkAddress(address); @@ -375,7 +373,7 @@ public final class LinkProperties implements Parcelable { */ @TestApi @SystemApi - public boolean addDnsServer(InetAddress dnsServer) { + public boolean addDnsServer(@NonNull InetAddress dnsServer) { if (dnsServer != null && !mDnses.contains(dnsServer)) { mDnses.add(dnsServer); return true; @@ -392,7 +390,7 @@ public final class LinkProperties implements Parcelable { */ @TestApi @SystemApi - public boolean removeDnsServer(InetAddress dnsServer) { + public boolean removeDnsServer(@NonNull InetAddress dnsServer) { if (dnsServer != null) { return mDnses.remove(dnsServer); } @@ -404,10 +402,8 @@ public final class LinkProperties implements Parcelable { * the given {@link Collection} of {@link InetAddress} objects. * * @param dnsServers The {@link Collection} of DNS servers to set in this object. - * @hide */ - @SystemApi - public void setDnsServers(Collection<InetAddress> dnsServers) { + public void setDnsServers(@NonNull Collection<InetAddress> dnsServers) { mDnses.clear(); for (InetAddress dnsServer: dnsServers) { addDnsServer(dnsServer); @@ -420,7 +416,7 @@ public final class LinkProperties implements Parcelable { * @return An unmodifiable {@link List} of {@link InetAddress} for DNS servers on * this link. */ - public List<InetAddress> getDnsServers() { + public @NonNull List<InetAddress> getDnsServers() { return Collections.unmodifiableList(mDnses); } @@ -490,7 +486,7 @@ public final class LinkProperties implements Parcelable { * @return true if the DNS server was added, false if it was already present. * @hide */ - public boolean addValidatedPrivateDnsServer(InetAddress dnsServer) { + public boolean addValidatedPrivateDnsServer(@NonNull InetAddress dnsServer) { if (dnsServer != null && !mValidatedPrivateDnses.contains(dnsServer)) { mValidatedPrivateDnses.add(dnsServer); return true; @@ -506,11 +502,8 @@ public final class LinkProperties implements Parcelable { * @return true if the DNS server was removed, false if it did not exist. * @hide */ - public boolean removeValidatedPrivateDnsServer(InetAddress dnsServer) { - if (dnsServer != null) { - return mValidatedPrivateDnses.remove(dnsServer); - } - return false; + public boolean removeValidatedPrivateDnsServer(@NonNull InetAddress dnsServer) { + return mValidatedPrivateDnses.remove(dnsServer); } /** @@ -523,7 +516,7 @@ public final class LinkProperties implements Parcelable { */ @TestApi @SystemApi - public void setValidatedPrivateDnsServers(Collection<InetAddress> dnsServers) { + public void setValidatedPrivateDnsServers(@NonNull Collection<InetAddress> dnsServers) { mValidatedPrivateDnses.clear(); for (InetAddress dnsServer: dnsServers) { addValidatedPrivateDnsServer(dnsServer); @@ -534,13 +527,13 @@ public final class LinkProperties implements Parcelable { * Returns all the {@link InetAddress} for validated private DNS servers on this link. * These are resolved from the private DNS server name. * - * @return An umodifiable {@link List} of {@link InetAddress} for validated private + * @return An unmodifiable {@link List} of {@link InetAddress} for validated private * DNS servers on this link. * @hide */ @TestApi @SystemApi - public List<InetAddress> getValidatedPrivateDnsServers() { + public @NonNull List<InetAddress> getValidatedPrivateDnsServers() { return Collections.unmodifiableList(mValidatedPrivateDnses); } @@ -551,7 +544,7 @@ public final class LinkProperties implements Parcelable { * @return true if the PCSCF server was added, false otherwise. * @hide */ - public boolean addPcscfServer(InetAddress pcscfServer) { + public boolean addPcscfServer(@NonNull InetAddress pcscfServer) { if (pcscfServer != null && !mPcscfs.contains(pcscfServer)) { mPcscfs.add(pcscfServer); return true; @@ -562,27 +555,24 @@ public final class LinkProperties implements Parcelable { /** * Removes the given {@link InetAddress} from the list of PCSCF servers. * - * @param pcscf Server The {@link InetAddress} to remove from the list of PCSCF servers. + * @param pcscfServer The {@link InetAddress} to remove from the list of PCSCF servers. * @return true if the PCSCF server was removed, false otherwise. * @hide */ - public boolean removePcscfServer(InetAddress pcscfServer) { - if (pcscfServer != null) { - return mPcscfs.remove(pcscfServer); - } - return false; + public boolean removePcscfServer(@NonNull InetAddress pcscfServer) { + return mPcscfs.remove(pcscfServer); } /** * Replaces the PCSCF servers in this {@code LinkProperties} with * the given {@link Collection} of {@link InetAddress} objects. * - * @param addresses The {@link Collection} of PCSCF servers to set in this object. + * @param pcscfServers The {@link Collection} of PCSCF servers to set in this object. * @hide */ @SystemApi @TestApi - public void setPcscfServers(Collection<InetAddress> pcscfServers) { + public void setPcscfServers(@NonNull Collection<InetAddress> pcscfServers) { mPcscfs.clear(); for (InetAddress pcscfServer: pcscfServers) { addPcscfServer(pcscfServer); @@ -598,7 +588,7 @@ public final class LinkProperties implements Parcelable { */ @SystemApi @TestApi - public List<InetAddress> getPcscfServers() { + public @NonNull List<InetAddress> getPcscfServers() { return Collections.unmodifiableList(mPcscfs); } @@ -607,20 +597,18 @@ public final class LinkProperties implements Parcelable { * * @param domains A {@link String} listing in priority order the comma separated * domains to search when resolving host names on this link. - * @hide */ - @SystemApi - public void setDomains(String domains) { + public void setDomains(@Nullable String domains) { mDomains = domains; } /** - * Get the DNS domains search path set for this link. + * Get the DNS domains search path set for this link. May be {@code null} if not set. * - * @return A {@link String} containing the comma separated domains to search when resolving - * host names on this link. + * @return A {@link String} containing the comma separated domains to search when resolving host + * names on this link or {@code null}. */ - public String getDomains() { + public @Nullable String getDomains() { return mDomains; } @@ -630,9 +618,7 @@ public final class LinkProperties implements Parcelable { * 10000 will be ignored. * * @param mtu The MTU to use for this link. - * @hide */ - @SystemApi public void setMtu(int mtu) { mMtu = mtu; } @@ -657,20 +643,20 @@ public final class LinkProperties implements Parcelable { */ @TestApi @SystemApi - public void setTcpBufferSizes(String tcpBufferSizes) { + public void setTcpBufferSizes(@Nullable String tcpBufferSizes) { mTcpBufferSizes = tcpBufferSizes; } /** - * Gets the tcp buffer sizes. + * Gets the tcp buffer sizes. May be {@code null} if not set. * - * @return the tcp buffer sizes to use when this link is the system default. + * @return the tcp buffer sizes to use when this link is the system default or {@code null}. * * @hide */ @TestApi @SystemApi - public String getTcpBufferSizes() { + public @Nullable String getTcpBufferSizes() { return mTcpBufferSizes; } @@ -690,23 +676,18 @@ public final class LinkProperties implements Parcelable { * * @param route A {@link RouteInfo} to add to this object. * @return {@code false} if the route was already present, {@code true} if it was added. - * - * @hide */ - @SystemApi - public boolean addRoute(RouteInfo route) { - if (route != null) { - String routeIface = route.getInterface(); - if (routeIface != null && !routeIface.equals(mIfaceName)) { - throw new IllegalArgumentException( - "Route added with non-matching interface: " + routeIface + - " vs. " + mIfaceName); - } - route = routeWithInterface(route); - if (!mRoutes.contains(route)) { - mRoutes.add(route); - return true; - } + public boolean addRoute(@NonNull RouteInfo route) { + String routeIface = route.getInterface(); + if (routeIface != null && !routeIface.equals(mIfaceName)) { + throw new IllegalArgumentException( + "Route added with non-matching interface: " + routeIface + + " vs. " + mIfaceName); + } + route = routeWithInterface(route); + if (!mRoutes.contains(route)) { + mRoutes.add(route); + return true; } return false; } @@ -722,10 +703,8 @@ public final class LinkProperties implements Parcelable { */ @TestApi @SystemApi - public boolean removeRoute(RouteInfo route) { - return route != null && - Objects.equals(mIfaceName, route.getInterface()) && - mRoutes.remove(route); + public boolean removeRoute(@NonNull RouteInfo route) { + return Objects.equals(mIfaceName, route.getInterface()) && mRoutes.remove(route); } /** @@ -733,7 +712,7 @@ public final class LinkProperties implements Parcelable { * * @return An unmodifiable {@link List} of {@link RouteInfo} for this link. */ - public List<RouteInfo> getRoutes() { + public @NonNull List<RouteInfo> getRoutes() { return Collections.unmodifiableList(mRoutes); } @@ -753,7 +732,7 @@ public final class LinkProperties implements Parcelable { * @hide */ @UnsupportedAppUsage - public List<RouteInfo> getAllRoutes() { + public @NonNull List<RouteInfo> getAllRoutes() { List<RouteInfo> routes = new ArrayList<>(mRoutes); for (LinkProperties stacked: mStackedLinks.values()) { routes.addAll(stacked.getAllRoutes()); @@ -767,26 +746,24 @@ public final class LinkProperties implements Parcelable { * not enforce it and applications may ignore them. * * @param proxy A {@link ProxyInfo} defining the HTTP Proxy to use on this link. - * @hide */ - @SystemApi - public void setHttpProxy(ProxyInfo proxy) { + public void setHttpProxy(@Nullable ProxyInfo proxy) { mHttpProxy = proxy; } /** * Gets the recommended {@link ProxyInfo} (or {@code null}) set on this link. * - * @return The {@link ProxyInfo} set on this link + * @return The {@link ProxyInfo} set on this link or {@code null}. */ - public ProxyInfo getHttpProxy() { + public @Nullable ProxyInfo getHttpProxy() { return mHttpProxy; } /** * Returns the NAT64 prefix in use on this link, if any. * - * @return the NAT64 prefix. + * @return the NAT64 prefix or {@code null}. * @hide */ @SystemApi @@ -799,14 +776,14 @@ public final class LinkProperties implements Parcelable { * Sets the NAT64 prefix in use on this link. * * Currently, only 96-bit prefixes (i.e., where the 32-bit IPv4 address is at the end of the - * 128-bit IPv6 address) are supported. + * 128-bit IPv6 address) are supported or {@code null} for no prefix. * * @param prefix the NAT64 prefix. * @hide */ @SystemApi @TestApi - public void setNat64Prefix(IpPrefix prefix) { + public void setNat64Prefix(@Nullable IpPrefix prefix) { if (prefix != null && prefix.getPrefixLength() != 96) { throw new IllegalArgumentException("Only 96-bit prefixes are supported: " + prefix); } @@ -818,15 +795,15 @@ public final class LinkProperties implements Parcelable { * * If there is already a stacked link with the same interface name as link, * that link is replaced with link. Otherwise, link is added to the list - * of stacked links. If link is null, nothing changes. + * of stacked links. * * @param link The link to add. * @return true if the link was stacked, false otherwise. * @hide */ @UnsupportedAppUsage - public boolean addStackedLink(LinkProperties link) { - if (link != null && link.getInterfaceName() != null) { + public boolean addStackedLink(@NonNull LinkProperties link) { + if (link.getInterfaceName() != null) { mStackedLinks.put(link.getInterfaceName(), link); return true; } @@ -843,12 +820,9 @@ public final class LinkProperties implements Parcelable { * @return true if the link was removed, false otherwise. * @hide */ - public boolean removeStackedLink(String iface) { - if (iface != null) { - LinkProperties removed = mStackedLinks.remove(iface); - return removed != null; - } - return false; + public boolean removeStackedLink(@NonNull String iface) { + LinkProperties removed = mStackedLinks.remove(iface); + return removed != null; } /** @@ -860,7 +834,7 @@ public final class LinkProperties implements Parcelable { if (mStackedLinks.isEmpty()) { return Collections.emptyList(); } - List<LinkProperties> stacked = new ArrayList<>(); + final List<LinkProperties> stacked = new ArrayList<>(); for (LinkProperties link : mStackedLinks.values()) { stacked.add(new LinkProperties(link)); } @@ -869,9 +843,7 @@ public final class LinkProperties implements Parcelable { /** * Clears this object to its initial state. - * @hide */ - @SystemApi public void clear() { mIfaceName = null; mLinkAddresses.clear(); @@ -988,7 +960,7 @@ public final class LinkProperties implements Parcelable { */ @TestApi @SystemApi - public boolean hasIPv4Address() { + public boolean hasIpv4Address() { for (LinkAddress address : mLinkAddresses) { if (address.getAddress() instanceof Inet4Address) { return true; @@ -998,15 +970,27 @@ public final class LinkProperties implements Parcelable { } /** + * For backward compatibility. + * This was annotated with @UnsupportedAppUsage in P, so we can't remove the method completely + * just yet. + * @return {@code true} if there is an IPv4 address, {@code false} otherwise. + * @hide + */ + @UnsupportedAppUsage(maxTargetSdk = Build.VERSION_CODES.P) + public boolean hasIPv4Address() { + return hasIpv4Address(); + } + + /** * Returns true if this link or any of its stacked interfaces has an IPv4 address. * * @return {@code true} if there is an IPv4 address, {@code false} otherwise. */ - private boolean hasIPv4AddressOnInterface(String iface) { + private boolean hasIpv4AddressOnInterface(String iface) { // mIfaceName can be null. - return (Objects.equals(iface, mIfaceName) && hasIPv4Address()) || - (iface != null && mStackedLinks.containsKey(iface) && - mStackedLinks.get(iface).hasIPv4Address()); + return (Objects.equals(iface, mIfaceName) && hasIpv4Address()) + || (iface != null && mStackedLinks.containsKey(iface) + && mStackedLinks.get(iface).hasIpv4Address()); } /** @@ -1017,7 +1001,7 @@ public final class LinkProperties implements Parcelable { */ @TestApi @SystemApi - public boolean hasGlobalIPv6Address() { + public boolean hasGlobalIpv6Address() { for (LinkAddress address : mLinkAddresses) { if (address.getAddress() instanceof Inet6Address && address.isGlobalPreferred()) { return true; @@ -1027,13 +1011,25 @@ public final class LinkProperties implements Parcelable { } /** + * For backward compatibility. + * This was annotated with @UnsupportedAppUsage in P, so we can't remove the method completely + * just yet. + * @return {@code true} if there is a global preferred IPv6 address, {@code false} otherwise. + * @hide + */ + @UnsupportedAppUsage(maxTargetSdk = Build.VERSION_CODES.P) + public boolean hasGlobalIPv6Address() { + return hasGlobalIpv6Address(); + } + + /** * Returns true if this link has an IPv4 default route. * * @return {@code true} if there is an IPv4 default route, {@code false} otherwise. * @hide */ @UnsupportedAppUsage - public boolean hasIPv4DefaultRoute() { + public boolean hasIpv4DefaultRoute() { for (RouteInfo r : mRoutes) { if (r.isIPv4Default()) { return true; @@ -1043,6 +1039,18 @@ public final class LinkProperties implements Parcelable { } /** + * For backward compatibility. + * This was annotated with @UnsupportedAppUsage in P, so we can't remove the method completely + * just yet. + * @return {@code true} if there is an IPv4 default route, {@code false} otherwise. + * @hide + */ + @UnsupportedAppUsage(maxTargetSdk = Build.VERSION_CODES.P) + public boolean hasIPv4DefaultRoute() { + return hasIpv4DefaultRoute(); + } + + /** * Returns true if this link has an IPv6 default route. * * @return {@code true} if there is an IPv6 default route, {@code false} otherwise. @@ -1050,7 +1058,7 @@ public final class LinkProperties implements Parcelable { */ @TestApi @SystemApi - public boolean hasIPv6DefaultRoute() { + public boolean hasIpv6DefaultRoute() { for (RouteInfo r : mRoutes) { if (r.isIPv6Default()) { return true; @@ -1060,13 +1068,25 @@ public final class LinkProperties implements Parcelable { } /** + * For backward compatibility. + * This was annotated with @UnsupportedAppUsage in P, so we can't remove the method completely + * just yet. + * @return {@code true} if there is an IPv6 default route, {@code false} otherwise. + * @hide + */ + @UnsupportedAppUsage(maxTargetSdk = Build.VERSION_CODES.P) + public boolean hasIPv6DefaultRoute() { + return hasIpv6DefaultRoute(); + } + + /** * Returns true if this link has an IPv4 DNS server. * * @return {@code true} if there is an IPv4 DNS server, {@code false} otherwise. * @hide */ @UnsupportedAppUsage - public boolean hasIPv4DnsServer() { + public boolean hasIpv4DnsServer() { for (InetAddress ia : mDnses) { if (ia instanceof Inet4Address) { return true; @@ -1076,13 +1096,25 @@ public final class LinkProperties implements Parcelable { } /** + * For backward compatibility. + * This was annotated with @UnsupportedAppUsage in P, so we can't remove the method completely + * just yet. + * @return {@code true} if there is an IPv4 DNS server, {@code false} otherwise. + * @hide + */ + @UnsupportedAppUsage(maxTargetSdk = Build.VERSION_CODES.P) + public boolean hasIPv4DnsServer() { + return hasIpv4DnsServer(); + } + + /** * Returns true if this link has an IPv6 DNS server. * * @return {@code true} if there is an IPv6 DNS server, {@code false} otherwise. * @hide */ @UnsupportedAppUsage - public boolean hasIPv6DnsServer() { + public boolean hasIpv6DnsServer() { for (InetAddress ia : mDnses) { if (ia instanceof Inet6Address) { return true; @@ -1092,12 +1124,24 @@ public final class LinkProperties implements Parcelable { } /** + * For backward compatibility. + * This was annotated with @UnsupportedAppUsage in P, so we can't remove the method completely + * just yet. + * @return {@code true} if there is an IPv6 DNS server, {@code false} otherwise. + * @hide + */ + @UnsupportedAppUsage(maxTargetSdk = Build.VERSION_CODES.P) + public boolean hasIPv6DnsServer() { + return hasIpv6DnsServer(); + } + + /** * Returns true if this link has an IPv4 PCSCF server. * * @return {@code true} if there is an IPv4 PCSCF server, {@code false} otherwise. * @hide */ - public boolean hasIPv4PcscfServer() { + public boolean hasIpv4PcscfServer() { for (InetAddress ia : mPcscfs) { if (ia instanceof Inet4Address) { return true; @@ -1112,7 +1156,7 @@ public final class LinkProperties implements Parcelable { * @return {@code true} if there is an IPv6 PCSCF server, {@code false} otherwise. * @hide */ - public boolean hasIPv6PcscfServer() { + public boolean hasIpv6PcscfServer() { for (InetAddress ia : mPcscfs) { if (ia instanceof Inet6Address) { return true; @@ -1130,10 +1174,10 @@ public final class LinkProperties implements Parcelable { */ @TestApi @SystemApi - public boolean isIPv4Provisioned() { - return (hasIPv4Address() && - hasIPv4DefaultRoute() && - hasIPv4DnsServer()); + public boolean isIpv4Provisioned() { + return (hasIpv4Address() + && hasIpv4DefaultRoute() + && hasIpv4DnsServer()); } /** @@ -1145,12 +1189,25 @@ public final class LinkProperties implements Parcelable { */ @TestApi @SystemApi + public boolean isIpv6Provisioned() { + return (hasGlobalIpv6Address() + && hasIpv6DefaultRoute() + && hasIpv6DnsServer()); + } + + /** + * For backward compatibility. + * This was annotated with @UnsupportedAppUsage in P, so we can't remove the method completely + * just yet. + * @return {@code true} if the link is provisioned, {@code false} otherwise. + * @hide + */ + @UnsupportedAppUsage(maxTargetSdk = Build.VERSION_CODES.P) public boolean isIPv6Provisioned() { - return (hasGlobalIPv6Address() && - hasIPv6DefaultRoute() && - hasIPv6DnsServer()); + return isIpv6Provisioned(); } + /** * Returns true if this link is provisioned for global connectivity, * for at least one Internet Protocol family. @@ -1161,7 +1218,7 @@ public final class LinkProperties implements Parcelable { @TestApi @SystemApi public boolean isProvisioned() { - return (isIPv4Provisioned() || isIPv6Provisioned()); + return (isIpv4Provisioned() || isIpv6Provisioned()); } /** @@ -1173,7 +1230,7 @@ public final class LinkProperties implements Parcelable { */ @TestApi @SystemApi - public boolean isReachable(InetAddress ip) { + public boolean isReachable(@NonNull InetAddress ip) { final List<RouteInfo> allRoutes = getAllRoutes(); // If we don't have a route to this IP address, it's not reachable. final RouteInfo bestRoute = RouteInfo.selectBestRoute(allRoutes, ip); @@ -1185,7 +1242,7 @@ public final class LinkProperties implements Parcelable { if (ip instanceof Inet4Address) { // For IPv4, it suffices for now to simply have any address. - return hasIPv4AddressOnInterface(bestRoute.getInterface()); + return hasIpv4AddressOnInterface(bestRoute.getInterface()); } else if (ip instanceof Inet6Address) { if (ip.isLinkLocalAddress()) { // For now, just make sure link-local destinations have @@ -1196,7 +1253,7 @@ public final class LinkProperties implements Parcelable { // For non-link-local destinations check that either the best route // is directly connected or that some global preferred address exists. // TODO: reconsider all cases (disconnected ULA networks, ...). - return (!bestRoute.hasGateway() || hasGlobalIPv6Address()); + return (!bestRoute.hasGateway() || hasGlobalIpv6Address()); } } @@ -1211,7 +1268,7 @@ public final class LinkProperties implements Parcelable { * @hide */ @UnsupportedAppUsage - public boolean isIdenticalInterfaceName(LinkProperties target) { + public boolean isIdenticalInterfaceName(@NonNull LinkProperties target) { return TextUtils.equals(getInterfaceName(), target.getInterfaceName()); } @@ -1223,7 +1280,7 @@ public final class LinkProperties implements Parcelable { * @hide */ @UnsupportedAppUsage - public boolean isIdenticalAddresses(LinkProperties target) { + public boolean isIdenticalAddresses(@NonNull LinkProperties target) { Collection<InetAddress> targetAddresses = target.getAddresses(); Collection<InetAddress> sourceAddresses = getAddresses(); return (sourceAddresses.size() == targetAddresses.size()) ? @@ -1238,7 +1295,7 @@ public final class LinkProperties implements Parcelable { * @hide */ @UnsupportedAppUsage - public boolean isIdenticalDnses(LinkProperties target) { + public boolean isIdenticalDnses(@NonNull LinkProperties target) { Collection<InetAddress> targetDnses = target.getDnsServers(); String targetDomains = target.getDomains(); if (mDomains == null) { @@ -1258,7 +1315,7 @@ public final class LinkProperties implements Parcelable { * @return {@code true} if both are identical, {@code false} otherwise. * @hide */ - public boolean isIdenticalPrivateDns(LinkProperties target) { + public boolean isIdenticalPrivateDns(@NonNull LinkProperties target) { return (isPrivateDnsActive() == target.isPrivateDnsActive() && TextUtils.equals(getPrivateDnsServerName(), target.getPrivateDnsServerName())); @@ -1272,7 +1329,7 @@ public final class LinkProperties implements Parcelable { * @return {@code true} if both are identical, {@code false} otherwise. * @hide */ - public boolean isIdenticalValidatedPrivateDnses(LinkProperties target) { + public boolean isIdenticalValidatedPrivateDnses(@NonNull LinkProperties target) { Collection<InetAddress> targetDnses = target.getValidatedPrivateDnsServers(); return (mValidatedPrivateDnses.size() == targetDnses.size()) ? mValidatedPrivateDnses.containsAll(targetDnses) : false; @@ -1285,7 +1342,7 @@ public final class LinkProperties implements Parcelable { * @return {@code true} if both are identical, {@code false} otherwise. * @hide */ - public boolean isIdenticalPcscfs(LinkProperties target) { + public boolean isIdenticalPcscfs(@NonNull LinkProperties target) { Collection<InetAddress> targetPcscfs = target.getPcscfServers(); return (mPcscfs.size() == targetPcscfs.size()) ? mPcscfs.containsAll(targetPcscfs) : false; @@ -1299,7 +1356,7 @@ public final class LinkProperties implements Parcelable { * @hide */ @UnsupportedAppUsage - public boolean isIdenticalRoutes(LinkProperties target) { + public boolean isIdenticalRoutes(@NonNull LinkProperties target) { Collection<RouteInfo> targetRoutes = target.getRoutes(); return (mRoutes.size() == targetRoutes.size()) ? mRoutes.containsAll(targetRoutes) : false; @@ -1313,7 +1370,7 @@ public final class LinkProperties implements Parcelable { * @hide */ @UnsupportedAppUsage(maxTargetSdk = Build.VERSION_CODES.P, trackingBug = 115609023) - public boolean isIdenticalHttpProxy(LinkProperties target) { + public boolean isIdenticalHttpProxy(@NonNull LinkProperties target) { return getHttpProxy() == null ? target.getHttpProxy() == null : getHttpProxy().equals(target.getHttpProxy()); } @@ -1326,7 +1383,7 @@ public final class LinkProperties implements Parcelable { * @hide */ @UnsupportedAppUsage - public boolean isIdenticalStackedLinks(LinkProperties target) { + public boolean isIdenticalStackedLinks(@NonNull LinkProperties target) { if (!mStackedLinks.keySet().equals(target.mStackedLinks.keySet())) { return false; } @@ -1347,7 +1404,7 @@ public final class LinkProperties implements Parcelable { * @return {@code true} if both are identical, {@code false} otherwise. * @hide */ - public boolean isIdenticalMtu(LinkProperties target) { + public boolean isIdenticalMtu(@NonNull LinkProperties target) { return getMtu() == target.getMtu(); } @@ -1358,7 +1415,7 @@ public final class LinkProperties implements Parcelable { * @return {@code true} if both are identical, {@code false} otherwise. * @hide */ - public boolean isIdenticalTcpBufferSizes(LinkProperties target) { + public boolean isIdenticalTcpBufferSizes(@NonNull LinkProperties target) { return Objects.equals(mTcpBufferSizes, target.mTcpBufferSizes); } @@ -1369,7 +1426,7 @@ public final class LinkProperties implements Parcelable { * @return {@code true} if both are identical, {@code false} otherwise. * @hide */ - public boolean isIdenticalNat64Prefix(LinkProperties target) { + public boolean isIdenticalNat64Prefix(@NonNull LinkProperties target) { return Objects.equals(mNat64Prefix, target.mNat64Prefix); } @@ -1421,7 +1478,7 @@ public final class LinkProperties implements Parcelable { * @return the differences between the addresses. * @hide */ - public CompareResult<LinkAddress> compareAddresses(LinkProperties target) { + public @NonNull CompareResult<LinkAddress> compareAddresses(@Nullable LinkProperties target) { /* * Duplicate the LinkAddresses into removed, we will be removing * address which are common between mLinkAddresses and target @@ -1441,7 +1498,7 @@ public final class LinkProperties implements Parcelable { * @return the differences between the DNS addresses. * @hide */ - public CompareResult<InetAddress> compareDnses(LinkProperties target) { + public @NonNull CompareResult<InetAddress> compareDnses(@Nullable LinkProperties target) { /* * Duplicate the InetAddresses into removed, we will be removing * dns address which are common between mDnses and target @@ -1460,7 +1517,8 @@ public final class LinkProperties implements Parcelable { * @return the differences between the DNS addresses. * @hide */ - public CompareResult<InetAddress> compareValidatedPrivateDnses(LinkProperties target) { + public @NonNull CompareResult<InetAddress> compareValidatedPrivateDnses( + @Nullable LinkProperties target) { return new CompareResult<>(mValidatedPrivateDnses, target != null ? target.getValidatedPrivateDnsServers() : null); } @@ -1473,7 +1531,7 @@ public final class LinkProperties implements Parcelable { * @return the differences between the routes. * @hide */ - public CompareResult<RouteInfo> compareAllRoutes(LinkProperties target) { + public @NonNull CompareResult<RouteInfo> compareAllRoutes(@Nullable LinkProperties target) { /* * Duplicate the RouteInfos into removed, we will be removing * routes which are common between mRoutes and target @@ -1491,7 +1549,8 @@ public final class LinkProperties implements Parcelable { * @return the differences between the interface names. * @hide */ - public CompareResult<String> compareAllInterfaceNames(LinkProperties target) { + public @NonNull CompareResult<String> compareAllInterfaceNames( + @Nullable LinkProperties target) { /* * Duplicate the interface names into removed, we will be removing * interface names which are common between this and target diff --git a/core/java/android/net/NattSocketKeepalive.java b/core/java/android/net/NattSocketKeepalive.java index 84da294f8940..b0ce0c71fbeb 100644 --- a/core/java/android/net/NattSocketKeepalive.java +++ b/core/java/android/net/NattSocketKeepalive.java @@ -17,10 +17,10 @@ package android.net; import android.annotation.NonNull; +import android.os.ParcelFileDescriptor; import android.os.RemoteException; import android.util.Log; -import java.io.FileDescriptor; import java.net.InetAddress; import java.util.concurrent.Executor; @@ -31,21 +31,19 @@ public final class NattSocketKeepalive extends SocketKeepalive { @NonNull private final InetAddress mSource; @NonNull private final InetAddress mDestination; - @NonNull private final FileDescriptor mFd; private final int mResourceId; NattSocketKeepalive(@NonNull IConnectivityManager service, @NonNull Network network, - @NonNull FileDescriptor fd, + @NonNull ParcelFileDescriptor pfd, int resourceId, @NonNull InetAddress source, @NonNull InetAddress destination, @NonNull Executor executor, @NonNull Callback callback) { - super(service, network, executor, callback); + super(service, network, pfd, executor, callback); mSource = source; mDestination = destination; - mFd = fd; mResourceId = resourceId; } @@ -53,8 +51,8 @@ public final class NattSocketKeepalive extends SocketKeepalive { void startImpl(int intervalSec) { mExecutor.execute(() -> { try { - mService.startNattKeepaliveWithFd(mNetwork, mFd, mResourceId, intervalSec, - mCallback, + mService.startNattKeepaliveWithFd(mNetwork, mPfd.getFileDescriptor(), mResourceId, + intervalSec, mCallback, mSource.getHostAddress(), mDestination.getHostAddress()); } catch (RemoteException e) { Log.e(TAG, "Error starting socket keepalive: ", e); @@ -75,6 +73,5 @@ public final class NattSocketKeepalive extends SocketKeepalive { throw e.rethrowFromSystemServer(); } }); - } } diff --git a/core/java/android/net/Network.java b/core/java/android/net/Network.java index e04b5fc5f9cf..09a86fcfa86f 100644 --- a/core/java/android/net/Network.java +++ b/core/java/android/net/Network.java @@ -16,6 +16,7 @@ package android.net; +import android.annotation.NonNull; import android.annotation.SystemApi; import android.annotation.TestApi; import android.annotation.UnsupportedAppUsage; @@ -125,7 +126,7 @@ public class Network implements Parcelable { */ @SystemApi @TestApi - public Network(Network that) { + public Network(@NonNull Network that) { this(that.netId, that.mPrivateDnsBypass); } @@ -163,7 +164,7 @@ public class Network implements Parcelable { */ @TestApi @SystemApi - public Network getPrivateDnsBypassingCopy() { + public @NonNull Network getPrivateDnsBypassingCopy() { return new Network(netId, true); } diff --git a/core/java/android/net/NetworkAgent.java b/core/java/android/net/NetworkAgent.java index b55f6ba06438..1edea556c574 100644 --- a/core/java/android/net/NetworkAgent.java +++ b/core/java/android/net/NetworkAgent.java @@ -488,14 +488,14 @@ public abstract class NetworkAgent extends Handler { * Requests that the network hardware send the specified packet at the specified interval. */ protected void startSocketKeepalive(Message msg) { - onSocketKeepaliveEvent(msg.arg1, SocketKeepalive.ERROR_HARDWARE_UNSUPPORTED); + onSocketKeepaliveEvent(msg.arg1, SocketKeepalive.ERROR_UNSUPPORTED); } /** * Requests that the network hardware stops sending keepalive packets. */ protected void stopSocketKeepalive(Message msg) { - onSocketKeepaliveEvent(msg.arg1, SocketKeepalive.ERROR_HARDWARE_UNSUPPORTED); + onSocketKeepaliveEvent(msg.arg1, SocketKeepalive.ERROR_UNSUPPORTED); } /** @@ -511,7 +511,7 @@ public abstract class NetworkAgent extends Handler { * override this method. */ protected void addKeepalivePacketFilter(Message msg) { - onSocketKeepaliveEvent(msg.arg1, SocketKeepalive.ERROR_HARDWARE_UNSUPPORTED); + onSocketKeepaliveEvent(msg.arg1, SocketKeepalive.ERROR_UNSUPPORTED); } /** @@ -520,7 +520,7 @@ public abstract class NetworkAgent extends Handler { * must override this method. */ protected void removeKeepalivePacketFilter(Message msg) { - onSocketKeepaliveEvent(msg.arg1, SocketKeepalive.ERROR_HARDWARE_UNSUPPORTED); + onSocketKeepaliveEvent(msg.arg1, SocketKeepalive.ERROR_UNSUPPORTED); } /** diff --git a/core/java/android/net/NetworkCapabilities.java b/core/java/android/net/NetworkCapabilities.java index e1cfe991de8d..99375f842b4c 100644 --- a/core/java/android/net/NetworkCapabilities.java +++ b/core/java/android/net/NetworkCapabilities.java @@ -17,6 +17,7 @@ package android.net; import android.annotation.IntDef; +import android.annotation.NonNull; import android.annotation.Nullable; import android.annotation.SystemApi; import android.annotation.TestApi; @@ -91,7 +92,7 @@ public final class NetworkCapabilities implements Parcelable { * Set all contents of this object to the contents of a NetworkCapabilities. * @hide */ - public void set(NetworkCapabilities nc) { + public void set(@NonNull NetworkCapabilities nc) { mNetworkCapabilities = nc.mNetworkCapabilities; mTransportTypes = nc.mTransportTypes; mLinkUpBandwidthKbps = nc.mLinkUpBandwidthKbps; @@ -405,7 +406,7 @@ public final class NetworkCapabilities implements Parcelable { * @hide */ @UnsupportedAppUsage - public NetworkCapabilities addCapability(@NetCapability int capability) { + public @NonNull NetworkCapabilities addCapability(@NetCapability int capability) { checkValidCapability(capability); mNetworkCapabilities |= 1 << capability; mUnwantedNetworkCapabilities &= ~(1 << capability); // remove from unwanted capability list @@ -442,7 +443,7 @@ public final class NetworkCapabilities implements Parcelable { * @hide */ @UnsupportedAppUsage - public NetworkCapabilities removeCapability(@NetCapability int capability) { + public @NonNull NetworkCapabilities removeCapability(@NetCapability int capability) { checkValidCapability(capability); final long mask = ~(1 << capability); mNetworkCapabilities &= mask; @@ -456,7 +457,8 @@ public final class NetworkCapabilities implements Parcelable { * * @hide */ - public NetworkCapabilities setCapability(@NetCapability int capability, boolean value) { + public @NonNull NetworkCapabilities setCapability(@NetCapability int capability, + boolean value) { if (value) { addCapability(capability); } else { @@ -534,7 +536,7 @@ public final class NetworkCapabilities implements Parcelable { } /** Note this method may result in having the same capability in wanted and unwanted lists. */ - private void combineNetCapabilities(NetworkCapabilities nc) { + private void combineNetCapabilities(@NonNull NetworkCapabilities nc) { this.mNetworkCapabilities |= nc.mNetworkCapabilities; this.mUnwantedNetworkCapabilities |= nc.mUnwantedNetworkCapabilities; } @@ -546,7 +548,7 @@ public final class NetworkCapabilities implements Parcelable { * * @hide */ - public String describeFirstNonRequestableCapability() { + public @Nullable String describeFirstNonRequestableCapability() { final long nonRequestable = (mNetworkCapabilities | mUnwantedNetworkCapabilities) & NON_REQUESTABLE_CAPABILITIES; @@ -558,7 +560,8 @@ public final class NetworkCapabilities implements Parcelable { return null; } - private boolean satisfiedByNetCapabilities(NetworkCapabilities nc, boolean onlyImmutable) { + private boolean satisfiedByNetCapabilities(@NonNull NetworkCapabilities nc, + boolean onlyImmutable) { long requestedCapabilities = mNetworkCapabilities; long requestedUnwantedCapabilities = mUnwantedNetworkCapabilities; long providedCapabilities = nc.mNetworkCapabilities; @@ -572,12 +575,12 @@ public final class NetworkCapabilities implements Parcelable { } /** @hide */ - public boolean equalsNetCapabilities(NetworkCapabilities nc) { + public boolean equalsNetCapabilities(@NonNull NetworkCapabilities nc) { return (nc.mNetworkCapabilities == this.mNetworkCapabilities) && (nc.mUnwantedNetworkCapabilities == this.mUnwantedNetworkCapabilities); } - private boolean equalsNetCapabilitiesRequestable(NetworkCapabilities that) { + private boolean equalsNetCapabilitiesRequestable(@NonNull NetworkCapabilities that) { return ((this.mNetworkCapabilities & ~NON_REQUESTABLE_CAPABILITIES) == (that.mNetworkCapabilities & ~NON_REQUESTABLE_CAPABILITIES)) && ((this.mUnwantedNetworkCapabilities & ~NON_REQUESTABLE_CAPABILITIES) == @@ -713,7 +716,7 @@ public final class NetworkCapabilities implements Parcelable { * @hide */ @UnsupportedAppUsage - public NetworkCapabilities addTransportType(@Transport int transportType) { + public @NonNull NetworkCapabilities addTransportType(@Transport int transportType) { checkValidTransportType(transportType); mTransportTypes |= 1 << transportType; setNetworkSpecifier(mNetworkSpecifier); // used for exception checking @@ -727,7 +730,7 @@ public final class NetworkCapabilities implements Parcelable { * @return This NetworkCapabilities instance, to facilitate chaining. * @hide */ - public NetworkCapabilities removeTransportType(@Transport int transportType) { + public @NonNull NetworkCapabilities removeTransportType(@Transport int transportType) { checkValidTransportType(transportType); mTransportTypes &= ~(1 << transportType); setNetworkSpecifier(mNetworkSpecifier); // used for exception checking @@ -740,7 +743,8 @@ public final class NetworkCapabilities implements Parcelable { * * @hide */ - public NetworkCapabilities setTransportType(@Transport int transportType, boolean value) { + public @NonNull NetworkCapabilities setTransportType(@Transport int transportType, + boolean value) { if (value) { addTransportType(transportType); } else { @@ -757,7 +761,7 @@ public final class NetworkCapabilities implements Parcelable { */ @TestApi @SystemApi - public @Transport int[] getTransportTypes() { + @NonNull public @Transport int[] getTransportTypes() { return BitUtils.unpackBits(mTransportTypes); } @@ -847,7 +851,7 @@ public final class NetworkCapabilities implements Parcelable { * @param upKbps the estimated first hop upstream (device to network) bandwidth. * @hide */ - public NetworkCapabilities setLinkUpstreamBandwidthKbps(int upKbps) { + public @NonNull NetworkCapabilities setLinkUpstreamBandwidthKbps(int upKbps) { mLinkUpBandwidthKbps = upKbps; return this; } @@ -877,7 +881,7 @@ public final class NetworkCapabilities implements Parcelable { * @param downKbps the estimated first hop downstream (network to device) bandwidth. * @hide */ - public NetworkCapabilities setLinkDownstreamBandwidthKbps(int downKbps) { + public @NonNull NetworkCapabilities setLinkDownstreamBandwidthKbps(int downKbps) { mLinkDownBandwidthKbps = downKbps; return this; } @@ -936,7 +940,7 @@ public final class NetworkCapabilities implements Parcelable { * @return This NetworkCapabilities instance, to facilitate chaining. * @hide */ - public NetworkCapabilities setNetworkSpecifier(NetworkSpecifier networkSpecifier) { + public @NonNull NetworkCapabilities setNetworkSpecifier(NetworkSpecifier networkSpecifier) { if (networkSpecifier != null && Long.bitCount(mTransportTypes) != 1) { throw new IllegalStateException("Must have a single transport specified to use " + "setNetworkSpecifier"); @@ -955,20 +959,20 @@ public final class NetworkCapabilities implements Parcelable { * @return This NetworkCapabilities instance, to facilitate chaining. * @hide */ - public NetworkCapabilities setTransportInfo(TransportInfo transportInfo) { + public @NonNull NetworkCapabilities setTransportInfo(TransportInfo transportInfo) { mTransportInfo = transportInfo; return this; } /** - * Gets the optional bearer specific network specifier. + * Gets the optional bearer specific network specifier. May be {@code null} if not set. * * @return The optional {@link NetworkSpecifier} specifying the bearer specific network - * specifier. See {@link #setNetworkSpecifier}. + * specifier or {@code null}. See {@link #setNetworkSpecifier}. * @hide */ @UnsupportedAppUsage(maxTargetSdk = Build.VERSION_CODES.P, trackingBug = 115609023) - public NetworkSpecifier getNetworkSpecifier() { + public @Nullable NetworkSpecifier getNetworkSpecifier() { return mNetworkSpecifier; } @@ -1015,8 +1019,6 @@ public final class NetworkCapabilities implements Parcelable { /** * Magic value that indicates no signal strength provided. A request specifying this value is * always satisfied. - * - * @hide */ public static final int SIGNAL_STRENGTH_UNSPECIFIED = Integer.MIN_VALUE; @@ -1024,7 +1026,7 @@ public final class NetworkCapabilities implements Parcelable { * Signal strength. This is a signed integer, and higher values indicate better signal. * The exact units are bearer-dependent. For example, Wi-Fi uses RSSI. */ - @UnsupportedAppUsage + @UnsupportedAppUsage(maxTargetSdk = Build.VERSION_CODES.P) private int mSignalStrength = SIGNAL_STRENGTH_UNSPECIFIED; /** @@ -1041,7 +1043,7 @@ public final class NetworkCapabilities implements Parcelable { * @hide */ @UnsupportedAppUsage - public NetworkCapabilities setSignalStrength(int signalStrength) { + public @NonNull NetworkCapabilities setSignalStrength(int signalStrength) { mSignalStrength = signalStrength; return this; } @@ -1060,9 +1062,7 @@ public final class NetworkCapabilities implements Parcelable { * Retrieves the signal strength. * * @return The bearer-specific signal strength. - * @hide */ - @SystemApi public int getSignalStrength() { return mSignalStrength; } @@ -1120,7 +1120,7 @@ public final class NetworkCapabilities implements Parcelable { * Convenience method to set the UIDs this network applies to to a single UID. * @hide */ - public NetworkCapabilities setSingleUid(int uid) { + public @NonNull NetworkCapabilities setSingleUid(int uid) { final ArraySet<UidRange> identity = new ArraySet<>(1); identity.add(new UidRange(uid, uid)); setUids(identity); @@ -1132,7 +1132,7 @@ public final class NetworkCapabilities implements Parcelable { * This makes a copy of the set so that callers can't modify it after the call. * @hide */ - public NetworkCapabilities setUids(Set<UidRange> uids) { + public @NonNull NetworkCapabilities setUids(Set<UidRange> uids) { if (null == uids) { mUids = null; } else { @@ -1146,7 +1146,7 @@ public final class NetworkCapabilities implements Parcelable { * This returns a copy of the set so that callers can't modify the original object. * @hide */ - public Set<UidRange> getUids() { + public @Nullable Set<UidRange> getUids() { return null == mUids ? null : new ArraySet<>(mUids); } @@ -1179,7 +1179,7 @@ public final class NetworkCapabilities implements Parcelable { * @hide */ @VisibleForTesting - public boolean equalsUids(NetworkCapabilities nc) { + public boolean equalsUids(@NonNull NetworkCapabilities nc) { Set<UidRange> comparedUids = nc.mUids; if (null == comparedUids) return null == mUids; if (null == mUids) return false; @@ -1212,7 +1212,7 @@ public final class NetworkCapabilities implements Parcelable { * @see #appliesToUid * @hide */ - public boolean satisfiedByUids(NetworkCapabilities nc) { + public boolean satisfiedByUids(@NonNull NetworkCapabilities nc) { if (null == nc.mUids || null == mUids) return true; // The network satisfies everything. for (UidRange requiredRange : mUids) { if (requiredRange.contains(nc.mEstablishingVpnAppUid)) return true; @@ -1232,7 +1232,7 @@ public final class NetworkCapabilities implements Parcelable { * @hide */ @VisibleForTesting - public boolean appliesToUidRange(UidRange requiredRange) { + public boolean appliesToUidRange(@Nullable UidRange requiredRange) { if (null == mUids) return true; for (UidRange uidRange : mUids) { if (uidRange.containsRange(requiredRange)) { @@ -1247,7 +1247,7 @@ public final class NetworkCapabilities implements Parcelable { * NetworkCapabilities apply to. * nc is assumed nonnull. */ - private void combineUids(NetworkCapabilities nc) { + private void combineUids(@NonNull NetworkCapabilities nc) { if (null == nc.mUids || null == mUids) { mUids = null; return; @@ -1268,7 +1268,7 @@ public final class NetworkCapabilities implements Parcelable { * Sets the SSID of this network. * @hide */ - public NetworkCapabilities setSSID(String ssid) { + public @NonNull NetworkCapabilities setSSID(@Nullable String ssid) { mSSID = ssid; return this; } @@ -1277,7 +1277,7 @@ public final class NetworkCapabilities implements Parcelable { * Gets the SSID of this network, or null if none or unknown. * @hide */ - public String getSSID() { + public @Nullable String getSSID() { return mSSID; } @@ -1285,7 +1285,7 @@ public final class NetworkCapabilities implements Parcelable { * Tests if the SSID of this network is the same as the SSID of the passed network. * @hide */ - public boolean equalsSSID(NetworkCapabilities nc) { + public boolean equalsSSID(@NonNull NetworkCapabilities nc) { return Objects.equals(mSSID, nc.mSSID); } @@ -1293,7 +1293,7 @@ public final class NetworkCapabilities implements Parcelable { * Check if the SSID requirements of this object are matched by the passed object. * @hide */ - public boolean satisfiedBySSID(NetworkCapabilities nc) { + public boolean satisfiedBySSID(@NonNull NetworkCapabilities nc) { return mSSID == null || mSSID.equals(nc.mSSID); } @@ -1304,7 +1304,7 @@ public final class NetworkCapabilities implements Parcelable { * equal. * @hide */ - private void combineSSIDs(NetworkCapabilities nc) { + private void combineSSIDs(@NonNull NetworkCapabilities nc) { if (mSSID != null && !mSSID.equals(nc.mSSID)) { throw new IllegalStateException("Can't combine two SSIDs"); } @@ -1319,7 +1319,7 @@ public final class NetworkCapabilities implements Parcelable { * both lists will never be satisfied. * @hide */ - public void combineCapabilities(NetworkCapabilities nc) { + public void combineCapabilities(@NonNull NetworkCapabilities nc) { combineNetCapabilities(nc); combineTransportTypes(nc); combineLinkBandwidths(nc); @@ -1359,7 +1359,7 @@ public final class NetworkCapabilities implements Parcelable { */ @TestApi @SystemApi - public boolean satisfiedByNetworkCapabilities(NetworkCapabilities nc) { + public boolean satisfiedByNetworkCapabilities(@Nullable NetworkCapabilities nc) { return satisfiedByNetworkCapabilities(nc, false); } @@ -1370,7 +1370,7 @@ public final class NetworkCapabilities implements Parcelable { * * @hide */ - public boolean satisfiedByImmutableNetworkCapabilities(NetworkCapabilities nc) { + public boolean satisfiedByImmutableNetworkCapabilities(@Nullable NetworkCapabilities nc) { return satisfiedByNetworkCapabilities(nc, true); } @@ -1381,7 +1381,7 @@ public final class NetworkCapabilities implements Parcelable { * * @hide */ - public String describeImmutableDifferences(NetworkCapabilities that) { + public String describeImmutableDifferences(@Nullable NetworkCapabilities that) { if (that == null) { return "other NetworkCapabilities was null"; } @@ -1420,7 +1420,7 @@ public final class NetworkCapabilities implements Parcelable { * * @hide */ - public boolean equalRequestableCapabilities(NetworkCapabilities nc) { + public boolean equalRequestableCapabilities(@Nullable NetworkCapabilities nc) { if (nc == null) return false; return (equalsNetCapabilitiesRequestable(nc) && equalsTransportTypes(nc) && @@ -1428,7 +1428,7 @@ public final class NetworkCapabilities implements Parcelable { } @Override - public boolean equals(Object obj) { + public boolean equals(@Nullable Object obj) { if (obj == null || (obj instanceof NetworkCapabilities == false)) return false; NetworkCapabilities that = (NetworkCapabilities) obj; return (equalsNetCapabilities(that) @@ -1502,7 +1502,7 @@ public final class NetworkCapabilities implements Parcelable { }; @Override - public String toString() { + public @NonNull String toString() { final StringBuilder sb = new StringBuilder("["); if (0 != mTransportTypes) { sb.append(" Transports: "); @@ -1561,8 +1561,8 @@ public final class NetworkCapabilities implements Parcelable { /** * @hide */ - public static void appendStringRepresentationOfBitMaskToStringBuilder(StringBuilder sb, - long bitMask, NameOf nameFetcher, String separator) { + public static void appendStringRepresentationOfBitMaskToStringBuilder(@NonNull StringBuilder sb, + long bitMask, @NonNull NameOf nameFetcher, @NonNull String separator) { int bitPos = 0; boolean firstElementAdded = false; while (bitMask != 0) { @@ -1580,7 +1580,7 @@ public final class NetworkCapabilities implements Parcelable { } /** @hide */ - public void writeToProto(ProtoOutputStream proto, long fieldId) { + public void writeToProto(@NonNull ProtoOutputStream proto, long fieldId) { final long token = proto.start(fieldId); for (int transport : getTransportTypes()) { @@ -1610,7 +1610,7 @@ public final class NetworkCapabilities implements Parcelable { /** * @hide */ - public static String capabilityNamesOf(@NetCapability int[] capabilities) { + public static @NonNull String capabilityNamesOf(@Nullable @NetCapability int[] capabilities) { StringJoiner joiner = new StringJoiner("|"); if (capabilities != null) { for (int c : capabilities) { @@ -1623,7 +1623,7 @@ public final class NetworkCapabilities implements Parcelable { /** * @hide */ - public static String capabilityNameOf(@NetCapability int capability) { + public static @NonNull String capabilityNameOf(@NetCapability int capability) { switch (capability) { case NET_CAPABILITY_MMS: return "MMS"; case NET_CAPABILITY_SUPL: return "SUPL"; @@ -1658,7 +1658,7 @@ public final class NetworkCapabilities implements Parcelable { * @hide */ @UnsupportedAppUsage - public static String transportNamesOf(@Transport int[] types) { + public static @NonNull String transportNamesOf(@Nullable @Transport int[] types) { StringJoiner joiner = new StringJoiner("|"); if (types != null) { for (int t : types) { @@ -1671,7 +1671,7 @@ public final class NetworkCapabilities implements Parcelable { /** * @hide */ - public static String transportNameOf(@Transport int transport) { + public static @NonNull String transportNameOf(@Transport int transport) { if (!isValidTransport(transport)) { return "UNKNOWN"; } diff --git a/core/java/android/net/NetworkInfo.java b/core/java/android/net/NetworkInfo.java index 89d99617dfbf..8fb5a202fe03 100644 --- a/core/java/android/net/NetworkInfo.java +++ b/core/java/android/net/NetworkInfo.java @@ -16,6 +16,7 @@ package android.net; +import android.annotation.NonNull; import android.annotation.UnsupportedAppUsage; import android.os.Parcel; import android.os.Parcelable; @@ -138,7 +139,9 @@ public class NetworkInfo implements Parcelable { private int mSubtype; private String mTypeName; private String mSubtypeName; + @NonNull private State mState; + @NonNull private DetailedState mDetailedState; private String mReason; private String mExtraInfo; @@ -451,7 +454,7 @@ public class NetworkInfo implements Parcelable { * the device and let apps react more easily and quickly to changes. */ @Deprecated - public DetailedState getDetailedState() { + public @NonNull DetailedState getDetailedState() { synchronized (this) { return mDetailedState; } diff --git a/core/java/android/net/NetworkRequest.java b/core/java/android/net/NetworkRequest.java index 9508217be53f..3a41a079dad0 100644 --- a/core/java/android/net/NetworkRequest.java +++ b/core/java/android/net/NetworkRequest.java @@ -347,7 +347,7 @@ public class NetworkRequest implements Parcelable { * @hide */ @SystemApi - public Builder setSignalStrength(int signalStrength) { + public @NonNull Builder setSignalStrength(int signalStrength) { mNetworkCapabilities.setSignalStrength(signalStrength); return this; } diff --git a/core/java/android/net/NetworkUtils.java b/core/java/android/net/NetworkUtils.java index 0ae29b125149..d2d886ba9a7f 100644 --- a/core/java/android/net/NetworkUtils.java +++ b/core/java/android/net/NetworkUtils.java @@ -172,6 +172,12 @@ public class NetworkUtils { public static native byte[] resNetworkResult(FileDescriptor fd) throws ErrnoException; /** + * DNS resolver series jni method. + * Attempts to cancel the in-progress query associated with the {@code fd}. + */ + public static native void resNetworkCancel(FileDescriptor fd); + + /** * Add an entry into the ARP cache. */ public static void addArpEntry(Inet4Address ipv4Addr, MacAddress ethAddr, String ifname, diff --git a/core/java/android/net/RouteInfo.java b/core/java/android/net/RouteInfo.java index 5c0f7582091d..24d9b8e2c1b0 100644 --- a/core/java/android/net/RouteInfo.java +++ b/core/java/android/net/RouteInfo.java @@ -16,6 +16,7 @@ package android.net; +import android.annotation.Nullable; import android.annotation.SystemApi; import android.annotation.TestApi; import android.annotation.UnsupportedAppUsage; @@ -112,7 +113,8 @@ public final class RouteInfo implements Parcelable { */ @SystemApi @TestApi - public RouteInfo(IpPrefix destination, InetAddress gateway, String iface, int type) { + public RouteInfo(@Nullable IpPrefix destination, @Nullable InetAddress gateway, + @Nullable String iface, int type) { switch (type) { case RTN_UNICAST: case RTN_UNREACHABLE: diff --git a/core/java/android/net/SocketKeepalive.java b/core/java/android/net/SocketKeepalive.java index 0e768dfc8eb9..9d91620bdf96 100644 --- a/core/java/android/net/SocketKeepalive.java +++ b/core/java/android/net/SocketKeepalive.java @@ -21,8 +21,10 @@ import android.annotation.IntRange; import android.annotation.NonNull; import android.annotation.Nullable; import android.os.Binder; +import android.os.ParcelFileDescriptor; import android.os.RemoteException; +import java.io.IOException; import java.lang.annotation.Retention; import java.lang.annotation.RetentionPolicy; import java.util.concurrent.Executor; @@ -73,10 +75,15 @@ public abstract class SocketKeepalive implements AutoCloseable { /** The target socket is not idle. */ public static final int ERROR_SOCKET_NOT_IDLE = -26; - /** The hardware does not support this request. */ - public static final int ERROR_HARDWARE_UNSUPPORTED = -30; + /** The device does not support this request. */ + public static final int ERROR_UNSUPPORTED = -30; + /** @hide TODO: delete when telephony code has been updated. */ + public static final int ERROR_HARDWARE_UNSUPPORTED = ERROR_UNSUPPORTED; /** The hardware returned an error. */ public static final int ERROR_HARDWARE_ERROR = -31; + /** The limitation of resource is reached. */ + public static final int ERROR_INSUFFICIENT_RESOURCES = -32; + /** @hide */ @Retention(RetentionPolicy.SOURCE) @@ -147,15 +154,18 @@ public abstract class SocketKeepalive implements AutoCloseable { @NonNull final IConnectivityManager mService; @NonNull final Network mNetwork; + @NonNull final ParcelFileDescriptor mPfd; @NonNull final Executor mExecutor; @NonNull final ISocketKeepaliveCallback mCallback; // TODO: remove slot since mCallback could be used to identify which keepalive to stop. @Nullable Integer mSlot; SocketKeepalive(@NonNull IConnectivityManager service, @NonNull Network network, + @NonNull ParcelFileDescriptor pfd, @NonNull Executor executor, @NonNull Callback callback) { mService = service; mNetwork = network; + mPfd = pfd; mExecutor = executor; mCallback = new ISocketKeepaliveCallback.Stub() { @Override @@ -233,6 +243,11 @@ public abstract class SocketKeepalive implements AutoCloseable { @Override public final void close() { stop(); + try { + mPfd.close(); + } catch (IOException e) { + // Nothing much can be done. + } } /** diff --git a/core/java/android/net/StaticIpConfigurationParcelable.aidl b/core/java/android/net/StaticIpConfiguration.aidl index 6fffb423edb5..8aac701fe7e1 100644 --- a/core/java/android/net/StaticIpConfigurationParcelable.aidl +++ b/core/java/android/net/StaticIpConfiguration.aidl @@ -17,11 +17,4 @@ package android.net; -import android.net.LinkAddress; - -parcelable StaticIpConfigurationParcelable { - LinkAddress ipAddress; - String gateway; - String[] dnsServers; - String domains; -} +@JavaOnlyStableParcelable parcelable StaticIpConfiguration;
\ No newline at end of file diff --git a/core/java/android/net/StaticIpConfiguration.java b/core/java/android/net/StaticIpConfiguration.java index 99cf3a99f57a..14dbca0183f0 100644 --- a/core/java/android/net/StaticIpConfiguration.java +++ b/core/java/android/net/StaticIpConfiguration.java @@ -16,6 +16,8 @@ package android.net; +import android.annotation.NonNull; +import android.annotation.Nullable; import android.annotation.SystemApi; import android.annotation.TestApi; import android.annotation.UnsupportedAppUsage; @@ -53,22 +55,26 @@ import java.util.Objects; public final class StaticIpConfiguration implements Parcelable { /** @hide */ @UnsupportedAppUsage + @Nullable public LinkAddress ipAddress; /** @hide */ @UnsupportedAppUsage + @Nullable public InetAddress gateway; /** @hide */ @UnsupportedAppUsage + @NonNull public final ArrayList<InetAddress> dnsServers; /** @hide */ @UnsupportedAppUsage + @Nullable public String domains; public StaticIpConfiguration() { dnsServers = new ArrayList<InetAddress>(); } - public StaticIpConfiguration(StaticIpConfiguration source) { + public StaticIpConfiguration(@Nullable StaticIpConfiguration source) { this(); if (source != null) { // All of these except dnsServers are immutable, so no need to make copies. @@ -86,38 +92,38 @@ public final class StaticIpConfiguration implements Parcelable { domains = null; } - public LinkAddress getIpAddress() { + public @Nullable LinkAddress getIpAddress() { return ipAddress; } - public void setIpAddress(LinkAddress ipAddress) { + public void setIpAddress(@Nullable LinkAddress ipAddress) { this.ipAddress = ipAddress; } - public InetAddress getGateway() { + public @Nullable InetAddress getGateway() { return gateway; } - public void setGateway(InetAddress gateway) { + public void setGateway(@Nullable InetAddress gateway) { this.gateway = gateway; } - public List<InetAddress> getDnsServers() { + public @NonNull List<InetAddress> getDnsServers() { return dnsServers; } - public String getDomains() { + public @Nullable String getDomains() { return domains; } - public void setDomains(String newDomains) { + public void setDomains(@Nullable String newDomains) { domains = newDomains; } /** * Add a DNS server to this configuration. */ - public void addDnsServer(InetAddress server) { + public void addDnsServer(@NonNull InetAddress server) { dnsServers.add(server); } @@ -128,7 +134,7 @@ public final class StaticIpConfiguration implements Parcelable { * route to the gateway as well. This configuration is arguably invalid, but it used to work * in K and earlier, and other OSes appear to accept it. */ - public List<RouteInfo> getRoutes(String iface) { + public @NonNull List<RouteInfo> getRoutes(@Nullable String iface) { List<RouteInfo> routes = new ArrayList<RouteInfo>(3); if (ipAddress != null) { RouteInfo connectedRoute = new RouteInfo(ipAddress, null, iface); @@ -150,7 +156,7 @@ public final class StaticIpConfiguration implements Parcelable { * IPv6 configuration) will not be included. * @hide */ - public LinkProperties toLinkProperties(String iface) { + public @NonNull LinkProperties toLinkProperties(String iface) { LinkProperties lp = new LinkProperties(); lp.setInterfaceName(iface); if (ipAddress != null) { diff --git a/core/java/android/net/TcpSocketKeepalive.java b/core/java/android/net/TcpSocketKeepalive.java index 26cc8ff181b2..436397ea7754 100644 --- a/core/java/android/net/TcpSocketKeepalive.java +++ b/core/java/android/net/TcpSocketKeepalive.java @@ -17,25 +17,22 @@ package android.net; import android.annotation.NonNull; +import android.os.ParcelFileDescriptor; import android.os.RemoteException; import android.util.Log; import java.io.FileDescriptor; -import java.net.Socket; import java.util.concurrent.Executor; /** @hide */ final class TcpSocketKeepalive extends SocketKeepalive { - private final Socket mSocket; - TcpSocketKeepalive(@NonNull IConnectivityManager service, @NonNull Network network, - @NonNull Socket socket, + @NonNull ParcelFileDescriptor pfd, @NonNull Executor executor, @NonNull Callback callback) { - super(service, network, executor, callback); - mSocket = socket; + super(service, network, pfd, executor, callback); } /** @@ -57,7 +54,7 @@ final class TcpSocketKeepalive extends SocketKeepalive { void startImpl(int intervalSec) { mExecutor.execute(() -> { try { - final FileDescriptor fd = mSocket.getFileDescriptor$(); + final FileDescriptor fd = mPfd.getFileDescriptor(); mService.startTcpKeepalive(mNetwork, fd, intervalSec, mCallback); } catch (RemoteException e) { Log.e(TAG, "Error starting packet keepalive: ", e); diff --git a/core/java/android/net/UidRange.java b/core/java/android/net/UidRange.java index 793c82dc68e1..fa0eeb9e0e49 100644 --- a/core/java/android/net/UidRange.java +++ b/core/java/android/net/UidRange.java @@ -19,14 +19,17 @@ package android.net; import static android.os.UserHandle.PER_USER_RANGE; import android.os.Parcel; +import android.os.Parcelable; /** * An inclusive range of UIDs. * * @hide */ -public final class UidRange extends UidRangeParcel { - private UidRange() {} +public final class UidRange implements Parcelable { + public final int start; + public final int stop; + public UidRange(int startUid, int stopUid) { if (startUid < 0) throw new IllegalArgumentException("Invalid start UID."); if (stopUid < 0) throw new IllegalArgumentException("Invalid stop UID."); @@ -86,18 +89,28 @@ public final class UidRange extends UidRangeParcel { return start + "-" + stop; } - /** - * DO NOT override "writeToParcel" and "readFromParcel" in this class. - * The parceling code is autogenerated by the superclass. - */ + // Implement the Parcelable interface + // TODO: Consider making this class no longer parcelable, since all users are likely in the + // system server. + @Override + public int describeContents() { + return 0; + } + + @Override + public void writeToParcel(Parcel dest, int flags) { + dest.writeInt(start); + dest.writeInt(stop); + } public static final Creator<UidRange> CREATOR = new Creator<UidRange>() { @Override public UidRange createFromParcel(Parcel in) { - UidRange obj = new UidRange(); - obj.readFromParcel(in); - return obj; + int start = in.readInt(); + int stop = in.readInt(); + + return new UidRange(start, stop); } @Override public UidRange[] newArray(int size) { diff --git a/core/java/android/net/apf/ApfCapabilities.aidl b/core/java/android/net/apf/ApfCapabilities.aidl new file mode 100644 index 000000000000..7c4d4c2da4bc --- /dev/null +++ b/core/java/android/net/apf/ApfCapabilities.aidl @@ -0,0 +1,20 @@ +/* +** +** 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. +*/ + +package android.net.apf; + +@JavaOnlyStableParcelable parcelable ApfCapabilities;
\ No newline at end of file diff --git a/core/java/android/net/apf/ApfCapabilities.java b/core/java/android/net/apf/ApfCapabilities.java index e09fa8fd9e77..17a03c7c8933 100644 --- a/core/java/android/net/apf/ApfCapabilities.java +++ b/core/java/android/net/apf/ApfCapabilities.java @@ -16,20 +16,24 @@ package android.net.apf; +import android.annotation.NonNull; import android.annotation.SystemApi; import android.annotation.TestApi; import android.content.Context; +import android.os.Parcel; +import android.os.Parcelable; import com.android.internal.R; /** * APF program support capabilities. * + * This class is immutable. * @hide */ @SystemApi @TestApi -public class ApfCapabilities { +public final class ApfCapabilities implements Parcelable { /** * Version of APF instruction set supported for packet filtering. 0 indicates no support for * packet filtering using APF programs. @@ -53,6 +57,37 @@ public class ApfCapabilities { this.apfPacketFormat = apfPacketFormat; } + private ApfCapabilities(Parcel in) { + apfVersionSupported = in.readInt(); + maximumApfProgramSize = in.readInt(); + apfPacketFormat = in.readInt(); + } + + + @Override + public int describeContents() { + return 0; + } + + @Override + public void writeToParcel(Parcel dest, int flags) { + dest.writeInt(apfVersionSupported); + dest.writeInt(maximumApfProgramSize); + dest.writeInt(apfPacketFormat); + } + + public static final Creator<ApfCapabilities> CREATOR = new Creator<ApfCapabilities>() { + @Override + public ApfCapabilities createFromParcel(Parcel in) { + return new ApfCapabilities(in); + } + + @Override + public ApfCapabilities[] newArray(int size) { + return new ApfCapabilities[size]; + } + }; + @Override public String toString() { return String.format("%s{version: %d, maxSize: %d, format: %d}", getClass().getSimpleName(), @@ -81,14 +116,14 @@ public class ApfCapabilities { /** * @return Whether the APF Filter in the device should filter out IEEE 802.3 Frames. */ - public static boolean getApfDrop8023Frames(Context context) { + public static boolean getApfDrop8023Frames(@NonNull Context context) { return context.getResources().getBoolean(R.bool.config_apfDrop802_3Frames); } /** * @return An array of blacklisted EtherType, packets with EtherTypes within it will be dropped. */ - public static int[] getApfEthTypeBlackList(Context context) { + public static @NonNull int[] getApfEthTypeBlackList(@NonNull Context context) { return context.getResources().getIntArray(R.array.config_apfEthTypeBlackList); } } diff --git a/core/java/android/net/captiveportal/CaptivePortalProbeResult.java b/core/java/android/net/captiveportal/CaptivePortalProbeResult.java index 3930344e5d27..a1d3de248a96 100644 --- a/core/java/android/net/captiveportal/CaptivePortalProbeResult.java +++ b/core/java/android/net/captiveportal/CaptivePortalProbeResult.java @@ -16,6 +16,7 @@ package android.net.captiveportal; +import android.annotation.NonNull; import android.annotation.Nullable; import android.annotation.SystemApi; import android.annotation.TestApi; @@ -39,14 +40,18 @@ public final class CaptivePortalProbeResult { */ public static final int PARTIAL_CODE = -1; + @NonNull public static final CaptivePortalProbeResult FAILED = new CaptivePortalProbeResult(FAILED_CODE); + @NonNull public static final CaptivePortalProbeResult SUCCESS = new CaptivePortalProbeResult(SUCCESS_CODE); public static final CaptivePortalProbeResult PARTIAL = new CaptivePortalProbeResult(PARTIAL_CODE); private final int mHttpResponseCode; // HTTP response code returned from Internet probe. + @Nullable public final String redirectUrl; // Redirect destination returned from Internet probe. + @Nullable public final String detectUrl; // URL where a 204 response code indicates // captive portal has been appeased. @Nullable @@ -56,12 +61,13 @@ public final class CaptivePortalProbeResult { this(httpResponseCode, null, null); } - public CaptivePortalProbeResult(int httpResponseCode, String redirectUrl, String detectUrl) { + public CaptivePortalProbeResult(int httpResponseCode, @Nullable String redirectUrl, + @Nullable String detectUrl) { this(httpResponseCode, redirectUrl, detectUrl, null); } - public CaptivePortalProbeResult(int httpResponseCode, String redirectUrl, String detectUrl, - CaptivePortalProbeSpec probeSpec) { + public CaptivePortalProbeResult(int httpResponseCode, @Nullable String redirectUrl, + @Nullable String detectUrl, @Nullable CaptivePortalProbeSpec probeSpec) { mHttpResponseCode = httpResponseCode; this.redirectUrl = redirectUrl; this.detectUrl = detectUrl; diff --git a/core/java/android/net/captiveportal/CaptivePortalProbeSpec.java b/core/java/android/net/captiveportal/CaptivePortalProbeSpec.java index 7ad4ecf2264c..6c6a16c4534e 100644 --- a/core/java/android/net/captiveportal/CaptivePortalProbeSpec.java +++ b/core/java/android/net/captiveportal/CaptivePortalProbeSpec.java @@ -19,6 +19,8 @@ package android.net.captiveportal; import static android.net.captiveportal.CaptivePortalProbeResult.PORTAL_CODE; import static android.net.captiveportal.CaptivePortalProbeResult.SUCCESS_CODE; +import static com.android.internal.util.Preconditions.checkNotNull; + import android.annotation.NonNull; import android.annotation.Nullable; import android.annotation.SystemApi; @@ -48,9 +50,10 @@ public abstract class CaptivePortalProbeSpec { private final String mEncodedSpec; private final URL mUrl; - CaptivePortalProbeSpec(String encodedSpec, URL url) { - mEncodedSpec = encodedSpec; - mUrl = url; + CaptivePortalProbeSpec(@NonNull String encodedSpec, @NonNull URL url) + throws NullPointerException { + mEncodedSpec = checkNotNull(encodedSpec); + mUrl = checkNotNull(url); } /** @@ -64,7 +67,7 @@ public abstract class CaptivePortalProbeSpec { */ @VisibleForTesting @NonNull - public static CaptivePortalProbeSpec parseSpec(String spec) throws ParseException, + public static CaptivePortalProbeSpec parseSpec(@NonNull String spec) throws ParseException, MalformedURLException { if (TextUtils.isEmpty(spec)) { throw new ParseException("Empty probe spec", 0 /* errorOffset */); @@ -84,7 +87,8 @@ public abstract class CaptivePortalProbeSpec { } @Nullable - private static Pattern parsePatternIfNonEmpty(String pattern, int pos) throws ParseException { + private static Pattern parsePatternIfNonEmpty(@Nullable String pattern, int pos) + throws ParseException { if (TextUtils.isEmpty(pattern)) { return null; } @@ -120,8 +124,9 @@ public abstract class CaptivePortalProbeSpec { * <p>Each spec is separated by @@,@@ and follows the format for {@link #parseSpec(String)}. * <p>This method does not throw but ignores any entry that could not be parsed. */ + @NonNull public static Collection<CaptivePortalProbeSpec> parseCaptivePortalProbeSpecs( - String settingsVal) { + @NonNull String settingsVal) { List<CaptivePortalProbeSpec> specs = new ArrayList<>(); if (settingsVal != null) { for (String spec : TextUtils.split(settingsVal, SPEC_SEPARATOR)) { @@ -142,12 +147,15 @@ public abstract class CaptivePortalProbeSpec { /** * Get the probe result from HTTP status and location header. */ + @NonNull public abstract CaptivePortalProbeResult getResult(int status, @Nullable String locationHeader); + @NonNull public String getEncodedSpec() { return mEncodedSpec; } + @NonNull public URL getUrl() { return mUrl; } diff --git a/core/java/android/net/metrics/ApfProgramEvent.java b/core/java/android/net/metrics/ApfProgramEvent.java index 8601005c8af4..30d3b84c978c 100644 --- a/core/java/android/net/metrics/ApfProgramEvent.java +++ b/core/java/android/net/metrics/ApfProgramEvent.java @@ -17,6 +17,7 @@ package android.net.metrics; import android.annotation.IntDef; +import android.annotation.NonNull; import android.annotation.SystemApi; import android.annotation.TestApi; import android.annotation.UnsupportedAppUsage; @@ -95,7 +96,7 @@ public final class ApfProgramEvent implements IpConnectivityLog.Event { /** * Utility to create an instance of {@link ApfProgramEvent}. */ - public static class Builder { + public static final class Builder { private long mLifetime; private long mActualLifetime; private int mFilteredRas; @@ -106,6 +107,7 @@ public final class ApfProgramEvent implements IpConnectivityLog.Event { /** * Set the maximum computed lifetime of the program in seconds. */ + @NonNull public Builder setLifetime(long lifetime) { mLifetime = lifetime; return this; @@ -114,6 +116,7 @@ public final class ApfProgramEvent implements IpConnectivityLog.Event { /** * Set the effective program lifetime in seconds. */ + @NonNull public Builder setActualLifetime(long lifetime) { mActualLifetime = lifetime; return this; @@ -122,6 +125,7 @@ public final class ApfProgramEvent implements IpConnectivityLog.Event { /** * Set the number of RAs filtered by the APF program. */ + @NonNull public Builder setFilteredRas(int filteredRas) { mFilteredRas = filteredRas; return this; @@ -130,6 +134,7 @@ public final class ApfProgramEvent implements IpConnectivityLog.Event { /** * Set the total number of current RAs at generation time. */ + @NonNull public Builder setCurrentRas(int currentRas) { mCurrentRas = currentRas; return this; @@ -138,6 +143,7 @@ public final class ApfProgramEvent implements IpConnectivityLog.Event { /** * Set the length of the APF program in bytes. */ + @NonNull public Builder setProgramLength(int programLength) { mProgramLength = programLength; return this; @@ -146,6 +152,7 @@ public final class ApfProgramEvent implements IpConnectivityLog.Event { /** * Set the flags describing what an Apf program filters. */ + @NonNull public Builder setFlags(boolean hasIPv4, boolean multicastFilterOn) { mFlags = flagsFor(hasIPv4, multicastFilterOn); return this; @@ -154,6 +161,7 @@ public final class ApfProgramEvent implements IpConnectivityLog.Event { /** * Build a new {@link ApfProgramEvent}. */ + @NonNull public ApfProgramEvent build() { return new ApfProgramEvent(mLifetime, mActualLifetime, mFilteredRas, mCurrentRas, mProgramLength, mFlags); diff --git a/core/java/android/net/metrics/ApfStats.java b/core/java/android/net/metrics/ApfStats.java index 844a1342a7fa..ddc788dba649 100644 --- a/core/java/android/net/metrics/ApfStats.java +++ b/core/java/android/net/metrics/ApfStats.java @@ -16,6 +16,7 @@ package android.net.metrics; +import android.annotation.NonNull; import android.annotation.SystemApi; import android.annotation.TestApi; import android.annotation.UnsupportedAppUsage; @@ -125,7 +126,7 @@ public final class ApfStats implements IpConnectivityLog.Event { */ @SystemApi @TestApi - public static class Builder { + public static final class Builder { private long mDurationMs; private int mReceivedRas; private int mMatchingRas; @@ -140,6 +141,7 @@ public final class ApfStats implements IpConnectivityLog.Event { /** * Set the time interval in milliseconds these statistics covers. */ + @NonNull public Builder setDurationMs(long durationMs) { mDurationMs = durationMs; return this; @@ -148,6 +150,7 @@ public final class ApfStats implements IpConnectivityLog.Event { /** * Set the number of received RAs. */ + @NonNull public Builder setReceivedRas(int receivedRas) { mReceivedRas = receivedRas; return this; @@ -156,6 +159,7 @@ public final class ApfStats implements IpConnectivityLog.Event { /** * Set the number of received RAs matching a known RA. */ + @NonNull public Builder setMatchingRas(int matchingRas) { mMatchingRas = matchingRas; return this; @@ -164,6 +168,7 @@ public final class ApfStats implements IpConnectivityLog.Event { /** * Set the number of received RAs ignored due to the MAX_RAS limit. */ + @NonNull public Builder setDroppedRas(int droppedRas) { mDroppedRas = droppedRas; return this; @@ -172,6 +177,7 @@ public final class ApfStats implements IpConnectivityLog.Event { /** * Set the number of received RAs with a minimum lifetime of 0. */ + @NonNull public Builder setZeroLifetimeRas(int zeroLifetimeRas) { mZeroLifetimeRas = zeroLifetimeRas; return this; @@ -180,6 +186,7 @@ public final class ApfStats implements IpConnectivityLog.Event { /** * Set the number of received RAs that could not be parsed. */ + @NonNull public Builder setParseErrors(int parseErrors) { mParseErrors = parseErrors; return this; @@ -188,6 +195,7 @@ public final class ApfStats implements IpConnectivityLog.Event { /** * Set the number of APF program updates from receiving RAs. */ + @NonNull public Builder setProgramUpdates(int programUpdates) { mProgramUpdates = programUpdates; return this; @@ -196,6 +204,7 @@ public final class ApfStats implements IpConnectivityLog.Event { /** * Set the total number of APF program updates. */ + @NonNull public Builder setProgramUpdatesAll(int programUpdatesAll) { mProgramUpdatesAll = programUpdatesAll; return this; @@ -204,6 +213,7 @@ public final class ApfStats implements IpConnectivityLog.Event { /** * Set the number of APF program updates from allowing multicast traffic. */ + @NonNull public Builder setProgramUpdatesAllowingMulticast(int programUpdatesAllowingMulticast) { mProgramUpdatesAllowingMulticast = programUpdatesAllowingMulticast; return this; @@ -212,6 +222,7 @@ public final class ApfStats implements IpConnectivityLog.Event { /** * Set the maximum APF program size advertised by hardware. */ + @NonNull public Builder setMaxProgramSize(int maxProgramSize) { mMaxProgramSize = maxProgramSize; return this; @@ -220,6 +231,7 @@ public final class ApfStats implements IpConnectivityLog.Event { /** * Create a new {@link ApfStats}. */ + @NonNull public ApfStats build() { return new ApfStats(mDurationMs, mReceivedRas, mMatchingRas, mDroppedRas, mZeroLifetimeRas, mParseErrors, mProgramUpdates, mProgramUpdatesAll, diff --git a/core/java/android/net/metrics/DhcpClientEvent.java b/core/java/android/net/metrics/DhcpClientEvent.java index 3008115e063b..93063cbe09a4 100644 --- a/core/java/android/net/metrics/DhcpClientEvent.java +++ b/core/java/android/net/metrics/DhcpClientEvent.java @@ -16,6 +16,7 @@ package android.net.metrics; +import android.annotation.NonNull; import android.annotation.SystemApi; import android.annotation.TestApi; import android.annotation.UnsupportedAppUsage; @@ -51,13 +52,14 @@ public final class DhcpClientEvent implements IpConnectivityLog.Event { /** * Utility to create an instance of {@link ApfProgramEvent}. */ - public static class Builder { + public static final class Builder { private String mMsg; private int mDurationMs; /** * Set the message of the event. */ + @NonNull public Builder setMsg(String msg) { mMsg = msg; return this; @@ -66,6 +68,7 @@ public final class DhcpClientEvent implements IpConnectivityLog.Event { /** * Set the duration of the event in milliseconds. */ + @NonNull public Builder setDurationMs(int durationMs) { mDurationMs = durationMs; return this; @@ -74,6 +77,7 @@ public final class DhcpClientEvent implements IpConnectivityLog.Event { /** * Create a new {@link DhcpClientEvent}. */ + @NonNull public DhcpClientEvent build() { return new DhcpClientEvent(mMsg, mDurationMs); } diff --git a/core/java/android/net/metrics/DhcpErrorEvent.java b/core/java/android/net/metrics/DhcpErrorEvent.java index 18fde80b69b0..84823464a093 100644 --- a/core/java/android/net/metrics/DhcpErrorEvent.java +++ b/core/java/android/net/metrics/DhcpErrorEvent.java @@ -37,27 +37,6 @@ public final class DhcpErrorEvent implements IpConnectivityLog.Event { public static final int DHCP_ERROR = 4; public static final int MISC_ERROR = 5; - public static final int L2_TOO_SHORT = makeErrorCode(L2_ERROR, 1); - public static final int L2_WRONG_ETH_TYPE = makeErrorCode(L2_ERROR, 2); - - public static final int L3_TOO_SHORT = makeErrorCode(L3_ERROR, 1); - public static final int L3_NOT_IPV4 = makeErrorCode(L3_ERROR, 2); - public static final int L3_INVALID_IP = makeErrorCode(L3_ERROR, 3); - - public static final int L4_NOT_UDP = makeErrorCode(L4_ERROR, 1); - public static final int L4_WRONG_PORT = makeErrorCode(L4_ERROR, 2); - - public static final int BOOTP_TOO_SHORT = makeErrorCode(DHCP_ERROR, 1); - public static final int DHCP_BAD_MAGIC_COOKIE = makeErrorCode(DHCP_ERROR, 2); - public static final int DHCP_INVALID_OPTION_LENGTH = makeErrorCode(DHCP_ERROR, 3); - public static final int DHCP_NO_MSG_TYPE = makeErrorCode(DHCP_ERROR, 4); - public static final int DHCP_UNKNOWN_MSG_TYPE = makeErrorCode(DHCP_ERROR, 5); - public static final int DHCP_NO_COOKIE = makeErrorCode(DHCP_ERROR, 6); - - public static final int BUFFER_UNDERFLOW = makeErrorCode(MISC_ERROR, 1); - public static final int RECEIVE_ERROR = makeErrorCode(MISC_ERROR, 2); - public static final int PARSING_ERROR = makeErrorCode(MISC_ERROR, 3); - // error code byte format (MSB to LSB): // byte 0: error type // byte 1: error subtype @@ -66,6 +45,33 @@ public final class DhcpErrorEvent implements IpConnectivityLog.Event { /** @hide */ public final int errorCode; + private static final int L2_ERROR_TYPE = L2_ERROR << 8; + private static final int L3_ERROR_TYPE = L3_ERROR << 8; + private static final int L4_ERROR_TYPE = L4_ERROR << 8; + private static final int DHCP_ERROR_TYPE = DHCP_ERROR << 8; + private static final int MISC_ERROR_TYPE = MISC_ERROR << 8; + + public static final int L2_TOO_SHORT = (L2_ERROR_TYPE | 0x1) << 16; + public static final int L2_WRONG_ETH_TYPE = (L2_ERROR_TYPE | 0x2) << 16; + + public static final int L3_TOO_SHORT = (L3_ERROR_TYPE | 0x1) << 16; + public static final int L3_NOT_IPV4 = (L3_ERROR_TYPE | 0x2) << 16; + public static final int L3_INVALID_IP = (L3_ERROR_TYPE | 0x3) << 16; + + public static final int L4_NOT_UDP = (L4_ERROR_TYPE | 0x1) << 16; + public static final int L4_WRONG_PORT = (L4_ERROR_TYPE | 0x2) << 16; + + public static final int BOOTP_TOO_SHORT = (DHCP_ERROR_TYPE | 0x1) << 16; + public static final int DHCP_BAD_MAGIC_COOKIE = (DHCP_ERROR_TYPE | 0x2) << 16; + public static final int DHCP_INVALID_OPTION_LENGTH = (DHCP_ERROR_TYPE | 0x3) << 16; + public static final int DHCP_NO_MSG_TYPE = (DHCP_ERROR_TYPE | 0x4) << 16; + public static final int DHCP_UNKNOWN_MSG_TYPE = (DHCP_ERROR_TYPE | 0x5) << 16; + public static final int DHCP_NO_COOKIE = (DHCP_ERROR_TYPE | 0x6) << 16; + + public static final int BUFFER_UNDERFLOW = (MISC_ERROR_TYPE | 0x1) << 16; + public static final int RECEIVE_ERROR = (MISC_ERROR_TYPE | 0x2) << 16; + public static final int PARSING_ERROR = (MISC_ERROR_TYPE | 0x3) << 16; + public DhcpErrorEvent(int errorCode) { this.errorCode = errorCode; } @@ -102,10 +108,6 @@ public final class DhcpErrorEvent implements IpConnectivityLog.Event { return (0xFFFF0000 & errorCode) | (0xFF & option); } - private static int makeErrorCode(int type, int subtype) { - return (type << 24) | ((0xFF & subtype) << 16); - } - @Override public String toString() { return String.format("DhcpErrorEvent(%s)", Decoder.constants.get(errorCode)); diff --git a/core/java/android/net/metrics/IpConnectivityLog.java b/core/java/android/net/metrics/IpConnectivityLog.java index 5b5a23578954..680c01573f98 100644 --- a/core/java/android/net/metrics/IpConnectivityLog.java +++ b/core/java/android/net/metrics/IpConnectivityLog.java @@ -16,6 +16,7 @@ package android.net.metrics; +import android.annotation.NonNull; import android.annotation.SystemApi; import android.annotation.TestApi; import android.net.ConnectivityMetricsEvent; @@ -41,7 +42,7 @@ public class IpConnectivityLog { /** @hide */ public static final String SERVICE_NAME = "connmetrics"; - + @NonNull private IIpConnectivityMetrics mService; /** @@ -57,7 +58,7 @@ public class IpConnectivityLog { /** @hide */ @VisibleForTesting - public IpConnectivityLog(IIpConnectivityMetrics service) { + public IpConnectivityLog(@NonNull IIpConnectivityMetrics service) { mService = service; } @@ -83,7 +84,7 @@ public class IpConnectivityLog { * @return true if the event was successfully logged. * @hide */ - public boolean log(ConnectivityMetricsEvent ev) { + public boolean log(@NonNull ConnectivityMetricsEvent ev) { if (!checkLoggerService()) { if (DBG) { Log.d(TAG, SERVICE_NAME + " service was not ready"); @@ -109,7 +110,7 @@ public class IpConnectivityLog { * @param data is a Parcelable instance representing the event. * @return true if the event was successfully logged. */ - public boolean log(long timestamp, Event data) { + public boolean log(long timestamp, @NonNull Event data) { ConnectivityMetricsEvent ev = makeEv(data); ev.timestamp = timestamp; return log(ev); @@ -121,7 +122,7 @@ public class IpConnectivityLog { * @param data is a Parcelable instance representing the event. * @return true if the event was successfully logged. */ - public boolean log(String ifname, Event data) { + public boolean log(@NonNull String ifname, @NonNull Event data) { ConnectivityMetricsEvent ev = makeEv(data); ev.ifname = ifname; return log(ev); @@ -135,7 +136,7 @@ public class IpConnectivityLog { * @param data is a Parcelable instance representing the event. * @return true if the event was successfully logged. */ - public boolean log(Network network, int[] transports, Event data) { + public boolean log(@NonNull Network network, @NonNull int[] transports, @NonNull Event data) { return log(network.netId, transports, data); } @@ -147,7 +148,7 @@ public class IpConnectivityLog { * @param data is a Parcelable instance representing the event. * @return true if the event was successfully logged. */ - public boolean log(int netid, int[] transports, Event data) { + public boolean log(int netid, @NonNull int[] transports, @NonNull Event data) { ConnectivityMetricsEvent ev = makeEv(data); ev.netId = netid; ev.transports = BitUtils.packBits(transports); @@ -159,7 +160,7 @@ public class IpConnectivityLog { * @param data is a Parcelable instance representing the event. * @return true if the event was successfully logged. */ - public boolean log(Event data) { + public boolean log(@NonNull Event data) { return log(makeEv(data)); } diff --git a/core/java/android/net/metrics/RaEvent.java b/core/java/android/net/metrics/RaEvent.java index 04a2e6e3102c..d16a10432373 100644 --- a/core/java/android/net/metrics/RaEvent.java +++ b/core/java/android/net/metrics/RaEvent.java @@ -16,6 +16,7 @@ package android.net.metrics; +import android.annotation.NonNull; import android.annotation.SystemApi; import android.annotation.TestApi; import android.os.Parcel; @@ -107,7 +108,7 @@ public final class RaEvent implements IpConnectivityLog.Event { } }; - public static class Builder { + public static final class Builder { long routerLifetime = NO_LIFETIME; long prefixValidLifetime = NO_LIFETIME; @@ -119,37 +120,37 @@ public final class RaEvent implements IpConnectivityLog.Event { public Builder() { } - public RaEvent build() { + public @NonNull RaEvent build() { return new RaEvent(routerLifetime, prefixValidLifetime, prefixPreferredLifetime, routeInfoLifetime, rdnssLifetime, dnsslLifetime); } - public Builder updateRouterLifetime(long lifetime) { + public @NonNull Builder updateRouterLifetime(long lifetime) { routerLifetime = updateLifetime(routerLifetime, lifetime); return this; } - public Builder updatePrefixValidLifetime(long lifetime) { + public @NonNull Builder updatePrefixValidLifetime(long lifetime) { prefixValidLifetime = updateLifetime(prefixValidLifetime, lifetime); return this; } - public Builder updatePrefixPreferredLifetime(long lifetime) { + public @NonNull Builder updatePrefixPreferredLifetime(long lifetime) { prefixPreferredLifetime = updateLifetime(prefixPreferredLifetime, lifetime); return this; } - public Builder updateRouteInfoLifetime(long lifetime) { + public @NonNull Builder updateRouteInfoLifetime(long lifetime) { routeInfoLifetime = updateLifetime(routeInfoLifetime, lifetime); return this; } - public Builder updateRdnssLifetime(long lifetime) { + public @NonNull Builder updateRdnssLifetime(long lifetime) { rdnssLifetime = updateLifetime(rdnssLifetime, lifetime); return this; } - public Builder updateDnsslLifetime(long lifetime) { + public @NonNull Builder updateDnsslLifetime(long lifetime) { dnsslLifetime = updateLifetime(dnsslLifetime, lifetime); return this; } diff --git a/core/java/android/net/metrics/ValidationProbeEvent.java b/core/java/android/net/metrics/ValidationProbeEvent.java index a43dc60cec84..ebca7e6d5607 100644 --- a/core/java/android/net/metrics/ValidationProbeEvent.java +++ b/core/java/android/net/metrics/ValidationProbeEvent.java @@ -17,6 +17,7 @@ package android.net.metrics; import android.annotation.IntDef; +import android.annotation.NonNull; import android.annotation.SystemApi; import android.annotation.TestApi; import android.os.Parcel; @@ -81,7 +82,7 @@ public final class ValidationProbeEvent implements IpConnectivityLog.Event { /** * Utility to create an instance of {@link ValidationProbeEvent}. */ - public static class Builder { + public static final class Builder { private long mDurationMs; private int mProbeType; private int mReturnCode; @@ -89,6 +90,7 @@ public final class ValidationProbeEvent implements IpConnectivityLog.Event { /** * Set the duration of the probe in milliseconds. */ + @NonNull public Builder setDurationMs(long durationMs) { mDurationMs = durationMs; return this; @@ -97,6 +99,7 @@ public final class ValidationProbeEvent implements IpConnectivityLog.Event { /** * Set the probe type based on whether it was the first validation. */ + @NonNull public Builder setProbeType(int probeType, boolean firstValidation) { mProbeType = makeProbeType(probeType, firstValidation); return this; @@ -105,6 +108,7 @@ public final class ValidationProbeEvent implements IpConnectivityLog.Event { /** * Set the return code of the probe. */ + @NonNull public Builder setReturnCode(int returnCode) { mReturnCode = returnCode; return this; @@ -113,6 +117,7 @@ public final class ValidationProbeEvent implements IpConnectivityLog.Event { /** * Create a new {@link ValidationProbeEvent}. */ + @NonNull public ValidationProbeEvent build() { return new ValidationProbeEvent(mDurationMs, mProbeType, mReturnCode); } @@ -148,11 +153,14 @@ public final class ValidationProbeEvent implements IpConnectivityLog.Event { return (probeType & 0xff) | (firstValidation ? FIRST_VALIDATION : REVALIDATION); } - public static String getProbeName(int probeType) { + /** + * Get the name of a probe specified by its probe type. + */ + public static @NonNull String getProbeName(int probeType) { return Decoder.constants.get(probeType & 0xff, "PROBE_???"); } - private static String getValidationStage(int probeType) { + private static @NonNull String getValidationStage(int probeType) { return Decoder.constants.get(probeType & 0xff00, "UNKNOWN"); } diff --git a/core/java/android/net/nsd/INsdManager.aidl b/core/java/android/net/nsd/INsdManager.aidl index 3361a7b84b53..9484c74bcb23 100644 --- a/core/java/android/net/nsd/INsdManager.aidl +++ b/core/java/android/net/nsd/INsdManager.aidl @@ -25,6 +25,7 @@ import android.os.Messenger; */ interface INsdManager { + @UnsupportedAppUsage Messenger getMessenger(); void setEnabled(boolean enable); } diff --git a/core/java/android/os/INetworkManagementService.aidl b/core/java/android/os/INetworkManagementService.aidl index f62a999a7d39..6536fc991b30 100644 --- a/core/java/android/os/INetworkManagementService.aidl +++ b/core/java/android/os/INetworkManagementService.aidl @@ -242,27 +242,6 @@ interface INetworkManagementService void tetherLimitReached(ITetheringStatsProvider provider); /** - ** PPPD - **/ - - /** - * Returns the list of currently known TTY devices on the system - */ - String[] listTtys(); - - /** - * Attaches a PPP server daemon to the specified TTY with the specified - * local/remote addresses. - */ - void attachPppd(String tty, String localAddr, String remoteAddr, String dns1Addr, - String dns2Addr); - - /** - * Detaches a PPP server daemon from the specified TTY. - */ - void detachPppd(String tty); - - /** ** DATA USAGE RELATED **/ diff --git a/core/java/android/os/ServiceSpecificException.java b/core/java/android/os/ServiceSpecificException.java index 3b0f26ae8867..03d5d3e195e0 100644 --- a/core/java/android/os/ServiceSpecificException.java +++ b/core/java/android/os/ServiceSpecificException.java @@ -15,6 +15,7 @@ */ package android.os; +import android.annotation.Nullable; import android.annotation.SystemApi; /** @@ -34,7 +35,7 @@ import android.annotation.SystemApi; public class ServiceSpecificException extends RuntimeException { public final int errorCode; - public ServiceSpecificException(int errorCode, String message) { + public ServiceSpecificException(int errorCode, @Nullable String message) { super(message); this.errorCode = errorCode; } diff --git a/core/java/android/preference/PreferenceGroupAdapter.java b/core/java/android/preference/PreferenceGroupAdapter.java index bee45ab0fe32..44754b7378a2 100644 --- a/core/java/android/preference/PreferenceGroupAdapter.java +++ b/core/java/android/preference/PreferenceGroupAdapter.java @@ -20,6 +20,7 @@ import java.util.ArrayList; import java.util.Collections; import java.util.List; +import android.annotation.UnsupportedAppUsage; import android.graphics.drawable.Drawable; import android.os.Handler; import android.preference.Preference.OnPreferenceChangeInternalListener; @@ -208,6 +209,7 @@ public class PreferenceGroupAdapter extends BaseAdapter return mPreferenceList.size(); } + @UnsupportedAppUsage public Preference getItem(int position) { if (position < 0 || position >= getCount()) return null; return mPreferenceList.get(position); diff --git a/core/java/android/security/keymaster/KeymasterBlobArgument.java b/core/java/android/security/keymaster/KeymasterBlobArgument.java index 541d33ef614f..fc562bd2174e 100644 --- a/core/java/android/security/keymaster/KeymasterBlobArgument.java +++ b/core/java/android/security/keymaster/KeymasterBlobArgument.java @@ -16,14 +16,17 @@ package android.security.keymaster; +import android.annotation.UnsupportedAppUsage; import android.os.Parcel; /** * @hide */ class KeymasterBlobArgument extends KeymasterArgument { + @UnsupportedAppUsage public final byte[] blob; + @UnsupportedAppUsage public KeymasterBlobArgument(int tag, byte[] blob) { super(tag); switch (KeymasterDefs.getTagType(tag)) { @@ -36,6 +39,7 @@ class KeymasterBlobArgument extends KeymasterArgument { this.blob = blob; } + @UnsupportedAppUsage public KeymasterBlobArgument(int tag, Parcel in) { super(tag); blob = in.createByteArray(); diff --git a/core/java/android/security/keymaster/KeymasterBooleanArgument.java b/core/java/android/security/keymaster/KeymasterBooleanArgument.java index 67b3281a8a64..4286aa0d4ae3 100644 --- a/core/java/android/security/keymaster/KeymasterBooleanArgument.java +++ b/core/java/android/security/keymaster/KeymasterBooleanArgument.java @@ -16,6 +16,7 @@ package android.security.keymaster; +import android.annotation.UnsupportedAppUsage; import android.os.Parcel; /** @@ -36,6 +37,7 @@ class KeymasterBooleanArgument extends KeymasterArgument { } } + @UnsupportedAppUsage public KeymasterBooleanArgument(int tag, Parcel in) { super(tag); } diff --git a/core/java/android/security/keymaster/KeymasterDateArgument.java b/core/java/android/security/keymaster/KeymasterDateArgument.java index aa15e34e3e86..3e04c1543117 100644 --- a/core/java/android/security/keymaster/KeymasterDateArgument.java +++ b/core/java/android/security/keymaster/KeymasterDateArgument.java @@ -16,6 +16,7 @@ package android.security.keymaster; +import android.annotation.UnsupportedAppUsage; import android.os.Parcel; import java.util.Date; @@ -36,6 +37,7 @@ class KeymasterDateArgument extends KeymasterArgument { this.date = date; } + @UnsupportedAppUsage public KeymasterDateArgument(int tag, Parcel in) { super(tag); date = new Date(in.readLong()); diff --git a/core/java/android/security/keymaster/KeymasterIntArgument.java b/core/java/android/security/keymaster/KeymasterIntArgument.java index 578d2498612d..4aadce458395 100644 --- a/core/java/android/security/keymaster/KeymasterIntArgument.java +++ b/core/java/android/security/keymaster/KeymasterIntArgument.java @@ -16,14 +16,17 @@ package android.security.keymaster; +import android.annotation.UnsupportedAppUsage; import android.os.Parcel; /** * @hide */ class KeymasterIntArgument extends KeymasterArgument { + @UnsupportedAppUsage public final int value; + @UnsupportedAppUsage public KeymasterIntArgument(int tag, int value) { super(tag); switch (KeymasterDefs.getTagType(tag)) { @@ -38,6 +41,7 @@ class KeymasterIntArgument extends KeymasterArgument { this.value = value; } + @UnsupportedAppUsage public KeymasterIntArgument(int tag, Parcel in) { super(tag); value = in.readInt(); diff --git a/core/java/android/security/keymaster/KeymasterLongArgument.java b/core/java/android/security/keymaster/KeymasterLongArgument.java index d3d40ba0cb9d..bc2255e22a69 100644 --- a/core/java/android/security/keymaster/KeymasterLongArgument.java +++ b/core/java/android/security/keymaster/KeymasterLongArgument.java @@ -16,14 +16,17 @@ package android.security.keymaster; +import android.annotation.UnsupportedAppUsage; import android.os.Parcel; /** * @hide */ class KeymasterLongArgument extends KeymasterArgument { + @UnsupportedAppUsage public final long value; + @UnsupportedAppUsage public KeymasterLongArgument(int tag, long value) { super(tag); switch (KeymasterDefs.getTagType(tag)) { @@ -36,6 +39,7 @@ class KeymasterLongArgument extends KeymasterArgument { this.value = value; } + @UnsupportedAppUsage public KeymasterLongArgument(int tag, Parcel in) { super(tag); value = in.readLong(); diff --git a/core/java/android/service/euicc/EuiccService.java b/core/java/android/service/euicc/EuiccService.java index 4f321dc07c2f..4564d3aec001 100644 --- a/core/java/android/service/euicc/EuiccService.java +++ b/core/java/android/service/euicc/EuiccService.java @@ -106,15 +106,27 @@ public abstract class EuiccService extends Service { public static final String ACTION_PROVISION_EMBEDDED_SUBSCRIPTION = "android.service.euicc.action.PROVISION_EMBEDDED_SUBSCRIPTION"; - /** @see android.telephony.euicc.EuiccManager#ACTION_TOGGLE_SUBSCRIPTION_PRIVILEGED */ + /** + * @see android.telephony.euicc.EuiccManager#ACTION_TOGGLE_SUBSCRIPTION_PRIVILEGED. This is + * a protected intent that can only be sent by the system, and requires the + * {@link android.Manifest.permission#BIND_EUICC_SERVICE} permission. + */ public static final String ACTION_TOGGLE_SUBSCRIPTION_PRIVILEGED = "android.service.euicc.action.TOGGLE_SUBSCRIPTION_PRIVILEGED"; - /** @see android.telephony.euicc.EuiccManager#ACTION_DELETE_SUBSCRIPTION_PRIVILEGED */ + /** + * @see android.telephony.euicc.EuiccManager#ACTION_DELETE_SUBSCRIPTION_PRIVILEGED. This is + * a protected intent that can only be sent by the system, and requires the + * {@link android.Manifest.permission#BIND_EUICC_SERVICE} permission. + */ public static final String ACTION_DELETE_SUBSCRIPTION_PRIVILEGED = "android.service.euicc.action.DELETE_SUBSCRIPTION_PRIVILEGED"; - /** @see android.telephony.euicc.EuiccManager#ACTION_RENAME_SUBSCRIPTION_PRIVILEGED */ + /** + * @see android.telephony.euicc.EuiccManager#ACTION_RENAME_SUBSCRIPTION_PRIVILEGED. This is + * a protected intent that can only be sent by the system, and requires the + * {@link android.Manifest.permission#BIND_EUICC_SERVICE} permission. + */ public static final String ACTION_RENAME_SUBSCRIPTION_PRIVILEGED = "android.service.euicc.action.RENAME_SUBSCRIPTION_PRIVILEGED"; diff --git a/core/java/android/service/euicc/GetEuiccProfileInfoListResult.java b/core/java/android/service/euicc/GetEuiccProfileInfoListResult.java index 464d136e70e5..9f2b522db78a 100644 --- a/core/java/android/service/euicc/GetEuiccProfileInfoListResult.java +++ b/core/java/android/service/euicc/GetEuiccProfileInfoListResult.java @@ -97,9 +97,10 @@ public final class GetEuiccProfileInfoListResult implements Parcelable { if (this.result == EuiccService.RESULT_OK) { this.mProfiles = profiles; } else { - if (profiles != null) { + // For error case, profiles is either null or 0 size. + if (profiles != null && profiles.length > 0) { throw new IllegalArgumentException( - "Error result with non-null profiles: " + result); + "Error result with non-empty profiles: " + result); } this.mProfiles = null; } diff --git a/core/java/android/util/XmlPullAttributes.java b/core/java/android/util/XmlPullAttributes.java index cb35eb5c12a3..32fe16fcb2b1 100644 --- a/core/java/android/util/XmlPullAttributes.java +++ b/core/java/android/util/XmlPullAttributes.java @@ -18,6 +18,7 @@ package android.util; import org.xmlpull.v1.XmlPullParser; +import android.annotation.UnsupportedAppUsage; import android.util.AttributeSet; import com.android.internal.util.XmlUtils; @@ -26,6 +27,7 @@ import com.android.internal.util.XmlUtils; * Provides an implementation of AttributeSet on top of an XmlPullParser. */ class XmlPullAttributes implements AttributeSet { + @UnsupportedAppUsage public XmlPullAttributes(XmlPullParser parser) { mParser = parser; } @@ -147,5 +149,6 @@ class XmlPullAttributes implements AttributeSet { return getAttributeResourceValue(null, "style", 0); } + @UnsupportedAppUsage /*package*/ XmlPullParser mParser; } diff --git a/core/java/android/view/accessibility/IAccessibilityInteractionConnectionCallback.aidl b/core/java/android/view/accessibility/IAccessibilityInteractionConnectionCallback.aidl index c1a3ab770989..f96f0acd6082 100644 --- a/core/java/android/view/accessibility/IAccessibilityInteractionConnectionCallback.aidl +++ b/core/java/android/view/accessibility/IAccessibilityInteractionConnectionCallback.aidl @@ -33,6 +33,7 @@ oneway interface IAccessibilityInteractionConnectionCallback { * @param infos The result {@link AccessibilityNodeInfo}. * @param interactionId The interaction id to match the result with the request. */ + @UnsupportedAppUsage void setFindAccessibilityNodeInfoResult(in AccessibilityNodeInfo info, int interactionId); /** @@ -41,6 +42,7 @@ oneway interface IAccessibilityInteractionConnectionCallback { * @param infos The result {@link AccessibilityNodeInfo}s. * @param interactionId The interaction id to match the result with the request. */ + @UnsupportedAppUsage void setFindAccessibilityNodeInfosResult(in List<AccessibilityNodeInfo> infos, int interactionId); @@ -50,5 +52,6 @@ oneway interface IAccessibilityInteractionConnectionCallback { * @param Whether the action was performed. * @param interactionId The interaction id to match the result with the request. */ + @UnsupportedAppUsage void setPerformAccessibilityActionResult(boolean succeeded, int interactionId); } diff --git a/core/java/android/view/accessibility/IAccessibilityManager.aidl b/core/java/android/view/accessibility/IAccessibilityManager.aidl index c93e2c15407b..78bce10ef7aa 100644 --- a/core/java/android/view/accessibility/IAccessibilityManager.aidl +++ b/core/java/android/view/accessibility/IAccessibilityManager.aidl @@ -42,6 +42,7 @@ interface IAccessibilityManager { List<AccessibilityServiceInfo> getInstalledAccessibilityServiceList(int userId); + @UnsupportedAppUsage List<AccessibilityServiceInfo> getEnabledAccessibilityServiceList(int feedbackType, int userId); int addAccessibilityInteractionConnection(IWindow windowToken, diff --git a/core/java/com/android/internal/app/AlertActivity.java b/core/java/com/android/internal/app/AlertActivity.java index 999a908251dd..0b08099b51ed 100644 --- a/core/java/com/android/internal/app/AlertActivity.java +++ b/core/java/com/android/internal/app/AlertActivity.java @@ -16,6 +16,7 @@ package com.android.internal.app; +import android.annotation.UnsupportedAppUsage; import android.app.Activity; import android.app.Dialog; import android.content.DialogInterface; @@ -38,11 +39,13 @@ public abstract class AlertActivity extends Activity implements DialogInterface * * @see #mAlertParams */ + @UnsupportedAppUsage protected AlertController mAlert; /** * The parameters for the alert. */ + @UnsupportedAppUsage protected AlertController.AlertParams mAlertParams; @Override @@ -90,6 +93,7 @@ public abstract class AlertActivity extends Activity implements DialogInterface * @see #mAlert * @see #mAlertParams */ + @UnsupportedAppUsage protected void setupAlert() { mAlert.installContent(mAlertParams); } diff --git a/core/java/com/android/internal/app/AssistUtils.java b/core/java/com/android/internal/app/AssistUtils.java index fed0a89a4d75..9ae614982fb5 100644 --- a/core/java/com/android/internal/app/AssistUtils.java +++ b/core/java/com/android/internal/app/AssistUtils.java @@ -18,6 +18,7 @@ package com.android.internal.app; import com.android.internal.R; +import android.annotation.UnsupportedAppUsage; import android.app.SearchManager; import android.content.ComponentName; import android.content.Context; @@ -53,6 +54,7 @@ public class AssistUtils { private final Context mContext; private final IVoiceInteractionManagerService mVoiceInteractionManagerService; + @UnsupportedAppUsage public AssistUtils(Context context) { mContext = context; mVoiceInteractionManagerService = IVoiceInteractionManagerService.Stub.asInterface( @@ -155,6 +157,7 @@ public class AssistUtils { } } + @UnsupportedAppUsage public ComponentName getAssistComponentForUser(int userId) { final String setting = Settings.Secure.getStringForUser(mContext.getContentResolver(), Settings.Secure.ASSISTANT, userId); diff --git a/core/java/com/android/internal/app/ChooserActivity.java b/core/java/com/android/internal/app/ChooserActivity.java index c31f17af67af..6343908738fc 100644 --- a/core/java/com/android/internal/app/ChooserActivity.java +++ b/core/java/com/android/internal/app/ChooserActivity.java @@ -20,6 +20,7 @@ import android.animation.Animator; import android.animation.AnimatorListenerAdapter; import android.animation.ObjectAnimator; import android.annotation.NonNull; +import android.annotation.UnsupportedAppUsage; import android.app.Activity; import android.app.ActivityManager; import android.app.usage.UsageStatsManager; diff --git a/core/java/com/android/internal/app/IntentForwarderActivity.java b/core/java/com/android/internal/app/IntentForwarderActivity.java index 4728124c17c5..ed771406db5c 100644 --- a/core/java/com/android/internal/app/IntentForwarderActivity.java +++ b/core/java/com/android/internal/app/IntentForwarderActivity.java @@ -20,6 +20,7 @@ import static android.content.pm.PackageManager.MATCH_DEFAULT_ONLY; import android.annotation.Nullable; import android.annotation.StringRes; +import android.annotation.UnsupportedAppUsage; import android.app.Activity; import android.app.ActivityManager; import android.app.ActivityThread; @@ -50,6 +51,7 @@ import java.util.Set; * be passed in and out of a managed profile. */ public class IntentForwarderActivity extends Activity { + @UnsupportedAppUsage public static String TAG = "IntentForwarderActivity"; public static String FORWARD_INTENT_TO_PARENT diff --git a/core/java/com/android/internal/app/LocaleHelper.java b/core/java/com/android/internal/app/LocaleHelper.java index 0a230a90a735..aef4dbf41d35 100644 --- a/core/java/com/android/internal/app/LocaleHelper.java +++ b/core/java/com/android/internal/app/LocaleHelper.java @@ -17,6 +17,7 @@ package com.android.internal.app; import android.annotation.IntRange; +import android.annotation.UnsupportedAppUsage; import android.icu.text.ListFormatter; import android.icu.util.ULocale; import android.os.LocaleList; @@ -84,6 +85,7 @@ public class LocaleHelper { * @param locale the locale that might be used for certain operations (i.e. case conversion) * @return the string normalized for search */ + @UnsupportedAppUsage public static String normalizeForSearch(String str, Locale locale) { // TODO: tbd if it needs to be smarter (real normalization, remove accents, etc.) // If needed we might use case folding and ICU/CLDR's collation-based loose searching. @@ -109,6 +111,7 @@ public class LocaleHelper { * @param sentenceCase true if the result should be sentence-cased * @return the localized name of the locale. */ + @UnsupportedAppUsage public static String getDisplayName(Locale locale, Locale displayLocale, boolean sentenceCase) { final ULocale displayULocale = ULocale.forLocale(displayLocale); String result = shouldUseDialectName(locale) @@ -135,6 +138,7 @@ public class LocaleHelper { * @param displayLocale the locale in which to display the name. * @return the localized country name. */ + @UnsupportedAppUsage public static String getDisplayCountry(Locale locale, Locale displayLocale) { final String languageTag = locale.toLanguageTag(); final ULocale uDisplayLocale = ULocale.forLocale(displayLocale); @@ -226,6 +230,7 @@ public class LocaleHelper { * * @param sortLocale the locale to be used for sorting. */ + @UnsupportedAppUsage public LocaleInfoComparator(Locale sortLocale, boolean countryMode) { mCollator = Collator.getInstance(sortLocale); mCountryMode = countryMode; @@ -253,6 +258,7 @@ public class LocaleHelper { * @return a negative integer, zero, or a positive integer as the first * argument is less than, equal to, or greater than the second. */ + @UnsupportedAppUsage @Override public int compare(LocaleStore.LocaleInfo lhs, LocaleStore.LocaleInfo rhs) { // We don't care about the various suggestion types, just "suggested" (!= 0) diff --git a/core/java/com/android/internal/app/LocalePicker.java b/core/java/com/android/internal/app/LocalePicker.java index c8c2fcf60d1f..75174246cd99 100644 --- a/core/java/com/android/internal/app/LocalePicker.java +++ b/core/java/com/android/internal/app/LocalePicker.java @@ -18,6 +18,7 @@ package com.android.internal.app; import com.android.internal.R; +import android.annotation.UnsupportedAppUsage; import android.app.ActivityManager; import android.app.IActivityManager; import android.app.ListFragment; @@ -70,6 +71,7 @@ public class LocalePicker extends ListFragment { return label; } + @UnsupportedAppUsage public Locale getLocale() { return locale; } @@ -251,6 +253,7 @@ public class LocalePicker extends ListFragment { * * @see #updateLocales(LocaleList) */ + @UnsupportedAppUsage public static void updateLocale(Locale locale) { updateLocales(new LocaleList(locale)); } @@ -260,6 +263,7 @@ public class LocalePicker extends ListFragment { * Note that the system looks halted for a while during the Locale migration, * so the caller need to take care of it. */ + @UnsupportedAppUsage public static void updateLocales(LocaleList locales) { try { final IActivityManager am = ActivityManager.getService(); @@ -281,6 +285,7 @@ public class LocalePicker extends ListFragment { * * @return The locale list. */ + @UnsupportedAppUsage public static LocaleList getLocales() { try { return ActivityManager.getService() diff --git a/core/java/com/android/internal/app/LocaleStore.java b/core/java/com/android/internal/app/LocaleStore.java index d24701372453..df2df4e92200 100644 --- a/core/java/com/android/internal/app/LocaleStore.java +++ b/core/java/com/android/internal/app/LocaleStore.java @@ -16,6 +16,7 @@ package com.android.internal.app; +import android.annotation.UnsupportedAppUsage; import android.content.Context; import android.os.LocaleList; import android.provider.Settings; @@ -80,14 +81,17 @@ public class LocaleStore { return mId; } + @UnsupportedAppUsage public Locale getLocale() { return mLocale; } + @UnsupportedAppUsage public Locale getParent() { return mParent; } + @UnsupportedAppUsage public String getId() { return mId; } @@ -114,6 +118,7 @@ public class LocaleStore { return (mSuggestionFlags & suggestionMask) == suggestionMask; } + @UnsupportedAppUsage public String getFullNameNative() { if (mFullNameNative == null) { mFullNameNative = @@ -139,6 +144,7 @@ public class LocaleStore { * For instance German will show as "Deutsch" in the list, but we will also search for * "allemand" if the system UI is in French. */ + @UnsupportedAppUsage public String getFullNameInUiLanguage() { // We don't cache the UI name because the default locale keeps changing return LocaleHelper.getDisplayName(mLocale, true /* sentence case */); @@ -253,6 +259,7 @@ public class LocaleStore { } } + @UnsupportedAppUsage public static void fillCache(Context context) { if (sFullyInitialized) { return; @@ -339,6 +346,7 @@ public class LocaleStore { * Example: if the parent is "ar", then the region list will contain all Arabic locales. * (this is not language based, but language-script, so that it works for zh-Hant and so on. */ + @UnsupportedAppUsage public static Set<LocaleInfo> getLevelLocales(Context context, Set<String> ignorables, LocaleInfo parent, boolean translatedOnly) { fillCache(context); @@ -364,6 +372,7 @@ public class LocaleStore { return result; } + @UnsupportedAppUsage public static LocaleInfo getLocaleInfo(Locale locale) { String id = locale.toLanguageTag(); LocaleInfo result; diff --git a/core/java/com/android/internal/app/NetInitiatedActivity.java b/core/java/com/android/internal/app/NetInitiatedActivity.java index d3bae16d03a7..9a802a9c0fa9 100644 --- a/core/java/com/android/internal/app/NetInitiatedActivity.java +++ b/core/java/com/android/internal/app/NetInitiatedActivity.java @@ -16,6 +16,7 @@ package com.android.internal.app; +import android.annotation.UnsupportedAppUsage; import android.app.AlertDialog; import android.content.BroadcastReceiver; import android.content.Context; @@ -141,6 +142,7 @@ public class NetInitiatedActivity extends AlertActivity implements DialogInterfa locationManager.sendNiResponse(notificationId, response); } + @UnsupportedAppUsage private void handleNIVerify(Intent intent) { int notifId = intent.getIntExtra(GpsNetInitiatedHandler.NI_INTENT_KEY_NOTIF_ID, -1); notificationId = notifId; diff --git a/core/java/com/android/internal/app/ResolverActivity.java b/core/java/com/android/internal/app/ResolverActivity.java index ceb06f511108..5ab76694df65 100644 --- a/core/java/com/android/internal/app/ResolverActivity.java +++ b/core/java/com/android/internal/app/ResolverActivity.java @@ -19,6 +19,7 @@ package com.android.internal.app; import android.annotation.Nullable; import android.annotation.StringRes; import android.annotation.UiThread; +import android.annotation.UnsupportedAppUsage; import android.app.Activity; import android.app.ActivityManager; import android.app.ActivityThread; @@ -90,6 +91,7 @@ import static android.content.Intent.FLAG_ACTIVITY_NEW_TASK; @UiThread public class ResolverActivity extends Activity { + @UnsupportedAppUsage protected ResolveListAdapter mAdapter; private boolean mSafeForwardingMode; private AbsListView mAdapterView; @@ -110,6 +112,7 @@ public class ResolverActivity extends Activity { // Whether or not this activity supports choosing a default handler for the intent. private boolean mSupportsAlwaysUseOption; protected ResolverDrawerLayout mResolverDrawerLayout; + @UnsupportedAppUsage protected PackageManager mPm; protected int mLaunchedFromUid; @@ -242,6 +245,7 @@ public class ResolverActivity extends Activity { * Compatibility version for other bundled services that use this overload without * a default title resource */ + @UnsupportedAppUsage protected void onCreate(Bundle savedInstanceState, Intent intent, CharSequence title, Intent[] initialIntents, List<ResolveInfo> rList, boolean supportsAlwaysUseOption) { diff --git a/core/java/com/android/internal/app/WindowDecorActionBar.java b/core/java/com/android/internal/app/WindowDecorActionBar.java index 119f30df8946..e71ee66c677c 100644 --- a/core/java/com/android/internal/app/WindowDecorActionBar.java +++ b/core/java/com/android/internal/app/WindowDecorActionBar.java @@ -84,6 +84,7 @@ public class WindowDecorActionBar extends ActionBar implements private ActionBarContextView mContextView; private ActionBarContainer mSplitView; private View mContentView; + @UnsupportedAppUsage private ScrollingTabContainerView mTabScrollView; private ArrayList<TabImpl> mTabs = new ArrayList<TabImpl>(); @@ -331,6 +332,7 @@ public class WindowDecorActionBar extends ActionBar implements * * @param enabled true to animate, false to not animate. */ + @UnsupportedAppUsage public void setShowHideAnimationEnabled(boolean enabled) { mShowHideAnimationEnabled = enabled; if (!enabled && mCurrentShowAnim != null) { @@ -1147,6 +1149,7 @@ public class WindowDecorActionBar extends ActionBar implements * @hide */ public class TabImpl extends ActionBar.Tab { + @UnsupportedAppUsage private ActionBar.TabListener mCallback; private Object mTag; private Drawable mIcon; diff --git a/core/java/com/android/internal/database/SortCursor.java b/core/java/com/android/internal/database/SortCursor.java index 00255128972c..7fe809ee319b 100644 --- a/core/java/com/android/internal/database/SortCursor.java +++ b/core/java/com/android/internal/database/SortCursor.java @@ -16,6 +16,7 @@ package com.android.internal.database; +import android.annotation.UnsupportedAppUsage; import android.database.AbstractCursor; import android.database.Cursor; import android.database.DataSetObserver; @@ -28,7 +29,9 @@ import android.util.Log; public class SortCursor extends AbstractCursor { private static final String TAG = "SortCursor"; + @UnsupportedAppUsage private Cursor mCursor; // updated in onMove + @UnsupportedAppUsage private Cursor[] mCursors; private int [] mSortColumns; private final int ROWCACHESIZE = 64; @@ -52,6 +55,7 @@ public class SortCursor extends AbstractCursor } }; + @UnsupportedAppUsage public SortCursor(Cursor[] cursors, String sortcolumn) { mCursors = cursors; diff --git a/core/java/com/android/internal/http/HttpDateTime.java b/core/java/com/android/internal/http/HttpDateTime.java index 8ebd4aaf1ac0..f7706e310952 100644 --- a/core/java/com/android/internal/http/HttpDateTime.java +++ b/core/java/com/android/internal/http/HttpDateTime.java @@ -16,6 +16,7 @@ package com.android.internal.http; +import android.annotation.UnsupportedAppUsage; import android.text.format.Time; import java.util.Calendar; @@ -82,6 +83,7 @@ public final class HttpDateTime { int second; } + @UnsupportedAppUsage public static long parse(String timeString) throws IllegalArgumentException { diff --git a/core/java/com/android/internal/os/AndroidPrintStream.java b/core/java/com/android/internal/os/AndroidPrintStream.java index 7f4807a5b863..fe2341144d28 100644 --- a/core/java/com/android/internal/os/AndroidPrintStream.java +++ b/core/java/com/android/internal/os/AndroidPrintStream.java @@ -16,6 +16,7 @@ package com.android.internal.os; +import android.annotation.UnsupportedAppUsage; import android.util.Log; /** @@ -34,6 +35,7 @@ class AndroidPrintStream extends LoggingPrintStream { * @param priority from {@link android.util.Log} * @param tag to log */ + @UnsupportedAppUsage public AndroidPrintStream(int priority, String tag) { if (tag == null) { throw new NullPointerException("tag"); diff --git a/core/java/com/android/internal/os/BaseCommand.java b/core/java/com/android/internal/os/BaseCommand.java index 05ec9e90513e..278f40660ee9 100644 --- a/core/java/com/android/internal/os/BaseCommand.java +++ b/core/java/com/android/internal/os/BaseCommand.java @@ -17,12 +17,14 @@ package com.android.internal.os; +import android.annotation.UnsupportedAppUsage; import android.os.ShellCommand; import java.io.PrintStream; public abstract class BaseCommand { + @UnsupportedAppUsage final protected ShellCommand mArgs = new ShellCommand() { @Override public int onCommand(String cmd) { return 0; diff --git a/core/java/com/android/internal/os/BinderInternal.java b/core/java/com/android/internal/os/BinderInternal.java index 5bddd2f98983..6efcbda9a00d 100644 --- a/core/java/com/android/internal/os/BinderInternal.java +++ b/core/java/com/android/internal/os/BinderInternal.java @@ -17,6 +17,7 @@ package com.android.internal.os; import android.annotation.NonNull; +import android.annotation.UnsupportedAppUsage; import android.os.Handler; import android.os.IBinder; import android.os.SystemClock; @@ -94,6 +95,7 @@ public class BinderInternal { * an implementation of IServiceManager, which you can use to find * other services. */ + @UnsupportedAppUsage public static final native IBinder getContextObject(); /** @@ -105,6 +107,7 @@ public class BinderInternal { public static final native void setMaxThreads(int numThreads); + @UnsupportedAppUsage static native final void handleGc(); public static void forceGc(String reason) { diff --git a/core/java/com/android/internal/os/ClassLoaderFactory.java b/core/java/com/android/internal/os/ClassLoaderFactory.java index 99a1a19686e4..d32349834dd8 100644 --- a/core/java/com/android/internal/os/ClassLoaderFactory.java +++ b/core/java/com/android/internal/os/ClassLoaderFactory.java @@ -16,6 +16,7 @@ package com.android.internal.os; +import android.annotation.UnsupportedAppUsage; import android.os.Trace; import dalvik.system.DelegateLastClassLoader; @@ -132,6 +133,7 @@ public class ClassLoaderFactory { return classLoader; } + @UnsupportedAppUsage private static native String createClassloaderNamespace(ClassLoader classLoader, int targetSdkVersion, String librarySearchPath, diff --git a/core/java/com/android/internal/os/ProcessCpuTracker.java b/core/java/com/android/internal/os/ProcessCpuTracker.java index 1ee4269d974b..e097ddbdab40 100644 --- a/core/java/com/android/internal/os/ProcessCpuTracker.java +++ b/core/java/com/android/internal/os/ProcessCpuTracker.java @@ -18,6 +18,7 @@ package com.android.internal.os; import static android.os.Process.*; +import android.annotation.UnsupportedAppUsage; import android.os.FileUtils; import android.os.Process; import android.os.StrictMode; @@ -197,6 +198,7 @@ public class ProcessCpuTracker { public boolean interesting; public String baseName; + @UnsupportedAppUsage public String name; public int nameWidth; @@ -212,6 +214,7 @@ public class ProcessCpuTracker { /** * Time in milliseconds. */ + @UnsupportedAppUsage public long rel_uptime; /** @@ -227,11 +230,13 @@ public class ProcessCpuTracker { /** * Time in milliseconds. */ + @UnsupportedAppUsage public int rel_utime; /** * Time in milliseconds. */ + @UnsupportedAppUsage public int rel_stime; public long base_minfaults; @@ -292,6 +297,7 @@ public class ProcessCpuTracker { }; + @UnsupportedAppUsage public ProcessCpuTracker(boolean includeThreads) { mIncludeThreads = includeThreads; long jiffyHz = Os.sysconf(OsConstants._SC_CLK_TCK); @@ -311,6 +317,7 @@ public class ProcessCpuTracker { update(); } + @UnsupportedAppUsage public void update() { if (DEBUG) Slog.v(TAG, "Update: " + this); @@ -713,11 +720,13 @@ public class ProcessCpuTracker { return statses; } + @UnsupportedAppUsage final public int countWorkingStats() { buildWorkingProcs(); return mWorkingProcs.size(); } + @UnsupportedAppUsage final public Stats getWorkingStats(int index) { return mWorkingProcs.get(index); } diff --git a/core/java/com/android/internal/os/RuntimeInit.java b/core/java/com/android/internal/os/RuntimeInit.java index e37e650f6e50..eac150dbd320 100644 --- a/core/java/com/android/internal/os/RuntimeInit.java +++ b/core/java/com/android/internal/os/RuntimeInit.java @@ -16,6 +16,7 @@ package com.android.internal.os; +import android.annotation.UnsupportedAppUsage; import android.app.ActivityManager; import android.app.ActivityThread; import android.app.ApplicationErrorReport; @@ -48,8 +49,10 @@ public class RuntimeInit { final static boolean DEBUG = false; /** true if commonInit() has been called */ + @UnsupportedAppUsage private static boolean initialized; + @UnsupportedAppUsage private static IBinder mApplicationObject; private static volatile boolean mCrashing = false; @@ -186,6 +189,7 @@ public class RuntimeInit { } } + @UnsupportedAppUsage protected static final void commonInit() { if (DEBUG) Slog.d(TAG, "Entered RuntimeInit!"); @@ -315,6 +319,7 @@ public class RuntimeInit { return new MethodAndArgsCaller(m, argv); } + @UnsupportedAppUsage public static final void main(String[] argv) { enableDdms(); if (argv.length == 2 && argv[1].equals("application")) { @@ -402,6 +407,7 @@ public class RuntimeInit { mApplicationObject = app; } + @UnsupportedAppUsage public static final IBinder getApplicationObject() { return mApplicationObject; } diff --git a/core/java/com/android/internal/os/ZygoteConnection.java b/core/java/com/android/internal/os/ZygoteConnection.java index 14958ca539de..034c37cdf4c3 100644 --- a/core/java/com/android/internal/os/ZygoteConnection.java +++ b/core/java/com/android/internal/os/ZygoteConnection.java @@ -26,6 +26,7 @@ import static android.system.OsConstants.STDOUT_FILENO; import static com.android.internal.os.ZygoteConnectionConstants.CONNECTION_TIMEOUT_MILLIS; import static com.android.internal.os.ZygoteConnectionConstants.WRAPPED_PID_TIMEOUT_MILLIS; +import android.annotation.UnsupportedAppUsage; import android.metrics.LogMaker; import android.net.Credentials; import android.net.LocalSocket; @@ -65,9 +66,12 @@ class ZygoteConnection { * that it closes when the child process terminates. In other cases, * it is closed in the peer. */ + @UnsupportedAppUsage private final LocalSocket mSocket; + @UnsupportedAppUsage private final DataOutputStream mSocketOutStream; private final BufferedReader mSocketReader; + @UnsupportedAppUsage private final Credentials peer; private final String abiList; private boolean isEof; @@ -396,6 +400,7 @@ class ZygoteConnection { /** * Closes socket associated with this connection. */ + @UnsupportedAppUsage void closeSocket() { try { mSocket.close(); diff --git a/core/java/com/android/internal/os/ZygoteInit.java b/core/java/com/android/internal/os/ZygoteInit.java index d695ad6646f8..2abc8c080ac1 100644 --- a/core/java/com/android/internal/os/ZygoteInit.java +++ b/core/java/com/android/internal/os/ZygoteInit.java @@ -19,6 +19,7 @@ package com.android.internal.os; import static android.system.OsConstants.S_IRWXG; import static android.system.OsConstants.S_IRWXO; +import android.annotation.UnsupportedAppUsage; import android.content.res.Resources; import android.content.res.TypedArray; import android.app.ApplicationLoaders; @@ -107,6 +108,7 @@ public class ZygoteInit { /** * Used to pre-load resources. */ + @UnsupportedAppUsage private static Resources mResources; /** @@ -818,6 +820,7 @@ public class ZygoteInit { return result; } + @UnsupportedAppUsage public static void main(String argv[]) { ZygoteServer zygoteServer = new ZygoteServer(); diff --git a/core/java/com/android/internal/os/ZygoteSecurityException.java b/core/java/com/android/internal/os/ZygoteSecurityException.java index 13b47597c1eb..7e50cb885324 100644 --- a/core/java/com/android/internal/os/ZygoteSecurityException.java +++ b/core/java/com/android/internal/os/ZygoteSecurityException.java @@ -16,10 +16,13 @@ package com.android.internal.os; +import android.annotation.UnsupportedAppUsage; + /** * Exception thrown when a security policy is violated. */ class ZygoteSecurityException extends RuntimeException { + @UnsupportedAppUsage ZygoteSecurityException(String message) { super(message); } diff --git a/core/java/com/android/internal/policy/DecorView.java b/core/java/com/android/internal/policy/DecorView.java index 6ad1d72eaec4..b38a7c1c47b2 100644 --- a/core/java/com/android/internal/policy/DecorView.java +++ b/core/java/com/android/internal/policy/DecorView.java @@ -41,6 +41,7 @@ import java.util.List; import android.animation.Animator; import android.animation.AnimatorListenerAdapter; import android.animation.ObjectAnimator; +import android.annotation.UnsupportedAppUsage; import android.content.Context; import android.content.res.Configuration; import android.content.res.Resources; @@ -207,8 +208,11 @@ public class DecorView extends FrameLayout implements RootViewSurfaceTaker, Wind private final BackgroundFallback mBackgroundFallback = new BackgroundFallback(); private int mLastTopInset = 0; + @UnsupportedAppUsage private int mLastBottomInset = 0; + @UnsupportedAppUsage private int mLastRightInset = 0; + @UnsupportedAppUsage private int mLastLeftInset = 0; private boolean mLastHasTopStableInset = false; private boolean mLastHasBottomStableInset = false; @@ -219,6 +223,7 @@ public class DecorView extends FrameLayout implements RootViewSurfaceTaker, Wind private int mRootScrollY = 0; + @UnsupportedAppUsage private PhoneWindow mWindow; ViewGroup mContentRoot; diff --git a/core/java/com/android/internal/policy/PhoneFallbackEventHandler.java b/core/java/com/android/internal/policy/PhoneFallbackEventHandler.java index d8ee4dd34269..791c2d7aa4b2 100644 --- a/core/java/com/android/internal/policy/PhoneFallbackEventHandler.java +++ b/core/java/com/android/internal/policy/PhoneFallbackEventHandler.java @@ -16,6 +16,7 @@ package com.android.internal.policy; +import android.annotation.UnsupportedAppUsage; import android.app.KeyguardManager; import android.app.SearchManager; import android.content.ActivityNotFoundException; @@ -41,7 +42,9 @@ public class PhoneFallbackEventHandler implements FallbackEventHandler { private static String TAG = "PhoneFallbackEventHandler"; private static final boolean DEBUG = false; + @UnsupportedAppUsage Context mContext; + @UnsupportedAppUsage View mView; AudioManager mAudioManager; @@ -50,6 +53,7 @@ public class PhoneFallbackEventHandler implements FallbackEventHandler { TelephonyManager mTelephonyManager; MediaSessionManager mMediaSessionManager; + @UnsupportedAppUsage public PhoneFallbackEventHandler(Context context) { mContext = context; } @@ -74,6 +78,7 @@ public class PhoneFallbackEventHandler implements FallbackEventHandler { } } + @UnsupportedAppUsage boolean onKeyDown(int keyCode, KeyEvent event) { /* **************************************************************************** * HOW TO DECIDE WHERE YOUR KEY HANDLING GOES. @@ -207,6 +212,7 @@ public class PhoneFallbackEventHandler implements FallbackEventHandler { && (getKeyguardManager().inKeyguardRestrictedInputMode() || dispatcher == null); } + @UnsupportedAppUsage boolean onKeyUp(int keyCode, KeyEvent event) { if (DEBUG) { Log.d(TAG, "up " + keyCode); @@ -270,6 +276,7 @@ public class PhoneFallbackEventHandler implements FallbackEventHandler { return false; } + @UnsupportedAppUsage void startCallActivity() { sendCloseSystemWindows(); Intent intent = new Intent(Intent.ACTION_CALL_BUTTON); diff --git a/core/java/com/android/internal/policy/PhoneWindow.java b/core/java/com/android/internal/policy/PhoneWindow.java index daea9a8eff41..0fa43a6f069d 100644 --- a/core/java/com/android/internal/policy/PhoneWindow.java +++ b/core/java/com/android/internal/policy/PhoneWindow.java @@ -63,6 +63,7 @@ import com.android.internal.view.menu.MenuView; import com.android.internal.widget.DecorContentParent; import com.android.internal.widget.SwipeDismissLayout; +import android.annotation.UnsupportedAppUsage; import android.app.ActivityManager; import android.app.KeyguardManager; import android.content.Context; @@ -237,6 +238,7 @@ public class PhoneWindow extends Window implements MenuBuilder.Callback { private boolean mForcedStatusBarColor = false; private boolean mForcedNavigationBarColor = false; + @UnsupportedAppUsage private CharSequence mTitle = null; private int mTitleColor = 0; @@ -300,6 +302,7 @@ public class PhoneWindow extends Window implements MenuBuilder.Callback { static final RotationWatcher sRotationWatcher = new RotationWatcher(); + @UnsupportedAppUsage public PhoneWindow(Context context) { super(context); mLayoutInflater = LayoutInflater.from(context); diff --git a/core/java/com/android/internal/util/ArrayUtils.java b/core/java/com/android/internal/util/ArrayUtils.java index 4b662670f5e7..eb556855ad41 100644 --- a/core/java/com/android/internal/util/ArrayUtils.java +++ b/core/java/com/android/internal/util/ArrayUtils.java @@ -18,6 +18,7 @@ package com.android.internal.util; import android.annotation.NonNull; import android.annotation.Nullable; +import android.annotation.UnsupportedAppUsage; import android.util.ArraySet; import dalvik.system.VMRuntime; @@ -51,6 +52,7 @@ public class ArrayUtils { return (char[])VMRuntime.getRuntime().newUnpaddedArray(char.class, minLen); } + @UnsupportedAppUsage public static int[] newUnpaddedIntArray(int minLen) { return (int[])VMRuntime.getRuntime().newUnpaddedArray(int.class, minLen); } @@ -71,6 +73,7 @@ public class ArrayUtils { return (Object[])VMRuntime.getRuntime().newUnpaddedArray(Object.class, minLen); } + @UnsupportedAppUsage @SuppressWarnings("unchecked") public static <T> T[] newUnpaddedArray(Class<T> clazz, int minLen) { return (T[])VMRuntime.getRuntime().newUnpaddedArray(clazz, minLen); @@ -108,6 +111,7 @@ public class ArrayUtils { * it will return the same empty array every time to avoid reallocation, * although this is not guaranteed. */ + @UnsupportedAppUsage @SuppressWarnings("unchecked") public static <T> T[] emptyArray(Class<T> kind) { if (kind == Object.class) { @@ -144,6 +148,7 @@ public class ArrayUtils { /** * Checks if given array is null or has zero elements. */ + @UnsupportedAppUsage public static <T> boolean isEmpty(@Nullable T[] array) { return array == null || array.length == 0; } @@ -196,6 +201,7 @@ public class ArrayUtils { * @param value the value to check for * @return true if the value is present in the array */ + @UnsupportedAppUsage public static <T> boolean contains(@Nullable T[] array, T value) { return indexOf(array, value) != -1; } @@ -204,6 +210,7 @@ public class ArrayUtils { * Return first index of {@code value} in {@code array}, or {@code -1} if * not found. */ + @UnsupportedAppUsage public static <T> int indexOf(@Nullable T[] array, T value) { if (array == null) return -1; for (int i = 0; i < array.length; i++) { @@ -238,6 +245,7 @@ public class ArrayUtils { return false; } + @UnsupportedAppUsage public static boolean contains(@Nullable int[] array, int value) { if (array == null) return false; for (int element : array) { @@ -329,6 +337,7 @@ public class ArrayUtils { * Adds value to given array if not already present, providing set-like * behavior. */ + @UnsupportedAppUsage @SuppressWarnings("unchecked") public static @NonNull <T> T[] appendElement(Class<T> kind, @Nullable T[] array, T element) { return appendElement(kind, array, element, false); @@ -358,6 +367,7 @@ public class ArrayUtils { /** * Removes value from given array if present, providing set-like behavior. */ + @UnsupportedAppUsage @SuppressWarnings("unchecked") public static @Nullable <T> T[] removeElement(Class<T> kind, @Nullable T[] array, T element) { if (array != null) { @@ -404,6 +414,7 @@ public class ArrayUtils { * Adds value to given array if not already present, providing set-like * behavior. */ + @UnsupportedAppUsage public static @NonNull int[] appendInt(@Nullable int[] cur, int val) { return appendInt(cur, val, false); } diff --git a/core/java/com/android/internal/util/BitwiseInputStream.java b/core/java/com/android/internal/util/BitwiseInputStream.java index 86f74f302518..6ff67e9b9718 100644 --- a/core/java/com/android/internal/util/BitwiseInputStream.java +++ b/core/java/com/android/internal/util/BitwiseInputStream.java @@ -16,6 +16,8 @@ package com.android.internal.util; +import android.annotation.UnsupportedAppUsage; + /** * An object that provides bitwise incremental read access to a byte array. * @@ -49,6 +51,7 @@ public class BitwiseInputStream { * * @param buf a byte array containing data */ + @UnsupportedAppUsage public BitwiseInputStream(byte buf[]) { mBuf = buf; mEnd = buf.length << 3; @@ -58,6 +61,7 @@ public class BitwiseInputStream { /** * Return the number of bit still available for reading. */ + @UnsupportedAppUsage public int available() { return mEnd - mPos; } @@ -71,6 +75,7 @@ public class BitwiseInputStream { * @param bits the amount of data to read (gte 0, lte 8) * @return byte of read data (possibly partially filled, from lsb) */ + @UnsupportedAppUsage public int read(int bits) throws AccessException { int index = mPos >>> 3; int offset = 16 - (mPos & 0x07) - bits; // &7==%8 @@ -92,6 +97,7 @@ public class BitwiseInputStream { * @param bits the amount of data to read * @return newly allocated byte array of read data */ + @UnsupportedAppUsage public byte[] readByteArray(int bits) throws AccessException { int bytes = (bits >>> 3) + ((bits & 0x07) > 0 ? 1 : 0); // &7==%8 byte[] arr = new byte[bytes]; @@ -107,6 +113,7 @@ public class BitwiseInputStream { * * @param bits the amount by which to increment the position */ + @UnsupportedAppUsage public void skip(int bits) throws AccessException { if ((mPos + bits) > mEnd) { throw new AccessException("illegal skip " + diff --git a/core/java/com/android/internal/util/BitwiseOutputStream.java b/core/java/com/android/internal/util/BitwiseOutputStream.java index ddecbed1d97c..cdd6f173484c 100644 --- a/core/java/com/android/internal/util/BitwiseOutputStream.java +++ b/core/java/com/android/internal/util/BitwiseOutputStream.java @@ -16,6 +16,8 @@ package com.android.internal.util; +import android.annotation.UnsupportedAppUsage; + /** * An object that provides bitwise incremental write access to a byte array. * @@ -49,6 +51,7 @@ public class BitwiseOutputStream { * * @param startingLength initial internal byte array length in bytes */ + @UnsupportedAppUsage public BitwiseOutputStream(int startingLength) { mBuf = new byte[startingLength]; mEnd = startingLength << 3; @@ -60,6 +63,7 @@ public class BitwiseOutputStream { * * @return newly allocated byte array */ + @UnsupportedAppUsage public byte[] toByteArray() { int len = (mPos >>> 3) + ((mPos & 0x07) > 0 ? 1 : 0); // &7==%8 byte[] newBuf = new byte[len]; @@ -89,6 +93,7 @@ public class BitwiseOutputStream { * @param bits the amount of data to write (gte 0, lte 8) * @param data to write, will be masked to expose only bits param from lsb */ + @UnsupportedAppUsage public void write(int bits, int data) throws AccessException { if ((bits < 0) || (bits > 8)) { throw new AccessException("illegal write (" + bits + " bits)"); @@ -109,6 +114,7 @@ public class BitwiseOutputStream { * @param bits the amount of data to write * @param arr the byte array containing data to be written */ + @UnsupportedAppUsage public void writeByteArray(int bits, byte[] arr) throws AccessException { for (int i = 0; i < arr.length; i++) { int increment = Math.min(8, bits - (i << 3)); diff --git a/core/java/com/android/internal/util/CharSequences.java b/core/java/com/android/internal/util/CharSequences.java index fdaa4bce25db..6b6c43ce8195 100644 --- a/core/java/com/android/internal/util/CharSequences.java +++ b/core/java/com/android/internal/util/CharSequences.java @@ -16,6 +16,8 @@ package com.android.internal.util; +import android.annotation.UnsupportedAppUsage; + /** * {@link CharSequence} utility methods. */ @@ -93,6 +95,7 @@ public class CharSequences { /** * Compares two character sequences for equality. */ + @UnsupportedAppUsage public static boolean equals(CharSequence a, CharSequence b) { if (a.length() != b.length()) { return false; @@ -114,6 +117,7 @@ public class CharSequences { * @param another The other CharSequence. * @return See {@link Comparable#compareTo}. */ + @UnsupportedAppUsage public static int compareToIgnoreCase(CharSequence me, CharSequence another) { // Code adapted from String#compareTo int myLen = me.length(), anotherLen = another.length(); diff --git a/core/java/com/android/internal/util/FastMath.java b/core/java/com/android/internal/util/FastMath.java index 88a17e6ba259..35efe708795e 100644 --- a/core/java/com/android/internal/util/FastMath.java +++ b/core/java/com/android/internal/util/FastMath.java @@ -16,6 +16,8 @@ package com.android.internal.util; +import android.annotation.UnsupportedAppUsage; + /** * Fast and loose math routines. */ @@ -26,6 +28,7 @@ public class FastMath { * thought it may return slightly different results. It does not try to * handle (in any meaningful way) NaN or infinities. */ + @UnsupportedAppUsage public static int round(float value) { long lx = (long) (value * (65536 * 256f)); return (int) ((lx + 0x800000) >> 24); diff --git a/core/java/com/android/internal/util/FastXmlSerializer.java b/core/java/com/android/internal/util/FastXmlSerializer.java index b85b84fb3dc8..9f76aeb663c5 100644 --- a/core/java/com/android/internal/util/FastXmlSerializer.java +++ b/core/java/com/android/internal/util/FastXmlSerializer.java @@ -18,6 +18,7 @@ package com.android.internal.util; import org.xmlpull.v1.XmlSerializer; +import android.annotation.UnsupportedAppUsage; import java.io.IOException; import java.io.OutputStream; import java.io.OutputStreamWriter; @@ -69,6 +70,7 @@ public class FastXmlSerializer implements XmlSerializer { private int mNesting = 0; private boolean mLineStart = true; + @UnsupportedAppUsage public FastXmlSerializer() { this(DEFAULT_BUFFER_LEN); } diff --git a/core/java/com/android/internal/util/GrowingArrayUtils.java b/core/java/com/android/internal/util/GrowingArrayUtils.java index 968d9204b106..9f563667e019 100644 --- a/core/java/com/android/internal/util/GrowingArrayUtils.java +++ b/core/java/com/android/internal/util/GrowingArrayUtils.java @@ -16,6 +16,8 @@ package com.android.internal.util; +import android.annotation.UnsupportedAppUsage; + /** * A helper class that aims to provide comparable growth performance to ArrayList, but on primitive * arrays. Common array operations are implemented for efficient use in dynamic containers. @@ -37,6 +39,7 @@ public final class GrowingArrayUtils { * @return the array to which the element was appended. This may be different than the given * array. */ + @UnsupportedAppUsage public static <T> T[] append(T[] array, int currentSize, T element) { assert currentSize <= array.length; @@ -54,6 +57,7 @@ public final class GrowingArrayUtils { /** * Primitive int version of {@link #append(Object[], int, Object)}. */ + @UnsupportedAppUsage public static int[] append(int[] array, int currentSize, int element) { assert currentSize <= array.length; diff --git a/core/java/com/android/internal/util/HexDump.java b/core/java/com/android/internal/util/HexDump.java index af004009e1ee..6ffc92853b08 100644 --- a/core/java/com/android/internal/util/HexDump.java +++ b/core/java/com/android/internal/util/HexDump.java @@ -17,6 +17,7 @@ package com.android.internal.util; import android.annotation.Nullable; +import android.annotation.UnsupportedAppUsage; public class HexDump { @@ -100,16 +101,19 @@ public class HexDump return toHexString(toByteArray(b)); } + @UnsupportedAppUsage public static String toHexString(byte[] array) { return toHexString(array, 0, array.length, true); } + @UnsupportedAppUsage public static String toHexString(byte[] array, boolean upperCase) { return toHexString(array, 0, array.length, upperCase); } + @UnsupportedAppUsage public static String toHexString(byte[] array, int offset, int length) { return toHexString(array, offset, length, true); @@ -131,6 +135,7 @@ public class HexDump return new String(buf); } + @UnsupportedAppUsage public static String toHexString(int i) { return toHexString(toByteArray(i)); @@ -164,6 +169,7 @@ public class HexDump throw new RuntimeException ("Invalid hex char '" + c + "'"); } + @UnsupportedAppUsage public static byte[] hexStringToByteArray(String hexString) { int length = hexString.length(); diff --git a/core/java/com/android/internal/util/IState.java b/core/java/com/android/internal/util/IState.java index 056f8e9b0424..eb66e2ce94d7 100644 --- a/core/java/com/android/internal/util/IState.java +++ b/core/java/com/android/internal/util/IState.java @@ -16,6 +16,7 @@ package com.android.internal.util; +import android.annotation.UnsupportedAppUsage; import android.os.Message; /** @@ -67,5 +68,6 @@ public interface IState { * * @return name of state. */ + @UnsupportedAppUsage String getName(); } diff --git a/core/java/com/android/internal/util/MemInfoReader.java b/core/java/com/android/internal/util/MemInfoReader.java index 8d7166679b78..630916ebeecb 100644 --- a/core/java/com/android/internal/util/MemInfoReader.java +++ b/core/java/com/android/internal/util/MemInfoReader.java @@ -16,12 +16,14 @@ package com.android.internal.util; +import android.annotation.UnsupportedAppUsage; import android.os.Debug; import android.os.StrictMode; public final class MemInfoReader { final long[] mInfos = new long[Debug.MEMINFO_COUNT]; + @UnsupportedAppUsage public void readMemInfo() { // Permit disk reads here, as /proc/meminfo isn't really "on // disk" and should be fast. TODO: make BlockGuard ignore @@ -37,6 +39,7 @@ public final class MemInfoReader { /** * Total amount of RAM available to the kernel. */ + @UnsupportedAppUsage public long getTotalSize() { return mInfos[Debug.MEMINFO_TOTAL] * 1024; } @@ -44,6 +47,7 @@ public final class MemInfoReader { /** * Amount of RAM that is not being used for anything. */ + @UnsupportedAppUsage public long getFreeSize() { return mInfos[Debug.MEMINFO_FREE] * 1024; } @@ -52,6 +56,7 @@ public final class MemInfoReader { * Amount of RAM that the kernel is being used for caches, not counting caches * that are mapped in to processes. */ + @UnsupportedAppUsage public long getCachedSize() { return getCachedSizeKb() * 1024; } @@ -107,6 +112,7 @@ public final class MemInfoReader { return mInfos[Debug.MEMINFO_ZRAM_TOTAL]; } + @UnsupportedAppUsage public long[] getRawInfo() { return mInfos; } diff --git a/core/java/com/android/internal/util/Preconditions.java b/core/java/com/android/internal/util/Preconditions.java index 91c76afdf5b2..3a5720f6e918 100644 --- a/core/java/com/android/internal/util/Preconditions.java +++ b/core/java/com/android/internal/util/Preconditions.java @@ -18,6 +18,7 @@ package com.android.internal.util; import android.annotation.IntRange; import android.annotation.NonNull; +import android.annotation.UnsupportedAppUsage; import android.text.TextUtils; import java.util.Collection; @@ -28,6 +29,7 @@ import java.util.Collection; */ public class Preconditions { + @UnsupportedAppUsage public static void checkArgument(boolean expression) { if (!expression) { throw new IllegalArgumentException(); @@ -42,6 +44,7 @@ public class Preconditions { * be converted to a string using {@link String#valueOf(Object)} * @throws IllegalArgumentException if {@code expression} is false */ + @UnsupportedAppUsage public static void checkArgument(boolean expression, final Object errorMessage) { if (!expression) { throw new IllegalArgumentException(String.valueOf(errorMessage)); @@ -106,6 +109,7 @@ public class Preconditions { * @return the non-null reference that was validated * @throws NullPointerException if {@code reference} is null */ + @UnsupportedAppUsage public static @NonNull <T> T checkNotNull(final T reference) { if (reference == null) { throw new NullPointerException(); @@ -123,6 +127,7 @@ public class Preconditions { * @return the non-null reference that was validated * @throws NullPointerException if {@code reference} is null */ + @UnsupportedAppUsage public static @NonNull <T> T checkNotNull(final T reference, final Object errorMessage) { if (reference == null) { throw new NullPointerException(String.valueOf(errorMessage)); @@ -158,6 +163,7 @@ public class Preconditions { * @param message exception message * @throws IllegalStateException if {@code expression} is false */ + @UnsupportedAppUsage public static void checkState(final boolean expression, String message) { if (!expression) { throw new IllegalStateException(message); @@ -171,6 +177,7 @@ public class Preconditions { * @param expression a boolean expression * @throws IllegalStateException if {@code expression} is false */ + @UnsupportedAppUsage public static void checkState(final boolean expression) { checkState(expression, null); } @@ -338,6 +345,7 @@ public class Preconditions { * * @throws IllegalArgumentException if {@code value} was not within the range */ + @UnsupportedAppUsage public static int checkArgumentInRange(int value, int lower, int upper, String valueName) { if (value < lower) { diff --git a/core/java/com/android/internal/util/State.java b/core/java/com/android/internal/util/State.java index 3eadff58bc09..3c61e035e886 100644 --- a/core/java/com/android/internal/util/State.java +++ b/core/java/com/android/internal/util/State.java @@ -16,6 +16,7 @@ package com.android.internal.util; +import android.annotation.UnsupportedAppUsage; import android.os.Message; /** @@ -28,12 +29,14 @@ public class State implements IState { /** * Constructor */ + @UnsupportedAppUsage protected State() { } /* (non-Javadoc) * @see com.android.internal.util.IState#enter() */ + @UnsupportedAppUsage @Override public void enter() { } @@ -41,6 +44,7 @@ public class State implements IState { /* (non-Javadoc) * @see com.android.internal.util.IState#exit() */ + @UnsupportedAppUsage @Override public void exit() { } @@ -48,6 +52,7 @@ public class State implements IState { /* (non-Javadoc) * @see com.android.internal.util.IState#processMessage(android.os.Message) */ + @UnsupportedAppUsage @Override public boolean processMessage(Message msg) { return false; @@ -65,6 +70,7 @@ public class State implements IState { * * @see com.android.internal.util.IState#processMessage(android.os.Message) */ + @UnsupportedAppUsage @Override public String getName() { String name = getClass().getName(); diff --git a/core/java/com/android/internal/util/StateMachine.java b/core/java/com/android/internal/util/StateMachine.java index 7398e9526a42..dacdae6fd6c6 100644 --- a/core/java/com/android/internal/util/StateMachine.java +++ b/core/java/com/android/internal/util/StateMachine.java @@ -1301,6 +1301,7 @@ public class StateMachine { * * @param name of the state machine */ + @UnsupportedAppUsage protected StateMachine(String name) { mSmThread = new HandlerThread(name); mSmThread.start(); @@ -1314,6 +1315,7 @@ public class StateMachine { * * @param name of the state machine */ + @UnsupportedAppUsage protected StateMachine(String name, Looper looper) { initStateMachine(name, looper); } @@ -1323,6 +1325,7 @@ public class StateMachine { * * @param name of the state machine */ + @UnsupportedAppUsage protected StateMachine(String name, Handler handler) { initStateMachine(name, handler.getLooper()); } @@ -1678,6 +1681,7 @@ public class StateMachine { * @param arg2 is assigned to Message.arg2 * @return A Message object from the global pool */ + @UnsupportedAppUsage public final Message obtainMessage(int what, int arg1, int arg2) { return Message.obtain(mSmHandler, what, arg1, arg2); } @@ -1697,6 +1701,7 @@ public class StateMachine { * @param obj is assigned to Message.obj * @return A Message object from the global pool */ + @UnsupportedAppUsage public final Message obtainMessage(int what, int arg1, int arg2, Object obj) { return Message.obtain(mSmHandler, what, arg1, arg2, obj); } @@ -1706,6 +1711,7 @@ public class StateMachine { * * Message is ignored if state machine has quit. */ + @UnsupportedAppUsage public void sendMessage(int what) { // mSmHandler can be null if the state machine has quit. SmHandler smh = mSmHandler; @@ -1719,6 +1725,7 @@ public class StateMachine { * * Message is ignored if state machine has quit. */ + @UnsupportedAppUsage public void sendMessage(int what, Object obj) { // mSmHandler can be null if the state machine has quit. SmHandler smh = mSmHandler; @@ -1732,6 +1739,7 @@ public class StateMachine { * * Message is ignored if state machine has quit. */ + @UnsupportedAppUsage public void sendMessage(int what, int arg1) { // mSmHandler can be null if the state machine has quit. SmHandler smh = mSmHandler; @@ -1758,6 +1766,7 @@ public class StateMachine { * * Message is ignored if state machine has quit. */ + @UnsupportedAppUsage public void sendMessage(int what, int arg1, int arg2, Object obj) { // mSmHandler can be null if the state machine has quit. SmHandler smh = mSmHandler; @@ -1771,6 +1780,7 @@ public class StateMachine { * * Message is ignored if state machine has quit. */ + @UnsupportedAppUsage public void sendMessage(Message msg) { // mSmHandler can be null if the state machine has quit. SmHandler smh = mSmHandler; @@ -2074,6 +2084,7 @@ public class StateMachine { * @param pw * @param args */ + @UnsupportedAppUsage public void dump(FileDescriptor fd, PrintWriter pw, String[] args) { pw.println(getName() + ":"); pw.println(" total records=" + getLogRecCount()); diff --git a/core/java/com/android/internal/view/ActionBarPolicy.java b/core/java/com/android/internal/view/ActionBarPolicy.java index 755faf333a1e..d18c35e703da 100644 --- a/core/java/com/android/internal/view/ActionBarPolicy.java +++ b/core/java/com/android/internal/view/ActionBarPolicy.java @@ -18,6 +18,7 @@ package com.android.internal.view; import com.android.internal.R; +import android.annotation.UnsupportedAppUsage; import android.content.Context; import android.content.res.Configuration; import android.content.res.Resources; @@ -29,12 +30,15 @@ import android.os.Build; * about how the action bar should lay out and behave on the current device. */ public class ActionBarPolicy { + @UnsupportedAppUsage private Context mContext; + @UnsupportedAppUsage public static ActionBarPolicy get(Context context) { return new ActionBarPolicy(context); } + @UnsupportedAppUsage private ActionBarPolicy(Context context) { mContext = context; } @@ -44,6 +48,7 @@ public class ActionBarPolicy { * bar/action mode. This will be used to determine how many showAsAction="ifRoom" items can fit. * "always" items can override this. */ + @UnsupportedAppUsage public int getMaxActionButtons() { final Configuration config = mContext.getResources().getConfiguration(); final int width = config.screenWidthDp; @@ -62,14 +67,17 @@ public class ActionBarPolicy { return 2; } } + @UnsupportedAppUsage public boolean showsOverflowMenuButton() { return true; } + @UnsupportedAppUsage public int getEmbeddedMenuWidthLimit() { return mContext.getResources().getDisplayMetrics().widthPixels / 2; } + @UnsupportedAppUsage public boolean hasEmbeddedTabs() { final int targetSdk = mContext.getApplicationInfo().targetSdkVersion; if (targetSdk >= Build.VERSION_CODES.JELLY_BEAN) { @@ -85,6 +93,7 @@ public class ActionBarPolicy { width >= 480 || (width >= 640 && height >= 480); } + @UnsupportedAppUsage public int getTabContainerHeight() { TypedArray a = mContext.obtainStyledAttributes(null, R.styleable.ActionBar, com.android.internal.R.attr.actionBarStyle, 0); @@ -106,6 +115,7 @@ public class ActionBarPolicy { Build.VERSION_CODES.ICE_CREAM_SANDWICH; } + @UnsupportedAppUsage public int getStackedTabMaxWidth() { return mContext.getResources().getDimensionPixelSize( R.dimen.action_bar_stacked_tab_max_width); diff --git a/core/java/com/android/internal/view/InputConnectionWrapper.java b/core/java/com/android/internal/view/InputConnectionWrapper.java index 5b65bbe1e90e..666c9e093218 100644 --- a/core/java/com/android/internal/view/InputConnectionWrapper.java +++ b/core/java/com/android/internal/view/InputConnectionWrapper.java @@ -19,6 +19,7 @@ package com.android.internal.view; import android.annotation.AnyThread; import android.annotation.BinderThread; import android.annotation.NonNull; +import android.annotation.UnsupportedAppUsage; import android.inputmethodservice.AbstractInputMethodService; import android.os.Bundle; import android.os.Handler; @@ -78,6 +79,7 @@ public class InputConnectionWrapper implements InputConnection { * sequence number is set to a new integer. We use a sequence number so that replies that * occur after a timeout has expired are not interpreted as replies to a later request. */ + @UnsupportedAppUsage @AnyThread private static InputContextCallback getInstance() { synchronized (InputContextCallback.class) { @@ -102,6 +104,7 @@ public class InputConnectionWrapper implements InputConnection { /** * Makes the given InputContextCallback available for use in the future. */ + @UnsupportedAppUsage @AnyThread private void dispose() { synchronized (InputContextCallback.class) { diff --git a/core/java/com/android/internal/view/WindowManagerPolicyThread.java b/core/java/com/android/internal/view/WindowManagerPolicyThread.java index c8c38bb01886..b009a2d8ca30 100644 --- a/core/java/com/android/internal/view/WindowManagerPolicyThread.java +++ b/core/java/com/android/internal/view/WindowManagerPolicyThread.java @@ -16,6 +16,7 @@ package com.android.internal.view; +import android.annotation.UnsupportedAppUsage; import android.os.Looper; /** @@ -35,6 +36,7 @@ public class WindowManagerPolicyThread { return mThread; } + @UnsupportedAppUsage public static Looper getLooper() { return mLooper; } diff --git a/core/java/com/android/internal/view/menu/ActionMenu.java b/core/java/com/android/internal/view/menu/ActionMenu.java index c657b872e71e..977c1f6fda7b 100644 --- a/core/java/com/android/internal/view/menu/ActionMenu.java +++ b/core/java/com/android/internal/view/menu/ActionMenu.java @@ -19,6 +19,7 @@ package com.android.internal.view.menu; import java.util.ArrayList; import java.util.List; +import android.annotation.UnsupportedAppUsage; import android.content.ComponentName; import android.content.Context; import android.content.Intent; @@ -39,6 +40,7 @@ public class ActionMenu implements Menu { private ArrayList<ActionMenuItem> mItems; + @UnsupportedAppUsage public ActionMenu(Context context) { mContext = context; mItems = new ArrayList<ActionMenuItem>(); diff --git a/core/java/com/android/internal/view/menu/ActionMenuItem.java b/core/java/com/android/internal/view/menu/ActionMenuItem.java index b807a42e922e..ed253d58fb82 100644 --- a/core/java/com/android/internal/view/menu/ActionMenuItem.java +++ b/core/java/com/android/internal/view/menu/ActionMenuItem.java @@ -17,6 +17,7 @@ package com.android.internal.view.menu; import android.annotation.Nullable; +import android.annotation.UnsupportedAppUsage; import android.content.Context; import android.content.Intent; import android.content.res.ColorStateList; @@ -69,6 +70,7 @@ public class ActionMenuItem implements MenuItem { private static final int HIDDEN = 0x00000008; private static final int ENABLED = 0x00000010; + @UnsupportedAppUsage public ActionMenuItem(Context context, int group, int id, int categoryOrder, int ordering, CharSequence title) { mContext = context; diff --git a/core/java/com/android/internal/view/menu/ContextMenuBuilder.java b/core/java/com/android/internal/view/menu/ContextMenuBuilder.java index 82f061cb86ca..3d3aceb4a85f 100644 --- a/core/java/com/android/internal/view/menu/ContextMenuBuilder.java +++ b/core/java/com/android/internal/view/menu/ContextMenuBuilder.java @@ -16,6 +16,7 @@ package com.android.internal.view.menu; +import android.annotation.UnsupportedAppUsage; import android.content.Context; import android.graphics.drawable.Drawable; import android.os.IBinder; @@ -39,6 +40,7 @@ import android.view.View; */ public class ContextMenuBuilder extends MenuBuilder implements ContextMenu { + @UnsupportedAppUsage public ContextMenuBuilder(Context context) { super(context); } diff --git a/core/java/com/android/internal/view/menu/IconMenuItemView.java b/core/java/com/android/internal/view/menu/IconMenuItemView.java index 6c8f330fbcc8..3d888d347d65 100644 --- a/core/java/com/android/internal/view/menu/IconMenuItemView.java +++ b/core/java/com/android/internal/view/menu/IconMenuItemView.java @@ -18,6 +18,7 @@ package com.android.internal.view.menu; import com.android.internal.view.menu.MenuBuilder.ItemInvoker; +import android.annotation.UnsupportedAppUsage; import android.content.Context; import android.content.res.TypedArray; import android.graphics.Rect; @@ -213,6 +214,7 @@ public final class IconMenuItemView extends TextView implements MenuView.ItemVie } } + @UnsupportedAppUsage public void setItemInvoker(ItemInvoker itemInvoker) { mItemInvoker = itemInvoker; } @@ -232,6 +234,7 @@ public final class IconMenuItemView extends TextView implements MenuView.ItemVie } } + @UnsupportedAppUsage void setIconMenuView(IconMenuView iconMenuView) { mIconMenuView = iconMenuView; } @@ -267,6 +270,7 @@ public final class IconMenuItemView extends TextView implements MenuView.ItemVie * @return layout params appropriate for this view. If layout params already exist, it will * augment them to be appropriate to the current text size. */ + @UnsupportedAppUsage IconMenuView.LayoutParams getTextAppropriateLayoutParams() { IconMenuView.LayoutParams lp = (IconMenuView.LayoutParams) getLayoutParams(); if (lp == null) { diff --git a/core/java/com/android/internal/view/menu/IconMenuView.java b/core/java/com/android/internal/view/menu/IconMenuView.java index dab43ebfe5d5..6f264341f7b4 100644 --- a/core/java/com/android/internal/view/menu/IconMenuView.java +++ b/core/java/com/android/internal/view/menu/IconMenuView.java @@ -18,6 +18,7 @@ package com.android.internal.view.menu; import com.android.internal.view.menu.MenuBuilder.ItemInvoker; +import android.annotation.UnsupportedAppUsage; import android.content.Context; import android.content.res.Resources; import android.content.res.TypedArray; @@ -51,6 +52,7 @@ import java.util.ArrayList; public final class IconMenuView extends ViewGroup implements ItemInvoker, MenuView, Runnable { private static final int ITEM_CAPTION_CYCLE_DELAY = 1000; + @UnsupportedAppUsage private MenuBuilder mMenu; /** Height of each row */ @@ -58,6 +60,7 @@ public final class IconMenuView extends ViewGroup implements ItemInvoker, MenuVi /** Maximum number of rows to be shown */ private int mMaxRows; /** Maximum number of items to show in the icon menu. */ + @UnsupportedAppUsage private int mMaxItems; /** Maximum number of items per row */ private int mMaxItemsPerRow; @@ -82,6 +85,7 @@ public final class IconMenuView extends ViewGroup implements ItemInvoker, MenuVi private Drawable mMoreIcon; /** Background of each item (should contain the selected and focused states) */ + @UnsupportedAppUsage private Drawable mItemBackground; /** Default animations for this menu */ @@ -288,6 +292,7 @@ public final class IconMenuView extends ViewGroup implements ItemInvoker, MenuVi * have a MenuItemData backing it. * @return The IconMenuItemView for the 'More' button */ + @UnsupportedAppUsage IconMenuItemView createMoreItemView() { Context context = getContext(); LayoutInflater inflater = LayoutInflater.from(context); @@ -494,6 +499,7 @@ public final class IconMenuView extends ViewGroup implements ItemInvoker, MenuVi * {@link MenuView.ItemView} implementation--eg: excludes More * item). */ + @UnsupportedAppUsage int getNumActualItemsShown() { return mNumActualItemsShown; } @@ -717,6 +723,7 @@ public final class IconMenuView extends ViewGroup implements ItemInvoker, MenuVi /** * Constructor called from {@link #CREATOR} */ + @UnsupportedAppUsage private SavedState(Parcel in) { super(in); focusedPosition = in.readInt(); diff --git a/core/java/com/android/internal/view/menu/MenuDialogHelper.java b/core/java/com/android/internal/view/menu/MenuDialogHelper.java index ecab29fdbbd4..88d0a03bd55f 100644 --- a/core/java/com/android/internal/view/menu/MenuDialogHelper.java +++ b/core/java/com/android/internal/view/menu/MenuDialogHelper.java @@ -16,6 +16,7 @@ package com.android.internal.view.menu; +import android.annotation.UnsupportedAppUsage; import android.app.AlertDialog; import android.app.Dialog; import android.content.DialogInterface; @@ -36,6 +37,7 @@ public class MenuDialogHelper implements MenuHelper, DialogInterface.OnKeyListen ListMenuPresenter mPresenter; private MenuPresenter.Callback mPresenterCallback; + @UnsupportedAppUsage public MenuDialogHelper(MenuBuilder menu) { mMenu = menu; } @@ -45,6 +47,7 @@ public class MenuDialogHelper implements MenuHelper, DialogInterface.OnKeyListen * * @param windowToken Optional token to assign to the window. */ + @UnsupportedAppUsage public void show(IBinder windowToken) { // Many references to mMenu, create local reference final MenuBuilder menu = mMenu; @@ -132,6 +135,7 @@ public class MenuDialogHelper implements MenuHelper, DialogInterface.OnKeyListen * * @see Dialog#dismiss() */ + @UnsupportedAppUsage @Override public void dismiss() { if (mDialog != null) { diff --git a/core/java/com/android/internal/widget/AbsActionBarView.java b/core/java/com/android/internal/widget/AbsActionBarView.java index 582c4f1dd669..9ccee7fc32ff 100644 --- a/core/java/com/android/internal/widget/AbsActionBarView.java +++ b/core/java/com/android/internal/widget/AbsActionBarView.java @@ -27,6 +27,7 @@ import android.animation.Animator; import android.animation.AnimatorSet; import android.animation.ObjectAnimator; import android.animation.TimeInterpolator; +import android.annotation.UnsupportedAppUsage; import android.content.Context; import android.content.res.Configuration; import android.content.res.TypedArray; @@ -294,6 +295,7 @@ public abstract class AbsActionBarView extends ViewGroup { return isOverflowReserved() && getVisibility() == VISIBLE; } + @UnsupportedAppUsage public void dismissPopupMenus() { if (mActionMenuPresenter != null) { mActionMenuPresenter.dismissPopupMenus(); diff --git a/core/java/com/android/internal/widget/ActionBarContextView.java b/core/java/com/android/internal/widget/ActionBarContextView.java index 693b194caa8b..78ed53fa918c 100644 --- a/core/java/com/android/internal/widget/ActionBarContextView.java +++ b/core/java/com/android/internal/widget/ActionBarContextView.java @@ -21,6 +21,7 @@ import android.widget.ActionMenuPresenter; import android.widget.ActionMenuView; import com.android.internal.view.menu.MenuBuilder; +import android.annotation.UnsupportedAppUsage; import android.content.Context; import android.content.res.TypedArray; import android.graphics.drawable.Drawable; @@ -58,6 +59,7 @@ public class ActionBarContextView extends AbsActionBarView { this(context, null); } + @UnsupportedAppUsage public ActionBarContextView(Context context, AttributeSet attrs) { this(context, attrs, com.android.internal.R.attr.actionModeStyle); } diff --git a/core/java/com/android/internal/widget/ActionBarOverlayLayout.java b/core/java/com/android/internal/widget/ActionBarOverlayLayout.java index 4a1c95532ba0..efa8f2c3888a 100644 --- a/core/java/com/android/internal/widget/ActionBarOverlayLayout.java +++ b/core/java/com/android/internal/widget/ActionBarOverlayLayout.java @@ -18,6 +18,7 @@ package com.android.internal.widget; import android.animation.Animator; import android.animation.AnimatorListenerAdapter; +import android.annotation.UnsupportedAppUsage; import android.content.Context; import android.content.pm.ActivityInfo; import android.content.res.Configuration; @@ -168,6 +169,7 @@ public class ActionBarOverlayLayout extends ViewGroup implements DecorContentPar init(context); } + @UnsupportedAppUsage public ActionBarOverlayLayout(Context context, AttributeSet attrs) { super(context, attrs); init(context); @@ -672,6 +674,7 @@ public class ActionBarOverlayLayout extends ViewGroup implements DecorContentPar return finalY > mActionBarTop.getHeight(); } + @UnsupportedAppUsage @Override public void setWindowCallback(Window.Callback cb) { pullChildren(); diff --git a/core/java/com/android/internal/widget/EditableInputConnection.java b/core/java/com/android/internal/widget/EditableInputConnection.java index 7f7528dd3de0..4bf34c83a872 100644 --- a/core/java/com/android/internal/widget/EditableInputConnection.java +++ b/core/java/com/android/internal/widget/EditableInputConnection.java @@ -16,6 +16,7 @@ package com.android.internal.widget; +import android.annotation.UnsupportedAppUsage; import android.os.Bundle; import android.text.Editable; import android.text.Spanned; @@ -41,6 +42,7 @@ public class EditableInputConnection extends BaseInputConnection { // A negative value means that this connection has been finished by the InputMethodManager. private int mBatchEditNesting; + @UnsupportedAppUsage public EditableInputConnection(TextView textview) { super(textview, true); mTextView = textview; diff --git a/core/java/com/android/internal/widget/LinearLayoutWithDefaultTouchRecepient.java b/core/java/com/android/internal/widget/LinearLayoutWithDefaultTouchRecepient.java index b2001cbe15ef..cc7911da0b96 100644 --- a/core/java/com/android/internal/widget/LinearLayoutWithDefaultTouchRecepient.java +++ b/core/java/com/android/internal/widget/LinearLayoutWithDefaultTouchRecepient.java @@ -16,6 +16,7 @@ package com.android.internal.widget; +import android.annotation.UnsupportedAppUsage; import android.content.Context; import android.graphics.Rect; import android.util.AttributeSet; @@ -36,6 +37,7 @@ public class LinearLayoutWithDefaultTouchRecepient extends LinearLayout { private final Rect mTempRect = new Rect(); private View mDefaultTouchRecepient; + @UnsupportedAppUsage public LinearLayoutWithDefaultTouchRecepient(Context context) { super(context); } @@ -44,6 +46,7 @@ public class LinearLayoutWithDefaultTouchRecepient extends LinearLayout { super(context, attrs); } + @UnsupportedAppUsage public void setDefaultTouchRecepient(View defaultTouchRecepient) { mDefaultTouchRecepient = defaultTouchRecepient; } diff --git a/core/java/com/android/internal/widget/LockPatternChecker.java b/core/java/com/android/internal/widget/LockPatternChecker.java index 586ece0a274a..2a485f129ab8 100644 --- a/core/java/com/android/internal/widget/LockPatternChecker.java +++ b/core/java/com/android/internal/widget/LockPatternChecker.java @@ -1,5 +1,6 @@ package com.android.internal.widget; +import android.annotation.UnsupportedAppUsage; import android.os.AsyncTask; import com.android.internal.widget.LockPatternUtils.RequestThrottledException; @@ -223,6 +224,7 @@ public final class LockPatternChecker { * @param userId The user to check against the pattern. * @param callback The callback to be invoked with the check result. */ + @UnsupportedAppUsage public static AsyncTask<?, ?, ?> checkPassword(final LockPatternUtils utils, final String password, final int userId, diff --git a/core/java/com/android/internal/widget/LockPatternUtils.java b/core/java/com/android/internal/widget/LockPatternUtils.java index 8eae8afe2407..a3bfd021ca87 100644 --- a/core/java/com/android/internal/widget/LockPatternUtils.java +++ b/core/java/com/android/internal/widget/LockPatternUtils.java @@ -27,6 +27,7 @@ import static android.app.admin.DevicePolicyManager.PASSWORD_QUALITY_UNSPECIFIED import android.annotation.IntDef; import android.annotation.Nullable; +import android.annotation.UnsupportedAppUsage; import android.app.admin.DevicePolicyManager; import android.app.admin.PasswordMetrics; import android.app.trust.IStrongAuthTracker; @@ -169,7 +170,9 @@ public class LockPatternUtils { public static final String SYNTHETIC_PASSWORD_ENABLED_KEY = "enable-sp"; private static final String HISTORY_DELIMITER = ","; + @UnsupportedAppUsage private final Context mContext; + @UnsupportedAppUsage private final ContentResolver mContentResolver; private DevicePolicyManager mDevicePolicyManager; private ILockSettings mLockSettingsService; @@ -212,6 +215,7 @@ public class LockPatternUtils { public static final class RequestThrottledException extends Exception { private int mTimeoutMs; + @UnsupportedAppUsage public RequestThrottledException(int timeoutMs) { mTimeoutMs = timeoutMs; } @@ -220,12 +224,14 @@ public class LockPatternUtils { * @return The amount of time in ms before another request may * be executed */ + @UnsupportedAppUsage public int getTimeoutMs() { return mTimeoutMs; } } + @UnsupportedAppUsage public DevicePolicyManager getDevicePolicyManager() { if (mDevicePolicyManager == null) { mDevicePolicyManager = @@ -254,6 +260,7 @@ public class LockPatternUtils { return trust; } + @UnsupportedAppUsage public LockPatternUtils(Context context) { mContext = context; mContentResolver = context.getContentResolver(); @@ -262,6 +269,7 @@ public class LockPatternUtils { mHandler = looper != null ? new Handler(looper) : null; } + @UnsupportedAppUsage @VisibleForTesting public ILockSettings getLockSettings() { if (mLockSettingsService == null) { @@ -312,6 +320,7 @@ public class LockPatternUtils { return getDevicePolicyManager().getPasswordMinimumNonLetter(null, userId); } + @UnsupportedAppUsage public void reportFailedPasswordAttempt(int userId) { if (userId == USER_FRP && frpCredentialEnabled(mContext)) { return; @@ -320,6 +329,7 @@ public class LockPatternUtils { getTrustManager().reportUnlockAttempt(false /* authenticated */, userId); } + @UnsupportedAppUsage public void reportSuccessfulPasswordAttempt(int userId) { if (userId == USER_FRP && frpCredentialEnabled(mContext)) { return; @@ -479,6 +489,7 @@ public class LockPatternUtils { * @param password The password to check. * @return Whether the password matches the stored one. */ + @UnsupportedAppUsage public boolean checkPassword(String password, int userId) throws RequestThrottledException { return checkPassword(password, userId, null /* progressCallback */); } @@ -602,6 +613,7 @@ public class LockPatternUtils { * Used by device policy manager to validate the current password * information it has. */ + @UnsupportedAppUsage public int getActivePasswordQuality(int userId) { int quality = getKeyguardStoredPasswordQuality(userId); @@ -672,6 +684,7 @@ public class LockPatternUtils { * * @return true if lock screen is disabled */ + @UnsupportedAppUsage public boolean isLockScreenDisabled(int userId) { if (isSecure(userId)) { return false; @@ -754,16 +767,19 @@ public class LockPatternUtils { } } + @UnsupportedAppUsage public void setOwnerInfo(String info, int userId) { setString(LOCK_SCREEN_OWNER_INFO, info, userId); updateCryptoUserInfo(userId); } + @UnsupportedAppUsage public void setOwnerInfoEnabled(boolean enabled, int userId) { setBoolean(LOCK_SCREEN_OWNER_INFO_ENABLED, enabled, userId); updateCryptoUserInfo(userId); } + @UnsupportedAppUsage public String getOwnerInfo(int userId) { return getString(LOCK_SCREEN_OWNER_INFO, userId); } @@ -829,6 +845,7 @@ public class LockPatternUtils { * @param requestedQuality {@see DevicePolicyManager#getPasswordQuality(android.content.ComponentName)} * @param userHandle The userId of the user to change the password for */ + @UnsupportedAppUsage public void saveLockPassword(String password, String savedPassword, int requestedQuality, int userHandle) { if (password == null || password.length() < MIN_LOCK_PASSWORD_SIZE) { @@ -926,6 +943,7 @@ public class LockPatternUtils { * encrypted with the default password. * @return true if device encryption is enabled */ + @UnsupportedAppUsage public static boolean isDeviceEncryptionEnabled() { return StorageManager.isEncrypted(); } @@ -951,6 +969,7 @@ public class LockPatternUtils { * * @return stored password quality */ + @UnsupportedAppUsage public int getKeyguardStoredPasswordQuality(int userHandle) { return (int) getLong(PASSWORD_TYPE_KEY, PASSWORD_QUALITY_UNSPECIFIED, userHandle); } @@ -1072,6 +1091,7 @@ public class LockPatternUtils { * @param pattern The pattern. * @return The pattern in string form. */ + @UnsupportedAppUsage public static String patternToString(List<LockPatternView.Cell> pattern) { if (pattern == null) { return ""; @@ -1107,6 +1127,7 @@ public class LockPatternUtils { * @param pattern the gesture pattern. * @return the hash of the pattern in a byte array. */ + @UnsupportedAppUsage public static byte[] patternToHash(List<LockPatternView.Cell> pattern) { if (pattern == null) { return null; @@ -1193,11 +1214,13 @@ public class LockPatternUtils { * @param userId the user for which to report the value * @return Whether the lock screen is secured. */ + @UnsupportedAppUsage public boolean isSecure(int userId) { int mode = getKeyguardStoredPasswordQuality(userId); return isLockPatternEnabled(mode, userId) || isLockPasswordEnabled(mode, userId); } + @UnsupportedAppUsage public boolean isLockPasswordEnabled(int userId) { return isLockPasswordEnabled(getKeyguardStoredPasswordQuality(userId), userId); } @@ -1215,6 +1238,7 @@ public class LockPatternUtils { /** * @return Whether the lock pattern is enabled */ + @UnsupportedAppUsage public boolean isLockPatternEnabled(int userId) { return isLockPatternEnabled(getKeyguardStoredPasswordQuality(userId), userId); } @@ -1239,6 +1263,7 @@ public class LockPatternUtils { /** * @return Whether the visible pattern is enabled. */ + @UnsupportedAppUsage public boolean isVisiblePatternEnabled(int userId) { return getBoolean(Settings.Secure.LOCK_PATTERN_VISIBLE, false, userId); } @@ -1298,6 +1323,7 @@ public class LockPatternUtils { /** * @return Whether tactile feedback for the pattern is enabled. */ + @UnsupportedAppUsage public boolean isTactileFeedbackEnabled() { return Settings.System.getIntForUser(mContentResolver, Settings.System.HAPTIC_FEEDBACK_ENABLED, 1, UserHandle.USER_CURRENT) != 0; @@ -1308,6 +1334,7 @@ public class LockPatternUtils { * pattern until the deadline has passed. * @return the chosen deadline. */ + @UnsupportedAppUsage public long setLockoutAttemptDeadline(int userId, int timeoutMs) { final long deadline = SystemClock.elapsedRealtime() + timeoutMs; if (userId == USER_FRP) { @@ -1360,6 +1387,7 @@ public class LockPatternUtils { } } + @UnsupportedAppUsage private void setLong(String secureSettingKey, long value, int userHandle) { try { getLockSettings().setLong(secureSettingKey, value, userHandle); @@ -1369,6 +1397,7 @@ public class LockPatternUtils { } } + @UnsupportedAppUsage private String getString(String secureSettingKey, int userHandle) { try { return getLockSettings().getString(secureSettingKey, null, userHandle); @@ -1377,6 +1406,7 @@ public class LockPatternUtils { } } + @UnsupportedAppUsage private void setString(String secureSettingKey, String value, int userHandle) { try { getLockSettings().setString(secureSettingKey, value, userHandle); @@ -1390,6 +1420,7 @@ public class LockPatternUtils { setBoolean(LOCKSCREEN_POWER_BUTTON_INSTANTLY_LOCKS, enabled, userId); } + @UnsupportedAppUsage public boolean getPowerButtonInstantlyLocks(int userId) { return getBoolean(LOCKSCREEN_POWER_BUTTON_INSTANTLY_LOCKS, true, userId); } diff --git a/core/java/com/android/internal/widget/LockPatternView.java b/core/java/com/android/internal/widget/LockPatternView.java index e8fc5989354a..70efd0081fcc 100644 --- a/core/java/com/android/internal/widget/LockPatternView.java +++ b/core/java/com/android/internal/widget/LockPatternView.java @@ -19,6 +19,7 @@ package com.android.internal.widget; import android.animation.Animator; import android.animation.AnimatorListenerAdapter; import android.animation.ValueAnimator; +import android.annotation.UnsupportedAppUsage; import android.content.Context; import android.content.res.Resources; import android.content.res.TypedArray; @@ -79,7 +80,9 @@ public class LockPatternView extends View { private boolean mDrawingProfilingStarted = false; + @UnsupportedAppUsage private final Paint mPaint = new Paint(); + @UnsupportedAppUsage private final Paint mPathPaint = new Paint(); /** @@ -99,6 +102,7 @@ public class LockPatternView extends View { private static final String TAG = "LockPatternView"; private OnPatternListener mOnPatternListener; + @UnsupportedAppUsage private final ArrayList<Cell> mPattern = new ArrayList<Cell>(9); /** @@ -120,16 +124,21 @@ public class LockPatternView extends View { private long mAnimatingPeriodStart; private long[] mLineFadeStart = new long[9]; + @UnsupportedAppUsage private DisplayMode mPatternDisplayMode = DisplayMode.Correct; private boolean mInputEnabled = true; + @UnsupportedAppUsage private boolean mInStealthMode = false; private boolean mEnableHapticFeedback = true; + @UnsupportedAppUsage private boolean mPatternInProgress = false; private boolean mFadePattern = true; private float mHitFactor = 0.6f; + @UnsupportedAppUsage private float mSquareWidth; + @UnsupportedAppUsage private float mSquareHeight; private final Path mCurrentPath = new Path(); @@ -154,7 +163,9 @@ public class LockPatternView extends View { * Represents a cell in the 3 X 3 matrix of the unlock pattern view. */ public static final class Cell { + @UnsupportedAppUsage final int row; + @UnsupportedAppUsage final int column; // keep # objects limited to 9 @@ -232,16 +243,19 @@ public class LockPatternView extends View { /** * The pattern drawn is correct (i.e draw it in a friendly color) */ + @UnsupportedAppUsage Correct, /** * Animate the pattern (for demo, and help). */ + @UnsupportedAppUsage Animate, /** * The pattern is wrong (i.e draw a foreboding color) */ + @UnsupportedAppUsage Wrong } @@ -277,6 +291,7 @@ public class LockPatternView extends View { this(context, null); } + @UnsupportedAppUsage public LockPatternView(Context context, AttributeSet attrs) { super(context, attrs); @@ -348,6 +363,7 @@ public class LockPatternView extends View { a.recycle(); } + @UnsupportedAppUsage public CellState[][] getCellStates() { return mCellStates; } @@ -372,6 +388,7 @@ public class LockPatternView extends View { * * @param inStealthMode Whether in stealth mode. */ + @UnsupportedAppUsage public void setInStealthMode(boolean inStealthMode) { mInStealthMode = inStealthMode; } @@ -390,6 +407,7 @@ public class LockPatternView extends View { * * @param tactileFeedbackEnabled Whether tactile feedback is enabled */ + @UnsupportedAppUsage public void setTactileFeedbackEnabled(boolean tactileFeedbackEnabled) { mEnableHapticFeedback = tactileFeedbackEnabled; } @@ -398,6 +416,7 @@ public class LockPatternView extends View { * Set the call back for pattern detection. * @param onPatternListener The call back. */ + @UnsupportedAppUsage public void setOnPatternListener( OnPatternListener onPatternListener) { mOnPatternListener = onPatternListener; @@ -426,6 +445,7 @@ public class LockPatternView extends View { * in progress result to correct or wrong. * @param displayMode The display mode. */ + @UnsupportedAppUsage public void setDisplayMode(DisplayMode displayMode) { mPatternDisplayMode = displayMode; if (displayMode == DisplayMode.Animate) { @@ -565,6 +585,7 @@ public class LockPatternView extends View { } } + @UnsupportedAppUsage private void notifyPatternDetected() { sendAccessEvent(R.string.lockscreen_access_pattern_detected); if (mOnPatternListener != null) { @@ -582,6 +603,7 @@ public class LockPatternView extends View { /** * Clear the pattern. */ + @UnsupportedAppUsage public void clearPattern() { resetPattern(); } @@ -622,6 +644,7 @@ public class LockPatternView extends View { * Disable input (for instance when displaying a message that will * timeout so user doesn't get view into messy state). */ + @UnsupportedAppUsage public void disableInput() { mInputEnabled = false; } @@ -629,6 +652,7 @@ public class LockPatternView extends View { /** * Enable input. */ + @UnsupportedAppUsage public void enableInput() { mInputEnabled = true; } @@ -1307,6 +1331,7 @@ public class LockPatternView extends View { /** * Constructor called from {@link LockPatternView#onSaveInstanceState()} */ + @UnsupportedAppUsage private SavedState(Parcelable superState, String serializedPattern, int displayMode, boolean inputEnabled, boolean inStealthMode, boolean tactileFeedbackEnabled) { super(superState); @@ -1320,6 +1345,7 @@ public class LockPatternView extends View { /** * Constructor called from {@link #CREATOR} */ + @UnsupportedAppUsage private SavedState(Parcel in) { super(in); mSerializedPattern = in.readString(); diff --git a/core/java/com/android/internal/widget/PointerLocationView.java b/core/java/com/android/internal/widget/PointerLocationView.java index 5847033feb1e..65e10029f37e 100644 --- a/core/java/com/android/internal/widget/PointerLocationView.java +++ b/core/java/com/android/internal/widget/PointerLocationView.java @@ -16,6 +16,7 @@ package com.android.internal.widget; +import android.annotation.UnsupportedAppUsage; import android.content.Context; import android.graphics.Canvas; import android.graphics.Paint; @@ -53,6 +54,7 @@ public class PointerLocationView extends View implements InputDeviceListener, private int mTraceCount; // True if the pointer is down. + @UnsupportedAppUsage private boolean mCurDown; // Most recent coordinates. @@ -120,10 +122,14 @@ public class PointerLocationView extends View implements InputDeviceListener, private final Paint mPathPaint; private final FontMetricsInt mTextMetrics = new FontMetricsInt(); private int mHeaderBottom; + @UnsupportedAppUsage private boolean mCurDown; + @UnsupportedAppUsage private int mCurNumPointers; + @UnsupportedAppUsage private int mMaxNumPointers; private int mActivePointerId; + @UnsupportedAppUsage private final ArrayList<PointerState> mPointers = new ArrayList<PointerState>(); private final PointerCoords mTempCoords = new PointerCoords(); @@ -132,6 +138,7 @@ public class PointerLocationView extends View implements InputDeviceListener, private final FasterStringBuilder mText = new FasterStringBuilder(); + @UnsupportedAppUsage private boolean mPrintCoords = true; public PointerLocationView(Context c) { diff --git a/core/java/com/android/internal/widget/PreferenceImageView.java b/core/java/com/android/internal/widget/PreferenceImageView.java index 8730cdab258b..02a0b8d436b9 100644 --- a/core/java/com/android/internal/widget/PreferenceImageView.java +++ b/core/java/com/android/internal/widget/PreferenceImageView.java @@ -16,6 +16,7 @@ package com.android.internal.widget; +import android.annotation.UnsupportedAppUsage; import android.content.Context; import android.util.AttributeSet; import android.widget.ImageView; @@ -29,6 +30,7 @@ public class PreferenceImageView extends ImageView { this(context, null); } + @UnsupportedAppUsage public PreferenceImageView(Context context, AttributeSet attrs) { this(context, attrs, 0); } diff --git a/core/java/com/android/internal/widget/RecyclerView.java b/core/java/com/android/internal/widget/RecyclerView.java index 408a4e9b02a4..b66a7b44f05d 100644 --- a/core/java/com/android/internal/widget/RecyclerView.java +++ b/core/java/com/android/internal/widget/RecyclerView.java @@ -20,6 +20,7 @@ import android.annotation.CallSuper; import android.annotation.IntDef; import android.annotation.NonNull; import android.annotation.Nullable; +import android.annotation.UnsupportedAppUsage; import android.content.Context; import android.content.res.TypedArray; import android.database.Observable; @@ -4953,6 +4954,7 @@ public class RecyclerView extends ViewGroup implements ScrollingView, NestedScro * constructed by {@link GapWorker} prefetch from being bound to a lower priority prefetch. */ static class ScrapData { + @UnsupportedAppUsage ArrayList<ViewHolder> mScrapHeap = new ArrayList<>(); int mMaxScrap = DEFAULT_MAX_SCRAP; long mCreateRunningAverageNs = 0; diff --git a/core/java/com/android/internal/widget/ScrollBarUtils.java b/core/java/com/android/internal/widget/ScrollBarUtils.java index 0ae9f74167d5..982e3152fc7c 100644 --- a/core/java/com/android/internal/widget/ScrollBarUtils.java +++ b/core/java/com/android/internal/widget/ScrollBarUtils.java @@ -16,8 +16,11 @@ package com.android.internal.widget; +import android.annotation.UnsupportedAppUsage; + public class ScrollBarUtils { + @UnsupportedAppUsage public static int getThumbLength(int size, int thickness, int extent, int range) { // Avoid the tiny thumb. final int minLength = thickness * 2; diff --git a/core/java/com/android/internal/widget/SlidingTab.java b/core/java/com/android/internal/widget/SlidingTab.java index 79adada9cc98..4b5d62467af0 100644 --- a/core/java/com/android/internal/widget/SlidingTab.java +++ b/core/java/com/android/internal/widget/SlidingTab.java @@ -16,6 +16,7 @@ package com.android.internal.widget; +import android.annotation.UnsupportedAppUsage; import android.content.Context; import android.content.res.Resources; import android.content.res.TypedArray; @@ -83,7 +84,9 @@ public class SlidingTab extends ViewGroup { */ private final int mOrientation; + @UnsupportedAppUsage private final Slider mLeftSlider; + @UnsupportedAppUsage private final Slider mRightSlider; private Slider mCurrentSlider; private boolean mTracking; @@ -95,6 +98,7 @@ public class SlidingTab extends ViewGroup { /** * Listener used to reset the view when the current animation completes. */ + @UnsupportedAppUsage private final AnimationListener mAnimationDoneListener = new AnimationListener() { public void onAnimationStart(Animation animation) { @@ -178,7 +182,9 @@ public class SlidingTab extends ViewGroup { private static final int STATE_PRESSED = 1; private static final int STATE_ACTIVE = 2; + @UnsupportedAppUsage private final ImageView tab; + @UnsupportedAppUsage private final TextView text; private final ImageView target; private int currentState = STATE_NORMAL; @@ -708,6 +714,7 @@ public class SlidingTab extends ViewGroup { slider.startAnimation(trans1, trans2); } + @UnsupportedAppUsage private void onAnimationDone() { resetView(); mAnimating = false; @@ -722,6 +729,7 @@ public class SlidingTab extends ViewGroup { return mOrientation == HORIZONTAL; } + @UnsupportedAppUsage private void resetView() { mLeftSlider.reset(false); mRightSlider.reset(false); @@ -763,6 +771,7 @@ public class SlidingTab extends ViewGroup { * @param barId the resource of the bar drawable (stateful) * @param tabId the resource of the */ + @UnsupportedAppUsage public void setLeftTabResources(int iconId, int targetId, int barId, int tabId) { mLeftSlider.setIcon(iconId); mLeftSlider.setTarget(targetId); @@ -776,6 +785,7 @@ public class SlidingTab extends ViewGroup { * * @param resId */ + @UnsupportedAppUsage public void setLeftHintText(int resId) { if (isHorizontal()) { mLeftSlider.setHintText(resId); @@ -793,6 +803,7 @@ public class SlidingTab extends ViewGroup { * @param barId the resource of the bar drawable (stateful) * @param tabId the resource of the */ + @UnsupportedAppUsage public void setRightTabResources(int iconId, int targetId, int barId, int tabId) { mRightSlider.setIcon(iconId); mRightSlider.setTarget(targetId); @@ -806,12 +817,14 @@ public class SlidingTab extends ViewGroup { * * @param resId */ + @UnsupportedAppUsage public void setRightHintText(int resId) { if (isHorizontal()) { mRightSlider.setHintText(resId); } } + @UnsupportedAppUsage public void setHoldAfterTrigger(boolean holdLeft, boolean holdRight) { mHoldLeftOnTransition = holdLeft; mHoldRightOnTransition = holdRight; @@ -838,6 +851,7 @@ public class SlidingTab extends ViewGroup { * * @param listener the OnDialTriggerListener to attach to this view */ + @UnsupportedAppUsage public void setOnTriggerListener(OnTriggerListener listener) { mOnTriggerListener = listener; } diff --git a/core/java/com/android/internal/widget/TextViewInputDisabler.java b/core/java/com/android/internal/widget/TextViewInputDisabler.java index fb0b3b95b6f2..8d8f0fe52d64 100644 --- a/core/java/com/android/internal/widget/TextViewInputDisabler.java +++ b/core/java/com/android/internal/widget/TextViewInputDisabler.java @@ -16,6 +16,7 @@ package com.android.internal.widget; +import android.annotation.UnsupportedAppUsage; import android.text.InputFilter; import android.text.Spanned; import android.widget.TextView; @@ -38,11 +39,13 @@ public class TextViewInputDisabler { } }; + @UnsupportedAppUsage public TextViewInputDisabler(TextView textView) { mTextView = textView; mDefaultFilters = mTextView.getFilters(); } + @UnsupportedAppUsage public void setInputEnabled(boolean enabled) { mTextView.setFilters(enabled ? mDefaultFilters : mNoInputFilters); } diff --git a/core/java/com/android/internal/widget/ViewPager.java b/core/java/com/android/internal/widget/ViewPager.java index 64bdc6e1eb37..574a09f8d3af 100644 --- a/core/java/com/android/internal/widget/ViewPager.java +++ b/core/java/com/android/internal/widget/ViewPager.java @@ -18,6 +18,7 @@ package com.android.internal.widget; import android.annotation.DrawableRes; import android.annotation.NonNull; +import android.annotation.UnsupportedAppUsage; import android.content.Context; import android.content.res.Resources; import android.content.res.TypedArray; @@ -243,6 +244,7 @@ public class ViewPager extends ViewGroup { * @param positionOffset Value from [0, 1) indicating the offset from the page at position. * @param positionOffsetPixels Value in pixels indicating the offset from position. */ + @UnsupportedAppUsage public void onPageScrolled(int position, float positionOffset, int positionOffsetPixels); /** @@ -251,6 +253,7 @@ public class ViewPager extends ViewGroup { * * @param position Position index of the new selected page. */ + @UnsupportedAppUsage public void onPageSelected(int position); /** @@ -263,6 +266,7 @@ public class ViewPager extends ViewGroup { * @see com.android.internal.widget.ViewPager#SCROLL_STATE_DRAGGING * @see com.android.internal.widget.ViewPager#SCROLL_STATE_SETTLING */ + @UnsupportedAppUsage public void onPageScrollStateChanged(int state); } @@ -483,6 +487,7 @@ public class ViewPager extends ViewGroup { setCurrentItemInternal(item, smoothScroll, false); } + @UnsupportedAppUsage public int getCurrentItem() { return mCurItem; } diff --git a/core/java/com/android/server/ResettableTimeout.java b/core/java/com/android/server/ResettableTimeout.java index ac5b160670b0..64083f72aff5 100644 --- a/core/java/com/android/server/ResettableTimeout.java +++ b/core/java/com/android/server/ResettableTimeout.java @@ -18,6 +18,7 @@ package com.android.server; import android.os.SystemClock; +import android.annotation.UnsupportedAppUsage; import android.os.ConditionVariable; /** @@ -120,9 +121,11 @@ abstract class ResettableTimeout } } + @UnsupportedAppUsage private ConditionVariable mLock = new ConditionVariable(); // turn it off at this time. + @UnsupportedAppUsage private volatile long mOffAt; private volatile boolean mOffCalled; diff --git a/core/java/com/android/server/net/BaseNetworkObserver.java b/core/java/com/android/server/net/BaseNetworkObserver.java index 3d9fb5c872f7..a0740eee5df6 100644 --- a/core/java/com/android/server/net/BaseNetworkObserver.java +++ b/core/java/com/android/server/net/BaseNetworkObserver.java @@ -16,6 +16,7 @@ package com.android.server.net; +import android.annotation.UnsupportedAppUsage; import android.net.INetworkManagementEventObserver; import android.net.LinkAddress; import android.net.RouteInfo; diff --git a/core/java/com/android/server/net/NetlinkTracker.java b/core/java/com/android/server/net/NetlinkTracker.java index 5b421d988e0a..647fb5b9d079 100644 --- a/core/java/com/android/server/net/NetlinkTracker.java +++ b/core/java/com/android/server/net/NetlinkTracker.java @@ -16,6 +16,7 @@ package com.android.server.net; +import android.annotation.UnsupportedAppUsage; import android.net.LinkAddress; import android.net.LinkProperties; import android.net.RouteInfo; @@ -79,6 +80,7 @@ public class NetlinkTracker extends BaseNetworkObserver { private static final boolean DBG = false; + @UnsupportedAppUsage public NetlinkTracker(String iface, Callback callback) { TAG = "NetlinkTracker/" + iface; mInterfaceName = iface; @@ -187,10 +189,12 @@ public class NetlinkTracker extends BaseNetworkObserver { /** * Returns a copy of this object's LinkProperties. */ + @UnsupportedAppUsage public synchronized LinkProperties getLinkProperties() { return new LinkProperties(mLinkProperties); } + @UnsupportedAppUsage public synchronized void clearLinkProperties() { // Clear the repository before clearing mLinkProperties. That way, if a clear() happens // while interfaceDnsServerInfo() is being called, we'll end up with no DNS servers in diff --git a/core/java/com/google/android/collect/Lists.java b/core/java/com/google/android/collect/Lists.java index 3ea873bbb0f9..8f6594aefb0a 100644 --- a/core/java/com/google/android/collect/Lists.java +++ b/core/java/com/google/android/collect/Lists.java @@ -57,6 +57,7 @@ public class Lists { * @param elements the elements that the list should contain, in order * @return a newly-created {@code ArrayList} containing those elements */ + @UnsupportedAppUsage public static <E> ArrayList<E> newArrayList(E... elements) { int capacity = (elements.length * 110) / 100 + 5; ArrayList<E> list = new ArrayList<E>(capacity); diff --git a/core/java/com/google/android/collect/Sets.java b/core/java/com/google/android/collect/Sets.java index dd3cab15d0b2..09b5e51ae2c6 100644 --- a/core/java/com/google/android/collect/Sets.java +++ b/core/java/com/google/android/collect/Sets.java @@ -16,6 +16,7 @@ package com.google.android.collect; +import android.annotation.UnsupportedAppUsage; import android.util.ArraySet; import java.util.Collections; @@ -42,6 +43,7 @@ public class Sets { * * @return a newly-created, initially-empty {@code HashSet} */ + @UnsupportedAppUsage public static <K> HashSet<K> newHashSet() { return new HashSet<K>(); } @@ -63,6 +65,7 @@ public class Sets { * @return a newly-created {@code HashSet} containing those elements (minus * duplicates) */ + @UnsupportedAppUsage public static <E> HashSet<E> newHashSet(E... elements) { int capacity = elements.length * 4 / 3 + 1; HashSet<E> set = new HashSet<E>(capacity); @@ -75,6 +78,7 @@ public class Sets { * * @return a newly-created, initially-empty {@code SortedSet}. */ + @UnsupportedAppUsage public static <E> SortedSet<E> newSortedSet() { return new TreeSet<E>(); } @@ -95,6 +99,7 @@ public class Sets { /** * Creates a {@code ArraySet} instance. */ + @UnsupportedAppUsage public static <E> ArraySet<E> newArraySet() { return new ArraySet<E>(); } @@ -102,6 +107,7 @@ public class Sets { /** * Creates a {@code ArraySet} instance containing the given elements. */ + @UnsupportedAppUsage public static <E> ArraySet<E> newArraySet(E... elements) { int capacity = elements.length * 4 / 3 + 1; ArraySet<E> set = new ArraySet<E>(capacity); diff --git a/core/java/com/google/android/util/AbstractMessageParser.java b/core/java/com/google/android/util/AbstractMessageParser.java index 1871682ee063..9d12f82aeb75 100644 --- a/core/java/com/google/android/util/AbstractMessageParser.java +++ b/core/java/com/google/android/util/AbstractMessageParser.java @@ -16,6 +16,7 @@ package com.google.android.util; +import android.annotation.UnsupportedAppUsage; import java.util.ArrayList; import java.util.HashMap; import java.util.LinkedHashMap; @@ -654,15 +655,25 @@ public abstract class AbstractMessageParser { public static abstract class Token { public enum Type { + @UnsupportedAppUsage HTML ("html"), + @UnsupportedAppUsage FORMAT ("format"), // subtype of HTML + @UnsupportedAppUsage LINK ("l"), + @UnsupportedAppUsage SMILEY ("e"), + @UnsupportedAppUsage ACRONYM ("a"), + @UnsupportedAppUsage MUSIC ("m"), + @UnsupportedAppUsage GOOGLE_VIDEO ("v"), + @UnsupportedAppUsage YOUTUBE_VIDEO ("yt"), + @UnsupportedAppUsage PHOTO ("p"), + @UnsupportedAppUsage FLICKR ("f"); //stringreps for HTML and FORMAT don't really matter diff --git a/core/jni/AndroidRuntime.cpp b/core/jni/AndroidRuntime.cpp index 388285a5687f..79850d03160a 100644 --- a/core/jni/AndroidRuntime.cpp +++ b/core/jni/AndroidRuntime.cpp @@ -1112,6 +1112,12 @@ void AndroidRuntime::start(const char* className, const Vector<String8>& options return; } + const char* tzdataRootDir = getenv("ANDROID_TZDATA_ROOT"); + if (tzdataRootDir == NULL) { + LOG_FATAL("No tz data directory specified with ANDROID_TZDATA_ROOT environment variable."); + return; + } + //const char* kernelHack = getenv("LD_ASSUME_KERNEL"); //ALOGD("Found LD_ASSUME_KERNEL='%s'\n", kernelHack); diff --git a/core/jni/android_net_NetUtils.cpp b/core/jni/android_net_NetUtils.cpp index cfb2dd199f39..d7a981ed3e9d 100644 --- a/core/jni/android_net_NetUtils.cpp +++ b/core/jni/android_net_NetUtils.cpp @@ -487,6 +487,11 @@ static jbyteArray android_net_utils_resNetworkResult(JNIEnv *env, jobject thiz, return answer; } +static void android_net_utils_resNetworkCancel(JNIEnv *env, jobject thiz, jobject javaFd) { + int fd = jniGetFDFromFileDescriptor(env, javaFd); + resNetworkCancel(fd); +} + static jobject android_net_utils_getTcpRepairWindow(JNIEnv *env, jobject thiz, jobject javaFd) { if (javaFd == NULL) { jniThrowNullPointerException(env, NULL); @@ -546,6 +551,7 @@ static const JNINativeMethod gNetworkUtilMethods[] = { { "resNetworkSend", "(I[BII)Ljava/io/FileDescriptor;", (void*) android_net_utils_resNetworkSend }, { "resNetworkQuery", "(ILjava/lang/String;III)Ljava/io/FileDescriptor;", (void*) android_net_utils_resNetworkQuery }, { "resNetworkResult", "(Ljava/io/FileDescriptor;)[B", (void*) android_net_utils_resNetworkResult }, + { "resNetworkCancel", "(Ljava/io/FileDescriptor;)V", (void*) android_net_utils_resNetworkCancel }, }; int register_android_net_NetworkUtils(JNIEnv* env) diff --git a/core/proto/android/stats/connectivity/Android.bp b/core/proto/android/stats/connectivity/Android.bp new file mode 100644 index 000000000000..5aa4ddbdf7f9 --- /dev/null +++ b/core/proto/android/stats/connectivity/Android.bp @@ -0,0 +1,25 @@ +// 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. + +java_library_static { + name: "networkstackprotosnano", + proto: { + type: "nano", + }, + srcs: [ + "network_stack.proto", + ], + sdk_version: "system_current", + no_framework_libs: true, +}
\ No newline at end of file diff --git a/core/java/android/net/ApfCapabilitiesParcelable.aidl b/core/proto/android/stats/connectivity/network_stack.proto index f0645d2782d2..7d9aa1c6eb23 100644 --- a/core/java/android/net/ApfCapabilitiesParcelable.aidl +++ b/core/proto/android/stats/connectivity/network_stack.proto @@ -14,10 +14,13 @@ * limitations under the License. */ -package android.net; +syntax = "proto2"; + +package android.stats.connectivity; +option java_multiple_files = true; +option java_outer_classname = "NetworkStackProto"; + +message NetworkStackEventData { + +} -parcelable ApfCapabilitiesParcelable { - int apfVersionSupported; - int maximumApfProgramSize; - int apfPacketFormat; -}
\ No newline at end of file diff --git a/core/res/AndroidManifest.xml b/core/res/AndroidManifest.xml index 3d0b12d3f7e6..71879194ccf6 100644 --- a/core/res/AndroidManifest.xml +++ b/core/res/AndroidManifest.xml @@ -1009,6 +1009,18 @@ android:description="@string/permdesc_manageOwnCalls" android:protectionLevel="normal" /> + <!--Allows an app which implements the + {@link android.telecom.InCallService} API to be eligible to be enabled as a calling companion app. This + means that the Telecom framework will bind to the app's InCallService implementation when + there are calls active. The app can use the InCallService API to view information about + calls on the system and control these calls. + <p>Protection level: normal + --> + <permission android:name="android.permission.CALL_COMPANION_APP" + android:label="@string/permlab_callCompanionApp" + android:description="@string/permdesc_callCompanionApp" + android:protectionLevel="normal" /> + <!-- Allows a calling app to continue a call which was started in another app. An example is a video calling app that wants to continue a voice call on the user's mobile network.<p> When the handover of a call from one app to another takes place, there are two devices @@ -1829,6 +1841,12 @@ <permission android:name="android.permission.BIND_INCALL_SERVICE" android:protectionLevel="signature|privileged" /> + <!-- Allows the app to request network scans from telephony. + <p>Not for use by third-party applications. + @SystemApi @hide--> + <permission android:name="android.permission.NETWORK_SCAN" + android:protectionLevel="signature|privileged" /> + <!-- Must be required by a link {@link android.telephony.VisualVoicemailService} to ensure that only the system can bind to it. <p>Protection level: signature|privileged diff --git a/core/res/res/drawable/ic_bluetooth_share_icon.xml b/core/res/res/drawable/ic_bluetooth_share_icon.xml new file mode 100644 index 000000000000..2446402be93f --- /dev/null +++ b/core/res/res/drawable/ic_bluetooth_share_icon.xml @@ -0,0 +1,27 @@ +<!-- + 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. +--> +<!-- This drawable should only be used by the Bluetooth application for its share target icon. --> +<vector xmlns:android="http://schemas.android.com/apk/res/android" + android:width="24dp" + android:height="24dp" + android:viewportWidth="24" + android:viewportHeight="24" + android:tint="@android:color/accent_device_default"> + + <path + android:fillColor="@android:color/white" + android:pathData="M17.71,7.71L12,2h-1v7.59L6.41,5L5,6.41L10.59,12L5,17.59L6.41,19L11,14.41V22h1l5.71-5.71L13.41,12L17.71,7.71z M13,5.83 l1.88,1.88L13,9.59V5.83z M14.88,16.29L13,18.17v-3.76L14.88,16.29z" /> +</vector>
\ No newline at end of file diff --git a/core/res/res/values-night/colors_device_defaults.xml b/core/res/res/values-night/colors_device_defaults.xml new file mode 100644 index 000000000000..08ad4926197b --- /dev/null +++ b/core/res/res/values-night/colors_device_defaults.xml @@ -0,0 +1,19 @@ +<?xml version="1.0" encoding="utf-8"?> +<!-- 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. +--> + +<resources> + <color name="accent_device_default">@color/accent_device_default_dark</color> +</resources>
\ No newline at end of file diff --git a/core/res/res/values/colors_device_defaults.xml b/core/res/res/values/colors_device_defaults.xml index 256c53133096..212e1cc55137 100644 --- a/core/res/res/values/colors_device_defaults.xml +++ b/core/res/res/values/colors_device_defaults.xml @@ -35,6 +35,7 @@ <color name="accent_device_default_light">@color/accent_material_light</color> <color name="accent_device_default_dark">@color/accent_material_dark</color> + <color name="accent_device_default">@color/accent_device_default_light</color> <color name="background_device_default_dark">@color/background_material_dark</color> <color name="background_device_default_light">@color/background_material_light</color> diff --git a/core/res/res/values/config.xml b/core/res/res/values/config.xml index 97ae8e5215fe..7698d271cfac 100644 --- a/core/res/res/values/config.xml +++ b/core/res/res/values/config.xml @@ -302,6 +302,15 @@ Settings.Global.NETWORK_AVOID_BAD_WIFI. This is the default value of that setting. --> <integer translatable="false" name="config_networkAvoidBadWifi">1</integer> + <!-- The URL returned by ConnectivityManager#getCaptivePortalServerUrl. The actual returned + value is controlled by Settings.Global.CAPTIVE_PORTAL_HTTP_URL. This is the default value + used if that setting is unset. + This is *NOT* a URL that will always be used by the system network validation to detect + captive portals: NetworkMonitor may use different strategies and will not necessarily use + this URL. NetworkMonitor behaviour should be configured with NetworkStack resource overlays + instead. --> + <string translatable="false" name="config_networkDefaultCaptivePortalServerUrl">http://connectivitycheck.gstatic.com/generate_204</string> + <!-- If the hardware supports specially marking packets that caused a wakeup of the main CPU, set this value to the mark used. --> <integer name="config_networkWakeupPacketMark">0</integer> diff --git a/core/res/res/values/strings.xml b/core/res/res/values/strings.xml index 75aa60f1242a..4f6775b99e10 100644 --- a/core/res/res/values/strings.xml +++ b/core/res/res/values/strings.xml @@ -1185,6 +1185,15 @@ <string name="permdesc_manageOwnCalls">Allows the app to route its calls through the system in order to improve the calling experience.</string> + <!-- Title of an application permission. When granted the app is allowed to be enabled as + a companion app. [CHAR LIMIT=NONE]--> + <string name="permlab_callCompanionApp">see and control calls through the system.</string> + <!-- Description of an application permission. When granted the app is allowed to be enabled as + a companion app. [CHAR LIMIT=NONE]--> + <string name="permdesc_callCompanionApp">Allows the app to see and control ongoing calls on the + device. This includes information such as call numbers for calls and the state of the + calls.</string> + <!-- Title of an application permission. When granted the user is giving access to a third party app to continue a call which originated in another app. For example, the user could be in a voice call over their carrier's mobile network, and a third party video diff --git a/core/res/res/values/symbols.xml b/core/res/res/values/symbols.xml index a95fa540e33a..05303c96ea80 100644 --- a/core/res/res/values/symbols.xml +++ b/core/res/res/values/symbols.xml @@ -1945,6 +1945,7 @@ <java-symbol type="integer" name="config_networkNotifySwitchType" /> <java-symbol type="array" name="config_networkNotifySwitches" /> <java-symbol type="integer" name="config_networkAvoidBadWifi" /> + <java-symbol type="string" name="config_networkDefaultCaptivePortalServerUrl" /> <java-symbol type="integer" name="config_networkWakeupPacketMark" /> <java-symbol type="integer" name="config_networkWakeupPacketMask" /> <java-symbol type="bool" name="config_apfDrop802_3Frames" /> diff --git a/core/tests/coretests/src/android/app/servertransaction/ClientTransactionTests.java b/core/tests/coretests/src/android/app/servertransaction/ClientTransactionTests.java index b1f855246320..c59098795faf 100644 --- a/core/tests/coretests/src/android/app/servertransaction/ClientTransactionTests.java +++ b/core/tests/coretests/src/android/app/servertransaction/ClientTransactionTests.java @@ -29,6 +29,15 @@ import android.support.test.runner.AndroidJUnit4; import org.junit.Test; import org.junit.runner.RunWith; +/** + * Tests for {@link ClientTransaction}. + * + * <p>Build/Install/Run: + * atest FrameworksCoreTests:ClientTransactionTests + * + * <p>This test class is a part of Window Manager Service tests and specified in + * {@link com.android.server.wm.test.filters.FrameworksTestsFilter}. + */ @RunWith(AndroidJUnit4.class) @SmallTest @Presubmit diff --git a/core/tests/coretests/src/android/app/servertransaction/ObjectPoolTests.java b/core/tests/coretests/src/android/app/servertransaction/ObjectPoolTests.java index fb0f5344f643..32e5f008c729 100644 --- a/core/tests/coretests/src/android/app/servertransaction/ObjectPoolTests.java +++ b/core/tests/coretests/src/android/app/servertransaction/ObjectPoolTests.java @@ -41,6 +41,15 @@ import android.support.test.runner.AndroidJUnit4; import org.junit.Test; import org.junit.runner.RunWith; +/** + * Tests for {@link ObjectPool}. + * + * <p>Build/Install/Run: + * atest FrameworksCoreTests:ObjectPoolTests + * + * <p>This test class is a part of Window Manager Service tests and specified in + * {@link com.android.server.wm.test.filters.FrameworksTestsFilter}. + */ @RunWith(AndroidJUnit4.class) @SmallTest @Presubmit diff --git a/core/tests/coretests/src/android/app/servertransaction/TransactionExecutorTests.java b/core/tests/coretests/src/android/app/servertransaction/TransactionExecutorTests.java index fe58116002f2..6620a2e86272 100644 --- a/core/tests/coretests/src/android/app/servertransaction/TransactionExecutorTests.java +++ b/core/tests/coretests/src/android/app/servertransaction/TransactionExecutorTests.java @@ -26,9 +26,8 @@ import static android.app.servertransaction.ActivityLifecycleItem.ON_STOP; import static android.app.servertransaction.ActivityLifecycleItem.PRE_ON_CREATE; import static android.app.servertransaction.ActivityLifecycleItem.UNDEFINED; -import static junit.framework.Assert.assertEquals; - import static org.junit.Assert.assertArrayEquals; +import static org.junit.Assert.assertEquals; import static org.mockito.ArgumentMatchers.any; import static org.mockito.ArgumentMatchers.eq; import static org.mockito.Mockito.inOrder; @@ -58,7 +57,15 @@ import java.util.Collections; import java.util.List; import java.util.stream.Collectors; -/** Test {@link TransactionExecutor} logic. */ +/** + * Test {@link TransactionExecutor} logic. + * + * <p>Build/Install/Run: + * atest FrameworksCoreTests:TransactionExecutorTests + * + * <p>This test class is a part of Window Manager Service tests and specified in + * {@link com.android.server.wm.test.filters.FrameworksTestsFilter}. + */ @RunWith(AndroidJUnit4.class) @SmallTest @Presubmit diff --git a/core/tests/coretests/src/android/app/servertransaction/TransactionParcelTests.java b/core/tests/coretests/src/android/app/servertransaction/TransactionParcelTests.java index 104208eefef7..d922c16a9297 100644 --- a/core/tests/coretests/src/android/app/servertransaction/TransactionParcelTests.java +++ b/core/tests/coretests/src/android/app/servertransaction/TransactionParcelTests.java @@ -21,8 +21,8 @@ import static android.app.servertransaction.TestUtils.mergedConfig; import static android.app.servertransaction.TestUtils.referrerIntentList; import static android.app.servertransaction.TestUtils.resultInfoList; -import static junit.framework.Assert.assertEquals; -import static junit.framework.Assert.assertTrue; +import static org.junit.Assert.assertEquals; +import static org.junit.Assert.assertTrue; import android.app.IApplicationThread; import android.app.IInstrumentationWatcher; @@ -60,7 +60,15 @@ import org.junit.runner.RunWith; import java.util.List; import java.util.Map; -/** Test parcelling and unparcelling of transactions and transaction items. */ +/** + * Test parcelling and unparcelling of transactions and transaction items. + * + * <p>Build/Install/Run: + * atest FrameworksCoreTests:TransactionParcelTests + * + * <p>This test class is a part of Window Manager Service tests and specified in + * {@link com.android.server.wm.test.filters.FrameworksTestsFilter}. + */ @RunWith(AndroidJUnit4.class) @SmallTest @Presubmit diff --git a/core/tests/coretests/src/android/view/DisplayCutoutTest.java b/core/tests/coretests/src/android/view/DisplayCutoutTest.java index fe45fe7d3aaf..a3df1a094ec0 100644 --- a/core/tests/coretests/src/android/view/DisplayCutoutTest.java +++ b/core/tests/coretests/src/android/view/DisplayCutoutTest.java @@ -40,6 +40,15 @@ import org.junit.runner.RunWith; import java.util.Arrays; +/** + * Tests for {@link DisplayCutout}. + * + * <p>Build/Install/Run: + * atest FrameworksCoreTests:DisplayCutoutTest + * + * <p>This test class is a part of Window Manager Service tests and specified in + * {@link com.android.server.wm.test.filters.FrameworksTestsFilter}. + */ @RunWith(AndroidJUnit4.class) @SmallTest @Presubmit diff --git a/core/tests/coretests/src/com/android/server/wm/test/filters/CoreTestsFilter.java b/core/tests/coretests/src/com/android/server/wm/test/filters/CoreTestsFilter.java deleted file mode 100644 index 941cfdb20fed..000000000000 --- a/core/tests/coretests/src/com/android/server/wm/test/filters/CoreTestsFilter.java +++ /dev/null @@ -1,44 +0,0 @@ -/* - * 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. - */ - -package com.android.server.wm.test.filters; - -import android.os.Bundle; - -import com.android.test.filters.SelectTest; - -/** - * JUnit test filter that select Window Manager Service related tests from FrameworksCoreTests. - * - * <p>Use this filter when running FrameworksCoreTests as - * <pre> - * adb shell am instrument -w \ - * -e filter com.android.server.wm.test.filters.CoreTestsFilter \ - * -e selectTest_verbose true \ - * com.android.frameworks.coretests/androidx.test.runner.AndroidJUnitRunner - * </pre> - */ -public final class CoreTestsFilter extends SelectTest { - - private static final String[] SELECTED_CORE_TESTS = { - "android.app.servertransaction.", // all tests under the package. - "android.view.DisplayCutoutTest", - }; - - public CoreTestsFilter(Bundle testArgs) { - super(addSelectTest(testArgs, SELECTED_CORE_TESTS)); - } -} diff --git a/data/etc/Android.bp b/data/etc/Android.bp index bb4765835890..3968f84471c5 100644 --- a/data/etc/Android.bp +++ b/data/etc/Android.bp @@ -66,6 +66,14 @@ prebuilt_etc { } prebuilt_etc { + name: "privapp_whitelist_com.android.emergency", + product_specific: true, + sub_dir: "permissions", + src: "com.android.emergency.xml", + filename_from_src: true, +} + +prebuilt_etc { name: "privapp_whitelist_com.android.launcher3", product_specific: true, sub_dir: "permissions", diff --git a/data/etc/com.android.emergency.xml b/data/etc/com.android.emergency.xml new file mode 100644 index 000000000000..28f99dd1d018 --- /dev/null +++ b/data/etc/com.android.emergency.xml @@ -0,0 +1,23 @@ +<?xml version="1.0" encoding="utf-8"?> +<!-- + ~ 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 + --> +<permissions> + <privapp-permissions package="com.android.emergency"> + <!-- Required to place emergency calls from emergency info screen. --> + <permission name="android.permission.CALL_PRIVILEGED"/> + <permission name="android.permission.MANAGE_USERS"/> + </privapp-permissions> +</permissions> diff --git a/data/etc/privapp-permissions-platform.xml b/data/etc/privapp-permissions-platform.xml index 78bbcf137f2a..9decd086972a 100644 --- a/data/etc/privapp-permissions-platform.xml +++ b/data/etc/privapp-permissions-platform.xml @@ -48,12 +48,6 @@ applications that come with the platform <permission name="android.permission.WRITE_MEDIA_STORAGE"/> </privapp-permissions> - <privapp-permissions package="com.android.emergency"> - <!-- Required to place emergency calls from emergency info screen. --> - <permission name="android.permission.CALL_PRIVILEGED"/> - <permission name="android.permission.MANAGE_USERS"/> - </privapp-permissions> - <privapp-permissions package="com.android.externalstorage"> <permission name="android.permission.MOUNT_UNMOUNT_FILESYSTEMS"/> <permission name="android.permission.WRITE_MEDIA_STORAGE"/> diff --git a/location/java/com/android/internal/location/GpsNetInitiatedHandler.java b/location/java/com/android/internal/location/GpsNetInitiatedHandler.java index b5313256e4dc..4c8d04549bed 100644 --- a/location/java/com/android/internal/location/GpsNetInitiatedHandler.java +++ b/location/java/com/android/internal/location/GpsNetInitiatedHandler.java @@ -241,6 +241,8 @@ public class GpsNetInitiatedHandler { * window after the end of that call. * 3. If the device is in a emergency callback state, this is provided by querying * TelephonyManager. + * 4. If the user has recently sent an Emergency SMS and telephony reports that it is in + * emergency SMS mode, this is provided by querying TelephonyManager. * @return true if is considered in user initiated emergency mode for NI purposes */ public boolean getInEmergency() { @@ -248,7 +250,9 @@ public class GpsNetInitiatedHandler { (SystemClock.elapsedRealtime() - mCallEndElapsedRealtimeMillis) < mEmergencyExtensionMillis; boolean isInEmergencyCallback = mTelephonyManager.getEmergencyCallbackMode(); - return mIsInEmergencyCall || isInEmergencyCallback || isInEmergencyExtension; + boolean isInEmergencySmsMode = mTelephonyManager.isInEmergencySmsMode(); + return mIsInEmergencyCall || isInEmergencyCallback || isInEmergencyExtension + || isInEmergencySmsMode; } public void setEmergencyExtensionSeconds(int emergencyExtensionSeconds) { diff --git a/media/java/android/media/projection/OWNERS b/media/java/android/media/projection/OWNERS new file mode 100644 index 000000000000..7e7335d68d3b --- /dev/null +++ b/media/java/android/media/projection/OWNERS @@ -0,0 +1 @@ +michaelwr@google.com diff --git a/media/mca/effect/java/android/media/effect/SingleFilterEffect.java b/media/mca/effect/java/android/media/effect/SingleFilterEffect.java index 47900dfcfd5a..dfbf5d20e074 100644 --- a/media/mca/effect/java/android/media/effect/SingleFilterEffect.java +++ b/media/mca/effect/java/android/media/effect/SingleFilterEffect.java @@ -17,6 +17,7 @@ package android.media.effect; +import android.annotation.UnsupportedAppUsage; import android.filterfw.core.Filter; import android.filterfw.core.FilterFactory; import android.filterfw.core.FilterFunction; @@ -44,6 +45,7 @@ public class SingleFilterEffect extends FilterEffect { * @param outputName The name of the output image port. * @param finalParameters Key-value pairs of final input port assignments. */ + @UnsupportedAppUsage public SingleFilterEffect(EffectContext context, String name, Class filterClass, diff --git a/media/mca/filterfw/java/android/filterfw/GraphEnvironment.java b/media/mca/filterfw/java/android/filterfw/GraphEnvironment.java index 7c90b2731ff8..52615bf09faa 100644 --- a/media/mca/filterfw/java/android/filterfw/GraphEnvironment.java +++ b/media/mca/filterfw/java/android/filterfw/GraphEnvironment.java @@ -119,6 +119,7 @@ public class GraphEnvironment extends MffEnvironment { * * @param references An alternating argument list of keys (Strings) and values. */ + @UnsupportedAppUsage public void addReferences(Object... references) { getGraphReader().addReferencesByKeysAndValues(references); } diff --git a/packages/CaptivePortalLogin/src/com/android/captiveportallogin/CaptivePortalLoginActivity.java b/packages/CaptivePortalLogin/src/com/android/captiveportallogin/CaptivePortalLoginActivity.java index 2c9b6eb72b4d..9488afb446c4 100644 --- a/packages/CaptivePortalLogin/src/com/android/captiveportallogin/CaptivePortalLoginActivity.java +++ b/packages/CaptivePortalLogin/src/com/android/captiveportallogin/CaptivePortalLoginActivity.java @@ -53,6 +53,7 @@ import android.view.View; import android.webkit.CookieManager; import android.webkit.SslErrorHandler; import android.webkit.WebChromeClient; +import android.webkit.WebResourceRequest; import android.webkit.WebSettings; import android.webkit.WebView; import android.webkit.WebViewClient; @@ -408,8 +409,7 @@ public class CaptivePortalLoginActivity extends Activity { TypedValue.applyDimension(TypedValue.COMPLEX_UNIT_DIP, 1, getResources().getDisplayMetrics()); private int mPagesLoaded; - // the host of the page that this webview is currently loading. Can be null when undefined. - private String mHostname; + private String mMainFrameUrl; // If we haven't finished cleaning up the history, don't allow going back. public boolean allowBack() { @@ -435,7 +435,6 @@ public class CaptivePortalLoginActivity extends Activity { } final URL url = makeURL(urlString); Log.d(TAG, "onPageStarted: " + sanitizeURL(url)); - mHostname = host(url); // For internally generated pages, leave URL bar listing prior URL as this is the URL // the page refers to. if (!urlString.startsWith(INTERNAL_ASSETS)) { @@ -479,17 +478,28 @@ public class CaptivePortalLoginActivity extends Activity { return Integer.toString((int)dp) + "px"; } + // Check if webview is trying to load the main frame and record its url. + @Override + public boolean shouldOverrideUrlLoading(WebView view, WebResourceRequest request) { + if (request.isForMainFrame()) { + mMainFrameUrl = request.getUrl().toString(); + } + return false; + } + // A web page consisting of a large broken lock icon to indicate SSL failure. @Override public void onReceivedSslError(WebView view, SslErrorHandler handler, SslError error) { - final URL url = makeURL(error.getUrl()); - final String host = host(url); + final URL errorUrl = makeURL(error.getUrl()); + final URL mainFrameUrl = makeURL(mMainFrameUrl); Log.d(TAG, String.format("SSL error: %s, url: %s, certificate: %s", - sslErrorName(error), sanitizeURL(url), error.getCertificate())); - if (url == null || !Objects.equals(host, mHostname)) { - // Ignore ssl errors for resources coming from a different hostname than the page - // that we are currently loading, and only cancel the request. + sslErrorName(error), sanitizeURL(errorUrl), error.getCertificate())); + if (errorUrl == null + // Ignore SSL errors from resources by comparing the main frame url with SSL + // error url. + || !errorUrl.equals(mainFrameUrl)) { + Log.d(TAG, "onReceivedSslError: mMainFrameUrl = " + mMainFrameUrl); handler.cancel(); return; } diff --git a/packages/NetworkStack/Android.bp b/packages/NetworkStack/Android.bp index 8872147b65ed..52534a8fbae7 100644 --- a/packages/NetworkStack/Android.bp +++ b/packages/NetworkStack/Android.bp @@ -14,11 +14,16 @@ // limitations under the License. // +java_defaults { + name: "NetworkStackCommon", + sdk_version: "system_current", + min_sdk_version: "28", +} + // Library including the network stack, used to compile both variants of the network stack android_library { name: "NetworkStackBase", - sdk_version: "system_current", - min_sdk_version: "28", + defaults: ["NetworkStackCommon"], srcs: [ "src/**/*.java", ":framework-networkstack-shared-srcs", @@ -29,38 +34,37 @@ android_library { "netd_aidl_interface-java", "networkstack-aidl-interfaces-java", "datastallprotosnano", + "networkstackprotosnano", ], manifest: "AndroidManifestBase.xml", } -// Non-updatable in-process network stack for devices not using the module -android_app { - name: "InProcessNetworkStack", - sdk_version: "system_current", - min_sdk_version: "28", - certificate: "platform", +java_defaults { + name: "NetworkStackAppCommon", + defaults: ["NetworkStackCommon"], privileged: true, static_libs: [ "NetworkStackBase", ], + // Resources already included in NetworkStackBase + resource_dirs: [], jarjar_rules: "jarjar-rules-shared.txt", // The permission configuration *must* be included to ensure security of the device required: ["NetworkStackPermissionStub"], +} + +// Non-updatable network stack running in the system server process for devices not using the module +android_app { + name: "InProcessNetworkStack", + defaults: ["NetworkStackAppCommon"], + certificate: "platform", manifest: "AndroidManifest_InProcess.xml", } // Updatable network stack packaged as an application android_app { name: "NetworkStack", - sdk_version: "system_current", - min_sdk_version: "28", + defaults: ["NetworkStackAppCommon"], certificate: "networkstack", - privileged: true, - static_libs: [ - "NetworkStackBase" - ], - jarjar_rules: "jarjar-rules-shared.txt", - // The permission configuration *must* be included to ensure security of the device - required: ["NetworkStackPermissionStub"], manifest: "AndroidManifest.xml", } diff --git a/packages/NetworkStack/AndroidManifest.xml b/packages/NetworkStack/AndroidManifest.xml index a90db11df016..b0a7923d65f4 100644 --- a/packages/NetworkStack/AndroidManifest.xml +++ b/packages/NetworkStack/AndroidManifest.xml @@ -19,6 +19,7 @@ <manifest xmlns:android="http://schemas.android.com/apk/res/android" package="com.android.networkstack" android:sharedUserId="android.uid.networkstack"> + <uses-sdk android:minSdkVersion="28" android:targetSdkVersion="28" /> <!-- Signature permission defined in NetworkStackStub --> <uses-permission android:name="android.permission.MAINLINE_NETWORK_STACK" /> <application> @@ -28,4 +29,4 @@ </intent-filter> </service> </application> -</manifest>
\ No newline at end of file +</manifest> diff --git a/packages/NetworkStack/AndroidManifestBase.xml b/packages/NetworkStack/AndroidManifestBase.xml index 621d30c31f98..f69e4b2bb795 100644 --- a/packages/NetworkStack/AndroidManifestBase.xml +++ b/packages/NetworkStack/AndroidManifestBase.xml @@ -20,7 +20,6 @@ package="com.android.networkstack" android:versionCode="11" android:versionName="Q-initial"> - <uses-sdk android:minSdkVersion="28" android:targetSdkVersion="28" /> <uses-permission android:name="android.permission.INTERNET" /> <uses-permission android:name="android.permission.ACCESS_COARSE_LOCATION" /> <uses-permission android:name="android.permission.ACCESS_NETWORK_STATE" /> diff --git a/packages/NetworkStack/AndroidManifest_InProcess.xml b/packages/NetworkStack/AndroidManifest_InProcess.xml index 48fcecd2f06d..275cd02a6cc0 100644 --- a/packages/NetworkStack/AndroidManifest_InProcess.xml +++ b/packages/NetworkStack/AndroidManifest_InProcess.xml @@ -20,6 +20,7 @@ package="com.android.networkstack.inprocess" android:sharedUserId="android.uid.system" android:process="system"> + <uses-sdk android:minSdkVersion="28" android:targetSdkVersion="28" /> <application> <service android:name="com.android.server.NetworkStackService" android:process="system"> <intent-filter> @@ -27,4 +28,4 @@ </intent-filter> </service> </application> -</manifest>
\ No newline at end of file +</manifest> diff --git a/packages/NetworkStack/jarjar-rules-shared.txt b/packages/NetworkStack/jarjar-rules-shared.txt index a8c712a3336d..7346b1ae81e6 100644 --- a/packages/NetworkStack/jarjar-rules-shared.txt +++ b/packages/NetworkStack/jarjar-rules-shared.txt @@ -8,12 +8,3 @@ rule android.net.shared.InetAddressUtils* android.net.networkstack.shared.InetAd rule android.net.DhcpResultsParcelable* @0 rule android.net.DhcpResults* android.net.networkstack.DhcpResults@1 rule android.net.LocalLog* android.net.networkstack.LocalLog@1 - -# TODO: remove from framework dependencies, then remove here -rule android.net.InterfaceConfigurationParcel* android.net.networkstack.InterfaceConfigurationParcel@1 -rule android.net.TetherStatsParcel* android.net.networkstack.TetherStatsParcel@1 - -# Used by UidRange, which is used by framework classes such as NetworkCapabilities. -rule android.net.UidRangeParcel* android.net.networkstack.UidRangeParcel@1 -# TODO: move TcpKeepalivePacketData to services.net and delete -rule android.net.TcpKeepalivePacketDataParcelable* android.net.networkstack.TcpKeepalivePacketDataParcelable@1
\ No newline at end of file diff --git a/packages/NetworkStack/res/values/config.xml b/packages/NetworkStack/res/values/config.xml new file mode 100644 index 000000000000..52425e57ba3a --- /dev/null +++ b/packages/NetworkStack/res/values/config.xml @@ -0,0 +1,5 @@ +<?xml version="1.0" encoding="utf-8"?> +<resources> + <!-- Captive portal http url --> + <string name="config_captive_portal_http_url" translatable="false">http://connectivitycheck.gstatic.com/generate_204</string> +</resources>
\ No newline at end of file diff --git a/packages/NetworkStack/src/android/net/dhcp/DhcpClient.java b/packages/NetworkStack/src/android/net/dhcp/DhcpClient.java index 0b7809e9f614..c6dd0117477b 100644 --- a/packages/NetworkStack/src/android/net/dhcp/DhcpClient.java +++ b/packages/NetworkStack/src/android/net/dhcp/DhcpClient.java @@ -102,9 +102,9 @@ public class DhcpClient extends StateMachine { private static final String TAG = "DhcpClient"; private static final boolean DBG = true; - private static final boolean STATE_DBG = false; - private static final boolean MSG_DBG = false; - private static final boolean PACKET_DBG = false; + private static final boolean STATE_DBG = Log.isLoggable(TAG, Log.DEBUG); + private static final boolean MSG_DBG = Log.isLoggable(TAG, Log.DEBUG); + private static final boolean PACKET_DBG = Log.isLoggable(TAG, Log.DEBUG); // Metrics events: must be kept in sync with server-side aggregation code. /** Represents transitions from DhcpInitState to DhcpBoundState */ diff --git a/packages/NetworkStack/src/android/net/dhcp/DhcpServingParams.java b/packages/NetworkStack/src/android/net/dhcp/DhcpServingParams.java index 3cd2aa40dfb2..230b693a809a 100644 --- a/packages/NetworkStack/src/android/net/dhcp/DhcpServingParams.java +++ b/packages/NetworkStack/src/android/net/dhcp/DhcpServingParams.java @@ -329,7 +329,7 @@ public class DhcpServingParams { if (mLinkMtu != MTU_UNSET && (mLinkMtu < IPV4_MIN_MTU || mLinkMtu > IPV4_MAX_MTU)) { throw new InvalidParameterException("Invalid link MTU: " + mLinkMtu); } - if (!mServerAddr.isIPv4()) { + if (!mServerAddr.isIpv4()) { throw new InvalidParameterException("serverAddr must be IPv4"); } if (mServerAddr.getPrefixLength() < MIN_PREFIX_LENGTH diff --git a/packages/NetworkStack/src/android/net/ip/IpClient.java b/packages/NetworkStack/src/android/net/ip/IpClient.java index b68fe235647a..346ac68407de 100644 --- a/packages/NetworkStack/src/android/net/ip/IpClient.java +++ b/packages/NetworkStack/src/android/net/ip/IpClient.java @@ -834,7 +834,7 @@ public class IpClient extends StateMachine { static boolean isProvisioned(LinkProperties lp, InitialConfiguration config) { // For historical reasons, we should connect even if all we have is // an IPv4 address and nothing else. - if (lp.hasIPv4Address() || lp.isProvisioned()) { + if (lp.hasIpv4Address() || lp.isProvisioned()) { return true; } if (config == null) { @@ -878,9 +878,9 @@ public class IpClient extends StateMachine { delta = PROV_CHANGE_LOST_PROVISIONING; } - final boolean lostIPv6 = oldLp.isIPv6Provisioned() && !newLp.isIPv6Provisioned(); - final boolean lostIPv4Address = oldLp.hasIPv4Address() && !newLp.hasIPv4Address(); - final boolean lostIPv6Router = oldLp.hasIPv6DefaultRoute() && !newLp.hasIPv6DefaultRoute(); + final boolean lostIPv6 = oldLp.isIpv6Provisioned() && !newLp.isIpv6Provisioned(); + final boolean lostIPv4Address = oldLp.hasIpv4Address() && !newLp.hasIpv4Address(); + final boolean lostIPv6Router = oldLp.hasIpv6DefaultRoute() && !newLp.hasIpv6DefaultRoute(); // If bad wifi avoidance is disabled, then ignore IPv6 loss of // provisioning. Otherwise, when a hotspot that loses Internet @@ -897,7 +897,7 @@ public class IpClient extends StateMachine { // accompanying code in IpReachabilityMonitor) is unreachable. final boolean ignoreIPv6ProvisioningLoss = mConfiguration != null && mConfiguration.mUsingMultinetworkPolicyTracker - && mCm.getAvoidBadWifi(); + && mCm.shouldAvoidBadWifi(); // Additionally: // @@ -920,7 +920,7 @@ public class IpClient extends StateMachine { // If the previous link properties had a global IPv6 address and an // IPv6 default route then also consider the loss of that default route // to be a loss of provisioning. See b/27962810. - if (oldLp.hasGlobalIPv6Address() && (lostIPv6Router && !ignoreIPv6ProvisioningLoss)) { + if (oldLp.hasGlobalIpv6Address() && (lostIPv6Router && !ignoreIPv6ProvisioningLoss)) { delta = PROV_CHANGE_LOST_PROVISIONING; } @@ -1156,7 +1156,7 @@ public class IpClient extends StateMachine { private boolean applyInitialConfig(InitialConfiguration config) { // TODO: also support specifying a static IPv4 configuration in InitialConfiguration. - for (LinkAddress addr : findAll(config.ipAddresses, LinkAddress::isIPv6)) { + for (LinkAddress addr : findAll(config.ipAddresses, LinkAddress::isIpv6)) { if (!mInterfaceCtrl.addAddress(addr)) return false; } @@ -1374,7 +1374,7 @@ public class IpClient extends StateMachine { } private boolean readyToProceed() { - return (!mLinkProperties.hasIPv4Address() && !mLinkProperties.hasGlobalIPv6Address()); + return (!mLinkProperties.hasIpv4Address() && !mLinkProperties.hasGlobalIpv6Address()); } } diff --git a/packages/NetworkStack/src/android/net/ip/IpReachabilityMonitor.java b/packages/NetworkStack/src/android/net/ip/IpReachabilityMonitor.java index 76a03387a12d..c19a24eb7fb6 100644 --- a/packages/NetworkStack/src/android/net/ip/IpReachabilityMonitor.java +++ b/packages/NetworkStack/src/android/net/ip/IpReachabilityMonitor.java @@ -129,8 +129,8 @@ import java.util.Map; */ public class IpReachabilityMonitor { private static final String TAG = "IpReachabilityMonitor"; - private static final boolean DBG = false; - private static final boolean VDBG = false; + private static final boolean DBG = Log.isLoggable(TAG, Log.DEBUG); + private static final boolean VDBG = Log.isLoggable(TAG, Log.VERBOSE); public interface Callback { // This callback function must execute as quickly as possible as it is @@ -316,8 +316,8 @@ public class IpReachabilityMonitor { } final boolean lostProvisioning = - (mLinkProperties.isIPv4Provisioned() && !whatIfLp.isIPv4Provisioned()) - || (mLinkProperties.isIPv6Provisioned() && !whatIfLp.isIPv6Provisioned()); + (mLinkProperties.isIpv4Provisioned() && !whatIfLp.isIpv4Provisioned()) + || (mLinkProperties.isIpv6Provisioned() && !whatIfLp.isIpv6Provisioned()); if (lostProvisioning) { final String logMsg = "FAILURE: LOST_PROVISIONING, " + event; @@ -332,7 +332,7 @@ public class IpReachabilityMonitor { } private boolean avoidingBadLinks() { - return !mUsingMultinetworkPolicyTracker || mCm.getAvoidBadWifi(); + return !mUsingMultinetworkPolicyTracker || mCm.shouldAvoidBadWifi(); } public void probeAll() { diff --git a/packages/NetworkStack/src/com/android/server/NetworkStackService.java b/packages/NetworkStack/src/com/android/server/NetworkStackService.java index 335d9513bddb..19e9108d2fc8 100644 --- a/packages/NetworkStack/src/com/android/server/NetworkStackService.java +++ b/packages/NetworkStack/src/com/android/server/NetworkStackService.java @@ -277,9 +277,9 @@ public class NetworkStackService extends Service { } @Override - public void notifyAcceptPartialConnectivity() { + public void setAcceptPartialConnectivity() { checkNetworkStackCallingPermission(); - mNm.notifyAcceptPartialConnectivity(); + mNm.setAcceptPartialConnectivity(); } @Override diff --git a/packages/NetworkStack/src/com/android/server/connectivity/NetworkMonitor.java b/packages/NetworkStack/src/com/android/server/connectivity/NetworkMonitor.java index bcfc412c6f4e..f3476ed1566f 100644 --- a/packages/NetworkStack/src/com/android/server/connectivity/NetworkMonitor.java +++ b/packages/NetworkStack/src/com/android/server/connectivity/NetworkMonitor.java @@ -72,7 +72,7 @@ import android.os.UserHandle; import android.provider.Settings; import android.telephony.AccessNetworkConstants; import android.telephony.CellSignalStrength; -import android.telephony.NetworkRegistrationState; +import android.telephony.NetworkRegistrationInfo; import android.telephony.ServiceState; import android.telephony.SignalStrength; import android.telephony.TelephonyManager; @@ -83,6 +83,7 @@ import com.android.internal.annotations.VisibleForTesting; import com.android.internal.util.RingBufferIndices; import com.android.internal.util.State; import com.android.internal.util.StateMachine; +import com.android.networkstack.R; import java.io.IOException; import java.net.HttpURLConnection; @@ -319,7 +320,8 @@ public class NetworkMonitor extends StateMachine { private final DnsStallDetector mDnsStallDetector; private long mLastProbeTime; // Set to true if data stall is suspected and reset to false after metrics are sent to statsd. - private boolean mCollectDataStallMetrics = false; + private boolean mCollectDataStallMetrics; + private boolean mAcceptPartialConnectivity; public NetworkMonitor(Context context, INetworkMonitorCallbacks cb, Network network, SharedLog validationLog) { @@ -386,10 +388,11 @@ public class NetworkMonitor extends StateMachine { } /** - * ConnectivityService notifies NetworkMonitor that the user accepts partial connectivity and - * NetworkMonitor should ignore the https probe. + * ConnectivityService notifies NetworkMonitor that the user already accepted partial + * connectivity previously, so NetworkMonitor can validate the network even if it has partial + * connectivity. */ - public void notifyAcceptPartialConnectivity() { + public void setAcceptPartialConnectivity() { sendMessage(EVENT_ACCEPT_PARTIAL_CONNECTIVITY); } @@ -651,9 +654,11 @@ public class NetworkMonitor extends StateMachine { case EVENT_DNS_NOTIFICATION: mDnsStallDetector.accumulateConsecutiveDnsTimeoutCount(message.arg1); break; + // Set mAcceptPartialConnectivity to true and if network start evaluating or + // re-evaluating and get the result of partial connectivity, ProbingState will + // disable HTTPS probe and transition to EvaluatingPrivateDnsState. case EVENT_ACCEPT_PARTIAL_CONNECTIVITY: - mUseHttps = false; - transitionTo(mEvaluatingPrivateDnsState); + mAcceptPartialConnectivity = true; break; default: break; @@ -849,6 +854,14 @@ public class NetworkMonitor extends StateMachine { // ignore any re-evaluation requests. After, restart the // evaluation process via EvaluatingState#enter. return (mEvaluateAttempts < IGNORE_REEVALUATE_ATTEMPTS) ? HANDLED : NOT_HANDLED; + // Disable HTTPS probe and transition to EvaluatingPrivateDnsState because: + // 1. Network is connected and finish the network validation. + // 2. NetworkMonitor detects network is partial connectivity and user accepts it. + case EVENT_ACCEPT_PARTIAL_CONNECTIVITY: + mAcceptPartialConnectivity = true; + mUseHttps = false; + transitionTo(mEvaluatingPrivateDnsState); + return HANDLED; default: return NOT_HANDLED; } @@ -1081,7 +1094,12 @@ public class NetworkMonitor extends StateMachine { logNetworkEvent(NetworkEvent.NETWORK_PARTIAL_CONNECTIVITY); notifyNetworkTested(NETWORK_TEST_RESULT_PARTIAL_CONNECTIVITY, probeResult.redirectUrl); - transitionTo(mWaitingForNextProbeState); + if (mAcceptPartialConnectivity) { + mUseHttps = false; + transitionTo(mEvaluatingPrivateDnsState); + } else { + transitionTo(mWaitingForNextProbeState); + } } else { logNetworkEvent(NetworkEvent.NETWORK_VALIDATION_FAILED); notifyNetworkTested(NETWORK_TEST_RESULT_INVALID, probeResult.redirectUrl); @@ -1615,12 +1633,12 @@ public class NetworkMonitor extends StateMachine { return; } // See if the data sub is registered for PS services on cell. - final NetworkRegistrationState nrs = dataSs.getNetworkRegistrationState( - NetworkRegistrationState.DOMAIN_PS, + final NetworkRegistrationInfo nri = dataSs.getNetworkRegistrationInfo( + NetworkRegistrationInfo.DOMAIN_PS, AccessNetworkConstants.TRANSPORT_TYPE_WWAN); latencyBroadcast.putExtra( NetworkMonitorUtils.EXTRA_CELL_ID, - nrs == null ? null : nrs.getCellIdentity()); + nri == null ? null : nri.getCellIdentity()); latencyBroadcast.putExtra(NetworkMonitorUtils.EXTRA_CONNECTIVITY_TYPE, TYPE_MOBILE); } else { return; @@ -1693,9 +1711,15 @@ public class NetworkMonitor extends StateMachine { /** * Get the captive portal server HTTP URL that is configured on the device. + * + * NetworkMonitor does not use {@link ConnectivityManager#getCaptivePortalServerUrl()} as + * it has its own updatable strategies to detect captive portals. The framework only advises + * on one URL that can be used, while NetworkMonitor may implement more complex logic. */ public String getCaptivePortalServerHttpUrl(Context context) { - return NetworkMonitorUtils.getCaptivePortalServerHttpUrl(context); + final String defaultUrl = + context.getResources().getString(R.string.config_captive_portal_http_url); + return NetworkMonitorUtils.getCaptivePortalServerHttpUrl(context, defaultUrl); } /** diff --git a/packages/NetworkStack/tests/src/com/android/server/connectivity/NetworkMonitorTest.java b/packages/NetworkStack/tests/src/com/android/server/connectivity/NetworkMonitorTest.java index d93aef2b73f6..d732c4e81d83 100644 --- a/packages/NetworkStack/tests/src/com/android/server/connectivity/NetworkMonitorTest.java +++ b/packages/NetworkStack/tests/src/com/android/server/connectivity/NetworkMonitorTest.java @@ -583,7 +583,7 @@ public class NetworkMonitorTest { verify(mCallbacks, timeout(HANDLER_TIMEOUT_MS).times(1)) .notifyNetworkTested(NETWORK_TEST_RESULT_PARTIAL_CONNECTIVITY, null); - nm.notifyAcceptPartialConnectivity(); + nm.setAcceptPartialConnectivity(); verify(mCallbacks, timeout(HANDLER_TIMEOUT_MS).times(1)) .notifyNetworkTested(NETWORK_TEST_RESULT_VALID, null); } diff --git a/packages/SettingsLib/res/values/strings.xml b/packages/SettingsLib/res/values/strings.xml index 23e13c231c20..d5b121768a66 100644 --- a/packages/SettingsLib/res/values/strings.xml +++ b/packages/SettingsLib/res/values/strings.xml @@ -97,6 +97,9 @@ <!-- Summary for Connected wifi network without internet --> <string name="wifi_connected_no_internet">Connected, no internet</string> + <!-- Summary for connected wifi network with partial internet connectivity [CHAR LIMIT=50] --> + <string name="wifi_limited_connection">Limited connection</string> + <!-- Wi-Fi status indicating that the current network is connected, but has no internet access. --> <string name="wifi_status_no_internet">No internet</string> diff --git a/packages/SettingsLib/src/com/android/settingslib/wifi/AccessPoint.java b/packages/SettingsLib/src/com/android/settingslib/wifi/AccessPoint.java index b9c76013b0d7..0d3b7a3b0dab 100644 --- a/packages/SettingsLib/src/com/android/settingslib/wifi/AccessPoint.java +++ b/packages/SettingsLib/src/com/android/settingslib/wifi/AccessPoint.java @@ -48,7 +48,6 @@ import android.os.RemoteException; import android.os.ServiceManager; import android.os.SystemClock; import android.os.UserHandle; -import androidx.annotation.NonNull; import android.text.Spannable; import android.text.SpannableString; import android.text.TextUtils; @@ -56,6 +55,8 @@ import android.text.style.TtsSpan; import android.util.ArraySet; import android.util.Log; +import androidx.annotation.NonNull; + import com.android.internal.annotations.VisibleForTesting; import com.android.settingslib.R; import com.android.settingslib.utils.ThreadUtils; @@ -1243,6 +1244,9 @@ public class AccessPoint implements Comparable<AccessPoint> { int id = context.getResources() .getIdentifier("network_available_sign_in", "string", "android"); return context.getString(id); + } else if (nc.hasCapability( + NetworkCapabilities.NET_CAPABILITY_PARTIAL_CONNECTIVITY)) { + return context.getString(R.string.wifi_limited_connection); } else if (!nc.hasCapability(NetworkCapabilities.NET_CAPABILITY_VALIDATED)) { return context.getString(R.string.wifi_connected_no_internet); } diff --git a/packages/SettingsLib/src/com/android/settingslib/wifi/WifiStatusTracker.java b/packages/SettingsLib/src/com/android/settingslib/wifi/WifiStatusTracker.java index fe0b35b4191c..faefc0fd6969 100644 --- a/packages/SettingsLib/src/com/android/settingslib/wifi/WifiStatusTracker.java +++ b/packages/SettingsLib/src/com/android/settingslib/wifi/WifiStatusTracker.java @@ -11,6 +11,7 @@ package com.android.settingslib.wifi; import static android.net.NetworkCapabilities.NET_CAPABILITY_CAPTIVE_PORTAL; +import static android.net.NetworkCapabilities.NET_CAPABILITY_PARTIAL_CONNECTIVITY; import static android.net.NetworkCapabilities.NET_CAPABILITY_VALIDATED; import android.content.Context; @@ -151,6 +152,9 @@ public class WifiStatusTracker extends ConnectivityManager.NetworkCallback { if (networkCapabilities.hasCapability(NET_CAPABILITY_CAPTIVE_PORTAL)) { statusLabel = mContext.getString(R.string.wifi_status_sign_in_required); return; + } else if (networkCapabilities.hasCapability(NET_CAPABILITY_PARTIAL_CONNECTIVITY)) { + statusLabel = mContext.getString(R.string.wifi_limited_connection); + return; } else if (!networkCapabilities.hasCapability(NET_CAPABILITY_VALIDATED)) { statusLabel = mContext.getString(R.string.wifi_status_no_internet); return; diff --git a/packages/Shell/src/com/android/shell/BugreportProgressService.java b/packages/Shell/src/com/android/shell/BugreportProgressService.java index a9ff21fef99c..1060c7b7ce79 100644 --- a/packages/Shell/src/com/android/shell/BugreportProgressService.java +++ b/packages/Shell/src/com/android/shell/BugreportProgressService.java @@ -1095,6 +1095,7 @@ public class BugreportProgressService extends Service { new AsyncTask<Void, Void, Void>() { @Override protected Void doInBackground(Void... params) { + Looper.prepare(); zipBugreport(info); sendBugreportNotification(info, takingScreenshot); return null; diff --git a/packages/SystemUI/OWNERS b/packages/SystemUI/OWNERS index 3f6ebf0fe09d..99c48cb0eaec 100644 --- a/packages/SystemUI/OWNERS +++ b/packages/SystemUI/OWNERS @@ -20,6 +20,7 @@ juliacr@google.com juliatuttle@google.com kozynski@google.com kprevas@google.com +lynhan@google.com madym@google.com mankoff@google.com nbenbernou@google.com diff --git a/packages/SystemUI/src/com/android/systemui/media/OWNERS b/packages/SystemUI/src/com/android/systemui/media/OWNERS new file mode 100644 index 000000000000..69ea57bfd397 --- /dev/null +++ b/packages/SystemUI/src/com/android/systemui/media/OWNERS @@ -0,0 +1 @@ +per-file MediaProjectionPermissionActivity.java = michaelwr@google.com diff --git a/packages/SystemUI/src/com/android/systemui/statusbar/policy/MobileSignalController.java b/packages/SystemUI/src/com/android/systemui/statusbar/policy/MobileSignalController.java index 9734918f624c..2f7e3b18d3c1 100644 --- a/packages/SystemUI/src/com/android/systemui/statusbar/policy/MobileSignalController.java +++ b/packages/SystemUI/src/com/android/systemui/statusbar/policy/MobileSignalController.java @@ -22,7 +22,7 @@ import android.net.NetworkCapabilities; import android.os.Handler; import android.os.Looper; import android.provider.Settings.Global; -import android.telephony.NetworkRegistrationState; +import android.telephony.NetworkRegistrationInfo; import android.telephony.PhoneStateListener; import android.telephony.ServiceState; import android.telephony.SignalStrength; @@ -494,8 +494,8 @@ public class MobileSignalController extends SignalController< private MobileIconGroup getNr5GIconGroup() { if (mServiceState == null) return null; - int nrStatus = mServiceState.getNrStatus(); - if (nrStatus == NetworkRegistrationState.NR_STATUS_CONNECTED) { + int nrState = mServiceState.getNrState(); + if (nrState == NetworkRegistrationInfo.NR_STATE_CONNECTED) { // Check if the NR 5G is using millimeter wave and the icon is config. if (mServiceState.getNrFrequencyRange() == ServiceState.FREQUENCY_RANGE_MMWAVE) { if (mConfig.nr5GIconMap.containsKey(Config.NR_CONNECTED_MMWAVE)) { @@ -508,11 +508,11 @@ public class MobileSignalController extends SignalController< if (mConfig.nr5GIconMap.containsKey(Config.NR_CONNECTED)) { return mConfig.nr5GIconMap.get(Config.NR_CONNECTED); } - } else if (nrStatus == NetworkRegistrationState.NR_STATUS_NOT_RESTRICTED) { + } else if (nrState == NetworkRegistrationInfo.NR_STATE_NOT_RESTRICTED) { if (mConfig.nr5GIconMap.containsKey(Config.NR_NOT_RESTRICTED)) { return mConfig.nr5GIconMap.get(Config.NR_NOT_RESTRICTED); } - } else if (nrStatus == NetworkRegistrationState.NR_STATUS_RESTRICTED) { + } else if (nrState == NetworkRegistrationInfo.NR_STATE_RESTRICTED) { if (mConfig.nr5GIconMap.containsKey(Config.NR_RESTRICTED)) { return mConfig.nr5GIconMap.get(Config.NR_RESTRICTED); } diff --git a/packages/SystemUI/tests/src/com/android/systemui/statusbar/policy/NetworkControllerDataTest.java b/packages/SystemUI/tests/src/com/android/systemui/statusbar/policy/NetworkControllerDataTest.java index 2baea1ae3b19..96fad21ed7a3 100644 --- a/packages/SystemUI/tests/src/com/android/systemui/statusbar/policy/NetworkControllerDataTest.java +++ b/packages/SystemUI/tests/src/com/android/systemui/statusbar/policy/NetworkControllerDataTest.java @@ -7,7 +7,7 @@ import static org.mockito.Mockito.when; import android.net.NetworkCapabilities; import android.os.Looper; -import android.telephony.NetworkRegistrationState; +import android.telephony.NetworkRegistrationInfo; import android.telephony.ServiceState; import android.telephony.TelephonyManager; import android.test.suitebuilder.annotation.SmallTest; @@ -151,7 +151,7 @@ public class NetworkControllerDataTest extends NetworkControllerBaseTest { updateDataConnectionState(TelephonyManager.DATA_CONNECTED, TelephonyManager.NETWORK_TYPE_LTE); ServiceState ss = Mockito.mock(ServiceState.class); - doReturn(NetworkRegistrationState.NR_STATUS_CONNECTED).when(ss).getNrStatus(); + doReturn(NetworkRegistrationInfo.NR_STATE_CONNECTED).when(ss).getNrState(); doReturn(ServiceState.FREQUENCY_RANGE_HIGH).when(ss).getNrFrequencyRange(); mPhoneStateListener.onServiceStateChanged(ss); @@ -165,7 +165,7 @@ public class NetworkControllerDataTest extends NetworkControllerBaseTest { updateDataConnectionState(TelephonyManager.DATA_CONNECTED, TelephonyManager.NETWORK_TYPE_LTE); ServiceState ss = Mockito.mock(ServiceState.class); - doReturn(NetworkRegistrationState.NR_STATUS_CONNECTED).when(ss).getNrStatus(); + doReturn(NetworkRegistrationInfo.NR_STATE_CONNECTED).when(ss).getNrState(); doReturn(ServiceState.FREQUENCY_RANGE_MMWAVE).when(ss).getNrFrequencyRange(); mPhoneStateListener.onServiceStateChanged(ss); @@ -179,7 +179,7 @@ public class NetworkControllerDataTest extends NetworkControllerBaseTest { updateDataConnectionState(TelephonyManager.DATA_CONNECTED, TelephonyManager.NETWORK_TYPE_LTE); ServiceState ss = Mockito.mock(ServiceState.class); - doReturn(NetworkRegistrationState.NR_STATUS_RESTRICTED).when(ss).getNrStatus(); + doReturn(NetworkRegistrationInfo.NR_STATE_RESTRICTED).when(ss).getNrState(); mPhoneStateListener.onServiceStateChanged(mServiceState); verifyDataIndicators(TelephonyIcons.ICON_LTE); diff --git a/services/core/Android.bp b/services/core/Android.bp index 48b69b029643..b028ba80ca02 100644 --- a/services/core/Android.bp +++ b/services/core/Android.bp @@ -20,6 +20,7 @@ java_library_static { ":mediaupdateservice_aidl", "java/com/android/server/EventLogTags.logtags", "java/com/android/server/am/EventLogTags.logtags", + "java/com/android/server/policy/EventLogTags.logtags", ], libs: [ diff --git a/services/core/java/com/android/server/ConnectivityService.java b/services/core/java/com/android/server/ConnectivityService.java index 4416b4d103aa..bca2df47cd22 100644 --- a/services/core/java/com/android/server/ConnectivityService.java +++ b/services/core/java/com/android/server/ConnectivityService.java @@ -988,7 +988,7 @@ public class ConnectivityService extends IConnectivityManager.Stub mUserManager = (UserManager) context.getSystemService(Context.USER_SERVICE); - mKeepaliveTracker = new KeepaliveTracker(mHandler); + mKeepaliveTracker = new KeepaliveTracker(mContext, mHandler); mNotifier = new NetworkNotificationManager(mContext, mTelephonyManager, mContext.getSystemService(NotificationManager.class)); @@ -2174,7 +2174,7 @@ public class ConnectivityService extends IConnectivityManager.Stub if (VDBG) log("identical MTU - not setting"); return; } - if (LinkProperties.isValidMtu(mtu, newLp.hasGlobalIPv6Address()) == false) { + if (!LinkProperties.isValidMtu(mtu, newLp.hasGlobalIpv6Address())) { if (mtu != 0) loge("Unexpected mtu value: " + mtu + ", " + iface); return; } @@ -2561,19 +2561,16 @@ public class ConnectivityService extends IConnectivityManager.Stub final boolean partialConnectivity = (msg.arg1 == NETWORK_TEST_RESULT_PARTIAL_CONNECTIVITY) - // If user accepts partial connectivity network, NetworkMonitor - // will skip https probing. It will make partial connectivity - // network becomes valid. But user still need to know this - // network is limited. So, it's needed to refer to - // acceptPartialConnectivity to add - // NET_CAPABILITY_PARTIAL_CONNECTIVITY into NetworkCapabilities - // of this network. So that user can see "Limited connection" - // in the settings. || (nai.networkMisc.acceptPartialConnectivity && nai.partialConnectivity); // Once a network is determined to have partial connectivity, it cannot - // go back to full connectivity without a disconnect. - final boolean partialConnectivityChange = + // go back to full connectivity without a disconnect. This is because + // NetworkMonitor can only communicate either PARTIAL_CONNECTIVITY or VALID, + // but not both. + // TODO: Provide multi-testResult to improve the communication between + // ConnectivityService and NetworkMonitor, so that ConnectivityService could + // know the real status of network. + final boolean partialConnectivityChanged = (partialConnectivity && !nai.partialConnectivity); final boolean valid = (msg.arg1 == NETWORK_TEST_RESULT_VALID); @@ -2584,17 +2581,6 @@ public class ConnectivityService extends IConnectivityManager.Stub nai.captivePortalLoginNotified = true; showNetworkNotification(nai, NotificationType.LOGGED_IN); } - // If this network has just connected and partial connectivity has just been - // detected, tell NetworkMonitor if the user accepted partial connectivity on a - // previous connect. - if ((msg.arg1 == NETWORK_TEST_RESULT_PARTIAL_CONNECTIVITY) - && nai.networkMisc.acceptPartialConnectivity) { - try { - nai.networkMonitor().notifyAcceptPartialConnectivity(); - } catch (RemoteException e) { - e.rethrowFromSystemServer(); - } - } final String redirectUrl = (msg.obj instanceof String) ? (String) msg.obj : ""; @@ -2624,7 +2610,7 @@ public class ConnectivityService extends IConnectivityManager.Stub mNotifier.clearNotification(nai.network.netId, NotificationType.LOST_INTERNET); } - } else if (partialConnectivityChange) { + } else if (partialConnectivityChanged) { nai.partialConnectivity = partialConnectivity; updateCapabilities(nai.getCurrentScore(), nai, nai.networkCapabilities); } @@ -3378,8 +3364,11 @@ public class ConnectivityService extends IConnectivityManager.Stub // Tear down the network. teardownUnneededNetwork(nai); } else { + // Inform NetworkMonitor that partial connectivity is acceptable. This will likely + // result in a partial connectivity result which will be processed by + // maybeHandleNetworkMonitorMessage. try { - nai.networkMonitor().notifyAcceptPartialConnectivity(); + nai.networkMonitor().setAcceptPartialConnectivity(); } catch (RemoteException e) { e.rethrowFromSystemServer(); } @@ -3486,8 +3475,12 @@ public class ConnectivityService extends IConnectivityManager.Stub return mMultinetworkPolicyTracker.getAvoidBadWifi(); } - @Override - public boolean getAvoidBadWifi() { + /** + * Return whether the device should maintain continuous, working connectivity by switching away + * from WiFi networks having no connectivity. + * @see MultinetworkPolicyTracker#getAvoidBadWifi() + */ + public boolean shouldAvoidBadWifi() { if (!checkNetworkStackPermission()) { throw new SecurityException("avoidBadWifi requires NETWORK_STACK permission"); } @@ -3587,6 +3580,9 @@ public class ConnectivityService extends IConnectivityManager.Stub // because we're already prompting the user to sign in. if (nai == null || nai.everValidated || nai.everCaptivePortalDetected || !nai.networkMisc.explicitlySelected || nai.networkMisc.acceptUnvalidated + // TODO: Once the value of acceptPartialConnectivity is moved to IpMemoryStore, + // we should reevaluate how to handle acceptPartialConnectivity when network just + // connected. || nai.networkMisc.acceptPartialConnectivity) { return; } @@ -3594,9 +3590,7 @@ public class ConnectivityService extends IConnectivityManager.Stub // NetworkMonitor detects the network is partial connectivity. Need to change the design to // popup the notification immediately when the network is partial connectivity. if (nai.partialConnectivity) { - // Treat PARTIAL_CONNECTIVITY as NO_INTERNET temporary until Settings has been updated. - // TODO: Need to change back to PARTIAL_CONNECTIVITY when Settings part is merged. - showNetworkNotification(nai, NotificationType.NO_INTERNET); + showNetworkNotification(nai, NotificationType.PARTIAL_CONNECTIVITY); } else { showNetworkNotification(nai, NotificationType.NO_INTERNET); } @@ -6395,6 +6389,9 @@ public class ConnectivityService extends IConnectivityManager.Stub // NetworkMonitor seeing the correct LinkProperties when starting. // TODO: pass LinkProperties to the NetworkMonitor in the notifyNetworkConnected call. try { + if (networkAgent.networkMisc.acceptPartialConnectivity) { + networkAgent.networkMonitor().setAcceptPartialConnectivity(); + } networkAgent.networkMonitor().notifyNetworkConnected(); } catch (RemoteException e) { e.rethrowFromSystemServer(); @@ -6695,7 +6692,9 @@ public class ConnectivityService extends IConnectivityManager.Stub @Override public String getCaptivePortalServerUrl() { enforceConnectivityInternalPermission(); - return NetworkMonitorUtils.getCaptivePortalServerHttpUrl(mContext); + final String defaultUrl = mContext.getResources().getString( + R.string.config_networkDefaultCaptivePortalServerUrl); + return NetworkMonitorUtils.getCaptivePortalServerHttpUrl(mContext, defaultUrl); } @Override @@ -6703,7 +6702,7 @@ public class ConnectivityService extends IConnectivityManager.Stub ISocketKeepaliveCallback cb, String srcAddr, int srcPort, String dstAddr) { enforceKeepalivePermission(); mKeepaliveTracker.startNattKeepalive( - getNetworkAgentInfoForNetwork(network), + getNetworkAgentInfoForNetwork(network), null /* fd */, intervalSeconds, cb, srcAddr, srcPort, dstAddr, NattSocketKeepalive.NATT_PORT); } @@ -6712,7 +6711,6 @@ public class ConnectivityService extends IConnectivityManager.Stub public void startNattKeepaliveWithFd(Network network, FileDescriptor fd, int resourceId, int intervalSeconds, ISocketKeepaliveCallback cb, String srcAddr, String dstAddr) { - enforceKeepalivePermission(); mKeepaliveTracker.startNattKeepalive( getNetworkAgentInfoForNetwork(network), fd, resourceId, intervalSeconds, cb, diff --git a/services/core/java/com/android/server/DynamicAndroidService.java b/services/core/java/com/android/server/DynamicAndroidService.java index 8488941587fb..b02bfb111727 100644 --- a/services/core/java/com/android/server/DynamicAndroidService.java +++ b/services/core/java/com/android/server/DynamicAndroidService.java @@ -25,6 +25,7 @@ import android.os.IBinder.DeathRecipient; import android.os.IDynamicAndroidService; import android.os.RemoteException; import android.os.ServiceManager; +import android.os.SystemProperties; import android.util.Slog; /** @@ -34,6 +35,7 @@ import android.util.Slog; public class DynamicAndroidService extends IDynamicAndroidService.Stub implements DeathRecipient { private static final String TAG = "DynamicAndroidService"; private static final String NO_SERVICE_ERROR = "no gsiservice"; + private static final int GSID_ROUGH_TIMEOUT_MS = 8192; private Context mContext; private volatile IGsiService mGsiService; @@ -66,12 +68,27 @@ public class DynamicAndroidService extends IDynamicAndroidService.Stub implement private IGsiService getGsiService() throws RemoteException { checkPermission(); - synchronized (this) { - if (mGsiService == null) { - mGsiService = connect(this); + if (!"running".equals(SystemProperties.get("init.svc.gsid"))) { + SystemProperties.set("ctl.start", "gsid"); + } + for (int sleepMs = 64; sleepMs <= (GSID_ROUGH_TIMEOUT_MS << 1); sleepMs <<= 1) { + try { + Thread.sleep(sleepMs); + } catch (InterruptedException e) { + Slog.e(TAG, "Interrupted when waiting for GSID"); + break; + } + if ("running".equals(SystemProperties.get("init.svc.gsid"))) { + synchronized (this) { + if (mGsiService == null) { + mGsiService = connect(this); + } + return mGsiService; + } } - return mGsiService; } + Slog.e(TAG, "Unable to start gsid"); + return null; } private void checkPermission() { diff --git a/services/core/java/com/android/server/NetworkManagementService.java b/services/core/java/com/android/server/NetworkManagementService.java index a9645c419108..06b85daf2023 100644 --- a/services/core/java/com/android/server/NetworkManagementService.java +++ b/services/core/java/com/android/server/NetworkManagementService.java @@ -39,7 +39,6 @@ import static android.net.NetworkStats.TAG_NONE; import static android.net.NetworkStats.UID_ALL; import static android.net.TrafficStats.UID_TETHERING; -import static com.android.server.NetworkManagementService.NetdResponseCode.TtyListResult; import static com.android.server.NetworkManagementSocketTagger.PROP_QTAGUID_ENABLED; import android.annotation.NonNull; @@ -62,6 +61,7 @@ import android.net.NetworkUtils; import android.net.RouteInfo; import android.net.TetherStatsParcel; import android.net.UidRange; +import android.net.UidRangeParcel; import android.net.util.NetdService; import android.os.BatteryStats; import android.os.Binder; @@ -69,7 +69,6 @@ import android.os.Handler; import android.os.IBinder; import android.os.INetworkActivityListener; import android.os.INetworkManagementService; -import android.os.PowerManager; import android.os.Process; import android.os.RemoteCallbackList; import android.os.RemoteException; @@ -80,6 +79,7 @@ import android.os.SystemClock; import android.os.SystemProperties; import android.os.Trace; import android.telephony.DataConnectionRealTimeInfo; +import android.text.TextUtils; import android.util.Log; import android.util.Slog; import android.util.SparseBooleanArray; @@ -109,13 +109,11 @@ import java.util.Arrays; import java.util.HashMap; import java.util.List; import java.util.Map; -import java.util.concurrent.CountDownLatch; /** * @hide */ -public class NetworkManagementService extends INetworkManagementService.Stub - implements Watchdog.Monitor { +public class NetworkManagementService extends INetworkManagementService.Stub { /** * Helper class that encapsulates NetworkManagementService dependencies and makes them @@ -135,8 +133,6 @@ public class NetworkManagementService extends INetworkManagementService.Stub private static final String TAG = "NetworkManagement"; private static final boolean DBG = Log.isLoggable(TAG, Log.DEBUG); - private static final String NETD_TAG = "NetdConnector"; - static final String NETD_SERVICE_NAME = "netd"; private static final int MAX_UID_RANGES_PER_COMMAND = 10; @@ -146,44 +142,6 @@ public class NetworkManagementService extends INetworkManagementService.Stub */ public static final String LIMIT_GLOBAL_ALERT = "globalAlert"; - static class NetdResponseCode { - /* Keep in sync with system/netd/server/ResponseCode.h */ - public static final int InterfaceListResult = 110; - public static final int TetherInterfaceListResult = 111; - public static final int TetherDnsFwdTgtListResult = 112; - public static final int TtyListResult = 113; - public static final int TetheringStatsListResult = 114; - - public static final int TetherStatusResult = 210; - public static final int IpFwdStatusResult = 211; - public static final int InterfaceGetCfgResult = 213; - public static final int SoftapStatusResult = 214; - public static final int InterfaceRxCounterResult = 216; - public static final int InterfaceTxCounterResult = 217; - public static final int QuotaCounterResult = 220; - public static final int TetheringStatsResult = 221; - public static final int DnsProxyQueryResult = 222; - public static final int ClatdStatusResult = 223; - - public static final int InterfaceChange = 600; - public static final int BandwidthControl = 601; - public static final int InterfaceClassActivity = 613; - public static final int InterfaceAddressChange = 614; - public static final int InterfaceDnsServerInfo = 615; - public static final int RouteChange = 616; - public static final int StrictCleartext = 617; - } - - /** - * String indicating a softap command. - */ - static final String SOFT_AP_COMMAND = "softap"; - - /** - * String passed back to netd connector indicating softap command success. - */ - static final String SOFT_AP_COMMAND_SUCCESS = "Ok"; - static final int DAEMON_MSG_MOBILE_CONN_REAL_TIME_INFO = 1; static final boolean MODIFY_OPERATION_ADD = true; @@ -194,12 +152,6 @@ public class NetworkManagementService extends INetworkManagementService.Stub */ private final Context mContext; - /** - * connector object for communicating with netd - */ - private final NativeDaemonConnector mConnector; - - private final Handler mFgHandler; private final Handler mDaemonHandler; private final SystemServices mServices; @@ -210,9 +162,6 @@ public class NetworkManagementService extends INetworkManagementService.Stub private IBatteryStats mBatteryStats; - private final Thread mThread; - private CountDownLatch mConnectedSignal = new CountDownLatch(1); - private final RemoteCallbackList<INetworkManagementEventObserver> mObservers = new RemoteCallbackList<>(); @@ -304,32 +253,14 @@ public class NetworkManagementService extends INetworkManagementService.Stub * @param context Binder context for this service */ private NetworkManagementService( - Context context, String socket, SystemServices services) { + Context context, SystemServices services) { mContext = context; mServices = services; - // make sure this is on the same looper as our NativeDaemonConnector for sync purposes - mFgHandler = new Handler(FgThread.get().getLooper()); - - // Don't need this wake lock, since we now have a time stamp for when - // the network actually went inactive. (It might be nice to still do this, - // but I don't want to do it through the power manager because that pollutes the - // battery stats history with pointless noise.) - //PowerManager pm = (PowerManager)context.getSystemService(Context.POWER_SERVICE); - PowerManager.WakeLock wl = null; //pm.newWakeLock(PowerManager.PARTIAL_WAKE_LOCK, NETD_TAG); - - mConnector = new NativeDaemonConnector( - new NetdCallbackReceiver(), socket, 10, NETD_TAG, 160, wl, - FgThread.get().getLooper()); - mThread = new Thread(mConnector, NETD_TAG); - mDaemonHandler = new Handler(FgThread.get().getLooper()); mNetdUnsolicitedEventListener = new NetdUnsolicitedEventListener(); - // Add ourself to the Watchdog monitors. - Watchdog.getInstance().addMonitor(this); - mServices.registerLocalService(new LocalService()); synchronized (mTetheringStatsProviders) { @@ -339,25 +270,17 @@ public class NetworkManagementService extends INetworkManagementService.Stub @VisibleForTesting NetworkManagementService() { - mConnector = null; mContext = null; mDaemonHandler = null; - mFgHandler = null; - mThread = null; mServices = null; mNetdUnsolicitedEventListener = null; } - static NetworkManagementService create(Context context, String socket, SystemServices services) + static NetworkManagementService create(Context context, SystemServices services) throws InterruptedException { final NetworkManagementService service = - new NetworkManagementService(context, socket, services); - final CountDownLatch connectedSignal = service.mConnectedSignal; + new NetworkManagementService(context, services); if (DBG) Slog.d(TAG, "Creating NetworkManagementService"); - service.mThread.start(); - if (DBG) Slog.d(TAG, "Awaiting socket connection"); - connectedSignal.await(); - if (DBG) Slog.d(TAG, "Connected"); if (DBG) Slog.d(TAG, "Connecting native netd service"); service.connectNativeNetdService(); if (DBG) Slog.d(TAG, "Connected"); @@ -365,7 +288,7 @@ public class NetworkManagementService extends INetworkManagementService.Stub } public static NetworkManagementService create(Context context) throws InterruptedException { - return create(context, NETD_SERVICE_NAME, new SystemServices()); + return create(context, new SystemServices()); } public void systemReady() { @@ -805,212 +728,6 @@ public class NetworkManagementService extends INetworkManagementService.Stub } // - // Netd Callback handling - // - - private class NetdCallbackReceiver implements INativeDaemonConnectorCallbacks { - @Override - public void onDaemonConnected() { - Slog.i(TAG, "onDaemonConnected()"); - // event is dispatched from internal NDC thread, so we prepare the - // daemon back on main thread. - if (mConnectedSignal != null) { - // The system is booting and we're connecting to netd for the first time. - mConnectedSignal.countDown(); - mConnectedSignal = null; - } else { - // We're reconnecting to netd after the socket connection - // was interrupted (e.g., if it crashed). - mFgHandler.post(new Runnable() { - @Override - public void run() { - connectNativeNetdService(); - prepareNativeDaemon(); - } - }); - } - } - - @Override - public boolean onCheckHoldWakeLock(int code) { - return code == NetdResponseCode.InterfaceClassActivity; - } - - @Override - public boolean onEvent(int code, String raw, String[] cooked) { - String errorMessage = String.format("Invalid event from daemon (%s)", raw); - switch (code) { - case NetdResponseCode.InterfaceChange: - /* - * a network interface change occured - * Format: "NNN Iface added <name>" - * "NNN Iface removed <name>" - * "NNN Iface changed <name> <up/down>" - * "NNN Iface linkstatus <name> <up/down>" - */ - if (cooked.length < 4 || !cooked[1].equals("Iface")) { - throw new IllegalStateException(errorMessage); - } - if (cooked[2].equals("added")) { - notifyInterfaceAdded(cooked[3]); - return true; - } else if (cooked[2].equals("removed")) { - notifyInterfaceRemoved(cooked[3]); - return true; - } else if (cooked[2].equals("changed") && cooked.length == 5) { - notifyInterfaceStatusChanged(cooked[3], cooked[4].equals("up")); - return true; - } else if (cooked[2].equals("linkstate") && cooked.length == 5) { - notifyInterfaceLinkStateChanged(cooked[3], cooked[4].equals("up")); - return true; - } - throw new IllegalStateException(errorMessage); - // break; - case NetdResponseCode.BandwidthControl: - /* - * Bandwidth control needs some attention - * Format: "NNN limit alert <alertName> <ifaceName>" - */ - if (cooked.length < 5 || !cooked[1].equals("limit")) { - throw new IllegalStateException(errorMessage); - } - if (cooked[2].equals("alert")) { - notifyLimitReached(cooked[3], cooked[4]); - return true; - } - throw new IllegalStateException(errorMessage); - // break; - case NetdResponseCode.InterfaceClassActivity: - /* - * An network interface class state changed (active/idle) - * Format: "NNN IfaceClass <active/idle> <label>" - */ - if (cooked.length < 4 || !cooked[1].equals("IfaceClass")) { - throw new IllegalStateException(errorMessage); - } - long timestampNanos = 0; - int processUid = -1; - if (cooked.length >= 5) { - try { - timestampNanos = Long.parseLong(cooked[4]); - if (cooked.length == 6) { - processUid = Integer.parseInt(cooked[5]); - } - } catch(NumberFormatException ne) {} - } else { - timestampNanos = SystemClock.elapsedRealtimeNanos(); - } - boolean isActive = cooked[2].equals("active"); - notifyInterfaceClassActivity(Integer.parseInt(cooked[3]), - isActive, timestampNanos, processUid, false); - return true; - // break; - case NetdResponseCode.InterfaceAddressChange: - /* - * A network address change occurred - * Format: "NNN Address updated <addr> <iface> <flags> <scope>" - * "NNN Address removed <addr> <iface> <flags> <scope>" - */ - if (cooked.length < 7 || !cooked[1].equals("Address")) { - throw new IllegalStateException(errorMessage); - } - - String iface = cooked[4]; - LinkAddress address; - try { - int flags = Integer.parseInt(cooked[5]); - int scope = Integer.parseInt(cooked[6]); - address = new LinkAddress(cooked[3], flags, scope); - } catch(NumberFormatException e) { // Non-numeric lifetime or scope. - throw new IllegalStateException(errorMessage, e); - } catch(IllegalArgumentException e) { // Malformed/invalid IP address. - throw new IllegalStateException(errorMessage, e); - } - - if (cooked[2].equals("updated")) { - notifyAddressUpdated(iface, address); - } else { - notifyAddressRemoved(iface, address); - } - return true; - // break; - case NetdResponseCode.InterfaceDnsServerInfo: - /* - * Information about available DNS servers has been received. - * Format: "NNN DnsInfo servers <interface> <lifetime> <servers>" - */ - long lifetime; // Actually a 32-bit unsigned integer. - - if (cooked.length == 6 && - cooked[1].equals("DnsInfo") && - cooked[2].equals("servers")) { - try { - lifetime = Long.parseLong(cooked[4]); - } catch (NumberFormatException e) { - throw new IllegalStateException(errorMessage); - } - String[] servers = cooked[5].split(","); - notifyInterfaceDnsServerInfo(cooked[3], lifetime, servers); - } - return true; - // break; - case NetdResponseCode.RouteChange: - /* - * A route has been updated or removed. - * Format: "NNN Route <updated|removed> <dst> [via <gateway] [dev <iface>]" - */ - if (!cooked[1].equals("Route") || cooked.length < 6) { - throw new IllegalStateException(errorMessage); - } - - String via = null; - String dev = null; - boolean valid = true; - for (int i = 4; (i + 1) < cooked.length && valid; i += 2) { - if (cooked[i].equals("dev")) { - if (dev == null) { - dev = cooked[i+1]; - } else { - valid = false; // Duplicate interface. - } - } else if (cooked[i].equals("via")) { - if (via == null) { - via = cooked[i+1]; - } else { - valid = false; // Duplicate gateway. - } - } else { - valid = false; // Unknown syntax. - } - } - if (valid) { - try { - // InetAddress.parseNumericAddress(null) inexplicably returns ::1. - InetAddress gateway = null; - if (via != null) gateway = InetAddress.parseNumericAddress(via); - RouteInfo route = new RouteInfo(new IpPrefix(cooked[3]), gateway, dev); - notifyRouteChange(cooked[2].equals("updated"), route); - return true; - } catch (IllegalArgumentException e) {} - } - throw new IllegalStateException(errorMessage); - // break; - case NetdResponseCode.StrictCleartext: - final int uid = Integer.parseInt(cooked[1]); - final byte[] firstPacket = HexDump.hexStringToByteArray(cooked[2]); - try { - ActivityManager.getService().notifyCleartextNetwork(uid, firstPacket); - } catch (RemoteException ignored) { - } - break; - default: break; - } - return false; - } - } - - - // // INetworkManagementService members // @Override @@ -1023,6 +740,46 @@ public class NetworkManagementService extends INetworkManagementService.Stub } } + /** + * Convert InterfaceConfiguration to InterfaceConfigurationParcel with given ifname. + */ + private static InterfaceConfigurationParcel toStableParcel(InterfaceConfiguration cfg, + String iface) { + InterfaceConfigurationParcel cfgParcel = new InterfaceConfigurationParcel(); + cfgParcel.ifName = iface; + String hwAddr = cfg.getHardwareAddress(); + if (!TextUtils.isEmpty(hwAddr)) { + cfgParcel.hwAddr = hwAddr; + } else { + cfgParcel.hwAddr = ""; + } + cfgParcel.ipv4Addr = cfg.getLinkAddress().getAddress().getHostAddress(); + cfgParcel.prefixLength = cfg.getLinkAddress().getPrefixLength(); + ArrayList<String> flags = new ArrayList<>(); + for (String flag : cfg.getFlags()) { + flags.add(flag); + } + cfgParcel.flags = flags.toArray(new String[0]); + + return cfgParcel; + } + + /** + * Construct InterfaceConfiguration from InterfaceConfigurationParcel. + */ + public static InterfaceConfiguration fromStableParcel(InterfaceConfigurationParcel p) { + InterfaceConfiguration cfg = new InterfaceConfiguration(); + cfg.setHardwareAddress(p.hwAddr); + + final InetAddress addr = NetworkUtils.numericToInetAddress(p.ipv4Addr); + cfg.setLinkAddress(new LinkAddress(addr, p.prefixLength)); + for (String flag : p.flags) { + cfg.setFlag(flag); + } + + return cfg; + } + @Override public InterfaceConfiguration getInterfaceConfig(String iface) { mContext.enforceCallingOrSelfPermission(CONNECTIVITY_INTERNAL, TAG); @@ -1034,7 +791,7 @@ public class NetworkManagementService extends INetworkManagementService.Stub } try { - final InterfaceConfiguration cfg = InterfaceConfiguration.fromParcel(result); + final InterfaceConfiguration cfg = fromStableParcel(result); return cfg; } catch (IllegalArgumentException iae) { throw new IllegalStateException("Invalid InterfaceConfigurationParcel", iae); @@ -1049,7 +806,7 @@ public class NetworkManagementService extends INetworkManagementService.Stub throw new IllegalStateException("Null LinkAddress given"); } - final InterfaceConfigurationParcel cfgParcel = cfg.toParcel(iface); + final InterfaceConfigurationParcel cfgParcel = toStableParcel(cfg, iface); try { mNetdService.interfaceSetCfg(cfgParcel); @@ -1392,42 +1149,6 @@ public class NetworkManagementService extends INetworkManagementService.Stub } @Override - public String[] listTtys() { - mContext.enforceCallingOrSelfPermission(CONNECTIVITY_INTERNAL, TAG); - try { - return NativeDaemonEvent.filterMessageList( - mConnector.executeForList("list_ttys"), TtyListResult); - } catch (NativeDaemonConnectorException e) { - throw e.rethrowAsParcelableException(); - } - } - - @Override - public void attachPppd( - String tty, String localAddr, String remoteAddr, String dns1Addr, String dns2Addr) { - mContext.enforceCallingOrSelfPermission(CONNECTIVITY_INTERNAL, TAG); - try { - mConnector.execute("pppd", "attach", tty, - NetworkUtils.numericToInetAddress(localAddr).getHostAddress(), - NetworkUtils.numericToInetAddress(remoteAddr).getHostAddress(), - NetworkUtils.numericToInetAddress(dns1Addr).getHostAddress(), - NetworkUtils.numericToInetAddress(dns2Addr).getHostAddress()); - } catch (NativeDaemonConnectorException e) { - throw e.rethrowAsParcelableException(); - } - } - - @Override - public void detachPppd(String tty) { - mContext.enforceCallingOrSelfPermission(CONNECTIVITY_INTERNAL, TAG); - try { - mConnector.execute("pppd", "detach", tty); - } catch (NativeDaemonConnectorException e) { - throw e.rethrowAsParcelableException(); - } - } - - @Override public void addIdleTimer(String iface, int timeout, final int type) { mContext.enforceCallingOrSelfPermission(CONNECTIVITY_INTERNAL, TAG); @@ -1713,12 +1434,27 @@ public class NetworkManagementService extends INetworkManagementService.Stub } } + private static UidRangeParcel makeUidRangeParcel(int start, int stop) { + UidRangeParcel range = new UidRangeParcel(); + range.start = start; + range.stop = stop; + return range; + } + + private static UidRangeParcel[] toStableParcels(UidRange[] ranges) { + UidRangeParcel[] stableRanges = new UidRangeParcel[ranges.length]; + for (int i = 0; i < ranges.length; i++) { + stableRanges[i] = makeUidRangeParcel(ranges[i].start, ranges[i].stop); + } + return stableRanges; + } + @Override public void setAllowOnlyVpnForUids(boolean add, UidRange[] uidRanges) throws ServiceSpecificException { mContext.enforceCallingOrSelfPermission(NETWORK_STACK, TAG); try { - mNetdService.networkRejectNonSecureVpn(add, uidRanges); + mNetdService.networkRejectNonSecureVpn(add, toStableParcels(uidRanges)); } catch (ServiceSpecificException e) { Log.w(TAG, "setAllowOnlyVpnForUids(" + add + ", " + Arrays.toString(uidRanges) + ")" + ": netd command failed", e); @@ -1887,7 +1623,7 @@ public class NetworkManagementService extends INetworkManagementService.Stub mContext.enforceCallingOrSelfPermission(CONNECTIVITY_INTERNAL, TAG); try { - mNetdService.networkAddUidRanges(netId, ranges); + mNetdService.networkAddUidRanges(netId, toStableParcels(ranges)); } catch (RemoteException | ServiceSpecificException e) { throw new IllegalStateException(e); } @@ -1897,7 +1633,7 @@ public class NetworkManagementService extends INetworkManagementService.Stub public void removeVpnUidRanges(int netId, UidRange[] ranges) { mContext.enforceCallingOrSelfPermission(CONNECTIVITY_INTERNAL, TAG); try { - mNetdService.networkRemoveUidRanges(netId, ranges); + mNetdService.networkRemoveUidRanges(netId, toStableParcels(ranges)); } catch (RemoteException | ServiceSpecificException e) { throw new IllegalStateException(e); } @@ -1935,7 +1671,7 @@ public class NetworkManagementService extends INetworkManagementService.Stub private void closeSocketsForFirewallChainLocked(int chain, String chainName) { // UID ranges to close sockets on. - UidRange[] ranges; + UidRangeParcel[] ranges; // UID ranges whose sockets we won't touch. int[] exemptUids; @@ -1943,10 +1679,10 @@ public class NetworkManagementService extends INetworkManagementService.Stub if (DBG) Slog.d(TAG, "Closing sockets after enabling chain " + chainName); if (getFirewallType(chain) == FIREWALL_WHITELIST) { // Close all sockets on all non-system UIDs... - ranges = new UidRange[] { + ranges = new UidRangeParcel[] { // TODO: is there a better way of finding all existing users? If so, we could // specify their ranges here. - new UidRange(Process.FIRST_APPLICATION_UID, Integer.MAX_VALUE), + makeUidRangeParcel(Process.FIRST_APPLICATION_UID, Integer.MAX_VALUE), }; // ... except for the UIDs that have allow rules. synchronized (mRulesLock) { @@ -1973,11 +1709,11 @@ public class NetworkManagementService extends INetworkManagementService.Stub // Close sockets for every UID that has a deny rule... synchronized (mRulesLock) { final SparseIntArray rules = getUidFirewallRulesLR(chain); - ranges = new UidRange[rules.size()]; + ranges = new UidRangeParcel[rules.size()]; for (int i = 0; i < ranges.length; i++) { if (rules.valueAt(i) == FIREWALL_RULE_DENY) { int uid = rules.keyAt(i); - ranges[numUids] = new UidRange(uid, uid); + ranges[numUids] = makeUidRangeParcel(uid, uid); numUids++; } } @@ -2232,22 +1968,10 @@ public class NetworkManagementService extends INetworkManagementService.Stub } } - /** {@inheritDoc} */ - @Override - public void monitor() { - if (mConnector != null) { - mConnector.monitor(); - } - } - @Override protected void dump(FileDescriptor fd, PrintWriter pw, String[] args) { if (!DumpUtils.checkDumpPermission(mContext, TAG, pw)) return; - pw.println("NetworkManagementService NativeDaemonConnector Log:"); - mConnector.dump(fd, pw, args); - pw.println(); - pw.print("mMobileActivityFromRadio="); pw.print(mMobileActivityFromRadio); pw.print(" mLastPowerStateFromRadio="); pw.println(mLastPowerStateFromRadio); pw.print("mNetworkActive="); pw.println(mNetworkActive); diff --git a/services/core/java/com/android/server/TelephonyRegistry.java b/services/core/java/com/android/server/TelephonyRegistry.java index d2a0d7bc23fa..4a4b6254ffa7 100644 --- a/services/core/java/com/android/server/TelephonyRegistry.java +++ b/services/core/java/com/android/server/TelephonyRegistry.java @@ -627,6 +627,11 @@ public class TelephonyRegistry extends ITelephonyRegistry.Stub { r.callingPackage = callingPackage; r.callerUid = Binder.getCallingUid(); r.callerPid = Binder.getCallingPid(); + if (r.subId != SubscriptionManager.INVALID_SUBSCRIPTION_ID && r.subId != subId) { + throw new IllegalArgumentException( + "PhoneStateListener cannot concurrently listen on multiple " + + "subscriptions. Previously registered on subId: " + r.subId); + } // Legacy applications pass SubscriptionManager.DEFAULT_SUB_ID, // force all illegal subId to SubscriptionManager.DEFAULT_SUB_ID if (!SubscriptionManager.isValidSubscriptionId(subId)) { @@ -1883,7 +1888,7 @@ public class TelephonyRegistry extends ITelephonyRegistry.Stub { pw.println("mDataConnectionState=" + mDataConnectionState[i]); pw.println("mCellLocation=" + mCellLocation[i]); pw.println("mCellInfo=" + mCellInfo.get(i)); - pw.println("mImsCallDisconnectCause=" + mImsReasonInfo.get(i).toString()); + pw.println("mImsCallDisconnectCause=" + mImsReasonInfo.get(i)); pw.decreaseIndent(); } pw.println("mCallNetworkType=" + mCallNetworkType); diff --git a/services/core/java/com/android/server/connectivity/DefaultNetworkMetrics.java b/services/core/java/com/android/server/connectivity/DefaultNetworkMetrics.java index e43d1526f760..96a202fa2b10 100644 --- a/services/core/java/com/android/server/connectivity/DefaultNetworkMetrics.java +++ b/services/core/java/com/android/server/connectivity/DefaultNetworkMetrics.java @@ -163,8 +163,8 @@ public class DefaultNetworkMetrics { LinkProperties lp = nai.linkProperties; ev.netId = nai.network().netId; ev.transports |= BitUtils.packBits(nai.networkCapabilities.getTransportTypes()); - ev.ipv4 |= lp.hasIPv4Address() && lp.hasIPv4DefaultRoute(); - ev.ipv6 |= lp.hasGlobalIPv6Address() && lp.hasIPv6DefaultRoute(); + ev.ipv4 |= lp.hasIpv4Address() && lp.hasIpv4DefaultRoute(); + ev.ipv6 |= lp.hasGlobalIpv6Address() && lp.hasIpv6DefaultRoute(); } private static void printEvent(long localTimeMs, PrintWriter pw, DefaultNetworkEvent ev) { diff --git a/services/core/java/com/android/server/connectivity/KeepaliveTracker.java b/services/core/java/com/android/server/connectivity/KeepaliveTracker.java index 35d6860080d1..ce887eb4f0fe 100644 --- a/services/core/java/com/android/server/connectivity/KeepaliveTracker.java +++ b/services/core/java/com/android/server/connectivity/KeepaliveTracker.java @@ -16,6 +16,7 @@ package com.android.server.connectivity; +import static android.content.pm.PackageManager.PERMISSION_GRANTED; import static android.net.NattSocketKeepalive.NATT_PORT; import static android.net.NetworkAgent.CMD_ADD_KEEPALIVE_PACKET_FILTER; import static android.net.NetworkAgent.CMD_REMOVE_KEEPALIVE_PACKET_FILTER; @@ -23,6 +24,7 @@ import static android.net.NetworkAgent.CMD_START_SOCKET_KEEPALIVE; import static android.net.NetworkAgent.CMD_STOP_SOCKET_KEEPALIVE; import static android.net.SocketKeepalive.BINDER_DIED; import static android.net.SocketKeepalive.DATA_RECEIVED; +import static android.net.SocketKeepalive.ERROR_INSUFFICIENT_RESOURCES; import static android.net.SocketKeepalive.ERROR_INVALID_INTERVAL; import static android.net.SocketKeepalive.ERROR_INVALID_IP_ADDRESS; import static android.net.SocketKeepalive.ERROR_INVALID_NETWORK; @@ -34,6 +36,7 @@ import static android.net.SocketKeepalive.SUCCESS; import android.annotation.NonNull; import android.annotation.Nullable; +import android.content.Context; import android.net.ISocketKeepaliveCallback; import android.net.KeepalivePacketData; import android.net.NattKeepalivePacketData; @@ -42,7 +45,6 @@ import android.net.NetworkUtils; import android.net.SocketKeepalive.InvalidPacketException; import android.net.SocketKeepalive.InvalidSocketException; import android.net.TcpKeepalivePacketData; -import android.net.TcpKeepalivePacketData.TcpSocketInfo; import android.net.util.IpUtils; import android.os.Binder; import android.os.Handler; @@ -85,10 +87,13 @@ public class KeepaliveTracker { private final Handler mConnectivityServiceHandler; @NonNull private final TcpKeepaliveController mTcpController; + @NonNull + private final Context mContext; - public KeepaliveTracker(Handler handler) { + public KeepaliveTracker(Context context, Handler handler) { mConnectivityServiceHandler = handler; mTcpController = new TcpKeepaliveController(handler); + mContext = context; } /** @@ -102,6 +107,7 @@ public class KeepaliveTracker { private final ISocketKeepaliveCallback mCallback; private final int mUid; private final int mPid; + private final boolean mPrivileged; private final NetworkAgentInfo mNai; private final int mType; private final FileDescriptor mFd; @@ -109,6 +115,11 @@ public class KeepaliveTracker { public static final int TYPE_NATT = 1; public static final int TYPE_TCP = 2; + // Max allowed unprivileged keepalive slots per network. Caller's permission will be + // enforced if number of existing keepalives reach this limit. + // TODO: consider making this limit configurable via resources. + private static final int MAX_UNPRIVILEGED_SLOTS = 3; + // Keepalive slot. A small integer that identifies this keepalive among the ones handled // by this network. private int mSlot = NO_KEEPALIVE; @@ -128,16 +139,33 @@ public class KeepaliveTracker { @NonNull KeepalivePacketData packet, int interval, int type, - @NonNull FileDescriptor fd) { + @Nullable FileDescriptor fd) throws InvalidSocketException { mCallback = callback; mPid = Binder.getCallingPid(); mUid = Binder.getCallingUid(); + mPrivileged = (PERMISSION_GRANTED == mContext.checkPermission(PERMISSION, mPid, mUid)); mNai = nai; mPacket = packet; mInterval = interval; mType = type; - mFd = fd; + + // For SocketKeepalive, a dup of fd is kept in mFd so the source port from which the + // keepalives are sent cannot be reused by another app even if the fd gets closed by + // the user. A null is acceptable here for backward compatibility of PacketKeepalive + // API. + // TODO: don't accept null fd after legacy packetKeepalive API is removed. + try { + if (fd != null) { + mFd = Os.dup(fd); + } else { + Log.d(TAG, "uid/pid " + mUid + "/" + mPid + " calls with null fd"); + mFd = null; + } + } catch (ErrnoException e) { + Log.e(TAG, "Cannot dup fd: ", e); + throw new InvalidSocketException(ERROR_INVALID_SOCKET, e); + } try { mCallback.asBinder().linkToDeath(this, 0); @@ -168,7 +196,7 @@ public class KeepaliveTracker { + "->" + IpUtils.addressAndPortToString(mPacket.dstAddress, mPacket.dstPort) + " interval=" + mInterval - + " uid=" + mUid + " pid=" + mPid + + " uid=" + mUid + " pid=" + mPid + " privileged=" + mPrivileged + " packetData=" + HexDump.toHexString(mPacket.getPacket()) + " ]"; } @@ -208,9 +236,27 @@ public class KeepaliveTracker { return SUCCESS; } + private int checkPermission() { + final HashMap<Integer, KeepaliveInfo> networkKeepalives = mKeepalives.get(mNai); + int unprivilegedCount = 0; + if (networkKeepalives == null) { + return ERROR_INVALID_NETWORK; + } + for (KeepaliveInfo ki : networkKeepalives.values()) { + if (!ki.mPrivileged) { + unprivilegedCount++; + } + if (unprivilegedCount >= MAX_UNPRIVILEGED_SLOTS) { + return mPrivileged ? SUCCESS : ERROR_INSUFFICIENT_RESOURCES; + } + } + return SUCCESS; + } + private int isValid() { synchronized (mNai) { int error = checkInterval(); + if (error == SUCCESS) error = checkPermission(); if (error == SUCCESS) error = checkNetworkConnected(); if (error == SUCCESS) error = checkSourceAddress(); return error; @@ -273,6 +319,18 @@ public class KeepaliveTracker { } } + // Close the duplicated fd that maintains the lifecycle of socket whenever + // keepalive is running. + if (mFd != null) { + try { + Os.close(mFd); + } catch (ErrnoException e) { + // This should not happen since system server controls the lifecycle of fd when + // keepalive offload is running. + Log.wtf(TAG, "Error closing fd for keepalive " + mSlot + ": " + e); + } + } + if (reason == SUCCESS) { try { mCallback.onStopped(); @@ -356,8 +414,9 @@ public class KeepaliveTracker { return; } ki.stop(reason); - Log.d(TAG, "Stopped keepalive " + slot + " on " + networkName); networkKeepalives.remove(slot); + Log.d(TAG, "Stopped keepalive " + slot + " on " + networkName + ", " + + networkKeepalives.size() + " remains."); if (networkKeepalives.isEmpty()) { mKeepalives.remove(nai); } @@ -390,7 +449,8 @@ public class KeepaliveTracker { ki = mKeepalives.get(nai).get(slot); } catch(NullPointerException e) {} if (ki == null) { - Log.e(TAG, "Event for unknown keepalive " + slot + " on " + nai.name()); + Log.e(TAG, "Event " + message.what + " for unknown keepalive " + slot + " on " + + nai.name()); return; } @@ -438,6 +498,7 @@ public class KeepaliveTracker { * {@link android.net.SocketKeepalive}. **/ public void startNattKeepalive(@Nullable NetworkAgentInfo nai, + @Nullable FileDescriptor fd, int intervalSeconds, @NonNull ISocketKeepaliveCallback cb, @NonNull String srcAddrString, @@ -466,8 +527,14 @@ public class KeepaliveTracker { notifyErrorCallback(cb, e.error); return; } - KeepaliveInfo ki = new KeepaliveInfo(cb, nai, packet, intervalSeconds, - KeepaliveInfo.TYPE_NATT, null); + KeepaliveInfo ki = null; + try { + ki = new KeepaliveInfo(cb, nai, packet, intervalSeconds, + KeepaliveInfo.TYPE_NATT, fd); + } catch (InvalidSocketException e) { + notifyErrorCallback(cb, ERROR_INVALID_SOCKET); + return; + } Log.d(TAG, "Created keepalive: " + ki.toString()); mConnectivityServiceHandler.obtainMessage( NetworkAgent.CMD_START_SOCKET_KEEPALIVE, ki).sendToTarget(); @@ -492,21 +559,21 @@ public class KeepaliveTracker { return; } - TcpKeepalivePacketData packet = null; + final TcpKeepalivePacketData packet; try { - TcpSocketInfo tsi = TcpKeepaliveController.switchToRepairMode(fd); - packet = TcpKeepalivePacketData.tcpKeepalivePacket(tsi); + packet = TcpKeepaliveController.getTcpKeepalivePacket(fd); } catch (InvalidPacketException | InvalidSocketException e) { - try { - TcpKeepaliveController.switchOutOfRepairMode(fd); - } catch (ErrnoException e1) { - Log.e(TAG, "Couldn't move fd out of repair mode after failure to start keepalive"); - } notifyErrorCallback(cb, e.error); return; } - KeepaliveInfo ki = new KeepaliveInfo(cb, nai, packet, intervalSeconds, - KeepaliveInfo.TYPE_TCP, fd); + KeepaliveInfo ki = null; + try { + ki = new KeepaliveInfo(cb, nai, packet, intervalSeconds, + KeepaliveInfo.TYPE_TCP, fd); + } catch (InvalidSocketException e) { + notifyErrorCallback(cb, ERROR_INVALID_SOCKET); + return; + } Log.d(TAG, "Created keepalive: " + ki.toString()); mConnectivityServiceHandler.obtainMessage(CMD_START_SOCKET_KEEPALIVE, ki).sendToTarget(); } @@ -541,7 +608,7 @@ public class KeepaliveTracker { } // Forward request to old API. - startNattKeepalive(nai, intervalSeconds, cb, srcAddrString, srcPort, + startNattKeepalive(nai, fd, intervalSeconds, cb, srcAddrString, srcPort, dstAddrString, dstPort); } diff --git a/services/core/java/com/android/server/connectivity/Nat464Xlat.java b/services/core/java/com/android/server/connectivity/Nat464Xlat.java index 2646d7669d79..262ba7a475bb 100644 --- a/services/core/java/com/android/server/connectivity/Nat464Xlat.java +++ b/services/core/java/com/android/server/connectivity/Nat464Xlat.java @@ -107,8 +107,8 @@ public class Nat464Xlat extends BaseNetworkObserver { // Only run clat on networks that have a global IPv6 address and don't have a native IPv4 // address. LinkProperties lp = nai.linkProperties; - final boolean isIpv6OnlyNetwork = (lp != null) && lp.hasGlobalIPv6Address() - && !lp.hasIPv4Address(); + final boolean isIpv6OnlyNetwork = (lp != null) && lp.hasGlobalIpv6Address() + && !lp.hasIpv4Address(); // If the network tells us it doesn't use clat, respect that. final boolean skip464xlat = (nai.netMisc() != null) && nai.netMisc().skip464xlat; diff --git a/services/core/java/com/android/server/connectivity/NetworkDiagnostics.java b/services/core/java/com/android/server/connectivity/NetworkDiagnostics.java index c471f0caa3cc..948c690956d3 100644 --- a/services/core/java/com/android/server/connectivity/NetworkDiagnostics.java +++ b/services/core/java/com/android/server/connectivity/NetworkDiagnostics.java @@ -34,10 +34,12 @@ import android.util.Pair; import com.android.internal.util.IndentingPrintWriter; +import libcore.io.IoUtils; + import java.io.Closeable; import java.io.FileDescriptor; -import java.io.InterruptedIOException; import java.io.IOException; +import java.io.InterruptedIOException; import java.net.Inet4Address; import java.net.Inet6Address; import java.net.InetAddress; @@ -48,17 +50,13 @@ import java.net.SocketException; import java.net.UnknownHostException; import java.nio.ByteBuffer; import java.nio.charset.StandardCharsets; -import java.util.concurrent.CountDownLatch; -import java.util.concurrent.TimeUnit; -import java.util.Arrays; import java.util.ArrayList; import java.util.HashMap; import java.util.List; import java.util.Map; import java.util.Random; - -import libcore.io.IoUtils; - +import java.util.concurrent.CountDownLatch; +import java.util.concurrent.TimeUnit; /** * NetworkDiagnostics @@ -186,7 +184,7 @@ public class NetworkDiagnostics { // TODO: we could use mLinkProperties.isReachable(TEST_DNS6) here, because we won't set any // DNS servers for which isReachable() is false, but since this is diagnostic code, be extra // careful. - if (mLinkProperties.hasGlobalIPv6Address() || mLinkProperties.hasIPv6DefaultRoute()) { + if (mLinkProperties.hasGlobalIpv6Address() || mLinkProperties.hasIpv6DefaultRoute()) { mLinkProperties.addDnsServer(TEST_DNS6); } diff --git a/services/core/java/com/android/server/connectivity/PermissionMonitor.java b/services/core/java/com/android/server/connectivity/PermissionMonitor.java index 123564eb4fdb..0c559346bc42 100644 --- a/services/core/java/com/android/server/connectivity/PermissionMonitor.java +++ b/services/core/java/com/android/server/connectivity/PermissionMonitor.java @@ -22,6 +22,7 @@ import static android.Manifest.permission.CONNECTIVITY_USE_RESTRICTED_NETWORKS; import static android.Manifest.permission.INTERNET; import static android.Manifest.permission.NETWORK_STACK; import static android.Manifest.permission.UPDATE_DEVICE_STATS; +import static android.content.pm.PackageInfo.REQUESTED_PERMISSION_GRANTED; import static android.content.pm.PackageManager.GET_PERMISSIONS; import static android.content.pm.PackageManager.MATCH_ANY_USER; import static android.os.Process.INVALID_UID; @@ -42,13 +43,15 @@ import android.os.INetworkManagementService; import android.os.RemoteException; import android.os.UserHandle; import android.os.UserManager; +import android.util.ArraySet; import android.util.Log; -import android.util.Slog; +import android.util.SparseArray; import android.util.SparseIntArray; import com.android.internal.annotations.VisibleForTesting; import com.android.internal.util.ArrayUtils; import com.android.server.LocalServices; +import com.android.server.SystemConfig; import java.util.ArrayList; import java.util.HashMap; @@ -83,41 +86,32 @@ public class PermissionMonitor { private final Map<Integer, Boolean> mApps = new HashMap<>(); private class PackageListObserver implements PackageManagerInternal.PackageListObserver { - @Override - public void onPackageAdded(String packageName, int uid) { - final PackageInfo app = getPackageInfo(packageName); - if (app == null) { - Slog.wtf(TAG, "Failed to get information of installed package: " + packageName); - return; - } - if (uid == INVALID_UID) { - Slog.wtf(TAG, "Failed to get the uid of installed package: " + packageName - + "uid: " + uid); - return; - } - if (app.requestedPermissions == null) { - return; - } - sendPackagePermissionsForUid(uid, - getNetdPermissionMask(app.requestedPermissions)); - } - @Override - public void onPackageRemoved(String packageName, int uid) { + private int getPermissionForUid(int uid) { int permission = 0; - // If there are still packages remain under the same uid, check the permission of the - // remaining packages. We only remove the permission for a given uid when all packages - // for that uid no longer have that permission. + // Check all the packages for this UID. The UID has the permission if any of the + // packages in it has the permission. String[] packages = mPackageManager.getPackagesForUid(uid); if (packages != null && packages.length > 0) { for (String name : packages) { final PackageInfo app = getPackageInfo(name); if (app != null && app.requestedPermissions != null) { - permission |= getNetdPermissionMask(app.requestedPermissions); + permission |= getNetdPermissionMask(app.requestedPermissions, + app.requestedPermissionsFlags); } } } - sendPackagePermissionsForUid(uid, permission); + return permission; + } + + @Override + public void onPackageAdded(String packageName, int uid) { + sendPackagePermissionsForUid(uid, getPermissionForUid(uid)); + } + + @Override + public void onPackageRemoved(String packageName, int uid) { + sendPackagePermissionsForUid(uid, getPermissionForUid(uid)); } } @@ -167,12 +161,9 @@ public class PermissionMonitor { } //TODO: unify the management of the permissions into one codepath. - if (app.requestedPermissions != null) { - int otherNetdPerms = getNetdPermissionMask(app.requestedPermissions); - if (otherNetdPerms != 0) { - netdPermsUids.put(uid, netdPermsUids.get(uid) | otherNetdPerms); - } - } + int otherNetdPerms = getNetdPermissionMask(app.requestedPermissions, + app.requestedPermissionsFlags); + netdPermsUids.put(uid, netdPermsUids.get(uid) | otherNetdPerms); } List<UserInfo> users = mUserManager.getUsers(true); // exclude dying users @@ -182,6 +173,23 @@ public class PermissionMonitor { } } + final SparseArray<ArraySet<String>> systemPermission = + SystemConfig.getInstance().getSystemPermissions(); + for (int i = 0; i < systemPermission.size(); i++) { + ArraySet<String> perms = systemPermission.valueAt(i); + int uid = systemPermission.keyAt(i); + int netdPermission = 0; + // Get the uids of native services that have UPDATE_DEVICE_STATS permission. + if (perms != null) { + netdPermission |= perms.contains(UPDATE_DEVICE_STATS) + ? INetd.PERMISSION_UPDATE_DEVICE_STATS : 0; + } + // For internet permission, the native services have their own selinux domains and + // sepolicy will control the socket creation during run time. netd cannot block the + // socket creation based on the permission information here. + netdPermission |= INetd.PERMISSION_INTERNET; + netdPermsUids.put(uid, netdPermsUids.get(uid) | netdPermission); + } log("Users: " + mUsers.size() + ", Apps: " + mApps.size()); update(mUsers, mApps, true); sendPackagePermissionsToNetd(netdPermsUids); @@ -403,13 +411,17 @@ public class PermissionMonitor { } } - private static int getNetdPermissionMask(String[] requestedPermissions) { + private static int getNetdPermissionMask(String[] requestedPermissions, + int[] requestedPermissionsFlags) { int permissions = 0; - for (String permissionName : requestedPermissions) { - if (permissionName.equals(INTERNET)) { + if (requestedPermissions == null || requestedPermissionsFlags == null) return permissions; + for (int i = 0; i < requestedPermissions.length; i++) { + if (requestedPermissions[i].equals(INTERNET) + && ((requestedPermissionsFlags[i] & REQUESTED_PERMISSION_GRANTED) != 0)) { permissions |= INetd.PERMISSION_INTERNET; } - if (permissionName.equals(UPDATE_DEVICE_STATS)) { + if (requestedPermissions[i].equals(UPDATE_DEVICE_STATS) + && ((requestedPermissionsFlags[i] & REQUESTED_PERMISSION_GRANTED) != 0)) { permissions |= INetd.PERMISSION_UPDATE_DEVICE_STATS; } } diff --git a/services/core/java/com/android/server/connectivity/TcpKeepaliveController.java b/services/core/java/com/android/server/connectivity/TcpKeepaliveController.java index 3e21b5b15ea1..e570ef1e9bf2 100644 --- a/services/core/java/com/android/server/connectivity/TcpKeepaliveController.java +++ b/services/core/java/com/android/server/connectivity/TcpKeepaliveController.java @@ -16,20 +16,25 @@ package com.android.server.connectivity; import static android.net.SocketKeepalive.DATA_RECEIVED; -import static android.net.SocketKeepalive.ERROR_HARDWARE_UNSUPPORTED; import static android.net.SocketKeepalive.ERROR_INVALID_SOCKET; import static android.net.SocketKeepalive.ERROR_SOCKET_NOT_IDLE; +import static android.net.SocketKeepalive.ERROR_UNSUPPORTED; import static android.os.MessageQueue.OnFileDescriptorEventListener.EVENT_ERROR; import static android.os.MessageQueue.OnFileDescriptorEventListener.EVENT_INPUT; import static android.system.OsConstants.ENOPROTOOPT; import static android.system.OsConstants.FIONREAD; +import static android.system.OsConstants.IPPROTO_IP; import static android.system.OsConstants.IPPROTO_TCP; +import static android.system.OsConstants.IP_TOS; +import static android.system.OsConstants.IP_TTL; import static android.system.OsConstants.TIOCOUTQ; import android.annotation.NonNull; import android.net.NetworkUtils; +import android.net.SocketKeepalive.InvalidPacketException; import android.net.SocketKeepalive.InvalidSocketException; -import android.net.TcpKeepalivePacketData.TcpSocketInfo; +import android.net.TcpKeepalivePacketData; +import android.net.TcpKeepalivePacketDataParcelable; import android.net.TcpRepairWindow; import android.os.Handler; import android.os.MessageQueue; @@ -44,7 +49,6 @@ import com.android.internal.annotations.GuardedBy; import com.android.server.connectivity.KeepaliveTracker.KeepaliveInfo; import java.io.FileDescriptor; -import java.net.InetAddress; import java.net.InetSocketAddress; import java.net.SocketAddress; import java.net.SocketException; @@ -103,26 +107,30 @@ public class TcpKeepaliveController { mFdHandlerQueue = connectivityServiceHandler.getLooper().getQueue(); } + /** Build tcp keepalive packet. */ + public static TcpKeepalivePacketData getTcpKeepalivePacket(@NonNull FileDescriptor fd) + throws InvalidPacketException, InvalidSocketException { + try { + final TcpKeepalivePacketDataParcelable tcpDetails = switchToRepairMode(fd); + return TcpKeepalivePacketData.tcpKeepalivePacket(tcpDetails); + } catch (InvalidPacketException | InvalidSocketException e) { + switchOutOfRepairMode(fd); + throw e; + } + } /** - * Switch the tcp socket to repair mode and query tcp socket information. + * Switch the tcp socket to repair mode and query detail tcp information. * - * @param fd the fd of socket on which to use keepalive offload - * @return a {@link TcpKeepalivePacketData#TcpSocketInfo} object for current + * @param fd the fd of socket on which to use keepalive offload. + * @return a {@link TcpKeepalivePacketData#TcpKeepalivePacketDataParcelable} object for current * tcp/ip information. */ - // TODO : make this private. It's far too confusing that this gets called from outside - // at a time that nobody can understand. - public static TcpSocketInfo switchToRepairMode(FileDescriptor fd) + private static TcpKeepalivePacketDataParcelable switchToRepairMode(FileDescriptor fd) throws InvalidSocketException { if (DBG) Log.i(TAG, "switchToRepairMode to start tcp keepalive : " + fd); + final TcpKeepalivePacketDataParcelable tcpDetails = new TcpKeepalivePacketDataParcelable(); final SocketAddress srcSockAddr; final SocketAddress dstSockAddr; - final InetAddress srcAddress; - final InetAddress dstAddress; - final int srcPort; - final int dstPort; - int seq; - final int ack; final TcpRepairWindow trw; // Query source address and port. @@ -133,8 +141,8 @@ public class TcpKeepaliveController { throw new InvalidSocketException(ERROR_INVALID_SOCKET, e); } if (srcSockAddr instanceof InetSocketAddress) { - srcAddress = getAddress((InetSocketAddress) srcSockAddr); - srcPort = getPort((InetSocketAddress) srcSockAddr); + tcpDetails.srcAddress = getAddress((InetSocketAddress) srcSockAddr); + tcpDetails.srcPort = getPort((InetSocketAddress) srcSockAddr); } else { Log.e(TAG, "Invalid or mismatched SocketAddress"); throw new InvalidSocketException(ERROR_INVALID_SOCKET); @@ -147,8 +155,8 @@ public class TcpKeepaliveController { throw new InvalidSocketException(ERROR_INVALID_SOCKET, e); } if (dstSockAddr instanceof InetSocketAddress) { - dstAddress = getAddress((InetSocketAddress) dstSockAddr); - dstPort = getPort((InetSocketAddress) dstSockAddr); + tcpDetails.dstAddress = getAddress((InetSocketAddress) dstSockAddr); + tcpDetails.dstPort = getPort((InetSocketAddress) dstSockAddr); } else { Log.e(TAG, "Invalid or mismatched peer SocketAddress"); throw new InvalidSocketException(ERROR_INVALID_SOCKET); @@ -157,34 +165,49 @@ public class TcpKeepaliveController { // Query sequence and ack number dropAllIncomingPackets(fd, true); try { - // Enter tcp repair mode. + // Switch to tcp repair mode. Os.setsockoptInt(fd, IPPROTO_TCP, TCP_REPAIR, TCP_REPAIR_ON); + // Check if socket is idle. if (!isSocketIdle(fd)) { + Log.e(TAG, "Socket is not idle"); throw new InvalidSocketException(ERROR_SOCKET_NOT_IDLE); } // Query write sequence number from SEND_QUEUE. Os.setsockoptInt(fd, IPPROTO_TCP, TCP_REPAIR_QUEUE, TCP_SEND_QUEUE); - seq = Os.getsockoptInt(fd, IPPROTO_TCP, TCP_QUEUE_SEQ); + tcpDetails.seq = Os.getsockoptInt(fd, IPPROTO_TCP, TCP_QUEUE_SEQ); // Query read sequence number from RECV_QUEUE. Os.setsockoptInt(fd, IPPROTO_TCP, TCP_REPAIR_QUEUE, TCP_RECV_QUEUE); - ack = Os.getsockoptInt(fd, IPPROTO_TCP, TCP_QUEUE_SEQ); + tcpDetails.ack = Os.getsockoptInt(fd, IPPROTO_TCP, TCP_QUEUE_SEQ); // Switch to NO_QUEUE to prevent illegal socket read/write in repair mode. Os.setsockoptInt(fd, IPPROTO_TCP, TCP_REPAIR_QUEUE, TCP_NO_QUEUE); // Finally, check if socket is still idle. TODO : this check needs to move to // after starting polling to prevent a race. - if (!isSocketIdle(fd)) { + if (!isReceiveQueueEmpty(fd)) { + Log.e(TAG, "Fatal: receive queue of this socket is not empty"); throw new InvalidSocketException(ERROR_INVALID_SOCKET); } + if (!isSendQueueEmpty(fd)) { + Log.e(TAG, "Socket is not idle"); + throw new InvalidSocketException(ERROR_SOCKET_NOT_IDLE); + } // Query tcp window size. trw = NetworkUtils.getTcpRepairWindow(fd); + tcpDetails.rcvWnd = trw.rcvWnd; + tcpDetails.rcvWndScale = trw.rcvWndScale; + if (tcpDetails.srcAddress.length == 4 /* V4 address length */) { + // Query TOS. + tcpDetails.tos = Os.getsockoptInt(fd, IPPROTO_IP, IP_TOS); + // Query TTL. + tcpDetails.ttl = Os.getsockoptInt(fd, IPPROTO_IP, IP_TTL); + } } catch (ErrnoException e) { Log.e(TAG, "Exception reading TCP state from socket", e); if (e.errno == ENOPROTOOPT) { // ENOPROTOOPT may happen in kernel version lower than 4.8. - // Treat it as ERROR_HARDWARE_UNSUPPORTED. - throw new InvalidSocketException(ERROR_HARDWARE_UNSUPPORTED, e); + // Treat it as ERROR_UNSUPPORTED. + throw new InvalidSocketException(ERROR_UNSUPPORTED, e); } else { throw new InvalidSocketException(ERROR_INVALID_SOCKET, e); } @@ -194,10 +217,9 @@ public class TcpKeepaliveController { // Keepalive sequence number is last sequence number - 1. If it couldn't be retrieved, // then it must be set to -1, so decrement in all cases. - seq = seq - 1; + tcpDetails.seq = tcpDetails.seq - 1; - return new TcpSocketInfo(srcAddress, srcPort, dstAddress, dstPort, seq, ack, trw.rcvWnd, - trw.rcvWndScale); + return tcpDetails; } /** @@ -205,10 +227,13 @@ public class TcpKeepaliveController { * * @param fd the fd of socket to switch back to normal. */ - // TODO : make this private. - public static void switchOutOfRepairMode(@NonNull final FileDescriptor fd) - throws ErrnoException { - Os.setsockoptInt(fd, IPPROTO_TCP, TCP_REPAIR, TCP_REPAIR_OFF); + private static void switchOutOfRepairMode(@NonNull final FileDescriptor fd) { + try { + Os.setsockoptInt(fd, IPPROTO_TCP, TCP_REPAIR, TCP_REPAIR_OFF); + } catch (ErrnoException e) { + Log.e(TAG, "Cannot switch socket out of repair mode", e); + // Well, there is not much to do here to recover + } } /** @@ -262,17 +287,12 @@ public class TcpKeepaliveController { mListeners.remove(slot); } mFdHandlerQueue.removeOnFileDescriptorEventListener(fd); - try { - if (DBG) Log.d(TAG, "Moving socket out of repair mode for stop : " + fd); - switchOutOfRepairMode(fd); - } catch (ErrnoException e) { - Log.e(TAG, "Cannot switch socket out of repair mode", e); - // Well, there is not much to do here to recover - } + if (DBG) Log.d(TAG, "Moving socket out of repair mode for stop : " + fd); + switchOutOfRepairMode(fd); } - private static InetAddress getAddress(InetSocketAddress inetAddr) { - return inetAddr.getAddress(); + private static byte [] getAddress(InetSocketAddress inetAddr) { + return inetAddr.getAddress().getAddress(); } private static int getPort(InetSocketAddress inetAddr) { diff --git a/services/core/java/com/android/server/connectivity/Tethering.java b/services/core/java/com/android/server/connectivity/Tethering.java index 35704d404ff3..37fe3d094179 100644 --- a/services/core/java/com/android/server/connectivity/Tethering.java +++ b/services/core/java/com/android/server/connectivity/Tethering.java @@ -247,7 +247,14 @@ public class Tethering extends BaseNetworkObserver { (Intent ignored) -> { mLog.log("OBSERVED default data subscription change"); updateConfiguration(); - mEntitlementMgr.reevaluateSimCardProvisioning(); + // To avoid launch unexpected provisioning checks, ignore re-provisioning when + // no CarrierConfig loaded yet. Assume reevaluateSimCardProvisioning() will be + // triggered again when CarrierConfig is loaded. + if (mEntitlementMgr.getCarrierConfig() != null) { + mEntitlementMgr.reevaluateSimCardProvisioning(); + } else { + mLog.log("IGNORED reevaluate provisioning due to no carrier config loaded"); + } }); mStateReceiver = new StateReceiver(); diff --git a/services/core/java/com/android/server/connectivity/tethering/EntitlementManager.java b/services/core/java/com/android/server/connectivity/tethering/EntitlementManager.java index 65cc51610e72..70ab38983446 100644 --- a/services/core/java/com/android/server/connectivity/tethering/EntitlementManager.java +++ b/services/core/java/com/android/server/connectivity/tethering/EntitlementManager.java @@ -158,6 +158,21 @@ public class EntitlementManager { } } + /** Get carrier configuration bundle. */ + public PersistableBundle getCarrierConfig() { + final CarrierConfigManager configManager = (CarrierConfigManager) mContext + .getSystemService(Context.CARRIER_CONFIG_SERVICE); + if (configManager == null) return null; + + final PersistableBundle carrierConfig = configManager.getConfig(); + + if (CarrierConfigManager.isConfigForIdentifiedCarrier(carrierConfig)) { + return carrierConfig; + } + + return null; + } + // The logic here is aimed solely at confirming that a CarrierConfig exists // and affirms that entitlement checks are not required. // @@ -165,11 +180,7 @@ public class EntitlementManager { // entirely so that this is more intuitive. private boolean carrierConfigAffirmsEntitlementCheckNotRequired() { // Check carrier config for entitlement checks - final CarrierConfigManager configManager = (CarrierConfigManager) mContext - .getSystemService(Context.CARRIER_CONFIG_SERVICE); - if (configManager == null) return false; - - final PersistableBundle carrierConfig = configManager.getConfig(); + final PersistableBundle carrierConfig = getCarrierConfig(); if (carrierConfig == null) return false; // A CarrierConfigManager was found and it has a config. diff --git a/services/core/java/com/android/server/connectivity/tethering/IPv6TetheringCoordinator.java b/services/core/java/com/android/server/connectivity/tethering/IPv6TetheringCoordinator.java index 100014898127..38eb0bcfd3cc 100644 --- a/services/core/java/com/android/server/connectivity/tethering/IPv6TetheringCoordinator.java +++ b/services/core/java/com/android/server/connectivity/tethering/IPv6TetheringCoordinator.java @@ -17,7 +17,6 @@ package com.android.server.connectivity.tethering; import android.net.ConnectivityManager; -import android.net.ip.IpServer; import android.net.IpPrefix; import android.net.LinkAddress; import android.net.LinkProperties; @@ -25,6 +24,7 @@ import android.net.Network; import android.net.NetworkCapabilities; import android.net.NetworkState; import android.net.RouteInfo; +import android.net.ip.IpServer; import android.net.util.NetworkConstants; import android.net.util.SharedLog; import android.util.Log; @@ -191,7 +191,7 @@ public class IPv6TetheringCoordinator { if (currentActive != null && currentActive.ipServer == ipServer) { final LinkProperties lp = getIPv6OnlyLinkProperties( mUpstreamNetworkState.linkProperties); - if (lp.hasIPv6DefaultRoute() && lp.hasGlobalIPv6Address()) { + if (lp.hasIpv6DefaultRoute() && lp.hasGlobalIpv6Address()) { return lp; } } diff --git a/services/core/java/com/android/server/connectivity/tethering/TetheringInterfaceUtils.java b/services/core/java/com/android/server/connectivity/tethering/TetheringInterfaceUtils.java index 6c7ff91761ac..0ef3805ff7c0 100644 --- a/services/core/java/com/android/server/connectivity/tethering/TetheringInterfaceUtils.java +++ b/services/core/java/com/android/server/connectivity/tethering/TetheringInterfaceUtils.java @@ -67,14 +67,14 @@ public final class TetheringInterfaceUtils { // because "[t]he 3GPP network allocates each default bearer a unique // /64 prefix", per RFC 6459, Section 5.2. final boolean canTether = - (ns != null) && (ns.network != null) && - (ns.linkProperties != null) && (ns.networkCapabilities != null) && + (ns != null) && (ns.network != null) + && (ns.linkProperties != null) && (ns.networkCapabilities != null) // At least one upstream DNS server: - ns.linkProperties.hasIPv6DnsServer() && + && ns.linkProperties.hasIpv6DnsServer() // Minimal amount of IPv6 provisioning: - ns.linkProperties.hasGlobalIPv6Address() && + && ns.linkProperties.hasGlobalIpv6Address() // Temporary approximation of "dedicated prefix": - ns.networkCapabilities.hasTransport(NetworkCapabilities.TRANSPORT_CELLULAR); + && ns.networkCapabilities.hasTransport(NetworkCapabilities.TRANSPORT_CELLULAR); return canTether ? getInterfaceForDestination(ns.linkProperties, Inet6Address.ANY) diff --git a/services/core/java/com/android/server/media/projection/OWNERS b/services/core/java/com/android/server/media/projection/OWNERS new file mode 100644 index 000000000000..7e7335d68d3b --- /dev/null +++ b/services/core/java/com/android/server/media/projection/OWNERS @@ -0,0 +1 @@ +michaelwr@google.com diff --git a/services/core/java/com/android/server/os/BugreportManagerServiceImpl.java b/services/core/java/com/android/server/os/BugreportManagerServiceImpl.java index 5c0874d7977a..c98a79ad4ed9 100644 --- a/services/core/java/com/android/server/os/BugreportManagerServiceImpl.java +++ b/services/core/java/com/android/server/os/BugreportManagerServiceImpl.java @@ -174,7 +174,11 @@ class BugreportManagerServiceImpl extends IDumpstate.Stub { ds.startBugreport(callingUid, callingPackage, bugreportFd, screenshotFd, bugreportMode, myListener); } catch (RemoteException e) { - reportError(listener, IDumpstateListener.BUGREPORT_ERROR_RUNTIME_ERROR); + // bugreportd service is already started now. We need to kill it to manage the + // lifecycle correctly. If we don't subsequent callers will get + // BUGREPORT_ERROR_ANOTHER_REPORT_IN_PROGRESS error. + // Note that listener will be notified by the death recipient below. + cancelBugreport(); } } diff --git a/services/core/java/com/android/server/policy/EventLogTags.logtags b/services/core/java/com/android/server/policy/EventLogTags.logtags new file mode 100644 index 000000000000..75633820d01f --- /dev/null +++ b/services/core/java/com/android/server/policy/EventLogTags.logtags @@ -0,0 +1,8 @@ +# See system/core/logcat/event.logtags for a description of the format of this file. + +option java_package com.android.server.policy + + +# 0 for screen off, 1 for screen on +70000 screen_toggled (screen_state|1|5) +70001 intercept_power (action|3),(mPowerKeyHandled|1),(mPowerKeyPressCounter|1) diff --git a/services/core/java/com/android/server/policy/PhoneWindowManager.java b/services/core/java/com/android/server/policy/PhoneWindowManager.java index 9a741bcfc3d6..0149d30da6bd 100644 --- a/services/core/java/com/android/server/policy/PhoneWindowManager.java +++ b/services/core/java/com/android/server/policy/PhoneWindowManager.java @@ -225,7 +225,6 @@ import android.speech.RecognizerIntent; import android.telecom.TelecomManager; import android.util.ArraySet; import android.util.DisplayMetrics; -import android.util.EventLog; import android.util.Log; import android.util.LongSparseArray; import android.util.MutableBoolean; @@ -270,12 +269,11 @@ import com.android.internal.logging.MetricsLogger; import com.android.internal.logging.nano.MetricsProto; import com.android.internal.policy.IKeyguardDismissCallback; import com.android.internal.policy.IShortcutService; -import com.android.internal.policy.KeyguardDismissCallback; import com.android.internal.policy.PhoneWindow; import com.android.internal.statusbar.IStatusBarService; import com.android.internal.util.ArrayUtils; -import com.android.internal.util.ScreenshotHelper; import com.android.internal.util.ScreenShapeHelper; +import com.android.internal.util.ScreenshotHelper; import com.android.internal.widget.PointerLocationView; import com.android.server.GestureLauncherService; import com.android.server.LocalServices; @@ -6247,6 +6245,9 @@ public class PhoneWindowManager implements WindowManagerPolicy { } case KeyEvent.KEYCODE_POWER: { + EventLogTags.writeInterceptPower( + KeyEvent.actionToString(event.getAction()), + mPowerKeyHandled ? 1 : 0, mPowerKeyPressCounter); // Any activity on the power button stops the accessibility shortcut cancelPendingAccessibilityShortcutAction(); result &= ~ACTION_PASS_TO_USER; @@ -6785,7 +6786,7 @@ public class PhoneWindowManager implements WindowManagerPolicy { // Called on the PowerManager's Notifier thread. @Override public void finishedGoingToSleep(int why) { - EventLog.writeEvent(70000, 0); + EventLogTags.writeScreenToggled(0); if (DEBUG_WAKEUP) Slog.i(TAG, "Finished going to sleep... (why=" + why + ")"); MetricsLogger.histogram(mContext, "screen_timeout", mLockScreenTimeout / 1000); @@ -6810,7 +6811,7 @@ public class PhoneWindowManager implements WindowManagerPolicy { // Called on the PowerManager's Notifier thread. @Override public void startedWakingUp() { - EventLog.writeEvent(70000, 1); + EventLogTags.writeScreenToggled(1); if (DEBUG_WAKEUP) Slog.i(TAG, "Started waking up..."); // Since goToSleep performs these functions synchronously, we must diff --git a/services/core/java/com/android/server/wm/DisplayContent.java b/services/core/java/com/android/server/wm/DisplayContent.java index 22ac65df4337..1fb28e1969a8 100644 --- a/services/core/java/com/android/server/wm/DisplayContent.java +++ b/services/core/java/com/android/server/wm/DisplayContent.java @@ -3703,13 +3703,19 @@ class DisplayContent extends WindowContainer<DisplayContent.DisplayChildWindowCo .show(mSplitScreenDividerAnchor); scheduleAnimation(); } else { - mAppAnimationLayer.destroy(); + // At this time mBoostedAppAnimationLayer may be used for animating, + // and ResizeableActivity is in it. mBoostedAppAnimationLayer.destroy() + // can also destroy the surface of ResizeableActivity, but the surface will + // be used after. So change to use transaction to call destroy to delay it, + // and ResizeableActivity is not in mBoostedAppAnimationLayer. + getPendingTransaction() + .destroy(mAppAnimationLayer) + .destroy(mBoostedAppAnimationLayer) + .destroy(mHomeAppAnimationLayer) + .destroy(mSplitScreenDividerAnchor); mAppAnimationLayer = null; - mBoostedAppAnimationLayer.destroy(); mBoostedAppAnimationLayer = null; - mHomeAppAnimationLayer.destroy(); mHomeAppAnimationLayer = null; - mSplitScreenDividerAnchor.destroy(); mSplitScreenDividerAnchor = null; } } diff --git a/services/net/Android.bp b/services/net/Android.bp index 486d15d918bf..67fbdc4d95f2 100644 --- a/services/net/Android.bp +++ b/services/net/Android.bp @@ -1,3 +1,59 @@ +// AIDL interfaces between the core system and the networking mainline module. +aidl_interface { + name: "ipmemorystore-aidl-interfaces", + local_include_dir: "java", + srcs: [ + // TODO: Define and use a filegroup for these files, since they're also used in + // networkstack-aidl-interfaces. This does not appear to work at the moment. + "java/android/net/IIpMemoryStore.aidl", + "java/android/net/IIpMemoryStoreCallbacks.aidl", + "java/android/net/ipmemorystore/**/*.aidl", + ], + backend: { + ndk: { + enabled: false, + }, + cpp: { + enabled: false, + }, + }, + api_dir: "aidl/networkstack", +} + +aidl_interface { + name: "networkstack-aidl-interfaces", + local_include_dir: "java", + include_dirs: ["frameworks/base/core/java"], // For framework parcelables. + srcs: [ + "java/android/net/DhcpResultsParcelable.aidl", + "java/android/net/IIpMemoryStore.aidl", + "java/android/net/IIpMemoryStoreCallbacks.aidl", + "java/android/net/INetworkMonitor.aidl", + "java/android/net/INetworkMonitorCallbacks.aidl", + "java/android/net/INetworkStackConnector.aidl", + "java/android/net/INetworkStackStatusCallback.aidl", + "java/android/net/InitialConfigurationParcelable.aidl", + "java/android/net/PrivateDnsConfigParcel.aidl", + "java/android/net/ProvisioningConfigurationParcelable.aidl", + "java/android/net/TcpKeepalivePacketDataParcelable.aidl", + "java/android/net/dhcp/DhcpServingParamsParcel.aidl", + "java/android/net/dhcp/IDhcpServer.aidl", + "java/android/net/dhcp/IDhcpServerCallbacks.aidl", + "java/android/net/ip/IIpClient.aidl", + "java/android/net/ip/IIpClientCallbacks.aidl", + "java/android/net/ipmemorystore/**/*.aidl", + ], + backend: { + ndk: { + enabled: false, + }, + cpp: { + enabled: false, + }, + }, + api_dir: "aidl/networkstack", +} + java_library_static { name: "services.net", srcs: ["java/**/*.java"], diff --git a/core/java/android/net/DhcpResultsParcelable.aidl b/services/net/java/android/net/DhcpResultsParcelable.aidl index cf5629b6f792..978638b51ad1 100644 --- a/core/java/android/net/DhcpResultsParcelable.aidl +++ b/services/net/java/android/net/DhcpResultsParcelable.aidl @@ -16,10 +16,10 @@ package android.net; -import android.net.StaticIpConfigurationParcelable; +import android.net.StaticIpConfiguration; parcelable DhcpResultsParcelable { - StaticIpConfigurationParcelable baseConfiguration; + StaticIpConfiguration baseConfiguration; int leaseDuration; int mtu; String serverAddress; diff --git a/core/java/android/net/IIpMemoryStore.aidl b/services/net/java/android/net/IIpMemoryStore.aidl index 6f88dec8dee9..6f88dec8dee9 100644 --- a/core/java/android/net/IIpMemoryStore.aidl +++ b/services/net/java/android/net/IIpMemoryStore.aidl diff --git a/core/java/android/net/IIpMemoryStoreCallbacks.aidl b/services/net/java/android/net/IIpMemoryStoreCallbacks.aidl index 53108dbca097..53108dbca097 100644 --- a/core/java/android/net/IIpMemoryStoreCallbacks.aidl +++ b/services/net/java/android/net/IIpMemoryStoreCallbacks.aidl diff --git a/core/java/android/net/INetworkMonitor.aidl b/services/net/java/android/net/INetworkMonitor.aidl index 5d1ab983c5fc..1b0e1d788ff3 100644 --- a/core/java/android/net/INetworkMonitor.aidl +++ b/services/net/java/android/net/INetworkMonitor.aidl @@ -41,7 +41,7 @@ oneway interface INetworkMonitor { void start(); void launchCaptivePortalApp(); void notifyCaptivePortalAppFinished(int response); - void notifyAcceptPartialConnectivity(); + void setAcceptPartialConnectivity(); void forceReevaluation(int uid); void notifyPrivateDnsChanged(in PrivateDnsConfigParcel config); void notifyDnsResponse(int returnCode); diff --git a/core/java/android/net/INetworkMonitorCallbacks.aidl b/services/net/java/android/net/INetworkMonitorCallbacks.aidl index 2c61511feb72..2c61511feb72 100644 --- a/core/java/android/net/INetworkMonitorCallbacks.aidl +++ b/services/net/java/android/net/INetworkMonitorCallbacks.aidl diff --git a/core/java/android/net/INetworkStackConnector.aidl b/services/net/java/android/net/INetworkStackConnector.aidl index 3751c36d6ee9..3751c36d6ee9 100644 --- a/core/java/android/net/INetworkStackConnector.aidl +++ b/services/net/java/android/net/INetworkStackConnector.aidl diff --git a/core/java/android/net/INetworkStackStatusCallback.aidl b/services/net/java/android/net/INetworkStackStatusCallback.aidl index 51032d80a172..51032d80a172 100644 --- a/core/java/android/net/INetworkStackStatusCallback.aidl +++ b/services/net/java/android/net/INetworkStackStatusCallback.aidl diff --git a/core/java/android/net/InitialConfigurationParcelable.aidl b/services/net/java/android/net/InitialConfigurationParcelable.aidl index 3fa88c377a64..3fa88c377a64 100644 --- a/core/java/android/net/InitialConfigurationParcelable.aidl +++ b/services/net/java/android/net/InitialConfigurationParcelable.aidl diff --git a/core/java/android/net/PrivateDnsConfigParcel.aidl b/services/net/java/android/net/PrivateDnsConfigParcel.aidl index b52fce643302..b52fce643302 100644 --- a/core/java/android/net/PrivateDnsConfigParcel.aidl +++ b/services/net/java/android/net/PrivateDnsConfigParcel.aidl diff --git a/core/java/android/net/ProvisioningConfigurationParcelable.aidl b/services/net/java/android/net/ProvisioningConfigurationParcelable.aidl index 5b46d7f55ee3..99606fb4b7a2 100644 --- a/core/java/android/net/ProvisioningConfigurationParcelable.aidl +++ b/services/net/java/android/net/ProvisioningConfigurationParcelable.aidl @@ -17,10 +17,10 @@ package android.net; -import android.net.ApfCapabilitiesParcelable; import android.net.InitialConfigurationParcelable; import android.net.Network; -import android.net.StaticIpConfigurationParcelable; +import android.net.StaticIpConfiguration; +import android.net.apf.ApfCapabilities; parcelable ProvisioningConfigurationParcelable { boolean enableIPv4; @@ -29,8 +29,8 @@ parcelable ProvisioningConfigurationParcelable { boolean usingIpReachabilityMonitor; int requestedPreDhcpActionMs; InitialConfigurationParcelable initialConfig; - StaticIpConfigurationParcelable staticIpConfig; - ApfCapabilitiesParcelable apfCapabilities; + StaticIpConfiguration staticIpConfig; + ApfCapabilities apfCapabilities; int provisioningTimeoutMs; int ipv6AddrGenMode; Network network; diff --git a/core/java/android/net/TcpKeepalivePacketData.java b/services/net/java/android/net/TcpKeepalivePacketData.java index f07dfb64cd01..7f2f499ab21f 100644 --- a/core/java/android/net/TcpKeepalivePacketData.java +++ b/services/net/java/android/net/TcpKeepalivePacketData.java @@ -25,8 +25,8 @@ import android.os.Parcel; import android.os.Parcelable; import android.system.OsConstants; -import java.net.Inet4Address; import java.net.InetAddress; +import java.net.UnknownHostException; import java.nio.ByteBuffer; import java.nio.ByteOrder; import java.util.Objects; @@ -38,7 +38,7 @@ import java.util.Objects; public class TcpKeepalivePacketData extends KeepalivePacketData implements Parcelable { private static final String TAG = "TcpKeepalivePacketData"; - /** TCP sequence number. */ + /** TCP sequence number. */ public final int tcpSeq; /** TCP ACK number. */ @@ -50,38 +50,51 @@ public class TcpKeepalivePacketData extends KeepalivePacketData implements Parce /** TCP RCV window scale. */ public final int tcpWndScale; + /** IP TOS. */ + public final int ipTos; + + /** IP TTL. */ + public final int ipTtl; + private static final int IPV4_HEADER_LENGTH = 20; private static final int IPV6_HEADER_LENGTH = 40; private static final int TCP_HEADER_LENGTH = 20; // This should only be constructed via static factory methods, such as // tcpKeepalivePacket. - private TcpKeepalivePacketData(TcpSocketInfo tcpDetails, byte[] data) - throws InvalidPacketException { - super(tcpDetails.srcAddress, tcpDetails.srcPort, tcpDetails.dstAddress, - tcpDetails.dstPort, data); + private TcpKeepalivePacketData(final TcpKeepalivePacketDataParcelable tcpDetails, + final byte[] data) throws InvalidPacketException, UnknownHostException { + super(InetAddress.getByAddress(tcpDetails.srcAddress), tcpDetails.srcPort, + InetAddress.getByAddress(tcpDetails.dstAddress), tcpDetails.dstPort, data); tcpSeq = tcpDetails.seq; tcpAck = tcpDetails.ack; // In the packet, the window is shifted right by the window scale. tcpWnd = tcpDetails.rcvWnd; tcpWndScale = tcpDetails.rcvWndScale; + ipTos = tcpDetails.tos; + ipTtl = tcpDetails.ttl; } /** * Factory method to create tcp keepalive packet structure. */ public static TcpKeepalivePacketData tcpKeepalivePacket( - TcpSocketInfo tcpDetails) throws InvalidPacketException { + TcpKeepalivePacketDataParcelable tcpDetails) throws InvalidPacketException { final byte[] packet; - if ((tcpDetails.srcAddress instanceof Inet4Address) - && (tcpDetails.dstAddress instanceof Inet4Address)) { - packet = buildV4Packet(tcpDetails); - } else { - // TODO: support ipv6 + try { + if ((tcpDetails.srcAddress != null) && (tcpDetails.dstAddress != null) + && (tcpDetails.srcAddress.length == 4 /* V4 IP length */) + && (tcpDetails.dstAddress.length == 4 /* V4 IP length */)) { + packet = buildV4Packet(tcpDetails); + } else { + // TODO: support ipv6 + throw new InvalidPacketException(ERROR_INVALID_IP_ADDRESS); + } + return new TcpKeepalivePacketData(tcpDetails, packet); + } catch (UnknownHostException e) { throw new InvalidPacketException(ERROR_INVALID_IP_ADDRESS); } - return new TcpKeepalivePacketData(tcpDetails, packet); } /** @@ -89,21 +102,20 @@ public class TcpKeepalivePacketData extends KeepalivePacketData implements Parce */ // TODO : if this code is ever moved to the network stack, factorize constants with the ones // over there. - private static byte[] buildV4Packet(TcpSocketInfo tcpDetails) { + private static byte[] buildV4Packet(TcpKeepalivePacketDataParcelable tcpDetails) { final int length = IPV4_HEADER_LENGTH + TCP_HEADER_LENGTH; ByteBuffer buf = ByteBuffer.allocate(length); buf.order(ByteOrder.BIG_ENDIAN); - // IP version and TOS. TODO : fetch this from getsockopt(SOL_IP, IP_TOS) - buf.putShort((short) 0x4500); + buf.put((byte) 0x45); // IP version and IHL + buf.put((byte) tcpDetails.tos); // TOS buf.putShort((short) length); - buf.putInt(0x4000); // ID, flags=DF, offset - // TODO : fetch TTL from getsockopt(SOL_IP, IP_TTL) - buf.put((byte) 64); + buf.putInt(0x00004000); // ID, flags=DF, offset + buf.put((byte) tcpDetails.ttl); // TTL buf.put((byte) OsConstants.IPPROTO_TCP); final int ipChecksumOffset = buf.position(); buf.putShort((short) 0); // IP checksum - buf.put(tcpDetails.srcAddress.getAddress()); - buf.put(tcpDetails.dstAddress.getAddress()); + buf.put(tcpDetails.srcAddress); + buf.put(tcpDetails.dstAddress); buf.putShort((short) tcpDetails.srcPort); buf.putShort((short) tcpDetails.dstPort); buf.putInt(tcpDetails.seq); // Sequence Number @@ -112,7 +124,9 @@ public class TcpKeepalivePacketData extends KeepalivePacketData implements Parce buf.putShort((short) (tcpDetails.rcvWnd >> tcpDetails.rcvWndScale)); // Window size final int tcpChecksumOffset = buf.position(); buf.putShort((short) 0); // TCP checksum - // URG is not set therefore the urgent pointer is not included + // URG is not set therefore the urgent pointer is zero. + buf.putShort((short) 0); // Urgent pointer + buf.putShort(ipChecksumOffset, IpUtils.ipChecksum(buf, 0)); buf.putShort(tcpChecksumOffset, IpUtils.tcpChecksum( buf, 0, IPV4_HEADER_LENGTH, TCP_HEADER_LENGTH)); @@ -122,31 +136,6 @@ public class TcpKeepalivePacketData extends KeepalivePacketData implements Parce // TODO: add buildV6Packet. - /** Represents tcp/ip information. */ - // TODO: Replace TcpSocketInfo with TcpKeepalivePacketDataParcelable. - public static class TcpSocketInfo { - public final InetAddress srcAddress; - public final InetAddress dstAddress; - public final int srcPort; - public final int dstPort; - public final int seq; - public final int ack; - public final int rcvWnd; - public final int rcvWndScale; - - public TcpSocketInfo(InetAddress sAddr, int sPort, InetAddress dAddr, - int dPort, int writeSeq, int readSeq, int rWnd, int rWndScale) { - srcAddress = sAddr; - dstAddress = dAddr; - srcPort = sPort; - dstPort = dPort; - seq = writeSeq; - ack = readSeq; - rcvWnd = rWnd; - rcvWndScale = rWndScale; - } - } - @Override public boolean equals(@Nullable final Object o) { if (!(o instanceof TcpKeepalivePacketData)) return false; @@ -158,17 +147,20 @@ public class TcpKeepalivePacketData extends KeepalivePacketData implements Parce && this.tcpAck == other.tcpAck && this.tcpSeq == other.tcpSeq && this.tcpWnd == other.tcpWnd - && this.tcpWndScale == other.tcpWndScale; + && this.tcpWndScale == other.tcpWndScale + && this.ipTos == other.ipTos + && this.ipTtl == other.ipTtl; } @Override public int hashCode() { return Objects.hash(srcAddress, dstAddress, srcPort, dstPort, tcpAck, tcpSeq, tcpWnd, - tcpWndScale); + tcpWndScale, ipTos, ipTtl); } - /* Parcelable Implementation. */ - /* Note that this object implements parcelable (and needs to keep doing this as it inherits + /** + * Parcelable Implementation. + * Note that this object implements parcelable (and needs to keep doing this as it inherits * from a class that does), but should usually be parceled as a stable parcelable using * the toStableParcelable() and fromStableParcelable() methods. */ @@ -183,6 +175,8 @@ public class TcpKeepalivePacketData extends KeepalivePacketData implements Parce out.writeInt(tcpAck); out.writeInt(tcpWnd); out.writeInt(tcpWndScale); + out.writeInt(ipTos); + out.writeInt(ipTtl); } private TcpKeepalivePacketData(Parcel in) { @@ -191,10 +185,12 @@ public class TcpKeepalivePacketData extends KeepalivePacketData implements Parce tcpAck = in.readInt(); tcpWnd = in.readInt(); tcpWndScale = in.readInt(); + ipTos = in.readInt(); + ipTtl = in.readInt(); } /** Parcelable Creator. */ - public static final Parcelable.Creator<TcpKeepalivePacketData> CREATOR = + public static final @NonNull Parcelable.Creator<TcpKeepalivePacketData> CREATOR = new Parcelable.Creator<TcpKeepalivePacketData>() { public TcpKeepalivePacketData createFromParcel(Parcel in) { return new TcpKeepalivePacketData(in); @@ -217,6 +213,10 @@ public class TcpKeepalivePacketData extends KeepalivePacketData implements Parce parcel.dstPort = dstPort; parcel.seq = tcpSeq; parcel.ack = tcpAck; + parcel.rcvWnd = tcpWnd; + parcel.rcvWndScale = tcpWndScale; + parcel.tos = ipTos; + parcel.ttl = ipTtl; return parcel; } @@ -229,6 +229,8 @@ public class TcpKeepalivePacketData extends KeepalivePacketData implements Parce + " seq: " + tcpSeq + " ack: " + tcpAck + " wnd: " + tcpWnd - + " wndScale: " + tcpWndScale; + + " wndScale: " + tcpWndScale + + " tos: " + ipTos + + " ttl: " + ipTtl; } } diff --git a/core/java/android/net/TcpKeepalivePacketDataParcelable.aidl b/services/net/java/android/net/TcpKeepalivePacketDataParcelable.aidl index 7329c63b09be..e25168d588e7 100644 --- a/core/java/android/net/TcpKeepalivePacketDataParcelable.aidl +++ b/services/net/java/android/net/TcpKeepalivePacketDataParcelable.aidl @@ -23,4 +23,8 @@ parcelable TcpKeepalivePacketDataParcelable { int dstPort; int seq; int ack; + int rcvWnd; + int rcvWndScale; + int tos; + int ttl; } diff --git a/core/java/android/net/dhcp/DhcpServingParamsParcel.aidl b/services/net/java/android/net/dhcp/DhcpServingParamsParcel.aidl index 7b8b9ee324bc..7b8b9ee324bc 100644 --- a/core/java/android/net/dhcp/DhcpServingParamsParcel.aidl +++ b/services/net/java/android/net/dhcp/DhcpServingParamsParcel.aidl diff --git a/core/java/android/net/dhcp/IDhcpServer.aidl b/services/net/java/android/net/dhcp/IDhcpServer.aidl index 559433b13962..559433b13962 100644 --- a/core/java/android/net/dhcp/IDhcpServer.aidl +++ b/services/net/java/android/net/dhcp/IDhcpServer.aidl diff --git a/core/java/android/net/dhcp/IDhcpServerCallbacks.aidl b/services/net/java/android/net/dhcp/IDhcpServerCallbacks.aidl index 7ab4dcdbe584..7ab4dcdbe584 100644 --- a/core/java/android/net/dhcp/IDhcpServerCallbacks.aidl +++ b/services/net/java/android/net/dhcp/IDhcpServerCallbacks.aidl diff --git a/core/java/android/net/ip/IIpClient.aidl b/services/net/java/android/net/ip/IIpClient.aidl index b834e45c6852..b834e45c6852 100644 --- a/core/java/android/net/ip/IIpClient.aidl +++ b/services/net/java/android/net/ip/IIpClient.aidl diff --git a/core/java/android/net/ip/IIpClientCallbacks.aidl b/services/net/java/android/net/ip/IIpClientCallbacks.aidl index 3681416611a9..3681416611a9 100644 --- a/core/java/android/net/ip/IIpClientCallbacks.aidl +++ b/services/net/java/android/net/ip/IIpClientCallbacks.aidl diff --git a/services/net/java/android/net/ip/IpServer.java b/services/net/java/android/net/ip/IpServer.java index 0e44f88d2389..fc1128b80499 100644 --- a/services/net/java/android/net/ip/IpServer.java +++ b/services/net/java/android/net/ip/IpServer.java @@ -506,7 +506,7 @@ public class IpServer extends StateMachine { if (v6only != null) { params = new RaParams(); params.mtu = v6only.getMtu(); - params.hasDefaultRoute = v6only.hasIPv6DefaultRoute(); + params.hasDefaultRoute = v6only.hasIpv6DefaultRoute(); if (params.hasDefaultRoute) params.hopLimit = getHopLimit(v6only.getInterfaceName()); diff --git a/core/java/android/net/ipmemorystore/Blob.aidl b/services/net/java/android/net/ipmemorystore/Blob.aidl index 9dbef117f8a4..9dbef117f8a4 100644 --- a/core/java/android/net/ipmemorystore/Blob.aidl +++ b/services/net/java/android/net/ipmemorystore/Blob.aidl diff --git a/core/java/android/net/ipmemorystore/IOnBlobRetrievedListener.aidl b/services/net/java/android/net/ipmemorystore/IOnBlobRetrievedListener.aidl index 4926feb06e55..4926feb06e55 100644 --- a/core/java/android/net/ipmemorystore/IOnBlobRetrievedListener.aidl +++ b/services/net/java/android/net/ipmemorystore/IOnBlobRetrievedListener.aidl diff --git a/core/java/android/net/ipmemorystore/IOnL2KeyResponseListener.aidl b/services/net/java/android/net/ipmemorystore/IOnL2KeyResponseListener.aidl index dea0cc4e2586..dea0cc4e2586 100644 --- a/core/java/android/net/ipmemorystore/IOnL2KeyResponseListener.aidl +++ b/services/net/java/android/net/ipmemorystore/IOnL2KeyResponseListener.aidl diff --git a/core/java/android/net/ipmemorystore/IOnNetworkAttributesRetrieved.aidl b/services/net/java/android/net/ipmemorystore/IOnNetworkAttributesRetrieved.aidl index fb4ca3b97895..fb4ca3b97895 100644 --- a/core/java/android/net/ipmemorystore/IOnNetworkAttributesRetrieved.aidl +++ b/services/net/java/android/net/ipmemorystore/IOnNetworkAttributesRetrieved.aidl diff --git a/core/java/android/net/ipmemorystore/IOnSameNetworkResponseListener.aidl b/services/net/java/android/net/ipmemorystore/IOnSameNetworkResponseListener.aidl index 294bd3bd4012..294bd3bd4012 100644 --- a/core/java/android/net/ipmemorystore/IOnSameNetworkResponseListener.aidl +++ b/services/net/java/android/net/ipmemorystore/IOnSameNetworkResponseListener.aidl diff --git a/core/java/android/net/ipmemorystore/IOnStatusListener.aidl b/services/net/java/android/net/ipmemorystore/IOnStatusListener.aidl index 5d0750449ec5..5d0750449ec5 100644 --- a/core/java/android/net/ipmemorystore/IOnStatusListener.aidl +++ b/services/net/java/android/net/ipmemorystore/IOnStatusListener.aidl diff --git a/core/java/android/net/ipmemorystore/NetworkAttributesParcelable.aidl b/services/net/java/android/net/ipmemorystore/NetworkAttributesParcelable.aidl index 0894d7260915..0894d7260915 100644 --- a/core/java/android/net/ipmemorystore/NetworkAttributesParcelable.aidl +++ b/services/net/java/android/net/ipmemorystore/NetworkAttributesParcelable.aidl diff --git a/core/java/android/net/ipmemorystore/SameL3NetworkResponseParcelable.aidl b/services/net/java/android/net/ipmemorystore/SameL3NetworkResponseParcelable.aidl index 71966998a68a..71966998a68a 100644 --- a/core/java/android/net/ipmemorystore/SameL3NetworkResponseParcelable.aidl +++ b/services/net/java/android/net/ipmemorystore/SameL3NetworkResponseParcelable.aidl diff --git a/core/java/android/net/ipmemorystore/StatusParcelable.aidl b/services/net/java/android/net/ipmemorystore/StatusParcelable.aidl index fb36ef4a56ff..fb36ef4a56ff 100644 --- a/core/java/android/net/ipmemorystore/StatusParcelable.aidl +++ b/services/net/java/android/net/ipmemorystore/StatusParcelable.aidl diff --git a/services/net/java/android/net/shared/InitialConfiguration.java b/services/net/java/android/net/shared/InitialConfiguration.java index e423d62da7c9..007c8ca93d5a 100644 --- a/services/net/java/android/net/shared/InitialConfiguration.java +++ b/services/net/java/android/net/shared/InitialConfiguration.java @@ -207,7 +207,7 @@ public class InitialConfiguration { } private static boolean isIPv6GUA(LinkAddress addr) { - return addr.isIPv6() && addr.isGlobalPreferred(); + return addr.isIpv6() && addr.isGlobalPreferred(); } // TODO: extract out into CollectionUtils. diff --git a/services/net/java/android/net/shared/IpConfigurationParcelableUtil.java b/services/net/java/android/net/shared/IpConfigurationParcelableUtil.java index 6b5826f8b095..44d8e0ce3635 100644 --- a/services/net/java/android/net/shared/IpConfigurationParcelableUtil.java +++ b/services/net/java/android/net/shared/IpConfigurationParcelableUtil.java @@ -16,17 +16,10 @@ package android.net.shared; -import static android.net.shared.ParcelableUtil.fromParcelableArray; -import static android.net.shared.ParcelableUtil.toParcelableArray; - import android.annotation.Nullable; -import android.net.ApfCapabilitiesParcelable; import android.net.DhcpResults; import android.net.DhcpResultsParcelable; import android.net.InetAddresses; -import android.net.StaticIpConfiguration; -import android.net.StaticIpConfigurationParcelable; -import android.net.apf.ApfCapabilities; import java.net.Inet4Address; import java.net.InetAddress; @@ -38,44 +31,12 @@ import java.net.InetAddress; */ public final class IpConfigurationParcelableUtil { /** - * Convert a StaticIpConfiguration to a StaticIpConfigurationParcelable. - */ - public static StaticIpConfigurationParcelable toStableParcelable( - @Nullable StaticIpConfiguration config) { - if (config == null) return null; - final StaticIpConfigurationParcelable p = new StaticIpConfigurationParcelable(); - p.ipAddress = config.getIpAddress(); - p.gateway = parcelAddress(config.getGateway()); - p.dnsServers = toParcelableArray( - config.getDnsServers(), IpConfigurationParcelableUtil::parcelAddress, String.class); - p.domains = config.getDomains(); - return p; - } - - /** - * Convert a StaticIpConfigurationParcelable to a StaticIpConfiguration. - */ - public static StaticIpConfiguration fromStableParcelable( - @Nullable StaticIpConfigurationParcelable p) { - if (p == null) return null; - final StaticIpConfiguration config = new StaticIpConfiguration(); - config.setIpAddress(p.ipAddress); - config.setGateway(unparcelAddress(p.gateway)); - for (InetAddress addr : fromParcelableArray( - p.dnsServers, IpConfigurationParcelableUtil::unparcelAddress)) { - config.addDnsServer(addr); - } - config.setDomains(p.domains); - return config; - } - - /** * Convert DhcpResults to a DhcpResultsParcelable. */ public static DhcpResultsParcelable toStableParcelable(@Nullable DhcpResults results) { if (results == null) return null; final DhcpResultsParcelable p = new DhcpResultsParcelable(); - p.baseConfiguration = toStableParcelable(results.toStaticIpConfiguration()); + p.baseConfiguration = results.toStaticIpConfiguration(); p.leaseDuration = results.leaseDuration; p.mtu = results.mtu; p.serverAddress = parcelAddress(results.serverAddress); @@ -88,7 +49,7 @@ public final class IpConfigurationParcelableUtil { */ public static DhcpResults fromStableParcelable(@Nullable DhcpResultsParcelable p) { if (p == null) return null; - final DhcpResults results = new DhcpResults(fromStableParcelable(p.baseConfiguration)); + final DhcpResults results = new DhcpResults(p.baseConfiguration); results.leaseDuration = p.leaseDuration; results.mtu = p.mtu; results.serverAddress = (Inet4Address) unparcelAddress(p.serverAddress); @@ -97,27 +58,6 @@ public final class IpConfigurationParcelableUtil { } /** - * Convert ApfCapabilities to ApfCapabilitiesParcelable. - */ - public static ApfCapabilitiesParcelable toStableParcelable(@Nullable ApfCapabilities caps) { - if (caps == null) return null; - final ApfCapabilitiesParcelable p = new ApfCapabilitiesParcelable(); - p.apfVersionSupported = caps.apfVersionSupported; - p.maximumApfProgramSize = caps.maximumApfProgramSize; - p.apfPacketFormat = caps.apfPacketFormat; - return p; - } - - /** - * Convert ApfCapabilitiesParcelable toApfCapabilities. - */ - public static ApfCapabilities fromStableParcelable(@Nullable ApfCapabilitiesParcelable p) { - if (p == null) return null; - return new ApfCapabilities( - p.apfVersionSupported, p.maximumApfProgramSize, p.apfPacketFormat); - } - - /** * Convert InetAddress to String. * TODO: have an InetAddressParcelable */ diff --git a/services/net/java/android/net/shared/NetworkMonitorUtils.java b/services/net/java/android/net/shared/NetworkMonitorUtils.java index 3d2a2de45539..a17cb4647158 100644 --- a/services/net/java/android/net/shared/NetworkMonitorUtils.java +++ b/services/net/java/android/net/shared/NetworkMonitorUtils.java @@ -44,18 +44,14 @@ public class NetworkMonitorUtils { public static final String PERMISSION_ACCESS_NETWORK_CONDITIONS = "android.permission.ACCESS_NETWORK_CONDITIONS"; - // TODO: once the URL is a resource overlay, remove and have the resource define the default - private static final String DEFAULT_HTTP_URL = - "http://connectivitycheck.gstatic.com/generate_204"; - /** * Get the captive portal server HTTP URL that is configured on the device. */ - public static String getCaptivePortalServerHttpUrl(Context context) { + public static String getCaptivePortalServerHttpUrl(Context context, String defaultUrl) { final String settingUrl = Settings.Global.getString( context.getContentResolver(), Settings.Global.CAPTIVE_PORTAL_HTTP_URL); - return settingUrl != null ? settingUrl : DEFAULT_HTTP_URL; + return settingUrl != null ? settingUrl : defaultUrl; } /** diff --git a/services/net/java/android/net/shared/ProvisioningConfiguration.java b/services/net/java/android/net/shared/ProvisioningConfiguration.java index 0aceb2278660..6f9c2949d864 100644 --- a/services/net/java/android/net/shared/ProvisioningConfiguration.java +++ b/services/net/java/android/net/shared/ProvisioningConfiguration.java @@ -235,8 +235,10 @@ public class ProvisioningConfiguration { p.usingIpReachabilityMonitor = mUsingIpReachabilityMonitor; p.requestedPreDhcpActionMs = mRequestedPreDhcpActionMs; p.initialConfig = mInitialConfig == null ? null : mInitialConfig.toStableParcelable(); - p.staticIpConfig = IpConfigurationParcelableUtil.toStableParcelable(mStaticIpConfig); - p.apfCapabilities = IpConfigurationParcelableUtil.toStableParcelable(mApfCapabilities); + p.staticIpConfig = mStaticIpConfig == null + ? null + : new StaticIpConfiguration(mStaticIpConfig); + p.apfCapabilities = mApfCapabilities; // ApfCapabilities is immutable p.provisioningTimeoutMs = mProvisioningTimeoutMs; p.ipv6AddrGenMode = mIPv6AddrGenMode; p.network = mNetwork; @@ -257,10 +259,10 @@ public class ProvisioningConfiguration { config.mUsingIpReachabilityMonitor = p.usingIpReachabilityMonitor; config.mRequestedPreDhcpActionMs = p.requestedPreDhcpActionMs; config.mInitialConfig = InitialConfiguration.fromStableParcelable(p.initialConfig); - config.mStaticIpConfig = IpConfigurationParcelableUtil.fromStableParcelable( - p.staticIpConfig); - config.mApfCapabilities = IpConfigurationParcelableUtil.fromStableParcelable( - p.apfCapabilities); + config.mStaticIpConfig = p.staticIpConfig == null + ? null + : new StaticIpConfiguration(p.staticIpConfig); + config.mApfCapabilities = p.apfCapabilities; // ApfCapabilities is immutable config.mProvisioningTimeoutMs = p.provisioningTimeoutMs; config.mIPv6AddrGenMode = p.ipv6AddrGenMode; config.mNetwork = p.network; diff --git a/services/tests/servicestests/src/com/android/server/am/ActivityLaunchParamsModifierTests.java b/services/tests/servicestests/src/com/android/server/am/ActivityLaunchParamsModifierTests.java index d75a3fc8d20b..01644737f55f 100644 --- a/services/tests/servicestests/src/com/android/server/am/ActivityLaunchParamsModifierTests.java +++ b/services/tests/servicestests/src/com/android/server/am/ActivityLaunchParamsModifierTests.java @@ -43,8 +43,11 @@ import org.junit.runner.RunWith; /** * Tests for exercising resizing bounds due to activity options. * - * Build/Install/Run: + * <p>Build/Install/Run: * atest FrameworksServicesTests:ActivityLaunchParamsModifierTests + * + * <p>This test class is a part of Window Manager Service tests and specified in + * {@link com.android.server.wm.test.filters.FrameworksTestsFilter}. */ @MediumTest @Presubmit diff --git a/services/tests/servicestests/src/com/android/server/am/ActivityRecordTests.java b/services/tests/servicestests/src/com/android/server/am/ActivityRecordTests.java index 5ee7477b486c..af0aaf31cd59 100644 --- a/services/tests/servicestests/src/com/android/server/am/ActivityRecordTests.java +++ b/services/tests/servicestests/src/com/android/server/am/ActivityRecordTests.java @@ -30,16 +30,15 @@ import static com.android.server.policy.WindowManagerPolicy.NAV_BAR_BOTTOM; import static com.android.server.policy.WindowManagerPolicy.NAV_BAR_LEFT; import static com.android.server.policy.WindowManagerPolicy.NAV_BAR_RIGHT; -import static junit.framework.TestCase.assertNotNull; - import static org.junit.Assert.assertEquals; import static org.junit.Assert.assertFalse; +import static org.junit.Assert.assertNotNull; import static org.junit.Assert.assertNull; import static org.junit.Assert.assertTrue; -import static org.mockito.Mockito.any; -import static org.mockito.Mockito.anyInt; +import static org.mockito.ArgumentMatchers.any; +import static org.mockito.ArgumentMatchers.anyInt; +import static org.mockito.ArgumentMatchers.eq; import static org.mockito.Mockito.doAnswer; -import static org.mockito.Mockito.eq; import static org.mockito.Mockito.times; import static org.mockito.Mockito.verify; import static org.mockito.Mockito.when; @@ -62,8 +61,11 @@ import org.mockito.invocation.InvocationOnMock; /** * Tests for the {@link ActivityRecord} class. * - * Build/Install/Run: + * <p>Build/Install/Run: * atest FrameworksServicesTests:com.android.server.am.ActivityRecordTests + * + * <p>This test class is a part of Window Manager Service tests and specified in + * {@link com.android.server.wm.test.filters.FrameworksTestsFilter}. */ @MediumTest @Presubmit diff --git a/services/tests/servicestests/src/com/android/server/am/ActivityStackSupervisorTests.java b/services/tests/servicestests/src/com/android/server/am/ActivityStackSupervisorTests.java index f36c57973240..b0f949132c3e 100644 --- a/services/tests/servicestests/src/com/android/server/am/ActivityStackSupervisorTests.java +++ b/services/tests/servicestests/src/com/android/server/am/ActivityStackSupervisorTests.java @@ -27,15 +27,14 @@ import static android.content.pm.ActivityInfo.FLAG_ALWAYS_FOCUSABLE; import static android.content.pm.ActivityInfo.FLAG_SHOW_WHEN_LOCKED; import static com.android.server.am.ActivityStack.REMOVE_TASK_MODE_DESTROYING; -import static com.android.server.am.ActivityStackSupervisor - .MATCH_TASK_IN_STACKS_OR_RECENT_TASKS_AND_RESTORE; +import static com.android.server.am.ActivityStackSupervisor.MATCH_TASK_IN_STACKS_OR_RECENT_TASKS_AND_RESTORE; import static org.junit.Assert.assertEquals; import static org.junit.Assert.assertFalse; import static org.junit.Assert.assertNull; import static org.junit.Assert.assertTrue; import static org.mockito.ArgumentMatchers.any; -import static org.mockito.Matchers.anyInt; +import static org.mockito.ArgumentMatchers.anyInt; import static org.mockito.Mockito.doAnswer; import static org.mockito.Mockito.doReturn; import static org.mockito.Mockito.mock; @@ -62,8 +61,11 @@ import java.util.ArrayList; /** * Tests for the {@link ActivityStackSupervisor} class. * - * Build/Install/Run: + * <p>Build/Install/Run: * atest FrameworksServicesTests:com.android.server.am.ActivityStackSupervisorTests + * + * <p>This test class is a part of Window Manager Service tests and specified in + * {@link com.android.server.wm.test.filters.FrameworksTestsFilter}. */ @MediumTest @Presubmit diff --git a/services/tests/servicestests/src/com/android/server/am/ActivityStackTests.java b/services/tests/servicestests/src/com/android/server/am/ActivityStackTests.java index be0c689ab89f..d89bc976e73f 100644 --- a/services/tests/servicestests/src/com/android/server/am/ActivityStackTests.java +++ b/services/tests/servicestests/src/com/android/server/am/ActivityStackTests.java @@ -33,7 +33,7 @@ import static org.junit.Assert.assertFalse; import static org.junit.Assert.assertNotNull; import static org.junit.Assert.assertNull; import static org.junit.Assert.assertTrue; -import static org.mockito.Mockito.anyInt; +import static org.mockito.ArgumentMatchers.anyInt; import static org.mockito.Mockito.doReturn; import static org.mockito.Mockito.mock; @@ -51,8 +51,11 @@ import org.junit.runner.RunWith; /** * Tests for the {@link ActivityStack} class. * - * Build/Install/Run: + * <p>Build/Install/Run: * atest FrameworksServicesTests:com.android.server.am.ActivityStackTests + * + * <p>This test class is a part of Window Manager Service tests and specified in + * {@link com.android.server.wm.test.filters.FrameworksTestsFilter}. */ @SmallTest @Presubmit diff --git a/services/tests/servicestests/src/com/android/server/am/ActivityStartControllerTests.java b/services/tests/servicestests/src/com/android/server/am/ActivityStartControllerTests.java index 3464ac2a3044..e84e354dbb8f 100644 --- a/services/tests/servicestests/src/com/android/server/am/ActivityStartControllerTests.java +++ b/services/tests/servicestests/src/com/android/server/am/ActivityStartControllerTests.java @@ -19,8 +19,8 @@ package com.android.server.am; import static android.app.WindowConfiguration.ACTIVITY_TYPE_STANDARD; import static android.app.WindowConfiguration.WINDOWING_MODE_FULLSCREEN; +import static org.mockito.ArgumentMatchers.eq; import static org.mockito.Mockito.doReturn; -import static org.mockito.Mockito.eq; import static org.mockito.Mockito.mock; import static org.mockito.Mockito.spy; import static org.mockito.Mockito.times; @@ -43,8 +43,11 @@ import java.util.Random; /** * Tests for the {@link ActivityStartController} class. * - * Build/Install/Run: + * <p>Build/Install/Run: * atest FrameworksServicesTests:ActivityStartControllerTests + * + * <p>This test class is a part of Window Manager Service tests and specified in + * {@link com.android.server.wm.test.filters.FrameworksTestsFilter}. */ @SmallTest @Presubmit diff --git a/services/tests/servicestests/src/com/android/server/am/ActivityStartInterceptorTest.java b/services/tests/servicestests/src/com/android/server/am/ActivityStartInterceptorTest.java index d1550d736e0b..1c83ded3cb9e 100644 --- a/services/tests/servicestests/src/com/android/server/am/ActivityStartInterceptorTest.java +++ b/services/tests/servicestests/src/com/android/server/am/ActivityStartInterceptorTest.java @@ -55,8 +55,11 @@ import org.mockito.MockitoAnnotations; /** * Unit tests for {@link ActivityStartInterceptorTest}. * - * Build/Install/Run: - * bit FrameworksServicesTests:com.android.server.am.ActivityStartInterceptorTest + * <p>Build/Install/Run: + * atest FrameworksServicesTests:ActivityStartInterceptorTest + * + * <p>This test class is a part of Window Manager Service tests and specified in + * {@link com.android.server.wm.test.filters.FrameworksTestsFilter}. */ @SmallTest public class ActivityStartInterceptorTest { diff --git a/services/tests/servicestests/src/com/android/server/am/ActivityStarterTests.java b/services/tests/servicestests/src/com/android/server/am/ActivityStarterTests.java index f956a364315b..1e127a9863e6 100644 --- a/services/tests/servicestests/src/com/android/server/am/ActivityStarterTests.java +++ b/services/tests/servicestests/src/com/android/server/am/ActivityStarterTests.java @@ -39,14 +39,14 @@ import static com.android.server.am.ActivityManagerService.ANIMATE; import static org.junit.Assert.assertEquals; import static org.junit.Assert.assertTrue; -import static org.mockito.Mockito.any; -import static org.mockito.Mockito.anyBoolean; -import static org.mockito.Mockito.anyInt; -import static org.mockito.Mockito.anyObject; +import static org.mockito.ArgumentMatchers.any; +import static org.mockito.ArgumentMatchers.anyBoolean; +import static org.mockito.ArgumentMatchers.anyInt; +import static org.mockito.ArgumentMatchers.anyObject; +import static org.mockito.ArgumentMatchers.eq; import static org.mockito.Mockito.clearInvocations; import static org.mockito.Mockito.doAnswer; import static org.mockito.Mockito.doReturn; -import static org.mockito.Mockito.eq; import static org.mockito.Mockito.mock; import static org.mockito.Mockito.never; import static org.mockito.Mockito.spy; @@ -80,8 +80,11 @@ import org.junit.runner.RunWith; /** * Tests for the {@link ActivityStarter} class. * - * Build/Install/Run: + * <p>Build/Install/Run: * atest FrameworksServicesTests:ActivityStarterTests + * + * <p>This test class is a part of Window Manager Service tests and specified in + * {@link com.android.server.wm.test.filters.FrameworksTestsFilter}. */ @SmallTest @Presubmit diff --git a/services/tests/servicestests/src/com/android/server/am/AssistDataRequesterTest.java b/services/tests/servicestests/src/com/android/server/am/AssistDataRequesterTest.java index d985364a7cee..2e1155e0a905 100644 --- a/services/tests/servicestests/src/com/android/server/am/AssistDataRequesterTest.java +++ b/services/tests/servicestests/src/com/android/server/am/AssistDataRequesterTest.java @@ -64,7 +64,11 @@ import java.util.concurrent.TimeUnit; * Note: Currently, we only support fetching the screenshot for the current application, so the * screenshot checks are hardcoded accordingly. * - * runtest --path frameworks/base/services/tests/servicestests/src/com/android/server/am/AssistDataRequesterTest.java + * <p>Build/Install/Run: + * atest FrameworksServicesTests:AssistDataRequesterTest + * + * <p>This test class is a part of Window Manager Service tests and specified in + * {@link com.android.server.wm.test.filters.FrameworksTestsFilter}. */ @MediumTest @FlakyTest(bugId = 113616538) diff --git a/services/tests/servicestests/src/com/android/server/am/ClientLifecycleManagerTests.java b/services/tests/servicestests/src/com/android/server/am/ClientLifecycleManagerTests.java index b4ad183db386..f882b63acfce 100644 --- a/services/tests/servicestests/src/com/android/server/am/ClientLifecycleManagerTests.java +++ b/services/tests/servicestests/src/com/android/server/am/ClientLifecycleManagerTests.java @@ -16,6 +16,15 @@ import androidx.test.runner.AndroidJUnit4; import org.junit.Test; import org.junit.runner.RunWith; +/** + * Tests for {@link ClientLifecycleManager}. + * + * <p>Build/Install/Run: + * atest FrameworksServicesTests:ClientLifecycleManagerTests + * + * <p>This test class is a part of Window Manager Service tests and specified in + * {@link com.android.server.wm.test.filters.FrameworksTestsFilter}. + */ @RunWith(AndroidJUnit4.class) @SmallTest @Presubmit diff --git a/services/tests/servicestests/src/com/android/server/am/LaunchParamsControllerTests.java b/services/tests/servicestests/src/com/android/server/am/LaunchParamsControllerTests.java index 8d675dd3032d..d24991ebc539 100644 --- a/services/tests/servicestests/src/com/android/server/am/LaunchParamsControllerTests.java +++ b/services/tests/servicestests/src/com/android/server/am/LaunchParamsControllerTests.java @@ -24,10 +24,10 @@ import static com.android.server.am.LaunchParamsController.LaunchParamsModifier. import static org.junit.Assert.assertEquals; import static org.junit.Assert.assertNotEquals; -import static org.mockito.Mockito.any; -import static org.mockito.Mockito.anyInt; +import static org.mockito.ArgumentMatchers.any; +import static org.mockito.ArgumentMatchers.anyInt; +import static org.mockito.ArgumentMatchers.eq; import static org.mockito.Mockito.doNothing; -import static org.mockito.Mockito.eq; import static org.mockito.Mockito.mock; import static org.mockito.Mockito.never; import static org.mockito.Mockito.spy; @@ -51,8 +51,11 @@ import org.junit.runner.RunWith; /** * Tests for exercising {@link LaunchParamsController}. * - * Build/Install/Run: + * <p>Build/Install/Run: * atest FrameworksServicesTests:LaunchParamsControllerTests + * + * <p>This test class is a part of Window Manager Service tests and specified in + * {@link com.android.server.wm.test.filters.FrameworksTestsFilter}. */ @MediumTest @Presubmit diff --git a/services/tests/servicestests/src/com/android/server/am/PendingRemoteAnimationRegistryTest.java b/services/tests/servicestests/src/com/android/server/am/PendingRemoteAnimationRegistryTest.java index f5f507f8b210..b52ce1702488 100644 --- a/services/tests/servicestests/src/com/android/server/am/PendingRemoteAnimationRegistryTest.java +++ b/services/tests/servicestests/src/com/android/server/am/PendingRemoteAnimationRegistryTest.java @@ -38,7 +38,13 @@ import org.mockito.Mock; import org.mockito.MockitoAnnotations; /** - * atest PendingRemoteAnimationRegistryTest + * Tests for {@link PendingRemoteAnimationRegistry}. + * + * <p>Build/Install/Run: + * atest PendingRemoteAnimationRegistryTest + * + * <p>This test class is a part of Window Manager Service tests and specified in + * {@link com.android.server.wm.test.filters.FrameworksTestsFilter}. */ @SmallTest @Presubmit diff --git a/services/tests/servicestests/src/com/android/server/am/RecentTasksTest.java b/services/tests/servicestests/src/com/android/server/am/RecentTasksTest.java index aa9123b16aa7..c61054099282 100644 --- a/services/tests/servicestests/src/com/android/server/am/RecentTasksTest.java +++ b/services/tests/servicestests/src/com/android/server/am/RecentTasksTest.java @@ -76,7 +76,13 @@ import java.util.Random; import java.util.Set; /** - * atest FrameworksServicesTests:RecentTasksTest + * Tests for {@link RecentTasks}. + * + * <p>Build/Install/Run: + * atest FrameworksServicesTests:RecentTasksTest + * + * <p>This test class is a part of Window Manager Service tests and specified in + * {@link com.android.server.wm.test.filters.FrameworksTestsFilter}. */ @MediumTest @Presubmit diff --git a/services/tests/servicestests/src/com/android/server/am/RecentsAnimationTest.java b/services/tests/servicestests/src/com/android/server/am/RecentsAnimationTest.java index fa6a95ce275c..edc623589f4b 100644 --- a/services/tests/servicestests/src/com/android/server/am/RecentsAnimationTest.java +++ b/services/tests/servicestests/src/com/android/server/am/RecentsAnimationTest.java @@ -22,9 +22,9 @@ import static android.app.WindowConfiguration.WINDOWING_MODE_FULLSCREEN; import static com.android.server.wm.RecentsAnimationController.REORDER_KEEP_IN_PLACE; -import static org.mockito.Mockito.any; +import static org.mockito.ArgumentMatchers.any; +import static org.mockito.ArgumentMatchers.eq; import static org.mockito.Mockito.doReturn; -import static org.mockito.Mockito.eq; import static org.mockito.Mockito.mock; import static org.mockito.Mockito.times; import static org.mockito.Mockito.verify; @@ -46,7 +46,13 @@ import org.junit.Test; import org.junit.runner.RunWith; /** - * atest FrameworksServicesTests:RecentsAnimationTest + * Tests for recent tasks animation. + * + * <p>Build/Install/Run: + * atest FrameworksServicesTests:RecentsAnimationTest + * + * <p>This test class is a part of Window Manager Service tests and specified in + * {@link com.android.server.wm.test.filters.FrameworksTestsFilter}. */ @MediumTest @Presubmit diff --git a/services/tests/servicestests/src/com/android/server/am/RunningTasksTest.java b/services/tests/servicestests/src/com/android/server/am/RunningTasksTest.java index 19288a9c28d7..c38a594c1038 100644 --- a/services/tests/servicestests/src/com/android/server/am/RunningTasksTest.java +++ b/services/tests/servicestests/src/com/android/server/am/RunningTasksTest.java @@ -43,7 +43,13 @@ import org.junit.runner.RunWith; import java.util.ArrayList; /** - * runtest --path frameworks/base/services/tests/servicestests/src/com/android/server/am/RunningTasksTest.java + * Tests for {@link RunningTasks}. + * + * <p>Build/Install/Run: + * atest FrameworksServicesTests:RunningTasksTest + * + * <p>This test class is a part of Window Manager Service tests and specified in + * {@link com.android.server.wm.test.filters.FrameworksTestsFilter}. */ @MediumTest @Presubmit @@ -124,4 +130,4 @@ public class RunningTasksTest extends ActivityTestsBase { .build(); return task; } -}
\ No newline at end of file +} diff --git a/services/tests/servicestests/src/com/android/server/am/SafeActivityOptionsTest.java b/services/tests/servicestests/src/com/android/server/am/SafeActivityOptionsTest.java index 8e4e7e6b63c3..03d17375298f 100644 --- a/services/tests/servicestests/src/com/android/server/am/SafeActivityOptionsTest.java +++ b/services/tests/servicestests/src/com/android/server/am/SafeActivityOptionsTest.java @@ -28,6 +28,15 @@ import androidx.test.runner.AndroidJUnit4; import org.junit.Test; import org.junit.runner.RunWith; +/** + * Tests for {@link SafeActivityOptions}. + * + * <p>Build/Install/Run: + * atest FrameworksServicesTests:SafeActivityOptionsTest + * + * <p>This test class is a part of Window Manager Service tests and specified in + * {@link com.android.server.wm.test.filters.FrameworksTestsFilter}. + */ @MediumTest @Presubmit @FlakyTest diff --git a/services/tests/servicestests/src/com/android/server/am/TaskLaunchParamsModifierTests.java b/services/tests/servicestests/src/com/android/server/am/TaskLaunchParamsModifierTests.java index eec55b162b3e..fc9db14d5834 100644 --- a/services/tests/servicestests/src/com/android/server/am/TaskLaunchParamsModifierTests.java +++ b/services/tests/servicestests/src/com/android/server/am/TaskLaunchParamsModifierTests.java @@ -38,8 +38,11 @@ import org.junit.runner.RunWith; /** * Tests for exercising resizing task bounds. * - * Build/Install/Run: + * <p>Build/Install/Run: * atest FrameworksServicesTests:TaskLaunchParamsModifierTests + * + * <p>This test class is a part of Window Manager Service tests and specified in + * {@link com.android.server.wm.test.filters.FrameworksTestsFilter}. */ @MediumTest @Presubmit diff --git a/services/tests/servicestests/src/com/android/server/am/TaskPersisterTest.java b/services/tests/servicestests/src/com/android/server/am/TaskPersisterTest.java index 9e6055d55e0f..976e8355128e 100644 --- a/services/tests/servicestests/src/com/android/server/am/TaskPersisterTest.java +++ b/services/tests/servicestests/src/com/android/server/am/TaskPersisterTest.java @@ -30,7 +30,13 @@ import java.io.File; import java.util.Random; /** - * atest FrameworksServicesTests:TaskPersisterTest + * Tests for {@link TaskPersister}. + * + * <p>Build/Install/Run: + * atest FrameworksServicesTests:TaskPersisterTest + * + * <p>This test class is a part of Window Manager Service tests and specified in + * {@link com.android.server.wm.test.filters.FrameworksTestsFilter}. */ public class TaskPersisterTest extends AndroidTestCase { private static final String TEST_USER_NAME = "AM-Test-User"; @@ -85,4 +91,4 @@ public class TaskPersisterTest extends AndroidTestCase { fail("Error while removing the test user: " + TEST_USER_NAME); } } -}
\ No newline at end of file +} diff --git a/services/tests/servicestests/src/com/android/server/am/TaskRecordTests.java b/services/tests/servicestests/src/com/android/server/am/TaskRecordTests.java index 5aecec005fdb..eada2ce4f004 100644 --- a/services/tests/servicestests/src/com/android/server/am/TaskRecordTests.java +++ b/services/tests/servicestests/src/com/android/server/am/TaskRecordTests.java @@ -59,8 +59,11 @@ import java.util.ArrayList; /** * Tests for exercising {@link TaskRecord}. * - * Build/Install/Run: + * <p>Build/Install/Run: * atest FrameworksServicesTests:com.android.server.am.TaskRecordTests + * + * <p>This test class is a part of Window Manager Service tests and specified in + * {@link com.android.server.wm.test.filters.FrameworksTestsFilter}. */ @MediumTest @Presubmit diff --git a/services/tests/servicestests/src/com/android/server/am/TaskStackChangedListenerTest.java b/services/tests/servicestests/src/com/android/server/am/TaskStackChangedListenerTest.java index 9406160b52ca..814071445df8 100644 --- a/services/tests/servicestests/src/com/android/server/am/TaskStackChangedListenerTest.java +++ b/services/tests/servicestests/src/com/android/server/am/TaskStackChangedListenerTest.java @@ -52,6 +52,15 @@ import org.junit.runner.RunWith; import java.util.concurrent.CountDownLatch; import java.util.concurrent.TimeUnit; +/** + * Tests for {@link TaskStackListener}. + * + * <p>Build/Install/Run: + * atest FrameworksServicesTests:TaskStackChangedListenerTest + * + * <p>This test class is a part of Window Manager Service tests and specified in + * {@link com.android.server.wm.test.filters.FrameworksTestsFilter}. + */ @MediumTest @RunWith(AndroidJUnit4.class) public class TaskStackChangedListenerTest { diff --git a/services/usb/java/com/android/server/usb/UsbDeviceManager.java b/services/usb/java/com/android/server/usb/UsbDeviceManager.java index da682c6df621..e949e7490230 100644 --- a/services/usb/java/com/android/server/usb/UsbDeviceManager.java +++ b/services/usb/java/com/android/server/usb/UsbDeviceManager.java @@ -855,7 +855,7 @@ public class UsbDeviceManager implements ActivityManagerInternal.ScreenObserver && status.isRoleCombinationSupported(UsbPort.POWER_ROLE_SOURCE, UsbPort.DATA_ROLE_DEVICE) && status.isRoleCombinationSupported(UsbPort.POWER_ROLE_SINK, - UsbPort.DATA_ROLE_HOST); + UsbPort.DATA_ROLE_DEVICE); args.recycle(); updateUsbNotification(false); diff --git a/startop/view_compiler/Android.bp b/startop/view_compiler/Android.bp index f5b4308a1b50..92ea872f04fc 100644 --- a/startop/view_compiler/Android.bp +++ b/startop/view_compiler/Android.bp @@ -22,7 +22,6 @@ cc_defaults { ], shared_libs: [ "libbase", - "libz", "slicer", ], static_libs: [ diff --git a/telecomm/java/android/telecom/Log.java b/telecomm/java/android/telecom/Log.java index 16791a4b8680..7d4ee7686512 100644 --- a/telecomm/java/android/telecom/Log.java +++ b/telecomm/java/android/telecom/Log.java @@ -16,6 +16,7 @@ package android.telecom; +import android.annotation.UnsupportedAppUsage; import android.content.Context; import android.net.Uri; import android.os.Build; @@ -97,6 +98,7 @@ public class Log { } } + @UnsupportedAppUsage public static void i(String prefix, String format, Object... args) { if (INFO) { android.util.Slog.i(TAG, buildMessage(prefix, format, args)); @@ -127,6 +129,7 @@ public class Log { } } + @UnsupportedAppUsage public static void w(String prefix, String format, Object... args) { if (WARN) { android.util.Slog.w(TAG, buildMessage(prefix, format, args)); diff --git a/telecomm/java/android/telecom/TelecomManager.java b/telecomm/java/android/telecom/TelecomManager.java index 558d8d495d5c..06c85d27d880 100644 --- a/telecomm/java/android/telecom/TelecomManager.java +++ b/telecomm/java/android/telecom/TelecomManager.java @@ -33,7 +33,6 @@ import android.os.Build; import android.os.Bundle; import android.os.RemoteException; import android.os.ServiceManager; -import android.os.UserHandle; import android.telephony.TelephonyManager; import android.text.TextUtils; import android.util.Log; @@ -45,7 +44,6 @@ import java.lang.annotation.RetentionPolicy; import java.util.ArrayList; import java.util.Collections; import java.util.List; -import java.util.concurrent.Executor; /** * Provides access to information about active calls and registration/call-management functionality. @@ -477,6 +475,12 @@ public class TelecomManager { "android.telecom.extra.START_CALL_WITH_RTT"; /** + * A boolean extra set to indicate whether an app is eligible to be bound to when there are + * ongoing calls on the device. + */ + public static final String EXTRA_IS_ENABLED = "android.telecom.extra.IS_ENABLED"; + + /** * A boolean meta-data value indicating whether an {@link InCallService} implements an * in-call user interface. Dialer implementations (see {@link #getDefaultDialerPackage()}) which * would also like to replace the in-call interface should set this meta-data to {@code true} in @@ -487,9 +491,7 @@ public class TelecomManager { /** * A boolean meta-data value indicating whether an {@link InCallService} implements an * in-call user interface to be used while the device is in car-mode (see - * {@link android.content.res.Configuration.UI_MODE_TYPE_CAR}). - * - * @hide + * {@link android.content.res.Configuration#UI_MODE_TYPE_CAR}). */ public static final String METADATA_IN_CALL_SERVICE_CAR_MODE_UI = "android.telecom.IN_CALL_SERVICE_CAR_MODE_UI"; @@ -2041,7 +2043,6 @@ public class TelecomManager { } catch (RemoteException e) { Log.e(TAG, "RemoteException handleCallIntent: " + e); } - } private ITelecomService getTelecomService() { diff --git a/telephony/java/android/telephony/AccessNetworkConstants.java b/telephony/java/android/telephony/AccessNetworkConstants.java index 81553a3bc0f8..afa35b4d4de3 100644 --- a/telephony/java/android/telephony/AccessNetworkConstants.java +++ b/telephony/java/android/telephony/AccessNetworkConstants.java @@ -18,6 +18,7 @@ package android.telephony; import android.annotation.IntDef; import android.annotation.SystemApi; +import android.annotation.TestApi; import java.lang.annotation.Retention; import java.lang.annotation.RetentionPolicy; @@ -51,6 +52,7 @@ public final class AccessNetworkConstants { * @hide */ @SystemApi + @TestApi public static final int TRANSPORT_TYPE_WWAN = 1; /** @@ -58,6 +60,7 @@ public final class AccessNetworkConstants { * @hide */ @SystemApi + @TestApi public static final int TRANSPORT_TYPE_WLAN = 2; /** @hide */ diff --git a/telephony/java/android/telephony/CarrierConfigManager.java b/telephony/java/android/telephony/CarrierConfigManager.java index 3454c1cbc14c..47bf48f09b25 100755 --- a/telephony/java/android/telephony/CarrierConfigManager.java +++ b/telephony/java/android/telephony/CarrierConfigManager.java @@ -1535,6 +1535,21 @@ public class CarrierConfigManager { "allow_non_emergency_calls_in_ecm_bool"; /** + * Time that the telephony framework stays in "emergency SMS mode" after an emergency SMS is + * sent to the network. This is used by carriers to configure the time + * {@link TelephonyManager#isInEmergencySmsMode()} will be true after an emergency SMS is sent. + * This is used by GNSS to override user location permissions so that the carrier network can + * get the user's location for emergency services. + * + * The default is 0, which means that this feature is disabled. The maximum value for this timer + * is 300000 mS (5 minutes). + * + * @hide + */ + public static final String KEY_EMERGENCY_SMS_MODE_TIMER_MS_INT = + "emergency_sms_mode_timer_ms_int"; + + /** * Flag indicating whether to allow carrier video calls to emergency numbers. * When {@code true}, video calls to emergency numbers will be allowed. When {@code false}, * video calls to emergency numbers will be initiated as audio-only calls instead. @@ -1829,6 +1844,14 @@ public class CarrierConfigManager { "editable_wfc_roaming_mode_bool"; /** + * Flag specifying wether to show blocking pay phone option in blocked numbers screen. Only show + * the option if payphone call presentation represents in the carrier's region. + * @hide + */ + public static final java.lang.String KEY_SHOW_BLOCKING_PAY_PHONE_OPTION_BOOL = + "show_blocking_pay_phone_option_bool"; + + /** * Flag specifying whether the carrier will use the WFC home network mode in roaming network. * {@code false} - roaming preference can be selected separately from the home preference. * {@code true} - roaming preference is the same as home preference and @@ -2454,6 +2477,18 @@ public class CarrierConfigManager { */ public static final String KEY_OPPORTUNISTIC_NETWORK_DATA_SWITCH_HYSTERESIS_TIME_LONG = "opportunistic_network_data_switch_hysteresis_time_long"; + + /** + * Indicates zero or more emergency number prefix(es), because some carrier requires + * if users dial an emergency number address with a specific prefix, the combination of the + * prefix and the address is also a valid emergency number to dial. For example, an emergency + * number prefix is 318, and the emergency number is 911. Both 318911 and 911 can be dialed by + * users for emergency call. An empty array of string indicates that current carrier does not + * have this requirement. + */ + public static final String KEY_EMERGENCY_NUMBER_PREFIX_STRING_ARRAY = + "emergency_number_prefix_string_array"; + /** * Determines whether the carrier wants to cancel the cs reject notification automatically * when the voice registration state changes. @@ -2733,6 +2768,7 @@ public class CarrierConfigManager { sDefaults.putString(KEY_MMS_UA_PROF_URL_STRING, ""); sDefaults.putString(KEY_MMS_USER_AGENT_STRING, ""); sDefaults.putBoolean(KEY_ALLOW_NON_EMERGENCY_CALLS_IN_ECM_BOOL, true); + sDefaults.putInt(KEY_EMERGENCY_SMS_MODE_TIMER_MS_INT, 0); sDefaults.putBoolean(KEY_USE_RCS_PRESENCE_BOOL, false); sDefaults.putBoolean(KEY_FORCE_IMEI_BOOL, false); sDefaults.putInt( @@ -2798,6 +2834,7 @@ public class CarrierConfigManager { sDefaults.putBoolean(KEY_NOTIFY_VT_HANDOVER_TO_WIFI_FAILURE_BOOL, false); sDefaults.putStringArray(KEY_FILTERED_CNAP_NAMES_STRING_ARRAY, null); sDefaults.putBoolean(KEY_EDITABLE_WFC_ROAMING_MODE_BOOL, false); + sDefaults.putBoolean(KEY_SHOW_BLOCKING_PAY_PHONE_OPTION_BOOL, false); sDefaults.putBoolean(KEY_USE_WFC_HOME_NETWORK_MODE_IN_ROAMING_NETWORK_BOOL, false); sDefaults.putBoolean(KEY_STK_DISABLE_LAUNCH_BROWSER_BOOL, false); sDefaults.putBoolean(KEY_PERSIST_LPP_MODE_BOOL, true); @@ -2884,6 +2921,7 @@ public class CarrierConfigManager { new int[] { 1 /* Roaming Indicator Off */ }); + sDefaults.putStringArray(KEY_EMERGENCY_NUMBER_PREFIX_STRING_ARRAY, new String[0]); sDefaults.putString(KEY_5G_ICON_CONFIGURATION_STRING, "connected_mmwave:None,connected:5G,not_restricted:None,restricted:None"); sDefaults.putBoolean(KEY_AUTO_CANCEL_CS_REJECT_NOTIFICATION, false); diff --git a/telephony/java/android/telephony/CellIdentityNr.java b/telephony/java/android/telephony/CellIdentityNr.java index b94ca9b3f927..771e7b9a8076 100644 --- a/telephony/java/android/telephony/CellIdentityNr.java +++ b/telephony/java/android/telephony/CellIdentityNr.java @@ -16,13 +16,15 @@ package android.telephony; +import android.annotation.IntRange; +import android.annotation.Nullable; import android.os.Parcel; import android.telephony.gsm.GsmCellLocation; import java.util.Objects; /** - * Information to represent a unique 5G NR cell. + * Information to represent a unique NR(New Radio 5G) cell. */ public final class CellIdentityNr extends CellIdentity { private static final String TAG = "CellIdentityNr"; @@ -79,7 +81,7 @@ public final class CellIdentityNr extends CellIdentity { } /** - * Get the NR Cell Identity. + * Get the NR(New Radio 5G) Cell Identity. * * @return The 36-bit NR Cell Identity in range [0, 68719476735] or * {@link CellInfo#UNAVAILABLE_LONG} if unknown. @@ -96,6 +98,7 @@ public final class CellIdentityNr extends CellIdentity { * * @return Integer value in range [0, 3279165] or {@link CellInfo#UNAVAILABLE} if unknown. */ + @IntRange(from = 0, to = 3279165) public int getNrarfcn() { return mNrArfcn; } @@ -104,6 +107,7 @@ public final class CellIdentityNr extends CellIdentity { * Get the physical cell id. * @return Integer value in range [0, 1007] or {@link CellInfo#UNAVAILABLE} if unknown. */ + @IntRange(from = 0, to = 1007) public int getPci() { return mPci; } @@ -112,6 +116,7 @@ public final class CellIdentityNr extends CellIdentity { * Get the tracking area code. * @return a 16 bit integer or {@link CellInfo#UNAVAILABLE} if unknown. */ + @IntRange(from = 0, to = 65535) public int getTac() { return mTac; } @@ -119,6 +124,7 @@ public final class CellIdentityNr extends CellIdentity { /** * @return Mobile Country Code in string format, or {@code null} if unknown. */ + @Nullable public String getMccString() { return mMccStr; } @@ -126,6 +132,7 @@ public final class CellIdentityNr extends CellIdentity { /** * @return Mobile Network Code in string fomrat, or {@code null} if unknown. */ + @Nullable public String getMncString() { return mMncStr; } diff --git a/telephony/java/android/telephony/CellIdentityTdscdma.java b/telephony/java/android/telephony/CellIdentityTdscdma.java index dba437a3a007..19b11b666018 100644 --- a/telephony/java/android/telephony/CellIdentityTdscdma.java +++ b/telephony/java/android/telephony/CellIdentityTdscdma.java @@ -16,6 +16,7 @@ package android.telephony; +import android.annotation.NonNull; import android.annotation.Nullable; import android.os.Parcel; import android.telephony.gsm.GsmCellLocation; @@ -205,6 +206,12 @@ public final class CellIdentityTdscdma extends CellIdentity { /** Implement the Parcelable interface */ @Override + public int describeContents() { + return 0; + } + + /** Implement the Parcelable interface */ + @Override public void writeToParcel(Parcel dest, int flags) { if (DBG) log("writeToParcel(Parcel, int): " + toString()); super.writeToParcel(dest, CellInfo.TYPE_TDSCDMA); @@ -226,16 +233,17 @@ public final class CellIdentityTdscdma extends CellIdentity { /** Implement the Parcelable interface */ @SuppressWarnings("hiding") + @NonNull public static final Creator<CellIdentityTdscdma> CREATOR = new Creator<CellIdentityTdscdma>() { @Override - public CellIdentityTdscdma createFromParcel(Parcel in) { + public @NonNull CellIdentityTdscdma createFromParcel(Parcel in) { in.readInt(); // skip return createFromParcelBody(in); } @Override - public CellIdentityTdscdma[] newArray(int size) { + public @NonNull CellIdentityTdscdma[] newArray(int size) { return new CellIdentityTdscdma[size]; } }; diff --git a/telephony/java/android/telephony/CellInfoNr.java b/telephony/java/android/telephony/CellInfoNr.java index 11857a60783d..7f7902c76095 100644 --- a/telephony/java/android/telephony/CellInfoNr.java +++ b/telephony/java/android/telephony/CellInfoNr.java @@ -16,6 +16,7 @@ package android.telephony; +import android.annotation.NonNull; import android.os.Parcel; import java.util.Objects; @@ -36,11 +37,13 @@ public final class CellInfoNr extends CellInfo { } @Override + @NonNull public CellIdentity getCellIdentity() { return mCellIdentity; } @Override + @NonNull public CellSignalStrength getCellSignalStrength() { return mCellSignalStrength; } diff --git a/telephony/java/android/telephony/CellInfoTdscdma.java b/telephony/java/android/telephony/CellInfoTdscdma.java index cb45e956a1cd..1830086ba448 100644 --- a/telephony/java/android/telephony/CellInfoTdscdma.java +++ b/telephony/java/android/telephony/CellInfoTdscdma.java @@ -16,6 +16,7 @@ package android.telephony; +import android.annotation.NonNull; import android.os.Parcel; import android.os.Parcelable; @@ -24,7 +25,9 @@ import java.util.Objects; /** * A {@link CellInfo} representing a TD-SCDMA cell that provides identity and measurement info. * - * @hide + * @see android.telephony.CellInfo + * @see android.telephony.CellSignalStrengthTdscdma + * @see android.telephony.CellIdentityTdscdma */ public final class CellInfoTdscdma extends CellInfo implements Parcelable { @@ -72,18 +75,21 @@ public final class CellInfoTdscdma extends CellInfo implements Parcelable { mCellSignalStrengthTdscdma = new CellSignalStrengthTdscdma(cit.signalStrengthTdscdma); } - @Override public CellIdentityTdscdma getCellIdentity() { + @Override + public @NonNull CellIdentityTdscdma getCellIdentity() { return mCellIdentityTdscdma; } + /** @hide */ public void setCellIdentity(CellIdentityTdscdma cid) { mCellIdentityTdscdma = cid; } @Override - public CellSignalStrengthTdscdma getCellSignalStrength() { + public @NonNull CellSignalStrengthTdscdma getCellSignalStrength() { return mCellSignalStrengthTdscdma; } + /** @hide */ public void setCellSignalStrength(CellSignalStrengthTdscdma css) { mCellSignalStrengthTdscdma = css; @@ -149,15 +155,16 @@ public final class CellInfoTdscdma extends CellInfo implements Parcelable { } /** Implement the Parcelable interface */ + @NonNull public static final Creator<CellInfoTdscdma> CREATOR = new Creator<CellInfoTdscdma>() { @Override - public CellInfoTdscdma createFromParcel(Parcel in) { + public @NonNull CellInfoTdscdma createFromParcel(Parcel in) { in.readInt(); // Skip past token, we know what it is return createFromParcelBody(in); } @Override - public CellInfoTdscdma[] newArray(int size) { + public @NonNull CellInfoTdscdma[] newArray(int size) { return new CellInfoTdscdma[size]; } }; diff --git a/telephony/java/android/telephony/CellSignalStrengthTdscdma.java b/telephony/java/android/telephony/CellSignalStrengthTdscdma.java index 5ae89b0f8b3d..ddbd851bbce5 100644 --- a/telephony/java/android/telephony/CellSignalStrengthTdscdma.java +++ b/telephony/java/android/telephony/CellSignalStrengthTdscdma.java @@ -16,6 +16,7 @@ package android.telephony; +import android.annotation.NonNull; import android.os.Parcel; import android.os.Parcelable; import android.os.PersistableBundle; @@ -25,7 +26,8 @@ import java.util.Objects; /** * Tdscdma signal strength related information. * - * @hide + * This class provides signal strength and signal quality information for the TD-SCDMA air + * interface. For more information see 3gpp 25.225. */ public final class CellSignalStrengthTdscdma extends CellSignalStrength implements Parcelable { @@ -59,7 +61,9 @@ public final class CellSignalStrengthTdscdma extends CellSignalStrength implemen * @param rssi in dBm [-113, -51] or UNAVAILABLE * @param ber [0-7], 99 or UNAVAILABLE * @param rscp in dBm [-120, -24] or UNAVAILABLE - * @hide */ + * + * @hide + */ public CellSignalStrengthTdscdma(int rssi, int ber, int rscp) { mRssi = inRangeOrUnavailable(rssi, -113, -51); mBitErrorRate = inRangeOrUnavailable(ber, 0, 7, 99); @@ -148,8 +152,7 @@ public final class CellSignalStrengthTdscdma extends CellSignalStrength implemen } /** - * Get the RSCP as dBm - * @hide + * Get the RSCP as dBm value -120..-24dBm or {@link CellInfo#UNAVAILABLE UNAVAILABLE}. */ public int getRscp() { return mRscp; @@ -160,7 +163,7 @@ public final class CellSignalStrengthTdscdma extends CellSignalStrength implemen * * Asu is calculated based on 3GPP RSRP. Refer to 3GPP 27.007 (Ver 10.3.0) Sec 8.69 * - * @return RSCP in ASU 0..96, 255, or UNAVAILABLE + * @return RSCP in ASU 0..96, 255, or {@link CellInfo#UNAVAILABLE UNAVAILABLE}. */ @Override public int getAsuLevel() { @@ -237,15 +240,16 @@ public final class CellSignalStrengthTdscdma extends CellSignalStrength implemen /** Implement the Parcelable interface */ @SuppressWarnings("hiding") + @NonNull public static final Parcelable.Creator<CellSignalStrengthTdscdma> CREATOR = new Parcelable.Creator<CellSignalStrengthTdscdma>() { @Override - public CellSignalStrengthTdscdma createFromParcel(Parcel in) { + public @NonNull CellSignalStrengthTdscdma createFromParcel(Parcel in) { return new CellSignalStrengthTdscdma(in); } @Override - public CellSignalStrengthTdscdma[] newArray(int size) { + public @NonNull CellSignalStrengthTdscdma[] newArray(int size) { return new CellSignalStrengthTdscdma[size]; } }; diff --git a/telephony/java/android/telephony/DataSpecificRegistrationStates.java b/telephony/java/android/telephony/DataSpecificRegistrationInfo.java index c3387f3f112d..fbf488e590fd 100644 --- a/telephony/java/android/telephony/DataSpecificRegistrationStates.java +++ b/telephony/java/android/telephony/DataSpecificRegistrationInfo.java @@ -1,7 +1,24 @@ +/* + * Copyright 2018 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 android.telephony; import android.annotation.NonNull; import android.annotation.SystemApi; +import android.annotation.TestApi; import android.os.Parcel; import android.os.Parcelable; @@ -13,7 +30,8 @@ import java.util.Objects; * @hide */ @SystemApi -public final class DataSpecificRegistrationStates implements Parcelable{ +@TestApi +public final class DataSpecificRegistrationInfo implements Parcelable { /** * @hide * The maximum number of simultaneous Data Calls that @@ -53,27 +71,27 @@ public final class DataSpecificRegistrationStates implements Parcelable{ /** * Provides network support info for LTE VoPS and LTE Emergency bearer support */ - private final LteVopsSupportInfo lteVopsSupportInfo; + private final LteVopsSupportInfo mLteVopsSupportInfo; /** * @hide */ - DataSpecificRegistrationStates( + DataSpecificRegistrationInfo( int maxDataCalls, boolean isDcNrRestricted, boolean isNrAvailable, boolean isEnDcAvailable, LteVopsSupportInfo lteVops) { this.maxDataCalls = maxDataCalls; this.isDcNrRestricted = isDcNrRestricted; this.isNrAvailable = isNrAvailable; this.isEnDcAvailable = isEnDcAvailable; - this.lteVopsSupportInfo = lteVops; + this.mLteVopsSupportInfo = lteVops; } - private DataSpecificRegistrationStates(Parcel source) { + private DataSpecificRegistrationInfo(Parcel source) { maxDataCalls = source.readInt(); isDcNrRestricted = source.readBoolean(); isNrAvailable = source.readBoolean(); isEnDcAvailable = source.readBoolean(); - lteVopsSupportInfo = LteVopsSupportInfo.CREATOR.createFromParcel(source); + mLteVopsSupportInfo = LteVopsSupportInfo.CREATOR.createFromParcel(source); } @Override @@ -82,7 +100,7 @@ public final class DataSpecificRegistrationStates implements Parcelable{ dest.writeBoolean(isDcNrRestricted); dest.writeBoolean(isNrAvailable); dest.writeBoolean(isEnDcAvailable); - lteVopsSupportInfo.writeToParcel(dest, flags); + mLteVopsSupportInfo.writeToParcel(dest, flags); } @Override @@ -98,7 +116,7 @@ public final class DataSpecificRegistrationStates implements Parcelable{ .append(" isDcNrRestricted = " + isDcNrRestricted) .append(" isNrAvailable = " + isNrAvailable) .append(" isEnDcAvailable = " + isEnDcAvailable) - .append(lteVopsSupportInfo.toString()) + .append(mLteVopsSupportInfo.toString()) .append(" }") .toString(); } @@ -106,41 +124,41 @@ public final class DataSpecificRegistrationStates implements Parcelable{ @Override public int hashCode() { return Objects.hash(maxDataCalls, isDcNrRestricted, isNrAvailable, isEnDcAvailable, - lteVopsSupportInfo); + mLteVopsSupportInfo); } @Override public boolean equals(Object o) { if (this == o) return true; - if (!(o instanceof DataSpecificRegistrationStates)) return false; + if (!(o instanceof DataSpecificRegistrationInfo)) return false; - DataSpecificRegistrationStates other = (DataSpecificRegistrationStates) o; + DataSpecificRegistrationInfo other = (DataSpecificRegistrationInfo) o; return this.maxDataCalls == other.maxDataCalls && this.isDcNrRestricted == other.isDcNrRestricted && this.isNrAvailable == other.isNrAvailable && this.isEnDcAvailable == other.isEnDcAvailable - && this.lteVopsSupportInfo.equals(other.lteVopsSupportInfo); + && this.mLteVopsSupportInfo.equals(other.mLteVopsSupportInfo); } - public static final Parcelable.Creator<DataSpecificRegistrationStates> CREATOR = - new Parcelable.Creator<DataSpecificRegistrationStates>() { + public static final @NonNull Parcelable.Creator<DataSpecificRegistrationInfo> CREATOR = + new Parcelable.Creator<DataSpecificRegistrationInfo>() { @Override - public DataSpecificRegistrationStates createFromParcel(Parcel source) { - return new DataSpecificRegistrationStates(source); + public DataSpecificRegistrationInfo createFromParcel(Parcel source) { + return new DataSpecificRegistrationInfo(source); } @Override - public DataSpecificRegistrationStates[] newArray(int size) { - return new DataSpecificRegistrationStates[size]; + public DataSpecificRegistrationInfo[] newArray(int size) { + return new DataSpecificRegistrationInfo[size]; } }; /** - * @return LteVopsSupportInfo + * @return The LTE VOPS (Voice over Packet Switched) support information */ @NonNull public LteVopsSupportInfo getLteVopsSupportInfo() { - return lteVopsSupportInfo; + return mLteVopsSupportInfo; } } diff --git a/telephony/java/android/telephony/INetworkService.aidl b/telephony/java/android/telephony/INetworkService.aidl index 9ef7186e8ae1..3a9c3a5bd45d 100644 --- a/telephony/java/android/telephony/INetworkService.aidl +++ b/telephony/java/android/telephony/INetworkService.aidl @@ -25,7 +25,7 @@ oneway interface INetworkService { void createNetworkServiceProvider(int slotId); void removeNetworkServiceProvider(int slotId); - void getNetworkRegistrationState(int slotId, int domain, INetworkServiceCallback callback); - void registerForNetworkRegistrationStateChanged(int slotId, INetworkServiceCallback callback); - void unregisterForNetworkRegistrationStateChanged(int slotId, INetworkServiceCallback callback); + void requestNetworkRegistrationInfo(int slotId, int domain, INetworkServiceCallback callback); + void registerForNetworkRegistrationInfoChanged(int slotId, INetworkServiceCallback callback); + void unregisterForNetworkRegistrationInfoChanged(int slotId, INetworkServiceCallback callback); } diff --git a/telephony/java/android/telephony/INetworkServiceCallback.aidl b/telephony/java/android/telephony/INetworkServiceCallback.aidl index 520598ff9144..c35986c65f37 100644 --- a/telephony/java/android/telephony/INetworkServiceCallback.aidl +++ b/telephony/java/android/telephony/INetworkServiceCallback.aidl @@ -16,7 +16,7 @@ package android.telephony; -import android.telephony.NetworkRegistrationState; +import android.telephony.NetworkRegistrationInfo; /** * Network service call back interface @@ -24,6 +24,6 @@ import android.telephony.NetworkRegistrationState; */ oneway interface INetworkServiceCallback { - void onGetNetworkRegistrationStateComplete(int result, in NetworkRegistrationState state); + void onRequestNetworkRegistrationInfoComplete(int result, in NetworkRegistrationInfo state); void onNetworkStateChanged(); } diff --git a/telephony/java/android/telephony/JapanesePhoneNumberFormatter.java b/telephony/java/android/telephony/JapanesePhoneNumberFormatter.java index f5e53ef1ee5d..92a674c57688 100644 --- a/telephony/java/android/telephony/JapanesePhoneNumberFormatter.java +++ b/telephony/java/android/telephony/JapanesePhoneNumberFormatter.java @@ -16,6 +16,7 @@ package android.telephony; +import android.annotation.UnsupportedAppUsage; import android.text.Editable; /* @@ -154,6 +155,7 @@ import android.text.Editable; -35, -35, -35, -35, -35, -35, -35, -35, -35, -45, -26, -15, -15, -15, -15, -15, -15, -15, -15, -15}; + @UnsupportedAppUsage public static void format(Editable text) { // Here, "root" means the position of "'": // 0'3, 0'90, and +81'-90 diff --git a/telephony/java/android/telephony/LteVopsSupportInfo.java b/telephony/java/android/telephony/LteVopsSupportInfo.java index 0ae85c0dfa6c..fda20bd4cf12 100644 --- a/telephony/java/android/telephony/LteVopsSupportInfo.java +++ b/telephony/java/android/telephony/LteVopsSupportInfo.java @@ -18,6 +18,7 @@ package android.telephony; import android.annotation.IntDef; import android.annotation.SystemApi; +import android.annotation.TestApi; import android.os.Parcel; import android.os.Parcelable; @@ -30,6 +31,7 @@ import java.util.Objects; * @hide */ @SystemApi +@TestApi public final class LteVopsSupportInfo implements Parcelable { /**@hide*/ diff --git a/telephony/java/android/telephony/NetworkRegistrationState.aidl b/telephony/java/android/telephony/NetworkRegistrationInfo.aidl index 98cba7720603..5c803bf69f69 100644 --- a/telephony/java/android/telephony/NetworkRegistrationState.aidl +++ b/telephony/java/android/telephony/NetworkRegistrationInfo.aidl @@ -16,4 +16,4 @@ package android.telephony; -parcelable NetworkRegistrationState; +parcelable NetworkRegistrationInfo; diff --git a/telephony/java/android/telephony/NetworkRegistrationState.java b/telephony/java/android/telephony/NetworkRegistrationInfo.java index 74f200b94510..1dc29979dc61 100644 --- a/telephony/java/android/telephony/NetworkRegistrationState.java +++ b/telephony/java/android/telephony/NetworkRegistrationInfo.java @@ -20,6 +20,7 @@ import android.annotation.IntDef; import android.annotation.NonNull; import android.annotation.Nullable; import android.annotation.SystemApi; +import android.annotation.TestApi; import android.os.Parcel; import android.os.Parcelable; import android.telephony.AccessNetworkConstants.TransportType; @@ -27,16 +28,19 @@ import android.telephony.TelephonyManager.NetworkType; import java.lang.annotation.Retention; import java.lang.annotation.RetentionPolicy; -import java.util.Arrays; +import java.util.ArrayList; +import java.util.Collections; +import java.util.List; import java.util.Objects; import java.util.stream.Collectors; /** - * Description of a mobile network registration state + * Description of a mobile network registration info * @hide */ @SystemApi -public class NetworkRegistrationState implements Parcelable { +@TestApi +public final class NetworkRegistrationInfo implements Parcelable { /** * Network domain * @hide @@ -51,41 +55,42 @@ public class NetworkRegistrationState implements Parcelable { public static final int DOMAIN_PS = 2; /** - * Registration state + * Network registration state * @hide */ @Retention(RetentionPolicy.SOURCE) - @IntDef(prefix = "REG_STATE_", - value = {REG_STATE_NOT_REG_NOT_SEARCHING, REG_STATE_HOME, REG_STATE_NOT_REG_SEARCHING, - REG_STATE_DENIED, REG_STATE_UNKNOWN, REG_STATE_ROAMING}) - public @interface RegState {} - - /** Not registered. The device is not currently searching a new operator to register */ - public static final int REG_STATE_NOT_REG_NOT_SEARCHING = 0; - /** Registered on home network */ - public static final int REG_STATE_HOME = 1; - /** Not registered. The device is currently searching a new operator to register */ - public static final int REG_STATE_NOT_REG_SEARCHING = 2; - /** Registration denied */ - public static final int REG_STATE_DENIED = 3; - /** Registration state is unknown */ - public static final int REG_STATE_UNKNOWN = 4; - /** Registered on roaming network */ - public static final int REG_STATE_ROAMING = 5; + @IntDef(prefix = "REGISTRATION_STATE_", + value = {REGISTRATION_STATE_NOT_REGISTERED_OR_SEARCHING, REGISTRATION_STATE_HOME, + REGISTRATION_STATE_NOT_REGISTERED_SEARCHING, REGISTRATION_STATE_DENIED, + REGISTRATION_STATE_UNKNOWN, REGISTRATION_STATE_ROAMING}) + public @interface RegistrationState {} + + /** Not registered. The device is not currently searching a new operator to register. */ + public static final int REGISTRATION_STATE_NOT_REGISTERED_OR_SEARCHING = 0; + /** Registered on home network. */ + public static final int REGISTRATION_STATE_HOME = 1; + /** Not registered. The device is currently searching a new operator to register. */ + public static final int REGISTRATION_STATE_NOT_REGISTERED_SEARCHING = 2; + /** Registration denied. */ + public static final int REGISTRATION_STATE_DENIED = 3; + /** Registration state is unknown. */ + public static final int REGISTRATION_STATE_UNKNOWN = 4; + /** Registered on roaming network. */ + public static final int REGISTRATION_STATE_ROAMING = 5; /** @hide */ @Retention(RetentionPolicy.SOURCE) - @IntDef(prefix = "NR_STATUS_", - value = {NR_STATUS_NONE, NR_STATUS_RESTRICTED, NR_STATUS_NOT_RESTRICTED, - NR_STATUS_CONNECTED}) - public @interface NRStatus {} + @IntDef(prefix = "NR_STATE_", + value = {NR_STATE_NONE, NR_STATE_RESTRICTED, NR_STATE_NOT_RESTRICTED, + NR_STATE_CONNECTED}) + public @interface NRState {} /** * The device isn't camped on an LTE cell or the LTE cell doesn't support E-UTRA-NR * Dual Connectivity(EN-DC). * @hide */ - public static final int NR_STATUS_NONE = -1; + public static final int NR_STATE_NONE = -1; /** * The device is camped on an LTE cell that supports E-UTRA-NR Dual Connectivity(EN-DC) but @@ -93,7 +98,7 @@ public class NetworkRegistrationState implements Parcelable { * the selected PLMN. * @hide */ - public static final int NR_STATUS_RESTRICTED = 1; + public static final int NR_STATE_RESTRICTED = 1; /** * The device is camped on an LTE cell that supports E-UTRA-NR Dual Connectivity(EN-DC) and both @@ -101,14 +106,14 @@ public class NetworkRegistrationState implements Parcelable { * selected PLMN. * @hide */ - public static final int NR_STATUS_NOT_RESTRICTED = 2; + public static final int NR_STATE_NOT_RESTRICTED = 2; /** * The device is camped on an LTE cell that supports E-UTRA-NR Dual Connectivity(EN-DC) and * also connected to at least one 5G cell as a secondary serving cell. * @hide */ - public static final int NR_STATUS_CONNECTED = 3; + public static final int NR_STATE_CONNECTED = 3; /** * Supported service type @@ -116,23 +121,36 @@ public class NetworkRegistrationState implements Parcelable { */ @Retention(RetentionPolicy.SOURCE) @IntDef(prefix = "SERVICE_TYPE_", - value = {SERVICE_TYPE_VOICE, SERVICE_TYPE_DATA, SERVICE_TYPE_SMS, SERVICE_TYPE_VIDEO, - SERVICE_TYPE_EMERGENCY}) + value = {SERVICE_TYPE_UNKNOWN, SERVICE_TYPE_VOICE, SERVICE_TYPE_DATA, SERVICE_TYPE_SMS, + SERVICE_TYPE_VIDEO, SERVICE_TYPE_EMERGENCY}) public @interface ServiceType {} + /** Unkown service */ + public static final int SERVICE_TYPE_UNKNOWN = 0; + + /** Voice service */ public static final int SERVICE_TYPE_VOICE = 1; + + /** Data service */ public static final int SERVICE_TYPE_DATA = 2; + + /** SMS service */ public static final int SERVICE_TYPE_SMS = 3; + + /** Video service */ public static final int SERVICE_TYPE_VIDEO = 4; + + /** Emergency service */ public static final int SERVICE_TYPE_EMERGENCY = 5; @Domain private final int mDomain; + @TransportType private final int mTransportType; - @RegState - private final int mRegState; + @RegistrationState + private final int mRegistrationState; /** * Save the {@link ServiceState.RoamingType roaming type}. it can be overridden roaming type @@ -144,118 +162,126 @@ public class NetworkRegistrationState implements Parcelable { @NetworkType private int mAccessNetworkTechnology; - @NRStatus - private int mNrStatus; + @NRState + private int mNrState; private final int mRejectCause; private final boolean mEmergencyOnly; @ServiceType - private final int[] mAvailableServices; + private final ArrayList<Integer> mAvailableServices; @Nullable private CellIdentity mCellIdentity; @Nullable - private VoiceSpecificRegistrationStates mVoiceSpecificStates; + private VoiceSpecificRegistrationInfo mVoiceSpecificInfo; @Nullable - private DataSpecificRegistrationStates mDataSpecificStates; + private DataSpecificRegistrationInfo mDataSpecificInfo; /** * @param domain Network domain. Must be a {@link Domain}. For transport type * {@link AccessNetworkConstants#TRANSPORT_TYPE_WLAN}, this must set to {@link #DOMAIN_PS}. * @param transportType Transport type. - * @param regState Network registration state. Must be one of the {@link RegState}. For - * transport type {@link AccessNetworkConstants#TRANSPORT_TYPE_WLAN}, only - * {@link #REG_STATE_HOME} and {@link #REG_STATE_NOT_REG_NOT_SEARCHING} are valid states. + * @param registrationState Network registration state. For transport type + * {@link AccessNetworkConstants#TRANSPORT_TYPE_WLAN}, only + * {@link #REGISTRATION_STATE_HOME} and {@link #REGISTRATION_STATE_NOT_REGISTERED_OR_SEARCHING} + * are valid states. * @param accessNetworkTechnology Access network technology.For transport type * {@link AccessNetworkConstants#TRANSPORT_TYPE_WLAN}, set to * {@link TelephonyManager#NETWORK_TYPE_IWLAN}. - * @param rejectCause Reason for denial if the registration state is {@link #REG_STATE_DENIED}. - * Depending on {@code accessNetworkTechnology}, the values are defined in 3GPP TS 24.008 - * 10.5.3.6 for UMTS, 3GPP TS 24.301 9.9.3.9 for LTE, and 3GPP2 A.S0001 6.2.2.44 for CDMA. If - * the reject cause is not supported or unknown, set it to 0. + * @param rejectCause Reason for denial if the registration state is + * {@link #REGISTRATION_STATE_DENIED}. Depending on {@code accessNetworkTechnology}, the values + * are defined in 3GPP TS 24.008 10.5.3.6 for UMTS, 3GPP TS 24.301 9.9.3.9 for LTE, and 3GPP2 + * A.S0001 6.2.2.44 for CDMA. If the reject cause is not supported or unknown, set it to 0. * // TODO: Add IWLAN reject cause reference * @param emergencyOnly True if this registration is for emergency only. - * @param availableServices The list of the supported services. Each element must be one of - * the {@link ServiceType}. + * @param availableServices The list of the supported services. * @param cellIdentity The identity representing a unique cell or wifi AP. Set to null if the * information is not available. */ - public NetworkRegistrationState(@Domain int domain, @TransportType int transportType, - @RegState int regState, - @NetworkType int accessNetworkTechnology, int rejectCause, - boolean emergencyOnly, - @NonNull @ServiceType int[] availableServices, - @Nullable CellIdentity cellIdentity) { + private NetworkRegistrationInfo(@Domain int domain, @TransportType int transportType, + @RegistrationState int registrationState, + @NetworkType int accessNetworkTechnology, int rejectCause, + boolean emergencyOnly, + @Nullable @ServiceType List<Integer> availableServices, + @Nullable CellIdentity cellIdentity) { mDomain = domain; mTransportType = transportType; - mRegState = regState; - mRoamingType = (regState == REG_STATE_ROAMING) + mRegistrationState = registrationState; + mRoamingType = (registrationState == REGISTRATION_STATE_ROAMING) ? ServiceState.ROAMING_TYPE_UNKNOWN : ServiceState.ROAMING_TYPE_NOT_ROAMING; mAccessNetworkTechnology = accessNetworkTechnology; mRejectCause = rejectCause; - mAvailableServices = availableServices; + mAvailableServices = (availableServices != null) + ? new ArrayList<>(availableServices) : new ArrayList<>(); mCellIdentity = cellIdentity; mEmergencyOnly = emergencyOnly; - mNrStatus = NR_STATUS_NONE; + mNrState = NR_STATE_NONE; } /** - * Constructor for voice network registration states. + * Constructor for voice network registration info. * @hide */ - public NetworkRegistrationState(int domain, @TransportType int transportType, int regState, - int accessNetworkTechnology, int rejectCause, boolean emergencyOnly, - int[] availableServices, @Nullable CellIdentity cellIdentity, boolean cssSupported, - int roamingIndicator, int systemIsInPrl, int defaultRoamingIndicator) { - this(domain, transportType, regState, accessNetworkTechnology, rejectCause, emergencyOnly, - availableServices, cellIdentity); - - mVoiceSpecificStates = new VoiceSpecificRegistrationStates(cssSupported, roamingIndicator, + public NetworkRegistrationInfo(int domain, @TransportType int transportType, + int registrationState, int accessNetworkTechnology, + int rejectCause, boolean emergencyOnly, + @Nullable List<Integer> availableServices, + @Nullable CellIdentity cellIdentity, boolean cssSupported, + int roamingIndicator, int systemIsInPrl, + int defaultRoamingIndicator) { + this(domain, transportType, registrationState, accessNetworkTechnology, rejectCause, + emergencyOnly, availableServices, cellIdentity); + + mVoiceSpecificInfo = new VoiceSpecificRegistrationInfo(cssSupported, roamingIndicator, systemIsInPrl, defaultRoamingIndicator); } /** - * Constructor for data network registration states. + * Constructor for data network registration info. * @hide */ - public NetworkRegistrationState(int domain, @TransportType int transportType, int regState, - int accessNetworkTechnology, int rejectCause, boolean emergencyOnly, - int[] availableServices, @Nullable CellIdentity cellIdentity, int maxDataCalls, - boolean isDcNrRestricted, boolean isNrAvailable, boolean isEndcAvailable, - LteVopsSupportInfo lteVopsSupportInfo) { - this(domain, transportType, regState, accessNetworkTechnology, rejectCause, emergencyOnly, - availableServices, cellIdentity); - - mDataSpecificStates = new DataSpecificRegistrationStates( + public NetworkRegistrationInfo(int domain, @TransportType int transportType, + int registrationState, int accessNetworkTechnology, + int rejectCause, boolean emergencyOnly, + @Nullable List<Integer> availableServices, + @Nullable CellIdentity cellIdentity, int maxDataCalls, + boolean isDcNrRestricted, boolean isNrAvailable, + boolean isEndcAvailable, + LteVopsSupportInfo lteVopsSupportInfo) { + this(domain, transportType, registrationState, accessNetworkTechnology, rejectCause, + emergencyOnly, availableServices, cellIdentity); + + mDataSpecificInfo = new DataSpecificRegistrationInfo( maxDataCalls, isDcNrRestricted, isNrAvailable, isEndcAvailable, lteVopsSupportInfo); - updateNrStatus(mDataSpecificStates); + updateNrState(mDataSpecificInfo); } - private NetworkRegistrationState(Parcel source) { + private NetworkRegistrationInfo(Parcel source) { mDomain = source.readInt(); mTransportType = source.readInt(); - mRegState = source.readInt(); + mRegistrationState = source.readInt(); mRoamingType = source.readInt(); mAccessNetworkTechnology = source.readInt(); mRejectCause = source.readInt(); mEmergencyOnly = source.readBoolean(); - mAvailableServices = source.createIntArray(); + mAvailableServices = new ArrayList<>(); + source.readList(mAvailableServices, Integer.class.getClassLoader()); mCellIdentity = source.readParcelable(CellIdentity.class.getClassLoader()); - mVoiceSpecificStates = source.readParcelable( - VoiceSpecificRegistrationStates.class.getClassLoader()); - mDataSpecificStates = source.readParcelable( - DataSpecificRegistrationStates.class.getClassLoader()); - mNrStatus = source.readInt(); + mVoiceSpecificInfo = source.readParcelable( + VoiceSpecificRegistrationInfo.class.getClassLoader()); + mDataSpecificInfo = source.readParcelable( + DataSpecificRegistrationInfo.class.getClassLoader()); + mNrState = source.readInt(); } /** * @return The transport type. */ - public int getTransportType() { return mTransportType; } + public @TransportType int getTransportType() { return mTransportType; } /** * @return The network domain. @@ -263,23 +289,23 @@ public class NetworkRegistrationState implements Parcelable { public @Domain int getDomain() { return mDomain; } /** - * @return the 5G NR connection status. + * @return the 5G NR connection state. * @hide */ - public @NRStatus int getNrStatus() { - return mNrStatus; + public @NRState int getNrState() { + return mNrState; } /** @hide */ - public void setNrStatus(@NRStatus int nrStatus) { - mNrStatus = nrStatus; + public void setNrState(@NRState int nrState) { + mNrState = nrState; } /** * @return The registration state. */ - public @RegState int getRegState() { - return mRegState; + public @RegistrationState int getRegistrationState() { + return mRegistrationState; } /** @@ -294,7 +320,8 @@ public class NetworkRegistrationState implements Parcelable { * @return {@code true} if in service. */ public boolean isInService() { - return mRegState == REG_STATE_HOME || mRegState == REG_STATE_ROAMING; + return mRegistrationState == REGISTRATION_STATE_HOME + || mRegistrationState == REGISTRATION_STATE_ROAMING; } /** @@ -324,7 +351,9 @@ public class NetworkRegistrationState implements Parcelable { */ @NonNull @ServiceType - public int[] getAvailableServices() { return mAvailableServices; } + public List<Integer> getAvailableServices() { + return Collections.unmodifiableList(mAvailableServices); + } /** * @return The access network technology {@link NetworkType}. @@ -342,7 +371,7 @@ public class NetworkRegistrationState implements Parcelable { } /** - * @return Reason for denial if the registration state is {@link #REG_STATE_DENIED}. + * @return Reason for denial if the registration state is {@link #REGISTRATION_STATE_DENIED}. * Depending on {@code accessNetworkTechnology}, the values are defined in 3GPP TS 24.008 * 10.5.3.6 for UMTS, 3GPP TS 24.301 9.9.3.9 for LTE, and 3GPP2 A.S0001 6.2.2.44 for CDMA */ @@ -362,16 +391,16 @@ public class NetworkRegistrationState implements Parcelable { * @hide */ @Nullable - public VoiceSpecificRegistrationStates getVoiceSpecificStates() { - return mVoiceSpecificStates; + public VoiceSpecificRegistrationInfo getVoiceSpecificInfo() { + return mVoiceSpecificInfo; } /** * @return Data registration related info */ @Nullable - public DataSpecificRegistrationStates getDataSpecificStates() { - return mDataSpecificStates; + public DataSpecificRegistrationInfo getDataSpecificInfo() { + return mDataSpecificInfo; } @Override @@ -403,28 +432,28 @@ public class NetworkRegistrationState implements Parcelable { * * @hide * - * @param regState The registration state + * @param registrationState The registration state * @return The reg state in string */ - public static String regStateToString(@RegState int regState) { - switch (regState) { - case REG_STATE_NOT_REG_NOT_SEARCHING: return "NOT_REG_NOT_SEARCHING"; - case REG_STATE_HOME: return "HOME"; - case REG_STATE_NOT_REG_SEARCHING: return "NOT_REG_SEARCHING"; - case REG_STATE_DENIED: return "DENIED"; - case REG_STATE_UNKNOWN: return "UNKNOWN"; - case REG_STATE_ROAMING: return "ROAMING"; + public static String registrationStateToString(@RegistrationState int registrationState) { + switch (registrationState) { + case REGISTRATION_STATE_NOT_REGISTERED_OR_SEARCHING: return "NOT_REG_OR_SEARCHING"; + case REGISTRATION_STATE_HOME: return "HOME"; + case REGISTRATION_STATE_NOT_REGISTERED_SEARCHING: return "NOT_REG_SEARCHING"; + case REGISTRATION_STATE_DENIED: return "DENIED"; + case REGISTRATION_STATE_UNKNOWN: return "UNKNOWN"; + case REGISTRATION_STATE_ROAMING: return "ROAMING"; } - return "Unknown reg state " + regState; + return "Unknown reg state " + registrationState; } - private static String nrStatusToString(@NRStatus int nrStatus) { - switch (nrStatus) { - case NR_STATUS_RESTRICTED: + private static String nrStateToString(@NRState int nrState) { + switch (nrState) { + case NR_STATE_RESTRICTED: return "RESTRICTED"; - case NR_STATUS_NOT_RESTRICTED: + case NR_STATE_NOT_RESTRICTED: return "NOT_RESTRICTED"; - case NR_STATUS_CONNECTED: + case NR_STATE_CONNECTED: return "CONNECTED"; default: return "NONE"; @@ -433,76 +462,75 @@ public class NetworkRegistrationState implements Parcelable { @Override public String toString() { - return new StringBuilder("NetworkRegistrationState{") + return new StringBuilder("NetworkRegistrationInfo{") .append(" domain=").append((mDomain == DOMAIN_CS) ? "CS" : "PS") .append(" transportType=").append( AccessNetworkConstants.transportTypeToString(mTransportType)) - .append(" regState=").append(regStateToString(mRegState)) + .append(" registrationState=").append(registrationStateToString(mRegistrationState)) .append(" roamingType=").append(ServiceState.roamingTypeToString(mRoamingType)) .append(" accessNetworkTechnology=") .append(TelephonyManager.getNetworkTypeName(mAccessNetworkTechnology)) .append(" rejectCause=").append(mRejectCause) .append(" emergencyEnabled=").append(mEmergencyOnly) .append(" availableServices=").append("[" + (mAvailableServices != null - ? Arrays.stream(mAvailableServices) - .mapToObj(type -> serviceTypeToString(type)) + ? mAvailableServices.stream().map(type -> serviceTypeToString(type)) .collect(Collectors.joining(",")) : null) + "]") .append(" cellIdentity=").append(mCellIdentity) - .append(" voiceSpecificStates=").append(mVoiceSpecificStates) - .append(" dataSpecificStates=").append(mDataSpecificStates) - .append(" nrStatus=").append(nrStatusToString(mNrStatus)) + .append(" voiceSpecificInfo=").append(mVoiceSpecificInfo) + .append(" dataSpecificInfo=").append(mDataSpecificInfo) + .append(" nrState=").append(nrStateToString(mNrState)) .append("}").toString(); } @Override public int hashCode() { - return Objects.hash(mDomain, mTransportType, mRegState, mRoamingType, + return Objects.hash(mDomain, mTransportType, mRegistrationState, mRoamingType, mAccessNetworkTechnology, mRejectCause, mEmergencyOnly, mAvailableServices, - mCellIdentity, mVoiceSpecificStates, mDataSpecificStates, mNrStatus); + mCellIdentity, mVoiceSpecificInfo, mDataSpecificInfo, mNrState); } @Override public boolean equals(Object o) { if (this == o) return true; - if (!(o instanceof NetworkRegistrationState)) { + if (!(o instanceof NetworkRegistrationInfo)) { return false; } - NetworkRegistrationState other = (NetworkRegistrationState) o; + NetworkRegistrationInfo other = (NetworkRegistrationInfo) o; return mDomain == other.mDomain && mTransportType == other.mTransportType - && mRegState == other.mRegState + && mRegistrationState == other.mRegistrationState && mRoamingType == other.mRoamingType && mAccessNetworkTechnology == other.mAccessNetworkTechnology && mRejectCause == other.mRejectCause && mEmergencyOnly == other.mEmergencyOnly - && Arrays.equals(mAvailableServices, other.mAvailableServices) + && mAvailableServices.equals(other.mAvailableServices) && Objects.equals(mCellIdentity, other.mCellIdentity) - && Objects.equals(mVoiceSpecificStates, other.mVoiceSpecificStates) - && Objects.equals(mDataSpecificStates, other.mDataSpecificStates) - && mNrStatus == other.mNrStatus; + && Objects.equals(mVoiceSpecificInfo, other.mVoiceSpecificInfo) + && Objects.equals(mDataSpecificInfo, other.mDataSpecificInfo) + && mNrState == other.mNrState; } @Override public void writeToParcel(Parcel dest, int flags) { dest.writeInt(mDomain); dest.writeInt(mTransportType); - dest.writeInt(mRegState); + dest.writeInt(mRegistrationState); dest.writeInt(mRoamingType); dest.writeInt(mAccessNetworkTechnology); dest.writeInt(mRejectCause); dest.writeBoolean(mEmergencyOnly); - dest.writeIntArray(mAvailableServices); + dest.writeList(mAvailableServices); dest.writeParcelable(mCellIdentity, 0); - dest.writeParcelable(mVoiceSpecificStates, 0); - dest.writeParcelable(mDataSpecificStates, 0); - dest.writeInt(mNrStatus); + dest.writeParcelable(mVoiceSpecificInfo, 0); + dest.writeParcelable(mDataSpecificInfo, 0); + dest.writeInt(mNrState); } /** * Use the 5G NR Non-Standalone indicators from the network registration state to update the - * NR status. There are 3 indicators in the network registration state: + * NR state. There are 3 indicators in the network registration state: * * 1. if E-UTRA-NR Dual Connectivity (EN-DC) is supported by the primary serving cell. * 2. if NR is supported by the selected PLMN. @@ -517,90 +545,81 @@ public class NetworkRegistrationState implements Parcelable { * * @param state data specific registration state contains the 5G NR indicators. */ - private void updateNrStatus(DataSpecificRegistrationStates state) { - mNrStatus = NR_STATUS_NONE; + private void updateNrState(DataSpecificRegistrationInfo state) { + mNrState = NR_STATE_NONE; if (state.isEnDcAvailable) { if (!state.isDcNrRestricted && state.isNrAvailable) { - mNrStatus = NR_STATUS_NOT_RESTRICTED; + mNrState = NR_STATE_NOT_RESTRICTED; } else { - mNrStatus = NR_STATUS_RESTRICTED; + mNrState = NR_STATE_RESTRICTED; } } } - public static final Parcelable.Creator<NetworkRegistrationState> CREATOR = - new Parcelable.Creator<NetworkRegistrationState>() { - @Override - public NetworkRegistrationState createFromParcel(Parcel source) { - return new NetworkRegistrationState(source); - } + public static final @NonNull Parcelable.Creator<NetworkRegistrationInfo> CREATOR = + new Parcelable.Creator<NetworkRegistrationInfo>() { + @Override + public NetworkRegistrationInfo createFromParcel(Parcel source) { + return new NetworkRegistrationInfo(source); + } - @Override - public NetworkRegistrationState[] newArray(int size) { - return new NetworkRegistrationState[size]; - } - }; + @Override + public NetworkRegistrationInfo[] newArray(int size) { + return new NetworkRegistrationInfo[size]; + } + }; /** * @hide */ - public NetworkRegistrationState sanitizeLocationInfo() { - NetworkRegistrationState result = copy(); + public NetworkRegistrationInfo sanitizeLocationInfo() { + NetworkRegistrationInfo result = copy(); result.mCellIdentity = null; return result; } - private NetworkRegistrationState copy() { + private NetworkRegistrationInfo copy() { Parcel p = Parcel.obtain(); this.writeToParcel(p, 0); p.setDataPosition(0); - NetworkRegistrationState result = new NetworkRegistrationState(p); + NetworkRegistrationInfo result = new NetworkRegistrationInfo(p); p.recycle(); return result; } /** - * Provides a convenient way to set the fields of a {@link NetworkRegistrationState} when + * Provides a convenient way to set the fields of a {@link NetworkRegistrationInfo} when * creating a new instance. * - * <p>The example below shows how you might create a new {@code NetworkRegistrationState}: + * <p>The example below shows how you might create a new {@code NetworkRegistrationInfo}: * * <pre><code> * - * NetworkRegistrationState nrs = new NetworkRegistrationState.Builder() - * .setApnTypeBitmask(ApnSetting.TYPE_DEFAULT | ApnSetting.TYPE_MMS) - * .setApnName("apn.example.com") - * .setEntryName("Example Carrier APN") - * .setMmsc(Uri.parse("http://mms.example.com:8002")) - * .setMmsProxyAddress(mmsProxy) - * .setMmsProxyPort(8799) + * NetworkRegistrationInfo nri = new NetworkRegistrationInfo.Builder() + * .setAccessNetworkTechnology(TelephonyManager.NETWORK_TYPE_LTE) + * .setRegistrationState(REGISTRATION_STATE_HOME) * .build(); * </code></pre> */ - public static class Builder{ + public static final class Builder{ @Domain private int mDomain; + @TransportType private int mTransportType; - @RegState - private int mRegState; - - @ServiceState.RoamingType - private int mRoamingType; + @RegistrationState + private int mRegistrationState; @NetworkType private int mAccessNetworkTechnology; - @NRStatus - private int mNrStatus; - private int mRejectCause; private boolean mEmergencyOnly; @ServiceType - private int[] mAvailableServices; + private List<Integer> mAvailableServices; @Nullable private CellIdentity mCellIdentity; @@ -637,24 +656,12 @@ public class NetworkRegistrationState implements Parcelable { /** * Set the registration state. * - * @param regState The registration state. + * @param registrationState The registration state. * * @return The same instance of the builder. */ - public @NonNull Builder setRegState(@RegState int regState) { - mRegState = regState; - return this; - } - - /** - * Set the roaming type. - * - * @param roamingType Roaming type. - * - * @return The same instance of the builder. - */ - public @NonNull Builder setRoamingType(@ServiceState.RoamingType int roamingType) { - mRoamingType = roamingType; + public @NonNull Builder setRegistrationState(@RegistrationState int registrationState) { + mRegistrationState = registrationState; return this; } @@ -672,24 +679,13 @@ public class NetworkRegistrationState implements Parcelable { } /** - * Set the 5G NR connection status. - * - * @param nrStatus 5G NR connection status. - * - * @return The same instance of the builder. - */ - public @NonNull Builder setNrStatus(@NRStatus int nrStatus) { - mNrStatus = nrStatus; - return this; - } - - /** * Set the network reject cause. * * @param rejectCause Reason for denial if the registration state is - * {@link #REG_STATE_DENIED}.Depending on {@code accessNetworkTechnology}, the values are - * defined in 3GPP TS 24.008 10.5.3.6 for UMTS, 3GPP TS 24.301 9.9.3.9 for LTE, and 3GPP2 - * A.S0001 6.2.2.44 for CDMA. If the reject cause is not supported or unknown, set it to 0. + * {@link #REGISTRATION_STATE_DENIED}.Depending on {@code accessNetworkTechnology}, the + * values are defined in 3GPP TS 24.008 10.5.3.6 for UMTS, 3GPP TS 24.301 9.9.3.9 for LTE, + * and 3GPP2 A.S0001 6.2.2.44 for CDMA. If the reject cause is not supported or unknown, set + * it to 0. * * @return The same instance of the builder. */ @@ -718,7 +714,7 @@ public class NetworkRegistrationState implements Parcelable { * @return The same instance of the builder. */ public @NonNull Builder setAvailableServices( - @NonNull @ServiceType int[] availableServices) { + @NonNull @ServiceType List<Integer> availableServices) { mAvailableServices = availableServices; return this; } @@ -736,12 +732,12 @@ public class NetworkRegistrationState implements Parcelable { } /** - * Build the NetworkRegistrationState. + * Build the NetworkRegistrationInfo. * - * @return the NetworkRegistrationState object. + * @return the NetworkRegistrationInfo object. */ - public @NonNull NetworkRegistrationState build() { - return new NetworkRegistrationState(mDomain, mTransportType, mRegState, + public @NonNull NetworkRegistrationInfo build() { + return new NetworkRegistrationInfo(mDomain, mTransportType, mRegistrationState, mAccessNetworkTechnology, mRejectCause, mEmergencyOnly, mAvailableServices, mCellIdentity); } diff --git a/telephony/java/android/telephony/NetworkService.java b/telephony/java/android/telephony/NetworkService.java index f1240e9fcf34..8c5e10788b89 100644 --- a/telephony/java/android/telephony/NetworkService.java +++ b/telephony/java/android/telephony/NetworkService.java @@ -18,6 +18,7 @@ package android.telephony; import android.annotation.NonNull; import android.annotation.Nullable; +import android.annotation.SdkConstant; import android.annotation.SystemApi; import android.app.Service; import android.content.Intent; @@ -27,7 +28,7 @@ import android.os.IBinder; import android.os.Looper; import android.os.Message; import android.os.RemoteException; -import android.telephony.NetworkRegistrationState.Domain; +import android.telephony.NetworkRegistrationInfo.Domain; import android.util.SparseArray; import com.android.internal.annotations.VisibleForTesting; @@ -54,15 +55,16 @@ public abstract class NetworkService extends Service { private final String TAG = NetworkService.class.getSimpleName(); - public static final String NETWORK_SERVICE_INTERFACE = "android.telephony.NetworkService"; + @SdkConstant(SdkConstant.SdkConstantType.SERVICE_ACTION) + public static final String SERVICE_INTERFACE = "android.telephony.NetworkService"; private static final int NETWORK_SERVICE_CREATE_NETWORK_SERVICE_PROVIDER = 1; private static final int NETWORK_SERVICE_REMOVE_NETWORK_SERVICE_PROVIDER = 2; private static final int NETWORK_SERVICE_REMOVE_ALL_NETWORK_SERVICE_PROVIDERS = 3; - private static final int NETWORK_SERVICE_GET_REGISTRATION_STATE = 4; - private static final int NETWORK_SERVICE_REGISTER_FOR_STATE_CHANGE = 5; - private static final int NETWORK_SERVICE_UNREGISTER_FOR_STATE_CHANGE = 6; - private static final int NETWORK_SERVICE_INDICATION_NETWORK_STATE_CHANGED = 7; + private static final int NETWORK_SERVICE_GET_REGISTRATION_INFO = 4; + private static final int NETWORK_SERVICE_REGISTER_FOR_INFO_CHANGE = 5; + private static final int NETWORK_SERVICE_UNREGISTER_FOR_INFO_CHANGE = 6; + private static final int NETWORK_SERVICE_INDICATION_NETWORK_INFO_CHANGED = 7; private final HandlerThread mHandlerThread; @@ -86,7 +88,7 @@ public abstract class NetworkService extends Service { private final int mSlotIndex; private final List<INetworkServiceCallback> - mNetworkRegistrationStateChangedCallbacks = new ArrayList<>(); + mNetworkRegistrationInfoChangedCallbacks = new ArrayList<>(); /** * Constructor @@ -104,38 +106,39 @@ public abstract class NetworkService extends Service { } /** - * API to get network registration state. The result will be passed to the callback. + * Request network registration info. The result will be passed to the callback. + * * @param domain Network domain - * @param callback The callback for reporting network registration state + * @param callback The callback for reporting network registration info */ - public void getNetworkRegistrationState(@Domain int domain, - @NonNull NetworkServiceCallback callback) { - callback.onGetNetworkRegistrationStateComplete( + public void requestNetworkRegistrationInfo(@Domain int domain, + @NonNull NetworkServiceCallback callback) { + callback.onRequestNetworkRegistrationInfoComplete( NetworkServiceCallback.RESULT_ERROR_UNSUPPORTED, null); } /** - * Notify the system that network registration state is changed. + * Notify the system that network registration info is changed. */ - public final void notifyNetworkRegistrationStateChanged() { - mHandler.obtainMessage(NETWORK_SERVICE_INDICATION_NETWORK_STATE_CHANGED, + public final void notifyNetworkRegistrationInfoChanged() { + mHandler.obtainMessage(NETWORK_SERVICE_INDICATION_NETWORK_INFO_CHANGED, mSlotIndex, 0, null).sendToTarget(); } - private void registerForStateChanged(@NonNull INetworkServiceCallback callback) { - synchronized (mNetworkRegistrationStateChangedCallbacks) { - mNetworkRegistrationStateChangedCallbacks.add(callback); + private void registerForInfoChanged(@NonNull INetworkServiceCallback callback) { + synchronized (mNetworkRegistrationInfoChangedCallbacks) { + mNetworkRegistrationInfoChangedCallbacks.add(callback); } } - private void unregisterForStateChanged(@NonNull INetworkServiceCallback callback) { - synchronized (mNetworkRegistrationStateChangedCallbacks) { - mNetworkRegistrationStateChangedCallbacks.remove(callback); + private void unregisterForInfoChanged(@NonNull INetworkServiceCallback callback) { + synchronized (mNetworkRegistrationInfoChangedCallbacks) { + mNetworkRegistrationInfoChangedCallbacks.remove(callback); } } - private void notifyStateChangedToCallbacks() { - for (INetworkServiceCallback callback : mNetworkRegistrationStateChangedCallbacks) { + private void notifyInfoChangedToCallbacks() { + for (INetworkServiceCallback callback : mNetworkRegistrationInfoChangedCallbacks) { try { callback.onNetworkStateChanged(); } catch (RemoteException exception) { @@ -189,24 +192,24 @@ public abstract class NetworkService extends Service { } mServiceMap.clear(); break; - case NETWORK_SERVICE_GET_REGISTRATION_STATE: + case NETWORK_SERVICE_GET_REGISTRATION_INFO: if (serviceProvider == null) break; int domainId = message.arg2; - serviceProvider.getNetworkRegistrationState(domainId, + serviceProvider.requestNetworkRegistrationInfo(domainId, new NetworkServiceCallback(callback)); break; - case NETWORK_SERVICE_REGISTER_FOR_STATE_CHANGE: + case NETWORK_SERVICE_REGISTER_FOR_INFO_CHANGE: if (serviceProvider == null) break; - serviceProvider.registerForStateChanged(callback); + serviceProvider.registerForInfoChanged(callback); break; - case NETWORK_SERVICE_UNREGISTER_FOR_STATE_CHANGE: + case NETWORK_SERVICE_UNREGISTER_FOR_INFO_CHANGE: if (serviceProvider == null) break; - serviceProvider.unregisterForStateChanged(callback); + serviceProvider.unregisterForInfoChanged(callback); break; - case NETWORK_SERVICE_INDICATION_NETWORK_STATE_CHANGED: + case NETWORK_SERVICE_INDICATION_NETWORK_INFO_CHANGED: if (serviceProvider == null) break; - serviceProvider.notifyStateChangedToCallbacks(); + serviceProvider.notifyInfoChangedToCallbacks(); break; default: break; @@ -231,14 +234,15 @@ public abstract class NetworkService extends Service { * will call this method after binding the network service for each active SIM slot id. * * @param slotIndex SIM slot id the network service associated with. - * @return Network service object + * @return Network service object. Null if failed to create the provider (e.g. invalid slot + * index) */ @Nullable public abstract NetworkServiceProvider onCreateNetworkServiceProvider(int slotIndex); @Override public IBinder onBind(Intent intent) { - if (intent == null || !NETWORK_SERVICE_INTERFACE.equals(intent.getAction())) { + if (intent == null || !SERVICE_INTERFACE.equals(intent.getAction())) { loge("Unexpected intent " + intent); return null; } @@ -280,23 +284,23 @@ public abstract class NetworkService extends Service { } @Override - public void getNetworkRegistrationState( - int slotIndex, int domain, INetworkServiceCallback callback) { - mHandler.obtainMessage(NETWORK_SERVICE_GET_REGISTRATION_STATE, slotIndex, + public void requestNetworkRegistrationInfo(int slotIndex, int domain, + INetworkServiceCallback callback) { + mHandler.obtainMessage(NETWORK_SERVICE_GET_REGISTRATION_INFO, slotIndex, domain, callback).sendToTarget(); } @Override - public void registerForNetworkRegistrationStateChanged( + public void registerForNetworkRegistrationInfoChanged( int slotIndex, INetworkServiceCallback callback) { - mHandler.obtainMessage(NETWORK_SERVICE_REGISTER_FOR_STATE_CHANGE, slotIndex, + mHandler.obtainMessage(NETWORK_SERVICE_REGISTER_FOR_INFO_CHANGE, slotIndex, 0, callback).sendToTarget(); } @Override - public void unregisterForNetworkRegistrationStateChanged( + public void unregisterForNetworkRegistrationInfoChanged( int slotIndex, INetworkServiceCallback callback) { - mHandler.obtainMessage(NETWORK_SERVICE_UNREGISTER_FOR_STATE_CHANGE, slotIndex, + mHandler.obtainMessage(NETWORK_SERVICE_UNREGISTER_FOR_INFO_CHANGE, slotIndex, 0, callback).sendToTarget(); } } diff --git a/telephony/java/android/telephony/NetworkServiceCallback.java b/telephony/java/android/telephony/NetworkServiceCallback.java index c2fcfb7a0759..1c64bcd28966 100644 --- a/telephony/java/android/telephony/NetworkServiceCallback.java +++ b/telephony/java/android/telephony/NetworkServiceCallback.java @@ -28,9 +28,9 @@ import java.lang.ref.WeakReference; /** * Network service callback. Object of this class is passed to NetworkServiceProvider upon - * calling getNetworkRegistrationState, to receive asynchronous feedback from NetworkServiceProvider - * upon onGetNetworkRegistrationStateComplete. It's like a wrapper of INetworkServiceCallback - * because INetworkServiceCallback can't be a parameter type in public APIs. + * calling requestNetworkRegistrationInfo, to receive asynchronous feedback from + * NetworkServiceProvider upon onRequestNetworkRegistrationInfoComplete. It's like a wrapper of + * INetworkServiceCallback because INetworkServiceCallback can't be a parameter type in public APIs. * * @hide */ @@ -70,20 +70,20 @@ public class NetworkServiceCallback { /** * Called to indicate result of - * {@link NetworkServiceProvider#getNetworkRegistrationState(int, NetworkServiceCallback)} + * {@link NetworkServiceProvider#requestNetworkRegistrationInfo(int, NetworkServiceCallback)} * * @param result Result status like {@link NetworkServiceCallback#RESULT_SUCCESS} or - * {@link NetworkServiceCallback#RESULT_ERROR_UNSUPPORTED} + * {@link NetworkServiceCallback#RESULT_ERROR_UNSUPPORTED} * @param state The state information to be returned to callback. */ - public void onGetNetworkRegistrationStateComplete(int result, - @Nullable NetworkRegistrationState state) { + public void onRequestNetworkRegistrationInfoComplete(int result, + @Nullable NetworkRegistrationInfo state) { INetworkServiceCallback callback = mCallback.get(); if (callback != null) { try { - callback.onGetNetworkRegistrationStateComplete(result, state); + callback.onRequestNetworkRegistrationInfoComplete(result, state); } catch (RemoteException e) { - Rlog.e(mTag, "Failed to onGetNetworkRegistrationStateComplete on the remote"); + Rlog.e(mTag, "Failed to onRequestNetworkRegistrationInfoComplete on the remote"); } } else { Rlog.e(mTag, "Weak reference of callback is null."); diff --git a/telephony/java/android/telephony/ServiceState.java b/telephony/java/android/telephony/ServiceState.java index 4b15aac77940..caf27b79dc13 100644 --- a/telephony/java/android/telephony/ServiceState.java +++ b/telephony/java/android/telephony/ServiceState.java @@ -29,8 +29,8 @@ import android.os.Parcel; import android.os.Parcelable; import android.telephony.AccessNetworkConstants.AccessNetworkType; import android.telephony.AccessNetworkConstants.TransportType; -import android.telephony.NetworkRegistrationState.Domain; -import android.telephony.NetworkRegistrationState.NRStatus; +import android.telephony.NetworkRegistrationInfo.Domain; +import android.telephony.NetworkRegistrationInfo.NRState; import android.text.TextUtils; import java.lang.annotation.Retention; @@ -53,6 +53,9 @@ import java.util.stream.Collectors; * <li>Operator name, short name and numeric id * <li>Network selection mode * </ul> + * + * For historical reasons this class is not declared as final; however, + * it should be treated as though it were final. */ public class ServiceState implements Parcelable { @@ -349,7 +352,7 @@ public class ServiceState implements Parcelable { * Reference: 3GPP TS 36.104 5.4.3 */ private int mLteEarfcnRsrpBoost = 0; - private List<NetworkRegistrationState> mNetworkRegistrationStates = new ArrayList<>(); + private List<NetworkRegistrationInfo> mNetworkRegistrationInfos = new ArrayList<>(); /** * get String description of roaming type @@ -432,8 +435,8 @@ public class ServiceState implements Parcelable { mCellBandwidths = s.mCellBandwidths == null ? null : Arrays.copyOf(s.mCellBandwidths, s.mCellBandwidths.length); mLteEarfcnRsrpBoost = s.mLteEarfcnRsrpBoost; - mNetworkRegistrationStates = s.mNetworkRegistrationStates == null ? null : - new ArrayList<>(s.mNetworkRegistrationStates); + mNetworkRegistrationInfos = s.mNetworkRegistrationInfos == null ? null : + new ArrayList<>(s.mNetworkRegistrationInfos); mNrFrequencyRange = s.mNrFrequencyRange; } @@ -466,8 +469,8 @@ public class ServiceState implements Parcelable { mIsEmergencyOnly = in.readInt() != 0; mIsUsingCarrierAggregation = in.readInt() != 0; mLteEarfcnRsrpBoost = in.readInt(); - mNetworkRegistrationStates = new ArrayList<>(); - in.readList(mNetworkRegistrationStates, NetworkRegistrationState.class.getClassLoader()); + mNetworkRegistrationInfos = new ArrayList<>(); + in.readList(mNetworkRegistrationInfos, NetworkRegistrationInfo.class.getClassLoader()); mChannelNumber = in.readInt(); mCellBandwidths = in.createIntArray(); mNrFrequencyRange = in.readInt(); @@ -495,7 +498,7 @@ public class ServiceState implements Parcelable { out.writeInt(mIsEmergencyOnly ? 1 : 0); out.writeInt(mIsUsingCarrierAggregation ? 1 : 0); out.writeInt(mLteEarfcnRsrpBoost); - out.writeList(mNetworkRegistrationStates); + out.writeList(mNetworkRegistrationInfos); out.writeInt(mChannelNumber); out.writeIntArray(mCellBandwidths); out.writeInt(mNrFrequencyRange); @@ -620,8 +623,8 @@ public class ServiceState implements Parcelable { */ @UnsupportedAppUsage(maxTargetSdk = Build.VERSION_CODES.P) public @RoamingType int getVoiceRoamingType() { - final NetworkRegistrationState regState = getNetworkRegistrationState( - NetworkRegistrationState.DOMAIN_CS, AccessNetworkConstants.TRANSPORT_TYPE_WWAN); + final NetworkRegistrationInfo regState = getNetworkRegistrationInfo( + NetworkRegistrationInfo.DOMAIN_CS, AccessNetworkConstants.TRANSPORT_TYPE_WWAN); if (regState != null) { return regState.getRoamingType(); } @@ -644,10 +647,11 @@ public class ServiceState implements Parcelable { * @hide */ public boolean getDataRoamingFromRegistration() { - final NetworkRegistrationState regState = getNetworkRegistrationState( - NetworkRegistrationState.DOMAIN_PS, AccessNetworkConstants.TRANSPORT_TYPE_WWAN); + final NetworkRegistrationInfo regState = getNetworkRegistrationInfo( + NetworkRegistrationInfo.DOMAIN_PS, AccessNetworkConstants.TRANSPORT_TYPE_WWAN); if (regState != null) { - return (regState.getRegState() == NetworkRegistrationState.REG_STATE_ROAMING); + return regState.getRegistrationState() + == NetworkRegistrationInfo.REGISTRATION_STATE_ROAMING; } return false; } @@ -659,8 +663,8 @@ public class ServiceState implements Parcelable { */ @UnsupportedAppUsage(maxTargetSdk = Build.VERSION_CODES.P) public @RoamingType int getDataRoamingType() { - final NetworkRegistrationState regState = getNetworkRegistrationState( - NetworkRegistrationState.DOMAIN_PS, AccessNetworkConstants.TRANSPORT_TYPE_WWAN); + final NetworkRegistrationInfo regState = getNetworkRegistrationInfo( + NetworkRegistrationInfo.DOMAIN_PS, AccessNetworkConstants.TRANSPORT_TYPE_WWAN); if (regState != null) { return regState.getRoamingType(); } @@ -858,7 +862,7 @@ public class ServiceState implements Parcelable { mIsEmergencyOnly, mIsUsingCarrierAggregation, mLteEarfcnRsrpBoost, - mNetworkRegistrationStates, + mNetworkRegistrationInfos, mNrFrequencyRange); } @@ -888,9 +892,9 @@ public class ServiceState implements Parcelable { s.mCdmaDefaultRoamingIndicator) && mIsEmergencyOnly == s.mIsEmergencyOnly && mIsUsingCarrierAggregation == s.mIsUsingCarrierAggregation) - && (mNetworkRegistrationStates == null ? s.mNetworkRegistrationStates == null : - s.mNetworkRegistrationStates != null && - mNetworkRegistrationStates.containsAll(s.mNetworkRegistrationStates)) + && (mNetworkRegistrationInfos == null + ? s.mNetworkRegistrationInfos == null : s.mNetworkRegistrationInfos != null + && mNetworkRegistrationInfos.containsAll(s.mNetworkRegistrationInfos)) && mNrFrequencyRange == s.mNrFrequencyRange; } @@ -1043,7 +1047,7 @@ public class ServiceState implements Parcelable { .append(", mIsEmergencyOnly=").append(mIsEmergencyOnly) .append(", mIsUsingCarrierAggregation=").append(mIsUsingCarrierAggregation) .append(", mLteEarfcnRsrpBoost=").append(mLteEarfcnRsrpBoost) - .append(", mNetworkRegistrationStates=").append(mNetworkRegistrationStates) + .append(", mNetworkRegistrationInfos=").append(mNetworkRegistrationInfos) .append(", mNrFrequencyRange=").append(mNrFrequencyRange) .append("}").toString(); } @@ -1073,7 +1077,7 @@ public class ServiceState implements Parcelable { mIsEmergencyOnly = false; mIsUsingCarrierAggregation = false; mLteEarfcnRsrpBoost = 0; - mNetworkRegistrationStates = new ArrayList<>(); + mNetworkRegistrationInfos = new ArrayList<>(); mNrFrequencyRange = FREQUENCY_RANGE_UNKNOWN; } @@ -1128,16 +1132,16 @@ public class ServiceState implements Parcelable { } /** @hide */ - @UnsupportedAppUsage(maxTargetSdk = Build.VERSION_CODES.P, trackingBug = 115609023) + @TestApi public void setVoiceRoamingType(@RoamingType int type) { - NetworkRegistrationState regState = getNetworkRegistrationState( - NetworkRegistrationState.DOMAIN_CS, AccessNetworkConstants.TRANSPORT_TYPE_WWAN); + NetworkRegistrationInfo regState = getNetworkRegistrationInfo( + NetworkRegistrationInfo.DOMAIN_CS, AccessNetworkConstants.TRANSPORT_TYPE_WWAN); if (regState == null) { - regState = new NetworkRegistrationState( - NetworkRegistrationState.DOMAIN_CS, AccessNetworkConstants.TRANSPORT_TYPE_WWAN, - ServiceState.ROAMING_TYPE_NOT_ROAMING, TelephonyManager.NETWORK_TYPE_UNKNOWN, 0, - false, null, null); - addNetworkRegistrationState(regState); + regState = new NetworkRegistrationInfo.Builder() + .setDomain(NetworkRegistrationInfo.DOMAIN_CS) + .setTransportType(AccessNetworkConstants.TRANSPORT_TYPE_WWAN) + .build(); + addNetworkRegistrationInfo(regState); } regState.setRoamingType(type); } @@ -1149,16 +1153,16 @@ public class ServiceState implements Parcelable { } /** @hide */ - @UnsupportedAppUsage(maxTargetSdk = Build.VERSION_CODES.P, trackingBug = 115609023) + @TestApi public void setDataRoamingType(@RoamingType int type) { - NetworkRegistrationState regState = getNetworkRegistrationState( - NetworkRegistrationState.DOMAIN_PS, AccessNetworkConstants.TRANSPORT_TYPE_WWAN); + NetworkRegistrationInfo regState = getNetworkRegistrationInfo( + NetworkRegistrationInfo.DOMAIN_PS, AccessNetworkConstants.TRANSPORT_TYPE_WWAN); if (regState == null) { - regState = new NetworkRegistrationState( - NetworkRegistrationState.DOMAIN_PS, AccessNetworkConstants.TRANSPORT_TYPE_WWAN, - ServiceState.ROAMING_TYPE_NOT_ROAMING, TelephonyManager.NETWORK_TYPE_UNKNOWN, 0, - false, null, null); - addNetworkRegistrationState(regState); + regState = new NetworkRegistrationInfo.Builder() + .setDomain(NetworkRegistrationInfo.DOMAIN_PS) + .setTransportType(AccessNetworkConstants.TRANSPORT_TYPE_WWAN) + .build(); + addNetworkRegistrationInfo(regState); } regState.setRoamingType(type); } @@ -1326,14 +1330,14 @@ public class ServiceState implements Parcelable { this.mRilVoiceRadioTechnology = rt; // sync to network registration state - NetworkRegistrationState regState = getNetworkRegistrationState( - NetworkRegistrationState.DOMAIN_CS, AccessNetworkConstants.TRANSPORT_TYPE_WWAN); + NetworkRegistrationInfo regState = getNetworkRegistrationInfo( + NetworkRegistrationInfo.DOMAIN_CS, AccessNetworkConstants.TRANSPORT_TYPE_WWAN); if (regState == null) { - regState = new NetworkRegistrationState( - NetworkRegistrationState.DOMAIN_CS, AccessNetworkConstants.TRANSPORT_TYPE_WWAN, - ServiceState.ROAMING_TYPE_NOT_ROAMING, TelephonyManager.NETWORK_TYPE_UNKNOWN, - 0, false, null, null); - addNetworkRegistrationState(regState); + regState = new NetworkRegistrationInfo.Builder() + .setDomain(NetworkRegistrationInfo.DOMAIN_CS) + .setTransportType(AccessNetworkConstants.TRANSPORT_TYPE_WWAN) + .build(); + addNetworkRegistrationInfo(regState); } regState.setAccessNetworkTechnology( rilRadioTechnologyToNetworkType(mRilVoiceRadioTechnology)); @@ -1353,15 +1357,15 @@ public class ServiceState implements Parcelable { mRilDataRadioTechnology); // sync to network registration state - NetworkRegistrationState regState = getNetworkRegistrationState( - NetworkRegistrationState.DOMAIN_PS, AccessNetworkConstants.TRANSPORT_TYPE_WWAN); + NetworkRegistrationInfo regState = getNetworkRegistrationInfo( + NetworkRegistrationInfo.DOMAIN_PS, AccessNetworkConstants.TRANSPORT_TYPE_WWAN); if (regState == null) { - regState = new NetworkRegistrationState( - NetworkRegistrationState.DOMAIN_PS, AccessNetworkConstants.TRANSPORT_TYPE_WWAN, - ServiceState.ROAMING_TYPE_NOT_ROAMING, TelephonyManager.NETWORK_TYPE_UNKNOWN, - 0, false, null, null); - addNetworkRegistrationState(regState); + regState = new NetworkRegistrationInfo.Builder() + .setDomain(NetworkRegistrationInfo.DOMAIN_PS) + .setTransportType(AccessNetworkConstants.TRANSPORT_TYPE_WWAN) + .build(); + addNetworkRegistrationInfo(regState); } regState.setAccessNetworkTechnology( rilRadioTechnologyToNetworkType(mRilDataRadioTechnology)); @@ -1386,15 +1390,15 @@ public class ServiceState implements Parcelable { } /** - * Get the NR 5G status of the mobile data network. - * @return the NR 5G status. + * Get the NR 5G state of the mobile data network. + * @return the NR 5G state. * @hide */ - public @NRStatus int getNrStatus() { - final NetworkRegistrationState regState = getNetworkRegistrationState( - NetworkRegistrationState.DOMAIN_PS, AccessNetworkConstants.TRANSPORT_TYPE_WWAN); - if (regState == null) return NetworkRegistrationState.NR_STATUS_NONE; - return regState.getNrStatus(); + public @NRState int getNrState() { + final NetworkRegistrationInfo regState = getNetworkRegistrationInfo( + NetworkRegistrationInfo.DOMAIN_PS, AccessNetworkConstants.TRANSPORT_TYPE_WWAN); + if (regState == null) return NetworkRegistrationInfo.NR_STATE_NONE; + return regState.getNrState(); } /** @@ -1576,19 +1580,19 @@ public class ServiceState implements Parcelable { /** @hide */ @UnsupportedAppUsage(maxTargetSdk = Build.VERSION_CODES.P) public @TelephonyManager.NetworkType int getDataNetworkType() { - final NetworkRegistrationState iwlanRegState = getNetworkRegistrationState( - NetworkRegistrationState.DOMAIN_PS, AccessNetworkConstants.TRANSPORT_TYPE_WLAN); - if (iwlanRegState != null - && iwlanRegState.getRegState() == NetworkRegistrationState.REG_STATE_HOME) { + final NetworkRegistrationInfo iwlanRegState = getNetworkRegistrationInfo( + NetworkRegistrationInfo.DOMAIN_PS, AccessNetworkConstants.TRANSPORT_TYPE_WLAN); + if (iwlanRegState != null && iwlanRegState.getRegistrationState() + == NetworkRegistrationInfo.REGISTRATION_STATE_HOME) { // If the device is on IWLAN, return IWLAN as the network type. This is to simulate the // behavior of legacy mode device. In the future caller should use - // getNetworkRegistrationState() to retrieve the actual data network type on cellular + // requestNetworkRegistrationInfo() to retrieve the actual data network type on cellular // or on IWLAN. return iwlanRegState.getAccessNetworkTechnology(); } - final NetworkRegistrationState regState = getNetworkRegistrationState( - NetworkRegistrationState.DOMAIN_PS, AccessNetworkConstants.TRANSPORT_TYPE_WWAN); + final NetworkRegistrationInfo regState = getNetworkRegistrationInfo( + NetworkRegistrationInfo.DOMAIN_PS, AccessNetworkConstants.TRANSPORT_TYPE_WWAN); if (regState != null) { return regState.getAccessNetworkTechnology(); } @@ -1598,8 +1602,8 @@ public class ServiceState implements Parcelable { /** @hide */ @UnsupportedAppUsage(maxTargetSdk = Build.VERSION_CODES.P) public @TelephonyManager.NetworkType int getVoiceNetworkType() { - final NetworkRegistrationState regState = getNetworkRegistrationState( - NetworkRegistrationState.DOMAIN_CS, AccessNetworkConstants.TRANSPORT_TYPE_WWAN); + final NetworkRegistrationInfo regState = getNetworkRegistrationInfo( + NetworkRegistrationInfo.DOMAIN_CS, AccessNetworkConstants.TRANSPORT_TYPE_WWAN); if (regState != null) { return regState.getAccessNetworkTechnology(); } @@ -1762,52 +1766,36 @@ public class ServiceState implements Parcelable { } /** - * Get all of the available network registration states. + * Get all of the available network registration info. * - * @return List of {@link NetworkRegistrationState} + * @return List of {@link NetworkRegistrationInfo} * @hide */ @NonNull @SystemApi - public List<NetworkRegistrationState> getNetworkRegistrationStates() { - synchronized (mNetworkRegistrationStates) { - return new ArrayList<>(mNetworkRegistrationStates); + public List<NetworkRegistrationInfo> getNetworkRegistrationInfoList() { + synchronized (mNetworkRegistrationInfos) { + return new ArrayList<>(mNetworkRegistrationInfos); } } /** - * Get the network registration states for the transport type. + * Get the network registration info list for the transport type. * * @param transportType The transport type - * @return List of {@link NetworkRegistrationState} + * @return List of {@link NetworkRegistrationInfo} * @hide - * - * @deprecated Use {@link #getNetworkRegistrationStatesForTransportType(int)} */ @NonNull - @Deprecated @SystemApi - public List<NetworkRegistrationState> getNetworkRegistrationStates(int transportType) { - return getNetworkRegistrationStatesForTransportType(transportType); - } - - /** - * Get the network registration states for the transport type. - * - * @param transportType The transport type - * @return List of {@link NetworkRegistrationState} - * @hide - */ - @NonNull - @SystemApi - public List<NetworkRegistrationState> getNetworkRegistrationStatesForTransportType( + public List<NetworkRegistrationInfo> getNetworkRegistrationInfoListForTransportType( @TransportType int transportType) { - List<NetworkRegistrationState> list = new ArrayList<>(); + List<NetworkRegistrationInfo> list = new ArrayList<>(); - synchronized (mNetworkRegistrationStates) { - for (NetworkRegistrationState networkRegistrationState : mNetworkRegistrationStates) { - if (networkRegistrationState.getTransportType() == transportType) { - list.add(networkRegistrationState); + synchronized (mNetworkRegistrationInfos) { + for (NetworkRegistrationInfo networkRegistrationInfo : mNetworkRegistrationInfos) { + if (networkRegistrationInfo.getTransportType() == transportType) { + list.add(networkRegistrationInfo); } } } @@ -1816,22 +1804,22 @@ public class ServiceState implements Parcelable { } /** - * Get the network registration states for the network domain. + * Get the network registration info list for the network domain. * - * @param domain The network {@link NetworkRegistrationState.Domain domain} - * @return List of {@link NetworkRegistrationState} + * @param domain The network {@link NetworkRegistrationInfo.Domain domain} + * @return List of {@link NetworkRegistrationInfo} * @hide */ @NonNull @SystemApi - public List<NetworkRegistrationState> getNetworkRegistrationStatesForDomain( + public List<NetworkRegistrationInfo> getNetworkRegistrationInfoListForDomain( @Domain int domain) { - List<NetworkRegistrationState> list = new ArrayList<>(); + List<NetworkRegistrationInfo> list = new ArrayList<>(); - synchronized (mNetworkRegistrationStates) { - for (NetworkRegistrationState networkRegistrationState : mNetworkRegistrationStates) { - if (networkRegistrationState.getDomain() == domain) { - list.add(networkRegistrationState); + synchronized (mNetworkRegistrationInfos) { + for (NetworkRegistrationInfo networkRegistrationInfo : mNetworkRegistrationInfos) { + if (networkRegistrationInfo.getDomain() == domain) { + list.add(networkRegistrationInfo); } } } @@ -1842,39 +1830,21 @@ public class ServiceState implements Parcelable { /** * Get the network registration state for the transport type and network domain. * - * @param domain The network {@link NetworkRegistrationState.Domain domain} - * @param transportType The transport type - * @return The matching {@link NetworkRegistrationState} - * @hide - * - * @deprecated Use {@link #getNetworkRegistrationState(int, int)} - */ - @Nullable - @Deprecated - @SystemApi - public NetworkRegistrationState getNetworkRegistrationStates(@Domain int domain, - @TransportType int transportType) { - return getNetworkRegistrationState(domain, transportType); - } - - /** - * Get the network registration state for the transport type and network domain. - * - * @param domain The network {@link NetworkRegistrationState.Domain domain} + * @param domain The network {@link NetworkRegistrationInfo.Domain domain} * @param transportType The transport type - * @return The matching {@link NetworkRegistrationState} + * @return The matching {@link NetworkRegistrationInfo} * @hide * */ @Nullable @SystemApi - public NetworkRegistrationState getNetworkRegistrationState(@Domain int domain, - @TransportType int transportType) { - synchronized (mNetworkRegistrationStates) { - for (NetworkRegistrationState networkRegistrationState : mNetworkRegistrationStates) { - if (networkRegistrationState.getTransportType() == transportType - && networkRegistrationState.getDomain() == domain) { - return networkRegistrationState; + public NetworkRegistrationInfo getNetworkRegistrationInfo(@Domain int domain, + @TransportType int transportType) { + synchronized (mNetworkRegistrationInfos) { + for (NetworkRegistrationInfo networkRegistrationInfo : mNetworkRegistrationInfos) { + if (networkRegistrationInfo.getTransportType() == transportType + && networkRegistrationInfo.getDomain() == domain) { + return networkRegistrationInfo; } } } @@ -1885,20 +1855,21 @@ public class ServiceState implements Parcelable { /** * @hide */ - public void addNetworkRegistrationState(NetworkRegistrationState regState) { + @TestApi + public void addNetworkRegistrationInfo(NetworkRegistrationInfo regState) { if (regState == null) return; - synchronized (mNetworkRegistrationStates) { - for (int i = 0; i < mNetworkRegistrationStates.size(); i++) { - NetworkRegistrationState curRegState = mNetworkRegistrationStates.get(i); + synchronized (mNetworkRegistrationInfos) { + for (int i = 0; i < mNetworkRegistrationInfos.size(); i++) { + NetworkRegistrationInfo curRegState = mNetworkRegistrationInfos.get(i); if (curRegState.getTransportType() == regState.getTransportType() && curRegState.getDomain() == regState.getDomain()) { - mNetworkRegistrationStates.remove(i); + mNetworkRegistrationInfos.remove(i); break; } } - mNetworkRegistrationStates.add(regState); + mNetworkRegistrationInfos.add(regState); } } @@ -1913,15 +1884,15 @@ public class ServiceState implements Parcelable { /** * Returns a copy of self with location-identifying information removed. - * Always clears the NetworkRegistrationState's CellIdentity fields, but if removeCoarseLocation + * Always clears the NetworkRegistrationInfo's CellIdentity fields, but if removeCoarseLocation * is true, clears other info as well. * @hide */ public ServiceState sanitizeLocationInfo(boolean removeCoarseLocation) { ServiceState state = new ServiceState(this); - if (state.mNetworkRegistrationStates != null) { - state.mNetworkRegistrationStates = state.mNetworkRegistrationStates.stream() - .map(NetworkRegistrationState::sanitizeLocationInfo) + if (state.mNetworkRegistrationInfos != null) { + state.mNetworkRegistrationInfos = state.mNetworkRegistrationInfos.stream() + .map(NetworkRegistrationInfo::sanitizeLocationInfo) .collect(Collectors.toList()); } if (!removeCoarseLocation) return state; diff --git a/telephony/java/android/telephony/SmsManager.java b/telephony/java/android/telephony/SmsManager.java index c39f1f5613b0..4d1b89c0e8ce 100644 --- a/telephony/java/android/telephony/SmsManager.java +++ b/telephony/java/android/telephony/SmsManager.java @@ -22,10 +22,6 @@ import android.annotation.SystemApi; import android.annotation.UnsupportedAppUsage; import android.app.ActivityThread; import android.app.PendingIntent; -import android.bluetooth.BluetoothAdapter; -import android.bluetooth.BluetoothDevice; -import android.bluetooth.BluetoothMapClient; -import android.bluetooth.BluetoothProfile; import android.content.ActivityNotFoundException; import android.content.ContentValues; import android.content.Context; @@ -36,7 +32,6 @@ import android.os.Build; import android.os.Bundle; import android.os.RemoteException; import android.os.ServiceManager; -import android.telecom.PhoneAccount; import android.text.TextUtils; import android.util.ArrayMap; import android.util.Log; @@ -66,7 +61,6 @@ import java.util.Map; */ public final class SmsManager { private static final String TAG = "SmsManager"; - private static final boolean DBG = false; /** * A psuedo-subId that represents the default subId at any given time. The actual subId it @@ -347,42 +341,11 @@ public final class SmsManager { throw new IllegalArgumentException("Invalid message body"); } - // A Manager code accessing another manager is *not* acceptable, in Android. - // In this particular case, it is unavoidable because of the following: - // If the subscription for this SmsManager instance belongs to a remote SIM - // then a listener to get BluetoothMapClient proxy needs to be started up. - // Doing that is possible only in a foreground thread or as a system user. - // i.e., Can't be done in ISms service. - // For that reason, SubscriptionManager needs to be accessed here to determine - // if the subscription belongs to a remote SIM. - // Ideally, there should be another API in ISms to service messages going thru - // remote SIM subscriptions (and ISms should be tweaked to be able to access - // BluetoothMapClient proxy) - Context context = ActivityThread.currentApplication().getApplicationContext(); - SubscriptionManager manager = (SubscriptionManager) context - .getSystemService(Context.TELEPHONY_SUBSCRIPTION_SERVICE); - int subId = getSubscriptionId(); - SubscriptionInfo info = manager.getActiveSubscriptionInfo(subId); - if (DBG) { - Log.d(TAG, "for subId: " + subId + ", subscription-info: " + info); - } - - /* If the Subscription associated with this SmsManager instance belongs to a remote-sim, - * then send the message thru the remote-sim subscription. - */ - if (info != null - && info.getSubscriptionType() == SubscriptionManager.SUBSCRIPTION_TYPE_REMOTE_SIM) { - if (DBG) Log.d(TAG, "sending message thru bluetooth"); - sendTextMessageBluetooth(destinationAddress, scAddress, text, sentIntent, - deliveryIntent, info); - return; - } - try { // If the subscription is invalid or default, we will use the default phone to send the // SMS and possibly fail later in the SMS sending process. - ISms iccISms = getISmsServiceOrThrow(); - iccISms.sendTextForSubscriber(subId, ActivityThread.currentPackageName(), + ISms iSms = getISmsServiceOrThrow(); + iSms.sendTextForSubscriber(getSubscriptionId(), ActivityThread.currentPackageName(), destinationAddress, scAddress, text, sentIntent, deliveryIntent, persistMessage); @@ -391,82 +354,6 @@ public final class SmsManager { } } - private void sendTextMessageBluetooth(String destAddr, String scAddress, - String text, PendingIntent sentIntent, PendingIntent deliveryIntent, - SubscriptionInfo info) { - BluetoothAdapter btAdapter = BluetoothAdapter.getDefaultAdapter(); - if (btAdapter == null) { - // No bluetooth service on this platform? - sendErrorInPendingIntent(sentIntent, SmsManager.RESULT_ERROR_NO_SERVICE); - return; - } - BluetoothDevice device = btAdapter.getRemoteDevice(info.getIccId()); - if (device == null) { - if (DBG) Log.d(TAG, "Bluetooth device addr invalid: " + info.getIccId()); - sendErrorInPendingIntent(sentIntent, SmsManager.RESULT_ERROR_NO_SERVICE); - return; - } - btAdapter.getProfileProxy(ActivityThread.currentApplication().getApplicationContext(), - new MapMessageSender(destAddr, text, device, sentIntent, deliveryIntent), - BluetoothProfile.MAP_CLIENT); - } - - private class MapMessageSender implements BluetoothProfile.ServiceListener { - final Uri[] mDestAddr; - private String mMessage; - final BluetoothDevice mDevice; - final PendingIntent mSentIntent; - final PendingIntent mDeliveryIntent; - MapMessageSender(final String destAddr, final String message, final BluetoothDevice device, - final PendingIntent sentIntent, final PendingIntent deliveryIntent) { - super(); - mDestAddr = new Uri[] {new Uri.Builder() - .appendPath(destAddr) - .scheme(PhoneAccount.SCHEME_TEL) - .build()}; - mMessage = message; - mDevice = device; - mSentIntent = sentIntent; - mDeliveryIntent = deliveryIntent; - } - - @Override - public void onServiceConnected(int profile, BluetoothProfile proxy) { - if (DBG) Log.d(TAG, "Service connected"); - if (profile != BluetoothProfile.MAP_CLIENT) return; - BluetoothMapClient mapProfile = (BluetoothMapClient) proxy; - if (mMessage != null) { - if (DBG) Log.d(TAG, "Sending message thru bluetooth"); - mapProfile.sendMessage(mDevice, mDestAddr, mMessage, mSentIntent, mDeliveryIntent); - mMessage = null; - } - BluetoothAdapter.getDefaultAdapter() - .closeProfileProxy(BluetoothProfile.MAP_CLIENT, mapProfile); - } - - @Override - public void onServiceDisconnected(int profile) { - if (mMessage != null) { - if (DBG) Log.d(TAG, "Bluetooth disconnected before sending the message"); - sendErrorInPendingIntent(mSentIntent, SmsManager.RESULT_ERROR_NO_SERVICE); - mMessage = null; - } - } - } - - private void sendErrorInPendingIntent(PendingIntent intent, int errorCode) { - if (intent == null) { - return; - } - try { - intent.send(errorCode); - } catch (PendingIntent.CanceledException e) { - // PendingIntent is cancelled. ignore sending this error code back to - // caller. - if (DBG) Log.d(TAG, "PendingIntent.CanceledException: " + e.getMessage()); - } - } - /** * Send a text based SMS without writing it into the SMS Provider. * @@ -516,8 +403,8 @@ public final class SmsManager { } try { - ISms iccISms = getISmsServiceOrThrow(); - iccISms.sendTextForSubscriberWithSelfPermissions(getSubscriptionId(), + ISms iSms = getISmsServiceOrThrow(); + iSms.sendTextForSubscriberWithSelfPermissions(getSubscriptionId(), ActivityThread.currentPackageName(), destinationAddress, scAddress, text, sentIntent, deliveryIntent, persistMessage); @@ -600,9 +487,9 @@ public final class SmsManager { } try { - ISms iccISms = getISmsServiceOrThrow(); - if (iccISms != null) { - iccISms.sendTextForSubscriberWithOptions(getSubscriptionId(), + ISms iSms = getISmsServiceOrThrow(); + if (iSms != null) { + iSms.sendTextForSubscriberWithOptions(getSubscriptionId(), ActivityThread.currentPackageName(), destinationAddress, scAddress, text, sentIntent, deliveryIntent, persistMessage, priority, expectMore, validityPeriod); @@ -661,9 +548,9 @@ public final class SmsManager { "Invalid pdu format. format must be either 3gpp or 3gpp2"); } try { - ISms iccISms = ISms.Stub.asInterface(ServiceManager.getService("isms")); - if (iccISms != null) { - iccISms.injectSmsPduForSubscriber( + ISms iSms = ISms.Stub.asInterface(ServiceManager.getService("isms")); + if (iSms != null) { + iSms.injectSmsPduForSubscriber( getSubscriptionId(), pdu, format, receivedIntent); } } catch (RemoteException ex) { @@ -749,8 +636,8 @@ public final class SmsManager { if (parts.size() > 1) { try { - ISms iccISms = getISmsServiceOrThrow(); - iccISms.sendMultipartTextForSubscriber(getSubscriptionId(), + ISms iSms = getISmsServiceOrThrow(); + iSms.sendMultipartTextForSubscriber(getSubscriptionId(), ActivityThread.currentPackageName(), destinationAddress, scAddress, parts, sentIntents, deliveryIntents, persistMessage); @@ -881,9 +768,9 @@ public final class SmsManager { if (parts.size() > 1) { try { - ISms iccISms = getISmsServiceOrThrow(); - if (iccISms != null) { - iccISms.sendMultipartTextForSubscriberWithOptions(getSubscriptionId(), + ISms iSms = getISmsServiceOrThrow(); + if (iSms != null) { + iSms.sendMultipartTextForSubscriberWithOptions(getSubscriptionId(), ActivityThread.currentPackageName(), destinationAddress, scAddress, parts, sentIntents, deliveryIntents, persistMessage, priority, expectMore, validityPeriod); @@ -969,8 +856,8 @@ public final class SmsManager { } try { - ISms iccISms = getISmsServiceOrThrow(); - iccISms.sendDataForSubscriber(getSubscriptionId(), ActivityThread.currentPackageName(), + ISms iSms = getISmsServiceOrThrow(); + iSms.sendDataForSubscriber(getSubscriptionId(), ActivityThread.currentPackageName(), destinationAddress, scAddress, destinationPort & 0xFFFF, data, sentIntent, deliveryIntent); } catch (RemoteException ex) { @@ -996,8 +883,8 @@ public final class SmsManager { } try { - ISms iccISms = getISmsServiceOrThrow(); - iccISms.sendDataForSubscriberWithSelfPermissions(getSubscriptionId(), + ISms iSms = getISmsServiceOrThrow(); + iSms.sendDataForSubscriberWithSelfPermissions(getSubscriptionId(), ActivityThread.currentPackageName(), destinationAddress, scAddress, destinationPort & 0xFFFF, data, sentIntent, deliveryIntent); } catch (RemoteException ex) { @@ -1059,9 +946,9 @@ public final class SmsManager { boolean isSmsSimPickActivityNeeded = false; final Context context = ActivityThread.currentApplication().getApplicationContext(); try { - ISms iccISms = getISmsService(); - if (iccISms != null) { - isSmsSimPickActivityNeeded = iccISms.isSmsSimPickActivityNeeded(subId); + ISms iSms = getISmsService(); + if (iSms != null) { + isSmsSimPickActivityNeeded = iSms.isSmsSimPickActivityNeeded(subId); } } catch (RemoteException ex) { Log.e(TAG, "Exception in getSubscriptionId"); @@ -1092,11 +979,11 @@ public final class SmsManager { * the service does not exist. */ private static ISms getISmsServiceOrThrow() { - ISms iccISms = getISmsService(); - if (iccISms == null) { + ISms iSms = getISmsService(); + if (iSms == null) { throw new UnsupportedOperationException("Sms is not supported"); } - return iccISms; + return iSms; } private static ISms getISmsService() { @@ -1125,9 +1012,9 @@ public final class SmsManager { throw new IllegalArgumentException("pdu is NULL"); } try { - ISms iccISms = getISmsService(); - if (iccISms != null) { - success = iccISms.copyMessageToIccEfForSubscriber(getSubscriptionId(), + ISms iSms = getISmsService(); + if (iSms != null) { + success = iSms.copyMessageToIccEfForSubscriber(getSubscriptionId(), ActivityThread.currentPackageName(), status, pdu, smsc); } @@ -1156,9 +1043,9 @@ public final class SmsManager { Arrays.fill(pdu, (byte)0xff); try { - ISms iccISms = getISmsService(); - if (iccISms != null) { - success = iccISms.updateMessageOnIccEfForSubscriber(getSubscriptionId(), + ISms iSms = getISmsService(); + if (iSms != null) { + success = iSms.updateMessageOnIccEfForSubscriber(getSubscriptionId(), ActivityThread.currentPackageName(), messageIndex, STATUS_ON_ICC_FREE, pdu); } @@ -1188,9 +1075,9 @@ public final class SmsManager { boolean success = false; try { - ISms iccISms = getISmsService(); - if (iccISms != null) { - success = iccISms.updateMessageOnIccEfForSubscriber(getSubscriptionId(), + ISms iSms = getISmsService(); + if (iSms != null) { + success = iSms.updateMessageOnIccEfForSubscriber(getSubscriptionId(), ActivityThread.currentPackageName(), messageIndex, newStatus, pdu); } @@ -1215,9 +1102,9 @@ public final class SmsManager { List<SmsRawData> records = null; try { - ISms iccISms = getISmsService(); - if (iccISms != null) { - records = iccISms.getAllMessagesFromIccEfForSubscriber( + ISms iSms = getISmsService(); + if (iSms != null) { + records = iSms.getAllMessagesFromIccEfForSubscriber( getSubscriptionId(), ActivityThread.currentPackageName()); } @@ -1252,9 +1139,9 @@ public final class SmsManager { boolean success = false; try { - ISms iccISms = getISmsService(); - if (iccISms != null) { - success = iccISms.enableCellBroadcastForSubscriber( + ISms iSms = getISmsService(); + if (iSms != null) { + success = iSms.enableCellBroadcastForSubscriber( getSubscriptionId(), messageIdentifier, ranType); } } catch (RemoteException ex) { @@ -1288,9 +1175,9 @@ public final class SmsManager { boolean success = false; try { - ISms iccISms = getISmsService(); - if (iccISms != null) { - success = iccISms.disableCellBroadcastForSubscriber( + ISms iSms = getISmsService(); + if (iSms != null) { + success = iSms.disableCellBroadcastForSubscriber( getSubscriptionId(), messageIdentifier, ranType); } } catch (RemoteException ex) { @@ -1331,9 +1218,9 @@ public final class SmsManager { throw new IllegalArgumentException("endMessageId < startMessageId"); } try { - ISms iccISms = getISmsService(); - if (iccISms != null) { - success = iccISms.enableCellBroadcastRangeForSubscriber(getSubscriptionId(), + ISms iSms = getISmsService(); + if (iSms != null) { + success = iSms.enableCellBroadcastRangeForSubscriber(getSubscriptionId(), startMessageId, endMessageId, ranType); } } catch (RemoteException ex) { @@ -1374,9 +1261,9 @@ public final class SmsManager { throw new IllegalArgumentException("endMessageId < startMessageId"); } try { - ISms iccISms = getISmsService(); - if (iccISms != null) { - success = iccISms.disableCellBroadcastRangeForSubscriber(getSubscriptionId(), + ISms iSms = getISmsService(); + if (iSms != null) { + success = iSms.disableCellBroadcastRangeForSubscriber(getSubscriptionId(), startMessageId, endMessageId, ranType); } } catch (RemoteException ex) { @@ -1426,9 +1313,9 @@ public final class SmsManager { public boolean isImsSmsSupported() { boolean boSupported = false; try { - ISms iccISms = getISmsService(); - if (iccISms != null) { - boSupported = iccISms.isImsSmsSupportedForSubscriber(getSubscriptionId()); + ISms iSms = getISmsService(); + if (iSms != null) { + boSupported = iSms.isImsSmsSupportedForSubscriber(getSubscriptionId()); } } catch (RemoteException ex) { // ignore it @@ -1451,9 +1338,9 @@ public final class SmsManager { public String getImsSmsFormat() { String format = com.android.internal.telephony.SmsConstants.FORMAT_UNKNOWN; try { - ISms iccISms = getISmsService(); - if (iccISms != null) { - format = iccISms.getImsSmsFormatForSubscriber(getSubscriptionId()); + ISms iSms = getISmsService(); + if (iSms != null) { + format = iSms.getImsSmsFormatForSubscriber(getSubscriptionId()); } } catch (RemoteException ex) { // ignore it @@ -1467,10 +1354,10 @@ public final class SmsManager { * @return the default SMS subscription id */ public static int getDefaultSmsSubscriptionId() { - ISms iccISms = null; + ISms iSms = null; try { - iccISms = ISms.Stub.asInterface(ServiceManager.getService("isms")); - return iccISms.getPreferredSmsSubscription(); + iSms = ISms.Stub.asInterface(ServiceManager.getService("isms")); + return iSms.getPreferredSmsSubscription(); } catch (RemoteException ex) { return -1; } catch (NullPointerException ex) { @@ -1486,10 +1373,10 @@ public final class SmsManager { */ @UnsupportedAppUsage public boolean isSMSPromptEnabled() { - ISms iccISms = null; + ISms iSms = null; try { - iccISms = ISms.Stub.asInterface(ServiceManager.getService("isms")); - return iccISms.isSMSPromptEnabled(); + iSms = ISms.Stub.asInterface(ServiceManager.getService("isms")); + return iSms.isSMSPromptEnabled(); } catch (RemoteException ex) { return false; } catch (NullPointerException ex) { @@ -1966,8 +1853,8 @@ public final class SmsManager { throw new IllegalArgumentException("Empty message URI"); } try { - ISms iccISms = getISmsServiceOrThrow(); - iccISms.sendStoredText( + ISms iSms = getISmsServiceOrThrow(); + iSms.sendStoredText( getSubscriptionId(), ActivityThread.currentPackageName(), messageUri, scAddress, sentIntent, deliveryIntent); } catch (RemoteException ex) { @@ -2014,8 +1901,8 @@ public final class SmsManager { throw new IllegalArgumentException("Empty message URI"); } try { - ISms iccISms = getISmsServiceOrThrow(); - iccISms.sendStoredMultipartText( + ISms iSms = getISmsServiceOrThrow(); + iSms.sendStoredMultipartText( getSubscriptionId(), ActivityThread.currentPackageName(), messageUri, scAddress, sentIntents, deliveryIntents); } catch (RemoteException ex) { diff --git a/telephony/java/android/telephony/SubscriptionInfo.java b/telephony/java/android/telephony/SubscriptionInfo.java index 58f12e2c427a..b781b109bdcc 100644 --- a/telephony/java/android/telephony/SubscriptionInfo.java +++ b/telephony/java/android/telephony/SubscriptionInfo.java @@ -467,7 +467,7 @@ public class SubscriptionInfo implements Parcelable { * @return group UUID a String of group UUID if it belongs to a group. Otherwise * it will return null. */ - public String getGroupUuid() { + public @Nullable String getGroupUuid() { return mGroupUUID; } diff --git a/telephony/java/android/telephony/SubscriptionManager.java b/telephony/java/android/telephony/SubscriptionManager.java index 0bbf054d7563..1377277bc8e2 100644 --- a/telephony/java/android/telephony/SubscriptionManager.java +++ b/telephony/java/android/telephony/SubscriptionManager.java @@ -63,6 +63,7 @@ import com.android.internal.telephony.ISetOpportunisticDataCallback; import com.android.internal.telephony.ISub; import com.android.internal.telephony.ITelephonyRegistry; import com.android.internal.telephony.PhoneConstants; +import com.android.internal.util.Preconditions; import java.lang.annotation.Retention; import java.lang.annotation.RetentionPolicy; @@ -1075,7 +1076,8 @@ public class SubscriptionManager { * @param listener that is to be unregistered. */ public void removeOnOpportunisticSubscriptionsChangedListener( - OnOpportunisticSubscriptionsChangedListener listener) { + @NonNull OnOpportunisticSubscriptionsChangedListener listener) { + Preconditions.checkNotNull(listener, "listener cannot be null"); String pkgForDebug = mContext != null ? mContext.getOpPackageName() : "<unknown>"; if (DBG) { logd("unregister OnOpportunisticSubscriptionsChangedListener pkgForDebug=" @@ -2699,7 +2701,8 @@ public class SubscriptionManager { * @param callbackIntent pending intent that will be sent after operation is done. */ @RequiresPermission(android.Manifest.permission.WRITE_EMBEDDED_SUBSCRIPTIONS) - public void switchToSubscription(int subId, PendingIntent callbackIntent) { + public void switchToSubscription(int subId, @NonNull PendingIntent callbackIntent) { + Preconditions.checkNotNull(callbackIntent, "callbackIntent cannot be null"); EuiccManager euiccManager = new EuiccManager(mContext); euiccManager.switchToSubscription(subId, callbackIntent); } diff --git a/telephony/java/android/telephony/TelephonyManager.java b/telephony/java/android/telephony/TelephonyManager.java index 973cd77916b5..f5ae945e5174 100644 --- a/telephony/java/android/telephony/TelephonyManager.java +++ b/telephony/java/android/telephony/TelephonyManager.java @@ -4755,18 +4755,22 @@ public class TelephonyManager { * Registers a listener object to receive notification of changes * in specified telephony states. * <p> - * To register a listener, pass a {@link PhoneStateListener} - * and specify at least one telephony state of interest in - * the events argument. - * - * At registration, and when a specified telephony state - * changes, the telephony manager invokes the appropriate - * callback method on the listener object and passes the - * current (updated) values. + * To register a listener, pass a {@link PhoneStateListener} and specify at least one telephony + * state of interest in the events argument. + * + * At registration, and when a specified telephony state changes, the telephony manager invokes + * the appropriate callback method on the listener object and passes the current (updated) + * values. * <p> - * To unregister a listener, pass the listener object and set the - * events argument to + * To un-register a listener, pass the listener object and set the events argument to * {@link PhoneStateListener#LISTEN_NONE LISTEN_NONE} (0). + * + * If this TelephonyManager object has been created with {@link #createForSubscriptionId}, + * applies to the given subId. Otherwise, applies to + * {@link SubscriptionManager#getDefaultSubscriptionId()}. To listen events for multiple subIds, + * pass a separate listener object to each TelephonyManager object created with + * {@link #createForSubscriptionId}. + * * Note: if you call this method while in the middle of a binder transaction, you <b>must</b> * call {@link android.os.Binder#clearCallingIdentity()} before calling this method. A * {@link SecurityException} will be thrown otherwise. @@ -4781,17 +4785,18 @@ public class TelephonyManager { if (mContext == null) return; try { boolean notifyNow = (getITelephony() != null); - // If the listener has not explicitly set the subId (for example, created with the - // default constructor), replace the subId so it will listen to the account the - // telephony manager is created with. - if (listener.mSubId == null) { - listener.mSubId = mSubId; - } - ITelephonyRegistry registry = getTelephonyRegistry(); if (registry != null) { - registry.listenForSubscriber(listener.mSubId, getOpPackageName(), + // listen to the subId the telephony manager is created with. Ignore subId in + // PhoneStateListener. + registry.listenForSubscriber(mSubId, getOpPackageName(), listener.callback, events, notifyNow); + // TODO: remove this once we remove PhoneStateListener constructor with subId. + if (events == PhoneStateListener.LISTEN_NONE) { + listener.mSubId = SubscriptionManager.INVALID_SUBSCRIPTION_ID; + } else { + listener.mSubId = mSubId; + } } else { Rlog.w(TAG, "telephony registry not ready."); } @@ -5267,7 +5272,6 @@ public class TelephonyManager { */ @RequiresPermission(Manifest.permission.MODIFY_PHONE_STATE) @SystemApi - @Nullable public boolean iccCloseLogicalChannelBySlot(int slotIndex, int channel) { try { ITelephony telephony = getITelephony(); @@ -5344,8 +5348,8 @@ public class TelephonyManager { * @param p3 P3 value of the APDU command. If p3 is negative a 4 byte APDU * is sent to the SIM. * @param data Data to be sent with the APDU. - * @return The APDU response from the ICC card with the status appended at - * the end. + * @return The APDU response from the ICC card with the status appended at the end, or null if + * there is an issue connecting to the Telephony service. * @hide */ @RequiresPermission(Manifest.permission.MODIFY_PHONE_STATE) @@ -6757,14 +6761,12 @@ public class TelephonyManager { } } catch (RemoteException ex) { Rlog.e(TAG, "getPreferredNetworkType RemoteException", ex); - } catch (NullPointerException ex) { - Rlog.e(TAG, "getPreferredNetworkType NPE", ex); } return -1; } /** - * Get the preferred network type bitmap. + * Get the preferred network type bitmask. * * <p>If this object has been created with {@link #createForSubscriptionId}, applies to the * given subId. Otherwise, applies to {@link SubscriptionManager#getDefaultSubscriptionId()} @@ -6773,13 +6775,13 @@ public class TelephonyManager { * {@link android.Manifest.permission#READ_PRIVILEGED_PHONE_STATE READ_PRIVILEGED_PHONE_STATE} * or that the calling app has carrier privileges (see {@link #hasCarrierPrivileges}). * - * @return The bitmap of preferred network types. + * @return The bitmask of preferred network types. * * @hide */ @RequiresPermission(android.Manifest.permission.READ_PRIVILEGED_PHONE_STATE) @SystemApi - public @NetworkTypeBitMask long getPreferredNetworkTypeBitmap() { + public @NetworkTypeBitMask long getPreferredNetworkTypeBitmask() { try { ITelephony telephony = getITelephony(); if (telephony != null) { @@ -6787,9 +6789,7 @@ public class TelephonyManager { telephony.getPreferredNetworkType(getSubId())); } } catch (RemoteException ex) { - Rlog.e(TAG, "getPreferredNetworkTypeBitmap RemoteException", ex); - } catch (NullPointerException ex) { - Rlog.e(TAG, "getPreferredNetworkTypeBitmap NPE", ex); + Rlog.e(TAG, "getPreferredNetworkTypeBitmask RemoteException", ex); } return 0; } @@ -6994,6 +6994,35 @@ public class TelephonyManager { } /** + * Query Telephony to see if there has recently been an emergency SMS sent to the network by the + * user and we are still within the time interval after the emergency SMS was sent that we are + * considered in Emergency SMS mode. + * + * <p>This mode is used by other applications to allow them to perform special functionality, + * such as allow the GNSS service to provide user location to the carrier network for emergency + * when an emergency SMS is sent. This interval is set by + * {@link CarrierConfigManager#KEY_EMERGENCY_SMS_MODE_TIMER_MS_INT}. If + * the carrier does not support this mode, this function will always return false. + * + * @return true if this device is in emergency SMS mode, false otherwise. + * + * @hide + */ + @RequiresPermission(android.Manifest.permission.READ_PRIVILEGED_PHONE_STATE) + public boolean isInEmergencySmsMode() { + + try { + ITelephony telephony = getITelephony(); + if (telephony != null) { + return telephony.isInEmergencySmsMode(); + } + } catch (RemoteException ex) { + Rlog.e(TAG, "getNetworkSelectionMode RemoteException", ex); + } + return false; + } + + /** * Set the preferred network type. * * <p>Requires Permission: @@ -7014,14 +7043,12 @@ public class TelephonyManager { } } catch (RemoteException ex) { Rlog.e(TAG, "setPreferredNetworkType RemoteException", ex); - } catch (NullPointerException ex) { - Rlog.e(TAG, "setPreferredNetworkType NPE", ex); } return false; } /** - * Set the preferred network type bitmap. + * Set the preferred network type bitmask. * * <p>If this object has been created with {@link #createForSubscriptionId}, applies to the * given subId. Otherwise, applies to {@link SubscriptionManager#getDefaultSubscriptionId()} @@ -7030,24 +7057,22 @@ public class TelephonyManager { * {@link android.Manifest.permission#MODIFY_PHONE_STATE MODIFY_PHONE_STATE} or that the calling * app has carrier privileges (see {@link #hasCarrierPrivileges}). * - * @param networkTypeBitmap The bitmap of preferred network types. + * @param networkTypeBitmask The bitmask of preferred network types. * @return true on success; false on any failure. * @hide */ @RequiresPermission(android.Manifest.permission.MODIFY_PHONE_STATE) @SystemApi - public boolean setPreferredNetworkTypeBitmap(@NetworkTypeBitMask long networkTypeBitmap) { + public boolean setPreferredNetworkTypeBitmask(@NetworkTypeBitMask long networkTypeBitmask) { try { ITelephony telephony = getITelephony(); if (telephony != null) { return telephony.setPreferredNetworkType( getSubId(), RadioAccessFamily.getNetworkTypeFromRaf( - (int) networkTypeBitmap)); + (int) networkTypeBitmask)); } } catch (RemoteException ex) { - Rlog.e(TAG, "setPreferredNetworkType RemoteException", ex); - } catch (NullPointerException ex) { - Rlog.e(TAG, "setPreferredNetworkType NPE", ex); + Rlog.e(TAG, "setPreferredNetworkTypeBitmask RemoteException", ex); } return false; } @@ -7082,10 +7107,21 @@ public class TelephonyManager { * @hide */ public boolean getTetherApnRequired() { + return getTetherApnRequired(getSubId(SubscriptionManager.getDefaultDataSubscriptionId())); + } + + /** + * Check whether DUN APN is required for tethering with subId. + * + * @param subId the id of the subscription to require tethering. + * @return {@code true} if DUN APN is required for tethering. + * @hide + */ + public boolean getTetherApnRequired(int subId) { try { ITelephony telephony = getITelephony(); if (telephony != null) - return telephony.getTetherApnRequired(); + return telephony.getTetherApnRequiredForSubscriber(subId); } catch (RemoteException ex) { Rlog.e(TAG, "hasMatchedTetherApnSetting RemoteException", ex); } catch (NullPointerException ex) { @@ -10512,45 +10548,77 @@ public class TelephonyManager { * <p>Note: the API does not prevent access to the SIM cards for operations that don't require * access to the network. * - * @param isMultisimCarrierRestricted true if usage of multiple SIMs is restricted, false + * @param isMultiSimCarrierRestricted true if usage of multiple SIMs is restricted, false * otherwise. * * @hide */ @SystemApi @RequiresPermission(android.Manifest.permission.MODIFY_PHONE_STATE) - public void setMultisimCarrierRestriction(boolean isMultisimCarrierRestricted) { + public void setMultiSimCarrierRestriction(boolean isMultiSimCarrierRestricted) { try { ITelephony service = getITelephony(); if (service != null) { - service.setMultisimCarrierRestriction(isMultisimCarrierRestricted); + service.setMultiSimCarrierRestriction(isMultiSimCarrierRestricted); } } catch (RemoteException e) { - Log.e(TAG, "setMultisimCarrierRestriction RemoteException", e); + Log.e(TAG, "setMultiSimCarrierRestriction RemoteException", e); } } /** + * The usage of multiple SIM cards at the same time to register on the network (e.g. Dual + * Standby or Dual Active) is supported. + */ + public static final int MULTISIM_ALLOWED = 0; + + /** + * The usage of multiple SIM cards at the same time to register on the network (e.g. Dual + * Standby or Dual Active) is not supported by the hardware. + */ + public static final int MULTISIM_NOT_SUPPORTED_BY_HARDWARE = 1; + + /** + * The usage of multiple SIM cards at the same time to register on the network (e.g. Dual + * Standby or Dual Active) is supported by the hardware, but restricted by the carrier. + */ + public static final int MULTISIM_NOT_SUPPORTED_BY_CARRIER = 2; + + /** @hide */ + @Retention(RetentionPolicy.SOURCE) + @IntDef(prefix = {"MULTISIM_"}, + value = { + MULTISIM_ALLOWED, + MULTISIM_NOT_SUPPORTED_BY_HARDWARE, + MULTISIM_NOT_SUPPORTED_BY_CARRIER + }) + public @interface IsMultiSimSupportedResult {} + + /** * Returns if the usage of multiple SIM cards at the same time to register on the network * (e.g. Dual Standby or Dual Active) is supported by the device and by the carrier. * * <p>Requires Permission: {@link android.Manifest.permission#READ_PHONE_STATE READ_PHONE_STATE} * or that the calling app has carrier privileges (see {@link #hasCarrierPrivileges}). * - * @return true if usage of multiple SIMs is supported, false otherwise. + * @return {@link #MULTISIM_ALLOWED} if the device supports multiple SIMs. + * {@link #MULTISIM_NOT_SUPPORTED_BY_HARDWARE} if the device does not support multiple SIMs. + * {@link #MULTISIM_NOT_SUPPORTED_BY_CARRIER} in the device supports multiple SIMs, but the + * functionality is restricted by the carrier. */ @SuppressAutoDoc // Blocked by b/72967236 - no support for carrier privileges @RequiresPermission(android.Manifest.permission.READ_PHONE_STATE) - public boolean isMultisimSupported() { + @IsMultiSimSupportedResult + public int isMultiSimSupported() { try { ITelephony service = getITelephony(); if (service != null) { - return service.isMultisimSupported(getOpPackageName()); + return service.isMultiSimSupported(getOpPackageName()); } } catch (RemoteException e) { - Log.e(TAG, "isMultisimSupported RemoteException", e); + Log.e(TAG, "isMultiSimSupported RemoteException", e); } - return false; + return MULTISIM_NOT_SUPPORTED_BY_HARDWARE; } /** diff --git a/telephony/java/android/telephony/VoiceSpecificRegistrationStates.java b/telephony/java/android/telephony/VoiceSpecificRegistrationInfo.java index 871ee4d9f0a1..18a533a46273 100644 --- a/telephony/java/android/telephony/VoiceSpecificRegistrationStates.java +++ b/telephony/java/android/telephony/VoiceSpecificRegistrationInfo.java @@ -1,5 +1,22 @@ +/* + * Copyright 2018 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 android.telephony; +import android.annotation.NonNull; import android.os.Parcel; import android.os.Parcelable; @@ -10,14 +27,14 @@ import java.util.Objects; * Class that stores information specific to voice network registration. * @hide */ -public class VoiceSpecificRegistrationStates implements Parcelable{ +public class VoiceSpecificRegistrationInfo implements Parcelable{ /** * oncurrent services support indicator. if * registered on a CDMA system. * false - Concurrent services not supported, * true - Concurrent services supported */ - public final boolean cssSupported; + public final boolean cssSupported; /** * TSB-58 Roaming Indicator if registered @@ -40,15 +57,15 @@ public class VoiceSpecificRegistrationStates implements Parcelable{ */ public final int defaultRoamingIndicator; - VoiceSpecificRegistrationStates(boolean cssSupported, int roamingIndicator, int systemIsInPrl, - int defaultRoamingIndicator) { + VoiceSpecificRegistrationInfo(boolean cssSupported, int roamingIndicator, int systemIsInPrl, + int defaultRoamingIndicator) { this.cssSupported = cssSupported; this.roamingIndicator = roamingIndicator; this.systemIsInPrl = systemIsInPrl; this.defaultRoamingIndicator = defaultRoamingIndicator; } - private VoiceSpecificRegistrationStates(Parcel source) { + private VoiceSpecificRegistrationInfo(Parcel source) { this.cssSupported = source.readBoolean(); this.roamingIndicator = source.readInt(); this.systemIsInPrl = source.readInt(); @@ -70,7 +87,7 @@ public class VoiceSpecificRegistrationStates implements Parcelable{ @Override public String toString() { - return "VoiceSpecificRegistrationStates {" + return "VoiceSpecificRegistrationInfo {" + " mCssSupported=" + cssSupported + " mRoamingIndicator=" + roamingIndicator + " mSystemIsInPrl=" + systemIsInPrl @@ -87,11 +104,11 @@ public class VoiceSpecificRegistrationStates implements Parcelable{ public boolean equals(Object o) { if (this == o) return true; - if (o == null || !(o instanceof VoiceSpecificRegistrationStates)) { + if (o == null || !(o instanceof VoiceSpecificRegistrationInfo)) { return false; } - VoiceSpecificRegistrationStates other = (VoiceSpecificRegistrationStates) o; + VoiceSpecificRegistrationInfo other = (VoiceSpecificRegistrationInfo) o; return this.cssSupported == other.cssSupported && this.roamingIndicator == other.roamingIndicator && this.systemIsInPrl == other.systemIsInPrl @@ -99,16 +116,16 @@ public class VoiceSpecificRegistrationStates implements Parcelable{ } - public static final Parcelable.Creator<VoiceSpecificRegistrationStates> CREATOR = - new Parcelable.Creator<VoiceSpecificRegistrationStates>() { + public static final @NonNull Parcelable.Creator<VoiceSpecificRegistrationInfo> CREATOR = + new Parcelable.Creator<VoiceSpecificRegistrationInfo>() { @Override - public VoiceSpecificRegistrationStates createFromParcel(Parcel source) { - return new VoiceSpecificRegistrationStates(source); + public VoiceSpecificRegistrationInfo createFromParcel(Parcel source) { + return new VoiceSpecificRegistrationInfo(source); } @Override - public VoiceSpecificRegistrationStates[] newArray(int size) { - return new VoiceSpecificRegistrationStates[size]; + public VoiceSpecificRegistrationInfo[] newArray(int size) { + return new VoiceSpecificRegistrationInfo[size]; } }; -}
\ No newline at end of file +} diff --git a/telephony/java/android/telephony/data/ApnSetting.java b/telephony/java/android/telephony/data/ApnSetting.java index ae2c1d1f1e72..4b9abc1e6f33 100644 --- a/telephony/java/android/telephony/data/ApnSetting.java +++ b/telephony/java/android/telephony/data/ApnSetting.java @@ -17,6 +17,7 @@ package android.telephony.data; import android.annotation.IntDef; import android.annotation.NonNull; +import android.annotation.Nullable; import android.content.ContentValues; import android.database.Cursor; import android.hardware.radio.V1_4.ApnTypes; @@ -1620,7 +1621,7 @@ public class ApnSetting implements Parcelable { * @param mvnoMatchData the MVNO match data for the APN * @hide */ - public Builder setMvnoMatchData(String mvnoMatchData) { + public Builder setMvnoMatchData(@Nullable String mvnoMatchData) { this.mMvnoMatchData = mvnoMatchData; return this; } @@ -1642,7 +1643,7 @@ public class ApnSetting implements Parcelable { * @param entryName the entry name to set for the APN */ @NonNull - public Builder setEntryName(String entryName) { + public Builder setEntryName(@Nullable String entryName) { this.mEntryName = entryName; return this; } @@ -1653,7 +1654,7 @@ public class ApnSetting implements Parcelable { * @param apnName the name to set for the APN */ @NonNull - public Builder setApnName(String apnName) { + public Builder setApnName(@Nullable String apnName) { this.mApnName = apnName; return this; } @@ -1684,7 +1685,7 @@ public class ApnSetting implements Parcelable { * @param proxy the proxy address to set for the APN */ @NonNull - public Builder setProxyAddress(String proxy) { + public Builder setProxyAddress(@Nullable String proxy) { this.mProxyAddress = proxy; return this; } @@ -1706,7 +1707,7 @@ public class ApnSetting implements Parcelable { * @param mmsc the MMSC Uri to set for the APN */ @NonNull - public Builder setMmsc(Uri mmsc) { + public Builder setMmsc(@Nullable Uri mmsc) { this.mMmsc = mmsc; return this; } @@ -1738,7 +1739,7 @@ public class ApnSetting implements Parcelable { * @param mmsProxy the MMS proxy address to set for the APN */ @NonNull - public Builder setMmsProxyAddress(String mmsProxy) { + public Builder setMmsProxyAddress(@Nullable String mmsProxy) { this.mMmsProxyAddress = mmsProxy; return this; } @@ -1760,7 +1761,7 @@ public class ApnSetting implements Parcelable { * @param user the APN username to set for the APN */ @NonNull - public Builder setUser(String user) { + public Builder setUser(@Nullable String user) { this.mUser = user; return this; } @@ -1772,7 +1773,7 @@ public class ApnSetting implements Parcelable { * @param password the APN password to set for the APN */ @NonNull - public Builder setPassword(String password) { + public Builder setPassword(@Nullable String password) { this.mPassword = password; return this; } @@ -1813,7 +1814,7 @@ public class ApnSetting implements Parcelable { * @param operatorNumeric the numeric operator ID to set for this entry */ @NonNull - public Builder setOperatorNumeric(String operatorNumeric) { + public Builder setOperatorNumeric(@Nullable String operatorNumeric) { this.mOperatorNumeric = operatorNumeric; return this; } diff --git a/telephony/java/android/telephony/data/DataCallResponse.java b/telephony/java/android/telephony/data/DataCallResponse.java index 6d74deda1ac4..3806a7e2cbe0 100644 --- a/telephony/java/android/telephony/data/DataCallResponse.java +++ b/telephony/java/android/telephony/data/DataCallResponse.java @@ -17,16 +17,21 @@ package android.telephony.data; +import android.annotation.IntDef; import android.annotation.NonNull; import android.annotation.Nullable; import android.annotation.SystemApi; import android.net.LinkAddress; import android.os.Parcel; import android.os.Parcelable; +import android.telephony.DataFailCause; +import android.telephony.DataFailCause.FailCause; import android.telephony.data.ApnSetting.ProtocolType; import com.android.internal.annotations.VisibleForTesting; +import java.lang.annotation.Retention; +import java.lang.annotation.RetentionPolicy; import java.net.InetAddress; import java.util.ArrayList; import java.util.List; @@ -39,83 +44,114 @@ import java.util.Objects; */ @SystemApi public final class DataCallResponse implements Parcelable { - private final int mStatus; + + /** {@hide} */ + @IntDef(prefix = "LINK_STATUS_", value = { + LINK_STATUS_UNKNOWN, + LINK_STATUS_INACTIVE, + LINK_STATUS_DORMANT, + LINK_STATUS_ACTIVE + }) + @Retention(RetentionPolicy.SOURCE) + public @interface LinkStatus {} + + /** Unknown status */ + public static final int LINK_STATUS_UNKNOWN = -1; + + /** Indicates the data connection is inactive. */ + public static final int LINK_STATUS_INACTIVE = 0; + + /** Indicates the data connection is active with physical link dormant. */ + public static final int LINK_STATUS_DORMANT = 1; + + /** Indicates the data connection is active with physical link up. */ + public static final int LINK_STATUS_ACTIVE = 2; + + private final @FailCause int mCause; private final int mSuggestedRetryTime; - private final int mCid; - private final int mActive; - private final int mProtocolType; - private final String mIfname; + private final int mId; + private final @LinkStatus int mLinkStatus; + private final @ProtocolType int mProtocolType; + private final String mInterfaceName; private final List<LinkAddress> mAddresses; - private final List<InetAddress> mDnses; - private final List<InetAddress> mGateways; - private final List<String> mPcscfs; + private final List<InetAddress> mDnsAddresses; + private final List<InetAddress> mGatewayAddresses; + private final List<InetAddress> mPcscfAddresses; private final int mMtu; /** - * @param status Data call fail cause. 0 indicates no error. + * @param cause Data call fail cause. {@link DataFailCause#NONE} indicates no error. * @param suggestedRetryTime The suggested data retry time in milliseconds. - * @param cid The unique id of the data connection. - * @param active Data connection active status. 0 = inactive, 1 = dormant, 2 = active. + * @param id The unique id of the data connection. + * @param linkStatus Data connection link status. * @param protocolType The connection protocol, should be one of the PDP_type values in 3GPP - * TS 27.007 section 10.1.1. For example, "IP", "IPV6", "IPV4V6", or "PPP". - * @param ifname The network interface name. + * TS 27.007 section 10.1.1. For example, "IP", "IPV6", "IPV4V6", or "PPP". + * @param interfaceName The network interface name. * @param addresses A list of addresses with optional "/" prefix length, e.g., - * "192.0.1.3" or "192.0.1.11/16 2001:db8::1/64". Typically 1 IPv4 or 1 IPv6 or - * one of each. If the prefix length is absent the addresses are assumed to be - * point to point with IPv4 having a prefix length of 32 and IPv6 128. - * @param dnses A list of DNS server addresses, e.g., "192.0.1.3" or - * "192.0.1.11 2001:db8::1". Null if no dns server addresses returned. - * @param gateways A list of default gateway addresses, e.g., "192.0.1.3" or - * "192.0.1.11 2001:db8::1". When null, the addresses represent point to point - * connections. - * @param pcscfs A list of Proxy Call State Control Function address via PCO(Protocol - * Configuration Option) for IMS client. - * @param mtu MTU (Maximum transmission unit) received from network Value <= 0 means network has - * either not sent a value or sent an invalid value. + * "192.0.1.3" or "192.0.1.11/16 2001:db8::1/64". Typically 1 IPv4 or 1 IPv6 or + * one of each. If the prefix length is absent the addresses are assumed to be + * point to point with IPv4 having a prefix length of 32 and IPv6 128. + * @param dnsAddresses A list of DNS server addresses, e.g., "192.0.1.3" or + * "192.0.1.11 2001:db8::1". Null if no dns server addresses returned. + * @param gatewayAddresses A list of default gateway addresses, e.g., "192.0.1.3" or + * "192.0.1.11 2001:db8::1". When null, the addresses represent point to point connections. + * @param pcscfAddresses A list of Proxy Call State Control Function address via PCO (Protocol + * Configuration Option) for IMS client. + * @param mtu MTU (maximum transmission unit) in bytes received from network. Zero or negative + * values means network has either not sent a value or sent an invalid value. + * either not sent a value or sent an invalid value. + * + * @removed Use the {@link Builder()} instead. */ - public DataCallResponse(int status, int suggestedRetryTime, int cid, int active, - @ProtocolType int protocolType, @Nullable String ifname, + public DataCallResponse(@FailCause int cause, int suggestedRetryTime, int id, + @LinkStatus int linkStatus, + @ProtocolType int protocolType, @Nullable String interfaceName, @Nullable List<LinkAddress> addresses, - @Nullable List<InetAddress> dnses, - @Nullable List<InetAddress> gateways, - @Nullable List<String> pcscfs, int mtu) { - mStatus = status; + @Nullable List<InetAddress> dnsAddresses, + @Nullable List<InetAddress> gatewayAddresses, + @Nullable List<InetAddress> pcscfAddresses, int mtu) { + mCause = cause; mSuggestedRetryTime = suggestedRetryTime; - mCid = cid; - mActive = active; + mId = id; + mLinkStatus = linkStatus; mProtocolType = protocolType; - mIfname = (ifname == null) ? "" : ifname; - mAddresses = (addresses == null) ? new ArrayList<>() : addresses; - mDnses = (dnses == null) ? new ArrayList<>() : dnses; - mGateways = (gateways == null) ? new ArrayList<>() : gateways; - mPcscfs = (pcscfs == null) ? new ArrayList<>() : pcscfs; + mInterfaceName = (interfaceName == null) ? "" : interfaceName; + mAddresses = (addresses == null) + ? new ArrayList<>() : new ArrayList<>(addresses); + mDnsAddresses = (dnsAddresses == null) + ? new ArrayList<>() : new ArrayList<>(dnsAddresses); + mGatewayAddresses = (gatewayAddresses == null) + ? new ArrayList<>() : new ArrayList<>(gatewayAddresses); + mPcscfAddresses = (pcscfAddresses == null) + ? new ArrayList<>() : new ArrayList<>(pcscfAddresses); mMtu = mtu; } /** @hide */ @VisibleForTesting public DataCallResponse(Parcel source) { - mStatus = source.readInt(); + mCause = source.readInt(); mSuggestedRetryTime = source.readInt(); - mCid = source.readInt(); - mActive = source.readInt(); + mId = source.readInt(); + mLinkStatus = source.readInt(); mProtocolType = source.readInt(); - mIfname = source.readString(); + mInterfaceName = source.readString(); mAddresses = new ArrayList<>(); source.readList(mAddresses, LinkAddress.class.getClassLoader()); - mDnses = new ArrayList<>(); - source.readList(mDnses, InetAddress.class.getClassLoader()); - mGateways = new ArrayList<>(); - source.readList(mGateways, InetAddress.class.getClassLoader()); - mPcscfs = new ArrayList<>(); - source.readList(mPcscfs, InetAddress.class.getClassLoader()); + mDnsAddresses = new ArrayList<>(); + source.readList(mDnsAddresses, InetAddress.class.getClassLoader()); + mGatewayAddresses = new ArrayList<>(); + source.readList(mGatewayAddresses, InetAddress.class.getClassLoader()); + mPcscfAddresses = new ArrayList<>(); + source.readList(mPcscfAddresses, InetAddress.class.getClassLoader()); mMtu = source.readInt(); } /** - * @return Data call fail cause. 0 indicates no error. + * @return Data call fail cause. {@link DataFailCause#NONE} indicates no error. */ - public int getStatus() { return mStatus; } + @FailCause + public int getCause() { return mCause; } /** * @return The suggested data retry time in milliseconds. @@ -125,12 +161,12 @@ public final class DataCallResponse implements Parcelable { /** * @return The unique id of the data connection. */ - public int getCallId() { return mCid; } + public int getId() { return mId; } /** - * @return 0 = inactive, 1 = dormant, 2 = active. + * @return The link status */ - public int getActive() { return mActive; } + @LinkStatus public int getLinkStatus() { return mLinkStatus; } /** * @return The connection protocol type. @@ -139,13 +175,13 @@ public final class DataCallResponse implements Parcelable { public int getProtocolType() { return mProtocolType; } /** - * @return The network interface name. + * @return The network interface name (e.g. "rmnet_data1"). */ @NonNull - public String getIfname() { return mIfname; } + public String getInterfaceName() { return mInterfaceName; } /** - * @return A list of {@link LinkAddress} + * @return A list of addresses of this data connection. */ @NonNull public List<LinkAddress> getAddresses() { return mAddresses; } @@ -155,25 +191,25 @@ public final class DataCallResponse implements Parcelable { * "192.0.1.11 2001:db8::1". Empty list if no dns server addresses returned. */ @NonNull - public List<InetAddress> getDnses() { return mDnses; } + public List<InetAddress> getDnsAddresses() { return mDnsAddresses; } /** * @return A list of default gateway addresses, e.g., "192.0.1.3" or * "192.0.1.11 2001:db8::1". Empty list if the addresses represent point to point connections. */ @NonNull - public List<InetAddress> getGateways() { return mGateways; } + public List<InetAddress> getGatewayAddresses() { return mGatewayAddresses; } /** - * @return A list of Proxy Call State Control Function address via PCO(Protocol Configuration + * @return A list of Proxy Call State Control Function address via PCO (Protocol Configuration * Option) for IMS client. */ @NonNull - public List<String> getPcscfs() { return mPcscfs; } + public List<InetAddress> getPcscfAddresses() { return mPcscfAddresses; } /** - * @return MTU received from network Value <= 0 means network has either not sent a value or - * sent an invalid value + * @return MTU (maximum transmission unit) in bytes received from network. Zero or negative + * values means network has either not sent a value or sent an invalid value. */ public int getMtu() { return mMtu; } @@ -181,16 +217,16 @@ public final class DataCallResponse implements Parcelable { public String toString() { StringBuffer sb = new StringBuffer(); sb.append("DataCallResponse: {") - .append(" status=").append(mStatus) + .append(" cause=").append(mCause) .append(" retry=").append(mSuggestedRetryTime) - .append(" cid=").append(mCid) - .append(" active=").append(mActive) + .append(" cid=").append(mId) + .append(" linkStatus=").append(mLinkStatus) .append(" protocolType=").append(mProtocolType) - .append(" ifname=").append(mIfname) + .append(" ifname=").append(mInterfaceName) .append(" addresses=").append(mAddresses) - .append(" dnses=").append(mDnses) - .append(" gateways=").append(mGateways) - .append(" pcscf=").append(mPcscfs) + .append(" dnses=").append(mDnsAddresses) + .append(" gateways=").append(mGatewayAddresses) + .append(" pcscf=").append(mPcscfAddresses) .append(" mtu=").append(mMtu) .append("}"); return sb.toString(); @@ -200,32 +236,33 @@ public final class DataCallResponse implements Parcelable { public boolean equals (Object o) { if (this == o) return true; - if (o == null || !(o instanceof DataCallResponse)) { + if (!(o instanceof DataCallResponse)) { return false; } DataCallResponse other = (DataCallResponse) o; - return this.mStatus == other.mStatus + return this.mCause == other.mCause && this.mSuggestedRetryTime == other.mSuggestedRetryTime - && this.mCid == other.mCid - && this.mActive == other.mActive + && this.mId == other.mId + && this.mLinkStatus == other.mLinkStatus && this.mProtocolType == other.mProtocolType - && this.mIfname.equals(other.mIfname) + && this.mInterfaceName.equals(other.mInterfaceName) && mAddresses.size() == other.mAddresses.size() && mAddresses.containsAll(other.mAddresses) - && mDnses.size() == other.mDnses.size() - && mDnses.containsAll(other.mDnses) - && mGateways.size() == other.mGateways.size() - && mGateways.containsAll(other.mGateways) - && mPcscfs.size() == other.mPcscfs.size() - && mPcscfs.containsAll(other.mPcscfs) + && mDnsAddresses.size() == other.mDnsAddresses.size() + && mDnsAddresses.containsAll(other.mDnsAddresses) + && mGatewayAddresses.size() == other.mGatewayAddresses.size() + && mGatewayAddresses.containsAll(other.mGatewayAddresses) + && mPcscfAddresses.size() == other.mPcscfAddresses.size() + && mPcscfAddresses.containsAll(other.mPcscfAddresses) && mMtu == other.mMtu; } @Override public int hashCode() { - return Objects.hash(mStatus, mSuggestedRetryTime, mCid, mActive, mProtocolType, mIfname, - mAddresses, mDnses, mGateways, mPcscfs, mMtu); + return Objects.hash(mCause, mSuggestedRetryTime, mId, mLinkStatus, mProtocolType, + mInterfaceName, mAddresses, mDnsAddresses, mGatewayAddresses, mPcscfAddresses, + mMtu); } @Override @@ -235,20 +272,20 @@ public final class DataCallResponse implements Parcelable { @Override public void writeToParcel(Parcel dest, int flags) { - dest.writeInt(mStatus); + dest.writeInt(mCause); dest.writeInt(mSuggestedRetryTime); - dest.writeInt(mCid); - dest.writeInt(mActive); + dest.writeInt(mId); + dest.writeInt(mLinkStatus); dest.writeInt(mProtocolType); - dest.writeString(mIfname); + dest.writeString(mInterfaceName); dest.writeList(mAddresses); - dest.writeList(mDnses); - dest.writeList(mGateways); - dest.writeList(mPcscfs); + dest.writeList(mDnsAddresses); + dest.writeList(mGatewayAddresses); + dest.writeList(mPcscfAddresses); dest.writeInt(mMtu); } - public static final Parcelable.Creator<DataCallResponse> CREATOR = + public static final @NonNull Parcelable.Creator<DataCallResponse> CREATOR = new Parcelable.Creator<DataCallResponse>() { @Override public DataCallResponse createFromParcel(Parcel source) { @@ -260,4 +297,183 @@ public final class DataCallResponse implements Parcelable { return new DataCallResponse[size]; } }; -}
\ No newline at end of file + + /** + * Provides a convenient way to set the fields of a {@link DataCallResponse} when creating a new + * instance. + * + * <p>The example below shows how you might create a new {@code DataCallResponse}: + * + * <pre><code> + * + * DataCallResponse response = new DataCallResponse.Builder() + * .setAddresses(Arrays.asList("192.168.1.2")) + * .setProtocolType(ApnSetting.PROTOCOL_IPV4V6) + * .build(); + * </code></pre> + */ + public static final class Builder { + private @FailCause int mCause; + + private int mSuggestedRetryTime; + + private int mId; + + private @LinkStatus int mLinkStatus; + + private @ProtocolType int mProtocolType; + + private String mInterfaceName; + + private List<LinkAddress> mAddresses; + + private List<InetAddress> mDnsAddresses; + + private List<InetAddress> mGatewayAddresses; + + private List<InetAddress> mPcscfAddresses; + + private int mMtu; + + /** + * Default constructor for Builder. + */ + public Builder() { + } + + /** + * Set data call fail cause. + * + * @param cause Data call fail cause. {@link DataFailCause#NONE} indicates no error. + * @return The same instance of the builder. + */ + public @NonNull Builder setCause(@FailCause int cause) { + mCause = cause; + return this; + } + + /** + * Set the suggested data retry time. + * + * @param suggestedRetryTime The suggested data retry time in milliseconds. + * @return The same instance of the builder. + */ + public @NonNull Builder setSuggestedRetryTime(int suggestedRetryTime) { + mSuggestedRetryTime = suggestedRetryTime; + return this; + } + + /** + * Set the unique id of the data connection. + * + * @param id The unique id of the data connection. + * @return The same instance of the builder. + */ + public @NonNull Builder setId(int id) { + mId = id; + return this; + } + + /** + * Set the link status + * + * @param linkStatus The link status + * @return The same instance of the builder. + */ + public @NonNull Builder setLinkStatus(@LinkStatus int linkStatus) { + mLinkStatus = linkStatus; + return this; + } + + /** + * Set the connection protocol type. + * + * @param protocolType The connection protocol type. + * @return The same instance of the builder. + */ + public @NonNull Builder setProtocolType(@ProtocolType int protocolType) { + mProtocolType = protocolType; + return this; + } + + /** + * Set the network interface name. + * + * @param interfaceName The network interface name (e.g. "rmnet_data1"). + * @return The same instance of the builder. + */ + public @NonNull Builder setInterfaceName(@NonNull String interfaceName) { + mInterfaceName = interfaceName; + return this; + } + + /** + * Set the addresses of this data connection. + * + * @param addresses The list of address of the data connection. + * @return The same instance of the builder. + */ + public @NonNull Builder setAddresses(@NonNull List<LinkAddress> addresses) { + mAddresses = addresses; + return this; + } + + /** + * Set the DNS addresses of this data connection + * + * @param dnsAddresses The list of DNS address of the data connection. + * @return The same instance of the builder. + */ + public @NonNull Builder setDnsAddresses(@NonNull List<InetAddress> dnsAddresses) { + mDnsAddresses = dnsAddresses; + return this; + } + + /** + * Set the gateway addresses of this data connection + * + * @param gatewayAddresses The list of gateway address of the data connection. + * @return The same instance of the builder. + */ + public @NonNull Builder setGatewayAddresses(@NonNull List<InetAddress> gatewayAddresses) { + mGatewayAddresses = gatewayAddresses; + return this; + } + + /** + * Set the Proxy Call State Control Function address via PCO(Protocol Configuration + * Option) for IMS client. + * + * @param pcscfAddresses The list of pcscf address of the data connection. + * @return The same instance of the builder. + */ + public @NonNull Builder setPcscfAddresses(@NonNull List<InetAddress> pcscfAddresses) { + mPcscfAddresses = pcscfAddresses; + return this; + } + + /** + * Set maximum transmission unit of the data connection. + * + * @param mtu MTU (maximum transmission unit) in bytes received from network. Zero or + * negative values means network has either not sent a value or sent an invalid value. + * + * @return The same instance of the builder. + */ + public @NonNull Builder setMtu(int mtu) { + mMtu = mtu; + return this; + } + + /** + * Build the DataCallResponse. + * + * @return the DataCallResponse object. + */ + public @NonNull DataCallResponse build() { + return new DataCallResponse(mCause, mSuggestedRetryTime, mId, mLinkStatus, + mProtocolType, mInterfaceName, mAddresses, mDnsAddresses, mGatewayAddresses, + mPcscfAddresses, mMtu); + } + } +} diff --git a/telephony/java/android/telephony/data/DataProfile.java b/telephony/java/android/telephony/data/DataProfile.java index 1d196f9b2885..c53ade16cae4 100644 --- a/telephony/java/android/telephony/data/DataProfile.java +++ b/telephony/java/android/telephony/data/DataProfile.java @@ -19,6 +19,8 @@ package android.telephony.data; import static android.telephony.data.ApnSetting.ProtocolType; import android.annotation.IntDef; +import android.annotation.NonNull; +import android.annotation.Nullable; import android.annotation.SystemApi; import android.os.Build; import android.os.Parcel; @@ -32,6 +34,7 @@ import com.android.internal.telephony.RILConstants; import java.lang.annotation.Retention; import java.lang.annotation.RetentionPolicy; +import java.util.Objects; /** * Description of a mobile data profile used for establishing @@ -48,7 +51,7 @@ public final class DataProfile implements Parcelable { TYPE_COMMON, TYPE_3GPP, TYPE_3GPP2}) - public @interface DataProfileType {} + public @interface Type {} /** Common data profile */ public static final int TYPE_COMMON = 0; @@ -73,25 +76,25 @@ public final class DataProfile implements Parcelable { private final String mPassword; - @DataProfileType + @Type private final int mType; - private final int mMaxConnsTime; + private final int mMaxConnectionsTime; - private final int mMaxConns; + private final int mMaxConnections; private final int mWaitTime; private final boolean mEnabled; @ApnType - private final int mSupportedApnTypesBitmap; + private final int mSupportedApnTypesBitmask; @ProtocolType private final int mRoamingProtocolType; @NetworkTypeBitMask - private final int mBearerBitmap; + private final int mBearerBitmask; private final int mMtu; @@ -100,11 +103,13 @@ public final class DataProfile implements Parcelable { private final boolean mPreferred; /** @hide */ - public DataProfile(int profileId, String apn, @ProtocolType int protocolType, int authType, - String userName, String password, int type, int maxConnsTime, int maxConns, - int waitTime, boolean enabled, @ApnType int supportedApnTypesBitmap, - @ProtocolType int roamingProtocolType, @NetworkTypeBitMask int bearerBitmap, - int mtu, boolean persistent, boolean preferred) { + private DataProfile(int profileId, String apn, @ProtocolType int protocolType, int authType, + String userName, String password, int type, int maxConnectionsTime, + int maxConnections, int waitTime, boolean enabled, + @ApnType int supportedApnTypesBitmask, + @ProtocolType int roamingProtocolType, + @NetworkTypeBitMask int bearerBitmask, int mtu, boolean persistent, + boolean preferred) { this.mProfileId = profileId; this.mApn = apn; this.mProtocolType = protocolType; @@ -116,21 +121,19 @@ public final class DataProfile implements Parcelable { this.mUserName = userName; this.mPassword = password; this.mType = type; - this.mMaxConnsTime = maxConnsTime; - this.mMaxConns = maxConns; + this.mMaxConnectionsTime = maxConnectionsTime; + this.mMaxConnections = maxConnections; this.mWaitTime = waitTime; this.mEnabled = enabled; - - this.mSupportedApnTypesBitmap = supportedApnTypesBitmap; + this.mSupportedApnTypesBitmask = supportedApnTypesBitmask; this.mRoamingProtocolType = roamingProtocolType; - this.mBearerBitmap = bearerBitmap; + this.mBearerBitmask = bearerBitmask; this.mMtu = mtu; this.mPersistent = persistent; this.mPreferred = preferred; } - /** @hide */ - public DataProfile(Parcel source) { + private DataProfile(Parcel source) { mProfileId = source.readInt(); mApn = source.readString(); mProtocolType = source.readInt(); @@ -138,13 +141,13 @@ public final class DataProfile implements Parcelable { mUserName = source.readString(); mPassword = source.readString(); mType = source.readInt(); - mMaxConnsTime = source.readInt(); - mMaxConns = source.readInt(); + mMaxConnectionsTime = source.readInt(); + mMaxConnections = source.readInt(); mWaitTime = source.readInt(); mEnabled = source.readBoolean(); - mSupportedApnTypesBitmap = source.readInt(); + mSupportedApnTypesBitmask = source.readInt(); mRoamingProtocolType = source.readInt(); - mBearerBitmap = source.readInt(); + mBearerBitmask = source.readInt(); mMtu = source.readInt(); mPersistent = source.readBoolean(); mPreferred = source.readBoolean(); @@ -156,14 +159,16 @@ public final class DataProfile implements Parcelable { public int getProfileId() { return mProfileId; } /** - * @return The APN to establish data connection. + * @return The APN (Access Point Name) to establish data connection. This is a string + * specifically defined by the carrier. */ + @NonNull public String getApn() { return mApn; } /** * @return The connection protocol defined in 3GPP TS 27.007 section 10.1.1. */ - public @ProtocolType int getProtocol() { return mProtocolType; } + public @ProtocolType int getProtocolType() { return mProtocolType; } /** * @return The authentication protocol used for this PDP context. @@ -173,32 +178,40 @@ public final class DataProfile implements Parcelable { /** * @return The username for APN. Can be null. */ + @Nullable public String getUserName() { return mUserName; } /** * @return The password for APN. Can be null. */ + @Nullable public String getPassword() { return mPassword; } /** * @return The profile type. */ - public @DataProfileType int getType() { return mType; } + public @Type int getType() { return mType; } /** * @return The period in seconds to limit the maximum connections. + * + * @hide */ - public int getMaxConnsTime() { return mMaxConnsTime; } + public int getMaxConnectionsTime() { return mMaxConnectionsTime; } /** * @return The maximum connections allowed. + * + * @hide */ - public int getMaxConns() { return mMaxConns; } + public int getMaxConnections() { return mMaxConnections; } /** * @return The required wait time in seconds after a successful UE initiated disconnect of a * given PDN connection before the device can send a new PDN connection request for that given * PDN. + * + * @hide */ public int getWaitTime() { return mWaitTime; } @@ -208,19 +221,19 @@ public final class DataProfile implements Parcelable { public boolean isEnabled() { return mEnabled; } /** - * @return The supported APN types bitmap. + * @return The supported APN types bitmask. */ - public @ApnType int getSupportedApnTypesBitmap() { return mSupportedApnTypesBitmap; } + public @ApnType int getSupportedApnTypesBitmask() { return mSupportedApnTypesBitmask; } /** * @return The connection protocol on roaming network defined in 3GPP TS 27.007 section 10.1.1. */ - public @ProtocolType int getRoamingProtocol() { return mRoamingProtocolType; } + public @ProtocolType int getRoamingProtocolType() { return mRoamingProtocolType; } /** - * @return The bearer bitmap indicating the applicable networks for this data profile. + * @return The bearer bitmask indicating the applicable networks for this data profile. */ - public @NetworkTypeBitMask int getBearerBitmap() { return mBearerBitmap; } + public @NetworkTypeBitMask int getBearerBitmask() { return mBearerBitmask; } /** * @return The maximum transmission unit (MTU) size in bytes. @@ -234,11 +247,11 @@ public final class DataProfile implements Parcelable { /** * @return {@code true} if this data profile was used to bring up the last default - * (i.e internet) data connection successfully. + * (i.e internet) data connection successfully, or the one chosen by the user in Settings' + * APN editor. For one carrier there can be only one profiled preferred. */ public boolean isPreferred() { return mPreferred; } - /** @hide */ @Override public int describeContents() { return 0; @@ -249,20 +262,13 @@ public final class DataProfile implements Parcelable { return "DataProfile=" + mProfileId + "/" + mProtocolType + "/" + mAuthType + "/" + (Build.IS_USER ? "***/***/***" : (mApn + "/" + mUserName + "/" + mPassword)) + "/" + mType + "/" - + mMaxConnsTime + "/" + mMaxConns + "/" - + mWaitTime + "/" + mEnabled + "/" + mSupportedApnTypesBitmap + "/" - + mRoamingProtocolType + "/" + mBearerBitmap + "/" + mMtu + "/" + mPersistent + "/" + + mMaxConnectionsTime + "/" + mMaxConnections + "/" + + mWaitTime + "/" + mEnabled + "/" + mSupportedApnTypesBitmask + "/" + + mRoamingProtocolType + "/" + mBearerBitmask + "/" + mMtu + "/" + mPersistent + "/" + mPreferred; } @Override - public boolean equals(Object o) { - if (o instanceof DataProfile == false) return false; - return (o == this || toString().equals(o.toString())); - } - - /** @hide */ - @Override public void writeToParcel(Parcel dest, int flags) { dest.writeInt(mProfileId); dest.writeString(mApn); @@ -271,20 +277,19 @@ public final class DataProfile implements Parcelable { dest.writeString(mUserName); dest.writeString(mPassword); dest.writeInt(mType); - dest.writeInt(mMaxConnsTime); - dest.writeInt(mMaxConns); + dest.writeInt(mMaxConnectionsTime); + dest.writeInt(mMaxConnections); dest.writeInt(mWaitTime); dest.writeBoolean(mEnabled); - dest.writeInt(mSupportedApnTypesBitmap); + dest.writeInt(mSupportedApnTypesBitmask); dest.writeInt(mRoamingProtocolType); - dest.writeInt(mBearerBitmap); + dest.writeInt(mBearerBitmask); dest.writeInt(mMtu); dest.writeBoolean(mPersistent); dest.writeBoolean(mPreferred); } - /** @hide */ - public static final Parcelable.Creator<DataProfile> CREATOR = + public static final @android.annotation.NonNull Parcelable.Creator<DataProfile> CREATOR = new Parcelable.Creator<DataProfile>() { @Override public DataProfile createFromParcel(Parcel source) { @@ -296,4 +301,312 @@ public final class DataProfile implements Parcelable { return new DataProfile[size]; } }; + + @Override + public boolean equals(Object o) { + if (this == o) return true; + if (o == null || getClass() != o.getClass()) return false; + DataProfile that = (DataProfile) o; + return mProfileId == that.mProfileId + && mProtocolType == that.mProtocolType + && mAuthType == that.mAuthType + && mType == that.mType + && mMaxConnectionsTime == that.mMaxConnectionsTime + && mMaxConnections == that.mMaxConnections + && mWaitTime == that.mWaitTime + && mEnabled == that.mEnabled + && mSupportedApnTypesBitmask == that.mSupportedApnTypesBitmask + && mRoamingProtocolType == that.mRoamingProtocolType + && mBearerBitmask == that.mBearerBitmask + && mMtu == that.mMtu + && mPersistent == that.mPersistent + && mPreferred == that.mPreferred + && Objects.equals(mApn, that.mApn) + && Objects.equals(mUserName, that.mUserName) + && Objects.equals(mPassword, that.mPassword); + } + + @Override + public int hashCode() { + return Objects.hash(mProfileId, mApn, mProtocolType, mAuthType, mUserName, mPassword, mType, + mMaxConnectionsTime, mMaxConnections, mWaitTime, mEnabled, + mSupportedApnTypesBitmask, mRoamingProtocolType, mBearerBitmask, mMtu, mPersistent, + mPreferred); + } + + /** + * Provides a convenient way to set the fields of a {@link DataProfile} when creating a new + * instance. + * + * <p>The example below shows how you might create a new {@code DataProfile}: + * + * <pre><code> + * + * DataProfile dp = new DataProfile.Builder() + * .setApn("apn.xyz.com") + * .setProtocol(ApnSetting.PROTOCOL_IPV4V6) + * .build(); + * </code></pre> + */ + public static final class Builder { + private int mProfileId; + + private String mApn; + + @ProtocolType + private int mProtocolType; + + @AuthType + private int mAuthType; + + private String mUserName; + + private String mPassword; + + @Type + private int mType; + + private int mMaxConnectionsTime; + + private int mMaxConnections; + + private int mWaitTime; + + private boolean mEnabled; + + @ApnType + private int mSupportedApnTypesBitmask; + + @ProtocolType + private int mRoamingProtocolType; + + @NetworkTypeBitMask + private int mBearerBitmask; + + private int mMtu; + + private boolean mPersistent; + + private boolean mPreferred; + + /** + * Default constructor for Builder. + */ + public Builder() { + } + + /** + * Set profile id. Note that this is not a global unique id of the data profile. This id + * is only used by certain CDMA carriers to identify the type of data profile. + * + * @param profileId Network domain. + * @return The same instance of the builder. + */ + public @NonNull Builder setProfileId(int profileId) { + mProfileId = profileId; + return this; + } + + /** + * Set the APN (Access Point Name) to establish data connection. This is a string + * specifically defined by the carrier. + * + * @param apn Access point name + * @return The same instance of the builder. + */ + public @NonNull Builder setApn(@NonNull String apn) { + mApn = apn; + return this; + } + + /** + * Set the connection protocol type. + * + * @param protocolType The connection protocol defined in 3GPP TS 27.007 section 10.1.1. + * @return The same instance of the builder. + */ + public @NonNull Builder setProtocolType(@ProtocolType int protocolType) { + mProtocolType = protocolType; + return this; + } + + /** + * Set the authentication type. + * + * @param authType The authentication type + * @return The same instance of the builder. + */ + public @NonNull Builder setAuthType(@AuthType int authType) { + mAuthType = authType; + return this; + } + + /** + * Set the user name + * + * @param userName The user name + * @return The same instance of the builder. + */ + public @NonNull Builder setUserName(@NonNull String userName) { + mUserName = userName; + return this; + } + + /** + * Set the password + * + * @param password The password + * @return The same instance of the builder. + */ + public @NonNull Builder setPassword(@NonNull String password) { + mPassword = password; + return this; + } + + /** + * Set the type + * + * @param type The profile type + * @return The same instance of the builder. + */ + public @NonNull Builder setType(@Type int type) { + mType = type; + return this; + } + + /** + * Set the period in seconds to limit the maximum connections. + * + * @param maxConnectionsTime The profile type + * @return The same instance of the builder. + * + * @hide + */ + public @NonNull Builder setMaxConnectionsTime(int maxConnectionsTime) { + mMaxConnectionsTime = maxConnectionsTime; + return this; + } + + /** + * Set the maximum connections allowed. + * + * @param maxConnections The maximum connections allowed. + * @return The same instance of the builder. + * + * @hide + */ + public @NonNull Builder setMaxConnections(int maxConnections) { + mMaxConnections = maxConnections; + return this; + } + + /** + * Set the period in seconds to limit the maximum connections. + * + * @param waitTime The required wait time in seconds after a successful UE initiated + * disconnect of a given PDN connection before the device can send a new PDN connection + * request for that given PDN. + * + * @return The same instance of the builder. + * + * @hide + */ + public @NonNull Builder setWaitTime(int waitTime) { + mWaitTime = waitTime; + return this; + } + + /** + * Enable the data profile + * + * @param isEnabled {@code true} to enable the data profile, otherwise disable. + * @return The same instance of the builder. + */ + public @NonNull Builder enable(boolean isEnabled) { + mEnabled = isEnabled; + return this; + } + + /** + * Set the supported APN types bitmask. + * + * @param supportedApnTypesBitmask The supported APN types bitmask. + * @return The same instance of the builder. + */ + public @NonNull Builder setSupportedApnTypesBitmask(@ApnType int supportedApnTypesBitmask) { + mSupportedApnTypesBitmask = supportedApnTypesBitmask; + return this; + } + + /** + * Set the connection protocol type for roaming. + * + * @param protocolType The connection protocol defined in 3GPP TS 27.007 section 10.1.1. + * @return The same instance of the builder. + */ + public @NonNull Builder setRoamingProtocolType(@ProtocolType int protocolType) { + mRoamingProtocolType = protocolType; + return this; + } + + /** + * Set the bearer bitmask indicating the applicable networks for this data profile. + * + * @param bearerBitmask The bearer bitmask indicating the applicable networks for this data + * profile. + * @return The same instance of the builder. + */ + public @NonNull Builder setBearerBitmask(@NetworkTypeBitMask int bearerBitmask) { + mBearerBitmask = bearerBitmask; + return this; + } + + /** + * Set the maximum transmission unit (MTU) size in bytes. + * + * @param mtu The maximum transmission unit (MTU) size in bytes. + * @return The same instance of the builder. + */ + public @NonNull Builder setMtu(int mtu) { + mMtu = mtu; + return this; + } + + /** + * Set data profile as preferred/non-preferred. + * + * @param isPreferred {@code true} if this data profile was used to bring up the last + * default (i.e internet) data connection successfully, or the one chosen by the user in + * Settings' APN editor. For one carrier there can be only one profiled preferred. + * @return The same instance of the builder. + */ + public @NonNull Builder setPreferred(boolean isPreferred) { + mPreferred = isPreferred; + return this; + } + + /** + * Set data profile as persistent/non-persistent + * + * @param isPersistent {@code true} if this data profile was used to bring up the last + * default (i.e internet) data connection successfully. + * @return The same instance of the builder. + */ + public @NonNull Builder setPersistent(boolean isPersistent) { + mPersistent = isPersistent; + return this; + } + + /** + * Build the DataProfile object + * + * @return The data profile object + */ + public @NonNull DataProfile build() { + return new DataProfile(mProfileId, mApn, mProtocolType, mAuthType, mUserName, mPassword, + mType, mMaxConnectionsTime, mMaxConnections, mWaitTime, mEnabled, + mSupportedApnTypesBitmask, mRoamingProtocolType, mBearerBitmask, mMtu, + mPersistent, mPreferred); + } + } } diff --git a/telephony/java/android/telephony/data/DataService.java b/telephony/java/android/telephony/data/DataService.java index 59d1e1e7115a..372bdf1c0f81 100644 --- a/telephony/java/android/telephony/data/DataService.java +++ b/telephony/java/android/telephony/data/DataService.java @@ -19,6 +19,7 @@ package android.telephony.data; import android.annotation.IntDef; import android.annotation.NonNull; import android.annotation.Nullable; +import android.annotation.SdkConstant; import android.annotation.SystemApi; import android.app.Service; import android.content.Intent; @@ -58,10 +59,12 @@ import java.util.List; public abstract class DataService extends Service { private static final String TAG = DataService.class.getSimpleName(); - public static final String DATA_SERVICE_INTERFACE = "android.telephony.data.DataService"; + @SdkConstant(SdkConstant.SdkConstantType.SERVICE_ACTION) + public static final String SERVICE_INTERFACE = "android.telephony.data.DataService"; /** {@hide} */ @IntDef(prefix = "REQUEST_REASON_", value = { + REQUEST_REASON_UNKNOWN, REQUEST_REASON_NORMAL, REQUEST_REASON_HANDOVER, }) @@ -70,6 +73,7 @@ public abstract class DataService extends Service { /** {@hide} */ @IntDef(prefix = "REQUEST_REASON_", value = { + REQUEST_REASON_UNKNOWN, REQUEST_REASON_NORMAL, REQUEST_REASON_SHUTDOWN, REQUEST_REASON_HANDOVER, @@ -77,6 +81,8 @@ public abstract class DataService extends Service { @Retention(RetentionPolicy.SOURCE) public @interface DeactivateDataReason {} + /** The reason of the data request is unknown */ + public static final int REQUEST_REASON_UNKNOWN = 0; /** The reason of the data request is normal */ public static final int REQUEST_REASON_NORMAL = 1; @@ -94,7 +100,7 @@ public abstract class DataService extends Service { private static final int DATA_SERVICE_REQUEST_DEACTIVATE_DATA_CALL = 5; private static final int DATA_SERVICE_REQUEST_SET_INITIAL_ATTACH_APN = 6; private static final int DATA_SERVICE_REQUEST_SET_DATA_PROFILE = 7; - private static final int DATA_SERVICE_REQUEST_GET_DATA_CALL_LIST = 8; + private static final int DATA_SERVICE_REQUEST_REQUEST_DATA_CALL_LIST = 8; private static final int DATA_SERVICE_REQUEST_REGISTER_DATA_CALL_LIST_CHANGED = 9; private static final int DATA_SERVICE_REQUEST_UNREGISTER_DATA_CALL_LIST_CHANGED = 10; private static final int DATA_SERVICE_INDICATION_DATA_CALL_LIST_CHANGED = 11; @@ -149,14 +155,13 @@ public abstract class DataService extends Service { * {@link #REQUEST_REASON_HANDOVER}. * @param linkProperties If {@code reason} is {@link #REQUEST_REASON_HANDOVER}, this is the * link properties of the existing data connection, otherwise null. - * @param callback The result callback for this request. Null if the client does not care - * about the result. + * @param callback The result callback for this request. */ public void setupDataCall(int accessNetworkType, @NonNull DataProfile dataProfile, boolean isRoaming, boolean allowRoaming, @SetupDataReason int reason, @Nullable LinkProperties linkProperties, - @Nullable DataServiceCallback callback) { + @NonNull DataServiceCallback callback) { // The default implementation is to return unsupported. if (callback != null) { callback.onSetupDataCallComplete(DataServiceCallback.RESULT_ERROR_UNSUPPORTED, @@ -190,11 +195,10 @@ public abstract class DataService extends Service { * * @param dataProfile Data profile used for data call setup. See {@link DataProfile}. * @param isRoaming True if the device is data roaming. - * @param callback The result callback for this request. Null if the client does not care - * about the result. + * @param callback The result callback for this request. */ public void setInitialAttachApn(@NonNull DataProfile dataProfile, boolean isRoaming, - @Nullable DataServiceCallback callback) { + @NonNull DataServiceCallback callback) { // The default implementation is to return unsupported. if (callback != null) { callback.onSetInitialAttachApnComplete( @@ -209,11 +213,10 @@ public abstract class DataService extends Service { * * @param dps A list of data profiles. * @param isRoaming True if the device is data roaming. - * @param callback The result callback for this request. Null if the client does not care - * about the result. + * @param callback The result callback for this request. */ public void setDataProfile(@NonNull List<DataProfile> dps, boolean isRoaming, - @Nullable DataServiceCallback callback) { + @NonNull DataServiceCallback callback) { // The default implementation is to return unsupported. if (callback != null) { callback.onSetDataProfileComplete(DataServiceCallback.RESULT_ERROR_UNSUPPORTED); @@ -225,9 +228,10 @@ public abstract class DataService extends Service { * * @param callback The result callback for this request. */ - public void getDataCallList(@NonNull DataServiceCallback callback) { + public void requestDataCallList(@NonNull DataServiceCallback callback) { // The default implementation is to return unsupported. - callback.onGetDataCallListComplete(DataServiceCallback.RESULT_ERROR_UNSUPPORTED, null); + callback.onRequestDataCallListComplete(DataServiceCallback.RESULT_ERROR_UNSUPPORTED, + null); } private void registerForDataCallListChanged(IDataServiceCallback callback) { @@ -409,10 +413,10 @@ public abstract class DataService extends Service { ? new DataServiceCallback(setDataProfileRequest.callback) : null); break; - case DATA_SERVICE_REQUEST_GET_DATA_CALL_LIST: + case DATA_SERVICE_REQUEST_REQUEST_DATA_CALL_LIST: if (serviceProvider == null) break; - serviceProvider.getDataCallList(new DataServiceCallback( + serviceProvider.requestDataCallList(new DataServiceCallback( (IDataServiceCallback) message.obj)); break; case DATA_SERVICE_REQUEST_REGISTER_DATA_CALL_LIST_CHANGED: @@ -455,14 +459,14 @@ public abstract class DataService extends Service { * will call this method after binding the data service for each active SIM slot id. * * @param slotIndex SIM slot id the data service associated with. - * @return Data service object + * @return Data service object. Null if failed to create the provider (e.g. invalid slot index) */ @Nullable public abstract DataServiceProvider onCreateDataServiceProvider(int slotIndex); @Override public IBinder onBind(Intent intent) { - if (intent == null || !DATA_SERVICE_INTERFACE.equals(intent.getAction())) { + if (intent == null || !SERVICE_INTERFACE.equals(intent.getAction())) { loge("Unexpected intent " + intent); return null; } @@ -531,12 +535,12 @@ public abstract class DataService extends Service { } @Override - public void getDataCallList(int slotIndex, IDataServiceCallback callback) { + public void requestDataCallList(int slotIndex, IDataServiceCallback callback) { if (callback == null) { - loge("getDataCallList: callback is null"); + loge("requestDataCallList: callback is null"); return; } - mHandler.obtainMessage(DATA_SERVICE_REQUEST_GET_DATA_CALL_LIST, slotIndex, 0, + mHandler.obtainMessage(DATA_SERVICE_REQUEST_REQUEST_DATA_CALL_LIST, slotIndex, 0, callback).sendToTarget(); } diff --git a/telephony/java/android/telephony/data/DataServiceCallback.java b/telephony/java/android/telephony/data/DataServiceCallback.java index 2d0cfe80366c..5d8d79367ba4 100644 --- a/telephony/java/android/telephony/data/DataServiceCallback.java +++ b/telephony/java/android/telephony/data/DataServiceCallback.java @@ -140,21 +140,21 @@ public class DataServiceCallback { } /** - * Called to indicate result for the request {@link DataServiceProvider#getDataCallList( + * Called to indicate result for the request {@link DataServiceProvider#requestDataCallList( * DataServiceCallback)}. * * @param result The result code. Must be one of the {@link ResultCode}. * @param dataCallList List of the current active data connection. If no data call is presented, * set it to an empty list. */ - public void onGetDataCallListComplete(@ResultCode int result, - @NonNull List<DataCallResponse> dataCallList) { + public void onRequestDataCallListComplete(@ResultCode int result, + @NonNull List<DataCallResponse> dataCallList) { IDataServiceCallback callback = mCallback.get(); if (callback != null) { try { - callback.onGetDataCallListComplete(result, dataCallList); + callback.onRequestDataCallListComplete(result, dataCallList); } catch (RemoteException e) { - Rlog.e(TAG, "Failed to onGetDataCallListComplete on the remote"); + Rlog.e(TAG, "Failed to onRequestDataCallListComplete on the remote"); } } } diff --git a/telephony/java/android/telephony/data/IDataService.aidl b/telephony/java/android/telephony/data/IDataService.aidl index d4d9be85ffa8..9c74dcccec54 100644 --- a/telephony/java/android/telephony/data/IDataService.aidl +++ b/telephony/java/android/telephony/data/IDataService.aidl @@ -35,7 +35,7 @@ oneway interface IDataService IDataServiceCallback callback); void setDataProfile(int slotId, in List<DataProfile> dps, boolean isRoaming, IDataServiceCallback callback); - void getDataCallList(int slotId, IDataServiceCallback callback); + void requestDataCallList(int slotId, IDataServiceCallback callback); void registerForDataCallListChanged(int slotId, IDataServiceCallback callback); void unregisterForDataCallListChanged(int slotId, IDataServiceCallback callback); } diff --git a/telephony/java/android/telephony/data/IDataServiceCallback.aidl b/telephony/java/android/telephony/data/IDataServiceCallback.aidl index 856185b2974f..cec757d23988 100644 --- a/telephony/java/android/telephony/data/IDataServiceCallback.aidl +++ b/telephony/java/android/telephony/data/IDataServiceCallback.aidl @@ -28,6 +28,6 @@ oneway interface IDataServiceCallback void onDeactivateDataCallComplete(int result); void onSetInitialAttachApnComplete(int result); void onSetDataProfileComplete(int result); - void onGetDataCallListComplete(int result, in List<DataCallResponse> dataCallList); + void onRequestDataCallListComplete(int result, in List<DataCallResponse> dataCallList); void onDataCallListChanged(in List<DataCallResponse> dataCallList); } diff --git a/telephony/java/android/telephony/data/IQualifiedNetworksService.aidl b/telephony/java/android/telephony/data/IQualifiedNetworksService.aidl index 9c80cb77e435..3bf09bc19788 100644 --- a/telephony/java/android/telephony/data/IQualifiedNetworksService.aidl +++ b/telephony/java/android/telephony/data/IQualifiedNetworksService.aidl @@ -23,6 +23,6 @@ import android.telephony.data.IQualifiedNetworksServiceCallback; */ interface IQualifiedNetworksService { - oneway void createNetworkAvailabilityUpdater(int slotId, IQualifiedNetworksServiceCallback callback); - oneway void removeNetworkAvailabilityUpdater(int slotId); + oneway void createNetworkAvailabilityProvider(int slotId, IQualifiedNetworksServiceCallback callback); + oneway void removeNetworkAvailabilityProvider(int slotId); } diff --git a/telephony/java/android/telephony/data/QualifiedNetworksService.java b/telephony/java/android/telephony/data/QualifiedNetworksService.java index c38f2788ca92..0e1751d50949 100644 --- a/telephony/java/android/telephony/data/QualifiedNetworksService.java +++ b/telephony/java/android/telephony/data/QualifiedNetworksService.java @@ -17,7 +17,6 @@ package android.telephony.data; import android.annotation.NonNull; -import android.annotation.Nullable; import android.annotation.SystemApi; import android.app.Service; import android.content.Intent; @@ -34,14 +33,21 @@ import android.util.SparseArray; import com.android.internal.annotations.VisibleForTesting; +import java.util.List; + /** - * Base class of the qualified networks service. Services that extend QualifiedNetworksService must - * register the service in their AndroidManifest to be detected by the framework. They must be - * protected by the permission "android.permission.BIND_TELEPHONY_QUALIFIED_NETWORKS_SERVICE". - * The qualified networks service definition in the manifest must follow the following format: + * Base class of the qualified networks service, which is a vendor service providing up-to-date + * qualified network information to the frameworks for data handover control. A qualified network + * is defined as an access network that is ready for bringing up data connection for given APN + * types. + * + * Services that extend QualifiedNetworksService must register the service in their AndroidManifest + * to be detected by the framework. They must be protected by the permission + * "android.permission.BIND_TELEPHONY_DATA_SERVICE". The qualified networks service definition in + * the manifest must follow the following format: * ... * <service android:name=".xxxQualifiedNetworksService" - * android:permission="android.permission.BIND_TELEPHONY_QUALIFIED_NETWORKS_SERVICE" > + * android:permission="android.permission.BIND_TELEPHONY_DATA_SERVICE" > * <intent-filter> * <action android:name="android.telephony.data.QualifiedNetworksService" /> * </intent-filter> @@ -55,28 +61,28 @@ public abstract class QualifiedNetworksService extends Service { public static final String QUALIFIED_NETWORKS_SERVICE_INTERFACE = "android.telephony.data.QualifiedNetworksService"; - private static final int QNS_CREATE_NETWORK_AVAILABILITY_UPDATER = 1; - private static final int QNS_REMOVE_NETWORK_AVAILABILITY_UPDATER = 2; - private static final int QNS_REMOVE_ALL_NETWORK_AVAILABILITY_UPDATERS = 3; + private static final int QNS_CREATE_NETWORK_AVAILABILITY_PROVIDER = 1; + private static final int QNS_REMOVE_NETWORK_AVAILABILITY_PROVIDER = 2; + private static final int QNS_REMOVE_ALL_NETWORK_AVAILABILITY_PROVIDERS = 3; private static final int QNS_UPDATE_QUALIFIED_NETWORKS = 4; private final HandlerThread mHandlerThread; private final QualifiedNetworksServiceHandler mHandler; - private final SparseArray<NetworkAvailabilityUpdater> mUpdaters = new SparseArray<>(); + private final SparseArray<NetworkAvailabilityProvider> mProviders = new SparseArray<>(); /** @hide */ @VisibleForTesting public final IQualifiedNetworksServiceWrapper mBinder = new IQualifiedNetworksServiceWrapper(); /** - * The abstract class of the network availability updater implementation. The vendor qualified + * The abstract class of the network availability provider implementation. The vendor qualified * network service must extend this class to report the available networks for data - * connection setup. Note that each instance of network availability updater is associated with + * connection setup. Note that each instance of network availability provider is associated with * one physical SIM slot. */ - public abstract class NetworkAvailabilityUpdater implements AutoCloseable { + public abstract class NetworkAvailabilityProvider implements AutoCloseable { private final int mSlotIndex; private IQualifiedNetworksServiceCallback mCallback; @@ -89,14 +95,14 @@ public abstract class QualifiedNetworksService extends Service { /** * Constructor - * @param slotIndex SIM slot index the network availability updater associated with. + * @param slotIndex SIM slot index the network availability provider associated with. */ - public NetworkAvailabilityUpdater(int slotIndex) { + public NetworkAvailabilityProvider(int slotIndex) { mSlotIndex = slotIndex; } /** - * @return SIM slot index the network availability updater associated with. + * @return SIM slot index the network availability provider associated with. */ public final int getSlotIndex() { return mSlotIndex; @@ -121,7 +127,7 @@ public abstract class QualifiedNetworksService extends Service { } /** - * Update the qualified networks list. Network availability updater must invoke this method + * Update the qualified networks list. Network availability provider must invoke this method * whenever the qualified networks changes. If this method is never invoked for certain * APN types, then frameworks will always use the default (i.e. cellular) data and network * service. @@ -129,14 +135,16 @@ public abstract class QualifiedNetworksService extends Service { * @param apnTypes APN types of the qualified networks. This must be a bitmask combination * of {@link ApnSetting.ApnType}. * @param qualifiedNetworkTypes List of network types which are qualified for data - * connection setup for {@link @apnType} in the preferred order. Each element in the array - * is a {@link AccessNetworkType}. An empty list or null indicates no networks are qualified + * connection setup for {@link @apnType} in the preferred order. Each element in the list + * is a {@link AccessNetworkType}. An empty list indicates no networks are qualified * for data setup. */ - public final void updateQualifiedNetworkTypes(@ApnType int apnTypes, - @Nullable int[] qualifiedNetworkTypes) { + public final void updateQualifiedNetworkTypes( + @ApnType int apnTypes, @NonNull List<Integer> qualifiedNetworkTypes) { + int[] qualifiedNetworkTypesArray = + qualifiedNetworkTypes.stream().mapToInt(i->i).toArray(); mHandler.obtainMessage(QNS_UPDATE_QUALIFIED_NETWORKS, mSlotIndex, apnTypes, - qualifiedNetworkTypes).sendToTarget(); + qualifiedNetworkTypesArray).sendToTarget(); } private void onUpdateQualifiedNetworkTypes(@ApnType int apnTypes, @@ -152,7 +160,7 @@ public abstract class QualifiedNetworksService extends Service { } /** - * Called when the qualified networks updater is removed. The extended class should + * Called when the qualified networks provider is removed. The extended class should * implement this method to perform cleanup works. */ @Override @@ -168,48 +176,48 @@ public abstract class QualifiedNetworksService extends Service { public void handleMessage(Message message) { IQualifiedNetworksServiceCallback callback; final int slotIndex = message.arg1; - NetworkAvailabilityUpdater updater = mUpdaters.get(slotIndex); + NetworkAvailabilityProvider provider = mProviders.get(slotIndex); switch (message.what) { - case QNS_CREATE_NETWORK_AVAILABILITY_UPDATER: - if (mUpdaters.get(slotIndex) != null) { - loge("Network availability updater for slot " + slotIndex + case QNS_CREATE_NETWORK_AVAILABILITY_PROVIDER: + if (mProviders.get(slotIndex) != null) { + loge("Network availability provider for slot " + slotIndex + " already existed."); return; } - updater = createNetworkAvailabilityUpdater(slotIndex); - if (updater != null) { - mUpdaters.put(slotIndex, updater); + provider = onCreateNetworkAvailabilityProvider(slotIndex); + if (provider != null) { + mProviders.put(slotIndex, provider); callback = (IQualifiedNetworksServiceCallback) message.obj; - updater.registerForQualifiedNetworkTypesChanged(callback); + provider.registerForQualifiedNetworkTypesChanged(callback); } else { - loge("Failed to create network availability updater. slot index = " + loge("Failed to create network availability provider. slot index = " + slotIndex); } break; - case QNS_REMOVE_NETWORK_AVAILABILITY_UPDATER: - if (updater != null) { - updater.close(); - mUpdaters.remove(slotIndex); + case QNS_REMOVE_NETWORK_AVAILABILITY_PROVIDER: + if (provider != null) { + provider.close(); + mProviders.remove(slotIndex); } break; - case QNS_REMOVE_ALL_NETWORK_AVAILABILITY_UPDATERS: - for (int i = 0; i < mUpdaters.size(); i++) { - updater = mUpdaters.get(i); - if (updater != null) { - updater.close(); + case QNS_REMOVE_ALL_NETWORK_AVAILABILITY_PROVIDERS: + for (int i = 0; i < mProviders.size(); i++) { + provider = mProviders.get(i); + if (provider != null) { + provider.close(); } } - mUpdaters.clear(); + mProviders.clear(); break; case QNS_UPDATE_QUALIFIED_NETWORKS: - if (updater == null) break; - updater.onUpdateQualifiedNetworkTypes(message.arg2, (int[]) message.obj); + if (provider == null) break; + provider.onUpdateQualifiedNetworkTypes(message.arg2, (int[]) message.obj); break; } } @@ -227,8 +235,8 @@ public abstract class QualifiedNetworksService extends Service { } /** - * Create the instance of {@link NetworkAvailabilityUpdater}. Vendor qualified network service - * must override this method to facilitate the creation of {@link NetworkAvailabilityUpdater} + * Create the instance of {@link NetworkAvailabilityProvider}. Vendor qualified network service + * must override this method to facilitate the creation of {@link NetworkAvailabilityProvider} * instances. The system will call this method after binding the qualified networks service for * each active SIM slot index. * @@ -236,7 +244,7 @@ public abstract class QualifiedNetworksService extends Service { * @return Qualified networks service instance */ @NonNull - public abstract NetworkAvailabilityUpdater createNetworkAvailabilityUpdater(int slotIndex); + public abstract NetworkAvailabilityProvider onCreateNetworkAvailabilityProvider(int slotIndex); /** @hide */ @Override @@ -251,7 +259,7 @@ public abstract class QualifiedNetworksService extends Service { /** @hide */ @Override public boolean onUnbind(Intent intent) { - mHandler.obtainMessage(QNS_REMOVE_ALL_NETWORK_AVAILABILITY_UPDATERS).sendToTarget(); + mHandler.obtainMessage(QNS_REMOVE_ALL_NETWORK_AVAILABILITY_PROVIDERS).sendToTarget(); return false; } @@ -267,15 +275,15 @@ public abstract class QualifiedNetworksService extends Service { */ private class IQualifiedNetworksServiceWrapper extends IQualifiedNetworksService.Stub { @Override - public void createNetworkAvailabilityUpdater(int slotIndex, - IQualifiedNetworksServiceCallback callback) { - mHandler.obtainMessage(QNS_CREATE_NETWORK_AVAILABILITY_UPDATER, slotIndex, 0, + public void createNetworkAvailabilityProvider(int slotIndex, + IQualifiedNetworksServiceCallback callback) { + mHandler.obtainMessage(QNS_CREATE_NETWORK_AVAILABILITY_PROVIDER, slotIndex, 0, callback).sendToTarget(); } @Override - public void removeNetworkAvailabilityUpdater(int slotIndex) { - mHandler.obtainMessage(QNS_REMOVE_NETWORK_AVAILABILITY_UPDATER, slotIndex, 0) + public void removeNetworkAvailabilityProvider(int slotIndex) { + mHandler.obtainMessage(QNS_REMOVE_NETWORK_AVAILABILITY_PROVIDER, slotIndex, 0) .sendToTarget(); } } diff --git a/telephony/java/android/telephony/euicc/EuiccManager.java b/telephony/java/android/telephony/euicc/EuiccManager.java index b8a07e4ed777..f1a5778b2281 100644 --- a/telephony/java/android/telephony/euicc/EuiccManager.java +++ b/telephony/java/android/telephony/euicc/EuiccManager.java @@ -119,7 +119,11 @@ public class EuiccManager { /** * Intent action sent by system apps (such as the Settings app) to the Telephony framework to * enable or disable a subscription. Must be accompanied with {@link #EXTRA_SUBSCRIPTION_ID} and - * {@link #EXTRA_ENABLE_SUBSCRIPTION}. + * {@link #EXTRA_ENABLE_SUBSCRIPTION}, and optionally {@link #EXTRA_FROM_SUBSCRIPTION_ID}. + * + * <p>Requires the caller to be a privileged process with the + * {@link android.permission#CALL_PRIVILEGED} permission for the intent to reach the Telephony + * stack. * * <p>Unlike {@link #switchToSubscription(int, PendingIntent)}, using this action allows the * underlying eUICC service (i.e. the LPA app) to control the UI experience during this @@ -140,6 +144,10 @@ public class EuiccManager { * Intent action sent by system apps (such as the Settings app) to the Telephony framework to * delete a subscription. Must be accompanied with {@link #EXTRA_SUBSCRIPTION_ID}. * + * <p>Requires the caller to be a privileged process with the + * {@link android.permission#CALL_PRIVILEGED} permission for the intent to reach the Telephony + * stack. + * * <p>Unlike {@link #deleteSubscription(int, PendingIntent)}, using this action allows the * underlying eUICC service (i.e. the LPA app) to control the UI experience during this * operation. The action is received by the Telephony framework, which in turn selects and @@ -160,6 +168,10 @@ public class EuiccManager { * rename a subscription. Must be accompanied with {@link #EXTRA_SUBSCRIPTION_ID} and * {@link #EXTRA_SUBSCRIPTION_NICKNAME}. * + * <p>Requires the caller to be a privileged process with the + * {@link android.permission#CALL_PRIVILEGED} permission for the intent to reach the Telephony + * stack. + * * <p>Unlike {@link #updateSubscriptionNickname(int, String, PendingIntent)}, using this action * allows the the underlying eUICC service (i.e. the LPA app) to control the UI experience * during this operation. The action is received by the Telephony framework, which in turn @@ -260,6 +272,8 @@ public class EuiccManager { * {@link #ACTION_DELETE_SUBSCRIPTION_PRIVILEGED}, and * {@link #ACTION_RENAME_SUBSCRIPTION_PRIVILEGED} providing the ID of the targeted subscription. * + * <p>Expected type of the extra data: int + * * @hide */ @SystemApi @@ -270,6 +284,8 @@ public class EuiccManager { * Key for an extra set on {@link #ACTION_TOGGLE_SUBSCRIPTION_PRIVILEGED} providing a boolean * value of whether to enable or disable the targeted subscription. * + * <p>Expected type of the extra data: boolean + * * @hide */ @SystemApi @@ -280,6 +296,8 @@ public class EuiccManager { * Key for an extra set on {@link #ACTION_RENAME_SUBSCRIPTION_PRIVILEGED} providing a new * nickname for the targeted subscription. * + * <p>Expected type of the extra data: String + * * @hide */ @SystemApi @@ -287,6 +305,22 @@ public class EuiccManager { "android.telephony.euicc.extra.SUBSCRIPTION_NICKNAME"; /** + * Key for an extra set on {@link #ACTION_TOGGLE_SUBSCRIPTION_PRIVILEGED} providing the ID of + * the subscription we're toggling from. This extra is optional and is only used for UI + * purposes by the underlying eUICC service (i.e. the LPA app), such as displaying a dialog + * titled "Switch X with Y". If set, the provided subscription will be used as the "from" + * subscription in UI (the "X" in the dialog example). Otherwise, the currently active + * subscription that will be disabled is the "from" subscription. + * + * <p>Expected type of the extra data: int + * + * @hide + */ + @SystemApi + public static final String EXTRA_FROM_SUBSCRIPTION_ID = + "android.telephony.euicc.extra.FROM_SUBSCRIPTION_ID"; + + /** * Optional meta-data attribute for a carrier app providing an icon to use to represent the * carrier. If not provided, the app's launcher icon will be used as a fallback. */ diff --git a/telephony/java/android/telephony/ims/ImsException.java b/telephony/java/android/telephony/ims/ImsException.java index 02eddf67e25b..8c686f704967 100644 --- a/telephony/java/android/telephony/ims/ImsException.java +++ b/telephony/java/android/telephony/ims/ImsException.java @@ -31,7 +31,7 @@ import java.lang.annotation.RetentionPolicy; * @hide */ @SystemApi -public class ImsException extends Exception { +public final class ImsException extends Exception { /** * The operation has failed due to an unknown or unspecified error. diff --git a/telephony/java/android/telephony/ims/feature/ImsFeature.java b/telephony/java/android/telephony/ims/feature/ImsFeature.java index b55866b5c1c8..5e3f3983b0a1 100644 --- a/telephony/java/android/telephony/ims/feature/ImsFeature.java +++ b/telephony/java/android/telephony/ims/feature/ImsFeature.java @@ -210,6 +210,7 @@ public abstract class ImsFeature { /** * Contains the capabilities defined and supported by an ImsFeature in the form of a bit mask. * @hide + * @deprecated Use {@link MmTelFeature.MmTelCapabilities} instead. */ @SystemApi // SystemApi only because it was leaked through type usage in a previous release. public static class Capabilities { diff --git a/telephony/java/com/android/internal/telephony/ITelephony.aidl b/telephony/java/com/android/internal/telephony/ITelephony.aidl index 02a5bc8937ee..c8dab272de3e 100644 --- a/telephony/java/com/android/internal/telephony/ITelephony.aidl +++ b/telephony/java/com/android/internal/telephony/ITelephony.aidl @@ -788,12 +788,13 @@ interface ITelephony { int getPreferredNetworkType(int subId); /** - * Check whether DUN APN is required for tethering. + * Check whether DUN APN is required for tethering with subId. * + * @param subId the id of the subscription to require tethering. * @return {@code true} if DUN APN is required for tethering. * @hide */ - boolean getTetherApnRequired(); + boolean getTetherApnRequiredForSubscriber(int subId); /** * Enables framework IMS and triggers IMS Registration. @@ -1699,6 +1700,11 @@ interface ITelephony { */ int getNetworkSelectionMode(int subId); + /** + * Return true if the device is in emergency sms mode, false otherwise. + */ + boolean isInEmergencySmsMode(); + /** * Get a list of SMS apps on a user. */ @@ -1911,15 +1917,18 @@ interface ITelephony { * Indicate if the enablement of multi SIM functionality is restricted. * @hide */ - void setMultisimCarrierRestriction(boolean isMultisimCarrierRestricted); + void setMultiSimCarrierRestriction(boolean isMultiSimCarrierRestricted); /** * Returns if the usage of multiple SIM cards at the same time is supported. * * @param callingPackage The package making the call. - * @return true if multisim is supported, false otherwise. + * @return {@link #MULTISIM_ALLOWED} if the device supports multiple SIMs. + * {@link #MULTISIM_NOT_SUPPORTED_BY_HARDWARE} if the device does not support multiple SIMs. + * {@link #MULTISIM_NOT_SUPPORTED_BY_CARRIER} in the device supports multiple SIMs, but the + * functionality is restricted by the carrier. */ - boolean isMultisimSupported(String callingPackage); + int isMultiSimSupported(String callingPackage); /** * Switch configs to enable multi-sim or switch back to single-sim diff --git a/tests/ActivityManagerPerfTests/test-app/Android.bp b/tests/ActivityManagerPerfTests/test-app/Android.bp new file mode 100644 index 000000000000..ef9d587581c4 --- /dev/null +++ b/tests/ActivityManagerPerfTests/test-app/Android.bp @@ -0,0 +1,21 @@ +// Copyright (C) 2018 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. + +android_test { + name: "ActivityManagerPerfTestsTestApp", + srcs: ["src/**/*.java"], + static_libs: ["ActivityManagerPerfTestsUtils"], + min_sdk_version: "25", + sdk_version: "current", +} diff --git a/tests/ActivityManagerPerfTests/test-app/Android.mk b/tests/ActivityManagerPerfTests/test-app/Android.mk deleted file mode 100644 index 33d15d2a3387..000000000000 --- a/tests/ActivityManagerPerfTests/test-app/Android.mk +++ /dev/null @@ -1,31 +0,0 @@ -# Copyright (C) 2018 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. - -LOCAL_PATH := $(call my-dir) -include $(CLEAR_VARS) - -LOCAL_MODULE_TAGS := tests - -LOCAL_SRC_FILES := \ - $(call all-java-files-under, src) - -LOCAL_STATIC_JAVA_LIBRARIES := \ - ActivityManagerPerfTestsUtils - -LOCAL_MIN_SDK_VERSION := 25 - -LOCAL_PACKAGE_NAME := ActivityManagerPerfTestsTestApp -LOCAL_SDK_VERSION := current - -include $(BUILD_PACKAGE) diff --git a/tests/ActivityManagerPerfTests/tests/Android.bp b/tests/ActivityManagerPerfTests/tests/Android.bp new file mode 100644 index 000000000000..268715c6d1a6 --- /dev/null +++ b/tests/ActivityManagerPerfTests/tests/Android.bp @@ -0,0 +1,27 @@ +// Copyright (C) 2018 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. + +android_test { + name: "ActivityManagerPerfTests", + srcs: ["src/**/*.java"], + static_libs: [ + "android-support-test", + "apct-perftests-utils", + "ActivityManagerPerfTestsUtils", + ], + platform_apis: true, + min_sdk_version: "25", + // For android.permission.FORCE_STOP_PACKAGES permission + certificate: "platform", +} diff --git a/tests/ActivityManagerPerfTests/tests/Android.mk b/tests/ActivityManagerPerfTests/tests/Android.mk deleted file mode 100644 index f23a665dc5b2..000000000000 --- a/tests/ActivityManagerPerfTests/tests/Android.mk +++ /dev/null @@ -1,36 +0,0 @@ -# Copyright (C) 2018 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. - -LOCAL_PATH := $(call my-dir) -include $(CLEAR_VARS) - -LOCAL_MODULE_TAGS := tests - -LOCAL_SRC_FILES := \ - $(call all-java-files-under, src) - -LOCAL_STATIC_JAVA_LIBRARIES := \ - android-support-test \ - apct-perftests-utils \ - ActivityManagerPerfTestsUtils - -LOCAL_PACKAGE_NAME := ActivityManagerPerfTests -LOCAL_PRIVATE_PLATFORM_APIS := true - -LOCAL_MIN_SDK_VERSION := 25 - -# For android.permission.FORCE_STOP_PACKAGES permission -LOCAL_CERTIFICATE := platform - -include $(BUILD_PACKAGE) diff --git a/tests/ActivityManagerPerfTests/utils/Android.bp b/tests/ActivityManagerPerfTests/utils/Android.bp new file mode 100644 index 000000000000..c052656346cc --- /dev/null +++ b/tests/ActivityManagerPerfTests/utils/Android.bp @@ -0,0 +1,27 @@ +// Copyright (C) 2018 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. + +java_test { + name: "ActivityManagerPerfTestsUtils", + sdk_version: "current", + srcs: [ + "src/**/*.java", + "src/com/android/frameworks/perftests/am/util/ITimeReceiverCallback.aidl", + ], + static_libs: [ + "android-support-test", + "junit", + "ub-uiautomator", + ], +} diff --git a/tests/ActivityManagerPerfTests/utils/Android.mk b/tests/ActivityManagerPerfTests/utils/Android.mk deleted file mode 100644 index 60c94239d85f..000000000000 --- a/tests/ActivityManagerPerfTests/utils/Android.mk +++ /dev/null @@ -1,32 +0,0 @@ -# Copyright (C) 2018 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. - -LOCAL_PATH := $(call my-dir) -include $(CLEAR_VARS) - -LOCAL_MODULE_TAGS := tests -LOCAL_SDK_VERSION := current - -LOCAL_SRC_FILES := \ - $(call all-java-files-under, src) \ - src/com/android/frameworks/perftests/am/util/ITimeReceiverCallback.aidl - -LOCAL_STATIC_JAVA_LIBRARIES := \ - android-support-test \ - junit \ - ub-uiautomator - -LOCAL_MODULE := ActivityManagerPerfTestsUtils - -include $(BUILD_STATIC_JAVA_LIBRARY) diff --git a/tests/AppLaunch/Android.bp b/tests/AppLaunch/Android.bp new file mode 100644 index 000000000000..0f07da61bc91 --- /dev/null +++ b/tests/AppLaunch/Android.bp @@ -0,0 +1,13 @@ +android_test { + name: "AppLaunch", + // Only compile source java files in this apk. + srcs: ["src/**/*.java"], + platform_apis: true, + certificate: "platform", + libs: [ + "android.test.base", + "android.test.runner", + ], + static_libs: ["android-support-test"], + test_suites: ["device-tests"], +} diff --git a/tests/AppLaunch/Android.mk b/tests/AppLaunch/Android.mk deleted file mode 100644 index 1fb548b0edde..000000000000 --- a/tests/AppLaunch/Android.mk +++ /dev/null @@ -1,22 +0,0 @@ -LOCAL_PATH:= $(call my-dir) -include $(CLEAR_VARS) - -LOCAL_MODULE_TAGS := tests - -# Only compile source java files in this apk. -LOCAL_SRC_FILES := $(call all-java-files-under, src) - -LOCAL_PACKAGE_NAME := AppLaunch -LOCAL_PRIVATE_PLATFORM_APIS := true - -LOCAL_CERTIFICATE := platform -LOCAL_JAVA_LIBRARIES := android.test.base android.test.runner - -LOCAL_STATIC_JAVA_LIBRARIES := android-support-test - -LOCAL_COMPATIBILITY_SUITE := device-tests - -include $(BUILD_PACKAGE) - -# Use the following include to make our test apk. -include $(call all-makefiles-under,$(LOCAL_PATH)) diff --git a/tests/AppLaunchWear/Android.bp b/tests/AppLaunchWear/Android.bp new file mode 100644 index 000000000000..6a8b38200700 --- /dev/null +++ b/tests/AppLaunchWear/Android.bp @@ -0,0 +1,13 @@ +android_test { + name: "AppLaunchWear", + // Only compile source java files in this apk. + srcs: ["src/**/*.java"], + platform_apis: true, + certificate: "platform", + libs: [ + "android.test.base", + "android.test.runner", + ], + static_libs: ["android-support-test"], + test_suites: ["device-tests"], +} diff --git a/tests/AppLaunchWear/Android.mk b/tests/AppLaunchWear/Android.mk deleted file mode 100644 index 6d083661324d..000000000000 --- a/tests/AppLaunchWear/Android.mk +++ /dev/null @@ -1,22 +0,0 @@ -LOCAL_PATH:= $(call my-dir) -include $(CLEAR_VARS) - -LOCAL_MODULE_TAGS := tests - -# Only compile source java files in this apk. -LOCAL_SRC_FILES := $(call all-java-files-under, src) - -LOCAL_PACKAGE_NAME := AppLaunchWear -LOCAL_PRIVATE_PLATFORM_APIS := true - -LOCAL_CERTIFICATE := platform -LOCAL_JAVA_LIBRARIES := android.test.base android.test.runner - -LOCAL_STATIC_JAVA_LIBRARIES := android-support-test - -LOCAL_COMPATIBILITY_SUITE := device-tests - -include $(BUILD_PACKAGE) - -# Use the following include to make our test apk. -include $(call all-makefiles-under,$(LOCAL_PATH)) diff --git a/tests/BackgroundDexOptServiceIntegrationTests/Android.bp b/tests/BackgroundDexOptServiceIntegrationTests/Android.bp new file mode 100644 index 000000000000..036f84526889 --- /dev/null +++ b/tests/BackgroundDexOptServiceIntegrationTests/Android.bp @@ -0,0 +1,24 @@ +// +// Copyright (C) 2017 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. +// + +android_test { + name: "BackgroundDexOptServiceIntegrationTests", + srcs: ["src/**/*.java"], + static_libs: ["android-support-test"], + platform_apis: true, + test_suites: ["device-tests"], + certificate: "platform", +} diff --git a/tests/BackgroundDexOptServiceIntegrationTests/Android.mk b/tests/BackgroundDexOptServiceIntegrationTests/Android.mk deleted file mode 100644 index b10305d96fce..000000000000 --- a/tests/BackgroundDexOptServiceIntegrationTests/Android.mk +++ /dev/null @@ -1,35 +0,0 @@ -# -# Copyright (C) 2017 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. -# - -LOCAL_PATH:= $(call my-dir) -include $(CLEAR_VARS) - -# We only want this apk build for tests. -LOCAL_MODULE_TAGS := tests - -# Include all test java files. -LOCAL_SRC_FILES := $(call all-java-files-under, src) - -LOCAL_STATIC_JAVA_LIBRARIES := \ - android-support-test \ - -LOCAL_PACKAGE_NAME := BackgroundDexOptServiceIntegrationTests -LOCAL_PRIVATE_PLATFORM_APIS := true -LOCAL_COMPATIBILITY_SUITE := device-tests - -LOCAL_CERTIFICATE := platform - -include $(BUILD_PACKAGE) diff --git a/tests/Compatibility/Android.bp b/tests/Compatibility/Android.bp new file mode 100644 index 000000000000..a0c37619841f --- /dev/null +++ b/tests/Compatibility/Android.bp @@ -0,0 +1,22 @@ +// Copyright (C) 2012 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. + +android_test { + name: "AppCompatibilityTest", + static_libs: ["android-support-test"], + // Include all test java files. + srcs: ["src/**/*.java"], + platform_apis: true, + certificate: "platform", +} diff --git a/tests/Compatibility/Android.mk b/tests/Compatibility/Android.mk deleted file mode 100644 index 9c47a2610223..000000000000 --- a/tests/Compatibility/Android.mk +++ /dev/null @@ -1,31 +0,0 @@ -# Copyright (C) 2012 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. - -LOCAL_PATH := $(call my-dir) -include $(CLEAR_VARS) - -# We only want this apk build for tests. -LOCAL_MODULE_TAGS := tests -LOCAL_STATIC_JAVA_LIBRARIES := android-support-test -# Include all test java files. -LOCAL_SRC_FILES := \ - $(call all-java-files-under, src) - - -LOCAL_PACKAGE_NAME := AppCompatibilityTest -LOCAL_PRIVATE_PLATFORM_APIS := true -LOCAL_CERTIFICATE := platform -include $(BUILD_PACKAGE) - -include $(call all-makefiles-under,$(LOCAL_PATH)) diff --git a/tests/Internal/Android.bp b/tests/Internal/Android.bp new file mode 100644 index 000000000000..db3e03bf20ed --- /dev/null +++ b/tests/Internal/Android.bp @@ -0,0 +1,18 @@ +android_test { + name: "InternalTests", + proto: { + type: "nano", + }, + // Include some source files directly to be able to access package members + srcs: ["src/**/*.java"], + libs: ["android.test.runner"], + static_libs: [ + "junit", + "android-support-test", + "mockito-target-minus-junit4", + ], + java_resource_dirs: ["res"], + certificate: "platform", + platform_apis: true, + test_suites: ["device-tests"], +} diff --git a/tests/Internal/Android.mk b/tests/Internal/Android.mk deleted file mode 100644 index da566967fbeb..000000000000 --- a/tests/Internal/Android.mk +++ /dev/null @@ -1,24 +0,0 @@ -LOCAL_PATH:= $(call my-dir) -include $(CLEAR_VARS) - -LOCAL_USE_AAPT2 := true -LOCAL_MODULE_TAGS := tests - -LOCAL_PROTOC_OPTIMIZE_TYPE := nano - -# Include some source files directly to be able to access package members -LOCAL_SRC_FILES := $(call all-java-files-under, src) - -LOCAL_JAVA_LIBRARIES := android.test.runner -LOCAL_STATIC_JAVA_LIBRARIES := junit \ - android-support-test \ - mockito-target-minus-junit4 - -LOCAL_JAVA_RESOURCE_DIRS := res -LOCAL_CERTIFICATE := platform - -LOCAL_PACKAGE_NAME := InternalTests -LOCAL_PRIVATE_PLATFORM_APIS := true -LOCAL_COMPATIBILITY_SUITE := device-tests - -include $(BUILD_PACKAGE) diff --git a/tests/JankBench/app/src/main/jni/Android.bp.converted b/tests/JankBench/app/src/main/jni/Android.bp.converted index 9fecf1599fd9..b53c79ad8b7c 100644 --- a/tests/JankBench/app/src/main/jni/Android.bp.converted +++ b/tests/JankBench/app/src/main/jni/Android.bp.converted @@ -12,12 +12,20 @@ // See the License for the specific language governing permissions and // limitations under the License. +<<<<<<< HEAD cc_library_shared { name: "libnativebench", cflags: [ "-Wno-unused-parameter", "-Wno-unused-variable", ], +======= +// ANDROIDMK TRANSLATION WARNING: No 'include $(CLEAR_VARS)' detected before first assignment; clearing vars now + +cc_library_shared { + name: "libnativebench", + cflags: ["-Wno-unused-parameter"], +>>>>>>> Convert Android.mk file to Android.bp srcs: [ "Bench.cpp", "WorkerPool.cpp", diff --git a/tests/RcsTests/Android.bp b/tests/RcsTests/Android.bp new file mode 100644 index 000000000000..81c6df070881 --- /dev/null +++ b/tests/RcsTests/Android.bp @@ -0,0 +1,17 @@ +android_test { + name: "RcsTests", + // Only compile source java files in this apk. + srcs: ["src/**/*.java"], + platform_apis: true, + certificate: "platform", + libs: [ + "android.test.runner", + "android.test.base", + ], + static_libs: [ + "junit", + "android-support-test", + "mockito-target-minus-junit4", + "truth-prebuilt", + ], +} diff --git a/tests/RcsTests/Android.mk b/tests/RcsTests/Android.mk deleted file mode 100644 index 7b348d73747a..000000000000 --- a/tests/RcsTests/Android.mk +++ /dev/null @@ -1,19 +0,0 @@ -LOCAL_PATH:= $(call my-dir) -include $(CLEAR_VARS) - -LOCAL_MODULE_TAGS := tests - -# Only compile source java files in this apk. -LOCAL_SRC_FILES := $(call all-java-files-under, src) - -LOCAL_PACKAGE_NAME := RcsTests -LOCAL_PRIVATE_PLATFORM_APIS := true - -LOCAL_CERTIFICATE := platform -LOCAL_JAVA_LIBRARIES := android.test.runner android.test.base -LOCAL_STATIC_JAVA_LIBRARIES := junit android-support-test mockito-target-minus-junit4 truth-prebuilt - -include $(BUILD_PACKAGE) - -# Use the following include to make our test apk. -include $(call all-makefiles-under,$(LOCAL_PATH)) diff --git a/tests/ServiceCrashTest/Android.bp b/tests/ServiceCrashTest/Android.bp new file mode 100644 index 000000000000..b646ae7d33d3 --- /dev/null +++ b/tests/ServiceCrashTest/Android.bp @@ -0,0 +1,12 @@ +android_test { + name: "ServiceCrashTest", + // Only compile source java files in this apk. + srcs: ["src/**/*.java"], + platform_apis: true, + certificate: "platform", + libs: ["android.test.base"], + static_libs: [ + "compatibility-device-util", + "android-support-test", + ], +} diff --git a/tests/ServiceCrashTest/Android.mk b/tests/ServiceCrashTest/Android.mk deleted file mode 100644 index d1f6450e84a6..000000000000 --- a/tests/ServiceCrashTest/Android.mk +++ /dev/null @@ -1,20 +0,0 @@ -LOCAL_PATH:= $(call my-dir) -include $(CLEAR_VARS) - -LOCAL_MODULE_TAGS := tests - -# Only compile source java files in this apk. -LOCAL_SRC_FILES := $(call all-java-files-under, src) - -LOCAL_PACKAGE_NAME := ServiceCrashTest -LOCAL_PRIVATE_PLATFORM_APIS := true - -LOCAL_CERTIFICATE := platform -LOCAL_JAVA_LIBRARIES := android.test.base - -LOCAL_STATIC_JAVA_LIBRARIES := compatibility-device-util android-support-test - -include $(BUILD_PACKAGE) - -# Use the following include to make our test apk. -include $(call all-makefiles-under,$(LOCAL_PATH)) diff --git a/tests/SurfaceComposition/Android.bp b/tests/SurfaceComposition/Android.bp new file mode 100644 index 000000000000..53e4d52b2efd --- /dev/null +++ b/tests/SurfaceComposition/Android.bp @@ -0,0 +1,32 @@ +// Copyright (C) 2015 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. + +android_test { + name: "SurfaceComposition", + // Don't include this package in any target + // When built, explicitly put it in the data partition. + dex_preopt: { + enabled: false, + }, + optimize: { + enabled: false, + }, + srcs: ["src/**/*.java"], + static_libs: ["junit"], + libs: [ + "android.test.runner.stubs", + "android.test.base.stubs", + ], + sdk_version: "current", +} diff --git a/tests/SurfaceComposition/Android.mk b/tests/SurfaceComposition/Android.mk deleted file mode 100644 index f59458d48c68..000000000000 --- a/tests/SurfaceComposition/Android.mk +++ /dev/null @@ -1,38 +0,0 @@ -# Copyright (C) 2015 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. - -LOCAL_PATH:= $(call my-dir) - -include $(CLEAR_VARS) - -# Don't include this package in any target -LOCAL_MODULE_TAGS := tests -# When built, explicitly put it in the data partition. -LOCAL_MODULE_PATH := $(TARGET_OUT_DATA_APPS) - -LOCAL_DEX_PREOPT := false - -LOCAL_PROGUARD_ENABLED := disabled - -LOCAL_SRC_FILES := $(call all-java-files-under, src) - -LOCAL_STATIC_JAVA_LIBRARIES := junit - -LOCAL_JAVA_LIBRARIES := android.test.runner.stubs android.test.base.stubs - -LOCAL_PACKAGE_NAME := SurfaceComposition - -LOCAL_SDK_VERSION := current - -include $(BUILD_PACKAGE) diff --git a/tests/UsbHostExternalManagmentTest/AoapTestDevice/Android.bp b/tests/UsbHostExternalManagmentTest/AoapTestDevice/Android.bp new file mode 100644 index 000000000000..c7e9df0fe9cf --- /dev/null +++ b/tests/UsbHostExternalManagmentTest/AoapTestDevice/Android.bp @@ -0,0 +1,27 @@ +// Copyright (C) 2016 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. +// +// + +//################################################# + +android_test { + name: "AoapTestDeviceApp", + srcs: ["src/**/*.java"], + resource_dirs: ["res"], + platform_apis: true, + optimize: { + enabled: false, + }, +} diff --git a/tests/UsbHostExternalManagmentTest/AoapTestDevice/Android.mk b/tests/UsbHostExternalManagmentTest/AoapTestDevice/Android.mk deleted file mode 100644 index cd7aaedf2bb1..000000000000 --- a/tests/UsbHostExternalManagmentTest/AoapTestDevice/Android.mk +++ /dev/null @@ -1,36 +0,0 @@ -# Copyright (C) 2016 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. -# -# - -LOCAL_PATH:= $(call my-dir) - -################################################## - -include $(CLEAR_VARS) - -LOCAL_SRC_FILES := $(call all-java-files-under, src) - -LOCAL_RESOURCE_DIR := $(LOCAL_PATH)/res - -LOCAL_PACKAGE_NAME := AoapTestDeviceApp -LOCAL_PRIVATE_PLATFORM_APIS := true - -LOCAL_MODULE_TAGS := tests -LOCAL_MODULE_PATH := $(TARGET_OUT_DATA_APPS) - -LOCAL_PROGUARD_ENABLED := disabled - -include $(BUILD_PACKAGE) - diff --git a/tests/UsbHostExternalManagmentTest/AoapTestHost/Android.bp b/tests/UsbHostExternalManagmentTest/AoapTestHost/Android.bp new file mode 100644 index 000000000000..6fa58cb5c682 --- /dev/null +++ b/tests/UsbHostExternalManagmentTest/AoapTestHost/Android.bp @@ -0,0 +1,27 @@ +// Copyright (C) 2016 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. +// +// + +//################################################# + +android_test { + name: "AoapTestHostApp", + srcs: ["src/**/*.java"], + resource_dirs: ["res"], + platform_apis: true, + optimize: { + enabled: false, + }, +} diff --git a/tests/UsbHostExternalManagmentTest/AoapTestHost/Android.mk b/tests/UsbHostExternalManagmentTest/AoapTestHost/Android.mk deleted file mode 100644 index bd8a51b69bff..000000000000 --- a/tests/UsbHostExternalManagmentTest/AoapTestHost/Android.mk +++ /dev/null @@ -1,36 +0,0 @@ -# Copyright (C) 2016 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. -# -# - -LOCAL_PATH:= $(call my-dir) - -################################################## - -include $(CLEAR_VARS) - -LOCAL_SRC_FILES := $(call all-java-files-under, src) - -LOCAL_RESOURCE_DIR := $(LOCAL_PATH)/res - -LOCAL_PACKAGE_NAME := AoapTestHostApp -LOCAL_PRIVATE_PLATFORM_APIS := true - -LOCAL_MODULE_TAGS := tests -LOCAL_MODULE_PATH := $(TARGET_OUT_DATA_APPS) - -LOCAL_PROGUARD_ENABLED := disabled - -include $(BUILD_PACKAGE) - diff --git a/tests/UsbHostExternalManagmentTest/UsbHostExternalManagmentTestApp/Android.bp b/tests/UsbHostExternalManagmentTest/UsbHostExternalManagmentTestApp/Android.bp new file mode 100644 index 000000000000..edd4205968b3 --- /dev/null +++ b/tests/UsbHostExternalManagmentTest/UsbHostExternalManagmentTestApp/Android.bp @@ -0,0 +1,32 @@ +// Copyright (C) 2016 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. +// +// + +//################################################# + +// TODO: should this be android_helper_test_app? +android_app { + name: "UsbHostExternalManagementTestApp", + srcs: ["src/**/*.java"], + resource_dirs: ["res"], + platform_apis: true, + privileged: true, + // TODO remove tests tag + //LOCAL_MODULE_TAGS := tests + //LOCAL_MODULE_PATH := $(TARGET_OUT_DATA_APPS) + optimize: { + enabled: false, + }, +} diff --git a/tests/UsbHostExternalManagmentTest/UsbHostExternalManagmentTestApp/Android.mk b/tests/UsbHostExternalManagmentTest/UsbHostExternalManagmentTestApp/Android.mk deleted file mode 100644 index fed454eb9d01..000000000000 --- a/tests/UsbHostExternalManagmentTest/UsbHostExternalManagmentTestApp/Android.mk +++ /dev/null @@ -1,38 +0,0 @@ -# Copyright (C) 2016 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. -# -# - -LOCAL_PATH:= $(call my-dir) - -################################################## - -include $(CLEAR_VARS) - -LOCAL_SRC_FILES := $(call all-java-files-under, src) - -LOCAL_RESOURCE_DIR := $(LOCAL_PATH)/res - -LOCAL_PACKAGE_NAME := UsbHostExternalManagementTestApp -LOCAL_PRIVATE_PLATFORM_APIS := true - -LOCAL_PRIVILEGED_MODULE := true -# TODO remove tests tag -#LOCAL_MODULE_TAGS := tests -#LOCAL_MODULE_PATH := $(TARGET_OUT_DATA_APPS) - -LOCAL_PROGUARD_ENABLED := disabled - -include $(BUILD_PACKAGE) - diff --git a/tests/UsbTests/Android.bp b/tests/UsbTests/Android.bp new file mode 100644 index 000000000000..7dc7c85b25de --- /dev/null +++ b/tests/UsbTests/Android.bp @@ -0,0 +1,34 @@ +// +// Copyright (C) 2018 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. +// + +android_test { + name: "UsbTests", + srcs: ["**/*.java"], + static_libs: [ + "frameworks-base-testutils", + "android-support-test", + "mockito-target-inline-minus-junit4", + "platform-test-annotations", + "services.core", + "services.net", + "services.usb", + "truth-prebuilt", + ], + jni_libs: ["libdexmakerjvmtiagent"], + certificate: "platform", + platform_apis: true, + test_suites: ["device-tests"], +} diff --git a/tests/UsbTests/Android.mk b/tests/UsbTests/Android.mk deleted file mode 100644 index 4e215cc5996f..000000000000 --- a/tests/UsbTests/Android.mk +++ /dev/null @@ -1,45 +0,0 @@ -# -# Copyright (C) 2018 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. -# - -LOCAL_PATH:= $(call my-dir) - -include $(CLEAR_VARS) - -LOCAL_MODULE_TAGS := tests - -LOCAL_SRC_FILES := $(call all-subdir-java-files) - -LOCAL_STATIC_JAVA_LIBRARIES := \ - frameworks-base-testutils \ - android-support-test \ - mockito-target-inline-minus-junit4 \ - platform-test-annotations \ - services.core \ - services.net \ - services.usb \ - truth-prebuilt \ - -LOCAL_JNI_SHARED_LIBRARIES := \ - libdexmakerjvmtiagent \ - -LOCAL_CERTIFICATE := platform - -LOCAL_PACKAGE_NAME := UsbTests -LOCAL_PRIVATE_PLATFORM_APIS := true - -LOCAL_COMPATIBILITY_SUITE := device-tests - -include $(BUILD_PACKAGE) diff --git a/tests/WindowAnimationJank/Android.bp b/tests/WindowAnimationJank/Android.bp new file mode 100644 index 000000000000..60e8f7417194 --- /dev/null +++ b/tests/WindowAnimationJank/Android.bp @@ -0,0 +1,25 @@ +// Copyright (C) 2015 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. + +android_test { + name: "WindowAnimationJank", + srcs: ["src/**/*.java"], + static_libs: [ + "ub-uiautomator", + "ub-janktesthelper", + "junit", + ], + libs: ["android.test.base.stubs"], + sdk_version: "current", +} diff --git a/tests/WindowAnimationJank/Android.mk b/tests/WindowAnimationJank/Android.mk deleted file mode 100644 index 7800a8078d2a..000000000000 --- a/tests/WindowAnimationJank/Android.mk +++ /dev/null @@ -1,36 +0,0 @@ -# Copyright (C) 2015 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. - -LOCAL_PATH:= $(call my-dir) - -include $(CLEAR_VARS) - -LOCAL_MODULE_TAGS := tests - -LOCAL_MODULE_PATH := $(TARGET_OUT_DATA_APPS) - -LOCAL_SRC_FILES := $(call all-java-files-under, src) - -LOCAL_PACKAGE_NAME := WindowAnimationJank - -LOCAL_STATIC_JAVA_LIBRARIES := \ - ub-uiautomator \ - ub-janktesthelper \ - junit - -LOCAL_JAVA_LIBRARIES := android.test.base.stubs - -LOCAL_SDK_VERSION := current - -include $(BUILD_PACKAGE) diff --git a/tests/net/java/android/net/LinkAddressTest.java b/tests/net/java/android/net/LinkAddressTest.java index be7bd1b108b0..d462441b22fa 100644 --- a/tests/net/java/android/net/LinkAddressTest.java +++ b/tests/net/java/android/net/LinkAddressTest.java @@ -81,14 +81,14 @@ public class LinkAddressTest { assertEquals(25, address.getPrefixLength()); assertEquals(0, address.getFlags()); assertEquals(RT_SCOPE_UNIVERSE, address.getScope()); - assertTrue(address.isIPv4()); + assertTrue(address.isIpv4()); address = new LinkAddress(V6_ADDRESS, 127); assertEquals(V6_ADDRESS, address.getAddress()); assertEquals(127, address.getPrefixLength()); assertEquals(0, address.getFlags()); assertEquals(RT_SCOPE_UNIVERSE, address.getScope()); - assertTrue(address.isIPv6()); + assertTrue(address.isIpv6()); // Nonsensical flags/scopes or combinations thereof are acceptable. address = new LinkAddress(V6 + "/64", IFA_F_DEPRECATED | IFA_F_PERMANENT, RT_SCOPE_LINK); @@ -96,14 +96,14 @@ public class LinkAddressTest { assertEquals(64, address.getPrefixLength()); assertEquals(IFA_F_DEPRECATED | IFA_F_PERMANENT, address.getFlags()); assertEquals(RT_SCOPE_LINK, address.getScope()); - assertTrue(address.isIPv6()); + assertTrue(address.isIpv6()); address = new LinkAddress(V4 + "/23", 123, 456); assertEquals(V4_ADDRESS, address.getAddress()); assertEquals(23, address.getPrefixLength()); assertEquals(123, address.getFlags()); assertEquals(456, address.getScope()); - assertTrue(address.isIPv4()); + assertTrue(address.isIpv4()); // InterfaceAddress doesn't have a constructor. Fetch some from an interface. List<InterfaceAddress> addrs = NetworkInterface.getByName("lo").getInterfaceAddresses(); diff --git a/tests/net/java/android/net/LinkPropertiesTest.java b/tests/net/java/android/net/LinkPropertiesTest.java index 9a7d48723e8c..417729150be8 100644 --- a/tests/net/java/android/net/LinkPropertiesTest.java +++ b/tests/net/java/android/net/LinkPropertiesTest.java @@ -405,8 +405,8 @@ public class LinkPropertiesTest { LinkProperties lp = new LinkProperties(); // No addresses. - assertFalse(lp.hasIPv4Address()); - assertFalse(lp.hasGlobalIPv6Address()); + assertFalse(lp.hasIpv4Address()); + assertFalse(lp.hasGlobalIpv6Address()); // Addresses on stacked links don't count. LinkProperties stacked = new LinkProperties(); @@ -414,53 +414,53 @@ public class LinkPropertiesTest { lp.addStackedLink(stacked); stacked.addLinkAddress(LINKADDRV4); stacked.addLinkAddress(LINKADDRV6); - assertTrue(stacked.hasIPv4Address()); - assertTrue(stacked.hasGlobalIPv6Address()); - assertFalse(lp.hasIPv4Address()); - assertFalse(lp.hasGlobalIPv6Address()); + assertTrue(stacked.hasIpv4Address()); + assertTrue(stacked.hasGlobalIpv6Address()); + assertFalse(lp.hasIpv4Address()); + assertFalse(lp.hasGlobalIpv6Address()); lp.removeStackedLink("stacked"); - assertFalse(lp.hasIPv4Address()); - assertFalse(lp.hasGlobalIPv6Address()); + assertFalse(lp.hasIpv4Address()); + assertFalse(lp.hasGlobalIpv6Address()); // Addresses on the base link. - // Check the return values of hasIPvXAddress and ensure the add/remove methods return true + // Check the return values of hasIpvXAddress and ensure the add/remove methods return true // iff something changes. assertEquals(0, lp.getLinkAddresses().size()); assertTrue(lp.addLinkAddress(LINKADDRV6)); assertEquals(1, lp.getLinkAddresses().size()); - assertFalse(lp.hasIPv4Address()); - assertTrue(lp.hasGlobalIPv6Address()); + assertFalse(lp.hasIpv4Address()); + assertTrue(lp.hasGlobalIpv6Address()); assertTrue(lp.removeLinkAddress(LINKADDRV6)); assertEquals(0, lp.getLinkAddresses().size()); assertTrue(lp.addLinkAddress(LINKADDRV6LINKLOCAL)); assertEquals(1, lp.getLinkAddresses().size()); - assertFalse(lp.hasGlobalIPv6Address()); + assertFalse(lp.hasGlobalIpv6Address()); assertTrue(lp.addLinkAddress(LINKADDRV4)); assertEquals(2, lp.getLinkAddresses().size()); - assertTrue(lp.hasIPv4Address()); - assertFalse(lp.hasGlobalIPv6Address()); + assertTrue(lp.hasIpv4Address()); + assertFalse(lp.hasGlobalIpv6Address()); assertTrue(lp.addLinkAddress(LINKADDRV6)); assertEquals(3, lp.getLinkAddresses().size()); - assertTrue(lp.hasIPv4Address()); - assertTrue(lp.hasGlobalIPv6Address()); + assertTrue(lp.hasIpv4Address()); + assertTrue(lp.hasGlobalIpv6Address()); assertTrue(lp.removeLinkAddress(LINKADDRV6LINKLOCAL)); assertEquals(2, lp.getLinkAddresses().size()); - assertTrue(lp.hasIPv4Address()); - assertTrue(lp.hasGlobalIPv6Address()); + assertTrue(lp.hasIpv4Address()); + assertTrue(lp.hasGlobalIpv6Address()); // Adding an address twice has no effect. // Removing an address that's not present has no effect. assertFalse(lp.addLinkAddress(LINKADDRV4)); assertEquals(2, lp.getLinkAddresses().size()); - assertTrue(lp.hasIPv4Address()); + assertTrue(lp.hasIpv4Address()); assertTrue(lp.removeLinkAddress(LINKADDRV4)); assertEquals(1, lp.getLinkAddresses().size()); - assertFalse(lp.hasIPv4Address()); + assertFalse(lp.hasIpv4Address()); assertFalse(lp.removeLinkAddress(LINKADDRV4)); assertEquals(1, lp.getLinkAddresses().size()); @@ -546,8 +546,8 @@ public class LinkPropertiesTest { assertFalse("v4only:addr+dns", lp4.isProvisioned()); lp4.addRoute(new RouteInfo(GATEWAY1)); assertTrue("v4only:addr+dns+route", lp4.isProvisioned()); - assertTrue("v4only:addr+dns+route", lp4.isIPv4Provisioned()); - assertFalse("v4only:addr+dns+route", lp4.isIPv6Provisioned()); + assertTrue("v4only:addr+dns+route", lp4.isIpv4Provisioned()); + assertFalse("v4only:addr+dns+route", lp4.isIpv6Provisioned()); LinkProperties lp6 = new LinkProperties(); assertFalse("v6only:empty", lp6.isProvisioned()); @@ -558,11 +558,11 @@ public class LinkPropertiesTest { lp6.addRoute(new RouteInfo(GATEWAY61)); assertFalse("v6only:fe80+dns+route", lp6.isProvisioned()); lp6.addLinkAddress(LINKADDRV6); - assertTrue("v6only:fe80+global+dns+route", lp6.isIPv6Provisioned()); + assertTrue("v6only:fe80+global+dns+route", lp6.isIpv6Provisioned()); assertTrue("v6only:fe80+global+dns+route", lp6.isProvisioned()); lp6.removeLinkAddress(LINKADDRV6LINKLOCAL); - assertFalse("v6only:global+dns+route", lp6.isIPv4Provisioned()); - assertTrue("v6only:global+dns+route", lp6.isIPv6Provisioned()); + assertFalse("v6only:global+dns+route", lp6.isIpv4Provisioned()); + assertTrue("v6only:global+dns+route", lp6.isIpv6Provisioned()); assertTrue("v6only:global+dns+route", lp6.isProvisioned()); LinkProperties lp46 = new LinkProperties(); @@ -572,12 +572,12 @@ public class LinkPropertiesTest { lp46.addDnsServer(DNS6); assertFalse("dualstack:missing-routes", lp46.isProvisioned()); lp46.addRoute(new RouteInfo(GATEWAY1)); - assertTrue("dualstack:v4-provisioned", lp46.isIPv4Provisioned()); - assertFalse("dualstack:v4-provisioned", lp46.isIPv6Provisioned()); + assertTrue("dualstack:v4-provisioned", lp46.isIpv4Provisioned()); + assertFalse("dualstack:v4-provisioned", lp46.isIpv6Provisioned()); assertTrue("dualstack:v4-provisioned", lp46.isProvisioned()); lp46.addRoute(new RouteInfo(GATEWAY61)); - assertTrue("dualstack:both-provisioned", lp46.isIPv4Provisioned()); - assertTrue("dualstack:both-provisioned", lp46.isIPv6Provisioned()); + assertTrue("dualstack:both-provisioned", lp46.isIpv4Provisioned()); + assertTrue("dualstack:both-provisioned", lp46.isIpv6Provisioned()); assertTrue("dualstack:both-provisioned", lp46.isProvisioned()); // A link with an IPv6 address and default route, but IPv4 DNS server. @@ -585,8 +585,8 @@ public class LinkPropertiesTest { mixed.addLinkAddress(LINKADDRV6); mixed.addDnsServer(DNS1); mixed.addRoute(new RouteInfo(GATEWAY61)); - assertFalse("mixed:addr6+route6+dns4", mixed.isIPv4Provisioned()); - assertFalse("mixed:addr6+route6+dns4", mixed.isIPv6Provisioned()); + assertFalse("mixed:addr6+route6+dns4", mixed.isIpv4Provisioned()); + assertFalse("mixed:addr6+route6+dns4", mixed.isIpv6Provisioned()); assertFalse("mixed:addr6+route6+dns4", mixed.isProvisioned()); } @@ -617,16 +617,16 @@ public class LinkPropertiesTest { v6lp.addLinkAddress(LINKADDRV6); v6lp.addRoute(new RouteInfo(GATEWAY61)); v6lp.addDnsServer(DNS6); - assertFalse(v6lp.isIPv4Provisioned()); - assertTrue(v6lp.isIPv6Provisioned()); + assertFalse(v6lp.isIpv4Provisioned()); + assertTrue(v6lp.isIpv6Provisioned()); assertTrue(v6lp.isProvisioned()); LinkProperties v46lp = new LinkProperties(v6lp); v46lp.addLinkAddress(LINKADDRV4); v46lp.addRoute(new RouteInfo(GATEWAY1)); v46lp.addDnsServer(DNS1); - assertTrue(v46lp.isIPv4Provisioned()); - assertTrue(v46lp.isIPv6Provisioned()); + assertTrue(v46lp.isIpv4Provisioned()); + assertTrue(v46lp.isIpv6Provisioned()); assertTrue(v46lp.isProvisioned()); assertEquals(ProvisioningChange.STILL_PROVISIONED, diff --git a/tests/net/java/android/net/TcpKeepalivePacketDataTest.java b/tests/net/java/android/net/TcpKeepalivePacketDataTest.java index 1f2dd275bb7b..e0b722761c34 100644 --- a/tests/net/java/android/net/TcpKeepalivePacketDataTest.java +++ b/tests/net/java/android/net/TcpKeepalivePacketDataTest.java @@ -21,12 +21,9 @@ import static org.junit.Assert.assertEquals; import static org.junit.Assert.fail; import android.net.SocketKeepalive.InvalidPacketException; -import android.net.TcpKeepalivePacketData.TcpSocketInfo; import com.android.internal.util.TestUtils; -import libcore.net.InetAddressUtils; - import org.junit.Before; import org.junit.Test; import org.junit.runner.RunWith; @@ -37,52 +34,69 @@ import java.nio.ByteBuffer; @RunWith(JUnit4.class) public final class TcpKeepalivePacketDataTest { + private static final byte[] IPV4_KEEPALIVE_SRC_ADDR = {10, 0, 0, 1}; + private static final byte[] IPV4_KEEPALIVE_DST_ADDR = {10, 0, 0, 5}; @Before public void setUp() {} @Test - public void testV4TcpKeepalivePacket() { - final InetAddress srcAddr = InetAddressUtils.parseNumericAddress("192.168.0.1"); - final InetAddress dstAddr = InetAddressUtils.parseNumericAddress("192.168.0.10"); + public void testV4TcpKeepalivePacket() throws Exception { final int srcPort = 1234; final int dstPort = 4321; final int seq = 0x11111111; final int ack = 0x22222222; final int wnd = 8000; final int wndScale = 2; + final int tos = 4; + final int ttl = 64; TcpKeepalivePacketData resultData = null; - TcpSocketInfo testInfo = new TcpSocketInfo( - srcAddr, srcPort, dstAddr, dstPort, seq, ack, wnd, wndScale); + final TcpKeepalivePacketDataParcelable testInfo = new TcpKeepalivePacketDataParcelable(); + testInfo.srcAddress = IPV4_KEEPALIVE_SRC_ADDR; + testInfo.srcPort = srcPort; + testInfo.dstAddress = IPV4_KEEPALIVE_DST_ADDR; + testInfo.dstPort = dstPort; + testInfo.seq = seq; + testInfo.ack = ack; + testInfo.rcvWnd = wnd; + testInfo.rcvWndScale = wndScale; + testInfo.tos = tos; + testInfo.ttl = ttl; try { resultData = TcpKeepalivePacketData.tcpKeepalivePacket(testInfo); } catch (InvalidPacketException e) { fail("InvalidPacketException: " + e); } - assertEquals(testInfo.srcAddress, resultData.srcAddress); - assertEquals(testInfo.dstAddress, resultData.dstAddress); + assertEquals(InetAddress.getByAddress(testInfo.srcAddress), resultData.srcAddress); + assertEquals(InetAddress.getByAddress(testInfo.dstAddress), resultData.dstAddress); assertEquals(testInfo.srcPort, resultData.srcPort); assertEquals(testInfo.dstPort, resultData.dstPort); assertEquals(testInfo.seq, resultData.tcpSeq); assertEquals(testInfo.ack, resultData.tcpAck); + assertEquals(testInfo.rcvWnd, resultData.tcpWnd); assertEquals(testInfo.rcvWndScale, resultData.tcpWndScale); + assertEquals(testInfo.tos, resultData.ipTos); + assertEquals(testInfo.ttl, resultData.ipTtl); TestUtils.assertParcelingIsLossless(resultData, TcpKeepalivePacketData.CREATOR); final byte[] packet = resultData.getPacket(); - // IP version and TOS. - ByteBuffer buf = ByteBuffer.wrap(packet); - assertEquals(buf.getShort(), 0x4500); + // IP version and IHL + assertEquals(packet[0], 0x45); + // TOS + assertEquals(packet[1], tos); + // TTL + assertEquals(packet[8], ttl); // Source IP address. byte[] ip = new byte[4]; - buf = ByteBuffer.wrap(packet, 12, 4); + ByteBuffer buf = ByteBuffer.wrap(packet, 12, 4); buf.get(ip); - assertArrayEquals(ip, srcAddr.getAddress()); + assertArrayEquals(ip, IPV4_KEEPALIVE_SRC_ADDR); // Destination IP address. buf = ByteBuffer.wrap(packet, 16, 4); buf.get(ip); - assertArrayEquals(ip, dstAddr.getAddress()); + assertArrayEquals(ip, IPV4_KEEPALIVE_DST_ADDR); buf = ByteBuffer.wrap(packet, 20, 12); // Source port. @@ -102,25 +116,38 @@ public final class TcpKeepalivePacketDataTest { @Test public void testParcel() throws Exception { - final InetAddress srcAddr = InetAddresses.parseNumericAddress("192.168.0.1"); - final InetAddress dstAddr = InetAddresses.parseNumericAddress("192.168.0.10"); final int srcPort = 1234; final int dstPort = 4321; final int sequence = 0x11111111; final int ack = 0x22222222; final int wnd = 48_000; final int wndScale = 2; + final int tos = 4; + final int ttl = 64; + final TcpKeepalivePacketDataParcelable testInfo = new TcpKeepalivePacketDataParcelable(); + testInfo.srcAddress = IPV4_KEEPALIVE_SRC_ADDR; + testInfo.srcPort = srcPort; + testInfo.dstAddress = IPV4_KEEPALIVE_DST_ADDR; + testInfo.dstPort = dstPort; + testInfo.seq = sequence; + testInfo.ack = ack; + testInfo.rcvWnd = wnd; + testInfo.rcvWndScale = wndScale; + testInfo.tos = tos; + testInfo.ttl = ttl; TcpKeepalivePacketData testData = null; TcpKeepalivePacketDataParcelable resultData = null; - TcpSocketInfo testInfo = new TcpSocketInfo( - srcAddr, srcPort, dstAddr, dstPort, sequence, ack, wnd, wndScale); testData = TcpKeepalivePacketData.tcpKeepalivePacket(testInfo); resultData = testData.toStableParcelable(); - assertArrayEquals(resultData.srcAddress, srcAddr.getAddress()); - assertArrayEquals(resultData.dstAddress, dstAddr.getAddress()); + assertArrayEquals(resultData.srcAddress, IPV4_KEEPALIVE_SRC_ADDR); + assertArrayEquals(resultData.dstAddress, IPV4_KEEPALIVE_DST_ADDR); assertEquals(resultData.srcPort, srcPort); assertEquals(resultData.dstPort, dstPort); assertEquals(resultData.seq, sequence); assertEquals(resultData.ack, ack); + assertEquals(resultData.rcvWnd, wnd); + assertEquals(resultData.rcvWndScale, wndScale); + assertEquals(resultData.tos, tos); + assertEquals(resultData.ttl, ttl); } } diff --git a/tests/net/java/android/net/apf/ApfCapabilitiesTest.java b/tests/net/java/android/net/apf/ApfCapabilitiesTest.java new file mode 100644 index 000000000000..75752c33da5c --- /dev/null +++ b/tests/net/java/android/net/apf/ApfCapabilitiesTest.java @@ -0,0 +1,50 @@ +/* + * 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. + */ + +package android.net.apf; + +import static org.junit.Assert.assertEquals; +import static org.junit.Assert.assertNotEquals; + +import android.net.shared.ParcelableTestUtil; + +import androidx.test.filters.SmallTest; +import androidx.test.runner.AndroidJUnit4; + +import com.android.internal.util.TestUtils; + +import org.junit.Test; +import org.junit.runner.RunWith; + +@RunWith(AndroidJUnit4.class) +@SmallTest +public class ApfCapabilitiesTest { + @Test + public void testParcelUnparcel() { + final ApfCapabilities caps = new ApfCapabilities(123, 456, 789); + ParcelableTestUtil.assertFieldCountEquals(3, ApfCapabilities.class); + + TestUtils.assertParcelingIsLossless(caps, ApfCapabilities.CREATOR); + } + + @Test + public void testEquals() { + assertEquals(new ApfCapabilities(1, 2, 3), new ApfCapabilities(1, 2, 3)); + assertNotEquals(new ApfCapabilities(2, 2, 3), new ApfCapabilities(1, 2, 3)); + assertNotEquals(new ApfCapabilities(1, 3, 3), new ApfCapabilities(1, 2, 3)); + assertNotEquals(new ApfCapabilities(1, 2, 4), new ApfCapabilities(1, 2, 3)); + } +} diff --git a/tests/net/java/android/net/shared/IpConfigurationParcelableUtilTest.java b/tests/net/java/android/net/shared/IpConfigurationParcelableUtilTest.java index 3e86e77183ec..21a4988950db 100644 --- a/tests/net/java/android/net/shared/IpConfigurationParcelableUtilTest.java +++ b/tests/net/java/android/net/shared/IpConfigurationParcelableUtilTest.java @@ -25,8 +25,6 @@ import static org.junit.Assert.assertEquals; import android.net.DhcpResults; import android.net.LinkAddress; -import android.net.StaticIpConfiguration; -import android.net.apf.ApfCapabilities; import androidx.test.filters.SmallTest; import androidx.test.runner.AndroidJUnit4; @@ -43,21 +41,16 @@ import java.net.Inet4Address; @RunWith(AndroidJUnit4.class) @SmallTest public class IpConfigurationParcelableUtilTest { - private StaticIpConfiguration mStaticIpConfiguration; private DhcpResults mDhcpResults; @Before public void setUp() { - mStaticIpConfiguration = new StaticIpConfiguration(); - mStaticIpConfiguration.ipAddress = new LinkAddress(parseNumericAddress("2001:db8::42"), 64); - mStaticIpConfiguration.gateway = parseNumericAddress("192.168.42.42"); - mStaticIpConfiguration.dnsServers.add(parseNumericAddress("2001:db8::43")); - mStaticIpConfiguration.dnsServers.add(parseNumericAddress("192.168.43.43")); - mStaticIpConfiguration.domains = "example.com"; - // Any added StaticIpConfiguration field must be included in equals() to be tested properly - assertFieldCountEquals(4, StaticIpConfiguration.class); - - mDhcpResults = new DhcpResults(mStaticIpConfiguration); + mDhcpResults = new DhcpResults(); + mDhcpResults.ipAddress = new LinkAddress(parseNumericAddress("2001:db8::42"), 64); + mDhcpResults.gateway = parseNumericAddress("192.168.42.42"); + mDhcpResults.dnsServers.add(parseNumericAddress("2001:db8::43")); + mDhcpResults.dnsServers.add(parseNumericAddress("192.168.43.43")); + mDhcpResults.domains = "example.com"; mDhcpResults.serverAddress = (Inet4Address) parseNumericAddress("192.168.44.44"); mDhcpResults.vendorInfo = "TEST_VENDOR_INFO"; mDhcpResults.leaseDuration = 3600; @@ -67,42 +60,31 @@ public class IpConfigurationParcelableUtilTest { } @Test - public void testParcelUnparcelStaticConfiguration() { - doStaticConfigurationParcelUnparcelTest(); - } - - @Test - public void testParcelUnparcelStaticConfiguration_NullIpAddress() { - mStaticIpConfiguration.ipAddress = null; - doStaticConfigurationParcelUnparcelTest(); + public void testParcelUnparcelDhcpResults() { + doDhcpResultsParcelUnparcelTest(); } @Test - public void testParcelUnparcelStaticConfiguration_NullGateway() { - mStaticIpConfiguration.gateway = null; - doStaticConfigurationParcelUnparcelTest(); + public void testParcelUnparcelDhcpResults_NullIpAddress() { + mDhcpResults.ipAddress = null; + doDhcpResultsParcelUnparcelTest(); } @Test - public void testParcelUnparcelStaticConfiguration_NullDomains() { - mStaticIpConfiguration.domains = null; - doStaticConfigurationParcelUnparcelTest(); + public void testParcelUnparcelDhcpResults_NullGateway() { + mDhcpResults.gateway = null; + doDhcpResultsParcelUnparcelTest(); } @Test - public void testParcelUnparcelStaticConfiguration_EmptyDomains() { - mStaticIpConfiguration.domains = ""; - doStaticConfigurationParcelUnparcelTest(); - } - - private void doStaticConfigurationParcelUnparcelTest() { - final StaticIpConfiguration unparceled = - fromStableParcelable(toStableParcelable(mStaticIpConfiguration)); - assertEquals(mStaticIpConfiguration, unparceled); + public void testParcelUnparcelDhcpResults_NullDomains() { + mDhcpResults.domains = null; + doDhcpResultsParcelUnparcelTest(); } @Test - public void testParcelUnparcelDhcpResults() { + public void testParcelUnparcelDhcpResults_EmptyDomains() { + mDhcpResults.domains = ""; doDhcpResultsParcelUnparcelTest(); } @@ -122,10 +104,4 @@ public class IpConfigurationParcelableUtilTest { final DhcpResults unparceled = fromStableParcelable(toStableParcelable(mDhcpResults)); assertEquals(mDhcpResults, unparceled); } - - @Test - public void testParcelUnparcelApfCapabilities() { - final ApfCapabilities caps = new ApfCapabilities(123, 456, 789); - assertEquals(caps, fromStableParcelable(toStableParcelable(caps))); - } } diff --git a/tests/net/java/com/android/server/ConnectivityServiceTest.java b/tests/net/java/com/android/server/ConnectivityServiceTest.java index 3efdfd94b1b7..a95db2242371 100644 --- a/tests/net/java/com/android/server/ConnectivityServiceTest.java +++ b/tests/net/java/com/android/server/ConnectivityServiceTest.java @@ -144,12 +144,14 @@ import android.os.INetworkManagementService; import android.os.Looper; import android.os.Message; import android.os.Parcel; +import android.os.ParcelFileDescriptor; import android.os.Parcelable; import android.os.Process; import android.os.RemoteException; import android.os.SystemClock; import android.os.UserHandle; import android.provider.Settings; +import android.system.Os; import android.test.mock.MockContentResolver; import android.text.TextUtils; import android.util.ArraySet; @@ -188,6 +190,8 @@ import org.mockito.MockitoAnnotations; import org.mockito.Spy; import org.mockito.stubbing.Answer; +import java.io.IOException; +import java.net.DatagramSocket; import java.net.Inet4Address; import java.net.InetAddress; import java.net.InetSocketAddress; @@ -208,7 +212,6 @@ import java.util.concurrent.Executors; import java.util.concurrent.LinkedBlockingQueue; import java.util.concurrent.TimeUnit; import java.util.concurrent.atomic.AtomicBoolean; -import java.util.function.Consumer; import java.util.function.Predicate; /** @@ -421,7 +424,7 @@ public class ConnectivityServiceTest { private final ConditionVariable mPreventReconnectReceived = new ConditionVariable(); private int mScore; private NetworkAgent mNetworkAgent; - private int mStartKeepaliveError = SocketKeepalive.ERROR_HARDWARE_UNSUPPORTED; + private int mStartKeepaliveError = SocketKeepalive.ERROR_UNSUPPORTED; private int mStopKeepaliveError = SocketKeepalive.NO_KEEPALIVE; private Integer mExpectedKeepaliveSlot = null; // Contains the redirectUrl from networkStatus(). Before reading, wait for @@ -495,7 +498,6 @@ public class ConnectivityServiceTest { try { doAnswer(validateAnswer).when(mNetworkMonitor).notifyNetworkConnected(); doAnswer(validateAnswer).when(mNetworkMonitor).forceReevaluation(anyInt()); - doAnswer(validateAnswer).when(mNetworkMonitor).notifyAcceptPartialConnectivity(); } catch (RemoteException e) { fail(e.getMessage()); } @@ -2550,8 +2552,7 @@ public class ConnectivityServiceTest { verifyActiveNetwork(TRANSPORT_CELLULAR); } - // TODO: deflake and re-enable - // @Test + @Test public void testPartialConnectivity() { // Register network callback. NetworkRequest request = new NetworkRequest.Builder() @@ -2575,20 +2576,24 @@ public class ConnectivityServiceTest { assertEquals(mCellNetworkAgent.getNetwork(), mCm.getActiveNetwork()); callback.assertNoCallback(); + // With HTTPS probe disabled, NetworkMonitor should pass the network validation with http + // probe. + mWiFiNetworkAgent.setNetworkValid(); // If the user chooses yes to use this partial connectivity wifi, switch the default // network to wifi and check if wifi becomes valid or not. mCm.setAcceptPartialConnectivity(mWiFiNetworkAgent.getNetwork(), true /* accept */, false /* always */); - // With https probe disabled, NetworkMonitor should pass the network validation with http - // probe. - mWiFiNetworkAgent.setNetworkValid(); + // If user accepts partial connectivity network, + // NetworkMonitor#setAcceptPartialConnectivity() should be called too. waitForIdle(); try { - verify(mWiFiNetworkAgent.mNetworkMonitor, - timeout(TIMEOUT_MS).times(1)).notifyAcceptPartialConnectivity(); + verify(mWiFiNetworkAgent.mNetworkMonitor, times(1)).setAcceptPartialConnectivity(); } catch (RemoteException e) { fail(e.getMessage()); } + // Need a trigger point to let NetworkMonitor tell ConnectivityService that network is + // validated. + mCm.reportNetworkConnectivity(mWiFiNetworkAgent.getNetwork(), true); callback.expectCallback(CallbackState.LOSING, mCellNetworkAgent); NetworkCapabilities nc = callback.expectCapabilitiesWith(NET_CAPABILITY_VALIDATED, mWiFiNetworkAgent); @@ -2618,6 +2623,15 @@ public class ConnectivityServiceTest { // acceptUnvalidated is also used as setting for accepting partial networks. mWiFiNetworkAgent.explicitlySelected(true /* acceptUnvalidated */); mWiFiNetworkAgent.connect(true); + // If user accepted partial connectivity network before, + // NetworkMonitor#setAcceptPartialConnectivity() will be called in + // ConnectivityService#updateNetworkInfo(). + waitForIdle(); + try { + verify(mWiFiNetworkAgent.mNetworkMonitor, times(1)).setAcceptPartialConnectivity(); + } catch (RemoteException e) { + fail(e.getMessage()); + } callback.expectAvailableCallbacksUnvalidated(mWiFiNetworkAgent); callback.expectCallback(CallbackState.LOSING, mCellNetworkAgent); nc = callback.expectCapabilitiesWith(NET_CAPABILITY_VALIDATED, mWiFiNetworkAgent); @@ -2632,23 +2646,33 @@ public class ConnectivityServiceTest { // NET_CAPABILITY_PARTIAL_CONNECTIVITY. mWiFiNetworkAgent = new MockNetworkAgent(TRANSPORT_WIFI); mWiFiNetworkAgent.explicitlySelected(true /* acceptUnvalidated */); + // Current design cannot send multi-testResult from NetworkMonitor to ConnectivityService. + // So, if user accepts partial connectivity, NetworkMonitor will send PARTIAL_CONNECTIVITY + // to ConnectivityService first then send VALID. Once NetworkMonitor support + // multi-testResult, this test case also need to be changed to meet the new design. mWiFiNetworkAgent.connectWithPartialConnectivity(); - callback.expectAvailableCallbacksUnvalidated(mWiFiNetworkAgent); - // TODO: If the user accepted partial connectivity, we shouldn't switch to wifi until - // NetworkMonitor detects partial connectivity - assertEquals(mWiFiNetworkAgent.getNetwork(), mCm.getActiveNetwork()); - mWiFiNetworkAgent.setNetworkValid(); + // If user accepted partial connectivity network before, + // NetworkMonitor#setAcceptPartialConnectivity() will be called in + // ConnectivityService#updateNetworkInfo(). waitForIdle(); try { - verify(mWiFiNetworkAgent.mNetworkMonitor, - timeout(TIMEOUT_MS).times(1)).notifyAcceptPartialConnectivity(); + verify(mWiFiNetworkAgent.mNetworkMonitor, times(1)).setAcceptPartialConnectivity(); } catch (RemoteException e) { fail(e.getMessage()); } + callback.expectAvailableCallbacksUnvalidated(mWiFiNetworkAgent); callback.expectCallback(CallbackState.LOSING, mCellNetworkAgent); - callback.expectCapabilitiesWith(NET_CAPABILITY_PARTIAL_CONNECTIVITY, mWiFiNetworkAgent); - // Wifi should be the default network. + // TODO: If the user accepted partial connectivity, we shouldn't switch to wifi until + // NetworkMonitor detects partial connectivity assertEquals(mWiFiNetworkAgent.getNetwork(), mCm.getActiveNetwork()); + callback.expectCapabilitiesWith(NET_CAPABILITY_PARTIAL_CONNECTIVITY, mWiFiNetworkAgent); + mWiFiNetworkAgent.setNetworkValid(); + // Need a trigger point to let NetworkMonitor tell ConnectivityService that network is + // validated. + mCm.reportNetworkConnectivity(mWiFiNetworkAgent.getNetwork(), true); + callback.expectCapabilitiesWith(NET_CAPABILITY_VALIDATED, mWiFiNetworkAgent); + mWiFiNetworkAgent.disconnect(); + callback.expectCallback(CallbackState.LOST, mWiFiNetworkAgent); } @Test @@ -4018,8 +4042,13 @@ public class ConnectivityServiceTest { callback3.expectStopped(); } + @FunctionalInterface + private interface ThrowingConsumer<T> { + void accept(T t) throws Exception; + } + // Helper method to prepare the executor and run test - private void runTestWithSerialExecutors(Consumer<Executor> functor) { + private void runTestWithSerialExecutors(ThrowingConsumer<Executor> functor) throws Exception { final ExecutorService executorSingleThread = Executors.newSingleThreadExecutor(); final Executor executorInline = (Runnable r) -> r.run(); functor.accept(executorSingleThread); @@ -4028,19 +4057,16 @@ public class ConnectivityServiceTest { } @Test - public void testNattSocketKeepalives() { - runTestWithSerialExecutors(executor -> { - try { - doTestNattSocketKeepalivesWithExecutor(executor); - } catch (Exception e) { - fail(e.getMessage()); - } - }); + public void testNattSocketKeepalives() throws Exception { + runTestWithSerialExecutors(executor -> doTestNattSocketKeepalivesWithExecutor(executor)); + runTestWithSerialExecutors(executor -> doTestNattSocketKeepalivesFdWithExecutor(executor)); } private void doTestNattSocketKeepalivesWithExecutor(Executor executor) throws Exception { // TODO: 1. Move this outside of ConnectivityServiceTest. // 2. Make test to verify that Nat-T keepalive socket is created by IpSecService. + // 3. Mock ipsec service. + // 4. Find a free port instead of a fixed port. final int srcPort = 12345; final InetAddress myIPv4 = InetAddress.getByName("192.0.2.129"); final InetAddress notMyIPv4 = InetAddress.getByName("192.0.2.35"); @@ -4065,89 +4091,106 @@ public class ConnectivityServiceTest { Network myNet = connectKeepaliveNetwork(lp); TestSocketKeepaliveCallback callback = new TestSocketKeepaliveCallback(executor); - SocketKeepalive ka; // Attempt to start keepalives with invalid parameters and check for errors. // Invalid network. - ka = mCm.createSocketKeepalive(notMyNet, testSocket, myIPv4, dstIPv4, executor, callback); - ka.start(validKaInterval); - callback.expectError(SocketKeepalive.ERROR_INVALID_NETWORK); + try (SocketKeepalive ka = mCm.createSocketKeepalive( + notMyNet, testSocket, myIPv4, dstIPv4, executor, callback)) { + ka.start(validKaInterval); + callback.expectError(SocketKeepalive.ERROR_INVALID_NETWORK); + } // Invalid interval. - ka = mCm.createSocketKeepalive(myNet, testSocket, myIPv4, dstIPv4, executor, callback); - ka.start(invalidKaInterval); - callback.expectError(SocketKeepalive.ERROR_INVALID_INTERVAL); + try (SocketKeepalive ka = mCm.createSocketKeepalive( + myNet, testSocket, myIPv4, dstIPv4, executor, callback)) { + ka.start(invalidKaInterval); + callback.expectError(SocketKeepalive.ERROR_INVALID_INTERVAL); + } // Invalid destination. - ka = mCm.createSocketKeepalive(myNet, testSocket, myIPv4, dstIPv6, executor, callback); - ka.start(validKaInterval); - callback.expectError(SocketKeepalive.ERROR_INVALID_IP_ADDRESS); + try (SocketKeepalive ka = mCm.createSocketKeepalive( + myNet, testSocket, myIPv4, dstIPv6, executor, callback)) { + ka.start(validKaInterval); + callback.expectError(SocketKeepalive.ERROR_INVALID_IP_ADDRESS); + } // Invalid source; - ka = mCm.createSocketKeepalive(myNet, testSocket, myIPv6, dstIPv4, executor, callback); - ka.start(validKaInterval); - callback.expectError(SocketKeepalive.ERROR_INVALID_IP_ADDRESS); + try (SocketKeepalive ka = mCm.createSocketKeepalive( + myNet, testSocket, myIPv6, dstIPv4, executor, callback)) { + ka.start(validKaInterval); + callback.expectError(SocketKeepalive.ERROR_INVALID_IP_ADDRESS); + } // NAT-T is only supported for IPv4. - ka = mCm.createSocketKeepalive(myNet, testSocket, myIPv6, dstIPv6, executor, callback); - ka.start(validKaInterval); - callback.expectError(SocketKeepalive.ERROR_INVALID_IP_ADDRESS); + try (SocketKeepalive ka = mCm.createSocketKeepalive( + myNet, testSocket, myIPv6, dstIPv6, executor, callback)) { + ka.start(validKaInterval); + callback.expectError(SocketKeepalive.ERROR_INVALID_IP_ADDRESS); + } // Sanity check before testing started keepalive. - ka = mCm.createSocketKeepalive(myNet, testSocket, myIPv4, dstIPv4, executor, callback); - ka.start(validKaInterval); - callback.expectError(SocketKeepalive.ERROR_HARDWARE_UNSUPPORTED); + try (SocketKeepalive ka = mCm.createSocketKeepalive( + myNet, testSocket, myIPv4, dstIPv4, executor, callback)) { + ka.start(validKaInterval); + callback.expectError(SocketKeepalive.ERROR_UNSUPPORTED); + } // Check that a started keepalive can be stopped. mWiFiNetworkAgent.setStartKeepaliveError(SocketKeepalive.SUCCESS); - ka = mCm.createSocketKeepalive(myNet, testSocket, myIPv4, dstIPv4, executor, callback); - ka.start(validKaInterval); - callback.expectStarted(); - mWiFiNetworkAgent.setStopKeepaliveError(SocketKeepalive.SUCCESS); - ka.stop(); - callback.expectStopped(); - - // Check that keepalive could be restarted. - ka.start(validKaInterval); - callback.expectStarted(); - ka.stop(); - callback.expectStopped(); - - // Check that keepalive can be restarted without waiting for callback. - ka.start(validKaInterval); - callback.expectStarted(); - ka.stop(); - ka.start(validKaInterval); - callback.expectStopped(); - callback.expectStarted(); - ka.stop(); - callback.expectStopped(); + try (SocketKeepalive ka = mCm.createSocketKeepalive( + myNet, testSocket, myIPv4, dstIPv4, executor, callback)) { + ka.start(validKaInterval); + callback.expectStarted(); + mWiFiNetworkAgent.setStopKeepaliveError(SocketKeepalive.SUCCESS); + ka.stop(); + callback.expectStopped(); + + // Check that keepalive could be restarted. + ka.start(validKaInterval); + callback.expectStarted(); + ka.stop(); + callback.expectStopped(); + + // Check that keepalive can be restarted without waiting for callback. + ka.start(validKaInterval); + callback.expectStarted(); + ka.stop(); + ka.start(validKaInterval); + callback.expectStopped(); + callback.expectStarted(); + ka.stop(); + callback.expectStopped(); + } // Check that deleting the IP address stops the keepalive. LinkProperties bogusLp = new LinkProperties(lp); - ka = mCm.createSocketKeepalive(myNet, testSocket, myIPv4, dstIPv4, executor, callback); - ka.start(validKaInterval); - callback.expectStarted(); - bogusLp.removeLinkAddress(new LinkAddress(myIPv4, 25)); - bogusLp.addLinkAddress(new LinkAddress(notMyIPv4, 25)); - mWiFiNetworkAgent.sendLinkProperties(bogusLp); - callback.expectError(SocketKeepalive.ERROR_INVALID_IP_ADDRESS); - mWiFiNetworkAgent.sendLinkProperties(lp); + try (SocketKeepalive ka = mCm.createSocketKeepalive( + myNet, testSocket, myIPv4, dstIPv4, executor, callback)) { + ka.start(validKaInterval); + callback.expectStarted(); + bogusLp.removeLinkAddress(new LinkAddress(myIPv4, 25)); + bogusLp.addLinkAddress(new LinkAddress(notMyIPv4, 25)); + mWiFiNetworkAgent.sendLinkProperties(bogusLp); + callback.expectError(SocketKeepalive.ERROR_INVALID_IP_ADDRESS); + mWiFiNetworkAgent.sendLinkProperties(lp); + } // Check that a started keepalive is stopped correctly when the network disconnects. - ka = mCm.createSocketKeepalive(myNet, testSocket, myIPv4, dstIPv4, executor, callback); - ka.start(validKaInterval); - callback.expectStarted(); - mWiFiNetworkAgent.disconnect(); - waitFor(mWiFiNetworkAgent.getDisconnectedCV()); - callback.expectError(SocketKeepalive.ERROR_INVALID_NETWORK); + try (SocketKeepalive ka = mCm.createSocketKeepalive( + myNet, testSocket, myIPv4, dstIPv4, executor, callback)) { + ka.start(validKaInterval); + callback.expectStarted(); + mWiFiNetworkAgent.disconnect(); + waitFor(mWiFiNetworkAgent.getDisconnectedCV()); + callback.expectError(SocketKeepalive.ERROR_INVALID_NETWORK); - // ... and that stopping it after that has no adverse effects. - waitForIdle(); - final Network myNetAlias = myNet; - assertNull(mCm.getNetworkCapabilities(myNetAlias)); - ka.stop(); - callback.assertNoCallback(); + // ... and that stopping it after that has no adverse effects. + waitForIdle(); + final Network myNetAlias = myNet; + assertNull(mCm.getNetworkCapabilities(myNetAlias)); + ka.stop(); + callback.assertNoCallback(); + } // Reconnect. myNet = connectKeepaliveNetwork(lp); @@ -4155,27 +4198,30 @@ public class ConnectivityServiceTest { // Check that keepalive slots start from 1 and increment. The first one gets slot 1. mWiFiNetworkAgent.setExpectedKeepaliveSlot(1); - ka = mCm.createSocketKeepalive(myNet, testSocket, myIPv4, dstIPv4, executor, callback); - ka.start(validKaInterval); - callback.expectStarted(); - - // The second one gets slot 2. - mWiFiNetworkAgent.setExpectedKeepaliveSlot(2); - final UdpEncapsulationSocket testSocket2 = mIpSec.openUdpEncapsulationSocket(6789); - TestSocketKeepaliveCallback callback2 = new TestSocketKeepaliveCallback(executor); - SocketKeepalive ka2 = - mCm.createSocketKeepalive(myNet, testSocket2, myIPv4, dstIPv4, executor, callback2); - ka2.start(validKaInterval); - callback2.expectStarted(); - - ka.stop(); - callback.expectStopped(); - - ka2.stop(); - callback2.expectStopped(); - - testSocket.close(); - testSocket2.close(); + try (SocketKeepalive ka = mCm.createSocketKeepalive( + myNet, testSocket, myIPv4, dstIPv4, executor, callback)) { + ka.start(validKaInterval); + callback.expectStarted(); + + // The second one gets slot 2. + mWiFiNetworkAgent.setExpectedKeepaliveSlot(2); + final UdpEncapsulationSocket testSocket2 = mIpSec.openUdpEncapsulationSocket(6789); + TestSocketKeepaliveCallback callback2 = new TestSocketKeepaliveCallback(executor); + try (SocketKeepalive ka2 = mCm.createSocketKeepalive( + myNet, testSocket2, myIPv4, dstIPv4, executor, callback2)) { + ka2.start(validKaInterval); + callback2.expectStarted(); + + ka.stop(); + callback.expectStopped(); + + ka2.stop(); + callback2.expectStopped(); + + testSocket.close(); + testSocket2.close(); + } + } mWiFiNetworkAgent.disconnect(); waitFor(mWiFiNetworkAgent.getDisconnectedCV()); @@ -4183,14 +4229,8 @@ public class ConnectivityServiceTest { } @Test - public void testTcpSocketKeepalives() { - runTestWithSerialExecutors(executor -> { - try { - doTestTcpSocketKeepalivesWithExecutor(executor); - } catch (Exception e) { - fail(e.getMessage()); - } - }); + public void testTcpSocketKeepalives() throws Exception { + runTestWithSerialExecutors(executor -> doTestTcpSocketKeepalivesWithExecutor(executor)); } private void doTestTcpSocketKeepalivesWithExecutor(Executor executor) throws Exception { @@ -4200,7 +4240,6 @@ public class ConnectivityServiceTest { final InetAddress myIPv6 = InetAddress.getByName("::1"); final int validKaInterval = 15; - final int invalidKaInterval = 9; final LinkProperties lp = new LinkProperties(); lp.setInterfaceName("wlan12"); @@ -4216,37 +4255,46 @@ public class ConnectivityServiceTest { final Socket testSocketV6 = new Socket(); TestSocketKeepaliveCallback callback = new TestSocketKeepaliveCallback(executor); - SocketKeepalive ka; // Attempt to start Tcp keepalives with invalid parameters and check for errors. // Invalid network. - ka = mCm.createSocketKeepalive(notMyNet, testSocketV4, executor, callback); - ka.start(validKaInterval); - callback.expectError(SocketKeepalive.ERROR_INVALID_NETWORK); + try (SocketKeepalive ka = mCm.createSocketKeepalive( + notMyNet, testSocketV4, executor, callback)) { + ka.start(validKaInterval); + callback.expectError(SocketKeepalive.ERROR_INVALID_NETWORK); + } // Invalid Socket (socket is not bound with IPv4 address). - ka = mCm.createSocketKeepalive(myNet, testSocketV4, executor, callback); - ka.start(validKaInterval); - callback.expectError(SocketKeepalive.ERROR_INVALID_SOCKET); + try (SocketKeepalive ka = mCm.createSocketKeepalive( + myNet, testSocketV4, executor, callback)) { + ka.start(validKaInterval); + callback.expectError(SocketKeepalive.ERROR_INVALID_SOCKET); + } // Invalid Socket (socket is not bound with IPv6 address). - ka = mCm.createSocketKeepalive(myNet, testSocketV6, executor, callback); - ka.start(validKaInterval); - callback.expectError(SocketKeepalive.ERROR_INVALID_SOCKET); + try (SocketKeepalive ka = mCm.createSocketKeepalive( + myNet, testSocketV6, executor, callback)) { + ka.start(validKaInterval); + callback.expectError(SocketKeepalive.ERROR_INVALID_SOCKET); + } // Bind the socket address testSocketV4.bind(new InetSocketAddress(myIPv4, srcPortV4)); testSocketV6.bind(new InetSocketAddress(myIPv6, srcPortV6)); // Invalid Socket (socket is bound with IPv4 address). - ka = mCm.createSocketKeepalive(myNet, testSocketV4, executor, callback); - ka.start(validKaInterval); - callback.expectError(SocketKeepalive.ERROR_INVALID_SOCKET); + try (SocketKeepalive ka = mCm.createSocketKeepalive( + myNet, testSocketV4, executor, callback)) { + ka.start(validKaInterval); + callback.expectError(SocketKeepalive.ERROR_INVALID_SOCKET); + } // Invalid Socket (socket is bound with IPv6 address). - ka = mCm.createSocketKeepalive(myNet, testSocketV6, executor, callback); - ka.start(validKaInterval); - callback.expectError(SocketKeepalive.ERROR_INVALID_SOCKET); + try (SocketKeepalive ka = mCm.createSocketKeepalive( + myNet, testSocketV6, executor, callback)) { + ka.start(validKaInterval); + callback.expectError(SocketKeepalive.ERROR_INVALID_SOCKET); + } testSocketV4.close(); testSocketV6.close(); @@ -4256,6 +4304,66 @@ public class ConnectivityServiceTest { mWiFiNetworkAgent = null; } + private void doTestNattSocketKeepalivesFdWithExecutor(Executor executor) throws Exception { + final int srcPort = 12345; + final InetAddress myIPv4 = InetAddress.getByName("192.0.2.129"); + final InetAddress anyIPv4 = InetAddress.getByName("0.0.0.0"); + final InetAddress dstIPv4 = InetAddress.getByName("8.8.8.8"); + final int validKaInterval = 15; + + // Prepare the target network. + LinkProperties lp = new LinkProperties(); + lp.setInterfaceName("wlan12"); + lp.addLinkAddress(new LinkAddress(myIPv4, 25)); + lp.addRoute(new RouteInfo(InetAddress.getByName("192.0.2.254"))); + Network myNet = connectKeepaliveNetwork(lp); + mWiFiNetworkAgent.setStartKeepaliveError(SocketKeepalive.SUCCESS); + mWiFiNetworkAgent.setStopKeepaliveError(SocketKeepalive.SUCCESS); + + TestSocketKeepaliveCallback callback = new TestSocketKeepaliveCallback(executor); + + // Prepare the target file descriptor, keep only one instance. + final IpSecManager mIpSec = (IpSecManager) mContext.getSystemService(Context.IPSEC_SERVICE); + final UdpEncapsulationSocket testSocket = mIpSec.openUdpEncapsulationSocket(srcPort); + final ParcelFileDescriptor testPfd = + ParcelFileDescriptor.dup(testSocket.getFileDescriptor()); + testSocket.close(); + assertTrue(isUdpPortInUse(srcPort)); + + // Start keepalive and explicit make the variable goes out of scope with try-with-resources + // block. + try (SocketKeepalive ka = mCm.createNattKeepalive( + myNet, testPfd, myIPv4, dstIPv4, executor, callback)) { + ka.start(validKaInterval); + callback.expectStarted(); + ka.stop(); + callback.expectStopped(); + } + + // Check that the ParcelFileDescriptor is still valid after keepalive stopped, + // ErrnoException with EBADF will be thrown if the socket is closed when checking local + // address. + assertTrue(isUdpPortInUse(srcPort)); + final InetSocketAddress sa = + (InetSocketAddress) Os.getsockname(testPfd.getFileDescriptor()); + assertEquals(anyIPv4, sa.getAddress()); + + testPfd.close(); + assertFalse(isUdpPortInUse(srcPort)); + + mWiFiNetworkAgent.disconnect(); + waitFor(mWiFiNetworkAgent.getDisconnectedCV()); + mWiFiNetworkAgent = null; + } + + private static boolean isUdpPortInUse(int port) { + try (DatagramSocket ignored = new DatagramSocket(port)) { + return false; + } catch (IOException ignored) { + return true; + } + } + @Test public void testGetCaptivePortalServerUrl() throws Exception { String url = mCm.getCaptivePortalServerUrl(); diff --git a/tests/net/java/com/android/server/NetworkManagementServiceTest.java b/tests/net/java/com/android/server/NetworkManagementServiceTest.java index 6fb322554d48..968b3071bf1d 100644 --- a/tests/net/java/com/android/server/NetworkManagementServiceTest.java +++ b/tests/net/java/com/android/server/NetworkManagementServiceTest.java @@ -16,6 +16,7 @@ package com.android.server; +import static org.mockito.Mockito.doNothing; import static org.mockito.Mockito.doReturn; import static org.mockito.Mockito.mock; import static org.mockito.Mockito.reset; @@ -23,11 +24,11 @@ import static org.mockito.Mockito.timeout; import static org.mockito.Mockito.verify; import static org.mockito.Mockito.verifyNoMoreInteractions; +import android.annotation.NonNull; import android.content.Context; import android.net.INetd; +import android.net.INetdUnsolicitedEventListener; import android.net.LinkAddress; -import android.net.LocalServerSocket; -import android.net.LocalSocket; import android.os.BatteryStats; import android.os.Binder; import android.os.IBinder; @@ -43,12 +44,11 @@ import org.junit.After; import org.junit.Before; import org.junit.Test; import org.junit.runner.RunWith; +import org.mockito.ArgumentCaptor; +import org.mockito.Captor; import org.mockito.Mock; import org.mockito.MockitoAnnotations; -import java.io.IOException; -import java.io.OutputStream; - /** * Tests for {@link NetworkManagementService}. */ @@ -56,16 +56,16 @@ import java.io.OutputStream; @SmallTest public class NetworkManagementServiceTest { - private static final String SOCKET_NAME = "__test__NetworkManagementServiceTest"; private NetworkManagementService mNMService; - private LocalServerSocket mServerSocket; - private LocalSocket mSocket; - private OutputStream mOutputStream; @Mock private Context mContext; @Mock private IBatteryStats.Stub mBatteryStatsService; @Mock private INetd.Stub mNetdService; + @NonNull + @Captor + private ArgumentCaptor<INetdUnsolicitedEventListener> mUnsolListenerCaptor; + private final SystemServices mServices = new SystemServices() { @Override public IBinder getService(String name) { @@ -88,32 +88,15 @@ public class NetworkManagementServiceTest { @Before public void setUp() throws Exception { MockitoAnnotations.initMocks(this); - - // Set up a sheltered test environment. - mServerSocket = new LocalServerSocket(SOCKET_NAME); - + doNothing().when(mNetdService) + .registerUnsolicitedEventListener(mUnsolListenerCaptor.capture()); // Start the service and wait until it connects to our socket. - mNMService = NetworkManagementService.create(mContext, SOCKET_NAME, mServices); - mSocket = mServerSocket.accept(); - mOutputStream = mSocket.getOutputStream(); + mNMService = NetworkManagementService.create(mContext, mServices); } @After public void tearDown() throws Exception { mNMService.shutdown(); - // Once NetworkManagementService#shutdown() actually does something and shutdowns - // the underlying NativeDaemonConnector, the block below should be uncommented. - // if (mOutputStream != null) mOutputStream.close(); - // if (mSocket != null) mSocket.close(); - // if (mServerSocket != null) mServerSocket.close(); - } - - /** - * Sends a message on the netd socket and gives the events some time to make it back. - */ - private void sendMessage(String message) throws IOException { - // Strings are null-terminated, so add "\0" at the end. - mOutputStream.write((message + "\0").getBytes()); } private static <T> T expectSoon(T mock) { @@ -131,125 +114,78 @@ public class NetworkManagementServiceTest { // Forget everything that happened to the mock so far, so we can explicitly verify // everything that happens and does not happen to it from now on. - reset(observer); - // Now send NetworkManagementService messages and ensure that the observer methods are - // called. After every valid message we expect a callback soon after; to ensure that + INetdUnsolicitedEventListener unsolListener = mUnsolListenerCaptor.getValue(); + reset(observer); + // Now call unsolListener methods and ensure that the observer methods are + // called. After every method we expect a callback soon after; to ensure that // invalid messages don't cause any callbacks, we call verifyNoMoreInteractions at the end. /** * Interface changes. */ - sendMessage("600 Iface added rmnet12"); + unsolListener.onInterfaceAdded("rmnet12"); expectSoon(observer).interfaceAdded("rmnet12"); - sendMessage("600 Iface removed eth1"); + unsolListener.onInterfaceRemoved("eth1"); expectSoon(observer).interfaceRemoved("eth1"); - sendMessage("607 Iface removed eth1"); - // Invalid code. - - sendMessage("600 Iface borked lo down"); - // Invalid event. - - sendMessage("600 Iface changed clat4 up again"); - // Extra tokens. - - sendMessage("600 Iface changed clat4 up"); + unsolListener.onInterfaceChanged("clat4", true); expectSoon(observer).interfaceStatusChanged("clat4", true); - sendMessage("600 Iface linkstate rmnet0 down"); + unsolListener.onInterfaceLinkStateChanged("rmnet0", false); expectSoon(observer).interfaceLinkStateChanged("rmnet0", false); - sendMessage("600 IFACE linkstate clat4 up"); - // Invalid group. - /** * Bandwidth control events. */ - sendMessage("601 limit alert data rmnet_usb0"); + unsolListener.onQuotaLimitReached("data", "rmnet_usb0"); expectSoon(observer).limitReached("data", "rmnet_usb0"); - sendMessage("601 invalid alert data rmnet0"); - // Invalid group. - - sendMessage("601 limit increased data rmnet0"); - // Invalid event. - - /** * Interface class activity. */ - - sendMessage("613 IfaceClass active 1 1234 10012"); + unsolListener.onInterfaceClassActivityChanged(true, 1, 1234, 0); expectSoon(observer).interfaceClassDataActivityChanged("1", true, 1234); - sendMessage("613 IfaceClass idle 9 5678"); + unsolListener.onInterfaceClassActivityChanged(false, 9, 5678, 0); expectSoon(observer).interfaceClassDataActivityChanged("9", false, 5678); - sendMessage("613 IfaceClass reallyactive 9 4321"); + unsolListener.onInterfaceClassActivityChanged(false, 9, 4321, 0); expectSoon(observer).interfaceClassDataActivityChanged("9", false, 4321); - sendMessage("613 InterfaceClass reallyactive 1"); - // Invalid group. - - /** * IP address changes. */ - sendMessage("614 Address updated fe80::1/64 wlan0 128 253"); + unsolListener.onInterfaceAddressUpdated("fe80::1/64", "wlan0", 128, 253); expectSoon(observer).addressUpdated("wlan0", new LinkAddress("fe80::1/64", 128, 253)); - // There is no "added", so we take this as "removed". - sendMessage("614 Address added fe80::1/64 wlan0 128 253"); + unsolListener.onInterfaceAddressRemoved("fe80::1/64", "wlan0", 128, 253); expectSoon(observer).addressRemoved("wlan0", new LinkAddress("fe80::1/64", 128, 253)); - sendMessage("614 Address removed 2001:db8::1/64 wlan0 1 0"); + unsolListener.onInterfaceAddressRemoved("2001:db8::1/64", "wlan0", 1, 0); expectSoon(observer).addressRemoved("wlan0", new LinkAddress("2001:db8::1/64", 1, 0)); - sendMessage("614 Address removed 2001:db8::1/64 wlan0 1"); - // Not enough arguments. - - sendMessage("666 Address removed 2001:db8::1/64 wlan0 1 0"); - // Invalid code. - - /** * DNS information broadcasts. */ - sendMessage("615 DnsInfo servers rmnet_usb0 3600 2001:db8::1"); + unsolListener.onInterfaceDnsServerInfo("rmnet_usb0", 3600, new String[]{"2001:db8::1"}); expectSoon(observer).interfaceDnsServerInfo("rmnet_usb0", 3600, new String[]{"2001:db8::1"}); - sendMessage("615 DnsInfo servers wlan0 14400 2001:db8::1,2001:db8::2"); + unsolListener.onInterfaceDnsServerInfo("wlan0", 14400, + new String[]{"2001:db8::1", "2001:db8::2"}); expectSoon(observer).interfaceDnsServerInfo("wlan0", 14400, new String[]{"2001:db8::1", "2001:db8::2"}); // We don't check for negative lifetimes, only for parse errors. - sendMessage("615 DnsInfo servers wlan0 -3600 ::1"); + unsolListener.onInterfaceDnsServerInfo("wlan0", -3600, new String[]{"::1"}); expectSoon(observer).interfaceDnsServerInfo("wlan0", -3600, new String[]{"::1"}); - sendMessage("615 DnsInfo servers wlan0 SIXHUNDRED ::1"); - // Non-numeric lifetime. - - sendMessage("615 DnsInfo servers wlan0 2001:db8::1"); - // Missing lifetime. - - sendMessage("615 DnsInfo servers wlan0 3600"); - // No servers. - - sendMessage("615 DnsInfo servers 3600 wlan0 2001:db8::1,2001:db8::2"); - // Non-numeric lifetime. - - sendMessage("615 DnsInfo wlan0 7200 2001:db8::1,2001:db8::2"); - // Invalid tokens. - - sendMessage("666 DnsInfo servers wlan0 5400 2001:db8::1"); - // Invalid code. - // No syntax checking on the addresses. - sendMessage("615 DnsInfo servers wlan0 600 ,::,,foo,::1,"); + unsolListener.onInterfaceDnsServerInfo("wlan0", 600, + new String[]{"", "::", "", "foo", "::1"}); expectSoon(observer).interfaceDnsServerInfo("wlan0", 600, new String[]{"", "::", "", "foo", "::1"}); diff --git a/tests/net/java/com/android/server/connectivity/TetheringTest.java b/tests/net/java/com/android/server/connectivity/TetheringTest.java index fdba72333f0b..6c42ac398b47 100644 --- a/tests/net/java/com/android/server/connectivity/TetheringTest.java +++ b/tests/net/java/com/android/server/connectivity/TetheringTest.java @@ -550,7 +550,7 @@ public class TetheringTest { mTetheringDependencies.ipv6CoordinatorNotifyList) { NetworkState ipv6OnlyState = buildMobileUpstreamState(false, true, false); ipSrv.sendMessage(IpServer.CMD_IPV6_TETHER_UPDATE, 0, 0, - upstreamState.linkProperties.isIPv6Provisioned() + upstreamState.linkProperties.isIpv6Provisioned() ? ipv6OnlyState.linkProperties : null); } diff --git a/tests/net/java/com/android/server/connectivity/tethering/EntitlementManagerTest.java b/tests/net/java/com/android/server/connectivity/tethering/EntitlementManagerTest.java index 3944fad2ac9e..bac509802258 100644 --- a/tests/net/java/com/android/server/connectivity/tethering/EntitlementManagerTest.java +++ b/tests/net/java/com/android/server/connectivity/tethering/EntitlementManagerTest.java @@ -166,6 +166,7 @@ public final class EntitlementManagerTest { .thenReturn(mCarrierConfigManager); when(mCarrierConfigManager.getConfig()).thenReturn(mCarrierConfig); mCarrierConfig.putBoolean(CarrierConfigManager.KEY_REQUIRE_ENTITLEMENT_CHECKS_BOOL, true); + mCarrierConfig.putBoolean(CarrierConfigManager.KEY_CARRIER_CONFIG_APPLIED_BOOL, true); } @Test @@ -199,6 +200,16 @@ public final class EntitlementManagerTest { } @Test + public void toleratesCarrierConfigNotLoaded() { + setupForRequiredProvisioning(); + mCarrierConfig.putBoolean(CarrierConfigManager.KEY_CARRIER_CONFIG_APPLIED_BOOL, false); + mEnMgr.updateConfiguration( + new TetheringConfiguration(mMockContext, mLog, INVALID_SUBSCRIPTION_ID)); + // We still have a provisioning app configured, so still require provisioning. + assertTrue(mEnMgr.isTetherProvisioningRequired()); + } + + @Test public void provisioningNotRequiredWhenAppNotFound() { setupForRequiredProvisioning(); when(mResources.getStringArray(R.array.config_mobile_hotspot_provision_app)) diff --git a/tests/utils/testutils/Android.bp b/tests/utils/testutils/Android.bp index 0a9e964d8d8d..f71be7b0b7d3 100644 --- a/tests/utils/testutils/Android.bp +++ b/tests/utils/testutils/Android.bp @@ -19,7 +19,10 @@ java_library { srcs: ["java/**/*.java"], - static_libs: ["junit"], + static_libs: [ + "junit", + "hamcrest-library", + ], libs: [ "android.test.runner", diff --git a/tests/utils/testutils/java/com/android/server/wm/test/filters/FrameworksTestsFilter.java b/tests/utils/testutils/java/com/android/server/wm/test/filters/FrameworksTestsFilter.java new file mode 100644 index 000000000000..2ce1fc68e1ce --- /dev/null +++ b/tests/utils/testutils/java/com/android/server/wm/test/filters/FrameworksTestsFilter.java @@ -0,0 +1,66 @@ +/* + * 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. + */ + +package com.android.server.wm.test.filters; + +import android.os.Bundle; + +import com.android.test.filters.SelectTest; + +/** + * JUnit test filter that select Window Manager Service related tests from FrameworksCoreTests. + * + * <p>Use this filter when running FrameworksCoreTests as + * <pre> + * adb shell am instrument -w \ + * -e filter com.android.server.wm.test.filters.FrameworksTestsFilter \ + * -e selectTest_verbose true \ + * com.android.frameworks.coretests/androidx.test.runner.AndroidJUnitRunner + * </pre> + */ +public final class FrameworksTestsFilter extends SelectTest { + + private static final String[] SELECTED_TESTS = { + // Test specifications for FrameworksCoreTests. + "android.app.servertransaction.", // all tests under the package. + "android.view.DisplayCutoutTest", + // Test specifications for FrameworksServicesTests. + "com.android.server.policy.", // all tests under the package. + "com.android.server.am.ActivityLaunchParamsModifierTests", + "com.android.server.am.ActivityRecordTests", + "com.android.server.am.ActivityStackSupervisorTests", + "com.android.server.am.ActivityStackTests", + "com.android.server.am.ActivityStartControllerTests", + "com.android.server.am.ActivityStarterTests", + "com.android.server.am.ActivityStartInterceptorTest", + "com.android.server.am.AssistDataRequesterTest", + "com.android.server.am.ClientLifecycleManagerTests", + "com.android.server.am.LaunchParamsControllerTests", + "com.android.server.am.PendingRemoteAnimationRegistryTest", + "com.android.server.am.RecentsAnimationTest", + "com.android.server.am.RecentTasksTest", + "com.android.server.am.RunningTasksTest", + "com.android.server.am.SafeActivityOptionsTest", + "com.android.server.am.TaskLaunchParamsModifierTests", + "com.android.server.am.TaskPersisterTest", + "com.android.server.am.TaskRecordTests", + "com.android.server.am.TaskStackChangedListenerTest", + }; + + public FrameworksTestsFilter(Bundle testArgs) { + super(addSelectTest(testArgs, SELECTED_TESTS)); + } +} diff --git a/tests/utils/testutils/java/com/android/test/filters/SelectTest.java b/tests/utils/testutils/java/com/android/test/filters/SelectTest.java index d0350aff5ef5..d5b14c58512e 100644 --- a/tests/utils/testutils/java/com/android/test/filters/SelectTest.java +++ b/tests/utils/testutils/java/com/android/test/filters/SelectTest.java @@ -26,10 +26,12 @@ import com.android.internal.annotations.VisibleForTesting; import org.junit.runner.Description; import org.junit.runner.manipulation.Filter; +import java.util.ArrayList; import java.util.Arrays; import java.util.Collection; import java.util.LinkedHashMap; import java.util.LinkedHashSet; +import java.util.List; import java.util.Map; import java.util.Set; import java.util.StringJoiner; @@ -131,7 +133,8 @@ public class SelectTest extends Filter { * * @param testArgs instrumentation test arguments. * @param selectTests array of class name to be selected to run. - * @return modified instrumentation test arguments. + * @return modified instrumentation test arguments. if {@link #OPTION_SELECT_TEST} argument + * already exists in {@code testArgs}, those are prepended before {@code selectTests}. */ @NonNull protected static Bundle addSelectTest( @@ -139,7 +142,13 @@ public class SelectTest extends Filter { if (selectTests.length == 0) { return testArgs; } - testArgs.putString(OPTION_SELECT_TEST, join(Arrays.asList(selectTests))); + final List<String> selectedTestList = new ArrayList<>(); + final String selectTestArgs = testArgs.getString(OPTION_SELECT_TEST); + if (selectTestArgs != null) { + selectedTestList.addAll(Arrays.asList(selectTestArgs.split(ARGUMENT_ITEM_SEPARATOR))); + } + selectedTestList.addAll(Arrays.asList(selectTests)); + testArgs.putString(OPTION_SELECT_TEST, join(selectedTestList)); return testArgs; } diff --git a/tests/utils/testutils/java/com/android/test/filters/SelectTestTests.java b/tests/utils/testutils/java/com/android/test/filters/SelectTestTests.java index 163b00abafcd..df18985f77bf 100644 --- a/tests/utils/testutils/java/com/android/test/filters/SelectTestTests.java +++ b/tests/utils/testutils/java/com/android/test/filters/SelectTestTests.java @@ -19,7 +19,11 @@ package com.android.test.filters; import static com.android.test.filters.SelectTest.OPTION_SELECT_TEST; import static com.android.test.filters.SelectTest.OPTION_SELECT_TEST_VERBOSE; +import static org.hamcrest.collection.IsArrayContaining.hasItemInArray; import static org.junit.Assert.assertFalse; +import static org.junit.Assert.assertNotNull; +import static org.junit.Assert.assertSame; +import static org.junit.Assert.assertThat; import static org.junit.Assert.assertTrue; import android.os.Bundle; @@ -146,6 +150,45 @@ public class SelectTestTests { } @Test + public void testAddSelectTest() { + final Bundle testArgs = new Bundle(); + + final Bundle modifiedTestArgs = + SelectTest.addSelectTest(testArgs, PACKAGE_A, CLASS_B3, METHOD_C5X); + assertSame(testArgs, modifiedTestArgs); + + final String selectTestArgs = modifiedTestArgs.getString(OPTION_SELECT_TEST); + assertNotNull(selectTestArgs); + final String[] selectedTests = selectTestArgs.split(","); + assertThat(selectedTests, hasItemInArray(PACKAGE_A)); + assertThat(selectedTests, hasItemInArray(CLASS_B3)); + assertThat(selectedTests, hasItemInArray(METHOD_C5X)); + } + + @Test + public void testAddSelectTest_prependExistingTestArg() { + final Bundle testArgs = new Bundle(); + testArgs.putString(OPTION_SELECT_TEST, new StringJoiner(",") + .add(PACKAGE_A) + .add(CLASS_B3) + .add(METHOD_C5X) + .toString()); + + final Bundle modifiedTestArgs = + SelectTest.addSelectTest(testArgs, PACKAGE_B, CLASS_B4, METHOD_C6Y); + + final String selectTestArgs = modifiedTestArgs.getString(OPTION_SELECT_TEST); + assertNotNull(selectTestArgs); + final String[] selectedTests = selectTestArgs.split(","); + assertThat(selectedTests, hasItemInArray(PACKAGE_A)); + assertThat(selectedTests, hasItemInArray(CLASS_B3)); + assertThat(selectedTests, hasItemInArray(METHOD_C5X)); + assertThat(selectedTests, hasItemInArray(PACKAGE_B)); + assertThat(selectedTests, hasItemInArray(CLASS_B4)); + assertThat(selectedTests, hasItemInArray(METHOD_C6Y)); + } + + @Test public void testFilterDisabled() { final Filter filter = mBuilder.build(); acceptTests(filter, TEST_ALL); diff --git a/tools/aapt2/Android.bp b/tools/aapt2/Android.bp index 750fb56b2792..3669890c80af 100644 --- a/tools/aapt2/Android.bp +++ b/tools/aapt2/Android.bp @@ -187,3 +187,22 @@ cc_binary_host { static_libs: ["libaapt2"], defaults: ["aapt2_defaults"], } + +// ========================================================== +// Dist the protos +// ========================================================== +genrule { + name: "aapt2-protos", + tools: [":soong_zip"], + srcs: [ + "Configuration.proto", + "Resources.proto", + ], + out: ["aapt2-protos.zip"], + cmd: "mkdir $(genDir)/protos && " + + "cp $(in) $(genDir)/protos && " + + "$(location :soong_zip) -o $(out) -C $(genDir)/protos -D $(genDir)/protos", + dist: { + targets: ["sdk_repo"], + }, +} |