| 1 |
|
| 2 |
|
| 3 |
|
| 4 |
|
| 5 |
|
| 6 |
|
| 7 |
|
| 8 |
|
| 9 |
|
| 10 |
|
| 11 |
|
| 12 |
|
| 13 |
|
| 14 |
|
| 15 |
|
| 16 |
|
| 17 |
package android.app.compat; |
| 18 |
|
| 19 |
import android.annotation.IntDef; |
| 20 |
import android.annotation.NonNull; |
| 21 |
import android.annotation.Nullable; |
| 22 |
|
| 23 |
import com.android.internal.annotations.Immutable; |
| 24 |
|
| 25 |
import java.lang.annotation.Retention; |
| 26 |
import java.lang.annotation.RetentionPolicy; |
| 27 |
import java.util.Objects; |
| 28 |
|
| 29 |
|
| 30 |
|
| 31 |
|
| 32 |
|
| 33 |
|
| 34 |
|
| 35 |
|
| 36 |
|
| 37 |
@Immutable |
| 38 |
final class ChangeIdStateQuery { |
| 39 |
|
| 40 |
static final int QUERY_BY_PACKAGE_NAME = 0; |
| 41 |
static final int QUERY_BY_UID = 1; |
| 42 |
@IntDef({QUERY_BY_PACKAGE_NAME, QUERY_BY_UID}) |
| 43 |
@Retention(RetentionPolicy.SOURCE) |
| 44 |
@interface QueryType {} |
| 45 |
|
| 46 |
public @QueryType int type; |
| 47 |
public long changeId; |
| 48 |
public String packageName; |
| 49 |
public int uid; |
| 50 |
public int userId; |
| 51 |
|
| 52 |
private ChangeIdStateQuery(@QueryType int type, long changeId, String packageName, |
| 53 |
int uid, int userId) { |
| 54 |
this.type = type; |
| 55 |
this.changeId = changeId; |
| 56 |
this.packageName = packageName; |
| 57 |
this.uid = uid; |
| 58 |
this.userId = userId; |
| 59 |
} |
| 60 |
|
| 61 |
static ChangeIdStateQuery byPackageName(long changeId, @NonNull String packageName, |
| 62 |
int userId) { |
| 63 |
return new ChangeIdStateQuery(QUERY_BY_PACKAGE_NAME, changeId, packageName, 0, userId); |
| 64 |
} |
| 65 |
|
| 66 |
static ChangeIdStateQuery byUid(long changeId, int uid) { |
| 67 |
return new ChangeIdStateQuery(QUERY_BY_UID, changeId, null, uid, 0); |
| 68 |
} |
| 69 |
|
| 70 |
@Override |
| 71 |
public boolean equals(@Nullable Object other) { |
| 72 |
if (this == other) { |
| 73 |
return true; |
| 74 |
} |
| 75 |
if ((other == null) || !(other instanceof ChangeIdStateQuery)) { |
| 76 |
return false; |
| 77 |
} |
| 78 |
final ChangeIdStateQuery that = (ChangeIdStateQuery) other; |
| 79 |
return this.type == that.type |
| 80 |
&& this.changeId == that.changeId |
| 81 |
&& Objects.equals(this.packageName, that.packageName) |
| 82 |
&& this.uid == that.uid |
| 83 |
&& this.userId == that.userId; |
| 84 |
} |
| 85 |
|
| 86 |
@Override |
| 87 |
public int hashCode() { |
| 88 |
int result = 1; |
| 89 |
result = 31 * result + type; |
| 90 |
result = 31 * result + (int) (changeId ^ (changeId >>> 32)); |
| 91 |
if (packageName != null) { |
| 92 |
result = 31 * result + packageName.hashCode(); |
| 93 |
} |
| 94 |
result = 31 * result + uid; |
| 95 |
result = 31 * result + userId; |
| 96 |
return result; |
| 97 |
} |
| 98 |
} |