Skip to content

Commit abcaeea

Browse files
committed
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
1 parent c1ec220 commit abcaeea

File tree

1 file changed

+6
-2
lines changed

1 file changed

+6
-2
lines changed

core/java/android/widget/ActivityChooserModel.java

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,6 @@
2121
import android.content.Intent;
2222
import android.content.pm.ResolveInfo;
2323
import android.database.DataSetObservable;
24-
import android.database.DataSetObserver;
2524
import android.os.AsyncTask;
2625
import android.text.TextUtils;
2726
import android.util.Log;
@@ -458,13 +457,18 @@ public int getActivityIndex(ResolveInfo activity) {
458457
* </p>
459458
*
460459
* @return An {@link Intent} for launching the activity or null if the
461-
* policy has consumed the intent.
460+
* policy has consumed the intent or there is not current intent
461+
* set via {@link #setIntent(Intent)}.
462462
*
463463
* @see HistoricalRecord
464464
* @see OnChooseActivityListener
465465
*/
466466
public Intent chooseActivity(int index) {
467467
synchronized (mInstanceLock) {
468+
if (mIntent == null) {
469+
return null;
470+
}
471+
468472
ensureConsistentState();
469473

470474
ActivityResolveInfo chosenActivity = mActivities.get(index);

0 commit comments

Comments
 (0)