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
17package android.telephony.mbms;
18
19import android.annotation.SystemApi;
20import android.annotation.TestApi;
21import android.os.Parcel;
22import android.os.Parcelable;
23
24import java.util.ArrayList;
25import java.util.Date;
26import java.util.List;
27import java.util.Locale;
28import java.util.Map;
29
30/**
31 * Describes a file service available from the carrier from which files can be downloaded via
32 * cell-broadcast.
33 */
34public final class FileServiceInfo extends ServiceInfo implements Parcelable {
35    private final List<FileInfo> files;
36
37    /** @hide */
38    @SystemApi
39    @TestApi
40    public FileServiceInfo(Map<Locale, String> newNames, String newClassName,
41            List<Locale> newLocales, String newServiceId, Date start, Date end,
42            List<FileInfo> newFiles) {
43        super(newNames, newClassName, newLocales, newServiceId, start, end);
44        files = new ArrayList<>(newFiles);
45    }
46
47    public static final Parcelable.Creator<FileServiceInfo> CREATOR =
48            new Parcelable.Creator<FileServiceInfo>() {
49        @Override
50        public FileServiceInfo createFromParcel(Parcel source) {
51            return new FileServiceInfo(source);
52        }
53
54        @Override
55        public FileServiceInfo[] newArray(int size) {
56            return new FileServiceInfo[size];
57        }
58    };
59
60    FileServiceInfo(Parcel in) {
61        super(in);
62        files = new ArrayList<FileInfo>();
63        in.readList(files, FileInfo.class.getClassLoader());
64    }
65
66    @Override
67    public void writeToParcel(Parcel dest, int flags) {
68        super.writeToParcel(dest, flags);
69        dest.writeList(files);
70    }
71
72    @Override
73    public int describeContents() {
74        return 0;
75    }
76
77    /**
78     * @return A list of files available from this service. Note that this list may not be
79     * exhaustive -- the middleware may not have information on all files that are available.
80     * Consult the carrier for an authoritative and exhaustive list.
81     */
82    public List<FileInfo> getFiles() {
83        return files;
84    }
85}
86