Merge "Undo isDataCapable as Public API"
diff --git a/Android.bp b/Android.bp
index d298af2..26971be 100644
--- a/Android.bp
+++ b/Android.bp
@@ -515,6 +515,10 @@
defaults: ["framework-defaults"],
srcs: [":framework-all-sources"],
installable: false,
+ static_libs: [
+ // Additional dependencies needed to build the ike API classes.
+ "ike-internals",
+ ],
apex_available: ["//apex_available:platform"],
visibility: [
// DO NOT ADD ANY MORE ENTRIES TO THIS LIST
@@ -524,39 +528,9 @@
],
}
-java_library {
- name: "framework-annotation-proc",
- defaults: ["framework-defaults"],
- srcs: [":framework-all-sources"],
- libs: [
- "app-compat-annotations",
- "unsupportedappusage",
- ],
- installable: false,
- plugins: [
- "compat-changeid-annotation-processor",
- ],
-}
-
platform_compat_config {
- name: "framework-platform-compat-config",
- src: ":framework-annotation-proc",
-}
-
-// A library including just UnsupportedAppUsage.java classes.
-//
-// Provided for target so that libraries can use it without depending on
-// the whole of framework or the core platform API.
-//
-// Built for host so that the annotation processor can also use this annotation.
-java_library {
- name: "unsupportedappusage-annotation",
- host_supported: true,
- srcs: [
- "core/java/android/annotation/IntDef.java",
- ],
-
- sdk_version: "core_current",
+ name: "framework-platform-compat-config",
+ src: ":framework-minus-apex",
}
// A temporary build target that is conditionally included on the bootclasspath if
diff --git a/ApiDocs.bp b/ApiDocs.bp
index b7e3646..7fd1168 100644
--- a/ApiDocs.bp
+++ b/ApiDocs.bp
@@ -65,8 +65,9 @@
"test-base/src/**/*.java",
":opt-telephony-srcs",
":opt-net-voip-srcs",
- ":core-current-stubs-source",
- ":core_public_api_files",
+ ":art-module-public-api-stubs-source",
+ ":conscrypt-module-public-api-stubs-source",
+ ":android_icu4j_public_api_files",
"test-mock/src/**/*.java",
"test-runner/src/**/*.java",
],
diff --git a/StubLibraries.bp b/StubLibraries.bp
index fccb258..de6d6f6 100644
--- a/StubLibraries.bp
+++ b/StubLibraries.bp
@@ -47,8 +47,9 @@
"core/java/**/*.logtags",
":opt-telephony-srcs",
":opt-net-voip-srcs",
- ":core-current-stubs-source",
- ":core_public_api_files",
+ ":art-module-public-api-stubs-source",
+ ":conscrypt-module-public-api-stubs-source",
+ ":android_icu4j_public_api_files",
],
libs: ["framework-internal-utils"],
installable: false,
@@ -88,6 +89,7 @@
api_filename: "public_api.txt",
private_api_filename: "private.txt",
removed_api_filename: "removed.txt",
+ removed_dex_api_filename: "removed-dex.txt",
arg_files: [
"core/res/AndroidManifest.xml",
],
@@ -128,6 +130,7 @@
api_filename: "system-api.txt",
private_api_filename: "system-private.txt",
removed_api_filename: "system-removed.txt",
+ removed_dex_api_filename: "system-removed-dex.txt",
arg_files: [
"core/res/AndroidManifest.xml",
],
@@ -314,42 +317,6 @@
}
/////////////////////////////////////////////////////////////////////
-// Stubs for hiddenapi processing.
-/////////////////////////////////////////////////////////////////////
-
-droidstubs {
- name: "hiddenapi-lists-docs",
- defaults: ["metalava-full-api-stubs-default"],
- arg_files: [
- "core/res/AndroidManifest.xml",
- ],
- removed_dex_api_filename: "removed-dex.txt",
- args: metalava_framework_docs_args +
- " --show-unannotated " +
- priv_apps +
- " --show-annotation android.annotation.TestApi ",
-}
-
-droidstubs {
- name: "hiddenapi-mappings",
- defaults: ["metalava-full-api-stubs-default"],
- srcs: [
- ":opt-telephony-common-srcs",
- ],
-
- arg_files: [
- "core/res/AndroidManifest.xml",
- ],
- dex_mapping_filename: "dex-mapping.txt",
- args: metalava_framework_docs_args +
- " --hide ReferencesHidden " +
- " --hide UnhiddenSystemApi " +
- " --show-unannotated " +
- priv_apps +
- " --show-annotation android.annotation.TestApi ",
-}
-
-/////////////////////////////////////////////////////////////////////
// api/*-current.txt files for use by modules in other directories
// like the CTS test
/////////////////////////////////////////////////////////////////////
diff --git a/apex/Android.bp b/apex/Android.bp
index a6461f3..0b9802d 100644
--- a/apex/Android.bp
+++ b/apex/Android.bp
@@ -26,8 +26,24 @@
"--hide Typo " +
"--hide UnavailableSymbol "
-// TODO: remove this server classes are cleaned up.
-mainline_stubs_args += "--hide-package com.android.server "
+// TODO: modularize this so not every module has the same whitelist
+framework_packages_to_document = [
+ "android",
+ "dalvik",
+ "java",
+ "javax",
+ "junit",
+ "org.apache.http",
+ "org.json",
+ "org.w3c.dom",
+ "org.xml.sax",
+ "org.xmlpull",
+]
+
+// TODO: remove the hiding when server classes are cleaned up.
+mainline_framework_stubs_args =
+ mainline_stubs_args +
+ "--hide-package com.android.server "
priv_apps = " " +
"--show-annotation android.annotation.SystemApi\\(" +
@@ -39,11 +55,20 @@
"client=android.annotation.SystemApi.Client.MODULE_LIBRARIES" +
"\\) "
+mainline_service_stubs_args =
+ mainline_stubs_args +
+ "--show-annotation android.annotation.SystemApi\\(" +
+ "client=android.annotation.SystemApi.Client.SYSTEM_SERVER" +
+ "\\) " +
+ "--hide-annotation android.annotation.Hide " +
+ "--hide InternalClasses " // com.android.* classes are okay in this interface
+
stubs_defaults {
name: "framework-module-stubs-defaults-publicapi",
- args: mainline_stubs_args,
+ args: mainline_framework_stubs_args,
installable: false,
sdk_version: "current",
+ filter_packages: framework_packages_to_document,
check_api: {
current: {
api_file: "api/current.txt",
@@ -54,10 +79,11 @@
stubs_defaults {
name: "framework-module-stubs-defaults-systemapi",
- args: mainline_stubs_args + priv_apps,
+ args: mainline_framework_stubs_args + priv_apps,
libs: ["framework-annotations-lib"],
installable: false,
sdk_version: "system_current",
+ filter_packages: framework_packages_to_document,
check_api: {
current: {
api_file: "api/system-current.txt",
@@ -91,10 +117,11 @@
stubs_defaults {
name: "framework-module-api-defaults-module_libs_api",
- args: mainline_stubs_args + module_libs,
+ args: mainline_framework_stubs_args + module_libs,
libs: ["framework-annotations-lib"],
installable: false,
sdk_version: "module_current",
+ filter_packages: framework_packages_to_document,
check_api: {
current: {
api_file: "api/module-lib-current.txt",
@@ -105,8 +132,28 @@
stubs_defaults {
name: "framework-module-stubs-defaults-module_libs_api",
- args: mainline_stubs_args + module_libs + priv_apps,
+ args: mainline_framework_stubs_args + module_libs + priv_apps,
libs: ["framework-annotations-lib"],
installable: false,
sdk_version: "module_current",
+ filter_packages: framework_packages_to_document,
+}
+
+stubs_defaults {
+ name: "service-module-stubs-srcs-defaults",
+ args: mainline_service_stubs_args,
+ installable: false,
+ filter_packages: ["com.android."],
+ check_api: {
+ current: {
+ api_file: "api/current.txt",
+ removed_api_file: "api/removed.txt",
+ },
+ },
+}
+
+// Empty for now, but a convenient place to add rules for all
+// module java_library system_server stub libs.
+java_defaults {
+ name: "service-module-stubs-defaults",
}
diff --git a/api/current.txt b/api/current.txt
index 5c843c8..403cf2d 100644
--- a/api/current.txt
+++ b/api/current.txt
@@ -9849,7 +9849,6 @@
field public static final String MEDIA_ROUTER_SERVICE = "media_router";
field public static final String MEDIA_SESSION_SERVICE = "media_session";
field public static final String MIDI_SERVICE = "midi";
- field public static final String MMS_SERVICE = "mms";
field public static final int MODE_APPEND = 32768; // 0x8000
field public static final int MODE_ENABLE_WRITE_AHEAD_LOGGING = 8; // 0x8
field @Deprecated public static final int MODE_MULTI_PROCESS = 4; // 0x4
@@ -29146,9 +29145,6 @@
public final class NetworkCapabilities implements android.os.Parcelable {
ctor public NetworkCapabilities();
ctor public NetworkCapabilities(android.net.NetworkCapabilities);
- method @NonNull public android.net.NetworkCapabilities addCapability(int);
- method @NonNull public android.net.NetworkCapabilities addTransportType(int);
- method public void clearAll();
method public int describeContents();
method public int getLinkDownstreamBandwidthKbps();
method public int getLinkUpstreamBandwidthKbps();
@@ -29158,13 +29154,6 @@
method @Nullable public android.net.TransportInfo getTransportInfo();
method public boolean hasCapability(int);
method public boolean hasTransport(int);
- method @NonNull public android.net.NetworkCapabilities removeCapability(int);
- method @NonNull public android.net.NetworkCapabilities setCapability(int, boolean);
- method @NonNull public android.net.NetworkCapabilities setLinkDownstreamBandwidthKbps(int);
- method @NonNull public android.net.NetworkCapabilities setLinkUpstreamBandwidthKbps(int);
- method @NonNull public android.net.NetworkCapabilities setNetworkSpecifier(@NonNull android.net.NetworkSpecifier);
- method @NonNull public android.net.NetworkCapabilities setOwnerUid(int);
- method @NonNull public android.net.NetworkCapabilities setSignalStrength(int);
method public void writeToParcel(android.os.Parcel, int);
field @NonNull public static final android.os.Parcelable.Creator<android.net.NetworkCapabilities> CREATOR;
field public static final int NET_CAPABILITY_CAPTIVE_PORTAL = 17; // 0x11
@@ -29251,6 +29240,7 @@
method @Nullable public android.net.NetworkSpecifier getNetworkSpecifier();
method public boolean hasCapability(int);
method public boolean hasTransport(int);
+ method public boolean satisfiedBy(@Nullable android.net.NetworkCapabilities);
method public void writeToParcel(android.os.Parcel, int);
field @NonNull public static final android.os.Parcelable.Creator<android.net.NetworkRequest> CREATOR;
}
@@ -36025,6 +36015,7 @@
method public boolean isAllocationSupported(@NonNull java.io.FileDescriptor);
method public boolean isCacheBehaviorGroup(java.io.File) throws java.io.IOException;
method public boolean isCacheBehaviorTombstone(java.io.File) throws java.io.IOException;
+ method public boolean isCheckpointSupported();
method public boolean isEncrypted(java.io.File);
method public boolean isObbMounted(String);
method public boolean mountObb(String, String, android.os.storage.OnObbStateChangeListener);
@@ -45316,11 +45307,6 @@
method @Nullable public android.telephony.mbms.StreamingService startStreaming(android.telephony.mbms.StreamingServiceInfo, @NonNull java.util.concurrent.Executor, android.telephony.mbms.StreamingServiceCallback);
}
- public class MmsManager {
- method public void downloadMultimediaMessage(int, @NonNull String, @NonNull android.net.Uri, @Nullable android.os.Bundle, @Nullable android.app.PendingIntent);
- method public void sendMultimediaMessage(int, @NonNull android.net.Uri, @Nullable String, @Nullable android.os.Bundle, @Nullable android.app.PendingIntent);
- }
-
@Deprecated public class NeighboringCellInfo implements android.os.Parcelable {
ctor @Deprecated public NeighboringCellInfo();
ctor @Deprecated public NeighboringCellInfo(int, int);
@@ -45594,7 +45580,7 @@
method public String createAppSpecificSmsToken(android.app.PendingIntent);
method @Nullable public String createAppSpecificSmsTokenWithPackageInfo(@Nullable String, @NonNull android.app.PendingIntent);
method public java.util.ArrayList<java.lang.String> divideMessage(String);
- method @Deprecated public void downloadMultimediaMessage(android.content.Context, String, android.net.Uri, android.os.Bundle, android.app.PendingIntent);
+ method public void downloadMultimediaMessage(android.content.Context, String, android.net.Uri, android.os.Bundle, android.app.PendingIntent);
method @NonNull public android.os.Bundle getCarrierConfigValues();
method public static android.telephony.SmsManager getDefault();
method public static int getDefaultSmsSubscriptionId();
@@ -45604,7 +45590,7 @@
method public int getSubscriptionId();
method public void injectSmsPdu(byte[], String, android.app.PendingIntent);
method public void sendDataMessage(String, String, short, byte[], android.app.PendingIntent, android.app.PendingIntent);
- method @Deprecated public void sendMultimediaMessage(android.content.Context, android.net.Uri, String, android.os.Bundle, android.app.PendingIntent);
+ method public void sendMultimediaMessage(android.content.Context, android.net.Uri, String, android.os.Bundle, android.app.PendingIntent);
method public void sendMultipartTextMessage(String, String, java.util.ArrayList<java.lang.String>, java.util.ArrayList<android.app.PendingIntent>, java.util.ArrayList<android.app.PendingIntent>);
method public void sendTextMessage(String, String, String, android.app.PendingIntent, android.app.PendingIntent);
method @RequiresPermission(allOf={android.Manifest.permission.MODIFY_PHONE_STATE, android.Manifest.permission.SEND_SMS}) public void sendTextMessageWithoutPersisting(String, String, String, android.app.PendingIntent, android.app.PendingIntent);
@@ -45890,6 +45876,7 @@
method public android.telephony.SubscriptionPlan build();
method public static android.telephony.SubscriptionPlan.Builder createNonrecurring(java.time.ZonedDateTime, java.time.ZonedDateTime);
method public static android.telephony.SubscriptionPlan.Builder createRecurring(java.time.ZonedDateTime, java.time.Period);
+ method @NonNull public android.telephony.SubscriptionPlan.Builder resetNetworkTypes();
method public android.telephony.SubscriptionPlan.Builder setDataLimit(long, int);
method public android.telephony.SubscriptionPlan.Builder setDataUsage(long, long);
method @NonNull public android.telephony.SubscriptionPlan.Builder setNetworkTypes(@NonNull int[]);
diff --git a/api/system-current.txt b/api/system-current.txt
index 4e97dc5..2373a2f 100755
--- a/api/system-current.txt
+++ b/api/system-current.txt
@@ -1900,7 +1900,6 @@
field @Deprecated public static final int MASK_PERMISSION_FLAGS = 255; // 0xff
field public static final int MATCH_ANY_USER = 4194304; // 0x400000
field public static final int MATCH_FACTORY_ONLY = 2097152; // 0x200000
- field public static final int MATCH_HIDDEN_UNTIL_INSTALLED_COMPONENTS = 536870912; // 0x20000000
field public static final int MATCH_INSTANT = 8388608; // 0x800000
field public static final int RESTRICTION_HIDE_FROM_SUGGESTIONS = 1; // 0x1
field public static final int RESTRICTION_HIDE_NOTIFICATIONS = 2; // 0x2
@@ -4399,10 +4398,10 @@
public class InvalidPacketException extends java.lang.Exception {
ctor public InvalidPacketException(int);
+ method public int getError();
field public static final int ERROR_INVALID_IP_ADDRESS = -21; // 0xffffffeb
field public static final int ERROR_INVALID_LENGTH = -23; // 0xffffffe9
field public static final int ERROR_INVALID_PORT = -22; // 0xffffffea
- field public final int error;
}
public final class IpConfiguration implements android.os.Parcelable {
@@ -4456,12 +4455,12 @@
}
public class KeepalivePacketData {
- ctor protected KeepalivePacketData(@NonNull java.net.InetAddress, int, @NonNull java.net.InetAddress, int, @NonNull byte[]) throws android.net.InvalidPacketException;
+ ctor protected KeepalivePacketData(@NonNull java.net.InetAddress, @IntRange(from=0, to=65535) int, @NonNull java.net.InetAddress, @IntRange(from=0, to=65535) int, @NonNull byte[]) throws android.net.InvalidPacketException;
+ method @NonNull public java.net.InetAddress getDstAddress();
+ method public int getDstPort();
method @NonNull public byte[] getPacket();
- field @NonNull public final java.net.InetAddress dstAddress;
- field public final int dstPort;
- field @NonNull public final java.net.InetAddress srcAddress;
- field public final int srcPort;
+ method @NonNull public java.net.InetAddress getSrcAddress();
+ method public int getSrcPort();
}
public class LinkAddress implements android.os.Parcelable {
@@ -4547,14 +4546,14 @@
method public void onRemoveKeepalivePacketFilter(int);
method public void onSaveAcceptUnvalidated(boolean);
method public void onSignalStrengthThresholdsUpdated(@NonNull int[]);
- method public void onStartSocketKeepalive(int, int, @NonNull android.net.KeepalivePacketData);
+ method public void onStartSocketKeepalive(int, @IntRange(from=10, to=3600) int, @NonNull android.net.KeepalivePacketData);
method public void onStopSocketKeepalive(int);
- method public void onValidationStatus(int, @Nullable String);
+ method public void onValidationStatus(int, @Nullable android.net.Uri);
method @NonNull public android.net.Network register();
- method public void sendLinkProperties(@NonNull android.net.LinkProperties);
- method public void sendNetworkCapabilities(@NonNull android.net.NetworkCapabilities);
- method public void sendNetworkScore(int);
- method public void sendSocketKeepaliveEvent(int, int);
+ method public final void sendLinkProperties(@NonNull android.net.LinkProperties);
+ method public final void sendNetworkCapabilities(@NonNull android.net.NetworkCapabilities);
+ method public final void sendNetworkScore(@IntRange(from=0, to=99) int);
+ method public final void sendSocketKeepaliveEvent(int, int);
method public void setConnected();
method public void unregister();
field public static final int VALIDATION_STATUS_NOT_VALID = 2; // 0x2
@@ -4572,7 +4571,7 @@
field @NonNull public static final android.os.Parcelable.Creator<android.net.NetworkAgentConfig> CREATOR;
}
- public static class NetworkAgentConfig.Builder {
+ public static final class NetworkAgentConfig.Builder {
ctor public NetworkAgentConfig.Builder();
method @NonNull public android.net.NetworkAgentConfig build();
method @NonNull public android.net.NetworkAgentConfig.Builder setExplicitlySelected(boolean);
@@ -4584,18 +4583,33 @@
public final class NetworkCapabilities implements android.os.Parcelable {
method @NonNull public int[] getAdministratorUids();
- method @Nullable public String getSSID();
+ method @Nullable public String getSsid();
method @NonNull public int[] getTransportTypes();
method public boolean satisfiedByNetworkCapabilities(@Nullable android.net.NetworkCapabilities);
- method @NonNull public android.net.NetworkCapabilities setAdministratorUids(@NonNull int[]);
- method @NonNull public android.net.NetworkCapabilities setRequestorPackageName(@NonNull String);
- method @NonNull public android.net.NetworkCapabilities setRequestorUid(int);
- method @NonNull public android.net.NetworkCapabilities setSSID(@Nullable String);
- method @NonNull public android.net.NetworkCapabilities setTransportInfo(@NonNull android.net.TransportInfo);
field public static final int NET_CAPABILITY_OEM_PAID = 22; // 0x16
field public static final int NET_CAPABILITY_PARTIAL_CONNECTIVITY = 24; // 0x18
}
+ public static class NetworkCapabilities.Builder {
+ ctor public NetworkCapabilities.Builder();
+ ctor public NetworkCapabilities.Builder(@NonNull android.net.NetworkCapabilities);
+ method @NonNull public android.net.NetworkCapabilities.Builder addCapability(int);
+ method @NonNull public android.net.NetworkCapabilities.Builder addTransportType(int);
+ method @NonNull public android.net.NetworkCapabilities build();
+ method @NonNull public android.net.NetworkCapabilities.Builder removeCapability(int);
+ method @NonNull public android.net.NetworkCapabilities.Builder removeTransportType(int);
+ method @NonNull @RequiresPermission(android.Manifest.permission.NETWORK_FACTORY) public android.net.NetworkCapabilities.Builder setAdministratorUids(@NonNull int[]);
+ method @NonNull public android.net.NetworkCapabilities.Builder setLinkDownstreamBandwidthKbps(int);
+ method @NonNull public android.net.NetworkCapabilities.Builder setLinkUpstreamBandwidthKbps(int);
+ method @NonNull public android.net.NetworkCapabilities.Builder setNetworkSpecifier(@Nullable android.net.NetworkSpecifier);
+ method @NonNull @RequiresPermission(android.Manifest.permission.NETWORK_FACTORY) public android.net.NetworkCapabilities.Builder setOwnerUid(int);
+ method @NonNull @RequiresPermission(android.Manifest.permission.NETWORK_FACTORY) public android.net.NetworkCapabilities.Builder setRequestorPackageName(@Nullable String);
+ method @NonNull @RequiresPermission(android.Manifest.permission.NETWORK_FACTORY) public android.net.NetworkCapabilities.Builder setRequestorUid(int);
+ method @NonNull @RequiresPermission(android.Manifest.permission.NETWORK_SIGNAL_STRENGTH_WAKEUP) public android.net.NetworkCapabilities.Builder setSignalStrength(int);
+ method @NonNull @RequiresPermission(android.Manifest.permission.NETWORK_FACTORY) public android.net.NetworkCapabilities.Builder setSsid(@Nullable String);
+ method @NonNull public android.net.NetworkCapabilities.Builder setTransportInfo(@Nullable android.net.TransportInfo);
+ }
+
public class NetworkKey implements android.os.Parcelable {
ctor public NetworkKey(android.net.WifiKey);
method @Nullable public static android.net.NetworkKey createFromScanResult(@Nullable android.net.wifi.ScanResult);
@@ -4611,8 +4625,8 @@
ctor public NetworkProvider(@NonNull android.content.Context, @NonNull android.os.Looper, @NonNull String);
method @RequiresPermission(android.Manifest.permission.NETWORK_FACTORY) public void declareNetworkRequestUnfulfillable(@NonNull android.net.NetworkRequest);
method public int getProviderId();
- method public void onNetworkRequested(@NonNull android.net.NetworkRequest, int, int);
- method public void onRequestWithdrawn(@NonNull android.net.NetworkRequest);
+ method public void onNetworkRequestWithdrawn(@NonNull android.net.NetworkRequest);
+ method public void onNetworkRequested(@NonNull android.net.NetworkRequest, @IntRange(from=0, to=99) int, int);
field public static final int ID_NONE = -1; // 0xffffffff
}
@@ -4625,7 +4639,6 @@
public class NetworkRequest implements android.os.Parcelable {
method @Nullable public String getRequestorPackageName();
method public int getRequestorUid();
- method public boolean satisfiedBy(@Nullable android.net.NetworkCapabilities);
}
public static class NetworkRequest.Builder {
@@ -6790,7 +6803,6 @@
field public static final String AUTOFILL_USER_DATA_MAX_USER_DATA_SIZE = "autofill_user_data_max_user_data_size";
field public static final String AUTOFILL_USER_DATA_MAX_VALUE_LENGTH = "autofill_user_data_max_value_length";
field public static final String AUTOFILL_USER_DATA_MIN_VALUE_LENGTH = "autofill_user_data_min_value_length";
- field public static final String CARRIER_APPS_HANDLED = "carrier_apps_handled";
field public static final String COMPLETED_CATEGORY_PREFIX = "suggested.completed_category.";
field public static final String DOZE_ALWAYS_ON = "doze_always_on";
field public static final String HUSH_GESTURE_USED = "hush_gesture_used";
@@ -8853,7 +8865,6 @@
public class ServiceState implements android.os.Parcelable {
method public void fillInNotifierBundle(@NonNull android.os.Bundle);
method public int getDataNetworkType();
- method public boolean getDataRoamingFromRegistration();
method @Nullable public android.telephony.NetworkRegistrationInfo getNetworkRegistrationInfo(int, int);
method @NonNull public java.util.List<android.telephony.NetworkRegistrationInfo> getNetworkRegistrationInfoListForDomain(int);
method @NonNull public java.util.List<android.telephony.NetworkRegistrationInfo> getNetworkRegistrationInfoListForTransportType(int);
@@ -9140,9 +9151,9 @@
method public boolean isDataConnectivityPossible();
method @RequiresPermission(android.Manifest.permission.READ_PRIVILEGED_PHONE_STATE) public boolean isDataEnabledForApn(int);
method @RequiresPermission(android.Manifest.permission.READ_PRIVILEGED_PHONE_STATE) public boolean isEmergencyAssistanceEnabled();
- method @RequiresPermission(android.Manifest.permission.READ_PRIVILEGED_PHONE_STATE) public boolean isGlobalModeEnabled();
method @Deprecated @RequiresPermission(anyOf={android.Manifest.permission.READ_PRIVILEGED_PHONE_STATE, android.Manifest.permission.READ_PHONE_STATE}) public boolean isIdle();
method @RequiresPermission(android.Manifest.permission.READ_PRIVILEGED_PHONE_STATE) public boolean isInEmergencySmsMode();
+ method @RequiresPermission(android.Manifest.permission.READ_PRIVILEGED_PHONE_STATE) public boolean isLteCdmaEvdoGsmWcdmaEnabled();
method @RequiresPermission(android.Manifest.permission.READ_PRIVILEGED_PHONE_STATE) public boolean isManualNetworkSelectionAllowed();
method public boolean isModemEnabledForSlot(int);
method @Deprecated @RequiresPermission(anyOf={android.Manifest.permission.READ_PRIVILEGED_PHONE_STATE, android.Manifest.permission.READ_PHONE_STATE}) public boolean isOffhook();
@@ -9189,9 +9200,9 @@
method @RequiresPermission(android.Manifest.permission.MODIFY_PHONE_STATE) public void setVoiceActivationState(int);
method @RequiresPermission(android.Manifest.permission.MODIFY_PHONE_STATE) public void shutdownAllRadios();
method @RequiresPermission(android.Manifest.permission.MODIFY_PHONE_STATE) public boolean supplyPin(String);
- method @Deprecated @RequiresPermission(android.Manifest.permission.MODIFY_PHONE_STATE) public int[] supplyPinReportResult(String);
+ method @RequiresPermission(android.Manifest.permission.MODIFY_PHONE_STATE) public int[] supplyPinReportResult(String);
method @RequiresPermission(android.Manifest.permission.MODIFY_PHONE_STATE) public boolean supplyPuk(String, String);
- method @Deprecated @RequiresPermission(android.Manifest.permission.MODIFY_PHONE_STATE) public int[] supplyPukReportResult(String, String);
+ method @RequiresPermission(android.Manifest.permission.MODIFY_PHONE_STATE) public int[] supplyPukReportResult(String, String);
method @RequiresPermission(android.Manifest.permission.MODIFY_PHONE_STATE) public boolean switchSlots(int[]);
method @RequiresPermission(android.Manifest.permission.MODIFY_PHONE_STATE) public void toggleRadioOnOff();
method @RequiresPermission(android.Manifest.permission.READ_ACTIVE_EMERGENCY_SESSION) public void updateOtaEmergencyNumberDbFilePath(@NonNull android.os.ParcelFileDescriptor);
@@ -9209,9 +9220,6 @@
field public static final String ACTION_SIM_APPLICATION_STATE_CHANGED = "android.telephony.action.SIM_APPLICATION_STATE_CHANGED";
field public static final String ACTION_SIM_CARD_STATE_CHANGED = "android.telephony.action.SIM_CARD_STATE_CHANGED";
field public static final String ACTION_SIM_SLOT_STATUS_CHANGED = "android.telephony.action.SIM_SLOT_STATUS_CHANGED";
- field public static final int CARD_POWER_DOWN = 0; // 0x0
- field public static final int CARD_POWER_UP = 1; // 0x1
- field public static final int CARD_POWER_UP_PASS_THROUGH = 2; // 0x2
field public static final int CARRIER_PRIVILEGE_STATUS_ERROR_LOADING_RULES = -2; // 0xfffffffe
field public static final int CARRIER_PRIVILEGE_STATUS_HAS_ACCESS = 1; // 0x1
field public static final int CARRIER_PRIVILEGE_STATUS_NO_ACCESS = 0; // 0x0
diff --git a/api/test-current.txt b/api/test-current.txt
index 73abb27..9ed451c 100644
--- a/api/test-current.txt
+++ b/api/test-current.txt
@@ -1511,12 +1511,34 @@
}
public final class NetworkCapabilities implements android.os.Parcelable {
+ method @NonNull public int[] getAdministratorUids();
method public int[] getCapabilities();
+ method @Nullable public String getSsid();
method @NonNull public int[] getTransportTypes();
method public boolean satisfiedByNetworkCapabilities(@Nullable android.net.NetworkCapabilities);
field public static final int TRANSPORT_TEST = 7; // 0x7
}
+ public static class NetworkCapabilities.Builder {
+ ctor public NetworkCapabilities.Builder();
+ ctor public NetworkCapabilities.Builder(@NonNull android.net.NetworkCapabilities);
+ method @NonNull public android.net.NetworkCapabilities.Builder addCapability(int);
+ method @NonNull public android.net.NetworkCapabilities.Builder addTransportType(int);
+ method @NonNull public android.net.NetworkCapabilities build();
+ method @NonNull public android.net.NetworkCapabilities.Builder removeCapability(int);
+ method @NonNull public android.net.NetworkCapabilities.Builder removeTransportType(int);
+ method @NonNull @RequiresPermission("android.permission.NETWORK_FACTORY") public android.net.NetworkCapabilities.Builder setAdministratorUids(@NonNull int[]);
+ method @NonNull public android.net.NetworkCapabilities.Builder setLinkDownstreamBandwidthKbps(int);
+ method @NonNull public android.net.NetworkCapabilities.Builder setLinkUpstreamBandwidthKbps(int);
+ method @NonNull public android.net.NetworkCapabilities.Builder setNetworkSpecifier(@Nullable android.net.NetworkSpecifier);
+ method @NonNull @RequiresPermission("android.permission.NETWORK_FACTORY") public android.net.NetworkCapabilities.Builder setOwnerUid(int);
+ method @NonNull @RequiresPermission("android.permission.NETWORK_FACTORY") public android.net.NetworkCapabilities.Builder setRequestorPackageName(@Nullable String);
+ method @NonNull @RequiresPermission("android.permission.NETWORK_FACTORY") public android.net.NetworkCapabilities.Builder setRequestorUid(int);
+ method @NonNull @RequiresPermission("android.permission.NETWORK_SIGNAL_STRENGTH_WAKEUP") public android.net.NetworkCapabilities.Builder setSignalStrength(int);
+ method @NonNull @RequiresPermission("android.permission.NETWORK_FACTORY") public android.net.NetworkCapabilities.Builder setSsid(@Nullable String);
+ method @NonNull public android.net.NetworkCapabilities.Builder setTransportInfo(@Nullable android.net.TransportInfo);
+ }
+
public class NetworkStack {
method @Nullable public static android.os.IBinder getService();
method public static void setServiceForTest(@Nullable android.os.IBinder);
diff --git a/cmds/statsd/src/atoms.proto b/cmds/statsd/src/atoms.proto
index 97fe7cd..3519a15 100644
--- a/cmds/statsd/src/atoms.proto
+++ b/cmds/statsd/src/atoms.proto
@@ -1531,7 +1531,7 @@
* Logged from:
* packages/apps/Bluetooth/src/com/android/bluetooth/btservice/RemoteDevices.java
*
- * Next Tag: 5
+ * Next Tag: 6
*/
message BluetoothConnectionStateChanged {
// The state of the connection.
@@ -1553,6 +1553,15 @@
// Size: 32 byte
// Default: null or empty if the device identifier is not known
optional bytes new_obfuscated_id = 4 [(android.os.statsd.log_mode) = MODE_BYTES];
+ // An identifier that can be used to match events for this device.
+ // The incremental identifier is locally generated and guaranteed not derived
+ // from any globally unique hardware id.
+ // For paired devices, it stays consistent between Bluetooth toggling for the
+ // same remote device.
+ // For unpaired devices, it stays consistent within the same Bluetooth adapter
+ // session for the same remote device.
+ // Default: 0 if the device's metric id is unknown.
+ optional int32 metric_id = 5;
}
/**
@@ -1561,7 +1570,7 @@
* Logged from:
* packages/apps/Bluetooth/src/com/android/bluetooth/btservice/AdapterProperties.java
*
- * Next Tag: 3
+ * Next Tag: 4
*/
message BluetoothAclConnectionStateChanged {
// An identifier that can be used to match events for this device.
@@ -1574,6 +1583,15 @@
// The state of the connection.
// Eg: CONNECTING, CONNECTED, DISCONNECTING, DISCONNECTED.
optional android.bluetooth.ConnectionStateEnum state = 2;
+ // An identifier that can be used to match events for this device.
+ // The incremental identifier is locally generated and guaranteed not derived
+ // from any globally unique hardware id.
+ // For paired devices, it stays consistent between Bluetooth toggling for the
+ // same remote device.
+ // For unpaired devices, it stays consistent within the same Bluetooth adapter
+ // session for the same remote device.
+ // Default: 0 if the device's metric id is unknown.
+ optional int32 metric_id = 3;
}
/**
@@ -1583,7 +1601,7 @@
* packages/apps/Bluetooth/src/com/android/bluetooth/hfp/HeadsetStateMachine.java
* packages/apps/Bluetooth/src/com/android/bluetooth/hfp/HeadsetClientStateMachine.java
*
- * Next Tag: 4
+ * Next Tag: 5
*/
message BluetoothScoConnectionStateChanged {
// An identifier that can be used to match events for this device.
@@ -1599,6 +1617,15 @@
// Codec used for this SCO connection
// Default: UNKNOWN
optional android.bluetooth.hfp.ScoCodec codec = 3;
+ // An identifier that can be used to match events for this device.
+ // The incremental identifier is locally generated and guaranteed not derived
+ // from any globally unique hardware id.
+ // For paired devices, it stays consistent between Bluetooth toggling for the
+ // same remote device.
+ // For unpaired devices, it stays consistent within the same Bluetooth adapter
+ // session for the same remote device.
+ // Default: 0 if the device's metric id is unknown.
+ optional int32 metric_id = 4;
}
/**
@@ -1620,6 +1647,15 @@
// Size: 32 byte
// Default: null or empty if there is no active device for this profile
optional bytes obfuscated_id = 2 [(android.os.statsd.log_mode) = MODE_BYTES];
+ // An identifier that can be used to match events for this device.
+ // The incremental identifier is locally generated and guaranteed not derived
+ // from any globally unique hardware id.
+ // For paired devices, it stays consistent between Bluetooth toggling for the
+ // same remote device.
+ // For unpaired devices, it stays consistent within the same Bluetooth adapter
+ // session for the same remote device.
+ // Default: 0 if the device's metric id is unknown.
+ optional int32 metric_id = 3;
}
// Logs when there is an event affecting Bluetooth device's link layer connection.
@@ -1703,6 +1739,15 @@
// HCI reason code associated with this event
// Default: STATUS_UNKNOWN
optional android.bluetooth.hci.StatusEnum reason_code = 9;
+ // An identifier that can be used to match events for this device.
+ // The incremental identifier is locally generated and guaranteed not derived
+ // from any globally unique hardware id.
+ // For paired devices, it stays consistent between Bluetooth toggling for the
+ // same remote device.
+ // For unpaired devices, it stays consistent within the same Bluetooth adapter
+ // session for the same remote device.
+ // Default: 0 if the device's metric id is unknown.
+ optional int32 metric_id = 10;
}
/**
@@ -1758,6 +1803,15 @@
// Current audio coding mode
// Default: AUDIO_CODING_MODE_UNKNOWN
optional android.bluetooth.a2dp.AudioCodingModeEnum audio_coding_mode = 3;
+ // An identifier that can be used to match events for this device.
+ // The incremental identifier is locally generated and guaranteed not derived
+ // from any globally unique hardware id.
+ // For paired devices, it stays consistent between Bluetooth toggling for the
+ // same remote device.
+ // For unpaired devices, it stays consistent within the same Bluetooth adapter
+ // session for the same remote device.
+ // Default: 0 if the device's metric id is unknown.
+ optional int32 metric_id = 4;
}
/**
@@ -1796,6 +1850,15 @@
optional int64 codec_specific_2 = 8;
optional int64 codec_specific_3 = 9;
optional int64 codec_specific_4 = 10;
+ // An identifier that can be used to match events for this device.
+ // The incremental identifier is locally generated and guaranteed not derived
+ // from any globally unique hardware id.
+ // For paired devices, it stays consistent between Bluetooth toggling for the
+ // same remote device.
+ // For unpaired devices, it stays consistent within the same Bluetooth adapter
+ // session for the same remote device.
+ // Default: 0 if the device's metric id is unknown.
+ optional int32 metric_id = 11;
}
/**
@@ -1838,6 +1901,15 @@
optional int64 codec_specific_2 = 8;
optional int64 codec_specific_3 = 9;
optional int64 codec_specific_4 = 10;
+ // An identifier that can be used to match events for this device.
+ // The incremental identifier is locally generated and guaranteed not derived
+ // from any globally unique hardware id.
+ // For paired devices, it stays consistent between Bluetooth toggling for the
+ // same remote device.
+ // For unpaired devices, it stays consistent within the same Bluetooth adapter
+ // session for the same remote device.
+ // Default: 0 if the device's metric id is unknown.
+ optional int32 metric_id = 11;
}
/**
@@ -1861,6 +1933,15 @@
// Number of bytes of PCM data that could not be read from the source
// Default: 0
optional int32 num_missing_pcm_bytes = 3;
+ // An identifier that can be used to match events for this device.
+ // The incremental identifier is locally generated and guaranteed not derived
+ // from any globally unique hardware id.
+ // For paired devices, it stays consistent between Bluetooth toggling for the
+ // same remote device.
+ // For unpaired devices, it stays consistent within the same Bluetooth adapter
+ // session for the same remote device.
+ // Default: 0 if the device's metric id is unknown.
+ optional int32 metric_id = 4;
}
/**
@@ -1891,6 +1972,15 @@
// Number of encoded bytes dropped in this event
// Default: 0
optional int32 num_dropped_encoded_bytes = 5;
+ // An identifier that can be used to match events for this device.
+ // The incremental identifier is locally generated and guaranteed not derived
+ // from any globally unique hardware id.
+ // For paired devices, it stays consistent between Bluetooth toggling for the
+ // same remote device.
+ // For unpaired devices, it stays consistent within the same Bluetooth adapter
+ // session for the same remote device.
+ // Default: 0 if the device's metric id is unknown.
+ optional int32 metric_id = 6;
}
/**
@@ -1922,6 +2012,15 @@
// Units: dBm
// Invalid when an out of range value is reported
optional int32 rssi = 4;
+ // An identifier that can be used to match events for this device.
+ // The incremental identifier is locally generated and guaranteed not derived
+ // from any globally unique hardware id.
+ // For paired devices, it stays consistent between Bluetooth toggling for the
+ // same remote device.
+ // For unpaired devices, it stays consistent within the same Bluetooth adapter
+ // session for the same remote device.
+ // Default: 0 if the device's metric id is unknown.
+ optional int32 metric_id = 5;
}
/**
@@ -1949,6 +2048,15 @@
// Range: uint16_t, 0-0xFFFF
// Default: 0xFFFFF
optional int32 failed_contact_counter = 4;
+ // An identifier that can be used to match events for this device.
+ // The incremental identifier is locally generated and guaranteed not derived
+ // from any globally unique hardware id.
+ // For paired devices, it stays consistent between Bluetooth toggling for the
+ // same remote device.
+ // For unpaired devices, it stays consistent within the same Bluetooth adapter
+ // session for the same remote device.
+ // Default: 0 if the device's metric id is unknown.
+ optional int32 metric_id = 5;
}
/**
@@ -1976,6 +2084,15 @@
// Units: dBm
// Invalid when an out of range value is reported
optional int32 transmit_power_level = 4;
+ // An identifier that can be used to match events for this device.
+ // The incremental identifier is locally generated and guaranteed not derived
+ // from any globally unique hardware id.
+ // For paired devices, it stays consistent between Bluetooth toggling for the
+ // same remote device.
+ // For unpaired devices, it stays consistent within the same Bluetooth adapter
+ // session for the same remote device.
+ // Default: 0 if the device's metric id is unknown.
+ optional int32 metric_id = 5;
}
/**
@@ -2105,6 +2222,15 @@
optional string hardware_version = 6;
// Software version of this device
optional string software_version = 7;
+ // An identifier that can be used to match events for this device.
+ // The incremental identifier is locally generated and guaranteed not derived
+ // from any globally unique hardware id.
+ // For paired devices, it stays consistent between Bluetooth toggling for the
+ // same remote device.
+ // For unpaired devices, it stays consistent within the same Bluetooth adapter
+ // session for the same remote device.
+ // Default: 0 if the device's metric id is unknown.
+ optional int32 metric_id = 8;
}
/**
@@ -2158,6 +2284,15 @@
optional int32 attribute_id = 3;
// Attribute value for the particular attribute
optional bytes attribute_value = 4 [(android.os.statsd.log_mode) = MODE_BYTES];
+ // An identifier that can be used to match events for this device.
+ // The incremental identifier is locally generated and guaranteed not derived
+ // from any globally unique hardware id.
+ // For paired devices, it stays consistent between Bluetooth toggling for the
+ // same remote device.
+ // For unpaired devices, it stays consistent within the same Bluetooth adapter
+ // session for the same remote device.
+ // Default: 0 if the device's metric id is unknown.
+ optional int32 metric_id = 5;
}
/**
@@ -2190,6 +2325,15 @@
// Unbond Reason
// Default: UNBOND_REASON_UNKNOWN
optional android.bluetooth.UnbondReasonEnum unbond_reason = 6;
+ // An identifier that can be used to match events for this device.
+ // The incremental identifier is locally generated and guaranteed not derived
+ // from any globally unique hardware id.
+ // For paired devices, it stays consistent between Bluetooth toggling for the
+ // same remote device.
+ // For unpaired devices, it stays consistent within the same Bluetooth adapter
+ // session for the same remote device.
+ // Default: 0 if the device's metric id is unknown.
+ optional int32 metric_id = 7;
}
/**
@@ -2225,6 +2369,15 @@
// A status value related to this specific event
// Default: 0
optional int64 event_value = 7;
+ // An identifier that can be used to match events for this device.
+ // The incremental identifier is locally generated and guaranteed not derived
+ // from any globally unique hardware id.
+ // For paired devices, it stays consistent between Bluetooth toggling for the
+ // same remote device.
+ // For unpaired devices, it stays consistent within the same Bluetooth adapter
+ // session for the same remote device.
+ // Default: 0 if the device's metric id is unknown.
+ optional int32 metric_id = 8;
}
/**
@@ -2250,6 +2403,15 @@
// SMP failure reason code
// Default: PAIRING_FAIL_REASON_DEFAULT
optional android.bluetooth.smp.PairingFailReasonEnum smp_fail_reason = 4;
+ // An identifier that can be used to match events for this device.
+ // The incremental identifier is locally generated and guaranteed not derived
+ // from any globally unique hardware id.
+ // For paired devices, it stays consistent between Bluetooth toggling for the
+ // same remote device.
+ // For unpaired devices, it stays consistent within the same Bluetooth adapter
+ // session for the same remote device.
+ // Default: 0 if the device's metric id is unknown.
+ optional int32 metric_id = 5;
}
/**
@@ -2288,6 +2450,15 @@
optional int32 server_port = 8;
// Whether this is a server listener socket
optional android.bluetooth.SocketRoleEnum is_server = 9;
+ // An identifier that can be used to match events for this device.
+ // The incremental identifier is locally generated and guaranteed not derived
+ // from any globally unique hardware id.
+ // For paired devices, it stays consistent between Bluetooth toggling for the
+ // same remote device.
+ // For unpaired devices, it stays consistent within the same Bluetooth adapter
+ // session for the same remote device.
+ // Default: 0 if the device's metric id is unknown.
+ optional int32 metric_id = 10;
}
/**
@@ -2311,6 +2482,15 @@
// Also defined in: https://developer.android.com/reference/android/bluetooth/BluetoothClass
// Default: 0
optional int32 class_of_device = 2;
+ // An identifier that can be used to match events for this device.
+ // The incremental identifier is locally generated and guaranteed not derived
+ // from any globally unique hardware id.
+ // For paired devices, it stays consistent between Bluetooth toggling for the
+ // same remote device.
+ // For unpaired devices, it stays consistent within the same Bluetooth adapter
+ // session for the same remote device.
+ // Default: 0 if the device's metric id is unknown.
+ optional int32 metric_id = 3;
}
/**
diff --git a/core/java/android/app/UiModeManager.java b/core/java/android/app/UiModeManager.java
index 3633064..62c7329 100644
--- a/core/java/android/app/UiModeManager.java
+++ b/core/java/android/app/UiModeManager.java
@@ -70,19 +70,26 @@
* also monitor this Intent in order to be informed of mode changes or
* prevent the normal car UI from being displayed by setting the result
* of the broadcast to {@link Activity#RESULT_CANCELED}.
+ * <p>
+ * This intent is broadcast when {@link #getCurrentModeType()} transitions to
+ * {@link Configuration#UI_MODE_TYPE_CAR} from some other ui mode.
*/
public static String ACTION_ENTER_CAR_MODE = "android.app.action.ENTER_CAR_MODE";
/**
- * Broadcast sent when the device's UI has switched to car mode, either by being placed in a car
- * dock or explicit action of the user.
+ * Broadcast sent when an app has entered car mode using either {@link #enableCarMode(int)} or
+ * {@link #enableCarMode(int, int)}.
* <p>
- * In addition to the behavior for {@link #ACTION_ENTER_CAR_MODE}, this broadcast includes the
- * package name of the app which requested to enter car mode in the
- * {@link #EXTRA_CALLING_PACKAGE}. If an app requested to enter car mode using
- * {@link #enableCarMode(int, int)} and specified a priority this will be specified in the
+ * Unlike {@link #ACTION_ENTER_CAR_MODE}, which is only sent when the global car mode state
+ * (i.e. {@link #getCurrentModeType()}) transitions to {@link Configuration#UI_MODE_TYPE_CAR},
+ * this intent is sent any time an app declares it has entered car mode. Thus, this intent is
+ * intended for use by a component which needs to know not only when the global car mode state
+ * changed, but also when the highest priority app declaring car mode has changed.
+ * <p>
+ * This broadcast includes the package name of the app which requested to enter car mode in
+ * {@link #EXTRA_CALLING_PACKAGE}. The priority the app entered car mode at is specified in
* {@link #EXTRA_PRIORITY}.
- *
+ * <p>
* This is primarily intended to be received by other components of the Android OS.
* <p>
* Receiver requires permission: {@link android.Manifest.permission.HANDLE_CAR_MODE_CHANGES}
@@ -96,17 +103,25 @@
* Broadcast sent when the device's UI has switch away from car mode back
* to normal mode. Typically used by a car mode app, to dismiss itself
* when the user exits car mode.
+ * <p>
+ * This intent is broadcast when {@link #getCurrentModeType()} transitions from
+ * {@link Configuration#UI_MODE_TYPE_CAR} to some other ui mode.
*/
public static String ACTION_EXIT_CAR_MODE = "android.app.action.EXIT_CAR_MODE";
/**
- * Broadcast sent when the device's UI has switched away from car mode back to normal mode.
- * Typically used by a car mode app, to dismiss itself when the user exits car mode.
+ * Broadcast sent when an app has exited car mode using {@link #disableCarMode(int)}.
* <p>
- * In addition to the behavior for {@link #ACTION_EXIT_CAR_MODE}, this broadcast includes the
- * package name of the app which requested to exit car mode in {@link #EXTRA_CALLING_PACKAGE}.
- * If an app requested to enter car mode using {@link #enableCarMode(int, int)} and specified a
- * priority this will be specified in the {@link #EXTRA_PRIORITY} when exiting car mode.
+ * Unlike {@link #ACTION_EXIT_CAR_MODE}, which is only sent when the global car mode state
+ * (i.e. {@link #getCurrentModeType()}) transitions to a non-car mode state such as
+ * {@link Configuration#UI_MODE_TYPE_NORMAL}, this intent is sent any time an app declares it
+ * has exited car mode. Thus, this intent is intended for use by a component which needs to
+ * know not only when the global car mode state changed, but also when the highest priority app
+ * declaring car mode has changed.
+ * <p>
+ * This broadcast includes the package name of the app which requested to exit car mode in
+ * {@link #EXTRA_CALLING_PACKAGE}. The priority the app originally entered car mode at is
+ * specified in {@link #EXTRA_PRIORITY}.
* <p>
* If {@link #DISABLE_CAR_MODE_ALL_PRIORITIES} is used when disabling car mode (i.e. this is
* initiated by the user via the persistent car mode notification), this broadcast is sent once
@@ -251,9 +266,7 @@
* An app may request to enter car mode when the system is already in car mode. The app may
* specify a "priority" when entering car mode. The device will remain in car mode
* (i.e. {@link #getCurrentModeType()} is {@link Configuration#UI_MODE_TYPE_CAR}) as long as
- * there is a priority level at which car mode have been enabled. For example assume app A
- * enters car mode at priority level 100, and then app B enters car mode at the default priority
- * (0). If app A exits car mode, the device will remain in car mode until app B exits car mode.
+ * there is a priority level at which car mode have been enabled.
* <p>
* Specifying a priority level when entering car mode is important in cases where multiple apps
* on a device implement a car-mode {@link android.telecom.InCallService} (see
@@ -266,18 +279,28 @@
* correct conditions exist for that app to be in car mode. The device maker should ensure that
* where multiple apps exist on the device which can potentially enter car mode, appropriate
* priorities are used to ensure that calls delivered by the
- * {@link android.telecom.InCallService} API are delivered to the highest priority app.
- * If app A and app B can both potentially enable car mode, and it is desired that app B is the
- * one which should receive call information, the priority for app B should be higher than the
- * one for app A.
+ * {@link android.telecom.InCallService} API are sent to the highest priority app given the
+ * desired behavior of the car mode experience on the device.
* <p>
- * When an app uses a priority to enable car mode, they can disable car mode at the specified
+ * If app A and app B both meet their own criteria to enable car mode, and it is desired that
+ * app B should be the one which should receive call information in that scenario, the priority
+ * for app B should be higher than the one for app A. The higher priority of app B compared to
+ * A means it will be bound to during calls and app A will not. When app B no longer meets its
+ * criteria for providing a car mode experience it uses {@link #disableCarMode(int)} to disable
+ * car mode at its priority level. The system will then unbind from app B and bind to app A as
+ * it has the next highest priority.
+ * <p>
+ * When an app enables car mode at a certain priority, it can disable car mode at the specified
* priority level using {@link #disableCarMode(int)}. An app may only enable car mode at a
* single priority.
* <p>
- * Public apps are assumed to enter/exit car mode at {@link #DEFAULT_PRIORITY}.
+ * Public apps are assumed to enter/exit car mode at the lowest priority,
+ * {@link #DEFAULT_PRIORITY}.
*
- * @param priority The declared priority for the caller.
+ * @param priority The declared priority for the caller, where {@link #DEFAULT_PRIORITY} (0) is
+ * the lowest priority and higher numbers represent a higher priority.
+ * The priorities apps declare when entering car mode is determined by the
+ * device manufacturer based on the desired car mode experience.
* @param flags Car mode flags.
* @hide
*/
@@ -322,11 +345,11 @@
/**
* The default priority used for entering car mode.
* <p>
- * Callers of the {@link UiModeManager#enableCarMode(int)} priority will be assigned the
- * default priority.
+ * Callers of the {@link #enableCarMode(int)} priority will be assigned the default priority.
+ * This is considered the lowest possible priority for enabling car mode.
* <p>
* System apps can specify a priority other than the default priority when using
- * {@link UiModeManager#enableCarMode(int, int)} to enable car mode.
+ * {@link #enableCarMode(int, int)} to enable car mode.
* @hide
*/
@SystemApi
diff --git a/core/java/android/bluetooth/BluetoothAdapter.java b/core/java/android/bluetooth/BluetoothAdapter.java
index e6b90d8..1508a65 100644
--- a/core/java/android/bluetooth/BluetoothAdapter.java
+++ b/core/java/android/bluetooth/BluetoothAdapter.java
@@ -916,23 +916,11 @@
if (!isBleScanAlwaysAvailable()) {
return false;
}
-
- int state = getLeState();
- if (state == BluetoothAdapter.STATE_ON || state == BluetoothAdapter.STATE_BLE_ON) {
- String packageName = ActivityThread.currentPackageName();
- if (DBG) {
- Log.d(TAG, "disableBLE(): de-registering " + packageName);
- }
- try {
- mManagerService.updateBleAppCount(mToken, false, packageName);
- } catch (RemoteException e) {
- Log.e(TAG, "", e);
- }
- return true;
- }
-
- if (DBG) {
- Log.d(TAG, "disableBLE(): Already disabled");
+ String packageName = ActivityThread.currentPackageName();
+ try {
+ return mManagerService.disableBle(packageName, mToken);
+ } catch (RemoteException e) {
+ Log.e(TAG, "", e);
}
return false;
}
@@ -973,20 +961,9 @@
if (!isBleScanAlwaysAvailable()) {
return false;
}
-
+ String packageName = ActivityThread.currentPackageName();
try {
- String packageName = ActivityThread.currentPackageName();
- mManagerService.updateBleAppCount(mToken, true, packageName);
- if (isLeEnabled()) {
- if (DBG) {
- Log.d(TAG, "enableBLE(): Bluetooth already enabled");
- }
- return true;
- }
- if (DBG) {
- Log.d(TAG, "enableBLE(): Calling enable");
- }
- return mManagerService.enable(packageName);
+ return mManagerService.enableBle(packageName, mToken);
} catch (RemoteException e) {
Log.e(TAG, "", e);
}
diff --git a/core/java/android/content/Context.java b/core/java/android/content/Context.java
index b79965e..3ed585c 100644
--- a/core/java/android/content/Context.java
+++ b/core/java/android/content/Context.java
@@ -3321,7 +3321,7 @@
TELEPHONY_SUBSCRIPTION_SERVICE,
CARRIER_CONFIG_SERVICE,
EUICC_SERVICE,
- MMS_SERVICE,
+ //@hide: MMS_SERVICE,
TELECOM_SERVICE,
CLIPBOARD_SERVICE,
INPUT_METHOD_SERVICE,
@@ -4182,6 +4182,7 @@
*
* @see #getSystemService(String)
* @see android.telephony.MmsManager
+ * @hide
*/
public static final String MMS_SERVICE = "mms";
diff --git a/core/java/android/content/pm/PackageManager.java b/core/java/android/content/pm/PackageManager.java
index 66f9ac0..a2a5469 100644
--- a/core/java/android/content/pm/PackageManager.java
+++ b/core/java/android/content/pm/PackageManager.java
@@ -548,7 +548,6 @@
* Internal {@link PackageInfo} flag used to indicate that a package is a hidden system app.
* @hide
*/
- @SystemApi
public static final int MATCH_HIDDEN_UNTIL_INSTALLED_COMPONENTS = 0x20000000;
/**
diff --git a/core/java/android/net/ConnectivityDiagnosticsManager.java b/core/java/android/net/ConnectivityDiagnosticsManager.java
index 6f0a4f9..9086d49 100644
--- a/core/java/android/net/ConnectivityDiagnosticsManager.java
+++ b/core/java/android/net/ConnectivityDiagnosticsManager.java
@@ -659,7 +659,8 @@
public abstract static class ConnectivityDiagnosticsCallback {
/**
* Called when the platform completes a data connectivity check. This will also be invoked
- * upon registration with the latest report.
+ * immediately upon registration for each network matching the request with the latest
+ * report, if a report has already been generated for that network.
*
* <p>The Network specified in the ConnectivityReport may not be active any more when this
* method is invoked.
diff --git a/core/java/android/net/ConnectivityManager.java b/core/java/android/net/ConnectivityManager.java
index 0f48ac2..6892a94 100644
--- a/core/java/android/net/ConnectivityManager.java
+++ b/core/java/android/net/ConnectivityManager.java
@@ -705,6 +705,36 @@
@Deprecated
public static final int TYPE_TEST = 18; // TODO: Remove this once NetworkTypes are unused.
+ /**
+ * @deprecated Use {@link NetworkCapabilities} instead.
+ * @hide
+ */
+ @Deprecated
+ @Retention(RetentionPolicy.SOURCE)
+ @IntDef(prefix = { "TYPE_" }, value = {
+ TYPE_NONE,
+ TYPE_MOBILE,
+ TYPE_WIFI,
+ TYPE_MOBILE_MMS,
+ TYPE_MOBILE_SUPL,
+ TYPE_MOBILE_DUN,
+ TYPE_MOBILE_HIPRI,
+ TYPE_WIMAX,
+ TYPE_BLUETOOTH,
+ TYPE_DUMMY,
+ TYPE_ETHERNET,
+ TYPE_MOBILE_FOTA,
+ TYPE_MOBILE_IMS,
+ TYPE_MOBILE_CBS,
+ TYPE_WIFI_P2P,
+ TYPE_MOBILE_IA,
+ TYPE_MOBILE_EMERGENCY,
+ TYPE_PROXY,
+ TYPE_VPN,
+ TYPE_TEST
+ })
+ public @interface LegacyNetworkType {}
+
// Deprecated constants for return values of startUsingNetworkFeature. They used to live
// in com.android.internal.telephony.PhoneConstants until they were made inaccessible.
private static final int DEPRECATED_PHONE_CONSTANT_APN_ALREADY_ACTIVE = 0;
diff --git a/core/java/android/net/Ikev2VpnProfile.java b/core/java/android/net/Ikev2VpnProfile.java
index f19a341..81d03f0 100644
--- a/core/java/android/net/Ikev2VpnProfile.java
+++ b/core/java/android/net/Ikev2VpnProfile.java
@@ -562,7 +562,7 @@
@NonNull private List<String> mAllowedAlgorithms = new ArrayList<>();
private boolean mIsBypassable = false;
private boolean mIsMetered = true;
- private int mMaxMtu = 1360;
+ private int mMaxMtu = PlatformVpnProfile.MAX_MTU_DEFAULT;
/**
* Creates a new builder with the basic parameters of an IKEv2/IPsec VPN.
diff --git a/core/java/android/net/InvalidPacketException.java b/core/java/android/net/InvalidPacketException.java
index 909998d..b3b0f11 100644
--- a/core/java/android/net/InvalidPacketException.java
+++ b/core/java/android/net/InvalidPacketException.java
@@ -28,7 +28,7 @@
*/
@SystemApi
public class InvalidPacketException extends Exception {
- public final int error;
+ private final int mError;
// Must match SocketKeepalive#ERROR_INVALID_IP_ADDRESS.
/** Invalid IP address. */
@@ -56,6 +56,11 @@
* See the error code for details.
*/
public InvalidPacketException(@ErrorCode final int error) {
- this.error = error;
+ this.mError = error;
+ }
+
+ /** Get error code. */
+ public int getError() {
+ return mError;
}
}
diff --git a/core/java/android/net/KeepalivePacketData.java b/core/java/android/net/KeepalivePacketData.java
index 6c0ba2f..e21cb44 100644
--- a/core/java/android/net/KeepalivePacketData.java
+++ b/core/java/android/net/KeepalivePacketData.java
@@ -19,6 +19,7 @@
import static android.net.InvalidPacketException.ERROR_INVALID_IP_ADDRESS;
import static android.net.InvalidPacketException.ERROR_INVALID_PORT;
+import android.annotation.IntRange;
import android.annotation.NonNull;
import android.annotation.SystemApi;
import android.net.util.IpUtils;
@@ -37,17 +38,17 @@
/** Source IP address */
@NonNull
- public final InetAddress srcAddress;
+ private final InetAddress mSrcAddress;
/** Destination IP address */
@NonNull
- public final InetAddress dstAddress;
+ private final InetAddress mDstAddress;
/** Source port */
- public final int srcPort;
+ private final int mSrcPort;
/** Destination port */
- public final int dstPort;
+ private final int mDstPort;
/** Packet data. A raw byte string of packet data, not including the link-layer header. */
private final byte[] mPacket;
@@ -60,13 +61,14 @@
/**
* A holding class for data necessary to build a keepalive packet.
*/
- protected KeepalivePacketData(@NonNull InetAddress srcAddress, int srcPort,
- @NonNull InetAddress dstAddress, int dstPort,
- @NonNull byte[] data) throws InvalidPacketException {
- this.srcAddress = srcAddress;
- this.dstAddress = dstAddress;
- this.srcPort = srcPort;
- this.dstPort = dstPort;
+ protected KeepalivePacketData(@NonNull InetAddress srcAddress,
+ @IntRange(from = 0, to = 65535) int srcPort, @NonNull InetAddress dstAddress,
+ @IntRange(from = 0, to = 65535) int dstPort,
+ @NonNull byte[] data) throws InvalidPacketException {
+ this.mSrcAddress = srcAddress;
+ this.mDstAddress = dstAddress;
+ this.mSrcPort = srcPort;
+ this.mDstPort = dstPort;
this.mPacket = data;
// Check we have two IP addresses of the same family.
@@ -83,6 +85,31 @@
}
}
+ /** Get source IP address. */
+ @NonNull
+ public InetAddress getSrcAddress() {
+ return mSrcAddress;
+ }
+
+ /** Get destination IP address. */
+ @NonNull
+ public InetAddress getDstAddress() {
+ return mDstAddress;
+ }
+
+ /** Get source port number. */
+ public int getSrcPort() {
+ return mSrcPort;
+ }
+
+ /** Get destination port number. */
+ public int getDstPort() {
+ return mDstPort;
+ }
+
+ /**
+ * Returns a byte array of the given packet data.
+ */
@NonNull
public byte[] getPacket() {
return mPacket.clone();
diff --git a/core/java/android/net/NattKeepalivePacketData.java b/core/java/android/net/NattKeepalivePacketData.java
index 29da495..22288b6 100644
--- a/core/java/android/net/NattKeepalivePacketData.java
+++ b/core/java/android/net/NattKeepalivePacketData.java
@@ -94,10 +94,10 @@
/** Write to parcel */
public void writeToParcel(@NonNull Parcel out, int flags) {
- out.writeString(srcAddress.getHostAddress());
- out.writeString(dstAddress.getHostAddress());
- out.writeInt(srcPort);
- out.writeInt(dstPort);
+ out.writeString(getSrcAddress().getHostAddress());
+ out.writeString(getDstAddress().getHostAddress());
+ out.writeInt(getSrcPort());
+ out.writeInt(getDstPort());
}
/** Parcelable Creator */
@@ -115,7 +115,7 @@
dstAddress, dstPort);
} catch (InvalidPacketException e) {
throw new IllegalArgumentException(
- "Invalid NAT-T keepalive data: " + e.error);
+ "Invalid NAT-T keepalive data: " + e.getError());
}
}
@@ -128,14 +128,16 @@
public boolean equals(@Nullable final Object o) {
if (!(o instanceof NattKeepalivePacketData)) return false;
final NattKeepalivePacketData other = (NattKeepalivePacketData) o;
- return this.srcAddress.equals(other.srcAddress)
- && this.dstAddress.equals(other.dstAddress)
- && this.srcPort == other.srcPort
- && this.dstPort == other.dstPort;
+ final InetAddress srcAddress = getSrcAddress();
+ final InetAddress dstAddress = getDstAddress();
+ return srcAddress.equals(other.getSrcAddress())
+ && dstAddress.equals(other.getDstAddress())
+ && getSrcPort() == other.getSrcPort()
+ && getDstPort() == other.getDstPort();
}
@Override
public int hashCode() {
- return Objects.hash(srcAddress, dstAddress, srcPort, dstPort);
+ return Objects.hash(getSrcAddress(), getDstAddress(), getSrcPort(), getDstPort());
}
}
diff --git a/core/java/android/net/NetworkAgent.java b/core/java/android/net/NetworkAgent.java
index 5c754a1..8119df9 100644
--- a/core/java/android/net/NetworkAgent.java
+++ b/core/java/android/net/NetworkAgent.java
@@ -16,6 +16,8 @@
package android.net;
+import android.annotation.IntDef;
+import android.annotation.IntRange;
import android.annotation.NonNull;
import android.annotation.Nullable;
import android.annotation.SystemApi;
@@ -32,18 +34,52 @@
import com.android.internal.util.AsyncChannel;
import com.android.internal.util.Protocol;
+import java.lang.annotation.Retention;
+import java.lang.annotation.RetentionPolicy;
import java.util.ArrayList;
import java.util.Objects;
import java.util.concurrent.atomic.AtomicBoolean;
/**
- * A Utility class for handling for communicating between bearer-specific
+ * A utility class for handling for communicating between bearer-specific
* code and ConnectivityService.
*
+ * An agent manages the life cycle of a network. A network starts its
+ * life cycle when {@link register} is called on NetworkAgent. The network
+ * is then connecting. When full L3 connectivity has been established,
+ * the agent shoud call {@link setConnected} to inform the system that
+ * this network is ready to use. When the network disconnects its life
+ * ends and the agent should call {@link unregister}, at which point the
+ * system will clean up and free resources.
+ * Any reconnection becomes a new logical network, so after a network
+ * is disconnected the agent cannot be used any more. Network providers
+ * should create a new NetworkAgent instance to handle new connections.
+ *
* A bearer may have more than one NetworkAgent if it can simultaneously
* support separate networks (IMS / Internet / MMS Apns on cellular, or
* perhaps connections with different SSID or P2P for Wi-Fi).
*
+ * This class supports methods to start and stop sending keepalive packets.
+ * Keepalive packets are typically sent at periodic intervals over a network
+ * with NAT when there is no other traffic to avoid the network forcefully
+ * closing the connection. NetworkAgents that manage technologies that
+ * have hardware support for keepalive should implement the related
+ * methods to save battery life. NetworkAgent that cannot get support
+ * without waking up the CPU should not, as this would be prohibitive in
+ * terms of battery - these agents should simply not override the related
+ * methods, which results in the implementation returning
+ * {@link SocketKeepalive.ERROR_UNSUPPORTED} as appropriate.
+ *
+ * Keepalive packets need to be sent at relatively frequent intervals
+ * (a few seconds to a few minutes). As the contents of keepalive packets
+ * depend on the current network status, hardware needs to be configured
+ * to send them and has a limited amount of memory to do so. The HAL
+ * formalizes this as slots that an implementation can configure to send
+ * the correct packets. Devices typically have a small number of slots
+ * per radio technology, and the specific number of slots for each
+ * technology is specified in configuration files.
+ * {@see SocketKeepalive} for details.
+ *
* @hide
*/
@SystemApi
@@ -65,7 +101,7 @@
private final String LOG_TAG;
private static final boolean DBG = true;
private static final boolean VDBG = false;
- private final ArrayList<Message>mPreConnectedQueue = new ArrayList<Message>();
+ private final ArrayList<Message> mPreConnectedQueue = new ArrayList<Message>();
private volatile long mLastBwRefreshTime = 0;
private static final long BW_REFRESH_MIN_WIN_MS = 500;
private boolean mBandwidthUpdateScheduled = false;
@@ -74,6 +110,8 @@
// into the internal API of ConnectivityService.
@NonNull
private NetworkInfo mNetworkInfo;
+ @NonNull
+ private final Object mRegisterLock = new Object();
/**
* The ID of the {@link NetworkProvider} that created this object, or
@@ -158,6 +196,14 @@
*/
public static final int VALIDATION_STATUS_NOT_VALID = 2;
+ /** @hide */
+ @Retention(RetentionPolicy.SOURCE)
+ @IntDef(prefix = { "VALIDATION_STATUS_" }, value = {
+ VALIDATION_STATUS_VALID,
+ VALIDATION_STATUS_NOT_VALID
+ })
+ public @interface ValidationStatus {}
+
// TODO: remove.
/** @hide */
public static final int VALID_NETWORK = 1;
@@ -202,7 +248,7 @@
* Sent by ConnectivityService to the NetworkAgent to request that the specified packet be sent
* periodically on the given interval.
*
- * arg1 = the slot number of the keepalive to start
+ * arg1 = the hardware slot number of the keepalive to start
* arg2 = interval in seconds
* obj = KeepalivePacketData object describing the data to be sent
*
@@ -214,7 +260,7 @@
/**
* Requests that the specified keepalive packet be stopped.
*
- * arg1 = slot number of the keepalive to stop.
+ * arg1 = hardware slot number of the keepalive to stop.
*
* Also used internally by ConnectivityService / KeepaliveTracker, with different semantics.
* @hide
@@ -229,7 +275,7 @@
* This is also sent by KeepaliveTracker to the app's {@link SocketKeepalive},
* so that the app's {@link SocketKeepalive.Callback} methods can be called.
*
- * arg1 = slot number of the keepalive
+ * arg1 = hardware slot number of the keepalive
* arg2 = error code
* @hide
*/
@@ -259,7 +305,7 @@
* remote site will send ACK packets in response to the keepalive packets, the firmware also
* needs to be configured to properly filter the ACKs to prevent the system from waking up.
* This does not happen with UDP, so this message is TCP-specific.
- * arg1 = slot number of the keepalive to filter for.
+ * arg1 = hardware slot number of the keepalive to filter for.
* obj = the keepalive packet to send repeatedly.
* @hide
*/
@@ -268,7 +314,7 @@
/**
* Sent by the KeepaliveTracker to NetworkAgent to remove a packet filter. See
* {@link #CMD_ADD_KEEPALIVE_PACKET_FILTER}.
- * arg1 = slot number of the keepalive packet filter to remove.
+ * arg1 = hardware slot number of the keepalive packet filter to remove.
* @hide
*/
public static final int CMD_REMOVE_KEEPALIVE_PACKET_FILTER = BASE + 17;
@@ -441,7 +487,15 @@
+ (msg.arg1 == VALID_NETWORK ? "VALID, " : "INVALID, ")
+ redirectUrl);
}
- onValidationStatus(msg.arg1 /* status */, redirectUrl);
+ Uri uri = null;
+ try {
+ if (null != redirectUrl) {
+ uri = Uri.parse(redirectUrl);
+ }
+ } catch (Exception e) {
+ Log.wtf(LOG_TAG, "Surprising URI : " + redirectUrl, e);
+ }
+ onValidationStatus(msg.arg1 /* status */, uri);
break;
}
case CMD_SAVE_ACCEPT_UNVALIDATED: {
@@ -489,19 +543,29 @@
/**
* Register this network agent with ConnectivityService.
+ *
+ * This method can only be called once per network agent.
+ *
* @return the Network associated with this network agent (which can also be obtained later
* by calling getNetwork() on this agent).
+ * @throws IllegalStateException thrown by the system server if this network agent is
+ * already registered.
*/
@NonNull
public Network register() {
if (VDBG) log("Registering NetworkAgent");
final ConnectivityManager cm = (ConnectivityManager) mInitialConfiguration.context
.getSystemService(Context.CONNECTIVITY_SERVICE);
- mNetwork = cm.registerNetworkAgent(new Messenger(mHandler),
- new NetworkInfo(mInitialConfiguration.info),
- mInitialConfiguration.properties, mInitialConfiguration.capabilities,
- mInitialConfiguration.score, mInitialConfiguration.config, providerId);
- mInitialConfiguration = null; // All this memory can now be GC'd
+ synchronized (mRegisterLock) {
+ if (mNetwork != null) {
+ throw new IllegalStateException("Agent already registered");
+ }
+ mNetwork = cm.registerNetworkAgent(new Messenger(mHandler),
+ new NetworkInfo(mInitialConfiguration.info),
+ mInitialConfiguration.properties, mInitialConfiguration.capabilities,
+ mInitialConfiguration.score, mInitialConfiguration.config, providerId);
+ mInitialConfiguration = null; // All this memory can now be GC'd
+ }
return mNetwork;
}
@@ -544,13 +608,14 @@
* Must be called by the agent when the network's {@link LinkProperties} change.
* @param linkProperties the new LinkProperties.
*/
- public void sendLinkProperties(@NonNull LinkProperties linkProperties) {
+ public final void sendLinkProperties(@NonNull LinkProperties linkProperties) {
Objects.requireNonNull(linkProperties);
queueOrSendMessage(EVENT_NETWORK_PROPERTIES_CHANGED, new LinkProperties(linkProperties));
}
/**
* Inform ConnectivityService that this agent has now connected.
+ * Call {@link #unregister} to disconnect.
*/
public void setConnected() {
if (mIsLegacy) {
@@ -569,8 +634,7 @@
*/
public void unregister() {
if (mIsLegacy) {
- throw new UnsupportedOperationException(
- "Legacy agents can't call unregister.");
+ throw new UnsupportedOperationException("Legacy agents can't call unregister.");
}
mNetworkInfo.setDetailedState(NetworkInfo.DetailedState.DISCONNECTED, null, null);
queueOrSendMessage(EVENT_NETWORK_INFO_CHANGED, mNetworkInfo);
@@ -626,7 +690,7 @@
* @hide TODO: expose something better.
*/
@UnsupportedAppUsage(maxTargetSdk = Build.VERSION_CODES.P, trackingBug = 115609023)
- public void sendNetworkInfo(NetworkInfo networkInfo) {
+ public final void sendNetworkInfo(NetworkInfo networkInfo) {
if (!mIsLegacy) {
throw new UnsupportedOperationException("Only legacy agents can call sendNetworkInfo.");
}
@@ -637,7 +701,7 @@
* Must be called by the agent when the network's {@link NetworkCapabilities} change.
* @param networkCapabilities the new NetworkCapabilities.
*/
- public void sendNetworkCapabilities(@NonNull NetworkCapabilities networkCapabilities) {
+ public final void sendNetworkCapabilities(@NonNull NetworkCapabilities networkCapabilities) {
Objects.requireNonNull(networkCapabilities);
mBandwidthUpdatePending.set(false);
mLastBwRefreshTime = System.currentTimeMillis();
@@ -647,9 +711,10 @@
/**
* Must be called by the agent to update the score of this network.
- * @param score the new score.
+ *
+ * @param score the new score, between 0 and 99.
*/
- public void sendNetworkScore(int score) {
+ public final void sendNetworkScore(@IntRange(from = 0, to = 99) int score) {
if (score < 0) {
throw new IllegalArgumentException("Score must be >= 0");
}
@@ -737,11 +802,11 @@
* subsequent attempts to validate connectivity that fail.
*
* @param status one of {@code VALIDATION_STATUS_VALID} or {@code VALIDATION_STATUS_NOT_VALID}.
- * @param redirectUrl If Internet connectivity is being redirected (e.g., on a captive portal),
+ * @param redirectUri If Internet connectivity is being redirected (e.g., on a captive portal),
* this is the destination the probes are being redirected to, otherwise {@code null}.
*/
- public void onValidationStatus(int status, @Nullable String redirectUrl) {
- networkStatus(status, redirectUrl);
+ public void onValidationStatus(@ValidationStatus int status, @Nullable Uri redirectUri) {
+ networkStatus(status, redirectUri.toString());
}
/** @hide TODO delete once subclasses have moved to onValidationStatus */
protected void networkStatus(int status, String redirectUrl) {
@@ -770,7 +835,12 @@
* @param intervalSeconds the interval between packets
* @param packet the packet to send.
*/
- public void onStartSocketKeepalive(int slot, int intervalSeconds,
+ // seconds is from SocketKeepalive.MIN_INTERVAL_SEC to MAX_INTERVAL_SEC, but these should
+ // not be exposed as constants because they may change in the future (API guideline 4.8)
+ // and should have getters if exposed at all. Getters can't be used in the annotation,
+ // so the values unfortunately need to be copied.
+ public void onStartSocketKeepalive(int slot,
+ @IntRange(from = 10, to = 3600) int intervalSeconds,
@NonNull KeepalivePacketData packet) {
Message msg = mHandler.obtainMessage(CMD_START_SOCKET_KEEPALIVE, slot, intervalSeconds,
packet);
@@ -801,9 +871,11 @@
* Must be called by the agent when a socket keepalive event occurs.
*
* @param slot the hardware slot on which the event occurred.
- * @param event the event that occurred.
+ * @param event the event that occurred, as one of the SocketKeepalive.ERROR_*
+ * or SocketKeepalive.SUCCESS constants.
*/
- public void sendSocketKeepaliveEvent(int slot, int event) {
+ public final void sendSocketKeepaliveEvent(int slot,
+ @SocketKeepalive.KeepaliveEvent int event) {
queueOrSendMessage(EVENT_SOCKET_KEEPALIVE, slot, event);
}
/** @hide TODO delete once callers have moved to sendSocketKeepaliveEvent */
@@ -845,9 +917,18 @@
}
/**
- * Called by ConnectivityService to inform this network transport of signal strength thresholds
+ * Called by ConnectivityService to inform this network agent of signal strength thresholds
* that when crossed should trigger a system wakeup and a NetworkCapabilities update.
*
+ * When the system updates the list of thresholds that should wake up the CPU for a
+ * given agent it will call this method on the agent. The agent that implement this
+ * should implement it in hardware so as to ensure the CPU will be woken up on breach.
+ * Agents are expected to react to a breach by sending an updated NetworkCapabilities
+ * object with the appropriate signal strength to sendNetworkCapabilities.
+ *
+ * The specific units are bearer-dependent. See details on the units and requests in
+ * {@link NetworkCapabilities.Builder#setSignalStrength}.
+ *
* @param thresholds the array of thresholds that should trigger wakeups.
*/
public void onSignalStrengthThresholdsUpdated(@NonNull int[] thresholds) {
diff --git a/core/java/android/net/NetworkAgentConfig.java b/core/java/android/net/NetworkAgentConfig.java
index ca9328a..fee868a 100644
--- a/core/java/android/net/NetworkAgentConfig.java
+++ b/core/java/android/net/NetworkAgentConfig.java
@@ -155,6 +155,7 @@
/**
* @return the legacy type
*/
+ @ConnectivityManager.LegacyNetworkType
public int getLegacyType() {
return legacyType;
}
@@ -206,7 +207,7 @@
/**
* Builder class to facilitate constructing {@link NetworkAgentConfig} objects.
*/
- public static class Builder {
+ public static final class Builder {
private final NetworkAgentConfig mConfig = new NetworkAgentConfig();
/**
diff --git a/core/java/android/net/NetworkCapabilities.java b/core/java/android/net/NetworkCapabilities.java
index 64e9350..995cb72 100644
--- a/core/java/android/net/NetworkCapabilities.java
+++ b/core/java/android/net/NetworkCapabilities.java
@@ -16,9 +16,12 @@
package android.net;
+import static com.android.internal.annotations.VisibleForTesting.Visibility.PRIVATE;
+
import android.annotation.IntDef;
import android.annotation.NonNull;
import android.annotation.Nullable;
+import android.annotation.RequiresPermission;
import android.annotation.SystemApi;
import android.annotation.TestApi;
import android.compat.annotation.UnsupportedAppUsage;
@@ -32,6 +35,7 @@
import android.util.proto.ProtoOutputStream;
import com.android.internal.annotations.VisibleForTesting;
+import com.android.internal.util.ArrayUtils;
import com.android.internal.util.BitUtils;
import com.android.internal.util.Preconditions;
@@ -86,6 +90,7 @@
/**
* Completely clears the contents of this object, removing even the capabilities that are set
* by default when the object is constructed.
+ * @hide
*/
public void clearAll() {
mNetworkCapabilities = mTransportTypes = mUnwantedNetworkCapabilities = 0;
@@ -115,7 +120,7 @@
mTransportInfo = nc.mTransportInfo;
mSignalStrength = nc.mSignalStrength;
setUids(nc.mUids); // Will make the defensive copy
- setAdministratorUids(nc.mAdministratorUids);
+ setAdministratorUids(nc.getAdministratorUids());
mOwnerUid = nc.mOwnerUid;
mUnwantedNetworkCapabilities = nc.mUnwantedNetworkCapabilities;
mSSID = nc.mSSID;
@@ -427,11 +432,12 @@
/**
* Adds the given capability to this {@code NetworkCapability} instance.
- * Multiple capabilities may be applied sequentially. Note that when searching
- * for a network to satisfy a request, all capabilities requested must be satisfied.
+ * Note that when searching for a network to satisfy a request, all capabilities
+ * requested must be satisfied.
*
* @param capability the capability to be added.
* @return This NetworkCapabilities instance, to facilitate chaining.
+ * @hide
*/
public @NonNull NetworkCapabilities addCapability(@NetCapability int capability) {
// If the given capability was previously added to the list of unwanted capabilities
@@ -446,9 +452,9 @@
/**
* Adds the given capability to the list of unwanted capabilities of this
- * {@code NetworkCapability} instance. Multiple unwanted capabilities may be applied
- * sequentially. Note that when searching for a network to satisfy a request, the network
- * must not contain any capability from unwanted capability list.
+ * {@code NetworkCapability} instance. Note that when searching for a network to
+ * satisfy a request, the network must not contain any capability from unwanted capability
+ * list.
* <p>
* If the capability was previously added to the list of required capabilities (for
* example, it was there by default or added using {@link #addCapability(int)} method), then
@@ -468,6 +474,7 @@
*
* @param capability the capability to be removed.
* @return This NetworkCapabilities instance, to facilitate chaining.
+ * @hide
*/
public @NonNull NetworkCapabilities removeCapability(@NetCapability int capability) {
// Note that this method removes capabilities that were added via addCapability(int),
@@ -482,7 +489,7 @@
/**
* Sets (or clears) the given capability on this {@link NetworkCapabilities}
* instance.
- *
+ * @hide
*/
public @NonNull NetworkCapabilities setCapability(@NetCapability int capability,
boolean value) {
@@ -757,7 +764,7 @@
/**
* Adds the given transport type to this {@code NetworkCapability} instance.
- * Multiple transports may be applied sequentially. Note that when searching
+ * Multiple transports may be applied. Note that when searching
* for a network to satisfy a request, any listed in the request will satisfy the request.
* For example {@code TRANSPORT_WIFI} and {@code TRANSPORT_ETHERNET} added to a
* {@code NetworkCapabilities} would cause either a Wi-Fi network or an Ethernet network
@@ -766,6 +773,7 @@
*
* @param transportType the transport type to be added.
* @return This NetworkCapabilities instance, to facilitate chaining.
+ * @hide
*/
public @NonNull NetworkCapabilities addTransportType(@Transport int transportType) {
checkValidTransportType(transportType);
@@ -878,6 +886,7 @@
/**
* Set the UID of the owner app.
+ * @hide
*/
public @NonNull NetworkCapabilities setOwnerUid(final int uid) {
mOwnerUid = uid;
@@ -895,6 +904,8 @@
* <li>The user's location toggle is on
* </ol>
*
+ * Instances of NetworkCapabilities sent to apps without the appropriate permissions will
+ * have this field cleared out.
*/
public int getOwnerUid() {
return mOwnerUid;
@@ -910,18 +921,22 @@
* <p>For NetworkCapability instances being sent from the System Server, this value MUST be
* empty unless the destination is 1) the System Server, or 2) Telephony. In either case, the
* receiving entity must have the ACCESS_FINE_LOCATION permission and target R+.
+ *
+ * <p>When received from an app in a NetworkRequest this is always cleared out by the system
+ * server. This field is never used for matching NetworkRequests to NetworkAgents.
*/
- private int[] mAdministratorUids = new int[0];
+ @NonNull private int[] mAdministratorUids = new int[0];
/**
* Sets the int[] of UIDs that are administrators of this network.
*
* <p>UIDs included in administratorUids gain administrator privileges over this Network.
* Examples of UIDs that should be included in administratorUids are:
+ *
* <ul>
- * <li>Carrier apps with privileges for the relevant subscription
- * <li>Active VPN apps
- * <li>Other application groups with a particular Network-related role
+ * <li>Carrier apps with privileges for the relevant subscription
+ * <li>Active VPN apps
+ * <li>Other application groups with a particular Network-related role
* </ul>
*
* <p>In general, user-supplied networks (such as WiFi networks) do not have an administrator.
@@ -929,29 +944,78 @@
* <p>An app is granted owner privileges over Networks that it supplies. The owner UID MUST
* always be included in administratorUids.
*
+ * <p>The administrator UIDs are set by network agents.
+ *
* @param administratorUids the UIDs to be set as administrators of this Network.
+ * @throws IllegalArgumentException if duplicate UIDs are contained in administratorUids
+ * @see #mAdministratorUids
* @hide
*/
@NonNull
- @SystemApi
public NetworkCapabilities setAdministratorUids(@NonNull final int[] administratorUids) {
mAdministratorUids = Arrays.copyOf(administratorUids, administratorUids.length);
+ Arrays.sort(mAdministratorUids);
+ for (int i = 0; i < mAdministratorUids.length - 1; i++) {
+ if (mAdministratorUids[i] >= mAdministratorUids[i + 1]) {
+ throw new IllegalArgumentException("All administrator UIDs must be unique");
+ }
+ }
return this;
}
/**
* Retrieves the UIDs that are administrators of this Network.
*
+ * <p>This is only populated in NetworkCapabilities objects that come from network agents for
+ * networks that are managed by specific apps on the system, such as carrier privileged apps or
+ * wifi suggestion apps. This will include the network owner.
+ *
* @return the int[] of UIDs that are administrators of this Network
+ * @see #mAdministratorUids
* @hide
*/
@NonNull
@SystemApi
+ @TestApi
public int[] getAdministratorUids() {
return Arrays.copyOf(mAdministratorUids, mAdministratorUids.length);
}
/**
+ * Tests if the set of administrator UIDs of this network is the same as that of the passed one.
+ *
+ * <p>The administrator UIDs must be in sorted order.
+ *
+ * <p>nc is assumed non-null. Else, NPE.
+ *
+ * @hide
+ */
+ @VisibleForTesting(visibility = PRIVATE)
+ public boolean equalsAdministratorUids(@NonNull final NetworkCapabilities nc) {
+ return Arrays.equals(mAdministratorUids, nc.mAdministratorUids);
+ }
+
+ /**
+ * Combine the administrator UIDs of the capabilities.
+ *
+ * <p>This is only legal if either of the administrators lists are empty, or if they are equal.
+ * Combining administrator UIDs is only possible for combining non-overlapping sets of UIDs.
+ *
+ * <p>If both administrator lists are non-empty but not equal, they conflict with each other. In
+ * this case, it would not make sense to add them together.
+ */
+ private void combineAdministratorUids(@NonNull final NetworkCapabilities nc) {
+ if (nc.mAdministratorUids.length == 0) return;
+ if (mAdministratorUids.length == 0) {
+ mAdministratorUids = Arrays.copyOf(nc.mAdministratorUids, nc.mAdministratorUids.length);
+ return;
+ }
+ if (!equalsAdministratorUids(nc)) {
+ throw new IllegalStateException("Can't combine two different administrator UID lists");
+ }
+ }
+
+ /**
* Value indicating that link bandwidth is unspecified.
* @hide
*/
@@ -969,15 +1033,10 @@
* Sets the upstream bandwidth for this network in Kbps. This always only refers to
* the estimated first hop transport bandwidth.
* <p>
- * Note that when used to request a network, this specifies the minimum acceptable.
- * When received as the state of an existing network this specifies the typical
- * first hop bandwidth expected. This is never measured, but rather is inferred
- * from technology type and other link parameters. It could be used to differentiate
- * between very slow 1xRTT cellular links and other faster networks or even between
- * 802.11b vs 802.11AC wifi technologies. It should not be used to differentiate between
- * fast backhauls and slow backhauls.
+ * {@see Builder#setLinkUpstreamBandwidthKbps}
*
* @param upKbps the estimated first hop upstream (device to network) bandwidth.
+ * @hide
*/
public @NonNull NetworkCapabilities setLinkUpstreamBandwidthKbps(int upKbps) {
mLinkUpBandwidthKbps = upKbps;
@@ -998,15 +1057,10 @@
* Sets the downstream bandwidth for this network in Kbps. This always only refers to
* the estimated first hop transport bandwidth.
* <p>
- * Note that when used to request a network, this specifies the minimum acceptable.
- * When received as the state of an existing network this specifies the typical
- * first hop bandwidth expected. This is never measured, but rather is inferred
- * from technology type and other link parameters. It could be used to differentiate
- * between very slow 1xRTT cellular links and other faster networks or even between
- * 802.11b vs 802.11AC wifi technologies. It should not be used to differentiate between
- * fast backhauls and slow backhauls.
+ * {@see Builder#setLinkUpstreamBandwidthKbps}
*
* @param downKbps the estimated first hop downstream (network to device) bandwidth.
+ * @hide
*/
public @NonNull NetworkCapabilities setLinkDownstreamBandwidthKbps(int downKbps) {
mLinkDownBandwidthKbps = downKbps;
@@ -1065,6 +1119,7 @@
* @param networkSpecifier A concrete, parcelable framework class that extends
* NetworkSpecifier.
* @return This NetworkCapabilities instance, to facilitate chaining.
+ * @hide
*/
public @NonNull NetworkCapabilities setNetworkSpecifier(
@NonNull NetworkSpecifier networkSpecifier) {
@@ -1086,7 +1141,6 @@
* @return This NetworkCapabilities instance, to facilitate chaining.
* @hide
*/
- @SystemApi
public @NonNull NetworkCapabilities setTransportInfo(@NonNull TransportInfo transportInfo) {
mTransportInfo = transportInfo;
return this;
@@ -1096,7 +1150,7 @@
* 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 or {@code null}. See {@link #setNetworkSpecifier}.
+ * specifier or {@code null}.
*/
public @Nullable NetworkSpecifier getNetworkSpecifier() {
return mNetworkSpecifier;
@@ -1166,6 +1220,7 @@
* effect when requesting a callback.
*
* @param signalStrength the bearer-specific signal strength.
+ * @hide
*/
public @NonNull NetworkCapabilities setSignalStrength(int signalStrength) {
mSignalStrength = signalStrength;
@@ -1392,7 +1447,6 @@
* Sets the SSID of this network.
* @hide
*/
- @SystemApi
public @NonNull NetworkCapabilities setSSID(@Nullable String ssid) {
mSSID = ssid;
return this;
@@ -1403,7 +1457,8 @@
* @hide
*/
@SystemApi
- public @Nullable String getSSID() {
+ @TestApi
+ public @Nullable String getSsid() {
return mSSID;
}
@@ -1455,6 +1510,7 @@
combineUids(nc);
combineSSIDs(nc);
combineRequestor(nc);
+ combineAdministratorUids(nc);
}
/**
@@ -1568,7 +1624,8 @@
&& equalsUids(that)
&& equalsSSID(that)
&& equalsPrivateDnsBroken(that)
- && equalsRequestor(that);
+ && equalsRequestor(that)
+ && equalsAdministratorUids(that);
}
@Override
@@ -1588,7 +1645,8 @@
+ Objects.hashCode(mTransportInfo) * 41
+ Objects.hashCode(mPrivateDnsBroken) * 43
+ Objects.hashCode(mRequestorUid) * 47
- + Objects.hashCode(mRequestorPackageName) * 53;
+ + Objects.hashCode(mRequestorPackageName) * 53
+ + Arrays.hashCode(mAdministratorUids) * 59;
}
@Override
@@ -1609,7 +1667,7 @@
dest.writeArraySet(mUids);
dest.writeString(mSSID);
dest.writeBoolean(mPrivateDnsBroken);
- dest.writeIntArray(mAdministratorUids);
+ dest.writeIntArray(getAdministratorUids());
dest.writeInt(mOwnerUid);
dest.writeInt(mRequestorUid);
dest.writeString(mRequestorPackageName);
@@ -1883,25 +1941,32 @@
}
/**
- * Set the uid of the app making the request.
+ * Set the UID of the app making the request.
*
- * Note: This works only for {@link NetworkAgent} instances. Any capabilities passed in
- * via the public {@link ConnectivityManager} API's will have this field overwritten.
+ * For instances of NetworkCapabilities representing a request, sets the
+ * UID of the app making the request. For a network created by the system,
+ * sets the UID of the only app whose requests can match this network.
+ * This can be set to {@link Process#INVALID_UID} if there is no such app,
+ * or if this instance of NetworkCapabilities is about to be sent to a
+ * party that should not learn about this.
*
* @param uid UID of the app.
* @hide
*/
- @SystemApi
public @NonNull NetworkCapabilities setRequestorUid(int uid) {
mRequestorUid = uid;
return this;
}
/**
- * @return the uid of the app making the request.
+ * Returns the UID of the app making the request.
*
- * Note: This could return {@link Process#INVALID_UID} if the {@link NetworkRequest}
- * object was not obtained from {@link ConnectivityManager}.
+ * For a NetworkRequest being made by an app, contains the app's UID. For a network
+ * created by the system, contains the UID of the only app whose requests can match
+ * this network, or {@link Process#INVALID_UID} if none or if the
+ * caller does not have permission to learn about this.
+ *
+ * @return the uid of the app making the request.
* @hide
*/
public int getRequestorUid() {
@@ -1911,23 +1976,29 @@
/**
* Set the package name of the app making the request.
*
- * Note: This works only for {@link NetworkAgent} instances. Any capabilities passed in
- * via the public {@link ConnectivityManager} API's will have this field overwritten.
+ * For instances of NetworkCapabilities representing a request, sets the
+ * package name of the app making the request. For a network created by the system,
+ * sets the package name of the only app whose requests can match this network.
+ * This can be set to null if there is no such app, or if this instance of
+ * NetworkCapabilities is about to be sent to a party that should not learn about this.
*
* @param packageName package name of the app.
* @hide
*/
- @SystemApi
public @NonNull NetworkCapabilities setRequestorPackageName(@NonNull String packageName) {
mRequestorPackageName = packageName;
return this;
}
/**
- * @return the package name of the app making the request.
+ * Returns the package name of the app making the request.
*
- * Note: This could return {@code null} if the {@link NetworkRequest} object was not obtained
- * from {@link ConnectivityManager}.
+ * For a NetworkRequest being made by an app, contains the app's package name. For a
+ * network created by the system, contains the package name of the only app whose
+ * requests can match this network, or null if none or if the caller does not have
+ * permission to learn about this.
+ *
+ * @return the package name of the app making the request.
* @hide
*/
@Nullable
@@ -1936,9 +2007,9 @@
}
/**
- * Set the uid and package name of the app making the request.
+ * Set the uid and package name of the app causing this network to exist.
*
- * Note: This is intended to be only invoked from within connectivitiy service.
+ * {@see #setRequestorUid} and {@link #setRequestorPackageName}
*
* @param uid UID of the app.
* @param packageName package name of the app.
@@ -1997,4 +2068,316 @@
return mRequestorUid == nc.mRequestorUid
&& TextUtils.equals(mRequestorPackageName, nc.mRequestorPackageName);
}
+
+ /**
+ * Builder class for NetworkCapabilities.
+ *
+ * This class is mainly for for {@link NetworkAgent} instances to use. Many fields in
+ * the built class require holding a signature permission to use - mostly
+ * {@link android.Manifest.permission.NETWORK_FACTORY}, but refer to the specific
+ * description of each setter. As this class lives entirely in app space it does not
+ * enforce these restrictions itself but the system server clears out the relevant
+ * fields when receiving a NetworkCapabilities object from a caller without the
+ * appropriate permission.
+ *
+ * Apps don't use this builder directly. Instead, they use {@link NetworkRequest} via
+ * its builder object.
+ *
+ * @hide
+ */
+ @SystemApi
+ @TestApi
+ public static class Builder {
+ private final NetworkCapabilities mCaps;
+
+ /**
+ * Creates a new Builder to construct NetworkCapabilities objects.
+ */
+ public Builder() {
+ mCaps = new NetworkCapabilities();
+ }
+
+ /**
+ * Creates a new Builder of NetworkCapabilities from an existing instance.
+ */
+ public Builder(@NonNull final NetworkCapabilities nc) {
+ Objects.requireNonNull(nc);
+ mCaps = new NetworkCapabilities(nc);
+ }
+
+ /**
+ * Adds the given transport type.
+ *
+ * Multiple transports may be added. Note that when searching for a network to satisfy a
+ * request, satisfying any of the transports listed in the request will satisfy the request.
+ * For example {@code TRANSPORT_WIFI} and {@code TRANSPORT_ETHERNET} added to a
+ * {@code NetworkCapabilities} would cause either a Wi-Fi network or an Ethernet network
+ * to be selected. This is logically different than
+ * {@code NetworkCapabilities.NET_CAPABILITY_*}.
+ *
+ * @param transportType the transport type to be added or removed.
+ * @return this builder
+ */
+ @NonNull
+ public Builder addTransportType(@Transport int transportType) {
+ checkValidTransportType(transportType);
+ mCaps.addTransportType(transportType);
+ return this;
+ }
+
+ /**
+ * Removes the given transport type.
+ *
+ * {@see #addTransportType}.
+ *
+ * @param transportType the transport type to be added or removed.
+ * @return this builder
+ */
+ @NonNull
+ public Builder removeTransportType(@Transport int transportType) {
+ checkValidTransportType(transportType);
+ mCaps.removeTransportType(transportType);
+ return this;
+ }
+
+ /**
+ * Adds the given capability.
+ *
+ * @param capability the capability
+ * @return this builder
+ */
+ @NonNull
+ public Builder addCapability(@NetCapability final int capability) {
+ mCaps.setCapability(capability, true);
+ return this;
+ }
+
+ /**
+ * Removes the given capability.
+ *
+ * @param capability the capability
+ * @return this builder
+ */
+ @NonNull
+ public Builder removeCapability(@NetCapability final int capability) {
+ mCaps.setCapability(capability, false);
+ return this;
+ }
+
+ /**
+ * Sets the owner UID.
+ *
+ * The default value is {@link Process#INVALID_UID}. Pass this value to reset.
+ *
+ * Note: for security the system will clear out this field when received from a
+ * non-privileged source.
+ *
+ * @param ownerUid the owner UID
+ * @return this builder
+ */
+ @NonNull
+ @RequiresPermission(android.Manifest.permission.NETWORK_FACTORY)
+ public Builder setOwnerUid(final int ownerUid) {
+ mCaps.setOwnerUid(ownerUid);
+ return this;
+ }
+
+ /**
+ * Sets the list of UIDs that are administrators of this network.
+ *
+ * <p>UIDs included in administratorUids gain administrator privileges over this
+ * Network. Examples of UIDs that should be included in administratorUids are:
+ * <ul>
+ * <li>Carrier apps with privileges for the relevant subscription
+ * <li>Active VPN apps
+ * <li>Other application groups with a particular Network-related role
+ * </ul>
+ *
+ * <p>In general, user-supplied networks (such as WiFi networks) do not have
+ * administrators.
+ *
+ * <p>An app is granted owner privileges over Networks that it supplies. The owner
+ * UID MUST always be included in administratorUids.
+ *
+ * The default value is the empty array. Pass an empty array to reset.
+ *
+ * Note: for security the system will clear out this field when received from a
+ * non-privileged source, such as an app using reflection to call this or
+ * mutate the member in the built object.
+ *
+ * @param administratorUids the UIDs to be set as administrators of this Network.
+ * @return this builder
+ */
+ @NonNull
+ @RequiresPermission(android.Manifest.permission.NETWORK_FACTORY)
+ public Builder setAdministratorUids(@NonNull final int[] administratorUids) {
+ Objects.requireNonNull(administratorUids);
+ mCaps.setAdministratorUids(administratorUids);
+ return this;
+ }
+
+ /**
+ * Sets the upstream bandwidth of the link.
+ *
+ * Sets the upstream bandwidth for this network in Kbps. This always only refers to
+ * the estimated first hop transport bandwidth.
+ * <p>
+ * Note that when used to request a network, this specifies the minimum acceptable.
+ * When received as the state of an existing network this specifies the typical
+ * first hop bandwidth expected. This is never measured, but rather is inferred
+ * from technology type and other link parameters. It could be used to differentiate
+ * between very slow 1xRTT cellular links and other faster networks or even between
+ * 802.11b vs 802.11AC wifi technologies. It should not be used to differentiate between
+ * fast backhauls and slow backhauls.
+ *
+ * @param upKbps the estimated first hop upstream (device to network) bandwidth.
+ * @return this builder
+ */
+ @NonNull
+ public Builder setLinkUpstreamBandwidthKbps(final int upKbps) {
+ mCaps.setLinkUpstreamBandwidthKbps(upKbps);
+ return this;
+ }
+
+ /**
+ * Sets the downstream bandwidth for this network in Kbps. This always only refers to
+ * the estimated first hop transport bandwidth.
+ * <p>
+ * Note that when used to request a network, this specifies the minimum acceptable.
+ * When received as the state of an existing network this specifies the typical
+ * first hop bandwidth expected. This is never measured, but rather is inferred
+ * from technology type and other link parameters. It could be used to differentiate
+ * between very slow 1xRTT cellular links and other faster networks or even between
+ * 802.11b vs 802.11AC wifi technologies. It should not be used to differentiate between
+ * fast backhauls and slow backhauls.
+ *
+ * @param downKbps the estimated first hop downstream (network to device) bandwidth.
+ * @return this builder
+ */
+ @NonNull
+ public Builder setLinkDownstreamBandwidthKbps(final int downKbps) {
+ mCaps.setLinkDownstreamBandwidthKbps(downKbps);
+ return this;
+ }
+
+ /**
+ * Sets the optional bearer specific network specifier.
+ * This has no meaning if a single transport is also not specified, so calling
+ * this without a single transport set will generate an exception, as will
+ * subsequently adding or removing transports after this is set.
+ * </p>
+ *
+ * @param specifier a concrete, parcelable framework class that extends NetworkSpecifier,
+ * or null to clear it.
+ * @return this builder
+ */
+ @NonNull
+ public Builder setNetworkSpecifier(@Nullable final NetworkSpecifier specifier) {
+ mCaps.setNetworkSpecifier(specifier);
+ return this;
+ }
+
+ /**
+ * Sets the optional transport specific information.
+ *
+ * @param info A concrete, parcelable framework class that extends {@link TransportInfo},
+ * or null to clear it.
+ * @return this builder
+ */
+ @NonNull
+ public Builder setTransportInfo(@Nullable final TransportInfo info) {
+ mCaps.setTransportInfo(info);
+ return this;
+ }
+
+ /**
+ * Sets the signal strength. This is a signed integer, with higher values indicating a
+ * stronger signal. The exact units are bearer-dependent. For example, Wi-Fi uses the
+ * same RSSI units reported by wifi code.
+ * <p>
+ * Note that when used to register a network callback, this specifies the minimum
+ * acceptable signal strength. When received as the state of an existing network it
+ * specifies the current value. A value of code SIGNAL_STRENGTH_UNSPECIFIED} means
+ * no value when received and has no effect when requesting a callback.
+ *
+ * Note: for security the system will throw if it receives a NetworkRequest where
+ * the underlying NetworkCapabilities has this member set from a source that does
+ * not hold the {@link android.Manifest.permission.NETWORK_SIGNAL_STRENGTH_WAKEUP}
+ * permission. Apps with this permission can use this indirectly through
+ * {@link android.net.NetworkRequest}.
+ *
+ * @param signalStrength the bearer-specific signal strength.
+ * @return this builder
+ */
+ @NonNull
+ @RequiresPermission(android.Manifest.permission.NETWORK_SIGNAL_STRENGTH_WAKEUP)
+ public Builder setSignalStrength(final int signalStrength) {
+ mCaps.setSignalStrength(signalStrength);
+ return this;
+ }
+
+ /**
+ * Sets the SSID of this network.
+ *
+ * Note: for security the system will clear out this field when received from a
+ * non-privileged source, like an app using reflection to set this.
+ *
+ * @param ssid the SSID, or null to clear it.
+ * @return this builder
+ */
+ @NonNull
+ @RequiresPermission(android.Manifest.permission.NETWORK_FACTORY)
+ public Builder setSsid(@Nullable final String ssid) {
+ mCaps.setSSID(ssid);
+ return this;
+ }
+
+ /**
+ * Set the uid of the app causing this network to exist.
+ *
+ * Note: for security the system will clear out this field when received from a
+ * non-privileged source.
+ *
+ * @param uid UID of the app.
+ * @return this builder
+ */
+ @NonNull
+ @RequiresPermission(android.Manifest.permission.NETWORK_FACTORY)
+ public Builder setRequestorUid(final int uid) {
+ mCaps.setRequestorUid(uid);
+ return this;
+ }
+
+ /**
+ * Set the package name of the app causing this network to exist.
+ *
+ * Note: for security the system will clear out this field when received from a
+ * non-privileged source.
+ *
+ * @param packageName package name of the app, or null to clear it.
+ * @return this builder
+ */
+ @NonNull
+ @RequiresPermission(android.Manifest.permission.NETWORK_FACTORY)
+ public Builder setRequestorPackageName(@Nullable final String packageName) {
+ mCaps.setRequestorPackageName(packageName);
+ return this;
+ }
+
+ /**
+ * Builds the instance of the capabilities.
+ *
+ * @return the built instance of NetworkCapabilities.
+ */
+ @NonNull
+ public NetworkCapabilities build() {
+ if (mCaps.getOwnerUid() != Process.INVALID_UID) {
+ if (!ArrayUtils.contains(mCaps.getAdministratorUids(), mCaps.getOwnerUid())) {
+ throw new IllegalStateException("The owner UID must be included in "
+ + " administrator UIDs.");
+ }
+ }
+ return new NetworkCapabilities(mCaps);
+ }
+ }
}
diff --git a/core/java/android/net/NetworkProvider.java b/core/java/android/net/NetworkProvider.java
index 418d691..75086cf 100644
--- a/core/java/android/net/NetworkProvider.java
+++ b/core/java/android/net/NetworkProvider.java
@@ -16,6 +16,7 @@
package android.net;
+import android.annotation.IntRange;
import android.annotation.NonNull;
import android.annotation.Nullable;
import android.annotation.RequiresPermission;
@@ -33,8 +34,8 @@
* {@link NetworkAgent}s. The networks can then provide connectivity to apps and can be interacted
* with via networking APIs such as {@link ConnectivityManager}.
*
- * Subclasses should implement {@link #onNetworkRequested} and {@link #onRequestWithdrawn} to
- * receive {@link NetworkRequest}s sent by the system and by apps. A network that is not the
+ * Subclasses should implement {@link #onNetworkRequested} and {@link #onNetworkRequestWithdrawn}
+ * to receive {@link NetworkRequest}s sent by the system and by apps. A network that is not the
* best (highest-scoring) network for any request is generally not used by the system, and torn
* down.
*
@@ -77,7 +78,7 @@
* Constructs a new NetworkProvider.
*
* @param looper the Looper on which to run {@link #onNetworkRequested} and
- * {@link #onRequestWithdrawn}.
+ * {@link #onNetworkRequestWithdrawn}.
* @param name the name of the listener, used only for debugging.
*
* @hide
@@ -94,7 +95,7 @@
onNetworkRequested((NetworkRequest) m.obj, m.arg1, m.arg2);
break;
case CMD_CANCEL_REQUEST:
- onRequestWithdrawn((NetworkRequest) m.obj);
+ onNetworkRequestWithdrawn((NetworkRequest) m.obj);
break;
default:
Log.e(mName, "Unhandled message: " + m.what);
@@ -142,14 +143,15 @@
* @hide
*/
@SystemApi
- public void onNetworkRequested(@NonNull NetworkRequest request, int score, int providerId) {}
+ public void onNetworkRequested(@NonNull NetworkRequest request,
+ @IntRange(from = 0, to = 99) int score, int providerId) {}
/**
* Called when a NetworkRequest is withdrawn.
* @hide
*/
@SystemApi
- public void onRequestWithdrawn(@NonNull NetworkRequest request) {}
+ public void onNetworkRequestWithdrawn(@NonNull NetworkRequest request) {}
/**
* Asserts that no provider will ever be able to satisfy the specified request. The provider
@@ -157,7 +159,7 @@
* satisfying this request, and that the request cannot be satisfied. The application filing the
* request will receive an {@link NetworkCallback#onUnavailable()} callback.
*
- * @param request the request that cannot be fulfilled
+ * @param request the request that permanently cannot be fulfilled
* @hide
*/
@SystemApi
diff --git a/core/java/android/net/NetworkRequest.java b/core/java/android/net/NetworkRequest.java
index b0bf64e..75fe6b1 100644
--- a/core/java/android/net/NetworkRequest.java
+++ b/core/java/android/net/NetworkRequest.java
@@ -473,9 +473,7 @@
*
* @param nc Capabilities that should satisfy this NetworkRequest. null capabilities do not
* satisfy any request.
- * @hide
*/
- @SystemApi
public boolean satisfiedBy(@Nullable NetworkCapabilities nc) {
return networkCapabilities.satisfiedByNetworkCapabilities(nc);
}
diff --git a/core/java/android/net/OWNERS b/core/java/android/net/OWNERS
index 767b693..5e2a718 100644
--- a/core/java/android/net/OWNERS
+++ b/core/java/android/net/OWNERS
@@ -8,4 +8,4 @@
reminv@google.com
satk@google.com
-per-file SSL*, Uri*, Url* = prb@google.com, dauletz@google.com, narayan@google.com, tobiast@google.com
+per-file SSL*, Uri*, Url* = prb@google.com, dauletz@google.com, narayan@google.com, ngeoffray@google.com
diff --git a/core/java/android/net/PlatformVpnProfile.java b/core/java/android/net/PlatformVpnProfile.java
index fbae637..445ec91 100644
--- a/core/java/android/net/PlatformVpnProfile.java
+++ b/core/java/android/net/PlatformVpnProfile.java
@@ -60,6 +60,9 @@
public static final int TYPE_IKEV2_IPSEC_RSA = VpnProfile.TYPE_IKEV2_IPSEC_RSA;
/** @hide */
+ public static final int MAX_MTU_DEFAULT = 1360;
+
+ /** @hide */
@PlatformVpnType protected final int mType;
/** @hide */
diff --git a/core/java/android/net/SocketKeepalive.java b/core/java/android/net/SocketKeepalive.java
index fc9a8f6..8ff8f4c 100644
--- a/core/java/android/net/SocketKeepalive.java
+++ b/core/java/android/net/SocketKeepalive.java
@@ -109,6 +109,16 @@
})
public @interface ErrorCode {}
+ /** @hide */
+ @Retention(RetentionPolicy.SOURCE)
+ @IntDef(value = {
+ SUCCESS,
+ ERROR_INVALID_LENGTH,
+ ERROR_UNSUPPORTED,
+ ERROR_INSUFFICIENT_RESOURCES
+ })
+ public @interface KeepaliveEvent {}
+
/**
* The minimum interval in seconds between keepalive packet transmissions.
*
diff --git a/core/java/android/net/http/OWNERS b/core/java/android/net/http/OWNERS
index 3092612..3271d24 100644
--- a/core/java/android/net/http/OWNERS
+++ b/core/java/android/net/http/OWNERS
@@ -1,4 +1,4 @@
narayan@google.com
-tobiast@google.com
+ngeoffray@google.com
include platform/libcore:/OWNERS
include platform/external/conscrypt:/OWNERS
diff --git a/core/java/android/os/PowerManager.java b/core/java/android/os/PowerManager.java
index 1f2a6d9..d3913b0 100644
--- a/core/java/android/os/PowerManager.java
+++ b/core/java/android/os/PowerManager.java
@@ -29,6 +29,7 @@
import android.compat.annotation.UnsupportedAppUsage;
import android.content.Context;
import android.service.dreams.Sandman;
+import android.sysprop.InitProperties;
import android.util.ArrayMap;
import android.util.Log;
import android.util.proto.ProtoOutputStream;
@@ -1336,7 +1337,7 @@
*/
// TODO(b/138605180): add link to documentation once it's ready.
public boolean isRebootingUserspaceSupported() {
- return SystemProperties.getBoolean("ro.init.userspace_reboot.is_supported", false);
+ return InitProperties.is_userspace_reboot_supported().orElse(false);
}
/**
diff --git a/core/java/android/os/ShellCommand.java b/core/java/android/os/ShellCommand.java
index 814aac4..044892a 100644
--- a/core/java/android/os/ShellCommand.java
+++ b/core/java/android/os/ShellCommand.java
@@ -317,6 +317,16 @@
}
/**
+ * Returns number of arguments that haven't been processed yet.
+ */
+ public int getRemainingArgsCount() {
+ if (mArgPos >= mArgs.length) {
+ return 0;
+ }
+ return mArgs.length - mArgPos;
+ }
+
+ /**
* Return the next argument on the command line, whatever it is; if there are
* no arguments left, throws an IllegalArgumentException to report this to the user.
*/
diff --git a/core/java/android/os/storage/StorageManager.java b/core/java/android/os/storage/StorageManager.java
index c7709b9..c31017b 100644
--- a/core/java/android/os/storage/StorageManager.java
+++ b/core/java/android/os/storage/StorageManager.java
@@ -2304,6 +2304,19 @@
}
}
+ /**
+ * Check whether the device supports filesystem checkpoint.
+ *
+ * @return true if the device supports filesystem checkpoint, false otherwise.
+ */
+ public boolean isCheckpointSupported() {
+ try {
+ return mStorageManager.supportsCheckpoint();
+ } catch (RemoteException e) {
+ throw e.rethrowFromSystemServer();
+ }
+ }
+
private final Object mFuseAppLoopLock = new Object();
@GuardedBy("mFuseAppLoopLock")
diff --git a/core/java/android/provider/Settings.java b/core/java/android/provider/Settings.java
index de30bce..7923b58 100644
--- a/core/java/android/provider/Settings.java
+++ b/core/java/android/provider/Settings.java
@@ -8612,7 +8612,6 @@
*
* @hide
*/
- @SystemApi
public static final String CARRIER_APPS_HANDLED = "carrier_apps_handled";
/**
diff --git a/core/java/android/telephony/SubscriptionPlan.java b/core/java/android/telephony/SubscriptionPlan.java
index 901957f..d5ac436 100644
--- a/core/java/android/telephony/SubscriptionPlan.java
+++ b/core/java/android/telephony/SubscriptionPlan.java
@@ -372,5 +372,15 @@
plan.networkTypes = Arrays.copyOf(networkTypes, networkTypes.length);
return this;
}
+
+ /**
+ * Reset any network types that were set with {@link #setNetworkTypes(int[])}.
+ * This will make the SubscriptionPlan apply to all network types.
+ */
+ public @NonNull Builder resetNetworkTypes() {
+ plan.networkTypes = Arrays.copyOf(TelephonyManager.getAllNetworkTypes(),
+ TelephonyManager.getAllNetworkTypes().length);
+ return this;
+ }
}
}
diff --git a/core/java/com/android/internal/net/VpnProfile.java b/core/java/com/android/internal/net/VpnProfile.java
index 23b1ab5..829bd8a 100644
--- a/core/java/com/android/internal/net/VpnProfile.java
+++ b/core/java/com/android/internal/net/VpnProfile.java
@@ -19,6 +19,7 @@
import android.annotation.NonNull;
import android.compat.annotation.UnsupportedAppUsage;
import android.net.Ikev2VpnProfile;
+import android.net.PlatformVpnProfile;
import android.net.ProxyInfo;
import android.os.Build;
import android.os.Parcel;
@@ -131,10 +132,10 @@
* delimiters) are not present in the algorithm names. See {@link #validateAllowedAlgorithms()}
*/
private List<String> mAllowedAlgorithms = new ArrayList<>(); // 19
- public boolean isBypassable = false; // 20
- public boolean isMetered = false; // 21
- public int maxMtu = 1400; // 22
- public boolean areAuthParamsInline = false; // 23
+ public boolean isBypassable = false; // 20
+ public boolean isMetered = false; // 21
+ public int maxMtu = PlatformVpnProfile.MAX_MTU_DEFAULT; // 22
+ public boolean areAuthParamsInline = false; // 23
// Helper fields.
@UnsupportedAppUsage
diff --git a/core/res/res/values/strings.xml b/core/res/res/values/strings.xml
index 492ea68..7f46380 100644
--- a/core/res/res/values/strings.xml
+++ b/core/res/res/values/strings.xml
@@ -5421,4 +5421,236 @@
<!-- ChooserActivity - Alphabetically sorted apps list label. [CHAR LIMIT=NONE] -->
<string name="chooser_all_apps_button_label">Apps list</string>
+ <!-- Icc depersonalization related strings -->
+ <!-- Label text for PIN entry widget on SIM Network Depersonalization panel [CHAR LIMIT=none] -->
+ <string name="PERSOSUBSTATE_SIM_NETWORK_ENTRY">SIM network unlock PIN</string>
+ <!-- Label text for PIN entry widget on SIM Network Subset Depersonalization panel [CHAR LIMIT=none] -->
+ <string name="PERSOSUBSTATE_SIM_NETWORK_SUBSET_ENTRY">SIM network subset unlock PIN</string>
+ <!-- Label text for PIN entry widget on SIM Corporate Depersonalization panel [CHAR LIMIT=none] -->
+ <string name="PERSOSUBSTATE_SIM_CORPORATE_ENTRY">SIM corporate unlock PIN</string>
+ <!-- Label text for PIN entry widget on SIM Service Provider Depersonalization panel [CHAR LIMIT=none] -->
+ <string name="PERSOSUBSTATE_SIM_SERVICE_PROVIDER_ENTRY">SIM service provider unlock PIN</string>
+ <!-- Label text for PIN entry widget on SIM SIM Depersonalization panel [CHAR LIMIT=none] -->
+ <string name="PERSOSUBSTATE_SIM_SIM_ENTRY">SIM unlock PIN</string>
+ <!-- Label text for PUK entry widget on Depersonalization panel [CHAR LIMIT=none] -->
+ <string name="PERSOSUBSTATE_SIM_NETWORK_PUK_ENTRY">Enter PUK</string>
+ <!-- Label text for Subset PUK entry widget on Depersonalization panel [CHAR LIMIT=none] -->
+ <string name="PERSOSUBSTATE_SIM_NETWORK_SUBSET_PUK_ENTRY">Enter PUK</string>
+ <!-- Label text for Corporate PUK entry widget on Depersonalization panel [CHAR LIMIT=none] -->
+ <string name="PERSOSUBSTATE_SIM_CORPORATE_PUK_ENTRY">Enter PUK</string>
+ <!-- Label text for SIM service provider PUK entry widget on Depersonalization panel [CHAR LIMIT=none] -->
+ <string name="PERSOSUBSTATE_SIM_SERVICE_PROVIDER_PUK_ENTRY">Enter PUK</string>
+ <!-- Label text for SIM PUK entry widget on Depersonalization panel [CHAR LIMIT=none] -->
+ <string name="PERSOSUBSTATE_SIM_SIM_PUK_ENTRY">Enter PUK</string>
+ <!-- Label text for PIN entry widget on RUIM Network1 Depersonalization panel [CHAR LIMIT=none] -->
+ <string name="PERSOSUBSTATE_RUIM_NETWORK1_ENTRY">RUIM network1 unlock PIN</string>
+ <!-- Label text for PIN entry widget on RUIM Network2 Depersonalization panel [CHAR LIMIT=none] -->
+ <string name="PERSOSUBSTATE_RUIM_NETWORK2_ENTRY">RUIM network2 unlock PIN</string>
+ <!-- Label text for PIN entry widget on RUIM Hrpd Depersonalization panel [CHAR LIMIT=none] -->
+ <string name="PERSOSUBSTATE_RUIM_HRPD_ENTRY">RUIM hrpd unlock PIN</string>
+ <!-- Label text for PIN entry widget on RUIM Corporate Depersonalization panel [CHAR LIMIT=none] -->
+ <string name="PERSOSUBSTATE_RUIM_CORPORATE_ENTRY">RUIM corporate unlock PIN</string>
+ <!-- Label text for PIN entry widget on RUIM Service Provider Depersonalization panel [CHAR LIMIT=none] -->
+ <string name="PERSOSUBSTATE_RUIM_SERVICE_PROVIDER_ENTRY">RUIM service provider unlock PIN</string>
+ <!-- Label text for PIN entry widget on RUIM RUIM Depersonalization panel [CHAR LIMIT=none] -->
+ <string name="PERSOSUBSTATE_RUIM_RUIM_ENTRY">RUIM unlock PIN</string>
+ <!-- Label text for PUK entry widget on Depersonalization panel [CHAR LIMIT=none] -->
+ <string name="PERSOSUBSTATE_RUIM_NETWORK1_PUK_ENTRY">Enter PUK</string>
+ <!-- Label text for PUK entry widget on Depersonalization panel [CHAR LIMIT=none] -->
+ <string name="PERSOSUBSTATE_RUIM_NETWORK2_PUK_ENTRY">Enter PUK</string>
+ <!-- Label text for PUK entry widget on Depersonalization panel [CHAR LIMIT=none] -->
+ <string name="PERSOSUBSTATE_RUIM_HRPD_PUK_ENTRY">Enter PUK</string>
+ <!-- Label text for PUK entry widget on Depersonalization panel [CHAR LIMIT=none] -->
+ <string name="PERSOSUBSTATE_RUIM_SERVICE_PROVIDER_PUK_ENTRY">Enter PUK</string>
+ <!-- Label text for PUK entry widget on Depersonalization panel [CHAR LIMIT=none] -->
+ <string name="PERSOSUBSTATE_RUIM_RUIM_PUK_ENTRY">Enter PUK</string>
+ <!-- Label text for PUK entry widget on Depersonalization panel [CHAR LIMIT=none] -->
+ <string name="PERSOSUBSTATE_RUIM_CORPORATE_PUK_ENTRY">Enter PUK</string>
+
+ <!-- Label text for PIN entry widget on SIM SPN Depersonalization panel [CHAR LIMIT=none] -->
+ <string name="PERSOSUBSTATE_SIM_SPN_ENTRY">SPN unlock PIN</string>
+ <!-- Label text for PIN entry widget on SIM SP EHPLMN Depersonalization panel [CHAR LIMIT=none] -->
+ <string name="PERSOSUBSTATE_SIM_SP_EHPLMN_ENTRY">SP Equivalent Home PLMN unlock PIN</string>
+ <!-- Label text for PIN entry widget on SIM ICCID Depersonalization panel [CHAR LIMIT=none] -->
+ <string name="PERSOSUBSTATE_SIM_ICCID_ENTRY">ICCID unlock PIN</string>
+ <!-- Label text for PIN entry widget on SIM IMPI Depersonalization panel [CHAR LIMIT=none] -->
+ <string name="PERSOSUBSTATE_SIM_IMPI_ENTRY">IMPI unlock PIN</string>
+ <!-- Label text for PIN entry widget on SIM NS_SP Depersonalization panel [CHAR LIMIT=none] -->
+ <string name="PERSOSUBSTATE_SIM_NS_SP_ENTRY">Network subset service provider unlock PIN</string>
+
+ <!-- Status message displayed on SIM Network Depersonalization panel [CHAR LIMIT=none] -->
+ <string name="PERSOSUBSTATE_SIM_NETWORK_IN_PROGRESS">Requesting SIM network unlock\u2026</string>
+ <!-- Status message displayed on SIM Network Subset Depersonalization panel [CHAR LIMIT=none] -->
+ <string name="PERSOSUBSTATE_SIM_NETWORK_SUBSET_IN_PROGRESS">Requesting SIM network subset unlock
+\u2026</string>
+ <!-- Status message displayed on SIM Service Provider Depersonalization panel [CHAR LIMIT=none] -->
+ <string name="PERSOSUBSTATE_SIM_SERVICE_PROVIDER_IN_PROGRESS">Requesting SIM service provider un
+lock\u2026</string>
+ <!-- Status message displayed on SIM Corporate Depersonalization panel [CHAR LIMIT=none] -->
+ <string name="PERSOSUBSTATE_SIM_CORPORATE_IN_PROGRESS">Requesting SIM corporate unlock\u2026</string>
+ <!-- Status message displayed on PUK Depersonalization panel [CHAR LIMIT=none] -->
+ <string name="PERSOSUBSTATE_SIM_NETWORK_PUK_IN_PROGRESS">Requesting PUK unlock\u2026</string>
+ <!-- Status message displayed on PUK Depersonalization panel [CHAR LIMIT=none] -->
+ <string name="PERSOSUBSTATE_SIM_NETWORK_SUBSET_PUK_IN_PROGRESS">Requesting PUK unlock\u2026</string>
+ <!-- Status message displayed on Corporate PUK entry widget on Depersonalization panel [CHAR LIMIT=none] -->
+ <string name="PERSOSUBSTATE_SIM_CORPORATE_PUK_IN_PROGRESS">Requesting PUK unlock\u2026</string>
+ <!-- Status message displayed on SIM Service provider PUK entry widget on Depersonalization panel [CHAR LIMIT=none] -->
+ <string name="PERSOSUBSTATE_SIM_SERVICE_PROVIDER_PUK_IN_PROGRESS">Requesting PUK unlock\u2026</string>
+ <!-- Status message displayed on SIM PUK entry widget on Depersonalization panel [CHAR LIMIT=none] -->
+ <string name="PERSOSUBSTATE_SIM_SIM_PUK_IN_PROGRESS">Requesting PUK unlock\u2026</string>
+ <!-- Status message displayed on SIM SIM Depersonalization panel [CHAR LIMIT=none] -->
+ <string name="PERSOSUBSTATE_SIM_SIM_IN_PROGRESS">Requesting SIM unlock\u2026</string>
+ <!-- Status message displayed on RUIM Network1 Depersonalization panel [CHAR LIMIT=none] -->
+ <string name="PERSOSUBSTATE_RUIM_NETWORK1_IN_PROGRESS">Requesting RUIM network1 unlock\u2026</string>
+ <!-- Status message displayed on RUIM Network2 Depersonalization panel [CHAR LIMIT=none] -->
+ <string name="PERSOSUBSTATE_RUIM_NETWORK2_IN_PROGRESS">Requesting RUIM network2 unlock\u2026</string>
+ <!-- Status message displayed on RUIM Hrpd Depersonalization panel [CHAR LIMIT=none] -->
+ <string name="PERSOSUBSTATE_RUIM_HRPD_IN_PROGRESS">Requesting RUIM hrpd unlock\u2026</string>
+ <!-- Status message displayed on RUIM Service Provider Depersonalization panel [CHAR LIMIT=none] -->
+ <string name="PERSOSUBSTATE_RUIM_SERVICE_PROVIDER_IN_PROGRESS">Requesting RUIM service provider
+unlock\u2026</string>
+ <!-- Status message displayed on RUIM Corporate Depersonalization panel [CHAR LIMIT=none] -->
+ <string name="PERSOSUBSTATE_RUIM_CORPORATE_IN_PROGRESS">Requesting RUIM corporate unlock\u2026</string>
+
+ <!-- Status message displayed on SIM SPN Depersonalization panel [CHAR LIMIT=none] -->
+ <string name="PERSOSUBSTATE_SIM_SPN_IN_PROGRESS">Requesting SPN unlock\u2026</string>
+ <!-- Status message displayed on SIM SP EHPLMN Depersonalization panel [CHAR LIMIT=none] -->
+ <string name="PERSOSUBSTATE_SIM_SP_EHPLMN_IN_PROGRESS">Requesting SP Equivalent Home PLMN unlock\u2026</string>
+ <!-- Status message displayed on SIM ICCID Depersonalization panel [CHAR LIMIT=none] -->
+ <string name="PERSOSUBSTATE_SIM_ICCID_IN_PROGRESS">Requesting ICCID unlock\u2026</string>
+ <!-- Status message displayed on SIM IMPI Depersonalization panel [CHAR LIMIT=none] -->
+ <string name="PERSOSUBSTATE_SIM_IMPI_IN_PROGRESS">Requesting IMPI unlock\u2026</string>
+ <!-- Status message displayed on SIM NS_SP Depersonalization panel [CHAR LIMIT=none] -->
+ <string name="PERSOSUBSTATE_SIM_NS_SP_IN_PROGRESS">Requesting Network subset service provider unlock\u2026</string>
+
+ <!-- Status message displayed on RUIM RUIM Depersonalization panel [CHAR LIMIT=none] -->
+ <string name="PERSOSUBSTATE_RUIM_RUIM_IN_PROGRESS">Requesting RUIM unlock\u2026</string>
+ <!-- Status message displayed on PUK Depersonalization panel [CHAR LIMIT=none] -->
+ <string name="PERSOSUBSTATE_RUIM_NETWORK1_PUK_IN_PROGRESS">Requesting PUK unlock\u2026</string>
+ <!-- Status message displayed on PUK Depersonalization panel [CHAR LIMIT=none] -->
+ <string name="PERSOSUBSTATE_RUIM_NETWORK2_PUK_IN_PROGRESS">Requesting PUK unlock\u2026</string>
+ <!-- Status message displayed on PUK Depersonalization panel [CHAR LIMIT=none] -->
+ <string name="PERSOSUBSTATE_RUIM_HRPD_PUK_IN_PROGRESS">Requesting PUK unlock\u2026</string>
+ <!-- Status message displayed on PUK Depersonalization panel [CHAR LIMIT=none] -->
+ <string name="PERSOSUBSTATE_RUIM_CORPORATE_PUK_IN_PROGRESS">Requesting PUK unlock\u2026</string>
+ <!-- Status message displayed on PUK Depersonalization panel [CHAR LIMIT=none] -->
+ <string name="PERSOSUBSTATE_RUIM_SERVICE_PROVIDER_PUK_IN_PROGRESS">Requesting PUK unlock\u2026</string>
+ <!-- Status message displayed on PUK Depersonalization panel [CHAR LIMIT=none] -->
+ <string name="PERSOSUBSTATE_RUIM_RUIM_PUK_IN_PROGRESS">Requesting PUK unlock\u2026</string>
+ <!-- Error message displayed on SIM Network Depersonalization panel [CHAR LIMIT=none] -->
+ <string name="PERSOSUBSTATE_SIM_NETWORK_ERROR">SIM Network unlock request unsuccessful.</string>
+ <!-- Error message displayed on SIM Network Subset Depersonalization panel [CHAR LIMIT=none] -->
+ <string name="PERSOSUBSTATE_SIM_NETWORK_SUBSET_ERROR">SIM Network Subset unlock request unsucces
+sful.</string>
+ <!-- Error message displayed on SIM Service Provider Depersonalization panel [CHAR LIMIT=none] -->
+ <string name="PERSOSUBSTATE_SIM_SERVICE_PROVIDER_ERROR">SIM Service Provider unlock request unsu
+ccessful.</string>
+ <!-- Error message displayed on SIM Corporate Depersonalization panel [CHAR LIMIT=none] -->
+ <string name="PERSOSUBSTATE_SIM_CORPORATE_ERROR">SIM Corporate unlock request unsuccessful.</string>
+ <!-- Error message displayed on SIM SIM Depersonalization panel [CHAR LIMIT=none] -->
+ <string name="PERSOSUBSTATE_SIM_SIM_ERROR">SIM unlock request unsuccessful.</string>
+ <!-- Error message displayed on RUIM Network1 Depersonalization panel [CHAR LIMIT=none] -->
+ <string name="PERSOSUBSTATE_RUIM_NETWORK1_ERROR">RUIM Network1 unlock request unsuccessful.</string>
+ <!-- Error message displayed on RUIM Network2 Depersonalization panel [CHAR LIMIT=none] -->
+ <string name="PERSOSUBSTATE_RUIM_NETWORK2_ERROR">RUIM Network2 unlock request unsuccessful.</string>
+ <!-- Error message displayed on RUIM Hrpd Depersonalization panel [CHAR LIMIT=none] -->
+ <string name="PERSOSUBSTATE_RUIM_HRPD_ERROR">RUIM Hrpd unlock request unsuccessful.</string>
+ <!-- Error message displayed on RUIM Corporate Depersonalization panel [CHAR LIMIT=none] -->
+ <string name="PERSOSUBSTATE_RUIM_CORPORATE_ERROR">RUIM Corporate unlock request unsuccessful.</string>
+ <!-- Error message displayed on RUIM Service Provider Depersonalization panel [CHAR LIMIT=none] -->
+ <string name="PERSOSUBSTATE_RUIM_SERVICE_PROVIDER_ERROR">RUIM Service Provider unlock request un
+successful.</string>
+ <!-- Error message displayed on RUIM RUIM Depersonalization panel [CHAR LIMIT=none] -->
+ <string name="PERSOSUBSTATE_RUIM_RUIM_ERROR">RUIM unlock request unsuccessful.</string>
+ <!-- Error message displayed on PUK Depersonalization panel [CHAR LIMIT=none] -->
+ <string name="PERSOSUBSTATE_SIM_NETWORK_PUK_ERROR">PUK unlock unsuccessful.</string>
+ <!-- Error message displayed on PUK Depersonalization panel [CHAR LIMIT=none] -->
+ <string name="PERSOSUBSTATE_SIM_NETWORK_SUBSET_PUK_ERROR">PUK unlock unsuccessful.</string>
+ <!-- Error message displayed on PUK Depersonalization panel [CHAR LIMIT=none] -->
+ <string name="PERSOSUBSTATE_SIM_CORPORATE_PUK_ERROR">PUK unlock unsuccessful.</string>
+ <!-- Error message displayed on PUK Depersonalization panel [CHAR LIMIT=none] -->
+ <string name="PERSOSUBSTATE_SIM_SERVICE_PROVIDER_PUK_ERROR">PUK unlock unsuccessful.</string>
+ <!-- Error message displayed on PUK Depersonalization panel [CHAR LIMIT=none] -->
+ <string name="PERSOSUBSTATE_SIM_SIM_PUK_ERROR">PUK unlock unsuccessful.</string>
+ <!-- Error message displayed on PUK Depersonalization panel [CHAR LIMIT=none] -->
+ <string name="PERSOSUBSTATE_RUIM_NETWORK1_PUK_ERROR">PUK unlock unsuccessful.</string>
+ <!-- Error message displayed on PUK Depersonalization panel [CHAR LIMIT=none] -->
+ <string name="PERSOSUBSTATE_RUIM_NETWORK2_PUK_ERROR">PUK unlock unsuccessful.</string>
+ <!-- Error message displayed on PUK Depersonalization panel [CHAR LIMIT=none] -->
+ <string name="PERSOSUBSTATE_RUIM_HRPD_PUK_ERROR">PUK unlock unsuccessful.</string>
+ <!-- Error message displayed on PUK Depersonalization panel [CHAR LIMIT=none] -->
+ <string name="PERSOSUBSTATE_RUIM_SERVICE_PROVIDER_PUK_ERROR">PUK unlock unsuccessful.</string>
+ <!-- Error message displayed on PUK Depersonalization panel [CHAR LIMIT=none] -->
+ <string name="PERSOSUBSTATE_RUIM_RUIM_PUK_ERROR">PUK unlock unsuccessful.</string>
+ <!-- Error message displayed on PUK Depersonalization panel [CHAR LIMIT=none] -->
+ <string name="PERSOSUBSTATE_RUIM_CORPORATE_PUK_ERROR">PUK unlock unsuccessful.</string>
+
+ <!-- Error message displayed on SIM SPN Depersonalization panel [CHAR LIMIT=none] -->
+ <string name="PERSOSUBSTATE_SIM_SPN_ERROR">SPN unlock request unsuccessful.</string>
+ <!-- Error message displayed on SIM SP EHPLMN Depersonalization panel [CHAR LIMIT=none] -->
+ <string name="PERSOSUBSTATE_SIM_SP_EHPLMN_ERROR">SP Equivalent Home PLMN unlock request unsuccessful.</string>
+ <!-- Error message displayed on SIM ICCID Depersonalization panel [CHAR LIMIT=none] -->
+ <string name="PERSOSUBSTATE_SIM_ICCID_ERROR">ICCID unlock request unsuccessful.</string>
+ <!-- Error message displayed on SIM IMPI Depersonalization panel [CHAR LIMIT=none] -->
+ <string name="PERSOSUBSTATE_SIM_IMPI_ERROR">IMPI unlock request unsuccessful.</string>
+ <!-- Error message displayed on SIM NS_SP Depersonalization panel [CHAR LIMIT=none] -->
+ <string name="PERSOSUBSTATE_SIM_NS_SP_ERROR">Network subset service provider unlock request unsuccessful.</string>
+
+ <!-- Success message displayed on SIM Network Depersonalization panel [CHAR LIMIT=none] -->
+ <string name="PERSOSUBSTATE_SIM_NETWORK_SUCCESS">SIM Network unlock successful.</string>
+ <!-- Success message displayed on SIM Network Subset Depersonalization panel [CHAR LIMIT=none] -->
+ <string name="PERSOSUBSTATE_SIM_NETWORK_SUBSET_SUCCESS">SIM Network Subset unlock successful.</string>
+ <!-- Success message displayed on SIM Service Provider Depersonalization panel [CHAR LIMIT=none] -->
+ <string name="PERSOSUBSTATE_SIM_SERVICE_PROVIDER_SUCCESS">SIM Service Provider unlock successful
+.</string>
+ <!-- Success message displayed on SIM Corporate Depersonalization panel [CHAR LIMIT=none] -->
+ <string name="PERSOSUBSTATE_SIM_CORPORATE_SUCCESS">SIM Corporate unlock successful.</string>
+ <!-- Success message displayed on SIM SIM Depersonalization panel [CHAR LIMIT=none] -->
+ <string name="PERSOSUBSTATE_SIM_SIM_SUCCESS">SIM unlock successful.</string>
+ <!-- Success message displayed on RUIM Network1 Depersonalization panel [CHAR LIMIT=none] -->
+ <string name="PERSOSUBSTATE_RUIM_NETWORK1_SUCCESS">RUIM Network1 unlock successful.</string>
+ <!-- Success message displayed on RUIM Network2 Depersonalization panel [CHAR LIMIT=none] -->
+ <string name="PERSOSUBSTATE_RUIM_NETWORK2_SUCCESS">RUIM Network2 unlock successful.</string>
+ <!-- Success message displayed on RUIM Hrpd Depersonalization panel [CHAR LIMIT=none] -->
+ <string name="PERSOSUBSTATE_RUIM_HRPD_SUCCESS">RUIM Hrpd unlock successful.</string>
+ <!-- Success message displayed on RUIM Service Provider Depersonalization panel [CHAR LIMIT=none] -->
+ <string name="PERSOSUBSTATE_RUIM_SERVICE_PROVIDER_SUCCESS">RUIM Service Provider unlock successf
+ul.</string>
+ <!-- Success message displayed on RUIM Corporate Depersonalization panel [CHAR LIMIT=none] -->
+ <string name="PERSOSUBSTATE_RUIM_CORPORATE_SUCCESS">RUIM Corporate unlock successful.</string>
+ <!-- Success message displayed on RUIM RUIM Depersonalization panel [CHAR LIMIT=none] -->
+ <string name="PERSOSUBSTATE_RUIM_RUIM_SUCCESS">RUIM unlock successful.</string>
+ <!-- Success message displayed on PUK Depersonalization panel [CHAR LIMIT=none] -->
+ <string name="PERSOSUBSTATE_SIM_NETWORK_PUK_SUCCESS">PUK unlock successful.</string>
+ <!-- Success message displayed on PUK Depersonalization panel [CHAR LIMIT=none] -->
+ <string name="PERSOSUBSTATE_SIM_NETWORK_SUBSET_PUK_SUCCESS">PUK unlock successful.</string>
+ <!-- Success message displayed on PUK Depersonalization panel [CHAR LIMIT=none] -->
+ <string name="PERSOSUBSTATE_SIM_CORPORATE_PUK_SUCCESS">PUK unlock successful.</string>
+ <!-- Success message displayed on PUK Depersonalization panel [CHAR LIMIT=none] -->
+ <string name="PERSOSUBSTATE_SIM_SERVICE_PROVIDER_PUK_SUCCESS">PUK unlock successful.</string>
+ <!-- Success message displayed on PUK Depersonalization panel [CHAR LIMIT=none] -->
+ <string name="PERSOSUBSTATE_SIM_SIM_PUK_SUCCESS">PUK unlock successful.</string>
+ <!-- Success message displayed on PUK Depersonalization panel [CHAR LIMIT=none] -->
+ <string name="PERSOSUBSTATE_RUIM_NETWORK1_PUK_SUCCESS">PUK unlock successful.</string>
+ <!-- Success message displayed on PUK Depersonalization panel [CHAR LIMIT=none] -->
+ <string name="PERSOSUBSTATE_RUIM_NETWORK2_PUK_SUCCESS">PUK unlock successful.</string>
+ <!-- Success message displayed on PUK Depersonalization panel [CHAR LIMIT=none] -->
+ <string name="PERSOSUBSTATE_RUIM_HRPD_PUK_SUCCESS">PUK unlock successful.</string>
+ <!-- Success message displayed on PUK Depersonalization panel [CHAR LIMIT=none] -->
+ <string name="PERSOSUBSTATE_RUIM_CORPORATE_PUK_SUCCESS">PUK unlock successful.</string>
+ <!-- Success message displayed on PUK Depersonalization panel [CHAR LIMIT=none] -->
+ <string name="PERSOSUBSTATE_RUIM_SERVICE_PROVIDER_PUK_SUCCESS">PUK unlock successful.</string>
+ <!-- Success message displayed on PUK Depersonalization panel [CHAR LIMIT=none] -->
+ <string name="PERSOSUBSTATE_RUIM_RUIM_PUK_SUCCESS">PUK unlock successful.</string>
+
+ <!-- Success message displayed on SIM SPN Depersonalization panel [CHAR LIMIT=none] -->
+ <string name="PERSOSUBSTATE_SIM_SPN_SUCCESS">SPN unlock successful.</string>
+ <!-- Success message displayed on SIM SP EHPLMN Depersonalization panel [CHAR LIMIT=none] -->
+ <string name="PERSOSUBSTATE_SIM_SP_EHPLMN_SUCCESS">SP Equivalent Home PLMN unlock successful.</string>
+ <!-- Success message displayed on SIM ICCID Depersonalization panel [CHAR LIMIT=none] -->
+ <string name="PERSOSUBSTATE_SIM_ICCID_SUCCESS">ICCID unlock successful.</string>
+ <!-- Success message displayed on SIM IMPI Depersonalization panel [CHAR LIMIT=none] -->
+ <string name="PERSOSUBSTATE_SIM_IMPI_SUCCESS">IMPI unlock successful.</string>
+ <!-- Success message displayed on SIM NS_SP Depersonalization panel [CHAR LIMIT=none] -->
+ <string name="PERSOSUBSTATE_SIM_NS_SP_SUCCESS">Network subset service provider unlock successful.</string>
</resources>
diff --git a/libs/androidfw/OWNERS b/libs/androidfw/OWNERS
index 8cffd6a..bc056df 100644
--- a/libs/androidfw/OWNERS
+++ b/libs/androidfw/OWNERS
@@ -3,4 +3,4 @@
rtmitchell@google.com
per-file CursorWindow.cpp=omakoto@google.com
-per-file LocaleDataTables.cpp=vichang@google.com,tobiast@google.com,nikitai@google.com
+per-file LocaleDataTables.cpp=vichang@google.com,ngeoffray@google.com,nikitai@google.com
diff --git a/mms/java/android/telephony/MmsManager.java b/mms/java/android/telephony/MmsManager.java
index cf55eba..199f0eb 100644
--- a/mms/java/android/telephony/MmsManager.java
+++ b/mms/java/android/telephony/MmsManager.java
@@ -32,6 +32,7 @@
/**
* Manages MMS operations such as sending multimedia messages.
* Get this object by calling Context#getSystemService(Context#MMS_SERVICE).
+ * @hide
*/
@SystemService(Context.MMS_SERVICE)
public class MmsManager {
diff --git a/packages/SystemUI/OWNERS b/packages/SystemUI/OWNERS
index 656827a..c8cf7f50 100644
--- a/packages/SystemUI/OWNERS
+++ b/packages/SystemUI/OWNERS
@@ -4,7 +4,6 @@
adamcohen@google.com
asc@google.com
-ashaikh@google.com
beverlyt@google.com
brockman@google.com
cinek@google.com
@@ -12,8 +11,8 @@
dupin@google.com
ethibodeau@google.com
evanlaird@google.com
+hwwang@google.com
hyunyoungs@google.com
-jmonk@google.com
jaggies@google.com
jjaggi@google.com
joshmcgrath@google.com
@@ -29,16 +28,16 @@
mrenouf@google.com
nbenbernou@google.com
nesciosquid@google.com
-ngmatthew@google.com
ogunwale@google.com
+peanutbutter@google.com
pixel@google.com
roosa@google.com
-shahrk@google.com
snoeberger@google.com
steell@google.com
stwu@google.com
sunnygoyal@google.com
susikp@google.com
+tracyzhou@google.com
tsuji@google.com
twickham@google.com
winsonc@google.com
diff --git a/packages/Tethering/Android.bp b/packages/Tethering/Android.bp
index 0c37235..0cfd884 100644
--- a/packages/Tethering/Android.bp
+++ b/packages/Tethering/Android.bp
@@ -16,9 +16,7 @@
java_defaults {
name: "TetheringAndroidLibraryDefaults",
- // TODO (b/146757305): change to module API once available
- // TODO (b/148190005): change to module-libs-api-stubs-current once it is ready.
- sdk_version: "core_platform",
+ sdk_version: "module_current",
srcs: [
"src/**/*.java",
":framework-tethering-shared-srcs",
@@ -35,15 +33,8 @@
"net-utils-framework-common",
],
libs: [
- // Order matters: framework-tethering needs to be before the system stubs, otherwise
- // hidden fields in the framework-tethering classes (which are also used to generate stubs)
- // will not be found.
"framework-tethering",
- "android_system_stubs_current",
- "framework-res",
"unsupportedappusage",
- "android_system_stubs_current",
- "framework-res",
],
plugins: ["java_api_finder"],
manifest: "AndroidManifestBase.xml",
@@ -91,9 +82,7 @@
// Common defaults for compiling the actual APK.
java_defaults {
name: "TetheringAppDefaults",
- // TODO (b/146757305): change to module API once available
- // TODO (b/148190005): change to module-libs-api-stubs-current once it is ready.
- sdk_version: "core_platform",
+ sdk_version: "module_current",
privileged: true,
jni_libs: [
"libtetherutilsjni",
@@ -102,12 +91,7 @@
"res",
],
libs: [
- // Order matters: framework-tethering needs to be before the system stubs, otherwise
- // hidden fields in the framework-tethering classes (which are also used to generate stubs)
- // will not be found.
"framework-tethering",
- "android_system_stubs_current",
- "framework-res",
],
jarjar_rules: "jarjar-rules.txt",
optimize: {
diff --git a/packages/Tethering/common/TetheringLib/Android.bp b/packages/Tethering/common/TetheringLib/Android.bp
index 00d0d9c..31c40d2 100644
--- a/packages/Tethering/common/TetheringLib/Android.bp
+++ b/packages/Tethering/common/TetheringLib/Android.bp
@@ -65,12 +65,7 @@
stubs_defaults {
name: "framework-tethering-stubs-defaults",
- srcs: [
- "src/android/net/TetheredClient.java",
- "src/android/net/TetheringManager.java",
- "src/android/net/TetheringConstants.java",
- ],
- libs: ["tethering-aidl-interfaces-java"],
+ srcs: [":framework-tethering-srcs"],
}
filegroup {
@@ -126,17 +121,17 @@
java_library {
name: "framework-tethering-stubs-publicapi",
srcs: [":framework-tethering-stubs-srcs-publicapi"],
- sdk_version: "current",
+ defaults: ["framework-module-stubs-lib-defaults-publicapi"],
}
java_library {
name: "framework-tethering-stubs-systemapi",
srcs: [":framework-tethering-stubs-srcs-systemapi"],
- sdk_version: "system_current",
+ defaults: ["framework-module-stubs-lib-defaults-systemapi"],
}
java_library {
name: "framework-tethering-stubs-module_libs_api",
srcs: [":framework-tethering-stubs-srcs-module_libs_api"],
- sdk_version: "module_current",
+ defaults: ["framework-module-stubs-lib-defaults-systemapi"],
}
diff --git a/packages/Tethering/common/TetheringLib/src/android/net/TetheringManager.java b/packages/Tethering/common/TetheringLib/src/android/net/TetheringManager.java
index 096f4fe..0107a7e 100644
--- a/packages/Tethering/common/TetheringLib/src/android/net/TetheringManager.java
+++ b/packages/Tethering/common/TetheringLib/src/android/net/TetheringManager.java
@@ -571,9 +571,8 @@
/**
* Configure tethering with static IPv4 assignment.
*
- * The clientAddress must be in the localIPv4Address prefix. A DHCP server will be
- * started, but will only be able to offer the client address. The two addresses must
- * be in the same prefix.
+ * A DHCP server will be started, but will only be able to offer the client address.
+ * The two addresses must be in the same prefix.
*
* @param localIPv4Address The preferred local IPv4 link address to use.
* @param clientAddress The static client address.
@@ -584,10 +583,7 @@
@NonNull final LinkAddress clientAddress) {
Objects.requireNonNull(localIPv4Address);
Objects.requireNonNull(clientAddress);
- if (localIPv4Address.getPrefixLength() != clientAddress.getPrefixLength()
- || !localIPv4Address.isIpv4() || !clientAddress.isIpv4()
- || !new IpPrefix(localIPv4Address.toString()).equals(
- new IpPrefix(clientAddress.toString()))) {
+ if (!checkStaticAddressConfiguration(localIPv4Address, clientAddress)) {
throw new IllegalArgumentException("Invalid server or client addresses");
}
@@ -657,6 +653,19 @@
}
/**
+ * Check whether the two addresses are ipv4 and in the same prefix.
+ * @hide
+ */
+ public static boolean checkStaticAddressConfiguration(
+ @NonNull final LinkAddress localIPv4Address,
+ @NonNull final LinkAddress clientAddress) {
+ return localIPv4Address.getPrefixLength() == clientAddress.getPrefixLength()
+ && localIPv4Address.isIpv4() && clientAddress.isIpv4()
+ && new IpPrefix(localIPv4Address.toString()).equals(
+ new IpPrefix(clientAddress.toString()));
+ }
+
+ /**
* Get a TetheringRequestParcel from the configuration
* @hide
*/
diff --git a/packages/Tethering/src/android/net/dhcp/DhcpServingParamsParcelExt.java b/packages/Tethering/src/android/net/dhcp/DhcpServingParamsParcelExt.java
index d6bc063..82a26be 100644
--- a/packages/Tethering/src/android/net/dhcp/DhcpServingParamsParcelExt.java
+++ b/packages/Tethering/src/android/net/dhcp/DhcpServingParamsParcelExt.java
@@ -18,10 +18,12 @@
import static android.net.shared.Inet4AddressUtils.inet4AddressToIntHTH;
-import android.annotation.NonNull;
import android.net.LinkAddress;
import android.util.ArraySet;
+import androidx.annotation.NonNull;
+import androidx.annotation.Nullable;
+
import java.net.Inet4Address;
import java.util.Collection;
import java.util.Collections;
@@ -160,6 +162,17 @@
return this;
}
+ /**
+ * Set the client address to tell DHCP server only offer this address.
+ * The client's prefix length is the same as server's.
+ *
+ * <p>If not set, the default value is null.
+ */
+ public DhcpServingParamsParcelExt setSingleClientAddr(@Nullable Inet4Address clientAddr) {
+ this.clientAddr = clientAddr == null ? 0 : inet4AddressToIntHTH(clientAddr);
+ return this;
+ }
+
private static int[] toIntArray(@NonNull Collection<Inet4Address> addrs) {
int[] res = new int[addrs.size()];
int i = 0;
diff --git a/packages/Tethering/src/android/net/ip/IpServer.java b/packages/Tethering/src/android/net/ip/IpServer.java
index c5478d2..82b17ac 100644
--- a/packages/Tethering/src/android/net/ip/IpServer.java
+++ b/packages/Tethering/src/android/net/ip/IpServer.java
@@ -18,6 +18,7 @@
import static android.net.InetAddresses.parseNumericAddress;
import static android.net.RouteInfo.RTN_UNICAST;
+import static android.net.TetheringManager.TetheringRequest.checkStaticAddressConfiguration;
import static android.net.dhcp.IDhcpServer.STATUS_SUCCESS;
import static android.net.shared.Inet4AddressUtils.intToInet4AddressHTH;
import static android.net.util.NetworkConstants.FF;
@@ -492,17 +493,24 @@
}
}
- private boolean startDhcp(Inet4Address addr, int prefixLen) {
+ private boolean startDhcp(final LinkAddress serverLinkAddr, final LinkAddress clientLinkAddr) {
if (mUsingLegacyDhcp) {
return true;
}
+
+ final Inet4Address addr = (Inet4Address) serverLinkAddr.getAddress();
+ final int prefixLen = serverLinkAddr.getPrefixLength();
+ final Inet4Address clientAddr = clientLinkAddr == null ? null :
+ (Inet4Address) clientLinkAddr.getAddress();
+
final DhcpServingParamsParcel params;
params = new DhcpServingParamsParcelExt()
.setDefaultRouters(addr)
.setDhcpLeaseTimeSecs(DHCP_LEASE_TIME_SECS)
.setDnsServers(addr)
- .setServerAddr(new LinkAddress(addr, prefixLen))
- .setMetered(true);
+ .setServerAddr(serverLinkAddr)
+ .setMetered(true)
+ .setSingleClientAddr(clientAddr);
// TODO: also advertise link MTU
mDhcpServerStartIndex++;
@@ -537,9 +545,10 @@
}
}
- private boolean configureDhcp(boolean enable, Inet4Address addr, int prefixLen) {
+ private boolean configureDhcp(boolean enable, final LinkAddress serverAddr,
+ final LinkAddress clientAddr) {
if (enable) {
- return startDhcp(addr, prefixLen);
+ return startDhcp(serverAddr, clientAddr);
} else {
stopDhcp();
return true;
@@ -587,7 +596,7 @@
// code that calls into NetworkManagementService directly.
srvAddr = (Inet4Address) parseNumericAddress(BLUETOOTH_IFACE_ADDR);
mIpv4Address = new LinkAddress(srvAddr, BLUETOOTH_DHCP_PREFIX_LENGTH);
- return configureDhcp(enabled, srvAddr, BLUETOOTH_DHCP_PREFIX_LENGTH);
+ return configureDhcp(enabled, mIpv4Address, null /* clientAddress */);
}
mIpv4Address = new LinkAddress(srvAddr, prefixLen);
} catch (IllegalArgumentException e) {
@@ -624,7 +633,7 @@
mLinkProperties.removeRoute(route);
}
- return configureDhcp(enabled, srvAddr, prefixLen);
+ return configureDhcp(enabled, mIpv4Address, mStaticIpv4ClientAddr);
}
private String getRandomWifiIPv4Address() {
@@ -945,7 +954,14 @@
}
private void maybeConfigureStaticIp(final TetheringRequestParcel request) {
- if (request == null) return;
+ // Ignore static address configuration if they are invalid or null. In theory, static
+ // addresses should not be invalid here because TetheringManager do not allow caller to
+ // specify invalid static address configuration.
+ if (request == null || request.localIPv4Address == null
+ || request.staticClientAddress == null || !checkStaticAddressConfiguration(
+ request.localIPv4Address, request.staticClientAddress)) {
+ return;
+ }
mStaticIpv4ServerAddr = request.localIPv4Address;
mStaticIpv4ClientAddr = request.staticClientAddress;
diff --git a/packages/Tethering/src/com/android/server/connectivity/tethering/Tethering.java b/packages/Tethering/src/com/android/server/connectivity/tethering/Tethering.java
index 020db54..343ed4b 100644
--- a/packages/Tethering/src/com/android/server/connectivity/tethering/Tethering.java
+++ b/packages/Tethering/src/com/android/server/connectivity/tethering/Tethering.java
@@ -307,28 +307,22 @@
userManager, this, mNotificationUpdater);
mExecutor = new TetheringThreadExecutor(mHandler);
mActiveDataSubIdListener = new ActiveDataSubIdListener(mExecutor);
+ mNetdCallback = new NetdCallback();
// Load tethering configuration.
updateConfiguration();
- // NetdCallback should be registered after updateConfiguration() to ensure
- // TetheringConfiguration is created.
- mNetdCallback = new NetdCallback();
+ }
+
+ /**
+ * Start to register callbacks.
+ * Call this function when tethering is ready to handle callback events.
+ */
+ public void startStateMachineUpdaters() {
try {
mNetd.registerUnsolicitedEventListener(mNetdCallback);
} catch (RemoteException e) {
mLog.e("Unable to register netd UnsolicitedEventListener");
}
-
- startStateMachineUpdaters(mHandler);
- startTrackDefaultNetwork();
-
- final WifiManager wifiManager = getWifiManager();
- if (wifiManager != null) {
- wifiManager.registerSoftApCallback(mExecutor, new TetheringSoftApCallback());
- }
- }
-
- private void startStateMachineUpdaters(Handler handler) {
mCarrierConfigChange.startListening();
mContext.getSystemService(TelephonyManager.class).listen(mActiveDataSubIdListener,
PhoneStateListener.LISTEN_ACTIVE_DATA_SUBSCRIPTION_ID_CHANGE);
@@ -341,7 +335,14 @@
filter.addAction(WifiP2pManager.WIFI_P2P_CONNECTION_CHANGED_ACTION);
filter.addAction(UserManager.ACTION_USER_RESTRICTIONS_CHANGED);
filter.addAction(ACTION_RESTRICT_BACKGROUND_CHANGED);
- mContext.registerReceiver(mStateReceiver, filter, null, handler);
+ mContext.registerReceiver(mStateReceiver, filter, null, mHandler);
+
+ final WifiManager wifiManager = getWifiManager();
+ if (wifiManager != null) {
+ wifiManager.registerSoftApCallback(mExecutor, new TetheringSoftApCallback());
+ }
+
+ startTrackDefaultNetwork();
}
private class TetheringThreadExecutor implements Executor {
diff --git a/packages/Tethering/src/com/android/server/connectivity/tethering/TetheringService.java b/packages/Tethering/src/com/android/server/connectivity/tethering/TetheringService.java
index c5329d8..c30be25 100644
--- a/packages/Tethering/src/com/android/server/connectivity/tethering/TetheringService.java
+++ b/packages/Tethering/src/com/android/server/connectivity/tethering/TetheringService.java
@@ -80,6 +80,7 @@
mContext = mDeps.getContext();
mUserManager = (UserManager) mContext.getSystemService(Context.USER_SERVICE);
mTethering = makeTethering(mDeps);
+ mTethering.startStateMachineUpdaters();
}
/**
diff --git a/packages/Tethering/src/com/android/server/connectivity/tethering/UpstreamNetworkMonitor.java b/packages/Tethering/src/com/android/server/connectivity/tethering/UpstreamNetworkMonitor.java
index 7ac7f5f..45bb4ab 100644
--- a/packages/Tethering/src/com/android/server/connectivity/tethering/UpstreamNetworkMonitor.java
+++ b/packages/Tethering/src/com/android/server/connectivity/tethering/UpstreamNetworkMonitor.java
@@ -586,21 +586,21 @@
*/
@VisibleForTesting
public static NetworkCapabilities networkCapabilitiesForType(int type) {
- final NetworkCapabilities nc = new NetworkCapabilities();
+ final NetworkCapabilities.Builder builder = new NetworkCapabilities.Builder();
// Map from type to transports.
final int notFound = -1;
final int transport = sLegacyTypeToTransport.get(type, notFound);
Preconditions.checkArgument(transport != notFound, "unknown legacy type: " + type);
- nc.addTransportType(transport);
+ builder.addTransportType(transport);
if (type == TYPE_MOBILE_DUN) {
- nc.addCapability(NetworkCapabilities.NET_CAPABILITY_DUN);
+ builder.addCapability(NetworkCapabilities.NET_CAPABILITY_DUN);
// DUN is restricted network, see NetworkCapabilities#FORCE_RESTRICTED_CAPABILITIES.
- nc.removeCapability(NetworkCapabilities.NET_CAPABILITY_NOT_RESTRICTED);
+ builder.removeCapability(NetworkCapabilities.NET_CAPABILITY_NOT_RESTRICTED);
} else {
- nc.addCapability(NetworkCapabilities.NET_CAPABILITY_INTERNET);
+ builder.addCapability(NetworkCapabilities.NET_CAPABILITY_INTERNET);
}
- return nc;
+ return builder.build();
}
}
diff --git a/packages/Tethering/tests/integration/Android.bp b/packages/Tethering/tests/integration/Android.bp
new file mode 100644
index 0000000..1a1c30d
--- /dev/null
+++ b/packages/Tethering/tests/integration/Android.bp
@@ -0,0 +1,42 @@
+//
+// Copyright (C) 2020 The Android Open Source Project
+//
+// Licensed under the Apache License, Version 2.0 (the "License");
+// you may not use this file except in compliance with the License.
+// You may obtain a copy of the License at
+//
+// http://www.apache.org/licenses/LICENSE-2.0
+//
+// Unless required by applicable law or agreed to in writing, software
+// distributed under the License is distributed on an "AS IS" BASIS,
+// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+// See the License for the specific language governing permissions and
+// limitations under the License.
+//
+
+android_test {
+ name: "TetheringIntegrationTests",
+ certificate: "platform",
+ platform_apis: true,
+ srcs: [
+ "src/**/*.java",
+ "src/**/*.kt",
+ ],
+ test_suites: [
+ "device-tests",
+ "mts",
+ ],
+ static_libs: [
+ "NetworkStackApiStableLib",
+ "androidx.test.rules",
+ "frameworks-base-testutils",
+ "mockito-target-extended-minus-junit4",
+ "net-tests-utils",
+ "testables",
+ ],
+ libs: [
+ "android.test.runner",
+ "android.test.base",
+ "android.test.mock",
+ ],
+}
diff --git a/packages/Tethering/tests/integration/AndroidManifest.xml b/packages/Tethering/tests/integration/AndroidManifest.xml
new file mode 100644
index 0000000..233ba40
--- /dev/null
+++ b/packages/Tethering/tests/integration/AndroidManifest.xml
@@ -0,0 +1,29 @@
+<?xml version="1.0" encoding="utf-8"?>
+<!-- Copyright (C) 2020 The Android Open Source Project
+
+ Licensed under the Apache License, Version 2.0 (the "License");
+ you may not use this file except in compliance with the License.
+ You may obtain a copy of the License at
+
+ http://www.apache.org/licenses/LICENSE-2.0
+
+ Unless required by applicable law or agreed to in writing, software
+ distributed under the License is distributed on an "AS IS" BASIS,
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ See the License for the specific language governing permissions and
+ limitations under the License.
+-->
+<manifest xmlns:android="http://schemas.android.com/apk/res/android"
+ package="com.android.networkstack.tethering.tests.integration">
+
+ <uses-permission android:name="android.permission.INTERNET"/>
+ <uses-permission android:name="android.permission.TETHER_PRIVILEGED"/>
+
+ <application android:debuggable="true">
+ <uses-library android:name="android.test.runner" />
+ </application>
+ <instrumentation android:name="androidx.test.runner.AndroidJUnitRunner"
+ android:targetPackage="com.android.networkstack.tethering.tests.integration"
+ android:label="Tethering integration tests">
+ </instrumentation>
+</manifest>
diff --git a/packages/Tethering/tests/integration/src/android/net/EthernetTetheringTest.java b/packages/Tethering/tests/integration/src/android/net/EthernetTetheringTest.java
new file mode 100644
index 0000000..492ce3d
--- /dev/null
+++ b/packages/Tethering/tests/integration/src/android/net/EthernetTetheringTest.java
@@ -0,0 +1,459 @@
+/*
+ * Copyright (C) 2020 The Android Open Source Project
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package android.net;
+
+import static android.Manifest.permission.MANAGE_TEST_NETWORKS;
+import static android.Manifest.permission.NETWORK_SETTINGS;
+
+import static org.junit.Assert.assertEquals;
+import static org.junit.Assert.assertNotNull;
+import static org.junit.Assert.assertNull;
+import static org.junit.Assert.assertTrue;
+import static org.junit.Assert.fail;
+import static org.junit.Assume.assumeFalse;
+import static org.junit.Assume.assumeTrue;
+
+import android.app.UiAutomation;
+import android.content.Context;
+import android.net.EthernetManager.TetheredInterfaceCallback;
+import android.net.EthernetManager.TetheredInterfaceRequest;
+import android.net.TetheringManager.StartTetheringCallback;
+import android.net.TetheringManager.TetheringEventCallback;
+import android.net.TetheringManager.TetheringRequest;
+import android.net.dhcp.DhcpAckPacket;
+import android.net.dhcp.DhcpOfferPacket;
+import android.net.dhcp.DhcpPacket;
+import android.os.Handler;
+import android.os.HandlerThread;
+import android.os.SystemClock;
+import android.system.Os;
+import android.util.Log;
+
+import androidx.test.InstrumentationRegistry;
+import androidx.test.filters.MediumTest;
+import androidx.test.runner.AndroidJUnit4;
+
+import com.android.testutils.HandlerUtilsKt;
+import com.android.testutils.TapPacketReader;
+
+import org.junit.After;
+import org.junit.Before;
+import org.junit.Test;
+import org.junit.runner.RunWith;
+
+import java.io.FileDescriptor;
+import java.net.Inet4Address;
+import java.net.NetworkInterface;
+import java.net.SocketException;
+import java.nio.ByteBuffer;
+import java.util.Collection;
+import java.util.List;
+import java.util.Random;
+import java.util.concurrent.CompletableFuture;
+import java.util.concurrent.CountDownLatch;
+import java.util.concurrent.TimeUnit;
+
+@RunWith(AndroidJUnit4.class)
+@MediumTest
+public class EthernetTetheringTest {
+
+ private static final String TAG = EthernetTetheringTest.class.getSimpleName();
+ private static final int TIMEOUT_MS = 1000;
+ private static final int PACKET_READ_TIMEOUT_MS = 100;
+ private static final int DHCP_DISCOVER_ATTEMPTS = 10;
+ private static final byte[] DHCP_REQUESTED_PARAMS = new byte[] {
+ DhcpPacket.DHCP_SUBNET_MASK,
+ DhcpPacket.DHCP_ROUTER,
+ DhcpPacket.DHCP_DNS_SERVER,
+ DhcpPacket.DHCP_LEASE_TIME,
+ };
+ private static final String DHCP_HOSTNAME = "testhostname";
+
+ private final Context mContext = InstrumentationRegistry.getContext();
+ private final EthernetManager mEm = mContext.getSystemService(EthernetManager.class);
+ private final TetheringManager mTm = mContext.getSystemService(TetheringManager.class);
+
+ private TestNetworkInterface mTestIface;
+ private HandlerThread mHandlerThread;
+ private Handler mHandler;
+ private TapPacketReader mTapPacketReader;
+
+ private TetheredInterfaceRequester mTetheredInterfaceRequester;
+ private MyTetheringEventCallback mTetheringEventCallback;
+
+ private UiAutomation mUiAutomation =
+ InstrumentationRegistry.getInstrumentation().getUiAutomation();
+
+ @Before
+ public void setUp() throws Exception {
+ mHandlerThread = new HandlerThread(getClass().getSimpleName());
+ mHandlerThread.start();
+ mHandler = new Handler(mHandlerThread.getLooper());
+ mTetheredInterfaceRequester = new TetheredInterfaceRequester(mHandler, mEm);
+ // Needed to create a TestNetworkInterface, to call requestTetheredInterface, and to receive
+ // tethered client callbacks.
+ mUiAutomation.adoptShellPermissionIdentity(MANAGE_TEST_NETWORKS, NETWORK_SETTINGS);
+ }
+
+ private void cleanUp() throws Exception {
+ mTm.stopTethering(TetheringManager.TETHERING_ETHERNET);
+ if (mTetheringEventCallback != null) {
+ mTetheringEventCallback.awaitInterfaceUntethered();
+ mTetheringEventCallback.unregister();
+ mTetheringEventCallback = null;
+ }
+ if (mTapPacketReader != null) {
+ TapPacketReader reader = mTapPacketReader;
+ mHandler.post(() -> reader.stop());
+ mTapPacketReader = null;
+ }
+ mHandlerThread.quitSafely();
+ mTetheredInterfaceRequester.release();
+ mEm.setIncludeTestInterfaces(false);
+ maybeDeleteTestInterface();
+ }
+
+ @After
+ public void tearDown() throws Exception {
+ try {
+ cleanUp();
+ } finally {
+ mUiAutomation.dropShellPermissionIdentity();
+ }
+ }
+
+ @Test
+ public void testVirtualEthernetAlreadyExists() throws Exception {
+ // This test requires manipulating packets. Skip if there is a physical Ethernet connected.
+ assumeFalse(mEm.isAvailable());
+
+ mTestIface = createTestInterface();
+ // This must be done now because as soon as setIncludeTestInterfaces(true) is called, the
+ // interface will be placed in client mode, which will delete the link-local address.
+ // At that point NetworkInterface.getByName() will cease to work on the interface, because
+ // starting in R NetworkInterface can no longer see interfaces without IP addresses.
+ int mtu = getMTU(mTestIface);
+
+ Log.d(TAG, "Including test interfaces");
+ mEm.setIncludeTestInterfaces(true);
+
+ final String iface = mTetheredInterfaceRequester.getInterface();
+ assertEquals("TetheredInterfaceCallback for unexpected interface",
+ mTestIface.getInterfaceName(), iface);
+
+ checkVirtualEthernet(mTestIface, mtu);
+ }
+
+ @Test
+ public void testVirtualEthernet() throws Exception {
+ // This test requires manipulating packets. Skip if there is a physical Ethernet connected.
+ assumeFalse(mEm.isAvailable());
+
+ CompletableFuture<String> futureIface = mTetheredInterfaceRequester.requestInterface();
+
+ mEm.setIncludeTestInterfaces(true);
+
+ mTestIface = createTestInterface();
+
+ final String iface = futureIface.get(TIMEOUT_MS, TimeUnit.MILLISECONDS);
+ assertEquals("TetheredInterfaceCallback for unexpected interface",
+ mTestIface.getInterfaceName(), iface);
+
+ checkVirtualEthernet(mTestIface, getMTU(mTestIface));
+ }
+
+ @Test
+ public void testPhysicalEthernet() throws Exception {
+ assumeTrue(mEm.isAvailable());
+
+ // Get an interface to use.
+ final String iface = mTetheredInterfaceRequester.getInterface();
+
+ // Enable Ethernet tethering and check that it starts.
+ mTetheringEventCallback = enableEthernetTethering(iface);
+
+ // There is nothing more we can do on a physical interface without connecting an actual
+ // client, which is not possible in this test.
+ }
+
+ private static final class MyTetheringEventCallback implements TetheringEventCallback {
+ private final TetheringManager mTm;
+ private final CountDownLatch mTetheringStartedLatch = new CountDownLatch(1);
+ private final CountDownLatch mTetheringStoppedLatch = new CountDownLatch(1);
+ private final CountDownLatch mClientConnectedLatch = new CountDownLatch(1);
+ private final String mIface;
+
+ private volatile boolean mInterfaceWasTethered = false;
+ private volatile boolean mUnregistered = false;
+ private volatile Collection<TetheredClient> mClients = null;
+
+ MyTetheringEventCallback(TetheringManager tm, String iface) {
+ mTm = tm;
+ mIface = iface;
+ }
+
+ public void unregister() {
+ mTm.unregisterTetheringEventCallback(this);
+ mUnregistered = true;
+ }
+
+ @Override
+ public void onTetheredInterfacesChanged(List<String> interfaces) {
+ // Ignore stale callbacks registered by previous test cases.
+ if (mUnregistered) return;
+
+ final boolean wasTethered = mTetheringStartedLatch.getCount() == 0;
+ if (!mInterfaceWasTethered && (mIface == null || interfaces.contains(mIface))) {
+ // This interface is being tethered for the first time.
+ Log.d(TAG, "Tethering started: " + interfaces);
+ mInterfaceWasTethered = true;
+ mTetheringStartedLatch.countDown();
+ } else if (mInterfaceWasTethered && !interfaces.contains(mIface)) {
+ Log.d(TAG, "Tethering stopped: " + interfaces);
+ mTetheringStoppedLatch.countDown();
+ }
+ }
+
+ public void awaitInterfaceTethered() throws Exception {
+ assertTrue("Ethernet not tethered after " + TIMEOUT_MS + "ms",
+ mTetheringStartedLatch.await(TIMEOUT_MS, TimeUnit.MILLISECONDS));
+ }
+
+ public void awaitInterfaceUntethered() throws Exception {
+ // Don't block teardown if the interface was never tethered.
+ // This is racy because the interface might become tethered right after this check, but
+ // that can only happen in tearDown if startTethering timed out, which likely means
+ // the test has already failed.
+ if (!mInterfaceWasTethered) return;
+
+ assertTrue(mIface + " not untethered after " + TIMEOUT_MS + "ms",
+ mTetheringStoppedLatch.await(TIMEOUT_MS, TimeUnit.MILLISECONDS));
+ }
+
+ @Override
+ public void onError(String ifName, int error) {
+ // Ignore stale callbacks registered by previous test cases.
+ if (mUnregistered) return;
+
+ fail("TetheringEventCallback got error:" + error + " on iface " + ifName);
+ }
+
+ @Override
+ public void onClientsChanged(Collection<TetheredClient> clients) {
+ // Ignore stale callbacks registered by previous test cases.
+ if (mUnregistered) return;
+
+ Log.d(TAG, "Got clients changed: " + clients);
+ mClients = clients;
+ if (clients.size() > 0) {
+ mClientConnectedLatch.countDown();
+ }
+ }
+
+ public Collection<TetheredClient> awaitClientConnected() throws Exception {
+ assertTrue("Did not receive client connected callback after " + TIMEOUT_MS + "ms",
+ mClientConnectedLatch.await(TIMEOUT_MS, TimeUnit.MILLISECONDS));
+ return mClients;
+ }
+ }
+
+ private MyTetheringEventCallback enableEthernetTethering(String iface) throws Exception {
+ MyTetheringEventCallback callback = new MyTetheringEventCallback(mTm, iface);
+ mTm.registerTetheringEventCallback(mHandler::post, callback);
+
+ StartTetheringCallback startTetheringCallback = new StartTetheringCallback() {
+ @Override
+ public void onTetheringFailed(int resultCode) {
+ fail("Unexpectedly got onTetheringFailed");
+ }
+ };
+ Log.d(TAG, "Starting Ethernet tethering");
+ mTm.startTethering(
+ new TetheringRequest.Builder(TetheringManager.TETHERING_ETHERNET).build(),
+ mHandler::post /* executor */, startTetheringCallback);
+ callback.awaitInterfaceTethered();
+ return callback;
+ }
+
+ private int getMTU(TestNetworkInterface iface) throws SocketException {
+ NetworkInterface nif = NetworkInterface.getByName(iface.getInterfaceName());
+ assertNotNull("Can't get NetworkInterface object for " + iface.getInterfaceName(), nif);
+ return nif.getMTU();
+ }
+
+ private void checkVirtualEthernet(TestNetworkInterface iface, int mtu) throws Exception {
+ FileDescriptor fd = iface.getFileDescriptor().getFileDescriptor();
+ mTapPacketReader = new TapPacketReader(mHandler, fd, mtu);
+ mHandler.post(() -> mTapPacketReader.start());
+ HandlerUtilsKt.waitForIdle(mHandler, TIMEOUT_MS);
+
+ mTetheringEventCallback = enableEthernetTethering(iface.getInterfaceName());
+ checkTetheredClientCallbacks(fd);
+ }
+
+ private void checkTetheredClientCallbacks(FileDescriptor fd) throws Exception {
+ // Create a fake client.
+ byte[] clientMacAddr = new byte[6];
+ new Random().nextBytes(clientMacAddr);
+
+ // We have to retransmit DHCP requests because IpServer declares itself to be ready before
+ // its DhcpServer is actually started. TODO: fix this race and remove this loop.
+ DhcpPacket offerPacket = null;
+ for (int i = 0; i < DHCP_DISCOVER_ATTEMPTS; i++) {
+ Log.d(TAG, "Sending DHCP discover");
+ sendDhcpDiscover(fd, clientMacAddr);
+ offerPacket = getNextDhcpPacket();
+ if (offerPacket instanceof DhcpOfferPacket) break;
+ }
+ assertTrue("No DHCPOFFER received on interface within timeout",
+ offerPacket instanceof DhcpOfferPacket);
+
+ sendDhcpRequest(fd, offerPacket, clientMacAddr);
+ DhcpPacket ackPacket = getNextDhcpPacket();
+ assertTrue("No DHCPACK received on interface within timeout",
+ ackPacket instanceof DhcpAckPacket);
+
+ final Collection<TetheredClient> clients = mTetheringEventCallback.awaitClientConnected();
+ assertEquals(1, clients.size());
+ final TetheredClient client = clients.iterator().next();
+
+ // Check the MAC address.
+ assertEquals(MacAddress.fromBytes(clientMacAddr), client.getMacAddress());
+ assertEquals(TetheringManager.TETHERING_ETHERNET, client.getTetheringType());
+
+ // Check the hostname.
+ assertEquals(1, client.getAddresses().size());
+ TetheredClient.AddressInfo info = client.getAddresses().get(0);
+ assertEquals(DHCP_HOSTNAME, info.getHostname());
+
+ // Check the address is the one that was handed out in the DHCP ACK.
+ DhcpResults dhcpResults = offerPacket.toDhcpResults();
+ assertLinkAddressMatches(dhcpResults.ipAddress, info.getAddress());
+
+ // Check that the lifetime is correct +/- 10s.
+ final long now = SystemClock.elapsedRealtime();
+ final long actualLeaseDuration = (info.getAddress().getExpirationTime() - now) / 1000;
+ final String msg = String.format("IP address should have lifetime of %d, got %d",
+ dhcpResults.leaseDuration, actualLeaseDuration);
+ assertTrue(msg, Math.abs(dhcpResults.leaseDuration - actualLeaseDuration) < 10);
+ }
+
+ private DhcpPacket getNextDhcpPacket() throws ParseException {
+ byte[] packet;
+ while ((packet = mTapPacketReader.popPacket(PACKET_READ_TIMEOUT_MS)) != null) {
+ try {
+ return DhcpPacket.decodeFullPacket(packet, packet.length, DhcpPacket.ENCAP_L2);
+ } catch (DhcpPacket.ParseException e) {
+ // Not a DHCP packet. Continue.
+ }
+ }
+ return null;
+ }
+
+ private static final class TetheredInterfaceRequester implements TetheredInterfaceCallback {
+ private final CountDownLatch mInterfaceAvailableLatch = new CountDownLatch(1);
+ private final Handler mHandler;
+ private final EthernetManager mEm;
+
+ private TetheredInterfaceRequest mRequest;
+ private final CompletableFuture<String> mFuture = new CompletableFuture<>();
+
+ TetheredInterfaceRequester(Handler handler, EthernetManager em) {
+ mHandler = handler;
+ mEm = em;
+ }
+
+ @Override
+ public void onAvailable(String iface) {
+ Log.d(TAG, "Ethernet interface available: " + iface);
+ mFuture.complete(iface);
+ }
+
+ @Override
+ public void onUnavailable() {
+ mFuture.completeExceptionally(new IllegalStateException("onUnavailable received"));
+ }
+
+ public CompletableFuture<String> requestInterface() {
+ assertNull("BUG: more than one tethered interface request", mRequest);
+ Log.d(TAG, "Requesting tethered interface");
+ mRequest = mEm.requestTetheredInterface(mHandler::post, this);
+ return mFuture;
+ }
+
+ public String getInterface() throws Exception {
+ return requestInterface().get(TIMEOUT_MS, TimeUnit.MILLISECONDS);
+ }
+
+ public void release() {
+ if (mRequest != null) {
+ mFuture.obtrudeException(new IllegalStateException("Request already released"));
+ mRequest.release();
+ mRequest = null;
+ }
+ }
+ }
+
+ private void sendDhcpDiscover(FileDescriptor fd, byte[] macAddress) throws Exception {
+ ByteBuffer packet = DhcpPacket.buildDiscoverPacket(DhcpPacket.ENCAP_L2,
+ new Random().nextInt() /* transactionId */, (short) 0 /* secs */,
+ macAddress, false /* unicast */, DHCP_REQUESTED_PARAMS,
+ false /* rapid commit */, DHCP_HOSTNAME);
+ sendPacket(fd, packet);
+ }
+
+ private void sendDhcpRequest(FileDescriptor fd, DhcpPacket offerPacket, byte[] macAddress)
+ throws Exception {
+ DhcpResults results = offerPacket.toDhcpResults();
+ Inet4Address clientIp = (Inet4Address) results.ipAddress.getAddress();
+ Inet4Address serverIdentifier = results.serverAddress;
+ ByteBuffer packet = DhcpPacket.buildRequestPacket(DhcpPacket.ENCAP_L2,
+ 0 /* transactionId */, (short) 0 /* secs */, DhcpPacket.INADDR_ANY /* clientIp */,
+ false /* broadcast */, macAddress, clientIp /* requestedIpAddress */,
+ serverIdentifier, DHCP_REQUESTED_PARAMS, DHCP_HOSTNAME);
+ sendPacket(fd, packet);
+ }
+
+ private void sendPacket(FileDescriptor fd, ByteBuffer packet) throws Exception {
+ assertNotNull("Only tests on virtual interfaces can send packets", fd);
+ Os.write(fd, packet);
+ }
+
+ public void assertLinkAddressMatches(LinkAddress l1, LinkAddress l2) {
+ // Check all fields except the deprecation and expiry times.
+ String msg = String.format("LinkAddresses do not match. expected: %s actual: %s", l1, l2);
+ assertTrue(msg, l1.isSameAddressAs(l2));
+ assertEquals("LinkAddress flags do not match", l1.getFlags(), l2.getFlags());
+ assertEquals("LinkAddress scope does not match", l1.getScope(), l2.getScope());
+ }
+
+ private TestNetworkInterface createTestInterface() throws Exception {
+ TestNetworkManager tnm = mContext.getSystemService(TestNetworkManager.class);
+ TestNetworkInterface iface = tnm.createTapInterface();
+ Log.d(TAG, "Created test interface " + iface.getInterfaceName());
+ assertNotNull(NetworkInterface.getByName(iface.getInterfaceName()));
+ return iface;
+ }
+
+ private void maybeDeleteTestInterface() throws Exception {
+ if (mTestIface != null) {
+ mTestIface.getFileDescriptor().close();
+ Log.d(TAG, "Deleted test interface " + mTestIface.getInterfaceName());
+ mTestIface = null;
+ }
+ }
+}
diff --git a/packages/Tethering/tests/unit/src/android/net/dhcp/DhcpServingParamsParcelExtTest.java b/packages/Tethering/tests/unit/src/android/net/dhcp/DhcpServingParamsParcelExtTest.java
index e8add98..f8eb147 100644
--- a/packages/Tethering/tests/unit/src/android/net/dhcp/DhcpServingParamsParcelExtTest.java
+++ b/packages/Tethering/tests/unit/src/android/net/dhcp/DhcpServingParamsParcelExtTest.java
@@ -42,7 +42,9 @@
@SmallTest
public class DhcpServingParamsParcelExtTest {
private static final Inet4Address TEST_ADDRESS = inet4Addr("192.168.0.123");
+ private static final Inet4Address TEST_CLIENT_ADDRESS = inet4Addr("192.168.0.42");
private static final int TEST_ADDRESS_PARCELED = 0xc0a8007b;
+ private static final int TEST_CLIENT_ADDRESS_PARCELED = 0xc0a8002a;
private static final int TEST_PREFIX_LENGTH = 17;
private static final int TEST_LEASE_TIME_SECS = 120;
private static final int TEST_MTU = 1000;
@@ -105,6 +107,12 @@
assertFalse(mParcel.metered);
}
+ @Test
+ public void testSetClientAddr() {
+ mParcel.setSingleClientAddr(TEST_CLIENT_ADDRESS);
+ assertEquals(TEST_CLIENT_ADDRESS_PARCELED, mParcel.clientAddr);
+ }
+
private static Inet4Address inet4Addr(String addr) {
return (Inet4Address) parseNumericAddress(addr);
}
diff --git a/packages/Tethering/tests/unit/src/com/android/server/connectivity/tethering/TetheringTest.java b/packages/Tethering/tests/unit/src/com/android/server/connectivity/tethering/TetheringTest.java
index 0980514..a418c4a 100644
--- a/packages/Tethering/tests/unit/src/com/android/server/connectivity/tethering/TetheringTest.java
+++ b/packages/Tethering/tests/unit/src/com/android/server/connectivity/tethering/TetheringTest.java
@@ -38,6 +38,7 @@
import static android.net.TetheringManager.TETHER_HARDWARE_OFFLOAD_STARTED;
import static android.net.TetheringManager.TETHER_HARDWARE_OFFLOAD_STOPPED;
import static android.net.dhcp.IDhcpServer.STATUS_SUCCESS;
+import static android.net.shared.Inet4AddressUtils.intToInet4AddressHTH;
import static android.net.wifi.WifiManager.EXTRA_WIFI_AP_INTERFACE_NAME;
import static android.net.wifi.WifiManager.EXTRA_WIFI_AP_MODE;
import static android.net.wifi.WifiManager.EXTRA_WIFI_AP_STATE;
@@ -484,6 +485,7 @@
mServiceContext.registerReceiver(mBroadcastReceiver,
new IntentFilter(ACTION_TETHER_STATE_CHANGED));
mTethering = makeTethering();
+ mTethering.startStateMachineUpdaters();
verify(mStatsManager, times(1)).registerNetworkStatsProvider(anyString(), any());
verify(mNetd).registerUnsolicitedEventListener(any());
final ArgumentCaptor<PhoneStateListener> phoneListenerCaptor =
@@ -1653,10 +1655,13 @@
}
@Test
- public void testRequestStaticServerIp() throws Exception {
- final LinkAddress serverLinkAddr = new LinkAddress("192.168.20.1/24");
- final LinkAddress clientLinkAddr = new LinkAddress("192.168.20.42/24");
- final String serverAddr = "192.168.20.1";
+ public void testRequestStaticIp() throws Exception {
+ final LinkAddress serverLinkAddr = new LinkAddress("192.168.0.123/24");
+ final LinkAddress clientLinkAddr = new LinkAddress("192.168.0.42/24");
+ final String serverAddr = "192.168.0.123";
+ final int clientAddrParceled = 0xc0a8002a;
+ final ArgumentCaptor<DhcpServingParamsParcel> dhcpParamsCaptor =
+ ArgumentCaptor.forClass(DhcpServingParamsParcel.class);
mTethering.startTethering(createTetheringRequestParcel(TETHERING_USB,
serverLinkAddr, clientLinkAddr), null);
mLooper.dispatchAll();
@@ -1665,8 +1670,12 @@
sendUsbBroadcast(true, true, true, TETHERING_USB);
mLooper.dispatchAll();
verify(mNetd).interfaceSetCfg(argThat(cfg -> serverAddr.equals(cfg.ipv4Addr)));
-
- // TODO: test static client address.
+ verify(mIpServerDependencies, times(1)).makeDhcpServer(any(), dhcpParamsCaptor.capture(),
+ any());
+ final DhcpServingParamsParcel params = dhcpParamsCaptor.getValue();
+ assertEquals(serverAddr, intToInet4AddressHTH(params.serverAddr).getHostAddress());
+ assertEquals(24, params.serverAddrPrefixLength);
+ assertEquals(clientAddrParceled, params.clientAddr);
}
// TODO: Test that a request for hotspot mode doesn't interfere with an
diff --git a/services/Android.bp b/services/Android.bp
index 1ab2395..8af642c 100644
--- a/services/Android.bp
+++ b/services/Android.bp
@@ -75,10 +75,6 @@
"framework-tethering-stubs-module_libs_api",
],
- plugins: [
- "compat-changeid-annotation-processor",
- ],
-
// Uncomment to enable output of certain warnings (deprecated, unchecked)
//javacflags: ["-Xlint"],
@@ -94,8 +90,8 @@
}
platform_compat_config {
- name: "services-platform-compat-config",
- src: ":services",
+ name: "services-platform-compat-config",
+ src: ":services",
}
filegroup {
@@ -120,6 +116,7 @@
" --hide DeprecationMismatch" +
" --hide HiddenTypedefConstant",
visibility: ["//visibility:private"],
+ filter_packages: ["com.android."],
check_api: {
current: {
api_file: "api/current.txt",
diff --git a/services/core/Android.bp b/services/core/Android.bp
index b7fd227..7a3a910 100644
--- a/services/core/Android.bp
+++ b/services/core/Android.bp
@@ -56,10 +56,6 @@
"dnsresolver_aidl_interface-V2-java",
"netd_event_listener_interface-java",
],
-
- plugins: [
- "compat-changeid-annotation-processor",
- ],
}
java_genrule {
diff --git a/services/core/java/com/android/server/AppStateTracker.java b/services/core/java/com/android/server/AppStateTracker.java
index 207e007..ecbf9a4 100644
--- a/services/core/java/com/android/server/AppStateTracker.java
+++ b/services/core/java/com/android/server/AppStateTracker.java
@@ -54,7 +54,6 @@
import com.android.internal.app.IAppOpsService;
import com.android.internal.util.ArrayUtils;
import com.android.internal.util.IndentingPrintWriter;
-import com.android.internal.util.Preconditions;
import com.android.internal.util.StatLogger;
import com.android.server.ForceAppStandbyTrackerProto.ExemptedPackage;
import com.android.server.ForceAppStandbyTrackerProto.RunAnyInBackgroundRestrictedPackages;
@@ -62,6 +61,7 @@
import java.io.PrintWriter;
import java.util.Arrays;
import java.util.List;
+import java.util.Objects;
/**
* Class to keep track of the information related to "force app standby", which includes:
@@ -416,12 +416,12 @@
}
mStarted = true;
- mIActivityManager = Preconditions.checkNotNull(injectIActivityManager());
- mActivityManagerInternal = Preconditions.checkNotNull(injectActivityManagerInternal());
- mAppOpsManager = Preconditions.checkNotNull(injectAppOpsManager());
- mAppOpsService = Preconditions.checkNotNull(injectIAppOpsService());
- mPowerManagerInternal = Preconditions.checkNotNull(injectPowerManagerInternal());
- mUsageStatsManagerInternal = Preconditions.checkNotNull(
+ mIActivityManager = Objects.requireNonNull(injectIActivityManager());
+ mActivityManagerInternal = Objects.requireNonNull(injectActivityManagerInternal());
+ mAppOpsManager = Objects.requireNonNull(injectAppOpsManager());
+ mAppOpsService = Objects.requireNonNull(injectIAppOpsService());
+ mPowerManagerInternal = Objects.requireNonNull(injectPowerManagerInternal());
+ mUsageStatsManagerInternal = Objects.requireNonNull(
injectUsageStatsManagerInternal());
mFlagsObserver = new FeatureFlagsObserver();
diff --git a/services/core/java/com/android/server/BluetoothManagerService.java b/services/core/java/com/android/server/BluetoothManagerService.java
index 11c1405..168c8cd 100644
--- a/services/core/java/com/android/server/BluetoothManagerService.java
+++ b/services/core/java/com/android/server/BluetoothManagerService.java
@@ -747,13 +747,7 @@
}
}
- public int updateBleAppCount(IBinder token, boolean enable, String packageName) {
- // Check if packageName belongs to callingUid
- final int callingUid = Binder.getCallingUid();
- final boolean isCallerSystem = UserHandle.getAppId(callingUid) == Process.SYSTEM_UID;
- if (!isCallerSystem) {
- checkPackage(callingUid, packageName);
- }
+ private int updateBleAppCount(IBinder token, boolean enable, String packageName) {
ClientDeathRecipient r = mBleApps.get(token);
if (r == null && enable) {
ClientDeathRecipient deathRec = new ClientDeathRecipient(packageName);
@@ -778,15 +772,96 @@
if (DBG) {
Slog.d(TAG, appCount + " registered Ble Apps");
}
- if (appCount == 0 && mEnable) {
- disableBleScanMode();
- }
- if (appCount == 0 && !mEnableExternal) {
- sendBrEdrDownCallback();
- }
return appCount;
}
+ private boolean checkBluetoothPermissions(String packageName, boolean requireForeground) {
+ if (isBluetoothDisallowed()) {
+ if (DBG) {
+ Slog.d(TAG, "checkBluetoothPermissions: bluetooth disallowed");
+ }
+ return false;
+ }
+ // Check if packageName belongs to callingUid
+ final int callingUid = Binder.getCallingUid();
+ final boolean isCallerSystem = UserHandle.getAppId(callingUid) == Process.SYSTEM_UID;
+ if (!isCallerSystem) {
+ checkPackage(callingUid, packageName);
+
+ if (requireForeground && !checkIfCallerIsForegroundUser()) {
+ Slog.w(TAG, "Not allowed for non-active and non system user");
+ return false;
+ }
+
+ mContext.enforceCallingOrSelfPermission(BLUETOOTH_ADMIN_PERM,
+ "Need BLUETOOTH ADMIN permission");
+ }
+ return true;
+ }
+
+ public boolean enableBle(String packageName, IBinder token) throws RemoteException {
+ if (!checkBluetoothPermissions(packageName, false)) {
+ if (DBG) {
+ Slog.d(TAG, "enableBle(): bluetooth disallowed");
+ }
+ return false;
+ }
+
+ if (DBG) {
+ Slog.d(TAG, "enableBle(" + packageName + "): mBluetooth =" + mBluetooth
+ + " mBinding = " + mBinding + " mState = "
+ + BluetoothAdapter.nameForState(mState));
+ }
+ updateBleAppCount(token, true, packageName);
+
+ if (mState == BluetoothAdapter.STATE_ON
+ || mState == BluetoothAdapter.STATE_BLE_ON
+ || mState == BluetoothAdapter.STATE_TURNING_ON
+ || mState == BluetoothAdapter.STATE_TURNING_OFF) {
+ Log.d(TAG, "enableBLE(): Bluetooth already enabled");
+ return true;
+ }
+ synchronized (mReceiver) {
+ // waive WRITE_SECURE_SETTINGS permission check
+ sendEnableMsg(false,
+ BluetoothProtoEnums.ENABLE_DISABLE_REASON_APPLICATION_REQUEST, packageName);
+ }
+ return true;
+ }
+
+ public boolean disableBle(String packageName, IBinder token) throws RemoteException {
+ if (!checkBluetoothPermissions(packageName, false)) {
+ if (DBG) {
+ Slog.d(TAG, "disableBLE(): bluetooth disallowed");
+ }
+ return false;
+ }
+
+ if (DBG) {
+ Slog.d(TAG, "disableBle(" + packageName + "): mBluetooth =" + mBluetooth
+ + " mBinding = " + mBinding + " mState = "
+ + BluetoothAdapter.nameForState(mState));
+ }
+
+ if (mState == BluetoothAdapter.STATE_OFF) {
+ Slog.d(TAG, "disableBLE(): Already disabled");
+ return false;
+ }
+ updateBleAppCount(token, false, packageName);
+
+ if (mState == BluetoothAdapter.STATE_BLE_ON && !isBleAppPresent()) {
+ if (mEnable) {
+ disableBleScanMode();
+ }
+ if (!mEnableExternal) {
+ addActiveLog(BluetoothProtoEnums.ENABLE_DISABLE_REASON_APPLICATION_REQUEST,
+ packageName, false);
+ sendBrEdrDownCallback();
+ }
+ }
+ return true;
+ }
+
// Clear all apps using BLE scan only mode.
private void clearBleApps() {
mBleApps.clear();
@@ -813,6 +888,13 @@
Slog.e(TAG, "onBluetoothServiceUp: mBluetooth is null!");
return;
}
+ if (!mEnableExternal && !isBleAppPresent() && isAirplaneModeOn()) {
+ // Airplane mode is turned on while enabling BLE only mode, disable
+ // BLE now.
+ disableBleScanMode();
+ sendBrEdrDownCallback();
+ return;
+ }
if (isBluetoothPersistedStateOnBluetooth() || !isBleAppPresent()) {
// This triggers transition to STATE_ON
mBluetooth.onLeServiceUp();
@@ -862,29 +944,19 @@
}
public boolean enableNoAutoConnect(String packageName) {
- if (isBluetoothDisallowed()) {
+ if (!checkBluetoothPermissions(packageName, false)) {
if (DBG) {
Slog.d(TAG, "enableNoAutoConnect(): not enabling - bluetooth disallowed");
}
return false;
}
- // Check if packageName belongs to callingUid
- final int callingUid = Binder.getCallingUid();
- final boolean isCallerSystem = UserHandle.getAppId(callingUid) == Process.SYSTEM_UID;
- if (!isCallerSystem) {
- checkPackage(callingUid, packageName);
- }
-
- mContext.enforceCallingOrSelfPermission(BLUETOOTH_ADMIN_PERM,
- "Need BLUETOOTH ADMIN permission");
-
if (DBG) {
Slog.d(TAG, "enableNoAutoConnect(): mBluetooth =" + mBluetooth + " mBinding = "
+ mBinding);
}
- int callingAppId = UserHandle.getAppId(callingUid);
+ int callingAppId = UserHandle.getAppId(Binder.getCallingUid());
if (callingAppId != Process.NFC_UID) {
throw new SecurityException("no permission to enable Bluetooth quietly");
}
@@ -899,32 +971,19 @@
}
public boolean enable(String packageName) throws RemoteException {
- final int callingUid = Binder.getCallingUid();
- final boolean callerSystem = UserHandle.getAppId(callingUid) == Process.SYSTEM_UID;
-
- if (isBluetoothDisallowed()) {
+ if (!checkBluetoothPermissions(packageName, true)) {
if (DBG) {
Slog.d(TAG, "enable(): not enabling - bluetooth disallowed");
}
return false;
}
- if (!callerSystem) {
- // Check if packageName belongs to callingUid
- checkPackage(callingUid, packageName);
-
- if (!checkIfCallerIsForegroundUser()) {
- Slog.w(TAG, "enable(): not allowed for non-active and non system user");
- return false;
- }
-
- mContext.enforceCallingOrSelfPermission(BLUETOOTH_ADMIN_PERM,
- "Need BLUETOOTH ADMIN permission");
-
- if (!isEnabled() && mWirelessConsentRequired && startConsentUiIfNeeded(packageName,
- callingUid, BluetoothAdapter.ACTION_REQUEST_ENABLE)) {
- return false;
- }
+ final int callingUid = Binder.getCallingUid();
+ final boolean callerSystem = UserHandle.getAppId(callingUid) == Process.SYSTEM_UID;
+ if (!callerSystem && !isEnabled() && mWirelessConsentRequired
+ && startConsentUiIfNeeded(packageName,
+ callingUid, BluetoothAdapter.ACTION_REQUEST_ENABLE)) {
+ return false;
}
if (DBG) {
@@ -946,25 +1005,19 @@
}
public boolean disable(String packageName, boolean persist) throws RemoteException {
+ if (!checkBluetoothPermissions(packageName, true)) {
+ if (DBG) {
+ Slog.d(TAG, "disable(): not disabling - bluetooth disallowed");
+ }
+ return false;
+ }
+
final int callingUid = Binder.getCallingUid();
final boolean callerSystem = UserHandle.getAppId(callingUid) == Process.SYSTEM_UID;
-
- if (!callerSystem) {
- // Check if packageName belongs to callingUid
- checkPackage(callingUid, packageName);
-
- if (!checkIfCallerIsForegroundUser()) {
- Slog.w(TAG, "disable(): not allowed for non-active and non system user");
- return false;
- }
-
- mContext.enforceCallingOrSelfPermission(BLUETOOTH_ADMIN_PERM,
- "Need BLUETOOTH ADMIN permission");
-
- if (isEnabled() && mWirelessConsentRequired && startConsentUiIfNeeded(packageName,
- callingUid, BluetoothAdapter.ACTION_REQUEST_DISABLE)) {
- return false;
- }
+ if (!callerSystem && isEnabled() && mWirelessConsentRequired
+ && startConsentUiIfNeeded(packageName,
+ callingUid, BluetoothAdapter.ACTION_REQUEST_DISABLE)) {
+ return false;
}
if (DBG) {
diff --git a/services/core/java/com/android/server/ConnectivityService.java b/services/core/java/com/android/server/ConnectivityService.java
index 1309740..0b024e7 100644
--- a/services/core/java/com/android/server/ConnectivityService.java
+++ b/services/core/java/com/android/server/ConnectivityService.java
@@ -49,8 +49,6 @@
import static android.system.OsConstants.IPPROTO_TCP;
import static android.system.OsConstants.IPPROTO_UDP;
-import static com.android.internal.util.Preconditions.checkNotNull;
-
import static java.util.Map.Entry;
import android.Manifest;
@@ -65,6 +63,7 @@
import android.content.Context;
import android.content.Intent;
import android.content.IntentFilter;
+import android.content.pm.PackageManager;
import android.content.res.Configuration;
import android.database.ContentObserver;
import android.net.CaptivePortal;
@@ -654,8 +653,8 @@
final MultipathPolicyTracker mMultipathPolicyTracker;
@VisibleForTesting
- final Map<IConnectivityDiagnosticsCallback, ConnectivityDiagnosticsCallbackInfo>
- mConnectivityDiagnosticsCallbacks = new HashMap<>();
+ final Map<IBinder, ConnectivityDiagnosticsCallbackInfo> mConnectivityDiagnosticsCallbacks =
+ new HashMap<>();
/**
* Implements support for the legacy "one network per network type" model.
@@ -929,7 +928,7 @@
* @see IpConnectivityMetrics.Logger
*/
public IpConnectivityMetrics.Logger getMetricsLogger() {
- return checkNotNull(LocalServices.getService(IpConnectivityMetrics.Logger.class),
+ return Objects.requireNonNull(LocalServices.getService(IpConnectivityMetrics.Logger.class),
"no IpConnectivityMetrics service");
}
@@ -958,10 +957,10 @@
IDnsResolver dnsresolver, IpConnectivityLog logger, INetd netd, Dependencies deps) {
if (DBG) log("ConnectivityService starting up");
- mDeps = checkNotNull(deps, "missing Dependencies");
+ mDeps = Objects.requireNonNull(deps, "missing Dependencies");
mSystemProperties = mDeps.getSystemProperties();
mNetIdManager = mDeps.makeNetIdManager();
- mContext = checkNotNull(context, "missing Context");
+ mContext = Objects.requireNonNull(context, "missing Context");
mMetricsLog = logger;
mDefaultRequest = createDefaultInternetRequestForTransport(-1, NetworkRequest.Type.REQUEST);
@@ -991,13 +990,13 @@
mLingerDelayMs = mSystemProperties.getInt(LINGER_DELAY_PROPERTY, DEFAULT_LINGER_DELAY_MS);
- mNMS = checkNotNull(netManager, "missing INetworkManagementService");
- mStatsService = checkNotNull(statsService, "missing INetworkStatsService");
- mPolicyManager = checkNotNull(policyManager, "missing INetworkPolicyManager");
- mPolicyManagerInternal = checkNotNull(
+ mNMS = Objects.requireNonNull(netManager, "missing INetworkManagementService");
+ mStatsService = Objects.requireNonNull(statsService, "missing INetworkStatsService");
+ mPolicyManager = Objects.requireNonNull(policyManager, "missing INetworkPolicyManager");
+ mPolicyManagerInternal = Objects.requireNonNull(
LocalServices.getService(NetworkPolicyManagerInternal.class),
"missing NetworkPolicyManagerInternal");
- mDnsResolver = checkNotNull(dnsresolver, "missing IDnsResolver");
+ mDnsResolver = Objects.requireNonNull(dnsresolver, "missing IDnsResolver");
mProxyTracker = mDeps.makeProxyTracker(mContext, mHandler);
mNetd = netd;
@@ -5333,7 +5332,7 @@
// specific SSID/SignalStrength, or the calling app has permission to do so.
private void ensureSufficientPermissionsForRequest(NetworkCapabilities nc,
int callerPid, int callerUid, String callerPackageName) {
- if (null != nc.getSSID() && !checkSettingsPermission(callerPid, callerUid)) {
+ if (null != nc.getSsid() && !checkSettingsPermission(callerPid, callerUid)) {
throw new SecurityException("Insufficient permissions to request a specific SSID");
}
@@ -5398,12 +5397,25 @@
}
}
+ private boolean checkUnsupportedStartingFrom(int version, String callingPackageName) {
+ final PackageManager pm = mContext.getPackageManager();
+ final int userId = UserHandle.getCallingUserId();
+ try {
+ final int callingVersion = pm.getApplicationInfoAsUser(
+ callingPackageName, 0 /* flags */, userId).targetSdkVersion;
+ if (callingVersion < version) return false;
+ } catch (PackageManager.NameNotFoundException e) { }
+ return true;
+ }
+
@Override
public NetworkRequest requestNetwork(NetworkCapabilities networkCapabilities,
Messenger messenger, int timeoutMs, IBinder binder, int legacyType,
@NonNull String callingPackageName) {
if (legacyType != TYPE_NONE && !checkNetworkStackPermission()) {
- throw new SecurityException("Insufficient permissions to specify legacy type");
+ if (checkUnsupportedStartingFrom(Build.VERSION_CODES.M, callingPackageName)) {
+ throw new SecurityException("Insufficient permissions to specify legacy type");
+ }
}
final int callingUid = Binder.getCallingUid();
final NetworkRequest.Type type = (networkCapabilities == null)
@@ -5508,7 +5520,7 @@
@Override
public NetworkRequest pendingRequestForNetwork(NetworkCapabilities networkCapabilities,
PendingIntent operation, @NonNull String callingPackageName) {
- checkNotNull(operation, "PendingIntent cannot be null.");
+ Objects.requireNonNull(operation, "PendingIntent cannot be null.");
final int callingUid = Binder.getCallingUid();
networkCapabilities = new NetworkCapabilities(networkCapabilities);
enforceNetworkRequestPermissions(networkCapabilities);
@@ -5537,7 +5549,7 @@
@Override
public void releasePendingNetworkRequest(PendingIntent operation) {
- checkNotNull(operation, "PendingIntent cannot be null.");
+ Objects.requireNonNull(operation, "PendingIntent cannot be null.");
mHandler.sendMessage(mHandler.obtainMessage(EVENT_RELEASE_NETWORK_REQUEST_WITH_INTENT,
getCallingUid(), 0, operation));
}
@@ -5596,7 +5608,7 @@
@Override
public void pendingListenForNetwork(NetworkCapabilities networkCapabilities,
PendingIntent operation, @NonNull String callingPackageName) {
- checkNotNull(operation, "PendingIntent cannot be null.");
+ Objects.requireNonNull(operation, "PendingIntent cannot be null.");
final int callingUid = Binder.getCallingUid();
if (!hasWifiNetworkListenPermission(networkCapabilities)) {
enforceAccessPermission();
@@ -5805,7 +5817,7 @@
nai.getAndSetNetworkCapabilities(mixInCapabilities(nai, nc));
final String extraInfo = networkInfo.getExtraInfo();
final String name = TextUtils.isEmpty(extraInfo)
- ? nai.networkCapabilities.getSSID() : extraInfo;
+ ? nai.networkCapabilities.getSsid() : extraInfo;
if (DBG) log("registerNetworkAgent " + nai);
final long token = Binder.clearCallingIdentity();
try {
@@ -7814,11 +7826,12 @@
ensureRunningOnConnectivityServiceThread();
final IConnectivityDiagnosticsCallback cb = cbInfo.mCb;
+ final IBinder iCb = cb.asBinder();
final NetworkRequestInfo nri = cbInfo.mRequestInfo;
// This means that the client registered the same callback multiple times. Do
// not override the previous entry, and exit silently.
- if (mConnectivityDiagnosticsCallbacks.containsKey(cb)) {
+ if (mConnectivityDiagnosticsCallbacks.containsKey(iCb)) {
if (VDBG) log("Diagnostics callback is already registered");
// Decrement the reference count for this NetworkRequestInfo. The reference count is
@@ -7828,40 +7841,75 @@
return;
}
- mConnectivityDiagnosticsCallbacks.put(cb, cbInfo);
+ mConnectivityDiagnosticsCallbacks.put(iCb, cbInfo);
try {
- cb.asBinder().linkToDeath(cbInfo, 0);
+ iCb.linkToDeath(cbInfo, 0);
} catch (RemoteException e) {
cbInfo.binderDied();
+ return;
+ }
+
+ // Once registered, provide ConnectivityReports for matching Networks
+ final List<NetworkAgentInfo> matchingNetworks = new ArrayList<>();
+ synchronized (mNetworkForNetId) {
+ for (int i = 0; i < mNetworkForNetId.size(); i++) {
+ final NetworkAgentInfo nai = mNetworkForNetId.valueAt(i);
+ if (nai.satisfies(nri.request)) {
+ matchingNetworks.add(nai);
+ }
+ }
+ }
+ for (final NetworkAgentInfo nai : matchingNetworks) {
+ final ConnectivityReport report = nai.getConnectivityReport();
+ if (report == null) {
+ continue;
+ }
+ if (!checkConnectivityDiagnosticsPermissions(
+ nri.mPid, nri.mUid, nai, cbInfo.mCallingPackageName)) {
+ continue;
+ }
+
+ try {
+ cb.onConnectivityReportAvailable(report);
+ } catch (RemoteException e) {
+ // Exception while sending the ConnectivityReport. Move on to the next network.
+ }
}
}
private void handleUnregisterConnectivityDiagnosticsCallback(
@NonNull IConnectivityDiagnosticsCallback cb, int uid) {
ensureRunningOnConnectivityServiceThread();
+ final IBinder iCb = cb.asBinder();
- if (!mConnectivityDiagnosticsCallbacks.containsKey(cb)) {
+ final ConnectivityDiagnosticsCallbackInfo cbInfo =
+ mConnectivityDiagnosticsCallbacks.remove(iCb);
+ if (cbInfo == null) {
if (VDBG) log("Removing diagnostics callback that is not currently registered");
return;
}
- final NetworkRequestInfo nri = mConnectivityDiagnosticsCallbacks.get(cb).mRequestInfo;
+ final NetworkRequestInfo nri = cbInfo.mRequestInfo;
if (uid != nri.mUid) {
if (VDBG) loge("Different uid than registrant attempting to unregister cb");
return;
}
- cb.asBinder().unlinkToDeath(mConnectivityDiagnosticsCallbacks.remove(cb), 0);
+ // Decrement the reference count for this NetworkRequestInfo. The reference count is
+ // incremented when the NetworkRequestInfo is created as part of
+ // enforceRequestCountLimit().
+ decrementNetworkRequestPerUidCount(nri);
+
+ iCb.unlinkToDeath(cbInfo, 0);
}
private void handleNetworkTestedWithExtras(
@NonNull ConnectivityReportEvent reportEvent, @NonNull PersistableBundle extras) {
final NetworkAgentInfo nai = reportEvent.mNai;
final NetworkCapabilities networkCapabilities =
- new NetworkCapabilities(nai.networkCapabilities);
- clearNetworkCapabilitiesUids(networkCapabilities);
+ getNetworkCapabilitiesWithoutUids(nai.networkCapabilities);
final ConnectivityReport report =
new ConnectivityReport(
reportEvent.mNai.network,
@@ -7869,6 +7917,7 @@
nai.linkProperties,
networkCapabilities,
extras);
+ nai.setConnectivityReport(report);
final List<IConnectivityDiagnosticsCallback> results =
getMatchingPermissionedCallbacks(nai);
for (final IConnectivityDiagnosticsCallback cb : results) {
@@ -7884,8 +7933,7 @@
@NonNull NetworkAgentInfo nai, long timestampMillis, int detectionMethod,
@NonNull PersistableBundle extras) {
final NetworkCapabilities networkCapabilities =
- new NetworkCapabilities(nai.networkCapabilities);
- clearNetworkCapabilitiesUids(networkCapabilities);
+ getNetworkCapabilitiesWithoutUids(nai.networkCapabilities);
final DataStallReport report =
new DataStallReport(
nai.network,
@@ -7918,23 +7966,25 @@
}
}
- private void clearNetworkCapabilitiesUids(@NonNull NetworkCapabilities nc) {
- nc.setUids(null);
- nc.setAdministratorUids(new int[0]);
- nc.setOwnerUid(Process.INVALID_UID);
+ private NetworkCapabilities getNetworkCapabilitiesWithoutUids(@NonNull NetworkCapabilities nc) {
+ final NetworkCapabilities sanitized = new NetworkCapabilities(nc);
+ sanitized.setUids(null);
+ sanitized.setAdministratorUids(new int[0]);
+ sanitized.setOwnerUid(Process.INVALID_UID);
+ return sanitized;
}
private List<IConnectivityDiagnosticsCallback> getMatchingPermissionedCallbacks(
@NonNull NetworkAgentInfo nai) {
final List<IConnectivityDiagnosticsCallback> results = new ArrayList<>();
- for (Entry<IConnectivityDiagnosticsCallback, ConnectivityDiagnosticsCallbackInfo> entry :
+ for (Entry<IBinder, ConnectivityDiagnosticsCallbackInfo> entry :
mConnectivityDiagnosticsCallbacks.entrySet()) {
final ConnectivityDiagnosticsCallbackInfo cbInfo = entry.getValue();
final NetworkRequestInfo nri = cbInfo.mRequestInfo;
if (nai.satisfies(nri.request)) {
if (checkConnectivityDiagnosticsPermissions(
nri.mPid, nri.mUid, nai, cbInfo.mCallingPackageName)) {
- results.add(entry.getKey());
+ results.add(entry.getValue().mCb);
}
}
}
@@ -7971,11 +8021,7 @@
// Administrator UIDs also contains the Owner UID
final int[] administratorUids = nai.networkCapabilities.getAdministratorUids();
- for (final int uid : administratorUids) {
- if (uid == callbackUid) return true;
- }
-
- return false;
+ return ArrayUtils.contains(administratorUids, callbackUid);
}
@Override
diff --git a/services/core/java/com/android/server/ExplicitHealthCheckController.java b/services/core/java/com/android/server/ExplicitHealthCheckController.java
index f7c4aac..77059d9 100644
--- a/services/core/java/com/android/server/ExplicitHealthCheckController.java
+++ b/services/core/java/com/android/server/ExplicitHealthCheckController.java
@@ -47,6 +47,7 @@
import java.util.Collections;
import java.util.Iterator;
import java.util.List;
+import java.util.Objects;
import java.util.Set;
import java.util.function.Consumer;
@@ -113,9 +114,9 @@
Slog.wtf(TAG, "Resetting health check controller callbacks");
}
- mPassedConsumer = Preconditions.checkNotNull(passedConsumer);
- mSupportedConsumer = Preconditions.checkNotNull(supportedConsumer);
- mNotifySyncRunnable = Preconditions.checkNotNull(notifySyncRunnable);
+ mPassedConsumer = Objects.requireNonNull(passedConsumer);
+ mSupportedConsumer = Objects.requireNonNull(supportedConsumer);
+ mNotifySyncRunnable = Objects.requireNonNull(notifySyncRunnable);
}
}
diff --git a/services/core/java/com/android/server/IpSecService.java b/services/core/java/com/android/server/IpSecService.java
index 424407a..905c489 100644
--- a/services/core/java/com/android/server/IpSecService.java
+++ b/services/core/java/com/android/server/IpSecService.java
@@ -25,8 +25,6 @@
import static android.system.OsConstants.IPPROTO_UDP;
import static android.system.OsConstants.SOCK_DGRAM;
-import static com.android.internal.util.Preconditions.checkNotNull;
-
import android.annotation.NonNull;
import android.app.AppOpsManager;
import android.content.Context;
@@ -575,7 +573,7 @@
}
void put(int key, RefcountedResource<T> obj) {
- checkNotNull(obj, "Null resources cannot be added");
+ Objects.requireNonNull(obj, "Null resources cannot be added");
mArray.put(key, obj);
}
@@ -1114,7 +1112,7 @@
if (requestedSpi > 0 && requestedSpi < 256) {
throw new IllegalArgumentException("ESP SPI must not be in the range of 0-255.");
}
- checkNotNull(binder, "Null Binder passed to allocateSecurityParameterIndex");
+ Objects.requireNonNull(binder, "Null Binder passed to allocateSecurityParameterIndex");
int callingUid = Binder.getCallingUid();
UserRecord userRecord = mUserResourceTracker.getUserRecord(callingUid);
@@ -1231,7 +1229,7 @@
throw new IllegalArgumentException(
"Specified port number must be a valid non-reserved UDP port");
}
- checkNotNull(binder, "Null Binder passed to openUdpEncapsulationSocket");
+ Objects.requireNonNull(binder, "Null Binder passed to openUdpEncapsulationSocket");
int callingUid = Binder.getCallingUid();
UserRecord userRecord = mUserResourceTracker.getUserRecord(callingUid);
@@ -1291,8 +1289,8 @@
String localAddr, String remoteAddr, Network underlyingNetwork, IBinder binder,
String callingPackage) {
enforceTunnelFeatureAndPermissions(callingPackage);
- checkNotNull(binder, "Null Binder passed to createTunnelInterface");
- checkNotNull(underlyingNetwork, "No underlying network was specified");
+ Objects.requireNonNull(binder, "Null Binder passed to createTunnelInterface");
+ Objects.requireNonNull(underlyingNetwork, "No underlying network was specified");
checkInetAddress(localAddr);
checkInetAddress(remoteAddr);
@@ -1573,7 +1571,7 @@
"IPsec Tunnel Mode requires PackageManager.FEATURE_IPSEC_TUNNELS");
}
- checkNotNull(callingPackage, "Null calling package cannot create IpSec tunnels");
+ Objects.requireNonNull(callingPackage, "Null calling package cannot create IpSec tunnels");
// OP_MANAGE_IPSEC_TUNNELS will return MODE_ERRORED by default, including for the system
// server. If the appop is not granted, require that the caller has the MANAGE_IPSEC_TUNNELS
@@ -1642,12 +1640,12 @@
@Override
public synchronized IpSecTransformResponse createTransform(
IpSecConfig c, IBinder binder, String callingPackage) throws RemoteException {
- checkNotNull(c);
+ Objects.requireNonNull(c);
if (c.getMode() == IpSecTransform.MODE_TUNNEL) {
enforceTunnelFeatureAndPermissions(callingPackage);
}
checkIpSecConfig(c);
- checkNotNull(binder, "Null Binder passed to createTransform");
+ Objects.requireNonNull(binder, "Null Binder passed to createTransform");
final int resourceId = mNextResourceId++;
UserRecord userRecord = mUserResourceTracker.getUserRecord(Binder.getCallingUid());
diff --git a/services/core/java/com/android/server/LocationManagerService.java b/services/core/java/com/android/server/LocationManagerService.java
index 90e4670..f4b769f 100644
--- a/services/core/java/com/android/server/LocationManagerService.java
+++ b/services/core/java/com/android/server/LocationManagerService.java
@@ -25,7 +25,6 @@
import static android.os.PowerManager.locationPowerSaveModeToString;
import static android.provider.Settings.Global.LOCATION_DISABLE_STATUS_CALLBACKS;
-import static com.android.internal.util.Preconditions.checkNotNull;
import static com.android.internal.util.Preconditions.checkState;
import android.Manifest;
@@ -133,6 +132,7 @@
import java.util.List;
import java.util.Map;
import java.util.Map.Entry;
+import java.util.Objects;
import java.util.NoSuchElementException;
import java.util.function.Consumer;
import java.util.function.Function;
@@ -986,7 +986,7 @@
@GuardedBy("mLock")
public void attachLocked(AbstractLocationProvider provider) {
- checkNotNull(provider);
+ Objects.requireNonNull(provider);
checkState(mProvider == null);
if (D) {
diff --git a/services/core/java/com/android/server/NativeDaemonConnector.java b/services/core/java/com/android/server/NativeDaemonConnector.java
index ad02aad..eac767f 100644
--- a/services/core/java/com/android/server/NativeDaemonConnector.java
+++ b/services/core/java/com/android/server/NativeDaemonConnector.java
@@ -46,6 +46,7 @@
import java.util.concurrent.CountDownLatch;
import java.util.concurrent.TimeUnit;
import java.util.LinkedList;
+import java.util.Objects;
/**
* Generic connector class for interfacing with a native daemon which uses the
@@ -126,7 +127,7 @@
*/
public void setWarnIfHeld(Object warnIfHeld) {
Preconditions.checkState(mWarnIfHeld == null);
- mWarnIfHeld = Preconditions.checkNotNull(warnIfHeld);
+ mWarnIfHeld = Objects.requireNonNull(warnIfHeld);
}
@Override
diff --git a/services/core/java/com/android/server/NetworkManagementService.java b/services/core/java/com/android/server/NetworkManagementService.java
index 7d6ae21..1bb3c3a 100644
--- a/services/core/java/com/android/server/NetworkManagementService.java
+++ b/services/core/java/com/android/server/NetworkManagementService.java
@@ -111,6 +111,7 @@
import java.util.HashMap;
import java.util.List;
import java.util.Map;
+import java.util.Objects;
/**
* @hide
@@ -458,7 +459,7 @@
@Override
public void registerTetheringStatsProvider(ITetheringStatsProvider provider, String name) {
NetworkStack.checkNetworkStackPermission(mContext);
- Preconditions.checkNotNull(provider);
+ Objects.requireNonNull(provider);
synchronized(mTetheringStatsProviders) {
mTetheringStatsProviders.put(provider, name);
}
diff --git a/services/core/java/com/android/server/StorageManagerService.java b/services/core/java/com/android/server/StorageManagerService.java
index 39ad354..ddbc79a 100644
--- a/services/core/java/com/android/server/StorageManagerService.java
+++ b/services/core/java/com/android/server/StorageManagerService.java
@@ -1934,7 +1934,7 @@
public void setVolumeNickname(String fsUuid, String nickname) {
enforcePermission(android.Manifest.permission.MOUNT_UNMOUNT_FILESYSTEMS);
- Preconditions.checkNotNull(fsUuid);
+ Objects.requireNonNull(fsUuid);
synchronized (mLock) {
final VolumeRecord rec = mRecords.get(fsUuid);
rec.nickname = nickname;
@@ -1947,7 +1947,7 @@
public void setVolumeUserFlags(String fsUuid, int flags, int mask) {
enforcePermission(android.Manifest.permission.MOUNT_UNMOUNT_FILESYSTEMS);
- Preconditions.checkNotNull(fsUuid);
+ Objects.requireNonNull(fsUuid);
synchronized (mLock) {
final VolumeRecord rec = mRecords.get(fsUuid);
rec.userFlags = (rec.userFlags & ~mask) | (flags & mask);
@@ -1960,7 +1960,7 @@
public void forgetVolume(String fsUuid) {
enforcePermission(android.Manifest.permission.MOUNT_UNMOUNT_FILESYSTEMS);
- Preconditions.checkNotNull(fsUuid);
+ Objects.requireNonNull(fsUuid);
synchronized (mLock) {
final VolumeRecord rec = mRecords.remove(fsUuid);
@@ -2361,7 +2361,7 @@
@Override
public String getMountedObbPath(String rawPath) {
- Preconditions.checkNotNull(rawPath, "rawPath cannot be null");
+ Objects.requireNonNull(rawPath, "rawPath cannot be null");
warnOnNotMounted();
@@ -2379,7 +2379,7 @@
@Override
public boolean isObbMounted(String rawPath) {
- Preconditions.checkNotNull(rawPath, "rawPath cannot be null");
+ Objects.requireNonNull(rawPath, "rawPath cannot be null");
synchronized (mObbMounts) {
return mObbPathToStateMap.containsKey(rawPath);
}
@@ -2388,10 +2388,10 @@
@Override
public void mountObb(String rawPath, String canonicalPath, String key,
IObbActionListener token, int nonce, ObbInfo obbInfo) {
- Preconditions.checkNotNull(rawPath, "rawPath cannot be null");
- Preconditions.checkNotNull(canonicalPath, "canonicalPath cannot be null");
- Preconditions.checkNotNull(token, "token cannot be null");
- Preconditions.checkNotNull(obbInfo, "obbIfno cannot be null");
+ Objects.requireNonNull(rawPath, "rawPath cannot be null");
+ Objects.requireNonNull(canonicalPath, "canonicalPath cannot be null");
+ Objects.requireNonNull(token, "token cannot be null");
+ Objects.requireNonNull(obbInfo, "obbIfno cannot be null");
final int callingUid = Binder.getCallingUid();
final ObbState obbState = new ObbState(rawPath, canonicalPath,
@@ -2405,7 +2405,7 @@
@Override
public void unmountObb(String rawPath, boolean force, IObbActionListener token, int nonce) {
- Preconditions.checkNotNull(rawPath, "rawPath cannot be null");
+ Objects.requireNonNull(rawPath, "rawPath cannot be null");
final ObbState existingState;
synchronized (mObbMounts) {
@@ -2648,13 +2648,6 @@
*/
@Override
public boolean supportsCheckpoint() throws RemoteException {
- // Only the root, system_server and shell processes are permitted to start checkpoints
- final int callingUid = Binder.getCallingUid();
- if (callingUid != Process.SYSTEM_UID && callingUid != Process.ROOT_UID
- && callingUid != Process.SHELL_UID) {
- throw new SecurityException("no permission to start filesystem checkpoint");
- }
-
return mVold.supportsCheckpoint();
}
diff --git a/services/core/java/com/android/server/SystemServerInitThreadPool.java b/services/core/java/com/android/server/SystemServerInitThreadPool.java
index ff6a537..ba82938 100644
--- a/services/core/java/com/android/server/SystemServerInitThreadPool.java
+++ b/services/core/java/com/android/server/SystemServerInitThreadPool.java
@@ -26,6 +26,7 @@
import java.util.ArrayList;
import java.util.List;
+import java.util.Objects;
import java.util.concurrent.ExecutorService;
import java.util.concurrent.Future;
import java.util.concurrent.TimeUnit;
diff --git a/services/core/java/com/android/server/TelephonyRegistry.java b/services/core/java/com/android/server/TelephonyRegistry.java
index d54bacc..ac897e4 100644
--- a/services/core/java/com/android/server/TelephonyRegistry.java
+++ b/services/core/java/com/android/server/TelephonyRegistry.java
@@ -168,14 +168,13 @@
@Override
public String toString() {
- return "{callingPackage=" + callingPackage + " binder=" + binder
- + " callback=" + callback
+ return "{callingPackage=" + pii(callingPackage) + " callerUid=" + callerUid + " binder="
+ + binder + " callback=" + callback
+ " onSubscriptionsChangedListenererCallback="
+ onSubscriptionsChangedListenerCallback
+ " onOpportunisticSubscriptionsChangedListenererCallback="
- + onOpportunisticSubscriptionsChangedListenerCallback
- + " callerUid=" + callerUid + " subId=" + subId + " phoneId=" + phoneId
- + " events=" + Integer.toHexString(events) + "}";
+ + onOpportunisticSubscriptionsChangedListenerCallback + " subId=" + subId
+ + " phoneId=" + phoneId + " events=" + Integer.toHexString(events) + "}";
}
}
@@ -598,9 +597,9 @@
int callerUserId = UserHandle.getCallingUserId();
mAppOps.checkPackage(Binder.getCallingUid(), callingPackage);
if (VDBG) {
- log("listen oscl: E pkg=" + callingPackage + " myUserId=" + UserHandle.myUserId()
- + " callerUserId=" + callerUserId + " callback=" + callback
- + " callback.asBinder=" + callback.asBinder());
+ log("listen oscl: E pkg=" + pii(callingPackage) + " uid=" + Binder.getCallingUid()
+ + " myUserId=" + UserHandle.myUserId() + " callerUserId=" + callerUserId
+ + " callback=" + callback + " callback.asBinder=" + callback.asBinder());
}
synchronized (mRecords) {
@@ -652,9 +651,9 @@
int callerUserId = UserHandle.getCallingUserId();
mAppOps.checkPackage(Binder.getCallingUid(), callingPackage);
if (VDBG) {
- log("listen ooscl: E pkg=" + callingPackage + " myUserId=" + UserHandle.myUserId()
- + " callerUserId=" + callerUserId + " callback=" + callback
- + " callback.asBinder=" + callback.asBinder());
+ log("listen ooscl: E pkg=" + pii(callingPackage) + " uid=" + Binder.getCallingUid()
+ + " myUserId=" + UserHandle.myUserId() + " callerUserId=" + callerUserId
+ + " callback=" + callback + " callback.asBinder=" + callback.asBinder());
}
synchronized (mRecords) {
@@ -769,9 +768,9 @@
IPhoneStateListener callback, int events, boolean notifyNow, int subId) {
int callerUserId = UserHandle.getCallingUserId();
mAppOps.checkPackage(Binder.getCallingUid(), callingPackage);
- String str = "listen: E pkg=" + callingPackage + " events=0x" + Integer.toHexString(events)
- + " notifyNow=" + notifyNow + " subId=" + subId + " myUserId="
- + UserHandle.myUserId() + " callerUserId=" + callerUserId;
+ String str = "listen: E pkg=" + pii(callingPackage) + " uid=" + Binder.getCallingUid()
+ + " events=0x" + Integer.toHexString(events) + " notifyNow=" + notifyNow + " subId="
+ + subId + " myUserId=" + UserHandle.myUserId() + " callerUserId=" + callerUserId;
mListenLog.log(str);
if (VDBG) {
log(str);
@@ -2935,4 +2934,14 @@
if (info == null) return INVALID_SIM_SLOT_INDEX;
return info.getSimSlotIndex();
}
+
+ /**
+ * On certain build types, we should redact information by default. UID information will be
+ * preserved in the same log line, so no debugging capability is lost in full bug reports.
+ * However, privacy-constrained bug report types (e.g. connectivity) cannot display raw
+ * package names on user builds as it's considered an information leak.
+ */
+ private static String pii(String packageName) {
+ return Build.IS_DEBUGGABLE ? packageName : "***";
+ }
}
diff --git a/services/core/java/com/android/server/connectivity/KeepaliveTracker.java b/services/core/java/com/android/server/connectivity/KeepaliveTracker.java
index 5059a48..7c8fb5a 100644
--- a/services/core/java/com/android/server/connectivity/KeepaliveTracker.java
+++ b/services/core/java/com/android/server/connectivity/KeepaliveTracker.java
@@ -220,9 +220,9 @@
+ " network=" + mNai.network
+ " startedState=" + startedStateString(mStartedState)
+ " "
- + IpUtils.addressAndPortToString(mPacket.srcAddress, mPacket.srcPort)
+ + IpUtils.addressAndPortToString(mPacket.getSrcAddress(), mPacket.getSrcPort())
+ "->"
- + IpUtils.addressAndPortToString(mPacket.dstAddress, mPacket.dstPort)
+ + IpUtils.addressAndPortToString(mPacket.getDstAddress(), mPacket.getDstPort())
+ " interval=" + mInterval
+ " uid=" + mUid + " pid=" + mPid + " privileged=" + mPrivileged
+ " packetData=" + HexDump.toHexString(mPacket.getPacket())
@@ -250,7 +250,7 @@
private int checkSourceAddress() {
// Check that we have the source address.
for (InetAddress address : mNai.linkProperties.getAddresses()) {
- if (address.equals(mPacket.srcAddress)) {
+ if (address.equals(mPacket.getSrcAddress())) {
return SUCCESS;
}
}
@@ -619,7 +619,7 @@
packet = NattKeepalivePacketData.nattKeepalivePacket(
srcAddress, srcPort, dstAddress, NATT_PORT);
} catch (InvalidPacketException e) {
- notifyErrorCallback(cb, e.error);
+ notifyErrorCallback(cb, e.getError());
return;
}
KeepaliveInfo ki = null;
@@ -662,7 +662,7 @@
notifyErrorCallback(cb, e.error);
return;
} catch (InvalidPacketException e) {
- notifyErrorCallback(cb, e.error);
+ notifyErrorCallback(cb, e.getError());
return;
}
KeepaliveInfo ki = null;
diff --git a/services/core/java/com/android/server/connectivity/NetworkAgentInfo.java b/services/core/java/com/android/server/connectivity/NetworkAgentInfo.java
index f844844..2d1f553 100644
--- a/services/core/java/com/android/server/connectivity/NetworkAgentInfo.java
+++ b/services/core/java/com/android/server/connectivity/NetworkAgentInfo.java
@@ -16,6 +16,7 @@
package com.android.server.connectivity;
+import static android.net.ConnectivityDiagnosticsManager.ConnectivityReport;
import static android.net.NetworkCapabilities.transportNamesOf;
import android.annotation.NonNull;
@@ -243,6 +244,10 @@
// How many of the satisfied requests are of type BACKGROUND_REQUEST.
private int mNumBackgroundNetworkRequests = 0;
+ // The last ConnectivityReport made available for this network. This value is only null before a
+ // report is generated. Once non-null, it will never be null again.
+ @Nullable private ConnectivityReport mConnectivityReport;
+
public final Messenger messenger;
public final AsyncChannel asyncChannel;
@@ -621,6 +626,32 @@
for (LingerTimer timer : mLingerTimers) { pw.println(timer); }
}
+ /**
+ * Sets the most recent ConnectivityReport for this network.
+ *
+ * <p>This should only be called from the ConnectivityService thread.
+ *
+ * @hide
+ */
+ public void setConnectivityReport(@NonNull ConnectivityReport connectivityReport) {
+ mConnectivityReport = connectivityReport;
+ }
+
+ /**
+ * Returns the most recent ConnectivityReport for this network, or null if none have been
+ * reported yet.
+ *
+ * <p>This should only be called from the ConnectivityService thread.
+ *
+ * @hide
+ */
+ @Nullable
+ public ConnectivityReport getConnectivityReport() {
+ return mConnectivityReport;
+ }
+
+ // TODO: Print shorter members first and only print the boolean variable which value is true
+ // to improve readability.
public String toString() {
return "NetworkAgentInfo{"
+ "network{" + network + "} handle{" + network.getNetworkHandle() + "} ni{"
diff --git a/services/core/java/com/android/server/connectivity/NetworkNotificationManager.java b/services/core/java/com/android/server/connectivity/NetworkNotificationManager.java
index 0925de8..34b0aa2 100644
--- a/services/core/java/com/android/server/connectivity/NetworkNotificationManager.java
+++ b/services/core/java/com/android/server/connectivity/NetworkNotificationManager.java
@@ -150,7 +150,7 @@
if (nai != null) {
transportType = approximateTransportType(nai);
final String extraInfo = nai.networkInfo.getExtraInfo();
- name = TextUtils.isEmpty(extraInfo) ? nai.networkCapabilities.getSSID() : extraInfo;
+ name = TextUtils.isEmpty(extraInfo) ? nai.networkCapabilities.getSsid() : extraInfo;
// Only notify for Internet-capable networks.
if (!nai.networkCapabilities.hasCapability(NET_CAPABILITY_INTERNET)) return;
} else {
@@ -183,14 +183,14 @@
int icon = getIcon(transportType);
if (notifyType == NotificationType.NO_INTERNET && transportType == TRANSPORT_WIFI) {
title = r.getString(R.string.wifi_no_internet,
- WifiInfo.sanitizeSsid(nai.networkCapabilities.getSSID()));
+ WifiInfo.sanitizeSsid(nai.networkCapabilities.getSsid()));
details = r.getString(R.string.wifi_no_internet_detailed);
} else if (notifyType == NotificationType.PRIVATE_DNS_BROKEN) {
if (transportType == TRANSPORT_CELLULAR) {
title = r.getString(R.string.mobile_no_internet);
} else if (transportType == TRANSPORT_WIFI) {
title = r.getString(R.string.wifi_no_internet,
- WifiInfo.sanitizeSsid(nai.networkCapabilities.getSSID()));
+ WifiInfo.sanitizeSsid(nai.networkCapabilities.getSsid()));
} else {
title = r.getString(R.string.other_networks_no_internet);
}
@@ -198,19 +198,19 @@
} else if (notifyType == NotificationType.PARTIAL_CONNECTIVITY
&& transportType == TRANSPORT_WIFI) {
title = r.getString(R.string.network_partial_connectivity,
- WifiInfo.sanitizeSsid(nai.networkCapabilities.getSSID()));
+ WifiInfo.sanitizeSsid(nai.networkCapabilities.getSsid()));
details = r.getString(R.string.network_partial_connectivity_detailed);
} else if (notifyType == NotificationType.LOST_INTERNET &&
transportType == TRANSPORT_WIFI) {
title = r.getString(R.string.wifi_no_internet,
- WifiInfo.sanitizeSsid(nai.networkCapabilities.getSSID()));
+ WifiInfo.sanitizeSsid(nai.networkCapabilities.getSsid()));
details = r.getString(R.string.wifi_no_internet_detailed);
} else if (notifyType == NotificationType.SIGN_IN) {
switch (transportType) {
case TRANSPORT_WIFI:
title = r.getString(R.string.wifi_available_sign_in, 0);
details = r.getString(R.string.network_available_sign_in_detailed,
- WifiInfo.sanitizeSsid(nai.networkCapabilities.getSSID()));
+ WifiInfo.sanitizeSsid(nai.networkCapabilities.getSsid()));
break;
case TRANSPORT_CELLULAR:
title = r.getString(R.string.network_available_sign_in, 0);
diff --git a/services/core/java/com/android/server/connectivity/Vpn.java b/services/core/java/com/android/server/connectivity/Vpn.java
index e80b39f..120e744 100644
--- a/services/core/java/com/android/server/connectivity/Vpn.java
+++ b/services/core/java/com/android/server/connectivity/Vpn.java
@@ -2248,12 +2248,16 @@
final String interfaceName = mTunnelIface.getInterfaceName();
final int maxMtu = mProfile.getMaxMtu();
final List<LinkAddress> internalAddresses = childConfig.getInternalAddresses();
+ final List<String> dnsAddrStrings = new ArrayList<>();
final Collection<RouteInfo> newRoutes = VpnIkev2Utils.getRoutesFromTrafficSelectors(
childConfig.getOutboundTrafficSelectors());
for (final LinkAddress address : internalAddresses) {
mTunnelIface.addAddress(address.getAddress(), address.getPrefixLength());
}
+ for (InetAddress addr : childConfig.getInternalDnsServers()) {
+ dnsAddrStrings.add(addr.getHostAddress());
+ }
final NetworkAgent networkAgent;
final LinkProperties lp;
@@ -2269,7 +2273,9 @@
mConfig.routes.clear();
mConfig.routes.addAll(newRoutes);
- // TODO: Add DNS servers from negotiation
+ if (mConfig.dnsServers == null) mConfig.dnsServers = new ArrayList<>();
+ mConfig.dnsServers.clear();
+ mConfig.dnsServers.addAll(dnsAddrStrings);
networkAgent = mNetworkAgent;
diff --git a/services/core/java/com/android/server/notification/NotificationManagerService.java b/services/core/java/com/android/server/notification/NotificationManagerService.java
index 0bd2967..31e2fe8 100755
--- a/services/core/java/com/android/server/notification/NotificationManagerService.java
+++ b/services/core/java/com/android/server/notification/NotificationManagerService.java
@@ -1643,7 +1643,7 @@
ActivityManager activityManager, GroupHelper groupHelper, IActivityManager am,
UsageStatsManagerInternal appUsageStats, DevicePolicyManagerInternal dpm,
IUriGrantsManager ugm, UriGrantsManagerInternal ugmInternal, AppOpsManager appOps,
- UserManager userManager) {
+ UserManager userManager, TelephonyManager telephonyManager) {
Resources resources = getContext().getResources();
mMaxPackageEnqueueRate = Settings.Global.getFloat(getContext().getContentResolver(),
Settings.Global.MAX_NOTIFICATION_ENQUEUE_RATE,
@@ -1766,7 +1766,15 @@
mInterruptionFilter = mZenModeHelper.getZenModeListenerInterruptionFilter();
mUserProfiles.updateCache(getContext());
- listenForCallState();
+
+ telephonyManager.listen(new PhoneStateListener() {
+ @Override
+ public void onCallStateChanged(int state, String incomingNumber) {
+ if (mCallState == state) return;
+ if (DBG) Slog.d(TAG, "Call state changed: " + callStateToString(state));
+ mCallState = state;
+ }
+ }, PhoneStateListener.LISTEN_CALL_STATE);
mSettingsObserver = new SettingsObserver(mHandler);
@@ -1825,7 +1833,8 @@
UriGrantsManager.getService(),
LocalServices.getService(UriGrantsManagerInternal.class),
(AppOpsManager) getContext().getSystemService(Context.APP_OPS_SERVICE),
- getContext().getSystemService(UserManager.class));
+ getContext().getSystemService(UserManager.class),
+ getContext().getSystemService(TelephonyManager.class));
// register for various Intents
IntentFilter filter = new IntentFilter();
@@ -7467,17 +7476,6 @@
}
}
- private void listenForCallState() {
- getContext().getSystemService(TelephonyManager.class).listen(new PhoneStateListener() {
- @Override
- public void onCallStateChanged(int state, String incomingNumber) {
- if (mCallState == state) return;
- if (DBG) Slog.d(TAG, "Call state changed: " + callStateToString(state));
- mCallState = state;
- }
- }, PhoneStateListener.LISTEN_CALL_STATE);
- }
-
/**
* Generates a NotificationRankingUpdate from 'sbns', considering only
* notifications visible to the given listener.
diff --git a/services/core/java/com/android/server/pm/ApexManager.java b/services/core/java/com/android/server/pm/ApexManager.java
index cf5ec05..341a88d 100644
--- a/services/core/java/com/android/server/pm/ApexManager.java
+++ b/services/core/java/com/android/server/pm/ApexManager.java
@@ -207,7 +207,14 @@
*
* @return {@code true} upon success, {@code false} if any remote exception occurs
*/
- abstract boolean abortActiveSession();
+ abstract boolean revertActiveSessions();
+
+ /**
+ * Abandons the staged session with the given sessionId.
+ *
+ * @return {@code true} upon success, {@code false} if any remote exception occurs
+ */
+ abstract boolean abortStagedSession(int sessionId) throws PackageManagerException;
/**
* Uninstalls given {@code apexPackage}.
@@ -489,13 +496,31 @@
}
@Override
- boolean abortActiveSession() {
+ boolean revertActiveSessions() {
try {
- mApexService.abortActiveSession();
+ mApexService.revertActiveSessions();
return true;
} catch (RemoteException re) {
Slog.e(TAG, "Unable to contact apexservice", re);
return false;
+ } catch (Exception e) {
+ Slog.e(TAG, e.getMessage(), e);
+ return false;
+ }
+ }
+
+ @Override
+ boolean abortStagedSession(int sessionId) throws PackageManagerException {
+ try {
+ mApexService.abortStagedSession(sessionId);
+ return true;
+ } catch (RemoteException re) {
+ Slog.e(TAG, "Unable to contact apexservice", re);
+ return false;
+ } catch (Exception e) {
+ throw new PackageManagerException(
+ PackageInstaller.SessionInfo.STAGED_SESSION_VERIFICATION_FAILED,
+ "Failed to abort staged session : " + e.getMessage());
}
}
@@ -569,12 +594,12 @@
ipw.println("State: ACTIVATION FAILED");
} else if (si.isSuccess) {
ipw.println("State: SUCCESS");
- } else if (si.isRollbackInProgress) {
- ipw.println("State: ROLLBACK IN PROGRESS");
- } else if (si.isRolledBack) {
- ipw.println("State: ROLLED BACK");
- } else if (si.isRollbackFailed) {
- ipw.println("State: ROLLBACK FAILED");
+ } else if (si.isRevertInProgress) {
+ ipw.println("State: REVERT IN PROGRESS");
+ } else if (si.isReverted) {
+ ipw.println("State: REVERTED");
+ } else if (si.isRevertFailed) {
+ ipw.println("State: REVERT FAILED");
}
ipw.decreaseIndent();
}
@@ -682,7 +707,12 @@
}
@Override
- boolean abortActiveSession() {
+ boolean revertActiveSessions() {
+ throw new UnsupportedOperationException();
+ }
+
+ @Override
+ boolean abortStagedSession(int sessionId) throws PackageManagerException {
throw new UnsupportedOperationException();
}
diff --git a/services/core/java/com/android/server/pm/PackageManagerShellCommand.java b/services/core/java/com/android/server/pm/PackageManagerShellCommand.java
index d023ebb..ad8de40 100644
--- a/services/core/java/com/android/server/pm/PackageManagerShellCommand.java
+++ b/services/core/java/com/android/server/pm/PackageManagerShellCommand.java
@@ -1163,42 +1163,7 @@
pw.println("Success");
return 0;
}
-
- long timeoutMs = params.timeoutMs <= 0
- ? DEFAULT_WAIT_MS
- : params.timeoutMs;
- PackageInstaller.SessionInfo si = mInterface.getPackageInstaller()
- .getSessionInfo(sessionId);
- long currentTime = System.currentTimeMillis();
- long endTime = currentTime + timeoutMs;
- // Using a loop instead of BroadcastReceiver since we can receive session update
- // broadcast only if packageInstallerName is "android". We can't always force
- // "android" as packageIntallerName, e.g, rollback auto implies
- // "-i com.android.shell".
- while (currentTime < endTime) {
- if (si != null
- && (si.isStagedSessionReady() || si.isStagedSessionFailed())) {
- break;
- }
- SystemClock.sleep(Math.min(endTime - currentTime, 100));
- currentTime = System.currentTimeMillis();
- si = mInterface.getPackageInstaller().getSessionInfo(sessionId);
- }
- if (si == null) {
- pw.println("Failure [failed to retrieve SessionInfo]");
- return 1;
- }
- if (!si.isStagedSessionReady() && !si.isStagedSessionFailed()) {
- pw.println("Failure [timed out after " + timeoutMs + " ms]");
- return 1;
- }
- if (!si.isStagedSessionReady()) {
- pw.println("Error [" + si.getStagedSessionErrorCode() + "] ["
- + si.getStagedSessionErrorMessage() + "]");
- return 1;
- }
- pw.println("Success. Reboot device to apply staged session");
- return 0;
+ return doWaitForStagedSessionRead(sessionId, params.timeoutMs, pw);
} finally {
if (abandonSession) {
try {
@@ -1209,14 +1174,92 @@
}
}
+ private int doWaitForStagedSessionRead(int sessionId, long timeoutMs, PrintWriter pw)
+ throws RemoteException {
+ if (timeoutMs <= 0) {
+ timeoutMs = DEFAULT_WAIT_MS;
+ }
+ PackageInstaller.SessionInfo si = mInterface.getPackageInstaller()
+ .getSessionInfo(sessionId);
+ if (si == null) {
+ pw.println("Failure [Unknown session " + sessionId + "]");
+ return 1;
+ }
+ if (!si.isStaged()) {
+ pw.println("Failure [Session " + sessionId + " is not a staged session]");
+ return 1;
+ }
+ long currentTime = System.currentTimeMillis();
+ long endTime = currentTime + timeoutMs;
+ // Using a loop instead of BroadcastReceiver since we can receive session update
+ // broadcast only if packageInstallerName is "android". We can't always force
+ // "android" as packageIntallerName, e.g, rollback auto implies
+ // "-i com.android.shell".
+ while (currentTime < endTime) {
+ if (si != null && (si.isStagedSessionReady() || si.isStagedSessionFailed())) {
+ break;
+ }
+ SystemClock.sleep(Math.min(endTime - currentTime, 100));
+ currentTime = System.currentTimeMillis();
+ si = mInterface.getPackageInstaller().getSessionInfo(sessionId);
+ }
+ if (si == null) {
+ pw.println("Failure [failed to retrieve SessionInfo]");
+ return 1;
+ }
+ if (!si.isStagedSessionReady() && !si.isStagedSessionFailed()) {
+ pw.println("Failure [timed out after " + timeoutMs + " ms]");
+ return 1;
+ }
+ if (!si.isStagedSessionReady()) {
+ pw.println("Error [" + si.getStagedSessionErrorCode() + "] ["
+ + si.getStagedSessionErrorMessage() + "]");
+ return 1;
+ }
+ pw.println("Success. Reboot device to apply staged session");
+ return 0;
+ }
+
private int runInstallAbandon() throws RemoteException {
final int sessionId = Integer.parseInt(getNextArg());
return doAbandonSession(sessionId, true /*logSuccess*/);
}
private int runInstallCommit() throws RemoteException {
+ final PrintWriter pw = getOutPrintWriter();
+ String opt;
+ boolean waitForStagedSessionReady = true;
+ long timeoutMs = -1;
+ while ((opt = getNextOption()) != null) {
+ switch (opt) {
+ case "--wait":
+ waitForStagedSessionReady = true;
+ // If there is only one remaining argument, then it represents the sessionId, we
+ // shouldn't try to parse it as timeoutMs.
+ if (getRemainingArgsCount() > 1) {
+ try {
+ timeoutMs = Long.parseLong(peekNextArg());
+ getNextArg();
+ } catch (NumberFormatException ignore) {
+ }
+ }
+ break;
+ case "--no-wait":
+ waitForStagedSessionReady = false;
+ break;
+ }
+ }
final int sessionId = Integer.parseInt(getNextArg());
- return doCommitSession(sessionId, true /*logSuccess*/);
+ if (doCommitSession(sessionId, false /*logSuccess*/) != PackageInstaller.STATUS_SUCCESS) {
+ return 1;
+ }
+ final PackageInstaller.SessionInfo si = mInterface.getPackageInstaller()
+ .getSessionInfo(sessionId);
+ if (si == null || !si.isStaged() || !waitForStagedSessionReady) {
+ pw.println("Success");
+ return 0;
+ }
+ return doWaitForStagedSessionRead(sessionId, timeoutMs, pw);
}
private int runInstallCreate() throws RemoteException {
diff --git a/services/core/java/com/android/server/pm/StagingManager.java b/services/core/java/com/android/server/pm/StagingManager.java
index 96ccba5..3e9610e 100644
--- a/services/core/java/com/android/server/pm/StagingManager.java
+++ b/services/core/java/com/android/server/pm/StagingManager.java
@@ -46,12 +46,15 @@
import android.os.PowerManager;
import android.os.RemoteException;
import android.os.ServiceManager;
+import android.os.storage.IStorageManager;
+import android.os.storage.StorageManager;
import android.util.IntArray;
import android.util.Slog;
import android.util.SparseArray;
import android.util.apk.ApkSignatureVerifier;
import com.android.internal.annotations.GuardedBy;
+import com.android.internal.content.PackageHelper;
import com.android.internal.os.BackgroundThread;
import java.io.File;
@@ -76,6 +79,7 @@
private final PackageInstallerService mPi;
private final ApexManager mApexManager;
private final PowerManager mPowerManager;
+ private final Context mContext;
private final PreRebootVerificationHandler mPreRebootVerificationHandler;
@GuardedBy("mStagedSessions")
@@ -84,6 +88,7 @@
StagingManager(PackageInstallerService pi, ApexManager am, Context context) {
mPi = pi;
mApexManager = am;
+ mContext = context;
mPowerManager = (PowerManager) context.getSystemService(Context.POWER_SERVICE);
mPreRebootVerificationHandler = new PreRebootVerificationHandler(
BackgroundThread.get().getLooper());
@@ -213,7 +218,7 @@
}
final long activeVersion = activePackage.applicationInfo.longVersionCode;
if (activeVersion != session.params.requiredInstalledVersionCode) {
- if (!mApexManager.abortActiveSession()) {
+ if (!mApexManager.abortStagedSession(session.sessionId)) {
Slog.e(TAG, "Failed to abort apex session " + session.sessionId);
}
throw new PackageManagerException(
@@ -232,7 +237,7 @@
final boolean allowsDowngrade = PackageManagerServiceUtils.isDowngradePermitted(
session.params.installFlags, activePackage.applicationInfo.flags);
if (activeVersion > newVersionCode && !allowsDowngrade) {
- if (!mApexManager.abortActiveSession()) {
+ if (!mApexManager.abortStagedSession(session.sessionId)) {
Slog.e(TAG, "Failed to abort apex session " + session.sessionId);
}
throw new PackageManagerException(
@@ -271,39 +276,100 @@
return sessionContains(session, (s) -> !isApexSession(s));
}
+ // Reverts apex sessions and user data (if checkpoint is supported). Also reboots the device.
+ private void abortCheckpoint() {
+ try {
+ if (supportsCheckpoint() && needsCheckpoint()) {
+ mApexManager.revertActiveSessions();
+ PackageHelper.getStorageManager().abortChanges(
+ "StagingManager initiated", false /*retry*/);
+ }
+ } catch (Exception e) {
+ Slog.wtf(TAG, "Failed to abort checkpoint", e);
+ mApexManager.revertActiveSessions();
+ mPowerManager.reboot(null);
+ }
+ }
+
+ private boolean supportsCheckpoint() throws RemoteException {
+ return PackageHelper.getStorageManager().supportsCheckpoint();
+ }
+
+ private boolean needsCheckpoint() throws RemoteException {
+ return PackageHelper.getStorageManager().needsCheckpoint();
+ }
+
private void resumeSession(@NonNull PackageInstallerSession session) {
Slog.d(TAG, "Resuming session " + session.sessionId);
+
final boolean hasApex = sessionContainsApex(session);
+ ApexSessionInfo apexSessionInfo = null;
if (hasApex) {
// Check with apexservice whether the apex packages have been activated.
- ApexSessionInfo apexSessionInfo = mApexManager.getStagedSessionInfo(session.sessionId);
+ apexSessionInfo = mApexManager.getStagedSessionInfo(session.sessionId);
+
+ if (apexSessionInfo != null && apexSessionInfo.isVerified) {
+ // Session has been previously submitted to apexd, but didn't complete all the
+ // pre-reboot verification, perhaps because the device rebooted in the meantime.
+ // Greedily re-trigger the pre-reboot verification. We want to avoid marking it as
+ // failed when not in checkpoint mode, hence it is being processed separately.
+ Slog.d(TAG, "Found pending staged session " + session.sessionId + " still to "
+ + "be verified, resuming pre-reboot verification");
+ mPreRebootVerificationHandler.startPreRebootVerification(session.sessionId);
+ return;
+ }
+ }
+
+ // Before we resume session, we check if revert is needed or not. Typically, we enter file-
+ // system checkpoint mode when we reboot first time in order to install staged sessions. We
+ // want to install staged sessions in this mode as rebooting now will revert user data. If
+ // something goes wrong, then we reboot again to enter fs-rollback mode. Rebooting now will
+ // have no effect on user data, so mark the sessions as failed instead.
+ try {
+ // If checkpoint is supported, then we only resume sessions if we are in checkpointing
+ // mode. If not, we fail all sessions.
+ if (supportsCheckpoint() && !needsCheckpoint()) {
+ // TODO(b/146343545): Persist failure reason across checkpoint reboot
+ session.setStagedSessionFailed(SessionInfo.STAGED_SESSION_UNKNOWN,
+ "Reverting back to safe state");
+ return;
+ }
+ } catch (RemoteException e) {
+ // Cannot continue staged install without knowing if fs-checkpoint is supported
+ Slog.e(TAG, "Checkpoint support unknown. Aborting staged install for session "
+ + session.sessionId, e);
+ // TODO: Mark all staged sessions together and reboot only once
+ session.setStagedSessionFailed(SessionInfo.STAGED_SESSION_UNKNOWN,
+ "Checkpoint support unknown. Aborting staged install.");
+ if (hasApex) {
+ mApexManager.revertActiveSessions();
+ }
+ mPowerManager.reboot("Checkpoint support unknown");
+ return;
+ }
+
+ if (hasApex) {
if (apexSessionInfo == null) {
session.setStagedSessionFailed(SessionInfo.STAGED_SESSION_ACTIVATION_FAILED,
"apexd did not know anything about a staged session supposed to be"
+ "activated");
+ abortCheckpoint();
return;
}
if (isApexSessionFailed(apexSessionInfo)) {
session.setStagedSessionFailed(SessionInfo.STAGED_SESSION_ACTIVATION_FAILED,
"APEX activation failed. Check logcat messages from apexd for "
+ "more information.");
- return;
- }
- if (apexSessionInfo.isVerified) {
- // Session has been previously submitted to apexd, but didn't complete all the
- // pre-reboot verification, perhaps because the device rebooted in the meantime.
- // Greedily re-trigger the pre-reboot verification.
- Slog.d(TAG, "Found pending staged session " + session.sessionId + " still to be "
- + "verified, resuming pre-reboot verification");
- mPreRebootVerificationHandler.startPreRebootVerification(session.sessionId);
+ abortCheckpoint();
return;
}
if (!apexSessionInfo.isActivated && !apexSessionInfo.isSuccess) {
- // In all the remaining cases apexd will try to apply the session again at next
- // boot. Nothing to do here for now.
- Slog.w(TAG, "Staged session " + session.sessionId + " scheduled to be applied "
- + "at boot didn't activate nor fail. This usually means that apexd will "
- + "retry at next reboot.");
+ // Apexd did not apply the session for some unknown reason. There is no guarantee
+ // that apexd will install it next time. Safer to proactively mark as failed.
+ session.setStagedSessionFailed(SessionInfo.STAGED_SESSION_ACTIVATION_FAILED,
+ "Staged session " + session.sessionId + "at boot didn't "
+ + "activate nor fail. Marking it as failed anyway.");
+ abortCheckpoint();
return;
}
Slog.i(TAG, "APEX packages in session " + session.sessionId
@@ -315,12 +381,14 @@
installApksInSession(session);
} catch (PackageManagerException e) {
session.setStagedSessionFailed(e.error, e.getMessage());
+ abortCheckpoint();
+ // If checkpoint is not supported, we have to handle failure for one staged session.
if (!hasApex) {
return;
}
- if (!mApexManager.abortActiveSession()) {
+ if (!mApexManager.revertActiveSessions()) {
Slog.e(TAG, "Failed to abort APEXd session");
} else {
Slog.e(TAG,
@@ -539,6 +607,10 @@
mPreRebootVerificationHandler.startPreRebootVerification(session.sessionId);
}
+ private int parentOrOwnSessionId(PackageInstallerSession session) {
+ return session.hasParentSessionId() ? session.getParentSessionId() : session.sessionId;
+ }
+
/**
* <p> Check if the session provided is non-overlapping with the active staged sessions.
*
@@ -561,6 +633,9 @@
"Cannot stage session " + session.sessionId + " with package name null");
}
+ boolean supportsCheckpoint = ((StorageManager) mContext.getSystemService(
+ Context.STORAGE_SERVICE)).isCheckpointSupported();
+
synchronized (mStagedSessions) {
for (int i = 0; i < mStagedSessions.size(); i++) {
final PackageInstallerSession stagedSession = mStagedSessions.valueAt(i);
@@ -601,30 +676,14 @@
+ stagedSession.sessionId, null);
}
- // TODO(b/141843321): Add support for staging multiple sessions in apexd
- // Since apexd doesn't support multiple staged sessions yet, we have to careful how
- // we handle apex sessions. We want to allow a set of apex sessions under the same
- // parent to be staged when there is no previously staged apex sessions.
- if (isApexSession(session) && isApexSession(stagedSession)) {
- // session is apex and it can co-exist with stagedSession only if they are from
- // same parent
- final boolean coExist;
- if (!session.hasParentSessionId() && !stagedSession.hasParentSessionId()) {
- // Both single package apex sessions. Cannot co-exist.
- coExist = false;
- } else {
- // At least one of the session has parent. Both must be from same parent.
- coExist =
- session.getParentSessionId() == stagedSession.getParentSessionId();
- }
- if (!coExist) {
- throw new PackageManagerException(
- PackageManager.INSTALL_FAILED_OTHER_STAGED_SESSION_IN_PROGRESS,
- "Package: " + session.getPackageName() + " in session: "
- + session.sessionId + " cannot be staged as there is "
- + "already another apex staged session: "
- + stagedSession.sessionId, null);
- }
+ // Staging multiple root sessions is not allowed if device doesn't support
+ // checkpoint. If session and stagedSession do not have common ancestor, they are
+ // from two different root sessions.
+ if (!supportsCheckpoint
+ && parentOrOwnSessionId(session) != parentOrOwnSessionId(stagedSession)) {
+ throw new PackageManagerException(
+ PackageManager.INSTALL_FAILED_OTHER_STAGED_SESSION_IN_PROGRESS,
+ "Cannot stage multiple sessions without checkpoint support", null);
}
}
}
@@ -658,22 +717,25 @@
+ " because it is not active or APEXD is not reachable");
return;
}
- mApexManager.abortActiveSession();
+ try {
+ mApexManager.abortStagedSession(session.sessionId);
+ } catch (Exception ignore) {
+ }
}
}
private boolean isApexSessionFinalized(ApexSessionInfo session) {
/* checking if the session is in a final state, i.e., not active anymore */
return session.isUnknown || session.isActivationFailed || session.isSuccess
- || session.isRolledBack;
+ || session.isReverted;
}
private static boolean isApexSessionFailed(ApexSessionInfo apexSessionInfo) {
- // isRollbackInProgress is included to cover the scenario, when a device is rebooted in
- // during the rollback, and apexd fails to resume the rollback after reboot.
+ // isRevertInProgress is included to cover the scenario, when a device is rebooted
+ // during the revert, and apexd fails to resume the revert after reboot.
return apexSessionInfo.isActivationFailed || apexSessionInfo.isUnknown
- || apexSessionInfo.isRolledBack || apexSessionInfo.isRollbackInProgress
- || apexSessionInfo.isRollbackFailed;
+ || apexSessionInfo.isReverted || apexSessionInfo.isRevertInProgress
+ || apexSessionInfo.isRevertFailed;
}
@GuardedBy("mStagedSessions")
@@ -950,6 +1012,19 @@
+ session.sessionId, re);
}
}
+ // Before marking the session as ready, start checkpoint service if available
+ try {
+ IStorageManager storageManager = PackageHelper.getStorageManager();
+ if (storageManager.supportsCheckpoint()) {
+ storageManager.startCheckpoint(1);
+ }
+ } catch (Exception e) {
+ // Failed to get hold of StorageManager
+ Slog.e(TAG, "Failed to get hold of StorageManager", e);
+ session.setStagedSessionFailed(SessionInfo.STAGED_SESSION_UNKNOWN,
+ "Failed to get hold of StorageManager");
+ return;
+ }
// Proactively mark session as ready before calling apexd. Although this call order
// looks counter-intuitive, this is the easiest way to ensure that session won't end up
diff --git a/services/core/java/com/android/server/wm/OWNERS b/services/core/java/com/android/server/wm/OWNERS
index 0ab1a3e..4be4c89 100644
--- a/services/core/java/com/android/server/wm/OWNERS
+++ b/services/core/java/com/android/server/wm/OWNERS
@@ -10,3 +10,4 @@
erosky@google.com
riddlehsu@google.com
louischang@google.com
+winsonc@google.com
diff --git a/services/net/java/android/net/TcpKeepalivePacketData.java b/services/net/java/android/net/TcpKeepalivePacketData.java
index fcf3a56..c0c386b 100644
--- a/services/net/java/android/net/TcpKeepalivePacketData.java
+++ b/services/net/java/android/net/TcpKeepalivePacketData.java
@@ -152,10 +152,12 @@
public boolean equals(@Nullable final Object o) {
if (!(o instanceof TcpKeepalivePacketData)) return false;
final TcpKeepalivePacketData other = (TcpKeepalivePacketData) o;
- return this.srcAddress.equals(other.srcAddress)
- && this.dstAddress.equals(other.dstAddress)
- && this.srcPort == other.srcPort
- && this.dstPort == other.dstPort
+ final InetAddress srcAddress = getSrcAddress();
+ final InetAddress dstAddress = getDstAddress();
+ return srcAddress.equals(other.getSrcAddress())
+ && dstAddress.equals(other.getDstAddress())
+ && getSrcPort() == other.getSrcPort()
+ && getDstPort() == other.getDstPort()
&& this.tcpAck == other.tcpAck
&& this.tcpSeq == other.tcpSeq
&& this.tcpWnd == other.tcpWnd
@@ -166,8 +168,8 @@
@Override
public int hashCode() {
- return Objects.hash(srcAddress, dstAddress, srcPort, dstPort, tcpAck, tcpSeq, tcpWnd,
- tcpWndScale, ipTos, ipTtl);
+ return Objects.hash(getSrcAddress(), getDstAddress(), getSrcPort(), getDstPort(),
+ tcpAck, tcpSeq, tcpWnd, tcpWndScale, ipTos, ipTtl);
}
/**
@@ -182,10 +184,10 @@
/** Write to parcel. */
public void writeToParcel(Parcel out, int flags) {
- out.writeString(srcAddress.getHostAddress());
- out.writeString(dstAddress.getHostAddress());
- out.writeInt(srcPort);
- out.writeInt(dstPort);
+ out.writeString(getSrcAddress().getHostAddress());
+ out.writeString(getDstAddress().getHostAddress());
+ out.writeInt(getSrcPort());
+ out.writeInt(getDstPort());
out.writeByteArray(getPacket());
out.writeInt(tcpSeq);
out.writeInt(tcpAck);
@@ -219,7 +221,7 @@
return readFromParcel(in);
} catch (InvalidPacketException e) {
throw new IllegalArgumentException(
- "Invalid NAT-T keepalive data: " + e.error);
+ "Invalid NAT-T keepalive data: " + e.getError());
}
}
@@ -234,10 +236,12 @@
@NonNull
public TcpKeepalivePacketDataParcelable toStableParcelable() {
final TcpKeepalivePacketDataParcelable parcel = new TcpKeepalivePacketDataParcelable();
+ final InetAddress srcAddress = getSrcAddress();
+ final InetAddress dstAddress = getDstAddress();
parcel.srcAddress = srcAddress.getAddress();
- parcel.srcPort = srcPort;
+ parcel.srcPort = getSrcPort();
parcel.dstAddress = dstAddress.getAddress();
- parcel.dstPort = dstPort;
+ parcel.dstPort = getDstPort();
parcel.seq = tcpSeq;
parcel.ack = tcpAck;
parcel.rcvWnd = tcpWnd;
@@ -249,10 +253,10 @@
@Override
public String toString() {
- return "saddr: " + srcAddress
- + " daddr: " + dstAddress
- + " sport: " + srcPort
- + " dport: " + dstPort
+ return "saddr: " + getSrcAddress()
+ + " daddr: " + getDstAddress()
+ + " sport: " + getSrcPort()
+ + " dport: " + getDstPort()
+ " seq: " + tcpSeq
+ " ack: " + tcpAck
+ " wnd: " + tcpWnd
diff --git a/services/net/java/android/net/ip/IpClientManager.java b/services/net/java/android/net/ip/IpClientManager.java
index 09e333e..db464e7 100644
--- a/services/net/java/android/net/ip/IpClientManager.java
+++ b/services/net/java/android/net/ip/IpClientManager.java
@@ -21,6 +21,7 @@
import android.net.NattKeepalivePacketData;
import android.net.ProxyInfo;
import android.net.TcpKeepalivePacketData;
+import android.net.shared.Layer2Information;
import android.net.shared.ProvisioningConfiguration;
import android.net.util.KeepalivePacketDataUtil;
import android.os.Binder;
@@ -292,4 +293,20 @@
Binder.restoreCallingIdentity(token);
}
}
+
+ /**
+ * Update the bssid, L2 key and group hint layer2 information.
+ */
+ public boolean updateLayer2Information(Layer2Information info) {
+ final long token = Binder.clearCallingIdentity();
+ try {
+ mIpClient.updateLayer2Information(info.toStableParcelable());
+ return true;
+ } catch (RemoteException e) {
+ log("Error updating layer2 information", e);
+ return false;
+ } finally {
+ Binder.restoreCallingIdentity(token);
+ }
+ }
}
diff --git a/services/net/java/android/net/util/KeepalivePacketDataUtil.java b/services/net/java/android/net/util/KeepalivePacketDataUtil.java
index 9a51729..4466ea0 100644
--- a/services/net/java/android/net/util/KeepalivePacketDataUtil.java
+++ b/services/net/java/android/net/util/KeepalivePacketDataUtil.java
@@ -20,6 +20,8 @@
import android.net.NattKeepalivePacketData;
import android.net.NattKeepalivePacketDataParcelable;
+import java.net.InetAddress;
+
/** @hide */
public final class KeepalivePacketDataUtil {
/**
@@ -29,11 +31,12 @@
public static NattKeepalivePacketDataParcelable toStableParcelable(
NattKeepalivePacketData pkt) {
final NattKeepalivePacketDataParcelable parcel = new NattKeepalivePacketDataParcelable();
-
- parcel.srcAddress = pkt.srcAddress.getAddress();
- parcel.srcPort = pkt.srcPort;
- parcel.dstAddress = pkt.dstAddress.getAddress();
- parcel.dstPort = pkt.dstPort;
+ final InetAddress srcAddress = pkt.getSrcAddress();
+ final InetAddress dstAddress = pkt.getDstAddress();
+ parcel.srcAddress = srcAddress.getAddress();
+ parcel.srcPort = pkt.getSrcPort();
+ parcel.dstAddress = dstAddress.getAddress();
+ parcel.dstPort = pkt.getDstPort();
return parcel;
}
}
diff --git a/services/tests/servicestests/src/com/android/server/pm/ApexManagerTest.java b/services/tests/servicestests/src/com/android/server/pm/ApexManagerTest.java
index 143dc28..30d1035 100644
--- a/services/tests/servicestests/src/com/android/server/pm/ApexManagerTest.java
+++ b/services/tests/servicestests/src/com/android/server/pm/ApexManagerTest.java
@@ -216,11 +216,11 @@
}
@Test
- public void testAbortActiveSession_remoteException() throws RemoteException {
- doThrow(RemoteException.class).when(mApexService).abortActiveSession();
+ public void testRevertActiveSessions_remoteException() throws RemoteException {
+ doThrow(RemoteException.class).when(mApexService).revertActiveSessions();
try {
- assertThat(mApexManager.abortActiveSession()).isFalse();
+ assertThat(mApexManager.revertActiveSessions()).isFalse();
} catch (Exception e) {
throw new AssertionError("ApexManager should not raise Exception");
}
diff --git a/services/tests/uiservicestests/src/com/android/server/notification/NotificationManagerServiceTest.java b/services/tests/uiservicestests/src/com/android/server/notification/NotificationManagerServiceTest.java
index f390ae6..10b41d2 100755
--- a/services/tests/uiservicestests/src/com/android/server/notification/NotificationManagerServiceTest.java
+++ b/services/tests/uiservicestests/src/com/android/server/notification/NotificationManagerServiceTest.java
@@ -122,6 +122,7 @@
import android.service.notification.NotificationStats;
import android.service.notification.StatusBarNotification;
import android.service.notification.ZenPolicy;
+import android.telephony.TelephonyManager;
import android.test.suitebuilder.annotation.SmallTest;
import android.testing.AndroidTestingRunner;
import android.testing.TestableContext;
@@ -391,7 +392,7 @@
mCompanionMgr, mSnoozeHelper, mUsageStats, mPolicyFile, mActivityManager,
mGroupHelper, mAm, mAppUsageStats,
mock(DevicePolicyManagerInternal.class), mUgm, mUgmInternal,
- mAppOpsManager, mUm);
+ mAppOpsManager, mUm, mock(TelephonyManager.class));
mService.onBootPhase(SystemService.PHASE_SYSTEM_SERVICES_READY);
mService.setAudioManager(mAudioManager);
diff --git a/services/tests/uiservicestests/src/com/android/server/notification/RoleObserverTest.java b/services/tests/uiservicestests/src/com/android/server/notification/RoleObserverTest.java
index f37ff11..501161e 100644
--- a/services/tests/uiservicestests/src/com/android/server/notification/RoleObserverTest.java
+++ b/services/tests/uiservicestests/src/com/android/server/notification/RoleObserverTest.java
@@ -47,6 +47,7 @@
import android.os.Looper;
import android.os.UserHandle;
import android.os.UserManager;
+import android.telephony.TelephonyManager;
import android.test.suitebuilder.annotation.SmallTest;
import android.testing.AndroidTestingRunner;
import android.testing.TestableContext;
@@ -140,7 +141,7 @@
mock(UsageStatsManagerInternal.class),
mock(DevicePolicyManagerInternal.class), mock(IUriGrantsManager.class),
mock(UriGrantsManagerInternal.class),
- mock(AppOpsManager.class), mUm);
+ mock(AppOpsManager.class), mUm, mock(TelephonyManager.class));
} catch (SecurityException e) {
if (!e.getMessage().contains("Permission Denial: not allowed to send broadcast")) {
throw e;
diff --git a/telephony/api/system-current.txt b/telephony/api/system-current.txt
index efe586a..a5514ad 100644
--- a/telephony/api/system-current.txt
+++ b/telephony/api/system-current.txt
@@ -859,9 +859,9 @@
method @RequiresPermission(android.Manifest.permission.MODIFY_PHONE_STATE) public void setVoiceActivationState(int);
method @RequiresPermission(android.Manifest.permission.MODIFY_PHONE_STATE) public void shutdownAllRadios();
method @RequiresPermission(android.Manifest.permission.MODIFY_PHONE_STATE) public boolean supplyPin(String);
- method @Deprecated @RequiresPermission(android.Manifest.permission.MODIFY_PHONE_STATE) public int[] supplyPinReportResult(String);
+ method @RequiresPermission(android.Manifest.permission.MODIFY_PHONE_STATE) public int[] supplyPinReportResult(String);
method @RequiresPermission(android.Manifest.permission.MODIFY_PHONE_STATE) public boolean supplyPuk(String, String);
- method @Deprecated @RequiresPermission(android.Manifest.permission.MODIFY_PHONE_STATE) public int[] supplyPukReportResult(String, String);
+ method @RequiresPermission(android.Manifest.permission.MODIFY_PHONE_STATE) public int[] supplyPukReportResult(String, String);
method @RequiresPermission(android.Manifest.permission.MODIFY_PHONE_STATE) public boolean switchSlots(int[]);
method @RequiresPermission(android.Manifest.permission.MODIFY_PHONE_STATE) public void toggleRadioOnOff();
method @RequiresPermission(android.Manifest.permission.READ_ACTIVE_EMERGENCY_SESSION) public void updateOtaEmergencyNumberDbFilePath(@NonNull android.os.ParcelFileDescriptor);
diff --git a/telephony/java/android/telephony/CarrierConfigManager.java b/telephony/java/android/telephony/CarrierConfigManager.java
index 8cbeba1..8ea80d0 100644
--- a/telephony/java/android/telephony/CarrierConfigManager.java
+++ b/telephony/java/android/telephony/CarrierConfigManager.java
@@ -2991,7 +2991,7 @@
* Controls time in milliseconds until DcTracker reevaluates 5G connection state.
* @hide
*/
- public static final String KEY_5G_WATCHDOG_TIME_MS_LONG = "5g_watchdog_time_long";
+ public static final String KEY_5G_WATCHDOG_TIME_MS_LONG = "5g_watchdog_time_ms_long";
/**
* Whether NR (non-standalone) should be unmetered for all frequencies.
diff --git a/telephony/java/android/telephony/CellIdentity.java b/telephony/java/android/telephony/CellIdentity.java
index 0c2f1f3..390a79a 100644
--- a/telephony/java/android/telephony/CellIdentity.java
+++ b/telephony/java/android/telephony/CellIdentity.java
@@ -68,6 +68,12 @@
/** @hide */
protected String mAlphaShort;
+ // For GSM, WCDMA, TDSCDMA, LTE and NR, Cell Global ID is defined in 3GPP TS 23.003.
+ // For CDMA, its defined as System Id + Network Id + Basestation Id.
+ /** @hide */
+ protected String mGlobalCellId;
+
+
/** @hide */
protected CellIdentity(@Nullable String tag, int type, @Nullable String mcc,
@Nullable String mnc, @Nullable String alphal, @Nullable String alphas) {
@@ -182,6 +188,36 @@
}
/**
+ * @return Global Cell ID
+ * @hide
+ */
+ @Nullable
+ public String getGlobalCellId() {
+ return mGlobalCellId;
+ }
+
+ /**
+ * @param ci a CellIdentity to compare to the current CellIdentity.
+ * @return true if ci has the same technology and Global Cell ID; false, otherwise.
+ * @hide
+ */
+ public boolean isSameCell(@Nullable CellIdentity ci) {
+ if (ci == null) return false;
+ if (this.getClass() != ci.getClass()) return false;
+ if (this.getGlobalCellId() == null || ci.getGlobalCellId() == null) return false;
+ return TextUtils.equals(this.getGlobalCellId(), ci.getGlobalCellId());
+ }
+
+ /** @hide */
+ protected String getPlmn() {
+ if (mMccStr == null || mMncStr == null) return null;
+ return mMccStr + mMncStr;
+ }
+
+ /** @hide */
+ protected abstract void updateGlobalCellId();
+
+ /**
* @return a CellLocation object for this CellIdentity
* @hide
*/
diff --git a/telephony/java/android/telephony/CellIdentityCdma.java b/telephony/java/android/telephony/CellIdentityCdma.java
index e220b07..f21277c 100644
--- a/telephony/java/android/telephony/CellIdentityCdma.java
+++ b/telephony/java/android/telephony/CellIdentityCdma.java
@@ -75,6 +75,7 @@
mBasestationId = CellInfo.UNAVAILABLE;
mLongitude = CellInfo.UNAVAILABLE;
mLatitude = CellInfo.UNAVAILABLE;
+ mGlobalCellId = null;
}
/**
@@ -106,6 +107,7 @@
} else {
mLongitude = mLatitude = CellInfo.UNAVAILABLE;
}
+ updateGlobalCellId();
}
/** @hide */
@@ -136,6 +138,16 @@
mAlphaLong, mAlphaShort);
}
+ /** @hide */
+ @Override
+ protected void updateGlobalCellId() {
+ mGlobalCellId = null;
+ if (mNetworkId == CellInfo.UNAVAILABLE || mSystemId == CellInfo.UNAVAILABLE
+ || mBasestationId == CellInfo.UNAVAILABLE) return;
+
+ mGlobalCellId = String.format("%04x%04x%04x", mSystemId, mNetworkId, mBasestationId);
+ }
+
/**
* Take the latitude and longitude in 1/4 seconds and see if
* the reported location is on Null Island.
diff --git a/telephony/java/android/telephony/CellIdentityGsm.java b/telephony/java/android/telephony/CellIdentityGsm.java
index 203047f..1a91310 100644
--- a/telephony/java/android/telephony/CellIdentityGsm.java
+++ b/telephony/java/android/telephony/CellIdentityGsm.java
@@ -64,6 +64,7 @@
mArfcn = CellInfo.UNAVAILABLE;
mBsic = CellInfo.UNAVAILABLE;
mAdditionalPlmns = new ArraySet<>();
+ mGlobalCellId = null;
}
/**
@@ -94,6 +95,7 @@
mAdditionalPlmns.add(plmn);
}
}
+ updateGlobalCellId();
}
/** @hide */
@@ -136,6 +138,18 @@
CellInfo.UNAVAILABLE, mMccStr, mMncStr, mAlphaLong, mAlphaShort, mAdditionalPlmns);
}
+ /** @hide */
+ @Override
+ protected void updateGlobalCellId() {
+ mGlobalCellId = null;
+ String plmn = getPlmn();
+ if (plmn == null) return;
+
+ if (mLac == CellInfo.UNAVAILABLE || mCid == CellInfo.UNAVAILABLE) return;
+
+ mGlobalCellId = plmn + String.format("%04x%04x", mLac, mCid);
+ }
+
/**
* @return 3-digit Mobile Country Code, 0..999,
* {@link android.telephony.CellInfo#UNAVAILABLE UNAVAILABLE} if unavailable.
diff --git a/telephony/java/android/telephony/CellIdentityLte.java b/telephony/java/android/telephony/CellIdentityLte.java
index b4ce162..c37735c 100644
--- a/telephony/java/android/telephony/CellIdentityLte.java
+++ b/telephony/java/android/telephony/CellIdentityLte.java
@@ -76,6 +76,7 @@
mBandwidth = CellInfo.UNAVAILABLE;
mAdditionalPlmns = new ArraySet<>();
mCsgInfo = null;
+ mGlobalCellId = null;
}
/**
@@ -130,6 +131,7 @@
}
}
mCsgInfo = csgInfo;
+ updateGlobalCellId();
}
/** @hide */
@@ -172,6 +174,18 @@
return new CellIdentityLte(this);
}
+ /** @hide */
+ @Override
+ protected void updateGlobalCellId() {
+ mGlobalCellId = null;
+ String plmn = getPlmn();
+ if (plmn == null) return;
+
+ if (mCi == CellInfo.UNAVAILABLE) return;
+
+ mGlobalCellId = plmn + String.format("%07x", mCi);
+ }
+
/**
* @return 3-digit Mobile Country Code, 0..999,
* {@link android.telephony.CellInfo#UNAVAILABLE UNAVAILABLE} if unavailable.
diff --git a/telephony/java/android/telephony/CellIdentityNr.java b/telephony/java/android/telephony/CellIdentityNr.java
index 69cf7e7d..f0d8780 100644
--- a/telephony/java/android/telephony/CellIdentityNr.java
+++ b/telephony/java/android/telephony/CellIdentityNr.java
@@ -82,6 +82,7 @@
mAdditionalPlmns.add(plmn);
}
}
+ updateGlobalCellId();
}
/** @hide */
@@ -107,6 +108,17 @@
mAdditionalPlmns);
}
+ /** @hide */
+ protected void updateGlobalCellId() {
+ mGlobalCellId = null;
+ String plmn = getPlmn();
+ if (plmn == null) return;
+
+ if (mNci == CellInfo.UNAVAILABLE_LONG) return;
+
+ mGlobalCellId = plmn + String.format("%09x", mNci);
+ }
+
/**
* @return a CellLocation object for this CellIdentity.
* @hide
diff --git a/telephony/java/android/telephony/CellIdentityTdscdma.java b/telephony/java/android/telephony/CellIdentityTdscdma.java
index 30f98bc..3f95596 100644
--- a/telephony/java/android/telephony/CellIdentityTdscdma.java
+++ b/telephony/java/android/telephony/CellIdentityTdscdma.java
@@ -66,6 +66,7 @@
mUarfcn = CellInfo.UNAVAILABLE;
mAdditionalPlmns = new ArraySet<>();
mCsgInfo = null;
+ mGlobalCellId = null;
}
/**
@@ -100,6 +101,7 @@
}
}
mCsgInfo = csgInfo;
+ updateGlobalCellId();
}
private CellIdentityTdscdma(@NonNull CellIdentityTdscdma cid) {
@@ -142,6 +144,18 @@
return new CellIdentityTdscdma(this);
}
+ /** @hide */
+ @Override
+ protected void updateGlobalCellId() {
+ mGlobalCellId = null;
+ String plmn = getPlmn();
+ if (plmn == null) return;
+
+ if (mLac == CellInfo.UNAVAILABLE || mCid == CellInfo.UNAVAILABLE) return;
+
+ mGlobalCellId = plmn + String.format("%04x%04x", mLac, mCid);
+ }
+
/**
* Get Mobile Country Code in string format
* @return Mobile Country Code in string format, null if unknown
diff --git a/telephony/java/android/telephony/CellIdentityWcdma.java b/telephony/java/android/telephony/CellIdentityWcdma.java
index 9d2cb74..38c4ed4 100644
--- a/telephony/java/android/telephony/CellIdentityWcdma.java
+++ b/telephony/java/android/telephony/CellIdentityWcdma.java
@@ -68,6 +68,7 @@
mUarfcn = CellInfo.UNAVAILABLE;
mAdditionalPlmns = new ArraySet<>();
mCsgInfo = null;
+ mGlobalCellId = null;
}
/**
@@ -101,6 +102,7 @@
}
}
mCsgInfo = csgInfo;
+ updateGlobalCellId();
}
/** @hide */
@@ -142,6 +144,18 @@
return new CellIdentityWcdma(this);
}
+ /** @hide */
+ @Override
+ protected void updateGlobalCellId() {
+ mGlobalCellId = null;
+ String plmn = getPlmn();
+ if (plmn == null) return;
+
+ if (mLac == CellInfo.UNAVAILABLE || mCid == CellInfo.UNAVAILABLE) return;
+
+ mGlobalCellId = plmn + String.format("%04x%04x", mLac, mCid);
+ }
+
/**
* @return 3-digit Mobile Country Code, 0..999,
* {@link android.telephony.CellInfo#UNAVAILABLE UNAVAILABLE} if unavailable.
diff --git a/telephony/java/android/telephony/RadioAccessFamily.java b/telephony/java/android/telephony/RadioAccessFamily.java
index bc84738..90ddf2c 100644
--- a/telephony/java/android/telephony/RadioAccessFamily.java
+++ b/telephony/java/android/telephony/RadioAccessFamily.java
@@ -260,24 +260,6 @@
return raf;
}
- /**
- * Returns the highest capability of the RadioAccessFamily (4G > 3G > 2G).
- * @param raf The RadioAccessFamily that we wish to filter
- * @return The highest radio capability
- */
- public static int getHighestRafCapability(int raf) {
- if ((LTE & raf) > 0) {
- return TelephonyManager.NETWORK_CLASS_4_G;
- }
- if ((EVDO|HS|WCDMA & raf) > 0) {
- return TelephonyManager.NETWORK_CLASS_3_G;
- }
- if((GSM|CDMA & raf) > 0) {
- return TelephonyManager.NETWORK_CLASS_2_G;
- }
- return TelephonyManager.NETWORK_CLASS_UNKNOWN;
- }
-
@UnsupportedAppUsage(maxTargetSdk = Build.VERSION_CODES.P, trackingBug = 115609023)
@PrefNetworkMode
public static int getNetworkTypeFromRaf(int raf) {
@@ -395,4 +377,34 @@
}
return result;
}
+
+ /**
+ * Compare two sets of network types to see which is more capable.
+ *
+ * This algorithm first tries to see see if a set has a strict superset of RAT support for
+ * each generation, from newest to oldest; if that results in a tie, then it returns the set
+ * that supports the most RAT types.
+ */
+ public static int compare(long networkTypeBitmaskL, long networkTypeBitmaskR) {
+ final long[] prioritizedNetworkClassBitmasks = new long[] {
+ TelephonyManager.NETWORK_CLASS_BITMASK_5G,
+ TelephonyManager.NETWORK_CLASS_BITMASK_4G,
+ TelephonyManager.NETWORK_CLASS_BITMASK_3G,
+ TelephonyManager.NETWORK_CLASS_BITMASK_2G,
+ };
+
+ long lhsUnique = networkTypeBitmaskL & ~networkTypeBitmaskR;
+ long rhsUnique = networkTypeBitmaskR & ~networkTypeBitmaskL;
+
+ // See if one has a strict super-set of capabilities, generation by generation.
+ for (long classBitmask : prioritizedNetworkClassBitmasks) {
+ int result = 0;
+ if ((lhsUnique & classBitmask) != 0) ++result;
+ if ((rhsUnique & classBitmask) != 0) --result;
+ if (result != 0) return result;
+ }
+
+ // Without a clear winner, return the one that supports the most types.
+ return Long.bitCount(networkTypeBitmaskL) - Long.bitCount(networkTypeBitmaskR);
+ }
}
diff --git a/telephony/java/android/telephony/ServiceState.java b/telephony/java/android/telephony/ServiceState.java
index 82470d4..a269bd1 100644
--- a/telephony/java/android/telephony/ServiceState.java
+++ b/telephony/java/android/telephony/ServiceState.java
@@ -688,8 +688,9 @@
* @return true if registration indicates roaming, false otherwise
* @hide
*/
- @SystemApi
public boolean getDataRoamingFromRegistration() {
+ // TODO: all callers should refactor to get roaming state directly from modem
+ // this should not be exposed as a public API
return mIsDataRoamingFromRegistration;
}
diff --git a/telephony/java/android/telephony/SmsManager.java b/telephony/java/android/telephony/SmsManager.java
index 0f52ba7..7456aab 100644
--- a/telephony/java/android/telephony/SmsManager.java
+++ b/telephony/java/android/telephony/SmsManager.java
@@ -2395,7 +2395,6 @@
* @param sentIntent if not NULL this <code>PendingIntent</code> is
* broadcast when the message is successfully sent, or failed
* @throws IllegalArgumentException if contentUri is empty
- * @deprecated use {@link MmsManager#sendMultimediaMessage} instead.
*/
public void sendMultimediaMessage(Context context, Uri contentUri, String locationUrl,
Bundle configOverrides, PendingIntent sentIntent) {
@@ -2430,7 +2429,6 @@
* @param downloadedIntent if not NULL this <code>PendingIntent</code> is
* broadcast when the message is downloaded, or the download is failed
* @throws IllegalArgumentException if locationUrl or contentUri is empty
- * @deprecated use {@link MmsManager#downloadMultimediaMessage} instead.
*/
public void downloadMultimediaMessage(Context context, String locationUrl, Uri contentUri,
Bundle configOverrides, PendingIntent downloadedIntent) {
@@ -2768,7 +2766,7 @@
getSubscriptionId(), null);
}
} catch (RemoteException ex) {
- // ignore it
+ throw new RuntimeException(ex);
}
return smsc;
}
@@ -2790,7 +2788,7 @@
* </p>
*
* @param smsc the SMSC address string.
- * @return true for success, false otherwise.
+ * @return true for success, false otherwise. Failure can be due modem returning an error.
*/
@SuppressAutoDoc // for carrier privileges and default SMS application.
@RequiresPermission(android.Manifest.permission.MODIFY_PHONE_STATE)
@@ -2802,7 +2800,7 @@
smsc, getSubscriptionId(), null);
}
} catch (RemoteException ex) {
- // ignore it
+ throw new RuntimeException(ex);
}
return false;
}
diff --git a/telephony/java/android/telephony/TelephonyManager.java b/telephony/java/android/telephony/TelephonyManager.java
index 8cfc8b4..e502b9e 100644
--- a/telephony/java/android/telephony/TelephonyManager.java
+++ b/telephony/java/android/telephony/TelephonyManager.java
@@ -3010,64 +3010,6 @@
}
/**
- * Network Class Definitions.
- * Do not change this order, it is used for sorting during emergency calling in
- * {@link TelephonyConnectionService#getFirstPhoneForEmergencyCall()}. Any newer technologies
- * should be added after the current definitions.
- */
- /** Unknown network class. {@hide} */
- public static final int NETWORK_CLASS_UNKNOWN = 0;
- /** Class of broadly defined "2G" networks. {@hide} */
- @UnsupportedAppUsage
- public static final int NETWORK_CLASS_2_G = 1;
- /** Class of broadly defined "3G" networks. {@hide} */
- @UnsupportedAppUsage
- public static final int NETWORK_CLASS_3_G = 2;
- /** Class of broadly defined "4G" networks. {@hide} */
- @UnsupportedAppUsage
- public static final int NETWORK_CLASS_4_G = 3;
- /** Class of broadly defined "5G" networks. {@hide} */
- public static final int NETWORK_CLASS_5_G = 4;
-
- /**
- * Return general class of network type, such as "3G" or "4G". In cases
- * where classification is contentious, this method is conservative.
- *
- * @hide
- */
- @UnsupportedAppUsage
- public static int getNetworkClass(int networkType) {
- switch (networkType) {
- case NETWORK_TYPE_GPRS:
- case NETWORK_TYPE_GSM:
- case NETWORK_TYPE_EDGE:
- case NETWORK_TYPE_CDMA:
- case NETWORK_TYPE_1xRTT:
- case NETWORK_TYPE_IDEN:
- return NETWORK_CLASS_2_G;
- case NETWORK_TYPE_UMTS:
- case NETWORK_TYPE_EVDO_0:
- case NETWORK_TYPE_EVDO_A:
- case NETWORK_TYPE_HSDPA:
- case NETWORK_TYPE_HSUPA:
- case NETWORK_TYPE_HSPA:
- case NETWORK_TYPE_EVDO_B:
- case NETWORK_TYPE_EHRPD:
- case NETWORK_TYPE_HSPAP:
- case NETWORK_TYPE_TD_SCDMA:
- return NETWORK_CLASS_3_G;
- case NETWORK_TYPE_LTE:
- case NETWORK_TYPE_IWLAN:
- case NETWORK_TYPE_LTE_CA:
- return NETWORK_CLASS_4_G;
- case NETWORK_TYPE_NR:
- return NETWORK_CLASS_5_G;
- default:
- return NETWORK_CLASS_UNKNOWN;
- }
- }
-
- /**
* Returns a string representation of the radio technology (network type)
* currently in use on the device.
* @return the name of the radio technology
@@ -3849,19 +3791,19 @@
}
/**
- * Return if the current radio has global mode enabled, meaning it supports
- * both 3GPP and 3GPP2 radio technologies at the same time.
+ * Return if the current radio can support both 3GPP and 3GPP2 radio technologies at the same
+ * time. This is also known as global mode, which includes LTE, CDMA, EvDo and GSM/WCDMA.
*
* <p>If this object has been created with {@link #createForSubscriptionId}, applies to the
* given subId. Otherwise, applies to {@link SubscriptionManager#getDefaultSubscriptionId()}.
*
- * @return {@code true} if global mode is enabled
- * {@code false} if global mode is not enabled or unknown
+ * @return {@code true} if 3GPP and 3GPP2 radio technologies can be supported at the same time
+ * {@code false} if not supported or unknown
* @hide
*/
@SystemApi
@RequiresPermission(android.Manifest.permission.READ_PRIVILEGED_PHONE_STATE)
- public boolean isGlobalModeEnabled() {
+ public boolean isLteCdmaEvdoGsmWcdmaEnabled() {
return getLteOnCdmaMode(getSubId()) == PhoneConstants.LTE_ON_CDMA_TRUE;
}
@@ -8642,13 +8584,9 @@
return false;
}
- /**
- * @deprecated use {@link #supplyPinReportPinResult(String pin)} instead.
- *
- * @hide */
+ /** @hide */
@SystemApi
@RequiresPermission(android.Manifest.permission.MODIFY_PHONE_STATE)
- @Deprecated
public int[] supplyPinReportResult(String pin) {
try {
ITelephony telephony = getITelephony();
@@ -8660,13 +8598,9 @@
return new int[0];
}
- /**
- * @deprecated use {@link #supplyPukReportPinResult(String puk, String pin)} instead.
- *
- * @hide */
+ /** @hide */
@SystemApi
@RequiresPermission(android.Manifest.permission.MODIFY_PHONE_STATE)
- @Deprecated
public int[] supplyPukReportResult(String puk, String pin) {
try {
ITelephony telephony = getITelephony();
@@ -9686,14 +9620,12 @@
* Powers down the SIM. SIM must be up prior.
* @hide
*/
- @SystemApi
public static final int CARD_POWER_DOWN = 0;
/**
* Powers up the SIM normally. SIM must be down prior.
* @hide
*/
- @SystemApi
public static final int CARD_POWER_UP = 1;
/**
@@ -9711,7 +9643,6 @@
* is NOT persistent across boots. On reboot, SIM will power up normally.
* @hide
*/
- @SystemApi
public static final int CARD_POWER_UP_PASS_THROUGH = 2;
/**
@@ -11474,6 +11405,55 @@
@SystemApi
public static final long NETWORK_TYPE_BITMASK_IWLAN = (1 << (NETWORK_TYPE_IWLAN -1));
+ /** @hide */
+ public static final long NETWORK_CLASS_BITMASK_2G = NETWORK_TYPE_BITMASK_GSM
+ | NETWORK_TYPE_BITMASK_GPRS
+ | NETWORK_TYPE_BITMASK_EDGE
+ | NETWORK_TYPE_BITMASK_CDMA
+ | NETWORK_TYPE_BITMASK_1xRTT;
+
+ /** @hide */
+ public static final long NETWORK_CLASS_BITMASK_3G = NETWORK_TYPE_BITMASK_EVDO_0
+ | NETWORK_TYPE_BITMASK_EVDO_A
+ | NETWORK_TYPE_BITMASK_EVDO_B
+ | NETWORK_TYPE_BITMASK_EHRPD
+ | NETWORK_TYPE_BITMASK_HSUPA
+ | NETWORK_TYPE_BITMASK_HSDPA
+ | NETWORK_TYPE_BITMASK_HSPA
+ | NETWORK_TYPE_BITMASK_HSPAP
+ | NETWORK_TYPE_BITMASK_UMTS
+ | NETWORK_TYPE_BITMASK_TD_SCDMA;
+
+ /** @hide */
+ public static final long NETWORK_CLASS_BITMASK_4G = NETWORK_TYPE_BITMASK_LTE
+ | NETWORK_TYPE_BITMASK_LTE_CA
+ | NETWORK_TYPE_BITMASK_IWLAN;
+
+ /** @hide */
+ public static final long NETWORK_CLASS_BITMASK_5G = NETWORK_TYPE_BITMASK_NR;
+
+ /** @hide */
+ public static final long NETWORK_STANDARDS_FAMILY_BITMASK_3GPP = NETWORK_TYPE_BITMASK_GSM
+ | NETWORK_TYPE_BITMASK_GPRS
+ | NETWORK_TYPE_BITMASK_EDGE
+ | NETWORK_TYPE_BITMASK_HSUPA
+ | NETWORK_TYPE_BITMASK_HSDPA
+ | NETWORK_TYPE_BITMASK_HSPA
+ | NETWORK_TYPE_BITMASK_HSPAP
+ | NETWORK_TYPE_BITMASK_UMTS
+ | NETWORK_TYPE_BITMASK_TD_SCDMA
+ | NETWORK_TYPE_BITMASK_LTE
+ | NETWORK_TYPE_BITMASK_LTE_CA
+ | NETWORK_TYPE_BITMASK_NR;
+
+ /** @hide */
+ public static final long NETWORK_STANDARDS_FAMILY_BITMASK_3GPP2 = NETWORK_TYPE_BITMASK_CDMA
+ | NETWORK_TYPE_BITMASK_1xRTT
+ | NETWORK_TYPE_BITMASK_EVDO_0
+ | NETWORK_TYPE_BITMASK_EVDO_A
+ | NETWORK_TYPE_BITMASK_EVDO_B
+ | NETWORK_TYPE_BITMASK_EHRPD;
+
/**
* @return Modem supported radio access family bitmask
*
@@ -12168,6 +12148,17 @@
"android.telephony.extra.NETWORK_COUNTRY";
/**
+ * The extra used with an {@link #ACTION_NETWORK_COUNTRY_CHANGED} to specify the
+ * last known the country code in ISO-3166-1 alpha-2 format.
+ * <p class="note">
+ * Retrieve with {@link android.content.Intent#getStringExtra(String)}.
+ *
+ * @hide
+ */
+ public static final String EXTRA_LAST_KNOWN_NETWORK_COUNTRY =
+ "android.telephony.extra.LAST_KNOWN_NETWORK_COUNTRY";
+
+ /**
* Indicate if the user is allowed to use multiple SIM cards at the same time to register
* on the network (e.g. Dual Standby or Dual Active) when the device supports it, or if the
* usage is restricted. This API is used to prevent usage of multiple SIM card, based on
diff --git a/telephony/java/com/android/internal/telephony/DctConstants.java b/telephony/java/com/android/internal/telephony/DctConstants.java
index f61d4e1..3e1d72c 100644
--- a/telephony/java/com/android/internal/telephony/DctConstants.java
+++ b/telephony/java/com/android/internal/telephony/DctConstants.java
@@ -126,4 +126,7 @@
public static final String PROVISIONING_URL_KEY = "provisioningUrl";
public static final String BANDWIDTH_SOURCE_MODEM_KEY = "modem";
public static final String BANDWIDTH_SOURCE_CARRIER_CONFIG_KEY = "carrier_config";
+ public static final String RAT_NAME_LTE = "LTE";
+ public static final String RAT_NAME_NR_NSA = "NR_NSA";
+ public static final String RAT_NAME_NR_NSA_MMWAVE = "NR_NSA_MMWAVE";
}
diff --git a/tests/AppLaunch/src/com/android/tests/applaunch/AppLaunch.java b/tests/AppLaunch/src/com/android/tests/applaunch/AppLaunch.java
index 8b182b7..da5a151d 100644
--- a/tests/AppLaunch/src/com/android/tests/applaunch/AppLaunch.java
+++ b/tests/AppLaunch/src/com/android/tests/applaunch/AppLaunch.java
@@ -41,11 +41,16 @@
import java.io.File;
import java.io.FileInputStream;
import java.io.FileOutputStream;
+import java.io.FileWriter;
import java.io.IOException;
import java.io.InputStream;
import java.io.InputStreamReader;
import java.io.OutputStreamWriter;
+import java.time.format.DateTimeFormatter;
+import java.time.ZonedDateTime;
+import java.time.ZoneOffset;
import java.util.ArrayList;
+import java.util.Arrays;
import java.util.HashMap;
import java.util.HashSet;
import java.util.LinkedHashMap;
@@ -72,6 +77,7 @@
private static final String KEY_REQUIRED_ACCOUNTS = "required_accounts";
private static final String KEY_APPS = "apps";
private static final String KEY_IORAP_TRIAL_LAUNCH = "iorap_trial_launch";
+ private static final String KEY_IORAP_COMPILER_FILTERS = "iorap_compiler_filters";
private static final String KEY_TRIAL_LAUNCH = "trial_launch";
private static final String KEY_LAUNCH_ITERATIONS = "launch_iterations";
private static final String KEY_LAUNCH_ORDER = "launch_order";
@@ -153,6 +159,7 @@
private BufferedWriter mBufferedWriter = null;
private boolean mSimplePerfAppOnly = false;
private String[] mCompilerFilters = null;
+ private List<String> mIorapCompilerFilters = null;
private String mLastAppName = "";
private boolean mCycleCleanUp = false;
private boolean mTraceAll = false;
@@ -501,22 +508,93 @@
* based on status of the compilation command.
*/
private boolean compileAppForIorap(String appPkgName) throws IOException {
+ String logcatTimestamp = getTimeNowForLogcat();
+
getInstrumentation().getUiAutomation().
executeShellCommand(IORAP_COMPILE_CMD);
- for (int i = 0; i < IORAP_COMPILE_CMD_TIMEOUT; ++i) {
+ int i = 0;
+ for (i = 0; i < IORAP_COMPILE_CMD_TIMEOUT; ++i) {
IorapCompilationStatus status = waitForIorapCompiled(appPkgName);
if (status == IorapCompilationStatus.COMPLETE) {
- return true;
+ Log.v(TAG, "compileAppForIorap: success");
+ logDumpsysIorapd(appPkgName);
+ break;
} else if (status == IorapCompilationStatus.INSUFFICIENT_TRACES) {
+ Log.e(TAG, "compileAppForIorap: failed due to insufficient traces");
+ logDumpsysIorapd(appPkgName);
return false;
} // else INCOMPLETE. keep asking iorapd if it's done yet.
sleep(1000);
}
+ if (i == IORAP_COMPILE_CMD_TIMEOUT) {
+ Log.e(TAG, "compileAppForIorap: failed due to timeout");
+ logDumpsysIorapd(appPkgName);
+ return false;
+ }
+
+ // Wait for the job to finish completely.
+ // Other packages could be compiled in cyclic runs.
+ int currentAttempt = 0;
+ do {
+ String logcatLines = getLogcatSinceTime(logcatTimestamp);
+ if (logcatLines.contains("IorapForwardingService: Finished background job")) {
+ return true;
+ }
+ sleep(1000);
+ } while (currentAttempt++ < IORAP_COMPILE_CMD_TIMEOUT);
+
+ Log.e(TAG, "compileAppForIorap: failed due to jobscheduler timeout.");
return false;
}
+ /** Save the contents of $(adb shell dumpsys iorapd) to the launch_logs directory. */
+ private void logDumpsysIorapd(String packageName) throws IOException {
+ InstrumentationTestRunner instrumentation =
+ (InstrumentationTestRunner)getInstrumentation();
+ Bundle args = instrumentation.getArguments();
+
+ String launchDirectory = args.getString(KEY_LAUNCH_DIRECTORY);
+
+ // Root directory for applaunch file to log the app launch output
+ // Will be useful in case of simpleperf command is used
+ File launchRootDir = null;
+ if (null != launchDirectory && !launchDirectory.isEmpty()) {
+ launchRootDir = new File(launchDirectory);
+ if (!launchRootDir.exists() && !launchRootDir.mkdirs()) {
+ throw new IOException("Unable to create the destination directory "
+ + launchRootDir + ". Try disabling selinux.");
+ }
+ } else {
+ Log.w(TAG, "logDumpsysIorapd: Missing launch-directory arg");
+ return;
+ }
+
+ File launchSubDir = new File(launchRootDir, LAUNCH_SUB_DIRECTORY);
+
+ if (!launchSubDir.exists() && !launchSubDir.mkdirs()) {
+ throw new IOException("Unable to create the lauch file sub directory "
+ + launchSubDir + ". Try disabling selinux.");
+ }
+ String path = "iorapd_dumpsys_" + packageName + "_" + System.nanoTime() + ".txt";
+ File file = new File(launchSubDir, path);
+ try (FileOutputStream outputStream = new FileOutputStream(file);
+ BufferedWriter writer = new BufferedWriter(
+ new OutputStreamWriter(outputStream));
+ ParcelFileDescriptor result = getInstrumentation().getUiAutomation().
+ executeShellCommand(IORAP_DUMPSYS_CMD);
+ BufferedReader bufferedReader = new BufferedReader(new InputStreamReader(
+ new FileInputStream(result.getFileDescriptor())))) {
+ String line;
+ while ((line = bufferedReader.readLine()) != null) {
+ writer.write(line + "\n");
+ }
+ }
+
+ Log.v(TAG, "logDumpsysIorapd: Saved to file: " + path);
+ }
+
enum IorapCompilationStatus {
INCOMPLETE,
COMPLETE,
@@ -564,6 +642,24 @@
return reason;
}
+ private boolean shouldIncludeIorap(String compilerFilter) {
+ if (!mIorapTrialLaunch) {
+ return false;
+ }
+
+ // No iorap compiler filters specified: treat all compiler filters as ok.
+ if (mIorapCompilerFilters == null) {
+ return true;
+ }
+
+ // iorap compiler filters specified: the compilerFilter must be in the whitelist.
+ if (mIorapCompilerFilters.indexOf(compilerFilter) != -1) {
+ return true;
+ }
+
+ return false;
+ }
+
/**
* If launch order is "cyclic" then apps will be launched one after the
* other for each iteration count.
@@ -578,7 +674,7 @@
mLaunchOrderList.add(new LaunchOrder(app, compilerFilter, TRIAL_LAUNCH, /*iorapEnabled*/false));
}
}
- if (mIorapTrialLaunch) {
+ if (shouldIncludeIorap(compilerFilter)) {
for (int launchCount = 0; launchCount < IORAP_TRIAL_LAUNCH_ITERATIONS; ++launchCount) {
for (String app : mNameToResultKey.keySet()) {
String reason = makeReasonForIorapTrialLaunch(launchCount);
@@ -592,14 +688,16 @@
for (int launchCount = 0; launchCount < mLaunchIterations; launchCount++) {
for (String app : mNameToResultKey.keySet()) {
mLaunchOrderList.add(new LaunchOrder(app, compilerFilter,
- String.format(LAUNCH_ITERATION, launchCount), mIorapTrialLaunch));
+ String.format(LAUNCH_ITERATION, launchCount),
+ shouldIncludeIorap(compilerFilter)));
}
}
if (mTraceDirectoryStr != null && !mTraceDirectoryStr.isEmpty()) {
for (int traceCount = 0; traceCount < mTraceLaunchCount; traceCount++) {
for (String app : mNameToResultKey.keySet()) {
mLaunchOrderList.add(new LaunchOrder(app, compilerFilter,
- String.format(TRACE_ITERATION, traceCount), mIorapTrialLaunch));
+ String.format(TRACE_ITERATION, traceCount),
+ shouldIncludeIorap(compilerFilter)));
}
}
}
@@ -610,7 +708,7 @@
if (mTrialLaunch) {
mLaunchOrderList.add(new LaunchOrder(app, compilerFilter, TRIAL_LAUNCH, /*iorapEnabled*/false));
}
- if (mIorapTrialLaunch) {
+ if (shouldIncludeIorap(compilerFilter)) {
for (int launchCount = 0; launchCount < IORAP_TRIAL_LAUNCH_ITERATIONS; ++launchCount) {
String reason = makeReasonForIorapTrialLaunch(launchCount);
mLaunchOrderList.add(
@@ -621,12 +719,14 @@
}
for (int launchCount = 0; launchCount < mLaunchIterations; launchCount++) {
mLaunchOrderList.add(new LaunchOrder(app, compilerFilter,
- String.format(LAUNCH_ITERATION, launchCount), mIorapTrialLaunch));
+ String.format(LAUNCH_ITERATION, launchCount),
+ shouldIncludeIorap(compilerFilter)));
}
if (mTraceDirectoryStr != null && !mTraceDirectoryStr.isEmpty()) {
for (int traceCount = 0; traceCount < mTraceLaunchCount; traceCount++) {
mLaunchOrderList.add(new LaunchOrder(app, compilerFilter,
- String.format(TRACE_ITERATION, traceCount), mIorapTrialLaunch));
+ String.format(TRACE_ITERATION, traceCount),
+ shouldIncludeIorap(compilerFilter)));
}
}
}
@@ -659,6 +759,41 @@
return total.contains("root");
}
+ private void stopIorapd() {
+ getInstrumentation().getUiAutomation()
+ .executeShellCommand("stop iorapd");
+ sleep(100); // give it extra time to fully stop.
+ }
+
+ private void startIorapd() {
+ String logcatTimeNow = getTimeNowForLogcat();
+ Log.v(TAG, "startIorapd, logcat time: " + logcatTimeNow);
+
+ getInstrumentation().getUiAutomation()
+ .executeShellCommand("start iorapd");
+
+ int maxAttempts = 100;
+ int attempt = 0;
+ do {
+ // Ensure that IorapForwardingService fully reconnects to iorapd before proceeding.
+ String needle = "Connected to iorapd native service";
+ String logcatLines = getLogcatSinceTime(logcatTimeNow);
+
+ if (logcatLines.contains(needle)) {
+ break;
+ }
+
+ sleep(1000);
+ attempt++;
+ } while (attempt < maxAttempts);
+
+ if (attempt == maxAttempts) {
+ Log.e(TAG, "Timed out after waiting for iorapd to start");
+ }
+ // Wait a little bit longer for iorapd to settle.
+ sleep(1000);
+ }
+
// Delete all db rows and files associated with a package in iorapd.
// Effectively deletes any raw or compiled trace files, unoptimizing the package in iorap.
private void purgeIorapPackage(String packageName) {
@@ -670,15 +805,65 @@
throw new AssertionError(e);
}
- getInstrumentation().getUiAutomation()
- .executeShellCommand("stop iorapd");
- sleep(100); // give iorapd enough time to stop.
+ Log.v(TAG, "Purge iorap package: " + packageName);
+ stopIorapd();
getInstrumentation().getUiAutomation()
.executeShellCommand(String.format(IORAP_MAINTENANCE_CMD, packageName));
Log.v(TAG, "Executed: " + String.format(IORAP_MAINTENANCE_CMD, packageName));
- getInstrumentation().getUiAutomation()
- .executeShellCommand("start iorapd");
- sleep(2000); // give iorapd enough time to start up.
+ startIorapd();
+ }
+
+ String executeShellCommandWithTempFile(String cmd) {
+ Log.v(TAG, "executeShellCommandWithTempFile, cmd: " + cmd);
+ try {
+ //File outputDir =
+ // InstrumentationRegistry.getInstrumentation().getContext().getCacheDir();
+ File outputFile = File.createTempFile("exec_shell_command", ".sh");
+
+ try {
+ outputFile.setWritable(true);
+ outputFile.setExecutable(true, /*ownersOnly*/false);
+
+ String scriptPath = outputFile.toString();
+
+ // If this works correctly, the next log-line will print 'Success'.
+ try (BufferedWriter writer = new BufferedWriter(new FileWriter(scriptPath))) {
+ writer.write(cmd);
+ }
+
+ String resultString = "";
+ try (ParcelFileDescriptor result = getInstrumentation().getUiAutomation().
+ executeShellCommand(scriptPath);
+ BufferedReader bufferedReader = new BufferedReader(new InputStreamReader(
+ new FileInputStream(result.getFileDescriptor())))) {
+ String line;
+ while ((line = bufferedReader.readLine()) != null) {
+ resultString += line + "\n";
+ }
+ }
+
+ return resultString;
+ } finally {
+ outputFile.delete();
+ }
+ } catch (IOException e) {
+ throw new AssertionError("Failed to execute shell command: " + cmd, e);
+ }
+ }
+
+ // Get the 'now' timestamp usable with $(adb logcat -v utc -T "time string")
+ String getTimeNowForLogcat() {
+ ZonedDateTime utc = ZonedDateTime.now(ZoneOffset.UTC);
+
+ // YYYY-MM-DD hh:mm:ss.mmm
+ return utc.format(DateTimeFormatter.ofPattern("yyyy-MM-dd HH:mm:ss.SSS"));
+ }
+
+ String getLogcatSinceTime(String logcatTime) {
+ // The time has spaces in it but must be passed as a single arg.
+ // Therefore use a temp script file.
+ return executeShellCommandWithTempFile(
+ String.format("logcat -d -v threadtime -v utc -T '%s'", logcatTime));
}
/**
@@ -705,15 +890,12 @@
throw new AssertionError(e);
}
- getInstrumentation().getUiAutomation()
- .executeShellCommand("stop iorapd");
+ stopIorapd();
getInstrumentation().getUiAutomation()
.executeShellCommand(String.format("setprop iorapd.perfetto.enable %b", enable));
getInstrumentation().getUiAutomation()
.executeShellCommand(String.format("setprop iorapd.readahead.enable %b", enable));
- getInstrumentation().getUiAutomation()
- .executeShellCommand("start iorapd");
- sleep(2000); // give enough time for iorapd to start back up.
+ startIorapd();
if (enable) {
mIorapStatus = IorapStatus.ENABLED;
@@ -768,6 +950,13 @@
mCompilerFilters = new String[1];
}
+ String iorapCompilerFilterList = args.getString(KEY_IORAP_COMPILER_FILTERS);
+ if (iorapCompilerFilterList != null) {
+ // Passing in iorap compiler filters implies an iorap trial launch.
+ mIorapTrialLaunch = true;
+ mIorapCompilerFilters = Arrays.asList(iorapCompilerFilterList.split("\\|"));
+ }
+
// Pre-populate the results map to avoid null checks.
for (String app : mNameToLaunchTime.keySet()) {
HashMap<String, List<AppLaunchResult>> map = new HashMap<>();
diff --git a/tests/net/common/java/android/net/LinkPropertiesTest.java b/tests/net/common/java/android/net/LinkPropertiesTest.java
index 2b5720a..8de27e8 100644
--- a/tests/net/common/java/android/net/LinkPropertiesTest.java
+++ b/tests/net/common/java/android/net/LinkPropertiesTest.java
@@ -445,14 +445,20 @@
// Check comparisons work.
LinkProperties lp2 = new LinkProperties(lp);
assertAllRoutesHaveInterface("wlan0", lp2);
- assertEquals(0, lp.compareAllRoutes(lp2).added.size());
- assertEquals(0, lp.compareAllRoutes(lp2).removed.size());
+ // LinkProperties#compareAllRoutes exists both in R and before R, but the return type
+ // changed in R, so a test compiled with the R version of LinkProperties cannot run on Q.
+ if (isAtLeastR()) {
+ assertEquals(0, lp.compareAllRoutes(lp2).added.size());
+ assertEquals(0, lp.compareAllRoutes(lp2).removed.size());
+ }
lp2.setInterfaceName("p2p0");
assertAllRoutesHaveInterface("p2p0", lp2);
assertAllRoutesNotHaveInterface("wlan0", lp2);
- assertEquals(3, lp.compareAllRoutes(lp2).added.size());
- assertEquals(3, lp.compareAllRoutes(lp2).removed.size());
+ if (isAtLeastR()) {
+ assertEquals(3, lp.compareAllRoutes(lp2).added.size());
+ assertEquals(3, lp.compareAllRoutes(lp2).removed.size());
+ }
// Remove route with incorrect interface, no route removed.
lp.removeRoute(new RouteInfo(prefix2, null, null));
@@ -480,6 +486,8 @@
assertEquals(1, rmnet0.getLinkAddresses().size());
assertEquals(1, rmnet0.getAllAddresses().size());
assertEquals(1, rmnet0.getAllLinkAddresses().size());
+ assertEquals(1, rmnet0.getAllInterfaceNames().size());
+ assertEquals("rmnet0", rmnet0.getAllInterfaceNames().get(0));
rmnet0.addStackedLink(clat4);
assertEquals(1, rmnet0.getStackedLinks().size());
@@ -487,6 +495,9 @@
assertEquals(1, rmnet0.getLinkAddresses().size());
assertEquals(2, rmnet0.getAllAddresses().size());
assertEquals(2, rmnet0.getAllLinkAddresses().size());
+ assertEquals(2, rmnet0.getAllInterfaceNames().size());
+ assertEquals("rmnet0", rmnet0.getAllInterfaceNames().get(0));
+ assertEquals("clat4", rmnet0.getAllInterfaceNames().get(1));
rmnet0.addStackedLink(clat4);
assertEquals(1, rmnet0.getStackedLinks().size());
@@ -494,6 +505,9 @@
assertEquals(1, rmnet0.getLinkAddresses().size());
assertEquals(2, rmnet0.getAllAddresses().size());
assertEquals(2, rmnet0.getAllLinkAddresses().size());
+ assertEquals(2, rmnet0.getAllInterfaceNames().size());
+ assertEquals("rmnet0", rmnet0.getAllInterfaceNames().get(0));
+ assertEquals("clat4", rmnet0.getAllInterfaceNames().get(1));
assertEquals(0, clat4.getStackedLinks().size());
@@ -513,6 +527,8 @@
assertEquals(1, rmnet0.getLinkAddresses().size());
assertEquals(1, rmnet0.getAllAddresses().size());
assertEquals(1, rmnet0.getAllLinkAddresses().size());
+ assertEquals(1, rmnet0.getAllInterfaceNames().size());
+ assertEquals("rmnet0", rmnet0.getAllInterfaceNames().get(0));
assertFalse(rmnet0.removeStackedLink("clat4"));
}
@@ -936,7 +952,7 @@
}
- @Test
+ @Test @IgnoreUpTo(Build.VERSION_CODES.Q)
public void testCompareResult() {
// Either adding or removing items
compareResult(Arrays.asList(1, 2, 3, 4), Arrays.asList(1),
@@ -1197,4 +1213,48 @@
lp.clear();
assertNull(lp.getCaptivePortalData());
}
+
+ private LinkProperties makeIpv4LinkProperties() {
+ final LinkProperties linkProperties = new LinkProperties();
+ linkProperties.setInterfaceName(NAME);
+ linkProperties.addLinkAddress(LINKADDRV4);
+ linkProperties.addDnsServer(DNS1);
+ linkProperties.addRoute(new RouteInfo(GATEWAY1));
+ linkProperties.addRoute(new RouteInfo(GATEWAY2));
+ return linkProperties;
+ }
+
+ private LinkProperties makeIpv6LinkProperties() {
+ final LinkProperties linkProperties = new LinkProperties();
+ linkProperties.setInterfaceName(NAME);
+ linkProperties.addLinkAddress(LINKADDRV6);
+ linkProperties.addDnsServer(DNS6);
+ linkProperties.addRoute(new RouteInfo(GATEWAY61));
+ linkProperties.addRoute(new RouteInfo(GATEWAY62));
+ return linkProperties;
+ }
+
+ @Test
+ public void testHasIpv4DefaultRoute() {
+ final LinkProperties Ipv4 = makeIpv4LinkProperties();
+ assertTrue(Ipv4.hasIpv4DefaultRoute());
+ final LinkProperties Ipv6 = makeIpv6LinkProperties();
+ assertFalse(Ipv6.hasIpv4DefaultRoute());
+ }
+
+ @Test
+ public void testHasIpv4DnsServer() {
+ final LinkProperties Ipv4 = makeIpv4LinkProperties();
+ assertTrue(Ipv4.hasIpv4DnsServer());
+ final LinkProperties Ipv6 = makeIpv6LinkProperties();
+ assertFalse(Ipv6.hasIpv4DnsServer());
+ }
+
+ @Test
+ public void testHasIpv6DnsServer() {
+ final LinkProperties Ipv4 = makeIpv4LinkProperties();
+ assertFalse(Ipv4.hasIpv6DnsServer());
+ final LinkProperties Ipv6 = makeIpv6LinkProperties();
+ assertTrue(Ipv6.hasIpv6DnsServer());
+ }
}
diff --git a/tests/net/common/java/android/net/MatchAllNetworkSpecifierTest.kt b/tests/net/common/java/android/net/MatchAllNetworkSpecifierTest.kt
new file mode 100644
index 0000000..ef15b66
--- /dev/null
+++ b/tests/net/common/java/android/net/MatchAllNetworkSpecifierTest.kt
@@ -0,0 +1,50 @@
+/*
+ * Copyright (C) 2020 The Android Open Source Project
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package android.net
+
+import android.net.wifi.aware.DiscoverySession
+import android.net.wifi.aware.PeerHandle
+import android.net.wifi.aware.WifiAwareNetworkSpecifier
+import androidx.test.filters.SmallTest
+import androidx.test.runner.AndroidJUnit4
+
+import com.android.testutils.assertParcelSane
+
+import java.lang.IllegalStateException
+
+import org.junit.Test
+import org.junit.runner.RunWith
+import org.mockito.Mockito
+
+@RunWith(AndroidJUnit4::class)
+@SmallTest
+class MatchAllNetworkSpecifierTest {
+ @Test
+ fun testParcel() {
+ assertParcelSane(MatchAllNetworkSpecifier(), 0)
+ }
+
+ @Test(expected = IllegalStateException::class)
+ fun testSatisfiedBy() {
+ val specifier = MatchAllNetworkSpecifier()
+ val discoverySession = Mockito.mock(DiscoverySession::class.java)
+ val peerHandle = Mockito.mock(PeerHandle::class.java)
+ val wifiAwareNetworkSpecifier = WifiAwareNetworkSpecifier.Builder(discoverySession,
+ peerHandle).build()
+ specifier.satisfiedBy(wifiAwareNetworkSpecifier)
+ }
+}
diff --git a/tests/net/common/java/android/net/NetworkCapabilitiesTest.java b/tests/net/common/java/android/net/NetworkCapabilitiesTest.java
index 9fe1883..316a83a 100644
--- a/tests/net/common/java/android/net/NetworkCapabilitiesTest.java
+++ b/tests/net/common/java/android/net/NetworkCapabilitiesTest.java
@@ -58,6 +58,7 @@
import org.junit.Test;
import org.junit.runner.RunWith;
+import java.util.Arrays;
import java.util.Set;
@RunWith(AndroidJUnit4.class)
@@ -280,6 +281,7 @@
.addCapability(NET_CAPABILITY_NOT_METERED);
if (isAtLeastR()) {
netCap.setOwnerUid(123);
+ netCap.setAdministratorUids(new int[] {5, 11});
}
assertParcelingIsLossless(netCap);
netCap.setSSID(TEST_SSID);
@@ -440,6 +442,23 @@
}
@Test
+ public void testSetAdministratorUids() {
+ NetworkCapabilities nc =
+ new NetworkCapabilities().setAdministratorUids(new int[] {2, 1, 3});
+
+ assertArrayEquals(new int[] {1, 2, 3}, nc.getAdministratorUids());
+ }
+
+ @Test
+ public void testSetAdministratorUidsWithDuplicates() {
+ try {
+ new NetworkCapabilities().setAdministratorUids(new int[] {1, 1});
+ fail("Expected IllegalArgumentException for duplicate uids");
+ } catch (IllegalArgumentException expected) {
+ }
+ }
+
+ @Test
public void testCombineCapabilities() {
NetworkCapabilities nc1 = new NetworkCapabilities();
NetworkCapabilities nc2 = new NetworkCapabilities();
@@ -463,7 +482,9 @@
nc1.setSSID(TEST_SSID);
nc2.combineCapabilities(nc1);
- assertTrue(TEST_SSID.equals(nc2.getSSID()));
+ if (isAtLeastR()) {
+ assertTrue(TEST_SSID.equals(nc2.getSsid()));
+ }
// Because they now have the same SSID, the following call should not throw
nc2.combineCapabilities(nc1);
@@ -489,6 +510,25 @@
assertFalse(nc2.appliesToUid(12));
assertTrue(nc1.appliesToUid(22));
assertTrue(nc2.appliesToUid(22));
+
+ final int[] adminUids = {3, 6, 12};
+ nc1.setAdministratorUids(adminUids);
+ nc2.combineCapabilities(nc1);
+ assertTrue(nc2.equalsAdministratorUids(nc1));
+ assertArrayEquals(nc2.getAdministratorUids(), adminUids);
+
+ final int[] adminUidsOtherOrder = {3, 12, 6};
+ nc1.setAdministratorUids(adminUids);
+ assertTrue(nc2.equalsAdministratorUids(nc1));
+
+ final int[] adminUids2 = {11, 1, 12, 3, 6};
+ nc1.setAdministratorUids(adminUids2);
+ assertFalse(nc2.equalsAdministratorUids(nc1));
+ assertFalse(Arrays.equals(nc2.getAdministratorUids(), adminUids2));
+ try {
+ nc2.combineCapabilities(nc1);
+ fail("Shouldn't be able to combine different lists of admin UIDs");
+ } catch (IllegalStateException expected) { }
}
@Test
@@ -601,12 +641,16 @@
// from nc2.
assertFalse(nc2.hasCapability(NET_CAPABILITY_NOT_ROAMING));
assertTrue(nc2.hasUnwantedCapability(NET_CAPABILITY_NOT_ROAMING));
- assertTrue(TEST_SSID.equals(nc2.getSSID()));
+ if (isAtLeastR()) {
+ assertTrue(TEST_SSID.equals(nc2.getSsid()));
+ }
nc1.setSSID(DIFFERENT_TEST_SSID);
nc2.set(nc1);
assertEquals(nc1, nc2);
- assertTrue(DIFFERENT_TEST_SSID.equals(nc2.getSSID()));
+ if (isAtLeastR()) {
+ assertTrue(DIFFERENT_TEST_SSID.equals(nc2.getSsid()));
+ }
nc1.setUids(uidRange(10, 13));
nc2.set(nc1); // Overwrites, as opposed to combineCapabilities
diff --git a/tests/net/integration/src/com/android/server/net/integrationtests/TestNetworkStackService.kt b/tests/net/integration/src/com/android/server/net/integrationtests/TestNetworkStackService.kt
index 23caf49..eec3cdbe 100644
--- a/tests/net/integration/src/com/android/server/net/integrationtests/TestNetworkStackService.kt
+++ b/tests/net/integration/src/com/android/server/net/integrationtests/TestNetworkStackService.kt
@@ -24,7 +24,6 @@
import android.net.metrics.IpConnectivityLog
import android.net.util.SharedLog
import android.os.IBinder
-import com.android.networkstack.metrics.DataStallStatsUtils
import com.android.networkstack.netlink.TcpSocketTracker
import com.android.server.NetworkStackService
import com.android.server.NetworkStackService.NetworkMonitorConnector
@@ -91,7 +90,6 @@
mock(IpConnectivityLog::class.java), mock(SharedLog::class.java),
mock(NetworkStackService.NetworkStackServiceManager::class.java),
NetworkMonitorDeps(privateDnsBypassNetwork),
- mock(DataStallStatsUtils::class.java),
mock(TcpSocketTracker::class.java))
cb.onNetworkMonitorCreated(NetworkMonitorConnector(nm, TestPermissionChecker()))
}
diff --git a/tests/net/java/android/net/TcpKeepalivePacketDataTest.java b/tests/net/java/android/net/TcpKeepalivePacketDataTest.java
index e632aaf..cea8c57 100644
--- a/tests/net/java/android/net/TcpKeepalivePacketDataTest.java
+++ b/tests/net/java/android/net/TcpKeepalivePacketDataTest.java
@@ -66,10 +66,10 @@
fail("InvalidPacketException: " + e);
}
- 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(InetAddress.getByAddress(testInfo.srcAddress), resultData.getSrcAddress());
+ assertEquals(InetAddress.getByAddress(testInfo.dstAddress), resultData.getDstAddress());
+ assertEquals(testInfo.srcPort, resultData.getSrcPort());
+ assertEquals(testInfo.dstPort, resultData.getDstPort());
assertEquals(testInfo.seq, resultData.tcpSeq);
assertEquals(testInfo.ack, resultData.tcpAck);
assertEquals(testInfo.rcvWnd, resultData.tcpWnd);
diff --git a/tests/net/java/com/android/internal/net/VpnProfileTest.java b/tests/net/java/com/android/internal/net/VpnProfileTest.java
index 8a4b533..ceca6f0 100644
--- a/tests/net/java/com/android/internal/net/VpnProfileTest.java
+++ b/tests/net/java/com/android/internal/net/VpnProfileTest.java
@@ -65,7 +65,7 @@
assertTrue(p.getAllowedAlgorithms() != null && p.getAllowedAlgorithms().isEmpty());
assertFalse(p.isBypassable);
assertFalse(p.isMetered);
- assertEquals(1400, p.maxMtu);
+ assertEquals(1360, p.maxMtu);
assertFalse(p.areAuthParamsInline);
}
diff --git a/tests/net/java/com/android/server/ConnectivityServiceTest.java b/tests/net/java/com/android/server/ConnectivityServiceTest.java
index 83399b8..7b9d2bd 100644
--- a/tests/net/java/com/android/server/ConnectivityServiceTest.java
+++ b/tests/net/java/com/android/server/ConnectivityServiceTest.java
@@ -316,6 +316,8 @@
private static final String TEST_PACKAGE_NAME = "com.android.test.package";
private static final String[] EMPTY_STRING_ARRAY = new String[0];
+ private static final String INTERFACE_NAME = "interface";
+
private MockContext mServiceContext;
private HandlerThread mCsHandlerThread;
private ConnectivityService mService;
@@ -6742,16 +6744,12 @@
verify(mIBinder).linkToDeath(any(ConnectivityDiagnosticsCallbackInfo.class), anyInt());
verify(mConnectivityDiagnosticsCallback).asBinder();
- assertTrue(
- mService.mConnectivityDiagnosticsCallbacks.containsKey(
- mConnectivityDiagnosticsCallback));
+ assertTrue(mService.mConnectivityDiagnosticsCallbacks.containsKey(mIBinder));
mService.unregisterConnectivityDiagnosticsCallback(mConnectivityDiagnosticsCallback);
verify(mIBinder, timeout(TIMEOUT_MS))
.unlinkToDeath(any(ConnectivityDiagnosticsCallbackInfo.class), anyInt());
- assertFalse(
- mService.mConnectivityDiagnosticsCallbacks.containsKey(
- mConnectivityDiagnosticsCallback));
+ assertFalse(mService.mConnectivityDiagnosticsCallbacks.containsKey(mIBinder));
verify(mConnectivityDiagnosticsCallback, atLeastOnce()).asBinder();
}
@@ -6769,9 +6767,7 @@
verify(mIBinder).linkToDeath(any(ConnectivityDiagnosticsCallbackInfo.class), anyInt());
verify(mConnectivityDiagnosticsCallback).asBinder();
- assertTrue(
- mService.mConnectivityDiagnosticsCallbacks.containsKey(
- mConnectivityDiagnosticsCallback));
+ assertTrue(mService.mConnectivityDiagnosticsCallbacks.containsKey(mIBinder));
// Register the same callback again
mService.registerConnectivityDiagnosticsCallback(
@@ -6780,9 +6776,7 @@
// Block until all other events are done processing.
HandlerUtilsKt.waitForIdle(mCsHandlerThread, TIMEOUT_MS);
- assertTrue(
- mService.mConnectivityDiagnosticsCallbacks.containsKey(
- mConnectivityDiagnosticsCallback));
+ assertTrue(mService.mConnectivityDiagnosticsCallbacks.containsKey(mIBinder));
}
@Test
@@ -6909,6 +6903,38 @@
mContext.getOpPackageName()));
}
+ @Test
+ public void testRegisterConnectivityDiagnosticsCallbackCallsOnConnectivityReport()
+ throws Exception {
+ // Set up the Network, which leads to a ConnectivityReport being cached for the network.
+ final TestNetworkCallback callback = new TestNetworkCallback();
+ mCm.registerDefaultNetworkCallback(callback);
+ final LinkProperties linkProperties = new LinkProperties();
+ linkProperties.setInterfaceName(INTERFACE_NAME);
+ mCellNetworkAgent = new TestNetworkAgentWrapper(TRANSPORT_CELLULAR, linkProperties);
+ mCellNetworkAgent.connect(true);
+ callback.expectAvailableThenValidatedCallbacks(mCellNetworkAgent);
+ callback.assertNoCallback();
+
+ final NetworkRequest request = new NetworkRequest.Builder().build();
+ when(mConnectivityDiagnosticsCallback.asBinder()).thenReturn(mIBinder);
+
+ mServiceContext.setPermission(
+ android.Manifest.permission.NETWORK_STACK, PERMISSION_GRANTED);
+
+ mService.registerConnectivityDiagnosticsCallback(
+ mConnectivityDiagnosticsCallback, request, mContext.getPackageName());
+
+ // Block until all other events are done processing.
+ HandlerUtilsKt.waitForIdle(mCsHandlerThread, TIMEOUT_MS);
+
+ verify(mConnectivityDiagnosticsCallback)
+ .onConnectivityReportAvailable(argThat(report -> {
+ return INTERFACE_NAME.equals(report.getLinkProperties().getInterfaceName())
+ && report.getNetworkCapabilities().hasTransport(TRANSPORT_CELLULAR);
+ }));
+ }
+
private void setUpConnectivityDiagnosticsCallback() throws Exception {
final NetworkRequest request = new NetworkRequest.Builder().build();
when(mConnectivityDiagnosticsCallback.asBinder()).thenReturn(mIBinder);