blob: fcd5297f13632b92217f827f3dfbcc25e2dda9e4 [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 com.android.server.rollback;
18
19import android.content.rollback.PackageRollbackInfo;
20
21import java.io.File;
22import java.time.Instant;
Richard Uhler01b06152019-01-09 13:51:54 +000023import java.util.ArrayList;
24import java.util.List;
Richard Uhlerb29f1452018-09-12 16:38:15 +010025
26/**
Richard Uhler01b06152019-01-09 13:51:54 +000027 * Information about a rollback available for a set of atomically installed
28 * packages.
Richard Uhlerb29f1452018-09-12 16:38:15 +010029 */
Richard Uhler32f63a72019-01-09 10:43:52 +000030class RollbackData {
Richard Uhler01b06152019-01-09 13:51:54 +000031 /**
Richard Uhlerb9d54472019-01-22 12:50:08 +000032 * A unique identifier for this rollback.
33 */
34 public final int rollbackId;
35
36 /**
Richard Uhler01b06152019-01-09 13:51:54 +000037 * The per-package rollback information.
38 */
39 public final List<PackageRollbackInfo> packages = new ArrayList<>();
Richard Uhlerb29f1452018-09-12 16:38:15 +010040
41 /**
Richard Uhlerc0e57422019-01-09 11:25:56 +000042 * The directory where the rollback data is stored.
Richard Uhlerb29f1452018-09-12 16:38:15 +010043 */
44 public final File backupDir;
45
46 /**
47 * The time when the upgrade occurred, for purposes of expiring
48 * rollback data.
49 */
Richard Uhler2d7c7f0d2019-01-04 09:18:21 +000050 public Instant timestamp;
Richard Uhlerb29f1452018-09-12 16:38:15 +010051
Narayan Kamathbc36f8d2019-01-23 12:00:08 +000052 /**
Narayan Kamathfcd4a042019-02-01 14:16:37 +000053 * The session ID for the staged session if this rollback data represents a staged session,
54 * {@code -1} otherwise.
55 */
56 public int stagedSessionId;
57
58 /**
Richard Uhler60ac7062019-02-05 13:25:39 +000059 * A flag to indicate whether the rollback should be considered available
60 * for use. This will always be true for rollbacks of non-staged sessions.
61 * For rollbacks of staged sessions, this is not set to true until after
62 * the staged session has been applied.
63 */
64 public boolean isAvailable;
65
66 /**
Richard Uhlerba13ab22019-02-05 15:27:12 +000067 * The id of the post-reboot apk session for a staged install, if any.
68 */
69 public int apkSessionId = -1;
70
71 /**
Narayan Kamathbc36f8d2019-01-23 12:00:08 +000072 * Whether this Rollback is currently in progress. This field is true from the point
73 * we commit a {@code PackageInstaller} session containing these packages to the point the
74 * {@code PackageInstaller} calls into the {@code onFinished} callback.
75 */
76 // NOTE: All accesses to this field are from the RollbackManager handler thread.
77 public boolean inProgress = false;
78
Richard Uhler60ac7062019-02-05 13:25:39 +000079 RollbackData(int rollbackId, File backupDir, int stagedSessionId, boolean isAvailable) {
Richard Uhlerb9d54472019-01-22 12:50:08 +000080 this.rollbackId = rollbackId;
Richard Uhlerb29f1452018-09-12 16:38:15 +010081 this.backupDir = backupDir;
Narayan Kamathfcd4a042019-02-01 14:16:37 +000082 this.stagedSessionId = stagedSessionId;
Richard Uhler60ac7062019-02-05 13:25:39 +000083 this.isAvailable = isAvailable;
Richard Uhlerb29f1452018-09-12 16:38:15 +010084 }
Richard Uhler72fb9612019-02-04 14:37:36 +000085
86 /**
87 * Whether the rollback is for rollback of a staged install.
88 */
89 public boolean isStaged() {
90 return stagedSessionId != -1;
91 }
Richard Uhlerb29f1452018-09-12 16:38:15 +010092}