summaryrefslogtreecommitdiff
path: root/packages/PrintSpooler/src
diff options
context:
space:
mode:
authorPhilip P. Moltmann <moltmann@google.com>2018-02-14 12:26:21 -0800
committerPhilip P. Moltmann <moltmann@google.com>2018-02-14 12:31:21 -0800
commitae2b732ddf246233f0450845aa4664af1a52a393 (patch)
treee3f9066306efba855523057ed68e6608050cf3ca /packages/PrintSpooler/src
parente047522ecec94e7253761cf45b94b5a9b9e6c691 (diff)
Don't attempt to create context menu for 'add printer' entry
As the 'printer' variable becomes null and the activity crashes. This could also be solved to register context menu's for each printer entry (and not for the 'add printer' entry). Then we would need to create a custom view for the printer entry that returns a ContextMenuInfo containing the printer ID. While this solution is cleaner, it is much more complex. Test: Tried to open context menu in 'add printer' entry Change-Id: I23dcba2dd876cff27b5cad9736f5ec4524985bac Fixes: 73126748
Diffstat (limited to 'packages/PrintSpooler/src')
-rw-r--r--packages/PrintSpooler/src/com/android/printspooler/ui/SelectPrinterActivity.java5
1 files changed, 5 insertions, 0 deletions
diff --git a/packages/PrintSpooler/src/com/android/printspooler/ui/SelectPrinterActivity.java b/packages/PrintSpooler/src/com/android/printspooler/ui/SelectPrinterActivity.java
index 7c2e55f35cde..cf73aacb9b55 100644
--- a/packages/PrintSpooler/src/com/android/printspooler/ui/SelectPrinterActivity.java
+++ b/packages/PrintSpooler/src/com/android/printspooler/ui/SelectPrinterActivity.java
@@ -285,6 +285,11 @@ public final class SelectPrinterActivity extends Activity implements
final int position = ((AdapterContextMenuInfo) menuInfo).position;
PrinterInfo printer = (PrinterInfo) mListView.getAdapter().getItem(position);
+ // Printer is null if this is a context menu for the "add printer" entry
+ if (printer == null) {
+ return;
+ }
+
menu.setHeaderTitle(printer.getName());
// Add the select menu item if applicable.