blob: 170475772cb2333f0ebfbe4ff41e07617f7e65db [file] [log] [blame]
Gustav Sennton6258dcd2015-10-30 19:25:37 +00001/*
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
17package android.webkit;
18
Gustav Sennton1c177d82016-03-29 20:43:11 +010019import android.annotation.SystemApi;
Mathew Inwood62d83fb2018-08-16 19:09:48 +010020import android.annotation.UnsupportedAppUsage;
Gustav Sennton74473592017-11-20 20:14:17 +000021import android.content.pm.Signature;
Gustav Sennton6258dcd2015-10-30 19:25:37 +000022import android.os.Parcel;
23import android.os.Parcelable;
Gustav Sennton74473592017-11-20 20:14:17 +000024import android.util.Base64;
Gustav Sennton6258dcd2015-10-30 19:25:37 +000025
Gustav Sennton1c177d82016-03-29 20:43:11 +010026/**
27 * @hide
28 */
29@SystemApi
Gustav Senntondbf5eb02016-03-30 14:53:03 +010030public final class WebViewProviderInfo implements Parcelable {
Gustav Sennton6258dcd2015-10-30 19:25:37 +000031
Gustav Senntondbf5eb02016-03-30 14:53:03 +010032 public WebViewProviderInfo(String packageName, String description,
33 boolean availableByDefault, boolean isFallback, String[] signatures) {
Gustav Sennton6258dcd2015-10-30 19:25:37 +000034 this.packageName = packageName;
35 this.description = description;
Gustav Senntonc83e3fa2016-02-18 12:19:13 +000036 this.availableByDefault = availableByDefault;
37 this.isFallback = isFallback;
Gustav Sennton74473592017-11-20 20:14:17 +000038 if (signatures == null) {
39 this.signatures = new Signature[0];
40 } else {
41 this.signatures = new Signature[signatures.length];
42 for (int n = 0; n < signatures.length; n++) {
43 this.signatures[n] = new Signature(Base64.decode(signatures[n], Base64.DEFAULT));
44 }
45 }
Gustav Sennton6258dcd2015-10-30 19:25:37 +000046 }
47
Gustav Sennton6258dcd2015-10-30 19:25:37 +000048 // aidl stuff
49 public static final Parcelable.Creator<WebViewProviderInfo> CREATOR =
50 new Parcelable.Creator<WebViewProviderInfo>() {
51 public WebViewProviderInfo createFromParcel(Parcel in) {
52 return new WebViewProviderInfo(in);
53 }
54
55 public WebViewProviderInfo[] newArray(int size) {
56 return new WebViewProviderInfo[size];
57 }
58 };
59
Mathew Inwood62d83fb2018-08-16 19:09:48 +010060 @UnsupportedAppUsage
Gustav Sennton6258dcd2015-10-30 19:25:37 +000061 private WebViewProviderInfo(Parcel in) {
62 packageName = in.readString();
63 description = in.readString();
Gustav Sennton8b179262016-03-14 11:31:14 +000064 availableByDefault = (in.readInt() > 0);
65 isFallback = (in.readInt() > 0);
Gustav Sennton74473592017-11-20 20:14:17 +000066 signatures = in.createTypedArray(Signature.CREATOR);
Gustav Sennton6258dcd2015-10-30 19:25:37 +000067 }
68
69 @Override
70 public int describeContents() {
71 return 0;
72 }
73
74 @Override
75 public void writeToParcel(Parcel out, int flags) {
76 out.writeString(packageName);
77 out.writeString(description);
Gustav Sennton8b179262016-03-14 11:31:14 +000078 out.writeInt(availableByDefault ? 1 : 0);
79 out.writeInt(isFallback ? 1 : 0);
Gustav Sennton74473592017-11-20 20:14:17 +000080 out.writeTypedArray(signatures, 0);
Gustav Sennton6258dcd2015-10-30 19:25:37 +000081 }
82
83 // fields read from framework resource
Gustav Senntondbf5eb02016-03-30 14:53:03 +010084 public final String packageName;
85 public final String description;
86 public final boolean availableByDefault;
87 public final boolean isFallback;
Gustav Sennton74473592017-11-20 20:14:17 +000088 public final Signature[] signatures;
Jeff Sharkeyc5967e92016-01-07 18:50:29 -070089}