Debian Codegraph @

core/java/android/os/RemoteException.java

raw symbols SCIP
1 /*
2 * Copyright (C) 2006 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.os;
18
19 import android.annotation.NonNull;
20 import android.util.AndroidException;
21
22 /**
23 * Parent exception for all Binder remote-invocation errors
24 *
25 * Note: not all exceptions from binder services will be subclasses of this.
26 * For instance, RuntimeException and several subclasses of it may be
27 * thrown as well as OutOfMemoryException.
28 *
29 * One common subclass is {@link DeadObjectException}.
30 */
31 public class RemoteException extends AndroidException {
32 public RemoteException() {
33 super();
34 }
35
36 public RemoteException(String message) {
37 super(message);
38 }
39
40 /** @hide */
41 public RemoteException(String message, Throwable cause, boolean enableSuppression,
42 boolean writableStackTrace) {
43 super(message, cause, enableSuppression, writableStackTrace);
44 }
45
46 /** @hide */
47 public RemoteException(Throwable cause) {
48 this(cause.getMessage(), cause, true, false);
49 }
50
51 /**
52 * Rethrow this as an unchecked runtime exception.
53 * <p>
54 * Apps making calls into other processes may end up persisting internal
55 * state or making security decisions based on the perceived success or
56 * failure of a call, or any default values returned. For this reason, we
57 * want to strongly throw when there was trouble with the transaction.
58 *
59 * @throws RuntimeException
60 */
61 @NonNull
62 public RuntimeException rethrowAsRuntimeException() {
63 throw new RuntimeException(this);
64 }
65
66 /**
67 * Rethrow this exception when we know it came from the system server. This
68 * gives us an opportunity to throw a nice clean
69 * {@link DeadSystemRuntimeException} signal to avoid spamming logs with
70 * misleading stack traces.
71 * <p>
72 * Apps making calls into the system server may end up persisting internal
73 * state or making security decisions based on the perceived success or
74 * failure of a call, or any default values returned. For this reason, we
75 * want to strongly throw when there was trouble with the transaction.
76 *
77 * @throws RuntimeException
78 */
79 @NonNull
80 public RuntimeException rethrowFromSystemServer() {
81 if (this instanceof DeadObjectException) {
82 throw new DeadSystemRuntimeException();
83 } else {
84 throw new RuntimeException(this);
85 }
86 }
87 }