summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--core/api/current.txt11
-rw-r--r--core/api/module-lib-current.txt4
-rw-r--r--core/java/android/app/ActivityThread.java41
-rw-r--r--core/java/android/net/ConnectivityMetricsEvent.aidl (renamed from packages/Connectivity/framework/src/android/net/ConnectivityMetricsEvent.aidl)0
-rw-r--r--core/java/android/net/InterfaceConfiguration.aidl (renamed from packages/Connectivity/framework/src/android/net/InterfaceConfiguration.aidl)0
-rw-r--r--core/java/android/net/UidRange.aidl (renamed from packages/Connectivity/framework/src/android/net/UidRange.aidl)0
-rw-r--r--core/java/android/net/vcn/VcnControlPlaneConfig.java2
-rw-r--r--core/java/android/net/vcn/VcnControlPlaneIkeConfig.java2
-rw-r--r--core/java/android/net/vcn/VcnGatewayConnectionConfig.java8
-rw-r--r--core/java/android/os/Trace.java6
-rw-r--r--core/java/android/uwb/OWNERS1
-rw-r--r--core/java/android/uwb/TEST_MAPPING5
-rw-r--r--core/jni/android_os_Trace.cpp2
-rw-r--r--core/tests/overlaytests/device/AndroidTest.xml8
-rw-r--r--core/tests/uwbtests/src/android/uwb/AngleMeasurementTest.java85
-rw-r--r--core/tests/uwbtests/src/android/uwb/AngleOfArrivalMeasurementTest.java89
-rw-r--r--core/tests/uwbtests/src/android/uwb/DistanceMeasurementTest.java87
-rw-r--r--core/tests/uwbtests/src/android/uwb/RangingMeasurementTest.java95
-rw-r--r--core/tests/uwbtests/src/android/uwb/RangingReportTest.java90
-rw-r--r--core/tests/uwbtests/src/android/uwb/RangingSessionTest.java378
-rw-r--r--core/tests/uwbtests/src/android/uwb/SessionHandleTest.java52
-rw-r--r--core/tests/uwbtests/src/android/uwb/UwbAddressTest.java79
-rw-r--r--core/tests/uwbtests/src/android/uwb/UwbManagerTest.java49
-rw-r--r--packages/Connectivity/framework/Android.bp27
-rw-r--r--packages/Connectivity/framework/aidl-export/android/net/CaptivePortalData.aidl (renamed from packages/Connectivity/framework/src/android/net/CaptivePortalData.aidl)0
-rw-r--r--packages/Connectivity/framework/aidl-export/android/net/ConnectivityDiagnosticsManager.aidl (renamed from packages/Connectivity/framework/src/android/net/ConnectivityDiagnosticsManager.aidl)0
-rw-r--r--packages/Connectivity/framework/aidl-export/android/net/DhcpInfo.aidl (renamed from packages/Connectivity/framework/src/android/net/DhcpInfo.aidl)0
-rw-r--r--packages/Connectivity/framework/aidl-export/android/net/IpConfiguration.aidl (renamed from packages/Connectivity/framework/src/android/net/IpConfiguration.aidl)0
-rw-r--r--packages/Connectivity/framework/aidl-export/android/net/IpPrefix.aidl (renamed from packages/Connectivity/framework/src/android/net/IpPrefix.aidl)0
-rw-r--r--packages/Connectivity/framework/aidl-export/android/net/KeepalivePacketData.aidl (renamed from packages/Connectivity/framework/src/android/net/KeepalivePacketData.aidl)0
-rw-r--r--packages/Connectivity/framework/aidl-export/android/net/LinkAddress.aidl (renamed from packages/Connectivity/framework/src/android/net/LinkAddress.aidl)0
-rw-r--r--packages/Connectivity/framework/aidl-export/android/net/LinkProperties.aidl (renamed from packages/Connectivity/framework/src/android/net/LinkProperties.aidl)0
-rw-r--r--packages/Connectivity/framework/aidl-export/android/net/MacAddress.aidl (renamed from packages/Connectivity/framework/src/android/net/MacAddress.aidl)0
-rw-r--r--packages/Connectivity/framework/aidl-export/android/net/Network.aidl (renamed from packages/Connectivity/framework/src/android/net/Network.aidl)0
-rw-r--r--packages/Connectivity/framework/aidl-export/android/net/NetworkAgentConfig.aidl (renamed from packages/Connectivity/framework/src/android/net/NetworkAgentConfig.aidl)0
-rw-r--r--packages/Connectivity/framework/aidl-export/android/net/NetworkCapabilities.aidl (renamed from packages/Connectivity/framework/src/android/net/NetworkCapabilities.aidl)0
-rw-r--r--packages/Connectivity/framework/aidl-export/android/net/NetworkInfo.aidl (renamed from packages/Connectivity/framework/src/android/net/NetworkInfo.aidl)0
-rw-r--r--packages/Connectivity/framework/aidl-export/android/net/NetworkRequest.aidl (renamed from packages/Connectivity/framework/src/android/net/NetworkRequest.aidl)0
-rw-r--r--packages/Connectivity/framework/aidl-export/android/net/ProxyInfo.aidl (renamed from packages/Connectivity/framework/src/android/net/ProxyInfo.aidl)0
-rw-r--r--packages/Connectivity/framework/aidl-export/android/net/RouteInfo.aidl (renamed from packages/Connectivity/framework/src/android/net/RouteInfo.aidl)0
-rw-r--r--packages/Connectivity/framework/aidl-export/android/net/StaticIpConfiguration.aidl (renamed from packages/Connectivity/framework/src/android/net/StaticIpConfiguration.aidl)0
-rw-r--r--packages/Connectivity/framework/aidl-export/android/net/TestNetworkInterface.aidl (renamed from packages/Connectivity/framework/src/android/net/TestNetworkInterface.aidl)0
-rw-r--r--packages/Connectivity/framework/aidl-export/android/net/apf/ApfCapabilities.aidl (renamed from packages/Connectivity/framework/src/android/net/apf/ApfCapabilities.aidl)0
-rw-r--r--packages/Connectivity/framework/src/android/net/ConnectivityManager.java2
-rw-r--r--packages/Connectivity/framework/src/android/net/Proxy.java20
-rw-r--r--services/core/java/com/android/server/os/NativeTombstoneManager.java3
-rw-r--r--tests/net/java/com/android/server/ConnectivityServiceTest.java100
-rw-r--r--tests/net/java/com/android/server/connectivity/NetworkNotificationManagerTest.java4
48 files changed, 149 insertions, 1101 deletions
diff --git a/core/api/current.txt b/core/api/current.txt
index 39f330f468a8..eb3330ccc586 100644
--- a/core/api/current.txt
+++ b/core/api/current.txt
@@ -26113,6 +26113,15 @@ package android.net.vcn {
method @NonNull public android.net.vcn.VcnConfig build();
}
+ public abstract class VcnControlPlaneConfig {
+ }
+
+ public final class VcnControlPlaneIkeConfig extends android.net.vcn.VcnControlPlaneConfig {
+ ctor public VcnControlPlaneIkeConfig(@NonNull android.net.ipsec.ike.IkeSessionParams, @NonNull android.net.ipsec.ike.TunnelModeChildSessionParams);
+ method @NonNull public android.net.ipsec.ike.TunnelModeChildSessionParams getChildSessionParams();
+ method @NonNull public android.net.ipsec.ike.IkeSessionParams getIkeSessionParams();
+ }
+
public final class VcnGatewayConnectionConfig {
method @NonNull public int[] getExposedCapabilities();
method @IntRange(from=android.net.vcn.VcnGatewayConnectionConfig.MIN_MTU_V6) public int getMaxMtu();
@@ -26121,7 +26130,7 @@ package android.net.vcn {
}
public static final class VcnGatewayConnectionConfig.Builder {
- ctor public VcnGatewayConnectionConfig.Builder();
+ ctor public VcnGatewayConnectionConfig.Builder(@NonNull android.net.vcn.VcnControlPlaneConfig);
method @NonNull public android.net.vcn.VcnGatewayConnectionConfig.Builder addExposedCapability(int);
method @NonNull public android.net.vcn.VcnGatewayConnectionConfig.Builder addRequiredUnderlyingCapability(int);
method @NonNull public android.net.vcn.VcnGatewayConnectionConfig build();
diff --git a/core/api/module-lib-current.txt b/core/api/module-lib-current.txt
index fbaa93185680..527cf9e5e27d 100644
--- a/core/api/module-lib-current.txt
+++ b/core/api/module-lib-current.txt
@@ -36,6 +36,10 @@ package android.net {
field public static final int TRANSPORT_TEST = 7; // 0x7
}
+ public final class Proxy {
+ method public static void setHttpProxyConfiguration(@Nullable android.net.ProxyInfo);
+ }
+
public final class TcpRepairWindow {
ctor public TcpRepairWindow(int, int, int, int, int, int);
field public final int maxWindow;
diff --git a/core/java/android/app/ActivityThread.java b/core/java/android/app/ActivityThread.java
index bfde2d5d3d29..b99d5cd13a77 100644
--- a/core/java/android/app/ActivityThread.java
+++ b/core/java/android/app/ActivityThread.java
@@ -88,7 +88,6 @@ import android.graphics.ImageDecoder;
import android.hardware.display.DisplayManagerGlobal;
import android.inputmethodservice.InputMethodService;
import android.net.ConnectivityManager;
-import android.net.IConnectivityManager;
import android.net.Proxy;
import android.net.Uri;
import android.os.AsyncTask;
@@ -6546,25 +6545,6 @@ public final class ActivityThread extends ClientTransactionHandler {
HardwareRenderer.setDebuggingEnabled(isAppDebuggable || Build.IS_DEBUGGABLE);
HardwareRenderer.setPackageName(data.appInfo.packageName);
- /**
- * Initialize the default http proxy in this process for the reasons we set the time zone.
- */
- Trace.traceBegin(Trace.TRACE_TAG_ACTIVITY_MANAGER, "Setup proxies");
- final IBinder b = ServiceManager.getService(Context.CONNECTIVITY_SERVICE);
- if (b != null) {
- // In pre-boot mode (doing initial launch to collect password), not
- // all system is up. This includes the connectivity service, so don't
- // crash if we can't get it.
- final IConnectivityManager service = IConnectivityManager.Stub.asInterface(b);
- try {
- Proxy.setHttpProxySystemProperty(service.getProxyForNetwork(null));
- } catch (RemoteException e) {
- Trace.traceEnd(Trace.TRACE_TAG_ACTIVITY_MANAGER);
- throw e.rethrowFromSystemServer();
- }
- }
- Trace.traceEnd(Trace.TRACE_TAG_ACTIVITY_MANAGER);
-
// Instrumentation info affects the class loader, so load it before
// setting up the app context.
final InstrumentationInfo ii;
@@ -6603,6 +6583,23 @@ public final class ActivityThread extends ClientTransactionHandler {
updateLocaleListFromAppContext(appContext,
mResourcesManager.getConfiguration().getLocales());
+ // Initialize the default http proxy in this process.
+ Trace.traceBegin(Trace.TRACE_TAG_ACTIVITY_MANAGER, "Setup proxies");
+ try {
+ // In pre-boot mode (doing initial launch to collect password), not all system is up.
+ // This includes the connectivity service, so trying to obtain ConnectivityManager at
+ // that point would return null. Check whether the ConnectivityService is available, and
+ // avoid crashing with a NullPointerException if it is not.
+ final IBinder b = ServiceManager.getService(Context.CONNECTIVITY_SERVICE);
+ if (b != null) {
+ final ConnectivityManager cm =
+ appContext.getSystemService(ConnectivityManager.class);
+ Proxy.setHttpProxyConfiguration(cm.getDefaultProxy());
+ }
+ } finally {
+ Trace.traceEnd(Trace.TRACE_TAG_ACTIVITY_MANAGER);
+ }
+
if (!Process.isIsolated()) {
final int oldMask = StrictMode.allowThreadDiskWritesMask();
try {
@@ -7429,8 +7426,8 @@ public final class ActivityThread extends ClientTransactionHandler {
}
public static void updateHttpProxy(@NonNull Context context) {
- final ConnectivityManager cm = ConnectivityManager.from(context);
- Proxy.setHttpProxySystemProperty(cm.getDefaultProxy());
+ final ConnectivityManager cm = context.getSystemService(ConnectivityManager.class);
+ Proxy.setHttpProxyConfiguration(cm.getDefaultProxy());
}
@UnsupportedAppUsage
diff --git a/packages/Connectivity/framework/src/android/net/ConnectivityMetricsEvent.aidl b/core/java/android/net/ConnectivityMetricsEvent.aidl
index 1c541dc4c8cc..1c541dc4c8cc 100644
--- a/packages/Connectivity/framework/src/android/net/ConnectivityMetricsEvent.aidl
+++ b/core/java/android/net/ConnectivityMetricsEvent.aidl
diff --git a/packages/Connectivity/framework/src/android/net/InterfaceConfiguration.aidl b/core/java/android/net/InterfaceConfiguration.aidl
index 8aa5e3452853..8aa5e3452853 100644
--- a/packages/Connectivity/framework/src/android/net/InterfaceConfiguration.aidl
+++ b/core/java/android/net/InterfaceConfiguration.aidl
diff --git a/packages/Connectivity/framework/src/android/net/UidRange.aidl b/core/java/android/net/UidRange.aidl
index f70fc8e2fefd..f70fc8e2fefd 100644
--- a/packages/Connectivity/framework/src/android/net/UidRange.aidl
+++ b/core/java/android/net/UidRange.aidl
diff --git a/core/java/android/net/vcn/VcnControlPlaneConfig.java b/core/java/android/net/vcn/VcnControlPlaneConfig.java
index 0c6ccfee5d5d..92f6c4440377 100644
--- a/core/java/android/net/vcn/VcnControlPlaneConfig.java
+++ b/core/java/android/net/vcn/VcnControlPlaneConfig.java
@@ -35,8 +35,6 @@ import java.util.Objects;
*
* @see VcnManager
* @see VcnGatewayConnectionConfig
- *
- * @hide
*/
public abstract class VcnControlPlaneConfig {
/** @hide */
diff --git a/core/java/android/net/vcn/VcnControlPlaneIkeConfig.java b/core/java/android/net/vcn/VcnControlPlaneIkeConfig.java
index 2f6e1f63b960..de086f63b14d 100644
--- a/core/java/android/net/vcn/VcnControlPlaneIkeConfig.java
+++ b/core/java/android/net/vcn/VcnControlPlaneIkeConfig.java
@@ -34,8 +34,6 @@ import java.util.Objects;
* configuration, authentication and authorization parameters.
*
* @see VcnControlPlaneConfig
- *
- * @hide
*/
public final class VcnControlPlaneIkeConfig extends VcnControlPlaneConfig {
private static final String TAG = VcnControlPlaneIkeConfig.class.getSimpleName();
diff --git a/core/java/android/net/vcn/VcnGatewayConnectionConfig.java b/core/java/android/net/vcn/VcnGatewayConnectionConfig.java
index 94dff9159bd9..9f83b21f0d0c 100644
--- a/core/java/android/net/vcn/VcnGatewayConnectionConfig.java
+++ b/core/java/android/net/vcn/VcnGatewayConnectionConfig.java
@@ -420,7 +420,6 @@ public final class VcnGatewayConnectionConfig {
*
* @param ctrlPlaneConfig the control plane configuration
* @see VcnControlPlaneConfig
- * @hide
*/
public Builder(@NonNull VcnControlPlaneConfig ctrlPlaneConfig) {
Objects.requireNonNull(ctrlPlaneConfig, "ctrlPlaneConfig was null");
@@ -428,13 +427,6 @@ public final class VcnGatewayConnectionConfig {
mCtrlPlaneConfig = ctrlPlaneConfig;
}
- /** Construct a Builder object. */
- // TODO: Remove this constructor when #Builder(ctrlPlaneConfig) is exposed as public API.
- // This constructor is created to avoid changing API shape in this CL
- public Builder() {
- mCtrlPlaneConfig = null;
- }
-
/**
* Add a capability that this VCN Gateway Connection will support.
*
diff --git a/core/java/android/os/Trace.java b/core/java/android/os/Trace.java
index 9c9e4995d673..c8cbc517b226 100644
--- a/core/java/android/os/Trace.java
+++ b/core/java/android/os/Trace.java
@@ -168,8 +168,10 @@ public final class Trace {
}
/**
- * Set whether application tracing is allowed for this process. This is intended to be set
- * once at application start-up time based on whether the application is debuggable.
+ * From Android S, this is no-op.
+ *
+ * Before, set whether application tracing is allowed for this process. This is intended to be
+ * set once at application start-up time based on whether the application is debuggable.
*
* @hide
*/
diff --git a/core/java/android/uwb/OWNERS b/core/java/android/uwb/OWNERS
index ea41c3984dfd..17936ae7bb73 100644
--- a/core/java/android/uwb/OWNERS
+++ b/core/java/android/uwb/OWNERS
@@ -1,5 +1,6 @@
bstack@google.com
eliptus@google.com
jsolnit@google.com
+matbev@google.com
siyuanh@google.com
zachoverflow@google.com
diff --git a/core/java/android/uwb/TEST_MAPPING b/core/java/android/uwb/TEST_MAPPING
index 9e50bd64d089..08ed2c7b71d9 100644
--- a/core/java/android/uwb/TEST_MAPPING
+++ b/core/java/android/uwb/TEST_MAPPING
@@ -2,6 +2,9 @@
"presubmit": [
{
"name": "UwbManagerTests"
+ },
+ {
+ "name": "CtsUwbTestCases"
}
]
-} \ No newline at end of file
+}
diff --git a/core/jni/android_os_Trace.cpp b/core/jni/android_os_Trace.cpp
index 0f7611a8ead1..f67007cda209 100644
--- a/core/jni/android_os_Trace.cpp
+++ b/core/jni/android_os_Trace.cpp
@@ -83,7 +83,7 @@ static void android_os_Trace_nativeAsyncTraceEnd(JNIEnv* env, jclass,
}
static void android_os_Trace_nativeSetAppTracingAllowed(JNIEnv*, jclass, jboolean allowed) {
- atrace_set_debuggable(allowed);
+ atrace_update_tags();
}
static void android_os_Trace_nativeSetTracingEnabled(JNIEnv*, jclass, jboolean enabled) {
diff --git a/core/tests/overlaytests/device/AndroidTest.xml b/core/tests/overlaytests/device/AndroidTest.xml
index ebbdda559ed2..2d7d9b450c8c 100644
--- a/core/tests/overlaytests/device/AndroidTest.xml
+++ b/core/tests/overlaytests/device/AndroidTest.xml
@@ -19,17 +19,13 @@
<option name="test-suite-tag" value="apct" />
<option name="test-suite-tag" value="apct-instrumentation" />
+ <target_preparer class="com.android.tradefed.targetprep.RootTargetPreparer" />
<target_preparer class="com.android.compatibility.common.tradefed.targetprep.FilePusher">
<option name="cleanup" value="true" />
<option name="remount-system" value="true" />
<option name="push" value="OverlayDeviceTests.apk->/system/app/OverlayDeviceTests.apk" />
</target_preparer>
-
- <!-- Reboot to have the test APK scanned by PM and reboot after to remove the test APK. -->
- <target_preparer class="com.android.tradefed.targetprep.RebootTargetPreparer">
- <option name="pre-reboot" value="true" />
- <option name="post-reboot" value="true" />
- </target_preparer>
+ <target_preparer class="com.android.tradefed.targetprep.RebootTargetPreparer" />
<target_preparer class="com.android.tradefed.targetprep.TestAppInstallSetup">
<option name="cleanup-apks" value="true" />
diff --git a/core/tests/uwbtests/src/android/uwb/AngleMeasurementTest.java b/core/tests/uwbtests/src/android/uwb/AngleMeasurementTest.java
deleted file mode 100644
index 7769c28202f2..000000000000
--- a/core/tests/uwbtests/src/android/uwb/AngleMeasurementTest.java
+++ /dev/null
@@ -1,85 +0,0 @@
-/*
- * 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.uwb;
-
-import static org.junit.Assert.assertEquals;
-import static org.junit.Assert.fail;
-
-import android.os.Parcel;
-
-import androidx.test.ext.junit.runners.AndroidJUnit4;
-import androidx.test.filters.SmallTest;
-
-import org.junit.Test;
-import org.junit.runner.RunWith;
-
-/**
- * Test of {@link AngleMeasurement}.
- */
-@SmallTest
-@RunWith(AndroidJUnit4.class)
-public class AngleMeasurementTest {
- private static final double EPSILON = 0.00000000001;
-
- @Test
- public void testBuilder() {
- double radians = 0.1234;
- double errorRadians = 0.5678;
- double confidence = 0.5;
-
- AngleMeasurement.Builder builder = new AngleMeasurement.Builder();
- tryBuild(builder, false);
-
- builder.setRadians(radians);
- tryBuild(builder, false);
-
- builder.setErrorRadians(errorRadians);
- tryBuild(builder, false);
-
- builder.setConfidenceLevel(confidence);
- AngleMeasurement measurement = tryBuild(builder, true);
-
- assertEquals(measurement.getRadians(), radians, 0);
- assertEquals(measurement.getErrorRadians(), errorRadians, 0);
- assertEquals(measurement.getConfidenceLevel(), confidence, 0);
- }
-
- private AngleMeasurement tryBuild(AngleMeasurement.Builder builder, boolean expectSuccess) {
- AngleMeasurement measurement = null;
- try {
- measurement = builder.build();
- if (!expectSuccess) {
- fail("Expected AngleMeasurement.Builder.build() to fail, but it succeeded");
- }
- } catch (IllegalStateException e) {
- if (expectSuccess) {
- fail("Expected AngleMeasurement.Builder.build() to succeed, but it failed");
- }
- }
- return measurement;
- }
-
- @Test
- public void testParcel() {
- Parcel parcel = Parcel.obtain();
- AngleMeasurement measurement = UwbTestUtils.getAngleMeasurement();
- measurement.writeToParcel(parcel, 0);
- parcel.setDataPosition(0);
- AngleMeasurement fromParcel = AngleMeasurement.CREATOR.createFromParcel(parcel);
- assertEquals(measurement, fromParcel);
- }
-}
diff --git a/core/tests/uwbtests/src/android/uwb/AngleOfArrivalMeasurementTest.java b/core/tests/uwbtests/src/android/uwb/AngleOfArrivalMeasurementTest.java
deleted file mode 100644
index 9394dec7f46f..000000000000
--- a/core/tests/uwbtests/src/android/uwb/AngleOfArrivalMeasurementTest.java
+++ /dev/null
@@ -1,89 +0,0 @@
-/*
- * 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.uwb;
-
-import static org.junit.Assert.assertEquals;
-import static org.junit.Assert.fail;
-
-import android.os.Parcel;
-
-import androidx.test.ext.junit.runners.AndroidJUnit4;
-import androidx.test.filters.SmallTest;
-
-import org.junit.Test;
-import org.junit.runner.RunWith;
-
-/**
- * Test of {@link AngleOfArrivalMeasurement}.
- */
-@SmallTest
-@RunWith(AndroidJUnit4.class)
-public class AngleOfArrivalMeasurementTest {
-
- @Test
- public void testBuilder() {
- AngleMeasurement azimuth = UwbTestUtils.getAngleMeasurement();
- AngleMeasurement altitude = UwbTestUtils.getAngleMeasurement();
-
- AngleOfArrivalMeasurement.Builder builder = new AngleOfArrivalMeasurement.Builder();
- tryBuild(builder, false);
-
- builder.setAltitude(altitude);
- tryBuild(builder, false);
-
- builder.setAzimuth(azimuth);
- AngleOfArrivalMeasurement measurement = tryBuild(builder, true);
-
- assertEquals(azimuth, measurement.getAzimuth());
- assertEquals(altitude, measurement.getAltitude());
- }
-
- private AngleMeasurement getAngleMeasurement(double radian, double error, double confidence) {
- return new AngleMeasurement.Builder()
- .setRadians(radian)
- .setErrorRadians(error)
- .setConfidenceLevel(confidence)
- .build();
- }
-
- private AngleOfArrivalMeasurement tryBuild(AngleOfArrivalMeasurement.Builder builder,
- boolean expectSuccess) {
- AngleOfArrivalMeasurement measurement = null;
- try {
- measurement = builder.build();
- if (!expectSuccess) {
- fail("Expected AngleOfArrivalMeasurement.Builder.build() to fail");
- }
- } catch (IllegalStateException e) {
- if (expectSuccess) {
- fail("Expected AngleOfArrivalMeasurement.Builder.build() to succeed");
- }
- }
- return measurement;
- }
-
- @Test
- public void testParcel() {
- Parcel parcel = Parcel.obtain();
- AngleOfArrivalMeasurement measurement = UwbTestUtils.getAngleOfArrivalMeasurement();
- measurement.writeToParcel(parcel, 0);
- parcel.setDataPosition(0);
- AngleOfArrivalMeasurement fromParcel =
- AngleOfArrivalMeasurement.CREATOR.createFromParcel(parcel);
- assertEquals(measurement, fromParcel);
- }
-}
diff --git a/core/tests/uwbtests/src/android/uwb/DistanceMeasurementTest.java b/core/tests/uwbtests/src/android/uwb/DistanceMeasurementTest.java
deleted file mode 100644
index 439c884723be..000000000000
--- a/core/tests/uwbtests/src/android/uwb/DistanceMeasurementTest.java
+++ /dev/null
@@ -1,87 +0,0 @@
-/*
- * 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.uwb;
-
-import static org.junit.Assert.assertEquals;
-import static org.junit.Assert.fail;
-
-import android.os.Parcel;
-
-import androidx.test.ext.junit.runners.AndroidJUnit4;
-import androidx.test.filters.SmallTest;
-
-import org.junit.Test;
-import org.junit.runner.RunWith;
-
-/**
- * Test of {@link DistanceMeasurement}.
- */
-@SmallTest
-@RunWith(AndroidJUnit4.class)
-public class DistanceMeasurementTest {
- private static final double EPSILON = 0.00000000001;
-
- @Test
- public void testBuilder() {
- double meters = 0.12;
- double error = 0.54;
- double confidence = 0.99;
-
- DistanceMeasurement.Builder builder = new DistanceMeasurement.Builder();
- tryBuild(builder, false);
-
- builder.setMeters(meters);
- tryBuild(builder, false);
-
- builder.setErrorMeters(error);
- tryBuild(builder, false);
-
- builder.setConfidenceLevel(confidence);
- DistanceMeasurement measurement = tryBuild(builder, true);
-
- assertEquals(meters, measurement.getMeters(), 0);
- assertEquals(error, measurement.getErrorMeters(), 0);
- assertEquals(confidence, measurement.getConfidenceLevel(), 0);
- }
-
- private DistanceMeasurement tryBuild(DistanceMeasurement.Builder builder,
- boolean expectSuccess) {
- DistanceMeasurement measurement = null;
- try {
- measurement = builder.build();
- if (!expectSuccess) {
- fail("Expected DistanceMeasurement.Builder.build() to fail");
- }
- } catch (IllegalStateException e) {
- if (expectSuccess) {
- fail("Expected DistanceMeasurement.Builder.build() to succeed");
- }
- }
- return measurement;
- }
-
- @Test
- public void testParcel() {
- Parcel parcel = Parcel.obtain();
- DistanceMeasurement measurement = UwbTestUtils.getDistanceMeasurement();
- measurement.writeToParcel(parcel, 0);
- parcel.setDataPosition(0);
- DistanceMeasurement fromParcel =
- DistanceMeasurement.CREATOR.createFromParcel(parcel);
- assertEquals(measurement, fromParcel);
- }
-}
diff --git a/core/tests/uwbtests/src/android/uwb/RangingMeasurementTest.java b/core/tests/uwbtests/src/android/uwb/RangingMeasurementTest.java
deleted file mode 100644
index edd4d08992ba..000000000000
--- a/core/tests/uwbtests/src/android/uwb/RangingMeasurementTest.java
+++ /dev/null
@@ -1,95 +0,0 @@
-/*
- * 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.uwb;
-
-import static org.junit.Assert.assertEquals;
-import static org.junit.Assert.fail;
-
-import android.os.Parcel;
-import android.os.SystemClock;
-
-import androidx.test.ext.junit.runners.AndroidJUnit4;
-import androidx.test.filters.SmallTest;
-
-import org.junit.Test;
-import org.junit.runner.RunWith;
-
-/**
- * Test of {@link RangingMeasurement}.
- */
-@SmallTest
-@RunWith(AndroidJUnit4.class)
-public class RangingMeasurementTest {
-
- @Test
- public void testBuilder() {
- int status = RangingMeasurement.RANGING_STATUS_SUCCESS;
- UwbAddress address = UwbTestUtils.getUwbAddress(false);
- long time = SystemClock.elapsedRealtimeNanos();
- AngleOfArrivalMeasurement angleMeasurement = UwbTestUtils.getAngleOfArrivalMeasurement();
- DistanceMeasurement distanceMeasurement = UwbTestUtils.getDistanceMeasurement();
-
- RangingMeasurement.Builder builder = new RangingMeasurement.Builder();
-
- builder.setStatus(status);
- tryBuild(builder, false);
-
- builder.setElapsedRealtimeNanos(time);
- tryBuild(builder, false);
-
- builder.setAngleOfArrivalMeasurement(angleMeasurement);
- tryBuild(builder, false);
-
- builder.setDistanceMeasurement(distanceMeasurement);
- tryBuild(builder, false);
-
- builder.setRemoteDeviceAddress(address);
- RangingMeasurement measurement = tryBuild(builder, true);
-
- assertEquals(status, measurement.getStatus());
- assertEquals(address, measurement.getRemoteDeviceAddress());
- assertEquals(time, measurement.getElapsedRealtimeNanos());
- assertEquals(angleMeasurement, measurement.getAngleOfArrivalMeasurement());
- assertEquals(distanceMeasurement, measurement.getDistanceMeasurement());
- }
-
- private RangingMeasurement tryBuild(RangingMeasurement.Builder builder,
- boolean expectSuccess) {
- RangingMeasurement measurement = null;
- try {
- measurement = builder.build();
- if (!expectSuccess) {
- fail("Expected RangingMeasurement.Builder.build() to fail");
- }
- } catch (IllegalStateException e) {
- if (expectSuccess) {
- fail("Expected DistanceMeasurement.Builder.build() to succeed");
- }
- }
- return measurement;
- }
-
- @Test
- public void testParcel() {
- Parcel parcel = Parcel.obtain();
- RangingMeasurement measurement = UwbTestUtils.getRangingMeasurement();
- measurement.writeToParcel(parcel, 0);
- parcel.setDataPosition(0);
- RangingMeasurement fromParcel = RangingMeasurement.CREATOR.createFromParcel(parcel);
- assertEquals(measurement, fromParcel);
- }
-}
diff --git a/core/tests/uwbtests/src/android/uwb/RangingReportTest.java b/core/tests/uwbtests/src/android/uwb/RangingReportTest.java
deleted file mode 100644
index 64c48ba4b6f4..000000000000
--- a/core/tests/uwbtests/src/android/uwb/RangingReportTest.java
+++ /dev/null
@@ -1,90 +0,0 @@
-/*
- * 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.uwb;
-
-import static org.junit.Assert.assertEquals;
-import static org.junit.Assert.fail;
-
-import android.os.Parcel;
-
-import androidx.test.ext.junit.runners.AndroidJUnit4;
-import androidx.test.filters.SmallTest;
-
-import org.junit.Test;
-import org.junit.runner.RunWith;
-
-import java.util.List;
-
-/**
- * Test of {@link RangingReport}.
- */
-@SmallTest
-@RunWith(AndroidJUnit4.class)
-public class RangingReportTest {
-
- @Test
- public void testBuilder() {
- List<RangingMeasurement> measurements = UwbTestUtils.getRangingMeasurements(5);
-
- RangingReport.Builder builder = new RangingReport.Builder();
- builder.addMeasurements(measurements);
- RangingReport report = tryBuild(builder, true);
- verifyMeasurementsEqual(measurements, report.getMeasurements());
-
-
- builder = new RangingReport.Builder();
- for (RangingMeasurement measurement : measurements) {
- builder.addMeasurement(measurement);
- }
- report = tryBuild(builder, true);
- verifyMeasurementsEqual(measurements, report.getMeasurements());
- }
-
- private void verifyMeasurementsEqual(List<RangingMeasurement> expected,
- List<RangingMeasurement> actual) {
- assertEquals(expected.size(), actual.size());
- for (int i = 0; i < expected.size(); i++) {
- assertEquals(expected.get(i), actual.get(i));
- }
- }
-
- private RangingReport tryBuild(RangingReport.Builder builder,
- boolean expectSuccess) {
- RangingReport report = null;
- try {
- report = builder.build();
- if (!expectSuccess) {
- fail("Expected RangingReport.Builder.build() to fail");
- }
- } catch (IllegalStateException e) {
- if (expectSuccess) {
- fail("Expected RangingReport.Builder.build() to succeed");
- }
- }
- return report;
- }
-
- @Test
- public void testParcel() {
- Parcel parcel = Parcel.obtain();
- RangingReport report = UwbTestUtils.getRangingReports(5);
- report.writeToParcel(parcel, 0);
- parcel.setDataPosition(0);
- RangingReport fromParcel = RangingReport.CREATOR.createFromParcel(parcel);
- assertEquals(report, fromParcel);
- }
-}
diff --git a/core/tests/uwbtests/src/android/uwb/RangingSessionTest.java b/core/tests/uwbtests/src/android/uwb/RangingSessionTest.java
deleted file mode 100644
index e5eea26f5d11..000000000000
--- a/core/tests/uwbtests/src/android/uwb/RangingSessionTest.java
+++ /dev/null
@@ -1,378 +0,0 @@
-/*
- * Copyright (C) 2020 The Android Open Source Project
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-package android.uwb;
-
-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.any;
-import static org.mockito.ArgumentMatchers.anyInt;
-import static org.mockito.ArgumentMatchers.eq;
-import static org.mockito.Mockito.doAnswer;
-import static org.mockito.Mockito.mock;
-import static org.mockito.Mockito.times;
-import static org.mockito.Mockito.verify;
-
-import android.os.PersistableBundle;
-import android.os.RemoteException;
-
-import androidx.test.ext.junit.runners.AndroidJUnit4;
-import androidx.test.filters.SmallTest;
-
-import org.junit.Test;
-import org.junit.runner.RunWith;
-import org.mockito.invocation.InvocationOnMock;
-import org.mockito.stubbing.Answer;
-
-import java.util.concurrent.Executor;
-
-/**
- * Test of {@link RangingSession}.
- */
-@SmallTest
-@RunWith(AndroidJUnit4.class)
-public class RangingSessionTest {
- private static final Executor EXECUTOR = UwbTestUtils.getExecutor();
- private static final PersistableBundle PARAMS = new PersistableBundle();
- private static final @RangingSession.Callback.Reason int REASON =
- RangingSession.Callback.REASON_GENERIC_ERROR;
-
- @Test
- public void testOnRangingOpened_OnOpenSuccessCalled() {
- SessionHandle handle = new SessionHandle(123);
- RangingSession.Callback callback = mock(RangingSession.Callback.class);
- IUwbAdapter adapter = mock(IUwbAdapter.class);
- RangingSession session = new RangingSession(EXECUTOR, callback, adapter, handle);
- verifyOpenState(session, false);
-
- session.onRangingOpened();
- verifyOpenState(session, true);
-
- // Verify that the onOpenSuccess callback was invoked
- verify(callback, times(1)).onOpened(eq(session));
- verify(callback, times(0)).onClosed(anyInt(), any());
- }
-
- @Test
- public void testOnRangingOpened_CannotOpenClosedSession() {
- SessionHandle handle = new SessionHandle(123);
- RangingSession.Callback callback = mock(RangingSession.Callback.class);
- IUwbAdapter adapter = mock(IUwbAdapter.class);
- RangingSession session = new RangingSession(EXECUTOR, callback, adapter, handle);
-
- session.onRangingOpened();
- verifyOpenState(session, true);
- verify(callback, times(1)).onOpened(eq(session));
- verify(callback, times(0)).onClosed(anyInt(), any());
-
- session.onRangingClosed(REASON, PARAMS);
- verifyOpenState(session, false);
- verify(callback, times(1)).onOpened(eq(session));
- verify(callback, times(1)).onClosed(anyInt(), any());
-
- // Now invoke the ranging started callback and ensure the session remains closed
- session.onRangingOpened();
- verifyOpenState(session, false);
- verify(callback, times(1)).onOpened(eq(session));
- verify(callback, times(1)).onClosed(anyInt(), any());
- }
-
- @Test
- public void testOnRangingClosed_OnClosedCalledWhenSessionNotOpen() {
- SessionHandle handle = new SessionHandle(123);
- RangingSession.Callback callback = mock(RangingSession.Callback.class);
- IUwbAdapter adapter = mock(IUwbAdapter.class);
- RangingSession session = new RangingSession(EXECUTOR, callback, adapter, handle);
- verifyOpenState(session, false);
-
- session.onRangingClosed(REASON, PARAMS);
- verifyOpenState(session, false);
-
- // Verify that the onOpenSuccess callback was invoked
- verify(callback, times(0)).onOpened(eq(session));
- verify(callback, times(1)).onClosed(anyInt(), any());
- }
-
- @Test
- public void testOnRangingClosed_OnClosedCalled() {
- SessionHandle handle = new SessionHandle(123);
- RangingSession.Callback callback = mock(RangingSession.Callback.class);
- IUwbAdapter adapter = mock(IUwbAdapter.class);
- RangingSession session = new RangingSession(EXECUTOR, callback, adapter, handle);
- session.onRangingStarted(PARAMS);
- session.onRangingClosed(REASON, PARAMS);
- verify(callback, times(1)).onClosed(anyInt(), any());
-
- verifyOpenState(session, false);
- session.onRangingClosed(REASON, PARAMS);
- verify(callback, times(2)).onClosed(anyInt(), any());
- }
-
- @Test
- public void testOnRangingResult_OnReportReceivedCalled() {
- SessionHandle handle = new SessionHandle(123);
- RangingSession.Callback callback = mock(RangingSession.Callback.class);
- IUwbAdapter adapter = mock(IUwbAdapter.class);
- RangingSession session = new RangingSession(EXECUTOR, callback, adapter, handle);
- verifyOpenState(session, false);
-
- session.onRangingStarted(PARAMS);
- verifyOpenState(session, true);
-
- RangingReport report = UwbTestUtils.getRangingReports(1);
- session.onRangingResult(report);
- verify(callback, times(1)).onReportReceived(eq(report));
- }
-
- @Test
- public void testStart_CannotStartIfAlreadyStarted() throws RemoteException {
- SessionHandle handle = new SessionHandle(123);
- RangingSession.Callback callback = mock(RangingSession.Callback.class);
- IUwbAdapter adapter = mock(IUwbAdapter.class);
- RangingSession session = new RangingSession(EXECUTOR, callback, adapter, handle);
- doAnswer(new StartAnswer(session)).when(adapter).startRanging(any(), any());
- session.onRangingOpened();
-
- session.start(PARAMS);
- verify(callback, times(1)).onStarted(any());
-
- // Calling start again should throw an illegal state
- verifyThrowIllegalState(() -> session.start(PARAMS));
- verify(callback, times(1)).onStarted(any());
- }
-
- @Test
- public void testStop_CannotStopIfAlreadyStopped() throws RemoteException {
- SessionHandle handle = new SessionHandle(123);
- RangingSession.Callback callback = mock(RangingSession.Callback.class);
- IUwbAdapter adapter = mock(IUwbAdapter.class);
- RangingSession session = new RangingSession(EXECUTOR, callback, adapter, handle);
- doAnswer(new StartAnswer(session)).when(adapter).startRanging(any(), any());
- doAnswer(new StopAnswer(session)).when(adapter).stopRanging(any());
- session.onRangingOpened();
- session.start(PARAMS);
-
- verifyNoThrowIllegalState(session::stop);
- verify(callback, times(1)).onStopped();
-
- // Calling stop again should throw an illegal state
- verifyThrowIllegalState(session::stop);
- verify(callback, times(1)).onStopped();
- }
-
- @Test
- public void testReconfigure_OnlyWhenOpened() throws RemoteException {
- SessionHandle handle = new SessionHandle(123);
- RangingSession.Callback callback = mock(RangingSession.Callback.class);
- IUwbAdapter adapter = mock(IUwbAdapter.class);
- RangingSession session = new RangingSession(EXECUTOR, callback, adapter, handle);
- doAnswer(new StartAnswer(session)).when(adapter).startRanging(any(), any());
- doAnswer(new ReconfigureAnswer(session)).when(adapter).reconfigureRanging(any(), any());
-
- verifyThrowIllegalState(() -> session.reconfigure(PARAMS));
- verify(callback, times(0)).onReconfigured(any());
- verifyOpenState(session, false);
-
- session.onRangingOpened();
- verifyNoThrowIllegalState(() -> session.reconfigure(PARAMS));
- verify(callback, times(1)).onReconfigured(any());
- verifyOpenState(session, true);
-
- session.onRangingStarted(PARAMS);
- verifyNoThrowIllegalState(() -> session.reconfigure(PARAMS));
- verify(callback, times(2)).onReconfigured(any());
- verifyOpenState(session, true);
-
- session.onRangingStopped();
- verifyNoThrowIllegalState(() -> session.reconfigure(PARAMS));
- verify(callback, times(3)).onReconfigured(any());
- verifyOpenState(session, true);
-
-
- session.onRangingClosed(REASON, PARAMS);
- verifyThrowIllegalState(() -> session.reconfigure(PARAMS));
- verify(callback, times(3)).onReconfigured(any());
- verifyOpenState(session, false);
- }
-
- @Test
- public void testClose_NoCallbackUntilInvoked() throws RemoteException {
- SessionHandle handle = new SessionHandle(123);
- RangingSession.Callback callback = mock(RangingSession.Callback.class);
- IUwbAdapter adapter = mock(IUwbAdapter.class);
- RangingSession session = new RangingSession(EXECUTOR, callback, adapter, handle);
- session.onRangingOpened();
-
- // Calling close multiple times should invoke closeRanging until the session receives
- // the onClosed callback.
- int totalCallsBeforeOnRangingClosed = 3;
- for (int i = 1; i <= totalCallsBeforeOnRangingClosed; i++) {
- session.close();
- verifyOpenState(session, true);
- verify(adapter, times(i)).closeRanging(handle);
- verify(callback, times(0)).onClosed(anyInt(), any());
- }
-
- // After onClosed is invoked, then the adapter should no longer be called for each call to
- // the session's close.
- final int totalCallsAfterOnRangingClosed = 2;
- for (int i = 1; i <= totalCallsAfterOnRangingClosed; i++) {
- session.onRangingClosed(REASON, PARAMS);
- verifyOpenState(session, false);
- verify(adapter, times(totalCallsBeforeOnRangingClosed)).closeRanging(handle);
- verify(callback, times(i)).onClosed(anyInt(), any());
- }
- }
-
- @Test
- public void testClose_OnClosedCalled() throws RemoteException {
- SessionHandle handle = new SessionHandle(123);
- RangingSession.Callback callback = mock(RangingSession.Callback.class);
- IUwbAdapter adapter = mock(IUwbAdapter.class);
- RangingSession session = new RangingSession(EXECUTOR, callback, adapter, handle);
- doAnswer(new CloseAnswer(session)).when(adapter).closeRanging(any());
- session.onRangingOpened();
-
- session.close();
- verify(callback, times(1)).onClosed(anyInt(), any());
- }
-
- @Test
- public void testClose_CannotInteractFurther() throws RemoteException {
- SessionHandle handle = new SessionHandle(123);
- RangingSession.Callback callback = mock(RangingSession.Callback.class);
- IUwbAdapter adapter = mock(IUwbAdapter.class);
- RangingSession session = new RangingSession(EXECUTOR, callback, adapter, handle);
- doAnswer(new CloseAnswer(session)).when(adapter).closeRanging(any());
- session.close();
-
- verifyThrowIllegalState(() -> session.start(PARAMS));
- verifyThrowIllegalState(() -> session.reconfigure(PARAMS));
- verifyThrowIllegalState(() -> session.stop());
- verifyNoThrowIllegalState(() -> session.close());
- }
-
- @Test
- public void testOnRangingResult_OnReportReceivedCalledWhenOpen() {
- SessionHandle handle = new SessionHandle(123);
- RangingSession.Callback callback = mock(RangingSession.Callback.class);
- IUwbAdapter adapter = mock(IUwbAdapter.class);
- RangingSession session = new RangingSession(EXECUTOR, callback, adapter, handle);
-
- assertFalse(session.isOpen());
- session.onRangingStarted(PARAMS);
- assertTrue(session.isOpen());
-
- // Verify that the onReportReceived callback was invoked
- RangingReport report = UwbTestUtils.getRangingReports(1);
- session.onRangingResult(report);
- verify(callback, times(1)).onReportReceived(report);
- }
-
- @Test
- public void testOnRangingResult_OnReportReceivedNotCalledWhenNotOpen() {
- SessionHandle handle = new SessionHandle(123);
- RangingSession.Callback callback = mock(RangingSession.Callback.class);
- IUwbAdapter adapter = mock(IUwbAdapter.class);
- RangingSession session = new RangingSession(EXECUTOR, callback, adapter, handle);
-
- assertFalse(session.isOpen());
-
- // Verify that the onReportReceived callback was invoked
- RangingReport report = UwbTestUtils.getRangingReports(1);
- session.onRangingResult(report);
- verify(callback, times(0)).onReportReceived(report);
- }
-
- private void verifyOpenState(RangingSession session, boolean expected) {
- assertEquals(expected, session.isOpen());
- }
-
- private void verifyThrowIllegalState(Runnable runnable) {
- try {
- runnable.run();
- fail();
- } catch (IllegalStateException e) {
- // Pass
- }
- }
-
- private void verifyNoThrowIllegalState(Runnable runnable) {
- try {
- runnable.run();
- } catch (IllegalStateException e) {
- fail();
- }
- }
-
- abstract class AdapterAnswer implements Answer {
- protected RangingSession mSession;
-
- protected AdapterAnswer(RangingSession session) {
- mSession = session;
- }
- }
-
- class StartAnswer extends AdapterAnswer {
- StartAnswer(RangingSession session) {
- super(session);
- }
-
- @Override
- public Object answer(InvocationOnMock invocation) {
- mSession.onRangingStarted(PARAMS);
- return null;
- }
- }
-
- class ReconfigureAnswer extends AdapterAnswer {
- ReconfigureAnswer(RangingSession session) {
- super(session);
- }
-
- @Override
- public Object answer(InvocationOnMock invocation) {
- mSession.onRangingReconfigured(PARAMS);
- return null;
- }
- }
-
- class StopAnswer extends AdapterAnswer {
- StopAnswer(RangingSession session) {
- super(session);
- }
-
- @Override
- public Object answer(InvocationOnMock invocation) {
- mSession.onRangingStopped();
- return null;
- }
- }
-
- class CloseAnswer extends AdapterAnswer {
- CloseAnswer(RangingSession session) {
- super(session);
- }
-
- @Override
- public Object answer(InvocationOnMock invocation) {
- mSession.onRangingClosed(REASON, PARAMS);
- return null;
- }
- }
-}
diff --git a/core/tests/uwbtests/src/android/uwb/SessionHandleTest.java b/core/tests/uwbtests/src/android/uwb/SessionHandleTest.java
deleted file mode 100644
index 8b42ff7f62a7..000000000000
--- a/core/tests/uwbtests/src/android/uwb/SessionHandleTest.java
+++ /dev/null
@@ -1,52 +0,0 @@
-/*
- * 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.uwb;
-
-import static org.junit.Assert.assertEquals;
-
-import android.os.Parcel;
-
-import androidx.test.ext.junit.runners.AndroidJUnit4;
-import androidx.test.filters.SmallTest;
-
-import org.junit.Test;
-import org.junit.runner.RunWith;
-
-/**
- * Test of {@link SessionHandle}.
- */
-@SmallTest
-@RunWith(AndroidJUnit4.class)
-public class SessionHandleTest {
-
- @Test
- public void testBasic() {
- int handleId = 12;
- SessionHandle handle = new SessionHandle(handleId);
- assertEquals(handle.getId(), handleId);
- }
-
- @Test
- public void testParcel() {
- Parcel parcel = Parcel.obtain();
- SessionHandle handle = new SessionHandle(10);
- handle.writeToParcel(parcel, 0);
- parcel.setDataPosition(0);
- SessionHandle fromParcel = SessionHandle.CREATOR.createFromParcel(parcel);
- assertEquals(handle, fromParcel);
- }
-}
diff --git a/core/tests/uwbtests/src/android/uwb/UwbAddressTest.java b/core/tests/uwbtests/src/android/uwb/UwbAddressTest.java
deleted file mode 100644
index ccc88a9a5399..000000000000
--- a/core/tests/uwbtests/src/android/uwb/UwbAddressTest.java
+++ /dev/null
@@ -1,79 +0,0 @@
-/*
- * 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.uwb;
-
-import static org.junit.Assert.assertEquals;
-
-import android.os.Parcel;
-
-import androidx.test.ext.junit.runners.AndroidJUnit4;
-import androidx.test.filters.SmallTest;
-
-import org.junit.Test;
-import org.junit.runner.RunWith;
-
-/**
- * Test of {@link UwbAddress}.
- */
-@SmallTest
-@RunWith(AndroidJUnit4.class)
-public class UwbAddressTest {
-
- @Test
- public void testFromBytes_Short() {
- runFromBytes(UwbAddress.SHORT_ADDRESS_BYTE_LENGTH);
- }
-
- @Test
- public void testFromBytes_Extended() {
- runFromBytes(UwbAddress.EXTENDED_ADDRESS_BYTE_LENGTH);
- }
-
- private void runFromBytes(int len) {
- byte[] addressBytes = getByteArray(len);
- UwbAddress address = UwbAddress.fromBytes(addressBytes);
- assertEquals(address.size(), len);
- assertEquals(addressBytes, address.toBytes());
- }
-
- private byte[] getByteArray(int len) {
- byte[] res = new byte[len];
- for (int i = 0; i < len; i++) {
- res[i] = (byte) i;
- }
- return res;
- }
-
- @Test
- public void testParcel_Short() {
- runParcel(true);
- }
-
- @Test
- public void testParcel_Extended() {
- runParcel(false);
- }
-
- private void runParcel(boolean useShortAddress) {
- Parcel parcel = Parcel.obtain();
- UwbAddress address = UwbTestUtils.getUwbAddress(useShortAddress);
- address.writeToParcel(parcel, 0);
- parcel.setDataPosition(0);
- UwbAddress fromParcel = UwbAddress.CREATOR.createFromParcel(parcel);
- assertEquals(address, fromParcel);
- }
-}
diff --git a/core/tests/uwbtests/src/android/uwb/UwbManagerTest.java b/core/tests/uwbtests/src/android/uwb/UwbManagerTest.java
deleted file mode 100644
index 4983bed742fd..000000000000
--- a/core/tests/uwbtests/src/android/uwb/UwbManagerTest.java
+++ /dev/null
@@ -1,49 +0,0 @@
-/*
- * 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.uwb;
-
-import static org.junit.Assert.assertNotNull;
-import static org.junit.Assert.assertNull;
-
-import android.content.Context;
-
-import androidx.test.InstrumentationRegistry;
-import androidx.test.ext.junit.runners.AndroidJUnit4;
-import androidx.test.filters.SmallTest;
-
-import org.junit.Test;
-import org.junit.runner.RunWith;
-
-/**
- * Test of {@link UwbManager}.
- */
-@SmallTest
-@RunWith(AndroidJUnit4.class)
-public class UwbManagerTest {
-
- public final Context mContext = InstrumentationRegistry.getContext();
-
- @Test
- public void testServiceAvailable() {
- UwbManager manager = mContext.getSystemService(UwbManager.class);
- if (UwbTestUtils.isUwbSupported(mContext)) {
- assertNotNull(manager);
- } else {
- assertNull(manager);
- }
- }
-}
diff --git a/packages/Connectivity/framework/Android.bp b/packages/Connectivity/framework/Android.bp
index 3326ea9eddcb..ffca97143009 100644
--- a/packages/Connectivity/framework/Android.bp
+++ b/packages/Connectivity/framework/Android.bp
@@ -14,7 +14,6 @@
// limitations under the License.
//
-// TODO: use a java_library in the bootclasspath instead
package {
// See: http://go/android-license-faq
// A large-scale-change added 'default_applicable_licenses' to import
@@ -24,14 +23,38 @@ package {
default_applicable_licenses: ["frameworks_base_license"],
}
+// TODO: use a java_library in the bootclasspath instead
filegroup {
- name: "framework-connectivity-sources",
+ name: "framework-connectivity-internal-sources",
srcs: [
"src/**/*.java",
"src/**/*.aidl",
],
path: "src",
visibility: [
+ "//visibility:private",
+ ],
+}
+
+filegroup {
+ name: "framework-connectivity-aidl-export-sources",
+ srcs: [
+ "aidl-export/**/*.aidl",
+ ],
+ path: "aidl-export",
+ visibility: [
+ "//visibility:private",
+ ],
+}
+
+// TODO: use a java_library in the bootclasspath instead
+filegroup {
+ name: "framework-connectivity-sources",
+ srcs: [
+ ":framework-connectivity-internal-sources",
+ ":framework-connectivity-aidl-export-sources",
+ ],
+ visibility: [
"//frameworks/base",
"//packages/modules/Connectivity:__subpackages__",
],
diff --git a/packages/Connectivity/framework/src/android/net/CaptivePortalData.aidl b/packages/Connectivity/framework/aidl-export/android/net/CaptivePortalData.aidl
index 1d57ee759136..1d57ee759136 100644
--- a/packages/Connectivity/framework/src/android/net/CaptivePortalData.aidl
+++ b/packages/Connectivity/framework/aidl-export/android/net/CaptivePortalData.aidl
diff --git a/packages/Connectivity/framework/src/android/net/ConnectivityDiagnosticsManager.aidl b/packages/Connectivity/framework/aidl-export/android/net/ConnectivityDiagnosticsManager.aidl
index 82ba0ca113c5..82ba0ca113c5 100644
--- a/packages/Connectivity/framework/src/android/net/ConnectivityDiagnosticsManager.aidl
+++ b/packages/Connectivity/framework/aidl-export/android/net/ConnectivityDiagnosticsManager.aidl
diff --git a/packages/Connectivity/framework/src/android/net/DhcpInfo.aidl b/packages/Connectivity/framework/aidl-export/android/net/DhcpInfo.aidl
index 29cd21fe7652..29cd21fe7652 100644
--- a/packages/Connectivity/framework/src/android/net/DhcpInfo.aidl
+++ b/packages/Connectivity/framework/aidl-export/android/net/DhcpInfo.aidl
diff --git a/packages/Connectivity/framework/src/android/net/IpConfiguration.aidl b/packages/Connectivity/framework/aidl-export/android/net/IpConfiguration.aidl
index 7a30f0e79cad..7a30f0e79cad 100644
--- a/packages/Connectivity/framework/src/android/net/IpConfiguration.aidl
+++ b/packages/Connectivity/framework/aidl-export/android/net/IpConfiguration.aidl
diff --git a/packages/Connectivity/framework/src/android/net/IpPrefix.aidl b/packages/Connectivity/framework/aidl-export/android/net/IpPrefix.aidl
index 0d70f2a1ed2c..0d70f2a1ed2c 100644
--- a/packages/Connectivity/framework/src/android/net/IpPrefix.aidl
+++ b/packages/Connectivity/framework/aidl-export/android/net/IpPrefix.aidl
diff --git a/packages/Connectivity/framework/src/android/net/KeepalivePacketData.aidl b/packages/Connectivity/framework/aidl-export/android/net/KeepalivePacketData.aidl
index d456b53fd188..d456b53fd188 100644
--- a/packages/Connectivity/framework/src/android/net/KeepalivePacketData.aidl
+++ b/packages/Connectivity/framework/aidl-export/android/net/KeepalivePacketData.aidl
diff --git a/packages/Connectivity/framework/src/android/net/LinkAddress.aidl b/packages/Connectivity/framework/aidl-export/android/net/LinkAddress.aidl
index 9c804db08d61..9c804db08d61 100644
--- a/packages/Connectivity/framework/src/android/net/LinkAddress.aidl
+++ b/packages/Connectivity/framework/aidl-export/android/net/LinkAddress.aidl
diff --git a/packages/Connectivity/framework/src/android/net/LinkProperties.aidl b/packages/Connectivity/framework/aidl-export/android/net/LinkProperties.aidl
index a8b3c7b0392f..a8b3c7b0392f 100644
--- a/packages/Connectivity/framework/src/android/net/LinkProperties.aidl
+++ b/packages/Connectivity/framework/aidl-export/android/net/LinkProperties.aidl
diff --git a/packages/Connectivity/framework/src/android/net/MacAddress.aidl b/packages/Connectivity/framework/aidl-export/android/net/MacAddress.aidl
index 48a18a7ac821..48a18a7ac821 100644
--- a/packages/Connectivity/framework/src/android/net/MacAddress.aidl
+++ b/packages/Connectivity/framework/aidl-export/android/net/MacAddress.aidl
diff --git a/packages/Connectivity/framework/src/android/net/Network.aidl b/packages/Connectivity/framework/aidl-export/android/net/Network.aidl
index 05622025bf33..05622025bf33 100644
--- a/packages/Connectivity/framework/src/android/net/Network.aidl
+++ b/packages/Connectivity/framework/aidl-export/android/net/Network.aidl
diff --git a/packages/Connectivity/framework/src/android/net/NetworkAgentConfig.aidl b/packages/Connectivity/framework/aidl-export/android/net/NetworkAgentConfig.aidl
index cb70bdd31260..cb70bdd31260 100644
--- a/packages/Connectivity/framework/src/android/net/NetworkAgentConfig.aidl
+++ b/packages/Connectivity/framework/aidl-export/android/net/NetworkAgentConfig.aidl
diff --git a/packages/Connectivity/framework/src/android/net/NetworkCapabilities.aidl b/packages/Connectivity/framework/aidl-export/android/net/NetworkCapabilities.aidl
index 01d328605de4..01d328605de4 100644
--- a/packages/Connectivity/framework/src/android/net/NetworkCapabilities.aidl
+++ b/packages/Connectivity/framework/aidl-export/android/net/NetworkCapabilities.aidl
diff --git a/packages/Connectivity/framework/src/android/net/NetworkInfo.aidl b/packages/Connectivity/framework/aidl-export/android/net/NetworkInfo.aidl
index f50187302966..f50187302966 100644
--- a/packages/Connectivity/framework/src/android/net/NetworkInfo.aidl
+++ b/packages/Connectivity/framework/aidl-export/android/net/NetworkInfo.aidl
diff --git a/packages/Connectivity/framework/src/android/net/NetworkRequest.aidl b/packages/Connectivity/framework/aidl-export/android/net/NetworkRequest.aidl
index 508defc6b497..508defc6b497 100644
--- a/packages/Connectivity/framework/src/android/net/NetworkRequest.aidl
+++ b/packages/Connectivity/framework/aidl-export/android/net/NetworkRequest.aidl
diff --git a/packages/Connectivity/framework/src/android/net/ProxyInfo.aidl b/packages/Connectivity/framework/aidl-export/android/net/ProxyInfo.aidl
index a5d0c120e747..a5d0c120e747 100644
--- a/packages/Connectivity/framework/src/android/net/ProxyInfo.aidl
+++ b/packages/Connectivity/framework/aidl-export/android/net/ProxyInfo.aidl
diff --git a/packages/Connectivity/framework/src/android/net/RouteInfo.aidl b/packages/Connectivity/framework/aidl-export/android/net/RouteInfo.aidl
index 7af9fdaef342..7af9fdaef342 100644
--- a/packages/Connectivity/framework/src/android/net/RouteInfo.aidl
+++ b/packages/Connectivity/framework/aidl-export/android/net/RouteInfo.aidl
diff --git a/packages/Connectivity/framework/src/android/net/StaticIpConfiguration.aidl b/packages/Connectivity/framework/aidl-export/android/net/StaticIpConfiguration.aidl
index 8aac701fe7e1..8aac701fe7e1 100644
--- a/packages/Connectivity/framework/src/android/net/StaticIpConfiguration.aidl
+++ b/packages/Connectivity/framework/aidl-export/android/net/StaticIpConfiguration.aidl
diff --git a/packages/Connectivity/framework/src/android/net/TestNetworkInterface.aidl b/packages/Connectivity/framework/aidl-export/android/net/TestNetworkInterface.aidl
index e1f4f9f794eb..e1f4f9f794eb 100644
--- a/packages/Connectivity/framework/src/android/net/TestNetworkInterface.aidl
+++ b/packages/Connectivity/framework/aidl-export/android/net/TestNetworkInterface.aidl
diff --git a/packages/Connectivity/framework/src/android/net/apf/ApfCapabilities.aidl b/packages/Connectivity/framework/aidl-export/android/net/apf/ApfCapabilities.aidl
index 7c4d4c2da4bc..7c4d4c2da4bc 100644
--- a/packages/Connectivity/framework/src/android/net/apf/ApfCapabilities.aidl
+++ b/packages/Connectivity/framework/aidl-export/android/net/apf/ApfCapabilities.aidl
diff --git a/packages/Connectivity/framework/src/android/net/ConnectivityManager.java b/packages/Connectivity/framework/src/android/net/ConnectivityManager.java
index c7bb2a75dba0..d3414a404d7c 100644
--- a/packages/Connectivity/framework/src/android/net/ConnectivityManager.java
+++ b/packages/Connectivity/framework/src/android/net/ConnectivityManager.java
@@ -4606,7 +4606,7 @@ public class ConnectivityManager {
// Set HTTP proxy system properties to match network.
// TODO: Deprecate this static method and replace it with a non-static version.
try {
- Proxy.setHttpProxySystemProperty(getInstance().getDefaultProxy());
+ Proxy.setHttpProxyConfiguration(getInstance().getDefaultProxy());
} catch (SecurityException e) {
// The process doesn't have ACCESS_NETWORK_STATE, so we can't fetch the proxy.
Log.e(TAG, "Can't set proxy properties", e);
diff --git a/packages/Connectivity/framework/src/android/net/Proxy.java b/packages/Connectivity/framework/src/android/net/Proxy.java
index 9cd7ab2c3e40..77c8a4f4579b 100644
--- a/packages/Connectivity/framework/src/android/net/Proxy.java
+++ b/packages/Connectivity/framework/src/android/net/Proxy.java
@@ -16,8 +16,10 @@
package android.net;
+import android.annotation.Nullable;
import android.annotation.SdkConstant;
import android.annotation.SdkConstant.SdkConstantType;
+import android.annotation.SystemApi;
import android.compat.annotation.UnsupportedAppUsage;
import android.content.Context;
import android.os.Build;
@@ -185,7 +187,19 @@ public final class Proxy {
/** @hide */
@UnsupportedAppUsage(maxTargetSdk = Build.VERSION_CODES.R, trackingBug = 170729553)
- public static final void setHttpProxySystemProperty(ProxyInfo p) {
+ @Deprecated
+ public static void setHttpProxySystemProperty(ProxyInfo p) {
+ setHttpProxyConfiguration(p);
+ }
+
+ /**
+ * Set HTTP proxy configuration for the process to match the provided ProxyInfo.
+ *
+ * If the provided ProxyInfo is null, the proxy configuration will be cleared.
+ * @hide
+ */
+ @SystemApi(client = SystemApi.Client.MODULE_LIBRARIES)
+ public static void setHttpProxyConfiguration(@Nullable ProxyInfo p) {
String host = null;
String port = null;
String exclList = null;
@@ -196,11 +210,11 @@ public final class Proxy {
exclList = ProxyUtils.exclusionListAsString(p.getExclusionList());
pacFileUrl = p.getPacFileUrl();
}
- setHttpProxySystemProperty(host, port, exclList, pacFileUrl);
+ setHttpProxyConfiguration(host, port, exclList, pacFileUrl);
}
/** @hide */
- public static final void setHttpProxySystemProperty(String host, String port, String exclList,
+ public static void setHttpProxyConfiguration(String host, String port, String exclList,
Uri pacFileUrl) {
if (exclList != null) exclList = exclList.replace(",", "|");
if (false) Log.d(TAG, "setHttpProxySystemProperty :"+host+":"+port+" - "+exclList);
diff --git a/services/core/java/com/android/server/os/NativeTombstoneManager.java b/services/core/java/com/android/server/os/NativeTombstoneManager.java
index 9984bfae30fd..d95a7254efe1 100644
--- a/services/core/java/com/android/server/os/NativeTombstoneManager.java
+++ b/services/core/java/com/android/server/os/NativeTombstoneManager.java
@@ -42,6 +42,7 @@ import android.system.StructStat;
import android.util.Slog;
import android.util.SparseArray;
import android.util.proto.ProtoInputStream;
+import android.util.proto.ProtoParseException;
import com.android.internal.annotations.GuardedBy;
import com.android.server.BootReceiver;
@@ -434,7 +435,7 @@ public final class NativeTombstoneManager {
break;
}
}
- } catch (IOException ex) {
+ } catch (IOException | ProtoParseException ex) {
Slog.e(TAG, "Failed to parse tombstone", ex);
return Optional.empty();
}
diff --git a/tests/net/java/com/android/server/ConnectivityServiceTest.java b/tests/net/java/com/android/server/ConnectivityServiceTest.java
index 182897e37e0a..219cc35ae36a 100644
--- a/tests/net/java/com/android/server/ConnectivityServiceTest.java
+++ b/tests/net/java/com/android/server/ConnectivityServiceTest.java
@@ -2158,6 +2158,24 @@ public class ConnectivityServiceTest {
}
}
+ static void expectOnLost(TestNetworkAgentWrapper network, TestNetworkCallback ... callbacks) {
+ for (TestNetworkCallback c : callbacks) {
+ c.expectCallback(CallbackEntry.LOST, network);
+ }
+ }
+
+ static void expectAvailableCallbacksUnvalidatedWithSpecifier(TestNetworkAgentWrapper network,
+ NetworkSpecifier specifier, TestNetworkCallback ... callbacks) {
+ for (TestNetworkCallback c : callbacks) {
+ c.expectCallback(CallbackEntry.AVAILABLE, network);
+ c.expectCapabilitiesThat(network, (nc) ->
+ !nc.hasCapability(NET_CAPABILITY_VALIDATED)
+ && Objects.equals(specifier, nc.getNetworkSpecifier()));
+ c.expectCallback(CallbackEntry.LINK_PROPERTIES_CHANGED, network);
+ c.expectCallback(CallbackEntry.BLOCKED_STATUS, network);
+ }
+ }
+
@Test
public void testStateChangeNetworkCallbacks() throws Exception {
final TestNetworkCallback genericNetworkCallback = new TestNetworkCallback();
@@ -3521,11 +3539,9 @@ public class ConnectivityServiceTest {
/**
* Verify request matching behavior with network specifiers.
*
- * Note: this test is somewhat problematic since it involves removing capabilities from
- * agents - i.e. agents rejecting requests which they previously accepted. This is flagged
- * as a WTF bug in
- * {@link ConnectivityService#mixInCapabilities(NetworkAgentInfo, NetworkCapabilities)} but
- * does work.
+ * This test does not check updating the specifier on a live network because the specifier is
+ * immutable and this triggers a WTF in
+ * {@link ConnectivityService#mixInCapabilities(NetworkAgentInfo, NetworkCapabilities)}.
*/
@Test
public void testNetworkSpecifier() throws Exception {
@@ -3610,60 +3626,49 @@ public class ConnectivityServiceTest {
mWiFiNetworkAgent = new TestNetworkAgentWrapper(TRANSPORT_WIFI);
mWiFiNetworkAgent.connect(false);
- cEmpty1.expectAvailableCallbacksUnvalidated(mWiFiNetworkAgent);
- cEmpty2.expectAvailableCallbacksUnvalidated(mWiFiNetworkAgent);
- cEmpty3.expectAvailableCallbacksUnvalidated(mWiFiNetworkAgent);
- cEmpty4.expectAvailableCallbacksUnvalidated(mWiFiNetworkAgent);
+ expectAvailableCallbacksUnvalidatedWithSpecifier(mWiFiNetworkAgent, null /* specifier */,
+ cEmpty1, cEmpty2, cEmpty3, cEmpty4);
assertNoCallbacks(cFoo, cBar);
+ mWiFiNetworkAgent.disconnect();
+ expectOnLost(mWiFiNetworkAgent, cEmpty1, cEmpty2, cEmpty3, cEmpty4);
+
+ mWiFiNetworkAgent = new TestNetworkAgentWrapper(TRANSPORT_WIFI);
mWiFiNetworkAgent.setNetworkSpecifier(nsFoo);
- cFoo.expectAvailableCallbacksUnvalidated(mWiFiNetworkAgent);
- for (TestNetworkCallback c: emptyCallbacks) {
- c.expectCapabilitiesThat(mWiFiNetworkAgent,
- (caps) -> caps.getNetworkSpecifier().equals(nsFoo));
- }
- cFoo.expectCapabilitiesThat(mWiFiNetworkAgent,
- (caps) -> caps.getNetworkSpecifier().equals(nsFoo));
+ mWiFiNetworkAgent.connect(false);
+ expectAvailableCallbacksUnvalidatedWithSpecifier(mWiFiNetworkAgent, nsFoo,
+ cEmpty1, cEmpty2, cEmpty3, cEmpty4, cFoo);
+ cBar.assertNoCallback();
assertEquals(nsFoo,
mCm.getNetworkCapabilities(mWiFiNetworkAgent.getNetwork()).getNetworkSpecifier());
- cFoo.assertNoCallback();
+ assertNoCallbacks(cEmpty1, cEmpty2, cEmpty3, cEmpty4, cFoo);
+ mWiFiNetworkAgent.disconnect();
+ expectOnLost(mWiFiNetworkAgent, cEmpty1, cEmpty2, cEmpty3, cEmpty4, cFoo);
+
+ mWiFiNetworkAgent = new TestNetworkAgentWrapper(TRANSPORT_WIFI);
mWiFiNetworkAgent.setNetworkSpecifier(nsBar);
- cFoo.expectCallback(CallbackEntry.LOST, mWiFiNetworkAgent);
- cBar.expectAvailableCallbacksUnvalidated(mWiFiNetworkAgent);
- for (TestNetworkCallback c: emptyCallbacks) {
- c.expectCapabilitiesThat(mWiFiNetworkAgent,
- (caps) -> caps.getNetworkSpecifier().equals(nsBar));
- }
- cBar.expectCapabilitiesThat(mWiFiNetworkAgent,
- (caps) -> caps.getNetworkSpecifier().equals(nsBar));
+ mWiFiNetworkAgent.connect(false);
+ expectAvailableCallbacksUnvalidatedWithSpecifier(mWiFiNetworkAgent, nsBar,
+ cEmpty1, cEmpty2, cEmpty3, cEmpty4, cBar);
+ cFoo.assertNoCallback();
assertEquals(nsBar,
mCm.getNetworkCapabilities(mWiFiNetworkAgent.getNetwork()).getNetworkSpecifier());
- cBar.assertNoCallback();
+ mWiFiNetworkAgent.disconnect();
+ expectOnLost(mWiFiNetworkAgent, cEmpty1, cEmpty2, cEmpty3, cEmpty4, cBar);
+ cFoo.assertNoCallback();
+
+ mWiFiNetworkAgent = new TestNetworkAgentWrapper(TRANSPORT_WIFI);
mWiFiNetworkAgent.setNetworkSpecifier(new ConfidentialMatchAllNetworkSpecifier());
- cFoo.expectAvailableCallbacksUnvalidated(mWiFiNetworkAgent);
- for (TestNetworkCallback c : emptyCallbacks) {
- c.expectCapabilitiesThat(mWiFiNetworkAgent,
- (caps) -> caps.getNetworkSpecifier() == null);
- }
- cFoo.expectCapabilitiesThat(mWiFiNetworkAgent,
- (caps) -> caps.getNetworkSpecifier() == null);
- cBar.expectCapabilitiesThat(mWiFiNetworkAgent,
- (caps) -> caps.getNetworkSpecifier() == null);
+ mWiFiNetworkAgent.connect(false);
+ expectAvailableCallbacksUnvalidatedWithSpecifier(mWiFiNetworkAgent, null /* specifier */,
+ cEmpty1, cEmpty2, cEmpty3, cEmpty4, cFoo, cBar);
assertNull(
mCm.getNetworkCapabilities(mWiFiNetworkAgent.getNetwork()).getNetworkSpecifier());
- cFoo.assertNoCallback();
- cBar.assertNoCallback();
- mWiFiNetworkAgent.setNetworkSpecifier(null);
- cFoo.expectCallback(CallbackEntry.LOST, mWiFiNetworkAgent);
- cBar.expectCallback(CallbackEntry.LOST, mWiFiNetworkAgent);
- for (TestNetworkCallback c: emptyCallbacks) {
- c.expectCallback(CallbackEntry.NETWORK_CAPS_UPDATED, mWiFiNetworkAgent);
- }
-
- assertNoCallbacks(cEmpty1, cEmpty2, cEmpty3, cEmpty4, cFoo, cBar);
+ mWiFiNetworkAgent.disconnect();
+ expectOnLost(mWiFiNetworkAgent, cEmpty1, cEmpty2, cEmpty3, cEmpty4, cFoo, cBar);
}
/**
@@ -6818,6 +6823,7 @@ public class ConnectivityServiceTest {
.thenReturn(UserHandle.getUid(RESTRICTED_USER, VPN_UID));
final Intent addedIntent = new Intent(ACTION_USER_ADDED);
+ addedIntent.putExtra(Intent.EXTRA_USER, UserHandle.of(RESTRICTED_USER));
addedIntent.putExtra(Intent.EXTRA_USER_HANDLE, RESTRICTED_USER);
// Send a USER_ADDED broadcast for it.
@@ -6844,6 +6850,7 @@ public class ConnectivityServiceTest {
// Send a USER_REMOVED broadcast and expect to lose the UID range for the restricted user.
final Intent removedIntent = new Intent(ACTION_USER_REMOVED);
+ removedIntent.putExtra(Intent.EXTRA_USER, UserHandle.of(RESTRICTED_USER));
removedIntent.putExtra(Intent.EXTRA_USER_HANDLE, RESTRICTED_USER);
processBroadcastForVpn(removedIntent);
@@ -6901,6 +6908,7 @@ public class ConnectivityServiceTest {
RESTRICTED_USER_INFO));
// TODO: check that VPN app within restricted profile still has access, etc.
final Intent addedIntent = new Intent(ACTION_USER_ADDED);
+ addedIntent.putExtra(Intent.EXTRA_USER, UserHandle.of(RESTRICTED_USER));
addedIntent.putExtra(Intent.EXTRA_USER_HANDLE, RESTRICTED_USER);
processBroadcastForVpn(addedIntent);
assertNull(mCm.getActiveNetworkForUid(uid));
@@ -6911,6 +6919,7 @@ public class ConnectivityServiceTest {
// Send a USER_REMOVED broadcast and expect to lose the UID range for the restricted user.
final Intent removedIntent = new Intent(ACTION_USER_REMOVED);
+ removedIntent.putExtra(Intent.EXTRA_USER, UserHandle.of(RESTRICTED_USER));
removedIntent.putExtra(Intent.EXTRA_USER_HANDLE, RESTRICTED_USER);
processBroadcastForVpn(removedIntent);
assertNull(mCm.getActiveNetworkForUid(uid));
@@ -7505,6 +7514,7 @@ public class ConnectivityServiceTest {
// Send a USER_UNLOCKED broadcast so CS starts LockdownVpnTracker.
final int userId = UserHandle.getUserId(Process.myUid());
final Intent addedIntent = new Intent(ACTION_USER_UNLOCKED);
+ addedIntent.putExtra(Intent.EXTRA_USER, UserHandle.of(userId));
addedIntent.putExtra(Intent.EXTRA_USER_HANDLE, userId);
processBroadcastForVpn(addedIntent);
diff --git a/tests/net/java/com/android/server/connectivity/NetworkNotificationManagerTest.java b/tests/net/java/com/android/server/connectivity/NetworkNotificationManagerTest.java
index 697dbc48880c..ff8c632833f2 100644
--- a/tests/net/java/com/android/server/connectivity/NetworkNotificationManagerTest.java
+++ b/tests/net/java/com/android/server/connectivity/NetworkNotificationManagerTest.java
@@ -49,6 +49,7 @@ import com.android.server.connectivity.NetworkNotificationManager.NotificationTy
import org.junit.AfterClass;
import org.junit.Before;
import org.junit.BeforeClass;
+import org.junit.Ignore;
import org.junit.Test;
import org.junit.runner.RunWith;
import org.mockito.AdditionalAnswers;
@@ -183,6 +184,9 @@ public class NetworkNotificationManagerTest {
}
@Test
+ @Ignore
+ // Ignored because the code under test calls Log.wtf, which crashes the tests on eng builds.
+ // TODO: re-enable after fixing this (e.g., turn Log.wtf into exceptions that this test catches)
public void testNoInternetNotificationsNotShownForCellular() {
mManager.showNotification(100, NO_INTERNET, mCellNai, mWifiNai, null, false);
mManager.showNotification(101, LOST_INTERNET, mCellNai, mWifiNai, null, false);