Merge "Remove unnecessary custom shadow of android.system.Os" into main
diff --git a/tests/robotests/src/com/android/settings/network/PrivateDnsModeDialogPreferenceTest.java b/tests/robotests/src/com/android/settings/network/PrivateDnsModeDialogPreferenceTest.java
index 85a67f6..4580002 100644
--- a/tests/robotests/src/com/android/settings/network/PrivateDnsModeDialogPreferenceTest.java
+++ b/tests/robotests/src/com/android/settings/network/PrivateDnsModeDialogPreferenceTest.java
@@ -38,7 +38,6 @@
import androidx.appcompat.app.AlertDialog;
import com.android.settings.R;
-import com.android.settings.testutils.shadow.ShadowOs;
import com.android.settingslib.CustomDialogPreferenceCompat.CustomPreferenceDialogFragment;
import org.junit.Before;
@@ -48,6 +47,7 @@
import org.robolectric.RobolectricTestRunner;
import org.robolectric.RuntimeEnvironment;
import org.robolectric.annotation.Config;
+import org.robolectric.shadows.ShadowOs;
import org.robolectric.util.ReflectionHelpers;
@RunWith(RobolectricTestRunner.class)
diff --git a/tests/robotests/src/com/android/settings/testutils/shadow/ShadowOs.java b/tests/robotests/src/com/android/settings/testutils/shadow/ShadowOs.java
deleted file mode 100644
index 72dfcb8..0000000
--- a/tests/robotests/src/com/android/settings/testutils/shadow/ShadowOs.java
+++ /dev/null
@@ -1,54 +0,0 @@
-/*
- * Copyright (C) 2018 The Android Open Source Project
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-package com.android.settings.testutils.shadow;
-
-import static android.system.OsConstants.AF_INET;
-import static android.system.OsConstants.AF_INET6;
-
-import android.system.Os;
-
-import org.robolectric.annotation.Implementation;
-import org.robolectric.annotation.Implements;
-
-import java.net.InetAddress;
-import java.net.UnknownHostException;
-import java.util.regex.Pattern;
-
-@Implements(Os.class)
-public class ShadowOs {
- // These are not actually correct, but good enough for the test
- private static final Pattern IPV4_PATTERN =
- Pattern.compile("^\\d{1,3}(\\.\\d{1,3}){3}$");
- private static final Pattern IPV6_PATTERN =
- Pattern.compile("^[0-9a-f]{1,4}(:[0-9a-f]{0,4}){0,6}$");
-
- private static final byte[] IPV4_BYTES = new byte[4];
- private static final byte[] IPV6_BYTES = new byte[16];
-
- @Implementation
- protected static InetAddress inet_pton(int family, String address) {
- if ((AF_INET == family && IPV4_PATTERN.matcher(address).find()) ||
- (AF_INET6 == family && IPV6_PATTERN.matcher(address).find())) {
- try {
- return InetAddress.getByAddress((AF_INET == family) ? IPV4_BYTES : IPV6_BYTES);
- } catch (UnknownHostException uhe) {
- // Shouldn't be reached.
- }
- }
- return null;
- }
-}