blob: 5c1d35e372adf264718adfb201fd3b92dd3f25ca [file] [log] [blame]
Geremy Condraf1bcca82013-01-07 22:35:24 -08001/*
2 * Copyright (C) 2012 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
17package android.content.pm;
18
dcashman9d2f4412014-06-09 09:27:54 -070019import android.os.IBinder;
dcashmanc6f22492014-08-14 09:54:51 -070020import android.os.Parcel;
21import android.os.Parcelable;
Geremy Condraf1bcca82013-01-07 22:35:24 -080022
dcashman9d2f4412014-06-09 09:27:54 -070023/**
24 * Represents a {@code KeySet} that has been declared in the AndroidManifest.xml
25 * file for the application. A {@code KeySet} can be used explicitly to
26 * represent a trust relationship with other applications on the device.
dcashmanc6f22492014-08-14 09:54:51 -070027 * @hide
dcashman9d2f4412014-06-09 09:27:54 -070028 */
dcashmanc6f22492014-08-14 09:54:51 -070029public class KeySet implements Parcelable {
Geremy Condraf1bcca82013-01-07 22:35:24 -080030
dcashman9d2f4412014-06-09 09:27:54 -070031 private IBinder token;
Geremy Condraf1bcca82013-01-07 22:35:24 -080032
33 /** @hide */
dcashman9d2f4412014-06-09 09:27:54 -070034 public KeySet(IBinder token) {
35 if (token == null) {
36 throw new NullPointerException("null value for KeySet IBinder token");
37 }
Geremy Condraf1bcca82013-01-07 22:35:24 -080038 this.token = token;
39 }
40
dcashman9d2f4412014-06-09 09:27:54 -070041 /** @hide */
42 public IBinder getToken() {
Geremy Condraf1bcca82013-01-07 22:35:24 -080043 return token;
44 }
dcashman9d2f4412014-06-09 09:27:54 -070045
dcashmanc6f22492014-08-14 09:54:51 -070046 /** @hide */
dcashman9d2f4412014-06-09 09:27:54 -070047 @Override
48 public boolean equals(Object o) {
49 if (o instanceof KeySet) {
50 KeySet ks = (KeySet) o;
51 return token == ks.token;
52 }
53 return false;
54 }
dcashmanc6f22492014-08-14 09:54:51 -070055
56 /** @hide */
57 @Override
58 public int hashCode() {
59 return token.hashCode();
60 }
61
62 /**
63 * Implement Parcelable
64 * @hide
65 */
Jeff Sharkey9e8f83d2019-02-28 12:06:45 -070066 public static final @android.annotation.NonNull Parcelable.Creator<KeySet> CREATOR
dcashmanc6f22492014-08-14 09:54:51 -070067 = new Parcelable.Creator<KeySet>() {
68
69 /**
70 * Create a KeySet from a Parcel
71 *
72 * @param in The parcel containing the KeySet
73 */
74 public KeySet createFromParcel(Parcel source) {
75 return readFromParcel(source);
76 }
77
78 /**
79 * Create an array of null KeySets
80 */
81 public KeySet[] newArray(int size) {
82 return new KeySet[size];
83 }
84 };
85
86 /**
87 * @hide
88 */
89 private static KeySet readFromParcel(Parcel in) {
90 IBinder token = in.readStrongBinder();
91 return new KeySet(token);
92 }
93
94 /**
95 * @hide
96 */
97 @Override
98 public void writeToParcel(Parcel out, int flags) {
99 out.writeStrongBinder(token);
100 }
101
102 /**
103 * @hide
104 */
105 @Override
106 public int describeContents() {
107 return 0;
108 }
Geremy Condraf1bcca82013-01-07 22:35:24 -0800109}