• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1 /*
2  * Copyright (C) 2015 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.messaging.sms;
18 
19 import com.android.messaging.datamodel.data.MessageData;
20 import com.android.messaging.util.Assert;
21 
22 /**
23  * Exception for MMS failures
24  */
25 public class MmsFailureException extends Exception {
26     private static final long serialVersionUID = 1L;
27 
28     /**
29      * Hint of how we should retry in case of failure. Take values defined in MmsUtils.
30      */
31     public final int retryHint;
32 
33     /**
34      * If set, provides a more detailed reason for the failure.
35      */
36     public final int rawStatus;
37 
checkRetryHint()38     private void checkRetryHint() {
39         Assert.isTrue(retryHint == MmsUtils.MMS_REQUEST_AUTO_RETRY
40                 || retryHint == MmsUtils.MMS_REQUEST_MANUAL_RETRY
41                 || retryHint == MmsUtils.MMS_REQUEST_NO_RETRY);
42     }
43     /**
44      * Creates a new MmsFailureException.
45      *
46      * @param retryHint Hint for how to retry
47      */
MmsFailureException(final int retryHint)48     public MmsFailureException(final int retryHint) {
49         super();
50         this.retryHint = retryHint;
51         checkRetryHint();
52         this.rawStatus = MessageData.RAW_TELEPHONY_STATUS_UNDEFINED;
53     }
54 
MmsFailureException(final int retryHint, final int rawStatus)55     public MmsFailureException(final int retryHint, final int rawStatus) {
56         super();
57         this.retryHint = retryHint;
58         checkRetryHint();
59         this.rawStatus = rawStatus;
60     }
61 
62     /**
63      * Creates a new MmsFailureException with the specified detail message.
64      *
65      * @param retryHint Hint for how to retry
66      * @param message the detail message.
67      */
MmsFailureException(final int retryHint, String message)68     public MmsFailureException(final int retryHint, String message) {
69         super(message);
70         this.retryHint = retryHint;
71         checkRetryHint();
72         this.rawStatus = MessageData.RAW_TELEPHONY_STATUS_UNDEFINED;
73     }
74 
75     /**
76      * Creates a new MmsFailureException with the specified cause.
77      *
78      * @param retryHint Hint for how to retry
79      * @param cause the cause.
80      */
MmsFailureException(final int retryHint, Throwable cause)81     public MmsFailureException(final int retryHint, Throwable cause) {
82         super(cause);
83         this.retryHint = retryHint;
84         checkRetryHint();
85         this.rawStatus = MessageData.RAW_TELEPHONY_STATUS_UNDEFINED;
86     }
87 
88     /**
89      * Creates a new MmsFailureException
90      * with the specified detail message and cause.
91      *
92      * @param retryHint Hint for how to retry
93      * @param message the detail message.
94      * @param cause the cause.
95      */
MmsFailureException(final int retryHint, String message, Throwable cause)96     public MmsFailureException(final int retryHint, String message, Throwable cause) {
97         super(message, cause);
98         this.retryHint = retryHint;
99         checkRetryHint();
100         this.rawStatus = MessageData.RAW_TELEPHONY_STATUS_UNDEFINED;
101     }
102 }
103