Richard Uhler | b29f145 | 2018-09-12 16:38:15 +0100 | [diff] [blame] | 1 | /* |
| 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 | |
| 17 | package android.content.rollback; |
| 18 | |
Richard Uhler | c739c8c | 2018-12-12 11:03:34 +0000 | [diff] [blame] | 19 | import android.annotation.SystemApi; |
Richard Uhler | b29f145 | 2018-09-12 16:38:15 +0100 | [diff] [blame] | 20 | import android.os.Parcel; |
| 21 | import android.os.Parcelable; |
| 22 | |
Richard Uhler | 0a79b32 | 2019-01-23 13:51:07 +0000 | [diff] [blame^] | 23 | import java.util.List; |
| 24 | |
Richard Uhler | b29f145 | 2018-09-12 16:38:15 +0100 | [diff] [blame] | 25 | /** |
| 26 | * Information about a set of packages that can be, or already have been |
| 27 | * rolled back together. |
| 28 | * |
Richard Uhler | c739c8c | 2018-12-12 11:03:34 +0000 | [diff] [blame] | 29 | * @hide |
Richard Uhler | b29f145 | 2018-09-12 16:38:15 +0100 | [diff] [blame] | 30 | */ |
Richard Uhler | c739c8c | 2018-12-12 11:03:34 +0000 | [diff] [blame] | 31 | @SystemApi |
Richard Uhler | b29f145 | 2018-09-12 16:38:15 +0100 | [diff] [blame] | 32 | public final class RollbackInfo implements Parcelable { |
| 33 | |
| 34 | /** |
Richard Uhler | b9d5447 | 2019-01-22 12:50:08 +0000 | [diff] [blame] | 35 | * A unique identifier for the rollback. |
| 36 | */ |
| 37 | private final int mRollbackId; |
| 38 | |
Richard Uhler | 0a79b32 | 2019-01-23 13:51:07 +0000 | [diff] [blame^] | 39 | private final List<PackageRollbackInfo> mPackages; |
Richard Uhler | b29f145 | 2018-09-12 16:38:15 +0100 | [diff] [blame] | 40 | |
Richard Uhler | b29f145 | 2018-09-12 16:38:15 +0100 | [diff] [blame] | 41 | // TODO: Add a flag to indicate if reboot is required, when rollback of |
| 42 | // staged installs is supported. |
| 43 | |
Richard Uhler | c739c8c | 2018-12-12 11:03:34 +0000 | [diff] [blame] | 44 | /** @hide */ |
Richard Uhler | 0a79b32 | 2019-01-23 13:51:07 +0000 | [diff] [blame^] | 45 | public RollbackInfo(int rollbackId, List<PackageRollbackInfo> packages) { |
Richard Uhler | b9d5447 | 2019-01-22 12:50:08 +0000 | [diff] [blame] | 46 | this.mRollbackId = rollbackId; |
Richard Uhler | 0a79b32 | 2019-01-23 13:51:07 +0000 | [diff] [blame^] | 47 | this.mPackages = packages; |
Richard Uhler | b29f145 | 2018-09-12 16:38:15 +0100 | [diff] [blame] | 48 | } |
| 49 | |
| 50 | private RollbackInfo(Parcel in) { |
Richard Uhler | b9d5447 | 2019-01-22 12:50:08 +0000 | [diff] [blame] | 51 | mRollbackId = in.readInt(); |
Richard Uhler | 0a79b32 | 2019-01-23 13:51:07 +0000 | [diff] [blame^] | 52 | mPackages = in.createTypedArrayList(PackageRollbackInfo.CREATOR); |
Richard Uhler | b9d5447 | 2019-01-22 12:50:08 +0000 | [diff] [blame] | 53 | } |
| 54 | |
| 55 | /** |
| 56 | * Returns a unique identifier for this rollback. |
| 57 | */ |
| 58 | public int getRollbackId() { |
| 59 | return mRollbackId; |
Richard Uhler | b29f145 | 2018-09-12 16:38:15 +0100 | [diff] [blame] | 60 | } |
| 61 | |
Richard Uhler | 0a79b32 | 2019-01-23 13:51:07 +0000 | [diff] [blame^] | 62 | /** |
| 63 | * Returns the list of package that are rolled back. |
| 64 | */ |
| 65 | public List<PackageRollbackInfo> getPackages() { |
| 66 | return mPackages; |
| 67 | } |
| 68 | |
Richard Uhler | b29f145 | 2018-09-12 16:38:15 +0100 | [diff] [blame] | 69 | @Override |
| 70 | public int describeContents() { |
| 71 | return 0; |
| 72 | } |
| 73 | |
| 74 | @Override |
| 75 | public void writeToParcel(Parcel out, int flags) { |
Richard Uhler | b9d5447 | 2019-01-22 12:50:08 +0000 | [diff] [blame] | 76 | out.writeInt(mRollbackId); |
Richard Uhler | 0a79b32 | 2019-01-23 13:51:07 +0000 | [diff] [blame^] | 77 | out.writeTypedList(mPackages); |
Richard Uhler | b29f145 | 2018-09-12 16:38:15 +0100 | [diff] [blame] | 78 | } |
| 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 | } |