Kenny Root | 02c8730 | 2010-07-01 08:10:18 -0700 | [diff] [blame] | 1 | /* |
| 2 | * Copyright (C) 2010 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.content.res; |
| 18 | |
Mathew Inwood | 5c0d354 | 2018-08-14 13:54:31 +0100 | [diff] [blame] | 19 | import android.annotation.UnsupportedAppUsage; |
Kenny Root | 02c8730 | 2010-07-01 08:10:18 -0700 | [diff] [blame] | 20 | import android.os.Parcel; |
| 21 | import android.os.Parcelable; |
| 22 | |
| 23 | /** |
Kenny Root | 05105f7 | 2010-09-22 17:29:43 -0700 | [diff] [blame] | 24 | * Basic information about a Opaque Binary Blob (OBB) that reflects the info |
| 25 | * from the footer on the OBB file. This information may be manipulated by a |
| 26 | * developer with the <code>obbtool</code> program in the Android SDK. |
Kenny Root | 02c8730 | 2010-07-01 08:10:18 -0700 | [diff] [blame] | 27 | */ |
| 28 | public class ObbInfo implements Parcelable { |
Kenny Root | 02ca31f | 2010-08-12 07:36:02 -0700 | [diff] [blame] | 29 | /** Flag noting that this OBB is an overlay patch for a base OBB. */ |
| 30 | public static final int OBB_OVERLAY = 1 << 0; |
| 31 | |
Kenny Root | 02c8730 | 2010-07-01 08:10:18 -0700 | [diff] [blame] | 32 | /** |
Kenny Root | 38cf886 | 2010-09-26 14:18:51 -0700 | [diff] [blame] | 33 | * The canonical filename of the OBB. |
| 34 | */ |
| 35 | public String filename; |
| 36 | |
| 37 | /** |
Kenny Root | 02c8730 | 2010-07-01 08:10:18 -0700 | [diff] [blame] | 38 | * The name of the package to which the OBB file belongs. |
| 39 | */ |
| 40 | public String packageName; |
| 41 | |
| 42 | /** |
| 43 | * The version of the package to which the OBB file belongs. |
| 44 | */ |
| 45 | public int version; |
| 46 | |
Kenny Root | 02ca31f | 2010-08-12 07:36:02 -0700 | [diff] [blame] | 47 | /** |
| 48 | * The flags relating to the OBB. |
| 49 | */ |
| 50 | public int flags; |
| 51 | |
Kenny Root | 3b1abba | 2010-10-13 15:00:07 -0700 | [diff] [blame] | 52 | /** |
| 53 | * The salt for the encryption algorithm. |
| 54 | * |
| 55 | * @hide |
| 56 | */ |
Mathew Inwood | 5c0d354 | 2018-08-14 13:54:31 +0100 | [diff] [blame] | 57 | @UnsupportedAppUsage |
Kenny Root | 3b1abba | 2010-10-13 15:00:07 -0700 | [diff] [blame] | 58 | public byte[] salt; |
| 59 | |
Kenny Root | 05105f7 | 2010-09-22 17:29:43 -0700 | [diff] [blame] | 60 | // Only allow things in this package to instantiate. |
| 61 | /* package */ ObbInfo() { |
Kenny Root | 02c8730 | 2010-07-01 08:10:18 -0700 | [diff] [blame] | 62 | } |
| 63 | |
| 64 | public String toString() { |
Kenny Root | 02ca31f | 2010-08-12 07:36:02 -0700 | [diff] [blame] | 65 | StringBuilder sb = new StringBuilder(); |
| 66 | sb.append("ObbInfo{"); |
| 67 | sb.append(Integer.toHexString(System.identityHashCode(this))); |
| 68 | sb.append(" packageName="); |
| 69 | sb.append(packageName); |
| 70 | sb.append(",version="); |
| 71 | sb.append(version); |
| 72 | sb.append(",flags="); |
| 73 | sb.append(flags); |
| 74 | sb.append('}'); |
| 75 | return sb.toString(); |
Kenny Root | 02c8730 | 2010-07-01 08:10:18 -0700 | [diff] [blame] | 76 | } |
| 77 | |
| 78 | public int describeContents() { |
| 79 | return 0; |
| 80 | } |
| 81 | |
| 82 | public void writeToParcel(Parcel dest, int parcelableFlags) { |
Sudheer Shanka | 25469aa | 2018-08-27 15:50:23 -0700 | [diff] [blame] | 83 | // Keep this in sync with writeToParcel() in ObbInfo.cpp |
Kenny Root | 38cf886 | 2010-09-26 14:18:51 -0700 | [diff] [blame] | 84 | dest.writeString(filename); |
Kenny Root | 02c8730 | 2010-07-01 08:10:18 -0700 | [diff] [blame] | 85 | dest.writeString(packageName); |
| 86 | dest.writeInt(version); |
Kenny Root | 02ca31f | 2010-08-12 07:36:02 -0700 | [diff] [blame] | 87 | dest.writeInt(flags); |
Kenny Root | 3b1abba | 2010-10-13 15:00:07 -0700 | [diff] [blame] | 88 | dest.writeByteArray(salt); |
Kenny Root | 02c8730 | 2010-07-01 08:10:18 -0700 | [diff] [blame] | 89 | } |
| 90 | |
| 91 | public static final Parcelable.Creator<ObbInfo> CREATOR |
| 92 | = new Parcelable.Creator<ObbInfo>() { |
| 93 | public ObbInfo createFromParcel(Parcel source) { |
| 94 | return new ObbInfo(source); |
| 95 | } |
| 96 | |
| 97 | public ObbInfo[] newArray(int size) { |
| 98 | return new ObbInfo[size]; |
| 99 | } |
| 100 | }; |
| 101 | |
| 102 | private ObbInfo(Parcel source) { |
Kenny Root | 38cf886 | 2010-09-26 14:18:51 -0700 | [diff] [blame] | 103 | filename = source.readString(); |
Kenny Root | 02c8730 | 2010-07-01 08:10:18 -0700 | [diff] [blame] | 104 | packageName = source.readString(); |
| 105 | version = source.readInt(); |
Kenny Root | 02ca31f | 2010-08-12 07:36:02 -0700 | [diff] [blame] | 106 | flags = source.readInt(); |
Kenny Root | 3b1abba | 2010-10-13 15:00:07 -0700 | [diff] [blame] | 107 | salt = source.createByteArray(); |
Kenny Root | 02c8730 | 2010-07-01 08:10:18 -0700 | [diff] [blame] | 108 | } |
| 109 | } |