blob: 8532b5a4844e5b4cc7dd15c9ce63776f2dfba726 [file] [log] [blame]
Richard Uhlerb29f1452018-09-12 16:38:15 +01001/*
2 * Copyright (C) 2018 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.rollback;
18
Richard Uhlerc739c8c2018-12-12 11:03:34 +000019import android.annotation.SystemApi;
Richard Uhlerb29f1452018-09-12 16:38:15 +010020import android.os.Parcel;
21import android.os.Parcelable;
22
Richard Uhler0a79b322019-01-23 13:51:07 +000023import java.util.List;
24
Richard Uhlerb29f1452018-09-12 16:38:15 +010025/**
26 * Information about a set of packages that can be, or already have been
27 * rolled back together.
28 *
Richard Uhlerc739c8c2018-12-12 11:03:34 +000029 * @hide
Richard Uhlerb29f1452018-09-12 16:38:15 +010030 */
Richard Uhlerc739c8c2018-12-12 11:03:34 +000031@SystemApi
Richard Uhlerb29f1452018-09-12 16:38:15 +010032public final class RollbackInfo implements Parcelable {
33
34 /**
Richard Uhlerb9d54472019-01-22 12:50:08 +000035 * A unique identifier for the rollback.
36 */
37 private final int mRollbackId;
38
Richard Uhler0a79b322019-01-23 13:51:07 +000039 private final List<PackageRollbackInfo> mPackages;
Richard Uhlerb29f1452018-09-12 16:38:15 +010040
Richard Uhlerb29f1452018-09-12 16:38:15 +010041 // TODO: Add a flag to indicate if reboot is required, when rollback of
42 // staged installs is supported.
43
Richard Uhlerc739c8c2018-12-12 11:03:34 +000044 /** @hide */
Richard Uhler0a79b322019-01-23 13:51:07 +000045 public RollbackInfo(int rollbackId, List<PackageRollbackInfo> packages) {
Richard Uhlerb9d54472019-01-22 12:50:08 +000046 this.mRollbackId = rollbackId;
Richard Uhler0a79b322019-01-23 13:51:07 +000047 this.mPackages = packages;
Richard Uhlerb29f1452018-09-12 16:38:15 +010048 }
49
50 private RollbackInfo(Parcel in) {
Richard Uhlerb9d54472019-01-22 12:50:08 +000051 mRollbackId = in.readInt();
Richard Uhler0a79b322019-01-23 13:51:07 +000052 mPackages = in.createTypedArrayList(PackageRollbackInfo.CREATOR);
Richard Uhlerb9d54472019-01-22 12:50:08 +000053 }
54
55 /**
56 * Returns a unique identifier for this rollback.
57 */
58 public int getRollbackId() {
59 return mRollbackId;
Richard Uhlerb29f1452018-09-12 16:38:15 +010060 }
61
Richard Uhler0a79b322019-01-23 13:51:07 +000062 /**
63 * Returns the list of package that are rolled back.
64 */
65 public List<PackageRollbackInfo> getPackages() {
66 return mPackages;
67 }
68
Richard Uhlerb29f1452018-09-12 16:38:15 +010069 @Override
70 public int describeContents() {
71 return 0;
72 }
73
74 @Override
75 public void writeToParcel(Parcel out, int flags) {
Richard Uhlerb9d54472019-01-22 12:50:08 +000076 out.writeInt(mRollbackId);
Richard Uhler0a79b322019-01-23 13:51:07 +000077 out.writeTypedList(mPackages);
Richard Uhlerb29f1452018-09-12 16:38:15 +010078 }
79
80 public static final Parcelable.Creator<RollbackInfo> CREATOR =
81 new Parcelable.Creator<RollbackInfo>() {
82 public RollbackInfo createFromParcel(Parcel in) {
83 return new RollbackInfo(in);
84 }
85
86 public RollbackInfo[] newArray(int size) {
87 return new RollbackInfo[size];
88 }
89 };
90}