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 import android.os.PersistableBundle;
21 import android.telephony.CarrierConfigManager;
22 
23 import com.android.internal.annotations.VisibleForTesting;
24 import com.android.settings.R;
25 
26 /**
27  * Disclaimer item class for displaying location privacy policy UI on
28  * {@link WifiCallingDisclaimerFragment}.
29  */
30 class LocationPolicyDisclaimer extends DisclaimerItem {
31     private static final String DISCLAIMER_ITEM_NAME = "LocationPolicyDisclaimer";
32     @VisibleForTesting
33     static final String KEY_HAS_AGREED_LOCATION_DISCLAIMER
34             = "key_has_agreed_location_disclaimer";
35 
LocationPolicyDisclaimer(Context context, int subId)36     LocationPolicyDisclaimer(Context context, int subId) {
37         super(context, subId);
38     }
39 
40     /**
41      * {@inheritDoc}
42      */
43     @Override
shouldShow()44     boolean shouldShow() {
45         PersistableBundle config = getCarrierConfig();
46         if (!config.getBoolean(CarrierConfigManager.KEY_SHOW_WFC_LOCATION_PRIVACY_POLICY_BOOL)) {
47             logd("shouldShow: false due to carrier config is false.");
48             return false;
49         }
50 
51         if (config.getBoolean(CarrierConfigManager.KEY_CARRIER_DEFAULT_WFC_IMS_ENABLED_BOOL)) {
52             logd("shouldShow: false due to WFC is on as default.");
53             return false;
54         }
55 
56         return super.shouldShow();
57     }
58 
59     /**
60      * {@inheritDoc}
61      */
62     @Override
getName()63     protected String getName() {
64         return DISCLAIMER_ITEM_NAME;
65     }
66 
67     /**
68      * {@inheritDoc}
69      */
70     @Override
getTitleId()71     protected int getTitleId() {
72         return R.string.wfc_disclaimer_location_title_text;
73     }
74 
75     /**
76      * {@inheritDoc}
77      */
78     @Override
getMessageId()79     protected int getMessageId() {
80         return R.string.wfc_disclaimer_location_desc_text;
81     }
82 
83     /**
84      * {@inheritDoc}
85      */
86     @Override
getPrefKey()87     protected String getPrefKey() {
88         return KEY_HAS_AGREED_LOCATION_DISCLAIMER;
89     }
90 }
91