1 /* 2 * Copyright (C) 2022 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 android.telephony.mockmodem; 18 19 import android.hardware.radio.voice.LastCallFailCause; 20 import android.hardware.radio.voice.LastCallFailCauseInfo; 21 import android.util.Log; 22 23 public class MockCallControlInfo { 24 public static final int CALL_NO_FAIL_BITMASK = 0; 25 public static final int CALL_DIALING_FAIL_BITMASK = 1; 26 public static final int CALL_ALERTING_FAIL_BITMASK = 2; 27 public static final int CALL_INCOMING_FAIL_BITMASK = 4; 28 public static final int CALL_STATE_DURATION_INFINITY = -1; 29 30 // Default value 31 public static final int DEFAULT_DIALING_DURATION_IN_MS = 500; 32 // Ringback tone should happen during dialing to active 33 // The value should be less than dialing duration + alerting duration 34 public static final int DEFAULT_RINGBACK_TONE_IN_MS = 300; 35 public static final int DEFAULT_ALERTING_DURATION_IN_MS = 500; 36 public static final int DEFAULT_ACTIVE_DURATION_IN_MS = CALL_STATE_DURATION_INFINITY; 37 public static final int DEFAULT_DISCONNECTING_DURATION_IN_MS = 10; 38 public static final int DEFAULT_INCOMING_DURATION_IN_MS = CALL_STATE_DURATION_INFINITY; 39 public static final int DEFAULT_CALL_STATE_FAIL_BITMASK = CALL_NO_FAIL_BITMASK; 40 public static final int DEFAULT_DIALING_FAIL_DURATION_IN_MS = 100; 41 public static final int DEFAULT_ALERTING_FAIL_DURATION_IN_MS = 100; 42 public static final int DEFAULT_INCOMING_FAIL_DURATION_IN_MS = 100; 43 public static final int DEFAULT_CALL_END_REASON = LastCallFailCause.NORMAL; 44 public static final String DEFAULT_CALL_END_VENDOR_CAUSE = "Mock call end reason - normal"; 45 46 private String mTag = "MockCallControlInfo"; 47 private long mDialingDurationInMs; 48 private long mRingbackToneTimeInMs; 49 private long mAlertingDurationInMs; 50 private long mActiveDurationInMs; 51 private long mDisconnectingDurationInMs; 52 private long mIncomingDurationInMs; 53 private int mCallStateFailBitMask; 54 private LastCallFailCauseInfo mCallEndReasonInfo; 55 private boolean mRingbackToneState; 56 MockCallControlInfo()57 public MockCallControlInfo() { 58 mDialingDurationInMs = DEFAULT_DIALING_DURATION_IN_MS; 59 mRingbackToneTimeInMs = DEFAULT_RINGBACK_TONE_IN_MS; 60 mAlertingDurationInMs = DEFAULT_ALERTING_DURATION_IN_MS; 61 mActiveDurationInMs = DEFAULT_ACTIVE_DURATION_IN_MS; 62 mDisconnectingDurationInMs = DEFAULT_DISCONNECTING_DURATION_IN_MS; 63 mIncomingDurationInMs = DEFAULT_INCOMING_DURATION_IN_MS; 64 mCallStateFailBitMask = DEFAULT_CALL_STATE_FAIL_BITMASK; 65 mCallEndReasonInfo = new LastCallFailCauseInfo(); 66 mCallEndReasonInfo.causeCode = DEFAULT_CALL_END_REASON; 67 mCallEndReasonInfo.vendorCause = DEFAULT_CALL_END_VENDOR_CAUSE; 68 mRingbackToneState = false; 69 } 70 dump()71 public void dump() { 72 Log.d( 73 mTag, 74 "mDialingDurationInMs = " 75 + mDialingDurationInMs 76 + ", mRingbackToneTimeInMs = " 77 + mRingbackToneTimeInMs 78 + ", mAlertingDurationInMs = " 79 + mAlertingDurationInMs 80 + ", mActiveDurationInMs = " 81 + mActiveDurationInMs 82 + ", mDisconnectingDurationInMs = " 83 + mDisconnectingDurationInMs 84 + ", mIncomingDurationInMs = " 85 + mIncomingDurationInMs 86 + ", mCallStateFailBitMask = " 87 + mCallStateFailBitMask 88 + ", mCallEndReasonInfo.causeCode = " 89 + mCallEndReasonInfo.causeCode 90 + ", mCallEndReasonInfo.vendorCause = " 91 + mCallEndReasonInfo.vendorCause 92 + ", mRingbackTone = " 93 + mRingbackToneState); 94 } 95 getDialingDurationInMs()96 public long getDialingDurationInMs() { 97 return mDialingDurationInMs; 98 } 99 setDialingDurationInMs(long dialingDurationInMs)100 public void setDialingDurationInMs(long dialingDurationInMs) { 101 mDialingDurationInMs = dialingDurationInMs; 102 } 103 getRingbackToneTimeInMs()104 public long getRingbackToneTimeInMs() { 105 return mRingbackToneTimeInMs; 106 } 107 setRingbackToneTimeInMs(long ringbackToneTimeInMs)108 public void setRingbackToneTimeInMs(long ringbackToneTimeInMs) { 109 mRingbackToneTimeInMs = ringbackToneTimeInMs; 110 } 111 getAlertingDurationInMs()112 public long getAlertingDurationInMs() { 113 return mAlertingDurationInMs; 114 } 115 setAlertingDurationInMs(long alertingDurationInMs)116 public void setAlertingDurationInMs(long alertingDurationInMs) { 117 mAlertingDurationInMs = alertingDurationInMs; 118 } 119 getActiveDurationInMs()120 public long getActiveDurationInMs() { 121 return mActiveDurationInMs; 122 } 123 setActiveDurationInMs(long activeDurationInMs)124 public void setActiveDurationInMs(long activeDurationInMs) { 125 mActiveDurationInMs = activeDurationInMs; 126 } 127 getDisconnectingDurationInMs()128 public long getDisconnectingDurationInMs() { 129 return mDisconnectingDurationInMs; 130 } 131 setDisconnectingDurationInMs(long disconnectingDurationInMs)132 public void setDisconnectingDurationInMs(long disconnectingDurationInMs) { 133 mDisconnectingDurationInMs = disconnectingDurationInMs; 134 } 135 getIncomingDurationInMs()136 public long getIncomingDurationInMs() { 137 return mIncomingDurationInMs; 138 } 139 setIncomingDurationInMs(long incomingDurationInMs)140 public void setIncomingDurationInMs(long incomingDurationInMs) { 141 mIncomingDurationInMs = incomingDurationInMs; 142 } 143 getCallStateFailBitMask()144 public int getCallStateFailBitMask() { 145 return mCallStateFailBitMask; 146 } 147 setCallStateFailBitMask(int bitMask)148 public void setCallStateFailBitMask(int bitMask) { 149 mCallStateFailBitMask = bitMask; 150 } 151 getCallEndInfo()152 public LastCallFailCauseInfo getCallEndInfo() { 153 return mCallEndReasonInfo; 154 } 155 setCallEndInfo(int reason, String vendorCause)156 public void setCallEndInfo(int reason, String vendorCause) { 157 mCallEndReasonInfo.causeCode = reason; 158 mCallEndReasonInfo.vendorCause = vendorCause; 159 } 160 getRingbackToneState()161 public boolean getRingbackToneState() { 162 return mRingbackToneState; 163 } 164 setRingbackToneState(boolean ringbackToneState)165 public void setRingbackToneState(boolean ringbackToneState) { 166 mRingbackToneState = ringbackToneState; 167 } 168 } 169