diff options
author | Brett Chabot <brettchabot@google.com> | 2024-04-24 11:04:35 -0700 |
---|---|---|
committer | Copybara-Service <copybara-worker@google.com> | 2024-04-24 11:05:24 -0700 |
commit | c577257599dc30cf283f8961c286d4ef65e799cb (patch) | |
tree | 5a6cdd50c556be3b4183171754b3fe4e32dc2216 | |
parent | f962e53e401fc88fef263e4ee8168cd977f9b8af (diff) | |
download | robolectric-c577257599dc30cf283f8961c286d4ef65e799cb.tar.gz |
Drop support for KITKAT SDK and associated dead code cleanup.
The android ecosystem is moving to support a minimum of minSdkVersion L,
and thus Robolectric is following suit and dropping support for running on
SDKs < L (21).
This change does the following:
- removes SDK 19/Kitkat from the list of default SDKs. Tests that attempt to
run explicitly on KitKat (e.g Config(sdk = 19) will now fail with
'unsupported sdk' errors.
- Remove now redundant methods and logic that was only relevant to SDKs < L,
such as removing @Implementation or unit tests with a maxSdk of < L.
- Remove redundant minSdk = LOLLIPOP declarations from @Implementation and
@Config references.
PiperOrigin-RevId: 627785965
160 files changed, 487 insertions, 2952 deletions
diff --git a/.github/workflows/tests.yml b/.github/workflows/tests.yml index 00e9e46b2..fb6573b43 100644 --- a/.github/workflows/tests.yml +++ b/.github/workflows/tests.yml @@ -47,7 +47,7 @@ jobs: strategy: fail-fast: false matrix: - api-versions: [ '19,21,34', '22,23,33', '24,25,32', '26,27,28', '29,30,31', ] + api-versions: [ '21,34', '22,23,33', '24,25,32', '26,27,28', '29,30,31', ] steps: - uses: actions/checkout@v4 diff --git a/buildSrc/src/main/groovy/AndroidSdk.groovy b/buildSrc/src/main/groovy/AndroidSdk.groovy index 5a6ed794b..c3133a790 100644 --- a/buildSrc/src/main/groovy/AndroidSdk.groovy +++ b/buildSrc/src/main/groovy/AndroidSdk.groovy @@ -1,7 +1,6 @@ class AndroidSdk implements Comparable<AndroidSdk> { static final PREINSTRUMENTED_VERSION = 6 - static final KITKAT = new AndroidSdk(19, "4.4_r1", "r2") static final LOLLIPOP = new AndroidSdk(21, "5.0.2_r3", "r0") static final LOLLIPOP_MR1 = new AndroidSdk(22, "5.1.1_r9", "r2") static final M = new AndroidSdk(23, "6.0.1_r3", "r1") @@ -18,7 +17,6 @@ class AndroidSdk implements Comparable<AndroidSdk> { static final U = new AndroidSdk(34, "14", "10818077") static final List<AndroidSdk> ALL_SDKS = [ - KITKAT, LOLLIPOP, LOLLIPOP_MR1, M, N, N_MR1, O, O_MR1, P, Q, R, S, S_V2, TIRAMISU, U ] diff --git a/integration_tests/androidx_test/src/sharedTest/java/org/robolectric/integrationtests/axt/EspressoTest.java b/integration_tests/androidx_test/src/sharedTest/java/org/robolectric/integrationtests/axt/EspressoTest.java index e703a282c..830e1ca66 100644 --- a/integration_tests/androidx_test/src/sharedTest/java/org/robolectric/integrationtests/axt/EspressoTest.java +++ b/integration_tests/androidx_test/src/sharedTest/java/org/robolectric/integrationtests/axt/EspressoTest.java @@ -1,6 +1,5 @@ package org.robolectric.integrationtests.axt; -import static android.os.Build.VERSION_CODES.LOLLIPOP; import static androidx.test.espresso.Espresso.onView; import static androidx.test.espresso.action.ViewActions.click; import static androidx.test.espresso.action.ViewActions.closeSoftKeyboard; @@ -26,13 +25,11 @@ import androidx.test.core.app.ActivityScenario; import androidx.test.espresso.Espresso; import androidx.test.ext.junit.rules.ActivityScenarioRule; import androidx.test.ext.junit.runners.AndroidJUnit4; -import androidx.test.filters.SdkSuppress; import java.util.concurrent.atomic.AtomicReference; import org.junit.Ignore; import org.junit.Rule; import org.junit.Test; import org.junit.runner.RunWith; -import org.robolectric.annotation.Config; import org.robolectric.annotation.LooperMode; import org.robolectric.annotation.LooperMode.Mode; import org.robolectric.integration.axt.R; @@ -184,8 +181,6 @@ public final class EspressoTest { }); } - @Config(minSdk = LOLLIPOP) - @SdkSuppress(minSdkVersion = LOLLIPOP) @Test public void textViewWithLetterSpacing() { onView(withId(R.id.text_view_letter_spacing)) diff --git a/integration_tests/ctesque/src/sharedTest/java/android/content/res/ResourcesTest.java b/integration_tests/ctesque/src/sharedTest/java/android/content/res/ResourcesTest.java index 5e4de013c..5a08f8d29 100644 --- a/integration_tests/ctesque/src/sharedTest/java/android/content/res/ResourcesTest.java +++ b/integration_tests/ctesque/src/sharedTest/java/android/content/res/ResourcesTest.java @@ -1,8 +1,5 @@ package android.content.res; -import static android.os.Build.VERSION_CODES.KITKAT; -import static android.os.Build.VERSION_CODES.KITKAT_WATCH; -import static android.os.Build.VERSION_CODES.LOLLIPOP; import static android.os.Build.VERSION_CODES.O; import static android.os.Build.VERSION_CODES.Q; import static android.util.TypedValue.COMPLEX_UNIT_DIP; @@ -504,8 +501,6 @@ public class ResourcesTest { } @Test - @SdkSuppress(minSdkVersion = LOLLIPOP) - @Config(minSdk = LOLLIPOP) public void getIdentifier_material() { int id = Resources.getSystem().getIdentifier("btn_check_material_anim", "drawable", "android"); assertThat(id).isGreaterThan(0); @@ -523,10 +518,6 @@ public class ResourcesTest { * ourselves. */ @Test - // @Config(sdk = Build.VERSION_CODES.LOLLIPOP) // android:color/secondary_text_material_dark was - // added in API 21 - @SdkSuppress(minSdkVersion = LOLLIPOP) - @Config(minSdk = LOLLIPOP) public void shouldGenerateIdsForResourcesThatAreMissingRValues() { int identifierMissingFromRFile = resources.getIdentifier("secondary_text_material_dark", "color", "android"); @@ -793,27 +784,12 @@ public class ResourcesTest { } @Test - @SdkSuppress(minSdkVersion = LOLLIPOP) - @Config(minSdk = LOLLIPOP) public void whenAttrIsDefinedInRuntimeSdk_getResourceName_findsResource() { assertThat(context.getResources().getResourceName(android.R.attr.viewportHeight)) .isEqualTo("android:attr/viewportHeight"); } @Test - @SdkSuppress(maxSdkVersion = KITKAT) - @Config(maxSdk = KITKAT_WATCH) - public void whenAttrIsNotDefinedInRuntimeSdk_getResourceName_doesntFindRequestedResourceButInsteadFindsInternalResourceWithSameId() { - // asking for an attr defined after the current SDK doesn't have a defined result; in this case it returns - // numberPickerStyle from com.internal.android.R - assertThat(context.getResources().getResourceName(android.R.attr.viewportHeight)) - .isNotEqualTo("android:attr/viewportHeight"); - - assertThat(context.getResources().getIdentifier("viewportHeight", "attr", "android")) - .isEqualTo(0); - } - - @Test public void subClassInitializedOK() { SubClassResources subClassResources = new SubClassResources(resources); assertThat(subClassResources.openRawResource(R.raw.raw_resource)).isNotNull(); diff --git a/integration_tests/ctesque/src/sharedTest/java/android/database/SQLiteDatabaseTest.java b/integration_tests/ctesque/src/sharedTest/java/android/database/SQLiteDatabaseTest.java index df6592e00..b00502897 100644 --- a/integration_tests/ctesque/src/sharedTest/java/android/database/SQLiteDatabaseTest.java +++ b/integration_tests/ctesque/src/sharedTest/java/android/database/SQLiteDatabaseTest.java @@ -1,6 +1,5 @@ package android.database; -import static android.os.Build.VERSION_CODES.LOLLIPOP; import static android.os.Build.VERSION_CODES.M; import static com.google.common.truth.Truth.assertThat; import static java.util.concurrent.TimeUnit.SECONDS; @@ -27,7 +26,6 @@ import org.junit.After; import org.junit.Before; import org.junit.Test; import org.junit.runner.RunWith; -import org.robolectric.annotation.Config; import org.robolectric.annotation.internal.DoNotInstrument; /** Compatibility test for {@link android.database.sqlite.SQLiteDatabase} */ @@ -207,8 +205,6 @@ public class SQLiteDatabaseTest { } @Test - @Config(minSdk = LOLLIPOP) - @SdkSuppress(minSdkVersion = LOLLIPOP) public void collate_unicode() { String[] names = new String[] {"aaa", "abc", "ABC", "bbb"}; for (String name : names) { @@ -229,8 +225,6 @@ public class SQLiteDatabaseTest { } @Test - @Config(minSdk = LOLLIPOP) - @SdkSuppress(minSdkVersion = LOLLIPOP) public void regex_selection() { ContentValues values = new ContentValues(); values.put("first_column", "test"); @@ -284,8 +278,6 @@ public class SQLiteDatabaseTest { results.close(); } - @Config(minSdk = LOLLIPOP) // The SQLite error messages were updated significantly in Lollipop. - @SdkSuppress(minSdkVersion = LOLLIPOP) @Test public void uniqueConstraintViolation_errorMessage() { database.execSQL( diff --git a/integration_tests/ctesque/src/sharedTest/java/android/graphics/BitmapTest.java b/integration_tests/ctesque/src/sharedTest/java/android/graphics/BitmapTest.java index 109194022..a68fce2b4 100644 --- a/integration_tests/ctesque/src/sharedTest/java/android/graphics/BitmapTest.java +++ b/integration_tests/ctesque/src/sharedTest/java/android/graphics/BitmapTest.java @@ -1,6 +1,5 @@ package android.graphics; -import static android.os.Build.VERSION_CODES.LOLLIPOP; import static android.os.Build.VERSION_CODES.M; import static android.os.Build.VERSION_CODES.O; import static android.os.Build.VERSION_CODES.P; @@ -654,8 +653,6 @@ public class BitmapTest { assertThat(bitmap.getColorSpace()).isEqualTo(ColorSpace.get(ColorSpace.Named.ADOBE_RGB)); } - @SdkSuppress(minSdkVersion = LOLLIPOP) - @Config(minSdk = LOLLIPOP) @Test public void bitmapDrawable_mutate() { BitmapDrawable drawable1 = (BitmapDrawable) resources.getDrawable(R.drawable.an_image); diff --git a/integration_tests/dependency-on-stubs/src/test/java/org/robolectric/LoadWeirdClassesTest.java b/integration_tests/dependency-on-stubs/src/test/java/org/robolectric/LoadWeirdClassesTest.java index b3e4f14d7..416338fdf 100644 --- a/integration_tests/dependency-on-stubs/src/test/java/org/robolectric/LoadWeirdClassesTest.java +++ b/integration_tests/dependency-on-stubs/src/test/java/org/robolectric/LoadWeirdClassesTest.java @@ -1,6 +1,5 @@ package org.robolectric; -import static android.os.Build.VERSION_CODES.KITKAT; import static org.robolectric.Shadows.shadowOf; import android.content.pm.PackageInfo; @@ -17,7 +16,7 @@ import org.robolectric.util.ReflectionHelpers; public class LoadWeirdClassesTest { @Test - @Config(sdk = KITKAT) + @Config(sdk = Config.OLDEST_SDK) public void shouldLoadDisplay() { ReflectionHelpers.callInstanceMethod( Display.class, ShadowDisplay.getDefaultDisplay(), "getDisplayAdjustments"); diff --git a/nativeruntime/src/test/java/org/robolectric/nativeruntime/DefaultNativeRuntimeLazyLoadTest.java b/nativeruntime/src/test/java/org/robolectric/nativeruntime/DefaultNativeRuntimeLazyLoadTest.java index d432b9497..164ee6e01 100644 --- a/nativeruntime/src/test/java/org/robolectric/nativeruntime/DefaultNativeRuntimeLazyLoadTest.java +++ b/nativeruntime/src/test/java/org/robolectric/nativeruntime/DefaultNativeRuntimeLazyLoadTest.java @@ -1,6 +1,5 @@ package org.robolectric.nativeruntime; -import static android.os.Build.VERSION_CODES.KITKAT; import static com.google.common.truth.Truth.assertThat; import android.app.Application; @@ -13,7 +12,7 @@ import org.robolectric.annotation.Config; import org.robolectric.versioning.AndroidVersions.U; @RunWith(RobolectricTestRunner.class) -@Config(minSdk = KITKAT, maxSdk = U.SDK_INT) +@Config(minSdk = Config.OLDEST_SDK, maxSdk = U.SDK_INT) public final class DefaultNativeRuntimeLazyLoadTest { /** diff --git a/robolectric/src/main/java/org/robolectric/android/internal/AndroidTestEnvironment.java b/robolectric/src/main/java/org/robolectric/android/internal/AndroidTestEnvironment.java index 15918a0c4..9ea315982 100755 --- a/robolectric/src/main/java/org/robolectric/android/internal/AndroidTestEnvironment.java +++ b/robolectric/src/main/java/org/robolectric/android/internal/AndroidTestEnvironment.java @@ -94,7 +94,6 @@ import org.robolectric.shadows.ShadowLog; import org.robolectric.shadows.ShadowLooper; import org.robolectric.shadows.ShadowPackageManager; import org.robolectric.shadows.ShadowPackageParser; -import org.robolectric.shadows.ShadowPackageParser._Package_; import org.robolectric.shadows.ShadowPausedLooper; import org.robolectric.shadows.ShadowView; import org.robolectric.util.Logger; @@ -713,17 +712,8 @@ public class AndroidTestEnvironment implements TestEnvironment { applicationInfo.publicSourceDir = createTempDir(applicationInfo.packageName + "-publicSourceDir"); } else { - if (apiLevel == VERSION_CODES.KITKAT) { - String sourcePath = reflector(_Package_.class, parsedPackage).getPath(); - if (sourcePath == null) { - sourcePath = createTempDir("sourceDir"); - } - applicationInfo.publicSourceDir = sourcePath; - applicationInfo.sourceDir = sourcePath; - } else { - applicationInfo.publicSourceDir = parsedPackage.codePath; - applicationInfo.sourceDir = parsedPackage.codePath; - } + applicationInfo.publicSourceDir = parsedPackage.codePath; + applicationInfo.sourceDir = parsedPackage.codePath; } applicationInfo.dataDir = createTempDir(applicationInfo.packageName + "-dataDir"); diff --git a/robolectric/src/main/java/org/robolectric/plugins/DefaultSdkProvider.java b/robolectric/src/main/java/org/robolectric/plugins/DefaultSdkProvider.java index 0f9272c03..159c5defc 100644 --- a/robolectric/src/main/java/org/robolectric/plugins/DefaultSdkProvider.java +++ b/robolectric/src/main/java/org/robolectric/plugins/DefaultSdkProvider.java @@ -17,7 +17,6 @@ import org.robolectric.internal.dependency.DependencyResolver; import org.robolectric.pluginapi.Sdk; import org.robolectric.pluginapi.SdkProvider; import org.robolectric.util.Util; -import org.robolectric.versioning.AndroidVersions.K; import org.robolectric.versioning.AndroidVersions.L; import org.robolectric.versioning.AndroidVersions.LMR1; import org.robolectric.versioning.AndroidVersions.M; @@ -62,7 +61,6 @@ public class DefaultSdkProvider implements SdkProvider { } protected void populateSdks(TreeMap<Integer, Sdk> knownSdks) { - knownSdks.put(K.SDK_INT, new DefaultSdk(K.SDK_INT, "4.4_r1", "r2", "REL", 8)); knownSdks.put(L.SDK_INT, new DefaultSdk(L.SDK_INT, "5.0.2_r3", "r0", "REL", 8)); knownSdks.put(LMR1.SDK_INT, new DefaultSdk(LMR1.SDK_INT, "5.1.1_r9", "r2", "REL", 8)); knownSdks.put(M.SDK_INT, new DefaultSdk(M.SDK_INT, "6.0.1_r3", "r1", "REL", 8)); diff --git a/robolectric/src/test/java/org/robolectric/RobolectricTestRunnerMultiApiTest.java b/robolectric/src/test/java/org/robolectric/RobolectricTestRunnerMultiApiTest.java index d994d8d92..4fd1ba199 100644 --- a/robolectric/src/test/java/org/robolectric/RobolectricTestRunnerMultiApiTest.java +++ b/robolectric/src/test/java/org/robolectric/RobolectricTestRunnerMultiApiTest.java @@ -317,7 +317,7 @@ public class RobolectricTestRunnerMultiApiTest { public static class TestMethodWithSdkAndMinMax { @Config(sdk = M, minSdk = M, maxSdk = N) @Test - public void testWithKitKatAndLollipop() { + public void testWithSdkRange() { assertThat(Build.VERSION.SDK_INT).isIn(Range.closed(M, N)); } } diff --git a/robolectric/src/test/java/org/robolectric/android/BootstrapTest.java b/robolectric/src/test/java/org/robolectric/android/BootstrapTest.java index 6dd5256b9..de38ffa9a 100644 --- a/robolectric/src/test/java/org/robolectric/android/BootstrapTest.java +++ b/robolectric/src/test/java/org/robolectric/android/BootstrapTest.java @@ -98,9 +98,7 @@ public class BootstrapTest { assertThat(displayInfo.logicalDensityDpi).isEqualTo(160); assertThat(displayInfo.physicalXDpi).isEqualTo(160f); assertThat(displayInfo.physicalYDpi).isEqualTo(160f); - if (Build.VERSION.SDK_INT > Build.VERSION_CODES.KITKAT) { - assertThat(displayInfo.state).isEqualTo(Display.STATE_ON); - } + assertThat(displayInfo.state).isEqualTo(Display.STATE_ON); DisplayMetrics displayMetrics = ApplicationProvider.getApplicationContext().getResources().getDisplayMetrics(); @@ -131,9 +129,7 @@ public class BootstrapTest { assertThat(displayInfo.logicalDensityDpi).isEqualTo(240); assertThat(displayInfo.physicalXDpi).isEqualTo(240f); assertThat(displayInfo.physicalYDpi).isEqualTo(240f); - if (Build.VERSION.SDK_INT > Build.VERSION_CODES.KITKAT) { - assertThat(displayInfo.state).isEqualTo(Display.STATE_ON); - } + assertThat(displayInfo.state).isEqualTo(Display.STATE_ON); DisplayMetrics displayMetrics = ApplicationProvider.getApplicationContext().getResources().getDisplayMetrics(); diff --git a/robolectric/src/test/java/org/robolectric/android/DrawableResourceLoaderTest.java b/robolectric/src/test/java/org/robolectric/android/DrawableResourceLoaderTest.java index 0428c44e1..bf5855e23 100644 --- a/robolectric/src/test/java/org/robolectric/android/DrawableResourceLoaderTest.java +++ b/robolectric/src/test/java/org/robolectric/android/DrawableResourceLoaderTest.java @@ -1,7 +1,5 @@ package org.robolectric.android; -import static android.os.Build.VERSION_CODES.KITKAT_WATCH; -import static android.os.Build.VERSION_CODES.LOLLIPOP; import static com.google.common.truth.Truth.assertThat; import static com.google.common.truth.TruthJUnit.assume; import static org.junit.Assert.assertEquals; @@ -59,12 +57,7 @@ public class DrawableResourceLoaderTest { assertThat(resources.getDrawable(R.drawable.rainbow)).isInstanceOf(LayerDrawable.class); } - @Test @Config(maxSdk = KITKAT_WATCH) - public void testVectorDrawableType_preVectors() { - assertThat(resources.getDrawable(R.drawable.an_image_or_vector)).isInstanceOf(BitmapDrawable.class); - } - - @Test @Config(minSdk = LOLLIPOP) + @Test public void testVectorDrawableType() { assertThat(resources.getDrawable(R.drawable.an_image_or_vector)).isInstanceOf(VectorDrawable.class); } diff --git a/robolectric/src/test/java/org/robolectric/shadows/MediaCodecInfoBuilderTest.java b/robolectric/src/test/java/org/robolectric/shadows/MediaCodecInfoBuilderTest.java index f57b4842b..8e60f35c5 100644 --- a/robolectric/src/test/java/org/robolectric/shadows/MediaCodecInfoBuilderTest.java +++ b/robolectric/src/test/java/org/robolectric/shadows/MediaCodecInfoBuilderTest.java @@ -4,7 +4,6 @@ import static android.media.MediaFormat.MIMETYPE_AUDIO_AAC; import static android.media.MediaFormat.MIMETYPE_AUDIO_OPUS; import static android.media.MediaFormat.MIMETYPE_VIDEO_AVC; import static android.media.MediaFormat.MIMETYPE_VIDEO_VP9; -import static android.os.Build.VERSION_CODES.LOLLIPOP; import static android.os.Build.VERSION_CODES.M; import static android.os.Build.VERSION_CODES.Q; import static com.google.common.truth.Truth.assertThat; @@ -23,7 +22,6 @@ import org.robolectric.annotation.Config; /** Tests for {@link MediaCodecInfoBuilder}. */ @RunWith(AndroidJUnit4.class) -@Config(minSdk = LOLLIPOP) public class MediaCodecInfoBuilderTest { private static final String AAC_ENCODER_NAME = "test.encoder.aac"; @@ -365,7 +363,6 @@ public class MediaCodecInfoBuilderTest { } @Test - @Config(minSdk = LOLLIPOP) public void mediaCodecInfo_preQ() { if (RuntimeEnvironment.getApiLevel() <= M) { MediaCodecList.getCodecCount(); diff --git a/robolectric/src/test/java/org/robolectric/shadows/ShadowAccessibilityNodeInfoTest.java b/robolectric/src/test/java/org/robolectric/shadows/ShadowAccessibilityNodeInfoTest.java index 74bf81c9c..e80484ef5 100644 --- a/robolectric/src/test/java/org/robolectric/shadows/ShadowAccessibilityNodeInfoTest.java +++ b/robolectric/src/test/java/org/robolectric/shadows/ShadowAccessibilityNodeInfoTest.java @@ -1,6 +1,5 @@ package org.robolectric.shadows; -import static android.os.Build.VERSION_CODES.LOLLIPOP; import static android.os.Build.VERSION_CODES.N; import static android.os.Build.VERSION_CODES.O; import static android.os.Build.VERSION_CODES.P; @@ -107,7 +106,6 @@ public class ShadowAccessibilityNodeInfoTest { } @Test - @Config(minSdk = LOLLIPOP) public void shouldRecordFlagsProperly() { node = AccessibilityNodeInfo.obtain(); node.setClickable(false); diff --git a/robolectric/src/test/java/org/robolectric/shadows/ShadowAccessibilityServiceTest.java b/robolectric/src/test/java/org/robolectric/shadows/ShadowAccessibilityServiceTest.java index 195d67374..289a2e4b8 100644 --- a/robolectric/src/test/java/org/robolectric/shadows/ShadowAccessibilityServiceTest.java +++ b/robolectric/src/test/java/org/robolectric/shadows/ShadowAccessibilityServiceTest.java @@ -1,6 +1,5 @@ package org.robolectric.shadows; -import static android.os.Build.VERSION_CODES.LOLLIPOP; import static android.os.Build.VERSION_CODES.N; import static android.os.Build.VERSION_CODES.R; import static android.os.Build.VERSION_CODES.S; @@ -49,11 +48,8 @@ public class ShadowAccessibilityServiceTest { assertThat(shadow.getGlobalActionsPerformed().get(0)).isEqualTo(1); } - /** - * The AccessibilityService shadow should return an empty list if no window data is provided. - */ + /** The AccessibilityService shadow should return an empty list if no window data is provided. */ @Test - @Config(minSdk = LOLLIPOP) public void shouldReturnEmptyListIfNoWindowDataProvided() { assertThat(service.getWindows()).isEmpty(); } @@ -62,7 +58,6 @@ public class ShadowAccessibilityServiceTest { * The AccessibilityService shadow should return an empty list if null window data is provided. */ @Test - @Config(minSdk = LOLLIPOP) public void shouldReturnEmptyListIfNullWindowDataProvided() { shadow.setWindows(null); assertThat(service.getWindows()).isEmpty(); @@ -80,7 +75,7 @@ public class ShadowAccessibilityServiceTest { GestureDescription gestureDescription = createTestGesture(); GestureResultCallback gestureResultCallback = createEmptyGestureResultCallback(); - service.dispatchGesture(gestureDescription, gestureResultCallback, /*handler=*/ null); + service.dispatchGesture(gestureDescription, gestureResultCallback, /* handler= */ null); assertThat(shadow.getGesturesDispatched().get(0).description()) .isSameInstanceAs(gestureDescription); @@ -92,7 +87,7 @@ public class ShadowAccessibilityServiceTest { GestureDescription gestureDescription = createTestGesture(); GestureResultCallback gestureResultCallback = createEmptyGestureResultCallback(); - service.dispatchGesture(gestureDescription, gestureResultCallback, /*handler=*/ null); + service.dispatchGesture(gestureDescription, gestureResultCallback, /* handler= */ null); assertThat(shadow.getGesturesDispatched().get(0).callback()) .isSameInstanceAs(gestureResultCallback); @@ -107,7 +102,7 @@ public class ShadowAccessibilityServiceTest { shadow.setCanDispatchGestures(false); assertThat( - service.dispatchGesture(gestureDescription, gestureResultCallback, /*handler=*/ null)) + service.dispatchGesture(gestureDescription, gestureResultCallback, /* handler= */ null)) .isFalse(); } @@ -118,7 +113,7 @@ public class ShadowAccessibilityServiceTest { GestureResultCallback gestureResultCallback = createEmptyGestureResultCallback(); shadow.setCanDispatchGestures(false); - service.dispatchGesture(gestureDescription, gestureResultCallback, /*handler=*/ null); + service.dispatchGesture(gestureDescription, gestureResultCallback, /* handler= */ null); assertThat(shadow.getGesturesDispatched()).isEmpty(); } @@ -133,7 +128,7 @@ public class ShadowAccessibilityServiceTest { shadow.setCanDispatchGestures(true); assertThat( - service.dispatchGesture(gestureDescription, gestureResultCallback, /*handler=*/ null)) + service.dispatchGesture(gestureDescription, gestureResultCallback, /* handler= */ null)) .isTrue(); } @@ -153,7 +148,7 @@ public class ShadowAccessibilityServiceTest { }; service.takeScreenshot( - /*displayId=*/ Display.DEFAULT_DISPLAY, + /* displayId= */ Display.DEFAULT_DISPLAY, MoreExecutors.directExecutor(), takeScreenshotCallback); @@ -178,7 +173,7 @@ public class ShadowAccessibilityServiceTest { }; service.takeScreenshot( - /*displayId=*/ Display.DEFAULT_DISPLAY, + /* displayId= */ Display.DEFAULT_DISPLAY, MoreExecutors.directExecutor(), takeScreenshotCallback); @@ -205,18 +200,15 @@ public class ShadowAccessibilityServiceTest { shadow.unsetTakeScreenshotErrorCode(); service.takeScreenshot( - /*displayId=*/ Display.DEFAULT_DISPLAY, + /* displayId= */ Display.DEFAULT_DISPLAY, MoreExecutors.directExecutor(), takeScreenshotCallback); assertThat(screenshotResultAtomicReference.get()).isNotNull(); } - /** - * The AccessibilityService shadow should return consistent window data. - */ + /** The AccessibilityService shadow should return consistent window data. */ @Test - @Config(minSdk = LOLLIPOP) public void shouldReturnPopulatedWindowData() { AccessibilityWindowInfo w1 = AccessibilityWindowInfo.obtain(); w1.setId(1); @@ -340,10 +332,10 @@ public class ShadowAccessibilityServiceTest { private static GestureDescription createTestGesture() { Path path = new Path(); - path.moveTo(/*x=*/ 100, /*y=*/ 200); - path.lineTo(/*x=*/ 100, /*y=*/ 800); + path.moveTo(/* x= */ 100, /* y= */ 200); + path.lineTo(/* x= */ 100, /* y= */ 800); return new GestureDescription.Builder() - .addStroke(new StrokeDescription(path, /*startTime=*/ 0, /*duration=*/ 100)) + .addStroke(new StrokeDescription(path, /* startTime= */ 0, /* duration= */ 100)) .build(); } @@ -365,13 +357,12 @@ public class ShadowAccessibilityServiceTest { @Override public void onAccessibilityEvent(AccessibilityEvent arg0) { - //Do nothing + // Do nothing } @Override public void onInterrupt() { - //Do nothing + // Do nothing } } } - diff --git a/robolectric/src/test/java/org/robolectric/shadows/ShadowAccessibilityWindowInfoTest.java b/robolectric/src/test/java/org/robolectric/shadows/ShadowAccessibilityWindowInfoTest.java index 9407c0904..803599825 100644 --- a/robolectric/src/test/java/org/robolectric/shadows/ShadowAccessibilityWindowInfoTest.java +++ b/robolectric/src/test/java/org/robolectric/shadows/ShadowAccessibilityWindowInfoTest.java @@ -1,6 +1,5 @@ package org.robolectric.shadows; -import static android.os.Build.VERSION_CODES.LOLLIPOP; import static com.google.common.truth.Truth.assertThat; import static org.robolectric.Shadows.shadowOf; @@ -10,10 +9,8 @@ import androidx.test.ext.junit.runners.AndroidJUnit4; import org.junit.Before; import org.junit.Test; import org.junit.runner.RunWith; -import org.robolectric.annotation.Config; @RunWith(AndroidJUnit4.class) -@Config(minSdk = LOLLIPOP) public class ShadowAccessibilityWindowInfoTest { private ShadowAccessibilityWindowInfo shadow; diff --git a/robolectric/src/test/java/org/robolectric/shadows/ShadowAccountManagerTest.java b/robolectric/src/test/java/org/robolectric/shadows/ShadowAccountManagerTest.java index ffbc9c760..1c614565e 100644 --- a/robolectric/src/test/java/org/robolectric/shadows/ShadowAccountManagerTest.java +++ b/robolectric/src/test/java/org/robolectric/shadows/ShadowAccountManagerTest.java @@ -1,6 +1,5 @@ package org.robolectric.shadows; -import static android.os.Build.VERSION_CODES.LOLLIPOP; import static android.os.Build.VERSION_CODES.LOLLIPOP_MR1; import static android.os.Build.VERSION_CODES.O; import static com.google.common.truth.Truth.assertThat; @@ -829,7 +828,6 @@ public class ShadowAccountManagerTest { } @Test - @Config(minSdk = LOLLIPOP) public void addPreviousAccount() { Account account = new Account("name_a", "type_a"); shadowOf(am).setPreviousAccountName(account, "old_name"); diff --git a/robolectric/src/test/java/org/robolectric/shadows/ShadowActivityManagerTest.java b/robolectric/src/test/java/org/robolectric/shadows/ShadowActivityManagerTest.java index e2212f443..fb1709160 100644 --- a/robolectric/src/test/java/org/robolectric/shadows/ShadowActivityManagerTest.java +++ b/robolectric/src/test/java/org/robolectric/shadows/ShadowActivityManagerTest.java @@ -4,7 +4,6 @@ import static android.app.ActivityManager.RunningAppProcessInfo.IMPORTANCE_FOREG import static android.app.ActivityManager.RunningAppProcessInfo.IMPORTANCE_FOREGROUND_SERVICE; import static android.app.ActivityManager.RunningAppProcessInfo.IMPORTANCE_GONE; import static android.app.ActivityManager.RunningAppProcessInfo.IMPORTANCE_VISIBLE; -import static android.os.Build.VERSION_CODES.LOLLIPOP; import static android.os.Build.VERSION_CODES.M; import static android.os.Build.VERSION_CODES.O; import static android.os.Build.VERSION_CODES.P; @@ -93,7 +92,6 @@ public class ShadowActivityManagerTest { } @Test - @Config(minSdk = LOLLIPOP) public void getAppTasks_shouldReturnAppTaskList() { final AppTask task1 = ShadowAppTask.newInstance(); final AppTask task2 = ShadowAppTask.newInstance(); diff --git a/robolectric/src/test/java/org/robolectric/shadows/ShadowActivityTest.java b/robolectric/src/test/java/org/robolectric/shadows/ShadowActivityTest.java index 387f0cfcc..f9b136da7 100644 --- a/robolectric/src/test/java/org/robolectric/shadows/ShadowActivityTest.java +++ b/robolectric/src/test/java/org/robolectric/shadows/ShadowActivityTest.java @@ -1,6 +1,5 @@ package org.robolectric.shadows; -import static android.os.Build.VERSION_CODES.LOLLIPOP; import static android.os.Build.VERSION_CODES.M; import static android.os.Build.VERSION_CODES.N; import static android.os.Build.VERSION_CODES.O; @@ -520,7 +519,6 @@ public class ShadowActivityTest { } @Test - @Config(minSdk = LOLLIPOP) public void shouldCallFinishOnFinishAndRemoveTask() { Activity activity = new Activity(); activity.finishAndRemoveTask(); @@ -1312,7 +1310,6 @@ public class ShadowActivityTest { } @Test - @Config(minSdk = LOLLIPOP) public void lockTask() { Activity activity = Robolectric.setupActivity(Activity.class); diff --git a/robolectric/src/test/java/org/robolectric/shadows/ShadowAlertDialogTest.java b/robolectric/src/test/java/org/robolectric/shadows/ShadowAlertDialogTest.java index 00c2327f6..f8a907f6a 100644 --- a/robolectric/src/test/java/org/robolectric/shadows/ShadowAlertDialogTest.java +++ b/robolectric/src/test/java/org/robolectric/shadows/ShadowAlertDialogTest.java @@ -1,6 +1,5 @@ package org.robolectric.shadows; -import static android.os.Build.VERSION_CODES.LOLLIPOP; import static com.google.common.truth.Truth.assertThat; import static org.junit.Assert.assertEquals; import static org.junit.Assert.assertFalse; @@ -29,7 +28,6 @@ import org.junit.runner.RunWith; import org.robolectric.R; import org.robolectric.Robolectric; import org.robolectric.android.CustomView; -import org.robolectric.annotation.Config; @RunWith(AndroidJUnit4.class) public class ShadowAlertDialogTest { @@ -136,7 +134,6 @@ public class ShadowAlertDialogTest { } @Test - @Config(minSdk = LOLLIPOP) public void shouldSetView_withLayoutId() { AlertDialog.Builder builder = new AlertDialog.Builder(getApplication()); builder.setView(R.layout.custom_layout); diff --git a/robolectric/src/test/java/org/robolectric/shadows/ShadowAppTaskTest.java b/robolectric/src/test/java/org/robolectric/shadows/ShadowAppTaskTest.java index db17e6e82..8eff0e0ed 100644 --- a/robolectric/src/test/java/org/robolectric/shadows/ShadowAppTaskTest.java +++ b/robolectric/src/test/java/org/robolectric/shadows/ShadowAppTaskTest.java @@ -1,6 +1,5 @@ package org.robolectric.shadows; -import static android.os.Build.VERSION_CODES.LOLLIPOP; import static com.google.common.truth.Truth.assertThat; import static org.robolectric.Shadows.shadowOf; @@ -12,10 +11,8 @@ import androidx.test.ext.junit.runners.AndroidJUnit4; import org.junit.Test; import org.junit.runner.RunWith; import org.robolectric.Robolectric; -import org.robolectric.annotation.Config; @RunWith(AndroidJUnit4.class) -@Config(minSdk = LOLLIPOP) public class ShadowAppTaskTest { @Test diff --git a/robolectric/src/test/java/org/robolectric/shadows/ShadowApplicationTest.java b/robolectric/src/test/java/org/robolectric/shadows/ShadowApplicationTest.java index 83e57227e..91be98663 100644 --- a/robolectric/src/test/java/org/robolectric/shadows/ShadowApplicationTest.java +++ b/robolectric/src/test/java/org/robolectric/shadows/ShadowApplicationTest.java @@ -1,6 +1,5 @@ package org.robolectric.shadows; -import static android.os.Build.VERSION_CODES.LOLLIPOP; import static android.os.Build.VERSION_CODES.LOLLIPOP_MR1; import static android.os.Build.VERSION_CODES.M; import static android.os.Build.VERSION_CODES.O; @@ -140,7 +139,6 @@ public class ShadowApplicationTest { } @Test - @Config(minSdk = LOLLIPOP) public void shouldProvideServicesIntroducedInLollipop() throws Exception { assertThat(context.getSystemService(Context.MEDIA_SESSION_SERVICE)) .isInstanceOf(MediaSessionManager.class); diff --git a/robolectric/src/test/java/org/robolectric/shadows/ShadowAudioManagerTest.java b/robolectric/src/test/java/org/robolectric/shadows/ShadowAudioManagerTest.java index f35e38783..0d9d0fcbd 100644 --- a/robolectric/src/test/java/org/robolectric/shadows/ShadowAudioManagerTest.java +++ b/robolectric/src/test/java/org/robolectric/shadows/ShadowAudioManagerTest.java @@ -1,6 +1,5 @@ package org.robolectric.shadows; -import static android.os.Build.VERSION_CODES.LOLLIPOP; import static android.os.Build.VERSION_CODES.M; import static android.os.Build.VERSION_CODES.N; import static android.os.Build.VERSION_CODES.O; @@ -1233,7 +1232,6 @@ public class ShadowAudioManagerTest { } @Test - @Config(minSdk = LOLLIPOP) public void generateAudioSessionId_returnsPositiveValues() { int audioSessionId = audioManager.generateAudioSessionId(); int audioSessionId2 = audioManager.generateAudioSessionId(); @@ -1243,7 +1241,6 @@ public class ShadowAudioManagerTest { } @Test - @Config(minSdk = LOLLIPOP) public void generateAudioSessionId_returnsDistinctValues() { int audioSessionId = audioManager.generateAudioSessionId(); int audioSessionId2 = audioManager.generateAudioSessionId(); diff --git a/robolectric/src/test/java/org/robolectric/shadows/ShadowAudioRecordTest.java b/robolectric/src/test/java/org/robolectric/shadows/ShadowAudioRecordTest.java index 4170a5b16..242cf4858 100644 --- a/robolectric/src/test/java/org/robolectric/shadows/ShadowAudioRecordTest.java +++ b/robolectric/src/test/java/org/robolectric/shadows/ShadowAudioRecordTest.java @@ -1,7 +1,6 @@ package org.robolectric.shadows; import static android.media.AudioPort.ROLE_SOURCE; -import static android.os.Build.VERSION_CODES.LOLLIPOP; import static android.os.Build.VERSION_CODES.M; import static com.google.common.truth.Truth.assertThat; import static java.lang.Math.min; @@ -27,7 +26,6 @@ import org.robolectric.shadows.ShadowAudioRecord.AudioRecordSource; /** Tests for {@link ShadowAudioRecord}. */ @RunWith(AndroidJUnit4.class) -@Config(minSdk = LOLLIPOP) public class ShadowAudioRecordTest { @Test diff --git a/robolectric/src/test/java/org/robolectric/shadows/ShadowAudioTrackTest.java b/robolectric/src/test/java/org/robolectric/shadows/ShadowAudioTrackTest.java index 10dc3e33a..841606630 100644 --- a/robolectric/src/test/java/org/robolectric/shadows/ShadowAudioTrackTest.java +++ b/robolectric/src/test/java/org/robolectric/shadows/ShadowAudioTrackTest.java @@ -3,7 +3,6 @@ package org.robolectric.shadows; import static android.media.AudioTrack.ERROR_BAD_VALUE; import static android.media.AudioTrack.WRITE_BLOCKING; import static android.media.AudioTrack.WRITE_NON_BLOCKING; -import static android.os.Build.VERSION_CODES.LOLLIPOP; import static android.os.Build.VERSION_CODES.M; import static android.os.Build.VERSION_CODES.N; import static android.os.Build.VERSION_CODES.Q; @@ -34,7 +33,6 @@ import org.robolectric.annotation.Config; /** Tests for {@link ShadowAudioTrack}. */ @RunWith(AndroidJUnit4.class) -@Config(minSdk = LOLLIPOP) public class ShadowAudioTrackTest implements ShadowAudioTrack.OnAudioDataWrittenListener { private static final int SAMPLE_RATE_IN_HZ = 44100; diff --git a/robolectric/src/test/java/org/robolectric/shadows/ShadowBackupManagerTest.java b/robolectric/src/test/java/org/robolectric/shadows/ShadowBackupManagerTest.java index 219423d6b..7d1d91665 100644 --- a/robolectric/src/test/java/org/robolectric/shadows/ShadowBackupManagerTest.java +++ b/robolectric/src/test/java/org/robolectric/shadows/ShadowBackupManagerTest.java @@ -1,6 +1,5 @@ package org.robolectric.shadows; -import static android.os.Build.VERSION_CODES.LOLLIPOP; import static android.os.Build.VERSION_CODES.M; import static android.os.Build.VERSION_CODES.Q; import static com.google.common.truth.Truth.assertThat; @@ -66,14 +65,12 @@ public class ShadowBackupManagerTest { } @Test - @Config(minSdk = LOLLIPOP) public void setBackupEnabled_setToTrue_shouldEnableBackup() { backupManager.setBackupEnabled(true); assertThat(backupManager.isBackupEnabled()).isTrue(); } @Test - @Config(minSdk = LOLLIPOP) public void setBackupEnabled_multipleInstances_shouldBeEnabled() { // BackupManager is used by creating new instances, but all of them talk to the same // BackupManagerService in Android, so methods that route through the service will share states. @@ -83,14 +80,12 @@ public class ShadowBackupManagerTest { } @Test - @Config(minSdk = LOLLIPOP) public void setBackupEnabled_setToFalse_shouldDisableBackup() { backupManager.setBackupEnabled(false); assertThat(backupManager.isBackupEnabled()).isFalse(); } @Test - @Config(minSdk = LOLLIPOP) public void isBackupEnabled_noPermission_shouldThrowSecurityException() { shadowOf((Application) ApplicationProvider.getApplicationContext()) .denyPermissions(android.Manifest.permission.BACKUP); diff --git a/robolectric/src/test/java/org/robolectric/shadows/ShadowBatteryManagerTest.java b/robolectric/src/test/java/org/robolectric/shadows/ShadowBatteryManagerTest.java index aee4779e0..c820cf9ba 100644 --- a/robolectric/src/test/java/org/robolectric/shadows/ShadowBatteryManagerTest.java +++ b/robolectric/src/test/java/org/robolectric/shadows/ShadowBatteryManagerTest.java @@ -1,6 +1,5 @@ package org.robolectric.shadows; -import static android.os.Build.VERSION_CODES.LOLLIPOP; import static android.os.Build.VERSION_CODES.M; import static android.os.Build.VERSION_CODES.P; import static com.google.common.truth.Truth.assertThat; @@ -17,7 +16,6 @@ import org.junit.runner.RunWith; import org.robolectric.annotation.Config; @RunWith(AndroidJUnit4.class) -@Config(minSdk = LOLLIPOP) public class ShadowBatteryManagerTest { private BatteryManager batteryManager; private ShadowBatteryManager shadowBatteryManager; diff --git a/robolectric/src/test/java/org/robolectric/shadows/ShadowBluetoothAdapterTest.java b/robolectric/src/test/java/org/robolectric/shadows/ShadowBluetoothAdapterTest.java index ae6eb3bdc..aadac4457 100644 --- a/robolectric/src/test/java/org/robolectric/shadows/ShadowBluetoothAdapterTest.java +++ b/robolectric/src/test/java/org/robolectric/shadows/ShadowBluetoothAdapterTest.java @@ -1,6 +1,5 @@ package org.robolectric.shadows; -import static android.os.Build.VERSION_CODES.LOLLIPOP; import static android.os.Build.VERSION_CODES.M; import static android.os.Build.VERSION_CODES.O; import static android.os.Build.VERSION_CODES.Q; @@ -154,7 +153,6 @@ public class ShadowBluetoothAdapterTest { } @Test - @Config(minSdk = LOLLIPOP) public void canGetBluetoothLeScanner() { if (RuntimeEnvironment.getApiLevel() < M) { // On SDK < 23, bluetooth has to be in STATE_ON in order to get a BluetoothLeScanner. @@ -165,7 +163,6 @@ public class ShadowBluetoothAdapterTest { } @Test - @Config(minSdk = LOLLIPOP) public void canGetBluetoothLeAdvertiser() throws Exception { // bluetooth needs to be ON in APIS 21 and 22 for getBluetoothLeAdvertiser to return a // non null value @@ -187,7 +184,6 @@ public class ShadowBluetoothAdapterTest { } @Test - @Config(minSdk = LOLLIPOP) public void canGetAndSetMultipleAdvertisementSupport() throws Exception { BluetoothAdapter adapter = BluetoothAdapter.getDefaultAdapter(); diff --git a/robolectric/src/test/java/org/robolectric/shadows/ShadowBluetoothDeviceTest.java b/robolectric/src/test/java/org/robolectric/shadows/ShadowBluetoothDeviceTest.java index 93a5d5dfc..7039d7658 100644 --- a/robolectric/src/test/java/org/robolectric/shadows/ShadowBluetoothDeviceTest.java +++ b/robolectric/src/test/java/org/robolectric/shadows/ShadowBluetoothDeviceTest.java @@ -614,7 +614,6 @@ public class ShadowBluetoothDeviceTest { } @Test - @Config(minSdk = VERSION_CODES.KITKAT_WATCH) public void setDeviceConnected_isConnected() { shadowOf(application).grantPermissions(BLUETOOTH_CONNECT); BluetoothDevice device = BluetoothAdapter.getDefaultAdapter().getRemoteDevice(MOCK_MAC_ADDRESS); @@ -625,7 +624,6 @@ public class ShadowBluetoothDeviceTest { } @Test - @Config(minSdk = VERSION_CODES.KITKAT_WATCH) public void setDeviceNotConnected_isNotConnected() { shadowOf(application).grantPermissions(BLUETOOTH_CONNECT); BluetoothDevice device = BluetoothAdapter.getDefaultAdapter().getRemoteDevice(MOCK_MAC_ADDRESS); @@ -636,7 +634,6 @@ public class ShadowBluetoothDeviceTest { } @Test - @Config(minSdk = VERSION_CODES.KITKAT_WATCH) public void notSetDeviceNotConnected_isNotConnectedByDefault() { shadowOf(application).grantPermissions(BLUETOOTH_CONNECT); BluetoothDevice device = BluetoothAdapter.getDefaultAdapter().getRemoteDevice(MOCK_MAC_ADDRESS); diff --git a/robolectric/src/test/java/org/robolectric/shadows/ShadowBluetoothLeScannerTest.java b/robolectric/src/test/java/org/robolectric/shadows/ShadowBluetoothLeScannerTest.java index 51b12b86f..022c1f718 100644 --- a/robolectric/src/test/java/org/robolectric/shadows/ShadowBluetoothLeScannerTest.java +++ b/robolectric/src/test/java/org/robolectric/shadows/ShadowBluetoothLeScannerTest.java @@ -1,6 +1,5 @@ package org.robolectric.shadows; -import static android.os.Build.VERSION_CODES.LOLLIPOP; import static android.os.Build.VERSION_CODES.M; import static android.os.Build.VERSION_CODES.O; import static com.google.common.truth.Truth.assertThat; @@ -31,7 +30,6 @@ import org.robolectric.annotation.Config; /** Unit tests for {@link ShadowBluetoothLeScanner}. */ @RunWith(RobolectricTestRunner.class) -@Config(minSdk = LOLLIPOP) public class ShadowBluetoothLeScannerTest { private BluetoothAdapter adapter; private BluetoothLeScanner bluetoothLeScanner; diff --git a/robolectric/src/test/java/org/robolectric/shadows/ShadowConnectivityManagerTest.java b/robolectric/src/test/java/org/robolectric/shadows/ShadowConnectivityManagerTest.java index dc7230dff..236c59225 100644 --- a/robolectric/src/test/java/org/robolectric/shadows/ShadowConnectivityManagerTest.java +++ b/robolectric/src/test/java/org/robolectric/shadows/ShadowConnectivityManagerTest.java @@ -3,7 +3,6 @@ package org.robolectric.shadows; import static android.net.ConnectivityManager.RESTRICT_BACKGROUND_STATUS_DISABLED; import static android.net.ConnectivityManager.RESTRICT_BACKGROUND_STATUS_ENABLED; import static android.net.ConnectivityManager.RESTRICT_BACKGROUND_STATUS_WHITELISTED; -import static android.os.Build.VERSION_CODES.LOLLIPOP; import static android.os.Build.VERSION_CODES.M; import static android.os.Build.VERSION_CODES.N; import static android.os.Build.VERSION_CODES.O; @@ -81,7 +80,6 @@ public class ShadowConnectivityManagerTest { } @Test - @Config(minSdk = LOLLIPOP) public void getNetworkInfo_shouldReturnSomeForAllNetworks() { Network[] allNetworks = connectivityManager.getAllNetworks(); for (Network network: allNetworks) { @@ -91,7 +89,6 @@ public class ShadowConnectivityManagerTest { } @Test - @Config(minSdk = LOLLIPOP) public void getNetworkInfo_shouldReturnAddedNetwork() { Network vpnNetwork = ShadowNetwork.newInstance(123); NetworkInfo vpnNetworkInfo = @@ -108,7 +105,6 @@ public class ShadowConnectivityManagerTest { } @Test - @Config(minSdk = LOLLIPOP) public void getNetworkInfo_shouldNotReturnRemovedNetwork() { Network wifiNetwork = ShadowNetwork.newInstance(ShadowConnectivityManager.NET_ID_WIFI); shadowOf(connectivityManager).removeNetwork(wifiNetwork); @@ -201,7 +197,6 @@ public class ShadowConnectivityManagerTest { } @Test - @Config(minSdk = LOLLIPOP) public void getAllNetworkInfo_shouldEqualGetAllNetworks() { // Update the active network so that we're no longer in the default state. NetworkInfo networkInfo = @@ -224,21 +219,18 @@ public class ShadowConnectivityManagerTest { } @Test - @Config(minSdk = LOLLIPOP) public void getAllNetworkInfo_nullIfNetworkNotActive() { shadowOf(connectivityManager).setDefaultNetworkActive(false); assertThat(connectivityManager.getAllNetworkInfo()).isNull(); } @Test - @Config(minSdk = LOLLIPOP) public void getAllNetworks_shouldReturnAllNetworks() { Network[] networks = connectivityManager.getAllNetworks(); assertThat(networks).asList().hasSize(2); } @Test - @Config(minSdk = LOLLIPOP) public void getAllNetworks_shouldReturnNoNetworksWhenCleared() { shadowOf(connectivityManager).clearAllNetworks(); Network[] networks = connectivityManager.getAllNetworks(); @@ -246,7 +238,6 @@ public class ShadowConnectivityManagerTest { } @Test - @Config(minSdk = LOLLIPOP) public void getAllNetworks_shouldReturnAddedNetworks() { // Let's start clear. shadowOf(connectivityManager).clearAllNetworks(); @@ -273,7 +264,6 @@ public class ShadowConnectivityManagerTest { } @Test - @Config(minSdk = LOLLIPOP) public void getAllNetworks_shouldNotReturnRemovedNetworks() { Network wifiNetwork = ShadowNetwork.newInstance(ShadowConnectivityManager.NET_ID_WIFI); shadowOf(connectivityManager).removeNetwork(wifiNetwork); @@ -318,7 +308,6 @@ public class ShadowConnectivityManagerTest { } @Test - @Config(minSdk = LOLLIPOP) public void getNetworkCallbacks_shouldHaveEmptyDefault() { assertThat(shadowOf(connectivityManager).getNetworkCallbacks()).isEmpty(); } @@ -337,7 +326,6 @@ public class ShadowConnectivityManagerTest { } @Test - @Config(minSdk = LOLLIPOP) public void requestNetwork_shouldAddCallback() { NetworkRequest.Builder builder = new NetworkRequest.Builder(); ConnectivityManager.NetworkCallback callback = createSimpleCallback(); @@ -346,7 +334,6 @@ public class ShadowConnectivityManagerTest { } @Test - @Config(minSdk = LOLLIPOP) public void registerCallback_shouldAddCallback() { NetworkRequest.Builder builder = new NetworkRequest.Builder(); ConnectivityManager.NetworkCallback callback = createSimpleCallback(); @@ -409,7 +396,6 @@ public class ShadowConnectivityManagerTest { } @Test - @Config(minSdk = LOLLIPOP) public void unregisterCallback_shouldRemoveCallbacks() { NetworkRequest.Builder builder = new NetworkRequest.Builder(); // Add two different callbacks. @@ -440,7 +426,6 @@ public class ShadowConnectivityManagerTest { assertThat(shadowOf(connectivityManager).getNetworkCallbackPendingIntents()).isEmpty(); } - @Config(minSdk = LOLLIPOP) @Test public void unregisterCallback_shouldNotAllowNullCallback() { // Verify that exception is thrown. @@ -500,13 +485,11 @@ public class ShadowConnectivityManagerTest { } @Test - @Config(minSdk = LOLLIPOP) public void isDefaultNetworkActive_defaultActive() { assertThat(shadowOf(connectivityManager).isDefaultNetworkActive()).isTrue(); } @Test - @Config(minSdk = LOLLIPOP) public void isDefaultNetworkActive_notActive() { shadowOf(connectivityManager).setDefaultNetworkActive(false); assertThat(shadowOf(connectivityManager).isDefaultNetworkActive()).isFalse(); @@ -520,7 +503,6 @@ public class ShadowConnectivityManagerTest { } @Test - @Config(minSdk = LOLLIPOP) public void addDefaultNetworkActiveListener_shouldAddListener() { ConnectivityManager.OnNetworkActiveListener listener1 = spy(createSimpleOnNetworkActiveListener()); @@ -536,7 +518,6 @@ public class ShadowConnectivityManagerTest { } @Test - @Config(minSdk = LOLLIPOP) public void removeDefaultNetworkActiveListener_shouldRemoveListeners() { // Add two different callbacks. ConnectivityManager.OnNetworkActiveListener listener1 = @@ -566,7 +547,6 @@ public class ShadowConnectivityManagerTest { verify(listener2).onNetworkActive(); } - @Config(minSdk = LOLLIPOP) @Test public void removeDefaultNetworkActiveListener_shouldNotAllowNullListener() { // Verify that exception is thrown. @@ -576,7 +556,6 @@ public class ShadowConnectivityManagerTest { } @Test - @Config(minSdk = LOLLIPOP) public void getNetworkCapabilities() { NetworkCapabilities nc = ShadowNetworkCapabilities.newInstance(); shadowOf(nc).addCapability(NetworkCapabilities.NET_CAPABILITY_MMS); @@ -592,7 +571,6 @@ public class ShadowConnectivityManagerTest { } @Test - @Config(minSdk = LOLLIPOP) public void getNetworkCapabilities_shouldReturnDefaultCapabilities() { for (Network network : connectivityManager.getAllNetworks()) { NetworkCapabilities nc = connectivityManager.getNetworkCapabilities(network); @@ -635,7 +613,6 @@ public class ShadowConnectivityManagerTest { } @Test - @Config(minSdk = LOLLIPOP) public void getLinkProperties() { Network network = shadowOf(connectivityManager).getActiveNetwork(); LinkProperties lp = ReflectionHelpers.callConstructor(LinkProperties.class); @@ -645,7 +622,6 @@ public class ShadowConnectivityManagerTest { } @Test - @Config(minSdk = LOLLIPOP) public void getLinkProperties_shouldReturnNull() { Network network = shadowOf(connectivityManager).getActiveNetwork(); shadowOf(connectivityManager).setLinkProperties(network, null); diff --git a/robolectric/src/test/java/org/robolectric/shadows/ShadowContextImplTest.java b/robolectric/src/test/java/org/robolectric/shadows/ShadowContextImplTest.java index 41d72849c..2a348b1ec 100644 --- a/robolectric/src/test/java/org/robolectric/shadows/ShadowContextImplTest.java +++ b/robolectric/src/test/java/org/robolectric/shadows/ShadowContextImplTest.java @@ -1,7 +1,6 @@ package org.robolectric.shadows; import static android.os.Build.VERSION_CODES.KITKAT; -import static android.os.Build.VERSION_CODES.LOLLIPOP; import static android.os.Build.VERSION_CODES.N; import static android.os.Build.VERSION_CODES.Q; import static android.os.Build.VERSION_CODES.TIRAMISU; @@ -188,7 +187,6 @@ public class ShadowContextImplTest { } @Test - @Config(minSdk = LOLLIPOP) public void bindServiceAsUser() { Intent serviceIntent = new Intent().setPackage("dummy.package"); ServiceConnection serviceConnection = buildServiceConnection(); @@ -203,7 +201,6 @@ public class ShadowContextImplTest { } @Test - @Config(minSdk = LOLLIPOP) public void bindServiceAsUser_shouldThrowOnImplicitIntent() { Intent serviceIntent = new Intent(); ServiceConnection serviceConnection = buildServiceConnection(); @@ -383,7 +380,6 @@ public class ShadowContextImplTest { } @Test - @Config(minSdk = LOLLIPOP) public void startActivityAsUser() { Intent intent = new Intent(); intent.addFlags(Intent.FLAG_ACTIVITY_NEW_TASK); diff --git a/robolectric/src/test/java/org/robolectric/shadows/ShadowCookieManagerTest.java b/robolectric/src/test/java/org/robolectric/shadows/ShadowCookieManagerTest.java index 660982c8e..07d1eb08a 100644 --- a/robolectric/src/test/java/org/robolectric/shadows/ShadowCookieManagerTest.java +++ b/robolectric/src/test/java/org/robolectric/shadows/ShadowCookieManagerTest.java @@ -1,6 +1,5 @@ package org.robolectric.shadows; -import static android.os.Build.VERSION_CODES.LOLLIPOP; import static com.google.common.truth.Truth.assertThat; import android.webkit.CookieManager; @@ -8,7 +7,6 @@ import androidx.test.ext.junit.runners.AndroidJUnit4; import com.google.common.base.Optional; import org.junit.Test; import org.junit.runner.RunWith; -import org.robolectric.annotation.Config; @RunWith(AndroidJUnit4.class) public class ShadowCookieManagerTest { @@ -36,7 +34,6 @@ public class ShadowCookieManagerTest { } @Test - @Config(minSdk = LOLLIPOP) public void shouldGetCookieWhenSetAsyncWithNormalCallback() { CookieManager cookieManager = CookieManager.getInstance(); String url = "http://www.google.com"; @@ -54,7 +51,6 @@ public class ShadowCookieManagerTest { } @Test - @Config(minSdk = LOLLIPOP) public void shouldGetCookieWhenSetAsyncWithNullCallback() { CookieManager cookieManager = CookieManager.getInstance(); String url = "http://www.google.com"; @@ -207,7 +203,6 @@ public class ShadowCookieManagerTest { } @Test - @Config(minSdk = LOLLIPOP) public void shouldRemoveAllCookiesWithCallback() { cookieManager.setCookie(url, "name=value; Expires=Wed, 09 Jun 2121 10:18:14 GMT"); cookieManager.setCookie(url, "name2=value2;"); @@ -237,7 +232,6 @@ public class ShadowCookieManagerTest { } @Test - @Config(minSdk = LOLLIPOP) public void shouldRemoveSessionCookiesWithNormalCallback() { cookieManager.setCookie(url, "name=value; Expires=Wed, 09 Jun 2121 10:18:14 GMT"); cookieManager.setCookie(url, "name2=value2;"); @@ -251,7 +245,6 @@ public class ShadowCookieManagerTest { } @Test - @Config(minSdk = LOLLIPOP) public void shouldRemoveSessionCookiesWithNullCallback() { cookieManager.setCookie(url, "name=value; Expires=Wed, 09 Jun 2121 10:18:14 GMT"); cookieManager.setCookie(url, "name2=value2;"); @@ -261,7 +254,6 @@ public class ShadowCookieManagerTest { } @Test - @Config(minSdk = LOLLIPOP) public void shouldRemoveSessionCookiesWhenSessionCookieIsNoPresent() { cookieManager.setCookie(url, "name=value; Expires=Wed, 09 Jun 2121 10:18:14 GMT"); diff --git a/robolectric/src/test/java/org/robolectric/shadows/ShadowDebugTest.java b/robolectric/src/test/java/org/robolectric/shadows/ShadowDebugTest.java index 1b5a52a7f..048e625a9 100644 --- a/robolectric/src/test/java/org/robolectric/shadows/ShadowDebugTest.java +++ b/robolectric/src/test/java/org/robolectric/shadows/ShadowDebugTest.java @@ -1,6 +1,5 @@ package org.robolectric.shadows; -import static android.os.Build.VERSION_CODES.LOLLIPOP; import static android.os.Build.VERSION_CODES.M; import static com.google.common.truth.Truth.assertThat; import static org.junit.Assert.fail; @@ -46,7 +45,6 @@ public class ShadowDebugTest { } @Test - @Config(minSdk = LOLLIPOP) public void startStopTracingSamplingShouldWriteFile() { Debug.startMethodTracingSampling(TRACE_FILENAME, 100, 100); Debug.stopMethodTracing(); diff --git a/robolectric/src/test/java/org/robolectric/shadows/ShadowDevicePolicyManagerTest.java b/robolectric/src/test/java/org/robolectric/shadows/ShadowDevicePolicyManagerTest.java index 0767e8b3d..564ceb778 100644 --- a/robolectric/src/test/java/org/robolectric/shadows/ShadowDevicePolicyManagerTest.java +++ b/robolectric/src/test/java/org/robolectric/shadows/ShadowDevicePolicyManagerTest.java @@ -107,7 +107,6 @@ public final class ShadowDevicePolicyManagerTest { } @Test - @Config(minSdk = LOLLIPOP) public void isDeviceOwnerShouldReturnFalseForProfileOwner() { // GIVEN an test package which is the profile owner app of the device String testPackage = testComponent.getPackageName(); @@ -167,7 +166,6 @@ public final class ShadowDevicePolicyManagerTest { } @Test - @Config(minSdk = LOLLIPOP) public void isProfileOwnerAppShouldReturnFalseForNonProfileOwnerApp() { // GIVEN an test package which is not the profile owner app of the device String testPackage = testComponent.getPackageName(); @@ -178,7 +176,6 @@ public final class ShadowDevicePolicyManagerTest { } @Test - @Config(minSdk = LOLLIPOP) public void isProfileOwnerShouldReturnFalseForDeviceOwner() { // GIVEN an test package which is the device owner app of the device String testPackage = testComponent.getPackageName(); @@ -190,7 +187,6 @@ public final class ShadowDevicePolicyManagerTest { } @Test - @Config(minSdk = LOLLIPOP) public void isProfileOwnerShouldReturnTrueForProfileOwner() { // GIVEN an test package which is the profile owner app of the device String testPackage = testComponent.getPackageName(); @@ -202,7 +198,6 @@ public final class ShadowDevicePolicyManagerTest { } @Test - @Config(minSdk = LOLLIPOP) public void getProfileOwnerShouldReturnDeviceOwnerComponentName() { // GIVEN an test package which is the profile owner app of the device shadowOf(devicePolicyManager).setProfileOwner(testComponent); @@ -213,7 +208,6 @@ public final class ShadowDevicePolicyManagerTest { } @Test - @Config(minSdk = LOLLIPOP) public void getProfileOwnerShouldReturnNullWhenThereIsNoProfileOwner() { // WHEN DevicePolicyManager#getProfileOwner is called without a profile owner // THEN the method should return null @@ -296,7 +290,6 @@ public final class ShadowDevicePolicyManagerTest { } @Test - @Config(minSdk = LOLLIPOP) public void getActiveAdminsShouldReturnProfileOwner() { // GIVEN an test package which is the profile owner app of the device shadowOf(devicePolicyManager).setProfileOwner(testComponent); @@ -307,7 +300,6 @@ public final class ShadowDevicePolicyManagerTest { } @Test - @Config(minSdk = LOLLIPOP) public void addUserRestrictionShouldWorkAsIntendedForDeviceOwner() { // GIVEN a user restriction to set String restrictionKey = "restriction key"; @@ -324,7 +316,6 @@ public final class ShadowDevicePolicyManagerTest { } @Test - @Config(minSdk = LOLLIPOP) public void addUserRestrictionShouldWorkAsIntendedForProfileOwner() { // GIVEN a user restriction to set String restrictionKey = "restriction key"; @@ -341,7 +332,6 @@ public final class ShadowDevicePolicyManagerTest { } @Test - @Config(minSdk = LOLLIPOP) public void clearUserRestrictionShouldWorkAsIntendedForActiveAdmins() { // GIVEN the caller is the device owner, and thus an active admin shadowOf(devicePolicyManager).setDeviceOwner(testComponent); @@ -359,7 +349,6 @@ public final class ShadowDevicePolicyManagerTest { } @Test - @Config(minSdk = LOLLIPOP) public void isApplicationHiddenShouldReturnTrueForNotExistingApps() { // GIVEN the caller is the device owner, and thus an active admin shadowOf(devicePolicyManager).setDeviceOwner(testComponent); @@ -373,7 +362,6 @@ public final class ShadowDevicePolicyManagerTest { } @Test - @Config(minSdk = LOLLIPOP) public void isApplicationHiddenShouldReturnFalseForAppsByDefault() { // GIVEN the caller is the device owner, and thus an active admin shadowOf(devicePolicyManager).setDeviceOwner(testComponent); @@ -388,7 +376,6 @@ public final class ShadowDevicePolicyManagerTest { } @Test - @Config(minSdk = LOLLIPOP) public void isApplicationHiddenShouldReturnTrueForHiddenApps() { // GIVEN the caller is the device owner, and thus an active admin shadowOf(devicePolicyManager).setDeviceOwner(testComponent); @@ -404,7 +391,6 @@ public final class ShadowDevicePolicyManagerTest { } @Test - @Config(minSdk = LOLLIPOP) public void isApplicationHiddenShouldReturnFalseForNonHiddenApps() { // GIVEN the caller is the device owner, and thus an active admin shadowOf(devicePolicyManager).setDeviceOwner(testComponent); @@ -420,7 +406,6 @@ public final class ShadowDevicePolicyManagerTest { } @Test - @Config(minSdk = LOLLIPOP) public void setApplicationHiddenShouldBeAbleToUnhideHiddenApps() { // GIVEN the caller is the device owner, and thus an active admin shadowOf(devicePolicyManager).setDeviceOwner(testComponent); @@ -438,7 +423,6 @@ public final class ShadowDevicePolicyManagerTest { } @Test - @Config(minSdk = LOLLIPOP) public void setApplicationHiddenShouldReturnFalseForNotExistingApps() { // GIVEN the caller is the device owner, and thus an active admin shadowOf(devicePolicyManager).setDeviceOwner(testComponent); @@ -451,7 +435,6 @@ public final class ShadowDevicePolicyManagerTest { } @Test - @Config(minSdk = LOLLIPOP) public void setApplicationHiddenShouldFailForNeitherOwnerNorDelegated() { // GIVEN the caller is the device owner, and thus an active admin shadowOf(devicePolicyManager).setDeviceOwner(testComponent); @@ -479,7 +462,6 @@ public final class ShadowDevicePolicyManagerTest { } @Test - @Config(minSdk = LOLLIPOP) public void setApplicationHiddenShouldFailForNeitherOwnerNorDelegatedAdminIsNull() { // GIVEN the caller is the device owner, and thus an active admin shadowOf(devicePolicyManager).setDeviceOwner(testComponent); @@ -557,7 +539,6 @@ public final class ShadowDevicePolicyManagerTest { } @Test - @Config(minSdk = LOLLIPOP) public void wasPackageEverHiddenShouldReturnFalseForPackageNeverHidden() { // GIVEN the caller is the device owner, and thus an active admin shadowOf(devicePolicyManager).setDeviceOwner(testComponent); @@ -572,7 +553,6 @@ public final class ShadowDevicePolicyManagerTest { } @Test - @Config(minSdk = LOLLIPOP) public void wasPackageEverHiddenShouldReturnTrueForPackageWhichIsHidden() { // GIVEN the caller is the device owner, and thus an active admin shadowOf(devicePolicyManager).setDeviceOwner(testComponent); @@ -588,7 +568,6 @@ public final class ShadowDevicePolicyManagerTest { } @Test - @Config(minSdk = LOLLIPOP) public void wasPackageEverHiddenShouldReturnTrueForPackageWhichWasHidden() { // GIVEN the caller is the device owner, and thus an active admin shadowOf(devicePolicyManager).setDeviceOwner(testComponent); @@ -605,7 +584,6 @@ public final class ShadowDevicePolicyManagerTest { } @Test - @Config(minSdk = LOLLIPOP) public void enableSystemAppShouldWorkForActiveAdmins() { // GIVEN the caller is the device owner, and thus an active admin shadowOf(devicePolicyManager).setDeviceOwner(testComponent); @@ -621,7 +599,6 @@ public final class ShadowDevicePolicyManagerTest { } @Test - @Config(minSdk = LOLLIPOP) public void isUninstallBlockedShouldReturnFalseForAppsNeverBeingBlocked() { // GIVEN the caller is the device owner, and thus an active admin shadowOf(devicePolicyManager).setDeviceOwner(testComponent); @@ -635,7 +612,6 @@ public final class ShadowDevicePolicyManagerTest { } @Test - @Config(minSdk = LOLLIPOP) public void isUninstallBlockedShouldReturnTrueForAppsBeingUnblocked() { // GIVEN the caller is the device owner, and thus an active admin shadowOf(devicePolicyManager).setDeviceOwner(testComponent); @@ -650,7 +626,6 @@ public final class ShadowDevicePolicyManagerTest { } @Test - @Config(minSdk = LOLLIPOP) public void isUninstallBlockedShouldReturnFalseForAppsBeingBlocked() { // GIVEN the caller is the device owner, and thus an active admin shadowOf(devicePolicyManager).setDeviceOwner(testComponent); @@ -710,7 +685,6 @@ public final class ShadowDevicePolicyManagerTest { } @Test - @Config(minSdk = LOLLIPOP) public void setApplicationRestrictionsShouldWorkAsIntendedForDeviceOwner() { // GIVEN the caller is the device owner shadowOf(devicePolicyManager).setDeviceOwner(testComponent); @@ -732,7 +706,6 @@ public final class ShadowDevicePolicyManagerTest { } @Test - @Config(minSdk = LOLLIPOP) public void setApplicationRestrictionsShouldWorkAsIntendedForProfileOwner() { // GIVEN the caller is the profile owner shadowOf(devicePolicyManager).setProfileOwner(testComponent); @@ -754,7 +727,6 @@ public final class ShadowDevicePolicyManagerTest { } @Test - @Config(minSdk = LOLLIPOP) public void setApplicationRestrictionsShouldFailForNeitherOwnerNorDelegated() { // GIVEN the caller is the device owner shadowOf(devicePolicyManager).setDeviceOwner(testComponent); @@ -779,7 +751,6 @@ public final class ShadowDevicePolicyManagerTest { } @Test - @Config(minSdk = LOLLIPOP) public void setApplicationRestrictionsShouldFailForNeitherOwnerNorDelegatedAdminIsNull() { // GIVEN the caller is the device owner shadowOf(devicePolicyManager).setDeviceOwner(testComponent); @@ -854,7 +825,6 @@ public final class ShadowDevicePolicyManagerTest { } @Test - @Config(minSdk = LOLLIPOP) public void getApplicationRestrictionsShouldReturnEmptyBundleIfAppHasNone() { // GIVEN the caller is the device owner shadowOf(devicePolicyManager).setDeviceOwner(testComponent); @@ -870,7 +840,6 @@ public final class ShadowDevicePolicyManagerTest { } @Test - @Config(minSdk = LOLLIPOP) public void getAccountTypesWithManagementDisabledShouldReturnNothingWhenNoAccountIsDislabed() { // GIVEN no account type has ever been disabled @@ -881,7 +850,6 @@ public final class ShadowDevicePolicyManagerTest { } @Test - @Config(minSdk = LOLLIPOP) public void getAccountTypesWithManagementDisabledShouldReturnDisabledAccountTypesIfAny() { // GIVEN the caller is the device owner shadowOf(devicePolicyManager).setDeviceOwner(testComponent); @@ -898,7 +866,6 @@ public final class ShadowDevicePolicyManagerTest { } @Test - @Config(minSdk = LOLLIPOP) public void getAccountTypesWithManagementDisabledShouldNotReturnReenabledAccountTypesIfAny() { // GIVEN the caller is the device owner shadowOf(devicePolicyManager).setDeviceOwner(testComponent); @@ -1056,7 +1023,6 @@ public final class ShadowDevicePolicyManagerTest { } @Test - @Config(minSdk = LOLLIPOP) public void getAutoTimeRequiredShouldWorkAsIntendedForDeviceOwner() { // GIVEN the caller is the device owner shadowOf(devicePolicyManager).setDeviceOwner(testComponent); @@ -1069,7 +1035,6 @@ public final class ShadowDevicePolicyManagerTest { } @Test - @Config(minSdk = LOLLIPOP) public void getAutoTimeRequiredShouldWorkAsIntendedForProfileOwner() { // GIVEN the caller is the profile owner shadowOf(devicePolicyManager).setProfileOwner(testComponent); @@ -1082,7 +1047,6 @@ public final class ShadowDevicePolicyManagerTest { } @Test - @Config(minSdk = LOLLIPOP) public void getAutoTimeRequiredShouldReturnFalseIfNotSet() { // GIVEN the caller is the device owner shadowOf(devicePolicyManager).setDeviceOwner(testComponent); @@ -1235,7 +1199,6 @@ public final class ShadowDevicePolicyManagerTest { } @Test - @Config(minSdk = LOLLIPOP) public void getPermittedAccessibilityServicesShouldWorkAsIntendedForDeviceOwner() { List<String> accessibilityServices = Arrays.asList("com.example.accessibility1", "com.example.accessibility2"); @@ -1252,7 +1215,6 @@ public final class ShadowDevicePolicyManagerTest { } @Test - @Config(minSdk = LOLLIPOP) public void getPermittedAccessibilityServicesShouldWorkAsIntendedForProfileOwner() { List<String> accessibilityServices = new ArrayList<>(); @@ -1267,7 +1229,6 @@ public final class ShadowDevicePolicyManagerTest { } @Test - @Config(minSdk = LOLLIPOP) public void getPermittedAccessibilityServicesShouldReturnNullIfNullIsSet() { List<String> accessibilityServices = null; @@ -1282,7 +1243,6 @@ public final class ShadowDevicePolicyManagerTest { } @Test - @Config(minSdk = LOLLIPOP) public void getPermittedInputMethodsShouldWorkAsIntendedForDeviceOwner() { List<String> inputMethods = Arrays.asList("com.example.input1", "com.example.input2"); @@ -1297,7 +1257,6 @@ public final class ShadowDevicePolicyManagerTest { } @Test - @Config(minSdk = LOLLIPOP) public void getPermittedInputMethodsShouldWorkAsIntendedForProfileOwner() { List<String> inputMethods = new ArrayList<>(); @@ -1312,7 +1271,6 @@ public final class ShadowDevicePolicyManagerTest { } @Test - @Config(minSdk = LOLLIPOP) public void getPermittedInputMethodsShouldReturnNullIfNullIsSet() { List<String> inputMethods = null; @@ -1925,7 +1883,6 @@ public final class ShadowDevicePolicyManagerTest { } @Test - @Config(minSdk = LOLLIPOP) public void getProfileOwnerNameAsUser() { int userId = 0; String orgName = "organization"; @@ -1937,7 +1894,6 @@ public final class ShadowDevicePolicyManagerTest { } @Test - @Config(minSdk = LOLLIPOP) public void setPersistentPreferrecActivity_exists() { ComponentName randomActivity = new ComponentName("random.package", "Activity"); shadowOf(devicePolicyManager).setDeviceOwner(testComponent); @@ -1973,7 +1929,6 @@ public final class ShadowDevicePolicyManagerTest { } @Test - @Config(minSdk = LOLLIPOP) public void clearPersistentPreferredActivity_packageNotAdded() { shadowOf(devicePolicyManager).setDeviceOwner(testComponent); devicePolicyManager.clearPackagePersistentPreferredActivities(testComponent, "package"); @@ -1987,7 +1942,6 @@ public final class ShadowDevicePolicyManagerTest { } @Test - @Config(minSdk = LOLLIPOP) public void clearPersistentPreferredActivity_packageAdded() { shadowOf(devicePolicyManager).setDeviceOwner(testComponent); ComponentName randomActivity = new ComponentName("random.package", "Activity"); @@ -2127,7 +2081,6 @@ public final class ShadowDevicePolicyManagerTest { } @Test - @Config(minSdk = LOLLIPOP) public void getLockTaskPackages_notOwner() { try { devicePolicyManager.getLockTaskPackages(testComponent); @@ -2138,7 +2091,6 @@ public final class ShadowDevicePolicyManagerTest { } @Test - @Config(minSdk = LOLLIPOP) public void setLockTaskPackages_notOwner() { try { devicePolicyManager.setLockTaskPackages(testComponent, new String[] {"allowed.package"}); @@ -2148,7 +2100,6 @@ public final class ShadowDevicePolicyManagerTest { } @Test - @Config(minSdk = LOLLIPOP) public void getSetLockTaskPackages() { shadowOf(devicePolicyManager).setProfileOwner(testComponent); @@ -2162,7 +2113,6 @@ public final class ShadowDevicePolicyManagerTest { } @Test - @Config(minSdk = LOLLIPOP) public void isLockTaskPermitted() { assertThat(devicePolicyManager.isLockTaskPermitted("allowed.package")).isFalse(); diff --git a/robolectric/src/test/java/org/robolectric/shadows/ShadowDisplayTest.java b/robolectric/src/test/java/org/robolectric/shadows/ShadowDisplayTest.java index 361312110..d13dc511e 100644 --- a/robolectric/src/test/java/org/robolectric/shadows/ShadowDisplayTest.java +++ b/robolectric/src/test/java/org/robolectric/shadows/ShadowDisplayTest.java @@ -1,6 +1,5 @@ package org.robolectric.shadows; -import static android.os.Build.VERSION_CODES.LOLLIPOP; import static android.os.Build.VERSION_CODES.M; import static android.os.Build.VERSION_CODES.N; import static android.os.Build.VERSION_CODES.Q; @@ -91,7 +90,6 @@ public class ShadowDisplayTest { } @Test - @Config(minSdk = LOLLIPOP) public void stateChangeShouldApplyToOtherInstancesOfSameDisplay_postKitKatFields() { shadow.setState(Display.STATE_DOZE_SUSPEND); diff --git a/robolectric/src/test/java/org/robolectric/shadows/ShadowDrawableTest.java b/robolectric/src/test/java/org/robolectric/shadows/ShadowDrawableTest.java index 504993c4b..ba9fa2b78 100644 --- a/robolectric/src/test/java/org/robolectric/shadows/ShadowDrawableTest.java +++ b/robolectric/src/test/java/org/robolectric/shadows/ShadowDrawableTest.java @@ -1,7 +1,5 @@ package org.robolectric.shadows; -import static android.os.Build.VERSION_CODES.KITKAT_WATCH; -import static android.os.Build.VERSION_CODES.LOLLIPOP; import static com.google.common.truth.Truth.assertThat; import static com.google.common.truth.TruthJUnit.assume; import static org.junit.Assert.assertNotNull; @@ -14,7 +12,6 @@ import android.graphics.BitmapFactory; import android.graphics.Canvas; import android.graphics.ColorFilter; import android.graphics.Rect; -import android.graphics.drawable.BitmapDrawable; import android.graphics.drawable.Drawable; import android.graphics.drawable.VectorDrawable; import android.os.Build; @@ -135,16 +132,6 @@ public class ShadowDrawableTest { } @Test - @Config(maxSdk = KITKAT_WATCH) - public void testGetBitmapOrVectorDrawableAt19() { - // at API 21+ and mdpi, the drawable-anydpi-v21/image_or_vector.xml should be loaded instead - // of drawable/image_or_vector.png - final Drawable aDrawable = context.getResources().getDrawable(R.drawable.an_image_or_vector); - assertThat(aDrawable).isInstanceOf(BitmapDrawable.class); - } - - @Test - @Config(minSdk = LOLLIPOP) public void testGetBitmapOrVectorDrawableAt21() { final Drawable aDrawable = context.getResources().getDrawable(R.drawable.an_image_or_vector); assertThat(aDrawable).isInstanceOf(VectorDrawable.class); diff --git a/robolectric/src/test/java/org/robolectric/shadows/ShadowEnvironmentTest.java b/robolectric/src/test/java/org/robolectric/shadows/ShadowEnvironmentTest.java index 3f5d8ea78..cb29f8677 100644 --- a/robolectric/src/test/java/org/robolectric/shadows/ShadowEnvironmentTest.java +++ b/robolectric/src/test/java/org/robolectric/shadows/ShadowEnvironmentTest.java @@ -151,7 +151,6 @@ public class ShadowEnvironmentTest { } @Test - @Config(minSdk = LOLLIPOP) public void isExternalStorageRemovable_shouldReturnSavedValue() { final File file = new File("/mnt/media/file"); assertThat(Environment.isExternalStorageRemovable(file)).isFalse(); @@ -160,7 +159,6 @@ public class ShadowEnvironmentTest { } @Test - @Config(minSdk = LOLLIPOP) public void isExternalStorageEmulated_shouldReturnSavedValue() { final File file = new File("/mnt/media/file"); assertThat(Environment.isExternalStorageEmulated(file)).isFalse(); @@ -178,7 +176,6 @@ public class ShadowEnvironmentTest { } @Test - @Config(minSdk = LOLLIPOP) public void storageIsLazy() { assertNull(ShadowEnvironment.EXTERNAL_CACHE_DIR); assertNull(ShadowEnvironment.EXTERNAL_FILES_DIR); @@ -191,7 +188,6 @@ public class ShadowEnvironmentTest { } @Test - @Config(minSdk = LOLLIPOP) public void reset_shouldClearRemovableFiles() { final File file = new File("foo"); ShadowEnvironment.setExternalStorageRemovable(file, true); @@ -202,7 +198,6 @@ public class ShadowEnvironmentTest { } @Test - @Config(minSdk = LOLLIPOP) public void reset_shouldClearEmulatedFiles() { final File file = new File("foo"); ShadowEnvironment.setExternalStorageEmulated(file, true); @@ -213,7 +208,6 @@ public class ShadowEnvironmentTest { } @Test - @Config(minSdk = LOLLIPOP) public void reset_shouldResetExternalStorageState() { ShadowEnvironment.setExternalStorageState(Environment.MEDIA_UNKNOWN); ShadowEnvironment.reset(); diff --git a/robolectric/src/test/java/org/robolectric/shadows/ShadowICUTest.java b/robolectric/src/test/java/org/robolectric/shadows/ShadowICUTest.java index 28a990362..31b679826 100644 --- a/robolectric/src/test/java/org/robolectric/shadows/ShadowICUTest.java +++ b/robolectric/src/test/java/org/robolectric/shadows/ShadowICUTest.java @@ -1,6 +1,5 @@ package org.robolectric.shadows; -import static android.os.Build.VERSION_CODES.LOLLIPOP; import static android.os.Build.VERSION_CODES.M; import static android.os.Build.VERSION_CODES.N; import static com.google.common.truth.Truth.assertThat; @@ -40,50 +39,42 @@ public class ShadowICUTest { } @Test - @Config(minSdk = LOLLIPOP) public void getBestDateTimePattern_returnsReasonableValue() { assertThat(ICU.getBestDateTimePattern("hm", null)).isEqualTo("hm"); } @Test - @Config(minSdk = LOLLIPOP) public void getBestDateTimePattern_returns_jmm_US() { assertThat(ICU.getBestDateTimePattern("jmm", Locale.US)).isEqualTo("h:mm a"); } @Test - @Config(minSdk = LOLLIPOP) public void getBestDateTimePattern_returns_jmm_UK() { assertThat(ICU.getBestDateTimePattern("jmm", Locale.UK)).isEqualTo("H:mm"); } @Test - @Config(minSdk = LOLLIPOP) public void getBestDateTimePattern_returns_jmm_ptBR() { assertThat(ICU.getBestDateTimePattern("jmm", new Locale("pt", "BR"))).isEqualTo("H:mm"); } @Test - @Config(minSdk = LOLLIPOP) public void getBestDateTimePattern_returns_yMMMd_ptBR() { assertThat(ICU.getBestDateTimePattern("yMMMd", new Locale("pt", "BR"))).isEqualTo("MMM d, y"); } @Test - @Config(minSdk = LOLLIPOP) public void getBestDateTimePattern_returns_yMMMMEEEEd_ptBR() { assertThat(ICU.getBestDateTimePattern("yMMMMEEEEd", new Locale("pt", "BR"))) .isEqualTo("EEEE, MMMM d, y"); } @Test - @Config(minSdk = LOLLIPOP) public void getBestDateTimePattern_returns_yMMMM_ptBR() { assertThat(ICU.getBestDateTimePattern("yMMMM", new Locale("pt", "BR"))).isEqualTo("MMMM y"); } @Test - @Config(minSdk = LOLLIPOP) public void datePickerShouldNotCrashWhenAskingForBestDateTimePattern() { ActivityController<DatePickerActivity> activityController = Robolectric.buildActivity(DatePickerActivity.class); diff --git a/robolectric/src/test/java/org/robolectric/shadows/ShadowJobSchedulerTest.java b/robolectric/src/test/java/org/robolectric/shadows/ShadowJobSchedulerTest.java index 06d0d26e3..082d7a6e0 100644 --- a/robolectric/src/test/java/org/robolectric/shadows/ShadowJobSchedulerTest.java +++ b/robolectric/src/test/java/org/robolectric/shadows/ShadowJobSchedulerTest.java @@ -1,6 +1,5 @@ package org.robolectric.shadows; -import static android.os.Build.VERSION_CODES.LOLLIPOP; import static android.os.Build.VERSION_CODES.N; import static android.os.Build.VERSION_CODES.O; import static android.os.Build.VERSION_CODES.S; @@ -22,7 +21,6 @@ import org.junit.runner.RunWith; import org.robolectric.annotation.Config; @RunWith(AndroidJUnit4.class) -@Config(minSdk = LOLLIPOP) public class ShadowJobSchedulerTest { private JobScheduler jobScheduler; diff --git a/robolectric/src/test/java/org/robolectric/shadows/ShadowJobServiceTest.java b/robolectric/src/test/java/org/robolectric/shadows/ShadowJobServiceTest.java index 2e549b727..4776c2913 100644 --- a/robolectric/src/test/java/org/robolectric/shadows/ShadowJobServiceTest.java +++ b/robolectric/src/test/java/org/robolectric/shadows/ShadowJobServiceTest.java @@ -1,6 +1,5 @@ package org.robolectric.shadows; -import static android.os.Build.VERSION_CODES.LOLLIPOP; import static com.google.common.truth.Truth.assertThat; import static org.robolectric.Shadows.shadowOf; @@ -16,7 +15,6 @@ import org.robolectric.annotation.Config; /** Robolectric test for {@link ShadowJobService}. */ @RunWith(AndroidJUnit4.class) -@Config(minSdk = LOLLIPOP) public class ShadowJobServiceTest { private JobService jobService; @Mock private JobParameters params; diff --git a/robolectric/src/test/java/org/robolectric/shadows/ShadowLegacyMessageTest.java b/robolectric/src/test/java/org/robolectric/shadows/ShadowLegacyMessageTest.java index a1f1c2d7d..f57b20561 100644 --- a/robolectric/src/test/java/org/robolectric/shadows/ShadowLegacyMessageTest.java +++ b/robolectric/src/test/java/org/robolectric/shadows/ShadowLegacyMessageTest.java @@ -1,7 +1,5 @@ package org.robolectric.shadows; -import static android.os.Build.VERSION_CODES.KITKAT_WATCH; -import static android.os.Build.VERSION_CODES.LOLLIPOP; import static com.google.common.truth.Truth.assertThat; import static com.google.common.truth.Truth.assertWithMessage; import static org.robolectric.Shadows.shadowOf; @@ -13,7 +11,6 @@ import androidx.test.ext.junit.runners.AndroidJUnit4; import org.junit.Test; import org.junit.runner.RunWith; import org.robolectric.Robolectric; -import org.robolectric.annotation.Config; import org.robolectric.annotation.LooperMode; import org.robolectric.annotation.LooperMode.Mode; import org.robolectric.shadow.api.Shadow; @@ -184,13 +181,6 @@ public class ShadowLegacyMessageTest { } @Test - @Config(maxSdk = KITKAT_WATCH) - public void recycle_shouldInvokeRealObject19() { - recycle_shouldInvokeRealObject("recycle"); - } - - @Test - @Config(minSdk = LOLLIPOP) public void recycle_shouldInvokeRealObject21() { recycle_shouldInvokeRealObject("recycleUnchecked"); } @@ -201,19 +191,12 @@ public class ShadowLegacyMessageTest { ReflectionHelpers.callInstanceMethod(msg, recycleMethod); assertThat(msg.what).isEqualTo(0); } - - @Test - @Config(maxSdk = KITKAT_WATCH) - public void recycle_shouldRemoveMessageFromScheduler19() { - recycle_shouldRemoveMessageFromScheduler(); - } - + @Test - @Config(minSdk = LOLLIPOP) public void recycle_shouldRemoveMessageFromScheduler21() { recycle_shouldRemoveMessageFromScheduler(); } - + private void recycle_shouldRemoveMessageFromScheduler() { ShadowLooper.pauseMainLooper(); Handler h = new Handler(); diff --git a/robolectric/src/test/java/org/robolectric/shadows/ShadowLocaleDataTest.java b/robolectric/src/test/java/org/robolectric/shadows/ShadowLocaleDataTest.java index f039fd76e..f1c4deb4d 100644 --- a/robolectric/src/test/java/org/robolectric/shadows/ShadowLocaleDataTest.java +++ b/robolectric/src/test/java/org/robolectric/shadows/ShadowLocaleDataTest.java @@ -1,6 +1,5 @@ package org.robolectric.shadows; -import static android.os.Build.VERSION_CODES.LOLLIPOP; import static android.os.Build.VERSION_CODES.LOLLIPOP_MR1; import static android.os.Build.VERSION_CODES.M; import static android.os.Build.VERSION_CODES.R; @@ -154,7 +153,6 @@ public class ShadowLocaleDataTest { } @Test - @Config(minSdk = LOLLIPOP) public void shouldSupportLocaleEn_US_since_lollipop() { LocaleData localeData = LocaleData.get(Locale.US); LocaleDataReflector localeDataReflector = reflector(LocaleDataReflector.class, localeData); diff --git a/robolectric/src/test/java/org/robolectric/shadows/ShadowMatrixTest.java b/robolectric/src/test/java/org/robolectric/shadows/ShadowMatrixTest.java index 18d4527fc..aae056334 100644 --- a/robolectric/src/test/java/org/robolectric/shadows/ShadowMatrixTest.java +++ b/robolectric/src/test/java/org/robolectric/shadows/ShadowMatrixTest.java @@ -1,6 +1,5 @@ package org.robolectric.shadows; -import static android.os.Build.VERSION_CODES.LOLLIPOP; import static com.google.common.truth.Truth.assertThat; import android.graphics.Matrix; @@ -9,7 +8,6 @@ import android.graphics.RectF; import androidx.test.ext.junit.runners.AndroidJUnit4; import org.junit.Test; import org.junit.runner.RunWith; -import org.robolectric.annotation.Config; import org.robolectric.shadow.api.Shadow; @RunWith(AndroidJUnit4.class) @@ -111,7 +109,6 @@ public class ShadowMatrixTest { } @Test - @Config(minSdk = LOLLIPOP) public void testIsAffine() { final Matrix matrix = new Matrix(); assertThat(matrix.isAffine()).isTrue(); diff --git a/robolectric/src/test/java/org/robolectric/shadows/ShadowMediaCodecTest.java b/robolectric/src/test/java/org/robolectric/shadows/ShadowMediaCodecTest.java index 1fcfcc6ba..7dc00c82e 100644 --- a/robolectric/src/test/java/org/robolectric/shadows/ShadowMediaCodecTest.java +++ b/robolectric/src/test/java/org/robolectric/shadows/ShadowMediaCodecTest.java @@ -1,6 +1,5 @@ package org.robolectric.shadows; -import static android.os.Build.VERSION_CODES.LOLLIPOP; import static com.google.common.truth.Truth.assertThat; import static java.util.Arrays.copyOfRange; import static java.util.Collections.max; @@ -33,13 +32,11 @@ import org.junit.Test; import org.junit.runner.RunWith; import org.mockito.ArgumentCaptor; import org.mockito.verification.VerificationMode; -import org.robolectric.annotation.Config; import org.robolectric.shadows.ShadowMediaCodec.CodecConfig; import org.robolectric.shadows.ShadowMediaCodec.CodecConfig.Codec; /** Tests for {@link ShadowMediaCodec}. */ @RunWith(AndroidJUnit4.class) -@Config(minSdk = LOLLIPOP) public final class ShadowMediaCodecTest { private static final String AUDIO_MIME = "audio/fake"; private static final String AUDIO_DECODER_NAME = "audio-fake.decoder"; diff --git a/robolectric/src/test/java/org/robolectric/shadows/ShadowMediaControllerTest.java b/robolectric/src/test/java/org/robolectric/shadows/ShadowMediaControllerTest.java index 772d89a66..58ba79717 100644 --- a/robolectric/src/test/java/org/robolectric/shadows/ShadowMediaControllerTest.java +++ b/robolectric/src/test/java/org/robolectric/shadows/ShadowMediaControllerTest.java @@ -1,6 +1,5 @@ package org.robolectric.shadows; -import static android.os.Build.VERSION_CODES.LOLLIPOP; import static android.os.Build.VERSION_CODES.Q; import static android.os.Looper.getMainLooper; import static com.google.common.truth.Truth.assertThat; @@ -31,7 +30,6 @@ import org.junit.Test; import org.junit.runner.RunWith; import org.mockito.ArgumentCaptor; import org.robolectric.RuntimeEnvironment; -import org.robolectric.annotation.Config; import org.robolectric.shadow.api.Shadow; import org.robolectric.util.ReflectionHelpers; import org.robolectric.util.ReflectionHelpers.ClassParameter; @@ -66,14 +64,12 @@ public final class ShadowMediaControllerTest { } @Test - @Config(minSdk = LOLLIPOP) public void setPackageName() { shadowMediaController.setPackageName(testPackageName); assertEquals(testPackageName, mediaController.getPackageName()); } @Test - @Config(minSdk = LOLLIPOP) public void setAndGetPlaybackState() { PlaybackState playbackState = createPlaybackState(); shadowMediaController.setPlaybackState(playbackState); @@ -81,7 +77,6 @@ public final class ShadowMediaControllerTest { } @Test - @Config(minSdk = LOLLIPOP) public void setAndGetMetadata() { MediaMetadata metadata = createMetadata("test"); shadowMediaController.setMetadata(metadata); @@ -89,7 +84,6 @@ public final class ShadowMediaControllerTest { } @Test - @Config(minSdk = LOLLIPOP) public void setAndGetPlaybackInfo() { PlaybackInfo playbackInfo = PlaybackInfoBuilder.newBuilder() @@ -104,7 +98,6 @@ public final class ShadowMediaControllerTest { } @Test - @Config(minSdk = LOLLIPOP) public void setInvalidRatingType() { int ratingType = Rating.RATING_PERCENTAGE + 1; IllegalArgumentException thrown = @@ -120,13 +113,11 @@ public final class ShadowMediaControllerTest { } @Test - @Config(minSdk = LOLLIPOP) public void getDefaultRatingType() { assertThat(mediaController.getRatingType()).isEqualTo(Rating.RATING_NONE); } @Test - @Config(minSdk = LOLLIPOP) public void setAndGetRatingType() { int ratingType = Rating.RATING_HEART; shadowMediaController.setRatingType(ratingType); @@ -134,7 +125,6 @@ public final class ShadowMediaControllerTest { } @Test - @Config(minSdk = LOLLIPOP) public void setAndGetSessionActivity() { Context context = ApplicationProvider.getApplicationContext(); Intent intent = new Intent("testIntent"); @@ -144,7 +134,6 @@ public final class ShadowMediaControllerTest { } @Test - @Config(minSdk = LOLLIPOP) public void setAndGetExtras() { String extraKey = "test.extra.key"; Bundle extras = new Bundle(); @@ -154,7 +143,6 @@ public final class ShadowMediaControllerTest { } @Test - @Config(minSdk = LOLLIPOP) public void registerAndGetCallback() { List<MediaController.Callback> mockCallbacks = new ArrayList<>(); assertEquals(mockCallbacks, shadowMediaController.getCallbacks()); @@ -171,7 +159,6 @@ public final class ShadowMediaControllerTest { } @Test - @Config(minSdk = LOLLIPOP) public void registerWithHandlerAndGetCallback() { List<MediaController.Callback> mockCallbacks = new ArrayList<>(); assertEquals(mockCallbacks, shadowMediaController.getCallbacks()); @@ -188,7 +175,6 @@ public final class ShadowMediaControllerTest { } @Test - @Config(minSdk = LOLLIPOP) public void unregisterCallback() { List<MediaController.Callback> mockCallbacks = new ArrayList<>(); MediaController.Callback mockCallback1 = mock(MediaController.Callback.class); @@ -209,7 +195,6 @@ public final class ShadowMediaControllerTest { } @Test - @Config(minSdk = LOLLIPOP) public void executeOnPlaybackStateChanged() { ArgumentCaptor<PlaybackState> argument = ArgumentCaptor.forClass(PlaybackState.class); MediaController.Callback mockCallback = mock(MediaController.Callback.class); @@ -226,7 +211,6 @@ public final class ShadowMediaControllerTest { } @Test - @Config(minSdk = LOLLIPOP) public void executeOnMetadataChanged() { ArgumentCaptor<MediaMetadata> argument = ArgumentCaptor.forClass(MediaMetadata.class); MediaController.Callback mockCallback = mock(MediaController.Callback.class); @@ -243,7 +227,6 @@ public final class ShadowMediaControllerTest { } @Test - @Config(minSdk = LOLLIPOP) public void executeOnSessionDestroyed() { MediaController.Callback mockCallback = mock(MediaController.Callback.class); diff --git a/robolectric/src/test/java/org/robolectric/shadows/ShadowMediaMuxerTest.java b/robolectric/src/test/java/org/robolectric/shadows/ShadowMediaMuxerTest.java index 53e383619..51bd19cc6 100644 --- a/robolectric/src/test/java/org/robolectric/shadows/ShadowMediaMuxerTest.java +++ b/robolectric/src/test/java/org/robolectric/shadows/ShadowMediaMuxerTest.java @@ -1,6 +1,5 @@ package org.robolectric.shadows; -import static android.os.Build.VERSION_CODES.LOLLIPOP; import static android.os.Build.VERSION_CODES.O; import static com.google.common.truth.Truth.assertThat; @@ -40,7 +39,6 @@ public final class ShadowMediaMuxerTest { } @Test - @Config(minSdk = LOLLIPOP) public void basicMuxingFlow_sameZeroOffset() throws IOException { String tempFilePath = tempDirectory.create("dir").resolve(UUID.randomUUID().toString()).toString(); @@ -50,7 +48,6 @@ public final class ShadowMediaMuxerTest { } @Test - @Config(minSdk = LOLLIPOP) public void basicMuxingFlow_sameNonZeroOffset() throws IOException { String tempFilePath = tempDirectory.create("dir").resolve(UUID.randomUUID().toString()).toString(); @@ -60,7 +57,6 @@ public final class ShadowMediaMuxerTest { } @Test - @Config(minSdk = LOLLIPOP) public void basicMuxingFlow_nonSameButSmallerOffset() throws IOException { String tempFilePath = tempDirectory.create("dir").resolve(UUID.randomUUID().toString()).toString(); @@ -70,7 +66,6 @@ public final class ShadowMediaMuxerTest { } @Test - @Config(minSdk = LOLLIPOP) public void basicMuxingFlow_nonSameButLargerOffset() throws IOException { String tempFilePath = tempDirectory.create("dir").resolve(UUID.randomUUID().toString()).toString(); diff --git a/robolectric/src/test/java/org/robolectric/shadows/ShadowNetworkCapabilitiesTest.java b/robolectric/src/test/java/org/robolectric/shadows/ShadowNetworkCapabilitiesTest.java index 9c5f964ad..972e32ea5 100644 --- a/robolectric/src/test/java/org/robolectric/shadows/ShadowNetworkCapabilitiesTest.java +++ b/robolectric/src/test/java/org/robolectric/shadows/ShadowNetworkCapabilitiesTest.java @@ -6,7 +6,6 @@ import static android.net.NetworkCapabilities.NET_CAPABILITY_NOT_VPN; import static android.net.NetworkCapabilities.NET_CAPABILITY_TRUSTED; import static android.net.NetworkCapabilities.TRANSPORT_CELLULAR; import static android.net.NetworkCapabilities.TRANSPORT_WIFI; -import static android.os.Build.VERSION_CODES.LOLLIPOP; import static android.os.Build.VERSION_CODES.N; import static android.os.Build.VERSION_CODES.N_MR1; import static android.os.Build.VERSION_CODES.O; @@ -26,7 +25,6 @@ import org.robolectric.annotation.Config; import org.robolectric.util.ReflectionHelpers; @RunWith(AndroidJUnit4.class) -@Config(minSdk = LOLLIPOP) public class ShadowNetworkCapabilitiesTest { @Test diff --git a/robolectric/src/test/java/org/robolectric/shadows/ShadowNetworkScoreManagerTest.java b/robolectric/src/test/java/org/robolectric/shadows/ShadowNetworkScoreManagerTest.java index 8524eb036..e9a951236 100644 --- a/robolectric/src/test/java/org/robolectric/shadows/ShadowNetworkScoreManagerTest.java +++ b/robolectric/src/test/java/org/robolectric/shadows/ShadowNetworkScoreManagerTest.java @@ -1,6 +1,5 @@ package org.robolectric.shadows; -import static android.os.Build.VERSION_CODES.LOLLIPOP; import static com.google.common.truth.Truth.assertThat; import android.content.Context; @@ -9,7 +8,6 @@ import androidx.test.core.app.ApplicationProvider; import androidx.test.ext.junit.runners.AndroidJUnit4; import org.junit.Test; import org.junit.runner.RunWith; -import org.robolectric.annotation.Config; import org.robolectric.shadow.api.Shadow; /** ShadowNetworkScoreManagerTest tests {@link ShadowNetworkScoreManager}. */ @@ -17,7 +15,6 @@ import org.robolectric.shadow.api.Shadow; public final class ShadowNetworkScoreManagerTest { @Test - @Config(minSdk = LOLLIPOP) public void testGetActiveScorerPackage() { Context context = ApplicationProvider.getApplicationContext(); NetworkScoreManager networkScoreManager = @@ -29,7 +26,6 @@ public final class ShadowNetworkScoreManagerTest { } @Test - @Config(minSdk = LOLLIPOP) public void testIsScoringEnabled() { Context context = ApplicationProvider.getApplicationContext(); NetworkScoreManager networkScoreManager = diff --git a/robolectric/src/test/java/org/robolectric/shadows/ShadowNetworkTest.java b/robolectric/src/test/java/org/robolectric/shadows/ShadowNetworkTest.java index d7748729e..3889e39f4 100644 --- a/robolectric/src/test/java/org/robolectric/shadows/ShadowNetworkTest.java +++ b/robolectric/src/test/java/org/robolectric/shadows/ShadowNetworkTest.java @@ -1,6 +1,5 @@ package org.robolectric.shadows; -import static android.os.Build.VERSION_CODES.LOLLIPOP; import static android.os.Build.VERSION_CODES.LOLLIPOP_MR1; import static android.os.Build.VERSION_CODES.M; import static com.google.common.truth.Truth.assertThat; @@ -16,7 +15,6 @@ import org.robolectric.Shadows; import org.robolectric.annotation.Config; @RunWith(AndroidJUnit4.class) -@Config(minSdk = LOLLIPOP) public class ShadowNetworkTest { @Test public void getNetId_shouldReturnConstructorNetId() { diff --git a/robolectric/src/test/java/org/robolectric/shadows/ShadowOsConstantsTest.java b/robolectric/src/test/java/org/robolectric/shadows/ShadowOsConstantsTest.java index bfc4e6dd0..bc3bf9a4e 100644 --- a/robolectric/src/test/java/org/robolectric/shadows/ShadowOsConstantsTest.java +++ b/robolectric/src/test/java/org/robolectric/shadows/ShadowOsConstantsTest.java @@ -1,6 +1,5 @@ package org.robolectric.shadows; -import static android.os.Build.VERSION_CODES.LOLLIPOP; import static com.google.common.truth.Truth.assertThat; import static org.robolectric.shadows.OsConstantsValues.OPEN_MODE_VALUES; @@ -8,20 +7,17 @@ import android.system.OsConstants; import androidx.test.ext.junit.runners.AndroidJUnit4; import org.junit.Test; import org.junit.runner.RunWith; -import org.robolectric.annotation.Config; /** Unit tests for {@link ShadowOsConstants}. */ @RunWith(AndroidJUnit4.class) public final class ShadowOsConstantsTest { - @Config(minSdk = LOLLIPOP) @Test public void valuesAreDistinct() throws Exception { assertThat(OsConstants.errnoName(OsConstants.EAGAIN)).isEqualTo("EAGAIN"); assertThat(OsConstants.errnoName(OsConstants.EBADF)).isEqualTo("EBADF"); } - @Config(minSdk = LOLLIPOP) @Test public void valuesAreExpected() { assertThat(OsConstants.S_IFMT).isEqualTo(OsConstantsValues.S_IFMT_VALUE); diff --git a/robolectric/src/test/java/org/robolectric/shadows/ShadowOutlineTest.java b/robolectric/src/test/java/org/robolectric/shadows/ShadowOutlineTest.java index 7870d7ca2..504c068b3 100644 --- a/robolectric/src/test/java/org/robolectric/shadows/ShadowOutlineTest.java +++ b/robolectric/src/test/java/org/robolectric/shadows/ShadowOutlineTest.java @@ -1,16 +1,13 @@ package org.robolectric.shadows; -import static android.os.Build.VERSION_CODES.LOLLIPOP; import android.graphics.Outline; import android.graphics.Path; import androidx.test.ext.junit.runners.AndroidJUnit4; import org.junit.Test; import org.junit.runner.RunWith; -import org.robolectric.annotation.Config; @RunWith(AndroidJUnit4.class) -@Config(minSdk = LOLLIPOP) public class ShadowOutlineTest { @Test diff --git a/robolectric/src/test/java/org/robolectric/shadows/ShadowPackageInstallerTest.java b/robolectric/src/test/java/org/robolectric/shadows/ShadowPackageInstallerTest.java index 453768b20..957241133 100644 --- a/robolectric/src/test/java/org/robolectric/shadows/ShadowPackageInstallerTest.java +++ b/robolectric/src/test/java/org/robolectric/shadows/ShadowPackageInstallerTest.java @@ -1,6 +1,5 @@ package org.robolectric.shadows; -import static android.os.Build.VERSION_CODES.LOLLIPOP; import static android.os.Build.VERSION_CODES.O; import static android.os.Build.VERSION_CODES.S; import static android.os.Build.VERSION_CODES.UPSIDE_DOWN_CAKE; @@ -36,7 +35,6 @@ import org.robolectric.annotation.Config; import org.robolectric.util.ReflectionHelpers; @RunWith(AndroidJUnit4.class) -@Config(minSdk = LOLLIPOP) public class ShadowPackageInstallerTest { private PackageInstaller packageInstaller; diff --git a/robolectric/src/test/java/org/robolectric/shadows/ShadowPackageManagerTest.java b/robolectric/src/test/java/org/robolectric/shadows/ShadowPackageManagerTest.java index 720a01d2f..91f3127fa 100644 --- a/robolectric/src/test/java/org/robolectric/shadows/ShadowPackageManagerTest.java +++ b/robolectric/src/test/java/org/robolectric/shadows/ShadowPackageManagerTest.java @@ -32,7 +32,6 @@ import static android.content.pm.PackageManager.SIGNATURE_SECOND_NOT_SIGNED; import static android.content.pm.PackageManager.SIGNATURE_UNKNOWN_PACKAGE; import static android.content.pm.PackageManager.VERIFICATION_ALLOW; import static android.content.pm.PackageManager.VERIFICATION_REJECT; -import static android.os.Build.VERSION_CODES.LOLLIPOP; import static android.os.Build.VERSION_CODES.LOLLIPOP_MR1; import static android.os.Build.VERSION_CODES.M; import static android.os.Build.VERSION_CODES.N; @@ -181,7 +180,6 @@ public class ShadowPackageManagerTest { } @Test - @Config(minSdk = LOLLIPOP) public void packageInstallerCreateSession() throws Exception { PackageInstaller packageInstaller = context.getPackageManager().getPackageInstaller(); int sessionId = packageInstaller.createSession(createSessionParams("packageName")); @@ -197,7 +195,6 @@ public class ShadowPackageManagerTest { } @Test - @Config(minSdk = LOLLIPOP) public void packageInstallerOpenSession() throws Exception { PackageInstaller packageInstaller = context.getPackageManager().getPackageInstaller(); int sessionId = packageInstaller.createSession(createSessionParams("packageName")); @@ -1421,7 +1418,6 @@ public class ShadowPackageManagerTest { } @Test - @Config(minSdk = LOLLIPOP) public void queryIntentActivities_appHidden_includeUninstalled() { String packageName = context.getPackageName(); packageManager.setApplicationHiddenSettingAsUser( @@ -1439,7 +1435,6 @@ public class ShadowPackageManagerTest { } @Test - @Config(minSdk = LOLLIPOP) public void queryIntentActivities_appHidden_dontIncludeUninstalled() { String packageName = context.getPackageName(); packageManager.setApplicationHiddenSettingAsUser( @@ -1671,7 +1666,6 @@ public class ShadowPackageManagerTest { } @Test - @Config(minSdk = LOLLIPOP) public void queryIntentServices_appHidden_includeUninstalled() { String packageName = context.getPackageName(); packageManager.setApplicationHiddenSettingAsUser( @@ -1687,7 +1681,6 @@ public class ShadowPackageManagerTest { } @Test - @Config(minSdk = LOLLIPOP) public void queryIntentServices_appHidden_dontIncludeUninstalled() { String packageName = context.getPackageName(); packageManager.setApplicationHiddenSettingAsUser( @@ -1746,7 +1739,6 @@ public class ShadowPackageManagerTest { } @Test - @Config(minSdk = LOLLIPOP) public void queryBroadcastReceivers_appHidden_includeUninstalled() { String packageName = context.getPackageName(); packageManager.setApplicationHiddenSettingAsUser( @@ -1764,7 +1756,6 @@ public class ShadowPackageManagerTest { } @Test - @Config(minSdk = LOLLIPOP) public void queryBroadcastReceivers_appHidden_dontIncludeUninstalled() { String packageName = context.getPackageName(); packageManager.setApplicationHiddenSettingAsUser( @@ -1777,7 +1768,6 @@ public class ShadowPackageManagerTest { } @Test - @Config(minSdk = LOLLIPOP) public void queryIntentContentProviders_EmptyResult() { Intent i = new Intent(DocumentsContract.PROVIDER_INTERFACE); @@ -1786,7 +1776,6 @@ public class ShadowPackageManagerTest { } @Test - @Config(minSdk = LOLLIPOP) public void queryIntentContentProviders_Match() { Intent i = new Intent(DocumentsContract.PROVIDER_INTERFACE); @@ -1803,7 +1792,6 @@ public class ShadowPackageManagerTest { } @Test - @Config(minSdk = LOLLIPOP) public void queryIntentContentProviders_MatchSystemOnly() { Intent i = new Intent(DocumentsContract.PROVIDER_INTERFACE); @@ -1828,7 +1816,6 @@ public class ShadowPackageManagerTest { } @Test - @Config(minSdk = LOLLIPOP) public void queryIntentContentProviders_MatchDisabledComponents() { Intent i = new Intent(DocumentsContract.PROVIDER_INTERFACE); @@ -1852,7 +1839,6 @@ public class ShadowPackageManagerTest { } @Test - @Config(minSdk = LOLLIPOP) public void queryIntentContentProviders_appHidden_includeUninstalled() { String packageName = context.getPackageName(); packageManager.setApplicationHiddenSettingAsUser( @@ -2403,7 +2389,6 @@ public class ShadowPackageManagerTest { } @Test - @Config(minSdk = LOLLIPOP) public void testLeanbackLaunchIntentForPackage() { Intent intent = packageManager.getLeanbackLaunchIntentForPackage(TEST_PACKAGE_LABEL); assertThat(intent).isNull(); @@ -3371,7 +3356,6 @@ public class ShadowPackageManagerTest { } @Test - @Config(minSdk = LOLLIPOP) public void addPackageShouldNotCreateSessions() { PackageInfo packageInfo = new PackageInfo(); @@ -3726,7 +3710,6 @@ public class ShadowPackageManagerTest { } @Test - @Config(minSdk = LOLLIPOP) public void getApplicationHiddenSettingAsUser_hidden() { String packageName = context.getPackageName(); @@ -3738,7 +3721,6 @@ public class ShadowPackageManagerTest { } @Test - @Config(minSdk = LOLLIPOP) public void getApplicationHiddenSettingAsUser_notHidden() { String packageName = context.getPackageName(); @@ -3747,14 +3729,12 @@ public class ShadowPackageManagerTest { } @Test - @Config(minSdk = LOLLIPOP) public void getApplicationHiddenSettingAsUser_unknownPackage() { assertThat(packageManager.getApplicationHiddenSettingAsUser("not.a.package", /* user= */ null)) .isTrue(); } @Test - @Config(minSdk = LOLLIPOP) public void setApplicationHiddenSettingAsUser_includeUninstalled() throws Exception { String packageName = context.getPackageName(); @@ -3771,7 +3751,6 @@ public class ShadowPackageManagerTest { } @Test - @Config(minSdk = LOLLIPOP) public void setApplicationHiddenSettingAsUser_dontIncludeUninstalled() { String packageName = context.getPackageName(); diff --git a/robolectric/src/test/java/org/robolectric/shadows/ShadowParcelTest.java b/robolectric/src/test/java/org/robolectric/shadows/ShadowParcelTest.java index dd01e26e1..b08224690 100644 --- a/robolectric/src/test/java/org/robolectric/shadows/ShadowParcelTest.java +++ b/robolectric/src/test/java/org/robolectric/shadows/ShadowParcelTest.java @@ -1,6 +1,5 @@ package org.robolectric.shadows; -import static android.os.Build.VERSION_CODES.LOLLIPOP; import static android.os.Build.VERSION_CODES.M; import static com.google.common.truth.Truth.assertThat; import static com.google.common.truth.Truth.assertWithMessage; @@ -161,7 +160,6 @@ public class ShadowParcelTest { } @Test - @Config(minSdk = LOLLIPOP) public void testReadWriteSingleStrongBinder() { IBinder binder = new Binder(); parcel.writeStrongBinder(binder); @@ -170,7 +168,6 @@ public class ShadowParcelTest { } @Test - @Config(minSdk = LOLLIPOP) public void testWriteNullStrongBinder() { parcel.writeStrongBinder(null); parcel.setDataPosition(0); @@ -178,7 +175,6 @@ public class ShadowParcelTest { } @Test - @Config(minSdk = LOLLIPOP) public void testReadWriteMultipleStrongBinders() { List<IBinder> binders = new ArrayList<>(); for (int i = 0; i < 10; ++i) { diff --git a/robolectric/src/test/java/org/robolectric/shadows/ShadowPorterDuffColorFilterTest.java b/robolectric/src/test/java/org/robolectric/shadows/ShadowPorterDuffColorFilterTest.java index d144019e3..c22aa38b3 100644 --- a/robolectric/src/test/java/org/robolectric/shadows/ShadowPorterDuffColorFilterTest.java +++ b/robolectric/src/test/java/org/robolectric/shadows/ShadowPorterDuffColorFilterTest.java @@ -1,6 +1,5 @@ package org.robolectric.shadows; -import static android.os.Build.VERSION_CODES.LOLLIPOP; import static android.os.Build.VERSION_CODES.O; import static com.google.common.truth.Truth.assertThat; @@ -13,7 +12,6 @@ import org.junit.runner.RunWith; import org.robolectric.annotation.Config; @RunWith(AndroidJUnit4.class) -@Config(minSdk = LOLLIPOP) public class ShadowPorterDuffColorFilterTest { @Test public void constructor_shouldWork() { diff --git a/robolectric/src/test/java/org/robolectric/shadows/ShadowPosixTest.java b/robolectric/src/test/java/org/robolectric/shadows/ShadowPosixTest.java index 437c313b7..b9965735e 100644 --- a/robolectric/src/test/java/org/robolectric/shadows/ShadowPosixTest.java +++ b/robolectric/src/test/java/org/robolectric/shadows/ShadowPosixTest.java @@ -1,6 +1,5 @@ package org.robolectric.shadows; -import static android.os.Build.VERSION_CODES.LOLLIPOP; import static com.google.common.truth.Truth.assertThat; import android.system.StructStat; @@ -11,7 +10,6 @@ import java.time.Duration; import org.junit.Before; import org.junit.Test; import org.junit.runner.RunWith; -import org.robolectric.annotation.Config; import org.robolectric.util.ReflectionHelpers; /** Unit tests for ShadowPosix to check values returned from stat() call. */ @@ -30,21 +28,18 @@ public final class ShadowPosixTest { } @Test - @Config(minSdk = LOLLIPOP) public void getStatAtLeastLollipop_returnCorrectMode() throws Exception { StructStat stat = (StructStat) ShadowPosix.stat(path); assertThat(stat.st_mode).isEqualTo(OsConstantsValues.S_IFREG_VALUE); } @Test - @Config(minSdk = LOLLIPOP) public void getStatAtLeastLollipop_returnCorrectSize() throws Exception { StructStat stat = (StructStat) ShadowPosix.stat(path); assertThat(stat.st_size).isEqualTo(file.length()); } @Test - @Config(minSdk = LOLLIPOP) public void getStatAtLeastLollipop_returnCorrectModifiedTime() throws Exception { StructStat stat = (StructStat) ShadowPosix.stat(path); assertThat(stat.st_mtime).isEqualTo(Duration.ofMillis(file.lastModified()).getSeconds()); diff --git a/robolectric/src/test/java/org/robolectric/shadows/ShadowPowerManagerTest.java b/robolectric/src/test/java/org/robolectric/shadows/ShadowPowerManagerTest.java index f001fecff..ffad2f518 100644 --- a/robolectric/src/test/java/org/robolectric/shadows/ShadowPowerManagerTest.java +++ b/robolectric/src/test/java/org/robolectric/shadows/ShadowPowerManagerTest.java @@ -2,7 +2,6 @@ package org.robolectric.shadows; import static android.content.Intent.ACTION_SCREEN_OFF; import static android.content.Intent.ACTION_SCREEN_ON; -import static android.os.Build.VERSION_CODES.LOLLIPOP; import static android.os.Build.VERSION_CODES.M; import static android.os.Build.VERSION_CODES.N; import static android.os.Build.VERSION_CODES.P; @@ -68,7 +67,6 @@ public class ShadowPowerManagerTest { } @Test - @Config(minSdk = LOLLIPOP) public void isWakeLockLevelSupported() { assertThat(powerManager.isWakeLockLevelSupported(PowerManager.PARTIAL_WAKE_LOCK)).isFalse(); @@ -163,7 +161,6 @@ public class ShadowPowerManagerTest { } @Test - @Config(minSdk = LOLLIPOP) public void isInteractive_shouldGetAndSet() { shadowOf(powerManager).turnScreenOn(false); assertThat(powerManager.isInteractive()).isFalse(); @@ -181,7 +178,6 @@ public class ShadowPowerManagerTest { } @Test - @Config(minSdk = LOLLIPOP) public void isPowerSaveMode_shouldGetAndSet() { assertThat(powerManager.isPowerSaveMode()).isFalse(); shadowOf(powerManager).setIsPowerSaveMode(true); diff --git a/robolectric/src/test/java/org/robolectric/shadows/ShadowRankingTest.java b/robolectric/src/test/java/org/robolectric/shadows/ShadowRankingTest.java index 2c4a0c15a..8bf4de7ca 100644 --- a/robolectric/src/test/java/org/robolectric/shadows/ShadowRankingTest.java +++ b/robolectric/src/test/java/org/robolectric/shadows/ShadowRankingTest.java @@ -16,7 +16,6 @@ import org.robolectric.annotation.Config; /** Test for {@link ShadowRanking}. */ @RunWith(RobolectricTestRunner.class) -@Config(minSdk = VERSION_CODES.KITKAT_WATCH) public class ShadowRankingTest { private Ranking ranking; diff --git a/robolectric/src/test/java/org/robolectric/shadows/ShadowRenderNodeAnimatorTest.java b/robolectric/src/test/java/org/robolectric/shadows/ShadowRenderNodeAnimatorTest.java index 141c3e433..d19bb672b 100644 --- a/robolectric/src/test/java/org/robolectric/shadows/ShadowRenderNodeAnimatorTest.java +++ b/robolectric/src/test/java/org/robolectric/shadows/ShadowRenderNodeAnimatorTest.java @@ -1,6 +1,5 @@ package org.robolectric.shadows; -import static android.os.Build.VERSION_CODES.LOLLIPOP; import static com.google.common.truth.Truth.assertThat; import static org.robolectric.shadows.ShadowLooper.shadowMainLooper; @@ -15,10 +14,8 @@ import org.junit.Before; import org.junit.Test; import org.junit.runner.RunWith; import org.robolectric.Robolectric; -import org.robolectric.annotation.Config; @RunWith(AndroidJUnit4.class) -@Config(minSdk = LOLLIPOP) public class ShadowRenderNodeAnimatorTest { private Activity activity; private View view; diff --git a/robolectric/src/test/java/org/robolectric/shadows/ShadowRenderNodeTest.java b/robolectric/src/test/java/org/robolectric/shadows/ShadowRenderNodeTest.java index e2b5e49be..addc4f31a 100644 --- a/robolectric/src/test/java/org/robolectric/shadows/ShadowRenderNodeTest.java +++ b/robolectric/src/test/java/org/robolectric/shadows/ShadowRenderNodeTest.java @@ -1,6 +1,5 @@ package org.robolectric.shadows; -import static android.os.Build.VERSION_CODES.LOLLIPOP; import static android.os.Build.VERSION_CODES.Q; import static com.google.common.truth.Truth.assertThat; import static org.robolectric.util.ReflectionHelpers.callInstanceMethod; @@ -16,7 +15,6 @@ import androidx.test.core.app.ApplicationProvider; import androidx.test.ext.junit.runners.AndroidJUnit4; import org.junit.Test; import org.junit.runner.RunWith; -import org.robolectric.annotation.Config; import org.robolectric.util.ReflectionHelpers; /** @@ -24,7 +22,6 @@ import org.robolectric.util.ReflectionHelpers; * RenderNode} was moved to a public API to open access to it. */ @RunWith(AndroidJUnit4.class) -@Config(minSdk = LOLLIPOP) public final class ShadowRenderNodeTest { @Test diff --git a/robolectric/src/test/java/org/robolectric/shadows/ShadowRestrictionsManagerTest.java b/robolectric/src/test/java/org/robolectric/shadows/ShadowRestrictionsManagerTest.java index 06974fb11..e9bbf6862 100644 --- a/robolectric/src/test/java/org/robolectric/shadows/ShadowRestrictionsManagerTest.java +++ b/robolectric/src/test/java/org/robolectric/shadows/ShadowRestrictionsManagerTest.java @@ -1,6 +1,5 @@ package org.robolectric.shadows; -import static android.os.Build.VERSION_CODES.LOLLIPOP; import static com.google.common.truth.Truth.assertThat; import static org.robolectric.Shadows.shadowOf; @@ -14,10 +13,8 @@ import com.google.common.collect.Iterables; import org.junit.Before; import org.junit.Test; import org.junit.runner.RunWith; -import org.robolectric.annotation.Config; @RunWith(AndroidJUnit4.class) -@Config(minSdk = LOLLIPOP) public final class ShadowRestrictionsManagerTest { private RestrictionsManager restrictionsManager; diff --git a/robolectric/src/test/java/org/robolectric/shadows/ShadowSQLiteConnectionTest.java b/robolectric/src/test/java/org/robolectric/shadows/ShadowSQLiteConnectionTest.java index 5e8151ceb..9a46cfde8 100644 --- a/robolectric/src/test/java/org/robolectric/shadows/ShadowSQLiteConnectionTest.java +++ b/robolectric/src/test/java/org/robolectric/shadows/ShadowSQLiteConnectionTest.java @@ -1,6 +1,5 @@ package org.robolectric.shadows; -import static android.os.Build.VERSION_CODES.LOLLIPOP; import static com.google.common.truth.Truth.assertThat; import static com.google.common.truth.Truth.assertWithMessage; import static com.google.common.truth.TruthJUnit.assume; @@ -27,13 +26,11 @@ import org.junit.After; import org.junit.Before; import org.junit.Test; import org.junit.runner.RunWith; -import org.robolectric.annotation.Config; import org.robolectric.annotation.SQLiteMode; import org.robolectric.shadows.util.SQLiteLibraryLoader; import org.robolectric.util.ReflectionHelpers; @RunWith(AndroidJUnit4.class) -@Config(minSdk = LOLLIPOP) @SQLiteMode(LEGACY) // This test relies on legacy SQLite behavior in Robolectric. public class ShadowSQLiteConnectionTest { private SQLiteDatabase database; diff --git a/robolectric/src/test/java/org/robolectric/shadows/ShadowSettingsTest.java b/robolectric/src/test/java/org/robolectric/shadows/ShadowSettingsTest.java index ae2737ccb..09ab05a55 100644 --- a/robolectric/src/test/java/org/robolectric/shadows/ShadowSettingsTest.java +++ b/robolectric/src/test/java/org/robolectric/shadows/ShadowSettingsTest.java @@ -3,7 +3,6 @@ package org.robolectric.shadows; import static android.location.LocationManager.GPS_PROVIDER; import static android.location.LocationManager.NETWORK_PROVIDER; import static android.os.Build.VERSION_CODES.JELLY_BEAN_MR2; -import static android.os.Build.VERSION_CODES.LOLLIPOP; import static android.os.Build.VERSION_CODES.O; import static android.provider.Settings.Secure.LOCATION_MODE; import static android.provider.Settings.Secure.LOCATION_MODE_BATTERY_SAVING; @@ -11,6 +10,7 @@ import static android.provider.Settings.Secure.LOCATION_MODE_HIGH_ACCURACY; import static android.provider.Settings.Secure.LOCATION_MODE_OFF; import static android.provider.Settings.Secure.LOCATION_MODE_SENSORS_ONLY; import static com.google.common.truth.Truth.assertThat; +import static org.robolectric.annotation.Config.OLDEST_SDK; import static org.robolectric.shadows.ShadowLooper.idleMainLooper; import android.animation.ValueAnimator; @@ -172,7 +172,7 @@ public class ShadowSettingsTest { .isEqualTo(0); } - @Config(minSdk = LOLLIPOP, maxSdk = O) // TODO(christianw) fix location mode + @Config(minSdk = OLDEST_SDK, maxSdk = O) // TODO(christianw) fix location mode @Test public void locationProviders_affectsLocationMode() { // Verify default values @@ -200,7 +200,7 @@ public class ShadowSettingsTest { assertThat(Secure.getInt(contentResolver, LOCATION_MODE, -1)).isEqualTo(LOCATION_MODE_OFF); } - @Config(minSdk = LOLLIPOP, maxSdk = O) // TODO(christianw) fix location mode + @Config(minSdk = OLDEST_SDK, maxSdk = O) // TODO(christianw) fix location mode @Test public void locationMode_affectsLocationProviders() { // Verify the default value diff --git a/robolectric/src/test/java/org/robolectric/shadows/ShadowSmsManagerTest.java b/robolectric/src/test/java/org/robolectric/shadows/ShadowSmsManagerTest.java index 29d5dfd60..a3a3fa8cd 100644 --- a/robolectric/src/test/java/org/robolectric/shadows/ShadowSmsManagerTest.java +++ b/robolectric/src/test/java/org/robolectric/shadows/ShadowSmsManagerTest.java @@ -1,6 +1,5 @@ package org.robolectric.shadows; -import static android.os.Build.VERSION_CODES.LOLLIPOP; import static android.os.Build.VERSION_CODES.LOLLIPOP_MR1; import static android.os.Build.VERSION_CODES.R; import static android.os.Build.VERSION_CODES.S; @@ -144,7 +143,6 @@ public class ShadowSmsManagerTest { // Tests for {@link SmsManager#sendMultimediaMessage} @Test - @Config(minSdk = LOLLIPOP) public void sendMultimediaMessage_shouldStoreLastSentMultimediaMessageParameters() { Bundle configOverrides = new Bundle(); configOverrides.putBoolean("enableMMSDeliveryReports", true); @@ -162,7 +160,6 @@ public class ShadowSmsManagerTest { } @Test(expected = IllegalArgumentException.class) - @Config(minSdk = LOLLIPOP) public void sendMultimediaMessage_shouldThrowExceptionWithEmptyContentUri() { smsManager.sendMultimediaMessage( null, @@ -188,7 +185,6 @@ public class ShadowSmsManagerTest { } @Test - @Config(minSdk = LOLLIPOP) public void clearLastSentMultimediaMessageParams_shouldClearParameters() { smsManager.sendMultimediaMessage( null, @@ -205,7 +201,6 @@ public class ShadowSmsManagerTest { // Tests for {@link SmsManager#downloadMultimediaMessage} @Test - @Config(minSdk = LOLLIPOP) public void downloadMultimediaMessage_shouldStoreLastDownloadedMultimediaMessageParameters() { Bundle configOverrides = new Bundle(); configOverrides.putBoolean("enableMMSDeliveryReports", true); @@ -239,7 +234,6 @@ public class ShadowSmsManagerTest { } @Test(expected = IllegalArgumentException.class) - @Config(minSdk = LOLLIPOP) public void downloadMultimediaMessage_shouldThrowExceptionWithEmptyLocationUrl() { smsManager.downloadMultimediaMessage( null, @@ -250,7 +244,6 @@ public class ShadowSmsManagerTest { } @Test(expected = IllegalArgumentException.class) - @Config(minSdk = LOLLIPOP) public void downloadMultimediaMessage_shouldThrowExceptionWithEmptyContentUri() { smsManager.downloadMultimediaMessage( null, @@ -261,7 +254,6 @@ public class ShadowSmsManagerTest { } @Test - @Config(minSdk = LOLLIPOP) public void clearLastDownloadedMultimediaMessageParams_shouldClearParameters() { smsManager.downloadMultimediaMessage( null, diff --git a/robolectric/src/test/java/org/robolectric/shadows/ShadowSoundPoolTest.java b/robolectric/src/test/java/org/robolectric/shadows/ShadowSoundPoolTest.java index 855b782fd..d38cbb63a 100644 --- a/robolectric/src/test/java/org/robolectric/shadows/ShadowSoundPoolTest.java +++ b/robolectric/src/test/java/org/robolectric/shadows/ShadowSoundPoolTest.java @@ -14,14 +14,12 @@ import org.junit.Test; import org.junit.runner.RunWith; import org.robolectric.R; import org.robolectric.RuntimeEnvironment; -import org.robolectric.annotation.Config; import org.robolectric.shadows.ShadowSoundPool.Playback; @RunWith(AndroidJUnit4.class) public class ShadowSoundPoolTest { @Test - @Config(minSdk = LOLLIPOP) public void shouldCreateSoundPool_Lollipop() { SoundPool soundPool = new SoundPool.Builder().build(); assertThat(soundPool).isNotNull(); diff --git a/robolectric/src/test/java/org/robolectric/shadows/ShadowSurfaceTextureTest.java b/robolectric/src/test/java/org/robolectric/shadows/ShadowSurfaceTextureTest.java index 0fe2ba8e0..b3811789e 100644 --- a/robolectric/src/test/java/org/robolectric/shadows/ShadowSurfaceTextureTest.java +++ b/robolectric/src/test/java/org/robolectric/shadows/ShadowSurfaceTextureTest.java @@ -1,6 +1,5 @@ package org.robolectric.shadows; -import static android.os.Build.VERSION_CODES.LOLLIPOP; import static com.google.common.truth.Truth.assertThat; import android.graphics.Rect; @@ -13,7 +12,6 @@ import java.util.concurrent.CountDownLatch; import java.util.concurrent.atomic.AtomicBoolean; import org.junit.Test; import org.junit.runner.RunWith; -import org.robolectric.annotation.Config; /** Tests for {@link ShadowSurfaceTexture}. */ @RunWith(AndroidJUnit4.class) @@ -21,7 +19,6 @@ public class ShadowSurfaceTextureTest { private final SurfaceTexture surfaceTexture = new SurfaceTexture(0); @Test - @Config(minSdk = LOLLIPOP) public void surfaceUnlockAndPost_callsBackListener() throws Exception { final AtomicBoolean frameCallback = new AtomicBoolean(false); CountDownLatch latch = new CountDownLatch(1); diff --git a/robolectric/src/test/java/org/robolectric/shadows/ShadowTelecomManagerTest.java b/robolectric/src/test/java/org/robolectric/shadows/ShadowTelecomManagerTest.java index 04e7b6e01..f7606cff6 100644 --- a/robolectric/src/test/java/org/robolectric/shadows/ShadowTelecomManagerTest.java +++ b/robolectric/src/test/java/org/robolectric/shadows/ShadowTelecomManagerTest.java @@ -1,6 +1,5 @@ package org.robolectric.shadows; -import static android.os.Build.VERSION_CODES.LOLLIPOP; import static android.os.Build.VERSION_CODES.LOLLIPOP_MR1; import static android.os.Build.VERSION_CODES.M; import static android.os.Build.VERSION_CODES.N; @@ -45,7 +44,6 @@ import org.robolectric.shadows.ShadowTelecomManager.CallRequestMode; import org.robolectric.shadows.testing.TestConnectionService; @RunWith(AndroidJUnit4.class) -@Config(minSdk = LOLLIPOP) public class ShadowTelecomManagerTest { @Rule public MockitoRule mockitoRule = MockitoJUnit.rule(); diff --git a/robolectric/src/test/java/org/robolectric/shadows/ShadowTextToSpeechTest.java b/robolectric/src/test/java/org/robolectric/shadows/ShadowTextToSpeechTest.java index 1d987740d..e3c1ee49f 100644 --- a/robolectric/src/test/java/org/robolectric/shadows/ShadowTextToSpeechTest.java +++ b/robolectric/src/test/java/org/robolectric/shadows/ShadowTextToSpeechTest.java @@ -1,6 +1,5 @@ package org.robolectric.shadows; -import static android.os.Build.VERSION_CODES.LOLLIPOP; import static com.google.common.truth.Truth.assertThat; import static org.mockito.Mockito.mock; import static org.mockito.Mockito.never; @@ -27,7 +26,6 @@ import org.junit.rules.TemporaryFolder; import org.junit.runner.RunWith; import org.robolectric.Robolectric; import org.robolectric.Shadows; -import org.robolectric.annotation.Config; @RunWith(AndroidJUnit4.class) public class ShadowTextToSpeechTest { @@ -170,7 +168,6 @@ public class ShadowTextToSpeechTest { } @Test - @Config(minSdk = LOLLIPOP) public void speak_withUtteranceId_shouldReturnSpokenText() { TextToSpeech textToSpeech = new TextToSpeech(activity, result -> {}); textToSpeech.speak("Hello", TextToSpeech.QUEUE_FLUSH, null, "TTSEnable"); @@ -178,7 +175,6 @@ public class ShadowTextToSpeechTest { } @Test - @Config(minSdk = LOLLIPOP) public void onUtteranceProgressListener_shouldGetCallbackUtteranceId() { TextToSpeech textToSpeech = new TextToSpeech(activity, result -> {}); UtteranceProgressListener mockListener = mock(UtteranceProgressListener.class); @@ -192,7 +188,6 @@ public class ShadowTextToSpeechTest { } @Test - @Config(minSdk = LOLLIPOP) public void synthesizeToFile_lastSynthesizeToFileTextStored() throws IOException { TextToSpeech textToSpeech = new TextToSpeech(activity, result -> {}); Bundle bundle = new Bundle(); @@ -204,7 +199,6 @@ public class ShadowTextToSpeechTest { } @Test - @Config(minSdk = LOLLIPOP) public void synthesizeToFile_byDefault_doesNotCallOnStart() throws IOException { TextToSpeech textToSpeech = new TextToSpeech(activity, result -> {}); UtteranceProgressListener mockListener = mock(UtteranceProgressListener.class); @@ -218,7 +212,6 @@ public class ShadowTextToSpeechTest { } @Test - @Config(minSdk = LOLLIPOP) public void synthesizeToFile_byDefault_doesNotCallOnDone() throws IOException { TextToSpeech textToSpeech = new TextToSpeech(activity, result -> {}); UtteranceProgressListener mockListener = mock(UtteranceProgressListener.class); @@ -232,7 +225,6 @@ public class ShadowTextToSpeechTest { } @Test - @Config(minSdk = LOLLIPOP) public void synthesizeToFile_successSimulated_callsOnStart() throws IOException { TextToSpeech textToSpeech = new TextToSpeech(activity, result -> {}); UtteranceProgressListener mockListener = mock(UtteranceProgressListener.class); @@ -249,7 +241,6 @@ public class ShadowTextToSpeechTest { } @Test - @Config(minSdk = LOLLIPOP) public void synthesizeToFile_successSimulated_callsOnDone() throws IOException { TextToSpeech textToSpeech = new TextToSpeech(activity, result -> {}); UtteranceProgressListener mockListener = mock(UtteranceProgressListener.class); @@ -266,7 +257,6 @@ public class ShadowTextToSpeechTest { } @Test - @Config(minSdk = LOLLIPOP) public void synthesizeToFile_setToFail_doesNotCallIsDone() throws IOException { TextToSpeech textToSpeech = new TextToSpeech(activity, result -> {}); UtteranceProgressListener mockListener = mock(UtteranceProgressListener.class); @@ -284,7 +274,6 @@ public class ShadowTextToSpeechTest { } @Test - @Config(minSdk = LOLLIPOP) public void synthesizeToFile_setToFail_callsOnErrorWithErrorCode() throws IOException { TextToSpeech textToSpeech = new TextToSpeech(activity, result -> {}); UtteranceProgressListener mockListener = mock(UtteranceProgressListener.class); @@ -302,7 +291,6 @@ public class ShadowTextToSpeechTest { } @Test - @Config(minSdk = LOLLIPOP) public void synthesizeToFile_neverCalled_lastSynthesizeToFileTextNull() { TextToSpeech textToSpeech = new TextToSpeech(activity, result -> {}); assertThat(shadowOf(textToSpeech).getLastSynthesizeToFileText()).isNull(); @@ -431,7 +419,6 @@ public class ShadowTextToSpeechTest { } @Test - @Config(minSdk = LOLLIPOP) public void getCurrentVoice_voiceSet_returnsVoice() { TextToSpeech textToSpeech = new TextToSpeech(activity, result -> {}); @@ -449,7 +436,6 @@ public class ShadowTextToSpeechTest { } @Test - @Config(minSdk = LOLLIPOP) public void getVoices_returnsAvailableVoices() { TextToSpeech textToSpeech = new TextToSpeech(activity, result -> {}); diff --git a/robolectric/src/test/java/org/robolectric/shadows/ShadowTimeTest.java b/robolectric/src/test/java/org/robolectric/shadows/ShadowTimeTest.java index 239d1c665..dd1ae814e 100644 --- a/robolectric/src/test/java/org/robolectric/shadows/ShadowTimeTest.java +++ b/robolectric/src/test/java/org/robolectric/shadows/ShadowTimeTest.java @@ -1,6 +1,5 @@ package org.robolectric.shadows; -import static android.os.Build.VERSION_CODES.KITKAT_WATCH; import static com.google.common.truth.Truth.assertThat; import static org.junit.Assert.assertEquals; @@ -9,7 +8,6 @@ import android.text.format.Time; import androidx.test.ext.junit.runners.AndroidJUnit4; import org.junit.Test; import org.junit.runner.RunWith; -import org.robolectric.annotation.Config; @RunWith(AndroidJUnit4.class) public class ShadowTimeTest { @@ -66,21 +64,6 @@ public class ShadowTimeTest { } @Test - @Config(maxSdk = KITKAT_WATCH) - // these fail on LOLLIPOP+; is the shadow impl of format correct for pre-LOLLIPOP? - public void shouldFormatAllFormats_withQuestionableResults() { - Time t = new Time("Asia/Tokyo"); - t.set(1407496560000L); - - assertEquals("08/08/2014", t.format("%x")); - assertEquals("08:16:00 PM", t.format("%X")); - - // Case. - assertEquals("PM", t.format("%^P")); - assertEquals("PM", t.format("%#P")); - } - - @Test public void shouldSetToNow() { Time t = new Time(); SystemClock.setCurrentTimeMillis(1000); diff --git a/robolectric/src/test/java/org/robolectric/shadows/ShadowTransportControlsTest.java b/robolectric/src/test/java/org/robolectric/shadows/ShadowTransportControlsTest.java index 243428b7f..fa045f008 100644 --- a/robolectric/src/test/java/org/robolectric/shadows/ShadowTransportControlsTest.java +++ b/robolectric/src/test/java/org/robolectric/shadows/ShadowTransportControlsTest.java @@ -12,7 +12,6 @@ import static android.media.session.PlaybackState.ACTION_SKIP_TO_NEXT; import static android.media.session.PlaybackState.ACTION_SKIP_TO_PREVIOUS; import static android.media.session.PlaybackState.ACTION_SKIP_TO_QUEUE_ITEM; import static android.media.session.PlaybackState.ACTION_STOP; -import static android.os.Build.VERSION_CODES.LOLLIPOP; import static android.os.Build.VERSION_CODES.M; import static android.os.Build.VERSION_CODES.N; import static com.google.common.truth.Truth.assertThat; @@ -45,7 +44,6 @@ public class ShadowTransportControlsTest { } @Test - @Config(minSdk = LOLLIPOP) public void testPause_lastPerformedActionIsPause() { transportControls.pause(); @@ -53,7 +51,6 @@ public class ShadowTransportControlsTest { } @Test - @Config(minSdk = LOLLIPOP) public void testPlay_lastPerformedActionIsPlay() { transportControls.play(); @@ -61,7 +58,6 @@ public class ShadowTransportControlsTest { } @Test - @Config(minSdk = LOLLIPOP) public void testPlayFromSearch_lastPerformedActionIsPlayFromSearch() { transportControls.playFromSearch("query", new Bundle()); @@ -98,7 +94,6 @@ public class ShadowTransportControlsTest { } @Test - @Config(minSdk = LOLLIPOP) public void testSeekTo_lastPerformedActionIsSeekTo() { transportControls.seekTo(50); @@ -107,7 +102,6 @@ public class ShadowTransportControlsTest { } @Test - @Config(minSdk = LOLLIPOP) public void testSendCustomAction_customActionAndArgsAreRecorded() { Bundle customActionArgs = new Bundle(); customActionArgs.putInt("test", 5); @@ -118,7 +112,6 @@ public class ShadowTransportControlsTest { } @Test - @Config(minSdk = LOLLIPOP) public void testSetRating_lastPerformedActionIsSetRating() { Rating rating = Rating.newPercentageRating(30F); transportControls.setRating(rating); @@ -128,7 +121,6 @@ public class ShadowTransportControlsTest { } @Test - @Config(minSdk = LOLLIPOP) public void testSkipToNext_lastPerformedActionIsSkipToNext() { transportControls.skipToNext(); @@ -136,7 +128,6 @@ public class ShadowTransportControlsTest { } @Test - @Config(minSdk = LOLLIPOP) public void testSkipToPrevious_lastPerformedActionIsSkipToPrevious() { transportControls.skipToPrevious(); @@ -144,7 +135,6 @@ public class ShadowTransportControlsTest { } @Test - @Config(minSdk = LOLLIPOP) public void testSkipToPrevious_lastPerformedActionIsSkipToQueueItem() { transportControls.skipToQueueItem(5); @@ -154,7 +144,6 @@ public class ShadowTransportControlsTest { } @Test - @Config(minSdk = LOLLIPOP) public void testStop_lastPerformedActionIsStop() { transportControls.stop(); diff --git a/robolectric/src/test/java/org/robolectric/shadows/ShadowTypefaceTest.java b/robolectric/src/test/java/org/robolectric/shadows/ShadowTypefaceTest.java index 9a42b5518..504acb9ad 100644 --- a/robolectric/src/test/java/org/robolectric/shadows/ShadowTypefaceTest.java +++ b/robolectric/src/test/java/org/robolectric/shadows/ShadowTypefaceTest.java @@ -1,12 +1,12 @@ package org.robolectric.shadows; -import static android.os.Build.VERSION_CODES.LOLLIPOP; import static android.os.Build.VERSION_CODES.O_MR1; import static android.os.Build.VERSION_CODES.P; import static android.os.Build.VERSION_CODES.Q; import static com.google.common.truth.Truth.assertThat; import static org.junit.Assert.fail; import static org.robolectric.Shadows.shadowOf; +import static org.robolectric.annotation.Config.OLDEST_SDK; import android.graphics.Typeface; import android.graphics.fonts.Font; @@ -146,7 +146,7 @@ public class ShadowTypefaceTest { /** Check that there is no spurious error message about /system/etc/fonts.xml */ @Test - @Config(minSdk = LOLLIPOP, maxSdk = O_MR1) + @Config(minSdk = OLDEST_SDK, maxSdk = O_MR1) public void init_shouldNotComplainAboutSystemFonts() { ShadowLog.clear(); ReflectionHelpers.callStaticMethod(Typeface.class, "init"); diff --git a/robolectric/src/test/java/org/robolectric/shadows/ShadowUsageStatsManagerTest.java b/robolectric/src/test/java/org/robolectric/shadows/ShadowUsageStatsManagerTest.java index acd99dcc5..bd4bdb6ba 100644 --- a/robolectric/src/test/java/org/robolectric/shadows/ShadowUsageStatsManagerTest.java +++ b/robolectric/src/test/java/org/robolectric/shadows/ShadowUsageStatsManagerTest.java @@ -3,7 +3,6 @@ package org.robolectric.shadows; import static android.app.usage.UsageStatsManager.INTERVAL_DAILY; import static android.app.usage.UsageStatsManager.INTERVAL_WEEKLY; import static android.content.Context.USAGE_STATS_SERVICE; -import static android.os.Build.VERSION_CODES.LOLLIPOP; import static android.os.Build.VERSION_CODES.Q; import static android.os.Build.VERSION_CODES.TIRAMISU; import static com.google.common.truth.Truth.assertThat; @@ -38,7 +37,6 @@ import org.robolectric.shadows.ShadowUsageStatsManager.UsageStatsBuilder; /** Test for {@link ShadowUsageStatsManager}. */ @RunWith(AndroidJUnit4.class) -@Config(minSdk = LOLLIPOP) public class ShadowUsageStatsManagerTest { private static final String TEST_PACKAGE_NAME1 = "com.company1.pkg1"; diff --git a/robolectric/src/test/java/org/robolectric/shadows/ShadowUsbDeviceConnectionTest.java b/robolectric/src/test/java/org/robolectric/shadows/ShadowUsbDeviceConnectionTest.java index 52ba0285b..301b3709c 100644 --- a/robolectric/src/test/java/org/robolectric/shadows/ShadowUsbDeviceConnectionTest.java +++ b/robolectric/src/test/java/org/robolectric/shadows/ShadowUsbDeviceConnectionTest.java @@ -1,6 +1,5 @@ package org.robolectric.shadows; -import static android.os.Build.VERSION_CODES.LOLLIPOP; import static com.google.common.truth.Truth.assertThat; import static java.nio.charset.StandardCharsets.UTF_8; import static org.junit.Assert.assertThrows; @@ -26,7 +25,6 @@ import org.junit.Test; import org.junit.runner.RunWith; import org.mockito.Mock; import org.mockito.MockitoAnnotations; -import org.robolectric.annotation.Config; /** Unit tests for {@link ShadowUsbDeviceConnection}. */ @RunWith(AndroidJUnit4.class) @@ -54,7 +52,6 @@ public class ShadowUsbDeviceConnectionTest { } @Test - @Config(minSdk = LOLLIPOP) public void claimInterface() { UsbDeviceConnection usbDeviceConnection = usbManager.openDevice(usbDevice); UsbInterface usbInterface = selectInterface(usbDevice); @@ -64,7 +61,6 @@ public class ShadowUsbDeviceConnectionTest { } @Test - @Config(minSdk = LOLLIPOP) public void setInterface() { UsbDeviceConnection usbDeviceConnection = usbManager.openDevice(usbDevice); UsbInterface usbInterface = selectInterface(usbDevice); @@ -73,7 +69,6 @@ public class ShadowUsbDeviceConnectionTest { } @Test - @Config(minSdk = LOLLIPOP) public void controlTransfer() { UsbDeviceConnection usbDeviceConnection = usbManager.openDevice(usbDevice); UsbInterface usbInterface = selectInterface(usbDevice); @@ -104,7 +99,6 @@ public class ShadowUsbDeviceConnectionTest { } @Test - @Config(minSdk = LOLLIPOP) public void bulkTransfer() throws Exception { UsbDeviceConnection usbDeviceConnection = usbManager.openDevice(usbDevice); UsbInterface usbInterface = selectInterface(usbDevice); @@ -132,7 +126,6 @@ public class ShadowUsbDeviceConnectionTest { } @Test - @Config(minSdk = LOLLIPOP) public void releaseInterface_closesOutgoingDataStream() throws Exception { UsbDeviceConnection usbDeviceConnection = usbManager.openDevice(usbDevice); UsbInterface usbInterface = selectInterface(usbDevice); diff --git a/robolectric/src/test/java/org/robolectric/shadows/ShadowUsbRequestTest.java b/robolectric/src/test/java/org/robolectric/shadows/ShadowUsbRequestTest.java index 98fc28ce8..6c57851e7 100644 --- a/robolectric/src/test/java/org/robolectric/shadows/ShadowUsbRequestTest.java +++ b/robolectric/src/test/java/org/robolectric/shadows/ShadowUsbRequestTest.java @@ -63,7 +63,6 @@ public class ShadowUsbRequestTest { } @Test - @Config(minSdk = LOLLIPOP) public void initialize() { UsbDeviceConnection usbDeviceConnection = usbManager.openDevice(usbDevice); UsbInterface usbInterface = selectInterface(usbDevice); @@ -73,7 +72,6 @@ public class ShadowUsbRequestTest { } @Test - @Config(minSdk = LOLLIPOP) public void queue() { UsbDeviceConnection usbDeviceConnection = usbManager.openDevice(usbDevice); UsbInterface usbInterface = selectInterface(usbDevice); diff --git a/robolectric/src/test/java/org/robolectric/shadows/ShadowUserManagerTest.java b/robolectric/src/test/java/org/robolectric/shadows/ShadowUserManagerTest.java index 9da42710a..e0019b359 100644 --- a/robolectric/src/test/java/org/robolectric/shadows/ShadowUserManagerTest.java +++ b/robolectric/src/test/java/org/robolectric/shadows/ShadowUserManagerTest.java @@ -1,7 +1,5 @@ package org.robolectric.shadows; -import static android.os.Build.VERSION_CODES.KITKAT_WATCH; -import static android.os.Build.VERSION_CODES.LOLLIPOP; import static android.os.Build.VERSION_CODES.M; import static android.os.Build.VERSION_CODES.N; import static android.os.Build.VERSION_CODES.N_MR1; @@ -64,7 +62,6 @@ public class ShadowUserManagerTest { } @Test - @Config(minSdk = LOLLIPOP) public void shouldGetUserProfiles() { assertThat(userManager.getUserProfiles()).contains(Process.myUserHandle()); @@ -76,7 +73,6 @@ public class ShadowUserManagerTest { } @Test - @Config(minSdk = LOLLIPOP) public void getUserProfiles_calledFromProfile_shouldReturnList() { ShadowProcess.setUid(2 * 100000); assertThat(userManager.getUserProfiles()).contains(new UserHandle(2)); @@ -87,7 +83,6 @@ public class ShadowUserManagerTest { } @Test - @Config(minSdk = LOLLIPOP) public void getUserProfiles_noProfiles_shouldReturnListOfSelf() { assertThat(userManager.getUserProfiles()).containsExactly(new UserHandle(0)); } @@ -118,7 +113,6 @@ public class ShadowUserManagerTest { } @Test - @Config(minSdk = LOLLIPOP) public void hasUserRestriction() { assertThat(userManager.hasUserRestriction(UserManager.ENSURE_VERIFY_APPS)).isFalse(); @@ -180,7 +174,6 @@ public class ShadowUserManagerTest { } @Test - @Config(minSdk = LOLLIPOP) public void isManagedProfile() { assertThat(userManager.isManagedProfile()).isFalse(); shadowOf(userManager).setManagedProfile(true); @@ -257,7 +250,6 @@ public class ShadowUserManagerTest { } @Test - @Config(minSdk = LOLLIPOP) public void enforcePermissionChecks() { shadowOf(userManager).enforcePermissionChecks(true); @@ -452,7 +444,6 @@ public class ShadowUserManagerTest { } @Test - @Config(minSdk = KITKAT_WATCH) public void isGuestUser() { assertThat(userManager.isGuestUser()).isFalse(); @@ -698,7 +689,6 @@ public class ShadowUserManagerTest { } @Test - @Config(minSdk = LOLLIPOP) public void getProfiles_addedProfile_containsProfile() { shadowOf(userManager).addUser(TEST_USER_HANDLE, "", 0); shadowOf(userManager) diff --git a/robolectric/src/test/java/org/robolectric/shadows/ShadowViewTest.java b/robolectric/src/test/java/org/robolectric/shadows/ShadowViewTest.java index 336342ed9..9b6c2bc22 100644 --- a/robolectric/src/test/java/org/robolectric/shadows/ShadowViewTest.java +++ b/robolectric/src/test/java/org/robolectric/shadows/ShadowViewTest.java @@ -1,6 +1,5 @@ package org.robolectric.shadows; -import static android.os.Build.VERSION_CODES.LOLLIPOP; import static com.google.common.truth.Truth.assertThat; import static org.junit.Assert.assertEquals; import static org.junit.Assert.assertFalse; @@ -61,7 +60,6 @@ import org.robolectric.R; import org.robolectric.Robolectric; import org.robolectric.android.DeviceConfig; import org.robolectric.android.controller.ActivityController; -import org.robolectric.annotation.Config; import org.robolectric.util.TestRunnable; @RunWith(AndroidJUnit4.class) @@ -678,7 +676,6 @@ public class ShadowViewTest { } @Test - @Config(minSdk = LOLLIPOP) public void cameraDistance() { view.setCameraDistance(100f); assertThat(view.getCameraDistance()).isEqualTo(100f); @@ -711,7 +708,6 @@ public class ShadowViewTest { } @Test - @Config(minSdk = LOLLIPOP) public void elevation() { view.setElevation(10f); assertThat(view.getElevation()).isEqualTo(10f); @@ -730,14 +726,12 @@ public class ShadowViewTest { } @Test - @Config(minSdk = LOLLIPOP) public void translationZ() { view.setTranslationZ(10f); assertThat(view.getTranslationZ()).isEqualTo(10f); } @Test - @Config(minSdk = LOLLIPOP) public void clipToOutline() { view.setClipToOutline(true); assertThat(view.getClipToOutline()).isTrue(); diff --git a/robolectric/src/test/java/org/robolectric/shadows/ShadowWifiInfoTest.java b/robolectric/src/test/java/org/robolectric/shadows/ShadowWifiInfoTest.java index 6351aed0f..e3ebc6cac 100644 --- a/robolectric/src/test/java/org/robolectric/shadows/ShadowWifiInfoTest.java +++ b/robolectric/src/test/java/org/robolectric/shadows/ShadowWifiInfoTest.java @@ -1,7 +1,6 @@ package org.robolectric.shadows; import static android.content.Context.WIFI_SERVICE; -import static android.os.Build.VERSION_CODES.LOLLIPOP; import static com.google.common.truth.Truth.assertThat; import static org.robolectric.RuntimeEnvironment.getApplication; import static org.robolectric.Shadows.shadowOf; @@ -14,7 +13,6 @@ import java.net.InetAddress; import org.junit.Before; import org.junit.Test; import org.junit.runner.RunWith; -import org.robolectric.annotation.Config; @RunWith(AndroidJUnit4.class) public class ShadowWifiInfoTest { @@ -95,7 +93,6 @@ public class ShadowWifiInfoTest { } @Test - @Config(minSdk = LOLLIPOP) public void shouldReturnFrequency() { WifiInfo wifiInfo = wifiManager.getConnectionInfo(); assertThat(wifiInfo.getFrequency()).isEqualTo(-1); diff --git a/robolectric/src/test/java/org/robolectric/shadows/ShadowWifiManagerTest.java b/robolectric/src/test/java/org/robolectric/shadows/ShadowWifiManagerTest.java index bfcd80e50..1d376a432 100644 --- a/robolectric/src/test/java/org/robolectric/shadows/ShadowWifiManagerTest.java +++ b/robolectric/src/test/java/org/robolectric/shadows/ShadowWifiManagerTest.java @@ -627,7 +627,6 @@ public class ShadowWifiManagerTest { } @Test - @Config(minSdk = LOLLIPOP) public void is5GhzBandSupportedAndConfigurable() { assertThat(wifiManager.is5GHzBandSupported()).isFalse(); shadowOf(wifiManager).setIs5GHzBandSupported(true); diff --git a/shadows/framework/src/main/java/org/robolectric/shadows/CellInfoLteBuilder.java b/shadows/framework/src/main/java/org/robolectric/shadows/CellInfoLteBuilder.java index 06396e050..9a3af30ee 100644 --- a/shadows/framework/src/main/java/org/robolectric/shadows/CellInfoLteBuilder.java +++ b/shadows/framework/src/main/java/org/robolectric/shadows/CellInfoLteBuilder.java @@ -74,11 +74,7 @@ public class CellInfoLteBuilder { cellInfoLteReflector.setCellSignalStrength(cellSignalStrength); CellInfoReflector cellInfoReflector = reflector(CellInfoReflector.class, cellInfo); cellInfoReflector.setTimeStamp(timeStamp); - if (apiLevel == Build.VERSION_CODES.KITKAT) { - cellInfoReflector.setRegisterd(isRegistered); - } else { - cellInfoReflector.setRegistered(isRegistered); - } + cellInfoReflector.setRegistered(isRegistered); if (apiLevel > Build.VERSION_CODES.O_MR1) { cellInfoReflector.setCellConnectionStatus(cellConnectionStatus); } @@ -125,10 +121,6 @@ public class CellInfoLteBuilder { @ForType(CellInfo.class) private interface CellInfoReflector { - // https://android.googlesource.com/platform/frameworks/base/+/refs/heads/kitkat-release/telephony/java/android/telephony/CellInfo.java#79 - @Accessor("mRegistered") - void setRegisterd(boolean registered); // NOTYPO - @Accessor("mRegistered") void setRegistered(boolean registered); diff --git a/shadows/framework/src/main/java/org/robolectric/shadows/PreLPointers.java b/shadows/framework/src/main/java/org/robolectric/shadows/PreLPointers.java deleted file mode 100644 index 46830f900..000000000 --- a/shadows/framework/src/main/java/org/robolectric/shadows/PreLPointers.java +++ /dev/null @@ -1,38 +0,0 @@ -package org.robolectric.shadows; - -import java.util.Map; -import java.util.concurrent.ConcurrentHashMap; -import java.util.concurrent.atomic.AtomicInteger; - -/** - * A pointer registration system used to associate real (long) pointers with fake 32-bit pointers - * used in pre-lollipop. - */ -class PreLPointers { - static final Map<Integer, Long> preLPointers = new ConcurrentHashMap<>(); - private static final AtomicInteger nextPreLPointer = new AtomicInteger(1); - - private PreLPointers() {} - - static int register(long realPtr) { - int nextPtr = nextPreLPointer.incrementAndGet(); - preLPointers.put(nextPtr, realPtr); - return nextPtr; - } - - @SuppressWarnings("AndroidJdkLibsChecker") - static long get(int fakePtr) { - return preLPointers.computeIfAbsent( - fakePtr, - integer -> { - throw new AssertionError("Missing pre-L pointer " + fakePtr); - }); - } - - static void remove(int fakePtr) { - if (!preLPointers.containsKey(fakePtr)) { - throw new AssertionError("Missing pre-L pointer " + fakePtr); - } - preLPointers.remove(fakePtr); - } -} diff --git a/shadows/framework/src/main/java/org/robolectric/shadows/ShadowAccessibilityNodeInfo.java b/shadows/framework/src/main/java/org/robolectric/shadows/ShadowAccessibilityNodeInfo.java index 905baf661..6fcde1f7b 100644 --- a/shadows/framework/src/main/java/org/robolectric/shadows/ShadowAccessibilityNodeInfo.java +++ b/shadows/framework/src/main/java/org/robolectric/shadows/ShadowAccessibilityNodeInfo.java @@ -429,7 +429,7 @@ public class ShadowAccessibilityNodeInfo { this.view = root; } - @Implementation(minSdk = LOLLIPOP) + @Implementation protected AccessibilityWindowInfo getWindow() { return accessibilityWindowInfo; } diff --git a/shadows/framework/src/main/java/org/robolectric/shadows/ShadowAccessibilityService.java b/shadows/framework/src/main/java/org/robolectric/shadows/ShadowAccessibilityService.java index 8c830f8ee..38f0e64d3 100644 --- a/shadows/framework/src/main/java/org/robolectric/shadows/ShadowAccessibilityService.java +++ b/shadows/framework/src/main/java/org/robolectric/shadows/ShadowAccessibilityService.java @@ -1,6 +1,5 @@ package org.robolectric.shadows; -import static android.os.Build.VERSION_CODES.LOLLIPOP; import static android.os.Build.VERSION_CODES.N; import static android.os.Build.VERSION_CODES.R; import static android.os.Build.VERSION_CODES.S; @@ -75,7 +74,7 @@ public class ShadowAccessibilityService extends ShadowService { * the values provided to {@link #setWindows(List<AccessibilityWindowInfo>)}. Returns an empty * list if not set. */ - @Implementation(minSdk = LOLLIPOP) + @Implementation protected List<AccessibilityWindowInfo> getWindows() { List<AccessibilityWindowInfo> windowInfos = windows.get(Display.DEFAULT_DISPLAY); if (windowInfos != null) { diff --git a/shadows/framework/src/main/java/org/robolectric/shadows/ShadowAccountManager.java b/shadows/framework/src/main/java/org/robolectric/shadows/ShadowAccountManager.java index a51d205d1..8ca8ee026 100644 --- a/shadows/framework/src/main/java/org/robolectric/shadows/ShadowAccountManager.java +++ b/shadows/framework/src/main/java/org/robolectric/shadows/ShadowAccountManager.java @@ -1,6 +1,5 @@ package org.robolectric.shadows; -import static android.os.Build.VERSION_CODES.LOLLIPOP; import static android.os.Build.VERSION_CODES.LOLLIPOP_MR1; import static android.os.Build.VERSION_CODES.O; @@ -608,8 +607,10 @@ public class ShadowAccountManager { previousNames.put(account, previousName); } - /** @see #setPreviousAccountName(Account, String) */ - @Implementation(minSdk = LOLLIPOP) + /** + * @see #setPreviousAccountName(Account, String) + */ + @Implementation protected String getPreviousName(Account account) { return previousNames.get(account); } diff --git a/shadows/framework/src/main/java/org/robolectric/shadows/ShadowActivity.java b/shadows/framework/src/main/java/org/robolectric/shadows/ShadowActivity.java index e4320f73f..448705290 100644 --- a/shadows/framework/src/main/java/org/robolectric/shadows/ShadowActivity.java +++ b/shadows/framework/src/main/java/org/robolectric/shadows/ShadowActivity.java @@ -1,6 +1,5 @@ package org.robolectric.shadows; -import static android.os.Build.VERSION_CODES.LOLLIPOP; import static android.os.Build.VERSION_CODES.M; import static android.os.Build.VERSION_CODES.N; import static android.os.Build.VERSION_CODES.O; @@ -363,7 +362,7 @@ public class ShadowActivity extends ShadowContextThemeWrapper { reflector(_Activity_.class, realActivity).setFinished(true); } - @Implementation(minSdk = LOLLIPOP) + @Implementation protected void finishAndRemoveTask() { // Sets the mFinished field in the real activity so NoDisplay activities can be tested. reflector(_Activity_.class, realActivity).setFinished(true); @@ -846,7 +845,7 @@ public class ShadowActivity extends ShadowContextThemeWrapper { * <p>The status of the lock task can be verified using {@link #isLockTask} method. Otherwise this * implementation has no effect. */ - @Implementation(minSdk = LOLLIPOP) + @Implementation protected void startLockTask() { Shadow.<ShadowActivityManager>extract(getActivityManager()) .setLockTaskModeState(ActivityManager.LOCK_TASK_MODE_LOCKED); @@ -858,7 +857,7 @@ public class ShadowActivity extends ShadowContextThemeWrapper { * <p>The status of the lock task can be verified using {@link #isLockTask} method. Otherwise this * implementation has no effect. */ - @Implementation(minSdk = LOLLIPOP) + @Implementation protected void stopLockTask() { Shadow.<ShadowActivityManager>extract(getActivityManager()) .setLockTaskModeState(ActivityManager.LOCK_TASK_MODE_NONE); diff --git a/shadows/framework/src/main/java/org/robolectric/shadows/ShadowActivityManager.java b/shadows/framework/src/main/java/org/robolectric/shadows/ShadowActivityManager.java index b3607ac0e..17516f9f8 100644 --- a/shadows/framework/src/main/java/org/robolectric/shadows/ShadowActivityManager.java +++ b/shadows/framework/src/main/java/org/robolectric/shadows/ShadowActivityManager.java @@ -1,7 +1,6 @@ package org.robolectric.shadows; import static android.app.ActivityManager.RunningAppProcessInfo.IMPORTANCE_GONE; -import static android.os.Build.VERSION_CODES.LOLLIPOP; import static android.os.Build.VERSION_CODES.M; import static android.os.Build.VERSION_CODES.O; import static android.os.Build.VERSION_CODES.P; @@ -112,7 +111,7 @@ public class ShadowActivityManager { * @see #setAppTasks(List) * @return List of current AppTask. */ - @Implementation(minSdk = LOLLIPOP) + @Implementation protected List<ActivityManager.AppTask> getAppTasks() { return appTasks; } @@ -294,7 +293,7 @@ public class ShadowActivityManager { return lockTaskModeState; } - @Implementation(minSdk = VERSION_CODES.LOLLIPOP) + @Implementation protected boolean isInLockTaskMode() { return getLockTaskModeState() != ActivityManager.LOCK_TASK_MODE_NONE; } diff --git a/shadows/framework/src/main/java/org/robolectric/shadows/ShadowAlarmManager.java b/shadows/framework/src/main/java/org/robolectric/shadows/ShadowAlarmManager.java index 2971b8e57..cec406166 100644 --- a/shadows/framework/src/main/java/org/robolectric/shadows/ShadowAlarmManager.java +++ b/shadows/framework/src/main/java/org/robolectric/shadows/ShadowAlarmManager.java @@ -204,7 +204,7 @@ public class ShadowAlarmManager { } @RequiresApi(VERSION_CODES.LOLLIPOP) - @Implementation(minSdk = VERSION_CODES.LOLLIPOP) + @Implementation protected void setAlarmClock(AlarmClockInfo info, PendingIntent operation) { setImpl(RTC_WAKEUP, info.getTriggerTime(), WINDOW_EXACT, 0L, operation, null, info, true); } @@ -356,7 +356,7 @@ public class ShadowAlarmManager { } @RequiresApi(VERSION_CODES.LOLLIPOP) - @Implementation(minSdk = VERSION_CODES.LOLLIPOP) + @Implementation @Nullable protected AlarmClockInfo getNextAlarmClock() { synchronized (scheduledAlarms) { diff --git a/shadows/framework/src/main/java/org/robolectric/shadows/ShadowAlertController.java b/shadows/framework/src/main/java/org/robolectric/shadows/ShadowAlertController.java index ead437d8e..e242eb201 100644 --- a/shadows/framework/src/main/java/org/robolectric/shadows/ShadowAlertController.java +++ b/shadows/framework/src/main/java/org/robolectric/shadows/ShadowAlertController.java @@ -1,6 +1,5 @@ package org.robolectric.shadows; -import static android.os.Build.VERSION_CODES.LOLLIPOP; import static org.robolectric.util.reflector.Reflector.reflector; import android.view.LayoutInflater; @@ -64,7 +63,7 @@ public class ShadowAlertController { reflector(AlertControllerReflector.class, realAlertController).setView(view); } - @Implementation(minSdk = LOLLIPOP) + @Implementation public void setView(int resourceId) { setView(LayoutInflater.from(RuntimeEnvironment.getApplication()).inflate(resourceId, null)); } diff --git a/shadows/framework/src/main/java/org/robolectric/shadows/ShadowAppOpsManager.java b/shadows/framework/src/main/java/org/robolectric/shadows/ShadowAppOpsManager.java index 814e96a76..e2930b799 100644 --- a/shadows/framework/src/main/java/org/robolectric/shadows/ShadowAppOpsManager.java +++ b/shadows/framework/src/main/java/org/robolectric/shadows/ShadowAppOpsManager.java @@ -1,6 +1,5 @@ package org.robolectric.shadows; -import static android.os.Build.VERSION_CODES.LOLLIPOP; import static android.os.Build.VERSION_CODES.M; import static android.os.Build.VERSION_CODES.P; import static android.os.Build.VERSION_CODES.Q; @@ -492,7 +491,7 @@ public class ShadowAppOpsManager { * * <p>This method is public for testing, as the original method is {@code @hide}. */ - @Implementation(minSdk = LOLLIPOP) + @Implementation @HiddenApi public void setRestriction( int code, @AttributeUsage int usage, int mode, String[] exceptionPackages) { diff --git a/shadows/framework/src/main/java/org/robolectric/shadows/ShadowAppWidgetManager.java b/shadows/framework/src/main/java/org/robolectric/shadows/ShadowAppWidgetManager.java index b1d78d1f4..439906678 100644 --- a/shadows/framework/src/main/java/org/robolectric/shadows/ShadowAppWidgetManager.java +++ b/shadows/framework/src/main/java/org/robolectric/shadows/ShadowAppWidgetManager.java @@ -1,8 +1,6 @@ package org.robolectric.shadows; -import static android.os.Build.VERSION_CODES.KITKAT; import static android.os.Build.VERSION_CODES.L; -import static android.os.Build.VERSION_CODES.LOLLIPOP; import static android.os.Build.VERSION_CODES.O; import static org.robolectric.util.reflector.Reflector.reflector; @@ -58,12 +56,7 @@ public class ShadowAppWidgetManager { // to false if the last widget is removed (when removing widgets is implemented). private boolean isWidgetsEnabled = false; - @Implementation(maxSdk = KITKAT) - protected void __constructor__(Context context) { - this.context = context; - } - - @Implementation(minSdk = LOLLIPOP) + @Implementation protected void __constructor__(Context context, IAppWidgetService service) { this.context = context; } diff --git a/shadows/framework/src/main/java/org/robolectric/shadows/ShadowApplicationPackageManager.java b/shadows/framework/src/main/java/org/robolectric/shadows/ShadowApplicationPackageManager.java index 77fc0c11a..f749507b9 100644 --- a/shadows/framework/src/main/java/org/robolectric/shadows/ShadowApplicationPackageManager.java +++ b/shadows/framework/src/main/java/org/robolectric/shadows/ShadowApplicationPackageManager.java @@ -22,7 +22,6 @@ import static android.content.pm.PackageManager.MATCH_DISABLED_COMPONENTS; import static android.content.pm.PackageManager.MATCH_UNINSTALLED_PACKAGES; import static android.content.pm.PackageManager.SIGNATURE_UNKNOWN_PACKAGE; import static android.os.Build.VERSION_CODES.JELLY_BEAN; -import static android.os.Build.VERSION_CODES.LOLLIPOP; import static android.os.Build.VERSION_CODES.LOLLIPOP_MR1; import static android.os.Build.VERSION_CODES.M; import static android.os.Build.VERSION_CODES.N; @@ -463,7 +462,7 @@ public class ShadowApplicationPackageManager extends ShadowPackageManager { return null; } - @Implementation(minSdk = LOLLIPOP) + @Implementation protected ProviderInfo resolveContentProviderAsUser( String name, int flags, @UserIdInt int userId) { return null; @@ -1281,7 +1280,7 @@ public class ShadowApplicationPackageManager extends ShadowPackageManager { return getApplicationIcon(info.packageName); } - @Implementation(minSdk = LOLLIPOP) + @Implementation protected Drawable getUserBadgeForDensity(UserHandle userHandle, int i) { return null; } @@ -1383,7 +1382,7 @@ public class ShadowApplicationPackageManager extends ShadowPackageManager { return getLaunchIntentForPackage(packageName, Intent.CATEGORY_LAUNCHER); } - @Implementation(minSdk = LOLLIPOP) + @Implementation protected Intent getLeanbackLaunchIntentForPackage(String packageName) { return getLaunchIntentForPackage(packageName, Intent.CATEGORY_LEANBACK_LAUNCHER); } @@ -2014,7 +2013,7 @@ public class ShadowApplicationPackageManager extends ShadowPackageManager { @Implementation(minSdk = N) protected void flushPackageRestrictionsAsUser(int userId) {} - @Implementation(minSdk = LOLLIPOP) + @Implementation protected boolean setApplicationHiddenSettingAsUser( String packageName, boolean hidden, UserHandle user) { synchronized (lock) { @@ -2033,7 +2032,7 @@ public class ShadowApplicationPackageManager extends ShadowPackageManager { } } - @Implementation(minSdk = LOLLIPOP) + @Implementation protected boolean getApplicationHiddenSettingAsUser(String packageName, UserHandle user) { // Note that this ignores the UserHandle parameter synchronized (lock) { @@ -2055,16 +2054,16 @@ public class ShadowApplicationPackageManager extends ShadowPackageManager { return false; } - @Implementation(minSdk = LOLLIPOP) + @Implementation protected boolean isPackageAvailable(String packageName) { return false; } - @Implementation(minSdk = LOLLIPOP) + @Implementation protected void addCrossProfileIntentFilter( IntentFilter filter, int sourceUserId, int targetUserId, int flags) {} - @Implementation(minSdk = LOLLIPOP) + @Implementation protected void clearCrossProfileIntentFilters(int sourceUserId) {} /** @@ -2087,7 +2086,7 @@ public class ShadowApplicationPackageManager extends ShadowPackageManager { * <p>This implementation just returns the unbadged icon, as some default implementations add an * internal resource to the icon that is unavailable to Robolectric. */ - @Implementation(minSdk = LOLLIPOP) + @Implementation protected Drawable getUserBadgedIcon(Drawable icon, UserHandle user) { return icon; } diff --git a/shadows/framework/src/main/java/org/robolectric/shadows/ShadowArscAssetManager.java b/shadows/framework/src/main/java/org/robolectric/shadows/ShadowArscAssetManager.java index d3d487190..31fa0480f 100644 --- a/shadows/framework/src/main/java/org/robolectric/shadows/ShadowArscAssetManager.java +++ b/shadows/framework/src/main/java/org/robolectric/shadows/ShadowArscAssetManager.java @@ -1,7 +1,5 @@ package org.robolectric.shadows; -import static android.os.Build.VERSION_CODES.KITKAT_WATCH; -import static android.os.Build.VERSION_CODES.LOLLIPOP; import static android.os.Build.VERSION_CODES.M; import static android.os.Build.VERSION_CODES.N_MR1; import static android.os.Build.VERSION_CODES.O; @@ -419,25 +417,13 @@ public class ShadowArscAssetManager extends ShadowAssetManager.ArscBase { } @HiddenApi - @Implementation(maxSdk = KITKAT_WATCH) - protected void destroyAsset(int asset) { - destroyAsset((long) asset); - } - - @HiddenApi - @Implementation(minSdk = LOLLIPOP) + @Implementation protected void destroyAsset(long asset) { Registries.NATIVE_ASSET_REGISTRY.unregister(asset); } @HiddenApi - @Implementation(maxSdk = KITKAT_WATCH) - protected int readAssetChar(int asset) { - return readAssetChar((long) asset); - } - - @HiddenApi - @Implementation(minSdk = LOLLIPOP) + @Implementation protected int readAssetChar(long asset) { Asset a = getAsset(asset); byte[] b = new byte[1]; @@ -446,13 +432,7 @@ public class ShadowArscAssetManager extends ShadowAssetManager.ArscBase { } @HiddenApi - @Implementation(maxSdk = KITKAT_WATCH) - protected int readAsset(int asset, byte[] b, int off, int len) throws IOException { - return readAsset((long) asset, b, off, len); - } - - @HiddenApi - @Implementation(minSdk = LOLLIPOP) + @Implementation protected int readAsset(long asset, byte[] bArray, int off, int len) throws IOException { Asset a = getAsset(asset); @@ -481,39 +461,21 @@ public class ShadowArscAssetManager extends ShadowAssetManager.ArscBase { } @HiddenApi - @Implementation(maxSdk = KITKAT_WATCH) - protected long seekAsset(int asset, long offset, int whence) { - return seekAsset((long) asset, offset, whence); - } - - @HiddenApi - @Implementation(minSdk = LOLLIPOP) + @Implementation protected long seekAsset(long asset, long offset, int whence) { Asset a = getAsset(asset); return a.seek(offset, whence < 0 ? SEEK_SET : SEEK_CUR); } @HiddenApi - @Implementation(maxSdk = KITKAT_WATCH) - protected long getAssetLength(int asset) { - return getAssetLength((long) asset); - } - - @HiddenApi - @Implementation(minSdk = LOLLIPOP) + @Implementation protected long getAssetLength(long asset) { Asset a = getAsset(asset); return a.getLength(); } @HiddenApi - @Implementation(maxSdk = KITKAT_WATCH) - protected long getAssetRemainingLength(int asset) { - return getAssetRemainingLength((long) asset); - } - - @HiddenApi - @Implementation(minSdk = LOLLIPOP) + @Implementation protected long getAssetRemainingLength(long assetHandle) { Asset a = getAsset(assetHandle); @@ -697,13 +659,6 @@ public class ShadowArscAssetManager extends ShadowAssetManager.ArscBase { // # define PRIx16 "x" // # define PRIx32 "x" - @HiddenApi @Implementation(maxSdk = KITKAT_WATCH) - protected static void applyStyle(int themeToken, int defStyleAttr, int defStyleRes, - int xmlParserToken, int[] attrs, int[] outValues, int[] outIndices) { - applyStyle((long)themeToken, defStyleAttr, defStyleRes, (long)xmlParserToken, attrs, - outValues, outIndices); - } - @HiddenApi @Implementation(minSdk = O, maxSdk = O_MR1) protected static void applyStyle(long themeToken, int defStyleAttr, int defStyleRes, long xmlParserToken, int[] inAttrs, int length, long outValuesAddress, @@ -715,9 +670,16 @@ public class ShadowArscAssetManager extends ShadowAssetManager.ArscBase { outValues, outIndices); } - @HiddenApi @Implementation(minSdk = LOLLIPOP, maxSdk = N_MR1) - protected static void applyStyle(long themeToken, int defStyleAttr, int defStyleRes, - long xmlParserToken, int[] attrs, int[] outValues, int[] outIndices) { + @HiddenApi + @Implementation(maxSdk = N_MR1) + protected static void applyStyle( + long themeToken, + int defStyleAttr, + int defStyleRes, + long xmlParserToken, + int[] attrs, + int[] outValues, + int[] outIndices) { ResTableTheme theme = Registries.NATIVE_THEME_REGISTRY.getNativeObject(themeToken); ResXMLParser xmlParser = xmlParserToken == 0 ? null @@ -786,14 +748,7 @@ public class ShadowArscAssetManager extends ShadowAssetManager.ArscBase { } @HiddenApi - @Implementation(maxSdk = KITKAT_WATCH) - protected boolean retrieveAttributes( - int xmlParserToken, int[] attrs, int[] outValues, int[] outIndices) { - return retrieveAttributes((long)xmlParserToken, attrs, outValues, outIndices); - } - - @HiddenApi - @Implementation(minSdk = LOLLIPOP) + @Implementation protected boolean retrieveAttributes( long xmlParserToken, int[] attrs, int[] outValues, int[] outIndices) { if (xmlParserToken == 0) { @@ -1003,49 +958,29 @@ public class ShadowArscAssetManager extends ShadowAssetManager.ArscBase { } @HiddenApi - @Implementation(maxSdk = KITKAT_WATCH) - protected void deleteTheme(int theme) { - deleteTheme((long) theme); - } - - @HiddenApi - @Implementation(minSdk = LOLLIPOP) + @Implementation protected void deleteTheme(long theme) { Registries.NATIVE_THEME_REGISTRY.unregister(theme); } @HiddenApi - @Implementation(maxSdk = KITKAT_WATCH) - public static void applyThemeStyle(int themePtr, int styleRes, boolean force) { - applyThemeStyle((long)themePtr, styleRes, force); - } - - @HiddenApi @Implementation(minSdk = LOLLIPOP, maxSdk = O_MR1) + @Implementation(maxSdk = O_MR1) public static void applyThemeStyle(long themePtr, int styleRes, boolean force) { Registries.NATIVE_THEME_REGISTRY.getNativeObject(themePtr).applyStyle(styleRes, force); } - @HiddenApi @Implementation(maxSdk = KITKAT_WATCH) - public static void copyTheme(int destPtr, int sourcePtr) { - copyTheme((long) destPtr, (long) sourcePtr); - } - - @HiddenApi @Implementation(minSdk = LOLLIPOP, maxSdk = O_MR1) + @HiddenApi + @Implementation(maxSdk = O_MR1) public static void copyTheme(long destPtr, long sourcePtr) { ResTableTheme dest = Registries.NATIVE_THEME_REGISTRY.getNativeObject(destPtr); ResTableTheme src = Registries.NATIVE_THEME_REGISTRY.getNativeObject(sourcePtr); dest.setTo(src); } - @HiddenApi @Implementation(maxSdk = KITKAT_WATCH) - protected static int loadThemeAttributeValue(int themeHandle, int ident, - TypedValue outValue, boolean resolve) { - return loadThemeAttributeValue((long) themeHandle, ident, outValue, resolve); - } - - @HiddenApi @Implementation(minSdk = LOLLIPOP) - protected static int loadThemeAttributeValue(long themeHandle, int ident, - TypedValue outValue, boolean resolve) { + @HiddenApi + @Implementation + protected static int loadThemeAttributeValue( + long themeHandle, int ident, TypedValue outValue, boolean resolve) { ResTableTheme theme = Preconditions.checkNotNull(Registries.NATIVE_THEME_REGISTRY.getNativeObject(themeHandle)); ResTable res = theme.getResTable(); @@ -1274,17 +1209,10 @@ public class ShadowArscAssetManager extends ShadowAssetManager.ArscBase { return array; } - @HiddenApi @Implementation(maxSdk = VERSION_CODES.KITKAT) - protected void init() { - // if (isSystem) { - // verifySystemIdmaps(); - // } - init(false); - } - private static CppAssetManager systemCppAssetManager; - @HiddenApi @Implementation(minSdk = VERSION_CODES.KITKAT_WATCH) + @HiddenApi + @Implementation protected void init(boolean isSystem) { // if (isSystem) { // verifySystemIdmaps(); diff --git a/shadows/framework/src/main/java/org/robolectric/shadows/ShadowAudioManager.java b/shadows/framework/src/main/java/org/robolectric/shadows/ShadowAudioManager.java index c2e7e21c9..1d7ba935f 100644 --- a/shadows/framework/src/main/java/org/robolectric/shadows/ShadowAudioManager.java +++ b/shadows/framework/src/main/java/org/robolectric/shadows/ShadowAudioManager.java @@ -1,6 +1,5 @@ package org.robolectric.shadows; -import static android.os.Build.VERSION_CODES.LOLLIPOP; import static android.os.Build.VERSION_CODES.M; import static android.os.Build.VERSION_CODES.N; import static android.os.Build.VERSION_CODES.O; @@ -977,7 +976,7 @@ public class ShadowAudioManager { * returning positive distinct values, or {@link AudioManager#ERROR} if all possible values have * already been returned. */ - @Implementation(minSdk = LOLLIPOP) + @Implementation protected int generateAudioSessionId() { if (audioSessionIdCounter < 0) { return AudioManager.ERROR; diff --git a/shadows/framework/src/main/java/org/robolectric/shadows/ShadowAudioTrack.java b/shadows/framework/src/main/java/org/robolectric/shadows/ShadowAudioTrack.java index 4ffeb5edd..52f00724e 100644 --- a/shadows/framework/src/main/java/org/robolectric/shadows/ShadowAudioTrack.java +++ b/shadows/framework/src/main/java/org/robolectric/shadows/ShadowAudioTrack.java @@ -4,7 +4,6 @@ import static android.media.AudioTrack.ERROR_BAD_VALUE; import static android.media.AudioTrack.ERROR_DEAD_OBJECT; import static android.media.AudioTrack.WRITE_BLOCKING; import static android.media.AudioTrack.WRITE_NON_BLOCKING; -import static android.os.Build.VERSION_CODES.LOLLIPOP; import static android.os.Build.VERSION_CODES.M; import static android.os.Build.VERSION_CODES.N; import static android.os.Build.VERSION_CODES.P; @@ -358,7 +357,7 @@ public class ShadowAudioTrack { * properly created). Do not block even if {@link AudioTrack} in offload mode is in STOPPING play * state. This method returns immediately even with {@link AudioTrack#WRITE_BLOCKING} */ - @Implementation(minSdk = LOLLIPOP) + @Implementation protected int write(@NonNull ByteBuffer audioData, int sizeInBytes, @WriteMode int writeMode) { int encoding = audioTrack.getAudioFormat(); // Assume that offload support does not change during the lifetime of the instance. diff --git a/shadows/framework/src/main/java/org/robolectric/shadows/ShadowBackupManager.java b/shadows/framework/src/main/java/org/robolectric/shadows/ShadowBackupManager.java index 8c42bc161..e40c61fc6 100644 --- a/shadows/framework/src/main/java/org/robolectric/shadows/ShadowBackupManager.java +++ b/shadows/framework/src/main/java/org/robolectric/shadows/ShadowBackupManager.java @@ -1,6 +1,5 @@ package org.robolectric.shadows; -import static android.os.Build.VERSION_CODES.LOLLIPOP; import static android.os.Build.VERSION_CODES.M; import android.app.backup.BackupManager; @@ -75,14 +74,14 @@ public class ShadowBackupManager { return serviceState.dataChangedCount.getOrDefault(context.getPackageName(), 0); } - @Implementation(minSdk = LOLLIPOP) + @Implementation @HiddenApi // SystemApi protected void setBackupEnabled(boolean isEnabled) { enforceBackupPermission("setBackupEnabled"); serviceState.backupEnabled = isEnabled; } - @Implementation(minSdk = LOLLIPOP) + @Implementation @HiddenApi // SystemApi protected boolean isBackupEnabled() { enforceBackupPermission("isBackupEnabled"); diff --git a/shadows/framework/src/main/java/org/robolectric/shadows/ShadowBatteryManager.java b/shadows/framework/src/main/java/org/robolectric/shadows/ShadowBatteryManager.java index aeceac4db..2f168385e 100644 --- a/shadows/framework/src/main/java/org/robolectric/shadows/ShadowBatteryManager.java +++ b/shadows/framework/src/main/java/org/robolectric/shadows/ShadowBatteryManager.java @@ -1,6 +1,5 @@ package org.robolectric.shadows; -import static android.os.Build.VERSION_CODES.LOLLIPOP; import static android.os.Build.VERSION_CODES.M; import static android.os.Build.VERSION_CODES.P; @@ -27,7 +26,7 @@ public class ShadowBatteryManager { isCharging = charging; } - @Implementation(minSdk = LOLLIPOP) + @Implementation protected int getIntProperty(int id) { return intProperties.containsKey(id) ? intProperties.get(id) : Integer.MIN_VALUE; } @@ -36,7 +35,7 @@ public class ShadowBatteryManager { intProperties.put(id, value); } - @Implementation(minSdk = LOLLIPOP) + @Implementation protected long getLongProperty(int id) { return longProperties.containsKey(id) ? longProperties.get(id) : Long.MIN_VALUE; } diff --git a/shadows/framework/src/main/java/org/robolectric/shadows/ShadowBluetoothAdapter.java b/shadows/framework/src/main/java/org/robolectric/shadows/ShadowBluetoothAdapter.java index bff4fe2b7..49d43d475 100644 --- a/shadows/framework/src/main/java/org/robolectric/shadows/ShadowBluetoothAdapter.java +++ b/shadows/framework/src/main/java/org/robolectric/shadows/ShadowBluetoothAdapter.java @@ -1,7 +1,6 @@ package org.robolectric.shadows; import static android.bluetooth.BluetoothAdapter.STATE_ON; -import static android.os.Build.VERSION_CODES.LOLLIPOP; import static android.os.Build.VERSION_CODES.M; import static android.os.Build.VERSION_CODES.O; import static android.os.Build.VERSION_CODES.Q; @@ -447,7 +446,7 @@ public class ShadowBluetoothAdapter { return BluetoothStatusCodes.SUCCESS; } - @Implementation(minSdk = LOLLIPOP) + @Implementation protected boolean isMultipleAdvertisementSupported() { return isMultipleAdvertisementSupported; } diff --git a/shadows/framework/src/main/java/org/robolectric/shadows/ShadowBluetoothDevice.java b/shadows/framework/src/main/java/org/robolectric/shadows/ShadowBluetoothDevice.java index 56b3be662..ff9cd6eed 100644 --- a/shadows/framework/src/main/java/org/robolectric/shadows/ShadowBluetoothDevice.java +++ b/shadows/framework/src/main/java/org/robolectric/shadows/ShadowBluetoothDevice.java @@ -2,7 +2,6 @@ package org.robolectric.shadows; import static android.bluetooth.BluetoothDevice.BOND_NONE; import static android.content.pm.PackageManager.PERMISSION_GRANTED; -import static android.os.Build.VERSION_CODES.KITKAT_WATCH; import static android.os.Build.VERSION_CODES.M; import static android.os.Build.VERSION_CODES.O; import static android.os.Build.VERSION_CODES.O_MR1; @@ -436,7 +435,7 @@ public class ShadowBluetoothDevice { return true; } - @Implementation(minSdk = KITKAT_WATCH) + @Implementation protected boolean isConnected() { return isConnected; } diff --git a/shadows/framework/src/main/java/org/robolectric/shadows/ShadowCameraManager.java b/shadows/framework/src/main/java/org/robolectric/shadows/ShadowCameraManager.java index b2776de84..be1e29713 100644 --- a/shadows/framework/src/main/java/org/robolectric/shadows/ShadowCameraManager.java +++ b/shadows/framework/src/main/java/org/robolectric/shadows/ShadowCameraManager.java @@ -205,14 +205,14 @@ public class ShadowCameraManager { return deviceImpl; } - @Implementation(minSdk = VERSION_CODES.LOLLIPOP) + @Implementation protected void registerAvailabilityCallback( CameraManager.AvailabilityCallback callback, Handler handler) { Preconditions.checkNotNull(callback); registeredCallbacks.add(callback); } - @Implementation(minSdk = VERSION_CODES.LOLLIPOP) + @Implementation protected void unregisterAvailabilityCallback(CameraManager.AvailabilityCallback callback) { Preconditions.checkNotNull(callback); registeredCallbacks.remove(callback); diff --git a/shadows/framework/src/main/java/org/robolectric/shadows/ShadowCameraMetadataNative.java b/shadows/framework/src/main/java/org/robolectric/shadows/ShadowCameraMetadataNative.java index 840b959e2..f3cde0665 100644 --- a/shadows/framework/src/main/java/org/robolectric/shadows/ShadowCameraMetadataNative.java +++ b/shadows/framework/src/main/java/org/robolectric/shadows/ShadowCameraMetadataNative.java @@ -14,12 +14,12 @@ import org.robolectric.annotation.Implements; maxSdk = Q, isInAndroidSdk = false) public class ShadowCameraMetadataNative { - @Implementation(minSdk = LOLLIPOP, maxSdk = Q) + @Implementation(maxSdk = Q) protected long nativeAllocate() { return 1L; } - @Implementation(minSdk = LOLLIPOP, maxSdk = Q) + @Implementation(maxSdk = Q) protected long nativeAllocateCopy(CameraMetadataNative other) { return 1L; } diff --git a/shadows/framework/src/main/java/org/robolectric/shadows/ShadowConnectivityManager.java b/shadows/framework/src/main/java/org/robolectric/shadows/ShadowConnectivityManager.java index 010f9619b..dbb580883 100644 --- a/shadows/framework/src/main/java/org/robolectric/shadows/ShadowConnectivityManager.java +++ b/shadows/framework/src/main/java/org/robolectric/shadows/ShadowConnectivityManager.java @@ -99,7 +99,7 @@ public class ShadowConnectivityManager { return new HashMap<>(reportedNetworkConnectivity); } - @Implementation(minSdk = LOLLIPOP) + @Implementation protected void registerNetworkCallback( NetworkRequest request, ConnectivityManager.NetworkCallback networkCallback) { registerNetworkCallback(request, networkCallback, null); @@ -118,7 +118,7 @@ public class ShadowConnectivityManager { networkCallbackPendingIntents.add(pendingIntent); } - @Implementation(minSdk = LOLLIPOP) + @Implementation protected void requestNetwork( NetworkRequest request, ConnectivityManager.NetworkCallback networkCallback) { registerNetworkCallback(request, networkCallback); @@ -161,7 +161,7 @@ public class ShadowConnectivityManager { networkCallbacks.add(networkCallback); } - @Implementation(minSdk = LOLLIPOP) + @Implementation protected void unregisterNetworkCallback(ConnectivityManager.NetworkCallback networkCallback) { if (networkCallback == null) { throw new IllegalArgumentException("Invalid NetworkCallback"); @@ -218,7 +218,7 @@ public class ShadowConnectivityManager { return networkTypeToNetworkInfo.get(networkType); } - @Implementation(minSdk = LOLLIPOP) + @Implementation protected NetworkInfo getNetworkInfo(Network network) { if (network == null) { return null; @@ -227,7 +227,7 @@ public class ShadowConnectivityManager { return netIdToNetworkInfo.get(shadowNetwork.getNetId()); } - @Implementation(minSdk = LOLLIPOP) + @Implementation protected Network[] getAllNetworks() { return netIdToNetwork.values().toArray(new Network[netIdToNetwork.size()]); } @@ -383,17 +383,18 @@ public class ShadowConnectivityManager { * @return true by default, or the value specifed via {@link #setDefaultNetworkActive(boolean)} * @see #setDefaultNetworkActive(boolean) */ - @Implementation(minSdk = LOLLIPOP) + @Implementation protected boolean isDefaultNetworkActive() { return defaultNetworkActive; } - @Implementation(minSdk = LOLLIPOP) - protected void addDefaultNetworkActiveListener(final ConnectivityManager.OnNetworkActiveListener l) { + @Implementation + protected void addDefaultNetworkActiveListener( + final ConnectivityManager.OnNetworkActiveListener l) { onNetworkActiveListeners.add(l); } - @Implementation(minSdk = LOLLIPOP) + @Implementation protected void removeDefaultNetworkActiveListener(ConnectivityManager.OnNetworkActiveListener l) { if (l == null) { throw new IllegalArgumentException("Invalid OnNetworkActiveListener"); @@ -415,7 +416,7 @@ public class ShadowConnectivityManager { * @return The {@link android.net.NetworkCapabilities} for the network. * @see #setNetworkCapabilities(Network, NetworkCapabilities) */ - @Implementation(minSdk = LOLLIPOP) + @Implementation protected NetworkCapabilities getNetworkCapabilities(Network network) { return networkCapabilitiesMap.get(network); } @@ -441,8 +442,10 @@ public class ShadowConnectivityManager { ShadowSettings.setAirplaneMode(enable); } - /** @see #setLinkProperties(Network, LinkProperties) */ - @Implementation(minSdk = LOLLIPOP) + /** + * @see #setLinkProperties(Network, LinkProperties) + */ + @Implementation protected LinkProperties getLinkProperties(Network network) { return linkPropertiesMap.get(network); } diff --git a/shadows/framework/src/main/java/org/robolectric/shadows/ShadowContextImpl.java b/shadows/framework/src/main/java/org/robolectric/shadows/ShadowContextImpl.java index 1bf662214..af41db2df 100644 --- a/shadows/framework/src/main/java/org/robolectric/shadows/ShadowContextImpl.java +++ b/shadows/framework/src/main/java/org/robolectric/shadows/ShadowContextImpl.java @@ -1,6 +1,5 @@ package org.robolectric.shadows; -import static android.os.Build.VERSION_CODES.LOLLIPOP; import static android.os.Build.VERSION_CODES.M; import static android.os.Build.VERSION_CODES.N; import static android.os.Build.VERSION_CODES.O; @@ -364,7 +363,7 @@ public class ShadowContextImpl { } /** Binds to a service but ignores the given UserHandle. */ - @Implementation(minSdk = LOLLIPOP) + @Implementation protected boolean bindServiceAsUser( Intent intent, final ServiceConnection serviceConnection, int i, UserHandle userHandle) { return bindService(intent, serviceConnection, i); @@ -389,7 +388,7 @@ public class ShadowContextImpl { * Behaves as {@link android.app.ContextImpl#startActivity(Intent, Bundle)}. The user parameter is * ignored. */ - @Implementation(minSdk = LOLLIPOP) + @Implementation protected void startActivityAsUser(Intent intent, Bundle options, UserHandle user) { // TODO: Remove this once {@link com.android.server.wmActivityTaskManagerService} is // properly shadowed. diff --git a/shadows/framework/src/main/java/org/robolectric/shadows/ShadowDatePickerDialog.java b/shadows/framework/src/main/java/org/robolectric/shadows/ShadowDatePickerDialog.java index f0313f2a8..b7a59ba05 100644 --- a/shadows/framework/src/main/java/org/robolectric/shadows/ShadowDatePickerDialog.java +++ b/shadows/framework/src/main/java/org/robolectric/shadows/ShadowDatePickerDialog.java @@ -1,18 +1,14 @@ package org.robolectric.shadows; -import static android.os.Build.VERSION_CODES.KITKAT; -import static android.os.Build.VERSION_CODES.KITKAT_WATCH; import static android.os.Build.VERSION_CODES.N; import static org.robolectric.shadow.api.Shadow.invokeConstructor; import static org.robolectric.util.ReflectionHelpers.ClassParameter; import static org.robolectric.util.reflector.Reflector.reflector; -import android.annotation.RequiresApi; import android.app.DatePickerDialog; import android.app.DatePickerDialog.OnDateSetListener; import android.content.Context; import java.util.Calendar; -import org.robolectric.RuntimeEnvironment; import org.robolectric.annotation.Implementation; import org.robolectric.annotation.Implements; import org.robolectric.annotation.RealObject; @@ -63,23 +59,14 @@ public class ShadowDatePickerDialog extends ShadowAlertDialog { } public DatePickerDialog.OnDateSetListener getOnDateSetListenerCallback() { - if (RuntimeEnvironment.getApiLevel() == KITKAT) { - return reflector(DatePickerDialogReflector.class, realDatePickerDialog).getCallback(); - } else { - return reflector(DatePickerDialogReflector.class, realDatePickerDialog).getDateSetListener(); - } + + return reflector(DatePickerDialogReflector.class, realDatePickerDialog).getDateSetListener(); } @ForType(DatePickerDialog.class) interface DatePickerDialogReflector { - /** For sdk version at least {@link KITKAT_WATCH} */ - @RequiresApi(KITKAT_WATCH) @Accessor("mDateSetListener") OnDateSetListener getDateSetListener(); - - /** For sdk version is equals to {@link KITKAT} */ - @Accessor("mCallBack") - OnDateSetListener getCallback(); } } diff --git a/shadows/framework/src/main/java/org/robolectric/shadows/ShadowDebug.java b/shadows/framework/src/main/java/org/robolectric/shadows/ShadowDebug.java index b2f1a5544..19dcbdd39 100644 --- a/shadows/framework/src/main/java/org/robolectric/shadows/ShadowDebug.java +++ b/shadows/framework/src/main/java/org/robolectric/shadows/ShadowDebug.java @@ -1,6 +1,5 @@ package org.robolectric.shadows; -import static android.os.Build.VERSION_CODES.LOLLIPOP; import static android.os.Build.VERSION_CODES.M; import static android.os.Build.VERSION_CODES.N; @@ -57,8 +56,9 @@ public class ShadowDebug { internalStartTracing(fixTracePath(tracePath)); } - @Implementation(minSdk = LOLLIPOP) - protected static void startMethodTracingSampling(String tracePath, int bufferSize, int intervalUs) { + @Implementation + protected static void startMethodTracingSampling( + String tracePath, int bufferSize, int intervalUs) { internalStartTracing(fixTracePath(tracePath)); } diff --git a/shadows/framework/src/main/java/org/robolectric/shadows/ShadowDevicePolicyManager.java b/shadows/framework/src/main/java/org/robolectric/shadows/ShadowDevicePolicyManager.java index e4a197af8..83f659e2b 100644 --- a/shadows/framework/src/main/java/org/robolectric/shadows/ShadowDevicePolicyManager.java +++ b/shadows/framework/src/main/java/org/robolectric/shadows/ShadowDevicePolicyManager.java @@ -3,7 +3,6 @@ package org.robolectric.shadows; import static android.app.admin.DevicePolicyManager.LOCK_TASK_FEATURE_HOME; import static android.app.admin.DevicePolicyManager.LOCK_TASK_FEATURE_NOTIFICATIONS; import static android.app.admin.DevicePolicyManager.LOCK_TASK_FEATURE_OVERVIEW; -import static android.os.Build.VERSION_CODES.LOLLIPOP; import static android.os.Build.VERSION_CODES.LOLLIPOP_MR1; import static android.os.Build.VERSION_CODES.M; import static android.os.Build.VERSION_CODES.N; @@ -218,7 +217,7 @@ public class ShadowDevicePolicyManager { return deviceOwner != null && deviceOwner.getPackageName().equals(packageName); } - @Implementation(minSdk = LOLLIPOP) + @Implementation protected boolean isProfileOwnerApp(String packageName) { return profileOwner != null && profileOwner.getPackageName().equals(packageName); } @@ -233,19 +232,19 @@ public class ShadowDevicePolicyManager { return deviceAdmins; } - @Implementation(minSdk = LOLLIPOP) + @Implementation protected void addUserRestriction(ComponentName admin, String key) { enforceActiveAdmin(admin); getShadowUserManager().setUserRestriction(Process.myUserHandle(), key, true); } - @Implementation(minSdk = LOLLIPOP) + @Implementation protected void clearUserRestriction(ComponentName admin, String key) { enforceActiveAdmin(admin); getShadowUserManager().setUserRestriction(Process.myUserHandle(), key, false); } - @Implementation(minSdk = LOLLIPOP) + @Implementation protected boolean setApplicationHidden(ComponentName admin, String packageName, boolean hidden) { if (admin != null) { enforceActiveAdmin(admin); @@ -274,7 +273,7 @@ public class ShadowDevicePolicyManager { packagesToFailForSetApplicationHidden = packagesToFail; } - @Implementation(minSdk = LOLLIPOP) + @Implementation protected boolean isApplicationHidden(ComponentName admin, String packageName) { if (admin != null) { enforceActiveAdmin(admin); @@ -290,7 +289,7 @@ public class ShadowDevicePolicyManager { return wasHiddenPackages.contains(packageName); } - @Implementation(minSdk = LOLLIPOP) + @Implementation protected void enableSystemApp(ComponentName admin, String packageName) { enforceActiveAdmin(admin); systemAppsEnabled.add(packageName); @@ -301,7 +300,7 @@ public class ShadowDevicePolicyManager { return systemAppsEnabled.contains(packageName); } - @Implementation(minSdk = LOLLIPOP) + @Implementation protected void setUninstallBlocked( ComponentName admin, String packageName, boolean uninstallBlocked) { enforceActiveAdmin(admin); @@ -312,7 +311,7 @@ public class ShadowDevicePolicyManager { } } - @Implementation(minSdk = LOLLIPOP) + @Implementation protected boolean isUninstallBlocked(@Nullable ComponentName admin, String packageName) { if (admin == null) { // Starting from LOLLIPOP_MR1, the behavior of this API is changed such that passing null as @@ -365,7 +364,7 @@ public class ShadowDevicePolicyManager { /** * @see #setProfileOwner(ComponentName) */ - @Implementation(minSdk = LOLLIPOP) + @Implementation protected ComponentName getProfileOwner() { return profileOwner; } @@ -374,7 +373,7 @@ public class ShadowDevicePolicyManager { * Returns the human-readable name of the profile owner for a user if set using {@link * #setProfileOwnerName}, otherwise null. */ - @Implementation(minSdk = LOLLIPOP) + @Implementation protected String getProfileOwnerNameAsUser(int userId) { return profileOwnerNamesMap.get(userId); } @@ -450,7 +449,7 @@ public class ShadowDevicePolicyManager { deviceAdmins.remove(admin); } - @Implementation(minSdk = LOLLIPOP) + @Implementation protected void clearProfileOwner(ComponentName admin) { profileOwner = null; lastTransferOwnershipBundle = null; @@ -459,7 +458,7 @@ public class ShadowDevicePolicyManager { } } - @Implementation(minSdk = LOLLIPOP) + @Implementation protected Bundle getApplicationRestrictions(ComponentName admin, String packageName) { if (admin != null) { enforceDeviceOwnerOrProfileOwner(admin); @@ -476,7 +475,7 @@ public class ShadowDevicePolicyManager { return bundle != null ? new Bundle(bundle) : new Bundle(); } - @Implementation(minSdk = LOLLIPOP) + @Implementation protected void setApplicationRestrictions( ComponentName admin, String packageName, Bundle applicationRestrictions) { if (admin != null) { @@ -550,7 +549,7 @@ public class ShadowDevicePolicyManager { } } - @Implementation(minSdk = LOLLIPOP) + @Implementation protected void setAccountManagementDisabled( ComponentName admin, String accountType, boolean disabled) { enforceDeviceOwnerOrProfileOwner(admin); @@ -561,7 +560,7 @@ public class ShadowDevicePolicyManager { } } - @Implementation(minSdk = LOLLIPOP) + @Implementation protected String[] getAccountTypesWithManagementDisabled() { return accountTypesWithManagementDisabled.toArray(new String[0]); } @@ -675,13 +674,13 @@ public class ShadowDevicePolicyManager { return isAutoTimeEnabled; } - @Implementation(minSdk = LOLLIPOP) + @Implementation protected void setAutoTimeRequired(ComponentName admin, boolean required) { enforceDeviceOwnerOrProfileOwner(admin); isAutoTimeRequired = required; } - @Implementation(minSdk = LOLLIPOP) + @Implementation protected boolean getAutoTimeRequired() { return isAutoTimeRequired; } @@ -721,7 +720,7 @@ public class ShadowDevicePolicyManager { * <p>This method does not check already enabled non-system accessibility services, so will always * set the restriction and return true. */ - @Implementation(minSdk = LOLLIPOP) + @Implementation protected boolean setPermittedAccessibilityServices( ComponentName admin, List<String> packageNames) { enforceDeviceOwnerOrProfileOwner(admin); @@ -729,7 +728,7 @@ public class ShadowDevicePolicyManager { return true; } - @Implementation(minSdk = LOLLIPOP) + @Implementation @Nullable protected List<String> getPermittedAccessibilityServices(ComponentName admin) { enforceDeviceOwnerOrProfileOwner(admin); @@ -744,14 +743,14 @@ public class ShadowDevicePolicyManager { * <p>This method does not check already enabled non-system input methods, so will always set the * restriction and return true. */ - @Implementation(minSdk = LOLLIPOP) + @Implementation protected boolean setPermittedInputMethods(ComponentName admin, List<String> packageNames) { enforceDeviceOwnerOrProfileOwner(admin); permittedInputMethods = packageNames; return true; } - @Implementation(minSdk = LOLLIPOP) + @Implementation @Nullable protected List<String> getPermittedInputMethods(ComponentName admin) { enforceDeviceOwnerOrProfileOwner(admin); @@ -1253,7 +1252,7 @@ public class ShadowDevicePolicyManager { return componentsWithActivatedTokens.add(admin); } - @Implementation(minSdk = LOLLIPOP) + @Implementation protected void addPersistentPreferredActivity( ComponentName admin, IntentFilter filter, ComponentName activity) { enforceDeviceOwnerOrProfileOwner(admin); @@ -1263,7 +1262,7 @@ public class ShadowDevicePolicyManager { .addPersistentPreferredActivity(filter, activity); } - @Implementation(minSdk = LOLLIPOP) + @Implementation protected void clearPackagePersistentPreferredActivities( ComponentName admin, String packageName) { enforceDeviceOwnerOrProfileOwner(admin); @@ -1338,20 +1337,20 @@ public class ShadowDevicePolicyManager { lockTaskFeatures = flags; } - @Implementation(minSdk = LOLLIPOP) + @Implementation protected void setLockTaskPackages(@NonNull ComponentName admin, String[] packages) { enforceDeviceOwnerOrProfileOwner(admin); lockTaskPackages.clear(); Collections.addAll(lockTaskPackages, packages); } - @Implementation(minSdk = LOLLIPOP) + @Implementation protected String[] getLockTaskPackages(@NonNull ComponentName admin) { enforceDeviceOwnerOrProfileOwner(admin); return lockTaskPackages.toArray(new String[0]); } - @Implementation(minSdk = LOLLIPOP) + @Implementation protected boolean isLockTaskPermitted(@NonNull String pkg) { return lockTaskPackages.contains(pkg); } diff --git a/shadows/framework/src/main/java/org/robolectric/shadows/ShadowDisplayEventReceiver.java b/shadows/framework/src/main/java/org/robolectric/shadows/ShadowDisplayEventReceiver.java index 50a53d9d3..dc6a1cc6b 100644 --- a/shadows/framework/src/main/java/org/robolectric/shadows/ShadowDisplayEventReceiver.java +++ b/shadows/framework/src/main/java/org/robolectric/shadows/ShadowDisplayEventReceiver.java @@ -1,7 +1,5 @@ package org.robolectric.shadows; -import static android.os.Build.VERSION_CODES.KITKAT; -import static android.os.Build.VERSION_CODES.KITKAT_WATCH; import static android.os.Build.VERSION_CODES.LOLLIPOP_MR1; import static android.os.Build.VERSION_CODES.M; import static android.os.Build.VERSION_CODES.N_MR1; @@ -72,19 +70,12 @@ public class ShadowDisplayEventReceiver { return nativeObjRegistry.register(new NativeDisplayEventReceiver(receiver)); } - @Implementation(minSdk = KITKAT_WATCH, maxSdk = LOLLIPOP_MR1) + @Implementation(maxSdk = LOLLIPOP_MR1) protected static long nativeInit(DisplayEventReceiver receiver, MessageQueue msgQueue) { return nativeObjRegistry.register( new NativeDisplayEventReceiver(new WeakReference<>(receiver))); } - @Implementation(maxSdk = KITKAT) - protected static int nativeInit(Object receiver, Object msgQueue) { - return (int) - nativeObjRegistry.register( - new NativeDisplayEventReceiver(new WeakReference<>((DisplayEventReceiver) receiver))); - } - @Implementation(minSdk = R, maxSdk = TIRAMISU) protected static long nativeInit( WeakReference<DisplayEventReceiver> receiver, @@ -105,7 +96,7 @@ public class ShadowDisplayEventReceiver { return nativeInit(receiver, msgQueue); } - @Implementation(minSdk = KITKAT_WATCH, maxSdk = TIRAMISU) + @Implementation(maxSdk = TIRAMISU) protected static void nativeDispose(long receiverPtr) { NativeDisplayEventReceiver receiver = nativeObjRegistry.unregister(receiverPtr); if (receiver != null) { @@ -113,23 +104,11 @@ public class ShadowDisplayEventReceiver { } } - @Implementation(maxSdk = KITKAT) - protected static void nativeDispose(int receiverPtr) { - NativeDisplayEventReceiver receiver = nativeObjRegistry.unregister(receiverPtr); - if (receiver != null) { - receiver.dispose(); - } - } - - @Implementation(minSdk = KITKAT_WATCH) + @Implementation protected static void nativeScheduleVsync(long receiverPtr) { nativeObjRegistry.getNativeObject(receiverPtr).scheduleVsync(); } - @Implementation(maxSdk = KITKAT) - protected static void nativeScheduleVsync(int receiverPtr) { - nativeObjRegistry.getNativeObject(receiverPtr).scheduleVsync(); - } @Implementation(maxSdk = R) protected void dispose(boolean finalized) { diff --git a/shadows/framework/src/main/java/org/robolectric/shadows/ShadowDisplayManager.java b/shadows/framework/src/main/java/org/robolectric/shadows/ShadowDisplayManager.java index e03590f32..876df13d6 100644 --- a/shadows/framework/src/main/java/org/robolectric/shadows/ShadowDisplayManager.java +++ b/shadows/framework/src/main/java/org/robolectric/shadows/ShadowDisplayManager.java @@ -151,10 +151,6 @@ public class ShadowDisplayManager { displayInfo.state = Display.STATE_ON; } - if (Build.VERSION.SDK_INT == Build.VERSION_CODES.KITKAT) { - displayInfo.getAppMetrics(displayMetrics); - } - return displayInfo; } diff --git a/shadows/framework/src/main/java/org/robolectric/shadows/ShadowEnvironment.java b/shadows/framework/src/main/java/org/robolectric/shadows/ShadowEnvironment.java index 2ce293834..bd3bbb47b 100644 --- a/shadows/framework/src/main/java/org/robolectric/shadows/ShadowEnvironment.java +++ b/shadows/framework/src/main/java/org/robolectric/shadows/ShadowEnvironment.java @@ -1,7 +1,6 @@ package org.robolectric.shadows; import static android.os.Build.VERSION_CODES.JELLY_BEAN_MR2; -import static android.os.Build.VERSION_CODES.LOLLIPOP; import static android.os.Build.VERSION_CODES.M; import static android.os.Build.VERSION_CODES.Q; import static android.os.Build.VERSION_CODES.R; @@ -208,7 +207,7 @@ public class ShadowEnvironment { return null; } - @Implementation(minSdk = LOLLIPOP) + @Implementation protected static String getExternalStorageState(File directory) { Path directoryPath = directory.toPath(); for (Map.Entry<Path, String> entry : storageState.entrySet()) { @@ -219,13 +218,13 @@ public class ShadowEnvironment { return null; } - @Implementation(minSdk = LOLLIPOP) + @Implementation protected static boolean isExternalStorageRemovable(File path) { final Boolean exists = STORAGE_REMOVABLE.get(path); return exists != null ? exists : false; } - @Implementation(minSdk = LOLLIPOP) + @Implementation protected static boolean isExternalStorageEmulated(File path) { final Boolean emulated = STORAGE_EMULATED.get(path); return emulated != null ? emulated : false; diff --git a/shadows/framework/src/main/java/org/robolectric/shadows/ShadowICU.java b/shadows/framework/src/main/java/org/robolectric/shadows/ShadowICU.java index 941e260fb..24dc34285 100644 --- a/shadows/framework/src/main/java/org/robolectric/shadows/ShadowICU.java +++ b/shadows/framework/src/main/java/org/robolectric/shadows/ShadowICU.java @@ -1,7 +1,5 @@ package org.robolectric.shadows; -import static android.os.Build.VERSION_CODES.KITKAT_WATCH; -import static android.os.Build.VERSION_CODES.LOLLIPOP; import static android.os.Build.VERSION_CODES.N; import android.icu.util.ULocale; @@ -31,7 +29,7 @@ public class ShadowICU { } } - @Implementation(minSdk = LOLLIPOP) + @Implementation public static String getBestDateTimePattern(String skeleton, Locale locale) { switch (skeleton) { case "jmm": @@ -47,11 +45,6 @@ public class ShadowICU { } } - @Implementation(maxSdk = KITKAT_WATCH) - public static String getBestDateTimePattern(String skeleton, String locale) { - return skeleton; - } - private static String getjmmPattern(Locale locale) { if (locale.equals(new Locale("pt", "BR")) || locale.equals(Locale.UK)) { return "H:mm"; diff --git a/shadows/framework/src/main/java/org/robolectric/shadows/ShadowInCallAdapter.java b/shadows/framework/src/main/java/org/robolectric/shadows/ShadowInCallAdapter.java index 3f671aaca..b2e3ee1fa 100644 --- a/shadows/framework/src/main/java/org/robolectric/shadows/ShadowInCallAdapter.java +++ b/shadows/framework/src/main/java/org/robolectric/shadows/ShadowInCallAdapter.java @@ -2,7 +2,6 @@ package org.robolectric.shadows; import static org.robolectric.util.reflector.Reflector.reflector; -import android.os.Build.VERSION_CODES; import android.telecom.CallAudioState; import android.telecom.InCallAdapter; import org.robolectric.annotation.Implementation; @@ -20,7 +19,7 @@ public class ShadowInCallAdapter { private int audioRoute = CallAudioState.ROUTE_EARPIECE; - @Implementation(minSdk = VERSION_CODES.LOLLIPOP) + @Implementation protected void setAudioRoute(int route) { audioRoute = route; if (isInternalInCallAdapterSet()) { diff --git a/shadows/framework/src/main/java/org/robolectric/shadows/ShadowKeyCharacterMap.java b/shadows/framework/src/main/java/org/robolectric/shadows/ShadowKeyCharacterMap.java index 92ff331f6..b9768fb92 100644 --- a/shadows/framework/src/main/java/org/robolectric/shadows/ShadowKeyCharacterMap.java +++ b/shadows/framework/src/main/java/org/robolectric/shadows/ShadowKeyCharacterMap.java @@ -1,7 +1,5 @@ package org.robolectric.shadows; -import static android.os.Build.VERSION_CODES.KITKAT; -import static android.os.Build.VERSION_CODES.KITKAT_WATCH; import android.view.KeyCharacterMap; import android.view.KeyEvent; @@ -182,7 +180,7 @@ public class ShadowKeyCharacterMap { return ReflectionHelpers.callConstructor(KeyCharacterMap.class); } - @Implementation(minSdk = KITKAT_WATCH) + @Implementation protected static KeyEvent[] nativeGetEvents(long ptr, char[] chars) { int eventsPerChar = 2; KeyEvent[] events = new KeyEvent[chars.length * eventsPerChar]; @@ -195,27 +193,12 @@ public class ShadowKeyCharacterMap { return events; } - @Implementation(maxSdk = KITKAT) - protected static KeyEvent[] nativeGetEvents(int ptr, char[] chars) { - return nativeGetEvents((long) ptr, chars); - } - - @Implementation(minSdk = KITKAT_WATCH) + @Implementation protected static int nativeGetKeyboardType(long ptr) { return KeyCharacterMap.FULL; } - @Implementation(maxSdk = KITKAT) - protected static int nativeGetKeyboardType(int ptr) { - return KeyCharacterMap.FULL; - } - - @Implementation(maxSdk = KITKAT) - protected static char nativeGetCharacter(int ptr, int keyCode, int metaState) { - return nativeGetCharacter((long) ptr, keyCode, metaState); - } - - @Implementation(minSdk = KITKAT_WATCH) + @Implementation protected static char nativeGetCharacter(long ptr, int keyCode, int metaState) { boolean metaShiftOn = (metaState & KeyEvent.META_SHIFT_ON) != 0; Character character = KEY_CODE_TO_CHAR.get(keyCode); @@ -252,17 +235,12 @@ public class ShadowKeyCharacterMap { 0); } - @Implementation(minSdk = KITKAT_WATCH) + @Implementation protected static char nativeGetDisplayLabel(long ptr, int keyCode) { return KEY_CODE_TO_CHAR.getOrDefault(keyCode, (char) 0); } - @Implementation(maxSdk = KITKAT) - protected static char nativeGetDisplayLabel(int ptr, int keyCode) { - return KEY_CODE_TO_CHAR.getOrDefault(keyCode, (char) 0); - } - - @Implementation(minSdk = KITKAT_WATCH) + @Implementation protected static char nativeGetNumber(long ptr, int keyCode) { Character character = KEY_CODE_TO_CHAR.get(keyCode); if (character == null) { @@ -271,15 +249,6 @@ public class ShadowKeyCharacterMap { return character; } - @Implementation(maxSdk = KITKAT) - protected static char nativeGetNumber(int ptr, int keyCode) { - Character character = KEY_CODE_TO_CHAR.get(keyCode); - if (character == null) { - return 0; - } - return character; - } - private static int toCharKeyCode(char a) { if (CHAR_TO_KEY_CODE.containsKey(Character.toUpperCase(a))) { return CHAR_TO_KEY_CODE.get(Character.toUpperCase(a)); diff --git a/shadows/framework/src/main/java/org/robolectric/shadows/ShadowLegacyAssetManager.java b/shadows/framework/src/main/java/org/robolectric/shadows/ShadowLegacyAssetManager.java index 5f1536bba..5bf6a6c97 100644 --- a/shadows/framework/src/main/java/org/robolectric/shadows/ShadowLegacyAssetManager.java +++ b/shadows/framework/src/main/java/org/robolectric/shadows/ShadowLegacyAssetManager.java @@ -1,7 +1,5 @@ package org.robolectric.shadows; -import static android.os.Build.VERSION_CODES.KITKAT_WATCH; -import static android.os.Build.VERSION_CODES.LOLLIPOP; import static android.os.Build.VERSION_CODES.M; import static android.os.Build.VERSION_CODES.N; import static android.os.Build.VERSION_CODES.N_MR1; @@ -262,12 +260,8 @@ public class ShadowLegacyAssetManager extends ShadowAssetManager { return 1; } - @HiddenApi @Implementation(maxSdk = KITKAT_WATCH) - protected void init() { - // no op - } - - @HiddenApi @Implementation(minSdk = LOLLIPOP, maxSdk = O_MR1) + @HiddenApi + @Implementation(maxSdk = O_MR1) protected void init(boolean isSystem) { // no op } @@ -344,12 +338,8 @@ public class ShadowLegacyAssetManager extends ShadowAssetManager { return charSequences; } - @HiddenApi @Implementation(maxSdk = KITKAT_WATCH) - public boolean getThemeValue(int themePtr, int ident, TypedValue outValue, boolean resolveRefs) { - return getThemeValue((long) themePtr, ident, outValue, resolveRefs); - } - - @HiddenApi @Implementation(minSdk = LOLLIPOP) + @HiddenApi + @Implementation public boolean getThemeValue(long themePtr, int ident, TypedValue outValue, boolean resolveRefs) { ResName resName = getResourceTable().getResName(ident); @@ -551,45 +541,25 @@ public class ShadowLegacyAssetManager extends ShadowAssetManager { } @HiddenApi - @Implementation(maxSdk = KITKAT_WATCH) - protected long seekAsset(int asset, long offset, int whence) { - return seekAsset((long) asset, offset, whence); - } - - @HiddenApi @Implementation(minSdk = LOLLIPOP, maxSdk = O_MR1) + @Implementation(maxSdk = O_MR1) protected long seekAsset(long asset, long offset, int whence) { return 0; } @HiddenApi - @Implementation(maxSdk = KITKAT_WATCH) - protected long getAssetLength(int asset) { - return getAssetLength((long) asset); - } - - @HiddenApi @Implementation(minSdk = LOLLIPOP, maxSdk = O_MR1) + @Implementation(maxSdk = O_MR1) protected long getAssetLength(long asset) { return 0; } @HiddenApi - @Implementation(maxSdk = KITKAT_WATCH) - protected long getAssetRemainingLength(int asset) { - return getAssetRemainingLength((long) asset); - } - - @HiddenApi @Implementation(minSdk = LOLLIPOP, maxSdk = O_MR1) + @Implementation(maxSdk = O_MR1) protected long getAssetRemainingLength(long assetHandle) { return 0; } @HiddenApi - @Implementation(maxSdk = KITKAT_WATCH) - protected void destroyAsset(int asset) { - destroyAsset((long) asset); - } - - @HiddenApi @Implementation(minSdk = LOLLIPOP, maxSdk = O_MR1) + @Implementation(maxSdk = O_MR1) protected void destroyAsset(long asset) { // no op } @@ -913,15 +883,12 @@ public class ShadowLegacyAssetManager extends ShadowAssetManager { } } - @HiddenApi @Implementation(minSdk = LOLLIPOP, maxSdk = O_MR1) + @HiddenApi + @Implementation(maxSdk = O_MR1) protected static void dumpTheme(long theme, int priority, String tag, String prefix) { throw new UnsupportedOperationException("not yet implemented"); } - @HiddenApi @Implementation(maxSdk = KITKAT_WATCH) - public void releaseTheme(int themePtr) { - // no op - } private static NativeTheme getNativeTheme(long themePtr) { NativeTheme nativeTheme; @@ -934,41 +901,30 @@ public class ShadowLegacyAssetManager extends ShadowAssetManager { return nativeTheme; } - @HiddenApi @Implementation(minSdk = LOLLIPOP) + @HiddenApi + @Implementation public void releaseTheme(long themePtr) { synchronized (nativeThemes) { nativeThemes.remove(themePtr); } } - @HiddenApi @Implementation(maxSdk = KITKAT_WATCH) - protected void deleteTheme(int theme) { - deleteTheme((long) theme); - } - - @HiddenApi @Implementation(minSdk = LOLLIPOP, maxSdk = O_MR1) + @HiddenApi + @Implementation(maxSdk = O_MR1) protected void deleteTheme(long theme) { // no op } - @HiddenApi @Implementation(maxSdk = KITKAT_WATCH) - public static void applyThemeStyle(int themePtr, int styleRes, boolean force) { - applyThemeStyle((long) themePtr, styleRes, force); - } - - @HiddenApi @Implementation(minSdk = LOLLIPOP, maxSdk = O_MR1) + @HiddenApi + @Implementation(maxSdk = O_MR1) public static void applyThemeStyle(long themePtr, int styleRes, boolean force) { NativeTheme nativeTheme = getNativeTheme(themePtr); Style style = nativeTheme.getShadowAssetManager().resolveStyle(styleRes, null); nativeTheme.themeStyleSet.apply(style, force); } - @HiddenApi @Implementation(maxSdk = KITKAT_WATCH) - public static void copyTheme(int destPtr, int sourcePtr) { - copyTheme((long) destPtr, (long) sourcePtr); - } - - @HiddenApi @Implementation(minSdk = LOLLIPOP, maxSdk = O_MR1) + @HiddenApi + @Implementation(maxSdk = O_MR1) public static void copyTheme(long destPtr, long sourcePtr) { NativeTheme destNativeTheme = getNativeTheme(destPtr); NativeTheme sourceNativeTheme = getNativeTheme(sourcePtr); @@ -988,26 +944,6 @@ public class ShadowLegacyAssetManager extends ShadowAssetManager { } @HiddenApi - @Implementation(maxSdk = KITKAT_WATCH) - protected static boolean applyStyle( - int themeToken, - int defStyleAttr, - int defStyleRes, - int xmlParserToken, - int[] attrs, - int[] outValues, - int[] outIndices) { - return applyStyle( - (long) themeToken, - defStyleAttr, - defStyleRes, - (long) xmlParserToken, - attrs, - outValues, - outIndices); - } - - @HiddenApi @Implementation(minSdk = O, maxSdk = O_MR1) protected static void applyStyle( long themeToken, @@ -1031,7 +967,7 @@ public class ShadowLegacyAssetManager extends ShadowAssetManager { } @HiddenApi - @Implementation(minSdk = LOLLIPOP, maxSdk = N_MR1) + @Implementation(maxSdk = N_MR1) protected static boolean applyStyle( long themeToken, int defStyleAttr, @@ -1045,7 +981,7 @@ public class ShadowLegacyAssetManager extends ShadowAssetManager { } @HiddenApi - @Implementation(minSdk = LOLLIPOP, maxSdk = O_MR1) + @Implementation(maxSdk = O_MR1) protected static boolean resolveAttrs( long themeToken, int defStyleAttr, @@ -1058,28 +994,14 @@ public class ShadowLegacyAssetManager extends ShadowAssetManager { return false; } - @HiddenApi - @Implementation(maxSdk = KITKAT_WATCH) - protected boolean retrieveAttributes( - int xmlParserToken, int[] attrs, int[] outValues, int[] outIndices) { - return retrieveAttributes((long)xmlParserToken, attrs, outValues, outIndices); - } - - @Implementation(minSdk = LOLLIPOP, maxSdk = O_MR1) + @Implementation(maxSdk = O_MR1) protected boolean retrieveAttributes( long xmlParserToken, int[] attrs, int[] outValues, int[] outIndices) { return false; } @HiddenApi - @Implementation(maxSdk = KITKAT_WATCH) - protected static int loadThemeAttributeValue( - int themeHandle, int ident, TypedValue outValue, boolean resolve) { - return loadThemeAttributeValue((long) themeHandle, ident, outValue, resolve); - } - - @HiddenApi - @Implementation(minSdk = LOLLIPOP, maxSdk = O_MR1) + @Implementation(maxSdk = O_MR1) protected static int loadThemeAttributeValue( long themeHandle, int ident, TypedValue outValue, boolean resolve) { // no-op @@ -1423,7 +1345,7 @@ public class ShadowLegacyAssetManager extends ShadowAssetManager { throw new IllegalStateException(); } - @Implementation(minSdk = LOLLIPOP, maxSdk = O_MR1) + @Implementation(maxSdk = O_MR1) protected SparseArray<String> getAssignedPackageIdentifiers() { return new SparseArray<>(); } diff --git a/shadows/framework/src/main/java/org/robolectric/shadows/ShadowLegacyCanvas.java b/shadows/framework/src/main/java/org/robolectric/shadows/ShadowLegacyCanvas.java index 0db52d49f..7e9cad3bb 100644 --- a/shadows/framework/src/main/java/org/robolectric/shadows/ShadowLegacyCanvas.java +++ b/shadows/framework/src/main/java/org/robolectric/shadows/ShadowLegacyCanvas.java @@ -1,7 +1,5 @@ package org.robolectric.shadows; -import static android.os.Build.VERSION_CODES.KITKAT_WATCH; -import static android.os.Build.VERSION_CODES.LOLLIPOP; import static android.os.Build.VERSION_CODES.LOLLIPOP_MR1; import static android.os.Build.VERSION_CODES.M; import static android.os.Build.VERSION_CODES.N_MR1; @@ -22,7 +20,6 @@ import android.graphics.RectF; import com.google.common.base.Preconditions; import java.util.ArrayList; import java.util.List; -import org.robolectric.RuntimeEnvironment; import org.robolectric.annotation.Implementation; import org.robolectric.annotation.Implements; import org.robolectric.annotation.RealObject; @@ -72,9 +69,7 @@ public class ShadowLegacyCanvas extends ShadowCanvas { } private long getNativeId() { - return RuntimeEnvironment.getApiLevel() <= KITKAT_WATCH - ? (int) ReflectionHelpers.getField(realCanvas, "mNativeCanvas") - : realCanvas.getNativeCanvasWrapper(); + return realCanvas.getNativeCanvasWrapper(); } private NativeCanvas getNativeCanvas() { @@ -483,12 +478,7 @@ public class ShadowLegacyCanvas extends ShadowCanvas { canvasReflector.release(); } - @Implementation(maxSdk = KITKAT_WATCH) - protected static int initRaster(int bitmapHandle) { - return (int) nativeObjectRegistry.register(new NativeCanvas()); - } - - @Implementation(minSdk = LOLLIPOP, maxSdk = LOLLIPOP_MR1) + @Implementation(maxSdk = LOLLIPOP_MR1) protected static long initRaster(long bitmapHandle) { return nativeObjectRegistry.register(new NativeCanvas()); } @@ -518,18 +508,7 @@ public class ShadowLegacyCanvas extends ShadowCanvas { return nativeObjectRegistry.getNativeObject(canvasHandle).save(); } - @Implementation(maxSdk = KITKAT_WATCH) - protected static int native_saveLayer(int nativeCanvas, RectF bounds, int paint, int layerFlags) { - return nativeObjectRegistry.getNativeObject(nativeCanvas).save(); - } - - @Implementation(maxSdk = KITKAT_WATCH) - protected static int native_saveLayer( - int nativeCanvas, float l, float t, float r, float b, int paint, int layerFlags) { - return nativeObjectRegistry.getNativeObject(nativeCanvas).save(); - } - - @Implementation(minSdk = LOLLIPOP, maxSdk = N_MR1) + @Implementation(maxSdk = N_MR1) protected static int native_saveLayer( long nativeCanvas, float l, float t, float r, float b, long nativePaint, int layerFlags) { return nativeObjectRegistry.getNativeObject(nativeCanvas).save(); @@ -547,19 +526,7 @@ public class ShadowLegacyCanvas extends ShadowCanvas { return nativeObjectRegistry.getNativeObject(nativeCanvas).save(); } - @Implementation(maxSdk = KITKAT_WATCH) - protected static int native_saveLayerAlpha( - int nativeCanvas, RectF bounds, int alpha, int layerFlags) { - return nativeObjectRegistry.getNativeObject(nativeCanvas).save(); - } - - @Implementation(maxSdk = KITKAT_WATCH) - protected static int native_saveLayerAlpha( - int nativeCanvas, float l, float t, float r, float b, int alpha, int layerFlags) { - return nativeObjectRegistry.getNativeObject(nativeCanvas).save(); - } - - @Implementation(minSdk = LOLLIPOP, maxSdk = N_MR1) + @Implementation(maxSdk = N_MR1) protected static int native_saveLayerAlpha( long nativeCanvas, float l, float t, float r, float b, int alpha, int layerFlags) { return nativeObjectRegistry.getNativeObject(nativeCanvas).save(); diff --git a/shadows/framework/src/main/java/org/robolectric/shadows/ShadowLegacyCursorWindow.java b/shadows/framework/src/main/java/org/robolectric/shadows/ShadowLegacyCursorWindow.java index 49fcaca4f..ec31ac526 100644 --- a/shadows/framework/src/main/java/org/robolectric/shadows/ShadowLegacyCursorWindow.java +++ b/shadows/framework/src/main/java/org/robolectric/shadows/ShadowLegacyCursorWindow.java @@ -1,7 +1,5 @@ package org.robolectric.shadows; -import static android.os.Build.VERSION_CODES.KITKAT_WATCH; -import static android.os.Build.VERSION_CODES.LOLLIPOP; import static java.nio.charset.StandardCharsets.UTF_8; import static org.robolectric.RuntimeEnvironment.castNativePtr; @@ -30,22 +28,12 @@ public class ShadowLegacyCursorWindow extends ShadowCursorWindow { return castNativePtr(WINDOW_DATA.create(name, cursorWindowSize)); } - @Implementation(maxSdk = KITKAT_WATCH) - protected static void nativeDispose(int windowPtr) { - nativeDispose((long) windowPtr); - } - - @Implementation(minSdk = LOLLIPOP) + @Implementation protected static void nativeDispose(long windowPtr) { WINDOW_DATA.close(windowPtr); } - @Implementation(maxSdk = KITKAT_WATCH) - protected static byte[] nativeGetBlob(int windowPtr, int row, int column) { - return nativeGetBlob((long) windowPtr, row, column); - } - - @Implementation(minSdk = LOLLIPOP) + @Implementation protected static byte[] nativeGetBlob(long windowPtr, int row, int column) { Value value = WINDOW_DATA.get(windowPtr).value(row, column); @@ -66,12 +54,7 @@ public class ShadowLegacyCursorWindow extends ShadowCursorWindow { } } - @Implementation(maxSdk = KITKAT_WATCH) - protected static String nativeGetString(int windowPtr, int row, int column) { - return nativeGetString((long) windowPtr, row, column); - } - - @Implementation(minSdk = LOLLIPOP) + @Implementation protected static String nativeGetString(long windowPtr, int row, int column) { Value val = WINDOW_DATA.get(windowPtr).value(row, column); if (val.type == Cursor.FIELD_TYPE_BLOB) { @@ -82,136 +65,71 @@ public class ShadowLegacyCursorWindow extends ShadowCursorWindow { return value == null ? null : String.valueOf(value); } - @Implementation(maxSdk = KITKAT_WATCH) - protected static long nativeGetLong(int windowPtr, int row, int column) { - return nativeGetLong((long) windowPtr, row, column); - } - - @Implementation(minSdk = LOLLIPOP) + @Implementation protected static long nativeGetLong(long windowPtr, int row, int column) { return nativeGetNumber(windowPtr, row, column).longValue(); } - @Implementation(maxSdk = KITKAT_WATCH) - protected static double nativeGetDouble(int windowPtr, int row, int column) { - return nativeGetDouble((long) windowPtr, row, column); - } - - @Implementation(minSdk = LOLLIPOP) + @Implementation protected static double nativeGetDouble(long windowPtr, int row, int column) { return nativeGetNumber(windowPtr, row, column).doubleValue(); } - @Implementation(maxSdk = KITKAT_WATCH) - protected static int nativeGetType(int windowPtr, int row, int column) { - return nativeGetType((long) windowPtr, row, column); - } - - @Implementation(minSdk = LOLLIPOP) + @Implementation protected static int nativeGetType(long windowPtr, int row, int column) { return WINDOW_DATA.get(windowPtr).value(row, column).type; } - @Implementation(maxSdk = KITKAT_WATCH) - protected static void nativeClear(int windowPtr) { - nativeClear((long) windowPtr); - } - - @Implementation(minSdk = LOLLIPOP) + @Implementation protected static void nativeClear(long windowPtr) { WINDOW_DATA.clear(windowPtr); } - @Implementation(maxSdk = KITKAT_WATCH) - protected static int nativeGetNumRows(int windowPtr) { - return nativeGetNumRows((long) windowPtr); - } - - @Implementation(minSdk = LOLLIPOP) + @Implementation protected static int nativeGetNumRows(long windowPtr) { return WINDOW_DATA.get(windowPtr).numRows(); } - @Implementation(maxSdk = KITKAT_WATCH) - protected static boolean nativePutBlob(int windowPtr, byte[] value, int row, int column) { - return nativePutBlob((long) windowPtr, value, row, column); - } - - @Implementation(minSdk = LOLLIPOP) + @Implementation protected static boolean nativePutBlob(long windowPtr, byte[] value, int row, int column) { // Real Android will crash in native code if putString is called with a null value. Preconditions.checkNotNull(value); return WINDOW_DATA.get(windowPtr).putValue(new Value(value, Cursor.FIELD_TYPE_BLOB), row, column); } - @Implementation(maxSdk = KITKAT_WATCH) - protected static boolean nativePutString(int windowPtr, String value, int row, int column) { - return nativePutString((long) windowPtr, value, row, column); - } - - @Implementation(minSdk = LOLLIPOP) + @Implementation protected static boolean nativePutString(long windowPtr, String value, int row, int column) { // Real Android will crash in native code if putString is called with a null value. Preconditions.checkNotNull(value); return WINDOW_DATA.get(windowPtr).putValue(new Value(value, Cursor.FIELD_TYPE_STRING), row, column); } - @Implementation(maxSdk = KITKAT_WATCH) - protected static boolean nativePutLong(int windowPtr, long value, int row, int column) { - return nativePutLong((long) windowPtr, value, row, column); - } - - @Implementation(minSdk = LOLLIPOP) + @Implementation protected static boolean nativePutLong(long windowPtr, long value, int row, int column) { return WINDOW_DATA.get(windowPtr).putValue(new Value(value, Cursor.FIELD_TYPE_INTEGER), row, column); } - @Implementation(maxSdk = KITKAT_WATCH) - protected static boolean nativePutDouble(int windowPtr, double value, int row, int column) { - return nativePutDouble((long) windowPtr, value, row, column); - } - - @Implementation(minSdk = LOLLIPOP) + @Implementation protected static boolean nativePutDouble(long windowPtr, double value, int row, int column) { return WINDOW_DATA.get(windowPtr).putValue(new Value(value, Cursor.FIELD_TYPE_FLOAT), row, column); } - @Implementation(maxSdk = KITKAT_WATCH) - protected static boolean nativePutNull(int windowPtr, int row, int column) { - return nativePutNull((long) windowPtr, row, column); - } - - @Implementation(minSdk = LOLLIPOP) + @Implementation protected static boolean nativePutNull(long windowPtr, int row, int column) { return WINDOW_DATA.get(windowPtr).putValue(new Value(null, Cursor.FIELD_TYPE_NULL), row, column); } - @Implementation(maxSdk = KITKAT_WATCH) - protected static boolean nativeAllocRow(int windowPtr) { - return nativeAllocRow((long) windowPtr); - } - - @Implementation(minSdk = LOLLIPOP) + @Implementation protected static boolean nativeAllocRow(long windowPtr) { return WINDOW_DATA.get(windowPtr).allocRow(); } - @Implementation(maxSdk = KITKAT_WATCH) - protected static boolean nativeSetNumColumns(int windowPtr, int columnNum) { - return nativeSetNumColumns((long) windowPtr, columnNum); - } - - @Implementation(minSdk = LOLLIPOP) + @Implementation protected static boolean nativeSetNumColumns(long windowPtr, int columnNum) { return WINDOW_DATA.get(windowPtr).setNumColumns(columnNum); } - @Implementation(maxSdk = KITKAT_WATCH) - protected static String nativeGetName(int windowPtr) { - return nativeGetName((long) windowPtr); - } - - @Implementation(minSdk = LOLLIPOP) + @Implementation protected static String nativeGetName(long windowPtr) { return WINDOW_DATA.get(windowPtr).getName(); } diff --git a/shadows/framework/src/main/java/org/robolectric/shadows/ShadowLegacyMatrix.java b/shadows/framework/src/main/java/org/robolectric/shadows/ShadowLegacyMatrix.java index b72627e5f..fb6bb48e5 100644 --- a/shadows/framework/src/main/java/org/robolectric/shadows/ShadowLegacyMatrix.java +++ b/shadows/framework/src/main/java/org/robolectric/shadows/ShadowLegacyMatrix.java @@ -1,6 +1,5 @@ package org.robolectric.shadows; -import static android.os.Build.VERSION_CODES.LOLLIPOP; import android.graphics.Matrix; import android.graphics.Matrix.ScaleToFit; @@ -74,7 +73,7 @@ public class ShadowLegacyMatrix extends ShadowMatrix { return simpleMatrix.equals(SimpleMatrix.IDENTITY); } - @Implementation(minSdk = LOLLIPOP) + @Implementation protected boolean isAffine() { return simpleMatrix.isAffine(); } diff --git a/shadows/framework/src/main/java/org/robolectric/shadows/ShadowLegacyMessage.java b/shadows/framework/src/main/java/org/robolectric/shadows/ShadowLegacyMessage.java index 5f4c2ebbb..a2d27cec0 100644 --- a/shadows/framework/src/main/java/org/robolectric/shadows/ShadowLegacyMessage.java +++ b/shadows/framework/src/main/java/org/robolectric/shadows/ShadowLegacyMessage.java @@ -1,9 +1,5 @@ package org.robolectric.shadows; -import static android.os.Build.VERSION_CODES.KITKAT_WATCH; -import static android.os.Build.VERSION_CODES.LOLLIPOP; -import static org.robolectric.RuntimeEnvironment.getApiLevel; -import static org.robolectric.shadow.api.Shadow.directlyOn; import static org.robolectric.util.reflector.Reflector.reflector; import android.os.Handler; @@ -43,31 +39,16 @@ public class ShadowLegacyMessage extends ShadowMessage { } /** - * Hook to unscheduled the callback when the message is recycled. - * Invokes {@link #unschedule()} and then calls through to the - * package private method {@link Message#recycleUnchecked()} - * on the real object. + * Hook to unscheduled the callback when the message is recycled. Invokes {@link #unschedule()} + * and then calls through to the package private method {@link Message#recycleUnchecked()} on the + * real object. */ @HiddenApi - @Implementation(minSdk = LOLLIPOP) + @Implementation public void recycleUnchecked() { - if (getApiLevel() >= LOLLIPOP) { - unschedule(); - reflector(MessageReflector.class, realMessage).recycleUnchecked(); - } else { - // provide forward compatibility with SDK 21. - recycle(); - } - } - /** - * Hook to unscheduled the callback when the message is recycled. Invokes {@link #unschedule()} - * and then calls through to {@link Message#recycle()} on the real object. - */ - @Implementation(maxSdk = KITKAT_WATCH) - protected void recycle() { unschedule(); - directlyOn(realMessage, Message.class, "recycle"); + reflector(MessageReflector.class, realMessage).recycleUnchecked(); } @Override diff --git a/shadows/framework/src/main/java/org/robolectric/shadows/ShadowLegacyMessageQueue.java b/shadows/framework/src/main/java/org/robolectric/shadows/ShadowLegacyMessageQueue.java index 5763ef5f8..0d7e20e11 100644 --- a/shadows/framework/src/main/java/org/robolectric/shadows/ShadowLegacyMessageQueue.java +++ b/shadows/framework/src/main/java/org/robolectric/shadows/ShadowLegacyMessageQueue.java @@ -1,6 +1,5 @@ package org.robolectric.shadows; -import static android.os.Build.VERSION_CODES.KITKAT_WATCH; import static android.os.Build.VERSION_CODES.LOLLIPOP; import static android.os.Build.VERSION_CODES.LOLLIPOP_MR1; import static org.robolectric.RuntimeEnvironment.getApiLevel; @@ -52,22 +51,10 @@ public class ShadowLegacyMessageQueue extends ShadowMessageQueue { return 1; } - @HiddenApi - @Implementation(maxSdk = KITKAT_WATCH) - public static void nativeDestroy(int ptr) { - nativeDestroy((long) ptr); - } - - @Implementation(minSdk = LOLLIPOP) + @Implementation protected static void nativeDestroy(long ptr) {} - @HiddenApi - @Implementation(maxSdk = KITKAT_WATCH) - public static boolean nativeIsIdling(int ptr) { - return nativeIsIdling((long) ptr); - } - - @Implementation(minSdk = LOLLIPOP, maxSdk = LOLLIPOP_MR1) + @Implementation(maxSdk = LOLLIPOP_MR1) protected static boolean nativeIsIdling(long ptr) { return false; } diff --git a/shadows/framework/src/main/java/org/robolectric/shadows/ShadowLegacyPath.java b/shadows/framework/src/main/java/org/robolectric/shadows/ShadowLegacyPath.java index 4f2040826..4789e56d4 100644 --- a/shadows/framework/src/main/java/org/robolectric/shadows/ShadowLegacyPath.java +++ b/shadows/framework/src/main/java/org/robolectric/shadows/ShadowLegacyPath.java @@ -1,6 +1,5 @@ package org.robolectric.shadows; -import static android.os.Build.VERSION_CODES.LOLLIPOP; import static org.robolectric.shadow.api.Shadow.extract; import static org.robolectric.shadows.ShadowPath.Point.Type.LINE_TO; import static org.robolectric.shadows.ShadowPath.Point.Type.MOVE_TO; @@ -108,7 +107,7 @@ public class ShadowLegacyPath extends ShadowPath { points.clear(); } - @Implementation(minSdk = LOLLIPOP) + @Implementation protected float[] approximate(float acceptableError) { PathIterator iterator = mPath.getPathIterator(null, acceptableError); @@ -178,7 +177,7 @@ public class ShadowLegacyPath extends ShadowPath { return false; } - @Implementation(minSdk = LOLLIPOP) + @Implementation protected boolean isConvex() { Log.w(TAG, "android.graphics.Path#isConvex() not supported yet."); return true; @@ -331,7 +330,7 @@ public class ShadowLegacyPath extends ShadowPath { arcTo(oval.left, oval.top, oval.right, oval.bottom, startAngle, sweepAngle, forceMoveTo); } - @Implementation(minSdk = LOLLIPOP) + @Implementation protected void arcTo( float left, float top, @@ -385,7 +384,7 @@ public class ShadowLegacyPath extends ShadowPath { resetLastPointFromPath(); } - @Implementation(minSdk = LOLLIPOP) + @Implementation protected void addOval(float left, float top, float right, float bottom, Path.Direction dir) { mPath.append(new Ellipse2D.Float(left, top, right - left, bottom - top), false); } @@ -395,7 +394,7 @@ public class ShadowLegacyPath extends ShadowPath { mPath.append(new Ellipse2D.Float(x - radius, y - radius, radius * 2, radius * 2), false); } - @Implementation(minSdk = LOLLIPOP) + @Implementation protected void addArc( float left, float top, float right, float bottom, float startAngle, float sweepAngle) { mPath.append( @@ -417,14 +416,14 @@ public class ShadowLegacyPath extends ShadowPath { addRoundRect(rect.left, rect.top, rect.right, rect.bottom, radii, dir); } - @Implementation(minSdk = LOLLIPOP) + @Implementation protected void addRoundRect( float left, float top, float right, float bottom, float rx, float ry, Path.Direction dir) { mPath.append( new RoundRectangle2D.Float(left, top, right - left, bottom - top, rx * 2, ry * 2), false); } - @Implementation(minSdk = LOLLIPOP) + @Implementation protected void addRoundRect( float left, float top, float right, float bottom, float[] radii, Path.Direction dir) { if (radii.length < 8) { diff --git a/shadows/framework/src/main/java/org/robolectric/shadows/ShadowLegacySQLiteConnection.java b/shadows/framework/src/main/java/org/robolectric/shadows/ShadowLegacySQLiteConnection.java index 2159878eb..7a2b439cc 100644 --- a/shadows/framework/src/main/java/org/robolectric/shadows/ShadowLegacySQLiteConnection.java +++ b/shadows/framework/src/main/java/org/robolectric/shadows/ShadowLegacySQLiteConnection.java @@ -1,11 +1,10 @@ package org.robolectric.shadows; -import static android.os.Build.VERSION_CODES.KITKAT_WATCH; -import static android.os.Build.VERSION_CODES.LOLLIPOP; import static android.os.Build.VERSION_CODES.O; import static android.os.Build.VERSION_CODES.O_MR1; import static android.os.Build.VERSION_CODES.Q; import static android.os.Build.VERSION_CODES.S_V2; +import static android.os.Build.VERSION_CODES.TIRAMISU; import static org.robolectric.RuntimeEnvironment.castNativePtr; import android.database.sqlite.SQLiteAbortException; @@ -86,12 +85,7 @@ public class ShadowLegacySQLiteConnection extends ShadowSQLiteConnection { return nativeOpen(path, openFlags, label, enableTrace, enableProfile).longValue(); } - @Implementation(maxSdk = KITKAT_WATCH) - protected static int nativePrepareStatement(int connectionPtr, String sql) { - return (int) nativePrepareStatement((long) connectionPtr, sql); - } - - @Implementation(minSdk = LOLLIPOP) + @Implementation protected static long nativePrepareStatement(long connectionPtr, String sql) { final String newSql = convertSQLWithLocalizedUnicodeCollator(sql); return CONNECTIONS.prepareStatement(connectionPtr, newSql); @@ -110,209 +104,109 @@ public class ShadowLegacySQLiteConnection extends ShadowSQLiteConnection { CONNECTIONS.reset(); } - @Implementation(maxSdk = KITKAT_WATCH) - protected static void nativeClose(int connectionPtr) { - nativeClose((long) connectionPtr); - } - - @Implementation(minSdk = LOLLIPOP) + @Implementation protected static void nativeClose(long connectionPtr) { CONNECTIONS.close(connectionPtr); } - @Implementation(maxSdk = KITKAT_WATCH) - protected static void nativeFinalizeStatement(int connectionPtr, int statementPtr) { - nativeFinalizeStatement((long) connectionPtr, statementPtr); - } - - @Implementation(minSdk = LOLLIPOP) + @Implementation protected static void nativeFinalizeStatement(long connectionPtr, long statementPtr) { CONNECTIONS.finalizeStmt(connectionPtr, statementPtr); } - @Implementation(maxSdk = KITKAT_WATCH) - protected static int nativeGetParameterCount(int connectionPtr, int statementPtr) { - return nativeGetParameterCount((long) connectionPtr, statementPtr); - } - - @Implementation(minSdk = LOLLIPOP) + @Implementation protected static int nativeGetParameterCount(final long connectionPtr, final long statementPtr) { return CONNECTIONS.getParameterCount(connectionPtr, statementPtr); } - @Implementation(maxSdk = KITKAT_WATCH) - protected static boolean nativeIsReadOnly(int connectionPtr, int statementPtr) { - return nativeIsReadOnly((long) connectionPtr, (long) statementPtr); - } - - @Implementation(minSdk = LOLLIPOP) + @Implementation protected static boolean nativeIsReadOnly(final long connectionPtr, final long statementPtr) { return CONNECTIONS.isReadOnly(connectionPtr, statementPtr); } - @Implementation(maxSdk = KITKAT_WATCH) - protected static long nativeExecuteForLong(int connectionPtr, int statementPtr) { - return nativeExecuteForLong((long) connectionPtr, (long) statementPtr); - } - - @Implementation(minSdk = LOLLIPOP) + @Implementation protected static long nativeExecuteForLong(final long connectionPtr, final long statementPtr) { return CONNECTIONS.executeForLong(connectionPtr, statementPtr); } - @Implementation(maxSdk = KITKAT_WATCH) - protected static void nativeExecute(int connectionPtr, int statementPtr) { - nativeExecute((long) connectionPtr, (long) statementPtr); - } - - @Implementation(minSdk = LOLLIPOP, maxSdk = S_V2) + @Implementation(maxSdk = S_V2) protected static void nativeExecute(final long connectionPtr, final long statementPtr) { CONNECTIONS.executeStatement(connectionPtr, statementPtr); } - @Implementation(minSdk = 33) + @Implementation(minSdk = TIRAMISU) protected static void nativeExecute( final long connectionPtr, final long statementPtr, boolean isPragmaStmt) { CONNECTIONS.executeStatement(connectionPtr, statementPtr); } - @Implementation(maxSdk = KITKAT_WATCH) - protected static String nativeExecuteForString(int connectionPtr, int statementPtr) { - return nativeExecuteForString((long) connectionPtr, (long) statementPtr); - } - - @Implementation(minSdk = LOLLIPOP) + @Implementation protected static String nativeExecuteForString( final long connectionPtr, final long statementPtr) { return CONNECTIONS.executeForString(connectionPtr, statementPtr); } - @Implementation(maxSdk = KITKAT_WATCH) - protected static int nativeGetColumnCount(int connectionPtr, int statementPtr) { - return nativeGetColumnCount((long) connectionPtr, (long) statementPtr); - } - - @Implementation(minSdk = LOLLIPOP) + @Implementation protected static int nativeGetColumnCount(final long connectionPtr, final long statementPtr) { return CONNECTIONS.getColumnCount(connectionPtr, statementPtr); } - @Implementation(maxSdk = KITKAT_WATCH) - protected static String nativeGetColumnName(int connectionPtr, int statementPtr, int index) { - return nativeGetColumnName((long) connectionPtr, (long) statementPtr, index); - } - - @Implementation(minSdk = LOLLIPOP) + @Implementation protected static String nativeGetColumnName( final long connectionPtr, final long statementPtr, final int index) { return CONNECTIONS.getColumnName(connectionPtr, statementPtr, index); } - @Implementation(maxSdk = KITKAT_WATCH) - protected static void nativeBindNull(int connectionPtr, int statementPtr, int index) { - nativeBindNull((long) connectionPtr, (long) statementPtr, index); - } - - @Implementation(minSdk = LOLLIPOP) + @Implementation protected static void nativeBindNull( final long connectionPtr, final long statementPtr, final int index) { CONNECTIONS.bindNull(connectionPtr, statementPtr, index); } - @Implementation(maxSdk = KITKAT_WATCH) - protected static void nativeBindLong(int connectionPtr, int statementPtr, int index, long value) { - nativeBindLong((long) connectionPtr, (long) statementPtr, index, value); - } - - @Implementation(minSdk = LOLLIPOP) + @Implementation protected static void nativeBindLong( final long connectionPtr, final long statementPtr, final int index, final long value) { CONNECTIONS.bindLong(connectionPtr, statementPtr, index, value); } - @Implementation(maxSdk = KITKAT_WATCH) - protected static void nativeBindDouble( - int connectionPtr, int statementPtr, int index, double value) { - nativeBindDouble((long) connectionPtr, (long) statementPtr, index, value); - } - - @Implementation(minSdk = LOLLIPOP) + @Implementation protected static void nativeBindDouble( final long connectionPtr, final long statementPtr, final int index, final double value) { CONNECTIONS.bindDouble(connectionPtr, statementPtr, index, value); } - @Implementation(maxSdk = KITKAT_WATCH) - protected static void nativeBindString( - int connectionPtr, int statementPtr, int index, String value) { - nativeBindString((long) connectionPtr, (long) statementPtr, index, value); - } - - @Implementation(minSdk = LOLLIPOP) + @Implementation protected static void nativeBindString( final long connectionPtr, final long statementPtr, final int index, final String value) { CONNECTIONS.bindString(connectionPtr, statementPtr, index, value); } - @Implementation(maxSdk = KITKAT_WATCH) - protected static void nativeBindBlob( - int connectionPtr, int statementPtr, int index, byte[] value) { - nativeBindBlob((long) connectionPtr, (long) statementPtr, index, value); - } - - @Implementation(minSdk = LOLLIPOP) + @Implementation protected static void nativeBindBlob( final long connectionPtr, final long statementPtr, final int index, final byte[] value) { CONNECTIONS.bindBlob(connectionPtr, statementPtr, index, value); } - @Implementation(maxSdk = KITKAT_WATCH) - protected static void nativeRegisterLocalizedCollators(int connectionPtr, String locale) { - nativeRegisterLocalizedCollators((long) connectionPtr, locale); - } - - @Implementation(minSdk = LOLLIPOP) + @Implementation protected static void nativeRegisterLocalizedCollators(long connectionPtr, String locale) { // TODO: find a way to create a collator // http://www.sqlite.org/c3ref/create_collation.html // xerial jdbc driver does not have a Java method for sqlite3_create_collation } - @Implementation(maxSdk = KITKAT_WATCH) - protected static int nativeExecuteForChangedRowCount(int connectionPtr, int statementPtr) { - return nativeExecuteForChangedRowCount((long) connectionPtr, (long) statementPtr); - } - - @Implementation(minSdk = LOLLIPOP) + @Implementation protected static int nativeExecuteForChangedRowCount( final long connectionPtr, final long statementPtr) { return CONNECTIONS.executeForChangedRowCount(connectionPtr, statementPtr); } - @Implementation(maxSdk = KITKAT_WATCH) - protected static long nativeExecuteForLastInsertedRowId(int connectionPtr, int statementPtr) { - return nativeExecuteForLastInsertedRowId((long) connectionPtr, (long) statementPtr); - } - - @Implementation(minSdk = LOLLIPOP) + @Implementation protected static long nativeExecuteForLastInsertedRowId( final long connectionPtr, final long statementPtr) { return CONNECTIONS.executeForLastInsertedRowId(connectionPtr, statementPtr); } - @Implementation(maxSdk = KITKAT_WATCH) - protected static long nativeExecuteForCursorWindow( - int connectionPtr, - int statementPtr, - int windowPtr, - int startPos, - int requiredPos, - boolean countAllRows) { - return nativeExecuteForCursorWindow((long) connectionPtr, (long) statementPtr, (long) windowPtr, - startPos, requiredPos, countAllRows); -} - - @Implementation(minSdk = LOLLIPOP) + @Implementation protected static long nativeExecuteForCursorWindow( final long connectionPtr, final long statementPtr, @@ -323,66 +217,35 @@ public class ShadowLegacySQLiteConnection extends ShadowSQLiteConnection { return CONNECTIONS.executeForCursorWindow(connectionPtr, statementPtr, windowPtr); } - @Implementation(maxSdk = KITKAT_WATCH) - protected static void nativeResetStatementAndClearBindings(int connectionPtr, int statementPtr) { - nativeResetStatementAndClearBindings((long) connectionPtr, (long) statementPtr); - } - - @Implementation(minSdk = LOLLIPOP) + @Implementation protected static void nativeResetStatementAndClearBindings( final long connectionPtr, final long statementPtr) { CONNECTIONS.resetStatementAndClearBindings(connectionPtr, statementPtr); } - @Implementation(maxSdk = KITKAT_WATCH) - protected static void nativeCancel(int connectionPtr) { - nativeCancel((long) connectionPtr); - } - - @Implementation(minSdk = LOLLIPOP) + @Implementation protected static void nativeCancel(long connectionPtr) { CONNECTIONS.cancel(connectionPtr); } - @Implementation(maxSdk = KITKAT_WATCH) - protected static void nativeResetCancel(int connectionPtr, boolean cancelable) { - nativeResetCancel((long) connectionPtr, cancelable); - } - - @Implementation(minSdk = LOLLIPOP) + @Implementation protected static void nativeResetCancel(long connectionPtr, boolean cancelable) { // handled in com.almworks.sqlite4java.SQLiteConnection#exec } - @Implementation(maxSdk = KITKAT_WATCH) - protected static void nativeRegisterCustomFunction( - int connectionPtr, SQLiteCustomFunction function) { - nativeRegisterCustomFunction((long) connectionPtr, function); - } - - @Implementation(minSdk = LOLLIPOP, maxSdk = Q) + @Implementation(maxSdk = Q) protected static void nativeRegisterCustomFunction( long connectionPtr, SQLiteCustomFunction function) { // not supported } - @Implementation(maxSdk = KITKAT_WATCH) - protected static int nativeExecuteForBlobFileDescriptor(int connectionPtr, int statementPtr) { - return nativeExecuteForBlobFileDescriptor((long) connectionPtr, (long) statementPtr); - } - - @Implementation(minSdk = LOLLIPOP) + @Implementation protected static int nativeExecuteForBlobFileDescriptor(long connectionPtr, long statementPtr) { // impossible to support without native code? return -1; } - @Implementation(maxSdk = KITKAT_WATCH) - protected static int nativeGetDbLookaside(int connectionPtr) { - return nativeGetDbLookaside((long) connectionPtr); - } - - @Implementation(minSdk = LOLLIPOP) + @Implementation protected static int nativeGetDbLookaside(long connectionPtr) { // not supported by sqlite4java return 0; diff --git a/shadows/framework/src/main/java/org/robolectric/shadows/ShadowLegacyTypeface.java b/shadows/framework/src/main/java/org/robolectric/shadows/ShadowLegacyTypeface.java index 23cab9ef2..cec7d881a 100644 --- a/shadows/framework/src/main/java/org/robolectric/shadows/ShadowLegacyTypeface.java +++ b/shadows/framework/src/main/java/org/robolectric/shadows/ShadowLegacyTypeface.java @@ -1,6 +1,6 @@ package org.robolectric.shadows; -import static android.os.Build.VERSION_CODES.KITKAT; + import static android.os.Build.VERSION_CODES.LOLLIPOP; import static android.os.Build.VERSION_CODES.N_MR1; import static android.os.Build.VERSION_CODES.O; @@ -48,13 +48,8 @@ public class ShadowLegacyTypeface extends ShadowTypeface { private static final AtomicLong nextFontId = new AtomicLong(1); private FontDesc description; - @Implementation(maxSdk = KITKAT) - protected void __constructor__(int fontId) { - description = findById(fontId); - } - /** Starting in U, this constructor calls {@link #__constructor__(long, String )} below. */ - @Implementation(minSdk = LOLLIPOP, maxSdk = T.SDK_INT) + @Implementation(maxSdk = T.SDK_INT) protected void __constructor__(long fontId) { description = findById(fontId); } @@ -168,13 +163,13 @@ public class ShadowLegacyTypeface extends ShadowTypeface { } @HiddenApi - @Implementation(minSdk = LOLLIPOP) + @Implementation protected static Typeface createFromFamilies(Object /*FontFamily[]*/ families) { return null; } @HiddenApi - @Implementation(minSdk = LOLLIPOP, maxSdk = N_MR1) + @Implementation(maxSdk = N_MR1) protected static Typeface createFromFamiliesWithDefault(Object /*FontFamily[]*/ families) { return null; } @@ -204,7 +199,7 @@ public class ShadowLegacyTypeface extends ShadowTypeface { } /** Avoid spurious error message about /system/etc/fonts.xml */ - @Implementation(minSdk = LOLLIPOP, maxSdk = O_MR1) + @Implementation(maxSdk = O_MR1) protected static void init() {} @HiddenApi diff --git a/shadows/framework/src/main/java/org/robolectric/shadows/ShadowMediaCodec.java b/shadows/framework/src/main/java/org/robolectric/shadows/ShadowMediaCodec.java index 3bee37b16..2e3003ac9 100644 --- a/shadows/framework/src/main/java/org/robolectric/shadows/ShadowMediaCodec.java +++ b/shadows/framework/src/main/java/org/robolectric/shadows/ShadowMediaCodec.java @@ -151,12 +151,12 @@ public class ShadowMediaCodec { } /** Saves the callback to allow use inside the shadow. */ - @Implementation(minSdk = LOLLIPOP) + @Implementation protected void native_setCallback(MediaCodec.Callback callback) { this.callback = callback; } - @Implementation(minSdk = LOLLIPOP, maxSdk = N_MR1) + @Implementation(maxSdk = N_MR1) protected void native_configure( String[] keys, Object[] values, Surface surface, MediaCrypto crypto, int flags) { innerConfigure(keys, values, surface, crypto, flags); @@ -189,7 +189,7 @@ public class ShadowMediaCodec { * Starts the async encoding process, by first reporting a format change event, and then * presenting an input buffer to the callback. */ - @Implementation(minSdk = LOLLIPOP) + @Implementation protected void native_start() { // Reset state inputBuffersPendingDequeue.clear(); @@ -215,7 +215,7 @@ public class ShadowMediaCodec { } /** Flushes the available output buffers. */ - @Implementation(minSdk = LOLLIPOP) + @Implementation protected void native_flush() { // Reset input buffers only if the MediaCodec is in synchronous mode. If it is in asynchronous // mode, the client needs to call start(). @@ -237,7 +237,7 @@ public class ShadowMediaCodec { } /** Returns the input or output buffer corresponding to the given index, or null if invalid. */ - @Implementation(minSdk = LOLLIPOP) + @Implementation protected ByteBuffer getBuffer(boolean input, int index) { ByteBuffer[] buffers = input ? inputBuffers : outputBuffers; return index >= 0 && index < buffers.length && !(input && codecOwnsInputBuffer(index)) @@ -245,7 +245,7 @@ public class ShadowMediaCodec { : null; } - @Implementation(minSdk = LOLLIPOP) + @Implementation protected int native_dequeueInputBuffer(long timeoutUs) { checkState(!isAsync, "Attempting to deque buffer in Async mode."); try { @@ -273,7 +273,7 @@ public class ShadowMediaCodec { * Triggers presentation of the corresponding output buffer for the given input buffer, and passes * the given metadata as buffer info. */ - @Implementation(minSdk = LOLLIPOP) + @Implementation protected void native_queueInputBuffer( int index, int offset, int size, long presentationTimeUs, int flags) { if (index < 0 @@ -291,7 +291,7 @@ public class ShadowMediaCodec { inputBuffersPendingQueuing.remove(Integer.valueOf(index)); } - @Implementation(minSdk = LOLLIPOP) + @Implementation protected int native_dequeueOutputBuffer(BufferInfo info, long timeoutUs) { checkState(!isAsync, "Attempting to deque buffer in Async mode."); try { @@ -326,7 +326,7 @@ public class ShadowMediaCodec { releaseOutputBuffer(index); } - @Implementation(minSdk = LOLLIPOP) + @Implementation protected void releaseOutputBuffer(int index, long renderTimestampNs) { releaseOutputBuffer(index); } @@ -405,7 +405,7 @@ public class ShadowMediaCodec { } /** Prevents calling Android-only methods on basic ByteBuffer objects. */ - @Implementation(minSdk = LOLLIPOP, maxSdk = TIRAMISU) + @Implementation(maxSdk = TIRAMISU) protected void invalidateByteBuffer(@Nullable ByteBuffer[] buffers, int index) {} @Implementation(minSdk = U.SDK_INT) @@ -413,14 +413,14 @@ public class ShadowMediaCodec { @Nullable ByteBuffer[] buffers, int index, boolean input) {} /** Prevents calling Android-only methods on basic ByteBuffer objects. */ - @Implementation(minSdk = LOLLIPOP, maxSdk = TIRAMISU) + @Implementation(maxSdk = TIRAMISU) protected void validateInputByteBuffer(@Nullable ByteBuffer[] buffers, int index) {} @Implementation(minSdk = U.SDK_INT) protected void validateInputByteBufferLocked(@Nullable ByteBuffer[] buffers, int index) {} /** Prevents calling Android-only methods on basic ByteBuffer objects. */ - @Implementation(minSdk = LOLLIPOP, maxSdk = TIRAMISU) + @Implementation(maxSdk = TIRAMISU) protected void revalidateByteBuffer(@Nullable ByteBuffer[] buffers, int index) {} @Implementation(minSdk = U.SDK_INT) @@ -430,7 +430,7 @@ public class ShadowMediaCodec { * Prevents calling Android-only methods on basic ByteBuffer objects. Replicates existing behavior * adjusting buffer positions and limits. */ - @Implementation(minSdk = LOLLIPOP, maxSdk = TIRAMISU) + @Implementation(maxSdk = TIRAMISU) protected void validateOutputByteBuffer( @Nullable ByteBuffer[] buffers, int index, @NonNull BufferInfo info) { if (buffers != null && index >= 0 && index < buffers.length) { @@ -448,14 +448,14 @@ public class ShadowMediaCodec { } /** Prevents calling Android-only methods on basic ByteBuffer objects. */ - @Implementation(minSdk = LOLLIPOP, maxSdk = TIRAMISU) + @Implementation(maxSdk = TIRAMISU) protected void invalidateByteBuffers(@Nullable ByteBuffer[] buffers) {} @Implementation(minSdk = U.SDK_INT) protected void invalidateByteBuffersLocked(@Nullable ByteBuffer[] buffers) {} /** Prevents attempting to free non-direct ByteBuffer objects. */ - @Implementation(minSdk = LOLLIPOP, maxSdk = TIRAMISU) + @Implementation(maxSdk = TIRAMISU) protected void freeByteBuffer(@Nullable ByteBuffer buffer) {} @Implementation(minSdk = U.SDK_INT) diff --git a/shadows/framework/src/main/java/org/robolectric/shadows/ShadowMediaRecorder.java b/shadows/framework/src/main/java/org/robolectric/shadows/ShadowMediaRecorder.java index eed1f6230..58b035ceb 100644 --- a/shadows/framework/src/main/java/org/robolectric/shadows/ShadowMediaRecorder.java +++ b/shadows/framework/src/main/java/org/robolectric/shadows/ShadowMediaRecorder.java @@ -3,7 +3,6 @@ package org.robolectric.shadows; import android.graphics.SurfaceTexture; import android.hardware.Camera; import android.media.MediaRecorder; -import android.os.Build.VERSION_CODES; import android.view.Surface; import com.google.common.base.Preconditions; import org.robolectric.annotation.Implementation; @@ -190,7 +189,7 @@ public class ShadowMediaRecorder { } } - @Implementation(minSdk = VERSION_CODES.LOLLIPOP) + @Implementation protected Surface getSurface() { Preconditions.checkState( getVideoSource() == MediaRecorder.VideoSource.SURFACE, diff --git a/shadows/framework/src/main/java/org/robolectric/shadows/ShadowMotionEvent.java b/shadows/framework/src/main/java/org/robolectric/shadows/ShadowMotionEvent.java index 371cb6d9e..ba220ffe0 100644 --- a/shadows/framework/src/main/java/org/robolectric/shadows/ShadowMotionEvent.java +++ b/shadows/framework/src/main/java/org/robolectric/shadows/ShadowMotionEvent.java @@ -1,7 +1,6 @@ package org.robolectric.shadows; -import static android.os.Build.VERSION_CODES.KITKAT_WATCH; -import static android.os.Build.VERSION_CODES.LOLLIPOP; + import static android.os.Build.VERSION_CODES.M; import static android.os.Build.VERSION_CODES.P; import static android.os.Build.VERSION_CODES.UPSIDE_DOWN_CAKE; @@ -25,7 +24,6 @@ import android.view.MotionEvent.PointerProperties; import java.lang.reflect.Field; import java.lang.reflect.Modifier; import java.util.List; -import org.robolectric.RuntimeEnvironment; import org.robolectric.annotation.HiddenApi; import org.robolectric.annotation.Implementation; import org.robolectric.annotation.Implements; @@ -195,48 +193,7 @@ public class ShadowMotionEvent extends ShadowInputEvent { ReflectionHelpers.setField(outPointerCoordsObj, "mPackedAxisBits", outBits); } - @Implementation(maxSdk = KITKAT_WATCH) - @HiddenApi - protected static int nativeInitialize( - int nativePtr, - int deviceId, - int source, - int action, - int flags, - int edgeFlags, - int metaState, - int buttonState, - float xOffset, - float yOffset, - float xPrecision, - float yPrecision, - long downTimeNanos, - long eventTimeNanos, - int pointerCount, - PointerProperties[] pointerIds, - PointerCoords[] pointerCoords) { - return (int) - nativeInitialize( - (long) nativePtr, - deviceId, - source, - action, - flags, - edgeFlags, - metaState, - buttonState, - xOffset, - yOffset, - xPrecision, - yPrecision, - downTimeNanos, - eventTimeNanos, - pointerCount, - pointerIds, - pointerCoords); - } - - @Implementation(minSdk = LOLLIPOP, maxSdk = P) + @Implementation(maxSdk = P) @HiddenApi protected static long nativeInitialize( long nativePtr, @@ -340,26 +297,13 @@ public class ShadowMotionEvent extends ShadowInputEvent { pointerCoords); } - @Implementation(maxSdk = KITKAT_WATCH) - @HiddenApi - protected static void nativeDispose(int nativePtr) { - nativeDispose((long) nativePtr); - } - - @Implementation(minSdk = LOLLIPOP) + @Implementation @HiddenApi protected static void nativeDispose(long nativePtr) { nativeMotionEventRegistry.unregister(nativePtr); } - @Implementation(maxSdk = KITKAT_WATCH) - @HiddenApi - protected static void nativeAddBatch( - int nativePtr, long eventTimeNanos, PointerCoords[] pointerCoordsObjArray, int metaState) { - nativeAddBatch((long) nativePtr, eventTimeNanos, pointerCoordsObjArray, metaState); - } - - @Implementation(minSdk = LOLLIPOP) + @Implementation @HiddenApi protected static void nativeAddBatch( long nativePtr, long eventTimeNanos, PointerCoords[] pointerCoordsObjArray, int metaState) { @@ -377,14 +321,7 @@ public class ShadowMotionEvent extends ShadowInputEvent { event.setMetaState(event.getMetaState() | metaState); } - @Implementation(maxSdk = KITKAT_WATCH) - @HiddenApi - protected static void nativeGetPointerCoords( - int nativePtr, int pointerIndex, int historyPos, PointerCoords outPointerCoordsObj) { - nativeGetPointerCoords((long) nativePtr, pointerIndex, historyPos, outPointerCoordsObj); - } - - @Implementation(minSdk = LOLLIPOP) + @Implementation @HiddenApi protected static void nativeGetPointerCoords( long nativePtr, int pointerIndex, int historyPos, PointerCoords outPointerCoordsObj) { @@ -405,14 +342,7 @@ public class ShadowMotionEvent extends ShadowInputEvent { rawPointerCoords, event.getXOffset(), event.getYOffset(), outPointerCoordsObj); } - @Implementation(maxSdk = KITKAT_WATCH) - @HiddenApi - protected static void nativeGetPointerProperties( - int nativePtr, int pointerIndex, PointerProperties outPointerPropertiesObj) { - nativeGetPointerProperties((long) nativePtr, pointerIndex, outPointerPropertiesObj); - } - - @Implementation(minSdk = LOLLIPOP) + @Implementation @HiddenApi protected static void nativeGetPointerProperties( long nativePtr, int pointerIndex, PointerProperties outPointerPropertiesObj) { @@ -426,13 +356,7 @@ public class ShadowMotionEvent extends ShadowInputEvent { outPointerPropertiesObj.copyFrom(pointerProperties); } - @Implementation(maxSdk = KITKAT_WATCH) - @HiddenApi - protected static int nativeReadFromParcel(int nativePtr, Parcel parcelObj) { - return (int) nativeReadFromParcel((long) nativePtr, parcelObj); - } - - @Implementation(minSdk = LOLLIPOP) + @Implementation @HiddenApi protected static long nativeReadFromParcel(long nativePtr, Parcel parcelObj) { NativeInput.MotionEvent event; @@ -452,13 +376,7 @@ public class ShadowMotionEvent extends ShadowInputEvent { return nativePtr; } - @Implementation(maxSdk = KITKAT_WATCH) - @HiddenApi - protected static void nativeWriteToParcel(int nativePtr, Parcel parcel) { - nativeWriteToParcel((long) nativePtr, parcel); - } - - @Implementation(minSdk = LOLLIPOP) + @Implementation @HiddenApi protected static void nativeWriteToParcel(long nativePtr, Parcel parcel) { NativeInput.MotionEvent event = getNativeMotionEvent(nativePtr); @@ -467,7 +385,7 @@ public class ShadowMotionEvent extends ShadowInputEvent { } } - @Implementation(minSdk = LOLLIPOP) + @Implementation @HiddenApi protected static String nativeAxisToString(int axis) { // The native code just mirrors the AXIS_* constants defined in MotionEvent.java. @@ -489,7 +407,7 @@ public class ShadowMotionEvent extends ShadowInputEvent { return null; } - @Implementation(minSdk = LOLLIPOP) + @Implementation @HiddenApi protected static int nativeAxisFromString(String label) { // The native code just mirrors the AXIS_* constants defined in MotionEvent.java. Look up @@ -502,13 +420,7 @@ public class ShadowMotionEvent extends ShadowInputEvent { } } - @Implementation(maxSdk = KITKAT_WATCH) - @HiddenApi - protected static int nativeGetPointerId(int nativePtr, int pointerIndex) { - return nativeGetPointerId((long) nativePtr, pointerIndex); - } - - @Implementation(minSdk = LOLLIPOP) + @Implementation @HiddenApi protected static int nativeGetPointerId(long nativePtr, int pointerIndex) { NativeInput.MotionEvent event = getNativeMotionEvent(nativePtr); @@ -517,13 +429,7 @@ public class ShadowMotionEvent extends ShadowInputEvent { return event.getPointerId(pointerIndex); } - @Implementation(maxSdk = KITKAT_WATCH) - @HiddenApi - protected static int nativeGetToolType(int nativePtr, int pointerIndex) { - return nativeGetToolType((long) nativePtr, pointerIndex); - } - - @Implementation(minSdk = LOLLIPOP) + @Implementation @HiddenApi protected static int nativeGetToolType(long nativePtr, int pointerIndex) { NativeInput.MotionEvent event = getNativeMotionEvent(nativePtr); @@ -532,13 +438,7 @@ public class ShadowMotionEvent extends ShadowInputEvent { return event.getToolType(pointerIndex); } - @Implementation(maxSdk = KITKAT_WATCH) - @HiddenApi - protected static long nativeGetEventTimeNanos(int nativePtr, int historyPos) { - return nativeGetEventTimeNanos((long) nativePtr, historyPos); - } - - @Implementation(minSdk = LOLLIPOP) + @Implementation @HiddenApi protected static long nativeGetEventTimeNanos(long nativePtr, int historyPos) { NativeInput.MotionEvent event = getNativeMotionEvent(nativePtr); @@ -551,14 +451,7 @@ public class ShadowMotionEvent extends ShadowInputEvent { } } - @Implementation(maxSdk = KITKAT_WATCH) - @HiddenApi - protected static float nativeGetRawAxisValue( - int nativePtr, int axis, int pointerIndex, int historyPos) { - return nativeGetRawAxisValue((long) nativePtr, axis, pointerIndex, historyPos); - } - - @Implementation(minSdk = LOLLIPOP) + @Implementation @HiddenApi protected static float nativeGetRawAxisValue( long nativePtr, int axis, int pointerIndex, int historyPos) { @@ -575,14 +468,7 @@ public class ShadowMotionEvent extends ShadowInputEvent { } } - @Implementation(maxSdk = KITKAT_WATCH) - @HiddenApi - protected static float nativeGetAxisValue( - int nativePtr, int axis, int pointerIndex, int historyPos) { - return nativeGetAxisValue((long) nativePtr, axis, pointerIndex, historyPos); - } - - @Implementation(minSdk = LOLLIPOP) + @Implementation @HiddenApi protected static float nativeGetAxisValue( long nativePtr, int axis, int pointerIndex, int historyPos) { @@ -599,13 +485,7 @@ public class ShadowMotionEvent extends ShadowInputEvent { } } - @Implementation(maxSdk = KITKAT_WATCH) - @HiddenApi - protected static int nativeCopy(int destNativePtr, int sourceNativePtr, boolean keepHistory) { - return (int) nativeCopy((long) destNativePtr, (long) sourceNativePtr, keepHistory); - } - - @Implementation(minSdk = LOLLIPOP) + @Implementation @HiddenApi protected static long nativeCopy(long destNativePtr, long sourceNativePtr, boolean keepHistory) { NativeInput.MotionEvent destEvent = nativeMotionEventRegistry.peekNativeObject(destNativePtr); @@ -618,40 +498,21 @@ public class ShadowMotionEvent extends ShadowInputEvent { return destNativePtr; } - @Implementation(maxSdk = KITKAT_WATCH) - @HiddenApi - protected static int nativeGetDeviceId(int nativePtr) { - return nativeGetDeviceId((long) nativePtr); - } - - @Implementation(minSdk = LOLLIPOP) + @Implementation @HiddenApi protected static int nativeGetDeviceId(long nativePtr) { NativeInput.MotionEvent event = getNativeMotionEvent(nativePtr); return event.getDeviceId(); } - @Implementation(maxSdk = KITKAT_WATCH) - @HiddenApi - protected static int nativeGetSource(int nativePtr) { - return nativeGetSource((long) nativePtr); - } - - @Implementation(minSdk = LOLLIPOP) + @Implementation @HiddenApi protected static int nativeGetSource(long nativePtr) { NativeInput.MotionEvent event = getNativeMotionEvent(nativePtr); return event.getSource(); } - @Implementation(maxSdk = KITKAT_WATCH) - @HiddenApi - protected static int nativeSetSource(int nativePtr, int source) { - nativeSetSource((long) nativePtr, source); - return 0; - } - - @Implementation(minSdk = LOLLIPOP) + @Implementation @HiddenApi @SuppressWarnings("robolectric.ShadowReturnTypeMismatch") protected static void nativeSetSource(long nativePtr, int source) { @@ -659,26 +520,14 @@ public class ShadowMotionEvent extends ShadowInputEvent { event.setSource(source); } - @Implementation(maxSdk = KITKAT_WATCH) - @HiddenApi - protected static int nativeGetAction(int nativePtr) { - return nativeGetAction((long) nativePtr); - } - - @Implementation(minSdk = LOLLIPOP) + @Implementation @HiddenApi protected static int nativeGetAction(long nativePtr) { NativeInput.MotionEvent event = getNativeMotionEvent(nativePtr); return event.getAction(); } - @Implementation(maxSdk = KITKAT_WATCH) - @HiddenApi - protected static void nativeSetAction(int nativePtr, int action) { - nativeSetAction((long) nativePtr, action); - } - - @Implementation(minSdk = LOLLIPOP) + @Implementation @HiddenApi protected static void nativeSetAction(long nativePtr, int action) { NativeInput.MotionEvent event = getNativeMotionEvent(nativePtr); @@ -699,91 +548,49 @@ public class ShadowMotionEvent extends ShadowInputEvent { event.setActionButton(button); } - @Implementation(maxSdk = KITKAT_WATCH) - @HiddenApi - protected static boolean nativeIsTouchEvent(int nativePtr) { - return nativeIsTouchEvent((long) nativePtr); - } - - @Implementation(minSdk = LOLLIPOP) + @Implementation @HiddenApi protected static boolean nativeIsTouchEvent(long nativePtr) { NativeInput.MotionEvent event = getNativeMotionEvent(nativePtr); return event.isTouchEvent(); } - @Implementation(maxSdk = KITKAT_WATCH) - @HiddenApi - protected static int nativeGetFlags(int nativePtr) { - return nativeGetFlags((long) nativePtr); - } - - @Implementation(minSdk = LOLLIPOP) + @Implementation @HiddenApi protected static int nativeGetFlags(long nativePtr) { NativeInput.MotionEvent event = getNativeMotionEvent(nativePtr); return event.getFlags(); } - @Implementation(maxSdk = KITKAT_WATCH) - @HiddenApi - protected static void nativeSetFlags(int nativePtr, int flags) { - nativeSetFlags((long) nativePtr, flags); - } - - @Implementation(minSdk = LOLLIPOP) + @Implementation @HiddenApi protected static void nativeSetFlags(long nativePtr, int flags) { NativeInput.MotionEvent event = getNativeMotionEvent(nativePtr); event.setFlags(flags); } - @Implementation(maxSdk = KITKAT_WATCH) - @HiddenApi - protected static int nativeGetEdgeFlags(int nativePtr) { - return nativeGetEdgeFlags((long) nativePtr); - } - - @Implementation(minSdk = LOLLIPOP) + @Implementation @HiddenApi protected static int nativeGetEdgeFlags(long nativePtr) { NativeInput.MotionEvent event = getNativeMotionEvent(nativePtr); return event.getEdgeFlags(); } - @Implementation(maxSdk = KITKAT_WATCH) - @HiddenApi - protected static void nativeSetEdgeFlags(int nativePtr, int edgeFlags) { - nativeSetEdgeFlags((long) nativePtr, edgeFlags); - } - - @Implementation(minSdk = LOLLIPOP) + @Implementation @HiddenApi protected static void nativeSetEdgeFlags(long nativePtr, int edgeFlags) { NativeInput.MotionEvent event = getNativeMotionEvent(nativePtr); event.setEdgeFlags(edgeFlags); } - @Implementation(maxSdk = KITKAT_WATCH) - @HiddenApi - protected static int nativeGetMetaState(int nativePtr) { - return nativeGetMetaState((long) nativePtr); - } - - @Implementation(minSdk = LOLLIPOP) + @Implementation @HiddenApi protected static int nativeGetMetaState(long nativePtr) { NativeInput.MotionEvent event = getNativeMotionEvent(nativePtr); return event.getMetaState(); } - @Implementation(maxSdk = KITKAT_WATCH) - @HiddenApi - protected static int nativeGetButtonState(int nativePtr) { - return nativeGetButtonState((long) nativePtr); - } - - @Implementation(minSdk = LOLLIPOP) + @Implementation @HiddenApi protected static int nativeGetButtonState(long nativePtr) { NativeInput.MotionEvent event = getNativeMotionEvent(nativePtr); @@ -797,26 +604,14 @@ public class ShadowMotionEvent extends ShadowInputEvent { event.setButtonState(buttonState); } - @Implementation(maxSdk = KITKAT_WATCH) - @HiddenApi - protected static void nativeOffsetLocation(int nativePtr, float deltaX, float deltaY) { - nativeOffsetLocation((long) nativePtr, deltaX, deltaY); - } - - @Implementation(minSdk = LOLLIPOP) + @Implementation @HiddenApi protected static void nativeOffsetLocation(long nativePtr, float deltaX, float deltaY) { NativeInput.MotionEvent event = getNativeMotionEvent(nativePtr); event.offsetLocation(deltaX, deltaY); } - @Implementation(maxSdk = KITKAT_WATCH) - @HiddenApi - protected static float nativeGetXOffset(int nativePtr) { - return nativeGetXOffset((long) nativePtr); - } - - @Implementation(minSdk = LOLLIPOP, maxSdk = UPSIDE_DOWN_CAKE) + @Implementation(maxSdk = UPSIDE_DOWN_CAKE) @HiddenApi @InDevelopment protected static float nativeGetXOffset(long nativePtr) { @@ -824,13 +619,7 @@ public class ShadowMotionEvent extends ShadowInputEvent { return event.getXOffset(); } - @Implementation(maxSdk = KITKAT_WATCH) - @HiddenApi - protected static float nativeGetYOffset(int nativePtr) { - return nativeGetYOffset((long) nativePtr); - } - - @Implementation(minSdk = LOLLIPOP, maxSdk = UPSIDE_DOWN_CAKE) + @Implementation(maxSdk = UPSIDE_DOWN_CAKE) @HiddenApi @InDevelopment protected static float nativeGetYOffset(long nativePtr) { @@ -856,104 +645,56 @@ public class ShadowMotionEvent extends ShadowInputEvent { return getNativeMotionEvent(nativePtr).getYOffset(); } - @Implementation(maxSdk = KITKAT_WATCH) - @HiddenApi - protected static float nativeGetXPrecision(int nativePtr) { - return nativeGetXPrecision((long) nativePtr); - } - - @Implementation(minSdk = LOLLIPOP) + @Implementation @HiddenApi protected static float nativeGetXPrecision(long nativePtr) { NativeInput.MotionEvent event = getNativeMotionEvent(nativePtr); return event.getXPrecision(); } - @Implementation(maxSdk = KITKAT_WATCH) - @HiddenApi - protected static float nativeGetYPrecision(int nativePtr) { - return nativeGetYPrecision((long) nativePtr); - } - - @Implementation(minSdk = LOLLIPOP) + @Implementation @HiddenApi protected static float nativeGetYPrecision(long nativePtr) { NativeInput.MotionEvent event = getNativeMotionEvent(nativePtr); return event.getYPrecision(); } - @Implementation(maxSdk = KITKAT_WATCH) - @HiddenApi - protected static long nativeGetDownTimeNanos(int nativePtr) { - return nativeGetDownTimeNanos((long) nativePtr); - } - - @Implementation(minSdk = LOLLIPOP) + @Implementation @HiddenApi protected static long nativeGetDownTimeNanos(long nativePtr) { NativeInput.MotionEvent event = getNativeMotionEvent(nativePtr); return event.getDownTime(); } - @Implementation(maxSdk = KITKAT_WATCH) - @HiddenApi - protected static void nativeSetDownTimeNanos(int nativePtr, long downTimeNanos) { - nativeSetDownTimeNanos((long) nativePtr, downTimeNanos); - } - - @Implementation(minSdk = LOLLIPOP) + @Implementation @HiddenApi protected static void nativeSetDownTimeNanos(long nativePtr, long downTimeNanos) { NativeInput.MotionEvent event = getNativeMotionEvent(nativePtr); event.setDownTime(downTimeNanos); } - @Implementation(maxSdk = KITKAT_WATCH) - @HiddenApi - protected static int nativeGetPointerCount(int nativePtr) { - return nativeGetPointerCount((long) nativePtr); - } - - @Implementation(minSdk = LOLLIPOP) + @Implementation @HiddenApi protected static int nativeGetPointerCount(long nativePtr) { NativeInput.MotionEvent event = getNativeMotionEvent(nativePtr); return event.getPointerCount(); } - @Implementation(maxSdk = KITKAT_WATCH) - @HiddenApi - protected static int nativeFindPointerIndex(int nativePtr, int pointerId) { - return nativeFindPointerIndex((long) nativePtr, pointerId); - } - - @Implementation(minSdk = LOLLIPOP) + @Implementation @HiddenApi protected static int nativeFindPointerIndex(long nativePtr, int pointerId) { NativeInput.MotionEvent event = getNativeMotionEvent(nativePtr); return event.findPointerIndex(pointerId); } - @Implementation(maxSdk = KITKAT_WATCH) - @HiddenApi - protected static int nativeGetHistorySize(int nativePtr) { - return nativeGetHistorySize((long) nativePtr); - } - - @Implementation(minSdk = LOLLIPOP) + @Implementation @HiddenApi protected static int nativeGetHistorySize(long nativePtr) { NativeInput.MotionEvent event = getNativeMotionEvent(nativePtr); return event.getHistorySize(); } - @Implementation(maxSdk = KITKAT_WATCH) - @HiddenApi - protected static void nativeScale(int nativePtr, float scale) { - nativeScale((long) nativePtr, scale); - } - - @Implementation(minSdk = LOLLIPOP) + @Implementation @HiddenApi protected static void nativeScale(long nativePtr, float scale) { NativeInput.MotionEvent event = getNativeMotionEvent(nativePtr); @@ -982,13 +723,9 @@ public class ShadowMotionEvent extends ShadowInputEvent { } protected NativeInput.MotionEvent getNativeMotionEvent() { - long nativePtr; - if (RuntimeEnvironment.getApiLevel() <= KITKAT_WATCH) { - Integer nativePtrInt = ReflectionHelpers.getField(realMotionEvent, "mNativePtr"); - nativePtr = nativePtrInt.longValue(); - } else { - nativePtr = ReflectionHelpers.getField(realMotionEvent, "mNativePtr"); - } + + long nativePtr = ReflectionHelpers.getField(realMotionEvent, "mNativePtr"); + return nativeMotionEventRegistry.getNativeObject(nativePtr); } diff --git a/shadows/framework/src/main/java/org/robolectric/shadows/ShadowNativeBitmap.java b/shadows/framework/src/main/java/org/robolectric/shadows/ShadowNativeBitmap.java index 140ba87ac..7f5377ffb 100644 --- a/shadows/framework/src/main/java/org/robolectric/shadows/ShadowNativeBitmap.java +++ b/shadows/framework/src/main/java/org/robolectric/shadows/ShadowNativeBitmap.java @@ -1,6 +1,5 @@ package org.robolectric.shadows; -import static android.os.Build.VERSION_CODES.LOLLIPOP; import static android.os.Build.VERSION_CODES.M; import static android.os.Build.VERSION_CODES.N; import static android.os.Build.VERSION_CODES.N_MR1; @@ -100,7 +99,7 @@ public class ShadowNativeBitmap extends ShadowBitmap { colors, offset, stride, width, height, nativeConfig, mutable, colorSpacePtr); } - @Implementation(minSdk = LOLLIPOP, maxSdk = U.SDK_INT) + @Implementation(maxSdk = U.SDK_INT) protected static Bitmap nativeCopy(long nativeSrcBitmap, int nativeConfig, boolean isMutable) { return BitmapNatives.nativeCopy(nativeSrcBitmap, nativeConfig, isMutable); } @@ -120,7 +119,7 @@ public class ShadowNativeBitmap extends ShadowBitmap { return BitmapNatives.nativeGetNativeFinalizer(); } - @Implementation(minSdk = LOLLIPOP, maxSdk = U.SDK_INT) + @Implementation(maxSdk = U.SDK_INT) protected static Object nativeRecycle(Object nativeBitmap) { BitmapNatives.nativeRecycle((long) nativeBitmap); return true; @@ -132,13 +131,13 @@ public class ShadowNativeBitmap extends ShadowBitmap { BitmapNatives.nativeReconfigure(nativeBitmap, width, height, config, isPremultiplied); } - @Implementation(minSdk = LOLLIPOP, maxSdk = U.SDK_INT) + @Implementation(maxSdk = U.SDK_INT) protected static boolean nativeCompress( long nativeBitmap, int format, int quality, OutputStream stream, byte[] tempStorage) { return BitmapNatives.nativeCompress(nativeBitmap, format, quality, stream, tempStorage); } - @Implementation(minSdk = LOLLIPOP, maxSdk = U.SDK_INT) + @Implementation(maxSdk = U.SDK_INT) protected static void nativeErase(long nativeBitmap, int color) { BitmapNatives.nativeErase(nativeBitmap, color); } @@ -148,17 +147,17 @@ public class ShadowNativeBitmap extends ShadowBitmap { BitmapNatives.nativeErase(nativeBitmap, colorSpacePtr, color); } - @Implementation(minSdk = LOLLIPOP, maxSdk = U.SDK_INT) + @Implementation(maxSdk = U.SDK_INT) protected static int nativeRowBytes(long nativeBitmap) { return BitmapNatives.nativeRowBytes(nativeBitmap); } - @Implementation(minSdk = LOLLIPOP, maxSdk = U.SDK_INT) + @Implementation(maxSdk = U.SDK_INT) protected static int nativeConfig(long nativeBitmap) { return BitmapNatives.nativeConfig(nativeBitmap); } - @Implementation(minSdk = LOLLIPOP, maxSdk = U.SDK_INT) + @Implementation(maxSdk = U.SDK_INT) protected static int nativeGetPixel(long nativeBitmap, int x, int y) { return BitmapNatives.nativeGetPixel(nativeBitmap, x, y); } @@ -168,7 +167,7 @@ public class ShadowNativeBitmap extends ShadowBitmap { return BitmapNatives.nativeGetColor(nativeBitmap, x, y); } - @Implementation(minSdk = LOLLIPOP, maxSdk = U.SDK_INT) + @Implementation(maxSdk = U.SDK_INT) protected static void nativeGetPixels( long nativeBitmap, int[] pixels, @@ -181,12 +180,12 @@ public class ShadowNativeBitmap extends ShadowBitmap { BitmapNatives.nativeGetPixels(nativeBitmap, pixels, offset, stride, x, y, width, height); } - @Implementation(minSdk = LOLLIPOP, maxSdk = U.SDK_INT) + @Implementation(maxSdk = U.SDK_INT) protected static void nativeSetPixel(long nativeBitmap, int x, int y, int color) { BitmapNatives.nativeSetPixel(nativeBitmap, x, y, color); } - @Implementation(minSdk = LOLLIPOP, maxSdk = U.SDK_INT) + @Implementation(maxSdk = U.SDK_INT) protected static void nativeSetPixels( long nativeBitmap, int[] colors, @@ -225,17 +224,17 @@ public class ShadowNativeBitmap extends ShadowBitmap { return BitmapNatives.nativeHasAlpha(nativeBitmap); } - @Implementation(minSdk = LOLLIPOP, maxSdk = U.SDK_INT) + @Implementation(maxSdk = U.SDK_INT) protected static boolean nativeIsPremultiplied(long nativeBitmap) { return BitmapNatives.nativeIsPremultiplied(nativeBitmap); } - @Implementation(minSdk = LOLLIPOP, maxSdk = U.SDK_INT) + @Implementation(maxSdk = U.SDK_INT) protected static void nativeSetPremultiplied(long nativeBitmap, boolean isPremul) { BitmapNatives.nativeSetPremultiplied(nativeBitmap, isPremul); } - @Implementation(minSdk = LOLLIPOP, maxSdk = U.SDK_INT) + @Implementation(maxSdk = U.SDK_INT) protected static void nativeSetHasAlpha( long nativeBitmap, boolean hasAlpha, boolean requestPremul) { BitmapNatives.nativeSetHasAlpha(nativeBitmap, hasAlpha, requestPremul); diff --git a/shadows/framework/src/main/java/org/robolectric/shadows/ShadowNativeBitmapFactory.java b/shadows/framework/src/main/java/org/robolectric/shadows/ShadowNativeBitmapFactory.java index 06d3cb7e8..593a1e94f 100644 --- a/shadows/framework/src/main/java/org/robolectric/shadows/ShadowNativeBitmapFactory.java +++ b/shadows/framework/src/main/java/org/robolectric/shadows/ShadowNativeBitmapFactory.java @@ -1,6 +1,5 @@ package org.robolectric.shadows; -import static android.os.Build.VERSION_CODES.LOLLIPOP; import static android.os.Build.VERSION_CODES.O; import static android.os.Build.VERSION_CODES.P; import static android.os.Build.VERSION_CODES.Q; @@ -101,7 +100,7 @@ public class ShadowNativeBitmapFactory { nativeAsset, padding, opts, inBitmapHandle, colorSpaceHandle); } - @Implementation(minSdk = LOLLIPOP, maxSdk = P) + @Implementation(maxSdk = P) protected static Bitmap nativeDecodeAsset(long nativeAsset, Rect padding, Options opts) { return nativeDecodeAsset(nativeAsset, padding, opts, nativeInBitmap(opts), 0); } diff --git a/shadows/framework/src/main/java/org/robolectric/shadows/ShadowNativeCursorWindow.java b/shadows/framework/src/main/java/org/robolectric/shadows/ShadowNativeCursorWindow.java index f7c242326..533bb049e 100644 --- a/shadows/framework/src/main/java/org/robolectric/shadows/ShadowNativeCursorWindow.java +++ b/shadows/framework/src/main/java/org/robolectric/shadows/ShadowNativeCursorWindow.java @@ -1,12 +1,10 @@ package org.robolectric.shadows; -import static android.os.Build.VERSION_CODES.KITKAT_WATCH; -import static android.os.Build.VERSION_CODES.LOLLIPOP; + import android.database.CharArrayBuffer; import android.database.CursorWindow; import com.google.common.base.Preconditions; -import org.robolectric.RuntimeEnvironment; import org.robolectric.annotation.Implementation; import org.robolectric.annotation.Implements; import org.robolectric.nativeruntime.CursorWindowNatives; @@ -20,185 +18,100 @@ public class ShadowNativeCursorWindow extends ShadowCursorWindow { @Implementation(maxSdk = U.SDK_INT) protected static Number nativeCreate(String name, int cursorWindowSize) { DefaultNativeRuntimeLoader.injectAndLoad(); - long result = CursorWindowNatives.nativeCreate(name, cursorWindowSize); - if (RuntimeEnvironment.getApiLevel() < LOLLIPOP) { - return PreLPointers.register(result); - } - return result; - } - - @Implementation(maxSdk = KITKAT_WATCH) - protected static void nativeDispose(int windowPtr) { - nativeDispose(PreLPointers.get(windowPtr)); - PreLPointers.remove(windowPtr); + return CursorWindowNatives.nativeCreate(name, cursorWindowSize); } - @Implementation(minSdk = LOLLIPOP, maxSdk = U.SDK_INT) + @Implementation(maxSdk = U.SDK_INT) protected static void nativeDispose(long windowPtr) { CursorWindowNatives.nativeDispose(windowPtr); } - @Implementation(maxSdk = KITKAT_WATCH) - protected static String nativeGetName(int windowPtr) { - return nativeGetName(PreLPointers.get(windowPtr)); - } - - @Implementation(minSdk = LOLLIPOP, maxSdk = U.SDK_INT) + @Implementation(maxSdk = U.SDK_INT) protected static String nativeGetName(long windowPtr) { return CursorWindowNatives.nativeGetName(windowPtr); } - @Implementation(maxSdk = KITKAT_WATCH) - protected static byte[] nativeGetBlob(int windowPtr, int row, int column) { - return nativeGetBlob(PreLPointers.get(windowPtr), row, column); - } - - @Implementation(minSdk = LOLLIPOP, maxSdk = U.SDK_INT) + @Implementation(maxSdk = U.SDK_INT) protected static byte[] nativeGetBlob(long windowPtr, int row, int column) { return CursorWindowNatives.nativeGetBlob(windowPtr, row, column); } - @Implementation(maxSdk = KITKAT_WATCH) - protected static String nativeGetString(int windowPtr, int row, int column) { - return nativeGetString(PreLPointers.get(windowPtr), row, column); - } - - @Implementation(minSdk = LOLLIPOP, maxSdk = U.SDK_INT) + @Implementation(maxSdk = U.SDK_INT) protected static String nativeGetString(long windowPtr, int row, int column) { return CursorWindowNatives.nativeGetString(windowPtr, row, column); } - @Implementation(minSdk = LOLLIPOP, maxSdk = U.SDK_INT) + @Implementation(maxSdk = U.SDK_INT) protected static void nativeCopyStringToBuffer( long windowPtr, int row, int column, CharArrayBuffer buffer) { CursorWindowNatives.nativeCopyStringToBuffer(windowPtr, row, column, buffer); } - @Implementation(maxSdk = KITKAT_WATCH) - protected static boolean nativePutBlob(int windowPtr, byte[] value, int row, int column) { - return nativePutBlob(PreLPointers.get(windowPtr), value, row, column); - } - - @Implementation(minSdk = LOLLIPOP, maxSdk = U.SDK_INT) + @Implementation(maxSdk = U.SDK_INT) protected static boolean nativePutBlob(long windowPtr, byte[] value, int row, int column) { // Real Android will crash in native code if putBlob is called with a null value. Preconditions.checkNotNull(value); return CursorWindowNatives.nativePutBlob(windowPtr, value, row, column); } - @Implementation(maxSdk = KITKAT_WATCH) - protected static boolean nativePutString(int windowPtr, String value, int row, int column) { - return nativePutString(PreLPointers.get(windowPtr), value, row, column); - } - - @Implementation(minSdk = LOLLIPOP, maxSdk = U.SDK_INT) + @Implementation(maxSdk = U.SDK_INT) protected static boolean nativePutString(long windowPtr, String value, int row, int column) { // Real Android will crash in native code if putString is called with a null value. Preconditions.checkNotNull(value); return CursorWindowNatives.nativePutString(windowPtr, value, row, column); } - @Implementation(maxSdk = KITKAT_WATCH) - protected static void nativeClear(int windowPtr) { - nativeClear(PreLPointers.get(windowPtr)); - } - - @Implementation(minSdk = LOLLIPOP, maxSdk = U.SDK_INT) + @Implementation(maxSdk = U.SDK_INT) protected static void nativeClear(long windowPtr) { CursorWindowNatives.nativeClear(windowPtr); } - @Implementation(maxSdk = KITKAT_WATCH) - protected static int nativeGetNumRows(int windowPtr) { - return nativeGetNumRows(PreLPointers.get(windowPtr)); - } - - @Implementation(minSdk = LOLLIPOP, maxSdk = U.SDK_INT) + @Implementation(maxSdk = U.SDK_INT) protected static int nativeGetNumRows(long windowPtr) { return CursorWindowNatives.nativeGetNumRows(windowPtr); } - @Implementation(maxSdk = KITKAT_WATCH) - protected static boolean nativeSetNumColumns(int windowPtr, int columnNum) { - return nativeSetNumColumns(PreLPointers.get(windowPtr), columnNum); - } - - @Implementation(minSdk = LOLLIPOP, maxSdk = U.SDK_INT) + @Implementation(maxSdk = U.SDK_INT) protected static boolean nativeSetNumColumns(long windowPtr, int columnNum) { return CursorWindowNatives.nativeSetNumColumns(windowPtr, columnNum); } - @Implementation(maxSdk = KITKAT_WATCH) - protected static boolean nativeAllocRow(int windowPtr) { - return nativeAllocRow(PreLPointers.get(windowPtr)); - } - - @Implementation(minSdk = LOLLIPOP, maxSdk = U.SDK_INT) + @Implementation(maxSdk = U.SDK_INT) protected static boolean nativeAllocRow(long windowPtr) { return CursorWindowNatives.nativeAllocRow(windowPtr); } - @Implementation(minSdk = LOLLIPOP, maxSdk = U.SDK_INT) + @Implementation(maxSdk = U.SDK_INT) protected static void nativeFreeLastRow(long windowPtr) { CursorWindowNatives.nativeFreeLastRow(windowPtr); } - @Implementation(maxSdk = KITKAT_WATCH) - protected static int nativeGetType(int windowPtr, int row, int column) { - return nativeGetType(PreLPointers.get(windowPtr), row, column); - } - - @Implementation(minSdk = LOLLIPOP, maxSdk = U.SDK_INT) + @Implementation(maxSdk = U.SDK_INT) protected static int nativeGetType(long windowPtr, int row, int column) { return CursorWindowNatives.nativeGetType(windowPtr, row, column); } - @Implementation(maxSdk = KITKAT_WATCH) - protected static long nativeGetLong(int windowPtr, int row, int column) { - return nativeGetLong(PreLPointers.get(windowPtr), row, column); - } - - @Implementation(minSdk = LOLLIPOP, maxSdk = U.SDK_INT) + @Implementation(maxSdk = U.SDK_INT) protected static long nativeGetLong(long windowPtr, int row, int column) { return CursorWindowNatives.nativeGetLong(windowPtr, row, column); } - @Implementation(maxSdk = KITKAT_WATCH) - protected static double nativeGetDouble(int windowPtr, int row, int column) { - return nativeGetDouble(PreLPointers.get(windowPtr), row, column); - } - - @Implementation(minSdk = LOLLIPOP, maxSdk = U.SDK_INT) + @Implementation(maxSdk = U.SDK_INT) protected static double nativeGetDouble(long windowPtr, int row, int column) { return CursorWindowNatives.nativeGetDouble(windowPtr, row, column); } - @Implementation(maxSdk = KITKAT_WATCH) - protected static boolean nativePutLong(int windowPtr, long value, int row, int column) { - return nativePutLong(PreLPointers.get(windowPtr), value, row, column); - } - - @Implementation(minSdk = LOLLIPOP, maxSdk = U.SDK_INT) + @Implementation(maxSdk = U.SDK_INT) protected static boolean nativePutLong(long windowPtr, long value, int row, int column) { return CursorWindowNatives.nativePutLong(windowPtr, value, row, column); } - @Implementation(maxSdk = KITKAT_WATCH) - protected static boolean nativePutDouble(int windowPtr, double value, int row, int column) { - return nativePutDouble(PreLPointers.get(windowPtr), value, row, column); - } - - @Implementation(minSdk = LOLLIPOP, maxSdk = U.SDK_INT) + @Implementation(maxSdk = U.SDK_INT) protected static boolean nativePutDouble(long windowPtr, double value, int row, int column) { return CursorWindowNatives.nativePutDouble(windowPtr, value, row, column); } - @Implementation(maxSdk = KITKAT_WATCH) - protected static boolean nativePutNull(int windowPtr, int row, int column) { - return nativePutNull(PreLPointers.get(windowPtr), row, column); - } - - @Implementation(minSdk = LOLLIPOP, maxSdk = U.SDK_INT) + @Implementation(maxSdk = U.SDK_INT) protected static boolean nativePutNull(long windowPtr, int row, int column) { return CursorWindowNatives.nativePutNull(windowPtr, row, column); } diff --git a/shadows/framework/src/main/java/org/robolectric/shadows/ShadowNativeMatrix.java b/shadows/framework/src/main/java/org/robolectric/shadows/ShadowNativeMatrix.java index 61c4e7db5..de4fccdfe 100644 --- a/shadows/framework/src/main/java/org/robolectric/shadows/ShadowNativeMatrix.java +++ b/shadows/framework/src/main/java/org/robolectric/shadows/ShadowNativeMatrix.java @@ -1,6 +1,5 @@ package org.robolectric.shadows; -import static android.os.Build.VERSION_CODES.LOLLIPOP; import static android.os.Build.VERSION_CODES.N_MR1; import static android.os.Build.VERSION_CODES.O; @@ -32,7 +31,7 @@ public class ShadowNativeMatrix extends ShadowMatrix { // deferred } - @Implementation(minSdk = LOLLIPOP, maxSdk = N_MR1) + @Implementation(maxSdk = N_MR1) protected static long native_create(long nSrcOrZero) { return nCreate(nSrcOrZero); } diff --git a/shadows/framework/src/main/java/org/robolectric/shadows/ShadowNativeSQLiteConnection.java b/shadows/framework/src/main/java/org/robolectric/shadows/ShadowNativeSQLiteConnection.java index 5f26774c3..fde3573ed 100644 --- a/shadows/framework/src/main/java/org/robolectric/shadows/ShadowNativeSQLiteConnection.java +++ b/shadows/framework/src/main/java/org/robolectric/shadows/ShadowNativeSQLiteConnection.java @@ -1,7 +1,5 @@ package org.robolectric.shadows; -import static android.os.Build.VERSION_CODES.KITKAT_WATCH; -import static android.os.Build.VERSION_CODES.LOLLIPOP; import static android.os.Build.VERSION_CODES.O; import static android.os.Build.VERSION_CODES.O_MR1; import static android.os.Build.VERSION_CODES.R; @@ -10,7 +8,6 @@ import static android.os.Build.VERSION_CODES.S_V2; import android.database.sqlite.SQLiteConnection; import java.util.function.BinaryOperator; import java.util.function.UnaryOperator; -import org.robolectric.RuntimeEnvironment; import org.robolectric.annotation.Implementation; import org.robolectric.annotation.Implements; import org.robolectric.nativeruntime.DefaultNativeRuntimeLoader; @@ -28,11 +25,7 @@ public class ShadowNativeSQLiteConnection extends ShadowSQLiteConnection { @Implementation(maxSdk = O) protected static Number nativeOpen( String path, int openFlags, String label, boolean enableTrace, boolean enableProfile) { - long result = nativeOpen(path, openFlags, label, enableTrace, enableProfile, 0, 0); - if (RuntimeEnvironment.getApiLevel() < LOLLIPOP) { - return PreLPointers.register(result); - } - return result; + return nativeOpen(path, openFlags, label, enableTrace, enableProfile, 0, 0); } @Implementation(minSdk = O_MR1, maxSdk = U.SDK_INT) @@ -59,24 +52,13 @@ public class ShadowNativeSQLiteConnection extends ShadowSQLiteConnection { lookasideSlotCount)); } - @Implementation(maxSdk = KITKAT_WATCH) - protected static void nativeClose(int connectionPtr) { - nativeClose(PreLPointers.get(connectionPtr)); - } - - @Implementation(minSdk = LOLLIPOP, maxSdk = U.SDK_INT) + @Implementation(maxSdk = U.SDK_INT) protected static void nativeClose(long connectionPtr) { PerfStatsCollector.getInstance() .measure("androidsqlite", () -> SQLiteConnectionNatives.nativeClose(connectionPtr)); } - @Implementation(maxSdk = KITKAT_WATCH) - protected static int nativePrepareStatement(int connectionPtr, String sql) { - long statementPtr = nativePrepareStatement(PreLPointers.get(connectionPtr), sql); - return PreLPointers.register(statementPtr); - } - - @Implementation(minSdk = LOLLIPOP, maxSdk = U.SDK_INT) + @Implementation(maxSdk = U.SDK_INT) protected static long nativePrepareStatement(long connectionPtr, String sql) { return PerfStatsCollector.getInstance() .measure( @@ -84,12 +66,7 @@ public class ShadowNativeSQLiteConnection extends ShadowSQLiteConnection { () -> SQLiteConnectionNatives.nativePrepareStatement(connectionPtr, sql)); } - @Implementation(maxSdk = KITKAT_WATCH) - protected static void nativeFinalizeStatement(int connectionPtr, int statementPtr) { - nativeFinalizeStatement(PreLPointers.get(connectionPtr), PreLPointers.get(statementPtr)); - } - - @Implementation(minSdk = LOLLIPOP, maxSdk = U.SDK_INT) + @Implementation(maxSdk = U.SDK_INT) protected static void nativeFinalizeStatement(long connectionPtr, long statementPtr) { PerfStatsCollector.getInstance() .measure( @@ -97,12 +74,7 @@ public class ShadowNativeSQLiteConnection extends ShadowSQLiteConnection { () -> SQLiteConnectionNatives.nativeFinalizeStatement(connectionPtr, statementPtr)); } - @Implementation(maxSdk = KITKAT_WATCH) - protected static int nativeGetParameterCount(int connectionPtr, int statementPtr) { - return nativeGetParameterCount(PreLPointers.get(connectionPtr), PreLPointers.get(statementPtr)); - } - - @Implementation(minSdk = LOLLIPOP, maxSdk = U.SDK_INT) + @Implementation(maxSdk = U.SDK_INT) protected static int nativeGetParameterCount(final long connectionPtr, final long statementPtr) { return PerfStatsCollector.getInstance() .measure( @@ -110,12 +82,7 @@ public class ShadowNativeSQLiteConnection extends ShadowSQLiteConnection { () -> SQLiteConnectionNatives.nativeGetParameterCount(connectionPtr, statementPtr)); } - @Implementation(maxSdk = KITKAT_WATCH) - protected static boolean nativeIsReadOnly(int connectionPtr, int statementPtr) { - return nativeIsReadOnly(PreLPointers.get(connectionPtr), PreLPointers.get(statementPtr)); - } - - @Implementation(minSdk = LOLLIPOP, maxSdk = U.SDK_INT) + @Implementation(maxSdk = U.SDK_INT) protected static boolean nativeIsReadOnly(final long connectionPtr, final long statementPtr) { return PerfStatsCollector.getInstance() .measure( @@ -123,12 +90,7 @@ public class ShadowNativeSQLiteConnection extends ShadowSQLiteConnection { () -> SQLiteConnectionNatives.nativeIsReadOnly(connectionPtr, statementPtr)); } - @Implementation(maxSdk = KITKAT_WATCH) - protected static String nativeExecuteForString(int connectionPtr, int statementPtr) { - return nativeExecuteForString(PreLPointers.get(connectionPtr), PreLPointers.get(statementPtr)); - } - - @Implementation(minSdk = LOLLIPOP, maxSdk = U.SDK_INT) + @Implementation(maxSdk = U.SDK_INT) protected static String nativeExecuteForString( final long connectionPtr, final long statementPtr) { return PerfStatsCollector.getInstance() @@ -137,12 +99,7 @@ public class ShadowNativeSQLiteConnection extends ShadowSQLiteConnection { () -> SQLiteConnectionNatives.nativeExecuteForString(connectionPtr, statementPtr)); } - @Implementation(maxSdk = KITKAT_WATCH) - protected static void nativeRegisterLocalizedCollators(int connectionPtr, String locale) { - nativeRegisterLocalizedCollators(PreLPointers.get(connectionPtr), locale); - } - - @Implementation(minSdk = LOLLIPOP, maxSdk = U.SDK_INT) + @Implementation(maxSdk = U.SDK_INT) protected static void nativeRegisterLocalizedCollators(long connectionPtr, String locale) { PerfStatsCollector.getInstance() .measure( @@ -150,12 +107,7 @@ public class ShadowNativeSQLiteConnection extends ShadowSQLiteConnection { () -> SQLiteConnectionNatives.nativeRegisterLocalizedCollators(connectionPtr, locale)); } - @Implementation(maxSdk = KITKAT_WATCH) - protected static long nativeExecuteForLong(int connectionPtr, int statementPtr) { - return nativeExecuteForLong(PreLPointers.get(connectionPtr), PreLPointers.get(statementPtr)); - } - - @Implementation(minSdk = LOLLIPOP, maxSdk = U.SDK_INT) + @Implementation(maxSdk = U.SDK_INT) protected static long nativeExecuteForLong(final long connectionPtr, final long statementPtr) { return PerfStatsCollector.getInstance() .measure( @@ -163,12 +115,7 @@ public class ShadowNativeSQLiteConnection extends ShadowSQLiteConnection { () -> SQLiteConnectionNatives.nativeExecuteForLong(connectionPtr, statementPtr)); } - @Implementation(maxSdk = KITKAT_WATCH) - protected static void nativeExecute(int connectionPtr, int statementPtr) { - nativeExecute(PreLPointers.get(connectionPtr), PreLPointers.get(statementPtr)); - } - - @Implementation(minSdk = LOLLIPOP, maxSdk = S_V2) + @Implementation(maxSdk = S_V2) protected static void nativeExecute(final long connectionPtr, final long statementPtr) { PerfStatsCollector.getInstance() .measure( @@ -185,13 +132,7 @@ public class ShadowNativeSQLiteConnection extends ShadowSQLiteConnection { () -> SQLiteConnectionNatives.nativeExecute(connectionPtr, statementPtr, isPragmaStmt)); } - @Implementation(maxSdk = KITKAT_WATCH) - protected static int nativeExecuteForChangedRowCount(int connectionPtr, int statementPtr) { - return nativeExecuteForChangedRowCount( - PreLPointers.get(connectionPtr), PreLPointers.get(statementPtr)); - } - - @Implementation(minSdk = LOLLIPOP, maxSdk = U.SDK_INT) + @Implementation(maxSdk = U.SDK_INT) protected static int nativeExecuteForChangedRowCount( final long connectionPtr, final long statementPtr) { return PerfStatsCollector.getInstance() @@ -202,12 +143,7 @@ public class ShadowNativeSQLiteConnection extends ShadowSQLiteConnection { connectionPtr, statementPtr)); } - @Implementation(maxSdk = KITKAT_WATCH) - protected static int nativeGetColumnCount(int connectionPtr, int statementPtr) { - return nativeGetColumnCount(PreLPointers.get(connectionPtr), PreLPointers.get(statementPtr)); - } - - @Implementation(minSdk = LOLLIPOP, maxSdk = U.SDK_INT) + @Implementation(maxSdk = U.SDK_INT) protected static int nativeGetColumnCount(final long connectionPtr, final long statementPtr) { return PerfStatsCollector.getInstance() .measure( @@ -215,13 +151,7 @@ public class ShadowNativeSQLiteConnection extends ShadowSQLiteConnection { () -> SQLiteConnectionNatives.nativeGetColumnCount(connectionPtr, statementPtr)); } - @Implementation(maxSdk = KITKAT_WATCH) - protected static String nativeGetColumnName(int connectionPtr, int statementPtr, int index) { - return nativeGetColumnName( - PreLPointers.get(connectionPtr), PreLPointers.get(statementPtr), index); - } - - @Implementation(minSdk = LOLLIPOP, maxSdk = U.SDK_INT) + @Implementation(maxSdk = U.SDK_INT) protected static String nativeGetColumnName( final long connectionPtr, final long statementPtr, final int index) { return PerfStatsCollector.getInstance() @@ -230,12 +160,7 @@ public class ShadowNativeSQLiteConnection extends ShadowSQLiteConnection { () -> SQLiteConnectionNatives.nativeGetColumnName(connectionPtr, statementPtr, index)); } - @Implementation(maxSdk = KITKAT_WATCH) - protected static void nativeBindNull(int connectionPtr, int statementPtr, int index) { - nativeBindNull(PreLPointers.get(connectionPtr), PreLPointers.get(statementPtr), index); - } - - @Implementation(minSdk = LOLLIPOP, maxSdk = U.SDK_INT) + @Implementation(maxSdk = U.SDK_INT) protected static void nativeBindNull( final long connectionPtr, final long statementPtr, final int index) { PerfStatsCollector.getInstance() @@ -244,12 +169,7 @@ public class ShadowNativeSQLiteConnection extends ShadowSQLiteConnection { () -> SQLiteConnectionNatives.nativeBindNull(connectionPtr, statementPtr, index)); } - @Implementation(maxSdk = KITKAT_WATCH) - protected static void nativeBindLong(int connectionPtr, int statementPtr, int index, long value) { - nativeBindLong(PreLPointers.get(connectionPtr), PreLPointers.get(statementPtr), index, value); - } - - @Implementation(minSdk = LOLLIPOP, maxSdk = U.SDK_INT) + @Implementation(maxSdk = U.SDK_INT) protected static void nativeBindLong( final long connectionPtr, final long statementPtr, final int index, final long value) { PerfStatsCollector.getInstance() @@ -259,13 +179,7 @@ public class ShadowNativeSQLiteConnection extends ShadowSQLiteConnection { SQLiteConnectionNatives.nativeBindLong(connectionPtr, statementPtr, index, value)); } - @Implementation(maxSdk = KITKAT_WATCH) - protected static void nativeBindDouble( - int connectionPtr, int statementPtr, int index, double value) { - nativeBindDouble(PreLPointers.get(connectionPtr), PreLPointers.get(statementPtr), index, value); - } - - @Implementation(minSdk = LOLLIPOP, maxSdk = U.SDK_INT) + @Implementation(maxSdk = U.SDK_INT) protected static void nativeBindDouble( final long connectionPtr, final long statementPtr, final int index, final double value) { PerfStatsCollector.getInstance() @@ -276,13 +190,7 @@ public class ShadowNativeSQLiteConnection extends ShadowSQLiteConnection { connectionPtr, statementPtr, index, value)); } - @Implementation(maxSdk = KITKAT_WATCH) - protected static void nativeBindString( - int connectionPtr, int statementPtr, int index, String value) { - nativeBindString(PreLPointers.get(connectionPtr), PreLPointers.get(statementPtr), index, value); - } - - @Implementation(minSdk = LOLLIPOP, maxSdk = U.SDK_INT) + @Implementation(maxSdk = U.SDK_INT) protected static void nativeBindString( final long connectionPtr, final long statementPtr, final int index, final String value) { PerfStatsCollector.getInstance() @@ -293,13 +201,7 @@ public class ShadowNativeSQLiteConnection extends ShadowSQLiteConnection { connectionPtr, statementPtr, index, value)); } - @Implementation(maxSdk = KITKAT_WATCH) - protected static void nativeBindBlob( - int connectionPtr, int statementPtr, int index, byte[] value) { - nativeBindBlob(PreLPointers.get(connectionPtr), PreLPointers.get(statementPtr), index, value); - } - - @Implementation(minSdk = LOLLIPOP, maxSdk = U.SDK_INT) + @Implementation(maxSdk = U.SDK_INT) protected static void nativeBindBlob( final long connectionPtr, final long statementPtr, final int index, final byte[] value) { PerfStatsCollector.getInstance() @@ -309,13 +211,7 @@ public class ShadowNativeSQLiteConnection extends ShadowSQLiteConnection { SQLiteConnectionNatives.nativeBindBlob(connectionPtr, statementPtr, index, value)); } - @Implementation(maxSdk = KITKAT_WATCH) - protected static void nativeResetStatementAndClearBindings(int connectionPtr, int statementPtr) { - nativeResetStatementAndClearBindings( - PreLPointers.get(connectionPtr), PreLPointers.get(statementPtr)); - } - - @Implementation(minSdk = LOLLIPOP, maxSdk = U.SDK_INT) + @Implementation(maxSdk = U.SDK_INT) protected static void nativeResetStatementAndClearBindings( final long connectionPtr, final long statementPtr) { PerfStatsCollector.getInstance() @@ -326,13 +222,7 @@ public class ShadowNativeSQLiteConnection extends ShadowSQLiteConnection { connectionPtr, statementPtr)); } - @Implementation(maxSdk = KITKAT_WATCH) - protected static long nativeExecuteForLastInsertedRowId(int connectionPtr, int statementPtr) { - return nativeExecuteForLastInsertedRowId( - PreLPointers.get(connectionPtr), PreLPointers.get(statementPtr)); - } - - @Implementation(minSdk = LOLLIPOP, maxSdk = U.SDK_INT) + @Implementation(maxSdk = U.SDK_INT) protected static long nativeExecuteForLastInsertedRowId( final long connectionPtr, final long statementPtr) { return PerfStatsCollector.getInstance() @@ -343,24 +233,7 @@ public class ShadowNativeSQLiteConnection extends ShadowSQLiteConnection { connectionPtr, statementPtr)); } - @Implementation(maxSdk = KITKAT_WATCH) - protected static long nativeExecuteForCursorWindow( - int connectionPtr, - int statementPtr, - int windowPtr, - int startPos, - int requiredPos, - boolean countAllRows) { - return nativeExecuteForCursorWindow( - PreLPointers.get(connectionPtr), - PreLPointers.get(statementPtr), - PreLPointers.get(windowPtr), - startPos, - requiredPos, - countAllRows); - } - - @Implementation(minSdk = LOLLIPOP, maxSdk = U.SDK_INT) + @Implementation(maxSdk = U.SDK_INT) protected static long nativeExecuteForCursorWindow( final long connectionPtr, final long statementPtr, @@ -376,13 +249,7 @@ public class ShadowNativeSQLiteConnection extends ShadowSQLiteConnection { connectionPtr, statementPtr, windowPtr, startPos, requiredPos, countAllRows)); } - @Implementation(maxSdk = KITKAT_WATCH) - protected static int nativeExecuteForBlobFileDescriptor(int connectionPtr, int statementPtr) { - return nativeExecuteForBlobFileDescriptor( - PreLPointers.get(connectionPtr), PreLPointers.get(statementPtr)); - } - - @Implementation(minSdk = LOLLIPOP, maxSdk = U.SDK_INT) + @Implementation(maxSdk = U.SDK_INT) protected static int nativeExecuteForBlobFileDescriptor( final long connectionPtr, final long statementPtr) { return PerfStatsCollector.getInstance() @@ -393,23 +260,13 @@ public class ShadowNativeSQLiteConnection extends ShadowSQLiteConnection { connectionPtr, statementPtr)); } - @Implementation(maxSdk = KITKAT_WATCH) - protected static void nativeCancel(int connectionPtr) { - nativeCancel(PreLPointers.get(connectionPtr)); - } - - @Implementation(minSdk = LOLLIPOP, maxSdk = U.SDK_INT) + @Implementation(maxSdk = U.SDK_INT) protected static void nativeCancel(long connectionPtr) { PerfStatsCollector.getInstance() .measure("androidsqlite", () -> SQLiteConnectionNatives.nativeCancel(connectionPtr)); } - @Implementation(maxSdk = KITKAT_WATCH) - protected static void nativeResetCancel(int connectionPtr, boolean cancelable) { - nativeResetCancel(PreLPointers.get(connectionPtr), cancelable); - } - - @Implementation(minSdk = LOLLIPOP, maxSdk = U.SDK_INT) + @Implementation(maxSdk = U.SDK_INT) protected static void nativeResetCancel(long connectionPtr, boolean cancelable) { PerfStatsCollector.getInstance() .measure( @@ -441,12 +298,7 @@ public class ShadowNativeSQLiteConnection extends ShadowSQLiteConnection { connectionPtr, name, function)); } - @Implementation(maxSdk = KITKAT_WATCH) - protected static int nativeGetDbLookaside(int connectionPtr) { - return nativeGetDbLookaside(PreLPointers.get(connectionPtr)); - } - - @Implementation(minSdk = LOLLIPOP, maxSdk = U.SDK_INT) + @Implementation(maxSdk = U.SDK_INT) protected static int nativeGetDbLookaside(long connectionPtr) { return PerfStatsCollector.getInstance() .measure( diff --git a/shadows/framework/src/main/java/org/robolectric/shadows/ShadowNativeTypeface.java b/shadows/framework/src/main/java/org/robolectric/shadows/ShadowNativeTypeface.java index 897ea85d8..60475e0f0 100644 --- a/shadows/framework/src/main/java/org/robolectric/shadows/ShadowNativeTypeface.java +++ b/shadows/framework/src/main/java/org/robolectric/shadows/ShadowNativeTypeface.java @@ -1,6 +1,5 @@ package org.robolectric.shadows; -import static android.os.Build.VERSION_CODES.LOLLIPOP; import static android.os.Build.VERSION_CODES.O; import static android.os.Build.VERSION_CODES.O_MR1; import static android.os.Build.VERSION_CODES.P; @@ -137,7 +136,7 @@ public class ShadowNativeTypeface extends ShadowTypeface { return fontFamily; } - @Implementation(minSdk = LOLLIPOP, maxSdk = U.SDK_INT) + @Implementation(maxSdk = U.SDK_INT) protected static long nativeCreateFromTypeface(long nativeInstance, int style) { return TypefaceNatives.nativeCreateFromTypeface(nativeInstance, style); } @@ -154,7 +153,7 @@ public class ShadowNativeTypeface extends ShadowTypeface { return TypefaceNatives.nativeCreateFromTypefaceWithVariation(nativeInstance, axes); } - @Implementation(minSdk = LOLLIPOP, maxSdk = U.SDK_INT) + @Implementation(maxSdk = U.SDK_INT) protected static long nativeCreateWeightAlias(long nativeInstance, int weight) { return TypefaceNatives.nativeCreateWeightAlias(nativeInstance, weight); } @@ -175,12 +174,12 @@ public class ShadowNativeTypeface extends ShadowTypeface { return TypefaceNatives.nativeGetSupportedAxes(nativeInstance); } - @Implementation(minSdk = LOLLIPOP, maxSdk = U.SDK_INT) + @Implementation(maxSdk = U.SDK_INT) protected static void nativeSetDefault(long nativePtr) { TypefaceNatives.nativeSetDefault(nativePtr); } - @Implementation(minSdk = LOLLIPOP, maxSdk = U.SDK_INT) + @Implementation(maxSdk = U.SDK_INT) protected static int nativeGetStyle(long nativePtr) { return TypefaceNatives.nativeGetStyle(nativePtr); } diff --git a/shadows/framework/src/main/java/org/robolectric/shadows/ShadowPackageInstaller.java b/shadows/framework/src/main/java/org/robolectric/shadows/ShadowPackageInstaller.java index d662e2328..247ac2111 100644 --- a/shadows/framework/src/main/java/org/robolectric/shadows/ShadowPackageInstaller.java +++ b/shadows/framework/src/main/java/org/robolectric/shadows/ShadowPackageInstaller.java @@ -1,6 +1,5 @@ package org.robolectric.shadows; -import static android.os.Build.VERSION_CODES.KITKAT_WATCH; import static android.os.Build.VERSION_CODES.LOLLIPOP; import static android.os.Build.VERSION_CODES.O; import static android.os.Build.VERSION_CODES.P; @@ -210,7 +209,7 @@ public class ShadowPackageInstaller { } } - @Implementation(minSdk = LOLLIPOP) + @Implementation protected void uninstall(String packageName, IntentSender statusReceiver) { uninstalledPackages.put( packageName, @@ -340,8 +339,6 @@ public class ShadowPackageInstaller { private ShadowPackageInstaller shadowPackageInstaller; private PersistableBundle appMetadata = new PersistableBundle(); - @Implementation(maxSdk = KITKAT_WATCH) - protected void __constructor__() {} @Implementation(minSdk = UPSIDE_DOWN_CAKE) protected void requestUserPreapproval( diff --git a/shadows/framework/src/main/java/org/robolectric/shadows/ShadowPaint.java b/shadows/framework/src/main/java/org/robolectric/shadows/ShadowPaint.java index 8a3eaee0f..a23985865 100644 --- a/shadows/framework/src/main/java/org/robolectric/shadows/ShadowPaint.java +++ b/shadows/framework/src/main/java/org/robolectric/shadows/ShadowPaint.java @@ -1,10 +1,6 @@ package org.robolectric.shadows; -import static android.os.Build.VERSION_CODES.JELLY_BEAN_MR1; -import static android.os.Build.VERSION_CODES.KITKAT; -import static android.os.Build.VERSION_CODES.KITKAT_WATCH; import static android.os.Build.VERSION_CODES.L; -import static android.os.Build.VERSION_CODES.LOLLIPOP; import static android.os.Build.VERSION_CODES.LOLLIPOP_MR1; import static android.os.Build.VERSION_CODES.M; import static android.os.Build.VERSION_CODES.N; @@ -389,19 +385,7 @@ public class ShadowPaint { return Math.max(0f, textScaleX) * textWidth; } - @Implementation(maxSdk = JELLY_BEAN_MR1) - protected int native_breakText( - char[] text, int index, int count, float maxWidth, float[] measuredWidth) { - return breakText(text, maxWidth, measuredWidth); - } - - @Implementation(maxSdk = KITKAT_WATCH) - protected int native_breakText( - char[] text, int index, int count, float maxWidth, int bidiFlags, float[] measuredWidth) { - return breakText(text, maxWidth, measuredWidth); - } - - @Implementation(minSdk = LOLLIPOP, maxSdk = M) + @Implementation(maxSdk = M) protected static int native_breakText( long native_object, long native_typeface, @@ -446,19 +430,7 @@ public class ShadowPaint { return text.length; } - @Implementation(maxSdk = JELLY_BEAN_MR1) - protected int native_breakText( - String text, boolean measureForwards, float maxWidth, float[] measuredWidth) { - return breakText(text, maxWidth, measuredWidth); - } - - @Implementation(maxSdk = KITKAT_WATCH) - protected int native_breakText( - String text, boolean measureForwards, float maxWidth, int bidiFlags, float[] measuredWidth) { - return breakText(text, maxWidth, measuredWidth); - } - - @Implementation(minSdk = LOLLIPOP, maxSdk = M) + @Implementation(maxSdk = M) protected static int native_breakText( long native_object, long native_typeface, @@ -630,7 +602,7 @@ public class ShadowPaint { return nGetRunAdvance(0, text, start, end, contextStart, contextEnd, isRtl, offset); } - @Implementation(minSdk = KITKAT_WATCH, maxSdk = LOLLIPOP_MR1) + @Implementation(maxSdk = LOLLIPOP_MR1) protected static float native_getTextRunAdvances( long nativeObject, long nativeTypeface, @@ -646,7 +618,7 @@ public class ShadowPaint { 0, text, index, index + count, contextIndex, contextIndex + contextCount, isRtl, index); } - @Implementation(minSdk = KITKAT_WATCH, maxSdk = LOLLIPOP_MR1) + @Implementation(maxSdk = LOLLIPOP_MR1) protected static float native_getTextRunAdvances( long nativeObject, long nativeTypeface, @@ -660,64 +632,4 @@ public class ShadowPaint { int advancesIndex) { return nGetRunAdvance(0, text.toCharArray(), start, end, contextStart, contextEnd, isRtl, 0); } - - @Implementation(maxSdk = KITKAT) - protected static float native_getTextRunAdvances( - int nativeObject, - char[] text, - int index, - int count, - int contextIndex, - int contextCount, - int flags, - float[] advances, - int advancesIndex) { - return nGetRunAdvance( - 0, text, index, index + count, contextIndex, contextIndex + contextCount, false, index); - } - - @Implementation(maxSdk = KITKAT) - protected static float native_getTextRunAdvances( - int nativeObject, - String text, - int start, - int end, - int contextStart, - int contextEnd, - int flags, - float[] advances, - int advancesIndex) { - return nGetRunAdvance(0, text.toCharArray(), start, end, contextStart, contextEnd, false, 0); - } - - @Implementation(maxSdk = JELLY_BEAN_MR1) - protected static float native_getTextRunAdvances( - int nativeObject, - char[] text, - int index, - int count, - int contextIndex, - int contextCount, - int flags, - float[] advances, - int advancesIndex, - int reserved) { - return nGetRunAdvance( - 0, text, index, index + count, contextIndex, contextIndex + contextCount, false, index); - } - - @Implementation(maxSdk = JELLY_BEAN_MR1) - protected static float native_getTextRunAdvances( - int nativeObject, - String text, - int start, - int end, - int contextStart, - int contextEnd, - int flags, - float[] advances, - int advancesIndex, - int reserved) { - return nGetRunAdvance(0, text.toCharArray(), start, end, contextStart, contextEnd, false, 0); - } } diff --git a/shadows/framework/src/main/java/org/robolectric/shadows/ShadowParcel.java b/shadows/framework/src/main/java/org/robolectric/shadows/ShadowParcel.java index a27e5038e..79ef89737 100644 --- a/shadows/framework/src/main/java/org/robolectric/shadows/ShadowParcel.java +++ b/shadows/framework/src/main/java/org/robolectric/shadows/ShadowParcel.java @@ -1,8 +1,7 @@ package org.robolectric.shadows; -import static android.os.Build.VERSION_CODES.JELLY_BEAN_MR1; -import static android.os.Build.VERSION_CODES.KITKAT_WATCH; -import static android.os.Build.VERSION_CODES.LOLLIPOP; + + import static android.os.Build.VERSION_CODES.M; import static android.os.Build.VERSION_CODES.O_MR1; import static android.os.Build.VERSION_CODES.P; @@ -64,22 +63,7 @@ public class ShadowParcel { private static final HashMap<ClassLoader, HashMap<String, Pair<Creator<?>, Class<?>>>> pairedCreators = new HashMap<>(); - @Implementation(maxSdk = JELLY_BEAN_MR1) - @SuppressWarnings("TypeParameterUnusedInFormals") - protected <T extends Parcelable> T readParcelable(ClassLoader loader) { - // prior to JB MR2, readParcelableCreator() is inlined here. - Parcelable.Creator<?> creator = readParcelableCreator(loader); - if (creator == null) { - return null; - } - if (creator instanceof Parcelable.ClassLoaderCreator<?>) { - Parcelable.ClassLoaderCreator<?> classLoaderCreator = - (Parcelable.ClassLoaderCreator<?>) creator; - return (T) classLoaderCreator.createFromParcel(realObject, loader); - } - return (T) creator.createFromParcel(realObject); - } @HiddenApi @Implementation @@ -290,91 +274,43 @@ public class ShadowParcel { nativeWriteByteArray(nativePtr.longValue(), b, offset, len); } - @HiddenApi - @Implementation(maxSdk = KITKAT_WATCH) - public static int nativeDataSize(int nativePtr) { - return nativeDataSize((long) nativePtr); - } - - @Implementation(minSdk = LOLLIPOP) + @Implementation protected static int nativeDataSize(long nativePtr) { return NATIVE_BYTE_BUFFER_REGISTRY.getNativeObject(nativePtr).dataSize(); } - @HiddenApi - @Implementation(maxSdk = KITKAT_WATCH) - public static int nativeDataAvail(int nativePtr) { - return nativeDataAvail((long) nativePtr); - } - - @Implementation(minSdk = LOLLIPOP) + @Implementation protected static int nativeDataAvail(long nativePtr) { return NATIVE_BYTE_BUFFER_REGISTRY.getNativeObject(nativePtr).dataAvailable(); } - @HiddenApi - @Implementation(maxSdk = KITKAT_WATCH) - public static int nativeDataPosition(int nativePtr) { - return nativeDataPosition((long) nativePtr); - } - - @Implementation(minSdk = LOLLIPOP) + @Implementation protected static int nativeDataPosition(long nativePtr) { return NATIVE_BYTE_BUFFER_REGISTRY.getNativeObject(nativePtr).dataPosition(); } - @HiddenApi - @Implementation(maxSdk = KITKAT_WATCH) - public static int nativeDataCapacity(int nativePtr) { - return nativeDataCapacity((long) nativePtr); - } - - @Implementation(minSdk = LOLLIPOP) + @Implementation protected static int nativeDataCapacity(long nativePtr) { return NATIVE_BYTE_BUFFER_REGISTRY.getNativeObject(nativePtr).dataCapacity(); } - @HiddenApi - @Implementation(maxSdk = KITKAT_WATCH) - public static void nativeSetDataSize(int nativePtr, int size) { - nativeSetDataSize((long) nativePtr, size); - } - - @Implementation(minSdk = LOLLIPOP) + @Implementation @SuppressWarnings("robolectric.ShadowReturnTypeMismatch") protected static void nativeSetDataSize(long nativePtr, int size) { NATIVE_BYTE_BUFFER_REGISTRY.getNativeObject(nativePtr).setDataSize(size); } - @HiddenApi - @Implementation(maxSdk = KITKAT_WATCH) - public static void nativeSetDataPosition(int nativePtr, int pos) { - nativeSetDataPosition((long) nativePtr, pos); - } - - @Implementation(minSdk = LOLLIPOP) + @Implementation protected static void nativeSetDataPosition(long nativePtr, int pos) { NATIVE_BYTE_BUFFER_REGISTRY.getNativeObject(nativePtr).setDataPosition(pos); } - @HiddenApi - @Implementation(maxSdk = KITKAT_WATCH) - public static void nativeSetDataCapacity(int nativePtr, int size) { - nativeSetDataCapacity((long) nativePtr, size); - } - - @Implementation(minSdk = LOLLIPOP) + @Implementation protected static void nativeSetDataCapacity(long nativePtr, int size) { NATIVE_BYTE_BUFFER_REGISTRY.getNativeObject(nativePtr).setDataCapacityAtLeast(size); } - @HiddenApi - @Implementation(maxSdk = KITKAT_WATCH) - public static void nativeWriteByteArray(int nativePtr, byte[] b, int offset, int len) { - nativeWriteByteArray((long) nativePtr, b, offset, len); - } - - @Implementation(minSdk = LOLLIPOP) + @Implementation protected static void nativeWriteByteArray(long nativePtr, byte[] b, int offset, int len) { NATIVE_BYTE_BUFFER_REGISTRY.getNativeObject(nativePtr).writeByteArray(b, offset, len); } @@ -403,90 +339,48 @@ public class ShadowParcel { } // nativeWriteBlob was introduced in lollipop, thus no need for a int nativePtr variant - @Implementation(minSdk = LOLLIPOP) + @Implementation protected static void nativeWriteBlob(long nativePtr, byte[] b, int offset, int len) { nativeWriteByteArray(nativePtr, b, offset, len); } - @HiddenApi - @Implementation(maxSdk = KITKAT_WATCH) - public static void nativeWriteInt(int nativePtr, int val) { - nativeWriteInt((long) nativePtr, val); - } - - @Implementation(minSdk = LOLLIPOP, maxSdk = R) + @Implementation(maxSdk = R) protected static void nativeWriteInt(long nativePtr, int val) { NATIVE_BYTE_BUFFER_REGISTRY.getNativeObject(nativePtr).writeInt(val); } - @HiddenApi - @Implementation(maxSdk = KITKAT_WATCH) - public static void nativeWriteLong(int nativePtr, long val) { - nativeWriteLong((long) nativePtr, val); - } - - @Implementation(minSdk = LOLLIPOP, maxSdk = R) + @Implementation(maxSdk = R) protected static void nativeWriteLong(long nativePtr, long val) { NATIVE_BYTE_BUFFER_REGISTRY.getNativeObject(nativePtr).writeLong(val); } - @HiddenApi - @Implementation(maxSdk = KITKAT_WATCH) - public static void nativeWriteFloat(int nativePtr, float val) { - nativeWriteFloat((long) nativePtr, val); - } - - @Implementation(minSdk = LOLLIPOP, maxSdk = R) + @Implementation(maxSdk = R) protected static void nativeWriteFloat(long nativePtr, float val) { NATIVE_BYTE_BUFFER_REGISTRY.getNativeObject(nativePtr).writeFloat(val); } - @HiddenApi - @Implementation(maxSdk = KITKAT_WATCH) - public static void nativeWriteDouble(int nativePtr, double val) { - nativeWriteDouble((long) nativePtr, val); - } - - @Implementation(minSdk = LOLLIPOP, maxSdk = R) + @Implementation(maxSdk = R) protected static void nativeWriteDouble(long nativePtr, double val) { NATIVE_BYTE_BUFFER_REGISTRY.getNativeObject(nativePtr).writeDouble(val); } - @HiddenApi - @Implementation(maxSdk = KITKAT_WATCH) - public static void nativeWriteString(int nativePtr, String val) { - nativeWriteString((long) nativePtr, val); - } - - @Implementation(minSdk = LOLLIPOP, maxSdk = Q) + @Implementation(maxSdk = Q) protected static void nativeWriteString(long nativePtr, String val) { NATIVE_BYTE_BUFFER_REGISTRY.getNativeObject(nativePtr).writeString(val); } - @HiddenApi - @Implementation(maxSdk = KITKAT_WATCH) - protected static void nativeWriteStrongBinder(int nativePtr, IBinder val) { - nativeWriteStrongBinder((long) nativePtr, val); - } - - @Implementation(minSdk = LOLLIPOP) + @Implementation protected static void nativeWriteStrongBinder(long nativePtr, IBinder val) { NATIVE_BYTE_BUFFER_REGISTRY.getNativeObject(nativePtr).writeStrongBinder(val); } - @HiddenApi - @Implementation(maxSdk = KITKAT_WATCH) - public static byte[] nativeCreateByteArray(int nativePtr) { - return nativeCreateByteArray((long) nativePtr); - } - - @Implementation(minSdk = LOLLIPOP) + @Implementation protected static byte[] nativeCreateByteArray(long nativePtr) { return NATIVE_BYTE_BUFFER_REGISTRY.getNativeObject(nativePtr).createByteArray(); } // nativeReadBlob was introduced in lollipop, thus no need for a int nativePtr variant - @Implementation(minSdk = LOLLIPOP) + @Implementation protected static byte[] nativeReadBlob(long nativePtr) { return nativeCreateByteArray(nativePtr); } @@ -496,68 +390,32 @@ public class ShadowParcel { return NATIVE_BYTE_BUFFER_REGISTRY.getNativeObject(nativePtr).readByteArray(dest, destLen); } - @HiddenApi - @Implementation(maxSdk = KITKAT_WATCH) - public static int nativeReadInt(int nativePtr) { - return nativeReadInt((long) nativePtr); - } - - @Implementation(minSdk = LOLLIPOP) + @Implementation protected static int nativeReadInt(long nativePtr) { return NATIVE_BYTE_BUFFER_REGISTRY.getNativeObject(nativePtr).readInt(); } - @HiddenApi - @Implementation(maxSdk = KITKAT_WATCH) - public static long nativeReadLong(int nativePtr) { - return nativeReadLong((long) nativePtr); - } - - @Implementation(minSdk = LOLLIPOP) + @Implementation protected static long nativeReadLong(long nativePtr) { return NATIVE_BYTE_BUFFER_REGISTRY.getNativeObject(nativePtr).readLong(); } - @HiddenApi - @Implementation(maxSdk = KITKAT_WATCH) - public static float nativeReadFloat(int nativePtr) { - return nativeReadFloat((long) nativePtr); - } - - @Implementation(minSdk = LOLLIPOP) + @Implementation protected static float nativeReadFloat(long nativePtr) { return NATIVE_BYTE_BUFFER_REGISTRY.getNativeObject(nativePtr).readFloat(); } - @HiddenApi - @Implementation(maxSdk = KITKAT_WATCH) - public static double nativeReadDouble(int nativePtr) { - return nativeReadDouble((long) nativePtr); - } - - @Implementation(minSdk = LOLLIPOP) + @Implementation protected static double nativeReadDouble(long nativePtr) { return NATIVE_BYTE_BUFFER_REGISTRY.getNativeObject(nativePtr).readDouble(); } - @HiddenApi - @Implementation(maxSdk = KITKAT_WATCH) - public static String nativeReadString(int nativePtr) { - return nativeReadString((long) nativePtr); - } - - @Implementation(minSdk = LOLLIPOP, maxSdk = Q) + @Implementation(maxSdk = Q) protected static String nativeReadString(long nativePtr) { return NATIVE_BYTE_BUFFER_REGISTRY.getNativeObject(nativePtr).readString(); } - @HiddenApi - @Implementation(maxSdk = KITKAT_WATCH) - protected static IBinder nativeReadStrongBinder(int nativePtr) { - return nativeReadStrongBinder((long) nativePtr); - } - - @Implementation(minSdk = LOLLIPOP) + @Implementation protected static IBinder nativeReadStrongBinder(long nativePtr) { return NATIVE_BYTE_BUFFER_REGISTRY.getNativeObject(nativePtr).readStrongBinder(); } @@ -568,60 +426,29 @@ public class ShadowParcel { return castNativePtr(NATIVE_BYTE_BUFFER_REGISTRY.register(new ByteBuffer())); } - @HiddenApi - @Implementation(maxSdk = KITKAT_WATCH) - public static void nativeFreeBuffer(int nativePtr) { - nativeFreeBuffer((long) nativePtr); - } - - @Implementation(minSdk = LOLLIPOP) + @Implementation @SuppressWarnings("robolectric.ShadowReturnTypeMismatch") protected static void nativeFreeBuffer(long nativePtr) { NATIVE_BYTE_BUFFER_REGISTRY.getNativeObject(nativePtr).clear(); } - @HiddenApi - @Implementation(maxSdk = KITKAT_WATCH) - public static void nativeDestroy(int nativePtr) { - nativeDestroy((long) nativePtr); - } - - @Implementation(minSdk = LOLLIPOP) + @Implementation protected static void nativeDestroy(long nativePtr) { NATIVE_BYTE_BUFFER_REGISTRY.unregister(nativePtr); } - @HiddenApi - @Implementation(maxSdk = KITKAT_WATCH) - public static byte[] nativeMarshall(int nativePtr) { - return nativeMarshall((long) nativePtr); - } - - @Implementation(minSdk = LOLLIPOP) + @Implementation protected static byte[] nativeMarshall(long nativePtr) { return NATIVE_BYTE_BUFFER_REGISTRY.getNativeObject(nativePtr).toByteArray(); } - @HiddenApi - @Implementation(maxSdk = KITKAT_WATCH) - public static void nativeUnmarshall(int nativePtr, byte[] data, int offset, int length) { - nativeUnmarshall((long) nativePtr, data, offset, length); - } - - @Implementation(minSdk = LOLLIPOP) + @Implementation @SuppressWarnings("robolectric.ShadowReturnTypeMismatch") protected static void nativeUnmarshall(long nativePtr, byte[] data, int offset, int length) { NATIVE_BYTE_BUFFER_REGISTRY.update(nativePtr, ByteBuffer.fromByteArray(data, offset, length)); } - @HiddenApi - @Implementation(maxSdk = KITKAT_WATCH) - public static void nativeAppendFrom( - int thisNativePtr, int otherNativePtr, int offset, int length) { - nativeAppendFrom((long) thisNativePtr, otherNativePtr, offset, length); - } - - @Implementation(minSdk = LOLLIPOP) + @Implementation @SuppressWarnings("robolectric.ShadowReturnTypeMismatch") protected static void nativeAppendFrom( long thisNativePtr, long otherNativePtr, int offset, int length) { @@ -630,26 +457,14 @@ public class ShadowParcel { thisByteBuffer.appendFrom(otherByteBuffer, offset, length); } - @HiddenApi - @Implementation(maxSdk = KITKAT_WATCH) - public static void nativeWriteInterfaceToken(int nativePtr, String interfaceName) { - nativeWriteInterfaceToken((long) nativePtr, interfaceName); - } - - @Implementation(minSdk = LOLLIPOP) + @Implementation protected static void nativeWriteInterfaceToken(long nativePtr, String interfaceName) { // Write StrictMode.ThreadPolicy bits (assume 0 for test). nativeWriteInt(nativePtr, 0); nativeWriteString(nativePtr, interfaceName); } - @HiddenApi - @Implementation(maxSdk = KITKAT_WATCH) - public static void nativeEnforceInterface(int nativePtr, String interfaceName) { - nativeEnforceInterface((long) nativePtr, interfaceName); - } - - @Implementation(minSdk = LOLLIPOP) + @Implementation protected static void nativeEnforceInterface(long nativePtr, String interfaceName) { // Consume StrictMode.ThreadPolicy bits (don't bother setting in test). nativeReadInt(nativePtr); diff --git a/shadows/framework/src/main/java/org/robolectric/shadows/ShadowPausedMessage.java b/shadows/framework/src/main/java/org/robolectric/shadows/ShadowPausedMessage.java index 100cc4364..a23cae497 100644 --- a/shadows/framework/src/main/java/org/robolectric/shadows/ShadowPausedMessage.java +++ b/shadows/framework/src/main/java/org/robolectric/shadows/ShadowPausedMessage.java @@ -32,7 +32,7 @@ public class ShadowPausedMessage extends ShadowMessage { // TODO: Reconsider this being exposed as a public method @Override - @Implementation(minSdk = LOLLIPOP) + @Implementation public void recycleUnchecked() { if (RuntimeEnvironment.getApiLevel() >= LOLLIPOP) { reflector(MessageReflector.class, realMessage).recycleUnchecked(); diff --git a/shadows/framework/src/main/java/org/robolectric/shadows/ShadowPausedMessageQueue.java b/shadows/framework/src/main/java/org/robolectric/shadows/ShadowPausedMessageQueue.java index 8af76ac18..3dd0587c3 100644 --- a/shadows/framework/src/main/java/org/robolectric/shadows/ShadowPausedMessageQueue.java +++ b/shadows/framework/src/main/java/org/robolectric/shadows/ShadowPausedMessageQueue.java @@ -1,8 +1,6 @@ package org.robolectric.shadows; import static android.os.Build.VERSION_CODES.JELLY_BEAN_MR1; -import static android.os.Build.VERSION_CODES.KITKAT; -import static android.os.Build.VERSION_CODES.KITKAT_WATCH; import static android.os.Build.VERSION_CODES.LOLLIPOP_MR1; import static android.os.Build.VERSION_CODES.M; import static com.google.common.base.Preconditions.checkState; @@ -55,7 +53,7 @@ public class ShadowPausedMessageQueue extends ShadowMessageQueue { @Implementation protected void __constructor__(boolean quitAllowed) { invokeConstructor(MessageQueue.class, realQueue, from(boolean.class, quitAllowed)); - int ptr = (int) nativeQueueRegistry.register(this); + long ptr = nativeQueueRegistry.register(this); reflector(MessageQueueReflector.class, realQueue).setPtr(ptr); clockListener = () -> { @@ -70,27 +68,12 @@ public class ShadowPausedMessageQueue extends ShadowMessageQueue { ShadowPausedSystemClock.addStaticListener(clockListener); } - @Implementation(maxSdk = JELLY_BEAN_MR1) - protected void nativeDestroy() { - nativeDestroy(reflector(MessageQueueReflector.class, realQueue).getPtr()); - } - - @Implementation(maxSdk = KITKAT) - protected static void nativeDestroy(int ptr) { - nativeDestroy((long) ptr); - } - - @Implementation(minSdk = KITKAT_WATCH) + @Implementation protected static void nativeDestroy(long ptr) { ShadowPausedMessageQueue q = nativeQueueRegistry.unregister(ptr); ShadowPausedSystemClock.removeListener(q.clockListener); } - @Implementation(maxSdk = JELLY_BEAN_MR1) - protected void nativePollOnce(int ptr, int timeoutMillis) { - nativePollOnce((long) ptr, timeoutMillis); - } - // use the generic Object parameter types here, to avoid conflicts with the non-static // nativePollOnce @Implementation(maxSdk = LOLLIPOP_MR1) @@ -153,32 +136,14 @@ public class ShadowPausedMessageQueue extends ShadowMessageQueue { } } - @Implementation(maxSdk = JELLY_BEAN_MR1) - protected void nativeWake(int ptr) { + @Implementation + protected static void nativeWake(long ptr) { + MessageQueue realQueue = nativeQueueRegistry.getNativeObject(ptr).realQueue; synchronized (realQueue) { realQueue.notifyAll(); } } - // use the generic Object parameter types here, to avoid conflicts with the non-static - // nativeWake - @Implementation(maxSdk = KITKAT) - protected static void nativeWake(Object ptr) { - // JELLY_BEAN_MR2 has a bug where nativeWake can get called when pointer has already been - // destroyed. See here where nativeWake is called outside the synchronized block - // https://android.googlesource.com/platform/frameworks/base/+/refs/heads/jb-mr2-release/core/java/android/os/MessageQueue.java#239 - // So check to see if native object exists first - ShadowPausedMessageQueue q = nativeQueueRegistry.peekNativeObject(getLong(ptr)); - if (q != null) { - q.nativeWake(getInt(ptr)); - } - } - - @Implementation(minSdk = KITKAT_WATCH) - protected static void nativeWake(long ptr) { - nativeQueueRegistry.getNativeObject(ptr).nativeWake((int) ptr); - } - @Implementation(minSdk = M) protected static boolean nativeIsPolling(long ptr) { return nativeQueueRegistry.getNativeObject(ptr).isPolling; @@ -494,7 +459,7 @@ public class ShadowPausedMessageQueue extends ShadowMessageQueue { boolean getQuitAllowed(); @Accessor("mPtr") - void setPtr(int ptr); + void setPtr(long ptr); @Accessor("mPtr") int getPtr(); diff --git a/shadows/framework/src/main/java/org/robolectric/shadows/ShadowPicture.java b/shadows/framework/src/main/java/org/robolectric/shadows/ShadowPicture.java index bff1e90e7..20418669f 100644 --- a/shadows/framework/src/main/java/org/robolectric/shadows/ShadowPicture.java +++ b/shadows/framework/src/main/java/org/robolectric/shadows/ShadowPicture.java @@ -1,7 +1,5 @@ package org.robolectric.shadows; -import static android.os.Build.VERSION_CODES.KITKAT; -import static android.os.Build.VERSION_CODES.KITKAT_WATCH; import android.graphics.Bitmap; import android.graphics.Canvas; @@ -16,13 +14,7 @@ public class ShadowPicture { private int height; private static long nativePtr = 0; - @Implementation(maxSdk = KITKAT) - protected static int nativeConstructor(int nativeSrc) { - // just return a non zero value, so it appears that native allocation was successful - return (int) nativeConstructor((long) nativeSrc); - } - - @Implementation(minSdk = KITKAT_WATCH) + @Implementation protected static long nativeConstructor(long nativeSrc) { // just return a non zero value, so it appears that native allocation was successful return ++nativePtr; diff --git a/shadows/framework/src/main/java/org/robolectric/shadows/ShadowPorterDuffColorFilter.java b/shadows/framework/src/main/java/org/robolectric/shadows/ShadowPorterDuffColorFilter.java index 68f65553b..314510d73 100644 --- a/shadows/framework/src/main/java/org/robolectric/shadows/ShadowPorterDuffColorFilter.java +++ b/shadows/framework/src/main/java/org/robolectric/shadows/ShadowPorterDuffColorFilter.java @@ -1,12 +1,10 @@ package org.robolectric.shadows; -import static android.os.Build.VERSION_CODES.KITKAT; -import static android.os.Build.VERSION_CODES.LOLLIPOP; + import static org.robolectric.util.reflector.Reflector.reflector; import android.graphics.PorterDuff; import android.graphics.PorterDuffColorFilter; -import org.robolectric.RuntimeEnvironment; import org.robolectric.annotation.Implementation; import org.robolectric.annotation.Implements; import org.robolectric.annotation.RealObject; @@ -20,38 +18,23 @@ public class ShadowPorterDuffColorFilter { @RealObject private PorterDuffColorFilter realPorterDuffColorFilter; - @Implementation(maxSdk = KITKAT) - protected void __constructor__(int color, PorterDuff.Mode mode) { - // We need these copies because before Lollipop, PorterDuffColorFilter had no fields, it would - // just delegate to a native instance. If we remove them, the shadow cannot access the fields - // on KitKat - this.color = color; - this.mode = mode; - } - /** * @return Returns the ARGB color used to tint the source pixels when this filter is applied. */ - @Implementation(minSdk = LOLLIPOP) + @Implementation public int getColor() { - if (RuntimeEnvironment.getApiLevel() == KITKAT) { - return color; - } else { + return reflector(PorterDuffColorFilterReflector.class, realPorterDuffColorFilter).getColor(); - } } /** * @return Returns the Porter-Duff mode used to composite this color filter's color with the * source pixel when this filter is applied. */ - @Implementation(minSdk = LOLLIPOP) + @Implementation public PorterDuff.Mode getMode() { - if (RuntimeEnvironment.getApiLevel() == KITKAT) { - return mode; - } else { + return reflector(PorterDuffColorFilterReflector.class, realPorterDuffColorFilter).getMode(); - } } @ForType(PorterDuffColorFilter.class) diff --git a/shadows/framework/src/main/java/org/robolectric/shadows/ShadowPowerManager.java b/shadows/framework/src/main/java/org/robolectric/shadows/ShadowPowerManager.java index cc6e427a7..404479f90 100644 --- a/shadows/framework/src/main/java/org/robolectric/shadows/ShadowPowerManager.java +++ b/shadows/framework/src/main/java/org/robolectric/shadows/ShadowPowerManager.java @@ -2,7 +2,6 @@ package org.robolectric.shadows; import static android.content.Intent.ACTION_SCREEN_OFF; import static android.content.Intent.ACTION_SCREEN_ON; -import static android.os.Build.VERSION_CODES.LOLLIPOP; import static android.os.Build.VERSION_CODES.LOLLIPOP_MR1; import static android.os.Build.VERSION_CODES.M; import static android.os.Build.VERSION_CODES.N; @@ -110,7 +109,7 @@ public class ShadowPowerManager { setIsInteractive(screenOn); } - @Implementation(minSdk = LOLLIPOP) + @Implementation protected boolean isInteractive() { return isInteractive; } @@ -131,7 +130,7 @@ public class ShadowPowerManager { } } - @Implementation(minSdk = LOLLIPOP) + @Implementation protected boolean isPowerSaveMode() { return isPowerSaveMode; } @@ -142,7 +141,7 @@ public class ShadowPowerManager { private Map<Integer, Boolean> supportedWakeLockLevels = new HashMap<>(); - @Implementation(minSdk = LOLLIPOP) + @Implementation protected boolean isWakeLockLevelSupported(int level) { return supportedWakeLockLevels.containsKey(level) ? supportedWakeLockLevels.get(level) : false; } diff --git a/shadows/framework/src/main/java/org/robolectric/shadows/ShadowRanking.java b/shadows/framework/src/main/java/org/robolectric/shadows/ShadowRanking.java index 67c701260..ab110e160 100644 --- a/shadows/framework/src/main/java/org/robolectric/shadows/ShadowRanking.java +++ b/shadows/framework/src/main/java/org/robolectric/shadows/ShadowRanking.java @@ -3,7 +3,6 @@ package org.robolectric.shadows; import static org.robolectric.util.reflector.Reflector.reflector; import android.app.NotificationChannel; -import android.os.Build.VERSION_CODES; import android.service.notification.NotificationListenerService.Ranking; import java.util.ArrayList; import org.robolectric.annotation.Implements; @@ -12,7 +11,7 @@ import org.robolectric.util.reflector.Accessor; import org.robolectric.util.reflector.ForType; /** Shadow for {@link android.service.notification.NotificationListenerService.Ranking}. */ -@Implements(value = Ranking.class, minSdk = VERSION_CODES.KITKAT_WATCH) +@Implements(value = Ranking.class) public class ShadowRanking { @RealObject private Ranking realObject; diff --git a/shadows/framework/src/main/java/org/robolectric/shadows/ShadowRenderNodeAnimator.java b/shadows/framework/src/main/java/org/robolectric/shadows/ShadowRenderNodeAnimator.java index a35ed8b3f..5e958be4e 100644 --- a/shadows/framework/src/main/java/org/robolectric/shadows/ShadowRenderNodeAnimator.java +++ b/shadows/framework/src/main/java/org/robolectric/shadows/ShadowRenderNodeAnimator.java @@ -19,7 +19,8 @@ import org.robolectric.util.reflector.Direct; import org.robolectric.util.reflector.ForType; import org.robolectric.util.reflector.Static; -@Implements(value = RenderNodeAnimator.class, isInAndroidSdk = false, minSdk = LOLLIPOP, maxSdk = Q) +/** Shadow for {@link RenderNodeAnimator}. */ +@Implements(value = RenderNodeAnimator.class, isInAndroidSdk = false, maxSdk = Q) public class ShadowRenderNodeAnimator { private static final int STATE_FINISHED = 3; diff --git a/shadows/framework/src/main/java/org/robolectric/shadows/ShadowResources.java b/shadows/framework/src/main/java/org/robolectric/shadows/ShadowResources.java index 93e56ccfd..97d84ad55 100644 --- a/shadows/framework/src/main/java/org/robolectric/shadows/ShadowResources.java +++ b/shadows/framework/src/main/java/org/robolectric/shadows/ShadowResources.java @@ -1,6 +1,6 @@ package org.robolectric.shadows; -import static android.os.Build.VERSION_CODES.KITKAT_WATCH; + import static android.os.Build.VERSION_CODES.LOLLIPOP; import static android.os.Build.VERSION_CODES.M; import static android.os.Build.VERSION_CODES.N; @@ -240,15 +240,7 @@ public class ShadowResources { return parser; } - @HiddenApi - @Implementation(maxSdk = KITKAT_WATCH) - protected Drawable loadDrawable(TypedValue value, int id) { - Drawable drawable = reflector(ResourcesReflector.class, realResources).loadDrawable(value, id); - setCreatedFromResId(realResources, id, drawable); - return drawable; - } - - @Implementation(minSdk = LOLLIPOP, maxSdk = N_MR1) + @Implementation(maxSdk = N_MR1) protected Drawable loadDrawable(TypedValue value, int id, Resources.Theme theme) throws Resources.NotFoundException { Drawable drawable = diff --git a/shadows/framework/src/main/java/org/robolectric/shadows/ShadowSettings.java b/shadows/framework/src/main/java/org/robolectric/shadows/ShadowSettings.java index 00149ac68..d4ebacb98 100644 --- a/shadows/framework/src/main/java/org/robolectric/shadows/ShadowSettings.java +++ b/shadows/framework/src/main/java/org/robolectric/shadows/ShadowSettings.java @@ -1,7 +1,6 @@ package org.robolectric.shadows; import static android.os.Build.VERSION_CODES.JELLY_BEAN; -import static android.os.Build.VERSION_CODES.LOLLIPOP; import static android.os.Build.VERSION_CODES.M; import static android.os.Build.VERSION_CODES.P; import static android.os.Build.VERSION_CODES.Q; @@ -240,7 +239,7 @@ public class ShadowSettings { return true; } - @Implementation(minSdk = LOLLIPOP) + @Implementation protected static boolean putIntForUser( ContentResolver cr, String name, int value, int userHandle) { putInt(cr, name, value); diff --git a/shadows/framework/src/main/java/org/robolectric/shadows/ShadowSmsManager.java b/shadows/framework/src/main/java/org/robolectric/shadows/ShadowSmsManager.java index 81a1521fe..b76edc3f1 100644 --- a/shadows/framework/src/main/java/org/robolectric/shadows/ShadowSmsManager.java +++ b/shadows/framework/src/main/java/org/robolectric/shadows/ShadowSmsManager.java @@ -1,6 +1,5 @@ package org.robolectric.shadows; -import static android.os.Build.VERSION_CODES.LOLLIPOP; import static android.os.Build.VERSION_CODES.LOLLIPOP_MR1; import static android.os.Build.VERSION_CODES.R; import static android.os.Build.VERSION_CODES.S; @@ -317,7 +316,7 @@ public class ShadowSmsManager { protected SendMultimediaMessageParams lastSentMultimediaMessageParams; protected DownloadMultimediaMessageParams lastDownloadedMultimediaMessageParams; - @Implementation(minSdk = LOLLIPOP) + @Implementation protected void sendMultimediaMessage( Context context, Uri contentUri, @@ -349,7 +348,7 @@ public class ShadowSmsManager { contentUri, locationUrl, configOverrides, sentIntent, messageId); } - @Implementation(minSdk = LOLLIPOP) + @Implementation protected void downloadMultimediaMessage( Context context, String locationUrl, diff --git a/shadows/framework/src/main/java/org/robolectric/shadows/ShadowStaticLayout.java b/shadows/framework/src/main/java/org/robolectric/shadows/ShadowStaticLayout.java index 5a08de4eb..32fcf2aba 100644 --- a/shadows/framework/src/main/java/org/robolectric/shadows/ShadowStaticLayout.java +++ b/shadows/framework/src/main/java/org/robolectric/shadows/ShadowStaticLayout.java @@ -1,6 +1,5 @@ package org.robolectric.shadows; -import static android.os.Build.VERSION_CODES.LOLLIPOP; import static android.os.Build.VERSION_CODES.LOLLIPOP_MR1; import static android.os.Build.VERSION_CODES.M; import static android.os.Build.VERSION_CODES.O_MR1; @@ -37,7 +36,7 @@ public class ShadowStaticLayout { } @HiddenApi - @Implementation(minSdk = LOLLIPOP, maxSdk = LOLLIPOP_MR1) + @Implementation(maxSdk = LOLLIPOP_MR1) public static int[] nLineBreakOpportunities( String locale, char[] text, int length, int[] recycle) { return new int[] {-1}; diff --git a/shadows/framework/src/main/java/org/robolectric/shadows/ShadowStringBlock.java b/shadows/framework/src/main/java/org/robolectric/shadows/ShadowStringBlock.java index 858229158..15a53dfbd 100644 --- a/shadows/framework/src/main/java/org/robolectric/shadows/ShadowStringBlock.java +++ b/shadows/framework/src/main/java/org/robolectric/shadows/ShadowStringBlock.java @@ -1,7 +1,6 @@ package org.robolectric.shadows; -import static android.os.Build.VERSION_CODES.KITKAT_WATCH; -import static android.os.Build.VERSION_CODES.LOLLIPOP; + import static org.robolectric.res.android.Util.SIZEOF_INT; import java.nio.ByteBuffer; @@ -23,32 +22,17 @@ public class ShadowStringBlock { throw new UnsupportedOperationException(); } - @Implementation(maxSdk = KITKAT_WATCH) - protected static int nativeGetSize(int nativeId) { - return nativeGetSize((long) nativeId); - } - - @Implementation(minSdk = LOLLIPOP) + @Implementation protected static int nativeGetSize(long nativeId) { return ResStringPool.getNativeObject(nativeId).size(); } - @Implementation(maxSdk = KITKAT_WATCH) - protected static String nativeGetString(int nativeId, int index) { - return nativeGetString((long) nativeId, index); - } - - @Implementation(minSdk = LOLLIPOP) + @Implementation protected static String nativeGetString(long nativeId, int index) { return ResStringPool.getNativeObject(nativeId).stringAt(index); } - @Implementation(maxSdk = KITKAT_WATCH) - protected static int[] nativeGetStyle(int obj, int idx) { - return nativeGetStyle((long) obj, idx); - } - - @Implementation(minSdk = LOLLIPOP) + @Implementation protected static int[] nativeGetStyle(long obj, int idx) { ResStringPool osb = ResStringPool.getNativeObject(obj); @@ -100,12 +84,7 @@ public class ShadowStringBlock { } } - @Implementation(maxSdk = KITKAT_WATCH) - protected static void nativeDestroy(int obj) { - nativeDestroy((long) obj); - } - - @Implementation(minSdk = LOLLIPOP) + @Implementation protected static void nativeDestroy(long obj) { throw new UnsupportedOperationException(); } diff --git a/shadows/framework/src/main/java/org/robolectric/shadows/ShadowSurface.java b/shadows/framework/src/main/java/org/robolectric/shadows/ShadowSurface.java index be5ebeda7..08d794286 100644 --- a/shadows/framework/src/main/java/org/robolectric/shadows/ShadowSurface.java +++ b/shadows/framework/src/main/java/org/robolectric/shadows/ShadowSurface.java @@ -1,6 +1,6 @@ package org.robolectric.shadows; -import static android.os.Build.VERSION_CODES.KITKAT; + import static android.os.Build.VERSION_CODES.M; import static android.os.Build.VERSION_CODES.Q; import static org.robolectric.util.reflector.Reflector.reflector; @@ -13,7 +13,6 @@ import dalvik.system.CloseGuard; import java.lang.ref.WeakReference; import java.util.concurrent.atomic.AtomicBoolean; import java.util.concurrent.atomic.AtomicInteger; -import org.robolectric.RuntimeEnvironment; import org.robolectric.annotation.Implementation; import org.robolectric.annotation.Implements; import org.robolectric.annotation.RealObject; @@ -113,13 +112,8 @@ public class ShadowSurface { throw new IllegalStateException("Canvas is not locked!"); } if (surfaceTexture != null) { - if (RuntimeEnvironment.getApiLevel() > KITKAT) { - reflector(SurfaceTextureReflector.class, surfaceTexture) - .postEventFromNative(new WeakReference<>(surfaceTexture)); - } else { - reflector(SurfaceTextureReflector.class, surfaceTexture) - .postEventFromNative((Object) new WeakReference<>(surfaceTexture)); - } + reflector(SurfaceTextureReflector.class, surfaceTexture) + .postEventFromNative(new WeakReference<>(surfaceTexture)); } if (canvas != null && canvas.isHardwareAccelerated()) { surfaceReflector.unlockCanvasAndPost(canvas); diff --git a/shadows/framework/src/main/java/org/robolectric/shadows/ShadowSystemVibrator.java b/shadows/framework/src/main/java/org/robolectric/shadows/ShadowSystemVibrator.java index 1b44991e3..3971c8f60 100644 --- a/shadows/framework/src/main/java/org/robolectric/shadows/ShadowSystemVibrator.java +++ b/shadows/framework/src/main/java/org/robolectric/shadows/ShadowSystemVibrator.java @@ -1,8 +1,6 @@ package org.robolectric.shadows; -import static android.os.Build.VERSION_CODES.JELLY_BEAN_MR1; -import static android.os.Build.VERSION_CODES.KITKAT_WATCH; -import static android.os.Build.VERSION_CODES.LOLLIPOP; + import static android.os.Build.VERSION_CODES.N_MR1; import static android.os.Build.VERSION_CODES.O; import static android.os.Build.VERSION_CODES.P; @@ -41,33 +39,13 @@ public class ShadowSystemVibrator extends ShadowVibrator { return hasAmplitudeControl; } - @Implementation(maxSdk = JELLY_BEAN_MR1) - protected void vibrate(long[] pattern, int repeat) { - recordVibratePattern(pattern, repeat); - } - - @Implementation(maxSdk = KITKAT_WATCH) - protected void vibrate(int owningUid, String owningPackage, long[] pattern, int repeat) { - recordVibratePattern(pattern, repeat); - } - - @Implementation(minSdk = LOLLIPOP, maxSdk = N_MR1) + @Implementation(maxSdk = N_MR1) protected void vibrate( int uid, String opPkg, long[] pattern, int repeat, AudioAttributes attributes) { recordVibratePattern(pattern, repeat); } - @Implementation(maxSdk = JELLY_BEAN_MR1) - public void vibrate(long milliseconds) { - recordVibrate(milliseconds); - } - - @Implementation(maxSdk = KITKAT_WATCH) - public void vibrate(int owningUid, String owningPackage, long milliseconds) { - recordVibrate(milliseconds); - } - - @Implementation(minSdk = LOLLIPOP, maxSdk = N_MR1) + @Implementation(maxSdk = N_MR1) protected void vibrate(int uid, String opPkg, long milliseconds, AudioAttributes attributes) { recordVibrate(milliseconds); } diff --git a/shadows/framework/src/main/java/org/robolectric/shadows/ShadowTelephonyManager.java b/shadows/framework/src/main/java/org/robolectric/shadows/ShadowTelephonyManager.java index 249d53483..b9f9a949f 100644 --- a/shadows/framework/src/main/java/org/robolectric/shadows/ShadowTelephonyManager.java +++ b/shadows/framework/src/main/java/org/robolectric/shadows/ShadowTelephonyManager.java @@ -1,7 +1,6 @@ package org.robolectric.shadows; import static android.content.pm.PackageManager.PERMISSION_GRANTED; -import static android.os.Build.VERSION_CODES.LOLLIPOP; import static android.os.Build.VERSION_CODES.LOLLIPOP_MR1; import static android.os.Build.VERSION_CODES.M; import static android.os.Build.VERSION_CODES.N; @@ -436,7 +435,7 @@ public class ShadowTelephonyManager { setNetworkOperatorName(networkOperatorName); } - @Implementation(minSdk = LOLLIPOP) + @Implementation protected String getImei() { checkReadPhoneStatePermission(); return imei; @@ -1199,7 +1198,7 @@ public class ShadowTelephonyManager { return carrierPackageNames.get(phoneId); } - @Implementation(minSdk = LOLLIPOP) + @Implementation @HiddenApi protected List<String> getCarrierPackageNamesForIntent(Intent intent) { return carrierPackageNames.get(SubscriptionManager.DEFAULT_SUBSCRIPTION_ID); diff --git a/shadows/framework/src/main/java/org/robolectric/shadows/ShadowTextToSpeech.java b/shadows/framework/src/main/java/org/robolectric/shadows/ShadowTextToSpeech.java index 83be824d9..d88988322 100644 --- a/shadows/framework/src/main/java/org/robolectric/shadows/ShadowTextToSpeech.java +++ b/shadows/framework/src/main/java/org/robolectric/shadows/ShadowTextToSpeech.java @@ -120,7 +120,7 @@ public class ShadowTextToSpeech { text, queueMode, null, params == null ? null : params.get(Engine.KEY_PARAM_UTTERANCE_ID)); } - @Implementation(minSdk = LOLLIPOP) + @Implementation protected int speak( final CharSequence text, final int queueMode, final Bundle params, final String utteranceId) { stopped = false; @@ -193,7 +193,7 @@ public class ShadowTextToSpeech { * * @see #getLastSynthesizeToFileText() */ - @Implementation(minSdk = LOLLIPOP) + @Implementation protected int synthesizeToFile(CharSequence text, Bundle params, File file, String utteranceId) throws IOException { this.lastSynthesizeToFileText = text.toString(); @@ -237,13 +237,13 @@ public class ShadowTextToSpeech { return TextToSpeech.SUCCESS; } - @Implementation(minSdk = LOLLIPOP) + @Implementation protected int setVoice(Voice voice) { this.currentVoice = voice; return TextToSpeech.SUCCESS; } - @Implementation(minSdk = LOLLIPOP) + @Implementation protected Set<Voice> getVoices() { return voices; } diff --git a/shadows/framework/src/main/java/org/robolectric/shadows/ShadowTime.java b/shadows/framework/src/main/java/org/robolectric/shadows/ShadowTime.java index df7615078..c3e234985 100644 --- a/shadows/framework/src/main/java/org/robolectric/shadows/ShadowTime.java +++ b/shadows/framework/src/main/java/org/robolectric/shadows/ShadowTime.java @@ -1,386 +1,22 @@ package org.robolectric.shadows; -import static android.os.Build.VERSION_CODES.KITKAT_WATCH; -import static android.os.Build.VERSION_CODES.LOLLIPOP; - -import android.os.SystemClock; import android.text.format.Time; import android.util.TimeFormatException; -import java.text.ParseException; -import java.text.SimpleDateFormat; -import java.util.Calendar; -import java.util.Date; -import java.util.Locale; -import java.util.TimeZone; import org.robolectric.annotation.Implementation; import org.robolectric.annotation.Implements; import org.robolectric.annotation.RealObject; import org.robolectric.util.ReflectionHelpers; -import org.robolectric.util.Strftime; @Implements(value = Time.class) public class ShadowTime { @RealObject private Time time; - @Implementation(maxSdk = KITKAT_WATCH) - protected void setToNow() { - time.set(SystemClock.currentThreadTimeMillis()); - } - private static final long SECOND_IN_MILLIS = 1000; private static final long MINUTE_IN_MILLIS = SECOND_IN_MILLIS * 60; private static final long HOUR_IN_MILLIS = MINUTE_IN_MILLIS * 60; private static final long DAY_IN_MILLIS = HOUR_IN_MILLIS * 24; - @Implementation(maxSdk = KITKAT_WATCH) - protected void __constructor__() { - __constructor__(getCurrentTimezone()); - } - - @Implementation(maxSdk = KITKAT_WATCH) - protected void __constructor__(String timezone) { - if (timezone == null) { - throw new NullPointerException("timezone is null!"); - } - time.timezone = timezone; - time.year = 1970; - time.monthDay = 1; - time.isDst = -1; - } - - @Implementation(maxSdk = KITKAT_WATCH) - protected void __constructor__(Time other) { - set(other); - } - - @Implementation(maxSdk = KITKAT_WATCH) - protected void set(Time other) { - time.timezone = other.timezone; - time.second = other.second; - time.minute = other.minute; - time.hour = other.hour; - time.monthDay = other.monthDay; - time.month = other.month; - time.year = other.year; - time.weekDay = other.weekDay; - time.yearDay = other.yearDay; - time.isDst = other.isDst; - time.gmtoff = other.gmtoff; - } - - @Implementation(maxSdk = KITKAT_WATCH) - protected static boolean isEpoch(Time time) { - long millis = time.toMillis(true); - return getJulianDay(millis, 0) == Time.EPOCH_JULIAN_DAY; - } - - @Implementation(maxSdk = KITKAT_WATCH) - protected static int getJulianDay(long millis, long gmtoff) { - long offsetMillis = gmtoff * 1000; - long julianDay = (millis + offsetMillis) / DAY_IN_MILLIS; - return (int) julianDay + Time.EPOCH_JULIAN_DAY; - } - - @Implementation(maxSdk = KITKAT_WATCH) - protected long setJulianDay(int julianDay) { - // Don't bother with the GMT offset since we don't know the correct - // value for the given Julian day. Just get close and then adjust - // the day. - // long millis = (julianDay - EPOCH_JULIAN_DAY) * DateUtils.DAY_IN_MILLIS; - long millis = (julianDay - Time.EPOCH_JULIAN_DAY) * DAY_IN_MILLIS; - set(millis); - - // Figure out how close we are to the requested Julian day. - // We can't be off by more than a day. - int approximateDay = getJulianDay(millis, time.gmtoff); - int diff = julianDay - approximateDay; - time.monthDay += diff; - - // Set the time to 12am and re-normalize. - time.hour = 0; - time.minute = 0; - time.second = 0; - millis = time.normalize(true); - return millis; - } - - @Implementation(maxSdk = KITKAT_WATCH) - protected void set(long millis) { - Calendar c = getCalendar(); - c.setTimeInMillis(millis); - set( - c.get(Calendar.SECOND), - c.get(Calendar.MINUTE), - c.get(Calendar.HOUR_OF_DAY), - c.get(Calendar.DAY_OF_MONTH), - c.get(Calendar.MONTH), - c.get(Calendar.YEAR)); - } - - @Implementation(maxSdk = KITKAT_WATCH) - protected long toMillis(boolean ignoreDst) { - Calendar c = getCalendar(); - return c.getTimeInMillis(); - } - - @Implementation(maxSdk = KITKAT_WATCH) - protected void set(int second, int minute, int hour, int monthDay, int month, int year) { - time.second = second; - time.minute = minute; - time.hour = hour; - time.monthDay = monthDay; - time.month = month; - time.year = year; - time.weekDay = 0; - time.yearDay = 0; - time.isDst = -1; - time.gmtoff = 0; - } - - @Implementation(maxSdk = KITKAT_WATCH) - protected void set(int monthDay, int month, int year) { - set(0, 0, 0, monthDay, month, year); - } - - @Implementation(maxSdk = KITKAT_WATCH) - protected void clear(String timezone) { - if (timezone == null) { - throw new NullPointerException("timezone is null!"); - } - time.timezone = timezone; - time.allDay = false; - time.second = 0; - time.minute = 0; - time.hour = 0; - time.monthDay = 0; - time.month = 0; - time.year = 0; - time.weekDay = 0; - time.yearDay = 0; - time.gmtoff = 0; - time.isDst = -1; - } - - @Implementation(maxSdk = KITKAT_WATCH) - protected static String getCurrentTimezone() { - return TimeZone.getDefault().getID(); - } - - @Implementation(maxSdk = KITKAT_WATCH) - protected void switchTimezone(String timezone) { - long date = toMillis(true); - long gmtoff = TimeZone.getTimeZone(timezone).getOffset(date); - set(date + gmtoff); - time.timezone = timezone; - time.gmtoff = (gmtoff / 1000); - } - - @Implementation(maxSdk = KITKAT_WATCH) - protected static int compare(Time a, Time b) { - long ams = a.toMillis(false); - long bms = b.toMillis(false); - if (ams == bms) { - return 0; - } else if (ams < bms) { - return -1; - } else { - return 1; - } - } - - @Implementation(maxSdk = KITKAT_WATCH) - protected boolean before(Time other) { - return Time.compare(time, other) < 0; - } - - @Implementation(maxSdk = KITKAT_WATCH) - protected boolean after(Time other) { - return Time.compare(time, other) > 0; - } - - @Implementation(maxSdk = KITKAT_WATCH) - protected boolean parse(String timeString) { - TimeZone tz; - if (timeString.endsWith("Z")) { - timeString = timeString.substring(0, timeString.length() - 1); - tz = TimeZone.getTimeZone("UTC"); - } else { - tz = TimeZone.getTimeZone(time.timezone); - } - SimpleDateFormat df = new SimpleDateFormat("yyyyMMdd'T'HHmmss", Locale.ENGLISH); - SimpleDateFormat dfShort = new SimpleDateFormat("yyyyMMdd", Locale.ENGLISH); - df.setTimeZone(tz); - dfShort.setTimeZone(tz); - time.timezone = tz.getID(); - try { - set(df.parse(timeString).getTime()); - } catch (ParseException e) { - try { - set(dfShort.parse(timeString).getTime()); - } catch (ParseException e2) { - throwTimeFormatException(e2.getLocalizedMessage()); - } - } - return "UTC".equals(tz.getID()); - } - - @Implementation(maxSdk = KITKAT_WATCH) - protected String format2445() { - String value = format("%Y%m%dT%H%M%S"); - if ("UTC".equals(time.timezone)) { - value += "Z"; - } - return value; - } - - @Implementation(maxSdk = KITKAT_WATCH) - protected String format3339(boolean allDay) { - if (allDay) { - return format("%Y-%m-%d"); - } else if ("UTC".equals(time.timezone)) { - return format("%Y-%m-%dT%H:%M:%S.000Z"); - } else { - String base = format("%Y-%m-%dT%H:%M:%S.000"); - String sign = (time.gmtoff < 0) ? "-" : "+"; - int offset = (int) Math.abs(time.gmtoff); - int minutes = (offset % 3600) / 60; - int hours = offset / 3600; - return String.format("%s%s%02d:%02d", base, sign, hours, minutes); - } - } - - @Implementation(maxSdk = KITKAT_WATCH) - protected boolean nativeParse3339(String s) { - // In lollipop, the native implementation was replaced with java - // this is a copy of the aosp-pie implementation - int len = s.length(); - if (len < 10) { - throwTimeFormatException("String too short --- expected at least 10 characters."); - } - boolean inUtc = false; - - // year - int n = getChar(s, 0, 1000); - n += getChar(s, 1, 100); - n += getChar(s, 2, 10); - n += getChar(s, 3, 1); - time.year = n; - - checkChar(s, 4, '-'); - - // month - n = getChar(s, 5, 10); - n += getChar(s, 6, 1); - --n; - time.month = n; - - checkChar(s, 7, '-'); - - // day - n = getChar(s, 8, 10); - n += getChar(s, 9, 1); - time.monthDay = n; - - if (len >= 19) { - // T - checkChar(s, 10, 'T'); - time.allDay = false; - - // hour - n = getChar(s, 11, 10); - n += getChar(s, 12, 1); - - // Note that this.hour is not set here. It is set later. - int hour = n; - - checkChar(s, 13, ':'); - - // minute - n = getChar(s, 14, 10); - n += getChar(s, 15, 1); - // Note that this.minute is not set here. It is set later. - int minute = n; - - checkChar(s, 16, ':'); - - // second - n = getChar(s, 17, 10); - n += getChar(s, 18, 1); - time.second = n; - - // skip the '.XYZ' -- we don't care about subsecond precision. - - int tzIndex = 19; - if (tzIndex < len && s.charAt(tzIndex) == '.') { - do { - tzIndex++; - } while (tzIndex < len && Character.isDigit(s.charAt(tzIndex))); - } - - int offset = 0; - if (len > tzIndex) { - char c = s.charAt(tzIndex); - // NOTE: the offset is meant to be subtracted to get from local time - // to UTC. we therefore use 1 for '-' and -1 for '+'. - switch (c) { - case 'Z': - // Zulu time -- UTC - offset = 0; - break; - case '-': - offset = 1; - break; - case '+': - offset = -1; - break; - default: - throwTimeFormatException( - String.format( - "Unexpected character 0x%02d at position %d. Expected + or -", - (int) c, tzIndex)); - } - inUtc = true; - - if (offset != 0) { - if (len < tzIndex + 6) { - throwTimeFormatException( - String.format("Unexpected length; should be %d characters", tzIndex + 6)); - } - - // hour - n = getChar(s, tzIndex + 1, 10); - n += getChar(s, tzIndex + 2, 1); - n *= offset; - hour += n; - - // minute - n = getChar(s, tzIndex + 4, 10); - n += getChar(s, tzIndex + 5, 1); - n *= offset; - minute += n; - } - } - time.hour = hour; - time.minute = minute; - - if (offset != 0) { - time.normalize(false); - } - } else { - time.allDay = true; - time.hour = 0; - time.minute = 0; - time.second = 0; - } - - time.weekDay = 0; - time.yearDay = 0; - time.isDst = -1; - time.gmtoff = 0; - return inUtc; - } - - @Implementation(minSdk = LOLLIPOP) + @Implementation protected static int getChar(String s, int spos, int mul) { char c = s.charAt(spos); if (Character.isDigit(c)) { @@ -391,7 +27,7 @@ public class ShadowTime { return -1; } - @Implementation(minSdk = LOLLIPOP) + @Implementation protected void checkChar(String s, int spos, char expected) { char c = s.charAt(spos); if (c != expected) { @@ -408,20 +44,4 @@ public class ShadowTime { ReflectionHelpers.ClassParameter.from( String.class, optionalMessage == null ? "fail" : optionalMessage)); } - - @Implementation(maxSdk = KITKAT_WATCH) - protected String format(String format) { - return Strftime.format( - format, - new Date(toMillis(false)), - Locale.getDefault(), - TimeZone.getTimeZone(time.timezone)); - } - - private Calendar getCalendar() { - Calendar c = Calendar.getInstance(TimeZone.getTimeZone(time.timezone)); - c.set(time.year, time.month, time.monthDay, time.hour, time.minute, time.second); - c.set(Calendar.MILLISECOND, 0); - return c; - } } diff --git a/shadows/framework/src/main/java/org/robolectric/shadows/ShadowUsbDeviceConnection.java b/shadows/framework/src/main/java/org/robolectric/shadows/ShadowUsbDeviceConnection.java index dcfdc5ae3..e691d608e 100644 --- a/shadows/framework/src/main/java/org/robolectric/shadows/ShadowUsbDeviceConnection.java +++ b/shadows/framework/src/main/java/org/robolectric/shadows/ShadowUsbDeviceConnection.java @@ -1,6 +1,5 @@ package org.robolectric.shadows; -import static android.os.Build.VERSION_CODES.LOLLIPOP; import static android.os.Build.VERSION_CODES.O; import android.hardware.usb.UsbDeviceConnection; @@ -57,7 +56,7 @@ public class ShadowUsbDeviceConnection { * No-op on Robolectrict. The real implementation would return false on Robolectric and make it * impossible to test callers that expect a successful result. Always returns {@code true}. */ - @Implementation(minSdk = LOLLIPOP) + @Implementation protected boolean setInterface(UsbInterface intf) { return true; } diff --git a/shadows/framework/src/main/java/org/robolectric/shadows/ShadowUserManager.java b/shadows/framework/src/main/java/org/robolectric/shadows/ShadowUserManager.java index 1fef4d09d..7accd63a4 100644 --- a/shadows/framework/src/main/java/org/robolectric/shadows/ShadowUserManager.java +++ b/shadows/framework/src/main/java/org/robolectric/shadows/ShadowUserManager.java @@ -193,7 +193,7 @@ public class ShadowUserManager { return userManagerState.userSerialNumbers.get(userHandle.getIdentifier()); } - @Implementation(minSdk = LOLLIPOP) + @Implementation protected List<UserHandle> getUserProfiles() { ImmutableList.Builder<UserHandle> builder = new ImmutableList.Builder<>(); List<UserHandle> profiles = userManagerState.userProfilesListMap.get(UserHandle.myUserId()); @@ -213,7 +213,7 @@ public class ShadowUserManager { * * <p>Otherwise follow real android behaviour. */ - @Implementation(minSdk = LOLLIPOP) + @Implementation protected List<UserInfo> getProfiles(int userHandle) { if (userManagerState.userProfilesListMap.containsKey(userHandle)) { ArrayList<UserInfo> infos = new ArrayList<>(); @@ -249,7 +249,7 @@ public class ShadowUserManager { return userHandles; } - @Implementation(minSdk = LOLLIPOP) + @Implementation protected UserInfo getProfileParent(int userId) { if (enforcePermissions && !hasManageUsersPermission()) { throw new SecurityException("Requires MANAGE_USERS permission"); @@ -367,7 +367,7 @@ public class ShadowUserManager { * @see #enforcePermissionChecks(boolean) * @see #setManagedProfile(boolean) */ - @Implementation(minSdk = LOLLIPOP) + @Implementation protected boolean isManagedProfile() { if (enforcePermissions && !hasManageUsersPermission()) { throw new SecurityException( @@ -484,7 +484,7 @@ public class ShadowUserManager { return userInfo.profileGroupId == otherUserInfo.profileGroupId; } - @Implementation(minSdk = LOLLIPOP) + @Implementation protected boolean hasUserRestriction(String restrictionKey, UserHandle userHandle) { synchronized (lock) { Bundle bundle = userManagerState.userRestrictions.get(userHandle.getIdentifier()); diff --git a/shadows/framework/src/main/java/org/robolectric/shadows/ShadowVMRuntime.java b/shadows/framework/src/main/java/org/robolectric/shadows/ShadowVMRuntime.java index 30da1ba7d..8bc20c406 100644 --- a/shadows/framework/src/main/java/org/robolectric/shadows/ShadowVMRuntime.java +++ b/shadows/framework/src/main/java/org/robolectric/shadows/ShadowVMRuntime.java @@ -25,7 +25,7 @@ public class ShadowVMRuntime { @Nullable private static String currentInstructionSet = null; - @Implementation(minSdk = LOLLIPOP) + @Implementation public Object newUnpaddedArray(Class<?> klass, int size) { return Array.newInstance(klass, size); } @@ -57,7 +57,7 @@ public class ShadowVMRuntime { /** * Returns whether the VM is running in 64-bit mode. Available in Android L+. Defaults to true. */ - @Implementation(minSdk = LOLLIPOP) + @Implementation protected boolean is64Bit() { return ShadowVMRuntime.is64Bit; } @@ -69,7 +69,7 @@ public class ShadowVMRuntime { } /** Returns the instruction set of the current runtime. */ - @Implementation(minSdk = LOLLIPOP) + @Implementation protected static String getCurrentInstructionSet() { return currentInstructionSet; } diff --git a/shadows/framework/src/main/java/org/robolectric/shadows/ShadowView.java b/shadows/framework/src/main/java/org/robolectric/shadows/ShadowView.java index 848502e60..60ee635a3 100644 --- a/shadows/framework/src/main/java/org/robolectric/shadows/ShadowView.java +++ b/shadows/framework/src/main/java/org/robolectric/shadows/ShadowView.java @@ -1,7 +1,5 @@ package org.robolectric.shadows; -import static android.os.Build.VERSION_CODES.KITKAT; -import static android.os.Build.VERSION_CODES.KITKAT_WATCH; import static android.os.Build.VERSION_CODES.N; import static android.os.Build.VERSION_CODES.O; import static android.os.Build.VERSION_CODES.Q; @@ -164,16 +162,8 @@ public class ShadowView { return locationInSurface; } - // Only override up to kitkat, while this version exists after kitkat it just calls through to the - // __constructor__(Context, AttributeSet, int, int) variant below. - @Implementation(maxSdk = KITKAT) - protected void __constructor__(Context context, AttributeSet attributeSet, int defStyle) { - this.attributeSet = attributeSet; - reflector(_View_.class, realView).__constructor__(context, attributeSet, defStyle); - } - /* Note: maxSdk is R because capturing `attributeSet` is not needed any more after R. */ - @Implementation(minSdk = KITKAT_WATCH, maxSdk = R) + @Implementation(maxSdk = R) protected void __constructor__( Context context, AttributeSet attributeSet, int defStyleAttr, int defStyleRes) { this.attributeSet = attributeSet; diff --git a/shadows/framework/src/main/java/org/robolectric/shadows/ShadowViewRootImpl.java b/shadows/framework/src/main/java/org/robolectric/shadows/ShadowViewRootImpl.java index 86c2bd02e..41299cb5c 100644 --- a/shadows/framework/src/main/java/org/robolectric/shadows/ShadowViewRootImpl.java +++ b/shadows/framework/src/main/java/org/robolectric/shadows/ShadowViewRootImpl.java @@ -388,15 +388,6 @@ public class ShadowViewRootImpl { @Accessor("mWindowAttributes") WindowManager.LayoutParams getWindowAttributes(); - // == KITKAT - void dispatchResized( - Rect frame, - Rect overscanInsets, - Rect contentInsets, - Rect visibleInsets, - boolean reportDraw, - Configuration newConfig); - // <= LOLLIPOP_MR1 void dispatchResized( Rect frame, @@ -467,9 +458,7 @@ public class ShadowViewRootImpl { Rect emptyRect = new Rect(0, 0, 0, 0); int apiLevel = RuntimeEnvironment.getApiLevel(); - if (apiLevel == Build.VERSION_CODES.KITKAT) { - dispatchResized(frame, emptyRect, emptyRect, emptyRect, true, null); - } else if (apiLevel <= Build.VERSION_CODES.LOLLIPOP_MR1) { + if (apiLevel <= Build.VERSION_CODES.LOLLIPOP_MR1) { dispatchResized(frame, emptyRect, emptyRect, emptyRect, emptyRect, true, null); } else if (apiLevel <= Build.VERSION_CODES.M) { dispatchResized(frame, emptyRect, emptyRect, emptyRect, emptyRect, emptyRect, true, null); diff --git a/shadows/framework/src/main/java/org/robolectric/shadows/ShadowVirtualRefBasePtr.java b/shadows/framework/src/main/java/org/robolectric/shadows/ShadowVirtualRefBasePtr.java index df4db7538..34fd332ab 100644 --- a/shadows/framework/src/main/java/org/robolectric/shadows/ShadowVirtualRefBasePtr.java +++ b/shadows/framework/src/main/java/org/robolectric/shadows/ShadowVirtualRefBasePtr.java @@ -1,6 +1,5 @@ package org.robolectric.shadows; -import static android.os.Build.VERSION_CODES.LOLLIPOP; import com.android.internal.util.VirtualRefBasePtr; import org.robolectric.annotation.Implementation; @@ -20,7 +19,7 @@ public class ShadowVirtualRefBasePtr { return clazz.cast(NATIVE_REGISTRY.getNativeObject(nativePtr).nativeThing); } - @Implementation(minSdk = LOLLIPOP) + @Implementation protected static synchronized void nIncStrong(long ptr) { if (ptr == 0) { return; @@ -28,7 +27,7 @@ public class ShadowVirtualRefBasePtr { NATIVE_REGISTRY.getNativeObject(ptr).incr(); } - @Implementation(minSdk = LOLLIPOP) + @Implementation protected static synchronized void nDecStrong(long ptr) { if (ptr == 0) { return; diff --git a/shadows/framework/src/main/java/org/robolectric/shadows/ShadowWifiInfo.java b/shadows/framework/src/main/java/org/robolectric/shadows/ShadowWifiInfo.java index 183637167..81cfff980 100644 --- a/shadows/framework/src/main/java/org/robolectric/shadows/ShadowWifiInfo.java +++ b/shadows/framework/src/main/java/org/robolectric/shadows/ShadowWifiInfo.java @@ -1,6 +1,5 @@ package org.robolectric.shadows; -import static android.os.Build.VERSION_CODES.LOLLIPOP; import static org.robolectric.util.reflector.Reflector.reflector; import android.net.wifi.SupplicantState; @@ -69,7 +68,7 @@ public class ShadowWifiInfo { reflector(WifiInfoReflector.class, realObject).setLinkSpeed(linkSpeed); } - @Implementation(minSdk = LOLLIPOP) + @Implementation public void setFrequency(int frequency) { reflector(WifiInfoReflector.class, realObject).setFrequency(frequency); } diff --git a/shadows/framework/src/main/java/org/robolectric/shadows/ShadowWifiManager.java b/shadows/framework/src/main/java/org/robolectric/shadows/ShadowWifiManager.java index 9e17e3531..05d1f3d58 100644 --- a/shadows/framework/src/main/java/org/robolectric/shadows/ShadowWifiManager.java +++ b/shadows/framework/src/main/java/org/robolectric/shadows/ShadowWifiManager.java @@ -1,6 +1,5 @@ package org.robolectric.shadows; -import static android.os.Build.VERSION_CODES.LOLLIPOP; import static android.os.Build.VERSION_CODES.Q; import static android.os.Build.VERSION_CODES.R; import static android.os.Build.VERSION_CODES.S; @@ -162,7 +161,7 @@ public class ShadowWifiManager { return wifiInfo; } - @Implementation(minSdk = LOLLIPOP) + @Implementation protected boolean is5GHzBandSupported() { return is5GHzBandSupported; } @@ -264,7 +263,7 @@ public class ShadowWifiManager { return wifiConfigurations; } - @Implementation(minSdk = LOLLIPOP) + @Implementation protected List<WifiConfiguration> getPrivilegedConfiguredNetworks() { return getConfiguredNetworks(); } diff --git a/shadows/framework/src/main/java/org/robolectric/shadows/ShadowXmlBlock.java b/shadows/framework/src/main/java/org/robolectric/shadows/ShadowXmlBlock.java index 9f0496df0..ac02b5779 100644 --- a/shadows/framework/src/main/java/org/robolectric/shadows/ShadowXmlBlock.java +++ b/shadows/framework/src/main/java/org/robolectric/shadows/ShadowXmlBlock.java @@ -42,12 +42,7 @@ public class ShadowXmlBlock { return RuntimeEnvironment.castNativePtr(Registries.NATIVE_RES_XML_TREES.register(osb)); } - @Implementation(maxSdk = VERSION_CODES.KITKAT_WATCH) - protected static int nativeGetStringBlock(int obj) { - return (int)nativeGetStringBlock((long)obj); - } - - @Implementation(minSdk = VERSION_CODES.LOLLIPOP) + @Implementation protected static Number nativeGetStringBlock(long obj) { ResXMLTree osb = Registries.NATIVE_RES_XML_TREES.getNativeObject(obj); // if (osb == NULL) { @@ -58,12 +53,7 @@ public class ShadowXmlBlock { return RuntimeEnvironment.castNativePtr(osb.getStrings().getNativePtr()); } - @Implementation(maxSdk = VERSION_CODES.KITKAT_WATCH) - protected static int nativeCreateParseState(int obj) { - return (int)nativeCreateParseState((long)obj); - } - - @Implementation(minSdk = VERSION_CODES.LOLLIPOP, maxSdk = VERSION_CODES.P) + @Implementation(maxSdk = VERSION_CODES.P) protected static long nativeCreateParseState(long obj) { ResXMLTree osb = Registries.NATIVE_RES_XML_TREES.getNativeObject(obj); // if (osb == NULL) { @@ -102,12 +92,7 @@ public class ShadowXmlBlock { return Registries.NATIVE_RES_XML_PARSERS.register(st); } - @Implementation(maxSdk = VERSION_CODES.KITKAT_WATCH) - protected static int nativeNext(int state) throws XmlPullParserException { - return (int)nativeNext((long)state); - } - - @Implementation(minSdk = VERSION_CODES.LOLLIPOP) + @Implementation protected static int nativeNext(long state) throws XmlPullParserException { ResXMLParser st = getResXMLParser(state); if (st == null) { @@ -137,12 +122,7 @@ public class ShadowXmlBlock { } while (true); } - @Implementation(maxSdk = VERSION_CODES.KITKAT_WATCH) - protected static int nativeGetNamespace(int state) { - return nativeGetNamespace((long)state); - } - - @Implementation(minSdk = VERSION_CODES.LOLLIPOP) + @Implementation protected static int nativeGetNamespace(long state) { ResXMLParser resXMLParser = getResXMLParser(state); if (resXMLParser == null) { @@ -151,12 +131,7 @@ public class ShadowXmlBlock { return resXMLParser.getElementNamespaceID(); } - @Implementation(maxSdk = VERSION_CODES.KITKAT_WATCH) - protected static int nativeGetName(int state) { - return nativeGetName((long) state); - } - - @Implementation(minSdk = VERSION_CODES.LOLLIPOP) + @Implementation protected static int nativeGetName(long state) { ResXMLParser resXMLParser = getResXMLParser(state); if (resXMLParser == null) { @@ -165,12 +140,7 @@ public class ShadowXmlBlock { return resXMLParser.getElementNameID(); } - @Implementation(maxSdk = VERSION_CODES.KITKAT_WATCH) - protected static int nativeGetText(int state) { - return nativeGetText((long) state); - } - - @Implementation(minSdk = VERSION_CODES.LOLLIPOP) + @Implementation protected static int nativeGetText(long state) { ResXMLParser resXMLParser = getResXMLParser(state); if (resXMLParser == null) { @@ -179,124 +149,69 @@ public class ShadowXmlBlock { return resXMLParser.getTextID(); } - @Implementation(maxSdk = VERSION_CODES.KITKAT_WATCH) - protected static int nativeGetLineNumber(int state) { - return (int)nativeGetLineNumber((long)state); - } - - @Implementation(minSdk = VERSION_CODES.LOLLIPOP) + @Implementation protected static int nativeGetLineNumber(long state) { ResXMLParser resXMLParser = getResXMLParser(state); return resXMLParser.getLineNumber(); } - @Implementation(maxSdk = VERSION_CODES.KITKAT_WATCH) - protected static int nativeGetAttributeCount(int state) { - return (int)nativeGetAttributeCount((long)state); - } - - @Implementation(minSdk = VERSION_CODES.LOLLIPOP) + @Implementation protected static int nativeGetAttributeCount(long state) { ResXMLParser resXMLParser = getResXMLParser(state); return resXMLParser.getAttributeCount(); } - @Implementation(maxSdk = VERSION_CODES.KITKAT_WATCH) - protected static int nativeGetAttributeNamespace(int state, int idx) { - return (int)nativeGetAttributeNamespace((long)state, idx); - } - - @Implementation(minSdk = VERSION_CODES.LOLLIPOP) + @Implementation protected static int nativeGetAttributeNamespace(long state, int idx) { ResXMLParser resXMLParser = getResXMLParser(state); return resXMLParser.getAttributeNamespaceID(idx); } - @Implementation(maxSdk = VERSION_CODES.KITKAT_WATCH) - protected static int nativeGetAttributeName(int state, int idx) { - return (int)nativeGetAttributeName((long) state, idx); - } - - @Implementation(minSdk = VERSION_CODES.LOLLIPOP) + @Implementation protected static int nativeGetAttributeName(long state, int idx) { ResXMLParser resXMLParser = getResXMLParser(state); return resXMLParser.getAttributeNameID(idx); } - @Implementation(maxSdk = VERSION_CODES.KITKAT_WATCH) - protected static int nativeGetAttributeResource(int state, int idx) { - return (int)nativeGetAttributeResource((long)state, idx); - } - - @Implementation(minSdk = VERSION_CODES.LOLLIPOP) + @Implementation protected static int nativeGetAttributeResource(long state, int idx) { ResXMLParser resXMLParser = getResXMLParser(state); return resXMLParser.getAttributeNameResID(idx); } - @Implementation(maxSdk = VERSION_CODES.KITKAT_WATCH) - protected static int nativeGetAttributeDataType(int state, int idx) { - return (int)nativeGetAttributeDataType((long)state, idx); - } - - @Implementation(minSdk = VERSION_CODES.LOLLIPOP) + @Implementation protected static int nativeGetAttributeDataType(long state, int idx) { ResXMLParser resXMLParser = getResXMLParser(state); return resXMLParser.getAttributeDataType(idx); } - @Implementation(maxSdk = VERSION_CODES.KITKAT_WATCH) - protected static int nativeGetAttributeData(int state, int idx) { - return (int)nativeGetAttributeData((long)state, idx); - } - - @Implementation(minSdk = VERSION_CODES.LOLLIPOP) + @Implementation protected static int nativeGetAttributeData(long state, int idx) { ResXMLParser resXMLParser = getResXMLParser(state); return resXMLParser.getAttributeData(idx); } - @Implementation(maxSdk = VERSION_CODES.KITKAT_WATCH) - protected static int nativeGetAttributeStringValue(int state, int idx) { - return (int)nativeGetAttributeStringValue((long)state, idx); - } - - @Implementation(minSdk = VERSION_CODES.LOLLIPOP) + @Implementation protected static int nativeGetAttributeStringValue(long state, int idx) { ResXMLParser resXMLParser = getResXMLParser(state); return resXMLParser.getAttributeValueStringID(idx); } - @Implementation(maxSdk = VERSION_CODES.KITKAT_WATCH) - protected static int nativeGetIdAttribute(int obj) { - return (int)nativeGetIdAttribute((long)obj); - } - - @Implementation(minSdk = VERSION_CODES.LOLLIPOP) + @Implementation protected static int nativeGetIdAttribute(long state) { ResXMLParser resXMLParser = getResXMLParser(state); int idx = resXMLParser.indexOfID(); return idx >= 0 ? resXMLParser.getAttributeValueStringID(idx) : -1; } - @Implementation(maxSdk = VERSION_CODES.KITKAT_WATCH) - protected static int nativeGetClassAttribute(int obj) { - return (int)nativeGetClassAttribute((long)obj); - } - - @Implementation(minSdk = VERSION_CODES.LOLLIPOP) + @Implementation protected static int nativeGetClassAttribute(long state) { ResXMLParser resXMLParser = getResXMLParser(state); int idx = resXMLParser.indexOfClass(); return idx >= 0 ? resXMLParser.getAttributeValueStringID(idx) : -1; } - @Implementation(maxSdk = VERSION_CODES.KITKAT_WATCH) - protected static int nativeGetStyleAttribute(int obj) { - return (int)nativeGetStyleAttribute((long)obj); - } - - @Implementation(minSdk = VERSION_CODES.LOLLIPOP) + @Implementation protected static int nativeGetStyleAttribute(long state) { ResXMLParser resXMLParser = getResXMLParser(state); int idx = resXMLParser.indexOfStyle(); @@ -315,12 +230,7 @@ public class ShadowXmlBlock { ? value.data : 0; } - @Implementation(maxSdk = VERSION_CODES.KITKAT_WATCH) - protected static int nativeGetAttributeIndex(int obj, String ns, String name) { - return (int)nativeGetAttributeIndex((long)obj, ns, name); - } - - @Implementation(minSdk = VERSION_CODES.LOLLIPOP) + @Implementation protected static int nativeGetAttributeIndex(long token, String ns, String name) { ResXMLParser st = getResXMLParser(token); if (st == null || name == null) { @@ -345,22 +255,12 @@ public class ShadowXmlBlock { } } - @Implementation(maxSdk = VERSION_CODES.KITKAT_WATCH) - protected static void nativeDestroyParseState(int obj) { - nativeDestroyParseState((long)obj); - } - - @Implementation(minSdk = VERSION_CODES.LOLLIPOP) + @Implementation protected static void nativeDestroyParseState(long state) { Registries.NATIVE_RES_XML_PARSERS.unregister(state); } - @Implementation(maxSdk = VERSION_CODES.KITKAT_WATCH) - protected static void nativeDestroy(int obj) { - nativeDestroy((long)obj); - } - - @Implementation(minSdk = VERSION_CODES.LOLLIPOP) + @Implementation protected static void nativeDestroy(long obj) { Registries.NATIVE_RES_XML_TREES.unregister(obj); } diff --git a/shadows/framework/src/main/java/org/robolectric/shadows/_Activity_.java b/shadows/framework/src/main/java/org/robolectric/shadows/_Activity_.java index fcfcfda7c..d638630ca 100644 --- a/shadows/framework/src/main/java/org/robolectric/shadows/_Activity_.java +++ b/shadows/framework/src/main/java/org/robolectric/shadows/_Activity_.java @@ -28,23 +28,6 @@ public interface _Activity_ { @Accessor("mToken") IBinder getToken(); - // == KITKAT: - void attach( - Context context, - ActivityThread activityThread, - Instrumentation instrumentation, - IBinder token, - int ident, - Application application, - Intent intent, - ActivityInfo activityInfo, - CharSequence title, - Activity parent, - String id, - @WithType("android.app.Activity$NonConfigurationInstances") - Object lastNonConfigurationInstances, - Configuration configuration); - // <= LOLLIPOP: void attach( Context context, @@ -181,22 +164,7 @@ public interface _Activity_ { @WithType("android.app.Activity$NonConfigurationInstances") Object lastNonConfigurationInstances) { int apiLevel = RuntimeEnvironment.getApiLevel(); - if (apiLevel == Build.VERSION_CODES.KITKAT) { - attach( - baseContext, - activityThread, - instrumentation, - token, - 0, - application, - intent, - activityInfo, - activityTitle, - null, - null, - lastNonConfigurationInstances, - application.getResources().getConfiguration()); - } else if (apiLevel <= Build.VERSION_CODES.LOLLIPOP) { + if (apiLevel <= Build.VERSION_CODES.LOLLIPOP) { attach( baseContext, activityThread, |