am 358eaa78: am fc1d0471: am 11b7d9fa: Merge "PrintSpooler crash if printer is reported to have only one color mode." into klp-dev

* commit '358eaa7825140ee571a7b9d61705fb3adb5b60aa':
  PrintSpooler crash if printer is reported to have only one color mode.
This commit is contained in:
Svetoslav
2014-03-14 16:32:15 +00:00
committed by Android Git Automerger
2 changed files with 16 additions and 6 deletions

View File

@@ -475,6 +475,12 @@ public final class PrinterCapabilitiesInfo implements Parcelable {
* @param colorModes The color mode bit mask. * @param colorModes The color mode bit mask.
* @param defaultColorMode The default color mode. * @param defaultColorMode The default color mode.
* @return This builder. * @return This builder.
* <p>
* <strong>Note:</strong> On platform version 19 (Kitkat) specifying
* only PrintAttributes#COLOR_MODE_MONOCHROME leads to a print spooler
* crash. Hence, you should declare either both color modes or
* PrintAttributes#COLOR_MODE_COLOR.
* </p>
* *
* @throws IllegalArgumentException If color modes contains an invalid * @throws IllegalArgumentException If color modes contains an invalid
* mode bit or if the default color mode is invalid. * mode bit or if the default color mode is invalid.

View File

@@ -2190,12 +2190,16 @@ public class PrintJobConfigActivity extends Activity {
// Select the old color mode - nothing really changed. // Select the old color mode - nothing really changed.
setColorModeSpinnerSelectionNoCallback(oldColorModeNewIndex); setColorModeSpinnerSelectionNoCallback(oldColorModeNewIndex);
} else { } else {
final int selectedColorModeIndex = Integer.numberOfTrailingZeros( final int selectedColorMode = colorModes & defaultAttributes.getColorMode();
(colorModes & defaultAttributes.getColorMode())); final int itemCount = mColorModeSpinnerAdapter.getCount();
setColorModeSpinnerSelectionNoCallback(selectedColorModeIndex); for (int i = 0; i < itemCount; i++) {
mCurrPrintAttributes.setColorMode(mColorModeSpinnerAdapter SpinnerItem<Integer> item = mColorModeSpinnerAdapter.getItem(i);
.getItem(selectedColorModeIndex).value); if (selectedColorMode == item.value) {
someAttributeSelectionChanged = true; setColorModeSpinnerSelectionNoCallback(i);
mCurrPrintAttributes.setColorMode(selectedColorMode);
someAttributeSelectionChanged = true;
}
}
} }
} }
mColorModeSpinner.setEnabled(true); mColorModeSpinner.setEnabled(true);