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 | |
| 23 | /** |
| 24 | * Information about a set of packages that can be, or already have been |
| 25 | * rolled back together. |
| 26 | * |
Richard Uhler | c739c8c | 2018-12-12 11:03:34 +0000 | [diff] [blame] | 27 | * @hide |
Richard Uhler | b29f145 | 2018-09-12 16:38:15 +0100 | [diff] [blame] | 28 | */ |
Richard Uhler | c739c8c | 2018-12-12 11:03:34 +0000 | [diff] [blame] | 29 | @SystemApi |
Richard Uhler | b29f145 | 2018-09-12 16:38:15 +0100 | [diff] [blame] | 30 | public final class RollbackInfo implements Parcelable { |
| 31 | |
| 32 | /** |
Richard Uhler | b9d5447 | 2019-01-22 12:50:08 +0000 | [diff] [blame^] | 33 | * A unique identifier for the rollback. |
| 34 | */ |
| 35 | private final int mRollbackId; |
| 36 | |
| 37 | /** |
Richard Uhler | b29f145 | 2018-09-12 16:38:15 +0100 | [diff] [blame] | 38 | * 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 Uhler | c739c8c | 2018-12-12 11:03:34 +0000 | [diff] [blame] | 47 | /** @hide */ |
Richard Uhler | b9d5447 | 2019-01-22 12:50:08 +0000 | [diff] [blame^] | 48 | public RollbackInfo(int rollbackId, PackageRollbackInfo targetPackage) { |
| 49 | this.mRollbackId = rollbackId; |
Richard Uhler | b29f145 | 2018-09-12 16:38:15 +0100 | [diff] [blame] | 50 | this.targetPackage = targetPackage; |
| 51 | } |
| 52 | |
| 53 | private RollbackInfo(Parcel in) { |
Richard Uhler | b9d5447 | 2019-01-22 12:50:08 +0000 | [diff] [blame^] | 54 | 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 Uhler | b29f145 | 2018-09-12 16:38:15 +0100 | [diff] [blame] | 63 | } |
| 64 | |
| 65 | @Override |
| 66 | public int describeContents() { |
| 67 | return 0; |
| 68 | } |
| 69 | |
| 70 | @Override |
| 71 | public void writeToParcel(Parcel out, int flags) { |
Richard Uhler | b9d5447 | 2019-01-22 12:50:08 +0000 | [diff] [blame^] | 72 | out.writeInt(mRollbackId); |
Richard Uhler | b29f145 | 2018-09-12 16:38:15 +0100 | [diff] [blame] | 73 | 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 | } |