blob: 0803a7c1d65199289539575f65ae0720679fb1e7 [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
23/**
24 * Information about a set of packages that can be, or already have been
25 * rolled back together.
26 *
Richard Uhlerc739c8c2018-12-12 11:03:34 +000027 * @hide
Richard Uhlerb29f1452018-09-12 16:38:15 +010028 */
Richard Uhlerc739c8c2018-12-12 11:03:34 +000029@SystemApi
Richard Uhlerb29f1452018-09-12 16:38:15 +010030public final class RollbackInfo implements Parcelable {
31
32 /**
Richard Uhlerb9d54472019-01-22 12:50:08 +000033 * A unique identifier for the rollback.
34 */
35 private final int mRollbackId;
36
37 /**
Richard Uhlerb29f1452018-09-12 16:38:15 +010038 * The package that needs to be rolled back.
39 */
40 public final PackageRollbackInfo targetPackage;
41
42 // TODO: Add a list of additional packages rolled back due to atomic
43 // install dependencies when rollback of atomic installs is supported.
44 // TODO: Add a flag to indicate if reboot is required, when rollback of
45 // staged installs is supported.
46
Richard Uhlerc739c8c2018-12-12 11:03:34 +000047 /** @hide */
Richard Uhlerb9d54472019-01-22 12:50:08 +000048 public RollbackInfo(int rollbackId, PackageRollbackInfo targetPackage) {
49 this.mRollbackId = rollbackId;
Richard Uhlerb29f1452018-09-12 16:38:15 +010050 this.targetPackage = targetPackage;
51 }
52
53 private RollbackInfo(Parcel in) {
Richard Uhlerb9d54472019-01-22 12:50:08 +000054 mRollbackId = in.readInt();
55 targetPackage = PackageRollbackInfo.CREATOR.createFromParcel(in);
56 }
57
58 /**
59 * Returns a unique identifier for this rollback.
60 */
61 public int getRollbackId() {
62 return mRollbackId;
Richard Uhlerb29f1452018-09-12 16:38:15 +010063 }
64
65 @Override
66 public int describeContents() {
67 return 0;
68 }
69
70 @Override
71 public void writeToParcel(Parcel out, int flags) {
Richard Uhlerb9d54472019-01-22 12:50:08 +000072 out.writeInt(mRollbackId);
Richard Uhlerb29f1452018-09-12 16:38:15 +010073 targetPackage.writeToParcel(out, flags);
74 }
75
76 public static final Parcelable.Creator<RollbackInfo> CREATOR =
77 new Parcelable.Creator<RollbackInfo>() {
78 public RollbackInfo createFromParcel(Parcel in) {
79 return new RollbackInfo(in);
80 }
81
82 public RollbackInfo[] newArray(int size) {
83 return new RollbackInfo[size];
84 }
85 };
86}