Add protection for ActionMode-related window callbacks that may not

implement new methods.

Change-Id: Id4463ee97366187ba43b0966f79aa8bd34f7fa1d
This commit is contained in:
Adam Powell
2010-11-15 22:16:50 -08:00
parent debf3bed9e
commit bf85f43e48

View File

@@ -1832,7 +1832,12 @@ public class PhoneWindow extends Window implements MenuBuilder.Callback {
}
final ActionMode.Callback wrappedCallback = new ActionModeCallbackWrapper(callback);
ActionMode mode = getCallback().onWindowStartingActionMode(wrappedCallback);
ActionMode mode = null;
try {
mode = getCallback().onWindowStartingActionMode(wrappedCallback);
} catch (AbstractMethodError ame) {
// Older apps might not implement this callback method.
}
if (mode != null) {
mActionMode = mode;
} else {
@@ -1877,7 +1882,11 @@ public class PhoneWindow extends Window implements MenuBuilder.Callback {
}
}
if (mActionMode != null) {
getCallback().onActionModeStarted(mActionMode);
try {
getCallback().onActionModeStarted(mActionMode);
} catch (AbstractMethodError ame) {
// Older apps might not implement this callback method.
}
}
return mActionMode;
}
@@ -2094,7 +2103,11 @@ public class PhoneWindow extends Window implements MenuBuilder.Callback {
if (mActionModeView != null) {
mActionModeView.removeAllViews();
}
getCallback().onActionModeFinished(mActionMode);
try {
getCallback().onActionModeFinished(mActionMode);
} catch (AbstractMethodError ame) {
// Older apps might not implement this callback method.
}
mActionMode = null;
}
}