Merge "Fix NPE in obtainThemeColor due to use of Mocks" into sc-dev

This commit is contained in:
Jeff DeCew
2021-04-02 20:52:37 +00:00
committed by Android (Google) Code Review

View File

@@ -6562,7 +6562,7 @@ public class Notification implements Parcelable
theme = new ContextThemeWrapper(mContext, R.style.Theme_DeviceDefault_DayNight)
.getTheme();
try (TypedArray ta = theme.obtainStyledAttributes(new int[]{attrRes})) {
return ta.getColor(0, defaultColor);
return ta == null ? defaultColor : ta.getColor(0, defaultColor);
}
}
@@ -9060,10 +9060,8 @@ public class Notification implements Parcelable
container.setDrawableTint(buttonId, false, tintColor,
PorterDuff.Mode.SRC_ATOP);
final TypedArray typedArray = mBuilder.mContext.obtainStyledAttributes(
new int[]{ android.R.attr.colorControlHighlight });
int rippleAlpha = Color.alpha(typedArray.getColor(0, 0));
typedArray.recycle();
int rippleAlpha = Color.alpha(mBuilder.obtainThemeColor(
android.R.attr.colorControlHighlight, COLOR_DEFAULT));
int rippleColor = Color.argb(rippleAlpha, Color.red(tintColor), Color.green(tintColor),
Color.blue(tintColor));
container.setRippleDrawableColor(buttonId, ColorStateList.valueOf(rippleColor));