• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1 /*
2  * Copyright (C) 2023 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.telecom.cts.apps;
18 
19 import android.os.Parcel;
20 import android.os.Parcelable;
21 import android.telecom.CallException;
22 
23 import androidx.annotation.NonNull;
24 
25 public class CallExceptionTransaction extends BaseTransaction implements Parcelable {
26 
getCallException()27     public CallException getCallException() {
28         return mCallException;
29     }
30 
31     CallException mCallException;
32 
CallExceptionTransaction(TestAppTransaction result)33     public CallExceptionTransaction(TestAppTransaction result) {
34         mResult = result;
35         mCallException = null;
36     }
37 
CallExceptionTransaction(TestAppTransaction result, CallException callException)38     public CallExceptionTransaction(TestAppTransaction result, CallException callException) {
39         mResult = result;
40         mCallException = callException;
41     }
42 
CallExceptionTransaction(TestAppTransaction result, TestAppException exception)43     public CallExceptionTransaction(TestAppTransaction result, TestAppException exception) {
44         mResult = result;
45         mException = exception;
46     }
47 
48     @Override
describeContents()49     public int describeContents() {
50         return 0;
51     }
52 
53     @Override
writeToParcel(@onNull Parcel dest, int flags)54     public void writeToParcel(@NonNull Parcel dest, int flags) {
55         dest.writeParcelable(mResult, flags);
56         if (isTransactionSuccessful()) {
57             dest.writeParcelable(mCallException, flags);
58         } else {
59             dest.writeParcelable(mException, flags);
60         }
61     }
62 
63     public static final Creator<CallExceptionTransaction> CREATOR = new Creator<>() {
64         @Override
65         public CallExceptionTransaction createFromParcel(Parcel source) {
66             TestAppTransaction transactionResult =
67                     source.readParcelable(getClass().getClassLoader(),
68                             TestAppTransaction.class);
69 
70             if (transactionResult != null
71                     && transactionResult.equals(TestAppTransaction.Success)) {
72                 return new CallExceptionTransaction(
73                         transactionResult,
74                         source.readParcelable(getClass().getClassLoader(),
75                                 CallException.class));
76             } else {
77                 return new CallExceptionTransaction(
78                         transactionResult,
79                         source.readParcelable(getClass().getClassLoader(),
80                                 TestAppException.class));
81             }
82         }
83 
84         @Override
85         public CallExceptionTransaction[] newArray(int size) {
86             return new CallExceptionTransaction[size];
87         }
88     };
89 }
90