Skip to content

Commit f0eb740

Browse files
committed
Add lint check to ban usage of non-default @VisibleForTesting params
Suppresses existing API lint issues in modified libraries so that we can pass updateApi. Removes @VisibleForTesting annotations gated by @RestrictTo, which don't serve a practical purpose beyond documentation. Baselines rapidly-changing credential library so that we can actually get this landed. Bug: 277361353 Test: BanVisibleForTestingParamsTest Test: ./gradlew lintDebug Merged-In: Iece4b035e3796ff3f0516193bc1dbcde8aa1307c Change-Id: Iece4b035e3796ff3f0516193bc1dbcde8aa1307c
1 parent defa023 commit f0eb740

File tree

63 files changed

+2116
-270
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

63 files changed

+2116
-270
lines changed

activity/activity/src/main/java/androidx/activity/EdgeToEdge.kt

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -34,13 +34,13 @@ import androidx.core.view.WindowInsetsControllerCompat
3434

3535
// The light scrim color used in the platform API 29+
3636
// https://cs.android.com/android/platform/superproject/+/master:frameworks/base/core/java/com/android/internal/policy/DecorView.java;drc=6ef0f022c333385dba2c294e35b8de544455bf19;l=142
37-
@VisibleForTesting(otherwise = VisibleForTesting.PRIVATE)
37+
@VisibleForTesting
3838
internal val DefaultLightScrim = Color.argb(0xe6, 0xFF, 0xFF, 0xFF)
3939

4040
// The dark scrim color used in the platform.
4141
// https://cs.android.com/android/platform/superproject/+/master:frameworks/base/core/res/res/color/system_bar_background_semi_transparent.xml
4242
// https://cs.android.com/android/platform/superproject/+/master:frameworks/base/core/res/remote_color_resources_res/values/colors.xml;l=67
43-
@VisibleForTesting(otherwise = VisibleForTesting.PRIVATE)
43+
@VisibleForTesting
4444
internal val DefaultDarkScrim = Color.argb(0x80, 0x1b, 0x1b, 0x1b)
4545

4646
private var Impl: EdgeToEdgeImpl? = null

benchmark/benchmark-common/src/main/java/androidx/benchmark/BenchmarkState.kt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -146,7 +146,7 @@ public class BenchmarkState internal constructor(
146146
* This value is overridden by the end of the warmup stage. The default value defines
147147
* behavior for modes that bypass warmup (dryRun and startup).
148148
*/
149-
@VisibleForTesting(otherwise = VisibleForTesting.PRIVATE)
149+
@VisibleForTesting
150150
internal var iterationsPerRepeat = 1
151151

152152
private var state = NOT_STARTED // Current benchmark state.

buildSrc/private/src/main/kotlin/androidx/build/LintConfiguration.kt

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -231,6 +231,9 @@ fun Project.configureLint(lint: Lint, extension: AndroidXExtension, isLibrary: B
231231
// Disable until ag/19949626 goes in (b/261918265)
232232
disable.add("MissingQuantity")
233233

234+
// Disable new lint check so that we can land incrementally.
235+
disable.add("VisibleForTests")
236+
234237
// Provide stricter enforcement for project types intended to run on a device.
235238
if (extension.type.compilationTarget == CompilationTarget.DEVICE) {
236239
fatal.add("Assert")

camera/camera-camera2-pipe-integration/src/main/java/androidx/camera/camera2/pipe/integration/interop/Camera2CameraControl.kt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -49,7 +49,7 @@ class Camera2CameraControl
4949
private constructor(
5050
private val compat: Camera2CameraControlCompat,
5151
private val threads: UseCaseThreads,
52-
@VisibleForTesting(otherwise = VisibleForTesting.PRIVATE) internal val requestListener:
52+
@VisibleForTesting internal val requestListener:
5353
ComboRequestListener,
5454
) : UseCaseCameraControl {
5555

camera/camera-camera2/lint-baseline.xml

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -136,4 +136,13 @@
136136
file="src/main/java/androidx/camera/camera2/internal/ImageCaptureOptionUnpacker.java"/>
137137
</issue>
138138

139+
<issue
140+
id="VisibleForTests"
141+
message="This method should only be accessed from tests or within private scope"
142+
errorLine1=" characteristics = CameraCharacteristicsCompat.toCameraCharacteristicsCompat("
143+
errorLine2=" ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~">
144+
<location
145+
file="src/main/java/androidx/camera/camera2/internal/compat/CameraManagerCompat.java"/>
146+
</issue>
147+
139148
</issues>

camera/camera-camera2/src/main/java/androidx/camera/camera2/internal/compat/CameraCharacteristicsCompat.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -62,7 +62,7 @@ private CameraCharacteristicsCompat(@NonNull CameraCharacteristics cameraCharact
6262
* Tests might need to create CameraCharacteristicsCompat directly for convenience. Elsewhere
6363
* we should get the CameraCharacteristicsCompat instance from {@link CameraManagerCompat}.
6464
*/
65-
@VisibleForTesting(otherwise = VisibleForTesting.PACKAGE_PRIVATE)
65+
@VisibleForTesting
6666
@NonNull
6767
public static CameraCharacteristicsCompat toCameraCharacteristicsCompat(
6868
@NonNull CameraCharacteristics characteristics, @NonNull String cameraId) {

compose/animation/animation-core/src/commonMain/kotlin/androidx/compose/animation/core/Animation.kt

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -108,7 +108,6 @@ fun <T, V : AnimationVector> Animation<T, V>.getVelocityFromNanos(playTimeNanos:
108108
* @param initialVelocity the initial velocity to start the animation at
109109
* @suppress
110110
*/
111-
/*@VisibleForTesting(otherwise = PACKAGE_PRIVATE)*/
112111
fun <V : AnimationVector> VectorizedAnimationSpec<V>.createAnimation(
113112
initialValue: V,
114113
targetValue: V,

compose/animation/animation-core/src/commonMain/kotlin/androidx/compose/animation/core/SpringEstimation.kt

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,6 @@ import kotlin.math.sqrt
2626
* Returns the estimated time that the spring will last be at [delta]
2727
* @suppress
2828
*/
29-
/*@VisibleForTesting(otherwise = VisibleForTesting.PACKAGE_PRIVATE)*/
3029
fun estimateAnimationDurationMillis(
3130
stiffness: Float,
3231
dampingRatio: Float,
@@ -45,7 +44,6 @@ fun estimateAnimationDurationMillis(
4544
* Returns the estimated time that the spring will last be at [delta]
4645
* @suppress
4746
*/
48-
/*@VisibleForTesting(otherwise = VisibleForTesting.PACKAGE_PRIVATE)*/
4947
fun estimateAnimationDurationMillis(
5048
stiffness: Double,
5149
dampingRatio: Double,
@@ -69,7 +67,6 @@ fun estimateAnimationDurationMillis(
6967
* Returns the estimated time that the spring will last be at [delta]
7068
* @suppress
7169
*/
72-
/*@VisibleForTesting(otherwise = VisibleForTesting.PACKAGE_PRIVATE)*/
7370
fun estimateAnimationDurationMillis(
7471
springConstant: Double,
7572
dampingCoefficient: Double,

compose/ui/ui-test-junit4/src/androidMain/kotlin/androidx/compose/ui/test/junit4/ComposeRootRegistry.android.kt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -61,7 +61,7 @@ internal class ComposeRootRegistry {
6161
/**
6262
* Cleans up the changes made by [setupRegistry]. Call this after your test has run.
6363
*/
64-
@VisibleForTesting(otherwise = VisibleForTesting.PRIVATE)
64+
@VisibleForTesting
6565
internal fun tearDownRegistry() {
6666
synchronized(lock) {
6767
// Stop accepting new roots

compose/ui/ui-test-junit4/src/jvmMain/kotlin/androidx/compose/ui/test/junit4/IdlingResourceRegistry.jvm.kt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,7 @@ import kotlinx.coroutines.delay
2727
import kotlinx.coroutines.launch
2828

2929
internal class IdlingResourceRegistry
30-
@VisibleForTesting(otherwise = VisibleForTesting.PRIVATE)
30+
@VisibleForTesting
3131
@InternalTestApi
3232
internal constructor(
3333
private val pollScopeOverride: CoroutineScope?

0 commit comments

Comments
 (0)