Gustav Sennton | 6258dcd | 2015-10-30 19:25:37 +0000 | [diff] [blame] | 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 | |
Gustav Sennton | 1c177d8 | 2016-03-29 20:43:11 +0100 | [diff] [blame] | 19 | import android.annotation.SystemApi; |
Mathew Inwood | 62d83fb | 2018-08-16 19:09:48 +0100 | [diff] [blame] | 20 | import android.annotation.UnsupportedAppUsage; |
Gustav Sennton | 7447359 | 2017-11-20 20:14:17 +0000 | [diff] [blame] | 21 | import android.content.pm.Signature; |
Gustav Sennton | 6258dcd | 2015-10-30 19:25:37 +0000 | [diff] [blame] | 22 | import android.os.Parcel; |
| 23 | import android.os.Parcelable; |
Gustav Sennton | 7447359 | 2017-11-20 20:14:17 +0000 | [diff] [blame] | 24 | import android.util.Base64; |
Gustav Sennton | 6258dcd | 2015-10-30 19:25:37 +0000 | [diff] [blame] | 25 | |
Gustav Sennton | 1c177d8 | 2016-03-29 20:43:11 +0100 | [diff] [blame] | 26 | /** |
| 27 | * @hide |
| 28 | */ |
| 29 | @SystemApi |
Gustav Sennton | dbf5eb0 | 2016-03-30 14:53:03 +0100 | [diff] [blame] | 30 | public final class WebViewProviderInfo implements Parcelable { |
Gustav Sennton | 6258dcd | 2015-10-30 19:25:37 +0000 | [diff] [blame] | 31 | |
Gustav Sennton | dbf5eb0 | 2016-03-30 14:53:03 +0100 | [diff] [blame] | 32 | public WebViewProviderInfo(String packageName, String description, |
| 33 | boolean availableByDefault, boolean isFallback, String[] signatures) { |
Gustav Sennton | 6258dcd | 2015-10-30 19:25:37 +0000 | [diff] [blame] | 34 | this.packageName = packageName; |
| 35 | this.description = description; |
Gustav Sennton | c83e3fa | 2016-02-18 12:19:13 +0000 | [diff] [blame] | 36 | this.availableByDefault = availableByDefault; |
| 37 | this.isFallback = isFallback; |
Gustav Sennton | 7447359 | 2017-11-20 20:14:17 +0000 | [diff] [blame] | 38 | 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 Sennton | 6258dcd | 2015-10-30 19:25:37 +0000 | [diff] [blame] | 46 | } |
| 47 | |
Gustav Sennton | 6258dcd | 2015-10-30 19:25:37 +0000 | [diff] [blame] | 48 | // 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 Inwood | 62d83fb | 2018-08-16 19:09:48 +0100 | [diff] [blame] | 60 | @UnsupportedAppUsage |
Gustav Sennton | 6258dcd | 2015-10-30 19:25:37 +0000 | [diff] [blame] | 61 | private WebViewProviderInfo(Parcel in) { |
| 62 | packageName = in.readString(); |
| 63 | description = in.readString(); |
Gustav Sennton | 8b17926 | 2016-03-14 11:31:14 +0000 | [diff] [blame] | 64 | availableByDefault = (in.readInt() > 0); |
| 65 | isFallback = (in.readInt() > 0); |
Gustav Sennton | 7447359 | 2017-11-20 20:14:17 +0000 | [diff] [blame] | 66 | signatures = in.createTypedArray(Signature.CREATOR); |
Gustav Sennton | 6258dcd | 2015-10-30 19:25:37 +0000 | [diff] [blame] | 67 | } |
| 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 Sennton | 8b17926 | 2016-03-14 11:31:14 +0000 | [diff] [blame] | 78 | out.writeInt(availableByDefault ? 1 : 0); |
| 79 | out.writeInt(isFallback ? 1 : 0); |
Gustav Sennton | 7447359 | 2017-11-20 20:14:17 +0000 | [diff] [blame] | 80 | out.writeTypedArray(signatures, 0); |
Gustav Sennton | 6258dcd | 2015-10-30 19:25:37 +0000 | [diff] [blame] | 81 | } |
| 82 | |
| 83 | // fields read from framework resource |
Gustav Sennton | dbf5eb0 | 2016-03-30 14:53:03 +0100 | [diff] [blame] | 84 | public final String packageName; |
| 85 | public final String description; |
| 86 | public final boolean availableByDefault; |
| 87 | public final boolean isFallback; |
Gustav Sennton | 7447359 | 2017-11-20 20:14:17 +0000 | [diff] [blame] | 88 | public final Signature[] signatures; |
Jeff Sharkey | c5967e9 | 2016-01-07 18:50:29 -0700 | [diff] [blame] | 89 | } |