1 package org.robolectric.fakes; 2 3 import android.app.PendingIntent; 4 import android.content.Context; 5 import android.content.IIntentSender; 6 import android.content.Intent; 7 import android.content.IntentSender; 8 import android.os.Handler; 9 import java.util.Objects; 10 11 /** 12 * Robolectric implementation of {@link android.content.IntentSender}. 13 */ 14 public class RoboIntentSender extends IntentSender { 15 public Intent intent; 16 private PendingIntent pendingIntent; 17 RoboIntentSender(PendingIntent pendingIntent)18 public RoboIntentSender(PendingIntent pendingIntent) { 19 super((IIntentSender) null); 20 this.pendingIntent = pendingIntent; 21 } 22 23 @Override equals(Object other)24 public boolean equals(Object other) { 25 if (!(other instanceof RoboIntentSender)) { 26 return false; 27 } 28 return Objects.equals(pendingIntent, ((RoboIntentSender) other).pendingIntent); 29 } 30 31 @Override hashCode()32 public int hashCode() { 33 return pendingIntent.hashCode(); 34 } 35 sendIntent(Context context, int code, Intent intent, final OnFinished onFinished, Handler handler, String requiredPermission)36 @Override public void sendIntent(Context context, int code, Intent intent, 37 final OnFinished onFinished, Handler handler, String requiredPermission) 38 throws SendIntentException { 39 try { 40 pendingIntent.send(context, code, intent); 41 } catch (PendingIntent.CanceledException e) { 42 throw new SendIntentException(e); 43 } 44 } 45 getPendingIntent()46 public PendingIntent getPendingIntent() { 47 return pendingIntent; 48 } 49 } 50