NPE in AcitivtyChooserModel.
1. If there is not current intent sent and the client tries to
choose an activity a NPE occurs. The code in chooseActivity
now checks for null intent. Note that having a null intent
is a valid state.
bug:6738922
Change-Id: I91d4415649ce070d4fa4aa187e9eac02928dd38c
diff --git a/core/java/android/widget/ActivityChooserModel.java b/core/java/android/widget/ActivityChooserModel.java
index fe6c4f5..736566e4 100644
--- a/core/java/android/widget/ActivityChooserModel.java
+++ b/core/java/android/widget/ActivityChooserModel.java
@@ -21,7 +21,6 @@
import android.content.Intent;
import android.content.pm.ResolveInfo;
import android.database.DataSetObservable;
-import android.database.DataSetObserver;
import android.os.AsyncTask;
import android.text.TextUtils;
import android.util.Log;
@@ -458,13 +457,18 @@
* </p>
*
* @return An {@link Intent} for launching the activity or null if the
- * policy has consumed the intent.
+ * policy has consumed the intent or there is not current intent
+ * set via {@link #setIntent(Intent)}.
*
* @see HistoricalRecord
* @see OnChooseActivityListener
*/
public Intent chooseActivity(int index) {
synchronized (mInstanceLock) {
+ if (mIntent == null) {
+ return null;
+ }
+
ensureConsistentState();
ActivityResolveInfo chosenActivity = mActivities.get(index);