use of android.app.PendingIntent.CanceledException in project android_packages_apps_Dialer by LineageOS.
the class Bubble method primaryButtonClick.
void primaryButtonClick() {
if (expanded || textShowing || currentInfo.getActions().isEmpty()) {
try {
currentInfo.getPrimaryIntent().send();
} catch (CanceledException e) {
throw new RuntimeException(e);
}
return;
}
doResize(() -> {
onLeftRightSwitch(isDrawingFromRight());
viewHolder.setDrawerVisibility(View.VISIBLE);
});
View expandedView = viewHolder.getExpandedView();
expandedView.getViewTreeObserver().addOnPreDrawListener(new OnPreDrawListener() {
@Override
public boolean onPreDraw() {
expandedView.getViewTreeObserver().removeOnPreDrawListener(this);
expandedView.setTranslationX(isDrawingFromRight() ? expandedView.getWidth() : -expandedView.getWidth());
expandedView.animate().setInterpolator(new LinearOutSlowInInterpolator()).translationX(0);
return false;
}
});
setFocused(true);
expanded = true;
}
use of android.app.PendingIntent.CanceledException in project android_frameworks_opt_telephony by LineageOS.
the class CdmaSMSDispatcher method sendText.
/**
* {@inheritDoc}
*/
@Override
public void sendText(String destAddr, String scAddr, String text, PendingIntent sentIntent, PendingIntent deliveryIntent, Uri messageUri, String callingPkg, boolean persistMessage) {
SmsMessage.SubmitPdu pdu = SmsMessage.getSubmitPdu(scAddr, destAddr, text, (deliveryIntent != null), null);
if (pdu != null) {
HashMap map = getSmsTrackerMap(destAddr, scAddr, text, pdu);
SmsTracker tracker = getSmsTracker(map, sentIntent, deliveryIntent, getFormat(), messageUri, false, /*isExpectMore*/
text, true, /*isText*/
persistMessage);
String carrierPackage = getCarrierAppPackageName();
if (carrierPackage != null) {
Rlog.d(TAG, "Found carrier package.");
TextSmsSender smsSender = new TextSmsSender(tracker);
smsSender.sendSmsByCarrierApp(carrierPackage, new SmsSenderCallback(smsSender));
} else {
Rlog.v(TAG, "No carrier package.");
sendSubmitPdu(tracker);
}
} else {
Rlog.e(TAG, "CdmaSMSDispatcher.sendText(): getSubmitPdu() returned null");
if (sentIntent != null) {
try {
sentIntent.send(SmsManager.RESULT_ERROR_GENERIC_FAILURE);
} catch (CanceledException ex) {
Rlog.e(TAG, "Intent has been canceled!");
}
}
}
}
use of android.app.PendingIntent.CanceledException in project android_frameworks_opt_telephony by LineageOS.
the class GsmSMSDispatcher method handleStatusReport.
/**
* Called when a status report is received. This should correspond to
* a previously successful SEND.
*
* @param ar AsyncResult passed into the message handler. ar.result should
* be a String representing the status report PDU, as ASCII hex.
*/
private void handleStatusReport(AsyncResult ar) {
byte[] pdu = (byte[]) ar.result;
SmsMessage sms = SmsMessage.newFromCDS(pdu);
if (sms != null) {
int tpStatus = sms.getStatus();
int messageRef = sms.mMessageRef;
for (int i = 0, count = deliveryPendingList.size(); i < count; i++) {
SmsTracker tracker = deliveryPendingList.get(i);
if (tracker.mMessageRef == messageRef) {
// Found it. Remove from list and broadcast.
if (tpStatus >= Sms.STATUS_FAILED || tpStatus < Sms.STATUS_PENDING) {
deliveryPendingList.remove(i);
// Update the message status (COMPLETE or FAILED)
tracker.updateSentMessageStatus(mContext, tpStatus);
}
PendingIntent intent = tracker.mDeliveryIntent;
Intent fillIn = new Intent();
fillIn.putExtra("pdu", pdu);
fillIn.putExtra("format", getFormat());
try {
intent.send(mContext, Activity.RESULT_OK, fillIn);
} catch (CanceledException ex) {
}
// Only expect to see one tracker matching this messageref
break;
}
}
}
mCi.acknowledgeLastIncomingGsmSms(true, Intents.RESULT_SMS_HANDLED, null);
}
use of android.app.PendingIntent.CanceledException in project android_frameworks_opt_telephony by LineageOS.
the class ImsSMSDispatcher method injectSmsPdu.
@VisibleForTesting
@Override
public void injectSmsPdu(byte[] pdu, String format, PendingIntent receivedIntent) {
Rlog.d(TAG, "ImsSMSDispatcher:injectSmsPdu");
try {
// TODO We need to decide whether we should allow injecting GSM(3gpp)
// SMS pdus when the phone is camping on CDMA(3gpp2) network and vice versa.
android.telephony.SmsMessage msg = android.telephony.SmsMessage.createFromPdu(pdu, format);
// Only class 1 SMS are allowed to be injected.
if (msg == null || msg.getMessageClass() != android.telephony.SmsMessage.MessageClass.CLASS_1) {
if (msg == null) {
Rlog.e(TAG, "injectSmsPdu: createFromPdu returned null");
}
if (receivedIntent != null) {
receivedIntent.send(Intents.RESULT_SMS_GENERIC_ERROR);
}
return;
}
AsyncResult ar = new AsyncResult(receivedIntent, msg, null);
if (format.equals(SmsConstants.FORMAT_3GPP)) {
Rlog.i(TAG, "ImsSMSDispatcher:injectSmsText Sending msg=" + msg + ", format=" + format + "to mGsmInboundSmsHandler");
mGsmInboundSmsHandler.sendMessage(InboundSmsHandler.EVENT_INJECT_SMS, ar);
} else if (format.equals(SmsConstants.FORMAT_3GPP2)) {
Rlog.i(TAG, "ImsSMSDispatcher:injectSmsText Sending msg=" + msg + ", format=" + format + "to mCdmaInboundSmsHandler");
mCdmaInboundSmsHandler.sendMessage(InboundSmsHandler.EVENT_INJECT_SMS, ar);
} else {
// Invalid pdu format.
Rlog.e(TAG, "Invalid pdu format: " + format);
if (receivedIntent != null)
receivedIntent.send(Intents.RESULT_SMS_GENERIC_ERROR);
}
} catch (Exception e) {
Rlog.e(TAG, "injectSmsPdu failed: ", e);
try {
if (receivedIntent != null)
receivedIntent.send(Intents.RESULT_SMS_GENERIC_ERROR);
} catch (CanceledException ex) {
}
}
}
use of android.app.PendingIntent.CanceledException in project robolectric by robolectric.
the class ShadowPendingIntent method send.
@Implementation(minSdk = M)
protected void send(Context context, int code, Intent intent, PendingIntent.OnFinished onFinished, Handler handler, String requiredPermission, Bundle options) throws CanceledException {
this.lastOnFinished = handler == null ? onFinished : (pendingIntent, intent1, resultCode, resultData, resultExtras) -> handler.post(() -> onFinished.onSendFinished(pendingIntent, intent1, resultCode, resultData, resultExtras));
if (canceled) {
throw new CanceledException();
}
// Fill in the last Intent, if it is mutable, with information now available at send-time.
Intent[] intentsToSend;
if (intent != null && isMutable(flags)) {
// Copy the last intent before filling it in to avoid modifying this PendingIntent.
intentsToSend = Arrays.copyOf(savedIntents, savedIntents.length);
Intent lastIntentCopy = new Intent(intentsToSend[intentsToSend.length - 1]);
lastIntentCopy.fillIn(intent, 0);
intentsToSend[intentsToSend.length - 1] = lastIntentCopy;
} else {
intentsToSend = savedIntents;
}
ActivityThread activityThread = (ActivityThread) RuntimeEnvironment.getActivityThread();
ShadowInstrumentation shadowInstrumentation = Shadow.extract(activityThread.getInstrumentation());
if (isActivityIntent()) {
for (Intent intentToSend : intentsToSend) {
shadowInstrumentation.execStartActivity(context, (IBinder) null, (IBinder) null, (Activity) null, intentToSend, 0, (Bundle) null);
}
} else if (isBroadcastIntent()) {
for (Intent intentToSend : intentsToSend) {
shadowInstrumentation.sendBroadcastWithPermission(intentToSend, requiredPermission, context, options, code);
}
} else if (isServiceIntent()) {
for (Intent intentToSend : intentsToSend) {
context.startService(intentToSend);
}
} else if (isForegroundServiceIntent()) {
for (Intent intentToSend : intentsToSend) {
context.startForegroundService(intentToSend);
}
}
if (isOneShot(flags)) {
cancel();
}
}
Aggregations