Example usage for android.os Parcel unmarshall

List of usage examples for android.os Parcel unmarshall

Introduction

In this page you can find the example usage for android.os Parcel unmarshall.

Prototype

public final void unmarshall(byte[] data, int offset, int length) 

Source Link

Document

Set the bytes in data to be the raw bytes of this Parcel.

Usage

From source file:edu.umich.flowfence.common.ParceledPayload.java

public Object getValue(ClassLoader loader) {
    Parcel p = Parcel.obtain();
    try {//from  w  w  w  .  jav a2 s . c  o m
        p.unmarshall(data, 0, data.length);
        p.setDataPosition(0);
        return p.readValue(loader);
    } finally {
        p.recycle();
    }
}

From source file:com.harlie.android.sunshine.app.ItemChoiceManager.java

public void onRestoreInstanceState(Bundle savedInstanceState) {
    byte[] states = savedInstanceState.getByteArray(SELECTED_ITEMS_KEY);
    if (null != states) {
        Parcel inParcel = Parcel.obtain();
        inParcel.unmarshall(states, 0, states.length);
        inParcel.setDataPosition(0);//from w  ww.  j  ava 2 s . c o  m
        mCheckStates = inParcel.readSparseBooleanArray();
        final int numStates = inParcel.readInt();
        mCheckedIdStates.clear();
        for (int i = 0; i < numStates; i++) {
            final long key = inParcel.readLong();
            final int value = inParcel.readInt();
            mCheckedIdStates.put(key, value);
        }
        inParcel.recycle();
    }
}

From source file:app.com.example.android.sunshine.ItemChoiceManager.java

public void onRestoreInstanceState(Bundle savedInstanceState) {
    byte[] states = savedInstanceState.getByteArray(SELECTED_ITEMS_KEY);
    if (null != states) {
        Parcel inParcel = Parcel.obtain();
        inParcel.unmarshall(states, 0, states.length);
        inParcel.setDataPosition(0);//w  w  w.  ja  v a2  s .  com
        mCheckStates = inParcel.readSparseBooleanArray();
        final int numStates = inParcel.readInt();
        mCheckedIdStates.clear();
        for (int i = 0; i < numStates; i++) {
            final long key = inParcel.readLong();
            final int value = inParcel.readInt();
            mCheckedIdStates.put(key, value);
        }
    }
}

From source file:org.sufficientlysecure.keychain.ui.adapter.MultiUserIdsAdapter.java

@Override
public void bindView(View view, Context context, Cursor cursor) {
    TextView vHeaderId = (TextView) view.findViewById(R.id.user_id_header);
    TextView vName = (TextView) view.findViewById(R.id.user_id_item_name);
    TextView vAddresses = (TextView) view.findViewById(R.id.user_id_item_addresses);

    byte[] data = cursor.getBlob(1);
    int isHeader = cursor.getInt(2);
    Parcel p = Parcel.obtain();
    p.unmarshall(data, 0, data.length);
    p.setDataPosition(0);//w  w w.  jav a  2  s. co m
    ArrayList<String> uids = p.createStringArrayList();
    p.recycle();

    { // first one
        String userId = uids.get(0);
        OpenPgpUtils.UserId splitUserId = KeyRing.splitUserId(userId);
        if (splitUserId.name != null) {
            vName.setText(splitUserId.name);
        } else {
            vName.setText(R.string.user_id_no_name);
        }

        if (isHeader == 1) {
            vHeaderId.setVisibility(View.VISIBLE);
            String message;
            if (splitUserId.name != null) {
                message = mContext.getString(R.string.section_uids_to_certify) + splitUserId.name;
            } else {
                message = mContext.getString(R.string.section_uids_to_certify)
                        + context.getString(R.string.user_id_no_name);
            }
            vHeaderId.setText(message);
        } else {
            vHeaderId.setVisibility(View.GONE);
        }
    }

    StringBuilder lines = new StringBuilder();
    for (String uid : uids) {
        OpenPgpUtils.UserId splitUserId = KeyRing.splitUserId(uid);
        if (splitUserId.email == null) {
            continue;
        }
        lines.append(splitUserId.email);
        if (splitUserId.comment != null) {
            lines.append(" (").append(splitUserId.comment).append(")");
        }
        lines.append('\n');
    }

    // If we have any data here, show it
    if (lines.length() > 0) {
        // delete last newline
        lines.setLength(lines.length() - 1);
        vAddresses.setVisibility(View.VISIBLE);
        vAddresses.setText(lines);
    } else {
        vAddresses.setVisibility(View.GONE);
    }

    final CheckBox vCheckBox = (CheckBox) view.findViewById(R.id.user_id_item_check_box);
    final int position = cursor.getPosition();
    vCheckBox.setOnCheckedChangeListener(null);
    vCheckBox.setChecked(mCheckStates.get(position));
    vCheckBox.setOnCheckedChangeListener(new CompoundButton.OnCheckedChangeListener() {
        @Override
        public void onCheckedChanged(CompoundButton compoundButton, boolean b) {
            mCheckStates.set(position, b);
        }
    });
    vCheckBox.setClickable(false);
    vCheckBox.setVisibility(checkboxVisibility ? View.VISIBLE : View.GONE);

    View vUidBody = view.findViewById(R.id.user_id_body);
    vUidBody.setClickable(true);
    vUidBody.setOnClickListener(new OnClickListener() {
        @Override
        public void onClick(View v) {
            vCheckBox.toggle();
        }
    });

}

From source file:com.granita.tasks.notification.NotificationActionIntentService.java

@TargetApi(Build.VERSION_CODES.HONEYCOMB_MR2)
@Override/*from ww w .  j  a v a  2 s .co m*/
protected void onHandleIntent(Intent intent) {
    mAuthority = getString(R.string.org_dmfs_tasks_authority);

    final String action = intent.getAction();
    final Context context = this;

    if (intent.hasExtra(EXTRA_NOTIFICATION_ID)) {
        Uri taskUri = intent.getData();
        int notificationId = intent.getIntExtra(EXTRA_NOTIFICATION_ID, -1);

        NotificationManagerCompat notificationManager = NotificationManagerCompat.from(this);
        notificationManager.cancel(notificationId);

        if (ACTION_COMPLETE.equals(action)) {
            markCompleted(taskUri);

        } else if (intent.hasExtra(EXTRA_TASK_DUE) && intent.hasExtra(EXTRA_TIMEZONE)) {
            long due = intent.getLongExtra(EXTRA_TASK_DUE, -1);
            String tz = intent.getStringExtra(EXTRA_TIMEZONE);
            boolean allDay = intent.getBooleanExtra(EXTRA_ALLDAY, false);
            if (ACTION_DELAY_1H.equals(action)) {
                Time time = new Time(tz);
                time.set(due);
                time.allDay = false;
                time.hour++;
                time.normalize(true);
                delayTask(taskUri, time);
            } else if (ACTION_DELAY_1D.equals(action)) {
                if (tz == null) {
                    tz = "UTC";
                }
                Time time = new Time(tz);
                time.set(due);
                time.allDay = allDay;
                time.monthDay++;
                time.normalize(true);
                delayTask(taskUri, time);
            }

        }

    } else if (intent.hasExtra(NotificationActionUtils.EXTRA_NOTIFICATION_ACTION)) {

        /*
         * Grab the alarm from the intent. Since the remote AlarmManagerService fills in the Intent to add some extra data, it must unparcel the
         * NotificationAction object. It throws a ClassNotFoundException when unparcelling. To avoid this, do the marshalling ourselves.
         */
        final NotificationAction notificationAction;
        final byte[] data = intent.getByteArrayExtra(NotificationActionUtils.EXTRA_NOTIFICATION_ACTION);
        if (data != null) {
            final Parcel in = Parcel.obtain();
            in.unmarshall(data, 0, data.length);
            in.setDataPosition(0);
            notificationAction = NotificationAction.CREATOR.createFromParcel(in,
                    NotificationAction.class.getClassLoader());
        } else {
            return;
        }

        if (NotificationActionUtils.ACTION_UNDO.equals(action)) {
            NotificationActionUtils.cancelUndoTimeout(context, notificationAction);
            NotificationActionUtils.cancelUndoNotification(context, notificationAction);
            resendNotification(notificationAction);
        } else if (ACTION_COMPLETE.equals(action)) {
            // All we need to do is switch to an Undo notification
            NotificationActionUtils.createUndoNotification(context, notificationAction);
            NotificationActionUtils.registerUndoTimeout(this, notificationAction);
        } else {
            if (NotificationActionUtils.ACTION_UNDO_TIMEOUT.equals(action)
                    || NotificationActionUtils.ACTION_DESTRUCT.equals(action)) {
                // Process the action
                NotificationActionUtils.cancelUndoTimeout(this, notificationAction);
                NotificationActionUtils.processUndoNotification(this, notificationAction);
                processDesctructiveNotification(notificationAction);
            }
        }
    }

}

From source file:net.geniecode.ttr.ScheduleReceiver.java

@SuppressWarnings("deprecation")
@SuppressLint({ "Recycle", "NewApi", "InlinedApi" })
@Override//from   w ww.ja  v  a 2s.c om
public void onReceive(Context context, Intent intent) {
    if (!Schedules.SCHEDULE_ACTION.equals(intent.getAction())) {
        // Unknown intent, bail.
        return;
    }

    Schedule schedule = null;
    // Grab the schedule from the intent. Since the remote AlarmManagerService
    // fills in the Intent to add some extra data, it must unparcel the
    // Schedule object. It throws a ClassNotFoundException when unparcelling.
    // To avoid this, do the marshalling ourselves.
    final byte[] data = intent.getByteArrayExtra(Schedules.SCHEDULE_RAW_DATA);
    if (data != null) {
        Parcel in = Parcel.obtain();
        in.unmarshall(data, 0, data.length);
        in.setDataPosition(0);
        schedule = Schedule.CREATOR.createFromParcel(in);
    }

    if (schedule == null) {
        // Make sure we set the next schedule if needed.
        Schedules.setNextSchedule(context);
        return;
    }

    // Disable this schedule if it does not repeat.
    if (!schedule.daysOfWeek.isRepeatSet()) {
        Schedules.enableSchedule(context, schedule.id, false);
    } else {
        // Enable the next schedule if there is one. The above call to
        // enableSchedule will call setNextSchedule so avoid calling it twice.
        Schedules.setNextSchedule(context);
    }

    long now = System.currentTimeMillis();

    if (now > schedule.time + STALE_WINDOW) {
        return;
    }

    // Get telephony service
    mTelephonyManager = (TelephonyManager) context.getSystemService(Context.TELEPHONY_SERVICE);

    // Execute only for devices with versions of Android less than 4.2
    if (android.os.Build.VERSION.SDK_INT < 17) {
        // Get flight mode state
        boolean isEnabled = Settings.System.getInt(context.getContentResolver(),
                Settings.System.AIRPLANE_MODE_ON, 0) == 1;

        // Get Wi-Fi service
        mWifiManager = (WifiManager) context.getSystemService(Context.WIFI_SERVICE);

        if ((schedule.aponoff) && (!isEnabled) && (schedule.mode.equals("1"))
                && (mTelephonyManager.getCallState() == TelephonyManager.CALL_STATE_IDLE)) {
            // Enable flight mode
            Settings.System.putInt(context.getContentResolver(), Settings.System.AIRPLANE_MODE_ON,
                    isEnabled ? 0 : 1);

            // Get Wi-Fi state and disable that one too, just in case
            // (On some devices it doesn't get disabled when the flight mode is
            // turned on, so we do it here)
            boolean isWifiEnabled = mWifiManager.isWifiEnabled();

            SharedPreferences settings = context.getSharedPreferences(PREFS_NAME, 0);

            if (isWifiEnabled) {
                SharedPreferences.Editor editor = settings.edit();
                editor.putBoolean(WIFI_STATE, isWifiEnabled);
                editor.commit();
                mWifiManager.setWifiEnabled(false);
            } else {
                SharedPreferences.Editor editor = settings.edit();
                editor.putBoolean(WIFI_STATE, isWifiEnabled);
                editor.commit();
            }

            // Post an intent to reload
            Intent relintent = new Intent(Intent.ACTION_AIRPLANE_MODE_CHANGED);
            relintent.putExtra("state", !isEnabled);
            context.sendBroadcast(relintent);
        } else if ((!schedule.aponoff) && (isEnabled) && (schedule.mode.equals("1"))) {
            // Disable flight mode
            Settings.System.putInt(context.getContentResolver(), Settings.System.AIRPLANE_MODE_ON,
                    isEnabled ? 0 : 1);

            // Restore previously remembered Wi-Fi state
            SharedPreferences settings = context.getSharedPreferences(PREFS_NAME, 0);
            Boolean WiFiState = settings.getBoolean(WIFI_STATE, true);

            if (WiFiState) {
                mWifiManager.setWifiEnabled(true);
            }

            // Post an intent to reload
            Intent relintent = new Intent(Intent.ACTION_AIRPLANE_MODE_CHANGED);
            relintent.putExtra("state", !isEnabled);
            context.sendBroadcast(relintent);
        }
        // Check whether there are ongoing phone calls, and if so
        // show notification instead of just enabling the flight mode
        else if ((schedule.aponoff) && (!isEnabled) && (schedule.mode.equals("1"))
                && (mTelephonyManager.getCallState() != TelephonyManager.CALL_STATE_IDLE)) {
            setNotification(context);
        }
        // Execute for devices with Android 4.2   or higher
    } else {
        // Get flight mode state
        String result = Settings.Global.getString(context.getContentResolver(),
                Settings.Global.AIRPLANE_MODE_ON);

        if ((schedule.aponoff) && (result.equals("0")) && (schedule.mode.equals("1"))
                && (mTelephonyManager.getCallState() == TelephonyManager.CALL_STATE_IDLE)) {
            // Keep the device awake while enabling flight mode
            Intent service = new Intent(context, ScheduleIntentService.class);
            startWakefulService(context, service);
        } else if ((!schedule.aponoff) && (result.equals("1")) && (schedule.mode.equals("1"))) {
            // Keep the device awake while enabling flight mode
            Intent service = new Intent(context, ScheduleIntentService.class);
            startWakefulService(context, service);
        } else if ((schedule.aponoff) && (result.equals("0")) && (schedule.mode.equals("1"))
                && (mTelephonyManager.getCallState() != TelephonyManager.CALL_STATE_IDLE)) {
            setNotification(context);
        }
    }

    // Get audio service
    mAudioManager = (AudioManager) context.getSystemService(Context.AUDIO_SERVICE);

    // Get current ringer mode and set silent or normal mode accordingly
    switch (mAudioManager.getRingerMode()) {
    case AudioManager.RINGER_MODE_SILENT:
        if ((!schedule.silentonoff) && (schedule.mode.equals("2"))) {
            mAudioManager.setRingerMode(AudioManager.RINGER_MODE_NORMAL);
        }
        break;
    case AudioManager.RINGER_MODE_NORMAL:
        if ((schedule.silentonoff) && (schedule.mode.equals("2"))) {
            mAudioManager.setRingerMode(AudioManager.RINGER_MODE_SILENT);
        }
        break;
    case AudioManager.RINGER_MODE_VIBRATE:
        // If the phone is set to vibrate let's make it completely silent
        if ((schedule.silentonoff) && (schedule.mode.equals("2"))) {
            mAudioManager.setRingerMode(AudioManager.RINGER_MODE_SILENT);
        }
        // or restore the regular sounds on it if that's scheduled
        else if ((!schedule.silentonoff) && (schedule.mode.equals("2"))) {
            mAudioManager.setRingerMode(AudioManager.RINGER_MODE_NORMAL);
        }
        break;
    }
}

From source file:com.tct.mail.NotificationActionIntentService.java

@Override
protected void onHandleIntent(final Intent intent) {
    final Context context = this;
    final String action = intent.getAction();
    // TS: chao.zhang 2015-09-21 EMAIL FEATURE-585337 ADD_S
    //NOTE: handle the refresh intent.
    if (ACTION_REFRESH.equals(action)) {
        boolean cleanStatus = intent.getBooleanExtra(NotificationUtils.EXTRA_NEED_CLEAN_STATUS, false);
        long boxId = intent.getLongExtra(NotificationUtils.EXTRA_OUTBOX_ID, -1);
        //after click the action,cancel the notification.
        int notificationId = intent.getIntExtra(NotificationUtils.EXTRA_FAIL_NOTIFICATION_ID, 0);
        NotificationManager mNotificationManager = (NotificationManager) context
                .getSystemService(Context.NOTIFICATION_SERVICE);
        mNotificationManager.cancel(notificationId);
        if (boxId == -1) {
            LogUtils.e(LOG_TAG,/*from w  ww  . j  ava 2s  .  c o m*/
                    "can't find the oubox during handle Intent ACTION_REFRESH in NotificationActionIntentService#onHandleIntent");
            return;
        }
        Uri refreshUri = intent.getData();
        if (cleanStatus && isOutboxNotEmpty(context, boxId)) {
            // 1.clean failed status
            cleanFaildMailStatus(context, boxId);
            // 2.start refresh(sync) the outbox
            context.getContentResolver().query(refreshUri, null, null, null, null);
            // 3. show the sending toast
            // Why add toast to Handler? cause the notificationActionIntentService is
            // asynchronous,so want show toast,
            // only must add toast to Main thread.
            Handler handler = new Handler(Looper.getMainLooper());
            handler.post(new Runnable() {
                @Override
                public void run() {
                    // TODO Auto-generated method stub
                    Toast.makeText(getApplicationContext(), R.string.sending, Toast.LENGTH_SHORT).show();
                }
            });
        }
        return;
    }
    // TS: chao.zhang 2015-09-21 EMAIL FEATURE-585337 ADD_E
    else if (ACTION_CALENDAR_NEVER_ASK_AGAIN.equals(action)) {
        NotificationManager mNotificationManager = (NotificationManager) context
                .getSystemService(Context.NOTIFICATION_SERVICE);
        if (mNotificationManager != null) {
            mNotificationManager.cancel(NotificationController.EXCHANGE_NEWCALENDAR_NOTIFICATION_ID);
        }
        MailPrefs.get(context).setIgnoreExchangeCalendarPermission(true); //TS: zheng.zou 2016-1-22 EMAIL BUGFIX-1431088 ADD
        return;
    } else if (ACTION_CONTACTS_NEVER_ASK_AGAIN.equals(action)) {
        NotificationManager mNotificationManager = (NotificationManager) context
                .getSystemService(Context.NOTIFICATION_SERVICE);
        if (mNotificationManager != null) {
            mNotificationManager.cancel(NotificationController.EXCHANGE_NEWCONTACTS_NOTIFICATION_ID);
        }
        MailPrefs.get(context).setIgnoreExchangeContactPermission(true); //TS: zheng.zou 2016-1-22 EMAIL BUGFIX-1431088 ADD
        return;
    } else if (ACTION_STORAGE_NEVER_ASK_AGAIN.equals(action)) { //TS: zheng.zou 2016-1-22 EMAIL BUGFIX-1431088 ADD_S
        NotificationManager mNotificationManager = (NotificationManager) context
                .getSystemService(Context.NOTIFICATION_SERVICE);
        if (mNotificationManager != null) {
            mNotificationManager.cancel(NotificationController.EXCHANGE_NEWSTORAGE_NOTIFICATION_ID);
        }
        MailPrefs.get(context).setIgnoreExchangeStoragePermission(true);
        //TS: zheng.zou 2016-1-22 EMAIL BUGFIX-1431088 ADD_E
    }
    /*
     * Grab the alarm from the intent. Since the remote AlarmManagerService fills in the Intent
     * to add some extra data, it must unparcel the NotificationAction object. It throws a
     * ClassNotFoundException when unparcelling.
     * To avoid this, do the marshalling ourselves.
     */
    final NotificationAction notificationAction;
    final byte[] data = intent.getByteArrayExtra(EXTRA_NOTIFICATION_ACTION);
    if (data != null) {
        final Parcel in = Parcel.obtain();
        in.unmarshall(data, 0, data.length);
        in.setDataPosition(0);
        notificationAction = NotificationAction.CREATOR.createFromParcel(in,
                NotificationAction.class.getClassLoader());
    } else {
        LogUtils.wtf(LOG_TAG, "data was null trying to unparcel the NotificationAction");
        return;
    }

    final Message message = notificationAction.getMessage();

    final ContentResolver contentResolver = getContentResolver();

    LogUtils.i(LOG_TAG, "Handling %s", action);

    logNotificationAction(action, notificationAction);

    if (notificationAction.getSource() == NotificationAction.SOURCE_REMOTE) {
        // Skip undo if the action is bridged from remote node.  This should be similar to the
        // logic after the Undo notification expires in a regular flow.
        LogUtils.d(LOG_TAG, "Canceling %s", notificationAction.getNotificationId());
        NotificationManagerCompat.from(context).cancel(notificationAction.getNotificationId());
        NotificationActionUtils.processDestructiveAction(this, notificationAction);
        NotificationActionUtils.resendNotifications(context, notificationAction.getAccount(),
                notificationAction.getFolder());
        return;
    }

    if (ACTION_UNDO.equals(action)) {
        NotificationActionUtils.cancelUndoTimeout(context, notificationAction);
        NotificationActionUtils.cancelUndoNotification(context, notificationAction);
    } else if (ACTION_ARCHIVE_REMOVE_LABEL.equals(action) || ACTION_DELETE.equals(action)) {
        // All we need to do is switch to an Undo notification
        NotificationActionUtils.createUndoNotification(context, notificationAction);

        NotificationActionUtils.registerUndoTimeout(context, notificationAction);
    } else {
        if (ACTION_UNDO_TIMEOUT.equals(action) || ACTION_DESTRUCT.equals(action)) {
            // Process the action
            NotificationActionUtils.cancelUndoTimeout(this, notificationAction);
            NotificationActionUtils.processUndoNotification(this, notificationAction);
        } else if (ACTION_MARK_READ.equals(action)) {
            final Uri uri = message.uri;

            final ContentValues values = new ContentValues(1);
            values.put(UIProvider.MessageColumns.READ, 1);

            contentResolver.update(uri, values, null, null);
        }

        NotificationActionUtils.resendNotifications(context, notificationAction.getAccount(),
                notificationAction.getFolder());
    }
}

From source file:org.thoughtcrime.securesms.ShareActivity.java

private void handleResolvedMedia(Intent intent, boolean animate) {
    long threadId = intent.getLongExtra(EXTRA_THREAD_ID, -1);
    int distributionType = intent.getIntExtra(EXTRA_DISTRIBUTION_TYPE, -1);
    Address address = null;/*  w  w  w.  ja  v a 2  s  .c om*/

    if (intent.hasExtra(EXTRA_ADDRESS_MARSHALLED)) {
        Parcel parcel = Parcel.obtain();
        byte[] marshalled = intent.getByteArrayExtra(EXTRA_ADDRESS_MARSHALLED);
        parcel.unmarshall(marshalled, 0, marshalled.length);
        parcel.setDataPosition(0);
        address = parcel.readParcelable(getClassLoader());
        parcel.recycle();
    }

    boolean hasResolvedDestination = threadId != -1 && address != null && distributionType != -1;

    if (!hasResolvedDestination && animate) {
        ViewUtil.fadeIn(contactsFragment.getView(), 300);
        ViewUtil.fadeOut(progressWheel, 300);
    } else if (!hasResolvedDestination) {
        contactsFragment.getView().setVisibility(View.VISIBLE);
        progressWheel.setVisibility(View.GONE);
    } else {
        createConversation(threadId, address, distributionType);
    }
}

From source file:ca.farrelltonsolar.classic.PVOutputUploader.java

private Bundle deserializeBundle(byte[] data) {
    Bundle bundle = null;/*from w  w  w. j av  a 2  s  . c o  m*/
    final Parcel parcel = Parcel.obtain();
    try {
        final ByteArrayOutputStream byteBuffer = new ByteArrayOutputStream();
        final byte[] buffer = new byte[1024];
        final GZIPInputStream zis = new GZIPInputStream(new ByteArrayInputStream(data));
        int len = 0;
        while ((len = zis.read(buffer)) != -1) {
            byteBuffer.write(buffer, 0, len);
        }
        zis.close();
        parcel.unmarshall(byteBuffer.toByteArray(), 0, byteBuffer.size());
        parcel.setDataPosition(0);
        bundle = parcel.readBundle();
    } catch (IOException ex) {
        Log.w(getClass().getName(), String.format("deserializeBundle failed ex: %s", ex));
        bundle = null;
    } finally {
        parcel.recycle();
    }
    return bundle;
}

From source file:org.dmfs.tasks.notification.NotificationUpdaterService.java

@TargetApi(Build.VERSION_CODES.HONEYCOMB_MR2)
private void resolveUndoAction(Intent intent) {
    if (!intent.hasExtra(NotificationActionUtils.EXTRA_NOTIFICATION_ACTION)) {
        return;/*from w  w  w  .j a va2 s .  c  o  m*/
    }

    /*
     * Grab the alarm from the intent. Since the remote AlarmManagerService fills in the Intent to add some extra data, it must unparcel the
     * NotificationAction object. It throws a ClassNotFoundException when unparcelling. To avoid this, do the marshalling ourselves.
     */
    final NotificationAction notificationAction;
    final String action = intent.getAction();
    final byte[] data = intent.getByteArrayExtra(NotificationActionUtils.EXTRA_NOTIFICATION_ACTION);
    if (data != null) {
        final Parcel in = Parcel.obtain();
        in.unmarshall(data, 0, data.length);
        in.setDataPosition(0);
        notificationAction = NotificationAction.CREATOR.createFromParcel(in);
    } else {
        return;
    }

    if (NotificationActionUtils.ACTION_UNDO.equals(action)) {
        NotificationActionUtils.cancelUndoTimeout(this, notificationAction);
        NotificationActionUtils.cancelUndoNotification(this, notificationAction);
        resendNotification(notificationAction);
    } else if (ACTION_COMPLETE.equals(action)) {
        // All we need to do is switch to an Undo notification
        NotificationActionUtils.createUndoNotification(this, notificationAction);
        NotificationActionUtils.registerUndoTimeout(this, notificationAction);
    } else {
        if (NotificationActionUtils.ACTION_UNDO_TIMEOUT.equals(action)
                || NotificationActionUtils.ACTION_DESTRUCT.equals(action)) {
            // Process the action
            NotificationActionUtils.cancelUndoTimeout(this, notificationAction);
            NotificationActionUtils.processUndoNotification(this, notificationAction);
            processDesctructiveNotification(notificationAction);
        }
    }
}