use of android.app.PendingIntent.CanceledException in project android_frameworks_base by ParanoidAndroid.
the class KeyguardTransportControlView method sendMediaButtonClick.
private void sendMediaButtonClick(int keyCode) {
if (mClientIntent == null) {
// Shouldn't be possible because this view should be hidden in this case.
Log.e(TAG, "sendMediaButtonClick(): No client is currently registered");
return;
}
// use the registered PendingIntent that will be processed by the registered
// media button event receiver, which is the component of mClientIntent
KeyEvent keyEvent = new KeyEvent(KeyEvent.ACTION_DOWN, keyCode);
Intent intent = new Intent(Intent.ACTION_MEDIA_BUTTON);
intent.putExtra(Intent.EXTRA_KEY_EVENT, keyEvent);
try {
mClientIntent.send(getContext(), 0, intent);
} catch (CanceledException e) {
Log.e(TAG, "Error sending intent for media button down: " + e);
e.printStackTrace();
}
keyEvent = new KeyEvent(KeyEvent.ACTION_UP, keyCode);
intent = new Intent(Intent.ACTION_MEDIA_BUTTON);
intent.putExtra(Intent.EXTRA_KEY_EVENT, keyEvent);
try {
mClientIntent.send(getContext(), 0, intent);
} catch (CanceledException e) {
Log.e(TAG, "Error sending intent for media button up: " + e);
e.printStackTrace();
}
}
use of android.app.PendingIntent.CanceledException in project android_frameworks_base by ParanoidAndroid.
the class AudioService method dispatchMediaKeyEvent.
/**
* Handles the dispatching of the media button events to one of the registered listeners,
* or if there was none, broadcast an ACTION_MEDIA_BUTTON intent to the rest of the system.
* @param keyEvent a non-null KeyEvent whose key code is one of the supported media buttons
* @param needWakeLock true if a PARTIAL_WAKE_LOCK needs to be held while this key event
* is dispatched.
*/
private void dispatchMediaKeyEvent(KeyEvent keyEvent, boolean needWakeLock) {
if (needWakeLock) {
mMediaEventWakeLock.acquire();
}
Intent keyIntent = new Intent(Intent.ACTION_MEDIA_BUTTON, null);
keyIntent.putExtra(Intent.EXTRA_KEY_EVENT, keyEvent);
synchronized (mRCStack) {
if (!mRCStack.empty()) {
// send the intent that was registered by the client
try {
mRCStack.peek().mMediaIntent.send(mContext, needWakeLock ? WAKELOCK_RELEASE_ON_FINISHED : 0, /*code*/
keyIntent, AudioService.this, mAudioHandler);
} catch (CanceledException e) {
Log.e(TAG, "Error sending pending intent " + mRCStack.peek());
e.printStackTrace();
}
} else {
// through AudioManager
if (needWakeLock) {
keyIntent.putExtra(EXTRA_WAKELOCK_ACQUIRED, WAKELOCK_RELEASE_ON_FINISHED);
}
final long ident = Binder.clearCallingIdentity();
try {
mContext.sendOrderedBroadcastAsUser(keyIntent, UserHandle.ALL, null, mKeyEventDone, mAudioHandler, Activity.RESULT_OK, null, null);
} finally {
Binder.restoreCallingIdentity(ident);
}
}
}
}
use of android.app.PendingIntent.CanceledException in project android_frameworks_base by ResurrectionRemix.
the class ImeTile method handleClick.
@Override
public void handleClick() {
mHost.collapsePanels();
Intent intent = new Intent(Settings.ACTION_SHOW_INPUT_METHOD_PICKER);
PendingIntent pendingIntent = PendingIntent.getBroadcast(mContext, 0, intent, 0);
try {
pendingIntent.send();
} catch (CanceledException e) {
}
}
use of android.app.PendingIntent.CanceledException in project android_frameworks_base by DirtyUnicorns.
the class ImeTile method handleClick.
@Override
public void handleClick() {
mHost.collapsePanels();
Intent intent = new Intent(Settings.ACTION_SHOW_INPUT_METHOD_PICKER);
PendingIntent pendingIntent = PendingIntent.getBroadcast(mContext, 0, intent, 0);
try {
pendingIntent.send();
} catch (CanceledException e) {
}
}
use of android.app.PendingIntent.CanceledException in project XobotOS by xamarin.
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) {
String pduString = (String) ar.result;
SmsMessage sms = SmsMessage.newFromCDS(pduString);
if (sms != null) {
int tpStatus = sms.getStatus();
int messageRef = sms.messageRef;
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);
}
PendingIntent intent = tracker.mDeliveryIntent;
Intent fillIn = new Intent();
fillIn.putExtra("pdu", IccUtils.hexStringToBytes(pduString));
fillIn.putExtra("format", android.telephony.SmsMessage.FORMAT_3GPP);
try {
intent.send(mContext, Activity.RESULT_OK, fillIn);
} catch (CanceledException ex) {
}
// Only expect to see one tracker matching this messageref
break;
}
}
}
acknowledgeLastIncomingSms(true, Intents.RESULT_SMS_HANDLED, null);
}
Aggregations