1 /*
2  * Copyright (C) 2016 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.telephony.mbms;
18 
19 import android.annotation.SystemApi;
20 import android.annotation.TestApi;
21 import android.net.Uri;
22 import android.os.Parcel;
23 import android.os.Parcelable;
24 
25 import java.util.Objects;
26 
27 /**
28  * Describes a single file that is available over MBMS.
29  */
30 public final class FileInfo implements Parcelable {
31 
32     private final Uri uri;
33 
34     private final String mimeType;
35 
36     public static final @android.annotation.NonNull Parcelable.Creator<FileInfo> CREATOR =
37             new Parcelable.Creator<FileInfo>() {
38         @Override
39         public FileInfo createFromParcel(Parcel source) {
40             return new FileInfo(source);
41         }
42 
43         @Override
44         public FileInfo[] newArray(int size) {
45             return new FileInfo[size];
46         }
47     };
48 
49     /**
50      * @hide
51      */
52     @SystemApi
53     @TestApi
FileInfo(Uri uri, String mimeType)54     public FileInfo(Uri uri, String mimeType) {
55         this.uri = uri;
56         this.mimeType = mimeType;
57     }
58 
FileInfo(Parcel in)59     private FileInfo(Parcel in) {
60         uri = in.readParcelable(null);
61         mimeType = in.readString();
62     }
63 
64     @Override
writeToParcel(Parcel dest, int flags)65     public void writeToParcel(Parcel dest, int flags) {
66         dest.writeParcelable(uri, flags);
67         dest.writeString(mimeType);
68     }
69 
70     @Override
describeContents()71     public int describeContents() {
72         return 0;
73     }
74 
75     /**
76      * @return The URI in the carrier's infrastructure which points to this file. Apps should
77      * negotiate the contents of this URI separately with the carrier.
78      */
getUri()79     public Uri getUri() {
80         return uri;
81     }
82 
83     /**
84      * @return The MIME type of the file.
85      */
getMimeType()86     public String getMimeType() {
87         return mimeType;
88     }
89 
90     @Override
equals(Object o)91     public boolean equals(Object o) {
92         if (this == o) {
93             return true;
94         }
95         if (o == null || getClass() != o.getClass()) {
96             return false;
97         }
98 
99         FileInfo fileInfo = (FileInfo) o;
100         return Objects.equals(uri, fileInfo.uri) &&
101                 Objects.equals(mimeType, fileInfo.mimeType);
102     }
103 
104     @Override
hashCode()105     public int hashCode() {
106         return Objects.hash(uri, mimeType);
107     }
108 }
109