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