blob: 812f995675fce2dc6e4fc90b24ca9f10b0193404 [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 Uhlere4e38d62019-01-24 16:12:07 +000020import android.content.pm.PackageInstaller;
Richard Uhlerb29f1452018-09-12 16:38:15 +010021import android.os.Parcel;
22import android.os.Parcelable;
23
Richard Uhler0a79b322019-01-23 13:51:07 +000024import java.util.List;
25
Richard Uhlerb29f1452018-09-12 16:38:15 +010026/**
27 * Information about a set of packages that can be, or already have been
28 * rolled back together.
29 *
Richard Uhlerc739c8c2018-12-12 11:03:34 +000030 * @hide
Richard Uhlerb29f1452018-09-12 16:38:15 +010031 */
Richard Uhlerc739c8c2018-12-12 11:03:34 +000032@SystemApi
Richard Uhlerb29f1452018-09-12 16:38:15 +010033public final class RollbackInfo implements Parcelable {
34
35 /**
Richard Uhlerb9d54472019-01-22 12:50:08 +000036 * A unique identifier for the rollback.
37 */
38 private final int mRollbackId;
39
Richard Uhler0a79b322019-01-23 13:51:07 +000040 private final List<PackageRollbackInfo> mPackages;
Richard Uhlerb29f1452018-09-12 16:38:15 +010041
Richard Uhlerc739c8c2018-12-12 11:03:34 +000042 /** @hide */
Richard Uhler0a79b322019-01-23 13:51:07 +000043 public RollbackInfo(int rollbackId, List<PackageRollbackInfo> packages) {
Richard Uhlerb9d54472019-01-22 12:50:08 +000044 this.mRollbackId = rollbackId;
Richard Uhler0a79b322019-01-23 13:51:07 +000045 this.mPackages = packages;
Richard Uhlerb29f1452018-09-12 16:38:15 +010046 }
47
48 private RollbackInfo(Parcel in) {
Richard Uhlerb9d54472019-01-22 12:50:08 +000049 mRollbackId = in.readInt();
Richard Uhler0a79b322019-01-23 13:51:07 +000050 mPackages = in.createTypedArrayList(PackageRollbackInfo.CREATOR);
Richard Uhlerb9d54472019-01-22 12:50:08 +000051 }
52
53 /**
54 * Returns a unique identifier for this rollback.
55 */
56 public int getRollbackId() {
57 return mRollbackId;
Richard Uhlerb29f1452018-09-12 16:38:15 +010058 }
59
Richard Uhler0a79b322019-01-23 13:51:07 +000060 /**
61 * Returns the list of package that are rolled back.
62 */
63 public List<PackageRollbackInfo> getPackages() {
64 return mPackages;
65 }
66
Richard Uhlere4e38d62019-01-24 16:12:07 +000067 /**
68 * Returns true if this rollback requires reboot to take effect after
69 * being committed.
70 */
71 public boolean isStaged() {
72 // TODO: Support rollback of staged installs.
73 return false;
74 }
75
76 /**
77 * Returns the session ID for the committed rollback for staged rollbacks.
78 * Only applicable for rollbacks that have been committed.
79 */
80 public int getSessionId() {
81 // TODO: Support rollback of staged installs.
82 return PackageInstaller.SessionInfo.INVALID_ID;
83 }
84
Richard Uhlerb29f1452018-09-12 16:38:15 +010085 @Override
86 public int describeContents() {
87 return 0;
88 }
89
90 @Override
91 public void writeToParcel(Parcel out, int flags) {
Richard Uhlerb9d54472019-01-22 12:50:08 +000092 out.writeInt(mRollbackId);
Richard Uhler0a79b322019-01-23 13:51:07 +000093 out.writeTypedList(mPackages);
Richard Uhlerb29f1452018-09-12 16:38:15 +010094 }
95
96 public static final Parcelable.Creator<RollbackInfo> CREATOR =
97 new Parcelable.Creator<RollbackInfo>() {
98 public RollbackInfo createFromParcel(Parcel in) {
99 return new RollbackInfo(in);
100 }
101
102 public RollbackInfo[] newArray(int size) {
103 return new RollbackInfo[size];
104 }
105 };
106}