blob: 8af27ca825d0a67fcf0ddaf6f0a5f351c1907c84 [file] [log] [blame]
Kenny Root02c87302010-07-01 08:10:18 -07001/*
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
17package android.content.res;
18
Mathew Inwood5c0d3542018-08-14 13:54:31 +010019import android.annotation.UnsupportedAppUsage;
Kenny Root02c87302010-07-01 08:10:18 -070020import android.os.Parcel;
21import android.os.Parcelable;
22
23/**
Kenny Root05105f72010-09-22 17:29:43 -070024 * 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 Root02c87302010-07-01 08:10:18 -070027 */
28public class ObbInfo implements Parcelable {
Kenny Root02ca31f2010-08-12 07:36:02 -070029 /** Flag noting that this OBB is an overlay patch for a base OBB. */
30 public static final int OBB_OVERLAY = 1 << 0;
31
Kenny Root02c87302010-07-01 08:10:18 -070032 /**
Kenny Root38cf8862010-09-26 14:18:51 -070033 * The canonical filename of the OBB.
34 */
35 public String filename;
36
37 /**
Kenny Root02c87302010-07-01 08:10:18 -070038 * 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 Root02ca31f2010-08-12 07:36:02 -070047 /**
48 * The flags relating to the OBB.
49 */
50 public int flags;
51
Kenny Root3b1abba2010-10-13 15:00:07 -070052 /**
53 * The salt for the encryption algorithm.
54 *
55 * @hide
56 */
Mathew Inwood5c0d3542018-08-14 13:54:31 +010057 @UnsupportedAppUsage
Kenny Root3b1abba2010-10-13 15:00:07 -070058 public byte[] salt;
59
Kenny Root05105f72010-09-22 17:29:43 -070060 // Only allow things in this package to instantiate.
61 /* package */ ObbInfo() {
Kenny Root02c87302010-07-01 08:10:18 -070062 }
63
64 public String toString() {
Kenny Root02ca31f2010-08-12 07:36:02 -070065 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 Root02c87302010-07-01 08:10:18 -070076 }
77
78 public int describeContents() {
79 return 0;
80 }
81
82 public void writeToParcel(Parcel dest, int parcelableFlags) {
Sudheer Shanka25469aa2018-08-27 15:50:23 -070083 // Keep this in sync with writeToParcel() in ObbInfo.cpp
Kenny Root38cf8862010-09-26 14:18:51 -070084 dest.writeString(filename);
Kenny Root02c87302010-07-01 08:10:18 -070085 dest.writeString(packageName);
86 dest.writeInt(version);
Kenny Root02ca31f2010-08-12 07:36:02 -070087 dest.writeInt(flags);
Kenny Root3b1abba2010-10-13 15:00:07 -070088 dest.writeByteArray(salt);
Kenny Root02c87302010-07-01 08:10:18 -070089 }
90
Jeff Sharkey9e8f83d2019-02-28 12:06:45 -070091 public static final @android.annotation.NonNull Parcelable.Creator<ObbInfo> CREATOR
Kenny Root02c87302010-07-01 08:10:18 -070092 = 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 Root38cf8862010-09-26 14:18:51 -0700103 filename = source.readString();
Kenny Root02c87302010-07-01 08:10:18 -0700104 packageName = source.readString();
105 version = source.readInt();
Kenny Root02ca31f2010-08-12 07:36:02 -0700106 flags = source.readInt();
Kenny Root3b1abba2010-10-13 15:00:07 -0700107 salt = source.createByteArray();
Kenny Root02c87302010-07-01 08:10:18 -0700108 }
109}