Java 类android.os.BadParcelableException 实例源码

项目:ProgressManager    文件:a.java   
/**
 * Return information about who launched this activity.  If the launching Intent
 * contains an {@link android.content.Intent#EXTRA_REFERRER Intent.EXTRA_REFERRER},
 * that will be returned as-is; otherwise, if known, an
 * {@link Intent#URI_ANDROID_APP_SCHEME android-app:} referrer URI containing the
 * package name that started the Intent will be returned.  This may return null if no
 * referrer can be identified -- it is neither explicitly specified, nor is it known which
 * application package was involved.
 *
 * <p>If called while inside the handling of {@link #onNewIntent}, this function will
 * return the referrer that submitted that new intent to the activity.  Otherwise, it
 * always returns the referrer of the original Intent.</p>
 *
 * <p>Note that this is <em>not</em> a security feature -- you can not trust the
 * referrer information, applications can spoof it.</p>
 */
@Nullable
public Uri getReferrer() {
    Intent intent = getIntent();
    try {
        Uri referrer = intent.getParcelableExtra(Intent.EXTRA_REFERRER);
        if (referrer != null) {
            return referrer;
        }
        String referrerName = intent.getStringExtra(Intent.EXTRA_REFERRER_NAME);
        if (referrerName != null) {
            return Uri.parse(referrerName);
        }
    } catch (BadParcelableException e) {
        Log.w(TAG, "Cannot read referrer from intent;"
                + " intent extras contain unknown custom Parcelable objects");
    }
    if (mReferrer != null) {
        return new Uri.Builder().scheme("android-app").authority(mReferrer).build();
    }
    return null;
}
项目:ProgressManager    文件:a.java   
/**
 * Return information about who launched this activity.  If the launching Intent
 * contains an {@link android.content.Intent#EXTRA_REFERRER Intent.EXTRA_REFERRER},
 * that will be returned as-is; otherwise, if known, an
 * {@link Intent#URI_ANDROID_APP_SCHEME android-app:} referrer URI containing the
 * package name that started the Intent will be returned.  This may return null if no
 * referrer can be identified -- it is neither explicitly specified, nor is it known which
 * application package was involved.
 *
 * <p>If called while inside the handling of {@link #onNewIntent}, this function will
 * return the referrer that submitted that new intent to the activity.  Otherwise, it
 * always returns the referrer of the original Intent.</p>
 *
 * <p>Note that this is <em>not</em> a security feature -- you can not trust the
 * referrer information, applications can spoof it.</p>
 */
@Nullable
public Uri getReferrer() {
    Intent intent = getIntent();
    try {
        Uri referrer = intent.getParcelableExtra(Intent.EXTRA_REFERRER);
        if (referrer != null) {
            return referrer;
        }
        String referrerName = intent.getStringExtra(Intent.EXTRA_REFERRER_NAME);
        if (referrerName != null) {
            return Uri.parse(referrerName);
        }
    } catch (BadParcelableException e) {
        Log.w(TAG, "Cannot read referrer from intent;"
                + " intent extras contain unknown custom Parcelable objects");
    }
    if (mReferrer != null) {
        return new Uri.Builder().scheme("android-app").authority(mReferrer).build();
    }
    return null;
}
项目:ProgressManager    文件:a.java   
/**
 * Return information about who launched this activity.  If the launching Intent
 * contains an {@link android.content.Intent#EXTRA_REFERRER Intent.EXTRA_REFERRER},
 * that will be returned as-is; otherwise, if known, an
 * {@link Intent#URI_ANDROID_APP_SCHEME android-app:} referrer URI containing the
 * package name that started the Intent will be returned.  This may return null if no
 * referrer can be identified -- it is neither explicitly specified, nor is it known which
 * application package was involved.
 *
 * <p>If called while inside the handling of {@link #onNewIntent}, this function will
 * return the referrer that submitted that new intent to the activity.  Otherwise, it
 * always returns the referrer of the original Intent.</p>
 *
 * <p>Note that this is <em>not</em> a security feature -- you can not trust the
 * referrer information, applications can spoof it.</p>
 */
@Nullable
public Uri getReferrer() {
    Intent intent = getIntent();
    try {
        Uri referrer = intent.getParcelableExtra(Intent.EXTRA_REFERRER);
        if (referrer != null) {
            return referrer;
        }
        String referrerName = intent.getStringExtra(Intent.EXTRA_REFERRER_NAME);
        if (referrerName != null) {
            return Uri.parse(referrerName);
        }
    } catch (BadParcelableException e) {
        Log.w(TAG, "Cannot read referrer from intent;"
                + " intent extras contain unknown custom Parcelable objects");
    }
    if (mReferrer != null) {
        return new Uri.Builder().scheme("android-app").authority(mReferrer).build();
    }
    return null;
}
项目:ProgressManager    文件:a.java   
/**
 * Return information about who launched this activity.  If the launching Intent
 * contains an {@link android.content.Intent#EXTRA_REFERRER Intent.EXTRA_REFERRER},
 * that will be returned as-is; otherwise, if known, an
 * {@link Intent#URI_ANDROID_APP_SCHEME android-app:} referrer URI containing the
 * package name that started the Intent will be returned.  This may return null if no
 * referrer can be identified -- it is neither explicitly specified, nor is it known which
 * application package was involved.
 *
 * <p>If called while inside the handling of {@link #onNewIntent}, this function will
 * return the referrer that submitted that new intent to the activity.  Otherwise, it
 * always returns the referrer of the original Intent.</p>
 *
 * <p>Note that this is <em>not</em> a security feature -- you can not trust the
 * referrer information, applications can spoof it.</p>
 */
@Nullable
public Uri getReferrer() {
    Intent intent = getIntent();
    try {
        Uri referrer = intent.getParcelableExtra(Intent.EXTRA_REFERRER);
        if (referrer != null) {
            return referrer;
        }
        String referrerName = intent.getStringExtra(Intent.EXTRA_REFERRER_NAME);
        if (referrerName != null) {
            return Uri.parse(referrerName);
        }
    } catch (BadParcelableException e) {
        Log.w(TAG, "Cannot read referrer from intent;"
                + " intent extras contain unknown custom Parcelable objects");
    }
    if (mReferrer != null) {
        return new Uri.Builder().scheme("android-app").authority(mReferrer).build();
    }
    return null;
}
项目:ProgressManager    文件:a.java   
/**
 * Return information about who launched this activity.  If the launching Intent
 * contains an {@link android.content.Intent#EXTRA_REFERRER Intent.EXTRA_REFERRER},
 * that will be returned as-is; otherwise, if known, an
 * {@link Intent#URI_ANDROID_APP_SCHEME android-app:} referrer URI containing the
 * package name that started the Intent will be returned.  This may return null if no
 * referrer can be identified -- it is neither explicitly specified, nor is it known which
 * application package was involved.
 *
 * <p>If called while inside the handling of {@link #onNewIntent}, this function will
 * return the referrer that submitted that new intent to the activity.  Otherwise, it
 * always returns the referrer of the original Intent.</p>
 *
 * <p>Note that this is <em>not</em> a security feature -- you can not trust the
 * referrer information, applications can spoof it.</p>
 */
@Nullable
public Uri getReferrer() {
    Intent intent = getIntent();
    try {
        Uri referrer = intent.getParcelableExtra(Intent.EXTRA_REFERRER);
        if (referrer != null) {
            return referrer;
        }
        String referrerName = intent.getStringExtra(Intent.EXTRA_REFERRER_NAME);
        if (referrerName != null) {
            return Uri.parse(referrerName);
        }
    } catch (BadParcelableException e) {
        Log.w(TAG, "Cannot read referrer from intent;"
                + " intent extras contain unknown custom Parcelable objects");
    }
    if (mReferrer != null) {
        return new Uri.Builder().scheme("android-app").authority(mReferrer).build();
    }
    return null;
}
项目:ProgressManager    文件:a.java   
/**
 * Return information about who launched this activity.  If the launching Intent
 * contains an {@link android.content.Intent#EXTRA_REFERRER Intent.EXTRA_REFERRER},
 * that will be returned as-is; otherwise, if known, an
 * {@link Intent#URI_ANDROID_APP_SCHEME android-app:} referrer URI containing the
 * package name that started the Intent will be returned.  This may return null if no
 * referrer can be identified -- it is neither explicitly specified, nor is it known which
 * application package was involved.
 *
 * <p>If called while inside the handling of {@link #onNewIntent}, this function will
 * return the referrer that submitted that new intent to the activity.  Otherwise, it
 * always returns the referrer of the original Intent.</p>
 *
 * <p>Note that this is <em>not</em> a security feature -- you can not trust the
 * referrer information, applications can spoof it.</p>
 */
@Nullable
public Uri getReferrer() {
    Intent intent = getIntent();
    try {
        Uri referrer = intent.getParcelableExtra(Intent.EXTRA_REFERRER);
        if (referrer != null) {
            return referrer;
        }
        String referrerName = intent.getStringExtra(Intent.EXTRA_REFERRER_NAME);
        if (referrerName != null) {
            return Uri.parse(referrerName);
        }
    } catch (BadParcelableException e) {
        Log.w(TAG, "Cannot read referrer from intent;"
                + " intent extras contain unknown custom Parcelable objects");
    }
    if (mReferrer != null) {
        return new Uri.Builder().scheme("android-app").authority(mReferrer).build();
    }
    return null;
}
项目:ProgressManager    文件:a.java   
/**
 * Return information about who launched this activity.  If the launching Intent
 * contains an {@link android.content.Intent#EXTRA_REFERRER Intent.EXTRA_REFERRER},
 * that will be returned as-is; otherwise, if known, an
 * {@link Intent#URI_ANDROID_APP_SCHEME android-app:} referrer URI containing the
 * package name that started the Intent will be returned.  This may return null if no
 * referrer can be identified -- it is neither explicitly specified, nor is it known which
 * application package was involved.
 *
 * <p>If called while inside the handling of {@link #onNewIntent}, this function will
 * return the referrer that submitted that new intent to the activity.  Otherwise, it
 * always returns the referrer of the original Intent.</p>
 *
 * <p>Note that this is <em>not</em> a security feature -- you can not trust the
 * referrer information, applications can spoof it.</p>
 */
@Nullable
public Uri getReferrer() {
    Intent intent = getIntent();
    try {
        Uri referrer = intent.getParcelableExtra(Intent.EXTRA_REFERRER);
        if (referrer != null) {
            return referrer;
        }
        String referrerName = intent.getStringExtra(Intent.EXTRA_REFERRER_NAME);
        if (referrerName != null) {
            return Uri.parse(referrerName);
        }
    } catch (BadParcelableException e) {
        Log.w(TAG, "Cannot read referrer from intent;"
                + " intent extras contain unknown custom Parcelable objects");
    }
    if (mReferrer != null) {
        return new Uri.Builder().scheme("android-app").authority(mReferrer).build();
    }
    return null;
}
项目:ProgressManager    文件:a.java   
/**
 * Return information about who launched this activity.  If the launching Intent
 * contains an {@link android.content.Intent#EXTRA_REFERRER Intent.EXTRA_REFERRER},
 * that will be returned as-is; otherwise, if known, an
 * {@link Intent#URI_ANDROID_APP_SCHEME android-app:} referrer URI containing the
 * package name that started the Intent will be returned.  This may return null if no
 * referrer can be identified -- it is neither explicitly specified, nor is it known which
 * application package was involved.
 *
 * <p>If called while inside the handling of {@link #onNewIntent}, this function will
 * return the referrer that submitted that new intent to the activity.  Otherwise, it
 * always returns the referrer of the original Intent.</p>
 *
 * <p>Note that this is <em>not</em> a security feature -- you can not trust the
 * referrer information, applications can spoof it.</p>
 */
@Nullable
public Uri getReferrer() {
    Intent intent = getIntent();
    try {
        Uri referrer = intent.getParcelableExtra(Intent.EXTRA_REFERRER);
        if (referrer != null) {
            return referrer;
        }
        String referrerName = intent.getStringExtra(Intent.EXTRA_REFERRER_NAME);
        if (referrerName != null) {
            return Uri.parse(referrerName);
        }
    } catch (BadParcelableException e) {
        Log.w(TAG, "Cannot read referrer from intent;"
                + " intent extras contain unknown custom Parcelable objects");
    }
    if (mReferrer != null) {
        return new Uri.Builder().scheme("android-app").authority(mReferrer).build();
    }
    return null;
}
项目:ProgressManager    文件:a.java   
/**
 * Return information about who launched this activity.  If the launching Intent
 * contains an {@link android.content.Intent#EXTRA_REFERRER Intent.EXTRA_REFERRER},
 * that will be returned as-is; otherwise, if known, an
 * {@link Intent#URI_ANDROID_APP_SCHEME android-app:} referrer URI containing the
 * package name that started the Intent will be returned.  This may return null if no
 * referrer can be identified -- it is neither explicitly specified, nor is it known which
 * application package was involved.
 *
 * <p>If called while inside the handling of {@link #onNewIntent}, this function will
 * return the referrer that submitted that new intent to the activity.  Otherwise, it
 * always returns the referrer of the original Intent.</p>
 *
 * <p>Note that this is <em>not</em> a security feature -- you can not trust the
 * referrer information, applications can spoof it.</p>
 */
@Nullable
public Uri getReferrer() {
    Intent intent = getIntent();
    try {
        Uri referrer = intent.getParcelableExtra(Intent.EXTRA_REFERRER);
        if (referrer != null) {
            return referrer;
        }
        String referrerName = intent.getStringExtra(Intent.EXTRA_REFERRER_NAME);
        if (referrerName != null) {
            return Uri.parse(referrerName);
        }
    } catch (BadParcelableException e) {
        Log.w(TAG, "Cannot read referrer from intent;"
                + " intent extras contain unknown custom Parcelable objects");
    }
    if (mReferrer != null) {
        return new Uri.Builder().scheme("android-app").authority(mReferrer).build();
    }
    return null;
}
项目:ProgressManager    文件:a.java   
/**
 * Return information about who launched this activity.  If the launching Intent
 * contains an {@link android.content.Intent#EXTRA_REFERRER Intent.EXTRA_REFERRER},
 * that will be returned as-is; otherwise, if known, an
 * {@link Intent#URI_ANDROID_APP_SCHEME android-app:} referrer URI containing the
 * package name that started the Intent will be returned.  This may return null if no
 * referrer can be identified -- it is neither explicitly specified, nor is it known which
 * application package was involved.
 *
 * <p>If called while inside the handling of {@link #onNewIntent}, this function will
 * return the referrer that submitted that new intent to the activity.  Otherwise, it
 * always returns the referrer of the original Intent.</p>
 *
 * <p>Note that this is <em>not</em> a security feature -- you can not trust the
 * referrer information, applications can spoof it.</p>
 */
@Nullable
public Uri getReferrer() {
    Intent intent = getIntent();
    try {
        Uri referrer = intent.getParcelableExtra(Intent.EXTRA_REFERRER);
        if (referrer != null) {
            return referrer;
        }
        String referrerName = intent.getStringExtra(Intent.EXTRA_REFERRER_NAME);
        if (referrerName != null) {
            return Uri.parse(referrerName);
        }
    } catch (BadParcelableException e) {
        Log.w(TAG, "Cannot read referrer from intent;"
                + " intent extras contain unknown custom Parcelable objects");
    }
    if (mReferrer != null) {
        return new Uri.Builder().scheme("android-app").authority(mReferrer).build();
    }
    return null;
}
项目:nifi-android-s2s    文件:SerializationUtils.java   
/**
 * Unmarshalls a parcelable's byte array into the object
 *
 * @param bytes the byte array
 * @param clazz the class
 * @param <T>   the type
 * @return the object
 */
@SuppressWarnings("unchecked")
public static <T extends Parcelable> T unmarshallParcelable(byte[] bytes, Class<T> clazz) {
    if (bytes == null) {
        return null;
    }
    Parcel parcel = Parcel.obtain();
    parcel.unmarshall(bytes, 0, bytes.length);
    parcel.setDataPosition(0);

    try {
        Parcelable.Creator<? extends Parcelable> creator = (Parcelable.Creator<? extends Parcelable>) clazz.getField("CREATOR").get(null);
        return (T) creator.createFromParcel(parcel);
    } catch (Exception e) {
        throw new BadParcelableException(e);
    } finally {
        parcel.recycle();
    }
}
项目:nifi-android-s2s    文件:SerializationUtils.java   
/**
 * Unmarshalls a serializable's byte array into the object
 *
 * @param bytes the bytes
 * @param <T>   the type
 * @return the object
 */
@SuppressWarnings("unchecked")
public static <T extends Serializable> T unmarshallSerializable(byte[] bytes) {
    if (bytes == null) {
        return null;
    }
    Parcel parcel = Parcel.obtain();
    parcel.unmarshall(bytes, 0, bytes.length);
    parcel.setDataPosition(0);

    try {
        return (T) parcel.readSerializable();
    } catch (Exception e) {
        throw new BadParcelableException(e);
    } finally {
        parcel.recycle();
    }
}
项目:nifi-android-s2s    文件:SerializationUtils.java   
/**
 * Gets a parcelable from an intent
 *
 * @param intent the intent
 * @param name   the name
 * @param <T>    the type
 * @return the parcelable
 */
@SuppressWarnings("unchecked")
public static <T extends Parcelable> T getParcelable(Intent intent, String name) {
    byte[] bytes = intent.getByteArrayExtra(name);
    if (bytes == null) {
        return null;
    }
    try {
        ClassLoader intentClassLoader = intent.getExtras().getClassLoader();
        String classname = intent.getStringExtra(name + "_CLASSNAME");
        Class<T> parcelable;
        if (intentClassLoader == null) {
            parcelable = (Class<T>) Class.forName(classname);
        } else {
            parcelable = (Class<T>) Class.forName(classname, true, intentClassLoader);
        }
        return unmarshallParcelable(bytes, parcelable);
    } catch (Exception e) {
        throw new BadParcelableException(e);
    }
}
项目:OpenYOLO-Android    文件:IntentUtilTest.java   
@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);
}
项目:IntentsLab    文件:BundleAdapter.java   
private void updateKeySet() {
       // Try to unpack bundle without sandbox
       if (!mUseSandbox) {
           try {
               if (mBundle.keySet() != null) {
                   mKeys = mBundle.keySet().toArray(mKeys);
                   mKeysCount = mBundle.size();
               } else {
                   mKeys = new String[0];
                   mKeysCount = 0;
               }
               return;
           } catch (BadParcelableException ignored) {}
       }

       // If it failed or was disabled
       sandboxBundle(true, null);
}
项目:ProgressManager    文件:a.java   
/**
 * Return information about who launched this activity.  If the launching Intent
 * contains an {@link android.content.Intent#EXTRA_REFERRER Intent.EXTRA_REFERRER},
 * that will be returned as-is; otherwise, if known, an
 * {@link Intent#URI_ANDROID_APP_SCHEME android-app:} referrer URI containing the
 * package name that started the Intent will be returned.  This may return null if no
 * referrer can be identified -- it is neither explicitly specified, nor is it known which
 * application package was involved.
 *
 * <p>If called while inside the handling of {@link #onNewIntent}, this function will
 * return the referrer that submitted that new intent to the activity.  Otherwise, it
 * always returns the referrer of the original Intent.</p>
 *
 * <p>Note that this is <em>not</em> a security feature -- you can not trust the
 * referrer information, applications can spoof it.</p>
 */
@Nullable
public Uri getReferrer() {
    Intent intent = getIntent();
    try {
        Uri referrer = intent.getParcelableExtra(Intent.EXTRA_REFERRER);
        if (referrer != null) {
            return referrer;
        }
        String referrerName = intent.getStringExtra(Intent.EXTRA_REFERRER_NAME);
        if (referrerName != null) {
            return Uri.parse(referrerName);
        }
    } catch (BadParcelableException e) {
        Log.w(TAG, "Cannot read referrer from intent;"
                + " intent extras contain unknown custom Parcelable objects");
    }
    if (mReferrer != null) {
        return new Uri.Builder().scheme("android-app").authority(mReferrer).build();
    }
    return null;
}
项目:ProgressManager    文件:a.java   
/**
 * Return information about who launched this activity.  If the launching Intent
 * contains an {@link android.content.Intent#EXTRA_REFERRER Intent.EXTRA_REFERRER},
 * that will be returned as-is; otherwise, if known, an
 * {@link Intent#URI_ANDROID_APP_SCHEME android-app:} referrer URI containing the
 * package name that started the Intent will be returned.  This may return null if no
 * referrer can be identified -- it is neither explicitly specified, nor is it known which
 * application package was involved.
 *
 * <p>If called while inside the handling of {@link #onNewIntent}, this function will
 * return the referrer that submitted that new intent to the activity.  Otherwise, it
 * always returns the referrer of the original Intent.</p>
 *
 * <p>Note that this is <em>not</em> a security feature -- you can not trust the
 * referrer information, applications can spoof it.</p>
 */
@Nullable
public Uri getReferrer() {
    Intent intent = getIntent();
    try {
        Uri referrer = intent.getParcelableExtra(Intent.EXTRA_REFERRER);
        if (referrer != null) {
            return referrer;
        }
        String referrerName = intent.getStringExtra(Intent.EXTRA_REFERRER_NAME);
        if (referrerName != null) {
            return Uri.parse(referrerName);
        }
    } catch (BadParcelableException e) {
        Log.w(TAG, "Cannot read referrer from intent;"
                + " intent extras contain unknown custom Parcelable objects");
    }
    if (mReferrer != null) {
        return new Uri.Builder().scheme("android-app").authority(mReferrer).build();
    }
    return null;
}
项目:Android-Scrapper    文件:ScrapperService.java   
@SuppressWarnings("unused")
@Subscribe
public void onChildAdded(GameAddedEvent event) {
    synchronized (listeners) {
        for (ServiceListener listener : listeners) {
            try {
                listener.gameAdded(event.getGameData());
            } catch (RemoteException | BadParcelableException ignore) {
            }
        }
    }
}
项目:FireFiles    文件:DurableUtils.java   
public static <D extends Durable> void writeToParcel(Parcel parcel, D d) {
    try {
        parcel.writeByteArray(writeToArray(d));
    } catch (IOException e) {
        throw new BadParcelableException(e);
    }
}
项目:FireFiles    文件:DurableUtils.java   
public static <D extends Durable> D readFromParcel(Parcel parcel, D d) {
    try {
        return readFromArray(parcel.createByteArray(), d);
    } catch (IOException e) {
        throw new BadParcelableException(e);
    }
}
项目:simple-share-android    文件:DurableUtils.java   
public static <D extends Durable> void writeToParcel(Parcel parcel, D d) {
    try {
        parcel.writeByteArray(writeToArray(d));
    } catch (IOException e) {
        throw new BadParcelableException(e);
    }
}
项目:simple-share-android    文件:DurableUtils.java   
public static <D extends Durable> D readFromParcel(Parcel parcel, D d) {
    try {
        return readFromArray(parcel.createByteArray(), d);
    } catch (IOException e) {
        throw new BadParcelableException(e);
    }
}
项目:AndroidChromium    文件:IntentUtils.java   
/**
 * 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);
    }
}
项目:nevo-direct-reply    文件:NevoDecoratorService.java   
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);
}
项目:365browser    文件:IntentUtils.java   
/**
 * 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);
    }
}
项目:nevolution    文件:NevoDecoratorService.java   
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);
}
项目:IntentsLab    文件:SandboxedObject.java   
/**
 * Constructor for loading from parcel
 */
SandboxedObject(Parcel source) {
    try {
        mType = Type.values()[source.readInt()];
        mHelper = mType.mHelperClass.getDeclaredConstructor(Parcel.class).newInstance(source);
    } catch (Exception e) {
        throw new BadParcelableException(e);
    }
}
项目:IntentsLab    文件:SandboxedObject.java   
@Override
public Object unwrap(ClassLoader classLoader) {
    try {
        return Utils.deepCastArray(
                (Object[]) super.unwrap(classLoader),
                Class.forName(mArrayClassName, true, classLoader)
        );
    } catch (ClassNotFoundException e) {
        throw new BadParcelableException(e);
    }
}
项目:IntentsLab    文件:SandboxedObjectEditorHelper.java   
Accessors(String fieldName) throws RemoteException {
    mFieldName = fieldName;

    // Get value
    final SandboxedObject wrappedValue = mSandboxedObject.getFieldValue(mFieldName);
    try {
        // Try to unwrap, if successful use that value
        mCachedValue = wrappedValue.unwrap(null);
    } catch (BadParcelableException e) {
        // Unwrap failed, use sandbox
        mValueIsSandboxed = true;
        mCachedStringValue = mSandboxedObject.getFieldValueAsString(mFieldName);
        mCachedValue = wrappedValue;
    }
}
项目:commcare-android    文件:IntentCallout.java   
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;
}
项目:androidwisprclient    文件:NetworkConnectivityReceiver.java   
private boolean isConnectedIntent(Intent intent) {
    NetworkInfo networkInfo = null;
    try {
        networkInfo = (NetworkInfo) intent.getParcelableExtra(ConnectivityManager.EXTRA_NETWORK_INFO);
    } catch (BadParcelableException ignored) {}

    return (networkInfo != null && networkInfo.isConnected() && networkInfo.getType() == ConnectivityManager.TYPE_WIFI);
}
项目:MapsMeasure    文件:Map.java   
@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();
}
项目:IntentLogger    文件:IntentLogger.java   
public static boolean hasExtras(Bundle extras) {
    try {
        return (extras != null && !extras.isEmpty());
    } catch (BadParcelableException e) {
        Log.w("IntentLogger", "Extra contains unknown class instance: ", e);
        return true;
    }
}
项目:easyfilemanager    文件:DurableUtils.java   
public static <D extends Durable> D readFromParcel(Parcel parcel, D d) {
    try {
        return readFromArray(parcel.createByteArray(), d);
    } catch (IOException e) {
        throw new BadParcelableException(e);
    }
}
项目:OpenYOLO-Android    文件:IntentUtilTest.java   
@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);
}
项目:FMTech    文件:csb.java   
private final Intent c(Intent paramIntent)
{
  try
  {
    gya localgya = this.c.r_();
    if (localgya != null)
    {
      paramIntent.putExtra("com.google.plus.analytics.intent.extra.START_VIEW", localgya.ordinal());
      paramIntent.putExtra("com.google.plus.analytics.intent.extra.START_TIME", System.currentTimeMillis());
      Bundle localBundle = new Bundle();
      this.c.b(localBundle);
      if (!localBundle.isEmpty()) {
        paramIntent.putExtras(localBundle);
      }
    }
    return paramIntent;
  }
  catch (BadParcelableException localBadParcelableException) {}
  return paramIntent;
}
项目:ProgressManager    文件:a.java   
/**
 * Return information about who launched this activity.  If the launching Intent
 * contains an {@link android.content.Intent#EXTRA_REFERRER Intent.EXTRA_REFERRER},
 * that will be returned as-is; otherwise, if known, an
 * {@link Intent#URI_ANDROID_APP_SCHEME android-app:} referrer URI containing the
 * package name that started the Intent will be returned.  This may return null if no
 * referrer can be identified -- it is neither explicitly specified, nor is it known which
 * application package was involved.
 *
 * <p>If called while inside the handling of {@link #onNewIntent}, this function will
 * return the referrer that submitted that new intent to the activity.  Otherwise, it
 * always returns the referrer of the original Intent.</p>
 *
 * <p>Note that this is <em>not</em> a security feature -- you can not trust the
 * referrer information, applications can spoof it.</p>
 */
@Nullable
public Uri getReferrer() {
    Intent intent = getIntent();
    try {
        Uri referrer = intent.getParcelableExtra(Intent.EXTRA_REFERRER);
        if (referrer != null) {
            return referrer;
        }
        String referrerName = intent.getStringExtra(Intent.EXTRA_REFERRER_NAME);
        if (referrerName != null) {
            return Uri.parse(referrerName);
        }
    } catch (BadParcelableException e) {
        Log.w(TAG, "Cannot read referrer from intent;"
                + " intent extras contain unknown custom Parcelable objects");
    }
    if (mReferrer != null) {
        return new Uri.Builder().scheme("android-app").authority(mReferrer).build();
    }
    return null;
}
项目:nifi-android-s2s    文件:SerializationUtils.java   
@SuppressWarnings("unchecked")
@RequiresApi(api = Build.VERSION_CODES.LOLLIPOP)
public static <T extends Parcelable> T getParcelable(ClassLoader classLoader, PersistableBundle persistableBundle, String name) {
    PersistableBundle bundle = persistableBundle.getPersistableBundle(name);
    if (bundle == null) {
        return null;
    }
    try {
        return unmarshallParcelable(Base64.decode(bundle.getString("data"), 0), (Class<T>) Class.forName(bundle.getString("class"), true, classLoader));
    } catch (ClassNotFoundException e) {
        throw new BadParcelableException(e);
    }
}
项目:OpenYOLO-Android    文件:IntentUtil.java   
/**
 * 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;
}
项目:goloader    文件:HistoryStore.java   
@SuppressWarnings("unchecked")
private HistoryStore(Parcel in) {
    mMaxSize = in.readInt();

    int count = in.readInt();
    for (int i = 0; i < count; i++)
        try {
            mHistoryList.add((A) in.readParcelable(null)); // this (maybe sometimes) crashes with a BadParcelableException
        } catch (BadParcelableException e1) { 
            Log.e("afc_HistoryStore", "BadParcelableException: " + e1.getMessage());
            BugSenseHandler.sendExceptionMessage("afc_HistoryStore", "readParcelable_1: " + e1.getMessage(), e1);
            try {
                mHistoryList.add((A) in.readParcelable(HistoryStore.class.getClassLoader()));
            } catch (BadParcelableException e2) {
                Log.e("afc_HistoryStore", "BadParcelableException: " + e2.getMessage());
                BugSenseHandler.sendExceptionMessage("afc_HistoryStore", "readParcelable_2: " + e2.getMessage(), e2);
                try {
                    mHistoryList.add((A) in.readParcelable(getClass().getClassLoader()));
                } catch (BadParcelableException e3) {
                    Log.e("afc_HistoryStore", "BadParcelableException: " + e3.getMessage());
                    BugSenseHandler.sendExceptionMessage("afc_HistoryStore", "readParcelable_3: " + e3.getMessage(), e3);
                }
            }
        }
}