Merge "Supporting auto migrations in MigrationTestHelper." into androidx-main
diff --git a/appcompat/appcompat-resources/lint-baseline.xml b/appcompat/appcompat-resources/lint-baseline.xml
index 4982402..4826d47 100644
--- a/appcompat/appcompat-resources/lint-baseline.xml
+++ b/appcompat/appcompat-resources/lint-baseline.xml
@@ -112,94 +112,6 @@
</issue>
<issue
- id="ClassVerificationFailure"
- message="This call references a method added in API level 18; however, the containing class androidx.appcompat.graphics.drawable.AnimatedStateListDrawableCompat.AnimationDrawableTransition is reachable from earlier API levels and will fail run-time class verification."
- errorLine1=" anim.setAutoCancel(true);"
- errorLine2=" ~~~~~~~~~~~~~">
- <location
- file="src/main/java/androidx/appcompat/graphics/drawable/AnimatedStateListDrawableCompat.java"
- line="401"
- column="22"/>
- </issue>
-
- <issue
- id="ClassVerificationFailure"
- message="This call references a method added in API level 21; however, the containing class androidx.appcompat.graphics.drawable.AnimatedStateListDrawableCompat is reachable from earlier API levels and will fail run-time class verification."
- errorLine1=" state.mChangingConfigurations |= a.getChangingConfigurations();"
- errorLine2=" ~~~~~~~~~~~~~~~~~~~~~~~~~">
- <location
- file="src/main/java/androidx/appcompat/graphics/drawable/AnimatedStateListDrawableCompat.java"
- line="452"
- column="48"/>
- </issue>
-
- <issue
- id="ClassVerificationFailure"
- message="This call references a method added in API level 21; however, the containing class androidx.appcompat.graphics.drawable.AnimatedStateListDrawableCompat is reachable from earlier API levels and will fail run-time class verification."
- errorLine1=" dr = Drawable.createFromXmlInner(resources, parser, attrs, theme);"
- errorLine2=" ~~~~~~~~~~~~~~~~~~">
- <location
- file="src/main/java/androidx/appcompat/graphics/drawable/AnimatedStateListDrawableCompat.java"
- line="541"
- column="31"/>
- </issue>
-
- <issue
- id="ClassVerificationFailure"
- message="This call references a method added in API level 21; however, the containing class androidx.appcompat.graphics.drawable.AnimatedStateListDrawableCompat is reachable from earlier API levels and will fail run-time class verification."
- errorLine1=" dr = Drawable.createFromXmlInner(resources, parser, attrs, theme);"
- errorLine2=" ~~~~~~~~~~~~~~~~~~">
- <location
- file="src/main/java/androidx/appcompat/graphics/drawable/AnimatedStateListDrawableCompat.java"
- line="591"
- column="31"/>
- </issue>
-
- <issue
- id="ClassVerificationFailure"
- message="This call references a method added in API level 21; however, the containing class androidx.appcompat.widget.ResourceManagerInternal.DrawableDelegate is reachable from earlier API levels and will fail run-time class verification."
- errorLine1=" drawable.inflate(context.getResources(), parser, attrs, theme);"
- errorLine2=" ~~~~~~~">
- <location
- file="src/main/java/androidx/appcompat/widget/ResourceManagerInternal.java"
- line="565"
- column="34"/>
- </issue>
-
- <issue
- id="ClassVerificationFailure"
- message="This call references a method added in API level 15; however, the containing class androidx.appcompat.widget.ResourcesWrapper is reachable from earlier API levels and will fail run-time class verification."
- errorLine1=" mResources.getValueForDensity(id, density, outValue, resolveRefs);"
- errorLine2=" ~~~~~~~~~~~~~~~~~~">
- <location
- file="src/main/java/androidx/appcompat/widget/ResourcesWrapper.java"
- line="241"
- column="20"/>
- </issue>
-
- <issue
- id="ClassVerificationFailure"
- message="This call references a method added in API level 21; however, the containing class androidx.appcompat.graphics.drawable.StateListDrawable is reachable from earlier API levels and will fail run-time class verification."
- errorLine1=" state.mChangingConfigurations |= a.getChangingConfigurations();"
- errorLine2=" ~~~~~~~~~~~~~~~~~~~~~~~~~">
- <location
- file="src/main/java/androidx/appcompat/graphics/drawable/StateListDrawable.java"
- line="159"
- column="48"/>
- </issue>
-
- <issue
- id="ClassVerificationFailure"
- message="This call references a method added in API level 21; however, the containing class androidx.appcompat.graphics.drawable.StateListDrawable is reachable from earlier API levels and will fail run-time class verification."
- errorLine1=" dr = Drawable.createFromXmlInner(r, parser, attrs, theme);"
- errorLine2=" ~~~~~~~~~~~~~~~~~~">
- <location
- file="src/main/java/androidx/appcompat/graphics/drawable/StateListDrawable.java"
- line="218"
- column="35"/>
- </issue>
-
- <issue
id="KotlinPropertyAccess"
message="The getter return type (`Theme`) and setter parameter type (`int`) getter and setter methods for property `theme` should have exactly the same type to allow be accessed as a property from Kotlin; see https://android.github.io/kotlin-guides/interop.html#property-prefixes"
errorLine1=" public Resources.Theme getTheme() {"
diff --git a/appcompat/appcompat-resources/src/main/java/androidx/appcompat/graphics/drawable/AnimatedStateListDrawableCompat.java b/appcompat/appcompat-resources/src/main/java/androidx/appcompat/graphics/drawable/AnimatedStateListDrawableCompat.java
index f57aace..67c4235 100644
--- a/appcompat/appcompat-resources/src/main/java/androidx/appcompat/graphics/drawable/AnimatedStateListDrawableCompat.java
+++ b/appcompat/appcompat-resources/src/main/java/androidx/appcompat/graphics/drawable/AnimatedStateListDrawableCompat.java
@@ -39,6 +39,7 @@
import androidx.annotation.DrawableRes;
import androidx.annotation.NonNull;
import androidx.annotation.Nullable;
+import androidx.appcompat.resources.Compatibility;
import androidx.appcompat.resources.R;
import androidx.appcompat.widget.ResourceManagerInternal;
import androidx.collection.LongSparseArray;
@@ -398,7 +399,7 @@
final ObjectAnimator anim =
ObjectAnimator.ofInt(ad, "currentIndex", fromFrame, toFrame);
if (SDK_INT >= Build.VERSION_CODES.JELLY_BEAN_MR2) {
- anim.setAutoCancel(true);
+ Compatibility.Api18Impl.setAutoCancel(anim, true);
}
anim.setDuration(interp.getTotalDuration());
anim.setInterpolator(interp);
@@ -449,7 +450,7 @@
final AnimatedStateListState state = mState;
// Account for any configuration changes.
if (SDK_INT >= LOLLIPOP) {
- state.mChangingConfigurations |= a.getChangingConfigurations();
+ state.mChangingConfigurations |= Compatibility.Api21Impl.getChangingConfigurations(a);
}
// Extract the theme attributes, if any.
state.setVariablePadding(
@@ -538,7 +539,7 @@
dr = AnimatedVectorDrawableCompat.createFromXmlInner(context, resources, parser,
attrs, theme);
} else if (SDK_INT >= LOLLIPOP) {
- dr = Drawable.createFromXmlInner(resources, parser, attrs, theme);
+ dr = Compatibility.Api21Impl.createFromXmlInner(resources, parser, attrs, theme);
} else {
dr = Drawable.createFromXmlInner(resources, parser, attrs);
}
@@ -588,7 +589,7 @@
if (parser.getName().equals("vector")) {
dr = VectorDrawableCompat.createFromXmlInner(resources, parser, attrs, theme);
} else if (SDK_INT >= LOLLIPOP) {
- dr = Drawable.createFromXmlInner(resources, parser, attrs, theme);
+ dr = Compatibility.Api21Impl.createFromXmlInner(resources, parser, attrs, theme);
} else {
dr = Drawable.createFromXmlInner(resources, parser, attrs);
}
diff --git a/appcompat/appcompat-resources/src/main/java/androidx/appcompat/graphics/drawable/StateListDrawable.java b/appcompat/appcompat-resources/src/main/java/androidx/appcompat/graphics/drawable/StateListDrawable.java
index e501460..ceabac7 100644
--- a/appcompat/appcompat-resources/src/main/java/androidx/appcompat/graphics/drawable/StateListDrawable.java
+++ b/appcompat/appcompat-resources/src/main/java/androidx/appcompat/graphics/drawable/StateListDrawable.java
@@ -35,6 +35,7 @@
import androidx.annotation.Nullable;
import androidx.annotation.RequiresApi;
import androidx.annotation.RestrictTo;
+import androidx.appcompat.resources.Compatibility;
import androidx.appcompat.resources.R;
import androidx.appcompat.widget.ResourceManagerInternal;
@@ -156,7 +157,7 @@
final StateListState state = mStateListState;
// Account for any configuration changes.
if (SDK_INT >= LOLLIPOP) {
- state.mChangingConfigurations |= a.getChangingConfigurations();
+ state.mChangingConfigurations |= Compatibility.Api21Impl.getChangingConfigurations(a);
}
state.mVariablePadding = a.getBoolean(
R.styleable.StateListDrawable_android_variablePadding, state.mVariablePadding);
@@ -215,7 +216,7 @@
+ "child tag defining a drawable");
}
if (SDK_INT >= LOLLIPOP) {
- dr = Drawable.createFromXmlInner(r, parser, attrs, theme);
+ dr = Compatibility.Api21Impl.createFromXmlInner(r, parser, attrs, theme);
} else {
dr = Drawable.createFromXmlInner(r, parser, attrs);
}
diff --git a/appcompat/appcompat-resources/src/main/java/androidx/appcompat/resources/Compatibility.java b/appcompat/appcompat-resources/src/main/java/androidx/appcompat/resources/Compatibility.java
new file mode 100644
index 0000000..189b793
--- /dev/null
+++ b/appcompat/appcompat-resources/src/main/java/androidx/appcompat/resources/Compatibility.java
@@ -0,0 +1,99 @@
+/*
+ * Copyright 2021 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.appcompat.resources;
+
+import android.animation.ObjectAnimator;
+import android.content.res.Resources;
+import android.content.res.TypedArray;
+import android.graphics.drawable.Drawable;
+import android.util.AttributeSet;
+import android.util.TypedValue;
+
+import androidx.annotation.DoNotInline;
+import androidx.annotation.NonNull;
+import androidx.annotation.Nullable;
+import androidx.annotation.RequiresApi;
+import androidx.annotation.RestrictTo;
+
+import org.xmlpull.v1.XmlPullParser;
+import org.xmlpull.v1.XmlPullParserException;
+
+import java.io.IOException;
+
+/**
+ * Unified ApiXXImpls for appcompat-resources.
+ *
+ * @hide
+ */
+@RestrictTo(RestrictTo.Scope.LIBRARY)
+public final class Compatibility {
+ private Compatibility() {
+ // This class is not instantiable.
+ }
+
+ @RequiresApi(21)
+ public static class Api21Impl {
+ private Api21Impl() {
+ // This class is not instantiable.
+ }
+
+ @DoNotInline
+ public static void inflate(@NonNull Drawable drawable, @NonNull Resources r,
+ @NonNull XmlPullParser parser, @NonNull AttributeSet attrs,
+ @Nullable Resources.Theme theme) throws IOException, XmlPullParserException {
+ drawable.inflate(r, parser, attrs, theme);
+ }
+
+ @DoNotInline
+ public static int getChangingConfigurations(@NonNull TypedArray typedArray) {
+ return typedArray.getChangingConfigurations();
+ }
+
+ @NonNull
+ @DoNotInline
+ public static Drawable createFromXmlInner(@NonNull Resources r,
+ @NonNull XmlPullParser parser, @NonNull AttributeSet attrs,
+ @Nullable Resources.Theme theme) throws IOException, XmlPullParserException {
+ return Drawable.createFromXmlInner(r, parser, attrs, theme);
+ }
+ }
+
+ @RequiresApi(18)
+ public static class Api18Impl {
+ private Api18Impl() {
+ // This class is not instantiable.
+ }
+
+ @DoNotInline
+ public static void setAutoCancel(@NonNull ObjectAnimator objectAnimator, boolean cancel) {
+ objectAnimator.setAutoCancel(cancel);
+ }
+ }
+
+ @RequiresApi(15)
+ public static class Api15Impl {
+ private Api15Impl() {
+ // This class is not instantiable.
+ }
+
+ @DoNotInline
+ public static void getValueForDensity(@NonNull Resources resources, int id, int density,
+ @NonNull TypedValue outValue, boolean resolveRefs) {
+ resources.getValueForDensity(id, density, outValue, resolveRefs);
+ }
+ }
+}
diff --git a/appcompat/appcompat-resources/src/main/java/androidx/appcompat/widget/ResourceManagerInternal.java b/appcompat/appcompat-resources/src/main/java/androidx/appcompat/widget/ResourceManagerInternal.java
index dfb0754..a269912 100644
--- a/appcompat/appcompat-resources/src/main/java/androidx/appcompat/widget/ResourceManagerInternal.java
+++ b/appcompat/appcompat-resources/src/main/java/androidx/appcompat/widget/ResourceManagerInternal.java
@@ -38,6 +38,7 @@
import androidx.annotation.Nullable;
import androidx.annotation.RestrictTo;
import androidx.appcompat.graphics.drawable.AnimatedStateListDrawableCompat;
+import androidx.appcompat.resources.Compatibility;
import androidx.appcompat.resources.R;
import androidx.collection.LongSparseArray;
import androidx.collection.LruCache;
@@ -562,7 +563,8 @@
.asSubclass(Drawable.class);
Drawable drawable = drawableClass.getDeclaredConstructor().newInstance();
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.LOLLIPOP) {
- drawable.inflate(context.getResources(), parser, attrs, theme);
+ Compatibility.Api21Impl.inflate(drawable, context.getResources(), parser,
+ attrs, theme);
} else {
drawable.inflate(context.getResources(), parser, attrs);
}
diff --git a/appcompat/appcompat-resources/src/main/java/androidx/appcompat/widget/ResourcesWrapper.java b/appcompat/appcompat-resources/src/main/java/androidx/appcompat/widget/ResourcesWrapper.java
index d81cfe7..b854a9e 100644
--- a/appcompat/appcompat-resources/src/main/java/androidx/appcompat/widget/ResourcesWrapper.java
+++ b/appcompat/appcompat-resources/src/main/java/androidx/appcompat/widget/ResourcesWrapper.java
@@ -29,6 +29,7 @@
import android.util.TypedValue;
import androidx.annotation.RequiresApi;
+import androidx.appcompat.resources.Compatibility;
import androidx.core.content.res.ResourcesCompat;
import org.xmlpull.v1.XmlPullParserException;
@@ -238,7 +239,7 @@
@Override
public void getValueForDensity(int id, int density, TypedValue outValue, boolean resolveRefs)
throws NotFoundException {
- mResources.getValueForDensity(id, density, outValue, resolveRefs);
+ Compatibility.Api15Impl.getValueForDensity(mResources, id, density, outValue, resolveRefs);
}
@Override
diff --git a/appcompat/appcompat/api/current.txt b/appcompat/appcompat/api/current.txt
index e1847bb..d206436 100644
--- a/appcompat/appcompat/api/current.txt
+++ b/appcompat/appcompat/api/current.txt
@@ -317,6 +317,7 @@
public class AppCompatDialogFragment extends androidx.fragment.app.DialogFragment {
ctor public AppCompatDialogFragment();
+ ctor public AppCompatDialogFragment(@LayoutRes int);
}
public class AppCompatViewInflater {
diff --git a/appcompat/appcompat/api/public_plus_experimental_current.txt b/appcompat/appcompat/api/public_plus_experimental_current.txt
index cc92740..6cb8e4a 100644
--- a/appcompat/appcompat/api/public_plus_experimental_current.txt
+++ b/appcompat/appcompat/api/public_plus_experimental_current.txt
@@ -317,6 +317,7 @@
public class AppCompatDialogFragment extends androidx.fragment.app.DialogFragment {
ctor public AppCompatDialogFragment();
+ ctor public AppCompatDialogFragment(@LayoutRes int);
}
public class AppCompatViewInflater {
diff --git a/appcompat/appcompat/api/restricted_current.txt b/appcompat/appcompat/api/restricted_current.txt
index 7fa4fdb..fdc45fa 100644
--- a/appcompat/appcompat/api/restricted_current.txt
+++ b/appcompat/appcompat/api/restricted_current.txt
@@ -341,6 +341,7 @@
public class AppCompatDialogFragment extends androidx.fragment.app.DialogFragment {
ctor public AppCompatDialogFragment();
+ ctor public AppCompatDialogFragment(@LayoutRes int);
}
public class AppCompatViewInflater {
diff --git a/appcompat/appcompat/src/androidTest/AndroidManifest.xml b/appcompat/appcompat/src/androidTest/AndroidManifest.xml
index 7a8a2fb..590def4 100644
--- a/appcompat/appcompat/src/androidTest/AndroidManifest.xml
+++ b/appcompat/appcompat/src/androidTest/AndroidManifest.xml
@@ -239,6 +239,16 @@
android:configChanges="uiMode"/>
<activity
+ android:name="androidx.appcompat.app.NightModeUiModeConfigChangesActivityB"
+ android:theme="@style/Theme.AppCompat.DayNight"
+ android:configChanges="uiMode"/>
+
+ <activity
+ android:name="androidx.appcompat.app.NightModeUiModeConfigChangesActivityC"
+ android:theme="@style/Theme.AppCompat.DayNight"
+ android:configChanges="uiMode"/>
+
+ <activity
android:name="androidx.appcompat.app.NightModeRotateDoesNotRecreateActivity"
android:theme="@style/Theme.AppCompat.DayNight"
android:configChanges="orientation|screenSize"/>
diff --git a/appcompat/appcompat/src/androidTest/java/androidx/appcompat/app/AppCompatDialogFragmentTest.java b/appcompat/appcompat/src/androidTest/java/androidx/appcompat/app/AppCompatDialogFragmentTest.java
new file mode 100644
index 0000000..cf7049e
--- /dev/null
+++ b/appcompat/appcompat/src/androidTest/java/androidx/appcompat/app/AppCompatDialogFragmentTest.java
@@ -0,0 +1,96 @@
+/*
+ * Copyright (C) 2015 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.appcompat.app;
+
+import static org.junit.Assert.assertNotNull;
+import static org.junit.Assert.assertTrue;
+
+import android.app.Dialog;
+import android.os.Bundle;
+
+import androidx.annotation.NonNull;
+import androidx.appcompat.test.R;
+import androidx.fragment.app.DialogFragment;
+import androidx.test.ext.junit.runners.AndroidJUnit4;
+import androidx.test.filters.LargeTest;
+import androidx.test.platform.app.InstrumentationRegistry;
+
+import org.junit.Rule;
+import org.junit.Test;
+import org.junit.runner.RunWith;
+
+@LargeTest
+@RunWith(AndroidJUnit4.class)
+public class AppCompatDialogFragmentTest {
+ @SuppressWarnings("deprecation")
+ @Rule
+ public final androidx.test.rule.ActivityTestRule<WindowDecorAppCompatActivity> mTestRule =
+ new androidx.test.rule.ActivityTestRule<>(WindowDecorAppCompatActivity.class);
+
+ private DialogFragment mFragment;
+
+ @Test
+ public void testDialogFragmentShows() {
+ InstrumentationRegistry.getInstrumentation().waitForIdleSync();
+
+ InstrumentationRegistry.getInstrumentation().runOnMainSync(
+ () -> mFragment = new TestDialogFragment()
+ );
+ mFragment.show(mTestRule.getActivity().getSupportFragmentManager(), null);
+
+ InstrumentationRegistry.getInstrumentation().waitForIdleSync();
+
+ assertNotNull("Dialog was null", mFragment.getDialog());
+ assertTrue("Dialog was not being shown", mFragment.getDialog().isShowing());
+
+ // And make sure we dismiss the dialog
+ mFragment.dismissAllowingStateLoss();
+ }
+
+ @Test
+ public void testDialogFragmentWithLayout() {
+ InstrumentationRegistry.getInstrumentation().waitForIdleSync();
+
+ InstrumentationRegistry.getInstrumentation().runOnMainSync(
+ () -> mFragment = new AppCompatDialogFragment(R.layout.dialog_layout)
+ );
+ mFragment.show(mTestRule.getActivity().getSupportFragmentManager(), null);
+
+ InstrumentationRegistry.getInstrumentation().waitForIdleSync();
+
+ assertNotNull("Dialog is not null", mFragment.getDialog());
+ assertTrue("Dialog is showing", mFragment.getDialog().isShowing());
+ assertNotNull("Dialog is using custom layout",
+ mFragment.getDialog().findViewById(R.id.dialog_content));
+
+ // And make sure we dismiss the dialog
+ mFragment.dismissAllowingStateLoss();
+ }
+
+ public static class TestDialogFragment extends AppCompatDialogFragment {
+ @NonNull
+ @Override
+ public Dialog onCreateDialog(Bundle savedInstanceState) {
+ return new AlertDialog.Builder(requireContext())
+ .setTitle("Test")
+ .setMessage("Message")
+ .setPositiveButton("Button", null)
+ .create();
+ }
+ }
+}
+
diff --git a/appcompat/appcompat/src/androidTest/java/androidx/appcompat/app/DialogTestCase.java b/appcompat/appcompat/src/androidTest/java/androidx/appcompat/app/DialogTestCase.java
deleted file mode 100644
index 378cdf5..0000000
--- a/appcompat/appcompat/src/androidTest/java/androidx/appcompat/app/DialogTestCase.java
+++ /dev/null
@@ -1,77 +0,0 @@
-/*
- * Copyright (C) 2015 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.appcompat.app;
-
-import static org.junit.Assert.assertNotNull;
-import static org.junit.Assert.assertTrue;
-
-import android.app.Dialog;
-import android.os.Bundle;
-
-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.Rule;
-import org.junit.Test;
-import org.junit.runner.RunWith;
-
-@LargeTest
-@RunWith(AndroidJUnit4.class)
-public class DialogTestCase {
- @Rule
- public final ActivityTestRule<WindowDecorAppCompatActivity> mActivityTestRule =
- new ActivityTestRule<>(WindowDecorAppCompatActivity.class);
-
- private TestDialogFragment mFragment;
-
- @Test
- public void testDialogFragmentShows() {
- InstrumentationRegistry.getInstrumentation().waitForIdleSync();
-
- InstrumentationRegistry.getInstrumentation().runOnMainSync(
- new Runnable() {
- @Override
- public void run() {
- mFragment = new TestDialogFragment();
- }
- }
- );
- mFragment.show(mActivityTestRule.getActivity().getSupportFragmentManager(), null);
-
- InstrumentationRegistry.getInstrumentation().waitForIdleSync();
-
- assertNotNull("Dialog was null", mFragment.getDialog());
- assertTrue("Dialog was not being shown", mFragment.getDialog().isShowing());
-
- // And make sure we dismiss the dialog
- mFragment.dismissAllowingStateLoss();
- }
-
- public static class TestDialogFragment extends AppCompatDialogFragment {
- @Override
- public Dialog onCreateDialog(Bundle savedInstanceState) {
- return new AlertDialog.Builder(getContext())
- .setTitle("Test")
- .setMessage("Message")
- .setPositiveButton("Button", null)
- .create();
- }
- }
-}
-
diff --git a/appcompat/appcompat/src/androidTest/java/androidx/appcompat/app/NightModeStackedHandlingTestCase.kt b/appcompat/appcompat/src/androidTest/java/androidx/appcompat/app/NightModeStackedHandlingTestCase.kt
index 62f9285..d078551 100644
--- a/appcompat/appcompat/src/androidTest/java/androidx/appcompat/app/NightModeStackedHandlingTestCase.kt
+++ b/appcompat/appcompat/src/androidTest/java/androidx/appcompat/app/NightModeStackedHandlingTestCase.kt
@@ -14,7 +14,7 @@
* limitations under the License.
*/
-@file:Suppress("DEPRECATION")
+@file:Suppress("deprecation")
package androidx.appcompat.app
@@ -23,14 +23,19 @@
import android.app.Instrumentation.ActivityMonitor
import android.content.Intent
import android.content.res.Configuration
+import android.os.Handler
+import android.os.Looper
import androidx.appcompat.app.AppCompatDelegate.MODE_NIGHT_NO
import androidx.appcompat.app.AppCompatDelegate.MODE_NIGHT_YES
import androidx.appcompat.testutils.NightModeUtils
+import androidx.lifecycle.Lifecycle
import androidx.test.ext.junit.runners.AndroidJUnit4
import androidx.test.filters.LargeTest
import androidx.test.filters.SdkSuppress
import androidx.test.platform.app.InstrumentationRegistry
+import androidx.testutils.LifecycleOwnerUtils.waitUntilState
import junit.framework.Assert.assertNotNull
+import junit.framework.Assert.assertNotSame
import org.junit.Test
import org.junit.runner.RunWith
@@ -84,7 +89,7 @@
)
// From activity A, start activity B.
- var activityA = monitorA.waitForActivityWithTimeout(3000) as NightModeActivity
+ val activityA = monitorA.waitForActivityWithTimeout(3000) as NightModeActivity
assertNotNull(activityA)
activityA.startActivity(
Intent(instr.context, NightModeActivityB::class.java).apply {
@@ -92,6 +97,9 @@
}
)
+ // Activity A is hidden, wait for it to stop.
+ waitUntilState(activityA, Lifecycle.State.CREATED)
+
// From activity B, start activity C.
val activityB = monitorB.waitForActivityWithTimeout(3000) as NightModeActivity
assertNotNull(activityB)
@@ -101,6 +109,9 @@
}
)
+ // Activity B is hidden, wait for it to stop.
+ waitUntilState(activityB, Lifecycle.State.CREATED)
+
// Toggle default night mode.
val activityC = monitorC.waitForActivityWithTimeout(3000) as NightModeActivity
assertNotNull(activityC)
@@ -111,39 +122,196 @@
// Activity C should receive a configuration change.
activityC.expectOnConfigurationChange(3000)
- // Activities A and B should recreate().
+ // Activities A and B should recreate() in the background.
val activityA2 = expectRecreate(monitorA, activityA) as NightModeActivity
val activityB2 = expectRecreate(monitorB, activityB) as NightModeActivity
// Activity C should have received a night mode configuration change.
- activityC.runOnUiThread {
- NightModeUtils.assertConfigurationNightModeEquals(
- "Activity A's effective configuration has night mode set",
- Configuration.UI_MODE_NIGHT_YES,
- activityC.effectiveConfiguration!!
- )
- }
-
- // Activity A should have been recreated in night mode.
- activityA2.runOnUiThread {
- NightModeUtils.assertConfigurationNightModeEquals(
- "Activity A's effective configuration has night mode set",
- Configuration.UI_MODE_NIGHT_YES,
- activityA2.effectiveConfiguration!!
- )
- }
-
- // Activity B should have been recreated in night mode.
- activityB2.runOnUiThread {
- NightModeUtils.assertConfigurationNightModeEquals(
- "Activity B's effective configuration has night mode set",
- Configuration.UI_MODE_NIGHT_YES,
- activityB2.effectiveConfiguration!!
- )
+ listOf(activityC, activityA2, activityB2).forEach { activity ->
+ activityC.runOnUiThread {
+ NightModeUtils.assertConfigurationNightModeEquals(
+ "Activity ${activity.title}'s effective configuration has night mode set",
+ Configuration.UI_MODE_NIGHT_YES,
+ activityC.effectiveConfiguration!!
+ )
+ }
}
}
- fun expectRecreate(monitor: ActivityMonitor, activity: Activity): Activity {
+ /**
+ * Regression test for the following scenario:
+ *
+ * If you have a stack of activities where every activity has `android:configChanges="uiMode"`
+ * and you call [AppCompatDelegate.setDefaultNightMode] from thread other than the top
+ * activity, then it can cause the bottom activity to not receive `onConfigurationChanged`.
+ *
+ * Eg:
+ * - Activity A DOES intercept uiMode config changes in manifest
+ * - Activity B DOES as well
+ * - Activity C DOES as well
+ *
+ * Here is your stack : A > B > C (C on top)
+ *
+ * Call [AppCompatDelegate.setDefaultNightMode] with a new mode on activity C (but not directly
+ * from this activity, ex with RX AndroidSchedulers.mainThread or an handler). Activity C
+ * receives both `onConfigurationChanged` and `onNightModeChanged`, but activities A and B
+ * may not receive either callback or change their configurations.
+ *
+ * Process:
+ * 1. A > B > C > setDefaultNightMode YES
+ * 2. Go back to A (B & C destroyed) > B > C > setDefaultNightMode NO (wrong config for A)
+ * 3. repeat (YES/NO/YES/NO...)
+ */
+ @Test
+ @SdkSuppress(minSdkVersion = 17)
+ public fun testDefaultNightModeWithStackedActivitiesAndNavigation() {
+ val instr = InstrumentationRegistry.getInstrumentation()
+ val result = Instrumentation.ActivityResult(0, Intent())
+ val monitorA = ActivityMonitor(
+ NightModeUiModeConfigChangesActivity::class.java.name,
+ result, false
+ )
+ val monitorB = ActivityMonitor(
+ NightModeUiModeConfigChangesActivityB::class.java.name,
+ result, false
+ )
+ val monitorC = ActivityMonitor(
+ NightModeUiModeConfigChangesActivityC::class.java.name,
+ result, false
+ )
+ instr.addMonitor(monitorA)
+ instr.addMonitor(monitorB)
+ instr.addMonitor(monitorC)
+
+ instr.runOnMainSync {
+ AppCompatDelegate.setDefaultNightMode(MODE_NIGHT_NO)
+ }
+
+ // Start activity A.
+ instr.startActivitySync(
+ Intent(instr.context, NightModeUiModeConfigChangesActivity::class.java).apply {
+ addFlags(Intent.FLAG_ACTIVITY_NEW_TASK)
+ putExtra(NightModeActivity.KEY_TITLE, "A")
+ }
+ )
+
+ // From activity A, start activity B.
+ val activityA = monitorA.waitForActivityWithTimeout(3000) as NightModeActivity
+ assertNotNull("Activity A started within 3000ms", activityA)
+ activityA.startActivity(
+ Intent(instr.context, NightModeUiModeConfigChangesActivityB::class.java).apply {
+ putExtra(NightModeActivity.KEY_TITLE, "B")
+ }
+ )
+
+ // Activity A is hidden, wait for it to stop.
+ waitUntilState(activityA, Lifecycle.State.CREATED)
+
+ // From activity B, start activity C.
+ val activityB = monitorB.waitForActivityWithTimeout(3000) as NightModeActivity
+ assertNotNull("Activity B started within 3000ms", activityB)
+ activityB.startActivity(
+ Intent(instr.context, NightModeUiModeConfigChangesActivityC::class.java).apply {
+ putExtra(NightModeActivity.KEY_TITLE, "C")
+ }
+ )
+
+ // Activity B is hidden, wait for it to stop.
+ waitUntilState(activityB, Lifecycle.State.CREATED)
+
+ // Wait for activity C to start.
+ val activityC = monitorC.waitForActivityWithTimeout(3000) as NightModeActivity
+ assertNotNull("Activity C started within 3000ms", activityC)
+
+ // Toggle default night mode from a non-UI thread.
+ Handler(Looper.getMainLooper()).post {
+ AppCompatDelegate.setDefaultNightMode(MODE_NIGHT_YES)
+ }
+
+ // Activities A, B, and C should all receive configuration changes.
+ listOf(activityA, activityB, activityC).forEach { activity ->
+ activity.expectOnConfigurationChange(3000)
+ }
+
+ // Activities A, B, and C should have all received the new configuration.
+ listOf(activityA, activityB, activityC).forEach { activity ->
+ activity.runOnUiThread {
+ NightModeUtils.assertConfigurationNightModeEquals(
+ "Activity ${activity.title}'s effective configuration has night mode set",
+ Configuration.UI_MODE_NIGHT_YES,
+ activity.effectiveConfiguration!!
+ )
+ }
+ }
+
+ // Tear down activities C and B, in that order.
+ listOf(activityC, activityB).forEach { activity ->
+ activity.runOnUiThread {
+ activity.finish()
+ }
+ waitUntilState(activity, Lifecycle.State.DESTROYED)
+ }
+
+ // Activity A is in the foreground, wait for it to resume.
+ waitUntilState(activityA, Lifecycle.State.RESUMED)
+
+ // From activity A, start activity B again.
+ activityA.startActivity(
+ Intent(instr.context, NightModeUiModeConfigChangesActivityB::class.java).apply {
+ putExtra(NightModeActivity.KEY_TITLE, "B2")
+ }
+ )
+
+ // Activity A is hidden, wait for it to stop.
+ waitUntilState(activityA, Lifecycle.State.CREATED)
+
+ // From activity B, start activity C. Double-check the return, since the monitor could
+ // trigger on Activity B's lifecycle if the platform does something unexpected.
+ val activityB2 = monitorB.waitForActivityWithTimeout(3000) as NightModeActivity
+ assertNotSame("Monitor responded to activity B2 lifecycle", activityB, activityB2)
+ assertNotNull("Activity B2 started within 3000ms", activityB2)
+ activityB2.startActivity(
+ Intent(instr.context, NightModeUiModeConfigChangesActivityC::class.java).apply {
+ putExtra(NightModeActivity.KEY_TITLE, "C2")
+ }
+ )
+
+ // Activity B is hidden, wait for it to stop.
+ waitUntilState(activityB2, Lifecycle.State.CREATED)
+
+ // Wait for activity C to start. Double-check the return.
+ val activityC2 = monitorC.waitForActivityWithTimeout(3000) as NightModeActivity
+ assertNotSame("Monitor responded to Activity C2 lifecycle", activityC, activityC2)
+ assertNotNull("Activity C2 started within 3000ms", activityC2)
+
+ // Prepare activities A, B, and C to track configuration changes.
+ listOf(activityA, activityB2, activityC2).forEach { activity ->
+ activity.resetOnConfigurationChange()
+ }
+
+ // Toggle default night mode again from a non-UI thread.
+ Handler(Looper.getMainLooper()).post {
+ AppCompatDelegate.setDefaultNightMode(MODE_NIGHT_NO)
+ }
+
+ // Activities A, B, and C should all receive configuration changes.
+ listOf(activityA, activityB2, activityC2).forEach { activity ->
+ activity.expectOnConfigurationChange(3000)
+ }
+
+ // Activities A, B, and C should have all received the new configuration.
+ listOf(activityA, activityB2, activityC2).forEach { activity ->
+ activity.runOnUiThread {
+ NightModeUtils.assertConfigurationNightModeEquals(
+ "Activity ${activity.title}'s effective configuration has night mode set",
+ Configuration.UI_MODE_NIGHT_NO,
+ activity.effectiveConfiguration!!
+ )
+ }
+ }
+ }
+
+ private fun expectRecreate(monitor: ActivityMonitor, activity: Activity): Activity {
// The documentation says "Block until an Activity is created that matches this monitor."
// This statement is true, but there are some other true statements like: "Block until an
// Activity is destroyed" or "Block until an Activity is resumed"...
diff --git a/appcompat/appcompat/src/androidTest/java/androidx/appcompat/app/NightModeUiModeConfigChangesActivityB.java b/appcompat/appcompat/src/androidTest/java/androidx/appcompat/app/NightModeUiModeConfigChangesActivityB.java
new file mode 100644
index 0000000..a5d27ef
--- /dev/null
+++ b/appcompat/appcompat/src/androidTest/java/androidx/appcompat/app/NightModeUiModeConfigChangesActivityB.java
@@ -0,0 +1,22 @@
+/*
+ * Copyright 2019 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.appcompat.app;
+
+/**
+ * An activity with DayNight theme that handles uiMode configuration changes.
+ */
+public class NightModeUiModeConfigChangesActivityB extends NightModeActivity {}
diff --git a/appcompat/appcompat/src/androidTest/java/androidx/appcompat/app/NightModeUiModeConfigChangesActivityC.java b/appcompat/appcompat/src/androidTest/java/androidx/appcompat/app/NightModeUiModeConfigChangesActivityC.java
new file mode 100644
index 0000000..83b473c
--- /dev/null
+++ b/appcompat/appcompat/src/androidTest/java/androidx/appcompat/app/NightModeUiModeConfigChangesActivityC.java
@@ -0,0 +1,22 @@
+/*
+ * Copyright 2019 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.appcompat.app;
+
+/**
+ * An activity with DayNight theme that handles uiMode configuration changes.
+ */
+public class NightModeUiModeConfigChangesActivityC extends NightModeActivity {}
diff --git a/appcompat/appcompat/src/androidTest/java/androidx/appcompat/app/NightModeUiModeConfigChangesTestCase.kt b/appcompat/appcompat/src/androidTest/java/androidx/appcompat/app/NightModeUiModeConfigChangesTestCase.kt
index 0cec4f9..fe35b47 100644
--- a/appcompat/appcompat/src/androidTest/java/androidx/appcompat/app/NightModeUiModeConfigChangesTestCase.kt
+++ b/appcompat/appcompat/src/androidTest/java/androidx/appcompat/app/NightModeUiModeConfigChangesTestCase.kt
@@ -71,27 +71,51 @@
}
@Test
- fun testOnConfigurationChangeNotCalledWhenNotStarted() {
+ fun testOnConfigurationChangeCalledWhileStopped() {
+ scenario.moveToState(Lifecycle.State.RESUMED)
scenario.moveToState(Lifecycle.State.CREATED)
- // And clear any previous config changes
- scenario.onActivity { it.lastConfigurationChangeAndClear }
// Set local night mode to YES
scenario.onActivity { setNightMode(MODE_NIGHT_YES, it, setMode) }
- // Assert that the onConfigurationChange was not called with a new correct config
+ // Assert that the onConfigurationChange was called with a new correct config
scenario.onActivity {
- assertNull(it.lastConfigurationChangeAndClear)
+ val lastConfig = it.lastConfigurationChangeAndClear
+ assertConfigurationNightModeEquals(Configuration.UI_MODE_NIGHT_YES, lastConfig!!)
}
// Set local night mode back to NO
scenario.onActivity { setNightMode(MODE_NIGHT_NO, it, setMode) }
- // Assert that the onConfigurationChange was not called with a new correct config
+ // Assert that the onConfigurationChange was called with a new correct config
scenario.onActivity {
- assertNull(it.lastConfigurationChangeAndClear)
+ val lastConfig = it.lastConfigurationChangeAndClear
+ assertConfigurationNightModeEquals(Configuration.UI_MODE_NIGHT_NO, lastConfig!!)
}
}
@Test
+ fun testOnConfigurationChangeNotCalledWhileDestroyed() {
+ scenario.moveToState(Lifecycle.State.RESUMED)
+
+ lateinit var activity: NightModeUiModeConfigChangesActivity
+ scenario.onActivity { activity = it }
+
+ scenario.moveToState(Lifecycle.State.DESTROYED)
+
+ // And clear any previous config changes
+ activity.lastConfigurationChangeAndClear
+
+ // Set local night mode to YES
+ setNightMode(MODE_NIGHT_YES, activity, setMode)
+ // Assert that the onConfigurationChange was not called with a new correct config
+ assertNull(activity.lastConfigurationChangeAndClear)
+
+ // Set local night mode back to NO
+ setNightMode(MODE_NIGHT_NO, activity, setMode)
+ // Assert that the onConfigurationChange was not called with a new correct config
+ assertNull(activity.lastConfigurationChangeAndClear)
+ }
+
+ @Test
fun testResourcesUpdated() {
// Set local night mode to YES
scenario.onActivity { setNightMode(MODE_NIGHT_YES, it, setMode) }
@@ -128,7 +152,9 @@
@After
fun cleanup() {
// Reset the default night mode
- scenario.onActivity { setNightMode(MODE_NIGHT_NO, it, NightSetMode.DEFAULT) }
+ if (scenario.state != Lifecycle.State.DESTROYED) {
+ scenario.onActivity { setNightMode(MODE_NIGHT_NO, it, NightSetMode.DEFAULT) }
+ }
scenario.close()
}
diff --git a/appcompat/appcompat/src/androidTest/res/layout/dialog_layout.xml b/appcompat/appcompat/src/androidTest/res/layout/dialog_layout.xml
new file mode 100644
index 0000000..b97647f
--- /dev/null
+++ b/appcompat/appcompat/src/androidTest/res/layout/dialog_layout.xml
@@ -0,0 +1,37 @@
+<?xml version="1.0" encoding="utf-8"?>
+<!-- Copyright (C) 2016 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.
+-->
+
+<LinearLayout
+ xmlns:android="http://schemas.android.com/apk/res/android"
+ android:id="@+id/dialog_content"
+ android:layout_width="match_parent"
+ android:layout_height="wrap_content"
+ android:orientation="vertical">
+ <TextView
+ android:layout_width="match_parent"
+ android:layout_height="wrap_content"
+ android:textSize="24sp"
+ android:textColor="@color/test_green"
+ android:text="@string/alert_dialog_custom_text1"
+ android:singleLine="false" />
+ <TextView
+ android:layout_width="match_parent"
+ android:layout_height="wrap_content"
+ android:textSize="20sp"
+ android:textColor="@color/test_blue"
+ android:text="@string/alert_dialog_custom_text2"
+ android:singleLine="false" />
+</LinearLayout>
diff --git a/appcompat/appcompat/src/main/java/androidx/appcompat/app/AppCompatDelegateImpl.java b/appcompat/appcompat/src/main/java/androidx/appcompat/app/AppCompatDelegateImpl.java
index 08f06a8..7ca7f37 100644
--- a/appcompat/appcompat/src/main/java/androidx/appcompat/app/AppCompatDelegateImpl.java
+++ b/appcompat/appcompat/src/main/java/androidx/appcompat/app/AppCompatDelegateImpl.java
@@ -244,10 +244,10 @@
private boolean mLongPressBackDown;
private boolean mBaseContextAttached;
+ // true after the first call to onCreated.
private boolean mCreated;
- private boolean mStarted;
- @SuppressWarnings("WeakerAccess") /* synthetic access */
- boolean mIsDestroyed;
+ // true after the first (and only) call to onDestroyed.
+ boolean mDestroyed;
/**
* The configuration from the most recent call to either onConfigurationChanged or onCreate.
@@ -669,8 +669,6 @@
@Override
public void onStart() {
- mStarted = true;
-
// This will apply day/night if the time has changed, it will also call through to
// setupAutoNightModeIfNeeded()
applyDayNight();
@@ -678,8 +676,6 @@
@Override
public void onStop() {
- mStarted = false;
-
ActionBar ab = getSupportActionBar();
if (ab != null) {
ab.setShowHideAnimationEnabled(false);
@@ -743,8 +739,7 @@
mWindow.getDecorView().removeCallbacks(mInvalidatePanelMenuRunnable);
}
- mStarted = false;
- mIsDestroyed = true;
+ mDestroyed = true;
if (mLocalNightMode != MODE_NIGHT_UNSPECIFIED
&& mHost instanceof Activity
@@ -844,7 +839,7 @@
// A pending invalidation will typically be resolved before the posted message
// would run normally in order to satisfy instance state restoration.
PanelFeatureState st = getPanelState(FEATURE_OPTIONS_PANEL, false);
- if (!mIsDestroyed && (st == null || st.menu == null)) {
+ if (!mDestroyed && (st == null || st.menu == null)) {
invalidatePanelMenu(FEATURE_SUPPORT_ACTION_BAR);
}
}
@@ -1185,7 +1180,7 @@
@Override
public boolean onMenuItemSelected(@NonNull MenuBuilder menu, @NonNull MenuItem item) {
final Window.Callback cb = getWindowCallback();
- if (cb != null && !mIsDestroyed) {
+ if (cb != null && !mDestroyed) {
final PanelFeatureState panel = findMenuPanel(menu.getRootMenu());
if (panel != null) {
return cb.onMenuItemSelected(panel.featureId, item);
@@ -1247,7 +1242,7 @@
}
ActionMode mode = null;
- if (mAppCompatCallback != null && !mIsDestroyed) {
+ if (mAppCompatCallback != null && !mDestroyed) {
try {
mode = mAppCompatCallback.onWindowStartingSupportActionMode(callback);
} catch (AbstractMethodError ame) {
@@ -1653,7 +1648,7 @@
private void openPanel(final PanelFeatureState st, KeyEvent event) {
// Already open, return
- if (st.isOpen || mIsDestroyed) {
+ if (st.isOpen || mDestroyed) {
return;
}
@@ -1765,7 +1760,7 @@
final Window.Callback cb = getWindowCallback();
if (!mDecorContentParent.isOverflowMenuShowing() || !toggleMenuMode) {
- if (cb != null && !mIsDestroyed) {
+ if (cb != null && !mDestroyed) {
// If we have a menu invalidation pending, do it now.
if (mInvalidatePanelMenuPosted &&
(mInvalidatePanelMenuFeatures & (1 << FEATURE_OPTIONS_PANEL)) != 0) {
@@ -1785,7 +1780,7 @@
}
} else {
mDecorContentParent.hideOverflowMenu();
- if (!mIsDestroyed) {
+ if (!mDestroyed) {
final PanelFeatureState st = getPanelState(FEATURE_OPTIONS_PANEL, true);
cb.onPanelClosed(FEATURE_SUPPORT_ACTION_BAR, st.menu);
}
@@ -1866,7 +1861,7 @@
}
private boolean preparePanel(PanelFeatureState st, KeyEvent event) {
- if (mIsDestroyed) {
+ if (mDestroyed) {
return false;
}
@@ -1977,7 +1972,7 @@
mClosingActionMenu = true;
mDecorContentParent.dismissPopups();
Window.Callback cb = getWindowCallback();
- if (cb != null && !mIsDestroyed) {
+ if (cb != null && !mDestroyed) {
cb.onPanelClosed(FEATURE_SUPPORT_ACTION_BAR, menu);
}
mClosingActionMenu = false;
@@ -2041,7 +2036,7 @@
mDecorContentParent.canShowOverflowMenu() &&
!ViewConfiguration.get(mContext).hasPermanentMenuKey()) {
if (!mDecorContentParent.isOverflowMenuShowing()) {
- if (!mIsDestroyed && preparePanel(st, event)) {
+ if (!mDestroyed && preparePanel(st, event)) {
handled = mDecorContentParent.showOverflowMenu();
}
} else {
@@ -2104,7 +2099,7 @@
return;
}
- if (!mIsDestroyed) {
+ if (!mDestroyed) {
// We need to be careful which callback we dispatch the call to. We can not dispatch
// this to the Window's callback since that will call back into this method and cause a
// crash. Instead we need to dispatch down to the original Activity/Dialog/etc.
@@ -2385,7 +2380,7 @@
@SuppressWarnings("deprecation")
private boolean applyDayNight(final boolean allowRecreation) {
- if (mIsDestroyed) {
+ if (mDestroyed) {
if (DEBUG) {
Log.d(TAG, "applyDayNight. Skipping because host is destroyed");
}
@@ -2614,14 +2609,15 @@
if (callOnConfigChange && mHost instanceof Activity) {
final Activity activity = (Activity) mHost;
if (activity instanceof LifecycleOwner) {
- // If the Activity is a LifecyleOwner, check that it is at least started
+ // If the Activity is a LifecyleOwner, check that it is after onCreate() and
+ // before onDestroy(), which includes STOPPED.
Lifecycle lifecycle = ((LifecycleOwner) activity).getLifecycle();
- if (lifecycle.getCurrentState().isAtLeast(Lifecycle.State.STARTED)) {
+ if (lifecycle.getCurrentState().isAtLeast(Lifecycle.State.CREATED)) {
activity.onConfigurationChanged(conf);
}
} else {
- // Otherwise we'll fallback to our internal started flag.
- if (mStarted) {
+ // Otherwise, we'll fallback to our internal created and destroyed flags.
+ if (mCreated && !mDestroyed) {
activity.onConfigurationChanged(conf);
}
}
@@ -2777,7 +2773,7 @@
// Only dispatch for the root menu
if (subMenu == subMenu.getRootMenu() && mHasActionBar) {
Window.Callback cb = getWindowCallback();
- if (cb != null && !mIsDestroyed) {
+ if (cb != null && !mDestroyed) {
cb.onMenuOpened(FEATURE_SUPPORT_ACTION_BAR, subMenu);
}
}
diff --git a/appcompat/appcompat/src/main/java/androidx/appcompat/app/AppCompatDialogFragment.java b/appcompat/appcompat/src/main/java/androidx/appcompat/app/AppCompatDialogFragment.java
index feb05f0..48c6835 100644
--- a/appcompat/appcompat/src/main/java/androidx/appcompat/app/AppCompatDialogFragment.java
+++ b/appcompat/appcompat/src/main/java/androidx/appcompat/app/AppCompatDialogFragment.java
@@ -24,6 +24,7 @@
import android.view.Window;
import android.view.WindowManager;
+import androidx.annotation.LayoutRes;
import androidx.annotation.NonNull;
import androidx.annotation.Nullable;
import androidx.annotation.RestrictTo;
@@ -37,6 +38,16 @@
*/
public class AppCompatDialogFragment extends DialogFragment {
+ /** {@inheritDoc} **/
+ public AppCompatDialogFragment() {
+ super();
+ }
+
+ /** {@inheritDoc} **/
+ public AppCompatDialogFragment(@LayoutRes int contentLayoutId) {
+ super(contentLayoutId);
+ }
+
@NonNull
@Override
public Dialog onCreateDialog(@Nullable Bundle savedInstanceState) {
diff --git a/buildSrc/src/main/kotlin/androidx/build/AndroidXExtension.kt b/buildSrc/src/main/kotlin/androidx/build/AndroidXExtension.kt
index ea6c673..c17b7b7 100644
--- a/buildSrc/src/main/kotlin/androidx/build/AndroidXExtension.kt
+++ b/buildSrc/src/main/kotlin/androidx/build/AndroidXExtension.kt
@@ -155,6 +155,8 @@
var legacyDisableKotlinStrictApiMode = false
+ var benchmarkRunAlsoInterpreted = false
+
fun shouldEnforceKotlinStrictApiMode(): Boolean {
return !legacyDisableKotlinStrictApiMode &&
shouldConfigureApiTasks()
diff --git a/buildSrc/src/main/kotlin/androidx/build/LibraryVersions.kt b/buildSrc/src/main/kotlin/androidx/build/LibraryVersions.kt
index 212a24f..a2a0b1a 100644
--- a/buildSrc/src/main/kotlin/androidx/build/LibraryVersions.kt
+++ b/buildSrc/src/main/kotlin/androidx/build/LibraryVersions.kt
@@ -48,7 +48,7 @@
val CONTENTPAGER = Version("1.1.0-alpha01")
val COMPOSE = Version(System.getenv("COMPOSE_CUSTOM_VERSION") ?: "1.0.0-beta08")
val COORDINATORLAYOUT = Version("1.2.0-alpha01")
- val CORE = Version("1.7.0-alpha01")
+ val CORE = Version("1.6.0-beta02")
val CORE_ANIMATION = Version("1.0.0-alpha03")
val CORE_ANIMATION_TESTING = Version("1.0.0-alpha03")
val CORE_APPDIGEST = Version("1.0.0-alpha01")
diff --git a/buildSrc/src/main/kotlin/androidx/build/docs/AndroidXDocsPlugin.kt b/buildSrc/src/main/kotlin/androidx/build/docs/AndroidXDocsPlugin.kt
index da31e71..7e26c7b 100644
--- a/buildSrc/src/main/kotlin/androidx/build/docs/AndroidXDocsPlugin.kt
+++ b/buildSrc/src/main/kotlin/androidx/build/docs/AndroidXDocsPlugin.kt
@@ -562,7 +562,7 @@
}
}
-private const val DACKKA_DEPENDENCY = "com.google.devsite:dackka:0.0.4"
+private const val DACKKA_DEPENDENCY = "com.google.devsite:dackka:0.0.5"
private const val DOCLAVA_DEPENDENCY = "com.android:doclava:1.0.6"
// Allowlist for directories that should be processed by Dackka
@@ -570,6 +570,7 @@
"androidx/benchmark/**",
"androidx/collection/**",
"androidx/compose/**",
+ "androidx/datastore/**",
"androidx/lifecycle/**",
"androidx/navigation/**",
"androidx/paging/**",
diff --git a/buildSrc/src/main/kotlin/androidx/build/testConfiguration/GenerateTestConfigurationTask.kt b/buildSrc/src/main/kotlin/androidx/build/testConfiguration/GenerateTestConfigurationTask.kt
index 17c29c3..9cd747d 100644
--- a/buildSrc/src/main/kotlin/androidx/build/testConfiguration/GenerateTestConfigurationTask.kt
+++ b/buildSrc/src/main/kotlin/androidx/build/testConfiguration/GenerateTestConfigurationTask.kt
@@ -67,6 +67,10 @@
abstract val hasBenchmarkPlugin: Property<Boolean>
@get:Input
+ @get:Optional
+ abstract val benchmarkRunAlsoInterpreted: Property<Boolean>
+
+ @get:Input
abstract val testRunner: Property<String>
@get:Input
@@ -127,6 +131,9 @@
if (hasBenchmarkPlugin.get()) {
configBuilder.isBenchmark(true)
if (configBuilder.isPostsubmit) {
+ if (benchmarkRunAlsoInterpreted.get()) {
+ configBuilder.tag("microbenchmarks_interpreted")
+ }
configBuilder.tag("microbenchmarks")
}
} else if (testProjectPath.get().endsWith("macrobenchmark")) {
diff --git a/buildSrc/src/main/kotlin/androidx/build/testConfiguration/TestSuiteConfiguration.kt b/buildSrc/src/main/kotlin/androidx/build/testConfiguration/TestSuiteConfiguration.kt
index ff5b301..e2a730e 100644
--- a/buildSrc/src/main/kotlin/androidx/build/testConfiguration/TestSuiteConfiguration.kt
+++ b/buildSrc/src/main/kotlin/androidx/build/testConfiguration/TestSuiteConfiguration.kt
@@ -18,6 +18,7 @@
package androidx.build.testConfiguration
+import androidx.build.AndroidXExtension
import androidx.build.AndroidXPlugin
import androidx.build.AndroidXPlugin.Companion.ZIP_CONSTRAINED_TEST_CONFIGS_WITH_APKS_TASK
import androidx.build.AndroidXPlugin.Companion.ZIP_TEST_CONFIGS_WITH_APKS_TASK
@@ -82,7 +83,13 @@
} else {
task.minSdk.set(minSdk)
}
- task.hasBenchmarkPlugin.set(this.hasBenchmarkPlugin())
+ val hasBenchmarkPlugin = this.hasBenchmarkPlugin()
+ task.hasBenchmarkPlugin.set(hasBenchmarkPlugin)
+ if (hasBenchmarkPlugin) {
+ task.benchmarkRunAlsoInterpreted.set(
+ extensions.getByType<AndroidXExtension>().benchmarkRunAlsoInterpreted
+ )
+ }
task.testRunner.set(testRunner)
task.testProjectPath.set(this.path)
task.affectedModuleDetectorSubset.set(
diff --git a/busytown/androidx_incremental.sh b/busytown/androidx_incremental.sh
index 2c3383c1..f58af59 100755
--- a/busytown/androidx_incremental.sh
+++ b/busytown/androidx_incremental.sh
@@ -33,7 +33,7 @@
function zipKotlinMetadata() {
zipFile=kotlinMetadata.zip
echo "zipping kotlin metadata"
- (cd $OUT_DIR && find -name "*kotlin_metadata" | xargs zip "$DIST_DIR/$zipFile")
+ (cd $OUT_DIR && find -name "*kotlin_module" | xargs zip "$DIST_DIR/$zipFile")
echo done zipping kotlin metadata
}
diff --git a/camera/camera-camera2-pipe-integration/src/main/java/androidx/camera/camera2/pipe/integration/adapter/CameraUseCaseAdapter.kt b/camera/camera-camera2-pipe-integration/src/main/java/androidx/camera/camera2/pipe/integration/adapter/CameraUseCaseAdapter.kt
index 8645cc2..f4f27b5 100644
--- a/camera/camera-camera2-pipe-integration/src/main/java/androidx/camera/camera2/pipe/integration/adapter/CameraUseCaseAdapter.kt
+++ b/camera/camera-camera2-pipe-integration/src/main/java/androidx/camera/camera2/pipe/integration/adapter/CameraUseCaseAdapter.kt
@@ -140,7 +140,29 @@
object DefaultSessionOptionsUnpacker : SessionConfig.OptionUnpacker {
override fun unpack(config: UseCaseConfig<*>, builder: SessionConfig.Builder) {
- // Unused.
+ val defaultSessionConfig = config.getDefaultSessionConfig( /*valueIfMissing=*/null)
+
+ var implOptions: Config = OptionsBundle.emptyBundle()
+ var templateType = SessionConfig.defaultEmptySessionConfig().templateType
+
+ // Apply/extract defaults from session config
+ if (defaultSessionConfig != null) {
+ templateType = defaultSessionConfig.templateType
+ builder.addAllDeviceStateCallbacks(defaultSessionConfig.deviceStateCallbacks)
+ builder.addAllSessionStateCallbacks(defaultSessionConfig.sessionStateCallbacks)
+ builder.addAllRepeatingCameraCaptureCallbacks(
+ defaultSessionConfig.repeatingCameraCaptureCallbacks
+ )
+ implOptions = defaultSessionConfig.implementationOptions
+ }
+
+ // Set any additional implementation options
+ builder.setImplementationOptions(implOptions)
+
+ // Set the template type from default session config
+ builder.setTemplateType(templateType)
+
+ // TODO: Add Camera2 options and callbacks
}
}
}
\ No newline at end of file
diff --git a/camera/camera-camera2-pipe-integration/src/test/java/androidx/camera/camera2/pipe/integration/adapter/CameraUseCaseAdapterTest.kt b/camera/camera-camera2-pipe-integration/src/test/java/androidx/camera/camera2/pipe/integration/adapter/CameraUseCaseAdapterTest.kt
index 8c846fc..78a488a 100644
--- a/camera/camera-camera2-pipe-integration/src/test/java/androidx/camera/camera2/pipe/integration/adapter/CameraUseCaseAdapterTest.kt
+++ b/camera/camera-camera2-pipe-integration/src/test/java/androidx/camera/camera2/pipe/integration/adapter/CameraUseCaseAdapterTest.kt
@@ -16,6 +16,7 @@
package androidx.camera.camera2.pipe.integration.adapter
+import android.hardware.camera2.CameraCaptureSession
import android.hardware.camera2.CameraDevice
import android.os.Build
import android.view.Surface
@@ -24,6 +25,7 @@
import androidx.camera.core.impl.CaptureConfig
import androidx.camera.core.impl.ImageOutputConfig
import androidx.camera.core.impl.MutableOptionsBundle
+import androidx.camera.core.impl.SessionConfig
import com.google.common.truth.Truth.assertThat
import org.junit.Test
import org.junit.runner.RunWith
@@ -59,6 +61,60 @@
config.assertEquals(useCaseConfig.defaultCaptureConfig)
}
+ @Test
+ fun shouldApplySessionConfig_whenDefaultConfigSet() {
+ // Arrange
+ val defaultSessionCaptureConfig = SessionConfig.Builder()
+ .apply {
+ setTemplateType(CameraDevice.TEMPLATE_PREVIEW)
+ addImplementationOptions(
+ MutableOptionsBundle.create()
+ .apply {
+ insertOption(
+ ImageOutputConfig.OPTION_TARGET_ROTATION,
+ Surface.ROTATION_180
+ )
+ }
+ )
+ addDeviceStateCallback(object : CameraDevice.StateCallback() {
+ override fun onOpened(camera: CameraDevice) {
+ // unused
+ }
+
+ override fun onDisconnected(camera: CameraDevice) {
+ // unused
+ }
+
+ override fun onError(camera: CameraDevice, error: Int) {
+ // unused
+ }
+ })
+ addSessionStateCallback(object : CameraCaptureSession.StateCallback() {
+ override fun onConfigured(session: CameraCaptureSession) {
+ // unused
+ }
+
+ override fun onConfigureFailed(session: CameraCaptureSession) {
+ // unused
+ }
+ })
+ addRepeatingCameraCaptureCallback(object : CameraCaptureCallback() {})
+ }
+ .build()
+
+ val useCaseConfig = ImageCapture.Builder()
+ .setDefaultSessionConfig(defaultSessionCaptureConfig)
+ .useCaseConfig
+ val builder = SessionConfig.Builder()
+
+ // Act
+ CameraUseCaseAdapter.DefaultSessionOptionsUnpacker.unpack(useCaseConfig, builder)
+
+ // Assert
+ val config = builder.build()
+ config.assertEquals(useCaseConfig.defaultSessionConfig)
+ }
+
private fun CaptureConfig.assertEquals(other: CaptureConfig) {
assertThat(templateType).isEqualTo(other.templateType)
assertThat(isUseRepeatingSurface).isEqualTo(other.isUseRepeatingSurface)
@@ -80,4 +136,21 @@
assertThat(tagBundle.getTag(key)).isEqualTo(other.tagBundle.getTag(key))
}
}
+
+ private fun SessionConfig.assertEquals(other: SessionConfig) {
+ assertThat(templateType).isEqualTo(other.templateType)
+ // Implementation options
+ assertThat(implementationOptions.listOptions())
+ .isEqualTo(other.implementationOptions.listOptions())
+ implementationOptions.listOptions().forEach { option ->
+ assertThat(implementationOptions.retrieveOption(option)).isEqualTo(
+ other.implementationOptions.retrieveOption(option)
+ )
+ }
+
+ // Verify callbacks
+ assertThat(deviceStateCallbacks).isEqualTo(other.deviceStateCallbacks)
+ assertThat(sessionStateCallbacks).isEqualTo(other.sessionStateCallbacks)
+ assertThat(repeatingCameraCaptureCallbacks).isEqualTo(other.repeatingCameraCaptureCallbacks)
+ }
}
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 e84383d..46ab8cd 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
@@ -41,12 +41,10 @@
import android.view.Surface;
import androidx.annotation.NonNull;
-import androidx.annotation.OptIn;
import androidx.camera.camera2.internal.compat.CameraManagerCompat;
import androidx.camera.camera2.internal.util.SemaphoreReleasingCamera2Callbacks;
import androidx.camera.camera2.interop.Camera2Interop;
import androidx.camera.core.CameraSelector;
-import androidx.camera.core.ExperimentalExposureCompensation;
import androidx.camera.core.ExposureState;
import androidx.camera.core.ImageCapture;
import androidx.camera.core.impl.CameraControlInternal;
@@ -94,7 +92,6 @@
*/
@LargeTest
@RunWith(AndroidJUnit4.class)
-@OptIn(markerClass = ExperimentalExposureCompensation.class)
public class ExposureDeviceTest {
@CameraSelector.LensFacing
diff --git a/camera/camera-camera2/src/main/java/androidx/camera/camera2/internal/Camera2CameraControlImpl.java b/camera/camera-camera2/src/main/java/androidx/camera/camera2/internal/Camera2CameraControlImpl.java
index de30395..6417153 100644
--- a/camera/camera-camera2/src/main/java/androidx/camera/camera2/internal/Camera2CameraControlImpl.java
+++ b/camera/camera-camera2/src/main/java/androidx/camera/camera2/internal/Camera2CameraControlImpl.java
@@ -43,7 +43,6 @@
import androidx.camera.camera2.interop.Camera2CameraControl;
import androidx.camera.camera2.interop.CaptureRequestOptions;
import androidx.camera.camera2.interop.ExperimentalCamera2Interop;
-import androidx.camera.core.ExperimentalExposureCompensation;
import androidx.camera.core.FocusMeteringAction;
import androidx.camera.core.FocusMeteringResult;
import androidx.camera.core.ImageCapture;
@@ -420,7 +419,6 @@
@NonNull
@Override
- @ExperimentalExposureCompensation
public ListenableFuture<Integer> setExposureCompensationIndex(int exposure) {
if (!isControlInUse()) {
return Futures.immediateFailedFuture(
diff --git a/camera/camera-camera2/src/main/java/androidx/camera/camera2/internal/Camera2CameraInfoImpl.java b/camera/camera-camera2/src/main/java/androidx/camera/camera2/internal/Camera2CameraInfoImpl.java
index 66925a2..c6bd795 100644
--- a/camera/camera-camera2/src/main/java/androidx/camera/camera2/internal/Camera2CameraInfoImpl.java
+++ b/camera/camera-camera2/src/main/java/androidx/camera/camera2/internal/Camera2CameraInfoImpl.java
@@ -31,7 +31,6 @@
import androidx.camera.camera2.interop.ExperimentalCamera2Interop;
import androidx.camera.core.CameraSelector;
import androidx.camera.core.CameraState;
-import androidx.camera.core.ExperimentalExposureCompensation;
import androidx.camera.core.ExposureState;
import androidx.camera.core.Logger;
import androidx.camera.core.ZoomState;
@@ -294,7 +293,6 @@
@NonNull
@Override
- @ExperimentalExposureCompensation
public ExposureState getExposureState() {
synchronized (mLock) {
if (mCamera2CameraControlImpl == null) {
diff --git a/camera/camera-camera2/src/main/java/androidx/camera/camera2/internal/ExposureControl.java b/camera/camera-camera2/src/main/java/androidx/camera/camera2/internal/ExposureControl.java
index 8b87d66..bf9b6e9 100644
--- a/camera/camera-camera2/src/main/java/androidx/camera/camera2/internal/ExposureControl.java
+++ b/camera/camera-camera2/src/main/java/androidx/camera/camera2/internal/ExposureControl.java
@@ -23,7 +23,6 @@
import androidx.annotation.NonNull;
import androidx.annotation.Nullable;
-import androidx.annotation.OptIn;
import androidx.camera.camera2.impl.Camera2ImplConfig;
import androidx.camera.camera2.internal.annotation.CameraExecutor;
import androidx.camera.camera2.internal.compat.CameraCharacteristicsCompat;
@@ -53,7 +52,6 @@
* The task will fails with {@link CameraControl.OperationCanceledException} if the camera is
* closed.
*/
-@OptIn(markerClass = androidx.camera.core.ExperimentalExposureCompensation.class)
public class ExposureControl {
private static final int DEFAULT_EXPOSURE_COMPENSATION = 0;
diff --git a/camera/camera-camera2/src/main/java/androidx/camera/camera2/internal/ExposureStateImpl.java b/camera/camera-camera2/src/main/java/androidx/camera/camera2/internal/ExposureStateImpl.java
index bf44fdf..fb4a514 100644
--- a/camera/camera-camera2/src/main/java/androidx/camera/camera2/internal/ExposureStateImpl.java
+++ b/camera/camera-camera2/src/main/java/androidx/camera/camera2/internal/ExposureStateImpl.java
@@ -23,13 +23,11 @@
import androidx.annotation.GuardedBy;
import androidx.annotation.NonNull;
import androidx.camera.camera2.internal.compat.CameraCharacteristicsCompat;
-import androidx.camera.core.ExperimentalExposureCompensation;
import androidx.camera.core.ExposureState;
/**
* An implementation of {@link ExposureState} where the values can be set.
*/
-@ExperimentalExposureCompensation
class ExposureStateImpl implements ExposureState {
private final Object mLock = new Object();
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 58f8e22..1909102 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,10 +30,8 @@
import android.util.Range;
import android.util.Rational;
-import androidx.annotation.OptIn;
import androidx.camera.camera2.internal.compat.CameraCharacteristicsCompat;
import androidx.camera.core.CameraControl;
-import androidx.camera.core.ExperimentalExposureCompensation;
import androidx.camera.core.impl.CameraControlInternal;
import androidx.camera.core.impl.utils.executor.CameraXExecutors;
import androidx.test.core.app.ApplicationProvider;
@@ -57,7 +55,6 @@
@RunWith(RobolectricTestRunner.class)
@Config(minSdk = Build.VERSION_CODES.LOLLIPOP)
@DoNotInstrument
-@OptIn(markerClass = ExperimentalExposureCompensation.class)
public class ExposureControlTest {
private static final String CAMERA0_ID = "0";
diff --git a/camera/camera-core/api/current.ignore b/camera/camera-core/api/current.ignore
index 2f97885..17d923e 100644
--- a/camera/camera-core/api/current.ignore
+++ b/camera/camera-core/api/current.ignore
@@ -1,5 +1,9 @@
// Baseline format: 1.0
+AddedAbstractMethod: androidx.camera.core.CameraControl#setExposureCompensationIndex(int):
+ Added method androidx.camera.core.CameraControl.setExposureCompensationIndex(int)
AddedAbstractMethod: androidx.camera.core.CameraInfo#getCameraSelector():
Added method androidx.camera.core.CameraInfo.getCameraSelector()
AddedAbstractMethod: androidx.camera.core.CameraInfo#getCameraState():
Added method androidx.camera.core.CameraInfo.getCameraState()
+AddedAbstractMethod: androidx.camera.core.CameraInfo#getExposureState():
+ Added method androidx.camera.core.CameraInfo.getExposureState()
diff --git a/camera/camera-core/api/current.txt b/camera/camera-core/api/current.txt
index 4519564..46c69c1 100644
--- a/camera/camera-core/api/current.txt
+++ b/camera/camera-core/api/current.txt
@@ -14,6 +14,7 @@
public interface CameraControl {
method public com.google.common.util.concurrent.ListenableFuture<java.lang.Void!> cancelFocusAndMetering();
method public com.google.common.util.concurrent.ListenableFuture<java.lang.Void!> enableTorch(boolean);
+ method public com.google.common.util.concurrent.ListenableFuture<java.lang.Integer!> setExposureCompensationIndex(int);
method public com.google.common.util.concurrent.ListenableFuture<java.lang.Void!> setLinearZoom(@FloatRange(from=0.0f, to=1.0f) float);
method public com.google.common.util.concurrent.ListenableFuture<java.lang.Void!> setZoomRatio(float);
method public com.google.common.util.concurrent.ListenableFuture<androidx.camera.core.FocusMeteringResult!> startFocusAndMetering(androidx.camera.core.FocusMeteringAction);
@@ -29,6 +30,7 @@
public interface CameraInfo {
method public androidx.camera.core.CameraSelector getCameraSelector();
method public androidx.lifecycle.LiveData<androidx.camera.core.CameraState!> getCameraState();
+ method public androidx.camera.core.ExposureState getExposureState();
method public int getSensorRotationDegrees();
method public int getSensorRotationDegrees(int);
method public androidx.lifecycle.LiveData<java.lang.Integer!> getTorchState();
@@ -122,6 +124,13 @@
ctor public DisplayOrientedMeteringPointFactory(android.view.Display, androidx.camera.core.CameraInfo, float, float);
}
+ public interface ExposureState {
+ method public int getExposureCompensationIndex();
+ method public android.util.Range<java.lang.Integer!> getExposureCompensationRange();
+ method public android.util.Rational getExposureCompensationStep();
+ method public boolean isExposureCompensationSupported();
+ }
+
public interface ExtendableBuilder<T> {
method public T build();
}
diff --git a/camera/camera-core/api/public_plus_experimental_current.txt b/camera/camera-core/api/public_plus_experimental_current.txt
index ea9906c..daa3256 100644
--- a/camera/camera-core/api/public_plus_experimental_current.txt
+++ b/camera/camera-core/api/public_plus_experimental_current.txt
@@ -14,7 +14,7 @@
public interface CameraControl {
method public com.google.common.util.concurrent.ListenableFuture<java.lang.Void!> cancelFocusAndMetering();
method public com.google.common.util.concurrent.ListenableFuture<java.lang.Void!> enableTorch(boolean);
- method @androidx.camera.core.ExperimentalExposureCompensation public com.google.common.util.concurrent.ListenableFuture<java.lang.Integer!> setExposureCompensationIndex(int);
+ method public com.google.common.util.concurrent.ListenableFuture<java.lang.Integer!> setExposureCompensationIndex(int);
method public com.google.common.util.concurrent.ListenableFuture<java.lang.Void!> setLinearZoom(@FloatRange(from=0.0f, to=1.0f) float);
method public com.google.common.util.concurrent.ListenableFuture<java.lang.Void!> setZoomRatio(float);
method public com.google.common.util.concurrent.ListenableFuture<androidx.camera.core.FocusMeteringResult!> startFocusAndMetering(androidx.camera.core.FocusMeteringAction);
@@ -30,7 +30,7 @@
public interface CameraInfo {
method public androidx.camera.core.CameraSelector getCameraSelector();
method public androidx.lifecycle.LiveData<androidx.camera.core.CameraState!> getCameraState();
- method @androidx.camera.core.ExperimentalExposureCompensation public androidx.camera.core.ExposureState getExposureState();
+ method public androidx.camera.core.ExposureState getExposureState();
method public int getSensorRotationDegrees();
method public int getSensorRotationDegrees(int);
method public androidx.lifecycle.LiveData<java.lang.Integer!> getTorchState();
@@ -135,9 +135,6 @@
@RequiresOptIn @java.lang.annotation.Retention(java.lang.annotation.RetentionPolicy.CLASS) public @interface ExperimentalCustomizableThreads {
}
- @RequiresOptIn @java.lang.annotation.Retention(java.lang.annotation.RetentionPolicy.CLASS) public @interface ExperimentalExposureCompensation {
- }
-
@RequiresOptIn @java.lang.annotation.Retention(java.lang.annotation.RetentionPolicy.CLASS) public @interface ExperimentalGetImage {
}
@@ -147,7 +144,7 @@
@RequiresOptIn @java.lang.annotation.Retention(java.lang.annotation.RetentionPolicy.CLASS) public @interface ExperimentalUseCaseGroup {
}
- @androidx.camera.core.ExperimentalExposureCompensation public interface ExposureState {
+ public interface ExposureState {
method public int getExposureCompensationIndex();
method public android.util.Range<java.lang.Integer!> getExposureCompensationRange();
method public android.util.Rational getExposureCompensationStep();
diff --git a/camera/camera-core/api/restricted_current.ignore b/camera/camera-core/api/restricted_current.ignore
index 2f97885..17d923e 100644
--- a/camera/camera-core/api/restricted_current.ignore
+++ b/camera/camera-core/api/restricted_current.ignore
@@ -1,5 +1,9 @@
// Baseline format: 1.0
+AddedAbstractMethod: androidx.camera.core.CameraControl#setExposureCompensationIndex(int):
+ Added method androidx.camera.core.CameraControl.setExposureCompensationIndex(int)
AddedAbstractMethod: androidx.camera.core.CameraInfo#getCameraSelector():
Added method androidx.camera.core.CameraInfo.getCameraSelector()
AddedAbstractMethod: androidx.camera.core.CameraInfo#getCameraState():
Added method androidx.camera.core.CameraInfo.getCameraState()
+AddedAbstractMethod: androidx.camera.core.CameraInfo#getExposureState():
+ Added method androidx.camera.core.CameraInfo.getExposureState()
diff --git a/camera/camera-core/api/restricted_current.txt b/camera/camera-core/api/restricted_current.txt
index 4519564..46c69c1 100644
--- a/camera/camera-core/api/restricted_current.txt
+++ b/camera/camera-core/api/restricted_current.txt
@@ -14,6 +14,7 @@
public interface CameraControl {
method public com.google.common.util.concurrent.ListenableFuture<java.lang.Void!> cancelFocusAndMetering();
method public com.google.common.util.concurrent.ListenableFuture<java.lang.Void!> enableTorch(boolean);
+ method public com.google.common.util.concurrent.ListenableFuture<java.lang.Integer!> setExposureCompensationIndex(int);
method public com.google.common.util.concurrent.ListenableFuture<java.lang.Void!> setLinearZoom(@FloatRange(from=0.0f, to=1.0f) float);
method public com.google.common.util.concurrent.ListenableFuture<java.lang.Void!> setZoomRatio(float);
method public com.google.common.util.concurrent.ListenableFuture<androidx.camera.core.FocusMeteringResult!> startFocusAndMetering(androidx.camera.core.FocusMeteringAction);
@@ -29,6 +30,7 @@
public interface CameraInfo {
method public androidx.camera.core.CameraSelector getCameraSelector();
method public androidx.lifecycle.LiveData<androidx.camera.core.CameraState!> getCameraState();
+ method public androidx.camera.core.ExposureState getExposureState();
method public int getSensorRotationDegrees();
method public int getSensorRotationDegrees(int);
method public androidx.lifecycle.LiveData<java.lang.Integer!> getTorchState();
@@ -122,6 +124,13 @@
ctor public DisplayOrientedMeteringPointFactory(android.view.Display, androidx.camera.core.CameraInfo, float, float);
}
+ public interface ExposureState {
+ method public int getExposureCompensationIndex();
+ method public android.util.Range<java.lang.Integer!> getExposureCompensationRange();
+ method public android.util.Rational getExposureCompensationStep();
+ method public boolean isExposureCompensationSupported();
+ }
+
public interface ExtendableBuilder<T> {
method public T build();
}
diff --git a/camera/camera-core/src/main/java/androidx/camera/core/CameraControl.java b/camera/camera-core/src/main/java/androidx/camera/core/CameraControl.java
index e9df24a..9fa6afc 100644
--- a/camera/camera-core/src/main/java/androidx/camera/core/CameraControl.java
+++ b/camera/camera-core/src/main/java/androidx/camera/core/CameraControl.java
@@ -176,7 +176,6 @@
* </ul>
*/
@NonNull
- @ExperimentalExposureCompensation
ListenableFuture<Integer> setExposureCompensationIndex(int value);
/**
diff --git a/camera/camera-core/src/main/java/androidx/camera/core/CameraInfo.java b/camera/camera-core/src/main/java/androidx/camera/core/CameraInfo.java
index fa3d911..00f4c40 100644
--- a/camera/camera-core/src/main/java/androidx/camera/core/CameraInfo.java
+++ b/camera/camera-core/src/main/java/androidx/camera/core/CameraInfo.java
@@ -138,7 +138,6 @@
* <p>The {@link ExposureState} contains the current exposure related information.
*/
@NonNull
- @ExperimentalExposureCompensation
ExposureState getExposureState();
/**
diff --git a/camera/camera-core/src/main/java/androidx/camera/core/ExperimentalExposureCompensation.java b/camera/camera-core/src/main/java/androidx/camera/core/ExperimentalExposureCompensation.java
deleted file mode 100644
index 6e22ab7..0000000
--- a/camera/camera-core/src/main/java/androidx/camera/core/ExperimentalExposureCompensation.java
+++ /dev/null
@@ -1,37 +0,0 @@
-/*
- * 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.camera.core;
-
-
-import static java.lang.annotation.RetentionPolicy.CLASS;
-
-import androidx.annotation.RequiresOptIn;
-
-import java.lang.annotation.Retention;
-
-/**
- * Denotes that the annotated method uses the experimental ExposureCompensation APIs that can
- * control the exposure compensation of the camera.
- *
- * <p>The feature allow the user to control the exposure compensation of the camera, it includes a
- * setter in {@link androidx.camera.core.CameraControl} and a getter in
- * {@link androidx.camera.core.CameraInfo}.
- */
-@Retention(CLASS)
-@RequiresOptIn
-public @interface ExperimentalExposureCompensation {
-}
diff --git a/camera/camera-core/src/main/java/androidx/camera/core/ExposureState.java b/camera/camera-core/src/main/java/androidx/camera/core/ExposureState.java
index 919f708..7979a74 100644
--- a/camera/camera-core/src/main/java/androidx/camera/core/ExposureState.java
+++ b/camera/camera-core/src/main/java/androidx/camera/core/ExposureState.java
@@ -26,7 +26,6 @@
*
* <p>Applications can retrieve an instance via {@link CameraInfo#getExposureState()}.
*/
-@ExperimentalExposureCompensation
public interface ExposureState {
/**
diff --git a/camera/camera-core/src/main/java/androidx/camera/core/impl/CameraControlInternal.java b/camera/camera-core/src/main/java/androidx/camera/core/impl/CameraControlInternal.java
index d5354ed..ac35a05 100644
--- a/camera/camera-core/src/main/java/androidx/camera/core/impl/CameraControlInternal.java
+++ b/camera/camera-core/src/main/java/androidx/camera/core/impl/CameraControlInternal.java
@@ -22,7 +22,6 @@
import androidx.annotation.NonNull;
import androidx.camera.core.CameraControl;
-import androidx.camera.core.ExperimentalExposureCompensation;
import androidx.camera.core.FocusMeteringAction;
import androidx.camera.core.FocusMeteringResult;
import androidx.camera.core.ImageCapture.FlashMode;
@@ -82,7 +81,6 @@
*/
@NonNull
@Override
- @ExperimentalExposureCompensation
ListenableFuture<Integer> setExposureCompensationIndex(int exposure);
/**
@@ -157,7 +155,6 @@
@NonNull
@Override
- @ExperimentalExposureCompensation
public ListenableFuture<Integer> setExposureCompensationIndex(int exposure) {
return Futures.immediateFuture(0);
}
diff --git a/camera/camera-testing/src/main/java/androidx/camera/testing/LabTestRule.kt b/camera/camera-testing/src/main/java/androidx/camera/testing/LabTestRule.kt
index 4645b33..28da413 100644
--- a/camera/camera-testing/src/main/java/androidx/camera/testing/LabTestRule.kt
+++ b/camera/camera-testing/src/main/java/androidx/camera/testing/LabTestRule.kt
@@ -27,14 +27,16 @@
* throws the AssumptionViolatedException to ignore the test if the test environment is not in the
* lab. Useful for the tests not needed to run on the PostSubmit.
*
- * To use this [TestRule] do the following. <br></br><br></br>
+ * To use this [TestRule], do the following. <br></br><br></br>
*
* Add the Rule to your JUnit test. <br></br><br></br>
* `LabTestRule mLabTestRule = new LabTestRule();
` *
* <br></br><br></br>
*
- * Add the [LabTestOnly] annotation to your test case. <br></br><br></br>
+ * Add only one of [LabTestOnly], [LabTestFrontCamera] or, [LabTestRearCamera] annotation to your
+ * test case.
+ * <br></br><br></br>
* `public void yourTestCase() {
*
* }
@@ -50,6 +52,22 @@
@Retention(AnnotationRetention.RUNTIME)
annotation class LabTestOnly()
+ /**
+ * The annotation for tests that only want to run on the CameraX lab environment with
+ * enabling front camera.
+ */
+ @Target(AnnotationTarget.FUNCTION)
+ @Retention(AnnotationRetention.RUNTIME)
+ annotation class LabTestFrontCamera()
+
+ /**
+ * The annotation for tests that only want to run on the CameraX lab environment with
+ * enabling rear camera.
+ */
+ @Target(AnnotationTarget.FUNCTION)
+ @Retention(AnnotationRetention.RUNTIME)
+ annotation class LabTestRearCamera()
+
class LabTestStatement(private val statement: Statement) :
Statement() {
@@ -63,9 +81,38 @@
}
}
+ class LabTestFrontCameraStatement(private val statement: Statement) :
+ Statement() {
+
+ @Throws(Throwable::class)
+ override fun evaluate() {
+ // Only test in CameraX lab environment and the loggable tag will be set when running
+ // the CameraX e2e test with enabling front camera.
+ assumeTrue(Log.isLoggable("frontCameraE2E", Log.DEBUG))
+ statement.evaluate()
+ }
+ }
+
+ class LabTestRearCameraStatement(private val statement: Statement) :
+ Statement() {
+
+ @Throws(Throwable::class)
+ override fun evaluate() {
+ // Only test in CameraX lab environment and the loggable tag will be set when running
+ // the CameraX e2e test with enabling rear camera.
+ assumeTrue(Log.isLoggable("rearCameraE2E", Log.DEBUG))
+ statement.evaluate()
+ }
+ }
+
override fun apply(base: Statement, description: Description): Statement {
+
return if (description.getAnnotation(LabTestOnly::class.java) != null) {
LabTestStatement(base)
+ } else if (description.getAnnotation(LabTestFrontCamera::class.java) != null) {
+ LabTestFrontCameraStatement(base)
+ } else if (description.getAnnotation(LabTestRearCamera::class.java) != null) {
+ LabTestRearCameraStatement(base)
} else {
base
}
diff --git a/camera/camera-testing/src/main/java/androidx/camera/testing/fakes/FakeCameraControl.java b/camera/camera-testing/src/main/java/androidx/camera/testing/fakes/FakeCameraControl.java
index e42f23c..24f1a46 100644
--- a/camera/camera-testing/src/main/java/androidx/camera/testing/fakes/FakeCameraControl.java
+++ b/camera/camera-testing/src/main/java/androidx/camera/testing/fakes/FakeCameraControl.java
@@ -22,7 +22,6 @@
import android.graphics.Rect;
import androidx.annotation.NonNull;
-import androidx.camera.core.ExperimentalExposureCompensation;
import androidx.camera.core.FocusMeteringAction;
import androidx.camera.core.FocusMeteringResult;
import androidx.camera.core.ImageCapture;
@@ -136,7 +135,6 @@
@NonNull
@Override
- @ExperimentalExposureCompensation
public ListenableFuture<Integer> setExposureCompensationIndex(int exposure) {
return Futures.immediateFuture(null);
}
diff --git a/camera/camera-testing/src/main/java/androidx/camera/testing/fakes/FakeCameraInfoInternal.java b/camera/camera-testing/src/main/java/androidx/camera/testing/fakes/FakeCameraInfoInternal.java
index ac45541..cec24f5 100644
--- a/camera/camera-testing/src/main/java/androidx/camera/testing/fakes/FakeCameraInfoInternal.java
+++ b/camera/camera-testing/src/main/java/androidx/camera/testing/fakes/FakeCameraInfoInternal.java
@@ -24,7 +24,6 @@
import androidx.annotation.Nullable;
import androidx.camera.core.CameraSelector;
import androidx.camera.core.CameraState;
-import androidx.camera.core.ExperimentalExposureCompensation;
import androidx.camera.core.ExposureState;
import androidx.camera.core.TorchState;
import androidx.camera.core.ZoomState;
@@ -138,7 +137,6 @@
@NonNull
@Override
- @ExperimentalExposureCompensation
public ExposureState getExposureState() {
return new ExposureState() {
@Override
diff --git a/camera/camera-view/api/current.txt b/camera/camera-view/api/current.txt
index 160857f..d9c61fc 100644
--- a/camera/camera-view/api/current.txt
+++ b/camera/camera-view/api/current.txt
@@ -75,5 +75,13 @@
enum_constant public static final androidx.camera.view.PreviewView.StreamState STREAMING;
}
+ public abstract class RotationReceiver {
+ ctor public RotationReceiver(android.content.Context);
+ method public boolean canDetectOrientation();
+ method public void disable();
+ method public void enable();
+ method public abstract void onRotationChanged(int);
+ }
+
}
diff --git a/camera/camera-view/api/public_plus_experimental_current.txt b/camera/camera-view/api/public_plus_experimental_current.txt
index 2faf2d6..a02bc5e 100644
--- a/camera/camera-view/api/public_plus_experimental_current.txt
+++ b/camera/camera-view/api/public_plus_experimental_current.txt
@@ -83,6 +83,14 @@
enum_constant public static final androidx.camera.view.PreviewView.StreamState STREAMING;
}
+ public abstract class RotationReceiver {
+ ctor public RotationReceiver(android.content.Context);
+ method public boolean canDetectOrientation();
+ method public void disable();
+ method public void enable();
+ method public abstract void onRotationChanged(int);
+ }
+
}
package androidx.camera.view.transform {
diff --git a/camera/camera-view/api/restricted_current.txt b/camera/camera-view/api/restricted_current.txt
index 56cdeaa..a47bbc3 100644
--- a/camera/camera-view/api/restricted_current.txt
+++ b/camera/camera-view/api/restricted_current.txt
@@ -75,5 +75,13 @@
enum_constant public static final androidx.camera.view.PreviewView.StreamState STREAMING;
}
+ public abstract class RotationReceiver {
+ ctor public RotationReceiver(android.content.Context);
+ method public boolean canDetectOrientation();
+ method public void disable();
+ method public void enable();
+ method public abstract void onRotationChanged(int);
+ }
+
}
diff --git a/camera/camera-view/src/main/java/androidx/camera/view/CameraController.java b/camera/camera-view/src/main/java/androidx/camera/view/CameraController.java
index 46d7835..98d607f 100644
--- a/camera/camera-view/src/main/java/androidx/camera/view/CameraController.java
+++ b/camera/camera-view/src/main/java/androidx/camera/view/CameraController.java
@@ -205,7 +205,7 @@
// Synthetic access
@SuppressWarnings("WeakerAccess")
@NonNull
- final SensorRotationListener mSensorRotationListener;
+ final RotationReceiver mRotationReceiver;
@Nullable
private final DisplayRotationListener mDisplayRotationListener;
@@ -242,7 +242,7 @@
// Listen to motion sensor reading and set target rotation for ImageCapture and
// VideoCapture.
- mSensorRotationListener = new SensorRotationListener(mAppContext) {
+ mRotationReceiver = new RotationReceiver(mAppContext) {
@Override
public void onRotationChanged(int rotation) {
mImageAnalysis.setTargetRotation(rotation);
@@ -419,14 +419,14 @@
private void startListeningToRotationEvents() {
getDisplayManager().registerDisplayListener(mDisplayRotationListener,
new Handler(Looper.getMainLooper()));
- if (mSensorRotationListener.canDetectOrientation()) {
- mSensorRotationListener.enable();
+ if (mRotationReceiver.canDetectOrientation()) {
+ mRotationReceiver.enable();
}
}
private void stopListeningToRotationEvents() {
getDisplayManager().unregisterDisplayListener(mDisplayRotationListener);
- mSensorRotationListener.disable();
+ mRotationReceiver.disable();
}
private DisplayManager getDisplayManager() {
diff --git a/camera/camera-view/src/main/java/androidx/camera/view/RotationReceiver.java b/camera/camera-view/src/main/java/androidx/camera/view/RotationReceiver.java
new file mode 100644
index 0000000..b64fad4
--- /dev/null
+++ b/camera/camera-view/src/main/java/androidx/camera/view/RotationReceiver.java
@@ -0,0 +1,137 @@
+/*
+ * Copyright 2021 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.camera.view;
+
+import android.content.Context;
+import android.hardware.SensorManager;
+import android.view.OrientationEventListener;
+import android.view.Surface;
+
+import androidx.annotation.NonNull;
+import androidx.camera.core.UseCase;
+
+/**
+ * Helper class for receiving rotation updates from the {@link SensorManager} when the
+ * orientation of the device has changed.
+ *
+ * <p> This class is an wrapper of {@link OrientationEventListener} that notifies the app about
+ * physical orientation changes in the format of {@link Surface} rotation. It's useful when the
+ * device UI is in a fixed portrait or landscape orientation, while the app still wants to set the
+ * {@link UseCase} target rotation based on the device's physical orientation.
+ *
+ * <pre><code>
+ * rotationReceiver = new RotationReceiver(context) {
+ * public void onRotationChanged(int rotation) {
+ * mImageCapture.setTargetRotation(rotation);
+ * }
+ * };
+ * if (rotationReceiver.canDetectOrientation()) {
+ * rotationReceiver.enable();
+ * }
+ *
+ * // Disable it when it's no longer needed.
+ * rotationReceiver.disable();
+ * </code></pre>
+ *
+ * @see OrientationEventListener
+ */
+public abstract class RotationReceiver {
+
+ private static final int INVALID_SURFACE_ROTATION = -1;
+
+ // Synthetic access
+ @SuppressWarnings("WeakerAccess")
+ int mRotation = INVALID_SURFACE_ROTATION;
+
+ private final OrientationEventListener mOrientationEventListener;
+
+ public RotationReceiver(@NonNull Context context) {
+ mOrientationEventListener = new OrientationEventListener(context) {
+ @Override
+ public void onOrientationChanged(int orientation) {
+ if (orientation == OrientationEventListener.ORIENTATION_UNKNOWN) {
+ // Short-circuit if orientation is unknown. Unknown rotation can't be handled
+ // so it shouldn't be sent.
+ return;
+ }
+
+ int newRotation;
+ if (orientation >= 315 || orientation < 45) {
+ newRotation = Surface.ROTATION_0;
+ } else if (orientation >= 225) {
+ newRotation = Surface.ROTATION_90;
+ } else if (orientation >= 135) {
+ newRotation = Surface.ROTATION_180;
+ } else {
+ newRotation = Surface.ROTATION_270;
+ }
+ if (mRotation != newRotation) {
+ mRotation = newRotation;
+ onRotationChanged(newRotation);
+ }
+ }
+ };
+ }
+
+ /**
+ * Checks if the RotationReceiver can detect orientation changes.
+ *
+ * @see OrientationEventListener#canDetectOrientation()
+ */
+ public boolean canDetectOrientation() {
+ return mOrientationEventListener.canDetectOrientation();
+ }
+
+ /**
+ * Enables the RotationReceiver so it will monitor the sensor and call onRotationChanged when
+ * the device orientation changes.
+ *
+ * <p> By default, the receiver is not enabled.
+ *
+ * @see OrientationEventListener#enable()
+ */
+ public void enable() {
+ mOrientationEventListener.enable();
+ }
+
+ /**
+ * Disables the RotationReceiver.
+ *
+ * @see OrientationEventListener#disable()
+ */
+ public void disable() {
+ mOrientationEventListener.disable();
+ }
+
+ /**
+ * Called when the physical rotation of the device changes.
+ *
+ * <p> The rotation is one of the {@link Surface} rotations mapped from orientation
+ * degrees.
+ *
+ * <table summary="Orientation degrees to Surface rotation mapping">
+ * <tr><th>Orientation degrees</th><th>Surface rotation</th></tr>
+ * <tr><td>[-45°, 45°)</td><td>{@link Surface#ROTATION_0}</td></tr>
+ * <tr><td>[45°, 135°)</td><td>{@link Surface#ROTATION_270}</td></tr>
+ * <tr><td>[135°, 225°)</td><td>{@link Surface#ROTATION_180}</td></tr>
+ * <tr><td>[225°, 315°)</td><td>{@link Surface#ROTATION_90}</td></tr>
+ * </table>
+ *
+ * @see OrientationEventListener#onOrientationChanged(int)
+ */
+ public abstract void onRotationChanged(int rotation);
+}
diff --git a/camera/camera-view/src/main/java/androidx/camera/view/SensorRotationListener.java b/camera/camera-view/src/main/java/androidx/camera/view/SensorRotationListener.java
deleted file mode 100644
index d0919d4..0000000
--- a/camera/camera-view/src/main/java/androidx/camera/view/SensorRotationListener.java
+++ /dev/null
@@ -1,74 +0,0 @@
-/*
- * 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.camera.view;
-
-import android.content.Context;
-import android.view.OrientationEventListener;
-import android.view.Surface;
-
-import androidx.annotation.NonNull;
-import androidx.annotation.RestrictTo;
-
-/**
- * Listens to motion sensor reading and converts the orientation degrees to {@link Surface}
- * rotation.
- *
- * @hide
- */
-@RestrictTo(RestrictTo.Scope.LIBRARY_GROUP)
-public abstract class SensorRotationListener extends OrientationEventListener {
-
- public static final int INVALID_SURFACE_ROTATION = -1;
-
- private int mRotation = INVALID_SURFACE_ROTATION;
-
- public SensorRotationListener(@NonNull Context context) {
- super(context);
- }
-
- @Override
- public void onOrientationChanged(int orientation) {
- if (orientation == OrientationEventListener.ORIENTATION_UNKNOWN) {
- // Short-circuit if orientation is unknown. Unknown rotation can't be handled so it
- // shouldn't be sent.
- return;
- }
-
- int newRotation;
- if (orientation >= 315 || orientation < 45) {
- newRotation = Surface.ROTATION_0;
- } else if (orientation >= 225) {
- newRotation = Surface.ROTATION_90;
- } else if (orientation >= 135) {
- newRotation = Surface.ROTATION_180;
- } else {
- newRotation = Surface.ROTATION_270;
- }
- if (mRotation != newRotation) {
- mRotation = newRotation;
- onRotationChanged(newRotation);
- }
- }
-
- /**
- * Invoked when rotation changes.
- *
- * <p> The output rotation is defined as the UI Surface rotation, or what the Surface rotation
- * should be if the app's orientation is not locked.
- */
- public abstract void onRotationChanged(int rotation);
-}
diff --git a/camera/camera-view/src/test/java/androidx/camera/view/CameraControllerTest.kt b/camera/camera-view/src/test/java/androidx/camera/view/CameraControllerTest.kt
index 916d316..fe3a1c0 100644
--- a/camera/camera-view/src/test/java/androidx/camera/view/CameraControllerTest.kt
+++ b/camera/camera-view/src/test/java/androidx/camera/view/CameraControllerTest.kt
@@ -64,7 +64,7 @@
val controller = LifecycleCameraController(context)
// Act.
- controller.mSensorRotationListener.onRotationChanged(Surface.ROTATION_180)
+ controller.mRotationReceiver.onRotationChanged(Surface.ROTATION_180)
// Assert.
assertThat(controller.mImageAnalysis.targetRotation).isEqualTo(Surface.ROTATION_180)
diff --git a/camera/integration-tests/coretestapp/src/androidTest/java/androidx/camera/integration/core/MLKitBarcodeTest.kt b/camera/integration-tests/coretestapp/src/androidTest/java/androidx/camera/integration/core/MLKitBarcodeTest.kt
new file mode 100644
index 0000000..7a667a2
--- /dev/null
+++ b/camera/integration-tests/coretestapp/src/androidTest/java/androidx/camera/integration/core/MLKitBarcodeTest.kt
@@ -0,0 +1,177 @@
+/*
+ * Copyright 2021 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.camera.integration.core
+
+import android.content.Context
+import android.util.Log
+import android.util.Size
+import androidx.camera.camera2.Camera2Config
+import androidx.camera.core.CameraSelector
+import androidx.camera.core.CameraX
+import androidx.camera.core.CameraXConfig
+import androidx.camera.core.ImageAnalysis
+import androidx.camera.core.internal.CameraUseCaseAdapter
+import androidx.camera.testing.CameraUtil
+import androidx.camera.testing.LabTestRule
+import androidx.test.core.app.ApplicationProvider
+import androidx.test.filters.LargeTest
+import com.google.mlkit.vision.barcode.Barcode.FORMAT_QR_CODE
+import com.google.mlkit.vision.barcode.BarcodeScanner
+import com.google.mlkit.vision.barcode.BarcodeScannerOptions
+import com.google.mlkit.vision.barcode.BarcodeScanning
+import com.google.mlkit.vision.common.InputImage
+import kotlinx.coroutines.Dispatchers
+import kotlinx.coroutines.asExecutor
+import kotlinx.coroutines.runBlocking
+import kotlinx.coroutines.withContext
+import org.junit.After
+import org.junit.Assert.assertTrue
+import org.junit.Before
+import org.junit.Rule
+import org.junit.Test
+import org.junit.runner.RunWith
+import org.junit.runners.Parameterized
+import java.util.concurrent.CountDownLatch
+import java.util.concurrent.TimeUnit
+
+// The integration-tests for MLKit vision barcode component with CameraX ImageAnalysis use case.
+@LargeTest
+@RunWith(Parameterized::class)
+class MLKitBarcodeTest(
+ private val resolution: Size,
+ private val cameraConfig: CameraXConfig
+) {
+
+ @get:Rule
+ val cameraRule = CameraUtil.grantCameraPermissionAndPreTest()
+
+ @get:Rule
+ val labTest: LabTestRule = LabTestRule()
+
+ companion object {
+ private const val DETECT_TIMEOUT = 5_000L
+ private const val TAG = "MLKitVisionTest"
+
+ // TODO(b/189279877) Add different CameraXConfig (Camera2Config, CameraPipeConfig)
+ // as parameters.
+ @JvmStatic
+ @Parameterized.Parameters(name = "{0}")
+ fun data() = listOf(
+ arrayOf(Size(640, 480), Camera2Config.defaultConfig()),
+ arrayOf(Size(1280, 720), Camera2Config.defaultConfig())
+ )
+ }
+
+ private val context: Context = ApplicationProvider.getApplicationContext()
+ private lateinit var camera: CameraUseCaseAdapter
+ // For MK Kit Barcode scanner
+ private lateinit var barcodeScanner: BarcodeScanner
+
+ @Before
+ fun setup() {
+ CameraX.initialize(context, cameraConfig).get(10, TimeUnit.SECONDS)
+
+ barcodeScanner = BarcodeScanning.getClient(
+ BarcodeScannerOptions.Builder().setBarcodeFormats(FORMAT_QR_CODE).build()
+ )
+ }
+
+ @After
+ fun tearDown(): Unit = runBlocking {
+ if (::camera.isInitialized) {
+ // TODO: The removeUseCases() call might be removed after clarifying the
+ // abortCaptures() issue in b/162314023
+ withContext(Dispatchers.Main) {
+ camera.removeUseCases(camera.useCases)
+ }
+ }
+ CameraX.shutdown().get(10, TimeUnit.SECONDS)
+
+ if (::barcodeScanner.isInitialized) {
+ barcodeScanner.close()
+ }
+ }
+
+ @LabTestRule.LabTestFrontCamera
+ @Test
+ fun barcodeDetectViaFontCamera() {
+ val imageAnalysis = initImageAnalysis()
+
+ camera = CameraUtil.createCameraAndAttachUseCase(
+ context,
+ CameraSelector.DEFAULT_FRONT_CAMERA,
+ imageAnalysis
+ )
+ assertBarcodeDetect(imageAnalysis)
+ }
+
+ @LabTestRule.LabTestRearCamera
+ @Test
+ fun barcodeDetectViaRearCamera() {
+ val imageAnalysis = initImageAnalysis()
+
+ camera = CameraUtil.createCameraAndAttachUseCase(
+ context,
+ CameraSelector.DEFAULT_BACK_CAMERA,
+ imageAnalysis
+ )
+ assertBarcodeDetect(imageAnalysis)
+ }
+
+ private fun assertBarcodeDetect(imageAnalysis: ImageAnalysis) {
+ val latchForBarcodeDetect = CountDownLatch(4)
+
+ imageAnalysis.setAnalyzer(
+ Dispatchers.Main.asExecutor(),
+ { imageProxy ->
+ barcodeScanner.process(
+ InputImage.fromMediaImage(
+ imageProxy.image!!,
+ imageProxy.imageInfo.rotationDegrees
+ )
+ )
+ .addOnSuccessListener { barcodes ->
+ barcodes.forEach {
+ if ("Hi, CamX!" == it.displayValue) {
+ latchForBarcodeDetect.countDown()
+ Log.d(TAG, "barcode display value: {${it.displayValue}} ")
+ }
+ }
+ }
+ .addOnFailureListener { exception ->
+ Log.e(TAG, "processImage onFailure: $exception")
+ }
+ // When the image is from CameraX analysis use case, must call image.close() on
+ // received images when finished using them. Otherwise, new images may not be
+ // received or the camera may stall.
+ .addOnCompleteListener {
+ imageProxy.close()
+ }
+ }
+ )
+
+ // Verify it is the CameraX lab test environment and can detect qr-code.
+ assertTrue(latchForBarcodeDetect.await(DETECT_TIMEOUT, TimeUnit.MILLISECONDS))
+ }
+
+ private fun initImageAnalysis(): ImageAnalysis {
+ return ImageAnalysis.Builder()
+ .setTargetName("ImageAnalysis")
+ .setTargetResolution(resolution)
+ .build()
+ }
+}
diff --git a/camera/integration-tests/coretestapp/src/main/java/androidx/camera/integration/core/CameraXActivity.java b/camera/integration-tests/coretestapp/src/main/java/androidx/camera/integration/core/CameraXActivity.java
index c990c34..bf2dd58 100644
--- a/camera/integration-tests/coretestapp/src/main/java/androidx/camera/integration/core/CameraXActivity.java
+++ b/camera/integration-tests/coretestapp/src/main/java/androidx/camera/integration/core/CameraXActivity.java
@@ -195,7 +195,6 @@
private FutureCallback<Integer> mEVFutureCallback = new FutureCallback<Integer>() {
@Override
- @OptIn(markerClass = androidx.camera.core.ExperimentalExposureCompensation.class)
public void onSuccess(@Nullable Integer result) {
CameraInfo cameraInfo = getCameraInfo();
if (cameraInfo != null) {
@@ -324,7 +323,6 @@
return mPhotoToggle.isChecked() && cameraInfo != null && cameraInfo.hasFlashUnit();
}
- @OptIn(markerClass = androidx.camera.core.ExperimentalExposureCompensation.class)
private boolean isExposureCompensationSupported() {
CameraInfo cameraInfo = getCameraInfo();
return cameraInfo != null
@@ -469,7 +467,6 @@
});
}
- @OptIn(markerClass = androidx.camera.core.ExperimentalExposureCompensation.class)
private void setUpEVButton() {
mPlusEV.setOnClickListener(v -> {
Objects.requireNonNull(getCameraInfo());
diff --git a/camera/integration-tests/viewtestapp/src/main/java/androidx/camera/integration/view/CameraControllerFragment.java b/camera/integration-tests/viewtestapp/src/main/java/androidx/camera/integration/view/CameraControllerFragment.java
index 46cb4308..9fab3a8f 100644
--- a/camera/integration-tests/viewtestapp/src/main/java/androidx/camera/integration/view/CameraControllerFragment.java
+++ b/camera/integration-tests/viewtestapp/src/main/java/androidx/camera/integration/view/CameraControllerFragment.java
@@ -51,7 +51,7 @@
import androidx.camera.view.CameraController;
import androidx.camera.view.LifecycleCameraController;
import androidx.camera.view.PreviewView;
-import androidx.camera.view.SensorRotationListener;
+import androidx.camera.view.RotationReceiver;
import androidx.camera.view.video.ExperimentalVideo;
import androidx.camera.view.video.OnVideoSavedCallback;
import androidx.camera.view.video.OutputFileOptions;
@@ -89,7 +89,7 @@
private ToggleButton mTapToFocusToggle;
private TextView mZoomStateText;
private TextView mTorchStateText;
- private RotationListener mSensorRotationListener;
+ private SensorRotationReceiver mSensorRotationReceiver;
private TextView mLuminance;
private boolean mIsAnalyzerSet = true;
@@ -123,8 +123,8 @@
@Nullable ViewGroup container,
@Nullable Bundle savedInstanceState) {
mExecutorService = Executors.newSingleThreadExecutor();
- mSensorRotationListener = new RotationListener(requireContext());
- mSensorRotationListener.enable();
+ mSensorRotationReceiver = new SensorRotationReceiver(requireContext());
+ mSensorRotationReceiver.enable();
mCameraController = new LifecycleCameraController(requireContext());
checkFailedFuture(mCameraController.getInitializationFuture());
runSafely(() -> mCameraController.bindToLifecycle(getViewLifecycleOwner()));
@@ -321,8 +321,8 @@
if (mExecutorService != null) {
mExecutorService.shutdown();
}
- if (mSensorRotationListener != null) {
- mSensorRotationListener.disable();
+ if (mSensorRotationReceiver != null) {
+ mSensorRotationReceiver.disable();
}
}
@@ -451,11 +451,11 @@
/**
* Listens to accelerometer rotation change and pass it to tests.
*/
- static class RotationListener extends SensorRotationListener {
+ static class SensorRotationReceiver extends RotationReceiver {
private int mRotation;
- RotationListener(@NonNull Context context) {
+ SensorRotationReceiver(@NonNull Context context) {
super(context);
}
@@ -498,7 +498,7 @@
*/
@RestrictTo(RestrictTo.Scope.TESTS)
int getSensorRotation() {
- return mSensorRotationListener.getRotation();
+ return mSensorRotationReceiver.getRotation();
}
@VisibleForTesting
diff --git a/car/app/app-automotive/src/main/java/androidx/car/app/activity/CarAppActivity.java b/car/app/app-automotive/src/main/java/androidx/car/app/activity/CarAppActivity.java
index be5bb52..e981329 100644
--- a/car/app/app-automotive/src/main/java/androidx/car/app/activity/CarAppActivity.java
+++ b/car/app/app-automotive/src/main/java/androidx/car/app/activity/CarAppActivity.java
@@ -84,9 +84,14 @@
* <p>Note the name of the alias should be unique and resemble a fully qualified class name, but
* unlike the name of the target activity, the alias name is arbitrary; it does not refer to an
* actual class.
+ *
+ * <h4>Distraction-optimized Activities</h4>
+ *
+ * <p>The activity must be the {@code distractionOptimized} meta-data set to {@code true}, in order
+ * for it to be displayed while driving. This is the only activity that can have this meta-data
+ * set to {@code true}, any other activities marked this way may cause the app to be rejected
+ * during app submission.
*/
-// TODO(b/179225768): Remove distractionOptimized from the javadoc above if we can make that
-// implicit for car apps.
@SuppressLint({"ForbiddenSuperClass"})
public final class CarAppActivity extends FragmentActivity {
@VisibleForTesting
diff --git a/car/app/app-samples/showcase/common/src/main/java/androidx/car/app/sample/showcase/common/templates/MessageTemplateDemoScreen.java b/car/app/app-samples/showcase/common/src/main/java/androidx/car/app/sample/showcase/common/templates/MessageTemplateDemoScreen.java
index 100a797..860446f 100644
--- a/car/app/app-samples/showcase/common/src/main/java/androidx/car/app/sample/showcase/common/templates/MessageTemplateDemoScreen.java
+++ b/car/app/app-samples/showcase/common/src/main/java/androidx/car/app/sample/showcase/common/templates/MessageTemplateDemoScreen.java
@@ -16,12 +16,15 @@
package androidx.car.app.sample.showcase.common.templates;
+import static androidx.car.app.CarToast.LENGTH_LONG;
import static androidx.car.app.model.Action.BACK;
import androidx.annotation.NonNull;
import androidx.car.app.CarContext;
+import androidx.car.app.CarToast;
import androidx.car.app.Screen;
import androidx.car.app.model.Action;
+import androidx.car.app.model.ActionStrip;
import androidx.car.app.model.CarColor;
import androidx.car.app.model.CarIcon;
import androidx.car.app.model.MessageTemplate;
@@ -60,6 +63,21 @@
throw new RuntimeException("Error");
})
.build())
+
+ .setActionStrip(
+ new ActionStrip.Builder()
+ .addAction(
+ new Action.Builder()
+ .setTitle("Settings")
+ .setOnClickListener(
+ () ->
+ CarToast.makeText(
+ getCarContext(),
+ "Clicked Settings",
+ LENGTH_LONG)
+ .show())
+ .build())
+ .build())
.build();
}
}
diff --git a/car/app/app-samples/showcase/common/src/main/java/androidx/car/app/sample/showcase/common/templates/SignInTemplateDemoScreen.java b/car/app/app-samples/showcase/common/src/main/java/androidx/car/app/sample/showcase/common/templates/SignInTemplateDemoScreen.java
index 365b683..a545dcd 100644
--- a/car/app/app-samples/showcase/common/src/main/java/androidx/car/app/sample/showcase/common/templates/SignInTemplateDemoScreen.java
+++ b/car/app/app-samples/showcase/common/src/main/java/androidx/car/app/sample/showcase/common/templates/SignInTemplateDemoScreen.java
@@ -260,6 +260,8 @@
// .setClass(getCarContext(), SignInWithGoogleActivity.class)
// .addFlags(Intent.FLAG_ACTIVITY_NEW_TASK)
// .putExtras(extras));
+ CarToast.makeText(getCarContext(), "Sign-in with Google starts here", LENGTH_LONG)
+ .show();
}
private MessageTemplate getSignInCompletedMessageTemplate() {
diff --git a/car/app/app/api/current.txt b/car/app/app/api/current.txt
index 3a71b2b..03237cc 100644
--- a/car/app/app/api/current.txt
+++ b/car/app/app/api/current.txt
@@ -55,6 +55,7 @@
field public static final String CAR_SERVICE = "car";
field @androidx.car.app.annotations.RequiresCarApi(2) public static final String CONSTRAINT_SERVICE = "constraints";
field public static final String EXTRA_START_CAR_APP_BINDER_KEY = "androidx.car.app.extra.START_CAR_APP_BINDER_KEY";
+ field @androidx.car.app.annotations.RequiresCarApi(3) public static final String HARDWARE_SERVICE = "hardware";
field public static final String NAVIGATION_SERVICE = "navigation";
field public static final String SCREEN_SERVICE = "screen";
}
@@ -189,16 +190,6 @@
field public static final int CONNECTION_TYPE_PROJECTION = 2; // 0x2
}
- @Deprecated public final class ConnectionToCar {
- ctor @Deprecated public ConnectionToCar(android.content.Context);
- method @Deprecated public androidx.lifecycle.LiveData<java.lang.Integer!> getType();
- field @Deprecated public static final String ACTION_CAR_CONNECTION_UPDATED = "androidx.car.app.connection.action.CAR_CONNECTION_UPDATED";
- field @Deprecated public static final String CAR_CONNECTION_STATE = "CarConnectionState";
- field @Deprecated public static final int NATIVE = 1; // 0x1
- field @Deprecated public static final int NOT_CONNECTED = 0; // 0x0
- field @Deprecated public static final int PROJECTION = 2; // 0x2
- }
-
}
package androidx.car.app.constraints {
@@ -214,6 +205,285 @@
}
+package androidx.car.app.hardware {
+
+ @androidx.car.app.annotations.RequiresCarApi(3) public interface CarHardwareManager {
+ method public default androidx.car.app.hardware.info.CarInfo getCarInfo();
+ method public default androidx.car.app.hardware.info.CarSensors getCarSensors();
+ }
+
+}
+
+package androidx.car.app.hardware.common {
+
+ @androidx.car.app.annotations.CarProtocol @androidx.car.app.annotations.RequiresCarApi(3) public final class CarUnit {
+ field public static final int KILOMETER = 3; // 0x3
+ field public static final int KILOMETERS_PER_HOUR = 102; // 0x66
+ field public static final int METER = 2; // 0x2
+ field public static final int METERS_PER_SEC = 101; // 0x65
+ field public static final int MILE = 4; // 0x4
+ field public static final int MILES_PER_HOUR = 103; // 0x67
+ field public static final int MILLIMETER = 1; // 0x1
+ }
+
+ @androidx.car.app.annotations.CarProtocol @androidx.car.app.annotations.RequiresCarApi(3) public final class CarValue<T> {
+ ctor public CarValue(T?, long, int);
+ method public int getStatus();
+ method public long getTimestampMillis();
+ method public T? getValue();
+ field public static final int STATUS_SUCCESS = 1; // 0x1
+ field public static final int STATUS_UNAVAILABLE = 3; // 0x3
+ field public static final int STATUS_UNIMPLEMENTED = 2; // 0x2
+ field public static final int STATUS_UNKNOWN = 0; // 0x0
+ }
+
+ @androidx.car.app.annotations.CarProtocol @androidx.car.app.annotations.RequiresCarApi(3) public interface OnCarDataListener<T> {
+ method public void onCarData(T);
+ }
+
+ @androidx.car.app.annotations.CarProtocol @androidx.car.app.annotations.RequiresCarApi(3) public final class UpdateRate {
+ field public static final int DEFAULT = 0; // 0x0
+ field public static final int FASTEST = 2; // 0x2
+ field public static final int UI = 1; // 0x1
+ }
+
+}
+
+package androidx.car.app.hardware.info {
+
+ @androidx.car.app.annotations.CarProtocol @androidx.car.app.annotations.RequiresCarApi(3) public final class Accelerometer {
+ method public androidx.car.app.hardware.common.CarValue<java.lang.Float![]!> getAccelerometer();
+ }
+
+ public static final class Accelerometer.Builder {
+ ctor public Accelerometer.Builder();
+ method public androidx.car.app.hardware.info.Accelerometer build();
+ method public androidx.car.app.hardware.info.Accelerometer.Builder setAccelerometer(androidx.car.app.hardware.common.CarValue<java.lang.Float![]!>);
+ }
+
+ public static final class Accelerometer.Params {
+ ctor public Accelerometer.Params(int);
+ method public static androidx.car.app.hardware.info.Accelerometer.Params getDefault();
+ method public int getRate();
+ }
+
+ @androidx.car.app.annotations.CarProtocol @androidx.car.app.annotations.RequiresCarApi(3) public final class CarHardwareLocation {
+ method public androidx.car.app.hardware.common.CarValue<android.location.Location!> getLocation();
+ }
+
+ public static final class CarHardwareLocation.Builder {
+ ctor public CarHardwareLocation.Builder();
+ method public androidx.car.app.hardware.info.CarHardwareLocation build();
+ method public androidx.car.app.hardware.info.CarHardwareLocation.Builder setLocation(androidx.car.app.hardware.common.CarValue<android.location.Location!>);
+ }
+
+ public static final class CarHardwareLocation.Params {
+ ctor public CarHardwareLocation.Params(int);
+ method public static androidx.car.app.hardware.info.CarHardwareLocation.Params getDefault();
+ method public int getRate();
+ }
+
+ @androidx.car.app.annotations.RequiresCarApi(3) public interface CarInfo {
+ method public void addEnergyLevelListener(androidx.car.app.hardware.info.EnergyLevel.Params, java.util.concurrent.Executor, androidx.car.app.hardware.common.OnCarDataListener<androidx.car.app.hardware.info.EnergyLevel!>);
+ method public void addMileageListener(androidx.car.app.hardware.info.Mileage.Params, java.util.concurrent.Executor, androidx.car.app.hardware.common.OnCarDataListener<androidx.car.app.hardware.info.Mileage!>);
+ method public void addSpeedListener(androidx.car.app.hardware.info.Speed.Params, java.util.concurrent.Executor, androidx.car.app.hardware.common.OnCarDataListener<androidx.car.app.hardware.info.Speed!>);
+ method public void addTollListener(androidx.car.app.hardware.info.Toll.Params, java.util.concurrent.Executor, androidx.car.app.hardware.common.OnCarDataListener<androidx.car.app.hardware.info.Toll!>);
+ method public void getEnergyProfile(androidx.car.app.hardware.info.EnergyProfile.Params, java.util.concurrent.Executor, androidx.car.app.hardware.common.OnCarDataListener<androidx.car.app.hardware.info.EnergyProfile!>);
+ method public void getModel(androidx.car.app.hardware.info.Model.Params, java.util.concurrent.Executor, androidx.car.app.hardware.common.OnCarDataListener<androidx.car.app.hardware.info.Model!>);
+ method public void removeEnergyLevelListener(androidx.car.app.hardware.common.OnCarDataListener<androidx.car.app.hardware.info.EnergyLevel!>);
+ method public void removeMileageListener(androidx.car.app.hardware.common.OnCarDataListener<androidx.car.app.hardware.info.Mileage!>);
+ method public void removeSpeedListener(androidx.car.app.hardware.common.OnCarDataListener<androidx.car.app.hardware.info.Speed!>);
+ method public void removeTollListener(androidx.car.app.hardware.common.OnCarDataListener<androidx.car.app.hardware.info.Toll!>);
+ }
+
+ @androidx.car.app.annotations.RequiresCarApi(3) public interface CarSensors {
+ method public void addAccelerometerListener(androidx.car.app.hardware.info.Accelerometer.Params, java.util.concurrent.Executor, androidx.car.app.hardware.common.OnCarDataListener<androidx.car.app.hardware.info.Accelerometer!>);
+ method public void addCarHardwareLocationListener(androidx.car.app.hardware.info.CarHardwareLocation.Params, java.util.concurrent.Executor, androidx.car.app.hardware.common.OnCarDataListener<androidx.car.app.hardware.info.CarHardwareLocation!>);
+ method public void addCompassListener(androidx.car.app.hardware.info.Compass.Params, java.util.concurrent.Executor, androidx.car.app.hardware.common.OnCarDataListener<androidx.car.app.hardware.info.Compass!>);
+ method public void addGyroscopeListener(androidx.car.app.hardware.info.Gyroscope.Params, java.util.concurrent.Executor, androidx.car.app.hardware.common.OnCarDataListener<androidx.car.app.hardware.info.Gyroscope!>);
+ method public void removeAccelerometerListener(androidx.car.app.hardware.common.OnCarDataListener<androidx.car.app.hardware.info.Accelerometer!>);
+ method public void removeCarHardwareLocationListener(androidx.car.app.hardware.common.OnCarDataListener<androidx.car.app.hardware.info.CarHardwareLocation!>);
+ method public void removeCompassListener(androidx.car.app.hardware.common.OnCarDataListener<androidx.car.app.hardware.info.Compass!>);
+ method public void removeGyroscopeListener(androidx.car.app.hardware.common.OnCarDataListener<androidx.car.app.hardware.info.Gyroscope!>);
+ }
+
+ @androidx.car.app.annotations.CarProtocol @androidx.car.app.annotations.RequiresCarApi(3) public final class Compass {
+ method public androidx.car.app.hardware.common.CarValue<java.lang.Float![]!> getCompass();
+ }
+
+ public static final class Compass.Builder {
+ ctor public Compass.Builder();
+ method public androidx.car.app.hardware.info.Compass build();
+ method public androidx.car.app.hardware.info.Compass.Builder setCompass(androidx.car.app.hardware.common.CarValue<java.lang.Float![]!>);
+ }
+
+ public static final class Compass.Params {
+ ctor public Compass.Params(int);
+ method public static androidx.car.app.hardware.info.Compass.Params getDefault();
+ method public int getRate();
+ }
+
+ @androidx.car.app.annotations.CarProtocol @androidx.car.app.annotations.RequiresCarApi(3) public final class EnergyLevel {
+ method public androidx.car.app.hardware.common.CarValue<java.lang.Float!> getBatteryPercent();
+ method public androidx.car.app.hardware.common.CarValue<java.lang.Integer!> getDistanceDisplayUnit();
+ method public androidx.car.app.hardware.common.CarValue<java.lang.Boolean!> getEnergyIsLow();
+ method public androidx.car.app.hardware.common.CarValue<java.lang.Float!> getFuelPercent();
+ method public androidx.car.app.hardware.common.CarValue<java.lang.Float!> getRangeRemaining();
+ }
+
+ public static final class EnergyLevel.Builder {
+ ctor public EnergyLevel.Builder();
+ method public androidx.car.app.hardware.info.EnergyLevel build();
+ method public androidx.car.app.hardware.info.EnergyLevel.Builder setBatteryPercent(androidx.car.app.hardware.common.CarValue<java.lang.Float!>);
+ method public androidx.car.app.hardware.info.EnergyLevel.Builder setDistanceDisplayUnit(androidx.car.app.hardware.common.CarValue<java.lang.Integer!>);
+ method public androidx.car.app.hardware.info.EnergyLevel.Builder setEnergyIsLow(androidx.car.app.hardware.common.CarValue<java.lang.Boolean!>);
+ method public androidx.car.app.hardware.info.EnergyLevel.Builder setFuelPercent(androidx.car.app.hardware.common.CarValue<java.lang.Float!>);
+ method public androidx.car.app.hardware.info.EnergyLevel.Builder setRangeRemaining(androidx.car.app.hardware.common.CarValue<java.lang.Float!>);
+ }
+
+ public static final class EnergyLevel.Params {
+ ctor public EnergyLevel.Params(int);
+ method public static androidx.car.app.hardware.info.EnergyLevel.Params getDefault();
+ method public int getRate();
+ }
+
+ @androidx.car.app.annotations.CarProtocol @androidx.car.app.annotations.RequiresCarApi(3) public final class EnergyProfile {
+ method public androidx.car.app.hardware.common.CarValue<java.lang.Integer![]!> getEvConnectorTypes();
+ method public androidx.car.app.hardware.common.CarValue<java.lang.Integer![]!> getFuelTypes();
+ field public static final int EVCONNECTOR_TYPE_CHADEMO = 3; // 0x3
+ field public static final int EVCONNECTOR_TYPE_COMBO_1 = 4; // 0x4
+ field public static final int EVCONNECTOR_TYPE_COMBO_2 = 5; // 0x5
+ field public static final int EVCONNECTOR_TYPE_GBT = 9; // 0x9
+ field public static final int EVCONNECTOR_TYPE_GBT_DC = 10; // 0xa
+ field public static final int EVCONNECTOR_TYPE_J1772 = 1; // 0x1
+ field public static final int EVCONNECTOR_TYPE_MENNEKES = 2; // 0x2
+ field public static final int EVCONNECTOR_TYPE_OTHER = 101; // 0x65
+ field public static final int EVCONNECTOR_TYPE_SCAME = 11; // 0xb
+ field public static final int EVCONNECTOR_TYPE_TESLA_HPWC = 7; // 0x7
+ field public static final int EVCONNECTOR_TYPE_TESLA_ROADSTER = 6; // 0x6
+ field public static final int EVCONNECTOR_TYPE_TESLA_SUPERCHARGER = 8; // 0x8
+ field public static final int EVCONNECTOR_TYPE_UNKNOWN = 0; // 0x0
+ field public static final int FUEL_TYPE_BIODIESEL = 5; // 0x5
+ field public static final int FUEL_TYPE_CNG = 8; // 0x8
+ field public static final int FUEL_TYPE_DIESEL_1 = 3; // 0x3
+ field public static final int FUEL_TYPE_DIESEL_2 = 4; // 0x4
+ field public static final int FUEL_TYPE_E85 = 6; // 0x6
+ field public static final int FUEL_TYPE_ELECTRIC = 10; // 0xa
+ field public static final int FUEL_TYPE_HYDROGEN = 11; // 0xb
+ field public static final int FUEL_TYPE_LEADED = 2; // 0x2
+ field public static final int FUEL_TYPE_LNG = 9; // 0x9
+ field public static final int FUEL_TYPE_LPG = 7; // 0x7
+ field public static final int FUEL_TYPE_OTHER = 12; // 0xc
+ field public static final int FUEL_TYPE_UNKNOWN = 0; // 0x0
+ field public static final int FUEL_TYPE_UNLEADED = 1; // 0x1
+ }
+
+ public static final class EnergyProfile.Builder {
+ ctor public EnergyProfile.Builder();
+ method public androidx.car.app.hardware.info.EnergyProfile build();
+ method public androidx.car.app.hardware.info.EnergyProfile.Builder setEvConnectorTypes(androidx.car.app.hardware.common.CarValue<java.lang.Integer![]!>);
+ method public androidx.car.app.hardware.info.EnergyProfile.Builder setFuelTypes(androidx.car.app.hardware.common.CarValue<java.lang.Integer![]!>);
+ }
+
+ public static final class EnergyProfile.Params {
+ ctor public EnergyProfile.Params();
+ method public static androidx.car.app.hardware.info.EnergyProfile.Params getDefault();
+ }
+
+ @androidx.car.app.annotations.CarProtocol @androidx.car.app.annotations.RequiresCarApi(3) public final class Gyroscope {
+ method public androidx.car.app.hardware.common.CarValue<java.lang.Float![]!> getGyroscope();
+ }
+
+ public static final class Gyroscope.Builder {
+ ctor public Gyroscope.Builder();
+ method public androidx.car.app.hardware.info.Gyroscope build();
+ method public androidx.car.app.hardware.info.Gyroscope.Builder setGyroscope(androidx.car.app.hardware.common.CarValue<java.lang.Float![]!>);
+ }
+
+ public static final class Gyroscope.Params {
+ ctor public Gyroscope.Params(int);
+ method public static androidx.car.app.hardware.info.Gyroscope.Params getDefault();
+ method public int getRate();
+ }
+
+ @androidx.car.app.annotations.CarProtocol @androidx.car.app.annotations.RequiresCarApi(3) public final class Mileage {
+ method public androidx.car.app.hardware.common.CarValue<java.lang.Integer!> getDistanceDisplayUnit();
+ method public androidx.car.app.hardware.common.CarValue<java.lang.Float!> getOdometer();
+ }
+
+ public static final class Mileage.Builder {
+ ctor public Mileage.Builder();
+ method public androidx.car.app.hardware.info.Mileage build();
+ method public androidx.car.app.hardware.info.Mileage.Builder setDistanceDisplayUnit(androidx.car.app.hardware.common.CarValue<java.lang.Integer!>);
+ method public androidx.car.app.hardware.info.Mileage.Builder setOdometer(androidx.car.app.hardware.common.CarValue<java.lang.Float!>);
+ }
+
+ public static final class Mileage.Params {
+ ctor public Mileage.Params(int);
+ method public static androidx.car.app.hardware.info.Mileage.Params getDefault();
+ method public int getRate();
+ }
+
+ @androidx.car.app.annotations.CarProtocol @androidx.car.app.annotations.RequiresCarApi(3) public final class Model {
+ method public androidx.car.app.hardware.common.CarValue<java.lang.String!> getManufacturer();
+ method public androidx.car.app.hardware.common.CarValue<java.lang.String!> getName();
+ method public androidx.car.app.hardware.common.CarValue<java.lang.Integer!> getYear();
+ }
+
+ public static final class Model.Builder {
+ ctor public Model.Builder();
+ method public androidx.car.app.hardware.info.Model build();
+ method public androidx.car.app.hardware.info.Model.Builder setManufacturer(androidx.car.app.hardware.common.CarValue<java.lang.String!>);
+ method public androidx.car.app.hardware.info.Model.Builder setName(androidx.car.app.hardware.common.CarValue<java.lang.String!>);
+ method public androidx.car.app.hardware.info.Model.Builder setYear(androidx.car.app.hardware.common.CarValue<java.lang.Integer!>);
+ }
+
+ public static final class Model.Params {
+ ctor public Model.Params();
+ method public static androidx.car.app.hardware.info.Model.Params getDefault();
+ }
+
+ @androidx.car.app.annotations.CarProtocol @androidx.car.app.annotations.RequiresCarApi(3) public final class Speed {
+ method public androidx.car.app.hardware.common.CarValue<java.lang.Float!> getDisplaySpeed();
+ method public androidx.car.app.hardware.common.CarValue<java.lang.Float!> getRawSpeed();
+ method public androidx.car.app.hardware.common.CarValue<java.lang.Integer!> getSpeedDisplayUnit();
+ }
+
+ public static final class Speed.Builder {
+ ctor public Speed.Builder();
+ method public androidx.car.app.hardware.info.Speed build();
+ method public androidx.car.app.hardware.info.Speed.Builder setDisplaySpeed(androidx.car.app.hardware.common.CarValue<java.lang.Float!>);
+ method public androidx.car.app.hardware.info.Speed.Builder setRawSpeed(androidx.car.app.hardware.common.CarValue<java.lang.Float!>);
+ method public androidx.car.app.hardware.info.Speed.Builder setSpeedDisplayUnit(androidx.car.app.hardware.common.CarValue<java.lang.Integer!>);
+ }
+
+ public static final class Speed.Params {
+ ctor public Speed.Params(int);
+ method public static androidx.car.app.hardware.info.Speed.Params getDefault();
+ method public int getRate();
+ }
+
+ @androidx.car.app.annotations.CarProtocol @androidx.car.app.annotations.RequiresCarApi(3) public final class Toll {
+ method public androidx.car.app.hardware.common.CarValue<java.lang.Integer!> getCardState();
+ field public static final int TOLLCARD_STATE_INVALID = 2; // 0x2
+ field public static final int TOLLCARD_STATE_NOT_INSERTED = 3; // 0x3
+ field public static final int TOLLCARD_STATE_UNKNOWN = 0; // 0x0
+ field public static final int TOLLCARD_STATE_VALID = 1; // 0x1
+ }
+
+ public static final class Toll.Builder {
+ ctor public Toll.Builder();
+ method public androidx.car.app.hardware.info.Toll build();
+ method public androidx.car.app.hardware.info.Toll.Builder setCardState(androidx.car.app.hardware.common.CarValue<java.lang.Integer!>);
+ }
+
+ public static final class Toll.Params {
+ ctor public Toll.Params();
+ method public static androidx.car.app.hardware.info.Toll.Params getDefault();
+ }
+
+}
+
package androidx.car.app.model {
@androidx.car.app.annotations.CarProtocol public final class Action {
diff --git a/car/app/app/api/public_plus_experimental_current.txt b/car/app/app/api/public_plus_experimental_current.txt
index dbcb362..a91d6a4 100644
--- a/car/app/app/api/public_plus_experimental_current.txt
+++ b/car/app/app/api/public_plus_experimental_current.txt
@@ -55,6 +55,7 @@
field public static final String CAR_SERVICE = "car";
field @androidx.car.app.annotations.RequiresCarApi(2) public static final String CONSTRAINT_SERVICE = "constraints";
field public static final String EXTRA_START_CAR_APP_BINDER_KEY = "androidx.car.app.extra.START_CAR_APP_BINDER_KEY";
+ field @androidx.car.app.annotations.RequiresCarApi(3) public static final String HARDWARE_SERVICE = "hardware";
field public static final String NAVIGATION_SERVICE = "navigation";
field public static final String SCREEN_SERVICE = "screen";
}
@@ -192,16 +193,6 @@
field public static final int CONNECTION_TYPE_PROJECTION = 2; // 0x2
}
- @Deprecated public final class ConnectionToCar {
- ctor @Deprecated public ConnectionToCar(android.content.Context);
- method @Deprecated public androidx.lifecycle.LiveData<java.lang.Integer!> getType();
- field @Deprecated public static final String ACTION_CAR_CONNECTION_UPDATED = "androidx.car.app.connection.action.CAR_CONNECTION_UPDATED";
- field @Deprecated public static final String CAR_CONNECTION_STATE = "CarConnectionState";
- field @Deprecated public static final int NATIVE = 1; // 0x1
- field @Deprecated public static final int NOT_CONNECTED = 0; // 0x0
- field @Deprecated public static final int PROJECTION = 2; // 0x2
- }
-
}
package androidx.car.app.constraints {
@@ -217,6 +208,285 @@
}
+package androidx.car.app.hardware {
+
+ @androidx.car.app.annotations.RequiresCarApi(3) public interface CarHardwareManager {
+ method public default androidx.car.app.hardware.info.CarInfo getCarInfo();
+ method public default androidx.car.app.hardware.info.CarSensors getCarSensors();
+ }
+
+}
+
+package androidx.car.app.hardware.common {
+
+ @androidx.car.app.annotations.CarProtocol @androidx.car.app.annotations.RequiresCarApi(3) public final class CarUnit {
+ field public static final int KILOMETER = 3; // 0x3
+ field public static final int KILOMETERS_PER_HOUR = 102; // 0x66
+ field public static final int METER = 2; // 0x2
+ field public static final int METERS_PER_SEC = 101; // 0x65
+ field public static final int MILE = 4; // 0x4
+ field public static final int MILES_PER_HOUR = 103; // 0x67
+ field public static final int MILLIMETER = 1; // 0x1
+ }
+
+ @androidx.car.app.annotations.CarProtocol @androidx.car.app.annotations.RequiresCarApi(3) public final class CarValue<T> {
+ ctor public CarValue(T?, long, int);
+ method public int getStatus();
+ method public long getTimestampMillis();
+ method public T? getValue();
+ field public static final int STATUS_SUCCESS = 1; // 0x1
+ field public static final int STATUS_UNAVAILABLE = 3; // 0x3
+ field public static final int STATUS_UNIMPLEMENTED = 2; // 0x2
+ field public static final int STATUS_UNKNOWN = 0; // 0x0
+ }
+
+ @androidx.car.app.annotations.CarProtocol @androidx.car.app.annotations.RequiresCarApi(3) public interface OnCarDataListener<T> {
+ method public void onCarData(T);
+ }
+
+ @androidx.car.app.annotations.CarProtocol @androidx.car.app.annotations.RequiresCarApi(3) public final class UpdateRate {
+ field public static final int DEFAULT = 0; // 0x0
+ field public static final int FASTEST = 2; // 0x2
+ field public static final int UI = 1; // 0x1
+ }
+
+}
+
+package androidx.car.app.hardware.info {
+
+ @androidx.car.app.annotations.CarProtocol @androidx.car.app.annotations.RequiresCarApi(3) public final class Accelerometer {
+ method public androidx.car.app.hardware.common.CarValue<java.lang.Float![]!> getAccelerometer();
+ }
+
+ public static final class Accelerometer.Builder {
+ ctor public Accelerometer.Builder();
+ method public androidx.car.app.hardware.info.Accelerometer build();
+ method public androidx.car.app.hardware.info.Accelerometer.Builder setAccelerometer(androidx.car.app.hardware.common.CarValue<java.lang.Float![]!>);
+ }
+
+ public static final class Accelerometer.Params {
+ ctor public Accelerometer.Params(int);
+ method public static androidx.car.app.hardware.info.Accelerometer.Params getDefault();
+ method public int getRate();
+ }
+
+ @androidx.car.app.annotations.CarProtocol @androidx.car.app.annotations.RequiresCarApi(3) public final class CarHardwareLocation {
+ method public androidx.car.app.hardware.common.CarValue<android.location.Location!> getLocation();
+ }
+
+ public static final class CarHardwareLocation.Builder {
+ ctor public CarHardwareLocation.Builder();
+ method public androidx.car.app.hardware.info.CarHardwareLocation build();
+ method public androidx.car.app.hardware.info.CarHardwareLocation.Builder setLocation(androidx.car.app.hardware.common.CarValue<android.location.Location!>);
+ }
+
+ public static final class CarHardwareLocation.Params {
+ ctor public CarHardwareLocation.Params(int);
+ method public static androidx.car.app.hardware.info.CarHardwareLocation.Params getDefault();
+ method public int getRate();
+ }
+
+ @androidx.car.app.annotations.RequiresCarApi(3) public interface CarInfo {
+ method public void addEnergyLevelListener(androidx.car.app.hardware.info.EnergyLevel.Params, java.util.concurrent.Executor, androidx.car.app.hardware.common.OnCarDataListener<androidx.car.app.hardware.info.EnergyLevel!>);
+ method public void addMileageListener(androidx.car.app.hardware.info.Mileage.Params, java.util.concurrent.Executor, androidx.car.app.hardware.common.OnCarDataListener<androidx.car.app.hardware.info.Mileage!>);
+ method public void addSpeedListener(androidx.car.app.hardware.info.Speed.Params, java.util.concurrent.Executor, androidx.car.app.hardware.common.OnCarDataListener<androidx.car.app.hardware.info.Speed!>);
+ method public void addTollListener(androidx.car.app.hardware.info.Toll.Params, java.util.concurrent.Executor, androidx.car.app.hardware.common.OnCarDataListener<androidx.car.app.hardware.info.Toll!>);
+ method public void getEnergyProfile(androidx.car.app.hardware.info.EnergyProfile.Params, java.util.concurrent.Executor, androidx.car.app.hardware.common.OnCarDataListener<androidx.car.app.hardware.info.EnergyProfile!>);
+ method public void getModel(androidx.car.app.hardware.info.Model.Params, java.util.concurrent.Executor, androidx.car.app.hardware.common.OnCarDataListener<androidx.car.app.hardware.info.Model!>);
+ method public void removeEnergyLevelListener(androidx.car.app.hardware.common.OnCarDataListener<androidx.car.app.hardware.info.EnergyLevel!>);
+ method public void removeMileageListener(androidx.car.app.hardware.common.OnCarDataListener<androidx.car.app.hardware.info.Mileage!>);
+ method public void removeSpeedListener(androidx.car.app.hardware.common.OnCarDataListener<androidx.car.app.hardware.info.Speed!>);
+ method public void removeTollListener(androidx.car.app.hardware.common.OnCarDataListener<androidx.car.app.hardware.info.Toll!>);
+ }
+
+ @androidx.car.app.annotations.RequiresCarApi(3) public interface CarSensors {
+ method public void addAccelerometerListener(androidx.car.app.hardware.info.Accelerometer.Params, java.util.concurrent.Executor, androidx.car.app.hardware.common.OnCarDataListener<androidx.car.app.hardware.info.Accelerometer!>);
+ method public void addCarHardwareLocationListener(androidx.car.app.hardware.info.CarHardwareLocation.Params, java.util.concurrent.Executor, androidx.car.app.hardware.common.OnCarDataListener<androidx.car.app.hardware.info.CarHardwareLocation!>);
+ method public void addCompassListener(androidx.car.app.hardware.info.Compass.Params, java.util.concurrent.Executor, androidx.car.app.hardware.common.OnCarDataListener<androidx.car.app.hardware.info.Compass!>);
+ method public void addGyroscopeListener(androidx.car.app.hardware.info.Gyroscope.Params, java.util.concurrent.Executor, androidx.car.app.hardware.common.OnCarDataListener<androidx.car.app.hardware.info.Gyroscope!>);
+ method public void removeAccelerometerListener(androidx.car.app.hardware.common.OnCarDataListener<androidx.car.app.hardware.info.Accelerometer!>);
+ method public void removeCarHardwareLocationListener(androidx.car.app.hardware.common.OnCarDataListener<androidx.car.app.hardware.info.CarHardwareLocation!>);
+ method public void removeCompassListener(androidx.car.app.hardware.common.OnCarDataListener<androidx.car.app.hardware.info.Compass!>);
+ method public void removeGyroscopeListener(androidx.car.app.hardware.common.OnCarDataListener<androidx.car.app.hardware.info.Gyroscope!>);
+ }
+
+ @androidx.car.app.annotations.CarProtocol @androidx.car.app.annotations.RequiresCarApi(3) public final class Compass {
+ method public androidx.car.app.hardware.common.CarValue<java.lang.Float![]!> getCompass();
+ }
+
+ public static final class Compass.Builder {
+ ctor public Compass.Builder();
+ method public androidx.car.app.hardware.info.Compass build();
+ method public androidx.car.app.hardware.info.Compass.Builder setCompass(androidx.car.app.hardware.common.CarValue<java.lang.Float![]!>);
+ }
+
+ public static final class Compass.Params {
+ ctor public Compass.Params(int);
+ method public static androidx.car.app.hardware.info.Compass.Params getDefault();
+ method public int getRate();
+ }
+
+ @androidx.car.app.annotations.CarProtocol @androidx.car.app.annotations.RequiresCarApi(3) public final class EnergyLevel {
+ method public androidx.car.app.hardware.common.CarValue<java.lang.Float!> getBatteryPercent();
+ method public androidx.car.app.hardware.common.CarValue<java.lang.Integer!> getDistanceDisplayUnit();
+ method public androidx.car.app.hardware.common.CarValue<java.lang.Boolean!> getEnergyIsLow();
+ method public androidx.car.app.hardware.common.CarValue<java.lang.Float!> getFuelPercent();
+ method public androidx.car.app.hardware.common.CarValue<java.lang.Float!> getRangeRemaining();
+ }
+
+ public static final class EnergyLevel.Builder {
+ ctor public EnergyLevel.Builder();
+ method public androidx.car.app.hardware.info.EnergyLevel build();
+ method public androidx.car.app.hardware.info.EnergyLevel.Builder setBatteryPercent(androidx.car.app.hardware.common.CarValue<java.lang.Float!>);
+ method public androidx.car.app.hardware.info.EnergyLevel.Builder setDistanceDisplayUnit(androidx.car.app.hardware.common.CarValue<java.lang.Integer!>);
+ method public androidx.car.app.hardware.info.EnergyLevel.Builder setEnergyIsLow(androidx.car.app.hardware.common.CarValue<java.lang.Boolean!>);
+ method public androidx.car.app.hardware.info.EnergyLevel.Builder setFuelPercent(androidx.car.app.hardware.common.CarValue<java.lang.Float!>);
+ method public androidx.car.app.hardware.info.EnergyLevel.Builder setRangeRemaining(androidx.car.app.hardware.common.CarValue<java.lang.Float!>);
+ }
+
+ public static final class EnergyLevel.Params {
+ ctor public EnergyLevel.Params(int);
+ method public static androidx.car.app.hardware.info.EnergyLevel.Params getDefault();
+ method public int getRate();
+ }
+
+ @androidx.car.app.annotations.CarProtocol @androidx.car.app.annotations.RequiresCarApi(3) public final class EnergyProfile {
+ method public androidx.car.app.hardware.common.CarValue<java.lang.Integer![]!> getEvConnectorTypes();
+ method public androidx.car.app.hardware.common.CarValue<java.lang.Integer![]!> getFuelTypes();
+ field public static final int EVCONNECTOR_TYPE_CHADEMO = 3; // 0x3
+ field public static final int EVCONNECTOR_TYPE_COMBO_1 = 4; // 0x4
+ field public static final int EVCONNECTOR_TYPE_COMBO_2 = 5; // 0x5
+ field public static final int EVCONNECTOR_TYPE_GBT = 9; // 0x9
+ field public static final int EVCONNECTOR_TYPE_GBT_DC = 10; // 0xa
+ field public static final int EVCONNECTOR_TYPE_J1772 = 1; // 0x1
+ field public static final int EVCONNECTOR_TYPE_MENNEKES = 2; // 0x2
+ field public static final int EVCONNECTOR_TYPE_OTHER = 101; // 0x65
+ field public static final int EVCONNECTOR_TYPE_SCAME = 11; // 0xb
+ field public static final int EVCONNECTOR_TYPE_TESLA_HPWC = 7; // 0x7
+ field public static final int EVCONNECTOR_TYPE_TESLA_ROADSTER = 6; // 0x6
+ field public static final int EVCONNECTOR_TYPE_TESLA_SUPERCHARGER = 8; // 0x8
+ field public static final int EVCONNECTOR_TYPE_UNKNOWN = 0; // 0x0
+ field public static final int FUEL_TYPE_BIODIESEL = 5; // 0x5
+ field public static final int FUEL_TYPE_CNG = 8; // 0x8
+ field public static final int FUEL_TYPE_DIESEL_1 = 3; // 0x3
+ field public static final int FUEL_TYPE_DIESEL_2 = 4; // 0x4
+ field public static final int FUEL_TYPE_E85 = 6; // 0x6
+ field public static final int FUEL_TYPE_ELECTRIC = 10; // 0xa
+ field public static final int FUEL_TYPE_HYDROGEN = 11; // 0xb
+ field public static final int FUEL_TYPE_LEADED = 2; // 0x2
+ field public static final int FUEL_TYPE_LNG = 9; // 0x9
+ field public static final int FUEL_TYPE_LPG = 7; // 0x7
+ field public static final int FUEL_TYPE_OTHER = 12; // 0xc
+ field public static final int FUEL_TYPE_UNKNOWN = 0; // 0x0
+ field public static final int FUEL_TYPE_UNLEADED = 1; // 0x1
+ }
+
+ public static final class EnergyProfile.Builder {
+ ctor public EnergyProfile.Builder();
+ method public androidx.car.app.hardware.info.EnergyProfile build();
+ method public androidx.car.app.hardware.info.EnergyProfile.Builder setEvConnectorTypes(androidx.car.app.hardware.common.CarValue<java.lang.Integer![]!>);
+ method public androidx.car.app.hardware.info.EnergyProfile.Builder setFuelTypes(androidx.car.app.hardware.common.CarValue<java.lang.Integer![]!>);
+ }
+
+ public static final class EnergyProfile.Params {
+ ctor public EnergyProfile.Params();
+ method public static androidx.car.app.hardware.info.EnergyProfile.Params getDefault();
+ }
+
+ @androidx.car.app.annotations.CarProtocol @androidx.car.app.annotations.RequiresCarApi(3) public final class Gyroscope {
+ method public androidx.car.app.hardware.common.CarValue<java.lang.Float![]!> getGyroscope();
+ }
+
+ public static final class Gyroscope.Builder {
+ ctor public Gyroscope.Builder();
+ method public androidx.car.app.hardware.info.Gyroscope build();
+ method public androidx.car.app.hardware.info.Gyroscope.Builder setGyroscope(androidx.car.app.hardware.common.CarValue<java.lang.Float![]!>);
+ }
+
+ public static final class Gyroscope.Params {
+ ctor public Gyroscope.Params(int);
+ method public static androidx.car.app.hardware.info.Gyroscope.Params getDefault();
+ method public int getRate();
+ }
+
+ @androidx.car.app.annotations.CarProtocol @androidx.car.app.annotations.RequiresCarApi(3) public final class Mileage {
+ method public androidx.car.app.hardware.common.CarValue<java.lang.Integer!> getDistanceDisplayUnit();
+ method public androidx.car.app.hardware.common.CarValue<java.lang.Float!> getOdometer();
+ }
+
+ public static final class Mileage.Builder {
+ ctor public Mileage.Builder();
+ method public androidx.car.app.hardware.info.Mileage build();
+ method public androidx.car.app.hardware.info.Mileage.Builder setDistanceDisplayUnit(androidx.car.app.hardware.common.CarValue<java.lang.Integer!>);
+ method public androidx.car.app.hardware.info.Mileage.Builder setOdometer(androidx.car.app.hardware.common.CarValue<java.lang.Float!>);
+ }
+
+ public static final class Mileage.Params {
+ ctor public Mileage.Params(int);
+ method public static androidx.car.app.hardware.info.Mileage.Params getDefault();
+ method public int getRate();
+ }
+
+ @androidx.car.app.annotations.CarProtocol @androidx.car.app.annotations.RequiresCarApi(3) public final class Model {
+ method public androidx.car.app.hardware.common.CarValue<java.lang.String!> getManufacturer();
+ method public androidx.car.app.hardware.common.CarValue<java.lang.String!> getName();
+ method public androidx.car.app.hardware.common.CarValue<java.lang.Integer!> getYear();
+ }
+
+ public static final class Model.Builder {
+ ctor public Model.Builder();
+ method public androidx.car.app.hardware.info.Model build();
+ method public androidx.car.app.hardware.info.Model.Builder setManufacturer(androidx.car.app.hardware.common.CarValue<java.lang.String!>);
+ method public androidx.car.app.hardware.info.Model.Builder setName(androidx.car.app.hardware.common.CarValue<java.lang.String!>);
+ method public androidx.car.app.hardware.info.Model.Builder setYear(androidx.car.app.hardware.common.CarValue<java.lang.Integer!>);
+ }
+
+ public static final class Model.Params {
+ ctor public Model.Params();
+ method public static androidx.car.app.hardware.info.Model.Params getDefault();
+ }
+
+ @androidx.car.app.annotations.CarProtocol @androidx.car.app.annotations.RequiresCarApi(3) public final class Speed {
+ method public androidx.car.app.hardware.common.CarValue<java.lang.Float!> getDisplaySpeed();
+ method public androidx.car.app.hardware.common.CarValue<java.lang.Float!> getRawSpeed();
+ method public androidx.car.app.hardware.common.CarValue<java.lang.Integer!> getSpeedDisplayUnit();
+ }
+
+ public static final class Speed.Builder {
+ ctor public Speed.Builder();
+ method public androidx.car.app.hardware.info.Speed build();
+ method public androidx.car.app.hardware.info.Speed.Builder setDisplaySpeed(androidx.car.app.hardware.common.CarValue<java.lang.Float!>);
+ method public androidx.car.app.hardware.info.Speed.Builder setRawSpeed(androidx.car.app.hardware.common.CarValue<java.lang.Float!>);
+ method public androidx.car.app.hardware.info.Speed.Builder setSpeedDisplayUnit(androidx.car.app.hardware.common.CarValue<java.lang.Integer!>);
+ }
+
+ public static final class Speed.Params {
+ ctor public Speed.Params(int);
+ method public static androidx.car.app.hardware.info.Speed.Params getDefault();
+ method public int getRate();
+ }
+
+ @androidx.car.app.annotations.CarProtocol @androidx.car.app.annotations.RequiresCarApi(3) public final class Toll {
+ method public androidx.car.app.hardware.common.CarValue<java.lang.Integer!> getCardState();
+ field public static final int TOLLCARD_STATE_INVALID = 2; // 0x2
+ field public static final int TOLLCARD_STATE_NOT_INSERTED = 3; // 0x3
+ field public static final int TOLLCARD_STATE_UNKNOWN = 0; // 0x0
+ field public static final int TOLLCARD_STATE_VALID = 1; // 0x1
+ }
+
+ public static final class Toll.Builder {
+ ctor public Toll.Builder();
+ method public androidx.car.app.hardware.info.Toll build();
+ method public androidx.car.app.hardware.info.Toll.Builder setCardState(androidx.car.app.hardware.common.CarValue<java.lang.Integer!>);
+ }
+
+ public static final class Toll.Params {
+ ctor public Toll.Params();
+ method public static androidx.car.app.hardware.info.Toll.Params getDefault();
+ }
+
+}
+
package androidx.car.app.model {
@androidx.car.app.annotations.CarProtocol public final class Action {
diff --git a/car/app/app/api/restricted_current.txt b/car/app/app/api/restricted_current.txt
index 3a71b2b..03237cc 100644
--- a/car/app/app/api/restricted_current.txt
+++ b/car/app/app/api/restricted_current.txt
@@ -55,6 +55,7 @@
field public static final String CAR_SERVICE = "car";
field @androidx.car.app.annotations.RequiresCarApi(2) public static final String CONSTRAINT_SERVICE = "constraints";
field public static final String EXTRA_START_CAR_APP_BINDER_KEY = "androidx.car.app.extra.START_CAR_APP_BINDER_KEY";
+ field @androidx.car.app.annotations.RequiresCarApi(3) public static final String HARDWARE_SERVICE = "hardware";
field public static final String NAVIGATION_SERVICE = "navigation";
field public static final String SCREEN_SERVICE = "screen";
}
@@ -189,16 +190,6 @@
field public static final int CONNECTION_TYPE_PROJECTION = 2; // 0x2
}
- @Deprecated public final class ConnectionToCar {
- ctor @Deprecated public ConnectionToCar(android.content.Context);
- method @Deprecated public androidx.lifecycle.LiveData<java.lang.Integer!> getType();
- field @Deprecated public static final String ACTION_CAR_CONNECTION_UPDATED = "androidx.car.app.connection.action.CAR_CONNECTION_UPDATED";
- field @Deprecated public static final String CAR_CONNECTION_STATE = "CarConnectionState";
- field @Deprecated public static final int NATIVE = 1; // 0x1
- field @Deprecated public static final int NOT_CONNECTED = 0; // 0x0
- field @Deprecated public static final int PROJECTION = 2; // 0x2
- }
-
}
package androidx.car.app.constraints {
@@ -214,6 +205,285 @@
}
+package androidx.car.app.hardware {
+
+ @androidx.car.app.annotations.RequiresCarApi(3) public interface CarHardwareManager {
+ method public default androidx.car.app.hardware.info.CarInfo getCarInfo();
+ method public default androidx.car.app.hardware.info.CarSensors getCarSensors();
+ }
+
+}
+
+package androidx.car.app.hardware.common {
+
+ @androidx.car.app.annotations.CarProtocol @androidx.car.app.annotations.RequiresCarApi(3) public final class CarUnit {
+ field public static final int KILOMETER = 3; // 0x3
+ field public static final int KILOMETERS_PER_HOUR = 102; // 0x66
+ field public static final int METER = 2; // 0x2
+ field public static final int METERS_PER_SEC = 101; // 0x65
+ field public static final int MILE = 4; // 0x4
+ field public static final int MILES_PER_HOUR = 103; // 0x67
+ field public static final int MILLIMETER = 1; // 0x1
+ }
+
+ @androidx.car.app.annotations.CarProtocol @androidx.car.app.annotations.RequiresCarApi(3) public final class CarValue<T> {
+ ctor public CarValue(T?, long, int);
+ method public int getStatus();
+ method public long getTimestampMillis();
+ method public T? getValue();
+ field public static final int STATUS_SUCCESS = 1; // 0x1
+ field public static final int STATUS_UNAVAILABLE = 3; // 0x3
+ field public static final int STATUS_UNIMPLEMENTED = 2; // 0x2
+ field public static final int STATUS_UNKNOWN = 0; // 0x0
+ }
+
+ @androidx.car.app.annotations.CarProtocol @androidx.car.app.annotations.RequiresCarApi(3) public interface OnCarDataListener<T> {
+ method public void onCarData(T);
+ }
+
+ @androidx.car.app.annotations.CarProtocol @androidx.car.app.annotations.RequiresCarApi(3) public final class UpdateRate {
+ field public static final int DEFAULT = 0; // 0x0
+ field public static final int FASTEST = 2; // 0x2
+ field public static final int UI = 1; // 0x1
+ }
+
+}
+
+package androidx.car.app.hardware.info {
+
+ @androidx.car.app.annotations.CarProtocol @androidx.car.app.annotations.RequiresCarApi(3) public final class Accelerometer {
+ method public androidx.car.app.hardware.common.CarValue<java.lang.Float![]!> getAccelerometer();
+ }
+
+ public static final class Accelerometer.Builder {
+ ctor public Accelerometer.Builder();
+ method public androidx.car.app.hardware.info.Accelerometer build();
+ method public androidx.car.app.hardware.info.Accelerometer.Builder setAccelerometer(androidx.car.app.hardware.common.CarValue<java.lang.Float![]!>);
+ }
+
+ public static final class Accelerometer.Params {
+ ctor public Accelerometer.Params(int);
+ method public static androidx.car.app.hardware.info.Accelerometer.Params getDefault();
+ method public int getRate();
+ }
+
+ @androidx.car.app.annotations.CarProtocol @androidx.car.app.annotations.RequiresCarApi(3) public final class CarHardwareLocation {
+ method public androidx.car.app.hardware.common.CarValue<android.location.Location!> getLocation();
+ }
+
+ public static final class CarHardwareLocation.Builder {
+ ctor public CarHardwareLocation.Builder();
+ method public androidx.car.app.hardware.info.CarHardwareLocation build();
+ method public androidx.car.app.hardware.info.CarHardwareLocation.Builder setLocation(androidx.car.app.hardware.common.CarValue<android.location.Location!>);
+ }
+
+ public static final class CarHardwareLocation.Params {
+ ctor public CarHardwareLocation.Params(int);
+ method public static androidx.car.app.hardware.info.CarHardwareLocation.Params getDefault();
+ method public int getRate();
+ }
+
+ @androidx.car.app.annotations.RequiresCarApi(3) public interface CarInfo {
+ method public void addEnergyLevelListener(androidx.car.app.hardware.info.EnergyLevel.Params, java.util.concurrent.Executor, androidx.car.app.hardware.common.OnCarDataListener<androidx.car.app.hardware.info.EnergyLevel!>);
+ method public void addMileageListener(androidx.car.app.hardware.info.Mileage.Params, java.util.concurrent.Executor, androidx.car.app.hardware.common.OnCarDataListener<androidx.car.app.hardware.info.Mileage!>);
+ method public void addSpeedListener(androidx.car.app.hardware.info.Speed.Params, java.util.concurrent.Executor, androidx.car.app.hardware.common.OnCarDataListener<androidx.car.app.hardware.info.Speed!>);
+ method public void addTollListener(androidx.car.app.hardware.info.Toll.Params, java.util.concurrent.Executor, androidx.car.app.hardware.common.OnCarDataListener<androidx.car.app.hardware.info.Toll!>);
+ method public void getEnergyProfile(androidx.car.app.hardware.info.EnergyProfile.Params, java.util.concurrent.Executor, androidx.car.app.hardware.common.OnCarDataListener<androidx.car.app.hardware.info.EnergyProfile!>);
+ method public void getModel(androidx.car.app.hardware.info.Model.Params, java.util.concurrent.Executor, androidx.car.app.hardware.common.OnCarDataListener<androidx.car.app.hardware.info.Model!>);
+ method public void removeEnergyLevelListener(androidx.car.app.hardware.common.OnCarDataListener<androidx.car.app.hardware.info.EnergyLevel!>);
+ method public void removeMileageListener(androidx.car.app.hardware.common.OnCarDataListener<androidx.car.app.hardware.info.Mileage!>);
+ method public void removeSpeedListener(androidx.car.app.hardware.common.OnCarDataListener<androidx.car.app.hardware.info.Speed!>);
+ method public void removeTollListener(androidx.car.app.hardware.common.OnCarDataListener<androidx.car.app.hardware.info.Toll!>);
+ }
+
+ @androidx.car.app.annotations.RequiresCarApi(3) public interface CarSensors {
+ method public void addAccelerometerListener(androidx.car.app.hardware.info.Accelerometer.Params, java.util.concurrent.Executor, androidx.car.app.hardware.common.OnCarDataListener<androidx.car.app.hardware.info.Accelerometer!>);
+ method public void addCarHardwareLocationListener(androidx.car.app.hardware.info.CarHardwareLocation.Params, java.util.concurrent.Executor, androidx.car.app.hardware.common.OnCarDataListener<androidx.car.app.hardware.info.CarHardwareLocation!>);
+ method public void addCompassListener(androidx.car.app.hardware.info.Compass.Params, java.util.concurrent.Executor, androidx.car.app.hardware.common.OnCarDataListener<androidx.car.app.hardware.info.Compass!>);
+ method public void addGyroscopeListener(androidx.car.app.hardware.info.Gyroscope.Params, java.util.concurrent.Executor, androidx.car.app.hardware.common.OnCarDataListener<androidx.car.app.hardware.info.Gyroscope!>);
+ method public void removeAccelerometerListener(androidx.car.app.hardware.common.OnCarDataListener<androidx.car.app.hardware.info.Accelerometer!>);
+ method public void removeCarHardwareLocationListener(androidx.car.app.hardware.common.OnCarDataListener<androidx.car.app.hardware.info.CarHardwareLocation!>);
+ method public void removeCompassListener(androidx.car.app.hardware.common.OnCarDataListener<androidx.car.app.hardware.info.Compass!>);
+ method public void removeGyroscopeListener(androidx.car.app.hardware.common.OnCarDataListener<androidx.car.app.hardware.info.Gyroscope!>);
+ }
+
+ @androidx.car.app.annotations.CarProtocol @androidx.car.app.annotations.RequiresCarApi(3) public final class Compass {
+ method public androidx.car.app.hardware.common.CarValue<java.lang.Float![]!> getCompass();
+ }
+
+ public static final class Compass.Builder {
+ ctor public Compass.Builder();
+ method public androidx.car.app.hardware.info.Compass build();
+ method public androidx.car.app.hardware.info.Compass.Builder setCompass(androidx.car.app.hardware.common.CarValue<java.lang.Float![]!>);
+ }
+
+ public static final class Compass.Params {
+ ctor public Compass.Params(int);
+ method public static androidx.car.app.hardware.info.Compass.Params getDefault();
+ method public int getRate();
+ }
+
+ @androidx.car.app.annotations.CarProtocol @androidx.car.app.annotations.RequiresCarApi(3) public final class EnergyLevel {
+ method public androidx.car.app.hardware.common.CarValue<java.lang.Float!> getBatteryPercent();
+ method public androidx.car.app.hardware.common.CarValue<java.lang.Integer!> getDistanceDisplayUnit();
+ method public androidx.car.app.hardware.common.CarValue<java.lang.Boolean!> getEnergyIsLow();
+ method public androidx.car.app.hardware.common.CarValue<java.lang.Float!> getFuelPercent();
+ method public androidx.car.app.hardware.common.CarValue<java.lang.Float!> getRangeRemaining();
+ }
+
+ public static final class EnergyLevel.Builder {
+ ctor public EnergyLevel.Builder();
+ method public androidx.car.app.hardware.info.EnergyLevel build();
+ method public androidx.car.app.hardware.info.EnergyLevel.Builder setBatteryPercent(androidx.car.app.hardware.common.CarValue<java.lang.Float!>);
+ method public androidx.car.app.hardware.info.EnergyLevel.Builder setDistanceDisplayUnit(androidx.car.app.hardware.common.CarValue<java.lang.Integer!>);
+ method public androidx.car.app.hardware.info.EnergyLevel.Builder setEnergyIsLow(androidx.car.app.hardware.common.CarValue<java.lang.Boolean!>);
+ method public androidx.car.app.hardware.info.EnergyLevel.Builder setFuelPercent(androidx.car.app.hardware.common.CarValue<java.lang.Float!>);
+ method public androidx.car.app.hardware.info.EnergyLevel.Builder setRangeRemaining(androidx.car.app.hardware.common.CarValue<java.lang.Float!>);
+ }
+
+ public static final class EnergyLevel.Params {
+ ctor public EnergyLevel.Params(int);
+ method public static androidx.car.app.hardware.info.EnergyLevel.Params getDefault();
+ method public int getRate();
+ }
+
+ @androidx.car.app.annotations.CarProtocol @androidx.car.app.annotations.RequiresCarApi(3) public final class EnergyProfile {
+ method public androidx.car.app.hardware.common.CarValue<java.lang.Integer![]!> getEvConnectorTypes();
+ method public androidx.car.app.hardware.common.CarValue<java.lang.Integer![]!> getFuelTypes();
+ field public static final int EVCONNECTOR_TYPE_CHADEMO = 3; // 0x3
+ field public static final int EVCONNECTOR_TYPE_COMBO_1 = 4; // 0x4
+ field public static final int EVCONNECTOR_TYPE_COMBO_2 = 5; // 0x5
+ field public static final int EVCONNECTOR_TYPE_GBT = 9; // 0x9
+ field public static final int EVCONNECTOR_TYPE_GBT_DC = 10; // 0xa
+ field public static final int EVCONNECTOR_TYPE_J1772 = 1; // 0x1
+ field public static final int EVCONNECTOR_TYPE_MENNEKES = 2; // 0x2
+ field public static final int EVCONNECTOR_TYPE_OTHER = 101; // 0x65
+ field public static final int EVCONNECTOR_TYPE_SCAME = 11; // 0xb
+ field public static final int EVCONNECTOR_TYPE_TESLA_HPWC = 7; // 0x7
+ field public static final int EVCONNECTOR_TYPE_TESLA_ROADSTER = 6; // 0x6
+ field public static final int EVCONNECTOR_TYPE_TESLA_SUPERCHARGER = 8; // 0x8
+ field public static final int EVCONNECTOR_TYPE_UNKNOWN = 0; // 0x0
+ field public static final int FUEL_TYPE_BIODIESEL = 5; // 0x5
+ field public static final int FUEL_TYPE_CNG = 8; // 0x8
+ field public static final int FUEL_TYPE_DIESEL_1 = 3; // 0x3
+ field public static final int FUEL_TYPE_DIESEL_2 = 4; // 0x4
+ field public static final int FUEL_TYPE_E85 = 6; // 0x6
+ field public static final int FUEL_TYPE_ELECTRIC = 10; // 0xa
+ field public static final int FUEL_TYPE_HYDROGEN = 11; // 0xb
+ field public static final int FUEL_TYPE_LEADED = 2; // 0x2
+ field public static final int FUEL_TYPE_LNG = 9; // 0x9
+ field public static final int FUEL_TYPE_LPG = 7; // 0x7
+ field public static final int FUEL_TYPE_OTHER = 12; // 0xc
+ field public static final int FUEL_TYPE_UNKNOWN = 0; // 0x0
+ field public static final int FUEL_TYPE_UNLEADED = 1; // 0x1
+ }
+
+ public static final class EnergyProfile.Builder {
+ ctor public EnergyProfile.Builder();
+ method public androidx.car.app.hardware.info.EnergyProfile build();
+ method public androidx.car.app.hardware.info.EnergyProfile.Builder setEvConnectorTypes(androidx.car.app.hardware.common.CarValue<java.lang.Integer![]!>);
+ method public androidx.car.app.hardware.info.EnergyProfile.Builder setFuelTypes(androidx.car.app.hardware.common.CarValue<java.lang.Integer![]!>);
+ }
+
+ public static final class EnergyProfile.Params {
+ ctor public EnergyProfile.Params();
+ method public static androidx.car.app.hardware.info.EnergyProfile.Params getDefault();
+ }
+
+ @androidx.car.app.annotations.CarProtocol @androidx.car.app.annotations.RequiresCarApi(3) public final class Gyroscope {
+ method public androidx.car.app.hardware.common.CarValue<java.lang.Float![]!> getGyroscope();
+ }
+
+ public static final class Gyroscope.Builder {
+ ctor public Gyroscope.Builder();
+ method public androidx.car.app.hardware.info.Gyroscope build();
+ method public androidx.car.app.hardware.info.Gyroscope.Builder setGyroscope(androidx.car.app.hardware.common.CarValue<java.lang.Float![]!>);
+ }
+
+ public static final class Gyroscope.Params {
+ ctor public Gyroscope.Params(int);
+ method public static androidx.car.app.hardware.info.Gyroscope.Params getDefault();
+ method public int getRate();
+ }
+
+ @androidx.car.app.annotations.CarProtocol @androidx.car.app.annotations.RequiresCarApi(3) public final class Mileage {
+ method public androidx.car.app.hardware.common.CarValue<java.lang.Integer!> getDistanceDisplayUnit();
+ method public androidx.car.app.hardware.common.CarValue<java.lang.Float!> getOdometer();
+ }
+
+ public static final class Mileage.Builder {
+ ctor public Mileage.Builder();
+ method public androidx.car.app.hardware.info.Mileage build();
+ method public androidx.car.app.hardware.info.Mileage.Builder setDistanceDisplayUnit(androidx.car.app.hardware.common.CarValue<java.lang.Integer!>);
+ method public androidx.car.app.hardware.info.Mileage.Builder setOdometer(androidx.car.app.hardware.common.CarValue<java.lang.Float!>);
+ }
+
+ public static final class Mileage.Params {
+ ctor public Mileage.Params(int);
+ method public static androidx.car.app.hardware.info.Mileage.Params getDefault();
+ method public int getRate();
+ }
+
+ @androidx.car.app.annotations.CarProtocol @androidx.car.app.annotations.RequiresCarApi(3) public final class Model {
+ method public androidx.car.app.hardware.common.CarValue<java.lang.String!> getManufacturer();
+ method public androidx.car.app.hardware.common.CarValue<java.lang.String!> getName();
+ method public androidx.car.app.hardware.common.CarValue<java.lang.Integer!> getYear();
+ }
+
+ public static final class Model.Builder {
+ ctor public Model.Builder();
+ method public androidx.car.app.hardware.info.Model build();
+ method public androidx.car.app.hardware.info.Model.Builder setManufacturer(androidx.car.app.hardware.common.CarValue<java.lang.String!>);
+ method public androidx.car.app.hardware.info.Model.Builder setName(androidx.car.app.hardware.common.CarValue<java.lang.String!>);
+ method public androidx.car.app.hardware.info.Model.Builder setYear(androidx.car.app.hardware.common.CarValue<java.lang.Integer!>);
+ }
+
+ public static final class Model.Params {
+ ctor public Model.Params();
+ method public static androidx.car.app.hardware.info.Model.Params getDefault();
+ }
+
+ @androidx.car.app.annotations.CarProtocol @androidx.car.app.annotations.RequiresCarApi(3) public final class Speed {
+ method public androidx.car.app.hardware.common.CarValue<java.lang.Float!> getDisplaySpeed();
+ method public androidx.car.app.hardware.common.CarValue<java.lang.Float!> getRawSpeed();
+ method public androidx.car.app.hardware.common.CarValue<java.lang.Integer!> getSpeedDisplayUnit();
+ }
+
+ public static final class Speed.Builder {
+ ctor public Speed.Builder();
+ method public androidx.car.app.hardware.info.Speed build();
+ method public androidx.car.app.hardware.info.Speed.Builder setDisplaySpeed(androidx.car.app.hardware.common.CarValue<java.lang.Float!>);
+ method public androidx.car.app.hardware.info.Speed.Builder setRawSpeed(androidx.car.app.hardware.common.CarValue<java.lang.Float!>);
+ method public androidx.car.app.hardware.info.Speed.Builder setSpeedDisplayUnit(androidx.car.app.hardware.common.CarValue<java.lang.Integer!>);
+ }
+
+ public static final class Speed.Params {
+ ctor public Speed.Params(int);
+ method public static androidx.car.app.hardware.info.Speed.Params getDefault();
+ method public int getRate();
+ }
+
+ @androidx.car.app.annotations.CarProtocol @androidx.car.app.annotations.RequiresCarApi(3) public final class Toll {
+ method public androidx.car.app.hardware.common.CarValue<java.lang.Integer!> getCardState();
+ field public static final int TOLLCARD_STATE_INVALID = 2; // 0x2
+ field public static final int TOLLCARD_STATE_NOT_INSERTED = 3; // 0x3
+ field public static final int TOLLCARD_STATE_UNKNOWN = 0; // 0x0
+ field public static final int TOLLCARD_STATE_VALID = 1; // 0x1
+ }
+
+ public static final class Toll.Builder {
+ ctor public Toll.Builder();
+ method public androidx.car.app.hardware.info.Toll build();
+ method public androidx.car.app.hardware.info.Toll.Builder setCardState(androidx.car.app.hardware.common.CarValue<java.lang.Integer!>);
+ }
+
+ public static final class Toll.Params {
+ ctor public Toll.Params();
+ method public static androidx.car.app.hardware.info.Toll.Params getDefault();
+ }
+
+}
+
package androidx.car.app.model {
@androidx.car.app.annotations.CarProtocol public final class Action {
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 3e97f76..2220466 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
@@ -39,10 +39,12 @@
import androidx.activity.OnBackPressedDispatcher;
import androidx.annotation.MainThread;
import androidx.annotation.NonNull;
+import androidx.annotation.Nullable;
import androidx.annotation.RestrictTo;
import androidx.annotation.StringDef;
import androidx.car.app.annotations.RequiresCarApi;
import androidx.car.app.constraints.ConstraintManager;
+import androidx.car.app.hardware.CarHardwareManager;
import androidx.car.app.navigation.NavigationManager;
import androidx.car.app.notification.CarPendingIntent;
import androidx.car.app.utils.RemoteUtils;
@@ -93,7 +95,8 @@
*
* @hide
*/
- @StringDef({APP_SERVICE, CAR_SERVICE, NAVIGATION_SERVICE, SCREEN_SERVICE, CONSTRAINT_SERVICE})
+ @StringDef({APP_SERVICE, CAR_SERVICE, NAVIGATION_SERVICE, SCREEN_SERVICE, CONSTRAINT_SERVICE,
+ HARDWARE_SERVICE})
@Retention(RetentionPolicy.SOURCE)
@RestrictTo(LIBRARY)
public @interface CarServiceType {
@@ -120,6 +123,10 @@
*/
public static final String CAR_SERVICE = "car";
+ /** Manages access to androidx.car.app.hardware properties, sensors and actions. */
+ @RequiresCarApi(3)
+ public static final String HARDWARE_SERVICE = "hardware";
+
/**
* Key for including a IStartCarApp in the notification {@link Intent}, for starting the app
* if it has not been opened yet.
@@ -151,10 +158,18 @@
static final String EXTRA_ON_REQUEST_PERMISSIONS_RESULT_CALLBACK_KEY =
"androidx.car.app.action.EXTRA_ON_REQUEST_PERMISSIONS_RESULT_CALLBACK_KEY";
+ /**
+ * Holds an exception to be thrown when accessing {@link CarHardwareManager} if there is an
+ * error during initialization.
+ */
+ @Nullable
+ private final IllegalStateException mCarHardwareManagerException;
+
private final AppManager mAppManager;
private final NavigationManager mNavigationManager;
private final ScreenManager mScreenManager;
private final ConstraintManager mConstraintManager;
+ private final CarHardwareManager mCarHardwareManager;
private final OnBackPressedDispatcher mOnBackPressedDispatcher;
private final HostDispatcher mHostDispatcher;
private final Lifecycle mLifecycle;
@@ -208,6 +223,11 @@
return mScreenManager;
case CONSTRAINT_SERVICE:
return mConstraintManager;
+ case HARDWARE_SERVICE:
+ if (mCarHardwareManagerException != null) {
+ throw mCarHardwareManagerException;
+ }
+ return mCarHardwareManager;
default: // fall out
}
@@ -258,6 +278,8 @@
return SCREEN_SERVICE;
} else if (serviceClass.isInstance(mConstraintManager)) {
return CONSTRAINT_SERVICE;
+ } else if (serviceClass.isInstance(mCarHardwareManager)) {
+ return HARDWARE_SERVICE;
}
throw new IllegalArgumentException("The class does not correspond to a car service");
@@ -450,25 +472,10 @@
}
/**
- * Requests the provided {@code permissions} from the user.
+ * Requests the provided {@code permissions} from the user, calling the provided {@code
+ * callback} in the main thread.
*
- * <p>When the result is available, the {@code callback} provided will be called on the main
- * thread.
- *
- * <p>This method should be called using a parked only listener.
- *
- * <p>If this method is calle while the host deems it is unsafe (for example, when the user
- * is driving), the permission(s) may not be requested from the user, automatically rejecting
- * the permissions requested.
- *
- * <p>If the Session is destroyed before the user accepts or rejects the permissions, the
- * callback will not be executed.
- *
- * @param permissions the runtime permissions to request from the user
- * @param callback callback that will be notified when the user takes action on the
- * permission request
- * @throws NullPointerException if either {@code permissions} or {@code callback} are {@code
- * null}
+ * @see CarContext#requestPermissions(List, Executor, OnRequestPermissionsCallback)
*/
public void requestPermissions(@NonNull List<String> permissions,
@NonNull OnRequestPermissionsCallback callback) {
@@ -481,14 +488,26 @@
* <p>When the result is available, the {@code callback} provided will be called using the
* {@link Executor} provided.
*
- * <p>This method should be called using a parked only listener.
+ * <p>This method should be called using a
+ * {@link androidx.car.app.model.ParkedOnlyOnClickListener}.
*
- * <p>If this method is calle while the host deems it is unsafe (for example, when the user
- * is driving), the permission(s) may not be requested from the user, automatically rejecting
- * the permissions requested.
+ * <p>If this method is called while the host deems it is unsafe (for example, when the user
+ * is driving), the permission(s) will not be requested from the user.
*
- * <p>If the Session is destroyed before the user accepts or rejects the permissions, the
- * callback will not be executed.
+ * <p>If the {@link Session} is destroyed before the user accepts or rejects the permissions,
+ * the callback will not be executed.
+ *
+ * <h4>Platform Considerations</h4>
+ *
+ * Using this method allows the app to work across all platforms supported by the library with
+ * the same API (e.g. Android Auto on mobile devices and Android Automotive OS on native car
+ * heads unit). On a mobile platform, this method will start an activity that will display the
+ * platform's permissions UI over it. You can choose to not
+ * use this method and instead implement your own activity and code to request the
+ * permissions in that platform. On Automotive OS however, distraction-optimized activities
+ * other than {@link androidx.car.app.activity.CarAppActivity} are not allowed and may be
+ * rejected during app submission. See {@link androidx.car.app.activity.CarAppActivity} for
+ * more details.
*
* @param permissions the runtime permissions to request from the user
* @param executor the executor that will be used for calling the {@code callback} provided
@@ -627,6 +646,24 @@
mNavigationManager = NavigationManager.create(this, hostDispatcher, lifecycle);
mScreenManager = ScreenManager.create(this, lifecycle);
mConstraintManager = ConstraintManager.create(this, hostDispatcher);
+
+ // Try to instantiate a CarHardwareManager.
+ CarHardwareManager carHardwareManager = null;
+ IllegalStateException carHardwareManagerException = null;
+ try {
+ carHardwareManager = CarHardwareManager.create(this, hostDispatcher);
+ if (carHardwareManager == null) {
+ carHardwareManagerException = new IllegalStateException("CarHardwareManager not "
+ + "configured. Did you forget to add a dependency on automotive or "
+ + "projected artifacts?");
+ }
+ } catch (IllegalStateException e) {
+ carHardwareManager = new CarHardwareManager() { };
+ carHardwareManagerException = e;
+ }
+ mCarHardwareManager = carHardwareManager;
+ mCarHardwareManagerException = carHardwareManagerException;
+
mOnBackPressedDispatcher =
new OnBackPressedDispatcher(() -> getCarService(ScreenManager.class).pop());
mLifecycle = lifecycle;
diff --git a/car/app/app/src/main/java/androidx/car/app/connection/ConnectionToCar.java b/car/app/app/src/main/java/androidx/car/app/connection/ConnectionToCar.java
deleted file mode 100644
index 4caabbe..0000000
--- a/car/app/app/src/main/java/androidx/car/app/connection/ConnectionToCar.java
+++ /dev/null
@@ -1,116 +0,0 @@
-/*
- * Copyright 2021 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.car.app.connection;
-
-import static androidx.annotation.RestrictTo.Scope.LIBRARY;
-import static androidx.car.app.utils.CommonUtils.isAutomotiveOS;
-
-import static java.util.Objects.requireNonNull;
-
-import android.content.Context;
-
-import androidx.annotation.IntDef;
-import androidx.annotation.NonNull;
-import androidx.annotation.RestrictTo;
-import androidx.lifecycle.LiveData;
-
-import java.lang.annotation.ElementType;
-import java.lang.annotation.Retention;
-import java.lang.annotation.RetentionPolicy;
-import java.lang.annotation.Target;
-
-// TODO(b/169537526): Remove this class
-/**
- * A class that allows retrieval of information about connection to a car head unit.
- *
- * @deprecated use {@link CarConnection} instead.
- */
-@Deprecated
-public final class ConnectionToCar {
- /**
- * Defines current car connection state.
- *
- * <p>This is used for communication with the car host's content provider on queries for
- * connection type.
- */
- public static final String CAR_CONNECTION_STATE = "CarConnectionState";
-
- /**
- * Broadcast action that notifies that the car connection has changed and needs to be updated.
- */
- public static final String ACTION_CAR_CONNECTION_UPDATED =
- "androidx.car.app.connection.action.CAR_CONNECTION_UPDATED";
-
- /**
- * Represents the types of connections that exist to a car head unit.
- *
- * @hide
- */
- @IntDef({NOT_CONNECTED, NATIVE, PROJECTION})
- @Retention(RetentionPolicy.SOURCE)
- @Target({ElementType.TYPE_USE})
- @RestrictTo(LIBRARY)
- public @interface ConnectionType {
- }
-
- /**
- * Not connected to any car head unit.
- */
- public static final int NOT_CONNECTED = 0;
-
- /**
- * Natively running on a head unit (Android Automotive OS).
- */
- public static final int NATIVE = 1;
-
- /**
- * Connected to a car head unit by projecting to it.
- */
- public static final int PROJECTION = 2;
-
- private final LiveData<Integer> mConnectionTypeLiveData;
-
- /**
- * Constructs a {@link ConnectionToCar} that can be used to get connection information.
- *
- * @throws NullPointerException if {@code context} is {@code null}
- */
- public ConnectionToCar(@NonNull Context context) {
- requireNonNull(context);
- mConnectionTypeLiveData = isAutomotiveOS(context)
- ? new AutomotiveCarConnectionTypeLiveData()
- : new CarConnectionTypeLiveData(context);
- }
-
- /**
- * Returns a {@link LiveData} that can be observed to get current connection type.
- *
- * <p>The recommended pattern is to observe the {@link LiveData} with the activity's
- * lifecycle in order to get updates on the state change throughout the activity's lifetime.
- *
- * <p>Connection types are:
- * <ol>
- * <li>{@link #NOT_CONNECTED}
- * <li>{@link #NATIVE}
- * <li>{@link #PROJECTION}
- * </ol>
- */
- @NonNull
- public LiveData<@ConnectionType Integer> getType() {
- return mConnectionTypeLiveData;
- }
-}
diff --git a/car/app/app/src/main/java/androidx/car/app/hardware/CarHardwareManager.java b/car/app/app/src/main/java/androidx/car/app/hardware/CarHardwareManager.java
new file mode 100644
index 0000000..7825bb3
--- /dev/null
+++ b/car/app/app/src/main/java/androidx/car/app/hardware/CarHardwareManager.java
@@ -0,0 +1,97 @@
+/*
+ * Copyright 2021 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.car.app.hardware;
+
+import static androidx.annotation.RestrictTo.Scope.LIBRARY;
+
+import android.content.Context;
+
+import androidx.annotation.NonNull;
+import androidx.annotation.Nullable;
+import androidx.annotation.RestrictTo;
+import androidx.car.app.HostDispatcher;
+import androidx.car.app.annotations.RequiresCarApi;
+import androidx.car.app.hardware.info.CarInfo;
+import androidx.car.app.hardware.info.CarSensors;
+
+import java.lang.reflect.Constructor;
+import java.lang.reflect.InvocationTargetException;
+
+/**
+ * Manages access to car hardware specific properties and sensors.
+ */
+@RequiresCarApi(3)
+public interface CarHardwareManager {
+ /**
+ * Returns the {@link CarInfo} that can be used to query the car hardware information
+ * such as make, model, etc.
+ */
+ default @NonNull CarInfo getCarInfo() {
+ throw new UnsupportedOperationException();
+ }
+
+ /**
+ * Returns the {@link CarSensors} that can be used to access sensor information from the
+ * car hardware.
+ */
+ default @NonNull CarSensors getCarSensors() {
+ throw new UnsupportedOperationException();
+ }
+
+ /**
+ * Returns an instance of {@link CarHardwareManager} depending on linked library including an
+ * optional {@link HostDispatcher}.
+ *
+ * @throws IllegalStateException if none of the supported classes are found or if a supported
+ * class was found but the constructor was mismatched
+ * @hide
+ */
+ @RestrictTo(LIBRARY)
+ @NonNull
+ static CarHardwareManager create(@NonNull Context context,
+ @Nullable HostDispatcher hostDispatcher) throws IllegalStateException {
+
+ try { // Check for automotive library first.
+ Class<?> c = Class.forName("androidx.car.app.hardware.CarHardwareManagerAutomotive");
+ Constructor<?> ctor = c.getConstructor(Context.class);
+ Object object = ctor.newInstance(context);
+ return (CarHardwareManager) object;
+ } catch (ClassNotFoundException e) {
+ // No Automotive. Fall through.
+ } catch (NoSuchMethodException | IllegalAccessException | InstantiationException
+ | InvocationTargetException e) {
+ // Something went wrong with accessing the constructor or calling newInstance().
+ throw new IllegalStateException("Mismatch with app-automotive artifact", e);
+ }
+
+ try { // Check for automotive library first.
+ Class<?> c = Class.forName("androidx.car.app.hardware.CarHardwareManagerProjected");
+ Constructor<?> ctor = c.getConstructor(HostDispatcher.class);
+ Object object = ctor.newInstance(hostDispatcher);
+ return (CarHardwareManager) object;
+ } catch (ClassNotFoundException e) {
+ // No Projected. Fall through.
+ } catch (NoSuchMethodException | IllegalAccessException | InstantiationException
+ | InvocationTargetException e) {
+ // Something went wrong with accessing the constructor or calling newInstance().
+ throw new IllegalStateException("Mismatch with app-projected artifact", e);
+ }
+
+ throw new IllegalStateException("Vehicle Manager not "
+ + "configured. Did you forget to add a dependency on automotive or "
+ + "projected artifacts?");
+ }
+}
diff --git a/car/app/app/src/main/java/androidx/car/app/hardware/common/CarUnit.java b/car/app/app/src/main/java/androidx/car/app/hardware/common/CarUnit.java
new file mode 100644
index 0000000..50a8995
--- /dev/null
+++ b/car/app/app/src/main/java/androidx/car/app/hardware/common/CarUnit.java
@@ -0,0 +1,93 @@
+/*
+ * Copyright 2021 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.car.app.hardware.common;
+
+import static androidx.annotation.RestrictTo.Scope.LIBRARY;
+
+import androidx.annotation.IntDef;
+import androidx.annotation.RestrictTo;
+import androidx.car.app.annotations.CarProtocol;
+import androidx.car.app.annotations.RequiresCarApi;
+
+import java.lang.annotation.Retention;
+import java.lang.annotation.RetentionPolicy;
+
+/** Units such as speed and distance for car hardware measurements and display. */
+@CarProtocol
+@RequiresCarApi(3)
+public final class CarUnit {
+ /**
+ * Defines the possible distance units from car hardware.
+ *
+ * @hide
+ */
+ @IntDef({
+ MILLIMETER,
+ METER,
+ KILOMETER,
+ MILE,
+ })
+ @Retention(RetentionPolicy.SOURCE)
+ @RestrictTo(LIBRARY)
+ public @interface CarDistanceUnit {
+ }
+
+ /** Millimeter unit. */
+ @CarDistanceUnit
+ public static final int MILLIMETER = 1;
+
+ /** Meter unit. */
+ @CarDistanceUnit
+ public static final int METER = 2;
+
+ @CarDistanceUnit
+ /** Kilometer unit. */
+ public static final int KILOMETER = 3;
+
+ /** Miles unit. */
+ @CarDistanceUnit
+ public static final int MILE = 4;
+
+ /**
+ * Defines the possible distance units from car hardware.
+ *
+ * @hide
+ */
+ @IntDef({
+ METERS_PER_SEC,
+ KILOMETERS_PER_HOUR,
+ MILES_PER_HOUR,
+ })
+ @Retention(RetentionPolicy.SOURCE)
+ @RestrictTo(LIBRARY)
+ public @interface CarSpeedUnit {
+ }
+
+ /** Meters per second unit. */
+ @CarSpeedUnit
+ public static final int METERS_PER_SEC = 101;
+
+ /** Kilometers per hour unit. */
+ @CarSpeedUnit
+ public static final int KILOMETERS_PER_HOUR = 102;
+
+ /** Miles per hour unit. */
+ @CarSpeedUnit
+ public static final int MILES_PER_HOUR = 103;
+
+ private CarUnit() {}
+}
diff --git a/car/app/app/src/main/java/androidx/car/app/hardware/common/CarValue.java b/car/app/app/src/main/java/androidx/car/app/hardware/common/CarValue.java
new file mode 100644
index 0000000..ede436a
--- /dev/null
+++ b/car/app/app/src/main/java/androidx/car/app/hardware/common/CarValue.java
@@ -0,0 +1,200 @@
+/*
+ * Copyright 2021 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.car.app.hardware.common;
+
+import static androidx.annotation.RestrictTo.Scope.LIBRARY;
+
+import androidx.annotation.IntDef;
+import androidx.annotation.NonNull;
+import androidx.annotation.Nullable;
+import androidx.annotation.RestrictTo;
+import androidx.car.app.annotations.CarProtocol;
+import androidx.car.app.annotations.RequiresCarApi;
+
+import java.lang.annotation.Retention;
+import java.lang.annotation.RetentionPolicy;
+import java.util.Objects;
+
+/**
+ * A data value object returned from car hardware with associated metadata including status,
+ * timestamp, and the actual value.
+ *
+ * @param <T> data type which is returned by the {@link CarValue}
+ */
+@CarProtocol
+@RequiresCarApi(3)
+public final class CarValue<T> {
+ /**
+ * Defines the possible status codes when trying to access car hardware properties, sensors,
+ * and actions.
+ *
+ * @hide
+ */
+ @IntDef({
+ STATUS_UNKNOWN,
+ STATUS_SUCCESS,
+ STATUS_UNIMPLEMENTED,
+ STATUS_UNAVAILABLE,
+ })
+ @Retention(RetentionPolicy.SOURCE)
+ @RestrictTo(LIBRARY)
+ public @interface StatusCode {
+ }
+
+ /**
+ * {@link CarValue} has unknown status.
+ */
+ @StatusCode
+ public static final int STATUS_UNKNOWN = 0;
+
+ /**
+ * {@link CarValue} was obtained successfully.
+ */
+ @StatusCode
+ public static final int STATUS_SUCCESS = 1;
+
+ /**
+ * {@link CarValue} attempted for unimplemented property, sensor, or action.
+ *
+ * <p>For example, the car hardware might not be able to return a value such as speed or
+ * energy level and will set the status to this value.
+ */
+ @StatusCode
+ public static final int STATUS_UNIMPLEMENTED = 2;
+
+ /**
+ * {@link CarValue} attempted for unavailable property, sensor, or action.
+ *
+ * <p>For example, the car hardware might not be able to return a value such as climate at the
+ * current time because the engine is off and will set the status to this value.
+ */
+ @StatusCode
+ public static final int STATUS_UNAVAILABLE = 3;
+
+ @Nullable
+ private final T mValue;
+ private final long mTimestampMillis;
+ @StatusCode
+ private final int mStatus;
+
+ private static <T> CarValue<T> unimplemented() {
+ return new CarValue<>(null, 0, CarValue.STATUS_UNIMPLEMENTED);
+ }
+
+ /** @hide */
+ @RestrictTo(LIBRARY)
+ public static final CarValue<Integer> UNIMPLEMENTED_INTEGER = unimplemented();
+
+ /** @hide */
+ @RestrictTo(LIBRARY)
+ public static final CarValue<Boolean> UNIMPLEMENTED_BOOLEAN = unimplemented();
+
+ /** @hide */
+ @RestrictTo(LIBRARY)
+ public static final CarValue<Float> UNIMPLEMENTED_FLOAT = unimplemented();
+
+ /** @hide */
+ @RestrictTo(LIBRARY)
+ public static final CarValue<String> UNIMPLEMENTED_STRING = unimplemented();
+
+ /** @hide */
+ @RestrictTo(LIBRARY)
+ public static final CarValue<Float[]> UNIMPLEMENTED_FLOAT_ARRAY = unimplemented();
+
+ /** @hide */
+ @RestrictTo(LIBRARY)
+ public static final CarValue<Integer[]> UNIMPLEMENTED_INTEGER_ARRAY = unimplemented();
+
+ /**
+ * Returns a the data value or {@code null} if the status is not successful.
+ *
+ * @see #getStatus
+ */
+ @Nullable
+ public T getValue() {
+ return mValue;
+ }
+
+ /**
+ * Returns the time in milliseconds at which the event happened.
+ *
+ * <p>For a given property, sensor, or action, each new value's timestamp should be
+ * monotonically increasing using the same time base as SystemClock.elapsedRealtime().
+ */
+ public long getTimestampMillis() {
+ return mTimestampMillis;
+ }
+
+ /**
+ * Returns the status of this particular result such as success, unavailable, or unimplemented.
+ */
+ @StatusCode
+ public int getStatus() {
+ return mStatus;
+ }
+
+ @Override
+ @NonNull
+ public String toString() {
+ return "[value: "
+ + mValue
+ + ", timestamp: "
+ + mTimestampMillis
+ + ", Status: "
+ + mStatus
+ + "]";
+ }
+
+ @Override
+ public int hashCode() {
+ return Objects.hash(mValue, mTimestampMillis, mStatus);
+ }
+
+ @Override
+ public boolean equals(@Nullable Object other) {
+ if (this == other) {
+ return true;
+ }
+ if (!(other instanceof CarValue<?>)) {
+ return false;
+ }
+ CarValue<?> otherCarValue = (CarValue<?>) other;
+ return Objects.equals(mValue, otherCarValue.mValue)
+ && mTimestampMillis == otherCarValue.mTimestampMillis
+ && mStatus == otherCarValue.mStatus;
+ }
+
+ /**
+ * Constructs a new instance of a {@link CarValue}.
+ *
+ * @param value data to be returned with the result
+ * @param timestampMillis the time in milliseconds when the value was generated. See
+ * {@link #getTimestampMillis}
+ * @param status the status code associated with this value
+ */
+ public CarValue(@Nullable T value, long timestampMillis, @StatusCode int status) {
+ mValue = value;
+ mTimestampMillis = timestampMillis;
+ mStatus = status;
+ }
+
+ /** Constructs an empty instance, used by serialization code. */
+ private CarValue() {
+ mValue = null;
+ mTimestampMillis = 0;
+ mStatus = STATUS_UNKNOWN;
+ }
+}
diff --git a/car/app/app/src/main/java/androidx/car/app/hardware/common/OnCarDataListener.java b/car/app/app/src/main/java/androidx/car/app/hardware/common/OnCarDataListener.java
new file mode 100644
index 0000000..191efff
--- /dev/null
+++ b/car/app/app/src/main/java/androidx/car/app/hardware/common/OnCarDataListener.java
@@ -0,0 +1,37 @@
+/*
+ * Copyright 2021 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.car.app.hardware.common;
+
+import androidx.annotation.NonNull;
+import androidx.car.app.annotations.CarProtocol;
+import androidx.car.app.annotations.RequiresCarApi;
+
+/**
+ * A listener for data being returned about from the car hardware.
+ *
+ * @param <T> data type returned by the listener
+ */
+@CarProtocol
+@RequiresCarApi(3)
+public interface OnCarDataListener<T> {
+ /**
+ * Notifies that the requested data is available.
+ *
+ * @param data car hardware data that was requested.
+ */
+ void onCarData(@NonNull T data);
+}
diff --git a/car/app/app/src/main/java/androidx/car/app/hardware/common/UpdateRate.java b/car/app/app/src/main/java/androidx/car/app/hardware/common/UpdateRate.java
new file mode 100644
index 0000000..6c27cb7
--- /dev/null
+++ b/car/app/app/src/main/java/androidx/car/app/hardware/common/UpdateRate.java
@@ -0,0 +1,70 @@
+/*
+ * Copyright 2021 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.car.app.hardware.common;
+
+import static androidx.annotation.RestrictTo.Scope.LIBRARY;
+
+import androidx.annotation.IntDef;
+import androidx.annotation.RestrictTo;
+import androidx.car.app.annotations.CarProtocol;
+import androidx.car.app.annotations.RequiresCarApi;
+
+import java.lang.annotation.Retention;
+import java.lang.annotation.RetentionPolicy;
+
+/** Defines the possible update rates that properties, sensors, and actions can be requested with
+ * . */
+@CarProtocol
+@RequiresCarApi(3)
+public final class UpdateRate {
+ /**
+ * Defines the possible update rates that properties, sensors, and actions can be requested
+ * with.
+ *
+ * @hide
+ */
+ @IntDef({
+ DEFAULT,
+ UI,
+ FASTEST,
+ })
+ @Retention(RetentionPolicy.SOURCE)
+ @RestrictTo(LIBRARY)
+ public @interface Value {
+ }
+
+ /**
+ * Car hardware property, sensor, or action should be fetched at its default rate.
+ */
+ @Value
+ public static final int DEFAULT = 0;
+
+ /**
+ * Car hardware property, sensor, or action should be fetched at a rate consistent with
+ * drawing UI to a screen.
+ */
+ @Value
+ public static final int UI = 1;
+
+ /**
+ * Car hardware property, sensor, or action should be fetched at its fastest possible rate.
+ */
+ @Value
+ public static final int FASTEST = 2;
+
+ private UpdateRate() {}
+}
diff --git a/car/app/app/src/main/java/androidx/car/app/hardware/info/Accelerometer.java b/car/app/app/src/main/java/androidx/car/app/hardware/info/Accelerometer.java
new file mode 100644
index 0000000..8518764
--- /dev/null
+++ b/car/app/app/src/main/java/androidx/car/app/hardware/info/Accelerometer.java
@@ -0,0 +1,134 @@
+/*
+ * Copyright 2021 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.car.app.hardware.info;
+
+import static java.util.Objects.requireNonNull;
+
+import androidx.annotation.Keep;
+import androidx.annotation.NonNull;
+import androidx.annotation.Nullable;
+import androidx.car.app.annotations.CarProtocol;
+import androidx.car.app.annotations.RequiresCarApi;
+import androidx.car.app.hardware.common.CarValue;
+import androidx.car.app.hardware.common.UpdateRate;
+
+import java.util.Objects;
+
+/** Information about car specific accelerometers available from the car hardware. */
+@CarProtocol
+@RequiresCarApi(3)
+public final class Accelerometer {
+
+ /** Accelerometer request parameters. */
+ public static final class Params {
+ private final @UpdateRate.Value int mRate;
+
+ /**
+ * Construct accelerometer parameter instance.
+ */
+ public Params(@UpdateRate.Value int rate) {
+ mRate = rate;
+ }
+
+ /** Gets the requested data rate for the accelerometer. */
+ public @UpdateRate.Value int getRate() {
+ return mRate;
+ }
+
+ /** Gets an {@link Accelerometer.Params} instance with default values set. */
+ public static @NonNull Accelerometer.Params getDefault() {
+ return new Params(UpdateRate.DEFAULT);
+ }
+ }
+
+ @Keep
+ @NonNull
+ private final CarValue<Float[]> mAccelerometer;
+
+ /**
+ * Returns the raw accelerometer data from the car sensor.
+ *
+ * <p>Follows the same format as {@link android.hardware.SensorEvent#values}.
+ */
+ @NonNull
+ public CarValue<Float[]> getAccelerometer() {
+ return requireNonNull(mAccelerometer);
+ }
+
+ @Override
+ @NonNull
+ public String toString() {
+ return "[ accelerometer: " + mAccelerometer + " ]";
+ }
+
+ @Override
+ public int hashCode() {
+ return Objects.hash(mAccelerometer);
+ }
+
+ @Override
+ public boolean equals(@Nullable Object other) {
+ if (this == other) {
+ return true;
+ }
+ if (!(other instanceof Accelerometer)) {
+ return false;
+ }
+ Accelerometer otherAccelerometer = (Accelerometer) other;
+
+ return Objects.equals(mAccelerometer, otherAccelerometer.mAccelerometer);
+ }
+
+ Accelerometer(Builder builder) {
+ mAccelerometer = requireNonNull(builder.mAccelerometer);
+ }
+
+ /** Constructs an empty instance, used by serialization code. */
+ private Accelerometer() {
+ mAccelerometer = CarValue.UNIMPLEMENTED_FLOAT_ARRAY;
+ }
+
+ /** A builder of {@link Accelerometer}. */
+ public static final class Builder {
+ @Nullable
+ CarValue<Float[]> mAccelerometer;
+
+ /**
+ * Sets the raw accelerometer data.
+ *
+ * @throws NullPointerException if {@code accelerometer} is {@code null}
+ */
+ @NonNull
+ public Builder setAccelerometer(@NonNull CarValue<Float[]> accelerometer) {
+ mAccelerometer = requireNonNull(accelerometer);
+ return this;
+ }
+
+ /**
+ * Constructs the {@link Accelerometer} defined by this builder.
+ *
+ * <p>Any fields which have not been set are added with {@code null} value and
+ * {@link CarValue#STATUS_UNIMPLEMENTED}.
+ */
+ @NonNull
+ public Accelerometer build() {
+ if (mAccelerometer == null) {
+ mAccelerometer = CarValue.UNIMPLEMENTED_FLOAT_ARRAY;
+ }
+ return new Accelerometer(this);
+ }
+ }
+}
diff --git a/car/app/app/src/main/java/androidx/car/app/hardware/info/CarHardwareLocation.java b/car/app/app/src/main/java/androidx/car/app/hardware/info/CarHardwareLocation.java
new file mode 100644
index 0000000..2f88b62
--- /dev/null
+++ b/car/app/app/src/main/java/androidx/car/app/hardware/info/CarHardwareLocation.java
@@ -0,0 +1,136 @@
+/*
+ * Copyright 2021 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.car.app.hardware.info;
+
+import static java.util.Objects.requireNonNull;
+
+import android.location.Location;
+
+import androidx.annotation.Keep;
+import androidx.annotation.NonNull;
+import androidx.annotation.Nullable;
+import androidx.car.app.annotations.CarProtocol;
+import androidx.car.app.annotations.RequiresCarApi;
+import androidx.car.app.hardware.common.CarValue;
+import androidx.car.app.hardware.common.UpdateRate;
+
+import java.util.Objects;
+
+/** Information about car specific car location available from the car hardware. */
+@CarProtocol
+@RequiresCarApi(3)
+public final class CarHardwareLocation {
+
+ /** {@link CarHardwareLocation} request parameters. */
+ public static final class Params {
+ private final @UpdateRate.Value int mRate;
+
+ /**
+ * Construct car location parameter instance.
+ */
+ public Params(@UpdateRate.Value int rate) {
+ mRate = rate;
+ }
+
+ /** Gets the requested data rate for the location. */
+ public @UpdateRate.Value int getRate() {
+ return mRate;
+ }
+
+ /** Gets an {@link CarHardwareLocation.Params} instance with default values set. */
+ public static @NonNull CarHardwareLocation.Params getDefault() {
+ return new Params(UpdateRate.DEFAULT);
+ }
+ }
+
+ // Not private because needed in builder.
+ static final CarValue<Location> UNIMPLEMENTED_LOCATION = new CarValue<>(null, 0,
+ CarValue.STATUS_UNAVAILABLE);
+
+ @Keep
+ @NonNull
+ private final CarValue<Location> mLocation;
+
+ /** Returns the raw location data from the car sensor. */
+ @NonNull
+ public CarValue<Location> getLocation() {
+ return requireNonNull(mLocation);
+ }
+
+ @Override
+ @NonNull
+ public String toString() {
+ return "[ location: " + mLocation + " ]";
+ }
+
+ @Override
+ public int hashCode() {
+ return Objects.hash(mLocation);
+ }
+
+ @Override
+ public boolean equals(@Nullable Object other) {
+ if (this == other) {
+ return true;
+ }
+ if (!(other instanceof CarHardwareLocation)) {
+ return false;
+ }
+ CarHardwareLocation otherCarHardwareLocation = (CarHardwareLocation) other;
+
+ return Objects.equals(mLocation, otherCarHardwareLocation.mLocation);
+ }
+
+ CarHardwareLocation(Builder builder) {
+ mLocation = requireNonNull(builder.mLocation);
+ }
+
+ /** Constructs an empty instance, used by serialization code. */
+ private CarHardwareLocation() {
+ mLocation = UNIMPLEMENTED_LOCATION;
+ }
+
+ /** A builder of {@link CarHardwareLocation}. */
+ public static final class Builder {
+ @Nullable
+ CarValue<Location> mLocation;
+
+ /**
+ * Sets the raw car location data.
+ *
+ * @throws NullPointerException if {@code location} is {@code null}
+ */
+ @NonNull
+ public Builder setLocation(@NonNull CarValue<Location> location) {
+ mLocation = requireNonNull(location);
+ return this;
+ }
+
+ /**
+ * Constructs the {@link CarHardwareLocation} defined by this builder.
+ *
+ * <p>Any fields which have not been set are added with {@code null} value and
+ * {@link CarValue#STATUS_UNIMPLEMENTED}.
+ */
+ @NonNull
+ public CarHardwareLocation build() {
+ if (mLocation == null) {
+ mLocation = UNIMPLEMENTED_LOCATION;
+ }
+ return new CarHardwareLocation(this);
+ }
+ }
+}
diff --git a/car/app/app/src/main/java/androidx/car/app/hardware/info/CarInfo.java b/car/app/app/src/main/java/androidx/car/app/hardware/info/CarInfo.java
new file mode 100644
index 0000000..1f04ce6
--- /dev/null
+++ b/car/app/app/src/main/java/androidx/car/app/hardware/info/CarInfo.java
@@ -0,0 +1,144 @@
+/*
+ * Copyright 2021 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.car.app.hardware.info;
+
+import androidx.annotation.NonNull;
+import androidx.car.app.annotations.RequiresCarApi;
+import androidx.car.app.hardware.common.OnCarDataListener;
+
+import java.util.concurrent.Executor;
+
+/**
+ * Manages access to car hardware specific info such as model, energy, and speed info.
+ */
+@RequiresCarApi(3)
+public interface CarInfo {
+ /**
+ * Request the {@link Model} information about the car hardware.
+ *
+ * @param params the parameters for this specific request. Use
+ * {@link Model.Params#getDefault()} as a default.
+ * @param executor the executor which will be used for invoking the listener
+ * @param listener the listener to use
+ */
+ void getModel(@NonNull Model.Params params,
+ @NonNull Executor executor,
+ @NonNull OnCarDataListener<Model> listener);
+
+ /**
+ * Reguest the {@link EnergyProfile} information about the car hardware.
+ *
+ * @param params the parameters for this request. Use {@link EnergyProfile.Params#getDefault}
+ * as a default.
+ * @param executor the executor which will be used for invoking the listener
+ * @param listener the listener to use
+ */
+ void getEnergyProfile(@NonNull EnergyProfile.Params params,
+ @NonNull Executor executor,
+ @NonNull OnCarDataListener<EnergyProfile> listener);
+
+ /**
+ * Setup an ongoing listener to receive {@link Toll} information from the car hardware.
+ *
+ * <p>If the listener was added previously then previous params are updated with the new params.
+ *
+ * @param params the parameters for this request. Use {@link Toll.Params#getDefault}
+ * as a default.
+ * @param executor the executor which will be used for invoking the listener
+ * @param listener the listener to use
+ */
+ void addTollListener(@NonNull Toll.Params params,
+ @NonNull Executor executor,
+ @NonNull OnCarDataListener<Toll> listener);
+
+ /**
+ * Remove an ongoing listener for {@link Toll} information.
+ *
+ * <p>If the listener is not currently added, this call will be ignored.
+ *
+ * @param listener the listener to use
+ */
+ void removeTollListener(@NonNull OnCarDataListener<Toll> listener);
+
+ /**
+ * Setup an ongoing listener to receive {@link EnergyLevel} information from the car hardware.
+ *
+ * <p>If the listener was added previously then previous params are updated with the new params.
+ *
+ * @param params the parameters for this request. Use {@link EnergyLevel.Params#getDefault}
+ * as a default.
+ * @param executor the executor which will be used for invoking the listener
+ * @param listener the listener to use
+ */
+ void addEnergyLevelListener(@NonNull EnergyLevel.Params params,
+ @NonNull Executor executor,
+ @NonNull OnCarDataListener<EnergyLevel> listener);
+
+ /**
+ * Remove an ongoing listener for {@link EnergyLevel} information.
+ *
+ * <p>If the listener is not currently added, this call will be ignored.
+ *
+ * @param listener the listener to use
+ */
+ void removeEnergyLevelListener(@NonNull OnCarDataListener<EnergyLevel> listener);
+
+ /**
+ * Setup an ongoing listener to receive {@link Speed} information from the car hardware.
+ *
+ * <p>If the listener was added previously then previous params are updated with the new params.
+ *
+ * @param params the parameters for this request. Use {@link Speed.Params#getDefault}
+ * as a default.
+ * @param executor the executor which will be used for invoking the listener
+ * @param listener the listener to use
+ */
+ void addSpeedListener(@NonNull Speed.Params params,
+ @NonNull Executor executor,
+ @NonNull OnCarDataListener<Speed> listener);
+
+ /**
+ * Remove an ongoing listener for {@link Speed} information.
+ *
+ * <p>If the listener is not currently added, this call will be ignored.
+ *
+ * @param listener the listener to use
+ */
+ void removeSpeedListener(@NonNull OnCarDataListener<Speed> listener);
+
+ /**
+ * Setup an ongoing listener to receive {@link Mileage} information from the car hardware.
+ *
+ * <p>If the listener was added previously then previous params are updated with the new params.
+ *
+ * @param params the parameters for this request. Use {@link Mileage.Params#getDefault}
+ * as a default.
+ * @param executor the executor which will be used for invoking the listener
+ * @param listener the listener to use.
+ */
+ void addMileageListener(@NonNull Mileage.Params params,
+ @NonNull Executor executor,
+ @NonNull OnCarDataListener<Mileage> listener);
+
+ /**
+ * Remove an ongoing listener for {@link Mileage} information.
+ *
+ * <p>If the listener is not currently added, this call will be ignored.
+ *
+ * @param listener the listener to use
+ */
+ void removeMileageListener(@NonNull OnCarDataListener<Mileage> listener);
+}
diff --git a/car/app/app/src/main/java/androidx/car/app/hardware/info/CarSensors.java b/car/app/app/src/main/java/androidx/car/app/hardware/info/CarSensors.java
new file mode 100644
index 0000000..3f82d41
--- /dev/null
+++ b/car/app/app/src/main/java/androidx/car/app/hardware/info/CarSensors.java
@@ -0,0 +1,122 @@
+/*
+ * Copyright 2021 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.car.app.hardware.info;
+
+import androidx.annotation.NonNull;
+import androidx.car.app.annotations.RequiresCarApi;
+import androidx.car.app.hardware.common.OnCarDataListener;
+
+import java.util.concurrent.Executor;
+
+/**
+ * Manages access to androidx.car.app.hardware specific sensors such as compass, accelerometer,
+ * and gyroscope.
+ */
+@RequiresCarApi(3)
+public interface CarSensors {
+ /**
+ * Setup an ongoing listener to receive {@link Accelerometer} data from the car hardware.
+ *
+ * <p>If the listener was added previously then previous params are updated with the new params.
+ *
+ * @param params the parameters for this request. Use {@link Accelerometer.Params#getDefault}
+ * as a default
+ * @param executor the executor which will be used for invoking the listener
+ * @param listener the listener to use
+ */
+ void addAccelerometerListener(@NonNull Accelerometer.Params params,
+ @NonNull Executor executor,
+ @NonNull OnCarDataListener<Accelerometer> listener);
+
+ /**
+ * Remove an ongoing listener for {@link Accelerometer} information.
+ *
+ * <p>If the listener is not currently added, this call will be ignored.
+ *
+ * @param listener the listener to use
+ */
+ void removeAccelerometerListener(@NonNull OnCarDataListener<Accelerometer> listener);
+
+ /**
+ * Setup an ongoing listener to receive {@link Gyroscope} data from the car hardware.
+ *
+ * <p>If the listener was added previously then previous params are updated with the new params.
+ *
+ * @param params the parameters for this request. Use {@link Gyroscope.Params#getDefault}
+ * as a default
+ * @param executor the executor which will be used for invoking the listener
+ * @param listener the listener to use
+ */
+ void addGyroscopeListener(@NonNull Gyroscope.Params params,
+ @NonNull Executor executor,
+ @NonNull OnCarDataListener<Gyroscope> listener);
+
+ /**
+ * Remove an ongoing listener for {@link Gyroscope} information.
+ *
+ * <p>If the listener is not currently added, this call will be ignored.
+ *
+ * @param listener the listener to use
+ */
+ void removeGyroscopeListener(@NonNull OnCarDataListener<Gyroscope> listener);
+
+ /**
+ * Setup an ongoing listener to receive {@link Compass} data from the car hardware.
+ *
+ * <p>If the listener was added previously then previous params are updated with the new params.
+ *
+ * @param params the parameters for this request. Use {@link Compass.Params#getDefault}
+ * as a default
+ * @param executor the executor which will be used for invoking the listener
+ * @param listener the listener to use
+ */
+ void addCompassListener(@NonNull Compass.Params params,
+ @NonNull Executor executor,
+ @NonNull OnCarDataListener<Compass> listener);
+
+ /**
+ * Remove an ongoing listener for {@link Compass} information.
+ *
+ * <p>If the listener is not currently added, this call will be ignored.
+ *
+ * @param listener the listener to use
+ */
+ void removeCompassListener(@NonNull OnCarDataListener<Compass> listener);
+
+ /**
+ * Setup an ongoing listener to receive {@link CarHardwareLocation} data from the car hardware.
+ *
+ * <p>If the listener was added previously then previous params are updated with the new params.
+ *
+ * @param params the parameters for this request. Use
+ * {@link CarHardwareLocation.Params#getDefault} as a default
+ * @param executor the executor which will be used for invoking the listener
+ * @param listener the listener to use
+ */
+ void addCarHardwareLocationListener(@NonNull CarHardwareLocation.Params params,
+ @NonNull Executor executor,
+ @NonNull OnCarDataListener<CarHardwareLocation> listener);
+
+ /**
+ * Remove an ongoing listener for {@link CarHardwareLocation} information.
+ *
+ * <p>If the listener is not currently added, this call will be ignored.
+ *
+ * @param listener the listener to use
+ */
+ void removeCarHardwareLocationListener(
+ @NonNull OnCarDataListener<CarHardwareLocation> listener);
+}
diff --git a/car/app/app/src/main/java/androidx/car/app/hardware/info/Compass.java b/car/app/app/src/main/java/androidx/car/app/hardware/info/Compass.java
new file mode 100644
index 0000000..1ed0fd9
--- /dev/null
+++ b/car/app/app/src/main/java/androidx/car/app/hardware/info/Compass.java
@@ -0,0 +1,134 @@
+/*
+ * Copyright 2021 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.car.app.hardware.info;
+
+import static java.util.Objects.requireNonNull;
+
+import androidx.annotation.Keep;
+import androidx.annotation.NonNull;
+import androidx.annotation.Nullable;
+import androidx.car.app.annotations.CarProtocol;
+import androidx.car.app.annotations.RequiresCarApi;
+import androidx.car.app.hardware.common.CarValue;
+import androidx.car.app.hardware.common.UpdateRate;
+
+import java.util.Objects;
+
+/** Information about car specific compass available from the car hardware. */
+@CarProtocol
+@RequiresCarApi(3)
+public final class Compass {
+
+ /** Compass request parameters. */
+ public static final class Params {
+ private final @UpdateRate.Value int mRate;
+
+ /**
+ * Construct compass parameter instance.
+ */
+ public Params(@UpdateRate.Value int rate) {
+ mRate = rate;
+ }
+
+ /** Gets the requested data rate for the compass. */
+ public @UpdateRate.Value int getRate() {
+ return mRate;
+ }
+
+ /** Gets an {@link Compass.Params} instance with default values set. */
+ public static @NonNull Compass.Params getDefault() {
+ return new Params(UpdateRate.DEFAULT);
+ }
+ }
+
+ @Keep
+ @NonNull
+ private final CarValue<Float[]> mCompass;
+
+ /**
+ * Returns the raw compass data from the car sensor.
+ *
+ * <p>Follows the same format as {@link android.hardware.SensorEvent#values}.
+ */
+ @NonNull
+ public CarValue<Float[]> getCompass() {
+ return requireNonNull(mCompass);
+ }
+
+ @Override
+ @NonNull
+ public String toString() {
+ return "[ compass: " + mCompass + " ]";
+ }
+
+ @Override
+ public int hashCode() {
+ return Objects.hash(mCompass);
+ }
+
+ @Override
+ public boolean equals(@Nullable Object other) {
+ if (this == other) {
+ return true;
+ }
+ if (!(other instanceof Compass)) {
+ return false;
+ }
+ Compass otherCompass = (Compass) other;
+
+ return Objects.equals(mCompass, otherCompass.mCompass);
+ }
+
+ Compass(Builder builder) {
+ mCompass = requireNonNull(builder.mCompass);
+ }
+
+ /** Constructs an empty instance, used by serialization code. */
+ private Compass() {
+ mCompass = CarValue.UNIMPLEMENTED_FLOAT_ARRAY;
+ }
+
+ /** A builder of {@link Compass}. */
+ public static final class Builder {
+ @Nullable
+ CarValue<Float[]> mCompass;
+
+ /**
+ * Sets the raw compass data.
+ *
+ * @throws NullPointerException if {@code compass} is {@code null}
+ */
+ @NonNull
+ public Builder setCompass(@NonNull CarValue<Float[]> compass) {
+ mCompass = requireNonNull(compass);
+ return this;
+ }
+
+ /**
+ * Constructs the {@link Compass} defined by this builder.
+ *
+ * <p>Any fields which have not been set are added with {@code null} value and
+ * {@link CarValue#STATUS_UNIMPLEMENTED}.
+ */
+ @NonNull
+ public Compass build() {
+ if (mCompass == null) {
+ mCompass = CarValue.UNIMPLEMENTED_FLOAT_ARRAY;
+ }
+ return new Compass(this);
+ }
+ }
+}
diff --git a/car/app/app/src/main/java/androidx/car/app/hardware/info/EnergyLevel.java b/car/app/app/src/main/java/androidx/car/app/hardware/info/EnergyLevel.java
new file mode 100644
index 0000000..86955d8
--- /dev/null
+++ b/car/app/app/src/main/java/androidx/car/app/hardware/info/EnergyLevel.java
@@ -0,0 +1,263 @@
+/*
+ * Copyright 2021 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.car.app.hardware.info;
+
+import static java.util.Objects.requireNonNull;
+
+import androidx.annotation.Keep;
+import androidx.annotation.NonNull;
+import androidx.annotation.Nullable;
+import androidx.car.app.annotations.CarProtocol;
+import androidx.car.app.annotations.RequiresCarApi;
+import androidx.car.app.hardware.common.CarUnit;
+import androidx.car.app.hardware.common.CarValue;
+import androidx.car.app.hardware.common.UpdateRate;
+
+import java.util.Objects;
+
+/** Information of the energy (fuel and battery) levels from the car hardware. */
+@CarProtocol
+@RequiresCarApi(3)
+public final class EnergyLevel {
+
+ /** Energy level request parameters. */
+ public static final class Params {
+ private final @UpdateRate.Value int mRate;
+
+ private static final EnergyLevel.Params DEFAULT = new Params(UpdateRate.DEFAULT);
+
+ /** Construct {@link EnergyLevel} parameter instance. */
+ public Params(@UpdateRate.Value int rate) {
+ mRate = rate;
+ }
+
+ /** Gets the requested data rate for the energy level. */
+ public @UpdateRate.Value int getRate() {
+ return mRate;
+ }
+
+ /** Gets an {@link EnergyLevel.Params} instance with default values set. */
+ public static @NonNull EnergyLevel.Params getDefault() {
+ return DEFAULT;
+ }
+ }
+
+ @Keep
+ @NonNull
+ private final CarValue<Float> mBatteryPercent;
+
+ @Keep
+ @NonNull
+ private final CarValue<Float> mFuelPercent;
+
+ @Keep
+ @NonNull
+ private final CarValue<Boolean> mEnergyIsLow;
+
+ @Keep
+ @NonNull
+ private final CarValue<Float> mRangeRemaining;
+
+ @Keep
+ @NonNull
+ private final CarValue<Integer> mDistanceDisplayUnit;
+
+ /** Returns the battery percentage remaining from the car hardware. */
+ @NonNull
+ public CarValue<Float> getBatteryPercent() {
+ return requireNonNull(mBatteryPercent);
+ }
+
+ /** Returns the fuel percentage remaining from the car hardware. */
+ @NonNull
+ public CarValue<Float> getFuelPercent() {
+ return requireNonNull(mFuelPercent);
+ }
+
+ /** Returns if the remaining car energy is low from the car hardware. */
+ @NonNull
+ public CarValue<Boolean> getEnergyIsLow() {
+ return requireNonNull(mEnergyIsLow);
+ }
+
+ /** Returns the range remaining from the car hardware in meters. */
+ @NonNull
+ public CarValue<Float> getRangeRemaining() {
+ return requireNonNull(mRangeRemaining);
+ }
+
+ /**
+ * Returns the distance display unit from the car hardware.
+ *
+ * <p>See {@link CarUnit} for possible distance values.
+ */
+ @NonNull
+ public CarValue<Integer> getDistanceDisplayUnit() {
+ return requireNonNull(mDistanceDisplayUnit);
+ }
+
+ @Override
+ @NonNull
+ public String toString() {
+ return "[ battery percent: "
+ + mBatteryPercent
+ + ", fuel percent: "
+ + mFuelPercent
+ + ", energyIsLow: "
+ + mEnergyIsLow
+ + ", range remaining: "
+ + mRangeRemaining
+ + ", distance display unit: "
+ + mDistanceDisplayUnit
+ + "]";
+ }
+
+ @Override
+ public int hashCode() {
+ return Objects.hash(mBatteryPercent, mFuelPercent, mEnergyIsLow, mRangeRemaining,
+ mDistanceDisplayUnit);
+ }
+
+ @Override
+ public boolean equals(@Nullable Object other) {
+ if (this == other) {
+ return true;
+ }
+ if (!(other instanceof EnergyLevel)) {
+ return false;
+ }
+ EnergyLevel otherEnergyLevel = (EnergyLevel) other;
+
+ return Objects.equals(mBatteryPercent, otherEnergyLevel.mBatteryPercent)
+ && Objects.equals(mFuelPercent, otherEnergyLevel.mFuelPercent)
+ && Objects.equals(mEnergyIsLow, otherEnergyLevel.mEnergyIsLow)
+ && Objects.equals(mRangeRemaining, otherEnergyLevel.mRangeRemaining)
+ && Objects.equals(mDistanceDisplayUnit, otherEnergyLevel.mDistanceDisplayUnit);
+ }
+
+ EnergyLevel(Builder builder) {
+ mBatteryPercent = requireNonNull(builder.mBatteryPercent);
+ mFuelPercent = requireNonNull(builder.mFuelPercent);
+ mEnergyIsLow = requireNonNull(builder.mEnergyIsLow);
+ mRangeRemaining = requireNonNull(builder.mRangeRemaining);
+ mDistanceDisplayUnit = requireNonNull(builder.mDistanceDisplayUnit);
+ }
+
+ /** Constructs an empty instance, used by serialization code. */
+ private EnergyLevel() {
+ mBatteryPercent = CarValue.UNIMPLEMENTED_FLOAT;
+ mFuelPercent = CarValue.UNIMPLEMENTED_FLOAT;
+ mEnergyIsLow = CarValue.UNIMPLEMENTED_BOOLEAN;
+ mRangeRemaining = CarValue.UNIMPLEMENTED_FLOAT;
+ mDistanceDisplayUnit = CarValue.UNIMPLEMENTED_INTEGER;
+ }
+
+ /** A builder of {@link EnergyLevel}. */
+ public static final class Builder {
+ @Nullable
+ CarValue<Float> mBatteryPercent;
+ @Nullable
+ CarValue<Float> mFuelPercent;
+
+ @Nullable
+ CarValue<Boolean> mEnergyIsLow;
+
+ @Nullable
+ CarValue<Float> mRangeRemaining;
+
+ @Nullable
+ CarValue<Integer> mDistanceDisplayUnit;
+
+ /** Sets the remaining batter percentage. */
+ @NonNull
+ public Builder setBatteryPercent(@NonNull CarValue<Float> batteryPercent) {
+ mBatteryPercent = requireNonNull(batteryPercent);
+ return this;
+ }
+
+ /**
+ * Sets the remaining fuel percentage.
+ *
+ * @throws NullPointerException if {@code fuelPercent} is {@code null}
+ */
+ @NonNull
+ public Builder setFuelPercent(@NonNull CarValue<Float> fuelPercent) {
+ mFuelPercent = requireNonNull(fuelPercent);
+ return this;
+ }
+
+ /**
+ * Sets if the remaining energy is low.
+ *
+ * @throws NullPointerException if {@code energyIsLow} is {@code null}
+ */
+ @NonNull
+ public Builder setEnergyIsLow(@NonNull CarValue<Boolean> energyIsLow) {
+ mEnergyIsLow = requireNonNull(energyIsLow);
+ return this;
+ }
+
+ /**
+ * Sets the range of the remaining fuel in meters.
+ *
+ * @throws NullPointerException if {@code rangeRemaining} is {@code null}
+ */
+ @NonNull
+ public Builder setRangeRemaining(@NonNull CarValue<Float> rangeRemaining) {
+ mRangeRemaining = requireNonNull(rangeRemaining);
+ return this;
+ }
+
+ /**
+ * Sets the distance display unit.
+ *
+ * <p>Valid values are in {@link CarUnit}.
+ *
+ * @throws NullPointerException if {@code distanceDisplayUnit} is {@code null}
+ */
+ @NonNull
+ public Builder setDistanceDisplayUnit(@NonNull CarValue<Integer> distanceDisplayUnit) {
+ mDistanceDisplayUnit = requireNonNull(distanceDisplayUnit);
+ return this;
+ }
+
+ /**
+ * Constructs the {@link EnergyLevel} defined by this builder.
+ *
+ * <p>Any fields which have not been set are added with {@code null} value and
+ * {@link CarValue#STATUS_UNIMPLEMENTED}.
+ */
+ @NonNull
+ public EnergyLevel build() {
+ if (mBatteryPercent == null) {
+ mBatteryPercent = CarValue.UNIMPLEMENTED_FLOAT;
+ }
+ if (mFuelPercent == null) {
+ mFuelPercent = CarValue.UNIMPLEMENTED_FLOAT;
+ }
+ if (mEnergyIsLow == null) {
+ mEnergyIsLow = CarValue.UNIMPLEMENTED_BOOLEAN;
+ }
+ if (mRangeRemaining == null) {
+ mRangeRemaining = CarValue.UNIMPLEMENTED_FLOAT;
+ }
+ if (mDistanceDisplayUnit == null) {
+ mDistanceDisplayUnit = CarValue.UNIMPLEMENTED_INTEGER;
+ }
+ return new EnergyLevel(this);
+ }
+ }
+}
diff --git a/car/app/app/src/main/java/androidx/car/app/hardware/info/EnergyProfile.java b/car/app/app/src/main/java/androidx/car/app/hardware/info/EnergyProfile.java
new file mode 100644
index 0000000..f9590f5
--- /dev/null
+++ b/car/app/app/src/main/java/androidx/car/app/hardware/info/EnergyProfile.java
@@ -0,0 +1,292 @@
+/*
+ * Copyright 2021 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.car.app.hardware.info;
+
+import static androidx.annotation.RestrictTo.Scope.LIBRARY;
+
+import static java.util.Objects.requireNonNull;
+
+import androidx.annotation.IntDef;
+import androidx.annotation.Keep;
+import androidx.annotation.NonNull;
+import androidx.annotation.Nullable;
+import androidx.annotation.RestrictTo;
+import androidx.car.app.annotations.CarProtocol;
+import androidx.car.app.annotations.RequiresCarApi;
+import androidx.car.app.hardware.common.CarValue;
+
+import java.lang.annotation.Retention;
+import java.lang.annotation.RetentionPolicy;
+import java.util.Objects;
+
+/** Information about car hardware fuel profile such as fuel types and connector ports. */
+@CarProtocol
+@RequiresCarApi(3)
+public final class EnergyProfile {
+
+ /**
+ * Possible EV Connector types.
+ *
+ * @hide
+ */
+ @IntDef({
+ EVCONNECTOR_TYPE_UNKNOWN,
+ EVCONNECTOR_TYPE_J1772,
+ EVCONNECTOR_TYPE_MENNEKES,
+ EVCONNECTOR_TYPE_CHADEMO,
+ EVCONNECTOR_TYPE_COMBO_1,
+ EVCONNECTOR_TYPE_COMBO_2,
+ EVCONNECTOR_TYPE_TESLA_ROADSTER,
+ EVCONNECTOR_TYPE_TESLA_HPWC,
+ EVCONNECTOR_TYPE_TESLA_SUPERCHARGER,
+ EVCONNECTOR_TYPE_GBT,
+ EVCONNECTOR_TYPE_GBT_DC,
+ EVCONNECTOR_TYPE_SCAME,
+ EVCONNECTOR_TYPE_OTHER,
+ })
+ @Retention(RetentionPolicy.SOURCE)
+ @RestrictTo(LIBRARY)
+ public @interface EvConnectorType {}
+
+ /** Unknown connector type. */
+ @EvConnectorType
+ public static final int EVCONNECTOR_TYPE_UNKNOWN = 0;
+
+ /** Connector type SAE J1772 */
+ @EvConnectorType
+ public static final int EVCONNECTOR_TYPE_J1772 = 1;
+
+ /** IEC 62196 Type 2 connector */
+ @EvConnectorType
+ public static final int EVCONNECTOR_TYPE_MENNEKES = 2;
+
+ /** CHAdeMo fast charger connector */
+ @EvConnectorType
+ public static final int EVCONNECTOR_TYPE_CHADEMO = 3;
+
+ /** Combined Charging System Combo 1 */
+ @EvConnectorType
+ public static final int EVCONNECTOR_TYPE_COMBO_1 = 4;
+
+ /** Combined Charging System Combo 2 */
+ @EvConnectorType
+ public static final int EVCONNECTOR_TYPE_COMBO_2 = 5;
+
+ /** Connector of Tesla Roadster */
+ @EvConnectorType
+ public static final int EVCONNECTOR_TYPE_TESLA_ROADSTER = 6;
+
+ /** High Power Wall Charger of Tesla */
+ @EvConnectorType
+ public static final int EVCONNECTOR_TYPE_TESLA_HPWC = 7;
+
+ /** Supercharger of Tesla */
+ @EvConnectorType
+ public static final int EVCONNECTOR_TYPE_TESLA_SUPERCHARGER = 8;
+
+ /** GBT_AC Fast Charging Standard */
+ @EvConnectorType
+ public static final int EVCONNECTOR_TYPE_GBT = 9;
+
+ /** GBT_DC Fast Charging Standard */
+ @EvConnectorType
+ public static final int EVCONNECTOR_TYPE_GBT_DC = 10;
+
+ /** IEC_TYPE_3_AC connector */
+ @EvConnectorType
+ public static final int EVCONNECTOR_TYPE_SCAME = 11;
+
+ /**
+ * Connector type to use when no other types apply.
+ */
+ @EvConnectorType
+ public static final int EVCONNECTOR_TYPE_OTHER = 101;
+
+ /** Energy profile request parameters. */
+ @SuppressWarnings("PrivateConstructorForUtilityClass")
+ public static final class Params {
+ public static @NonNull Params getDefault() {
+ return new Params();
+ }
+ }
+
+ /**
+ * Possible Fual types.
+ *
+ * @hide
+ */
+ @IntDef({
+ FUEL_TYPE_UNKNOWN,
+ FUEL_TYPE_UNLEADED,
+ FUEL_TYPE_LEADED,
+ FUEL_TYPE_DIESEL_1,
+ FUEL_TYPE_DIESEL_2,
+ FUEL_TYPE_BIODIESEL,
+ FUEL_TYPE_E85,
+ FUEL_TYPE_LPG,
+ FUEL_TYPE_CNG,
+ FUEL_TYPE_LNG,
+ FUEL_TYPE_ELECTRIC,
+ FUEL_TYPE_HYDROGEN,
+ FUEL_TYPE_OTHER,
+ })
+ @Retention(RetentionPolicy.SOURCE)
+ @RestrictTo(LIBRARY)
+ public @interface FuelType {}
+
+ /** Unknown fuel type */
+ @FuelType public static final int FUEL_TYPE_UNKNOWN = 0;
+ /** Unleaded gasoline */
+ @FuelType public static final int FUEL_TYPE_UNLEADED = 1;
+ /** Leaded gasoline */
+ @FuelType public static final int FUEL_TYPE_LEADED = 2;
+ /** #1 Grade Diesel */
+ @FuelType public static final int FUEL_TYPE_DIESEL_1 = 3;
+ /** #2 Grade Diesel */
+ @FuelType public static final int FUEL_TYPE_DIESEL_2 = 4;
+ /** Biodiesel */
+ @FuelType public static final int FUEL_TYPE_BIODIESEL = 5;
+ /** 85% ethanol/gasoline blend */
+ @FuelType public static final int FUEL_TYPE_E85 = 6;
+ /** Liquified petroleum gas */
+ @FuelType public static final int FUEL_TYPE_LPG = 7;
+ /** Compressed natural gas */
+ @FuelType public static final int FUEL_TYPE_CNG = 8;
+ /** Liquified natural gas */
+ @FuelType public static final int FUEL_TYPE_LNG = 9;
+ /** Electric */
+ @FuelType public static final int FUEL_TYPE_ELECTRIC = 10;
+ /** Hydrogen fuel cell */
+ @FuelType public static final int FUEL_TYPE_HYDROGEN = 11;
+ /** Fuel type to use when no other types apply. */
+ @FuelType public static final int FUEL_TYPE_OTHER = 12;
+
+ @Keep
+ @NonNull
+ private final CarValue<Integer[]> mEvConnectorTypes;
+
+ @Keep
+ @NonNull
+ private final CarValue<Integer[]> mFuelTypes;
+
+ /**
+ * Returns an array of the available EV connectors.
+ *
+ * <p>If a vehicle does not know the EV connector type it will return
+ * {@link #EVCONNECTOR_TYPE_UNKNOWN} or {@link CarValue#STATUS_UNIMPLEMENTED}. If the value
+ * is known but not in the current list {@link #EVCONNECTOR_TYPE_UNKNOWN} will be returned.
+ */
+ @NonNull
+ public CarValue<Integer[]> getEvConnectorTypes() {
+ return requireNonNull(mEvConnectorTypes);
+ }
+
+ /**
+ * Returns an array of the available fuel types.
+ *
+ * <p>If a vehicle does not know the fuel type it will return {@link #FUEL_TYPE_UNKNOWN} or
+ * {@link CarValue#STATUS_UNIMPLEMENTED}. If the value is known but not in the current list
+ * {@link #EVCONNECTOR_TYPE_UNKNOWN} will be returned.
+ */
+ @NonNull
+ public CarValue<Integer[]> getFuelTypes() {
+ return requireNonNull(mFuelTypes);
+ }
+
+ @Override
+ @NonNull
+ public String toString() {
+ return "[ evConnectorTypes: " + mEvConnectorTypes + ", fuelTypes: " + mFuelTypes + "]";
+ }
+
+ @Override
+ public int hashCode() {
+ return Objects.hash(mEvConnectorTypes, mFuelTypes);
+ }
+
+ @Override
+ public boolean equals(@Nullable Object other) {
+ if (this == other) {
+ return true;
+ }
+ if (!(other instanceof EnergyProfile)) {
+ return false;
+ }
+ EnergyProfile otherProfile = (EnergyProfile) other;
+
+ return Objects.equals(mEvConnectorTypes, otherProfile.mEvConnectorTypes)
+ && Objects.equals(mFuelTypes, otherProfile.mFuelTypes);
+ }
+
+ EnergyProfile(Builder builder) {
+ mEvConnectorTypes = requireNonNull(builder.mEvConnectorTypes);
+ mFuelTypes = requireNonNull(builder.mFuelTypes);
+ }
+
+ /** Constructs an empty instance, used by serialization code. */
+ private EnergyProfile() {
+ mEvConnectorTypes = CarValue.UNIMPLEMENTED_INTEGER_ARRAY;
+ mFuelTypes = CarValue.UNIMPLEMENTED_INTEGER_ARRAY;
+ }
+
+ /** A builder of {@link EnergyProfile}. */
+ public static final class Builder {
+ @Nullable
+ CarValue<Integer[]> mEvConnectorTypes;
+ @Nullable
+ CarValue<Integer[]> mFuelTypes;
+
+ /**
+ * Sets the cars EV connector types.
+ *
+ * @throws NullPointerException if {@code evConnectorTypes} is {@code null}
+ */
+ @NonNull
+ public Builder setEvConnectorTypes(@NonNull CarValue<Integer[]> evConnectorTypes) {
+ mEvConnectorTypes = requireNonNull(evConnectorTypes);
+ return this;
+ }
+
+ /**
+ * Sets the cars fuel types.
+ *
+ * @throws NullPointerException if {@code fuelTypes} is {@code null}
+ */
+ @NonNull
+ public Builder setFuelTypes(@NonNull CarValue<Integer[]> fuelTypes) {
+ mFuelTypes = requireNonNull(fuelTypes);
+ return this;
+ }
+
+ /**
+ * Constructs the {@link EnergyProfile} defined by this builder.
+ *
+ * <p>Any fields which have not been set are added with {@code null} value and
+ * {@link CarValue#STATUS_UNIMPLEMENTED}.
+ */
+ @NonNull
+ public EnergyProfile build() {
+ if (mEvConnectorTypes == null) {
+ mEvConnectorTypes = CarValue.UNIMPLEMENTED_INTEGER_ARRAY;
+ }
+ if (mFuelTypes == null) {
+ mFuelTypes = CarValue.UNIMPLEMENTED_INTEGER_ARRAY;
+ }
+ return new EnergyProfile(this);
+ }
+
+ }
+}
diff --git a/car/app/app/src/main/java/androidx/car/app/hardware/info/Gyroscope.java b/car/app/app/src/main/java/androidx/car/app/hardware/info/Gyroscope.java
new file mode 100644
index 0000000..38eee39
--- /dev/null
+++ b/car/app/app/src/main/java/androidx/car/app/hardware/info/Gyroscope.java
@@ -0,0 +1,130 @@
+/*
+ * Copyright 2021 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.car.app.hardware.info;
+
+import static java.util.Objects.requireNonNull;
+
+import androidx.annotation.Keep;
+import androidx.annotation.NonNull;
+import androidx.annotation.Nullable;
+import androidx.car.app.annotations.CarProtocol;
+import androidx.car.app.annotations.RequiresCarApi;
+import androidx.car.app.hardware.common.CarValue;
+import androidx.car.app.hardware.common.UpdateRate;
+
+import java.util.Objects;
+
+/** Information about car specific gyroscopes available from the car hardware. */
+@CarProtocol
+@RequiresCarApi(3)
+public final class Gyroscope {
+
+ /** Gyroscope request parameters. */
+ public static final class Params {
+ private final @UpdateRate.Value int mRate;
+
+ /**
+ * Construct gyroscope parameter instance.
+ */
+ public Params(@UpdateRate.Value int rate) {
+ mRate = rate;
+ }
+
+ /** Gets the requested data rate for the gyroscope. */
+ public @UpdateRate.Value int getRate() {
+ return mRate;
+ }
+
+ /** Gets an {@link Gyroscope.Params} instance with default values set. */
+ public static @NonNull Gyroscope.Params getDefault() {
+ return new Params(UpdateRate.DEFAULT);
+ }
+ }
+
+ @Keep
+ @NonNull
+ private final CarValue<Float[]> mGyroscope;
+
+ /** Returns the raw gyroscope data from the car sensor. */
+ @NonNull
+ public CarValue<Float[]> getGyroscope() {
+ return requireNonNull(mGyroscope);
+ }
+
+ @Override
+ @NonNull
+ public String toString() {
+ return "[ gyroscope: " + mGyroscope + " ]";
+ }
+
+ @Override
+ public int hashCode() {
+ return Objects.hash(mGyroscope);
+ }
+
+ @Override
+ public boolean equals(@Nullable Object other) {
+ if (this == other) {
+ return true;
+ }
+ if (!(other instanceof Gyroscope)) {
+ return false;
+ }
+ Gyroscope otherGyroscope = (Gyroscope) other;
+
+ return Objects.equals(mGyroscope, otherGyroscope.mGyroscope);
+ }
+
+ Gyroscope(Builder builder) {
+ mGyroscope = requireNonNull(builder.mGyroscope);
+ }
+
+ /** Constructs an empty instance, used by serialization code. */
+ private Gyroscope() {
+ mGyroscope = CarValue.UNIMPLEMENTED_FLOAT_ARRAY;
+ }
+
+ /** A builder of {@link Gyroscope}. */
+ public static final class Builder {
+ @Nullable
+ CarValue<Float[]> mGyroscope;
+
+ /**
+ * Sets the raw gyroscope data.
+ *
+ * @throws NullPointerException if {@code gyroscope} is {@code null}
+ */
+ @NonNull
+ public Builder setGyroscope(@NonNull CarValue<Float[]> gyroscope) {
+ mGyroscope = requireNonNull(gyroscope);
+ return this;
+ }
+
+ /**
+ * Constructs the {@link Gyroscope} defined by this builder.
+ *
+ * <p>Any fields which have not been set are added with {@code null} value and
+ * {@link CarValue#STATUS_UNIMPLEMENTED}.
+ */
+ @NonNull
+ public Gyroscope build() {
+ if (mGyroscope == null) {
+ mGyroscope = CarValue.UNIMPLEMENTED_FLOAT_ARRAY;
+ }
+ return new Gyroscope(this);
+ }
+ }
+}
diff --git a/car/app/app/src/main/java/androidx/car/app/hardware/info/Mileage.java b/car/app/app/src/main/java/androidx/car/app/hardware/info/Mileage.java
new file mode 100644
index 0000000..fb93d0d
--- /dev/null
+++ b/car/app/app/src/main/java/androidx/car/app/hardware/info/Mileage.java
@@ -0,0 +1,166 @@
+/*
+ * Copyright 2021 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.car.app.hardware.info;
+
+import static java.util.Objects.requireNonNull;
+
+import androidx.annotation.Keep;
+import androidx.annotation.NonNull;
+import androidx.annotation.Nullable;
+import androidx.car.app.annotations.CarProtocol;
+import androidx.car.app.annotations.RequiresCarApi;
+import androidx.car.app.hardware.common.CarUnit;
+import androidx.car.app.hardware.common.CarValue;
+import androidx.car.app.hardware.common.UpdateRate;
+
+import java.util.Objects;
+
+/** Information about car mileage. */
+@CarProtocol
+@RequiresCarApi(3)
+public final class Mileage {
+
+ /** Mileage request parameters. */
+ public static final class Params {
+ private final @UpdateRate.Value int mRate;
+
+ public Params(@UpdateRate.Value int rate) {
+ mRate = rate;
+ }
+
+ public @UpdateRate.Value int getRate() {
+ return mRate;
+ }
+
+ public static @NonNull Mileage.Params getDefault() {
+ return new Params(UpdateRate.DEFAULT);
+ }
+ }
+
+ @Keep
+ @NonNull
+ private final CarValue<Float> mOdometer;
+
+ @Keep
+ @NonNull
+ private final CarValue<Integer> mDistanceDisplayUnit;
+
+ /** Returns the value of the odometer from the car hardware in meters. */
+ @NonNull
+ public CarValue<Float> getOdometer() {
+ return requireNonNull(mOdometer);
+ }
+
+ /**
+ * Returns the distance display unit from the car hardware.
+ *
+ * <p>See {@link CarUnit} for possible distance values.
+ */
+ @NonNull
+ public CarValue<Integer> getDistanceDisplayUnit() {
+ return requireNonNull(mDistanceDisplayUnit);
+ }
+
+ @Override
+ @NonNull
+ public String toString() {
+ return "[ odometer: "
+ + mOdometer
+ + ", distance display unit: "
+ + mDistanceDisplayUnit
+ + "]";
+ }
+
+ @Override
+ public int hashCode() {
+ return Objects.hash(mOdometer, mDistanceDisplayUnit);
+ }
+
+ @Override
+ public boolean equals(@Nullable Object other) {
+ if (this == other) {
+ return true;
+ }
+ if (!(other instanceof Mileage)) {
+ return false;
+ }
+ Mileage otherMileage = (Mileage) other;
+
+ return Objects.equals(mOdometer, otherMileage.mOdometer)
+ && Objects.equals(mDistanceDisplayUnit, otherMileage.mDistanceDisplayUnit);
+ }
+
+ Mileage(Builder builder) {
+ mOdometer = requireNonNull(builder.mOdometer);
+ mDistanceDisplayUnit = requireNonNull(builder.mDistanceDisplayUnit);
+ }
+
+ /** Constructs an empty instance, used by serialization code. */
+ private Mileage() {
+ mOdometer = CarValue.UNIMPLEMENTED_FLOAT;
+ mDistanceDisplayUnit = CarValue.UNIMPLEMENTED_INTEGER;
+ }
+
+ /** A builder of {@link Mileage}. */
+ public static final class Builder {
+ @Nullable
+ CarValue<Float> mOdometer;
+ @Nullable
+ CarValue<Integer> mDistanceDisplayUnit;
+
+ /**
+ * Sets the odometer value in meters.
+ *
+ * @throws NullPointerException if {@code odometer} is {@code null}
+ */
+ @NonNull
+ public Builder setOdometer(@NonNull CarValue<Float> odometer) {
+ mOdometer = requireNonNull(odometer);
+ return this;
+ }
+
+ /**
+ * Sets the mileage display unit.
+ *
+ * <p>Valid values are in {@link CarUnit}.
+ *
+ * @throws NullPointerException if {@code mileageDisplayUnit} is {@code null}
+ */
+ @NonNull
+ public Builder setDistanceDisplayUnit(@NonNull CarValue<Integer> mileageDisplayUnit) {
+ mDistanceDisplayUnit = requireNonNull(mileageDisplayUnit);
+ return this;
+ }
+
+ /**
+ * Constructs the {@link Mileage} defined by this builder.
+ *
+ * <p>Any fields which have not been set are added with {@code null} value and
+ * {@link CarValue#STATUS_UNIMPLEMENTED}.
+ */
+ @NonNull
+ public Mileage build() {
+ if (mOdometer == null) {
+ mOdometer = CarValue.UNIMPLEMENTED_FLOAT;
+ }
+ if (mDistanceDisplayUnit == null) {
+ mDistanceDisplayUnit = CarValue.UNIMPLEMENTED_INTEGER;
+ }
+ return new Mileage(this);
+ }
+
+ }
+}
diff --git a/car/app/app/src/main/java/androidx/car/app/hardware/info/Model.java b/car/app/app/src/main/java/androidx/car/app/hardware/info/Model.java
new file mode 100644
index 0000000..5af402b
--- /dev/null
+++ b/car/app/app/src/main/java/androidx/car/app/hardware/info/Model.java
@@ -0,0 +1,176 @@
+/*
+ * Copyright 2021 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.car.app.hardware.info;
+
+import static java.util.Objects.requireNonNull;
+
+import androidx.annotation.Keep;
+import androidx.annotation.NonNull;
+import androidx.annotation.Nullable;
+import androidx.car.app.annotations.CarProtocol;
+import androidx.car.app.annotations.RequiresCarApi;
+import androidx.car.app.hardware.common.CarValue;
+
+import java.util.Objects;
+
+/**
+ * Information about the androidx.car.app.hardware model such as name, year and manufacturer.
+ */
+@CarProtocol
+@RequiresCarApi(3)
+public final class Model {
+
+ /** Model request parameters. */
+ @SuppressWarnings("PrivateConstructorForUtilityClass")
+ public static final class Params {
+ public static @NonNull Params getDefault() {
+ return new Params();
+ }
+ }
+
+ @Keep
+ @NonNull
+ private final CarValue<String> mName;
+
+ @Keep
+ @NonNull
+ private final CarValue<Integer> mYear;
+
+ @Keep
+ @NonNull
+ private final CarValue<String> mManufacturer;
+
+ /** Returns the car model name. */
+ @NonNull
+ public CarValue<String> getName() {
+ return requireNonNull(mName);
+ }
+
+ /** Returns the car model year. */
+ @NonNull
+ public CarValue<Integer> getYear() {
+ return requireNonNull(mYear);
+ }
+
+ /** Returns the car manufacturer. */
+ @NonNull
+ public CarValue<String> getManufacturer() {
+ return requireNonNull(mManufacturer);
+ }
+
+ @Override
+ @NonNull
+ public String toString() {
+ return "[ name: " + mName + ", year: " + mYear + ", manufacturer: " + mManufacturer + "]";
+ }
+
+ @Override
+ public int hashCode() {
+ return Objects.hash(mName, mYear, mManufacturer);
+ }
+
+ @Override
+ public boolean equals(@Nullable Object other) {
+ if (this == other) {
+ return true;
+ }
+ if (!(other instanceof Model)) {
+ return false;
+ }
+ Model otherModel = (Model) other;
+
+ return Objects.equals(mName, otherModel.mName)
+ && Objects.equals(mYear, otherModel.mYear)
+ && Objects.equals(mManufacturer, otherModel.mManufacturer);
+ }
+
+ Model(Builder builder) {
+ mName = requireNonNull(builder.mName);
+ mManufacturer = requireNonNull(builder.mManufacturer);
+ mYear = requireNonNull(builder.mYear);
+ }
+
+ /** Constructs an empty instance, used by serialization code. */
+ private Model() {
+ mName = CarValue.UNIMPLEMENTED_STRING;
+ mManufacturer = CarValue.UNIMPLEMENTED_STRING;
+ mYear = CarValue.UNIMPLEMENTED_INTEGER;
+ }
+
+ /** A builder of {@link Model}. */
+ public static final class Builder {
+ @Nullable
+ CarValue<String> mName;
+ @Nullable
+ CarValue<Integer> mYear;
+ @Nullable
+ CarValue<String> mManufacturer;
+
+ /**
+ * Sets the car model name.
+ *
+ * @throws NullPointerException if {@code name} is {@code null}
+ */
+ @NonNull
+ public Builder setName(@NonNull CarValue<String> name) {
+ mName = requireNonNull(name);
+ return this;
+ }
+
+ /**
+ * Sets the car model year.
+ *
+ * @throws NullPointerException if {@code year} is {@code null}
+ */
+ @NonNull
+ public Builder setYear(@NonNull CarValue<Integer> year) {
+ mYear = requireNonNull(year);
+ return this;
+ }
+
+ /**
+ * Sets the car manufacturer.
+ *
+ * @throws NullPointerException if {@code manufacturer} is {@code null}
+ */
+ @NonNull
+ public Builder setManufacturer(@NonNull CarValue<String> manufacturer) {
+ mManufacturer = requireNonNull(manufacturer);
+ return this;
+ }
+
+ /**
+ * Constructs the {@link Model} defined by this builder.
+ *
+ * <p>Any fields which have not been set are added with {@code null} value and
+ * {@link CarValue#STATUS_UNIMPLEMENTED}.
+ */
+ @NonNull
+ public Model build() {
+ if (mName == null) {
+ mName = CarValue.UNIMPLEMENTED_STRING;
+ }
+ if (mYear == null) {
+ mYear = CarValue.UNIMPLEMENTED_INTEGER;
+ }
+ if (mManufacturer == null) {
+ mManufacturer = CarValue.UNIMPLEMENTED_STRING;
+ }
+ return new Model(this);
+ }
+
+ }
+}
diff --git a/car/app/app/src/main/java/androidx/car/app/hardware/info/Speed.java b/car/app/app/src/main/java/androidx/car/app/hardware/info/Speed.java
new file mode 100644
index 0000000..bfbc856
--- /dev/null
+++ b/car/app/app/src/main/java/androidx/car/app/hardware/info/Speed.java
@@ -0,0 +1,201 @@
+/*
+ * Copyright 2021 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.car.app.hardware.info;
+
+import static java.util.Objects.requireNonNull;
+
+import androidx.annotation.Keep;
+import androidx.annotation.NonNull;
+import androidx.annotation.Nullable;
+import androidx.car.app.annotations.CarProtocol;
+import androidx.car.app.annotations.RequiresCarApi;
+import androidx.car.app.hardware.common.CarUnit;
+import androidx.car.app.hardware.common.CarValue;
+import androidx.car.app.hardware.common.UpdateRate;
+
+import java.util.Objects;
+
+/**
+ * Information about the current car speed.
+ */
+@CarProtocol
+@RequiresCarApi(3)
+public final class Speed {
+
+ /**
+ * Parameters for speed requests.
+ */
+ public static final class Params {
+ private final @UpdateRate.Value int mRate;
+
+ public Params(@UpdateRate.Value int rate) {
+ mRate = rate;
+ }
+
+ public @UpdateRate.Value int getRate() {
+ return mRate;
+ }
+
+ public static @NonNull Speed.Params getDefault() {
+ return new Params(UpdateRate.DEFAULT);
+ }
+ }
+
+ @Keep
+ @NonNull
+ private final CarValue<Float> mRawSpeed;
+
+ @Keep
+ @NonNull
+ private final CarValue<Float> mDisplaySpeed;
+
+ @Keep
+ @NonNull
+ private final CarValue<Integer> mSpeedDisplayUnit;
+
+ /** Returns the raw speed of the car in meters/second. */
+ @NonNull
+ public CarValue<Float> getRawSpeed() {
+ return requireNonNull(mRawSpeed);
+ }
+
+ /** Returns the display speed of the car in meters/second. */
+ @NonNull
+ public CarValue<Float> getDisplaySpeed() {
+ return requireNonNull(mDisplaySpeed);
+ }
+
+ /**
+ * Returns the units used to display speed from the car settings.
+ *
+ * <p>See {@link CarUnit} for valid speed units.
+ */
+ @NonNull
+ public CarValue<Integer> getSpeedDisplayUnit() {
+ return requireNonNull(mSpeedDisplayUnit);
+ }
+
+ @Override
+ @NonNull
+ public String toString() {
+ return "[ raw speed: "
+ + mRawSpeed
+ + ", display speed: "
+ + mDisplaySpeed
+ + ", speed display unit: "
+ + mSpeedDisplayUnit
+ + "]";
+ }
+
+ @Override
+ public int hashCode() {
+ return Objects.hash(mRawSpeed, mDisplaySpeed, mSpeedDisplayUnit);
+ }
+
+ @Override
+ public boolean equals(@Nullable Object other) {
+ if (this == other) {
+ return true;
+ }
+ if (!(other instanceof Speed)) {
+ return false;
+ }
+ Speed otherSpeed = (Speed) other;
+
+ return Objects.equals(mRawSpeed, otherSpeed.mRawSpeed)
+ && Objects.equals(mDisplaySpeed, otherSpeed.mDisplaySpeed)
+ && Objects.equals(mSpeedDisplayUnit, otherSpeed.mSpeedDisplayUnit);
+ }
+
+ Speed(Builder builder) {
+ mRawSpeed = requireNonNull(builder.mRawSpeed);
+ mDisplaySpeed = requireNonNull(builder.mDisplaySpeed);
+ mSpeedDisplayUnit = requireNonNull(builder.mSpeedDisplayUnit);
+ }
+
+ /** Constructs an empty instance, used by serialization code. */
+ private Speed() {
+ mRawSpeed = CarValue.UNIMPLEMENTED_FLOAT;
+ mDisplaySpeed = CarValue.UNIMPLEMENTED_FLOAT;
+ mSpeedDisplayUnit = CarValue.UNIMPLEMENTED_INTEGER;
+ }
+
+ /** A builder of {@link Speed}. */
+ public static final class Builder {
+ @Nullable
+ CarValue<Float> mRawSpeed;
+ @Nullable
+ CarValue<Float> mDisplaySpeed;
+
+ @Nullable
+ CarValue<Integer> mSpeedDisplayUnit;
+
+ /**
+ * Sets the raw speed.
+ *
+ * @throws NullPointerException if {@code rawSpeed} is {@code null}
+ */
+ @NonNull
+ public Builder setRawSpeed(@NonNull CarValue<Float> rawSpeed) {
+ mRawSpeed = requireNonNull(rawSpeed);
+ return this;
+ }
+
+ /**
+ * Sets the display speed. *
+ *
+ * @throws NullPointerException if {@code displaySpeed} is {@code null}
+ */
+ @NonNull
+ public Builder setDisplaySpeed(@NonNull CarValue<Float> displaySpeed) {
+ mDisplaySpeed = requireNonNull(displaySpeed);
+ return this;
+ }
+
+ /**
+ * Sets the units used to display speed from the car hardware settings.
+ *
+ * <p>See {@link CarUnit} for valid speed units.
+ *
+ * @throws NullPointerException if {@code speedDisplayUnit} is {@code null}
+ */
+ @NonNull
+ public Builder setSpeedDisplayUnit(@NonNull CarValue<Integer> speedDisplayUnit) {
+ mSpeedDisplayUnit = requireNonNull(speedDisplayUnit);
+ return this;
+ }
+
+ /**
+ * Constructs the {@link Speed} defined by this builder.
+ *
+ * <p>Any fields which have not been set are added with {@code null} value and
+ * {@link CarValue#STATUS_UNIMPLEMENTED}.
+ */
+ @NonNull
+ public Speed build() {
+ if (mRawSpeed == null) {
+ mRawSpeed = CarValue.UNIMPLEMENTED_FLOAT;
+ }
+ if (mDisplaySpeed == null) {
+ mDisplaySpeed = CarValue.UNIMPLEMENTED_FLOAT;
+ }
+ if (mSpeedDisplayUnit == null) {
+ mSpeedDisplayUnit = CarValue.UNIMPLEMENTED_INTEGER;
+ }
+ return new Speed(this);
+ }
+ }
+}
diff --git a/car/app/app/src/main/java/androidx/car/app/hardware/info/Toll.java b/car/app/app/src/main/java/androidx/car/app/hardware/info/Toll.java
new file mode 100644
index 0000000..17de543
--- /dev/null
+++ b/car/app/app/src/main/java/androidx/car/app/hardware/info/Toll.java
@@ -0,0 +1,169 @@
+/*
+ * Copyright 2021 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.car.app.hardware.info;
+
+import static androidx.annotation.RestrictTo.Scope.LIBRARY;
+
+import static java.util.Objects.requireNonNull;
+
+import androidx.annotation.IntDef;
+import androidx.annotation.Keep;
+import androidx.annotation.NonNull;
+import androidx.annotation.Nullable;
+import androidx.annotation.RestrictTo;
+import androidx.car.app.annotations.CarProtocol;
+import androidx.car.app.annotations.RequiresCarApi;
+import androidx.car.app.hardware.common.CarValue;
+
+import java.lang.annotation.Retention;
+import java.lang.annotation.RetentionPolicy;
+import java.util.Objects;
+
+/**
+ * Information about toll card capabilities in a car.
+ */
+@CarProtocol
+@RequiresCarApi(3)
+public final class Toll {
+
+ /**
+ * Possible toll card states.
+ *
+ * @hide
+ */
+ @IntDef({
+ TOLLCARD_STATE_UNKNOWN,
+ TOLLCARD_STATE_VALID,
+ TOLLCARD_STATE_INVALID,
+ TOLLCARD_STATE_NOT_INSERTED,
+ })
+ @Retention(RetentionPolicy.SOURCE)
+ @RestrictTo(LIBRARY)
+ public @interface State {
+ }
+
+ /**
+ * Toll card state is unknown.
+ */
+ @State
+ public static final int TOLLCARD_STATE_UNKNOWN = 0;
+
+ /**
+ * Toll card state is valid.
+ */
+ @State
+ public static final int TOLLCARD_STATE_VALID = 1;
+
+ /**
+ * Toll card state invalid.
+ *
+ * <p>On some vehicles this may be that the toll card is inserted but not valid while other
+ * vehicles might not have a toll card inserted.
+ */
+ @State
+ public static final int TOLLCARD_STATE_INVALID = 2;
+
+ /**
+ * Toll card state is not inserted.
+ *
+ * <p>Will be returned if the car hardware is able to detect that the card is not inserted.
+ */
+ @State
+ public static final int TOLLCARD_STATE_NOT_INSERTED = 3;
+
+ /** Toll card request parameters. */
+ @SuppressWarnings("PrivateConstructorForUtilityClass")
+ public static final class Params {
+ public static @NonNull Params getDefault() {
+ return new Params();
+ }
+ }
+
+ @Keep
+ @NonNull
+ private final CarValue<Integer> mCardState;
+
+ /** Returns the toll card state if available. */
+ @NonNull
+ public CarValue<Integer> getCardState() {
+ return requireNonNull(mCardState);
+ }
+
+ @Override
+ @NonNull
+ public String toString() {
+ return "[ card state: " + mCardState + "]";
+ }
+
+ @Override
+ public int hashCode() {
+ return Objects.hash(mCardState);
+ }
+
+ @Override
+ public boolean equals(@Nullable Object other) {
+ if (this == other) {
+ return true;
+ }
+ if (!(other instanceof Toll)) {
+ return false;
+ }
+ Toll otherToll = (Toll) other;
+
+ return Objects.equals(mCardState, otherToll.mCardState);
+ }
+
+ Toll(Builder builder) {
+ mCardState = requireNonNull(builder.mCardState);
+ }
+
+ /** Constructs an empty instance, used by serialization code. */
+ private Toll() {
+ mCardState = CarValue.UNIMPLEMENTED_INTEGER;
+ }
+
+ /** A builder of {@link Toll}. */
+ public static final class Builder {
+ @Nullable
+ CarValue<Integer> mCardState;
+
+ /**
+ * Sets the toll card state.
+ *
+ * @throws NullPointerException if {@code cardState} is {@code null}
+ */
+ @NonNull
+ public Builder setCardState(@NonNull CarValue<Integer> cardState) {
+ mCardState = requireNonNull(cardState);
+ return this;
+ }
+
+ /**
+ * Constructs the {@link Toll} defined by this builder.
+ *
+ * <p>Any fields which have not been set are added with {@code null} value and
+ * {@link CarValue#STATUS_UNIMPLEMENTED}.
+ */
+ @NonNull
+ public Toll build() {
+ if (mCardState == null) {
+ mCardState = CarValue.UNIMPLEMENTED_INTEGER;
+ }
+ return new Toll(this);
+ }
+
+ }
+}
diff --git a/car/app/app/src/main/java/androidx/car/app/model/CarIcon.java b/car/app/app/src/main/java/androidx/car/app/model/CarIcon.java
index 1003326..3e42b54f 100644
--- a/car/app/app/src/main/java/androidx/car/app/model/CarIcon.java
+++ b/car/app/app/src/main/java/androidx/car/app/model/CarIcon.java
@@ -51,9 +51,9 @@
* <p>Similar to Android devices, car screens cover a wide range of sizes and densities. To
* ensure that icons and images render well across all car screens, use vector assets whenever
* possible to avoid scaling issues. If your app relies on bitmaps or other non-vector
- * assets, you should ensure that you have resources that address multiple size and pixel density
- * buckets using configuration qualifiers in your resource folders (e.g. "large", "xlarge", "mdpi",
- * "hdpi", etc). See {@link androidx.car.app.CarContext} for more details.
+ * assets, you should ensure that you have resources that address multiple pixel density
+ * buckets using configuration qualifiers in your resource folders (e.g. "mdpi", "hdpi", etc).
+ * See {@link androidx.car.app.CarContext} for more details.
*
* <h4>Themed Drawables</h4>
*
diff --git a/car/app/app/src/main/java/androidx/car/app/navigation/model/RoutingInfo.java b/car/app/app/src/main/java/androidx/car/app/navigation/model/RoutingInfo.java
index 57be50d..fb829cb 100644
--- a/car/app/app/src/main/java/androidx/car/app/navigation/model/RoutingInfo.java
+++ b/car/app/app/src/main/java/androidx/car/app/navigation/model/RoutingInfo.java
@@ -162,7 +162,7 @@
*
* Images in the cue of the {@link Step} object, set with {@link Step.Builder#setCue}, can
* contain image spans. To minimize scaling artifacts across a wide range of car screens,
- * apps should provide images targeting a 250 x 83 dp bounding box. If necessary, those
+ * apps should provide images targeting a 216 x 72 dp bounding box. If necessary, those
* images in the spans will be scaled down to fit the bounding box while preserving their
* aspect ratios.
*
@@ -189,7 +189,7 @@
*
* Images in the cue of the {@link Step} object, set with {@link Step.Builder#setCue}, can
* contain image spans. To minimize scaling artifacts across a wide range of car screens,
- * apps should provide images targeting a 250 x 83 dp bounding box. If necessary, those
+ * apps should provide images targeting a 216 x 72 dp bounding box. If necessary, those
* images in the spans will be scaled down to fit the bounding box while preserving their
* aspect ratios.
*
diff --git a/car/app/app/src/main/java/androidx/car/app/versioning/CarAppApiLevels.java b/car/app/app/src/main/java/androidx/car/app/versioning/CarAppApiLevels.java
index 881a154..7accc41 100644
--- a/car/app/app/src/main/java/androidx/car/app/versioning/CarAppApiLevels.java
+++ b/car/app/app/src/main/java/androidx/car/app/versioning/CarAppApiLevels.java
@@ -31,7 +31,7 @@
/**
* API level 3.
*
- * <p>Includes a vehicle manager for access to sensors and other vehicle properties.
+ * <p>Includes a car hardware manager for access to sensors and other vehicle properties.
*/
@CarAppApiLevel
public static final int LEVEL_3 = 3;
diff --git a/car/app/app/src/test/java/androidx/car/app/CarContextTest.java b/car/app/app/src/test/java/androidx/car/app/CarContextTest.java
index 502ea8bc..e37c8c7 100644
--- a/car/app/app/src/test/java/androidx/car/app/CarContextTest.java
+++ b/car/app/app/src/test/java/androidx/car/app/CarContextTest.java
@@ -42,6 +42,7 @@
import androidx.activity.OnBackPressedCallback;
import androidx.annotation.Nullable;
+import androidx.car.app.hardware.CarHardwareManager;
import androidx.car.app.navigation.NavigationManager;
import androidx.car.app.testing.TestLifecycleOwner;
import androidx.lifecycle.Lifecycle.Event;
@@ -69,6 +70,7 @@
private static final String APP_SERVICE = "app";
private static final String NAVIGATION_SERVICE = "navigation";
private static final String SCREEN_SERVICE = "screen";
+ private static final String HARDWARE_SERVICE = "hardware";
@Mock
private ICarHost mMockCarHost;
@@ -144,6 +146,12 @@
}
@Test
+ public void getCarService_hardwareManager() {
+ assertThrows(IllegalStateException.class, () ->
+ mCarContext.getCarService(CarContext.HARDWARE_SERVICE));
+ }
+
+ @Test
public void getCarService_unknown_throws() {
assertThrows(IllegalArgumentException.class, () -> mCarContext.getCarService("foo"));
}
@@ -173,6 +181,12 @@
}
@Test
+ public void getCarServiceName_hardwareManager_throws() {
+ assertThat(mCarContext.getCarServiceName(CarHardwareManager.class)).isEqualTo(
+ HARDWARE_SERVICE);
+ }
+
+ @Test
public void getCarServiceName_unexpectedClass_throws() {
assertThrows(
IllegalArgumentException.class,
diff --git a/car/app/app/src/test/java/androidx/car/app/hardware/common/CarValueTest.java b/car/app/app/src/test/java/androidx/car/app/hardware/common/CarValueTest.java
new file mode 100644
index 0000000..7ac9981
--- /dev/null
+++ b/car/app/app/src/test/java/androidx/car/app/hardware/common/CarValueTest.java
@@ -0,0 +1,82 @@
+/*
+ * Copyright 2021 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.car.app.hardware.common;
+
+/** Tests for {@link VehicleException}. */
+
+import static com.google.common.truth.Truth.assertThat;
+
+import org.junit.Test;
+import org.junit.runner.RunWith;
+import org.robolectric.RobolectricTestRunner;
+import org.robolectric.annotation.internal.DoNotInstrument;
+
+@RunWith(RobolectricTestRunner.class)
+@DoNotInstrument
+public class CarValueTest {
+
+ @Test
+ public void createInstance() {
+ String value = "VALUE";
+ long timeStampMillis = 10;
+ int status = CarValue.STATUS_UNIMPLEMENTED;
+ CarValue<String> carValue = new CarValue<>(value, timeStampMillis, status);
+
+ assertThat(value).isEqualTo(carValue.getValue());
+ assertThat(timeStampMillis).isEqualTo(carValue.getTimestampMillis());
+ assertThat(status).isEqualTo(carValue.getStatus());
+ }
+
+ @Test
+ public void equals() {
+ String value = "VALUE";
+ long timeStampMillis = 10;
+ int status = CarValue.STATUS_UNIMPLEMENTED;
+ CarValue<String> carValue = new CarValue<>(value, timeStampMillis, status);
+ assertThat(new CarValue<>(value, timeStampMillis, status)).isEqualTo(carValue);
+ }
+
+ @Test
+ public void notEquals_differentValue() {
+ String value = "VALUE";
+ long timeStampMillis = 10;
+ int status = CarValue.STATUS_UNIMPLEMENTED;
+ CarValue<String> carValue = new CarValue<>(value, timeStampMillis, status);
+ assertThat(new CarValue<>("other", timeStampMillis, status))
+ .isNotEqualTo(carValue);
+ }
+
+ @Test
+ public void notEquals_differentTimestamp() {
+ String value = "VALUE";
+ long timeStampMillis = 10;
+ int status = CarValue.STATUS_UNIMPLEMENTED;
+ CarValue<String> carValue = new CarValue<>(value, timeStampMillis, status);
+ assertThat(new CarValue<>(value, 20, status)).isNotEqualTo(carValue);
+ }
+
+ @Test
+ public void notEquals_differentStatus() {
+ String value = "VALUE";
+ long timeStampMillis = 10;
+ int status = CarValue.STATUS_UNIMPLEMENTED;
+ CarValue<String> carValue = new CarValue<>(value, timeStampMillis, status);
+ assertThat(new CarValue<>(value, timeStampMillis,
+ CarValue.STATUS_UNAVAILABLE)).isNotEqualTo(carValue);
+ }
+
+}
diff --git a/compose/androidview/androidview/lint-baseline.xml b/compose/androidview/androidview/lint-baseline.xml
index 42a176b..f268ca37 100644
--- a/compose/androidview/androidview/lint-baseline.xml
+++ b/compose/androidview/androidview/lint-baseline.xml
@@ -1,4 +1,15 @@
<?xml version="1.0" encoding="UTF-8"?>
<issues format="6" by="lint 7.0.0-alpha15" type="baseline" client="cli" name="Lint" variant="all" version="7.0.0-alpha15">
+ <issue
+ id="BanUncheckedReflection"
+ message="Calling Method.invoke without an SDK check"
+ errorLine1=" val lp = prev ?: genDefaultLayoutParams.invoke(parent) as? ViewGroup.LayoutParams"
+ errorLine2=" ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~">
+ <location
+ file="src/main/java/androidx/compose/androidview/adapters/LayoutBuilder.kt"
+ line="96"
+ column="26"/>
+ </issue>
+
</issues>
diff --git a/compose/compiler/compiler-hosted/src/main/java/androidx/compose/compiler/plugins/kotlin/lower/ComposableSymbolRemapper.kt b/compose/compiler/compiler-hosted/src/main/java/androidx/compose/compiler/plugins/kotlin/lower/ComposableSymbolRemapper.kt
index 722fd6c..6974105 100644
--- a/compose/compiler/compiler-hosted/src/main/java/androidx/compose/compiler/plugins/kotlin/lower/ComposableSymbolRemapper.kt
+++ b/compose/compiler/compiler-hosted/src/main/java/androidx/compose/compiler/plugins/kotlin/lower/ComposableSymbolRemapper.kt
@@ -16,22 +16,20 @@
package androidx.compose.compiler.plugins.kotlin.lower
-import org.jetbrains.kotlin.ir.IrElement
-import org.jetbrains.kotlin.ir.ObsoleteDescriptorBasedAPI
-import org.jetbrains.kotlin.ir.declarations.IrConstructor
-import org.jetbrains.kotlin.ir.declarations.IrSimpleFunction
-import org.jetbrains.kotlin.ir.declarations.IrTypeParameter
-import org.jetbrains.kotlin.ir.declarations.IrValueParameter
+import androidx.compose.compiler.plugins.kotlin.hasComposableAnnotation
+import org.jetbrains.kotlin.descriptors.ClassConstructorDescriptor
+import org.jetbrains.kotlin.descriptors.FunctionDescriptor
+import org.jetbrains.kotlin.descriptors.ParameterDescriptor
+import org.jetbrains.kotlin.descriptors.TypeParameterDescriptor
+import org.jetbrains.kotlin.ir.descriptors.IrBasedDeclarationDescriptor
import org.jetbrains.kotlin.ir.util.DeepCopySymbolRemapper
import org.jetbrains.kotlin.ir.util.DescriptorsRemapper
-import org.jetbrains.kotlin.ir.visitors.IrElementVisitorVoid
-import org.jetbrains.kotlin.ir.visitors.acceptChildrenVoid
+import org.jetbrains.kotlin.types.KotlinType
/**
- * This symbol remapper is aware of possible wrapped descriptor ownership change to align
+ * This symbol remapper is aware of possible descriptor signature change to align
* function signature and descriptor signature in cases of composable value parameters.
- * As wrapped descriptors are bound to IR functions inside, we need to create a new one to change
- * the function this descriptor represents as well.
+ * It removes descriptors whenever the signature changes, forcing it to be generated from IR.
*
* E.g. when function has a signature of:
* ```
@@ -43,37 +41,51 @@
* ```
* Same applies for receiver and return types.
*
- * After remapping them, the newly created descriptors are bound back using
- * [WrappedComposableDescriptorPatcher] right after IR counterparts are created
- * (see usages in [ComposerTypeRemapper])
- *
* This conversion is only required with decoys, but can be applied to the JVM as well for
* consistency.
*/
class ComposableSymbolRemapper : DeepCopySymbolRemapper(
object : DescriptorsRemapper {
+ override fun remapDeclaredConstructor(
+ descriptor: ClassConstructorDescriptor
+ ): ClassConstructorDescriptor? =
+ descriptor.takeUnless { it.isTransformed() }
+
+ override fun remapDeclaredSimpleFunction(
+ descriptor: FunctionDescriptor
+ ): FunctionDescriptor? =
+ descriptor.takeUnless { it.isTransformed() }
+
+ override fun remapDeclaredValueParameter(
+ descriptor: ParameterDescriptor
+ ): ParameterDescriptor? =
+ descriptor.takeUnless { it.isTransformed() }
+
+ override fun remapDeclaredTypeParameter(
+ descriptor: TypeParameterDescriptor
+ ): TypeParameterDescriptor? =
+ descriptor.takeUnless { it.isTransformed() }
+
+ private fun ClassConstructorDescriptor.isTransformed(): Boolean =
+ this is IrBasedDeclarationDescriptor<*> ||
+ valueParameters.any { it.type.containsComposable() }
+
+ private fun FunctionDescriptor.isTransformed(): Boolean =
+ this is IrBasedDeclarationDescriptor<*> ||
+ valueParameters.any { it.type.containsComposable() } ||
+ returnType?.containsComposable() == true
+
+ private fun ParameterDescriptor.isTransformed(): Boolean =
+ this is IrBasedDeclarationDescriptor<*> ||
+ type.containsComposable() ||
+ containingDeclaration.let { it is FunctionDescriptor && it.isTransformed() }
+
+ private fun TypeParameterDescriptor.isTransformed(): Boolean =
+ this is IrBasedDeclarationDescriptor<*> ||
+ containingDeclaration.let { it is FunctionDescriptor && it.isTransformed() }
+
+ private fun KotlinType.containsComposable() =
+ hasComposableAnnotation() ||
+ arguments.any { it.type.hasComposableAnnotation() }
}
)
-
-@OptIn(ObsoleteDescriptorBasedAPI::class)
-object WrappedComposableDescriptorPatcher : IrElementVisitorVoid {
- override fun visitElement(element: IrElement) {
- element.acceptChildrenVoid(this)
- }
-
- override fun visitConstructor(declaration: IrConstructor) {
- super.visitConstructor(declaration)
- }
-
- override fun visitSimpleFunction(declaration: IrSimpleFunction) {
- super.visitSimpleFunction(declaration)
- }
-
- override fun visitValueParameter(declaration: IrValueParameter) {
- super.visitValueParameter(declaration)
- }
-
- override fun visitTypeParameter(declaration: IrTypeParameter) {
- super.visitTypeParameter(declaration)
- }
-}
diff --git a/compose/compiler/compiler-hosted/src/main/java/androidx/compose/compiler/plugins/kotlin/lower/ComposableTypeRemapper.kt b/compose/compiler/compiler-hosted/src/main/java/androidx/compose/compiler/plugins/kotlin/lower/ComposableTypeRemapper.kt
index b5c9461..b465f4a 100644
--- a/compose/compiler/compiler-hosted/src/main/java/androidx/compose/compiler/plugins/kotlin/lower/ComposableTypeRemapper.kt
+++ b/compose/compiler/compiler-hosted/src/main/java/androidx/compose/compiler/plugins/kotlin/lower/ComposableTypeRemapper.kt
@@ -91,8 +91,6 @@
override fun visitConstructor(declaration: IrConstructor): IrConstructor {
return super.visitConstructor(declaration).also {
- WrappedComposableDescriptorPatcher.visitConstructor(it)
-
it.copyMetadataFrom(declaration)
}
}
@@ -105,8 +103,6 @@
symbolRemapper.visitSimpleFunction(declaration)
}
return super.visitSimpleFunction(declaration).also {
- WrappedComposableDescriptorPatcher.visitSimpleFunction(it)
-
it.correspondingPropertySymbol = declaration.correspondingPropertySymbol
it.copyMetadataFrom(declaration)
}
diff --git a/compose/compiler/compiler-hosted/src/main/java/androidx/compose/compiler/plugins/kotlin/lower/ComposerParamTransformer.kt b/compose/compiler/compiler-hosted/src/main/java/androidx/compose/compiler/plugins/kotlin/lower/ComposerParamTransformer.kt
index bff6adf..72b5ecf 100644
--- a/compose/compiler/compiler-hosted/src/main/java/androidx/compose/compiler/plugins/kotlin/lower/ComposerParamTransformer.kt
+++ b/compose/compiler/compiler-hosted/src/main/java/androidx/compose/compiler/plugins/kotlin/lower/ComposerParamTransformer.kt
@@ -600,12 +600,11 @@
return isInvoke() && dispatchReceiver?.type?.hasComposableAnnotation() == true
}
- @OptIn(ObsoleteDescriptorBasedAPI::class)
private fun IrFunction.isNonComposableInlinedLambda(): Boolean {
for (element in inlinedFunctions) {
if (element.argument.function != this)
continue
- if (!element.parameter.descriptor.type.hasComposableAnnotation())
+ if (!element.parameter.type.hasComposableAnnotation())
return true
}
return false
diff --git a/compose/compiler/compiler-hosted/src/main/java/androidx/compose/compiler/plugins/kotlin/lower/decoys/DecoyTransformBase.kt b/compose/compiler/compiler-hosted/src/main/java/androidx/compose/compiler/plugins/kotlin/lower/decoys/DecoyTransformBase.kt
index cd726fb..23be234 100644
--- a/compose/compiler/compiler-hosted/src/main/java/androidx/compose/compiler/plugins/kotlin/lower/decoys/DecoyTransformBase.kt
+++ b/compose/compiler/compiler-hosted/src/main/java/androidx/compose/compiler/plugins/kotlin/lower/decoys/DecoyTransformBase.kt
@@ -21,9 +21,6 @@
import org.jetbrains.kotlin.backend.common.extensions.IrPluginContextImpl
import org.jetbrains.kotlin.backend.common.ir.isTopLevel
import org.jetbrains.kotlin.backend.common.ir.remapTypeParameters
-import org.jetbrains.kotlin.backend.common.serialization.IrModuleDeserializer
-import org.jetbrains.kotlin.backend.common.serialization.KotlinIrLinker
-import org.jetbrains.kotlin.backend.common.serialization.encodings.BinarySymbolData.SymbolKind.FUNCTION_SYMBOL
import org.jetbrains.kotlin.backend.common.serialization.signature.IdSignatureSerializer
import org.jetbrains.kotlin.descriptors.ModuleDescriptor
import org.jetbrains.kotlin.ir.IrElement
@@ -38,6 +35,7 @@
import org.jetbrains.kotlin.ir.expressions.impl.IrVarargImpl
import org.jetbrains.kotlin.ir.interpreter.toIrConst
import org.jetbrains.kotlin.ir.linkage.IrDeserializer
+import org.jetbrains.kotlin.ir.linkage.IrDeserializer.TopLevelSymbolKind.FUNCTION_SYMBOL
import org.jetbrains.kotlin.ir.symbols.IrFunctionSymbol
import org.jetbrains.kotlin.ir.symbols.IrSimpleFunctionSymbol
import org.jetbrains.kotlin.ir.symbols.IrSymbol
@@ -168,24 +166,10 @@
}
}
- // todo(KT-44100): functions generated by this plugin are not referenceable from other modules
private fun IrDeserializer.getDeclaration(
moduleDescriptor: ModuleDescriptor,
idSignature: IdSignature
- ): IrSymbol? {
- val moduleDeserializerField =
- KotlinIrLinker::class.java.getDeclaredField("deserializersForModules")
- moduleDeserializerField.isAccessible = true
-
- @Suppress("UNCHECKED_CAST")
- val moduleMap = moduleDeserializerField.get(this)
- as Map<ModuleDescriptor, IrModuleDeserializer>
- val moduleDeserializer = moduleMap[moduleDescriptor] ?: return null
-
- val symbol = moduleDeserializer.deserializeIrSymbol(idSignature, FUNCTION_SYMBOL)
- moduleDeserializer.deserializeReachableDeclarations()
- return symbol
- }
+ ): IrSymbol = resolveBySignatureInModule(idSignature, FUNCTION_SYMBOL, moduleDescriptor.name)
}
@OptIn(ObsoleteDescriptorBasedAPI::class)
diff --git a/compose/desktop/desktop/samples/src/jvmMain/kotlin/androidx/compose/desktop/examples/popupexample/AppContent.jvm.kt b/compose/desktop/desktop/samples/src/jvmMain/kotlin/androidx/compose/desktop/examples/popupexample/AppContent.jvm.kt
index dc84d26..2591678 100644
--- a/compose/desktop/desktop/samples/src/jvmMain/kotlin/androidx/compose/desktop/examples/popupexample/AppContent.jvm.kt
+++ b/compose/desktop/desktop/samples/src/jvmMain/kotlin/androidx/compose/desktop/examples/popupexample/AppContent.jvm.kt
@@ -53,12 +53,12 @@
import androidx.compose.ui.unit.IntOffset
import androidx.compose.ui.unit.IntSize
import androidx.compose.ui.unit.dp
-import androidx.compose.ui.window.Dialog
-import androidx.compose.ui.window.DialogProperties
import androidx.compose.ui.window.Notifier
import androidx.compose.ui.window.Popup
-import androidx.compose.ui.window.Tray
import androidx.compose.ui.window.WindowDraggableArea
+import androidx.compose.ui.window.v1.Dialog
+import androidx.compose.ui.window.v1.DialogProperties
+import androidx.compose.ui.window.v1.Tray
import java.awt.Toolkit
import java.awt.event.ActionEvent
import java.awt.event.ActionListener
diff --git a/compose/desktop/desktop/samples/src/jvmMain/kotlin/androidx/compose/desktop/examples/popupexample/Main.jvm.kt b/compose/desktop/desktop/samples/src/jvmMain/kotlin/androidx/compose/desktop/examples/popupexample/Main.jvm.kt
index 0ace057..fd8dd5c 100644
--- a/compose/desktop/desktop/samples/src/jvmMain/kotlin/androidx/compose/desktop/examples/popupexample/Main.jvm.kt
+++ b/compose/desktop/desktop/samples/src/jvmMain/kotlin/androidx/compose/desktop/examples/popupexample/Main.jvm.kt
@@ -21,8 +21,8 @@
import androidx.compose.runtime.CompositionLocalProvider
import androidx.compose.ui.unit.IntOffset
import androidx.compose.ui.unit.IntSize
-import androidx.compose.ui.window.Menu
-import androidx.compose.ui.window.MenuBar
+import androidx.compose.ui.window.v1.Menu
+import androidx.compose.ui.window.v1.MenuBar
import javax.swing.SwingUtilities
fun main() = SwingUtilities.invokeLater {
diff --git a/compose/desktop/desktop/samples/src/jvmMain/kotlin/androidx/compose/desktop/examples/popupexample/MenuItems.jvm.kt b/compose/desktop/desktop/samples/src/jvmMain/kotlin/androidx/compose/desktop/examples/popupexample/MenuItems.jvm.kt
index e43c1d2..54c7476 100644
--- a/compose/desktop/desktop/samples/src/jvmMain/kotlin/androidx/compose/desktop/examples/popupexample/MenuItems.jvm.kt
+++ b/compose/desktop/desktop/samples/src/jvmMain/kotlin/androidx/compose/desktop/examples/popupexample/MenuItems.jvm.kt
@@ -17,9 +17,9 @@
import androidx.compose.desktop.AppManager
import androidx.compose.ui.input.key.Key
-import androidx.compose.ui.window.MenuItem
-import androidx.compose.ui.window.KeyStroke
import androidx.compose.ui.window.Notifier
+import androidx.compose.ui.window.v1.KeyStroke
+import androidx.compose.ui.window.v1.MenuItem
object MenuItems {
val Exit = MenuItem(
diff --git a/compose/foundation/foundation/integration-tests/foundation-demos/src/main/java/androidx/compose/foundation/demos/text/ComposeTextSelection.kt b/compose/foundation/foundation/integration-tests/foundation-demos/src/main/java/androidx/compose/foundation/demos/text/ComposeTextSelection.kt
index 637e42cc..f3b8f16 100644
--- a/compose/foundation/foundation/integration-tests/foundation-demos/src/main/java/androidx/compose/foundation/demos/text/ComposeTextSelection.kt
+++ b/compose/foundation/foundation/integration-tests/foundation-demos/src/main/java/androidx/compose/foundation/demos/text/ComposeTextSelection.kt
@@ -16,10 +16,13 @@
package androidx.compose.foundation.demos.text
+import androidx.compose.foundation.BorderStroke
+import androidx.compose.foundation.border
import androidx.compose.foundation.layout.Column
import androidx.compose.foundation.layout.Row
import androidx.compose.foundation.layout.fillMaxHeight
import androidx.compose.foundation.layout.fillMaxWidth
+import androidx.compose.foundation.layout.height
import androidx.compose.foundation.lazy.LazyColumn
import androidx.compose.material.Text
import androidx.compose.runtime.Composable
@@ -34,6 +37,7 @@
import androidx.compose.ui.text.font.FontWeight
import androidx.compose.ui.text.intl.LocaleList
import androidx.compose.ui.text.withStyle
+import androidx.compose.ui.unit.dp
@Composable
fun TextSelectionDemo() {
@@ -54,6 +58,20 @@
TagLine(tag = "enable and disable selection")
TextDemoSelectionEnableAndDisable()
}
+ item {
+ TagLine(tag = "fix crashing of longpress in the blank area")
+ SelectionContainer {
+ Text(
+ text = "Hello World\nHello",
+ modifier = Modifier.fillMaxWidth()
+ .border(BorderStroke(1.dp, color = Color.Black))
+ .height(80.dp)
+ )
+ }
+ }
+ item {
+ TagLine(tag = "")
+ }
}
}
diff --git a/compose/foundation/foundation/src/androidAndroidTest/kotlin/androidx/compose/foundation/lazy/LazyColumnTest.kt b/compose/foundation/foundation/src/androidAndroidTest/kotlin/androidx/compose/foundation/lazy/LazyColumnTest.kt
index 5803e10..dcbbe84 100644
--- a/compose/foundation/foundation/src/androidAndroidTest/kotlin/androidx/compose/foundation/lazy/LazyColumnTest.kt
+++ b/compose/foundation/foundation/src/androidAndroidTest/kotlin/androidx/compose/foundation/lazy/LazyColumnTest.kt
@@ -1474,6 +1474,65 @@
)
}
+ @Test
+ fun initialScrollPositionIsCorrectWhenItemsAreLoadedAsynchronously() {
+ lateinit var state: LazyListState
+ var itemsCount by mutableStateOf(0)
+ rule.setContent {
+ state = rememberLazyListState(2, 10)
+ LazyColumn(Modifier.fillMaxSize(), state) {
+ items(itemsCount) {
+ Box(Modifier.size(20.dp))
+ }
+ }
+ }
+
+ rule.runOnIdle {
+ itemsCount = 100
+ }
+
+ rule.runOnIdle {
+ assertThat(state.firstVisibleItemIndex).isEqualTo(2)
+ assertThat(state.firstVisibleItemScrollOffset).isEqualTo(10)
+ }
+ }
+
+ @Test
+ fun restoredScrollPositionIsCorrectWhenItemsAreLoadedAsynchronously() {
+ lateinit var state: LazyListState
+ var itemsCount = 100
+ val recomposeCounter = mutableStateOf(0)
+ val tester = StateRestorationTester(rule)
+ tester.setContent {
+ state = rememberLazyListState()
+ LazyColumn(Modifier.fillMaxSize(), state) {
+ recomposeCounter.value
+ items(itemsCount) {
+ Box(Modifier.size(20.dp))
+ }
+ }
+ }
+
+ rule.runOnIdle {
+ runBlocking {
+ state.scrollToItem(2, 10)
+ }
+ itemsCount = 0
+ }
+
+ tester.emulateSavedInstanceStateRestore()
+
+ rule.runOnIdle {
+ itemsCount = 100
+ recomposeCounter.value = 1
+ }
+
+ rule.runOnIdle {
+ assertThat(state.firstVisibleItemIndex).isEqualTo(2)
+ assertThat(state.firstVisibleItemScrollOffset).isEqualTo(10)
+ }
+ }
+
private fun SemanticsNodeInteraction.assertTopPositionIsAlmost(expected: Dp) {
getUnclippedBoundsInRoot().top.assertIsEqualTo(expected, tolerance = 1.dp)
}
diff --git a/compose/foundation/foundation/src/androidAndroidTest/kotlin/androidx/compose/foundation/lazy/LazyRowTest.kt b/compose/foundation/foundation/src/androidAndroidTest/kotlin/androidx/compose/foundation/lazy/LazyRowTest.kt
index e2b6fc5..9ad18ab 100644
--- a/compose/foundation/foundation/src/androidAndroidTest/kotlin/androidx/compose/foundation/lazy/LazyRowTest.kt
+++ b/compose/foundation/foundation/src/androidAndroidTest/kotlin/androidx/compose/foundation/lazy/LazyRowTest.kt
@@ -1169,6 +1169,65 @@
)
}
+ @Test
+ fun initialScrollPositionIsCorrectWhenItemsAreLoadedAsynchronously() {
+ lateinit var state: LazyListState
+ var itemsCount by mutableStateOf(0)
+ rule.setContent {
+ state = rememberLazyListState(2, 10)
+ LazyRow(Modifier.fillMaxSize(), state) {
+ items(itemsCount) {
+ Box(Modifier.size(20.dp))
+ }
+ }
+ }
+
+ rule.runOnIdle {
+ itemsCount = 100
+ }
+
+ rule.runOnIdle {
+ assertThat(state.firstVisibleItemIndex).isEqualTo(2)
+ assertThat(state.firstVisibleItemScrollOffset).isEqualTo(10)
+ }
+ }
+
+ @Test
+ fun restoredScrollPositionIsCorrectWhenItemsAreLoadedAsynchronously() {
+ lateinit var state: LazyListState
+ var itemsCount = 100
+ val recomposeCounter = mutableStateOf(0)
+ val tester = StateRestorationTester(rule)
+ tester.setContent {
+ state = rememberLazyListState()
+ LazyRow(Modifier.fillMaxSize(), state) {
+ recomposeCounter.value
+ items(itemsCount) {
+ Box(Modifier.size(20.dp))
+ }
+ }
+ }
+
+ rule.runOnIdle {
+ runBlocking {
+ state.scrollToItem(2, 10)
+ }
+ itemsCount = 0
+ }
+
+ tester.emulateSavedInstanceStateRestore()
+
+ rule.runOnIdle {
+ itemsCount = 100
+ recomposeCounter.value = 1
+ }
+
+ rule.runOnIdle {
+ assertThat(state.firstVisibleItemIndex).isEqualTo(2)
+ assertThat(state.firstVisibleItemScrollOffset).isEqualTo(10)
+ }
+ }
+
private fun LazyListState.scrollBy(offset: Dp) {
runBlocking(Dispatchers.Main + AutoTestFrameClock()) {
animateScrollBy(with(rule.density) { offset.roundToPx().toFloat() }, snap())
diff --git a/compose/foundation/foundation/src/androidAndroidTest/kotlin/androidx/compose/foundation/shape/CornerBasedShapeTest.kt b/compose/foundation/foundation/src/androidAndroidTest/kotlin/androidx/compose/foundation/shape/CornerBasedShapeTest.kt
index 00401f3..58285ba 100644
--- a/compose/foundation/foundation/src/androidAndroidTest/kotlin/androidx/compose/foundation/shape/CornerBasedShapeTest.kt
+++ b/compose/foundation/foundation/src/androidAndroidTest/kotlin/androidx/compose/foundation/shape/CornerBasedShapeTest.kt
@@ -88,44 +88,9 @@
val impl = Impl(
topStart = CornerSize(10.0f),
- topEnd = CornerSize(6.dp),
- bottomEnd = CornerSize(1.0f),
- bottomStart = CornerSize(2.0f),
- onOutlineRequested = assertSizes
- )
-
- impl.createOutline(sizeWithLargerWidth, LayoutDirection.Ltr, density)
- impl.createOutline(sizeWithLargerHeight, LayoutDirection.Ltr, density)
-
- assertThat(sizesList).isEqualTo(mutableListOf(sizeWithLargerWidth, sizeWithLargerHeight))
- }
-
- @Test
- fun largerBottomCornersUseRemainingFromMinDimensionSize() {
- val density = Density(2f, 1f)
- val sizeWithLargerWidth = Size(6.0f, 4.0f)
- val sizeWithLargerHeight = Size(4.0f, 6.0f)
-
- val sizesList = mutableListOf<Size>()
- val assertSizes = { size: Size,
- topStart: Float,
- topEnd: Float,
- bottomEnd: Float,
- bottomStart: Float,
- ld: LayoutDirection ->
- sizesList.add(size)
- assertThat(topStart).isEqualTo(1.0f)
- assertThat(topEnd).isEqualTo(1.0f)
- assertThat(bottomEnd).isEqualTo(3.0f)
- assertThat(bottomStart).isEqualTo(3.0f)
- assertThat(ld).isEqualTo(LayoutDirection.Ltr)
- }
-
- val impl = Impl(
- topStart = CornerSize(1.0f),
- topEnd = CornerSize(0.5f.dp),
- bottomEnd = CornerSize(10f),
- bottomStart = CornerSize(100),
+ topEnd = CornerSize(10.0f),
+ bottomEnd = CornerSize(0f),
+ bottomStart = CornerSize(0f),
onOutlineRequested = assertSizes
)
@@ -221,6 +186,76 @@
assertThat(assertionExecuted).isTrue()
}
+
+ @Test
+ fun overSizedEqualCornerSizes() {
+ val density = Density(2f, 1f)
+ val sizeWithLargerWidth = Size(6.0f, 4.0f)
+ val sizeWithLargerHeight = Size(4.0f, 6.0f)
+
+ val sizesList = mutableListOf<Size>()
+ val assertSizes = { size: Size,
+ topStart: Float,
+ topEnd: Float,
+ bottomEnd: Float,
+ bottomStart: Float,
+ ld: LayoutDirection ->
+ sizesList.add(size)
+ assertThat(topStart).isEqualTo(2.0f)
+ assertThat(topEnd).isEqualTo(2.0f)
+ assertThat(bottomEnd).isEqualTo(2.0f)
+ assertThat(bottomStart).isEqualTo(2.0f)
+ assertThat(ld).isEqualTo(LayoutDirection.Ltr)
+ }
+
+ val impl = Impl(
+ topStart = CornerSize(75),
+ topEnd = CornerSize(75),
+ bottomEnd = CornerSize(75),
+ bottomStart = CornerSize(75),
+ onOutlineRequested = assertSizes
+ )
+
+ impl.createOutline(sizeWithLargerWidth, LayoutDirection.Ltr, density)
+ impl.createOutline(sizeWithLargerHeight, LayoutDirection.Ltr, density)
+
+ assertThat(sizesList).isEqualTo(mutableListOf(sizeWithLargerWidth, sizeWithLargerHeight))
+ }
+
+ @Test
+ fun overSizedCornerSizesShouldProportionallyScale() {
+ val density = Density(2f, 1f)
+ val sizeWithLargerWidth = Size(15.0f, 10.0f)
+ val sizeWithLargerHeight = Size(10.0f, 15.0f)
+
+ val sizesList = mutableListOf<Size>()
+ val assertSizes = { size: Size,
+ topStart: Float,
+ topEnd: Float,
+ bottomEnd: Float,
+ bottomStart: Float,
+ ld: LayoutDirection ->
+ sizesList.add(size)
+ assertThat(topStart).isEqualTo(7.5f)
+ assertThat(topEnd).isEqualTo(2.5f)
+ assertThat(bottomEnd).isEqualTo(7.5f)
+ assertThat(bottomStart).isEqualTo(2.5f)
+ assertThat(ld).isEqualTo(LayoutDirection.Ltr)
+ }
+
+ val impl = Impl(
+ topStart = CornerSize(90),
+ topEnd = CornerSize(30),
+ bottomEnd = CornerSize(90),
+ bottomStart = CornerSize(30),
+ onOutlineRequested = assertSizes
+ )
+
+ impl.createOutline(sizeWithLargerWidth, LayoutDirection.Ltr, density)
+ impl.createOutline(sizeWithLargerHeight, LayoutDirection.Ltr, density)
+
+ assertThat(sizesList).isEqualTo(mutableListOf(sizeWithLargerWidth, sizeWithLargerHeight))
+ }
}
private class Impl(
diff --git a/compose/foundation/foundation/src/androidAndroidTest/kotlin/androidx/compose/foundation/text/selection/SelectionHandlePopupPositionTest.kt b/compose/foundation/foundation/src/androidAndroidTest/kotlin/androidx/compose/foundation/text/selection/SelectionHandlePopupPositionTest.kt
index 5141592..df97ada 100644
--- a/compose/foundation/foundation/src/androidAndroidTest/kotlin/androidx/compose/foundation/text/selection/SelectionHandlePopupPositionTest.kt
+++ b/compose/foundation/foundation/src/androidAndroidTest/kotlin/androidx/compose/foundation/text/selection/SelectionHandlePopupPositionTest.kt
@@ -187,7 +187,7 @@
modifier = Modifier.onGloballyPositioned {
measureLatch.countDown()
},
- handle = null
+ content = null
)
}
}
diff --git a/compose/foundation/foundation/src/androidMain/kotlin/androidx/compose/foundation/text/selection/AndroidSelectionHandles.android.kt b/compose/foundation/foundation/src/androidMain/kotlin/androidx/compose/foundation/text/selection/AndroidSelectionHandles.android.kt
index 1eb2594..db0f0f6 100644
--- a/compose/foundation/foundation/src/androidMain/kotlin/androidx/compose/foundation/text/selection/AndroidSelectionHandles.android.kt
+++ b/compose/foundation/foundation/src/androidMain/kotlin/androidx/compose/foundation/text/selection/AndroidSelectionHandles.android.kt
@@ -47,7 +47,7 @@
directions: Pair<ResolvedTextDirection, ResolvedTextDirection>,
handlesCrossed: Boolean,
modifier: Modifier,
- handle: (@Composable () -> Unit)?
+ content: @Composable (() -> Unit)?
) {
SelectionHandlePopup(
startHandlePosition = startHandlePosition,
@@ -56,14 +56,14 @@
directions = directions,
handlesCrossed = handlesCrossed
) {
- if (handle == null) {
+ if (content == null) {
DefaultSelectionHandle(
modifier = modifier,
isStartHandle = isStartHandle,
directions = directions,
handlesCrossed = handlesCrossed
)
- } else handle()
+ } else content()
}
}
diff --git a/compose/foundation/foundation/src/commonMain/kotlin/androidx/compose/foundation/lazy/LazyListState.kt b/compose/foundation/foundation/src/commonMain/kotlin/androidx/compose/foundation/lazy/LazyListState.kt
index 082c787..f592586 100644
--- a/compose/foundation/foundation/src/commonMain/kotlin/androidx/compose/foundation/lazy/LazyListState.kt
+++ b/compose/foundation/foundation/src/commonMain/kotlin/androidx/compose/foundation/lazy/LazyListState.kt
@@ -182,12 +182,7 @@
}
internal fun snapToItemIndexInternal(index: Int, scrollOffset: Int) {
- scrollPosition.update(
- index = DataIndex(index),
- scrollOffset = scrollOffset,
- // `true` will be replaced with the real value during the forceRemeasure() execution
- canScrollForward = true
- )
+ scrollPosition.update(DataIndex(index), scrollOffset)
remeasurement.forceRemeasure()
}
@@ -275,11 +270,7 @@
* Updates the state with the new calculated scroll position and consumed scroll.
*/
internal fun applyMeasureResult(measureResult: LazyListMeasureResult) {
- scrollPosition.update(
- index = measureResult.firstVisibleItemIndex,
- scrollOffset = measureResult.firstVisibleItemScrollOffset,
- canScrollForward = measureResult.canScrollForward
- )
+ scrollPosition.update(measureResult)
lastVisibleItemIndexNonObservable = DataIndex(
measureResult.visibleItemsInfo.lastOrNull()?.index ?: 0
)
@@ -335,11 +326,27 @@
private val scrollOffsetState = mutableStateOf(scrollOffset)
val observableScrollOffset get() = scrollOffsetState.value
- val canScrollBackward: Boolean get() = index.value != 0 || scrollOffset != 0
+ var canScrollBackward: Boolean = false
+ private set
var canScrollForward: Boolean = false
private set
- fun update(index: DataIndex, scrollOffset: Int, canScrollForward: Boolean) {
+ private var hadFirstNotEmptyLayout = false
+
+ fun update(measureResult: LazyListMeasureResult) {
+ // we ignore the index and offset from measureResult until we get at least one
+ // measurement with real items. otherwise the initial index and scroll passed to the
+ // state would be lost and overridden with zeros.
+ if (hadFirstNotEmptyLayout || measureResult.totalItemsCount > 0) {
+ hadFirstNotEmptyLayout = true
+ update(measureResult.firstVisibleItemIndex, measureResult.firstVisibleItemScrollOffset)
+ }
+ this.canScrollForward = measureResult.canScrollForward
+ this.canScrollBackward = measureResult.firstVisibleItemIndex.value != 0 ||
+ measureResult.firstVisibleItemScrollOffset != 0
+ }
+
+ fun update(index: DataIndex, scrollOffset: Int) {
require(index.value >= 0f) { "Index should be non-negative (${index.value})" }
require(scrollOffset >= 0f) { "scrollOffset should be non-negative ($scrollOffset)" }
if (index != this.index) {
@@ -350,7 +357,6 @@
this.scrollOffset = scrollOffset
scrollOffsetState.value = scrollOffset
}
- this.canScrollForward = canScrollForward
}
}
diff --git a/compose/foundation/foundation/src/commonMain/kotlin/androidx/compose/foundation/shape/CornerBasedShape.kt b/compose/foundation/foundation/src/commonMain/kotlin/androidx/compose/foundation/shape/CornerBasedShape.kt
index 2792bb6..710e524 100644
--- a/compose/foundation/foundation/src/commonMain/kotlin/androidx/compose/foundation/shape/CornerBasedShape.kt
+++ b/compose/foundation/foundation/src/commonMain/kotlin/androidx/compose/foundation/shape/CornerBasedShape.kt
@@ -21,7 +21,6 @@
import androidx.compose.ui.graphics.Shape
import androidx.compose.ui.unit.Density
import androidx.compose.ui.unit.LayoutDirection
-import kotlin.math.min
/**
* Base class for [Shape]s defined by four [CornerSize]s.
@@ -45,11 +44,21 @@
layoutDirection: LayoutDirection,
density: Density
): Outline {
+ var topStart = topStart.toPx(size, density)
+ var topEnd = topEnd.toPx(size, density)
+ var bottomEnd = bottomEnd.toPx(size, density)
+ var bottomStart = bottomStart.toPx(size, density)
val minDimension = size.minDimension
- val topStart = min(topStart.toPx(size, density), minDimension)
- val topEnd = min(topEnd.toPx(size, density), minDimension)
- val bottomEnd = min(bottomEnd.toPx(size, density), minDimension - topEnd)
- val bottomStart = min(bottomStart.toPx(size, density), minDimension - topStart)
+ if (topStart + bottomStart > minDimension) {
+ val scale = minDimension / (topStart + bottomStart)
+ topStart *= scale
+ bottomStart *= scale
+ }
+ if (topEnd + bottomEnd > minDimension) {
+ val scale = minDimension / (topEnd + bottomEnd)
+ topEnd *= scale
+ bottomEnd *= scale
+ }
require(topStart >= 0.0f && topEnd >= 0.0f && bottomEnd >= 0.0f && bottomStart >= 0.0f) {
"Corner size in Px can't be negative(topStart = $topStart, topEnd = $topEnd, " +
"bottomEnd = $bottomEnd, bottomStart = $bottomStart)!"
diff --git a/compose/foundation/foundation/src/commonMain/kotlin/androidx/compose/foundation/text/CoreText.kt b/compose/foundation/foundation/src/commonMain/kotlin/androidx/compose/foundation/text/CoreText.kt
index c0c452c..4d4e184 100644
--- a/compose/foundation/foundation/src/commonMain/kotlin/androidx/compose/foundation/text/CoreText.kt
+++ b/compose/foundation/foundation/src/commonMain/kotlin/androidx/compose/foundation/text/CoreText.kt
@@ -372,11 +372,17 @@
state.layoutCoordinates?.let {
if (!it.isAttached) return
- selectionRegistrar?.notifySelectionUpdateStart(
- layoutCoordinates = it,
- startPosition = startPoint,
- adjustment = SelectionAdjustment.WORD
- )
+ if (outOfBoundary(startPoint, startPoint)) {
+ selectionRegistrar?.notifySelectionUpdateSelectAll(
+ selectableId = state.selectableId
+ )
+ } else {
+ selectionRegistrar?.notifySelectionUpdateStart(
+ layoutCoordinates = it,
+ startPosition = startPoint,
+ adjustment = SelectionAdjustment.WORD
+ )
+ }
dragBeginPosition = startPoint
}
@@ -394,12 +400,14 @@
dragTotalDistance += delta
- selectionRegistrar?.notifySelectionUpdate(
- layoutCoordinates = it,
- startPosition = dragBeginPosition,
- endPosition = dragBeginPosition + dragTotalDistance,
- adjustment = SelectionAdjustment.CHARACTER
- )
+ if (!outOfBoundary(dragBeginPosition, dragBeginPosition + dragTotalDistance)) {
+ selectionRegistrar?.notifySelectionUpdate(
+ layoutCoordinates = it,
+ startPosition = dragBeginPosition,
+ endPosition = dragBeginPosition + dragTotalDistance,
+ adjustment = SelectionAdjustment.CHARACTER
+ )
+ }
}
}
@@ -484,6 +492,18 @@
}
}
+ private fun outOfBoundary(start: Offset, end: Offset): Boolean {
+ state.layoutResult?.let {
+ val lastOffset = it.layoutInput.text.text.length
+ val rawStartOffset = it.getOffsetForPosition(start)
+ val rawEndOffset = it.getOffsetForPosition(end)
+
+ return rawStartOffset >= lastOffset - 1 && rawEndOffset >= lastOffset - 1 ||
+ rawStartOffset < 0 && rawEndOffset < 0
+ }
+ return false
+ }
+
/**
* Draw the given selection on the canvas.
*/
diff --git a/compose/foundation/foundation/src/commonMain/kotlin/androidx/compose/foundation/text/selection/MultiWidgetSelectionDelegate.kt b/compose/foundation/foundation/src/commonMain/kotlin/androidx/compose/foundation/text/selection/MultiWidgetSelectionDelegate.kt
index 84c367d..eb1704b 100644
--- a/compose/foundation/foundation/src/commonMain/kotlin/androidx/compose/foundation/text/selection/MultiWidgetSelectionDelegate.kt
+++ b/compose/foundation/foundation/src/commonMain/kotlin/androidx/compose/foundation/text/selection/MultiWidgetSelectionDelegate.kt
@@ -57,6 +57,18 @@
)
}
+ override fun getSelectAllSelection(): Selection? {
+ val textLayoutResult = layoutResultCallback() ?: return null
+
+ return getAssembledSelectionInfo(
+ startOffset = 0,
+ endOffset = textLayoutResult.layoutInput.text.length,
+ handlesCrossed = false,
+ selectableId = selectableId,
+ textLayoutResult = textLayoutResult
+ )
+ }
+
override fun getHandlePosition(selection: Selection, isStartHandle: Boolean): Offset {
// Check if the selection handles's selectable is the current selectable.
if (isStartHandle && selection.start.selectableId != this.selectableId ||
diff --git a/compose/foundation/foundation/src/commonMain/kotlin/androidx/compose/foundation/text/selection/Selectable.kt b/compose/foundation/foundation/src/commonMain/kotlin/androidx/compose/foundation/text/selection/Selectable.kt
index 0e33360..ebad9c2 100644
--- a/compose/foundation/foundation/src/commonMain/kotlin/androidx/compose/foundation/text/selection/Selectable.kt
+++ b/compose/foundation/foundation/src/commonMain/kotlin/androidx/compose/foundation/text/selection/Selectable.kt
@@ -60,6 +60,15 @@
): Selection?
/**
+ * Returns selectAll [Selection] information for a selectable composable. If no selection can be
+ * provided null should be returned.
+ *
+ * @return selectAll [Selection] information for a selectable composable. If no selection can be
+ * provided null should be returned.
+ */
+ fun getSelectAllSelection(): Selection?
+
+ /**
* Return the [Offset] of a [SelectionHandle].
*
* @param selection [Selection] contains the [SelectionHandle]
diff --git a/compose/foundation/foundation/src/commonMain/kotlin/androidx/compose/foundation/text/selection/SelectionContainer.kt b/compose/foundation/foundation/src/commonMain/kotlin/androidx/compose/foundation/text/selection/SelectionContainer.kt
index d3da4b5..da2315f 100644
--- a/compose/foundation/foundation/src/commonMain/kotlin/androidx/compose/foundation/text/selection/SelectionContainer.kt
+++ b/compose/foundation/foundation/src/commonMain/kotlin/androidx/compose/foundation/text/selection/SelectionContainer.kt
@@ -113,7 +113,7 @@
modifier = Modifier.pointerInput(observer) {
detectDragGesturesWithObserver(observer)
},
- handle = null
+ content = null
)
}
}
diff --git a/compose/foundation/foundation/src/commonMain/kotlin/androidx/compose/foundation/text/selection/SelectionHandles.kt b/compose/foundation/foundation/src/commonMain/kotlin/androidx/compose/foundation/text/selection/SelectionHandles.kt
index 390eecd..245e720 100644
--- a/compose/foundation/foundation/src/commonMain/kotlin/androidx/compose/foundation/text/selection/SelectionHandles.kt
+++ b/compose/foundation/foundation/src/commonMain/kotlin/androidx/compose/foundation/text/selection/SelectionHandles.kt
@@ -33,7 +33,7 @@
directions: Pair<ResolvedTextDirection, ResolvedTextDirection>,
handlesCrossed: Boolean,
modifier: Modifier,
- handle: (@Composable () -> Unit)?
+ content: @Composable (() -> Unit)?
)
/**
diff --git a/compose/foundation/foundation/src/commonMain/kotlin/androidx/compose/foundation/text/selection/SelectionManager.kt b/compose/foundation/foundation/src/commonMain/kotlin/androidx/compose/foundation/text/selection/SelectionManager.kt
index 25e8c89..1774fd4 100644
--- a/compose/foundation/foundation/src/commonMain/kotlin/androidx/compose/foundation/text/selection/SelectionManager.kt
+++ b/compose/foundation/foundation/src/commonMain/kotlin/androidx/compose/foundation/text/selection/SelectionManager.kt
@@ -203,6 +203,21 @@
hideSelectionToolbar()
}
+ selectionRegistrar.onSelectionUpdateSelectAll =
+ { selectableId ->
+ val (newSelection, newSubselection) = mergeSelections(
+ selectableId = selectableId,
+ previousSelection = selection,
+ )
+ if (newSelection != selection) {
+ selectionRegistrar.subselections = newSubselection
+ onSelectionChange(newSelection)
+ }
+
+ focusRequester.requestFocus()
+ hideSelectionToolbar()
+ }
+
selectionRegistrar.onSelectionUpdateCallback =
{ layoutCoordinates, startPosition, endPosition, selectionMode ->
val startPositionOrCurrent = if (startPosition == null) {
@@ -356,6 +371,24 @@
return Pair(newSelection, subselections)
}
+ internal fun mergeSelections(
+ previousSelection: Selection? = null,
+ selectableId: Long
+ ): Pair<Selection?, Map<Long, Selection>> {
+ val subselections = mutableMapOf<Long, Selection>()
+ val newSelection = selectionRegistrar.sort(requireContainerCoordinates())
+ .fastFold(null) { mergedSelection: Selection?, selectable: Selectable ->
+ val selection = if (selectable.selectableId == selectableId)
+ selectable.getSelectAllSelection() else null
+ selection?.let { subselections[selectable.selectableId] = it }
+ merge(mergedSelection, selection)
+ }
+ if (previousSelection != newSelection) hapticFeedBack?.performHapticFeedback(
+ HapticFeedbackType.TextHandleMove
+ )
+ return Pair(newSelection, subselections)
+ }
+
internal fun getSelectedText(): AnnotatedString? {
val selectables = selectionRegistrar.sort(requireContainerCoordinates())
var selectedText: AnnotatedString? = null
diff --git a/compose/foundation/foundation/src/commonMain/kotlin/androidx/compose/foundation/text/selection/SelectionRegistrar.kt b/compose/foundation/foundation/src/commonMain/kotlin/androidx/compose/foundation/text/selection/SelectionRegistrar.kt
index f9bc6af..554371a 100644
--- a/compose/foundation/foundation/src/commonMain/kotlin/androidx/compose/foundation/text/selection/SelectionRegistrar.kt
+++ b/compose/foundation/foundation/src/commonMain/kotlin/androidx/compose/foundation/text/selection/SelectionRegistrar.kt
@@ -97,6 +97,14 @@
)
/**
+ * Call this method to notify the [SelectionContainer] that the selection has been initiated
+ * with selectAll [Selection].
+ *
+ * @param selectableId [selectableId] of the [Selectable]
+ */
+ fun notifySelectionUpdateSelectAll(selectableId: Long)
+
+ /**
* Call this method to notify the [SelectionContainer] that the selection has been updated.
* The caller of this method should make sure that [notifySelectionUpdateStart] is always
* called once before calling this function. And [notifySelectionUpdateEnd] is always called
diff --git a/compose/foundation/foundation/src/commonMain/kotlin/androidx/compose/foundation/text/selection/SelectionRegistrarImpl.kt b/compose/foundation/foundation/src/commonMain/kotlin/androidx/compose/foundation/text/selection/SelectionRegistrarImpl.kt
index 143361f..7aea413 100644
--- a/compose/foundation/foundation/src/commonMain/kotlin/androidx/compose/foundation/text/selection/SelectionRegistrarImpl.kt
+++ b/compose/foundation/foundation/src/commonMain/kotlin/androidx/compose/foundation/text/selection/SelectionRegistrarImpl.kt
@@ -69,6 +69,13 @@
)? = null
/**
+ * The callback to be invoked when the selection is initiated with selectAll [Selection].
+ */
+ internal var onSelectionUpdateSelectAll: (
+ (Long) -> Unit
+ )? = null
+
+ /**
* The callback to be invoked when the selection is updated.
* If the first offset is null it means that the start of selection is unknown for the caller.
*/
@@ -170,6 +177,10 @@
onSelectionUpdateStartCallback?.invoke(layoutCoordinates, startPosition, adjustment)
}
+ override fun notifySelectionUpdateSelectAll(selectableId: Long) {
+ onSelectionUpdateSelectAll?.invoke(selectableId)
+ }
+
override fun notifySelectionUpdate(
layoutCoordinates: LayoutCoordinates,
endPosition: Offset,
diff --git a/compose/foundation/foundation/src/commonMain/kotlin/androidx/compose/foundation/text/selection/TextFieldSelectionManager.kt b/compose/foundation/foundation/src/commonMain/kotlin/androidx/compose/foundation/text/selection/TextFieldSelectionManager.kt
index f5394fd..ef98a61 100644
--- a/compose/foundation/foundation/src/commonMain/kotlin/androidx/compose/foundation/text/selection/TextFieldSelectionManager.kt
+++ b/compose/foundation/foundation/src/commonMain/kotlin/androidx/compose/foundation/text/selection/TextFieldSelectionManager.kt
@@ -682,7 +682,7 @@
modifier = Modifier.pointerInput(observer) {
detectDragGesturesWithObserver(observer)
},
- handle = null
+ content = null
)
}
diff --git a/compose/foundation/foundation/src/desktopMain/kotlin/androidx/compose/foundation/text/selection/DesktopSelectionHandles.desktop.kt b/compose/foundation/foundation/src/desktopMain/kotlin/androidx/compose/foundation/text/selection/DesktopSelectionHandles.desktop.kt
index 06ab86b..e93a15e 100644
--- a/compose/foundation/foundation/src/desktopMain/kotlin/androidx/compose/foundation/text/selection/DesktopSelectionHandles.desktop.kt
+++ b/compose/foundation/foundation/src/desktopMain/kotlin/androidx/compose/foundation/text/selection/DesktopSelectionHandles.desktop.kt
@@ -29,7 +29,7 @@
directions: Pair<ResolvedTextDirection, ResolvedTextDirection>,
handlesCrossed: Boolean,
modifier: Modifier,
- handle: (@Composable () -> Unit)?
+ content: (@Composable () -> Unit)?
) {
// TODO
}
\ No newline at end of file
diff --git a/compose/foundation/foundation/src/test/kotlin/androidx/compose/foundation/text/TextSelectionLongPressDragTest.kt b/compose/foundation/foundation/src/test/kotlin/androidx/compose/foundation/text/TextSelectionLongPressDragTest.kt
index 0444795..9c742d1 100644
--- a/compose/foundation/foundation/src/test/kotlin/androidx/compose/foundation/text/TextSelectionLongPressDragTest.kt
+++ b/compose/foundation/foundation/src/test/kotlin/androidx/compose/foundation/text/TextSelectionLongPressDragTest.kt
@@ -22,7 +22,16 @@
import androidx.compose.foundation.text.selection.SelectionRegistrarImpl
import androidx.compose.ui.geometry.Offset
import androidx.compose.ui.layout.LayoutCoordinates
+import androidx.compose.ui.text.AnnotatedString
+import androidx.compose.ui.text.TextLayoutInput
+import androidx.compose.ui.text.TextLayoutResult
+import androidx.compose.ui.text.TextStyle
import androidx.compose.ui.text.style.ResolvedTextDirection
+import androidx.compose.ui.text.style.TextOverflow
+import androidx.compose.ui.unit.Constraints
+import androidx.compose.ui.unit.Density
+import androidx.compose.ui.unit.IntSize
+import androidx.compose.ui.unit.LayoutDirection
import com.nhaarman.mockitokotlin2.doReturn
import com.nhaarman.mockitokotlin2.mock
import com.nhaarman.mockitokotlin2.spy
@@ -70,6 +79,22 @@
state = TextState(mock(), selectableId)
state.layoutCoordinates = layoutCoordinates
+ state.layoutResult = TextLayoutResult(
+ TextLayoutInput(
+ text = AnnotatedString.Builder("Hello, World").toAnnotatedString(),
+ style = TextStyle(),
+ placeholders = listOf(),
+ maxLines = 1,
+ softWrap = true,
+ overflow = TextOverflow.Ellipsis,
+ density = Density(1.0f),
+ layoutDirection = LayoutDirection.Ltr,
+ resourceLoader = mock(),
+ constraints = Constraints.fixedWidth(100)
+ ),
+ multiParagraph = mock(),
+ size = IntSize(50, 50)
+ )
val controller = TextController(state).also {
it.update(selectionRegistrar)
@@ -80,6 +105,7 @@
@Test
fun longPressDragObserver_onLongPress_calls_notifySelectionInitiated() {
val position = Offset(100f, 100f)
+ whenever(state.layoutResult?.getOffsetForPosition(position)).thenReturn("Hello".length)
gesture.onStart(position)
@@ -91,12 +117,34 @@
}
@Test
+ fun longPressDragObserver_onLongPress_out_of_boundary_calls_notifySelectionUpdateSelectAll() {
+ val position = Offset(100f, 100f)
+ whenever(state.layoutResult?.getOffsetForPosition(position))
+ .thenReturn("Hello, World".length)
+
+ gesture.onStart(position)
+
+ verify(selectionRegistrar, times(1)).notifySelectionUpdateSelectAll(
+ selectableId = selectableId
+ )
+ }
+
+ @Test
fun longPressDragObserver_onDragStart_reset_dragTotalDistance() {
// Setup. Make sure selectionManager.dragTotalDistance is not 0.
val dragDistance1 = Offset(15f, 10f)
val beginPosition1 = Offset(30f, 20f)
val dragDistance2 = Offset(100f, 300f)
val beginPosition2 = Offset(300f, 200f)
+ whenever(state.layoutResult?.getOffsetForPosition(beginPosition1))
+ .thenReturn("Hello".length)
+ whenever(state.layoutResult?.getOffsetForPosition(beginPosition1 + dragDistance1))
+ .thenReturn("Hello".length)
+ whenever(state.layoutResult?.getOffsetForPosition(beginPosition2))
+ .thenReturn("Hello".length)
+ whenever(state.layoutResult?.getOffsetForPosition(beginPosition2 + dragDistance2))
+ .thenReturn("Hello".length)
+
gesture.onStart(beginPosition1)
gesture.onDrag(dragDistance1)
// Setup. Cancel selection and reselect.
@@ -122,6 +170,10 @@
fun longPressDragObserver_onDrag_calls_notifySelectionDrag() {
val dragDistance = Offset(15f, 10f)
val beginPosition = Offset(30f, 20f)
+ whenever(state.layoutResult?.getOffsetForPosition(beginPosition))
+ .thenReturn("Hello".length)
+ whenever(state.layoutResult?.getOffsetForPosition(beginPosition + dragDistance))
+ .thenReturn("Hello".length)
gesture.onStart(beginPosition)
selectionRegistrar.subselections = mapOf(selectableId to fakeSelection)
@@ -136,6 +188,27 @@
}
@Test
+ fun longPressDragObserver_onDrag_out_of_boundary_not_call_notifySelectionDrag() {
+ val dragDistance = Offset(15f, 10f)
+ val beginPosition = Offset(30f, 20f)
+ whenever(state.layoutResult?.getOffsetForPosition(beginPosition))
+ .thenReturn("Hello, World".length)
+ whenever(state.layoutResult?.getOffsetForPosition(beginPosition + dragDistance))
+ .thenReturn("Hello, World".length)
+ gesture.onStart(beginPosition)
+ selectionRegistrar.subselections = mapOf(selectableId to fakeSelection)
+
+ gesture.onDrag(dragDistance)
+ verify(selectionRegistrar, times(0))
+ .notifySelectionUpdate(
+ layoutCoordinates = layoutCoordinates,
+ startPosition = beginPosition,
+ endPosition = beginPosition + dragDistance,
+ adjustment = SelectionAdjustment.CHARACTER
+ )
+ }
+
+ @Test
fun longPressDragObserver_onStop_calls_notifySelectionEnd() {
val beginPosition = Offset(30f, 20f)
gesture.onStart(beginPosition)
diff --git a/compose/foundation/foundation/src/test/kotlin/androidx/compose/foundation/text/selection/SelectionManagerDragTest.kt b/compose/foundation/foundation/src/test/kotlin/androidx/compose/foundation/text/selection/SelectionManagerDragTest.kt
index 9c480e5..b30cf4a 100644
--- a/compose/foundation/foundation/src/test/kotlin/androidx/compose/foundation/text/selection/SelectionManagerDragTest.kt
+++ b/compose/foundation/foundation/src/test/kotlin/androidx/compose/foundation/text/selection/SelectionManagerDragTest.kt
@@ -210,6 +210,20 @@
var selectionToReturn: Selection? = null
var textToReturn: AnnotatedString? = null
+ private val selectableKey = 1L
+ private val fakeSelectAllSelection: Selection = Selection(
+ start = Selection.AnchorInfo(
+ direction = ResolvedTextDirection.Ltr,
+ offset = 0,
+ selectableId = selectableKey
+ ),
+ end = Selection.AnchorInfo(
+ direction = ResolvedTextDirection.Ltr,
+ offset = 10,
+ selectableId = selectableKey
+ )
+ )
+
override fun getSelection(
startPosition: Offset,
endPosition: Offset,
@@ -228,6 +242,10 @@
return selectionToReturn
}
+ override fun getSelectAllSelection(): Selection? {
+ return fakeSelectAllSelection
+ }
+
override fun getText(): AnnotatedString {
getTextCalledTimes++
return textToReturn!!
diff --git a/compose/foundation/foundation/src/test/kotlin/androidx/compose/foundation/text/selection/SelectionManagerTest.kt b/compose/foundation/foundation/src/test/kotlin/androidx/compose/foundation/text/selection/SelectionManagerTest.kt
index fa5092d..59736b1 100644
--- a/compose/foundation/foundation/src/test/kotlin/androidx/compose/foundation/text/selection/SelectionManagerTest.kt
+++ b/compose/foundation/foundation/src/test/kotlin/androidx/compose/foundation/text/selection/SelectionManagerTest.kt
@@ -193,6 +193,26 @@
}
@Test
+ fun mergeSelections_selectAll() {
+ val anotherSelectableId = 100L
+ val selectableAnother = mock<Selectable>()
+ whenever(selectableAnother.selectableId).thenReturn(anotherSelectableId)
+
+ selectionRegistrar.subscribe(selectableAnother)
+
+ selectionManager.mergeSelections(
+ selectableId = selectableId,
+ previousSelection = fakeSelection
+ )
+
+ verify(selectableAnother, times(0)).getSelectAllSelection()
+ verify(
+ hapticFeedback,
+ times(1)
+ ).performHapticFeedback(HapticFeedbackType.TextHandleMove)
+ }
+
+ @Test
fun getSelectedText_selection_null_return_null() {
selectionManager.selection = null
diff --git a/compose/integration-tests/demos/src/androidTest/java/androidx/compose/integration/demos/test/DemoTest.kt b/compose/integration-tests/demos/src/androidTest/java/androidx/compose/integration/demos/test/DemoTest.kt
index c228f39..4f83cc8 100644
--- a/compose/integration-tests/demos/src/androidTest/java/androidx/compose/integration/demos/test/DemoTest.kt
+++ b/compose/integration-tests/demos/src/androidTest/java/androidx/compose/integration/demos/test/DemoTest.kt
@@ -222,7 +222,7 @@
if (hostView.hasFocus()) {
if (hostView.isFocused) {
// One of the Compose components has focus.
- focusManager.clearFocus(forcedClear = true)
+ focusManager.clearFocus(force = true)
} else {
// A child view has focus. (View interop scenario).
// We could also use hostViewGroup.focusedChild?.clearFocus(), but the
diff --git a/compose/lint/common/src/main/java/androidx/compose/lint/ComposableUtils.kt b/compose/lint/common/src/main/java/androidx/compose/lint/ComposableUtils.kt
index e2efcce..fb9ee75 100644
--- a/compose/lint/common/src/main/java/androidx/compose/lint/ComposableUtils.kt
+++ b/compose/lint/common/src/main/java/androidx/compose/lint/ComposableUtils.kt
@@ -16,13 +16,15 @@
package androidx.compose.lint
-import com.intellij.psi.impl.compiled.ClsMethodImpl
+import com.intellij.psi.PsiMethod
import com.intellij.psi.impl.compiled.ClsParameterImpl
+import com.intellij.psi.impl.light.LightParameter
import kotlinx.metadata.jvm.annotations
import org.jetbrains.kotlin.psi.KtAnnotated
import org.jetbrains.kotlin.psi.KtFunction
import org.jetbrains.kotlin.psi.KtProperty
import org.jetbrains.kotlin.psi.KtTypeReference
+import org.jetbrains.kotlin.psi.psiUtil.getParentOfType
import org.jetbrains.uast.UAnnotation
import org.jetbrains.uast.UAnonymousClass
import org.jetbrains.uast.UCallExpression
@@ -35,7 +37,6 @@
import org.jetbrains.uast.UVariable
import org.jetbrains.uast.getContainingDeclaration
import org.jetbrains.uast.getContainingUClass
-import org.jetbrains.uast.getContainingUMethod
import org.jetbrains.uast.getParameterForArgument
import org.jetbrains.uast.toUElement
import org.jetbrains.uast.withContainingElements
@@ -110,14 +111,21 @@
* Returns whether this parameter's type is @Composable or not
*/
val UParameter.isComposable: Boolean
- get() = when (sourcePsi) {
+ get() = when {
// The parameter is in a class file. Currently type annotations aren't currently added to
// the underlying type (https://youtrack.jetbrains.com/issue/KT-45307), so instead we use
// the metadata annotation.
- is ClsParameterImpl -> {
+ sourcePsi is ClsParameterImpl
+ // In some cases when a method is defined in bytecode and the call fails to resolve
+ // to the ClsMethodImpl, sourcePsi can be null. In this case we can instead use javaPsi
+ // which will have a light implementation. Note that javaPsi will return a light
+ // implementation for most Kotlin declarations too, so we need to first check to see if
+ // the sourcePsi is null.
+ // https://youtrack.jetbrains.com/issue/KT-46883
+ || (sourcePsi == null && javaPsi is LightParameter) -> {
// Find the containing method, so we can get metadata from the containing class
- val containingMethod = getContainingUMethod()!!.sourcePsi as ClsMethodImpl
- val kmFunction = containingMethod.toKmFunction()
+ val containingMethod = javaPsi!!.getParentOfType<PsiMethod>(true)
+ val kmFunction = containingMethod!!.toKmFunction()
val kmValueParameter = kmFunction?.valueParameters?.find {
it.name == name
@@ -236,10 +244,9 @@
get() {
if (type.hasAnnotation(Names.Runtime.Composable.javaFqn)) return true
- // Annotations should be available on the PsiType itself in 1.4.30+, but we are
- // currently on an older version of UAST / Kotlin embedded compiled
- // (https://youtrack.jetbrains.com/issue/KT-45244), so we need to manually check the
- // underlying type reference. Until then, the above check will always fail.
+ // Annotations on the types of local properties (val foo: @Composable () -> Unit = {})
+ // are currently not present on the PsiType, we so need to manually check the underlying
+ // type reference. (https://youtrack.jetbrains.com/issue/KT-45244)
return (sourcePsi as? KtTypeReference)?.hasComposableAnnotation == true
}
diff --git a/compose/lint/common/src/main/java/androidx/compose/lint/KotlinMetadataUtils.kt b/compose/lint/common/src/main/java/androidx/compose/lint/KotlinMetadataUtils.kt
index c9da754..6e751b5 100644
--- a/compose/lint/common/src/main/java/androidx/compose/lint/KotlinMetadataUtils.kt
+++ b/compose/lint/common/src/main/java/androidx/compose/lint/KotlinMetadataUtils.kt
@@ -20,8 +20,8 @@
import com.intellij.lang.jvm.annotation.JvmAnnotationAttributeValue
import com.intellij.lang.jvm.annotation.JvmAnnotationConstantValue
import com.intellij.psi.PsiAnnotation
+import com.intellij.psi.PsiClass
import com.intellij.psi.PsiMethod
-import com.intellij.psi.impl.compiled.ClsMemberImpl
import com.intellij.psi.impl.compiled.ClsMethodImpl
import com.intellij.psi.util.ClassUtil
import kotlinx.metadata.KmDeclarationContainer
@@ -31,23 +31,24 @@
import kotlinx.metadata.jvm.signature
/**
- * @return the corresponding [KmFunction] for this [ClsMethodImpl], or `null` if there is no
- * corresponding [KmFunction].
+ * @return the corresponding [KmFunction] for this [PsiMethod], or `null` if there is no
+ * corresponding [KmFunction]. This method is only meaningful if this [PsiMethod] represents a
+ * method defined in bytecode (most often a [ClsMethodImpl]).
*/
-fun ClsMethodImpl.toKmFunction(): KmFunction? =
- getKmDeclarationContainer()?.findKmFunctionForPsiMethod(this)
+fun PsiMethod.toKmFunction(): KmFunction? =
+ containingClass!!.getKmDeclarationContainer()?.findKmFunctionForPsiMethod(this)
// TODO: https://youtrack.jetbrains.com/issue/KT-45310
// Currently there is no built in support for parsing kotlin metadata from kotlin class files, so
// we need to manually inspect the annotations and work with Cls* (compiled PSI).
/**
- * Returns the [KmDeclarationContainer] using the kotlin.Metadata annotation present on the
- * surrounding class. Returns null if there is no surrounding annotation (not parsing a Kotlin
+ * Returns the [KmDeclarationContainer] using the kotlin.Metadata annotation present on this
+ * [PsiClass]. Returns null if there is no annotation (not parsing a Kotlin
* class file), the annotation data is for an unsupported version of Kotlin, or if the metadata
* represents a synthetic class.
*/
-private fun ClsMemberImpl<*>.getKmDeclarationContainer(): KmDeclarationContainer? {
- val classKotlinMetadataAnnotation = containingClass?.annotations?.find {
+private fun PsiClass.getKmDeclarationContainer(): KmDeclarationContainer? {
+ val classKotlinMetadataAnnotation = annotations.find {
// hasQualifiedName() not available on the min version of Lint we compile against
it.qualifiedName == KotlinMetadataFqn
} ?: return null
diff --git a/compose/material/material/icons/generator/src/main/kotlin/androidx/compose/material/icons/generator/tasks/IconGenerationTask.kt b/compose/material/material/icons/generator/src/main/kotlin/androidx/compose/material/icons/generator/tasks/IconGenerationTask.kt
index bb03014..9daa0c4 100644
--- a/compose/material/material/icons/generator/src/main/kotlin/androidx/compose/material/icons/generator/tasks/IconGenerationTask.kt
+++ b/compose/material/material/icons/generator/src/main/kotlin/androidx/compose/material/icons/generator/tasks/IconGenerationTask.kt
@@ -170,6 +170,9 @@
// b/175401659 - disable lint as it takes a long time, and most errors should
// be caught by lint on material-icons-core anyway
project.afterEvaluate {
+ project.tasks.named("lintAnalyzeDebug") { t ->
+ t.enabled = false
+ }
project.tasks.named("lintDebug") { t ->
t.enabled = false
}
diff --git a/compose/material/material/src/desktopMain/kotlin/androidx/compose/material/DesktopAlertDialog.desktop.kt b/compose/material/material/src/desktopMain/kotlin/androidx/compose/material/DesktopAlertDialog.desktop.kt
index 0a9f875..b077db6 100644
--- a/compose/material/material/src/desktopMain/kotlin/androidx/compose/material/DesktopAlertDialog.desktop.kt
+++ b/compose/material/material/src/desktopMain/kotlin/androidx/compose/material/DesktopAlertDialog.desktop.kt
@@ -24,8 +24,8 @@
import androidx.compose.ui.graphics.Color
import androidx.compose.ui.graphics.Shape
import androidx.compose.ui.unit.dp
-import androidx.compose.ui.window.Dialog
-import androidx.compose.ui.window.DialogProperties
+import androidx.compose.ui.window.v1.Dialog
+import androidx.compose.ui.window.v1.DialogProperties
/**
* Alert dialog is a [Dialog] which interrupts the user with urgent information, details or actions.
diff --git a/compose/runtime/runtime-lint/src/main/java/androidx/compose/runtime/lint/ComposableLambdaParameterDetector.kt b/compose/runtime/runtime-lint/src/main/java/androidx/compose/runtime/lint/ComposableLambdaParameterDetector.kt
index ad32a95..cd738fe 100644
--- a/compose/runtime/runtime-lint/src/main/java/androidx/compose/runtime/lint/ComposableLambdaParameterDetector.kt
+++ b/compose/runtime/runtime-lint/src/main/java/androidx/compose/runtime/lint/ComposableLambdaParameterDetector.kt
@@ -135,25 +135,31 @@
companion object {
val ComposableLambdaParameterNaming = Issue.create(
- "ComposableLambdaParameterNaming",
- "Primary composable lambda parameter not named `content`",
- "Composable functions with only one composable lambda parameter should use the name " +
- "`content` for the parameter.",
- Category.CORRECTNESS, 3, Severity.IGNORE,
- Implementation(
+ id = "ComposableLambdaParameterNaming",
+ briefDescription = "Primary composable lambda parameter not named `content`",
+ explanation = "Composable functions with only one composable lambda parameter should " +
+ "use the name `content` for the parameter.",
+ category = Category.CORRECTNESS,
+ priority = 3,
+ severity = Severity.WARNING,
+ enabledByDefault = false,
+ implementation = Implementation(
ComposableLambdaParameterDetector::class.java,
EnumSet.of(Scope.JAVA_FILE, Scope.TEST_SOURCES)
)
)
val ComposableLambdaParameterPosition = Issue.create(
- "ComposableLambdaParameterPosition",
- "Non-trailing primary composable lambda parameter",
- "Composable functions with only one composable lambda parameter should place the " +
- "parameter at the end of the parameter list, so it can be used as a trailing " +
- "lambda.",
- Category.CORRECTNESS, 3, Severity.IGNORE,
- Implementation(
+ id = "ComposableLambdaParameterPosition",
+ briefDescription = "Non-trailing primary composable lambda parameter",
+ explanation = "Composable functions with only one composable lambda parameter should " +
+ "place the parameter at the end of the parameter list, so it can be used as a " +
+ "trailing lambda.",
+ category = Category.CORRECTNESS,
+ priority = 3,
+ severity = Severity.WARNING,
+ enabledByDefault = false,
+ implementation = Implementation(
ComposableLambdaParameterDetector::class.java,
EnumSet.of(Scope.JAVA_FILE, Scope.TEST_SOURCES)
)
diff --git a/compose/runtime/runtime-lint/src/test/java/androidx/compose/runtime/lint/ComposableLambdaParameterDetectorTest.kt b/compose/runtime/runtime-lint/src/test/java/androidx/compose/runtime/lint/ComposableLambdaParameterDetectorTest.kt
index da08c10..cae7ccf 100644
--- a/compose/runtime/runtime-lint/src/test/java/androidx/compose/runtime/lint/ComposableLambdaParameterDetectorTest.kt
+++ b/compose/runtime/runtime-lint/src/test/java/androidx/compose/runtime/lint/ComposableLambdaParameterDetectorTest.kt
@@ -214,7 +214,12 @@
@Composable
fun Button(
text: @Composable (() -> Unit)?,
- icon: @Composable () -> Unit,
+ foo: Int
+ ) {}
+
+ @Composable
+ fun Button2(
+ text: (@Composable () -> Unit)?,
foo: Int
) {}
"""
@@ -222,7 +227,35 @@
kotlin(Stubs.Composable)
)
.run()
- .expectClean()
+ .expect(
+ """
+src/androidx/compose/ui/foo/test.kt:8: Warning: Composable lambda parameter should be named content [ComposableLambdaParameterNaming]
+ text: @Composable (() -> Unit)?,
+ ~~~~
+src/androidx/compose/ui/foo/test.kt:14: Warning: Composable lambda parameter should be named content [ComposableLambdaParameterNaming]
+ text: (@Composable () -> Unit)?,
+ ~~~~
+src/androidx/compose/ui/foo/test.kt:8: Warning: Composable lambda parameter should be the last parameter so it can be used as a trailing lambda [ComposableLambdaParameterPosition]
+ text: @Composable (() -> Unit)?,
+ ~~~~
+src/androidx/compose/ui/foo/test.kt:14: Warning: Composable lambda parameter should be the last parameter so it can be used as a trailing lambda [ComposableLambdaParameterPosition]
+ text: (@Composable () -> Unit)?,
+ ~~~~
+0 errors, 4 warnings
+ """
+ )
+ .expectFixDiffs(
+ """
+Fix for src/androidx/compose/ui/foo/test.kt line 8: Rename text to content:
+@@ -8 +8
+- text: @Composable (() -> Unit)?,
++ content: @Composable (() -> Unit)?,
+Fix for src/androidx/compose/ui/foo/test.kt line 14: Rename text to content:
+@@ -14 +14
+- text: (@Composable () -> Unit)?,
++ content: (@Composable () -> Unit)?,
+ """
+ )
}
@Test
diff --git a/compose/runtime/runtime/compose-runtime-benchmark/build.gradle b/compose/runtime/runtime/compose-runtime-benchmark/build.gradle
index 460dabe..2bcb7e7 100644
--- a/compose/runtime/runtime/compose-runtime-benchmark/build.gradle
+++ b/compose/runtime/runtime/compose-runtime-benchmark/build.gradle
@@ -56,3 +56,7 @@
androidTestImplementation("androidx.activity:activity:1.2.0")
androidTestImplementation(project(":activity:activity-compose"))
}
+
+androidx {
+ benchmarkRunAlsoInterpreted = true
+}
\ No newline at end of file
diff --git a/compose/runtime/runtime/src/commonMain/kotlin/androidx/compose/runtime/Composer.kt b/compose/runtime/runtime/src/commonMain/kotlin/androidx/compose/runtime/Composer.kt
index e8ff224..76af048 100644
--- a/compose/runtime/runtime/src/commonMain/kotlin/androidx/compose/runtime/Composer.kt
+++ b/compose/runtime/runtime/src/commonMain/kotlin/androidx/compose/runtime/Composer.kt
@@ -3081,9 +3081,10 @@
value: Int,
noinline block: T.(value: Int) -> Unit
) = with(composer) {
+ val inserting = inserting
if (inserting || rememberedValue() != value) {
updateRememberedValue(value)
- composer.apply(value, block)
+ if (!inserting) apply(value, block)
}
}
@@ -3102,9 +3103,10 @@
value: V,
block: T.(value: V) -> Unit
) = with(composer) {
+ val inserting = inserting
if (inserting || rememberedValue() != value) {
updateRememberedValue(value)
- composer.apply(value, block)
+ if (!inserting) apply(value, block)
}
}
diff --git a/compose/runtime/runtime/src/test/kotlin/androidx/compose/runtime/CompositionTests.kt b/compose/runtime/runtime/src/test/kotlin/androidx/compose/runtime/CompositionTests.kt
index 7e07357..bc34c6e 100644
--- a/compose/runtime/runtime/src/test/kotlin/androidx/compose/runtime/CompositionTests.kt
+++ b/compose/runtime/runtime/src/test/kotlin/androidx/compose/runtime/CompositionTests.kt
@@ -2944,6 +2944,65 @@
stateA++
advance()
}
+
+ /**
+ * set should set the value every time, update should only set after initial composition.
+ */
+ @OptIn(ExperimentalCoroutinesApi::class)
+ @Test
+ fun composeNodeSetVsUpdate() = runBlockingTest {
+ localRecomposerTest { recomposer ->
+ class SetUpdateNode(property: String) {
+ var changeCount = 0
+ var property: String = property
+ set(value) {
+ field = value
+ changeCount++
+ }
+ }
+ class SetUpdateNodeApplier : AbstractApplier<SetUpdateNode>(SetUpdateNode("root")) {
+ override fun insertTopDown(index: Int, instance: SetUpdateNode) {}
+ override fun insertBottomUp(index: Int, instance: SetUpdateNode) {}
+ override fun remove(index: Int, count: Int) {}
+ override fun move(from: Int, to: Int, count: Int) {}
+ override fun onClear() {}
+ }
+ val composition = Composition(SetUpdateNodeApplier(), recomposer)
+ val nodes = mutableListOf<SetUpdateNode>()
+ fun makeNode(property: String) = SetUpdateNode(property).also { nodes += it }
+
+ var value by mutableStateOf("initial")
+
+ composition.setContent {
+ ComposeNode<SetUpdateNode, SetUpdateNodeApplier>(
+ factory = { makeNode(value) },
+ update = {
+ set(value) { property = value }
+ }
+ )
+ ComposeNode<SetUpdateNode, SetUpdateNodeApplier>(
+ factory = { makeNode(value) },
+ update = {
+ update(value) { property = value }
+ }
+ )
+ }
+
+ assertEquals("initial", nodes[0].property, "node 0 initial composition value")
+ assertEquals("initial", nodes[1].property, "node 1 initial composition value")
+ assertEquals(1, nodes[0].changeCount, "node 0 initial composition changeCount")
+ assertEquals(0, nodes[1].changeCount, "node 1 initial composition changeCount")
+
+ value = "changed"
+ Snapshot.sendApplyNotifications()
+ advanceUntilIdle()
+
+ assertEquals("changed", nodes[0].property, "node 0 recomposition value")
+ assertEquals("changed", nodes[1].property, "node 1 recomposition value")
+ assertEquals(2, nodes[0].changeCount, "node 0 recomposition changeCount")
+ assertEquals(1, nodes[1].changeCount, "node 1 recomposition changeCount")
+ }
+ }
}
var stateA by mutableStateOf(1000)
diff --git a/compose/test-utils/lint-baseline.xml b/compose/test-utils/lint-baseline.xml
index 42a176b..fd93d9f 100644
--- a/compose/test-utils/lint-baseline.xml
+++ b/compose/test-utils/lint-baseline.xml
@@ -1,4 +1,92 @@
<?xml version="1.0" encoding="UTF-8"?>
<issues format="6" by="lint 7.0.0-alpha15" type="baseline" client="cli" name="Lint" variant="all" version="7.0.0-alpha15">
+ <issue
+ id="BanTargetApiAnnotation"
+ message="Uses @TargetApi annotation"
+ errorLine1="@TargetApi(Build.VERSION_CODES.Q)"
+ errorLine2="~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~">
+ <location
+ file="src/androidMain/kotlin/androidx/compose/testutils/AndroidComposeTestCaseRunner.android.kt"
+ line="345"
+ column="1"/>
+ </issue>
+
+ <issue
+ id="ClassVerificationFailure"
+ message="This call references a method added in API level 28; however, the containing class androidx.compose.testutils.AndroidComposeTestCaseRunner is reachable from earlier API levels and will fail run-time class verification."
+ errorLine1=" bitmap = Bitmap.createBitmap(picture)"
+ errorLine2=" ~~~~~~~~~~~~">
+ <location
+ file="src/androidMain/kotlin/androidx/compose/testutils/AndroidComposeTestCaseRunner.android.kt"
+ line="274"
+ column="29"/>
+ </issue>
+
+ <issue
+ id="ClassVerificationFailure"
+ message="This call references a method added in API level 29; however, the containing class androidx.compose.testutils.RenderNodeCapture is reachable from earlier API levels and will fail run-time class verification."
+ errorLine1=" private val renderNode = RenderNode("Test")"
+ errorLine2=" ~~~~~~~~~~~~~~~~~~">
+ <location
+ file="src/androidMain/kotlin/androidx/compose/testutils/AndroidComposeTestCaseRunner.android.kt"
+ line="347"
+ column="30"/>
+ </issue>
+
+ <issue
+ id="ClassVerificationFailure"
+ message="This call references a method added in API level 29; however, the containing class androidx.compose.testutils.RenderNodeCapture is reachable from earlier API levels and will fail run-time class verification."
+ errorLine1=" renderNode.setPosition(0, 0, width, height)"
+ errorLine2=" ~~~~~~~~~~~">
+ <location
+ file="src/androidMain/kotlin/androidx/compose/testutils/AndroidComposeTestCaseRunner.android.kt"
+ line="350"
+ column="20"/>
+ </issue>
+
+ <issue
+ id="ClassVerificationFailure"
+ message="This call references a method added in API level 29; however, the containing class androidx.compose.testutils.RenderNodeCapture is reachable from earlier API levels and will fail run-time class verification."
+ errorLine1=" return renderNode.beginRecording()"
+ errorLine2=" ~~~~~~~~~~~~~~">
+ <location
+ file="src/androidMain/kotlin/androidx/compose/testutils/AndroidComposeTestCaseRunner.android.kt"
+ line="351"
+ column="27"/>
+ </issue>
+
+ <issue
+ id="ClassVerificationFailure"
+ message="This call references a method added in API level 29; however, the containing class androidx.compose.testutils.RenderNodeCapture is reachable from earlier API levels and will fail run-time class verification."
+ errorLine1=" renderNode.endRecording()"
+ errorLine2=" ~~~~~~~~~~~~">
+ <location
+ file="src/androidMain/kotlin/androidx/compose/testutils/AndroidComposeTestCaseRunner.android.kt"
+ line="355"
+ column="20"/>
+ </issue>
+
+ <issue
+ id="ClassVerificationFailure"
+ message="This call references a method added in API level 29; however, the containing class androidx.compose.testutils.ViewCapture_androidKt is reachable from earlier API levels and will fail run-time class verification."
+ errorLine1=" decorView.viewTreeObserver.registerFrameCommitCallback {"
+ errorLine2=" ~~~~~~~~~~~~~~~~~~~~~~~~~~~">
+ <location
+ file="src/androidMain/kotlin/androidx/compose/testutils/ViewCapture.android.kt"
+ line="68"
+ column="40"/>
+ </issue>
+
+ <issue
+ id="ClassVerificationFailure"
+ message="This call references a method added in API level 26; however, the containing class androidx.compose.testutils.ViewCapture_androidKt is reachable from earlier API levels and will fail run-time class verification."
+ errorLine1=" PixelCopy.request(windowToCapture, boundsInWindow, destBitmap, onCopyFinished, handler)"
+ errorLine2=" ~~~~~~~">
+ <location
+ file="src/androidMain/kotlin/androidx/compose/testutils/ViewCapture.android.kt"
+ line="104"
+ column="15"/>
+ </issue>
+
</issues>
diff --git a/compose/ui/ui-graphics/lint-baseline.xml b/compose/ui/ui-graphics/lint-baseline.xml
index 42a176b..bf0a68e 100644
--- a/compose/ui/ui-graphics/lint-baseline.xml
+++ b/compose/ui/ui-graphics/lint-baseline.xml
@@ -1,4 +1,37 @@
<?xml version="1.0" encoding="UTF-8"?>
<issues format="6" by="lint 7.0.0-alpha15" type="baseline" client="cli" name="Lint" variant="all" version="7.0.0-alpha15">
+ <issue
+ id="ClassVerificationFailure"
+ message="This call references a method added in API level 29; however, the containing class androidx.compose.ui.graphics.AndroidColorFilter_androidKt is reachable from earlier API levels and will fail run-time class verification."
+ errorLine1=" BlendModeColorFilter(color.toArgb(), blendMode.toAndroidBlendMode())"
+ errorLine2=" ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~">
+ <location
+ file="src/androidMain/kotlin/androidx/compose/ui/graphics/AndroidColorFilter.android.kt"
+ line="39"
+ column="9"/>
+ </issue>
+
+ <issue
+ id="ClassVerificationFailure"
+ message="This call references a method added in API level 29; however, the containing class androidx.compose.ui.graphics.CanvasUtils is reachable from earlier API levels and will fail run-time class verification."
+ errorLine1=" canvas.enableZ()"
+ errorLine2=" ~~~~~~~">
+ <location
+ file="src/androidMain/kotlin/androidx/compose/ui/graphics/CanvasUtils.android.kt"
+ line="39"
+ column="24"/>
+ </issue>
+
+ <issue
+ id="ClassVerificationFailure"
+ message="This call references a method added in API level 29; however, the containing class androidx.compose.ui.graphics.CanvasUtils is reachable from earlier API levels and will fail run-time class verification."
+ errorLine1=" canvas.disableZ()"
+ errorLine2=" ~~~~~~~~">
+ <location
+ file="src/androidMain/kotlin/androidx/compose/ui/graphics/CanvasUtils.android.kt"
+ line="41"
+ column="24"/>
+ </issue>
+
</issues>
diff --git a/compose/ui/ui-inspection/src/androidTest/java/androidx/compose/ui/inspection/inspector/LayoutInspectorTreeTest.kt b/compose/ui/ui-inspection/src/androidTest/java/androidx/compose/ui/inspection/inspector/LayoutInspectorTreeTest.kt
index edcae42..6580236 100644
--- a/compose/ui/ui-inspection/src/androidTest/java/androidx/compose/ui/inspection/inspector/LayoutInspectorTreeTest.kt
+++ b/compose/ui/ui-inspection/src/androidTest/java/androidx/compose/ui/inspection/inspector/LayoutInspectorTreeTest.kt
@@ -20,6 +20,7 @@
import android.view.ViewGroup
import android.view.inspector.WindowInspector
import android.widget.TextView
+import androidx.compose.animation.Crossfade
import androidx.compose.foundation.Image
import androidx.compose.foundation.background
import androidx.compose.foundation.layout.Arrangement
@@ -45,6 +46,9 @@
import androidx.compose.runtime.CompositionLocalProvider
import androidx.compose.runtime.InternalComposeApi
import androidx.compose.runtime.currentComposer
+import androidx.compose.runtime.getValue
+import androidx.compose.runtime.mutableStateOf
+import androidx.compose.runtime.remember
import androidx.compose.runtime.tooling.CompositionData
import androidx.compose.runtime.tooling.LocalInspectionTables
import androidx.compose.ui.Alignment
@@ -89,7 +93,7 @@
import java.util.WeakHashMap
import kotlin.math.roundToInt
-private const val DEBUG = false
+private const val DEBUG = true
private const val ROOT_ID = 3L
private const val MAX_RECURSIONS = 2
private const val MAX_ITERABLE_SIZE = 5
@@ -706,6 +710,43 @@
}
}
+ @Composable
+ fun First() {
+ Text("First")
+ }
+
+ @Composable
+ fun Second() {
+ Text("Second")
+ }
+
+ @Test
+ fun testCrossfade() {
+ val slotTableRecord = CompositionDataRecord.create()
+
+ show {
+ Inspectable(slotTableRecord) {
+ val showFirst by remember { mutableStateOf(true) }
+ Crossfade(showFirst) {
+ when (it) {
+ true -> First()
+ false -> Second()
+ }
+ }
+ }
+ }
+ val androidComposeView = findAndroidComposeView()
+ androidComposeView.setTag(R.id.inspection_slot_table_set, slotTableRecord.store)
+ val builder = LayoutInspectorTree()
+ builder.hideSystemNodes = false
+ val first = builder.convert(androidComposeView)
+ .flatMap { flatten(it) }
+ .first { it.name == "First" }
+ val hash = packageNameHash(this.javaClass.name.substringBeforeLast('.'))
+ assertThat(first.fileName).isEqualTo("LayoutInspectorTreeTest.kt")
+ assertThat(first.packageHash).isEqualTo(hash)
+ }
+
@Suppress("SameParameterValue")
private fun validate(
result: List<InspectorNode>,
diff --git a/compose/ui/ui-inspection/src/main/java/androidx/compose/ui/inspection/inspector/LayoutInspectorTree.kt b/compose/ui/ui-inspection/src/main/java/androidx/compose/ui/inspection/inspector/LayoutInspectorTree.kt
index a6779e4..2dca1dd 100644
--- a/compose/ui/ui-inspection/src/main/java/androidx/compose/ui/inspection/inspector/LayoutInspectorTree.kt
+++ b/compose/ui/ui-inspection/src/main/java/androidx/compose/ui/inspection/inspector/LayoutInspectorTree.kt
@@ -17,6 +17,7 @@
package androidx.compose.ui.inspection.inspector
import android.view.View
+import androidx.annotation.VisibleForTesting
import androidx.compose.runtime.InternalComposeApi
import androidx.compose.runtime.tooling.CompositionData
import androidx.compose.ui.ExperimentalComposeUiApi
@@ -74,7 +75,8 @@
"ProvideCommonCompositionLocals",
)
-private fun packageNameHash(packageName: String) =
+@VisibleForTesting
+fun packageNameHash(packageName: String) =
packageName.fold(0) { hash, char -> hash * 31 + char.code }.absoluteValue
/**
diff --git a/compose/ui/ui-test/lint-baseline.xml b/compose/ui/ui-test/lint-baseline.xml
index 42a176b..a9d6c54 100644
--- a/compose/ui/ui-test/lint-baseline.xml
+++ b/compose/ui/ui-test/lint-baseline.xml
@@ -1,4 +1,26 @@
<?xml version="1.0" encoding="UTF-8"?>
<issues format="6" by="lint 7.0.0-alpha15" type="baseline" client="cli" name="Lint" variant="all" version="7.0.0-alpha15">
+ <issue
+ id="ClassVerificationFailure"
+ message="This call references a method added in API level 29; however, the containing class androidx.compose.ui.test.android.WindowCapture_androidKt is reachable from earlier API levels and will fail run-time class verification."
+ errorLine1=" decorView.viewTreeObserver.registerFrameCommitCallback {"
+ errorLine2=" ~~~~~~~~~~~~~~~~~~~~~~~~~~~">
+ <location
+ file="src/androidMain/kotlin/androidx/compose/ui/test/android/WindowCapture.android.kt"
+ line="64"
+ column="40"/>
+ </issue>
+
+ <issue
+ id="ClassVerificationFailure"
+ message="This call references a method added in API level 26; however, the containing class androidx.compose.ui.test.android.WindowCapture_androidKt is reachable from earlier API levels and will fail run-time class verification."
+ errorLine1=" PixelCopy.request(windowToCapture, captureRectInWindow, destBitmap, onCopyFinished, handler)"
+ errorLine2=" ~~~~~~~">
+ <location
+ file="src/androidMain/kotlin/androidx/compose/ui/test/android/WindowCapture.android.kt"
+ line="100"
+ column="15"/>
+ </issue>
+
</issues>
diff --git a/compose/ui/ui-text/api/1.0.0-beta08.txt b/compose/ui/ui-text/api/1.0.0-beta08.txt
index d0abc49..d50cd19 100644
--- a/compose/ui/ui-text/api/1.0.0-beta08.txt
+++ b/compose/ui/ui-text/api/1.0.0-beta08.txt
@@ -222,24 +222,43 @@
}
@androidx.compose.runtime.Immutable public final class Placeholder {
- method public androidx.compose.ui.text.Placeholder copy-KJSDsNM(optional long width, optional long height, optional androidx.compose.ui.text.PlaceholderVerticalAlign placeholderVerticalAlign);
+ method public androidx.compose.ui.text.Placeholder copy-KJSDsNM(optional long width, optional long height, optional int placeholderVerticalAlign);
method public operator boolean equals(Object? other);
method public long getHeight-XSAIIZE();
- method public androidx.compose.ui.text.PlaceholderVerticalAlign getPlaceholderVerticalAlign();
+ method public int getPlaceholderVerticalAlign-J6kI3mc();
method public long getWidth-XSAIIZE();
property public final long height;
- property public final androidx.compose.ui.text.PlaceholderVerticalAlign placeholderVerticalAlign;
+ property public final int placeholderVerticalAlign;
property public final long width;
}
- public enum PlaceholderVerticalAlign {
- enum_constant public static final androidx.compose.ui.text.PlaceholderVerticalAlign AboveBaseline;
- enum_constant public static final androidx.compose.ui.text.PlaceholderVerticalAlign Bottom;
- enum_constant public static final androidx.compose.ui.text.PlaceholderVerticalAlign Center;
- enum_constant public static final androidx.compose.ui.text.PlaceholderVerticalAlign TextBottom;
- enum_constant public static final androidx.compose.ui.text.PlaceholderVerticalAlign TextCenter;
- enum_constant public static final androidx.compose.ui.text.PlaceholderVerticalAlign TextTop;
- enum_constant public static final androidx.compose.ui.text.PlaceholderVerticalAlign Top;
+ public final inline class PlaceholderVerticalAlign {
+ ctor public PlaceholderVerticalAlign();
+ method public static int constructor-impl(int value);
+ method public static inline boolean equals-impl(int p, Object? p1);
+ method public static boolean equals-impl0(int p1, int p2);
+ method public int getValue();
+ method public static inline int hashCode-impl(int p);
+ method public static String toString-impl(int $this);
+ property public final int value;
+ field public static final androidx.compose.ui.text.PlaceholderVerticalAlign.Companion Companion;
+ }
+
+ public static final class PlaceholderVerticalAlign.Companion {
+ method public int getAboveBaseline-J6kI3mc();
+ method public int getBottom-J6kI3mc();
+ method public int getCenter-J6kI3mc();
+ method public int getTextBottom-J6kI3mc();
+ method public int getTextCenter-J6kI3mc();
+ method public int getTextTop-J6kI3mc();
+ method public int getTop-J6kI3mc();
+ property public final int AboveBaseline;
+ property public final int Bottom;
+ property public final int Center;
+ property public final int TextBottom;
+ property public final int TextCenter;
+ property public final int TextTop;
+ property public final int Top;
}
public final class SaversKt {
diff --git a/compose/ui/ui-text/api/current.ignore b/compose/ui/ui-text/api/current.ignore
index 5bb1213..221b006 100644
--- a/compose/ui/ui-text/api/current.ignore
+++ b/compose/ui/ui-text/api/current.ignore
@@ -3,6 +3,8 @@
Added method androidx.compose.ui.text.input.InputEventCallback.onImeAction-KlQnJC8(int)
+ChangedSuperclass: androidx.compose.ui.text.PlaceholderVerticalAlign:
+ Class androidx.compose.ui.text.PlaceholderVerticalAlign superclass changed from java.lang.Enum to java.lang.Object
ChangedSuperclass: androidx.compose.ui.text.input.ImeAction:
Class androidx.compose.ui.text.input.ImeAction superclass changed from java.lang.Enum to java.lang.Object
ChangedSuperclass: androidx.compose.ui.text.input.KeyboardType:
@@ -13,6 +15,8 @@
Attempted to remove @NonNull annotation from Field ImeOptions.imeAction
InvalidNullConversion: Field ImeOptions.keyboardType:
Attempted to remove @NonNull annotation from Field ImeOptions.keyboardType
+InvalidNullConversion: Field Placeholder.placeholderVerticalAlign:
+ Attempted to remove @NonNull annotation from Field Placeholder.placeholderVerticalAlign
RemovedClass: androidx.compose.ui.text.JvmCharHelpers_jvmKt:
@@ -23,6 +27,20 @@
Removed deprecated method androidx.compose.ui.text.input.InputEventCallback.onImeAction(androidx.compose.ui.text.input.ImeAction)
+RemovedField: androidx.compose.ui.text.PlaceholderVerticalAlign#AboveBaseline:
+ Removed enum constant androidx.compose.ui.text.PlaceholderVerticalAlign.AboveBaseline
+RemovedField: androidx.compose.ui.text.PlaceholderVerticalAlign#Bottom:
+ Removed enum constant androidx.compose.ui.text.PlaceholderVerticalAlign.Bottom
+RemovedField: androidx.compose.ui.text.PlaceholderVerticalAlign#Center:
+ Removed enum constant androidx.compose.ui.text.PlaceholderVerticalAlign.Center
+RemovedField: androidx.compose.ui.text.PlaceholderVerticalAlign#TextBottom:
+ Removed enum constant androidx.compose.ui.text.PlaceholderVerticalAlign.TextBottom
+RemovedField: androidx.compose.ui.text.PlaceholderVerticalAlign#TextCenter:
+ Removed enum constant androidx.compose.ui.text.PlaceholderVerticalAlign.TextCenter
+RemovedField: androidx.compose.ui.text.PlaceholderVerticalAlign#TextTop:
+ Removed enum constant androidx.compose.ui.text.PlaceholderVerticalAlign.TextTop
+RemovedField: androidx.compose.ui.text.PlaceholderVerticalAlign#Top:
+ Removed enum constant androidx.compose.ui.text.PlaceholderVerticalAlign.Top
RemovedField: androidx.compose.ui.text.input.ImeAction#Default:
Removed enum constant androidx.compose.ui.text.input.ImeAction.Default
RemovedField: androidx.compose.ui.text.input.ImeAction#Done:
@@ -57,6 +75,10 @@
Removed enum constant androidx.compose.ui.text.input.KeyboardType.Uri
+RemovedMethod: androidx.compose.ui.text.Placeholder#copy-KJSDsNM(long, long, androidx.compose.ui.text.PlaceholderVerticalAlign):
+ Removed method androidx.compose.ui.text.Placeholder.copy-KJSDsNM(long,long,androidx.compose.ui.text.PlaceholderVerticalAlign)
+RemovedMethod: androidx.compose.ui.text.Placeholder#getPlaceholderVerticalAlign():
+ Removed method androidx.compose.ui.text.Placeholder.getPlaceholderVerticalAlign()
RemovedMethod: androidx.compose.ui.text.input.ImeOptions#ImeOptions(boolean, androidx.compose.ui.text.input.KeyboardCapitalization, boolean, androidx.compose.ui.text.input.KeyboardType, androidx.compose.ui.text.input.ImeAction):
Removed constructor androidx.compose.ui.text.input.ImeOptions(boolean,androidx.compose.ui.text.input.KeyboardCapitalization,boolean,androidx.compose.ui.text.input.KeyboardType,androidx.compose.ui.text.input.ImeAction)
RemovedMethod: androidx.compose.ui.text.input.ImeOptions#copy(boolean, androidx.compose.ui.text.input.KeyboardCapitalization, boolean, androidx.compose.ui.text.input.KeyboardType, androidx.compose.ui.text.input.ImeAction):
diff --git a/compose/ui/ui-text/api/current.txt b/compose/ui/ui-text/api/current.txt
index d0abc49..d50cd19 100644
--- a/compose/ui/ui-text/api/current.txt
+++ b/compose/ui/ui-text/api/current.txt
@@ -222,24 +222,43 @@
}
@androidx.compose.runtime.Immutable public final class Placeholder {
- method public androidx.compose.ui.text.Placeholder copy-KJSDsNM(optional long width, optional long height, optional androidx.compose.ui.text.PlaceholderVerticalAlign placeholderVerticalAlign);
+ method public androidx.compose.ui.text.Placeholder copy-KJSDsNM(optional long width, optional long height, optional int placeholderVerticalAlign);
method public operator boolean equals(Object? other);
method public long getHeight-XSAIIZE();
- method public androidx.compose.ui.text.PlaceholderVerticalAlign getPlaceholderVerticalAlign();
+ method public int getPlaceholderVerticalAlign-J6kI3mc();
method public long getWidth-XSAIIZE();
property public final long height;
- property public final androidx.compose.ui.text.PlaceholderVerticalAlign placeholderVerticalAlign;
+ property public final int placeholderVerticalAlign;
property public final long width;
}
- public enum PlaceholderVerticalAlign {
- enum_constant public static final androidx.compose.ui.text.PlaceholderVerticalAlign AboveBaseline;
- enum_constant public static final androidx.compose.ui.text.PlaceholderVerticalAlign Bottom;
- enum_constant public static final androidx.compose.ui.text.PlaceholderVerticalAlign Center;
- enum_constant public static final androidx.compose.ui.text.PlaceholderVerticalAlign TextBottom;
- enum_constant public static final androidx.compose.ui.text.PlaceholderVerticalAlign TextCenter;
- enum_constant public static final androidx.compose.ui.text.PlaceholderVerticalAlign TextTop;
- enum_constant public static final androidx.compose.ui.text.PlaceholderVerticalAlign Top;
+ public final inline class PlaceholderVerticalAlign {
+ ctor public PlaceholderVerticalAlign();
+ method public static int constructor-impl(int value);
+ method public static inline boolean equals-impl(int p, Object? p1);
+ method public static boolean equals-impl0(int p1, int p2);
+ method public int getValue();
+ method public static inline int hashCode-impl(int p);
+ method public static String toString-impl(int $this);
+ property public final int value;
+ field public static final androidx.compose.ui.text.PlaceholderVerticalAlign.Companion Companion;
+ }
+
+ public static final class PlaceholderVerticalAlign.Companion {
+ method public int getAboveBaseline-J6kI3mc();
+ method public int getBottom-J6kI3mc();
+ method public int getCenter-J6kI3mc();
+ method public int getTextBottom-J6kI3mc();
+ method public int getTextCenter-J6kI3mc();
+ method public int getTextTop-J6kI3mc();
+ method public int getTop-J6kI3mc();
+ property public final int AboveBaseline;
+ property public final int Bottom;
+ property public final int Center;
+ property public final int TextBottom;
+ property public final int TextCenter;
+ property public final int TextTop;
+ property public final int Top;
}
public final class SaversKt {
diff --git a/compose/ui/ui-text/api/public_plus_experimental_1.0.0-beta08.txt b/compose/ui/ui-text/api/public_plus_experimental_1.0.0-beta08.txt
index 2f0a4c8..7b15f2b 100644
--- a/compose/ui/ui-text/api/public_plus_experimental_1.0.0-beta08.txt
+++ b/compose/ui/ui-text/api/public_plus_experimental_1.0.0-beta08.txt
@@ -231,24 +231,43 @@
}
@androidx.compose.runtime.Immutable public final class Placeholder {
- method public androidx.compose.ui.text.Placeholder copy-KJSDsNM(optional long width, optional long height, optional androidx.compose.ui.text.PlaceholderVerticalAlign placeholderVerticalAlign);
+ method public androidx.compose.ui.text.Placeholder copy-KJSDsNM(optional long width, optional long height, optional int placeholderVerticalAlign);
method public operator boolean equals(Object? other);
method public long getHeight-XSAIIZE();
- method public androidx.compose.ui.text.PlaceholderVerticalAlign getPlaceholderVerticalAlign();
+ method public int getPlaceholderVerticalAlign-J6kI3mc();
method public long getWidth-XSAIIZE();
property public final long height;
- property public final androidx.compose.ui.text.PlaceholderVerticalAlign placeholderVerticalAlign;
+ property public final int placeholderVerticalAlign;
property public final long width;
}
- public enum PlaceholderVerticalAlign {
- enum_constant public static final androidx.compose.ui.text.PlaceholderVerticalAlign AboveBaseline;
- enum_constant public static final androidx.compose.ui.text.PlaceholderVerticalAlign Bottom;
- enum_constant public static final androidx.compose.ui.text.PlaceholderVerticalAlign Center;
- enum_constant public static final androidx.compose.ui.text.PlaceholderVerticalAlign TextBottom;
- enum_constant public static final androidx.compose.ui.text.PlaceholderVerticalAlign TextCenter;
- enum_constant public static final androidx.compose.ui.text.PlaceholderVerticalAlign TextTop;
- enum_constant public static final androidx.compose.ui.text.PlaceholderVerticalAlign Top;
+ public final inline class PlaceholderVerticalAlign {
+ ctor public PlaceholderVerticalAlign();
+ method public static int constructor-impl(int value);
+ method public static inline boolean equals-impl(int p, Object? p1);
+ method public static boolean equals-impl0(int p1, int p2);
+ method public int getValue();
+ method public static inline int hashCode-impl(int p);
+ method public static String toString-impl(int $this);
+ property public final int value;
+ field public static final androidx.compose.ui.text.PlaceholderVerticalAlign.Companion Companion;
+ }
+
+ public static final class PlaceholderVerticalAlign.Companion {
+ method public int getAboveBaseline-J6kI3mc();
+ method public int getBottom-J6kI3mc();
+ method public int getCenter-J6kI3mc();
+ method public int getTextBottom-J6kI3mc();
+ method public int getTextCenter-J6kI3mc();
+ method public int getTextTop-J6kI3mc();
+ method public int getTop-J6kI3mc();
+ property public final int AboveBaseline;
+ property public final int Bottom;
+ property public final int Center;
+ property public final int TextBottom;
+ property public final int TextCenter;
+ property public final int TextTop;
+ property public final int Top;
}
public final class SaversKt {
diff --git a/compose/ui/ui-text/api/public_plus_experimental_current.txt b/compose/ui/ui-text/api/public_plus_experimental_current.txt
index 2f0a4c8..7b15f2b 100644
--- a/compose/ui/ui-text/api/public_plus_experimental_current.txt
+++ b/compose/ui/ui-text/api/public_plus_experimental_current.txt
@@ -231,24 +231,43 @@
}
@androidx.compose.runtime.Immutable public final class Placeholder {
- method public androidx.compose.ui.text.Placeholder copy-KJSDsNM(optional long width, optional long height, optional androidx.compose.ui.text.PlaceholderVerticalAlign placeholderVerticalAlign);
+ method public androidx.compose.ui.text.Placeholder copy-KJSDsNM(optional long width, optional long height, optional int placeholderVerticalAlign);
method public operator boolean equals(Object? other);
method public long getHeight-XSAIIZE();
- method public androidx.compose.ui.text.PlaceholderVerticalAlign getPlaceholderVerticalAlign();
+ method public int getPlaceholderVerticalAlign-J6kI3mc();
method public long getWidth-XSAIIZE();
property public final long height;
- property public final androidx.compose.ui.text.PlaceholderVerticalAlign placeholderVerticalAlign;
+ property public final int placeholderVerticalAlign;
property public final long width;
}
- public enum PlaceholderVerticalAlign {
- enum_constant public static final androidx.compose.ui.text.PlaceholderVerticalAlign AboveBaseline;
- enum_constant public static final androidx.compose.ui.text.PlaceholderVerticalAlign Bottom;
- enum_constant public static final androidx.compose.ui.text.PlaceholderVerticalAlign Center;
- enum_constant public static final androidx.compose.ui.text.PlaceholderVerticalAlign TextBottom;
- enum_constant public static final androidx.compose.ui.text.PlaceholderVerticalAlign TextCenter;
- enum_constant public static final androidx.compose.ui.text.PlaceholderVerticalAlign TextTop;
- enum_constant public static final androidx.compose.ui.text.PlaceholderVerticalAlign Top;
+ public final inline class PlaceholderVerticalAlign {
+ ctor public PlaceholderVerticalAlign();
+ method public static int constructor-impl(int value);
+ method public static inline boolean equals-impl(int p, Object? p1);
+ method public static boolean equals-impl0(int p1, int p2);
+ method public int getValue();
+ method public static inline int hashCode-impl(int p);
+ method public static String toString-impl(int $this);
+ property public final int value;
+ field public static final androidx.compose.ui.text.PlaceholderVerticalAlign.Companion Companion;
+ }
+
+ public static final class PlaceholderVerticalAlign.Companion {
+ method public int getAboveBaseline-J6kI3mc();
+ method public int getBottom-J6kI3mc();
+ method public int getCenter-J6kI3mc();
+ method public int getTextBottom-J6kI3mc();
+ method public int getTextCenter-J6kI3mc();
+ method public int getTextTop-J6kI3mc();
+ method public int getTop-J6kI3mc();
+ property public final int AboveBaseline;
+ property public final int Bottom;
+ property public final int Center;
+ property public final int TextBottom;
+ property public final int TextCenter;
+ property public final int TextTop;
+ property public final int Top;
}
public final class SaversKt {
diff --git a/compose/ui/ui-text/api/restricted_1.0.0-beta08.txt b/compose/ui/ui-text/api/restricted_1.0.0-beta08.txt
index d0abc49..d50cd19 100644
--- a/compose/ui/ui-text/api/restricted_1.0.0-beta08.txt
+++ b/compose/ui/ui-text/api/restricted_1.0.0-beta08.txt
@@ -222,24 +222,43 @@
}
@androidx.compose.runtime.Immutable public final class Placeholder {
- method public androidx.compose.ui.text.Placeholder copy-KJSDsNM(optional long width, optional long height, optional androidx.compose.ui.text.PlaceholderVerticalAlign placeholderVerticalAlign);
+ method public androidx.compose.ui.text.Placeholder copy-KJSDsNM(optional long width, optional long height, optional int placeholderVerticalAlign);
method public operator boolean equals(Object? other);
method public long getHeight-XSAIIZE();
- method public androidx.compose.ui.text.PlaceholderVerticalAlign getPlaceholderVerticalAlign();
+ method public int getPlaceholderVerticalAlign-J6kI3mc();
method public long getWidth-XSAIIZE();
property public final long height;
- property public final androidx.compose.ui.text.PlaceholderVerticalAlign placeholderVerticalAlign;
+ property public final int placeholderVerticalAlign;
property public final long width;
}
- public enum PlaceholderVerticalAlign {
- enum_constant public static final androidx.compose.ui.text.PlaceholderVerticalAlign AboveBaseline;
- enum_constant public static final androidx.compose.ui.text.PlaceholderVerticalAlign Bottom;
- enum_constant public static final androidx.compose.ui.text.PlaceholderVerticalAlign Center;
- enum_constant public static final androidx.compose.ui.text.PlaceholderVerticalAlign TextBottom;
- enum_constant public static final androidx.compose.ui.text.PlaceholderVerticalAlign TextCenter;
- enum_constant public static final androidx.compose.ui.text.PlaceholderVerticalAlign TextTop;
- enum_constant public static final androidx.compose.ui.text.PlaceholderVerticalAlign Top;
+ public final inline class PlaceholderVerticalAlign {
+ ctor public PlaceholderVerticalAlign();
+ method public static int constructor-impl(int value);
+ method public static inline boolean equals-impl(int p, Object? p1);
+ method public static boolean equals-impl0(int p1, int p2);
+ method public int getValue();
+ method public static inline int hashCode-impl(int p);
+ method public static String toString-impl(int $this);
+ property public final int value;
+ field public static final androidx.compose.ui.text.PlaceholderVerticalAlign.Companion Companion;
+ }
+
+ public static final class PlaceholderVerticalAlign.Companion {
+ method public int getAboveBaseline-J6kI3mc();
+ method public int getBottom-J6kI3mc();
+ method public int getCenter-J6kI3mc();
+ method public int getTextBottom-J6kI3mc();
+ method public int getTextCenter-J6kI3mc();
+ method public int getTextTop-J6kI3mc();
+ method public int getTop-J6kI3mc();
+ property public final int AboveBaseline;
+ property public final int Bottom;
+ property public final int Center;
+ property public final int TextBottom;
+ property public final int TextCenter;
+ property public final int TextTop;
+ property public final int Top;
}
public final class SaversKt {
diff --git a/compose/ui/ui-text/api/restricted_current.ignore b/compose/ui/ui-text/api/restricted_current.ignore
index 5bb1213..221b006 100644
--- a/compose/ui/ui-text/api/restricted_current.ignore
+++ b/compose/ui/ui-text/api/restricted_current.ignore
@@ -3,6 +3,8 @@
Added method androidx.compose.ui.text.input.InputEventCallback.onImeAction-KlQnJC8(int)
+ChangedSuperclass: androidx.compose.ui.text.PlaceholderVerticalAlign:
+ Class androidx.compose.ui.text.PlaceholderVerticalAlign superclass changed from java.lang.Enum to java.lang.Object
ChangedSuperclass: androidx.compose.ui.text.input.ImeAction:
Class androidx.compose.ui.text.input.ImeAction superclass changed from java.lang.Enum to java.lang.Object
ChangedSuperclass: androidx.compose.ui.text.input.KeyboardType:
@@ -13,6 +15,8 @@
Attempted to remove @NonNull annotation from Field ImeOptions.imeAction
InvalidNullConversion: Field ImeOptions.keyboardType:
Attempted to remove @NonNull annotation from Field ImeOptions.keyboardType
+InvalidNullConversion: Field Placeholder.placeholderVerticalAlign:
+ Attempted to remove @NonNull annotation from Field Placeholder.placeholderVerticalAlign
RemovedClass: androidx.compose.ui.text.JvmCharHelpers_jvmKt:
@@ -23,6 +27,20 @@
Removed deprecated method androidx.compose.ui.text.input.InputEventCallback.onImeAction(androidx.compose.ui.text.input.ImeAction)
+RemovedField: androidx.compose.ui.text.PlaceholderVerticalAlign#AboveBaseline:
+ Removed enum constant androidx.compose.ui.text.PlaceholderVerticalAlign.AboveBaseline
+RemovedField: androidx.compose.ui.text.PlaceholderVerticalAlign#Bottom:
+ Removed enum constant androidx.compose.ui.text.PlaceholderVerticalAlign.Bottom
+RemovedField: androidx.compose.ui.text.PlaceholderVerticalAlign#Center:
+ Removed enum constant androidx.compose.ui.text.PlaceholderVerticalAlign.Center
+RemovedField: androidx.compose.ui.text.PlaceholderVerticalAlign#TextBottom:
+ Removed enum constant androidx.compose.ui.text.PlaceholderVerticalAlign.TextBottom
+RemovedField: androidx.compose.ui.text.PlaceholderVerticalAlign#TextCenter:
+ Removed enum constant androidx.compose.ui.text.PlaceholderVerticalAlign.TextCenter
+RemovedField: androidx.compose.ui.text.PlaceholderVerticalAlign#TextTop:
+ Removed enum constant androidx.compose.ui.text.PlaceholderVerticalAlign.TextTop
+RemovedField: androidx.compose.ui.text.PlaceholderVerticalAlign#Top:
+ Removed enum constant androidx.compose.ui.text.PlaceholderVerticalAlign.Top
RemovedField: androidx.compose.ui.text.input.ImeAction#Default:
Removed enum constant androidx.compose.ui.text.input.ImeAction.Default
RemovedField: androidx.compose.ui.text.input.ImeAction#Done:
@@ -57,6 +75,10 @@
Removed enum constant androidx.compose.ui.text.input.KeyboardType.Uri
+RemovedMethod: androidx.compose.ui.text.Placeholder#copy-KJSDsNM(long, long, androidx.compose.ui.text.PlaceholderVerticalAlign):
+ Removed method androidx.compose.ui.text.Placeholder.copy-KJSDsNM(long,long,androidx.compose.ui.text.PlaceholderVerticalAlign)
+RemovedMethod: androidx.compose.ui.text.Placeholder#getPlaceholderVerticalAlign():
+ Removed method androidx.compose.ui.text.Placeholder.getPlaceholderVerticalAlign()
RemovedMethod: androidx.compose.ui.text.input.ImeOptions#ImeOptions(boolean, androidx.compose.ui.text.input.KeyboardCapitalization, boolean, androidx.compose.ui.text.input.KeyboardType, androidx.compose.ui.text.input.ImeAction):
Removed constructor androidx.compose.ui.text.input.ImeOptions(boolean,androidx.compose.ui.text.input.KeyboardCapitalization,boolean,androidx.compose.ui.text.input.KeyboardType,androidx.compose.ui.text.input.ImeAction)
RemovedMethod: androidx.compose.ui.text.input.ImeOptions#copy(boolean, androidx.compose.ui.text.input.KeyboardCapitalization, boolean, androidx.compose.ui.text.input.KeyboardType, androidx.compose.ui.text.input.ImeAction):
diff --git a/compose/ui/ui-text/api/restricted_current.txt b/compose/ui/ui-text/api/restricted_current.txt
index d0abc49..d50cd19 100644
--- a/compose/ui/ui-text/api/restricted_current.txt
+++ b/compose/ui/ui-text/api/restricted_current.txt
@@ -222,24 +222,43 @@
}
@androidx.compose.runtime.Immutable public final class Placeholder {
- method public androidx.compose.ui.text.Placeholder copy-KJSDsNM(optional long width, optional long height, optional androidx.compose.ui.text.PlaceholderVerticalAlign placeholderVerticalAlign);
+ method public androidx.compose.ui.text.Placeholder copy-KJSDsNM(optional long width, optional long height, optional int placeholderVerticalAlign);
method public operator boolean equals(Object? other);
method public long getHeight-XSAIIZE();
- method public androidx.compose.ui.text.PlaceholderVerticalAlign getPlaceholderVerticalAlign();
+ method public int getPlaceholderVerticalAlign-J6kI3mc();
method public long getWidth-XSAIIZE();
property public final long height;
- property public final androidx.compose.ui.text.PlaceholderVerticalAlign placeholderVerticalAlign;
+ property public final int placeholderVerticalAlign;
property public final long width;
}
- public enum PlaceholderVerticalAlign {
- enum_constant public static final androidx.compose.ui.text.PlaceholderVerticalAlign AboveBaseline;
- enum_constant public static final androidx.compose.ui.text.PlaceholderVerticalAlign Bottom;
- enum_constant public static final androidx.compose.ui.text.PlaceholderVerticalAlign Center;
- enum_constant public static final androidx.compose.ui.text.PlaceholderVerticalAlign TextBottom;
- enum_constant public static final androidx.compose.ui.text.PlaceholderVerticalAlign TextCenter;
- enum_constant public static final androidx.compose.ui.text.PlaceholderVerticalAlign TextTop;
- enum_constant public static final androidx.compose.ui.text.PlaceholderVerticalAlign Top;
+ public final inline class PlaceholderVerticalAlign {
+ ctor public PlaceholderVerticalAlign();
+ method public static int constructor-impl(int value);
+ method public static inline boolean equals-impl(int p, Object? p1);
+ method public static boolean equals-impl0(int p1, int p2);
+ method public int getValue();
+ method public static inline int hashCode-impl(int p);
+ method public static String toString-impl(int $this);
+ property public final int value;
+ field public static final androidx.compose.ui.text.PlaceholderVerticalAlign.Companion Companion;
+ }
+
+ public static final class PlaceholderVerticalAlign.Companion {
+ method public int getAboveBaseline-J6kI3mc();
+ method public int getBottom-J6kI3mc();
+ method public int getCenter-J6kI3mc();
+ method public int getTextBottom-J6kI3mc();
+ method public int getTextCenter-J6kI3mc();
+ method public int getTextTop-J6kI3mc();
+ method public int getTop-J6kI3mc();
+ property public final int AboveBaseline;
+ property public final int Bottom;
+ property public final int Center;
+ property public final int TextBottom;
+ property public final int TextCenter;
+ property public final int TextTop;
+ property public final int Top;
}
public final class SaversKt {
diff --git a/compose/ui/ui-text/benchmark/lint-baseline.xml b/compose/ui/ui-text/benchmark/lint-baseline.xml
index 42a176b..cab51d3 100644
--- a/compose/ui/ui-text/benchmark/lint-baseline.xml
+++ b/compose/ui/ui-text/benchmark/lint-baseline.xml
@@ -1,4 +1,15 @@
<?xml version="1.0" encoding="UTF-8"?>
<issues format="6" by="lint 7.0.0-alpha15" type="baseline" client="cli" name="Lint" variant="all" version="7.0.0-alpha15">
+ <issue
+ id="BanUncheckedReflection"
+ message="Calling Method.invoke without an SDK check"
+ errorLine1=" freeCaches.invoke(null)"
+ errorLine2=" ~~~~~~~~~~~~~~~~~~~~~~~">
+ <location
+ file="src/main/java/androidx/compose/ui/text/benchmark/TextBenchmarkTestRule.kt"
+ line="81"
+ column="13"/>
+ </issue>
+
</issues>
diff --git a/compose/ui/ui-text/src/androidMain/kotlin/androidx/compose/ui/text/platform/extensions/PlaceholderExtensions.android.kt b/compose/ui/ui-text/src/androidMain/kotlin/androidx/compose/ui/text/platform/extensions/PlaceholderExtensions.android.kt
index ee998a9..94d26db 100644
--- a/compose/ui/ui-text/src/androidMain/kotlin/androidx/compose/ui/text/platform/extensions/PlaceholderExtensions.android.kt
+++ b/compose/ui/ui-text/src/androidMain/kotlin/androidx/compose/ui/text/platform/extensions/PlaceholderExtensions.android.kt
@@ -84,4 +84,5 @@
PlaceholderVerticalAlign.TextTop -> PlaceholderSpan.ALIGN_TEXT_TOP
PlaceholderVerticalAlign.TextBottom -> PlaceholderSpan.ALIGN_TEXT_BOTTOM
PlaceholderVerticalAlign.TextCenter -> PlaceholderSpan.ALIGN_TEXT_CENTER
+ else -> error("Invalid PlaceholderVerticalAlign")
}
diff --git a/compose/ui/ui-text/src/commonMain/kotlin/androidx/compose/ui/text/Placeholder.kt b/compose/ui/ui-text/src/commonMain/kotlin/androidx/compose/ui/text/Placeholder.kt
index cf6b935..eca4d3d 100644
--- a/compose/ui/ui-text/src/commonMain/kotlin/androidx/compose/ui/text/Placeholder.kt
+++ b/compose/ui/ui-text/src/commonMain/kotlin/androidx/compose/ui/text/Placeholder.kt
@@ -84,34 +84,51 @@
* The settings used to specify how a placeholder is vertically aligned within a text line.
* @see Placeholder
*/
-enum class PlaceholderVerticalAlign {
- /** Align the bottom of the placeholder with the baseline. */
- AboveBaseline,
- /** Align the top of the placeholder with the top of the entire line. */
- Top,
- /** Align the bottom of the placeholder with the bottom of the entire line. */
- Bottom,
- /** Align the center of the placeholder with the center of the entire line. */
- Center,
- /**
- * Align the top of the placeholder with the top of the proceeding text.
- * It is different from the [Top] when there are texts with different font size, font or other
- * styles in the same line. This option will use the proceeding text's top instead of the
- * whole line's top.
- */
- TextTop,
- /**
- * Align the bottom of the placeholder with the bottom of the proceeding text.
- * It is different from the [TextBottom] when there are texts with different font size, font or
- * other styles in the same line. This option will use the proceeding text's bottom instead of
- * the whole line's bottom.
- */
- TextBottom,
- /**
- * Align the center of the placeholder with the center of the proceeding text.
- * It is different from the [Center] when there are texts with different font size, font or
- * other styles in the same line. This option will use the proceeding text's center instead of
- * the whole line's center.
- */
- TextCenter,
+@Suppress("INLINE_CLASS_DEPRECATED")
+inline class PlaceholderVerticalAlign(val value: Int) {
+
+ override fun toString(): String {
+ return when (this) {
+ AboveBaseline -> "AboveBaseline"
+ Top -> "Top"
+ Bottom -> "Bottom"
+ Center -> "Center"
+ TextTop -> "TextTop"
+ TextBottom -> "TextBottom"
+ TextCenter -> "TextCenter"
+ else -> "Invalid"
+ }
+ }
+
+ companion object {
+ /** Align the bottom of the placeholder with the baseline. */
+ val AboveBaseline = PlaceholderVerticalAlign(1)
+ /** Align the top of the placeholder with the top of the entire line. */
+ val Top = PlaceholderVerticalAlign(2)
+ /** Align the bottom of the placeholder with the bottom of the entire line. */
+ val Bottom = PlaceholderVerticalAlign(3)
+ /** Align the center of the placeholder with the center of the entire line. */
+ val Center = PlaceholderVerticalAlign(4)
+ /**
+ * Align the top of the placeholder with the top of the proceeding text.
+ * It is different from the [Top] when there are texts with different font size, font or other
+ * styles in the same line. This option will use the proceeding text's top instead of the
+ * whole line's top.
+ */
+ val TextTop = PlaceholderVerticalAlign(5)
+ /**
+ * Align the bottom of the placeholder with the bottom of the proceeding text.
+ * It is different from the [TextBottom] when there are texts with different font size, font or
+ * other styles in the same line. This option will use the proceeding text's bottom instead of
+ * the whole line's bottom.
+ */
+ val TextBottom = PlaceholderVerticalAlign(6)
+ /**
+ * Align the center of the placeholder with the center of the proceeding text.
+ * It is different from the [Center] when there are texts with different font size, font or
+ * other styles in the same line. This option will use the proceeding text's center instead of
+ * the whole line's center.
+ */
+ val TextCenter = PlaceholderVerticalAlign(7)
+ }
}
\ No newline at end of file
diff --git a/compose/ui/ui-text/src/desktopMain/kotlin/androidx/compose/ui/text/platform/DesktopParagraph.desktop.kt b/compose/ui/ui-text/src/desktopMain/kotlin/androidx/compose/ui/text/platform/DesktopParagraph.desktop.kt
index 5934cd7..9105a83 100644
--- a/compose/ui/ui-text/src/desktopMain/kotlin/androidx/compose/ui/text/platform/DesktopParagraph.desktop.kt
+++ b/compose/ui/ui-text/src/desktopMain/kotlin/androidx/compose/ui/text/platform/DesktopParagraph.desktop.kt
@@ -866,6 +866,7 @@
PlaceholderVerticalAlign.Top -> PlaceholderAlignment.TOP
PlaceholderVerticalAlign.Bottom -> PlaceholderAlignment.BOTTOM
PlaceholderVerticalAlign.Center -> PlaceholderAlignment.MIDDLE
+ else -> error("Invalid PlaceholderVerticalAlign.")
}
}
diff --git a/compose/ui/ui-tooling-data/src/main/java/androidx/compose/ui/tooling/data/SlotTree.kt b/compose/ui/ui-tooling-data/src/main/java/androidx/compose/ui/tooling/data/SlotTree.kt
index 0817e3f..9a00966 100644
--- a/compose/ui/ui-tooling-data/src/main/java/androidx/compose/ui/tooling/data/SlotTree.kt
+++ b/compose/ui/ui-tooling-data/src/main/java/androidx/compose/ui/tooling/data/SlotTree.kt
@@ -432,7 +432,7 @@
return SourceInformationContext(
name = name,
sourceFile = sourceFile ?: parent?.sourceFile,
- packageHash = packageHash,
+ packageHash = if (sourceFile != null) packageHash else parent?.packageHash ?: packageHash,
locations = sourceLocations,
repeatOffset = repeatOffset,
parameters = parameters,
diff --git a/compose/ui/ui-tooling/lint-baseline.xml b/compose/ui/ui-tooling/lint-baseline.xml
index 42a176b..9d72f7c 100644
--- a/compose/ui/ui-tooling/lint-baseline.xml
+++ b/compose/ui/ui-tooling/lint-baseline.xml
@@ -1,4 +1,37 @@
<?xml version="1.0" encoding="UTF-8"?>
<issues format="6" by="lint 7.0.0-alpha15" type="baseline" client="cli" name="Lint" variant="all" version="7.0.0-alpha15">
+ <issue
+ id="BanUncheckedReflection"
+ message="Calling Method.invoke without an SDK check"
+ errorLine1=" val result = designInfoMethod.invoke("
+ errorLine2=" ^">
+ <location
+ file="src/main/java/androidx/compose/ui/tooling/preview/ComposeViewAdapter.kt"
+ line="384"
+ column="30"/>
+ </issue>
+
+ <issue
+ id="BanUncheckedReflection"
+ message="Calling Method.invoke without an SDK check"
+ errorLine1=" return invoke(instance, *arguments)"
+ errorLine2=" ~~~~~~~~~~~~~~~~~~~~~~~~~~~~">
+ <location
+ file="src/main/java/androidx/compose/ui/tooling/preview/PreviewUtils.kt"
+ line="141"
+ column="12"/>
+ </issue>
+
+ <issue
+ id="ClassVerificationFailure"
+ message="This call references a method added in API level 26; however, the containing class androidx.compose.ui.tooling.preview.LayoutlibFontResourceLoader is reachable from earlier API levels and will fail run-time class verification."
+ errorLine1=" is ResourceFont -> context.resources.getFont(font.resId)"
+ errorLine2=" ~~~~~~~">
+ <location
+ file="src/main/java/androidx/compose/ui/tooling/preview/LayoutlibFontResourceLoader.kt"
+ line="33"
+ column="50"/>
+ </issue>
+
</issues>
diff --git a/compose/ui/ui/api/1.0.0-beta08.txt b/compose/ui/ui/api/1.0.0-beta08.txt
index ef6a13d..fa7c70b 100644
--- a/compose/ui/ui/api/1.0.0-beta08.txt
+++ b/compose/ui/ui/api/1.0.0-beta08.txt
@@ -276,7 +276,7 @@
}
public interface FocusManager {
- method public void clearFocus(optional boolean forcedClear);
+ method public void clearFocus(optional boolean force);
method public boolean moveFocus-3ESFkO8(int focusDirection);
}
diff --git a/compose/ui/ui/api/current.ignore b/compose/ui/ui/api/current.ignore
index f30e81b..209860c 100644
--- a/compose/ui/ui/api/current.ignore
+++ b/compose/ui/ui/api/current.ignore
@@ -53,6 +53,8 @@
Attempted to remove @NonNull annotation from method androidx.compose.ui.semantics.SemanticsPropertiesKt.getImeAction(androidx.compose.ui.semantics.SemanticsPropertyReceiver)
+ParameterNameChange: androidx.compose.ui.focus.FocusManager#clearFocus(boolean) parameter #0:
+ Attempted to change parameter name from forcedClear to force in method androidx.compose.ui.focus.FocusManager.clearFocus
ParameterNameChange: androidx.compose.ui.semantics.SemanticsPropertiesKt#setContentDescription(androidx.compose.ui.semantics.SemanticsPropertyReceiver, String) parameter #1:
Attempted to change parameter name from p to value in method androidx.compose.ui.semantics.SemanticsPropertiesKt.setContentDescription
ParameterNameChange: androidx.compose.ui.semantics.SemanticsPropertiesKt#setText(androidx.compose.ui.semantics.SemanticsPropertyReceiver, androidx.compose.ui.text.AnnotatedString) parameter #1:
diff --git a/compose/ui/ui/api/current.txt b/compose/ui/ui/api/current.txt
index ef6a13d..fa7c70b 100644
--- a/compose/ui/ui/api/current.txt
+++ b/compose/ui/ui/api/current.txt
@@ -276,7 +276,7 @@
}
public interface FocusManager {
- method public void clearFocus(optional boolean forcedClear);
+ method public void clearFocus(optional boolean force);
method public boolean moveFocus-3ESFkO8(int focusDirection);
}
diff --git a/compose/ui/ui/api/public_plus_experimental_1.0.0-beta08.txt b/compose/ui/ui/api/public_plus_experimental_1.0.0-beta08.txt
index e989440..22062ae 100644
--- a/compose/ui/ui/api/public_plus_experimental_1.0.0-beta08.txt
+++ b/compose/ui/ui/api/public_plus_experimental_1.0.0-beta08.txt
@@ -347,7 +347,7 @@
}
public interface FocusManager {
- method public void clearFocus(optional boolean forcedClear);
+ method public void clearFocus(optional boolean force);
method public boolean moveFocus-3ESFkO8(int focusDirection);
method @Deprecated @androidx.compose.ui.ExperimentalComposeUiApi public default boolean moveFocusIn();
method @Deprecated @androidx.compose.ui.ExperimentalComposeUiApi public default boolean moveFocusOut();
@@ -1849,7 +1849,7 @@
@androidx.compose.ui.ExperimentalComposeUiApi public final class RelocationRequester {
ctor public RelocationRequester();
- method public void bringIntoParentBounds();
+ method public void bringIntoView();
}
public final class RelocationRequesterModifierKt {
diff --git a/compose/ui/ui/api/public_plus_experimental_current.txt b/compose/ui/ui/api/public_plus_experimental_current.txt
index e989440..22062ae 100644
--- a/compose/ui/ui/api/public_plus_experimental_current.txt
+++ b/compose/ui/ui/api/public_plus_experimental_current.txt
@@ -347,7 +347,7 @@
}
public interface FocusManager {
- method public void clearFocus(optional boolean forcedClear);
+ method public void clearFocus(optional boolean force);
method public boolean moveFocus-3ESFkO8(int focusDirection);
method @Deprecated @androidx.compose.ui.ExperimentalComposeUiApi public default boolean moveFocusIn();
method @Deprecated @androidx.compose.ui.ExperimentalComposeUiApi public default boolean moveFocusOut();
@@ -1849,7 +1849,7 @@
@androidx.compose.ui.ExperimentalComposeUiApi public final class RelocationRequester {
ctor public RelocationRequester();
- method public void bringIntoParentBounds();
+ method public void bringIntoView();
}
public final class RelocationRequesterModifierKt {
diff --git a/compose/ui/ui/api/restricted_1.0.0-beta08.txt b/compose/ui/ui/api/restricted_1.0.0-beta08.txt
index 7938cd4..60cf61c 100644
--- a/compose/ui/ui/api/restricted_1.0.0-beta08.txt
+++ b/compose/ui/ui/api/restricted_1.0.0-beta08.txt
@@ -276,7 +276,7 @@
}
public interface FocusManager {
- method public void clearFocus(optional boolean forcedClear);
+ method public void clearFocus(optional boolean force);
method public boolean moveFocus-3ESFkO8(int focusDirection);
}
diff --git a/compose/ui/ui/api/restricted_current.ignore b/compose/ui/ui/api/restricted_current.ignore
index f30e81b..209860c 100644
--- a/compose/ui/ui/api/restricted_current.ignore
+++ b/compose/ui/ui/api/restricted_current.ignore
@@ -53,6 +53,8 @@
Attempted to remove @NonNull annotation from method androidx.compose.ui.semantics.SemanticsPropertiesKt.getImeAction(androidx.compose.ui.semantics.SemanticsPropertyReceiver)
+ParameterNameChange: androidx.compose.ui.focus.FocusManager#clearFocus(boolean) parameter #0:
+ Attempted to change parameter name from forcedClear to force in method androidx.compose.ui.focus.FocusManager.clearFocus
ParameterNameChange: androidx.compose.ui.semantics.SemanticsPropertiesKt#setContentDescription(androidx.compose.ui.semantics.SemanticsPropertyReceiver, String) parameter #1:
Attempted to change parameter name from p to value in method androidx.compose.ui.semantics.SemanticsPropertiesKt.setContentDescription
ParameterNameChange: androidx.compose.ui.semantics.SemanticsPropertiesKt#setText(androidx.compose.ui.semantics.SemanticsPropertyReceiver, androidx.compose.ui.text.AnnotatedString) parameter #1:
diff --git a/compose/ui/ui/api/restricted_current.txt b/compose/ui/ui/api/restricted_current.txt
index 7938cd4..60cf61c 100644
--- a/compose/ui/ui/api/restricted_current.txt
+++ b/compose/ui/ui/api/restricted_current.txt
@@ -276,7 +276,7 @@
}
public interface FocusManager {
- method public void clearFocus(optional boolean forcedClear);
+ method public void clearFocus(optional boolean force);
method public boolean moveFocus-3ESFkO8(int focusDirection);
}
diff --git a/compose/ui/ui/integration-tests/ui-demos/src/main/java/androidx/compose/ui/demos/UiDemos.kt b/compose/ui/ui/integration-tests/ui-demos/src/main/java/androidx/compose/ui/demos/UiDemos.kt
index 16d5c82..7914fe1 100644
--- a/compose/ui/ui/integration-tests/ui-demos/src/main/java/androidx/compose/ui/demos/UiDemos.kt
+++ b/compose/ui/ui/integration-tests/ui-demos/src/main/java/androidx/compose/ui/demos/UiDemos.kt
@@ -47,8 +47,9 @@
import androidx.compose.ui.demos.gestures.ScaleGestureFilterDemo
import androidx.compose.ui.demos.gestures.ScrollGestureFilterDemo
import androidx.compose.ui.demos.gestures.VerticalScrollerInDrawerDemo
-import androidx.compose.ui.demos.input.nestedscroll.BringIntoParentBoundsDemo
+import androidx.compose.ui.demos.input.nestedscroll.BringIntoViewDemo
import androidx.compose.ui.demos.keyinput.KeyInputDemo
+import androidx.compose.ui.demos.scroll.RequestRectangleOnScreenDemo
import androidx.compose.ui.demos.viewinterop.ViewInteropDemo
import androidx.compose.ui.samples.NestedScrollConnectionSample
@@ -128,7 +129,8 @@
private val RelocationDemos = DemoCategory(
"Relocation",
listOf(
- ComposableDemo("Bring Item Into View") { BringIntoParentBoundsDemo() }
+ ComposableDemo("Bring Into View") { BringIntoViewDemo() },
+ ComposableDemo("Request Rectangle On Screen") { RequestRectangleOnScreenDemo() }
)
)
diff --git a/compose/ui/ui/integration-tests/ui-demos/src/main/java/androidx/compose/ui/demos/scroll/BringIntoParentBoundsDemo.kt b/compose/ui/ui/integration-tests/ui-demos/src/main/java/androidx/compose/ui/demos/scroll/BringIntoViewDemo.kt
similarity index 93%
rename from compose/ui/ui/integration-tests/ui-demos/src/main/java/androidx/compose/ui/demos/scroll/BringIntoParentBoundsDemo.kt
rename to compose/ui/ui/integration-tests/ui-demos/src/main/java/androidx/compose/ui/demos/scroll/BringIntoViewDemo.kt
index bc44376..d86d786 100644
--- a/compose/ui/ui/integration-tests/ui-demos/src/main/java/androidx/compose/ui/demos/scroll/BringIntoParentBoundsDemo.kt
+++ b/compose/ui/ui/integration-tests/ui-demos/src/main/java/androidx/compose/ui/demos/scroll/BringIntoViewDemo.kt
@@ -42,7 +42,7 @@
@OptIn(ExperimentalComposeUiApi::class)
@Composable
-fun BringIntoParentBoundsDemo() {
+fun BringIntoViewDemo() {
val greenRequester = remember { RelocationRequester() }
val redRequester = remember { RelocationRequester() }
Column {
@@ -54,10 +54,10 @@
Box(Modifier.background(Red).size(100.dp).relocationRequester(redRequester))
Box(Modifier.background(LightGray).size(100.dp))
}
- Button(onClick = { greenRequester.bringIntoParentBounds() }) {
+ Button(onClick = { greenRequester.bringIntoView() }) {
Text("Bring Green box into view")
}
- Button(onClick = { redRequester.bringIntoParentBounds() }) {
+ Button(onClick = { redRequester.bringIntoView() }) {
Text("Bring Red box into view")
}
}
diff --git a/compose/ui/ui/integration-tests/ui-demos/src/main/java/androidx/compose/ui/demos/scroll/RequestRectangleOnScreeenDemo.kt b/compose/ui/ui/integration-tests/ui-demos/src/main/java/androidx/compose/ui/demos/scroll/RequestRectangleOnScreeenDemo.kt
new file mode 100644
index 0000000..c94d797
--- /dev/null
+++ b/compose/ui/ui/integration-tests/ui-demos/src/main/java/androidx/compose/ui/demos/scroll/RequestRectangleOnScreeenDemo.kt
@@ -0,0 +1,53 @@
+/*
+ * Copyright 2021 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.compose.ui.demos.scroll
+
+import androidx.compose.foundation.background
+import androidx.compose.foundation.layout.Box
+import androidx.compose.foundation.layout.Column
+import androidx.compose.foundation.layout.Spacer
+import androidx.compose.foundation.layout.size
+import androidx.compose.material.Button
+import androidx.compose.material.Text
+import androidx.compose.material.TextField
+import androidx.compose.runtime.Composable
+import androidx.compose.runtime.remember
+import androidx.compose.ui.ExperimentalComposeUiApi
+import androidx.compose.ui.Modifier
+import androidx.compose.ui.graphics.Color
+import androidx.compose.ui.layout.RelocationRequester
+import androidx.compose.ui.layout.relocationRequester
+import androidx.compose.ui.unit.dp
+
+@OptIn(ExperimentalComposeUiApi::class)
+@Composable
+fun RequestRectangleOnScreenDemo() {
+ val relocationRequester = remember { RelocationRequester() }
+ Column {
+ TextField(value = "Click here to bring up the soft keyboard", onValueChange = {})
+ Button(onClick = { relocationRequester.bringIntoView() }) {
+ Text("Bring blue rectangle into view")
+ }
+ Spacer(Modifier.weight(weight = 1f, fill = true))
+ Box(
+ Modifier
+ .size(50.dp)
+ .background(Color.Blue)
+ .relocationRequester(relocationRequester)
+ )
+ }
+}
diff --git a/compose/ui/ui/lint-baseline.xml b/compose/ui/ui/lint-baseline.xml
index b75d649..b2f4c19 100644
--- a/compose/ui/ui/lint-baseline.xml
+++ b/compose/ui/ui/lint-baseline.xml
@@ -12,4 +12,70 @@
column="63"/>
</issue>
+ <issue
+ id="BanUncheckedReflection"
+ message="Calling Method.invoke without an SDK check"
+ errorLine1=" updateDisplayListIfDirtyMethod?.invoke(view)"
+ errorLine2=" ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~">
+ <location
+ file="src/androidMain/kotlin/androidx/compose/ui/platform/ViewLayer.android.kt"
+ line="337"
+ column="17"/>
+ </issue>
+
+ <issue
+ id="ClassVerificationFailure"
+ message="This call references a method added in API level 26; however, the containing class androidx.compose.ui.autofill.AndroidAutofillDebugUtils_androidKt is reachable from earlier API levels and will fail run-time class verification."
+ errorLine1=" autofillManager.registerCallback(AutofillCallback)"
+ errorLine2=" ~~~~~~~~~~~~~~~~">
+ <location
+ file="src/androidMain/kotlin/androidx/compose/ui/autofill/AndroidAutofillDebugUtils.android.kt"
+ line="67"
+ column="21"/>
+ </issue>
+
+ <issue
+ id="ClassVerificationFailure"
+ message="This call references a method added in API level 26; however, the containing class androidx.compose.ui.autofill.AndroidAutofillDebugUtils_androidKt is reachable from earlier API levels and will fail run-time class verification."
+ errorLine1=" autofillManager.unregisterCallback(AutofillCallback)"
+ errorLine2=" ~~~~~~~~~~~~~~~~~~">
+ <location
+ file="src/androidMain/kotlin/androidx/compose/ui/autofill/AndroidAutofillDebugUtils.android.kt"
+ line="77"
+ column="21"/>
+ </issue>
+
+ <issue
+ id="ClassVerificationFailure"
+ message="This call references a method added in API level 23; however, the containing class androidx.compose.ui.res.ColorResources_androidKt is reachable from earlier API levels and will fail run-time class verification."
+ errorLine1=" Color(context.resources.getColor(id, context.theme))"
+ errorLine2=" ~~~~~~~~">
+ <location
+ file="src/androidMain/kotlin/androidx/compose/ui/res/ColorResources.android.kt"
+ line="37"
+ column="33"/>
+ </issue>
+
+ <issue
+ id="ClassVerificationFailure"
+ message="This call references a method added in API level 29; however, the containing class androidx.compose.ui.input.pointer.MotionEventAdapter_androidKt is reachable from earlier API levels and will fail run-time class verification."
+ errorLine1=" return Offset(getRawX(index), getRawY(index))"
+ errorLine2=" ~~~~~~~">
+ <location
+ file="src/androidMain/kotlin/androidx/compose/ui/input/pointer/MotionEventAdapter.android.kt"
+ line="194"
+ column="19"/>
+ </issue>
+
+ <issue
+ id="ClassVerificationFailure"
+ message="This call references a method added in API level 29; however, the containing class androidx.compose.ui.input.pointer.MotionEventAdapter_androidKt is reachable from earlier API levels and will fail run-time class verification."
+ errorLine1=" return Offset(getRawX(index), getRawY(index))"
+ errorLine2=" ~~~~~~~">
+ <location
+ file="src/androidMain/kotlin/androidx/compose/ui/input/pointer/MotionEventAdapter.android.kt"
+ line="194"
+ column="35"/>
+ </issue>
+
</issues>
diff --git a/compose/ui/ui/samples/src/main/java/androidx/compose/ui/samples/RelocationSamples.kt b/compose/ui/ui/samples/src/main/java/androidx/compose/ui/samples/RelocationSamples.kt
index dc4f837..f1e168a 100644
--- a/compose/ui/ui/samples/src/main/java/androidx/compose/ui/samples/RelocationSamples.kt
+++ b/compose/ui/ui/samples/src/main/java/androidx/compose/ui/samples/RelocationSamples.kt
@@ -36,14 +36,14 @@
@ExperimentalComposeUiApi
@Sampled
@Composable
-fun BringIntoParentBoundsSample() {
+fun BringIntoViewSample() {
val relocationRequester = remember { RelocationRequester() }
Column {
Box(Modifier.width(100.dp).horizontalScroll(rememberScrollState())) {
Box(Modifier.size(100.dp))
Box(Modifier.size(100.dp).relocationRequester(relocationRequester))
}
- Button(onClick = { relocationRequester.bringIntoParentBounds() }) {
+ Button(onClick = { relocationRequester.bringIntoView() }) {
Text("Bring box into view")
}
}
diff --git a/compose/ui/ui/src/androidAndroidTest/kotlin/androidx/compose/ui/graphics/vector/VectorTest.kt b/compose/ui/ui/src/androidAndroidTest/kotlin/androidx/compose/ui/graphics/vector/VectorTest.kt
index 60dfe8c..383b749 100644
--- a/compose/ui/ui/src/androidAndroidTest/kotlin/androidx/compose/ui/graphics/vector/VectorTest.kt
+++ b/compose/ui/ui/src/androidAndroidTest/kotlin/androidx/compose/ui/graphics/vector/VectorTest.kt
@@ -305,6 +305,44 @@
rule.onNodeWithTag(testTag).captureToImage().assertPixels { Color.Blue }
}
+ @SdkSuppress(minSdkVersion = Build.VERSION_CODES.O)
+ @Test
+ fun testVectorChangeSize() {
+ val size = mutableStateOf(200)
+ val color = mutableStateOf(Color.Magenta)
+
+ rule.setContent {
+ val background = Modifier.background(Color.Red).paint(
+ createTestVectorPainter(size.value, color.value),
+ alignment = Alignment.TopStart
+ )
+ AtLeastSize(size = 400, modifier = background) {
+ }
+ }
+
+ takeScreenShot(400).apply {
+ assertEquals(getPixel(100, 100), Color.Magenta.toArgb())
+ assertEquals(getPixel(300, 300), Color.Red.toArgb())
+ }
+
+ size.value = 400
+ color.value = Color.Cyan
+
+ takeScreenShot(400).apply {
+ assertEquals(getPixel(100, 100), Color.Cyan.toArgb())
+ assertEquals(getPixel(300, 300), Color.Cyan.toArgb())
+ }
+
+ size.value = 50
+ color.value = Color.Yellow
+
+ takeScreenShot(400).apply {
+ assertEquals(getPixel(10, 10), Color.Yellow.toArgb())
+ assertEquals(getPixel(100, 100), Color.Red.toArgb())
+ assertEquals(getPixel(300, 300), Color.Red.toArgb())
+ }
+ }
+
@Composable
private fun VectorTint(
size: Int = 200,
diff --git a/compose/ui/ui/src/androidAndroidTest/kotlin/androidx/compose/ui/input/EditorInfoTest.kt b/compose/ui/ui/src/androidAndroidTest/kotlin/androidx/compose/ui/input/EditorInfoTest.kt
index 5894e49..c69138c 100644
--- a/compose/ui/ui/src/androidAndroidTest/kotlin/androidx/compose/ui/input/EditorInfoTest.kt
+++ b/compose/ui/ui/src/androidAndroidTest/kotlin/androidx/compose/ui/input/EditorInfoTest.kt
@@ -25,12 +25,14 @@
import androidx.compose.ui.text.input.KeyboardType
import androidx.compose.ui.text.input.TextFieldValue
import androidx.compose.ui.text.input.update
+import androidx.test.ext.junit.runners.AndroidJUnit4
+import androidx.test.filters.MediumTest
import com.google.common.truth.Truth.assertThat
import org.junit.Test
import org.junit.runner.RunWith
-import org.junit.runners.JUnit4
-@RunWith(JUnit4::class)
+@MediumTest
+@RunWith(AndroidJUnit4::class)
class EditorInfoTest {
@Test
diff --git a/compose/ui/ui/src/androidAndroidTest/kotlin/androidx/compose/ui/input/pointer/PointerInputEventProcessorTest.kt b/compose/ui/ui/src/androidAndroidTest/kotlin/androidx/compose/ui/input/pointer/PointerInputEventProcessorTest.kt
index 3e51d7d..f7b1ade 100644
--- a/compose/ui/ui/src/androidAndroidTest/kotlin/androidx/compose/ui/input/pointer/PointerInputEventProcessorTest.kt
+++ b/compose/ui/ui/src/androidAndroidTest/kotlin/androidx/compose/ui/input/pointer/PointerInputEventProcessorTest.kt
@@ -24,6 +24,7 @@
import androidx.compose.ui.focus.FocusDirection
import androidx.compose.ui.focus.FocusManager
import androidx.compose.ui.geometry.Offset
+import androidx.compose.ui.geometry.Rect
import androidx.compose.ui.graphics.Canvas
import androidx.compose.ui.hapticfeedback.HapticFeedback
import androidx.compose.ui.input.key.KeyEvent
@@ -3095,6 +3096,10 @@
TODO("Not yet implemented")
}
+ override fun requestRectangleOnScreen(rect: Rect) {
+ TODO("Not yet implemented")
+ }
+
override val measureIteration: Long
get() = 0
diff --git a/compose/ui/ui/src/androidAndroidTest/kotlin/androidx/compose/ui/layout/RelocationRequesterModifierTest.kt b/compose/ui/ui/src/androidAndroidTest/kotlin/androidx/compose/ui/layout/RelocationRequesterModifierTest.kt
index 680b624..4fd76bd 100644
--- a/compose/ui/ui/src/androidAndroidTest/kotlin/androidx/compose/ui/layout/RelocationRequesterModifierTest.kt
+++ b/compose/ui/ui/src/androidAndroidTest/kotlin/androidx/compose/ui/layout/RelocationRequesterModifierTest.kt
@@ -105,7 +105,7 @@
}
// Act.
- rule.runOnIdle { relocationRequester.bringIntoParentBounds() }
+ rule.runOnIdle { relocationRequester.bringIntoView() }
// Assert.
rule.waitForIdle()
@@ -144,7 +144,7 @@
}
// Act.
- rule.runOnIdle { relocationRequester.bringIntoParentBounds() }
+ rule.runOnIdle { relocationRequester.bringIntoView() }
// Assert.
rule.waitForIdle()
@@ -183,7 +183,7 @@
}
// Act.
- rule.runOnIdle { relocationRequester.bringIntoParentBounds() }
+ rule.runOnIdle { relocationRequester.bringIntoView() }
// Assert.
rule.waitForIdle()
@@ -228,7 +228,7 @@
}
// Act.
- rule.runOnIdle { relocationRequester.bringIntoParentBounds() }
+ rule.runOnIdle { relocationRequester.bringIntoView() }
// Assert.
rule.waitForIdle()
@@ -273,7 +273,7 @@
}
// Act.
- rule.runOnIdle { relocationRequester.bringIntoParentBounds() }
+ rule.runOnIdle { relocationRequester.bringIntoView() }
// Assert.
rule.waitForIdle()
@@ -308,7 +308,7 @@
}
// Act.
- rule.runOnIdle { relocationRequester.bringIntoParentBounds() }
+ rule.runOnIdle { relocationRequester.bringIntoView() }
// Assert.
rule.waitForIdle()
@@ -348,7 +348,7 @@
rule.awaitIdle()
// Act.
- relocationRequester.bringIntoParentBounds()
+ relocationRequester.bringIntoView()
// Assert.
rule.awaitIdle()
@@ -388,7 +388,7 @@
rule.awaitIdle()
// Act.
- relocationRequester.bringIntoParentBounds()
+ relocationRequester.bringIntoView()
// Assert.
rule.awaitIdle()
@@ -446,7 +446,7 @@
rule.awaitIdle()
// Act.
- relocationRequester.bringIntoParentBounds()
+ relocationRequester.bringIntoView()
// Assert.
rule.awaitIdle()
@@ -504,7 +504,7 @@
rule.awaitIdle()
// Act.
- relocationRequester.bringIntoParentBounds()
+ relocationRequester.bringIntoView()
// Assert.
rule.awaitIdle()
@@ -557,7 +557,7 @@
rule.awaitIdle()
// Act.
- relocationRequester.bringIntoParentBounds()
+ relocationRequester.bringIntoView()
// Assert.
rule.awaitIdle()
@@ -615,7 +615,7 @@
rule.awaitIdle()
// Act.
- relocationRequester.bringIntoParentBounds()
+ relocationRequester.bringIntoView()
// Assert.
rule.awaitIdle()
@@ -693,7 +693,7 @@
rule.awaitIdle()
// Act.
- relocationRequester.bringIntoParentBounds()
+ relocationRequester.bringIntoView()
// Assert.
rule.awaitIdle()
@@ -757,7 +757,7 @@
rule.awaitIdle()
// Act.
- relocationRequester.bringIntoParentBounds()
+ relocationRequester.bringIntoView()
// Assert.
rule.awaitIdle()
diff --git a/compose/ui/ui/src/androidAndroidTest/kotlin/androidx/compose/ui/platform/ComposeViewOverlayTest.kt b/compose/ui/ui/src/androidAndroidTest/kotlin/androidx/compose/ui/platform/ComposeViewOverlayTest.kt
index 142aa4d..637f93f 100644
--- a/compose/ui/ui/src/androidAndroidTest/kotlin/androidx/compose/ui/platform/ComposeViewOverlayTest.kt
+++ b/compose/ui/ui/src/androidAndroidTest/kotlin/androidx/compose/ui/platform/ComposeViewOverlayTest.kt
@@ -31,6 +31,7 @@
import androidx.lifecycle.LifecycleOwner
import androidx.test.ext.junit.rules.activityScenarioRule
import androidx.test.ext.junit.runners.AndroidJUnit4
+import androidx.test.filters.LargeTest
import kotlinx.coroutines.flow.filter
import kotlinx.coroutines.flow.first
import kotlinx.coroutines.runBlocking
@@ -57,6 +58,7 @@
* originally attached to the target window "for real."
*/
@OptIn(InternalComposeUiApi::class)
+ @LargeTest
@Test
fun testComposeViewMovedToOverlay() {
var factoryCallCount = 0
diff --git a/compose/ui/ui/src/androidMain/kotlin/androidx/compose/ui/platform/AndroidComposeView.android.kt b/compose/ui/ui/src/androidMain/kotlin/androidx/compose/ui/platform/AndroidComposeView.android.kt
index d22435d..08d3717 100644
--- a/compose/ui/ui/src/androidMain/kotlin/androidx/compose/ui/platform/AndroidComposeView.android.kt
+++ b/compose/ui/ui/src/androidMain/kotlin/androidx/compose/ui/platform/AndroidComposeView.android.kt
@@ -62,6 +62,7 @@
import androidx.compose.ui.focus.FocusManager
import androidx.compose.ui.focus.FocusManagerImpl
import androidx.compose.ui.geometry.Offset
+import androidx.compose.ui.geometry.Rect as ComposeRect
import androidx.compose.ui.graphics.Canvas
import androidx.compose.ui.graphics.CanvasHolder
import androidx.compose.ui.graphics.Matrix
@@ -638,6 +639,10 @@
}
}
+ override fun requestRectangleOnScreen(rect: ComposeRect) {
+ requestRectangleOnScreen(rect.toRect())
+ }
+
override fun dispatchDraw(canvas: android.graphics.Canvas) {
if (!isAttachedToWindow) {
invalidateLayers(root)
@@ -1168,3 +1173,7 @@
other[3, 2] = ((-a30 * b03 + a31 * b01 - a32 * b00) * invDet)
other[3, 3] = ((a20 * b03 - a21 * b01 + a22 * b00) * invDet)
}
+
+private fun ComposeRect.toRect(): Rect {
+ return Rect(left.toInt(), top.toInt(), right.toInt(), bottom.toInt())
+}
\ No newline at end of file
diff --git a/compose/ui/ui/src/androidMain/kotlin/androidx/compose/ui/platform/AndroidComposeViewAccessibilityDelegateCompat.android.kt b/compose/ui/ui/src/androidMain/kotlin/androidx/compose/ui/platform/AndroidComposeViewAccessibilityDelegateCompat.android.kt
index f0ae381..e84f2ca 100644
--- a/compose/ui/ui/src/androidMain/kotlin/androidx/compose/ui/platform/AndroidComposeViewAccessibilityDelegateCompat.android.kt
+++ b/compose/ui/ui/src/androidMain/kotlin/androidx/compose/ui/platform/AndroidComposeViewAccessibilityDelegateCompat.android.kt
@@ -69,6 +69,7 @@
import androidx.compose.ui.text.InternalTextApi
import androidx.compose.ui.text.buildAnnotatedString
import androidx.compose.ui.util.fastForEachIndexed
+import androidx.compose.ui.util.fastMap
import androidx.core.view.AccessibilityDelegateCompat
import androidx.core.view.ViewCompat
import androidx.core.view.ViewCompat.ACCESSIBILITY_LIVE_REGION_ASSERTIVE
@@ -2012,7 +2013,7 @@
}
return node.config.getOrNull(SemanticsProperties.Text)
- ?.map { it.text }?.fastJoinToString(",")
+ ?.fastMap { it.text }?.fastJoinToString(",")
}
/**
@@ -2025,7 +2026,7 @@
val editableText = node.config.getOrNull(SemanticsProperties.EditableText)
return if (editableText.isNullOrEmpty()) {
node.config.getOrNull(SemanticsProperties.Text)
- ?.map { it.text }?.fastJoinToString(",")
+ ?.fastMap { it.text }?.fastJoinToString(",")
} else {
editableText.text
}
@@ -2044,7 +2045,7 @@
val contentDescription =
node.unmergedConfig.getOrNull(SemanticsProperties.ContentDescription)
if (!contentDescription.isNullOrEmpty()) {
- return contentDescription.joinToString(",")
+ return contentDescription.fastJoinToString(",")
}
if (node.unmergedConfig.contains(SemanticsProperties.Text) ||
@@ -2075,7 +2076,7 @@
val contentDescription =
childNode.unmergedConfig.getOrNull(SemanticsProperties.ContentDescription)
if (!contentDescription.isNullOrEmpty()) {
- childDescriptions.add(contentDescription.joinToString(","))
+ childDescriptions.add(contentDescription.fastJoinToString(","))
return@fastForEach
}
@@ -2091,7 +2092,7 @@
// check if it's a text node
val text = childNode.unmergedConfig.getOrNull(SemanticsProperties.Text)
if (!text.isNullOrEmpty()) {
- childDescriptions.add(text.map { it.text }.fastJoinToString(","))
+ childDescriptions.add(text.fastMap { it.text }.fastJoinToString(","))
return@fastForEach
}
diff --git a/compose/ui/ui/src/commonMain/kotlin/androidx/compose/ui/focus/FocusManager.kt b/compose/ui/ui/src/commonMain/kotlin/androidx/compose/ui/focus/FocusManager.kt
index cb20e73..c78d9ec 100644
--- a/compose/ui/ui/src/commonMain/kotlin/androidx/compose/ui/focus/FocusManager.kt
+++ b/compose/ui/ui/src/commonMain/kotlin/androidx/compose/ui/focus/FocusManager.kt
@@ -45,10 +45,10 @@
* Call this function to clear focus from the currently focused component, and set the focus to
* the root focus modifier.
*
- * @param forcedClear: Whether we should forcefully clear focus regardless of whether we have
+ * @param force: Whether we should forcefully clear focus regardless of whether we have
* any components that have Captured focus.
*/
- fun clearFocus(forcedClear: Boolean = false)
+ fun clearFocus(force: Boolean = false)
/**
* Moves focus in the specified [direction][FocusDirection].
@@ -157,13 +157,13 @@
/**
* Call this function to set the focus to the root focus modifier.
*
- * @param forcedClear: Whether we should forcefully clear focus regardless of whether we have
+ * @param force: Whether we should forcefully clear focus regardless of whether we have
* any components that have captured focus.
*
* This could be used to clear focus when a user clicks on empty space outside a focusable
* component.
*/
- override fun clearFocus(forcedClear: Boolean) {
+ override fun clearFocus(force: Boolean) {
// If this hierarchy had focus before clearing it, it indicates that the host view has
// focus. So after clearing focus within the compose hierarchy, we should reset the root
// focus modifier to "Active" to maintain consistency with the host view.
@@ -172,7 +172,7 @@
Disabled, Inactive -> false
}
- if (focusModifier.focusNode.clearFocus(forcedClear) && rootWasFocused) {
+ if (focusModifier.focusNode.clearFocus(force) && rootWasFocused) {
focusModifier.focusState = Active
}
}
diff --git a/compose/ui/ui/src/commonMain/kotlin/androidx/compose/ui/graphics/vector/DrawCache.kt b/compose/ui/ui/src/commonMain/kotlin/androidx/compose/ui/graphics/vector/DrawCache.kt
index 99a0886..c11e511 100644
--- a/compose/ui/ui/src/commonMain/kotlin/androidx/compose/ui/graphics/vector/DrawCache.kt
+++ b/compose/ui/ui/src/commonMain/kotlin/androidx/compose/ui/graphics/vector/DrawCache.kt
@@ -16,7 +16,6 @@
package androidx.compose.ui.graphics.vector
-import androidx.compose.ui.geometry.Offset
import androidx.compose.ui.graphics.BlendMode
import androidx.compose.ui.graphics.Canvas
import androidx.compose.ui.graphics.Color
@@ -43,6 +42,7 @@
private var cachedCanvas: Canvas? = null
private var scopeDensity: Density? = null
private var layoutDirection: LayoutDirection = LayoutDirection.Ltr
+ private var size: IntSize = IntSize.Zero
private val cacheScope = CanvasDrawScope()
@@ -72,6 +72,7 @@
mCachedImage = targetImage
cachedCanvas = targetCanvas
}
+ this.size = size
cacheScope.draw(density, layoutDirection, targetCanvas, size.toSize()) {
clear()
block()
@@ -92,7 +93,7 @@
"drawCachedImage must be invoked first before attempting to draw the result " +
"into another destination"
}
- target.drawImage(targetImage, Offset.Zero, alpha = alpha, colorFilter = colorFilter)
+ target.drawImage(targetImage, srcSize = size, alpha = alpha, colorFilter = colorFilter)
}
/**
diff --git a/compose/ui/ui/src/commonMain/kotlin/androidx/compose/ui/layout/RelocationRequester.kt b/compose/ui/ui/src/commonMain/kotlin/androidx/compose/ui/layout/RelocationRequester.kt
index 9a0780f..db7c07a 100644
--- a/compose/ui/ui/src/commonMain/kotlin/androidx/compose/ui/layout/RelocationRequester.kt
+++ b/compose/ui/ui/src/commonMain/kotlin/androidx/compose/ui/layout/RelocationRequester.kt
@@ -24,20 +24,20 @@
* This class can be used to send relocation requests. Pass it as a parameter to
* [Modifier.relocationRequester()][relocationRequester].
*
- * For instance, you can call [RelocationRequester.bringIntoParentBounds][bringIntoParentBounds] to
+ * For instance, you can call [RelocationRequester.bringIntoView][bringIntoView] to
* make all the scrollable parents scroll so that the specified item is brought into parent
* bounds. This sample demonstrates this use case:
*
- * @sample androidx.compose.ui.samples.BringIntoParentBoundsSample
+ * @sample androidx.compose.ui.samples.BringIntoViewSample
*/
@ExperimentalComposeUiApi
class RelocationRequester {
internal val modifiers: MutableVector<RelocationRequesterModifier> = mutableVectorOf()
/**
- * Bring this item into parent bounds by making all the scrollable parents scroll appropriately.
+ * Bring this item into bounds by making all the scrollable parents scroll appropriately.
*/
- fun bringIntoParentBounds() {
- modifiers.forEach { it.bringIntoParentBounds() }
+ fun bringIntoView() {
+ modifiers.forEach { it.bringIntoView() }
}
}
diff --git a/compose/ui/ui/src/commonMain/kotlin/androidx/compose/ui/layout/RelocationRequesterModifier.kt b/compose/ui/ui/src/commonMain/kotlin/androidx/compose/ui/layout/RelocationRequesterModifier.kt
index 0a51f59..7d7b737 100644
--- a/compose/ui/ui/src/commonMain/kotlin/androidx/compose/ui/layout/RelocationRequesterModifier.kt
+++ b/compose/ui/ui/src/commonMain/kotlin/androidx/compose/ui/layout/RelocationRequesterModifier.kt
@@ -34,9 +34,15 @@
internal class RelocationRequesterModifier : OnGloballyPositionedModifier {
lateinit var coordinates: LayoutCoordinates
- fun bringIntoParentBounds() {
- (coordinates as LayoutNodeWrapper).findPreviousNestedScrollWrapper()
- ?.bringIntoParentBounds(coordinates)
+ fun bringIntoView() {
+ val layoutNodeWrapper = coordinates
+ check(layoutNodeWrapper is LayoutNodeWrapper)
+
+ // Recursively scroll parents so that the item is visible.
+ layoutNodeWrapper.findPreviousNestedScrollWrapper()?.bringIntoView(coordinates)
+
+ // Ask the owner to send a request to its parents to make sure this item is visible.
+ layoutNodeWrapper.layoutNode.owner?.requestRectangleOnScreen(coordinates.boundsInRoot())
}
override fun onGloballyPositioned(coordinates: LayoutCoordinates) {
@@ -50,7 +56,7 @@
* Here is an example where the a [relocationRequester] can be used to bring an item into parent
* bounds. It demonstrates how a composable can ask its parents to scroll so that the component
* using this modifier is brought into the bounds of all its parents.
- * @sample androidx.compose.ui.samples.BringIntoParentBoundsSample
+ * @sample androidx.compose.ui.samples.BringIntoViewSample
*
* @param relocationRequester an instance of [RelocationRequester]. This hoisted object can be
* used to send relocation requests to parents of the current composable.
@@ -73,7 +79,7 @@
// Scroll this nested scroll parent to bring the child into view. Then find the nested scroll parent
// of this nested scroll parent and ask them to do the same. This results in scrolls propagating
// up to all the nested scroll parents to bring the specified child into view.
-private fun NestedScrollDelegatingWrapper.bringIntoParentBounds(child: LayoutCoordinates) {
+private fun NestedScrollDelegatingWrapper.bringIntoView(child: LayoutCoordinates) {
val childBounds = localBoundingBoxOf(child, false)
val offset = Offset(
calculateOffset(childBounds.left, childBounds.right, size.width.toFloat()),
@@ -84,7 +90,7 @@
// specific parents.
modifier.connection.onPostScroll(Zero, offset, Drag)
- wrappedBy?.findPreviousNestedScrollWrapper()?.bringIntoParentBounds(child)
+ wrappedBy?.findPreviousNestedScrollWrapper()?.bringIntoView(child)
}
// Calculate the offset needed to bring one of the edges into view. The leadingEdge is the side
diff --git a/compose/ui/ui/src/commonMain/kotlin/androidx/compose/ui/layout/SubcomposeLayout.kt b/compose/ui/ui/src/commonMain/kotlin/androidx/compose/ui/layout/SubcomposeLayout.kt
index 92a69d7..9c509bc 100644
--- a/compose/ui/ui/src/commonMain/kotlin/androidx/compose/ui/layout/SubcomposeLayout.kt
+++ b/compose/ui/ui/src/commonMain/kotlin/androidx/compose/ui/layout/SubcomposeLayout.kt
@@ -202,7 +202,8 @@
val itemIndex = root.foldedChildren.indexOf(node)
if (itemIndex < currentIndex) {
throw IllegalArgumentException(
- "$slotId was already used with subcompose during this measuring pass"
+ "Key $slotId was already used. If you are using LazyColumn/Row please make sure " +
+ "you provide a unique key for each item."
)
}
if (currentIndex != itemIndex) {
diff --git a/compose/ui/ui/src/commonMain/kotlin/androidx/compose/ui/node/ModifiedFocusNode.kt b/compose/ui/ui/src/commonMain/kotlin/androidx/compose/ui/node/ModifiedFocusNode.kt
index 050f56b..0a249c6 100644
--- a/compose/ui/ui/src/commonMain/kotlin/androidx/compose/ui/node/ModifiedFocusNode.kt
+++ b/compose/ui/ui/src/commonMain/kotlin/androidx/compose/ui/node/ModifiedFocusNode.kt
@@ -92,7 +92,7 @@
when (focusState) {
// If this node is focused, set the focus on the root layoutNode before removing it.
Active, Captured -> {
- layoutNode.owner?.focusManager?.clearFocus(forcedClear = true)
+ layoutNode.owner?.focusManager?.clearFocus(force = true)
}
// Propagate the state of the next focus node to any focus observers in the hierarchy.
ActiveParent -> {
diff --git a/compose/ui/ui/src/commonMain/kotlin/androidx/compose/ui/node/Owner.kt b/compose/ui/ui/src/commonMain/kotlin/androidx/compose/ui/node/Owner.kt
index 5a70959..212bb6c 100644
--- a/compose/ui/ui/src/commonMain/kotlin/androidx/compose/ui/node/Owner.kt
+++ b/compose/ui/ui/src/commonMain/kotlin/androidx/compose/ui/node/Owner.kt
@@ -21,6 +21,7 @@
import androidx.compose.ui.focus.FocusDirection
import androidx.compose.ui.focus.FocusManager
import androidx.compose.ui.geometry.Offset
+import androidx.compose.ui.geometry.Rect
import androidx.compose.ui.graphics.Canvas
import androidx.compose.ui.hapticfeedback.HapticFeedback
import androidx.compose.ui.input.key.KeyEvent
@@ -184,6 +185,12 @@
*/
fun getFocusDirection(keyEvent: KeyEvent): FocusDirection?
+ /**
+ * Request that a rectangle of this owner be visible on the screen, scrolling if necessary just
+ * enough.
+ */
+ fun requestRectangleOnScreen(rect: Rect)
+
val measureIteration: Long
/**
diff --git a/compose/ui/ui/src/desktopMain/kotlin/androidx/compose/desktop/AppFrame.desktop.kt b/compose/ui/ui/src/desktopMain/kotlin/androidx/compose/desktop/AppFrame.desktop.kt
index cf41892..b2fe299 100644
--- a/compose/ui/ui/src/desktopMain/kotlin/androidx/compose/desktop/AppFrame.desktop.kt
+++ b/compose/ui/ui/src/desktopMain/kotlin/androidx/compose/desktop/AppFrame.desktop.kt
@@ -17,7 +17,7 @@
import androidx.compose.ui.unit.IntOffset
import androidx.compose.ui.unit.IntSize
-import androidx.compose.ui.window.MenuBar
+import androidx.compose.ui.window.v1.MenuBar
import java.awt.event.MouseListener
import java.awt.event.MouseMotionListener
import java.awt.image.BufferedImage
diff --git a/compose/ui/ui/src/desktopMain/kotlin/androidx/compose/desktop/AppManager.desktop.kt b/compose/ui/ui/src/desktopMain/kotlin/androidx/compose/desktop/AppManager.desktop.kt
index 035aff4..2cdac33 100644
--- a/compose/ui/ui/src/desktopMain/kotlin/androidx/compose/desktop/AppManager.desktop.kt
+++ b/compose/ui/ui/src/desktopMain/kotlin/androidx/compose/desktop/AppManager.desktop.kt
@@ -15,7 +15,7 @@
*/
package androidx.compose.desktop
-import androidx.compose.ui.window.MenuBar
+import androidx.compose.ui.window.v1.MenuBar
object AppManager {
diff --git a/compose/ui/ui/src/desktopMain/kotlin/androidx/compose/desktop/AppWindow.desktop.kt b/compose/ui/ui/src/desktopMain/kotlin/androidx/compose/desktop/AppWindow.desktop.kt
index ac4cfd6..80252f0 100644
--- a/compose/ui/ui/src/desktopMain/kotlin/androidx/compose/desktop/AppWindow.desktop.kt
+++ b/compose/ui/ui/src/desktopMain/kotlin/androidx/compose/desktop/AppWindow.desktop.kt
@@ -22,7 +22,7 @@
import androidx.compose.ui.platform.Keyboard
import androidx.compose.ui.unit.IntOffset
import androidx.compose.ui.unit.IntSize
-import androidx.compose.ui.window.MenuBar
+import androidx.compose.ui.window.v1.MenuBar
import java.awt.Container
import java.awt.Frame
import java.awt.event.ComponentAdapter
diff --git a/compose/ui/ui/src/desktopMain/kotlin/androidx/compose/ui/platform/DesktopOwner.desktop.kt b/compose/ui/ui/src/desktopMain/kotlin/androidx/compose/ui/platform/DesktopOwner.desktop.kt
index 32b021f..74272e4 100644
--- a/compose/ui/ui/src/desktopMain/kotlin/androidx/compose/ui/platform/DesktopOwner.desktop.kt
+++ b/compose/ui/ui/src/desktopMain/kotlin/androidx/compose/ui/platform/DesktopOwner.desktop.kt
@@ -36,6 +36,7 @@
import androidx.compose.ui.focus.FocusManager
import androidx.compose.ui.focus.FocusManagerImpl
import androidx.compose.ui.geometry.Offset
+import androidx.compose.ui.geometry.Rect
import androidx.compose.ui.graphics.Canvas
import androidx.compose.ui.graphics.DesktopCanvas
import androidx.compose.ui.input.key.Key.Companion.Back
@@ -286,6 +287,10 @@
}
}
+ override fun requestRectangleOnScreen(rect: Rect) {
+ // TODO: Scroll the owner to bring the specified rectangle into view.
+ }
+
override fun calculatePositionInWindow(localPosition: Offset): Offset = localPosition
override fun calculateLocalPosition(positionInWindow: Offset): Offset = positionInWindow
diff --git a/compose/ui/ui/src/desktopMain/kotlin/androidx/compose/ui/window/DesktopDialog.desktop.kt b/compose/ui/ui/src/desktopMain/kotlin/androidx/compose/ui/window/v1/DesktopDialog.desktop.kt
similarity index 97%
rename from compose/ui/ui/src/desktopMain/kotlin/androidx/compose/ui/window/DesktopDialog.desktop.kt
rename to compose/ui/ui/src/desktopMain/kotlin/androidx/compose/ui/window/v1/DesktopDialog.desktop.kt
index 4a9174a..a16f12a 100644
--- a/compose/ui/ui/src/desktopMain/kotlin/androidx/compose/ui/window/DesktopDialog.desktop.kt
+++ b/compose/ui/ui/src/desktopMain/kotlin/androidx/compose/ui/window/v1/DesktopDialog.desktop.kt
@@ -1,5 +1,5 @@
/*
- * Copyright 2019 The Android Open Source Project
+ * Copyright 2021 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.
@@ -14,7 +14,7 @@
* limitations under the License.
*/
-package androidx.compose.ui.window
+package androidx.compose.ui.window.v1
import androidx.compose.desktop.AppWindow
import androidx.compose.desktop.LocalAppWindow
@@ -22,8 +22,8 @@
import androidx.compose.runtime.Composable
import androidx.compose.runtime.DisposableEffect
import androidx.compose.runtime.Immutable
-import androidx.compose.runtime.rememberCompositionContext
import androidx.compose.runtime.remember
+import androidx.compose.runtime.rememberCompositionContext
import androidx.compose.ui.unit.IntOffset
import androidx.compose.ui.unit.IntSize
import java.awt.image.BufferedImage
diff --git a/compose/ui/ui/src/desktopMain/kotlin/androidx/compose/ui/window/MenuBar.desktop.kt b/compose/ui/ui/src/desktopMain/kotlin/androidx/compose/ui/window/v1/MenuBar.desktop.kt
similarity index 96%
rename from compose/ui/ui/src/desktopMain/kotlin/androidx/compose/ui/window/MenuBar.desktop.kt
rename to compose/ui/ui/src/desktopMain/kotlin/androidx/compose/ui/window/v1/MenuBar.desktop.kt
index 3672743..8f65fcf 100644
--- a/compose/ui/ui/src/desktopMain/kotlin/androidx/compose/ui/window/MenuBar.desktop.kt
+++ b/compose/ui/ui/src/desktopMain/kotlin/androidx/compose/ui/window/v1/MenuBar.desktop.kt
@@ -1,5 +1,5 @@
/*
- * Copyright 2020 The Android Open Source Project
+ * Copyright 2021 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.
@@ -13,11 +13,11 @@
* See the License for the specific language governing permissions and
* limitations under the License.
*/
-package androidx.compose.ui.window
+package androidx.compose.ui.window.v1
import org.jetbrains.skiko.Library
-import java.awt.event.ActionListener
import java.awt.event.ActionEvent
+import java.awt.event.ActionListener
import javax.swing.JMenu
import javax.swing.JMenuBar
import javax.swing.JMenuItem
diff --git a/compose/ui/ui/src/desktopMain/kotlin/androidx/compose/ui/window/MenuItem.desktop.kt b/compose/ui/ui/src/desktopMain/kotlin/androidx/compose/ui/window/v1/MenuItem.desktop.kt
similarity index 95%
rename from compose/ui/ui/src/desktopMain/kotlin/androidx/compose/ui/window/MenuItem.desktop.kt
rename to compose/ui/ui/src/desktopMain/kotlin/androidx/compose/ui/window/v1/MenuItem.desktop.kt
index d7c732a..031c03b 100644
--- a/compose/ui/ui/src/desktopMain/kotlin/androidx/compose/ui/window/MenuItem.desktop.kt
+++ b/compose/ui/ui/src/desktopMain/kotlin/androidx/compose/ui/window/v1/MenuItem.desktop.kt
@@ -1,5 +1,5 @@
/*
- * Copyright 2020 The Android Open Source Project
+ * Copyright 2021 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.
@@ -13,7 +13,7 @@
* See the License for the specific language governing permissions and
* limitations under the License.
*/
-package androidx.compose.ui.window
+package androidx.compose.ui.window.v1
import androidx.compose.ui.input.key.Key
import androidx.compose.ui.input.key.nativeKeyCode
diff --git a/compose/ui/ui/src/desktopMain/kotlin/androidx/compose/ui/window/Tray.desktop.kt b/compose/ui/ui/src/desktopMain/kotlin/androidx/compose/ui/window/v1/Tray.desktop.kt
similarity index 97%
rename from compose/ui/ui/src/desktopMain/kotlin/androidx/compose/ui/window/Tray.desktop.kt
rename to compose/ui/ui/src/desktopMain/kotlin/androidx/compose/ui/window/v1/Tray.desktop.kt
index 5e51ec8..6affd42 100644
--- a/compose/ui/ui/src/desktopMain/kotlin/androidx/compose/ui/window/Tray.desktop.kt
+++ b/compose/ui/ui/src/desktopMain/kotlin/androidx/compose/ui/window/v1/Tray.desktop.kt
@@ -1,5 +1,5 @@
/*
- * Copyright 2020 The Android Open Source Project
+ * Copyright 2021 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.
@@ -13,15 +13,15 @@
* See the License for the specific language governing permissions and
* limitations under the License.
*/
-package androidx.compose.ui.window
+package androidx.compose.ui.window.v1
-import java.awt.event.ActionListener
-import java.awt.event.ActionEvent
import java.awt.Image
import java.awt.PopupMenu
import java.awt.SystemTray
import java.awt.TrayIcon
import java.awt.TrayIcon.MessageType
+import java.awt.event.ActionEvent
+import java.awt.event.ActionListener
/**
* Tray is class for working with the system tray.
diff --git a/compose/ui/ui/src/test/kotlin/androidx/compose/ui/focus/FocusManagerTest.kt b/compose/ui/ui/src/test/kotlin/androidx/compose/ui/focus/FocusManagerTest.kt
index 701b47e..e18c76c 100644
--- a/compose/ui/ui/src/test/kotlin/androidx/compose/ui/focus/FocusManagerTest.kt
+++ b/compose/ui/ui/src/test/kotlin/androidx/compose/ui/focus/FocusManagerTest.kt
@@ -105,7 +105,7 @@
}
// Act.
- focusManager.clearFocus(forcedClear = true)
+ focusManager.clearFocus(force = true)
// Assert.
assertThat(focusModifier.focusState).isEqualTo(
@@ -130,7 +130,7 @@
}
// Act.
- focusManager.clearFocus(forcedClear = false)
+ focusManager.clearFocus(force = false)
// Assert.
assertThat(focusModifier.focusState).isEqualTo(
diff --git a/compose/ui/ui/src/test/kotlin/androidx/compose/ui/node/LayoutNodeTest.kt b/compose/ui/ui/src/test/kotlin/androidx/compose/ui/node/LayoutNodeTest.kt
index e980555..4206975 100644
--- a/compose/ui/ui/src/test/kotlin/androidx/compose/ui/node/LayoutNodeTest.kt
+++ b/compose/ui/ui/src/test/kotlin/androidx/compose/ui/node/LayoutNodeTest.kt
@@ -25,6 +25,7 @@
import androidx.compose.ui.focus.FocusManager
import androidx.compose.ui.geometry.MutableRect
import androidx.compose.ui.geometry.Offset
+import androidx.compose.ui.geometry.Rect
import androidx.compose.ui.graphics.Canvas
import androidx.compose.ui.graphics.Shape
import androidx.compose.ui.graphics.TransformOrigin
@@ -1889,6 +1890,10 @@
TODO("Not yet implemented")
}
+ override fun requestRectangleOnScreen(rect: Rect) {
+ TODO("Not yet implemented")
+ }
+
override var measureIteration: Long = 0
override val viewConfiguration: ViewConfiguration
get() = TODO("Not yet implemented")
diff --git a/core/core-animation/build.gradle b/core/core-animation/build.gradle
index d7061d3..d963b61 100644
--- a/core/core-animation/build.gradle
+++ b/core/core-animation/build.gradle
@@ -25,7 +25,7 @@
}
dependencies {
- api("androidx.annotation:annotation:1.1.0")
+ api("androidx.annotation:annotation:1.2.0")
implementation("androidx.core:core:1.3.1")
implementation("androidx.collection:collection:1.1.0")
diff --git a/core/core-animation/lint-baseline.xml b/core/core-animation/lint-baseline.xml
index 35d7b15..13d37ce 100644
--- a/core/core-animation/lint-baseline.xml
+++ b/core/core-animation/lint-baseline.xml
@@ -90,17 +90,6 @@
</issue>
<issue
- id="ClassVerificationFailure"
- message="This call references a method added in API level 26; however, the containing class androidx.core.animation.PathUtils is reachable from earlier API levels and will fail run-time class verification."
- errorLine1=" return path.approximate(precision);"
- errorLine2=" ~~~~~~~~~~~">
- <location
- file="src/main/java/androidx/core/animation/PathUtils.java"
- line="34"
- column="25"/>
- </issue>
-
- <issue
id="KotlinPropertyAccess"
message="The getter return type (`PropertyValuesHolder[]`) and setter parameter type (`PropertyValuesHolder...`) getter and setter methods for property `values` should have exactly the same type to allow be accessed as a property from Kotlin; see https://android.github.io/kotlin-guides/interop.html#property-prefixes"
errorLine1=" public PropertyValuesHolder[] getValues() {"
diff --git a/core/core-animation/src/main/java/androidx/core/animation/PathUtils.java b/core/core-animation/src/main/java/androidx/core/animation/PathUtils.java
index 730fc21..f55e292 100644
--- a/core/core-animation/src/main/java/androidx/core/animation/PathUtils.java
+++ b/core/core-animation/src/main/java/androidx/core/animation/PathUtils.java
@@ -19,6 +19,9 @@
import android.graphics.PathMeasure;
import android.os.Build;
+import androidx.annotation.DoNotInline;
+import androidx.annotation.RequiresApi;
+
import java.util.ArrayList;
import java.util.List;
@@ -31,7 +34,7 @@
static float[] createKeyFrameData(Path path, float precision) {
if (Build.VERSION.SDK_INT >= 26) {
- return path.approximate(precision);
+ return Api26Impl.approximate(path, precision);
} else {
// Measure the total length the whole path.
final PathMeasure measureForTotalLength = new PathMeasure(path, false);
@@ -162,4 +165,15 @@
data.add(y);
}
+ @RequiresApi(26)
+ static class Api26Impl {
+ private Api26Impl() {
+ // This class is not instantiable.
+ }
+
+ @DoNotInline
+ static float[] approximate(Path path, float acceptableError) {
+ return path.approximate(acceptableError);
+ }
+ }
}
diff --git a/core/core-google-shortcuts/build.gradle b/core/core-google-shortcuts/build.gradle
index 7f7bf68..ea77000 100644
--- a/core/core-google-shortcuts/build.gradle
+++ b/core/core-google-shortcuts/build.gradle
@@ -32,7 +32,7 @@
}
dependencies {
- api("androidx.core:core:1.6.0-beta01")
+ api(project(":core:core"))
implementation("com.google.firebase:firebase-appindexing:19.2.0")
implementation("com.google.crypto.tink:tink-android:1.5.0")
diff --git a/core/core/api/current.txt b/core/core/api/current.txt
index 83d6a2d..2cf275c 100644
--- a/core/core/api/current.txt
+++ b/core/core/api/current.txt
@@ -1542,7 +1542,6 @@
method @Deprecated @ChecksSdkIntAtLeast(api=android.os.Build.VERSION_CODES.Q) public static boolean isAtLeastQ();
method @Deprecated @ChecksSdkIntAtLeast(api=android.os.Build.VERSION_CODES.R) public static boolean isAtLeastR();
method @ChecksSdkIntAtLeast(codename="S") public static boolean isAtLeastS();
- method @ChecksSdkIntAtLeast(codename="T") public static boolean isAtLeastT();
}
public final class CancellationSignal {
diff --git a/core/core/api/public_plus_experimental_current.txt b/core/core/api/public_plus_experimental_current.txt
index ebb5dfb..3934ab1 100644
--- a/core/core/api/public_plus_experimental_current.txt
+++ b/core/core/api/public_plus_experimental_current.txt
@@ -1540,7 +1540,6 @@
method @Deprecated @ChecksSdkIntAtLeast(api=android.os.Build.VERSION_CODES.Q) public static boolean isAtLeastQ();
method @Deprecated @ChecksSdkIntAtLeast(api=android.os.Build.VERSION_CODES.R) public static boolean isAtLeastR();
method @ChecksSdkIntAtLeast(codename="S") public static boolean isAtLeastS();
- method @ChecksSdkIntAtLeast(codename="T") public static boolean isAtLeastT();
}
public final class CancellationSignal {
diff --git a/core/core/api/restricted_current.txt b/core/core/api/restricted_current.txt
index 34557d9..46113a6 100644
--- a/core/core/api/restricted_current.txt
+++ b/core/core/api/restricted_current.txt
@@ -1861,7 +1861,6 @@
method @Deprecated @ChecksSdkIntAtLeast(api=android.os.Build.VERSION_CODES.Q) public static boolean isAtLeastQ();
method @Deprecated @ChecksSdkIntAtLeast(api=android.os.Build.VERSION_CODES.R) public static boolean isAtLeastR();
method @ChecksSdkIntAtLeast(codename="S") public static boolean isAtLeastS();
- method @ChecksSdkIntAtLeast(codename="T") public static boolean isAtLeastT();
}
public final class CancellationSignal {
diff --git a/core/core/lint-baseline.xml b/core/core/lint-baseline.xml
index 63626a6..cbe1a6d 100644
--- a/core/core/lint-baseline.xml
+++ b/core/core/lint-baseline.xml
@@ -46,39 +46,6 @@
</issue>
<issue
- id="BanSynchronizedMethods"
- message="Use of synchronized methods is not recommended"
- errorLine1=" /**"
- errorLine2=" ^">
- <location
- file="src/main/java/androidx/core/widget/ContentLoadingProgressBar.java"
- line="92"
- column="5"/>
- </issue>
-
- <issue
- id="BanSynchronizedMethods"
- message="Use of synchronized methods is not recommended"
- errorLine1=" /**"
- errorLine2=" ^">
- <location
- file="src/main/java/androidx/core/widget/ContentLoadingProgressBar.java"
- line="118"
- column="5"/>
- </issue>
-
- <issue
- id="BanSynchronizedMethods"
- message="Use of synchronized methods is not recommended"
- errorLine1=" private synchronized static File createFilesDir(File file) {"
- errorLine2=" ^">
- <location
- file="src/main/java/androidx/core/content/ContextCompat.java"
- line="602"
- column="5"/>
- </issue>
-
- <issue
id="BanUncheckedReflection"
message="Calling Method.invoke without an SDK check"
errorLine1=" requestRelaunchActivityMethod.invoke(activityThread,"
diff --git a/core/core/src/androidTest/java/androidx/core/os/BuildCompatTest.java b/core/core/src/androidTest/java/androidx/core/os/BuildCompatTest.java
new file mode 100644
index 0000000..a333e5e
--- /dev/null
+++ b/core/core/src/androidTest/java/androidx/core/os/BuildCompatTest.java
@@ -0,0 +1,52 @@
+/*
+ * Copyright 2021 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.core.os;
+
+import static org.junit.Assert.assertFalse;
+import static org.junit.Assert.assertTrue;
+
+import androidx.test.ext.junit.runners.AndroidJUnit4;
+import androidx.test.filters.SmallTest;
+
+import org.junit.Test;
+import org.junit.runner.RunWith;
+
+/**
+ * Tests for {@link BuildCompat}.
+ */
+@RunWith(AndroidJUnit4.class)
+@SmallTest
+public class BuildCompatTest {
+ @Test
+ public void isAtLeastPreReleaseCodename() {
+ assertTrue(BuildCompat.isAtLeastPreReleaseCodename("S", "S"));
+ assertTrue(BuildCompat.isAtLeastPreReleaseCodename("T", "S"));
+ assertFalse(BuildCompat.isAtLeastPreReleaseCodename("S", "T"));
+
+ assertTrue(BuildCompat.isAtLeastPreReleaseCodename("OMR1", "O"));
+ assertFalse(BuildCompat.isAtLeastPreReleaseCodename("O", "OMR1"));
+
+ assertTrue(BuildCompat.isAtLeastPreReleaseCodename("OMR1", "OMR1"));
+ assertTrue(BuildCompat.isAtLeastPreReleaseCodename("OMR2", "OMR1"));
+ assertFalse(BuildCompat.isAtLeastPreReleaseCodename("OMR1", "OMR2"));
+
+ assertFalse(BuildCompat.isAtLeastPreReleaseCodename("S", "REL"));
+
+ assertFalse(BuildCompat.isAtLeastPreReleaseCodename("RMR1", "REL"));
+ }
+
+}
diff --git a/core/core/src/main/java/androidx/core/content/ContextCompat.java b/core/core/src/main/java/androidx/core/content/ContextCompat.java
index 882f35b..2f54ab4 100644
--- a/core/core/src/main/java/androidx/core/content/ContextCompat.java
+++ b/core/core/src/main/java/androidx/core/content/ContextCompat.java
@@ -158,6 +158,9 @@
private static final Object sLock = new Object();
+ // Lock that provides similar functionality to ContextImpl.mSync.
+ private static final Object sSync = new Object();
+
private static TypedValue sTempValue;
/**
@@ -599,18 +602,23 @@
}
}
- private synchronized static File createFilesDir(File file) {
- if (!file.exists()) {
- if (!file.mkdirs()) {
- if (file.exists()) {
- // spurious failure; probably racing with another process for this app
+ private static File createFilesDir(File file) {
+ // In the platform, all operations on Context that involve creating files (codeCacheDir,
+ // noBackupFilesDir, etc.) are synchronized on a single lock owned by the Context. So, if
+ // we lock on a single static lock owned by ContextCompat then we're a bit too broad but
+ // at least we'll provide similar guarantees.
+ synchronized (sSync) {
+ if (!file.exists()) {
+ if (file.mkdirs()) {
return file;
+ } else {
+ // There used to be another check for file.exists() here, but that was a
+ // side-effect of improper synchronization.
+ Log.w(TAG, "Unable to create files subdir " + file.getPath());
}
- Log.w(TAG, "Unable to create files subdir " + file.getPath());
- return null;
}
+ return file;
}
- return file;
}
/**
diff --git a/core/core/src/main/java/androidx/core/os/BuildCompat.java b/core/core/src/main/java/androidx/core/os/BuildCompat.java
index 389622f..7df4319 100644
--- a/core/core/src/main/java/androidx/core/os/BuildCompat.java
+++ b/core/core/src/main/java/androidx/core/os/BuildCompat.java
@@ -20,6 +20,8 @@
import android.os.Build.VERSION;
import androidx.annotation.ChecksSdkIntAtLeast;
+import androidx.annotation.NonNull;
+import androidx.annotation.RestrictTo;
/**
* This class contains additional platform version checking methods for targeting pre-release
@@ -30,6 +32,28 @@
}
/**
+ * Checks if the codename is a matching or higher version than the given build value.
+ * @param codename the requested build codename, e.g. {@code "O"} or {@code "OMR1"}
+ * @param buildCodename the value of {@link VERSION.CODENAME}
+ *
+ * @return {@code true} if APIs from the requested codename are available in the build.
+ *
+ * @hide
+ */
+ @RestrictTo(RestrictTo.Scope.TESTS)
+ protected static boolean isAtLeastPreReleaseCodename(@NonNull String codename,
+ @NonNull String buildCodename) {
+
+ // Special case "REL", which means the build is not a pre-release build.
+ if ("REL".equals(buildCodename)) {
+ return false;
+ }
+
+ // Otherwise lexically compare them.
+ return codename.compareTo(buildCodename) >= 0;
+ }
+
+ /**
* Checks if the device is running on the Android N release or newer.
*
* @return {@code true} if N APIs are available for use
@@ -139,21 +163,6 @@
*/
@ChecksSdkIntAtLeast(codename = "S")
public static boolean isAtLeastS() {
- return VERSION.CODENAME.equals("S") || VERSION.CODENAME.equals("T");
- }
-
- /**
- * Checks if the device is running on a pre-release version of Android T or a release version of
- * Android T or newer.
- * <p>
- * <strong>Note:</strong> When Android T is finalized for release, this method will be
- * deprecated and all calls should be replaced with {@code Build.VERSION.SDK_INT >=
- * Build.VERSION_CODES.T}.
- *
- * @return {@code true} if T APIs are available for use, {@code false} otherwise
- */
- @ChecksSdkIntAtLeast(codename = "T")
- public static boolean isAtLeastT() {
- return VERSION.CODENAME.equals("T");
+ return isAtLeastPreReleaseCodename("S", VERSION.CODENAME);
}
}
diff --git a/core/core/src/main/java/androidx/core/widget/ContentLoadingProgressBar.java b/core/core/src/main/java/androidx/core/widget/ContentLoadingProgressBar.java
index e24b6a1..2eb84ef 100644
--- a/core/core/src/main/java/androidx/core/widget/ContentLoadingProgressBar.java
+++ b/core/core/src/main/java/androidx/core/widget/ContentLoadingProgressBar.java
@@ -23,44 +23,35 @@
import androidx.annotation.NonNull;
import androidx.annotation.Nullable;
+import androidx.annotation.UiThread;
/**
* ContentLoadingProgressBar implements a ProgressBar that waits a minimum time to be
* dismissed before showing. Once visible, the progress bar will be visible for
* a minimum amount of time to avoid "flashes" in the UI when an event could take
- * a largely variable time to complete (from none, to a user perceivable amount)
+ * a largely variable time to complete (from none, to a user perceivable amount).
*/
public class ContentLoadingProgressBar extends ProgressBar {
- private static final int MIN_SHOW_TIME = 500; // ms
- private static final int MIN_DELAY = 500; // ms
+ private static final int MIN_SHOW_TIME_MS = 500;
+ private static final int MIN_DELAY_MS = 500;
+ // These fields should only be accessed on the UI thread.
long mStartTime = -1;
-
boolean mPostedHide = false;
-
boolean mPostedShow = false;
-
boolean mDismissed = false;
- private final Runnable mDelayedHide = new Runnable() {
-
- @Override
- public void run() {
- mPostedHide = false;
- mStartTime = -1;
- setVisibility(View.GONE);
- }
+ private final Runnable mDelayedHide = () -> {
+ mPostedHide = false;
+ mStartTime = -1;
+ setVisibility(View.GONE);
};
- private final Runnable mDelayedShow = new Runnable() {
-
- @Override
- public void run() {
- mPostedShow = false;
- if (!mDismissed) {
- mStartTime = System.currentTimeMillis();
- setVisibility(View.VISIBLE);
- }
+ private final Runnable mDelayedShow = () -> {
+ mPostedShow = false;
+ if (!mDismissed) {
+ mStartTime = System.currentTimeMillis();
+ setVisibility(View.VISIBLE);
}
};
@@ -93,13 +84,23 @@
* Hide the progress view if it is visible. The progress view will not be
* hidden until it has been shown for at least a minimum show time. If the
* progress view was not yet visible, cancels showing the progress view.
+ * <p>
+ * This method may be called off the UI thread.
*/
- public synchronized void hide() {
+ public void hide() {
+ // This method used to be synchronized, presumably so that it could be safely called off
+ // the UI thread; however, the referenced fields were still accessed both on and off the
+ // UI thread, e.g. not thread-safe. Now we hand-off everything to the UI thread.
+ post(this::hideOnUiThread);
+ }
+
+ @UiThread
+ private void hideOnUiThread() {
mDismissed = true;
removeCallbacks(mDelayedShow);
mPostedShow = false;
long diff = System.currentTimeMillis() - mStartTime;
- if (diff >= MIN_SHOW_TIME || mStartTime == -1) {
+ if (diff >= MIN_SHOW_TIME_MS || mStartTime == -1) {
// The progress spinner has been shown long enough
// OR was not shown yet. If it wasn't shown yet,
// it will just never be shown.
@@ -109,7 +110,7 @@
// so put a delayed message in to hide it when its been
// shown long enough.
if (!mPostedHide) {
- postDelayed(mDelayedHide, MIN_SHOW_TIME - diff);
+ postDelayed(mDelayedHide, MIN_SHOW_TIME_MS - diff);
mPostedHide = true;
}
}
@@ -118,15 +119,25 @@
/**
* Show the progress view after waiting for a minimum delay. If
* during that time, hide() is called, the view is never made visible.
+ * <p>
+ * This method may be called off the UI thread.
*/
- public synchronized void show() {
+ public void show() {
+ // This method used to be synchronized, presumably so that it could be safely called off
+ // the UI thread; however, the referenced fields were still accessed both on and off the
+ // UI thread, e.g. not thread-safe. Now we hand-off everything to the UI thread.
+ post(this::showOnUiThread);
+ }
+
+ @UiThread
+ private void showOnUiThread() {
// Reset the start time.
mStartTime = -1;
mDismissed = false;
removeCallbacks(mDelayedHide);
mPostedHide = false;
if (!mPostedShow) {
- postDelayed(mDelayedShow, MIN_DELAY);
+ postDelayed(mDelayedShow, MIN_DELAY_MS);
mPostedShow = true;
}
}
diff --git a/development/build_log_simplifier/message-flakes.ignore b/development/build_log_simplifier/message-flakes.ignore
index 843e9d4..f19cee7 100644
--- a/development/build_log_simplifier/message-flakes.ignore
+++ b/development/build_log_simplifier/message-flakes.ignore
@@ -75,3 +75,29 @@
warning: ATTENTION!
# b/185474400
at org.gradle.*
+# > Task :internal-testutils-common:lintAnalyze
+Scanning .*:
+Failure reading binary cache file .*\.android\/cache\/api\-versions\-[0-9]+\-[0-9A-Z]+rev[0-9]+\.bin
+Please delete the file and restart the IDE\/lint\: .*\.android\/cache\/api\-versions\-[0-9]+\-[0-9]+rev[0-9]+\.bin
+java\.io\.FileNotFoundException\: .*\.android\/cache\/api\-versions\-[0-9]+\-[0-9]+rev[0-9]+\.bin \(No such file or directory\)
+at com\.google\.common\.io\.Files\$FileByteSource\.openStream\(Files\.java\:[0-9]+\)
+at com\.google\.common\.io\.Files\$FileByteSource\.read\(Files\.java\:[0-9]+\)
+at com\.google\.common\.io\.Files\.toByteArray\(Files\.java\:[0-9]+\)
+at com\.android\.tools\.lint\.checks\.ApiDatabase\.readData\(ApiDatabase\.java\:[0-9]+\)
+at com\.android\.tools\.lint\.checks\.ApiLookup\.\<init\>\(ApiLookup\.java\:[0-9]+\)
+at com\.android\.tools\.lint\.checks\.ApiLookup\.get\(ApiLookup\.java\:[0-9]+\)
+at com\.android\.tools\.lint\.checks\.ApiDetector\.beforeCheckRootProject\(ApiDetector\.kt\:[0-9]+\)
+at com\.android\.tools\.lint\.client\.api\.LintDriver\.checkProject\(LintDriver\.kt\:[0-9]+\)
+at com\.android\.tools\.lint\.client\.api\.LintDriver\.checkProjectRoot\(LintDriver\.kt\:[0-9]+\)
+at com\.android\.tools\.lint\.client\.api\.LintDriver\.access\$checkProjectRoot\(LintDriver\.kt\:[0-9]+\)
+at com\.android\.tools\.lint\.client\.api\.LintDriver\$analyzeOnly\$[0-9]+\.invoke\(LintDriver\.kt\:[0-9]+\)
+at com\.android\.tools\.lint\.client\.api\.LintDriver\.doAnalyze\(LintDriver\.kt\:[0-9]+\)
+at com\.android\.tools\.lint\.client\.api\.LintDriver\.analyzeOnly\(LintDriver\.kt\:[0-9]+\)
+at com\.android\.tools\.lint\.LintCliClient\$analyzeOnly\$[0-9]+\.invoke\(LintCliClient\.kt\:[0-9]+\)
+at com\.android\.tools\.lint\.LintCliClient\.run\(LintCliClient\.kt\:[0-9]+\)
+at com\.android\.tools\.lint\.LintCliClient\.run\$default\(LintCliClient\.kt\:[0-9]+\)
+at com\.android\.tools\.lint\.LintCliClient\.analyzeOnly\(LintCliClient\.kt\:[0-9]+\)
+at com\.android\.tools\.lint\.Main\.run\(Main\.java\:[0-9]+\)
+at com\.android\.build\.gradle\.internal\.lint\.AndroidLintWorkAction\.invokeLintMainRunMethod\(AndroidLintWorkAction\.kt\:[0-9]+\)
+at com\.android\.build\.gradle\.internal\.lint\.AndroidLintWorkAction\.runLint\(AndroidLintWorkAction\.kt\:[0-9]+\)
+at com\.android\.build\.gradle\.internal\.lint\.AndroidLintWorkAction\.execute\(AndroidLintWorkAction\.kt\:[0-9]+\)
diff --git a/development/referenceDocs/stageReferenceDocsWithDackka.sh b/development/referenceDocs/stageReferenceDocsWithDackka.sh
index b5689aa..cc34502 100755
--- a/development/referenceDocs/stageReferenceDocsWithDackka.sh
+++ b/development/referenceDocs/stageReferenceDocsWithDackka.sh
@@ -26,6 +26,7 @@
# "collection"
"navigation"
"paging"
+ "window"
)
readonly kotlinLibraryDirs=(
# "benchmark"
@@ -33,6 +34,7 @@
# "collection"
"navigation"
# "paging"
+ "window"
)
diff --git a/docs-tip-of-tree/build.gradle b/docs-tip-of-tree/build.gradle
index 69af6e3..1ffc337 100644
--- a/docs-tip-of-tree/build.gradle
+++ b/docs-tip-of-tree/build.gradle
@@ -208,6 +208,7 @@
docs(project(":room:room-guava"))
docs(project(":room:room-ktx"))
docs(project(":room:room-migration"))
+ docs(project(":room:room-paging"))
docs(project(":room:room-runtime"))
docs(project(":room:room-rxjava2"))
docs(project(":room:room-rxjava3"))
diff --git a/fragment/fragment/api/current.txt b/fragment/fragment/api/current.txt
index 9bb98ad..f56726e 100644
--- a/fragment/fragment/api/current.txt
+++ b/fragment/fragment/api/current.txt
@@ -494,13 +494,31 @@
method public android.view.ViewGroup? getParentContainer();
}
- public final class RetainInstanceUsageViolation extends androidx.fragment.app.strictmode.Violation {
+ public final class GetRetainInstanceUsageViolation extends androidx.fragment.app.strictmode.RetainInstanceUsageViolation {
+ }
+
+ public final class GetTargetFragmentRequestCodeUsageViolation extends androidx.fragment.app.strictmode.TargetFragmentUsageViolation {
+ }
+
+ public final class GetTargetFragmentUsageViolation extends androidx.fragment.app.strictmode.TargetFragmentUsageViolation {
+ }
+
+ public abstract class RetainInstanceUsageViolation extends androidx.fragment.app.strictmode.Violation {
+ }
+
+ public final class SetRetainInstanceUsageViolation extends androidx.fragment.app.strictmode.RetainInstanceUsageViolation {
+ }
+
+ public final class SetTargetFragmentUsageViolation extends androidx.fragment.app.strictmode.TargetFragmentUsageViolation {
+ method public int getRequestCode();
+ method public androidx.fragment.app.Fragment getTargetFragment();
}
public final class SetUserVisibleHintViolation extends androidx.fragment.app.strictmode.Violation {
+ method public boolean isVisibleToUser();
}
- public final class TargetFragmentUsageViolation extends androidx.fragment.app.strictmode.Violation {
+ public abstract class TargetFragmentUsageViolation extends androidx.fragment.app.strictmode.Violation {
}
public abstract class Violation extends java.lang.RuntimeException {
@@ -508,6 +526,7 @@
}
public final class WrongFragmentContainerViolation extends androidx.fragment.app.strictmode.Violation {
+ method public android.view.ViewGroup getContainer();
}
}
diff --git a/fragment/fragment/api/public_plus_experimental_current.txt b/fragment/fragment/api/public_plus_experimental_current.txt
index d90beb5..23c97fe 100644
--- a/fragment/fragment/api/public_plus_experimental_current.txt
+++ b/fragment/fragment/api/public_plus_experimental_current.txt
@@ -464,10 +464,6 @@
public final class FragmentStrictMode {
method public static androidx.fragment.app.strictmode.FragmentStrictMode.Policy getDefaultPolicy();
- method @RestrictTo(androidx.annotation.RestrictTo.Scope.LIBRARY) public static void onRetainInstanceUsage(androidx.fragment.app.Fragment);
- method @RestrictTo(androidx.annotation.RestrictTo.Scope.LIBRARY) public static void onSetUserVisibleHint(androidx.fragment.app.Fragment);
- method @RestrictTo(androidx.annotation.RestrictTo.Scope.LIBRARY) public static void onTargetFragmentUsage(androidx.fragment.app.Fragment);
- method @RestrictTo(androidx.annotation.RestrictTo.Scope.LIBRARY) public static void onWrongFragmentContainer(androidx.fragment.app.Fragment);
method public static void setDefaultPolicy(androidx.fragment.app.strictmode.FragmentStrictMode.Policy);
}
@@ -498,13 +494,31 @@
method public android.view.ViewGroup? getParentContainer();
}
- public final class RetainInstanceUsageViolation extends androidx.fragment.app.strictmode.Violation {
+ public final class GetRetainInstanceUsageViolation extends androidx.fragment.app.strictmode.RetainInstanceUsageViolation {
+ }
+
+ public final class GetTargetFragmentRequestCodeUsageViolation extends androidx.fragment.app.strictmode.TargetFragmentUsageViolation {
+ }
+
+ public final class GetTargetFragmentUsageViolation extends androidx.fragment.app.strictmode.TargetFragmentUsageViolation {
+ }
+
+ public abstract class RetainInstanceUsageViolation extends androidx.fragment.app.strictmode.Violation {
+ }
+
+ public final class SetRetainInstanceUsageViolation extends androidx.fragment.app.strictmode.RetainInstanceUsageViolation {
+ }
+
+ public final class SetTargetFragmentUsageViolation extends androidx.fragment.app.strictmode.TargetFragmentUsageViolation {
+ method public int getRequestCode();
+ method public androidx.fragment.app.Fragment getTargetFragment();
}
public final class SetUserVisibleHintViolation extends androidx.fragment.app.strictmode.Violation {
+ method public boolean isVisibleToUser();
}
- public final class TargetFragmentUsageViolation extends androidx.fragment.app.strictmode.Violation {
+ public abstract class TargetFragmentUsageViolation extends androidx.fragment.app.strictmode.Violation {
}
public abstract class Violation extends java.lang.RuntimeException {
@@ -512,6 +526,7 @@
}
public final class WrongFragmentContainerViolation extends androidx.fragment.app.strictmode.Violation {
+ method public android.view.ViewGroup getContainer();
}
}
diff --git a/fragment/fragment/api/restricted_current.txt b/fragment/fragment/api/restricted_current.txt
index 225eb79..86bd304 100644
--- a/fragment/fragment/api/restricted_current.txt
+++ b/fragment/fragment/api/restricted_current.txt
@@ -494,10 +494,6 @@
public final class FragmentStrictMode {
method public static androidx.fragment.app.strictmode.FragmentStrictMode.Policy getDefaultPolicy();
- method @RestrictTo(androidx.annotation.RestrictTo.Scope.LIBRARY) public static void onRetainInstanceUsage(androidx.fragment.app.Fragment);
- method @RestrictTo(androidx.annotation.RestrictTo.Scope.LIBRARY) public static void onSetUserVisibleHint(androidx.fragment.app.Fragment);
- method @RestrictTo(androidx.annotation.RestrictTo.Scope.LIBRARY) public static void onTargetFragmentUsage(androidx.fragment.app.Fragment);
- method @RestrictTo(androidx.annotation.RestrictTo.Scope.LIBRARY) public static void onWrongFragmentContainer(androidx.fragment.app.Fragment);
method public static void setDefaultPolicy(androidx.fragment.app.strictmode.FragmentStrictMode.Policy);
}
@@ -528,13 +524,31 @@
method public android.view.ViewGroup? getParentContainer();
}
- public final class RetainInstanceUsageViolation extends androidx.fragment.app.strictmode.Violation {
+ public final class GetRetainInstanceUsageViolation extends androidx.fragment.app.strictmode.RetainInstanceUsageViolation {
+ }
+
+ public final class GetTargetFragmentRequestCodeUsageViolation extends androidx.fragment.app.strictmode.TargetFragmentUsageViolation {
+ }
+
+ public final class GetTargetFragmentUsageViolation extends androidx.fragment.app.strictmode.TargetFragmentUsageViolation {
+ }
+
+ public abstract class RetainInstanceUsageViolation extends androidx.fragment.app.strictmode.Violation {
+ }
+
+ public final class SetRetainInstanceUsageViolation extends androidx.fragment.app.strictmode.RetainInstanceUsageViolation {
+ }
+
+ public final class SetTargetFragmentUsageViolation extends androidx.fragment.app.strictmode.TargetFragmentUsageViolation {
+ method public int getRequestCode();
+ method public androidx.fragment.app.Fragment getTargetFragment();
}
public final class SetUserVisibleHintViolation extends androidx.fragment.app.strictmode.Violation {
+ method public boolean isVisibleToUser();
}
- public final class TargetFragmentUsageViolation extends androidx.fragment.app.strictmode.Violation {
+ public abstract class TargetFragmentUsageViolation extends androidx.fragment.app.strictmode.Violation {
}
public abstract class Violation extends java.lang.RuntimeException {
@@ -542,6 +556,7 @@
}
public final class WrongFragmentContainerViolation extends androidx.fragment.app.strictmode.Violation {
+ method public android.view.ViewGroup getContainer();
}
}
diff --git a/fragment/fragment/src/androidTest/java/androidx/fragment/app/strictmode/FragmentStrictModeTest.kt b/fragment/fragment/src/androidTest/java/androidx/fragment/app/strictmode/FragmentStrictModeTest.kt
index 39895c6..1830361 100644
--- a/fragment/fragment/src/androidTest/java/androidx/fragment/app/strictmode/FragmentStrictModeTest.kt
+++ b/fragment/fragment/src/androidTest/java/androidx/fragment/app/strictmode/FragmentStrictModeTest.kt
@@ -214,6 +214,7 @@
}
}
+ @Suppress("DEPRECATION")
@Test
public fun detectRetainInstanceUsage() {
var violation: Violation? = null
@@ -223,14 +224,12 @@
.build()
FragmentStrictMode.setDefaultPolicy(policy)
- @Suppress("DEPRECATION")
StrictFragment().retainInstance = true
- assertThat(violation).isInstanceOf(RetainInstanceUsageViolation::class.java)
+ assertThat(violation).isInstanceOf(SetRetainInstanceUsageViolation::class.java)
violation = null
- @Suppress("DEPRECATION")
StrictFragment().retainInstance
- assertThat(violation).isInstanceOf(RetainInstanceUsageViolation::class.java)
+ assertThat(violation).isInstanceOf(GetRetainInstanceUsageViolation::class.java)
}
@Test
@@ -247,6 +246,7 @@
assertThat(violation).isInstanceOf(SetUserVisibleHintViolation::class.java)
}
+ @Suppress("DEPRECATION")
@Test
public fun detectTargetFragmentUsage() {
var violation: Violation? = null
@@ -256,19 +256,16 @@
.build()
FragmentStrictMode.setDefaultPolicy(policy)
- @Suppress("DEPRECATION")
StrictFragment().setTargetFragment(StrictFragment(), 1)
- assertThat(violation).isInstanceOf(TargetFragmentUsageViolation::class.java)
+ assertThat(violation).isInstanceOf(SetTargetFragmentUsageViolation::class.java)
violation = null
- @Suppress("DEPRECATION")
StrictFragment().targetFragment
- assertThat(violation).isInstanceOf(TargetFragmentUsageViolation::class.java)
+ assertThat(violation).isInstanceOf(GetTargetFragmentUsageViolation::class.java)
violation = null
- @Suppress("DEPRECATION")
StrictFragment().targetRequestCode
- assertThat(violation).isInstanceOf(TargetFragmentUsageViolation::class.java)
+ assertThat(violation).isInstanceOf(GetTargetFragmentRequestCodeUsageViolation::class.java)
}
@Test
@@ -298,11 +295,13 @@
}
}
+ @Suppress("DEPRECATION")
@Test
public fun detectAllowedViolations() {
val violationClass1 = RetainInstanceUsageViolation::class.java
val violationClass2 = SetUserVisibleHintViolation::class.java
- val violationClassList = listOf(violationClass1, violationClass2)
+ val violationClass3 = GetTargetFragmentUsageViolation::class.java
+ val violationClassList = listOf(violationClass1, violationClass2, violationClass3)
var violation: Violation? = null
var policyBuilder = FragmentStrictMode.Policy.Builder()
@@ -314,21 +313,21 @@
}
FragmentStrictMode.setDefaultPolicy(policyBuilder.build())
- @Suppress("DEPRECATION")
StrictFragment().retainInstance = true
assertThat(violation).isNotInstanceOf(violationClass1)
- assertThat(violation).isNotInstanceOf(violationClass2)
+ assertThat(violation).isNotInstanceOf(SetRetainInstanceUsageViolation::class.java)
violation = null
- @Suppress("DEPRECATION")
StrictFragment().retainInstance
assertThat(violation).isNotInstanceOf(violationClass1)
+ assertThat(violation).isNotInstanceOf(GetRetainInstanceUsageViolation::class.java)
+
+ violation = null
+ StrictFragment().userVisibleHint = true
assertThat(violation).isNotInstanceOf(violationClass2)
violation = null
- @Suppress("DEPRECATION")
- StrictFragment().userVisibleHint = true
- assertThat(violation).isNotInstanceOf(violationClass1)
- assertThat(violation).isNotInstanceOf(violationClass2)
+ StrictFragment().targetFragment
+ assertThat(violation).isNotInstanceOf(violationClass3)
}
}
diff --git a/fragment/fragment/src/main/java/androidx/fragment/app/Fragment.java b/fragment/fragment/src/main/java/androidx/fragment/app/Fragment.java
index 1bf3be1..89d8c4f5 100644
--- a/fragment/fragment/src/main/java/androidx/fragment/app/Fragment.java
+++ b/fragment/fragment/src/main/java/androidx/fragment/app/Fragment.java
@@ -804,7 +804,9 @@
@SuppressWarnings("ReferenceEquality, deprecation")
@Deprecated
public void setTargetFragment(@Nullable Fragment fragment, int requestCode) {
- FragmentStrictMode.onTargetFragmentUsage(this);
+ if (fragment != null) {
+ FragmentStrictMode.onSetTargetFragmentUsage(this, fragment, requestCode);
+ }
// Don't allow a caller to set a target fragment in another FragmentManager,
// but there's a snag: people do set target fragments before fragments get added.
// We'll have the FragmentManager check that for validity when we move
@@ -818,7 +820,7 @@
}
// Don't let someone create a cycle.
- for (Fragment check = fragment; check != null; check = check.getTargetFragment()) {
+ for (Fragment check = fragment; check != null; check = check.getTargetFragment(false)) {
if (check.equals(this)) {
throw new IllegalArgumentException("Setting " + fragment + " as the target of "
+ this + " would create a target cycle");
@@ -852,7 +854,19 @@
@Nullable
@Deprecated
final public Fragment getTargetFragment() {
- FragmentStrictMode.onTargetFragmentUsage(this);
+ return getTargetFragment(true);
+ }
+
+ /**
+ * Use with {@param logViolations} set to {@code false} for all internal calls instead of the
+ * public {@link #getTargetFragment}.
+ */
+ @Nullable
+ private Fragment getTargetFragment(boolean logViolations) {
+ if (logViolations) {
+ FragmentStrictMode.onGetTargetFragmentUsage(this);
+ }
+
if (mTarget != null) {
// Ensure that any Fragment set with setTargetFragment is immediately
// available here
@@ -875,7 +889,7 @@
*/
@Deprecated
final public int getTargetRequestCode() {
- FragmentStrictMode.onTargetFragmentUsage(this);
+ FragmentStrictMode.onGetTargetFragmentRequestCodeUsage(this);
return mTargetRequestCode;
}
@@ -1224,7 +1238,7 @@
*/
@Deprecated
public void setRetainInstance(boolean retain) {
- FragmentStrictMode.onRetainInstanceUsage(this);
+ FragmentStrictMode.onSetRetainInstanceUsage(this);
mRetainInstance = retain;
if (mFragmentManager != null) {
if (retain) {
@@ -1251,7 +1265,7 @@
*/
@Deprecated
final public boolean getRetainInstance() {
- FragmentStrictMode.onRetainInstanceUsage(this);
+ FragmentStrictMode.onGetRetainInstanceUsage(this);
return mRetainInstance;
}
@@ -1313,7 +1327,7 @@
*/
@Deprecated
public void setUserVisibleHint(boolean isVisibleToUser) {
- FragmentStrictMode.onSetUserVisibleHint(this);
+ FragmentStrictMode.onSetUserVisibleHint(this, isVisibleToUser);
if (!mUserVisibleHint && isVisibleToUser && mState < STARTED
&& mFragmentManager != null && isAdded() && mIsCreated) {
mFragmentManager.performPendingDeferredStart(
@@ -2826,7 +2840,7 @@
writer.print(prefix); writer.print("mSavedViewRegistryState=");
writer.println(mSavedViewRegistryState);
}
- Fragment target = getTargetFragment();
+ Fragment target = getTargetFragment(false);
if (target != null) {
writer.print(prefix); writer.print("mTarget="); writer.print(target);
writer.print(" mTargetRequestCode=");
diff --git a/fragment/fragment/src/main/java/androidx/fragment/app/FragmentStateManager.java b/fragment/fragment/src/main/java/androidx/fragment/app/FragmentStateManager.java
index 5ebc691..e6f976b 100644
--- a/fragment/fragment/src/main/java/androidx/fragment/app/FragmentStateManager.java
+++ b/fragment/fragment/src/main/java/androidx/fragment/app/FragmentStateManager.java
@@ -482,19 +482,22 @@
}
FragmentContainer fragmentContainer = mFragment.mFragmentManager.getContainer();
container = (ViewGroup) fragmentContainer.onFindViewById(mFragment.mContainerId);
- if (!(container instanceof FragmentContainerView)) {
- FragmentStrictMode.onWrongFragmentContainer(mFragment);
- }
- if (container == null && !mFragment.mRestored) {
- String resName;
- try {
- resName = mFragment.getResources().getResourceName(mFragment.mContainerId);
- } catch (Resources.NotFoundException e) {
- resName = "unknown";
+ if (container == null) {
+ if (!mFragment.mRestored) {
+ String resName;
+ try {
+ resName = mFragment.getResources().getResourceName(mFragment.mContainerId);
+ } catch (Resources.NotFoundException e) {
+ resName = "unknown";
+ }
+ throw new IllegalArgumentException("No view found for id 0x"
+ + Integer.toHexString(mFragment.mContainerId) + " ("
+ + resName + ") for fragment " + mFragment);
}
- throw new IllegalArgumentException("No view found for id 0x"
- + Integer.toHexString(mFragment.mContainerId) + " ("
- + resName + ") for fragment " + mFragment);
+ } else {
+ if (!(container instanceof FragmentContainerView)) {
+ FragmentStrictMode.onWrongFragmentContainer(mFragment, container);
+ }
}
}
mFragment.mContainer = container;
diff --git a/fragment/fragment/src/main/java/androidx/fragment/app/strictmode/FragmentStrictMode.java b/fragment/fragment/src/main/java/androidx/fragment/app/strictmode/FragmentStrictMode.java
index 75ca89e..ac43754 100644
--- a/fragment/fragment/src/main/java/androidx/fragment/app/strictmode/FragmentStrictMode.java
+++ b/fragment/fragment/src/main/java/androidx/fragment/app/strictmode/FragmentStrictMode.java
@@ -320,9 +320,10 @@
}
}
+ /** @hide */
@RestrictTo(RestrictTo.Scope.LIBRARY)
- public static void onRetainInstanceUsage(@NonNull Fragment fragment) {
- Violation violation = new RetainInstanceUsageViolation(fragment);
+ public static void onSetRetainInstanceUsage(@NonNull Fragment fragment) {
+ Violation violation = new SetRetainInstanceUsageViolation(fragment);
logIfDebuggingEnabled(violation);
Policy policy = getNearestPolicy(fragment);
@@ -333,9 +334,24 @@
}
}
+ /** @hide */
@RestrictTo(RestrictTo.Scope.LIBRARY)
- public static void onSetUserVisibleHint(@NonNull Fragment fragment) {
- Violation violation = new SetUserVisibleHintViolation(fragment);
+ public static void onGetRetainInstanceUsage(@NonNull Fragment fragment) {
+ Violation violation = new GetRetainInstanceUsageViolation(fragment);
+ logIfDebuggingEnabled(violation);
+
+ Policy policy = getNearestPolicy(fragment);
+ if (policy.mFlags.contains(Flag.DETECT_RETAIN_INSTANCE_USAGE)
+ && shouldHandlePolicyViolation(
+ policy, fragment.getClass(), violation.getClass())) {
+ handlePolicyViolation(policy, violation);
+ }
+ }
+
+ /** @hide */
+ @RestrictTo(RestrictTo.Scope.LIBRARY)
+ public static void onSetUserVisibleHint(@NonNull Fragment fragment, boolean isVisibleToUser) {
+ Violation violation = new SetUserVisibleHintViolation(fragment, isVisibleToUser);
logIfDebuggingEnabled(violation);
Policy policy = getNearestPolicy(fragment);
@@ -346,9 +362,28 @@
}
}
+ /** @hide */
@RestrictTo(RestrictTo.Scope.LIBRARY)
- public static void onTargetFragmentUsage(@NonNull Fragment fragment) {
- Violation violation = new TargetFragmentUsageViolation(fragment);
+ public static void onSetTargetFragmentUsage(
+ @NonNull Fragment violatingFragment,
+ @NonNull Fragment targetFragment,
+ int requestCode) {
+ Violation violation = new SetTargetFragmentUsageViolation(
+ violatingFragment, targetFragment, requestCode);
+ logIfDebuggingEnabled(violation);
+
+ Policy policy = getNearestPolicy(violatingFragment);
+ if (policy.mFlags.contains(Flag.DETECT_TARGET_FRAGMENT_USAGE)
+ && shouldHandlePolicyViolation(
+ policy, violatingFragment.getClass(), violation.getClass())) {
+ handlePolicyViolation(policy, violation);
+ }
+ }
+
+ /** @hide */
+ @RestrictTo(RestrictTo.Scope.LIBRARY)
+ public static void onGetTargetFragmentUsage(@NonNull Fragment fragment) {
+ Violation violation = new GetTargetFragmentUsageViolation(fragment);
logIfDebuggingEnabled(violation);
Policy policy = getNearestPolicy(fragment);
@@ -359,9 +394,26 @@
}
}
+ /** @hide */
@RestrictTo(RestrictTo.Scope.LIBRARY)
- public static void onWrongFragmentContainer(@NonNull Fragment fragment) {
- Violation violation = new WrongFragmentContainerViolation(fragment);
+ public static void onGetTargetFragmentRequestCodeUsage(@NonNull Fragment fragment) {
+ Violation violation = new GetTargetFragmentRequestCodeUsageViolation(fragment);
+ logIfDebuggingEnabled(violation);
+
+ Policy policy = getNearestPolicy(fragment);
+ if (policy.mFlags.contains(Flag.DETECT_TARGET_FRAGMENT_USAGE)
+ && shouldHandlePolicyViolation(
+ policy, fragment.getClass(), violation.getClass())) {
+ handlePolicyViolation(policy, violation);
+ }
+ }
+
+ /** @hide */
+ @RestrictTo(RestrictTo.Scope.LIBRARY)
+ public static void onWrongFragmentContainer(
+ @NonNull Fragment fragment,
+ @NonNull ViewGroup container) {
+ Violation violation = new WrongFragmentContainerViolation(fragment, container);
logIfDebuggingEnabled(violation);
Policy policy = getNearestPolicy(fragment);
@@ -397,7 +449,16 @@
@NonNull Class<? extends Violation> violationClass) {
Set<Class<? extends Violation>> violationsToBypass =
policy.mAllowedViolations.get(fragmentClass);
- return violationsToBypass == null || !violationsToBypass.contains(violationClass);
+ if (violationsToBypass == null) {
+ return true;
+ }
+
+ if (violationClass.getSuperclass() != Violation.class) {
+ if (violationsToBypass.contains(violationClass.getSuperclass())) {
+ return false;
+ }
+ }
+ return !violationsToBypass.contains(violationClass);
}
private static void handlePolicyViolation(
diff --git a/fragment/fragment/src/main/java/androidx/fragment/app/strictmode/FragmentTagUsageViolation.java b/fragment/fragment/src/main/java/androidx/fragment/app/strictmode/FragmentTagUsageViolation.java
index c1f1e4b..9dffe58 100644
--- a/fragment/fragment/src/main/java/androidx/fragment/app/strictmode/FragmentTagUsageViolation.java
+++ b/fragment/fragment/src/main/java/androidx/fragment/app/strictmode/FragmentTagUsageViolation.java
@@ -26,7 +26,7 @@
public final class FragmentTagUsageViolation extends Violation {
@Nullable
- private ViewGroup mContainer;
+ private final ViewGroup mContainer;
FragmentTagUsageViolation(@NonNull Fragment fragment, @Nullable ViewGroup container) {
super(fragment);
diff --git a/fragment/fragment/src/main/java/androidx/fragment/app/strictmode/GetRetainInstanceUsageViolation.java b/fragment/fragment/src/main/java/androidx/fragment/app/strictmode/GetRetainInstanceUsageViolation.java
new file mode 100644
index 0000000..6ed5a3d
--- /dev/null
+++ b/fragment/fragment/src/main/java/androidx/fragment/app/strictmode/GetRetainInstanceUsageViolation.java
@@ -0,0 +1,28 @@
+/*
+ * Copyright 2021 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.fragment.app.strictmode;
+
+import androidx.annotation.NonNull;
+import androidx.fragment.app.Fragment;
+
+/** See #{@link FragmentStrictMode.Policy.Builder#detectRetainInstanceUsage()}. */
+public final class GetRetainInstanceUsageViolation extends RetainInstanceUsageViolation {
+
+ GetRetainInstanceUsageViolation(@NonNull Fragment fragment) {
+ super(fragment);
+ }
+}
diff --git a/fragment/fragment/src/main/java/androidx/fragment/app/strictmode/GetTargetFragmentRequestCodeUsageViolation.java b/fragment/fragment/src/main/java/androidx/fragment/app/strictmode/GetTargetFragmentRequestCodeUsageViolation.java
new file mode 100644
index 0000000..84053ee
--- /dev/null
+++ b/fragment/fragment/src/main/java/androidx/fragment/app/strictmode/GetTargetFragmentRequestCodeUsageViolation.java
@@ -0,0 +1,28 @@
+/*
+ * Copyright 2021 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.fragment.app.strictmode;
+
+import androidx.annotation.NonNull;
+import androidx.fragment.app.Fragment;
+
+/** See #{@link FragmentStrictMode.Policy.Builder#detectTargetFragmentUsage()}. */
+public final class GetTargetFragmentRequestCodeUsageViolation extends TargetFragmentUsageViolation {
+
+ GetTargetFragmentRequestCodeUsageViolation(@NonNull Fragment fragment) {
+ super(fragment);
+ }
+}
diff --git a/fragment/fragment/src/main/java/androidx/fragment/app/strictmode/GetTargetFragmentUsageViolation.java b/fragment/fragment/src/main/java/androidx/fragment/app/strictmode/GetTargetFragmentUsageViolation.java
new file mode 100644
index 0000000..da46c84
--- /dev/null
+++ b/fragment/fragment/src/main/java/androidx/fragment/app/strictmode/GetTargetFragmentUsageViolation.java
@@ -0,0 +1,28 @@
+/*
+ * Copyright 2021 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.fragment.app.strictmode;
+
+import androidx.annotation.NonNull;
+import androidx.fragment.app.Fragment;
+
+/** See #{@link FragmentStrictMode.Policy.Builder#detectTargetFragmentUsage()}. */
+public final class GetTargetFragmentUsageViolation extends TargetFragmentUsageViolation {
+
+ GetTargetFragmentUsageViolation(@NonNull Fragment fragment) {
+ super(fragment);
+ }
+}
diff --git a/fragment/fragment/src/main/java/androidx/fragment/app/strictmode/RetainInstanceUsageViolation.java b/fragment/fragment/src/main/java/androidx/fragment/app/strictmode/RetainInstanceUsageViolation.java
index 9c5b074..f7ebdc2 100644
--- a/fragment/fragment/src/main/java/androidx/fragment/app/strictmode/RetainInstanceUsageViolation.java
+++ b/fragment/fragment/src/main/java/androidx/fragment/app/strictmode/RetainInstanceUsageViolation.java
@@ -20,7 +20,7 @@
import androidx.fragment.app.Fragment;
/** See #{@link FragmentStrictMode.Policy.Builder#detectRetainInstanceUsage()}. */
-public final class RetainInstanceUsageViolation extends Violation {
+public abstract class RetainInstanceUsageViolation extends Violation {
RetainInstanceUsageViolation(@NonNull Fragment fragment) {
super(fragment);
diff --git a/fragment/fragment/src/main/java/androidx/fragment/app/strictmode/SetRetainInstanceUsageViolation.java b/fragment/fragment/src/main/java/androidx/fragment/app/strictmode/SetRetainInstanceUsageViolation.java
new file mode 100644
index 0000000..dbeb9be
--- /dev/null
+++ b/fragment/fragment/src/main/java/androidx/fragment/app/strictmode/SetRetainInstanceUsageViolation.java
@@ -0,0 +1,28 @@
+/*
+ * Copyright 2021 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.fragment.app.strictmode;
+
+import androidx.annotation.NonNull;
+import androidx.fragment.app.Fragment;
+
+/** See #{@link FragmentStrictMode.Policy.Builder#detectRetainInstanceUsage()}. */
+public final class SetRetainInstanceUsageViolation extends RetainInstanceUsageViolation {
+
+ SetRetainInstanceUsageViolation(@NonNull Fragment fragment) {
+ super(fragment);
+ }
+}
diff --git a/fragment/fragment/src/main/java/androidx/fragment/app/strictmode/SetTargetFragmentUsageViolation.java b/fragment/fragment/src/main/java/androidx/fragment/app/strictmode/SetTargetFragmentUsageViolation.java
new file mode 100644
index 0000000..8d4374c
--- /dev/null
+++ b/fragment/fragment/src/main/java/androidx/fragment/app/strictmode/SetTargetFragmentUsageViolation.java
@@ -0,0 +1,45 @@
+/*
+ * Copyright 2021 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.fragment.app.strictmode;
+
+import androidx.annotation.NonNull;
+import androidx.fragment.app.Fragment;
+
+/** See #{@link FragmentStrictMode.Policy.Builder#detectTargetFragmentUsage()}. */
+public final class SetTargetFragmentUsageViolation extends TargetFragmentUsageViolation {
+
+ private final Fragment mTargetFragment;
+ private final int mRequestCode;
+
+ SetTargetFragmentUsageViolation(
+ @NonNull Fragment violatingFragment,
+ @NonNull Fragment targetFragment,
+ int requestCode) {
+ super(violatingFragment);
+ this.mTargetFragment = targetFragment;
+ this.mRequestCode = requestCode;
+ }
+
+ @NonNull
+ public Fragment getTargetFragment() {
+ return mTargetFragment;
+ }
+
+ public int getRequestCode() {
+ return mRequestCode;
+ }
+}
diff --git a/fragment/fragment/src/main/java/androidx/fragment/app/strictmode/SetUserVisibleHintViolation.java b/fragment/fragment/src/main/java/androidx/fragment/app/strictmode/SetUserVisibleHintViolation.java
index 8eea442..122438d 100644
--- a/fragment/fragment/src/main/java/androidx/fragment/app/strictmode/SetUserVisibleHintViolation.java
+++ b/fragment/fragment/src/main/java/androidx/fragment/app/strictmode/SetUserVisibleHintViolation.java
@@ -22,7 +22,18 @@
/** See #{@link FragmentStrictMode.Policy.Builder#detectSetUserVisibleHint()}. */
public final class SetUserVisibleHintViolation extends Violation {
- SetUserVisibleHintViolation(@NonNull Fragment fragment) {
+ private final boolean mIsVisibleToUser;
+
+ SetUserVisibleHintViolation(@NonNull Fragment fragment, boolean isVisibleToUser) {
super(fragment);
+ this.mIsVisibleToUser = isVisibleToUser;
+ }
+
+ /**
+ * Indicates what the {@code isVisibleToUser} field for the {@link Fragment} causing the
+ * Violation was being set to.
+ */
+ public boolean isVisibleToUser() {
+ return mIsVisibleToUser;
}
}
diff --git a/fragment/fragment/src/main/java/androidx/fragment/app/strictmode/TargetFragmentUsageViolation.java b/fragment/fragment/src/main/java/androidx/fragment/app/strictmode/TargetFragmentUsageViolation.java
index bfec26c..b62c430 100644
--- a/fragment/fragment/src/main/java/androidx/fragment/app/strictmode/TargetFragmentUsageViolation.java
+++ b/fragment/fragment/src/main/java/androidx/fragment/app/strictmode/TargetFragmentUsageViolation.java
@@ -20,7 +20,7 @@
import androidx.fragment.app.Fragment;
/** See #{@link FragmentStrictMode.Policy.Builder#detectTargetFragmentUsage()}. */
-public final class TargetFragmentUsageViolation extends Violation {
+public abstract class TargetFragmentUsageViolation extends Violation {
TargetFragmentUsageViolation(@NonNull Fragment fragment) {
super(fragment);
diff --git a/fragment/fragment/src/main/java/androidx/fragment/app/strictmode/WrongFragmentContainerViolation.java b/fragment/fragment/src/main/java/androidx/fragment/app/strictmode/WrongFragmentContainerViolation.java
index 7c85d62..2dd613e 100644
--- a/fragment/fragment/src/main/java/androidx/fragment/app/strictmode/WrongFragmentContainerViolation.java
+++ b/fragment/fragment/src/main/java/androidx/fragment/app/strictmode/WrongFragmentContainerViolation.java
@@ -16,13 +16,27 @@
package androidx.fragment.app.strictmode;
+import android.view.ViewGroup;
+
import androidx.annotation.NonNull;
import androidx.fragment.app.Fragment;
/** See #{@link FragmentStrictMode.Policy.Builder#detectWrongFragmentContainer()}. */
public final class WrongFragmentContainerViolation extends Violation {
- WrongFragmentContainerViolation(@NonNull Fragment fragment) {
+ private final ViewGroup mContainer;
+
+ WrongFragmentContainerViolation(@NonNull Fragment fragment, @NonNull ViewGroup container) {
super(fragment);
+ this.mContainer = container;
+ }
+
+ /**
+ * Gets the container that the {@link Fragment} causing the Violation was
+ * being added to.
+ */
+ @NonNull
+ public ViewGroup getContainer() {
+ return mContainer;
}
}
diff --git a/gradle/libs.versions.toml b/gradle/libs.versions.toml
index 767eb12..5493c52 100644
--- a/gradle/libs.versions.toml
+++ b/gradle/libs.versions.toml
@@ -18,7 +18,7 @@
autoValue = "1.6.3"
dexmaker = "2.25.0"
espresso = "3.3.0"
-hilt = "2.35"
+hilt = "2.36"
incap = "0.2"
kotlin = "1.5.10"
kotlinCompileTesting = "1.4.0"
diff --git a/jetifier/jetifier/processor/build.gradle b/jetifier/jetifier/processor/build.gradle
index 39eeeaa..71565e7 100644
--- a/jetifier/jetifier/processor/build.gradle
+++ b/jetifier/jetifier/processor/build.gradle
@@ -32,8 +32,11 @@
api("org.ow2.asm:asm-commons:8.0.1")
api("org.jdom:jdom2:2.0.6")
api(KOTLIN_STDLIB)
+ api(KOTLIN_METADATA_JVM)
testImplementation("junit:junit:4.12")
testImplementation(TRUTH)
+ testImplementation(KOTLIN_REFLECT)
+ testImplementation(KOTLIN_COMPILE_TESTING)
}
androidx {
diff --git a/jetifier/jetifier/processor/src/main/kotlin/com/android/tools/build/jetifier/processor/Processor.kt b/jetifier/jetifier/processor/src/main/kotlin/com/android/tools/build/jetifier/processor/Processor.kt
index 7c32c73..2fb2197 100644
--- a/jetifier/jetifier/processor/src/main/kotlin/com/android/tools/build/jetifier/processor/Processor.kt
+++ b/jetifier/jetifier/processor/src/main/kotlin/com/android/tools/build/jetifier/processor/Processor.kt
@@ -24,10 +24,11 @@
import com.android.tools.build.jetifier.processor.archive.ArchiveFile
import com.android.tools.build.jetifier.processor.archive.ArchiveItemVisitor
import com.android.tools.build.jetifier.processor.archive.FileSearchResult
-import com.android.tools.build.jetifier.processor.com.android.tools.build.jetifier.processor.transform.java.JavaTransformer
import com.android.tools.build.jetifier.processor.transform.TransformationContext
import com.android.tools.build.jetifier.processor.transform.Transformer
import com.android.tools.build.jetifier.processor.transform.bytecode.ByteCodeTransformer
+import com.android.tools.build.jetifier.processor.transform.java.JavaTransformer
+import com.android.tools.build.jetifier.processor.transform.metainf.KotlinModuleTransformer
import com.android.tools.build.jetifier.processor.transform.metainf.MetaInfTransformer
import com.android.tools.build.jetifier.processor.transform.pom.PomDocument
import com.android.tools.build.jetifier.processor.transform.pom.PomScanner
@@ -59,7 +60,8 @@
ByteCodeTransformer(context),
XmlResourcesTransformer(context),
ProGuardTransformer(context),
- JavaTransformer(context)
+ JavaTransformer(context),
+ KotlinModuleTransformer(context)
)
/**
@@ -70,7 +72,8 @@
ByteCodeTransformer(context),
XmlResourcesTransformer(context),
ProGuardTransformer(context),
- MetaInfTransformer(context)
+ MetaInfTransformer(context),
+ KotlinModuleTransformer(context)
)
/**
diff --git a/jetifier/jetifier/processor/src/main/kotlin/com/android/tools/build/jetifier/processor/transform/TransformationContext.kt b/jetifier/jetifier/processor/src/main/kotlin/com/android/tools/build/jetifier/processor/transform/TransformationContext.kt
index 9b5f12e2..1546bed 100644
--- a/jetifier/jetifier/processor/src/main/kotlin/com/android/tools/build/jetifier/processor/transform/TransformationContext.kt
+++ b/jetifier/jetifier/processor/src/main/kotlin/com/android/tools/build/jetifier/processor/transform/TransformationContext.kt
@@ -119,4 +119,8 @@
)
}
}
+
+ fun reportUnreadableKotlinModule(tag: String, filePath: Path) {
+ Log.e(tag, "Unreadable kotlin module medata file: %s", filePath)
+ }
}
\ No newline at end of file
diff --git a/jetifier/jetifier/processor/src/main/kotlin/com/android/tools/build/jetifier/processor/transform/bytecode/CoreRemapperImpl.kt b/jetifier/jetifier/processor/src/main/kotlin/com/android/tools/build/jetifier/processor/transform/bytecode/CoreRemapperImpl.kt
index a03c041..6427c83 100644
--- a/jetifier/jetifier/processor/src/main/kotlin/com/android/tools/build/jetifier/processor/transform/bytecode/CoreRemapperImpl.kt
+++ b/jetifier/jetifier/processor/src/main/kotlin/com/android/tools/build/jetifier/processor/transform/bytecode/CoreRemapperImpl.kt
@@ -21,7 +21,9 @@
import com.android.tools.build.jetifier.core.utils.Log
import com.android.tools.build.jetifier.processor.transform.TransformationContext
import com.android.tools.build.jetifier.processor.transform.bytecode.asm.CustomRemapper
+import org.objectweb.asm.AnnotationVisitor
import org.objectweb.asm.ClassVisitor
+import org.objectweb.asm.Opcodes
import org.objectweb.asm.commons.ClassRemapper
import java.nio.file.Path
@@ -49,12 +51,30 @@
)
}
- private val typesMap = context.config.typesMap
-
var changesDone = false
private set
- val classRemapper = ClassRemapper(visitor, CustomRemapper(this))
+ val remapper = CustomRemapper(this)
+ val classRemapper = object : ClassRemapper(visitor, remapper) {
+ override fun visitAnnotation(descriptor: String?, visible: Boolean): AnnotationVisitor {
+ val annotationVisitor = super.visitAnnotation(descriptor, visible)
+ return if (descriptor == "Lkotlin/Metadata;")
+ KotlinMetadataVisitor(annotationVisitor) else annotationVisitor
+ }
+ }
+
+ inner class KotlinMetadataVisitor(
+ visitor: AnnotationVisitor
+ ) : AnnotationVisitor(Opcodes.ASM8, visitor) {
+ init {
+ remapper.onKotlinAnnotationVisitStart()
+ }
+
+ override fun visitEnd() {
+ remapper.onKotlinAnnotationVisitEnd()
+ super.visitEnd()
+ }
+ }
override fun rewriteType(type: JavaType): JavaType {
val result = context.typeRewriter.rewriteType(type)
diff --git a/jetifier/jetifier/processor/src/main/kotlin/com/android/tools/build/jetifier/processor/transform/bytecode/asm/CustomRemapper.kt b/jetifier/jetifier/processor/src/main/kotlin/com/android/tools/build/jetifier/processor/transform/bytecode/asm/CustomRemapper.kt
index 7e34af8..3d0ed43 100644
--- a/jetifier/jetifier/processor/src/main/kotlin/com/android/tools/build/jetifier/processor/transform/bytecode/asm/CustomRemapper.kt
+++ b/jetifier/jetifier/processor/src/main/kotlin/com/android/tools/build/jetifier/processor/transform/bytecode/asm/CustomRemapper.kt
@@ -24,6 +24,17 @@
* Extends [Remapper] to allow further customizations.
*/
class CustomRemapper(private val remapper: CoreRemapper) : Remapper() {
+ private var inKotlinMetadata = false
+
+ fun onKotlinAnnotationVisitStart() {
+ require(!inKotlinMetadata)
+ inKotlinMetadata = true
+ }
+
+ fun onKotlinAnnotationVisitEnd() {
+ require(inKotlinMetadata)
+ inKotlinMetadata = false
+ }
override fun map(typeName: String): String {
return remapper.rewriteType(JavaType(typeName)).fullName
@@ -72,6 +83,10 @@
return "L" + mapPoolReferenceType(typeDeclaration) + ";"
}
+ if (inKotlinMetadata) {
+ return rewriteIfMethodSignature(stringVal, ::mapPoolReferenceType)
+ ?: remapper.rewriteString(stringVal)
+ }
return remapper.rewriteString(stringVal)
}
}
diff --git a/jetifier/jetifier/processor/src/main/kotlin/com/android/tools/build/jetifier/processor/transform/bytecode/asm/KotlinMetadataUtil.kt b/jetifier/jetifier/processor/src/main/kotlin/com/android/tools/build/jetifier/processor/transform/bytecode/asm/KotlinMetadataUtil.kt
new file mode 100644
index 0000000..5e4ef1f
--- /dev/null
+++ b/jetifier/jetifier/processor/src/main/kotlin/com/android/tools/build/jetifier/processor/transform/bytecode/asm/KotlinMetadataUtil.kt
@@ -0,0 +1,68 @@
+/*
+ * Copyright 2021 The Android Open Source Project
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package com.android.tools.build.jetifier.processor.transform.bytecode.asm
+
+/**
+ * If the given string [signature] is in format `(ILFoo;LBar;)LResult;` it maps
+ * referenced types via [mapDeclaration]. If the given string doesn't follow this pattern,
+ * `null` is returned.
+ *
+ * Such strings occur in kotlin's [Metadata] annotation for property getters and setters and
+ * data classes.
+ */
+internal fun rewriteIfMethodSignature(
+ signature: String,
+ mapDeclaration: (String) -> String
+): String? {
+ val mapType = { declaration: String ->
+ val type = if (isArrayDeclaration(declaration)) declaration.trim('[') else declaration
+ val mapped = if (isTypeDeclaration(type)) {
+ "L${mapDeclaration(type.substring(1, type.length - 1))};"
+ } else {
+ type
+ }
+ "${"[".repeat(declaration.length - type.length)}$mapped"
+ }
+ // trying to match strings in the format `(ILFoo;LBar;)LResult;`
+ if (!signature.startsWith('(')) return null
+ val index = signature.indexOf(')')
+ if (index == -1) return null
+ val params = splitParameters(signature.substring(1, index)).joinToString("") {
+ mapType(it)
+ }
+ val returnType = signature.substring(index + 1)
+ return "($params)${mapType(returnType)}"
+}
+
+private fun splitParameters(parameters: String): List<String> {
+ val result = mutableListOf<String>()
+ val currentParam = StringBuilder(parameters.length)
+ var inClassName = false
+ for (c in parameters) {
+ currentParam.append(c)
+ inClassName = if (inClassName) c != ';' else c == 'L'
+ // add a parameter if we're no longer in class and not in array start
+ if (!inClassName && c != '[') {
+ result.add(currentParam.toString())
+ currentParam.clear()
+ }
+ }
+ return result
+}
+
+private fun isTypeDeclaration(string: String) = string.startsWith("L") && string.endsWith(";")
+private fun isArrayDeclaration(string: String) = string.startsWith("[")
\ No newline at end of file
diff --git a/jetifier/jetifier/processor/src/main/kotlin/com/android/tools/build/jetifier/processor/transform/java/JavaTransformer.kt b/jetifier/jetifier/processor/src/main/kotlin/com/android/tools/build/jetifier/processor/transform/java/JavaTransformer.kt
index 69f19fa..e8a6b6d 100644
--- a/jetifier/jetifier/processor/src/main/kotlin/com/android/tools/build/jetifier/processor/transform/java/JavaTransformer.kt
+++ b/jetifier/jetifier/processor/src/main/kotlin/com/android/tools/build/jetifier/processor/transform/java/JavaTransformer.kt
@@ -1,4 +1,4 @@
-package com.android.tools.build.jetifier.processor.com.android.tools.build.jetifier.processor.transform.java
+package com.android.tools.build.jetifier.processor.transform.java
import com.android.tools.build.jetifier.processor.archive.ArchiveFile
import com.android.tools.build.jetifier.processor.transform.TransformationContext
diff --git a/jetifier/jetifier/processor/src/main/kotlin/com/android/tools/build/jetifier/processor/transform/metainf/KotlinModuleTransformer.kt b/jetifier/jetifier/processor/src/main/kotlin/com/android/tools/build/jetifier/processor/transform/metainf/KotlinModuleTransformer.kt
new file mode 100644
index 0000000..5632348
--- /dev/null
+++ b/jetifier/jetifier/processor/src/main/kotlin/com/android/tools/build/jetifier/processor/transform/metainf/KotlinModuleTransformer.kt
@@ -0,0 +1,75 @@
+/*
+ * Copyright 2021 The Android Open Source Project
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package com.android.tools.build.jetifier.processor.transform.metainf
+
+import com.android.tools.build.jetifier.core.type.JavaType
+import com.android.tools.build.jetifier.core.type.PackageName
+import com.android.tools.build.jetifier.processor.archive.ArchiveFile
+import com.android.tools.build.jetifier.processor.transform.TransformationContext
+import com.android.tools.build.jetifier.processor.transform.Transformer
+import kotlinx.metadata.jvm.KmPackageParts
+import kotlinx.metadata.jvm.KotlinModuleMetadata
+
+class KotlinModuleTransformer internal constructor(
+ private val context: TransformationContext
+) : Transformer {
+ override fun canTransform(file: ArchiveFile): Boolean {
+ return file.relativePath.toString().startsWith(META_INF_DIR) &&
+ file.fileName.endsWith(KOTLIN_MODULE_SUFFIX) &&
+ !file.isSingleFile
+ }
+
+ override fun runTransform(file: ArchiveFile) {
+ val module = KotlinModuleMetadata.read(file.data)?.toKmModule()
+ ?: return context.reportUnreadableKotlinModule(TAG, file.relativePath)
+ val newPackageParts = module.packageParts.map { (packageName, packageParts) ->
+ val pckg = PackageName.fromDotVersion(packageName)
+ val result = context.config.packageMap.getPackageFor(pckg)
+ val newPackageName = result?.toDotNotation()
+ if (newPackageName == null && context.config.isEligibleForRewrite(pckg)) {
+ context.reportNoPackageMappingFoundFailure(TAG, packageName, file.relativePath)
+ }
+
+ val newSingleFacades = packageParts.fileFacades.map(this::mapType).toMutableList()
+ val newMultiFacades = packageParts.multiFileClassParts.map { (key, singleFile) ->
+ mapType(key) to mapType(singleFile)
+ }.toMap().toMutableMap()
+
+ val newPackageParts = KmPackageParts(
+ newSingleFacades,
+ newMultiFacades,
+ )
+ (newPackageName ?: packageName) to newPackageParts
+ }.toMap()
+ module.packageParts.clear()
+ module.packageParts.putAll(newPackageParts)
+ file.setNewData(KotlinModuleMetadata.Writer().apply(module::accept).write().bytes)
+ }
+
+ private fun mapType(packageName: String): String {
+ val javaType = JavaType(packageName)
+ val newType = context.typeRewriter.rewriteType(javaType)
+ if (newType == null) {
+ context.reportNoMappingFoundFailure(TAG, javaType)
+ }
+ return newType?.fullName ?: packageName
+ }
+}
+
+private const val META_INF_DIR = "META-INF"
+private const val KOTLIN_MODULE_SUFFIX = ".kotlin_module"
+private const val TAG = "KotlinModuleTransformer"
\ No newline at end of file
diff --git a/jetifier/jetifier/processor/src/test/kotlin/androidx/fake/lib/TestDataClass.kt b/jetifier/jetifier/processor/src/test/kotlin/androidx/fake/lib/TestDataClass.kt
new file mode 100644
index 0000000..6e8dbde
--- /dev/null
+++ b/jetifier/jetifier/processor/src/test/kotlin/androidx/fake/lib/TestDataClass.kt
@@ -0,0 +1,21 @@
+/*
+ * Copyright 2021 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.fake.lib
+
+// used in KotlinByteCodeTransformerTest as a resource
+@Suppress("unused")
+data class TestDataClass(val property: String, var children: TestDataClass? = null)
\ No newline at end of file
diff --git a/jetifier/jetifier/processor/src/test/kotlin/androidx/fake/lib/TestProperty.kt b/jetifier/jetifier/processor/src/test/kotlin/androidx/fake/lib/TestProperty.kt
new file mode 100644
index 0000000..3a86d06
--- /dev/null
+++ b/jetifier/jetifier/processor/src/test/kotlin/androidx/fake/lib/TestProperty.kt
@@ -0,0 +1,7 @@
+package androidx.fake.lib
+
+// used in KotlinByteCodeTransformerTest as a resource
+@Suppress("unused")
+class TestProperty {
+ var property: TestProperty? = null
+}
\ No newline at end of file
diff --git a/jetifier/jetifier/processor/src/test/kotlin/com/android/tools/build/jetifier/processor/transform/KotlinModuleRewriteTest.kt b/jetifier/jetifier/processor/src/test/kotlin/com/android/tools/build/jetifier/processor/transform/KotlinModuleRewriteTest.kt
new file mode 100644
index 0000000..a0eb8a5
--- /dev/null
+++ b/jetifier/jetifier/processor/src/test/kotlin/com/android/tools/build/jetifier/processor/transform/KotlinModuleRewriteTest.kt
@@ -0,0 +1,118 @@
+/*
+ * Copyright 2021 The Android Open Source Project
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package com.android.tools.build.jetifier.processor.transform
+
+import com.android.tools.build.jetifier.processor.FileMapping
+import com.android.tools.build.jetifier.processor.Processor
+import com.google.common.truth.Truth.assertThat
+import com.tschuchort.compiletesting.KotlinCompilation
+import com.tschuchort.compiletesting.SourceFile
+import com.tschuchort.compiletesting.SourceFile.Companion.kotlin
+import org.intellij.lang.annotations.Language
+import org.junit.Test
+import java.io.File
+import java.nio.file.Files
+
+/**
+ * Test that verifies that *.kotlin_module file is correctly rewritten.
+ */
+class KotlinModuleRewriteTest {
+ @Test
+ fun topLevel() {
+ val jars = originalJar(
+ kotlin(
+ "toplevel.kt",
+ """
+ package androidx.fake.lib;
+
+ fun topLevel(): Int = 10
+ """
+ )
+ )
+ testKotlinCompilation(
+ jars,
+ """
+ import android.old.fake.topLevel
+
+ fun hello() {
+ println(topLevel())
+ }
+ """
+ )
+ }
+
+ @Test
+ fun multifile() {
+ val originalJar = originalJar(
+ kotlin(
+ "mutlifile1.kt",
+ """
+ @file:JvmName("Single")
+ @file:JvmMultifileClass
+
+ package androidx.fake.lib
+
+ fun stringMethod(): String = "one"
+ """
+ ),
+ kotlin(
+ "mutlifile2.kt",
+ """
+ @file:JvmName("Single")
+ @file:JvmMultifileClass
+
+ package androidx.fake.lib
+
+ fun intMethod(): Int = 5
+ """
+ )
+ )
+ testKotlinCompilation(
+ originalJar,
+ """
+ import android.old.fake.stringMethod
+ import android.old.fake.intMethod
+
+ fun hello() {
+ println(stringMethod())
+ println(intMethod())
+ }
+ """
+ )
+ }
+}
+
+private fun testKotlinCompilation(originalJar: File, @Language("kotlin") content: String) {
+ val processor = Processor.createProcessor4(KotlinTestConfig)
+ val output = Files.createTempFile("out", ".jar").toFile()
+ processor.transform2(setOf(FileMapping(originalJar, output)))
+
+ val kotlinCompilation = KotlinCompilation()
+ kotlinCompilation.sources = listOf(kotlin("test.kt", content))
+ kotlinCompilation.classpaths = listOf(output)
+ assertThat(kotlinCompilation.compile().exitCode).isEqualTo(KotlinCompilation.ExitCode.OK)
+}
+
+fun originalJar(vararg sources: SourceFile): File {
+ val originalJar = Files.createTempFile("original", ".jar").toFile()
+ val kotlinCompilation = KotlinCompilation()
+ kotlinCompilation.kotlincArguments = listOf("-d", originalJar.absolutePath)
+ kotlinCompilation.sources = sources.toList()
+ kotlinCompilation.compile()
+ assertThat(kotlinCompilation.compile().exitCode).isEqualTo(KotlinCompilation.ExitCode.OK)
+ return originalJar
+}
\ No newline at end of file
diff --git a/jetifier/jetifier/processor/src/test/kotlin/com/android/tools/build/jetifier/processor/transform/KotlinTestConfig.kt b/jetifier/jetifier/processor/src/test/kotlin/com/android/tools/build/jetifier/processor/transform/KotlinTestConfig.kt
new file mode 100644
index 0000000..9d31e3d
--- /dev/null
+++ b/jetifier/jetifier/processor/src/test/kotlin/com/android/tools/build/jetifier/processor/transform/KotlinTestConfig.kt
@@ -0,0 +1,34 @@
+/*
+ * Copyright 2021 The Android Open Source Project
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package com.android.tools.build.jetifier.processor.transform
+
+import com.android.tools.build.jetifier.core.PackageMap
+import com.android.tools.build.jetifier.core.config.Config
+import com.android.tools.build.jetifier.core.rule.RewriteRule
+import com.android.tools.build.jetifier.core.rule.RewriteRulesMap
+
+val KotlinTestConfig = Config.fromOptional(
+ restrictToPackagePrefixes = setOf("androidx/fake"),
+ reversedRestrictToPackagesPrefixes = setOf("android/old"),
+ rulesMap = RewriteRulesMap(
+ RewriteRule("androidx/fake/lib/(.*)", "android/old/fake/{0}")
+ ),
+
+ packageMap = PackageMap(
+ listOf(PackageMap.PackageRule("androidx/fake/lib", "android/old/fake"))
+ )
+)
\ No newline at end of file
diff --git a/jetifier/jetifier/processor/src/test/kotlin/com/android/tools/build/jetifier/processor/transform/bytecode/KotlinByteCodeTransformerTest.kt b/jetifier/jetifier/processor/src/test/kotlin/com/android/tools/build/jetifier/processor/transform/bytecode/KotlinByteCodeTransformerTest.kt
new file mode 100644
index 0000000..2a76b4a
--- /dev/null
+++ b/jetifier/jetifier/processor/src/test/kotlin/com/android/tools/build/jetifier/processor/transform/bytecode/KotlinByteCodeTransformerTest.kt
@@ -0,0 +1,70 @@
+/*
+ * Copyright 2021 The Android Open Source Project
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package com.android.tools.build.jetifier.processor.transform.bytecode
+
+import com.android.tools.build.jetifier.processor.archive.ArchiveFile
+import com.android.tools.build.jetifier.processor.transform.KotlinTestConfig
+import com.android.tools.build.jetifier.processor.transform.TransformationContext
+import com.google.common.truth.Truth.assertThat
+import org.junit.Test
+import java.io.File
+import java.net.URLClassLoader
+import java.nio.file.Paths
+import kotlin.reflect.KClass
+import kotlin.reflect.full.memberProperties
+import kotlin.reflect.full.primaryConstructor
+
+class KotlinByteCodeTransformerTest {
+ @Test
+ fun propertyTest() {
+ val testClass = transformAndLoadClass("TestProperty")
+ val testInstance = testClass.primaryConstructor!!.call()
+
+ assertThat(testClass.memberProperties).hasSize(1)
+ val property = testClass.memberProperties.first()
+ // this call will fail if metadata for this property is incorrect
+ property.call(testInstance)
+ }
+
+ @Test
+ fun dataClassTest() {
+ val testClass = transformAndLoadClass("TestDataClass")
+ // this call will fail if metadata for this data class is incorrect
+ testClass.primaryConstructor!!.call("a", null)
+ }
+}
+
+private fun transformAndLoadClass(className: String): KClass<*> {
+ val inputClassPath = "/androidx/fake/lib/$className.class"
+ val inputFile = File(KotlinByteCodeTransformerTest::class.java.getResource(inputClassPath).file)
+ val archiveFile = ArchiveFile(
+ Paths.get("androidx/fake/lib", "$className.class"),
+ inputFile.readBytes()
+ )
+
+ val context = TransformationContext(config = KotlinTestConfig)
+ val transformer = ByteCodeTransformer(context)
+ transformer.runTransform(archiveFile)
+ val bytes = archiveFile.data
+
+ val classLoader = object : URLClassLoader(emptyArray()) {
+ override fun findClass(name: String): Class<*> =
+ if (name == "android.old.fake.$className") defineClass(name, bytes, 0, bytes.size)
+ else super.findClass(name)
+ }
+ return classLoader.loadClass("android.old.fake.$className").kotlin
+}
diff --git a/jetifier/jetifier/processor/src/test/kotlin/com/android/tools/build/jetifier/processor/transform/bytecode/SignatureMappingTest.kt b/jetifier/jetifier/processor/src/test/kotlin/com/android/tools/build/jetifier/processor/transform/bytecode/SignatureMappingTest.kt
new file mode 100644
index 0000000..6722eeb
--- /dev/null
+++ b/jetifier/jetifier/processor/src/test/kotlin/com/android/tools/build/jetifier/processor/transform/bytecode/SignatureMappingTest.kt
@@ -0,0 +1,51 @@
+/*
+ * Copyright 2021 The Android Open Source Project
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package com.android.tools.build.jetifier.processor.transform.bytecode
+
+import com.android.tools.build.jetifier.processor.transform.bytecode.asm.rewriteIfMethodSignature
+import com.google.common.truth.Truth.assertThat
+import org.junit.Test
+
+class SignatureMappingTest {
+ @Test
+ fun remapSignatureString_inKotlinMetadata() {
+ val typesMap = mapOf(
+ "android/old/Foo" to "androidx/fancy/Foo",
+ "android/old/Bar" to "androidx/fancy/Bar",
+ )
+
+ fun assertRewrite(oldSignature: String, newSignature: String) =
+ assertThat(rewriteIfMethodSignature(oldSignature) { type -> typesMap[type] ?: type })
+ .isEqualTo(newSignature)
+
+ assertRewrite("()V", "()V")
+ assertRewrite("(Landroid/old/Foo;)V", "(Landroidx/fancy/Foo;)V")
+ assertRewrite("()Landroid/old/Foo;", "()Landroidx/fancy/Foo;")
+
+ assertRewrite("(Landroid/unmapped/Foo;)V", "(Landroid/unmapped/Foo;)V")
+ assertRewrite(
+ "(Landroid/old/Bar;JLandroid/unmapped/Foo;)V",
+ "(Landroidx/fancy/Bar;JLandroid/unmapped/Foo;)V"
+ )
+ assertRewrite(
+ "(JLandroid/unmapped/Foo;I[[I)Landroid/old/Bar;",
+ "(JLandroid/unmapped/Foo;I[[I)Landroidx/fancy/Bar;"
+ )
+ assertRewrite("([Landroid/old/Foo;)V", "([Landroidx/fancy/Foo;)V")
+ assertRewrite("()[[Landroid/old/Foo;", "()[[Landroidx/fancy/Foo;")
+ }
+}
\ No newline at end of file
diff --git a/lint-checks/integration-tests/expected-lint-results.xml b/lint-checks/integration-tests/expected-lint-results.xml
index 6328019..ce6e261 100644
--- a/lint-checks/integration-tests/expected-lint-results.xml
+++ b/lint-checks/integration-tests/expected-lint-results.xml
@@ -148,7 +148,7 @@
<issue
id="ClassVerificationFailure"
severity="Error"
- message="This call references a method added in API level 19; however, the containing class androidx.core.widget.ListViewCompat is reachable from earlier API levels and will fail run-time class verification."
+ message="This call references a method added in API level 19; however, the containing class androidx.sample.core.widget.ListViewCompat is reachable from earlier API levels and will fail run-time class verification."
category="Correctness"
priority="5"
summary="Even in cases where references to new APIs are gated on SDK_INT checks, run-time class verification will still fail on references to APIs that may not be available at run time, including platform APIs introduced after a library's minSdkVersion."
@@ -164,7 +164,7 @@
<issue
id="ClassVerificationFailure"
severity="Error"
- message="This call references a method added in API level 19; however, the containing class androidx.core.widget.ListViewCompat is reachable from earlier API levels and will fail run-time class verification."
+ message="This call references a method added in API level 19; however, the containing class androidx.sample.core.widget.ListViewCompat is reachable from earlier API levels and will fail run-time class verification."
category="Correctness"
priority="5"
summary="Even in cases where references to new APIs are gated on SDK_INT checks, run-time class verification will still fail on references to APIs that may not be available at run time, including platform APIs introduced after a library's minSdkVersion."
diff --git a/lint-checks/integration-tests/src/main/AndroidManifest.xml b/lint-checks/integration-tests/src/main/AndroidManifest.xml
index 1a39913..98ea13f 100644
--- a/lint-checks/integration-tests/src/main/AndroidManifest.xml
+++ b/lint-checks/integration-tests/src/main/AndroidManifest.xml
@@ -13,4 +13,15 @@
~ See the License for the specific language governing permissions and
~ limitations under the License.
-->
-<manifest package="androidx.lint.integration.tests" />
+<manifest package="androidx.lint.integration.tests"
+ xmlns:android="http://schemas.android.com/apk/res/android">
+ <application>
+ <!-- Application-level metadata is not allowed. -->
+ <meta-data android:name="name" android:value="value" />
+
+ <service android:name="androidx.core.app.JobIntentService">
+ <!-- Service-level metadata is allowed. -->
+ <meta-data android:name="name" android:value="value" />
+ </service>
+ </application>
+</manifest>
diff --git a/lint-checks/integration-tests/src/main/java/androidx/ConcurrentHashMapUsageJava.java b/lint-checks/integration-tests/src/main/java/androidx/ConcurrentHashMapUsageJava.java
new file mode 100644
index 0000000..db30af2
--- /dev/null
+++ b/lint-checks/integration-tests/src/main/java/androidx/ConcurrentHashMapUsageJava.java
@@ -0,0 +1,33 @@
+/*
+ * Copyright 2021 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;
+
+import androidx.annotation.NonNull;
+
+import java.util.Map;
+import java.util.concurrent.ConcurrentHashMap;
+
+@SuppressWarnings("unused")
+public class ConcurrentHashMapUsageJava {
+
+ private final ConcurrentHashMap<?, ?> mMap = new ConcurrentHashMap<>();
+
+ @NonNull
+ public <V, K> Map<V, K> createMap() {
+ return new ConcurrentHashMap<>();
+ }
+}
diff --git a/lint-checks/integration-tests/src/main/java/androidx/KeepAnnotationUsageJava.java b/lint-checks/integration-tests/src/main/java/androidx/KeepAnnotationUsageJava.java
new file mode 100644
index 0000000..964459f
--- /dev/null
+++ b/lint-checks/integration-tests/src/main/java/androidx/KeepAnnotationUsageJava.java
@@ -0,0 +1,23 @@
+/*
+ * Copyright 2021 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;
+
+import androidx.annotation.Keep;
+
+@Keep
+public class KeepAnnotationUsageJava {
+}
diff --git a/lint-checks/integration-tests/src/main/java/androidx/ParcelableUsageJava.java b/lint-checks/integration-tests/src/main/java/androidx/ParcelableUsageJava.java
new file mode 100644
index 0000000..04aafe1
--- /dev/null
+++ b/lint-checks/integration-tests/src/main/java/androidx/ParcelableUsageJava.java
@@ -0,0 +1,50 @@
+/*
+ * Copyright 2021 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;
+
+import android.os.Parcel;
+import android.os.Parcelable;
+
+import androidx.annotation.NonNull;
+
+@SuppressWarnings("unused")
+public class ParcelableUsageJava implements Parcelable {
+
+ protected ParcelableUsageJava(@NonNull Parcel in) {
+ }
+
+ @Override
+ public int describeContents() {
+ return 0;
+ }
+
+ @Override
+ public void writeToParcel(@NonNull Parcel dest, int flags) {
+ }
+
+ public static final Creator<ParcelableUsageJava> CREATOR = new Creator<ParcelableUsageJava>() {
+ @Override
+ public ParcelableUsageJava createFromParcel(Parcel in) {
+ return new ParcelableUsageJava(in);
+ }
+
+ @Override
+ public ParcelableUsageJava[] newArray(int size) {
+ return new ParcelableUsageJava[size];
+ }
+ };
+}
diff --git a/lint-checks/integration-tests/src/main/java/androidx/SynchronizedMethodJava.java b/lint-checks/integration-tests/src/main/java/androidx/SynchronizedMethodJava.java
new file mode 100644
index 0000000..73e6365
--- /dev/null
+++ b/lint-checks/integration-tests/src/main/java/androidx/SynchronizedMethodJava.java
@@ -0,0 +1,24 @@
+/*
+ * Copyright 2021 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;
+
+@SuppressWarnings("unused")
+public class SynchronizedMethodJava {
+
+ public synchronized void someMethod() {
+ }
+}
diff --git a/lint-checks/integration-tests/src/main/java/androidx/TargetApiUsageJava.java b/lint-checks/integration-tests/src/main/java/androidx/TargetApiUsageJava.java
new file mode 100644
index 0000000..ff0d71d
--- /dev/null
+++ b/lint-checks/integration-tests/src/main/java/androidx/TargetApiUsageJava.java
@@ -0,0 +1,28 @@
+/*
+ * Copyright 2021 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;
+
+import android.annotation.TargetApi;
+
+@SuppressWarnings("unused")
+@TargetApi(29)
+public class TargetApiUsageJava {
+
+ @TargetApi(30)
+ public void someMethod() {
+ }
+}
diff --git a/lint-checks/integration-tests/src/main/java/androidx/sample/core/app/ActivityRecreator.java b/lint-checks/integration-tests/src/main/java/androidx/sample/core/app/ActivityRecreator.java
new file mode 100644
index 0000000..8790171
--- /dev/null
+++ b/lint-checks/integration-tests/src/main/java/androidx/sample/core/app/ActivityRecreator.java
@@ -0,0 +1,370 @@
+/*
+ * Copyright 2021 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.sample.core.app;
+
+import static android.os.Build.VERSION.SDK_INT;
+
+import static androidx.annotation.RestrictTo.Scope.LIBRARY;
+
+import android.app.Activity;
+import android.app.Application;
+import android.app.Application.ActivityLifecycleCallbacks;
+import android.content.res.Configuration;
+import android.os.Bundle;
+import android.os.Handler;
+import android.os.IBinder;
+import android.os.Looper;
+import android.util.Log;
+
+import androidx.annotation.NonNull;
+import androidx.annotation.RestrictTo;
+
+import java.lang.reflect.Field;
+import java.lang.reflect.Method;
+import java.util.List;
+
+/**
+ * The goal here is to get common (and correct) behavior around Activity recreation for all API
+ * versions up until P, where the behavior was specified to be useful and implemented to match the
+ * specification. On API 26 and 27, recreate() doesn't actually recreate the Activity if it's
+ * not in the foreground; it will be recreated when the user next interacts with it. This has a few
+ * undesirable consequences:
+ *
+ * <p>1. It's impossible to recreate multiple activities at once, which means that activities in the
+ * background will observe the new configuration before they're recreated. If we keep them on the
+ * old configuration, we have two conflicting configurations active in the app, which leads to
+ * logging skew.
+ *
+ * <p>2. Recreation occurs in the critical path of user interaction - re-inflating a bunch of views
+ * isn't free, and we'd rather do it when we're in the background than when the user is staring at
+ * the screen waiting to see us.
+ *
+ * <p>On API < 26, recreate() was implemented with a single call to a private method on
+ * ActivityThread. That method still exists in 26 and 27, so we can use reflection to call it and
+ * get the exact same behavior as < 26. However, that behavior has problems itself. When
+ * an Activity in the background is recreated, it goes through: destroy -> create -> start ->
+ * resume -> pause and doesn't stop. This is a violation of the contract for onStart/onStop,
+ * but that might be palatable if it didn't also have the effect of preventing new configurations
+ * from being applied - since the Activity doesn't go through onStop, our tracking of whether
+ * our app is visible thinks we're always visible, and thus can't do another recreation later.
+ *
+ * <p>The fix for this is to add the missing onStop() call, by using reflection to call into
+ * ActivityThread.
+ *
+ * @hide
+ */
+@RestrictTo(LIBRARY)
+@SuppressWarnings({"PrivateApi", "JavaReflectionMemberAccess", "unused"})
+final class ActivityRecreator {
+ private ActivityRecreator() {}
+
+ private static final String LOG_TAG = "ActivityRecreator";
+
+ // Activity.mMainThread
+ protected static final Field mainThreadField;
+ // Activity.mToken. This object is an identifier that is the same between multiple instances of
+ //the same underlying Activity.
+ protected static final Field tokenField;
+ // On API 25, a third param was added to performStopActivity
+ protected static final Method performStopActivity3ParamsMethod;
+ // Before API 25, performStopActivity had two params
+ protected static final Method performStopActivity2ParamsMethod;
+ // ActivityThread.requestRelaunchActivity
+ protected static final Method requestRelaunchActivityMethod;
+
+ private static final Handler mainHandler = new Handler(Looper.getMainLooper());
+
+ static {
+ Class<?> activityThreadClass = getActivityThreadClass();
+ mainThreadField = getMainThreadField();
+ tokenField = getTokenField();
+ performStopActivity3ParamsMethod = getPerformStopActivity3Params(activityThreadClass);
+ performStopActivity2ParamsMethod = getPerformStopActivity2Params(activityThreadClass);
+ requestRelaunchActivityMethod = getRequestRelaunchActivityMethod(activityThreadClass);
+ }
+
+ /**
+ * Equivalent to {@link Activity#recreate}, but working around a number of platform bugs.
+ *
+ * @return true if a recreate() task was successfully scheduled.
+ */
+ static boolean recreate(@NonNull final Activity activity) {
+ // On Android O and later we can rely on the platform recreate()
+ if (SDK_INT >= 28) {
+ activity.recreate();
+ return true;
+ }
+
+ // API 26 needs this workaround but it's not possible because our reflective lookup failed.
+ if (needsRelaunchCall() && requestRelaunchActivityMethod == null) {
+ return false;
+ }
+ // All versions of android so far need this workaround, but it's not possible because our
+ // reflective lookup failed.
+ if (performStopActivity2ParamsMethod == null && performStopActivity3ParamsMethod == null) {
+ return false;
+ }
+ try {
+ final Object token = tokenField.get(activity);
+ if (token == null) {
+ return false;
+ }
+ Object activityThread = mainThreadField.get(activity);
+ if (activityThread == null) {
+ return false;
+ }
+
+ final Application application = activity.getApplication();
+ final LifecycleCheckCallbacks callbacks = new LifecycleCheckCallbacks(activity);
+ application.registerActivityLifecycleCallbacks(callbacks);
+
+ /*
+ * Runnables scheduled before/after recreate() will run before and after the Runnables
+ * scheduled by recreate(). This allows us to bound the time where mActivity lifecycle
+ * events that could be caused by recreate() run - that way we can detect onPause()
+ * from the new Activity instance, and schedule onStop to run immediately after it.
+ */
+ mainHandler.post(() -> callbacks.currentlyRecreatingToken = token);
+
+ try {
+ if (needsRelaunchCall()) {
+ requestRelaunchActivityMethod.invoke(activityThread,
+ token, null, null, 0, false, null, null, false, false);
+ } else {
+ activity.recreate();
+ }
+ return true;
+ } finally {
+ mainHandler.post(() -> {
+ // Since we're calling hidden API, it's entirely possible for it to
+ // simply do nothing;
+ // if that's the case, make sure to unregister so we don't leak memory
+ // waiting for an event that will never happen.
+ application.unregisterActivityLifecycleCallbacks(callbacks);
+ });
+ }
+ } catch (Throwable t) {
+ return false;
+ }
+ }
+
+ private static final class LifecycleCheckCallbacks implements ActivityLifecycleCallbacks {
+ Object currentlyRecreatingToken;
+
+ private Activity mActivity;
+ private final int mRecreatingHashCode;
+
+ // Whether the activity on which recreate() was called went through onStart after
+ // recreate() was called (and thus the callback was registered).
+ private boolean mStarted = false;
+
+ // Whether the activity on which recreate() was called went through onDestroy after
+ // recreate() was called. This means we successfully initiated a recreate().
+ private boolean mDestroyed = false;
+
+ // Whether we'll force the activity on which recreate() was called to go through an
+ // onStop()
+ private boolean mStopQueued = false;
+
+ LifecycleCheckCallbacks(@NonNull Activity aboutToRecreate) {
+ mActivity = aboutToRecreate;
+ mRecreatingHashCode = mActivity.hashCode();
+ }
+
+ @Override
+ public void onActivityCreated(Activity activity, Bundle savedInstanceState) {
+ }
+
+ @Override
+ public void onActivityStarted(Activity activity) {
+ // If we see a start call on the original mActivity instance, then the mActivity
+ // starting event executed between our call to recreate() and the actual
+ // recreation of the mActivity. In that case, a stop() call should not be scheduled.
+ if (mActivity == activity) {
+ mStarted = true;
+ }
+ }
+
+ @Override
+ public void onActivityResumed(Activity activity) {
+ }
+
+ @Override
+ public void onActivityPaused(Activity activity) {
+ if (mDestroyed // Original mActivity must be gone
+ && !mStopQueued // Don't schedule stop twice for one recreate() call
+ && !mStarted
+ // Don't schedule stop if the original instance starting raced with recreate()
+ && queueOnStopIfNecessary(
+ currentlyRecreatingToken, mRecreatingHashCode, activity)) {
+ mStopQueued = true;
+ // Don't retain this object longer than necessary
+ currentlyRecreatingToken = null;
+ }
+ }
+
+ @Override
+ public void onActivitySaveInstanceState(Activity activity, Bundle outState) {
+ }
+
+ @Override
+ public void onActivityStopped(Activity activity) {
+ // Not possible to get a start/stop pair in the same UI thread loop
+ }
+
+ @Override
+ public void onActivityDestroyed(Activity activity) {
+ if (mActivity == activity) {
+ // Once the original mActivity instance is mDestroyed, we don't need to compare to
+ // it any
+ // longer, and we don't want to retain it any longer than necessary.
+ mActivity = null;
+ mDestroyed = true;
+ }
+ }
+ }
+
+ /**
+ * Returns true if a stop call was scheduled successfully
+ */
+ protected static boolean queueOnStopIfNecessary(
+ Object currentlyRecreatingToken, int currentlyRecreatingHashCode, Activity activity) {
+ try {
+ final Object token = tokenField.get(activity);
+ if (token != currentlyRecreatingToken
+ || activity.hashCode() != currentlyRecreatingHashCode) {
+ // We're looking at a different activity, don't try to make it stop! Note that
+ // tokens are reused on SDK 21-23 but Activity objects (and thus hashCode, in
+ // all likelihood) are not, so we need to check both.
+ return false;
+ }
+ final Object activityThread = mainThreadField.get(activity);
+ // These operations are posted at the front of the queue, so that operations
+ // scheduled from onCreate, onStart etc run after the onStop call - this should
+ // cause any redundant loads to be immediately cancelled.
+ mainHandler.postAtFrontOfQueue(() -> {
+ try {
+ if (performStopActivity3ParamsMethod != null) {
+ performStopActivity3ParamsMethod.invoke(activityThread,
+ token, false, "AppCompat recreation");
+ } else {
+ performStopActivity2ParamsMethod.invoke(activityThread,
+ token, false);
+ }
+ } catch (RuntimeException e) {
+ // If an Activity throws from onStop, don't swallow it
+ if (e.getClass() == RuntimeException.class
+ && e.getMessage() != null
+ && e.getMessage().startsWith("Unable to stop")) {
+ throw e;
+ }
+ // Otherwise just swallow it - we're calling random private methods,
+ // there's no guarantee on how they'll behave.
+ } catch (Throwable t) {
+ Log.e(LOG_TAG, "Exception while invoking performStopActivity", t);
+ }
+ });
+ return true;
+ } catch (Throwable t) {
+ Log.e(LOG_TAG, "Exception while fetching field values", t);
+ return false;
+ }
+ }
+
+ private static Method getPerformStopActivity3Params(Class<?> activityThreadClass) {
+ if (activityThreadClass == null) {
+ return null;
+ }
+ try {
+ Method performStop = activityThreadClass.getDeclaredMethod("performStopActivity",
+ IBinder.class, boolean.class, String.class);
+ performStop.setAccessible(true);
+ return performStop;
+ } catch (Throwable t) {
+ return null;
+ }
+ }
+
+ private static Method getPerformStopActivity2Params(Class<?> activityThreadClass) {
+ if (activityThreadClass == null) {
+ return null;
+ }
+ try {
+ Method performStop = activityThreadClass.getDeclaredMethod("performStopActivity",
+ IBinder.class, boolean.class);
+ performStop.setAccessible(true);
+ return performStop;
+ } catch (Throwable t) {
+ return null;
+ }
+ }
+
+ private static boolean needsRelaunchCall() {
+ return SDK_INT == 26 || SDK_INT == 27;
+ }
+
+ private static Method getRequestRelaunchActivityMethod(Class<?> activityThreadClass) {
+ if (!needsRelaunchCall() || activityThreadClass == null) {
+ return null;
+ }
+ try {
+ Method relaunch = activityThreadClass.getDeclaredMethod(
+ "requestRelaunchActivity",
+ IBinder.class,
+ List.class,
+ List.class,
+ int.class,
+ boolean.class,
+ Configuration.class,
+ Configuration.class,
+ boolean.class,
+ boolean.class);
+ relaunch.setAccessible(true);
+ return relaunch;
+ } catch (Throwable t) {
+ return null;
+ }
+ }
+
+ private static Field getMainThreadField() {
+ try {
+ Field mainThreadField = Activity.class.getDeclaredField("mMainThread");
+ mainThreadField.setAccessible(true);
+ return mainThreadField;
+ } catch (Throwable t) {
+ return null;
+ }
+ }
+
+ private static Field getTokenField() {
+ try {
+ Field tokenField = Activity.class.getDeclaredField("mToken");
+ tokenField.setAccessible(true);
+ return tokenField;
+ } catch (Throwable t) {
+ return null;
+ }
+ }
+
+ private static Class<?> getActivityThreadClass() {
+ try {
+ return Class.forName("android.app.ActivityThread");
+ } catch (Throwable t) {
+ return null;
+ }
+ }
+}
diff --git a/lint-checks/integration-tests/src/main/java/androidx/sample/core/app/ActivityRecreatorChecked.java b/lint-checks/integration-tests/src/main/java/androidx/sample/core/app/ActivityRecreatorChecked.java
new file mode 100644
index 0000000..0523d2d
--- /dev/null
+++ b/lint-checks/integration-tests/src/main/java/androidx/sample/core/app/ActivityRecreatorChecked.java
@@ -0,0 +1,377 @@
+/*
+ * Copyright 2021 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.sample.core.app;
+
+import static android.os.Build.VERSION.SDK_INT;
+
+import static androidx.annotation.RestrictTo.Scope.LIBRARY;
+
+import android.app.Activity;
+import android.app.Application;
+import android.app.Application.ActivityLifecycleCallbacks;
+import android.content.res.Configuration;
+import android.os.Bundle;
+import android.os.Handler;
+import android.os.IBinder;
+import android.os.Looper;
+import android.util.Log;
+
+import androidx.annotation.ChecksSdkIntAtLeast;
+import androidx.annotation.NonNull;
+import androidx.annotation.RestrictTo;
+
+import java.lang.reflect.Field;
+import java.lang.reflect.Method;
+import java.util.List;
+
+/**
+ * The goal here is to get common (and correct) behavior around Activity recreation for all API
+ * versions up until P, where the behavior was specified to be useful and implemented to match the
+ * specification. On API 26 and 27, recreate() doesn't actually recreate the Activity if it's
+ * not in the foreground; it will be recreated when the user next interacts with it. This has a few
+ * undesirable consequences:
+ *
+ * <p>1. It's impossible to recreate multiple activities at once, which means that activities in the
+ * background will observe the new configuration before they're recreated. If we keep them on the
+ * old configuration, we have two conflicting configurations active in the app, which leads to
+ * logging skew.
+ *
+ * <p>2. Recreation occurs in the critical path of user interaction - re-inflating a bunch of views
+ * isn't free, and we'd rather do it when we're in the background than when the user is staring at
+ * the screen waiting to see us.
+ *
+ * <p>On API < 26, recreate() was implemented with a single call to a private method on
+ * ActivityThread. That method still exists in 26 and 27, so we can use reflection to call it and
+ * get the exact same behavior as < 26. However, that behavior has problems itself. When
+ * an Activity in the background is recreated, it goes through: destroy -> create -> start ->
+ * resume -> pause and doesn't stop. This is a violation of the contract for onStart/onStop,
+ * but that might be palatable if it didn't also have the effect of preventing new configurations
+ * from being applied - since the Activity doesn't go through onStop, our tracking of whether
+ * our app is visible thinks we're always visible, and thus can't do another recreation later.
+ *
+ * <p>The fix for this is to add the missing onStop() call, by using reflection to call into
+ * ActivityThread.
+ *
+ * @hide
+ */
+@RestrictTo(LIBRARY)
+@SuppressWarnings({"PrivateApi", "JavaReflectionMemberAccess", "unused"})
+final class ActivityRecreatorChecked {
+ private ActivityRecreatorChecked() {}
+
+ private static final String LOG_TAG = "ActivityRecreatorChecked";
+
+ // Activity.mMainThread
+ protected static final Field mainThreadField;
+ // Activity.mToken. This object is an identifier that is the same between multiple instances of
+ //the same underlying Activity.
+ protected static final Field tokenField;
+ // On API 25, a third param was added to performStopActivity
+ protected static final Method performStopActivity3ParamsMethod;
+ // Before API 25, performStopActivity had two params
+ protected static final Method performStopActivity2ParamsMethod;
+ // ActivityThread.requestRelaunchActivity
+ protected static final Method requestRelaunchActivityMethod;
+
+ private static final Handler mainHandler = new Handler(Looper.getMainLooper());
+
+ static {
+ Class<?> activityThreadClass = getActivityThreadClass();
+ mainThreadField = getMainThreadField();
+ tokenField = getTokenField();
+ performStopActivity3ParamsMethod = getPerformStopActivity3Params(activityThreadClass);
+ performStopActivity2ParamsMethod = getPerformStopActivity2Params(activityThreadClass);
+ requestRelaunchActivityMethod = getRequestRelaunchActivityMethod(activityThreadClass);
+ }
+
+ /**
+ * Equivalent to {@link Activity#recreate}, but working around a number of platform bugs.
+ *
+ * @return true if a recreate() task was successfully scheduled.
+ */
+ static boolean recreate(@NonNull final Activity activity) {
+ // On Android O and later we can rely on the platform recreate()
+ if (SDK_INT >= 28) {
+ activity.recreate();
+ return true;
+ }
+
+ // API 26 needs this workaround but it's not possible because our reflective lookup failed.
+ if (needsRelaunchCall() && requestRelaunchActivityMethod == null) {
+ return false;
+ }
+ // All versions of android so far need this workaround, but it's not possible because our
+ // reflective lookup failed.
+ if (performStopActivity2ParamsMethod == null && performStopActivity3ParamsMethod == null) {
+ return false;
+ }
+ try {
+ final Object token = tokenField.get(activity);
+ if (token == null) {
+ return false;
+ }
+ Object activityThread = mainThreadField.get(activity);
+ if (activityThread == null) {
+ return false;
+ }
+
+ final Application application = activity.getApplication();
+ final LifecycleCheckCallbacks callbacks = new LifecycleCheckCallbacks(activity);
+ application.registerActivityLifecycleCallbacks(callbacks);
+
+ /*
+ * Runnables scheduled before/after recreate() will run before and after the Runnables
+ * scheduled by recreate(). This allows us to bound the time where mActivity lifecycle
+ * events that could be caused by recreate() run - that way we can detect onPause()
+ * from the new Activity instance, and schedule onStop to run immediately after it.
+ */
+ mainHandler.post(() -> callbacks.currentlyRecreatingToken = token);
+
+ try {
+ if (needsRelaunchCall()) {
+ requestRelaunchActivityMethod.invoke(activityThread,
+ token, null, null, 0, false, null, null, false, false);
+ } else {
+ activity.recreate();
+ }
+ return true;
+ } finally {
+ mainHandler.post(() -> {
+ // Since we're calling hidden API, it's entirely possible for it to
+ // simply do nothing;
+ // if that's the case, make sure to unregister so we don't leak memory
+ // waiting for an event that will never happen.
+ application.unregisterActivityLifecycleCallbacks(callbacks);
+ });
+ }
+ } catch (Throwable t) {
+ return false;
+ }
+ }
+
+ // Only reachable on SDK_INT < 28
+ private static final class LifecycleCheckCallbacks implements ActivityLifecycleCallbacks {
+ Object currentlyRecreatingToken;
+
+ private Activity mActivity;
+ private final int mRecreatingHashCode;
+
+ // Whether the activity on which recreate() was called went through onStart after
+ // recreate() was called (and thus the callback was registered).
+ private boolean mStarted = false;
+
+ // Whether the activity on which recreate() was called went through onDestroy after
+ // recreate() was called. This means we successfully initiated a recreate().
+ private boolean mDestroyed = false;
+
+ // Whether we'll force the activity on which recreate() was called to go through an
+ // onStop()
+ private boolean mStopQueued = false;
+
+ LifecycleCheckCallbacks(@NonNull Activity aboutToRecreate) {
+ mActivity = aboutToRecreate;
+ mRecreatingHashCode = mActivity.hashCode();
+ }
+
+ @Override
+ public void onActivityCreated(Activity activity, Bundle savedInstanceState) {
+ }
+
+ @Override
+ public void onActivityStarted(Activity activity) {
+ // If we see a start call on the original mActivity instance, then the mActivity
+ // starting event executed between our call to recreate() and the actual
+ // recreation of the mActivity. In that case, a stop() call should not be scheduled.
+ if (mActivity == activity) {
+ mStarted = true;
+ }
+ }
+
+ @Override
+ public void onActivityResumed(Activity activity) {
+ }
+
+ @Override
+ public void onActivityPaused(Activity activity) {
+ if (mDestroyed // Original mActivity must be gone
+ && !mStopQueued // Don't schedule stop twice for one recreate() call
+ && !mStarted
+ // Don't schedule stop if the original instance starting raced with recreate()
+ && queueOnStopIfNecessary(
+ currentlyRecreatingToken, mRecreatingHashCode, activity)) {
+ mStopQueued = true;
+ // Don't retain this object longer than necessary
+ currentlyRecreatingToken = null;
+ }
+ }
+
+ @Override
+ public void onActivitySaveInstanceState(Activity activity, Bundle outState) {
+ }
+
+ @Override
+ public void onActivityStopped(Activity activity) {
+ // Not possible to get a start/stop pair in the same UI thread loop
+ }
+
+ @Override
+ public void onActivityDestroyed(Activity activity) {
+ if (mActivity == activity) {
+ // Once the original mActivity instance is mDestroyed, we don't need to compare to
+ // it any
+ // longer, and we don't want to retain it any longer than necessary.
+ mActivity = null;
+ mDestroyed = true;
+ }
+ }
+ }
+
+ /**
+ * Returns true if a stop call was scheduled successfully.
+ *
+ * Only reachable on SDK < 28.
+ */
+ protected static boolean queueOnStopIfNecessary(
+ Object currentlyRecreatingToken, int currentlyRecreatingHashCode, Activity activity) {
+ try {
+ final Object token = tokenField.get(activity);
+ if (token != currentlyRecreatingToken
+ || activity.hashCode() != currentlyRecreatingHashCode) {
+ // We're looking at a different activity, don't try to make it stop! Note that
+ // tokens are reused on SDK 21-23 but Activity objects (and thus hashCode, in
+ // all likelihood) are not, so we need to check both.
+ return false;
+ }
+ final Object activityThread = mainThreadField.get(activity);
+ // These operations are posted at the front of the queue, so that operations
+ // scheduled from onCreate, onStart etc run after the onStop call - this should
+ // cause any redundant loads to be immediately cancelled.
+ mainHandler.postAtFrontOfQueue(() -> {
+ try {
+ if (SDK_INT < 28) {
+ if (performStopActivity3ParamsMethod != null) {
+ performStopActivity3ParamsMethod.invoke(activityThread,
+ token, false, "AppCompat recreation");
+ } else {
+ performStopActivity2ParamsMethod.invoke(activityThread,
+ token, false);
+ }
+ }
+ } catch (RuntimeException e) {
+ // If an Activity throws from onStop, don't swallow it
+ if (e.getClass() == RuntimeException.class
+ && e.getMessage() != null
+ && e.getMessage().startsWith("Unable to stop")) {
+ throw e;
+ }
+ // Otherwise just swallow it - we're calling random private methods,
+ // there's no guarantee on how they'll behave.
+ } catch (Throwable t) {
+ Log.e(LOG_TAG, "Exception while invoking performStopActivity", t);
+ }
+ });
+ return true;
+ } catch (Throwable t) {
+ Log.e(LOG_TAG, "Exception while fetching field values", t);
+ return false;
+ }
+ }
+
+ private static Method getPerformStopActivity3Params(Class<?> activityThreadClass) {
+ if (activityThreadClass == null) {
+ return null;
+ }
+ try {
+ Method performStop = activityThreadClass.getDeclaredMethod("performStopActivity",
+ IBinder.class, boolean.class, String.class);
+ performStop.setAccessible(true);
+ return performStop;
+ } catch (Throwable t) {
+ return null;
+ }
+ }
+
+ private static Method getPerformStopActivity2Params(Class<?> activityThreadClass) {
+ if (activityThreadClass == null) {
+ return null;
+ }
+ try {
+ Method performStop = activityThreadClass.getDeclaredMethod("performStopActivity",
+ IBinder.class, boolean.class);
+ performStop.setAccessible(true);
+ return performStop;
+ } catch (Throwable t) {
+ return null;
+ }
+ }
+
+ @ChecksSdkIntAtLeast(api = 26)
+ private static boolean needsRelaunchCall() {
+ return SDK_INT == 26 || SDK_INT == 27;
+ }
+
+ private static Method getRequestRelaunchActivityMethod(Class<?> activityThreadClass) {
+ if (!needsRelaunchCall() || activityThreadClass == null) {
+ return null;
+ }
+ try {
+ Method relaunch = activityThreadClass.getDeclaredMethod(
+ "requestRelaunchActivity",
+ IBinder.class,
+ List.class,
+ List.class,
+ int.class,
+ boolean.class,
+ Configuration.class,
+ Configuration.class,
+ boolean.class,
+ boolean.class);
+ relaunch.setAccessible(true);
+ return relaunch;
+ } catch (Throwable t) {
+ return null;
+ }
+ }
+
+ private static Field getMainThreadField() {
+ try {
+ Field mainThreadField = Activity.class.getDeclaredField("mMainThread");
+ mainThreadField.setAccessible(true);
+ return mainThreadField;
+ } catch (Throwable t) {
+ return null;
+ }
+ }
+
+ private static Field getTokenField() {
+ try {
+ Field tokenField = Activity.class.getDeclaredField("mToken");
+ tokenField.setAccessible(true);
+ return tokenField;
+ } catch (Throwable t) {
+ return null;
+ }
+ }
+
+ private static Class<?> getActivityThreadClass() {
+ try {
+ return Class.forName("android.app.ActivityThread");
+ } catch (Throwable t) {
+ return null;
+ }
+ }
+}
diff --git a/lint-checks/integration-tests/src/main/java/androidx/core/widget/ListViewCompat.java b/lint-checks/integration-tests/src/main/java/androidx/sample/core/widget/ListViewCompat.java
similarity index 97%
rename from lint-checks/integration-tests/src/main/java/androidx/core/widget/ListViewCompat.java
rename to lint-checks/integration-tests/src/main/java/androidx/sample/core/widget/ListViewCompat.java
index 1d51e41..216ef20 100644
--- a/lint-checks/integration-tests/src/main/java/androidx/core/widget/ListViewCompat.java
+++ b/lint-checks/integration-tests/src/main/java/androidx/sample/core/widget/ListViewCompat.java
@@ -1,5 +1,5 @@
/*
- * Copyright (C) 2016 The Android Open Source Project
+ * Copyright 2021 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.
@@ -14,7 +14,7 @@
* limitations under the License.
*/
-package androidx.core.widget;
+package androidx.sample.core.widget;
import android.os.Build;
import android.view.View;
diff --git a/lint-checks/lint-baseline.xml b/lint-checks/lint-baseline.xml
deleted file mode 100644
index 42a176b..0000000
--- a/lint-checks/lint-baseline.xml
+++ /dev/null
@@ -1,4 +0,0 @@
-<?xml version="1.0" encoding="UTF-8"?>
-<issues format="6" by="lint 7.0.0-alpha15" type="baseline" client="cli" name="Lint" variant="all" version="7.0.0-alpha15">
-
-</issues>
diff --git a/lint-checks/src/main/java/androidx/build/lint/BanInappropriateExperimentalUsage.kt b/lint-checks/src/main/java/androidx/build/lint/BanInappropriateExperimentalUsage.kt
index 5bc2e75..4ee07b7 100644
--- a/lint-checks/src/main/java/androidx/build/lint/BanInappropriateExperimentalUsage.kt
+++ b/lint-checks/src/main/java/androidx/build/lint/BanInappropriateExperimentalUsage.kt
@@ -22,13 +22,14 @@
import com.android.tools.lint.detector.api.Category
import com.android.tools.lint.detector.api.Detector
import com.android.tools.lint.detector.api.Implementation
+import com.android.tools.lint.detector.api.Incident
import com.android.tools.lint.detector.api.Issue
import com.android.tools.lint.detector.api.JavaContext
import com.android.tools.lint.detector.api.Scope
import com.android.tools.lint.detector.api.Severity
-import com.intellij.psi.PsiCompiledElement
import org.jetbrains.uast.UAnnotated
import org.jetbrains.uast.UAnnotation
+import org.jetbrains.uast.UClass
import org.jetbrains.uast.UElement
import org.jetbrains.uast.resolveToUElement
@@ -45,11 +46,28 @@
private inner class AnnotationChecker(val context: JavaContext) : UElementHandler() {
override fun visitAnnotation(node: UAnnotation) {
+ if (DEBUG) {
+ if (APPLICABLE_ANNOTATIONS.contains(node.qualifiedName) && node.sourcePsi != null) {
+ (node.uastParent as? UClass)?.let { annotation ->
+ println(
+ "${context.driver.mode}: declared ${annotation.qualifiedName} in " +
+ "${context.project}"
+ )
+ }
+ }
+ }
+
+ // If we find an usage of an experimentally-declared annotation, check it.
val annotation = node.resolveToUElement()
if (annotation is UAnnotated) {
val annotations = context.evaluator.getAllAnnotations(annotation, false)
- val isOptIn = annotations.any { APPLICABLE_ANNOTATIONS.contains(it.qualifiedName) }
- if (isOptIn) {
+ if (annotations.any { APPLICABLE_ANNOTATIONS.contains(it.qualifiedName) }) {
+ if (DEBUG) {
+ println(
+ "${context.driver.mode}: used ${node.qualifiedName} in " +
+ "${context.project}"
+ )
+ }
verifyUsageOfElementIsWithinSameGroup(context, node, annotation, ISSUE)
}
}
@@ -64,28 +82,28 @@
) {
val evaluator = context.evaluator
val usageCoordinates = evaluator.getLibrary(usage) ?: context.project.mavenCoordinate
- val annotationCoordinates = evaluator.getLibrary(annotation) ?: run {
- // Is the annotation defined in source code?
- if (usageCoordinates != null && annotation !is PsiCompiledElement) {
- annotation.sourcePsi?.let { sourcePsi ->
- evaluator.getProject(sourcePsi)?.mavenCoordinate
- }
- } else {
- null
- }
- }
val usageGroupId = usageCoordinates?.groupId
- val annotationGroupId = annotationCoordinates?.groupId
+ val annotationGroupId = evaluator.getLibrary(annotation)?.groupId
if (annotationGroupId != usageGroupId && annotationGroupId != null) {
- context.report(
- issue, usage, context.getNameLocation(usage),
- "`Experimental` and `RequiresOptIn` APIs may only be used within the same-version" +
- " group where they were defined."
- )
+ if (DEBUG) {
+ println(
+ "${context.driver.mode}: report usage of $annotationGroupId in $usageGroupId"
+ )
+ }
+ Incident(context)
+ .issue(issue)
+ .at(usage)
+ .message(
+ "`Experimental` and `RequiresOptIn` APIs may only be used within the " +
+ "same-version group where they were defined."
+ )
+ .report()
}
}
companion object {
+ private const val DEBUG = false
+
private const val KOTLIN_EXPERIMENTAL_ANNOTATION = "kotlin.Experimental"
private const val KOTLIN_REQUIRES_OPT_IN_ANNOTATION = "kotlin.RequiresOptIn"
private const val JAVA_EXPERIMENTAL_ANNOTATION =
diff --git a/lint-checks/src/main/java/androidx/build/lint/BanUncheckedReflection.kt b/lint-checks/src/main/java/androidx/build/lint/BanUncheckedReflection.kt
index 32c2133..725f322c 100644
--- a/lint-checks/src/main/java/androidx/build/lint/BanUncheckedReflection.kt
+++ b/lint-checks/src/main/java/androidx/build/lint/BanUncheckedReflection.kt
@@ -16,6 +16,7 @@
@file:Suppress("UnstableApiUsage")
package androidx.build.lint
+
import com.android.tools.lint.detector.api.Category
import com.android.tools.lint.detector.api.Detector
import com.android.tools.lint.detector.api.Implementation
@@ -23,47 +24,55 @@
import com.android.tools.lint.detector.api.JavaContext
import com.android.tools.lint.detector.api.Scope
import com.android.tools.lint.checks.VersionChecks.Companion.isWithinVersionCheckConditional
-import com.android.sdklib.SdkVersionInfo
+import com.android.sdklib.SdkVersionInfo.HIGHEST_KNOWN_API
import com.android.tools.lint.detector.api.Severity
import com.android.tools.lint.detector.api.SourceCodeScanner
import com.intellij.psi.PsiMethod
import org.jetbrains.uast.UCallExpression
-const val METHOD_REFLECTION_CLASS = "java.lang.reflect.Method"
-class BanUncheckedReflection : Detector(), SourceCodeScanner {
- override fun getApplicableMethodNames() = listOf("invoke")
- override fun visitMethodCall(context: JavaContext, node: UCallExpression, method: PsiMethod) {
- // We are not really monitoring if the reflection call is within the right API check
- // we leave that to the user, and so we check for any API check really. That means
- // any check with an upper bound of the highest known API or a with a lower bound of 1
- // (which should technically include every check) is good enough.
- // Return if not reflection
- if (!context.evaluator.isMemberInClass(method, METHOD_REFLECTION_CLASS)) return
- // If not within an SDK check, flag
- if (!isWithinVersionCheckConditional(
- context, node, SdkVersionInfo.HIGHEST_KNOWN_API, false
- ) && !isWithinVersionCheckConditional(
- context, node, 1, true
- )
- ) {
+class BanUncheckedReflection : Detector(), SourceCodeScanner {
+
+ override fun getApplicableMethodNames() = listOf(
+ METHOD_INVOKE_NAME
+ )
+
+ override fun visitMethodCall(
+ context: JavaContext,
+ node: UCallExpression,
+ method: PsiMethod
+ ) {
+ // We don't care if the invocation is correct -- there's another lint for that. We're
+ // just enforcing the "all reflection on the platform SDK must be gated on SDK_INT checks"
+ // policy. Also -- since we're not actually checking whether the invocation is on the
+ // platform SDK -- we're discouraging reflection in general.
+
+ // Skip if this isn't a call to `Method.invoke`.
+ if (!context.evaluator.isMemberInClass(method, METHOD_REFLECTION_CLASS)) return
+
+ // Flag if the call isn't inside an SDK_INT check.
+ if (!isWithinVersionCheckConditional(context, node, HIGHEST_KNOWN_API, false) &&
+ !isWithinVersionCheckConditional(context, node, 1, true)
+ ) {
context.report(
ISSUE, node, context.getLocation(node),
- "Calling Method.invoke without an SDK check"
+ "Calling `Method.invoke` without an SDK check"
)
}
}
+
companion object {
val ISSUE = Issue.create(
"BanUncheckedReflection",
"Reflection that is not within an SDK check",
- "Use of reflection can be risky and there is never a" +
- " reason to use reflection without" +
- " having to check for the device's SDK (either through SDK_INT comparison or " +
- "methods such as isAtLeastP etc...)" +
- ". Please surround the Method.invoke" +
- " call with the appropriate SDK_INT check.",
+ "Jetpack policy discourages reflection. In cases where reflection is used on " +
+ "platform SDK classes, it must be used within an `SDK_INT` check that delegates " +
+ "to an equivalent public API on the latest version of the platform. If no " +
+ "equivalent public API exists, reflection must not be used.",
Category.CORRECTNESS, 5, Severity.ERROR,
Implementation(BanUncheckedReflection::class.java, Scope.JAVA_FILE_SCOPE)
)
+
+ const val METHOD_REFLECTION_CLASS = "java.lang.reflect.Method"
+ const val METHOD_INVOKE_NAME = "invoke"
}
}
diff --git a/lint-checks/src/test/java/androidx/build/lint/AbstractLintDetectorTest.kt b/lint-checks/src/test/java/androidx/build/lint/AbstractLintDetectorTest.kt
new file mode 100644
index 0000000..8bcfd3e
--- /dev/null
+++ b/lint-checks/src/test/java/androidx/build/lint/AbstractLintDetectorTest.kt
@@ -0,0 +1,107 @@
+/*
+ * Copyright 2021 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.
+ */
+
+@file:Suppress("UnstableApiUsage")
+
+package androidx.build.lint
+
+import com.android.tools.lint.checks.infrastructure.LintDetectorTest
+import com.android.tools.lint.checks.infrastructure.ProjectDescription
+import com.android.tools.lint.checks.infrastructure.TestFile
+import com.android.tools.lint.checks.infrastructure.TestFiles
+import com.android.tools.lint.checks.infrastructure.TestLintResult
+import com.android.tools.lint.checks.infrastructure.TestMode
+import com.android.tools.lint.detector.api.Detector
+import com.android.tools.lint.detector.api.Issue
+import java.io.FileNotFoundException
+
+/**
+ * Implementation of [LintDetectorTest] that's slightly more Kotlin-friendly.
+ */
+abstract class AbstractLintDetectorTest(
+ val useDetector: Detector,
+ val useIssues: List<Issue>,
+ val stubs: Array<TestFile> = emptyArray(),
+) : LintDetectorTest() {
+ override fun getDetector(): Detector = useDetector
+
+ override fun getIssues(): List<Issue> = useIssues
+
+ fun check(
+ vararg projects: ProjectDescription
+ ): TestLintResult {
+ // If we have stubs, push those into a virtual project and pass them through the call to
+ // projects(), since attempting to call files() would overwrite the call to projects().
+ val projectsWithStubs = if (stubs.isNotEmpty()) {
+ arrayOf(*projects, project().files(*stubs))
+ } else {
+ projects
+ }
+
+ return lint()
+ .projects(*projectsWithStubs).testModes(TestMode.DEFAULT, TestMode.PARTIAL)
+ .run()
+ }
+
+ fun check(
+ vararg files: TestFile,
+ ): TestLintResult {
+ return lint()
+ .files(
+ *stubs,
+ *files
+ )
+ .run()
+ }
+}
+
+/**
+ * Creates a new [ProjectDescription].
+ */
+fun project(): ProjectDescription = ProjectDescription()
+
+/**
+ * Loads a [TestFile] from `AndroidManifest.xml` included in the JAR resources.
+ */
+fun manifestSample(): TestFile = TestFiles.manifest(
+ Stubs::class.java.getResource(
+ "/AndroidManifest.xml"
+ )?.readText() ?: throw FileNotFoundException(
+ "Could not find AndroidManifest.xml in the integration test project"
+ )
+)
+
+/**
+ * Loads a [TestFile] from Java source code included in the JAR resources.
+ */
+fun javaSample(className: String): TestFile = TestFiles.java(
+ Stubs::class.java.getResource(
+ "/java/${className.replace('.', '/')}.java"
+ )?.readText() ?: throw FileNotFoundException(
+ "Could not find Java sources for $className in the integration test project"
+ )
+)
+
+/**
+ * Loads a [TestFile] from Kotlin source code included in the JAR resources.
+ */
+fun ktSample(className: String): TestFile = TestFiles.kotlin(
+ Stubs::class.java.getResource(
+ "/java/${className.replace('.', '/')}.kt"
+ )?.readText() ?: throw FileNotFoundException(
+ "Could not find Kotlin sources for $className in the integration test project"
+ )
+)
diff --git a/lint-checks/src/test/java/androidx/build/lint/BanConcurrentHashMapTest.kt b/lint-checks/src/test/java/androidx/build/lint/BanConcurrentHashMapTest.kt
new file mode 100644
index 0000000..a01e86e
--- /dev/null
+++ b/lint-checks/src/test/java/androidx/build/lint/BanConcurrentHashMapTest.kt
@@ -0,0 +1,48 @@
+/*
+ * Copyright 2021 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.
+ */
+
+@file:Suppress("UnstableApiUsage")
+
+package androidx.build.lint
+
+import org.junit.Test
+import org.junit.runner.RunWith
+import org.junit.runners.JUnit4
+
+@RunWith(JUnit4::class)
+class BanConcurrentHashMapTest : AbstractLintDetectorTest(
+ useDetector = BanConcurrentHashMap(),
+ useIssues = listOf(BanConcurrentHashMap.ISSUE),
+) {
+
+ @Test
+ fun `Detection of ConcurrentHashMap usage in Java sources`() {
+ val input = arrayOf(
+ javaSample("androidx.ConcurrentHashMapUsageJava"),
+ )
+
+ /* ktlint-disable max-line-length */
+ val expected = """
+src/androidx/ConcurrentHashMapUsageJava.java:22: Error: Detected ConcurrentHashMap usage. [BanConcurrentHashMap]
+import java.util.concurrent.ConcurrentHashMap;
+~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
+1 errors, 0 warnings
+ """.trimIndent()
+ /* ktlint-enable max-line-length */
+
+ check(*input).expect(expected)
+ }
+}
\ No newline at end of file
diff --git a/lint-checks/src/test/java/androidx/build/lint/BanInappropriateExperimentalUsageTest.kt b/lint-checks/src/test/java/androidx/build/lint/BanInappropriateExperimentalUsageTest.kt
index 0c7e01e..64e10d8 100644
--- a/lint-checks/src/test/java/androidx/build/lint/BanInappropriateExperimentalUsageTest.kt
+++ b/lint-checks/src/test/java/androidx/build/lint/BanInappropriateExperimentalUsageTest.kt
@@ -14,20 +14,22 @@
* limitations under the License.
*/
-@file:Suppress("UnstableApiUsage")
+@file:Suppress("UnstableApiUsage", "GroovyUnusedAssignment")
package androidx.build.lint
-import com.android.tools.lint.checks.infrastructure.TestFile
-import com.android.tools.lint.checks.infrastructure.TestFiles
-import com.android.tools.lint.checks.infrastructure.TestFiles.gradle
-import com.android.tools.lint.checks.infrastructure.TestLintTask.lint
+import com.android.tools.lint.checks.infrastructure.ProjectDescription
+import org.junit.Ignore
import org.junit.Test
import org.junit.runner.RunWith
import org.junit.runners.JUnit4
@RunWith(JUnit4::class)
-class BanInappropriateExperimentalUsageTest {
+class BanInappropriateExperimentalUsageTest : AbstractLintDetectorTest(
+ useDetector = BanInappropriateExperimentalUsage(),
+ useIssues = listOf(BanInappropriateExperimentalUsage.ISSUE),
+ stubs = arrayOf(Stubs.OptIn),
+) {
@Test
fun `Test within-module Experimental usage via Gradle model`() {
@@ -42,24 +44,23 @@
group=sample.annotation.provider
"""
).indented(),
- OPT_IN_KT,
)
- lint()
- .projects(provider)
- .issues(BanInappropriateExperimentalUsage.ISSUE)
- .run()
- .expect(
- """
- No warnings.
- """.trimIndent()
- )
+ /* ktlint-disable max-line-length */
+ val expected = """
+No warnings.
+ """.trimIndent()
+ /* ktlint-enable max-line-length */
+
+ check(provider).expect(expected)
}
+ @Ignore("b/188814760")
@Test
fun `Test cross-module Experimental usage via Gradle model`() {
val provider = project()
.name("provider")
+ .type(ProjectDescription.Type.LIBRARY)
.report(false)
.files(
ktSample("sample.annotation.provider.ExperimentalSampleAnnotation"),
@@ -70,11 +71,11 @@
group=sample.annotation.provider
"""
).indented(),
- OPT_IN_KT,
)
val consumer = project()
.name("consumer")
+ .type(ProjectDescription.Type.LIBRARY)
.dependsOn(provider)
.files(
ktSample("androidx.sample.consumer.OutsideGroupExperimentalAnnotatedClass"),
@@ -83,69 +84,18 @@
apply plugin: 'com.android.library'
group=androidx.sample.consumer
"""
- ).indented()
+ ).indented(),
)
- lint()
- .projects(provider, consumer)
- .issues(BanInappropriateExperimentalUsage.ISSUE)
- .run()
- .expect(
- /* ktlint-enable max-line-length */
- """
- src/main/kotlin/androidx/sample/consumer/OutsideGroupExperimentalAnnotatedClass.kt:25: Error: Experimental and RequiresOptIn APIs may only be used within the same-version group where they were defined. [IllegalExperimentalApiUsage]
- @ExperimentalSampleAnnotationJava
- ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
- 1 errors, 0 warnings
- """.trimIndent()
- /* ktlint-enable max-line-length */
- )
+ /* ktlint-disable max-line-length */
+ val expected = """
+../consumer/src/main/kotlin/androidx/sample/consumer/OutsideGroupExperimentalAnnotatedClass.kt:25: Error: Experimental and RequiresOptIn APIs may only be used within the same-version group where they were defined. [IllegalExperimentalApiUsage]
+ @ExperimentalSampleAnnotationJava
+ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
+1 errors, 0 warnings
+ """.trimIndent()
+ /* ktlint-enable max-line-length */
+
+ check(provider, consumer).expect(expected)
}
}
-
-/* ktlint-disable max-line-length */
-
-/**
- * [TestFile] containing OptIn.kt from the Kotlin standard library.
- *
- * This is a workaround for the Kotlin standard library used by the Lint test harness not
- * including the Experimental annotation by default.
- */
-private val OPT_IN_KT: TestFile = TestFiles.kotlin(
- """
- package kotlin
-
- import kotlin.annotation.AnnotationRetention.BINARY
- import kotlin.annotation.AnnotationRetention.SOURCE
- import kotlin.annotation.AnnotationTarget.*
- import kotlin.internal.RequireKotlin
- import kotlin.internal.RequireKotlinVersionKind
- import kotlin.reflect.KClass
-
- @Target(ANNOTATION_CLASS)
- @Retention(BINARY)
- @SinceKotlin("1.3")
- @RequireKotlin("1.3.70", versionKind = RequireKotlinVersionKind.COMPILER_VERSION)
- public annotation class RequiresOptIn(
- val message: String = "",
- val level: Level = Level.ERROR
- ) {
- public enum class Level {
- WARNING,
- ERROR,
- }
- }
-
- @Target(
- CLASS, PROPERTY, LOCAL_VARIABLE, VALUE_PARAMETER, CONSTRUCTOR, FUNCTION, PROPERTY_GETTER, PROPERTY_SETTER, EXPRESSION, FILE, TYPEALIAS
- )
- @Retention(SOURCE)
- @SinceKotlin("1.3")
- @RequireKotlin("1.3.70", versionKind = RequireKotlinVersionKind.COMPILER_VERSION)
- public annotation class OptIn(
- vararg val markerClass: KClass<out Annotation>
- )
- """.trimIndent()
-)
-
-/* ktlint-enable max-line-length */
diff --git a/lint-checks/src/test/java/androidx/build/lint/BanKeepAnnotationTest.kt b/lint-checks/src/test/java/androidx/build/lint/BanKeepAnnotationTest.kt
index 4b5b504..dceb43b 100644
--- a/lint-checks/src/test/java/androidx/build/lint/BanKeepAnnotationTest.kt
+++ b/lint-checks/src/test/java/androidx/build/lint/BanKeepAnnotationTest.kt
@@ -14,55 +14,36 @@
* limitations under the License.
*/
+@file:Suppress("UnstableApiUsage")
+
package androidx.build.lint
-import com.android.tools.lint.checks.infrastructure.LintDetectorTest
-import com.android.tools.lint.checks.infrastructure.TestFiles.java
-import com.android.tools.lint.checks.infrastructure.TestLintResult
-import com.android.tools.lint.checks.infrastructure.TestLintTask.lint
-import com.android.tools.lint.detector.api.Detector
-import com.android.tools.lint.detector.api.Issue
-
import org.junit.Test
+import org.junit.runner.RunWith
+import org.junit.runners.JUnit4
-class BanKeepAnnotationTest : LintDetectorTest() {
- override fun getDetector(): Detector = BanKeepAnnotation()
+@RunWith(JUnit4::class)
+class BanKeepAnnotationTest : AbstractLintDetectorTest(
+ useDetector = BanKeepAnnotation(),
+ useIssues = listOf(BanKeepAnnotation.ISSUE),
+ stubs = arrayOf(Stubs.Keep),
+) {
- override fun getIssues(): List<Issue> = listOf(
- BanKeepAnnotation.ISSUE
- )
-
- private fun check(code: String): TestLintResult {
- return lint().files(
- java(annotationSource),
- java(code)
+ @Test
+ fun `Detection of Keep annotation in Java sources`() {
+ val input = arrayOf(
+ javaSample("androidx.KeepAnnotationUsageJava"),
)
- .run()
- }
- private val annotationSource = """
- package androidx.annotation;
-
- public @interface Keep {
- }
- """
-
- @Test fun testAnnotatedUnreferencedClass() {
- val input = """
- package androidx.sample;
-
- import androidx.annotation.Keep;
- @Keep
- public class SampleClass {
- }
- """
+ /* ktlint-disable max-line-length */
val expected = """
- src/androidx/sample/SampleClass.java:4: Error: Uses @Keep annotation [BanKeepAnnotation]
- @Keep
- ~~~~~
- 1 errors, 0 warnings
- """
- check(input.trimIndent())
- .expect(expected.trimIndent())
+src/androidx/KeepAnnotationUsageJava.java:21: Error: Uses @Keep annotation [BanKeepAnnotation]
+@Keep
+~~~~~
+1 errors, 0 warnings
+ """.trimIndent()
+ /* ktlint-enable max-line-length */
+
+ check(*input).expect(expected)
}
}
diff --git a/lint-checks/src/test/java/androidx/build/lint/BanParcelableUsageTest.kt b/lint-checks/src/test/java/androidx/build/lint/BanParcelableUsageTest.kt
new file mode 100644
index 0000000..b2cc7d4
--- /dev/null
+++ b/lint-checks/src/test/java/androidx/build/lint/BanParcelableUsageTest.kt
@@ -0,0 +1,48 @@
+/*
+ * Copyright 2021 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.
+ */
+
+@file:Suppress("UnstableApiUsage")
+
+package androidx.build.lint
+
+import org.junit.Test
+import org.junit.runner.RunWith
+import org.junit.runners.JUnit4
+
+@RunWith(JUnit4::class)
+class BanParcelableUsageTest : AbstractLintDetectorTest(
+ useDetector = BanParcelableUsage(),
+ useIssues = listOf(BanParcelableUsage.ISSUE),
+) {
+
+ @Test
+ fun `Detection of Parcelable usage in Java sources`() {
+ val input = arrayOf(
+ javaSample("androidx.ParcelableUsageJava"),
+ )
+
+ /* ktlint-disable max-line-length */
+ val expected = """
+src/androidx/ParcelableUsageJava.java:25: Error: Class implements android.os.Parcelable [BanParcelableUsage]
+public class ParcelableUsageJava implements Parcelable {
+ ~~~~~~~~~~~~~~~~~~~
+1 errors, 0 warnings
+ """.trimIndent()
+ /* ktlint-enable max-line-length */
+
+ check(*input).expect(expected)
+ }
+}
\ No newline at end of file
diff --git a/lint-checks/src/test/java/androidx/build/lint/BanSynchronizedMethodsTest.kt b/lint-checks/src/test/java/androidx/build/lint/BanSynchronizedMethodsTest.kt
new file mode 100644
index 0000000..702b681
--- /dev/null
+++ b/lint-checks/src/test/java/androidx/build/lint/BanSynchronizedMethodsTest.kt
@@ -0,0 +1,48 @@
+/*
+ * Copyright 2021 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.
+ */
+
+@file:Suppress("UnstableApiUsage")
+
+package androidx.build.lint
+
+import org.junit.Test
+import org.junit.runner.RunWith
+import org.junit.runners.JUnit4
+
+@RunWith(JUnit4::class)
+class BanSynchronizedMethodsTest : AbstractLintDetectorTest(
+ useDetector = BanSynchronizedMethods(),
+ useIssues = listOf(BanSynchronizedMethods.ISSUE),
+) {
+
+ @Test
+ fun `Detection of synchronized methods in Java sources`() {
+ val input = arrayOf(
+ javaSample("androidx.SynchronizedMethodJava"),
+ )
+
+ /* ktlint-disable max-line-length */
+ val expected = """
+src/androidx/SynchronizedMethodJava.java:22: Error: Use of synchronized methods is not recommended [BanSynchronizedMethods]
+ public synchronized void someMethod() {
+ ^
+1 errors, 0 warnings
+ """.trimIndent()
+ /* ktlint-enable max-line-length */
+
+ check(*input).expect(expected)
+ }
+}
diff --git a/lint-checks/src/test/java/androidx/build/lint/BanTargetApiAnnotationTest.kt b/lint-checks/src/test/java/androidx/build/lint/BanTargetApiAnnotationTest.kt
new file mode 100644
index 0000000..49429e0
--- /dev/null
+++ b/lint-checks/src/test/java/androidx/build/lint/BanTargetApiAnnotationTest.kt
@@ -0,0 +1,51 @@
+/*
+ * Copyright 2021 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.
+ */
+
+@file:Suppress("UnstableApiUsage")
+
+package androidx.build.lint
+
+import org.junit.Test
+import org.junit.runner.RunWith
+import org.junit.runners.JUnit4
+
+@RunWith(JUnit4::class)
+class BanTargetApiAnnotationTest : AbstractLintDetectorTest(
+ useDetector = BanTargetApiAnnotation(),
+ useIssues = listOf(BanTargetApiAnnotation.ISSUE),
+) {
+
+ @Test
+ fun `Detection of TargetApi usage in Java sources`() {
+ val input = arrayOf(
+ javaSample("androidx.TargetApiUsageJava"),
+ )
+
+ /* ktlint-disable max-line-length */
+ val expected = """
+src/androidx/TargetApiUsageJava.java:22: Error: Uses @TargetApi annotation [BanTargetApiAnnotation]
+@TargetApi(29)
+~~~~~~~~~~~~~~
+src/androidx/TargetApiUsageJava.java:25: Error: Uses @TargetApi annotation [BanTargetApiAnnotation]
+ @TargetApi(30)
+ ~~~~~~~~~~~~~~
+2 errors, 0 warnings
+ """.trimIndent()
+ /* ktlint-enable max-line-length */
+
+ check(*input).expect(expected)
+ }
+}
\ No newline at end of file
diff --git a/lint-checks/src/test/java/androidx/build/lint/BanUncheckedReflectionTest.kt b/lint-checks/src/test/java/androidx/build/lint/BanUncheckedReflectionTest.kt
new file mode 100644
index 0000000..6c66b16
--- /dev/null
+++ b/lint-checks/src/test/java/androidx/build/lint/BanUncheckedReflectionTest.kt
@@ -0,0 +1,70 @@
+/*
+ * Copyright 2021 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.
+ */
+
+@file:Suppress("UnstableApiUsage")
+
+package androidx.build.lint
+
+import org.junit.Test
+import org.junit.runner.RunWith
+import org.junit.runners.JUnit4
+
+@RunWith(JUnit4::class)
+class BanUncheckedReflectionTest : AbstractLintDetectorTest(
+ useDetector = BanUncheckedReflection(),
+ useIssues = listOf(BanUncheckedReflection.ISSUE),
+ stubs = arrayOf(Stubs.ChecksSdkIntAtLeast),
+) {
+
+ @Test
+ fun `Detection of unchecked reflection in real-world Java sources`() {
+ val input = arrayOf(
+ javaSample("androidx.sample.core.app.ActivityRecreator"),
+ )
+
+ /* ktlint-disable max-line-length */
+ val expected = """
+src/androidx/sample/core/app/ActivityRecreator.java:145: Error: Calling Method.invoke without an SDK check [BanUncheckedReflection]
+ requestRelaunchActivityMethod.invoke(activityThread,
+ ^
+src/androidx/sample/core/app/ActivityRecreator.java:262: Error: Calling Method.invoke without an SDK check [BanUncheckedReflection]
+ performStopActivity3ParamsMethod.invoke(activityThread,
+ ^
+src/androidx/sample/core/app/ActivityRecreator.java:265: Error: Calling Method.invoke without an SDK check [BanUncheckedReflection]
+ performStopActivity2ParamsMethod.invoke(activityThread,
+ ^
+3 errors, 0 warnings
+ """.trimIndent()
+ /* ktlint-enable max-line-length */
+
+ check(*input).expect(expected)
+ }
+
+ @Test
+ fun `Checked reflection in real-world Java sources`() {
+ val input = arrayOf(
+ javaSample("androidx.sample.core.app.ActivityRecreatorChecked"),
+ )
+
+ /* ktlint-disable max-line-length */
+ val expected = """
+No warnings.
+ """.trimIndent()
+ /* ktlint-enable max-line-length */
+
+ check(*input).expect(expected)
+ }
+}
diff --git a/lint-checks/src/test/java/androidx/build/lint/ClassVerificationFailureDetectorTest.kt b/lint-checks/src/test/java/androidx/build/lint/ClassVerificationFailureDetectorTest.kt
index 253df56..c1006d3 100644
--- a/lint-checks/src/test/java/androidx/build/lint/ClassVerificationFailureDetectorTest.kt
+++ b/lint-checks/src/test/java/androidx/build/lint/ClassVerificationFailureDetectorTest.kt
@@ -14,38 +14,28 @@
* limitations under the License.
*/
+@file:Suppress("UnstableApiUsage")
+
package androidx.build.lint
-import com.android.tools.lint.checks.infrastructure.LintDetectorTest.manifest
-import com.android.tools.lint.checks.infrastructure.TestFile
-import com.android.tools.lint.checks.infrastructure.TestFiles
-import com.android.tools.lint.checks.infrastructure.TestLintResult
-import com.android.tools.lint.checks.infrastructure.TestLintTask.lint
import org.junit.Test
import org.junit.runner.RunWith
import org.junit.runners.JUnit4
-@Suppress("UnstableApiUsage")
@RunWith(JUnit4::class)
-class ClassVerificationFailureDetectorTest {
-
- private fun check(
- vararg testFiles: TestFile,
- minSdkVersion: Int = 14,
- ): TestLintResult {
- return lint()
- .files(
- manifest().minSdk(minSdkVersion),
- *testFiles,
- )
- .issues(ClassVerificationFailureDetector.ISSUE)
- .run()
- }
+class ClassVerificationFailureDetectorTest : AbstractLintDetectorTest(
+ useDetector = ClassVerificationFailureDetector(),
+ useIssues = listOf(ClassVerificationFailureDetector.ISSUE),
+ stubs = arrayOf(
+ // AndroidManifest with minSdkVersion=14
+ manifest().minSdk(14),
+ ),
+) {
@Test
fun `Detection of unsafe references in Java sources`() {
val input = arrayOf(
- javaSample("androidx.ClassVerificationFailureFromJava")
+ javaSample("androidx.ClassVerificationFailureFromJava"),
)
/* ktlint-disable max-line-length */
@@ -72,22 +62,22 @@
@Test
fun `Detection and auto-fix of unsafe references in real-world Java sources`() {
val input = arrayOf(
- javaSample("androidx.core.widget.ListViewCompat")
+ javaSample("androidx.sample.core.widget.ListViewCompat"),
)
/* ktlint-disable max-line-length */
val expected = """
-src/androidx/core/widget/ListViewCompat.java:39: Error: This call references a method added in API level 19; however, the containing class androidx.core.widget.ListViewCompat is reachable from earlier API levels and will fail run-time class verification. [ClassVerificationFailure]
+src/androidx/sample/core/widget/ListViewCompat.java:39: Error: This call references a method added in API level 19; however, the containing class androidx.sample.core.widget.ListViewCompat is reachable from earlier API levels and will fail run-time class verification. [ClassVerificationFailure]
listView.scrollListBy(y);
~~~~~~~~~~~~
-src/androidx/core/widget/ListViewCompat.java:69: Error: This call references a method added in API level 19; however, the containing class androidx.core.widget.ListViewCompat is reachable from earlier API levels and will fail run-time class verification. [ClassVerificationFailure]
+src/androidx/sample/core/widget/ListViewCompat.java:69: Error: This call references a method added in API level 19; however, the containing class androidx.sample.core.widget.ListViewCompat is reachable from earlier API levels and will fail run-time class verification. [ClassVerificationFailure]
return listView.canScrollList(direction);
~~~~~~~~~~~~~
2 errors, 0 warnings
""".trimIndent()
val expectedFix = """
-Fix for src/androidx/core/widget/ListViewCompat.java line 39: Extract to static inner class:
+Fix for src/androidx/sample/core/widget/ListViewCompat.java line 39: Extract to static inner class:
@@ -39 +39
- listView.scrollListBy(y);
+ Api19Impl.scrollListBy(listView, y);
@@ -106,7 +96,7 @@
@@ -93 +102
+ }}
+
-Fix for src/androidx/core/widget/ListViewCompat.java line 69: Extract to static inner class:
+Fix for src/androidx/sample/core/widget/ListViewCompat.java line 69: Extract to static inner class:
@@ -69 +69
- return listView.canScrollList(direction);
+ return Api19Impl.canScrollList(listView, direction);
@@ -134,7 +124,7 @@
@Test
fun `Auto-fix unsafe void-type method reference in Java source`() {
val input = arrayOf(
- javaSample("androidx.AutofixUnsafeVoidMethodReferenceJava")
+ javaSample("androidx.AutofixUnsafeVoidMethodReferenceJava"),
)
/* ktlint-disable max-line-length */
@@ -167,7 +157,7 @@
@Test
fun `Auto-fix unsafe constructor reference in Java source`() {
val input = arrayOf(
- javaSample("androidx.AutofixUnsafeConstructorReferenceJava")
+ javaSample("androidx.AutofixUnsafeConstructorReferenceJava"),
)
/* ktlint-disable max-line-length */
@@ -200,7 +190,7 @@
@Test
fun `Auto-fix unsafe static method reference in Java source`() {
val input = arrayOf(
- javaSample("androidx.AutofixUnsafeStaticMethodReferenceJava")
+ javaSample("androidx.AutofixUnsafeStaticMethodReferenceJava"),
)
/* ktlint-disable max-line-length */
@@ -233,7 +223,7 @@
@Test
fun `Auto-fix unsafe generic-type method reference in Java source`() {
val input = arrayOf(
- javaSample("androidx.AutofixUnsafeGenericMethodReferenceJava")
+ javaSample("androidx.AutofixUnsafeGenericMethodReferenceJava"),
)
/* ktlint-disable max-line-length */
@@ -266,7 +256,7 @@
@Test
fun `Auto-fix unsafe reference in Java source with existing inner class`() {
val input = arrayOf(
- javaSample("androidx.AutofixUnsafeReferenceWithExistingClassJava")
+ javaSample("androidx.AutofixUnsafeReferenceWithExistingClassJava"),
)
/* ktlint-disable max-line-length */
@@ -295,18 +285,4 @@
check(*input).expectFixDiffs(expectedFix)
}
-
- /**
- * Loads a [TestFile] from Java source code included in the JAR resources.
- */
- private fun javaSample(className: String): TestFile = TestFiles.java(
- javaClass.getResource("/java/${className.replace('.', '/')}.java").readText()
- )
-
- /**
- * Loads a [TestFile] from Kotlin source code included in the JAR resources.
- */
- private fun ktSample(className: String): TestFile = TestFiles.kotlin(
- javaClass.getResource("/java/${className.replace('.', '/')}.kt").readText()
- )
}
\ No newline at end of file
diff --git a/lint-checks/src/test/java/androidx/build/lint/IdeaSuppressionDetectorTest.kt b/lint-checks/src/test/java/androidx/build/lint/IdeaSuppressionDetectorTest.kt
index d3879db..0ed74a4 100644
--- a/lint-checks/src/test/java/androidx/build/lint/IdeaSuppressionDetectorTest.kt
+++ b/lint-checks/src/test/java/androidx/build/lint/IdeaSuppressionDetectorTest.kt
@@ -14,30 +14,19 @@
* limitations under the License.
*/
+@file:Suppress("UnstableApiUsage")
+
package androidx.build.lint
-import com.android.tools.lint.checks.infrastructure.TestFile
-import com.android.tools.lint.checks.infrastructure.TestFiles
-import com.android.tools.lint.checks.infrastructure.TestLintResult
-import com.android.tools.lint.checks.infrastructure.TestLintTask.lint
import org.junit.Test
import org.junit.runner.RunWith
import org.junit.runners.JUnit4
-@Suppress("UnstableApiUsage")
@RunWith(JUnit4::class)
-class IdeaSuppressionDetectorTest {
-
- private fun check(
- vararg testFiles: TestFile,
- ): TestLintResult {
- return lint()
- .files(
- *testFiles,
- )
- .issues(IdeaSuppressionDetector.ISSUE)
- .run()
- }
+class IdeaSuppressionDetectorTest : AbstractLintDetectorTest(
+ useDetector = IdeaSuppressionDetector(),
+ useIssues = listOf(IdeaSuppressionDetector.ISSUE),
+) {
@Test
fun `Detection of IDEA-specific suppression in Java sources`() {
@@ -56,11 +45,4 @@
check(*input).expect(expected)
}
-
- /**
- * Loads a [TestFile] from Java source code included in the JAR resources.
- */
- private fun javaSample(className: String): TestFile = TestFiles.java(
- javaClass.getResource("/java/${className.replace('.', '/')}.java").readText()
- )
-}
\ No newline at end of file
+}
diff --git a/lint-checks/src/test/java/androidx/build/lint/MetadataTagInsideApplicationTagDetectorTest.kt b/lint-checks/src/test/java/androidx/build/lint/MetadataTagInsideApplicationTagDetectorTest.kt
new file mode 100644
index 0000000..f587614
--- /dev/null
+++ b/lint-checks/src/test/java/androidx/build/lint/MetadataTagInsideApplicationTagDetectorTest.kt
@@ -0,0 +1,48 @@
+/*
+ * Copyright 2021 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.
+ */
+
+@file:Suppress("UnstableApiUsage")
+
+package androidx.build.lint
+
+import org.junit.Test
+import org.junit.runner.RunWith
+import org.junit.runners.JUnit4
+
+@RunWith(JUnit4::class)
+class MetadataTagInsideApplicationTagDetectorTest : AbstractLintDetectorTest(
+ useDetector = MetadataTagInsideApplicationTagDetector(),
+ useIssues = listOf(MetadataTagInsideApplicationTagDetector.ISSUE),
+) {
+
+ @Test
+ fun `Detect usage of metadata tag insice application tag`() {
+ val input = arrayOf(
+ manifestSample()
+ )
+
+ /* ktlint-disable max-line-length */
+ val expected = """
+AndroidManifest.xml:20: Error: Detected <application>-level meta-data tag. [MetadataTagInsideApplicationTag]
+ <meta-data android:name="name" android:value="value" />
+ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
+1 errors, 0 warnings
+ """.trimIndent()
+ /* ktlint-enable max-line-length */
+
+ check(*input).expect(expected)
+ }
+}
diff --git a/lint-checks/src/test/java/androidx/build/lint/ObsoleteBuildCompatUsageDetectorTest.kt b/lint-checks/src/test/java/androidx/build/lint/ObsoleteBuildCompatUsageDetectorTest.kt
index deaab57..874cc32 100644
--- a/lint-checks/src/test/java/androidx/build/lint/ObsoleteBuildCompatUsageDetectorTest.kt
+++ b/lint-checks/src/test/java/androidx/build/lint/ObsoleteBuildCompatUsageDetectorTest.kt
@@ -14,40 +14,27 @@
* limitations under the License.
*/
-package androidx.build.lint
+@file:Suppress("UnstableApiUsage")
-import com.android.tools.lint.checks.infrastructure.TestFiles.java
-import com.android.tools.lint.checks.infrastructure.TestLintResult
-import com.android.tools.lint.checks.infrastructure.TestLintTask.lint
+package androidx.build.lint
import org.junit.Ignore
import org.junit.Test
+import org.junit.runner.RunWith
+import org.junit.runners.JUnit4
@Ignore("ANDROID_HOME not available on CI")
-class ObsoleteBuildCompatUsageDetectorTest {
- private val buildCompatStub = java(
- """
- package androidx.core.os;
- public class BuildCompat {
- public static boolean isAtLeastN() { return false; }
- public static boolean isAtLeastNMR1() { return false; }
- public static boolean isAtLeastO() { return false; }
- public static boolean isAtLeastOMR1() { return false; }
- public static boolean isAtLeastP() { return false; }
- public static boolean isAtLeastQ() { return false; }
- }
- """.trimIndent()
- )
+@RunWith(JUnit4::class)
+class ObsoleteBuildCompatUsageDetectorTest : AbstractLintDetectorTest(
+ useDetector = ObsoleteBuildCompatUsageDetector(),
+ useIssues = listOf(ObsoleteBuildCompatUsageDetector.ISSUE),
+ stubs = arrayOf(BuildCompat),
+) {
- private fun check(vararg code: String): TestLintResult {
- return lint().files(buildCompatStub, *code.map(::java).toTypedArray())
- .allowMissingSdk(true)
- .issues(ObsoleteBuildCompatUsageDetector.ISSUE)
- .run()
- }
-
- @Test fun isAtLeastN() {
- val input = """
+ @Test
+ fun isAtLeastN() {
+ val input = java(
+ """
package foo;
import androidx.core.os.BuildCompat;
public class Example {
@@ -57,26 +44,34 @@
}
}
}
- """
+ """.trimIndent()
+ )
+
+ /* ktlint-disable max-line-length */
val expected = """
src/foo/Example.java:5: Error: Using deprecated BuildCompat methods [ObsoleteBuildCompat]
if (BuildCompat.isAtLeastN()) {
~~~~~~~~~~~~~~~~~~~~~~~~
1 errors, 0 warnings
"""
+
val expectedDiff = """
Fix for src/foo/Example.java line 5: Use SDK_INT >= 24:
@@ -5 +5
- if (BuildCompat.isAtLeastN()) {
+ if (Build.VERSION.SDK_INT >= 24) {
"""
- check(input.trimIndent())
+ /* ktlint-enable max-line-length */
+
+ check(input)
.expect(expected.trimIndent())
.expectFixDiffs(expectedDiff.trimIndent())
}
- @Test fun isAtLeastNStaticImport() {
- val input = """
+ @Test
+ fun isAtLeastNStaticImport() {
+ val input = java(
+ """
package foo;
import static androidx.core.os.BuildCompat.isAtLeastN;
public class Example {
@@ -86,26 +81,34 @@
}
}
}
- """
+ """.trimIndent()
+ )
+
+ /* ktlint-disable max-line-length */
val expected = """
src/foo/Example.java:5: Error: Using deprecated BuildCompat methods [ObsoleteBuildCompat]
if (isAtLeastN()) {
~~~~~~~~~~~~
1 errors, 0 warnings
"""
+
val expectedDiff = """
Fix for src/foo/Example.java line 5: Use SDK_INT >= 24:
@@ -5 +5
- if (isAtLeastN()) {
+ if (Build.VERSION.SDK_INT >= 24) {
"""
- check(input.trimIndent())
+ /* ktlint-enable max-line-length */
+
+ check(input)
.expect(expected.trimIndent())
.expectFixDiffs(expectedDiff.trimIndent())
}
- @Test fun isAtLeastNMR1() {
- val input = """
+ @Test
+ fun isAtLeastNMR1() {
+ val input = java(
+ """
package foo;
import androidx.core.os.BuildCompat;
public class Example {
@@ -115,26 +118,34 @@
}
}
}
- """
+ """.trimIndent()
+ )
+
+ /* ktlint-disable max-line-length */
val expected = """
src/foo/Example.java:5: Error: Using deprecated BuildCompat methods [ObsoleteBuildCompat]
if (BuildCompat.isAtLeastNMR1()) {
~~~~~~~~~~~~~~~~~~~~~~~~~~~
1 errors, 0 warnings
"""
+
val expectedDiff = """
Fix for src/foo/Example.java line 5: Use SDK_INT >= 25:
@@ -5 +5
- if (BuildCompat.isAtLeastNMR1()) {
+ if (Build.VERSION.SDK_INT >= 25) {
"""
- check(input.trimIndent())
+ /* ktlint-enable max-line-length */
+
+ check(input)
.expect(expected.trimIndent())
.expectFixDiffs(expectedDiff.trimIndent())
}
- @Test fun isAtLeastO() {
- val input = """
+ @Test
+ fun isAtLeastO() {
+ val input = java(
+ """
package foo;
import androidx.core.os.BuildCompat;
public class Example {
@@ -144,26 +155,34 @@
}
}
}
- """
+ """.trimIndent()
+ )
+
+ /* ktlint-disable max-line-length */
val expected = """
src/foo/Example.java:5: Error: Using deprecated BuildCompat methods [ObsoleteBuildCompat]
if (BuildCompat.isAtLeastO()) {
~~~~~~~~~~~~~~~~~~~~~~~~
1 errors, 0 warnings
"""
+
val expectedDiff = """
Fix for src/foo/Example.java line 5: Use SDK_INT >= 26:
@@ -5 +5
- if (BuildCompat.isAtLeastO()) {
+ if (Build.VERSION.SDK_INT >= 26) {
"""
- check(input.trimIndent())
+ /* ktlint-enable max-line-length */
+
+ check(input)
.expect(expected.trimIndent())
.expectFixDiffs(expectedDiff.trimIndent())
}
- @Test fun isAtLeastOMR1() {
- val input = """
+ @Test
+ fun isAtLeastOMR1() {
+ val input = java(
+ """
package foo;
import androidx.core.os.BuildCompat;
public class Example {
@@ -173,26 +192,34 @@
}
}
}
- """
+ """.trimIndent()
+ )
+
+ /* ktlint-disable max-line-length */
val expected = """
src/foo/Example.java:5: Error: Using deprecated BuildCompat methods [ObsoleteBuildCompat]
if (BuildCompat.isAtLeastOMR1()) {
~~~~~~~~~~~~~~~~~~~~~~~~~~~
1 errors, 0 warnings
"""
+
val expectedDiff = """
Fix for src/foo/Example.java line 5: Use SDK_INT >= 27:
@@ -5 +5
- if (BuildCompat.isAtLeastOMR1()) {
+ if (Build.VERSION.SDK_INT >= 27) {
"""
- check(input.trimIndent())
+ /* ktlint-enable max-line-length */
+
+ check(input)
.expect(expected.trimIndent())
.expectFixDiffs(expectedDiff.trimIndent())
}
- @Test fun isAtLeastP() {
- val input = """
+ @Test
+ fun isAtLeastP() {
+ val input = java(
+ """
package foo;
import androidx.core.os.BuildCompat;
public class Example {
@@ -202,26 +229,34 @@
}
}
}
- """
+ """.trimIndent()
+ )
+
+ /* ktlint-disable max-line-length */
val expected = """
src/foo/Example.java:5: Error: Using deprecated BuildCompat methods [ObsoleteBuildCompat]
if (BuildCompat.isAtLeastP()) {
~~~~~~~~~~~~~~~~~~~~~~~~
1 errors, 0 warnings
"""
+
val expectedDiff = """
Fix for src/foo/Example.java line 5: Use SDK_INT >= 28:
@@ -5 +5
- if (BuildCompat.isAtLeastP()) {
+ if (Build.VERSION.SDK_INT >= 28) {
"""
- check(input.trimIndent())
+ /* ktlint-enable max-line-length */
+
+ check(input)
.expect(expected.trimIndent())
.expectFixDiffs(expectedDiff.trimIndent())
}
- @Test fun isAtLeastQ() {
- val input = """
+ @Test
+ fun isAtLeastQ() {
+ val input = java(
+ """
package foo;
import androidx.core.os.BuildCompat;
public class Example {
@@ -231,21 +266,43 @@
}
}
}
- """
+ """.trimIndent()
+ )
+
+ /* ktlint-disable max-line-length */
val expected = """
src/foo/Example.java:5: Error: Using deprecated BuildCompat methods [ObsoleteBuildCompat]
if (BuildCompat.isAtLeastQ()) {
~~~~~~~~~~~~~~~~~~~~~~~~
1 errors, 0 warnings
"""
+
val expectedDiff = """
Fix for src/foo/Example.java line 5: Use SDK_INT >= 29:
@@ -5 +5
- if (BuildCompat.isAtLeastQ()) {
+ if (Build.VERSION.SDK_INT >= 29) {
"""
- check(input.trimIndent())
+ /* ktlint-enable max-line-length */
+
+ check(input)
.expect(expected.trimIndent())
.expectFixDiffs(expectedDiff.trimIndent())
}
+
+ companion object {
+ private val BuildCompat = java(
+ """
+ package androidx.core.os;
+ public class BuildCompat {
+ public static boolean isAtLeastN() { return false; }
+ public static boolean isAtLeastNMR1() { return false; }
+ public static boolean isAtLeastO() { return false; }
+ public static boolean isAtLeastOMR1() { return false; }
+ public static boolean isAtLeastP() { return false; }
+ public static boolean isAtLeastQ() { return false; }
+ }
+ """.trimIndent()
+ )
+ }
}
diff --git a/lint-checks/src/test/java/androidx/build/lint/PrivateConstructorForUtilityClassDetectorTest.kt b/lint-checks/src/test/java/androidx/build/lint/PrivateConstructorForUtilityClassDetectorTest.kt
index 0d51308..b8ac0d9 100644
--- a/lint-checks/src/test/java/androidx/build/lint/PrivateConstructorForUtilityClassDetectorTest.kt
+++ b/lint-checks/src/test/java/androidx/build/lint/PrivateConstructorForUtilityClassDetectorTest.kt
@@ -18,24 +18,15 @@
package androidx.build.lint
-import com.android.tools.lint.checks.infrastructure.TestFile
-import com.android.tools.lint.checks.infrastructure.TestLintResult
-import com.android.tools.lint.checks.infrastructure.TestLintTask.lint
import org.junit.Test
import org.junit.runner.RunWith
import org.junit.runners.JUnit4
@RunWith(JUnit4::class)
-class PrivateConstructorForUtilityClassDetectorTest {
-
- private fun check(
- vararg testFiles: TestFile,
- ): TestLintResult {
- return lint()
- .files(*testFiles)
- .issues(PrivateConstructorForUtilityClassDetector.ISSUE)
- .run()
- }
+class PrivateConstructorForUtilityClassDetectorTest : AbstractLintDetectorTest(
+ useDetector = PrivateConstructorForUtilityClassDetector(),
+ useIssues = listOf(PrivateConstructorForUtilityClassDetector.ISSUE),
+) {
@Test
fun testInnerClassVisibilityJava() {
diff --git a/lint-checks/src/test/java/androidx/build/lint/SampledAnnotationEnforcerTest.kt b/lint-checks/src/test/java/androidx/build/lint/SampledAnnotationEnforcerTest.kt
index 2c638cb..0e6943f 100644
--- a/lint-checks/src/test/java/androidx/build/lint/SampledAnnotationEnforcerTest.kt
+++ b/lint-checks/src/test/java/androidx/build/lint/SampledAnnotationEnforcerTest.kt
@@ -14,7 +14,7 @@
* limitations under the License.
*/
-@file:Suppress("KDocUnresolvedReference")
+@file:Suppress("KDocUnresolvedReference", "UnstableApiUsage")
package androidx.build.lint
diff --git a/lint-checks/src/test/java/androidx/build/lint/Stubs.kt b/lint-checks/src/test/java/androidx/build/lint/Stubs.kt
new file mode 100644
index 0000000..06a6353
--- /dev/null
+++ b/lint-checks/src/test/java/androidx/build/lint/Stubs.kt
@@ -0,0 +1,164 @@
+/*
+ * Copyright 2021 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.
+ */
+
+@file:Suppress("UnstableApiUsage")
+
+package androidx.build.lint
+
+import com.android.tools.lint.checks.infrastructure.TestFile
+import com.android.tools.lint.checks.infrastructure.TestFiles
+
+class Stubs {
+
+ companion object {
+
+ /* ktlint-disable max-line-length */
+
+ /**
+ * [TestFile] containing Keep.java from the annotation library.
+ */
+ val Keep = TestFiles.java(
+ """
+package androidx.annotation;
+
+public @interface Keep {
+}
+ """
+ )
+
+ val RunWith = TestFiles.kotlin(
+ """
+package org.junit.runner
+
+annotation class RunWith(val value: KClass<*>)
+ """
+ )
+
+ val JUnit4Runner = TestFiles.kotlin(
+ """
+package org.junit.runners
+
+class JUnit4
+ """
+ )
+
+ val ParameterizedRunner = TestFiles.kotlin(
+ """
+package org.junit.runners
+
+class Parameterized
+ """
+ )
+
+ val AndroidJUnit4Runner = TestFiles.kotlin(
+ """
+package androidx.test.ext.junit.runners
+
+class AndroidJUnit4
+ """
+ )
+
+ val TestSizeAnnotations = TestFiles.kotlin(
+ """
+package androidx.test.filters
+
+annotation class SmallTest
+annotation class MediumTest
+annotation class LargeTest
+ """
+ )
+
+ val TestAnnotation = TestFiles.kotlin(
+ """
+package org.junit
+
+annotation class Test
+ """
+ )
+
+ /**
+ * [TestFile] containing OptIn.kt from the Kotlin standard library.
+ *
+ * This is a workaround for the Kotlin standard library used by the Lint test harness not
+ * including the Experimental annotation by default.
+ */
+ val OptIn = TestFiles.kotlin(
+ """
+package kotlin
+
+import kotlin.annotation.AnnotationRetention.BINARY
+import kotlin.annotation.AnnotationRetention.SOURCE
+import kotlin.annotation.AnnotationTarget.*
+import kotlin.internal.RequireKotlin
+import kotlin.internal.RequireKotlinVersionKind
+import kotlin.reflect.KClass
+
+@Target(ANNOTATION_CLASS)
+@Retention(BINARY)
+@SinceKotlin("1.3")
+@RequireKotlin("1.3.70", versionKind = RequireKotlinVersionKind.COMPILER_VERSION)
+public annotation class RequiresOptIn(
+ val message: String = "",
+ val level: Level = Level.ERROR
+) {
+ public enum class Level {
+ WARNING,
+ ERROR,
+ }
+}
+
+@Target(
+ CLASS, PROPERTY, LOCAL_VARIABLE, VALUE_PARAMETER, CONSTRUCTOR, FUNCTION, PROPERTY_GETTER, PROPERTY_SETTER, EXPRESSION, FILE, TYPEALIAS
+)
+@Retention(SOURCE)
+@SinceKotlin("1.3")
+@RequireKotlin("1.3.70", versionKind = RequireKotlinVersionKind.COMPILER_VERSION)
+public annotation class OptIn(
+ vararg val markerClass: KClass<out Annotation>
+)
+ """
+ )
+
+ /**
+ * [TestFile] containing ChecksSdkIntAtLeast.java from the annotation library.
+ */
+ val ChecksSdkIntAtLeast = TestFiles.java(
+ """
+package androidx.annotation;
+
+import static java.lang.annotation.ElementType.FIELD;
+import static java.lang.annotation.ElementType.METHOD;
+import static java.lang.annotation.RetentionPolicy.CLASS;
+
+import java.lang.annotation.Documented;
+import java.lang.annotation.Retention;
+import java.lang.annotation.Target;
+
+@Documented
+@Retention(CLASS)
+@Target({METHOD, FIELD})
+public @interface ChecksSdkIntAtLeast {
+ int api() default -1;
+ String codename() default "";
+ int parameter() default -1;
+ int lambda() default -1;
+}
+ """
+ )
+
+ /* ktlint-enable max-line-length */
+ }
+}
diff --git a/lint-checks/src/test/java/androidx/build/lint/TestSizeAnnotationEnforcerTest.kt b/lint-checks/src/test/java/androidx/build/lint/TestSizeAnnotationEnforcerTest.kt
index 08933de3..fe6ce7d 100644
--- a/lint-checks/src/test/java/androidx/build/lint/TestSizeAnnotationEnforcerTest.kt
+++ b/lint-checks/src/test/java/androidx/build/lint/TestSizeAnnotationEnforcerTest.kt
@@ -19,7 +19,6 @@
package androidx.build.lint
import com.android.tools.lint.checks.infrastructure.LintDetectorTest
-import com.android.tools.lint.checks.infrastructure.LintDetectorTest.kotlin
import com.android.tools.lint.detector.api.Detector
import com.android.tools.lint.detector.api.Issue
import org.junit.Test
@@ -53,7 +52,7 @@
}
"""
).within("src/test"),
- *Stubs
+ *StubClasses
)
.run()
.expectClean()
@@ -85,7 +84,7 @@
}
"""
).within("src/test"),
- *Stubs
+ *StubClasses
)
.run()
.expect(
@@ -114,7 +113,7 @@
class Test
"""
).within("src/androidTest"),
- *Stubs
+ *StubClasses
)
.run()
.expect(
@@ -148,7 +147,7 @@
}
"""
).within("src/androidTest"),
- *Stubs
+ *StubClasses
)
.run()
.expectClean()
@@ -171,7 +170,7 @@
}
"""
).within("src/androidTest"),
- *Stubs
+ *StubClasses
)
.run()
.expectClean()
@@ -218,7 +217,7 @@
}
"""
).within("src/androidTest"),
- *Stubs
+ *StubClasses
)
.run()
.expectClean()
@@ -249,7 +248,7 @@
}
"""
).within("src/androidTest"),
- *Stubs
+ *StubClasses
)
.run()
.expect(
@@ -287,7 +286,7 @@
}
"""
).within("src/androidTest"),
- *Stubs
+ *StubClasses
)
.run()
.expect(
@@ -332,68 +331,18 @@
}
"""
).within("src/androidTest"),
- *Stubs
+ *StubClasses
)
.run()
.expectClean()
}
+
+ private val StubClasses = arrayOf(
+ Stubs.RunWith,
+ Stubs.JUnit4Runner,
+ Stubs.ParameterizedRunner,
+ Stubs.AndroidJUnit4Runner,
+ Stubs.TestSizeAnnotations,
+ Stubs.TestAnnotation
+ )
}
-
-private val RunWith = kotlin(
- """
- package org.junit.runner
-
- annotation class RunWith(val value: KClass<*>)
- """
-)
-
-private val JUnit4Runner = kotlin(
- """
- package org.junit.runners
-
- class JUnit4
- """
-)
-
-private val ParameterizedRunner = kotlin(
- """
- package org.junit.runners
-
- class Parameterized
- """
-)
-
-private val AndroidJUnit4Runner = kotlin(
- """
- package androidx.test.ext.junit.runners
-
- class AndroidJUnit4
- """
-)
-
-private val TestSizeAnnotations = kotlin(
- """
- package androidx.test.filters
-
- annotation class SmallTest
- annotation class MediumTest
- annotation class LargeTest
- """
-)
-
-private val TestAnnotation = kotlin(
- """
- package org.junit
-
- annotation class Test
- """
-)
-
-private val Stubs = arrayOf(
- RunWith,
- JUnit4Runner,
- ParameterizedRunner,
- AndroidJUnit4Runner,
- TestSizeAnnotations,
- TestAnnotation
-)
diff --git a/lint-checks/src/test/java/androidx/build/lint/TestUtils.kt b/lint-checks/src/test/java/androidx/build/lint/TestUtils.kt
deleted file mode 100644
index b863b8b..0000000
--- a/lint-checks/src/test/java/androidx/build/lint/TestUtils.kt
+++ /dev/null
@@ -1,50 +0,0 @@
-/*
- * Copyright 2021 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.
- */
-
-@file:Suppress("UnstableApiUsage")
-
-package androidx.build.lint
-
-import com.android.tools.lint.checks.infrastructure.ProjectDescription
-import com.android.tools.lint.checks.infrastructure.TestFile
-import com.android.tools.lint.checks.infrastructure.TestFiles
-import java.io.FileNotFoundException
-
-private class TestUtils
-
-fun project(): ProjectDescription = ProjectDescription()
-
-/**
- * Loads a [TestFile] from Java source code included in the JAR resources.
- */
-fun javaSample(className: String): TestFile = TestFiles.java(
- TestUtils::class.java.getResource(
- "/java/${className.replace('.', '/')}.java"
- )?.readText() ?: throw FileNotFoundException(
- "Could not find Java sources for $className in the integration test project"
- )
-)
-
-/**
- * Loads a [TestFile] from Kotlin source code included in the JAR resources.
- */
-fun ktSample(className: String): TestFile = TestFiles.kotlin(
- TestUtils::class.java.getResource(
- "/java/${className.replace('.', '/')}.kt"
- )?.readText() ?: throw FileNotFoundException(
- "Could not find Kotlin sources for $className in the integration test project"
- )
-)
\ No newline at end of file
diff --git a/media/media/build.gradle b/media/media/build.gradle
index 561b834..214cdab 100644
--- a/media/media/build.gradle
+++ b/media/media/build.gradle
@@ -26,6 +26,7 @@
dependencies {
api("androidx.core:core:1.3.0")
+ implementation("androidx.annotation:annotation:1.2.0")
implementation("androidx.collection:collection:1.1.0")
androidTestImplementation(ANDROIDX_TEST_EXT_JUNIT)
diff --git a/media/media/lint-baseline.xml b/media/media/lint-baseline.xml
index 1fe0359..2386b46 100644
--- a/media/media/lint-baseline.xml
+++ b/media/media/lint-baseline.xml
@@ -2,1135 +2,13 @@
<issues format="6" by="lint 7.0.0-alpha15" type="baseline" client="cli" name="Lint" variant="all" version="7.0.0-alpha15">
<issue
- id="ClassVerificationFailure"
- message="This call references a method added in API level 21; however, the containing class androidx.media.AudioAttributesImplApi21.Builder is reachable from earlier API levels and will fail run-time class verification."
- errorLine1=" mFwkBuilder = new AudioAttributes.Builder();"
- errorLine2=" ~~~~~~~~~~~~~~~~~~~~~~~~~~~">
- <location
- file="src/main/java/androidx/media/AudioAttributesImplApi21.java"
- line="133"
- column="27"/>
- </issue>
-
- <issue
- id="ClassVerificationFailure"
- message="This call references a method added in API level 21; however, the containing class androidx.media.AudioAttributesImplApi21.Builder is reachable from earlier API levels and will fail run-time class verification."
- errorLine1=" mFwkBuilder = new AudioAttributes.Builder((AudioAttributes) aa);"
- errorLine2=" ~~~~~~~~~~~~~~~~~~~~~~~~~~~">
- <location
- file="src/main/java/androidx/media/AudioAttributesImplApi21.java"
- line="137"
- column="27"/>
- </issue>
-
- <issue
- id="ClassVerificationFailure"
- message="This call references a method added in API level 21; however, the containing class androidx.media.AudioAttributesImplApi21.Builder is reachable from earlier API levels and will fail run-time class verification."
- errorLine1=" return new AudioAttributesImplApi21(mFwkBuilder.build());"
- errorLine2=" ~~~~~">
- <location
- file="src/main/java/androidx/media/AudioAttributesImplApi21.java"
- line="143"
- column="61"/>
- </issue>
-
- <issue
- id="ClassVerificationFailure"
- message="This call references a method added in API level 21; however, the containing class androidx.media.AudioAttributesImplApi21.Builder is reachable from earlier API levels and will fail run-time class verification."
- errorLine1=" mFwkBuilder.setUsage(usage);"
- errorLine2=" ~~~~~~~~">
- <location
- file="src/main/java/androidx/media/AudioAttributesImplApi21.java"
- line="153"
- column="25"/>
- </issue>
-
- <issue
- id="ClassVerificationFailure"
- message="This call references a method added in API level 21; however, the containing class androidx.media.AudioAttributesImplApi21.Builder is reachable from earlier API levels and will fail run-time class verification."
- errorLine1=" mFwkBuilder.setContentType(contentType);"
- errorLine2=" ~~~~~~~~~~~~~~">
- <location
- file="src/main/java/androidx/media/AudioAttributesImplApi21.java"
- line="160"
- column="25"/>
- </issue>
-
- <issue
- id="ClassVerificationFailure"
- message="This call references a method added in API level 21; however, the containing class androidx.media.AudioAttributesImplApi21.Builder is reachable from earlier API levels and will fail run-time class verification."
- errorLine1=" mFwkBuilder.setFlags(flags);"
- errorLine2=" ~~~~~~~~">
- <location
- file="src/main/java/androidx/media/AudioAttributesImplApi21.java"
- line="167"
- column="25"/>
- </issue>
-
- <issue
- id="ClassVerificationFailure"
- message="This call references a method added in API level 21; however, the containing class androidx.media.AudioAttributesImplApi21.Builder is reachable from earlier API levels and will fail run-time class verification."
- errorLine1=" mFwkBuilder.setLegacyStreamType(streamType);"
- errorLine2=" ~~~~~~~~~~~~~~~~~~~">
- <location
- file="src/main/java/androidx/media/AudioAttributesImplApi21.java"
- line="174"
- column="25"/>
- </issue>
-
- <issue
- id="ClassVerificationFailure"
- message="This call references a method added in API level 21; however, the containing class androidx.media.AudioAttributesImplApi26.Builder is reachable from earlier API levels and will fail run-time class verification."
- errorLine1=" return new AudioAttributesImplApi26(mFwkBuilder.build());"
- errorLine2=" ~~~~~">
- <location
- file="src/main/java/androidx/media/AudioAttributesImplApi26.java"
- line="65"
- column="61"/>
- </issue>
-
- <issue
- id="ClassVerificationFailure"
- message="This call references a method added in API level 21; however, the containing class androidx.media.AudioAttributesImplApi26.Builder is reachable from earlier API levels and will fail run-time class verification."
- errorLine1=" mFwkBuilder.setUsage(usage);"
- errorLine2=" ~~~~~~~~">
- <location
- file="src/main/java/androidx/media/AudioAttributesImplApi26.java"
- line="71"
- column="25"/>
- </issue>
-
- <issue
- id="ClassVerificationFailure"
- message="This call references a method added in API level 26; however, the containing class androidx.media.AudioFocusRequestCompat is reachable from earlier API levels and will fail run-time class verification."
- errorLine1=" new AudioFocusRequest.Builder(mFocusGain)"
- errorLine2=" ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~">
- <location
- file="src/main/java/androidx/media/AudioFocusRequestCompat.java"
- line="84"
- column="21"/>
- </issue>
-
- <issue
- id="ClassVerificationFailure"
- message="This call references a method added in API level 26; however, the containing class androidx.media.AudioFocusRequestCompat is reachable from earlier API levels and will fail run-time class verification."
- errorLine1=" .setAudioAttributes(getAudioAttributes())"
- errorLine2=" ~~~~~~~~~~~~~~~~~~">
- <location
- file="src/main/java/androidx/media/AudioFocusRequestCompat.java"
- line="85"
- column="30"/>
- </issue>
-
- <issue
- id="ClassVerificationFailure"
- message="This call references a method added in API level 26; however, the containing class androidx.media.AudioFocusRequestCompat is reachable from earlier API levels and will fail run-time class verification."
- errorLine1=" .setWillPauseWhenDucked(mPauseOnDuck)"
- errorLine2=" ~~~~~~~~~~~~~~~~~~~~~~">
- <location
- file="src/main/java/androidx/media/AudioFocusRequestCompat.java"
- line="86"
- column="30"/>
- </issue>
-
- <issue
- id="ClassVerificationFailure"
- message="This call references a method added in API level 26; however, the containing class androidx.media.AudioFocusRequestCompat is reachable from earlier API levels and will fail run-time class verification."
- errorLine1=" .setOnAudioFocusChangeListener("
- errorLine2=" ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~">
- <location
- file="src/main/java/androidx/media/AudioFocusRequestCompat.java"
- line="87"
- column="30"/>
- </issue>
-
- <issue
- id="ClassVerificationFailure"
- message="This call references a method added in API level 26; however, the containing class androidx.media.AudioFocusRequestCompat is reachable from earlier API levels and will fail run-time class verification."
- errorLine1=" .build();"
- errorLine2=" ~~~~~">
- <location
- file="src/main/java/androidx/media/AudioFocusRequestCompat.java"
- line="89"
- column="30"/>
- </issue>
-
- <issue
- id="ClassVerificationFailure"
- message="This call references a method added in API level 26; however, the containing class androidx.media.AudioManagerCompat is reachable from earlier API levels and will fail run-time class verification."
- errorLine1=" return audioManager.requestAudioFocus(focusRequest.getAudioFocusRequest());"
- errorLine2=" ~~~~~~~~~~~~~~~~~">
- <location
- file="src/main/java/androidx/media/AudioManagerCompat.java"
- line="91"
- column="33"/>
- </issue>
-
- <issue
- id="ClassVerificationFailure"
- message="This call references a method added in API level 26; however, the containing class androidx.media.AudioManagerCompat is reachable from earlier API levels and will fail run-time class verification."
- errorLine1=" return audioManager.abandonAudioFocusRequest(focusRequest.getAudioFocusRequest());"
- errorLine2=" ~~~~~~~~~~~~~~~~~~~~~~~~">
- <location
- file="src/main/java/androidx/media/AudioManagerCompat.java"
- line="120"
- column="33"/>
- </issue>
-
- <issue
- id="ClassVerificationFailure"
- message="This call references a method added in API level 28; however, the containing class androidx.media.AudioManagerCompat is reachable from earlier API levels and will fail run-time class verification."
- errorLine1=" return audioManager.getStreamMinVolume(streamType);"
- errorLine2=" ~~~~~~~~~~~~~~~~~~">
- <location
- file="src/main/java/androidx/media/AudioManagerCompat.java"
- line="148"
- column="33"/>
- </issue>
-
- <issue
- id="ClassVerificationFailure"
- message="This call references a method added in API level 21; however, the containing class android.support.v4.media.MediaBrowserCompat.MediaItem is reachable from earlier API levels and will fail run-time class verification."
- errorLine1=" int flags = itemFwk.getFlags();"
- errorLine2=" ~~~~~~~~">
- <location
- file="src/main/java/android/support/v4/media/MediaBrowserCompat.java"
- line="499"
- column="33"/>
- </issue>
-
- <issue
- id="ClassVerificationFailure"
- message="This call references a method added in API level 21; however, the containing class android.support.v4.media.MediaBrowserCompat.MediaItem is reachable from earlier API levels and will fail run-time class verification."
- errorLine1=" MediaDescriptionCompat.fromMediaDescription(itemFwk.getDescription());"
- errorLine2=" ~~~~~~~~~~~~~~">
- <location
- file="src/main/java/android/support/v4/media/MediaBrowserCompat.java"
- line="501"
- column="73"/>
- </issue>
-
- <issue
- id="ClassVerificationFailure"
- message="This call references a method added in API level 21; however, the containing class null is reachable from earlier API levels and will fail run-time class verification."
- errorLine1=" mServiceFwk.setSessionToken((MediaSession.Token) token.getToken());"
- errorLine2=" ~~~~~~~~~~~~~~~">
- <location
- file="src/main/java/androidx/media/MediaBrowserServiceCompat.java"
- line="335"
- column="33"/>
- </issue>
-
- <issue
- id="ClassVerificationFailure"
- message="This call references a method added in API level 21; however, the containing class androidx.media.MediaBrowserServiceCompat.MediaBrowserServiceImplApi21.MediaBrowserServiceApi21 is reachable from earlier API levels and will fail run-time class verification."
- errorLine1=" return browserRootCompat == null ? null : new MediaBrowserService.BrowserRoot("
- errorLine2=" ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~">
- <location
- file="src/main/java/androidx/media/MediaBrowserServiceCompat.java"
- line="506"
- column="59"/>
- </issue>
-
- <issue
- id="ClassVerificationFailure"
- message="This call references a method added in API level 26; however, the containing class androidx.media.session.MediaButtonReceiver is reachable from earlier API levels and will fail run-time class verification."
- errorLine1=" context.startForegroundService(intent);"
- errorLine2=" ~~~~~~~~~~~~~~~~~~~~~~">
- <location
- file="src/main/java/androidx/media/session/MediaButtonReceiver.java"
- line="301"
- column="21"/>
- </issue>
-
- <issue
- id="ClassVerificationFailure"
- message="This call references a method added in API level 21; however, the containing class android.support.v4.media.session.MediaControllerCompat is reachable from earlier API levels and will fail run-time class verification."
- errorLine1=" controllerFwk = new MediaController(activity, (MediaSession.Token) sessionTokenObj);"
- errorLine2=" ~~~~~~~~~~~~~~~~~~~">
- <location
- file="src/main/java/android/support/v4/media/session/MediaControllerCompat.java"
- line="169"
- column="33"/>
- </issue>
-
- <issue
- id="ClassVerificationFailure"
- message="This call references a method added in API level 21; however, the containing class android.support.v4.media.session.MediaControllerCompat is reachable from earlier API levels and will fail run-time class verification."
- errorLine1=" activity.setMediaController(controllerFwk);"
- errorLine2=" ~~~~~~~~~~~~~~~~~~">
- <location
- file="src/main/java/android/support/v4/media/session/MediaControllerCompat.java"
- line="171"
- column="22"/>
- </issue>
-
- <issue
- id="ClassVerificationFailure"
- message="This call references a method added in API level 21; however, the containing class android.support.v4.media.session.MediaControllerCompat is reachable from earlier API levels and will fail run-time class verification."
- errorLine1=" MediaController controllerFwk = activity.getMediaController();"
- errorLine2=" ~~~~~~~~~~~~~~~~~~">
- <location
- file="src/main/java/android/support/v4/media/session/MediaControllerCompat.java"
- line="192"
- column="54"/>
- </issue>
-
- <issue
- id="ClassVerificationFailure"
- message="This call references a method added in API level 21; however, the containing class android.support.v4.media.session.MediaControllerCompat is reachable from earlier API levels and will fail run-time class verification."
- errorLine1=" MediaSession.Token sessionTokenFwk = controllerFwk.getSessionToken();"
- errorLine2=" ~~~~~~~~~~~~~~~">
- <location
- file="src/main/java/android/support/v4/media/session/MediaControllerCompat.java"
- line="196"
- column="64"/>
- </issue>
-
- <issue
- id="ClassVerificationFailure"
- message="This call references a method added in API level 29; however, the containing class android.support.v4.media.session.MediaControllerCompat.MediaControllerImplApi21 is reachable from earlier API levels and will fail run-time class verification."
- errorLine1=" mSessionInfo = mControllerFwk.getSessionInfo();"
- errorLine2=" ~~~~~~~~~~~~~~">
- <location
- file="src/main/java/android/support/v4/media/session/MediaControllerCompat.java"
- line="2270"
- column="47"/>
- </issue>
-
- <issue
- id="ClassVerificationFailure"
- message="This call references a method added in API level 24; however, the containing class android.support.v4.media.session.MediaControllerCompat.TransportControlsApi21 is reachable from earlier API levels and will fail run-time class verification."
- errorLine1=" mControlsFwk.prepare();"
- errorLine2=" ~~~~~~~">
- <location
- file="src/main/java/android/support/v4/media/session/MediaControllerCompat.java"
- line="2394"
- column="30"/>
- </issue>
-
- <issue
- id="ClassVerificationFailure"
- message="This call references a method added in API level 24; however, the containing class android.support.v4.media.session.MediaControllerCompat.TransportControlsApi21 is reachable from earlier API levels and will fail run-time class verification."
- errorLine1=" mControlsFwk.prepareFromMediaId(mediaId, extras);"
- errorLine2=" ~~~~~~~~~~~~~~~~~~">
- <location
- file="src/main/java/android/support/v4/media/session/MediaControllerCompat.java"
- line="2403"
- column="30"/>
- </issue>
-
- <issue
- id="ClassVerificationFailure"
- message="This call references a method added in API level 24; however, the containing class android.support.v4.media.session.MediaControllerCompat.TransportControlsApi21 is reachable from earlier API levels and will fail run-time class verification."
- errorLine1=" mControlsFwk.prepareFromSearch(query, extras);"
- errorLine2=" ~~~~~~~~~~~~~~~~~">
- <location
- file="src/main/java/android/support/v4/media/session/MediaControllerCompat.java"
- line="2415"
- column="30"/>
- </issue>
-
- <issue
- id="ClassVerificationFailure"
- message="This call references a method added in API level 24; however, the containing class android.support.v4.media.session.MediaControllerCompat.TransportControlsApi21 is reachable from earlier API levels and will fail run-time class verification."
- errorLine1=" mControlsFwk.prepareFromUri(uri, extras);"
- errorLine2=" ~~~~~~~~~~~~~~">
- <location
- file="src/main/java/android/support/v4/media/session/MediaControllerCompat.java"
- line="2427"
- column="30"/>
- </issue>
-
- <issue
- id="ClassVerificationFailure"
- message="This call references a method added in API level 29; however, the containing class android.support.v4.media.session.MediaControllerCompat.TransportControlsApi21 is reachable from earlier API levels and will fail run-time class verification."
- errorLine1=" mControlsFwk.setPlaybackSpeed(speed);"
- errorLine2=" ~~~~~~~~~~~~~~~~">
- <location
- file="src/main/java/android/support/v4/media/session/MediaControllerCompat.java"
- line="2495"
- column="30"/>
- </issue>
-
- <issue
- id="ClassVerificationFailure"
- message="This call references a method added in API level 23; however, the containing class android.support.v4.media.session.MediaControllerCompat.TransportControlsApi21 is reachable from earlier API levels and will fail run-time class verification."
- errorLine1=" mControlsFwk.playFromUri(uri, extras);"
- errorLine2=" ~~~~~~~~~~~">
- <location
- file="src/main/java/android/support/v4/media/session/MediaControllerCompat.java"
- line="2537"
- column="30"/>
- </issue>
-
- <issue
- id="ClassVerificationFailure"
- message="This call references a method added in API level 21; however, the containing class android.support.v4.media.MediaDescriptionCompat is reachable from earlier API levels and will fail run-time class verification."
- errorLine1=" MediaDescription.Builder bob = new MediaDescription.Builder();"
- errorLine2=" ~~~~~~~~~~~~~~~~~~~~~~~~~~~~">
- <location
- file="src/main/java/android/support/v4/media/MediaDescriptionCompat.java"
- line="339"
- column="40"/>
- </issue>
-
- <issue
- id="ClassVerificationFailure"
- message="This call references a method added in API level 21; however, the containing class android.support.v4.media.MediaDescriptionCompat is reachable from earlier API levels and will fail run-time class verification."
- errorLine1=" bob.setMediaId(mMediaId);"
- errorLine2=" ~~~~~~~~~~">
- <location
- file="src/main/java/android/support/v4/media/MediaDescriptionCompat.java"
- line="340"
- column="13"/>
- </issue>
-
- <issue
- id="ClassVerificationFailure"
- message="This call references a method added in API level 21; however, the containing class android.support.v4.media.MediaDescriptionCompat is reachable from earlier API levels and will fail run-time class verification."
- errorLine1=" bob.setTitle(mTitle);"
- errorLine2=" ~~~~~~~~">
- <location
- file="src/main/java/android/support/v4/media/MediaDescriptionCompat.java"
- line="341"
- column="13"/>
- </issue>
-
- <issue
- id="ClassVerificationFailure"
- message="This call references a method added in API level 21; however, the containing class android.support.v4.media.MediaDescriptionCompat is reachable from earlier API levels and will fail run-time class verification."
- errorLine1=" bob.setSubtitle(mSubtitle);"
- errorLine2=" ~~~~~~~~~~~">
- <location
- file="src/main/java/android/support/v4/media/MediaDescriptionCompat.java"
- line="342"
- column="13"/>
- </issue>
-
- <issue
- id="ClassVerificationFailure"
- message="This call references a method added in API level 21; however, the containing class android.support.v4.media.MediaDescriptionCompat is reachable from earlier API levels and will fail run-time class verification."
- errorLine1=" bob.setDescription(mDescription);"
- errorLine2=" ~~~~~~~~~~~~~~">
- <location
- file="src/main/java/android/support/v4/media/MediaDescriptionCompat.java"
- line="343"
- column="13"/>
- </issue>
-
- <issue
- id="ClassVerificationFailure"
- message="This call references a method added in API level 21; however, the containing class android.support.v4.media.MediaDescriptionCompat is reachable from earlier API levels and will fail run-time class verification."
- errorLine1=" bob.setIconBitmap(mIcon);"
- errorLine2=" ~~~~~~~~~~~~~">
- <location
- file="src/main/java/android/support/v4/media/MediaDescriptionCompat.java"
- line="344"
- column="13"/>
- </issue>
-
- <issue
- id="ClassVerificationFailure"
- message="This call references a method added in API level 21; however, the containing class android.support.v4.media.MediaDescriptionCompat is reachable from earlier API levels and will fail run-time class verification."
- errorLine1=" bob.setIconUri(mIconUri);"
- errorLine2=" ~~~~~~~~~~">
- <location
- file="src/main/java/android/support/v4/media/MediaDescriptionCompat.java"
- line="345"
- column="13"/>
- </issue>
-
- <issue
- id="ClassVerificationFailure"
- message="This call references a method added in API level 21; however, the containing class android.support.v4.media.MediaDescriptionCompat is reachable from earlier API levels and will fail run-time class verification."
- errorLine1=" bob.setExtras(extras);"
- errorLine2=" ~~~~~~~~~">
- <location
- file="src/main/java/android/support/v4/media/MediaDescriptionCompat.java"
- line="358"
- column="13"/>
- </issue>
-
- <issue
- id="ClassVerificationFailure"
- message="This call references a method added in API level 23; however, the containing class android.support.v4.media.MediaDescriptionCompat is reachable from earlier API levels and will fail run-time class verification."
- errorLine1=" bob.setMediaUri(mMediaUri);"
- errorLine2=" ~~~~~~~~~~~">
- <location
- file="src/main/java/android/support/v4/media/MediaDescriptionCompat.java"
- line="360"
- column="17"/>
- </issue>
-
- <issue
- id="ClassVerificationFailure"
- message="This call references a method added in API level 21; however, the containing class android.support.v4.media.MediaDescriptionCompat is reachable from earlier API levels and will fail run-time class verification."
- errorLine1=" mDescriptionFwk = bob.build();"
- errorLine2=" ~~~~~">
- <location
- file="src/main/java/android/support/v4/media/MediaDescriptionCompat.java"
- line="362"
- column="31"/>
- </issue>
-
- <issue
- id="ClassVerificationFailure"
- message="This call references a method added in API level 21; however, the containing class android.support.v4.media.MediaDescriptionCompat is reachable from earlier API levels and will fail run-time class verification."
- errorLine1=" bob.setMediaId(description.getMediaId());"
- errorLine2=" ~~~~~~~~~~">
- <location
- file="src/main/java/android/support/v4/media/MediaDescriptionCompat.java"
- line="383"
- column="40"/>
- </issue>
-
- <issue
- id="ClassVerificationFailure"
- message="This call references a method added in API level 21; however, the containing class android.support.v4.media.MediaDescriptionCompat is reachable from earlier API levels and will fail run-time class verification."
- errorLine1=" bob.setTitle(description.getTitle());"
- errorLine2=" ~~~~~~~~">
- <location
- file="src/main/java/android/support/v4/media/MediaDescriptionCompat.java"
- line="384"
- column="38"/>
- </issue>
-
- <issue
- id="ClassVerificationFailure"
- message="This call references a method added in API level 21; however, the containing class android.support.v4.media.MediaDescriptionCompat is reachable from earlier API levels and will fail run-time class verification."
- errorLine1=" bob.setSubtitle(description.getSubtitle());"
- errorLine2=" ~~~~~~~~~~~">
- <location
- file="src/main/java/android/support/v4/media/MediaDescriptionCompat.java"
- line="385"
- column="41"/>
- </issue>
-
- <issue
- id="ClassVerificationFailure"
- message="This call references a method added in API level 21; however, the containing class android.support.v4.media.MediaDescriptionCompat is reachable from earlier API levels and will fail run-time class verification."
- errorLine1=" bob.setDescription(description.getDescription());"
- errorLine2=" ~~~~~~~~~~~~~~">
- <location
- file="src/main/java/android/support/v4/media/MediaDescriptionCompat.java"
- line="386"
- column="44"/>
- </issue>
-
- <issue
- id="ClassVerificationFailure"
- message="This call references a method added in API level 21; however, the containing class android.support.v4.media.MediaDescriptionCompat is reachable from earlier API levels and will fail run-time class verification."
- errorLine1=" bob.setIconBitmap(description.getIconBitmap());"
- errorLine2=" ~~~~~~~~~~~~~">
- <location
- file="src/main/java/android/support/v4/media/MediaDescriptionCompat.java"
- line="387"
- column="43"/>
- </issue>
-
- <issue
- id="ClassVerificationFailure"
- message="This call references a method added in API level 21; however, the containing class android.support.v4.media.MediaDescriptionCompat is reachable from earlier API levels and will fail run-time class verification."
- errorLine1=" bob.setIconUri(description.getIconUri());"
- errorLine2=" ~~~~~~~~~~">
- <location
- file="src/main/java/android/support/v4/media/MediaDescriptionCompat.java"
- line="388"
- column="40"/>
- </issue>
-
- <issue
- id="ClassVerificationFailure"
- message="This call references a method added in API level 21; however, the containing class android.support.v4.media.MediaDescriptionCompat is reachable from earlier API levels and will fail run-time class verification."
- errorLine1=" Bundle extras = description.getExtras();"
- errorLine2=" ~~~~~~~~~">
- <location
- file="src/main/java/android/support/v4/media/MediaDescriptionCompat.java"
- line="389"
- column="41"/>
- </issue>
-
- <issue
- id="ClassVerificationFailure"
- message="This call references a method added in API level 23; however, the containing class android.support.v4.media.MediaDescriptionCompat is reachable from earlier API levels and will fail run-time class verification."
- errorLine1=" bob.setMediaUri(description.getMediaUri());"
- errorLine2=" ~~~~~~~~~~~">
- <location
- file="src/main/java/android/support/v4/media/MediaDescriptionCompat.java"
- line="415"
- column="45"/>
- </issue>
-
- <issue
- id="ClassVerificationFailure"
- message="This call references a method added in API level 29; however, the containing class android.support.v4.media.session.MediaSessionCompat is reachable from earlier API levels and will fail run-time class verification."
- errorLine1=" return new MediaSession(context, tag, sessionInfo);"
- errorLine2=" ~~~~~~~~~~~~~~~~">
- <location
- file="src/main/java/android/support/v4/media/session/MediaSessionCompat.java"
- line="613"
- column="20"/>
- </issue>
-
- <issue
- id="ClassVerificationFailure"
- message="This call references a method added in API level 21; however, the containing class android.support.v4.media.session.MediaSessionCompat is reachable from earlier API levels and will fail run-time class verification."
- errorLine1=" return new MediaSession(context, tag);"
- errorLine2=" ~~~~~~~~~~~~~~~~">
- <location
- file="src/main/java/android/support/v4/media/session/MediaSessionCompat.java"
- line="615"
- column="20"/>
- </issue>
-
- <issue
- id="ClassVerificationFailure"
- message="This call references a method added in API level 21; however, the containing class android.support.v4.media.session.MediaSessionCompat.QueueItem is reachable from earlier API levels and will fail run-time class verification."
- errorLine1=" mItemFwk = new MediaSession.QueueItem("
- errorLine2=" ~~~~~~~~~~~~~~~~~~~~~~~~~~">
- <location
- file="src/main/java/android/support/v4/media/session/MediaSessionCompat.java"
- line="2231"
- column="24"/>
- </issue>
-
- <issue
- id="ClassVerificationFailure"
- message="This call references a method added in API level 21; however, the containing class android.support.v4.media.session.MediaSessionCompat.QueueItem is reachable from earlier API levels and will fail run-time class verification."
- errorLine1=" Object descriptionObj = queueItemObj.getDescription();"
- errorLine2=" ~~~~~~~~~~~~~~">
- <location
- file="src/main/java/android/support/v4/media/session/MediaSessionCompat.java"
- line="2252"
- column="50"/>
- </issue>
-
- <issue
- id="ClassVerificationFailure"
- message="This call references a method added in API level 21; however, the containing class android.support.v4.media.session.MediaSessionCompat.QueueItem is reachable from earlier API levels and will fail run-time class verification."
- errorLine1=" long id = queueItemObj.getQueueId();"
- errorLine2=" ~~~~~~~~~~">
- <location
- file="src/main/java/android/support/v4/media/session/MediaSessionCompat.java"
- line="2255"
- column="36"/>
- </issue>
-
- <issue
- id="ClassVerificationFailure"
- message="This call references a method added in API level 22; however, the containing class android.support.v4.media.session.MediaSessionCompat.MediaSessionImplApi21 is reachable from earlier API levels and will fail run-time class verification."
- errorLine1=" mSessionFwk.setRatingType(type);"
- errorLine2=" ~~~~~~~~~~~~~">
- <location
- file="src/main/java/android/support/v4/media/session/MediaSessionCompat.java"
- line="3974"
- column="29"/>
- </issue>
-
- <issue
- id="ClassVerificationFailure"
- message="This call references a method added in API level 16; however, the containing class androidx.media.app.NotificationCompat.MediaStyle is reachable from earlier API levels and will fail run-time class verification."
- errorLine1=" builder.getBuilder().setStyle("
- errorLine2=" ~~~~~~~~">
- <location
- file="src/main/java/androidx/media/app/NotificationCompat.java"
- line="211"
- column="38"/>
- </issue>
-
- <issue
- id="ClassVerificationFailure"
- message="This call references a method added in API level 21; however, the containing class androidx.media.app.NotificationCompat.MediaStyle is reachable from earlier API levels and will fail run-time class verification."
- errorLine1=" fillInMediaStyle(new Notification.MediaStyle()));"
- errorLine2=" ~~~~~~~~~~~~~~~~~~~~~~~~~~~">
- <location
- file="src/main/java/androidx/media/app/NotificationCompat.java"
- line="212"
- column="42"/>
- </issue>
-
- <issue
- id="ClassVerificationFailure"
- message="This call references a method added in API level 21; however, the containing class androidx.media.app.NotificationCompat.MediaStyle is reachable from earlier API levels and will fail run-time class verification."
- errorLine1=" style.setShowActionsInCompactView(mActionsToShowInCompact);"
- errorLine2=" ~~~~~~~~~~~~~~~~~~~~~~~~~~~">
- <location
- file="src/main/java/androidx/media/app/NotificationCompat.java"
- line="221"
- column="23"/>
- </issue>
-
- <issue
- id="ClassVerificationFailure"
- message="This call references a method added in API level 21; however, the containing class androidx.media.app.NotificationCompat.MediaStyle is reachable from earlier API levels and will fail run-time class verification."
- errorLine1=" style.setMediaSession((MediaSession.Token) mToken.getToken());"
- errorLine2=" ~~~~~~~~~~~~~~~">
- <location
- file="src/main/java/androidx/media/app/NotificationCompat.java"
- line="224"
- column="23"/>
- </issue>
-
- <issue
- id="ClassVerificationFailure"
- message="This call references a method added in API level 15; however, the containing class androidx.media.app.NotificationCompat.MediaStyle is reachable from earlier API levels and will fail run-time class verification."
- errorLine1=" button.setContentDescription(R.id.action0, action.getTitle());"
- errorLine2=" ~~~~~~~~~~~~~~~~~~~~~">
- <location
- file="src/main/java/androidx/media/app/NotificationCompat.java"
- line="288"
- column="24"/>
- </issue>
-
- <issue
- id="ClassVerificationFailure"
- message="This call references a method added in API level 16; however, the containing class androidx.media.app.NotificationCompat.DecoratedMediaCustomViewStyle is reachable from earlier API levels and will fail run-time class verification."
- errorLine1=" builder.getBuilder().setStyle("
- errorLine2=" ~~~~~~~~">
- <location
- file="src/main/java/androidx/media/app/NotificationCompat.java"
- line="389"
- column="38"/>
- </issue>
-
- <issue
- id="ClassVerificationFailure"
- message="This call references a method added in API level 24; however, the containing class androidx.media.app.NotificationCompat.DecoratedMediaCustomViewStyle is reachable from earlier API levels and will fail run-time class verification."
- errorLine1=" fillInMediaStyle(new Notification.DecoratedMediaCustomViewStyle()));"
- errorLine2=" ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~">
- <location
- file="src/main/java/androidx/media/app/NotificationCompat.java"
- line="390"
- column="42"/>
- </issue>
-
- <issue
- id="ClassVerificationFailure"
- message="This call references a method added in API level 21; however, the containing class android.support.v4.media.session.PlaybackStateCompat is reachable from earlier API levels and will fail run-time class verification."
- errorLine1=" List<PlaybackState.CustomAction> customActionFwks = stateFwk.getCustomActions();"
- errorLine2=" ~~~~~~~~~~~~~~~~">
- <location
- file="src/main/java/android/support/v4/media/session/PlaybackStateCompat.java"
- line="809"
- column="74"/>
- </issue>
-
- <issue
- id="ClassVerificationFailure"
- message="This call references a method added in API level 22; however, the containing class android.support.v4.media.session.PlaybackStateCompat is reachable from earlier API levels and will fail run-time class verification."
- errorLine1=" extras = stateFwk.getExtras();"
- errorLine2=" ~~~~~~~~~">
- <location
- file="src/main/java/android/support/v4/media/session/PlaybackStateCompat.java"
- line="819"
- column="35"/>
- </issue>
-
- <issue
- id="ClassVerificationFailure"
- message="This call references a method added in API level 21; however, the containing class android.support.v4.media.session.PlaybackStateCompat is reachable from earlier API levels and will fail run-time class verification."
- errorLine1=" stateFwk.getState(),"
- errorLine2=" ~~~~~~~~">
- <location
- file="src/main/java/android/support/v4/media/session/PlaybackStateCompat.java"
- line="825"
- column="30"/>
- </issue>
-
- <issue
- id="ClassVerificationFailure"
- message="This call references a method added in API level 21; however, the containing class android.support.v4.media.session.PlaybackStateCompat is reachable from earlier API levels and will fail run-time class verification."
- errorLine1=" stateFwk.getPosition(),"
- errorLine2=" ~~~~~~~~~~~">
- <location
- file="src/main/java/android/support/v4/media/session/PlaybackStateCompat.java"
- line="826"
- column="30"/>
- </issue>
-
- <issue
- id="ClassVerificationFailure"
- message="This call references a method added in API level 21; however, the containing class android.support.v4.media.session.PlaybackStateCompat is reachable from earlier API levels and will fail run-time class verification."
- errorLine1=" stateFwk.getBufferedPosition(),"
- errorLine2=" ~~~~~~~~~~~~~~~~~~~">
- <location
- file="src/main/java/android/support/v4/media/session/PlaybackStateCompat.java"
- line="827"
- column="30"/>
- </issue>
-
- <issue
- id="ClassVerificationFailure"
- message="This call references a method added in API level 21; however, the containing class android.support.v4.media.session.PlaybackStateCompat is reachable from earlier API levels and will fail run-time class verification."
- errorLine1=" stateFwk.getPlaybackSpeed(),"
- errorLine2=" ~~~~~~~~~~~~~~~~">
- <location
- file="src/main/java/android/support/v4/media/session/PlaybackStateCompat.java"
- line="828"
- column="30"/>
- </issue>
-
- <issue
- id="ClassVerificationFailure"
- message="This call references a method added in API level 21; however, the containing class android.support.v4.media.session.PlaybackStateCompat is reachable from earlier API levels and will fail run-time class verification."
- errorLine1=" stateFwk.getActions(),"
- errorLine2=" ~~~~~~~~~~">
- <location
- file="src/main/java/android/support/v4/media/session/PlaybackStateCompat.java"
- line="829"
- column="30"/>
- </issue>
-
- <issue
- id="ClassVerificationFailure"
- message="This call references a method added in API level 21; however, the containing class android.support.v4.media.session.PlaybackStateCompat is reachable from earlier API levels and will fail run-time class verification."
- errorLine1=" stateFwk.getErrorMessage(),"
- errorLine2=" ~~~~~~~~~~~~~~~">
- <location
- file="src/main/java/android/support/v4/media/session/PlaybackStateCompat.java"
- line="831"
- column="30"/>
- </issue>
-
- <issue
- id="ClassVerificationFailure"
- message="This call references a method added in API level 21; however, the containing class android.support.v4.media.session.PlaybackStateCompat is reachable from earlier API levels and will fail run-time class verification."
- errorLine1=" stateFwk.getLastPositionUpdateTime(),"
- errorLine2=" ~~~~~~~~~~~~~~~~~~~~~~~~~">
- <location
- file="src/main/java/android/support/v4/media/session/PlaybackStateCompat.java"
- line="832"
- column="30"/>
- </issue>
-
- <issue
- id="ClassVerificationFailure"
- message="This call references a method added in API level 21; however, the containing class android.support.v4.media.session.PlaybackStateCompat is reachable from earlier API levels and will fail run-time class verification."
- errorLine1=" stateFwk.getActiveQueueItemId(),"
- errorLine2=" ~~~~~~~~~~~~~~~~~~~~">
- <location
- file="src/main/java/android/support/v4/media/session/PlaybackStateCompat.java"
- line="834"
- column="30"/>
- </issue>
-
- <issue
- id="ClassVerificationFailure"
- message="This call references a method added in API level 21; however, the containing class android.support.v4.media.session.PlaybackStateCompat is reachable from earlier API levels and will fail run-time class verification."
- errorLine1=" PlaybackState.Builder builder = new PlaybackState.Builder();"
- errorLine2=" ~~~~~~~~~~~~~~~~~~~~~~~~~">
- <location
- file="src/main/java/android/support/v4/media/session/PlaybackStateCompat.java"
- line="853"
- column="45"/>
- </issue>
-
- <issue
- id="ClassVerificationFailure"
- message="This call references a method added in API level 21; however, the containing class android.support.v4.media.session.PlaybackStateCompat is reachable from earlier API levels and will fail run-time class verification."
- errorLine1=" builder.setState(mState, mPosition, mSpeed, mUpdateTime);"
- errorLine2=" ~~~~~~~~">
- <location
- file="src/main/java/android/support/v4/media/session/PlaybackStateCompat.java"
- line="854"
- column="21"/>
- </issue>
-
- <issue
- id="ClassVerificationFailure"
- message="This call references a method added in API level 21; however, the containing class android.support.v4.media.session.PlaybackStateCompat is reachable from earlier API levels and will fail run-time class verification."
- errorLine1=" builder.setBufferedPosition(mBufferedPosition);"
- errorLine2=" ~~~~~~~~~~~~~~~~~~~">
- <location
- file="src/main/java/android/support/v4/media/session/PlaybackStateCompat.java"
- line="855"
- column="21"/>
- </issue>
-
- <issue
- id="ClassVerificationFailure"
- message="This call references a method added in API level 21; however, the containing class android.support.v4.media.session.PlaybackStateCompat is reachable from earlier API levels and will fail run-time class verification."
- errorLine1=" builder.setActions(mActions);"
- errorLine2=" ~~~~~~~~~~">
- <location
- file="src/main/java/android/support/v4/media/session/PlaybackStateCompat.java"
- line="856"
- column="21"/>
- </issue>
-
- <issue
- id="ClassVerificationFailure"
- message="This call references a method added in API level 21; however, the containing class android.support.v4.media.session.PlaybackStateCompat is reachable from earlier API levels and will fail run-time class verification."
- errorLine1=" builder.setErrorMessage(mErrorMessage);"
- errorLine2=" ~~~~~~~~~~~~~~~">
- <location
- file="src/main/java/android/support/v4/media/session/PlaybackStateCompat.java"
- line="857"
- column="21"/>
- </issue>
-
- <issue
- id="ClassVerificationFailure"
- message="This call references a method added in API level 21; however, the containing class android.support.v4.media.session.PlaybackStateCompat is reachable from earlier API levels and will fail run-time class verification."
- errorLine1=" builder.addCustomAction("
- errorLine2=" ~~~~~~~~~~~~~~~">
- <location
- file="src/main/java/android/support/v4/media/session/PlaybackStateCompat.java"
- line="859"
- column="25"/>
- </issue>
-
- <issue
- id="ClassVerificationFailure"
- message="This call references a method added in API level 21; however, the containing class android.support.v4.media.session.PlaybackStateCompat is reachable from earlier API levels and will fail run-time class verification."
- errorLine1=" builder.setActiveQueueItemId(mActiveItemId);"
- errorLine2=" ~~~~~~~~~~~~~~~~~~~~">
- <location
- file="src/main/java/android/support/v4/media/session/PlaybackStateCompat.java"
- line="862"
- column="21"/>
- </issue>
-
- <issue
- id="ClassVerificationFailure"
- message="This call references a method added in API level 22; however, the containing class android.support.v4.media.session.PlaybackStateCompat is reachable from earlier API levels and will fail run-time class verification."
- errorLine1=" builder.setExtras(mExtras);"
- errorLine2=" ~~~~~~~~~">
- <location
- file="src/main/java/android/support/v4/media/session/PlaybackStateCompat.java"
- line="864"
- column="25"/>
- </issue>
-
- <issue
- id="ClassVerificationFailure"
- message="This call references a method added in API level 21; however, the containing class android.support.v4.media.session.PlaybackStateCompat is reachable from earlier API levels and will fail run-time class verification."
- errorLine1=" mStateFwk = builder.build();"
- errorLine2=" ~~~~~">
- <location
- file="src/main/java/android/support/v4/media/session/PlaybackStateCompat.java"
- line="866"
- column="33"/>
- </issue>
-
- <issue
- id="ClassVerificationFailure"
- message="This call references a method added in API level 21; however, the containing class android.support.v4.media.session.PlaybackStateCompat.CustomAction is reachable from earlier API levels and will fail run-time class verification."
- errorLine1=" Bundle extras = customActionFwk.getExtras();"
- errorLine2=" ~~~~~~~~~">
- <location
- file="src/main/java/android/support/v4/media/session/PlaybackStateCompat.java"
- line="945"
- column="45"/>
- </issue>
-
- <issue
- id="ClassVerificationFailure"
- message="This call references a method added in API level 21; however, the containing class android.support.v4.media.session.PlaybackStateCompat.CustomAction is reachable from earlier API levels and will fail run-time class verification."
- errorLine1=" customActionFwk.getAction(),"
- errorLine2=" ~~~~~~~~~">
- <location
- file="src/main/java/android/support/v4/media/session/PlaybackStateCompat.java"
- line="949"
- column="45"/>
- </issue>
-
- <issue
- id="ClassVerificationFailure"
- message="This call references a method added in API level 21; however, the containing class android.support.v4.media.session.PlaybackStateCompat.CustomAction is reachable from earlier API levels and will fail run-time class verification."
- errorLine1=" customActionFwk.getName(),"
- errorLine2=" ~~~~~~~">
- <location
- file="src/main/java/android/support/v4/media/session/PlaybackStateCompat.java"
- line="950"
- column="45"/>
- </issue>
-
- <issue
- id="ClassVerificationFailure"
- message="This call references a method added in API level 21; however, the containing class android.support.v4.media.session.PlaybackStateCompat.CustomAction is reachable from earlier API levels and will fail run-time class verification."
- errorLine1=" customActionFwk.getIcon(),"
- errorLine2=" ~~~~~~~">
- <location
- file="src/main/java/android/support/v4/media/session/PlaybackStateCompat.java"
- line="951"
- column="45"/>
- </issue>
-
- <issue
- id="ClassVerificationFailure"
- message="This call references a method added in API level 21; however, the containing class android.support.v4.media.session.PlaybackStateCompat.CustomAction is reachable from earlier API levels and will fail run-time class verification."
- errorLine1=" PlaybackState.CustomAction.Builder builder = new PlaybackState.CustomAction.Builder("
- errorLine2=" ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~">
- <location
- file="src/main/java/android/support/v4/media/session/PlaybackStateCompat.java"
- line="972"
- column="58"/>
- </issue>
-
- <issue
- id="ClassVerificationFailure"
- message="This call references a method added in API level 21; however, the containing class android.support.v4.media.session.PlaybackStateCompat.CustomAction is reachable from earlier API levels and will fail run-time class verification."
- errorLine1=" builder.setExtras(mExtras);"
- errorLine2=" ~~~~~~~~~">
- <location
- file="src/main/java/android/support/v4/media/session/PlaybackStateCompat.java"
- line="974"
- column="21"/>
- </issue>
-
- <issue
- id="ClassVerificationFailure"
- message="This call references a method added in API level 21; however, the containing class android.support.v4.media.session.PlaybackStateCompat.CustomAction is reachable from earlier API levels and will fail run-time class verification."
- errorLine1=" return builder.build();"
- errorLine2=" ~~~~~">
- <location
- file="src/main/java/android/support/v4/media/session/PlaybackStateCompat.java"
- line="975"
- column="28"/>
- </issue>
-
- <issue
- id="ClassVerificationFailure"
- message="This call references a method added in API level 19; however, the containing class android.support.v4.media.RatingCompat is reachable from earlier API levels and will fail run-time class verification."
- errorLine1=" final int ratingStyle = ((Rating) ratingObj).getRatingStyle();"
- errorLine2=" ~~~~~~~~~~~~~~">
- <location
- file="src/main/java/android/support/v4/media/RatingCompat.java"
- line="334"
- column="58"/>
- </issue>
-
- <issue
- id="ClassVerificationFailure"
- message="This call references a method added in API level 19; however, the containing class android.support.v4.media.RatingCompat is reachable from earlier API levels and will fail run-time class verification."
- errorLine1=" if (((Rating) ratingObj).isRated()) {"
- errorLine2=" ~~~~~~~">
- <location
- file="src/main/java/android/support/v4/media/RatingCompat.java"
- line="336"
- column="38"/>
- </issue>
-
- <issue
- id="ClassVerificationFailure"
- message="This call references a method added in API level 19; however, the containing class android.support.v4.media.RatingCompat is reachable from earlier API levels and will fail run-time class verification."
- errorLine1=" rating = newHeartRating(((Rating) ratingObj).hasHeart());"
- errorLine2=" ~~~~~~~~">
- <location
- file="src/main/java/android/support/v4/media/RatingCompat.java"
- line="339"
- column="70"/>
- </issue>
-
- <issue
- id="ClassVerificationFailure"
- message="This call references a method added in API level 19; however, the containing class android.support.v4.media.RatingCompat is reachable from earlier API levels and will fail run-time class verification."
- errorLine1=" rating = newThumbRating(((Rating) ratingObj).isThumbUp());"
- errorLine2=" ~~~~~~~~~">
- <location
- file="src/main/java/android/support/v4/media/RatingCompat.java"
- line="342"
- column="70"/>
- </issue>
-
- <issue
- id="ClassVerificationFailure"
- message="This call references a method added in API level 19; however, the containing class android.support.v4.media.RatingCompat is reachable from earlier API levels and will fail run-time class verification."
- errorLine1=" ((Rating) ratingObj).getStarRating());"
- errorLine2=" ~~~~~~~~~~~~~">
- <location
- file="src/main/java/android/support/v4/media/RatingCompat.java"
- line="348"
- column="54"/>
- </issue>
-
- <issue
- id="ClassVerificationFailure"
- message="This call references a method added in API level 19; however, the containing class android.support.v4.media.RatingCompat is reachable from earlier API levels and will fail run-time class verification."
- errorLine1=" ((Rating) ratingObj).getPercentRating());"
- errorLine2=" ~~~~~~~~~~~~~~~~">
- <location
- file="src/main/java/android/support/v4/media/RatingCompat.java"
- line="352"
- column="54"/>
- </issue>
-
- <issue
- id="ClassVerificationFailure"
- message="This call references a method added in API level 19; however, the containing class android.support.v4.media.RatingCompat is reachable from earlier API levels and will fail run-time class verification."
- errorLine1=" mRatingObj = Rating.newHeartRating(hasHeart());"
- errorLine2=" ~~~~~~~~~~~~~~">
- <location
- file="src/main/java/android/support/v4/media/RatingCompat.java"
- line="380"
- column="45"/>
- </issue>
-
- <issue
- id="ClassVerificationFailure"
- message="This call references a method added in API level 19; however, the containing class android.support.v4.media.RatingCompat is reachable from earlier API levels and will fail run-time class verification."
- errorLine1=" mRatingObj = Rating.newThumbRating(isThumbUp());"
- errorLine2=" ~~~~~~~~~~~~~~">
- <location
- file="src/main/java/android/support/v4/media/RatingCompat.java"
- line="383"
- column="45"/>
- </issue>
-
- <issue
- id="ClassVerificationFailure"
- message="This call references a method added in API level 19; however, the containing class android.support.v4.media.RatingCompat is reachable from earlier API levels and will fail run-time class verification."
- errorLine1=" mRatingObj = Rating.newStarRating(mRatingStyle,"
- errorLine2=" ~~~~~~~~~~~~~">
- <location
- file="src/main/java/android/support/v4/media/RatingCompat.java"
- line="388"
- column="45"/>
- </issue>
-
- <issue
- id="ClassVerificationFailure"
- message="This call references a method added in API level 19; however, the containing class android.support.v4.media.RatingCompat is reachable from earlier API levels and will fail run-time class verification."
- errorLine1=" mRatingObj = Rating.newPercentageRating(getPercentRating());"
- errorLine2=" ~~~~~~~~~~~~~~~~~~~">
- <location
- file="src/main/java/android/support/v4/media/RatingCompat.java"
- line="392"
- column="45"/>
- </issue>
-
- <issue
- id="ClassVerificationFailure"
- message="This call references a method added in API level 19; however, the containing class android.support.v4.media.RatingCompat is reachable from earlier API levels and will fail run-time class verification."
- errorLine1=" mRatingObj = Rating.newUnratedRating(mRatingStyle);"
- errorLine2=" ~~~~~~~~~~~~~~~~">
- <location
- file="src/main/java/android/support/v4/media/RatingCompat.java"
- line="398"
- column="37"/>
- </issue>
-
- <issue
- id="ClassVerificationFailure"
- message="This call references a method added in API level 21; however, the containing class androidx.media.VolumeProviderCompat is reachable from earlier API levels and will fail run-time class verification."
- errorLine1=" volumeProviderFwk.setCurrentVolume(currentVolume);"
- errorLine2=" ~~~~~~~~~~~~~~~~">
- <location
- file="src/main/java/androidx/media/VolumeProviderCompat.java"
- line="146"
- column="31"/>
- </issue>
-
- <issue
id="LambdaLast"
message="Functional interface parameters (such as parameter 1, "listener", in androidx.media.AudioFocusRequestCompat.Builder.setOnAudioFocusChangeListener) should be last to improve Kotlin interoperability; see https://kotlinlang.org/docs/reference/java-interop.html#sam-conversions"
errorLine1=" @NonNull OnAudioFocusChangeListener listener, @NonNull Handler handler) {"
errorLine2=" ~~~~~~~~~~~~~~~~~~~~~~~~">
<location
file="src/main/java/androidx/media/AudioFocusRequestCompat.java"
- line="310"
+ line="306"
column="63"/>
</issue>
@@ -1229,7 +107,7 @@
errorLine2=" ~~~~~~~~~~~~~~~~~~~~~~~">
<location
file="src/main/java/androidx/media/AudioFocusRequestCompat.java"
- line="370"
+ line="366"
column="16"/>
</issue>
@@ -1240,7 +118,7 @@
errorLine2=" ~~~~~~~">
<location
file="src/main/java/android/support/v4/media/MediaBrowserCompat.java"
- line="190"
+ line="192"
column="31"/>
</issue>
@@ -1251,7 +129,7 @@
errorLine2=" ~~~~~~~~~~~~~">
<location
file="src/main/java/android/support/v4/media/MediaBrowserCompat.java"
- line="190"
+ line="192"
column="48"/>
</issue>
@@ -1262,7 +140,7 @@
errorLine2=" ~~~~~~~~~~~~~~~~~~">
<location
file="src/main/java/android/support/v4/media/MediaBrowserCompat.java"
- line="191"
+ line="193"
column="13"/>
</issue>
@@ -1273,7 +151,7 @@
errorLine2=" ~~~~~~">
<location
file="src/main/java/android/support/v4/media/MediaBrowserCompat.java"
- line="191"
+ line="193"
column="42"/>
</issue>
@@ -1284,7 +162,7 @@
errorLine2=" ~~~~~~">
<location
file="src/main/java/android/support/v4/media/MediaBrowserCompat.java"
- line="410"
+ line="412"
column="59"/>
</issue>
@@ -1295,7 +173,7 @@
errorLine2=" ~~~~~~">
<location
file="src/main/java/android/support/v4/media/MediaBrowserCompat.java"
- line="432"
+ line="434"
column="58"/>
</issue>
@@ -1306,7 +184,7 @@
errorLine2=" ~~~~~~~~~">
<location
file="src/main/java/android/support/v4/media/MediaBrowserCompat.java"
- line="494"
+ line="496"
column="23"/>
</issue>
@@ -1317,7 +195,7 @@
errorLine2=" ~~~~~~">
<location
file="src/main/java/android/support/v4/media/MediaBrowserCompat.java"
- line="494"
+ line="496"
column="47"/>
</issue>
@@ -1328,7 +206,7 @@
errorLine2=" ~~~~~~~~~~~~~~~">
<location
file="src/main/java/android/support/v4/media/MediaBrowserCompat.java"
- line="515"
+ line="517"
column="23"/>
</issue>
@@ -1339,7 +217,7 @@
errorLine2=" ~~~~~~~">
<location
file="src/main/java/android/support/v4/media/MediaBrowserCompat.java"
- line="515"
+ line="517"
column="57"/>
</issue>
@@ -1350,7 +228,7 @@
errorLine2=" ~~~~~~">
<location
file="src/main/java/android/support/v4/media/MediaBrowserCompat.java"
- line="557"
+ line="559"
column="35"/>
</issue>
@@ -1361,7 +239,7 @@
errorLine2=" ~~~~~~~~~">
<location
file="src/main/java/android/support/v4/media/MediaBrowserCompat.java"
- line="883"
+ line="885"
column="34"/>
</issue>
@@ -1372,7 +250,7 @@
errorLine2=" ~~~~~~">
<location
file="src/main/java/android/support/v4/media/MediaBrowserCompat.java"
- line="922"
+ line="924"
column="59"/>
</issue>
@@ -1383,7 +261,7 @@
errorLine2=" ~~~~~~">
<location
file="src/main/java/android/support/v4/media/MediaBrowserCompat.java"
- line="933"
+ line="935"
column="52"/>
</issue>
@@ -1394,7 +272,7 @@
errorLine2=" ~~~~~~">
<location
file="src/main/java/android/support/v4/media/MediaBrowserCompat.java"
- line="949"
+ line="951"
column="38"/>
</issue>
@@ -1405,7 +283,7 @@
errorLine2=" ~~~~~~">
<location
file="src/main/java/android/support/v4/media/MediaBrowserCompat.java"
- line="949"
+ line="951"
column="53"/>
</issue>
@@ -1416,7 +294,7 @@
errorLine2=" ~~~~~~">
<location
file="src/main/java/android/support/v4/media/MediaBrowserCompat.java"
- line="949"
+ line="951"
column="68"/>
</issue>
@@ -1427,7 +305,7 @@
errorLine2=" ~~~~~~">
<location
file="src/main/java/android/support/v4/media/MediaBrowserCompat.java"
- line="959"
+ line="961"
column="30"/>
</issue>
@@ -1438,7 +316,7 @@
errorLine2=" ~~~~~~">
<location
file="src/main/java/android/support/v4/media/MediaBrowserCompat.java"
- line="959"
+ line="961"
column="45"/>
</issue>
@@ -1449,7 +327,7 @@
errorLine2=" ~~~~~~">
<location
file="src/main/java/android/support/v4/media/MediaBrowserCompat.java"
- line="959"
+ line="961"
column="60"/>
</issue>
@@ -1460,7 +338,7 @@
errorLine2=" ~~~~~~">
<location
file="src/main/java/android/support/v4/media/MediaBrowserCompat.java"
- line="970"
+ line="972"
column="29"/>
</issue>
@@ -1471,7 +349,7 @@
errorLine2=" ~~~~~~">
<location
file="src/main/java/android/support/v4/media/MediaBrowserCompat.java"
- line="970"
+ line="972"
column="44"/>
</issue>
@@ -1482,7 +360,7 @@
errorLine2=" ~~~~~~">
<location
file="src/main/java/android/support/v4/media/MediaBrowserCompat.java"
- line="970"
+ line="972"
column="59"/>
</issue>
@@ -1537,7 +415,7 @@
errorLine2=" ~~~~~~~">
<location
file="src/main/java/androidx/media/MediaBrowserServiceCompat.java"
- line="1306"
+ line="1311"
column="37"/>
</issue>
@@ -1548,7 +426,7 @@
errorLine2=" ~~~~~~~">
<location
file="src/main/java/androidx/media/MediaBrowserServiceCompat.java"
- line="1328"
+ line="1333"
column="12"/>
</issue>
@@ -1559,7 +437,7 @@
errorLine2=" ~~~~~~">
<location
file="src/main/java/androidx/media/MediaBrowserServiceCompat.java"
- line="1328"
+ line="1333"
column="27"/>
</issue>
@@ -1570,7 +448,7 @@
errorLine2=" ~~~~~~~~~~~~~~">
<location
file="src/main/java/androidx/media/MediaBrowserServiceCompat.java"
- line="1333"
+ line="1338"
column="22"/>
</issue>
@@ -1581,7 +459,7 @@
errorLine2=" ~~~~~~~~~~~">
<location
file="src/main/java/androidx/media/MediaBrowserServiceCompat.java"
- line="1333"
+ line="1338"
column="41"/>
</issue>
@@ -1592,7 +470,7 @@
errorLine2=" ~~~~~~~~">
<location
file="src/main/java/androidx/media/MediaBrowserServiceCompat.java"
- line="1333"
+ line="1338"
column="61"/>
</issue>
@@ -1603,7 +481,7 @@
errorLine2=" ~~~~~~">
<location
file="src/main/java/androidx/media/MediaBrowserServiceCompat.java"
- line="1424"
+ line="1429"
column="29"/>
</issue>
@@ -1614,7 +492,7 @@
errorLine2=" ~~~~~~">
<location
file="src/main/java/androidx/media/MediaBrowserServiceCompat.java"
- line="1424"
+ line="1429"
column="40"/>
</issue>
@@ -1625,7 +503,7 @@
errorLine2=" ~~~~~~">
<location
file="src/main/java/androidx/media/MediaBrowserServiceCompat.java"
- line="1434"
+ line="1439"
column="31"/>
</issue>
@@ -1636,7 +514,7 @@
errorLine2=" ~~~~~~">
<location
file="src/main/java/androidx/media/MediaBrowserServiceCompat.java"
- line="1455"
+ line="1460"
column="28"/>
</issue>
@@ -1647,7 +525,7 @@
errorLine2=" ~~~~~~">
<location
file="src/main/java/androidx/media/MediaBrowserServiceCompat.java"
- line="1481"
+ line="1486"
column="49"/>
</issue>
@@ -1658,7 +536,7 @@
errorLine2=" ~~~~~~">
<location
file="src/main/java/androidx/media/MediaBrowserServiceCompat.java"
- line="1506"
+ line="1511"
column="56"/>
</issue>
@@ -1669,7 +547,7 @@
errorLine2=" ~~~~~~~~~~~~~~~~~~~~~~~~">
<location
file="src/main/java/androidx/media/MediaBrowserServiceCompat.java"
- line="1519"
+ line="1524"
column="33"/>
</issue>
@@ -1680,7 +558,7 @@
errorLine2=" ~~~~~~">
<location
file="src/main/java/androidx/media/MediaBrowserServiceCompat.java"
- line="1554"
+ line="1559"
column="18"/>
</issue>
@@ -1691,7 +569,7 @@
errorLine2=" ~~~~~~">
<location
file="src/main/java/androidx/media/MediaBrowserServiceCompat.java"
- line="1962"
+ line="1967"
column="16"/>
</issue>
@@ -1702,7 +580,7 @@
errorLine2=" ~~~~~~">
<location
file="src/main/java/androidx/media/MediaBrowserServiceCompat.java"
- line="1969"
+ line="1974"
column="16"/>
</issue>
@@ -1713,7 +591,7 @@
errorLine2=" ~~~~~~~">
<location
file="src/main/java/androidx/media/session/MediaButtonReceiver.java"
- line="106"
+ line="107"
column="27"/>
</issue>
@@ -1724,7 +602,7 @@
errorLine2=" ~~~~~~">
<location
file="src/main/java/androidx/media/session/MediaButtonReceiver.java"
- line="106"
+ line="107"
column="44"/>
</issue>
@@ -1735,7 +613,7 @@
errorLine2=" ~~~~~~~~">
<location
file="src/main/java/androidx/media/session/MediaButtonReceiver.java"
- line="191"
+ line="192"
column="19"/>
</issue>
@@ -1746,7 +624,7 @@
errorLine2=" ~~~~~~~~~~~~~~~~~~">
<location
file="src/main/java/androidx/media/session/MediaButtonReceiver.java"
- line="191"
+ line="192"
column="41"/>
</issue>
@@ -1757,7 +635,7 @@
errorLine2=" ~~~~~~">
<location
file="src/main/java/androidx/media/session/MediaButtonReceiver.java"
- line="191"
+ line="192"
column="80"/>
</issue>
@@ -1768,7 +646,7 @@
errorLine2=" ~~~~~~~~~~~~~">
<location
file="src/main/java/androidx/media/session/MediaButtonReceiver.java"
- line="224"
+ line="225"
column="19"/>
</issue>
@@ -1779,7 +657,7 @@
errorLine2=" ~~~~~~~">
<location
file="src/main/java/androidx/media/session/MediaButtonReceiver.java"
- line="224"
+ line="225"
column="63"/>
</issue>
@@ -1790,7 +668,7 @@
errorLine2=" ~~~~~~~~~~~~~">
<location
file="src/main/java/androidx/media/session/MediaButtonReceiver.java"
- line="258"
+ line="259"
column="19"/>
</issue>
@@ -1801,7 +679,7 @@
errorLine2=" ~~~~~~~">
<location
file="src/main/java/androidx/media/session/MediaButtonReceiver.java"
- line="258"
+ line="259"
column="63"/>
</issue>
@@ -1812,7 +690,7 @@
errorLine2=" ~~~~~~~~~~~~~">
<location
file="src/main/java/androidx/media/session/MediaButtonReceiver.java"
- line="259"
+ line="260"
column="13"/>
</issue>
@@ -1823,7 +701,7 @@
errorLine2=" ~~~~~~~~~~~~~">
<location
file="src/main/java/androidx/media/session/MediaButtonReceiver.java"
- line="283"
+ line="284"
column="19"/>
</issue>
@@ -1834,7 +712,7 @@
errorLine2=" ~~~~~~~">
<location
file="src/main/java/androidx/media/session/MediaButtonReceiver.java"
- line="283"
+ line="284"
column="65"/>
</issue>
@@ -1856,7 +734,7 @@
errorLine2=" ~~~~~~~~~~~~~~~~~~~~~">
<location
file="src/main/java/android/support/v4/media/session/MediaControllerCompat.java"
- line="186"
+ line="181"
column="19"/>
</issue>
@@ -1867,7 +745,7 @@
errorLine2=" ~~~~~~~">
<location
file="src/main/java/android/support/v4/media/session/MediaControllerCompat.java"
- line="235"
+ line="224"
column="34"/>
</issue>
@@ -1878,7 +756,7 @@
errorLine2=" ~~~~~~~">
<location
file="src/main/java/android/support/v4/media/session/MediaControllerCompat.java"
- line="254"
+ line="245"
column="34"/>
</issue>
@@ -1889,7 +767,7 @@
errorLine2=" ~~~~~~~~~~~~~~~~~">
<location
file="src/main/java/android/support/v4/media/session/MediaControllerCompat.java"
- line="272"
+ line="263"
column="12"/>
</issue>
@@ -1900,7 +778,7 @@
errorLine2=" ~~~~~~~~">
<location
file="src/main/java/android/support/v4/media/session/MediaControllerCompat.java"
- line="283"
+ line="274"
column="45"/>
</issue>
@@ -1911,7 +789,7 @@
errorLine2=" ~~~~~~~~~~~~~~~~~~~">
<location
file="src/main/java/android/support/v4/media/session/MediaControllerCompat.java"
- line="300"
+ line="291"
column="12"/>
</issue>
@@ -1922,7 +800,7 @@
errorLine2=" ~~~~~~~~~~~~~~~~~~~">
<location
file="src/main/java/android/support/v4/media/session/MediaControllerCompat.java"
- line="309"
+ line="300"
column="12"/>
</issue>
@@ -1933,7 +811,7 @@
errorLine2=" ~~~~~~~~~~~~~~~">
<location
file="src/main/java/android/support/v4/media/session/MediaControllerCompat.java"
- line="319"
+ line="310"
column="12"/>
</issue>
@@ -1944,7 +822,7 @@
errorLine2=" ~~~~~~~~~~~~~~~~~~~~~~">
<location
file="src/main/java/android/support/v4/media/session/MediaControllerCompat.java"
- line="335"
+ line="326"
column="30"/>
</issue>
@@ -1955,7 +833,7 @@
errorLine2=" ~~~~~~~~~~~~~~~~~~~~~~">
<location
file="src/main/java/android/support/v4/media/session/MediaControllerCompat.java"
- line="355"
+ line="346"
column="30"/>
</issue>
@@ -1966,7 +844,7 @@
errorLine2=" ~~~~~~~~~~~~~~~~~~~~~~">
<location
file="src/main/java/android/support/v4/media/session/MediaControllerCompat.java"
- line="372"
+ line="363"
column="33"/>
</issue>
@@ -1977,7 +855,7 @@
errorLine2=" ~~~~~~~~~~~~">
<location
file="src/main/java/android/support/v4/media/session/MediaControllerCompat.java"
- line="402"
+ line="393"
column="12"/>
</issue>
@@ -1988,7 +866,7 @@
errorLine2=" ~~~~~~">
<location
file="src/main/java/android/support/v4/media/session/MediaControllerCompat.java"
- line="409"
+ line="400"
column="12"/>
</issue>
@@ -1999,7 +877,7 @@
errorLine2=" ~~~~~~~~~~~~">
<location
file="src/main/java/android/support/v4/media/session/MediaControllerCompat.java"
- line="489"
+ line="480"
column="12"/>
</issue>
@@ -2010,7 +888,7 @@
errorLine2=" ~~~~~~~~~~~~~">
<location
file="src/main/java/android/support/v4/media/session/MediaControllerCompat.java"
- line="499"
+ line="490"
column="12"/>
</issue>
@@ -2021,7 +899,7 @@
errorLine2=" ~~~~~~~~~~~~~~~~~~~~~~~~">
<location
file="src/main/java/android/support/v4/media/session/MediaControllerCompat.java"
- line="508"
+ line="499"
column="12"/>
</issue>
@@ -2032,7 +910,7 @@
errorLine2=" ~~~~~~~">
<location
file="src/main/java/android/support/v4/media/session/MediaControllerCompat.java"
- line="576"
+ line="567"
column="62"/>
</issue>
@@ -2043,7 +921,7 @@
errorLine2=" ~~~~~~">
<location
file="src/main/java/android/support/v4/media/session/MediaControllerCompat.java"
- line="654"
+ line="645"
column="12"/>
</issue>
@@ -2054,7 +932,7 @@
errorLine2=" ~~~~~~">
<location
file="src/main/java/android/support/v4/media/session/MediaControllerCompat.java"
- line="684"
+ line="675"
column="12"/>
</issue>
@@ -2065,7 +943,7 @@
errorLine2=" ~~~~~~">
<location
file="src/main/java/android/support/v4/media/session/MediaControllerCompat.java"
- line="729"
+ line="720"
column="36"/>
</issue>
@@ -2076,7 +954,7 @@
errorLine2=" ~~~~~~">
<location
file="src/main/java/android/support/v4/media/session/MediaControllerCompat.java"
- line="729"
+ line="720"
column="50"/>
</issue>
@@ -2087,7 +965,7 @@
errorLine2=" ~~~~~~~~~~~~~~~~~~~">
<location
file="src/main/java/android/support/v4/media/session/MediaControllerCompat.java"
- line="737"
+ line="728"
column="44"/>
</issue>
@@ -2098,7 +976,7 @@
errorLine2=" ~~~~~~~~~~~~~~~~~~~">
<location
file="src/main/java/android/support/v4/media/session/MediaControllerCompat.java"
- line="746"
+ line="737"
column="39"/>
</issue>
@@ -2109,7 +987,7 @@
errorLine2=" ~~~~~~~~~~~~~~~">
<location
file="src/main/java/android/support/v4/media/session/MediaControllerCompat.java"
- line="757"
+ line="748"
column="36"/>
</issue>
@@ -2120,7 +998,7 @@
errorLine2=" ~~~~~~~~~~~~">
<location
file="src/main/java/android/support/v4/media/session/MediaControllerCompat.java"
- line="767"
+ line="758"
column="41"/>
</issue>
@@ -2131,7 +1009,7 @@
errorLine2=" ~~~~~~">
<location
file="src/main/java/android/support/v4/media/session/MediaControllerCompat.java"
- line="776"
+ line="767"
column="37"/>
</issue>
@@ -2142,7 +1020,7 @@
errorLine2=" ~~~~~~~~~~~~">
<location
file="src/main/java/android/support/v4/media/session/MediaControllerCompat.java"
- line="784"
+ line="775"
column="40"/>
</issue>
@@ -2153,7 +1031,7 @@
errorLine2=" ~~~~~~~~~~~~~~~~~~~~~~~~">
<location
file="src/main/java/android/support/v4/media/session/MediaControllerCompat.java"
- line="823"
+ line="814"
column="16"/>
</issue>
@@ -2164,7 +1042,7 @@
errorLine2=" ~~~~~~">
<location
file="src/main/java/android/support/v4/media/session/MediaControllerCompat.java"
- line="1174"
+ line="1165"
column="49"/>
</issue>
@@ -2175,7 +1053,7 @@
errorLine2=" ~~~~~~">
<location
file="src/main/java/android/support/v4/media/session/MediaControllerCompat.java"
- line="1174"
+ line="1165"
column="65"/>
</issue>
@@ -2186,7 +1064,7 @@
errorLine2=" ~~~~~~">
<location
file="src/main/java/android/support/v4/media/session/MediaControllerCompat.java"
- line="1186"
+ line="1177"
column="48"/>
</issue>
@@ -2197,7 +1075,7 @@
errorLine2=" ~~~~~~">
<location
file="src/main/java/android/support/v4/media/session/MediaControllerCompat.java"
- line="1186"
+ line="1177"
column="62"/>
</issue>
@@ -2208,7 +1086,7 @@
errorLine2=" ~~~">
<location
file="src/main/java/android/support/v4/media/session/MediaControllerCompat.java"
- line="1197"
+ line="1188"
column="45"/>
</issue>
@@ -2219,7 +1097,7 @@
errorLine2=" ~~~~~~">
<location
file="src/main/java/android/support/v4/media/session/MediaControllerCompat.java"
- line="1197"
+ line="1188"
column="54"/>
</issue>
@@ -2230,7 +1108,7 @@
errorLine2=" ~~~~~~">
<location
file="src/main/java/android/support/v4/media/session/MediaControllerCompat.java"
- line="1211"
+ line="1202"
column="46"/>
</issue>
@@ -2241,7 +1119,7 @@
errorLine2=" ~~~~~~">
<location
file="src/main/java/android/support/v4/media/session/MediaControllerCompat.java"
- line="1211"
+ line="1202"
column="62"/>
</issue>
@@ -2252,7 +1130,7 @@
errorLine2=" ~~~~~~">
<location
file="src/main/java/android/support/v4/media/session/MediaControllerCompat.java"
- line="1222"
+ line="1213"
column="45"/>
</issue>
@@ -2263,7 +1141,7 @@
errorLine2=" ~~~~~~">
<location
file="src/main/java/android/support/v4/media/session/MediaControllerCompat.java"
- line="1222"
+ line="1213"
column="59"/>
</issue>
@@ -2274,7 +1152,7 @@
errorLine2=" ~~~">
<location
file="src/main/java/android/support/v4/media/session/MediaControllerCompat.java"
- line="1231"
+ line="1222"
column="42"/>
</issue>
@@ -2285,7 +1163,7 @@
errorLine2=" ~~~~~~">
<location
file="src/main/java/android/support/v4/media/session/MediaControllerCompat.java"
- line="1231"
+ line="1222"
column="51"/>
</issue>
@@ -2296,7 +1174,7 @@
errorLine2=" ~~~~~~~~~~~~">
<location
file="src/main/java/android/support/v4/media/session/MediaControllerCompat.java"
- line="1287"
+ line="1278"
column="40"/>
</issue>
@@ -2307,7 +1185,7 @@
errorLine2=" ~~~~~~~~~~~~">
<location
file="src/main/java/android/support/v4/media/session/MediaControllerCompat.java"
- line="1301"
+ line="1292"
column="40"/>
</issue>
@@ -2318,7 +1196,7 @@
errorLine2=" ~~~~~~">
<location
file="src/main/java/android/support/v4/media/session/MediaControllerCompat.java"
- line="1301"
+ line="1292"
column="61"/>
</issue>
@@ -2329,7 +1207,7 @@
errorLine2=" ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~">
<location
file="src/main/java/android/support/v4/media/session/MediaControllerCompat.java"
- line="1347"
+ line="1338"
column="47"/>
</issue>
@@ -2340,7 +1218,7 @@
errorLine2=" ~~~~~~">
<location
file="src/main/java/android/support/v4/media/session/MediaControllerCompat.java"
- line="1348"
+ line="1339"
column="17"/>
</issue>
@@ -2351,7 +1229,7 @@
errorLine2=" ~~~~~~">
<location
file="src/main/java/android/support/v4/media/session/MediaControllerCompat.java"
- line="1366"
+ line="1357"
column="47"/>
</issue>
@@ -2362,7 +1240,7 @@
errorLine2=" ~~~~~~">
<location
file="src/main/java/android/support/v4/media/session/MediaControllerCompat.java"
- line="1366"
+ line="1357"
column="62"/>
</issue>
@@ -2373,7 +1251,7 @@
errorLine2=" ~~~~~~">
<location
file="src/main/java/android/support/v4/media/MediaDescriptionCompat.java"
- line="304"
+ line="306"
column="31"/>
</issue>
@@ -2384,7 +1262,7 @@
errorLine2=" ~~~~~~">
<location
file="src/main/java/android/support/v4/media/MediaDescriptionCompat.java"
- line="335"
+ line="337"
column="12"/>
</issue>
@@ -2395,7 +1273,7 @@
errorLine2=" ~~~~~~~~~~~~~~~~~~~~~~">
<location
file="src/main/java/android/support/v4/media/MediaDescriptionCompat.java"
- line="379"
+ line="381"
column="19"/>
</issue>
@@ -2406,7 +1284,7 @@
errorLine2=" ~~~~~~">
<location
file="src/main/java/android/support/v4/media/MediaDescriptionCompat.java"
- line="379"
+ line="381"
column="63"/>
</issue>
@@ -2417,7 +1295,7 @@
errorLine2=" ~~~~~~~">
<location
file="src/main/java/android/support/v4/media/MediaDescriptionCompat.java"
- line="468"
+ line="470"
column="16"/>
</issue>
@@ -2428,7 +1306,7 @@
errorLine2=" ~~~~~~~">
<location
file="src/main/java/android/support/v4/media/MediaDescriptionCompat.java"
- line="479"
+ line="481"
column="16"/>
</issue>
@@ -2439,7 +1317,7 @@
errorLine2=" ~~~~~~~">
<location
file="src/main/java/android/support/v4/media/MediaDescriptionCompat.java"
- line="490"
+ line="492"
column="16"/>
</issue>
@@ -2450,7 +1328,7 @@
errorLine2=" ~~~~~~~">
<location
file="src/main/java/android/support/v4/media/MediaDescriptionCompat.java"
- line="502"
+ line="504"
column="16"/>
</issue>
@@ -2461,7 +1339,7 @@
errorLine2=" ~~~~~~~">
<location
file="src/main/java/android/support/v4/media/MediaDescriptionCompat.java"
- line="514"
+ line="516"
column="16"/>
</issue>
@@ -2472,7 +1350,7 @@
errorLine2=" ~~~~~~~">
<location
file="src/main/java/android/support/v4/media/MediaDescriptionCompat.java"
- line="526"
+ line="528"
column="16"/>
</issue>
@@ -2483,7 +1361,7 @@
errorLine2=" ~~~~~~~">
<location
file="src/main/java/android/support/v4/media/MediaDescriptionCompat.java"
- line="537"
+ line="539"
column="16"/>
</issue>
@@ -2494,7 +1372,7 @@
errorLine2=" ~~~~~~~">
<location
file="src/main/java/android/support/v4/media/MediaDescriptionCompat.java"
- line="548"
+ line="550"
column="16"/>
</issue>
@@ -2505,7 +1383,7 @@
errorLine2=" ~~~~~~~~~~~~~~~~~~~~~~">
<location
file="src/main/java/android/support/v4/media/MediaDescriptionCompat.java"
- line="559"
+ line="561"
column="16"/>
</issue>
@@ -2890,7 +1768,7 @@
errorLine2=" ~~~~~~~~">
<location
file="src/main/java/android/support/v4/media/session/MediaSessionCompat.java"
- line="629"
+ line="619"
column="29"/>
</issue>
@@ -2901,7 +1779,7 @@
errorLine2=" ~~~~~~~~">
<location
file="src/main/java/android/support/v4/media/session/MediaSessionCompat.java"
- line="645"
+ line="635"
column="29"/>
</issue>
@@ -2912,7 +1790,7 @@
errorLine2=" ~~~~~~~">
<location
file="src/main/java/android/support/v4/media/session/MediaSessionCompat.java"
- line="645"
+ line="635"
column="48"/>
</issue>
@@ -2923,7 +1801,7 @@
errorLine2=" ~~~~~~~~~~~~~">
<location
file="src/main/java/android/support/v4/media/session/MediaSessionCompat.java"
- line="661"
+ line="651"
column="36"/>
</issue>
@@ -2934,7 +1812,7 @@
errorLine2=" ~~~~~~~~~~~~~">
<location
file="src/main/java/android/support/v4/media/session/MediaSessionCompat.java"
- line="678"
+ line="668"
column="40"/>
</issue>
@@ -2945,7 +1823,7 @@
errorLine2=" ~~~~~~~~~~~~~~~~~~~~">
<location
file="src/main/java/android/support/v4/media/session/MediaSessionCompat.java"
- line="720"
+ line="710"
column="37"/>
</issue>
@@ -2956,7 +1834,7 @@
errorLine2=" ~~~~~~">
<location
file="src/main/java/android/support/v4/media/session/MediaSessionCompat.java"
- line="764"
+ line="754"
column="34"/>
</issue>
@@ -2967,7 +1845,7 @@
errorLine2=" ~~~~~~">
<location
file="src/main/java/android/support/v4/media/session/MediaSessionCompat.java"
- line="764"
+ line="754"
column="48"/>
</issue>
@@ -2978,7 +1856,7 @@
errorLine2=" ~~~~~">
<location
file="src/main/java/android/support/v4/media/session/MediaSessionCompat.java"
- line="794"
+ line="784"
column="12"/>
</issue>
@@ -2989,7 +1867,7 @@
errorLine2=" ~~~~~~~~~~~~~~~~~~~~~">
<location
file="src/main/java/android/support/v4/media/session/MediaSessionCompat.java"
- line="804"
+ line="794"
column="12"/>
</issue>
@@ -3000,7 +1878,7 @@
errorLine2=" ~~~~~~~~~~~~~~~~~~~">
<location
file="src/main/java/android/support/v4/media/session/MediaSessionCompat.java"
- line="813"
+ line="803"
column="34"/>
</issue>
@@ -3011,7 +1889,7 @@
errorLine2=" ~~~~~~~~~~~~~~~~~~~">
<location
file="src/main/java/android/support/v4/media/session/MediaSessionCompat.java"
- line="825"
+ line="815"
column="29"/>
</issue>
@@ -3022,7 +1900,7 @@
errorLine2=" ~~~~~~~~~~~~~~~">
<location
file="src/main/java/android/support/v4/media/session/MediaSessionCompat.java"
- line="841"
+ line="831"
column="26"/>
</issue>
@@ -3033,7 +1911,7 @@
errorLine2=" ~~~~~~~~~~~~">
<location
file="src/main/java/android/support/v4/media/session/MediaSessionCompat.java"
- line="865"
+ line="855"
column="31"/>
</issue>
@@ -3044,7 +1922,7 @@
errorLine2=" ~~~~~~">
<location
file="src/main/java/android/support/v4/media/session/MediaSessionCompat.java"
- line="934"
+ line="924"
column="27"/>
</issue>
@@ -3055,7 +1933,7 @@
errorLine2=" ~~~~~~">
<location
file="src/main/java/android/support/v4/media/session/MediaSessionCompat.java"
- line="948"
+ line="938"
column="12"/>
</issue>
@@ -3066,7 +1944,7 @@
errorLine2=" ~~~~~~">
<location
file="src/main/java/android/support/v4/media/session/MediaSessionCompat.java"
- line="962"
+ line="952"
column="12"/>
</issue>
@@ -3077,7 +1955,7 @@
errorLine2=" ~~~~~~">
<location
file="src/main/java/android/support/v4/media/session/MediaSessionCompat.java"
- line="998"
+ line="988"
column="12"/>
</issue>
@@ -3088,7 +1966,7 @@
errorLine2=" ~~~~~~~~~~~~~~~~~~~~~~">
<location
file="src/main/java/android/support/v4/media/session/MediaSessionCompat.java"
- line="1009"
+ line="999"
column="43"/>
</issue>
@@ -3099,7 +1977,7 @@
errorLine2=" ~~~~~~~~~~~~~~~~~~~~~~">
<location
file="src/main/java/android/support/v4/media/session/MediaSessionCompat.java"
- line="1022"
+ line="1012"
column="46"/>
</issue>
@@ -3110,7 +1988,7 @@
errorLine2=" ~~~~~~~~~~~~~~~~~~">
<location
file="src/main/java/android/support/v4/media/session/MediaSessionCompat.java"
- line="1045"
+ line="1035"
column="19"/>
</issue>
@@ -3121,7 +1999,7 @@
errorLine2=" ~~~~~~~">
<location
file="src/main/java/android/support/v4/media/session/MediaSessionCompat.java"
- line="1045"
+ line="1035"
column="55"/>
</issue>
@@ -3132,7 +2010,7 @@
errorLine2=" ~~~~~~">
<location
file="src/main/java/android/support/v4/media/session/MediaSessionCompat.java"
- line="1045"
+ line="1035"
column="72"/>
</issue>
@@ -3143,7 +2021,7 @@
errorLine2=" ~~~~~~">
<location
file="src/main/java/android/support/v4/media/session/MediaSessionCompat.java"
- line="1178"
+ line="1168"
column="31"/>
</issue>
@@ -3154,7 +2032,7 @@
errorLine2=" ~~~~~~">
<location
file="src/main/java/android/support/v4/media/session/MediaSessionCompat.java"
- line="1178"
+ line="1168"
column="47"/>
</issue>
@@ -3165,7 +2043,7 @@
errorLine2=" ~~~~~~~~~~~~~~">
<location
file="src/main/java/android/support/v4/media/session/MediaSessionCompat.java"
- line="1178"
+ line="1168"
column="62"/>
</issue>
@@ -3176,7 +2054,7 @@
errorLine2=" ~~~~~~">
<location
file="src/main/java/android/support/v4/media/session/MediaSessionCompat.java"
- line="1192"
+ line="1182"
column="43"/>
</issue>
@@ -3187,7 +2065,7 @@
errorLine2=" ~~~~~~">
<location
file="src/main/java/android/support/v4/media/session/MediaSessionCompat.java"
- line="1285"
+ line="1275"
column="42"/>
</issue>
@@ -3198,7 +2076,7 @@
errorLine2=" ~~~~~~">
<location
file="src/main/java/android/support/v4/media/session/MediaSessionCompat.java"
- line="1285"
+ line="1275"
column="58"/>
</issue>
@@ -3209,7 +2087,7 @@
errorLine2=" ~~~~~~">
<location
file="src/main/java/android/support/v4/media/session/MediaSessionCompat.java"
- line="1295"
+ line="1285"
column="41"/>
</issue>
@@ -3220,7 +2098,7 @@
errorLine2=" ~~~~~~">
<location
file="src/main/java/android/support/v4/media/session/MediaSessionCompat.java"
- line="1295"
+ line="1285"
column="55"/>
</issue>
@@ -3231,7 +2109,7 @@
errorLine2=" ~~~">
<location
file="src/main/java/android/support/v4/media/session/MediaSessionCompat.java"
- line="1303"
+ line="1293"
column="38"/>
</issue>
@@ -3242,7 +2120,7 @@
errorLine2=" ~~~~~~">
<location
file="src/main/java/android/support/v4/media/session/MediaSessionCompat.java"
- line="1303"
+ line="1293"
column="47"/>
</issue>
@@ -3253,7 +2131,7 @@
errorLine2=" ~~~~~~">
<location
file="src/main/java/android/support/v4/media/session/MediaSessionCompat.java"
- line="1316"
+ line="1306"
column="39"/>
</issue>
@@ -3264,7 +2142,7 @@
errorLine2=" ~~~~~~">
<location
file="src/main/java/android/support/v4/media/session/MediaSessionCompat.java"
- line="1316"
+ line="1306"
column="55"/>
</issue>
@@ -3275,7 +2153,7 @@
errorLine2=" ~~~~~~">
<location
file="src/main/java/android/support/v4/media/session/MediaSessionCompat.java"
- line="1325"
+ line="1315"
column="38"/>
</issue>
@@ -3286,7 +2164,7 @@
errorLine2=" ~~~~~~">
<location
file="src/main/java/android/support/v4/media/session/MediaSessionCompat.java"
- line="1325"
+ line="1315"
column="52"/>
</issue>
@@ -3297,7 +2175,7 @@
errorLine2=" ~~~">
<location
file="src/main/java/android/support/v4/media/session/MediaSessionCompat.java"
- line="1331"
+ line="1321"
column="35"/>
</issue>
@@ -3308,7 +2186,7 @@
errorLine2=" ~~~~~~">
<location
file="src/main/java/android/support/v4/media/session/MediaSessionCompat.java"
- line="1331"
+ line="1321"
column="44"/>
</issue>
@@ -3319,7 +2197,7 @@
errorLine2=" ~~~~~~~~~~~~">
<location
file="src/main/java/android/support/v4/media/session/MediaSessionCompat.java"
- line="1390"
+ line="1380"
column="33"/>
</issue>
@@ -3330,7 +2208,7 @@
errorLine2=" ~~~~~~~~~~~~">
<location
file="src/main/java/android/support/v4/media/session/MediaSessionCompat.java"
- line="1399"
+ line="1389"
column="33"/>
</issue>
@@ -3341,7 +2219,7 @@
errorLine2=" ~~~~~~">
<location
file="src/main/java/android/support/v4/media/session/MediaSessionCompat.java"
- line="1399"
+ line="1389"
column="54"/>
</issue>
@@ -3352,7 +2230,7 @@
errorLine2=" ~~~~~~">
<location
file="src/main/java/android/support/v4/media/session/MediaSessionCompat.java"
- line="1470"
+ line="1460"
column="36"/>
</issue>
@@ -3363,7 +2241,7 @@
errorLine2=" ~~~~~~">
<location
file="src/main/java/android/support/v4/media/session/MediaSessionCompat.java"
- line="1470"
+ line="1460"
column="51"/>
</issue>
@@ -3374,7 +2252,7 @@
errorLine2=" ~~~~~~~~~~~~~~~~~~~~~~">
<location
file="src/main/java/android/support/v4/media/session/MediaSessionCompat.java"
- line="1480"
+ line="1470"
column="36"/>
</issue>
@@ -3385,7 +2263,7 @@
errorLine2=" ~~~~~~~~~~~~~~~~~~~~~~">
<location
file="src/main/java/android/support/v4/media/session/MediaSessionCompat.java"
- line="1492"
+ line="1482"
column="36"/>
</issue>
@@ -3396,7 +2274,7 @@
errorLine2=" ~~~~~~~~~~~~~~~~~~~~~~">
<location
file="src/main/java/android/support/v4/media/session/MediaSessionCompat.java"
- line="1503"
+ line="1493"
column="39"/>
</issue>
@@ -3407,7 +2285,7 @@
errorLine2=" ~~~~~">
<location
file="src/main/java/android/support/v4/media/session/MediaSessionCompat.java"
- line="1964"
+ line="1954"
column="23"/>
</issue>
@@ -3418,7 +2296,7 @@
errorLine2=" ~~~~~~">
<location
file="src/main/java/android/support/v4/media/session/MediaSessionCompat.java"
- line="1964"
+ line="1954"
column="39"/>
</issue>
@@ -3429,7 +2307,7 @@
errorLine2=" ~~~~~">
<location
file="src/main/java/android/support/v4/media/session/MediaSessionCompat.java"
- line="1982"
+ line="1972"
column="23"/>
</issue>
@@ -3440,7 +2318,7 @@
errorLine2=" ~~~~~~">
<location
file="src/main/java/android/support/v4/media/session/MediaSessionCompat.java"
- line="1982"
+ line="1972"
column="39"/>
</issue>
@@ -3451,7 +2329,7 @@
errorLine2=" ~~~~~~~~~~~~~">
<location
file="src/main/java/android/support/v4/media/session/MediaSessionCompat.java"
- line="1982"
+ line="1972"
column="53"/>
</issue>
@@ -3462,7 +2340,7 @@
errorLine2=" ~~~~~~">
<location
file="src/main/java/android/support/v4/media/session/MediaSessionCompat.java"
- line="1999"
+ line="1989"
column="35"/>
</issue>
@@ -3473,7 +2351,7 @@
errorLine2=" ~~~~~~">
<location
file="src/main/java/android/support/v4/media/session/MediaSessionCompat.java"
- line="2043"
+ line="2033"
column="16"/>
</issue>
@@ -3484,7 +2362,7 @@
errorLine2=" ~~~~~~~~~~~~~">
<location
file="src/main/java/android/support/v4/media/session/MediaSessionCompat.java"
- line="2051"
+ line="2041"
column="16"/>
</issue>
@@ -3495,7 +2373,7 @@
errorLine2=" ~~~~~~~~~~~~~">
<location
file="src/main/java/android/support/v4/media/session/MediaSessionCompat.java"
- line="2061"
+ line="2051"
column="36"/>
</issue>
@@ -3506,7 +2384,7 @@
errorLine2=" ~~~~~~~~~~~~~~~~~~~">
<location
file="src/main/java/android/support/v4/media/session/MediaSessionCompat.java"
- line="2071"
+ line="2061"
column="16"/>
</issue>
@@ -3517,7 +2395,7 @@
errorLine2=" ~~~~~~~~~~~~~~~~~~~">
<location
file="src/main/java/android/support/v4/media/session/MediaSessionCompat.java"
- line="2081"
+ line="2071"
column="38"/>
</issue>
@@ -3528,7 +2406,7 @@
errorLine2=" ~~~~~~">
<location
file="src/main/java/android/support/v4/media/session/MediaSessionCompat.java"
- line="2091"
+ line="2081"
column="16"/>
</issue>
@@ -3539,7 +2417,7 @@
errorLine2=" ~~~~~">
<location
file="src/main/java/android/support/v4/media/session/MediaSessionCompat.java"
- line="2113"
+ line="2103"
column="23"/>
</issue>
@@ -3550,7 +2428,7 @@
errorLine2=" ~~~~~~">
<location
file="src/main/java/android/support/v4/media/session/MediaSessionCompat.java"
- line="2113"
+ line="2103"
column="40"/>
</issue>
@@ -3561,7 +2439,7 @@
errorLine2=" ~~~~~~~~~~~~~~~~~~~~~~">
<location
file="src/main/java/android/support/v4/media/session/MediaSessionCompat.java"
- line="2168"
+ line="2158"
column="26"/>
</issue>
@@ -3572,7 +2450,7 @@
errorLine2=" ~~~~~~~~~~~~~~~~~~~~~~">
<location
file="src/main/java/android/support/v4/media/session/MediaSessionCompat.java"
- line="2195"
+ line="2185"
column="16"/>
</issue>
@@ -3583,7 +2461,7 @@
errorLine2=" ~~~~~~">
<location
file="src/main/java/android/support/v4/media/session/MediaSessionCompat.java"
- line="2207"
+ line="2197"
column="35"/>
</issue>
@@ -3594,7 +2472,7 @@
errorLine2=" ~~~~~~">
<location
file="src/main/java/android/support/v4/media/session/MediaSessionCompat.java"
- line="2227"
+ line="2217"
column="16"/>
</issue>
@@ -3605,7 +2483,7 @@
errorLine2=" ~~~~~~~~~">
<location
file="src/main/java/android/support/v4/media/session/MediaSessionCompat.java"
- line="2247"
+ line="2237"
column="23"/>
</issue>
@@ -3616,7 +2494,7 @@
errorLine2=" ~~~~~~">
<location
file="src/main/java/android/support/v4/media/session/MediaSessionCompat.java"
- line="2247"
+ line="2237"
column="47"/>
</issue>
@@ -3627,7 +2505,7 @@
errorLine2=" ~~~~~~~~~~~~~~~">
<location
file="src/main/java/android/support/v4/media/session/MediaSessionCompat.java"
- line="2269"
+ line="2259"
column="23"/>
</issue>
@@ -3638,7 +2516,7 @@
errorLine2=" ~~~~~~~">
<location
file="src/main/java/android/support/v4/media/session/MediaSessionCompat.java"
- line="2269"
+ line="2259"
column="57"/>
</issue>
@@ -3660,7 +2538,7 @@
errorLine2=" ~~~~~~~~~~~~~~~~~~~~~~~~">
<location
file="src/main/java/androidx/media/app/NotificationCompat.java"
- line="101"
+ line="102"
column="23"/>
</issue>
@@ -3671,7 +2549,7 @@
errorLine2=" ~~~~~~~~~~~~">
<location
file="src/main/java/androidx/media/app/NotificationCompat.java"
- line="101"
+ line="102"
column="64"/>
</issue>
@@ -3682,7 +2560,7 @@
errorLine2=" ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~">
<location
file="src/main/java/androidx/media/app/NotificationCompat.java"
- line="138"
+ line="139"
column="27"/>
</issue>
@@ -3693,7 +2571,7 @@
errorLine2=" ~~~~~~~~~~">
<location
file="src/main/java/androidx/media/app/NotificationCompat.java"
- line="148"
+ line="149"
column="16"/>
</issue>
@@ -3704,7 +2582,7 @@
errorLine2=" ~~~~~~">
<location
file="src/main/java/androidx/media/app/NotificationCompat.java"
- line="148"
+ line="149"
column="55"/>
</issue>
@@ -3715,7 +2593,7 @@
errorLine2=" ~~~~~~~~~~">
<location
file="src/main/java/androidx/media/app/NotificationCompat.java"
- line="157"
+ line="158"
column="16"/>
</issue>
@@ -3726,7 +2604,7 @@
errorLine2=" ~~~~~~~~~~~~~~~~~~~~~~~~">
<location
file="src/main/java/androidx/media/app/NotificationCompat.java"
- line="157"
+ line="158"
column="43"/>
</issue>
@@ -3737,7 +2615,7 @@
errorLine2=" ~~~~~~~~~~">
<location
file="src/main/java/androidx/media/app/NotificationCompat.java"
- line="186"
+ line="187"
column="16"/>
</issue>
@@ -3748,7 +2626,7 @@
errorLine2=" ~~~~~~~~~~">
<location
file="src/main/java/androidx/media/app/NotificationCompat.java"
- line="199"
+ line="200"
column="16"/>
</issue>
@@ -3759,7 +2637,7 @@
errorLine2=" ~~~~~~~~~~~~~">
<location
file="src/main/java/androidx/media/app/NotificationCompat.java"
- line="199"
+ line="200"
column="49"/>
</issue>
@@ -3770,7 +2648,7 @@
errorLine2=" ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~">
<location
file="src/main/java/androidx/media/app/NotificationCompat.java"
- line="209"
+ line="210"
column="27"/>
</issue>
@@ -3781,7 +2659,7 @@
errorLine2=" ~~~~~~~~~~~">
<location
file="src/main/java/androidx/media/app/NotificationCompat.java"
- line="234"
+ line="235"
column="16"/>
</issue>
@@ -3792,7 +2670,7 @@
errorLine2=" ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~">
<location
file="src/main/java/androidx/media/app/NotificationCompat.java"
- line="234"
+ line="235"
column="44"/>
</issue>
@@ -3803,7 +2681,7 @@
errorLine2=" ~~~~~~~~~~~">
<location
file="src/main/java/androidx/media/app/NotificationCompat.java"
- line="302"
+ line="303"
column="16"/>
</issue>
@@ -3814,7 +2692,7 @@
errorLine2=" ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~">
<location
file="src/main/java/androidx/media/app/NotificationCompat.java"
- line="302"
+ line="303"
column="47"/>
</issue>
@@ -3825,7 +2703,7 @@
errorLine2=" ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~">
<location
file="src/main/java/androidx/media/app/NotificationCompat.java"
- line="387"
+ line="388"
column="27"/>
</issue>
@@ -3836,7 +2714,7 @@
errorLine2=" ~~~~~~~~~~~">
<location
file="src/main/java/androidx/media/app/NotificationCompat.java"
- line="401"
+ line="402"
column="16"/>
</issue>
@@ -3847,7 +2725,7 @@
errorLine2=" ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~">
<location
file="src/main/java/androidx/media/app/NotificationCompat.java"
- line="401"
+ line="402"
column="44"/>
</issue>
@@ -3858,7 +2736,7 @@
errorLine2=" ~~~~~~~~~~~">
<location
file="src/main/java/androidx/media/app/NotificationCompat.java"
- line="443"
+ line="444"
column="16"/>
</issue>
@@ -3869,7 +2747,7 @@
errorLine2=" ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~">
<location
file="src/main/java/androidx/media/app/NotificationCompat.java"
- line="443"
+ line="444"
column="47"/>
</issue>
@@ -3880,7 +2758,7 @@
errorLine2=" ~~~~~~~~~~~">
<location
file="src/main/java/androidx/media/app/NotificationCompat.java"
- line="475"
+ line="476"
column="16"/>
</issue>
@@ -3891,7 +2769,7 @@
errorLine2=" ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~">
<location
file="src/main/java/androidx/media/app/NotificationCompat.java"
- line="475"
+ line="476"
column="51"/>
</issue>
@@ -3924,7 +2802,7 @@
errorLine2=" ~~~~~~">
<location
file="src/main/java/android/support/v4/media/session/PlaybackStateCompat.java"
- line="616"
+ line="618"
column="31"/>
</issue>
@@ -3935,7 +2813,7 @@
errorLine2=" ~~~~">
<location
file="src/main/java/android/support/v4/media/session/PlaybackStateCompat.java"
- line="677"
+ line="679"
column="36"/>
</issue>
@@ -3946,7 +2824,7 @@
errorLine2=" ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~">
<location
file="src/main/java/android/support/v4/media/session/PlaybackStateCompat.java"
- line="739"
+ line="741"
column="12"/>
</issue>
@@ -3957,7 +2835,7 @@
errorLine2=" ~~~~~~~~~~~~">
<location
file="src/main/java/android/support/v4/media/session/PlaybackStateCompat.java"
- line="772"
+ line="774"
column="12"/>
</issue>
@@ -3968,7 +2846,7 @@
errorLine2=" ~~~~~~~~~~~~~~~~~~~">
<location
file="src/main/java/android/support/v4/media/session/PlaybackStateCompat.java"
- line="806"
+ line="808"
column="19"/>
</issue>
@@ -3979,7 +2857,7 @@
errorLine2=" ~~~~~~">
<location
file="src/main/java/android/support/v4/media/session/PlaybackStateCompat.java"
- line="806"
+ line="808"
column="57"/>
</issue>
@@ -3990,7 +2868,7 @@
errorLine2=" ~~~~~~">
<location
file="src/main/java/android/support/v4/media/session/PlaybackStateCompat.java"
- line="851"
+ line="854"
column="12"/>
</issue>
@@ -4001,7 +2879,7 @@
errorLine2=" ~~~~~~">
<location
file="src/main/java/android/support/v4/media/session/PlaybackStateCompat.java"
- line="915"
+ line="918"
column="35"/>
</issue>
@@ -4012,7 +2890,7 @@
errorLine2=" ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~">
<location
file="src/main/java/android/support/v4/media/session/PlaybackStateCompat.java"
- line="938"
+ line="941"
column="23"/>
</issue>
@@ -4023,7 +2901,7 @@
errorLine2=" ~~~~~~">
<location
file="src/main/java/android/support/v4/media/session/PlaybackStateCompat.java"
- line="938"
+ line="941"
column="73"/>
</issue>
@@ -4034,7 +2912,7 @@
errorLine2=" ~~~~~~">
<location
file="src/main/java/android/support/v4/media/session/PlaybackStateCompat.java"
- line="967"
+ line="970"
column="16"/>
</issue>
@@ -4045,7 +2923,7 @@
errorLine2=" ~~~~~~">
<location
file="src/main/java/android/support/v4/media/session/PlaybackStateCompat.java"
- line="997"
+ line="1000"
column="16"/>
</issue>
@@ -4056,7 +2934,7 @@
errorLine2=" ~~~~~~~~~~~~">
<location
file="src/main/java/android/support/v4/media/session/PlaybackStateCompat.java"
- line="1006"
+ line="1009"
column="16"/>
</issue>
@@ -4067,7 +2945,7 @@
errorLine2=" ~~~~~~">
<location
file="src/main/java/android/support/v4/media/session/PlaybackStateCompat.java"
- line="1029"
+ line="1032"
column="16"/>
</issue>
@@ -4078,7 +2956,7 @@
errorLine2=" ~~~~~~">
<location
file="src/main/java/android/support/v4/media/session/PlaybackStateCompat.java"
- line="1063"
+ line="1066"
column="28"/>
</issue>
@@ -4089,7 +2967,7 @@
errorLine2=" ~~~~~~~~~~~~">
<location
file="src/main/java/android/support/v4/media/session/PlaybackStateCompat.java"
- line="1063"
+ line="1066"
column="43"/>
</issue>
@@ -4100,7 +2978,7 @@
errorLine2=" ~~~~~~~">
<location
file="src/main/java/android/support/v4/media/session/PlaybackStateCompat.java"
- line="1090"
+ line="1093"
column="20"/>
</issue>
@@ -4111,7 +2989,7 @@
errorLine2=" ~~~~~~">
<location
file="src/main/java/android/support/v4/media/session/PlaybackStateCompat.java"
- line="1090"
+ line="1093"
column="38"/>
</issue>
@@ -4122,7 +3000,7 @@
errorLine2=" ~~~~~~~~~~~~">
<location
file="src/main/java/android/support/v4/media/session/PlaybackStateCompat.java"
- line="1101"
+ line="1104"
column="20"/>
</issue>
@@ -4133,7 +3011,7 @@
errorLine2=" ~~~~~~~~~~~~~~~~~~~">
<location
file="src/main/java/android/support/v4/media/session/PlaybackStateCompat.java"
- line="1136"
+ line="1139"
column="24"/>
</issue>
@@ -4144,7 +3022,7 @@
errorLine2=" ~~~~~~~">
<location
file="src/main/java/android/support/v4/media/session/PlaybackStateCompat.java"
- line="1183"
+ line="1186"
column="16"/>
</issue>
@@ -4155,7 +3033,7 @@
errorLine2=" ~~~~~~~">
<location
file="src/main/java/android/support/v4/media/session/PlaybackStateCompat.java"
- line="1221"
+ line="1224"
column="16"/>
</issue>
@@ -4166,7 +3044,7 @@
errorLine2=" ~~~~~~~">
<location
file="src/main/java/android/support/v4/media/session/PlaybackStateCompat.java"
- line="1237"
+ line="1240"
column="16"/>
</issue>
@@ -4177,7 +3055,7 @@
errorLine2=" ~~~~~~~">
<location
file="src/main/java/android/support/v4/media/session/PlaybackStateCompat.java"
- line="1272"
+ line="1275"
column="16"/>
</issue>
@@ -4188,7 +3066,7 @@
errorLine2=" ~~~~~~~">
<location
file="src/main/java/android/support/v4/media/session/PlaybackStateCompat.java"
- line="1297"
+ line="1300"
column="16"/>
</issue>
@@ -4199,7 +3077,7 @@
errorLine2=" ~~~~~~">
<location
file="src/main/java/android/support/v4/media/session/PlaybackStateCompat.java"
- line="1297"
+ line="1300"
column="40"/>
</issue>
@@ -4210,7 +3088,7 @@
errorLine2=" ~~~~~~">
<location
file="src/main/java/android/support/v4/media/session/PlaybackStateCompat.java"
- line="1297"
+ line="1300"
column="55"/>
</issue>
@@ -4221,7 +3099,7 @@
errorLine2=" ~~~~~~~">
<location
file="src/main/java/android/support/v4/media/session/PlaybackStateCompat.java"
- line="1312"
+ line="1315"
column="16"/>
</issue>
@@ -4232,7 +3110,7 @@
errorLine2=" ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~">
<location
file="src/main/java/android/support/v4/media/session/PlaybackStateCompat.java"
- line="1312"
+ line="1315"
column="40"/>
</issue>
@@ -4243,7 +3121,7 @@
errorLine2=" ~~~~~~~">
<location
file="src/main/java/android/support/v4/media/session/PlaybackStateCompat.java"
- line="1328"
+ line="1331"
column="16"/>
</issue>
@@ -4254,7 +3132,7 @@
errorLine2=" ~~~~~~~">
<location
file="src/main/java/android/support/v4/media/session/PlaybackStateCompat.java"
- line="1341"
+ line="1344"
column="16"/>
</issue>
@@ -4265,7 +3143,7 @@
errorLine2=" ~~~~~~~~~~~~">
<location
file="src/main/java/android/support/v4/media/session/PlaybackStateCompat.java"
- line="1341"
+ line="1344"
column="40"/>
</issue>
@@ -4276,7 +3154,7 @@
errorLine2=" ~~~~~~~">
<location
file="src/main/java/android/support/v4/media/session/PlaybackStateCompat.java"
- line="1354"
+ line="1357"
column="16"/>
</issue>
@@ -4287,7 +3165,7 @@
errorLine2=" ~~~~~~~~~~~~">
<location
file="src/main/java/android/support/v4/media/session/PlaybackStateCompat.java"
- line="1354"
+ line="1357"
column="66"/>
</issue>
@@ -4298,7 +3176,7 @@
errorLine2=" ~~~~~~~">
<location
file="src/main/java/android/support/v4/media/session/PlaybackStateCompat.java"
- line="1366"
+ line="1369"
column="16"/>
</issue>
@@ -4309,7 +3187,7 @@
errorLine2=" ~~~~~~">
<location
file="src/main/java/android/support/v4/media/session/PlaybackStateCompat.java"
- line="1366"
+ line="1369"
column="34"/>
</issue>
@@ -4320,7 +3198,7 @@
errorLine2=" ~~~~~~~~~~~~~~~~~~~">
<location
file="src/main/java/android/support/v4/media/session/PlaybackStateCompat.java"
- line="1374"
+ line="1377"
column="16"/>
</issue>
@@ -4331,7 +3209,7 @@
errorLine2=" ~~~~~~">
<location
file="src/main/java/android/support/v4/media/RatingCompat.java"
- line="126"
+ line="128"
column="31"/>
</issue>
@@ -4342,7 +3220,7 @@
errorLine2=" ~~~~~~~~~~~~">
<location
file="src/main/java/android/support/v4/media/RatingCompat.java"
- line="158"
+ line="160"
column="19"/>
</issue>
@@ -4353,7 +3231,7 @@
errorLine2=" ~~~~~~~~~~~~">
<location
file="src/main/java/android/support/v4/media/RatingCompat.java"
- line="179"
+ line="181"
column="19"/>
</issue>
@@ -4364,7 +3242,7 @@
errorLine2=" ~~~~~~~~~~~~">
<location
file="src/main/java/android/support/v4/media/RatingCompat.java"
- line="190"
+ line="192"
column="19"/>
</issue>
@@ -4375,7 +3253,7 @@
errorLine2=" ~~~~~~~~~~~~">
<location
file="src/main/java/android/support/v4/media/RatingCompat.java"
- line="206"
+ line="208"
column="19"/>
</issue>
@@ -4386,7 +3264,7 @@
errorLine2=" ~~~~~~~~~~~~">
<location
file="src/main/java/android/support/v4/media/RatingCompat.java"
- line="237"
+ line="239"
column="19"/>
</issue>
@@ -4397,7 +3275,7 @@
errorLine2=" ~~~~~~~~~~~~">
<location
file="src/main/java/android/support/v4/media/RatingCompat.java"
- line="332"
+ line="334"
column="19"/>
</issue>
@@ -4408,7 +3286,7 @@
errorLine2=" ~~~~~~">
<location
file="src/main/java/android/support/v4/media/RatingCompat.java"
- line="332"
+ line="334"
column="43"/>
</issue>
@@ -4419,7 +3297,7 @@
errorLine2=" ~~~~~~">
<location
file="src/main/java/android/support/v4/media/RatingCompat.java"
- line="375"
+ line="377"
column="12"/>
</issue>
@@ -4430,7 +3308,7 @@
errorLine2=" ~~~~~~~~">
<location
file="src/main/java/androidx/media/VolumeProviderCompat.java"
- line="188"
+ line="190"
column="29"/>
</issue>
@@ -4441,7 +3319,7 @@
errorLine2=" ~~~~~~">
<location
file="src/main/java/androidx/media/VolumeProviderCompat.java"
- line="200"
+ line="202"
column="12"/>
</issue>
@@ -4452,7 +3330,7 @@
errorLine2=" ~~~~~~~~~~~~~~~~~~~~">
<location
file="src/main/java/androidx/media/VolumeProviderCompat.java"
- line="236"
+ line="238"
column="46"/>
</issue>
diff --git a/media/media/src/main/java/android/support/v4/media/MediaBrowserCompat.java b/media/media/src/main/java/android/support/v4/media/MediaBrowserCompat.java
index c9aa019..fafb972 100644
--- a/media/media/src/main/java/android/support/v4/media/MediaBrowserCompat.java
+++ b/media/media/src/main/java/android/support/v4/media/MediaBrowserCompat.java
@@ -55,6 +55,7 @@
import android.content.Context;
import android.content.Intent;
import android.content.ServiceConnection;
+import android.media.MediaDescription;
import android.media.browse.MediaBrowser;
import android.os.BadParcelableException;
import android.os.Binder;
@@ -75,6 +76,7 @@
import android.text.TextUtils;
import android.util.Log;
+import androidx.annotation.DoNotInline;
import androidx.annotation.IntDef;
import androidx.annotation.NonNull;
import androidx.annotation.Nullable;
@@ -496,9 +498,9 @@
return null;
}
MediaBrowser.MediaItem itemFwk = (MediaBrowser.MediaItem) itemObj;
- int flags = itemFwk.getFlags();
+ int flags = Api21Impl.getFlags(itemFwk);
MediaDescriptionCompat descriptionCompat =
- MediaDescriptionCompat.fromMediaDescription(itemFwk.getDescription());
+ MediaDescriptionCompat.fromMediaDescription(Api21Impl.getDescription(itemFwk));
return new MediaItem(descriptionCompat, flags);
}
@@ -2364,4 +2366,19 @@
}
}
}
+
+ @RequiresApi(21)
+ private static class Api21Impl {
+ private Api21Impl() {}
+
+ @DoNotInline
+ static MediaDescription getDescription(MediaBrowser.MediaItem item) {
+ return item.getDescription();
+ }
+
+ @DoNotInline
+ static int getFlags(MediaBrowser.MediaItem item) {
+ return item.getFlags();
+ }
+ }
}
diff --git a/media/media/src/main/java/android/support/v4/media/MediaDescriptionCompat.java b/media/media/src/main/java/android/support/v4/media/MediaDescriptionCompat.java
index 07b3dcc..49628eb 100644
--- a/media/media/src/main/java/android/support/v4/media/MediaDescriptionCompat.java
+++ b/media/media/src/main/java/android/support/v4/media/MediaDescriptionCompat.java
@@ -28,7 +28,9 @@
import android.support.v4.media.session.MediaSessionCompat;
import android.text.TextUtils;
+import androidx.annotation.DoNotInline;
import androidx.annotation.Nullable;
+import androidx.annotation.RequiresApi;
import androidx.annotation.RestrictTo;
/**
@@ -336,13 +338,13 @@
if (mDescriptionFwk != null || Build.VERSION.SDK_INT < 21) {
return mDescriptionFwk;
}
- MediaDescription.Builder bob = new MediaDescription.Builder();
- bob.setMediaId(mMediaId);
- bob.setTitle(mTitle);
- bob.setSubtitle(mSubtitle);
- bob.setDescription(mDescription);
- bob.setIconBitmap(mIcon);
- bob.setIconUri(mIconUri);
+ MediaDescription.Builder bob = Api21Impl.createBuilder();
+ Api21Impl.setMediaId(bob, mMediaId);
+ Api21Impl.setTitle(bob, mTitle);
+ Api21Impl.setSubtitle(bob, mSubtitle);
+ Api21Impl.setDescription(bob, mDescription);
+ Api21Impl.setIconBitmap(bob, mIcon);
+ Api21Impl.setIconUri(bob, mIconUri);
// Media URI was not added until API 23, so add it to the Bundle of extras to
// ensure the data is not lost - this ensures that
// fromMediaDescription(getMediaDescription(mediaDescriptionCompat)) returns
@@ -355,11 +357,11 @@
}
extras.putParcelable(DESCRIPTION_KEY_MEDIA_URI, mMediaUri);
}
- bob.setExtras(extras);
+ Api21Impl.setExtras(bob, extras);
if (Build.VERSION.SDK_INT >= 23) {
- bob.setMediaUri(mMediaUri);
+ Api23Impl.setMediaUri(bob, mMediaUri);
}
- mDescriptionFwk = bob.build();
+ mDescriptionFwk = Api21Impl.build(bob);
return mDescriptionFwk;
}
@@ -380,13 +382,13 @@
if (descriptionObj != null && Build.VERSION.SDK_INT >= 21) {
Builder bob = new Builder();
MediaDescription description = (MediaDescription) descriptionObj;
- bob.setMediaId(description.getMediaId());
- bob.setTitle(description.getTitle());
- bob.setSubtitle(description.getSubtitle());
- bob.setDescription(description.getDescription());
- bob.setIconBitmap(description.getIconBitmap());
- bob.setIconUri(description.getIconUri());
- Bundle extras = description.getExtras();
+ bob.setMediaId(Api21Impl.getMediaId(description));
+ bob.setTitle(Api21Impl.getTitle(description));
+ bob.setSubtitle(Api21Impl.getSubtitle(description));
+ bob.setDescription(Api21Impl.getDescription(description));
+ bob.setIconBitmap(Api21Impl.getIconBitmap(description));
+ bob.setIconUri(Api21Impl.getIconUri(description));
+ Bundle extras = Api21Impl.getExtras(description);
if (extras != null) {
extras = MediaSessionCompat.unparcelWithClassLoader(extras);
}
@@ -412,7 +414,7 @@
if (mediaUri != null) {
bob.setMediaUri(mediaUri);
} else if (Build.VERSION.SDK_INT >= 23) {
- bob.setMediaUri(description.getMediaUri());
+ bob.setMediaUri(Api23Impl.getMediaUri(description));
}
MediaDescriptionCompat descriptionCompat = bob.build();
descriptionCompat.mDescriptionFwk = description;
@@ -561,4 +563,120 @@
mIconUri, mExtras, mMediaUri);
}
}
+
+ @RequiresApi(21)
+ private static class Api21Impl {
+ private Api21Impl() {}
+
+ @DoNotInline
+ static MediaDescription.Builder createBuilder() {
+ return new MediaDescription.Builder();
+ }
+
+ @DoNotInline
+ static void setMediaId(MediaDescription.Builder builder,
+ @Nullable String mediaId) {
+ builder.setMediaId(mediaId);
+ }
+
+ @DoNotInline
+ static void setTitle(MediaDescription.Builder builder,
+ @Nullable CharSequence title) {
+ builder.setTitle(title);
+ }
+
+ @DoNotInline
+ static void setSubtitle(MediaDescription.Builder builder,
+ @Nullable CharSequence subtitle) {
+ builder.setSubtitle(subtitle);
+ }
+
+ @DoNotInline
+ static void setDescription(MediaDescription.Builder builder,
+ @Nullable CharSequence description) {
+ builder.setDescription(description);
+ }
+
+ @DoNotInline
+ static void setIconBitmap(MediaDescription.Builder builder,
+ @Nullable Bitmap icon) {
+ builder.setIconBitmap(icon);
+ }
+
+ @DoNotInline
+ static void setIconUri(MediaDescription.Builder builder,
+ @Nullable Uri iconUri) {
+ builder.setIconUri(iconUri);
+ }
+
+ @DoNotInline
+ static void setExtras(MediaDescription.Builder builder,
+ @Nullable Bundle extras) {
+ builder.setExtras(extras);
+ }
+
+ @DoNotInline
+ static MediaDescription build(MediaDescription.Builder builder) {
+ return builder.build();
+ }
+
+ @DoNotInline
+ @Nullable
+ static String getMediaId(MediaDescription description) {
+ return description.getMediaId();
+ }
+
+ @DoNotInline
+ @Nullable
+ static CharSequence getTitle(MediaDescription description) {
+ return description.getTitle();
+ }
+
+ @DoNotInline
+ @Nullable
+ static CharSequence getSubtitle(MediaDescription description) {
+ return description.getSubtitle();
+ }
+
+ @DoNotInline
+ @Nullable
+ static CharSequence getDescription(MediaDescription description) {
+ return description.getDescription();
+ }
+
+ @DoNotInline
+ @Nullable
+ static Bitmap getIconBitmap(MediaDescription description) {
+ return description.getIconBitmap();
+ }
+
+ @DoNotInline
+ @Nullable
+ static Uri getIconUri(MediaDescription description) {
+ return description.getIconUri();
+ }
+
+ @DoNotInline
+ @Nullable
+ static Bundle getExtras(MediaDescription description) {
+ return description.getExtras();
+ }
+ }
+
+ @RequiresApi(23)
+ private static class Api23Impl {
+ private Api23Impl() {}
+
+ @DoNotInline
+ static void setMediaUri(MediaDescription.Builder builder,
+ @Nullable Uri mediaUri) {
+ builder.setMediaUri(mediaUri);
+ }
+
+ @DoNotInline
+ @Nullable
+ static Uri getMediaUri(MediaDescription description) {
+ return description.getMediaUri();
+ }
+ }
}
diff --git a/media/media/src/main/java/android/support/v4/media/RatingCompat.java b/media/media/src/main/java/android/support/v4/media/RatingCompat.java
index 42b6da0..6578a65 100644
--- a/media/media/src/main/java/android/support/v4/media/RatingCompat.java
+++ b/media/media/src/main/java/android/support/v4/media/RatingCompat.java
@@ -26,7 +26,9 @@
import android.os.Parcelable;
import android.util.Log;
+import androidx.annotation.DoNotInline;
import androidx.annotation.IntDef;
+import androidx.annotation.RequiresApi;
import androidx.annotation.RestrictTo;
import java.lang.annotation.Retention;
@@ -331,25 +333,25 @@
*/
public static RatingCompat fromRating(Object ratingObj) {
if (ratingObj != null && Build.VERSION.SDK_INT >= 19) {
- final int ratingStyle = ((Rating) ratingObj).getRatingStyle();
+ final int ratingStyle = Api19Impl.getRatingStyle((Rating) ratingObj);
final RatingCompat rating;
- if (((Rating) ratingObj).isRated()) {
+ if (Api19Impl.isRated((Rating) ratingObj)) {
switch (ratingStyle) {
case RATING_HEART:
- rating = newHeartRating(((Rating) ratingObj).hasHeart());
+ rating = newHeartRating(Api19Impl.hasHeart((Rating) ratingObj));
break;
case RATING_THUMB_UP_DOWN:
- rating = newThumbRating(((Rating) ratingObj).isThumbUp());
+ rating = newThumbRating(Api19Impl.isThumbUp((Rating) ratingObj));
break;
case RATING_3_STARS:
case RATING_4_STARS:
case RATING_5_STARS:
rating = newStarRating(ratingStyle,
- ((Rating) ratingObj).getStarRating());
+ Api19Impl.getStarRating((Rating) ratingObj));
break;
case RATING_PERCENTAGE:
rating = newPercentageRating(
- ((Rating) ratingObj).getPercentRating());
+ Api19Impl.getPercentRating((Rating) ratingObj));
break;
default:
return null;
@@ -377,27 +379,87 @@
if (isRated()) {
switch (mRatingStyle) {
case RATING_HEART:
- mRatingObj = Rating.newHeartRating(hasHeart());
+ mRatingObj = Api19Impl.newHeartRating(hasHeart());
break;
case RATING_THUMB_UP_DOWN:
- mRatingObj = Rating.newThumbRating(isThumbUp());
+ mRatingObj = Api19Impl.newThumbRating(isThumbUp());
break;
case RATING_3_STARS:
case RATING_4_STARS:
case RATING_5_STARS:
- mRatingObj = Rating.newStarRating(mRatingStyle,
+ mRatingObj = Api19Impl.newStarRating(mRatingStyle,
getStarRating());
break;
case RATING_PERCENTAGE:
- mRatingObj = Rating.newPercentageRating(getPercentRating());
+ mRatingObj = Api19Impl.newPercentageRating(getPercentRating());
break;
default:
return null;
}
} else {
- mRatingObj = Rating.newUnratedRating(mRatingStyle);
+ mRatingObj = Api19Impl.newUnratedRating(mRatingStyle);
}
}
return mRatingObj;
}
+
+ @RequiresApi(19)
+ private static class Api19Impl {
+ private Api19Impl() {}
+
+ @DoNotInline
+ static int getRatingStyle(Rating rating) {
+ return rating.getRatingStyle();
+ }
+
+ @DoNotInline
+ static boolean isRated(Rating rating) {
+ return rating.isRated();
+ }
+
+ @DoNotInline
+ static boolean hasHeart(Rating rating) {
+ return rating.hasHeart();
+ }
+
+ @DoNotInline
+ static boolean isThumbUp(Rating rating) {
+ return rating.isThumbUp();
+ }
+
+ @DoNotInline
+ static float getStarRating(Rating rating) {
+ return rating.getStarRating();
+ }
+
+ @DoNotInline
+ static float getPercentRating(Rating rating) {
+ return rating.getPercentRating();
+ }
+
+ @DoNotInline
+ static Rating newHeartRating(boolean hasHeart) {
+ return Rating.newHeartRating(hasHeart);
+ }
+
+ @DoNotInline
+ static Rating newThumbRating(boolean thumbIsUp) {
+ return Rating.newThumbRating(thumbIsUp);
+ }
+
+ @DoNotInline
+ static Rating newStarRating(int starRatingStyle, float starRating) {
+ return Rating.newStarRating(starRatingStyle, starRating);
+ }
+
+ @DoNotInline
+ static Rating newPercentageRating(float percent) {
+ return Rating.newPercentageRating(percent);
+ }
+
+ @DoNotInline
+ static Rating newUnratedRating(int ratingStyle) {
+ return Rating.newUnratedRating(ratingStyle);
+ }
+ }
}
diff --git a/media/media/src/main/java/android/support/v4/media/session/MediaControllerCompat.java b/media/media/src/main/java/android/support/v4/media/session/MediaControllerCompat.java
index dfe730b..7f71344 100644
--- a/media/media/src/main/java/android/support/v4/media/session/MediaControllerCompat.java
+++ b/media/media/src/main/java/android/support/v4/media/session/MediaControllerCompat.java
@@ -163,12 +163,7 @@
activity.getWindow().getDecorView().setTag(
R.id.media_controller_compat_view_tag, mediaController);
if (android.os.Build.VERSION.SDK_INT >= 21) {
- MediaController controllerFwk = null;
- if (mediaController != null) {
- Object sessionTokenObj = mediaController.getSessionToken().getToken();
- controllerFwk = new MediaController(activity, (MediaSession.Token) sessionTokenObj);
- }
- activity.setMediaController(controllerFwk);
+ MediaControllerImplApi21.setMediaController(activity, mediaController);
}
}
@@ -189,13 +184,7 @@
if (tag instanceof MediaControllerCompat) {
return (MediaControllerCompat) tag;
} else if (android.os.Build.VERSION.SDK_INT >= 21) {
- MediaController controllerFwk = activity.getMediaController();
- if (controllerFwk == null) {
- return null;
- }
- MediaSession.Token sessionTokenFwk = controllerFwk.getSessionToken();
- return new MediaControllerCompat(activity,
- MediaSessionCompat.Token.fromToken(sessionTokenFwk));
+ return MediaControllerImplApi21.getMediaController(activity);
}
return null;
}
@@ -238,7 +227,9 @@
}
mToken = session.getSessionToken();
- if (android.os.Build.VERSION.SDK_INT >= 21) {
+ if (Build.VERSION.SDK_INT >= 29) {
+ mImpl = new MediaControllerImplApi29(context, mToken);
+ } else if (Build.VERSION.SDK_INT >= 21) {
mImpl = new MediaControllerImplApi21(context, mToken);
} else {
mImpl = new MediaControllerImplBase(mToken);
@@ -2027,7 +2018,7 @@
private HashMap<Callback, ExtraCallback> mCallbackMap = new HashMap<>();
- private Bundle mSessionInfo;
+ protected Bundle mSessionInfo;
final MediaSessionCompat.Token mSessionToken;
@@ -2090,7 +2081,16 @@
@Override
public TransportControls getTransportControls() {
- return new TransportControlsApi21(mControllerFwk.getTransportControls());
+ MediaController.TransportControls controlsFwk = mControllerFwk.getTransportControls();
+ if (Build.VERSION.SDK_INT >= 29) {
+ return new TransportControlsApi29(controlsFwk);
+ } else if (Build.VERSION.SDK_INT >= 24) {
+ return new TransportControlsApi24(controlsFwk);
+ } else if (Build.VERSION.SDK_INT >= 23) {
+ return new TransportControlsApi23(controlsFwk);
+ } else {
+ return new TransportControlsApi21(controlsFwk);
+ }
}
@Override
@@ -2265,10 +2265,7 @@
return new Bundle(mSessionInfo);
}
- // Get the info from the connected session.
- if (Build.VERSION.SDK_INT >= 29) {
- mSessionInfo = mControllerFwk.getSessionInfo();
- } else if (mSessionToken.getExtraBinder() != null) {
+ if (mSessionToken.getExtraBinder() != null) {
try {
mSessionInfo = mSessionToken.getExtraBinder().getSessionInfo();
} catch (RemoteException e) {
@@ -2310,6 +2307,27 @@
mPendingCallbacks.clear();
}
+ static void setMediaController(@NonNull Activity activity,
+ @Nullable MediaControllerCompat mediaControllerCompat) {
+ MediaController controllerFwk = null;
+ if (mediaControllerCompat != null) {
+ Object sessionTokenObj = mediaControllerCompat.getSessionToken().getToken();
+ controllerFwk = new MediaController(activity, (MediaSession.Token) sessionTokenObj);
+ }
+ activity.setMediaController(controllerFwk);
+ }
+
+ @Nullable
+ static MediaControllerCompat getMediaController(@NonNull Activity activity) {
+ MediaController controllerFwk = activity.getMediaController();
+ if (controllerFwk == null) {
+ return null;
+ }
+ MediaSession.Token sessionTokenFwk = controllerFwk.getSessionToken();
+ return new MediaControllerCompat(activity,
+ MediaSessionCompat.Token.fromToken(sessionTokenFwk));
+ }
+
private static class ExtraBinderRequestResultReceiver extends ResultReceiver {
private WeakReference<MediaControllerImplApi21> mMediaControllerImpl;
@@ -2380,6 +2398,23 @@
}
}
+ @RequiresApi(29)
+ static class MediaControllerImplApi29 extends MediaControllerImplApi21 {
+ MediaControllerImplApi29(Context context, MediaSessionCompat.Token sessionToken) {
+ super(context, sessionToken);
+ }
+
+ @Override
+ public Bundle getSessionInfo() {
+ if (mSessionInfo != null) {
+ return new Bundle(mSessionInfo);
+ }
+ mSessionInfo = mControllerFwk.getSessionInfo();
+ mSessionInfo = MediaSessionCompat.unparcelWithClassLoader(mSessionInfo);
+ return mSessionInfo == null ? Bundle.EMPTY : new Bundle(mSessionInfo);
+ }
+ }
+
@RequiresApi(21)
static class TransportControlsApi21 extends TransportControls {
protected final MediaController.TransportControls mControlsFwk;
@@ -2390,19 +2425,11 @@
@Override
public void prepare() {
- if (Build.VERSION.SDK_INT >= 24) {
- mControlsFwk.prepare();
- return;
- }
sendCustomAction(MediaSessionCompat.ACTION_PREPARE, null);
}
@Override
public void prepareFromMediaId(String mediaId, Bundle extras) {
- if (Build.VERSION.SDK_INT >= 24) {
- mControlsFwk.prepareFromMediaId(mediaId, extras);
- return;
- }
Bundle bundle = new Bundle();
bundle.putString(MediaSessionCompat.ACTION_ARGUMENT_MEDIA_ID, mediaId);
bundle.putBundle(MediaSessionCompat.ACTION_ARGUMENT_EXTRAS, extras);
@@ -2411,10 +2438,6 @@
@Override
public void prepareFromSearch(String query, Bundle extras) {
- if (Build.VERSION.SDK_INT >= 24) {
- mControlsFwk.prepareFromSearch(query, extras);
- return;
- }
Bundle bundle = new Bundle();
bundle.putString(MediaSessionCompat.ACTION_ARGUMENT_QUERY, query);
bundle.putBundle(MediaSessionCompat.ACTION_ARGUMENT_EXTRAS, extras);
@@ -2423,10 +2446,6 @@
@Override
public void prepareFromUri(Uri uri, Bundle extras) {
- if (Build.VERSION.SDK_INT >= 24) {
- mControlsFwk.prepareFromUri(uri, extras);
- return;
- }
Bundle bundle = new Bundle();
bundle.putParcelable(MediaSessionCompat.ACTION_ARGUMENT_URI, uri);
bundle.putBundle(MediaSessionCompat.ACTION_ARGUMENT_EXTRAS, extras);
@@ -2491,10 +2510,6 @@
if (speed == 0.0f) {
throw new IllegalArgumentException("speed must not be zero");
}
- if (Build.VERSION.SDK_INT >= 29) {
- mControlsFwk.setPlaybackSpeed(speed);
- return;
- }
Bundle bundle = new Bundle();
bundle.putFloat(MediaSessionCompat.ACTION_ARGUMENT_PLAYBACK_SPEED, speed);
sendCustomAction(MediaSessionCompat.ACTION_SET_PLAYBACK_SPEED, bundle);
@@ -2533,10 +2548,6 @@
@Override
public void playFromUri(Uri uri, Bundle extras) {
- if (Build.VERSION.SDK_INT >= 23) {
- mControlsFwk.playFromUri(uri, extras);
- return;
- }
if (uri == null || Uri.EMPTY.equals(uri)) {
throw new IllegalArgumentException(
"You must specify a non-empty Uri for playFromUri.");
@@ -2564,4 +2575,58 @@
mControlsFwk.sendCustomAction(action, args);
}
}
+
+ @RequiresApi(23)
+ static class TransportControlsApi23 extends TransportControlsApi21 {
+ TransportControlsApi23(MediaController.TransportControls controlsFwk) {
+ super(controlsFwk);
+ }
+
+ @Override
+ public void playFromUri(Uri uri, Bundle extras) {
+ mControlsFwk.playFromUri(uri, extras);
+ }
+ }
+
+ @RequiresApi(24)
+ static class TransportControlsApi24 extends TransportControlsApi23 {
+ TransportControlsApi24(MediaController.TransportControls controlsFwk) {
+ super(controlsFwk);
+ }
+
+ @Override
+ public void prepare() {
+ mControlsFwk.prepare();
+ }
+
+ @Override
+ public void prepareFromMediaId(String mediaId, Bundle extras) {
+ mControlsFwk.prepareFromMediaId(mediaId, extras);
+ }
+
+ @Override
+ public void prepareFromSearch(String query, Bundle extras) {
+ mControlsFwk.prepareFromSearch(query, extras);
+ }
+
+ @Override
+ public void prepareFromUri(Uri uri, Bundle extras) {
+ mControlsFwk.prepareFromUri(uri, extras);
+ }
+ }
+
+ @RequiresApi(29)
+ static class TransportControlsApi29 extends TransportControlsApi24 {
+ TransportControlsApi29(MediaController.TransportControls controlsFwk) {
+ super(controlsFwk);
+ }
+
+ @Override
+ public void setPlaybackSpeed(float speed) {
+ if (speed == 0.0f) {
+ throw new IllegalArgumentException("speed must not be zero");
+ }
+ mControlsFwk.setPlaybackSpeed(speed);
+ }
+ }
}
diff --git a/media/media/src/main/java/android/support/v4/media/session/MediaSessionCompat.java b/media/media/src/main/java/android/support/v4/media/session/MediaSessionCompat.java
index 5518d39..5f0fe6b 100644
--- a/media/media/src/main/java/android/support/v4/media/session/MediaSessionCompat.java
+++ b/media/media/src/main/java/android/support/v4/media/session/MediaSessionCompat.java
@@ -65,6 +65,7 @@
import android.view.KeyEvent;
import android.view.ViewConfiguration;
+import androidx.annotation.DoNotInline;
import androidx.annotation.GuardedBy;
import androidx.annotation.IntDef;
import androidx.annotation.NonNull;
@@ -570,13 +571,14 @@
}
if (android.os.Build.VERSION.SDK_INT >= 21) {
- MediaSession sessionFwk = createFwkMediaSession(context, tag, sessionInfo);
if (android.os.Build.VERSION.SDK_INT >= 29) {
- mImpl = new MediaSessionImplApi29(sessionFwk, session2Token, sessionInfo);
+ mImpl = new MediaSessionImplApi29(context, tag, session2Token, sessionInfo);
} else if (android.os.Build.VERSION.SDK_INT >= 28) {
- mImpl = new MediaSessionImplApi28(sessionFwk, session2Token, sessionInfo);
+ mImpl = new MediaSessionImplApi28(context, tag, session2Token, sessionInfo);
+ } else if (android.os.Build.VERSION.SDK_INT >= 22) {
+ mImpl = new MediaSessionImplApi22(context, tag, session2Token, sessionInfo);
} else {
- mImpl = new MediaSessionImplApi21(sessionFwk, session2Token, sessionInfo);
+ mImpl = new MediaSessionImplApi21(context, tag, session2Token, sessionInfo);
}
// Set default callback to respond to controllers' extra binder requests.
Handler handler = new Handler(Looper.myLooper() != null
@@ -606,16 +608,6 @@
mController = new MediaControllerCompat(context, this);
}
- @RequiresApi(21)
- private MediaSession createFwkMediaSession(Context context, String tag,
- Bundle sessionInfo) {
- if (android.os.Build.VERSION.SDK_INT >= 29) {
- return new MediaSession(context, tag, sessionInfo);
- } else {
- return new MediaSession(context, tag);
- }
- }
-
/**
* Adds a callback to receive updates on for the MediaSession. This includes
* media button and volume events. The caller's thread will be used to post
@@ -2228,7 +2220,7 @@
if (mItemFwk != null || android.os.Build.VERSION.SDK_INT < 21) {
return mItemFwk;
}
- mItemFwk = new MediaSession.QueueItem(
+ mItemFwk = Api21Impl.createQueueItem(
(MediaDescription) mDescription.getMediaDescription(),
mId);
return mItemFwk;
@@ -2249,10 +2241,10 @@
return null;
}
MediaSession.QueueItem queueItemObj = (MediaSession.QueueItem) queueItem;
- Object descriptionObj = queueItemObj.getDescription();
+ Object descriptionObj = Api21Impl.getDescription(queueItemObj);
MediaDescriptionCompat description = MediaDescriptionCompat.fromMediaDescription(
descriptionObj);
- long id = queueItemObj.getQueueId();
+ long id = Api21Impl.getQueueId(queueItemObj);
return new QueueItem(queueItemObj, description, id);
}
@@ -2297,6 +2289,26 @@
"Description=" + mDescription +
", Id=" + mId + " }";
}
+
+ @RequiresApi(21)
+ private static class Api21Impl {
+ private Api21Impl() {}
+
+ @DoNotInline
+ static MediaSession.QueueItem createQueueItem(MediaDescription description, long id) {
+ return new MediaSession.QueueItem(description, id);
+ }
+
+ @DoNotInline
+ static MediaDescription getDescription(MediaSession.QueueItem queueItem) {
+ return queueItem.getDescription();
+ }
+
+ @DoNotInline
+ static long getQueueId(MediaSession.QueueItem queueItem) {
+ return queueItem.getQueueId();
+ }
+ }
}
/**
@@ -3802,9 +3814,9 @@
@GuardedBy("mLock")
RemoteUserInfo mRemoteUserInfo;
- MediaSessionImplApi21(MediaSession sessionFwk, VersionedParcelable session2Token,
+ MediaSessionImplApi21(Context context, String tag, VersionedParcelable session2Token,
Bundle sessionInfo) {
- mSessionFwk = sessionFwk;
+ mSessionFwk = createFwkMediaSession(context, tag, sessionInfo);
mToken = new Token(mSessionFwk.getSessionToken(), new ExtraSession(), session2Token);
mSessionInfo = sessionInfo;
// For backward compatibility, these flags are always set.
@@ -3823,6 +3835,10 @@
setFlags(FLAG_HANDLES_MEDIA_BUTTONS | FLAG_HANDLES_TRANSPORT_CONTROLS);
}
+ public MediaSession createFwkMediaSession(Context context, String tag, Bundle sessionInfo) {
+ return new MediaSession(context, tag);
+ }
+
@Override
public void setCallback(Callback callback, Handler handler) {
synchronized (mLock) {
@@ -3968,11 +3984,7 @@
@Override
public void setRatingType(@RatingCompat.Style int type) {
- if (android.os.Build.VERSION.SDK_INT < 22) {
- mRatingType = type;
- } else {
- mSessionFwk.setRatingType(type);
- }
+ mRatingType = type;
}
@Override
@@ -4384,11 +4396,28 @@
}
}
- @RequiresApi(28)
- static class MediaSessionImplApi28 extends MediaSessionImplApi21 {
- MediaSessionImplApi28(MediaSession sessionFwk, VersionedParcelable session2Token,
+ @RequiresApi(22)
+ static class MediaSessionImplApi22 extends MediaSessionImplApi21 {
+ MediaSessionImplApi22(Context context, String tag, VersionedParcelable session2Token,
Bundle sessionInfo) {
- super(sessionFwk, session2Token, sessionInfo);
+ super(context, tag, session2Token, sessionInfo);
+ }
+
+ MediaSessionImplApi22(Object mediaSession) {
+ super(mediaSession);
+ }
+
+ @Override
+ public void setRatingType(@RatingCompat.Style int type) {
+ mSessionFwk.setRatingType(type);
+ }
+ }
+
+ @RequiresApi(28)
+ static class MediaSessionImplApi28 extends MediaSessionImplApi22 {
+ MediaSessionImplApi28(Context context, String tag, VersionedParcelable session2Token,
+ Bundle sessionInfo) {
+ super(context, tag, session2Token, sessionInfo);
}
MediaSessionImplApi28(Object mediaSession) {
@@ -4411,14 +4440,19 @@
@RequiresApi(29)
static class MediaSessionImplApi29 extends MediaSessionImplApi28 {
- MediaSessionImplApi29(MediaSession sessionFwk, VersionedParcelable session2Token,
+ MediaSessionImplApi29(Context context, String tag, VersionedParcelable session2Token,
Bundle sessionInfo) {
- super(sessionFwk, session2Token, sessionInfo);
+ super(context, tag, session2Token, sessionInfo);
}
MediaSessionImplApi29(Object mediaSession) {
super(mediaSession);
mSessionInfo = ((MediaSession) mediaSession).getController().getSessionInfo();
}
+
+ @Override
+ public MediaSession createFwkMediaSession(Context context, String tag, Bundle sessionInfo) {
+ return new MediaSession(context, tag, sessionInfo);
+ }
}
}
diff --git a/media/media/src/main/java/android/support/v4/media/session/PlaybackStateCompat.java b/media/media/src/main/java/android/support/v4/media/session/PlaybackStateCompat.java
index d51a003..1026438 100644
--- a/media/media/src/main/java/android/support/v4/media/session/PlaybackStateCompat.java
+++ b/media/media/src/main/java/android/support/v4/media/session/PlaybackStateCompat.java
@@ -28,9 +28,11 @@
import android.text.TextUtils;
import android.view.KeyEvent;
+import androidx.annotation.DoNotInline;
import androidx.annotation.IntDef;
import androidx.annotation.LongDef;
import androidx.annotation.Nullable;
+import androidx.annotation.RequiresApi;
import androidx.annotation.RestrictTo;
import java.lang.annotation.Retention;
@@ -806,7 +808,8 @@
public static PlaybackStateCompat fromPlaybackState(Object stateObj) {
if (stateObj != null && Build.VERSION.SDK_INT >= 21) {
PlaybackState stateFwk = (PlaybackState) stateObj;
- List<PlaybackState.CustomAction> customActionFwks = stateFwk.getCustomActions();
+ List<PlaybackState.CustomAction> customActionFwks =
+ Api21Impl.getCustomActions(stateFwk);
List<PlaybackStateCompat.CustomAction> customActions = null;
if (customActionFwks != null) {
customActions = new ArrayList<>(customActionFwks.size());
@@ -816,22 +819,22 @@
}
Bundle extras;
if (Build.VERSION.SDK_INT >= 22) {
- extras = stateFwk.getExtras();
+ extras = Api22Impl.getExtras(stateFwk);
MediaSessionCompat.ensureClassLoader(extras);
} else {
extras = null;
}
PlaybackStateCompat stateCompat = new PlaybackStateCompat(
- stateFwk.getState(),
- stateFwk.getPosition(),
- stateFwk.getBufferedPosition(),
- stateFwk.getPlaybackSpeed(),
- stateFwk.getActions(),
+ Api21Impl.getState(stateFwk),
+ Api21Impl.getPosition(stateFwk),
+ Api21Impl.getBufferedPosition(stateFwk),
+ Api21Impl.getPlaybackSpeed(stateFwk),
+ Api21Impl.getActions(stateFwk),
ERROR_CODE_UNKNOWN_ERROR,
- stateFwk.getErrorMessage(),
- stateFwk.getLastPositionUpdateTime(),
+ Api21Impl.getErrorMessage(stateFwk),
+ Api21Impl.getLastPositionUpdateTime(stateFwk),
customActions,
- stateFwk.getActiveQueueItemId(),
+ Api21Impl.getActiveQueueItemId(stateFwk),
extras);
stateCompat.mStateFwk = stateFwk;
return stateCompat;
@@ -850,20 +853,20 @@
*/
public Object getPlaybackState() {
if (mStateFwk == null && Build.VERSION.SDK_INT >= 21) {
- PlaybackState.Builder builder = new PlaybackState.Builder();
- builder.setState(mState, mPosition, mSpeed, mUpdateTime);
- builder.setBufferedPosition(mBufferedPosition);
- builder.setActions(mActions);
- builder.setErrorMessage(mErrorMessage);
+ PlaybackState.Builder builder = Api21Impl.createBuilder();
+ Api21Impl.setState(builder, mState, mPosition, mSpeed, mUpdateTime);
+ Api21Impl.setBufferedPosition(builder, mBufferedPosition);
+ Api21Impl.setActions(builder, mActions);
+ Api21Impl.setErrorMessage(builder, mErrorMessage);
for (PlaybackStateCompat.CustomAction customAction : mCustomActions) {
- builder.addCustomAction(
+ Api21Impl.addCustomAction(builder,
(PlaybackState.CustomAction) customAction.getCustomAction());
}
- builder.setActiveQueueItemId(mActiveItemId);
+ Api21Impl.setActiveQueueItemId(builder, mActiveItemId);
if (Build.VERSION.SDK_INT >= 22) {
- builder.setExtras(mExtras);
+ Api22Impl.setExtras(builder, mExtras);
}
- mStateFwk = builder.build();
+ mStateFwk = Api21Impl.build(builder);
}
return mStateFwk;
}
@@ -942,13 +945,13 @@
PlaybackState.CustomAction customActionFwk =
(PlaybackState.CustomAction) customActionObj;
- Bundle extras = customActionFwk.getExtras();
+ Bundle extras = Api21Impl.getExtras(customActionFwk);
MediaSessionCompat.ensureClassLoader(extras);
PlaybackStateCompat.CustomAction customActionCompat =
new PlaybackStateCompat.CustomAction(
- customActionFwk.getAction(),
- customActionFwk.getName(),
- customActionFwk.getIcon(),
+ Api21Impl.getAction(customActionFwk),
+ Api21Impl.getName(customActionFwk),
+ Api21Impl.getIcon(customActionFwk),
extras);
customActionCompat.mCustomActionFwk = customActionFwk;
return customActionCompat;
@@ -969,10 +972,10 @@
return mCustomActionFwk;
}
- PlaybackState.CustomAction.Builder builder = new PlaybackState.CustomAction.Builder(
- mAction, mName, mIcon);
- builder.setExtras(mExtras);
- return builder.build();
+ PlaybackState.CustomAction.Builder builder =
+ Api21Impl.createCustomActionBuilder(mAction, mName, mIcon);
+ Api21Impl.setExtras(builder, mExtras);
+ return Api21Impl.build(builder);
}
public static final Parcelable.Creator<PlaybackStateCompat.CustomAction> CREATOR
@@ -1377,4 +1380,147 @@
mCustomActions, mActiveItemId, mExtras);
}
}
-}
+
+ @RequiresApi(21)
+ private static class Api21Impl {
+ private Api21Impl() {}
+
+ @DoNotInline
+ static PlaybackState.Builder createBuilder() {
+ return new PlaybackState.Builder();
+ }
+
+ @DoNotInline
+ static void setState(PlaybackState.Builder builder, int state, long position,
+ float playbackSpeed, long updateTime) {
+ builder.setState(state, position, playbackSpeed, updateTime);
+ }
+
+ @DoNotInline
+ static void setBufferedPosition(PlaybackState.Builder builder, long bufferedPosition) {
+ builder.setBufferedPosition(bufferedPosition);
+ }
+
+ @DoNotInline
+ static void setActions(PlaybackState.Builder builder, long actions) {
+ builder.setActions(actions);
+ }
+
+ @DoNotInline
+ static void setErrorMessage(PlaybackState.Builder builder, CharSequence error) {
+ builder.setErrorMessage(error);
+ }
+
+ @DoNotInline
+ static void addCustomAction(PlaybackState.Builder builder,
+ PlaybackState.CustomAction customAction) {
+ builder.addCustomAction(customAction);
+ }
+
+ @DoNotInline
+ static void setActiveQueueItemId(PlaybackState.Builder builder, long id) {
+ builder.setActiveQueueItemId(id);
+ }
+
+ @DoNotInline
+ static List<PlaybackState.CustomAction> getCustomActions(PlaybackState state) {
+ return state.getCustomActions();
+ }
+
+ @DoNotInline
+ static PlaybackState build(PlaybackState.Builder builder) {
+ return builder.build();
+ }
+
+ @DoNotInline
+ static int getState(PlaybackState state) {
+ return state.getState();
+ }
+
+ @DoNotInline
+ static long getPosition(PlaybackState state) {
+ return state.getPosition();
+ }
+
+ @DoNotInline
+ static long getBufferedPosition(PlaybackState state) {
+ return state.getBufferedPosition();
+ }
+
+ @DoNotInline
+ static float getPlaybackSpeed(PlaybackState state) {
+ return state.getPlaybackSpeed();
+ }
+
+ @DoNotInline
+ static long getActions(PlaybackState state) {
+ return state.getActions();
+ }
+
+ @DoNotInline
+ static CharSequence getErrorMessage(PlaybackState state) {
+ return state.getErrorMessage();
+ }
+
+ @DoNotInline
+ static long getLastPositionUpdateTime(PlaybackState state) {
+ return state.getLastPositionUpdateTime();
+ }
+
+ @DoNotInline
+ static long getActiveQueueItemId(PlaybackState state) {
+ return state.getActiveQueueItemId();
+ }
+
+ @DoNotInline
+ static PlaybackState.CustomAction.Builder createCustomActionBuilder(String action,
+ CharSequence name, int icon) {
+ return new PlaybackState.CustomAction.Builder(action, name, icon);
+ }
+
+ @DoNotInline
+ static void setExtras(PlaybackState.CustomAction.Builder builder, Bundle extras) {
+ builder.setExtras(extras);
+ }
+
+ @DoNotInline
+ static PlaybackState.CustomAction build(PlaybackState.CustomAction.Builder builder) {
+ return builder.build();
+ }
+
+ @DoNotInline
+ static Bundle getExtras(PlaybackState.CustomAction customAction) {
+ return customAction.getExtras();
+ }
+
+ @DoNotInline
+ static String getAction(PlaybackState.CustomAction customAction) {
+ return customAction.getAction();
+ }
+
+ @DoNotInline
+ static CharSequence getName(PlaybackState.CustomAction customAction) {
+ return customAction.getName();
+ }
+
+ @DoNotInline
+ static int getIcon(PlaybackState.CustomAction customAction) {
+ return customAction.getIcon();
+ }
+ }
+
+ @RequiresApi(22)
+ private static class Api22Impl {
+ private Api22Impl() {}
+
+ @DoNotInline
+ static void setExtras(PlaybackState.Builder builder, Bundle extras) {
+ builder.setExtras(extras);
+ }
+
+ @DoNotInline
+ static Bundle getExtras(PlaybackState state) {
+ return state.getExtras();
+ }
+ }
+}
\ No newline at end of file
diff --git a/media/media/src/main/java/androidx/media/AudioAttributesImplApi21.java b/media/media/src/main/java/androidx/media/AudioAttributesImplApi21.java
index c923287..001a470 100644
--- a/media/media/src/main/java/androidx/media/AudioAttributesImplApi21.java
+++ b/media/media/src/main/java/androidx/media/AudioAttributesImplApi21.java
@@ -126,6 +126,7 @@
return "AudioAttributesCompat: audioattributes=" + mAudioAttributes;
}
+ @RequiresApi(21)
static class Builder implements AudioAttributesImpl.Builder {
final AudioAttributes.Builder mFwkBuilder;
diff --git a/media/media/src/main/java/androidx/media/AudioAttributesImplApi26.java b/media/media/src/main/java/androidx/media/AudioAttributesImplApi26.java
index 144c340..031e2d1 100644
--- a/media/media/src/main/java/androidx/media/AudioAttributesImplApi26.java
+++ b/media/media/src/main/java/androidx/media/AudioAttributesImplApi26.java
@@ -50,6 +50,7 @@
return mAudioAttributes.getVolumeControlStream();
}
+ @RequiresApi(26)
static class Builder extends AudioAttributesImplApi21.Builder {
Builder() {
super();
diff --git a/media/media/src/main/java/androidx/media/AudioFocusRequestCompat.java b/media/media/src/main/java/androidx/media/AudioFocusRequestCompat.java
index a774664..d79fdc5 100644
--- a/media/media/src/main/java/androidx/media/AudioFocusRequestCompat.java
+++ b/media/media/src/main/java/androidx/media/AudioFocusRequestCompat.java
@@ -28,6 +28,7 @@
import android.os.Looper;
import android.os.Message;
+import androidx.annotation.DoNotInline;
import androidx.annotation.IntDef;
import androidx.annotation.NonNull;
import androidx.annotation.RequiresApi;
@@ -80,13 +81,8 @@
}
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.O) {
- mFrameworkAudioFocusRequest =
- new AudioFocusRequest.Builder(mFocusGain)
- .setAudioAttributes(getAudioAttributes())
- .setWillPauseWhenDucked(mPauseOnDuck)
- .setOnAudioFocusChangeListener(
- mOnAudioFocusChangeListener, mFocusChangeHandler)
- .build();
+ mFrameworkAudioFocusRequest = Api26Impl.createInstance(mFocusGain, getAudioAttributes(),
+ mPauseOnDuck, mOnAudioFocusChangeListener, mFocusChangeHandler);
} else {
mFrameworkAudioFocusRequest = null;
}
@@ -433,4 +429,23 @@
return false;
}
}
+
+ @RequiresApi(26)
+ private static class Api26Impl {
+ private Api26Impl() {}
+
+ @DoNotInline
+ static AudioFocusRequest createInstance(
+ int focusGain,
+ AudioAttributes audioAttributes,
+ boolean pauseOnDuck,
+ OnAudioFocusChangeListener onAudioFocusChangeListener,
+ Handler focusChangeHandler) {
+ return new AudioFocusRequest.Builder(focusGain)
+ .setAudioAttributes(audioAttributes)
+ .setWillPauseWhenDucked(pauseOnDuck)
+ .setOnAudioFocusChangeListener(onAudioFocusChangeListener, focusChangeHandler)
+ .build();
+ }
+ }
}
diff --git a/media/media/src/main/java/androidx/media/AudioManagerCompat.java b/media/media/src/main/java/androidx/media/AudioManagerCompat.java
index a6d4ae7..8215406 100644
--- a/media/media/src/main/java/androidx/media/AudioManagerCompat.java
+++ b/media/media/src/main/java/androidx/media/AudioManagerCompat.java
@@ -16,11 +16,14 @@
package androidx.media;
+import android.media.AudioFocusRequest;
import android.media.AudioManager;
import android.os.Build;
+import androidx.annotation.DoNotInline;
import androidx.annotation.IntRange;
import androidx.annotation.NonNull;
+import androidx.annotation.RequiresApi;
import androidx.core.app.NotificationCompat.StreamType;
/** Compatibility library for {@link AudioManager} with fallbacks for older platforms. */
@@ -88,7 +91,7 @@
}
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.O) {
- return audioManager.requestAudioFocus(focusRequest.getAudioFocusRequest());
+ return Api26Impl.requestAudioFocus(audioManager, focusRequest.getAudioFocusRequest());
} else {
return audioManager.requestAudioFocus(
focusRequest.getOnAudioFocusChangeListener(),
@@ -117,7 +120,8 @@
}
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.O) {
- return audioManager.abandonAudioFocusRequest(focusRequest.getAudioFocusRequest());
+ return Api26Impl.abandonAudioFocusRequest(audioManager,
+ focusRequest.getAudioFocusRequest());
} else {
return audioManager.abandonAudioFocus(focusRequest.getOnAudioFocusChangeListener());
}
@@ -145,11 +149,37 @@
public static int getStreamMinVolume(@NonNull AudioManager audioManager,
@StreamType int streamType) {
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.P) {
- return audioManager.getStreamMinVolume(streamType);
+ return Api28Impl.getStreamMinVolume(audioManager, streamType);
} else {
return 0;
}
}
private AudioManagerCompat() {}
+
+ @RequiresApi(26)
+ private static class Api26Impl {
+ private Api26Impl() {}
+
+ @DoNotInline
+ static int abandonAudioFocusRequest(AudioManager audioManager,
+ AudioFocusRequest focusRequest) {
+ return audioManager.abandonAudioFocusRequest(focusRequest);
+ }
+
+ @DoNotInline
+ static int requestAudioFocus(AudioManager audioManager, AudioFocusRequest focusRequest) {
+ return audioManager.requestAudioFocus(focusRequest);
+ }
+ }
+
+ @RequiresApi(28)
+ private static class Api28Impl {
+ private Api28Impl() {}
+
+ @DoNotInline
+ static int getStreamMinVolume(AudioManager audioManager, int streamType) {
+ return audioManager.getStreamMinVolume(streamType);
+ }
+ }
}
diff --git a/media/media/src/main/java/androidx/media/MediaBrowserServiceCompat.java b/media/media/src/main/java/androidx/media/MediaBrowserServiceCompat.java
index 05bbf1f..ffb99dc 100644
--- a/media/media/src/main/java/androidx/media/MediaBrowserServiceCompat.java
+++ b/media/media/src/main/java/androidx/media/MediaBrowserServiceCompat.java
@@ -322,21 +322,25 @@
mHandler.postOrRun(new Runnable() {
@Override
public void run() {
- if (!mRootExtrasList.isEmpty()) {
- IMediaSession extraBinder = token.getExtraBinder();
- if (extraBinder != null) {
- for (Bundle rootExtras : mRootExtrasList) {
- BundleCompat.putBinder(rootExtras, EXTRA_SESSION_BINDER,
- extraBinder.asBinder());
- }
- }
- mRootExtrasList.clear();
- }
- mServiceFwk.setSessionToken((MediaSession.Token) token.getToken());
+ setSessionTokenOnHandler(token);
}
});
}
+ void setSessionTokenOnHandler(MediaSessionCompat.Token token) {
+ if (!mRootExtrasList.isEmpty()) {
+ IMediaSession extraBinder = token.getExtraBinder();
+ if (extraBinder != null) {
+ for (Bundle rootExtras : mRootExtrasList) {
+ BundleCompat.putBinder(rootExtras, EXTRA_SESSION_BINDER,
+ extraBinder.asBinder());
+ }
+ }
+ mRootExtrasList.clear();
+ }
+ mServiceFwk.setSessionToken((MediaSession.Token) token.getToken());
+ }
+
@Override
public void notifyChildrenChanged(final String parentId, final Bundle options) {
notifyChildrenChangedForFramework(parentId, options);
@@ -490,6 +494,7 @@
return mCurConnection.browserInfo;
}
+ @RequiresApi(21)
class MediaBrowserServiceApi21 extends MediaBrowserService {
MediaBrowserServiceApi21(Context context) {
attachBaseContext(context);
diff --git a/media/media/src/main/java/androidx/media/VolumeProviderCompat.java b/media/media/src/main/java/androidx/media/VolumeProviderCompat.java
index 201d74e..79e87f0 100644
--- a/media/media/src/main/java/androidx/media/VolumeProviderCompat.java
+++ b/media/media/src/main/java/androidx/media/VolumeProviderCompat.java
@@ -22,8 +22,10 @@
import android.os.Build;
import android.support.v4.media.session.MediaSessionCompat;
+import androidx.annotation.DoNotInline;
import androidx.annotation.IntDef;
import androidx.annotation.Nullable;
+import androidx.annotation.RequiresApi;
import androidx.annotation.RestrictTo;
import java.lang.annotation.Retention;
@@ -143,7 +145,7 @@
mCurrentVolume = currentVolume;
if (Build.VERSION.SDK_INT >= 21) {
VolumeProvider volumeProviderFwk = (VolumeProvider) getVolumeProvider();
- volumeProviderFwk.setCurrentVolume(currentVolume);
+ Api21Impl.setCurrentVolume(volumeProviderFwk, currentVolume);
}
if (mCallback != null) {
mCallback.onVolumeChanged(this);
@@ -235,4 +237,14 @@
public static abstract class Callback {
public abstract void onVolumeChanged(VolumeProviderCompat volumeProvider);
}
+
+ @RequiresApi(21)
+ private static class Api21Impl {
+ private Api21Impl() {}
+
+ @DoNotInline
+ static void setCurrentVolume(VolumeProvider volumeProvider, int currentVolume) {
+ volumeProvider.setCurrentVolume(currentVolume);
+ }
+ }
}
diff --git a/media/media/src/main/java/androidx/media/app/NotificationCompat.java b/media/media/src/main/java/androidx/media/app/NotificationCompat.java
index e1fe44d..bc6510e 100644
--- a/media/media/src/main/java/androidx/media/app/NotificationCompat.java
+++ b/media/media/src/main/java/androidx/media/app/NotificationCompat.java
@@ -30,6 +30,7 @@
import android.view.View;
import android.widget.RemoteViews;
+import androidx.annotation.DoNotInline;
import androidx.annotation.RequiresApi;
import androidx.annotation.RestrictTo;
import androidx.core.app.BundleCompat;
@@ -208,8 +209,8 @@
@Override
public void apply(NotificationBuilderWithBuilderAccessor builder) {
if (Build.VERSION.SDK_INT >= 21) {
- builder.getBuilder().setStyle(
- fillInMediaStyle(new Notification.MediaStyle()));
+ Api21Impl.setStyle(builder.getBuilder(),
+ fillInMediaStyle(Api21Impl.createMediaStyle()));
} else if (mShowCancelButton) {
builder.getBuilder().setOngoing(true);
}
@@ -218,10 +219,10 @@
@RequiresApi(21)
Notification.MediaStyle fillInMediaStyle(Notification.MediaStyle style) {
if (mActionsToShowInCompact != null) {
- style.setShowActionsInCompactView(mActionsToShowInCompact);
+ Api21Impl.setShowActionsInCompactView(style, mActionsToShowInCompact);
}
if (mToken != null) {
- style.setMediaSession((MediaSession.Token) mToken.getToken());
+ Api21Impl.setMediaSession(style, (MediaSession.Token) mToken.getToken());
}
return style;
}
@@ -285,7 +286,7 @@
button.setOnClickPendingIntent(R.id.action0, action.getActionIntent());
}
if (Build.VERSION.SDK_INT >= 15) {
- button.setContentDescription(R.id.action0, action.getTitle());
+ Api15Impl.setContentDescription(button, R.id.action0, action.getTitle());
}
return button;
}
@@ -386,8 +387,8 @@
@Override
public void apply(NotificationBuilderWithBuilderAccessor builder) {
if (Build.VERSION.SDK_INT >= 24) {
- builder.getBuilder().setStyle(
- fillInMediaStyle(new Notification.DecoratedMediaCustomViewStyle()));
+ Api21Impl.setStyle(builder.getBuilder(),
+ fillInMediaStyle(Api24Impl.createDecoratedMediaCustomViewStyle()));
} else {
super.apply(builder);
}
@@ -500,4 +501,50 @@
views.setInt(R.id.status_bar_latest_event_content, "setBackgroundColor", color);
}
}
+
+ @RequiresApi(15)
+ private static class Api15Impl {
+ private Api15Impl() {}
+
+ @DoNotInline
+ static void setContentDescription(RemoteViews remoteViews, int viewId,
+ CharSequence contentDescription) {
+ remoteViews.setContentDescription(viewId, contentDescription);
+ }
+ }
+
+ @RequiresApi(21)
+ private static class Api21Impl {
+ private Api21Impl() {}
+
+ @DoNotInline
+ static void setStyle(Notification.Builder builder, Notification.Style style) {
+ builder.setStyle(style);
+ }
+
+ @DoNotInline
+ static Notification.MediaStyle createMediaStyle() {
+ return new Notification.MediaStyle();
+ }
+
+ @DoNotInline
+ static void setShowActionsInCompactView(Notification.MediaStyle style, int... actions) {
+ style.setShowActionsInCompactView(actions);
+ }
+
+ @DoNotInline
+ static void setMediaSession(Notification.MediaStyle style, MediaSession.Token token) {
+ style.setMediaSession(token);
+ }
+ }
+
+ @RequiresApi(24)
+ private static class Api24Impl {
+ private Api24Impl() {}
+
+ @DoNotInline
+ static Notification.DecoratedMediaCustomViewStyle createDecoratedMediaCustomViewStyle() {
+ return new Notification.DecoratedMediaCustomViewStyle();
+ }
+ }
}
diff --git a/media/media/src/main/java/androidx/media/session/MediaButtonReceiver.java b/media/media/src/main/java/androidx/media/session/MediaButtonReceiver.java
index b6c2a3b..0d8dea6 100644
--- a/media/media/src/main/java/androidx/media/session/MediaButtonReceiver.java
+++ b/media/media/src/main/java/androidx/media/session/MediaButtonReceiver.java
@@ -39,6 +39,7 @@
import android.view.KeyEvent;
import androidx.annotation.RestrictTo;
+import androidx.core.content.ContextCompat;
import androidx.media.MediaBrowserServiceCompat;
import java.util.List;
@@ -114,7 +115,7 @@
getServiceComponentByAction(context, Intent.ACTION_MEDIA_BUTTON);
if (mediaButtonServiceComponentName != null) {
intent.setComponent(mediaButtonServiceComponentName);
- startForegroundService(context, intent);
+ ContextCompat.startForegroundService(context, intent);
return;
}
ComponentName mediaBrowserServiceComponentName = getServiceComponentByAction(context,
@@ -296,14 +297,6 @@
return null;
}
- private static void startForegroundService(Context context, Intent intent) {
- if (Build.VERSION.SDK_INT >= 26) {
- context.startForegroundService(intent);
- } else {
- context.startService(intent);
- }
- }
-
private static ComponentName getServiceComponentByAction(Context context, String action) {
PackageManager pm = context.getPackageManager();
Intent queryIntent = new Intent(action);
diff --git a/mediarouter/mediarouter/src/main/res/layout/mr_chooser_dialog.xml b/mediarouter/mediarouter/src/main/res/layout/mr_chooser_dialog.xml
index 363f158..966e42c 100644
--- a/mediarouter/mediarouter/src/main/res/layout/mr_chooser_dialog.xml
+++ b/mediarouter/mediarouter/src/main/res/layout/mr_chooser_dialog.xml
@@ -21,7 +21,8 @@
<TextView android:id="@+id/mr_chooser_title"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
- android:minHeight="64dp"
+ android:minHeight="52dp"
+ android:paddingTop="12dp"
android:paddingLeft="24dp"
android:paddingRight="24dp"
android:gravity="center_vertical"
diff --git a/mediarouter/mediarouter/src/main/res/layout/mr_chooser_list_item.xml b/mediarouter/mediarouter/src/main/res/layout/mr_chooser_list_item.xml
index 7fce7d5..e92def0 100644
--- a/mediarouter/mediarouter/src/main/res/layout/mr_chooser_list_item.xml
+++ b/mediarouter/mediarouter/src/main/res/layout/mr_chooser_list_item.xml
@@ -20,7 +20,8 @@
android:minHeight="32dp"
android:paddingLeft="24dp"
android:paddingRight="24dp"
- android:paddingBottom="24dp"
+ android:paddingTop="12dp"
+ android:paddingBottom="12dp"
android:orientation="horizontal"
android:gravity="center_vertical" >
diff --git a/navigation/integration-tests/testapp/src/main/java/androidx/navigation/testapp/HelpActivity.kt b/navigation/integration-tests/testapp/src/main/java/androidx/navigation/testapp/HelpActivity.kt
index 55f03b2..5eb47d1 100644
--- a/navigation/integration-tests/testapp/src/main/java/androidx/navigation/testapp/HelpActivity.kt
+++ b/navigation/integration-tests/testapp/src/main/java/androidx/navigation/testapp/HelpActivity.kt
@@ -78,6 +78,7 @@
}
class BottomSheetNavigationView : BottomSheetDialogFragment() {
+ @Suppress("DEPRECATION")
override fun onCreateView(
inflater: LayoutInflater,
container: ViewGroup?,
diff --git a/navigation/navigation-common/api/current.txt b/navigation/navigation-common/api/current.txt
index dda39ab..a889a60 100644
--- a/navigation/navigation-common/api/current.txt
+++ b/navigation/navigation-common/api/current.txt
@@ -226,7 +226,7 @@
}
@androidx.navigation.NavDestinationDsl public class NavDestinationBuilder<D extends androidx.navigation.NavDestination> {
- ctor public NavDestinationBuilder(androidx.navigation.Navigator<? extends D> navigator, @IdRes int id);
+ ctor @Deprecated public NavDestinationBuilder(androidx.navigation.Navigator<? extends D> navigator, @IdRes int id);
ctor public NavDestinationBuilder(androidx.navigation.Navigator<? extends D> navigator, String? route);
method public final void action(int actionId, kotlin.jvm.functions.Function1<? super androidx.navigation.NavActionBuilder,kotlin.Unit> actionBuilder);
method public final void argument(String name, kotlin.jvm.functions.Function1<? super androidx.navigation.NavArgumentBuilder,kotlin.Unit> argumentBuilder);
@@ -281,7 +281,7 @@
}
@androidx.navigation.NavDestinationDsl public class NavGraphBuilder extends androidx.navigation.NavDestinationBuilder<androidx.navigation.NavGraph> {
- ctor public NavGraphBuilder(androidx.navigation.NavigatorProvider provider, @IdRes int id, @IdRes int startDestination);
+ ctor @Deprecated public NavGraphBuilder(androidx.navigation.NavigatorProvider provider, @IdRes int id, @IdRes int startDestination);
ctor public NavGraphBuilder(androidx.navigation.NavigatorProvider provider, String startDestination, String? route);
method public final void addDestination(androidx.navigation.NavDestination destination);
method public androidx.navigation.NavGraph build();
@@ -292,9 +292,9 @@
}
public final class NavGraphBuilderKt {
- method public static inline androidx.navigation.NavGraph navigation(androidx.navigation.NavigatorProvider, optional @IdRes int id, @IdRes int startDestination, kotlin.jvm.functions.Function1<? super androidx.navigation.NavGraphBuilder,kotlin.Unit> builder);
+ method @Deprecated public static inline androidx.navigation.NavGraph navigation(androidx.navigation.NavigatorProvider, optional @IdRes int id, @IdRes int startDestination, kotlin.jvm.functions.Function1<? super androidx.navigation.NavGraphBuilder,kotlin.Unit> builder);
method public static inline androidx.navigation.NavGraph navigation(androidx.navigation.NavigatorProvider, String startDestination, optional String? route, kotlin.jvm.functions.Function1<? super androidx.navigation.NavGraphBuilder,kotlin.Unit> builder);
- method public static inline void navigation(androidx.navigation.NavGraphBuilder, @IdRes int id, @IdRes int startDestination, kotlin.jvm.functions.Function1<? super androidx.navigation.NavGraphBuilder,kotlin.Unit> builder);
+ method @Deprecated public static inline void navigation(androidx.navigation.NavGraphBuilder, @IdRes int id, @IdRes int startDestination, kotlin.jvm.functions.Function1<? super androidx.navigation.NavGraphBuilder,kotlin.Unit> builder);
method public static inline void navigation(androidx.navigation.NavGraphBuilder, String startDestination, String route, kotlin.jvm.functions.Function1<? super androidx.navigation.NavGraphBuilder,kotlin.Unit> builder);
}
diff --git a/navigation/navigation-common/api/public_plus_experimental_current.txt b/navigation/navigation-common/api/public_plus_experimental_current.txt
index bd49a55..3dc13449 100644
--- a/navigation/navigation-common/api/public_plus_experimental_current.txt
+++ b/navigation/navigation-common/api/public_plus_experimental_current.txt
@@ -263,7 +263,7 @@
}
@androidx.navigation.NavDestinationDsl public class NavDestinationBuilder<D extends androidx.navigation.NavDestination> {
- ctor public NavDestinationBuilder(androidx.navigation.Navigator<? extends D> navigator, @IdRes int id);
+ ctor @Deprecated public NavDestinationBuilder(androidx.navigation.Navigator<? extends D> navigator, @IdRes int id);
ctor public NavDestinationBuilder(androidx.navigation.Navigator<? extends D> navigator, String? route);
method public final void action(int actionId, kotlin.jvm.functions.Function1<? super androidx.navigation.NavActionBuilder,kotlin.Unit> actionBuilder);
method public final void argument(String name, kotlin.jvm.functions.Function1<? super androidx.navigation.NavArgumentBuilder,kotlin.Unit> argumentBuilder);
@@ -322,7 +322,7 @@
}
@androidx.navigation.NavDestinationDsl public class NavGraphBuilder extends androidx.navigation.NavDestinationBuilder<androidx.navigation.NavGraph> {
- ctor public NavGraphBuilder(androidx.navigation.NavigatorProvider provider, @IdRes int id, @IdRes int startDestination);
+ ctor @Deprecated public NavGraphBuilder(androidx.navigation.NavigatorProvider provider, @IdRes int id, @IdRes int startDestination);
ctor public NavGraphBuilder(androidx.navigation.NavigatorProvider provider, String startDestination, String? route);
method public final void addDestination(androidx.navigation.NavDestination destination);
method public androidx.navigation.NavGraph build();
@@ -333,9 +333,9 @@
}
public final class NavGraphBuilderKt {
- method public static inline androidx.navigation.NavGraph navigation(androidx.navigation.NavigatorProvider, optional @IdRes int id, @IdRes int startDestination, kotlin.jvm.functions.Function1<? super androidx.navigation.NavGraphBuilder,kotlin.Unit> builder);
+ method @Deprecated public static inline androidx.navigation.NavGraph navigation(androidx.navigation.NavigatorProvider, optional @IdRes int id, @IdRes int startDestination, kotlin.jvm.functions.Function1<? super androidx.navigation.NavGraphBuilder,kotlin.Unit> builder);
method public static inline androidx.navigation.NavGraph navigation(androidx.navigation.NavigatorProvider, String startDestination, optional String? route, kotlin.jvm.functions.Function1<? super androidx.navigation.NavGraphBuilder,kotlin.Unit> builder);
- method public static inline void navigation(androidx.navigation.NavGraphBuilder, @IdRes int id, @IdRes int startDestination, kotlin.jvm.functions.Function1<? super androidx.navigation.NavGraphBuilder,kotlin.Unit> builder);
+ method @Deprecated public static inline void navigation(androidx.navigation.NavGraphBuilder, @IdRes int id, @IdRes int startDestination, kotlin.jvm.functions.Function1<? super androidx.navigation.NavGraphBuilder,kotlin.Unit> builder);
method public static inline void navigation(androidx.navigation.NavGraphBuilder, String startDestination, String route, kotlin.jvm.functions.Function1<? super androidx.navigation.NavGraphBuilder,kotlin.Unit> builder);
}
diff --git a/navigation/navigation-common/api/restricted_current.txt b/navigation/navigation-common/api/restricted_current.txt
index dda39ab..a889a60 100644
--- a/navigation/navigation-common/api/restricted_current.txt
+++ b/navigation/navigation-common/api/restricted_current.txt
@@ -226,7 +226,7 @@
}
@androidx.navigation.NavDestinationDsl public class NavDestinationBuilder<D extends androidx.navigation.NavDestination> {
- ctor public NavDestinationBuilder(androidx.navigation.Navigator<? extends D> navigator, @IdRes int id);
+ ctor @Deprecated public NavDestinationBuilder(androidx.navigation.Navigator<? extends D> navigator, @IdRes int id);
ctor public NavDestinationBuilder(androidx.navigation.Navigator<? extends D> navigator, String? route);
method public final void action(int actionId, kotlin.jvm.functions.Function1<? super androidx.navigation.NavActionBuilder,kotlin.Unit> actionBuilder);
method public final void argument(String name, kotlin.jvm.functions.Function1<? super androidx.navigation.NavArgumentBuilder,kotlin.Unit> argumentBuilder);
@@ -281,7 +281,7 @@
}
@androidx.navigation.NavDestinationDsl public class NavGraphBuilder extends androidx.navigation.NavDestinationBuilder<androidx.navigation.NavGraph> {
- ctor public NavGraphBuilder(androidx.navigation.NavigatorProvider provider, @IdRes int id, @IdRes int startDestination);
+ ctor @Deprecated public NavGraphBuilder(androidx.navigation.NavigatorProvider provider, @IdRes int id, @IdRes int startDestination);
ctor public NavGraphBuilder(androidx.navigation.NavigatorProvider provider, String startDestination, String? route);
method public final void addDestination(androidx.navigation.NavDestination destination);
method public androidx.navigation.NavGraph build();
@@ -292,9 +292,9 @@
}
public final class NavGraphBuilderKt {
- method public static inline androidx.navigation.NavGraph navigation(androidx.navigation.NavigatorProvider, optional @IdRes int id, @IdRes int startDestination, kotlin.jvm.functions.Function1<? super androidx.navigation.NavGraphBuilder,kotlin.Unit> builder);
+ method @Deprecated public static inline androidx.navigation.NavGraph navigation(androidx.navigation.NavigatorProvider, optional @IdRes int id, @IdRes int startDestination, kotlin.jvm.functions.Function1<? super androidx.navigation.NavGraphBuilder,kotlin.Unit> builder);
method public static inline androidx.navigation.NavGraph navigation(androidx.navigation.NavigatorProvider, String startDestination, optional String? route, kotlin.jvm.functions.Function1<? super androidx.navigation.NavGraphBuilder,kotlin.Unit> builder);
- method public static inline void navigation(androidx.navigation.NavGraphBuilder, @IdRes int id, @IdRes int startDestination, kotlin.jvm.functions.Function1<? super androidx.navigation.NavGraphBuilder,kotlin.Unit> builder);
+ method @Deprecated public static inline void navigation(androidx.navigation.NavGraphBuilder, @IdRes int id, @IdRes int startDestination, kotlin.jvm.functions.Function1<? super androidx.navigation.NavGraphBuilder,kotlin.Unit> builder);
method public static inline void navigation(androidx.navigation.NavGraphBuilder, String startDestination, String route, kotlin.jvm.functions.Function1<? super androidx.navigation.NavGraphBuilder,kotlin.Unit> builder);
}
diff --git a/navigation/navigation-common/src/androidTest/java/androidx/navigation/NavDestinationBuilderTest.kt b/navigation/navigation-common/src/androidTest/java/androidx/navigation/NavDestinationBuilderTest.kt
index 68fa76a..6572323 100644
--- a/navigation/navigation-common/src/androidTest/java/androidx/navigation/NavDestinationBuilderTest.kt
+++ b/navigation/navigation-common/src/androidTest/java/androidx/navigation/NavDestinationBuilderTest.kt
@@ -124,6 +124,7 @@
* a NavDestination directly to allow for testing NavDestinationBuilder in
* isolation.
*/
+@Suppress("DEPRECATION")
fun NavigatorProvider.navDestination(
@IdRes id: Int,
builder: NavDestinationBuilder<NavDestination>.() -> Unit
diff --git a/navigation/navigation-common/src/androidTest/java/androidx/navigation/NavGraphBuilderTest.kt b/navigation/navigation-common/src/androidTest/java/androidx/navigation/NavGraphBuilderTest.kt
index cb75a08..69d1eda 100644
--- a/navigation/navigation-common/src/androidTest/java/androidx/navigation/NavGraphBuilderTest.kt
+++ b/navigation/navigation-common/src/androidTest/java/androidx/navigation/NavGraphBuilderTest.kt
@@ -32,6 +32,7 @@
addNavigator(NoOpNavigator())
}
+ @Suppress("DEPRECATION")
@Test
fun navigation() {
val graph = provider.navigation(startDestination = DESTINATION_ID) {
@@ -54,6 +55,7 @@
.isTrue()
}
+ @Suppress("DEPRECATION")
@Test
fun navigationUnaryPlus() {
val graph = provider.navigation(startDestination = DESTINATION_ID) {
@@ -80,6 +82,7 @@
.isTrue()
}
+ @Suppress("DEPRECATION")
@Test
fun navigationAddDestination() {
val graph = provider.navigation(startDestination = DESTINATION_ID) {
@@ -108,6 +111,7 @@
.isTrue()
}
+ @Suppress("DEPRECATION")
@Test(expected = IllegalStateException::class)
fun navigationMissingStartDestination() {
provider.navigation(startDestination = 0) {
@@ -124,6 +128,7 @@
fail("NavGraph should throw IllegalStateException if no startDestinationRoute is set")
}
+ @Suppress("DEPRECATION")
@Test
fun navigationNested() {
val graph = provider.navigation(startDestination = DESTINATION_ID) {
@@ -158,6 +163,7 @@
* Create a base NavDestination. Generally, only subtypes of NavDestination should be
* added to a NavGraph (hence why this is not in the common-ktx library)
*/
+@Suppress("DEPRECATION")
fun NavGraphBuilder.navDestination(
@IdRes id: Int,
builder: NavDestinationBuilder<NavDestination>.() -> Unit
diff --git a/navigation/navigation-common/src/main/java/androidx/navigation/NavDestinationBuilder.kt b/navigation/navigation-common/src/main/java/androidx/navigation/NavDestinationBuilder.kt
index f5453fd..22c9fa3 100644
--- a/navigation/navigation-common/src/main/java/androidx/navigation/NavDestinationBuilder.kt
+++ b/navigation/navigation-common/src/main/java/androidx/navigation/NavDestinationBuilder.kt
@@ -51,6 +51,10 @@
*
* @return the newly constructed [NavDestination]
*/
+ @Deprecated(
+ "Use routes to build your NavDestination instead",
+ ReplaceWith("NavDestinationBuilder(navigator, route = id.toString())")
+ )
public constructor(navigator: Navigator<out D>, @IdRes id: Int) :
this(navigator, id, null)
diff --git a/navigation/navigation-common/src/main/java/androidx/navigation/NavGraphBuilder.kt b/navigation/navigation-common/src/main/java/androidx/navigation/NavGraphBuilder.kt
index 28a4c0a..d69f5d2 100644
--- a/navigation/navigation-common/src/main/java/androidx/navigation/NavGraphBuilder.kt
+++ b/navigation/navigation-common/src/main/java/androidx/navigation/NavGraphBuilder.kt
@@ -27,6 +27,14 @@
*
* @return the newly constructed NavGraph
*/
+@Suppress("Deprecation")
+@Deprecated(
+ "Use routes to build your NavGraph instead",
+ ReplaceWith(
+ "navigation(startDestination = startDestination.toString(), route = id.toString()) " +
+ "{ builder.invoke() }"
+ )
+)
public inline fun NavigatorProvider.navigation(
@IdRes id: Int = 0,
@IdRes startDestination: Int,
@@ -58,6 +66,14 @@
*
* @return the newly constructed nested NavGraph
*/
+@Suppress("Deprecation")
+@Deprecated(
+ "Use routes to build your nested NavGraph instead",
+ ReplaceWith(
+ "navigation(startDestination = startDestination.toString(), route = id.toString()) " +
+ "{ builder.invoke() }"
+ )
+)
public inline fun NavGraphBuilder.navigation(
@IdRes id: Int,
@IdRes startDestination: Int,
@@ -100,6 +116,14 @@
*
* @return the newly created NavGraph
*/
+ @Suppress("Deprecation")
+ @Deprecated(
+ "Use routes to build your NavGraph instead",
+ ReplaceWith(
+ "NavGraphBuilder(provider, startDestination = startDestination.toString(), " +
+ "route = id.toString())"
+ )
+ )
public constructor(
provider: NavigatorProvider,
@IdRes id: Int,
diff --git a/navigation/navigation-dynamic-features-fragment/api/current.txt b/navigation/navigation-dynamic-features-fragment/api/current.txt
index e6dd027..d42b4d5 100644
--- a/navigation/navigation-dynamic-features-fragment/api/current.txt
+++ b/navigation/navigation-dynamic-features-fragment/api/current.txt
@@ -15,7 +15,7 @@
}
@androidx.navigation.NavDestinationDsl public final class DynamicFragmentNavigatorDestinationBuilder extends androidx.navigation.NavDestinationBuilder<androidx.navigation.fragment.FragmentNavigator.Destination> {
- ctor public DynamicFragmentNavigatorDestinationBuilder(androidx.navigation.dynamicfeatures.fragment.DynamicFragmentNavigator navigator, @IdRes int id, String fragmentClassName);
+ ctor @Deprecated public DynamicFragmentNavigatorDestinationBuilder(androidx.navigation.dynamicfeatures.fragment.DynamicFragmentNavigator navigator, @IdRes int id, String fragmentClassName);
ctor public DynamicFragmentNavigatorDestinationBuilder(androidx.navigation.dynamicfeatures.fragment.DynamicFragmentNavigator navigator, String route, String fragmentClassName);
method public androidx.navigation.dynamicfeatures.fragment.DynamicFragmentNavigator.Destination build();
method public String? getModuleName();
@@ -24,7 +24,7 @@
}
public final class DynamicFragmentNavigatorDestinationBuilderKt {
- method public static inline void fragment(androidx.navigation.dynamicfeatures.DynamicNavGraphBuilder, @IdRes int id, String fragmentClassName, kotlin.jvm.functions.Function1<? super androidx.navigation.dynamicfeatures.fragment.DynamicFragmentNavigatorDestinationBuilder,kotlin.Unit> builder);
+ method @Deprecated public static inline void fragment(androidx.navigation.dynamicfeatures.DynamicNavGraphBuilder, @IdRes int id, String fragmentClassName, kotlin.jvm.functions.Function1<? super androidx.navigation.dynamicfeatures.fragment.DynamicFragmentNavigatorDestinationBuilder,kotlin.Unit> builder);
method public static inline void fragment(androidx.navigation.dynamicfeatures.DynamicNavGraphBuilder, String route, String fragmentClassName, kotlin.jvm.functions.Function1<? super androidx.navigation.dynamicfeatures.fragment.DynamicFragmentNavigatorDestinationBuilder,kotlin.Unit> builder);
method public static inline <reified F extends androidx.fragment.app.Fragment> void fragment(androidx.navigation.dynamicfeatures.DynamicNavGraphBuilder, @IdRes int id);
method public static inline <reified F extends androidx.fragment.app.Fragment> void fragment(androidx.navigation.dynamicfeatures.DynamicNavGraphBuilder, @IdRes int id, kotlin.jvm.functions.Function1<? super androidx.navigation.dynamicfeatures.fragment.DynamicFragmentNavigatorDestinationBuilder,? extends kotlin.Unit> builder);
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 e6dd027..d42b4d5 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
@@ -15,7 +15,7 @@
}
@androidx.navigation.NavDestinationDsl public final class DynamicFragmentNavigatorDestinationBuilder extends androidx.navigation.NavDestinationBuilder<androidx.navigation.fragment.FragmentNavigator.Destination> {
- ctor public DynamicFragmentNavigatorDestinationBuilder(androidx.navigation.dynamicfeatures.fragment.DynamicFragmentNavigator navigator, @IdRes int id, String fragmentClassName);
+ ctor @Deprecated public DynamicFragmentNavigatorDestinationBuilder(androidx.navigation.dynamicfeatures.fragment.DynamicFragmentNavigator navigator, @IdRes int id, String fragmentClassName);
ctor public DynamicFragmentNavigatorDestinationBuilder(androidx.navigation.dynamicfeatures.fragment.DynamicFragmentNavigator navigator, String route, String fragmentClassName);
method public androidx.navigation.dynamicfeatures.fragment.DynamicFragmentNavigator.Destination build();
method public String? getModuleName();
@@ -24,7 +24,7 @@
}
public final class DynamicFragmentNavigatorDestinationBuilderKt {
- method public static inline void fragment(androidx.navigation.dynamicfeatures.DynamicNavGraphBuilder, @IdRes int id, String fragmentClassName, kotlin.jvm.functions.Function1<? super androidx.navigation.dynamicfeatures.fragment.DynamicFragmentNavigatorDestinationBuilder,kotlin.Unit> builder);
+ method @Deprecated public static inline void fragment(androidx.navigation.dynamicfeatures.DynamicNavGraphBuilder, @IdRes int id, String fragmentClassName, kotlin.jvm.functions.Function1<? super androidx.navigation.dynamicfeatures.fragment.DynamicFragmentNavigatorDestinationBuilder,kotlin.Unit> builder);
method public static inline void fragment(androidx.navigation.dynamicfeatures.DynamicNavGraphBuilder, String route, String fragmentClassName, kotlin.jvm.functions.Function1<? super androidx.navigation.dynamicfeatures.fragment.DynamicFragmentNavigatorDestinationBuilder,kotlin.Unit> builder);
method public static inline <reified F extends androidx.fragment.app.Fragment> void fragment(androidx.navigation.dynamicfeatures.DynamicNavGraphBuilder, @IdRes int id);
method public static inline <reified F extends androidx.fragment.app.Fragment> void fragment(androidx.navigation.dynamicfeatures.DynamicNavGraphBuilder, @IdRes int id, kotlin.jvm.functions.Function1<? super androidx.navigation.dynamicfeatures.fragment.DynamicFragmentNavigatorDestinationBuilder,? extends kotlin.Unit> builder);
diff --git a/navigation/navigation-dynamic-features-fragment/api/restricted_current.txt b/navigation/navigation-dynamic-features-fragment/api/restricted_current.txt
index e6dd027..d42b4d5 100644
--- a/navigation/navigation-dynamic-features-fragment/api/restricted_current.txt
+++ b/navigation/navigation-dynamic-features-fragment/api/restricted_current.txt
@@ -15,7 +15,7 @@
}
@androidx.navigation.NavDestinationDsl public final class DynamicFragmentNavigatorDestinationBuilder extends androidx.navigation.NavDestinationBuilder<androidx.navigation.fragment.FragmentNavigator.Destination> {
- ctor public DynamicFragmentNavigatorDestinationBuilder(androidx.navigation.dynamicfeatures.fragment.DynamicFragmentNavigator navigator, @IdRes int id, String fragmentClassName);
+ ctor @Deprecated public DynamicFragmentNavigatorDestinationBuilder(androidx.navigation.dynamicfeatures.fragment.DynamicFragmentNavigator navigator, @IdRes int id, String fragmentClassName);
ctor public DynamicFragmentNavigatorDestinationBuilder(androidx.navigation.dynamicfeatures.fragment.DynamicFragmentNavigator navigator, String route, String fragmentClassName);
method public androidx.navigation.dynamicfeatures.fragment.DynamicFragmentNavigator.Destination build();
method public String? getModuleName();
@@ -24,7 +24,7 @@
}
public final class DynamicFragmentNavigatorDestinationBuilderKt {
- method public static inline void fragment(androidx.navigation.dynamicfeatures.DynamicNavGraphBuilder, @IdRes int id, String fragmentClassName, kotlin.jvm.functions.Function1<? super androidx.navigation.dynamicfeatures.fragment.DynamicFragmentNavigatorDestinationBuilder,kotlin.Unit> builder);
+ method @Deprecated public static inline void fragment(androidx.navigation.dynamicfeatures.DynamicNavGraphBuilder, @IdRes int id, String fragmentClassName, kotlin.jvm.functions.Function1<? super androidx.navigation.dynamicfeatures.fragment.DynamicFragmentNavigatorDestinationBuilder,kotlin.Unit> builder);
method public static inline void fragment(androidx.navigation.dynamicfeatures.DynamicNavGraphBuilder, String route, String fragmentClassName, kotlin.jvm.functions.Function1<? super androidx.navigation.dynamicfeatures.fragment.DynamicFragmentNavigatorDestinationBuilder,kotlin.Unit> builder);
method public static inline <reified F extends androidx.fragment.app.Fragment> void fragment(androidx.navigation.dynamicfeatures.DynamicNavGraphBuilder, @IdRes int id);
method public static inline <reified F extends androidx.fragment.app.Fragment> void fragment(androidx.navigation.dynamicfeatures.DynamicNavGraphBuilder, @IdRes int id, kotlin.jvm.functions.Function1<? super androidx.navigation.dynamicfeatures.fragment.DynamicFragmentNavigatorDestinationBuilder,? extends kotlin.Unit> builder);
diff --git a/navigation/navigation-dynamic-features-fragment/build.gradle b/navigation/navigation-dynamic-features-fragment/build.gradle
index 60cf4908..5448fa7 100644
--- a/navigation/navigation-dynamic-features-fragment/build.gradle
+++ b/navigation/navigation-dynamic-features-fragment/build.gradle
@@ -39,6 +39,7 @@
testImplementation(libs.testRunner)
testImplementation(libs.junit)
testImplementation(libs.mockitoCore)
+ testImplementation(libs.robolectric)
testImplementation(libs.truth)
androidTestImplementation(libs.testCore)
@@ -53,7 +54,6 @@
androidTestImplementation(project(":internal-testutils-runtime"), {
exclude group: "androidx.fragment", module: "fragment"
})
- androidTestImplementation(libs.multidex)
}
android {
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 30da2f9..6f6d8d7 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
@@ -33,13 +33,14 @@
@MediumTest
@RunWith(AndroidJUnit4::class)
public class DynamicFragmentNavigatorDestinationBuilderTest {
- @Suppress("DEPRECATION")
+
@get:Rule
public val rule: ActivityScenarioRule<TestActivity> = ActivityScenarioRule(
TestActivity::class.java
)
private val fragmentManager get() = rule.withActivity { supportFragmentManager }
+ @Suppress("DEPRECATION")
@UiThreadTest
@Test
public fun reified() {
@@ -56,6 +57,7 @@
.isEqualTo(TestFragment::class.java.name)
}
+ @Suppress("DEPRECATION")
@UiThreadTest
@Test
public fun moduleName() {
@@ -77,6 +79,7 @@
.isEqualTo(MODULE_NAME)
}
+ @Suppress("DEPRECATION")
@UiThreadTest
@Test
public fun no_moduleName() {
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 3d0cde7..c1a8f7d 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
@@ -35,9 +35,8 @@
@RunWith(AndroidJUnit4::class)
public class DynamicNavHostFragmentTest {
- @Suppress("DEPRECATION")
@get:Rule
- public val activityTestRule: ActivityScenarioRule<NavigationActivity> = ActivityScenarioRule(
+ public val rule: ActivityScenarioRule<NavigationActivity> = ActivityScenarioRule(
NavigationActivity::class.java
)
diff --git a/navigation/navigation-dynamic-features-fragment/src/main/java/androidx/navigation/dynamicfeatures/fragment/DynamicFragmentNavigatorDestinationBuilder.kt b/navigation/navigation-dynamic-features-fragment/src/main/java/androidx/navigation/dynamicfeatures/fragment/DynamicFragmentNavigatorDestinationBuilder.kt
index dd0b7f2..d337aa2 100644
--- a/navigation/navigation-dynamic-features-fragment/src/main/java/androidx/navigation/dynamicfeatures/fragment/DynamicFragmentNavigatorDestinationBuilder.kt
+++ b/navigation/navigation-dynamic-features-fragment/src/main/java/androidx/navigation/dynamicfeatures/fragment/DynamicFragmentNavigatorDestinationBuilder.kt
@@ -29,6 +29,11 @@
* Construct a new [DynamicFragmentNavigator.Destination]
* @param id Destination id.
*/
+@Suppress("Deprecation")
+@Deprecated(
+ "Use routes to create your DynamicFragmentDestination instead",
+ ReplaceWith("fragment(route = id.toString())")
+)
public inline fun <reified F : Fragment> DynamicNavGraphBuilder.fragment(
@IdRes id: Int
): Unit = fragment<F>(id) {}
@@ -37,6 +42,11 @@
* Construct a new [DynamicFragmentNavigator.Destination]
* @param id Destination id.
*/
+@Suppress("Deprecation")
+@Deprecated(
+ "Use routes to create your DynamicFragmentDestination instead",
+ ReplaceWith("fragment(route = id.toString()) { builder.invoke() }")
+)
public inline fun <reified F : Fragment> DynamicNavGraphBuilder.fragment(
@IdRes id: Int,
builder: DynamicFragmentNavigatorDestinationBuilder.() -> Unit
@@ -47,6 +57,11 @@
* @param id Destination id.
* @param fragmentClassName Fully qualified class name of destination Fragment.
*/
+@Suppress("Deprecation")
+@Deprecated(
+ "Use routes to create your DynamicFragmentDestination instead",
+ ReplaceWith("fragment(route = id.toString(), fragmentClassName) { builder.invoke() }")
+)
public inline fun DynamicNavGraphBuilder.fragment(
@IdRes id: Int,
fragmentClassName: String,
@@ -102,6 +117,14 @@
private var fragmentClassName: String
+ @Suppress("Deprecation")
+ @Deprecated(
+ "Use routes to create your DynamicFragmentDestinationBuilder instead",
+ ReplaceWith(
+ "DynamicFragmentNavigatorDestinationBuilder(navigator, route = id.toString(), " +
+ "fragmentClassName)"
+ )
+ )
public constructor(
navigator: DynamicFragmentNavigator,
@IdRes id: Int,
diff --git a/navigation/navigation-dynamic-features-runtime/api/current.txt b/navigation/navigation-dynamic-features-runtime/api/current.txt
index 9807b58..ea49279 100644
--- a/navigation/navigation-dynamic-features-runtime/api/current.txt
+++ b/navigation/navigation-dynamic-features-runtime/api/current.txt
@@ -15,7 +15,7 @@
}
@androidx.navigation.NavDestinationDsl public final class DynamicActivityNavigatorDestinationBuilder extends androidx.navigation.NavDestinationBuilder<androidx.navigation.ActivityNavigator.Destination> {
- ctor public DynamicActivityNavigatorDestinationBuilder(androidx.navigation.dynamicfeatures.DynamicActivityNavigator activityNavigator, @IdRes int id);
+ ctor @Deprecated public DynamicActivityNavigatorDestinationBuilder(androidx.navigation.dynamicfeatures.DynamicActivityNavigator activityNavigator, @IdRes int id);
ctor public DynamicActivityNavigatorDestinationBuilder(androidx.navigation.dynamicfeatures.DynamicActivityNavigator activityNavigator, String route);
method public androidx.navigation.dynamicfeatures.DynamicActivityNavigator.Destination build();
method public String? getAction();
@@ -39,7 +39,7 @@
}
public final class DynamicActivityNavigatorDestinationBuilderKt {
- method public static inline void activity(androidx.navigation.dynamicfeatures.DynamicNavGraphBuilder, @IdRes int id, kotlin.jvm.functions.Function1<? super androidx.navigation.dynamicfeatures.DynamicActivityNavigatorDestinationBuilder,kotlin.Unit> builder);
+ method @Deprecated public static inline void activity(androidx.navigation.dynamicfeatures.DynamicNavGraphBuilder, @IdRes int id, kotlin.jvm.functions.Function1<? super androidx.navigation.dynamicfeatures.DynamicActivityNavigatorDestinationBuilder,kotlin.Unit> builder);
method public static inline void activity(androidx.navigation.dynamicfeatures.DynamicNavGraphBuilder, String route, kotlin.jvm.functions.Function1<? super androidx.navigation.dynamicfeatures.DynamicActivityNavigatorDestinationBuilder,kotlin.Unit> builder);
}
@@ -87,7 +87,7 @@
}
@androidx.navigation.NavDestinationDsl public final class DynamicIncludeNavGraphBuilder extends androidx.navigation.NavDestinationBuilder<androidx.navigation.dynamicfeatures.DynamicIncludeGraphNavigator.DynamicIncludeNavGraph> {
- ctor public DynamicIncludeNavGraphBuilder(androidx.navigation.dynamicfeatures.DynamicIncludeGraphNavigator dynamicIncludeGraphNavigator, @IdRes int id, String moduleName, String graphResourceName);
+ ctor @Deprecated public DynamicIncludeNavGraphBuilder(androidx.navigation.dynamicfeatures.DynamicIncludeGraphNavigator dynamicIncludeGraphNavigator, @IdRes int id, String moduleName, String graphResourceName);
ctor public DynamicIncludeNavGraphBuilder(androidx.navigation.dynamicfeatures.DynamicIncludeGraphNavigator dynamicIncludeGraphNavigator, String route, String moduleName, String graphResourceName);
method public androidx.navigation.dynamicfeatures.DynamicIncludeGraphNavigator.DynamicIncludeNavGraph build();
method public String? getGraphPackage();
@@ -96,8 +96,8 @@
}
public final class DynamicIncludeNavGraphBuilderKt {
- method public static inline void includeDynamic(androidx.navigation.dynamicfeatures.DynamicNavGraphBuilder, @IdRes int id, String moduleName, String graphResourceName);
- method public static inline void includeDynamic(androidx.navigation.dynamicfeatures.DynamicNavGraphBuilder, @IdRes int id, String moduleName, String graphResourceName, kotlin.jvm.functions.Function1<? super androidx.navigation.dynamicfeatures.DynamicIncludeNavGraphBuilder,kotlin.Unit> builder);
+ method @Deprecated public static inline void includeDynamic(androidx.navigation.dynamicfeatures.DynamicNavGraphBuilder, @IdRes int id, String moduleName, String graphResourceName);
+ method @Deprecated public static inline void includeDynamic(androidx.navigation.dynamicfeatures.DynamicNavGraphBuilder, @IdRes int id, String moduleName, String graphResourceName, kotlin.jvm.functions.Function1<? super androidx.navigation.dynamicfeatures.DynamicIncludeNavGraphBuilder,kotlin.Unit> builder);
method public static inline void includeDynamic(androidx.navigation.dynamicfeatures.DynamicNavGraphBuilder, String route, String moduleName, String graphResourceName);
method public static inline void includeDynamic(androidx.navigation.dynamicfeatures.DynamicNavGraphBuilder, String route, String moduleName, String graphResourceName, kotlin.jvm.functions.Function1<? super androidx.navigation.dynamicfeatures.DynamicIncludeNavGraphBuilder,kotlin.Unit> builder);
}
@@ -120,7 +120,7 @@
}
@androidx.navigation.NavDestinationDsl public final class DynamicNavGraphBuilder extends androidx.navigation.NavGraphBuilder {
- ctor public DynamicNavGraphBuilder(androidx.navigation.NavigatorProvider provider, @IdRes int id, @IdRes int startDestination);
+ ctor @Deprecated public DynamicNavGraphBuilder(androidx.navigation.NavigatorProvider provider, @IdRes int id, @IdRes int startDestination);
ctor public DynamicNavGraphBuilder(androidx.navigation.NavigatorProvider provider, String startDestination, optional String? route);
method public String? getModuleName();
method public int getProgressDestination();
@@ -134,19 +134,20 @@
}
public final class DynamicNavGraphBuilderKt {
- method public static inline androidx.navigation.NavGraph navigation(androidx.navigation.NavigatorProvider, optional @IdRes int id, @IdRes int startDestination, kotlin.jvm.functions.Function1<? super androidx.navigation.dynamicfeatures.DynamicNavGraphBuilder,kotlin.Unit> builder);
- method public static inline void navigation(androidx.navigation.dynamicfeatures.DynamicNavGraphBuilder, @IdRes int id, @IdRes int startDestination, kotlin.jvm.functions.Function1<? super androidx.navigation.dynamicfeatures.DynamicNavGraphBuilder,kotlin.Unit> builder);
+ method @Deprecated public static inline androidx.navigation.NavGraph navigation(androidx.navigation.NavigatorProvider, optional @IdRes int id, @IdRes int startDestination, kotlin.jvm.functions.Function1<? super androidx.navigation.dynamicfeatures.DynamicNavGraphBuilder,kotlin.Unit> builder);
+ method @Deprecated public static inline void navigation(androidx.navigation.dynamicfeatures.DynamicNavGraphBuilder, @IdRes int id, @IdRes int startDestination, kotlin.jvm.functions.Function1<? super androidx.navigation.dynamicfeatures.DynamicNavGraphBuilder,kotlin.Unit> builder);
method public static inline androidx.navigation.NavGraph navigation(androidx.navigation.NavigatorProvider, String startDestination, optional String? route, kotlin.jvm.functions.Function1<? super androidx.navigation.dynamicfeatures.DynamicNavGraphBuilder,kotlin.Unit> builder);
method public static inline void navigation(androidx.navigation.dynamicfeatures.DynamicNavGraphBuilder, String startDestination, String route, kotlin.jvm.functions.Function1<? super androidx.navigation.dynamicfeatures.DynamicNavGraphBuilder,kotlin.Unit> builder);
}
public final class NavControllerKt {
- method public static inline androidx.navigation.NavGraph createGraph(androidx.navigation.NavController, optional @IdRes int id, @IdRes int startDestination, kotlin.jvm.functions.Function1<? super androidx.navigation.dynamicfeatures.DynamicNavGraphBuilder,kotlin.Unit> builder);
+ method @Deprecated public static inline androidx.navigation.NavGraph createGraph(androidx.navigation.NavController, optional @IdRes int id, @IdRes int startDestination, kotlin.jvm.functions.Function1<? super androidx.navigation.dynamicfeatures.DynamicNavGraphBuilder,kotlin.Unit> builder);
method public static inline androidx.navigation.NavGraph createGraph(androidx.navigation.NavController, String startDestination, optional String? route, kotlin.jvm.functions.Function1<? super androidx.navigation.dynamicfeatures.DynamicNavGraphBuilder,kotlin.Unit> builder);
}
public final class NavHostKt {
- method public static inline androidx.navigation.NavGraph createGraph(androidx.navigation.NavHost, optional @IdRes int id, @IdRes int startDestination, kotlin.jvm.functions.Function1<? super androidx.navigation.dynamicfeatures.DynamicNavGraphBuilder,kotlin.Unit> builder);
+ method @Deprecated public static inline androidx.navigation.NavGraph createGraph(androidx.navigation.NavHost, optional @IdRes int id, @IdRes int startDestination, kotlin.jvm.functions.Function1<? super androidx.navigation.dynamicfeatures.DynamicNavGraphBuilder,kotlin.Unit> builder);
+ method public static inline androidx.navigation.NavGraph createGraph(androidx.navigation.NavHost, String startDestination, optional String? route, kotlin.jvm.functions.Function1<? super androidx.navigation.dynamicfeatures.DynamicNavGraphBuilder,kotlin.Unit> builder);
}
}
diff --git a/navigation/navigation-dynamic-features-runtime/api/public_plus_experimental_current.txt b/navigation/navigation-dynamic-features-runtime/api/public_plus_experimental_current.txt
index 9807b58..ea49279 100644
--- a/navigation/navigation-dynamic-features-runtime/api/public_plus_experimental_current.txt
+++ b/navigation/navigation-dynamic-features-runtime/api/public_plus_experimental_current.txt
@@ -15,7 +15,7 @@
}
@androidx.navigation.NavDestinationDsl public final class DynamicActivityNavigatorDestinationBuilder extends androidx.navigation.NavDestinationBuilder<androidx.navigation.ActivityNavigator.Destination> {
- ctor public DynamicActivityNavigatorDestinationBuilder(androidx.navigation.dynamicfeatures.DynamicActivityNavigator activityNavigator, @IdRes int id);
+ ctor @Deprecated public DynamicActivityNavigatorDestinationBuilder(androidx.navigation.dynamicfeatures.DynamicActivityNavigator activityNavigator, @IdRes int id);
ctor public DynamicActivityNavigatorDestinationBuilder(androidx.navigation.dynamicfeatures.DynamicActivityNavigator activityNavigator, String route);
method public androidx.navigation.dynamicfeatures.DynamicActivityNavigator.Destination build();
method public String? getAction();
@@ -39,7 +39,7 @@
}
public final class DynamicActivityNavigatorDestinationBuilderKt {
- method public static inline void activity(androidx.navigation.dynamicfeatures.DynamicNavGraphBuilder, @IdRes int id, kotlin.jvm.functions.Function1<? super androidx.navigation.dynamicfeatures.DynamicActivityNavigatorDestinationBuilder,kotlin.Unit> builder);
+ method @Deprecated public static inline void activity(androidx.navigation.dynamicfeatures.DynamicNavGraphBuilder, @IdRes int id, kotlin.jvm.functions.Function1<? super androidx.navigation.dynamicfeatures.DynamicActivityNavigatorDestinationBuilder,kotlin.Unit> builder);
method public static inline void activity(androidx.navigation.dynamicfeatures.DynamicNavGraphBuilder, String route, kotlin.jvm.functions.Function1<? super androidx.navigation.dynamicfeatures.DynamicActivityNavigatorDestinationBuilder,kotlin.Unit> builder);
}
@@ -87,7 +87,7 @@
}
@androidx.navigation.NavDestinationDsl public final class DynamicIncludeNavGraphBuilder extends androidx.navigation.NavDestinationBuilder<androidx.navigation.dynamicfeatures.DynamicIncludeGraphNavigator.DynamicIncludeNavGraph> {
- ctor public DynamicIncludeNavGraphBuilder(androidx.navigation.dynamicfeatures.DynamicIncludeGraphNavigator dynamicIncludeGraphNavigator, @IdRes int id, String moduleName, String graphResourceName);
+ ctor @Deprecated public DynamicIncludeNavGraphBuilder(androidx.navigation.dynamicfeatures.DynamicIncludeGraphNavigator dynamicIncludeGraphNavigator, @IdRes int id, String moduleName, String graphResourceName);
ctor public DynamicIncludeNavGraphBuilder(androidx.navigation.dynamicfeatures.DynamicIncludeGraphNavigator dynamicIncludeGraphNavigator, String route, String moduleName, String graphResourceName);
method public androidx.navigation.dynamicfeatures.DynamicIncludeGraphNavigator.DynamicIncludeNavGraph build();
method public String? getGraphPackage();
@@ -96,8 +96,8 @@
}
public final class DynamicIncludeNavGraphBuilderKt {
- method public static inline void includeDynamic(androidx.navigation.dynamicfeatures.DynamicNavGraphBuilder, @IdRes int id, String moduleName, String graphResourceName);
- method public static inline void includeDynamic(androidx.navigation.dynamicfeatures.DynamicNavGraphBuilder, @IdRes int id, String moduleName, String graphResourceName, kotlin.jvm.functions.Function1<? super androidx.navigation.dynamicfeatures.DynamicIncludeNavGraphBuilder,kotlin.Unit> builder);
+ method @Deprecated public static inline void includeDynamic(androidx.navigation.dynamicfeatures.DynamicNavGraphBuilder, @IdRes int id, String moduleName, String graphResourceName);
+ method @Deprecated public static inline void includeDynamic(androidx.navigation.dynamicfeatures.DynamicNavGraphBuilder, @IdRes int id, String moduleName, String graphResourceName, kotlin.jvm.functions.Function1<? super androidx.navigation.dynamicfeatures.DynamicIncludeNavGraphBuilder,kotlin.Unit> builder);
method public static inline void includeDynamic(androidx.navigation.dynamicfeatures.DynamicNavGraphBuilder, String route, String moduleName, String graphResourceName);
method public static inline void includeDynamic(androidx.navigation.dynamicfeatures.DynamicNavGraphBuilder, String route, String moduleName, String graphResourceName, kotlin.jvm.functions.Function1<? super androidx.navigation.dynamicfeatures.DynamicIncludeNavGraphBuilder,kotlin.Unit> builder);
}
@@ -120,7 +120,7 @@
}
@androidx.navigation.NavDestinationDsl public final class DynamicNavGraphBuilder extends androidx.navigation.NavGraphBuilder {
- ctor public DynamicNavGraphBuilder(androidx.navigation.NavigatorProvider provider, @IdRes int id, @IdRes int startDestination);
+ ctor @Deprecated public DynamicNavGraphBuilder(androidx.navigation.NavigatorProvider provider, @IdRes int id, @IdRes int startDestination);
ctor public DynamicNavGraphBuilder(androidx.navigation.NavigatorProvider provider, String startDestination, optional String? route);
method public String? getModuleName();
method public int getProgressDestination();
@@ -134,19 +134,20 @@
}
public final class DynamicNavGraphBuilderKt {
- method public static inline androidx.navigation.NavGraph navigation(androidx.navigation.NavigatorProvider, optional @IdRes int id, @IdRes int startDestination, kotlin.jvm.functions.Function1<? super androidx.navigation.dynamicfeatures.DynamicNavGraphBuilder,kotlin.Unit> builder);
- method public static inline void navigation(androidx.navigation.dynamicfeatures.DynamicNavGraphBuilder, @IdRes int id, @IdRes int startDestination, kotlin.jvm.functions.Function1<? super androidx.navigation.dynamicfeatures.DynamicNavGraphBuilder,kotlin.Unit> builder);
+ method @Deprecated public static inline androidx.navigation.NavGraph navigation(androidx.navigation.NavigatorProvider, optional @IdRes int id, @IdRes int startDestination, kotlin.jvm.functions.Function1<? super androidx.navigation.dynamicfeatures.DynamicNavGraphBuilder,kotlin.Unit> builder);
+ method @Deprecated public static inline void navigation(androidx.navigation.dynamicfeatures.DynamicNavGraphBuilder, @IdRes int id, @IdRes int startDestination, kotlin.jvm.functions.Function1<? super androidx.navigation.dynamicfeatures.DynamicNavGraphBuilder,kotlin.Unit> builder);
method public static inline androidx.navigation.NavGraph navigation(androidx.navigation.NavigatorProvider, String startDestination, optional String? route, kotlin.jvm.functions.Function1<? super androidx.navigation.dynamicfeatures.DynamicNavGraphBuilder,kotlin.Unit> builder);
method public static inline void navigation(androidx.navigation.dynamicfeatures.DynamicNavGraphBuilder, String startDestination, String route, kotlin.jvm.functions.Function1<? super androidx.navigation.dynamicfeatures.DynamicNavGraphBuilder,kotlin.Unit> builder);
}
public final class NavControllerKt {
- method public static inline androidx.navigation.NavGraph createGraph(androidx.navigation.NavController, optional @IdRes int id, @IdRes int startDestination, kotlin.jvm.functions.Function1<? super androidx.navigation.dynamicfeatures.DynamicNavGraphBuilder,kotlin.Unit> builder);
+ method @Deprecated public static inline androidx.navigation.NavGraph createGraph(androidx.navigation.NavController, optional @IdRes int id, @IdRes int startDestination, kotlin.jvm.functions.Function1<? super androidx.navigation.dynamicfeatures.DynamicNavGraphBuilder,kotlin.Unit> builder);
method public static inline androidx.navigation.NavGraph createGraph(androidx.navigation.NavController, String startDestination, optional String? route, kotlin.jvm.functions.Function1<? super androidx.navigation.dynamicfeatures.DynamicNavGraphBuilder,kotlin.Unit> builder);
}
public final class NavHostKt {
- method public static inline androidx.navigation.NavGraph createGraph(androidx.navigation.NavHost, optional @IdRes int id, @IdRes int startDestination, kotlin.jvm.functions.Function1<? super androidx.navigation.dynamicfeatures.DynamicNavGraphBuilder,kotlin.Unit> builder);
+ method @Deprecated public static inline androidx.navigation.NavGraph createGraph(androidx.navigation.NavHost, optional @IdRes int id, @IdRes int startDestination, kotlin.jvm.functions.Function1<? super androidx.navigation.dynamicfeatures.DynamicNavGraphBuilder,kotlin.Unit> builder);
+ method public static inline androidx.navigation.NavGraph createGraph(androidx.navigation.NavHost, String startDestination, optional String? route, kotlin.jvm.functions.Function1<? super androidx.navigation.dynamicfeatures.DynamicNavGraphBuilder,kotlin.Unit> builder);
}
}
diff --git a/navigation/navigation-dynamic-features-runtime/api/restricted_current.txt b/navigation/navigation-dynamic-features-runtime/api/restricted_current.txt
index 9807b58..ea49279 100644
--- a/navigation/navigation-dynamic-features-runtime/api/restricted_current.txt
+++ b/navigation/navigation-dynamic-features-runtime/api/restricted_current.txt
@@ -15,7 +15,7 @@
}
@androidx.navigation.NavDestinationDsl public final class DynamicActivityNavigatorDestinationBuilder extends androidx.navigation.NavDestinationBuilder<androidx.navigation.ActivityNavigator.Destination> {
- ctor public DynamicActivityNavigatorDestinationBuilder(androidx.navigation.dynamicfeatures.DynamicActivityNavigator activityNavigator, @IdRes int id);
+ ctor @Deprecated public DynamicActivityNavigatorDestinationBuilder(androidx.navigation.dynamicfeatures.DynamicActivityNavigator activityNavigator, @IdRes int id);
ctor public DynamicActivityNavigatorDestinationBuilder(androidx.navigation.dynamicfeatures.DynamicActivityNavigator activityNavigator, String route);
method public androidx.navigation.dynamicfeatures.DynamicActivityNavigator.Destination build();
method public String? getAction();
@@ -39,7 +39,7 @@
}
public final class DynamicActivityNavigatorDestinationBuilderKt {
- method public static inline void activity(androidx.navigation.dynamicfeatures.DynamicNavGraphBuilder, @IdRes int id, kotlin.jvm.functions.Function1<? super androidx.navigation.dynamicfeatures.DynamicActivityNavigatorDestinationBuilder,kotlin.Unit> builder);
+ method @Deprecated public static inline void activity(androidx.navigation.dynamicfeatures.DynamicNavGraphBuilder, @IdRes int id, kotlin.jvm.functions.Function1<? super androidx.navigation.dynamicfeatures.DynamicActivityNavigatorDestinationBuilder,kotlin.Unit> builder);
method public static inline void activity(androidx.navigation.dynamicfeatures.DynamicNavGraphBuilder, String route, kotlin.jvm.functions.Function1<? super androidx.navigation.dynamicfeatures.DynamicActivityNavigatorDestinationBuilder,kotlin.Unit> builder);
}
@@ -87,7 +87,7 @@
}
@androidx.navigation.NavDestinationDsl public final class DynamicIncludeNavGraphBuilder extends androidx.navigation.NavDestinationBuilder<androidx.navigation.dynamicfeatures.DynamicIncludeGraphNavigator.DynamicIncludeNavGraph> {
- ctor public DynamicIncludeNavGraphBuilder(androidx.navigation.dynamicfeatures.DynamicIncludeGraphNavigator dynamicIncludeGraphNavigator, @IdRes int id, String moduleName, String graphResourceName);
+ ctor @Deprecated public DynamicIncludeNavGraphBuilder(androidx.navigation.dynamicfeatures.DynamicIncludeGraphNavigator dynamicIncludeGraphNavigator, @IdRes int id, String moduleName, String graphResourceName);
ctor public DynamicIncludeNavGraphBuilder(androidx.navigation.dynamicfeatures.DynamicIncludeGraphNavigator dynamicIncludeGraphNavigator, String route, String moduleName, String graphResourceName);
method public androidx.navigation.dynamicfeatures.DynamicIncludeGraphNavigator.DynamicIncludeNavGraph build();
method public String? getGraphPackage();
@@ -96,8 +96,8 @@
}
public final class DynamicIncludeNavGraphBuilderKt {
- method public static inline void includeDynamic(androidx.navigation.dynamicfeatures.DynamicNavGraphBuilder, @IdRes int id, String moduleName, String graphResourceName);
- method public static inline void includeDynamic(androidx.navigation.dynamicfeatures.DynamicNavGraphBuilder, @IdRes int id, String moduleName, String graphResourceName, kotlin.jvm.functions.Function1<? super androidx.navigation.dynamicfeatures.DynamicIncludeNavGraphBuilder,kotlin.Unit> builder);
+ method @Deprecated public static inline void includeDynamic(androidx.navigation.dynamicfeatures.DynamicNavGraphBuilder, @IdRes int id, String moduleName, String graphResourceName);
+ method @Deprecated public static inline void includeDynamic(androidx.navigation.dynamicfeatures.DynamicNavGraphBuilder, @IdRes int id, String moduleName, String graphResourceName, kotlin.jvm.functions.Function1<? super androidx.navigation.dynamicfeatures.DynamicIncludeNavGraphBuilder,kotlin.Unit> builder);
method public static inline void includeDynamic(androidx.navigation.dynamicfeatures.DynamicNavGraphBuilder, String route, String moduleName, String graphResourceName);
method public static inline void includeDynamic(androidx.navigation.dynamicfeatures.DynamicNavGraphBuilder, String route, String moduleName, String graphResourceName, kotlin.jvm.functions.Function1<? super androidx.navigation.dynamicfeatures.DynamicIncludeNavGraphBuilder,kotlin.Unit> builder);
}
@@ -120,7 +120,7 @@
}
@androidx.navigation.NavDestinationDsl public final class DynamicNavGraphBuilder extends androidx.navigation.NavGraphBuilder {
- ctor public DynamicNavGraphBuilder(androidx.navigation.NavigatorProvider provider, @IdRes int id, @IdRes int startDestination);
+ ctor @Deprecated public DynamicNavGraphBuilder(androidx.navigation.NavigatorProvider provider, @IdRes int id, @IdRes int startDestination);
ctor public DynamicNavGraphBuilder(androidx.navigation.NavigatorProvider provider, String startDestination, optional String? route);
method public String? getModuleName();
method public int getProgressDestination();
@@ -134,19 +134,20 @@
}
public final class DynamicNavGraphBuilderKt {
- method public static inline androidx.navigation.NavGraph navigation(androidx.navigation.NavigatorProvider, optional @IdRes int id, @IdRes int startDestination, kotlin.jvm.functions.Function1<? super androidx.navigation.dynamicfeatures.DynamicNavGraphBuilder,kotlin.Unit> builder);
- method public static inline void navigation(androidx.navigation.dynamicfeatures.DynamicNavGraphBuilder, @IdRes int id, @IdRes int startDestination, kotlin.jvm.functions.Function1<? super androidx.navigation.dynamicfeatures.DynamicNavGraphBuilder,kotlin.Unit> builder);
+ method @Deprecated public static inline androidx.navigation.NavGraph navigation(androidx.navigation.NavigatorProvider, optional @IdRes int id, @IdRes int startDestination, kotlin.jvm.functions.Function1<? super androidx.navigation.dynamicfeatures.DynamicNavGraphBuilder,kotlin.Unit> builder);
+ method @Deprecated public static inline void navigation(androidx.navigation.dynamicfeatures.DynamicNavGraphBuilder, @IdRes int id, @IdRes int startDestination, kotlin.jvm.functions.Function1<? super androidx.navigation.dynamicfeatures.DynamicNavGraphBuilder,kotlin.Unit> builder);
method public static inline androidx.navigation.NavGraph navigation(androidx.navigation.NavigatorProvider, String startDestination, optional String? route, kotlin.jvm.functions.Function1<? super androidx.navigation.dynamicfeatures.DynamicNavGraphBuilder,kotlin.Unit> builder);
method public static inline void navigation(androidx.navigation.dynamicfeatures.DynamicNavGraphBuilder, String startDestination, String route, kotlin.jvm.functions.Function1<? super androidx.navigation.dynamicfeatures.DynamicNavGraphBuilder,kotlin.Unit> builder);
}
public final class NavControllerKt {
- method public static inline androidx.navigation.NavGraph createGraph(androidx.navigation.NavController, optional @IdRes int id, @IdRes int startDestination, kotlin.jvm.functions.Function1<? super androidx.navigation.dynamicfeatures.DynamicNavGraphBuilder,kotlin.Unit> builder);
+ method @Deprecated public static inline androidx.navigation.NavGraph createGraph(androidx.navigation.NavController, optional @IdRes int id, @IdRes int startDestination, kotlin.jvm.functions.Function1<? super androidx.navigation.dynamicfeatures.DynamicNavGraphBuilder,kotlin.Unit> builder);
method public static inline androidx.navigation.NavGraph createGraph(androidx.navigation.NavController, String startDestination, optional String? route, kotlin.jvm.functions.Function1<? super androidx.navigation.dynamicfeatures.DynamicNavGraphBuilder,kotlin.Unit> builder);
}
public final class NavHostKt {
- method public static inline androidx.navigation.NavGraph createGraph(androidx.navigation.NavHost, optional @IdRes int id, @IdRes int startDestination, kotlin.jvm.functions.Function1<? super androidx.navigation.dynamicfeatures.DynamicNavGraphBuilder,kotlin.Unit> builder);
+ method @Deprecated public static inline androidx.navigation.NavGraph createGraph(androidx.navigation.NavHost, optional @IdRes int id, @IdRes int startDestination, kotlin.jvm.functions.Function1<? super androidx.navigation.dynamicfeatures.DynamicNavGraphBuilder,kotlin.Unit> builder);
+ method public static inline androidx.navigation.NavGraph createGraph(androidx.navigation.NavHost, String startDestination, optional String? route, kotlin.jvm.functions.Function1<? super androidx.navigation.dynamicfeatures.DynamicNavGraphBuilder,kotlin.Unit> builder);
}
}
diff --git a/navigation/navigation-dynamic-features-runtime/build.gradle b/navigation/navigation-dynamic-features-runtime/build.gradle
index bc5ae9a..e1fc340 100644
--- a/navigation/navigation-dynamic-features-runtime/build.gradle
+++ b/navigation/navigation-dynamic-features-runtime/build.gradle
@@ -32,7 +32,6 @@
dependencies {
api(project(":navigation:navigation-runtime"))
api(libs.playCore)
- api(libs.kotlinStdlib)
testImplementation(project(":navigation:navigation-testing"))
testImplementation("androidx.arch.core:core-testing:2.1.0")
@@ -53,6 +52,9 @@
androidTestImplementation(libs.mockitoCore, excludes.bytebuddy)
androidTestImplementation(libs.truth)
androidTestImplementation(libs.multidex)
+ androidTestImplementation(project(":internal-testutils-runtime"), {
+ exclude group: "androidx.fragment", module: "fragment"
+ })
}
androidx {
diff --git a/navigation/navigation-dynamic-features-runtime/src/androidTest/java/androidx/navigation/dynamicfeatures/DynamicActivityNavigatorDestinationBuilderTest.kt b/navigation/navigation-dynamic-features-runtime/src/androidTest/java/androidx/navigation/dynamicfeatures/DynamicActivityNavigatorDestinationBuilderTest.kt
index 5fd5b65..f8eb54b 100644
--- a/navigation/navigation-dynamic-features-runtime/src/androidTest/java/androidx/navigation/dynamicfeatures/DynamicActivityNavigatorDestinationBuilderTest.kt
+++ b/navigation/navigation-dynamic-features-runtime/src/androidTest/java/androidx/navigation/dynamicfeatures/DynamicActivityNavigatorDestinationBuilderTest.kt
@@ -29,7 +29,7 @@
@SmallTest
@RunWith(AndroidJUnit4::class)
-class DynamicActivityNavigatorDestinationBuilderTest {
+public class DynamicActivityNavigatorDestinationBuilderTest {
private val context: Context = ApplicationProvider.getApplicationContext()
@@ -46,8 +46,9 @@
)
}
+ @Suppress("DEPRECATION")
@Test
- fun module() {
+ public fun module() {
val graph = navController.createGraph(startDestination = DESTINATION_ID) {
activity(DESTINATION_ID) {
moduleName = MODULE_NAME
@@ -60,8 +61,9 @@
.isEqualTo(MODULE_NAME)
}
+ @Suppress("DEPRECATION")
@Test
- fun noModule() {
+ public fun noModule() {
val graph = navController.createGraph(startDestination = DESTINATION_ID) {
activity(DESTINATION_ID) {
}
@@ -71,8 +73,9 @@
).isNull()
}
+ @Suppress("DEPRECATION")
@Test
- fun activity() {
+ public fun activity() {
val graph = navController.createGraph(startDestination = DESTINATION_ID) {
activity(DESTINATION_ID) {
moduleName = MODULE_NAME
@@ -90,8 +93,9 @@
)
}
+ @Suppress("DEPRECATION")
@Test
- fun noActivity() {
+ public fun noActivity() {
val graph = navController.createGraph(startDestination = DESTINATION_ID) {
activity(DESTINATION_ID) {
}
@@ -102,8 +106,9 @@
).isNull()
}
+ @Suppress("DEPRECATION")
@Test
- fun modulePackage() {
+ public fun modulePackage() {
val graph = navController.createGraph(startDestination = DESTINATION_ID) {
activity(DESTINATION_ID) {
moduleName = MODULE_NAME
@@ -116,7 +121,7 @@
}
@Test
- fun moduleRoute() {
+ public fun moduleRoute() {
val graph = navController.createGraph(startDestination = DESTINATION_ROUTE) {
activity(DESTINATION_ROUTE) {
moduleName = MODULE_NAME
@@ -130,7 +135,7 @@
}
@Test
- fun noModuleRoute() {
+ public fun noModuleRoute() {
val graph = navController.createGraph(startDestination = DESTINATION_ROUTE) {
activity(DESTINATION_ROUTE) {
}
@@ -141,7 +146,7 @@
}
@Test
- fun activityRoute() {
+ public fun activityRoute() {
val graph = navController.createGraph(startDestination = DESTINATION_ROUTE) {
activity(DESTINATION_ROUTE) {
moduleName = MODULE_NAME
@@ -160,7 +165,7 @@
}
@Test
- fun noActivityRoute() {
+ public fun noActivityRoute() {
val graph = navController.createGraph(startDestination = DESTINATION_ROUTE) {
activity(DESTINATION_ROUTE) {
}
@@ -172,7 +177,7 @@
}
@Test
- fun modulePackageRoute() {
+ public fun modulePackageRoute() {
val graph = navController.createGraph(startDestination = DESTINATION_ROUTE) {
activity(DESTINATION_ROUTE) {
moduleName = MODULE_NAME
diff --git a/navigation/navigation-dynamic-features-runtime/src/androidTest/java/androidx/navigation/dynamicfeatures/DynamicActivityNavigatorTest.kt b/navigation/navigation-dynamic-features-runtime/src/androidTest/java/androidx/navigation/dynamicfeatures/DynamicActivityNavigatorTest.kt
index 06fcce8..c072251 100644
--- a/navigation/navigation-dynamic-features-runtime/src/androidTest/java/androidx/navigation/dynamicfeatures/DynamicActivityNavigatorTest.kt
+++ b/navigation/navigation-dynamic-features-runtime/src/androidTest/java/androidx/navigation/dynamicfeatures/DynamicActivityNavigatorTest.kt
@@ -20,8 +20,10 @@
import android.content.Intent
import androidx.navigation.NavigatorProvider
import androidx.navigation.NoOpNavigator
+import androidx.test.ext.junit.rules.ActivityScenarioRule
import androidx.test.ext.junit.runners.AndroidJUnit4
import androidx.test.filters.SmallTest
+import androidx.testutils.withActivity
import com.google.android.play.core.splitinstall.SplitInstallManager
import org.junit.Assert.assertNotNull
import org.junit.Before
@@ -31,11 +33,12 @@
import org.mockito.Mockito.mock
/* ktlint-disable no-unused-imports */ // https://github.com/pinterest/ktlint/issues/937
import org.mockito.Mockito.`when` as mockWhen
+
/* ktlint-enable unused-imports */
@SmallTest
@RunWith(AndroidJUnit4::class)
-class DynamicActivityNavigatorTest {
+public class DynamicActivityNavigatorTest {
private lateinit var navigator: DynamicActivityNavigator
private lateinit var installManager: DynamicInstallManager
@@ -46,44 +49,54 @@
@Suppress("DEPRECATION")
@get:Rule
- val activityTestRule = androidx.test.rule.ActivityTestRule(NavigationActivity::class.java)
+ public val activityRule: ActivityScenarioRule<NavigationActivity> =
+ ActivityScenarioRule(NavigationActivity::class.java)
@Before
- fun setup() {
+ public fun setup() {
splitInstallManager = mock(SplitInstallManager::class.java)
- installManager = DynamicInstallManager(activityTestRule.activity, splitInstallManager)
- navigator = DynamicActivityNavigator(activityTestRule.activity, installManager)
+ activityRule.withActivity {
+ installManager = DynamicInstallManager(
+ this,
+ splitInstallManager
+ )
+ navigator = DynamicActivityNavigator(this, installManager)
+ dynamicDestination = navigator.createDestination()
+ dynamicDestination.setIntent(
+ Intent(this, DestinationActivity::class.java)
+ )
+ }
provider = NavigatorProvider()
noOpNavigator = NoOpNavigator()
provider.addNavigator(noOpNavigator)
- dynamicDestination = navigator.createDestination()
- dynamicDestination.setIntent(
- Intent(activityTestRule.activity, DestinationActivity::class.java)
- )
}
@Test
- fun navigate_DynamicActivityDestination() {
+ public fun navigate_DynamicActivityDestination() {
navigator.navigate(dynamicDestination, null, null, null)
}
@Test(expected = IllegalStateException::class)
- fun navigate_DynamicActivityDestination_NoDynamicNavGraph() {
+ public fun navigate_DynamicActivityDestination_NoDynamicNavGraph() {
+ lateinit var activity: NavigationActivity
+ activityRule.scenario.onActivity {
+ activity = it
+ }
@Suppress("UNUSED_VARIABLE")
val destination = DynamicActivityNavigator.Destination(NavigatorProvider())
val navDestination = mock(DynamicActivityNavigator.Destination::class.java).apply {
mockWhen(moduleName).thenReturn("module")
- setIntent(Intent(activityTestRule.activity, DestinationActivity::class.java))
+ setIntent(Intent(activity, DestinationActivity::class.java))
}
navigator.navigate(navDestination, null, null, null)
}
@Test
- fun createDestination() {
+ public fun createDestination() {
assertNotNull(navigator.createDestination())
}
}
-class NavigationActivity : Activity()
+public class NavigationActivity : Activity()
-class DestinationActivity : Activity()
+public class DestinationActivity : Activity()
diff --git a/navigation/navigation-dynamic-features-runtime/src/androidTest/java/androidx/navigation/dynamicfeatures/DynamicIncludeGraphNavigatorTest.kt b/navigation/navigation-dynamic-features-runtime/src/androidTest/java/androidx/navigation/dynamicfeatures/DynamicIncludeGraphNavigatorTest.kt
index ab2697a..9b562d7 100644
--- a/navigation/navigation-dynamic-features-runtime/src/androidTest/java/androidx/navigation/dynamicfeatures/DynamicIncludeGraphNavigatorTest.kt
+++ b/navigation/navigation-dynamic-features-runtime/src/androidTest/java/androidx/navigation/dynamicfeatures/DynamicIncludeGraphNavigatorTest.kt
@@ -16,13 +16,16 @@
package androidx.navigation.dynamicfeatures
+import android.content.Context
import android.os.Bundle
import androidx.navigation.NavController
import androidx.navigation.NoOpNavigator
import androidx.navigation.dynamicfeatures.shared.AndroidTestDynamicInstallManager
import androidx.navigation.dynamicfeatures.test.R
+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.assertThat
import org.junit.Assert.assertNotNull
import org.junit.Assert.fail
@@ -34,21 +37,26 @@
@MediumTest
@RunWith(AndroidJUnit4::class)
-class DynamicIncludeGraphNavigatorTest {
+public class DynamicIncludeGraphNavigatorTest {
private lateinit var navigator: DynamicIncludeGraphNavigator
+ private lateinit var context: Context
- @Suppress("DEPRECATION")
@get:Rule
- val rule = androidx.test.rule.ActivityTestRule(NavigationActivity::class.java)
+ public val rule: ActivityScenarioRule<NavigationActivity> =
+ ActivityScenarioRule(NavigationActivity::class.java)
@Before
- fun setup() {
+ public fun setup() {
setupInternal()
}
private fun setupInternal(navGraphId: Int = R.navigation.nav_graph) {
- val context = rule.activity
+
+ rule.withActivity {
+ context = this
+ }
+
val navController = NavController(context)
val navigatorProvider = navController.navigatorProvider
val installManager = AndroidTestDynamicInstallManager(context).also {
@@ -72,13 +80,12 @@
}
@Test
- fun createDestination() {
+ public fun createDestination() {
assertNotNull(navigator.createDestination())
}
@Test
- fun testReplacePackagePlaceholder() {
- val context = rule.activity
+ public fun testReplacePackagePlaceholder() {
val packageName = context.packageName
val dynamicNavGraph = navigator.createDestination().apply {
moduleName = FEATURE_NAME
@@ -105,7 +112,7 @@
}
@Test
- fun invalidGraphId() {
+ public fun invalidGraphId() {
try {
setupInternal(R.navigation.nav_invalid_id)
fail("Inflating nav_invalid_id should fail with an IllegalStateException")
@@ -120,23 +127,23 @@
}
@Test
- fun onSaveState() {
+ public fun onSaveState() {
assertThat(navigator.onSaveState()).isEqualTo(Bundle.EMPTY)
}
@Test
- fun onRestoreState() {
+ public fun onRestoreState() {
navigator.onRestoreState(Bundle.EMPTY)
}
@Test
- fun onRestoreState_nestedInclusion() {
+ public fun onRestoreState_nestedInclusion() {
setupInternal(R.navigation.nav_graph_nested_include_dynamic)
navigator.onRestoreState(Bundle.EMPTY)
}
@Test
- fun popBackStack() {
+ public fun popBackStack() {
assertThat(navigator.popBackStack()).isTrue()
}
}
diff --git a/navigation/navigation-dynamic-features-runtime/src/androidTest/java/androidx/navigation/dynamicfeatures/DynamicIncludeNavGraphBuilderTest.kt b/navigation/navigation-dynamic-features-runtime/src/androidTest/java/androidx/navigation/dynamicfeatures/DynamicIncludeNavGraphBuilderTest.kt
index aa3b07d..d90be5f 100644
--- a/navigation/navigation-dynamic-features-runtime/src/androidTest/java/androidx/navigation/dynamicfeatures/DynamicIncludeNavGraphBuilderTest.kt
+++ b/navigation/navigation-dynamic-features-runtime/src/androidTest/java/androidx/navigation/dynamicfeatures/DynamicIncludeNavGraphBuilderTest.kt
@@ -33,7 +33,7 @@
@SmallTest
@RunWith(AndroidJUnit4::class)
-class DynamicIncludeNavGraphBuilderTest {
+public class DynamicIncludeNavGraphBuilderTest {
private val context: Context = ApplicationProvider.getApplicationContext()
private val navController = NavController(context).apply {
@@ -44,8 +44,9 @@
navigatorProvider += NoOpNavigator()
}
+ @Suppress("DEPRECATION")
@Test
- fun includeDynamic() {
+ public fun includeDynamic() {
val graph = navController.navigatorProvider.navigation(startDestination = GRAPH_ID) {
includeDynamic(GRAPH_ID, MODULE_NAME, GRAPH_RESOURCE_NAME) {
graphPackage = GRAPH_PACKAGE
@@ -65,7 +66,9 @@
.isEqualTo(GRAPH_RESOURCE_NAME)
}
- fun includeDynamic_emptyModuleName() {
+ @Suppress("DEPRECATION")
+ @Test
+ public fun includeDynamic_emptyModuleName() {
navController.navigatorProvider.navigation(startDestination = GRAPH_ID) {
try {
includeDynamic(GRAPH_ID, "", GRAPH_RESOURCE_NAME)
@@ -76,8 +79,9 @@
}
}
+ @Suppress("DEPRECATION")
@Test
- fun includeDynamic_graphPackage_null() {
+ public fun includeDynamic_graphPackage_null() {
val graph = navController.navigatorProvider.navigation(startDestination = GRAPH_ID) {
includeDynamic(GRAPH_ID, MODULE_NAME, GRAPH_RESOURCE_NAME)
}
@@ -87,8 +91,9 @@
.that(includeDynamic.graphPackage).isEqualTo("${context.packageName}.$MODULE_NAME")
}
+ @Suppress("DEPRECATION")
@Test
- fun includeDynamic_graphPackage_empty() {
+ public fun includeDynamic_graphPackage_empty() {
navController.navigatorProvider.navigation(startDestination = GRAPH_ID) {
try {
includeDynamic(GRAPH_ID, MODULE_NAME, GRAPH_RESOURCE_NAME) {
@@ -101,8 +106,9 @@
}
}
+ @Suppress("DEPRECATION")
@Test
- fun includeDynamic_graphResourceName_empty() {
+ public fun includeDynamic_graphResourceName_empty() {
navController.navigatorProvider.navigation(startDestination = GRAPH_ID) {
try {
includeDynamic(GRAPH_ID, MODULE_NAME, "")
@@ -114,7 +120,7 @@
}
@Test
- fun includeDynamicRoute() {
+ public fun includeDynamicRoute() {
val graph = navController.navigatorProvider.navigation(startDestination = GRAPH_ROUTE) {
includeDynamic(GRAPH_ROUTE, MODULE_NAME, GRAPH_RESOURCE_NAME) {
graphPackage = GRAPH_PACKAGE
@@ -135,7 +141,7 @@
.isEqualTo(GRAPH_RESOURCE_NAME)
}
- fun includeDynamic_emptyModuleNameRoute() {
+ public fun includeDynamic_emptyModuleNameRoute() {
navController.navigatorProvider.navigation(startDestination = GRAPH_ROUTE) {
try {
includeDynamic(GRAPH_ROUTE, "", GRAPH_RESOURCE_NAME)
@@ -147,7 +153,7 @@
}
@Test
- fun includeDynamic_graphPackage_nullRoute() {
+ public fun includeDynamic_graphPackage_nullRoute() {
val graph = navController.navigatorProvider.navigation(startDestination = GRAPH_ROUTE) {
includeDynamic(GRAPH_ROUTE, MODULE_NAME, GRAPH_RESOURCE_NAME)
}
@@ -159,7 +165,7 @@
}
@Test
- fun includeDynamic_graphPackage_emptyRoute() {
+ public fun includeDynamic_graphPackage_emptyRoute() {
navController.navigatorProvider.navigation(startDestination = GRAPH_ROUTE) {
try {
includeDynamic(GRAPH_ROUTE, MODULE_NAME, GRAPH_RESOURCE_NAME) {
@@ -173,7 +179,7 @@
}
@Test
- fun includeDynamic_graphResourceName_emptyRoute() {
+ public fun includeDynamic_graphResourceName_emptyRoute() {
navController.navigatorProvider.navigation(startDestination = GRAPH_ROUTE) {
try {
includeDynamic(GRAPH_ROUTE, MODULE_NAME, "")
diff --git a/navigation/navigation-dynamic-features-runtime/src/androidTest/java/androidx/navigation/dynamicfeatures/DynamicNavGraphBuilderTest.kt b/navigation/navigation-dynamic-features-runtime/src/androidTest/java/androidx/navigation/dynamicfeatures/DynamicNavGraphBuilderTest.kt
index de954ca..cbbcf25 100644
--- a/navigation/navigation-dynamic-features-runtime/src/androidTest/java/androidx/navigation/dynamicfeatures/DynamicNavGraphBuilderTest.kt
+++ b/navigation/navigation-dynamic-features-runtime/src/androidTest/java/androidx/navigation/dynamicfeatures/DynamicNavGraphBuilderTest.kt
@@ -32,7 +32,7 @@
@SmallTest
@RunWith(AndroidJUnit4::class)
-class DynamicNavGraphBuilderTest {
+public class DynamicNavGraphBuilderTest {
private val provider = NavigatorProvider().apply {
addNavigator(
@@ -44,8 +44,9 @@
addNavigator(NoOpNavigator())
}
+ @Suppress("DEPRECATION")
@Test
- fun navigation() {
+ public fun navigation() {
val graph = provider.navigation(startDestination = DESTINATION_ID) {
moduleName = MODULE_NAME
navDestination(DESTINATION_ID) {}
@@ -59,15 +60,17 @@
.isEqualTo(MODULE_NAME)
}
- fun navigation_emptyModuleName() {
+ @Suppress("DEPRECATION")
+ public fun navigation_emptyModuleName() {
val graph = provider.navigation(startDestination = DESTINATION_ID) {
}
assertWithMessage("Without a moduleName the graph should be a NavGraph")
.that(graph !is DynamicGraphNavigator.DynamicNavGraph)
}
+ @Suppress("DEPRECATION")
@Test
- fun progressDestination() {
+ public fun progressDestination() {
val graph = provider.navigation(startDestination = DESTINATION_ID) {
moduleName = MODULE_NAME
progressDestination = PROGRESS_DESTINATION_ID
@@ -83,8 +86,9 @@
.isTrue()
}
+ @Suppress("DEPRECATION")
@Test
- fun progressDestination_notSet() {
+ public fun progressDestination_notSet() {
val graph = provider.navigation(startDestination = DESTINATION_ID) {
moduleName = MODULE_NAME
} as DynamicGraphNavigator.DynamicNavGraph
@@ -95,7 +99,7 @@
}
@Test
- fun navigationRoute() {
+ public fun navigationRoute() {
val graph = provider.navigation(startDestination = DESTINATION_ROUTE) {
moduleName = MODULE_NAME
navDestination(DESTINATION_ROUTE) {}
@@ -109,7 +113,7 @@
.isEqualTo(MODULE_NAME)
}
- fun navigation_emptyModuleNameRoute() {
+ public fun navigation_emptyModuleNameRoute() {
val graph = provider.navigation(startDestination = DESTINATION_ROUTE) {
}
assertWithMessage("Without a moduleName the graph should be a NavGraph")
@@ -117,7 +121,7 @@
}
@Test
- fun progressDestinationRoute() {
+ public fun progressDestinationRoute() {
val graph = provider.navigation(startDestination = DESTINATION_ROUTE) {
moduleName = MODULE_NAME
progressDestinationRoute = PROGRESS_DESTINATION_ROUTE
@@ -134,7 +138,7 @@
}
@Test
- fun progressDestination_notSetRoute() {
+ public fun progressDestination_notSetRoute() {
val graph = provider.navigation(startDestination = DESTINATION_ROUTE) {
moduleName = MODULE_NAME
} as DynamicGraphNavigator.DynamicNavGraph
@@ -155,16 +159,17 @@
* Create a base NavDestination. Generally, only subtypes of NavDestination should be
* added to a NavGraph (hence why this is not in the common-ktx library)
*/
-fun DynamicNavGraphBuilder.navDestination(
+@Suppress("DEPRECATION")
+public fun DynamicNavGraphBuilder.navDestination(
@IdRes id: Int,
builder: NavDestinationBuilder<NavDestination>.() -> Unit
-) = destination(NavDestinationBuilder(provider[NoOpNavigator::class], id).apply(builder))
+): Unit = destination(NavDestinationBuilder(provider[NoOpNavigator::class], id).apply(builder))
/**
* Create a base NavDestination. Generally, only subtypes of NavDestination should be
* added to a NavGraph (hence why this is not in the common-ktx library)
*/
-fun DynamicNavGraphBuilder.navDestination(
+public fun DynamicNavGraphBuilder.navDestination(
route: String,
builder: NavDestinationBuilder<NavDestination>.() -> Unit
-) = destination(NavDestinationBuilder(provider[NoOpNavigator::class], route).apply(builder))
+): Unit = destination(NavDestinationBuilder(provider[NoOpNavigator::class], route).apply(builder))
\ No newline at end of file
diff --git a/navigation/navigation-dynamic-features-runtime/src/androidTest/java/androidx/navigation/dynamicfeatures/shared/AndroidTestDynamicInstallManager.kt b/navigation/navigation-dynamic-features-runtime/src/androidTest/java/androidx/navigation/dynamicfeatures/shared/AndroidTestDynamicInstallManager.kt
index 60580b4..c400233 100644
--- a/navigation/navigation-dynamic-features-runtime/src/androidTest/java/androidx/navigation/dynamicfeatures/shared/AndroidTestDynamicInstallManager.kt
+++ b/navigation/navigation-dynamic-features-runtime/src/androidTest/java/androidx/navigation/dynamicfeatures/shared/AndroidTestDynamicInstallManager.kt
@@ -24,7 +24,7 @@
/**
* A dynamic install manager used for testing.
*/
-class AndroidTestDynamicInstallManager(
+public class AndroidTestDynamicInstallManager(
context: Context,
- val splitInstallManager: SplitInstallManager = mock(SplitInstallManager::class.java)
+ public val splitInstallManager: SplitInstallManager = mock(SplitInstallManager::class.java)
) : DynamicInstallManager(context, splitInstallManager)
diff --git a/navigation/navigation-dynamic-features-runtime/src/main/java/androidx/navigation/dynamicfeatures/DynamicActivityNavigatorDestinationBuilder.kt b/navigation/navigation-dynamic-features-runtime/src/main/java/androidx/navigation/dynamicfeatures/DynamicActivityNavigatorDestinationBuilder.kt
index 67dde4b..7fefcef 100644
--- a/navigation/navigation-dynamic-features-runtime/src/main/java/androidx/navigation/dynamicfeatures/DynamicActivityNavigatorDestinationBuilder.kt
+++ b/navigation/navigation-dynamic-features-runtime/src/main/java/androidx/navigation/dynamicfeatures/DynamicActivityNavigatorDestinationBuilder.kt
@@ -30,6 +30,11 @@
* Construct a new [DynamicActivityNavigator.Destination]
* @param id Destination id.
*/
+@Suppress("Deprecation")
+@Deprecated(
+ "Use routes to build your DynamicActivityDestination instead",
+ ReplaceWith("activity(route = id.toString()) { builder.invoke() }")
+)
public inline fun DynamicNavGraphBuilder.activity(
@IdRes id: Int,
builder: DynamicActivityNavigatorDestinationBuilder.() -> Unit
@@ -62,6 +67,13 @@
NavDestinationBuilder<ActivityNavigator.Destination> {
private var activityNavigator: DynamicActivityNavigator
+ @Suppress("Deprecation")
+ @Deprecated(
+ "Use routes to build your DynamicActivityDestination instead",
+ ReplaceWith(
+ "DynamicActivityNavigatorDestinationBuilder(activityNavigator, route = id.toString())"
+ )
+ )
public constructor(
activityNavigator: DynamicActivityNavigator,
@IdRes id: Int
diff --git a/navigation/navigation-dynamic-features-runtime/src/main/java/androidx/navigation/dynamicfeatures/DynamicIncludeNavGraphBuilder.kt b/navigation/navigation-dynamic-features-runtime/src/main/java/androidx/navigation/dynamicfeatures/DynamicIncludeNavGraphBuilder.kt
index 4b8cc85..a59d702 100644
--- a/navigation/navigation-dynamic-features-runtime/src/main/java/androidx/navigation/dynamicfeatures/DynamicIncludeNavGraphBuilder.kt
+++ b/navigation/navigation-dynamic-features-runtime/src/main/java/androidx/navigation/dynamicfeatures/DynamicIncludeNavGraphBuilder.kt
@@ -33,6 +33,11 @@
* @param graphResourceName Graph's resource name without the `navigation` qualifier. This
* must not be an empty string.
*/
+@Suppress("Deprecation")
+@Deprecated(
+ "Use routes to include your DynamicNavGraph instead",
+ ReplaceWith("includeDynamic(route = id.toString(), moduleName, graphResourceName)")
+)
public inline fun DynamicNavGraphBuilder.includeDynamic(
@IdRes id: Int,
moduleName: String,
@@ -49,6 +54,13 @@
* must not be an empty string.
* @param builder Another builder for chaining.
*/
+@Suppress("Deprecation")
+@Deprecated(
+ "Use routes to include your DynamicNavGraph instead",
+ ReplaceWith(
+ "includeDynamic(route = id.toString(), moduleName, graphResourceName) { builder.invoke() }"
+ )
+)
public inline fun DynamicNavGraphBuilder.includeDynamic(
@IdRes id: Int,
moduleName: String,
@@ -112,6 +124,14 @@
private var moduleName: String
private var graphResourceName: String
+ @Suppress("Deprecation")
+ @Deprecated(
+ "Use routes to create your DynamicIncludeNavGraphBuilder instead",
+ ReplaceWith(
+ "DynamicIncludeNavGraphBuilder(dynamicIncludeGraphNavigator, route = id.toString(), " +
+ "moduleName, graphResourceName)"
+ )
+ )
public constructor(
dynamicIncludeGraphNavigator: DynamicIncludeGraphNavigator,
@IdRes id: Int,
diff --git a/navigation/navigation-dynamic-features-runtime/src/main/java/androidx/navigation/dynamicfeatures/DynamicNavGraphBuilder.kt b/navigation/navigation-dynamic-features-runtime/src/main/java/androidx/navigation/dynamicfeatures/DynamicNavGraphBuilder.kt
index 1919a1f..367d36f 100644
--- a/navigation/navigation-dynamic-features-runtime/src/main/java/androidx/navigation/dynamicfeatures/DynamicNavGraphBuilder.kt
+++ b/navigation/navigation-dynamic-features-runtime/src/main/java/androidx/navigation/dynamicfeatures/DynamicNavGraphBuilder.kt
@@ -32,6 +32,14 @@
* @param startDestination Id start destination in the graph
* @param builder Another builder for chaining.
*/
+@Suppress("Deprecation")
+@Deprecated(
+ "Use routes to create your DynamicNavGraph instead",
+ ReplaceWith(
+ "navigation(startDestination = startDestination.toString(), route = id.toString()) " +
+ "{ builder.invoke() }"
+ )
+)
public inline fun NavigatorProvider.navigation(
@IdRes id: Int = 0,
@IdRes startDestination: Int,
@@ -49,6 +57,14 @@
* @param startDestination Id start destination in the graph
* @param builder Another builder for chaining.
*/
+@Suppress("Deprecation")
+@Deprecated(
+ "Use routes to create your DynamicNavGraph instead",
+ ReplaceWith(
+ "navigation(startDestination = startDestination.toString(), route = id.toString()) " +
+ "{ builder.invoke() }"
+ )
+)
public inline fun DynamicNavGraphBuilder.navigation(
@IdRes id: Int,
@IdRes startDestination: Int,
@@ -105,6 +121,14 @@
@IdRes private var startDestinationId: Int = 0
private var startDestinationRoute: String? = null
+ @Suppress("Deprecation")
+ @Deprecated(
+ "Use routes to create your DynamicNavGraphBuilder instead",
+ ReplaceWith(
+ "DynamicNavGraphBuilder(provider, startDestination = startDestination.toString(), " +
+ "route = id.toString())"
+ )
+ )
public constructor(
provider: NavigatorProvider,
@IdRes id: Int,
diff --git a/navigation/navigation-dynamic-features-runtime/src/main/java/androidx/navigation/dynamicfeatures/NavController.kt b/navigation/navigation-dynamic-features-runtime/src/main/java/androidx/navigation/dynamicfeatures/NavController.kt
index f9e3d8f..f35e4e4 100644
--- a/navigation/navigation-dynamic-features-runtime/src/main/java/androidx/navigation/dynamicfeatures/NavController.kt
+++ b/navigation/navigation-dynamic-features-runtime/src/main/java/androidx/navigation/dynamicfeatures/NavController.kt
@@ -23,6 +23,14 @@
/**
* Construct a new [androidx.navigation.NavGraph] that supports dynamic navigation destinations
*/
+@Suppress("Deprecation")
+@Deprecated(
+ "Use routes to create your dynamic NavGraph instead",
+ ReplaceWith(
+ "createGraph(startDestination = startDestination.toString(), route = id.toString()) " +
+ "{ builder.invoke() }"
+ )
+)
public inline fun NavController.createGraph(
@IdRes id: Int = 0,
@IdRes startDestination: Int,
diff --git a/navigation/navigation-dynamic-features-runtime/src/main/java/androidx/navigation/dynamicfeatures/NavHost.kt b/navigation/navigation-dynamic-features-runtime/src/main/java/androidx/navigation/dynamicfeatures/NavHost.kt
index 800645a..9bd3e8ee 100644
--- a/navigation/navigation-dynamic-features-runtime/src/main/java/androidx/navigation/dynamicfeatures/NavHost.kt
+++ b/navigation/navigation-dynamic-features-runtime/src/main/java/androidx/navigation/dynamicfeatures/NavHost.kt
@@ -23,8 +23,25 @@
/**
* Construct a new [androidx.navigation.NavGraph] that supports dynamic navigation destinations
*/
+@Suppress("Deprecation")
+@Deprecated(
+ "Use routes to create your dynamic NavGraph instead",
+ ReplaceWith(
+ "createGraph(startDestination = startDestination.toString(), route = id.toString()) " +
+ "{ builder.invoke() }"
+ )
+)
public inline fun NavHost.createGraph(
@IdRes id: Int = 0,
@IdRes startDestination: Int,
builder: DynamicNavGraphBuilder.() -> Unit
): NavGraph = navController.createGraph(id, startDestination, builder)
+
+/**
+ * Construct a new [androidx.navigation.NavGraph] that supports dynamic navigation destinations
+ */
+public inline fun NavHost.createGraph(
+ startDestination: String,
+ route: String? = null,
+ builder: DynamicNavGraphBuilder.() -> Unit
+): NavGraph = navController.createGraph(startDestination, route, builder)
diff --git a/navigation/navigation-dynamic-features-runtime/src/test/java/androidx/navigation/dynamicfeatures/DynamicExtrasTest.kt b/navigation/navigation-dynamic-features-runtime/src/test/java/androidx/navigation/dynamicfeatures/DynamicExtrasTest.kt
index 74bc039..0502397 100644
--- a/navigation/navigation-dynamic-features-runtime/src/test/java/androidx/navigation/dynamicfeatures/DynamicExtrasTest.kt
+++ b/navigation/navigation-dynamic-features-runtime/src/test/java/androidx/navigation/dynamicfeatures/DynamicExtrasTest.kt
@@ -23,12 +23,12 @@
import org.junit.runners.JUnit4
@RunWith(JUnit4::class)
-class DynamicExtrasTest {
+public class DynamicExtrasTest {
- class TestNavigatorExtras : Navigator.Extras
+ public class TestNavigatorExtras : Navigator.Extras
@Test
- fun build_withMonitorAndExtras() {
+ public fun build_withMonitorAndExtras() {
val monitor = DynamicInstallMonitor()
val navExtras = TestNavigatorExtras()
val extras = DynamicExtras(monitor, navExtras)
@@ -37,7 +37,7 @@
}
@Test
- fun build_withoutMonitorOrExtras() {
+ public fun build_withoutMonitorOrExtras() {
val extras = DynamicExtras()
assertThat(extras.destinationExtras).isNull()
assertThat(extras.installMonitor).isNull()
diff --git a/navigation/navigation-dynamic-features-runtime/src/test/java/androidx/navigation/dynamicfeatures/DynamicGraphNavigatorTest.kt b/navigation/navigation-dynamic-features-runtime/src/test/java/androidx/navigation/dynamicfeatures/DynamicGraphNavigatorTest.kt
index f62db26..cc94ec6 100644
--- a/navigation/navigation-dynamic-features-runtime/src/test/java/androidx/navigation/dynamicfeatures/DynamicGraphNavigatorTest.kt
+++ b/navigation/navigation-dynamic-features-runtime/src/test/java/androidx/navigation/dynamicfeatures/DynamicGraphNavigatorTest.kt
@@ -27,7 +27,7 @@
import org.mockito.Mockito.mock
@RunWith(JUnit4::class)
-class DynamicGraphNavigatorTest {
+public class DynamicGraphNavigatorTest {
private val navigator =
DynamicGraphNavigator(
@@ -36,12 +36,12 @@
)
@Test
- fun testCreateDestination() {
+ public fun testCreateDestination() {
assertNotNull(navigator.createDestination())
}
@Test
- fun testInstallDefaultProgressDestination() {
+ public fun testInstallDefaultProgressDestination() {
val navDestination = mock(NavDestination::class.java)
navigator.installDefaultProgressDestination { navDestination }
assertEquals(navDestination, navigator.defaultProgressDestinationSupplier!!.invoke())
diff --git a/navigation/navigation-dynamic-features-runtime/src/test/java/androidx/navigation/dynamicfeatures/DynamicInstallManagerTest.kt b/navigation/navigation-dynamic-features-runtime/src/test/java/androidx/navigation/dynamicfeatures/DynamicInstallManagerTest.kt
index 72ca243..d54950a 100644
--- a/navigation/navigation-dynamic-features-runtime/src/test/java/androidx/navigation/dynamicfeatures/DynamicInstallManagerTest.kt
+++ b/navigation/navigation-dynamic-features-runtime/src/test/java/androidx/navigation/dynamicfeatures/DynamicInstallManagerTest.kt
@@ -30,7 +30,7 @@
import org.mockito.Mockito.spy
@RunWith(JUnit4::class)
-class DynamicInstallManagerTest {
+public class DynamicInstallManagerTest {
private val splitInstallManager = mock(SplitInstallManager::class.java)
private var manager = DynamicInstallManager(
@@ -39,13 +39,13 @@
)
@Test
- fun testNeedsInstall_InstallNeeded() {
+ public fun testNeedsInstall_InstallNeeded() {
mockWhen(splitInstallManager.installedModules).thenReturn(setOf("not-module"))
assertTrue(manager.needsInstall("module"))
}
@Test
- fun testNeedsInstall_NoInstallNeeded() {
+ public fun testNeedsInstall_NoInstallNeeded() {
mockWhen(splitInstallManager.installedModules).thenReturn(setOf("module"))
assertFalse(manager.needsInstall("module"))
}
diff --git a/navigation/navigation-dynamic-features-runtime/src/test/java/androidx/navigation/dynamicfeatures/DynamicInstallMonitorTest.kt b/navigation/navigation-dynamic-features-runtime/src/test/java/androidx/navigation/dynamicfeatures/DynamicInstallMonitorTest.kt
index caed9ac..b6046f5 100644
--- a/navigation/navigation-dynamic-features-runtime/src/test/java/androidx/navigation/dynamicfeatures/DynamicInstallMonitorTest.kt
+++ b/navigation/navigation-dynamic-features-runtime/src/test/java/androidx/navigation/dynamicfeatures/DynamicInstallMonitorTest.kt
@@ -26,9 +26,9 @@
import org.mockito.Mockito.verify
@RunWith(JUnit4::class)
-class DynamicInstallMonitorTest {
+public class DynamicInstallMonitorTest {
@Test
- fun testCancelInstall_sessionIdZero() {
+ public fun testCancelInstall_sessionIdZero() {
val monitor = DynamicInstallMonitor()
val manager = mock(SplitInstallManager::class.java)
@@ -39,7 +39,7 @@
}
@Test
- fun testCancelInstall_sessionIdNotZero() {
+ public fun testCancelInstall_sessionIdNotZero() {
val monitor = DynamicInstallMonitor()
val manager = mock(SplitInstallManager::class.java)
diff --git a/navigation/navigation-dynamic-features-runtime/src/test/java/androidx/navigation/dynamicfeatures/DynamicNavGraphTest.kt b/navigation/navigation-dynamic-features-runtime/src/test/java/androidx/navigation/dynamicfeatures/DynamicNavGraphTest.kt
index f48fdbb..4d48ad3 100644
--- a/navigation/navigation-dynamic-features-runtime/src/test/java/androidx/navigation/dynamicfeatures/DynamicNavGraphTest.kt
+++ b/navigation/navigation-dynamic-features-runtime/src/test/java/androidx/navigation/dynamicfeatures/DynamicNavGraphTest.kt
@@ -32,10 +32,10 @@
import org.junit.runners.JUnit4
@RunWith(JUnit4::class)
-class DynamicNavGraphTest {
+public class DynamicNavGraphTest {
@get:Rule
- val instantTaskExecutorRule = InstantTaskExecutorRule()
+ public val instantTaskExecutorRule: InstantTaskExecutorRule = InstantTaskExecutorRule()
private val progressId = 1
private lateinit var provider: NavigatorProvider
@@ -46,7 +46,7 @@
private lateinit var noOpNavigator: NoOpNavigator
@Before
- fun setup() {
+ public fun setup() {
provider = NavigatorProvider()
noOpNavigator = NoOpNavigator()
navigator = DynamicGraphNavigator(
@@ -60,12 +60,12 @@
}
@Test(expected = IllegalStateException::class)
- fun testGetOrThrow_NoParent() {
+ public fun testGetOrThrow_NoParent() {
DynamicNavGraph.getOrThrow(noOpNavigator.createDestination())
}
@Test
- fun testGetOrThrow_CorrectParent() {
+ public fun testGetOrThrow_CorrectParent() {
setupProgressDestination(
noOpNavigator.createDestination().apply {
id = progressId
@@ -81,13 +81,13 @@
}
@Test(expected = IllegalStateException::class)
- fun testNavigateToProgressDestination_withoutProgressDestination() {
+ public fun testNavigateToProgressDestination_withoutProgressDestination() {
setupProgressDestination(null)
navigator.navigateToProgressDestination(dynamicNavGraph, null)
}
@Test
- fun testNavigateToProgressDestination_withProviderAndDestination() {
+ public fun testNavigateToProgressDestination_withProviderAndDestination() {
setupProgressDestination(
noOpNavigator.createDestination().apply {
id = progressId
diff --git a/navigation/navigation-dynamic-features-runtime/src/test/java/androidx/navigation/dynamicfeatures/shared/TestDynamicInstallManager.kt b/navigation/navigation-dynamic-features-runtime/src/test/java/androidx/navigation/dynamicfeatures/shared/TestDynamicInstallManager.kt
index e511f56..cbdf11a 100644
--- a/navigation/navigation-dynamic-features-runtime/src/test/java/androidx/navigation/dynamicfeatures/shared/TestDynamicInstallManager.kt
+++ b/navigation/navigation-dynamic-features-runtime/src/test/java/androidx/navigation/dynamicfeatures/shared/TestDynamicInstallManager.kt
@@ -24,7 +24,7 @@
/**
* A dynamic install manager used for testing.
*/
-class TestDynamicInstallManager :
+public class TestDynamicInstallManager :
DynamicInstallManager(
Mockito.spy(Context::class.java),
Mockito.mock(SplitInstallManager::class.java)
diff --git a/navigation/navigation-fragment/api/current.txt b/navigation/navigation-fragment/api/current.txt
index ce7ec82..dd116f0 100644
--- a/navigation/navigation-fragment/api/current.txt
+++ b/navigation/navigation-fragment/api/current.txt
@@ -23,13 +23,16 @@
}
@androidx.navigation.NavDestinationDsl public final class DialogFragmentNavigatorDestinationBuilder extends androidx.navigation.NavDestinationBuilder<androidx.navigation.fragment.DialogFragmentNavigator.Destination> {
- ctor public DialogFragmentNavigatorDestinationBuilder(androidx.navigation.fragment.DialogFragmentNavigator navigator, @IdRes int id, kotlin.reflect.KClass<? extends androidx.fragment.app.DialogFragment> fragmentClass);
+ ctor @Deprecated public DialogFragmentNavigatorDestinationBuilder(androidx.navigation.fragment.DialogFragmentNavigator navigator, @IdRes int id, kotlin.reflect.KClass<? extends androidx.fragment.app.DialogFragment> fragmentClass);
+ ctor public DialogFragmentNavigatorDestinationBuilder(androidx.navigation.fragment.DialogFragmentNavigator navigator, String route, kotlin.reflect.KClass<? extends androidx.fragment.app.DialogFragment> fragmentClass);
method public androidx.navigation.fragment.DialogFragmentNavigator.Destination build();
}
public final class DialogFragmentNavigatorDestinationBuilderKt {
method public static inline <reified F extends androidx.fragment.app.DialogFragment> void dialog(androidx.navigation.NavGraphBuilder, @IdRes int id);
method public static inline <reified F extends androidx.fragment.app.DialogFragment> void dialog(androidx.navigation.NavGraphBuilder, @IdRes int id, kotlin.jvm.functions.Function1<? super androidx.navigation.fragment.DialogFragmentNavigatorDestinationBuilder,? extends kotlin.Unit> builder);
+ method public static inline <reified F extends androidx.fragment.app.DialogFragment> void dialog(androidx.navigation.NavGraphBuilder, String route);
+ method public static inline <reified F extends androidx.fragment.app.DialogFragment> void dialog(androidx.navigation.NavGraphBuilder, String route, kotlin.jvm.functions.Function1<? super androidx.navigation.fragment.DialogFragmentNavigatorDestinationBuilder,? extends kotlin.Unit> builder);
}
public final class FragmentKt {
@@ -67,7 +70,7 @@
}
@androidx.navigation.NavDestinationDsl public final class FragmentNavigatorDestinationBuilder extends androidx.navigation.NavDestinationBuilder<androidx.navigation.fragment.FragmentNavigator.Destination> {
- ctor public FragmentNavigatorDestinationBuilder(androidx.navigation.fragment.FragmentNavigator navigator, @IdRes int id, kotlin.reflect.KClass<? extends androidx.fragment.app.Fragment> fragmentClass);
+ ctor @Deprecated public FragmentNavigatorDestinationBuilder(androidx.navigation.fragment.FragmentNavigator navigator, @IdRes int id, kotlin.reflect.KClass<? extends androidx.fragment.app.Fragment> fragmentClass);
ctor public FragmentNavigatorDestinationBuilder(androidx.navigation.fragment.FragmentNavigator navigator, String route, kotlin.reflect.KClass<? extends androidx.fragment.app.Fragment> fragmentClass);
method public androidx.navigation.fragment.FragmentNavigator.Destination build();
}
diff --git a/navigation/navigation-fragment/api/public_plus_experimental_current.txt b/navigation/navigation-fragment/api/public_plus_experimental_current.txt
index ce7ec82..dd116f0 100644
--- a/navigation/navigation-fragment/api/public_plus_experimental_current.txt
+++ b/navigation/navigation-fragment/api/public_plus_experimental_current.txt
@@ -23,13 +23,16 @@
}
@androidx.navigation.NavDestinationDsl public final class DialogFragmentNavigatorDestinationBuilder extends androidx.navigation.NavDestinationBuilder<androidx.navigation.fragment.DialogFragmentNavigator.Destination> {
- ctor public DialogFragmentNavigatorDestinationBuilder(androidx.navigation.fragment.DialogFragmentNavigator navigator, @IdRes int id, kotlin.reflect.KClass<? extends androidx.fragment.app.DialogFragment> fragmentClass);
+ ctor @Deprecated public DialogFragmentNavigatorDestinationBuilder(androidx.navigation.fragment.DialogFragmentNavigator navigator, @IdRes int id, kotlin.reflect.KClass<? extends androidx.fragment.app.DialogFragment> fragmentClass);
+ ctor public DialogFragmentNavigatorDestinationBuilder(androidx.navigation.fragment.DialogFragmentNavigator navigator, String route, kotlin.reflect.KClass<? extends androidx.fragment.app.DialogFragment> fragmentClass);
method public androidx.navigation.fragment.DialogFragmentNavigator.Destination build();
}
public final class DialogFragmentNavigatorDestinationBuilderKt {
method public static inline <reified F extends androidx.fragment.app.DialogFragment> void dialog(androidx.navigation.NavGraphBuilder, @IdRes int id);
method public static inline <reified F extends androidx.fragment.app.DialogFragment> void dialog(androidx.navigation.NavGraphBuilder, @IdRes int id, kotlin.jvm.functions.Function1<? super androidx.navigation.fragment.DialogFragmentNavigatorDestinationBuilder,? extends kotlin.Unit> builder);
+ method public static inline <reified F extends androidx.fragment.app.DialogFragment> void dialog(androidx.navigation.NavGraphBuilder, String route);
+ method public static inline <reified F extends androidx.fragment.app.DialogFragment> void dialog(androidx.navigation.NavGraphBuilder, String route, kotlin.jvm.functions.Function1<? super androidx.navigation.fragment.DialogFragmentNavigatorDestinationBuilder,? extends kotlin.Unit> builder);
}
public final class FragmentKt {
@@ -67,7 +70,7 @@
}
@androidx.navigation.NavDestinationDsl public final class FragmentNavigatorDestinationBuilder extends androidx.navigation.NavDestinationBuilder<androidx.navigation.fragment.FragmentNavigator.Destination> {
- ctor public FragmentNavigatorDestinationBuilder(androidx.navigation.fragment.FragmentNavigator navigator, @IdRes int id, kotlin.reflect.KClass<? extends androidx.fragment.app.Fragment> fragmentClass);
+ ctor @Deprecated public FragmentNavigatorDestinationBuilder(androidx.navigation.fragment.FragmentNavigator navigator, @IdRes int id, kotlin.reflect.KClass<? extends androidx.fragment.app.Fragment> fragmentClass);
ctor public FragmentNavigatorDestinationBuilder(androidx.navigation.fragment.FragmentNavigator navigator, String route, kotlin.reflect.KClass<? extends androidx.fragment.app.Fragment> fragmentClass);
method public androidx.navigation.fragment.FragmentNavigator.Destination build();
}
diff --git a/navigation/navigation-fragment/api/restricted_current.txt b/navigation/navigation-fragment/api/restricted_current.txt
index ce7ec82..dd116f0 100644
--- a/navigation/navigation-fragment/api/restricted_current.txt
+++ b/navigation/navigation-fragment/api/restricted_current.txt
@@ -23,13 +23,16 @@
}
@androidx.navigation.NavDestinationDsl public final class DialogFragmentNavigatorDestinationBuilder extends androidx.navigation.NavDestinationBuilder<androidx.navigation.fragment.DialogFragmentNavigator.Destination> {
- ctor public DialogFragmentNavigatorDestinationBuilder(androidx.navigation.fragment.DialogFragmentNavigator navigator, @IdRes int id, kotlin.reflect.KClass<? extends androidx.fragment.app.DialogFragment> fragmentClass);
+ ctor @Deprecated public DialogFragmentNavigatorDestinationBuilder(androidx.navigation.fragment.DialogFragmentNavigator navigator, @IdRes int id, kotlin.reflect.KClass<? extends androidx.fragment.app.DialogFragment> fragmentClass);
+ ctor public DialogFragmentNavigatorDestinationBuilder(androidx.navigation.fragment.DialogFragmentNavigator navigator, String route, kotlin.reflect.KClass<? extends androidx.fragment.app.DialogFragment> fragmentClass);
method public androidx.navigation.fragment.DialogFragmentNavigator.Destination build();
}
public final class DialogFragmentNavigatorDestinationBuilderKt {
method public static inline <reified F extends androidx.fragment.app.DialogFragment> void dialog(androidx.navigation.NavGraphBuilder, @IdRes int id);
method public static inline <reified F extends androidx.fragment.app.DialogFragment> void dialog(androidx.navigation.NavGraphBuilder, @IdRes int id, kotlin.jvm.functions.Function1<? super androidx.navigation.fragment.DialogFragmentNavigatorDestinationBuilder,? extends kotlin.Unit> builder);
+ method public static inline <reified F extends androidx.fragment.app.DialogFragment> void dialog(androidx.navigation.NavGraphBuilder, String route);
+ method public static inline <reified F extends androidx.fragment.app.DialogFragment> void dialog(androidx.navigation.NavGraphBuilder, String route, kotlin.jvm.functions.Function1<? super androidx.navigation.fragment.DialogFragmentNavigatorDestinationBuilder,? extends kotlin.Unit> builder);
}
public final class FragmentKt {
@@ -67,7 +70,7 @@
}
@androidx.navigation.NavDestinationDsl public final class FragmentNavigatorDestinationBuilder extends androidx.navigation.NavDestinationBuilder<androidx.navigation.fragment.FragmentNavigator.Destination> {
- ctor public FragmentNavigatorDestinationBuilder(androidx.navigation.fragment.FragmentNavigator navigator, @IdRes int id, kotlin.reflect.KClass<? extends androidx.fragment.app.Fragment> fragmentClass);
+ ctor @Deprecated public FragmentNavigatorDestinationBuilder(androidx.navigation.fragment.FragmentNavigator navigator, @IdRes int id, kotlin.reflect.KClass<? extends androidx.fragment.app.Fragment> fragmentClass);
ctor public FragmentNavigatorDestinationBuilder(androidx.navigation.fragment.FragmentNavigator navigator, String route, kotlin.reflect.KClass<? extends androidx.fragment.app.Fragment> fragmentClass);
method public androidx.navigation.fragment.FragmentNavigator.Destination build();
}
diff --git a/navigation/navigation-fragment/src/androidTest/java/androidx/navigation/fragment/DialogFragmentNavigatorDestinationBuilderTest.kt b/navigation/navigation-fragment/src/androidTest/java/androidx/navigation/fragment/DialogFragmentNavigatorDestinationBuilderTest.kt
index fed4875..7532fdb 100644
--- a/navigation/navigation-fragment/src/androidTest/java/androidx/navigation/fragment/DialogFragmentNavigatorDestinationBuilderTest.kt
+++ b/navigation/navigation-fragment/src/androidTest/java/androidx/navigation/fragment/DialogFragmentNavigatorDestinationBuilderTest.kt
@@ -36,6 +36,7 @@
val activityRule = androidx.test.rule.ActivityTestRule<TestActivity>(TestActivity::class.java)
private val fragmentManager get() = activityRule.activity.supportFragmentManager
+ @Suppress("DEPRECATION")
@UiThreadTest
@Test fun fragment() {
val navHostFragment = NavHostFragment()
@@ -53,6 +54,7 @@
.isEqualTo(BuilderTestDialogFragment::class.java.name)
}
+ @Suppress("DEPRECATION")
@UiThreadTest
@Test fun fragmentWithBody() {
val navHostFragment = NavHostFragment()
@@ -74,8 +76,48 @@
.that(graph[DESTINATION_ID].label)
.isEqualTo(LABEL)
}
+
+ @UiThreadTest
+ @Test fun fragmentRoute() {
+ val navHostFragment = NavHostFragment()
+ fragmentManager.beginTransaction()
+ .add(android.R.id.content, navHostFragment)
+ .commitNow()
+ val graph = navHostFragment.createGraph(startDestination = DESTINATION_ROUTE) {
+ dialog<BuilderTestDialogFragment>(DESTINATION_ROUTE)
+ }
+ assertWithMessage("Destination should be added to the graph")
+ .that(DESTINATION_ROUTE in graph)
+ .isTrue()
+ assertWithMessage("DialogFragment class should be set to BuilderTestDialogFragment")
+ .that((graph[DESTINATION_ROUTE] as DialogFragmentNavigator.Destination).className)
+ .isEqualTo(BuilderTestDialogFragment::class.java.name)
+ }
+
+ @UiThreadTest
+ @Test fun fragmentWithBodyRoute() {
+ val navHostFragment = NavHostFragment()
+ fragmentManager.beginTransaction()
+ .add(android.R.id.content, navHostFragment)
+ .commitNow()
+ val graph = navHostFragment.createGraph(startDestination = DESTINATION_ROUTE) {
+ dialog<BuilderTestDialogFragment>(DESTINATION_ROUTE) {
+ label = LABEL
+ }
+ }
+ assertWithMessage("Destination should be added to the graph")
+ .that(DESTINATION_ROUTE in graph)
+ .isTrue()
+ assertWithMessage("DialogFragment class should be set to BuilderTestDialogFragment")
+ .that((graph[DESTINATION_ROUTE] as DialogFragmentNavigator.Destination).className)
+ .isEqualTo(BuilderTestDialogFragment::class.java.name)
+ assertWithMessage("DialogFragment should have label set")
+ .that(graph[DESTINATION_ROUTE].label)
+ .isEqualTo(LABEL)
+ }
}
private const val DESTINATION_ID = 1
+private const val DESTINATION_ROUTE = "destination"
private const val LABEL = "Test"
class BuilderTestDialogFragment : DialogFragment()
diff --git a/navigation/navigation-fragment/src/androidTest/java/androidx/navigation/fragment/FragmentNavigatorDestinationBuilderTest.kt b/navigation/navigation-fragment/src/androidTest/java/androidx/navigation/fragment/FragmentNavigatorDestinationBuilderTest.kt
index 6e28a13..616174b 100644
--- a/navigation/navigation-fragment/src/androidTest/java/androidx/navigation/fragment/FragmentNavigatorDestinationBuilderTest.kt
+++ b/navigation/navigation-fragment/src/androidTest/java/androidx/navigation/fragment/FragmentNavigatorDestinationBuilderTest.kt
@@ -37,6 +37,7 @@
val activityRule = androidx.test.rule.ActivityTestRule<TestActivity>(TestActivity::class.java)
private val fragmentManager get() = activityRule.activity.supportFragmentManager
+ @Suppress("DEPRECATION")
@UiThreadTest
@Test fun fragment() {
val navHostFragment = NavHostFragment()
@@ -57,6 +58,7 @@
)
}
+ @Suppress("DEPRECATION")
@UiThreadTest
@Test fun fragmentWithBody() {
val navHostFragment = NavHostFragment()
diff --git a/navigation/navigation-fragment/src/androidTest/java/androidx/navigation/fragment/NavGraphViewModelLazyTest.kt b/navigation/navigation-fragment/src/androidTest/java/androidx/navigation/fragment/NavGraphViewModelLazyTest.kt
index f3c50e7..73b3b9bf 100644
--- a/navigation/navigation-fragment/src/androidTest/java/androidx/navigation/fragment/NavGraphViewModelLazyTest.kt
+++ b/navigation/navigation-fragment/src/androidTest/java/androidx/navigation/fragment/NavGraphViewModelLazyTest.kt
@@ -56,6 +56,7 @@
navigatorProvider += TestNavigator()
}
+ @Suppress("DEPRECATION")
@Test
fun vmInitialization() {
val scenario = launchFragmentInContainer<TestVMFragment>()
diff --git a/navigation/navigation-fragment/src/main/java/androidx/navigation/fragment/DialogFragmentNavigatorDestinationBuilder.kt b/navigation/navigation-fragment/src/main/java/androidx/navigation/fragment/DialogFragmentNavigatorDestinationBuilder.kt
index 465cf75..cf58061 100644
--- a/navigation/navigation-fragment/src/main/java/androidx/navigation/fragment/DialogFragmentNavigatorDestinationBuilder.kt
+++ b/navigation/navigation-fragment/src/main/java/androidx/navigation/fragment/DialogFragmentNavigatorDestinationBuilder.kt
@@ -27,6 +27,11 @@
/**
* Construct a new [DialogFragmentNavigator.Destination]
*/
+@Suppress("Deprecation")
+@Deprecated(
+ "Use routes to create your DialogFragmentDestination instead",
+ ReplaceWith("dialog<F>(route = id.toString())")
+)
public inline fun <reified F : DialogFragment> NavGraphBuilder.dialog(
@IdRes id: Int
): Unit = dialog<F>(id) {}
@@ -34,6 +39,11 @@
/**
* Construct a new [DialogFragmentNavigator.Destination]
*/
+@Suppress("Deprecation")
+@Deprecated(
+ "Use routes to create your DialogFragmentDestination instead",
+ ReplaceWith("dialog<F>(route = id.toString()) { builder.invoke() }")
+)
public inline fun <reified F : DialogFragment> NavGraphBuilder.dialog(
@IdRes id: Int,
builder: DialogFragmentNavigatorDestinationBuilder.() -> Unit
@@ -44,16 +54,59 @@
F::class
).apply(builder)
)
+/**
+ * Construct a new [DialogFragmentNavigator.Destination]
+ */
+public inline fun <reified F : DialogFragment> NavGraphBuilder.dialog(
+ route: String
+): Unit = dialog<F>(route) {}
+
+/**
+ * Construct a new [DialogFragmentNavigator.Destination]
+ */
+public inline fun <reified F : DialogFragment> NavGraphBuilder.dialog(
+ route: String,
+ builder: DialogFragmentNavigatorDestinationBuilder.() -> Unit
+): Unit = destination(
+ DialogFragmentNavigatorDestinationBuilder(
+ provider[DialogFragmentNavigator::class],
+ route,
+ F::class
+ ).apply(builder)
+)
/**
* DSL for constructing a new [DialogFragmentNavigator.Destination]
*/
@NavDestinationDsl
-public class DialogFragmentNavigatorDestinationBuilder(
- navigator: DialogFragmentNavigator,
- @IdRes id: Int,
- private val fragmentClass: KClass<out DialogFragment>
-) : NavDestinationBuilder<DialogFragmentNavigator.Destination>(navigator, id) {
+public class DialogFragmentNavigatorDestinationBuilder :
+ NavDestinationBuilder<DialogFragmentNavigator.Destination> {
+
+ private var fragmentClass: KClass<out DialogFragment>
+
+ @Suppress("Deprecation")
+ @Deprecated(
+ "Use routes to build your DialogFragmentNavigatorDestination instead",
+ ReplaceWith(
+ "DialogFragmentNavigatorDestinationBuilder(navigator, route = id.toString(), " +
+ "fragmentClass) "
+ )
+ )
+ public constructor(
+ navigator: DialogFragmentNavigator,
+ @IdRes id: Int,
+ fragmentClass: KClass<out DialogFragment>
+ ) : super(navigator, id) {
+ this.fragmentClass = fragmentClass
+ }
+
+ public constructor(
+ navigator: DialogFragmentNavigator,
+ route: String,
+ fragmentClass: KClass<out DialogFragment>
+ ) : super(navigator, route) {
+ this.fragmentClass = fragmentClass
+ }
override fun build(): DialogFragmentNavigator.Destination =
super.build().also { destination ->
diff --git a/navigation/navigation-fragment/src/main/java/androidx/navigation/fragment/FragmentNavigatorDestinationBuilder.kt b/navigation/navigation-fragment/src/main/java/androidx/navigation/fragment/FragmentNavigatorDestinationBuilder.kt
index 60eda99..e0060d9 100644
--- a/navigation/navigation-fragment/src/main/java/androidx/navigation/fragment/FragmentNavigatorDestinationBuilder.kt
+++ b/navigation/navigation-fragment/src/main/java/androidx/navigation/fragment/FragmentNavigatorDestinationBuilder.kt
@@ -27,6 +27,11 @@
/**
* Construct a new [FragmentNavigator.Destination]
*/
+@Suppress("Deprecation")
+@Deprecated(
+ "Use routes to create your FragmentDestination instead",
+ ReplaceWith("fragment<F>(route = id.toString())")
+)
public inline fun <reified F : Fragment> NavGraphBuilder.fragment(
@IdRes id: Int
): Unit = fragment<F>(id) {}
@@ -34,6 +39,11 @@
/**
* Construct a new [FragmentNavigator.Destination]
*/
+@Suppress("Deprecation")
+@Deprecated(
+ "Use routes to create your FragmentDestination instead",
+ ReplaceWith("fragment<F>(route = id.toString()) { builder.invoke() }")
+)
public inline fun <reified F : Fragment> NavGraphBuilder.fragment(
@IdRes id: Int,
builder: FragmentNavigatorDestinationBuilder.() -> Unit
@@ -75,6 +85,13 @@
private var fragmentClass: KClass<out Fragment>
+ @Suppress("Deprecation")
+ @Deprecated(
+ "Use routes to build your FragmentNavigatorDestination instead",
+ ReplaceWith(
+ "FragmentNavigatorDestinationBuilder(navigator, route = id.toString(), fragmentClass) "
+ )
+ )
public constructor(
navigator: FragmentNavigator,
@IdRes id: Int,
diff --git a/navigation/navigation-runtime/api/current.txt b/navigation/navigation-runtime/api/current.txt
index 03eef05..33808c0 100644
--- a/navigation/navigation-runtime/api/current.txt
+++ b/navigation/navigation-runtime/api/current.txt
@@ -59,7 +59,7 @@
}
@androidx.navigation.NavDestinationDsl public final class ActivityNavigatorDestinationBuilder extends androidx.navigation.NavDestinationBuilder<androidx.navigation.ActivityNavigator.Destination> {
- ctor public ActivityNavigatorDestinationBuilder(androidx.navigation.ActivityNavigator navigator, @IdRes int id);
+ ctor @Deprecated public ActivityNavigatorDestinationBuilder(androidx.navigation.ActivityNavigator navigator, @IdRes int id);
ctor public ActivityNavigatorDestinationBuilder(androidx.navigation.ActivityNavigator navigator, String route);
method public androidx.navigation.ActivityNavigator.Destination build();
method public String? getAction();
@@ -80,7 +80,7 @@
}
public final class ActivityNavigatorDestinationBuilderKt {
- method public static inline void activity(androidx.navigation.NavGraphBuilder, @IdRes int id, kotlin.jvm.functions.Function1<? super androidx.navigation.ActivityNavigatorDestinationBuilder,kotlin.Unit> builder);
+ method @Deprecated public static inline void activity(androidx.navigation.NavGraphBuilder, @IdRes int id, kotlin.jvm.functions.Function1<? super androidx.navigation.ActivityNavigatorDestinationBuilder,kotlin.Unit> builder);
method public static inline void activity(androidx.navigation.NavGraphBuilder, String route, kotlin.jvm.functions.Function1<? super androidx.navigation.ActivityNavigatorDestinationBuilder,kotlin.Unit> builder);
}
@@ -152,7 +152,7 @@
}
public final class NavControllerKt {
- method public static inline androidx.navigation.NavGraph createGraph(androidx.navigation.NavController, optional @IdRes int id, @IdRes int startDestination, kotlin.jvm.functions.Function1<? super androidx.navigation.NavGraphBuilder,kotlin.Unit> builder);
+ method @Deprecated public static inline androidx.navigation.NavGraph createGraph(androidx.navigation.NavController, optional @IdRes int id, @IdRes int startDestination, kotlin.jvm.functions.Function1<? super androidx.navigation.NavGraphBuilder,kotlin.Unit> builder);
method public static inline androidx.navigation.NavGraph createGraph(androidx.navigation.NavController, String startDestination, optional String? route, kotlin.jvm.functions.Function1<? super androidx.navigation.NavGraphBuilder,kotlin.Unit> builder);
}
@@ -189,7 +189,7 @@
}
public final class NavHostKt {
- method public static inline androidx.navigation.NavGraph createGraph(androidx.navigation.NavHost, optional @IdRes int id, @IdRes int startDestination, kotlin.jvm.functions.Function1<? super androidx.navigation.NavGraphBuilder,kotlin.Unit> builder);
+ method @Deprecated public static inline androidx.navigation.NavGraph createGraph(androidx.navigation.NavHost, optional @IdRes int id, @IdRes int startDestination, kotlin.jvm.functions.Function1<? super androidx.navigation.NavGraphBuilder,kotlin.Unit> builder);
method public static inline androidx.navigation.NavGraph createGraph(androidx.navigation.NavHost, String startDestination, optional String? route, kotlin.jvm.functions.Function1<? super androidx.navigation.NavGraphBuilder,kotlin.Unit> builder);
}
diff --git a/navigation/navigation-runtime/api/public_plus_experimental_current.txt b/navigation/navigation-runtime/api/public_plus_experimental_current.txt
index f98c73a..1a5eb2b 100644
--- a/navigation/navigation-runtime/api/public_plus_experimental_current.txt
+++ b/navigation/navigation-runtime/api/public_plus_experimental_current.txt
@@ -61,7 +61,7 @@
}
@androidx.navigation.NavDestinationDsl public final class ActivityNavigatorDestinationBuilder extends androidx.navigation.NavDestinationBuilder<androidx.navigation.ActivityNavigator.Destination> {
- ctor public ActivityNavigatorDestinationBuilder(androidx.navigation.ActivityNavigator navigator, @IdRes int id);
+ ctor @Deprecated public ActivityNavigatorDestinationBuilder(androidx.navigation.ActivityNavigator navigator, @IdRes int id);
ctor public ActivityNavigatorDestinationBuilder(androidx.navigation.ActivityNavigator navigator, String route);
method public androidx.navigation.ActivityNavigator.Destination build();
method public String? getAction();
@@ -82,7 +82,7 @@
}
public final class ActivityNavigatorDestinationBuilderKt {
- method public static inline void activity(androidx.navigation.NavGraphBuilder, @IdRes int id, kotlin.jvm.functions.Function1<? super androidx.navigation.ActivityNavigatorDestinationBuilder,kotlin.Unit> builder);
+ method @Deprecated public static inline void activity(androidx.navigation.NavGraphBuilder, @IdRes int id, kotlin.jvm.functions.Function1<? super androidx.navigation.ActivityNavigatorDestinationBuilder,kotlin.Unit> builder);
method public static inline void activity(androidx.navigation.NavGraphBuilder, String route, kotlin.jvm.functions.Function1<? super androidx.navigation.ActivityNavigatorDestinationBuilder,kotlin.Unit> builder);
}
@@ -166,7 +166,7 @@
}
public final class NavControllerKt {
- method public static inline androidx.navigation.NavGraph createGraph(androidx.navigation.NavController, optional @IdRes int id, @IdRes int startDestination, kotlin.jvm.functions.Function1<? super androidx.navigation.NavGraphBuilder,kotlin.Unit> builder);
+ method @Deprecated public static inline androidx.navigation.NavGraph createGraph(androidx.navigation.NavController, optional @IdRes int id, @IdRes int startDestination, kotlin.jvm.functions.Function1<? super androidx.navigation.NavGraphBuilder,kotlin.Unit> builder);
method public static inline androidx.navigation.NavGraph createGraph(androidx.navigation.NavController, String startDestination, optional String? route, kotlin.jvm.functions.Function1<? super androidx.navigation.NavGraphBuilder,kotlin.Unit> builder);
}
@@ -203,7 +203,7 @@
}
public final class NavHostKt {
- method public static inline androidx.navigation.NavGraph createGraph(androidx.navigation.NavHost, optional @IdRes int id, @IdRes int startDestination, kotlin.jvm.functions.Function1<? super androidx.navigation.NavGraphBuilder,kotlin.Unit> builder);
+ method @Deprecated public static inline androidx.navigation.NavGraph createGraph(androidx.navigation.NavHost, optional @IdRes int id, @IdRes int startDestination, kotlin.jvm.functions.Function1<? super androidx.navigation.NavGraphBuilder,kotlin.Unit> builder);
method public static inline androidx.navigation.NavGraph createGraph(androidx.navigation.NavHost, String startDestination, optional String? route, kotlin.jvm.functions.Function1<? super androidx.navigation.NavGraphBuilder,kotlin.Unit> builder);
}
diff --git a/navigation/navigation-runtime/api/restricted_current.txt b/navigation/navigation-runtime/api/restricted_current.txt
index 03eef05..33808c0 100644
--- a/navigation/navigation-runtime/api/restricted_current.txt
+++ b/navigation/navigation-runtime/api/restricted_current.txt
@@ -59,7 +59,7 @@
}
@androidx.navigation.NavDestinationDsl public final class ActivityNavigatorDestinationBuilder extends androidx.navigation.NavDestinationBuilder<androidx.navigation.ActivityNavigator.Destination> {
- ctor public ActivityNavigatorDestinationBuilder(androidx.navigation.ActivityNavigator navigator, @IdRes int id);
+ ctor @Deprecated public ActivityNavigatorDestinationBuilder(androidx.navigation.ActivityNavigator navigator, @IdRes int id);
ctor public ActivityNavigatorDestinationBuilder(androidx.navigation.ActivityNavigator navigator, String route);
method public androidx.navigation.ActivityNavigator.Destination build();
method public String? getAction();
@@ -80,7 +80,7 @@
}
public final class ActivityNavigatorDestinationBuilderKt {
- method public static inline void activity(androidx.navigation.NavGraphBuilder, @IdRes int id, kotlin.jvm.functions.Function1<? super androidx.navigation.ActivityNavigatorDestinationBuilder,kotlin.Unit> builder);
+ method @Deprecated public static inline void activity(androidx.navigation.NavGraphBuilder, @IdRes int id, kotlin.jvm.functions.Function1<? super androidx.navigation.ActivityNavigatorDestinationBuilder,kotlin.Unit> builder);
method public static inline void activity(androidx.navigation.NavGraphBuilder, String route, kotlin.jvm.functions.Function1<? super androidx.navigation.ActivityNavigatorDestinationBuilder,kotlin.Unit> builder);
}
@@ -152,7 +152,7 @@
}
public final class NavControllerKt {
- method public static inline androidx.navigation.NavGraph createGraph(androidx.navigation.NavController, optional @IdRes int id, @IdRes int startDestination, kotlin.jvm.functions.Function1<? super androidx.navigation.NavGraphBuilder,kotlin.Unit> builder);
+ method @Deprecated public static inline androidx.navigation.NavGraph createGraph(androidx.navigation.NavController, optional @IdRes int id, @IdRes int startDestination, kotlin.jvm.functions.Function1<? super androidx.navigation.NavGraphBuilder,kotlin.Unit> builder);
method public static inline androidx.navigation.NavGraph createGraph(androidx.navigation.NavController, String startDestination, optional String? route, kotlin.jvm.functions.Function1<? super androidx.navigation.NavGraphBuilder,kotlin.Unit> builder);
}
@@ -189,7 +189,7 @@
}
public final class NavHostKt {
- method public static inline androidx.navigation.NavGraph createGraph(androidx.navigation.NavHost, optional @IdRes int id, @IdRes int startDestination, kotlin.jvm.functions.Function1<? super androidx.navigation.NavGraphBuilder,kotlin.Unit> builder);
+ method @Deprecated public static inline androidx.navigation.NavGraph createGraph(androidx.navigation.NavHost, optional @IdRes int id, @IdRes int startDestination, kotlin.jvm.functions.Function1<? super androidx.navigation.NavGraphBuilder,kotlin.Unit> builder);
method public static inline androidx.navigation.NavGraph createGraph(androidx.navigation.NavHost, String startDestination, optional String? route, kotlin.jvm.functions.Function1<? super androidx.navigation.NavGraphBuilder,kotlin.Unit> builder);
}
diff --git a/navigation/navigation-runtime/src/androidTest/java/androidx/navigation/ActivityNavigatorDestinationBuilderTest.kt b/navigation/navigation-runtime/src/androidTest/java/androidx/navigation/ActivityNavigatorDestinationBuilderTest.kt
index 53c3aea..6e1ae7a 100644
--- a/navigation/navigation-runtime/src/androidTest/java/androidx/navigation/ActivityNavigatorDestinationBuilderTest.kt
+++ b/navigation/navigation-runtime/src/androidTest/java/androidx/navigation/ActivityNavigatorDestinationBuilderTest.kt
@@ -32,6 +32,7 @@
private val navController =
NavController(ApplicationProvider.getApplicationContext() as android.content.Context)
+ @Suppress("DEPRECATION")
@Test
fun activity() {
val graph = navController.createGraph(startDestination = DESTINATION_ID) {
@@ -50,6 +51,7 @@
)
}
+ @Suppress("DEPRECATION")
@Test
fun activityPackage() {
val graph = navController.createGraph(startDestination = DESTINATION_ID) {
@@ -65,6 +67,7 @@
.isEqualTo(PACKAGE_NAME)
}
+ @Suppress("DEPRECATION")
@Test
fun activityClass() {
val graph = navController.createGraph(startDestination = DESTINATION_ID) {
@@ -83,6 +86,7 @@
)
}
+ @Suppress("DEPRECATION")
@Test
fun action() {
val graph = navController.createGraph(startDestination = DESTINATION_ID) {
@@ -101,6 +105,7 @@
)
}
+ @Suppress("DEPRECATION")
@Test
fun data() {
val graph = navController.createGraph(startDestination = DESTINATION_ID) {
@@ -119,6 +124,7 @@
)
}
+ @Suppress("DEPRECATION")
@Test
fun dataPattern() {
val graph = navController.createGraph(startDestination = DESTINATION_ID) {
diff --git a/navigation/navigation-runtime/src/androidTest/java/androidx/navigation/NavBackStackEntryLifecycleTest.kt b/navigation/navigation-runtime/src/androidTest/java/androidx/navigation/NavBackStackEntryLifecycleTest.kt
index 1c9b115..f276f45 100644
--- a/navigation/navigation-runtime/src/androidTest/java/androidx/navigation/NavBackStackEntryLifecycleTest.kt
+++ b/navigation/navigation-runtime/src/androidTest/java/androidx/navigation/NavBackStackEntryLifecycleTest.kt
@@ -43,6 +43,7 @@
/**
* Test that navigating between siblings correctly stops the previous sibling.
*/
+ @Suppress("DEPRECATION")
@UiThreadTest
@Test
fun testLifecycle() {
@@ -105,6 +106,7 @@
* Test that navigating from a sibling to a FloatingWindow sibling leaves the previous
* destination started.
*/
+ @Suppress("DEPRECATION")
@UiThreadTest
@Test
fun testLifecycleWithDialog() {
@@ -167,6 +169,7 @@
* Test that navigating from within a nested navigation graph to one of the graph's
* siblings correctly stops both the previous destination and its graph.
*/
+ @Suppress("DEPRECATION")
@UiThreadTest
@Test
fun testLifecycleNested() {
@@ -232,6 +235,7 @@
* FloatingWindow siblings correctly moves both the previous destination and its graph to
* started.
*/
+ @Suppress("DEPRECATION")
@UiThreadTest
@Test
fun testLifecycleNestedWithDialog() {
@@ -299,6 +303,7 @@
* Test that navigating from within a nested navigation graph to one of the graph's
* siblings correctly stops both the previous destination and its graph.
*/
+ @Suppress("DEPRECATION")
@UiThreadTest
@Test
fun testLifecycleNestedOrdering() {
@@ -394,6 +399,7 @@
* FloatingWindow siblings correctly moves both the previous destination and its graph to
* started.
*/
+ @Suppress("DEPRECATION")
@UiThreadTest
@Test
fun testLifecycleNestedOrderingWithDialog() {
@@ -476,6 +482,7 @@
* Test that popping the last destination in a graph while navigating to a new
* destination in that graph keeps the graph around
*/
+ @Suppress("DEPRECATION")
@UiThreadTest
@Test
fun testLifecycleReplaceLastDestination() {
@@ -533,6 +540,7 @@
* Test that popping the last destination in a graph while navigating correctly
* cleans up the previous navigation graph
*/
+ @Suppress("DEPRECATION")
@UiThreadTest
@Test
fun testLifecycleOrphanedGraph() {
@@ -590,6 +598,7 @@
* Test that navigating to a new instance of a graph leaves the previous instance in its
* current state.
*/
+ @Suppress("DEPRECATION")
@UiThreadTest
@Test
fun testLifecycleNestedRepeated() {
@@ -663,6 +672,7 @@
* Test that navigating to a new instance of a graph back to back with its previous
* instance creates a brand new graph instance
*/
+ @Suppress("DEPRECATION")
@UiThreadTest
@Test
fun testLifecycleNestedRepeatedBackToBack() {
@@ -722,6 +732,7 @@
* last destination from the previous instance of the graph correctly cleans up
* the orphaned graph and creates a new graph instance.
*/
+ @Suppress("DEPRECATION")
@UiThreadTest
@Test
fun testLifecycleNestedRepeatedBackToBackWithOrphanedGraph() {
@@ -789,6 +800,7 @@
* Test that navigating to a new instance of a graph via a deep link to a FloatingWindow
* destination leaves the previous instance in its current state.
*/
+ @Suppress("DEPRECATION")
@UiThreadTest
@Test
fun testLifecycleNestedRepeatedWithDialog() {
@@ -861,6 +873,7 @@
.isEqualTo(Lifecycle.State.RESUMED)
}
+ @Suppress("DEPRECATION")
@UiThreadTest
@Test
fun testLifecycleToDestroyedWhenInitialized() {
diff --git a/navigation/navigation-runtime/src/androidTest/java/androidx/navigation/NavBackStackEntryTest.kt b/navigation/navigation-runtime/src/androidTest/java/androidx/navigation/NavBackStackEntryTest.kt
index bcd0b19..b061ee6 100644
--- a/navigation/navigation-runtime/src/androidTest/java/androidx/navigation/NavBackStackEntryTest.kt
+++ b/navigation/navigation-runtime/src/androidTest/java/androidx/navigation/NavBackStackEntryTest.kt
@@ -42,6 +42,7 @@
@RunWith(AndroidJUnit4::class)
class NavBackStackEntryTest {
+ @Suppress("DEPRECATION")
@UiThreadTest
@Test
fun testGetViewModelStoreOwner() {
@@ -61,6 +62,7 @@
assertThat(store).isNotNull()
}
+ @Suppress("DEPRECATION")
@UiThreadTest
@Test
fun testGetViewModelStoreOwnerAndroidViewModel() {
@@ -81,6 +83,7 @@
assertThat(viewModel).isNotNull()
}
+ @Suppress("DEPRECATION")
@UiThreadTest
@Test
fun testGetViewModelStoreOwnerSavedStateViewModel() {
@@ -116,6 +119,7 @@
assertThat(restoredState).isEqualTo("test")
}
+ @Suppress("DEPRECATION")
@UiThreadTest
@Test
fun testSaveRestoreGetViewModelStoreOwner() {
@@ -165,6 +169,7 @@
}
}
+ @Suppress("DEPRECATION")
@UiThreadTest
@Test
fun testGetViewModelStoreOwnerSameGraph() {
@@ -188,6 +193,7 @@
assertThat(sameGraphOwner.viewModelStore).isSameInstanceAs(viewStore)
}
+ @Suppress("DEPRECATION")
@UiThreadTest
@Test
fun testGetSavedStateHandleRestored() {
@@ -278,6 +284,7 @@
}
}
+ @Suppress("DEPRECATION")
@UiThreadTest
@Test
fun testOnClearedWhenHostCleared() {
@@ -304,6 +311,7 @@
.isTrue()
}
+ @Suppress("DEPRECATION")
@UiThreadTest
@Test
fun testOnClearedWhenPopped() {
@@ -338,6 +346,7 @@
.isTrue()
}
+ @Suppress("DEPRECATION")
@UiThreadTest
@Test
fun testOnClearedWhenHostClearedAfterSaveState() {
diff --git a/navigation/navigation-runtime/src/androidTest/java/androidx/navigation/NavControllerTest.kt b/navigation/navigation-runtime/src/androidTest/java/androidx/navigation/NavControllerTest.kt
index d3f9e3a..c2e4857 100644
--- a/navigation/navigation-runtime/src/androidTest/java/androidx/navigation/NavControllerTest.kt
+++ b/navigation/navigation-runtime/src/androidTest/java/androidx/navigation/NavControllerTest.kt
@@ -173,6 +173,7 @@
navController.setGraph(R.navigation.nav_start_destination, args)
}
+ @Suppress("DEPRECATION")
@UiThreadTest
@Test
fun testStartDestinationWithArgsProgrammatic() {
@@ -238,6 +239,7 @@
}
}
+ @Suppress("DEPRECATION")
@UiThreadTest
@Test
fun testSetViewModelStoreOwnerAfterGraphSet() {
@@ -260,6 +262,7 @@
}
}
+ @Suppress("DEPRECATION")
@UiThreadTest
@Test
fun testSetSameViewModelStoreOwnerAfterGraphSet() {
@@ -1977,6 +1980,7 @@
navController.navigate(R.id.second_test)
}
+ @Suppress("DEPRECATION")
@Test
fun createGraph() {
val graph = navController.createGraph(startDestination = DESTINATION_ID) {
@@ -1988,7 +1992,7 @@
@UiThreadTest
@Test
- @Suppress("EXPERIMENTAL_API_USAGE")
+ @Suppress("DEPRECATION", "EXPERIMENTAL_API_USAGE")
fun currentBackStackEntryFlow() = runBlocking {
navController.graph = navController.createGraph(startDestination = 1) {
test(1)
diff --git a/navigation/navigation-runtime/src/androidTest/java/androidx/navigation/NavDeepLinkBuilderTest.kt b/navigation/navigation-runtime/src/androidTest/java/androidx/navigation/NavDeepLinkBuilderTest.kt
index 951a236..0b21a08 100644
--- a/navigation/navigation-runtime/src/androidTest/java/androidx/navigation/NavDeepLinkBuilderTest.kt
+++ b/navigation/navigation-runtime/src/androidTest/java/androidx/navigation/NavDeepLinkBuilderTest.kt
@@ -105,6 +105,7 @@
assertEquals("Expected one Intent", 1, taskStackBuilder.intentCount)
}
+ @Suppress("DEPRECATION")
@Test
fun fromContextSetGraphProgrammatic() {
val deepLinkBuilder = NavDeepLinkBuilder(targetContext)
diff --git a/navigation/navigation-runtime/src/androidTest/java/androidx/navigation/NavHostTest.kt b/navigation/navigation-runtime/src/androidTest/java/androidx/navigation/NavHostTest.kt
index 37ecb1e..5ef8394 100644
--- a/navigation/navigation-runtime/src/androidTest/java/androidx/navigation/NavHostTest.kt
+++ b/navigation/navigation-runtime/src/androidTest/java/androidx/navigation/NavHostTest.kt
@@ -35,6 +35,7 @@
get() = this@NavHostTest.navController
}
+ @Suppress("DEPRECATION")
@Test
fun createGraph() {
val graph = navHost.createGraph(startDestination = DESTINATION_ID) {
diff --git a/navigation/navigation-runtime/src/androidTest/java/androidx/navigation/test/FloatingTestNavigator.kt b/navigation/navigation-runtime/src/androidTest/java/androidx/navigation/test/FloatingTestNavigator.kt
index 689f7c6..94ea1b6 100644
--- a/navigation/navigation-runtime/src/androidTest/java/androidx/navigation/test/FloatingTestNavigator.kt
+++ b/navigation/navigation-runtime/src/androidTest/java/androidx/navigation/test/FloatingTestNavigator.kt
@@ -59,6 +59,7 @@
/**
* DSL for constructing a new [TestNavigator.Destination] from a [FloatingTestNavigator].
*/
+@Suppress("DEPRECATION")
@NavDestinationDsl
class FloatingTestNavigatorDestinationBuilder(
navigator: FloatingTestNavigator,
diff --git a/navigation/navigation-runtime/src/main/java/androidx/navigation/ActivityNavigatorDestinationBuilder.kt b/navigation/navigation-runtime/src/main/java/androidx/navigation/ActivityNavigatorDestinationBuilder.kt
index 1089b72..c0cc861 100644
--- a/navigation/navigation-runtime/src/main/java/androidx/navigation/ActivityNavigatorDestinationBuilder.kt
+++ b/navigation/navigation-runtime/src/main/java/androidx/navigation/ActivityNavigatorDestinationBuilder.kt
@@ -28,6 +28,11 @@
/**
* Construct a new [ActivityNavigator.Destination]
*/
+@Suppress("Deprecation")
+@Deprecated(
+ "Use routes to build your ActivityDestination instead",
+ ReplaceWith("activity(route = id.toString()) { builder.invoke() }")
+)
public inline fun NavGraphBuilder.activity(
@IdRes id: Int,
builder: ActivityNavigatorDestinationBuilder.() -> Unit
@@ -59,6 +64,11 @@
NavDestinationBuilder<ActivityNavigator.Destination> {
private var context: Context
+ @Suppress("Deprecation")
+ @Deprecated(
+ "Use routes to create your ActivityNavigatorDestinationBuilder instead",
+ ReplaceWith("ActivityNavigatorDestinationBuilder(navigator, route = id.toString())")
+ )
public constructor(navigator: ActivityNavigator, @IdRes id: Int) : super(navigator, id) {
context = navigator.context
}
diff --git a/navigation/navigation-runtime/src/main/java/androidx/navigation/NavController.kt b/navigation/navigation-runtime/src/main/java/androidx/navigation/NavController.kt
index 24b4764..fc4bde0 100644
--- a/navigation/navigation-runtime/src/main/java/androidx/navigation/NavController.kt
+++ b/navigation/navigation-runtime/src/main/java/androidx/navigation/NavController.kt
@@ -1949,6 +1949,14 @@
* @param startDestination the route for the start destination
* @param builder the builder used to construct the graph
*/
+@Suppress("Deprecation")
+@Deprecated(
+ "Use routes to create your NavGraph instead",
+ ReplaceWith(
+ "createGraph(startDestination = startDestination.toString(), route = id.toString()) " +
+ "{ builder.invoke() }"
+ )
+)
public inline fun NavController.createGraph(
@IdRes id: Int = 0,
@IdRes startDestination: Int,
diff --git a/navigation/navigation-runtime/src/main/java/androidx/navigation/NavHost.kt b/navigation/navigation-runtime/src/main/java/androidx/navigation/NavHost.kt
index bb6b996..f3e159b 100644
--- a/navigation/navigation-runtime/src/main/java/androidx/navigation/NavHost.kt
+++ b/navigation/navigation-runtime/src/main/java/androidx/navigation/NavHost.kt
@@ -53,6 +53,14 @@
/**
* Construct a new [NavGraph]
*/
+@Suppress("Deprecation")
+@Deprecated(
+ "Use routes to create your NavGraph instead",
+ ReplaceWith(
+ "createGraph(startDestination = startDestination.toString(), route = id.toString()) " +
+ "{ builder.invoke() }"
+ )
+)
public inline fun NavHost.createGraph(
@IdRes id: Int = 0,
@IdRes startDestination: Int,
diff --git a/navigation/navigation-testing/src/androidTest/java/androidx/navigation/testing/TestNavHostControllerTest.kt b/navigation/navigation-testing/src/androidTest/java/androidx/navigation/testing/TestNavHostControllerTest.kt
index 2612a35..76aa369 100644
--- a/navigation/navigation-testing/src/androidTest/java/androidx/navigation/testing/TestNavHostControllerTest.kt
+++ b/navigation/navigation-testing/src/androidTest/java/androidx/navigation/testing/TestNavHostControllerTest.kt
@@ -76,6 +76,7 @@
assertThat(backStack[1].destination).isInstanceOf(TestNavigator.Destination::class.java)
}
+ @Suppress("DEPRECATION")
@UiThreadTest
@Test
fun testDsl() {
diff --git a/navigation/navigation-ui/src/androidTest/java/androidx/navigation/ui/AppBarConfigurationTest.kt b/navigation/navigation-ui/src/androidTest/java/androidx/navigation/ui/AppBarConfigurationTest.kt
index 1f393b1..c2576ae 100644
--- a/navigation/navigation-ui/src/androidTest/java/androidx/navigation/ui/AppBarConfigurationTest.kt
+++ b/navigation/navigation-ui/src/androidTest/java/androidx/navigation/ui/AppBarConfigurationTest.kt
@@ -42,6 +42,7 @@
context = InstrumentationRegistry.getInstrumentation().targetContext
}
+ @Suppress("DEPRECATION")
@Test
fun testTopLevelFromGraph() {
val navGraph = NavController(context).apply {
diff --git a/playground-common/playground.properties b/playground-common/playground.properties
index 3e7dfa5..945474e 100644
--- a/playground-common/playground.properties
+++ b/playground-common/playground.properties
@@ -26,7 +26,7 @@
kotlin.code.style=official
# Disable docs
androidx.enableDocumentation=false
-androidx.playground.snapshotBuildId=7378367
+androidx.playground.snapshotBuildId=7396899
androidx.playground.metalavaBuildId=7255182
androidx.playground.dokkaBuildId=7299536
androidx.studio.type=playground
diff --git a/room/OWNERS b/room/OWNERS
index 3ea2934..6d57c2e 100644
--- a/room/OWNERS
+++ b/room/OWNERS
@@ -1,5 +1,6 @@
danysantiago@google.com
sergeyv@google.com
yboyar@google.com
+dustinlam@google.com
-per-file settings.gradle = dustinlam@google.com, rahulrav@google.com
+per-file settings.gradle = rahulrav@google.com
diff --git a/room/compiler/src/main/kotlin/androidx/room/preconditions/Checks.kt b/room/compiler/src/main/kotlin/androidx/room/preconditions/Checks.kt
index 070e72a..271c1df 100644
--- a/room/compiler/src/main/kotlin/androidx/room/preconditions/Checks.kt
+++ b/room/compiler/src/main/kotlin/androidx/room/preconditions/Checks.kt
@@ -16,8 +16,8 @@
package androidx.room.preconditions
-import androidx.room.log.RLog
import androidx.room.compiler.processing.XElement
+import androidx.room.log.RLog
import com.squareup.javapoet.ParameterizedTypeName
import com.squareup.javapoet.TypeName
import com.squareup.javapoet.TypeVariableName
diff --git a/room/compiler/src/main/kotlin/androidx/room/processor/ProcessorErrors.kt b/room/compiler/src/main/kotlin/androidx/room/processor/ProcessorErrors.kt
index 7bbb587..83381bc 100644
--- a/room/compiler/src/main/kotlin/androidx/room/processor/ProcessorErrors.kt
+++ b/room/compiler/src/main/kotlin/androidx/room/processor/ProcessorErrors.kt
@@ -624,7 +624,13 @@
val INVALID_TABLE_NAME = "Invalid table name. Room does not allow using ` or \" in table names"
val RAW_QUERY_BAD_PARAMS = "RawQuery methods should have 1 and only 1 parameter with type" +
- " String or SupportSQLiteQuery"
+ " SupportSQLiteQuery"
+
+ fun parameterCannotBeNullable(
+ parameterName: String
+ ) = """
+ Parameter `$parameterName` cannot be nullable.
+ """.trimIndent()
val RAW_QUERY_BAD_RETURN_TYPE = "RawQuery methods must return a non-void type."
diff --git a/room/compiler/src/main/kotlin/androidx/room/processor/RawQueryMethodProcessor.kt b/room/compiler/src/main/kotlin/androidx/room/processor/RawQueryMethodProcessor.kt
index 4d2a30d..39377be8 100644
--- a/room/compiler/src/main/kotlin/androidx/room/processor/RawQueryMethodProcessor.kt
+++ b/room/compiler/src/main/kotlin/androidx/room/processor/RawQueryMethodProcessor.kt
@@ -22,6 +22,7 @@
import androidx.room.ext.isEntityElement
import androidx.room.parser.SqlParser
import androidx.room.compiler.processing.XMethodElement
+import androidx.room.compiler.processing.XNullability
import androidx.room.compiler.processing.XType
import androidx.room.compiler.processing.XVariableElement
import androidx.room.processor.ProcessorErrors.RAW_QUERY_STRING_PARAMETER_REMOVED
@@ -117,6 +118,17 @@
if (extractParams.size == 1 && !executableElement.isVarArgs()) {
val param = extractParams.first().asMemberOf(containing)
val processingEnv = context.processingEnv
+ if (param.nullability == XNullability.NULLABLE) {
+ context.logger.e(
+ element = extractParams.first(),
+ msg = ProcessorErrors.parameterCannotBeNullable(
+ parameterName = extractParams.first().name
+ )
+ )
+ }
+ // use nullable type to catch bad nullability. Because it is non-null by default in
+ // KSP, assignability will fail and we'll print a generic error instead of a specific
+ // one
val supportQueryType = processingEnv.requireType(SupportDbTypeNames.QUERY)
val isSupportSql = supportQueryType.isAssignableFrom(param)
if (isSupportSql) {
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 7145423..88ea374 100644
--- a/room/compiler/src/test/kotlin/androidx/room/processor/RawQueryMethodProcessorTest.kt
+++ b/room/compiler/src/test/kotlin/androidx/room/processor/RawQueryMethodProcessorTest.kt
@@ -286,6 +286,40 @@
}
@Test
+ fun badType() {
+ singleQueryMethod(
+ """
+ @RawQuery
+ abstract public int[] foo(int query);
+ """
+ ) { _, invocation ->
+ invocation.assertCompilationResult {
+ hasErrorContaining(
+ ProcessorErrors.RAW_QUERY_BAD_PARAMS
+ )
+ }
+ }
+ }
+
+ @Test
+ fun badType_nullable() {
+ singleQueryMethod(
+ """
+ @RawQuery
+ abstract public int[] foo(@androidx.annotation.Nullable SupportSQLiteQuery query);
+ """
+ ) { _, invocation ->
+ invocation.assertCompilationResult {
+ hasErrorContaining(
+ ProcessorErrors.parameterCannotBeNullable(
+ parameterName = "query"
+ )
+ )
+ }
+ }
+ }
+
+ @Test
fun observed_notAnEntity() {
singleQueryMethod(
"""
diff --git a/room/guava/lint-baseline.xml b/room/guava/lint-baseline.xml
index e3459e6..0f84c67 100644
--- a/room/guava/lint-baseline.xml
+++ b/room/guava/lint-baseline.xml
@@ -2,17 +2,6 @@
<issues format="6" by="lint 7.0.0-alpha15" type="baseline" client="cli" name="Lint" variant="all" version="7.0.0-alpha15">
<issue
- id="ClassVerificationFailure"
- message="This call references a method added in API level 16; however, the containing class null is reachable from earlier API levels and will fail run-time class verification."
- errorLine1=" cancellationSignal.cancel();"
- errorLine2=" ~~~~~~">
- <location
- file="src/main/java/androidx/room/guava/GuavaRoom.java"
- line="125"
- column="44"/>
- </issue>
-
- <issue
id="LambdaLast"
message="Functional interface parameters (such as parameter 1, "callable", in androidx.room.guava.GuavaRoom.createListenableFuture) should be last to improve Kotlin interoperability; see https://kotlinlang.org/docs/reference/java-interop.html#sam-conversions"
errorLine1=" final boolean releaseQuery) {"
diff --git a/room/guava/src/main/java/androidx/room/guava/GuavaRoom.java b/room/guava/src/main/java/androidx/room/guava/GuavaRoom.java
index 5993cfe..97e8e91 100644
--- a/room/guava/src/main/java/androidx/room/guava/GuavaRoom.java
+++ b/room/guava/src/main/java/androidx/room/guava/GuavaRoom.java
@@ -26,6 +26,7 @@
import androidx.concurrent.futures.ResolvableFuture;
import androidx.room.RoomDatabase;
import androidx.room.RoomSQLiteQuery;
+import androidx.sqlite.db.SupportSQLiteCompat;
import com.google.common.util.concurrent.ListenableFuture;
@@ -122,7 +123,7 @@
@Override
public void run() {
if (future.isCancelled()) {
- cancellationSignal.cancel();
+ SupportSQLiteCompat.Api16Impl.cancel(cancellationSignal);
}
}
}, sDirectExecutor);
diff --git a/room/ktx/lint-baseline.xml b/room/ktx/lint-baseline.xml
index 17243415..42a176b 100644
--- a/room/ktx/lint-baseline.xml
+++ b/room/ktx/lint-baseline.xml
@@ -1,26 +1,4 @@
<?xml version="1.0" encoding="UTF-8"?>
<issues format="6" by="lint 7.0.0-alpha15" type="baseline" client="cli" name="Lint" variant="all" version="7.0.0-alpha15">
- <issue
- id="ClassVerificationFailure"
- message="This call references a method added in API level 16; however, the containing class androidx.room.CoroutinesRoom is reachable from earlier API levels and will fail run-time class verification."
- errorLine1=" cancellationSignal.cancel()"
- errorLine2=" ~~~~~~">
- <location
- file="src/main/java/androidx/room/CoroutinesRoom.kt"
- line="93"
- column="44"/>
- </issue>
-
- <issue
- id="ClassVerificationFailure"
- message="This call references a method added in API level 16; however, the containing class androidx.room.CoroutinesRoom.Companion is reachable from earlier API levels and will fail run-time class verification."
- errorLine1=" cancellationSignal.cancel()"
- errorLine2=" ~~~~~~">
- <location
- file="src/main/java/androidx/room/CoroutinesRoom.kt"
- line="93"
- column="44"/>
- </issue>
-
</issues>
diff --git a/room/ktx/src/main/java/androidx/room/CoroutinesRoom.kt b/room/ktx/src/main/java/androidx/room/CoroutinesRoom.kt
index f45d8e5..8a71fe9 100644
--- a/room/ktx/src/main/java/androidx/room/CoroutinesRoom.kt
+++ b/room/ktx/src/main/java/androidx/room/CoroutinesRoom.kt
@@ -19,6 +19,7 @@
import android.os.Build
import android.os.CancellationSignal
import androidx.annotation.RestrictTo
+import androidx.sqlite.db.SupportSQLiteCompat
import kotlinx.coroutines.CoroutineDispatcher
import kotlinx.coroutines.GlobalScope
import kotlinx.coroutines.asCoroutineDispatcher
@@ -90,7 +91,7 @@
}
continuation.invokeOnCancellation {
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.JELLY_BEAN) {
- cancellationSignal.cancel()
+ SupportSQLiteCompat.Api16Impl.cancel(cancellationSignal)
}
job.cancel()
}
diff --git a/room/room-paging/api/current.txt b/room/room-paging/api/current.txt
new file mode 100644
index 0000000..e6f50d0
--- /dev/null
+++ b/room/room-paging/api/current.txt
@@ -0,0 +1 @@
+// Signature format: 4.0
diff --git a/room/room-paging/api/public_plus_experimental_current.txt b/room/room-paging/api/public_plus_experimental_current.txt
new file mode 100644
index 0000000..e6f50d0
--- /dev/null
+++ b/room/room-paging/api/public_plus_experimental_current.txt
@@ -0,0 +1 @@
+// Signature format: 4.0
diff --git a/room/room-paging/api/res-current.txt b/room/room-paging/api/res-current.txt
new file mode 100644
index 0000000..e69de29
--- /dev/null
+++ b/room/room-paging/api/res-current.txt
diff --git a/room/room-paging/api/restricted_current.txt b/room/room-paging/api/restricted_current.txt
new file mode 100644
index 0000000..e6f50d0
--- /dev/null
+++ b/room/room-paging/api/restricted_current.txt
@@ -0,0 +1 @@
+// Signature format: 4.0
diff --git a/room/room-paging/build.gradle b/room/room-paging/build.gradle
new file mode 100644
index 0000000..e9645b8
--- /dev/null
+++ b/room/room-paging/build.gradle
@@ -0,0 +1,40 @@
+/*
+ * Copyright (C) 2021 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.
+ */
+import static androidx.build.dependencies.DependenciesKt.*
+import androidx.build.LibraryGroups
+import androidx.build.LibraryType
+import androidx.build.LibraryVersions
+import androidx.build.Publish
+
+plugins {
+ id("AndroidXPlugin")
+ id("com.android.library")
+ id("org.jetbrains.kotlin.android")
+}
+
+dependencies {
+ api(KOTLIN_STDLIB)
+ // Add dependencies here
+}
+
+androidx {
+ name = "Room Paging"
+ type = LibraryType.PUBLISHED_LIBRARY
+ mavenGroup = LibraryGroups.ROOM
+ inceptionYear = "2021"
+ description = "Room Paging integration"
+ publish = Publish.NONE
+}
diff --git a/room/room-paging/src/androidTest/AndroidManifest.xml b/room/room-paging/src/androidTest/AndroidManifest.xml
new file mode 100644
index 0000000..50ba2eb
--- /dev/null
+++ b/room/room-paging/src/androidTest/AndroidManifest.xml
@@ -0,0 +1,20 @@
+<?xml version="1.0" encoding="utf-8"?>
+<!--
+ Copyright 2021 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.
+ -->
+<manifest xmlns:android="http://schemas.android.com/apk/res/android"
+ package="androidx.room.paging.test">
+
+</manifest>
diff --git a/room/room-paging/src/main/AndroidManifest.xml b/room/room-paging/src/main/AndroidManifest.xml
new file mode 100644
index 0000000..fa18cd8
--- /dev/null
+++ b/room/room-paging/src/main/AndroidManifest.xml
@@ -0,0 +1,20 @@
+<?xml version="1.0" encoding="utf-8"?>
+<!--
+ Copyright 2021 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.
+ -->
+<manifest xmlns:android="http://schemas.android.com/apk/res/android"
+ package="androidx.room.paging">
+
+</manifest>
\ No newline at end of file
diff --git a/room/runtime/build.gradle b/room/runtime/build.gradle
index 1740d3c..a1c2f8a 100644
--- a/room/runtime/build.gradle
+++ b/room/runtime/build.gradle
@@ -37,8 +37,8 @@
dependencies {
api(project(":room:room-common"))
- api("androidx.sqlite:sqlite-framework:2.1.0")
- api("androidx.sqlite:sqlite:2.1.0")
+ api(project(":sqlite:sqlite-framework"))
+ api(project(":sqlite:sqlite"))
implementation("androidx.arch.core:core-runtime:2.0.1")
compileOnly("androidx.paging:paging-common:2.0.0")
compileOnly("androidx.lifecycle:lifecycle-livedata-core:2.0.0")
diff --git a/room/runtime/lint-baseline.xml b/room/runtime/lint-baseline.xml
index 32d1bdf..cd534ae 100644
--- a/room/runtime/lint-baseline.xml
+++ b/room/runtime/lint-baseline.xml
@@ -57,72 +57,6 @@
</issue>
<issue
- id="ClassVerificationFailure"
- message="This call references a method added in API level 29; however, the containing class androidx.room.AutoClosingRoomOpenHelper.KeepAliveCursor is reachable from earlier API levels and will fail run-time class verification."
- errorLine1=" mDelegate.setNotificationUris(cr, uris);"
- errorLine2=" ~~~~~~~~~~~~~~~~~~~">
- <location
- file="src/main/java/androidx/room/AutoClosingRoomOpenHelper.java"
- line="706"
- column="23"/>
- </issue>
-
- <issue
- id="ClassVerificationFailure"
- message="This call references a method added in API level 19; however, the containing class androidx.room.AutoClosingRoomOpenHelper.KeepAliveCursor is reachable from earlier API levels and will fail run-time class verification."
- errorLine1=" return mDelegate.getNotificationUri();"
- errorLine2=" ~~~~~~~~~~~~~~~~~~">
- <location
- file="src/main/java/androidx/room/AutoClosingRoomOpenHelper.java"
- line="713"
- column="30"/>
- </issue>
-
- <issue
- id="ClassVerificationFailure"
- message="This call references a method added in API level 29; however, the containing class androidx.room.AutoClosingRoomOpenHelper.KeepAliveCursor is reachable from earlier API levels and will fail run-time class verification."
- errorLine1=" return mDelegate.getNotificationUris();"
- errorLine2=" ~~~~~~~~~~~~~~~~~~~">
- <location
- file="src/main/java/androidx/room/AutoClosingRoomOpenHelper.java"
- line="721"
- column="30"/>
- </issue>
-
- <issue
- id="ClassVerificationFailure"
- message="This call references a method added in API level 23; however, the containing class androidx.room.AutoClosingRoomOpenHelper.KeepAliveCursor is reachable from earlier API levels and will fail run-time class verification."
- errorLine1=" mDelegate.setExtras(extras);"
- errorLine2=" ~~~~~~~~~">
- <location
- file="src/main/java/androidx/room/AutoClosingRoomOpenHelper.java"
- line="733"
- column="23"/>
- </issue>
-
- <issue
- id="ClassVerificationFailure"
- message="This call references a method added in API level 16; however, the containing class androidx.room.util.DBUtil is reachable from earlier API levels and will fail run-time class verification."
- errorLine1=" return new CancellationSignal();"
- errorLine2=" ~~~~~~~~~~~~~~~~~~~~~~">
- <location
- file="src/main/java/androidx/room/util/DBUtil.java"
- line="168"
- column="20"/>
- </issue>
-
- <issue
- id="ClassVerificationFailure"
- message="This call references a method added in API level 19; however, the containing class androidx.room.RoomDatabase.JournalMode is reachable from earlier API levels and will fail run-time class verification."
- errorLine1=" return activityManager.isLowRamDevice();"
- errorLine2=" ~~~~~~~~~~~~~~">
- <location
- file="src/main/java/androidx/room/RoomDatabase.java"
- line="782"
- column="40"/>
- </issue>
-
- <issue
id="PrivateConstructorForUtilityClass"
message="Utility class is missing private constructor"
errorLine1="public class Room {"
diff --git a/room/runtime/src/main/java/androidx/room/AutoClosingRoomOpenHelper.java b/room/runtime/src/main/java/androidx/room/AutoClosingRoomOpenHelper.java
index b3a3853..430df67 100644
--- a/room/runtime/src/main/java/androidx/room/AutoClosingRoomOpenHelper.java
+++ b/room/runtime/src/main/java/androidx/room/AutoClosingRoomOpenHelper.java
@@ -36,6 +36,7 @@
import androidx.annotation.RequiresApi;
import androidx.arch.core.util.Function;
import androidx.room.util.SneakyThrow;
+import androidx.sqlite.db.SupportSQLiteCompat;
import androidx.sqlite.db.SupportSQLiteDatabase;
import androidx.sqlite.db.SupportSQLiteOpenHelper;
import androidx.sqlite.db.SupportSQLiteQuery;
@@ -703,14 +704,14 @@
@Override
public void setNotificationUris(@NonNull ContentResolver cr,
@NonNull List<Uri> uris) {
- mDelegate.setNotificationUris(cr, uris);
+ SupportSQLiteCompat.Api29Impl.setNotificationUris(mDelegate, cr, uris);
}
@SuppressLint("UnsafeNewApiCall")
@RequiresApi(api = Build.VERSION_CODES.KITKAT)
@Override
public Uri getNotificationUri() {
- return mDelegate.getNotificationUri();
+ return SupportSQLiteCompat.Api19Impl.getNotificationUri(mDelegate);
}
@SuppressLint("UnsafeNewApiCall")
@@ -718,7 +719,7 @@
@Nullable
@Override
public List<Uri> getNotificationUris() {
- return mDelegate.getNotificationUris();
+ return SupportSQLiteCompat.Api29Impl.getNotificationUris(mDelegate);
}
@Override
@@ -730,7 +731,7 @@
@RequiresApi(api = Build.VERSION_CODES.M)
@Override
public void setExtras(Bundle extras) {
- mDelegate.setExtras(extras);
+ SupportSQLiteCompat.Api23Impl.setExtras(mDelegate, extras);
}
@Override
diff --git a/room/runtime/src/main/java/androidx/room/RoomDatabase.java b/room/runtime/src/main/java/androidx/room/RoomDatabase.java
index d15c9c2..b6cf417 100644
--- a/room/runtime/src/main/java/androidx/room/RoomDatabase.java
+++ b/room/runtime/src/main/java/androidx/room/RoomDatabase.java
@@ -37,6 +37,7 @@
import androidx.room.migration.Migration;
import androidx.room.util.SneakyThrow;
import androidx.sqlite.db.SimpleSQLiteQuery;
+import androidx.sqlite.db.SupportSQLiteCompat;
import androidx.sqlite.db.SupportSQLiteDatabase;
import androidx.sqlite.db.SupportSQLiteOpenHelper;
import androidx.sqlite.db.SupportSQLiteQuery;
@@ -707,7 +708,7 @@
/**
* Journal modes for SQLite database.
*
- * @see RoomDatabase.Builder#setJournalMode(JournalMode)
+ * @see Builder#setJournalMode(JournalMode)
*/
public enum JournalMode {
@@ -752,7 +753,7 @@
private static boolean isLowRamDevice(@NonNull ActivityManager activityManager) {
if (Build.VERSION.SDK_INT >= 19) {
- return activityManager.isLowRamDevice();
+ return SupportSQLiteCompat.Api19Impl.isLowRamDevice(activityManager);
}
return false;
}
diff --git a/room/runtime/src/main/java/androidx/room/util/DBUtil.java b/room/runtime/src/main/java/androidx/room/util/DBUtil.java
index 1b9b866..c5014ae 100644
--- a/room/runtime/src/main/java/androidx/room/util/DBUtil.java
+++ b/room/runtime/src/main/java/androidx/room/util/DBUtil.java
@@ -25,6 +25,7 @@
import androidx.annotation.Nullable;
import androidx.annotation.RestrictTo;
import androidx.room.RoomDatabase;
+import androidx.sqlite.db.SupportSQLiteCompat;
import androidx.sqlite.db.SupportSQLiteDatabase;
import androidx.sqlite.db.SupportSQLiteQuery;
@@ -165,7 +166,7 @@
@Nullable
public static CancellationSignal createCancellationSignal() {
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.JELLY_BEAN) {
- return new CancellationSignal();
+ return SupportSQLiteCompat.Api16Impl.createCancellationSignal();
}
return null;
}
diff --git a/security/security-app-authenticator-testing/src/androidTest/java/androidx/security/app/authenticator/TestAppAuthenticatorBuilderTest.java b/security/security-app-authenticator-testing/src/androidTest/java/androidx/security/app/authenticator/TestAppAuthenticatorBuilderTest.java
index b45f255..83d27b6 100644
--- a/security/security-app-authenticator-testing/src/androidTest/java/androidx/security/app/authenticator/TestAppAuthenticatorBuilderTest.java
+++ b/security/security-app-authenticator-testing/src/androidTest/java/androidx/security/app/authenticator/TestAppAuthenticatorBuilderTest.java
@@ -324,4 +324,21 @@
assertThrows(SecurityException.class, () ->
appAuthenticatorFromInputStream.enforceAppIdentity(EXPECTED_IDENTITY_PACKAGE));
}
+
+ @Test
+ public void setSigningIdentityForPackage_digestCaseMismatch_returnsMatch() throws Exception {
+ // The TestAppAuthenticatorBuilder supports specifying a signing identity for a package
+ // under test; while the AppAuthenticator will normalize the digest in the config file to
+ // match the case output by the AppAuthenticatorUtils#computeDigest, the signing identity
+ // provided to the TestAppAuthenticatorBuilder#setSigningIdentityForPackage can be
+ // specified in either case. This test ensures regardless of the case provided to this
+ // method the value is normalized and a match can be successfully verified.
+ AppAuthenticator appAuthenticator =
+ mBuilderFromResource.setSigningIdentityForPackage(EXPECTED_IDENTITY_PACKAGE,
+ "6A8B96E278E58F62CFE3584022CEC1D0527FCB85A9E5D2E1694EB0405BE5B599")
+ .build();
+
+ assertEquals(AppAuthenticator.SIGNATURE_MATCH,
+ appAuthenticator.checkAppIdentity(EXPECTED_IDENTITY_PACKAGE));
+ }
}
diff --git a/security/security-app-authenticator-testing/src/main/java/androidx/security/app/authenticator/TestAppAuthenticatorBuilder.java b/security/security-app-authenticator-testing/src/main/java/androidx/security/app/authenticator/TestAppAuthenticatorBuilder.java
index a5f21d6..372a166 100644
--- a/security/security-app-authenticator-testing/src/main/java/androidx/security/app/authenticator/TestAppAuthenticatorBuilder.java
+++ b/security/security-app-authenticator-testing/src/main/java/androidx/security/app/authenticator/TestAppAuthenticatorBuilder.java
@@ -255,7 +255,9 @@
@NonNull String packageName,
@NonNull String certDigest) {
mTestPolicy = POLICY_CUSTOM;
- mAppSignatureVerifierBuilder.setSigningIdentityForPackage(packageName, certDigest);
+ mAppSignatureVerifierBuilder.setSigningIdentityForPackage(packageName,
+ AppAuthenticator.normalizeCertDigest(certDigest))
+ ;
return this;
}
diff --git a/security/security-app-authenticator/src/androidTest/java/androidx/security/app/authenticator/AppAuthenticatorTest.java b/security/security-app-authenticator/src/androidTest/java/androidx/security/app/authenticator/AppAuthenticatorTest.java
index f7402d3..b22b902 100644
--- a/security/security-app-authenticator/src/androidTest/java/androidx/security/app/authenticator/AppAuthenticatorTest.java
+++ b/security/security-app-authenticator/src/androidTest/java/androidx/security/app/authenticator/AppAuthenticatorTest.java
@@ -322,4 +322,22 @@
"d78405f761ff6236cc9b570347a570aba0c62a129a3ac30c831c64d09ad95469"));
assertEquals("SHA-256", config.getDigestAlgorithm());
}
+
+ @Test
+ public void createConfigFromParser_upperCaseDigestInConfig_returnsMatch() throws Exception {
+ // The digest computed by the AppAuthenticatorUtils is in lower case, but the
+ // AppAuthenticator supports matching digests provided in upper case as well.
+ // This test does not directly verify the digest of a package's signing certificate
+ // but instead uses the bytes from the package name in the identity; this test ensures
+ // the AppAuthenticator properly normalizes the provided digest so that it matches the
+ // digest returned by AppAuthenticatorUtils.
+ final String packageName = "com.example.app";
+ AppAuthenticator.AppAuthenticatorConfig config = AppAuthenticator.createConfigFromParser(
+ mResources.getXml(R.xml.upper_case_digest));
+ Set<String> expectedPackageIdentities = config.getExpectedIdentities().get(packageName);
+
+ assertTrue(expectedPackageIdentities.contains(
+ AppAuthenticatorUtils.computeDigest(AppAuthenticator.DEFAULT_DIGEST_ALGORITHM,
+ packageName.getBytes())));
+ }
}
diff --git a/security/security-app-authenticator/src/androidTest/res/xml/upper_case_digest.xml b/security/security-app-authenticator/src/androidTest/res/xml/upper_case_digest.xml
new file mode 100644
index 0000000..179c964
--- /dev/null
+++ b/security/security-app-authenticator/src/androidTest/res/xml/upper_case_digest.xml
@@ -0,0 +1,24 @@
+<?xml version="1.0" encoding="utf-8"?>
+<!--
+ Copyright 2021 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.
+ -->
+<app-authenticator>
+ <expected-identity>
+ <package name="com.example.app">
+ <cert-digest>8A464E05BF037AF2432200C8687455FCD1E0A804D69C8A30D29DA59F584AC77F
+ </cert-digest>
+ </package>
+ </expected-identity>
+</app-authenticator>
diff --git a/security/security-app-authenticator/src/main/java/androidx/security/app/authenticator/AppAuthenticator.java b/security/security-app-authenticator/src/main/java/androidx/security/app/authenticator/AppAuthenticator.java
index c6e26df..0e9f201 100644
--- a/security/security-app-authenticator/src/main/java/androidx/security/app/authenticator/AppAuthenticator.java
+++ b/security/security-app-authenticator/src/main/java/androidx/security/app/authenticator/AppAuthenticator.java
@@ -38,6 +38,7 @@
import java.io.IOException;
import java.io.InputStream;
+import java.util.Locale;
import java.util.Map;
import java.util.Set;
@@ -591,13 +592,28 @@
+ "on line " + parser.getLineNumber() + " must have non-empty text "
+ "containing the certificate digest of the signer");
}
- allowedCertDigests.add(digest);
+ allowedCertDigests.add(normalizeCertDigest(digest));
eventType = parser.nextTag();
}
return allowedCertDigests;
}
/**
+ * Normalizes the provided {@code certDigest} to ensure it is in the proper form for {@code
+ * Collection} membership checks when comparing a package's signing certificate digest against
+ * those provided to the {@code AppAuthenticator}.
+ *
+ * @param certDigest the digest to be normalized
+ * @return a normalized form of the provided digest that can be used in subsequent {@code
+ * Collection} membership checks
+ */
+ static String normalizeCertDigest(String certDigest) {
+ // The AppAuthenticatorUtils#computeDigest method uses lower case characters to compute the
+ // digest.
+ return certDigest.toLowerCase(Locale.US);
+ }
+
+ /**
* Moves the provided {@code parser} to the next {@link XmlPullParser#START_TAG} or {@link
* XmlPullParser#END_DOCUMENT} if the end of the document is reached, returning the value of
* the event type.
diff --git a/settings.gradle b/settings.gradle
index de23551..ba10801 100644
--- a/settings.gradle
+++ b/settings.gradle
@@ -529,6 +529,7 @@
includeProject(":room:room-guava", "room/guava", [BuildType.MAIN])
includeProject(":room:room-ktx", "room/ktx", [BuildType.MAIN])
includeProject(":room:room-migration", "room/migration", [BuildType.MAIN])
+includeProject(":room:room-paging", "room/room-paging", [BuildType.MAIN])
includeProject(":room:room-runtime", "room/runtime", [BuildType.MAIN])
includeProject(":room:room-rxjava2", "room/rxjava2", [BuildType.MAIN])
includeProject(":room:room-rxjava3", "room/rxjava3", [BuildType.MAIN])
diff --git a/sqlite/sqlite-framework/lint-baseline.xml b/sqlite/sqlite-framework/lint-baseline.xml
index 06f5edc..6603aec 100644
--- a/sqlite/sqlite-framework/lint-baseline.xml
+++ b/sqlite/sqlite-framework/lint-baseline.xml
@@ -34,81 +34,4 @@
column="9"/>
</issue>
- <issue
- id="ClassVerificationFailure"
- message="This call references a method added in API level 16; however, the containing class androidx.sqlite.db.framework.FrameworkSQLiteDatabase is reachable from earlier API levels and will fail run-time class verification."
- errorLine1=" return mDelegate.rawQueryWithFactory(new SQLiteDatabase.CursorFactory() {"
- errorLine2=" ~~~~~~~~~~~~~~~~~~~">
- <location
- file="src/main/java/androidx/sqlite/db/framework/FrameworkSQLiteDatabase.java"
- line="195"
- column="26"/>
- </issue>
-
- <issue
- id="ClassVerificationFailure"
- message="This call references a method added in API level 16; however, the containing class androidx.sqlite.db.framework.FrameworkSQLiteDatabase is reachable from earlier API levels and will fail run-time class verification."
- errorLine1=" mDelegate.setForeignKeyConstraintsEnabled(enable);"
- errorLine2=" ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~">
- <location
- file="src/main/java/androidx/sqlite/db/framework/FrameworkSQLiteDatabase.java"
- line="303"
- column="19"/>
- </issue>
-
- <issue
- id="ClassVerificationFailure"
- message="This call references a method added in API level 16; however, the containing class androidx.sqlite.db.framework.FrameworkSQLiteDatabase is reachable from earlier API levels and will fail run-time class verification."
- errorLine1=" mDelegate.disableWriteAheadLogging();"
- errorLine2=" ~~~~~~~~~~~~~~~~~~~~~~~~">
- <location
- file="src/main/java/androidx/sqlite/db/framework/FrameworkSQLiteDatabase.java"
- line="314"
- column="19"/>
- </issue>
-
- <issue
- id="ClassVerificationFailure"
- message="This call references a method added in API level 16; however, the containing class androidx.sqlite.db.framework.FrameworkSQLiteDatabase is reachable from earlier API levels and will fail run-time class verification."
- errorLine1=" return mDelegate.isWriteAheadLoggingEnabled();"
- errorLine2=" ~~~~~~~~~~~~~~~~~~~~~~~~~~">
- <location
- file="src/main/java/androidx/sqlite/db/framework/FrameworkSQLiteDatabase.java"
- line="320"
- column="26"/>
- </issue>
-
- <issue
- id="ClassVerificationFailure"
- message="This call references a method added in API level 21; however, the containing class androidx.sqlite.db.framework.FrameworkSQLiteOpenHelper is reachable from earlier API levels and will fail run-time class verification."
- errorLine1=" File file = new File(mContext.getNoBackupFilesDir(), mName);"
- errorLine2=" ~~~~~~~~~~~~~~~~~~~">
- <location
- file="src/main/java/androidx/sqlite/db/framework/FrameworkSQLiteOpenHelper.java"
- line="75"
- column="51"/>
- </issue>
-
- <issue
- id="ClassVerificationFailure"
- message="This call references a method added in API level 16; however, the containing class androidx.sqlite.db.framework.FrameworkSQLiteOpenHelper is reachable from earlier API levels and will fail run-time class verification."
- errorLine1=" mDelegate.setWriteAheadLoggingEnabled(mWriteAheadLoggingEnabled);"
- errorLine2=" ~~~~~~~~~~~~~~~~~~~~~~~~~~~">
- <location
- file="src/main/java/androidx/sqlite/db/framework/FrameworkSQLiteOpenHelper.java"
- line="81"
- column="31"/>
- </issue>
-
- <issue
- id="ClassVerificationFailure"
- message="This call references a method added in API level 16; however, the containing class androidx.sqlite.db.framework.FrameworkSQLiteOpenHelper is reachable from earlier API levels and will fail run-time class verification."
- errorLine1=" mDelegate.setWriteAheadLoggingEnabled(enabled);"
- errorLine2=" ~~~~~~~~~~~~~~~~~~~~~~~~~~~">
- <location
- file="src/main/java/androidx/sqlite/db/framework/FrameworkSQLiteOpenHelper.java"
- line="98"
- column="27"/>
- </issue>
-
</issues>
diff --git a/sqlite/sqlite-framework/src/main/java/androidx/sqlite/db/framework/FrameworkSQLiteDatabase.java b/sqlite/sqlite-framework/src/main/java/androidx/sqlite/db/framework/FrameworkSQLiteDatabase.java
index c75894e..7e14997 100644
--- a/sqlite/sqlite-framework/src/main/java/androidx/sqlite/db/framework/FrameworkSQLiteDatabase.java
+++ b/sqlite/sqlite-framework/src/main/java/androidx/sqlite/db/framework/FrameworkSQLiteDatabase.java
@@ -32,7 +32,9 @@
import androidx.annotation.NonNull;
import androidx.annotation.Nullable;
+import androidx.annotation.RequiresApi;
import androidx.sqlite.db.SimpleSQLiteQuery;
+import androidx.sqlite.db.SupportSQLiteCompat;
import androidx.sqlite.db.SupportSQLiteDatabase;
import androidx.sqlite.db.SupportSQLiteQuery;
import androidx.sqlite.db.SupportSQLiteStatement;
@@ -189,17 +191,18 @@
}
@Override
- @androidx.annotation.RequiresApi(api = Build.VERSION_CODES.JELLY_BEAN)
+ @RequiresApi(api = Build.VERSION_CODES.JELLY_BEAN)
public Cursor query(final SupportSQLiteQuery supportQuery,
CancellationSignal cancellationSignal) {
- return mDelegate.rawQueryWithFactory(new SQLiteDatabase.CursorFactory() {
- @Override
- public Cursor newCursor(SQLiteDatabase db, SQLiteCursorDriver masterQuery,
- String editTable, SQLiteQuery query) {
- supportQuery.bindTo(new FrameworkSQLiteProgram(query));
- return new SQLiteCursor(masterQuery, editTable, query);
- }
- }, supportQuery.getSql(), EMPTY_STRING_ARRAY, null, cancellationSignal);
+ return SupportSQLiteCompat.Api16Impl.rawQueryWithFactory(mDelegate, supportQuery.getSql(),
+ EMPTY_STRING_ARRAY, null, cancellationSignal, new SQLiteDatabase.CursorFactory() {
+ @Override
+ public Cursor newCursor(SQLiteDatabase db, SQLiteCursorDriver masterQuery,
+ String editTable, SQLiteQuery query) {
+ supportQuery.bindTo(new FrameworkSQLiteProgram(query));
+ return new SQLiteCursor(masterQuery, editTable, query);
+ }
+ });
}
@Override
@@ -298,9 +301,9 @@
}
@Override
- @androidx.annotation.RequiresApi(api = Build.VERSION_CODES.JELLY_BEAN)
+ @RequiresApi(api = Build.VERSION_CODES.JELLY_BEAN)
public void setForeignKeyConstraintsEnabled(boolean enable) {
- mDelegate.setForeignKeyConstraintsEnabled(enable);
+ SupportSQLiteCompat.Api16Impl.setForeignKeyConstraintsEnabled(mDelegate, enable);
}
@Override
@@ -309,15 +312,15 @@
}
@Override
- @androidx.annotation.RequiresApi(api = Build.VERSION_CODES.JELLY_BEAN)
+ @RequiresApi(api = Build.VERSION_CODES.JELLY_BEAN)
public void disableWriteAheadLogging() {
- mDelegate.disableWriteAheadLogging();
+ SupportSQLiteCompat.Api16Impl.disableWriteAheadLogging(mDelegate);
}
@Override
- @androidx.annotation.RequiresApi(api = Build.VERSION_CODES.JELLY_BEAN)
+ @RequiresApi(api = Build.VERSION_CODES.JELLY_BEAN)
public boolean isWriteAheadLoggingEnabled() {
- return mDelegate.isWriteAheadLoggingEnabled();
+ return SupportSQLiteCompat.Api16Impl.isWriteAheadLoggingEnabled(mDelegate);
}
@Override
diff --git a/sqlite/sqlite-framework/src/main/java/androidx/sqlite/db/framework/FrameworkSQLiteOpenHelper.java b/sqlite/sqlite-framework/src/main/java/androidx/sqlite/db/framework/FrameworkSQLiteOpenHelper.java
index a457b14..cc9415b 100644
--- a/sqlite/sqlite-framework/src/main/java/androidx/sqlite/db/framework/FrameworkSQLiteOpenHelper.java
+++ b/sqlite/sqlite-framework/src/main/java/androidx/sqlite/db/framework/FrameworkSQLiteOpenHelper.java
@@ -22,6 +22,8 @@
import android.database.sqlite.SQLiteOpenHelper;
import android.os.Build;
+import androidx.annotation.RequiresApi;
+import androidx.sqlite.db.SupportSQLiteCompat;
import androidx.sqlite.db.SupportSQLiteDatabase;
import androidx.sqlite.db.SupportSQLiteOpenHelper;
@@ -72,13 +74,17 @@
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.M
&& mName != null
&& mUseNoBackupDirectory) {
- File file = new File(mContext.getNoBackupFilesDir(), mName);
+ File file = new File(
+ SupportSQLiteCompat.Api21Impl.getNoBackupFilesDir(mContext),
+ mName
+ );
mDelegate = new OpenHelper(mContext, file.getAbsolutePath(), dbRef, mCallback);
} else {
mDelegate = new OpenHelper(mContext, mName, dbRef, mCallback);
}
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.JELLY_BEAN) {
- mDelegate.setWriteAheadLoggingEnabled(mWriteAheadLoggingEnabled);
+ SupportSQLiteCompat.Api16Impl.setWriteAheadLoggingEnabled(mDelegate,
+ mWriteAheadLoggingEnabled);
}
}
return mDelegate;
@@ -91,11 +97,11 @@
}
@Override
- @androidx.annotation.RequiresApi(api = Build.VERSION_CODES.JELLY_BEAN)
+ @RequiresApi(api = Build.VERSION_CODES.JELLY_BEAN)
public void setWriteAheadLoggingEnabled(boolean enabled) {
synchronized (mLock) {
if (mDelegate != null) {
- mDelegate.setWriteAheadLoggingEnabled(enabled);
+ SupportSQLiteCompat.Api16Impl.setWriteAheadLoggingEnabled(mDelegate, enabled);
}
mWriteAheadLoggingEnabled = enabled;
}
diff --git a/sqlite/sqlite/lint-baseline.xml b/sqlite/sqlite/lint-baseline.xml
index f4df559..1c02a16 100644
--- a/sqlite/sqlite/lint-baseline.xml
+++ b/sqlite/sqlite/lint-baseline.xml
@@ -2,17 +2,6 @@
<issues format="6" by="lint 7.0.0-alpha15" type="baseline" client="cli" name="Lint" variant="all" version="7.0.0-alpha15">
<issue
- id="ClassVerificationFailure"
- message="This call references a method added in API level 16; however, the containing class androidx.sqlite.db.SupportSQLiteOpenHelper.Callback is reachable from earlier API levels and will fail run-time class verification."
- errorLine1=" SQLiteDatabase.deleteDatabase(new File(fileName));"
- errorLine2=" ~~~~~~~~~~~~~~">
- <location
- file="src/main/java/androidx/sqlite/db/SupportSQLiteOpenHelper.java"
- line="284"
- column="36"/>
- </issue>
-
- <issue
id="UnknownNullness"
message="Unknown nullability; explicitly declare as `@Nullable` or `@NonNull` to improve Kotlin interoperability; see https://android.github.io/kotlin-guides/interop.html#nullability-annotations"
errorLine1=" public SimpleSQLiteQuery(String query, @Nullable Object[] bindArgs) {"
diff --git a/sqlite/sqlite/src/main/java/androidx/sqlite/db/SupportSQLiteCompat.java b/sqlite/sqlite/src/main/java/androidx/sqlite/db/SupportSQLiteCompat.java
new file mode 100644
index 0000000..286d449
--- /dev/null
+++ b/sqlite/sqlite/src/main/java/androidx/sqlite/db/SupportSQLiteCompat.java
@@ -0,0 +1,321 @@
+/*
+ * Copyright 2021 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.sqlite.db;
+
+import android.app.ActivityManager;
+import android.content.ContentResolver;
+import android.content.Context;
+import android.database.ContentObserver;
+import android.database.Cursor;
+import android.database.sqlite.SQLiteDatabase;
+import android.database.sqlite.SQLiteOpenHelper;
+import android.net.Uri;
+import android.os.Bundle;
+import android.os.CancellationSignal;
+import android.os.OperationCanceledException;
+
+import androidx.annotation.NonNull;
+import androidx.annotation.RequiresApi;
+import androidx.annotation.RestrictTo;
+
+import java.io.File;
+import java.util.List;
+
+/**
+ * Helper for accessing features in {@link SupportSQLiteOpenHelper}.
+ *
+ * @hide
+ */
+@RestrictTo(RestrictTo.Scope.LIBRARY_GROUP)
+public final class SupportSQLiteCompat {
+ private SupportSQLiteCompat() { }
+ /**
+ * Class for accessing functions that require SDK version 16 and higher.
+ *
+ * @hide
+ */
+ @RestrictTo(RestrictTo.Scope.LIBRARY_GROUP)
+ @RequiresApi(16)
+ public static final class Api16Impl {
+
+ /**
+ * Cancels the operation and signals the cancellation listener. If the operation has not yet
+ * started, then it will be canceled as soon as it does.
+ *
+ * @hide
+ */
+ @RestrictTo(RestrictTo.Scope.LIBRARY_GROUP)
+ public static void cancel(@NonNull CancellationSignal cancellationSignal) {
+ cancellationSignal.cancel();
+ }
+
+ /**
+ * Creates a cancellation signal, initially not canceled.
+ *
+ * @return a new cancellation signal
+ *
+ * @hide
+ */
+ @RestrictTo(RestrictTo.Scope.LIBRARY_GROUP)
+ @NonNull
+ public static CancellationSignal createCancellationSignal() {
+ return new CancellationSignal();
+ }
+
+ /**
+ * Deletes a database including its journal file and other auxiliary files
+ * that may have been created by the database engine.
+ *
+ * @param file The database file path.
+ * @return True if the database was successfully deleted.
+ *
+ * @hide
+ */
+ @RestrictTo(RestrictTo.Scope.LIBRARY_GROUP)
+ @SuppressWarnings("StreamFiles")
+ public static boolean deleteDatabase(@NonNull File file) {
+ return SQLiteDatabase.deleteDatabase(file);
+ }
+
+ /**
+ * Runs the provided SQL and returns a cursor over the result set.
+ *
+ * @param sql the SQL query. The SQL string must not be ; terminated
+ * @param selectionArgs You may include ?s in where clause in the query,
+ * which will be replaced by the values from selectionArgs. The
+ * values will be bound as Strings.
+ * @param editTable the name of the first table, which is editable
+ * @param cancellationSignal A signal to cancel the operation in progress, or null if none.
+ * If the operation is canceled, then {@link OperationCanceledException} will be thrown
+ * when the query is executed.
+ * @param cursorFactory the cursor factory to use, or null for the default factory
+ * @return A {@link Cursor} object, which is positioned before the first entry. Note that
+ * {@link Cursor}s are not synchronized, see the documentation for more details.
+ *
+ * @hide
+ */
+ @RestrictTo(RestrictTo.Scope.LIBRARY_GROUP)
+ @NonNull
+ public static Cursor rawQueryWithFactory(@NonNull SQLiteDatabase sQLiteDatabase,
+ @NonNull String sql, @NonNull String[] selectionArgs,
+ @NonNull String editTable, @NonNull CancellationSignal cancellationSignal,
+ @NonNull SQLiteDatabase.CursorFactory cursorFactory) {
+ return sQLiteDatabase.rawQueryWithFactory(cursorFactory, sql, selectionArgs, editTable,
+ cancellationSignal);
+ }
+
+ /**
+ * Sets whether foreign key constraints are enabled for the database.
+ *
+ * @param enable True to enable foreign key constraints, false to disable them.
+ *
+ * @throws IllegalStateException if the are transactions is in progress
+ * when this method is called.
+ *
+ * @hide
+ */
+ @RestrictTo(RestrictTo.Scope.LIBRARY_GROUP)
+ public static void setForeignKeyConstraintsEnabled(@NonNull SQLiteDatabase sQLiteDatabase,
+ boolean enable) {
+ sQLiteDatabase.setForeignKeyConstraintsEnabled(enable);
+ }
+
+ /**
+ * This method disables the features enabled by
+ * {@link SQLiteDatabase#enableWriteAheadLogging()}.
+ *
+ * @throws IllegalStateException if there are transactions in progress at the
+ * time this method is called. WAL mode can only be changed when there are no
+ * transactions in progress.
+ *
+ * @see SQLiteDatabase#enableWriteAheadLogging
+ *
+ * @hide
+ */
+ @RestrictTo(RestrictTo.Scope.LIBRARY_GROUP)
+ public static void disableWriteAheadLogging(@NonNull SQLiteDatabase sQLiteDatabase) {
+ sQLiteDatabase.disableWriteAheadLogging();
+ }
+
+ /**
+ * Returns true if write-ahead logging has been enabled for this database.
+ *
+ * @return True if write-ahead logging has been enabled for this database.
+ *
+ * @see SQLiteDatabase#enableWriteAheadLogging
+ * @see SQLiteDatabase#ENABLE_WRITE_AHEAD_LOGGING
+ *
+ * @hide
+ */
+ @RestrictTo(RestrictTo.Scope.LIBRARY_GROUP)
+ public static boolean isWriteAheadLoggingEnabled(@NonNull SQLiteDatabase sQLiteDatabase) {
+ return sQLiteDatabase.isWriteAheadLoggingEnabled();
+ }
+
+ /**
+ * Sets {@link SQLiteDatabase#ENABLE_WRITE_AHEAD_LOGGING} flag if {@code enabled} is {@code
+ * true}, unsets otherwise.
+ *
+ * @hide
+ */
+ @RestrictTo(RestrictTo.Scope.LIBRARY_GROUP)
+ public static void setWriteAheadLoggingEnabled(@NonNull SQLiteOpenHelper sQLiteOpenHelper,
+ boolean enabled) {
+ sQLiteOpenHelper.setWriteAheadLoggingEnabled(enabled);
+ }
+
+ private Api16Impl() {}
+ }
+
+ /**
+ * Helper for accessing functions that require SDK version 19 and higher.
+ *
+ * @hide
+ */
+ @RestrictTo(RestrictTo.Scope.LIBRARY_GROUP)
+ @RequiresApi(19)
+ public static final class Api19Impl {
+ /**
+ * Return the URI at which notifications of changes in this Cursor's data
+ * will be delivered.
+ *
+ * @return Returns a URI that can be used with
+ * {@link ContentResolver#registerContentObserver(android.net.Uri, boolean, ContentObserver)
+ * ContentResolver.registerContentObserver} to find out about changes to this Cursor's
+ * data. May be null if no notification URI has been set.
+ *
+ * @hide
+ */
+ @RestrictTo(RestrictTo.Scope.LIBRARY_GROUP)
+ @NonNull
+ public static Uri getNotificationUri(@NonNull Cursor cursor) {
+ return cursor.getNotificationUri();
+ }
+
+
+ /**
+ * Returns true if this is a low-RAM device. Exactly whether a device is low-RAM
+ * is ultimately up to the device configuration, but currently it generally means
+ * something with 1GB or less of RAM. This is mostly intended to be used by apps
+ * to determine whether they should turn off certain features that require more RAM.
+ *
+ * @hide
+ */
+ @RestrictTo(RestrictTo.Scope.LIBRARY_GROUP)
+ public static boolean isLowRamDevice(@NonNull ActivityManager activityManager) {
+ return activityManager.isLowRamDevice();
+ }
+
+ private Api19Impl() {}
+ }
+
+ /**
+ * Helper for accessing functions that require SDK version 21 and higher.
+ *
+ * @hide
+ */
+ @RestrictTo(RestrictTo.Scope.LIBRARY_GROUP)
+ @RequiresApi(21)
+ public static final class Api21Impl {
+
+ /**
+ * Returns the absolute path to the directory on the filesystem.
+ *
+ * @return The path of the directory holding application files that will not
+ * be automatically backed up to remote storage.
+ *
+ * @hide
+ */
+ @RestrictTo(RestrictTo.Scope.LIBRARY_GROUP)
+ @NonNull
+ public static File getNoBackupFilesDir(@NonNull Context context) {
+ return context.getNoBackupFilesDir();
+ }
+
+ private Api21Impl() {}
+ }
+
+ /**
+ * Helper for accessing functions that require SDK version 23 and higher.
+ *
+ * @hide
+ */
+ @RestrictTo(RestrictTo.Scope.LIBRARY_GROUP)
+ @RequiresApi(23)
+ public static final class Api23Impl {
+
+ /**
+ * Sets a {@link Bundle} that will be returned by {@link Cursor#getExtras()}.
+ *
+ * @param extras {@link Bundle} to set, or null to set an empty bundle.
+ *
+ * @hide
+ */
+ @RestrictTo(RestrictTo.Scope.LIBRARY_GROUP)
+ public static void setExtras(@NonNull Cursor cursor, @NonNull Bundle extras) {
+ cursor.setExtras(extras);
+ }
+
+ private Api23Impl() {}
+ }
+
+ /**
+ * Helper for accessing functions that require SDK version 29 and higher.
+ *
+ * @hide
+ */
+ @RestrictTo(RestrictTo.Scope.LIBRARY_GROUP)
+ @RequiresApi(29)
+ public static final class Api29Impl {
+
+ /**
+ * Similar to {@link Cursor#setNotificationUri(ContentResolver, Uri)}, except this version
+ * allows to watch multiple content URIs for changes.
+ *
+ * @param cr The content resolver from the caller's context. The listener attached to
+ * this resolver will be notified.
+ * @param uris The content URIs to watch.
+ *
+ * @hide
+ */
+ @RestrictTo(RestrictTo.Scope.LIBRARY_GROUP)
+ public static void setNotificationUris(@NonNull Cursor cursor, @NonNull ContentResolver cr,
+ @NonNull List<Uri> uris) {
+ cursor.setNotificationUris(cr, uris);
+ }
+
+ /**
+ * Return the URIs at which notifications of changes in this Cursor's data
+ * will be delivered, as previously set by {@link #setNotificationUris}.
+ *
+ * @return Returns URIs that can be used with
+ * {@link ContentResolver#registerContentObserver(android.net.Uri, boolean, ContentObserver)
+ * ContentResolver.registerContentObserver} to find out about changes to this Cursor's
+ * data. May be null if no notification URI has been set.
+ *
+ * @hide
+ */
+ @RestrictTo(RestrictTo.Scope.LIBRARY_GROUP)
+ @NonNull
+ public static List<Uri> getNotificationUris(@NonNull Cursor cursor) {
+ return cursor.getNotificationUris();
+ }
+
+ private Api29Impl() {}
+ }
+
+}
diff --git a/sqlite/sqlite/src/main/java/androidx/sqlite/db/SupportSQLiteOpenHelper.java b/sqlite/sqlite/src/main/java/androidx/sqlite/db/SupportSQLiteOpenHelper.java
index f39b07c..0123606 100644
--- a/sqlite/sqlite/src/main/java/androidx/sqlite/db/SupportSQLiteOpenHelper.java
+++ b/sqlite/sqlite/src/main/java/androidx/sqlite/db/SupportSQLiteOpenHelper.java
@@ -17,8 +17,8 @@
package androidx.sqlite.db;
import android.content.Context;
-import android.database.sqlite.SQLiteDatabase;
import android.database.sqlite.SQLiteException;
+import android.database.sqlite.SQLiteOpenHelper;
import android.os.Build;
import android.text.TextUtils;
import android.util.Log;
@@ -109,16 +109,16 @@
/**
* Handles various lifecycle events for the SQLite connection, similar to
- * {@link android.database.sqlite.SQLiteOpenHelper}.
+ * {@link SQLiteOpenHelper}.
*/
@SuppressWarnings({"unused", "WeakerAccess"})
abstract class Callback {
private static final String TAG = "SupportSQLite";
/**
* Version number of the database (starting at 1); if the database is older,
- * {@link SupportSQLiteOpenHelper.Callback#onUpgrade(SupportSQLiteDatabase, int, int)}
+ * {@link Callback#onUpgrade(SupportSQLiteDatabase, int, int)}
* will be used to upgrade the database; if the database is newer,
- * {@link SupportSQLiteOpenHelper.Callback#onDowngrade(SupportSQLiteDatabase, int, int)}
+ * {@link Callback#onDowngrade(SupportSQLiteDatabase, int, int)}
* will be used to downgrade the database.
*/
public final int version;
@@ -281,7 +281,7 @@
Log.w(TAG, "deleting the database file: " + fileName);
try {
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.JELLY_BEAN) {
- SQLiteDatabase.deleteDatabase(new File(fileName));
+ SupportSQLiteCompat.Api16Impl.deleteDatabase(new File(fileName));
} else {
try {
final boolean deleted = new File(fileName).delete();
diff --git a/testutils/testutils-navigation/src/androidTest/java/androidx/testutils/TestNavigatorDestinationBuilderTest.kt b/testutils/testutils-navigation/src/androidTest/java/androidx/testutils/TestNavigatorDestinationBuilderTest.kt
index fb2d187..20383a3 100644
--- a/testutils/testutils-navigation/src/androidTest/java/androidx/testutils/TestNavigatorDestinationBuilderTest.kt
+++ b/testutils/testutils-navigation/src/androidTest/java/androidx/testutils/TestNavigatorDestinationBuilderTest.kt
@@ -31,6 +31,7 @@
class TestNavigatorDestinationBuilderTest {
private val provider = TestNavigatorProvider()
+ @Suppress("DEPRECATION")
@Test
fun test() {
val graph = provider.navigation(startDestination = DESTINATION_ID) {
@@ -53,6 +54,7 @@
)
}
+ @Suppress("DEPRECATION")
@Test
fun testWithBody() {
val graph = provider.navigation(startDestination = DESTINATION_ID) {
diff --git a/testutils/testutils-navigation/src/main/java/androidx/testutils/TestNavigatorDestinationBuilder.kt b/testutils/testutils-navigation/src/main/java/androidx/testutils/TestNavigatorDestinationBuilder.kt
index f8b90e7..a9bcbad 100644
--- a/testutils/testutils-navigation/src/main/java/androidx/testutils/TestNavigatorDestinationBuilder.kt
+++ b/testutils/testutils-navigation/src/main/java/androidx/testutils/TestNavigatorDestinationBuilder.kt
@@ -37,6 +37,7 @@
/**
* Construct a new [TestNavigator.Destination]
*/
+@Suppress("DEPRECATION")
inline fun NavGraphBuilder.test(
@IdRes id: Int,
builder: TestNavigatorDestinationBuilder.() -> Unit
@@ -62,6 +63,7 @@
*/
@NavDestinationDsl
class TestNavigatorDestinationBuilder : NavDestinationBuilder<TestNavigator.Destination> {
+ @Suppress("DEPRECATION")
constructor(navigator: TestNavigator, @IdRes id: Int = 0) : super(navigator, id)
constructor(navigator: TestNavigator, route: String) : super(navigator, route)
}
diff --git a/wear/compose/material/src/androidAndroidTest/kotlin/androidx/wear/compose/material/ChipTest.kt b/wear/compose/material/src/androidAndroidTest/kotlin/androidx/wear/compose/material/ChipTest.kt
index 48a160f..defc993 100644
--- a/wear/compose/material/src/androidAndroidTest/kotlin/androidx/wear/compose/material/ChipTest.kt
+++ b/wear/compose/material/src/androidAndroidTest/kotlin/androidx/wear/compose/material/ChipTest.kt
@@ -27,6 +27,7 @@
import androidx.compose.testutils.assertShape
import androidx.compose.ui.Modifier
import androidx.compose.ui.graphics.Color
+import androidx.compose.ui.graphics.compositeOver
import androidx.compose.ui.platform.LocalLayoutDirection
import androidx.compose.ui.platform.testTag
import androidx.compose.ui.semantics.Role
@@ -310,7 +311,9 @@
.setContentWithThemeForSizeAssertions(useUnmergedTree = true) {
CompactChip(
onClick = {},
- modifier = Modifier.testTag(chipTag).width(100.dp),
+ modifier = Modifier
+ .testTag(chipTag)
+ .width(100.dp),
icon = { CreateImage(iconTag) }
)
}
@@ -381,7 +384,7 @@
TestChipColors.Primary,
ChipStatus.Enabled,
{ MaterialTheme.colors.primary },
- { MaterialTheme.colors.onPrimary }
+ { MaterialTheme.colors.onPrimary },
)
@Test
@@ -413,7 +416,7 @@
TestChipColors.Primary,
ChipStatus.Disabled,
{ MaterialTheme.colors.primary },
- { MaterialTheme.colors.onPrimary }
+ { MaterialTheme.colors.onPrimary },
)
@Test
@@ -626,16 +629,22 @@
var expectedBackground = Color.Transparent
var expectedContent = Color.Transparent
var actualContent = Color.Transparent
- var expectedAlpha = 0.0f
+ val testBackground = Color.White
rule.setContentWithTheme {
- expectedBackground = backgroundColor()
- expectedContent = contentColor()
- expectedAlpha = ContentAlpha.disabled
+ if (status.enabled()) {
+ expectedBackground = backgroundColor()
+ expectedContent = contentColor()
+ } else {
+ expectedBackground =
+ backgroundColor().copy(alpha = ContentAlpha.disabled)
+ .compositeOver(testBackground)
+ expectedContent = contentColor().copy(alpha = ContentAlpha.disabled)
+ }
Box(
modifier = Modifier
.fillMaxSize()
- .background(expectedBackground)
+ .background(testBackground)
) {
Chip(
onClick = {},
@@ -647,17 +656,14 @@
}
}
- if (status.enabled()) {
- assertEquals(expectedContent, actualContent)
- } else {
- assertEquals(expectedContent.copy(alpha = expectedAlpha), actualContent)
- }
+ assertEquals(expectedContent, actualContent)
- if (expectedBackground != Color.Transparent) {
- rule.onNodeWithTag("test-item").onChildAt(0)
- .captureToImage()
- .assertContainsColor(expectedBackground, 50.0f)
- }
+ rule.onNodeWithTag("test-item")
+ .captureToImage()
+ .assertContainsColor(
+ if (expectedBackground != Color.Transparent) expectedBackground else testBackground,
+ 50.0f
+ )
}
private fun verifySlotColors(
@@ -676,18 +682,27 @@
var actualContent = Color.Transparent
var actualSecondaryContent = Color.Transparent
var actualIcon = Color.Transparent
- var expectedAlpha = 0.0f
+ val testBackground = Color.White
rule.setContentWithTheme {
- expectedBackground = backgroundColor()
- expectedContent = contentColor()
- expectedSecondaryContent = secondaryContentColor()
- expectedIcon = iconColor()
- expectedAlpha = ContentAlpha.disabled
+ if (status.enabled()) {
+ expectedBackground = backgroundColor()
+ expectedContent = contentColor()
+ expectedSecondaryContent = secondaryContentColor()
+ expectedIcon = iconColor()
+ } else {
+ expectedBackground =
+ backgroundColor().copy(alpha = ContentAlpha.disabled)
+ .compositeOver(testBackground)
+ expectedContent = contentColor().copy(alpha = ContentAlpha.disabled)
+ expectedSecondaryContent = secondaryContentColor()
+ .copy(alpha = ContentAlpha.disabled)
+ expectedIcon = iconColor().copy(alpha = ContentAlpha.disabled)
+ }
Box(
modifier = Modifier
.fillMaxSize()
- .background(expectedBackground)
+ .background(testBackground)
) {
if (compactChip) {
CompactChip(
@@ -712,28 +727,18 @@
}
}
- if (status.enabled()) {
- assertEquals(expectedContent, actualContent)
- if (! compactChip) {
- assertEquals(expectedSecondaryContent, actualSecondaryContent)
- }
- assertEquals(expectedIcon, actualIcon)
- } else {
- assertEquals(expectedContent.copy(alpha = expectedAlpha), actualContent)
- if (! compactChip) {
- assertEquals(
- expectedSecondaryContent.copy(alpha = expectedAlpha),
- actualSecondaryContent
- )
- }
- assertEquals(expectedIcon.copy(alpha = expectedAlpha), actualIcon)
+ assertEquals(expectedContent, actualContent)
+ if (! compactChip) {
+ assertEquals(expectedSecondaryContent, actualSecondaryContent)
}
+ assertEquals(expectedIcon, actualIcon)
- if (expectedBackground != Color.Transparent) {
- rule.onNodeWithTag("test-item").onChildAt(0)
- .captureToImage()
- .assertContainsColor(expectedBackground, 50.0f)
- }
+ rule.onNodeWithTag("test-item")
+ .captureToImage()
+ .assertContainsColor(
+ if (expectedBackground != Color.Transparent) expectedBackground else testBackground,
+ 50.0f
+ )
}
}
diff --git a/wear/compose/material/src/commonMain/kotlin/androidx/wear/compose/material/Chip.kt b/wear/compose/material/src/commonMain/kotlin/androidx/wear/compose/material/Chip.kt
index fce5d9c..75b21b3 100644
--- a/wear/compose/material/src/commonMain/kotlin/androidx/wear/compose/material/Chip.kt
+++ b/wear/compose/material/src/commonMain/kotlin/androidx/wear/compose/material/Chip.kt
@@ -15,6 +15,7 @@
*/
package androidx.wear.compose.material
+import androidx.compose.foundation.background
import androidx.compose.foundation.clickable
import androidx.compose.foundation.interaction.Interaction
import androidx.compose.foundation.interaction.MutableInteractionSource
@@ -29,8 +30,6 @@
import androidx.compose.foundation.layout.size
import androidx.compose.foundation.layout.width
import androidx.compose.foundation.layout.wrapContentSize
-import androidx.compose.material.ContentAlpha
-import androidx.compose.material.Surface
import androidx.compose.material.ripple.rememberRipple
import androidx.compose.runtime.Composable
import androidx.compose.runtime.CompositionLocalProvider
@@ -41,6 +40,7 @@
import androidx.compose.runtime.rememberUpdatedState
import androidx.compose.ui.Alignment
import androidx.compose.ui.Modifier
+import androidx.compose.ui.draw.clip
import androidx.compose.ui.draw.paint
import androidx.compose.ui.graphics.Color
import androidx.compose.ui.graphics.Shape
@@ -98,11 +98,11 @@
role: Role? = Role.Button,
content: @Composable () -> Unit,
) {
- Surface(
+ Box(
modifier = modifier
- .height(ChipDefaults.Height),
- color = Color.Transparent,
- shape = shape,
+ .height(ChipDefaults.Height)
+ .clip(shape = shape)
+ .background(color = Color.Transparent, shape = shape)
) {
// TODO: Due to b/178201337 the paint() modifier on the box doesn't make a call to draw the
// box contents. As a result we need to have stacked boxes to enable us to paint the
@@ -121,6 +121,7 @@
indication = rememberRipple(),
interactionSource = interactionSource,
)
+ .fillMaxSize()
.padding(contentPadding)
Box(
@@ -132,6 +133,7 @@
CompositionLocalProvider(
LocalContentColor provides colors.contentColor(enabled = enabled).value,
LocalTextStyle provides MaterialTheme.typography.button,
+ LocalContentAlpha provides colors.contentColor(enabled = enabled).value.alpha,
content = content
)
}
@@ -212,6 +214,8 @@
) {
CompositionLocalProvider(
LocalContentColor provides colors.iconTintColor(enabled).value,
+ LocalContentAlpha provides
+ colors.iconTintColor(enabled = enabled).value.alpha,
content = icon
)
}
@@ -221,12 +225,15 @@
CompositionLocalProvider(
LocalContentColor provides colors.contentColor(enabled).value,
LocalTextStyle provides MaterialTheme.typography.button,
+ LocalContentAlpha provides colors.contentColor(enabled = enabled).value.alpha,
content = label
)
if (secondaryLabel != null) {
CompositionLocalProvider(
LocalContentColor provides colors.secondaryContentColor(enabled).value,
LocalTextStyle provides MaterialTheme.typography.button,
+ LocalContentAlpha provides
+ colors.secondaryContentColor(enabled = enabled).value.alpha,
content = secondaryLabel
)
}
@@ -508,7 +515,7 @@
disabledContentColor: Color = contentColor.copy(alpha = ContentAlpha.disabled),
disabledSecondaryContentColor: Color =
secondaryContentColor.copy(alpha = ContentAlpha.disabled),
- disabledIconTintColor: Color = disabledContentColor,
+ disabledIconTintColor: Color = iconTintColor.copy(alpha = ContentAlpha.disabled),
): ChipColors = DefaultChipColors(
backgroundColor = backgroundColor,
contentColor = contentColor,
diff --git a/wear/tiles/tiles/api/current.txt b/wear/tiles/tiles/api/current.txt
index 4209662..1d82943 100644
--- a/wear/tiles/tiles/api/current.txt
+++ b/wear/tiles/tiles/api/current.txt
@@ -124,6 +124,32 @@
method public androidx.wear.tiles.ColorBuilders.ColorProp.Builder setArgb(@ColorInt int);
}
+ public final class DeviceParametersBuilders {
+ field public static final int DEVICE_PLATFORM_UNDEFINED = 0; // 0x0
+ field public static final int DEVICE_PLATFORM_WEAR_OS = 1; // 0x1
+ field public static final int SCREEN_SHAPE_RECT = 2; // 0x2
+ field public static final int SCREEN_SHAPE_ROUND = 1; // 0x1
+ field public static final int SCREEN_SHAPE_UNDEFINED = 0; // 0x0
+ }
+
+ public static final class DeviceParametersBuilders.DeviceParameters {
+ method public static androidx.wear.tiles.DeviceParametersBuilders.DeviceParameters.Builder builder();
+ method public int getDevicePlatform();
+ method @FloatRange(from=0.0, fromInclusive=false, toInclusive=false) public float getScreenDensity();
+ method @Dimension(unit=androidx.annotation.Dimension.DP) public int getScreenHeightDp();
+ method public int getScreenShape();
+ method @Dimension(unit=androidx.annotation.Dimension.DP) public int getScreenWidthDp();
+ }
+
+ public static final class DeviceParametersBuilders.DeviceParameters.Builder {
+ method public androidx.wear.tiles.DeviceParametersBuilders.DeviceParameters build();
+ method public androidx.wear.tiles.DeviceParametersBuilders.DeviceParameters.Builder setDevicePlatform(int);
+ method public androidx.wear.tiles.DeviceParametersBuilders.DeviceParameters.Builder setScreenDensity(@FloatRange(from=0.0, fromInclusive=false, toInclusive=false) float);
+ method public androidx.wear.tiles.DeviceParametersBuilders.DeviceParameters.Builder setScreenHeightDp(@Dimension(unit=androidx.annotation.Dimension.DP) int);
+ method public androidx.wear.tiles.DeviceParametersBuilders.DeviceParameters.Builder setScreenShape(int);
+ method public androidx.wear.tiles.DeviceParametersBuilders.DeviceParameters.Builder setScreenWidthDp(@Dimension(unit=androidx.annotation.Dimension.DP) int);
+ }
+
public final class DimensionBuilders {
method public static androidx.wear.tiles.DimensionBuilders.DegreesProp degrees(float);
method public static androidx.wear.tiles.DimensionBuilders.DpProp dp(@Dimension(unit=androidx.annotation.Dimension.DP) float);
@@ -222,6 +248,41 @@
method public androidx.wear.tiles.DimensionBuilders.WrappedDimensionProp build();
}
+ public final class EventBuilders {
+ }
+
+ public static final class EventBuilders.TileAddEvent {
+ method public static androidx.wear.tiles.EventBuilders.TileAddEvent.Builder builder();
+ }
+
+ public static final class EventBuilders.TileAddEvent.Builder {
+ method public androidx.wear.tiles.EventBuilders.TileAddEvent build();
+ }
+
+ public static final class EventBuilders.TileEnterEvent {
+ method public static androidx.wear.tiles.EventBuilders.TileEnterEvent.Builder builder();
+ }
+
+ public static final class EventBuilders.TileEnterEvent.Builder {
+ method public androidx.wear.tiles.EventBuilders.TileEnterEvent build();
+ }
+
+ public static final class EventBuilders.TileLeaveEvent {
+ method public static androidx.wear.tiles.EventBuilders.TileLeaveEvent.Builder builder();
+ }
+
+ public static final class EventBuilders.TileLeaveEvent.Builder {
+ method public androidx.wear.tiles.EventBuilders.TileLeaveEvent build();
+ }
+
+ public static final class EventBuilders.TileRemoveEvent {
+ method public static androidx.wear.tiles.EventBuilders.TileRemoveEvent.Builder builder();
+ }
+
+ public static final class EventBuilders.TileRemoveEvent.Builder {
+ method public androidx.wear.tiles.EventBuilders.TileRemoveEvent build();
+ }
+
public final class LayoutElementBuilders {
field public static final int ARC_ANCHOR_CENTER = 2; // 0x2
field public static final int ARC_ANCHOR_END = 3; // 0x3
@@ -465,28 +526,28 @@
public static class LayoutElementBuilders.FontStyles {
method @Deprecated public androidx.wear.tiles.LayoutElementBuilders.FontStyle.Builder body1();
- method public static androidx.wear.tiles.LayoutElementBuilders.FontStyle.Builder body1(androidx.wear.tiles.readers.DeviceParametersReaders.DeviceParameters);
+ method public static androidx.wear.tiles.LayoutElementBuilders.FontStyle.Builder body1(androidx.wear.tiles.DeviceParametersBuilders.DeviceParameters);
method @Deprecated public androidx.wear.tiles.LayoutElementBuilders.FontStyle.Builder body2();
- method public static androidx.wear.tiles.LayoutElementBuilders.FontStyle.Builder body2(androidx.wear.tiles.readers.DeviceParametersReaders.DeviceParameters);
+ method public static androidx.wear.tiles.LayoutElementBuilders.FontStyle.Builder body2(androidx.wear.tiles.DeviceParametersBuilders.DeviceParameters);
method @Deprecated public androidx.wear.tiles.LayoutElementBuilders.FontStyle.Builder button();
- method public static androidx.wear.tiles.LayoutElementBuilders.FontStyle.Builder button(androidx.wear.tiles.readers.DeviceParametersReaders.DeviceParameters);
+ method public static androidx.wear.tiles.LayoutElementBuilders.FontStyle.Builder button(androidx.wear.tiles.DeviceParametersBuilders.DeviceParameters);
method @Deprecated public androidx.wear.tiles.LayoutElementBuilders.FontStyle.Builder caption1();
- method public static androidx.wear.tiles.LayoutElementBuilders.FontStyle.Builder caption1(androidx.wear.tiles.readers.DeviceParametersReaders.DeviceParameters);
+ method public static androidx.wear.tiles.LayoutElementBuilders.FontStyle.Builder caption1(androidx.wear.tiles.DeviceParametersBuilders.DeviceParameters);
method @Deprecated public androidx.wear.tiles.LayoutElementBuilders.FontStyle.Builder caption2();
- method public static androidx.wear.tiles.LayoutElementBuilders.FontStyle.Builder caption2(androidx.wear.tiles.readers.DeviceParametersReaders.DeviceParameters);
+ method public static androidx.wear.tiles.LayoutElementBuilders.FontStyle.Builder caption2(androidx.wear.tiles.DeviceParametersBuilders.DeviceParameters);
method @Deprecated public androidx.wear.tiles.LayoutElementBuilders.FontStyle.Builder display1();
- method public static androidx.wear.tiles.LayoutElementBuilders.FontStyle.Builder display1(androidx.wear.tiles.readers.DeviceParametersReaders.DeviceParameters);
+ method public static androidx.wear.tiles.LayoutElementBuilders.FontStyle.Builder display1(androidx.wear.tiles.DeviceParametersBuilders.DeviceParameters);
method @Deprecated public androidx.wear.tiles.LayoutElementBuilders.FontStyle.Builder display2();
- method public static androidx.wear.tiles.LayoutElementBuilders.FontStyle.Builder display2(androidx.wear.tiles.readers.DeviceParametersReaders.DeviceParameters);
+ method public static androidx.wear.tiles.LayoutElementBuilders.FontStyle.Builder display2(androidx.wear.tiles.DeviceParametersBuilders.DeviceParameters);
method @Deprecated public androidx.wear.tiles.LayoutElementBuilders.FontStyle.Builder display3();
- method public static androidx.wear.tiles.LayoutElementBuilders.FontStyle.Builder display3(androidx.wear.tiles.readers.DeviceParametersReaders.DeviceParameters);
+ method public static androidx.wear.tiles.LayoutElementBuilders.FontStyle.Builder display3(androidx.wear.tiles.DeviceParametersBuilders.DeviceParameters);
method @Deprecated public androidx.wear.tiles.LayoutElementBuilders.FontStyle.Builder title1();
- method public static androidx.wear.tiles.LayoutElementBuilders.FontStyle.Builder title1(androidx.wear.tiles.readers.DeviceParametersReaders.DeviceParameters);
+ method public static androidx.wear.tiles.LayoutElementBuilders.FontStyle.Builder title1(androidx.wear.tiles.DeviceParametersBuilders.DeviceParameters);
method @Deprecated public androidx.wear.tiles.LayoutElementBuilders.FontStyle.Builder title2();
- method public static androidx.wear.tiles.LayoutElementBuilders.FontStyle.Builder title2(androidx.wear.tiles.readers.DeviceParametersReaders.DeviceParameters);
+ method public static androidx.wear.tiles.LayoutElementBuilders.FontStyle.Builder title2(androidx.wear.tiles.DeviceParametersBuilders.DeviceParameters);
method @Deprecated public androidx.wear.tiles.LayoutElementBuilders.FontStyle.Builder title3();
- method public static androidx.wear.tiles.LayoutElementBuilders.FontStyle.Builder title3(androidx.wear.tiles.readers.DeviceParametersReaders.DeviceParameters);
- method @Deprecated public static androidx.wear.tiles.LayoutElementBuilders.FontStyles withDeviceParameters(androidx.wear.tiles.readers.DeviceParametersReaders.DeviceParameters);
+ method public static androidx.wear.tiles.LayoutElementBuilders.FontStyle.Builder title3(androidx.wear.tiles.DeviceParametersBuilders.DeviceParameters);
+ method @Deprecated public static androidx.wear.tiles.LayoutElementBuilders.FontStyles withDeviceParameters(androidx.wear.tiles.DeviceParametersBuilders.DeviceParameters);
}
public static final class LayoutElementBuilders.FontWeightProp {
@@ -870,6 +931,38 @@
method public androidx.wear.tiles.ModifiersBuilders.SpanModifiers.Builder setClickable(androidx.wear.tiles.ModifiersBuilders.Clickable.Builder);
}
+ public final class RequestBuilders {
+ }
+
+ public static final class RequestBuilders.ResourcesRequest {
+ method public static androidx.wear.tiles.RequestBuilders.ResourcesRequest.Builder builder();
+ method public androidx.wear.tiles.DeviceParametersBuilders.DeviceParameters? getDeviceParameters();
+ method public java.util.List<java.lang.String!> getResourceIds();
+ method public String getVersion();
+ }
+
+ public static final class RequestBuilders.ResourcesRequest.Builder {
+ method public androidx.wear.tiles.RequestBuilders.ResourcesRequest.Builder addResourceId(String);
+ method public androidx.wear.tiles.RequestBuilders.ResourcesRequest build();
+ method public androidx.wear.tiles.RequestBuilders.ResourcesRequest.Builder setDeviceParameters(androidx.wear.tiles.DeviceParametersBuilders.DeviceParameters);
+ method public androidx.wear.tiles.RequestBuilders.ResourcesRequest.Builder setDeviceParameters(androidx.wear.tiles.DeviceParametersBuilders.DeviceParameters.Builder);
+ method public androidx.wear.tiles.RequestBuilders.ResourcesRequest.Builder setVersion(String);
+ }
+
+ public static final class RequestBuilders.TileRequest {
+ method public static androidx.wear.tiles.RequestBuilders.TileRequest.Builder builder();
+ method public androidx.wear.tiles.DeviceParametersBuilders.DeviceParameters? getDeviceParameters();
+ method public androidx.wear.tiles.StateBuilders.State? getState();
+ }
+
+ public static final class RequestBuilders.TileRequest.Builder {
+ method public androidx.wear.tiles.RequestBuilders.TileRequest build();
+ method public androidx.wear.tiles.RequestBuilders.TileRequest.Builder setDeviceParameters(androidx.wear.tiles.DeviceParametersBuilders.DeviceParameters);
+ method public androidx.wear.tiles.RequestBuilders.TileRequest.Builder setDeviceParameters(androidx.wear.tiles.DeviceParametersBuilders.DeviceParameters.Builder);
+ method public androidx.wear.tiles.RequestBuilders.TileRequest.Builder setState(androidx.wear.tiles.StateBuilders.State);
+ method public androidx.wear.tiles.RequestBuilders.TileRequest.Builder setState(androidx.wear.tiles.StateBuilders.State.Builder);
+ }
+
public final class ResourceBuilders {
field public static final int IMAGE_FORMAT_RGB_565 = 1; // 0x1
field public static final int IMAGE_FORMAT_UNDEFINED = 0; // 0x0
@@ -962,12 +1055,12 @@
ctor public TileProviderService();
method public static androidx.wear.tiles.TileUpdateRequester getUpdater(android.content.Context);
method public android.os.IBinder? onBind(android.content.Intent);
- method @MainThread protected abstract com.google.common.util.concurrent.ListenableFuture<androidx.wear.tiles.ResourceBuilders.Resources!> onResourcesRequest(androidx.wear.tiles.readers.RequestReaders.ResourcesRequest);
- method @MainThread protected void onTileAddEvent(androidx.wear.tiles.readers.EventReaders.TileAddEvent);
- method @MainThread protected void onTileEnterEvent(androidx.wear.tiles.readers.EventReaders.TileEnterEvent);
- method @MainThread protected void onTileLeaveEvent(androidx.wear.tiles.readers.EventReaders.TileLeaveEvent);
- method @MainThread protected void onTileRemoveEvent(androidx.wear.tiles.readers.EventReaders.TileRemoveEvent);
- method @MainThread protected abstract com.google.common.util.concurrent.ListenableFuture<androidx.wear.tiles.TileBuilders.Tile!> onTileRequest(androidx.wear.tiles.readers.RequestReaders.TileRequest);
+ method @MainThread protected abstract com.google.common.util.concurrent.ListenableFuture<androidx.wear.tiles.ResourceBuilders.Resources!> onResourcesRequest(androidx.wear.tiles.RequestBuilders.ResourcesRequest);
+ method @MainThread protected void onTileAddEvent(androidx.wear.tiles.EventBuilders.TileAddEvent);
+ method @MainThread protected void onTileEnterEvent(androidx.wear.tiles.EventBuilders.TileEnterEvent);
+ method @MainThread protected void onTileLeaveEvent(androidx.wear.tiles.EventBuilders.TileLeaveEvent);
+ method @MainThread protected void onTileRemoveEvent(androidx.wear.tiles.EventBuilders.TileRemoveEvent);
+ method @MainThread protected abstract com.google.common.util.concurrent.ListenableFuture<androidx.wear.tiles.TileBuilders.Tile!> onTileRequest(androidx.wear.tiles.RequestBuilders.TileRequest);
field public static final String ACTION_BIND_TILE_PROVIDER = "androidx.wear.tiles.action.BIND_TILE_PROVIDER";
field public static final String EXTRA_CLICKABLE_ID = "androidx.wear.tiles.extra.CLICKABLE_ID";
field public static final String METADATA_PREVIEW_KEY = "androidx.wear.tiles.PREVIEW";
@@ -1062,52 +1155,3 @@
}
-package androidx.wear.tiles.readers {
-
- public class DeviceParametersReaders {
- field public static final int DEVICE_PLATFORM_UNDEFINED = 0; // 0x0
- field public static final int DEVICE_PLATFORM_WEAR_OS = 1; // 0x1
- field public static final int SCREEN_SHAPE_RECT = 2; // 0x2
- field public static final int SCREEN_SHAPE_ROUND = 1; // 0x1
- field public static final int SCREEN_SHAPE_UNDEFINED = 0; // 0x0
- }
-
- public static class DeviceParametersReaders.DeviceParameters {
- method public int getDevicePlatform();
- method @FloatRange(from=0.0, fromInclusive=false) public float getScreenDensity();
- method @Dimension(unit=androidx.annotation.Dimension.DP) public int getScreenHeightDp();
- method public int getScreenShape();
- method @Dimension(unit=androidx.annotation.Dimension.DP) public int getScreenWidthDp();
- }
-
- public class EventReaders {
- }
-
- public static class EventReaders.TileAddEvent {
- }
-
- public static class EventReaders.TileEnterEvent {
- }
-
- public static class EventReaders.TileLeaveEvent {
- }
-
- public static class EventReaders.TileRemoveEvent {
- }
-
- public class RequestReaders {
- }
-
- public static class RequestReaders.ResourcesRequest {
- method public androidx.wear.tiles.readers.DeviceParametersReaders.DeviceParameters getDeviceParameters();
- method public java.util.List<java.lang.String!> getResourceIds();
- method public String getVersion();
- }
-
- public static class RequestReaders.TileRequest {
- method public androidx.wear.tiles.readers.DeviceParametersReaders.DeviceParameters getDeviceParameters();
- method public androidx.wear.tiles.StateBuilders.State getState();
- }
-
-}
-
diff --git a/wear/tiles/tiles/api/public_plus_experimental_current.txt b/wear/tiles/tiles/api/public_plus_experimental_current.txt
index 5688279..80d61ee 100644
--- a/wear/tiles/tiles/api/public_plus_experimental_current.txt
+++ b/wear/tiles/tiles/api/public_plus_experimental_current.txt
@@ -124,6 +124,32 @@
method public androidx.wear.tiles.ColorBuilders.ColorProp.Builder setArgb(@ColorInt int);
}
+ public final class DeviceParametersBuilders {
+ field public static final int DEVICE_PLATFORM_UNDEFINED = 0; // 0x0
+ field public static final int DEVICE_PLATFORM_WEAR_OS = 1; // 0x1
+ field public static final int SCREEN_SHAPE_RECT = 2; // 0x2
+ field public static final int SCREEN_SHAPE_ROUND = 1; // 0x1
+ field public static final int SCREEN_SHAPE_UNDEFINED = 0; // 0x0
+ }
+
+ public static final class DeviceParametersBuilders.DeviceParameters {
+ method public static androidx.wear.tiles.DeviceParametersBuilders.DeviceParameters.Builder builder();
+ method public int getDevicePlatform();
+ method @FloatRange(from=0.0, fromInclusive=false, toInclusive=false) public float getScreenDensity();
+ method @Dimension(unit=androidx.annotation.Dimension.DP) public int getScreenHeightDp();
+ method public int getScreenShape();
+ method @Dimension(unit=androidx.annotation.Dimension.DP) public int getScreenWidthDp();
+ }
+
+ public static final class DeviceParametersBuilders.DeviceParameters.Builder {
+ method public androidx.wear.tiles.DeviceParametersBuilders.DeviceParameters build();
+ method public androidx.wear.tiles.DeviceParametersBuilders.DeviceParameters.Builder setDevicePlatform(int);
+ method public androidx.wear.tiles.DeviceParametersBuilders.DeviceParameters.Builder setScreenDensity(@FloatRange(from=0.0, fromInclusive=false, toInclusive=false) float);
+ method public androidx.wear.tiles.DeviceParametersBuilders.DeviceParameters.Builder setScreenHeightDp(@Dimension(unit=androidx.annotation.Dimension.DP) int);
+ method public androidx.wear.tiles.DeviceParametersBuilders.DeviceParameters.Builder setScreenShape(int);
+ method public androidx.wear.tiles.DeviceParametersBuilders.DeviceParameters.Builder setScreenWidthDp(@Dimension(unit=androidx.annotation.Dimension.DP) int);
+ }
+
public final class DimensionBuilders {
method public static androidx.wear.tiles.DimensionBuilders.DegreesProp degrees(float);
method public static androidx.wear.tiles.DimensionBuilders.DpProp dp(@Dimension(unit=androidx.annotation.Dimension.DP) float);
@@ -222,6 +248,41 @@
method public androidx.wear.tiles.DimensionBuilders.WrappedDimensionProp build();
}
+ public final class EventBuilders {
+ }
+
+ public static final class EventBuilders.TileAddEvent {
+ method public static androidx.wear.tiles.EventBuilders.TileAddEvent.Builder builder();
+ }
+
+ public static final class EventBuilders.TileAddEvent.Builder {
+ method public androidx.wear.tiles.EventBuilders.TileAddEvent build();
+ }
+
+ public static final class EventBuilders.TileEnterEvent {
+ method public static androidx.wear.tiles.EventBuilders.TileEnterEvent.Builder builder();
+ }
+
+ public static final class EventBuilders.TileEnterEvent.Builder {
+ method public androidx.wear.tiles.EventBuilders.TileEnterEvent build();
+ }
+
+ public static final class EventBuilders.TileLeaveEvent {
+ method public static androidx.wear.tiles.EventBuilders.TileLeaveEvent.Builder builder();
+ }
+
+ public static final class EventBuilders.TileLeaveEvent.Builder {
+ method public androidx.wear.tiles.EventBuilders.TileLeaveEvent build();
+ }
+
+ public static final class EventBuilders.TileRemoveEvent {
+ method public static androidx.wear.tiles.EventBuilders.TileRemoveEvent.Builder builder();
+ }
+
+ public static final class EventBuilders.TileRemoveEvent.Builder {
+ method public androidx.wear.tiles.EventBuilders.TileRemoveEvent build();
+ }
+
public final class LayoutElementBuilders {
field public static final int ARC_ANCHOR_CENTER = 2; // 0x2
field public static final int ARC_ANCHOR_END = 3; // 0x3
@@ -469,28 +530,28 @@
public static class LayoutElementBuilders.FontStyles {
method @Deprecated public androidx.wear.tiles.LayoutElementBuilders.FontStyle.Builder body1();
- method public static androidx.wear.tiles.LayoutElementBuilders.FontStyle.Builder body1(androidx.wear.tiles.readers.DeviceParametersReaders.DeviceParameters);
+ method public static androidx.wear.tiles.LayoutElementBuilders.FontStyle.Builder body1(androidx.wear.tiles.DeviceParametersBuilders.DeviceParameters);
method @Deprecated public androidx.wear.tiles.LayoutElementBuilders.FontStyle.Builder body2();
- method public static androidx.wear.tiles.LayoutElementBuilders.FontStyle.Builder body2(androidx.wear.tiles.readers.DeviceParametersReaders.DeviceParameters);
+ method public static androidx.wear.tiles.LayoutElementBuilders.FontStyle.Builder body2(androidx.wear.tiles.DeviceParametersBuilders.DeviceParameters);
method @Deprecated public androidx.wear.tiles.LayoutElementBuilders.FontStyle.Builder button();
- method public static androidx.wear.tiles.LayoutElementBuilders.FontStyle.Builder button(androidx.wear.tiles.readers.DeviceParametersReaders.DeviceParameters);
+ method public static androidx.wear.tiles.LayoutElementBuilders.FontStyle.Builder button(androidx.wear.tiles.DeviceParametersBuilders.DeviceParameters);
method @Deprecated public androidx.wear.tiles.LayoutElementBuilders.FontStyle.Builder caption1();
- method public static androidx.wear.tiles.LayoutElementBuilders.FontStyle.Builder caption1(androidx.wear.tiles.readers.DeviceParametersReaders.DeviceParameters);
+ method public static androidx.wear.tiles.LayoutElementBuilders.FontStyle.Builder caption1(androidx.wear.tiles.DeviceParametersBuilders.DeviceParameters);
method @Deprecated public androidx.wear.tiles.LayoutElementBuilders.FontStyle.Builder caption2();
- method public static androidx.wear.tiles.LayoutElementBuilders.FontStyle.Builder caption2(androidx.wear.tiles.readers.DeviceParametersReaders.DeviceParameters);
+ method public static androidx.wear.tiles.LayoutElementBuilders.FontStyle.Builder caption2(androidx.wear.tiles.DeviceParametersBuilders.DeviceParameters);
method @Deprecated public androidx.wear.tiles.LayoutElementBuilders.FontStyle.Builder display1();
- method public static androidx.wear.tiles.LayoutElementBuilders.FontStyle.Builder display1(androidx.wear.tiles.readers.DeviceParametersReaders.DeviceParameters);
+ method public static androidx.wear.tiles.LayoutElementBuilders.FontStyle.Builder display1(androidx.wear.tiles.DeviceParametersBuilders.DeviceParameters);
method @Deprecated public androidx.wear.tiles.LayoutElementBuilders.FontStyle.Builder display2();
- method public static androidx.wear.tiles.LayoutElementBuilders.FontStyle.Builder display2(androidx.wear.tiles.readers.DeviceParametersReaders.DeviceParameters);
+ method public static androidx.wear.tiles.LayoutElementBuilders.FontStyle.Builder display2(androidx.wear.tiles.DeviceParametersBuilders.DeviceParameters);
method @Deprecated public androidx.wear.tiles.LayoutElementBuilders.FontStyle.Builder display3();
- method public static androidx.wear.tiles.LayoutElementBuilders.FontStyle.Builder display3(androidx.wear.tiles.readers.DeviceParametersReaders.DeviceParameters);
+ method public static androidx.wear.tiles.LayoutElementBuilders.FontStyle.Builder display3(androidx.wear.tiles.DeviceParametersBuilders.DeviceParameters);
method @Deprecated public androidx.wear.tiles.LayoutElementBuilders.FontStyle.Builder title1();
- method public static androidx.wear.tiles.LayoutElementBuilders.FontStyle.Builder title1(androidx.wear.tiles.readers.DeviceParametersReaders.DeviceParameters);
+ method public static androidx.wear.tiles.LayoutElementBuilders.FontStyle.Builder title1(androidx.wear.tiles.DeviceParametersBuilders.DeviceParameters);
method @Deprecated public androidx.wear.tiles.LayoutElementBuilders.FontStyle.Builder title2();
- method public static androidx.wear.tiles.LayoutElementBuilders.FontStyle.Builder title2(androidx.wear.tiles.readers.DeviceParametersReaders.DeviceParameters);
+ method public static androidx.wear.tiles.LayoutElementBuilders.FontStyle.Builder title2(androidx.wear.tiles.DeviceParametersBuilders.DeviceParameters);
method @Deprecated public androidx.wear.tiles.LayoutElementBuilders.FontStyle.Builder title3();
- method public static androidx.wear.tiles.LayoutElementBuilders.FontStyle.Builder title3(androidx.wear.tiles.readers.DeviceParametersReaders.DeviceParameters);
- method @Deprecated public static androidx.wear.tiles.LayoutElementBuilders.FontStyles withDeviceParameters(androidx.wear.tiles.readers.DeviceParametersReaders.DeviceParameters);
+ method public static androidx.wear.tiles.LayoutElementBuilders.FontStyle.Builder title3(androidx.wear.tiles.DeviceParametersBuilders.DeviceParameters);
+ method @Deprecated public static androidx.wear.tiles.LayoutElementBuilders.FontStyles withDeviceParameters(androidx.wear.tiles.DeviceParametersBuilders.DeviceParameters);
}
@androidx.wear.tiles.TilesExperimental public static final class LayoutElementBuilders.FontVariantProp {
@@ -887,6 +948,38 @@
method public androidx.wear.tiles.ModifiersBuilders.SpanModifiers.Builder setClickable(androidx.wear.tiles.ModifiersBuilders.Clickable.Builder);
}
+ public final class RequestBuilders {
+ }
+
+ public static final class RequestBuilders.ResourcesRequest {
+ method public static androidx.wear.tiles.RequestBuilders.ResourcesRequest.Builder builder();
+ method public androidx.wear.tiles.DeviceParametersBuilders.DeviceParameters? getDeviceParameters();
+ method public java.util.List<java.lang.String!> getResourceIds();
+ method public String getVersion();
+ }
+
+ public static final class RequestBuilders.ResourcesRequest.Builder {
+ method public androidx.wear.tiles.RequestBuilders.ResourcesRequest.Builder addResourceId(String);
+ method public androidx.wear.tiles.RequestBuilders.ResourcesRequest build();
+ method public androidx.wear.tiles.RequestBuilders.ResourcesRequest.Builder setDeviceParameters(androidx.wear.tiles.DeviceParametersBuilders.DeviceParameters);
+ method public androidx.wear.tiles.RequestBuilders.ResourcesRequest.Builder setDeviceParameters(androidx.wear.tiles.DeviceParametersBuilders.DeviceParameters.Builder);
+ method public androidx.wear.tiles.RequestBuilders.ResourcesRequest.Builder setVersion(String);
+ }
+
+ public static final class RequestBuilders.TileRequest {
+ method public static androidx.wear.tiles.RequestBuilders.TileRequest.Builder builder();
+ method public androidx.wear.tiles.DeviceParametersBuilders.DeviceParameters? getDeviceParameters();
+ method public androidx.wear.tiles.StateBuilders.State? getState();
+ }
+
+ public static final class RequestBuilders.TileRequest.Builder {
+ method public androidx.wear.tiles.RequestBuilders.TileRequest build();
+ method public androidx.wear.tiles.RequestBuilders.TileRequest.Builder setDeviceParameters(androidx.wear.tiles.DeviceParametersBuilders.DeviceParameters);
+ method public androidx.wear.tiles.RequestBuilders.TileRequest.Builder setDeviceParameters(androidx.wear.tiles.DeviceParametersBuilders.DeviceParameters.Builder);
+ method public androidx.wear.tiles.RequestBuilders.TileRequest.Builder setState(androidx.wear.tiles.StateBuilders.State);
+ method public androidx.wear.tiles.RequestBuilders.TileRequest.Builder setState(androidx.wear.tiles.StateBuilders.State.Builder);
+ }
+
public final class ResourceBuilders {
field public static final int IMAGE_FORMAT_RGB_565 = 1; // 0x1
field public static final int IMAGE_FORMAT_UNDEFINED = 0; // 0x0
@@ -979,12 +1072,12 @@
ctor public TileProviderService();
method public static androidx.wear.tiles.TileUpdateRequester getUpdater(android.content.Context);
method public android.os.IBinder? onBind(android.content.Intent);
- method @MainThread protected abstract com.google.common.util.concurrent.ListenableFuture<androidx.wear.tiles.ResourceBuilders.Resources!> onResourcesRequest(androidx.wear.tiles.readers.RequestReaders.ResourcesRequest);
- method @MainThread protected void onTileAddEvent(androidx.wear.tiles.readers.EventReaders.TileAddEvent);
- method @MainThread protected void onTileEnterEvent(androidx.wear.tiles.readers.EventReaders.TileEnterEvent);
- method @MainThread protected void onTileLeaveEvent(androidx.wear.tiles.readers.EventReaders.TileLeaveEvent);
- method @MainThread protected void onTileRemoveEvent(androidx.wear.tiles.readers.EventReaders.TileRemoveEvent);
- method @MainThread protected abstract com.google.common.util.concurrent.ListenableFuture<androidx.wear.tiles.TileBuilders.Tile!> onTileRequest(androidx.wear.tiles.readers.RequestReaders.TileRequest);
+ method @MainThread protected abstract com.google.common.util.concurrent.ListenableFuture<androidx.wear.tiles.ResourceBuilders.Resources!> onResourcesRequest(androidx.wear.tiles.RequestBuilders.ResourcesRequest);
+ method @MainThread protected void onTileAddEvent(androidx.wear.tiles.EventBuilders.TileAddEvent);
+ method @MainThread protected void onTileEnterEvent(androidx.wear.tiles.EventBuilders.TileEnterEvent);
+ method @MainThread protected void onTileLeaveEvent(androidx.wear.tiles.EventBuilders.TileLeaveEvent);
+ method @MainThread protected void onTileRemoveEvent(androidx.wear.tiles.EventBuilders.TileRemoveEvent);
+ method @MainThread protected abstract com.google.common.util.concurrent.ListenableFuture<androidx.wear.tiles.TileBuilders.Tile!> onTileRequest(androidx.wear.tiles.RequestBuilders.TileRequest);
field public static final String ACTION_BIND_TILE_PROVIDER = "androidx.wear.tiles.action.BIND_TILE_PROVIDER";
field public static final String EXTRA_CLICKABLE_ID = "androidx.wear.tiles.extra.CLICKABLE_ID";
field public static final String METADATA_PREVIEW_KEY = "androidx.wear.tiles.PREVIEW";
@@ -1082,52 +1175,3 @@
}
-package androidx.wear.tiles.readers {
-
- public class DeviceParametersReaders {
- field public static final int DEVICE_PLATFORM_UNDEFINED = 0; // 0x0
- field public static final int DEVICE_PLATFORM_WEAR_OS = 1; // 0x1
- field public static final int SCREEN_SHAPE_RECT = 2; // 0x2
- field public static final int SCREEN_SHAPE_ROUND = 1; // 0x1
- field public static final int SCREEN_SHAPE_UNDEFINED = 0; // 0x0
- }
-
- public static class DeviceParametersReaders.DeviceParameters {
- method public int getDevicePlatform();
- method @FloatRange(from=0.0, fromInclusive=false) public float getScreenDensity();
- method @Dimension(unit=androidx.annotation.Dimension.DP) public int getScreenHeightDp();
- method public int getScreenShape();
- method @Dimension(unit=androidx.annotation.Dimension.DP) public int getScreenWidthDp();
- }
-
- public class EventReaders {
- }
-
- public static class EventReaders.TileAddEvent {
- }
-
- public static class EventReaders.TileEnterEvent {
- }
-
- public static class EventReaders.TileLeaveEvent {
- }
-
- public static class EventReaders.TileRemoveEvent {
- }
-
- public class RequestReaders {
- }
-
- public static class RequestReaders.ResourcesRequest {
- method public androidx.wear.tiles.readers.DeviceParametersReaders.DeviceParameters getDeviceParameters();
- method public java.util.List<java.lang.String!> getResourceIds();
- method public String getVersion();
- }
-
- public static class RequestReaders.TileRequest {
- method public androidx.wear.tiles.readers.DeviceParametersReaders.DeviceParameters getDeviceParameters();
- method public androidx.wear.tiles.StateBuilders.State getState();
- }
-
-}
-
diff --git a/wear/tiles/tiles/api/restricted_current.txt b/wear/tiles/tiles/api/restricted_current.txt
index 4209662..1d82943 100644
--- a/wear/tiles/tiles/api/restricted_current.txt
+++ b/wear/tiles/tiles/api/restricted_current.txt
@@ -124,6 +124,32 @@
method public androidx.wear.tiles.ColorBuilders.ColorProp.Builder setArgb(@ColorInt int);
}
+ public final class DeviceParametersBuilders {
+ field public static final int DEVICE_PLATFORM_UNDEFINED = 0; // 0x0
+ field public static final int DEVICE_PLATFORM_WEAR_OS = 1; // 0x1
+ field public static final int SCREEN_SHAPE_RECT = 2; // 0x2
+ field public static final int SCREEN_SHAPE_ROUND = 1; // 0x1
+ field public static final int SCREEN_SHAPE_UNDEFINED = 0; // 0x0
+ }
+
+ public static final class DeviceParametersBuilders.DeviceParameters {
+ method public static androidx.wear.tiles.DeviceParametersBuilders.DeviceParameters.Builder builder();
+ method public int getDevicePlatform();
+ method @FloatRange(from=0.0, fromInclusive=false, toInclusive=false) public float getScreenDensity();
+ method @Dimension(unit=androidx.annotation.Dimension.DP) public int getScreenHeightDp();
+ method public int getScreenShape();
+ method @Dimension(unit=androidx.annotation.Dimension.DP) public int getScreenWidthDp();
+ }
+
+ public static final class DeviceParametersBuilders.DeviceParameters.Builder {
+ method public androidx.wear.tiles.DeviceParametersBuilders.DeviceParameters build();
+ method public androidx.wear.tiles.DeviceParametersBuilders.DeviceParameters.Builder setDevicePlatform(int);
+ method public androidx.wear.tiles.DeviceParametersBuilders.DeviceParameters.Builder setScreenDensity(@FloatRange(from=0.0, fromInclusive=false, toInclusive=false) float);
+ method public androidx.wear.tiles.DeviceParametersBuilders.DeviceParameters.Builder setScreenHeightDp(@Dimension(unit=androidx.annotation.Dimension.DP) int);
+ method public androidx.wear.tiles.DeviceParametersBuilders.DeviceParameters.Builder setScreenShape(int);
+ method public androidx.wear.tiles.DeviceParametersBuilders.DeviceParameters.Builder setScreenWidthDp(@Dimension(unit=androidx.annotation.Dimension.DP) int);
+ }
+
public final class DimensionBuilders {
method public static androidx.wear.tiles.DimensionBuilders.DegreesProp degrees(float);
method public static androidx.wear.tiles.DimensionBuilders.DpProp dp(@Dimension(unit=androidx.annotation.Dimension.DP) float);
@@ -222,6 +248,41 @@
method public androidx.wear.tiles.DimensionBuilders.WrappedDimensionProp build();
}
+ public final class EventBuilders {
+ }
+
+ public static final class EventBuilders.TileAddEvent {
+ method public static androidx.wear.tiles.EventBuilders.TileAddEvent.Builder builder();
+ }
+
+ public static final class EventBuilders.TileAddEvent.Builder {
+ method public androidx.wear.tiles.EventBuilders.TileAddEvent build();
+ }
+
+ public static final class EventBuilders.TileEnterEvent {
+ method public static androidx.wear.tiles.EventBuilders.TileEnterEvent.Builder builder();
+ }
+
+ public static final class EventBuilders.TileEnterEvent.Builder {
+ method public androidx.wear.tiles.EventBuilders.TileEnterEvent build();
+ }
+
+ public static final class EventBuilders.TileLeaveEvent {
+ method public static androidx.wear.tiles.EventBuilders.TileLeaveEvent.Builder builder();
+ }
+
+ public static final class EventBuilders.TileLeaveEvent.Builder {
+ method public androidx.wear.tiles.EventBuilders.TileLeaveEvent build();
+ }
+
+ public static final class EventBuilders.TileRemoveEvent {
+ method public static androidx.wear.tiles.EventBuilders.TileRemoveEvent.Builder builder();
+ }
+
+ public static final class EventBuilders.TileRemoveEvent.Builder {
+ method public androidx.wear.tiles.EventBuilders.TileRemoveEvent build();
+ }
+
public final class LayoutElementBuilders {
field public static final int ARC_ANCHOR_CENTER = 2; // 0x2
field public static final int ARC_ANCHOR_END = 3; // 0x3
@@ -465,28 +526,28 @@
public static class LayoutElementBuilders.FontStyles {
method @Deprecated public androidx.wear.tiles.LayoutElementBuilders.FontStyle.Builder body1();
- method public static androidx.wear.tiles.LayoutElementBuilders.FontStyle.Builder body1(androidx.wear.tiles.readers.DeviceParametersReaders.DeviceParameters);
+ method public static androidx.wear.tiles.LayoutElementBuilders.FontStyle.Builder body1(androidx.wear.tiles.DeviceParametersBuilders.DeviceParameters);
method @Deprecated public androidx.wear.tiles.LayoutElementBuilders.FontStyle.Builder body2();
- method public static androidx.wear.tiles.LayoutElementBuilders.FontStyle.Builder body2(androidx.wear.tiles.readers.DeviceParametersReaders.DeviceParameters);
+ method public static androidx.wear.tiles.LayoutElementBuilders.FontStyle.Builder body2(androidx.wear.tiles.DeviceParametersBuilders.DeviceParameters);
method @Deprecated public androidx.wear.tiles.LayoutElementBuilders.FontStyle.Builder button();
- method public static androidx.wear.tiles.LayoutElementBuilders.FontStyle.Builder button(androidx.wear.tiles.readers.DeviceParametersReaders.DeviceParameters);
+ method public static androidx.wear.tiles.LayoutElementBuilders.FontStyle.Builder button(androidx.wear.tiles.DeviceParametersBuilders.DeviceParameters);
method @Deprecated public androidx.wear.tiles.LayoutElementBuilders.FontStyle.Builder caption1();
- method public static androidx.wear.tiles.LayoutElementBuilders.FontStyle.Builder caption1(androidx.wear.tiles.readers.DeviceParametersReaders.DeviceParameters);
+ method public static androidx.wear.tiles.LayoutElementBuilders.FontStyle.Builder caption1(androidx.wear.tiles.DeviceParametersBuilders.DeviceParameters);
method @Deprecated public androidx.wear.tiles.LayoutElementBuilders.FontStyle.Builder caption2();
- method public static androidx.wear.tiles.LayoutElementBuilders.FontStyle.Builder caption2(androidx.wear.tiles.readers.DeviceParametersReaders.DeviceParameters);
+ method public static androidx.wear.tiles.LayoutElementBuilders.FontStyle.Builder caption2(androidx.wear.tiles.DeviceParametersBuilders.DeviceParameters);
method @Deprecated public androidx.wear.tiles.LayoutElementBuilders.FontStyle.Builder display1();
- method public static androidx.wear.tiles.LayoutElementBuilders.FontStyle.Builder display1(androidx.wear.tiles.readers.DeviceParametersReaders.DeviceParameters);
+ method public static androidx.wear.tiles.LayoutElementBuilders.FontStyle.Builder display1(androidx.wear.tiles.DeviceParametersBuilders.DeviceParameters);
method @Deprecated public androidx.wear.tiles.LayoutElementBuilders.FontStyle.Builder display2();
- method public static androidx.wear.tiles.LayoutElementBuilders.FontStyle.Builder display2(androidx.wear.tiles.readers.DeviceParametersReaders.DeviceParameters);
+ method public static androidx.wear.tiles.LayoutElementBuilders.FontStyle.Builder display2(androidx.wear.tiles.DeviceParametersBuilders.DeviceParameters);
method @Deprecated public androidx.wear.tiles.LayoutElementBuilders.FontStyle.Builder display3();
- method public static androidx.wear.tiles.LayoutElementBuilders.FontStyle.Builder display3(androidx.wear.tiles.readers.DeviceParametersReaders.DeviceParameters);
+ method public static androidx.wear.tiles.LayoutElementBuilders.FontStyle.Builder display3(androidx.wear.tiles.DeviceParametersBuilders.DeviceParameters);
method @Deprecated public androidx.wear.tiles.LayoutElementBuilders.FontStyle.Builder title1();
- method public static androidx.wear.tiles.LayoutElementBuilders.FontStyle.Builder title1(androidx.wear.tiles.readers.DeviceParametersReaders.DeviceParameters);
+ method public static androidx.wear.tiles.LayoutElementBuilders.FontStyle.Builder title1(androidx.wear.tiles.DeviceParametersBuilders.DeviceParameters);
method @Deprecated public androidx.wear.tiles.LayoutElementBuilders.FontStyle.Builder title2();
- method public static androidx.wear.tiles.LayoutElementBuilders.FontStyle.Builder title2(androidx.wear.tiles.readers.DeviceParametersReaders.DeviceParameters);
+ method public static androidx.wear.tiles.LayoutElementBuilders.FontStyle.Builder title2(androidx.wear.tiles.DeviceParametersBuilders.DeviceParameters);
method @Deprecated public androidx.wear.tiles.LayoutElementBuilders.FontStyle.Builder title3();
- method public static androidx.wear.tiles.LayoutElementBuilders.FontStyle.Builder title3(androidx.wear.tiles.readers.DeviceParametersReaders.DeviceParameters);
- method @Deprecated public static androidx.wear.tiles.LayoutElementBuilders.FontStyles withDeviceParameters(androidx.wear.tiles.readers.DeviceParametersReaders.DeviceParameters);
+ method public static androidx.wear.tiles.LayoutElementBuilders.FontStyle.Builder title3(androidx.wear.tiles.DeviceParametersBuilders.DeviceParameters);
+ method @Deprecated public static androidx.wear.tiles.LayoutElementBuilders.FontStyles withDeviceParameters(androidx.wear.tiles.DeviceParametersBuilders.DeviceParameters);
}
public static final class LayoutElementBuilders.FontWeightProp {
@@ -870,6 +931,38 @@
method public androidx.wear.tiles.ModifiersBuilders.SpanModifiers.Builder setClickable(androidx.wear.tiles.ModifiersBuilders.Clickable.Builder);
}
+ public final class RequestBuilders {
+ }
+
+ public static final class RequestBuilders.ResourcesRequest {
+ method public static androidx.wear.tiles.RequestBuilders.ResourcesRequest.Builder builder();
+ method public androidx.wear.tiles.DeviceParametersBuilders.DeviceParameters? getDeviceParameters();
+ method public java.util.List<java.lang.String!> getResourceIds();
+ method public String getVersion();
+ }
+
+ public static final class RequestBuilders.ResourcesRequest.Builder {
+ method public androidx.wear.tiles.RequestBuilders.ResourcesRequest.Builder addResourceId(String);
+ method public androidx.wear.tiles.RequestBuilders.ResourcesRequest build();
+ method public androidx.wear.tiles.RequestBuilders.ResourcesRequest.Builder setDeviceParameters(androidx.wear.tiles.DeviceParametersBuilders.DeviceParameters);
+ method public androidx.wear.tiles.RequestBuilders.ResourcesRequest.Builder setDeviceParameters(androidx.wear.tiles.DeviceParametersBuilders.DeviceParameters.Builder);
+ method public androidx.wear.tiles.RequestBuilders.ResourcesRequest.Builder setVersion(String);
+ }
+
+ public static final class RequestBuilders.TileRequest {
+ method public static androidx.wear.tiles.RequestBuilders.TileRequest.Builder builder();
+ method public androidx.wear.tiles.DeviceParametersBuilders.DeviceParameters? getDeviceParameters();
+ method public androidx.wear.tiles.StateBuilders.State? getState();
+ }
+
+ public static final class RequestBuilders.TileRequest.Builder {
+ method public androidx.wear.tiles.RequestBuilders.TileRequest build();
+ method public androidx.wear.tiles.RequestBuilders.TileRequest.Builder setDeviceParameters(androidx.wear.tiles.DeviceParametersBuilders.DeviceParameters);
+ method public androidx.wear.tiles.RequestBuilders.TileRequest.Builder setDeviceParameters(androidx.wear.tiles.DeviceParametersBuilders.DeviceParameters.Builder);
+ method public androidx.wear.tiles.RequestBuilders.TileRequest.Builder setState(androidx.wear.tiles.StateBuilders.State);
+ method public androidx.wear.tiles.RequestBuilders.TileRequest.Builder setState(androidx.wear.tiles.StateBuilders.State.Builder);
+ }
+
public final class ResourceBuilders {
field public static final int IMAGE_FORMAT_RGB_565 = 1; // 0x1
field public static final int IMAGE_FORMAT_UNDEFINED = 0; // 0x0
@@ -962,12 +1055,12 @@
ctor public TileProviderService();
method public static androidx.wear.tiles.TileUpdateRequester getUpdater(android.content.Context);
method public android.os.IBinder? onBind(android.content.Intent);
- method @MainThread protected abstract com.google.common.util.concurrent.ListenableFuture<androidx.wear.tiles.ResourceBuilders.Resources!> onResourcesRequest(androidx.wear.tiles.readers.RequestReaders.ResourcesRequest);
- method @MainThread protected void onTileAddEvent(androidx.wear.tiles.readers.EventReaders.TileAddEvent);
- method @MainThread protected void onTileEnterEvent(androidx.wear.tiles.readers.EventReaders.TileEnterEvent);
- method @MainThread protected void onTileLeaveEvent(androidx.wear.tiles.readers.EventReaders.TileLeaveEvent);
- method @MainThread protected void onTileRemoveEvent(androidx.wear.tiles.readers.EventReaders.TileRemoveEvent);
- method @MainThread protected abstract com.google.common.util.concurrent.ListenableFuture<androidx.wear.tiles.TileBuilders.Tile!> onTileRequest(androidx.wear.tiles.readers.RequestReaders.TileRequest);
+ method @MainThread protected abstract com.google.common.util.concurrent.ListenableFuture<androidx.wear.tiles.ResourceBuilders.Resources!> onResourcesRequest(androidx.wear.tiles.RequestBuilders.ResourcesRequest);
+ method @MainThread protected void onTileAddEvent(androidx.wear.tiles.EventBuilders.TileAddEvent);
+ method @MainThread protected void onTileEnterEvent(androidx.wear.tiles.EventBuilders.TileEnterEvent);
+ method @MainThread protected void onTileLeaveEvent(androidx.wear.tiles.EventBuilders.TileLeaveEvent);
+ method @MainThread protected void onTileRemoveEvent(androidx.wear.tiles.EventBuilders.TileRemoveEvent);
+ method @MainThread protected abstract com.google.common.util.concurrent.ListenableFuture<androidx.wear.tiles.TileBuilders.Tile!> onTileRequest(androidx.wear.tiles.RequestBuilders.TileRequest);
field public static final String ACTION_BIND_TILE_PROVIDER = "androidx.wear.tiles.action.BIND_TILE_PROVIDER";
field public static final String EXTRA_CLICKABLE_ID = "androidx.wear.tiles.extra.CLICKABLE_ID";
field public static final String METADATA_PREVIEW_KEY = "androidx.wear.tiles.PREVIEW";
@@ -1062,52 +1155,3 @@
}
-package androidx.wear.tiles.readers {
-
- public class DeviceParametersReaders {
- field public static final int DEVICE_PLATFORM_UNDEFINED = 0; // 0x0
- field public static final int DEVICE_PLATFORM_WEAR_OS = 1; // 0x1
- field public static final int SCREEN_SHAPE_RECT = 2; // 0x2
- field public static final int SCREEN_SHAPE_ROUND = 1; // 0x1
- field public static final int SCREEN_SHAPE_UNDEFINED = 0; // 0x0
- }
-
- public static class DeviceParametersReaders.DeviceParameters {
- method public int getDevicePlatform();
- method @FloatRange(from=0.0, fromInclusive=false) public float getScreenDensity();
- method @Dimension(unit=androidx.annotation.Dimension.DP) public int getScreenHeightDp();
- method public int getScreenShape();
- method @Dimension(unit=androidx.annotation.Dimension.DP) public int getScreenWidthDp();
- }
-
- public class EventReaders {
- }
-
- public static class EventReaders.TileAddEvent {
- }
-
- public static class EventReaders.TileEnterEvent {
- }
-
- public static class EventReaders.TileLeaveEvent {
- }
-
- public static class EventReaders.TileRemoveEvent {
- }
-
- public class RequestReaders {
- }
-
- public static class RequestReaders.ResourcesRequest {
- method public androidx.wear.tiles.readers.DeviceParametersReaders.DeviceParameters getDeviceParameters();
- method public java.util.List<java.lang.String!> getResourceIds();
- method public String getVersion();
- }
-
- public static class RequestReaders.TileRequest {
- method public androidx.wear.tiles.readers.DeviceParametersReaders.DeviceParameters getDeviceParameters();
- method public androidx.wear.tiles.StateBuilders.State getState();
- }
-
-}
-
diff --git a/wear/tiles/tiles/src/main/java/androidx/wear/tiles/ActionBuilders.java b/wear/tiles/tiles/src/main/java/androidx/wear/tiles/ActionBuilders.java
index ac7dd67..1aa8fbb 100644
--- a/wear/tiles/tiles/src/main/java/androidx/wear/tiles/ActionBuilders.java
+++ b/wear/tiles/tiles/src/main/java/androidx/wear/tiles/ActionBuilders.java
@@ -631,9 +631,10 @@
}
/**
- * Gets the state to load the next tile with. This will be included in the TileRequest sent
- * after this action is invoked by a {@link
- * androidx.wear.tiles.ModifiersBuilders.Clickable}. Intended for testing purposes only.
+ * Gets the state to load the next tile with. This will be included in the {@link
+ * androidx.wear.tiles.RequestBuilders.TileRequest} sent after this action is invoked by a
+ * {@link androidx.wear.tiles.ModifiersBuilders.Clickable}. Intended for testing purposes
+ * only.
*/
@Nullable
public State getRequestState() {
@@ -680,9 +681,9 @@
Builder() {}
/**
- * Sets the state to load the next tile with. This will be included in the TileRequest
- * sent after this action is invoked by a {@link
- * androidx.wear.tiles.ModifiersBuilders.Clickable}.
+ * Sets the state to load the next tile with. This will be included in the {@link
+ * androidx.wear.tiles.RequestBuilders.TileRequest} sent after this action is invoked by
+ * a {@link androidx.wear.tiles.ModifiersBuilders.Clickable}.
*/
@NonNull
public Builder setRequestState(@NonNull State requestState) {
@@ -691,9 +692,9 @@
}
/**
- * Sets the state to load the next tile with. This will be included in the TileRequest
- * sent after this action is invoked by a {@link
- * androidx.wear.tiles.ModifiersBuilders.Clickable}.
+ * Sets the state to load the next tile with. This will be included in the {@link
+ * androidx.wear.tiles.RequestBuilders.TileRequest} sent after this action is invoked by
+ * a {@link androidx.wear.tiles.ModifiersBuilders.Clickable}.
*/
@NonNull
public Builder setRequestState(@NonNull State.Builder requestStateBuilder) {
diff --git a/wear/tiles/tiles/src/main/java/androidx/wear/tiles/DeviceParametersBuilders.java b/wear/tiles/tiles/src/main/java/androidx/wear/tiles/DeviceParametersBuilders.java
new file mode 100644
index 0000000..624f512
--- /dev/null
+++ b/wear/tiles/tiles/src/main/java/androidx/wear/tiles/DeviceParametersBuilders.java
@@ -0,0 +1,191 @@
+/*
+ * Copyright 2021 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.wear.tiles;
+
+import static androidx.annotation.Dimension.DP;
+
+import androidx.annotation.Dimension;
+import androidx.annotation.FloatRange;
+import androidx.annotation.IntDef;
+import androidx.annotation.NonNull;
+import androidx.annotation.RestrictTo;
+import androidx.annotation.RestrictTo.Scope;
+import androidx.wear.tiles.proto.DeviceParametersProto;
+
+import java.lang.annotation.Retention;
+import java.lang.annotation.RetentionPolicy;
+
+/** Builders for request messages used to fetch tiles and resources. */
+public final class DeviceParametersBuilders {
+ private DeviceParametersBuilders() {}
+
+ /**
+ * The platform of the device requesting a tile.
+ *
+ * @hide
+ */
+ @RestrictTo(RestrictTo.Scope.LIBRARY)
+ @IntDef({DEVICE_PLATFORM_UNDEFINED, DEVICE_PLATFORM_WEAR_OS})
+ @Retention(RetentionPolicy.SOURCE)
+ public @interface DevicePlatform {}
+
+ /** Device platform is undefined. */
+ public static final int DEVICE_PLATFORM_UNDEFINED = 0;
+
+ /** Device is a Wear OS by Google device. */
+ public static final int DEVICE_PLATFORM_WEAR_OS = 1;
+
+ /**
+ * The shape of a screen.
+ *
+ * @hide
+ */
+ @RestrictTo(RestrictTo.Scope.LIBRARY)
+ @IntDef({SCREEN_SHAPE_UNDEFINED, SCREEN_SHAPE_ROUND, SCREEN_SHAPE_RECT})
+ @Retention(RetentionPolicy.SOURCE)
+ public @interface ScreenShape {}
+
+ /** Screen shape is undefined. */
+ public static final int SCREEN_SHAPE_UNDEFINED = 0;
+
+ /** A round screen (typically found on most Wear devices). */
+ public static final int SCREEN_SHAPE_ROUND = 1;
+
+ /** Rectangular screens. */
+ public static final int SCREEN_SHAPE_RECT = 2;
+
+ /**
+ * Parameters describing the device requesting a tile update. This contains physical and logical
+ * characteristics about the device (e.g. screen size and density, etc).
+ */
+ public static final class DeviceParameters {
+ private final DeviceParametersProto.DeviceParameters mImpl;
+
+ private DeviceParameters(DeviceParametersProto.DeviceParameters impl) {
+ this.mImpl = impl;
+ }
+
+ /** Gets width of the device's screen in DP. */
+ @Dimension(unit = DP)
+ public int getScreenWidthDp() {
+ return mImpl.getScreenWidthDp();
+ }
+
+ /** Gets height of the device's screen in DP. */
+ @Dimension(unit = DP)
+ public int getScreenHeightDp() {
+ return mImpl.getScreenHeightDp();
+ }
+
+ /**
+ * Gets density of the display. This value is the scaling factor to get from DP to Pixels
+ * (px = dp * density).
+ */
+ @FloatRange(from = 0.0, fromInclusive = false, toInclusive = false)
+ public float getScreenDensity() {
+ return mImpl.getScreenDensity();
+ }
+
+ /** Gets the platform of the device. */
+ @DevicePlatform
+ public int getDevicePlatform() {
+ return mImpl.getDevicePlatform().getNumber();
+ }
+
+ /** Gets the shape of the device's screen. */
+ @ScreenShape
+ public int getScreenShape() {
+ return mImpl.getScreenShape().getNumber();
+ }
+
+ /** Returns a new {@link Builder}. */
+ @NonNull
+ public static Builder builder() {
+ return new Builder();
+ }
+
+ /** @hide */
+ @RestrictTo(Scope.LIBRARY_GROUP)
+ @NonNull
+ public static DeviceParameters fromProto(
+ @NonNull DeviceParametersProto.DeviceParameters proto) {
+ return new DeviceParameters(proto);
+ }
+
+ /** @hide */
+ @RestrictTo(Scope.LIBRARY_GROUP)
+ @NonNull
+ public DeviceParametersProto.DeviceParameters toProto() {
+ return mImpl;
+ }
+
+ /** Builder for {@link DeviceParameters} */
+ public static final class Builder {
+ private final DeviceParametersProto.DeviceParameters.Builder mImpl =
+ DeviceParametersProto.DeviceParameters.newBuilder();
+
+ Builder() {}
+
+ /** Sets width of the device's screen in DP. */
+ @NonNull
+ public Builder setScreenWidthDp(@Dimension(unit = DP) int screenWidthDp) {
+ mImpl.setScreenWidthDp(screenWidthDp);
+ return this;
+ }
+
+ /** Sets height of the device's screen in DP. */
+ @NonNull
+ public Builder setScreenHeightDp(@Dimension(unit = DP) int screenHeightDp) {
+ mImpl.setScreenHeightDp(screenHeightDp);
+ return this;
+ }
+
+ /**
+ * Sets density of the display. This value is the scaling factor to get from DP to
+ * Pixels (px = dp * density).
+ */
+ @NonNull
+ public Builder setScreenDensity(
+ @FloatRange(from = 0.0, fromInclusive = false, toInclusive = false)
+ float screenDensity) {
+ mImpl.setScreenDensity(screenDensity);
+ return this;
+ }
+
+ /** Sets the platform of the device. */
+ @NonNull
+ public Builder setDevicePlatform(@DevicePlatform int devicePlatform) {
+ mImpl.setDevicePlatform(
+ DeviceParametersProto.DevicePlatform.forNumber(devicePlatform));
+ return this;
+ }
+
+ /** Sets the shape of the device's screen. */
+ @NonNull
+ public Builder setScreenShape(@ScreenShape int screenShape) {
+ mImpl.setScreenShape(DeviceParametersProto.ScreenShape.forNumber(screenShape));
+ return this;
+ }
+
+ /** Builds an instance from accumulated values. */
+ @NonNull
+ public DeviceParameters build() {
+ return DeviceParameters.fromProto(mImpl.build());
+ }
+ }
+ }
+}
diff --git a/wear/tiles/tiles/src/main/java/androidx/wear/tiles/EventBuilders.java b/wear/tiles/tiles/src/main/java/androidx/wear/tiles/EventBuilders.java
new file mode 100644
index 0000000..cfc85fd
--- /dev/null
+++ b/wear/tiles/tiles/src/main/java/androidx/wear/tiles/EventBuilders.java
@@ -0,0 +1,202 @@
+/*
+ * Copyright 2021 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.wear.tiles;
+
+import androidx.annotation.NonNull;
+import androidx.annotation.RestrictTo;
+import androidx.annotation.RestrictTo.Scope;
+import androidx.wear.tiles.proto.EventProto;
+
+/** Builders for messages used when events happen in the Tiles system. */
+public final class EventBuilders {
+ private EventBuilders() {}
+
+ /** Event fired when a tile has been added to the carousel. */
+ public static final class TileAddEvent {
+ private final EventProto.TileAddEvent mImpl;
+
+ private TileAddEvent(EventProto.TileAddEvent impl) {
+ this.mImpl = impl;
+ }
+
+ /** Returns a new {@link Builder}. */
+ @NonNull
+ public static Builder builder() {
+ return new Builder();
+ }
+
+ /** @hide */
+ @RestrictTo(Scope.LIBRARY_GROUP)
+ @NonNull
+ public static TileAddEvent fromProto(@NonNull EventProto.TileAddEvent proto) {
+ return new TileAddEvent(proto);
+ }
+
+ /** @hide */
+ @RestrictTo(Scope.LIBRARY_GROUP)
+ @NonNull
+ public EventProto.TileAddEvent toProto() {
+ return mImpl;
+ }
+
+ /** Builder for {@link TileAddEvent} */
+ public static final class Builder {
+ private final EventProto.TileAddEvent.Builder mImpl =
+ EventProto.TileAddEvent.newBuilder();
+
+ Builder() {}
+
+ /** Builds an instance from accumulated values. */
+ @NonNull
+ public TileAddEvent build() {
+ return TileAddEvent.fromProto(mImpl.build());
+ }
+ }
+ }
+
+ /** Event fired when a tile has been removed from the carousel. */
+ public static final class TileRemoveEvent {
+ private final EventProto.TileRemoveEvent mImpl;
+
+ private TileRemoveEvent(EventProto.TileRemoveEvent impl) {
+ this.mImpl = impl;
+ }
+
+ /** Returns a new {@link Builder}. */
+ @NonNull
+ public static Builder builder() {
+ return new Builder();
+ }
+
+ /** @hide */
+ @RestrictTo(Scope.LIBRARY_GROUP)
+ @NonNull
+ public static TileRemoveEvent fromProto(@NonNull EventProto.TileRemoveEvent proto) {
+ return new TileRemoveEvent(proto);
+ }
+
+ /** @hide */
+ @RestrictTo(Scope.LIBRARY_GROUP)
+ @NonNull
+ public EventProto.TileRemoveEvent toProto() {
+ return mImpl;
+ }
+
+ /** Builder for {@link TileRemoveEvent} */
+ public static final class Builder {
+ private final EventProto.TileRemoveEvent.Builder mImpl =
+ EventProto.TileRemoveEvent.newBuilder();
+
+ Builder() {}
+
+ /** Builds an instance from accumulated values. */
+ @NonNull
+ public TileRemoveEvent build() {
+ return TileRemoveEvent.fromProto(mImpl.build());
+ }
+ }
+ }
+
+ /** Event fired when a tile is swiped to by the user (i.e. it's visible on screen). */
+ public static final class TileEnterEvent {
+ private final EventProto.TileEnterEvent mImpl;
+
+ private TileEnterEvent(EventProto.TileEnterEvent impl) {
+ this.mImpl = impl;
+ }
+
+ /** Returns a new {@link Builder}. */
+ @NonNull
+ public static Builder builder() {
+ return new Builder();
+ }
+
+ /** @hide */
+ @RestrictTo(Scope.LIBRARY_GROUP)
+ @NonNull
+ public static TileEnterEvent fromProto(@NonNull EventProto.TileEnterEvent proto) {
+ return new TileEnterEvent(proto);
+ }
+
+ /** @hide */
+ @RestrictTo(Scope.LIBRARY_GROUP)
+ @NonNull
+ public EventProto.TileEnterEvent toProto() {
+ return mImpl;
+ }
+
+ /** Builder for {@link TileEnterEvent} */
+ public static final class Builder {
+ private final EventProto.TileEnterEvent.Builder mImpl =
+ EventProto.TileEnterEvent.newBuilder();
+
+ Builder() {}
+
+ /** Builds an instance from accumulated values. */
+ @NonNull
+ public TileEnterEvent build() {
+ return TileEnterEvent.fromProto(mImpl.build());
+ }
+ }
+ }
+
+ /**
+ * Event fired when a tile is swiped away from by the user (i.e. it's no longer visible on
+ * screen).
+ */
+ public static final class TileLeaveEvent {
+ private final EventProto.TileLeaveEvent mImpl;
+
+ private TileLeaveEvent(EventProto.TileLeaveEvent impl) {
+ this.mImpl = impl;
+ }
+
+ /** Returns a new {@link Builder}. */
+ @NonNull
+ public static Builder builder() {
+ return new Builder();
+ }
+
+ /** @hide */
+ @RestrictTo(Scope.LIBRARY_GROUP)
+ @NonNull
+ public static TileLeaveEvent fromProto(@NonNull EventProto.TileLeaveEvent proto) {
+ return new TileLeaveEvent(proto);
+ }
+
+ /** @hide */
+ @RestrictTo(Scope.LIBRARY_GROUP)
+ @NonNull
+ public EventProto.TileLeaveEvent toProto() {
+ return mImpl;
+ }
+
+ /** Builder for {@link TileLeaveEvent} */
+ public static final class Builder {
+ private final EventProto.TileLeaveEvent.Builder mImpl =
+ EventProto.TileLeaveEvent.newBuilder();
+
+ Builder() {}
+
+ /** Builds an instance from accumulated values. */
+ @NonNull
+ public TileLeaveEvent build() {
+ return TileLeaveEvent.fromProto(mImpl.build());
+ }
+ }
+ }
+}
diff --git a/wear/tiles/tiles/src/main/java/androidx/wear/tiles/LayoutElementBuilders.java b/wear/tiles/tiles/src/main/java/androidx/wear/tiles/LayoutElementBuilders.java
index a07f141..5d76b9d 100644
--- a/wear/tiles/tiles/src/main/java/androidx/wear/tiles/LayoutElementBuilders.java
+++ b/wear/tiles/tiles/src/main/java/androidx/wear/tiles/LayoutElementBuilders.java
@@ -28,6 +28,7 @@
import androidx.annotation.RestrictTo;
import androidx.annotation.RestrictTo.Scope;
import androidx.wear.tiles.ColorBuilders.ColorProp;
+import androidx.wear.tiles.DeviceParametersBuilders.DeviceParameters;
import androidx.wear.tiles.DimensionBuilders.ContainerDimension;
import androidx.wear.tiles.DimensionBuilders.DegreesProp;
import androidx.wear.tiles.DimensionBuilders.DpProp;
@@ -43,7 +44,6 @@
import androidx.wear.tiles.TypeBuilders.StringProp;
import androidx.wear.tiles.proto.LayoutElementProto;
import androidx.wear.tiles.proto.TypesProto;
-import androidx.wear.tiles.readers.DeviceParametersReaders.DeviceParameters;
import java.lang.annotation.Retention;
import java.lang.annotation.RetentionPolicy;
diff --git a/wear/tiles/tiles/src/main/java/androidx/wear/tiles/RequestBuilders.java b/wear/tiles/tiles/src/main/java/androidx/wear/tiles/RequestBuilders.java
new file mode 100644
index 0000000..f41fd416
--- /dev/null
+++ b/wear/tiles/tiles/src/main/java/androidx/wear/tiles/RequestBuilders.java
@@ -0,0 +1,239 @@
+/*
+ * Copyright 2021 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.wear.tiles;
+
+import androidx.annotation.NonNull;
+import androidx.annotation.Nullable;
+import androidx.annotation.RestrictTo;
+import androidx.annotation.RestrictTo.Scope;
+import androidx.wear.tiles.DeviceParametersBuilders.DeviceParameters;
+import androidx.wear.tiles.StateBuilders.State;
+import androidx.wear.tiles.proto.RequestProto;
+
+import java.util.List;
+
+/** Builders for request messages used to fetch tiles and resources. */
+public final class RequestBuilders {
+ private RequestBuilders() {}
+
+ /**
+ * Parameters passed to a {@link androidx.wear.tiles.TileBuilders.Tile} provider when the
+ * renderer is requesting a new version of the tile.
+ */
+ public static final class TileRequest {
+ private final RequestProto.TileRequest mImpl;
+
+ private TileRequest(RequestProto.TileRequest impl) {
+ this.mImpl = impl;
+ }
+
+ /** Gets parameters describing the device requesting the tile update. */
+ @Nullable
+ public DeviceParameters getDeviceParameters() {
+ if (mImpl.hasDeviceParameters()) {
+ return DeviceParameters.fromProto(mImpl.getDeviceParameters());
+ } else {
+ return null;
+ }
+ }
+
+ /** Gets the state that should be used when building the tile. */
+ @Nullable
+ public State getState() {
+ if (mImpl.hasState()) {
+ return State.fromProto(mImpl.getState());
+ } else {
+ return null;
+ }
+ }
+
+ /** Returns a new {@link Builder}. */
+ @NonNull
+ public static Builder builder() {
+ return new Builder();
+ }
+
+ /** @hide */
+ @RestrictTo(Scope.LIBRARY_GROUP)
+ @NonNull
+ public static TileRequest fromProto(@NonNull RequestProto.TileRequest proto) {
+ return new TileRequest(proto);
+ }
+
+ /** @hide */
+ @RestrictTo(Scope.LIBRARY_GROUP)
+ @NonNull
+ public RequestProto.TileRequest toProto() {
+ return mImpl;
+ }
+
+ /** Builder for {@link TileRequest} */
+ public static final class Builder {
+ private final RequestProto.TileRequest.Builder mImpl =
+ RequestProto.TileRequest.newBuilder();
+
+ Builder() {}
+
+ /** Sets parameters describing the device requesting the tile update. */
+ @NonNull
+ public Builder setDeviceParameters(@NonNull DeviceParameters deviceParameters) {
+ mImpl.setDeviceParameters(deviceParameters.toProto());
+ return this;
+ }
+
+ /** Sets parameters describing the device requesting the tile update. */
+ @NonNull
+ public Builder setDeviceParameters(
+ @NonNull DeviceParameters.Builder deviceParametersBuilder) {
+ mImpl.setDeviceParameters(deviceParametersBuilder.build().toProto());
+ return this;
+ }
+
+ /** Sets the state that should be used when building the tile. */
+ @NonNull
+ public Builder setState(@NonNull State state) {
+ mImpl.setState(state.toProto());
+ return this;
+ }
+
+ /** Sets the state that should be used when building the tile. */
+ @NonNull
+ public Builder setState(@NonNull State.Builder stateBuilder) {
+ mImpl.setState(stateBuilder.build().toProto());
+ return this;
+ }
+
+ /** Builds an instance from accumulated values. */
+ @NonNull
+ public TileRequest build() {
+ return TileRequest.fromProto(mImpl.build());
+ }
+ }
+ }
+
+ /**
+ * Parameters passed to a {@link androidx.wear.tiles.TileBuilders.Tile} provider when the
+ * renderer is requesting a specific resource version.
+ */
+ public static final class ResourcesRequest {
+ private final RequestProto.ResourcesRequest mImpl;
+
+ private ResourcesRequest(RequestProto.ResourcesRequest impl) {
+ this.mImpl = impl;
+ }
+
+ /**
+ * Gets the version of the resources being fetched. This is the same as the requested
+ * resource version, passed in {@link androidx.wear.tiles.TileBuilders.Tile}.
+ */
+ @NonNull
+ public String getVersion() {
+ return mImpl.getVersion();
+ }
+
+ /**
+ * Gets requested resource IDs. If not specified, all resources for the given version must
+ * be provided in the response.
+ */
+ @NonNull
+ public List<String> getResourceIds() {
+ return mImpl.getResourceIdsList();
+ }
+
+ /**
+ * Gets parameters describing the device requesting the resources. Intended for testing
+ * purposes only.
+ */
+ @Nullable
+ public DeviceParameters getDeviceParameters() {
+ if (mImpl.hasDeviceParameters()) {
+ return DeviceParameters.fromProto(mImpl.getDeviceParameters());
+ } else {
+ return null;
+ }
+ }
+
+ /** Returns a new {@link Builder}. */
+ @NonNull
+ public static Builder builder() {
+ return new Builder();
+ }
+
+ /** @hide */
+ @RestrictTo(Scope.LIBRARY_GROUP)
+ @NonNull
+ public static ResourcesRequest fromProto(@NonNull RequestProto.ResourcesRequest proto) {
+ return new ResourcesRequest(proto);
+ }
+
+ /** @hide */
+ @RestrictTo(Scope.LIBRARY_GROUP)
+ @NonNull
+ public RequestProto.ResourcesRequest toProto() {
+ return mImpl;
+ }
+
+ /** Builder for {@link ResourcesRequest} */
+ public static final class Builder {
+ private final RequestProto.ResourcesRequest.Builder mImpl =
+ RequestProto.ResourcesRequest.newBuilder();
+
+ Builder() {}
+
+ /**
+ * Sets the version of the resources being fetched. This is the same as the requested
+ * resource version, passed in {@link androidx.wear.tiles.TileBuilders.Tile}.
+ */
+ @NonNull
+ public Builder setVersion(@NonNull String version) {
+ mImpl.setVersion(version);
+ return this;
+ }
+
+ /**
+ * Adds one item to requested resource IDs. If not specified, all resources for the
+ * given version must be provided in the response.
+ */
+ @NonNull
+ public Builder addResourceId(@NonNull String resourceId) {
+ mImpl.addResourceIds(resourceId);
+ return this;
+ }
+
+ /** Sets parameters describing the device requesting the resources. */
+ @NonNull
+ public Builder setDeviceParameters(@NonNull DeviceParameters deviceParameters) {
+ mImpl.setDeviceParameters(deviceParameters.toProto());
+ return this;
+ }
+
+ /** Sets parameters describing the device requesting the resources. */
+ @NonNull
+ public Builder setDeviceParameters(
+ @NonNull DeviceParameters.Builder deviceParametersBuilder) {
+ mImpl.setDeviceParameters(deviceParametersBuilder.build().toProto());
+ return this;
+ }
+
+ /** Builds an instance from accumulated values. */
+ @NonNull
+ public ResourcesRequest build() {
+ return ResourcesRequest.fromProto(mImpl.build());
+ }
+ }
+ }
+}
diff --git a/wear/tiles/tiles/src/main/java/androidx/wear/tiles/ResourceBuilders.java b/wear/tiles/tiles/src/main/java/androidx/wear/tiles/ResourceBuilders.java
index 3b7700e..c8b8750 100644
--- a/wear/tiles/tiles/src/main/java/androidx/wear/tiles/ResourceBuilders.java
+++ b/wear/tiles/tiles/src/main/java/androidx/wear/tiles/ResourceBuilders.java
@@ -365,8 +365,9 @@
* resources.
*
* <p>This value must match the version of the resources required by the tile for the tile
- * to render successfully, and must match the resource version specified in ResourcesRequest
- * which triggered this request. Intended for testing purposes only.
+ * to render successfully, and must match the resource version specified in {@link
+ * androidx.wear.tiles.RequestBuilders.ResourcesRequest} which triggered this request.
+ * Intended for testing purposes only.
*/
@NonNull
public String getVersion() {
@@ -422,8 +423,8 @@
* the resources.
*
* <p>This value must match the version of the resources required by the tile for the
- * tile to render successfully, and must match the resource version specified in
- * ResourcesRequest which triggered this request.
+ * tile to render successfully, and must match the resource version specified in {@link
+ * androidx.wear.tiles.RequestBuilders.ResourcesRequest} which triggered this request.
*/
@NonNull
public Builder setVersion(@NonNull String version) {
diff --git a/wear/tiles/tiles/src/main/java/androidx/wear/tiles/SysUiTileUpdateRequester.java b/wear/tiles/tiles/src/main/java/androidx/wear/tiles/SysUiTileUpdateRequester.java
index c1d54c8..628fc33 100644
--- a/wear/tiles/tiles/src/main/java/androidx/wear/tiles/SysUiTileUpdateRequester.java
+++ b/wear/tiles/tiles/src/main/java/androidx/wear/tiles/SysUiTileUpdateRequester.java
@@ -143,8 +143,7 @@
// we'll unbind, then immediately rebind. That said, this class should be
// used pretty rarely
// (and it'll be rare to have two in-flight update requests at once
- // regardless), so
- // it's probably fine.
+ // regardless), so it's probably fine.
TileUpdateRequesterService updateRequesterService =
TileUpdateRequesterService.Stub.asInterface(service);
diff --git a/wear/tiles/tiles/src/main/java/androidx/wear/tiles/TileBuilders.java b/wear/tiles/tiles/src/main/java/androidx/wear/tiles/TileBuilders.java
index 1fcacd7..aef9ccf 100644
--- a/wear/tiles/tiles/src/main/java/androidx/wear/tiles/TileBuilders.java
+++ b/wear/tiles/tiles/src/main/java/androidx/wear/tiles/TileBuilders.java
@@ -41,9 +41,9 @@
/**
* Gets the resource version required for these tiles. This can be any developer-defined
- * string; it is only used to cache resources, and is passed in ResourcesRequest if the
- * system does not have a copy of the specified resource version. Intended for testing
- * purposes only.
+ * string; it is only used to cache resources, and is passed in {@link
+ * androidx.wear.tiles.RequestBuilders.ResourcesRequest} if the system does not have a copy
+ * of the specified resource version. Intended for testing purposes only.
*/
@NonNull
public String getResourcesVersion() {
@@ -108,8 +108,9 @@
/**
* Sets the resource version required for these tiles. This can be any developer-defined
- * string; it is only used to cache resources, and is passed in ResourcesRequest if the
- * system does not have a copy of the specified resource version.
+ * string; it is only used to cache resources, and is passed in {@link
+ * androidx.wear.tiles.RequestBuilders.ResourcesRequest} if the system does not have a
+ * copy of the specified resource version.
*/
@NonNull
public Builder setResourcesVersion(@NonNull String resourcesVersion) {
diff --git a/wear/tiles/tiles/src/main/java/androidx/wear/tiles/TileProviderService.java b/wear/tiles/tiles/src/main/java/androidx/wear/tiles/TileProviderService.java
index 6029f15..9dce43d 100644
--- a/wear/tiles/tiles/src/main/java/androidx/wear/tiles/TileProviderService.java
+++ b/wear/tiles/tiles/src/main/java/androidx/wear/tiles/TileProviderService.java
@@ -27,16 +27,19 @@
import androidx.annotation.MainThread;
import androidx.annotation.NonNull;
import androidx.annotation.Nullable;
+import androidx.wear.tiles.EventBuilders.TileAddEvent;
+import androidx.wear.tiles.EventBuilders.TileEnterEvent;
+import androidx.wear.tiles.EventBuilders.TileLeaveEvent;
+import androidx.wear.tiles.EventBuilders.TileRemoveEvent;
+import androidx.wear.tiles.RequestBuilders.ResourcesRequest;
+import androidx.wear.tiles.RequestBuilders.TileRequest;
import androidx.wear.tiles.ResourceBuilders.Resources;
import androidx.wear.tiles.TileBuilders.Tile;
import androidx.wear.tiles.TileBuilders.Version;
+import androidx.wear.tiles.proto.EventProto;
+import androidx.wear.tiles.proto.RequestProto;
import androidx.wear.tiles.proto.TileProto;
-import androidx.wear.tiles.readers.EventReaders.TileAddEvent;
-import androidx.wear.tiles.readers.EventReaders.TileEnterEvent;
-import androidx.wear.tiles.readers.EventReaders.TileLeaveEvent;
-import androidx.wear.tiles.readers.EventReaders.TileRemoveEvent;
-import androidx.wear.tiles.readers.RequestReaders.ResourcesRequest;
-import androidx.wear.tiles.readers.RequestReaders.TileRequest;
+import androidx.wear.tiles.protobuf.InvalidProtocolBufferException;
import com.google.common.util.concurrent.ListenableFuture;
@@ -208,10 +211,20 @@
return;
}
- // TODO(b/166074385): Add tileId to TileRequest
+ TileRequest tileRequest;
+
+ try {
+ tileRequest =
+ TileRequest.fromProto(
+ RequestProto.TileRequest.parseFrom(
+ requestParams.getContents()));
+ } catch (InvalidProtocolBufferException ex) {
+ Log.e(TAG, "Error deserializing TileRequest payload.", ex);
+ return;
+ }
+
ListenableFuture<Tile> tileFuture =
- tileProviderService.onTileRequest(
- TileRequest.fromParcelable(requestParams, tileId));
+ tileProviderService.onTileRequest(tileRequest);
tileFuture.addListener(
() -> {
@@ -256,10 +269,20 @@
return;
}
- // TODO(b/166074385): Add tileId to ResourcesRequest
+ ResourcesRequest req;
+
+ try {
+ req =
+ ResourcesRequest.fromProto(
+ RequestProto.ResourcesRequest.parseFrom(
+ requestParams.getContents()));
+ } catch (InvalidProtocolBufferException ex) {
+ Log.e(TAG, "Error deserializing ResourcesRequest payload.", ex);
+ return;
+ }
+
ListenableFuture<Resources> resourcesFuture =
- tileProviderService.onResourcesRequest(
- ResourcesRequest.fromParcelable(requestParams, tileId));
+ tileProviderService.onResourcesRequest(req);
resourcesFuture.addListener(
() -> {
@@ -301,7 +324,15 @@
return;
}
- tileProviderService.onTileAddEvent(TileAddEvent.fromParcelable(data));
+ try {
+ TileAddEvent evt =
+ TileAddEvent.fromProto(
+ EventProto.TileAddEvent.parseFrom(
+ data.getContents()));
+ tileProviderService.onTileAddEvent(evt);
+ } catch (InvalidProtocolBufferException ex) {
+ Log.e(TAG, "Error deserializing TileAddEvent payload.", ex);
+ }
}
});
}
@@ -321,8 +352,15 @@
return;
}
- tileProviderService.onTileRemoveEvent(
- TileRemoveEvent.fromParcelable(data));
+ try {
+ TileRemoveEvent evt =
+ TileRemoveEvent.fromProto(
+ EventProto.TileRemoveEvent.parseFrom(
+ data.getContents()));
+ tileProviderService.onTileRemoveEvent(evt);
+ } catch (InvalidProtocolBufferException ex) {
+ Log.e(TAG, "Error deserializing TileRemoveEvent payload.", ex);
+ }
}
});
}
@@ -342,8 +380,15 @@
return;
}
- tileProviderService.onTileEnterEvent(
- TileEnterEvent.fromParcelable(data));
+ try {
+ TileEnterEvent evt =
+ TileEnterEvent.fromProto(
+ EventProto.TileEnterEvent.parseFrom(
+ data.getContents()));
+ tileProviderService.onTileEnterEvent(evt);
+ } catch (InvalidProtocolBufferException ex) {
+ Log.e(TAG, "Error deserializing TileEnterEvent payload.", ex);
+ }
}
});
}
@@ -363,8 +408,15 @@
return;
}
- tileProviderService.onTileLeaveEvent(
- TileLeaveEvent.fromParcelable(data));
+ try {
+ TileLeaveEvent evt =
+ TileLeaveEvent.fromProto(
+ EventProto.TileLeaveEvent.parseFrom(
+ data.getContents()));
+ tileProviderService.onTileLeaveEvent(evt);
+ } catch (InvalidProtocolBufferException ex) {
+ Log.e(TAG, "Error deserializing TileLeaveEvent payload.", ex);
+ }
}
});
}
diff --git a/wear/tiles/tiles/src/main/java/androidx/wear/tiles/readers/DeviceParametersReaders.java b/wear/tiles/tiles/src/main/java/androidx/wear/tiles/readers/DeviceParametersReaders.java
deleted file mode 100644
index 238d8e6..0000000
--- a/wear/tiles/tiles/src/main/java/androidx/wear/tiles/readers/DeviceParametersReaders.java
+++ /dev/null
@@ -1,111 +0,0 @@
-/*
- * 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.wear.tiles.readers;
-
-import static androidx.annotation.Dimension.DP;
-
-import androidx.annotation.Dimension;
-import androidx.annotation.FloatRange;
-import androidx.annotation.IntDef;
-import androidx.annotation.RestrictTo;
-import androidx.wear.tiles.proto.DeviceParametersProto;
-import androidx.wear.tiles.readers.RequestReaders.TileRequest;
-
-import java.lang.annotation.Retention;
-import java.lang.annotation.RetentionPolicy;
-
-/** Readers for androidx.wear.tiles' device parameters structures. */
-public class DeviceParametersReaders {
- private DeviceParametersReaders() {}
-
- /**
- * The platform of the device requesting a tile.
- *
- * @hide
- */
- @RestrictTo(RestrictTo.Scope.LIBRARY)
- @IntDef({DEVICE_PLATFORM_UNDEFINED, DEVICE_PLATFORM_WEAR_OS})
- @Retention(RetentionPolicy.SOURCE)
- public @interface DevicePlatform {}
-
- /** Device platform is undefined. */
- public static final int DEVICE_PLATFORM_UNDEFINED = 0;
-
- /** Device is a Wear OS by Google device. */
- public static final int DEVICE_PLATFORM_WEAR_OS = 1;
-
- /**
- * The shape of a screen.
- *
- * @hide
- */
- @RestrictTo(RestrictTo.Scope.LIBRARY)
- @IntDef({SCREEN_SHAPE_UNDEFINED, SCREEN_SHAPE_ROUND, SCREEN_SHAPE_RECT})
- @Retention(RetentionPolicy.SOURCE)
- public @interface ScreenShape {}
-
- /** Screen shape is undefined. */
- public static final int SCREEN_SHAPE_UNDEFINED = 0;
-
- /** A round screen (typically found on most Wear devices). */
- public static final int SCREEN_SHAPE_ROUND = 1;
-
- /** Rectangular screens. */
- public static final int SCREEN_SHAPE_RECT = 2;
-
- /** Reader for the Device Parameters returned from {@link TileRequest#getDeviceParameters()}. */
- public static class DeviceParameters {
- private final DeviceParametersProto.DeviceParameters mProto;
-
- DeviceParameters(DeviceParametersProto.DeviceParameters proto) {
- this.mProto = proto;
- }
-
- /** Get the width of the screen, in DP. */
- @Dimension(unit = DP)
- public int getScreenWidthDp() {
- return mProto.getScreenWidthDp();
- }
-
- /** Get the height of the screen, in DP. */
- @Dimension(unit = DP)
- public int getScreenHeightDp() {
- return mProto.getScreenHeightDp();
- }
-
- /**
- * Get the density of the screen. This value is the scaling factor to get from DP to Pixels,
- * where PX = DP * density.
- */
- @FloatRange(from = 0.0, fromInclusive = false)
- public float getScreenDensity() {
- return mProto.getScreenDensity();
- }
-
- /** Get the platform of the device. */
- @DevicePlatform
- public int getDevicePlatform() {
- return mProto.getDevicePlatformValue();
- }
-
- /** Get the shape of the screen of the device. */
- @ScreenShape
- public int getScreenShape() {
- return mProto.getScreenShapeValue();
- }
- }
-}
diff --git a/wear/tiles/tiles/src/main/java/androidx/wear/tiles/readers/EventReaders.java b/wear/tiles/tiles/src/main/java/androidx/wear/tiles/readers/EventReaders.java
deleted file mode 100644
index 8300687..0000000
--- a/wear/tiles/tiles/src/main/java/androidx/wear/tiles/readers/EventReaders.java
+++ /dev/null
@@ -1,149 +0,0 @@
-/*
- * Copyright 2021 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.wear.tiles.readers;
-
-import androidx.annotation.NonNull;
-import androidx.annotation.RestrictTo;
-import androidx.annotation.RestrictTo.Scope;
-import androidx.wear.tiles.TileAddEventData;
-import androidx.wear.tiles.TileEnterEventData;
-import androidx.wear.tiles.TileLeaveEventData;
-import androidx.wear.tiles.TileRemoveEventData;
-import androidx.wear.tiles.proto.EventProto;
-import androidx.wear.tiles.protobuf.ExtensionRegistryLite;
-import androidx.wear.tiles.protobuf.InvalidProtocolBufferException;
-
-/** Event readers for androidx.wear.tiles' Parcelable classes. */
-public class EventReaders {
- private EventReaders() {}
-
- /** Reader for Tile add event parameters. */
- public static class TileAddEvent {
- @SuppressWarnings("unused")
- private final EventProto.TileAddEvent mProto;
-
- private TileAddEvent(@NonNull EventProto.TileAddEvent proto) {
- this.mProto = proto;
- }
-
- /**
- * Create an instance of this reader from a given {@link TileAddEventData} instance.
- *
- * @hide
- */
- @RestrictTo(Scope.LIBRARY)
- @NonNull
- public static TileAddEvent fromParcelable(@NonNull TileAddEventData parcelable) {
- try {
- return new TileAddEvent(
- EventProto.TileAddEvent.parseFrom(
- parcelable.getContents(),
- ExtensionRegistryLite.getEmptyRegistry()));
- } catch (InvalidProtocolBufferException ex) {
- throw new IllegalArgumentException(
- "Passed TileAddEventData did not contain a valid proto payload", ex);
- }
- }
- }
-
- /** Reader for Tile remove event parameters. */
- public static class TileRemoveEvent {
- @SuppressWarnings("unused")
- private final EventProto.TileRemoveEvent mProto;
-
- private TileRemoveEvent(@NonNull EventProto.TileRemoveEvent proto) {
- this.mProto = proto;
- }
-
- /**
- * Create an instance of this reader from a given {@link TileRemoveEventData} instance.
- *
- * @hide
- */
- @RestrictTo(Scope.LIBRARY)
- @NonNull
- public static TileRemoveEvent fromParcelable(@NonNull TileRemoveEventData parcelable) {
- try {
- return new TileRemoveEvent(
- EventProto.TileRemoveEvent.parseFrom(
- parcelable.getContents(),
- ExtensionRegistryLite.getEmptyRegistry()));
- } catch (InvalidProtocolBufferException ex) {
- throw new IllegalArgumentException(
- "Passed TileRemoveEventData did not contain a valid proto payload", ex);
- }
- }
- }
-
- /** Reader for Tile enter event parameters. */
- public static class TileEnterEvent {
- @SuppressWarnings("unused")
- private final EventProto.TileEnterEvent mProto;
-
- private TileEnterEvent(@NonNull EventProto.TileEnterEvent proto) {
- this.mProto = proto;
- }
-
- /**
- * Create an instance of this reader from a given {@link TileEnterEventData} instance.
- *
- * @hide
- */
- @RestrictTo(Scope.LIBRARY)
- @NonNull
- public static TileEnterEvent fromParcelable(@NonNull TileEnterEventData parcelable) {
- try {
- return new TileEnterEvent(
- EventProto.TileEnterEvent.parseFrom(
- parcelable.getContents(),
- ExtensionRegistryLite.getEmptyRegistry()));
- } catch (InvalidProtocolBufferException ex) {
- throw new IllegalArgumentException(
- "Passed TileEnterEventData did not contain a valid proto payload", ex);
- }
- }
- }
-
- /** Reader for a Tile leave event parameters. */
- public static class TileLeaveEvent {
- @SuppressWarnings("unused")
- private final EventProto.TileLeaveEvent mProto;
-
- private TileLeaveEvent(@NonNull EventProto.TileLeaveEvent proto) {
- this.mProto = proto;
- }
-
- /**
- * Create an instance of this reader from a given {@link TileLeaveEventData} instance.
- *
- * @hide
- */
- @RestrictTo(Scope.LIBRARY)
- @NonNull
- public static TileLeaveEvent fromParcelable(@NonNull TileLeaveEventData parcelable) {
- try {
- return new TileLeaveEvent(
- EventProto.TileLeaveEvent.parseFrom(
- parcelable.getContents(),
- ExtensionRegistryLite.getEmptyRegistry()));
- } catch (InvalidProtocolBufferException ex) {
- throw new IllegalArgumentException(
- "Passed TileLeaveEventData did not contain a valid proto payload", ex);
- }
- }
- }
-}
diff --git a/wear/tiles/tiles/src/main/java/androidx/wear/tiles/readers/RequestReaders.java b/wear/tiles/tiles/src/main/java/androidx/wear/tiles/readers/RequestReaders.java
deleted file mode 100644
index 4462123..0000000
--- a/wear/tiles/tiles/src/main/java/androidx/wear/tiles/readers/RequestReaders.java
+++ /dev/null
@@ -1,125 +0,0 @@
-/*
- * 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.wear.tiles.readers;
-
-import androidx.annotation.NonNull;
-import androidx.annotation.RestrictTo;
-import androidx.annotation.RestrictTo.Scope;
-import androidx.wear.tiles.ResourcesRequestData;
-import androidx.wear.tiles.StateBuilders.State;
-import androidx.wear.tiles.TileRequestData;
-import androidx.wear.tiles.proto.RequestProto;
-import androidx.wear.tiles.protobuf.ExtensionRegistryLite;
-import androidx.wear.tiles.protobuf.InvalidProtocolBufferException;
-import androidx.wear.tiles.readers.DeviceParametersReaders.DeviceParameters;
-
-import java.util.List;
-
-/** Request readers for androidx.wear.tiles' Parcelable classes. */
-public class RequestReaders {
- private RequestReaders() {}
-
- /** Reader for Tile request parameters. */
- public static class TileRequest {
- private final RequestProto.TileRequest mProto;
-
- @SuppressWarnings("unused")
- private final int mTileId;
-
- private TileRequest(RequestProto.TileRequest proto, int tileId) {
- this.mProto = proto;
- this.mTileId = tileId;
- }
-
- /** Get the {@link State} that the tile should be built with. */
- @NonNull
- public State getState() {
- return State.fromProto(mProto.getState());
- }
-
- /** Get parameters describing the device requesting this tile. */
- @NonNull
- public DeviceParameters getDeviceParameters() {
- return new DeviceParameters(mProto.getDeviceParameters());
- }
-
- /** @hide */
- @RestrictTo(Scope.LIBRARY)
- @NonNull
- public static TileRequest fromParcelable(@NonNull TileRequestData parcelable, int tileId) {
- try {
- return new TileRequest(
- RequestProto.TileRequest.parseFrom(
- parcelable.getContents(), ExtensionRegistryLite.getEmptyRegistry()),
- tileId);
- } catch (InvalidProtocolBufferException ex) {
- throw new IllegalArgumentException(
- "Passed TileRequestData did not contain a valid proto payload", ex);
- }
- }
- }
-
- /** Reader for resource request parameters. */
- public static class ResourcesRequest {
- private final RequestProto.ResourcesRequest mProto;
-
- @SuppressWarnings("unused")
- private final int mTileId;
-
- private ResourcesRequest(@NonNull RequestProto.ResourcesRequest proto, int tileId) {
- this.mProto = proto;
- this.mTileId = tileId;
- }
-
- /** @hide */
- @RestrictTo(Scope.LIBRARY)
- @NonNull
- public static ResourcesRequest fromParcelable(
- @NonNull ResourcesRequestData parcelable, int tileId) {
- try {
- return new ResourcesRequest(
- RequestProto.ResourcesRequest.parseFrom(
- parcelable.getContents(), ExtensionRegistryLite.getEmptyRegistry()),
- tileId);
- } catch (InvalidProtocolBufferException ex) {
- throw new IllegalArgumentException(
- "Passed ResourcesRequestData did not contain a valid proto payload", ex);
- }
- }
-
- /** Get the requested resource version. */
- @NonNull
- public String getVersion() {
- return mProto.getVersion();
- }
-
- /**
- * Get the requested resource IDs. May be empty, in which case all resources should be
- * returned.
- */
- @NonNull
- public List<String> getResourceIds() {
- return mProto.getResourceIdsList();
- }
-
- /** Get parameters describing the device requesting these resources. */
- @NonNull
- public DeviceParameters getDeviceParameters() {
- return new DeviceParameters(mProto.getDeviceParameters());
- }
- }
-}
diff --git a/wear/tiles/tiles/src/main/java/androidx/wear/tiles/readers/package-info.java b/wear/tiles/tiles/src/main/java/androidx/wear/tiles/readers/package-info.java
deleted file mode 100644
index 48deb88..0000000
--- a/wear/tiles/tiles/src/main/java/androidx/wear/tiles/readers/package-info.java
+++ /dev/null
@@ -1,23 +0,0 @@
-/*
- * 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.
- */
-
-/**
- * Contains {@link androidx.wear.tiles.readers.RequestReaders.TileRequest} and {@link
- * androidx.wear.tiles.readers.RequestReaders.ResourcesRequest}, which are passed as parameters to
- * {@link androidx.wear.tiles.TileProviderService#onTileRequest} and {@link
- * androidx.wear.tiles.TileProviderService#onResourcesRequest} respectively.
- */
-package androidx.wear.tiles.readers;
diff --git a/wear/tiles/tiles/src/test/java/androidx/wear/tiles/CompositeTileUpdateRequesterTest.java b/wear/tiles/tiles/src/test/java/androidx/wear/tiles/CompositeTileUpdateRequesterTest.java
index 286fc1f..4f00c4f 100644
--- a/wear/tiles/tiles/src/test/java/androidx/wear/tiles/CompositeTileUpdateRequesterTest.java
+++ b/wear/tiles/tiles/src/test/java/androidx/wear/tiles/CompositeTileUpdateRequesterTest.java
@@ -24,7 +24,6 @@
import androidx.annotation.NonNull;
import androidx.annotation.Nullable;
import androidx.concurrent.futures.ResolvableFuture;
-import androidx.wear.tiles.readers.RequestReaders;
import com.google.common.util.concurrent.ListenableFuture;
@@ -75,7 +74,7 @@
@NonNull
@Override
protected ListenableFuture<TileBuilders.Tile> onTileRequest(
- @NonNull RequestReaders.TileRequest requestParams) {
+ @NonNull RequestBuilders.TileRequest requestParams) {
ResolvableFuture<TileBuilders.Tile> f = ResolvableFuture.create();
f.set(null);
return f;
@@ -84,7 +83,7 @@
@NonNull
@Override
protected ListenableFuture<ResourceBuilders.Resources> onResourcesRequest(
- @NonNull RequestReaders.ResourcesRequest requestParams) {
+ @NonNull RequestBuilders.ResourcesRequest requestParams) {
ResolvableFuture<ResourceBuilders.Resources> f = ResolvableFuture.create();
f.set(null);
return f;
diff --git a/wear/tiles/tiles/src/test/java/androidx/wear/tiles/TileProviderServiceTest.java b/wear/tiles/tiles/src/test/java/androidx/wear/tiles/TileProviderServiceTest.java
index 0a3e8f7..cdcd478 100644
--- a/wear/tiles/tiles/src/test/java/androidx/wear/tiles/TileProviderServiceTest.java
+++ b/wear/tiles/tiles/src/test/java/androidx/wear/tiles/TileProviderServiceTest.java
@@ -25,17 +25,17 @@
import android.os.Looper;
import androidx.annotation.NonNull;
+import androidx.wear.tiles.EventBuilders.TileAddEvent;
+import androidx.wear.tiles.EventBuilders.TileEnterEvent;
+import androidx.wear.tiles.EventBuilders.TileLeaveEvent;
+import androidx.wear.tiles.EventBuilders.TileRemoveEvent;
+import androidx.wear.tiles.RequestBuilders.ResourcesRequest;
+import androidx.wear.tiles.RequestBuilders.TileRequest;
import androidx.wear.tiles.TileBuilders.Version;
import androidx.wear.tiles.proto.EventProto;
import androidx.wear.tiles.proto.RequestProto;
import androidx.wear.tiles.proto.ResourceProto.Resources;
import androidx.wear.tiles.proto.TileProto.Tile;
-import androidx.wear.tiles.readers.EventReaders.TileAddEvent;
-import androidx.wear.tiles.readers.EventReaders.TileEnterEvent;
-import androidx.wear.tiles.readers.EventReaders.TileLeaveEvent;
-import androidx.wear.tiles.readers.EventReaders.TileRemoveEvent;
-import androidx.wear.tiles.readers.RequestReaders.ResourcesRequest;
-import androidx.wear.tiles.readers.RequestReaders.TileRequest;
import com.google.common.truth.Expect;
import com.google.common.util.concurrent.Futures;