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 com.android.server.telecom.voip; 18 19 import com.android.server.telecom.Call; 20 21 import java.util.Objects; 22 23 public class VoipCallTransactionResult { 24 public static final int RESULT_SUCCEED = 0; 25 26 // NOTE: if the VoipCallTransactionResult should not use the RESULT_SUCCEED to represent a 27 // successful transaction, use an error code defined in the 28 // {@link android.telecom.CallException} class 29 30 private final int mResult; 31 private final String mMessage; 32 private final Call mCall; 33 VoipCallTransactionResult(int result, String message)34 public VoipCallTransactionResult(int result, String message) { 35 mResult = result; 36 mMessage = message; 37 mCall = null; 38 } 39 VoipCallTransactionResult(int result, Call call, String message)40 public VoipCallTransactionResult(int result, Call call, String message) { 41 mResult = result; 42 mCall = call; 43 mMessage = message; 44 } 45 getResult()46 public int getResult() { 47 return mResult; 48 } 49 getMessage()50 public String getMessage() { 51 return mMessage; 52 } 53 getCall()54 public Call getCall(){ 55 return mCall; 56 } 57 58 @Override equals(Object o)59 public boolean equals(Object o) { 60 if (this == o) return true; 61 if (!(o instanceof VoipCallTransactionResult)) return false; 62 VoipCallTransactionResult that = (VoipCallTransactionResult) o; 63 return mResult == that.mResult && Objects.equals(mMessage, that.mMessage); 64 } 65 66 @Override hashCode()67 public int hashCode() { 68 return Objects.hash(mResult, mMessage); 69 } 70 71 @Override toString()72 public String toString() { 73 return new StringBuilder(). 74 append("{ VoipCallTransactionResult: [mResult: "). 75 append(mResult). 76 append("], [mCall: "). 77 append((mCall != null) ? mCall : "null"). 78 append("], [mMessage="). 79 append(mMessage).append("] }").toString(); 80 } 81 } 82