1/*
2 * Copyright (C) 2014 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.media.projection;
18
19import android.os.Parcel;
20import android.os.Parcelable;
21import android.os.UserHandle;
22
23import java.util.Objects;
24
25/** @hide */
26public final class MediaProjectionInfo implements Parcelable {
27    private final String mPackageName;
28    private final UserHandle mUserHandle;
29
30    public MediaProjectionInfo(String packageName, UserHandle handle) {
31        mPackageName = packageName;
32        mUserHandle = handle;
33    }
34
35    public MediaProjectionInfo(Parcel in) {
36        mPackageName = in.readString();
37        mUserHandle = UserHandle.readFromParcel(in);
38    }
39
40    public String getPackageName() {
41        return mPackageName;
42    }
43
44    public UserHandle getUserHandle() {
45        return mUserHandle;
46    }
47
48    @Override
49    public boolean equals(Object o) {
50        if (o instanceof MediaProjectionInfo) {
51            final MediaProjectionInfo other = (MediaProjectionInfo) o;
52            return Objects.equals(other.mPackageName, mPackageName)
53                    && Objects.equals(other.mUserHandle, mUserHandle);
54        }
55        return false;
56    }
57
58    @Override
59    public int hashCode() {
60        return Objects.hash(mPackageName, mUserHandle);
61    }
62
63    @Override
64    public String toString() {
65        return "MediaProjectionInfo{mPackageName="
66            + mPackageName + ", mUserHandle="
67            + mUserHandle + "}";
68    }
69
70    @Override
71    public int describeContents() {
72        return 0;
73    }
74
75    @Override
76    public void writeToParcel(Parcel out, int flags) {
77        out.writeString(mPackageName);
78        UserHandle.writeToParcel(mUserHandle, out);
79    }
80
81    public static final Parcelable.Creator<MediaProjectionInfo> CREATOR =
82            new Parcelable.Creator<MediaProjectionInfo>() {
83        @Override
84        public MediaProjectionInfo createFromParcel(Parcel in) {
85            return new MediaProjectionInfo (in);
86        }
87
88        @Override
89        public MediaProjectionInfo[] newArray(int size) {
90            return new MediaProjectionInfo[size];
91        }
92    };
93}
94