summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
author Pinyao Ting <pinyaoting@google.com> 2024-05-17 01:49:43 +0000
committer Pinyao Ting <pinyaoting@google.com> 2024-05-17 01:49:43 +0000
commitdbde425140e6f771c0ed052f90ac3e4515a5a77c (patch)
treeefa95b6aaed45ef130af6d02cac1903730ac6fe9
parentf5ecee638ca6b06042af0d9f495df1f8b813b902 (diff)
Include hashCode in app prediction classes
Bug: 341057962 Test: manual Flag: EXEMPT bugfix Change-Id: I5bf2a6141f9f38151ad5f03427ac3481c16bfb47
-rw-r--r--core/java/android/app/prediction/AppPredictionContext.java9
-rw-r--r--core/java/android/app/prediction/AppTarget.java10
-rw-r--r--core/java/android/app/prediction/AppTargetEvent.java8
3 files changed, 27 insertions, 0 deletions
diff --git a/core/java/android/app/prediction/AppPredictionContext.java b/core/java/android/app/prediction/AppPredictionContext.java
index 99fa869cee93..1b718d436d6d 100644
--- a/core/java/android/app/prediction/AppPredictionContext.java
+++ b/core/java/android/app/prediction/AppPredictionContext.java
@@ -24,6 +24,8 @@ import android.os.Bundle;
import android.os.Parcel;
import android.os.Parcelable;
+import java.util.Objects;
+
/**
* Class that provides contextual information about the environment in which the app prediction is
* used, such as package name, UI in which the app targets are shown, and number of targets.
@@ -99,6 +101,13 @@ public final class AppPredictionContext implements Parcelable {
}
@Override
+ public int hashCode() {
+ int hashCode = Objects.hash(mUiSurface, mPackageName);
+ hashCode = 31 * hashCode + mPredictedTargetCount;
+ return hashCode;
+ }
+
+ @Override
public int describeContents() {
return 0;
}
diff --git a/core/java/android/app/prediction/AppTarget.java b/core/java/android/app/prediction/AppTarget.java
index fef9e7020097..25c1a594ad81 100644
--- a/core/java/android/app/prediction/AppTarget.java
+++ b/core/java/android/app/prediction/AppTarget.java
@@ -167,6 +167,16 @@ public final class AppTarget implements Parcelable {
}
@Override
+ public int hashCode() {
+ int hashCode = Objects.hash(mId, mPackageName, mClassName, mUser);
+ if (mShortcutInfo != null) {
+ hashCode = 31 * hashCode + mShortcutInfo.getId().hashCode();
+ }
+ hashCode = 31 * hashCode + mRank;
+ return hashCode;
+ }
+
+ @Override
public int describeContents() {
return 0;
}
diff --git a/core/java/android/app/prediction/AppTargetEvent.java b/core/java/android/app/prediction/AppTargetEvent.java
index 91da8ec71dae..e36d87899b62 100644
--- a/core/java/android/app/prediction/AppTargetEvent.java
+++ b/core/java/android/app/prediction/AppTargetEvent.java
@@ -24,6 +24,7 @@ import android.os.Parcelable;
import java.lang.annotation.Retention;
import java.lang.annotation.RetentionPolicy;
+import java.util.Objects;
/**
* A representation of an app target event.
@@ -116,6 +117,13 @@ public final class AppTargetEvent implements Parcelable {
}
@Override
+ public int hashCode() {
+ int hashCode = Objects.hash(mTarget, mLocation);
+ hashCode = 31 * hashCode + mAction;
+ return hashCode;
+ }
+
+ @Override
public int describeContents() {
return 0;
}