• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
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.app.sdksandbox;
18 
19 import android.annotation.NonNull;
20 import android.annotation.Nullable;
21 import android.os.Bundle;
22 
23 /** Exception thrown by {@link SdkSandboxManager#requestSurfacePackage} */
24 public final class RequestSurfacePackageException extends Exception {
25 
26     private final @SdkSandboxManager.RequestSurfacePackageErrorCode int
27             mRequestSurfacePackageErrorCode;
28     private final Bundle mExtraInformation;
29 
30     /**
31      * Initializes a {@link RequestSurfacePackageException} with a result code and a message
32      *
33      * @param requestSurfacePackageErrorCode The result code.
34      * @param message The detailed message which is saved for later retrieval by the {@link
35      *     #getMessage()} method.
36      */
RequestSurfacePackageException( @dkSandboxManager.RequestSurfacePackageErrorCode int requestSurfacePackageErrorCode, @Nullable String message)37     public RequestSurfacePackageException(
38             @SdkSandboxManager.RequestSurfacePackageErrorCode int requestSurfacePackageErrorCode,
39             @Nullable String message) {
40         this(requestSurfacePackageErrorCode, message, /*cause=*/ null);
41     }
42 
43     /**
44      * Initializes a {@link RequestSurfacePackageException} with a result code, a message and a
45      * cause.
46      *
47      * @param requestSurfacePackageErrorCode The result code.
48      * @param message The detailed message which is saved for later retrieval by the {@link
49      *     #getMessage()} method.
50      * @param cause The cause of the exception, which is saved for later retrieval by the {@link
51      *     #getCause()} method. A null value is permitted, and indicates that the cause is
52      *     nonexistent or unknown.
53      */
RequestSurfacePackageException( @dkSandboxManager.RequestSurfacePackageErrorCode int requestSurfacePackageErrorCode, @Nullable String message, @Nullable Throwable cause)54     public RequestSurfacePackageException(
55             @SdkSandboxManager.RequestSurfacePackageErrorCode int requestSurfacePackageErrorCode,
56             @Nullable String message,
57             @Nullable Throwable cause) {
58         this(requestSurfacePackageErrorCode, message, cause, new Bundle());
59     }
60 
61     /**
62      * Initializes a {@link RequestSurfacePackageException} with a result code, a message, a cause
63      * and extra information.
64      *
65      * @param requestSurfacePackageErrorCode The result code.
66      * @param message The detailed message which is saved for later retrieval by the {@link
67      *     #getMessage()} method.
68      * @param cause The cause of the exception, which is saved for later retrieval by the {@link
69      *     #getCause()} method. A null value is permitted, and indicates that the cause is
70      *     nonexistent or unknown.
71      * @param extraInfo Extra error information. This is empty if there is no such information.
72      */
RequestSurfacePackageException( @dkSandboxManager.RequestSurfacePackageErrorCode int requestSurfacePackageErrorCode, @Nullable String message, @Nullable Throwable cause, @NonNull Bundle extraInfo)73     public RequestSurfacePackageException(
74             @SdkSandboxManager.RequestSurfacePackageErrorCode int requestSurfacePackageErrorCode,
75             @Nullable String message,
76             @Nullable Throwable cause,
77             @NonNull Bundle extraInfo) {
78         super(message, cause);
79         mRequestSurfacePackageErrorCode = requestSurfacePackageErrorCode;
80         mExtraInformation = extraInfo;
81     }
82     /**
83      * Returns the result code this exception was constructed with.
84      *
85      * @return The result code from {@link SdkSandboxManager#requestSurfacePackage}
86      */
87     public @SdkSandboxManager.RequestSurfacePackageErrorCode int
getRequestSurfacePackageErrorCode()88             getRequestSurfacePackageErrorCode() {
89         return mRequestSurfacePackageErrorCode;
90     }
91 
92     /**
93      * Returns the extra error information this exception was constructed with.
94      *
95      * @return The extra error information Bundle.
96      */
97     @NonNull
getExtraErrorInformation()98     public Bundle getExtraErrorInformation() {
99         return mExtraInformation;
100     }
101 }
102