Merge "Add file ownership to config_tv_external_input_logging.xml" into main
diff --git a/core/java/android/hardware/SensorAdditionalInfo.java b/core/java/android/hardware/SensorAdditionalInfo.java
index 59def9f..d1e101d 100644
--- a/core/java/android/hardware/SensorAdditionalInfo.java
+++ b/core/java/android/hardware/SensorAdditionalInfo.java
@@ -257,7 +257,7 @@
public static SensorAdditionalInfo createLocalGeomagneticField(
float strength, float declination, float inclination) {
if (strength < 10 || strength > 100 // much beyond extreme values on earth
- || declination < 0 || declination > Math.PI
+ || declination < -Math.PI / 2 || declination > Math.PI / 2
|| inclination < -Math.PI / 2 || inclination > Math.PI / 2) {
throw new IllegalArgumentException("Geomagnetic field info out of range");
}
diff --git a/core/java/android/os/INetworkManagementService.aidl b/core/java/android/os/INetworkManagementService.aidl
index ec69e2a..6e6ab7b 100644
--- a/core/java/android/os/INetworkManagementService.aidl
+++ b/core/java/android/os/INetworkManagementService.aidl
@@ -125,50 +125,65 @@
/**
* Returns true if IP forwarding is enabled
*/
- @UnsupportedAppUsage
+ @UnsupportedAppUsage(maxTargetSdk = 34, trackingBug = 170729553,
+ publicAlternatives = "Use {@code android.net.INetd#ipfwdEnabled}")
boolean getIpForwardingEnabled();
/**
* Enables/Disables IP Forwarding
*/
- @UnsupportedAppUsage
+ @UnsupportedAppUsage(maxTargetSdk = 34, trackingBug = 170729553,
+ publicAlternatives = "Avoid using this directly. Instead, enable tethering with "
+ + "{@code android.net.TetheringManager#startTethering}. See also "
+ + "{@code INetd#ipfwdEnableForwarding(String)}.")
void setIpForwardingEnabled(boolean enabled);
/**
* Start tethering services with the specified dhcp server range
* arg is a set of start end pairs defining the ranges.
*/
- @UnsupportedAppUsage
+ @UnsupportedAppUsage(maxTargetSdk = 34, trackingBug = 170729553,
+ publicAlternatives = "{@code android.net.TetheringManager#startTethering}")
void startTethering(in String[] dhcpRanges);
/**
* Stop currently running tethering services
*/
- @UnsupportedAppUsage
+ @UnsupportedAppUsage(maxTargetSdk = 34, trackingBug = 170729553,
+ publicAlternatives = "{@code android.net.TetheringManager#stopTethering(int)}")
void stopTethering();
/**
* Returns true if tethering services are started
*/
- @UnsupportedAppUsage
+ @UnsupportedAppUsage(maxTargetSdk = 34, trackingBug = 170729553,
+ publicAlternatives = "Generally track your own tethering requests. "
+ + "See also {@code android.net.INetd#tetherIsEnabled()}")
boolean isTetheringStarted();
/**
* Tethers the specified interface
*/
- @UnsupportedAppUsage
+ @UnsupportedAppUsage(maxTargetSdk = 34, trackingBug = 170729553,
+ publicAlternatives = "Avoid using this directly. Instead, enable tethering with "
+ + "{@code android.net.TetheringManager#startTethering}. See also "
+ + "{@code com.android.net.module.util.NetdUtils#tetherInterface}.")
void tetherInterface(String iface);
/**
* Untethers the specified interface
*/
- @UnsupportedAppUsage
+ @UnsupportedAppUsage(maxTargetSdk = 34, trackingBug = 170729553,
+ publicAlternatives = "Avoid using this directly. Instead, disable "
+ + "tethering with {@code android.net.TetheringManager#stopTethering(int)}. "
+ + "See also {@code NetdUtils#untetherInterface}.")
void untetherInterface(String iface);
/**
* Returns a list of currently tethered interfaces
*/
- @UnsupportedAppUsage
+ @UnsupportedAppUsage(maxTargetSdk = 34, trackingBug = 170729553,
+ publicAlternatives = "{@code android.net.TetheringManager#getTetheredIfaces()}")
String[] listTetheredInterfaces();
/**
@@ -176,13 +191,17 @@
* The address and netmask of the external interface is used for
* the NAT'ed network.
*/
- @UnsupportedAppUsage
+ @UnsupportedAppUsage(maxTargetSdk = 34, trackingBug = 170729553,
+ publicAlternatives = "Avoid using this directly. Instead, enable tethering with "
+ + "{@code android.net.TetheringManager#startTethering}.")
void enableNat(String internalInterface, String externalInterface);
/**
* Disables Network Address Translation between two interfaces.
*/
- @UnsupportedAppUsage
+ @UnsupportedAppUsage(maxTargetSdk = 34, trackingBug = 170729553,
+ publicAlternatives = "Avoid using this directly. Instead, disable tethering with "
+ + "{@code android.net.TetheringManager#stopTethering(int)}.")
void disableNat(String internalInterface, String externalInterface);
/**
diff --git a/services/core/java/com/android/server/NetworkManagementService.java b/services/core/java/com/android/server/NetworkManagementService.java
index a027e04..1da368e 100644
--- a/services/core/java/com/android/server/NetworkManagementService.java
+++ b/services/core/java/com/android/server/NetworkManagementService.java
@@ -75,6 +75,7 @@
import com.android.internal.app.IBatteryStats;
import com.android.internal.util.DumpUtils;
import com.android.internal.util.HexDump;
+import com.android.modules.utils.build.SdkLevel;
import com.android.net.module.util.NetdUtils;
import com.android.net.module.util.NetdUtils.ModifyOperation;
import com.android.net.module.util.PermissionUtils;
@@ -779,7 +780,10 @@
@Override
public boolean getIpForwardingEnabled() throws IllegalStateException{
PermissionUtils.enforceNetworkStackPermission(mContext);
-
+ if (SdkLevel.isAtLeastV()) {
+ throw new UnsupportedOperationException(
+ "NMS#getIpForwardingEnabled not supported in V+");
+ }
try {
return mNetdService.ipfwdEnabled();
} catch (RemoteException | ServiceSpecificException e) {
@@ -790,6 +794,10 @@
@Override
public void setIpForwardingEnabled(boolean enable) {
PermissionUtils.enforceNetworkStackPermission(mContext);
+ if (SdkLevel.isAtLeastV()) {
+ throw new UnsupportedOperationException(
+ "NMS#setIpForwardingEnabled not supported in V+");
+ }
try {
if (enable) {
mNetdService.ipfwdEnableForwarding("tethering");
@@ -804,6 +812,9 @@
@Override
public void startTethering(String[] dhcpRange) {
PermissionUtils.enforceNetworkStackPermission(mContext);
+ if (SdkLevel.isAtLeastV()) {
+ throw new UnsupportedOperationException("NMS#startTethering not supported in V+");
+ }
try {
NetdUtils.tetherStart(mNetdService, true /* usingLegacyDnsProxy */, dhcpRange);
} catch (RemoteException | ServiceSpecificException e) {
@@ -814,6 +825,9 @@
@Override
public void stopTethering() {
PermissionUtils.enforceNetworkStackPermission(mContext);
+ if (SdkLevel.isAtLeastV()) {
+ throw new UnsupportedOperationException("NMS#stopTethering not supported in V+");
+ }
try {
mNetdService.tetherStop();
} catch (RemoteException | ServiceSpecificException e) {
@@ -824,6 +838,9 @@
@Override
public boolean isTetheringStarted() {
PermissionUtils.enforceNetworkStackPermission(mContext);
+ if (SdkLevel.isAtLeastV()) {
+ throw new UnsupportedOperationException("NMS#isTetheringStarted not supported in V+");
+ }
try {
return mNetdService.tetherIsEnabled();
} catch (RemoteException | ServiceSpecificException e) {
@@ -834,6 +851,9 @@
@Override
public void tetherInterface(String iface) {
PermissionUtils.enforceNetworkStackPermission(mContext);
+ if (SdkLevel.isAtLeastV()) {
+ throw new UnsupportedOperationException("NMS#tetherInterface not supported in V+");
+ }
try {
final LinkAddress addr = getInterfaceConfig(iface).getLinkAddress();
final IpPrefix dest = new IpPrefix(addr.getAddress(), addr.getPrefixLength());
@@ -846,6 +866,9 @@
@Override
public void untetherInterface(String iface) {
PermissionUtils.enforceNetworkStackPermission(mContext);
+ if (SdkLevel.isAtLeastV()) {
+ throw new UnsupportedOperationException("NMS#untetherInterface not supported in V+");
+ }
try {
NetdUtils.untetherInterface(mNetdService, iface);
} catch (RemoteException | ServiceSpecificException e) {
@@ -856,6 +879,10 @@
@Override
public String[] listTetheredInterfaces() {
PermissionUtils.enforceNetworkStackPermission(mContext);
+ if (SdkLevel.isAtLeastV()) {
+ throw new UnsupportedOperationException(
+ "NMS#listTetheredInterfaces not supported in V+");
+ }
try {
return mNetdService.tetherInterfaceList();
} catch (RemoteException | ServiceSpecificException e) {
@@ -866,6 +893,9 @@
@Override
public void enableNat(String internalInterface, String externalInterface) {
PermissionUtils.enforceNetworkStackPermission(mContext);
+ if (SdkLevel.isAtLeastV()) {
+ throw new UnsupportedOperationException("NMS#enableNat not supported in V+");
+ }
try {
mNetdService.tetherAddForward(internalInterface, externalInterface);
} catch (RemoteException | ServiceSpecificException e) {
@@ -876,6 +906,9 @@
@Override
public void disableNat(String internalInterface, String externalInterface) {
PermissionUtils.enforceNetworkStackPermission(mContext);
+ if (SdkLevel.isAtLeastV()) {
+ throw new UnsupportedOperationException("NMS#disableNat not supported in V+");
+ }
try {
mNetdService.tetherRemoveForward(internalInterface, externalInterface);
} catch (RemoteException | ServiceSpecificException e) {
diff --git a/services/core/java/com/android/server/connectivity/Vpn.java b/services/core/java/com/android/server/connectivity/Vpn.java
index ff35b19..bfccd58 100644
--- a/services/core/java/com/android/server/connectivity/Vpn.java
+++ b/services/core/java/com/android/server/connectivity/Vpn.java
@@ -3066,7 +3066,8 @@
* <p>This variable controls the retry delay, and is reset when the VPN pass network
* validation.
*/
- private int mValidationFailRetryCount = 0;
+ @VisibleForTesting(visibility = VisibleForTesting.Visibility.PRIVATE)
+ int mValidationFailRetryCount = 0;
/**
* The number of attempts since the last successful connection.
@@ -3897,6 +3898,18 @@
// Skip other invalid status if the scheduled recovery exists.
if (mScheduledHandleDataStallFuture != null) return;
+ // Trigger network validation on the underlying network to possibly cause system
+ // switch default network or try recover if the current default network is broken.
+ //
+ // For the same underlying network, the first validation result should clarify if
+ // it's caused by broken underlying network. So only perform underlying network
+ // re-evaluation after first validation failure to prevent extra network resource
+ // costs on sending probes.
+ if (mValidationFailRetryCount == 0) {
+ mConnectivityManager.reportNetworkConnectivity(
+ mActiveNetwork, false /* hasConnectivity */);
+ }
+
if (mValidationFailRetryCount < MAX_MOBIKE_RECOVERY_ATTEMPT) {
Log.d(TAG, "Validation failed");