Merge "Add package-private DelegatingOpenHelper and have SqliteCopyOpenHelper and QueryInterceptorOpenHelper implement it so that they can be configured in the RoomDataBase.init block." into androidx-main
diff --git a/appcompat/appcompat-resources/src/androidTest/java/androidx/appcompat/graphics/drawable/AnimatedStateListDrawableCompatTest.java b/appcompat/appcompat-resources/src/androidTest/java/androidx/appcompat/graphics/drawable/AnimatedStateListDrawableCompatTest.java
index 10c86dc..86560c0 100644
--- a/appcompat/appcompat-resources/src/androidTest/java/androidx/appcompat/graphics/drawable/AnimatedStateListDrawableCompatTest.java
+++ b/appcompat/appcompat-resources/src/androidTest/java/androidx/appcompat/graphics/drawable/AnimatedStateListDrawableCompatTest.java
@@ -228,6 +228,7 @@
}
}
+ @SuppressWarnings("deprecation")
public class MockDrawable extends Drawable {
@Override
public void draw(Canvas canvas) {
diff --git a/appcompat/appcompat-resources/src/androidTest/java/androidx/appcompat/graphics/drawable/MyDrawable.java b/appcompat/appcompat-resources/src/androidTest/java/androidx/appcompat/graphics/drawable/MyDrawable.java
index b0be5f9..28aa645 100644
--- a/appcompat/appcompat-resources/src/androidTest/java/androidx/appcompat/graphics/drawable/MyDrawable.java
+++ b/appcompat/appcompat-resources/src/androidTest/java/androidx/appcompat/graphics/drawable/MyDrawable.java
@@ -25,6 +25,7 @@
/**
* Simple custom drawable.
*/
+@SuppressWarnings("deprecation")
public class MyDrawable extends Drawable {
private final Paint mPaint;
diff --git a/appcompat/appcompat-resources/src/androidTest/java/androidx/appcompat/widget/TintResourcesTest.java b/appcompat/appcompat-resources/src/androidTest/java/androidx/appcompat/widget/TintResourcesTest.java
index 5c3e673..313399e 100644
--- a/appcompat/appcompat-resources/src/androidTest/java/androidx/appcompat/widget/TintResourcesTest.java
+++ b/appcompat/appcompat-resources/src/androidTest/java/androidx/appcompat/widget/TintResourcesTest.java
@@ -25,18 +25,18 @@
import androidx.test.ext.junit.runners.AndroidJUnit4;
import androidx.test.filters.SmallTest;
-import androidx.test.rule.ActivityTestRule;
import org.junit.Rule;
import org.junit.Test;
import org.junit.runner.RunWith;
+@SuppressWarnings("deprecation")
@SmallTest
@RunWith(AndroidJUnit4.class)
public class TintResourcesTest {
@Rule
- public final ActivityTestRule<Activity> mActivityTestRule =
- new ActivityTestRule<>(Activity.class);
+ public final androidx.test.rule.ActivityTestRule<Activity> mActivityTestRule =
+ new androidx.test.rule.ActivityTestRule<>(Activity.class);
@Test
public void testTintResourcesDelegateBackToOriginalResources() {
diff --git a/appcompat/appcompat/src/androidTest/java/androidx/appcompat/app/AlertDialogCursorTest.java b/appcompat/appcompat/src/androidTest/java/androidx/appcompat/app/AlertDialogCursorTest.java
index d32054d..6ce6ee6 100644
--- a/appcompat/appcompat/src/androidTest/java/androidx/appcompat/app/AlertDialogCursorTest.java
+++ b/appcompat/appcompat/src/androidTest/java/androidx/appcompat/app/AlertDialogCursorTest.java
@@ -65,6 +65,7 @@
import java.io.File;
+@SuppressWarnings("unchecked")
@LargeTest
@RunWith(AndroidJUnit4.class)
public class AlertDialogCursorTest {
diff --git a/appcompat/appcompat/src/androidTest/java/androidx/appcompat/app/AlertDialogTest.java b/appcompat/appcompat/src/androidTest/java/androidx/appcompat/app/AlertDialogTest.java
index 923ec16..e197fff 100644
--- a/appcompat/appcompat/src/androidTest/java/androidx/appcompat/app/AlertDialogTest.java
+++ b/appcompat/appcompat/src/androidTest/java/androidx/appcompat/app/AlertDialogTest.java
@@ -104,6 +104,7 @@
* is rendered by a single <code>CheckedTextView</code>.</li>
* </ul>
*/
+@SuppressWarnings("unchecked")
@LargeTest
public class AlertDialogTest {
@Rule
diff --git a/appcompat/appcompat/src/androidTest/java/androidx/appcompat/testutils/AppCompatTintableViewActions.java b/appcompat/appcompat/src/androidTest/java/androidx/appcompat/testutils/AppCompatTintableViewActions.java
index 0f29c4c..36c0f87 100644
--- a/appcompat/appcompat/src/androidTest/java/androidx/appcompat/testutils/AppCompatTintableViewActions.java
+++ b/appcompat/appcompat/src/androidTest/java/androidx/appcompat/testutils/AppCompatTintableViewActions.java
@@ -36,6 +36,7 @@
import org.hamcrest.Matcher;
+@SuppressWarnings("unchecked")
public class AppCompatTintableViewActions {
/**
* Sets the passed color state list as the background tint on a {@link View}.
diff --git a/appcompat/appcompat/src/androidTest/java/androidx/appcompat/widget/AppCompatBaseImageViewTest.java b/appcompat/appcompat/src/androidTest/java/androidx/appcompat/widget/AppCompatBaseImageViewTest.java
index fe4058d..18f7ef7 100755
--- a/appcompat/appcompat/src/androidTest/java/androidx/appcompat/widget/AppCompatBaseImageViewTest.java
+++ b/appcompat/appcompat/src/androidTest/java/androidx/appcompat/widget/AppCompatBaseImageViewTest.java
@@ -69,7 +69,7 @@
public void testImageTintingAcrossStateChange() {
final @IdRes int viewId = R.id.view_tinted_source;
final Resources res = mActivity.getResources();
- final T view = (T) mContainer.findViewById(viewId);
+ final T view = mContainer.findViewById(viewId);
@ColorInt int lilacDefault = ResourcesCompat.getColor(res, R.color.lilac_default, null);
@ColorInt int lilacDisabled = ResourcesCompat.getColor(res, R.color.lilac_disabled, null);
@@ -147,7 +147,7 @@
public void testImageTintingAcrossModeChange() {
final @IdRes int viewId = R.id.view_untinted_source;
final Resources res = mActivity.getResources();
- final T view = (T) mContainer.findViewById(viewId);
+ final T view = mContainer.findViewById(viewId);
@ColorInt int emeraldDefault = ResourcesCompat.getColor(
res, R.color.emerald_translucent_default, null);
@@ -218,7 +218,7 @@
public void testImageTintingWithDefaultMode() {
final @IdRes int viewId = R.id.view_untinted_source;
final Resources res = mActivity.getResources();
- final T view = (T) mContainer.findViewById(viewId);
+ final T view = mContainer.findViewById(viewId);
@ColorInt final int sandDefault = ResourcesCompat.getColor(
res, R.color.sand_default, null);
@@ -258,7 +258,7 @@
public void testImageOpaqueTintingAcrossImageChange() {
final @IdRes int viewId = R.id.view_tinted_no_source;
final Resources res = mActivity.getResources();
- final T view = (T) mContainer.findViewById(viewId);
+ final T view = mContainer.findViewById(viewId);
@ColorInt int lilacDefault = ResourcesCompat.getColor(res, R.color.lilac_default, null);
@ColorInt int lilacDisabled = ResourcesCompat.getColor(res, R.color.lilac_disabled, null);
@@ -313,7 +313,7 @@
public void testImageTranslucentTintingAcrossImageChange() {
final @IdRes int viewId = R.id.view_untinted_no_source;
final Resources res = mActivity.getResources();
- final T view = (T) mContainer.findViewById(viewId);
+ final T view = mContainer.findViewById(viewId);
@ColorInt int emeraldDefault = ResourcesCompat.getColor(
res, R.color.emerald_translucent_default, null);
@@ -403,7 +403,7 @@
public void testImageTintingAcrossBackgroundTintingChange() {
final @IdRes int viewId = R.id.view_untinted_source;
final Resources res = mActivity.getResources();
- final T view = (T) mContainer.findViewById(viewId);
+ final T view = mContainer.findViewById(viewId);
@ColorInt int lilacDefault = ResourcesCompat.getColor(res, R.color.lilac_default, null);
@ColorInt int lilacDisabled = ResourcesCompat.getColor(res, R.color.lilac_disabled, null);
diff --git a/appcompat/appcompat/src/androidTest/java/androidx/appcompat/widget/AppCompatBaseViewTest.java b/appcompat/appcompat/src/androidTest/java/androidx/appcompat/widget/AppCompatBaseViewTest.java
index 2137144..cc18495 100644
--- a/appcompat/appcompat/src/androidTest/java/androidx/appcompat/widget/AppCompatBaseViewTest.java
+++ b/appcompat/appcompat/src/androidTest/java/androidx/appcompat/widget/AppCompatBaseViewTest.java
@@ -110,7 +110,7 @@
}
final @IdRes int viewId = R.id.view_tinted_no_background;
- final T view = (T) mContainer.findViewById(viewId);
+ final T view = mContainer.findViewById(viewId);
// Note that all the asserts in this test check that the view background
// is null. This is because the matching child in the activity doesn't define any
@@ -153,7 +153,7 @@
}
final @IdRes int viewId = R.id.view_tinted_no_background;
- final T view = (T) mContainer.findViewById(viewId);
+ final T view = mContainer.findViewById(viewId);
// Note that all the asserts in this test check that the view background
// is null. This is because the matching child in the activity doesn't define any
@@ -192,7 +192,7 @@
@Test
public void testBackgroundTintingAcrossStateChange() {
final @IdRes int viewId = R.id.view_tinted_background;
- final T view = (T) mContainer.findViewById(viewId);
+ final T view = mContainer.findViewById(viewId);
final @ColorInt int lilacDefault = ResourcesCompat.getColor(
mResources, R.color.lilac_default, null);
@@ -272,7 +272,7 @@
@Test
public void testBackgroundTintingViewCompatAcrossStateChange() {
final @IdRes int viewId = R.id.view_tinted_background;
- final T view = (T) mContainer.findViewById(viewId);
+ final T view = mContainer.findViewById(viewId);
final @ColorInt int lilacDefault = ResourcesCompat.getColor(
mResources, R.color.lilac_default, null);
@@ -353,7 +353,7 @@
@Test
public void testBackgroundTintingAcrossModeChange() {
final @IdRes int viewId = R.id.view_untinted_background;
- final T view = (T) mContainer.findViewById(viewId);
+ final T view = mContainer.findViewById(viewId);
final @ColorInt int emeraldDefault = ResourcesCompat.getColor(
mResources, R.color.emerald_translucent_default, null);
@@ -421,7 +421,7 @@
@Test
public void testBackgroundTintingViewCompatAcrossModeChange() {
final @IdRes int viewId = R.id.view_untinted_background;
- final T view = (T) mContainer.findViewById(viewId);
+ final T view = mContainer.findViewById(viewId);
final @ColorInt int emeraldDefault = ResourcesCompat.getColor(
mResources, R.color.emerald_translucent_default, null);
@@ -488,7 +488,7 @@
@Test
public void testBackgroundOpaqueTintingAcrossBackgroundChange() {
final @IdRes int viewId = R.id.view_tinted_no_background;
- final T view = (T) mContainer.findViewById(viewId);
+ final T view = mContainer.findViewById(viewId);
final @ColorInt int lilacDefault = ResourcesCompat.getColor(
mResources, R.color.lilac_default, null);
@@ -546,7 +546,7 @@
@Test
public void testBackgroundTranslucentTintingAcrossBackgroundChange() {
final @IdRes int viewId = R.id.view_untinted_no_background;
- final T view = (T) mContainer.findViewById(viewId);
+ final T view = mContainer.findViewById(viewId);
final @ColorInt int emeraldDefault = ResourcesCompat.getColor(
mResources, R.color.emerald_translucent_default, null);
@@ -628,7 +628,7 @@
}
protected void testUntintedBackgroundTintingViewCompatAcrossStateChange(@IdRes int viewId) {
- final T view = (T) mContainer.findViewById(viewId);
+ final T view = mContainer.findViewById(viewId);
final @ColorInt int oceanDefault = ResourcesCompat.getColor(
mResources, R.color.ocean_default, null);
diff --git a/appcompat/appcompat/src/androidTest/java/androidx/appcompat/widget/AppCompatEditTextReceiveContentTest.java b/appcompat/appcompat/src/androidTest/java/androidx/appcompat/widget/AppCompatEditTextReceiveContentTest.java
index fb22cdc..3fc3605 100644
--- a/appcompat/appcompat/src/androidTest/java/androidx/appcompat/widget/AppCompatEditTextReceiveContentTest.java
+++ b/appcompat/appcompat/src/androidTest/java/androidx/appcompat/widget/AppCompatEditTextReceiveContentTest.java
@@ -86,6 +86,7 @@
private OnReceiveContentListener mMockReceiver;
private ClipboardManager mClipboardManager;
+ @SuppressWarnings("unchecked")
@UiThreadTest
@Before
public void before() {
diff --git a/autofill/autofill/src/androidTest/java/androidx/autofill/inline/RendererTest.java b/autofill/autofill/src/androidTest/java/androidx/autofill/inline/RendererTest.java
index c186e75..cb51c64 100644
--- a/autofill/autofill/src/androidTest/java/androidx/autofill/inline/RendererTest.java
+++ b/autofill/autofill/src/androidTest/java/androidx/autofill/inline/RendererTest.java
@@ -40,7 +40,6 @@
import androidx.test.filters.SdkSuppress;
import androidx.test.filters.SmallTest;
import androidx.test.platform.app.InstrumentationRegistry;
-import androidx.test.rule.ActivityTestRule;
import org.junit.Before;
import org.junit.Rule;
@@ -56,10 +55,11 @@
@SdkSuppress(minSdkVersion = 30) // Needed only on 30 and above
public class RendererTest {
+ @SuppressWarnings("deprecation")
@Rule
@NonNull
- public final ActivityTestRule<InlineUiActivity> mActivityTestRule =
- new ActivityTestRule<>(InlineUiActivity.class);
+ public final androidx.test.rule.ActivityTestRule<InlineUiActivity> mActivityTestRule =
+ new androidx.test.rule.ActivityTestRule<>(InlineUiActivity.class);
private Instrumentation mInstrumentation;
private Context mContext;
diff --git a/autofill/autofill/src/androidTest/java/androidx/autofill/inline/v1/InlineSuggestionUiTest.java b/autofill/autofill/src/androidTest/java/androidx/autofill/inline/v1/InlineSuggestionUiTest.java
index e26e5af..943322b 100644
--- a/autofill/autofill/src/androidTest/java/androidx/autofill/inline/v1/InlineSuggestionUiTest.java
+++ b/autofill/autofill/src/androidTest/java/androidx/autofill/inline/v1/InlineSuggestionUiTest.java
@@ -51,7 +51,6 @@
import androidx.test.filters.SdkSuppress;
import androidx.test.filters.SmallTest;
import androidx.test.platform.app.InstrumentationRegistry;
-import androidx.test.rule.ActivityTestRule;
import org.junit.Assert;
import org.junit.Before;
@@ -71,10 +70,11 @@
private static final String TITLE = "Hello world!";
private static final String SUB_TITLE = "From God";
+ @SuppressWarnings("deprecation")
@Rule
@NonNull
- public final ActivityTestRule<InlineUiActivity> mActivityTestRule =
- new ActivityTestRule<>(InlineUiActivity.class);
+ public final androidx.test.rule.ActivityTestRule<InlineUiActivity> mActivityTestRule =
+ new androidx.test.rule.ActivityTestRule<>(InlineUiActivity.class);
private Instrumentation mInstrumentation;
private Context mContext;
diff --git a/biometric/biometric/src/test/java/androidx/biometric/KeyguardUtilsTest.java b/biometric/biometric/src/test/java/androidx/biometric/KeyguardUtilsTest.java
index 952adaa..453f6a9 100644
--- a/biometric/biometric/src/test/java/androidx/biometric/KeyguardUtilsTest.java
+++ b/biometric/biometric/src/test/java/androidx/biometric/KeyguardUtilsTest.java
@@ -88,6 +88,7 @@
assertThat(KeyguardUtils.isDeviceSecuredWithCredential(mContext)).isFalse();
}
+ @SuppressWarnings("unchecked")
@Test
@Config(minSdk = Build.VERSION_CODES.M)
public void testIsDeviceSecuredWithCredential_CorrectlyReturnsTrue_OnApi23AndAbove() {
diff --git a/browser/browser/src/androidTest/java/androidx/browser/browseractions/BrowserActionsFallbackMenuUiTest.java b/browser/browser/src/androidTest/java/androidx/browser/browseractions/BrowserActionsFallbackMenuUiTest.java
index 390df87..689dc8f 100644
--- a/browser/browser/src/androidTest/java/androidx/browser/browseractions/BrowserActionsFallbackMenuUiTest.java
+++ b/browser/browser/src/androidTest/java/androidx/browser/browseractions/BrowserActionsFallbackMenuUiTest.java
@@ -31,7 +31,6 @@
import androidx.browser.customtabs.TestActivity;
import androidx.test.ext.junit.runners.AndroidJUnit4;
import androidx.test.filters.LargeTest;
-import androidx.test.rule.ActivityTestRule;
import androidx.testutils.PollingCheck;
import org.junit.Before;
@@ -45,6 +44,7 @@
import java.util.concurrent.CountDownLatch;
import java.util.concurrent.TimeUnit;
+@SuppressWarnings("deprecation")
/** Unit tests for {@link BrowserActionsFallbackMenuUi}. */
@RunWith(AndroidJUnit4.class)
@LargeTest
@@ -53,8 +53,8 @@
private static final String CUSTOM_ITEM_TITLE_1 = "Open url";
private static final String CUSTOM_ITEM_TITLE_2 = "Share url";
@Rule
- public final ActivityTestRule<TestActivity> mActivityTestRule =
- new ActivityTestRule<>(TestActivity.class);
+ public final androidx.test.rule.ActivityTestRule<TestActivity> mActivityTestRule =
+ new androidx.test.rule.ActivityTestRule<>(TestActivity.class);
@Rule
public final EnableComponentsTestRule mEnableComponents = new EnableComponentsTestRule(
diff --git a/browser/browser/src/androidTest/java/androidx/browser/browseractions/BrowserActionsIntentTest.java b/browser/browser/src/androidTest/java/androidx/browser/browseractions/BrowserActionsIntentTest.java
index b8ace06..7dae296 100644
--- a/browser/browser/src/androidTest/java/androidx/browser/browseractions/BrowserActionsIntentTest.java
+++ b/browser/browser/src/androidTest/java/androidx/browser/browseractions/BrowserActionsIntentTest.java
@@ -38,6 +38,7 @@
import java.util.List;
/** Unit tests for {@link BrowserActionsIntent}. */
+@SuppressWarnings("deprecation")
@RunWith(AndroidJUnit4.class)
@SmallTest
public final class BrowserActionsIntentTest {
diff --git a/browser/browser/src/androidTest/java/androidx/browser/customtabs/PostMessageTest.java b/browser/browser/src/androidTest/java/androidx/browser/customtabs/PostMessageTest.java
index ee74d68..ab0d51b 100644
--- a/browser/browser/src/androidTest/java/androidx/browser/customtabs/PostMessageTest.java
+++ b/browser/browser/src/androidTest/java/androidx/browser/customtabs/PostMessageTest.java
@@ -29,7 +29,6 @@
import androidx.annotation.NonNull;
import androidx.test.ext.junit.runners.AndroidJUnit4;
import androidx.test.filters.SmallTest;
-import androidx.test.rule.ActivityTestRule;
import androidx.test.rule.ServiceTestRule;
import androidx.testutils.PollingCheck;
@@ -40,7 +39,6 @@
import java.util.concurrent.TimeoutException;
-
/**
* Tests for a complete loop between a browser side {@link CustomTabsService}
* and a client side {@link PostMessageService}. Both services are bound to through
@@ -52,9 +50,10 @@
public class PostMessageTest {
@Rule
public final ServiceTestRule mServiceRule = new ServiceTestRule();
+ @SuppressWarnings("deprecation")
@Rule
- public final ActivityTestRule<TestActivity> mActivityTestRule =
- new ActivityTestRule<>(TestActivity.class);
+ public final androidx.test.rule.ActivityTestRule<TestActivity> mActivityTestRule =
+ new androidx.test.rule.ActivityTestRule<>(TestActivity.class);
@Rule
public final EnableComponentsTestRule mEnableComponents = new EnableComponentsTestRule(
TestActivity.class,
diff --git a/browser/browser/src/androidTest/java/androidx/browser/trusted/VerifiedProviderTestRule.java b/browser/browser/src/androidTest/java/androidx/browser/trusted/VerifiedProviderTestRule.java
index d0c433f..e895570 100644
--- a/browser/browser/src/androidTest/java/androidx/browser/trusted/VerifiedProviderTestRule.java
+++ b/browser/browser/src/androidTest/java/androidx/browser/trusted/VerifiedProviderTestRule.java
@@ -18,8 +18,6 @@
import android.content.Context;
-import androidx.test.InstrumentationRegistry;
-
import org.junit.rules.TestWatcher;
import org.junit.runner.Description;
@@ -46,8 +44,9 @@
set(false);
}
+ @SuppressWarnings("deprecation")
private void set(boolean enabled) {
- Context context = InstrumentationRegistry.getContext();
+ Context context = androidx.test.InstrumentationRegistry.getContext();
TestTrustedWebActivityService.setVerifiedProvider(enabled
? Token.create(context.getPackageName(), context.getPackageManager())
: null);
diff --git a/browser/browser/src/test/java/androidx/browser/customtabs/CustomTabColorSchemeParamsTest.java b/browser/browser/src/test/java/androidx/browser/customtabs/CustomTabColorSchemeParamsTest.java
index 3def804..ac2f395 100644
--- a/browser/browser/src/test/java/androidx/browser/customtabs/CustomTabColorSchemeParamsTest.java
+++ b/browser/browser/src/test/java/androidx/browser/customtabs/CustomTabColorSchemeParamsTest.java
@@ -37,6 +37,7 @@
* In particular, for {@link CustomTabsIntent.Builder#setColorSchemeParams} and
* {@link CustomTabsIntent#getColorSchemeParams}
*/
+@SuppressWarnings("deprecation")
@RunWith(RobolectricTestRunner.class)
@DoNotInstrument
public class CustomTabColorSchemeParamsTest {
diff --git a/browser/browser/src/test/java/androidx/browser/customtabs/CustomTabsIntentTest.java b/browser/browser/src/test/java/androidx/browser/customtabs/CustomTabsIntentTest.java
index 215bbd7..08553dc 100644
--- a/browser/browser/src/test/java/androidx/browser/customtabs/CustomTabsIntentTest.java
+++ b/browser/browser/src/test/java/androidx/browser/customtabs/CustomTabsIntentTest.java
@@ -39,6 +39,7 @@
/**
* Tests for CustomTabsIntent.
*/
+@SuppressWarnings("deprecation")
@RunWith(RobolectricTestRunner.class)
@DoNotInstrument
// minSdk For Bundle#getBinder
diff --git a/browser/browser/src/test/java/androidx/browser/trusted/TrustedWebActivityIntentBuilderTest.java b/browser/browser/src/test/java/androidx/browser/trusted/TrustedWebActivityIntentBuilderTest.java
index 59a29ff..8b1847a 100644
--- a/browser/browser/src/test/java/androidx/browser/trusted/TrustedWebActivityIntentBuilderTest.java
+++ b/browser/browser/src/test/java/androidx/browser/trusted/TrustedWebActivityIntentBuilderTest.java
@@ -56,6 +56,7 @@
@Config(minSdk = Build.VERSION_CODES.JELLY_BEAN_MR2)
public class TrustedWebActivityIntentBuilderTest {
+ @SuppressWarnings("deprecation")
@Test
public void intentIsConstructedCorrectly() {
Uri url = Uri.parse("https://test.com/page");
diff --git a/buildSrc/src/main/kotlin/androidx/build/AndroidXPlugin.kt b/buildSrc/src/main/kotlin/androidx/build/AndroidXPlugin.kt
index 09e1a67..a4dd2eb 100644
--- a/buildSrc/src/main/kotlin/androidx/build/AndroidXPlugin.kt
+++ b/buildSrc/src/main/kotlin/androidx/build/AndroidXPlugin.kt
@@ -210,7 +210,7 @@
) {
project.tasks.withType(KotlinCompile::class.java).configureEach { task ->
task.kotlinOptions.jvmTarget = "1.8"
- project.configureCompilationWarnings(task)
+ project.configureJavaCompilationWarnings(task)
if (project.hasProperty(EXPERIMENTAL_KOTLIN_BACKEND_ENABLED)) {
task.kotlinOptions.freeCompilerArgs += listOf("-Xuse-ir=true")
}
@@ -289,6 +289,7 @@
project.configureSourceJarForAndroid(libraryExtension)
project.configureVersionFileWriter(libraryExtension, androidXExtension)
project.addCreateLibraryBuildInfoFileTask(androidXExtension)
+ project.configureJavaCompilationWarnings(androidXExtension)
val verifyDependencyVersionsTask = project.createVerifyDependencyVersionsTask()
val checkReleaseReadyTasks = mutableListOf<TaskProvider<out Task>>()
@@ -313,10 +314,6 @@
verifyDependencyVersionsTask?.configure { task ->
task.dependsOn(libraryVariant.javaCompileProvider)
}
-
- libraryVariant.javaCompileProvider.configure { task ->
- project.configureCompilationWarnings(task)
- }
}
// Standard lint, docs, resource API, and Metalava configuration for AndroidX projects.
@@ -340,9 +337,7 @@
targetCompatibility = VERSION_1_8
}
- project.tasks.withType(JavaCompile::class.java) { task ->
- project.configureCompilationWarnings(task)
- }
+ project.configureJavaCompilationWarnings(extension)
project.hideJavadocTask()
@@ -534,15 +529,6 @@
if (androidXExtension.publish.shouldRelease()) {
project.extra.set("publish", true)
}
- if (!project.rootProject.hasProperty(USE_MAX_DEP_VERSIONS)) {
- defaultPublishVariant { libraryVariant ->
- libraryVariant.javaCompileProvider.configure { javaCompile ->
- if (androidXExtension.failOnDeprecationWarnings) {
- javaCompile.options.compilerArgs.add("-Xlint:deprecation")
- }
- }
- }
- }
}
}
@@ -752,14 +738,23 @@
}
}
-private fun Project.configureCompilationWarnings(task: JavaCompile) {
- if (hasProperty(ALL_WARNINGS_AS_ERRORS)) {
- task.options.compilerArgs.add("-Werror")
- task.options.compilerArgs.add("-Xlint:unchecked")
+private fun Project.configureJavaCompilationWarnings(androidXExtension: AndroidXExtension) {
+ afterEvaluate {
+ project.tasks.withType(JavaCompile::class.java).configureEach { task ->
+ if (hasProperty(ALL_WARNINGS_AS_ERRORS)) {
+ task.options.compilerArgs.add("-Werror")
+ task.options.compilerArgs.add("-Xlint:unchecked")
+ if (androidXExtension.failOnDeprecationWarnings &&
+ !hasProperty(AndroidXPlugin.USE_MAX_DEP_VERSIONS)
+ ) {
+ task.options.compilerArgs.add("-Xlint:deprecation")
+ }
+ }
+ }
}
}
-private fun Project.configureCompilationWarnings(task: KotlinCompile) {
+private fun Project.configureJavaCompilationWarnings(task: KotlinCompile) {
if (hasProperty(ALL_WARNINGS_AS_ERRORS)) {
task.kotlinOptions.allWarningsAsErrors = true
}
diff --git a/camera/camera-camera2/src/androidTest/java/androidx/camera/camera2/CameraDisconnectTest.java b/camera/camera-camera2/src/androidTest/java/androidx/camera/camera2/CameraDisconnectTest.java
index 50460c4..25ce33e 100644
--- a/camera/camera-camera2/src/androidTest/java/androidx/camera/camera2/CameraDisconnectTest.java
+++ b/camera/camera-camera2/src/androidTest/java/androidx/camera/camera2/CameraDisconnectTest.java
@@ -40,7 +40,6 @@
import androidx.test.filters.LargeTest;
import androidx.test.filters.SdkSuppress;
import androidx.test.platform.app.InstrumentationRegistry;
-import androidx.test.rule.ActivityTestRule;
import org.junit.After;
import org.junit.Before;
@@ -60,12 +59,14 @@
@Rule
public TestRule mCameraRule = CameraUtil.grantCameraPermissionAndPreTest();
+ @SuppressWarnings("deprecation")
@Rule
- public ActivityTestRule<CameraXTestActivity> mCameraXTestActivityRule =
- new ActivityTestRule<>(CameraXTestActivity.class, true, false);
+ public androidx.test.rule.ActivityTestRule<CameraXTestActivity> mCameraXTestActivityRule =
+ new androidx.test.rule.ActivityTestRule<>(CameraXTestActivity.class, true, false);
+ @SuppressWarnings("deprecation")
@Rule
- public ActivityTestRule<Camera2TestActivity> mCamera2ActivityRule =
- new ActivityTestRule<>(Camera2TestActivity.class, true, false);
+ public androidx.test.rule.ActivityTestRule<Camera2TestActivity> mCamera2ActivityRule =
+ new androidx.test.rule.ActivityTestRule<>(Camera2TestActivity.class, true, false);
private CameraXTestActivity mCameraXTestActivity;
diff --git a/camera/camera-camera2/src/androidTest/java/androidx/camera/camera2/ImageCaptureTest.java b/camera/camera-camera2/src/androidTest/java/androidx/camera/camera2/ImageCaptureTest.java
index 85fac6e..2da8952 100644
--- a/camera/camera-camera2/src/androidTest/java/androidx/camera/camera2/ImageCaptureTest.java
+++ b/camera/camera-camera2/src/androidTest/java/androidx/camera/camera2/ImageCaptureTest.java
@@ -50,7 +50,7 @@
import androidx.annotation.NonNull;
import androidx.annotation.Nullable;
-import androidx.annotation.experimental.UseExperimental;
+import androidx.annotation.OptIn;
import androidx.camera.camera2.interop.Camera2Interop;
import androidx.camera.camera2.interop.ExperimentalCamera2Interop;
import androidx.camera.core.AspectRatio;
@@ -145,7 +145,7 @@
}
@Before
- @UseExperimental(markerClass = ExperimentalCamera2Interop.class)
+ @OptIn(markerClass = ExperimentalCamera2Interop.class)
public void setUp() throws ExecutionException, InterruptedException {
createDefaultPictureFolderIfNotExist();
mContext = ApplicationProvider.getApplicationContext();
@@ -610,7 +610,7 @@
}
@Test
- @UseExperimental(markerClass = ExperimentalCamera2Interop.class)
+ @OptIn(markerClass = ExperimentalCamera2Interop.class)
public void camera2InteropCaptureSessionCallbacks() {
ImageCapture.Builder builder = new ImageCapture.Builder();
CameraCaptureSession.CaptureCallback captureCallback =
@@ -825,6 +825,7 @@
ImageCapture.ERROR_INVALID_CAMERA);
}
+ @SuppressWarnings("deprecation")
private void createDefaultPictureFolderIfNotExist() {
File pictureFolder = Environment.getExternalStoragePublicDirectory(
Environment.DIRECTORY_PICTURES);
diff --git a/camera/camera-camera2/src/androidTest/java/androidx/camera/camera2/internal/Camera2CameraImplTest.java b/camera/camera-camera2/src/androidTest/java/androidx/camera/camera2/internal/Camera2CameraImplTest.java
index de75e09..e2fa459 100644
--- a/camera/camera-camera2/src/androidTest/java/androidx/camera/camera2/internal/Camera2CameraImplTest.java
+++ b/camera/camera-camera2/src/androidTest/java/androidx/camera/camera2/internal/Camera2CameraImplTest.java
@@ -551,6 +551,7 @@
assertThat(currentState).isEqualTo(CameraInternal.State.RELEASED);
}
+ @SuppressWarnings("unchecked")
@Test
public void openNewCaptureSessionImmediateBeforePreviousCaptureSessionClosed()
throws InterruptedException {
diff --git a/camera/camera-camera2/src/androidTest/java/androidx/camera/camera2/internal/Camera2ImplCameraXTest.java b/camera/camera-camera2/src/androidTest/java/androidx/camera/camera2/internal/Camera2ImplCameraXTest.java
index 0cf4896..30a066d 100644
--- a/camera/camera-camera2/src/androidTest/java/androidx/camera/camera2/internal/Camera2ImplCameraXTest.java
+++ b/camera/camera-camera2/src/androidTest/java/androidx/camera/camera2/internal/Camera2ImplCameraXTest.java
@@ -35,7 +35,7 @@
import android.hardware.camera2.TotalCaptureResult;
import androidx.annotation.NonNull;
-import androidx.annotation.experimental.UseExperimental;
+import androidx.annotation.OptIn;
import androidx.camera.camera2.Camera2Config;
import androidx.camera.camera2.internal.util.SemaphoreReleasingCamera2Callbacks;
import androidx.camera.camera2.internal.util.SemaphoreReleasingCamera2Callbacks.DeviceStateCallback;
@@ -81,7 +81,7 @@
@FlakyTest
@LargeTest
@RunWith(AndroidJUnit4.class)
-@UseExperimental(markerClass = ExperimentalCamera2Interop.class)
+@OptIn(markerClass = ExperimentalCamera2Interop.class)
public final class Camera2ImplCameraXTest {
@CameraSelector.LensFacing
private static final int DEFAULT_LENS_FACING = CameraSelector.LENS_FACING_BACK;
diff --git a/camera/camera-camera2/src/androidTest/java/androidx/camera/camera2/internal/CaptureSessionTest.java b/camera/camera-camera2/src/androidTest/java/androidx/camera/camera2/internal/CaptureSessionTest.java
index fc4877c..20e8154 100644
--- a/camera/camera-camera2/src/androidTest/java/androidx/camera/camera2/internal/CaptureSessionTest.java
+++ b/camera/camera-camera2/src/androidTest/java/androidx/camera/camera2/internal/CaptureSessionTest.java
@@ -43,7 +43,6 @@
import android.media.Image;
import android.media.ImageReader;
import android.media.ImageReader.OnImageAvailableListener;
-import android.os.AsyncTask;
import android.os.Build;
import android.os.Handler;
import android.os.HandlerThread;
@@ -103,6 +102,7 @@
* android.hardware.camera2.CameraDevice} can be opened since it is used to open a {@link
* android.hardware.camera2.CaptureRequest}.
*/
+@SuppressWarnings("unchecked")
@LargeTest
@RunWith(AndroidJUnit4.class)
public final class CaptureSessionTest {
@@ -745,7 +745,8 @@
ArgumentCaptor<Throwable> throwableCaptor = ArgumentCaptor.forClass(Throwable.class);
ListenableFuture<Void> openingFuture = captureSession.open(mTestParameters0.mSessionConfig,
mCameraDeviceHolder.get(), mCaptureSessionOpenerBuilder.build());
- Futures.addCallback(openingFuture, mockFutureCallback, AsyncTask.THREAD_POOL_EXECUTOR);
+ Futures.addCallback(openingFuture, mockFutureCallback,
+ android.os.AsyncTask.THREAD_POOL_EXECUTOR);
openingFuture.cancel(true);
// The captureSession opening should callback onFailure with a CancellationException.
diff --git a/camera/camera-camera2/src/androidTest/java/androidx/camera/camera2/internal/ExposureDeviceTest.java b/camera/camera-camera2/src/androidTest/java/androidx/camera/camera2/internal/ExposureDeviceTest.java
index a053541..69f91ce 100644
--- a/camera/camera-camera2/src/androidTest/java/androidx/camera/camera2/internal/ExposureDeviceTest.java
+++ b/camera/camera-camera2/src/androidTest/java/androidx/camera/camera2/internal/ExposureDeviceTest.java
@@ -40,7 +40,7 @@
import android.view.Surface;
import androidx.annotation.NonNull;
-import androidx.annotation.experimental.UseExperimental;
+import androidx.annotation.OptIn;
import androidx.camera.camera2.internal.compat.CameraManagerCompat;
import androidx.camera.camera2.internal.util.SemaphoreReleasingCamera2Callbacks;
import androidx.camera.camera2.interop.Camera2Interop;
@@ -93,7 +93,7 @@
*/
@LargeTest
@RunWith(AndroidJUnit4.class)
-@UseExperimental(markerClass = ExperimentalExposureCompensation.class)
+@OptIn(markerClass = ExperimentalExposureCompensation.class)
public class ExposureDeviceTest {
@CameraSelector.LensFacing
diff --git a/camera/camera-camera2/src/androidTest/java/androidx/camera/camera2/interop/Camera2CameraControlDeviceTest.java b/camera/camera-camera2/src/androidTest/java/androidx/camera/camera2/interop/Camera2CameraControlDeviceTest.java
index 65f54a8..fc5b274 100644
--- a/camera/camera-camera2/src/androidTest/java/androidx/camera/camera2/interop/Camera2CameraControlDeviceTest.java
+++ b/camera/camera-camera2/src/androidTest/java/androidx/camera/camera2/interop/Camera2CameraControlDeviceTest.java
@@ -38,7 +38,7 @@
import android.hardware.camera2.params.MeteringRectangle;
import android.util.Range;
-import androidx.annotation.experimental.UseExperimental;
+import androidx.annotation.OptIn;
import androidx.camera.camera2.Camera2Config;
import androidx.camera.camera2.internal.Camera2CameraControlImpl;
import androidx.camera.core.CameraSelector;
@@ -70,7 +70,7 @@
@LargeTest
@RunWith(AndroidJUnit4.class)
-@UseExperimental(markerClass = ExperimentalCamera2Interop.class)
+@OptIn(markerClass = ExperimentalCamera2Interop.class)
public final class Camera2CameraControlDeviceTest {
private static final Range<Integer> FAKE_RANGE = new Range<>(0, 30);
private final Instrumentation mInstrumentation = InstrumentationRegistry.getInstrumentation();
diff --git a/camera/camera-camera2/src/androidTest/java/androidx/camera/camera2/interop/Camera2InteropDeviceTest.java b/camera/camera-camera2/src/androidTest/java/androidx/camera/camera2/interop/Camera2InteropDeviceTest.java
index 074e01d..38c3594 100644
--- a/camera/camera-camera2/src/androidTest/java/androidx/camera/camera2/interop/Camera2InteropDeviceTest.java
+++ b/camera/camera-camera2/src/androidTest/java/androidx/camera/camera2/interop/Camera2InteropDeviceTest.java
@@ -36,7 +36,7 @@
import android.hardware.camera2.params.MeteringRectangle;
import android.util.Range;
-import androidx.annotation.experimental.UseExperimental;
+import androidx.annotation.OptIn;
import androidx.camera.camera2.Camera2Config;
import androidx.camera.core.CameraSelector;
import androidx.camera.core.CameraX;
@@ -65,7 +65,7 @@
@LargeTest
@RunWith(AndroidJUnit4.class)
-@UseExperimental(markerClass = ExperimentalCamera2Interop.class)
+@OptIn(markerClass = ExperimentalCamera2Interop.class)
public final class Camera2InteropDeviceTest {
private final Instrumentation mInstrumentation = InstrumentationRegistry.getInstrumentation();
private CameraSelector mCameraSelector;
diff --git a/camera/camera-camera2/src/test/java/androidx/camera/camera2/internal/Camera2CaptureOptionUnpackerTest.java b/camera/camera-camera2/src/test/java/androidx/camera/camera2/internal/Camera2CaptureOptionUnpackerTest.java
index 06e68a0..8ba5a2a 100644
--- a/camera/camera-camera2/src/test/java/androidx/camera/camera2/internal/Camera2CaptureOptionUnpackerTest.java
+++ b/camera/camera-camera2/src/test/java/androidx/camera/camera2/internal/Camera2CaptureOptionUnpackerTest.java
@@ -24,7 +24,7 @@
import android.hardware.camera2.CaptureRequest;
import android.os.Build;
-import androidx.annotation.experimental.UseExperimental;
+import androidx.annotation.OptIn;
import androidx.camera.camera2.impl.Camera2ImplConfig;
import androidx.camera.camera2.interop.Camera2Interop;
import androidx.camera.camera2.interop.ExperimentalCamera2Interop;
@@ -54,7 +54,7 @@
}
@Test
- @UseExperimental(markerClass = ExperimentalCamera2Interop.class)
+ @OptIn(markerClass = ExperimentalCamera2Interop.class)
public void unpackerExtractsCaptureCallbacks() {
ImageCapture.Builder imageCaptureBuilder = new ImageCapture.Builder();
CaptureCallback captureCallback = mock(CaptureCallback.class);
@@ -73,7 +73,7 @@
}
@Test
- @UseExperimental(markerClass = ExperimentalCamera2Interop.class)
+ @OptIn(markerClass = ExperimentalCamera2Interop.class)
public void unpackerExtractsOptions() {
ImageCapture.Builder imageCaptureConfigBuilder = new ImageCapture.Builder();
diff --git a/camera/camera-camera2/src/test/java/androidx/camera/camera2/internal/Camera2DeviceSurfaceManagerTest.java b/camera/camera-camera2/src/test/java/androidx/camera/camera2/internal/Camera2DeviceSurfaceManagerTest.java
index 85d73124c..12109f9 100644
--- a/camera/camera-camera2/src/test/java/androidx/camera/camera2/internal/Camera2DeviceSurfaceManagerTest.java
+++ b/camera/camera-camera2/src/test/java/androidx/camera/camera2/internal/Camera2DeviceSurfaceManagerTest.java
@@ -18,10 +18,9 @@
import static com.google.common.truth.Truth.assertThat;
-import static junit.framework.Assert.assertEquals;
-import static junit.framework.Assert.assertFalse;
-import static junit.framework.Assert.assertTrue;
-
+import static org.junit.Assert.assertEquals;
+import static org.junit.Assert.assertFalse;
+import static org.junit.Assert.assertTrue;
import static org.mockito.ArgumentMatchers.anyInt;
import static org.mockito.Mockito.mock;
import static org.mockito.Mockito.when;
diff --git a/camera/camera-camera2/src/test/java/androidx/camera/camera2/internal/Camera2SessionOptionUnpackerTest.java b/camera/camera-camera2/src/test/java/androidx/camera/camera2/internal/Camera2SessionOptionUnpackerTest.java
index ca78fc8..a301832 100644
--- a/camera/camera-camera2/src/test/java/androidx/camera/camera2/internal/Camera2SessionOptionUnpackerTest.java
+++ b/camera/camera-camera2/src/test/java/androidx/camera/camera2/internal/Camera2SessionOptionUnpackerTest.java
@@ -27,7 +27,7 @@
import android.hardware.camera2.CaptureRequest;
import android.os.Build;
-import androidx.annotation.experimental.UseExperimental;
+import androidx.annotation.OptIn;
import androidx.camera.camera2.impl.Camera2ImplConfig;
import androidx.camera.camera2.impl.CameraEventCallbacks;
import androidx.camera.camera2.interop.Camera2Interop;
@@ -58,7 +58,7 @@
}
@Test
- @UseExperimental(markerClass = ExperimentalCamera2Interop.class)
+ @OptIn(markerClass = ExperimentalCamera2Interop.class)
public void unpackerExtractsInteropCallbacks() {
ImageCapture.Builder imageCaptureBuilder = new ImageCapture.Builder();
CaptureCallback captureCallback = mock(CaptureCallback.class);
@@ -97,7 +97,7 @@
}
@Test
- @UseExperimental(markerClass = ExperimentalCamera2Interop.class)
+ @OptIn(markerClass = ExperimentalCamera2Interop.class)
public void unpackerExtractsOptions() {
ImageCapture.Builder imageCaptureConfigBuilder = new ImageCapture.Builder();
diff --git a/camera/camera-camera2/src/test/java/androidx/camera/camera2/internal/CameraSelectionOptimizerTest.java b/camera/camera-camera2/src/test/java/androidx/camera/camera2/internal/CameraSelectionOptimizerTest.java
index de4b238..144207b 100644
--- a/camera/camera-camera2/src/test/java/androidx/camera/camera2/internal/CameraSelectionOptimizerTest.java
+++ b/camera/camera-camera2/src/test/java/androidx/camera/camera2/internal/CameraSelectionOptimizerTest.java
@@ -26,6 +26,7 @@
import android.hardware.camera2.CameraCharacteristics;
import android.os.Build;
import android.os.Handler;
+import android.os.Looper;
import androidx.camera.camera2.interop.Camera2CameraFilter;
import androidx.camera.camera2.interop.Camera2CameraInfo;
@@ -59,7 +60,7 @@
mCamera2CameraFactory =
spy(new Camera2CameraFactory(ApplicationProvider.getApplicationContext(),
CameraThreadConfig.create(CameraXExecutors.mainThreadExecutor(),
- new Handler()),
+ new Handler(Looper.getMainLooper())),
null));
}
diff --git a/camera/camera-camera2/src/test/java/androidx/camera/camera2/internal/ExposureControlTest.java b/camera/camera-camera2/src/test/java/androidx/camera/camera2/internal/ExposureControlTest.java
index 5e4dabd..58f8e22 100644
--- a/camera/camera-camera2/src/test/java/androidx/camera/camera2/internal/ExposureControlTest.java
+++ b/camera/camera-camera2/src/test/java/androidx/camera/camera2/internal/ExposureControlTest.java
@@ -30,7 +30,7 @@
import android.util.Range;
import android.util.Rational;
-import androidx.annotation.experimental.UseExperimental;
+import androidx.annotation.OptIn;
import androidx.camera.camera2.internal.compat.CameraCharacteristicsCompat;
import androidx.camera.core.CameraControl;
import androidx.camera.core.ExperimentalExposureCompensation;
@@ -57,7 +57,7 @@
@RunWith(RobolectricTestRunner.class)
@Config(minSdk = Build.VERSION_CODES.LOLLIPOP)
@DoNotInstrument
-@UseExperimental(markerClass = ExperimentalExposureCompensation.class)
+@OptIn(markerClass = ExperimentalExposureCompensation.class)
public class ExposureControlTest {
private static final String CAMERA0_ID = "0";
diff --git a/camera/camera-camera2/src/test/java/androidx/camera/camera2/internal/SupportedSurfaceCombinationTest.java b/camera/camera-camera2/src/test/java/androidx/camera/camera2/internal/SupportedSurfaceCombinationTest.java
index 5448c5d..fcd9b35 100644
--- a/camera/camera-camera2/src/test/java/androidx/camera/camera2/internal/SupportedSurfaceCombinationTest.java
+++ b/camera/camera-camera2/src/test/java/androidx/camera/camera2/internal/SupportedSurfaceCombinationTest.java
@@ -93,6 +93,7 @@
import java.util.concurrent.TimeoutException;
/** Robolectric test for {@link SupportedSurfaceCombination} class */
+@SuppressWarnings("deprecation")
@RunWith(RobolectricTestRunner.class)
@DoNotInstrument
@Config(minSdk = Build.VERSION_CODES.LOLLIPOP)
diff --git a/camera/camera-camera2/src/test/java/androidx/camera/camera2/internal/SynchronizedCaptureSessionBaseTest.java b/camera/camera-camera2/src/test/java/androidx/camera/camera2/internal/SynchronizedCaptureSessionBaseTest.java
index d1fe978..6776683 100644
--- a/camera/camera-camera2/src/test/java/androidx/camera/camera2/internal/SynchronizedCaptureSessionBaseTest.java
+++ b/camera/camera-camera2/src/test/java/androidx/camera/camera2/internal/SynchronizedCaptureSessionBaseTest.java
@@ -25,7 +25,6 @@
import android.hardware.camera2.CameraCaptureSession;
import android.hardware.camera2.CameraDevice;
import android.hardware.camera2.CaptureRequest;
-import android.os.AsyncTask;
import android.os.Build;
import android.os.Handler;
import android.view.Surface;
@@ -45,6 +44,7 @@
import java.util.concurrent.Executors;
import java.util.concurrent.ScheduledExecutorService;
+@SuppressWarnings({"deprecation", "unchecked"})
@RunWith(RobolectricTestRunner.class)
@DoNotInstrument
@Config(minSdk = Build.VERSION_CODES.LOLLIPOP)
@@ -66,7 +66,7 @@
mSyncCaptureSessionBaseImpl =
new SynchronizedCaptureSessionBaseImpl(mMockCaptureSessionRepository,
- AsyncTask.THREAD_POOL_EXECUTOR, mScheduledExecutorService,
+ android.os.AsyncTask.THREAD_POOL_EXECUTOR, mScheduledExecutorService,
mock(Handler.class));
mMockCaptureSession = mock(CameraCaptureSession.class);
diff --git a/camera/camera-camera2/src/test/java/androidx/camera/camera2/internal/SynchronizedCaptureSessionStateCallbackTest.java b/camera/camera-camera2/src/test/java/androidx/camera/camera2/internal/SynchronizedCaptureSessionStateCallbackTest.java
index 3bb59ff..3790c3e 100644
--- a/camera/camera-camera2/src/test/java/androidx/camera/camera2/internal/SynchronizedCaptureSessionStateCallbackTest.java
+++ b/camera/camera-camera2/src/test/java/androidx/camera/camera2/internal/SynchronizedCaptureSessionStateCallbackTest.java
@@ -21,7 +21,6 @@
import static org.mockito.Mockito.verify;
import android.hardware.camera2.CameraCaptureSession;
-import android.os.AsyncTask;
import android.os.Build;
import android.os.Handler;
import android.view.Surface;
@@ -48,13 +47,14 @@
private SynchronizedCaptureSessionBaseImpl mCaptureSessionCompatBaseImpl;
+ @SuppressWarnings("deprecation")
@Before
public void setUp() {
mMockCameraCaptureSessionStateCallback = mock(CameraCaptureSession.StateCallback.class);
mMockStateCallback = mock(SynchronizedCaptureSession.StateCallback.class);
mCaptureSessionCompatBaseImpl = new SynchronizedCaptureSessionBaseImpl(
- mock(CaptureSessionRepository.class), AsyncTask.THREAD_POOL_EXECUTOR,
+ mock(CaptureSessionRepository.class), android.os.AsyncTask.THREAD_POOL_EXECUTOR,
mScheduledExecutorService, mock(Handler.class));
mCaptureSessionCompatBaseImpl.createCaptureSessionCompat(mock(CameraCaptureSession.class));
diff --git a/camera/camera-camera2/src/test/java/androidx/camera/camera2/internal/SynchronizedCaptureSessionTest.java b/camera/camera-camera2/src/test/java/androidx/camera/camera2/internal/SynchronizedCaptureSessionTest.java
index 20d5d81..64635f2 100644
--- a/camera/camera-camera2/src/test/java/androidx/camera/camera2/internal/SynchronizedCaptureSessionTest.java
+++ b/camera/camera-camera2/src/test/java/androidx/camera/camera2/internal/SynchronizedCaptureSessionTest.java
@@ -23,7 +23,6 @@
import android.hardware.camera2.CameraCaptureSession;
import android.hardware.camera2.CameraDevice;
-import android.os.AsyncTask;
import android.os.Build;
import android.os.Handler;
@@ -64,10 +63,11 @@
private DeferrableSurface mDeferrableSurface1;
private DeferrableSurface mDeferrableSurface2;
+ @SuppressWarnings("deprecation")
@Before
public void setUp() {
mCaptureSessionRepository =
- new CaptureSessionRepository(AsyncTask.THREAD_POOL_EXECUTOR);
+ new CaptureSessionRepository(android.os.AsyncTask.THREAD_POOL_EXECUTOR);
mDeferrableSurface1 = mock(DeferrableSurface.class);
mDeferrableSurface2 = mock(DeferrableSurface.class);
@@ -81,8 +81,8 @@
enabledFeature.add(SynchronizedCaptureSessionOpener.FEATURE_DEFERRABLE_SURFACE_CLOSE);
mCaptureSessionOpenerBuilder = new SynchronizedCaptureSessionOpener.Builder(
- AsyncTask.SERIAL_EXECUTOR, mScheduledExecutorService, mock(Handler.class),
- mCaptureSessionRepository, -1);
+ android.os.AsyncTask.SERIAL_EXECUTOR, mScheduledExecutorService,
+ mock(Handler.class), mCaptureSessionRepository, -1);
mSynchronizedCaptureSessionOpener = mCaptureSessionOpenerBuilder.build();
mMockCaptureSession = mock(CameraCaptureSession.class);
diff --git a/camera/camera-camera2/src/test/java/androidx/camera/camera2/internal/compat/CameraDeviceCompatTest.java b/camera/camera-camera2/src/test/java/androidx/camera/camera2/internal/compat/CameraDeviceCompatTest.java
index 2f994a7..5f0b6ff 100644
--- a/camera/camera-camera2/src/test/java/androidx/camera/camera2/internal/compat/CameraDeviceCompatTest.java
+++ b/camera/camera-camera2/src/test/java/androidx/camera/camera2/internal/compat/CameraDeviceCompatTest.java
@@ -46,6 +46,7 @@
import java.util.Objects;
import java.util.concurrent.Executor;
+@SuppressWarnings("deprecation")
@RunWith(RobolectricTestRunner.class)
@DoNotInstrument
@Config(minSdk = Build.VERSION_CODES.LOLLIPOP)
diff --git a/camera/camera-camera2/src/test/java/androidx/camera/camera2/internal/compat/workaround/AeFpsRangeTest.java b/camera/camera-camera2/src/test/java/androidx/camera/camera2/internal/compat/workaround/AeFpsRangeTest.java
index 5d32584..de0fc74 100644
--- a/camera/camera-camera2/src/test/java/androidx/camera/camera2/internal/compat/workaround/AeFpsRangeTest.java
+++ b/camera/camera-camera2/src/test/java/androidx/camera/camera2/internal/compat/workaround/AeFpsRangeTest.java
@@ -44,6 +44,7 @@
private static final String ANY_CAMERA_ID = "0";
+ @SuppressWarnings("unchecked")
@Test
public void validEntryExists_correctRangeIsSelected() {
Range<Integer>[] availableFpsRanges = new Range[]{
@@ -62,6 +63,7 @@
assertThat(pick).isEqualTo(new Range<>(15, 30));
}
+ @SuppressWarnings("unchecked")
@Test
public void noValidEntry_doesNotSetFpsRange() {
Range<Integer>[] availableFpsRanges = new Range[]{
@@ -87,6 +89,7 @@
assertThat(pick).isNull();
}
+ @SuppressWarnings("unchecked")
@Test
public void limitedDevices_doesNotSetFpsRange() {
Range<Integer>[] availableFpsRanges = new Range[]{
@@ -101,6 +104,7 @@
assertThat(pick).isNull();
}
+ @SuppressWarnings("unchecked")
@Test
public void fullDevices_doesNotSetFpsRange() {
Range<Integer>[] availableFpsRanges = new Range[]{
@@ -115,6 +119,7 @@
assertThat(pick).isNull();
}
+ @SuppressWarnings("unchecked")
@Test
public void level3Devices_doesNotSetFpsRange() {
Range<Integer>[] availableFpsRanges = new Range[]{
diff --git a/camera/camera-camera2/src/test/java/androidx/camera/camera2/internal/compat/workaround/ExcludedSupportedSizesContainerTest.java b/camera/camera-camera2/src/test/java/androidx/camera/camera2/internal/compat/workaround/ExcludedSupportedSizesContainerTest.java
index 4dfd1dd..748720f 100644
--- a/camera/camera-camera2/src/test/java/androidx/camera/camera2/internal/compat/workaround/ExcludedSupportedSizesContainerTest.java
+++ b/camera/camera-camera2/src/test/java/androidx/camera/camera2/internal/compat/workaround/ExcludedSupportedSizesContainerTest.java
@@ -72,7 +72,6 @@
mConfig = config;
}
- @SuppressWarnings("ConfusingArgumentToVarargsMethod")
@Test
public void exclude() {
// Set up device properties
@@ -88,7 +87,7 @@
// Get sizes to exclude
final List<Size> excludedSizes = excludedSupportedSizesContainer.get(mConfig.mImageFormat);
- assertThat(excludedSizes).containsExactly(mConfig.mExcludedSizes);
+ assertThat(excludedSizes).containsExactly((Object[]) mConfig.mExcludedSizes);
}
static class Config {
diff --git a/camera/camera-camera2/src/test/java/androidx/camera/camera2/interop/Camera2CameraFilterTest.java b/camera/camera-camera2/src/test/java/androidx/camera/camera2/interop/Camera2CameraFilterTest.java
index 820a234..e985477 100644
--- a/camera/camera-camera2/src/test/java/androidx/camera/camera2/interop/Camera2CameraFilterTest.java
+++ b/camera/camera-camera2/src/test/java/androidx/camera/camera2/interop/Camera2CameraFilterTest.java
@@ -24,7 +24,7 @@
import android.hardware.camera2.CameraCharacteristics;
import android.os.Build;
-import androidx.annotation.experimental.UseExperimental;
+import androidx.annotation.OptIn;
import androidx.camera.camera2.internal.Camera2CameraInfoImpl;
import androidx.camera.camera2.internal.compat.CameraCharacteristicsCompat;
import androidx.camera.core.CameraFilter;
@@ -46,7 +46,7 @@
@RunWith(RobolectricTestRunner.class)
@DoNotInstrument
@Config(minSdk = Build.VERSION_CODES.LOLLIPOP)
-@UseExperimental(markerClass = ExperimentalCamera2Interop.class)
+@OptIn(markerClass = ExperimentalCamera2Interop.class)
public final class Camera2CameraFilterTest {
private static final String BACK_ID = "0";
private static final String FRONT_ID = "1";
diff --git a/camera/camera-camera2/src/test/java/androidx/camera/camera2/interop/Camera2CameraInfoTest.java b/camera/camera-camera2/src/test/java/androidx/camera/camera2/interop/Camera2CameraInfoTest.java
index 9e3f9b4..d6883c0 100644
--- a/camera/camera-camera2/src/test/java/androidx/camera/camera2/interop/Camera2CameraInfoTest.java
+++ b/camera/camera-camera2/src/test/java/androidx/camera/camera2/interop/Camera2CameraInfoTest.java
@@ -24,7 +24,7 @@
import android.hardware.camera2.CameraCharacteristics;
import android.os.Build;
-import androidx.annotation.experimental.UseExperimental;
+import androidx.annotation.OptIn;
import androidx.camera.camera2.internal.Camera2CameraInfoImpl;
import androidx.camera.camera2.internal.compat.CameraCharacteristicsCompat;
import androidx.camera.core.impl.CameraInfoInternal;
@@ -38,7 +38,7 @@
@RunWith(RobolectricTestRunner.class)
@DoNotInstrument
@Config(minSdk = Build.VERSION_CODES.LOLLIPOP)
-@UseExperimental(markerClass = ExperimentalCamera2Interop.class)
+@OptIn(markerClass = ExperimentalCamera2Interop.class)
public final class Camera2CameraInfoTest {
@Test
diff --git a/camera/camera-camera2/src/test/java/androidx/camera/camera2/interop/Camera2InteropTest.java b/camera/camera-camera2/src/test/java/androidx/camera/camera2/interop/Camera2InteropTest.java
index 2594ad5..6fa48ed 100644
--- a/camera/camera-camera2/src/test/java/androidx/camera/camera2/interop/Camera2InteropTest.java
+++ b/camera/camera-camera2/src/test/java/androidx/camera/camera2/interop/Camera2InteropTest.java
@@ -25,7 +25,7 @@
import android.os.Build;
import android.util.Range;
-import androidx.annotation.experimental.UseExperimental;
+import androidx.annotation.OptIn;
import androidx.camera.camera2.impl.Camera2ImplConfig;
import androidx.camera.camera2.internal.Camera2CaptureCallbacks;
import androidx.camera.camera2.internal.CameraCaptureSessionStateCallbacks;
@@ -41,7 +41,7 @@
@RunWith(RobolectricTestRunner.class)
@DoNotInstrument
@org.robolectric.annotation.Config(minSdk = Build.VERSION_CODES.LOLLIPOP)
-@UseExperimental(markerClass = ExperimentalCamera2Interop.class)
+@OptIn(markerClass = ExperimentalCamera2Interop.class)
public final class Camera2InteropTest {
private static final int INVALID_TEMPLATE_TYPE = -1;
private static final int INVALID_COLOR_CORRECTION_MODE = -1;
diff --git a/camera/camera-core/src/androidTest/java/androidx/camera/core/CameraXTest.java b/camera/camera-core/src/androidTest/java/androidx/camera/core/CameraXTest.java
index 8157db1..5c061ff 100644
--- a/camera/camera-core/src/androidTest/java/androidx/camera/core/CameraXTest.java
+++ b/camera/camera-core/src/androidTest/java/androidx/camera/core/CameraXTest.java
@@ -186,6 +186,7 @@
assertThat(cameraX1.getCameraFactory()).isEqualTo(cameraFactory1);
}
+ @SuppressWarnings("deprecation")
@Test
public void canGetCameraXContext() {
initCameraX();
diff --git a/camera/camera-core/src/androidTest/java/androidx/camera/core/ImageCaptureTest.java b/camera/camera-core/src/androidTest/java/androidx/camera/core/ImageCaptureTest.java
index 8263ce2..8f3b4b0 100644
--- a/camera/camera-core/src/androidTest/java/androidx/camera/core/ImageCaptureTest.java
+++ b/camera/camera-core/src/androidTest/java/androidx/camera/core/ImageCaptureTest.java
@@ -192,6 +192,7 @@
}
// TODO(b/149336664): add a test to verify jpeg quality is 100 when CaptureMode is MAX_QUALITY.
+ @SuppressWarnings("unchecked")
@Test
public void captureWithMinLatency_jpegQualityIs95() throws InterruptedException {
// Arrange.
diff --git a/camera/camera-core/src/androidTest/java/androidx/camera/core/ImageSaverTest.java b/camera/camera-core/src/androidTest/java/androidx/camera/core/ImageSaverTest.java
index 7c49137..b00fd48 100644
--- a/camera/camera-core/src/androidTest/java/androidx/camera/core/ImageSaverTest.java
+++ b/camera/camera-core/src/androidTest/java/androidx/camera/core/ImageSaverTest.java
@@ -193,6 +193,7 @@
mBackgroundExecutor.shutdown();
}
+ @SuppressWarnings("deprecation")
private void createDefaultPictureFolderIfNotExist() {
File pictureFolder = Environment.getExternalStoragePublicDirectory(
Environment.DIRECTORY_PICTURES);
@@ -268,6 +269,7 @@
mContentResolver.delete(saveLocationUri, null, null);
}
+ @SuppressWarnings("deprecation")
@Test
public void saveToUriWithEmptyCollection_onErrorCalled() throws InterruptedException {
// Arrange.
diff --git a/camera/camera-core/src/androidTest/java/androidx/camera/core/impl/CaptureConfigTest.java b/camera/camera-core/src/androidTest/java/androidx/camera/core/impl/CaptureConfigTest.java
index 0e55cdb..4c6bea7 100644
--- a/camera/camera-core/src/androidTest/java/androidx/camera/core/impl/CaptureConfigTest.java
+++ b/camera/camera-core/src/androidTest/java/androidx/camera/core/impl/CaptureConfigTest.java
@@ -250,7 +250,7 @@
static class FakeMultiValueSet extends MultiValueSet<Object> {
@NonNull
@Override
- public MultiValueSet clone() {
+ public MultiValueSet<Object> clone() {
FakeMultiValueSet multiValueSet = new FakeMultiValueSet();
multiValueSet.addAll(getAllItems());
return multiValueSet;
diff --git a/camera/camera-core/src/androidTest/java/androidx/camera/core/impl/DeferrableSurfacesTest.java b/camera/camera-core/src/androidTest/java/androidx/camera/core/impl/DeferrableSurfacesTest.java
index 389990c..2f1684c 100644
--- a/camera/camera-core/src/androidTest/java/androidx/camera/core/impl/DeferrableSurfacesTest.java
+++ b/camera/camera-core/src/androidTest/java/androidx/camera/core/impl/DeferrableSurfacesTest.java
@@ -76,7 +76,7 @@
@Test
@MediumTest
- @SuppressWarnings("deprecation") /* AsyncTask */
+ @SuppressWarnings({"deprecation", "unchecked"}) /* AsyncTask */
public void getSurfaceTimeoutTest() {
DeferrableSurface fakeDeferrableSurface = getFakeDeferrableSurface();
diff --git a/camera/camera-core/src/androidTest/java/androidx/camera/core/impl/ImmediateSurfaceTest.java b/camera/camera-core/src/androidTest/java/androidx/camera/core/impl/ImmediateSurfaceTest.java
index def62a21..dae33b0 100644
--- a/camera/camera-core/src/androidTest/java/androidx/camera/core/impl/ImmediateSurfaceTest.java
+++ b/camera/camera-core/src/androidTest/java/androidx/camera/core/impl/ImmediateSurfaceTest.java
@@ -63,6 +63,7 @@
assertThat(surfaceListenableFuture.get()).isSameInstanceAs(mMockSurface);
}
+ @SuppressWarnings("unchecked")
@Test
public void surfaceClosedExceptionWhenClosed() {
mImmediateSurface.close();
diff --git a/camera/camera-core/src/test/java/androidx/camera/core/ProcessingImageReaderTest.java b/camera/camera-core/src/test/java/androidx/camera/core/ProcessingImageReaderTest.java
index 8917150..d1dd263 100644
--- a/camera/camera-core/src/test/java/androidx/camera/core/ProcessingImageReaderTest.java
+++ b/camera/camera-core/src/test/java/androidx/camera/core/ProcessingImageReaderTest.java
@@ -26,7 +26,6 @@
import static org.robolectric.Shadows.shadowOf;
import android.graphics.ImageFormat;
-import android.os.AsyncTask;
import android.os.Build;
import android.util.Pair;
import android.util.Size;
@@ -63,7 +62,8 @@
import java.util.concurrent.TimeUnit;
import java.util.concurrent.TimeoutException;
-@SuppressWarnings("UnstableApiUsage") // Needed because PausedExecutorService is marked @Beta
+// UnstableApiUsage is needed because PausedExecutorService is marked @Beta
+@SuppressWarnings({"UnstableApiUsage", "deprecation"})
@RunWith(RobolectricTestRunner.class)
@DoNotInstrument
@Config(minSdk = Build.VERSION_CODES.LOLLIPOP)
@@ -194,7 +194,7 @@
// Sets the callback from ProcessingImageReader to start processing
WaitingCaptureProcessor waitingCaptureProcessor = new WaitingCaptureProcessor();
ProcessingImageReader processingImageReader = new ProcessingImageReader(
- mMetadataImageReader, AsyncTask.THREAD_POOL_EXECUTOR, mCaptureBundle,
+ mMetadataImageReader, android.os.AsyncTask.THREAD_POOL_EXECUTOR, mCaptureBundle,
waitingCaptureProcessor);
processingImageReader.setOnImageAvailableListener(mock(
ImageReaderProxy.OnImageAvailableListener.class),
@@ -263,7 +263,7 @@
MetadataImageReader metadataImageReader = new MetadataImageReader(imageReaderProxy);
// Expects to throw exception when creating ProcessingImageReader.
- new ProcessingImageReader(metadataImageReader, AsyncTask.THREAD_POOL_EXECUTOR,
+ new ProcessingImageReader(metadataImageReader, android.os.AsyncTask.THREAD_POOL_EXECUTOR,
mCaptureBundle,
NOOP_PROCESSOR);
}
@@ -272,8 +272,8 @@
public void captureStageExceedMaxCaptureStage_setCaptureBundleThrowsException() {
// Creates a ProcessingImageReader with maximum Image number.
ProcessingImageReader processingImageReader = new ProcessingImageReader(100, 100,
- ImageFormat.YUV_420_888, 2, AsyncTask.THREAD_POOL_EXECUTOR, mCaptureBundle,
- mock(CaptureProcessor.class));
+ ImageFormat.YUV_420_888, 2, android.os.AsyncTask.THREAD_POOL_EXECUTOR,
+ mCaptureBundle, mock(CaptureProcessor.class));
// Expects to throw exception when invoke the setCaptureBundle method with a
// CaptureBundle size greater than maximum image number.
@@ -285,8 +285,8 @@
public void imageReaderFormatIsOutputFormat() {
// Creates a ProcessingImageReader with input format YUV_420_888 and output JPEG
ProcessingImageReader processingImageReader = new ProcessingImageReader(100, 100,
- ImageFormat.YUV_420_888, 2, AsyncTask.THREAD_POOL_EXECUTOR, mCaptureBundle,
- mock(CaptureProcessor.class), ImageFormat.JPEG);
+ ImageFormat.YUV_420_888, 2, android.os.AsyncTask.THREAD_POOL_EXECUTOR,
+ mCaptureBundle, mock(CaptureProcessor.class), ImageFormat.JPEG);
assertThat(processingImageReader.getImageFormat()).isEqualTo(ImageFormat.JPEG);
}
diff --git a/camera/camera-core/src/test/java/androidx/camera/core/impl/DeferrableSurfaceTest.java b/camera/camera-core/src/test/java/androidx/camera/core/impl/DeferrableSurfaceTest.java
index d7839cc..30ff85a 100644
--- a/camera/camera-core/src/test/java/androidx/camera/core/impl/DeferrableSurfaceTest.java
+++ b/camera/camera-core/src/test/java/androidx/camera/core/impl/DeferrableSurfaceTest.java
@@ -139,6 +139,7 @@
mDeferrableSurface.decrementUseCount();
}
+ @SuppressWarnings("unchecked")
@Test
public void closedSurfaceContainsSurfaceClosedException() {
mDeferrableSurface.close();
diff --git a/camera/camera-extensions/src/androidTest/java/androidx/camera/extensions/PreviewExtenderTest.java b/camera/camera-extensions/src/androidTest/java/androidx/camera/extensions/PreviewExtenderTest.java
index 062dd05..f848d32 100644
--- a/camera/camera-extensions/src/androidTest/java/androidx/camera/extensions/PreviewExtenderTest.java
+++ b/camera/camera-extensions/src/androidTest/java/androidx/camera/extensions/PreviewExtenderTest.java
@@ -198,6 +198,7 @@
verifyNoMoreInteractions(mockPreviewExtenderImpl);
}
+ @SuppressWarnings("unchecked")
@Test
@MediumTest
public void getCaptureStagesTest_shouldSetToRepeatingRequest() {
diff --git a/camera/camera-view/src/androidTest/java/androidx/camera/view/PreviewViewTest.java b/camera/camera-view/src/androidTest/java/androidx/camera/view/PreviewViewTest.java
index 4c81f04..41a8c1c 100644
--- a/camera/camera-view/src/androidTest/java/androidx/camera/view/PreviewViewTest.java
+++ b/camera/camera-view/src/androidTest/java/androidx/camera/view/PreviewViewTest.java
@@ -38,6 +38,7 @@
import android.graphics.drawable.ColorDrawable;
import android.os.Build;
import android.util.Size;
+import android.view.Display;
import android.view.LayoutInflater;
import android.view.Surface;
import android.view.SurfaceView;
@@ -54,6 +55,7 @@
import androidx.camera.core.MeteringPointFactory;
import androidx.camera.core.Preview;
import androidx.camera.core.SurfaceRequest;
+import androidx.camera.core.ViewPort;
import androidx.camera.core.impl.utils.executor.CameraXExecutors;
import androidx.camera.core.impl.utils.futures.FutureCallback;
import androidx.camera.core.impl.utils.futures.Futures;
@@ -129,6 +131,48 @@
}
@Test
+ public void previewViewSetScaleType_controllerRebinds() throws InterruptedException {
+ // Arrange.
+ CountDownLatch countDownLatch = new CountDownLatch(1);
+ Semaphore fitTypeSemaphore = new Semaphore(0);
+ CameraController fakeController = new CameraController(mContext) {
+
+ @Override
+ void attachPreviewSurface(@NonNull Preview.SurfaceProvider surfaceProvider,
+ @NonNull ViewPort viewPort, @NonNull Display display) {
+ if (viewPort.getScaleType() == ViewPort.FIT) {
+ fitTypeSemaphore.release();
+ }
+ }
+
+ @Nullable
+ @Override
+ Camera startCamera() {
+ return null;
+ }
+ };
+ AtomicReference<PreviewView> previewViewAtomicReference = new AtomicReference<>();
+ mInstrumentation.runOnMainSync(() -> {
+ PreviewView previewView = new PreviewView(mContext);
+ previewViewAtomicReference.set(previewView);
+ previewView.setImplementationMode(COMPATIBLE);
+ notifyLatchWhenLayoutReady(previewView, countDownLatch);
+ setContentView(previewView);
+ });
+ // Wait for layout ready
+ assertThat(countDownLatch.await(1, TimeUnit.SECONDS)).isTrue();
+
+ // Act: set controller then change the scale type.
+ mInstrumentation.runOnMainSync(() -> {
+ previewViewAtomicReference.get().setController(fakeController);
+ previewViewAtomicReference.get().setScaleType(PreviewView.ScaleType.FIT_CENTER);
+ });
+
+ // Assert: cameraController receives a fit type ViewPort.
+ assertThat(fitTypeSemaphore.tryAcquire(1, TimeUnit.SECONDS)).isTrue();
+ }
+
+ @Test
public void previewViewPinched_pinchToZoomInvokedOnController()
throws InterruptedException, UiObjectNotFoundException {
// TODO(b/169058735): investigate and enable on Cuttlefish.
diff --git a/camera/camera-view/src/main/java/androidx/camera/view/PreviewView.java b/camera/camera-view/src/main/java/androidx/camera/view/PreviewView.java
index 87fe126..90ed0e6 100644
--- a/camera/camera-view/src/main/java/androidx/camera/view/PreviewView.java
+++ b/camera/camera-view/src/main/java/androidx/camera/view/PreviewView.java
@@ -365,8 +365,13 @@
/**
* Applies a {@link ScaleType} to the preview.
*
- * <p> Once applied, the transformation will take immediate effect. This value can also be set
- * in the layout XML file via the {@code app:scaleType} attribute.
+ * <p> If a {@link CameraController} is attached to {@link PreviewView}, the change will take
+ * immediate effect. It also takes immediate effect if {@link #getViewPort()} is not set in
+ * the bound {@link UseCaseGroup}. Otherwise, the {@link UseCase}s need to be bound again
+ * with the latest value of {@link #getViewPort()}.
+ *
+ * <p> This value can also be set in the layout XML file via the {@code app:scaleType}
+ * attribute.
*
* <p> The default value is {@link ScaleType#FILL_CENTER}.
*
@@ -378,6 +383,8 @@
Threads.checkMainThread();
mPreviewTransform.setScaleType(scaleType);
redrawPreview();
+ // Notify controller to re-calculate the crop rect.
+ attachToControllerIfReady(false);
}
/**
@@ -807,7 +814,7 @@
mCameraController.clearPreviewSurface();
}
mCameraController = cameraController;
- attachToControllerIfReady(false);
+ attachToControllerIfReady(/*shouldFailSilently=*/false);
}
/**
diff --git a/car/app/app/proguard-rules.pro b/car/app/app/proguard-rules.pro
index 738e0db..fd43f97d 100644
--- a/car/app/app/proguard-rules.pro
+++ b/car/app/app/proguard-rules.pro
@@ -5,13 +5,5 @@
# For more details, see
# http://developer.android.com/guide/developing/tools/proguard.html
--keep class androidx.car.app.serialization.Bundleable
--keepclassmembers class * extends androidx.car.app.CarAppService
--keepclassmembers class androidx.car.app.FailureResponse
--keepclassmembers class androidx.car.app.SurfaceContainer
--keepclassmembers class androidx.car.app.CarContext {
- androidx.car.app.HostDispatcher mHostDispatcher;
-}
--keepclassmembers class * extends androidx.car.app.Screen {
- androidx.car.app.CarContext mCarContext;
-}
+# Keep all IInterfaces which are needed for host communications.
+-keep class androidx.car.app.** extends android.os.IInterface { *; }
diff --git a/car/app/app/src/main/java/androidx/car/app/AppInfo.java b/car/app/app/src/main/java/androidx/car/app/AppInfo.java
index 21ddd66..d034601 100644
--- a/car/app/app/src/main/java/androidx/car/app/AppInfo.java
+++ b/car/app/app/src/main/java/androidx/car/app/AppInfo.java
@@ -128,7 +128,8 @@
+ "Assuming min API level = " + CarAppApiLevels.getLatest());
return CarAppApiLevels.getLatest();
}
- return applicationInfo.metaData.getInt(MIN_API_LEVEL_MANIFEST_KEY);
+ return applicationInfo.metaData.getInt(MIN_API_LEVEL_MANIFEST_KEY,
+ CarAppApiLevels.getLatest());
} catch (PackageManager.NameNotFoundException e) {
Log.e(TAG, "Unable to read min API level from manifest. Assuming "
+ CarAppApiLevels.getLatest(), e);
diff --git a/car/app/app/src/main/java/androidx/car/app/CarAppService.java b/car/app/app/src/main/java/androidx/car/app/CarAppService.java
index 2929ce7..e5962fe 100644
--- a/car/app/app/src/main/java/androidx/car/app/CarAppService.java
+++ b/car/app/app/src/main/java/androidx/car/app/CarAppService.java
@@ -35,6 +35,7 @@
import androidx.car.app.serialization.BundlerException;
import androidx.car.app.utils.RemoteUtils;
import androidx.car.app.utils.ThreadUtils;
+import androidx.car.app.versioning.CarAppApiLevels;
import androidx.lifecycle.Lifecycle;
import androidx.lifecycle.Lifecycle.Event;
import androidx.lifecycle.Lifecycle.State;
@@ -85,13 +86,16 @@
private static final String TAG = "CarAppService";
private static final String AUTO_DRIVE = "AUTO_DRIVE";
+ private AppInfo mAppInfo;
+
@Nullable
private Session mCurrentSession;
@Nullable
private HostInfo mHostInfo;
+
@Nullable
- private AppInfo mAppInfo;
+ private HandshakeInfo mHandshakeInfo;
/**
* Handles the host binding to this car app.
@@ -244,14 +248,28 @@
}
// Strictly to avoid synthetic accessor.
- @Nullable
+ @NonNull
AppInfo getAppInfo() {
+ if (mAppInfo == null) {
+ // Lazy-initialized as the package manager is not available if this is created inlined.
+ mAppInfo = AppInfo.create(this);
+ }
return mAppInfo;
}
// Strictly to avoid synthetic accessor.
- void setAppInfo(@Nullable AppInfo appInfo) {
- mAppInfo = appInfo;
+ void setHandshakeInfo(@NonNull HandshakeInfo handshakeInfo) {
+ int apiLevel = handshakeInfo.getHostCarAppApiLevel();
+ if (!CarAppApiLevels.isValid(apiLevel)) {
+ throw new IllegalArgumentException("Invalid Car App API level received: " + apiLevel);
+ }
+ mHandshakeInfo = handshakeInfo;
+ }
+
+ // Strictly to avoid synthetic accessor.
+ @Nullable
+ HandshakeInfo getHandshakeInfo() {
+ return mHandshakeInfo;
}
private final ICarApp.Stub mBinder =
@@ -270,25 +288,25 @@
IOnDoneCallback callback) {
Log.d(TAG, "onAppCreate intent: " + intent);
RemoteUtils.dispatchHostCall(() -> {
- if (getCurrentSession() == null
- || getCurrentSession().getLifecycle().getCurrentState()
- == State.DESTROYED) {
- setCurrentSession(onCreateSession());
- setAppInfo(AppInfo.create(getCurrentSession().getCarContext()));
+ Session session = getCurrentSession();
+ if (session == null
+ || session.getLifecycle().getCurrentState() == State.DESTROYED) {
+ session = onCreateSession();
+ session.getCarContext().updateHandshakeInfo(getHandshakeInfo());
+ setCurrentSession(session);
}
// CarContext is not set up until the base Context is attached. First
// thing we need to do here is attach the base Context, so that any usage of
// it works after this point.
- CarContext carContext = getCurrentSession().getCarContext();
+ CarContext carContext = session.getCarContext();
carContext.attachBaseContext(CarAppService.this, configuration);
carContext.setCarHost(carHost);
// Whenever the host unbinds, the screens in the stack are destroyed. If
// there is another bind, before the OS has destroyed this Service, then
// the stack will be empty, and we need to treat it as a new instance.
- LifecycleRegistry registry =
- (LifecycleRegistry) getCurrentSession().getLifecycle();
+ LifecycleRegistry registry = (LifecycleRegistry) session.getLifecycle();
Lifecycle.State state = registry.getCurrentState();
int screenStackSize = carContext.getCarService(
ScreenManager.class).getScreenStack().size();
@@ -299,7 +317,7 @@
+ ", stack size: " + screenStackSize);
registry.handleLifecycleEvent(Event.ON_CREATE);
carContext.getCarService(ScreenManager.class).push(
- getCurrentSession().onCreateScreen(intent));
+ session.onCreateScreen(intent));
} else {
Log.d(TAG, "onAppCreate the app was already created");
onNewIntentInternal(intent);
@@ -406,8 +424,7 @@
String packageName = deserializedHandshakeInfo.getHostPackageName();
int uid = Binder.getCallingUid();
setHostInfo(new HostInfo(packageName, uid));
- getCurrentSession().getCarContext().onHandshakeComplete(
- deserializedHandshakeInfo);
+ setHandshakeInfo(deserializedHandshakeInfo);
RemoteUtils.sendSuccessResponse(callback, "onHandshakeCompleted", null);
} catch (BundlerException | IllegalArgumentException e) {
setHostInfo(null);
diff --git a/car/app/app/src/main/java/androidx/car/app/CarContext.java b/car/app/app/src/main/java/androidx/car/app/CarContext.java
index 41e3241..6839cbb 100644
--- a/car/app/app/src/main/java/androidx/car/app/CarContext.java
+++ b/car/app/app/src/main/java/androidx/car/app/CarContext.java
@@ -386,13 +386,8 @@
*/
@RestrictTo(LIBRARY)
@MainThread
- void onHandshakeComplete(HandshakeInfo handshakeInfo) {
- int carAppApiLevel = handshakeInfo.getHostCarAppApiLevel();
- if (!CarAppApiLevels.isValid(carAppApiLevel)) {
- throw new IllegalArgumentException("Invalid Car App API level received: "
- + carAppApiLevel);
- }
- mCarAppApiLevel = carAppApiLevel;
+ void updateHandshakeInfo(HandshakeInfo handshakeInfo) {
+ mCarAppApiLevel = handshakeInfo.getHostCarAppApiLevel();
}
/**
diff --git a/car/app/app/src/test/java/androidx/car/app/AppInfoTest.java b/car/app/app/src/test/java/androidx/car/app/AppInfoTest.java
index 84c7d9f..158e1fc 100644
--- a/car/app/app/src/test/java/androidx/car/app/AppInfoTest.java
+++ b/car/app/app/src/test/java/androidx/car/app/AppInfoTest.java
@@ -56,12 +56,19 @@
}
@Test
- public void create_minApiLevel_defaultsToCurrent() {
+ public void create_minApiLevel_nullMetadata_defaultsToCurrent() {
mApplicationInfo.metaData = null;
AppInfo appInfo = AppInfo.create(mContext);
assertThat(appInfo.getMinCarAppApiLevel()).isEqualTo(CarAppApiLevels.getLatest());
}
+ @Test
+ public void create_minApiLevel_noMetadataKey_defaultsToCurrent() {
+ mApplicationInfo.metaData = new Bundle();
+ AppInfo appInfo = AppInfo.create(mContext);
+ assertThat(appInfo.getMinCarAppApiLevel()).isEqualTo(CarAppApiLevels.getLatest());
+ }
+
@Test(expected = IllegalArgumentException.class)
public void create_minApiLevel_cannotBeLowerThanOldest() {
int minApiLevel = CarAppApiLevels.getOldest() - 1;
diff --git a/car/app/app/src/test/java/androidx/car/app/CarAppServiceTest.java b/car/app/app/src/test/java/androidx/car/app/CarAppServiceTest.java
index 918de32..b9dd5e5 100644
--- a/car/app/app/src/test/java/androidx/car/app/CarAppServiceTest.java
+++ b/car/app/app/src/test/java/androidx/car/app/CarAppServiceTest.java
@@ -119,6 +119,22 @@
}
@Test
+ public void onAppCreate_updatesCarApiLevel() throws RemoteException, BundlerException {
+ String hostPackageName = "com.google.projection.gearhead";
+ ICarApp carApp = (ICarApp) mCarAppService.onBind(null);
+ int hostApiLevel = CarAppApiLevels.LEVEL_1;
+ HandshakeInfo handshakeInfo = new HandshakeInfo(hostPackageName, hostApiLevel);
+
+ mCarAppService.setCurrentSession(null);
+ carApp.onHandshakeCompleted(Bundleable.create(handshakeInfo), mock(IOnDoneCallback.class));
+ carApp.onAppCreate(mMockCarHost, null, new Configuration(), mock(IOnDoneCallback.class));
+
+ assertThat(
+ mCarAppService.getCurrentSession().getCarContext().getCarAppApiLevel()).isEqualTo(
+ hostApiLevel);
+ }
+
+ @Test
public void onAppCreate_createsFirstScreen() throws RemoteException {
ICarApp carApp = (ICarApp) mCarAppService.onBind(null);
carApp.onAppCreate(mMockCarHost, null, new Configuration(), mock(IOnDoneCallback.class));
@@ -242,17 +258,19 @@
}
@Test
- public void onHandshakeCompleted_updatesCarApiLevel() throws RemoteException, BundlerException {
+ public void onHandshakeCompleted_updatesHandshakeInfo() throws RemoteException,
+ BundlerException {
String hostPackageName = "com.google.projection.gearhead";
ICarApp carApp = (ICarApp) mCarAppService.onBind(null);
- int hostApiLevel = CarAppApiLevels.LEVEL_1;
- HandshakeInfo handshakeInfo = new HandshakeInfo(hostPackageName, hostApiLevel);
+ assertThat(mCarAppService.getHandshakeInfo()).isNull();
+ HandshakeInfo handshakeInfo = new HandshakeInfo(hostPackageName, CarAppApiLevels.LEVEL_1);
carApp.onHandshakeCompleted(Bundleable.create(handshakeInfo), mock(IOnDoneCallback.class));
-
- assertThat(
- mCarAppService.getCurrentSession().getCarContext().getCarAppApiLevel()).isEqualTo(
- hostApiLevel);
+ assertThat(mCarAppService.getHandshakeInfo()).isNotNull();
+ assertThat(mCarAppService.getHandshakeInfo().getHostCarAppApiLevel()).isEqualTo(
+ handshakeInfo.getHostCarAppApiLevel());
+ assertThat(mCarAppService.getHandshakeInfo().getHostPackageName()).isEqualTo(
+ handshakeInfo.getHostPackageName());
}
@Test
@@ -299,8 +317,9 @@
}
@Test
- public void onUnbind_rebind_callsOnCreateScreen() throws RemoteException {
+ public void onUnbind_rebind_callsOnCreateScreen() throws RemoteException, BundlerException {
ICarApp carApp = (ICarApp) mCarAppService.onBind(null);
+
carApp.onAppCreate(mMockCarHost, null, new Configuration(), mock(IOnDoneCallback.class));
carApp.onAppStart(mock(IOnDoneCallback.class));
@@ -313,6 +332,10 @@
assertThat(currentSession.getCarContext().getCarService(
ScreenManager.class).getScreenStack()).isEmpty();
+ String hostPackageName = "com.google.projection.gearhead";
+ int hostApiLevel = CarAppApiLevels.LEVEL_1;
+ HandshakeInfo handshakeInfo = new HandshakeInfo(hostPackageName, hostApiLevel);
+ carApp.onHandshakeCompleted(Bundleable.create(handshakeInfo), mock(IOnDoneCallback.class));
carApp.onAppCreate(mMockCarHost, null, new Configuration(), mock(IOnDoneCallback.class));
assertThat(currentSession.getCarContext().getCarService(
ScreenManager.class).getScreenStack()).hasSize(1);
diff --git a/compose/runtime/runtime/src/commonMain/kotlin/androidx/compose/runtime/Recomposer.kt b/compose/runtime/runtime/src/commonMain/kotlin/androidx/compose/runtime/Recomposer.kt
index c91281c..8802e15 100644
--- a/compose/runtime/runtime/src/commonMain/kotlin/androidx/compose/runtime/Recomposer.kt
+++ b/compose/runtime/runtime/src/commonMain/kotlin/androidx/compose/runtime/Recomposer.kt
@@ -53,14 +53,11 @@
suspend fun <R> withRunningRecomposer(
block: suspend CoroutineScope.(recomposer: Recomposer) -> R
): R = coroutineScope {
- val recomposerJob = Job(coroutineContext[Job])
- val recomposer = Recomposer(coroutineContext + recomposerJob)
+ val recomposer = Recomposer(coroutineContext)
// Will be cancelled when recomposerJob cancels
launch { recomposer.runRecomposeAndApplyChanges() }
- try {
- block(recomposer)
- } finally {
- recomposerJob.cancel()
+ block(recomposer).also {
+ recomposer.shutDown()
}
}
diff --git a/concurrent/futures/src/main/java/androidx/concurrent/futures/CallbackToFutureAdapter.java b/concurrent/futures/src/main/java/androidx/concurrent/futures/CallbackToFutureAdapter.java
index 1590b89..67ed8ae 100644
--- a/concurrent/futures/src/main/java/androidx/concurrent/futures/CallbackToFutureAdapter.java
+++ b/concurrent/futures/src/main/java/androidx/concurrent/futures/CallbackToFutureAdapter.java
@@ -327,6 +327,7 @@
// toString intentionally left omitted, so that if the tag object (which holds this object
// as a field) includes it in its toString, we won't infinitely recurse.
+ @SuppressWarnings("deprecation")
@Override
protected void finalize() {
SafeFuture<T> localFuture = future;
diff --git a/concurrent/futures/src/test/java/androidx/concurrent/futures/AbstractResolvableFutureTest.java b/concurrent/futures/src/test/java/androidx/concurrent/futures/AbstractResolvableFutureTest.java
index d24822bf..0f36ad0 100644
--- a/concurrent/futures/src/test/java/androidx/concurrent/futures/AbstractResolvableFutureTest.java
+++ b/concurrent/futures/src/test/java/androidx/concurrent/futures/AbstractResolvableFutureTest.java
@@ -25,8 +25,14 @@
import com.google.common.collect.Range;
import com.google.common.collect.Sets;
import com.google.common.util.concurrent.Atomics;
-import com.google.common.util.concurrent.Uninterruptibles;
import com.google.common.util.concurrent.ListenableFuture;
+import com.google.common.util.concurrent.Uninterruptibles;
+
+import junit.framework.AssertionFailedError;
+import junit.framework.TestCase;
+
+import org.junit.internal.runners.JUnit38ClassRunner;
+import org.junit.runner.RunWith;
import java.util.ArrayList;
import java.util.Collections;
@@ -48,12 +54,6 @@
import java.util.concurrent.atomic.AtomicReference;
import java.util.concurrent.locks.LockSupport;
-import junit.framework.AssertionFailedError;
-import junit.framework.TestCase;
-
-import org.junit.internal.runners.JUnit38ClassRunner;
-import org.junit.runner.RunWith;
-
/**
* Tests for {@link AbstractResolvableFuture}.
*
@@ -232,7 +232,7 @@
* ranges
* derived from observing how much time actually passed for various operations.
*/
- @SuppressWarnings({"DeprecatedThreadMethods", "ThreadPriorityCheck"})
+ @SuppressWarnings({"DeprecatedThreadMethods", "ThreadPriorityCheck", "deprecation"})
public void testToString_delayedTimeout() throws Exception {
TimedWaiterThread thread =
new TimedWaiterThread(new AbstractResolvableFuture<Object>() {
diff --git a/concurrent/futures/src/test/java/androidx/concurrent/futures/CallbackToFutureAdapterTest.java b/concurrent/futures/src/test/java/androidx/concurrent/futures/CallbackToFutureAdapterTest.java
index 5e15221..971d3ed 100644
--- a/concurrent/futures/src/test/java/androidx/concurrent/futures/CallbackToFutureAdapterTest.java
+++ b/concurrent/futures/src/test/java/androidx/concurrent/futures/CallbackToFutureAdapterTest.java
@@ -111,6 +111,7 @@
*/
private static void createUnreachableLatchFinalizer(final CountDownLatch latch) {
new Object() {
+ @SuppressWarnings("deprecation")
@Override
protected void finalize() {
latch.countDown();
diff --git a/contentpager/contentpager/src/androidTest/java/androidx/contentpager/content/ContentPagerTest.java b/contentpager/contentpager/src/androidTest/java/androidx/contentpager/content/ContentPagerTest.java
index f8a66e7..7b5f3c7 100644
--- a/contentpager/contentpager/src/androidTest/java/androidx/contentpager/content/ContentPagerTest.java
+++ b/contentpager/contentpager/src/androidTest/java/androidx/contentpager/content/ContentPagerTest.java
@@ -26,7 +26,6 @@
import static org.junit.Assert.assertNotNull;
import static org.junit.Assert.assertTrue;
-import android.app.Activity;
import android.content.ContentResolver;
import android.database.Cursor;
import android.net.Uri;
@@ -38,7 +37,6 @@
import androidx.contentpager.content.ContentPager.ContentCallback;
import androidx.test.ext.junit.runners.AndroidJUnit4;
import androidx.test.filters.SmallTest;
-import androidx.test.rule.ActivityTestRule;
import org.junit.Before;
import org.junit.Rule;
@@ -60,8 +58,10 @@
private TestContentCallback mCallback;
private ContentPager mPager;
+ @SuppressWarnings("deprecation")
@Rule
- public ActivityTestRule<Activity> mActivityRule = new ActivityTestRule(TestActivity.class);
+ public androidx.test.rule.ActivityTestRule<TestActivity> mActivityRule =
+ new androidx.test.rule.ActivityTestRule<>(TestActivity.class);
@Before
public void setUp() {
diff --git a/contentpager/contentpager/src/androidTest/java/androidx/contentpager/content/LoaderQueryRunnerTest.java b/contentpager/contentpager/src/androidTest/java/androidx/contentpager/content/LoaderQueryRunnerTest.java
index 51643a0..a6eaaa8 100644
--- a/contentpager/contentpager/src/androidTest/java/androidx/contentpager/content/LoaderQueryRunnerTest.java
+++ b/contentpager/contentpager/src/androidTest/java/androidx/contentpager/content/LoaderQueryRunnerTest.java
@@ -22,11 +22,11 @@
import android.app.Activity;
import android.database.Cursor;
+import androidx.annotation.NonNull;
import androidx.contentpager.content.ContentPager.ContentCallback;
import androidx.contentpager.content.ContentPager.QueryRunner;
import androidx.test.ext.junit.runners.AndroidJUnit4;
import androidx.test.filters.MediumTest;
-import androidx.test.rule.ActivityTestRule;
import org.junit.Before;
import org.junit.Rule;
@@ -37,8 +37,10 @@
@RunWith(AndroidJUnit4.class)
public class LoaderQueryRunnerTest {
+ @SuppressWarnings("deprecation")
@Rule
- public ActivityTestRule<Activity> mActivityRule = new ActivityTestRule(TestActivity.class);
+ public androidx.test.rule.ActivityTestRule<TestActivity> mActivityRule =
+ new androidx.test.rule.ActivityTestRule<>(TestActivity.class);
private Activity mActivity;
private QueryRunner mRunner;
@@ -58,7 +60,7 @@
ContentCallback dummyContentCallback = new ContentCallback() {
@Override
- public void onCursorReady(Query query, Cursor cursor) {
+ public void onCursorReady(@NonNull Query query, Cursor cursor) {
// Nothing to see here. Move along.
}
};
diff --git a/contentpager/contentpager/src/main/java/androidx/contentpager/content/LoaderQueryRunner.java b/contentpager/contentpager/src/main/java/androidx/contentpager/content/LoaderQueryRunner.java
index 5e054d9..7054cfe 100644
--- a/contentpager/contentpager/src/main/java/androidx/contentpager/content/LoaderQueryRunner.java
+++ b/contentpager/contentpager/src/main/java/androidx/contentpager/content/LoaderQueryRunner.java
@@ -19,7 +19,6 @@
import static androidx.core.util.Preconditions.checkArgument;
import android.app.LoaderManager;
-import android.app.LoaderManager.LoaderCallbacks;
import android.content.Context;
import android.content.Loader;
import android.database.Cursor;
@@ -48,11 +47,12 @@
}
@Override
- @SuppressWarnings("unchecked") // feels spurious. But can't commit line :80 w/o this.
+ @SuppressWarnings({"unchecked", "deprecation"})
public void query(final @NonNull Query query, @NonNull final Callback callback) {
if (DEBUG) Log.d(TAG, "Handling query: " + query);
- LoaderCallbacks callbacks = new LoaderCallbacks<Cursor>() {
+ android.app.LoaderManager.LoaderCallbacks<Cursor> callbacks =
+ new android.app.LoaderManager.LoaderCallbacks<Cursor>() {
@Override
public Loader<Cursor> onCreateLoader(final int id, final Bundle args) {
if (DEBUG) Log.i(TAG, "Loading results for query: " + query);
diff --git a/coordinatorlayout/coordinatorlayout/src/androidTest/java/androidx/coordinatorlayout/widget/CoordinatorLayoutNestedScrollingParentTest.java b/coordinatorlayout/coordinatorlayout/src/androidTest/java/androidx/coordinatorlayout/widget/CoordinatorLayoutNestedScrollingParentTest.java
index 4f55c81..c7fce80 100644
--- a/coordinatorlayout/coordinatorlayout/src/androidTest/java/androidx/coordinatorlayout/widget/CoordinatorLayoutNestedScrollingParentTest.java
+++ b/coordinatorlayout/coordinatorlayout/src/androidTest/java/androidx/coordinatorlayout/widget/CoordinatorLayoutNestedScrollingParentTest.java
@@ -248,6 +248,7 @@
assertThat(consumed, is(new int[]{24, 225}));
}
+ @SuppressWarnings("unchecked")
private static CoordinatorLayout.Behavior<View> setupMockBehavior() {
CoordinatorLayout.Behavior<View> mockBehavior = mock(CoordinatorLayout.Behavior.class);
when(mockBehavior.onStartNestedScroll(
diff --git a/coordinatorlayout/coordinatorlayout/src/androidTest/java/androidx/coordinatorlayout/widget/CoordinatorLayoutSortTest.java b/coordinatorlayout/coordinatorlayout/src/androidTest/java/androidx/coordinatorlayout/widget/CoordinatorLayoutSortTest.java
index 7cda115c..666de71 100644
--- a/coordinatorlayout/coordinatorlayout/src/androidTest/java/androidx/coordinatorlayout/widget/CoordinatorLayoutSortTest.java
+++ b/coordinatorlayout/coordinatorlayout/src/androidTest/java/androidx/coordinatorlayout/widget/CoordinatorLayoutSortTest.java
@@ -36,6 +36,7 @@
import java.util.Collection;
import java.util.List;
+@SuppressWarnings("unchecked")
@RunWith(Parameterized.class)
@SmallTest
public class CoordinatorLayoutSortTest {
diff --git a/coordinatorlayout/coordinatorlayout/src/androidTest/java/androidx/coordinatorlayout/widget/CoordinatorLayoutTest.java b/coordinatorlayout/coordinatorlayout/src/androidTest/java/androidx/coordinatorlayout/widget/CoordinatorLayoutTest.java
index 1e7336e..548f4ba 100644
--- a/coordinatorlayout/coordinatorlayout/src/androidTest/java/androidx/coordinatorlayout/widget/CoordinatorLayoutTest.java
+++ b/coordinatorlayout/coordinatorlayout/src/androidTest/java/androidx/coordinatorlayout/widget/CoordinatorLayoutTest.java
@@ -69,6 +69,7 @@
import java.util.List;
import java.util.concurrent.atomic.AtomicInteger;
+@SuppressWarnings("unchecked")
@LargeTest
@RunWith(AndroidJUnit4.class)
public class CoordinatorLayoutTest {
diff --git a/coordinatorlayout/coordinatorlayout/src/androidTest/java/androidx/coordinatorlayout/widget/DirectedAcyclicGraphTest.java b/coordinatorlayout/coordinatorlayout/src/androidTest/java/androidx/coordinatorlayout/widget/DirectedAcyclicGraphTest.java
index c7726a7..9040367 100644
--- a/coordinatorlayout/coordinatorlayout/src/androidTest/java/androidx/coordinatorlayout/widget/DirectedAcyclicGraphTest.java
+++ b/coordinatorlayout/coordinatorlayout/src/androidTest/java/androidx/coordinatorlayout/widget/DirectedAcyclicGraphTest.java
@@ -82,6 +82,7 @@
mGraph.addEdge(node, edge);
}
+ @SuppressWarnings("unchecked")
@Test
public void test_getIncomingEdges() {
final TestNode node = new TestNode("node");
diff --git a/core/core/src/androidTest/java/androidx/core/content/pm/ShortcutManagerCompatTest.java b/core/core/src/androidTest/java/androidx/core/content/pm/ShortcutManagerCompatTest.java
index dd8ee2d..157ed9c 100644
--- a/core/core/src/androidTest/java/androidx/core/content/pm/ShortcutManagerCompatTest.java
+++ b/core/core/src/androidTest/java/androidx/core/content/pm/ShortcutManagerCompatTest.java
@@ -85,6 +85,7 @@
import java.util.Arrays;
import java.util.List;
+@SuppressWarnings("unchecked")
@RunWith(AndroidJUnit4.class)
public class ShortcutManagerCompatTest extends BaseInstrumentationTestCase<TestActivity> {
diff --git a/development/build_log_simplifier/messages.ignore b/development/build_log_simplifier/messages.ignore
index 95cf42b..26d8d03 100644
--- a/development/build_log_simplifier/messages.ignore
+++ b/development/build_log_simplifier/messages.ignore
@@ -386,6 +386,8 @@
# b/166471969
.*androidTest.*AndroidManifest.*xml Warning.*:
Package name.*test' used in: .*AndroidManifest.*xml.*
+\[:internal\-testutils\-espresso\] \$OUT_DIR/androidx/internal\-testutils\-espresso/build/intermediates/merged_manifest/debug/AndroidManifest\.xml Warning:
+Package name 'androidx\.testutils' used in: :internal\-testutils\-espresso, :internal\-testutils\-runtime\.
\$OUT_DIR/androidx/compose/ui/ui\-tooling/build/intermediates/tmp/manifest/androidTest/debug/manifestMerger[0-9]+\.xml:[0-9]+:[0-9]+\-[0-9]+:[0-9]+ Warning:
\[:internal\-testutils\-runtime\] \$OUT_DIR/androidx/internal\-testutils\-runtime/build/intermediates/merged_manifest/debug/AndroidManifest\.xml Warning:
# > Task :leanback:leanback-paging:generateApi
@@ -427,6 +429,7 @@
Set 'kapt\.includeCompileClasspath = false' to disable discovery\.
Run the build with '\-\-info' for more details\.
# > Task :camera:camera-core:compileDebugUnitTestJavaWithJavac
+Note\: \$SUPPORT\/camera\/camera\-core\/src\/test\/java\/androidx\/camera\/core\/CameraSelectorTest\.java uses or overrides a deprecated API\.
Note: \$SUPPORT/camera/camera\-core/src/test/java/androidx/camera/core/ProcessingImageReaderTest\.java uses or overrides a deprecated API\.
Note: \$SUPPORT/camera/camera\-core/src/test/java/androidx/camera/core/impl/DeferrableSurfaceTest\.java uses unchecked or unsafe operations\.
# > Task :wear:wear-input:compileDebugUnitTestJavaWithJavac
@@ -664,4 +667,6 @@
w\: \$SUPPORT\/viewpager[0-9]+\/viewpager[0-9]+\/src\/androidTest\/java\/androidx\/viewpager[0-9]+\/widget\/OnApplyWindowInsetsListenerTest\.kt\: \([0-9]+\, [0-9]+\)\: \'consumeSystemWindowInsets\(\)\: WindowInsetsCompat\' is deprecated\. Deprecated in Java
w\: \$SUPPORT\/viewpager[0-9]+\/viewpager[0-9]+\/src\/androidTest\/java\/androidx\/viewpager[0-9]+\/widget\/OnApplyWindowInsetsListenerTest\.kt\: \([0-9]+\, [0-9]+\)\: Unnecessary non\-null assertion \(\!\!\) on a non\-null receiver of type WindowInsetsCompat
w\: \$SUPPORT\/viewpager[0-9]+\/viewpager[0-9]+\/src\/androidTest\/java\/androidx\/viewpager[0-9]+\/widget\/OnApplyWindowInsetsListenerTest\.kt\: \([0-9]+\, [0-9]+\)\: \'consumeStableInsets\(\)\: WindowInsetsCompat\' is deprecated\. Deprecated in Java
-w\: \$SUPPORT\/viewpager[0-9]+\/viewpager[0-9]+\/src\/androidTest\/java\/androidx\/viewpager[0-9]+\/widget\/OnApplyWindowInsetsListenerTest\.kt\: \([0-9]+\, [0-9]+\)\: \'consumeDisplayCutout\(\)\: WindowInsetsCompat\' is deprecated\. Deprecated in Java
\ No newline at end of file
+w\: \$SUPPORT\/viewpager[0-9]+\/viewpager[0-9]+\/src\/androidTest\/java\/androidx\/viewpager[0-9]+\/widget\/OnApplyWindowInsetsListenerTest\.kt\: \([0-9]+\, [0-9]+\)\: \'consumeDisplayCutout\(\)\: WindowInsetsCompat\' is deprecated\. Deprecated in Java
+# > Task :contentpager:contentpager:compileDebugAndroidTestJavaWithJavac
+Note: \$SUPPORT/contentpager/contentpager/src/androidTest/java/androidx/contentpager/content/LoaderQueryRunnerTest\.java uses or overrides a deprecated API\.
\ No newline at end of file
diff --git a/drawerlayout/drawerlayout/src/androidTest/java/androidx/drawerlayout/widget/DrawerCustomThemeTest.java b/drawerlayout/drawerlayout/src/androidTest/java/androidx/drawerlayout/widget/DrawerCustomThemeTest.java
index 6b4033d..6b3c6b5 100644
--- a/drawerlayout/drawerlayout/src/androidTest/java/androidx/drawerlayout/widget/DrawerCustomThemeTest.java
+++ b/drawerlayout/drawerlayout/src/androidTest/java/androidx/drawerlayout/widget/DrawerCustomThemeTest.java
@@ -23,7 +23,6 @@
import androidx.drawerlayout.test.R;
import androidx.test.ext.junit.runners.AndroidJUnit4;
import androidx.test.filters.SmallTest;
-import androidx.test.rule.ActivityTestRule;
import org.junit.Rule;
import org.junit.Test;
@@ -31,9 +30,10 @@
@RunWith(AndroidJUnit4.class)
public class DrawerCustomThemeTest {
+ @SuppressWarnings("deprecation")
@Rule
- public final ActivityTestRule<DrawerCustomThemeActivity> mActivityTestRule =
- new ActivityTestRule<>(DrawerCustomThemeActivity.class);
+ public final androidx.test.rule.ActivityTestRule<DrawerCustomThemeActivity> mActivityTestRule =
+ new androidx.test.rule.ActivityTestRule<>(DrawerCustomThemeActivity.class);
@Test
@SmallTest
diff --git a/drawerlayout/drawerlayout/src/androidTest/java/androidx/drawerlayout/widget/DrawerNoThemeTest.java b/drawerlayout/drawerlayout/src/androidTest/java/androidx/drawerlayout/widget/DrawerNoThemeTest.java
index b44b5e9..745f8fe 100644
--- a/drawerlayout/drawerlayout/src/androidTest/java/androidx/drawerlayout/widget/DrawerNoThemeTest.java
+++ b/drawerlayout/drawerlayout/src/androidTest/java/androidx/drawerlayout/widget/DrawerNoThemeTest.java
@@ -23,7 +23,6 @@
import androidx.drawerlayout.test.R;
import androidx.test.ext.junit.runners.AndroidJUnit4;
import androidx.test.filters.SmallTest;
-import androidx.test.rule.ActivityTestRule;
import org.junit.Rule;
import org.junit.Test;
@@ -31,9 +30,10 @@
@RunWith(AndroidJUnit4.class)
public class DrawerNoThemeTest {
+ @SuppressWarnings("deprecation")
@Rule
- public final ActivityTestRule<DrawerNoThemeActivity> mActivityTestRule =
- new ActivityTestRule<>(DrawerNoThemeActivity.class);
+ public final androidx.test.rule.ActivityTestRule<DrawerNoThemeActivity> mActivityTestRule =
+ new androidx.test.rule.ActivityTestRule<>(DrawerNoThemeActivity.class);
@Test
@SmallTest
diff --git a/dynamic-animation/dynamic-animation/src/androidTest/java/androidx/dynamicanimation/tests/FlingTests.java b/dynamic-animation/dynamic-animation/src/androidTest/java/androidx/dynamicanimation/tests/FlingTests.java
index 2ad1ee0..75f6869 100644
--- a/dynamic-animation/dynamic-animation/src/androidTest/java/androidx/dynamicanimation/tests/FlingTests.java
+++ b/dynamic-animation/dynamic-animation/src/androidTest/java/androidx/dynamicanimation/tests/FlingTests.java
@@ -34,7 +34,6 @@
import androidx.test.ext.junit.runners.AndroidJUnit4;
import androidx.test.filters.LargeTest;
import androidx.test.platform.app.InstrumentationRegistry;
-import androidx.test.rule.ActivityTestRule;
import org.junit.Before;
import org.junit.Rule;
@@ -44,19 +43,22 @@
import org.mockito.internal.matchers.GreaterThan;
import org.mockito.internal.matchers.LessThan;
+@SuppressWarnings("unchecked")
@LargeTest
@RunWith(AndroidJUnit4.class)
public class FlingTests {
+ @SuppressWarnings("deprecation")
@Rule
- public final ActivityTestRule<AnimationActivity> mActivityTestRule;
+ public final androidx.test.rule.ActivityTestRule<AnimationActivity> mActivityTestRule;
public View mView1;
public View mView2;
@Rule
public ExpectedException mExpectedException = ExpectedException.none();
+ @SuppressWarnings("deprecation")
public FlingTests() {
- mActivityTestRule = new ActivityTestRule<>(AnimationActivity.class);
+ mActivityTestRule = new androidx.test.rule.ActivityTestRule<>(AnimationActivity.class);
}
@Before
diff --git a/dynamic-animation/dynamic-animation/src/androidTest/java/androidx/dynamicanimation/tests/SpringTests.java b/dynamic-animation/dynamic-animation/src/androidTest/java/androidx/dynamicanimation/tests/SpringTests.java
index b774708..d55d3ed 100644
--- a/dynamic-animation/dynamic-animation/src/androidTest/java/androidx/dynamicanimation/tests/SpringTests.java
+++ b/dynamic-animation/dynamic-animation/src/androidTest/java/androidx/dynamicanimation/tests/SpringTests.java
@@ -47,7 +47,6 @@
import androidx.test.filters.LargeTest;
import androidx.test.filters.MediumTest;
import androidx.test.platform.app.InstrumentationRegistry;
-import androidx.test.rule.ActivityTestRule;
import org.junit.Before;
import org.junit.Rule;
@@ -55,18 +54,21 @@
import org.junit.rules.ExpectedException;
import org.junit.runner.RunWith;
+@SuppressWarnings("unchecked")
@MediumTest
@RunWith(AndroidJUnit4.class)
public class SpringTests {
- @Rule public final ActivityTestRule<AnimationActivity> mActivityTestRule;
+ @SuppressWarnings("deprecation")
+ @Rule public final androidx.test.rule.ActivityTestRule<AnimationActivity> mActivityTestRule;
public View mView1;
public View mView2;
@Rule
public ExpectedException mExpectedException = ExpectedException.none();
+ @SuppressWarnings("deprecation")
public SpringTests() {
- mActivityTestRule = new ActivityTestRule<>(AnimationActivity.class);
+ mActivityTestRule = new androidx.test.rule.ActivityTestRule<>(AnimationActivity.class);
}
@Before
diff --git a/emoji/core/src/androidTest/java/androidx/emoji/text/EmojiKeyboardTest.java b/emoji/core/src/androidTest/java/androidx/emoji/text/EmojiKeyboardTest.java
index 47142fd..0f0c808 100644
--- a/emoji/core/src/androidTest/java/androidx/emoji/text/EmojiKeyboardTest.java
+++ b/emoji/core/src/androidTest/java/androidx/emoji/text/EmojiKeyboardTest.java
@@ -36,7 +36,6 @@
import androidx.test.filters.LargeTest;
import androidx.test.filters.Suppress;
import androidx.test.platform.app.InstrumentationRegistry;
-import androidx.test.rule.ActivityTestRule;
import androidx.testutils.PollingCheck;
import org.junit.Before;
@@ -50,9 +49,10 @@
@Suppress
public class EmojiKeyboardTest {
+ @SuppressWarnings("deprecation")
@Rule
- public ActivityTestRule<TestActivity> mActivityRule = new ActivityTestRule<>(
- TestActivity.class);
+ public androidx.test.rule.ActivityTestRule<TestActivity> mActivityRule =
+ new androidx.test.rule.ActivityTestRule<>(TestActivity.class);
private Instrumentation mInstrumentation;
@BeforeClass
diff --git a/emoji/core/src/androidTest/java/androidx/emoji/text/EmojiSpanInstrumentationTest.java b/emoji/core/src/androidTest/java/androidx/emoji/text/EmojiSpanInstrumentationTest.java
index 4f4b856..15beb23 100644
--- a/emoji/core/src/androidTest/java/androidx/emoji/text/EmojiSpanInstrumentationTest.java
+++ b/emoji/core/src/androidTest/java/androidx/emoji/text/EmojiSpanInstrumentationTest.java
@@ -35,7 +35,6 @@
import androidx.test.filters.LargeTest;
import androidx.test.filters.SdkSuppress;
import androidx.test.platform.app.InstrumentationRegistry;
-import androidx.test.rule.ActivityTestRule;
import org.junit.Before;
import org.junit.BeforeClass;
@@ -48,9 +47,10 @@
@SdkSuppress(minSdkVersion = 19)
public class EmojiSpanInstrumentationTest {
+ @SuppressWarnings("deprecation")
@Rule
- public ActivityTestRule<TestActivity> mActivityRule = new ActivityTestRule<>(
- TestActivity.class);
+ public androidx.test.rule.ActivityTestRule<TestActivity> mActivityRule =
+ new androidx.test.rule.ActivityTestRule<>(TestActivity.class);
private Instrumentation mInstrumentation;
@BeforeClass
diff --git a/emoji/core/src/androidTest/java/androidx/emoji/widget/EmojiEditTextTest.java b/emoji/core/src/androidTest/java/androidx/emoji/widget/EmojiEditTextTest.java
index faa4ad1..a4d8db8 100644
--- a/emoji/core/src/androidTest/java/androidx/emoji/widget/EmojiEditTextTest.java
+++ b/emoji/core/src/androidTest/java/androidx/emoji/widget/EmojiEditTextTest.java
@@ -35,7 +35,6 @@
import androidx.test.filters.MediumTest;
import androidx.test.filters.SdkSuppress;
import androidx.test.platform.app.InstrumentationRegistry;
-import androidx.test.rule.ActivityTestRule;
import org.junit.Before;
import org.junit.BeforeClass;
@@ -47,9 +46,10 @@
@RunWith(AndroidJUnit4.class)
public class EmojiEditTextTest {
+ @SuppressWarnings("deprecation")
@Rule
- public ActivityTestRule<TestActivity> mActivityRule = new ActivityTestRule<>(
- TestActivity.class);
+ public androidx.test.rule.ActivityTestRule<TestActivity> mActivityRule =
+ new androidx.test.rule.ActivityTestRule<>(TestActivity.class);
private Instrumentation mInstrumentation;
@BeforeClass
diff --git a/emoji/core/src/androidTest/java/androidx/emoji/widget/SpannableBuilderTest.java b/emoji/core/src/androidTest/java/androidx/emoji/widget/SpannableBuilderTest.java
index 2e92a7c..25b29eb 100644
--- a/emoji/core/src/androidTest/java/androidx/emoji/widget/SpannableBuilderTest.java
+++ b/emoji/core/src/androidTest/java/androidx/emoji/widget/SpannableBuilderTest.java
@@ -151,6 +151,7 @@
verify(mWatcher, times(1)).afterTextChanged(any(Editable.class));
}
+ @SuppressWarnings("deprecation")
@Test
public void testDoesNotBlockSpanCallbacks_forNonEmojiSpans() {
final QuoteSpan span = mock(QuoteSpan.class);
diff --git a/enterprise/feedback/src/test/java/androidx/enterprise/feedback/DefaultKeyedAppStatesReporterTest.java b/enterprise/feedback/src/test/java/androidx/enterprise/feedback/DefaultKeyedAppStatesReporterTest.java
index 85484de..4bbfe9f 100644
--- a/enterprise/feedback/src/test/java/androidx/enterprise/feedback/DefaultKeyedAppStatesReporterTest.java
+++ b/enterprise/feedback/src/test/java/androidx/enterprise/feedback/DefaultKeyedAppStatesReporterTest.java
@@ -66,6 +66,7 @@
import java.util.concurrent.Executor;
/** Tests {@link DefaultKeyedAppStatesReporter}. */
+@SuppressWarnings("deprecation")
@RunWith(RobolectricTestRunner.class)
@DoNotInstrument
@Config(minSdk = 21)
diff --git a/enterprise/feedback/src/test/java/androidx/enterprise/feedback/KeyedAppStateTest.java b/enterprise/feedback/src/test/java/androidx/enterprise/feedback/KeyedAppStateTest.java
index 464fbb3..a481663 100644
--- a/enterprise/feedback/src/test/java/androidx/enterprise/feedback/KeyedAppStateTest.java
+++ b/enterprise/feedback/src/test/java/androidx/enterprise/feedback/KeyedAppStateTest.java
@@ -40,6 +40,7 @@
import org.robolectric.annotation.internal.DoNotInstrument;
/** Tests {@link KeyedAppState}. */
+@SuppressWarnings("deprecation")
@RunWith(RobolectricTestRunner.class)
@DoNotInstrument
@Config(minSdk = 21)
diff --git a/enterprise/feedback/src/test/java/androidx/enterprise/feedback/TestHandler.java b/enterprise/feedback/src/test/java/androidx/enterprise/feedback/TestHandler.java
index f8d0945..d09aeb7 100644
--- a/enterprise/feedback/src/test/java/androidx/enterprise/feedback/TestHandler.java
+++ b/enterprise/feedback/src/test/java/androidx/enterprise/feedback/TestHandler.java
@@ -25,6 +25,7 @@
/** Handler which stores the most recently handled message in a public field. */
@DoNotInstrument
+@SuppressWarnings("deprecation")
class TestHandler extends Handler {
@Nullable
diff --git a/enterprise/feedback/testing/src/test/java/androidx/enterprise/feedback/FakeKeyedAppStatesReporterTest.java b/enterprise/feedback/testing/src/test/java/androidx/enterprise/feedback/FakeKeyedAppStatesReporterTest.java
index fe34f6a..5685db7 100644
--- a/enterprise/feedback/testing/src/test/java/androidx/enterprise/feedback/FakeKeyedAppStatesReporterTest.java
+++ b/enterprise/feedback/testing/src/test/java/androidx/enterprise/feedback/FakeKeyedAppStatesReporterTest.java
@@ -82,6 +82,7 @@
assertThat(mReporter.getOnDeviceKeyedAppStates()).containsExactly(KEYED_APP_STATE);
}
+ @SuppressWarnings("deprecation")
@Test
public void setStates_deprecated_isRecordedInOnDeviceKeyedAppStates() {
mReporter.setStates(singletonList(KEYED_APP_STATE));
@@ -214,6 +215,7 @@
assertThat(mReporter.getUploadedKeyedAppStates()).containsExactly(KEYED_APP_STATE);
}
+ @SuppressWarnings("deprecation")
@Test
public void setStatesImmediate_deprecated_isRecordedInUploadedKeyedAppStates() {
mReporter.setStatesImmediate(singletonList(KEYED_APP_STATE));
diff --git a/exifinterface/exifinterface/src/androidTest/java/androidx/exifinterface/media/ExifInterfaceTest.java b/exifinterface/exifinterface/src/androidTest/java/androidx/exifinterface/media/ExifInterfaceTest.java
index 7e1ec2e..ba44e3b 100644
--- a/exifinterface/exifinterface/src/androidTest/java/androidx/exifinterface/media/ExifInterfaceTest.java
+++ b/exifinterface/exifinterface/src/androidTest/java/androidx/exifinterface/media/ExifInterfaceTest.java
@@ -219,23 +219,23 @@
private static final HashMap<Integer, Pair> FLIP_STATE_AND_ROTATION_DEGREES = new HashMap<>();
static {
FLIP_STATE_AND_ROTATION_DEGREES.put(
- ExifInterface.ORIENTATION_UNDEFINED, new Pair(false, 0));
+ ExifInterface.ORIENTATION_UNDEFINED, new Pair<>(false, 0));
FLIP_STATE_AND_ROTATION_DEGREES.put(
- ExifInterface.ORIENTATION_NORMAL, new Pair(false, 0));
+ ExifInterface.ORIENTATION_NORMAL, new Pair<>(false, 0));
FLIP_STATE_AND_ROTATION_DEGREES.put(
- ExifInterface.ORIENTATION_ROTATE_90, new Pair(false, 90));
+ ExifInterface.ORIENTATION_ROTATE_90, new Pair<>(false, 90));
FLIP_STATE_AND_ROTATION_DEGREES.put(
- ExifInterface.ORIENTATION_ROTATE_180, new Pair(false, 180));
+ ExifInterface.ORIENTATION_ROTATE_180, new Pair<>(false, 180));
FLIP_STATE_AND_ROTATION_DEGREES.put(
- ExifInterface.ORIENTATION_ROTATE_270, new Pair(false, 270));
+ ExifInterface.ORIENTATION_ROTATE_270, new Pair<>(false, 270));
FLIP_STATE_AND_ROTATION_DEGREES.put(
- ExifInterface.ORIENTATION_FLIP_HORIZONTAL, new Pair(true, 0));
+ ExifInterface.ORIENTATION_FLIP_HORIZONTAL, new Pair<>(true, 0));
FLIP_STATE_AND_ROTATION_DEGREES.put(
- ExifInterface.ORIENTATION_TRANSVERSE, new Pair(true, 90));
+ ExifInterface.ORIENTATION_TRANSVERSE, new Pair<>(true, 90));
FLIP_STATE_AND_ROTATION_DEGREES.put(
- ExifInterface.ORIENTATION_FLIP_VERTICAL, new Pair(true, 180));
+ ExifInterface.ORIENTATION_FLIP_VERTICAL, new Pair<>(true, 180));
FLIP_STATE_AND_ROTATION_DEGREES.put(
- ExifInterface.ORIENTATION_TRANSPOSE, new Pair(true, 270));
+ ExifInterface.ORIENTATION_TRANSPOSE, new Pair<>(true, 270));
}
private static final String[] EXIF_TAGS = {
@@ -919,6 +919,7 @@
}
+ @SuppressWarnings("deprecation")
@Test
@SmallTest
public void testInterchangeabilityBetweenTwoIsoSpeedTags() throws IOException {
diff --git a/leanback/leanback-tab/src/androidTest/java/androidx/leanback/tab/app/PagerAdapter.java b/leanback/leanback-tab/src/androidTest/java/androidx/leanback/tab/app/PagerAdapter.java
index 6f6634b..90ce54e 100644
--- a/leanback/leanback-tab/src/androidTest/java/androidx/leanback/tab/app/PagerAdapter.java
+++ b/leanback/leanback-tab/src/androidTest/java/androidx/leanback/tab/app/PagerAdapter.java
@@ -20,6 +20,7 @@
import androidx.fragment.app.FragmentManager;
import androidx.fragment.app.FragmentStatePagerAdapter;
+@SuppressWarnings("deprecation")
public class PagerAdapter extends FragmentStatePagerAdapter {
int mNumOfTabs;
diff --git a/leanback/leanback/build.gradle b/leanback/leanback/build.gradle
index 8e03560..3cbeb52 100644
--- a/leanback/leanback/build.gradle
+++ b/leanback/leanback/build.gradle
@@ -18,6 +18,7 @@
api("androidx.recyclerview:recyclerview:1.2.0-beta01")
api("androidx.appcompat:appcompat:1.0.0")
+ androidTestImplementation(KOTLIN_STDLIB)
androidTestImplementation(ANDROIDX_TEST_EXT_JUNIT)
androidTestImplementation(ANDROIDX_TEST_CORE)
androidTestImplementation(ANDROIDX_TEST_RUNNER)
diff --git a/leanback/leanback/src/androidTest/java/androidx/leanback/app/BrowseFragmentTest.java b/leanback/leanback/src/androidTest/java/androidx/leanback/app/BrowseFragmentTest.java
index 058c193..02e6d11 100644
--- a/leanback/leanback/src/androidTest/java/androidx/leanback/app/BrowseFragmentTest.java
+++ b/leanback/leanback/src/androidTest/java/androidx/leanback/app/BrowseFragmentTest.java
@@ -206,8 +206,8 @@
public static class MyFragment extends Fragment implements
BrowseFragment.MainFragmentAdapterProvider {
- BrowseFragment.MainFragmentAdapter mMainFragmentAdapter = new BrowseFragment
- .MainFragmentAdapter(this);
+ BrowseFragment.MainFragmentAdapter<MyFragment> mMainFragmentAdapter =
+ new BrowseFragment.MainFragmentAdapter<>(this);
@Nullable
@Override
@@ -217,7 +217,7 @@
}
@Override
- public BrowseFragment.MainFragmentAdapter getMainFragmentAdapter() {
+ public BrowseFragment.MainFragmentAdapter<MyFragment> getMainFragmentAdapter() {
return mMainFragmentAdapter;
}
}
diff --git a/leanback/leanback/src/androidTest/java/androidx/leanback/app/BrowseSupportFragmentTest.java b/leanback/leanback/src/androidTest/java/androidx/leanback/app/BrowseSupportFragmentTest.java
index 1a36149..fb87cc6 100644
--- a/leanback/leanback/src/androidTest/java/androidx/leanback/app/BrowseSupportFragmentTest.java
+++ b/leanback/leanback/src/androidTest/java/androidx/leanback/app/BrowseSupportFragmentTest.java
@@ -203,8 +203,8 @@
public static class MyFragment extends Fragment implements
BrowseSupportFragment.MainFragmentAdapterProvider {
- BrowseSupportFragment.MainFragmentAdapter mMainFragmentAdapter = new BrowseSupportFragment
- .MainFragmentAdapter(this);
+ BrowseSupportFragment.MainFragmentAdapter<MyFragment> mMainFragmentAdapter =
+ new BrowseSupportFragment.MainFragmentAdapter<>(this);
@Nullable
@Override
@@ -214,7 +214,7 @@
}
@Override
- public BrowseSupportFragment.MainFragmentAdapter getMainFragmentAdapter() {
+ public BrowseSupportFragment.MainFragmentAdapter<MyFragment> getMainFragmentAdapter() {
return mMainFragmentAdapter;
}
}
diff --git a/leanback/leanback/src/androidTest/java/androidx/leanback/app/GuidedStepFragmentTest.java b/leanback/leanback/src/androidTest/java/androidx/leanback/app/GuidedStepFragmentTest.java
index afc30c9..a6e6a24 100644
--- a/leanback/leanback/src/androidTest/java/androidx/leanback/app/GuidedStepFragmentTest.java
+++ b/leanback/leanback/src/androidTest/java/androidx/leanback/app/GuidedStepFragmentTest.java
@@ -54,6 +54,7 @@
import java.util.ArrayList;
import java.util.List;
+@SuppressWarnings("unchecked")
@LargeTest
@RunWith(AndroidJUnit4.class)
public class GuidedStepFragmentTest extends GuidedStepFragmentTestBase {
diff --git a/leanback/leanback/src/androidTest/java/androidx/leanback/app/GuidedStepSupportFragmentTest.java b/leanback/leanback/src/androidTest/java/androidx/leanback/app/GuidedStepSupportFragmentTest.java
index 450c145..97ff132 100644
--- a/leanback/leanback/src/androidTest/java/androidx/leanback/app/GuidedStepSupportFragmentTest.java
+++ b/leanback/leanback/src/androidTest/java/androidx/leanback/app/GuidedStepSupportFragmentTest.java
@@ -51,6 +51,7 @@
import java.util.ArrayList;
import java.util.List;
+@SuppressWarnings("unchecked")
@LargeTest
@RunWith(AndroidJUnit4.class)
public class GuidedStepSupportFragmentTest extends GuidedStepSupportFragmentTestBase {
diff --git a/leanback/leanback/src/androidTest/java/androidx/leanback/app/RowsFragmentTest.java b/leanback/leanback/src/androidTest/java/androidx/leanback/app/RowsFragmentTest.java
index 0bd7956..cecbfc8 100644
--- a/leanback/leanback/src/androidTest/java/androidx/leanback/app/RowsFragmentTest.java
+++ b/leanback/leanback/src/androidTest/java/androidx/leanback/app/RowsFragmentTest.java
@@ -400,7 +400,7 @@
}
static class StableIdAdapter extends ObjectAdapter {
- ArrayList<Integer> mList = new ArrayList();
+ ArrayList<Integer> mList = new ArrayList<>();
@Override
public long getId(int position) {
@@ -526,8 +526,8 @@
public static class F_Base extends BrowseFragment {
- List<Long> mEntranceTransitionStartTS = new ArrayList();
- List<Long> mEntranceTransitionEndTS = new ArrayList();
+ List<Long> mEntranceTransitionStartTS = new ArrayList<>();
+ List<Long> mEntranceTransitionEndTS = new ArrayList<>();
@Override
protected void onEntranceTransitionStart() {
diff --git a/leanback/leanback/src/androidTest/java/androidx/leanback/app/RowsSupportFragmentTest.java b/leanback/leanback/src/androidTest/java/androidx/leanback/app/RowsSupportFragmentTest.java
index fae7d87..cfaf5c2 100644
--- a/leanback/leanback/src/androidTest/java/androidx/leanback/app/RowsSupportFragmentTest.java
+++ b/leanback/leanback/src/androidTest/java/androidx/leanback/app/RowsSupportFragmentTest.java
@@ -397,7 +397,7 @@
}
static class StableIdAdapter extends ObjectAdapter {
- ArrayList<Integer> mList = new ArrayList();
+ ArrayList<Integer> mList = new ArrayList<>();
@Override
public long getId(int position) {
@@ -523,8 +523,8 @@
public static class F_Base extends BrowseSupportFragment {
- List<Long> mEntranceTransitionStartTS = new ArrayList();
- List<Long> mEntranceTransitionEndTS = new ArrayList();
+ List<Long> mEntranceTransitionStartTS = new ArrayList<>();
+ List<Long> mEntranceTransitionEndTS = new ArrayList<>();
@Override
protected void onEntranceTransitionStart() {
diff --git a/leanback/leanback/src/androidTest/java/androidx/leanback/app/wizard/GuidedStepAttributesTestFragment.java b/leanback/leanback/src/androidTest/java/androidx/leanback/app/wizard/GuidedStepAttributesTestFragment.java
index fb4ed92..5dbad85 100644
--- a/leanback/leanback/src/androidTest/java/androidx/leanback/app/wizard/GuidedStepAttributesTestFragment.java
+++ b/leanback/leanback/src/androidTest/java/androidx/leanback/app/wizard/GuidedStepAttributesTestFragment.java
@@ -31,7 +31,7 @@
}
}
- static HashMap<Long, Callback> sCallbacks = new HashMap();
+ static HashMap<Long, Callback> sCallbacks = new HashMap<>();
public static GuidanceStylist.Guidance GUIDANCE = null;
public static List<GuidedAction> ACTION_LIST = null;
public static long LAST_CLICKED_ACTION_ID = -1;
diff --git a/leanback/leanback/src/androidTest/java/androidx/leanback/media/PlaybackBannerControlGlueTest.java b/leanback/leanback/src/androidTest/java/androidx/leanback/media/PlaybackBannerControlGlueTest.java
index 8e7d608..a16c430 100644
--- a/leanback/leanback/src/androidTest/java/androidx/leanback/media/PlaybackBannerControlGlueTest.java
+++ b/leanback/leanback/src/androidTest/java/androidx/leanback/media/PlaybackBannerControlGlueTest.java
@@ -54,7 +54,7 @@
}
public static class PlaybackBannerControlGlueImpl
- extends PlaybackBannerControlGlue {
+ extends PlaybackBannerControlGlue<PlayerAdapter> {
public PlaybackBannerControlGlueImpl(Context context) {
super(context, new int[] {1, 2 , 3, 4, 5}, new PlayerAdapterSample());
}
diff --git a/leanback/leanback/src/androidTest/java/androidx/leanback/media/PlaybackTransportControlGlueTest.java b/leanback/leanback/src/androidTest/java/androidx/leanback/media/PlaybackTransportControlGlueTest.java
index d3cfa19..080365e 100644
--- a/leanback/leanback/src/androidTest/java/androidx/leanback/media/PlaybackTransportControlGlueTest.java
+++ b/leanback/leanback/src/androidTest/java/androidx/leanback/media/PlaybackTransportControlGlueTest.java
@@ -55,6 +55,7 @@
}
}
+ @SuppressWarnings("unchecked")
public static class PlaybackTransportControlGlueImpl
extends PlaybackTransportControlGlue {
public PlaybackTransportControlGlueImpl(Context context) {
diff --git a/leanback/leanback/src/androidTest/java/androidx/leanback/widget/ControlBarTest.java b/leanback/leanback/src/androidTest/java/androidx/leanback/widget/ControlBarTest.java
index d72bbcc..87a16c1 100644
--- a/leanback/leanback/src/androidTest/java/androidx/leanback/widget/ControlBarTest.java
+++ b/leanback/leanback/src/androidTest/java/androidx/leanback/widget/ControlBarTest.java
@@ -118,7 +118,7 @@
final TextView v3 = new Button(context);
bar.addView(v3, 100, 100);
- ArrayList<View> focusables = new ArrayList();
+ ArrayList<View> focusables = new ArrayList<>();
bar.addFocusables(focusables, View.FOCUS_DOWN);
assertEquals(1, focusables.size());
assertSame(focusables.get(0), v2);
diff --git a/leanback/leanback/src/androidTest/java/androidx/leanback/widget/GridActivity.java b/leanback/leanback/src/androidTest/java/androidx/leanback/widget/GridActivity.java
index 693546d..48a59c7 100644
--- a/leanback/leanback/src/androidTest/java/androidx/leanback/widget/GridActivity.java
+++ b/leanback/leanback/src/androidTest/java/androidx/leanback/widget/GridActivity.java
@@ -132,6 +132,7 @@
return view;
}
+ @SuppressWarnings("unchecked")
@Override
protected void onCreate(Bundle savedInstanceState) {
Intent intent = getIntent();
diff --git a/leanback/leanback/src/androidTest/java/androidx/leanback/widget/GridWidgetTest.java b/leanback/leanback/src/androidTest/java/androidx/leanback/widget/GridWidgetTest.java
index 82e1323..5f7a59a 100644
--- a/leanback/leanback/src/androidTest/java/androidx/leanback/widget/GridWidgetTest.java
+++ b/leanback/leanback/src/androidTest/java/androidx/leanback/widget/GridWidgetTest.java
@@ -1168,7 +1168,7 @@
}
});
waitForScrollIdle();
- final ArrayList<RecyclerView.ViewHolder> moveViewHolders = new ArrayList();
+ final ArrayList<RecyclerView.ViewHolder> moveViewHolders = new ArrayList<>();
for (int i = 51;; i++) {
RecyclerView.ViewHolder vh = mGridView.findViewHolderForAdapterPosition(i);
if (vh == null) {
@@ -1233,7 +1233,7 @@
mActivity.moveItem(51, 1000, true);
}
});
- final ArrayList<View> moveInViewHolders = new ArrayList();
+ final ArrayList<View> moveInViewHolders = new ArrayList<>();
waitForItemAnimationStart();
mActivityTestRule.runOnUiThread(new Runnable() {
@Override
@@ -1297,7 +1297,7 @@
mActivity.moveItem(1499, 1, true);
}
});
- final ArrayList<View> moveInViewHolders = new ArrayList();
+ final ArrayList<View> moveInViewHolders = new ArrayList<>();
waitForItemAnimationStart();
mActivityTestRule.runOnUiThread(new Runnable() {
@Override
@@ -6129,7 +6129,7 @@
initActivity(intent);
- final HashSet<View> moveAnimationViews = new HashSet();
+ final HashSet<View> moveAnimationViews = new HashSet<>();
mActivity.mImportantForAccessibilityListener =
new GridActivity.ImportantForAccessibilityListener() {
RecyclerView.LayoutManager mLM = mGridView.getLayoutManager();
diff --git a/leanback/leanback/src/androidTest/java/androidx/leanback/widget/ItemBridgeAdapterTest.java b/leanback/leanback/src/androidTest/java/androidx/leanback/widget/ItemBridgeAdapterTest.java
index ac5ce09..2f6ed29 100644
--- a/leanback/leanback/src/androidTest/java/androidx/leanback/widget/ItemBridgeAdapterTest.java
+++ b/leanback/leanback/src/androidTest/java/androidx/leanback/widget/ItemBridgeAdapterTest.java
@@ -91,8 +91,8 @@
mRecyclerView.setHasFixedSize(false); // force layout items in layout pass
}
- List populateData() {
- List data = new ArrayList();
+ List<Integer> populateData() {
+ List<Integer> data = new ArrayList<>();
for (int i = 0; i < 10000; i++) {
data.add(i);
}
diff --git a/leanback/leanback/src/androidTest/java/androidx/leanback/widget/ObjectAdapterTest.java b/leanback/leanback/src/androidTest/java/androidx/leanback/widget/ObjectAdapterTest.java
index 50e78e7..43d2aaf 100644
--- a/leanback/leanback/src/androidTest/java/androidx/leanback/widget/ObjectAdapterTest.java
+++ b/leanback/leanback/src/androidTest/java/androidx/leanback/widget/ObjectAdapterTest.java
@@ -46,6 +46,7 @@
import java.util.ArrayList;
import java.util.List;
+@SuppressWarnings("unchecked")
@SmallTest
@RunWith(AndroidJUnit4.class)
public class ObjectAdapterTest {
diff --git a/leanback/leanback/src/androidTest/java/androidx/leanback/widget/PlaybackTransportRowPresenterTest.java b/leanback/leanback/src/androidTest/java/androidx/leanback/widget/PlaybackTransportRowPresenterTest.java
index 080fd44..ab90c40 100644
--- a/leanback/leanback/src/androidTest/java/androidx/leanback/widget/PlaybackTransportRowPresenterTest.java
+++ b/leanback/leanback/src/androidTest/java/androidx/leanback/widget/PlaybackTransportRowPresenterTest.java
@@ -51,7 +51,7 @@
public class PlaybackTransportRowPresenterTest {
Context mContext;
- PlaybackTransportControlGlue mGlue;
+ PlaybackTransportControlGlue<PlayerAdapter> mGlue;
PlaybackGlueHostImplWithViewHolder mHost;
PlayerAdapter mImpl;
PlaybackTransportRowPresenter.ViewHolder mViewHolder;
@@ -68,7 +68,7 @@
InstrumentationRegistry.getInstrumentation().runOnMainSync(new Runnable() {
@Override
public void run() {
- mGlue = new PlaybackTransportControlGlue(mContext, mImpl) {
+ mGlue = new PlaybackTransportControlGlue<PlayerAdapter>(mContext, mImpl) {
@Override
protected void onCreatePrimaryActions(ArrayObjectAdapter
primaryActionsAdapter) {
diff --git a/lifecycle/lifecycle-common/src/main/java/androidx/lifecycle/Lifecycling.java b/lifecycle/lifecycle-common/src/main/java/androidx/lifecycle/Lifecycling.java
index f5eda7f..f34e124 100644
--- a/lifecycle/lifecycle-common/src/main/java/androidx/lifecycle/Lifecycling.java
+++ b/lifecycle/lifecycle-common/src/main/java/androidx/lifecycle/Lifecycling.java
@@ -112,6 +112,7 @@
}
}
+ @SuppressWarnings("deprecation")
@Nullable
private static Constructor<? extends GeneratedAdapter> generatedConstructor(Class<?> klass) {
try {
diff --git a/lifecycle/lifecycle-process/src/test/java/androidx/lifecycle/DispatcherActivityCallbackTest.java b/lifecycle/lifecycle-process/src/test/java/androidx/lifecycle/DispatcherActivityCallbackTest.java
index c723dab..50c86f1 100644
--- a/lifecycle/lifecycle-process/src/test/java/androidx/lifecycle/DispatcherActivityCallbackTest.java
+++ b/lifecycle/lifecycle-process/src/test/java/androidx/lifecycle/DispatcherActivityCallbackTest.java
@@ -24,8 +24,6 @@
import android.annotation.SuppressLint;
import android.app.Activity;
-import android.app.Fragment;
-import android.app.FragmentTransaction;
import android.os.Bundle;
import org.junit.Test;
@@ -42,14 +40,15 @@
checkReportFragment(callback, activity);
}
+ @SuppressWarnings("deprecation")
@SuppressLint("CommitTransaction")
private void checkReportFragment(LifecycleDispatcher.DispatcherActivityCallback callback,
Activity activity) {
android.app.FragmentManager fm = mock(android.app.FragmentManager.class);
- FragmentTransaction transaction = mock(FragmentTransaction.class);
+ android.app.FragmentTransaction transaction = mock(android.app.FragmentTransaction.class);
when(activity.getFragmentManager()).thenReturn(fm);
when(fm.beginTransaction()).thenReturn(transaction);
- when(transaction.add(any(Fragment.class), anyString())).thenReturn(transaction);
+ when(transaction.add(any(android.app.Fragment.class), anyString())).thenReturn(transaction);
callback.onActivityCreated(activity, mock(Bundle.class));
verify(activity).getFragmentManager();
verify(fm).beginTransaction();
diff --git a/lifecycle/lifecycle-viewmodel/src/test/java/androidx/lifecycle/ViewModelProviderTest.java b/lifecycle/lifecycle-viewmodel/src/test/java/androidx/lifecycle/ViewModelProviderTest.java
index 0d5783c..7e20deb 100644
--- a/lifecycle/lifecycle-viewmodel/src/test/java/androidx/lifecycle/ViewModelProviderTest.java
+++ b/lifecycle/lifecycle-viewmodel/src/test/java/androidx/lifecycle/ViewModelProviderTest.java
@@ -106,6 +106,7 @@
}
};
ViewModelProvider.KeyedFactory keyed = new ViewModelProvider.KeyedFactory() {
+ @SuppressWarnings("unchecked")
@NonNull
@Override
public <T extends ViewModel> T create(@NonNull String key,
diff --git a/media/version-compat-tests/current/client/src/androidTest/java/android/support/mediacompat/client/MediaControllerCompatCallbackTest.java b/media/version-compat-tests/current/client/src/androidTest/java/android/support/mediacompat/client/MediaControllerCompatCallbackTest.java
index b856e04..b54cc59 100644
--- a/media/version-compat-tests/current/client/src/androidTest/java/android/support/mediacompat/client/MediaControllerCompatCallbackTest.java
+++ b/media/version-compat-tests/current/client/src/androidTest/java/android/support/mediacompat/client/MediaControllerCompatCallbackTest.java
@@ -202,6 +202,7 @@
/**
* Tests {@link MediaSessionCompat#setFlags}.
*/
+ @SuppressWarnings("deprecation")
@Test
@SmallTest
public void testSetFlags() throws Exception {
diff --git a/media/version-compat-tests/current/client/src/androidTest/java/android/support/mediacompat/client/RemoteUserInfoWithMediaControllerCompatTest.java b/media/version-compat-tests/current/client/src/androidTest/java/android/support/mediacompat/client/RemoteUserInfoWithMediaControllerCompatTest.java
index 7a1d085..b0fdbcb 100644
--- a/media/version-compat-tests/current/client/src/androidTest/java/android/support/mediacompat/client/RemoteUserInfoWithMediaControllerCompatTest.java
+++ b/media/version-compat-tests/current/client/src/androidTest/java/android/support/mediacompat/client/RemoteUserInfoWithMediaControllerCompatTest.java
@@ -77,6 +77,7 @@
private MediaControllerCompat mMediaController;
private ControllerCallback mMediaControllerCallback;
+ @SuppressWarnings("deprecation")
@Before
public void setUp() throws InterruptedException {
mServiceVersion = getArguments().getString(KEY_SERVICE_VERSION, "");
diff --git a/media/version-compat-tests/current/client/src/androidTest/java/android/support/mediacompat/client/RemoteUserInfoWithMediaControllerTest.java b/media/version-compat-tests/current/client/src/androidTest/java/android/support/mediacompat/client/RemoteUserInfoWithMediaControllerTest.java
index c01aeb2..1f3976f 100644
--- a/media/version-compat-tests/current/client/src/androidTest/java/android/support/mediacompat/client/RemoteUserInfoWithMediaControllerTest.java
+++ b/media/version-compat-tests/current/client/src/androidTest/java/android/support/mediacompat/client/RemoteUserInfoWithMediaControllerTest.java
@@ -78,6 +78,7 @@
private MediaController mMediaController;
private ControllerCallback mMediaControllerCallback;
+ @SuppressWarnings("deprecation")
@Before
public void setUp() throws InterruptedException {
mServiceVersion = getArguments().getString(KEY_SERVICE_VERSION, "");
diff --git a/media/version-compat-tests/current/service/src/androidTest/java/android/support/mediacompat/service/MediaSessionCompatCallbackTest.java b/media/version-compat-tests/current/service/src/androidTest/java/android/support/mediacompat/service/MediaSessionCompatCallbackTest.java
index 9953185..e53d656 100644
--- a/media/version-compat-tests/current/service/src/androidTest/java/android/support/mediacompat/service/MediaSessionCompatCallbackTest.java
+++ b/media/version-compat-tests/current/service/src/androidTest/java/android/support/mediacompat/service/MediaSessionCompatCallbackTest.java
@@ -175,6 +175,7 @@
/**
* Tests that a session can be created and that all the fields are initialized correctly.
*/
+ @SuppressWarnings("deprecation")
@Test
@SmallTest
public void testCreateSession() throws Exception {
diff --git a/media/version-compat-tests/current/service/src/androidTest/java/android/support/mediacompat/service/StubMediaBrowserServiceCompat.java b/media/version-compat-tests/current/service/src/androidTest/java/android/support/mediacompat/service/StubMediaBrowserServiceCompat.java
index 76314be..814ac7c 100644
--- a/media/version-compat-tests/current/service/src/androidTest/java/android/support/mediacompat/service/StubMediaBrowserServiceCompat.java
+++ b/media/version-compat-tests/current/service/src/androidTest/java/android/support/mediacompat/service/StubMediaBrowserServiceCompat.java
@@ -81,6 +81,7 @@
private String mExpectedCallerPackageName;
private int mExpectedCallerUid;
+ @SuppressWarnings("deprecation")
@Override
public void onCreate() {
super.onCreate();
@@ -420,6 +421,7 @@
notifyCurrentControllerInfo("onRemoveQueueItem");
}
+ @SuppressWarnings("deprecation")
@Override
public void onRemoveQueueItemAt(int index) {
notifyCurrentControllerInfo("onRemoveQueueItemAt");
diff --git a/media/version-compat-tests/previous/client/src/androidTest/java/android/support/mediacompat/client/RemoteUserInfoWithMediaControllerCompatTest.java b/media/version-compat-tests/previous/client/src/androidTest/java/android/support/mediacompat/client/RemoteUserInfoWithMediaControllerCompatTest.java
index 49e3478..0567306 100644
--- a/media/version-compat-tests/previous/client/src/androidTest/java/android/support/mediacompat/client/RemoteUserInfoWithMediaControllerCompatTest.java
+++ b/media/version-compat-tests/previous/client/src/androidTest/java/android/support/mediacompat/client/RemoteUserInfoWithMediaControllerCompatTest.java
@@ -78,6 +78,7 @@
private MediaControllerCompat mMediaController;
private ControllerCallback mMediaControllerCallback;
+ @SuppressWarnings("deprecation")
@Before
public void setUp() throws InterruptedException, RemoteException {
mServiceVersion = getArguments().getString(KEY_SERVICE_VERSION, "");
diff --git a/media/version-compat-tests/previous/client/src/androidTest/java/android/support/mediacompat/client/RemoteUserInfoWithMediaControllerTest.java b/media/version-compat-tests/previous/client/src/androidTest/java/android/support/mediacompat/client/RemoteUserInfoWithMediaControllerTest.java
index 464f21e..16fe1cc 100644
--- a/media/version-compat-tests/previous/client/src/androidTest/java/android/support/mediacompat/client/RemoteUserInfoWithMediaControllerTest.java
+++ b/media/version-compat-tests/previous/client/src/androidTest/java/android/support/mediacompat/client/RemoteUserInfoWithMediaControllerTest.java
@@ -78,6 +78,7 @@
private MediaController mMediaController;
private ControllerCallback mMediaControllerCallback;
+ @SuppressWarnings("deprecation")
@Before
public void setUp() throws InterruptedException {
mServiceVersion = getArguments().getString(KEY_SERVICE_VERSION, "");
diff --git a/media2/session/version-compat-tests/current/client/build.gradle b/media2/session/version-compat-tests/current/client/build.gradle
index a71c527..4dbf70c 100644
--- a/media2/session/version-compat-tests/current/client/build.gradle
+++ b/media2/session/version-compat-tests/current/client/build.gradle
@@ -36,3 +36,7 @@
minSdkVersion 16
}
}
+
+androidx {
+ failOnDeprecationWarnings = false
+}
\ No newline at end of file
diff --git a/media2/session/version-compat-tests/current/service/build.gradle b/media2/session/version-compat-tests/current/service/build.gradle
index cebe889..8dabfb8 100644
--- a/media2/session/version-compat-tests/current/service/build.gradle
+++ b/media2/session/version-compat-tests/current/service/build.gradle
@@ -35,3 +35,7 @@
minSdkVersion 16
}
}
+
+androidx {
+ failOnDeprecationWarnings = false
+}
\ No newline at end of file
diff --git a/media2/session/version-compat-tests/current/service/src/androidTest/java/androidx/media2/test/service/MockPlayer.java b/media2/session/version-compat-tests/current/service/src/androidTest/java/androidx/media2/test/service/MockPlayer.java
index 76136c5..662fefd 100644
--- a/media2/session/version-compat-tests/current/service/src/androidTest/java/androidx/media2/test/service/MockPlayer.java
+++ b/media2/session/version-compat-tests/current/service/src/androidTest/java/androidx/media2/test/service/MockPlayer.java
@@ -348,7 +348,7 @@
@NonNull
public ListenableFuture<PlayerResult> setMediaItem(@NonNull MediaItem item) {
mItem = item;
- ArrayList list = new ArrayList<>();
+ ArrayList<MediaItem> list = new ArrayList<>();
list.add(item);
return setPlaylist(list, null);
}
diff --git a/media2/session/version-compat-tests/previous/client/build.gradle b/media2/session/version-compat-tests/previous/client/build.gradle
index 3fd0d17..ae04edb8 100644
--- a/media2/session/version-compat-tests/previous/client/build.gradle
+++ b/media2/session/version-compat-tests/previous/client/build.gradle
@@ -36,3 +36,7 @@
minSdkVersion 19
}
}
+
+androidx {
+ failOnDeprecationWarnings = false
+}
\ No newline at end of file
diff --git a/media2/session/version-compat-tests/previous/service/build.gradle b/media2/session/version-compat-tests/previous/service/build.gradle
index aa5cba0..0a1091e 100644
--- a/media2/session/version-compat-tests/previous/service/build.gradle
+++ b/media2/session/version-compat-tests/previous/service/build.gradle
@@ -35,3 +35,7 @@
minSdkVersion 19
}
}
+
+androidx {
+ failOnDeprecationWarnings = false
+}
\ No newline at end of file
diff --git a/media2/session/version-compat-tests/previous/service/src/androidTest/java/androidx/media2/test/service/MockPlayer.java b/media2/session/version-compat-tests/previous/service/src/androidTest/java/androidx/media2/test/service/MockPlayer.java
index 46c9dbc..cbbeb33 100644
--- a/media2/session/version-compat-tests/previous/service/src/androidTest/java/androidx/media2/test/service/MockPlayer.java
+++ b/media2/session/version-compat-tests/previous/service/src/androidTest/java/androidx/media2/test/service/MockPlayer.java
@@ -337,7 +337,7 @@
@Override
public ListenableFuture<PlayerResult> setMediaItem(MediaItem item) {
mItem = item;
- ArrayList list = new ArrayList<>();
+ ArrayList<MediaItem> list = new ArrayList<>();
list.add(item);
return setPlaylist(list, null);
}
diff --git a/media2/widget/src/androidTest/java/androidx/media2/widget/MediaControlView_WithPlayerTest.java b/media2/widget/src/androidTest/java/androidx/media2/widget/MediaControlView_WithPlayerTest.java
index 43d18dd..c3d0127 100644
--- a/media2/widget/src/androidTest/java/androidx/media2/widget/MediaControlView_WithPlayerTest.java
+++ b/media2/widget/src/androidTest/java/androidx/media2/widget/MediaControlView_WithPlayerTest.java
@@ -45,7 +45,6 @@
import androidx.media2.common.SessionPlayer.TrackInfo;
import androidx.media2.session.MediaController;
import androidx.test.filters.LargeTest;
-import androidx.test.rule.ActivityTestRule;
import org.junit.After;
import org.junit.Before;
@@ -78,9 +77,10 @@
private MediaControlView mMediaControlView;
private MediaItem mFileSchemeMediaItem;
+ @SuppressWarnings("deprecation")
@Rule
- public ActivityTestRule<MediaControlViewTestActivity> mActivityRule =
- new ActivityTestRule<>(MediaControlViewTestActivity.class);
+ public androidx.test.rule.ActivityTestRule<MediaControlViewTestActivity> mActivityRule =
+ new androidx.test.rule.ActivityTestRule<>(MediaControlViewTestActivity.class);
public MediaControlView_WithPlayerTest(String playerType) {
mPlayerType = playerType;
diff --git a/media2/widget/src/androidTest/java/androidx/media2/widget/MediaControlView_WithoutPlayerTest.java b/media2/widget/src/androidTest/java/androidx/media2/widget/MediaControlView_WithoutPlayerTest.java
index d2ec15e..8c94b8c 100644
--- a/media2/widget/src/androidTest/java/androidx/media2/widget/MediaControlView_WithoutPlayerTest.java
+++ b/media2/widget/src/androidTest/java/androidx/media2/widget/MediaControlView_WithoutPlayerTest.java
@@ -32,7 +32,6 @@
import androidx.test.annotation.UiThreadTest;
import androidx.test.ext.junit.runners.AndroidJUnit4;
import androidx.test.filters.LargeTest;
-import androidx.test.rule.ActivityTestRule;
import org.junit.Before;
import org.junit.Rule;
@@ -52,9 +51,10 @@
private MediaControlViewTestActivity mActivity;
private MediaControlView mMediaControlView;
+ @SuppressWarnings("deprecation")
@Rule
- public ActivityTestRule<MediaControlViewTestActivity> mActivityRule =
- new ActivityTestRule<>(MediaControlViewTestActivity.class);
+ public androidx.test.rule.ActivityTestRule<MediaControlViewTestActivity> mActivityRule =
+ new androidx.test.rule.ActivityTestRule<>(MediaControlViewTestActivity.class);
@Before
public void setup() throws Throwable {
diff --git a/media2/widget/src/androidTest/java/androidx/media2/widget/MediaTestBase.java b/media2/widget/src/androidTest/java/androidx/media2/widget/MediaTestBase.java
index 03ad52d..bac7e6c 100644
--- a/media2/widget/src/androidTest/java/androidx/media2/widget/MediaTestBase.java
+++ b/media2/widget/src/androidTest/java/androidx/media2/widget/MediaTestBase.java
@@ -32,6 +32,7 @@
@BeforeClass
public static void setupMainLooper() {
InstrumentationRegistry.getInstrumentation().runOnMainSync(new Runnable() {
+ @SuppressWarnings("deprecation")
@Override
public void run() {
// Prepare the main looper if it hasn't.
diff --git a/media2/widget/src/androidTest/java/androidx/media2/widget/TestUtils.java b/media2/widget/src/androidTest/java/androidx/media2/widget/TestUtils.java
index 3d2ba52..ffeae29 100644
--- a/media2/widget/src/androidTest/java/androidx/media2/widget/TestUtils.java
+++ b/media2/widget/src/androidTest/java/androidx/media2/widget/TestUtils.java
@@ -24,6 +24,7 @@
import android.view.WindowManager;
final class TestUtils {
+ @SuppressWarnings("deprecation")
static void setKeepScreenOn(Activity activity) {
if (Build.VERSION.SDK_INT >= 27) {
activity.getWindow().addFlags(WindowManager.LayoutParams.FLAG_KEEP_SCREEN_ON);
diff --git a/media2/widget/src/androidTest/java/androidx/media2/widget/VideoView_WithPlayerTest.java b/media2/widget/src/androidTest/java/androidx/media2/widget/VideoView_WithPlayerTest.java
index 14e9f40..5fae061 100644
--- a/media2/widget/src/androidTest/java/androidx/media2/widget/VideoView_WithPlayerTest.java
+++ b/media2/widget/src/androidTest/java/androidx/media2/widget/VideoView_WithPlayerTest.java
@@ -51,7 +51,6 @@
import androidx.media2.session.MediaController;
import androidx.media2.widget.test.R;
import androidx.test.filters.LargeTest;
-import androidx.test.rule.ActivityTestRule;
import org.junit.After;
import org.junit.Before;
@@ -82,9 +81,10 @@
private MediaItem mMediaItem;
private SynchronousPixelCopy mPixelCopyHelper;
+ @SuppressWarnings("deprecation")
@Rule
- public ActivityTestRule<VideoViewTestActivity> mActivityRule =
- new ActivityTestRule<>(VideoViewTestActivity.class);
+ public androidx.test.rule.ActivityTestRule<VideoViewTestActivity> mActivityRule =
+ new androidx.test.rule.ActivityTestRule<>(VideoViewTestActivity.class);
public VideoView_WithPlayerTest(String playerType) {
mPlayerType = playerType;
diff --git a/media2/widget/src/androidTest/java/androidx/media2/widget/VideoView_WithoutPlayerTest.java b/media2/widget/src/androidTest/java/androidx/media2/widget/VideoView_WithoutPlayerTest.java
index 9bbfd04..03a18c0 100644
--- a/media2/widget/src/androidTest/java/androidx/media2/widget/VideoView_WithoutPlayerTest.java
+++ b/media2/widget/src/androidTest/java/androidx/media2/widget/VideoView_WithoutPlayerTest.java
@@ -22,7 +22,6 @@
import androidx.test.annotation.UiThreadTest;
import androidx.test.ext.junit.runners.AndroidJUnit4;
import androidx.test.filters.LargeTest;
-import androidx.test.rule.ActivityTestRule;
import org.junit.Before;
import org.junit.Rule;
@@ -39,9 +38,10 @@
private Activity mActivity;
private VideoView mVideoView;
+ @SuppressWarnings("deprecation")
@Rule
- public ActivityTestRule<VideoViewTestActivity> mActivityRule =
- new ActivityTestRule<>(VideoViewTestActivity.class);
+ public androidx.test.rule.ActivityTestRule<VideoViewTestActivity> mActivityRule =
+ new androidx.test.rule.ActivityTestRule<>(VideoViewTestActivity.class);
@Before
public void setup() throws Throwable {
diff --git a/navigation/navigation-dynamic-features-fragment/api/current.txt b/navigation/navigation-dynamic-features-fragment/api/current.txt
index 74621d5..73124fc8 100644
--- a/navigation/navigation-dynamic-features-fragment/api/current.txt
+++ b/navigation/navigation-dynamic-features-fragment/api/current.txt
@@ -30,7 +30,15 @@
public class DynamicNavHostFragment extends androidx.navigation.fragment.NavHostFragment {
ctor public DynamicNavHostFragment();
+ method public static final androidx.navigation.dynamicfeatures.fragment.DynamicNavHostFragment create(@NavigationRes int graphResId, optional android.os.Bundle? startDestinationArgs);
+ method public static final androidx.navigation.dynamicfeatures.fragment.DynamicNavHostFragment create(@NavigationRes int graphResId);
method protected com.google.android.play.core.splitinstall.SplitInstallManager createSplitInstallManager();
+ field public static final androidx.navigation.dynamicfeatures.fragment.DynamicNavHostFragment.Companion Companion;
+ }
+
+ public static final class DynamicNavHostFragment.Companion {
+ method public androidx.navigation.dynamicfeatures.fragment.DynamicNavHostFragment create(@NavigationRes int graphResId, optional android.os.Bundle? startDestinationArgs);
+ method public androidx.navigation.dynamicfeatures.fragment.DynamicNavHostFragment create(@NavigationRes int graphResId);
}
}
diff --git a/navigation/navigation-dynamic-features-fragment/api/public_plus_experimental_current.txt b/navigation/navigation-dynamic-features-fragment/api/public_plus_experimental_current.txt
index 74621d5..73124fc8 100644
--- a/navigation/navigation-dynamic-features-fragment/api/public_plus_experimental_current.txt
+++ b/navigation/navigation-dynamic-features-fragment/api/public_plus_experimental_current.txt
@@ -30,7 +30,15 @@
public class DynamicNavHostFragment extends androidx.navigation.fragment.NavHostFragment {
ctor public DynamicNavHostFragment();
+ method public static final androidx.navigation.dynamicfeatures.fragment.DynamicNavHostFragment create(@NavigationRes int graphResId, optional android.os.Bundle? startDestinationArgs);
+ method public static final androidx.navigation.dynamicfeatures.fragment.DynamicNavHostFragment create(@NavigationRes int graphResId);
method protected com.google.android.play.core.splitinstall.SplitInstallManager createSplitInstallManager();
+ field public static final androidx.navigation.dynamicfeatures.fragment.DynamicNavHostFragment.Companion Companion;
+ }
+
+ public static final class DynamicNavHostFragment.Companion {
+ method public androidx.navigation.dynamicfeatures.fragment.DynamicNavHostFragment create(@NavigationRes int graphResId, optional android.os.Bundle? startDestinationArgs);
+ method public androidx.navigation.dynamicfeatures.fragment.DynamicNavHostFragment create(@NavigationRes int graphResId);
}
}
diff --git a/navigation/navigation-dynamic-features-fragment/api/restricted_current.txt b/navigation/navigation-dynamic-features-fragment/api/restricted_current.txt
index 74621d5..73124fc8 100644
--- a/navigation/navigation-dynamic-features-fragment/api/restricted_current.txt
+++ b/navigation/navigation-dynamic-features-fragment/api/restricted_current.txt
@@ -30,7 +30,15 @@
public class DynamicNavHostFragment extends androidx.navigation.fragment.NavHostFragment {
ctor public DynamicNavHostFragment();
+ method public static final androidx.navigation.dynamicfeatures.fragment.DynamicNavHostFragment create(@NavigationRes int graphResId, optional android.os.Bundle? startDestinationArgs);
+ method public static final androidx.navigation.dynamicfeatures.fragment.DynamicNavHostFragment create(@NavigationRes int graphResId);
method protected com.google.android.play.core.splitinstall.SplitInstallManager createSplitInstallManager();
+ field public static final androidx.navigation.dynamicfeatures.fragment.DynamicNavHostFragment.Companion Companion;
+ }
+
+ public static final class DynamicNavHostFragment.Companion {
+ method public androidx.navigation.dynamicfeatures.fragment.DynamicNavHostFragment create(@NavigationRes int graphResId, optional android.os.Bundle? startDestinationArgs);
+ method public androidx.navigation.dynamicfeatures.fragment.DynamicNavHostFragment create(@NavigationRes int graphResId);
}
}
diff --git a/navigation/navigation-dynamic-features-fragment/src/androidTest/java/androidx/navigation/dynamicfeatures/fragment/DynamicFragmentNavigatorDestinationBuilderTest.kt b/navigation/navigation-dynamic-features-fragment/src/androidTest/java/androidx/navigation/dynamicfeatures/fragment/DynamicFragmentNavigatorDestinationBuilderTest.kt
index 7c33183..ee291df 100644
--- a/navigation/navigation-dynamic-features-fragment/src/androidTest/java/androidx/navigation/dynamicfeatures/fragment/DynamicFragmentNavigatorDestinationBuilderTest.kt
+++ b/navigation/navigation-dynamic-features-fragment/src/androidTest/java/androidx/navigation/dynamicfeatures/fragment/DynamicFragmentNavigatorDestinationBuilderTest.kt
@@ -21,8 +21,10 @@
import androidx.navigation.dynamicfeatures.createGraph
import androidx.navigation.get
import androidx.test.annotation.UiThreadTest
+import androidx.test.ext.junit.rules.ActivityScenarioRule
import androidx.test.ext.junit.runners.AndroidJUnit4
import androidx.test.filters.MediumTest
+import androidx.testutils.withActivity
import com.google.common.truth.Truth.assertWithMessage
import org.junit.Rule
import org.junit.Test
@@ -30,14 +32,17 @@
@MediumTest
@RunWith(AndroidJUnit4::class)
-class DynamicFragmentNavigatorDestinationBuilderTest {
+public class DynamicFragmentNavigatorDestinationBuilderTest {
@Suppress("DEPRECATION")
@get:Rule
- val activityRule = androidx.test.rule.ActivityTestRule<TestActivity>(TestActivity::class.java)
- private val fragmentManager get() = activityRule.activity.supportFragmentManager
+ public val rule: ActivityScenarioRule<TestActivity> = ActivityScenarioRule(
+ TestActivity::class.java
+ )
+ private val fragmentManager get() = rule.scenario.withActivity { supportFragmentManager }
@UiThreadTest
- @Test fun reified() {
+ @Test
+ public fun reified() {
val navHostFragment = DynamicNavHostFragment()
fragmentManager.beginTransaction()
.add(android.R.id.content, navHostFragment)
@@ -52,7 +57,8 @@
}
@UiThreadTest
- @Test fun moduleName() {
+ @Test
+ public fun moduleName() {
val navHostFragment = DynamicNavHostFragment()
fragmentManager.beginTransaction()
.add(android.R.id.content, navHostFragment)
@@ -72,7 +78,8 @@
}
@UiThreadTest
- @Test fun no_moduleName() {
+ @Test
+ public fun no_moduleName() {
val navHostFragment = DynamicNavHostFragment()
fragmentManager.beginTransaction()
.add(android.R.id.content, navHostFragment)
@@ -94,5 +101,5 @@
private const val MODULE_NAME = "module"
private const val FRAGMENT_CLASS_NAME = "androidx.navigation.dynamicfeatures.fragment.TestFragment"
-class TestActivity : FragmentActivity()
-class TestFragment : Fragment()
+public class TestActivity : FragmentActivity()
+private class TestFragment : Fragment()
diff --git a/navigation/navigation-dynamic-features-fragment/src/androidTest/java/androidx/navigation/dynamicfeatures/fragment/DynamicNavHostFragmentTest.kt b/navigation/navigation-dynamic-features-fragment/src/androidTest/java/androidx/navigation/dynamicfeatures/fragment/DynamicNavHostFragmentTest.kt
index 59e061f..e1fa686 100644
--- a/navigation/navigation-dynamic-features-fragment/src/androidTest/java/androidx/navigation/dynamicfeatures/fragment/DynamicNavHostFragmentTest.kt
+++ b/navigation/navigation-dynamic-features-fragment/src/androidTest/java/androidx/navigation/dynamicfeatures/fragment/DynamicNavHostFragmentTest.kt
@@ -20,9 +20,11 @@
import androidx.fragment.app.FragmentActivity
import androidx.navigation.dynamicfeatures.fragment.test.R
import androidx.test.core.app.ActivityScenario
+import androidx.test.ext.junit.rules.ActivityScenarioRule
import androidx.test.ext.junit.runners.AndroidJUnit4
import androidx.test.filters.MediumTest
import androidx.testutils.withActivity
+import com.google.android.play.core.splitinstall.SplitInstallManager
import org.junit.Assert.assertEquals
import org.junit.Rule
import org.junit.Test
@@ -30,14 +32,16 @@
@MediumTest
@RunWith(AndroidJUnit4::class)
-class DynamicNavHostFragmentTest {
+public class DynamicNavHostFragmentTest {
@Suppress("DEPRECATION")
@get:Rule
- val activityTestRule = androidx.test.rule.ActivityTestRule(NavigationActivity::class.java)
+ public val activityTestRule: ActivityScenarioRule<NavigationActivity> = ActivityScenarioRule(
+ NavigationActivity::class.java
+ )
@Test
- fun createSplitInstallManager() {
+ public fun createSplitInstallManager() {
val fragment = TestDynamicNavHostFragment()
with(ActivityScenario.launch(NavigationActivity::class.java)) {
withActivity {
@@ -49,15 +53,33 @@
}
assertEquals(fragment.createSplitInstallManager(), fragment.createSplitInstallManager())
}
+
+ @Test
+ public fun create_noArgs() {
+ val fragment = DynamicNavHostFragment.create(R.id.nav_host)
+ assertEquals(fragment.arguments!!.size(), 1)
+ }
+
+ @Test
+ public fun create_withArgs() {
+ val fragment = DynamicNavHostFragment.create(
+ R.id.nav_host,
+ Bundle().apply {
+ putInt("Test", 1)
+ }
+ )
+ assertEquals(fragment.arguments!!.size(), 2)
+ }
}
-class NavigationActivity : FragmentActivity() {
+public class NavigationActivity : FragmentActivity() {
override fun onCreate(savedInstanceState: Bundle?) {
setContentView(R.layout.dynamic_activity_layout)
super.onCreate(savedInstanceState)
}
}
-class TestDynamicNavHostFragment : DynamicNavHostFragment() {
- public override fun createSplitInstallManager() = super.createSplitInstallManager()
+public class TestDynamicNavHostFragment : DynamicNavHostFragment() {
+ public override fun createSplitInstallManager(): SplitInstallManager =
+ super.createSplitInstallManager()
}
diff --git a/navigation/navigation-dynamic-features-fragment/src/main/java/androidx/navigation/dynamicfeatures/fragment/DynamicNavHostFragment.kt b/navigation/navigation-dynamic-features-fragment/src/main/java/androidx/navigation/dynamicfeatures/fragment/DynamicNavHostFragment.kt
index 35b8ac7..b062ef3 100644
--- a/navigation/navigation-dynamic-features-fragment/src/main/java/androidx/navigation/dynamicfeatures/fragment/DynamicNavHostFragment.kt
+++ b/navigation/navigation-dynamic-features-fragment/src/main/java/androidx/navigation/dynamicfeatures/fragment/DynamicNavHostFragment.kt
@@ -16,6 +16,8 @@
package androidx.navigation.dynamicfeatures.fragment
+import android.os.Bundle
+import androidx.annotation.NavigationRes
import androidx.navigation.NavHostController
import androidx.navigation.dynamicfeatures.DynamicActivityNavigator
import androidx.navigation.dynamicfeatures.DynamicGraphNavigator
@@ -69,4 +71,35 @@
*/
protected open fun createSplitInstallManager(): SplitInstallManager =
SplitInstallManagerFactory.create(requireContext())
+
+ /** Companion object for DynamicNavHostFragment */
+ public companion object {
+
+ /**
+ * Create a new [DynamicNavHostFragment] instance with an inflated {@link NavGraph} resource.
+ *
+ * @param graphResId Resource id of the navigation graph to inflate.
+ * @param startDestinationArgs Arguments to send to the start destination of the graph.
+ * @return A new DynamicNavHostFragment instance.
+ */
+ @JvmStatic
+ @JvmOverloads
+ public fun create(
+ @NavigationRes graphResId: Int,
+ startDestinationArgs: Bundle? = null
+ ): DynamicNavHostFragment {
+ return DynamicNavHostFragment().apply {
+ arguments = if (graphResId != 0 || startDestinationArgs != null) {
+ Bundle().apply {
+ if (graphResId != 0) {
+ putInt(KEY_GRAPH_ID, graphResId)
+ }
+ if (startDestinationArgs != null) {
+ putBundle(KEY_START_DESTINATION_ARGS, startDestinationArgs)
+ }
+ }
+ } else null
+ }
+ }
+ }
}
diff --git a/navigation/navigation-fragment/src/main/java/androidx/navigation/fragment/NavHostFragment.java b/navigation/navigation-fragment/src/main/java/androidx/navigation/fragment/NavHostFragment.java
index 2d0bbea..e76bed7 100644
--- a/navigation/navigation-fragment/src/main/java/androidx/navigation/fragment/NavHostFragment.java
+++ b/navigation/navigation-fragment/src/main/java/androidx/navigation/fragment/NavHostFragment.java
@@ -31,6 +31,7 @@
import androidx.annotation.NavigationRes;
import androidx.annotation.NonNull;
import androidx.annotation.Nullable;
+import androidx.annotation.RestrictTo;
import androidx.fragment.app.DialogFragment;
import androidx.fragment.app.Fragment;
import androidx.fragment.app.FragmentContainerView;
@@ -80,8 +81,12 @@
* coupling to the navigation host.</p>
*/
public class NavHostFragment extends Fragment implements NavHost {
- private static final String KEY_GRAPH_ID = "android-support-nav:fragment:graphId";
- private static final String KEY_START_DESTINATION_ARGS =
+ /** @hide */
+ @RestrictTo(RestrictTo.Scope.LIBRARY_GROUP)
+ protected static final String KEY_GRAPH_ID = "android-support-nav:fragment:graphId";
+ /** @hide */
+ @RestrictTo(RestrictTo.Scope.LIBRARY_GROUP)
+ protected static final String KEY_START_DESTINATION_ARGS =
"android-support-nav:fragment:startDestinationArgs";
private static final String KEY_NAV_CONTROLLER_STATE =
"android-support-nav:fragment:navControllerState";
@@ -156,9 +161,9 @@
/**
* Create a new NavHostFragment instance with an inflated {@link NavGraph} resource.
*
- * @param graphResId resource id of the navigation graph to inflate
- * @param startDestinationArgs arguments to send to the start destination of the graph
- * @return a new NavHostFragment instance
+ * @param graphResId Resource id of the navigation graph to inflate.
+ * @param startDestinationArgs Arguments to send to the start destination of the graph.
+ * @return A new NavHostFragment instance.
*/
@NonNull
public static NavHostFragment create(@NavigationRes int graphResId,
diff --git a/percentlayout/percentlayout/src/androidTest/java/androidx/percentlayout/widget/BaseInstrumentationTestCase.java b/percentlayout/percentlayout/src/androidTest/java/androidx/percentlayout/widget/BaseInstrumentationTestCase.java
index f89a8f1..9cdcd79 100644
--- a/percentlayout/percentlayout/src/androidTest/java/androidx/percentlayout/widget/BaseInstrumentationTestCase.java
+++ b/percentlayout/percentlayout/src/androidTest/java/androidx/percentlayout/widget/BaseInstrumentationTestCase.java
@@ -21,18 +21,19 @@
import android.app.Activity;
import androidx.test.ext.junit.runners.AndroidJUnit4;
-import androidx.test.rule.ActivityTestRule;
import org.junit.Rule;
import org.junit.runner.RunWith;
@RunWith(AndroidJUnit4.class)
public abstract class BaseInstrumentationTestCase<A extends Activity> {
+ @SuppressWarnings("deprecation")
@Rule
- public final ActivityTestRule<A> mActivityTestRule;
+ public final androidx.test.rule.ActivityTestRule<A> mActivityTestRule;
+ @SuppressWarnings("deprecation")
protected BaseInstrumentationTestCase(Class<A> activityClass) {
- mActivityTestRule = new ActivityTestRule<A>(activityClass);
+ mActivityTestRule = new androidx.test.rule.ActivityTestRule<A>(activityClass);
}
protected static void assertFuzzyEquals(String description, float expected, float actual) {
diff --git a/percentlayout/percentlayout/src/androidTest/java/androidx/percentlayout/widget/PercentDynamicLayoutTest.java b/percentlayout/percentlayout/src/androidTest/java/androidx/percentlayout/widget/PercentDynamicLayoutTest.java
index ca4efd3..2e38fb8 100755
--- a/percentlayout/percentlayout/src/androidTest/java/androidx/percentlayout/widget/PercentDynamicLayoutTest.java
+++ b/percentlayout/percentlayout/src/androidTest/java/androidx/percentlayout/widget/PercentDynamicLayoutTest.java
@@ -41,6 +41,7 @@
/**
* Test cases to verify that percent layouts properly account for their own paddings.
*/
+@SuppressWarnings("deprecation")
@LargeTest
public class PercentDynamicLayoutTest
extends BaseInstrumentationTestCase<PercentDynamicLayoutActivity> {
diff --git a/percentlayout/percentlayout/src/androidTest/java/androidx/percentlayout/widget/PercentFrameTest.java b/percentlayout/percentlayout/src/androidTest/java/androidx/percentlayout/widget/PercentFrameTest.java
index c88e063..f4bf9ee 100644
--- a/percentlayout/percentlayout/src/androidTest/java/androidx/percentlayout/widget/PercentFrameTest.java
+++ b/percentlayout/percentlayout/src/androidTest/java/androidx/percentlayout/widget/PercentFrameTest.java
@@ -28,6 +28,7 @@
import org.junit.Before;
import org.junit.Test;
+@SuppressWarnings("deprecation")
@LargeTest
public class PercentFrameTest extends BaseInstrumentationTestCase<TestFrameActivity> {
private PercentFrameLayout mPercentFrameLayout;
diff --git a/percentlayout/percentlayout/src/androidTest/java/androidx/percentlayout/widget/PercentRelativeRtlTest.java b/percentlayout/percentlayout/src/androidTest/java/androidx/percentlayout/widget/PercentRelativeRtlTest.java
index bc51a0c..640be5b 100644
--- a/percentlayout/percentlayout/src/androidTest/java/androidx/percentlayout/widget/PercentRelativeRtlTest.java
+++ b/percentlayout/percentlayout/src/androidTest/java/androidx/percentlayout/widget/PercentRelativeRtlTest.java
@@ -94,6 +94,7 @@
* the core classes, but rather just provide a translation layer between percentage-based values
* and pixel-based ones.
*/
+@SuppressWarnings("deprecation")
@LargeTest
public class PercentRelativeRtlTest extends BaseInstrumentationTestCase<TestRelativeRtlActivity> {
private PercentRelativeLayout mPercentRelativeLayout;
diff --git a/percentlayout/percentlayout/src/androidTest/java/androidx/percentlayout/widget/PercentRelativeTest.java b/percentlayout/percentlayout/src/androidTest/java/androidx/percentlayout/widget/PercentRelativeTest.java
index b821678..ffbf0dbb 100644
--- a/percentlayout/percentlayout/src/androidTest/java/androidx/percentlayout/widget/PercentRelativeTest.java
+++ b/percentlayout/percentlayout/src/androidTest/java/androidx/percentlayout/widget/PercentRelativeTest.java
@@ -55,6 +55,7 @@
* <li>Center child (marked with C) - margin (all sides) from the other four children.</li>
* </ul>
*/
+@SuppressWarnings("deprecation")
@LargeTest
public class PercentRelativeTest extends BaseInstrumentationTestCase<TestRelativeActivity> {
private PercentRelativeLayout mPercentRelativeLayout;
diff --git a/preference/preference/src/androidTest/java/androidx/preference/tests/EditTextPreferenceTest.java b/preference/preference/src/androidTest/java/androidx/preference/tests/EditTextPreferenceTest.java
index 9091896..4f2d7f0 100644
--- a/preference/preference/src/androidTest/java/androidx/preference/tests/EditTextPreferenceTest.java
+++ b/preference/preference/src/androidTest/java/androidx/preference/tests/EditTextPreferenceTest.java
@@ -38,7 +38,6 @@
import androidx.test.annotation.UiThreadTest;
import androidx.test.ext.junit.runners.AndroidJUnit4;
import androidx.test.filters.LargeTest;
-import androidx.test.rule.ActivityTestRule;
import org.junit.Before;
import org.junit.Rule;
@@ -52,9 +51,10 @@
@RunWith(AndroidJUnit4.class)
public class EditTextPreferenceTest {
+ @SuppressWarnings("deprecation")
@Rule
- public ActivityTestRule<PreferenceTestHelperActivity> mActivityRule =
- new ActivityTestRule<>(PreferenceTestHelperActivity.class);
+ public androidx.test.rule.ActivityTestRule<PreferenceTestHelperActivity> mActivityRule =
+ new androidx.test.rule.ActivityTestRule<>(PreferenceTestHelperActivity.class);
private static final String PREFERENCE = "preference";
diff --git a/preference/preference/src/androidTest/java/androidx/preference/tests/ListPreferenceSummaryTest.java b/preference/preference/src/androidTest/java/androidx/preference/tests/ListPreferenceSummaryTest.java
index 6fae995..0f5dd8f 100644
--- a/preference/preference/src/androidTest/java/androidx/preference/tests/ListPreferenceSummaryTest.java
+++ b/preference/preference/src/androidTest/java/androidx/preference/tests/ListPreferenceSummaryTest.java
@@ -69,6 +69,7 @@
assertTrue(preference.getSummary() instanceof String);
}
+ @SuppressWarnings("deprecation")
@Test
@UiThreadTest
public void styledSummary() {
diff --git a/preference/preference/src/androidTest/java/androidx/preference/tests/PreferenceComparisonCallbackTest.java b/preference/preference/src/androidTest/java/androidx/preference/tests/PreferenceComparisonCallbackTest.java
index 31a12b4..f36c692 100644
--- a/preference/preference/src/androidTest/java/androidx/preference/tests/PreferenceComparisonCallbackTest.java
+++ b/preference/preference/src/androidTest/java/androidx/preference/tests/PreferenceComparisonCallbackTest.java
@@ -260,6 +260,7 @@
mComparisonCallback.arePreferenceContentsTheSame(dropdown1, dropdown2));
}
+ @SuppressWarnings("deprecation")
private static class ComparisonDrawable extends Drawable {
private final int mId;
diff --git a/preference/preference/src/androidTest/java/androidx/preference/tests/PreferenceCopyingTest.java b/preference/preference/src/androidTest/java/androidx/preference/tests/PreferenceCopyingTest.java
index d72d608..a8cb723 100644
--- a/preference/preference/src/androidTest/java/androidx/preference/tests/PreferenceCopyingTest.java
+++ b/preference/preference/src/androidTest/java/androidx/preference/tests/PreferenceCopyingTest.java
@@ -41,7 +41,6 @@
import androidx.test.annotation.UiThreadTest;
import androidx.test.ext.junit.runners.AndroidJUnit4;
import androidx.test.filters.LargeTest;
-import androidx.test.rule.ActivityTestRule;
import org.junit.Before;
import org.junit.Rule;
@@ -55,9 +54,10 @@
@RunWith(AndroidJUnit4.class)
public class PreferenceCopyingTest {
+ @SuppressWarnings("deprecation")
@Rule
- public ActivityTestRule<PreferenceTestHelperActivity> mActivityRule =
- new ActivityTestRule<>(PreferenceTestHelperActivity.class);
+ public androidx.test.rule.ActivityTestRule<PreferenceTestHelperActivity> mActivityRule =
+ new androidx.test.rule.ActivityTestRule<>(PreferenceTestHelperActivity.class);
private static final String COPY_BUTTON = "Copy";
private static final String PREFERENCE_1 = "Preference 1";
diff --git a/preference/preference/src/androidTest/java/androidx/preference/tests/PreferenceDataStoreTest.java b/preference/preference/src/androidTest/java/androidx/preference/tests/PreferenceDataStoreTest.java
index 9ea37b6..17f8d75 100644
--- a/preference/preference/src/androidTest/java/androidx/preference/tests/PreferenceDataStoreTest.java
+++ b/preference/preference/src/androidTest/java/androidx/preference/tests/PreferenceDataStoreTest.java
@@ -404,6 +404,7 @@
putStringSetTestCommon();
}
+ @SuppressWarnings({"deprecation", "unchecked"})
private void putStringSetTestCommon() {
Set<String> testSet = Collections.singleton(TEST_STR);
diff --git a/preference/preference/src/androidTest/java/androidx/preference/tests/PreferenceVisibilityTest.java b/preference/preference/src/androidTest/java/androidx/preference/tests/PreferenceVisibilityTest.java
index f96d68c..d8869b7 100644
--- a/preference/preference/src/androidTest/java/androidx/preference/tests/PreferenceVisibilityTest.java
+++ b/preference/preference/src/androidTest/java/androidx/preference/tests/PreferenceVisibilityTest.java
@@ -41,7 +41,6 @@
import androidx.test.ext.junit.runners.AndroidJUnit4;
import androidx.test.filters.LargeTest;
import androidx.test.platform.app.InstrumentationRegistry;
-import androidx.test.rule.ActivityTestRule;
import org.junit.Before;
import org.junit.Rule;
@@ -57,9 +56,10 @@
@RunWith(AndroidJUnit4.class)
public class PreferenceVisibilityTest {
+ @SuppressWarnings("deprecation")
@Rule
- public ActivityTestRule<PreferenceTestHelperActivity> mActivityRule =
- new ActivityTestRule<>(PreferenceTestHelperActivity.class);
+ public androidx.test.rule.ActivityTestRule<PreferenceTestHelperActivity> mActivityRule =
+ new androidx.test.rule.ActivityTestRule<>(PreferenceTestHelperActivity.class);
private static final String CATEGORY = "Category";
private static final String DEFAULT = "Default";
diff --git a/recyclerview/recyclerview-selection/src/androidTest/java/androidx/recyclerview/selection/DefaultSelectionTrackerTest.java b/recyclerview/recyclerview-selection/src/androidTest/java/androidx/recyclerview/selection/DefaultSelectionTrackerTest.java
index 85efcd3..7d90015 100644
--- a/recyclerview/recyclerview-selection/src/androidTest/java/androidx/recyclerview/selection/DefaultSelectionTrackerTest.java
+++ b/recyclerview/recyclerview-selection/src/androidTest/java/androidx/recyclerview/selection/DefaultSelectionTrackerTest.java
@@ -16,8 +16,7 @@
package androidx.recyclerview.selection;
-import static junit.framework.Assert.assertEquals;
-
+import static org.junit.Assert.assertEquals;
import static org.junit.Assert.assertFalse;
import static org.junit.Assert.assertTrue;
diff --git a/recyclerview/recyclerview-selection/src/androidTest/java/androidx/recyclerview/selection/GridModelTest.java b/recyclerview/recyclerview-selection/src/androidTest/java/androidx/recyclerview/selection/GridModelTest.java
index 7a6e171..249463c 100644
--- a/recyclerview/recyclerview-selection/src/androidTest/java/androidx/recyclerview/selection/GridModelTest.java
+++ b/recyclerview/recyclerview-selection/src/androidTest/java/androidx/recyclerview/selection/GridModelTest.java
@@ -219,6 +219,7 @@
assertEquals(0, mModel.getPositionNearestOrigin());
}
+ @SuppressWarnings("unchecked")
private void initData(final int numChildren, int numColumns) {
mHost = new TestHost(numChildren, numColumns);
mAdapter = new TestAdapter() {
diff --git a/recyclerview/recyclerview-selection/src/androidTest/java/androidx/recyclerview/selection/MouseInputHandlerTest.java b/recyclerview/recyclerview-selection/src/androidTest/java/androidx/recyclerview/selection/MouseInputHandlerTest.java
index 425bcc6..11211d4 100644
--- a/recyclerview/recyclerview-selection/src/androidTest/java/androidx/recyclerview/selection/MouseInputHandlerTest.java
+++ b/recyclerview/recyclerview-selection/src/androidTest/java/androidx/recyclerview/selection/MouseInputHandlerTest.java
@@ -71,14 +71,14 @@
mSelection = new SelectionProbe(mSelectionMgr);
mMouseCallbacks = new TestOnContextClickListener();
- mActivationCallbacks = new TestOnItemActivatedListener();
- mFocusCallbacks = new TestFocusDelegate();
+ mActivationCallbacks = new TestOnItemActivatedListener<>();
+ mFocusCallbacks = new TestFocusDelegate<>();
- mInputDelegate = new MouseInputHandler(
+ mInputDelegate = new MouseInputHandler<>(
mSelectionMgr,
- new TestItemKeyProvider(
+ new TestItemKeyProvider<>(
ItemKeyProvider.SCOPE_MAPPED,
- new TestAdapter(TestData.createStringData(100))),
+ new TestAdapter<>(TestData.createStringData(100))),
mDetailsLookup,
mMouseCallbacks,
mActivationCallbacks,
diff --git a/recyclerview/recyclerview-selection/src/androidTest/java/androidx/recyclerview/selection/MouseInputHandler_RangeTest.java b/recyclerview/recyclerview-selection/src/androidTest/java/androidx/recyclerview/selection/MouseInputHandler_RangeTest.java
index 825d45f..a3c50e2 100644
--- a/recyclerview/recyclerview-selection/src/androidTest/java/androidx/recyclerview/selection/MouseInputHandler_RangeTest.java
+++ b/recyclerview/recyclerview-selection/src/androidTest/java/androidx/recyclerview/selection/MouseInputHandler_RangeTest.java
@@ -50,6 +50,7 @@
private TestFocusDelegate<String> mFocusCallbacks;
private TestItemDetailsLookup mDetailsLookup;
+ @SuppressWarnings("unchecked")
@Before
public void setUp() {
SelectionTracker<String> selectionMgr =
@@ -64,9 +65,9 @@
mInputDelegate = new MouseInputHandler<>(
selectionMgr,
- new TestItemKeyProvider(
+ new TestItemKeyProvider<>(
ItemKeyProvider.SCOPE_MAPPED,
- new TestAdapter(TestData.createStringData(100))),
+ new TestAdapter<>(TestData.createStringData(100))),
mDetailsLookup,
mouseCallbacks,
activationCallbacks,
diff --git a/recyclerview/recyclerview-selection/src/androidTest/java/androidx/recyclerview/selection/SelectionTest.java b/recyclerview/recyclerview-selection/src/androidTest/java/androidx/recyclerview/selection/SelectionTest.java
index fa37577..a9a8b75 100644
--- a/recyclerview/recyclerview-selection/src/androidTest/java/androidx/recyclerview/selection/SelectionTest.java
+++ b/recyclerview/recyclerview-selection/src/androidTest/java/androidx/recyclerview/selection/SelectionTest.java
@@ -191,6 +191,7 @@
assertTrue(err, mSelection.contains(id));
}
+ @SuppressWarnings("unchecked")
public static <E> Set<E> newSet(E... elements) {
HashSet<E> set = new HashSet<>(elements.length);
Collections.addAll(set, elements);
diff --git a/recyclerview/recyclerview-selection/src/androidTest/java/androidx/recyclerview/selection/StableIdKeyProviderTest.java b/recyclerview/recyclerview-selection/src/androidTest/java/androidx/recyclerview/selection/StableIdKeyProviderTest.java
index 92089428..5d218e7 100644
--- a/recyclerview/recyclerview-selection/src/androidTest/java/androidx/recyclerview/selection/StableIdKeyProviderTest.java
+++ b/recyclerview/recyclerview-selection/src/androidTest/java/androidx/recyclerview/selection/StableIdKeyProviderTest.java
@@ -160,6 +160,7 @@
}
private static final class StableIdTestAdapter extends TestAdapter<Long> {
+ @SuppressWarnings("unchecked")
StableIdTestAdapter() {
super(Collections.EMPTY_LIST, true);
}
diff --git a/recyclerview/recyclerview/build.gradle b/recyclerview/recyclerview/build.gradle
index a44f788..4e67cdc 100644
--- a/recyclerview/recyclerview/build.gradle
+++ b/recyclerview/recyclerview/build.gradle
@@ -60,4 +60,5 @@
mavenGroup = LibraryGroups.RECYCLERVIEW
inceptionYear = "2014"
description = "Android Support RecyclerView"
+ failOnDeprecationWarnings = false
}
diff --git a/recyclerview/recyclerview/src/androidTest/java/androidx/recyclerview/widget/ItemAnimatorTestDouble.java b/recyclerview/recyclerview/src/androidTest/java/androidx/recyclerview/widget/ItemAnimatorTestDouble.java
index 4d9a546..03cd284 100644
--- a/recyclerview/recyclerview/src/androidTest/java/androidx/recyclerview/widget/ItemAnimatorTestDouble.java
+++ b/recyclerview/recyclerview/src/androidTest/java/androidx/recyclerview/widget/ItemAnimatorTestDouble.java
@@ -44,11 +44,11 @@
static final long TIMEOUT_SECOND = 10;
- ArrayList<RecyclerView.ViewHolder> mAdds = new ArrayList();
- ArrayList<RecyclerView.ViewHolder> mRemoves = new ArrayList();
- ArrayList<RecyclerView.ViewHolder> mMoves = new ArrayList();
- ArrayList<RecyclerView.ViewHolder> mChangesOld = new ArrayList();
- ArrayList<RecyclerView.ViewHolder> mChangesNew = new ArrayList();
+ ArrayList<RecyclerView.ViewHolder> mAdds = new ArrayList<>();
+ ArrayList<RecyclerView.ViewHolder> mRemoves = new ArrayList<>();
+ ArrayList<RecyclerView.ViewHolder> mMoves = new ArrayList<>();
+ ArrayList<RecyclerView.ViewHolder> mChangesOld = new ArrayList<>();
+ ArrayList<RecyclerView.ViewHolder> mChangesNew = new ArrayList<>();
@Retention(CLASS)
@Target({PARAMETER, METHOD, LOCAL_VARIABLE, FIELD})
diff --git a/recyclerview/recyclerview/src/androidTest/java/androidx/recyclerview/widget/RecyclerViewAccessibilityLifecycleTest.java b/recyclerview/recyclerview/src/androidTest/java/androidx/recyclerview/widget/RecyclerViewAccessibilityLifecycleTest.java
index c9c0be9..9000986 100644
--- a/recyclerview/recyclerview/src/androidTest/java/androidx/recyclerview/widget/RecyclerViewAccessibilityLifecycleTest.java
+++ b/recyclerview/recyclerview/src/androidTest/java/androidx/recyclerview/widget/RecyclerViewAccessibilityLifecycleTest.java
@@ -217,7 +217,7 @@
layoutManager.waitForLayout(1);
assertEquals(layoutCount, recyclerView.getChildCount());
- final ArrayList<View> children = new ArrayList();
+ final ArrayList<View> children = new ArrayList<>();
mActivityRule.runOnUiThread(new Runnable() {
@Override
public void run() {
@@ -306,7 +306,7 @@
// let all items go to recycler pool
layoutManager.expectLayouts(1);
layoutCount[0] = 0;
- adapter.resetItemsTo(new ArrayList());
+ adapter.resetItemsTo(new ArrayList<Item>());
layoutManager.waitForLayout(1);
assertEquals(0, recyclerView.getChildCount());
assertEquals(firstPassLayoutCount, recyclerView.getRecycledViewPool()
diff --git a/recyclerview/recyclerview/src/androidTest/java/androidx/recyclerview/widget/RecyclerViewBasicTest.java b/recyclerview/recyclerview/src/androidTest/java/androidx/recyclerview/widget/RecyclerViewBasicTest.java
index 3e11b02..a736765 100644
--- a/recyclerview/recyclerview/src/androidTest/java/androidx/recyclerview/widget/RecyclerViewBasicTest.java
+++ b/recyclerview/recyclerview/src/androidTest/java/androidx/recyclerview/widget/RecyclerViewBasicTest.java
@@ -58,6 +58,7 @@
import java.util.List;
import java.util.UUID;
+@SuppressWarnings("unchecked")
@SmallTest
@RunWith(AndroidJUnit4.class)
public class RecyclerViewBasicTest {
diff --git a/recyclerview/recyclerview/src/androidTest/java/androidx/recyclerview/widget/RecyclerViewCacheTest.java b/recyclerview/recyclerview/src/androidTest/java/androidx/recyclerview/widget/RecyclerViewCacheTest.java
index 330f659..0aa4e29 100644
--- a/recyclerview/recyclerview/src/androidTest/java/androidx/recyclerview/widget/RecyclerViewCacheTest.java
+++ b/recyclerview/recyclerview/src/androidTest/java/androidx/recyclerview/widget/RecyclerViewCacheTest.java
@@ -61,6 +61,7 @@
import java.util.List;
import java.util.concurrent.TimeUnit;
+@SuppressWarnings("unchecked")
@MediumTest
@SdkSuppress(minSdkVersion = Build.VERSION_CODES.LOLLIPOP)
@RunWith(AndroidJUnit4.class)
diff --git a/room/compiler-processing/src/main/java/androidx/room/compiler/processing/XElement.kt b/room/compiler-processing/src/main/java/androidx/room/compiler/processing/XElement.kt
index b18909e..77fc091 100644
--- a/room/compiler-processing/src/main/java/androidx/room/compiler/processing/XElement.kt
+++ b/room/compiler-processing/src/main/java/androidx/room/compiler/processing/XElement.kt
@@ -31,46 +31,21 @@
* Returns the string representation of the Element's kind.
*/
fun kindName(): String
-
- /**
- * Casts current element to [XTypeElement].
- */
- fun asTypeElement() = this as XTypeElement
-
- /**
- * Casts current element to [XVariableElement].
- */
- fun asVariableElement() = this as XVariableElement
-
- /**
- * Casts current element to [XMethodElement].
- */
- fun asMethodElement() = this as XMethodElement
-
- /**
- * Returns the [XDeclaredType] type of the current element, assuming it is an [XTypeElement].
- * It is a shortcut for `asTypeElement().type`.
- */
- fun asDeclaredType(): XDeclaredType {
- return asTypeElement().type
- }
}
/**
* Checks whether this element represents an [XTypeElement].
- * @see [XElement.asTypeElement]
*/
// we keep these as extension methods to be able to use contracts
-fun XElement.isType(): Boolean {
+fun XElement.isTypeElement(): Boolean {
contract {
- returns(true) implies (this@isType is XTypeElement)
+ returns(true) implies (this@isTypeElement is XTypeElement)
}
return this is XTypeElement
}
/**
* Checks whether this element represents an [XVariableElement].
- * @see [XElement.asVariableElement]
*/
fun XElement.isVariableElement(): Boolean {
contract {
@@ -81,7 +56,6 @@
/**
* Checks whether this element represents an [XMethodElement].
- * @see [XElement.asMethodElement]
*/
fun XElement.isMethod(): Boolean {
contract {
diff --git a/room/compiler-processing/src/main/java/androidx/room/compiler/processing/XType.kt b/room/compiler-processing/src/main/java/androidx/room/compiler/processing/XType.kt
index 1653b4a..d03e5f8 100644
--- a/room/compiler-processing/src/main/java/androidx/room/compiler/processing/XType.kt
+++ b/room/compiler-processing/src/main/java/androidx/room/compiler/processing/XType.kt
@@ -48,7 +48,7 @@
/**
* Casts the current type to [XTypeElement].
*
- * @see isType
+ * @see isTypeElement
*/
fun asTypeElement(): XTypeElement
diff --git a/room/compiler-processing/src/test/java/androidx/room/compiler/processing/XElementTest.kt b/room/compiler-processing/src/test/java/androidx/room/compiler/processing/XElementTest.kt
index 84623ee..ef5faf8 100644
--- a/room/compiler-processing/src/test/java/androidx/room/compiler/processing/XElementTest.kt
+++ b/room/compiler-processing/src/test/java/androidx/room/compiler/processing/XElementTest.kt
@@ -290,15 +290,15 @@
val element = it.processingEnv.requireTypeElement("foo.bar.Baz")
assertThat(element.isInterface()).isFalse()
assertThat(element.isAbstract()).isFalse()
- assertThat(element.isType()).isTrue()
+ assertThat(element.isTypeElement()).isTrue()
element.getField("field").let { field ->
- assertThat(field.isType()).isFalse()
+ assertThat(field.isTypeElement()).isFalse()
assertThat(field.isAbstract()).isFalse()
assertThat(field.isVariableElement()).isTrue()
assertThat(field.isMethod()).isFalse()
}
element.getMethod("method").let { method ->
- assertThat(method.isType()).isFalse()
+ assertThat(method.isTypeElement()).isFalse()
assertThat(method.isAbstract()).isFalse()
assertThat(method.isVariableElement()).isFalse()
assertThat(method.isMethod()).isTrue()
@@ -323,10 +323,7 @@
val element = it.processingEnv.requireTypeElement("foo.bar.Baz")
element.getField("x").let { field ->
assertThat(field.isStatic()).isTrue()
- val fail = runCatching {
- field.asTypeElement()
- }
- assertThat(fail.exceptionOrNull()).isNotNull()
+ assertThat(field.isTypeElement()).isFalse()
}
}
}
diff --git a/room/compiler-processing/src/test/java/androidx/room/compiler/processing/XProcessingEnvTest.kt b/room/compiler-processing/src/test/java/androidx/room/compiler/processing/XProcessingEnvTest.kt
index 2f92301..517f14c 100644
--- a/room/compiler-processing/src/test/java/androidx/room/compiler/processing/XProcessingEnvTest.kt
+++ b/room/compiler-processing/src/test/java/androidx/room/compiler/processing/XProcessingEnvTest.kt
@@ -116,7 +116,7 @@
val element = it.processingEnv.requireTypeElement("foo.bar.Baz")
assertThat(element.packageName).isEqualTo("foo.bar")
assertThat(element.name).isEqualTo("Baz")
- assertThat(element.asDeclaredType().typeName)
+ assertThat(element.className)
.isEqualTo(ClassName.get("foo.bar", "Baz"))
assertThat(element.findPrimaryConstructor()).isNull()
assertThat(element.getConstructors()).hasSize(1)
diff --git a/room/compiler/src/main/kotlin/androidx/room/DatabaseProcessingStep.kt b/room/compiler/src/main/kotlin/androidx/room/DatabaseProcessingStep.kt
index 7ed2149d..d3ee871 100644
--- a/room/compiler/src/main/kotlin/androidx/room/DatabaseProcessingStep.kt
+++ b/room/compiler/src/main/kotlin/androidx/room/DatabaseProcessingStep.kt
@@ -42,7 +42,7 @@
try {
DatabaseProcessor(
context,
- it.asTypeElement()
+ it
).process()
} catch (ex: MissingTypeException) {
// Abandon processing this database class since it needed a type element
diff --git a/room/compiler/src/main/kotlin/androidx/room/processor/CustomConverterProcessor.kt b/room/compiler/src/main/kotlin/androidx/room/processor/CustomConverterProcessor.kt
index d8a4bc2..b7b237c 100644
--- a/room/compiler/src/main/kotlin/androidx/room/processor/CustomConverterProcessor.kt
+++ b/room/compiler/src/main/kotlin/androidx/room/processor/CustomConverterProcessor.kt
@@ -75,12 +75,10 @@
fun process(): List<CustomTypeConverter> {
// using element utils instead of MoreElements to include statics.
val methods = element.getAllMethods()
- val declaredType = element.asDeclaredType()
val converterMethods = methods.filter {
it.hasAnnotation(TypeConverter::class)
}
- val isProvidedConverter = declaredType.asTypeElement()
- .hasAnnotation(ProvidedTypeConverter::class)
+ val isProvidedConverter = element.hasAnnotation(ProvidedTypeConverter::class)
context.checker.check(converterMethods.isNotEmpty(), element, TYPE_CONVERTER_EMPTY_CLASS)
val allStatic = converterMethods.all { it.isStatic() }
val constructors = element.getConstructors()
@@ -96,7 +94,7 @@
}
return converterMethods.mapNotNull {
processMethod(
- container = declaredType,
+ container = element.type,
isContainerKotlinObject = isKotlinObjectDeclaration,
methodElement = it,
isProvidedConverter = isProvidedConverter
diff --git a/room/compiler/src/main/kotlin/androidx/room/processor/DaoProcessor.kt b/room/compiler/src/main/kotlin/androidx/room/processor/DaoProcessor.kt
index d6769c1..3eacaa3 100644
--- a/room/compiler/src/main/kotlin/androidx/room/processor/DaoProcessor.kt
+++ b/room/compiler/src/main/kotlin/androidx/room/processor/DaoProcessor.kt
@@ -57,7 +57,7 @@
element, ProcessorErrors.DAO_MUST_BE_AN_ABSTRACT_CLASS_OR_AN_INTERFACE
)
- val declaredType = element.asDeclaredType()
+ val declaredType = element.type
val allMethods = element.getAllMethods()
val methods = allMethods
.filter {
diff --git a/room/compiler/src/main/kotlin/androidx/room/processor/DatabaseProcessor.kt b/room/compiler/src/main/kotlin/androidx/room/processor/DatabaseProcessor.kt
index cacbfba..c8f13ab 100644
--- a/room/compiler/src/main/kotlin/androidx/room/processor/DatabaseProcessor.kt
+++ b/room/compiler/src/main/kotlin/androidx/room/processor/DatabaseProcessor.kt
@@ -17,12 +17,11 @@
package androidx.room.processor
import androidx.room.SkipQueryVerification
-import androidx.room.ext.RoomTypeNames
import androidx.room.compiler.processing.XAnnotationBox
import androidx.room.compiler.processing.XElement
import androidx.room.compiler.processing.XType
import androidx.room.compiler.processing.XTypeElement
-import androidx.room.compiler.processing.isType
+import androidx.room.ext.RoomTypeNames
import androidx.room.verifier.DatabaseVerificationErrors
import androidx.room.verifier.DatabaseVerifier
import androidx.room.vo.Dao
@@ -77,16 +76,13 @@
}
validateUniqueTableAndViewNames(element, entities, views)
- val declaredType = element.asDeclaredType()
+ val declaredType = element.type
val daoMethods = element.getAllMethods().filter {
it.isAbstract()
}.filterNot {
// remove methods that belong to room
- val containing = it.enclosingTypeElement
- containing.isType() &&
- containing.asDeclaredType().typeName == RoomTypeNames.ROOM_DB
- }.map {
- val executable = it.asMethodElement()
+ it.enclosingTypeElement.className == RoomTypeNames.ROOM_DB
+ }.map { executable ->
// TODO when we add support for non Dao return types (e.g. database), this code needs
// to change
val daoType = executable.returnType.asTypeElement()
diff --git a/room/compiler/src/main/kotlin/androidx/room/processor/PojoProcessor.kt b/room/compiler/src/main/kotlin/androidx/room/processor/PojoProcessor.kt
index 24b38ec..d56d3ce 100644
--- a/room/compiler/src/main/kotlin/androidx/room/processor/PojoProcessor.kt
+++ b/room/compiler/src/main/kotlin/androidx/room/processor/PojoProcessor.kt
@@ -115,7 +115,7 @@
private fun doProcess(): Pojo {
delegate.onPreProcess(element)
- val declaredType = element.asDeclaredType()
+ val declaredType = element.type
// TODO handle conflicts with super: b/35568142
val allFields = element.getAllFieldsIncludingPrivateSupers()
.filter {
diff --git a/room/compiler/src/main/kotlin/androidx/room/processor/autovalue/AutoValuePojoProcessorDelegate.kt b/room/compiler/src/main/kotlin/androidx/room/processor/autovalue/AutoValuePojoProcessorDelegate.kt
index 6fc4899..15ad354 100644
--- a/room/compiler/src/main/kotlin/androidx/room/processor/autovalue/AutoValuePojoProcessorDelegate.kt
+++ b/room/compiler/src/main/kotlin/androidx/room/processor/autovalue/AutoValuePojoProcessorDelegate.kt
@@ -20,7 +20,6 @@
import androidx.room.compiler.processing.XDeclaredType
import androidx.room.compiler.processing.XExecutableElement
import androidx.room.compiler.processing.XTypeElement
-import androidx.room.compiler.processing.isType
import androidx.room.processor.Context
import androidx.room.processor.PojoProcessor
import androidx.room.processor.PojoProcessor.Companion.TARGET_METHOD_ANNOTATIONS
@@ -41,7 +40,7 @@
) : PojoProcessor.Delegate {
private val autoValueDeclaredType: XDeclaredType by lazy {
- autoValueElement.asDeclaredType()
+ autoValueElement.type
}
override fun onPreProcess(element: XTypeElement) {
@@ -110,8 +109,8 @@
fun getGeneratedClassName(element: XTypeElement): String {
var type = element
var name = type.name
- while (type.enclosingTypeElement?.isType() == true) {
- type = type.enclosingTypeElement!!.asTypeElement()
+ while (type.enclosingTypeElement != null) {
+ type = type.enclosingTypeElement!!
name = "${type.name}_$name"
}
val pkg = type.packageName
diff --git a/room/compiler/src/main/kotlin/androidx/room/solver/TypeAdapterStore.kt b/room/compiler/src/main/kotlin/androidx/room/solver/TypeAdapterStore.kt
index 4196bae..22caffd 100644
--- a/room/compiler/src/main/kotlin/androidx/room/solver/TypeAdapterStore.kt
+++ b/room/compiler/src/main/kotlin/androidx/room/solver/TypeAdapterStore.kt
@@ -515,7 +515,7 @@
return EntityRowAdapter(
EntityProcessor(
context = context,
- element = asElement.asTypeElement()
+ element = asElement
).process()
)
}
diff --git a/room/compiler/src/main/kotlin/androidx/room/vo/Constructor.kt b/room/compiler/src/main/kotlin/androidx/room/vo/Constructor.kt
index 338892d..6adaa3c 100644
--- a/room/compiler/src/main/kotlin/androidx/room/vo/Constructor.kt
+++ b/room/compiler/src/main/kotlin/androidx/room/vo/Constructor.kt
@@ -45,13 +45,13 @@
element.isConstructor() -> {
builder.addStatement(
"$L = new $T($L)", outVar,
- element.enclosingTypeElement.asDeclaredType().typeName, args
+ element.enclosingTypeElement.className, args
)
}
element.isMethod() -> {
builder.addStatement(
"$L = $T.$L($L)", outVar,
- element.enclosingTypeElement.asDeclaredType().typeName,
+ element.enclosingTypeElement.className,
element.name, args
)
}
diff --git a/room/compiler/src/main/kotlin/androidx/room/vo/Dao.kt b/room/compiler/src/main/kotlin/androidx/room/vo/Dao.kt
index 69e2b44..0aa719d 100644
--- a/room/compiler/src/main/kotlin/androidx/room/vo/Dao.kt
+++ b/room/compiler/src/main/kotlin/androidx/room/vo/Dao.kt
@@ -18,7 +18,7 @@
import androidx.room.compiler.processing.XDeclaredType
import androidx.room.compiler.processing.XTypeElement
-import androidx.room.compiler.processing.isType
+import androidx.room.compiler.processing.isTypeElement
import com.squareup.javapoet.ClassName
import com.squareup.javapoet.TypeName
@@ -57,7 +57,7 @@
}
val path = arrayListOf<String>()
var enclosing = element.enclosingTypeElement
- while (enclosing?.isType() == true) {
+ while (enclosing?.isTypeElement() == true) {
path.add(enclosing!!.name)
enclosing = enclosing!!.enclosingTypeElement
}
diff --git a/room/compiler/src/main/kotlin/androidx/room/vo/RelationCollector.kt b/room/compiler/src/main/kotlin/androidx/room/vo/RelationCollector.kt
index 5aaf495..4c6b0c2 100644
--- a/room/compiler/src/main/kotlin/androidx/room/vo/RelationCollector.kt
+++ b/room/compiler/src/main/kotlin/androidx/room/vo/RelationCollector.kt
@@ -272,7 +272,7 @@
QueryParameter(
name = RelationCollectorMethodWriter.PARAM_MAP_VARIABLE,
sqlName = RelationCollectorMethodWriter.PARAM_MAP_VARIABLE,
- type = longSparseArrayElement.asDeclaredType(),
+ type = longSparseArrayElement.type,
queryParamAdapter = LONG_SPARSE_ARRAY_KEY_QUERY_PARAM_ADAPTER
)
} else {
diff --git a/room/compiler/src/main/kotlin/androidx/room/writer/DaoWriter.kt b/room/compiler/src/main/kotlin/androidx/room/writer/DaoWriter.kt
index ee30de2..fe9c44d 100644
--- a/room/compiler/src/main/kotlin/androidx/room/writer/DaoWriter.kt
+++ b/room/compiler/src/main/kotlin/androidx/room/writer/DaoWriter.kt
@@ -72,7 +72,7 @@
val processingEnv: XProcessingEnv
) :
ClassWriter(dao.typeName) {
- private val declaredDao = dao.element.asDeclaredType()
+ private val declaredDao = dao.element.type
companion object {
const val GET_LIST_OF_TYPE_CONVERTERS_METHOD = "getRequiredConverters"
diff --git a/room/compiler/src/test/kotlin/androidx/room/ext/XRoundEnvExt.kt b/room/compiler/src/test/kotlin/androidx/room/ext/XRoundEnvExt.kt
new file mode 100644
index 0000000..10a7dd6
--- /dev/null
+++ b/room/compiler/src/test/kotlin/androidx/room/ext/XRoundEnvExt.kt
@@ -0,0 +1,34 @@
+/*
+ * Copyright 2020 The Android Open Source Project
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package androidx.room.ext
+
+import androidx.room.compiler.processing.XRoundEnv
+import androidx.room.compiler.processing.XTypeElement
+import androidx.room.compiler.processing.isTypeElement
+
+/**
+ * In tests, we frequently want type elements annotated with. This helper does that and ensures
+ * we don't receive any element that is not an [XTypeElement].
+ */
+fun XRoundEnv.getTypeElementsAnnotatedWith(
+ klass: Class<out Annotation>
+): Set<XTypeElement> {
+ return getElementsAnnotatedWith(klass).map {
+ check(it.isTypeElement())
+ it
+ }.toSet()
+}
\ No newline at end of file
diff --git a/room/compiler/src/test/kotlin/androidx/room/processor/BaseDaoTest.kt b/room/compiler/src/test/kotlin/androidx/room/processor/BaseDaoTest.kt
index fe49774..7b2bd76 100644
--- a/room/compiler/src/test/kotlin/androidx/room/processor/BaseDaoTest.kt
+++ b/room/compiler/src/test/kotlin/androidx/room/processor/BaseDaoTest.kt
@@ -184,7 +184,7 @@
val daoElm = invocation.processingEnv.requireTypeElement("foo.bar.MyDao")
val dbElm = invocation.context.processingEnv
.requireTypeElement(RoomTypeNames.ROOM_DB)
- val dbType = dbElm.asDeclaredType()
+ val dbType = dbElm.type
val processedDao = DaoProcessor(
invocation.context, daoElm, dbType, null
).process()
diff --git a/room/compiler/src/test/kotlin/androidx/room/processor/BaseEntityParserTest.kt b/room/compiler/src/test/kotlin/androidx/room/processor/BaseEntityParserTest.kt
index 03c14fd..04a7059 100644
--- a/room/compiler/src/test/kotlin/androidx/room/processor/BaseEntityParserTest.kt
+++ b/room/compiler/src/test/kotlin/androidx/room/processor/BaseEntityParserTest.kt
@@ -18,6 +18,7 @@
import androidx.annotation.NonNull
import androidx.room.Embedded
+import androidx.room.ext.getTypeElementsAnnotatedWith
import androidx.room.testing.TestInvocation
import androidx.room.testing.TestProcessor
import androidx.room.vo.Entity
@@ -89,13 +90,13 @@
)
.nextRunHandler { invocation ->
val entity = invocation.roundEnv
- .getElementsAnnotatedWith(
+ .getTypeElementsAnnotatedWith(
androidx.room.Entity::class.java
)
.first { it.toString() == "foo.bar.MyEntity" }
val parser = TableEntityProcessor(
invocation.context,
- entity.asTypeElement()
+ entity
)
val parsedQuery = parser.process()
handler(parsedQuery, invocation)
diff --git a/room/compiler/src/test/kotlin/androidx/room/processor/BaseFtsEntityParserTest.kt b/room/compiler/src/test/kotlin/androidx/room/processor/BaseFtsEntityParserTest.kt
index 4a29c48..da5f29a 100644
--- a/room/compiler/src/test/kotlin/androidx/room/processor/BaseFtsEntityParserTest.kt
+++ b/room/compiler/src/test/kotlin/androidx/room/processor/BaseFtsEntityParserTest.kt
@@ -20,6 +20,7 @@
import androidx.room.Embedded
import androidx.room.Fts3
import androidx.room.Fts4
+import androidx.room.ext.getTypeElementsAnnotatedWith
import androidx.room.testing.TestInvocation
import androidx.room.testing.TestProcessor
import androidx.room.vo.FtsEntity
@@ -99,15 +100,15 @@
)
.nextRunHandler { invocation ->
val fts3AnnotatedElements = invocation.roundEnv
- .getElementsAnnotatedWith(Fts3::class.java)
+ .getTypeElementsAnnotatedWith(Fts3::class.java)
val fts4AnnotatedElements = invocation.roundEnv
- .getElementsAnnotatedWith(Fts4::class.java)
+ .getTypeElementsAnnotatedWith(Fts4::class.java)
val entity = (fts3AnnotatedElements + fts4AnnotatedElements).first {
it.toString() == "foo.bar.MyEntity"
}
val processor = FtsTableEntityProcessor(
invocation.context,
- entity.asTypeElement()
+ entity
)
val processedEntity = processor.process()
handler(processedEntity, invocation)
diff --git a/room/compiler/src/test/kotlin/androidx/room/processor/DaoProcessorTest.kt b/room/compiler/src/test/kotlin/androidx/room/processor/DaoProcessorTest.kt
index 756af79..b1995f6 100644
--- a/room/compiler/src/test/kotlin/androidx/room/processor/DaoProcessorTest.kt
+++ b/room/compiler/src/test/kotlin/androidx/room/processor/DaoProcessorTest.kt
@@ -18,6 +18,7 @@
import COMMON
import androidx.room.compiler.processing.asDeclaredType
+import androidx.room.compiler.processing.isTypeElement
import androidx.room.ext.RoomTypeNames
import androidx.room.testing.TestInvocation
import androidx.room.testing.TestProcessor
@@ -220,7 +221,7 @@
assertThat(
QueryMethodProcessor(
baseContext = daoProcessor.context,
- containing = dao.element.asDeclaredType(),
+ containing = dao.element.type,
executableElement = it.element,
dbVerifier = null
).context.logger.suppressedWarnings,
@@ -256,7 +257,7 @@
assertThat(
QueryMethodProcessor(
baseContext = daoProcessor.context,
- containing = dao.element.asDeclaredType(),
+ containing = dao.element.type,
executableElement = it.element,
dbVerifier = null
).context.logger.suppressedWarnings,
@@ -422,6 +423,7 @@
androidx.room.Dao::class.java
)
.first()
+ check(dao.isTypeElement())
val dbVerifier = if (enableVerification) {
createVerifierFromEntitiesAndViews(invocation)
} else {
@@ -432,7 +434,7 @@
.asDeclaredType()
val parser = DaoProcessor(
invocation.context,
- dao.asTypeElement(), dbType, dbVerifier
+ dao, dbType, dbVerifier
)
val parsedDao = parser.process()
diff --git a/room/compiler/src/test/kotlin/androidx/room/processor/DatabaseProcessorTest.kt b/room/compiler/src/test/kotlin/androidx/room/processor/DatabaseProcessorTest.kt
index 4bfe81c..63ef8a5 100644
--- a/room/compiler/src/test/kotlin/androidx/room/processor/DatabaseProcessorTest.kt
+++ b/room/compiler/src/test/kotlin/androidx/room/processor/DatabaseProcessorTest.kt
@@ -23,6 +23,7 @@
import androidx.room.parser.Table
import androidx.room.compiler.processing.XDeclaredType
import androidx.room.compiler.processing.XTypeElement
+import androidx.room.ext.getTypeElementsAnnotatedWith
import androidx.room.solver.query.result.EntityRowAdapter
import androidx.room.solver.query.result.PojoRowAdapter
import androidx.room.testing.TestInvocation
@@ -1080,13 +1081,13 @@
.forAnnotations(androidx.room.Database::class)
.nextRunHandler { invocation ->
val database = invocation.roundEnv
- .getElementsAnnotatedWith(
+ .getTypeElementsAnnotatedWith(
androidx.room.Database::class.java
)
.first()
val processor = DatabaseProcessor(
invocation.context,
- database.asTypeElement()
+ database
)
val list = views.map { (viewName, names) ->
@@ -1153,13 +1154,13 @@
.forAnnotations(androidx.room.Database::class)
.nextRunHandler { invocation ->
val entity = invocation.roundEnv
- .getElementsAnnotatedWith(
+ .getTypeElementsAnnotatedWith(
androidx.room.Database::class.java
)
.first()
val parser = DatabaseProcessor(
invocation.context,
- entity.asTypeElement()
+ entity
)
val parsedDb = parser.process()
handler(parsedDb, invocation)
diff --git a/room/compiler/src/test/kotlin/androidx/room/processor/DatabaseViewProcessorTest.kt b/room/compiler/src/test/kotlin/androidx/room/processor/DatabaseViewProcessorTest.kt
index 7821b23..b343155 100644
--- a/room/compiler/src/test/kotlin/androidx/room/processor/DatabaseViewProcessorTest.kt
+++ b/room/compiler/src/test/kotlin/androidx/room/processor/DatabaseViewProcessorTest.kt
@@ -17,6 +17,7 @@
package androidx.room.processor
import androidx.annotation.NonNull
+import androidx.room.compiler.processing.isTypeElement
import androidx.room.parser.ParserErrors
import androidx.room.parser.SQLTypeAffinity
import androidx.room.testing.TestInvocation
@@ -237,12 +238,13 @@
val view = invocation.roundEnv
.rootElements
.first { it.toString() == name }
+ check(view.isTypeElement())
val verifier = if (verify) {
createVerifierFromEntitiesAndViews(invocation)
} else null
val processor = DatabaseViewProcessor(
invocation.context,
- view.asTypeElement()
+ view
)
val processedView = processor.process()
processedView.query.resultInfo =
diff --git a/room/compiler/src/test/kotlin/androidx/room/processor/FieldProcessorTest.kt b/room/compiler/src/test/kotlin/androidx/room/processor/FieldProcessorTest.kt
index 737e1d8..961298c 100644
--- a/room/compiler/src/test/kotlin/androidx/room/processor/FieldProcessorTest.kt
+++ b/room/compiler/src/test/kotlin/androidx/room/processor/FieldProcessorTest.kt
@@ -18,6 +18,7 @@
import androidx.room.Entity
import androidx.room.compiler.processing.XFieldElement
+import androidx.room.ext.getTypeElementsAnnotatedWith
import androidx.room.parser.Collate
import androidx.room.parser.SQLTypeAffinity
import androidx.room.solver.types.ColumnTypeAdapter
@@ -602,23 +603,22 @@
.forAnnotations(androidx.room.Entity::class)
.nextRunHandler { invocation ->
val (owner, fieldElement) = invocation.roundEnv
- .getElementsAnnotatedWith(Entity::class.java)
+ .getTypeElementsAnnotatedWith(Entity::class.java)
.map {
Pair(
it,
- it.asTypeElement()
- .getAllFieldsIncludingPrivateSupers().firstOrNull()
+ it.getAllFieldsIncludingPrivateSupers().firstOrNull()
)
}
.first { it.second != null }
val entityContext =
TableEntityProcessor(
baseContext = invocation.context,
- element = owner.asTypeElement()
+ element = owner
).context
val parser = FieldProcessor(
baseContext = entityContext,
- containing = owner.asDeclaredType(),
+ containing = owner.type,
element = fieldElement!!,
bindingScope = FieldProcessor.BindingScope.TWO_WAY,
fieldParent = null,
diff --git a/room/compiler/src/test/kotlin/androidx/room/processor/Fts4TableEntityProcessorTest.kt b/room/compiler/src/test/kotlin/androidx/room/processor/Fts4TableEntityProcessorTest.kt
index 6818d25..396a54e 100644
--- a/room/compiler/src/test/kotlin/androidx/room/processor/Fts4TableEntityProcessorTest.kt
+++ b/room/compiler/src/test/kotlin/androidx/room/processor/Fts4TableEntityProcessorTest.kt
@@ -18,6 +18,7 @@
import androidx.room.Fts4
import androidx.room.FtsOptions
+import androidx.room.ext.getTypeElementsAnnotatedWith
import androidx.room.parser.FtsVersion
import androidx.room.parser.SQLTypeAffinity
import androidx.room.vo.CallType
@@ -89,9 +90,9 @@
"""
)
) { invocation ->
- val entity = invocation.roundEnv.getElementsAnnotatedWith(Fts4::class.java)
+ val entity = invocation.roundEnv.getTypeElementsAnnotatedWith(Fts4::class.java)
.first { it.toString() == "foo.bar.MyEntity" }
- FtsTableEntityProcessor(invocation.context, entity.asTypeElement())
+ FtsTableEntityProcessor(invocation.context, entity)
.process()
}
.failsToCompile()
diff --git a/room/compiler/src/test/kotlin/androidx/room/processor/InsertionMethodProcessorTest.kt b/room/compiler/src/test/kotlin/androidx/room/processor/InsertionMethodProcessorTest.kt
index 14e28c6..71f7bcb 100644
--- a/room/compiler/src/test/kotlin/androidx/room/processor/InsertionMethodProcessorTest.kt
+++ b/room/compiler/src/test/kotlin/androidx/room/processor/InsertionMethodProcessorTest.kt
@@ -23,6 +23,7 @@
import androidx.room.ext.CommonTypeNames
import androidx.room.ext.RxJava2TypeNames
import androidx.room.ext.RxJava3TypeNames
+import androidx.room.ext.getTypeElementsAnnotatedWith
import androidx.room.solver.shortcut.result.InsertMethodAdapter
import androidx.room.testing.TestInvocation
import androidx.room.testing.TestProcessor
@@ -863,18 +864,18 @@
.forAnnotations(Insert::class, Dao::class)
.nextRunHandler { invocation ->
val (owner, methods) = invocation.roundEnv
- .getElementsAnnotatedWith(Dao::class.java)
+ .getTypeElementsAnnotatedWith(Dao::class.java)
.map {
Pair(
it,
- it.asTypeElement().getAllMethods().filter {
+ it.getAllMethods().filter {
it.hasAnnotation(Insert::class)
}
)
}.first { it.second.isNotEmpty() }
val processor = InsertionMethodProcessor(
baseContext = invocation.context,
- containing = owner.asDeclaredType(),
+ containing = owner.type,
executableElement = methods.first()
)
val processed = processor.process()
diff --git a/room/compiler/src/test/kotlin/androidx/room/processor/ProjectionExpanderTest.kt b/room/compiler/src/test/kotlin/androidx/room/processor/ProjectionExpanderTest.kt
index d5b5bc9..1ecc005 100644
--- a/room/compiler/src/test/kotlin/androidx/room/processor/ProjectionExpanderTest.kt
+++ b/room/compiler/src/test/kotlin/androidx/room/processor/ProjectionExpanderTest.kt
@@ -16,6 +16,8 @@
package androidx.room.processor
+import androidx.room.compiler.processing.isTypeElement
+import androidx.room.ext.getTypeElementsAnnotatedWith
import androidx.room.parser.SqlParser
import androidx.room.parser.expansion.ProjectionExpander
import androidx.room.testing.TestInvocation
@@ -519,19 +521,20 @@
options = listOf("-Aroom.expandProjection=true")
) { invocation ->
val entities = invocation.roundEnv
- .getElementsAnnotatedWith(androidx.room.Entity::class.java)
+ .getTypeElementsAnnotatedWith(androidx.room.Entity::class.java)
.map { element ->
TableEntityProcessor(
invocation.context,
- element.asTypeElement()
+ element
).process()
}
val entityElement = invocation.roundEnv
.rootElements
.first { it.toString() == "foo.bar.User" }
+ check(entityElement.isTypeElement())
val entity = PojoProcessor.createFor(
invocation.context,
- entityElement.asTypeElement(),
+ entityElement,
bindingScope = FieldProcessor.BindingScope.READ_FROM_CURSOR,
parent = null
).process()
@@ -621,19 +624,20 @@
options = listOf("-Aroom.expandProjection=true")
) { invocation ->
val entities = invocation.roundEnv
- .getElementsAnnotatedWith(androidx.room.Entity::class.java)
+ .getTypeElementsAnnotatedWith(androidx.room.Entity::class.java)
.map { element ->
TableEntityProcessor(
invocation.context,
- element.asTypeElement()
+ element
).process()
}
val pojoElement = invocation.roundEnv
.rootElements
.first { it.toString() == name }
+ check(pojoElement.isTypeElement())
val pojo = PojoProcessor.createFor(
invocation.context,
- pojoElement.asTypeElement(),
+ pojoElement,
bindingScope = FieldProcessor.BindingScope.READ_FROM_CURSOR,
parent = null
).process()
diff --git a/room/compiler/src/test/kotlin/androidx/room/processor/QueryMethodProcessorTest.kt b/room/compiler/src/test/kotlin/androidx/room/processor/QueryMethodProcessorTest.kt
index 1f1e14e..41042bb 100644
--- a/room/compiler/src/test/kotlin/androidx/room/processor/QueryMethodProcessorTest.kt
+++ b/room/compiler/src/test/kotlin/androidx/room/processor/QueryMethodProcessorTest.kt
@@ -28,6 +28,7 @@
import androidx.room.parser.Table
import androidx.room.compiler.processing.XDeclaredType
import androidx.room.compiler.processing.XType
+import androidx.room.ext.getTypeElementsAnnotatedWith
import androidx.room.processor.ProcessorErrors.cannotFindQueryResultAdapter
import androidx.room.solver.query.result.DataSourceFactoryQueryResultBinder
import androidx.room.solver.query.result.ListQueryResultAdapter
@@ -1136,11 +1137,11 @@
)
.nextRunHandler { invocation ->
val (owner, methods) = invocation.roundEnv
- .getElementsAnnotatedWith(Dao::class.java)
+ .getTypeElementsAnnotatedWith(Dao::class.java)
.map {
Pair(
it,
- it.asTypeElement().getAllMethods().filter {
+ it.getAllMethods().filter {
it.hasAnnotation(Query::class)
}
)
@@ -1154,7 +1155,7 @@
}
val parser = QueryMethodProcessor(
baseContext = invocation.context,
- containing = owner.asDeclaredType(),
+ containing = owner.type,
executableElement = methods.first(),
dbVerifier = verifier
)
diff --git a/room/compiler/src/test/kotlin/androidx/room/processor/RawQueryMethodProcessorTest.kt b/room/compiler/src/test/kotlin/androidx/room/processor/RawQueryMethodProcessorTest.kt
index f992e09..b1104c5 100644
--- a/room/compiler/src/test/kotlin/androidx/room/processor/RawQueryMethodProcessorTest.kt
+++ b/room/compiler/src/test/kotlin/androidx/room/processor/RawQueryMethodProcessorTest.kt
@@ -25,6 +25,7 @@
import androidx.room.RawQuery
import androidx.room.ext.PagingTypeNames
import androidx.room.ext.SupportDbTypeNames
+import androidx.room.ext.getTypeElementsAnnotatedWith
import androidx.room.processor.ProcessorErrors.RAW_QUERY_STRING_PARAMETER_REMOVED
import androidx.room.testing.TestInvocation
import androidx.room.testing.TestProcessor
@@ -219,7 +220,7 @@
val daoFunctionElement = daoElement.getDeclaredMethods().first()
RawQueryMethodProcessor(
baseContext = invocation.context,
- containing = daoElement.asDeclaredType(),
+ containing = daoElement.type,
executableElement = daoFunctionElement
).process()
}.failsToCompile().withErrorContaining(
@@ -343,18 +344,18 @@
)
.nextRunHandler { invocation ->
val (owner, methods) = invocation.roundEnv
- .getElementsAnnotatedWith(Dao::class.java)
+ .getTypeElementsAnnotatedWith(Dao::class.java)
.map {
Pair(
it,
- it.asTypeElement().getAllMethods().filter {
+ it.getAllMethods().filter {
it.hasAnnotation(RawQuery::class)
}
)
}.first { it.second.isNotEmpty() }
val parser = RawQueryMethodProcessor(
baseContext = invocation.context,
- containing = owner.asDeclaredType(),
+ containing = owner.type,
executableElement = methods.first()
)
val parsedQuery = parser.process()
diff --git a/room/compiler/src/test/kotlin/androidx/room/processor/ShortcutMethodProcessorTest.kt b/room/compiler/src/test/kotlin/androidx/room/processor/ShortcutMethodProcessorTest.kt
index 7555ec1..2cd6906 100644
--- a/room/compiler/src/test/kotlin/androidx/room/processor/ShortcutMethodProcessorTest.kt
+++ b/room/compiler/src/test/kotlin/androidx/room/processor/ShortcutMethodProcessorTest.kt
@@ -24,6 +24,7 @@
import androidx.room.ext.RxJava3TypeNames
import androidx.room.compiler.processing.XDeclaredType
import androidx.room.compiler.processing.XMethodElement
+import androidx.room.ext.getTypeElementsAnnotatedWith
import androidx.room.testing.TestInvocation
import androidx.room.testing.TestProcessor
import androidx.room.vo.ShortcutMethod
@@ -521,18 +522,18 @@
.forAnnotations(annotation, Dao::class)
.nextRunHandler { invocation ->
val (owner, methods) = invocation.roundEnv
- .getElementsAnnotatedWith(Dao::class.java)
+ .getTypeElementsAnnotatedWith(Dao::class.java)
.map {
Pair(
it,
- it.asTypeElement().getAllMethods().filter {
+ it.getAllMethods().filter {
it.hasAnnotation(annotation)
}
)
}.first { it.second.isNotEmpty() }
val processed = process(
baseContext = invocation.context,
- containing = owner.asDeclaredType(),
+ containing = owner.type,
executableElement = methods.first()
)
handler(processed, invocation)
diff --git a/room/compiler/src/test/kotlin/androidx/room/processor/TransactionMethodProcessorTest.kt b/room/compiler/src/test/kotlin/androidx/room/processor/TransactionMethodProcessorTest.kt
index aebd173..2ae21b5 100644
--- a/room/compiler/src/test/kotlin/androidx/room/processor/TransactionMethodProcessorTest.kt
+++ b/room/compiler/src/test/kotlin/androidx/room/processor/TransactionMethodProcessorTest.kt
@@ -19,6 +19,7 @@
import COMMON
import androidx.room.Dao
import androidx.room.Transaction
+import androidx.room.ext.getTypeElementsAnnotatedWith
import androidx.room.testing.TestInvocation
import androidx.room.testing.TestProcessor
import androidx.room.vo.TransactionMethod
@@ -251,18 +252,18 @@
.forAnnotations(Transaction::class, Dao::class)
.nextRunHandler { invocation ->
val (owner, methods) = invocation.roundEnv
- .getElementsAnnotatedWith(Dao::class.java)
+ .getTypeElementsAnnotatedWith(Dao::class.java)
.map {
Pair(
it,
- it.asTypeElement().getAllMethods().filter {
+ it.getAllMethods().filter {
it.hasAnnotation(Transaction::class)
}
)
}.first { it.second.isNotEmpty() }
val processor = TransactionMethodProcessor(
baseContext = invocation.context,
- containing = owner.asDeclaredType(),
+ containing = owner.type,
executableElement = methods.first()
)
val processed = processor.process()
diff --git a/room/compiler/src/test/kotlin/androidx/room/solver/TypeAdapterStoreTest.kt b/room/compiler/src/test/kotlin/androidx/room/solver/TypeAdapterStoreTest.kt
index 3b8ff54..04d9d40e 100644
--- a/room/compiler/src/test/kotlin/androidx/room/solver/TypeAdapterStoreTest.kt
+++ b/room/compiler/src/test/kotlin/androidx/room/solver/TypeAdapterStoreTest.kt
@@ -329,7 +329,7 @@
assertThat(publisherElement, notNullValue())
assertThat(
RxQueryResultBinderProvider.getAll(invocation.context).any {
- it.matches(publisherElement.asDeclaredType())
+ it.matches(publisherElement.type)
},
`is`(true)
)
@@ -350,7 +350,7 @@
assertThat(publisherElement, notNullValue())
assertThat(
RxQueryResultBinderProvider.getAll(invocation.context).any {
- it.matches(publisherElement.asDeclaredType())
+ it.matches(publisherElement.type)
},
`is`(true)
)
@@ -375,7 +375,7 @@
assertThat(publisher, notNullValue())
assertThat(
RxQueryResultBinderProvider.getAll(invocation.context).any {
- it.matches(publisher.asDeclaredType())
+ it.matches(publisher.type)
},
`is`(true)
)
@@ -396,7 +396,7 @@
val flowable = invocation.processingEnv.requireTypeElement(rxTypeClassName)
assertThat(
RxQueryResultBinderProvider.getAll(invocation.context).any {
- it.matches(flowable.asDeclaredType())
+ it.matches(flowable.type)
},
`is`(true)
)
@@ -418,7 +418,7 @@
assertThat(observable, notNullValue())
assertThat(
RxQueryResultBinderProvider.getAll(invocation.context).any {
- it.matches(observable.asDeclaredType())
+ it.matches(observable.type)
},
`is`(true)
)
@@ -438,7 +438,7 @@
assertThat(single, notNullValue())
assertThat(
RxCallableInsertMethodBinderProvider.getAll(invocation.context).any {
- it.matches(single.asDeclaredType())
+ it.matches(single.type)
},
`is`(true)
)
@@ -456,7 +456,7 @@
val maybe = invocation.processingEnv.requireTypeElement(rxTypeClassName)
assertThat(
RxCallableInsertMethodBinderProvider.getAll(invocation.context).any {
- it.matches(maybe.asDeclaredType())
+ it.matches(maybe.type)
},
`is`(true)
)
@@ -474,7 +474,7 @@
val completable = invocation.processingEnv.requireTypeElement(rxTypeClassName)
assertThat(
RxCallableInsertMethodBinderProvider.getAll(invocation.context).any {
- it.matches(completable.asDeclaredType())
+ it.matches(completable.type)
},
`is`(true)
)
@@ -490,7 +490,7 @@
.requireTypeElement(GuavaUtilConcurrentTypeNames.LISTENABLE_FUTURE)
assertThat(
GuavaListenableFutureInsertMethodBinderProvider(invocation.context).matches(
- future.asDeclaredType()
+ future.type
),
`is`(true)
)
@@ -504,7 +504,7 @@
assertThat(single, notNullValue())
assertThat(
RxCallableDeleteOrUpdateMethodBinderProvider.getAll(invocation.context).any {
- it.matches(single.asDeclaredType())
+ it.matches(single.type)
},
`is`(true)
)
@@ -519,7 +519,7 @@
assertThat(maybe, notNullValue())
assertThat(
RxCallableDeleteOrUpdateMethodBinderProvider.getAll(invocation.context).any {
- it.matches(maybe.asDeclaredType())
+ it.matches(maybe.type)
},
`is`(true)
)
@@ -535,7 +535,7 @@
assertThat(completable, notNullValue())
assertThat(
RxCallableDeleteOrUpdateMethodBinderProvider.getAll(invocation.context).any {
- it.matches(completable.asDeclaredType())
+ it.matches(completable.type)
},
`is`(true)
)
@@ -552,7 +552,7 @@
assertThat(future, notNullValue())
assertThat(
GuavaListenableFutureDeleteOrUpdateMethodBinderProvider(invocation.context)
- .matches(future.asDeclaredType()),
+ .matches(future.type),
`is`(true)
)
}
@@ -568,7 +568,7 @@
assertThat(liveData, notNullValue())
assertThat(
LiveDataQueryResultBinderProvider(invocation.context).matches(
- liveData.asDeclaredType()
+ liveData.type
),
`is`(true)
)
@@ -622,7 +622,7 @@
assertThat(dataSource, notNullValue())
assertThat(
DataSourceQueryResultBinderProvider(invocation.context).matches(
- dataSource.asDeclaredType()
+ dataSource.type
),
`is`(true)
)
@@ -642,7 +642,7 @@
assertThat(dataSource, notNullValue())
assertThat(
DataSourceQueryResultBinderProvider(invocation.context).matches(
- dataSource.asDeclaredType()
+ dataSource.type
),
`is`(true)
)
@@ -658,7 +658,7 @@
assertThat(pagedListProvider, notNullValue())
assertThat(
DataSourceFactoryQueryResultBinderProvider(invocation.context).matches(
- pagedListProvider.asDeclaredType()
+ pagedListProvider.type
),
`is`(true)
)
diff --git a/room/compiler/src/test/kotlin/androidx/room/solver/query/QueryWriterTest.kt b/room/compiler/src/test/kotlin/androidx/room/solver/query/QueryWriterTest.kt
index 21b26a5..7c325d5 100644
--- a/room/compiler/src/test/kotlin/androidx/room/solver/query/QueryWriterTest.kt
+++ b/room/compiler/src/test/kotlin/androidx/room/solver/query/QueryWriterTest.kt
@@ -20,6 +20,7 @@
import androidx.room.Query
import androidx.room.ext.RoomTypeNames.ROOM_SQL_QUERY
import androidx.room.ext.RoomTypeNames.STRING_UTIL
+import androidx.room.ext.getTypeElementsAnnotatedWith
import androidx.room.processor.QueryMethodProcessor
import androidx.room.testing.TestProcessor
import androidx.room.writer.QueryWriter
@@ -354,18 +355,18 @@
.forAnnotations(Query::class, Dao::class)
.nextRunHandler { invocation ->
val (owner, methods) = invocation.roundEnv
- .getElementsAnnotatedWith(Dao::class.java)
+ .getTypeElementsAnnotatedWith(Dao::class.java)
.map {
Pair(
it,
- it.asTypeElement().getAllMethods().filter {
+ it.getAllMethods().filter {
it.hasAnnotation(Query::class)
}
)
}.first { it.second.isNotEmpty() }
val parser = QueryMethodProcessor(
baseContext = invocation.context,
- containing = owner.asDeclaredType(),
+ containing = owner.type,
executableElement = methods.first()
)
val method = parser.process()
diff --git a/room/compiler/src/test/kotlin/androidx/room/testing/test_util.kt b/room/compiler/src/test/kotlin/androidx/room/testing/test_util.kt
index febe6e2..5688221 100644
--- a/room/compiler/src/test/kotlin/androidx/room/testing/test_util.kt
+++ b/room/compiler/src/test/kotlin/androidx/room/testing/test_util.kt
@@ -30,6 +30,7 @@
import androidx.room.ext.RoomRxJava3TypeNames
import androidx.room.ext.RxJava2TypeNames
import androidx.room.ext.RxJava3TypeNames
+import androidx.room.ext.getTypeElementsAnnotatedWith
import androidx.room.processor.DatabaseViewProcessor
import androidx.room.processor.TableEntityProcessor
import androidx.room.solver.CodeGenScope
@@ -263,14 +264,14 @@
}
fun TestInvocation.getViews(): List<androidx.room.vo.DatabaseView> {
- return roundEnv.getElementsAnnotatedWith(DatabaseView::class.java).map {
- DatabaseViewProcessor(context, it.asTypeElement()).process()
+ return roundEnv.getTypeElementsAnnotatedWith(DatabaseView::class.java).map {
+ DatabaseViewProcessor(context, it).process()
}
}
fun TestInvocation.getEntities(): List<androidx.room.vo.Entity> {
- val entities = roundEnv.getElementsAnnotatedWith(Entity::class.java).map {
- TableEntityProcessor(context, it.asTypeElement()).process()
+ val entities = roundEnv.getTypeElementsAnnotatedWith(Entity::class.java).map {
+ TableEntityProcessor(context, it).process()
}
return entities
}
diff --git a/room/compiler/src/test/kotlin/androidx/room/writer/DaoWriterTest.kt b/room/compiler/src/test/kotlin/androidx/room/writer/DaoWriterTest.kt
index f835074..b78e3b3 100644
--- a/room/compiler/src/test/kotlin/androidx/room/writer/DaoWriterTest.kt
+++ b/room/compiler/src/test/kotlin/androidx/room/writer/DaoWriterTest.kt
@@ -18,6 +18,7 @@
import COMMON
import androidx.room.ext.RoomTypeNames
+import androidx.room.ext.getTypeElementsAnnotatedWith
import androidx.room.processor.DaoProcessor
import androidx.room.testing.TestProcessor
import com.google.common.truth.Truth
@@ -98,21 +99,21 @@
.forAnnotations(androidx.room.Dao::class)
.nextRunHandler { invocation ->
val dao = invocation.roundEnv
- .getElementsAnnotatedWith(
+ .getTypeElementsAnnotatedWith(
androidx.room.Dao::class.java
)
.first()
val db = invocation.roundEnv
- .getElementsAnnotatedWith(
+ .getTypeElementsAnnotatedWith(
androidx.room.Database::class.java
)
.firstOrNull()
?: invocation.context.processingEnv
.requireTypeElement(RoomTypeNames.ROOM_DB)
- val dbType = db.asDeclaredType()
+ val dbType = db.type
val parser = DaoProcessor(
baseContext = invocation.context,
- element = dao.asTypeElement(),
+ element = dao,
dbType = dbType,
dbVerifier = createVerifierFromEntitiesAndViews(invocation)
)
diff --git a/room/compiler/src/test/kotlin/androidx/room/writer/SQLiteOpenHelperWriterTest.kt b/room/compiler/src/test/kotlin/androidx/room/writer/SQLiteOpenHelperWriterTest.kt
index c1dbb7a..6ec2ffd 100644
--- a/room/compiler/src/test/kotlin/androidx/room/writer/SQLiteOpenHelperWriterTest.kt
+++ b/room/compiler/src/test/kotlin/androidx/room/writer/SQLiteOpenHelperWriterTest.kt
@@ -17,6 +17,7 @@
package androidx.room.writer
import androidx.annotation.NonNull
+import androidx.room.ext.getTypeElementsAnnotatedWith
import androidx.room.processor.DatabaseProcessor
import androidx.room.testing.TestInvocation
import androidx.room.testing.TestProcessor
@@ -221,8 +222,8 @@
)
.nextRunHandler { invocation ->
val db = invocation.roundEnv
- .getElementsAnnotatedWith(androidx.room.Database::class.java)
- .first().asTypeElement()
+ .getTypeElementsAnnotatedWith(androidx.room.Database::class.java)
+ .first()
handler(DatabaseProcessor(invocation.context, db).process(), invocation)
true
}
diff --git a/room/runtime/src/androidTest/java/androidx/room/migration/TableInfoTest.java b/room/runtime/src/androidTest/java/androidx/room/migration/TableInfoTest.java
index 0a20b99..b71367d 100644
--- a/room/runtime/src/androidTest/java/androidx/room/migration/TableInfoTest.java
+++ b/room/runtime/src/androidTest/java/androidx/room/migration/TableInfoTest.java
@@ -364,6 +364,7 @@
return result;
}
+ @SuppressWarnings("unchecked")
private static <T> Set<T> toSet(T... ts) {
final HashSet<T> result = new HashSet<T>();
for (T t : ts) {
diff --git a/room/runtime/src/test/java/androidx/room/BuilderTest.java b/room/runtime/src/test/java/androidx/room/BuilderTest.java
index ae6d83b..63ce98d 100644
--- a/room/runtime/src/test/java/androidx/room/BuilderTest.java
+++ b/room/runtime/src/test/java/androidx/room/BuilderTest.java
@@ -44,7 +44,7 @@
import java.util.List;
import java.util.concurrent.Executor;
-@SuppressWarnings("ArraysAsListWithZeroOrOneArgument")
+@SuppressWarnings({"ArraysAsListWithZeroOrOneArgument", "deprecation"})
@RunWith(JUnit4.class)
public class BuilderTest {
@Test(expected = IllegalArgumentException.class)
diff --git a/room/runtime/src/test/java/androidx/room/InvalidationTrackerTest.java b/room/runtime/src/test/java/androidx/room/InvalidationTrackerTest.java
index 66a7047..e52d47f 100644
--- a/room/runtime/src/test/java/androidx/room/InvalidationTrackerTest.java
+++ b/room/runtime/src/test/java/androidx/room/InvalidationTrackerTest.java
@@ -427,6 +427,7 @@
assertThat(observer.getInvalidatedTables(), hasItem("a"));
}
+ @SuppressWarnings("deprecation")
@Test
public void failFastCreateLiveData() {
// assert that sending a bad createLiveData table name fails instantly
diff --git a/security/crypto/src/androidTest/java/androidx/security/crypto/EncryptedFileTest.java b/security/crypto/src/androidTest/java/androidx/security/crypto/EncryptedFileTest.java
index c683a79..b08a7bf 100644
--- a/security/crypto/src/androidTest/java/androidx/security/crypto/EncryptedFileTest.java
+++ b/security/crypto/src/androidTest/java/androidx/security/crypto/EncryptedFileTest.java
@@ -32,7 +32,6 @@
import com.google.crypto.tink.integration.android.AndroidKeysetManager;
import com.google.crypto.tink.streamingaead.AesGcmHkdfStreamingKeyManager;
import com.google.crypto.tink.streamingaead.StreamingAeadConfig;
-import com.google.crypto.tink.streamingaead.StreamingAeadFactory;
import org.junit.Assert;
import org.junit.Before;
@@ -50,7 +49,6 @@
@MediumTest
@RunWith(AndroidJUnit4.class)
public class EncryptedFileTest {
-
private Context mContext;
private MasterKey mMasterKey;
@@ -170,6 +168,7 @@
}
+ @SuppressWarnings("deprecation")
@Test
public void testWriteReadEncryptedFileWithAlias() throws Exception {
final String fileContent = "Don't tell anyone...";
@@ -299,6 +298,7 @@
Assert.assertTrue("Keyset should have existed.", containsKeyset);
}
+ @SuppressWarnings("deprecation")
@Test
public void tinkTest() throws Exception {
final String fileContent = "Don't tell anyone...";
@@ -324,8 +324,8 @@
.withMasterKeyUri(KEYSTORE_PATH_URI + mMasterKey.getKeyAlias())
.build().getKeysetHandle();
- StreamingAead streamingAead = StreamingAeadFactory.getPrimitive(
- streadmingAeadKeysetHandle);
+ StreamingAead streamingAead = com.google.crypto.tink.streamingaead.StreamingAeadFactory
+ .getPrimitive(streadmingAeadKeysetHandle);
FileInputStream fileInputStream = new FileInputStream(file);
InputStream inputStream = streamingAead.newDecryptingStream(fileInputStream,
diff --git a/security/crypto/src/androidTest/java/androidx/security/crypto/EncryptedSharedPreferencesTest.java b/security/crypto/src/androidTest/java/androidx/security/crypto/EncryptedSharedPreferencesTest.java
index 0a76af6..2b95874 100644
--- a/security/crypto/src/androidTest/java/androidx/security/crypto/EncryptedSharedPreferencesTest.java
+++ b/security/crypto/src/androidTest/java/androidx/security/crypto/EncryptedSharedPreferencesTest.java
@@ -347,6 +347,7 @@
sharedPreferences.getAll().size());
}
+ @SuppressWarnings("deprecation")
@Test
public void testWriteSharedPrefsTink() throws Exception {
String tinkTestPrefs = "TinkTestPrefs";
diff --git a/security/crypto/src/androidTest/java/androidx/security/crypto/MasterKeyTest.java b/security/crypto/src/androidTest/java/androidx/security/crypto/MasterKeyTest.java
index a271b22..616227f 100644
--- a/security/crypto/src/androidTest/java/androidx/security/crypto/MasterKeyTest.java
+++ b/security/crypto/src/androidTest/java/androidx/security/crypto/MasterKeyTest.java
@@ -170,6 +170,7 @@
}
}
+ @SuppressWarnings("deprecation")
@SdkSuppress(minSdkVersion = Build.VERSION_CODES.M)
@Test
public void testUseOfSchemeAndParamsFails() throws GeneralSecurityException,
diff --git a/security/crypto/src/androidTest/java/androidx/security/crypto/MasterKeysTest.java b/security/crypto/src/androidTest/java/androidx/security/crypto/MasterKeysTest.java
index 8a3cd6e..7e2ed24 100644
--- a/security/crypto/src/androidTest/java/androidx/security/crypto/MasterKeysTest.java
+++ b/security/crypto/src/androidTest/java/androidx/security/crypto/MasterKeysTest.java
@@ -39,6 +39,7 @@
import java.security.GeneralSecurityException;
import java.security.KeyStore;
+@SuppressWarnings("deprecation")
@MediumTest
@SdkSuppress(minSdkVersion = Build.VERSION_CODES.M)
@RunWith(AndroidJUnit4.class)
diff --git a/security/identity-credential/src/androidTest/java/androidx/security/identity/cts/DynamicAuthTest.java b/security/identity-credential/src/androidTest/java/androidx/security/identity/cts/DynamicAuthTest.java
index c986a44..7f6d550 100644
--- a/security/identity-credential/src/androidTest/java/androidx/security/identity/cts/DynamicAuthTest.java
+++ b/security/identity-credential/src/androidTest/java/androidx/security/identity/cts/DynamicAuthTest.java
@@ -29,7 +29,6 @@
import androidx.security.identity.IdentityCredentialStore;
import androidx.security.identity.NoAuthenticationKeyAvailableException;
import androidx.security.identity.ResultData;
-import androidx.test.InstrumentationRegistry;
import androidx.test.ext.junit.runners.AndroidJUnit4;
import androidx.test.filters.LargeTest;
@@ -61,9 +60,10 @@
public class DynamicAuthTest {
private static final String TAG = "DynamicAuthTest";
+ @SuppressWarnings("deprecation")
@Test
public void dynamicAuthTest() throws Exception {
- Context appContext = InstrumentationRegistry.getTargetContext();
+ Context appContext = androidx.test.InstrumentationRegistry.getTargetContext();
IdentityCredentialStore store = Util.getIdentityCredentialStore(appContext);
String credentialName = "test";
diff --git a/security/identity-credential/src/androidTest/java/androidx/security/identity/cts/EphemeralKeyTest.java b/security/identity-credential/src/androidTest/java/androidx/security/identity/cts/EphemeralKeyTest.java
index 4f0a62b..f9173ab 100644
--- a/security/identity-credential/src/androidTest/java/androidx/security/identity/cts/EphemeralKeyTest.java
+++ b/security/identity-credential/src/androidTest/java/androidx/security/identity/cts/EphemeralKeyTest.java
@@ -28,7 +28,6 @@
import androidx.security.identity.IdentityCredential;
import androidx.security.identity.IdentityCredentialException;
import androidx.security.identity.IdentityCredentialStore;
-import androidx.test.InstrumentationRegistry;
import androidx.test.ext.junit.runners.AndroidJUnit4;
import androidx.test.filters.MediumTest;
@@ -57,6 +56,7 @@
import javax.crypto.spec.SecretKeySpec;
// TODO: For better coverage, use different ECDH and HKDF implementations in test code.
+@SuppressWarnings("deprecation")
@MediumTest
@RunWith(AndroidJUnit4.class)
public class EphemeralKeyTest {
@@ -64,7 +64,7 @@
@Test
public void createEphemeralKey() throws IdentityCredentialException {
- Context appContext = InstrumentationRegistry.getTargetContext();
+ Context appContext = androidx.test.InstrumentationRegistry.getTargetContext();
IdentityCredentialStore store = Util.getIdentityCredentialStore(appContext);
String credentialName = "ephemeralKeyTest";
diff --git a/security/identity-credential/src/androidTest/java/androidx/security/identity/cts/ProvisioningTest.java b/security/identity-credential/src/androidTest/java/androidx/security/identity/cts/ProvisioningTest.java
index 8ec51a5..363c0b8 100644
--- a/security/identity-credential/src/androidTest/java/androidx/security/identity/cts/ProvisioningTest.java
+++ b/security/identity-credential/src/androidTest/java/androidx/security/identity/cts/ProvisioningTest.java
@@ -40,7 +40,6 @@
import androidx.security.identity.PersonalizationData;
import androidx.security.identity.ResultData;
import androidx.security.identity.WritableIdentityCredential;
-import androidx.test.InstrumentationRegistry;
import androidx.test.ext.junit.runners.AndroidJUnit4;
import androidx.test.filters.LargeTest;
@@ -71,6 +70,7 @@
*
* @see <a href="http://d.android.com/tools/testing">Testing documentation</a>
*/
+@SuppressWarnings("deprecation")
@LargeTest
@RunWith(AndroidJUnit4.class)
public class ProvisioningTest {
@@ -357,7 +357,7 @@
@Test
public void alreadyPersonalized() throws IdentityCredentialException {
- Context appContext = InstrumentationRegistry.getTargetContext();
+ Context appContext = androidx.test.InstrumentationRegistry.getTargetContext();
IdentityCredentialStore store = Util.getIdentityCredentialStore(appContext);
store.deleteCredentialByName("test");
@@ -374,7 +374,7 @@
@Test
public void nonExistent() throws IdentityCredentialException {
- Context appContext = InstrumentationRegistry.getTargetContext();
+ Context appContext = androidx.test.InstrumentationRegistry.getTargetContext();
IdentityCredentialStore store = Util.getIdentityCredentialStore(appContext);
store.deleteCredentialByName("test");
@@ -385,7 +385,7 @@
@Test
public void defaultStoreSupportsAnyDocumentType() throws IdentityCredentialException {
- Context appContext = InstrumentationRegistry.getTargetContext();
+ Context appContext = androidx.test.InstrumentationRegistry.getTargetContext();
IdentityCredentialStore store = Util.getIdentityCredentialStore(appContext);
String[] supportedDocTypes = store.getSupportedDocTypes();
@@ -395,7 +395,7 @@
@Test
public void deleteCredential()
throws IdentityCredentialException, CborException, CertificateEncodingException {
- Context appContext = InstrumentationRegistry.getTargetContext();
+ Context appContext = androidx.test.InstrumentationRegistry.getTargetContext();
IdentityCredentialStore store = Util.getIdentityCredentialStore(appContext);
store.deleteCredentialByName("test");
@@ -430,7 +430,7 @@
@Test
public void testProvisionAndRetrieve() throws IdentityCredentialException, CborException {
- Context appContext = InstrumentationRegistry.getTargetContext();
+ Context appContext = androidx.test.InstrumentationRegistry.getTargetContext();
IdentityCredentialStore store = Util.getIdentityCredentialStore(appContext);
store.deleteCredentialByName("test");
@@ -520,7 +520,7 @@
@Test
public void testProvisionAndRetrieveMultipleTimes() throws IdentityCredentialException,
InvalidKeyException {
- Context appContext = InstrumentationRegistry.getTargetContext();
+ Context appContext = androidx.test.InstrumentationRegistry.getTargetContext();
IdentityCredentialStore store = Util.getIdentityCredentialStore(appContext);
// This checks we can do multiple getEntries() calls
@@ -577,7 +577,7 @@
@Test
public void testProvisionAndRetrieveWithFiltering() throws IdentityCredentialException {
- Context appContext = InstrumentationRegistry.getTargetContext();
+ Context appContext = androidx.test.InstrumentationRegistry.getTargetContext();
IdentityCredentialStore store = Util.getIdentityCredentialStore(appContext);
store.deleteCredentialByName("test");
@@ -627,7 +627,7 @@
@Test
public void testProvisionAndRetrieveElementWithNoACP() throws IdentityCredentialException {
- Context appContext = InstrumentationRegistry.getTargetContext();
+ Context appContext = androidx.test.InstrumentationRegistry.getTargetContext();
IdentityCredentialStore store = Util.getIdentityCredentialStore(appContext);
store.deleteCredentialByName("test");
@@ -665,7 +665,7 @@
@Test
public void testProvisionAndRetrieveWithEntryNotInRequest() throws IdentityCredentialException {
- Context appContext = InstrumentationRegistry.getTargetContext();
+ Context appContext = androidx.test.InstrumentationRegistry.getTargetContext();
IdentityCredentialStore store = Util.getIdentityCredentialStore(appContext);
store.deleteCredentialByName("test");
@@ -718,7 +718,7 @@
@Test
public void nonExistentEntries() throws IdentityCredentialException {
- Context appContext = InstrumentationRegistry.getTargetContext();
+ Context appContext = androidx.test.InstrumentationRegistry.getTargetContext();
IdentityCredentialStore store = Util.getIdentityCredentialStore(appContext);
store.deleteCredentialByName("test");
@@ -760,7 +760,7 @@
@Test
public void multipleNamespaces() throws IdentityCredentialException, CborException {
- Context appContext = InstrumentationRegistry.getTargetContext();
+ Context appContext = androidx.test.InstrumentationRegistry.getTargetContext();
IdentityCredentialStore store = Util.getIdentityCredentialStore(appContext);
store.deleteCredentialByName("test");
diff --git a/security/identity-credential/src/androidTest/java/androidx/security/identity/cts/ReaderAuthTest.java b/security/identity-credential/src/androidTest/java/androidx/security/identity/cts/ReaderAuthTest.java
index aba2975..f2446c7 100644
--- a/security/identity-credential/src/androidTest/java/androidx/security/identity/cts/ReaderAuthTest.java
+++ b/security/identity-credential/src/androidTest/java/androidx/security/identity/cts/ReaderAuthTest.java
@@ -38,7 +38,6 @@
import androidx.security.identity.PersonalizationData;
import androidx.security.identity.ResultData;
import androidx.security.identity.WritableIdentityCredential;
-import androidx.test.InstrumentationRegistry;
import androidx.test.ext.junit.runners.AndroidJUnit4;
import androidx.test.filters.LargeTest;
@@ -84,6 +83,7 @@
return kpg.generateKeyPair();
}
+ @SuppressWarnings("deprecation")
@Test
public void readerAuth()
throws IdentityCredentialException, CborException, InvalidAlgorithmParameterException,
@@ -158,7 +158,7 @@
certChainForBwithC.add(certC);
// Provision the credential.
- Context appContext = InstrumentationRegistry.getTargetContext();
+ Context appContext = androidx.test.InstrumentationRegistry.getTargetContext();
IdentityCredentialStore store = Util.getIdentityCredentialStore(appContext);
String credentialName = "readerAuthTestCredential";
diff --git a/security/identity-credential/src/androidTest/java/androidx/security/identity/cts/X509CertificateSigningTest.java b/security/identity-credential/src/androidTest/java/androidx/security/identity/cts/X509CertificateSigningTest.java
index 336e84a..53cbedf 100644
--- a/security/identity-credential/src/androidTest/java/androidx/security/identity/cts/X509CertificateSigningTest.java
+++ b/security/identity-credential/src/androidTest/java/androidx/security/identity/cts/X509CertificateSigningTest.java
@@ -28,7 +28,6 @@
import android.util.AtomicFile;
import android.util.Log;
-import androidx.test.InstrumentationRegistry;
import androidx.test.ext.junit.runners.AndroidJUnit4;
import androidx.test.filters.MediumTest;
@@ -49,6 +48,7 @@
import java.security.cert.CertificateException;
import java.security.cert.X509Certificate;
+@SuppressWarnings("deprecation")
@MediumTest
@RunWith(AndroidJUnit4.class)
public class X509CertificateSigningTest {
@@ -57,7 +57,7 @@
@Test
public void testSigning() {
- Context appContext = InstrumentationRegistry.getTargetContext();
+ Context appContext = androidx.test.InstrumentationRegistry.getTargetContext();
String keyToSignAlias = "testKeyToSign";
String keyToSignWithAlias = "testKeyToSignWith";
diff --git a/sharetarget/sharetarget/src/androidTest/java/androidx/sharetarget/ChooserTargetServiceCompatTest.java b/sharetarget/sharetarget/src/androidTest/java/androidx/sharetarget/ChooserTargetServiceCompatTest.java
index e4d5212..068467b 100644
--- a/sharetarget/sharetarget/src/androidTest/java/androidx/sharetarget/ChooserTargetServiceCompatTest.java
+++ b/sharetarget/sharetarget/src/androidTest/java/androidx/sharetarget/ChooserTargetServiceCompatTest.java
@@ -27,7 +27,6 @@
import android.content.Context;
import android.content.ContextWrapper;
import android.content.Intent;
-import android.service.chooser.ChooserTarget;
import androidx.core.content.pm.ShortcutInfoCompat;
import androidx.core.content.pm.ShortcutManagerCompat;
@@ -64,6 +63,7 @@
when(mShortcutSaver.getShortcutIcon(any())).thenReturn(mTestIcon);
}
+ @SuppressWarnings({"deprecation", "unchecked"})
@Test
@SdkSuppress(minSdkVersion = 23)
public void testConvertShortcutstoChooserTargets() {
@@ -87,7 +87,7 @@
// Need to clone to keep the original order for testing.
ArrayList<ShortcutHolder> clonedList = (ArrayList<ShortcutHolder>) testShortcuts.clone();
- List<ChooserTarget> chooserTargets =
+ List<android.service.chooser.ChooserTarget> chooserTargets =
ChooserTargetServiceCompat.convertShortcutsToChooserTargets(
mShortcutSaver, clonedList);
@@ -96,7 +96,7 @@
assertEquals(testShortcuts.size(), chooserTargets.size());
for (int i = 0; i < chooserTargets.size(); i++) {
- ChooserTarget ct = chooserTargets.get(i);
+ android.service.chooser.ChooserTarget ct = chooserTargets.get(i);
ShortcutInfoCompat si = testShortcuts.get(expectedOrder[i]).getShortcut();
ComponentName cn = testShortcuts.get(expectedOrder[i]).getTargetClass();
diff --git a/slices/benchmark/src/androidTest/java/androidx/slice/SliceSerializeMetrics.java b/slices/benchmark/src/androidTest/java/androidx/slice/SliceSerializeMetrics.java
index de9e87a..5e843ea 100644
--- a/slices/benchmark/src/androidTest/java/androidx/slice/SliceSerializeMetrics.java
+++ b/slices/benchmark/src/androidTest/java/androidx/slice/SliceSerializeMetrics.java
@@ -21,8 +21,7 @@
import static android.app.slice.SliceItem.FORMAT_SLICE;
import static android.app.slice.SliceItem.FORMAT_TEXT;
-import static junit.framework.Assert.assertEquals;
-
+import static org.junit.Assert.assertEquals;
import static org.junit.Assert.assertNotNull;
import android.app.PendingIntent;
diff --git a/slices/view/api/current.txt b/slices/view/api/current.txt
index 47aa153..222c2f4 100644
--- a/slices/view/api/current.txt
+++ b/slices/view/api/current.txt
@@ -146,6 +146,7 @@
ctor public SliceView(android.content.Context!, android.util.AttributeSet?);
ctor public SliceView(android.content.Context!, android.util.AttributeSet?, int);
ctor @RequiresApi(21) public SliceView(android.content.Context!, android.util.AttributeSet!, int, int);
+ method protected void configureViewPolicy(int);
method public int getHiddenItemCount();
method public int getMode();
method public androidx.slice.Slice? getSlice();
diff --git a/slices/view/api/public_plus_experimental_current.txt b/slices/view/api/public_plus_experimental_current.txt
index 47aa153..222c2f4 100644
--- a/slices/view/api/public_plus_experimental_current.txt
+++ b/slices/view/api/public_plus_experimental_current.txt
@@ -146,6 +146,7 @@
ctor public SliceView(android.content.Context!, android.util.AttributeSet?);
ctor public SliceView(android.content.Context!, android.util.AttributeSet?, int);
ctor @RequiresApi(21) public SliceView(android.content.Context!, android.util.AttributeSet!, int, int);
+ method protected void configureViewPolicy(int);
method public int getHiddenItemCount();
method public int getMode();
method public androidx.slice.Slice? getSlice();
diff --git a/slices/view/api/restricted_current.txt b/slices/view/api/restricted_current.txt
index 4e85c2a..09f2209 100644
--- a/slices/view/api/restricted_current.txt
+++ b/slices/view/api/restricted_current.txt
@@ -248,6 +248,7 @@
ctor public SliceView(android.content.Context!, android.util.AttributeSet?);
ctor public SliceView(android.content.Context!, android.util.AttributeSet?, int);
ctor @RequiresApi(21) public SliceView(android.content.Context!, android.util.AttributeSet!, int, int);
+ method protected void configureViewPolicy(int);
method public int getHiddenItemCount();
method public int getMode();
method public androidx.slice.Slice? getSlice();
diff --git a/slices/view/src/androidTest/java/androidx/slice/widget/CachedSliceLiveDataTest.java b/slices/view/src/androidTest/java/androidx/slice/widget/CachedSliceLiveDataTest.java
index 9c35fc2..e7c7ac7 100644
--- a/slices/view/src/androidTest/java/androidx/slice/widget/CachedSliceLiveDataTest.java
+++ b/slices/view/src/androidTest/java/androidx/slice/widget/CachedSliceLiveDataTest.java
@@ -57,6 +57,7 @@
import java.io.InputStream;
import java.util.concurrent.CountDownLatch;
+@SuppressWarnings("unchecked")
@RunWith(AndroidJUnit4.class)
@SmallTest
@SdkSuppress(minSdkVersion = 19)
diff --git a/slices/view/src/androidTest/java/androidx/slice/widget/SliceLiveDataTest.java b/slices/view/src/androidTest/java/androidx/slice/widget/SliceLiveDataTest.java
index 88b0eb6..6e34c93 100644
--- a/slices/view/src/androidTest/java/androidx/slice/widget/SliceLiveDataTest.java
+++ b/slices/view/src/androidTest/java/androidx/slice/widget/SliceLiveDataTest.java
@@ -60,6 +60,7 @@
import java.io.InputStream;
import java.util.concurrent.CountDownLatch;
+@SuppressWarnings("unchecked")
@RunWith(AndroidJUnit4.class)
@MediumTest
@SdkSuppress(minSdkVersion = 19)
diff --git a/slices/view/src/main/java/androidx/slice/widget/SliceView.java b/slices/view/src/main/java/androidx/slice/widget/SliceView.java
index 1bbd4c7..bc77fc1 100644
--- a/slices/view/src/main/java/androidx/slice/widget/SliceView.java
+++ b/slices/view/src/main/java/androidx/slice/widget/SliceView.java
@@ -345,7 +345,10 @@
}
}
- private void configureViewPolicy(int maxHeight) {
+ /**
+ * Sets the maximum height for a slice through the view policy.
+ */
+ protected void configureViewPolicy(int maxHeight) {
if (mListContent != null && mListContent.isValid() && getMode() != MODE_SHORTCUT) {
if (maxHeight > 0 && maxHeight < mSliceStyle.getRowMaxHeight()) {
if (maxHeight <= mMinTemplateHeight) {
diff --git a/swiperefreshlayout/swiperefreshlayout/src/androidTest/java/androidx/swiperefreshlayout/widget/CircularProgressDrawableTest.java b/swiperefreshlayout/swiperefreshlayout/src/androidTest/java/androidx/swiperefreshlayout/widget/CircularProgressDrawableTest.java
index 14759bd..a554e07 100644
--- a/swiperefreshlayout/swiperefreshlayout/src/androidTest/java/androidx/swiperefreshlayout/widget/CircularProgressDrawableTest.java
+++ b/swiperefreshlayout/swiperefreshlayout/src/androidTest/java/androidx/swiperefreshlayout/widget/CircularProgressDrawableTest.java
@@ -32,7 +32,6 @@
import androidx.test.ext.junit.runners.AndroidJUnit4;
import androidx.test.filters.SmallTest;
-import androidx.test.rule.ActivityTestRule;
import org.junit.Before;
import org.junit.Rule;
@@ -46,9 +45,11 @@
*/
@RunWith(AndroidJUnit4.class)
public class CircularProgressDrawableTest {
+ @SuppressWarnings("deprecation")
@Rule
- public final ActivityTestRule<CircularProgressDrawableActivity> mActivityTestRule =
- new ActivityTestRule<>(CircularProgressDrawableActivity.class);
+ public final androidx.test.rule.ActivityTestRule<CircularProgressDrawableActivity>
+ mActivityTestRule =
+ new androidx.test.rule.ActivityTestRule<>(CircularProgressDrawableActivity.class);
private CircularProgressDrawable mDrawableUnderTest;
diff --git a/swiperefreshlayout/swiperefreshlayout/src/androidTest/java/androidx/swiperefreshlayout/widget/SwipeRefreshLayoutInScrollingParentBaseTest.java b/swiperefreshlayout/swiperefreshlayout/src/androidTest/java/androidx/swiperefreshlayout/widget/SwipeRefreshLayoutInScrollingParentBaseTest.java
index ad2a176..6486134 100644
--- a/swiperefreshlayout/swiperefreshlayout/src/androidTest/java/androidx/swiperefreshlayout/widget/SwipeRefreshLayoutInScrollingParentBaseTest.java
+++ b/swiperefreshlayout/swiperefreshlayout/src/androidTest/java/androidx/swiperefreshlayout/widget/SwipeRefreshLayoutInScrollingParentBaseTest.java
@@ -31,7 +31,6 @@
import androidx.recyclerview.widget.LinearLayoutManager;
import androidx.recyclerview.widget.RecyclerView;
import androidx.test.platform.app.InstrumentationRegistry;
-import androidx.test.rule.ActivityTestRule;
import androidx.testutils.PollingCheck;
import androidx.testutils.SwipeInjector;
@@ -41,9 +40,11 @@
public abstract class SwipeRefreshLayoutInScrollingParentBaseTest {
+ @SuppressWarnings("deprecation")
@Rule
- public final ActivityTestRule<? extends SwipeRefreshLayoutInRecyclerViewBaseActivity>
- mActivityTestRule = new ActivityTestRule<>(getActivityClass());
+ public final androidx.test.rule
+ .ActivityTestRule<? extends SwipeRefreshLayoutInRecyclerViewBaseActivity>
+ mActivityTestRule = new androidx.test.rule.ActivityTestRule<>(getActivityClass());
private RecyclerView mRecyclerView;
private LinearLayoutManager mLayoutManager;
diff --git a/swiperefreshlayout/swiperefreshlayout/src/androidTest/java/androidx/swiperefreshlayout/widget/SwipeRefreshLayoutRequestDisallowInterceptBaseTest.java b/swiperefreshlayout/swiperefreshlayout/src/androidTest/java/androidx/swiperefreshlayout/widget/SwipeRefreshLayoutRequestDisallowInterceptBaseTest.java
index 3fa3f7b..87d8cde 100644
--- a/swiperefreshlayout/swiperefreshlayout/src/androidTest/java/androidx/swiperefreshlayout/widget/SwipeRefreshLayoutRequestDisallowInterceptBaseTest.java
+++ b/swiperefreshlayout/swiperefreshlayout/src/androidTest/java/androidx/swiperefreshlayout/widget/SwipeRefreshLayoutRequestDisallowInterceptBaseTest.java
@@ -25,7 +25,6 @@
import android.view.ViewConfiguration;
import androidx.test.platform.app.InstrumentationRegistry;
-import androidx.test.rule.ActivityTestRule;
import androidx.testutils.SwipeInjector;
import org.junit.Before;
@@ -34,9 +33,11 @@
public abstract class SwipeRefreshLayoutRequestDisallowInterceptBaseTest {
+ @SuppressWarnings("deprecation")
@Rule
- public final ActivityTestRule<? extends SwipeRefreshLayoutInRecyclerViewBaseActivity>
- mActivityTestRule = new ActivityTestRule<>(getActivityClass());
+ public final androidx.test.rule
+ .ActivityTestRule<? extends SwipeRefreshLayoutInRecyclerViewBaseActivity>
+ mActivityTestRule = new androidx.test.rule.ActivityTestRule<>(getActivityClass());
private RequestDisallowInterceptRecordingRecyclerView mRecyclerView;
private int mTouchSlop;
diff --git a/swiperefreshlayout/swiperefreshlayout/src/androidTest/java/androidx/swiperefreshlayout/widget/SwipeRefreshLayoutTest.java b/swiperefreshlayout/swiperefreshlayout/src/androidTest/java/androidx/swiperefreshlayout/widget/SwipeRefreshLayoutTest.java
index caf7544..bf17eca 100644
--- a/swiperefreshlayout/swiperefreshlayout/src/androidTest/java/androidx/swiperefreshlayout/widget/SwipeRefreshLayoutTest.java
+++ b/swiperefreshlayout/swiperefreshlayout/src/androidTest/java/androidx/swiperefreshlayout/widget/SwipeRefreshLayoutTest.java
@@ -38,7 +38,6 @@
import androidx.test.filters.FlakyTest;
import androidx.test.filters.LargeTest;
import androidx.test.filters.SmallTest;
-import androidx.test.rule.ActivityTestRule;
import androidx.testutils.PollingCheck;
import org.junit.Before;
@@ -55,9 +54,10 @@
@LargeTest
@RunWith(AndroidJUnit4.class)
public class SwipeRefreshLayoutTest {
+ @SuppressWarnings("deprecation")
@Rule
- public final ActivityTestRule<SwipeRefreshLayoutActivity> mActivityTestRule =
- new ActivityTestRule<>(SwipeRefreshLayoutActivity.class);
+ public final androidx.test.rule.ActivityTestRule<SwipeRefreshLayoutActivity> mActivityTestRule =
+ new androidx.test.rule.ActivityTestRule<>(SwipeRefreshLayoutActivity.class);
private static final long TIMEOUT = 1000;
private static final int INVALID_SIZE = 1000;
diff --git a/swiperefreshlayout/swiperefreshlayout/src/androidTest/java/androidx/swiperefreshlayout/widget/SwipeRefreshLayoutWithHorizontallyScrollingChildTest.java b/swiperefreshlayout/swiperefreshlayout/src/androidTest/java/androidx/swiperefreshlayout/widget/SwipeRefreshLayoutWithHorizontallyScrollingChildTest.java
index e041327..66631cd 100644
--- a/swiperefreshlayout/swiperefreshlayout/src/androidTest/java/androidx/swiperefreshlayout/widget/SwipeRefreshLayoutWithHorizontallyScrollingChildTest.java
+++ b/swiperefreshlayout/swiperefreshlayout/src/androidTest/java/androidx/swiperefreshlayout/widget/SwipeRefreshLayoutWithHorizontallyScrollingChildTest.java
@@ -41,7 +41,6 @@
import androidx.recyclerview.widget.LinearLayoutManager;
import androidx.recyclerview.widget.RecyclerView;
import androidx.test.platform.app.InstrumentationRegistry;
-import androidx.test.rule.ActivityTestRule;
import androidx.testutils.SwipeInjector;
import org.junit.Before;
@@ -52,8 +51,8 @@
@Rule
@SuppressWarnings("deprecation")
- public final ActivityTestRule<ComponentActivity>
- mActivityTestRule = new ActivityTestRule<>(ComponentActivity.class);
+ public final androidx.test.rule.ActivityTestRule<ComponentActivity>
+ mActivityTestRule = new androidx.test.rule.ActivityTestRule<>(ComponentActivity.class);
private SwipeRefreshLayout mSwipeRefreshLayout;
private RecyclerView mRecyclerView;
diff --git a/tracing/tracing/src/androidTest/java/androidx/tracing/TraceTest.java b/tracing/tracing/src/androidTest/java/androidx/tracing/TraceTest.java
index 1ac1834..1e24c25 100644
--- a/tracing/tracing/src/androidTest/java/androidx/tracing/TraceTest.java
+++ b/tracing/tracing/src/androidTest/java/androidx/tracing/TraceTest.java
@@ -16,8 +16,8 @@
package androidx.tracing;
-import static junit.framework.Assert.assertFalse;
-import static junit.framework.TestCase.assertTrue;
+import static org.junit.Assert.assertFalse;
+import static org.junit.Assert.assertTrue;
import static java.nio.charset.StandardCharsets.UTF_8;
diff --git a/transition/transition/src/androidTest/java/androidx/transition/BaseTest.java b/transition/transition/src/androidTest/java/androidx/transition/BaseTest.java
index 7e934e0..1736a8b 100644
--- a/transition/transition/src/androidTest/java/androidx/transition/BaseTest.java
+++ b/transition/transition/src/androidTest/java/androidx/transition/BaseTest.java
@@ -17,19 +17,19 @@
package androidx.transition;
import androidx.test.ext.junit.runners.AndroidJUnit4;
-import androidx.test.rule.ActivityTestRule;
import org.junit.Rule;
import org.junit.runner.RunWith;
@RunWith(AndroidJUnit4.class)
public abstract class BaseTest {
-
+ @SuppressWarnings("deprecation")
@Rule
- public final ActivityTestRule<TransitionActivity> rule;
+ public final androidx.test.rule.ActivityTestRule<TransitionActivity> rule;
+ @SuppressWarnings("deprecation")
BaseTest() {
- rule = new ActivityTestRule<>(TransitionActivity.class);
+ rule = new androidx.test.rule.ActivityTestRule<>(TransitionActivity.class);
}
}
diff --git a/transition/transition/src/androidTest/java/androidx/transition/TransitionActivity.java b/transition/transition/src/androidTest/java/androidx/transition/TransitionActivity.java
index 8ce0767..002c7d4 100644
--- a/transition/transition/src/androidTest/java/androidx/transition/TransitionActivity.java
+++ b/transition/transition/src/androidTest/java/androidx/transition/TransitionActivity.java
@@ -28,6 +28,7 @@
private LinearLayout mRoot;
+ @SuppressWarnings("deprecation")
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
diff --git a/vectordrawable/vectordrawable-animated/build.gradle b/vectordrawable/vectordrawable-animated/build.gradle
index c188aac..57a3bf7 100644
--- a/vectordrawable/vectordrawable-animated/build.gradle
+++ b/vectordrawable/vectordrawable-animated/build.gradle
@@ -46,4 +46,5 @@
mavenGroup = LibraryGroups.VECTORDRAWABLE
inceptionYear = "2015"
description = "Android Support AnimatedVectorDrawable"
+ failOnDeprecationWarnings = false
}
diff --git a/viewpager/viewpager/build.gradle b/viewpager/viewpager/build.gradle
index 656aa08..7194986 100644
--- a/viewpager/viewpager/build.gradle
+++ b/viewpager/viewpager/build.gradle
@@ -35,4 +35,5 @@
mavenGroup = LibraryGroups.VIEWPAGER
inceptionYear = "2018"
description = "The Support Library is a static library that you can add to your Android application in order to use APIs that are either not available for older platform versions or utility APIs that aren't a part of the framework APIs. Compatible on devices running API 14 or later."
+ failOnDeprecationWarnings = false
}
diff --git a/wear/wear-input/src/test/java/androidx/wear/input/WearableButtonsTest.java b/wear/wear-input/src/test/java/androidx/wear/input/WearableButtonsTest.java
index 08c26d8..1c1f420 100644
--- a/wear/wear-input/src/test/java/androidx/wear/input/WearableButtonsTest.java
+++ b/wear/wear-input/src/test/java/androidx/wear/input/WearableButtonsTest.java
@@ -295,6 +295,7 @@
assertEquals(4, info.getY(), 1.0e-7);
}
+ @SuppressWarnings("deprecation")
@Test
public void testGetButtonsLeftyNoData() {
Context context = ApplicationProvider.getApplicationContext();
diff --git a/wear/wear-watchface-complications-rendering/src/test/java/androidx/wear/watchface/complications/rendering/RoundedDrawableTest.java b/wear/wear-watchface-complications-rendering/src/test/java/androidx/wear/watchface/complications/rendering/RoundedDrawableTest.java
index c909f57..a3b5fa2 100644
--- a/wear/wear-watchface-complications-rendering/src/test/java/androidx/wear/watchface/complications/rendering/RoundedDrawableTest.java
+++ b/wear/wear-watchface-complications-rendering/src/test/java/androidx/wear/watchface/complications/rendering/RoundedDrawableTest.java
@@ -63,6 +63,7 @@
Bitmap.createBitmap(BITMAP_WIDTH, BITMAP_HEIGHT, Bitmap.Config.ARGB_8888));
}
+ @SuppressWarnings("deprecation")
@Test
public void colorFilterIsAppliedCorrectly() {
ColorFilter cf = new ColorFilter();
diff --git a/wear/wear/build.gradle b/wear/wear/build.gradle
index 09fdd9a..3c16a59 100644
--- a/wear/wear/build.gradle
+++ b/wear/wear/build.gradle
@@ -60,4 +60,5 @@
mavenVersion = LibraryVersions.WEAR
inceptionYear = "2016"
description = "Android Wear Support UI"
+ failOnDeprecationWarnings = false
}
diff --git a/wear/wear/src/androidTest/java/androidx/wear/widget/WearableRecyclerViewTest.java b/wear/wear/src/androidTest/java/androidx/wear/widget/WearableRecyclerViewTest.java
index 840bb02..03e34be 100644
--- a/wear/wear/src/androidTest/java/androidx/wear/widget/WearableRecyclerViewTest.java
+++ b/wear/wear/src/androidTest/java/androidx/wear/widget/WearableRecyclerViewTest.java
@@ -154,6 +154,7 @@
mActivityRule.getScenario().onActivity(activity -> {
activity.runOnUiThread(new Runnable() {
@Override
+ @SuppressWarnings("unchecked")
public void run() {
WearableRecyclerView wrv = (WearableRecyclerView) activity.findViewById(
R.id.wrv);
diff --git a/wear/wear/src/androidTest/java/androidx/wear/widget/drawer/WearableDrawerLayoutEspressoTest.java b/wear/wear/src/androidTest/java/androidx/wear/widget/drawer/WearableDrawerLayoutEspressoTest.java
index 9d48837..36f4a4a 100644
--- a/wear/wear/src/androidTest/java/androidx/wear/widget/drawer/WearableDrawerLayoutEspressoTest.java
+++ b/wear/wear/src/androidTest/java/androidx/wear/widget/drawer/WearableDrawerLayoutEspressoTest.java
@@ -701,6 +701,7 @@
* Returns the first child of {@code root} to be an instance of class {@code T}, or {@code null}
* if none were found.
*/
+ @SuppressWarnings("unchecked")
@Nullable
private <T> T getChildByType(View root, Class<T> classOfChildToFind) {
for (View child : TreeIterables.breadthFirstViewTraversal(root)) {
diff --git a/webkit/webkit/src/androidTest/java/androidx/webkit/WebSettingsCompatForceDarkTest.java b/webkit/webkit/src/androidTest/java/androidx/webkit/WebSettingsCompatForceDarkTest.java
index 3e06afc..7b7806e 100644
--- a/webkit/webkit/src/androidTest/java/androidx/webkit/WebSettingsCompatForceDarkTest.java
+++ b/webkit/webkit/src/androidTest/java/androidx/webkit/WebSettingsCompatForceDarkTest.java
@@ -29,7 +29,6 @@
import androidx.core.graphics.ColorUtils;
import androidx.test.ext.junit.runners.AndroidJUnit4;
import androidx.test.filters.MediumTest;
-import androidx.test.rule.ActivityTestRule;
import org.junit.After;
import org.junit.Before;
@@ -61,9 +60,10 @@
// LayoutParams are null until WebView has a parent Activity.
// Test testForceDark_rendersDark requires LayoutParams to define
// width and height of WebView to capture its bitmap representation.
+ @SuppressWarnings("deprecation")
@Rule
- public final ActivityTestRule<WebViewTestActivity> mActivityRule =
- new ActivityTestRule<>(WebViewTestActivity.class);
+ public final androidx.test.rule.ActivityTestRule<WebViewTestActivity> mActivityRule =
+ new androidx.test.rule.ActivityTestRule<>(WebViewTestActivity.class);
private WebViewOnUiThread mWebViewOnUiThread;
@Before
diff --git a/webkit/webkit/src/androidTest/java/androidx/webkit/WebViewDocumentStartJavaScriptTest.java b/webkit/webkit/src/androidTest/java/androidx/webkit/WebViewDocumentStartJavaScriptTest.java
index d9ef604..2b1421f 100644
--- a/webkit/webkit/src/androidTest/java/androidx/webkit/WebViewDocumentStartJavaScriptTest.java
+++ b/webkit/webkit/src/androidTest/java/androidx/webkit/WebViewDocumentStartJavaScriptTest.java
@@ -46,7 +46,7 @@
private static final String JS_OBJECT_NAME = "myObject";
private static final String BASIC_USAGE = "<!DOCTYPE html><html><body></body></html>";
private static final String BASIC_SCRIPT = "myObject.postMessage('hello');";
- private static final Set<String> MATCH_EXAMPLE_COM = new HashSet(Arrays.asList(BASE_URI));
+ private static final Set<String> MATCH_EXAMPLE_COM = new HashSet<>(Arrays.asList(BASE_URI));
private WebViewOnUiThread mWebViewOnUiThread;
private TestWebMessageListener mListener = new TestWebMessageListener();
diff --git a/webkit/webkit/src/androidTest/java/androidx/webkit/WebViewWebMessageListenerTest.java b/webkit/webkit/src/androidTest/java/androidx/webkit/WebViewWebMessageListenerTest.java
index cedfdbb..ad67acc 100644
--- a/webkit/webkit/src/androidTest/java/androidx/webkit/WebViewWebMessageListenerTest.java
+++ b/webkit/webkit/src/androidTest/java/androidx/webkit/WebViewWebMessageListenerTest.java
@@ -58,7 +58,7 @@
+ " myObject.postMessage('hello');"
+ " </script>"
+ "</body></html>";
- private static final Set<String> MATCH_EXAMPLE_COM = new HashSet(Arrays.asList(BASE_URI));
+ private static final Set<String> MATCH_EXAMPLE_COM = new HashSet<>(Arrays.asList(BASE_URI));
private WebViewOnUiThread mWebViewOnUiThread;
private TestWebMessageListener mListener = new TestWebMessageListener();
diff --git a/window/window/src/androidTest/java/androidx/window/ExtensionWindowBackendTest.java b/window/window/src/androidTest/java/androidx/window/ExtensionWindowBackendTest.java
index 97fbd20..52a190b 100644
--- a/window/window/src/androidTest/java/androidx/window/ExtensionWindowBackendTest.java
+++ b/window/window/src/androidTest/java/androidx/window/ExtensionWindowBackendTest.java
@@ -52,7 +52,7 @@
import java.util.List;
/** Tests for {@link ExtensionWindowBackend} class. */
-@SuppressWarnings("deprecation") // TODO(b/173739071) remove DeviceState
+@SuppressWarnings({"deprecation", "unchecked"}) // TODO(b/173739071) remove DeviceState
@LargeTest
@RunWith(AndroidJUnit4.class)
public final class ExtensionWindowBackendTest extends WindowTestBase {
diff --git a/window/window/src/androidTest/java/androidx/window/WindowBackendTest.java b/window/window/src/androidTest/java/androidx/window/WindowBackendTest.java
index d807de5..1e88185 100644
--- a/window/window/src/androidTest/java/androidx/window/WindowBackendTest.java
+++ b/window/window/src/androidTest/java/androidx/window/WindowBackendTest.java
@@ -38,6 +38,7 @@
import java.util.concurrent.Executor;
/** Tests for {@link WindowBackend} class. */
+@SuppressWarnings("unchecked")
@LargeTest
@RunWith(AndroidJUnit4.class)
public final class WindowBackendTest extends WindowTestBase {
diff --git a/window/window/src/androidTest/java/androidx/window/WindowManagerTest.java b/window/window/src/androidTest/java/androidx/window/WindowManagerTest.java
index dddc9ef..83782d0 100644
--- a/window/window/src/androidTest/java/androidx/window/WindowManagerTest.java
+++ b/window/window/src/androidTest/java/androidx/window/WindowManagerTest.java
@@ -40,6 +40,7 @@
import java.util.concurrent.Executor;
/** Tests for {@link WindowManager} class. */
+@SuppressWarnings("unchecked")
@LargeTest
@RunWith(AndroidJUnit4.class)
public final class WindowManagerTest extends WindowTestBase {
diff --git a/work/workmanager/src/androidTest/java/androidx/work/impl/constraints/WorkConstraintsTrackerTest.java b/work/workmanager/src/androidTest/java/androidx/work/impl/constraints/WorkConstraintsTrackerTest.java
index 711f1e67..08dc032 100644
--- a/work/workmanager/src/androidTest/java/androidx/work/impl/constraints/WorkConstraintsTrackerTest.java
+++ b/work/workmanager/src/androidTest/java/androidx/work/impl/constraints/WorkConstraintsTrackerTest.java
@@ -74,6 +74,7 @@
mWorkConstraintsTracker = new WorkConstraintsTracker(mCallback, controllers);
}
+ @SuppressWarnings("unchecked")
@Test
public void testReplace() {
List<WorkSpec> emptyList = Collections.emptyList();
diff --git a/work/workmanager/src/androidTest/java/androidx/work/impl/constraints/controllers/ConstraintControllerTest.java b/work/workmanager/src/androidTest/java/androidx/work/impl/constraints/controllers/ConstraintControllerTest.java
index 5e48bef..5043e34 100644
--- a/work/workmanager/src/androidTest/java/androidx/work/impl/constraints/controllers/ConstraintControllerTest.java
+++ b/work/workmanager/src/androidTest/java/androidx/work/impl/constraints/controllers/ConstraintControllerTest.java
@@ -46,6 +46,7 @@
@SdkSuppress(minSdkVersion = 23)
public class ConstraintControllerTest extends WorkManagerTest {
private TestDeviceIdleConstraintController mTestIdleController;
+ @SuppressWarnings("unchecked")
private ConstraintTracker<Boolean> mMockTracker = mock(ConstraintTracker.class);
private ConstraintController.OnConstraintUpdatedCallback mCallback =
mock(ConstraintController.OnConstraintUpdatedCallback.class);
diff --git a/work/workmanager/src/androidTest/java/androidx/work/impl/constraints/trackers/BatteryChargingTrackerTest.java b/work/workmanager/src/androidTest/java/androidx/work/impl/constraints/trackers/BatteryChargingTrackerTest.java
index c59a654..f8c9da7 100644
--- a/work/workmanager/src/androidTest/java/androidx/work/impl/constraints/trackers/BatteryChargingTrackerTest.java
+++ b/work/workmanager/src/androidTest/java/androidx/work/impl/constraints/trackers/BatteryChargingTrackerTest.java
@@ -54,6 +54,7 @@
private ConstraintListener<Boolean> mListener;
private Context mMockContext;
+ @SuppressWarnings("unchecked")
@Before
public void setUp() {
mMockContext = mock(Context.class);
diff --git a/work/workmanager/src/androidTest/java/androidx/work/impl/constraints/trackers/BatteryNotLowTrackerTest.java b/work/workmanager/src/androidTest/java/androidx/work/impl/constraints/trackers/BatteryNotLowTrackerTest.java
index 8a593d5..f37c684 100644
--- a/work/workmanager/src/androidTest/java/androidx/work/impl/constraints/trackers/BatteryNotLowTrackerTest.java
+++ b/work/workmanager/src/androidTest/java/androidx/work/impl/constraints/trackers/BatteryNotLowTrackerTest.java
@@ -54,6 +54,7 @@
private BatteryNotLowTracker mTracker;
private ConstraintListener<Boolean> mListener;
+ @SuppressWarnings("unchecked")
@Before
public void setUp() {
mMockContext = mock(Context.class);
diff --git a/work/workmanager/src/androidTest/java/androidx/work/impl/constraints/trackers/ConstraintTrackerTest.java b/work/workmanager/src/androidTest/java/androidx/work/impl/constraints/trackers/ConstraintTrackerTest.java
index fc04e38..b3ee2dc 100644
--- a/work/workmanager/src/androidTest/java/androidx/work/impl/constraints/trackers/ConstraintTrackerTest.java
+++ b/work/workmanager/src/androidTest/java/androidx/work/impl/constraints/trackers/ConstraintTrackerTest.java
@@ -35,6 +35,7 @@
import org.junit.Test;
import org.junit.runner.RunWith;
+@SuppressWarnings("unchecked")
@SmallTest
@RunWith(AndroidJUnit4.class)
public class ConstraintTrackerTest {
@@ -79,6 +80,7 @@
assertThat(mTracker.mGetInitialStateCount, is(1));
}
+ @SuppressWarnings("unchecked")
@Test
public void testAddListener_sameListener_doesNotCallGetInitialStateAndStartTrackingTwice() {
ConstraintListener<Boolean> constraintListener = mock(ConstraintListener.class);
diff --git a/work/workmanager/src/androidTest/java/androidx/work/impl/constraints/trackers/NetworkStateTrackerTest.java b/work/workmanager/src/androidTest/java/androidx/work/impl/constraints/trackers/NetworkStateTrackerTest.java
index 38a03b9..0313e43 100644
--- a/work/workmanager/src/androidTest/java/androidx/work/impl/constraints/trackers/NetworkStateTrackerTest.java
+++ b/work/workmanager/src/androidTest/java/androidx/work/impl/constraints/trackers/NetworkStateTrackerTest.java
@@ -49,6 +49,7 @@
private Context mMockContext;
private ConnectivityManager mMockConnectivityManager;
+ @SuppressWarnings("unchecked")
@Before
public void setUp() {
mMockContext = mock(Context.class);
diff --git a/work/workmanager/src/androidTest/java/androidx/work/impl/constraints/trackers/StorageNotLowTrackerTest.java b/work/workmanager/src/androidTest/java/androidx/work/impl/constraints/trackers/StorageNotLowTrackerTest.java
index 59efc3f..af162d8 100644
--- a/work/workmanager/src/androidTest/java/androidx/work/impl/constraints/trackers/StorageNotLowTrackerTest.java
+++ b/work/workmanager/src/androidTest/java/androidx/work/impl/constraints/trackers/StorageNotLowTrackerTest.java
@@ -47,6 +47,7 @@
private ConstraintListener<Boolean> mListener;
private Context mMockContext;
+ @SuppressWarnings("unchecked")
@Before
public void setUp() {
mMockContext = mock(Context.class);