• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1 /*
2  * Copyright (C) 2018 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 com.android.settings.wifi.calling;
18 
19 import android.content.Context;
20 
21 import com.android.internal.annotations.VisibleForTesting;
22 
23 import java.util.ArrayList;
24 import java.util.Iterator;
25 import java.util.List;
26 
27 /**
28  * Factory class to create disclaimer items list.
29  */
30 @VisibleForTesting
31 public final class DisclaimerItemFactory {
32 
33     /**
34      * Creates disclaimer items list.
35      *
36      * @param context The application context
37      * @param subId The subscription id.
38      * @return The {@link DisclaimerItem} list instance, if there are no items, return empty list.
39      */
create(Context context, int subId)40     public static List<DisclaimerItem> create(Context context, int subId) {
41         List<DisclaimerItem> itemList = getDisclaimerItemList(context, subId);
42         Iterator itr = itemList.iterator();
43         while (itr.hasNext()) {
44             DisclaimerItem item = (DisclaimerItem) itr.next();
45             if (!item.shouldShow()) {
46                 itr.remove();
47             }
48         }
49         return itemList;
50     }
51 
getDisclaimerItemList(Context context, int subId)52     private static List<DisclaimerItem> getDisclaimerItemList(Context context, int subId) {
53         List<DisclaimerItem> itemList = new ArrayList<DisclaimerItem>();
54         itemList.add(new LocationPolicyDisclaimer(context, subId));
55         itemList.add(new EmergencyCallLimitationDisclaimer(context, subId));
56 
57         return itemList;
58     }
59 }
60