| 1 |
package android.net; |
| 2 |
|
| 3 |
import android.annotation.Nullable; |
| 4 |
import android.content.ComponentName; |
| 5 |
import android.os.Parcel; |
| 6 |
import android.os.Parcelable; |
| 7 |
|
| 8 |
import java.util.Objects; |
| 9 |
|
| 10 |
|
| 11 |
|
| 12 |
|
| 13 |
|
| 14 |
|
| 15 |
public final class NetworkScorerAppData implements Parcelable { |
| 16 |
|
| 17 |
public final int packageUid; |
| 18 |
private final ComponentName mRecommendationService; |
| 19 |
|
| 20 |
private final String mRecommendationServiceLabel; |
| 21 |
|
| 22 |
|
| 23 |
|
| 24 |
|
| 25 |
private final ComponentName mEnableUseOpenWifiActivity; |
| 26 |
|
| 27 |
|
| 28 |
|
| 29 |
|
| 30 |
private final String mNetworkAvailableNotificationChannelId; |
| 31 |
|
| 32 |
public NetworkScorerAppData(int packageUid, ComponentName recommendationServiceComp, |
| 33 |
String recommendationServiceLabel, ComponentName enableUseOpenWifiActivity, |
| 34 |
String networkAvailableNotificationChannelId) { |
| 35 |
this.packageUid = packageUid; |
| 36 |
this.mRecommendationService = recommendationServiceComp; |
| 37 |
this.mRecommendationServiceLabel = recommendationServiceLabel; |
| 38 |
this.mEnableUseOpenWifiActivity = enableUseOpenWifiActivity; |
| 39 |
this.mNetworkAvailableNotificationChannelId = networkAvailableNotificationChannelId; |
| 40 |
} |
| 41 |
|
| 42 |
protected NetworkScorerAppData(Parcel in) { |
| 43 |
packageUid = in.readInt(); |
| 44 |
mRecommendationService = ComponentName.readFromParcel(in); |
| 45 |
mRecommendationServiceLabel = in.readString(); |
| 46 |
mEnableUseOpenWifiActivity = ComponentName.readFromParcel(in); |
| 47 |
mNetworkAvailableNotificationChannelId = in.readString(); |
| 48 |
} |
| 49 |
|
| 50 |
@Override |
| 51 |
public void writeToParcel(Parcel dest, int flags) { |
| 52 |
dest.writeInt(packageUid); |
| 53 |
ComponentName.writeToParcel(mRecommendationService, dest); |
| 54 |
dest.writeString(mRecommendationServiceLabel); |
| 55 |
ComponentName.writeToParcel(mEnableUseOpenWifiActivity, dest); |
| 56 |
dest.writeString(mNetworkAvailableNotificationChannelId); |
| 57 |
} |
| 58 |
|
| 59 |
@Override |
| 60 |
public int describeContents() { |
| 61 |
return 0; |
| 62 |
} |
| 63 |
|
| 64 |
public static final @android.annotation.NonNull Creator<NetworkScorerAppData> CREATOR = |
| 65 |
new Creator<NetworkScorerAppData>() { |
| 66 |
@Override |
| 67 |
public NetworkScorerAppData createFromParcel(Parcel in) { |
| 68 |
return new NetworkScorerAppData(in); |
| 69 |
} |
| 70 |
|
| 71 |
@Override |
| 72 |
public NetworkScorerAppData[] newArray(int size) { |
| 73 |
return new NetworkScorerAppData[size]; |
| 74 |
} |
| 75 |
}; |
| 76 |
|
| 77 |
public String getRecommendationServicePackageName() { |
| 78 |
return mRecommendationService.getPackageName(); |
| 79 |
} |
| 80 |
|
| 81 |
public ComponentName getRecommendationServiceComponent() { |
| 82 |
return mRecommendationService; |
| 83 |
} |
| 84 |
|
| 85 |
@Nullable |
| 86 |
public ComponentName getEnableUseOpenWifiActivity() { |
| 87 |
return mEnableUseOpenWifiActivity; |
| 88 |
} |
| 89 |
|
| 90 |
@Nullable |
| 91 |
public String getRecommendationServiceLabel() { |
| 92 |
return mRecommendationServiceLabel; |
| 93 |
} |
| 94 |
|
| 95 |
@Nullable |
| 96 |
public String getNetworkAvailableNotificationChannelId() { |
| 97 |
return mNetworkAvailableNotificationChannelId; |
| 98 |
} |
| 99 |
|
| 100 |
@Override |
| 101 |
public String toString() { |
| 102 |
return "NetworkScorerAppData{" + |
| 103 |
"packageUid=" + packageUid + |
| 104 |
", mRecommendationService=" + mRecommendationService + |
| 105 |
", mRecommendationServiceLabel=" + mRecommendationServiceLabel + |
| 106 |
", mEnableUseOpenWifiActivity=" + mEnableUseOpenWifiActivity + |
| 107 |
", mNetworkAvailableNotificationChannelId=" + |
| 108 |
mNetworkAvailableNotificationChannelId + |
| 109 |
'}'; |
| 110 |
} |
| 111 |
|
| 112 |
@Override |
| 113 |
public boolean equals(@Nullable Object o) { |
| 114 |
if (this == o) return true; |
| 115 |
if (o == null || getClass() != o.getClass()) return false; |
| 116 |
NetworkScorerAppData that = (NetworkScorerAppData) o; |
| 117 |
return packageUid == that.packageUid && |
| 118 |
Objects.equals(mRecommendationService, that.mRecommendationService) && |
| 119 |
Objects.equals(mRecommendationServiceLabel, that.mRecommendationServiceLabel) && |
| 120 |
Objects.equals(mEnableUseOpenWifiActivity, that.mEnableUseOpenWifiActivity) && |
| 121 |
Objects.equals(mNetworkAvailableNotificationChannelId, |
| 122 |
that.mNetworkAvailableNotificationChannelId); |
| 123 |
} |
| 124 |
|
| 125 |
@Override |
| 126 |
public int hashCode() { |
| 127 |
return Objects.hash(packageUid, mRecommendationService, mRecommendationServiceLabel, |
| 128 |
mEnableUseOpenWifiActivity, mNetworkAvailableNotificationChannelId); |
| 129 |
} |
| 130 |
} |