Search in sources :

Example 6 with BadParcelableException

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

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 7 with BadParcelableException

use of android.os.BadParcelableException in project mixpanel-android by mixpanel.

the class MixpanelActivityLifecycleCallbacks method trackCampaignOpenedIfNeeded.

private void trackCampaignOpenedIfNeeded(Intent intent) {
    if (intent == null) {
        return;
    }
    try {
        if (intent.hasExtra("mp_campaign_id") && intent.hasExtra("mp_message_id")) {
            String campaignId = intent.getStringExtra("mp_campaign_id");
            String messageId = intent.getStringExtra("mp_message_id");
            String extraLogData = intent.getStringExtra("mp");
            try {
                JSONObject pushProps;
                if (extraLogData != null) {
                    pushProps = new JSONObject(extraLogData);
                } else {
                    pushProps = new JSONObject();
                }
                pushProps.put("campaign_id", Integer.valueOf(campaignId).intValue());
                pushProps.put("message_id", Integer.valueOf(messageId).intValue());
                pushProps.put("message_type", "push");
                mMpInstance.track("$app_open", pushProps);
            } catch (JSONException e) {
            }
            intent.removeExtra("mp_campaign_id");
            intent.removeExtra("mp_message_id");
            intent.removeExtra("mp");
        }
    } catch (BadParcelableException e) {
    // https://github.com/mixpanel/mixpanel-android/issues/251
    }
}
Also used : JSONObject(org.json.JSONObject) JSONException(org.json.JSONException) BadParcelableException(android.os.BadParcelableException)

Example 8 with BadParcelableException

use of android.os.BadParcelableException in project platform_frameworks_base by android.

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 9 with BadParcelableException

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

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.icon = this.icon;
    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.largeIcon != null) {
        that.largeIcon = Bitmap.createBitmap(this.largeIcon);
    }
    that.iconLevel = this.iconLevel;
    // android.net.Uri is immutable
    that.sound = this.sound;
    that.audioStreamType = this.audioStreamType;
    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;
    final String[] thiskind = this.kind;
    if (thiskind != null) {
        final int N = thiskind.length;
        final String[] thatkind = that.kind = new String[N];
        System.arraycopy(thiskind, 0, thatkind, 0, N);
    }
    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 (this.actions != null) {
        that.actions = new Action[this.actions.length];
        for (int i = 0; i < this.actions.length; i++) {
            that.actions[i] = this.actions[i].clone();
        }
    }
    if (heavy && this.bigContentView != null) {
        that.bigContentView = this.bigContentView.clone();
    }
    if (!heavy) {
        // will clean out extras
        that.lightenPayload();
    }
}
Also used : Bundle(android.os.Bundle) BadParcelableException(android.os.BadParcelableException)

Example 10 with BadParcelableException

use of android.os.BadParcelableException in project platform_frameworks_base by android.

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