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 android.webkit;
18 
19 import android.annotation.FlaggedApi;
20 import android.annotation.IntDef;
21 import android.annotation.NonNull;
22 import android.annotation.Nullable;
23 import android.annotation.SystemApi;
24 import android.compat.annotation.UnsupportedAppUsage;
25 import android.content.pm.PackageInfo;
26 import android.os.Parcel;
27 import android.os.Parcelable;
28 
29 import java.lang.annotation.Retention;
30 import java.lang.annotation.RetentionPolicy;
31 
32 /** @hide */
33 @FlaggedApi(Flags.FLAG_UPDATE_SERVICE_IPC_WRAPPER)
34 @SystemApi(client = SystemApi.Client.MODULE_LIBRARIES)
35 public final class WebViewProviderResponse implements Parcelable {
36 
37     @IntDef(
38             prefix = {"STATUS_"},
39             value = {
40                 STATUS_SUCCESS,
41                 STATUS_FAILED_WAITING_FOR_RELRO,
42                 STATUS_FAILED_LISTING_WEBVIEW_PACKAGES,
43                 STATUS_FAILED_OTHER,
44             })
45     @Retention(RetentionPolicy.SOURCE)
46     private @interface WebViewProviderStatus {}
47 
48     public static final int STATUS_SUCCESS = WebViewFactory.LIBLOAD_SUCCESS;
49     public static final int STATUS_FAILED_WAITING_FOR_RELRO =
50             WebViewFactory.LIBLOAD_FAILED_WAITING_FOR_RELRO;
51     public static final int STATUS_FAILED_LISTING_WEBVIEW_PACKAGES =
52             WebViewFactory.LIBLOAD_FAILED_LISTING_WEBVIEW_PACKAGES;
53     public static final int STATUS_FAILED_OTHER = WebViewFactory.LIBLOAD_FAILED_OTHER;
54 
WebViewProviderResponse( @ullable PackageInfo packageInfo, @WebViewProviderStatus int status)55     public WebViewProviderResponse(
56             @Nullable PackageInfo packageInfo, @WebViewProviderStatus int status) {
57         this.packageInfo = packageInfo;
58         this.status = status;
59     }
60 
61     // aidl stuff
62     public static final @NonNull Parcelable.Creator<WebViewProviderResponse> CREATOR =
63         new Parcelable.Creator<WebViewProviderResponse>() {
64             public WebViewProviderResponse createFromParcel(Parcel in) {
65                 return new WebViewProviderResponse(in);
66             }
67 
68             public WebViewProviderResponse[] newArray(int size) {
69                 return new WebViewProviderResponse[size];
70             }
71         };
72 
WebViewProviderResponse(Parcel in)73     private WebViewProviderResponse(Parcel in) {
74         packageInfo = in.readTypedObject(PackageInfo.CREATOR);
75         status = in.readInt();
76     }
77 
78     @Override
describeContents()79     public int describeContents() {
80         return 0;
81     }
82 
83     @Override
writeToParcel(@onNull Parcel out, int flags)84     public void writeToParcel(@NonNull Parcel out, int flags) {
85         out.writeTypedObject(packageInfo, flags);
86         out.writeInt(status);
87     }
88 
89     @UnsupportedAppUsage public final @Nullable PackageInfo packageInfo;
90     public final @WebViewProviderStatus int status;
91 }
92