Search in sources :

Example 1 with BadParcelableException

use of android.os.BadParcelableException in project android_frameworks_base by DirtyUnicorns.

the class Activity method getReferrer.

/**
     * 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;
}
Also used : Intent(android.content.Intent) Uri(android.net.Uri) BadParcelableException(android.os.BadParcelableException) Nullable(android.annotation.Nullable)

Example 2 with BadParcelableException

use of android.os.BadParcelableException in project android_frameworks_base by crdroidandroid.

the class Notification method cloneInto.

/**
     * Copy all (or if heavy is false, all except Bitmaps and RemoteViews) members
     * of this into that.
     * @hide
     */
public void cloneInto(Notification that, boolean heavy) {
    that.when = this.when;
    that.creationTime = this.creationTime;
    that.mSmallIcon = this.mSmallIcon;
    that.number = this.number;
    // PendingIntents are global, so there's no reason (or way) to clone them.
    that.contentIntent = this.contentIntent;
    that.deleteIntent = this.deleteIntent;
    that.fullScreenIntent = this.fullScreenIntent;
    if (this.tickerText != null) {
        that.tickerText = this.tickerText.toString();
    }
    if (heavy && this.tickerView != null) {
        that.tickerView = this.tickerView.clone();
    }
    if (heavy && this.contentView != null) {
        that.contentView = this.contentView.clone();
    }
    if (heavy && this.mLargeIcon != null) {
        that.mLargeIcon = this.mLargeIcon;
    }
    that.iconLevel = this.iconLevel;
    // android.net.Uri is immutable
    that.sound = this.sound;
    that.audioStreamType = this.audioStreamType;
    if (this.audioAttributes != null) {
        that.audioAttributes = new AudioAttributes.Builder(this.audioAttributes).build();
    }
    final long[] vibrate = this.vibrate;
    if (vibrate != null) {
        final int N = vibrate.length;
        final long[] vib = that.vibrate = new long[N];
        System.arraycopy(vibrate, 0, vib, 0, N);
    }
    that.ledARGB = this.ledARGB;
    that.ledOnMS = this.ledOnMS;
    that.ledOffMS = this.ledOffMS;
    that.defaults = this.defaults;
    that.flags = this.flags;
    that.priority = this.priority;
    that.category = this.category;
    that.mGroupKey = this.mGroupKey;
    that.mSortKey = this.mSortKey;
    if (this.extras != null) {
        try {
            that.extras = new Bundle(this.extras);
            // will unparcel
            that.extras.size();
        } catch (BadParcelableException e) {
            Log.e(TAG, "could not unparcel extras from notification: " + this, e);
            that.extras = null;
        }
    }
    if (!ArrayUtils.isEmpty(allPendingIntents)) {
        that.allPendingIntents = new ArraySet<>(allPendingIntents);
    }
    if (this.actions != null) {
        that.actions = new Action[this.actions.length];
        for (int i = 0; i < this.actions.length; i++) {
            if (this.actions[i] != null) {
                that.actions[i] = this.actions[i].clone();
            }
        }
    }
    if (heavy && this.bigContentView != null) {
        that.bigContentView = this.bigContentView.clone();
    }
    if (heavy && this.headsUpContentView != null) {
        that.headsUpContentView = this.headsUpContentView.clone();
    }
    that.visibility = this.visibility;
    if (this.publicVersion != null) {
        that.publicVersion = new Notification();
        this.publicVersion.cloneInto(that.publicVersion, heavy);
    }
    that.color = this.color;
    if (!heavy) {
        // will clean out extras
        that.lightenPayload();
    }
}
Also used : Bundle(android.os.Bundle) SpannableStringBuilder(android.text.SpannableStringBuilder) BadParcelableException(android.os.BadParcelableException)

Example 3 with BadParcelableException

use of android.os.BadParcelableException in project android_frameworks_base by crdroidandroid.

the class Activity method getReferrer.

/**
     * 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;
}
Also used : Intent(android.content.Intent) Uri(android.net.Uri) BadParcelableException(android.os.BadParcelableException) Nullable(android.annotation.Nullable)

Example 4 with BadParcelableException

use of android.os.BadParcelableException in project android_frameworks_base by AOSPA.

the class Activity method getReferrer.

/**
     * 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;
}
Also used : Intent(android.content.Intent) Uri(android.net.Uri) BadParcelableException(android.os.BadParcelableException) Nullable(android.annotation.Nullable)

Example 5 with BadParcelableException

use of android.os.BadParcelableException in project android_frameworks_base by DirtyUnicorns.

the class Notification method cloneInto.

/**
     * Copy all (or if heavy is false, all except Bitmaps and RemoteViews) members
     * of this into that.
     * @hide
     */
public void cloneInto(Notification that, boolean heavy) {
    that.when = this.when;
    that.creationTime = this.creationTime;
    that.mSmallIcon = this.mSmallIcon;
    that.number = this.number;
    // PendingIntents are global, so there's no reason (or way) to clone them.
    that.contentIntent = this.contentIntent;
    that.deleteIntent = this.deleteIntent;
    that.fullScreenIntent = this.fullScreenIntent;
    if (this.tickerText != null) {
        that.tickerText = this.tickerText.toString();
    }
    if (heavy && this.tickerView != null) {
        that.tickerView = this.tickerView.clone();
    }
    if (heavy && this.contentView != null) {
        that.contentView = this.contentView.clone();
    }
    if (heavy && this.mLargeIcon != null) {
        that.mLargeIcon = this.mLargeIcon;
    }
    that.iconLevel = this.iconLevel;
    // android.net.Uri is immutable
    that.sound = this.sound;
    that.audioStreamType = this.audioStreamType;
    if (this.audioAttributes != null) {
        that.audioAttributes = new AudioAttributes.Builder(this.audioAttributes).build();
    }
    final long[] vibrate = this.vibrate;
    if (vibrate != null) {
        final int N = vibrate.length;
        final long[] vib = that.vibrate = new long[N];
        System.arraycopy(vibrate, 0, vib, 0, N);
    }
    that.ledARGB = this.ledARGB;
    that.ledOnMS = this.ledOnMS;
    that.ledOffMS = this.ledOffMS;
    that.defaults = this.defaults;
    that.flags = this.flags;
    that.priority = this.priority;
    that.category = this.category;
    that.mGroupKey = this.mGroupKey;
    that.mSortKey = this.mSortKey;
    if (this.extras != null) {
        try {
            that.extras = new Bundle(this.extras);
            // will unparcel
            that.extras.size();
        } catch (BadParcelableException e) {
            Log.e(TAG, "could not unparcel extras from notification: " + this, e);
            that.extras = null;
        }
    }
    if (!ArrayUtils.isEmpty(allPendingIntents)) {
        that.allPendingIntents = new ArraySet<>(allPendingIntents);
    }
    if (this.actions != null) {
        that.actions = new Action[this.actions.length];
        for (int i = 0; i < this.actions.length; i++) {
            if (this.actions[i] != null) {
                that.actions[i] = this.actions[i].clone();
            }
        }
    }
    if (heavy && this.bigContentView != null) {
        that.bigContentView = this.bigContentView.clone();
    }
    if (heavy && this.headsUpContentView != null) {
        that.headsUpContentView = this.headsUpContentView.clone();
    }
    that.visibility = this.visibility;
    if (this.publicVersion != null) {
        that.publicVersion = new Notification();
        this.publicVersion.cloneInto(that.publicVersion, heavy);
    }
    that.color = this.color;
    if (!heavy) {
        // will clean out extras
        that.lightenPayload();
    }
}
Also used : Bundle(android.os.Bundle) SpannableStringBuilder(android.text.SpannableStringBuilder) BadParcelableException(android.os.BadParcelableException)

Aggregations

BadParcelableException (android.os.BadParcelableException)13 Bundle (android.os.Bundle)6 Nullable (android.annotation.Nullable)5 Intent (android.content.Intent)5 Uri (android.net.Uri)5 SpannableStringBuilder (android.text.SpannableStringBuilder)5 Parcelable (android.os.Parcelable)1 Field (java.lang.reflect.Field)1 JSONException (org.json.JSONException)1 JSONObject (org.json.JSONObject)1 HiddenApi (org.robolectric.annotation.HiddenApi)1 Implementation (org.robolectric.annotation.Implementation)1