[go: nahoru, domu]

Lint and VFY clean-up for androidx.core.graphics

No functional changes, only auto-fixes. Cleans up some nullability.

Relnote: Cleaned up nullability for a subset of androidx.core APIs.
Fixes: 206113818
Test: Existing androidx.core.graphics tests
Change-Id: Ib2583f0cb8d6bcf8b94141069ac6834e29dc7759
diff --git a/core/core/api/current.txt b/core/core/api/current.txt
index 6dca398..3b02b86 100644
--- a/core/core/api/current.txt
+++ b/core/core/api/current.txt
@@ -1311,7 +1311,7 @@
     method public static androidx.core.graphics.Insets of(android.graphics.Rect);
     method public static androidx.core.graphics.Insets subtract(androidx.core.graphics.Insets, androidx.core.graphics.Insets);
     method @RequiresApi(api=29) public static androidx.core.graphics.Insets toCompatInsets(android.graphics.Insets);
-    method @RequiresApi(api=29) public android.graphics.Insets toPlatformInsets();
+    method @RequiresApi(29) public android.graphics.Insets toPlatformInsets();
     field public static final androidx.core.graphics.Insets NONE;
     field public final int bottom;
     field public final int left;
@@ -1350,7 +1350,7 @@
     method public static boolean canApplyTheme(android.graphics.drawable.Drawable);
     method public static void clearColorFilter(android.graphics.drawable.Drawable);
     method public static int getAlpha(android.graphics.drawable.Drawable);
-    method public static android.graphics.ColorFilter! getColorFilter(android.graphics.drawable.Drawable);
+    method public static android.graphics.ColorFilter? getColorFilter(android.graphics.drawable.Drawable);
     method public static int getLayoutDirection(android.graphics.drawable.Drawable);
     method public static void inflate(android.graphics.drawable.Drawable, android.content.res.Resources, org.xmlpull.v1.XmlPullParser, android.util.AttributeSet, android.content.res.Resources.Theme?) throws java.io.IOException, org.xmlpull.v1.XmlPullParserException;
     method public static boolean isAutoMirrored(android.graphics.drawable.Drawable);
@@ -1363,20 +1363,20 @@
     method public static void setTintList(android.graphics.drawable.Drawable, android.content.res.ColorStateList?);
     method public static void setTintMode(android.graphics.drawable.Drawable, android.graphics.PorterDuff.Mode);
     method public static <T extends android.graphics.drawable.Drawable> T! unwrap(android.graphics.drawable.Drawable);
-    method public static android.graphics.drawable.Drawable! wrap(android.graphics.drawable.Drawable);
+    method public static android.graphics.drawable.Drawable wrap(android.graphics.drawable.Drawable);
   }
 
   public class IconCompat implements androidx.versionedparcelable.VersionedParcelable {
     method public static androidx.core.graphics.drawable.IconCompat? createFromBundle(android.os.Bundle);
     method @RequiresApi(23) public static androidx.core.graphics.drawable.IconCompat? createFromIcon(android.content.Context, android.graphics.drawable.Icon);
-    method public static androidx.core.graphics.drawable.IconCompat! createWithAdaptiveBitmap(android.graphics.Bitmap!);
+    method public static androidx.core.graphics.drawable.IconCompat createWithAdaptiveBitmap(android.graphics.Bitmap);
     method public static androidx.core.graphics.drawable.IconCompat createWithAdaptiveBitmapContentUri(String);
     method public static androidx.core.graphics.drawable.IconCompat createWithAdaptiveBitmapContentUri(android.net.Uri);
-    method public static androidx.core.graphics.drawable.IconCompat! createWithBitmap(android.graphics.Bitmap!);
-    method public static androidx.core.graphics.drawable.IconCompat! createWithContentUri(String!);
-    method public static androidx.core.graphics.drawable.IconCompat! createWithContentUri(android.net.Uri!);
-    method public static androidx.core.graphics.drawable.IconCompat! createWithData(byte[]!, int, int);
-    method public static androidx.core.graphics.drawable.IconCompat! createWithResource(android.content.Context!, @DrawableRes int);
+    method public static androidx.core.graphics.drawable.IconCompat createWithBitmap(android.graphics.Bitmap);
+    method public static androidx.core.graphics.drawable.IconCompat createWithContentUri(String);
+    method public static androidx.core.graphics.drawable.IconCompat createWithContentUri(android.net.Uri);
+    method public static androidx.core.graphics.drawable.IconCompat createWithData(byte[], int, int);
+    method public static androidx.core.graphics.drawable.IconCompat createWithResource(android.content.Context, @DrawableRes int);
     method @IdRes public int getResId();
     method public String getResPackage();
     method public int getType();
@@ -1384,9 +1384,9 @@
     method public android.graphics.drawable.Drawable? loadDrawable(android.content.Context);
     method public void onPostParceling();
     method public void onPreParceling(boolean);
-    method public androidx.core.graphics.drawable.IconCompat! setTint(@ColorInt int);
-    method public androidx.core.graphics.drawable.IconCompat! setTintList(android.content.res.ColorStateList!);
-    method public androidx.core.graphics.drawable.IconCompat! setTintMode(android.graphics.PorterDuff.Mode!);
+    method public androidx.core.graphics.drawable.IconCompat setTint(@ColorInt int);
+    method public androidx.core.graphics.drawable.IconCompat setTintList(android.content.res.ColorStateList?);
+    method public androidx.core.graphics.drawable.IconCompat setTintMode(android.graphics.PorterDuff.Mode?);
     method public android.os.Bundle toBundle();
     method @Deprecated @RequiresApi(23) public android.graphics.drawable.Icon toIcon();
     method @RequiresApi(23) public android.graphics.drawable.Icon toIcon(android.content.Context?);
diff --git a/core/core/api/public_plus_experimental_current.txt b/core/core/api/public_plus_experimental_current.txt
index 5dd917d..27c13a6 100644
--- a/core/core/api/public_plus_experimental_current.txt
+++ b/core/core/api/public_plus_experimental_current.txt
@@ -1311,7 +1311,7 @@
     method public static androidx.core.graphics.Insets of(android.graphics.Rect);
     method public static androidx.core.graphics.Insets subtract(androidx.core.graphics.Insets, androidx.core.graphics.Insets);
     method @RequiresApi(api=29) public static androidx.core.graphics.Insets toCompatInsets(android.graphics.Insets);
-    method @RequiresApi(api=29) public android.graphics.Insets toPlatformInsets();
+    method @RequiresApi(29) public android.graphics.Insets toPlatformInsets();
     field public static final androidx.core.graphics.Insets NONE;
     field public final int bottom;
     field public final int left;
@@ -1350,7 +1350,7 @@
     method public static boolean canApplyTheme(android.graphics.drawable.Drawable);
     method public static void clearColorFilter(android.graphics.drawable.Drawable);
     method public static int getAlpha(android.graphics.drawable.Drawable);
-    method public static android.graphics.ColorFilter! getColorFilter(android.graphics.drawable.Drawable);
+    method public static android.graphics.ColorFilter? getColorFilter(android.graphics.drawable.Drawable);
     method public static int getLayoutDirection(android.graphics.drawable.Drawable);
     method public static void inflate(android.graphics.drawable.Drawable, android.content.res.Resources, org.xmlpull.v1.XmlPullParser, android.util.AttributeSet, android.content.res.Resources.Theme?) throws java.io.IOException, org.xmlpull.v1.XmlPullParserException;
     method public static boolean isAutoMirrored(android.graphics.drawable.Drawable);
@@ -1363,20 +1363,20 @@
     method public static void setTintList(android.graphics.drawable.Drawable, android.content.res.ColorStateList?);
     method public static void setTintMode(android.graphics.drawable.Drawable, android.graphics.PorterDuff.Mode);
     method public static <T extends android.graphics.drawable.Drawable> T! unwrap(android.graphics.drawable.Drawable);
-    method public static android.graphics.drawable.Drawable! wrap(android.graphics.drawable.Drawable);
+    method public static android.graphics.drawable.Drawable wrap(android.graphics.drawable.Drawable);
   }
 
   public class IconCompat implements androidx.versionedparcelable.VersionedParcelable {
     method public static androidx.core.graphics.drawable.IconCompat? createFromBundle(android.os.Bundle);
     method @RequiresApi(23) public static androidx.core.graphics.drawable.IconCompat? createFromIcon(android.content.Context, android.graphics.drawable.Icon);
-    method public static androidx.core.graphics.drawable.IconCompat! createWithAdaptiveBitmap(android.graphics.Bitmap!);
+    method public static androidx.core.graphics.drawable.IconCompat createWithAdaptiveBitmap(android.graphics.Bitmap);
     method public static androidx.core.graphics.drawable.IconCompat createWithAdaptiveBitmapContentUri(String);
     method public static androidx.core.graphics.drawable.IconCompat createWithAdaptiveBitmapContentUri(android.net.Uri);
-    method public static androidx.core.graphics.drawable.IconCompat! createWithBitmap(android.graphics.Bitmap!);
-    method public static androidx.core.graphics.drawable.IconCompat! createWithContentUri(String!);
-    method public static androidx.core.graphics.drawable.IconCompat! createWithContentUri(android.net.Uri!);
-    method public static androidx.core.graphics.drawable.IconCompat! createWithData(byte[]!, int, int);
-    method public static androidx.core.graphics.drawable.IconCompat! createWithResource(android.content.Context!, @DrawableRes int);
+    method public static androidx.core.graphics.drawable.IconCompat createWithBitmap(android.graphics.Bitmap);
+    method public static androidx.core.graphics.drawable.IconCompat createWithContentUri(String);
+    method public static androidx.core.graphics.drawable.IconCompat createWithContentUri(android.net.Uri);
+    method public static androidx.core.graphics.drawable.IconCompat createWithData(byte[], int, int);
+    method public static androidx.core.graphics.drawable.IconCompat createWithResource(android.content.Context, @DrawableRes int);
     method @IdRes public int getResId();
     method public String getResPackage();
     method public int getType();
@@ -1384,9 +1384,9 @@
     method public android.graphics.drawable.Drawable? loadDrawable(android.content.Context);
     method public void onPostParceling();
     method public void onPreParceling(boolean);
-    method public androidx.core.graphics.drawable.IconCompat! setTint(@ColorInt int);
-    method public androidx.core.graphics.drawable.IconCompat! setTintList(android.content.res.ColorStateList!);
-    method public androidx.core.graphics.drawable.IconCompat! setTintMode(android.graphics.PorterDuff.Mode!);
+    method public androidx.core.graphics.drawable.IconCompat setTint(@ColorInt int);
+    method public androidx.core.graphics.drawable.IconCompat setTintList(android.content.res.ColorStateList?);
+    method public androidx.core.graphics.drawable.IconCompat setTintMode(android.graphics.PorterDuff.Mode?);
     method public android.os.Bundle toBundle();
     method @Deprecated @RequiresApi(23) public android.graphics.drawable.Icon toIcon();
     method @RequiresApi(23) public android.graphics.drawable.Icon toIcon(android.content.Context?);
diff --git a/core/core/api/restricted_current.txt b/core/core/api/restricted_current.txt
index 72c72f0..7322b0b2 100644
--- a/core/core/api/restricted_current.txt
+++ b/core/core/api/restricted_current.txt
@@ -1532,7 +1532,7 @@
     method public static androidx.core.graphics.Insets of(android.graphics.Rect);
     method public static androidx.core.graphics.Insets subtract(androidx.core.graphics.Insets, androidx.core.graphics.Insets);
     method @RequiresApi(api=29) public static androidx.core.graphics.Insets toCompatInsets(android.graphics.Insets);
-    method @RequiresApi(api=29) public android.graphics.Insets toPlatformInsets();
+    method @RequiresApi(29) public android.graphics.Insets toPlatformInsets();
     method @Deprecated @RequiresApi(api=29) @RestrictTo(androidx.annotation.RestrictTo.Scope.LIBRARY_GROUP_PREFIX) public static androidx.core.graphics.Insets wrap(android.graphics.Insets);
     field public static final androidx.core.graphics.Insets NONE;
     field public final int bottom;
@@ -1604,12 +1604,12 @@
   }
 
   @RestrictTo(androidx.annotation.RestrictTo.Scope.LIBRARY_GROUP_PREFIX) public class TypefaceCompatUtil {
-    method public static void closeQuietly(java.io.Closeable!);
-    method @RequiresApi(19) public static java.nio.ByteBuffer? copyToDirectBuffer(android.content.Context!, android.content.res.Resources!, int);
-    method public static boolean copyToFile(java.io.File!, java.io.InputStream!);
-    method public static boolean copyToFile(java.io.File!, android.content.res.Resources!, int);
-    method public static java.io.File? getTempFile(android.content.Context!);
-    method @RequiresApi(19) public static java.nio.ByteBuffer? mmap(android.content.Context!, android.os.CancellationSignal!, android.net.Uri!);
+    method public static void closeQuietly(java.io.Closeable?);
+    method @RequiresApi(19) public static java.nio.ByteBuffer? copyToDirectBuffer(android.content.Context, android.content.res.Resources, int);
+    method public static boolean copyToFile(java.io.File, java.io.InputStream);
+    method public static boolean copyToFile(java.io.File, android.content.res.Resources, int);
+    method public static java.io.File? getTempFile(android.content.Context);
+    method @RequiresApi(19) public static java.nio.ByteBuffer? mmap(android.content.Context, android.os.CancellationSignal?, android.net.Uri);
   }
 
 }
@@ -1621,7 +1621,7 @@
     method public static boolean canApplyTheme(android.graphics.drawable.Drawable);
     method public static void clearColorFilter(android.graphics.drawable.Drawable);
     method public static int getAlpha(android.graphics.drawable.Drawable);
-    method public static android.graphics.ColorFilter! getColorFilter(android.graphics.drawable.Drawable);
+    method public static android.graphics.ColorFilter? getColorFilter(android.graphics.drawable.Drawable);
     method public static int getLayoutDirection(android.graphics.drawable.Drawable);
     method public static void inflate(android.graphics.drawable.Drawable, android.content.res.Resources, org.xmlpull.v1.XmlPullParser, android.util.AttributeSet, android.content.res.Resources.Theme?) throws java.io.IOException, org.xmlpull.v1.XmlPullParserException;
     method public static boolean isAutoMirrored(android.graphics.drawable.Drawable);
@@ -1634,7 +1634,7 @@
     method public static void setTintList(android.graphics.drawable.Drawable, android.content.res.ColorStateList?);
     method public static void setTintMode(android.graphics.drawable.Drawable, android.graphics.PorterDuff.Mode);
     method public static <T extends android.graphics.drawable.Drawable> T! unwrap(android.graphics.drawable.Drawable);
-    method public static android.graphics.drawable.Drawable! wrap(android.graphics.drawable.Drawable);
+    method public static android.graphics.drawable.Drawable wrap(android.graphics.drawable.Drawable);
   }
 
   @androidx.versionedparcelable.VersionedParcelize(allowSerialization=true, ignoreParcelables=true, isCustom=true, jetifyAs="android.support.v4.graphics.drawable.IconCompat") public class IconCompat extends androidx.versionedparcelable.CustomVersionedParcelable {
@@ -1644,15 +1644,15 @@
     method @RequiresApi(23) public static androidx.core.graphics.drawable.IconCompat? createFromIcon(android.content.Context, android.graphics.drawable.Icon);
     method @RequiresApi(23) @RestrictTo(androidx.annotation.RestrictTo.Scope.LIBRARY_GROUP_PREFIX) public static androidx.core.graphics.drawable.IconCompat? createFromIcon(android.graphics.drawable.Icon);
     method @RequiresApi(23) @RestrictTo(androidx.annotation.RestrictTo.Scope.LIBRARY_GROUP_PREFIX) public static androidx.core.graphics.drawable.IconCompat? createFromIconOrNullIfZeroResId(android.graphics.drawable.Icon);
-    method public static androidx.core.graphics.drawable.IconCompat! createWithAdaptiveBitmap(android.graphics.Bitmap!);
+    method public static androidx.core.graphics.drawable.IconCompat createWithAdaptiveBitmap(android.graphics.Bitmap);
     method public static androidx.core.graphics.drawable.IconCompat createWithAdaptiveBitmapContentUri(String);
     method public static androidx.core.graphics.drawable.IconCompat createWithAdaptiveBitmapContentUri(android.net.Uri);
-    method public static androidx.core.graphics.drawable.IconCompat! createWithBitmap(android.graphics.Bitmap!);
-    method public static androidx.core.graphics.drawable.IconCompat! createWithContentUri(String!);
-    method public static androidx.core.graphics.drawable.IconCompat! createWithContentUri(android.net.Uri!);
-    method public static androidx.core.graphics.drawable.IconCompat! createWithData(byte[]!, int, int);
-    method public static androidx.core.graphics.drawable.IconCompat! createWithResource(android.content.Context!, @DrawableRes int);
-    method @RestrictTo(androidx.annotation.RestrictTo.Scope.LIBRARY_GROUP_PREFIX) public static androidx.core.graphics.drawable.IconCompat! createWithResource(android.content.res.Resources!, String!, @DrawableRes int);
+    method public static androidx.core.graphics.drawable.IconCompat createWithBitmap(android.graphics.Bitmap);
+    method public static androidx.core.graphics.drawable.IconCompat createWithContentUri(String);
+    method public static androidx.core.graphics.drawable.IconCompat createWithContentUri(android.net.Uri);
+    method public static androidx.core.graphics.drawable.IconCompat createWithData(byte[], int, int);
+    method public static androidx.core.graphics.drawable.IconCompat createWithResource(android.content.Context, @DrawableRes int);
+    method @RestrictTo(androidx.annotation.RestrictTo.Scope.LIBRARY_GROUP_PREFIX) public static androidx.core.graphics.drawable.IconCompat createWithResource(android.content.res.Resources?, String, @DrawableRes int);
     method @RestrictTo(androidx.annotation.RestrictTo.Scope.LIBRARY_GROUP_PREFIX) public android.graphics.Bitmap? getBitmap();
     method @IdRes public int getResId();
     method public String getResPackage();
@@ -1660,9 +1660,9 @@
     method public android.net.Uri getUri();
     method @RestrictTo(androidx.annotation.RestrictTo.Scope.LIBRARY_GROUP) public java.io.InputStream? getUriInputStream(android.content.Context);
     method public android.graphics.drawable.Drawable? loadDrawable(android.content.Context);
-    method public androidx.core.graphics.drawable.IconCompat! setTint(@ColorInt int);
-    method public androidx.core.graphics.drawable.IconCompat! setTintList(android.content.res.ColorStateList!);
-    method public androidx.core.graphics.drawable.IconCompat! setTintMode(android.graphics.PorterDuff.Mode!);
+    method public androidx.core.graphics.drawable.IconCompat setTint(@ColorInt int);
+    method public androidx.core.graphics.drawable.IconCompat setTintList(android.content.res.ColorStateList?);
+    method public androidx.core.graphics.drawable.IconCompat setTintMode(android.graphics.PorterDuff.Mode?);
     method public android.os.Bundle toBundle();
     method @Deprecated @RequiresApi(23) public android.graphics.drawable.Icon toIcon();
     method @RequiresApi(23) public android.graphics.drawable.Icon toIcon(android.content.Context?);
diff --git a/core/core/lint-baseline.xml b/core/core/lint-baseline.xml
index 79623f4..c1c27b8 100644
--- a/core/core/lint-baseline.xml
+++ b/core/core/lint-baseline.xml
@@ -3490,193 +3490,6 @@
 
     <issue
         id="ClassVerificationFailure"
-        message="This call references a method added in API level 19; however, the containing class androidx.core.graphics.ColorUtils is reachable from earlier API levels and will fail run-time class verification."
-        errorLine1="        if (!Objects.equals(foreground.getModel(), background.getModel())) {"
-        errorLine2="                     ~~~~~~">
-        <location
-            file="src/main/java/androidx/core/graphics/ColorUtils.java"
-            line="92"
-            column="22"/>
-    </issue>
-
-    <issue
-        id="ClassVerificationFailure"
-        message="This call references a method added in API level 26; however, the containing class androidx.core.graphics.ColorUtils is reachable from earlier API levels and will fail run-time class verification."
-        errorLine1="        if (!Objects.equals(foreground.getModel(), background.getModel())) {"
-        errorLine2="                                       ~~~~~~~~">
-        <location
-            file="src/main/java/androidx/core/graphics/ColorUtils.java"
-            line="92"
-            column="40"/>
-    </issue>
-
-    <issue
-        id="ClassVerificationFailure"
-        message="This call references a method added in API level 26; however, the containing class androidx.core.graphics.ColorUtils is reachable from earlier API levels and will fail run-time class verification."
-        errorLine1="        if (!Objects.equals(foreground.getModel(), background.getModel())) {"
-        errorLine2="                                                              ~~~~~~~~">
-        <location
-            file="src/main/java/androidx/core/graphics/ColorUtils.java"
-            line="92"
-            column="63"/>
-    </issue>
-
-    <issue
-        id="ClassVerificationFailure"
-        message="This call references a method added in API level 26; however, the containing class androidx.core.graphics.ColorUtils is reachable from earlier API levels and will fail run-time class verification."
-        errorLine1="                    &quot;Color models must match (&quot; + foreground.getModel() + &quot; vs. &quot;"
-        errorLine2="                                                             ~~~~~~~~">
-        <location
-            file="src/main/java/androidx/core/graphics/ColorUtils.java"
-            line="94"
-            column="62"/>
-    </issue>
-
-    <issue
-        id="ClassVerificationFailure"
-        message="This call references a method added in API level 26; however, the containing class androidx.core.graphics.ColorUtils is reachable from earlier API levels and will fail run-time class verification."
-        errorLine1="                            + background.getModel() + &quot;)&quot;);"
-        errorLine2="                                         ~~~~~~~~">
-        <location
-            file="src/main/java/androidx/core/graphics/ColorUtils.java"
-            line="95"
-            column="42"/>
-    </issue>
-
-    <issue
-        id="ClassVerificationFailure"
-        message="This call references a method added in API level 19; however, the containing class androidx.core.graphics.ColorUtils is reachable from earlier API levels and will fail run-time class verification."
-        errorLine1="        Color s = Objects.equals(background.getColorSpace(), foreground.getColorSpace())"
-        errorLine2="                          ~~~~~~">
-        <location
-            file="src/main/java/androidx/core/graphics/ColorUtils.java"
-            line="98"
-            column="27"/>
-    </issue>
-
-    <issue
-        id="ClassVerificationFailure"
-        message="This call references a method added in API level 26; however, the containing class androidx.core.graphics.ColorUtils is reachable from earlier API levels and will fail run-time class verification."
-        errorLine1="        Color s = Objects.equals(background.getColorSpace(), foreground.getColorSpace())"
-        errorLine2="                                            ~~~~~~~~~~~~~">
-        <location
-            file="src/main/java/androidx/core/graphics/ColorUtils.java"
-            line="98"
-            column="45"/>
-    </issue>
-
-    <issue
-        id="ClassVerificationFailure"
-        message="This call references a method added in API level 26; however, the containing class androidx.core.graphics.ColorUtils is reachable from earlier API levels and will fail run-time class verification."
-        errorLine1="        Color s = Objects.equals(background.getColorSpace(), foreground.getColorSpace())"
-        errorLine2="                                                                        ~~~~~~~~~~~~~">
-        <location
-            file="src/main/java/androidx/core/graphics/ColorUtils.java"
-            line="98"
-            column="73"/>
-    </issue>
-
-    <issue
-        id="ClassVerificationFailure"
-        message="This call references a method added in API level 26; however, the containing class androidx.core.graphics.ColorUtils is reachable from earlier API levels and will fail run-time class verification."
-        errorLine1="                : foreground.convert(background.getColorSpace());"
-        errorLine2="                             ~~~~~~~">
-        <location
-            file="src/main/java/androidx/core/graphics/ColorUtils.java"
-            line="100"
-            column="30"/>
-    </issue>
-
-    <issue
-        id="ClassVerificationFailure"
-        message="This call references a method added in API level 26; however, the containing class androidx.core.graphics.ColorUtils is reachable from earlier API levels and will fail run-time class verification."
-        errorLine1="                : foreground.convert(background.getColorSpace());"
-        errorLine2="                                                ~~~~~~~~~~~~~">
-        <location
-            file="src/main/java/androidx/core/graphics/ColorUtils.java"
-            line="100"
-            column="49"/>
-    </issue>
-
-    <issue
-        id="ClassVerificationFailure"
-        message="This call references a method added in API level 26; however, the containing class androidx.core.graphics.ColorUtils is reachable from earlier API levels and will fail run-time class verification."
-        errorLine1="        float[] src = s.getComponents();"
-        errorLine2="                        ~~~~~~~~~~~~~">
-        <location
-            file="src/main/java/androidx/core/graphics/ColorUtils.java"
-            line="102"
-            column="25"/>
-    </issue>
-
-    <issue
-        id="ClassVerificationFailure"
-        message="This call references a method added in API level 26; however, the containing class androidx.core.graphics.ColorUtils is reachable from earlier API levels and will fail run-time class verification."
-        errorLine1="        float[] dst = background.getComponents();"
-        errorLine2="                                 ~~~~~~~~~~~~~">
-        <location
-            file="src/main/java/androidx/core/graphics/ColorUtils.java"
-            line="103"
-            column="34"/>
-    </issue>
-
-    <issue
-        id="ClassVerificationFailure"
-        message="This call references a method added in API level 26; however, the containing class androidx.core.graphics.ColorUtils is reachable from earlier API levels and will fail run-time class verification."
-        errorLine1="        float sa = s.alpha();"
-        errorLine2="                     ~~~~~">
-        <location
-            file="src/main/java/androidx/core/graphics/ColorUtils.java"
-            line="105"
-            column="22"/>
-    </issue>
-
-    <issue
-        id="ClassVerificationFailure"
-        message="This call references a method added in API level 26; however, the containing class androidx.core.graphics.ColorUtils is reachable from earlier API levels and will fail run-time class verification."
-        errorLine1="        float da = background.alpha() * (1.0f - sa);"
-        errorLine2="                              ~~~~~">
-        <location
-            file="src/main/java/androidx/core/graphics/ColorUtils.java"
-            line="107"
-            column="31"/>
-    </issue>
-
-    <issue
-        id="ClassVerificationFailure"
-        message="This call references a method added in API level 26; however, the containing class androidx.core.graphics.ColorUtils is reachable from earlier API levels and will fail run-time class verification."
-        errorLine1="        int ai = background.getComponentCount() - 1;"
-        errorLine2="                            ~~~~~~~~~~~~~~~~~">
-        <location
-            file="src/main/java/androidx/core/graphics/ColorUtils.java"
-            line="111"
-            column="29"/>
-    </issue>
-
-    <issue
-        id="ClassVerificationFailure"
-        message="This call references a method added in API level 26; however, the containing class androidx.core.graphics.ColorUtils is reachable from earlier API levels and will fail run-time class verification."
-        errorLine1="        return Color.valueOf(dst, background.getColorSpace());"
-        errorLine2="                     ~~~~~~~">
-        <location
-            file="src/main/java/androidx/core/graphics/ColorUtils.java"
-            line="127"
-            column="22"/>
-    </issue>
-
-    <issue
-        id="ClassVerificationFailure"
-        message="This call references a method added in API level 26; however, the containing class androidx.core.graphics.ColorUtils is reachable from earlier API levels and will fail run-time class verification."
-        errorLine1="        return Color.valueOf(dst, background.getColorSpace());"
-        errorLine2="                                             ~~~~~~~~~~~~~">
-        <location
-            file="src/main/java/androidx/core/graphics/ColorUtils.java"
-            line="127"
-            column="46"/>
-    </issue>
-
-    <issue
-        id="ClassVerificationFailure"
         message="This call references a method added in API level 24; however, the containing class androidx.core.os.ConfigurationCompat is reachable from earlier API levels and will fail run-time class verification."
         errorLine1="            return LocaleListCompat.wrap(configuration.getLocales());"
         errorLine2="                                                       ~~~~~~~~~~">
@@ -4282,204 +4095,6 @@
 
     <issue
         id="ClassVerificationFailure"
-        message="This call references a method added in API level 23; however, the containing class androidx.core.graphics.drawable.IconCompat is reachable from earlier API levels and will fail run-time class verification."
-        errorLine1="                icon = Icon.createWithBitmap((Bitmap) mObj1);"
-        errorLine2="                            ~~~~~~~~~~~~~~~~">
-        <location
-            file="src/main/java/androidx/core/graphics/drawable/IconCompat.java"
-            line="546"
-            column="29"/>
-    </issue>
-
-    <issue
-        id="ClassVerificationFailure"
-        message="This call references a method added in API level 26; however, the containing class androidx.core.graphics.drawable.IconCompat is reachable from earlier API levels and will fail run-time class verification."
-        errorLine1="                    icon = Icon.createWithAdaptiveBitmap((Bitmap) mObj1);"
-        errorLine2="                                ~~~~~~~~~~~~~~~~~~~~~~~~">
-        <location
-            file="src/main/java/androidx/core/graphics/drawable/IconCompat.java"
-            line="550"
-            column="33"/>
-    </issue>
-
-    <issue
-        id="ClassVerificationFailure"
-        message="This call references a method added in API level 23; however, the containing class androidx.core.graphics.drawable.IconCompat is reachable from earlier API levels and will fail run-time class verification."
-        errorLine1="                    icon = Icon.createWithBitmap("
-        errorLine2="                                ~~~~~~~~~~~~~~~~">
-        <location
-            file="src/main/java/androidx/core/graphics/drawable/IconCompat.java"
-            line="552"
-            column="33"/>
-    </issue>
-
-    <issue
-        id="ClassVerificationFailure"
-        message="This call references a method added in API level 23; however, the containing class androidx.core.graphics.drawable.IconCompat is reachable from earlier API levels and will fail run-time class verification."
-        errorLine1="                icon = Icon.createWithResource(getResPackage(), mInt1);"
-        errorLine2="                            ~~~~~~~~~~~~~~~~~~">
-        <location
-            file="src/main/java/androidx/core/graphics/drawable/IconCompat.java"
-            line="557"
-            column="29"/>
-    </issue>
-
-    <issue
-        id="ClassVerificationFailure"
-        message="This call references a method added in API level 23; however, the containing class androidx.core.graphics.drawable.IconCompat is reachable from earlier API levels and will fail run-time class verification."
-        errorLine1="                icon = Icon.createWithData((byte[]) mObj1, mInt1, mInt2);"
-        errorLine2="                            ~~~~~~~~~~~~~~">
-        <location
-            file="src/main/java/androidx/core/graphics/drawable/IconCompat.java"
-            line="560"
-            column="29"/>
-    </issue>
-
-    <issue
-        id="ClassVerificationFailure"
-        message="This call references a method added in API level 23; however, the containing class androidx.core.graphics.drawable.IconCompat is reachable from earlier API levels and will fail run-time class verification."
-        errorLine1="                icon = Icon.createWithContentUri((String) mObj1);"
-        errorLine2="                            ~~~~~~~~~~~~~~~~~~~~">
-        <location
-            file="src/main/java/androidx/core/graphics/drawable/IconCompat.java"
-            line="563"
-            column="29"/>
-    </issue>
-
-    <issue
-        id="ClassVerificationFailure"
-        message="This call references a method added in API level 30; however, the containing class androidx.core.graphics.drawable.IconCompat is reachable from earlier API levels and will fail run-time class verification."
-        errorLine1="                    icon = Icon.createWithAdaptiveBitmapContentUri(getUri());"
-        errorLine2="                                ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~">
-        <location
-            file="src/main/java/androidx/core/graphics/drawable/IconCompat.java"
-            line="567"
-            column="33"/>
-    </issue>
-
-    <issue
-        id="ClassVerificationFailure"
-        message="This call references a method added in API level 26; however, the containing class androidx.core.graphics.drawable.IconCompat is reachable from earlier API levels and will fail run-time class verification."
-        errorLine1="                    icon = Icon.createWithAdaptiveBitmap(BitmapFactory.decodeStream(is));"
-        errorLine2="                                ~~~~~~~~~~~~~~~~~~~~~~~~">
-        <location
-            file="src/main/java/androidx/core/graphics/drawable/IconCompat.java"
-            line="580"
-            column="33"/>
-    </issue>
-
-    <issue
-        id="ClassVerificationFailure"
-        message="This call references a method added in API level 23; however, the containing class androidx.core.graphics.drawable.IconCompat is reachable from earlier API levels and will fail run-time class verification."
-        errorLine1="                    icon = Icon.createWithBitmap(createLegacyIconFromAdaptiveIcon("
-        errorLine2="                                ~~~~~~~~~~~~~~~~">
-        <location
-            file="src/main/java/androidx/core/graphics/drawable/IconCompat.java"
-            line="582"
-            column="33"/>
-    </issue>
-
-    <issue
-        id="ClassVerificationFailure"
-        message="This call references a method added in API level 23; however, the containing class androidx.core.graphics.drawable.IconCompat is reachable from earlier API levels and will fail run-time class verification."
-        errorLine1="            icon.setTintList(mTintList);"
-        errorLine2="                 ~~~~~~~~~~~">
-        <location
-            file="src/main/java/androidx/core/graphics/drawable/IconCompat.java"
-            line="590"
-            column="18"/>
-    </issue>
-
-    <issue
-        id="ClassVerificationFailure"
-        message="This call references a method added in API level 23; however, the containing class androidx.core.graphics.drawable.IconCompat is reachable from earlier API levels and will fail run-time class verification."
-        errorLine1="            icon.setTintMode(mTintMode);"
-        errorLine2="                 ~~~~~~~~~~~">
-        <location
-            file="src/main/java/androidx/core/graphics/drawable/IconCompat.java"
-            line="593"
-            column="18"/>
-    </issue>
-
-    <issue
-        id="ClassVerificationFailure"
-        message="This call references a method added in API level 23; however, the containing class androidx.core.graphics.drawable.IconCompat is reachable from earlier API levels and will fail run-time class verification."
-        errorLine1="            return toIcon(context).loadDrawable(context);"
-        errorLine2="                                   ~~~~~~~~~~~~">
-        <location
-            file="src/main/java/androidx/core/graphics/drawable/IconCompat.java"
-            line="641"
-            column="36"/>
-    </issue>
-
-    <issue
-        id="ClassVerificationFailure"
-        message="This call references a method added in API level 26; however, the containing class androidx.core.graphics.drawable.IconCompat is reachable from earlier API levels and will fail run-time class verification."
-        errorLine1="                        return new AdaptiveIconDrawable(null,"
-        errorLine2="                               ~~~~~~~~~~~~~~~~~~~~~~~~">
-        <location
-            file="src/main/java/androidx/core/graphics/drawable/IconCompat.java"
-            line="694"
-            column="32"/>
-    </issue>
-
-    <issue
-        id="ClassVerificationFailure"
-        message="This call references a method added in API level 28; however, the containing class androidx.core.graphics.drawable.IconCompat is reachable from earlier API levels and will fail run-time class verification."
-        errorLine1="            return icon.getType();"
-        errorLine2="                        ~~~~~~~">
-        <location
-            file="src/main/java/androidx/core/graphics/drawable/IconCompat.java"
-            line="1101"
-            column="25"/>
-    </issue>
-
-    <issue
-        id="ClassVerificationFailure"
-        message="This call references a method added in API level 28; however, the containing class androidx.core.graphics.drawable.IconCompat is reachable from earlier API levels and will fail run-time class verification."
-        errorLine1="            return icon.getResPackage();"
-        errorLine2="                        ~~~~~~~~~~~~~">
-        <location
-            file="src/main/java/androidx/core/graphics/drawable/IconCompat.java"
-            line="1129"
-            column="25"/>
-    </issue>
-
-    <issue
-        id="ClassVerificationFailure"
-        message="This call references a method added in API level 28; however, the containing class androidx.core.graphics.drawable.IconCompat is reachable from earlier API levels and will fail run-time class verification."
-        errorLine1="            return icon.getResId();"
-        errorLine2="                        ~~~~~~~~">
-        <location
-            file="src/main/java/androidx/core/graphics/drawable/IconCompat.java"
-            line="1158"
-            column="25"/>
-    </issue>
-
-    <issue
-        id="ClassVerificationFailure"
-        message="This call references a method added in API level 28; however, the containing class androidx.core.graphics.drawable.IconCompat is reachable from earlier API levels and will fail run-time class verification."
-        errorLine1="            return icon.getUri();"
-        errorLine2="                        ~~~~~~">
-        <location
-            file="src/main/java/androidx/core/graphics/drawable/IconCompat.java"
-            line="1186"
-            column="25"/>
-    </issue>
-
-    <issue
-        id="ClassVerificationFailure"
-        message="This call references a method added in API level 29; however, the containing class androidx.core.graphics.Insets is reachable from earlier API levels and will fail run-time class verification."
-        errorLine1="        return android.graphics.Insets.of(left, top, right, bottom);"
-        errorLine2="                                       ~~">
-        <location
-            file="src/main/java/androidx/core/graphics/Insets.java"
-            line="198"
-            column="40"/>
-    </issue>
-
-    <issue
-        id="ClassVerificationFailure"
         message="This call references a method added in API level 24; however, the containing class androidx.core.os.LocaleListCompat is reachable from earlier API levels and will fail run-time class verification."
         errorLine1="            return wrap(new LocaleList(localeList));"
         errorLine2="                        ~~~~~~~~~~~~~~">
@@ -7087,39 +6702,6 @@
 
     <issue
         id="ClassVerificationFailure"
-        message="This call references a method added in API level 23; however, the containing class androidx.core.graphics.PaintCompat is reachable from earlier API levels and will fail run-time class verification."
-        errorLine1="            return paint.hasGlyph(string);"
-        errorLine2="                         ~~~~~~~~">
-        <location
-            file="src/main/java/androidx/core/graphics/PaintCompat.java"
-            line="52"
-            column="26"/>
-    </issue>
-
-    <issue
-        id="ClassVerificationFailure"
-        message="This call references a method added in API level 29; however, the containing class androidx.core.graphics.PaintCompat is reachable from earlier API levels and will fail run-time class verification."
-        errorLine1="            paint.setBlendMode(blendMode != null ? obtainBlendModeFromCompat(blendMode) : null);"
-        errorLine2="                  ~~~~~~~~~~~~">
-        <location
-            file="src/main/java/androidx/core/graphics/PaintCompat.java"
-            line="127"
-            column="19"/>
-    </issue>
-
-    <issue
-        id="ClassVerificationFailure"
-        message="This call references a method added in API level 26; however, the containing class androidx.core.graphics.PathUtils is reachable from earlier API levels and will fail run-time class verification."
-        errorLine1="        float[] pathData = path.approximate(error);"
-        errorLine2="                                ~~~~~~~~~~~">
-        <location
-            file="src/main/java/androidx/core/graphics/PathUtils.java"
-            line="60"
-            column="33"/>
-    </issue>
-
-    <issue
-        id="ClassVerificationFailure"
         message="This call references a method added in API level 21; however, the containing class androidx.core.app.Person is reachable from earlier API levels and will fail run-time class verification."
         errorLine1="                .setName(bundle.getString(NAME_KEY))"
         errorLine2="                                ~~~~~~~~~">
@@ -9507,17 +9089,6 @@
 
     <issue
         id="ClassVerificationFailure"
-        message="This call references a method added in API level 19; however, the containing class androidx.core.graphics.TypefaceCompatUtil is reachable from earlier API levels and will fail run-time class verification."
-        errorLine1="        try (ParcelFileDescriptor pfd = resolver.openFileDescriptor(uri, &quot;r&quot;, cancellationSignal)) {"
-        errorLine2="                                                 ~~~~~~~~~~~~~~~~~~">
-        <location
-            file="src/main/java/androidx/core/graphics/TypefaceCompatUtil.java"
-            line="110"
-            column="50"/>
-    </issue>
-
-    <issue
-        id="ClassVerificationFailure"
         message="This call references a method added in API level 23; however, the containing class androidx.core.os.UserManagerCompat is reachable from earlier API levels and will fail run-time class verification."
         errorLine1="            return context.getSystemService(UserManager.class).isUserUnlocked();"
         errorLine2="                           ~~~~~~~~~~~~~~~~">
diff --git a/core/core/src/main/java/androidx/core/graphics/ColorUtils.java b/core/core/src/main/java/androidx/core/graphics/ColorUtils.java
index 6c1e37f..a7afe56 100644
--- a/core/core/src/main/java/androidx/core/graphics/ColorUtils.java
+++ b/core/core/src/main/java/androidx/core/graphics/ColorUtils.java
@@ -20,6 +20,7 @@
 import android.graphics.Color;
 
 import androidx.annotation.ColorInt;
+import androidx.annotation.DoNotInline;
 import androidx.annotation.FloatRange;
 import androidx.annotation.IntRange;
 import androidx.annotation.NonNull;
@@ -89,42 +90,54 @@
     @RequiresApi(26)
     @NonNull
     public static Color compositeColors(@NonNull Color foreground, @NonNull Color background) {
-        if (!Objects.equals(foreground.getModel(), background.getModel())) {
-            throw new IllegalArgumentException(
-                    "Color models must match (" + foreground.getModel() + " vs. "
-                            + background.getModel() + ")");
+        return Api26Impl.compositeColors(foreground, background);
+    }
+
+    @RequiresApi(26)
+    static class Api26Impl {
+        private Api26Impl() {
+            // This class is not instantiable.
         }
 
-        Color s = Objects.equals(background.getColorSpace(), foreground.getColorSpace())
-                ? foreground
-                : foreground.convert(background.getColorSpace());
+        @DoNotInline
+        static Color compositeColors(Color foreground, Color background) {
+            if (!Objects.equals(foreground.getModel(), background.getModel())) {
+                throw new IllegalArgumentException(
+                        "Color models must match (" + foreground.getModel() + " vs. "
+                                + background.getModel() + ")");
+            }
 
-        float[] src = s.getComponents();
-        float[] dst = background.getComponents();
+            Color s = Objects.equals(background.getColorSpace(), foreground.getColorSpace())
+                    ? foreground
+                    : foreground.convert(background.getColorSpace());
 
-        float sa = s.alpha();
-        // Destination alpha pre-composited
-        float da = background.alpha() * (1.0f - sa);
+            float[] src = s.getComponents();
+            float[] dst = background.getComponents();
 
-        // Index of the alpha component
-        @SuppressLint("Range") // TODO Remove after upgrading Android Gradle Plugin to 3.1 or newer.
-        int ai = background.getComponentCount() - 1;
+            float sa = s.alpha();
+            // Destination alpha pre-composited
+            float da = background.alpha() * (1.0f - sa);
 
-        // Final alpha: src_alpha + dst_alpha * (1 - src_alpha)
-        dst[ai] = sa + da;
+            // Index of the alpha component
+            @SuppressLint("Range") // TODO Remove after upgrading AGP to 3.1 or newer.
+            int ai = background.getComponentCount() - 1;
 
-        // Divide by final alpha to return non pre-multiplied color
-        if (dst[ai] > 0) {
-            sa /= dst[ai];
-            da /= dst[ai];
+            // Final alpha: src_alpha + dst_alpha * (1 - src_alpha)
+            dst[ai] = sa + da;
+
+            // Divide by final alpha to return non pre-multiplied color
+            if (dst[ai] > 0) {
+                sa /= dst[ai];
+                da /= dst[ai];
+            }
+
+            // Composite non-alpha components
+            for (int i = 0; i < ai; i++) {
+                dst[i] = src[i] * sa + dst[i] * da;
+            }
+
+            return Color.valueOf(dst, background.getColorSpace());
         }
-
-        // Composite non-alpha components
-        for (int i = 0; i < ai; i++) {
-            dst[i] = src[i] * sa + dst[i] * da;
-        }
-
-        return Color.valueOf(dst, background.getColorSpace());
     }
 
     private static int compositeAlpha(int foregroundAlpha, int backgroundAlpha) {
@@ -575,18 +588,21 @@
     /**
      * Returns the euclidean distance between two LAB colors.
      */
+    @SuppressWarnings("unused")
     public static double distanceEuclidean(@NonNull double[] labX, @NonNull double[] labY) {
         return Math.sqrt(Math.pow(labX[0] - labY[0], 2)
                 + Math.pow(labX[1] - labY[1], 2)
                 + Math.pow(labX[2] - labY[2], 2));
     }
 
+    @SuppressWarnings("SameParameterValue")
     private static float constrain(float amount, float low, float high) {
-        return amount < low ? low : (amount > high ? high : amount);
+        return amount < low ? low : Math.min(amount, high);
     }
 
+    @SuppressWarnings("SameParameterValue")
     private static int constrain(int amount, int low, int high) {
-        return amount < low ? low : (amount > high ? high : amount);
+        return amount < low ? low : Math.min(amount, high);
     }
 
     private static double pivotXyzComponent(double component) {
@@ -605,6 +621,7 @@
      * @param color2 the second ARGB color
      * @param ratio  the blend ratio of {@code color1} to {@code color2}
      */
+    @SuppressWarnings("unused")
     @ColorInt
     public static int blendARGB(@ColorInt int color1, @ColorInt int color2,
             @FloatRange(from = 0.0, to = 1.0) float ratio) {
@@ -628,6 +645,7 @@
      * @param ratio     the blend ratio of {@code hsl1} to {@code hsl2}
      * @param outResult 3-element array which holds the resulting HSL components
      */
+    @SuppressWarnings("unused")
     public static void blendHSL(@NonNull float[] hsl1, @NonNull float[] hsl2,
             @FloatRange(from = 0.0, to = 1.0) float ratio, @NonNull float[] outResult) {
         if (outResult.length != 3) {
@@ -651,6 +669,7 @@
      * @param ratio     the blend ratio of {@code lab1} to {@code lab2}
      * @param outResult 3-element array which holds the resulting LAB components
      */
+    @SuppressWarnings("unused")
     public static void blendLAB(@NonNull double[] lab1, @NonNull double[] lab2,
             @FloatRange(from = 0.0, to = 1.0) double ratio, @NonNull double[] outResult) {
         if (outResult.length != 3) {
diff --git a/core/core/src/main/java/androidx/core/graphics/Insets.java b/core/core/src/main/java/androidx/core/graphics/Insets.java
index b718179..3387d00 100644
--- a/core/core/src/main/java/androidx/core/graphics/Insets.java
+++ b/core/core/src/main/java/androidx/core/graphics/Insets.java
@@ -20,6 +20,7 @@
 
 import android.graphics.Rect;
 
+import androidx.annotation.DoNotInline;
 import androidx.annotation.NonNull;
 import androidx.annotation.RequiresApi;
 import androidx.annotation.RestrictTo;
@@ -96,6 +97,7 @@
      * @param b The subtrahend; the value which will be subtracted from {@code a}.
      * @return a - b, i. e. all insets on every side are subtracted from each other.
      */
+    @SuppressWarnings("unused")
     @NonNull
     public static Insets subtract(@NonNull Insets a, @NonNull Insets b) {
         return Insets.of(a.left - b.left, a.top - b.top, a.right - b.right, a.bottom - b.bottom);
@@ -136,6 +138,7 @@
      * @param o the object to compare this instance with.
      * @return true iff this object is equal {@code o}
      */
+    @SuppressWarnings("RedundantIfStatement")
     @Override
     public boolean equals(Object o) {
         if (this == o) return true;
@@ -160,6 +163,7 @@
         return result;
     }
 
+    @NonNull
     @Override
     public String toString() {
         return "Insets{left=" + left + ", top=" + top
@@ -192,9 +196,21 @@
      * Return a copy this instance, converted to be an {@link android.graphics.Insets} instance
      * from the platform.
      */
-    @RequiresApi(api = 29)
+    @RequiresApi(29)
     @NonNull
     public android.graphics.Insets toPlatformInsets() {
-        return android.graphics.Insets.of(left, top, right, bottom);
+        return Api29Impl.of(left, top, right, bottom);
+    }
+
+    @RequiresApi(29)
+    static class Api29Impl {
+        private Api29Impl() {
+            // This class is not instantiable.
+        }
+
+        @DoNotInline
+        static android.graphics.Insets of(int left, int top, int right, int bottom) {
+            return android.graphics.Insets.of(left, top, right, bottom);
+        }
     }
 }
diff --git a/core/core/src/main/java/androidx/core/graphics/PaintCompat.java b/core/core/src/main/java/androidx/core/graphics/PaintCompat.java
index 61673fe..73862de 100644
--- a/core/core/src/main/java/androidx/core/graphics/PaintCompat.java
+++ b/core/core/src/main/java/androidx/core/graphics/PaintCompat.java
@@ -19,14 +19,17 @@
 import static androidx.core.graphics.BlendModeUtils.obtainBlendModeFromCompat;
 import static androidx.core.graphics.BlendModeUtils.obtainPorterDuffFromCompat;
 
+import android.graphics.BlendMode;
 import android.graphics.Paint;
 import android.graphics.PorterDuff;
 import android.graphics.PorterDuffXfermode;
 import android.graphics.Rect;
 import android.os.Build;
 
+import androidx.annotation.DoNotInline;
 import androidx.annotation.NonNull;
 import androidx.annotation.Nullable;
+import androidx.annotation.RequiresApi;
 import androidx.core.util.Pair;
 
 /**
@@ -49,7 +52,7 @@
      */
     public static boolean hasGlyph(@NonNull Paint paint, @NonNull String string) {
         if (Build.VERSION.SDK_INT >= 23) {
-            return paint.hasGlyph(string);
+            return Api23Impl.hasGlyph(paint, string);
         }
         final int length = string.length();
 
@@ -124,7 +127,8 @@
      */
     public static boolean setBlendMode(@NonNull Paint paint, @Nullable BlendModeCompat blendMode) {
         if (Build.VERSION.SDK_INT >= 29) {
-            paint.setBlendMode(blendMode != null ? obtainBlendModeFromCompat(blendMode) : null);
+            Api29Impl.setBlendMode(paint,
+                    blendMode != null ? obtainBlendModeFromCompat(blendMode) : null);
             // All blend modes supported in Q
             return true;
         } else if (blendMode != null) {
@@ -153,5 +157,30 @@
         return rects;
     }
 
-    private PaintCompat() {}
+    private PaintCompat() {
+    }
+
+    @RequiresApi(23)
+    static class Api23Impl {
+        private Api23Impl() {
+            // This class is not instantiable.
+        }
+
+        @DoNotInline
+        static boolean hasGlyph(Paint paint, String string) {
+            return paint.hasGlyph(string);
+        }
+    }
+
+    @RequiresApi(29)
+    static class Api29Impl {
+        private Api29Impl() {
+            // This class is not instantiable.
+        }
+
+        @DoNotInline
+        static void setBlendMode(Paint paint, BlendMode blendmode) {
+            paint.setBlendMode(blendmode);
+        }
+    }
 }
diff --git a/core/core/src/main/java/androidx/core/graphics/PathUtils.java b/core/core/src/main/java/androidx/core/graphics/PathUtils.java
index 65e49f6..8c88875 100644
--- a/core/core/src/main/java/androidx/core/graphics/PathUtils.java
+++ b/core/core/src/main/java/androidx/core/graphics/PathUtils.java
@@ -19,6 +19,7 @@
 import android.graphics.Path;
 import android.graphics.PointF;
 
+import androidx.annotation.DoNotInline;
 import androidx.annotation.FloatRange;
 import androidx.annotation.NonNull;
 import androidx.annotation.RequiresApi;
@@ -57,7 +58,7 @@
     @NonNull
     public static Collection<PathSegment> flatten(@NonNull final Path path,
             @FloatRange(from = 0) final float error) {
-        float[] pathData = path.approximate(error);
+        float[] pathData = Api26Impl.approximate(path, error);
         int pointCount = pathData.length / 3;
         List<PathSegment> segments = new ArrayList<>(pointCount);
         for (int i = 1; i < pointCount; i++) {
@@ -81,4 +82,16 @@
 
     private PathUtils() {
     }
+
+    @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/src/main/java/androidx/core/graphics/TypefaceCompatUtil.java b/core/core/src/main/java/androidx/core/graphics/TypefaceCompatUtil.java
index 1f02d66..85c9e3c 100644
--- a/core/core/src/main/java/androidx/core/graphics/TypefaceCompatUtil.java
+++ b/core/core/src/main/java/androidx/core/graphics/TypefaceCompatUtil.java
@@ -29,6 +29,7 @@
 import android.os.StrictMode;
 import android.util.Log;
 
+import androidx.annotation.DoNotInline;
 import androidx.annotation.NonNull;
 import androidx.annotation.Nullable;
 import androidx.annotation.RequiresApi;
@@ -38,6 +39,7 @@
 import java.io.Closeable;
 import java.io.File;
 import java.io.FileInputStream;
+import java.io.FileNotFoundException;
 import java.io.FileOutputStream;
 import java.io.IOException;
 import java.io.InputStream;
@@ -65,7 +67,7 @@
      * Returns null if failed to create temp file.
      */
     @Nullable
-    public static File getTempFile(Context context) {
+    public static File getTempFile(@NonNull Context context) {
         File cacheDir = context.getCacheDir();
         if (cacheDir == null) {
             return null;
@@ -105,9 +107,11 @@
      */
     @Nullable
     @RequiresApi(19)
-    public static ByteBuffer mmap(Context context, CancellationSignal cancellationSignal, Uri uri) {
+    public static ByteBuffer mmap(@NonNull Context context,
+            @Nullable CancellationSignal cancellationSignal, @NonNull Uri uri) {
         final ContentResolver resolver = context.getContentResolver();
-        try (ParcelFileDescriptor pfd = resolver.openFileDescriptor(uri, "r", cancellationSignal)) {
+        try (ParcelFileDescriptor pfd = Api19Impl.openFileDescriptor(resolver, uri, "r",
+                cancellationSignal)) {
             if (pfd == null) {
                 return null;
             }
@@ -124,9 +128,11 @@
     /**
      * Copy the resource contents to the direct byte buffer.
      */
+    @SuppressWarnings("ResultOfMethodCallIgnored")
     @Nullable
     @RequiresApi(19)
-    public static ByteBuffer copyToDirectBuffer(Context context, Resources res, int id) {
+    public static ByteBuffer copyToDirectBuffer(@NonNull Context context, @NonNull Resources res,
+            int id) {
         File tmpFile = getTempFile(context);
         if (tmpFile == null) {
             return null;
@@ -144,7 +150,7 @@
     /**
      * Copy the input stream contents to file.
      */
-    public static boolean copyToFile(File file, InputStream is) {
+    public static boolean copyToFile(@NonNull File file, @NonNull InputStream is) {
         FileOutputStream os = null;
         StrictMode.ThreadPolicy old = StrictMode.allowThreadDiskWrites();
         try {
@@ -167,7 +173,8 @@
     /**
      * Copy the resource contents to file.
      */
-    public static boolean copyToFile(File file, Resources res, int id) {
+    @SuppressWarnings("BooleanMethodIsAlwaysInverted")
+    public static boolean copyToFile(@NonNull File file, @NonNull Resources res, int id) {
         InputStream is = null;
         try {
             is = res.openRawResource(id);
@@ -177,11 +184,17 @@
         }
     }
 
-    public static void closeQuietly(Closeable c) {
+    /**
+     * Attempts to close a Closeable, swallowing any resulting IOException.
+     *
+     * @param c the closeable to close
+     */
+    public static void closeQuietly(@Nullable Closeable c) {
         if (c != null) {
             try {
                 c.close();
             } catch (IOException e) {
+                // Quietly!
             }
         }
     }
@@ -222,4 +235,18 @@
         }
         return Collections.unmodifiableMap(out);
     }
+
+    @RequiresApi(19)
+    static class Api19Impl {
+        private Api19Impl() {
+            // This class is not instantiable.
+        }
+
+        @SuppressWarnings("SameParameterValue")
+        @DoNotInline
+        static ParcelFileDescriptor openFileDescriptor(ContentResolver contentResolver, Uri uri,
+                String mode, CancellationSignal cancellationSignal) throws FileNotFoundException {
+            return contentResolver.openFileDescriptor(uri, mode, cancellationSignal);
+        }
+    }
 }
diff --git a/core/core/src/main/java/androidx/core/graphics/drawable/DrawableCompat.java b/core/core/src/main/java/androidx/core/graphics/drawable/DrawableCompat.java
index d81ba22..8e96af8 100644
--- a/core/core/src/main/java/androidx/core/graphics/drawable/DrawableCompat.java
+++ b/core/core/src/main/java/androidx/core/graphics/drawable/DrawableCompat.java
@@ -28,8 +28,10 @@
 import android.util.Log;
 
 import androidx.annotation.ColorInt;
+import androidx.annotation.DoNotInline;
 import androidx.annotation.NonNull;
 import androidx.annotation.Nullable;
+import androidx.annotation.RequiresApi;
 import androidx.core.view.ViewCompat;
 
 import org.xmlpull.v1.XmlPullParser;
@@ -76,7 +78,7 @@
      */
     public static void setAutoMirrored(@NonNull Drawable drawable, boolean mirrored) {
         if (Build.VERSION.SDK_INT >= 19) {
-            drawable.setAutoMirrored(mirrored);
+            Api19Impl.setAutoMirrored(drawable, mirrored);
         }
     }
 
@@ -93,7 +95,7 @@
      */
     public static boolean isAutoMirrored(@NonNull Drawable drawable) {
         if (Build.VERSION.SDK_INT >= 19) {
-            return drawable.isAutoMirrored();
+            return Api19Impl.isAutoMirrored(drawable);
         } else {
             return false;
         }
@@ -108,7 +110,7 @@
      */
     public static void setHotspot(@NonNull Drawable drawable, float x, float y) {
         if (Build.VERSION.SDK_INT >= 21) {
-            drawable.setHotspot(x, y);
+            Api21Impl.setHotspot(drawable, x, y);
         }
     }
 
@@ -121,7 +123,7 @@
     public static void setHotspotBounds(@NonNull Drawable drawable, int left, int top,
             int right, int bottom) {
         if (Build.VERSION.SDK_INT >= 21) {
-            drawable.setHotspotBounds(left, top, right, bottom);
+            Api21Impl.setHotspotBounds(drawable, left, top, right, bottom);
         }
     }
 
@@ -133,7 +135,7 @@
      */
     public static void setTint(@NonNull Drawable drawable, @ColorInt int tint) {
         if (Build.VERSION.SDK_INT >= 21) {
-            drawable.setTint(tint);
+            Api21Impl.setTint(drawable, tint);
         } else if (drawable instanceof TintAwareDrawable) {
             ((TintAwareDrawable) drawable).setTint(tint);
         }
@@ -147,7 +149,7 @@
      */
     public static void setTintList(@NonNull Drawable drawable, @Nullable ColorStateList tint) {
         if (Build.VERSION.SDK_INT >= 21) {
-            drawable.setTintList(tint);
+            Api21Impl.setTintList(drawable, tint);
         } else if (drawable instanceof TintAwareDrawable) {
             ((TintAwareDrawable) drawable).setTintList(tint);
         }
@@ -161,7 +163,7 @@
      */
     public static void setTintMode(@NonNull Drawable drawable, @NonNull PorterDuff.Mode tintMode) {
         if (Build.VERSION.SDK_INT >= 21) {
-            drawable.setTintMode(tintMode);
+            Api21Impl.setTintMode(drawable, tintMode);
         } else if (drawable instanceof TintAwareDrawable) {
             ((TintAwareDrawable) drawable).setTintMode(tintMode);
         }
@@ -173,9 +175,10 @@
      *
      * @param drawable The Drawable against which to invoke the method.
      */
+    @SuppressWarnings("unused")
     public static int getAlpha(@NonNull Drawable drawable) {
         if (Build.VERSION.SDK_INT >= 19) {
-            return drawable.getAlpha();
+            return Api19Impl.getAlpha(drawable);
         } else {
             return 0;
         }
@@ -184,18 +187,20 @@
     /**
      * Applies the specified theme to this Drawable and its children.
      */
+    @SuppressWarnings("unused")
     public static void applyTheme(@NonNull Drawable drawable, @NonNull Resources.Theme theme) {
         if (Build.VERSION.SDK_INT >= 21) {
-            drawable.applyTheme(theme);
+            Api21Impl.applyTheme(drawable, theme);
         }
     }
 
     /**
      * Whether a theme can be applied to this Drawable and its children.
      */
+    @SuppressWarnings("unused")
     public static boolean canApplyTheme(@NonNull Drawable drawable) {
         if (Build.VERSION.SDK_INT >= 21) {
-            return drawable.canApplyTheme();
+            return Api21Impl.canApplyTheme(drawable);
         } else {
             return false;
         }
@@ -206,9 +211,11 @@
      *
      * @return the current color filter, or {@code null} if none set
      */
+    @SuppressWarnings("unused")
+    @Nullable
     public static ColorFilter getColorFilter(@NonNull Drawable drawable) {
         if (Build.VERSION.SDK_INT >= 21) {
-            return drawable.getColorFilter();
+            return Api21Impl.getColorFilter(drawable);
         } else {
             return null;
         }
@@ -217,6 +224,7 @@
     /**
      * Removes the color filter from the given drawable.
      */
+    @SuppressWarnings("unused")
     public static void clearColorFilter(@NonNull Drawable drawable) {
         if (Build.VERSION.SDK_INT >= 23) {
             // We can use clearColorFilter() safely on M+
@@ -229,7 +237,7 @@
             // to find any DrawableContainers, and then unwrap those to clear the filter on its
             // children manually
             if (drawable instanceof InsetDrawable) {
-                clearColorFilter(((InsetDrawable) drawable).getDrawable());
+                clearColorFilter(Api19Impl.getDrawable((InsetDrawable) drawable));
             } else if (drawable instanceof WrappedDrawable) {
                 clearColorFilter(((WrappedDrawable) drawable).getWrappedDrawable());
             } else if (drawable instanceof DrawableContainer) {
@@ -239,7 +247,7 @@
                 if (state != null) {
                     Drawable child;
                     for (int i = 0, count = state.getChildCount(); i < count; i++) {
-                        child = state.getChild(i);
+                        child = Api19Impl.getChild(state, i);
                         if (child != null) {
                             clearColorFilter(child);
                         }
@@ -266,7 +274,7 @@
             @Nullable Resources.Theme theme)
             throws XmlPullParserException, IOException {
         if (Build.VERSION.SDK_INT >= 21) {
-            drawable.inflate(res, parser, attrs, theme);
+            Api21Impl.inflate(drawable, res, parser, attrs, theme);
         } else {
             drawable.inflate(res, parser, attrs);
         }
@@ -303,6 +311,7 @@
      * @see #setTintMode(Drawable, PorterDuff.Mode)
      * @see #unwrap(Drawable)
      */
+    @NonNull
     public static Drawable wrap(@NonNull Drawable drawable) {
         if (Build.VERSION.SDK_INT >= 23) {
             return drawable;
@@ -352,7 +361,7 @@
      */
     public static boolean setLayoutDirection(@NonNull Drawable drawable, int layoutDirection) {
         if (Build.VERSION.SDK_INT >= 23) {
-            return drawable.setLayoutDirection(layoutDirection);
+            return Api23Impl.setLayoutDirection(drawable, layoutDirection);
         } else if (Build.VERSION.SDK_INT >= 17) {
             if (!sSetLayoutDirectionMethodFetched) {
                 try {
@@ -387,9 +396,10 @@
      *         {@link ViewCompat#LAYOUT_DIRECTION_RTL}
      * @see #setLayoutDirection(Drawable, int)
      */
+    @SuppressWarnings("ConstantConditions")
     public static int getLayoutDirection(@NonNull Drawable drawable) {
         if (Build.VERSION.SDK_INT >= 23) {
-            return drawable.getLayoutDirection();
+            return Api23Impl.getLayoutDirection(drawable);
         } else if (Build.VERSION.SDK_INT >= 17) {
             if (!sGetLayoutDirectionMethodFetched) {
                 try {
@@ -416,5 +426,110 @@
         }
     }
 
-    private DrawableCompat() {}
+    private DrawableCompat() {
+    }
+
+    @RequiresApi(19)
+    static class Api19Impl {
+        private Api19Impl() {
+            // This class is not instantiable.
+        }
+
+        @DoNotInline
+        static void setAutoMirrored(Drawable drawable, boolean mirrored) {
+            drawable.setAutoMirrored(mirrored);
+        }
+
+        @DoNotInline
+        static boolean isAutoMirrored(Drawable drawable) {
+            return drawable.isAutoMirrored();
+        }
+
+        @DoNotInline
+        static int getAlpha(Drawable drawable) {
+            return drawable.getAlpha();
+        }
+
+        @DoNotInline
+        static Drawable getChild(DrawableContainer.DrawableContainerState drawableContainerState,
+                int index) {
+            return drawableContainerState.getChild(index);
+        }
+
+        @DoNotInline
+        static Drawable getDrawable(InsetDrawable drawable) {
+            return drawable.getDrawable();
+        }
+    }
+
+    @RequiresApi(21)
+    static class Api21Impl {
+        private Api21Impl() {
+            // This class is not instantiable.
+        }
+
+        @DoNotInline
+        static void setHotspot(Drawable drawable, float x, float y) {
+            drawable.setHotspot(x, y);
+        }
+
+        @DoNotInline
+        static void setTint(Drawable drawable, int tintColor) {
+            drawable.setTint(tintColor);
+        }
+
+        @DoNotInline
+        static void setTintList(Drawable drawable, ColorStateList tint) {
+            drawable.setTintList(tint);
+        }
+
+        @DoNotInline
+        static void setTintMode(Drawable drawable, PorterDuff.Mode tintMode) {
+            drawable.setTintMode(tintMode);
+        }
+
+        @DoNotInline
+        static void applyTheme(Drawable drawable, Resources.Theme t) {
+            drawable.applyTheme(t);
+        }
+
+        @DoNotInline
+        static boolean canApplyTheme(Drawable drawable) {
+            return drawable.canApplyTheme();
+        }
+
+        @DoNotInline
+        static ColorFilter getColorFilter(Drawable drawable) {
+            return drawable.getColorFilter();
+        }
+
+        @DoNotInline
+        static void inflate(Drawable drawable, Resources r, XmlPullParser parser,
+                AttributeSet attrs, Resources.Theme theme)
+                throws XmlPullParserException, IOException {
+            drawable.inflate(r, parser, attrs, theme);
+        }
+
+        @DoNotInline
+        static void setHotspotBounds(Drawable drawable, int left, int top, int right, int bottom) {
+            drawable.setHotspotBounds(left, top, right, bottom);
+        }
+    }
+
+    @RequiresApi(23)
+    static class Api23Impl {
+        private Api23Impl() {
+            // This class is not instantiable.
+        }
+
+        @DoNotInline
+        static boolean setLayoutDirection(Drawable drawable, int layoutDirection) {
+            return drawable.setLayoutDirection(layoutDirection);
+        }
+
+        @DoNotInline
+        static int getLayoutDirection(Drawable drawable) {
+            return drawable.getLayoutDirection();
+        }
+    }
 }
diff --git a/core/core/src/main/java/androidx/core/graphics/drawable/IconCompat.java b/core/core/src/main/java/androidx/core/graphics/drawable/IconCompat.java
index 7ece7b1..a1833ae 100644
--- a/core/core/src/main/java/androidx/core/graphics/drawable/IconCompat.java
+++ b/core/core/src/main/java/androidx/core/graphics/drawable/IconCompat.java
@@ -49,6 +49,7 @@
 import android.util.Log;
 
 import androidx.annotation.ColorInt;
+import androidx.annotation.DoNotInline;
 import androidx.annotation.DrawableRes;
 import androidx.annotation.IdRes;
 import androidx.annotation.IntDef;
@@ -59,6 +60,7 @@
 import androidx.annotation.VisibleForTesting;
 import androidx.core.content.ContextCompat;
 import androidx.core.content.res.ResourcesCompat;
+import androidx.core.util.ObjectsCompat;
 import androidx.core.util.Preconditions;
 import androidx.versionedparcelable.CustomVersionedParcelable;
 import androidx.versionedparcelable.NonParcelField;
@@ -171,12 +173,14 @@
     /**
      * @hide
      */
+    @Nullable
     @RestrictTo(LIBRARY)
     @ParcelField(value = 2, defaultValue = "null")
     public byte[]          mData = null;
     /**
      * @hide
      */
+    @Nullable
     @RestrictTo(LIBRARY)
     @ParcelField(value = 3, defaultValue = "null")
     public Parcelable      mParcelable = null;
@@ -201,6 +205,7 @@
     /**
      * @hide
      */
+    @Nullable
     @RestrictTo(LIBRARY)
     @ParcelField(value = 6, defaultValue = "null")
     public ColorStateList  mTintList = null;
@@ -211,6 +216,7 @@
     /**
      * @hide
      */
+    @Nullable
     @RestrictTo(LIBRARY)
     @ParcelField(value = 7, defaultValue = "null")
     public String mTintModeStr = null;
@@ -218,6 +224,7 @@
     /**
      * @hide
      */
+    @Nullable
     @RestrictTo(LIBRARY)
     @ParcelField(value = 8, defaultValue = "null")
     public String mString1;
@@ -229,21 +236,20 @@
      * @param resId ID of the drawable resource
      * @see android.graphics.drawable.Icon#createWithResource(Context, int)
      */
-    public static IconCompat createWithResource(Context context, @DrawableRes int resId) {
-        if (context == null) {
-            throw new IllegalArgumentException("Context must not be null.");
-        }
+    @NonNull
+    public static IconCompat createWithResource(@NonNull Context context, @DrawableRes int resId) {
+        ObjectsCompat.requireNonNull(context);
         return createWithResource(context.getResources(), context.getPackageName(), resId);
     }
 
     /**
      * @hide
      */
+    @NonNull
     @RestrictTo(LIBRARY_GROUP_PREFIX)
-    public static IconCompat createWithResource(Resources r, String pkg, @DrawableRes int resId) {
-        if (pkg == null) {
-            throw new IllegalArgumentException("Package must not be null.");
-        }
+    public static IconCompat createWithResource(@Nullable Resources r, @NonNull String pkg,
+            @DrawableRes int resId) {
+        ObjectsCompat.requireNonNull(pkg);
         if (resId == 0) {
             throw new IllegalArgumentException("Drawable resource ID must not be 0");
         }
@@ -267,10 +273,9 @@
      * @param bits A valid {@link android.graphics.Bitmap} object
      * @see android.graphics.drawable.Icon#createWithBitmap(Bitmap)
      */
-    public static IconCompat createWithBitmap(Bitmap bits) {
-        if (bits == null) {
-            throw new IllegalArgumentException("Bitmap must not be null.");
-        }
+    @NonNull
+    public static IconCompat createWithBitmap(@NonNull Bitmap bits) {
+        ObjectsCompat.requireNonNull(bits);
         final IconCompat rep = new IconCompat(TYPE_BITMAP);
         rep.mObj1 = bits;
         return rep;
@@ -282,10 +287,9 @@
      * @param bits A valid {@link android.graphics.Bitmap} object
      * @see android.graphics.drawable.Icon#createWithAdaptiveBitmap(Bitmap)
      */
-    public static IconCompat createWithAdaptiveBitmap(Bitmap bits) {
-        if (bits == null) {
-            throw new IllegalArgumentException("Bitmap must not be null.");
-        }
+    @NonNull
+    public static IconCompat createWithAdaptiveBitmap(@NonNull Bitmap bits) {
+        ObjectsCompat.requireNonNull(bits);
         final IconCompat rep = new IconCompat(TYPE_ADAPTIVE_BITMAP);
         rep.mObj1 = bits;
         return rep;
@@ -300,10 +304,9 @@
      * @param length Length of the bitmap data
      * @see android.graphics.drawable.Icon#createWithData(byte[], int, int)
      */
-    public static IconCompat createWithData(byte[] data, int offset, int length) {
-        if (data == null) {
-            throw new IllegalArgumentException("Data must not be null.");
-        }
+    @NonNull
+    public static IconCompat createWithData(@NonNull byte[] data, int offset, int length) {
+        ObjectsCompat.requireNonNull(data);
         final IconCompat rep = new IconCompat(TYPE_DATA);
         rep.mObj1 = data;
         rep.mInt1 = offset;
@@ -317,10 +320,9 @@
      * @param uri A uri referring to local content:// or file:// image data.
      * @see android.graphics.drawable.Icon#createWithContentUri(String)
      */
-    public static IconCompat createWithContentUri(String uri) {
-        if (uri == null) {
-            throw new IllegalArgumentException("Uri must not be null.");
-        }
+    @NonNull
+    public static IconCompat createWithContentUri(@NonNull String uri) {
+        ObjectsCompat.requireNonNull(uri);
         final IconCompat rep = new IconCompat(TYPE_URI);
         rep.mObj1 = uri;
         return rep;
@@ -332,10 +334,9 @@
      * @param uri A uri referring to local content:// or file:// image data.
      * @see android.graphics.drawable.Icon#createWithContentUri(String)
      */
-    public static IconCompat createWithContentUri(Uri uri) {
-        if (uri == null) {
-            throw new IllegalArgumentException("Uri must not be null.");
-        }
+    @NonNull
+    public static IconCompat createWithContentUri(@NonNull Uri uri) {
+        ObjectsCompat.requireNonNull(uri);
         return createWithContentUri(uri.toString());
     }
 
@@ -348,9 +349,7 @@
      */
     @NonNull
     public static IconCompat createWithAdaptiveBitmapContentUri(@NonNull String uri) {
-        if (uri == null) {
-            throw new IllegalArgumentException("Uri must not be null.");
-        }
+        ObjectsCompat.requireNonNull(uri);
         final IconCompat rep = new IconCompat(TYPE_URI_ADAPTIVE_BITMAP);
         rep.mObj1 = uri;
         return rep;
@@ -365,9 +364,7 @@
      */
     @NonNull
     public static IconCompat createWithAdaptiveBitmapContentUri(@NonNull Uri uri) {
-        if (uri == null) {
-            throw new IllegalArgumentException("Uri must not be null.");
-        }
+        ObjectsCompat.requireNonNull(uri);
         return createWithAdaptiveBitmapContentUri(uri.toString());
     }
 
@@ -416,12 +413,13 @@
         // Before aosp/1307777, we don't put the package name to mString1. Try to get the
         // package name from the full resource name string. Note that this is not always the same
         // as "the package used to create this icon" and this was what aosp/1307777 tried to fix.
-        if (TextUtils.isEmpty(mString1)) {
+        if (mString1 == null || TextUtils.isEmpty(mString1)) {
             return ((String) mObj1).split(":", -1)[0];
+        } else {
+            // The name of the getResPackage() API is a bit confusing. It actually returns
+            // the app package name rather than the package name in the resource table.
+            return mString1;
         }
-        // The name of the getResPackage() API is a bit confusing. It actually returns
-        // the app package name rather than the package name in the resource table.
-        return mString1;
     }
 
     /**
@@ -493,6 +491,7 @@
      * @param tint a color, as in {@link Drawable#setTint(int)}
      * @return this same object, for use in chained construction
      */
+    @NonNull
     public IconCompat setTint(@ColorInt int tint) {
         return setTintList(ColorStateList.valueOf(tint));
     }
@@ -503,7 +502,8 @@
      * @param tintList as in {@link Drawable#setTintList(ColorStateList)}, null to remove tint
      * @return this same object, for use in chained construction
      */
-    public IconCompat setTintList(ColorStateList tintList) {
+    @NonNull
+    public IconCompat setTintList(@Nullable ColorStateList tintList) {
         mTintList = tintList;
         return this;
     }
@@ -514,7 +514,8 @@
      * @param mode a blending mode, as in {@link Drawable#setTintMode(PorterDuff.Mode)}, may be null
      * @return this same object, for use in chained construction
      */
-    public IconCompat setTintMode(PorterDuff.Mode mode) {
+    @NonNull
+    public IconCompat setTintMode(@Nullable PorterDuff.Mode mode) {
         mTintMode = mode;
         return this;
     }
@@ -537,62 +538,7 @@
     @RequiresApi(23)
     @NonNull
     public Icon toIcon(@Nullable Context context) {
-        Icon icon;
-        switch (mType) {
-            case TYPE_UNKNOWN:
-                // When type is unknown we are just wrapping an icon.
-                return (Icon) mObj1;
-            case TYPE_BITMAP:
-                icon = Icon.createWithBitmap((Bitmap) mObj1);
-                break;
-            case TYPE_ADAPTIVE_BITMAP:
-                if (Build.VERSION.SDK_INT >= 26) {
-                    icon = Icon.createWithAdaptiveBitmap((Bitmap) mObj1);
-                } else {
-                    icon = Icon.createWithBitmap(
-                            createLegacyIconFromAdaptiveIcon((Bitmap) mObj1, false));
-                }
-                break;
-            case TYPE_RESOURCE:
-                icon = Icon.createWithResource(getResPackage(), mInt1);
-                break;
-            case TYPE_DATA:
-                icon = Icon.createWithData((byte[]) mObj1, mInt1, mInt2);
-                break;
-            case TYPE_URI:
-                icon = Icon.createWithContentUri((String) mObj1);
-                break;
-            case TYPE_URI_ADAPTIVE_BITMAP:
-                if (Build.VERSION.SDK_INT >= 30) {
-                    icon = Icon.createWithAdaptiveBitmapContentUri(getUri());
-                    break;
-                }
-                if (context == null) {
-                    throw new IllegalArgumentException(
-                            "Context is required to resolve the file uri of the icon: " + getUri());
-                }
-                InputStream is = getUriInputStream(context);
-                if (is == null) {
-                    throw new IllegalStateException(
-                            "Cannot load adaptive icon from uri: " + getUri());
-                }
-                if (Build.VERSION.SDK_INT >= 26) {
-                    icon = Icon.createWithAdaptiveBitmap(BitmapFactory.decodeStream(is));
-                } else {
-                    icon = Icon.createWithBitmap(createLegacyIconFromAdaptiveIcon(
-                                BitmapFactory.decodeStream(is), false));
-                }
-                break;
-            default:
-                throw new IllegalArgumentException("Unknown type");
-        }
-        if (mTintList != null) {
-            icon.setTintList(mTintList);
-        }
-        if (mTintMode != DEFAULT_TINT_MODE) {
-            icon.setTintMode(mTintMode);
-        }
-        return icon;
+        return Api23Impl.toIcon(this, context);
     }
 
     /**
@@ -638,7 +584,7 @@
     public Drawable loadDrawable(@NonNull Context context) {
         checkResource(context);
         if (Build.VERSION.SDK_INT >= 23) {
-            return toIcon(context).loadDrawable(context);
+            return Api23Impl.loadDrawable(toIcon(context), context);
         }
         final Drawable result = loadDrawableInner(context);
         if (result != null && (mTintList != null || mTintMode != DEFAULT_TINT_MODE)) {
@@ -691,7 +637,7 @@
                 is = getUriInputStream(context);
                 if (is != null) {
                     if (Build.VERSION.SDK_INT >= 26) {
-                        return new AdaptiveIconDrawable(null,
+                        return Api26Impl.createAdaptiveIconDrawable(null,
                                 new BitmapDrawable(context.getResources(),
                                         BitmapFactory.decodeStream(is)));
                     } else {
@@ -1098,19 +1044,20 @@
     @RequiresApi(23)
     private static int getType(@NonNull Icon icon) {
         if (Build.VERSION.SDK_INT >= 28) {
-            return icon.getType();
-        }
-        try {
-            return (int) icon.getClass().getMethod("getType").invoke(icon);
-        } catch (IllegalAccessException e) {
-            Log.e(TAG, "Unable to get icon type " + icon, e);
-            return TYPE_UNKNOWN;
-        } catch (InvocationTargetException e) {
-            Log.e(TAG, "Unable to get icon type " + icon, e);
-            return TYPE_UNKNOWN;
-        } catch (NoSuchMethodException e) {
-            Log.e(TAG, "Unable to get icon type " + icon, e);
-            return TYPE_UNKNOWN;
+            return Api28Impl.getType(icon);
+        } else {
+            try {
+                return (int) icon.getClass().getMethod("getType").invoke(icon);
+            } catch (IllegalAccessException e) {
+                Log.e(TAG, "Unable to get icon type " + icon, e);
+                return TYPE_UNKNOWN;
+            } catch (InvocationTargetException e) {
+                Log.e(TAG, "Unable to get icon type " + icon, e);
+                return TYPE_UNKNOWN;
+            } catch (NoSuchMethodException e) {
+                Log.e(TAG, "Unable to get icon type " + icon, e);
+                return TYPE_UNKNOWN;
+            }
         }
     }
 
@@ -1126,19 +1073,20 @@
     @RequiresApi(23)
     private static String getResPackage(@NonNull Icon icon) {
         if (Build.VERSION.SDK_INT >= 28) {
-            return icon.getResPackage();
-        }
-        try {
-            return (String) icon.getClass().getMethod("getResPackage").invoke(icon);
-        } catch (IllegalAccessException e) {
-            Log.e(TAG, "Unable to get icon package", e);
-            return null;
-        } catch (InvocationTargetException e) {
-            Log.e(TAG, "Unable to get icon package", e);
-            return null;
-        } catch (NoSuchMethodException e) {
-            Log.e(TAG, "Unable to get icon package", e);
-            return null;
+            return Api28Impl.getResPackage(icon);
+        } else {
+            try {
+                return (String) icon.getClass().getMethod("getResPackage").invoke(icon);
+            } catch (IllegalAccessException e) {
+                Log.e(TAG, "Unable to get icon package", e);
+                return null;
+            } catch (InvocationTargetException e) {
+                Log.e(TAG, "Unable to get icon package", e);
+                return null;
+            } catch (NoSuchMethodException e) {
+                Log.e(TAG, "Unable to get icon package", e);
+                return null;
+            }
         }
     }
 
@@ -1155,19 +1103,20 @@
     @DrawableRes
     private static int getResId(@NonNull Icon icon) {
         if (Build.VERSION.SDK_INT >= 28) {
-            return icon.getResId();
-        }
-        try {
-            return (int) icon.getClass().getMethod("getResId").invoke(icon);
-        } catch (IllegalAccessException e) {
-            Log.e(TAG, "Unable to get icon resource", e);
-            return 0;
-        } catch (InvocationTargetException e) {
-            Log.e(TAG, "Unable to get icon resource", e);
-            return 0;
-        } catch (NoSuchMethodException e) {
-            Log.e(TAG, "Unable to get icon resource", e);
-            return 0;
+            return Api28Impl.getResId(icon);
+        } else {
+            try {
+                return (int) icon.getClass().getMethod("getResId").invoke(icon);
+            } catch (IllegalAccessException e) {
+                Log.e(TAG, "Unable to get icon resource", e);
+                return 0;
+            } catch (InvocationTargetException e) {
+                Log.e(TAG, "Unable to get icon resource", e);
+                return 0;
+            } catch (NoSuchMethodException e) {
+                Log.e(TAG, "Unable to get icon resource", e);
+                return 0;
+            }
         }
     }
 
@@ -1183,19 +1132,20 @@
     @RequiresApi(23)
     private static Uri getUri(@NonNull Icon icon) {
         if (Build.VERSION.SDK_INT >= 28) {
-            return icon.getUri();
-        }
-        try {
-            return (Uri) icon.getClass().getMethod("getUri").invoke(icon);
-        } catch (IllegalAccessException e) {
-            Log.e(TAG, "Unable to get icon uri", e);
-            return null;
-        } catch (InvocationTargetException e) {
-            Log.e(TAG, "Unable to get icon uri", e);
-            return null;
-        } catch (NoSuchMethodException e) {
-            Log.e(TAG, "Unable to get icon uri", e);
-            return null;
+            return Api28Impl.getUri(icon);
+        } else {
+            try {
+                return (Uri) icon.getClass().getMethod("getUri").invoke(icon);
+            } catch (IllegalAccessException e) {
+                Log.e(TAG, "Unable to get icon uri", e);
+                return null;
+            } catch (InvocationTargetException e) {
+                Log.e(TAG, "Unable to get icon uri", e);
+                return null;
+            } catch (NoSuchMethodException e) {
+                Log.e(TAG, "Unable to get icon uri", e);
+                return null;
+            }
         }
     }
 
@@ -1236,8 +1186,8 @@
         BitmapShader shader = new BitmapShader(adaptiveIconBitmap, Shader.TileMode.CLAMP,
                 Shader.TileMode.CLAMP);
         Matrix shift = new Matrix();
-        shift.setTranslate(-(adaptiveIconBitmap.getWidth() - size) / 2,
-                -(adaptiveIconBitmap.getHeight() - size) / 2);
+        shift.setTranslate(-(adaptiveIconBitmap.getWidth() - size) / 2.0f,
+                -(adaptiveIconBitmap.getHeight() - size) / 2.0f);
         shader.setLocalMatrix(shift);
         paint.setShader(shader);
         canvas.drawCircle(center, center, radius, paint);
@@ -1245,4 +1195,135 @@
         canvas.setBitmap(null);
         return icon;
     }
+
+    @RequiresApi(28)
+    static class Api28Impl {
+        private Api28Impl() {
+            // This class is not instantiable.
+        }
+
+        @DoNotInline
+        static String getResPackage(Icon icon) {
+            return icon.getResPackage();
+        }
+
+        @DoNotInline
+        static int getType(Icon icon) {
+            return icon.getType();
+        }
+
+        @DoNotInline
+        static int getResId(Icon icon) {
+            return icon.getResId();
+        }
+
+        @DoNotInline
+        static Uri getUri(Icon icon) {
+            return icon.getUri();
+        }
+    }
+
+    @RequiresApi(26)
+    static class Api26Impl {
+        private Api26Impl() {
+            // This class is not instantiable.
+        }
+
+        @DoNotInline
+        static AdaptiveIconDrawable createAdaptiveIconDrawable(Drawable backgroundDrawable,
+                Drawable foregroundDrawable) {
+            return new AdaptiveIconDrawable(backgroundDrawable, foregroundDrawable);
+        }
+
+        @DoNotInline
+        static Icon createWithAdaptiveBitmap(Bitmap bits) {
+            return Icon.createWithAdaptiveBitmap(bits);
+        }
+    }
+
+    @RequiresApi(30)
+    static class Api30Impl {
+        private Api30Impl() {
+            // This class is not instantiable.
+        }
+
+        @DoNotInline
+        static Icon createWithAdaptiveBitmapContentUri(Uri uri) {
+            return Icon.createWithAdaptiveBitmapContentUri(uri);
+        }
+
+    }
+
+    @RequiresApi(23)
+    static class Api23Impl {
+        private Api23Impl() {
+            // This class is not instantiable.
+        }
+
+        static Icon toIcon(IconCompat iconCompat, Context context) {
+            Icon icon;
+            switch (iconCompat.mType) {
+                case TYPE_UNKNOWN:
+                    // When type is unknown we are just wrapping an icon.
+                    return (Icon) iconCompat.mObj1;
+                case TYPE_BITMAP:
+                    icon = Icon.createWithBitmap((Bitmap) iconCompat.mObj1);
+                    break;
+                case TYPE_ADAPTIVE_BITMAP:
+                    if (Build.VERSION.SDK_INT >= 26) {
+                        icon = Api26Impl.createWithAdaptiveBitmap((Bitmap) iconCompat.mObj1);
+                    } else {
+                        icon = Icon.createWithBitmap(
+                                createLegacyIconFromAdaptiveIcon((Bitmap) iconCompat.mObj1, false));
+                    }
+                    break;
+                case TYPE_RESOURCE:
+                    icon = Icon.createWithResource(iconCompat.getResPackage(), iconCompat.mInt1);
+                    break;
+                case TYPE_DATA:
+                    icon = Icon.createWithData((byte[]) iconCompat.mObj1, iconCompat.mInt1,
+                            iconCompat.mInt2);
+                    break;
+                case TYPE_URI:
+                    icon = Icon.createWithContentUri((String) iconCompat.mObj1);
+                    break;
+                case TYPE_URI_ADAPTIVE_BITMAP:
+                    if (Build.VERSION.SDK_INT >= 30) {
+                        icon = Api30Impl.createWithAdaptiveBitmapContentUri(iconCompat.getUri());
+                        break;
+                    }
+                    if (context == null) {
+                        throw new IllegalArgumentException(
+                                "Context is required to resolve the file uri of the icon: "
+                                        + iconCompat.getUri());
+                    }
+                    InputStream is = iconCompat.getUriInputStream(context);
+                    if (is == null) {
+                        throw new IllegalStateException(
+                                "Cannot load adaptive icon from uri: " + iconCompat.getUri());
+                    }
+                    if (Build.VERSION.SDK_INT >= 26) {
+                        icon = Api26Impl.createWithAdaptiveBitmap(BitmapFactory.decodeStream(is));
+                    } else {
+                        icon = Icon.createWithBitmap(createLegacyIconFromAdaptiveIcon(
+                                BitmapFactory.decodeStream(is), false));
+                    }
+                    break;
+                default:
+                    throw new IllegalArgumentException("Unknown type");
+            }
+            if (iconCompat.mTintList != null) {
+                icon.setTintList(iconCompat.mTintList);
+            }
+            if (iconCompat.mTintMode != DEFAULT_TINT_MODE) {
+                icon.setTintMode(iconCompat.mTintMode);
+            }
+            return icon;
+        }
+
+        @DoNotInline
+        static Drawable loadDrawable(Icon icon, Context context) {
+            return icon.loadDrawable(context);
+        }
+    }
 }