Package IDs greater than 0x7f are interpreted as negative
numbers in Java's signed integer. The proper check for existence of
a resource ID is that it is not 0.
Bug:
37498913
Test: none
Change-Id: I446fb6abb514bf7cf2d0dcbfbd81dd5718cd2cb4
return R.style.Theme_DeviceDefault_Dialog_Alert;
} else if (themeResId == THEME_DEVICE_DEFAULT_LIGHT) {
return R.style.Theme_DeviceDefault_Light_Dialog_Alert;
- } else if (themeResId >= 0x01000000) { // start of real resource IDs.
+ } else if (Integer.compareUnsigned(themeResId, 0x01000000) >= 0) {
+ // start of real resource IDs.
return themeResId;
} else {
final TypedValue outValue = new TypedValue();
try {
Resources resources = context.getPackageManager().getResourcesForApplication(
providerInfo.applicationInfo);
- if (resourceId > 0) {
- if (density <= 0) {
- density = context.getResources().getDisplayMetrics().densityDpi;
+ if (resourceId != 0) {
+ if (density < 0) {
+ density = 0;
}
- return resources.getDrawableForDensity(resourceId, density);
+ return resources.getDrawableForDensity(resourceId, density, null);
}
} catch (PackageManager.NameNotFoundException | Resources.NotFoundException e) {
/* ignore */