summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--api/current.txt6
-rw-r--r--core/java/android/content/pm/PackageInstaller.java43
-rw-r--r--services/core/java/com/android/server/pm/PackageInstallerSession.java6
-rw-r--r--services/core/java/com/android/server/pm/PackageManagerShellCommand.java6
-rw-r--r--services/core/java/com/android/server/rollback/RollbackManagerServiceImpl.java8
-rw-r--r--services/core/java/com/android/server/rollback/RollbackPackageHealthObserver.java4
-rw-r--r--tests/RollbackTest/RollbackTest/src/com/android/tests/rollback/RollbackTestUtils.java6
7 files changed, 45 insertions, 34 deletions
diff --git a/api/current.txt b/api/current.txt
index 7e0156ff0bda..46d1f910e1f9 100644
--- a/api/current.txt
+++ b/api/current.txt
@@ -11457,10 +11457,10 @@ package android.content.pm {
method public boolean isActive();
method public boolean isMultiPackage();
method public boolean isSealed();
- method public boolean isSessionApplied();
- method public boolean isSessionFailed();
- method public boolean isSessionReady();
method public boolean isStaged();
+ method public boolean isStagedSessionApplied();
+ method public boolean isStagedSessionFailed();
+ method public boolean isStagedSessionReady();
method public void writeToParcel(android.os.Parcel, int);
field public static final android.os.Parcelable.Creator<android.content.pm.PackageInstaller.SessionInfo> CREATOR;
field public static final int INVALID_ID = -1; // 0xffffffff
diff --git a/core/java/android/content/pm/PackageInstaller.java b/core/java/android/content/pm/PackageInstaller.java
index 63020712acce..0304f19cc5b4 100644
--- a/core/java/android/content/pm/PackageInstaller.java
+++ b/core/java/android/content/pm/PackageInstaller.java
@@ -1743,11 +1743,11 @@ public class PackageInstaller {
public int[] childSessionIds = NO_SESSIONS;
/** {@hide} */
- public boolean isSessionApplied;
+ public boolean isStagedSessionApplied;
/** {@hide} */
- public boolean isSessionReady;
+ public boolean isStagedSessionReady;
/** {@hide} */
- public boolean isSessionFailed;
+ public boolean isStagedSessionFailed;
private int mStagedSessionErrorCode;
private String mStagedSessionErrorMessage;
@@ -1786,9 +1786,9 @@ public class PackageInstaller {
if (childSessionIds == null) {
childSessionIds = NO_SESSIONS;
}
- isSessionApplied = source.readBoolean();
- isSessionReady = source.readBoolean();
- isSessionFailed = source.readBoolean();
+ isStagedSessionApplied = source.readBoolean();
+ isStagedSessionReady = source.readBoolean();
+ isStagedSessionFailed = source.readBoolean();
mStagedSessionErrorCode = source.readInt();
mStagedSessionErrorMessage = source.readString();
}
@@ -2082,36 +2082,46 @@ public class PackageInstaller {
return childSessionIds;
}
+ private void checkSessionIsStaged() {
+ if (!isStaged) {
+ throw new IllegalStateException("Session is not marked as staged.");
+ }
+ }
+
/**
* Whether the staged session has been applied successfully, meaning that all of its
* packages have been activated and no further action is required.
* Only meaningful if {@code isStaged} is true.
*/
- public boolean isSessionApplied() {
- return isSessionApplied;
+ public boolean isStagedSessionApplied() {
+ checkSessionIsStaged();
+ return isStagedSessionApplied;
}
/**
* Whether the staged session is ready to be applied at next reboot. Only meaningful if
* {@code isStaged} is true.
*/
- public boolean isSessionReady() {
- return isSessionReady;
+ public boolean isStagedSessionReady() {
+ checkSessionIsStaged();
+ return isStagedSessionReady;
}
/**
* Whether something went wrong and the staged session is declared as failed, meaning that
* it will be ignored at next reboot. Only meaningful if {@code isStaged} is true.
*/
- public boolean isSessionFailed() {
- return isSessionFailed;
+ public boolean isStagedSessionFailed() {
+ checkSessionIsStaged();
+ return isStagedSessionFailed;
}
/**
* If something went wrong with a staged session, clients can check this error code to
* understand which kind of failure happened. Only meaningful if {@code isStaged} is true.
*/
- public int getStagedSessionErrorCode() {
+ public @StagedSessionErrorCode int getStagedSessionErrorCode() {
+ checkSessionIsStaged();
return mStagedSessionErrorCode;
}
@@ -2120,6 +2130,7 @@ public class PackageInstaller {
* empty string if no error was encountered.
*/
public String getStagedSessionErrorMessage() {
+ checkSessionIsStaged();
return mStagedSessionErrorMessage;
}
@@ -2162,9 +2173,9 @@ public class PackageInstaller {
dest.writeBoolean(isStaged);
dest.writeInt(parentSessionId);
dest.writeIntArray(childSessionIds);
- dest.writeBoolean(isSessionApplied);
- dest.writeBoolean(isSessionReady);
- dest.writeBoolean(isSessionFailed);
+ dest.writeBoolean(isStagedSessionApplied);
+ dest.writeBoolean(isStagedSessionReady);
+ dest.writeBoolean(isStagedSessionFailed);
dest.writeInt(mStagedSessionErrorCode);
dest.writeString(mStagedSessionErrorMessage);
}
diff --git a/services/core/java/com/android/server/pm/PackageInstallerSession.java b/services/core/java/com/android/server/pm/PackageInstallerSession.java
index be2b985145ce..675a8c08839d 100644
--- a/services/core/java/com/android/server/pm/PackageInstallerSession.java
+++ b/services/core/java/com/android/server/pm/PackageInstallerSession.java
@@ -490,9 +490,9 @@ public class PackageInstallerSession extends IPackageInstallerSession.Stub {
if (info.childSessionIds == null) {
info.childSessionIds = EMPTY_CHILD_SESSION_ARRAY;
}
- info.isSessionApplied = mStagedSessionApplied;
- info.isSessionReady = mStagedSessionReady;
- info.isSessionFailed = mStagedSessionFailed;
+ info.isStagedSessionApplied = mStagedSessionApplied;
+ info.isStagedSessionReady = mStagedSessionReady;
+ info.isStagedSessionFailed = mStagedSessionFailed;
info.setStagedSessionErrorCode(mStagedSessionErrorCode, mStagedSessionErrorMessage);
}
return info;
diff --git a/services/core/java/com/android/server/pm/PackageManagerShellCommand.java b/services/core/java/com/android/server/pm/PackageManagerShellCommand.java
index 52169676dab1..114810d9127b 100644
--- a/services/core/java/com/android/server/pm/PackageManagerShellCommand.java
+++ b/services/core/java/com/android/server/pm/PackageManagerShellCommand.java
@@ -300,9 +300,9 @@ class PackageManagerShellCommand extends ShellCommand {
pw.println("appPackageName = " + session.getAppPackageName()
+ "; sessionId = " + session.getSessionId()
+ "; isStaged = " + session.isStaged()
- + "; isSessionReady = " + session.isSessionReady()
- + "; isSessionApplied = " + session.isSessionApplied()
- + "; isSessionFailed = " + session.isSessionFailed() + ";");
+ + "; isStagedSessionReady = " + session.isStagedSessionReady()
+ + "; isStagedSessionApplied = " + session.isStagedSessionApplied()
+ + "; isStagedSessionFailed = " + session.isStagedSessionFailed() + ";");
}
} catch (RemoteException e) {
pw.println("Failure ["
diff --git a/services/core/java/com/android/server/rollback/RollbackManagerServiceImpl.java b/services/core/java/com/android/server/rollback/RollbackManagerServiceImpl.java
index 11839a52d939..d2c0ee3f5196 100644
--- a/services/core/java/com/android/server/rollback/RollbackManagerServiceImpl.java
+++ b/services/core/java/com/android/server/rollback/RollbackManagerServiceImpl.java
@@ -528,7 +528,7 @@ class RollbackManagerServiceImpl extends IRollbackManager.Stub {
PackageInstaller.SessionInfo session = installer.getSessionInfo(
data.stagedSessionId);
if (session != null) {
- if (session.isSessionApplied()) {
+ if (session.isStagedSessionApplied()) {
synchronized (mLock) {
data.isAvailable = true;
}
@@ -538,7 +538,7 @@ class RollbackManagerServiceImpl extends IRollbackManager.Stub {
Log.e(TAG, "Unable to save rollback info for : "
+ data.rollbackId, ioe);
}
- } else if (session.isSessionFailed()) {
+ } else if (session.isStagedSessionFailed()) {
// TODO: Do we need to remove this from
// mAvailableRollbacks, or is it okay to leave as
// unavailable until the next reboot when it will go
@@ -1195,13 +1195,13 @@ class RollbackManagerServiceImpl extends IRollbackManager.Stub {
}
if (pi.isStaged()) {
- if (!pi.isSessionFailed()) {
+ if (!pi.isStagedSessionFailed()) {
// TODO: The session really isn't "enabled" at this point, since more work might
// be required post reboot.
// TODO: We need to make this case consistent with the call from onFinished.
// Ideally, we'd call completeEnableRollback excatly once per multi-package session
// with the parentSessionId only.
- completeEnableRollback(pi.sessionId, pi.isSessionReady());
+ completeEnableRollback(pi.sessionId, pi.isStagedSessionReady());
} else {
// TODO: Clean up the saved rollback when the session fails. This may need to be
// unified with the case where things fail post reboot.
diff --git a/services/core/java/com/android/server/rollback/RollbackPackageHealthObserver.java b/services/core/java/com/android/server/rollback/RollbackPackageHealthObserver.java
index 3a2b69f8a6e1..d24f21781b39 100644
--- a/services/core/java/com/android/server/rollback/RollbackPackageHealthObserver.java
+++ b/services/core/java/com/android/server/rollback/RollbackPackageHealthObserver.java
@@ -218,10 +218,10 @@ public final class RollbackPackageHealthObserver implements PackageHealthObserve
&& (sessionId != PackageInstaller.SessionInfo.INVALID_ID)) {
PackageInstaller.SessionInfo sessionInfo =
packageInstaller.getSessionInfo(sessionId);
- if (sessionInfo.isSessionReady()) {
+ if (sessionInfo.isStagedSessionReady()) {
mContext.unregisterReceiver(listener);
mContext.getSystemService(PowerManager.class).reboot("Rollback staged install");
- } else if (sessionInfo.isSessionFailed()) {
+ } else if (sessionInfo.isStagedSessionFailed()) {
mContext.unregisterReceiver(listener);
}
}
diff --git a/tests/RollbackTest/RollbackTest/src/com/android/tests/rollback/RollbackTestUtils.java b/tests/RollbackTest/RollbackTest/src/com/android/tests/rollback/RollbackTestUtils.java
index 097d33d729f3..def5b8ead283 100644
--- a/tests/RollbackTest/RollbackTest/src/com/android/tests/rollback/RollbackTestUtils.java
+++ b/tests/RollbackTest/RollbackTest/src/com/android/tests/rollback/RollbackTestUtils.java
@@ -345,7 +345,7 @@ class RollbackTestUtils {
PackageInstaller.SessionInfo info =
intent.getParcelableExtra(PackageInstaller.EXTRA_SESSION);
if (info != null && info.getSessionId() == sessionId) {
- if (info.isSessionReady() || info.isSessionFailed()) {
+ if (info.isStagedSessionReady() || info.isStagedSessionFailed()) {
try {
sessionStatus.put(info);
} catch (InterruptedException e) {
@@ -365,13 +365,13 @@ class RollbackTestUtils {
PackageInstaller.SessionInfo info = installer.getSessionInfo(sessionId);
try {
- if (info.isSessionReady() || info.isSessionFailed()) {
+ if (info.isStagedSessionReady() || info.isStagedSessionFailed()) {
sessionStatus.put(info);
}
info = sessionStatus.take();
context.unregisterReceiver(sessionUpdatedReceiver);
- if (info.isSessionFailed()) {
+ if (info.isStagedSessionFailed()) {
throw new AssertionError(info.getStagedSessionErrorMessage());
}
} catch (InterruptedException e) {