Prevent NPE when GlobalActions items are clicked while the dialog isn't showing.
Unclear what circumstances this can happen in, perhaps a race condition for tapping items rapidly while the phone is under heavy load and running very slowly. Added warning logs in case we need to investigate further.
Test: Automated tests pass, GlobalActionsMenu still works as expected when tapping action items.
Bug: 134514187
Change-Id: I0c50ee02cc54d046a12e56f01d9c129122fbf737
diff --git a/packages/SystemUI/src/com/android/systemui/globalactions/GlobalActionsDialog.java b/packages/SystemUI/src/com/android/systemui/globalactions/GlobalActionsDialog.java
index 8826f43..df3f36e 100644
--- a/packages/SystemUI/src/com/android/systemui/globalactions/GlobalActionsDialog.java
+++ b/packages/SystemUI/src/com/android/systemui/globalactions/GlobalActionsDialog.java
@@ -1021,7 +1021,11 @@
public boolean onLongClickItem(int position) {
final Action action = mAdapter.getItem(position);
if (action instanceof LongPressAction) {
- mDialog.dismiss();
+ if (mDialog != null) {
+ mDialog.dismiss();
+ } else {
+ Log.w(TAG, "Action long-clicked while mDialog is null.");
+ }
return ((LongPressAction) action).onLongPress();
}
return false;
@@ -1031,9 +1035,13 @@
public void onClickItem(int position) {
Action item = mAdapter.getItem(position);
if (!(item instanceof SilentModeTriStateAction)) {
- mDialog.dismiss();
+ if (mDialog != null) {
+ mDialog.dismiss();
+ } else {
+ Log.w(TAG, "Action clicked while mDialog is null.");
+ }
+ item.onPress();
}
- item.onPress();
}
@Override