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