1/*
2 * Copyright (C) 2017 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
19import android.annotation.NonNull;
20import android.annotation.Nullable;
21import android.annotation.SystemApi;
22import android.content.IntentFilter;
23import android.os.Parcel;
24import android.os.Parcelable;
25
26import java.util.ArrayList;
27import java.util.List;
28
29/**
30 * Information about an instant application intent filter.
31 * @hide
32 */
33@SystemApi
34public final class InstantAppIntentFilter implements Parcelable {
35    private final String mSplitName;
36    /** The filters used to match domain */
37    private final List<IntentFilter> mFilters = new ArrayList<IntentFilter>();
38
39    public InstantAppIntentFilter(@Nullable String splitName, @NonNull List<IntentFilter> filters) {
40        if (filters == null || filters.size() == 0) {
41            throw new IllegalArgumentException();
42        }
43        mSplitName = splitName;
44        mFilters.addAll(filters);
45    }
46
47    InstantAppIntentFilter(Parcel in) {
48        mSplitName = in.readString();
49        in.readList(mFilters, null /*loader*/);
50    }
51
52    public String getSplitName() {
53        return mSplitName;
54    }
55
56    public List<IntentFilter> getFilters() {
57        return mFilters;
58    }
59
60    @Override
61    public int describeContents() {
62        return 0;
63    }
64
65    @Override
66    public void writeToParcel(Parcel out, int flags) {
67        out.writeString(mSplitName);
68        out.writeList(mFilters);
69    }
70
71    public static final Parcelable.Creator<InstantAppIntentFilter> CREATOR
72            = new Parcelable.Creator<InstantAppIntentFilter>() {
73        @Override
74        public InstantAppIntentFilter createFromParcel(Parcel in) {
75            return new InstantAppIntentFilter(in);
76        }
77        @Override
78        public InstantAppIntentFilter[] newArray(int size) {
79            return new InstantAppIntentFilter[size];
80        }
81    };
82}
83