android.os.BadParcelableException Java Examples
The following examples show how to use
android.os.BadParcelableException.
You can vote up the ones you like or vote down the ones you don't like,
and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example #1
Source File: IntentUtil.java From OpenYOLO-Android with Apache License 2.0 | 6 votes |
/** * Deserializes an intent from the provided bytes array. * @throws BadParcelableException if the intent is null, not present, or malformed. */ @NonNull public static Intent fromBytes(@NonNull byte[] intentBytes) throws BadParcelableException { require(intentBytes, notNullValue()); Intent intent; try { Parcel parcel = Parcel.obtain(); parcel.unmarshall(intentBytes, 0, intentBytes.length); parcel.setDataPosition(0); intent = parcel.readParcelable(IntentUtil.class.getClassLoader()); parcel.recycle(); } catch (Exception ex) { throw new BadParcelableException(ex); } validate(intent, notNullValue(), BadParcelableException.class); return intent; }
Example #2
Source File: TicketAlarmReceiver.java From sms-ticket with Apache License 2.0 | 6 votes |
@Override public void onReceive(Context c, Intent intent) { try { final Ticket t = intent.getParcelableExtra(EXTRA_TICKET); if (t == null) { DebugLog.w("Scheduled ticket is null"); } else { if (INTENT_TICKET_ALARM_EXPIRING.equals(intent.getAction())) { NotificationUtil.notifyTicket(c, t, Preferences.getBoolean(c, Preferences.KEEP_NOTIFICATIONS, true)); DebugLog.i("Receiving alarm for expiring ticket " + t); } if (INTENT_TICKET_ALARM_EXPIRED.equals(intent.getAction())) { NotificationUtil.notifyTicket(c, t, false); DebugLog.i("Receiving alarm for expired ticket " + t); } } } catch (BadParcelableException e) { DebugLog.i("ticket was bought in the old version and alarm received in the new version, ignoring"); } }
Example #3
Source File: DurableUtils.java From FireFiles with Apache License 2.0 | 5 votes |
public static <D extends Durable> D readFromParcel(Parcel parcel, D d) { try { return readFromArray(parcel.createByteArray(), d); } catch (IOException e) { throw new BadParcelableException(e); } }
Example #4
Source File: Map.java From MapsMeasure with Apache License 2.0 | 5 votes |
@SuppressLint("NewApi") @Override public void onCreate(final Bundle savedInstanceState) { if (BuildConfig.DEBUG && Build.VERSION.SDK_INT >= 23 && PermissionChecker .checkSelfPermission(this, Manifest.permission.WRITE_EXTERNAL_STORAGE) != PermissionChecker.PERMISSION_GRANTED) { requestPermissions(new String[]{Manifest.permission.WRITE_EXTERNAL_STORAGE}, 0); } try { super.onCreate(savedInstanceState); } catch (final BadParcelableException bpe) { if (BuildConfig.DEBUG) Logger.log(bpe); } init(); }
Example #5
Source File: IntentCallout.java From commcare-android with Apache License 2.0 | 5 votes |
private static boolean intentInvalid(Intent intent) { if (intent == null) { return true; } try { // force unparcelling to check if we are missing classes to // correctly process callout response intent.hasExtra(INTENT_RESULT_VALUE); } catch (BadParcelableException e) { Log.w(TAG, "unable to unparcel intent: " + e.getMessage()); return true; } return false; }
Example #6
Source File: IntentUtils.java From 365browser with Apache License 2.0 | 5 votes |
/** * Sanitizes an intent. In case the intent cannot be unparcelled, all extras will be removed to * make it safe to use. * @return A safe to use version of this intent. */ public static Intent sanitizeIntent(final Intent incomingIntent) { if (incomingIntent == null) return null; try { incomingIntent.getBooleanExtra("TriggerUnparcel", false); return incomingIntent; } catch (BadParcelableException e) { Log.e(TAG, "Invalid incoming intent.", e); return incomingIntent.replaceExtras((Bundle) null); } }
Example #7
Source File: NevoDecoratorService.java From sdk with Apache License 2.0 | 5 votes |
private RuntimeException asParcelableException(final Throwable e) { if (e instanceof SecurityException || e instanceof BadParcelableException || e instanceof IllegalArgumentException || e instanceof NullPointerException || e instanceof IllegalStateException || e instanceof NetworkOnMainThreadException || e instanceof UnsupportedOperationException) return (RuntimeException) e; return new IllegalStateException(e); }
Example #8
Source File: IntentUtils.java From AndroidChromium with Apache License 2.0 | 5 votes |
/** * Sanitizes an intent. In case the intent cannot be unparcelled, all extras will be removed to * make it safe to use. * @return A safe to use version of this intent. */ public static Intent sanitizeIntent(final Intent incomingIntent) { if (incomingIntent == null) return null; try { incomingIntent.getBooleanExtra("TriggerUnparcel", false); return incomingIntent; } catch (BadParcelableException e) { Log.e(TAG, "Invalid incoming intent.", e); return incomingIntent.replaceExtras((Bundle) null); } }
Example #9
Source File: DurableUtils.java From FireFiles with Apache License 2.0 | 5 votes |
public static <D extends Durable> D readFromParcel(Parcel parcel, D d) { try { return readFromArray(parcel.createByteArray(), d); } catch (IOException e) { throw new BadParcelableException(e); } }
Example #10
Source File: DurableUtils.java From FireFiles with Apache License 2.0 | 5 votes |
public static <D extends Durable> void writeToParcel(Parcel parcel, D d) { try { parcel.writeByteArray(writeToArray(d)); } catch (IOException e) { throw new BadParcelableException(e); } }
Example #11
Source File: KeyChainSnapshot.java From android_9.0.0_r45 with Apache License 2.0 | 5 votes |
/** * CertPath containing the public key used to encrypt {@code encryptedRecoveryKeyBlob}. */ public @NonNull CertPath getTrustedHardwareCertPath() { try { return mCertPath.getCertPath(); } catch (CertificateException e) { // Rethrow an unchecked exception as it should not happen. If such an issue exists, // an exception should have been thrown during service initialization. throw new BadParcelableException(e); } }
Example #12
Source File: DurableUtils.java From FireFiles with Apache License 2.0 | 5 votes |
public static <D extends Durable> void writeToParcel(Parcel parcel, D d) { try { parcel.writeByteArray(writeToArray(d)); } catch (IOException e) { throw new BadParcelableException(e); } }
Example #13
Source File: DurableUtils.java From FireFiles with Apache License 2.0 | 5 votes |
public static <D extends Durable> D readFromParcel(Parcel parcel, D d) { try { return readFromArray(parcel.createByteArray(), d); } catch (IOException e) { throw new BadParcelableException(e); } }
Example #14
Source File: DurableUtils.java From FireFiles with Apache License 2.0 | 5 votes |
public static <D extends Durable> void writeToParcel(Parcel parcel, D d) { try { parcel.writeByteArray(writeToArray(d)); } catch (IOException e) { throw new BadParcelableException(e); } }
Example #15
Source File: IntentUtilTest.java From OpenYOLO-Android with Apache License 2.0 | 5 votes |
@Test public void fromBytes_withIntentNotPresent_throwsBadParcelableException() { final byte[] intentBytes = new byte[10]; assertThatThrownBy(new ThrowableAssert.ThrowingCallable() { @Override public void call() throws Throwable { IntentUtil.fromBytes(intentBytes); } }).isInstanceOf(BadParcelableException.class); }
Example #16
Source File: IntentUtilTest.java From OpenYOLO-Android with Apache License 2.0 | 5 votes |
@Test public void fromBytes_withNullIntent_throwsBadParcelableException() { final byte[] intentBytes = toBytesUnchecked(null); assertThatThrownBy(new ThrowableAssert.ThrowingCallable() { @Override public void call() throws Throwable { IntentUtil.fromBytes(intentBytes); } }).isInstanceOf(BadParcelableException.class); }
Example #17
Source File: Log.java From FairEmail with GNU General Public License v3.0 | 5 votes |
static List<String> getExtras(Bundle data) { List<String> result = new ArrayList<>(); if (data == null) return result; try { Set<String> keys = data.keySet(); for (String key : keys) { Object v = data.get(key); Object value = v; if (v != null && v.getClass().isArray()) { int length = Array.getLength(v); if (length <= 10) { String[] elements = new String[length]; for (int i = 0; i < length; i++) { Object element = Array.get(v, i); if (element instanceof Long) elements[i] = element.toString() + " (0x" + Long.toHexString((Long) element) + ")"; else elements[i] = (element == null ? null : element.toString()); } value = TextUtils.join(",", elements); } else value = "[" + length + "]"; } else if (v instanceof Long) value = v.toString() + " (0x" + Long.toHexString((Long) v) + ")"; result.add(key + "=" + value + (value == null ? "" : " (" + v.getClass().getSimpleName() + ")")); } } catch (BadParcelableException ex) { // android.os.BadParcelableException: ClassNotFoundException when unmarshalling: ... Log.e(ex); } return result; }
Example #18
Source File: AssistStructure.java From android_9.0.0_r45 with Apache License 2.0 | 5 votes |
Parcel readParcel(int validateToken, int level) { if (DEBUG_PARCEL) Log.d(TAG, "readParcel: at " + mCurParcel.dataPosition() + ", avail=" + mCurParcel.dataAvail() + ", windows=" + mNumReadWindows + ", views=" + mNumReadViews + ", level=" + level); int token = mCurParcel.readInt(); if (token != 0) { if (token != validateToken) { throw new BadParcelableException("Got token " + Integer.toHexString(token) + ", expected token " + Integer.toHexString(validateToken)); } return mCurParcel; } // We have run out of partial data, need to read another batch. mTransferToken = mCurParcel.readStrongBinder(); if (mTransferToken == null) { throw new IllegalStateException( "Reached end of partial data without transfer token"); } if (DEBUG_PARCEL) Log.d(TAG, "Ran out of partial data at " + mCurParcel.dataPosition() + ", token " + mTransferToken); fetchData(); if (DEBUG_PARCEL) Log.d(TAG, "Creating PooledStringReader @ " + mCurParcel.dataPosition()); mStringReader = new PooledStringReader(mCurParcel); if (DEBUG_PARCEL) Log.d(TAG, "PooledStringReader size = " + mStringReader.getStringCount()); if (DEBUG_PARCEL) Log.d(TAG, "readParcel: at " + mCurParcel.dataPosition() + ", avail=" + mCurParcel.dataAvail() + ", windows=" + mNumReadWindows + ", views=" + mNumReadViews); mCurParcel.readInt(); return mCurParcel; }