1 /* 2 * Copyright (C) 2014 The Android Open Source Project 3 * 4 * Licensed under the Apache License, Version 2.0 (the "License"); 5 * you may not use this file except in compliance with the License. 6 * You may obtain a copy of the License at 7 * 8 * http://www.apache.org/licenses/LICENSE-2.0 9 * 10 * Unless required by applicable law or agreed to in writing, software 11 * distributed under the License is distributed on an "AS IS" BASIS, 12 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 * See the License for the specific language governing permissions and 14 * limitations under the License. 15 */ 16 17 package com.android.internal.content; 18 19 import android.content.Intent; 20 import android.os.Parcel; 21 22 import java.util.Objects; 23 24 /** 25 * Subclass of Intent that also contains referrer (as a package name) information. 26 */ 27 public class ReferrerIntent extends Intent { 28 public final String mReferrer; 29 30 public ReferrerIntent(Intent baseIntent, String referrer) { 31 super(baseIntent); 32 mReferrer = referrer; 33 } 34 35 public void writeToParcel(Parcel dest, int parcelableFlags) { 36 super.writeToParcel(dest, parcelableFlags); 37 dest.writeString(mReferrer); 38 } 39 40 ReferrerIntent(Parcel in) { 41 readFromParcel(in); 42 mReferrer = in.readString(); 43 } 44 45 public static final Creator<ReferrerIntent> CREATOR = new Creator<ReferrerIntent>() { 46 public ReferrerIntent createFromParcel(Parcel source) { 47 return new ReferrerIntent(source); 48 } 49 public ReferrerIntent[] newArray(int size) { 50 return new ReferrerIntent[size]; 51 } 52 }; 53 54 @Override 55 public boolean equals(Object obj) { 56 if (obj == null || !(obj instanceof ReferrerIntent)) { 57 return false; 58 } 59 final ReferrerIntent other = (ReferrerIntent) obj; 60 return filterEquals(other) && Objects.equals(mReferrer, other.mReferrer); 61 } 62 63 @Override 64 public int hashCode() { 65 int result = 17; 66 result = 31 * result + filterHashCode(); 67 result = 31 * result + Objects.hashCode(mReferrer); 68 return result; 69 } 70 } 71