Geremy Condra | f1bcca8 | 2013-01-07 22:35:24 -0800 | [diff] [blame] | 1 | /* |
| 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 | |
| 17 | package android.content.pm; |
| 18 | |
dcashman | 9d2f441 | 2014-06-09 09:27:54 -0700 | [diff] [blame] | 19 | import android.os.IBinder; |
dcashman | c6f2249 | 2014-08-14 09:54:51 -0700 | [diff] [blame] | 20 | import android.os.Parcel; |
| 21 | import android.os.Parcelable; |
Geremy Condra | f1bcca8 | 2013-01-07 22:35:24 -0800 | [diff] [blame] | 22 | |
dcashman | 9d2f441 | 2014-06-09 09:27:54 -0700 | [diff] [blame] | 23 | /** |
| 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. |
dcashman | c6f2249 | 2014-08-14 09:54:51 -0700 | [diff] [blame] | 27 | * @hide |
dcashman | 9d2f441 | 2014-06-09 09:27:54 -0700 | [diff] [blame] | 28 | */ |
dcashman | c6f2249 | 2014-08-14 09:54:51 -0700 | [diff] [blame] | 29 | public class KeySet implements Parcelable { |
Geremy Condra | f1bcca8 | 2013-01-07 22:35:24 -0800 | [diff] [blame] | 30 | |
dcashman | 9d2f441 | 2014-06-09 09:27:54 -0700 | [diff] [blame] | 31 | private IBinder token; |
Geremy Condra | f1bcca8 | 2013-01-07 22:35:24 -0800 | [diff] [blame] | 32 | |
| 33 | /** @hide */ |
dcashman | 9d2f441 | 2014-06-09 09:27:54 -0700 | [diff] [blame] | 34 | public KeySet(IBinder token) { |
| 35 | if (token == null) { |
| 36 | throw new NullPointerException("null value for KeySet IBinder token"); |
| 37 | } |
Geremy Condra | f1bcca8 | 2013-01-07 22:35:24 -0800 | [diff] [blame] | 38 | this.token = token; |
| 39 | } |
| 40 | |
dcashman | 9d2f441 | 2014-06-09 09:27:54 -0700 | [diff] [blame] | 41 | /** @hide */ |
| 42 | public IBinder getToken() { |
Geremy Condra | f1bcca8 | 2013-01-07 22:35:24 -0800 | [diff] [blame] | 43 | return token; |
| 44 | } |
dcashman | 9d2f441 | 2014-06-09 09:27:54 -0700 | [diff] [blame] | 45 | |
dcashman | c6f2249 | 2014-08-14 09:54:51 -0700 | [diff] [blame] | 46 | /** @hide */ |
dcashman | 9d2f441 | 2014-06-09 09:27:54 -0700 | [diff] [blame] | 47 | @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 | } |
dcashman | c6f2249 | 2014-08-14 09:54:51 -0700 | [diff] [blame] | 55 | |
| 56 | /** @hide */ |
| 57 | @Override |
| 58 | public int hashCode() { |
| 59 | return token.hashCode(); |
| 60 | } |
| 61 | |
| 62 | /** |
| 63 | * Implement Parcelable |
| 64 | * @hide |
| 65 | */ |
Jeff Sharkey | 9e8f83d | 2019-02-28 12:06:45 -0700 | [diff] [blame^] | 66 | public static final @android.annotation.NonNull Parcelable.Creator<KeySet> CREATOR |
dcashman | c6f2249 | 2014-08-14 09:54:51 -0700 | [diff] [blame] | 67 | = 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 Condra | f1bcca8 | 2013-01-07 22:35:24 -0800 | [diff] [blame] | 109 | } |