Merge "Move NetworkCallback to last parameter for new exposed requestNetwork" into rvc-dev
diff --git a/api/module-lib-current.txt b/api/module-lib-current.txt
index c3c31f5..cfb9b83 100644
--- a/api/module-lib-current.txt
+++ b/api/module-lib-current.txt
@@ -72,19 +72,20 @@
field public static final int TETHERING_WIFI = 0; // 0x0
field public static final int TETHERING_WIFI_P2P = 3; // 0x3
field public static final int TETHER_ERROR_DHCPSERVER_ERROR = 12; // 0xc
- field public static final int TETHER_ERROR_DISABLE_NAT_ERROR = 9; // 0x9
- field public static final int TETHER_ERROR_ENABLE_NAT_ERROR = 8; // 0x8
+ field public static final int TETHER_ERROR_DISABLE_FORWARDING_ERROR = 9; // 0x9
+ field public static final int TETHER_ERROR_ENABLE_FORWARDING_ERROR = 8; // 0x8
field public static final int TETHER_ERROR_ENTITLEMENT_UNKNOWN = 13; // 0xd
field public static final int TETHER_ERROR_IFACE_CFG_ERROR = 10; // 0xa
- field public static final int TETHER_ERROR_MASTER_ERROR = 5; // 0x5
+ field public static final int TETHER_ERROR_INTERNAL_ERROR = 5; // 0x5
field public static final int TETHER_ERROR_NO_ACCESS_TETHERING_PERMISSION = 15; // 0xf
field public static final int TETHER_ERROR_NO_CHANGE_TETHERING_PERMISSION = 14; // 0xe
field public static final int TETHER_ERROR_NO_ERROR = 0; // 0x0
- field public static final int TETHER_ERROR_PROVISION_FAILED = 11; // 0xb
+ field public static final int TETHER_ERROR_PROVISIONING_FAILED = 11; // 0xb
field public static final int TETHER_ERROR_SERVICE_UNAVAIL = 2; // 0x2
field public static final int TETHER_ERROR_TETHER_IFACE_ERROR = 6; // 0x6
field public static final int TETHER_ERROR_UNAVAIL_IFACE = 4; // 0x4
field public static final int TETHER_ERROR_UNKNOWN_IFACE = 1; // 0x1
+ field public static final int TETHER_ERROR_UNKNOWN_TYPE = 16; // 0x10
field public static final int TETHER_ERROR_UNSUPPORTED = 3; // 0x3
field public static final int TETHER_ERROR_UNTETHER_IFACE_ERROR = 7; // 0x7
field public static final int TETHER_HARDWARE_OFFLOAD_FAILED = 2; // 0x2
@@ -96,29 +97,26 @@
method public void onTetheringEntitlementResult(int);
}
- public abstract static class TetheringManager.StartTetheringCallback {
- ctor public TetheringManager.StartTetheringCallback();
- method public void onTetheringFailed(int);
- method public void onTetheringStarted();
+ public static interface TetheringManager.StartTetheringCallback {
+ method public default void onTetheringFailed(int);
+ method public default void onTetheringStarted();
}
- public abstract static class TetheringManager.TetheringEventCallback {
- ctor public TetheringManager.TetheringEventCallback();
- method public void onClientsChanged(@NonNull java.util.Collection<android.net.TetheredClient>);
- method public void onError(@NonNull String, int);
- method public void onOffloadStatusChanged(int);
- method @Deprecated public void onTetherableInterfaceRegexpsChanged(@NonNull android.net.TetheringManager.TetheringInterfaceRegexps);
- method public void onTetherableInterfacesChanged(@NonNull java.util.List<java.lang.String>);
- method public void onTetheredInterfacesChanged(@NonNull java.util.List<java.lang.String>);
- method public void onTetheringSupported(boolean);
- method public void onUpstreamChanged(@Nullable android.net.Network);
+ public static interface TetheringManager.TetheringEventCallback {
+ method public default void onClientsChanged(@NonNull java.util.Collection<android.net.TetheredClient>);
+ method public default void onError(@NonNull String, int);
+ method public default void onOffloadStatusChanged(int);
+ method public default void onTetherableInterfaceRegexpsChanged(@NonNull android.net.TetheringManager.TetheringInterfaceRegexps);
+ method public default void onTetherableInterfacesChanged(@NonNull java.util.List<java.lang.String>);
+ method public default void onTetheredInterfacesChanged(@NonNull java.util.List<java.lang.String>);
+ method public default void onTetheringSupported(boolean);
+ method public default void onUpstreamChanged(@Nullable android.net.Network);
}
- @Deprecated public static class TetheringManager.TetheringInterfaceRegexps {
- ctor @Deprecated public TetheringManager.TetheringInterfaceRegexps(@NonNull String[], @NonNull String[], @NonNull String[]);
- method @Deprecated @NonNull public java.util.List<java.lang.String> getTetherableBluetoothRegexs();
- method @Deprecated @NonNull public java.util.List<java.lang.String> getTetherableUsbRegexs();
- method @Deprecated @NonNull public java.util.List<java.lang.String> getTetherableWifiRegexs();
+ public static class TetheringManager.TetheringInterfaceRegexps {
+ method @NonNull public java.util.List<java.lang.String> getTetherableBluetoothRegexs();
+ method @NonNull public java.util.List<java.lang.String> getTetherableUsbRegexs();
+ method @NonNull public java.util.List<java.lang.String> getTetherableWifiRegexs();
}
public static class TetheringManager.TetheringRequest {
@@ -129,8 +127,11 @@
method @NonNull public android.net.TetheringManager.TetheringRequest build();
method @Nullable public android.net.LinkAddress getClientStaticIpv4Address();
method @Nullable public android.net.LinkAddress getLocalIpv4Address();
+ method public boolean getShouldShowEntitlementUi();
+ method public int getTetheringType();
+ method public boolean isExemptFromEntitlementCheck();
method @NonNull @RequiresPermission("android.permission.TETHER_PRIVILEGED") public android.net.TetheringManager.TetheringRequest.Builder setExemptFromEntitlementCheck(boolean);
- method @NonNull @RequiresPermission("android.permission.TETHER_PRIVILEGED") public android.net.TetheringManager.TetheringRequest.Builder setSilentProvisioning(boolean);
+ method @NonNull @RequiresPermission("android.permission.TETHER_PRIVILEGED") public android.net.TetheringManager.TetheringRequest.Builder setShouldShowEntitlementUi(boolean);
method @NonNull @RequiresPermission("android.permission.TETHER_PRIVILEGED") public android.net.TetheringManager.TetheringRequest.Builder setStaticIpv4Addresses(@NonNull android.net.LinkAddress, @NonNull android.net.LinkAddress);
}
diff --git a/api/system-current.txt b/api/system-current.txt
index b535a61..da8d3ec 100755
--- a/api/system-current.txt
+++ b/api/system-current.txt
@@ -6542,19 +6542,20 @@
field public static final int TETHERING_WIFI = 0; // 0x0
field public static final int TETHERING_WIFI_P2P = 3; // 0x3
field public static final int TETHER_ERROR_DHCPSERVER_ERROR = 12; // 0xc
- field public static final int TETHER_ERROR_DISABLE_NAT_ERROR = 9; // 0x9
- field public static final int TETHER_ERROR_ENABLE_NAT_ERROR = 8; // 0x8
+ field public static final int TETHER_ERROR_DISABLE_FORWARDING_ERROR = 9; // 0x9
+ field public static final int TETHER_ERROR_ENABLE_FORWARDING_ERROR = 8; // 0x8
field public static final int TETHER_ERROR_ENTITLEMENT_UNKNOWN = 13; // 0xd
field public static final int TETHER_ERROR_IFACE_CFG_ERROR = 10; // 0xa
- field public static final int TETHER_ERROR_MASTER_ERROR = 5; // 0x5
+ field public static final int TETHER_ERROR_INTERNAL_ERROR = 5; // 0x5
field public static final int TETHER_ERROR_NO_ACCESS_TETHERING_PERMISSION = 15; // 0xf
field public static final int TETHER_ERROR_NO_CHANGE_TETHERING_PERMISSION = 14; // 0xe
field public static final int TETHER_ERROR_NO_ERROR = 0; // 0x0
- field public static final int TETHER_ERROR_PROVISION_FAILED = 11; // 0xb
+ field public static final int TETHER_ERROR_PROVISIONING_FAILED = 11; // 0xb
field public static final int TETHER_ERROR_SERVICE_UNAVAIL = 2; // 0x2
field public static final int TETHER_ERROR_TETHER_IFACE_ERROR = 6; // 0x6
field public static final int TETHER_ERROR_UNAVAIL_IFACE = 4; // 0x4
field public static final int TETHER_ERROR_UNKNOWN_IFACE = 1; // 0x1
+ field public static final int TETHER_ERROR_UNKNOWN_TYPE = 16; // 0x10
field public static final int TETHER_ERROR_UNSUPPORTED = 3; // 0x3
field public static final int TETHER_ERROR_UNTETHER_IFACE_ERROR = 7; // 0x7
field public static final int TETHER_HARDWARE_OFFLOAD_FAILED = 2; // 0x2
@@ -6566,29 +6567,19 @@
method public void onTetheringEntitlementResult(int);
}
- public abstract static class TetheringManager.StartTetheringCallback {
- ctor public TetheringManager.StartTetheringCallback();
- method public void onTetheringFailed(int);
- method public void onTetheringStarted();
+ public static interface TetheringManager.StartTetheringCallback {
+ method public default void onTetheringFailed(int);
+ method public default void onTetheringStarted();
}
- public abstract static class TetheringManager.TetheringEventCallback {
- ctor public TetheringManager.TetheringEventCallback();
- method public void onClientsChanged(@NonNull java.util.Collection<android.net.TetheredClient>);
- method public void onError(@NonNull String, int);
- method public void onOffloadStatusChanged(int);
- method @Deprecated public void onTetherableInterfaceRegexpsChanged(@NonNull android.net.TetheringManager.TetheringInterfaceRegexps);
- method public void onTetherableInterfacesChanged(@NonNull java.util.List<java.lang.String>);
- method public void onTetheredInterfacesChanged(@NonNull java.util.List<java.lang.String>);
- method public void onTetheringSupported(boolean);
- method public void onUpstreamChanged(@Nullable android.net.Network);
- }
-
- @Deprecated public static class TetheringManager.TetheringInterfaceRegexps {
- ctor @Deprecated public TetheringManager.TetheringInterfaceRegexps(@NonNull String[], @NonNull String[], @NonNull String[]);
- method @Deprecated @NonNull public java.util.List<java.lang.String> getTetherableBluetoothRegexs();
- method @Deprecated @NonNull public java.util.List<java.lang.String> getTetherableUsbRegexs();
- method @Deprecated @NonNull public java.util.List<java.lang.String> getTetherableWifiRegexs();
+ public static interface TetheringManager.TetheringEventCallback {
+ method public default void onClientsChanged(@NonNull java.util.Collection<android.net.TetheredClient>);
+ method public default void onError(@NonNull String, int);
+ method public default void onOffloadStatusChanged(int);
+ method public default void onTetherableInterfacesChanged(@NonNull java.util.List<java.lang.String>);
+ method public default void onTetheredInterfacesChanged(@NonNull java.util.List<java.lang.String>);
+ method public default void onTetheringSupported(boolean);
+ method public default void onUpstreamChanged(@Nullable android.net.Network);
}
public static class TetheringManager.TetheringRequest {
@@ -6599,8 +6590,11 @@
method @NonNull public android.net.TetheringManager.TetheringRequest build();
method @Nullable public android.net.LinkAddress getClientStaticIpv4Address();
method @Nullable public android.net.LinkAddress getLocalIpv4Address();
+ method public boolean getShouldShowEntitlementUi();
+ method public int getTetheringType();
+ method public boolean isExemptFromEntitlementCheck();
method @NonNull @RequiresPermission(android.Manifest.permission.TETHER_PRIVILEGED) public android.net.TetheringManager.TetheringRequest.Builder setExemptFromEntitlementCheck(boolean);
- method @NonNull @RequiresPermission(android.Manifest.permission.TETHER_PRIVILEGED) public android.net.TetheringManager.TetheringRequest.Builder setSilentProvisioning(boolean);
+ method @NonNull @RequiresPermission(android.Manifest.permission.TETHER_PRIVILEGED) public android.net.TetheringManager.TetheringRequest.Builder setShouldShowEntitlementUi(boolean);
method @NonNull @RequiresPermission(android.Manifest.permission.TETHER_PRIVILEGED) public android.net.TetheringManager.TetheringRequest.Builder setStaticIpv4Addresses(@NonNull android.net.LinkAddress, @NonNull android.net.LinkAddress);
}
diff --git a/api/test-current.txt b/api/test-current.txt
index d107b17..632afdf6 100644
--- a/api/test-current.txt
+++ b/api/test-current.txt
@@ -1921,19 +1921,20 @@
field public static final int TETHERING_WIFI = 0; // 0x0
field public static final int TETHERING_WIFI_P2P = 3; // 0x3
field public static final int TETHER_ERROR_DHCPSERVER_ERROR = 12; // 0xc
- field public static final int TETHER_ERROR_DISABLE_NAT_ERROR = 9; // 0x9
- field public static final int TETHER_ERROR_ENABLE_NAT_ERROR = 8; // 0x8
+ field public static final int TETHER_ERROR_DISABLE_FORWARDING_ERROR = 9; // 0x9
+ field public static final int TETHER_ERROR_ENABLE_FORWARDING_ERROR = 8; // 0x8
field public static final int TETHER_ERROR_ENTITLEMENT_UNKNOWN = 13; // 0xd
field public static final int TETHER_ERROR_IFACE_CFG_ERROR = 10; // 0xa
- field public static final int TETHER_ERROR_MASTER_ERROR = 5; // 0x5
+ field public static final int TETHER_ERROR_INTERNAL_ERROR = 5; // 0x5
field public static final int TETHER_ERROR_NO_ACCESS_TETHERING_PERMISSION = 15; // 0xf
field public static final int TETHER_ERROR_NO_CHANGE_TETHERING_PERMISSION = 14; // 0xe
field public static final int TETHER_ERROR_NO_ERROR = 0; // 0x0
- field public static final int TETHER_ERROR_PROVISION_FAILED = 11; // 0xb
+ field public static final int TETHER_ERROR_PROVISIONING_FAILED = 11; // 0xb
field public static final int TETHER_ERROR_SERVICE_UNAVAIL = 2; // 0x2
field public static final int TETHER_ERROR_TETHER_IFACE_ERROR = 6; // 0x6
field public static final int TETHER_ERROR_UNAVAIL_IFACE = 4; // 0x4
field public static final int TETHER_ERROR_UNKNOWN_IFACE = 1; // 0x1
+ field public static final int TETHER_ERROR_UNKNOWN_TYPE = 16; // 0x10
field public static final int TETHER_ERROR_UNSUPPORTED = 3; // 0x3
field public static final int TETHER_ERROR_UNTETHER_IFACE_ERROR = 7; // 0x7
field public static final int TETHER_HARDWARE_OFFLOAD_FAILED = 2; // 0x2
@@ -1945,29 +1946,19 @@
method public void onTetheringEntitlementResult(int);
}
- public abstract static class TetheringManager.StartTetheringCallback {
- ctor public TetheringManager.StartTetheringCallback();
- method public void onTetheringFailed(int);
- method public void onTetheringStarted();
+ public static interface TetheringManager.StartTetheringCallback {
+ method public default void onTetheringFailed(int);
+ method public default void onTetheringStarted();
}
- public abstract static class TetheringManager.TetheringEventCallback {
- ctor public TetheringManager.TetheringEventCallback();
- method public void onClientsChanged(@NonNull java.util.Collection<android.net.TetheredClient>);
- method public void onError(@NonNull String, int);
- method public void onOffloadStatusChanged(int);
- method @Deprecated public void onTetherableInterfaceRegexpsChanged(@NonNull android.net.TetheringManager.TetheringInterfaceRegexps);
- method public void onTetherableInterfacesChanged(@NonNull java.util.List<java.lang.String>);
- method public void onTetheredInterfacesChanged(@NonNull java.util.List<java.lang.String>);
- method public void onTetheringSupported(boolean);
- method public void onUpstreamChanged(@Nullable android.net.Network);
- }
-
- @Deprecated public static class TetheringManager.TetheringInterfaceRegexps {
- ctor @Deprecated public TetheringManager.TetheringInterfaceRegexps(@NonNull String[], @NonNull String[], @NonNull String[]);
- method @Deprecated @NonNull public java.util.List<java.lang.String> getTetherableBluetoothRegexs();
- method @Deprecated @NonNull public java.util.List<java.lang.String> getTetherableUsbRegexs();
- method @Deprecated @NonNull public java.util.List<java.lang.String> getTetherableWifiRegexs();
+ public static interface TetheringManager.TetheringEventCallback {
+ method public default void onClientsChanged(@NonNull java.util.Collection<android.net.TetheredClient>);
+ method public default void onError(@NonNull String, int);
+ method public default void onOffloadStatusChanged(int);
+ method public default void onTetherableInterfacesChanged(@NonNull java.util.List<java.lang.String>);
+ method public default void onTetheredInterfacesChanged(@NonNull java.util.List<java.lang.String>);
+ method public default void onTetheringSupported(boolean);
+ method public default void onUpstreamChanged(@Nullable android.net.Network);
}
public static class TetheringManager.TetheringRequest {
@@ -1978,8 +1969,11 @@
method @NonNull public android.net.TetheringManager.TetheringRequest build();
method @Nullable public android.net.LinkAddress getClientStaticIpv4Address();
method @Nullable public android.net.LinkAddress getLocalIpv4Address();
+ method public boolean getShouldShowEntitlementUi();
+ method public int getTetheringType();
+ method public boolean isExemptFromEntitlementCheck();
method @NonNull @RequiresPermission("android.permission.TETHER_PRIVILEGED") public android.net.TetheringManager.TetheringRequest.Builder setExemptFromEntitlementCheck(boolean);
- method @NonNull @RequiresPermission("android.permission.TETHER_PRIVILEGED") public android.net.TetheringManager.TetheringRequest.Builder setSilentProvisioning(boolean);
+ method @NonNull @RequiresPermission("android.permission.TETHER_PRIVILEGED") public android.net.TetheringManager.TetheringRequest.Builder setShouldShowEntitlementUi(boolean);
method @NonNull @RequiresPermission("android.permission.TETHER_PRIVILEGED") public android.net.TetheringManager.TetheringRequest.Builder setStaticIpv4Addresses(@NonNull android.net.LinkAddress, @NonNull android.net.LinkAddress);
}
diff --git a/core/java/android/app/timezonedetector/ManualTimeZoneSuggestion.java b/core/java/android/app/timezonedetector/ManualTimeZoneSuggestion.java
index 3a9adc7..22e2efb 100644
--- a/core/java/android/app/timezonedetector/ManualTimeZoneSuggestion.java
+++ b/core/java/android/app/timezonedetector/ManualTimeZoneSuggestion.java
@@ -20,7 +20,9 @@
import android.annotation.Nullable;
import android.os.Parcel;
import android.os.Parcelable;
+import android.os.ShellCommand;
+import java.io.PrintWriter;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.Collections;
@@ -127,4 +129,32 @@
+ ", mDebugInfo=" + mDebugInfo
+ '}';
}
+
+ /** @hide */
+ public static ManualTimeZoneSuggestion parseCommandLineArg(@NonNull ShellCommand cmd) {
+ String zoneId = null;
+ String opt;
+ while ((opt = cmd.getNextArg()) != null) {
+ switch (opt) {
+ case "--zone_id": {
+ zoneId = cmd.getNextArgRequired();
+ break;
+ }
+ default: {
+ throw new IllegalArgumentException("Unknown option: " + opt);
+ }
+ }
+ }
+ ManualTimeZoneSuggestion suggestion = new ManualTimeZoneSuggestion(zoneId);
+ suggestion.addDebugInfo("Command line injection");
+ return suggestion;
+ }
+
+ /** @hide */
+ public static void printCommandLineOpts(@NonNull PrintWriter pw) {
+ pw.println("Manual suggestion options:");
+ pw.println(" --zone_id <Olson ID>");
+ pw.println();
+ pw.println("See " + ManualTimeZoneSuggestion.class.getName() + " for more information");
+ }
}
diff --git a/core/java/android/app/timezonedetector/TelephonyTimeZoneSuggestion.java b/core/java/android/app/timezonedetector/TelephonyTimeZoneSuggestion.java
index 150c01d..430462b 100644
--- a/core/java/android/app/timezonedetector/TelephonyTimeZoneSuggestion.java
+++ b/core/java/android/app/timezonedetector/TelephonyTimeZoneSuggestion.java
@@ -21,7 +21,10 @@
import android.annotation.Nullable;
import android.os.Parcel;
import android.os.Parcelable;
+import android.os.ShellCommand;
+import android.text.TextUtils;
+import java.io.PrintWriter;
import java.lang.annotation.Retention;
import java.lang.annotation.RetentionPolicy;
import java.util.ArrayList;
@@ -392,4 +395,96 @@
return new TelephonyTimeZoneSuggestion(this);
}
}
+
+ /** @hide */
+ public static TelephonyTimeZoneSuggestion parseCommandLineArg(@NonNull ShellCommand cmd)
+ throws IllegalArgumentException {
+ Integer slotIndex = null;
+ String zoneId = null;
+ Integer quality = null;
+ Integer matchType = null;
+ String opt;
+ while ((opt = cmd.getNextArg()) != null) {
+ switch (opt) {
+ case "--slot_index": {
+ slotIndex = Integer.parseInt(cmd.getNextArgRequired());
+ break;
+ }
+ case "--zone_id": {
+ zoneId = cmd.getNextArgRequired();
+ break;
+ }
+ case "--quality": {
+ quality = parseQualityCommandLineArg(cmd.getNextArgRequired());
+ break;
+ }
+ case "--match_type": {
+ matchType = parseMatchTypeCommandLineArg(cmd.getNextArgRequired());
+ break;
+ }
+ default: {
+ throw new IllegalArgumentException("Unknown option: " + opt);
+ }
+ }
+ }
+
+ if (slotIndex == null) {
+ throw new IllegalArgumentException("No slotIndex specified.");
+ }
+
+ Builder builder = new Builder(slotIndex);
+ if (!(TextUtils.isEmpty(zoneId) || "_".equals(zoneId))) {
+ builder.setZoneId(zoneId);
+ }
+ if (quality != null) {
+ builder.setQuality(quality);
+ }
+ if (matchType != null) {
+ builder.setMatchType(matchType);
+ }
+ builder.addDebugInfo("Command line injection");
+ return builder.build();
+ }
+
+ private static int parseQualityCommandLineArg(@NonNull String arg) {
+ switch (arg) {
+ case "single":
+ return QUALITY_SINGLE_ZONE;
+ case "multiple_same":
+ return QUALITY_MULTIPLE_ZONES_WITH_SAME_OFFSET;
+ case "multiple_different":
+ return QUALITY_MULTIPLE_ZONES_WITH_DIFFERENT_OFFSETS;
+ default:
+ throw new IllegalArgumentException("Unrecognized quality: " + arg);
+ }
+ }
+
+ private static int parseMatchTypeCommandLineArg(@NonNull String arg) {
+ switch (arg) {
+ case "emulator":
+ return MATCH_TYPE_EMULATOR_ZONE_ID;
+ case "country_with_offset":
+ return MATCH_TYPE_NETWORK_COUNTRY_AND_OFFSET;
+ case "country":
+ return MATCH_TYPE_NETWORK_COUNTRY_ONLY;
+ case "test_network":
+ return MATCH_TYPE_TEST_NETWORK_OFFSET_ONLY;
+ default:
+ throw new IllegalArgumentException("Unrecognized match_type: " + arg);
+ }
+ }
+
+ /** @hide */
+ public static void printCommandLineOpts(@NonNull PrintWriter pw) {
+ pw.println("Telephony suggestion options:");
+ pw.println(" --slot_index <number>");
+ pw.println(" To withdraw a previous suggestion:");
+ pw.println(" [--zone_id \"_\"]");
+ pw.println(" To make a new suggestion:");
+ pw.println(" --zone_id <Olson ID>");
+ pw.println(" --quality <single|multiple_same|multiple_different>");
+ pw.println(" --match_type <emulator|country_with_offset|country|test_network>");
+ pw.println();
+ pw.println("See " + TelephonyTimeZoneSuggestion.class.getName() + " for more information");
+ }
}
diff --git a/core/java/android/net/ConnectivityManager.java b/core/java/android/net/ConnectivityManager.java
index b8f5890..2a323e5 100644
--- a/core/java/android/net/ConnectivityManager.java
+++ b/core/java/android/net/ConnectivityManager.java
@@ -2487,13 +2487,13 @@
}
@Override
- public void onTetheringFailed(final int resultCode) {
+ public void onTetheringFailed(final int error) {
callback.onTetheringFailed();
}
};
final TetheringRequest request = new TetheringRequest.Builder(type)
- .setSilentProvisioning(!showProvisioningUi).build();
+ .setShouldShowEntitlementUi(showProvisioningUi).build();
mTetheringManager.startTethering(request, executor, tetheringCallback);
}
@@ -2713,11 +2713,12 @@
public static final int TETHER_ERROR_UNAVAIL_IFACE =
TetheringManager.TETHER_ERROR_UNAVAIL_IFACE;
/**
- * @deprecated Use {@link TetheringManager#TETHER_ERROR_MASTER_ERROR}.
+ * @deprecated Use {@link TetheringManager#TETHER_ERROR_INTERNAL_ERROR}.
* {@hide}
*/
@Deprecated
- public static final int TETHER_ERROR_MASTER_ERROR = TetheringManager.TETHER_ERROR_MASTER_ERROR;
+ public static final int TETHER_ERROR_MASTER_ERROR =
+ TetheringManager.TETHER_ERROR_INTERNAL_ERROR;
/**
* @deprecated Use {@link TetheringManager#TETHER_ERROR_TETHER_IFACE_ERROR}.
* {@hide}
@@ -2733,19 +2734,19 @@
public static final int TETHER_ERROR_UNTETHER_IFACE_ERROR =
TetheringManager.TETHER_ERROR_UNTETHER_IFACE_ERROR;
/**
- * @deprecated Use {@link TetheringManager#TETHER_ERROR_ENABLE_NAT_ERROR}.
+ * @deprecated Use {@link TetheringManager#TETHER_ERROR_ENABLE_FORWARDING_ERROR}.
* {@hide}
*/
@Deprecated
public static final int TETHER_ERROR_ENABLE_NAT_ERROR =
- TetheringManager.TETHER_ERROR_ENABLE_NAT_ERROR;
+ TetheringManager.TETHER_ERROR_ENABLE_FORWARDING_ERROR;
/**
- * @deprecated Use {@link TetheringManager#TETHER_ERROR_DISABLE_NAT_ERROR}.
+ * @deprecated Use {@link TetheringManager#TETHER_ERROR_DISABLE_FORWARDING_ERROR}.
* {@hide}
*/
@Deprecated
public static final int TETHER_ERROR_DISABLE_NAT_ERROR =
- TetheringManager.TETHER_ERROR_DISABLE_NAT_ERROR;
+ TetheringManager.TETHER_ERROR_DISABLE_FORWARDING_ERROR;
/**
* @deprecated Use {@link TetheringManager#TETHER_ERROR_IFACE_CFG_ERROR}.
* {@hide}
@@ -2754,13 +2755,13 @@
public static final int TETHER_ERROR_IFACE_CFG_ERROR =
TetheringManager.TETHER_ERROR_IFACE_CFG_ERROR;
/**
- * @deprecated Use {@link TetheringManager#TETHER_ERROR_PROVISION_FAILED}.
+ * @deprecated Use {@link TetheringManager#TETHER_ERROR_PROVISIONING_FAILED}.
* {@hide}
*/
@SystemApi
@Deprecated
public static final int TETHER_ERROR_PROVISION_FAILED =
- TetheringManager.TETHER_ERROR_PROVISION_FAILED;
+ TetheringManager.TETHER_ERROR_PROVISIONING_FAILED;
/**
* @deprecated Use {@link TetheringManager#TETHER_ERROR_DHCPSERVER_ERROR}.
* {@hide}
@@ -2792,7 +2793,14 @@
@UnsupportedAppUsage
@Deprecated
public int getLastTetherError(String iface) {
- return mTetheringManager.getLastTetherError(iface);
+ int error = mTetheringManager.getLastTetherError(iface);
+ if (error == TetheringManager.TETHER_ERROR_UNKNOWN_TYPE) {
+ // TETHER_ERROR_UNKNOWN_TYPE was introduced with TetheringManager and has never been
+ // returned by ConnectivityManager. Convert it to the legacy TETHER_ERROR_UNKNOWN_IFACE
+ // instead.
+ error = TetheringManager.TETHER_ERROR_UNKNOWN_IFACE;
+ }
+ return error;
}
/** @hide */
diff --git a/core/java/android/net/util/SocketUtils.java b/core/java/android/net/util/SocketUtils.java
index e9ea99f..6967084 100644
--- a/core/java/android/net/util/SocketUtils.java
+++ b/core/java/android/net/util/SocketUtils.java
@@ -66,6 +66,10 @@
/**
* Make socket address that packet sockets can bind to.
+ *
+ * @param protocol the layer 2 protocol of the packets to receive. One of the {@code ETH_P_*}
+ * constants in {@link android.system.OsConstants}.
+ * @param ifIndex the interface index on which packets will be received.
*/
@NonNull
public static SocketAddress makePacketSocketAddress(int protocol, int ifIndex) {
@@ -78,6 +82,9 @@
/**
* Make a socket address that packet socket can send packets to.
* @deprecated Use {@link #makePacketSocketAddress(int, int, byte[])} instead.
+ *
+ * @param ifIndex the interface index on which packets will be sent.
+ * @param hwAddr the hardware address to which packets will be sent.
*/
@Deprecated
@NonNull
@@ -89,7 +96,12 @@
}
/**
- * Make a socket address that packet socket can send packets to.
+ * Make a socket address that a packet socket can send packets to.
+ *
+ * @param protocol the layer 2 protocol of the packets to send. One of the {@code ETH_P_*}
+ * constants in {@link android.system.OsConstants}.
+ * @param ifIndex the interface index on which packets will be sent.
+ * @param hwAddr the hardware address to which packets will be sent.
*/
@NonNull
public static SocketAddress makePacketSocketAddress(int protocol, int ifIndex,
diff --git a/core/java/com/android/internal/app/ChooserActivity.java b/core/java/com/android/internal/app/ChooserActivity.java
index 78a0ae0..a1a434d 100644
--- a/core/java/com/android/internal/app/ChooserActivity.java
+++ b/core/java/com/android/internal/app/ChooserActivity.java
@@ -2418,13 +2418,20 @@
if (isLayoutUpdated
|| mLastNumberOfChildren != recyclerView.getChildCount()) {
mCurrAvailableWidth = availableWidth;
- if (isLayoutUpdated
- && mChooserMultiProfilePagerAdapter.getCurrentUserHandle() != getUser()) {
- // This fixes b/150936654 - empty work tab in share sheet when swiping
- mChooserMultiProfilePagerAdapter.getActiveAdapterView()
- .setAdapter(mChooserMultiProfilePagerAdapter.getCurrentRootAdapter());
+ if (isLayoutUpdated) {
+ // It is very important we call setAdapter from here. Otherwise in some cases
+ // the resolver list doesn't get populated, such as b/150922090, b/150918223
+ // and b/150936654
+ recyclerView.setAdapter(gridAdapter);
+ ((GridLayoutManager) recyclerView.getLayoutManager()).setSpanCount(
+ gridAdapter.getMaxTargetsPerRow());
+ }
+
+ if (mChooserMultiProfilePagerAdapter.getCurrentUserHandle() != getUser()) {
return;
- } else if (mChooserMultiProfilePagerAdapter.getCurrentUserHandle() != getUser()) {
+ }
+
+ if (mLastNumberOfChildren == recyclerView.getChildCount()) {
return;
}
diff --git a/core/tests/coretests/src/android/app/timezonedetector/ManualTimeZoneSuggestionTest.java b/core/tests/coretests/src/android/app/timezonedetector/ManualTimeZoneSuggestionTest.java
index 02ed0ed..17838bb 100644
--- a/core/tests/coretests/src/android/app/timezonedetector/ManualTimeZoneSuggestionTest.java
+++ b/core/tests/coretests/src/android/app/timezonedetector/ManualTimeZoneSuggestionTest.java
@@ -18,12 +18,19 @@
import static android.app.timezonedetector.ParcelableTestSupport.assertRoundTripParcelable;
import static android.app.timezonedetector.ParcelableTestSupport.roundTripParcelable;
+import static android.app.timezonedetector.ShellCommandTestSupport.createShellCommandWithArgsAndOptions;
import static org.junit.Assert.assertEquals;
import static org.junit.Assert.assertNotEquals;
+import static org.junit.Assert.assertTrue;
+
+import android.os.ShellCommand;
import org.junit.Test;
+import java.io.PrintWriter;
+import java.io.StringWriter;
+
public class ManualTimeZoneSuggestionTest {
private static final String ARBITRARY_ZONE_ID1 = "Europe/London";
@@ -58,4 +65,36 @@
ManualTimeZoneSuggestion rtSuggestion = roundTripParcelable(suggestion);
assertEquals(suggestion.getDebugInfo(), rtSuggestion.getDebugInfo());
}
+
+ @Test
+ public void testPrintCommandLineOpts() throws Exception {
+ try (StringWriter sw = new StringWriter(); PrintWriter pw = new PrintWriter(sw)) {
+ ManualTimeZoneSuggestion.printCommandLineOpts(pw);
+ assertTrue(sw.getBuffer().length() > 0);
+ }
+ }
+
+ @Test(expected = IllegalArgumentException.class)
+ public void testParseCommandLineArg_noArgs() {
+ ShellCommand testShellCommand = createShellCommandWithArgsAndOptions("");
+ ManualTimeZoneSuggestion.parseCommandLineArg(testShellCommand);
+ }
+
+ @Test
+ public void testParseCommandLineArg_validSuggestion() {
+ ShellCommand testShellCommand =
+ createShellCommandWithArgsAndOptions("--zone_id Europe/London");
+ ManualTimeZoneSuggestion expectedSuggestion =
+ new ManualTimeZoneSuggestion("Europe/London");
+ ManualTimeZoneSuggestion actualSuggestion =
+ ManualTimeZoneSuggestion.parseCommandLineArg(testShellCommand);
+ assertEquals(expectedSuggestion, actualSuggestion);
+ }
+
+ @Test(expected = IllegalArgumentException.class)
+ public void testParseCommandLineArg_unknownArgument() {
+ ShellCommand testShellCommand = createShellCommandWithArgsAndOptions(
+ "--zone_id Europe/London --bad_arg 0");
+ ManualTimeZoneSuggestion.parseCommandLineArg(testShellCommand);
+ }
}
diff --git a/core/tests/coretests/src/android/app/timezonedetector/ShellCommandTestSupport.java b/core/tests/coretests/src/android/app/timezonedetector/ShellCommandTestSupport.java
new file mode 100644
index 0000000..8d8290c
--- /dev/null
+++ b/core/tests/coretests/src/android/app/timezonedetector/ShellCommandTestSupport.java
@@ -0,0 +1,65 @@
+/*
+ * Copyright 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.app.timezonedetector;
+
+import static org.mockito.Mockito.mock;
+import static org.mockito.Mockito.when;
+
+import android.os.ShellCommand;
+
+import org.mockito.stubbing.Answer;
+
+import java.util.Arrays;
+import java.util.List;
+
+/** Utility methods related to {@link ShellCommand} objects used in several tests. */
+final class ShellCommandTestSupport {
+ private ShellCommandTestSupport() {}
+
+ static ShellCommand createShellCommandWithArgsAndOptions(String argsWithSpaces) {
+ return createShellCommandWithArgsAndOptions(Arrays.asList(argsWithSpaces.split(" ")));
+ }
+
+ static ShellCommand createShellCommandWithArgsAndOptions(List<String> args) {
+ ShellCommand command = mock(ShellCommand.class);
+ class ArgProvider {
+ private int mCount;
+
+ String getNext() {
+ if (mCount >= args.size()) {
+ return null;
+ }
+ return args.get(mCount++);
+ }
+
+ String getNextRequired() {
+ String next = getNext();
+ if (next == null) {
+ throw new IllegalArgumentException("No next");
+ }
+ return next;
+ }
+ }
+ ArgProvider argProvider = new ArgProvider();
+ when(command.getNextArg()).thenAnswer(
+ (Answer<String>) invocation -> argProvider.getNext());
+ when(command.getNextOption()).thenAnswer(
+ (Answer<String>) invocation -> argProvider.getNext());
+ when(command.getNextArgRequired()).thenAnswer(
+ (Answer<String>) invocation -> argProvider.getNextRequired());
+ return command;
+ }
+}
diff --git a/core/tests/coretests/src/android/app/timezonedetector/TelephonyTimeZoneSuggestionTest.java b/core/tests/coretests/src/android/app/timezonedetector/TelephonyTimeZoneSuggestionTest.java
index 59d55b7..c4ff9be 100644
--- a/core/tests/coretests/src/android/app/timezonedetector/TelephonyTimeZoneSuggestionTest.java
+++ b/core/tests/coretests/src/android/app/timezonedetector/TelephonyTimeZoneSuggestionTest.java
@@ -18,13 +18,19 @@
import static android.app.timezonedetector.ParcelableTestSupport.assertRoundTripParcelable;
import static android.app.timezonedetector.ParcelableTestSupport.roundTripParcelable;
+import static android.app.timezonedetector.ShellCommandTestSupport.createShellCommandWithArgsAndOptions;
import static org.junit.Assert.assertEquals;
import static org.junit.Assert.assertNotEquals;
import static org.junit.Assert.assertTrue;
+import android.os.ShellCommand;
+
import org.junit.Test;
+import java.io.PrintWriter;
+import java.io.StringWriter;
+
public class TelephonyTimeZoneSuggestionTest {
private static final int SLOT_INDEX = 99999;
@@ -159,4 +165,57 @@
assertEquals(suggestion1, suggestion1_2);
assertTrue(suggestion1_2.getDebugInfo().contains(debugString));
}
+
+ @Test
+ public void testPrintCommandLineOpts() throws Exception {
+ try (StringWriter sw = new StringWriter(); PrintWriter pw = new PrintWriter(sw)) {
+ TelephonyTimeZoneSuggestion.printCommandLineOpts(pw);
+ assertTrue(sw.getBuffer().length() > 0);
+ }
+ }
+
+ @Test(expected = IllegalArgumentException.class)
+ public void testParseCommandLineArg_noArgs() {
+ ShellCommand testShellCommand = createShellCommandWithArgsAndOptions("");
+ TelephonyTimeZoneSuggestion.parseCommandLineArg(testShellCommand);
+ }
+
+ @Test(expected = IllegalArgumentException.class)
+ public void testParseCommandLineArg_noSlotIndex() {
+ ShellCommand testShellCommand = createShellCommandWithArgsAndOptions("--zone_id _");
+ TelephonyTimeZoneSuggestion.parseCommandLineArg(testShellCommand);
+ }
+
+ @Test
+ public void testParseCommandLineArg_validEmptyZoneIdSuggestion() {
+ ShellCommand testShellCommand = createShellCommandWithArgsAndOptions(
+ "--slot_index 0 --zone_id _");
+ TelephonyTimeZoneSuggestion expectedSuggestion =
+ new TelephonyTimeZoneSuggestion.Builder(0).build();
+ TelephonyTimeZoneSuggestion actualSuggestion =
+ TelephonyTimeZoneSuggestion.parseCommandLineArg(testShellCommand);
+ assertEquals(expectedSuggestion, actualSuggestion);
+ }
+
+ @Test
+ public void testParseCommandLineArg_validNonEmptySuggestion() {
+ ShellCommand testShellCommand = createShellCommandWithArgsAndOptions(
+ "--slot_index 0 --zone_id Europe/London --quality single --match_type country");
+ TelephonyTimeZoneSuggestion expectedSuggestion =
+ new TelephonyTimeZoneSuggestion.Builder(0)
+ .setZoneId("Europe/London")
+ .setQuality(TelephonyTimeZoneSuggestion.QUALITY_SINGLE_ZONE)
+ .setMatchType(TelephonyTimeZoneSuggestion.MATCH_TYPE_NETWORK_COUNTRY_ONLY)
+ .build();
+ TelephonyTimeZoneSuggestion actualSuggestion =
+ TelephonyTimeZoneSuggestion.parseCommandLineArg(testShellCommand);
+ assertEquals(expectedSuggestion, actualSuggestion);
+ }
+
+ @Test(expected = IllegalArgumentException.class)
+ public void testParseCommandLineArg_unknownArgument() {
+ ShellCommand testShellCommand = createShellCommandWithArgsAndOptions(
+ "--slot_index 0 --zone_id _ --bad_arg 0");
+ TelephonyTimeZoneSuggestion.parseCommandLineArg(testShellCommand);
+ }
}
diff --git a/core/tests/coretests/src/android/view/InsetsAnimationControlImplTest.java b/core/tests/coretests/src/android/view/InsetsAnimationControlImplTest.java
index 22b4e45..c87433f 100644
--- a/core/tests/coretests/src/android/view/InsetsAnimationControlImplTest.java
+++ b/core/tests/coretests/src/android/view/InsetsAnimationControlImplTest.java
@@ -16,13 +16,14 @@
package android.view;
-import static android.view.InsetsController.LAYOUT_INSETS_DURING_ANIMATION_SHOWN;
import static android.view.InsetsState.ITYPE_NAVIGATION_BAR;
import static android.view.InsetsState.ITYPE_STATUS_BAR;
import static android.view.ViewRootImpl.NEW_INSETS_MODE_FULL;
import static android.view.WindowInsets.Type.systemBars;
import static org.junit.Assert.assertEquals;
+import static org.junit.Assert.assertFalse;
+import static org.junit.Assert.assertTrue;
import static org.junit.Assert.fail;
import static org.mockito.ArgumentMatchers.anyBoolean;
import static org.mockito.ArgumentMatchers.anyInt;
@@ -135,6 +136,13 @@
}
@Test
+ public void testReady() {
+ assertTrue(mController.isReady());
+ assertFalse(mController.isFinished());
+ assertFalse(mController.isCancelled());
+ }
+
+ @Test
public void testChangeInsets() {
mController.setInsetsAndAlpha(Insets.of(0, 30, 40, 0), 1f /* alpha */,
0f /* fraction */);
@@ -178,6 +186,10 @@
mController.applyChangeInsets(mInsetsState);
assertEquals(Insets.of(0, 100, 100, 0), mController.getCurrentInsets());
verify(mMockController).notifyFinished(eq(mController), eq(true /* shown */));
+ assertFalse(mController.isReady());
+ assertTrue(mController.isFinished());
+ assertFalse(mController.isCancelled());
+ verify(mMockListener).onFinished(mController);
}
@Test
@@ -188,6 +200,9 @@
fail("Expected exception to be thrown");
} catch (IllegalStateException ignored) {
}
+ assertFalse(mController.isReady());
+ assertFalse(mController.isFinished());
+ assertTrue(mController.isCancelled());
verify(mMockListener).onCancelled(mController);
mController.finish(true /* shown */);
}
diff --git a/core/tests/coretests/src/android/view/InsetsControllerTest.java b/core/tests/coretests/src/android/view/InsetsControllerTest.java
index 90a62e7..b449bb0 100644
--- a/core/tests/coretests/src/android/view/InsetsControllerTest.java
+++ b/core/tests/coretests/src/android/view/InsetsControllerTest.java
@@ -195,6 +195,9 @@
InstrumentationRegistry.getInstrumentation().runOnMainSync(() -> {
mController.onControlsChanged(createSingletonControl(ITYPE_STATUS_BAR));
+ ArgumentCaptor<WindowInsetsAnimationController> animationController =
+ ArgumentCaptor.forClass(WindowInsetsAnimationController.class);
+
WindowInsetsAnimationControlListener mockListener =
mock(WindowInsetsAnimationControlListener.class);
mController.controlWindowInsetsAnimation(statusBars(), 10 /* durationMs */,
@@ -202,9 +205,10 @@
// Ready gets deferred until next predraw
mViewRoot.getView().getViewTreeObserver().dispatchOnPreDraw();
- verify(mockListener).onReady(any(), anyInt());
+ verify(mockListener).onReady(animationController.capture(), anyInt());
mController.onControlsChanged(new InsetsSourceControl[0]);
verify(mockListener).onCancelled(notNull());
+ assertTrue(animationController.getValue().isCancelled());
});
}
diff --git a/packages/Tethering/common/TetheringLib/api/module-lib-current.txt b/packages/Tethering/common/TetheringLib/api/module-lib-current.txt
index 8a7e975..e823e17 100644
--- a/packages/Tethering/common/TetheringLib/api/module-lib-current.txt
+++ b/packages/Tethering/common/TetheringLib/api/module-lib-current.txt
@@ -62,19 +62,20 @@
field public static final int TETHERING_WIFI = 0; // 0x0
field public static final int TETHERING_WIFI_P2P = 3; // 0x3
field public static final int TETHER_ERROR_DHCPSERVER_ERROR = 12; // 0xc
- field public static final int TETHER_ERROR_DISABLE_NAT_ERROR = 9; // 0x9
- field public static final int TETHER_ERROR_ENABLE_NAT_ERROR = 8; // 0x8
+ field public static final int TETHER_ERROR_DISABLE_FORWARDING_ERROR = 9; // 0x9
+ field public static final int TETHER_ERROR_ENABLE_FORWARDING_ERROR = 8; // 0x8
field public static final int TETHER_ERROR_ENTITLEMENT_UNKNOWN = 13; // 0xd
field public static final int TETHER_ERROR_IFACE_CFG_ERROR = 10; // 0xa
- field public static final int TETHER_ERROR_MASTER_ERROR = 5; // 0x5
+ field public static final int TETHER_ERROR_INTERNAL_ERROR = 5; // 0x5
field public static final int TETHER_ERROR_NO_ACCESS_TETHERING_PERMISSION = 15; // 0xf
field public static final int TETHER_ERROR_NO_CHANGE_TETHERING_PERMISSION = 14; // 0xe
field public static final int TETHER_ERROR_NO_ERROR = 0; // 0x0
- field public static final int TETHER_ERROR_PROVISION_FAILED = 11; // 0xb
+ field public static final int TETHER_ERROR_PROVISIONING_FAILED = 11; // 0xb
field public static final int TETHER_ERROR_SERVICE_UNAVAIL = 2; // 0x2
field public static final int TETHER_ERROR_TETHER_IFACE_ERROR = 6; // 0x6
field public static final int TETHER_ERROR_UNAVAIL_IFACE = 4; // 0x4
field public static final int TETHER_ERROR_UNKNOWN_IFACE = 1; // 0x1
+ field public static final int TETHER_ERROR_UNKNOWN_TYPE = 16; // 0x10
field public static final int TETHER_ERROR_UNSUPPORTED = 3; // 0x3
field public static final int TETHER_ERROR_UNTETHER_IFACE_ERROR = 7; // 0x7
field public static final int TETHER_HARDWARE_OFFLOAD_FAILED = 2; // 0x2
@@ -86,29 +87,26 @@
method public void onTetheringEntitlementResult(int);
}
- public abstract static class TetheringManager.StartTetheringCallback {
- ctor public TetheringManager.StartTetheringCallback();
- method public void onTetheringFailed(int);
- method public void onTetheringStarted();
+ public static interface TetheringManager.StartTetheringCallback {
+ method public default void onTetheringFailed(int);
+ method public default void onTetheringStarted();
}
- public abstract static class TetheringManager.TetheringEventCallback {
- ctor public TetheringManager.TetheringEventCallback();
- method public void onClientsChanged(@NonNull java.util.Collection<android.net.TetheredClient>);
- method public void onError(@NonNull String, int);
- method public void onOffloadStatusChanged(int);
- method @Deprecated public void onTetherableInterfaceRegexpsChanged(@NonNull android.net.TetheringManager.TetheringInterfaceRegexps);
- method public void onTetherableInterfacesChanged(@NonNull java.util.List<java.lang.String>);
- method public void onTetheredInterfacesChanged(@NonNull java.util.List<java.lang.String>);
- method public void onTetheringSupported(boolean);
- method public void onUpstreamChanged(@Nullable android.net.Network);
+ public static interface TetheringManager.TetheringEventCallback {
+ method public default void onClientsChanged(@NonNull java.util.Collection<android.net.TetheredClient>);
+ method public default void onError(@NonNull String, int);
+ method public default void onOffloadStatusChanged(int);
+ method public default void onTetherableInterfaceRegexpsChanged(@NonNull android.net.TetheringManager.TetheringInterfaceRegexps);
+ method public default void onTetherableInterfacesChanged(@NonNull java.util.List<java.lang.String>);
+ method public default void onTetheredInterfacesChanged(@NonNull java.util.List<java.lang.String>);
+ method public default void onTetheringSupported(boolean);
+ method public default void onUpstreamChanged(@Nullable android.net.Network);
}
- @Deprecated public static class TetheringManager.TetheringInterfaceRegexps {
- ctor @Deprecated public TetheringManager.TetheringInterfaceRegexps(@NonNull String[], @NonNull String[], @NonNull String[]);
- method @Deprecated @NonNull public java.util.List<java.lang.String> getTetherableBluetoothRegexs();
- method @Deprecated @NonNull public java.util.List<java.lang.String> getTetherableUsbRegexs();
- method @Deprecated @NonNull public java.util.List<java.lang.String> getTetherableWifiRegexs();
+ public static class TetheringManager.TetheringInterfaceRegexps {
+ method @NonNull public java.util.List<java.lang.String> getTetherableBluetoothRegexs();
+ method @NonNull public java.util.List<java.lang.String> getTetherableUsbRegexs();
+ method @NonNull public java.util.List<java.lang.String> getTetherableWifiRegexs();
}
public static class TetheringManager.TetheringRequest {
@@ -119,8 +117,11 @@
method @NonNull public android.net.TetheringManager.TetheringRequest build();
method @Nullable public android.net.LinkAddress getClientStaticIpv4Address();
method @Nullable public android.net.LinkAddress getLocalIpv4Address();
+ method public boolean getShouldShowEntitlementUi();
+ method public int getTetheringType();
+ method public boolean isExemptFromEntitlementCheck();
method @NonNull @RequiresPermission(android.Manifest.permission.TETHER_PRIVILEGED) public android.net.TetheringManager.TetheringRequest.Builder setExemptFromEntitlementCheck(boolean);
- method @NonNull @RequiresPermission(android.Manifest.permission.TETHER_PRIVILEGED) public android.net.TetheringManager.TetheringRequest.Builder setSilentProvisioning(boolean);
+ method @NonNull @RequiresPermission(android.Manifest.permission.TETHER_PRIVILEGED) public android.net.TetheringManager.TetheringRequest.Builder setShouldShowEntitlementUi(boolean);
method @NonNull @RequiresPermission(android.Manifest.permission.TETHER_PRIVILEGED) public android.net.TetheringManager.TetheringRequest.Builder setStaticIpv4Addresses(@NonNull android.net.LinkAddress, @NonNull android.net.LinkAddress);
}
diff --git a/packages/Tethering/common/TetheringLib/api/system-current.txt b/packages/Tethering/common/TetheringLib/api/system-current.txt
index ac73953..3751135 100644
--- a/packages/Tethering/common/TetheringLib/api/system-current.txt
+++ b/packages/Tethering/common/TetheringLib/api/system-current.txt
@@ -40,19 +40,20 @@
field public static final int TETHERING_WIFI = 0; // 0x0
field public static final int TETHERING_WIFI_P2P = 3; // 0x3
field public static final int TETHER_ERROR_DHCPSERVER_ERROR = 12; // 0xc
- field public static final int TETHER_ERROR_DISABLE_NAT_ERROR = 9; // 0x9
- field public static final int TETHER_ERROR_ENABLE_NAT_ERROR = 8; // 0x8
+ field public static final int TETHER_ERROR_DISABLE_FORWARDING_ERROR = 9; // 0x9
+ field public static final int TETHER_ERROR_ENABLE_FORWARDING_ERROR = 8; // 0x8
field public static final int TETHER_ERROR_ENTITLEMENT_UNKNOWN = 13; // 0xd
field public static final int TETHER_ERROR_IFACE_CFG_ERROR = 10; // 0xa
- field public static final int TETHER_ERROR_MASTER_ERROR = 5; // 0x5
+ field public static final int TETHER_ERROR_INTERNAL_ERROR = 5; // 0x5
field public static final int TETHER_ERROR_NO_ACCESS_TETHERING_PERMISSION = 15; // 0xf
field public static final int TETHER_ERROR_NO_CHANGE_TETHERING_PERMISSION = 14; // 0xe
field public static final int TETHER_ERROR_NO_ERROR = 0; // 0x0
- field public static final int TETHER_ERROR_PROVISION_FAILED = 11; // 0xb
+ field public static final int TETHER_ERROR_PROVISIONING_FAILED = 11; // 0xb
field public static final int TETHER_ERROR_SERVICE_UNAVAIL = 2; // 0x2
field public static final int TETHER_ERROR_TETHER_IFACE_ERROR = 6; // 0x6
field public static final int TETHER_ERROR_UNAVAIL_IFACE = 4; // 0x4
field public static final int TETHER_ERROR_UNKNOWN_IFACE = 1; // 0x1
+ field public static final int TETHER_ERROR_UNKNOWN_TYPE = 16; // 0x10
field public static final int TETHER_ERROR_UNSUPPORTED = 3; // 0x3
field public static final int TETHER_ERROR_UNTETHER_IFACE_ERROR = 7; // 0x7
field public static final int TETHER_HARDWARE_OFFLOAD_FAILED = 2; // 0x2
@@ -64,29 +65,19 @@
method public void onTetheringEntitlementResult(int);
}
- public abstract static class TetheringManager.StartTetheringCallback {
- ctor public TetheringManager.StartTetheringCallback();
- method public void onTetheringFailed(int);
- method public void onTetheringStarted();
+ public static interface TetheringManager.StartTetheringCallback {
+ method public default void onTetheringFailed(int);
+ method public default void onTetheringStarted();
}
- public abstract static class TetheringManager.TetheringEventCallback {
- ctor public TetheringManager.TetheringEventCallback();
- method public void onClientsChanged(@NonNull java.util.Collection<android.net.TetheredClient>);
- method public void onError(@NonNull String, int);
- method public void onOffloadStatusChanged(int);
- method @Deprecated public void onTetherableInterfaceRegexpsChanged(@NonNull android.net.TetheringManager.TetheringInterfaceRegexps);
- method public void onTetherableInterfacesChanged(@NonNull java.util.List<java.lang.String>);
- method public void onTetheredInterfacesChanged(@NonNull java.util.List<java.lang.String>);
- method public void onTetheringSupported(boolean);
- method public void onUpstreamChanged(@Nullable android.net.Network);
- }
-
- @Deprecated public static class TetheringManager.TetheringInterfaceRegexps {
- ctor @Deprecated public TetheringManager.TetheringInterfaceRegexps(@NonNull String[], @NonNull String[], @NonNull String[]);
- method @Deprecated @NonNull public java.util.List<java.lang.String> getTetherableBluetoothRegexs();
- method @Deprecated @NonNull public java.util.List<java.lang.String> getTetherableUsbRegexs();
- method @Deprecated @NonNull public java.util.List<java.lang.String> getTetherableWifiRegexs();
+ public static interface TetheringManager.TetheringEventCallback {
+ method public default void onClientsChanged(@NonNull java.util.Collection<android.net.TetheredClient>);
+ method public default void onError(@NonNull String, int);
+ method public default void onOffloadStatusChanged(int);
+ method public default void onTetherableInterfacesChanged(@NonNull java.util.List<java.lang.String>);
+ method public default void onTetheredInterfacesChanged(@NonNull java.util.List<java.lang.String>);
+ method public default void onTetheringSupported(boolean);
+ method public default void onUpstreamChanged(@Nullable android.net.Network);
}
public static class TetheringManager.TetheringRequest {
@@ -97,8 +88,11 @@
method @NonNull public android.net.TetheringManager.TetheringRequest build();
method @Nullable public android.net.LinkAddress getClientStaticIpv4Address();
method @Nullable public android.net.LinkAddress getLocalIpv4Address();
+ method public boolean getShouldShowEntitlementUi();
+ method public int getTetheringType();
+ method public boolean isExemptFromEntitlementCheck();
method @NonNull @RequiresPermission(android.Manifest.permission.TETHER_PRIVILEGED) public android.net.TetheringManager.TetheringRequest.Builder setExemptFromEntitlementCheck(boolean);
- method @NonNull @RequiresPermission(android.Manifest.permission.TETHER_PRIVILEGED) public android.net.TetheringManager.TetheringRequest.Builder setSilentProvisioning(boolean);
+ method @NonNull @RequiresPermission(android.Manifest.permission.TETHER_PRIVILEGED) public android.net.TetheringManager.TetheringRequest.Builder setShouldShowEntitlementUi(boolean);
method @NonNull @RequiresPermission(android.Manifest.permission.TETHER_PRIVILEGED) public android.net.TetheringManager.TetheringRequest.Builder setStaticIpv4Addresses(@NonNull android.net.LinkAddress, @NonNull android.net.LinkAddress);
}
diff --git a/packages/Tethering/common/TetheringLib/src/android/net/TetheringManager.java b/packages/Tethering/common/TetheringLib/src/android/net/TetheringManager.java
index f2045df..86ef7f0 100644
--- a/packages/Tethering/common/TetheringLib/src/android/net/TetheringManager.java
+++ b/packages/Tethering/common/TetheringLib/src/android/net/TetheringManager.java
@@ -115,6 +115,19 @@
*/
public static final String EXTRA_ERRORED_TETHER = "erroredArray";
+ /** @hide */
+ @Retention(RetentionPolicy.SOURCE)
+ @IntDef(flag = false, value = {
+ TETHERING_WIFI,
+ TETHERING_USB,
+ TETHERING_BLUETOOTH,
+ TETHERING_WIFI_P2P,
+ TETHERING_NCM,
+ TETHERING_ETHERNET,
+ })
+ public @interface TetheringType {
+ }
+
/**
* Invalid tethering type.
* @see #startTethering.
@@ -158,22 +171,60 @@
*/
public static final int TETHERING_ETHERNET = 5;
- public static final int TETHER_ERROR_NO_ERROR = 0;
- public static final int TETHER_ERROR_UNKNOWN_IFACE = 1;
- public static final int TETHER_ERROR_SERVICE_UNAVAIL = 2;
- public static final int TETHER_ERROR_UNSUPPORTED = 3;
- public static final int TETHER_ERROR_UNAVAIL_IFACE = 4;
- public static final int TETHER_ERROR_MASTER_ERROR = 5;
+ /** @hide */
+ @Retention(RetentionPolicy.SOURCE)
+ @IntDef(value = {
+ TETHER_ERROR_NO_ERROR,
+ TETHER_ERROR_PROVISIONING_FAILED,
+ TETHER_ERROR_ENTITLEMENT_UNKNOWN,
+ })
+ public @interface EntitlementResult {
+ }
+
+ /** @hide */
+ @Retention(RetentionPolicy.SOURCE)
+ @IntDef(value = {
+ TETHER_ERROR_NO_ERROR,
+ TETHER_ERROR_UNKNOWN_IFACE,
+ TETHER_ERROR_SERVICE_UNAVAIL,
+ TETHER_ERROR_INTERNAL_ERROR,
+ TETHER_ERROR_TETHER_IFACE_ERROR,
+ TETHER_ERROR_ENABLE_FORWARDING_ERROR,
+ TETHER_ERROR_DISABLE_FORWARDING_ERROR,
+ TETHER_ERROR_IFACE_CFG_ERROR,
+ TETHER_ERROR_DHCPSERVER_ERROR,
+ })
+ public @interface TetheringIfaceError {
+ }
+
+ /** @hide */
+ @Retention(RetentionPolicy.SOURCE)
+ @IntDef(value = {
+ TETHER_ERROR_SERVICE_UNAVAIL,
+ TETHER_ERROR_INTERNAL_ERROR,
+ TETHER_ERROR_NO_CHANGE_TETHERING_PERMISSION,
+ TETHER_ERROR_UNKNOWN_TYPE,
+ })
+ public @interface StartTetheringError {
+ }
+
+ public static final int TETHER_ERROR_NO_ERROR = 0;
+ public static final int TETHER_ERROR_UNKNOWN_IFACE = 1;
+ public static final int TETHER_ERROR_SERVICE_UNAVAIL = 2;
+ public static final int TETHER_ERROR_UNSUPPORTED = 3;
+ public static final int TETHER_ERROR_UNAVAIL_IFACE = 4;
+ public static final int TETHER_ERROR_INTERNAL_ERROR = 5;
public static final int TETHER_ERROR_TETHER_IFACE_ERROR = 6;
public static final int TETHER_ERROR_UNTETHER_IFACE_ERROR = 7;
- public static final int TETHER_ERROR_ENABLE_NAT_ERROR = 8;
- public static final int TETHER_ERROR_DISABLE_NAT_ERROR = 9;
- public static final int TETHER_ERROR_IFACE_CFG_ERROR = 10;
- public static final int TETHER_ERROR_PROVISION_FAILED = 11;
- public static final int TETHER_ERROR_DHCPSERVER_ERROR = 12;
+ public static final int TETHER_ERROR_ENABLE_FORWARDING_ERROR = 8;
+ public static final int TETHER_ERROR_DISABLE_FORWARDING_ERROR = 9;
+ public static final int TETHER_ERROR_IFACE_CFG_ERROR = 10;
+ public static final int TETHER_ERROR_PROVISIONING_FAILED = 11;
+ public static final int TETHER_ERROR_DHCPSERVER_ERROR = 12;
public static final int TETHER_ERROR_ENTITLEMENT_UNKNOWN = 13;
public static final int TETHER_ERROR_NO_CHANGE_TETHERING_PERMISSION = 14;
public static final int TETHER_ERROR_NO_ACCESS_TETHERING_PERMISSION = 15;
+ public static final int TETHER_ERROR_UNKNOWN_TYPE = 16;
/** @hide */
@Retention(RetentionPolicy.SOURCE)
@@ -508,7 +559,7 @@
private final TetheringRequestParcel mBuilderParcel;
/** Default constructor of Builder. */
- public Builder(final int type) {
+ public Builder(@TetheringType final int type) {
mBuilderParcel = new TetheringRequestParcel();
mBuilderParcel.tetheringType = type;
mBuilderParcel.localIPv4Address = null;
@@ -553,11 +604,14 @@
return this;
}
- /** Start tethering without showing the provisioning UI. */
+ /**
+ * If an entitlement check is needed, sets whether to show the entitlement UI or to
+ * perform a silent entitlement check. By default, the entitlement UI is shown.
+ */
@RequiresPermission(android.Manifest.permission.TETHER_PRIVILEGED)
@NonNull
- public Builder setSilentProvisioning(boolean silent) {
- mBuilderParcel.showProvisioningUi = silent;
+ public Builder setShouldShowEntitlementUi(boolean showUi) {
+ mBuilderParcel.showProvisioningUi = showUi;
return this;
}
@@ -567,7 +621,6 @@
return new TetheringRequest(mBuilderParcel);
}
- /** Get static server address. */
@Nullable
public LinkAddress getLocalIpv4Address() {
return mBuilderParcel.localIPv4Address;
@@ -578,6 +631,22 @@
public LinkAddress getClientStaticIpv4Address() {
return mBuilderParcel.staticClientAddress;
}
+
+ /** Get tethering type. */
+ @TetheringType
+ public int getTetheringType() {
+ return mBuilderParcel.tetheringType;
+ }
+
+ /** Check if exempt from entitlement check. */
+ public boolean isExemptFromEntitlementCheck() {
+ return mBuilderParcel.exemptFromEntitlementCheck;
+ }
+
+ /** Check if show entitlement ui. */
+ public boolean getShouldShowEntitlementUi() {
+ return mBuilderParcel.showProvisioningUi;
+ }
}
/**
@@ -602,18 +671,18 @@
/**
* Callback for use with {@link #startTethering} to find out whether tethering succeeded.
*/
- public abstract static class StartTetheringCallback {
+ public interface StartTetheringCallback {
/**
* Called when tethering has been successfully started.
*/
- public void onTetheringStarted() {}
+ default void onTetheringStarted() {}
/**
* Called when starting tethering failed.
*
- * @param resultCode One of the {@code TETHER_ERROR_*} constants.
+ * @param error The error that caused the failure.
*/
- public void onTetheringFailed(final int resultCode) {}
+ default void onTetheringFailed(@StartTetheringError final int error) {}
}
/**
@@ -684,7 +753,7 @@
android.Manifest.permission.TETHER_PRIVILEGED,
android.Manifest.permission.WRITE_SETTINGS
})
- public void stopTethering(final int type) {
+ public void stopTethering(@TetheringType final int type) {
final String callerPkg = mContext.getOpPackageName();
Log.i(TAG, "stopTethering caller:" + callerPkg);
@@ -709,10 +778,10 @@
*
* @param resultCode an int value of entitlement result. It may be one of
* {@link #TETHER_ERROR_NO_ERROR},
- * {@link #TETHER_ERROR_PROVISION_FAILED}, or
+ * {@link #TETHER_ERROR_PROVISIONING_FAILED}, or
* {@link #TETHER_ERROR_ENTITLEMENT_UNKNOWN}.
*/
- void onTetheringEntitlementResult(int resultCode);
+ void onTetheringEntitlementResult(@EntitlementResult int result);
}
/**
@@ -727,7 +796,8 @@
* fail if a tethering entitlement check is required.
*
* @param type the downstream type of tethering. Must be one of {@code #TETHERING_*} constants.
- * @param showEntitlementUi a boolean indicating whether to run UI-based entitlement check.
+ * @param showEntitlementUi a boolean indicating whether to check result for the UI-based
+ * entitlement check or the silent entitlement check.
* @param executor the executor on which callback will be invoked.
* @param listener an {@link OnTetheringEntitlementResultListener} which will be called to
* notify the caller of the result of entitlement check. The listener may be called zero
@@ -737,7 +807,8 @@
android.Manifest.permission.TETHER_PRIVILEGED,
android.Manifest.permission.WRITE_SETTINGS
})
- public void requestLatestTetheringEntitlementResult(int type, boolean showEntitlementUi,
+ public void requestLatestTetheringEntitlementResult(@TetheringType int type,
+ boolean showEntitlementUi,
@NonNull Executor executor,
@NonNull final OnTetheringEntitlementResultListener listener) {
if (listener == null) {
@@ -766,7 +837,7 @@
*/
// TODO: improve the usage of ResultReceiver, b/145096122
@SystemApi(client = MODULE_LIBRARIES)
- public void requestLatestTetheringEntitlementResult(final int type,
+ public void requestLatestTetheringEntitlementResult(@TetheringType final int type,
@NonNull final ResultReceiver receiver, final boolean showEntitlementUi) {
final String callerPkg = mContext.getOpPackageName();
Log.i(TAG, "getLatestTetheringEntitlementResult caller:" + callerPkg);
@@ -779,7 +850,7 @@
* Callback for use with {@link registerTetheringEventCallback} to find out tethering
* upstream status.
*/
- public abstract static class TetheringEventCallback {
+ public interface TetheringEventCallback {
/**
* Called when tethering supported status changed.
*
@@ -791,7 +862,7 @@
*
* @param supported The new supported status
*/
- public void onTetheringSupported(boolean supported) {}
+ default void onTetheringSupported(boolean supported) {}
/**
* Called when tethering upstream changed.
@@ -802,7 +873,7 @@
* @param network the {@link Network} of tethering upstream. Null means tethering doesn't
* have any upstream.
*/
- public void onUpstreamChanged(@Nullable Network network) {}
+ default void onUpstreamChanged(@Nullable Network network) {}
/**
* Called when there was a change in tethering interface regular expressions.
@@ -810,28 +881,30 @@
* <p>This will be called immediately after the callback is registered, and may be called
* multiple times later upon changes.
* @param reg The new regular expressions.
- * @deprecated Referencing interfaces by regular expressions is a deprecated mechanism.
+ *
+ * @hide
*/
- @Deprecated
- public void onTetherableInterfaceRegexpsChanged(@NonNull TetheringInterfaceRegexps reg) {}
+ @SystemApi(client = MODULE_LIBRARIES)
+ default void onTetherableInterfaceRegexpsChanged(@NonNull TetheringInterfaceRegexps reg) {}
/**
- * Called when there was a change in the list of tetherable interfaces.
+ * Called when there was a change in the list of tetherable interfaces. Tetherable
+ * interface means this interface is available and can be used for tethering.
*
* <p>This will be called immediately after the callback is registered, and may be called
* multiple times later upon changes.
- * @param interfaces The list of tetherable interfaces.
+ * @param interfaces The list of tetherable interface names.
*/
- public void onTetherableInterfacesChanged(@NonNull List<String> interfaces) {}
+ default void onTetherableInterfacesChanged(@NonNull List<String> interfaces) {}
/**
* Called when there was a change in the list of tethered interfaces.
*
* <p>This will be called immediately after the callback is registered, and may be called
* multiple times later upon changes.
- * @param interfaces The list of tethered interfaces.
+ * @param interfaces The list of 0 or more String of currently tethered interface names.
*/
- public void onTetheredInterfacesChanged(@NonNull List<String> interfaces) {}
+ default void onTetheredInterfacesChanged(@NonNull List<String> interfaces) {}
/**
* Called when an error occurred configuring tethering.
@@ -841,7 +914,7 @@
* @param ifName Name of the interface.
* @param error One of {@code TetheringManager#TETHER_ERROR_*}.
*/
- public void onError(@NonNull String ifName, int error) {}
+ default void onError(@NonNull String ifName, @TetheringIfaceError int error) {}
/**
* Called when the list of tethered clients changes.
@@ -854,7 +927,7 @@
* determine if they are still connected.
* @param clients The new set of tethered clients; the collection is not ordered.
*/
- public void onClientsChanged(@NonNull Collection<TetheredClient> clients) {}
+ default void onClientsChanged(@NonNull Collection<TetheredClient> clients) {}
/**
* Called when tethering offload status changes.
@@ -862,19 +935,20 @@
* <p>This will be called immediately after the callback is registered.
* @param status The offload status.
*/
- public void onOffloadStatusChanged(@TetherOffloadStatus int status) {}
+ default void onOffloadStatusChanged(@TetherOffloadStatus int status) {}
}
/**
* Regular expressions used to identify tethering interfaces.
- * @deprecated Referencing interfaces by regular expressions is a deprecated mechanism.
+ * @hide
*/
- @Deprecated
+ @SystemApi(client = MODULE_LIBRARIES)
public static class TetheringInterfaceRegexps {
private final String[] mTetherableBluetoothRegexs;
private final String[] mTetherableUsbRegexs;
private final String[] mTetherableWifiRegexs;
+ /** @hide */
public TetheringInterfaceRegexps(@NonNull String[] tetherableBluetoothRegexs,
@NonNull String[] tetherableUsbRegexs, @NonNull String[] tetherableWifiRegexs) {
mTetherableBluetoothRegexs = tetherableBluetoothRegexs.clone();
diff --git a/packages/Tethering/src/android/net/ip/IpServer.java b/packages/Tethering/src/android/net/ip/IpServer.java
index 433b903..c5478d2 100644
--- a/packages/Tethering/src/android/net/ip/IpServer.java
+++ b/packages/Tethering/src/android/net/ip/IpServer.java
@@ -1054,7 +1054,7 @@
case CMD_START_TETHERING_ERROR:
case CMD_STOP_TETHERING_ERROR:
case CMD_SET_DNS_FORWARDERS_ERROR:
- mLastError = TetheringManager.TETHER_ERROR_MASTER_ERROR;
+ mLastError = TetheringManager.TETHER_ERROR_INTERNAL_ERROR;
transitionTo(mInitialState);
break;
default:
@@ -1185,7 +1185,7 @@
} catch (RemoteException | ServiceSpecificException e) {
mLog.e("Exception enabling NAT: " + e.toString());
cleanupUpstream();
- mLastError = TetheringManager.TETHER_ERROR_ENABLE_NAT_ERROR;
+ mLastError = TetheringManager.TETHER_ERROR_ENABLE_FORWARDING_ERROR;
transitionTo(mInitialState);
return true;
}
diff --git a/packages/Tethering/src/com/android/server/connectivity/tethering/EntitlementManager.java b/packages/Tethering/src/com/android/server/connectivity/tethering/EntitlementManager.java
index e81d6ac..bd60594f 100644
--- a/packages/Tethering/src/com/android/server/connectivity/tethering/EntitlementManager.java
+++ b/packages/Tethering/src/com/android/server/connectivity/tethering/EntitlementManager.java
@@ -25,7 +25,7 @@
import static android.net.TetheringManager.TETHERING_WIFI;
import static android.net.TetheringManager.TETHER_ERROR_ENTITLEMENT_UNKNOWN;
import static android.net.TetheringManager.TETHER_ERROR_NO_ERROR;
-import static android.net.TetheringManager.TETHER_ERROR_PROVISION_FAILED;
+import static android.net.TetheringManager.TETHER_ERROR_PROVISIONING_FAILED;
import android.app.AlarmManager;
import android.app.PendingIntent;
@@ -579,7 +579,7 @@
switch (value) {
case TETHER_ERROR_ENTITLEMENT_UNKNOWN: return "TETHER_ERROR_ENTITLEMENT_UNKONWN";
case TETHER_ERROR_NO_ERROR: return "TETHER_ERROR_NO_ERROR";
- case TETHER_ERROR_PROVISION_FAILED: return "TETHER_ERROR_PROVISION_FAILED";
+ case TETHER_ERROR_PROVISIONING_FAILED: return "TETHER_ERROR_PROVISIONING_FAILED";
default:
return String.format("UNKNOWN ERROR (%d)", value);
}
@@ -592,7 +592,7 @@
protected void onReceiveResult(int resultCode, Bundle resultData) {
int updatedCacheValue = updateEntitlementCacheValue(type, resultCode);
addDownstreamMapping(type, updatedCacheValue);
- if (updatedCacheValue == TETHER_ERROR_PROVISION_FAILED && notifyFail) {
+ if (updatedCacheValue == TETHER_ERROR_PROVISIONING_FAILED && notifyFail) {
mListener.onUiEntitlementFailed(type);
}
if (receiver != null) receiver.send(updatedCacheValue, null);
@@ -635,8 +635,8 @@
mEntitlementCacheValue.put(type, resultCode);
return resultCode;
} else {
- mEntitlementCacheValue.put(type, TETHER_ERROR_PROVISION_FAILED);
- return TETHER_ERROR_PROVISION_FAILED;
+ mEntitlementCacheValue.put(type, TETHER_ERROR_PROVISIONING_FAILED);
+ return TETHER_ERROR_PROVISIONING_FAILED;
}
}
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 6e91892..8e2d4f4 100644
--- a/packages/Tethering/src/com/android/server/connectivity/tethering/Tethering.java
+++ b/packages/Tethering/src/com/android/server/connectivity/tethering/Tethering.java
@@ -39,11 +39,12 @@
import static android.net.TetheringManager.TETHERING_USB;
import static android.net.TetheringManager.TETHERING_WIFI;
import static android.net.TetheringManager.TETHERING_WIFI_P2P;
-import static android.net.TetheringManager.TETHER_ERROR_MASTER_ERROR;
+import static android.net.TetheringManager.TETHER_ERROR_INTERNAL_ERROR;
import static android.net.TetheringManager.TETHER_ERROR_NO_ERROR;
import static android.net.TetheringManager.TETHER_ERROR_SERVICE_UNAVAIL;
import static android.net.TetheringManager.TETHER_ERROR_UNAVAIL_IFACE;
import static android.net.TetheringManager.TETHER_ERROR_UNKNOWN_IFACE;
+import static android.net.TetheringManager.TETHER_ERROR_UNKNOWN_TYPE;
import static android.net.TetheringManager.TETHER_HARDWARE_OFFLOAD_FAILED;
import static android.net.TetheringManager.TETHER_HARDWARE_OFFLOAD_STARTED;
import static android.net.TetheringManager.TETHER_HARDWARE_OFFLOAD_STOPPED;
@@ -545,7 +546,7 @@
break;
default:
Log.w(TAG, "Invalid tether type.");
- result = TETHER_ERROR_UNKNOWN_IFACE;
+ result = TETHER_ERROR_UNKNOWN_TYPE;
}
// The result of Bluetooth tethering will be sent by #setBluetoothTethering.
@@ -586,7 +587,7 @@
Binder.restoreCallingIdentity(ident);
}
- return TETHER_ERROR_MASTER_ERROR;
+ return TETHER_ERROR_INTERNAL_ERROR;
}
private void setBluetoothTethering(final boolean enable, final IIntResultListener listener) {
@@ -622,7 +623,7 @@
// We should figure out a way to bubble up that failure instead of sending success.
final int result = (((BluetoothPan) proxy).isTetheringOn() == enable)
? TETHER_ERROR_NO_ERROR
- : TETHER_ERROR_MASTER_ERROR;
+ : TETHER_ERROR_INTERNAL_ERROR;
sendTetherResult(listener, result, TETHERING_BLUETOOTH);
adapter.closeProfileProxy(BluetoothProfile.PAN, proxy);
}
@@ -2180,7 +2181,7 @@
// If TetherMasterSM is in ErrorState, TetherMasterSM stays there.
// Thus we give a chance for TetherMasterSM to recover to InitialState
// by sending CMD_CLEAR_ERROR
- if (error == TETHER_ERROR_MASTER_ERROR) {
+ if (error == TETHER_ERROR_INTERNAL_ERROR) {
mTetherMasterSM.sendMessage(TetherMasterSM.CMD_CLEAR_ERROR, who);
}
int which;
diff --git a/packages/Tethering/tests/unit/src/android/net/ip/IpServerTest.java b/packages/Tethering/tests/unit/src/android/net/ip/IpServerTest.java
index 948266d..3106e0e 100644
--- a/packages/Tethering/tests/unit/src/android/net/ip/IpServerTest.java
+++ b/packages/Tethering/tests/unit/src/android/net/ip/IpServerTest.java
@@ -21,7 +21,7 @@
import static android.net.TetheringManager.TETHERING_USB;
import static android.net.TetheringManager.TETHERING_WIFI;
import static android.net.TetheringManager.TETHERING_WIFI_P2P;
-import static android.net.TetheringManager.TETHER_ERROR_ENABLE_NAT_ERROR;
+import static android.net.TetheringManager.TETHER_ERROR_ENABLE_FORWARDING_ERROR;
import static android.net.TetheringManager.TETHER_ERROR_NO_ERROR;
import static android.net.TetheringManager.TETHER_ERROR_TETHER_IFACE_ERROR;
import static android.net.dhcp.IDhcpServer.STATUS_SUCCESS;
@@ -448,7 +448,7 @@
usbTeardownOrder.verify(mNetd, times(2)).interfaceSetCfg(
argThat(cfg -> IFACE_NAME.equals(cfg.ifName)));
usbTeardownOrder.verify(mCallback).updateInterfaceState(
- mIpServer, STATE_AVAILABLE, TETHER_ERROR_ENABLE_NAT_ERROR);
+ mIpServer, STATE_AVAILABLE, TETHER_ERROR_ENABLE_FORWARDING_ERROR);
usbTeardownOrder.verify(mCallback).updateLinkProperties(
eq(mIpServer), mLinkPropertiesCaptor.capture());
assertNoAddressesNorRoutes(mLinkPropertiesCaptor.getValue());
diff --git a/packages/Tethering/tests/unit/src/com/android/server/connectivity/tethering/EntitlementManagerTest.java b/packages/Tethering/tests/unit/src/com/android/server/connectivity/tethering/EntitlementManagerTest.java
index 3a1d4a6..0a7850b 100644
--- a/packages/Tethering/tests/unit/src/com/android/server/connectivity/tethering/EntitlementManagerTest.java
+++ b/packages/Tethering/tests/unit/src/com/android/server/connectivity/tethering/EntitlementManagerTest.java
@@ -21,7 +21,7 @@
import static android.net.TetheringManager.TETHERING_WIFI;
import static android.net.TetheringManager.TETHER_ERROR_ENTITLEMENT_UNKNOWN;
import static android.net.TetheringManager.TETHER_ERROR_NO_ERROR;
-import static android.net.TetheringManager.TETHER_ERROR_PROVISION_FAILED;
+import static android.net.TetheringManager.TETHER_ERROR_PROVISIONING_FAILED;
import static android.provider.DeviceConfig.NAMESPACE_CONNECTIVITY;
import static android.telephony.SubscriptionManager.INVALID_SUBSCRIPTION_ID;
@@ -284,11 +284,11 @@
assertEquals(0, mEnMgr.uiProvisionCount);
mEnMgr.reset();
// 3. No cache value and ui entitlement check is needed.
- mEnMgr.fakeEntitlementResult = TETHER_ERROR_PROVISION_FAILED;
+ mEnMgr.fakeEntitlementResult = TETHER_ERROR_PROVISIONING_FAILED;
receiver = new ResultReceiver(null) {
@Override
protected void onReceiveResult(int resultCode, Bundle resultData) {
- assertEquals(TETHER_ERROR_PROVISION_FAILED, resultCode);
+ assertEquals(TETHER_ERROR_PROVISIONING_FAILED, resultCode);
mCallbacklatch.countDown();
}
};
@@ -297,12 +297,13 @@
callbackTimeoutHelper(mCallbacklatch);
assertEquals(1, mEnMgr.uiProvisionCount);
mEnMgr.reset();
- // 4. Cache value is TETHER_ERROR_PROVISION_FAILED and don't need to run entitlement check.
+ // 4. Cache value is TETHER_ERROR_PROVISIONING_FAILED and don't need to run entitlement
+ // check.
mEnMgr.fakeEntitlementResult = TETHER_ERROR_NO_ERROR;
receiver = new ResultReceiver(null) {
@Override
protected void onReceiveResult(int resultCode, Bundle resultData) {
- assertEquals(TETHER_ERROR_PROVISION_FAILED, resultCode);
+ assertEquals(TETHER_ERROR_PROVISIONING_FAILED, resultCode);
mCallbacklatch.countDown();
}
};
@@ -311,7 +312,7 @@
callbackTimeoutHelper(mCallbacklatch);
assertEquals(0, mEnMgr.uiProvisionCount);
mEnMgr.reset();
- // 5. Cache value is TETHER_ERROR_PROVISION_FAILED and ui entitlement check is needed.
+ // 5. Cache value is TETHER_ERROR_PROVISIONING_FAILED and ui entitlement check is needed.
mEnMgr.fakeEntitlementResult = TETHER_ERROR_NO_ERROR;
receiver = new ResultReceiver(null) {
@Override
@@ -364,7 +365,7 @@
public void verifyPermissionResult() {
setupForRequiredProvisioning();
mEnMgr.notifyUpstream(true);
- mEnMgr.fakeEntitlementResult = TETHER_ERROR_PROVISION_FAILED;
+ mEnMgr.fakeEntitlementResult = TETHER_ERROR_PROVISIONING_FAILED;
mEnMgr.startProvisioningIfNeeded(TETHERING_WIFI, true);
mLooper.dispatchAll();
assertFalse(mEnMgr.isCellularUpstreamPermitted());
@@ -380,15 +381,15 @@
public void verifyPermissionIfAllNotApproved() {
setupForRequiredProvisioning();
mEnMgr.notifyUpstream(true);
- mEnMgr.fakeEntitlementResult = TETHER_ERROR_PROVISION_FAILED;
+ mEnMgr.fakeEntitlementResult = TETHER_ERROR_PROVISIONING_FAILED;
mEnMgr.startProvisioningIfNeeded(TETHERING_WIFI, true);
mLooper.dispatchAll();
assertFalse(mEnMgr.isCellularUpstreamPermitted());
- mEnMgr.fakeEntitlementResult = TETHER_ERROR_PROVISION_FAILED;
+ mEnMgr.fakeEntitlementResult = TETHER_ERROR_PROVISIONING_FAILED;
mEnMgr.startProvisioningIfNeeded(TETHERING_USB, true);
mLooper.dispatchAll();
assertFalse(mEnMgr.isCellularUpstreamPermitted());
- mEnMgr.fakeEntitlementResult = TETHER_ERROR_PROVISION_FAILED;
+ mEnMgr.fakeEntitlementResult = TETHER_ERROR_PROVISIONING_FAILED;
mEnMgr.startProvisioningIfNeeded(TETHERING_BLUETOOTH, true);
mLooper.dispatchAll();
assertFalse(mEnMgr.isCellularUpstreamPermitted());
@@ -403,7 +404,7 @@
mLooper.dispatchAll();
assertTrue(mEnMgr.isCellularUpstreamPermitted());
mLooper.dispatchAll();
- mEnMgr.fakeEntitlementResult = TETHER_ERROR_PROVISION_FAILED;
+ mEnMgr.fakeEntitlementResult = TETHER_ERROR_PROVISIONING_FAILED;
mEnMgr.startProvisioningIfNeeded(TETHERING_USB, true);
mLooper.dispatchAll();
assertTrue(mEnMgr.isCellularUpstreamPermitted());
@@ -465,7 +466,7 @@
assertEquals(0, mEnMgr.silentProvisionCount);
mEnMgr.reset();
// 6. switch upstream back to mobile again
- mEnMgr.fakeEntitlementResult = TETHER_ERROR_PROVISION_FAILED;
+ mEnMgr.fakeEntitlementResult = TETHER_ERROR_PROVISIONING_FAILED;
mEnMgr.notifyUpstream(true);
mLooper.dispatchAll();
assertEquals(0, mEnMgr.uiProvisionCount);
@@ -477,7 +478,7 @@
public void testCallStopTetheringWhenUiProvisioningFail() {
setupForRequiredProvisioning();
verify(mEntitlementFailedListener, times(0)).onUiEntitlementFailed(TETHERING_WIFI);
- mEnMgr.fakeEntitlementResult = TETHER_ERROR_PROVISION_FAILED;
+ mEnMgr.fakeEntitlementResult = TETHER_ERROR_PROVISIONING_FAILED;
mEnMgr.notifyUpstream(true);
mLooper.dispatchAll();
mEnMgr.startProvisioningIfNeeded(TETHERING_WIFI, true);
diff --git a/services/core/java/com/android/server/StorageManagerService.java b/services/core/java/com/android/server/StorageManagerService.java
index 5a056d3..a767347 100644
--- a/services/core/java/com/android/server/StorageManagerService.java
+++ b/services/core/java/com/android/server/StorageManagerService.java
@@ -4139,19 +4139,6 @@
boolean hasLegacy = mIAppOpsService.checkOperation(OP_LEGACY_STORAGE,
uid, packageName) == MODE_ALLOWED;
- // Hack(b/147137425): we have to honor hasRequestedLegacyExternalStorage for a short
- // while to enable 2 cases.
- // 1) Apps that want to be in scoped storage in R, but want to opt out in Q devices,
- // because they want to use raw file paths, would fail until fuse is enabled by default.
- // 2) Test apps that target current sdk will fail. They would fail even after fuse is
- // enabled, but we are fixing it with b/142395442. We are not planning to enable
- // fuse by default until b/142395442 is fixed.
- if (!hasLegacy && !mIsFuseEnabled) {
- ApplicationInfo ai = mIPackageManager.getApplicationInfo(packageName,
- 0, UserHandle.getUserId(uid));
- hasLegacy = (ai != null && ai.hasRequestedLegacyExternalStorage());
- }
-
if (hasLegacy && hasWrite) {
return Zygote.MOUNT_EXTERNAL_WRITE;
} else if (hasLegacy && hasRead) {
diff --git a/services/core/java/com/android/server/timezonedetector/TimeZoneDetectorService.java b/services/core/java/com/android/server/timezonedetector/TimeZoneDetectorService.java
index 57b6ec9..fc52584 100644
--- a/services/core/java/com/android/server/timezonedetector/TimeZoneDetectorService.java
+++ b/services/core/java/com/android/server/timezonedetector/TimeZoneDetectorService.java
@@ -25,6 +25,8 @@
import android.content.Context;
import android.database.ContentObserver;
import android.os.Handler;
+import android.os.ResultReceiver;
+import android.os.ShellCallback;
import android.provider.Settings;
import com.android.internal.annotations.VisibleForTesting;
@@ -133,5 +135,13 @@
android.Manifest.permission.SUGGEST_MANUAL_TIME_AND_ZONE,
"suggest manual time and time zone");
}
+
+ @Override
+ public void onShellCommand(FileDescriptor in, FileDescriptor out,
+ FileDescriptor err, String[] args, ShellCallback callback,
+ ResultReceiver resultReceiver) {
+ (new TimeZoneDetectorShellCommand(this)).exec(
+ this, in, out, err, args, callback, resultReceiver);
+ }
}
diff --git a/services/core/java/com/android/server/timezonedetector/TimeZoneDetectorShellCommand.java b/services/core/java/com/android/server/timezonedetector/TimeZoneDetectorShellCommand.java
new file mode 100644
index 0000000..b051bab
--- /dev/null
+++ b/services/core/java/com/android/server/timezonedetector/TimeZoneDetectorShellCommand.java
@@ -0,0 +1,118 @@
+/*
+ * Copyright (C) 2020 The Android Open Source Project
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package com.android.server.timezonedetector;
+
+import android.app.timezonedetector.ManualTimeZoneSuggestion;
+import android.app.timezonedetector.TelephonyTimeZoneSuggestion;
+import android.os.ShellCommand;
+
+import java.io.PrintWriter;
+
+/** Implemented the shell command interface for {@link TimeZoneDetectorService}. */
+class TimeZoneDetectorShellCommand extends ShellCommand {
+
+ private final TimeZoneDetectorService mInterface;
+
+ TimeZoneDetectorShellCommand(TimeZoneDetectorService timeZoneDetectorService) {
+ mInterface = timeZoneDetectorService;
+ }
+
+ @Override
+ public int onCommand(String cmd) {
+ if (cmd == null) {
+ return handleDefaultCommands(cmd);
+ }
+
+ switch (cmd) {
+ case "suggestTelephonyTimeZone":
+ return runSuggestTelephonyTimeZone();
+ case "suggestManualTimeZone":
+ return runSuggestManualTimeZone();
+ default: {
+ return handleDefaultCommands(cmd);
+ }
+ }
+ }
+
+ private int runSuggestTelephonyTimeZone() {
+ final PrintWriter pw = getOutPrintWriter();
+ try {
+ TelephonyTimeZoneSuggestion suggestion = null;
+ String opt;
+ while ((opt = getNextArg()) != null) {
+ if ("--suggestion".equals(opt)) {
+ suggestion = TelephonyTimeZoneSuggestion.parseCommandLineArg(this);
+ } else {
+ pw.println("Error: Unknown option: " + opt);
+ return 1;
+ }
+ }
+ if (suggestion == null) {
+ pw.println("Error: suggestion not specified");
+ return 1;
+ }
+ mInterface.suggestTelephonyTimeZone(suggestion);
+ pw.println("Suggestion " + suggestion + " injected.");
+ return 0;
+ } catch (RuntimeException e) {
+ pw.println(e.toString());
+ return 1;
+ }
+ }
+
+ private int runSuggestManualTimeZone() {
+ final PrintWriter pw = getOutPrintWriter();
+ try {
+ ManualTimeZoneSuggestion suggestion = null;
+ String opt;
+ while ((opt = getNextArg()) != null) {
+ if ("--suggestion".equals(opt)) {
+ suggestion = ManualTimeZoneSuggestion.parseCommandLineArg(this);
+ } else {
+ pw.println("Error: Unknown option: " + opt);
+ return 1;
+ }
+ }
+ if (suggestion == null) {
+ pw.println("Error: suggestion not specified");
+ return 1;
+ }
+ mInterface.suggestManualTimeZone(suggestion);
+ pw.println("Suggestion " + suggestion + " injected.");
+ return 0;
+ } catch (RuntimeException e) {
+ pw.println(e.toString());
+ return 1;
+ }
+ }
+
+ @Override
+ public void onHelp() {
+ final PrintWriter pw = getOutPrintWriter();
+ pw.println("Time Zone Detector (time_zone_detector) commands:");
+ pw.println(" help");
+ pw.println(" Print this help text.");
+ pw.println(" suggestTelephonyTimeZone");
+ pw.println(" --suggestion <telephony suggestion opts>");
+ pw.println(" suggestManualTimeZone");
+ pw.println(" --suggestion <manual suggestion opts>");
+ pw.println();
+ ManualTimeZoneSuggestion.printCommandLineOpts(pw);
+ pw.println();
+ TelephonyTimeZoneSuggestion.printCommandLineOpts(pw);
+ pw.println();
+ }
+}
diff --git a/services/tests/servicestests/src/com/android/server/webkit/WebViewUpdateServiceTest.java b/services/tests/servicestests/src/com/android/server/webkit/WebViewUpdateServiceTest.java
index 2e60866..bbfc5ab 100644
--- a/services/tests/servicestests/src/com/android/server/webkit/WebViewUpdateServiceTest.java
+++ b/services/tests/servicestests/src/com/android/server/webkit/WebViewUpdateServiceTest.java
@@ -1275,25 +1275,8 @@
true /* valid */, true /* installed */));
runWebViewBootPreparationOnMainSync();
-
checkPreparationPhasesForPackage(primaryPackage, 1 /* first preparation phase */);
- mWebViewUpdateServiceImpl.packageStateChanged(primaryPackage,
- WebViewUpdateService.PACKAGE_ADDED_REPLACED, 0 /* userId */);
- mWebViewUpdateServiceImpl.packageStateChanged(primaryPackage,
- WebViewUpdateService.PACKAGE_ADDED_REPLACED, 1 /* userId */);
- mWebViewUpdateServiceImpl.packageStateChanged(primaryPackage,
- WebViewUpdateService.PACKAGE_ADDED_REPLACED, 2 /* userId */);
- // package still has the same update-time so we shouldn't run preparation here
- Mockito.verify(mTestSystemImpl, Mockito.times(1)).onWebViewProviderChanged(
- Mockito.argThat(new IsPackageInfoWithName(primaryPackage)));
-
- // Ensure we can still load the package
- WebViewProviderResponse response = mWebViewUpdateServiceImpl.waitForAndGetProvider();
- assertEquals(WebViewFactory.LIBLOAD_SUCCESS, response.status);
- assertEquals(primaryPackage, response.packageInfo.packageName);
-
-
mTestSystemImpl.setPackageInfo(createPackageInfo(primaryPackage, true /* enabled */,
true /* valid */, true /* installed */, null /* signatures */,
20 /* lastUpdateTime*/ ));
diff --git a/tests/RollbackTest/RollbackTest.xml b/tests/RollbackTest/RollbackTest.xml
index f2c0f86..269cec1 100644
--- a/tests/RollbackTest/RollbackTest.xml
+++ b/tests/RollbackTest/RollbackTest.xml
@@ -18,6 +18,12 @@
<target_preparer class="com.android.tradefed.targetprep.TestAppInstallSetup">
<option name="test-file-name" value="RollbackTest.apk" />
</target_preparer>
+ <target_preparer class="com.android.tradefed.targetprep.RunCommandTargetPreparer">
+ <option name="run-command" value="am broadcast -a 'com.google.android.gms.phenotype.FLAG_OVERRIDE' --es package "com.google.android.gms.platformconfigurator" --es user '\\*' --esa flags "ModuleConfig__immediate_commit_packages" --esa types "bytes" --esa values "CgA=" com.google.android.gms" />
+ <option name="run-command" value="am broadcast -a 'com.google.android.gms.phenotype.FLAG_OVERRIDE' --es package "com.google.android.gms.platformconfigurator" --es user '\\*' --esa flags "ModuleConfig__versioned_immediate_commit_packages" --esa types "bytes" --esa values "Cm5vdGFwYWNrYWdlOgA=" com.google.android.gms" />
+ <option name="teardown-command" value="am broadcast -a 'com.google.android.gms.phenotype.FLAG_OVERRIDE' --es action delete --es package "com.google.android.gms.platformconfigurator" --es user '\*' --esa flag "ModuleConfig__immediate_commit_packages" com.google.android.gms" />
+ <option name="teardown-command" value="am broadcast -a 'com.google.android.gms.phenotype.FLAG_OVERRIDE' --es action delete --es package "com.google.android.gms.platformconfigurator" --es user '\*' --esa flag "ModuleConfig__versioned_immediate_commit_packages" com.google.android.gms" />
+ </target_preparer>
<test class="com.android.tradefed.testtype.AndroidJUnitTest" >
<option name="package" value="com.android.tests.rollback" />
<option name="runner" value="androidx.test.runner.AndroidJUnitRunner" />