aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAng Li <ihcinihsdk@google.com>2024-04-30 21:43:17 +0000
committerGerrit Code Review <noreply-gerritcodereview@google.com>2024-04-30 21:43:17 +0000
commitd3e156a92402a9bce9c30208b5d4d1358fad7f09 (patch)
treede0add2084b66cb8d22ddfce9c2841fb367f49e0
parent9201ec4b504ddb37e398e795810f3aa5be946aae (diff)
parent92d9656de1354daa51c408a95c62caf69dbc6628 (diff)
downloadrobolectric-d3e156a92402a9bce9c30208b5d4d1358fad7f09.tar.gz
Merge "Merge branch 'upstream-google' into merge_upstream" into main
-rw-r--r--.github/workflows/tests.yml2
-rw-r--r--README.md2
-rw-r--r--buildSrc/src/main/groovy/AndroidSdk.groovy2
-rw-r--r--integration_tests/androidx_test/src/sharedTest/java/org/robolectric/integrationtests/axt/EspressoTest.java5
-rw-r--r--integration_tests/ctesque/src/sharedTest/java/android/content/res/ResourcesTest.java27
-rw-r--r--integration_tests/ctesque/src/sharedTest/java/android/database/SQLiteDatabaseTest.java8
-rw-r--r--integration_tests/ctesque/src/sharedTest/java/android/graphics/BitmapTest.java3
-rw-r--r--integration_tests/ctesque/src/sharedTest/java/android/util/RationalTest.java3
-rw-r--r--integration_tests/ctesque/src/sharedTest/java/android/view/ViewConfigurationTest.java68
-rw-r--r--integration_tests/dependency-on-stubs/src/test/java/org/robolectric/LoadWeirdClassesTest.java3
-rw-r--r--integration_tests/nativegraphics/src/test/java/org/robolectric/integrationtests/nativegraphics/HardwareAcceleratedActivityRenderTest.java66
-rw-r--r--integration_tests/nativegraphics/src/test/java/org/robolectric/integrationtests/nativegraphics/ShadowNativeHardwareRendererTest.java46
-rw-r--r--junit/src/main/java/org/robolectric/internal/SandboxTestRunner.java32
-rw-r--r--nativeruntime/src/test/java/org/robolectric/nativeruntime/DefaultNativeRuntimeLazyLoadTest.java3
-rw-r--r--resources/src/main/java/org/robolectric/manifest/AndroidManifest.java6
-rw-r--r--robolectric/src/main/java/org/robolectric/android/internal/AndroidTestEnvironment.java29
-rw-r--r--robolectric/src/main/java/org/robolectric/plugins/DefaultSdkProvider.java2
-rw-r--r--robolectric/src/test/java/org/robolectric/QualifiersTest.java4
-rw-r--r--robolectric/src/test/java/org/robolectric/RobolectricTestRunnerMultiApiTest.java10
-rw-r--r--robolectric/src/test/java/org/robolectric/RobolectricTestRunnerTest.java20
-rw-r--r--robolectric/src/test/java/org/robolectric/android/BootstrapTest.java8
-rw-r--r--robolectric/src/test/java/org/robolectric/android/DrawableResourceLoaderTest.java9
-rw-r--r--robolectric/src/test/java/org/robolectric/android/ResourceTableFactoryIntegrationTest.java3
-rw-r--r--robolectric/src/test/java/org/robolectric/manifest/AndroidManifestTest.java6
-rw-r--r--robolectric/src/test/java/org/robolectric/res/StyleResourceLoaderTest.java4
-rw-r--r--robolectric/src/test/java/org/robolectric/shadows/CompatibilityTest.java8
-rw-r--r--robolectric/src/test/java/org/robolectric/shadows/MediaCodecInfoBuilderTest.java3
-rw-r--r--robolectric/src/test/java/org/robolectric/shadows/PlaybackInfoBuilderTest.java3
-rw-r--r--robolectric/src/test/java/org/robolectric/shadows/ShadowAccessibilityNodeInfoTest.java2
-rw-r--r--robolectric/src/test/java/org/robolectric/shadows/ShadowAccessibilityServiceTest.java39
-rw-r--r--robolectric/src/test/java/org/robolectric/shadows/ShadowAccessibilityWindowInfoTest.java3
-rw-r--r--robolectric/src/test/java/org/robolectric/shadows/ShadowAccountManagerTest.java2
-rw-r--r--robolectric/src/test/java/org/robolectric/shadows/ShadowActivityManagerTest.java2
-rw-r--r--robolectric/src/test/java/org/robolectric/shadows/ShadowActivityTest.java3
-rw-r--r--robolectric/src/test/java/org/robolectric/shadows/ShadowAlarmManagerTest.java2
-rw-r--r--robolectric/src/test/java/org/robolectric/shadows/ShadowAlertDialogTest.java3
-rw-r--r--robolectric/src/test/java/org/robolectric/shadows/ShadowAppOpsManagerTest.java1
-rw-r--r--robolectric/src/test/java/org/robolectric/shadows/ShadowAppTaskTest.java3
-rw-r--r--robolectric/src/test/java/org/robolectric/shadows/ShadowApplicationTest.java18
-rw-r--r--robolectric/src/test/java/org/robolectric/shadows/ShadowAudioManagerTest.java3
-rw-r--r--robolectric/src/test/java/org/robolectric/shadows/ShadowAudioRecordTest.java2
-rw-r--r--robolectric/src/test/java/org/robolectric/shadows/ShadowAudioTrackTest.java2
-rw-r--r--robolectric/src/test/java/org/robolectric/shadows/ShadowBackupDataInputTest.java3
-rw-r--r--robolectric/src/test/java/org/robolectric/shadows/ShadowBackupDataOutputTest.java3
-rw-r--r--robolectric/src/test/java/org/robolectric/shadows/ShadowBackupManagerTest.java5
-rw-r--r--robolectric/src/test/java/org/robolectric/shadows/ShadowBatteryManagerTest.java2
-rw-r--r--robolectric/src/test/java/org/robolectric/shadows/ShadowBluetoothAdapterTest.java4
-rw-r--r--robolectric/src/test/java/org/robolectric/shadows/ShadowBluetoothDeviceTest.java3
-rw-r--r--robolectric/src/test/java/org/robolectric/shadows/ShadowBluetoothLeScannerTest.java2
-rw-r--r--robolectric/src/test/java/org/robolectric/shadows/ShadowCallTest.java1
-rw-r--r--robolectric/src/test/java/org/robolectric/shadows/ShadowConnectivityManagerTest.java24
-rw-r--r--robolectric/src/test/java/org/robolectric/shadows/ShadowContextImplTest.java4
-rw-r--r--robolectric/src/test/java/org/robolectric/shadows/ShadowCookieManagerTest.java8
-rw-r--r--robolectric/src/test/java/org/robolectric/shadows/ShadowDebugTest.java2
-rw-r--r--robolectric/src/test/java/org/robolectric/shadows/ShadowDevicePolicyManagerTest.java50
-rw-r--r--robolectric/src/test/java/org/robolectric/shadows/ShadowDisplayTest.java4
-rw-r--r--robolectric/src/test/java/org/robolectric/shadows/ShadowDrawableTest.java13
-rw-r--r--robolectric/src/test/java/org/robolectric/shadows/ShadowEnvironmentTest.java6
-rw-r--r--robolectric/src/test/java/org/robolectric/shadows/ShadowICUTest.java9
-rw-r--r--robolectric/src/test/java/org/robolectric/shadows/ShadowJobSchedulerTest.java2
-rw-r--r--robolectric/src/test/java/org/robolectric/shadows/ShadowJobServiceTest.java2
-rw-r--r--robolectric/src/test/java/org/robolectric/shadows/ShadowLegacyMessageTest.java21
-rw-r--r--robolectric/src/test/java/org/robolectric/shadows/ShadowLocaleDataTest.java2
-rw-r--r--robolectric/src/test/java/org/robolectric/shadows/ShadowMatrixTest.java3
-rw-r--r--robolectric/src/test/java/org/robolectric/shadows/ShadowMediaCodecTest.java12
-rw-r--r--robolectric/src/test/java/org/robolectric/shadows/ShadowMediaControllerTest.java17
-rw-r--r--robolectric/src/test/java/org/robolectric/shadows/ShadowMediaMuxerTest.java5
-rw-r--r--robolectric/src/test/java/org/robolectric/shadows/ShadowNetworkCapabilitiesTest.java2
-rw-r--r--robolectric/src/test/java/org/robolectric/shadows/ShadowNetworkScoreManagerTest.java4
-rw-r--r--robolectric/src/test/java/org/robolectric/shadows/ShadowNetworkTest.java2
-rw-r--r--robolectric/src/test/java/org/robolectric/shadows/ShadowOsConstantsTest.java4
-rw-r--r--robolectric/src/test/java/org/robolectric/shadows/ShadowOutlineTest.java3
-rw-r--r--robolectric/src/test/java/org/robolectric/shadows/ShadowPackageInstallerTest.java2
-rw-r--r--robolectric/src/test/java/org/robolectric/shadows/ShadowPackageManagerTest.java21
-rw-r--r--robolectric/src/test/java/org/robolectric/shadows/ShadowParcelTest.java4
-rw-r--r--robolectric/src/test/java/org/robolectric/shadows/ShadowPausedMessageQueueTest.java2
-rw-r--r--robolectric/src/test/java/org/robolectric/shadows/ShadowPorterDuffColorFilterTest.java2
-rw-r--r--robolectric/src/test/java/org/robolectric/shadows/ShadowPosixTest.java5
-rw-r--r--robolectric/src/test/java/org/robolectric/shadows/ShadowPowerManagerTest.java4
-rw-r--r--robolectric/src/test/java/org/robolectric/shadows/ShadowRankingTest.java1
-rw-r--r--robolectric/src/test/java/org/robolectric/shadows/ShadowRenderNodeAnimatorTest.java3
-rw-r--r--robolectric/src/test/java/org/robolectric/shadows/ShadowRenderNodeTest.java3
-rw-r--r--robolectric/src/test/java/org/robolectric/shadows/ShadowRestrictionsManagerTest.java3
-rw-r--r--robolectric/src/test/java/org/robolectric/shadows/ShadowSQLiteConnectionTest.java6
-rw-r--r--robolectric/src/test/java/org/robolectric/shadows/ShadowSettingsTest.java30
-rw-r--r--robolectric/src/test/java/org/robolectric/shadows/ShadowSmsManagerTest.java8
-rw-r--r--robolectric/src/test/java/org/robolectric/shadows/ShadowSoundPoolTest.java2
-rw-r--r--robolectric/src/test/java/org/robolectric/shadows/ShadowSurfaceTextureTest.java3
-rw-r--r--robolectric/src/test/java/org/robolectric/shadows/ShadowTelecomManagerTest.java2
-rw-r--r--robolectric/src/test/java/org/robolectric/shadows/ShadowTelephonyManagerTest.java18
-rw-r--r--robolectric/src/test/java/org/robolectric/shadows/ShadowTextToSpeechTest.java14
-rw-r--r--robolectric/src/test/java/org/robolectric/shadows/ShadowTimeTest.java17
-rw-r--r--robolectric/src/test/java/org/robolectric/shadows/ShadowTransportControlsTest.java11
-rw-r--r--robolectric/src/test/java/org/robolectric/shadows/ShadowTypefaceTest.java4
-rw-r--r--robolectric/src/test/java/org/robolectric/shadows/ShadowUsageStatsManagerTest.java2
-rw-r--r--robolectric/src/test/java/org/robolectric/shadows/ShadowUsbDeviceConnectionTest.java7
-rw-r--r--robolectric/src/test/java/org/robolectric/shadows/ShadowUsbRequestTest.java2
-rw-r--r--robolectric/src/test/java/org/robolectric/shadows/ShadowUserManagerTest.java10
-rw-r--r--robolectric/src/test/java/org/robolectric/shadows/ShadowViewConfigurationTest.java61
-rw-r--r--robolectric/src/test/java/org/robolectric/shadows/ShadowViewTest.java6
-rw-r--r--robolectric/src/test/java/org/robolectric/shadows/ShadowWifiInfoTest.java3
-rw-r--r--robolectric/src/test/java/org/robolectric/shadows/ShadowWifiManagerTest.java1
-rw-r--r--robolectric/src/test/java/org/robolectric/shadows/ShadowWindowManagerGlobalTest.java9
-rw-r--r--scripts/README.md12
-rw-r--r--shadows/framework/src/main/java/org/robolectric/RuntimeEnvironment.java11
-rw-r--r--shadows/framework/src/main/java/org/robolectric/android/internal/DisplayConfig.java17
-rw-r--r--shadows/framework/src/main/java/org/robolectric/shadows/CellInfoLteBuilder.java10
-rw-r--r--shadows/framework/src/main/java/org/robolectric/shadows/LegacyManifestParser.java8
-rw-r--r--shadows/framework/src/main/java/org/robolectric/shadows/MediaCodecInfoBuilder.java5
-rw-r--r--shadows/framework/src/main/java/org/robolectric/shadows/PreLPointers.java38
-rw-r--r--shadows/framework/src/main/java/org/robolectric/shadows/ShadowAccessibilityNodeInfo.java21
-rw-r--r--shadows/framework/src/main/java/org/robolectric/shadows/ShadowAccessibilityService.java3
-rw-r--r--shadows/framework/src/main/java/org/robolectric/shadows/ShadowAccessibilityWindowInfo.java3
-rw-r--r--shadows/framework/src/main/java/org/robolectric/shadows/ShadowAccountManager.java7
-rw-r--r--shadows/framework/src/main/java/org/robolectric/shadows/ShadowActivity.java7
-rw-r--r--shadows/framework/src/main/java/org/robolectric/shadows/ShadowActivityManager.java5
-rw-r--r--shadows/framework/src/main/java/org/robolectric/shadows/ShadowAlarmManager.java16
-rw-r--r--shadows/framework/src/main/java/org/robolectric/shadows/ShadowAlertController.java3
-rw-r--r--shadows/framework/src/main/java/org/robolectric/shadows/ShadowAlwaysOnHotwordDetector.java4
-rw-r--r--shadows/framework/src/main/java/org/robolectric/shadows/ShadowAppOpsManager.java3
-rw-r--r--shadows/framework/src/main/java/org/robolectric/shadows/ShadowAppTask.java3
-rw-r--r--shadows/framework/src/main/java/org/robolectric/shadows/ShadowAppWidgetManager.java9
-rw-r--r--shadows/framework/src/main/java/org/robolectric/shadows/ShadowApplicationPackageManager.java35
-rw-r--r--shadows/framework/src/main/java/org/robolectric/shadows/ShadowArscAssetInputStream.java10
-rw-r--r--shadows/framework/src/main/java/org/robolectric/shadows/ShadowArscAssetManager.java173
-rw-r--r--shadows/framework/src/main/java/org/robolectric/shadows/ShadowAudioManager.java3
-rw-r--r--shadows/framework/src/main/java/org/robolectric/shadows/ShadowAudioRecord.java3
-rw-r--r--shadows/framework/src/main/java/org/robolectric/shadows/ShadowAudioTrack.java3
-rw-r--r--shadows/framework/src/main/java/org/robolectric/shadows/ShadowBackupDataInput.java3
-rw-r--r--shadows/framework/src/main/java/org/robolectric/shadows/ShadowBackupDataOutput.java3
-rw-r--r--shadows/framework/src/main/java/org/robolectric/shadows/ShadowBackupManager.java5
-rw-r--r--shadows/framework/src/main/java/org/robolectric/shadows/ShadowBatteryManager.java5
-rw-r--r--shadows/framework/src/main/java/org/robolectric/shadows/ShadowBitmapRegionDecoder.java11
-rw-r--r--shadows/framework/src/main/java/org/robolectric/shadows/ShadowBluetoothAdapter.java5
-rw-r--r--shadows/framework/src/main/java/org/robolectric/shadows/ShadowBluetoothDevice.java3
-rw-r--r--shadows/framework/src/main/java/org/robolectric/shadows/ShadowBluetoothGatt.java9
-rw-r--r--shadows/framework/src/main/java/org/robolectric/shadows/ShadowBluetoothLeScanner.java3
-rw-r--r--shadows/framework/src/main/java/org/robolectric/shadows/ShadowCall.java2
-rw-r--r--shadows/framework/src/main/java/org/robolectric/shadows/ShadowCameraCaptureSessionImpl.java1
-rw-r--r--shadows/framework/src/main/java/org/robolectric/shadows/ShadowCameraCharacteristics.java3
-rw-r--r--shadows/framework/src/main/java/org/robolectric/shadows/ShadowCameraManager.java4
-rw-r--r--shadows/framework/src/main/java/org/robolectric/shadows/ShadowCameraMetadataNative.java4
-rw-r--r--shadows/framework/src/main/java/org/robolectric/shadows/ShadowCompatibility.java20
-rw-r--r--shadows/framework/src/main/java/org/robolectric/shadows/ShadowConnectivityManager.java27
-rw-r--r--shadows/framework/src/main/java/org/robolectric/shadows/ShadowContextImpl.java5
-rw-r--r--shadows/framework/src/main/java/org/robolectric/shadows/ShadowDatePickerDialog.java17
-rw-r--r--shadows/framework/src/main/java/org/robolectric/shadows/ShadowDebug.java6
-rw-r--r--shadows/framework/src/main/java/org/robolectric/shadows/ShadowDevicePolicyManager.java53
-rw-r--r--shadows/framework/src/main/java/org/robolectric/shadows/ShadowDisplayEventReceiver.java27
-rw-r--r--shadows/framework/src/main/java/org/robolectric/shadows/ShadowDisplayManager.java4
-rw-r--r--shadows/framework/src/main/java/org/robolectric/shadows/ShadowEnvironment.java13
-rw-r--r--shadows/framework/src/main/java/org/robolectric/shadows/ShadowICU.java9
-rw-r--r--shadows/framework/src/main/java/org/robolectric/shadows/ShadowInCallAdapter.java3
-rw-r--r--shadows/framework/src/main/java/org/robolectric/shadows/ShadowInstrumentation.java1
-rw-r--r--shadows/framework/src/main/java/org/robolectric/shadows/ShadowKeyCharacterMap.java41
-rw-r--r--shadows/framework/src/main/java/org/robolectric/shadows/ShadowLegacyAssetManager.java132
-rw-r--r--shadows/framework/src/main/java/org/robolectric/shadows/ShadowLegacyCanvas.java41
-rw-r--r--shadows/framework/src/main/java/org/robolectric/shadows/ShadowLegacyCursorWindow.java119
-rw-r--r--shadows/framework/src/main/java/org/robolectric/shadows/ShadowLegacyMatrix.java3
-rw-r--r--shadows/framework/src/main/java/org/robolectric/shadows/ShadowLegacyMessage.java29
-rw-r--r--shadows/framework/src/main/java/org/robolectric/shadows/ShadowLegacyMessageQueue.java17
-rw-r--r--shadows/framework/src/main/java/org/robolectric/shadows/ShadowLegacyPath.java15
-rw-r--r--shadows/framework/src/main/java/org/robolectric/shadows/ShadowLegacySQLiteConnection.java198
-rw-r--r--shadows/framework/src/main/java/org/robolectric/shadows/ShadowLegacyTypeface.java15
-rw-r--r--shadows/framework/src/main/java/org/robolectric/shadows/ShadowLocaleData.java10
-rw-r--r--shadows/framework/src/main/java/org/robolectric/shadows/ShadowLocationManager.java6
-rw-r--r--shadows/framework/src/main/java/org/robolectric/shadows/ShadowMediaCodec.java52
-rw-r--r--shadows/framework/src/main/java/org/robolectric/shadows/ShadowMediaRecorder.java3
-rw-r--r--shadows/framework/src/main/java/org/robolectric/shadows/ShadowMotionEvent.java347
-rw-r--r--shadows/framework/src/main/java/org/robolectric/shadows/ShadowNativeBaseRecordingCanvas.java1
-rw-r--r--shadows/framework/src/main/java/org/robolectric/shadows/ShadowNativeBitmap.java27
-rw-r--r--shadows/framework/src/main/java/org/robolectric/shadows/ShadowNativeBitmapFactory.java3
-rw-r--r--shadows/framework/src/main/java/org/robolectric/shadows/ShadowNativeCursorWindow.java127
-rw-r--r--shadows/framework/src/main/java/org/robolectric/shadows/ShadowNativeMatrix.java3
-rw-r--r--shadows/framework/src/main/java/org/robolectric/shadows/ShadowNativePluralRules.java7
-rw-r--r--shadows/framework/src/main/java/org/robolectric/shadows/ShadowNativeSQLiteConnection.java198
-rw-r--r--shadows/framework/src/main/java/org/robolectric/shadows/ShadowNativeSurface.java6
-rw-r--r--shadows/framework/src/main/java/org/robolectric/shadows/ShadowNativeTypeface.java9
-rw-r--r--shadows/framework/src/main/java/org/robolectric/shadows/ShadowPackageInstaller.java5
-rw-r--r--shadows/framework/src/main/java/org/robolectric/shadows/ShadowPaint.java96
-rw-r--r--shadows/framework/src/main/java/org/robolectric/shadows/ShadowParcel.java254
-rw-r--r--shadows/framework/src/main/java/org/robolectric/shadows/ShadowPausedMessage.java2
-rw-r--r--shadows/framework/src/main/java/org/robolectric/shadows/ShadowPausedMessageQueue.java53
-rw-r--r--shadows/framework/src/main/java/org/robolectric/shadows/ShadowPicture.java10
-rw-r--r--shadows/framework/src/main/java/org/robolectric/shadows/ShadowPorterDuffColorFilter.java27
-rw-r--r--shadows/framework/src/main/java/org/robolectric/shadows/ShadowPowerManager.java7
-rw-r--r--shadows/framework/src/main/java/org/robolectric/shadows/ShadowRanking.java3
-rw-r--r--shadows/framework/src/main/java/org/robolectric/shadows/ShadowRegion.java5
-rw-r--r--shadows/framework/src/main/java/org/robolectric/shadows/ShadowRenderNodeAnimator.java3
-rw-r--r--shadows/framework/src/main/java/org/robolectric/shadows/ShadowResources.java12
-rw-r--r--shadows/framework/src/main/java/org/robolectric/shadows/ShadowSettings.java10
-rw-r--r--shadows/framework/src/main/java/org/robolectric/shadows/ShadowSmsManager.java5
-rw-r--r--shadows/framework/src/main/java/org/robolectric/shadows/ShadowStaticLayout.java3
-rw-r--r--shadows/framework/src/main/java/org/robolectric/shadows/ShadowStringBlock.java31
-rw-r--r--shadows/framework/src/main/java/org/robolectric/shadows/ShadowSurface.java12
-rw-r--r--shadows/framework/src/main/java/org/robolectric/shadows/ShadowSystemVibrator.java28
-rw-r--r--shadows/framework/src/main/java/org/robolectric/shadows/ShadowTelephonyManager.java27
-rw-r--r--shadows/framework/src/main/java/org/robolectric/shadows/ShadowTextToSpeech.java8
-rw-r--r--shadows/framework/src/main/java/org/robolectric/shadows/ShadowTime.java384
-rw-r--r--shadows/framework/src/main/java/org/robolectric/shadows/ShadowUsbDeviceConnection.java3
-rw-r--r--shadows/framework/src/main/java/org/robolectric/shadows/ShadowUserManager.java10
-rw-r--r--shadows/framework/src/main/java/org/robolectric/shadows/ShadowVMRuntime.java6
-rw-r--r--shadows/framework/src/main/java/org/robolectric/shadows/ShadowView.java12
-rw-r--r--shadows/framework/src/main/java/org/robolectric/shadows/ShadowViewConfiguration.java94
-rw-r--r--shadows/framework/src/main/java/org/robolectric/shadows/ShadowViewRootImpl.java22
-rw-r--r--shadows/framework/src/main/java/org/robolectric/shadows/ShadowVirtualRefBasePtr.java5
-rw-r--r--shadows/framework/src/main/java/org/robolectric/shadows/ShadowWifiInfo.java3
-rw-r--r--shadows/framework/src/main/java/org/robolectric/shadows/ShadowWifiManager.java5
-rw-r--r--shadows/framework/src/main/java/org/robolectric/shadows/ShadowWindowManagerGlobal.java7
-rw-r--r--shadows/framework/src/main/java/org/robolectric/shadows/ShadowWindowManagerImpl.java6
-rw-r--r--shadows/framework/src/main/java/org/robolectric/shadows/ShadowXmlBlock.java157
-rw-r--r--shadows/framework/src/main/java/org/robolectric/shadows/_Activity_.java34
212 files changed, 995 insertions, 3379 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/README.md b/README.md
index faa46f7a5..8138b804d 100644
--- a/README.md
+++ b/README.md
@@ -5,7 +5,7 @@
Robolectric is the industry-standard unit testing framework for Android. With Robolectric, your tests run in a simulated Android environment inside a JVM, without the overhead and flakiness of an emulator. Robolectric tests routinely run 10x faster than those on cold-started emulators.
-Robolectric supports running unit tests for *15* different versions of Android, ranging from KitKat (API level 19) to U (API level 34).
+Robolectric supports running unit tests for *14* different versions of Android, ranging from Lollipop (API level 21) to U (API level 34).
## Usage
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 a00f2bc86..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");
@@ -771,9 +762,6 @@ public class ResourcesTest {
// }
@Test
- @SdkSuppress(minSdkVersion = LOLLIPOP)
- @Config(minSdk = LOLLIPOP)
- // TODO (b/330075029): Remove this once it is fixed in K or we have disabled K's support.
public void obtainStyledAttributes_shouldCheckXmlFirst_fromXmlLoadedFromResources() throws Exception {
// This simulates a ResourceProvider built from a 21+ SDK as viewportHeight / viewportWidth were introduced in API 21
@@ -796,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/ctesque/src/sharedTest/java/android/util/RationalTest.java b/integration_tests/ctesque/src/sharedTest/java/android/util/RationalTest.java
index 69a088b31..46565be13 100644
--- a/integration_tests/ctesque/src/sharedTest/java/android/util/RationalTest.java
+++ b/integration_tests/ctesque/src/sharedTest/java/android/util/RationalTest.java
@@ -29,7 +29,6 @@ import static org.junit.Assert.assertFalse;
import static org.junit.Assert.assertTrue;
import static org.junit.Assert.fail;
-import android.os.Build;
import androidx.test.ext.junit.runners.AndroidJUnit4;
import java.io.ByteArrayInputStream;
import java.io.ByteArrayOutputStream;
@@ -41,11 +40,9 @@ import java.io.Serializable;
import java.lang.reflect.Field;
import org.junit.Test;
import org.junit.runner.RunWith;
-import org.robolectric.annotation.Config;
import org.robolectric.annotation.internal.DoNotInstrument;
@DoNotInstrument
-@Config(minSdk = Build.VERSION_CODES.LOLLIPOP)
@RunWith(AndroidJUnit4.class)
public class RationalTest {
diff --git a/integration_tests/ctesque/src/sharedTest/java/android/view/ViewConfigurationTest.java b/integration_tests/ctesque/src/sharedTest/java/android/view/ViewConfigurationTest.java
new file mode 100644
index 000000000..a490b5842
--- /dev/null
+++ b/integration_tests/ctesque/src/sharedTest/java/android/view/ViewConfigurationTest.java
@@ -0,0 +1,68 @@
+package android.view;
+
+import static android.os.Build.VERSION_CODES.O_MR1;
+import static com.google.common.truth.Truth.assertThat;
+
+import android.os.Build;
+import androidx.test.core.app.ApplicationProvider;
+import androidx.test.ext.junit.runners.AndroidJUnit4;
+import java.lang.reflect.Method;
+import org.junit.Before;
+import org.junit.Test;
+import org.junit.runner.RunWith;
+import org.robolectric.annotation.Config;
+import org.robolectric.annotation.internal.DoNotInstrument;
+
+/** Tests that {@link android.view.ViewConfiguration} behavior is consistent with real Android. */
+@DoNotInstrument
+@RunWith(AndroidJUnit4.class)
+public final class ViewConfigurationTest {
+
+ private float density;
+ private ViewConfiguration viewConfiguration;
+
+ @Before
+ public void setUp() {
+ density =
+ ApplicationProvider.getApplicationContext().getResources().getDisplayMetrics().density;
+ viewConfiguration = ViewConfiguration.get(ApplicationProvider.getApplicationContext());
+ }
+
+ @Test
+ public void scrollbar_configuration() {
+ int scrollBarSize = ViewConfiguration.getScrollBarSize();
+ int scaledScrollBarSizeDp = pxToDp(viewConfiguration.getScaledScrollBarSize());
+ if (Build.VERSION.SDK_INT >= O_MR1) {
+ assertThat(scrollBarSize).isEqualTo(4);
+ assertThat(scaledScrollBarSizeDp).isEqualTo(4);
+ } else {
+ assertThat(scrollBarSize).isEqualTo(10);
+ assertThat(scaledScrollBarSizeDp).isEqualTo(10);
+ }
+ }
+
+ @Test
+ public void isFadingMarqueeEnabled_returnsFalse() throws Exception {
+ // isFadingMarqueeEnabled is a '@hide' method.
+ boolean isFadingMarqueeEnabled =
+ callMethod(viewConfiguration, "isFadingMarqueeEnabled", Boolean.class);
+ assertThat(isFadingMarqueeEnabled).isFalse();
+ }
+
+ // Emulators have hdpi density by default, so match this in Robolectric for consistency.
+ @Config(qualifiers = "hdpi")
+ @Test
+ public void overfling_distance() {
+ assertThat(density).isEqualTo(1.5f);
+ assertThat(viewConfiguration.getScaledOverflingDistance()).isEqualTo(9);
+ }
+
+ public int pxToDp(int px) {
+ return Math.round(px / density);
+ }
+
+ public <T> T callMethod(Object obj, String methodName, Class<T> returnType) throws Exception {
+ Method method = obj.getClass().getMethod(methodName);
+ return returnType.cast(method.invoke(obj));
+ }
+}
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/integration_tests/nativegraphics/src/test/java/org/robolectric/integrationtests/nativegraphics/HardwareAcceleratedActivityRenderTest.java b/integration_tests/nativegraphics/src/test/java/org/robolectric/integrationtests/nativegraphics/HardwareAcceleratedActivityRenderTest.java
index 3828aa087..7f8e26578 100644
--- a/integration_tests/nativegraphics/src/test/java/org/robolectric/integrationtests/nativegraphics/HardwareAcceleratedActivityRenderTest.java
+++ b/integration_tests/nativegraphics/src/test/java/org/robolectric/integrationtests/nativegraphics/HardwareAcceleratedActivityRenderTest.java
@@ -1,29 +1,73 @@
package org.robolectric.integrationtests.nativegraphics;
import static android.os.Build.VERSION_CODES.S;
+import static com.google.common.truth.Truth.assertThat;
import android.app.Activity;
+import android.graphics.Bitmap;
+import android.graphics.Color;
+import android.os.Bundle;
+import android.os.Handler;
+import android.os.Looper;
+import android.view.PixelCopy;
+import android.view.View;
+import android.view.ViewGroup.LayoutParams;
+import android.view.Window;
import android.view.WindowManager;
+import android.widget.FrameLayout;
+import java.util.concurrent.CountDownLatch;
+import java.util.concurrent.TimeUnit;
import org.junit.Test;
import org.junit.runner.RunWith;
import org.robolectric.Robolectric;
import org.robolectric.RobolectricTestRunner;
-import org.robolectric.android.controller.ActivityController;
import org.robolectric.annotation.Config;
@RunWith(RobolectricTestRunner.class)
@Config(minSdk = S)
public class HardwareAcceleratedActivityRenderTest {
@Test
- public void setupHardwareAcceleratedActivity() {
- // This will exercise much of the HardwareRenderer / RenderNode / RecordingCanvas native code.
- ActivityController<Activity> controller = Robolectric.buildActivity(Activity.class);
- controller
- .get()
- .getWindow()
- .setFlags(
- WindowManager.LayoutParams.FLAG_HARDWARE_ACCELERATED,
- WindowManager.LayoutParams.FLAG_HARDWARE_ACCELERATED);
- controller.setup();
+ public void hardwareAcceleratedActivity_setup() throws Exception {
+ // Setting up an Activity is a smoke test that exercises much of the HardwareRenderer /
+ // RenderNode / RecordingCanvas native code.
+ Robolectric.setupActivity(HardwareAcceleratedActivity.class);
+ }
+
+ @Test
+ public void hardwareAcceleratedActivity_pixelCopy() throws Exception {
+ System.setProperty("robolectric.pixelCopyRenderMode", "hardware");
+ try {
+ HardwareAcceleratedActivity activity =
+ Robolectric.setupActivity(HardwareAcceleratedActivity.class);
+ Window window = activity.getWindow();
+ View decorView = window.getDecorView();
+ Bitmap bitmap =
+ Bitmap.createBitmap(decorView.getWidth(), decorView.getHeight(), Bitmap.Config.ARGB_8888);
+ CountDownLatch latch = new CountDownLatch(1);
+ PixelCopy.request(
+ window, bitmap, copyResult -> latch.countDown(), new Handler(Looper.getMainLooper()));
+ latch.await(1, TimeUnit.SECONDS);
+ assertThat(bitmap.getPixel(100, 100)).isEqualTo(Color.RED);
+ } finally {
+ System.clearProperty("robolectric.pixelCopyRenderMode");
+ }
+ }
+
+ static class HardwareAcceleratedActivity extends Activity {
+ @Override
+ public void onCreate(Bundle savedInstanceState) {
+ super.onCreate(savedInstanceState);
+ // TODO(hoisie): manually setting these flags should not be required. Robolectric should
+ // set them automatically by default (they have been default since ICS).
+ getWindow()
+ .setFlags(
+ WindowManager.LayoutParams.FLAG_HARDWARE_ACCELERATED,
+ WindowManager.LayoutParams.FLAG_HARDWARE_ACCELERATED);
+ FrameLayout frameLayout = new FrameLayout(this);
+ frameLayout.setLayoutParams(
+ new LayoutParams(LayoutParams.MATCH_PARENT, LayoutParams.MATCH_PARENT));
+ frameLayout.setBackgroundColor(Color.RED);
+ setContentView(frameLayout);
+ }
}
}
diff --git a/integration_tests/nativegraphics/src/test/java/org/robolectric/integrationtests/nativegraphics/ShadowNativeHardwareRendererTest.java b/integration_tests/nativegraphics/src/test/java/org/robolectric/integrationtests/nativegraphics/ShadowNativeHardwareRendererTest.java
index 2b6c48d7b..89d8e675c 100644
--- a/integration_tests/nativegraphics/src/test/java/org/robolectric/integrationtests/nativegraphics/ShadowNativeHardwareRendererTest.java
+++ b/integration_tests/nativegraphics/src/test/java/org/robolectric/integrationtests/nativegraphics/ShadowNativeHardwareRendererTest.java
@@ -1,9 +1,21 @@
package org.robolectric.integrationtests.nativegraphics;
import static android.os.Build.VERSION_CODES.Q;
+import static android.os.Build.VERSION_CODES.S;
+import static com.google.common.truth.Truth.assertThat;
+import android.graphics.Bitmap;
+import android.graphics.Color;
import android.graphics.HardwareRenderer;
+import android.graphics.Paint;
+import android.graphics.PixelFormat;
+import android.graphics.RecordingCanvas;
+import android.graphics.RenderNode;
+import android.media.Image;
+import android.media.Image.Plane;
+import android.media.ImageReader;
import android.view.Choreographer;
+import android.view.Surface;
import org.junit.Test;
import org.junit.runner.RunWith;
import org.robolectric.RobolectricTestRunner;
@@ -24,4 +36,38 @@ public class ShadowNativeHardwareRendererTest {
// HardwareRenderer.nHackySetRTAnimationsEnabled. Ensure that RNG is loaded if this happens.
var unused = Choreographer.getInstance();
}
+
+ @Test
+ @Config(minSdk = S)
+ public void imageReader_readsRenderedDisplayList() {
+ int width = 100;
+ int height = 100;
+
+ try (ImageReader imageReader =
+ ImageReader.newInstance(width, height, PixelFormat.RGBA_8888, 1)) {
+ HardwareRenderer renderer = new HardwareRenderer();
+ RenderNode displayList = createDisplayList(width, height);
+ Surface surface = imageReader.getSurface();
+ renderer.setSurface(surface);
+ Image nativeImage = imageReader.acquireNextImage();
+ renderer.setContentRoot(displayList);
+ renderer.createRenderRequest().syncAndDraw();
+ Plane[] planes = nativeImage.getPlanes();
+ Bitmap bitmap = Bitmap.createBitmap(width, height, Bitmap.Config.ARGB_8888);
+ bitmap.copyPixelsFromBuffer(planes[0].getBuffer());
+ surface.release();
+ assertThat(bitmap.getPixel(50, 50)).isEqualTo(Color.RED);
+ }
+ }
+
+ private static RenderNode createDisplayList(int width, int height) {
+ RenderNode renderNode = new RenderNode("RedNode");
+ renderNode.setPosition(0, 0, width, height);
+ RecordingCanvas canvas = renderNode.beginRecording();
+ Paint paint = new Paint();
+ paint.setColor(Color.RED);
+ canvas.drawRect(0, 0, width, height, paint);
+ renderNode.endRecording();
+ return renderNode;
+ }
}
diff --git a/junit/src/main/java/org/robolectric/internal/SandboxTestRunner.java b/junit/src/main/java/org/robolectric/internal/SandboxTestRunner.java
index 414b4108a..2821ff8bf 100644
--- a/junit/src/main/java/org/robolectric/internal/SandboxTestRunner.java
+++ b/junit/src/main/java/org/robolectric/internal/SandboxTestRunner.java
@@ -5,6 +5,7 @@ import static java.util.Arrays.stream;
import com.google.common.base.Splitter;
import java.lang.reflect.Method;
+import java.util.ArrayDeque;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.Collection;
@@ -12,6 +13,7 @@ import java.util.Collections;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
+import java.util.Queue;
import javax.annotation.Nonnull;
import org.junit.AfterClass;
import org.junit.BeforeClass;
@@ -274,6 +276,8 @@ public class SandboxTestRunner extends BlockJUnit4ClassRunner {
throw new RuntimeException(e);
}
+ Queue<Throwable> thrown = new ArrayDeque<>();
+
try {
// Only invoke @BeforeClass once per class
invokeBeforeClass(bootstrappedTestClass, sandbox);
@@ -284,20 +288,32 @@ public class SandboxTestRunner extends BlockJUnit4ClassRunner {
Statement statement =
helperTestRunner.methodBlock(new FrameworkMethod(bootstrappedMethod));
+ statement.evaluate();
+ } catch (Throwable throwable) {
+ thrown.add(throwable);
+ }
- // todo: this try/finally probably isn't right -- should mimic RunAfters? [xw]
- try {
- statement.evaluate();
- } finally {
- afterTest(method, bootstrappedMethod);
- }
+ try {
+ afterTest(method, bootstrappedMethod);
} catch (Throwable throwable) {
- throw Util.sneakyThrow(throwable);
- } finally {
+ thrown.add(throwable);
+ }
+
+ try {
Thread.currentThread().setContextClassLoader(priorContextClassLoader);
finallyAfterTest(method);
reportPerfStats(perfStatsCollector);
perfStatsCollector.reset();
+ } catch (Throwable throwable) {
+ thrown.add(throwable);
+ }
+
+ Throwable first = thrown.poll();
+ if (first != null) {
+ while (!thrown.isEmpty()) {
+ first.addSuppressed(thrown.remove());
+ }
+ throw Util.sneakyThrow(first);
}
});
}
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/resources/src/main/java/org/robolectric/manifest/AndroidManifest.java b/resources/src/main/java/org/robolectric/manifest/AndroidManifest.java
index 60f805d72..aab424ed1 100644
--- a/resources/src/main/java/org/robolectric/manifest/AndroidManifest.java
+++ b/resources/src/main/java/org/robolectric/manifest/AndroidManifest.java
@@ -614,12 +614,12 @@ public class AndroidManifest implements UsesSdk {
* <p>Note that if {@link #targetSdkVersion} isn't set, this value changes the behavior of some
* Android code (notably {@link android.content.SharedPreferences}) to emulate old bugs.
*
- * @return the minimum SDK version, or KitKat (19) by default
+ * @return the minimum SDK version, or Lollipop (21) by default
*/
@Override
public int getMinSdkVersion() {
parseAndroidManifest();
- return minSdkVersion == null ? 19 : minSdkVersion;
+ return minSdkVersion == null ? 21 : minSdkVersion;
}
/**
@@ -629,7 +629,7 @@ public class AndroidManifest implements UsesSdk {
* <p>Note that this value changes the behavior of some Android code (notably {@link
* android.content.SharedPreferences}) to emulate old bugs.
*
- * @return the target SDK version, or KitKat (19) by default
+ * @return the target SDK version, or Lollipop (21) by default
*/
@Override
public int getTargetSdkVersion() {
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 20c971652..67af1c364 100644
--- a/robolectric/src/main/java/org/robolectric/android/internal/AndroidTestEnvironment.java
+++ b/robolectric/src/main/java/org/robolectric/android/internal/AndroidTestEnvironment.java
@@ -17,7 +17,6 @@ import android.content.ComponentName;
import android.content.Context;
import android.content.IntentFilter;
import android.content.pm.ApplicationInfo;
-import android.content.pm.PackageManager;
import android.content.pm.PackageParser;
import android.content.pm.PackageParser.Package;
import android.content.res.AssetManager;
@@ -97,7 +96,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;
@@ -368,18 +366,8 @@ public class AndroidTestEnvironment implements TestEnvironment {
activityThread.getPackageInfo(applicationInfo, null, Context.CONTEXT_INCLUDE_CODE);
final _LoadedApk_ _loadedApk_ = reflector(_LoadedApk_.class, loadedApk);
- Context contextImpl;
- if (apiLevel >= VERSION_CODES.LOLLIPOP) {
- contextImpl = reflector(_ContextImpl_.class).createAppContext(activityThread, loadedApk);
- } else {
- try {
- contextImpl =
- systemContextImpl.createPackageContext(
- applicationInfo.packageName, Context.CONTEXT_INCLUDE_CODE);
- } catch (PackageManager.NameNotFoundException e) {
- throw new RuntimeException(e);
- }
- }
+ Context contextImpl =
+ reflector(_ContextImpl_.class).createAppContext(activityThread, loadedApk);
ShadowPackageManager shadowPackageManager = Shadow.extract(contextImpl.getPackageManager());
shadowPackageManager.addPackageInternal(parsedPackage);
activityThreadReflector.setInitialApplication(application);
@@ -718,17 +706,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/QualifiersTest.java b/robolectric/src/test/java/org/robolectric/QualifiersTest.java
index de99cdba4..bf2959d24 100644
--- a/robolectric/src/test/java/org/robolectric/QualifiersTest.java
+++ b/robolectric/src/test/java/org/robolectric/QualifiersTest.java
@@ -8,7 +8,6 @@ import static org.junit.Assert.fail;
import android.app.Activity;
import android.content.res.Configuration;
import android.content.res.Resources;
-import android.os.Build.VERSION_CODES;
import android.view.View;
import android.widget.TextView;
import androidx.test.ext.junit.runners.AndroidJUnit4;
@@ -97,7 +96,8 @@ public class QualifiersTest {
assertThat(resources.getConfiguration().smallestScreenWidthDp).isEqualTo(720);
}
- @Test @Config(qualifiers = "b+sr+Latn", minSdk = VERSION_CODES.LOLLIPOP)
+ @Test
+ @Config(qualifiers = "b+sr+Latn")
public void supportsBcp47() throws Exception {
assertThat(resources.getString(R.string.hello)).isEqualTo("Zdravo");
}
diff --git a/robolectric/src/test/java/org/robolectric/RobolectricTestRunnerMultiApiTest.java b/robolectric/src/test/java/org/robolectric/RobolectricTestRunnerMultiApiTest.java
index d994d8d92..38ab0da4d 100644
--- a/robolectric/src/test/java/org/robolectric/RobolectricTestRunnerMultiApiTest.java
+++ b/robolectric/src/test/java/org/robolectric/RobolectricTestRunnerMultiApiTest.java
@@ -189,8 +189,8 @@ public class RobolectricTestRunnerMultiApiTest {
assertThat(runListener.ignored).isEmpty();
// Since test method should only be run once
- int sdksInclusivelyBetweenJellyBeanMr2AndLollipop = 3;
- assertThat(runListener.finished).hasSize(sdksInclusivelyBetweenJellyBeanMr2AndLollipop);
+ int sdksInclusivelyInRange = 3;
+ assertThat(runListener.finished).hasSize(sdksInclusivelyInRange);
}
@Test
@@ -225,8 +225,8 @@ public class RobolectricTestRunnerMultiApiTest {
runner.run(runNotifier);
assertThat(runListener.ignored).isEmpty();
- int sdksInclusivelyBetweenJellyBeanMr2AndLollipop = 3;
- assertThat(runListener.finished).hasSize(sdksInclusivelyBetweenJellyBeanMr2AndLollipop);
+ int sdksInclusivelyInRange = 3;
+ assertThat(runListener.finished).hasSize(sdksInclusivelyInRange);
}
///////////////////////////
@@ -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/RobolectricTestRunnerTest.java b/robolectric/src/test/java/org/robolectric/RobolectricTestRunnerTest.java
index dfdb9d495..8bb56391a 100644
--- a/robolectric/src/test/java/org/robolectric/RobolectricTestRunnerTest.java
+++ b/robolectric/src/test/java/org/robolectric/RobolectricTestRunnerTest.java
@@ -31,6 +31,7 @@ import javax.inject.Named;
import org.junit.After;
import org.junit.AssumptionViolatedException;
import org.junit.Before;
+import org.junit.BeforeClass;
import org.junit.FixMethodOrder;
import org.junit.Ignore;
import org.junit.Test;
@@ -513,4 +514,23 @@ public class RobolectricTestRunnerTest {
events.add("failure: " + message);
}
}
+
+ @Test
+ public void shouldReportExceptionsInBeforeClass() throws Exception {
+ RobolectricTestRunner runner =
+ new SingleSdkRobolectricTestRunner(TestWithBeforeClassThatThrowsRuntimeException.class);
+ runner.run(notifier);
+ assertThat(events.get(1)).startsWith("failure: fail");
+ }
+
+ @Ignore
+ public static class TestWithBeforeClassThatThrowsRuntimeException {
+ @BeforeClass
+ public static void beforeClass() {
+ throw new RuntimeException("fail");
+ }
+
+ @Test
+ public void test() {}
+ }
}
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/android/ResourceTableFactoryIntegrationTest.java b/robolectric/src/test/java/org/robolectric/android/ResourceTableFactoryIntegrationTest.java
index d4395c5a7..f513b2f93 100644
--- a/robolectric/src/test/java/org/robolectric/android/ResourceTableFactoryIntegrationTest.java
+++ b/robolectric/src/test/java/org/robolectric/android/ResourceTableFactoryIntegrationTest.java
@@ -4,16 +4,13 @@ import static com.google.common.truth.Truth.assertThat;
import static com.google.common.truth.TruthJUnit.assume;
import static org.robolectric.shadows.ShadowAssetManager.useLegacy;
-import android.os.Build;
import androidx.test.ext.junit.runners.AndroidJUnit4;
import org.junit.Test;
import org.junit.runner.RunWith;
import org.robolectric.RuntimeEnvironment;
-import org.robolectric.annotation.Config;
import org.robolectric.res.ResName;
@RunWith(AndroidJUnit4.class)
-@Config(minSdk = Build.VERSION_CODES.LOLLIPOP)
public class ResourceTableFactoryIntegrationTest {
@Test
public void shouldIncludeStyleableAttributesThatDoNotHaveACorrespondingEntryInAttrClass() throws Exception {
diff --git a/robolectric/src/test/java/org/robolectric/manifest/AndroidManifestTest.java b/robolectric/src/test/java/org/robolectric/manifest/AndroidManifestTest.java
index e64cacd04..9c65dcf33 100644
--- a/robolectric/src/test/java/org/robolectric/manifest/AndroidManifestTest.java
+++ b/robolectric/src/test/java/org/robolectric/manifest/AndroidManifestTest.java
@@ -231,15 +231,15 @@ public class AndroidManifestTest {
assertThat(newConfigWith("minsdk7.xml", "android:minSdkVersion=\"7\"").getTargetSdkVersion())
.isEqualTo(7);
assertThat(newConfigWith("noattributes.xml", "").getTargetSdkVersion())
- .isEqualTo(VERSION_CODES.KITKAT);
+ .isEqualTo(VERSION_CODES.LOLLIPOP);
}
@Test
- public void shouldReadMinSdkVersionFromAndroidManifestOrDefaultToKitKat() throws Exception {
+ public void shouldReadMinSdkVersionFromAndroidManifestOrDefaultToLollipop() throws Exception {
assertThat(newConfigWith("minsdk17.xml", "android:minSdkVersion=\"17\"").getMinSdkVersion())
.isEqualTo(17);
assertThat(newConfigWith("noattributes.xml", "").getMinSdkVersion())
- .isEqualTo(VERSION_CODES.KITKAT);
+ .isEqualTo(VERSION_CODES.LOLLIPOP);
}
@Test
diff --git a/robolectric/src/test/java/org/robolectric/res/StyleResourceLoaderTest.java b/robolectric/src/test/java/org/robolectric/res/StyleResourceLoaderTest.java
index dc2026601..dc940d272 100644
--- a/robolectric/src/test/java/org/robolectric/res/StyleResourceLoaderTest.java
+++ b/robolectric/src/test/java/org/robolectric/res/StyleResourceLoaderTest.java
@@ -1,6 +1,6 @@
package org.robolectric.res;
-import static android.os.Build.VERSION_CODES.JELLY_BEAN;
+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.robolectric.util.TestUtil.sdkResources;
@@ -19,7 +19,7 @@ public class StyleResourceLoaderTest {
@Before
public void setUp() throws Exception {
assume().that(RuntimeEnvironment.useLegacyResources()).isTrue();
- ResourcePath resourcePath = sdkResources(JELLY_BEAN);
+ ResourcePath resourcePath = sdkResources(LOLLIPOP);
resourceTable = new ResourceTableFactory().newResourceTable("android", resourcePath);
}
diff --git a/robolectric/src/test/java/org/robolectric/shadows/CompatibilityTest.java b/robolectric/src/test/java/org/robolectric/shadows/CompatibilityTest.java
index 85621c7eb..d532dd7b7 100644
--- a/robolectric/src/test/java/org/robolectric/shadows/CompatibilityTest.java
+++ b/robolectric/src/test/java/org/robolectric/shadows/CompatibilityTest.java
@@ -10,6 +10,8 @@ import org.robolectric.RobolectricTestRunner;
import org.robolectric.annotation.Config;
import org.robolectric.annotation.experimental.LazyApplication;
import org.robolectric.annotation.experimental.LazyApplication.LazyLoad;
+import org.robolectric.versioning.AndroidVersions.U;
+import org.robolectric.versioning.AndroidVersions.V;
/** Tests to make sure {@link android.compat.Compatibility} is instrumented correctly */
@RunWith(RobolectricTestRunner.class)
@@ -33,4 +35,10 @@ public class CompatibilityTest {
// verify there are no CompatibilityChangeReporter spam logs
assertThat(ShadowLog.getLogsForTag("CompatibilityChangeReporter")).isEmpty();
}
+
+ @Test
+ public void edgeToEdgeEncorcement_minSdk() {
+ assertThat(ShadowCompatibility.isEdgeToEdgeEnabled(U.SDK_INT)).isFalse();
+ assertThat(ShadowCompatibility.isEdgeToEdgeEnabled(V.SDK_INT)).isTrue();
+ }
}
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/PlaybackInfoBuilderTest.java b/robolectric/src/test/java/org/robolectric/shadows/PlaybackInfoBuilderTest.java
index d59dc0b7e..ce2ccae95 100644
--- a/robolectric/src/test/java/org/robolectric/shadows/PlaybackInfoBuilderTest.java
+++ b/robolectric/src/test/java/org/robolectric/shadows/PlaybackInfoBuilderTest.java
@@ -4,15 +4,12 @@ import static com.google.common.truth.Truth.assertThat;
import android.media.AudioAttributes;
import android.media.session.MediaController.PlaybackInfo;
-import android.os.Build.VERSION_CODES;
import androidx.test.ext.junit.runners.AndroidJUnit4;
import org.junit.Test;
import org.junit.runner.RunWith;
-import org.robolectric.annotation.Config;
/** Test for {@link PlaybackInfoBuilder} */
@RunWith(AndroidJUnit4.class)
-@Config(minSdk = VERSION_CODES.LOLLIPOP)
public class PlaybackInfoBuilderTest {
@Test
public void build_playbackInfo() {
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/ShadowAlarmManagerTest.java b/robolectric/src/test/java/org/robolectric/shadows/ShadowAlarmManagerTest.java
index a2ae9222b..d1da6964c 100644
--- a/robolectric/src/test/java/org/robolectric/shadows/ShadowAlarmManagerTest.java
+++ b/robolectric/src/test/java/org/robolectric/shadows/ShadowAlarmManagerTest.java
@@ -257,7 +257,6 @@ public class ShadowAlarmManagerTest {
verify(onFire).onAlarm();
}
- @Config(minSdk = VERSION_CODES.LOLLIPOP)
@Test
public void setAlarmClock_pendingIntent() {
AlarmClockInfo alarmClockInfo =
@@ -534,7 +533,6 @@ public class ShadowAlarmManagerTest {
}
@Test
- @Config(minSdk = VERSION_CODES.LOLLIPOP)
public void getNextAlarmClockInfo() {
AlarmClockInfo alarmClockInfo1 =
new AlarmClockInfo(
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/ShadowAppOpsManagerTest.java b/robolectric/src/test/java/org/robolectric/shadows/ShadowAppOpsManagerTest.java
index 168e03fa1..74e52f562 100644
--- a/robolectric/src/test/java/org/robolectric/shadows/ShadowAppOpsManagerTest.java
+++ b/robolectric/src/test/java/org/robolectric/shadows/ShadowAppOpsManagerTest.java
@@ -467,7 +467,6 @@ public class ShadowAppOpsManagerTest {
}
@Test
- @Config(minSdk = VERSION_CODES.LOLLIPOP)
public void setRestrictions() {
appOps.setRestriction(
OP_VIBRATE, AudioAttributes.USAGE_NOTIFICATION, MODE_ERRORED, new String[] {PACKAGE_NAME1});
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..359cbad6c 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;
@@ -126,28 +125,19 @@ public class ShadowApplicationTest {
}
@Test
- public void shouldProvideServicesIntroducedInJellyBeanMr1() throws Exception {
+ public void shouldProvideServicesAvailableInAllSdKs() throws Exception {
assertThat(context.getSystemService(Context.DISPLAY_SERVICE))
.isInstanceOf(android.hardware.display.DisplayManager.class);
assertThat(context.getSystemService(Context.USER_SERVICE)).isInstanceOf(UserManager.class);
- }
-
- @Test
- public void shouldProvideServicesIntroducedInKitKat() throws Exception {
- assertThat(context.getSystemService(Context.PRINT_SERVICE)).isInstanceOf(PrintManager.class);
- assertThat(context.getSystemService(Context.CAPTIONING_SERVICE))
- .isInstanceOf(CaptioningManager.class);
- }
-
- @Test
- @Config(minSdk = LOLLIPOP)
- public void shouldProvideServicesIntroducedInLollipop() throws Exception {
assertThat(context.getSystemService(Context.MEDIA_SESSION_SERVICE))
.isInstanceOf(MediaSessionManager.class);
assertThat(context.getSystemService(Context.BATTERY_SERVICE))
.isInstanceOf(BatteryManager.class);
assertThat(context.getSystemService(Context.RESTRICTIONS_SERVICE))
.isInstanceOf(RestrictionsManager.class);
+ assertThat(context.getSystemService(Context.PRINT_SERVICE)).isInstanceOf(PrintManager.class);
+ assertThat(context.getSystemService(Context.CAPTIONING_SERVICE))
+ .isInstanceOf(CaptioningManager.class);
}
@Test
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/ShadowBackupDataInputTest.java b/robolectric/src/test/java/org/robolectric/shadows/ShadowBackupDataInputTest.java
index 4b0359800..894476d5c 100644
--- a/robolectric/src/test/java/org/robolectric/shadows/ShadowBackupDataInputTest.java
+++ b/robolectric/src/test/java/org/robolectric/shadows/ShadowBackupDataInputTest.java
@@ -6,19 +6,16 @@ import static org.robolectric.util.reflector.Reflector.reflector;
import android.app.backup.BackupDataInput;
import android.app.backup.BackupDataInputStream;
-import android.os.Build.VERSION_CODES;
import androidx.test.ext.junit.runners.AndroidJUnit4;
import java.io.BufferedInputStream;
import java.io.IOException;
import java.io.InputStream;
import org.junit.Test;
import org.junit.runner.RunWith;
-import org.robolectric.annotation.Config;
import org.robolectric.util.reflector.Constructor;
import org.robolectric.util.reflector.ForType;
@RunWith(AndroidJUnit4.class)
-@Config(minSdk = VERSION_CODES.LOLLIPOP)
public final class ShadowBackupDataInputTest {
private static final String TEST_KEY_1 = "key_1";
diff --git a/robolectric/src/test/java/org/robolectric/shadows/ShadowBackupDataOutputTest.java b/robolectric/src/test/java/org/robolectric/shadows/ShadowBackupDataOutputTest.java
index ac222a899..2fe9db27b 100644
--- a/robolectric/src/test/java/org/robolectric/shadows/ShadowBackupDataOutputTest.java
+++ b/robolectric/src/test/java/org/robolectric/shadows/ShadowBackupDataOutputTest.java
@@ -6,17 +6,14 @@ import static org.robolectric.Shadows.shadowOf;
import static org.robolectric.util.reflector.Reflector.reflector;
import android.app.backup.BackupDataOutput;
-import android.os.Build.VERSION_CODES;
import androidx.test.ext.junit.runners.AndroidJUnit4;
import java.io.IOException;
import java.util.Arrays;
import org.junit.Test;
import org.junit.runner.RunWith;
-import org.robolectric.annotation.Config;
import org.robolectric.util.reflector.ForType;
@RunWith(AndroidJUnit4.class)
-@Config(minSdk = VERSION_CODES.LOLLIPOP)
public final class ShadowBackupDataOutputTest {
private static final String TEST_PREFIX = "prefix";
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/ShadowCallTest.java b/robolectric/src/test/java/org/robolectric/shadows/ShadowCallTest.java
index 0d7c05114..e8e9dfdf4 100644
--- a/robolectric/src/test/java/org/robolectric/shadows/ShadowCallTest.java
+++ b/robolectric/src/test/java/org/robolectric/shadows/ShadowCallTest.java
@@ -14,7 +14,6 @@ import org.robolectric.util.ReflectionHelpers;
/** Test of ShadowCall. */
@RunWith(AndroidJUnit4.class)
-@Config(minSdk = VERSION_CODES.LOLLIPOP)
public final class ShadowCallTest {
Call call;
ShadowCall shadowCall;
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..099c9105e 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,8 +90,7 @@ public class ShadowDisplayTest {
}
@Test
- @Config(minSdk = LOLLIPOP)
- public void stateChangeShouldApplyToOtherInstancesOfSameDisplay_postKitKatFields() {
+ public void stateChangeShouldApplyToOtherInstancesOfSameDisplay() {
shadow.setState(Display.STATE_DOZE_SUSPEND);
display = DisplayManagerGlobal.getInstance().getRealDisplay(Display.DEFAULT_DISPLAY);
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..72a75bec1 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;
@@ -8,6 +7,7 @@ import static org.junit.Assert.fail;
import static org.mockito.ArgumentMatchers.any;
import static org.mockito.ArgumentMatchers.anyInt;
import static org.mockito.ArgumentMatchers.nullable;
+import static org.mockito.ArgumentMatchers.refEq;
import static org.mockito.Mockito.mock;
import static org.mockito.Mockito.same;
import static org.mockito.Mockito.times;
@@ -33,13 +33,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";
@@ -212,7 +210,13 @@ public final class ShadowMediaCodecTest {
@Test
public void formatChangeReported() throws IOException {
MediaCodec codec = createAsyncEncoder();
- verify(callback).onOutputFormatChanged(same(codec), any());
+ MediaFormat mediaFormat = getBasicAacFormat();
+ // ShadowMediaCodec if async, simulates adding codec specific info before making input
+ // buffers available.
+ mediaFormat.setByteBuffer("csd-0", ByteBuffer.wrap(new byte[] {0x13, 0x10}));
+ mediaFormat.setByteBuffer("csd-1", ByteBuffer.wrap(new byte[0]));
+
+ verify(callback).onOutputFormatChanged(same(codec), refEq(mediaFormat));
}
@Test
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/ShadowPausedMessageQueueTest.java b/robolectric/src/test/java/org/robolectric/shadows/ShadowPausedMessageQueueTest.java
index 9098c6b50..c0a86f05f 100644
--- a/robolectric/src/test/java/org/robolectric/shadows/ShadowPausedMessageQueueTest.java
+++ b/robolectric/src/test/java/org/robolectric/shadows/ShadowPausedMessageQueueTest.java
@@ -36,7 +36,7 @@ public class ShadowPausedMessageQueueTest {
@After
public void tearDown() {
- if (shadowQueue != null) {
+ if (queue != null) {
shadowQueue.quit();
}
}
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..9c2eab273 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;
@@ -241,8 +238,7 @@ public class ShadowSQLiteConnectionTest {
private SQLiteConnection getSQLiteConnection() {
ptr =
ShadowLegacySQLiteConnection.nativeOpen(
- databasePath.getPath(), 0, "test connection", false, false)
- .longValue();
+ databasePath.getPath(), 0, "test connection", false, false);
connections =
ReflectionHelpers.getStaticField(ShadowLegacySQLiteConnection.class, "CONNECTIONS");
return connections.getConnection(ptr);
diff --git a/robolectric/src/test/java/org/robolectric/shadows/ShadowSettingsTest.java b/robolectric/src/test/java/org/robolectric/shadows/ShadowSettingsTest.java
index ae2737ccb..6c037a073 100644
--- a/robolectric/src/test/java/org/robolectric/shadows/ShadowSettingsTest.java
+++ b/robolectric/src/test/java/org/robolectric/shadows/ShadowSettingsTest.java
@@ -2,8 +2,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 +9,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 +171,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 +199,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
@@ -236,29 +235,6 @@ public class ShadowSettingsTest {
assertThat(Secure.isLocationProviderEnabled(contentResolver, NETWORK_PROVIDER)).isTrue();
}
- @Config(maxSdk = JELLY_BEAN_MR2)
- @Test
- public void setLocationProviderEnabled() {
- // Verify default values
- assertThat(Secure.isLocationProviderEnabled(contentResolver, GPS_PROVIDER)).isTrue();
- assertThat(Secure.isLocationProviderEnabled(contentResolver, NETWORK_PROVIDER)).isFalse();
-
- Secure.setLocationProviderEnabled(contentResolver, NETWORK_PROVIDER, true);
-
- assertThat(Secure.isLocationProviderEnabled(contentResolver, GPS_PROVIDER)).isTrue();
- assertThat(Secure.isLocationProviderEnabled(contentResolver, NETWORK_PROVIDER)).isTrue();
-
- Secure.setLocationProviderEnabled(contentResolver, GPS_PROVIDER, false);
-
- assertThat(Secure.isLocationProviderEnabled(contentResolver, GPS_PROVIDER)).isFalse();
- assertThat(Secure.isLocationProviderEnabled(contentResolver, NETWORK_PROVIDER)).isTrue();
-
- Secure.setLocationProviderEnabled(contentResolver, NETWORK_PROVIDER, false);
-
- assertThat(Secure.isLocationProviderEnabled(contentResolver, GPS_PROVIDER)).isFalse();
- assertThat(Secure.isLocationProviderEnabled(contentResolver, NETWORK_PROVIDER)).isFalse();
- }
-
@Test
public void testGlobalGetFloat() {
float durationScale =
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/ShadowTelephonyManagerTest.java b/robolectric/src/test/java/org/robolectric/shadows/ShadowTelephonyManagerTest.java
index 6da61d037..c3535c043 100644
--- a/robolectric/src/test/java/org/robolectric/shadows/ShadowTelephonyManagerTest.java
+++ b/robolectric/src/test/java/org/robolectric/shadows/ShadowTelephonyManagerTest.java
@@ -53,6 +53,7 @@ import android.net.Uri;
import android.os.Build;
import android.os.PersistableBundle;
import android.telecom.PhoneAccountHandle;
+import android.telephony.CarrierRestrictionRules;
import android.telephony.CellInfo;
import android.telephony.CellLocation;
import android.telephony.PhoneCapability;
@@ -1512,4 +1513,21 @@ public class ShadowTelephonyManagerTest {
shadowOf(telephonyManager).setDataRoamingEnabled(true);
assertThat(telephonyManager.isDataRoamingEnabled()).isTrue();
}
+
+ @Test
+ @Config(minSdk = Q)
+ public void setCarrierRestrictionRules_changesCarrierRestrictionRules() {
+ CarrierRestrictionRules carrierRestrictionRules = CarrierRestrictionRules.newBuilder().build();
+ shadowOf(telephonyManager).setCarrierRestrictionRules(carrierRestrictionRules);
+
+ assertThat(telephonyManager.getCarrierRestrictionRules()).isEqualTo(carrierRestrictionRules);
+ }
+
+ @Test()
+ @Config(minSdk = Q)
+ public void setCarrierRestrictionRules_throwsIllegalStateException() {
+ assertThrows(
+ IllegalStateException.class,
+ () -> shadowTelephonyManager.setCarrierRestrictionRules(new Object()));
+ }
}
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/ShadowViewConfigurationTest.java b/robolectric/src/test/java/org/robolectric/shadows/ShadowViewConfigurationTest.java
index d0dfeadfb..0f240e7f4 100644
--- a/robolectric/src/test/java/org/robolectric/shadows/ShadowViewConfigurationTest.java
+++ b/robolectric/src/test/java/org/robolectric/shadows/ShadowViewConfigurationTest.java
@@ -1,5 +1,7 @@
package org.robolectric.shadows;
+import static android.os.Build.VERSION_CODES.O_MR1;
+import static android.os.Build.VERSION_CODES.Q;
import static com.google.common.truth.Truth.assertThat;
import static org.junit.Assert.assertEquals;
import static org.robolectric.Shadows.shadowOf;
@@ -11,23 +13,27 @@ import androidx.test.ext.junit.runners.AndroidJUnit4;
import org.junit.Before;
import org.junit.Test;
import org.junit.runner.RunWith;
+import org.robolectric.RuntimeEnvironment;
import org.robolectric.annotation.Config;
@RunWith(AndroidJUnit4.class)
public class ShadowViewConfigurationTest {
private Application context;
+ private ViewConfiguration viewConfiguration;
@Before
public void setUp() throws Exception {
context = ApplicationProvider.getApplicationContext();
+ viewConfiguration = ViewConfiguration.get(context);
}
@Test
public void methodsShouldReturnAndroidConstants() {
- ViewConfiguration viewConfiguration = ViewConfiguration.get(context);
-
- assertEquals(10, ViewConfiguration.getScrollBarSize());
+ // Most of the constants here are private statics from ViewConfiguration circa Jelly Bean:
+ // https://cs.android.com/android/platform/superproject/+/android-4.1.1_r1:frameworks/base/core/java/android/view/ViewConfiguration.java
+ final int expectedScrollBarSize = RuntimeEnvironment.getApiLevel() >= O_MR1 ? 4 : 10;
+ assertEquals(expectedScrollBarSize, ViewConfiguration.getScrollBarSize());
assertEquals(250, ViewConfiguration.getScrollBarFadeDuration());
assertEquals(300, ViewConfiguration.getScrollDefaultDelay());
assertEquals(12, ViewConfiguration.getFadingEdgeLength());
@@ -40,7 +46,7 @@ public class ShadowViewConfigurationTest {
assertEquals(16, ViewConfiguration.getTouchSlop());
assertEquals(16, ViewConfiguration.getWindowTouchSlop());
assertEquals(50, ViewConfiguration.getMinimumFlingVelocity());
- assertEquals(4000, ViewConfiguration.getMaximumFlingVelocity());
+ assertEquals(8000, ViewConfiguration.getMaximumFlingVelocity());
assertEquals(480 * 800 * 4, ViewConfiguration.getMaximumDrawingCacheSize());
assertEquals(3000, ViewConfiguration.getZoomControlsTimeout());
assertEquals(500, ViewConfiguration.getGlobalActionKeyTimeout());
@@ -48,7 +54,7 @@ public class ShadowViewConfigurationTest {
assertThat(context.getResources().getDisplayMetrics().density).isEqualTo(1f);
- assertEquals(10, viewConfiguration.getScaledScrollBarSize());
+ assertEquals(expectedScrollBarSize, viewConfiguration.getScaledScrollBarSize());
assertEquals(12, viewConfiguration.getScaledFadingEdgeLength());
assertEquals(12, viewConfiguration.getScaledEdgeSlop());
assertEquals(16, viewConfiguration.getScaledTouchSlop());
@@ -56,17 +62,24 @@ public class ShadowViewConfigurationTest {
assertEquals(100, viewConfiguration.getScaledDoubleTapSlop());
assertEquals(16, viewConfiguration.getScaledWindowTouchSlop());
assertEquals(50, viewConfiguration.getScaledMinimumFlingVelocity());
- assertEquals(4000, viewConfiguration.getScaledMaximumFlingVelocity());
+ assertEquals(8000, viewConfiguration.getScaledMaximumFlingVelocity());
// The min value of getScaledMaximumDrawingCacheSize is 480 * 800 * 4.
assertEquals(480 * 800 * 4, viewConfiguration.getScaledMaximumDrawingCacheSize());
+ assertThat(viewConfiguration.isFadingMarqueeEnabled()).isFalse();
+ assertThat(viewConfiguration.getScaledOverflingDistance()).isEqualTo(6);
+ if (RuntimeEnvironment.getApiLevel() >= Q) {
+ assertThat(viewConfiguration.getScaledMinimumScalingSpan()).isEqualTo(170);
+ }
}
@Test
+ @Config(qualifiers = "hdpi")
public void methodsShouldReturnScaledAndroidConstantsDependingOnPixelDensity() {
- context.getResources().getDisplayMetrics().density = 1.5f;
- ViewConfiguration viewConfiguration = ViewConfiguration.get(context);
-
- assertEquals(15, viewConfiguration.getScaledScrollBarSize());
+ // Most of the constants here are private statics from ViewConfiguration circa Jelly Bean:
+ // https://cs.android.com/android/platform/superproject/+/android-4.1.1_r1:frameworks/base/core/java/android/view/ViewConfiguration.java
+ // They are multiplied by the scaling factor 1.5 for HDPI.
+ final int expectedScaledScrollBarSize = RuntimeEnvironment.getApiLevel() >= O_MR1 ? 6 : 15;
+ assertEquals(expectedScaledScrollBarSize, viewConfiguration.getScaledScrollBarSize());
assertEquals(18, viewConfiguration.getScaledFadingEdgeLength());
assertEquals(18, viewConfiguration.getScaledEdgeSlop());
assertEquals(24, viewConfiguration.getScaledTouchSlop());
@@ -74,12 +87,15 @@ public class ShadowViewConfigurationTest {
assertEquals(150, viewConfiguration.getScaledDoubleTapSlop());
assertEquals(24, viewConfiguration.getScaledWindowTouchSlop());
assertEquals(75, viewConfiguration.getScaledMinimumFlingVelocity());
- assertEquals(6000, viewConfiguration.getScaledMaximumFlingVelocity());
+ assertEquals(12000, viewConfiguration.getScaledMaximumFlingVelocity());
+ assertThat(viewConfiguration.getScaledOverflingDistance()).isEqualTo(9);
+ if (RuntimeEnvironment.getApiLevel() >= Q) {
+ assertThat(viewConfiguration.getScaledMinimumScalingSpan()).isEqualTo(255);
+ }
}
@Test
public void testHasPermanentMenuKey() {
- ViewConfiguration viewConfiguration = ViewConfiguration.get(context);
assertThat(viewConfiguration.hasPermanentMenuKey()).isTrue();
ShadowViewConfiguration shadowViewConfiguration = shadowOf(viewConfiguration);
@@ -90,7 +106,6 @@ public class ShadowViewConfigurationTest {
@Config(qualifiers = "w420dp-h800dp-xxxhdpi")
@Test
public void getScaledMaximumFlingVelocity_scalesWithDisplaySize() {
- ViewConfiguration viewConfiguration = ViewConfiguration.get(context);
int expected = 4 * (4 * 420) * (4 * 800);
assertThat(viewConfiguration.getScaledMaximumDrawingCacheSize()).isEqualTo(expected);
}
@@ -98,8 +113,26 @@ public class ShadowViewConfigurationTest {
@Config(qualifiers = "w100dp-h500dp")
@Test
public void getScaledMaximumFlingVelocity_minValue() {
- ViewConfiguration viewConfiguration = ViewConfiguration.get(context);
int expected = 480 * 800 * 4; // The min value
assertThat(viewConfiguration.getScaledMaximumDrawingCacheSize()).isEqualTo(expected);
}
+
+ @Config(minSdk = Q, qualifiers = "w600dp-h800dp")
+ @Test
+ public void getScaledMinimumScalingSpan_largeScreen() {
+ assertThat(viewConfiguration.getScaledMinimumScalingSpan()).isEqualTo(202);
+ }
+
+ @Config(minSdk = Q)
+ @Test
+ public void getScaledMinimumScalingSpan_usePreviousBug() {
+ System.setProperty("robolectric.useRealMinScalingSpan", "false");
+ ShadowViewConfiguration.reset(); // clear the static cache
+ try {
+ ViewConfiguration viewConfiguration = ViewConfiguration.get(context);
+ assertThat(viewConfiguration.getScaledMinimumScalingSpan()).isEqualTo(0);
+ } finally {
+ System.clearProperty("robolectric.useRealMinScalingSpan");
+ }
+ }
}
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/robolectric/src/test/java/org/robolectric/shadows/ShadowWindowManagerGlobalTest.java b/robolectric/src/test/java/org/robolectric/shadows/ShadowWindowManagerGlobalTest.java
index 28185849a..6092630c1 100644
--- a/robolectric/src/test/java/org/robolectric/shadows/ShadowWindowManagerGlobalTest.java
+++ b/robolectric/src/test/java/org/robolectric/shadows/ShadowWindowManagerGlobalTest.java
@@ -1,6 +1,5 @@
package org.robolectric.shadows;
-import static android.os.Build.VERSION_CODES.JELLY_BEAN_MR1;
import static com.google.common.truth.Truth.assertThat;
import static org.junit.Assert.assertThrows;
@@ -9,7 +8,6 @@ import android.content.ClipData;
import android.graphics.Rect;
import android.os.Build.VERSION_CODES;
import android.os.Bundle;
-import android.os.Looper;
import android.view.Display;
import android.view.MotionEvent;
import android.view.View;
@@ -49,13 +47,6 @@ public class ShadowWindowManagerGlobalTest {
}
@Test
- @Config(minSdk = JELLY_BEAN_MR1)
- public void getWindowSession_withLooper_shouldReturnSession() {
- // method not available in JELLY BEAN, sorry :(
- assertThat(ShadowWindowManagerGlobal.getWindowSession(Looper.getMainLooper())).isNotNull();
- }
-
- @Test
public void getLastDragClipData() {
MotionEvent downEvent = MotionEvent.obtain(0L, 0L, MotionEvent.ACTION_DOWN, 12f, 34f, 0);
Robolectric.buildActivity(DragActivity.class)
diff --git a/scripts/README.md b/scripts/README.md
index 884a36f74..2a9476a31 100644
--- a/scripts/README.md
+++ b/scripts/README.md
@@ -52,16 +52,20 @@ Now use repo to sync the android source, and then build.
The currently supported Android versions are:
-* `4.1.2_r1` - Jelly Bean API 16
-* `4.2.2_r1.2` - Jelly Bean MR1 API 17
-* `4.3_r2` - Jelly Bean MR2 API 18
-* `4.4_r1` - Kit Kat API 19
* `5.0.2_r3` - Lollipop API 21
* `5.1.1_r9` - Lollipop MR1 API 22
* `6.0.1_r3` - Marshmallow API 23
* `7.0.0_r1` - Nougat API 24
* `7.1.0_r7` - Nougat MR1 API 25
* `8.0.0_r4` - Oreo API 26
+* `8.1.0` - Oreo MR1 API 27
+* `9` - P API 28
+* `10` - Q API 29
+* `11` - R API 30
+* `12` - S API 31
+* `12.1` - S V2 API 32
+* `13` - T API 33
+* `14` - U API 34
Beware it can take upwards of 100 GB of space to sync and build.
diff --git a/shadows/framework/src/main/java/org/robolectric/RuntimeEnvironment.java b/shadows/framework/src/main/java/org/robolectric/RuntimeEnvironment.java
index a728c859b..c262e889b 100644
--- a/shadows/framework/src/main/java/org/robolectric/RuntimeEnvironment.java
+++ b/shadows/framework/src/main/java/org/robolectric/RuntimeEnvironment.java
@@ -1,6 +1,5 @@
package org.robolectric;
-import static android.os.Build.VERSION_CODES.LOLLIPOP;
import static org.robolectric.annotation.LooperMode.Mode.LEGACY;
import static org.robolectric.shadows.ShadowLooper.assertLooperMode;
@@ -250,16 +249,6 @@ public class RuntimeEnvironment {
return apiLevel;
}
- public static Number castNativePtr(long ptr) {
- // Weird, using a ternary here doesn't work, there's some auto promotion of boxed types
- // happening.
- if (getApiLevel() >= LOLLIPOP) {
- return ptr;
- } else {
- return (int) ptr;
- }
- }
-
/**
* Retrieves the current master scheduler. This scheduler is always used by the main {@link
* android.os.Looper Looper}, and if the global scheduler option is set it is also used for the
diff --git a/shadows/framework/src/main/java/org/robolectric/android/internal/DisplayConfig.java b/shadows/framework/src/main/java/org/robolectric/android/internal/DisplayConfig.java
index 22368c241..bb3c57eaa 100644
--- a/shadows/framework/src/main/java/org/robolectric/android/internal/DisplayConfig.java
+++ b/shadows/framework/src/main/java/org/robolectric/android/internal/DisplayConfig.java
@@ -1,6 +1,5 @@
package org.robolectric.android.internal;
-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;
@@ -232,11 +231,9 @@ public final class DisplayConfig {
logicalDensityDpi = other.logicalDensityDpi;
physicalXDpi = other.physicalXDpi;
physicalYDpi = other.physicalYDpi;
- if (RuntimeEnvironment.getApiLevel() >= LOLLIPOP) {
- appVsyncOffsetNanos = other.appVsyncOffsetNanos;
- presentationDeadlineNanos = other.presentationDeadlineNanos;
- state = other.state;
- }
+ appVsyncOffsetNanos = other.appVsyncOffsetNanos;
+ presentationDeadlineNanos = other.presentationDeadlineNanos;
+ state = other.state;
ownerUid = other.ownerUid;
ownerPackageName = other.ownerPackageName;
if (RuntimeEnvironment.getApiLevel() >= O) {
@@ -364,11 +361,9 @@ public final class DisplayConfig {
other.logicalDensityDpi = logicalDensityDpi;
other.physicalXDpi = physicalXDpi;
other.physicalYDpi = physicalYDpi;
- if (RuntimeEnvironment.getApiLevel() >= LOLLIPOP) {
- other.appVsyncOffsetNanos = appVsyncOffsetNanos;
- other.presentationDeadlineNanos = presentationDeadlineNanos;
- other.state = state;
- }
+ other.appVsyncOffsetNanos = appVsyncOffsetNanos;
+ other.presentationDeadlineNanos = presentationDeadlineNanos;
+ other.state = state;
other.ownerUid = ownerUid;
other.ownerPackageName = ownerPackageName;
if (RuntimeEnvironment.getApiLevel() >= O) {
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/LegacyManifestParser.java b/shadows/framework/src/main/java/org/robolectric/shadows/LegacyManifestParser.java
index 760c7b7fc..d651a9177 100644
--- a/shadows/framework/src/main/java/org/robolectric/shadows/LegacyManifestParser.java
+++ b/shadows/framework/src/main/java/org/robolectric/shadows/LegacyManifestParser.java
@@ -15,7 +15,6 @@ import static android.content.pm.ApplicationInfo.FLAG_SUPPORTS_SCREEN_DENSITIES;
import static android.content.pm.ApplicationInfo.FLAG_SUPPORTS_SMALL_SCREENS;
import static android.content.pm.ApplicationInfo.FLAG_TEST_ONLY;
import static android.content.pm.ApplicationInfo.FLAG_VM_SAFE_MODE;
-import static android.os.Build.VERSION_CODES.LOLLIPOP;
import static android.os.PatternMatcher.PATTERN_LITERAL;
import static android.os.PatternMatcher.PATTERN_PREFIX;
import static android.os.PatternMatcher.PATTERN_SIMPLE_GLOB;
@@ -272,12 +271,7 @@ public class LegacyManifestParser {
.createIfNotExists(pkg.packageName + "-codePath")
.toAbsolutePath()
.toString();
- if (RuntimeEnvironment.getApiLevel() >= LOLLIPOP) {
- pkg.codePath = codePath;
- } else {
- ReflectionHelpers.setField(Package.class, pkg, "mPath", codePath);
- }
-
+ pkg.codePath = codePath;
return pkg;
}
diff --git a/shadows/framework/src/main/java/org/robolectric/shadows/MediaCodecInfoBuilder.java b/shadows/framework/src/main/java/org/robolectric/shadows/MediaCodecInfoBuilder.java
index 95c079190..9d3afb373 100644
--- a/shadows/framework/src/main/java/org/robolectric/shadows/MediaCodecInfoBuilder.java
+++ b/shadows/framework/src/main/java/org/robolectric/shadows/MediaCodecInfoBuilder.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 java.util.Arrays.asList;
@@ -119,14 +118,12 @@ public class MediaCodecInfoBuilder {
ClassParameter.from(String.class, name), // canonicalName
ClassParameter.from(int.class, flags),
ClassParameter.from(CodecCapabilities[].class, capabilities));
- } else if (RuntimeEnvironment.getApiLevel() >= LOLLIPOP) {
+ } else {
return ReflectionHelpers.callConstructor(
MediaCodecInfo.class,
ClassParameter.from(String.class, name),
ClassParameter.from(boolean.class, isEncoder),
ClassParameter.from(CodecCapabilities[].class, capabilities));
- } else {
- throw new UnsupportedOperationException("Unable to create MediaCodecInfo");
}
}
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..76fc86ee8 100644
--- a/shadows/framework/src/main/java/org/robolectric/shadows/ShadowAccessibilityNodeInfo.java
+++ b/shadows/framework/src/main/java/org/robolectric/shadows/ShadowAccessibilityNodeInfo.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.N;
import static android.os.Build.VERSION_CODES.O;
@@ -429,7 +428,7 @@ public class ShadowAccessibilityNodeInfo {
this.view = root;
}
- @Implementation(minSdk = LOLLIPOP)
+ @Implementation
protected AccessibilityWindowInfo getWindow() {
return accessibilityWindowInfo;
}
@@ -574,13 +573,8 @@ public class ShadowAccessibilityNodeInfo {
newShadow.labeledBy = (labeledBy == null) ? null : obtain(labeledBy);
newShadow.view = view;
newShadow.actionListener = actionListener;
- if (getApiLevel() >= LOLLIPOP) {
- newShadow.accessibilityNodeInfoReflector.setActionsList(
- new ArrayList<>(realAccessibilityNodeInfo.getActionList()));
- } else {
- newShadow.accessibilityNodeInfoReflector.setActionsMask(
- realAccessibilityNodeInfo.getActions());
- }
+ newShadow.accessibilityNodeInfoReflector.setActionsList(
+ new ArrayList<>(realAccessibilityNodeInfo.getActionList()));
if (children != null) {
newShadow.children = new ArrayList<>();
@@ -602,15 +596,14 @@ public class ShadowAccessibilityNodeInfo {
newInfo.setLiveRegion(realAccessibilityNodeInfo.getLiveRegion());
newInfo.setRangeInfo(realAccessibilityNodeInfo.getRangeInfo());
newShadow.realAccessibilityNodeInfo.getExtras().putAll(realAccessibilityNodeInfo.getExtras());
- if (getApiLevel() >= LOLLIPOP) {
- newInfo.setMaxTextLength(realAccessibilityNodeInfo.getMaxTextLength());
- newInfo.setError(realAccessibilityNodeInfo.getError());
- }
+ newInfo.setMaxTextLength(realAccessibilityNodeInfo.getMaxTextLength());
+ newInfo.setError(realAccessibilityNodeInfo.getError());
+
if (getApiLevel() >= LOLLIPOP_MR1) {
newShadow.traversalAfter = (traversalAfter == null) ? null : obtain(traversalAfter);
newShadow.traversalBefore = (traversalBefore == null) ? null : obtain(traversalBefore);
}
- if ((getApiLevel() >= LOLLIPOP) && (accessibilityWindowInfo != null)) {
+ if (accessibilityWindowInfo != null) {
newShadow.accessibilityWindowInfo =
ShadowAccessibilityWindowInfo.obtain(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/ShadowAccessibilityWindowInfo.java b/shadows/framework/src/main/java/org/robolectric/shadows/ShadowAccessibilityWindowInfo.java
index c20012ed6..cf51b33ba 100644
--- a/shadows/framework/src/main/java/org/robolectric/shadows/ShadowAccessibilityWindowInfo.java
+++ b/shadows/framework/src/main/java/org/robolectric/shadows/ShadowAccessibilityWindowInfo.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.Q;
@@ -25,7 +24,7 @@ import org.robolectric.util.reflector.ForType;
* Shadow of {@link android.view.accessibility.AccessibilityWindowInfo} that allows a test to set
* properties that are locked in the original class.
*/
-@Implements(value = AccessibilityWindowInfo.class, minSdk = LOLLIPOP)
+@Implements(value = AccessibilityWindowInfo.class)
public class ShadowAccessibilityWindowInfo {
private static final Map<StrictEqualityWindowWrapper, StackTraceElement[]> obtainedInstances =
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..cc666e81e 100644
--- a/shadows/framework/src/main/java/org/robolectric/shadows/ShadowAlarmManager.java
+++ b/shadows/framework/src/main/java/org/robolectric/shadows/ShadowAlarmManager.java
@@ -4,7 +4,6 @@ import static android.app.AlarmManager.RTC_WAKEUP;
import static org.robolectric.util.reflector.Reflector.reflector;
import android.annotation.Nullable;
-import android.annotation.RequiresApi;
import android.app.AlarmManager;
import android.app.AlarmManager.AlarmClockInfo;
import android.app.AlarmManager.OnAlarmListener;
@@ -203,8 +202,7 @@ public class ShadowAlarmManager {
false);
}
- @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);
}
@@ -355,8 +353,7 @@ public class ShadowAlarmManager {
return canScheduleExactAlarms;
}
- @RequiresApi(VERSION_CODES.LOLLIPOP)
- @Implementation(minSdk = VERSION_CODES.LOLLIPOP)
+ @Implementation
@Nullable
protected AlarmClockInfo getNextAlarmClock() {
synchronized (scheduledAlarms) {
@@ -533,9 +530,7 @@ public class ShadowAlarmManager {
WINDOW_HEURISTIC,
operation,
null,
- VERSION.SDK_INT >= VERSION_CODES.LOLLIPOP && showIntent != null
- ? new AlarmClockInfo(triggerAtMs, showIntent)
- : null,
+ showIntent != null ? new AlarmClockInfo(triggerAtMs, showIntent) : null,
allowWhileIdle);
}
@@ -561,7 +556,7 @@ public class ShadowAlarmManager {
this.allowWhileIdle = allowWhileIdle;
this.handler = null;
- if (VERSION.SDK_INT >= VERSION_CODES.LOLLIPOP && alarmClockInfo != null) {
+ if (alarmClockInfo != null) {
this.showIntent = ((AlarmClockInfo) alarmClockInfo).getShowIntent();
} else {
this.showIntent = null;
@@ -596,7 +591,7 @@ public class ShadowAlarmManager {
} else {
this.handler = null;
}
- if (VERSION.SDK_INT >= VERSION_CODES.LOLLIPOP && alarmClockInfo != null) {
+ if (alarmClockInfo != null) {
this.showIntent = ((AlarmClockInfo) alarmClockInfo).getShowIntent();
} else {
this.showIntent = null;
@@ -646,7 +641,6 @@ public class ShadowAlarmManager {
return workSource;
}
- @RequiresApi(VERSION_CODES.LOLLIPOP)
@Nullable
public AlarmClockInfo getAlarmClockInfo() {
return (AlarmClockInfo) alarmClockInfo;
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/ShadowAlwaysOnHotwordDetector.java b/shadows/framework/src/main/java/org/robolectric/shadows/ShadowAlwaysOnHotwordDetector.java
index 3f5b90db0..285ab265b 100644
--- a/shadows/framework/src/main/java/org/robolectric/shadows/ShadowAlwaysOnHotwordDetector.java
+++ b/shadows/framework/src/main/java/org/robolectric/shadows/ShadowAlwaysOnHotwordDetector.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;
@@ -40,7 +39,7 @@ import org.robolectric.util.reflector.Constructor;
import org.robolectric.util.reflector.ForType;
/** Shadow implementation of {@link android.service.voice.AlwaysOnHotwordDetector}. */
-@Implements(value = AlwaysOnHotwordDetector.class, minSdk = LOLLIPOP, isInAndroidSdk = false)
+@Implements(value = AlwaysOnHotwordDetector.class, isInAndroidSdk = false)
public class ShadowAlwaysOnHotwordDetector {
@RealObject private AlwaysOnHotwordDetector realObject;
@@ -165,7 +164,6 @@ public class ShadowAlwaysOnHotwordDetector {
/** Shadow for AsyncTask kicked off in the constructor of AlwaysOnHotwordDetector. */
@Implements(
className = "android.service.voice.AlwaysOnHotwordDetector$RefreshAvailabiltyTask",
- minSdk = LOLLIPOP,
maxSdk = TIRAMISU,
isInAndroidSdk = false)
public static class ShadowRefreshAvailabilityTask<Params, Progress, Result>
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/ShadowAppTask.java b/shadows/framework/src/main/java/org/robolectric/shadows/ShadowAppTask.java
index 505c75fc3..0efd3b2e8 100644
--- a/shadows/framework/src/main/java/org/robolectric/shadows/ShadowAppTask.java
+++ b/shadows/framework/src/main/java/org/robolectric/shadows/ShadowAppTask.java
@@ -1,6 +1,5 @@
package org.robolectric.shadows;
-import static android.os.Build.VERSION_CODES.LOLLIPOP;
import android.app.ActivityManager.AppTask;
import android.app.ActivityManager.RecentTaskInfo;
@@ -12,7 +11,7 @@ import org.robolectric.annotation.Implementation;
import org.robolectric.annotation.Implements;
import org.robolectric.util.ReflectionHelpers;
-@Implements(value = AppTask.class, minSdk = LOLLIPOP)
+@Implements(value = AppTask.class)
public class ShadowAppTask {
private boolean isFinished;
private RecentTaskInfo recentTaskInfo;
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..ffe019520 100644
--- a/shadows/framework/src/main/java/org/robolectric/shadows/ShadowApplicationPackageManager.java
+++ b/shadows/framework/src/main/java/org/robolectric/shadows/ShadowApplicationPackageManager.java
@@ -21,8 +21,6 @@ import static android.content.pm.PackageManager.MATCH_DEFAULT_ONLY;
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 +461,7 @@ public class ShadowApplicationPackageManager extends ShadowPackageManager {
return null;
}
- @Implementation(minSdk = LOLLIPOP)
+ @Implementation
protected ProviderInfo resolveContentProviderAsUser(
String name, int flags, @UserIdInt int userId) {
return null;
@@ -1197,21 +1195,6 @@ public class ShadowApplicationPackageManager extends ShadowPackageManager {
return null;
}
- @Implementation(maxSdk = JELLY_BEAN)
- protected void getPackageSizeInfo(Object pkgName, Object observer) {
- final PackageStats packageStats = packageStatsMap.get((String) pkgName);
- new Handler(Looper.getMainLooper())
- .post(
- () -> {
- try {
- ((IPackageStatsObserver) observer)
- .onGetStatsCompleted(packageStats, packageStats != null);
- } catch (RemoteException remoteException) {
- remoteException.rethrowFromSystemServer();
- }
- });
- }
-
@Implementation(maxSdk = M)
protected void getPackageSizeInfo(Object pkgName, Object uid, final Object observer) {
final PackageStats packageStats = packageStatsMap.get((String) pkgName);
@@ -1281,7 +1264,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 +1366,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 +1997,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 +2016,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 +2038,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 +2070,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/ShadowArscAssetInputStream.java b/shadows/framework/src/main/java/org/robolectric/shadows/ShadowArscAssetInputStream.java
index 9b91a22c1..82292453d 100644
--- a/shadows/framework/src/main/java/org/robolectric/shadows/ShadowArscAssetInputStream.java
+++ b/shadows/framework/src/main/java/org/robolectric/shadows/ShadowArscAssetInputStream.java
@@ -1,11 +1,9 @@
package org.robolectric.shadows;
-import static android.os.Build.VERSION_CODES.LOLLIPOP;
import static org.robolectric.util.reflector.Reflector.reflector;
import android.content.res.AssetManager.AssetInputStream;
import java.io.InputStream;
-import org.robolectric.RuntimeEnvironment;
import org.robolectric.annotation.Implements;
import org.robolectric.annotation.RealObject;
import org.robolectric.res.android.Asset;
@@ -26,13 +24,7 @@ public class ShadowArscAssetInputStream extends ShadowAssetInputStream {
}
private Asset getAsset() {
- int apiLevel = RuntimeEnvironment.getApiLevel();
- long assetPtr;
- if (apiLevel >= LOLLIPOP) {
- assetPtr = reflector(_AssetInputStream_.class, realObject).getNativeAsset();
- } else {
- assetPtr = reflector(_AssetInputStream_.class, realObject).getAssetInt();
- }
+ long assetPtr = reflector(_AssetInputStream_.class, realObject).getNativeAsset();
return Registries.NATIVE_ASSET_REGISTRY.getNativeObject(assetPtr);
}
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..d482bba1c 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;
@@ -274,12 +272,6 @@ public class ShadowArscAssetManager extends ShadowAssetManager.ArscBase {
//
@HiddenApi
- @Implementation(maxSdk = VERSION_CODES.JELLY_BEAN_MR1)
- public int addAssetPath(String path) {
- return addAssetPathNative(path);
- }
-
- @HiddenApi
@Implementation(maxSdk = M)
final protected int addAssetPathNative(String path) {
return addAssetPathNative(path, false);
@@ -317,7 +309,7 @@ public class ShadowArscAssetManager extends ShadowAssetManager.ArscBase {
@HiddenApi
@Implementation
- protected Number openAsset(String fileName, int mode) throws FileNotFoundException {
+ protected long openAsset(String fileName, int mode) throws FileNotFoundException {
CppAssetManager am = assetManagerForJavaObject();
ALOGV("openAsset in %s", am);
@@ -338,9 +330,9 @@ public class ShadowArscAssetManager extends ShadowAssetManager.ArscBase {
throw new FileNotFoundException(fileName8);
}
- //printf("Created Asset Stream: %p\n", a);
+ // printf("Created Asset Stream: %p\n", a);
- return RuntimeEnvironment.castNativePtr(Registries.NATIVE_ASSET_REGISTRY.register(a));
+ return Registries.NATIVE_ASSET_REGISTRY.register(a);
}
@HiddenApi @Implementation
@@ -365,16 +357,16 @@ public class ShadowArscAssetManager extends ShadowAssetManager.ArscBase {
@HiddenApi
@Implementation
- protected Number openNonAssetNative(int cookie, String fileName, int accessMode)
+ protected long openNonAssetNative(int cookie, String fileName, int accessMode)
throws FileNotFoundException {
CppAssetManager am = assetManagerForJavaObject();
if (am == null) {
- return RuntimeEnvironment.castNativePtr(0);
+ return 0;
}
ALOGV("openNonAssetNative in %s (Java object %s)\n", am, AssetManager.class);
String fileName8 = fileName;
if (fileName8 == null) {
- return RuntimeEnvironment.castNativePtr(-1);
+ return -1;
}
AccessMode mode = AccessMode.fromInt(accessMode);
if (mode != Asset.AccessMode.ACCESS_UNKNOWN && mode != Asset.AccessMode.ACCESS_RANDOM
@@ -390,8 +382,8 @@ public class ShadowArscAssetManager extends ShadowAssetManager.ArscBase {
long assetId = Registries.NATIVE_ASSET_REGISTRY.register(a);
// todo: something better than this [xw]
a.onClose = () -> destroyAsset(assetId);
- //printf("Created Asset Stream: %p\n", a);
- return RuntimeEnvironment.castNativePtr(assetId);
+ // printf("Created Asset Stream: %p\n", a);
+ return assetId;
}
@HiddenApi @Implementation
@@ -419,25 +411,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 +426,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 +455,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 +653,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 +664,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 +742,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) {
@@ -966,15 +915,15 @@ public class ShadowArscAssetManager extends ShadowAssetManager.ArscBase {
}
- @HiddenApi @Implementation
- protected Number getNativeStringBlock(int block) {
+ @HiddenApi
+ @Implementation
+ protected long getNativeStringBlock(int block) {
CppAssetManager am = assetManagerForJavaObject();
if (am == null) {
- return RuntimeEnvironment.castNativePtr(0);
+ return 0;
}
- return RuntimeEnvironment.castNativePtr(
- am.getResources().getTableStringBlock(block).getNativePtr());
+ return am.getResources().getTableStringBlock(block).getNativePtr();
}
@Implementation
@@ -993,59 +942,39 @@ public class ShadowArscAssetManager extends ShadowAssetManager.ArscBase {
@HiddenApi
@Implementation
- protected Number newTheme() {
+ protected long newTheme() {
CppAssetManager am = assetManagerForJavaObject();
if (am == null) {
- return RuntimeEnvironment.castNativePtr(0);
+ return 0;
}
ResTableTheme theme = new ResTableTheme(am.getResources());
- return RuntimeEnvironment.castNativePtr(Registries.NATIVE_THEME_REGISTRY.register(theme));
+ return Registries.NATIVE_THEME_REGISTRY.register(theme);
}
@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();
@@ -1070,17 +999,17 @@ public class ShadowArscAssetManager extends ShadowAssetManager.ArscBase {
@HiddenApi
@Implementation
- protected Number openXmlAssetNative(int cookie, String fileName) throws FileNotFoundException {
+ protected long openXmlAssetNative(int cookie, String fileName) throws FileNotFoundException {
CppAssetManager am = assetManagerForJavaObject();
if (am == null) {
- return RuntimeEnvironment.castNativePtr(0);
+ return 0;
}
ALOGV("openXmlAsset in %s (Java object %s)\n", am, ShadowArscAssetManager.class);
String fileName8 = fileName;
if (fileName8 == null) {
- return RuntimeEnvironment.castNativePtr(0);
+ return 0;
}
int assetCookie = cookie;
@@ -1108,8 +1037,7 @@ public class ShadowArscAssetManager extends ShadowAssetManager.ArscBase {
throw new FileNotFoundException("Corrupt XML binary file");
}
- return RuntimeEnvironment.castNativePtr(
- Registries.NATIVE_RES_XML_TREES.register(block));
+ return Registries.NATIVE_RES_XML_TREES.register(block);
}
@HiddenApi
@@ -1274,17 +1202,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/ShadowAudioRecord.java b/shadows/framework/src/main/java/org/robolectric/shadows/ShadowAudioRecord.java
index 63fab17ac..36a123bde 100644
--- a/shadows/framework/src/main/java/org/robolectric/shadows/ShadowAudioRecord.java
+++ b/shadows/framework/src/main/java/org/robolectric/shadows/ShadowAudioRecord.java
@@ -1,7 +1,6 @@
package org.robolectric.shadows;
import static android.media.AudioRecord.ERROR_BAD_VALUE;
-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;
@@ -23,7 +22,7 @@ import org.robolectric.annotation.Resetter;
* <p>It is also possible to provide the underlying data by implementing {@link AudioRecordSource}
* and setting this via {@link #setSourceProvider(AudioRecordSourceProvider)}.
*/
-@Implements(value = AudioRecord.class, minSdk = LOLLIPOP)
+@Implements(value = AudioRecord.class)
public final class ShadowAudioRecord {
@RealObject AudioRecord audioRecord;
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/ShadowBackupDataInput.java b/shadows/framework/src/main/java/org/robolectric/shadows/ShadowBackupDataInput.java
index eb9445101..01a574ee1 100644
--- a/shadows/framework/src/main/java/org/robolectric/shadows/ShadowBackupDataInput.java
+++ b/shadows/framework/src/main/java/org/robolectric/shadows/ShadowBackupDataInput.java
@@ -4,7 +4,6 @@ import static java.lang.Math.min;
import static org.robolectric.util.reflector.Reflector.reflector;
import android.app.backup.BackupDataInput;
-import android.os.Build.VERSION_CODES;
import com.google.common.collect.ImmutableList;
import java.io.FileDescriptor;
import java.util.ArrayList;
@@ -15,7 +14,7 @@ import org.robolectric.util.reflector.Accessor;
import org.robolectric.util.reflector.ForType;
/** Shadow for BackupDataInput. */
-@Implements(value = BackupDataInput.class, minSdk = VERSION_CODES.LOLLIPOP, looseSignatures = true)
+@Implements(value = BackupDataInput.class, looseSignatures = true)
public class ShadowBackupDataInput {
private List<BackupDataEntity> entities = new ArrayList<>();
diff --git a/shadows/framework/src/main/java/org/robolectric/shadows/ShadowBackupDataOutput.java b/shadows/framework/src/main/java/org/robolectric/shadows/ShadowBackupDataOutput.java
index b82f7c32c..c2460d213 100644
--- a/shadows/framework/src/main/java/org/robolectric/shadows/ShadowBackupDataOutput.java
+++ b/shadows/framework/src/main/java/org/robolectric/shadows/ShadowBackupDataOutput.java
@@ -2,7 +2,6 @@ package org.robolectric.shadows;
import android.annotation.Nullable;
import android.app.backup.BackupDataOutput;
-import android.os.Build.VERSION_CODES;
import com.google.common.collect.ImmutableList;
import java.io.FileDescriptor;
import java.util.ArrayList;
@@ -15,7 +14,7 @@ import org.robolectric.util.reflector.Accessor;
import org.robolectric.util.reflector.ForType;
/** Shadow for BackupDataOutput. */
-@Implements(value = BackupDataOutput.class, minSdk = VERSION_CODES.LOLLIPOP)
+@Implements(value = BackupDataOutput.class)
public class ShadowBackupDataOutput {
protected static final String KEY_PREFIX_JOINER = ":";
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/ShadowBitmapRegionDecoder.java b/shadows/framework/src/main/java/org/robolectric/shadows/ShadowBitmapRegionDecoder.java
index 82f6c79b1..acef7316d 100644
--- a/shadows/framework/src/main/java/org/robolectric/shadows/ShadowBitmapRegionDecoder.java
+++ b/shadows/framework/src/main/java/org/robolectric/shadows/ShadowBitmapRegionDecoder.java
@@ -1,7 +1,5 @@
package org.robolectric.shadows;
-import static android.os.Build.VERSION_CODES.LOLLIPOP;
-import static org.robolectric.RuntimeEnvironment.getApiLevel;
import android.graphics.Bitmap;
import android.graphics.BitmapFactory;
@@ -74,12 +72,7 @@ public class ShadowBitmapRegionDecoder {
}
private static BitmapRegionDecoder newInstance() {
- if (getApiLevel() >= LOLLIPOP) {
- return ReflectionHelpers.callConstructor(BitmapRegionDecoder.class,
- new ReflectionHelpers.ClassParameter<>(long.class, 0L));
- } else {
- return ReflectionHelpers.callConstructor(BitmapRegionDecoder.class,
- new ReflectionHelpers.ClassParameter<>(int.class, 0));
- }
+ return ReflectionHelpers.callConstructor(
+ BitmapRegionDecoder.class, new ReflectionHelpers.ClassParameter<>(long.class, 0L));
}
}
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..84bf1ca8c 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;
@@ -117,7 +116,7 @@ public class ShadowBluetoothAdapter {
setIsBluetoothSupported(true);
BluetoothAdapterReflector bluetoothReflector = reflector(BluetoothAdapterReflector.class);
int apiLevel = RuntimeEnvironment.getApiLevel();
- if (apiLevel >= VERSION_CODES.LOLLIPOP && apiLevel <= VERSION_CODES.R) {
+ if (apiLevel <= VERSION_CODES.R) {
bluetoothReflector.setSBluetoothLeAdvertiser(null);
bluetoothReflector.setSBluetoothLeScanner(null);
}
@@ -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/ShadowBluetoothGatt.java b/shadows/framework/src/main/java/org/robolectric/shadows/ShadowBluetoothGatt.java
index 3935c8ff7..fc8b17a04 100644
--- a/shadows/framework/src/main/java/org/robolectric/shadows/ShadowBluetoothGatt.java
+++ b/shadows/framework/src/main/java/org/robolectric/shadows/ShadowBluetoothGatt.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.R;
@@ -95,7 +94,7 @@ public class ShadowBluetoothGatt {
iBluetoothGattClass, BluetoothDevice.class, Integer.TYPE, Integer.TYPE
},
new Object[] {null, device, 0, 0});
- } else if (apiLevel >= LOLLIPOP) {
+ } else {
bluetoothGatt =
Shadow.newInstance(
BluetoothGatt.class,
@@ -103,12 +102,6 @@ public class ShadowBluetoothGatt {
Context.class, iBluetoothGattClass, BluetoothDevice.class, Integer.TYPE
},
new Object[] {RuntimeEnvironment.getApplication(), null, device, 0});
- } else {
- bluetoothGatt =
- Shadow.newInstance(
- BluetoothGatt.class,
- new Class<?>[] {Context.class, iBluetoothGattClass, BluetoothDevice.class},
- new Object[] {RuntimeEnvironment.getApplication(), null, device});
}
PerfStatsCollector.getInstance().incrementCount("constructShadowBluetoothGatt");
diff --git a/shadows/framework/src/main/java/org/robolectric/shadows/ShadowBluetoothLeScanner.java b/shadows/framework/src/main/java/org/robolectric/shadows/ShadowBluetoothLeScanner.java
index a27e1096a..e57379a0d 100644
--- a/shadows/framework/src/main/java/org/robolectric/shadows/ShadowBluetoothLeScanner.java
+++ b/shadows/framework/src/main/java/org/robolectric/shadows/ShadowBluetoothLeScanner.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.base.Preconditions.checkNotNull;
import static java.util.Collections.unmodifiableList;
@@ -26,7 +25,7 @@ import org.robolectric.annotation.Implementation;
import org.robolectric.annotation.Implements;
/** Adds Robolectric support for BLE scanning. */
-@Implements(value = BluetoothLeScanner.class, minSdk = LOLLIPOP)
+@Implements(value = BluetoothLeScanner.class)
public class ShadowBluetoothLeScanner {
private List<ScanParams> activeScanParams = new ArrayList<>();
diff --git a/shadows/framework/src/main/java/org/robolectric/shadows/ShadowCall.java b/shadows/framework/src/main/java/org/robolectric/shadows/ShadowCall.java
index e68223e2f..8b0239cc5 100644
--- a/shadows/framework/src/main/java/org/robolectric/shadows/ShadowCall.java
+++ b/shadows/framework/src/main/java/org/robolectric/shadows/ShadowCall.java
@@ -23,7 +23,7 @@ import org.robolectric.util.reflector.Direct;
import org.robolectric.util.reflector.ForType;
/** Robolectric test for {@link android.telecom.Call}. */
-@Implements(value = Call.class, minSdk = VERSION_CODES.LOLLIPOP)
+@Implements(value = Call.class)
public class ShadowCall {
@RealObject Call realObject;
private boolean hasSentRttRequest;
diff --git a/shadows/framework/src/main/java/org/robolectric/shadows/ShadowCameraCaptureSessionImpl.java b/shadows/framework/src/main/java/org/robolectric/shadows/ShadowCameraCaptureSessionImpl.java
index cadab2291..fce200556 100644
--- a/shadows/framework/src/main/java/org/robolectric/shadows/ShadowCameraCaptureSessionImpl.java
+++ b/shadows/framework/src/main/java/org/robolectric/shadows/ShadowCameraCaptureSessionImpl.java
@@ -16,7 +16,6 @@ import org.robolectric.util.ReflectionHelpers;
/** Shadow class for {@link CameraCaptureSessionImpl} */
@Implements(
value = CameraCaptureSessionImpl.class,
- minSdk = VERSION_CODES.LOLLIPOP,
isInAndroidSdk = false)
public class ShadowCameraCaptureSessionImpl {
@RealObject private CameraCaptureSessionImpl realObject;
diff --git a/shadows/framework/src/main/java/org/robolectric/shadows/ShadowCameraCharacteristics.java b/shadows/framework/src/main/java/org/robolectric/shadows/ShadowCameraCharacteristics.java
index e023a810f..66012f389 100644
--- a/shadows/framework/src/main/java/org/robolectric/shadows/ShadowCameraCharacteristics.java
+++ b/shadows/framework/src/main/java/org/robolectric/shadows/ShadowCameraCharacteristics.java
@@ -3,7 +3,6 @@ package org.robolectric.shadows;
import android.annotation.Nullable;
import android.hardware.camera2.CameraCharacteristics;
import android.hardware.camera2.CameraCharacteristics.Key;
-import android.os.Build.VERSION_CODES;
import com.google.common.base.Preconditions;
import java.util.HashMap;
import java.util.Map;
@@ -11,7 +10,7 @@ import org.robolectric.annotation.Implementation;
import org.robolectric.annotation.Implements;
import org.robolectric.util.ReflectionHelpers;
-@Implements(value = CameraCharacteristics.class, minSdk = VERSION_CODES.LOLLIPOP)
+@Implements(value = CameraCharacteristics.class)
public class ShadowCameraCharacteristics {
private final Map<Key<?>, Object> charactersKeyToValue = new HashMap<>();
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/ShadowCompatibility.java b/shadows/framework/src/main/java/org/robolectric/shadows/ShadowCompatibility.java
index 1dd630828..1826bcb65 100644
--- a/shadows/framework/src/main/java/org/robolectric/shadows/ShadowCompatibility.java
+++ b/shadows/framework/src/main/java/org/robolectric/shadows/ShadowCompatibility.java
@@ -5,32 +5,44 @@ import static org.robolectric.util.reflector.Reflector.reflector;
import android.compat.Compatibility;
import android.compat.annotation.ChangeId;
import android.os.Build.VERSION_CODES;
+import com.google.common.annotations.VisibleForTesting;
+import org.robolectric.RuntimeEnvironment;
import org.robolectric.annotation.Implementation;
import org.robolectric.annotation.Implements;
import org.robolectric.annotation.RealObject;
import org.robolectric.util.reflector.Direct;
import org.robolectric.util.reflector.ForType;
import org.robolectric.util.reflector.Static;
+import org.robolectric.versioning.AndroidVersions.U;
-/**
- * Robolectric shadow to disable CALL_ACTIVITY_RESULT_BEFORE_RESUME using Compatibility's
- * isChangeEnabled.
- */
+/** Shadow for {@link Compatability}. */
@Implements(value = Compatibility.class, isInAndroidSdk = false)
public class ShadowCompatibility {
private static final long CALL_ACTIVITY_RESULT_BEFORE_RESUME = 78294732L;
+ private static final long ENFORCE_EDGE_TO_EDGE = 309578419L;
+
@RealObject protected static Compatibility realCompatibility;
@Implementation(minSdk = VERSION_CODES.S_V2)
protected static boolean isChangeEnabled(@ChangeId long changeId) {
if (changeId == CALL_ACTIVITY_RESULT_BEFORE_RESUME) {
return false;
+ } else if (changeId == ENFORCE_EDGE_TO_EDGE) {
+ int targetSdkVersion =
+ RuntimeEnvironment.getApplication().getApplicationInfo().targetSdkVersion;
+ return isEdgeToEdgeEnabled(targetSdkVersion);
}
return reflector(CompatibilityReflector.class).isChangeEnabled(changeId);
}
+ @VisibleForTesting
+ static boolean isEdgeToEdgeEnabled(int targetSdkVersion) {
+ // Edge-to-edge is enforced for apps that target Android V and above.
+ return targetSdkVersion > U.SDK_INT;
+ }
+
/** Reflector interface for {@link Compatibility}'s isChangeEnabled function. */
@ForType(Compatibility.class)
private interface CompatibilityReflector {
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..f11322b69 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,5 @@
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;
@@ -137,11 +135,6 @@ public class ShadowEnvironment {
return new File[] {path.toFile()};
}
- @Implementation(maxSdk = JELLY_BEAN_MR2)
- protected static File getExternalStorageAppCacheDirectory(String packageName) {
- return buildExternalStorageAppCacheDirs(packageName)[0];
- }
-
/**
* Sets the return value of {@link #getExternalStoragePublicDirectory}. Note that the default
* value provides a directory that is usable in the test environment. If the test app uses this
@@ -208,7 +201,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 +212,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/ShadowInstrumentation.java b/shadows/framework/src/main/java/org/robolectric/shadows/ShadowInstrumentation.java
index d33cf20d9..6ad76286c 100644
--- a/shadows/framework/src/main/java/org/robolectric/shadows/ShadowInstrumentation.java
+++ b/shadows/framework/src/main/java/org/robolectric/shadows/ShadowInstrumentation.java
@@ -1061,7 +1061,6 @@ public class ShadowInstrumentation {
/** Reflector interface for {@link Instrumentation}'s internals. */
@ForType(Instrumentation.class)
public interface _Instrumentation_ {
- // > JELLY_BEAN_MR1:
void init(
ActivityThread thread,
Context instrContext,
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..d3557a403 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;
@@ -9,7 +7,6 @@ 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;
import static android.os.Build.VERSION_CODES.TIRAMISU;
-import static org.robolectric.RuntimeEnvironment.castNativePtr;
import static org.robolectric.shadow.api.Shadow.invokeConstructor;
import static org.robolectric.util.ReflectionHelpers.ClassParameter.from;
import static org.robolectric.util.reflector.Reflector.reflector;
@@ -262,12 +259,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 +337,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 +540,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
}
@@ -904,24 +873,22 @@ public class ShadowLegacyAssetManager extends ShadowAssetManager {
return type;
}
- @HiddenApi @Implementation
- public Number createTheme() {
+ @HiddenApi
+ @Implementation
+ public long createTheme() {
synchronized (nativeThemes) {
long nativePtr = nextInternalThemeId++;
nativeThemes.put(nativePtr, new NativeTheme(new ThemeStyleSet()));
- return castNativePtr(nativePtr);
+ return nativePtr;
}
}
- @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..38c91b832 100644
--- a/shadows/framework/src/main/java/org/robolectric/shadows/ShadowLegacyCursorWindow.java
+++ b/shadows/framework/src/main/java/org/robolectric/shadows/ShadowLegacyCursorWindow.java
@@ -1,9 +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 java.nio.charset.StandardCharsets.UTF_8;
-import static org.robolectric.RuntimeEnvironment.castNativePtr;
import android.database.Cursor;
import android.database.CursorWindow;
@@ -26,26 +23,16 @@ public class ShadowLegacyCursorWindow extends ShadowCursorWindow {
private static final WindowData WINDOW_DATA = new WindowData();
@Implementation
- protected static Number nativeCreate(String name, int cursorWindowSize) {
- return castNativePtr(WINDOW_DATA.create(name, cursorWindowSize));
+ protected static long nativeCreate(String name, int cursorWindowSize) {
+ return 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 +53,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 +64,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..727929e70 100644
--- a/shadows/framework/src/main/java/org/robolectric/shadows/ShadowLegacySQLiteConnection.java
+++ b/shadows/framework/src/main/java/org/robolectric/shadows/ShadowLegacySQLiteConnection.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 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 org.robolectric.RuntimeEnvironment.castNativePtr;
+import static android.os.Build.VERSION_CODES.TIRAMISU;
import android.database.sqlite.SQLiteAbortException;
import android.database.sqlite.SQLiteAccessPermException;
@@ -68,10 +66,10 @@ public class ShadowLegacySQLiteConnection extends ShadowSQLiteConnection {
private static final int IGNORED_REINDEX_STMT = -2;
@Implementation(maxSdk = O)
- protected static Number nativeOpen(
+ protected static long nativeOpen(
String path, int openFlags, String label, boolean enableTrace, boolean enableProfile) {
SQLiteLibraryLoader.load();
- return castNativePtr(CONNECTIONS.open(path));
+ return CONNECTIONS.open(path);
}
@Implementation(minSdk = O_MR1)
@@ -83,15 +81,10 @@ public class ShadowLegacySQLiteConnection extends ShadowSQLiteConnection {
boolean enableProfile,
int lookasideSlotSize,
int lookasideSlotCount) {
- 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);
+ return nativeOpen(path, openFlags, label, enableTrace, enableProfile);
}
- @Implementation(minSdk = LOLLIPOP)
+ @Implementation
protected static long nativePrepareStatement(long connectionPtr, String sql) {
final String newSql = convertSQLWithLocalizedUnicodeCollator(sql);
return CONNECTIONS.prepareStatement(connectionPtr, newSql);
@@ -110,209 +103,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 +216,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/ShadowLocaleData.java b/shadows/framework/src/main/java/org/robolectric/shadows/ShadowLocaleData.java
index ee3748664..668ca53d2 100644
--- a/shadows/framework/src/main/java/org/robolectric/shadows/ShadowLocaleData.java
+++ b/shadows/framework/src/main/java/org/robolectric/shadows/ShadowLocaleData.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;
@@ -127,14 +126,7 @@ public class ShadowLocaleData {
}
localDataReflector.setMonetarySeparator('.');
-
- if (getApiLevel() >= LOLLIPOP) {
- // Lollipop uses a String
- localDataReflector.setMinusSign("-");
- } else {
- // Upto KitKat was a char
- localDataReflector.setMinusSign('-');
- }
+ localDataReflector.setMinusSign("-");
localDataReflector.setExponentSeparator("E");
localDataReflector.setInfinity("\u221E");
diff --git a/shadows/framework/src/main/java/org/robolectric/shadows/ShadowLocationManager.java b/shadows/framework/src/main/java/org/robolectric/shadows/ShadowLocationManager.java
index 02d6b1776..b27bd96d7 100644
--- a/shadows/framework/src/main/java/org/robolectric/shadows/ShadowLocationManager.java
+++ b/shadows/framework/src/main/java/org/robolectric/shadows/ShadowLocationManager.java
@@ -905,7 +905,7 @@ public class ShadowLocationManager {
/**
* Returns the list of {@link LocationRequest} currently registered under the given provider.
* Clients compiled against the public Android SDK should only use this method on S+, clients
- * compiled against the system Android SDK may only use this method on Kitkat+.
+ * compiled against the system Android SDK can use this method on any supported SDK.
*
* <p>Prior to Android S {@link LocationRequest} equality is not well defined, so prefer using
* {@link #getLegacyLocationRequests(String)} instead if equality is required for testing.
@@ -1785,8 +1785,8 @@ public class ShadowLocationManager {
}
/**
- * LocationRequest doesn't exist prior to Kitkat, and is not public prior to S, so a new class is
- * required to represent it prior to those platforms.
+ * LocationRequest is not public prior to S, so a new class is required to represent it prior to
+ * those platforms.
*/
public static final class RoboLocationRequest {
@Nullable private final Object locationRequest;
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..4bcc972dd 100644
--- a/shadows/framework/src/main/java/org/robolectric/shadows/ShadowMediaCodec.java
+++ b/shadows/framework/src/main/java/org/robolectric/shadows/ShadowMediaCodec.java
@@ -98,6 +98,8 @@ public class ShadowMediaCodec {
@Nullable private MediaFormat pendingOutputFormat;
@Nullable private MediaFormat outputFormat;
+ @Nullable private String[] initialPendingOutputFormatKeys;
+ @Nullable private Object[] initialPendingOutputFormatValues;
private final BlockingQueue<Integer> inputBuffersPendingDequeue = new LinkedBlockingDeque<>();
private final BlockingQueue<Integer> outputBuffersPendingDequeue = new LinkedBlockingDeque<>();
@@ -151,12 +153,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);
@@ -175,13 +177,15 @@ public class ShadowMediaCodec {
}
private void innerConfigure(
- String[] keys,
- Object[] values,
+ @Nullable String[] keys,
+ @Nullable Object[] values,
@Nullable Surface surface,
@Nullable MediaCrypto mediaCrypto,
int flags) {
isAsync = callback != null;
pendingOutputFormat = recreateMediaFormatFromKeysValues(keys, values);
+ initialPendingOutputFormatKeys = keys;
+ initialPendingOutputFormatValues = values;
fakeCodec.onConfigured(pendingOutputFormat, surface, mediaCrypto, flags);
}
@@ -189,7 +193,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();
@@ -202,10 +206,21 @@ public class ShadowMediaCodec {
// Report the format as changed, to simulate adding codec specific info before making input
// buffers available.
HashMap<String, Object> format = new HashMap<>();
+ if (pendingOutputFormat != null) {
+ pendingOutputFormat.setByteBuffer("csd-0", ByteBuffer.wrap(new byte[] {0x13, 0x10}));
+ pendingOutputFormat.setByteBuffer("csd-1", ByteBuffer.wrap(new byte[0]));
+ if (initialPendingOutputFormatKeys != null
+ && initialPendingOutputFormatValues != null
+ && initialPendingOutputFormatKeys.length == initialPendingOutputFormatValues.length) {
+ for (int i = 0; i < initialPendingOutputFormatKeys.length; i++) {
+ format.put(initialPendingOutputFormatKeys[i], initialPendingOutputFormatValues[i]);
+ }
+ }
+ }
format.put("csd-0", ByteBuffer.wrap(new byte[] {0x13, 0x10}));
format.put("csd-1", ByteBuffer.wrap(new byte[0]));
- postFakeNativeEvent(EVENT_CALLBACK, CB_OUTPUT_FORMAT_CHANGE, 0, format);
+ postFakeNativeEvent(EVENT_CALLBACK, CB_OUTPUT_FORMAT_CHANGE, 0, format);
try {
makeInputBufferAvailable(inputBuffersPendingDequeue.take());
} catch (InterruptedException e) {
@@ -215,7 +230,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 +252,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 +260,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 +288,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 +306,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 +341,7 @@ public class ShadowMediaCodec {
releaseOutputBuffer(index);
}
- @Implementation(minSdk = LOLLIPOP)
+ @Implementation
protected void releaseOutputBuffer(int index, long renderTimestampNs) {
releaseOutputBuffer(index);
}
@@ -405,7 +420,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 +428,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 +445,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 +463,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)
@@ -544,6 +559,7 @@ public class ShadowMediaCodec {
/** Move the bytes on the in buffer to the out buffer */
void process(ByteBuffer in, ByteBuffer out);
+
/** Called when the codec is configured. @see MediaCodec#configure */
default void onConfigured(
MediaFormat format, @Nullable Surface surface, @Nullable MediaCrypto crypto, int flags) {}
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/ShadowNativeBaseRecordingCanvas.java b/shadows/framework/src/main/java/org/robolectric/shadows/ShadowNativeBaseRecordingCanvas.java
index 005b51905..b87bbe40d 100644
--- a/shadows/framework/src/main/java/org/robolectric/shadows/ShadowNativeBaseRecordingCanvas.java
+++ b/shadows/framework/src/main/java/org/robolectric/shadows/ShadowNativeBaseRecordingCanvas.java
@@ -21,6 +21,7 @@ import org.robolectric.versioning.AndroidVersions.U;
value = BaseRecordingCanvas.class,
minSdk = Q,
shadowPicker = Picker.class,
+ callNativeMethodsByDefault = true,
isInAndroidSdk = false)
public class ShadowNativeBaseRecordingCanvas extends ShadowNativeCanvas {
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/ShadowNativePluralRules.java b/shadows/framework/src/main/java/org/robolectric/shadows/ShadowNativePluralRules.java
index 454843ee5..6e50ec5b1 100644
--- a/shadows/framework/src/main/java/org/robolectric/shadows/ShadowNativePluralRules.java
+++ b/shadows/framework/src/main/java/org/robolectric/shadows/ShadowNativePluralRules.java
@@ -1,6 +1,5 @@
package org.robolectric.shadows;
-import static android.os.Build.VERSION_CODES.JELLY_BEAN_MR2;
import static android.os.Build.VERSION_CODES.M;
import org.robolectric.annotation.Implementation;
@@ -15,10 +14,4 @@ public class ShadowNativePluralRules {
if (quantity == 1) return 1;
else return 5 /* other */;
}
-
- @Implementation(maxSdk = JELLY_BEAN_MR2)
- protected static int quantityForIntImpl(int address, int quantity) {
- return quantityForIntImpl((long)address, quantity);
-
- }
}
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/ShadowNativeSurface.java b/shadows/framework/src/main/java/org/robolectric/shadows/ShadowNativeSurface.java
index 3ccae4a45..f7cd7161a 100644
--- a/shadows/framework/src/main/java/org/robolectric/shadows/ShadowNativeSurface.java
+++ b/shadows/framework/src/main/java/org/robolectric/shadows/ShadowNativeSurface.java
@@ -28,11 +28,11 @@ import org.robolectric.versioning.AndroidVersions.U;
isInAndroidSdk = false,
callNativeMethodsByDefault = true)
public class ShadowNativeSurface {
- @Implementation(maxSdk = U.SDK_INT)
+ @Implementation
protected static long nativeCreateFromSurfaceTexture(SurfaceTexture surfaceTexture)
throws OutOfResourcesException {
- DefaultNativeRuntimeLoader.injectAndLoad();
- return SurfaceNatives.nativeCreateFromSurfaceTexture(surfaceTexture);
+ // SurfaceTexture is not available for host.
+ return 0;
}
@Implementation(maxSdk = U.SDK_INT)
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..817761991 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;
@@ -10,7 +9,6 @@ import static android.os.Build.VERSION_CODES.Q;
import static android.os.Build.VERSION_CODES.R;
import static android.os.Build.VERSION_CODES.S;
import static android.os.Build.VERSION_CODES.TIRAMISU;
-import static org.robolectric.RuntimeEnvironment.castNativePtr;
import android.os.BadParcelableException;
import android.os.IBinder;
@@ -64,22 +62,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 +273,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 +338,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,132 +389,65 @@ 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();
}
@Implementation
@HiddenApi
- public static Number nativeCreate() {
- return castNativePtr(NATIVE_BYTE_BUFFER_REGISTRY.register(new ByteBuffer()));
+ public static long nativeCreate() {
+ return 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 +456,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..230313531 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,5 @@
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 +52,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 +67,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 +135,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;
@@ -256,9 +220,8 @@ public class ShadowPausedMessageQueue extends ShadowMessageQueue {
}
}
- @Implementation(maxSdk = JELLY_BEAN_MR1)
- protected void quit() {
- reflector(MessageQueueReflector.class, realQueue).quit(false);
+ void quit() {
+ quit(true);
}
@Implementation
@@ -494,7 +457,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/ShadowRegion.java b/shadows/framework/src/main/java/org/robolectric/shadows/ShadowRegion.java
index 753e32264..8f9a7eee9 100644
--- a/shadows/framework/src/main/java/org/robolectric/shadows/ShadowRegion.java
+++ b/shadows/framework/src/main/java/org/robolectric/shadows/ShadowRegion.java
@@ -3,7 +3,6 @@ package org.robolectric.shadows;
import static org.robolectric.util.reflector.Reflector.reflector;
import android.graphics.Region;
-import org.robolectric.RuntimeEnvironment;
import org.robolectric.annotation.HiddenApi;
import org.robolectric.annotation.Implementation;
import org.robolectric.annotation.Implements;
@@ -36,8 +35,8 @@ public class ShadowRegion {
@HiddenApi
@Implementation
- protected static Number nativeConstructor() {
- return RuntimeEnvironment.castNativePtr(nextId++);
+ protected static long nativeConstructor() {
+ return nextId++;
}
@ForType(Region.class)
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..e5a7f5676 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,5 @@
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;
@@ -165,12 +163,6 @@ public class ShadowSettings {
return updateEnabledProviders(cr, provider, enabled);
}
- @Implementation(maxSdk = JELLY_BEAN)
- protected static void setLocationProviderEnabled(
- ContentResolver cr, String provider, boolean enabled) {
- updateEnabledProviders(cr, provider, enabled);
- }
-
// only for use locally and by ShadowLocationManager, which requires a tight integration with
// ShadowSettings due to historical weirdness between LocationManager and Settings.
static boolean updateEnabledProviders(ContentResolver cr, String provider, boolean enabled) {
@@ -240,7 +232,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 bdf1d08bd..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;
@@ -33,6 +32,7 @@ import android.os.SystemProperties;
import android.telecom.PhoneAccountHandle;
import android.telephony.Annotation.NetworkType;
import android.telephony.Annotation.OverrideNetworkType;
+import android.telephony.CarrierRestrictionRules;
import android.telephony.CellInfo;
import android.telephony.CellLocation;
import android.telephony.PhoneStateListener;
@@ -179,6 +179,7 @@ public class ShadowTelephonyManager {
private static volatile boolean emergencyCallbackMode;
private static Map<Integer, List<EmergencyNumber>> emergencyNumbersList;
private static volatile boolean isDataRoamingEnabled;
+ private /*CarrierRestrictionRules*/ Object carrierRestrictionRules;
/**
* Should be {@link TelephonyManager.BootstrapAuthenticationCallback} but this object was
@@ -434,7 +435,7 @@ public class ShadowTelephonyManager {
setNetworkOperatorName(networkOperatorName);
}
- @Implementation(minSdk = LOLLIPOP)
+ @Implementation
protected String getImei() {
checkReadPhoneStatePermission();
return imei;
@@ -1197,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);
@@ -1662,4 +1663,24 @@ public class ShadowTelephonyManager {
protected void setDataRoamingEnabled(boolean isDataRoamingEnabled) {
ShadowTelephonyManager.isDataRoamingEnabled = isDataRoamingEnabled;
}
+
+ /**
+ * Sets the value to be returned by {@link #getCarrierRestrictionRules()}. Marked as public in
+ * order to allow it to be used as a test API.
+ *
+ * @param carrierRestrictionRules An object of type {@link CarrierRestrictionRules}
+ */
+ public void setCarrierRestrictionRules(Object carrierRestrictionRules) {
+ Preconditions.checkState(carrierRestrictionRules instanceof CarrierRestrictionRules);
+ this.carrierRestrictionRules = carrierRestrictionRules;
+ }
+
+ /**
+ * Implementation for {@link TelephonyManager#getCarrierRestrictionRules} that is set for tests by
+ * {@link TelephonyManager#setCarrierRestrictionRules}.
+ */
+ @Implementation(minSdk = Build.VERSION_CODES.Q)
+ protected /*CarrierRestrictionRules*/ Object getCarrierRestrictionRules() {
+ return carrierRestrictionRules;
+ }
}
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/ShadowViewConfiguration.java b/shadows/framework/src/main/java/org/robolectric/shadows/ShadowViewConfiguration.java
index 682f53b6a..10512159d 100644
--- a/shadows/framework/src/main/java/org/robolectric/shadows/ShadowViewConfiguration.java
+++ b/shadows/framework/src/main/java/org/robolectric/shadows/ShadowViewConfiguration.java
@@ -20,23 +20,30 @@
package org.robolectric.shadows;
+import static android.os.Build.VERSION_CODES.Q;
import static org.robolectric.util.reflector.Reflector.reflector;
import android.content.Context;
+import android.content.res.Resources;
import android.util.DisplayMetrics;
+import android.util.SparseArray;
import android.view.ViewConfiguration;
import org.robolectric.RuntimeEnvironment;
import org.robolectric.annotation.Implementation;
import org.robolectric.annotation.Implements;
+import org.robolectric.annotation.RealObject;
+import org.robolectric.annotation.Resetter;
import org.robolectric.shadow.api.Shadow;
+import org.robolectric.util.ReflectionHelpers.ClassParameter;
import org.robolectric.util.reflector.Accessor;
import org.robolectric.util.reflector.ForType;
+import org.robolectric.util.reflector.Static;
@SuppressWarnings({"UnusedDeclaration"})
@Implements(ViewConfiguration.class)
public class ShadowViewConfiguration {
+ @RealObject ViewConfiguration realViewConfiguration;
- private static final int SCROLL_BAR_SIZE = 10;
private static final int PRESSED_STATE_DURATION = 125;
private static final int LONG_PRESS_TIMEOUT = 500;
private static final int TAP_TIMEOUT = 115;
@@ -45,16 +52,12 @@ public class ShadowViewConfiguration {
private static final int PAGING_TOUCH_SLOP = TOUCH_SLOP * 2;
private static final int DOUBLE_TAP_SLOP = 100;
private static final int WINDOW_TOUCH_SLOP = 16;
- private static final int MAXIMUM_FLING_VELOCITY = 4000;
// The previous hardcoded value for draw cache size. Some screenshot tests depend on this value.
private static final int MIN_MAXIMUM_DRAWING_CACHE_SIZE = 480 * 800 * 4;
private int edgeSlop;
private int fadingEdgeLength;
- private int minimumFlingVelocity;
- private int maximumFlingVelocity;
- private int scrollbarSize;
private int touchSlop;
private int pagingTouchSlop;
private int doubleTapSlop;
@@ -62,15 +65,17 @@ public class ShadowViewConfiguration {
private int maximumDrawingCacheSize;
private static boolean hasPermanentMenuKey = true;
- private void setup(Context context) {
- final DisplayMetrics metrics = context.getResources().getDisplayMetrics();
+ @Implementation
+ protected void __constructor__(Context context) {
+ Shadow.invokeConstructor(
+ ViewConfiguration.class,
+ realViewConfiguration,
+ ClassParameter.from(Context.class, context));
+ final Resources resources = context.getResources();
+ final DisplayMetrics metrics = resources.getDisplayMetrics();
float density = metrics.density;
-
edgeSlop = (int) (density * ViewConfiguration.getEdgeSlop() + 0.5f);
fadingEdgeLength = (int) (density * ViewConfiguration.getFadingEdgeLength() + 0.5f);
- minimumFlingVelocity = (int) (density * ViewConfiguration.getMinimumFlingVelocity() + 0.5f);
- maximumFlingVelocity = (int) (density * ViewConfiguration.getMaximumFlingVelocity() + 0.5f);
- scrollbarSize = (int) (density * SCROLL_BAR_SIZE + 0.5f);
touchSlop = (int) (density * TOUCH_SLOP + 0.5f);
pagingTouchSlop = (int) (density * PAGING_TOUCH_SLOP + 0.5f);
doubleTapSlop = (int) (density * DOUBLE_TAP_SLOP + 0.5f);
@@ -81,30 +86,9 @@ public class ShadowViewConfiguration {
// TODO(hoisie): Investigate removing this Math.max logic.
maximumDrawingCacheSize =
Math.max(MIN_MAXIMUM_DRAWING_CACHE_SIZE, 4 * metrics.widthPixels * metrics.heightPixels);
- }
-
- @Implementation
- protected static ViewConfiguration get(Context context) {
- ViewConfiguration viewConfiguration = new ViewConfiguration();
- ShadowViewConfiguration shadowViewConfiguration = Shadow.extract(viewConfiguration);
- shadowViewConfiguration.setup(context);
-
- if (RuntimeEnvironment.getApiLevel() >= android.os.Build.VERSION_CODES.Q) {
- reflector(ViewConfigurationReflector.class, viewConfiguration)
- .setConstructedWithContext(true);
+ if (RuntimeEnvironment.getApiLevel() >= Q && !useRealMinScalingSpan()) {
+ reflector(ViewConfigurationReflector.class, realViewConfiguration).setMinScalingSpan(0);
}
-
- return viewConfiguration;
- }
-
- @Implementation
- protected static int getScrollBarSize() {
- return SCROLL_BAR_SIZE;
- }
-
- @Implementation
- protected int getScaledScrollBarSize() {
- return scrollbarSize;
}
@Implementation
@@ -168,21 +152,6 @@ public class ShadowViewConfiguration {
}
@Implementation
- protected int getScaledMinimumFlingVelocity() {
- return minimumFlingVelocity;
- }
-
- @Implementation
- protected static int getMaximumFlingVelocity() {
- return MAXIMUM_FLING_VELOCITY;
- }
-
- @Implementation
- protected int getScaledMaximumFlingVelocity() {
- return maximumFlingVelocity;
- }
-
- @Implementation
protected int getScaledMaximumDrawingCacheSize() {
return maximumDrawingCacheSize;
}
@@ -198,7 +167,30 @@ public class ShadowViewConfiguration {
@ForType(ViewConfiguration.class)
interface ViewConfigurationReflector {
- @Accessor("mConstructedWithContext")
- void setConstructedWithContext(boolean value);
+
+ @Accessor("mMinScalingSpan")
+ void setMinScalingSpan(int minScalingSpan);
+
+ @Static
+ @Accessor("sConfigurations")
+ SparseArray<ViewConfiguration> getStaticCache();
+ }
+
+ /**
+ * Due to overzealous shadowing, the return value of {@link
+ * ViewConfiguration#getScaledMinimumScalingSpan} was previously 0, when it should be around 170
+ * for an mdpi display with density factor 1. This issue has been fixed, but there may be tests
+ * that emit touch events to trigger pinching/spreading that rely on the previous incorrect
+ * behavior. These tests have an option to use a system property to enable this previous bug.
+ */
+ private static boolean useRealMinScalingSpan() {
+ return Boolean.parseBoolean(System.getProperty("robolectric.useRealMinScalingSpan", "true"));
+ }
+
+ @Resetter
+ public static void reset() {
+ SparseArray<ViewConfiguration> configurations =
+ reflector(ViewConfigurationReflector.class).getStaticCache();
+ configurations.clear();
}
}
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..fe582460b 100644
--- a/shadows/framework/src/main/java/org/robolectric/shadows/ShadowViewRootImpl.java
+++ b/shadows/framework/src/main/java/org/robolectric/shadows/ShadowViewRootImpl.java
@@ -10,12 +10,10 @@ import android.content.res.Configuration;
import android.graphics.Rect;
import android.os.Build;
import android.os.Build.VERSION_CODES;
-import android.os.Looper;
import android.os.RemoteException;
import android.util.MergedConfiguration;
import android.view.Display;
import android.view.HandlerActionQueue;
-import android.view.IWindowSession;
import android.view.InsetsState;
import android.view.Surface;
import android.view.SurfaceControl;
@@ -94,13 +92,6 @@ public class ShadowViewRootImpl {
ShadowViewRootImpl.isNavigationBarVisible = Optional.empty();
}
- @Implementation(maxSdk = VERSION_CODES.JELLY_BEAN)
- protected static IWindowSession getWindowSession(Looper mainLooper) {
- IWindowSession windowSession = ShadowWindowManagerGlobal.getWindowSession();
- ReflectionHelpers.setStaticField(ViewRootImpl.class, "sWindowSession", windowSession);
- return windowSession;
- }
-
@Implementation
public void playSoundEffect(int effectId) {}
@@ -388,15 +379,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 +449,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/ShadowWindowManagerGlobal.java b/shadows/framework/src/main/java/org/robolectric/shadows/ShadowWindowManagerGlobal.java
index 456609dea..b749a962a 100644
--- a/shadows/framework/src/main/java/org/robolectric/shadows/ShadowWindowManagerGlobal.java
+++ b/shadows/framework/src/main/java/org/robolectric/shadows/ShadowWindowManagerGlobal.java
@@ -1,6 +1,5 @@
package org.robolectric.shadows;
-import static android.os.Build.VERSION_CODES.JELLY_BEAN_MR1;
import static android.os.Build.VERSION_CODES.P;
import static android.os.Build.VERSION_CODES.UPSIDE_DOWN_CAKE;
import static com.google.common.base.Preconditions.checkArgument;
@@ -18,7 +17,6 @@ import android.content.Context;
import android.graphics.Rect;
import android.os.Binder;
import android.os.IBinder;
-import android.os.Looper;
import android.os.RemoteException;
import android.os.ServiceManager;
import android.os.SystemClock;
@@ -322,11 +320,6 @@ public class ShadowWindowManagerGlobal {
return windowSession;
}
- @Implementation(maxSdk = JELLY_BEAN_MR1)
- protected static Object getWindowSession(Looper looper) {
- return getWindowSession();
- }
-
@Implementation
protected static synchronized IWindowSession peekWindowSession() {
return windowSession;
diff --git a/shadows/framework/src/main/java/org/robolectric/shadows/ShadowWindowManagerImpl.java b/shadows/framework/src/main/java/org/robolectric/shadows/ShadowWindowManagerImpl.java
index 9fd17e952..bf54a5c14 100644
--- a/shadows/framework/src/main/java/org/robolectric/shadows/ShadowWindowManagerImpl.java
+++ b/shadows/framework/src/main/java/org/robolectric/shadows/ShadowWindowManagerImpl.java
@@ -1,6 +1,5 @@
package org.robolectric.shadows;
-import static android.os.Build.VERSION_CODES.JELLY_BEAN;
import static android.os.Build.VERSION_CODES.R;
import static android.os.Build.VERSION_CODES.S_V2;
import static android.view.View.SYSTEM_UI_FLAG_VISIBLE;
@@ -66,11 +65,6 @@ public class ShadowWindowManagerImpl extends ShadowWindowManager {
return ImmutableList.copyOf(views.get(realObject.getDefaultDisplay().getDisplayId()));
}
- @Implementation(maxSdk = JELLY_BEAN)
- public Display getDefaultDisplay() {
- return reflector(ReflectorWindowManagerImpl.class, realObject).getDefaultDisplay();
- }
-
/** Re implement to avoid server call */
@Implementation(minSdk = R, maxSdk = S_V2)
protected WindowInsets getWindowInsetsFromServer(WindowManager.LayoutParams attrs, Rect bounds) {
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..578549a5c 100644
--- a/shadows/framework/src/main/java/org/robolectric/shadows/ShadowXmlBlock.java
+++ b/shadows/framework/src/main/java/org/robolectric/shadows/ShadowXmlBlock.java
@@ -3,7 +3,6 @@ package org.robolectric.shadows;
import static org.robolectric.res.android.Errors.NO_ERROR;
import android.os.Build.VERSION_CODES;
-import org.robolectric.RuntimeEnvironment;
import org.robolectric.annotation.Implementation;
import org.robolectric.annotation.Implements;
import org.robolectric.res.android.Ref;
@@ -17,7 +16,7 @@ import org.xmlpull.v1.XmlPullParserException;
public class ShadowXmlBlock {
@Implementation
- protected static Number nativeCreate(byte[] bArray, int off, int len) {
+ protected static long nativeCreate(byte[] bArray, int off, int len) {
if (bArray == null) {
throw new NullPointerException();
}
@@ -39,31 +38,21 @@ public class ShadowXmlBlock {
throw new IllegalArgumentException();
}
- return RuntimeEnvironment.castNativePtr(Registries.NATIVE_RES_XML_TREES.register(osb));
+ return 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)
- protected static Number nativeGetStringBlock(long obj) {
+ @Implementation
+ protected static long nativeGetStringBlock(long obj) {
ResXMLTree osb = Registries.NATIVE_RES_XML_TREES.getNativeObject(obj);
-// if (osb == NULL) {
-// jniThrowNullPointerException(env, NULL);
-// return 0;
-// }
-
- return RuntimeEnvironment.castNativePtr(osb.getStrings().getNativePtr());
- }
+ // if (osb == NULL) {
+ // jniThrowNullPointerException(env, NULL);
+ // return 0;
+ // }
- @Implementation(maxSdk = VERSION_CODES.KITKAT_WATCH)
- protected static int nativeCreateParseState(int obj) {
- return (int)nativeCreateParseState((long)obj);
+ return osb.getStrings().getNativePtr();
}
- @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 +91,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 +121,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 +130,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 +139,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 +148,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 +229,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 +254,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,