From af8ff1c9a34307d78cf341334b2985eb5669be30 Mon Sep 17 00:00:00 2001 From: JW Wang Date: Tue, 21 Dec 2021 15:09:18 +0800 Subject: [PATCH] Rename STAGED_SESSION* error codes (2/n) Rename the error codes as they will be used by non-staged sessions as well. Bug: 210359798 Test: atest StagingManagerTest \ PackageInstallerSessionTest \ CtsStagedInstallHostTestCases Change-Id: Iec572d7a85f2615204ac069a42edb569ecadb294 --- core/api/current.txt | 15 +++-- .../android/content/pm/PackageInstaller.java | 60 ++++++++++++++----- .../com/android/server/pm/ApexManager.java | 4 +- .../server/pm/PackageInstallerService.java | 4 +- .../server/pm/PackageInstallerSession.java | 12 ++-- .../server/pm/PackageSessionVerifier.java | 30 +++++----- .../com/android/server/pm/StagingManager.java | 22 +++---- .../android/server/pm/StagingManagerTest.java | 26 ++++---- .../pm/PackageInstallerSessionTest.java | 2 +- 9 files changed, 105 insertions(+), 70 deletions(-) diff --git a/core/api/current.txt b/core/api/current.txt index 407855b107cdd..a20b9921063d7 100644 --- a/core/api/current.txt +++ b/core/api/current.txt @@ -12762,11 +12762,16 @@ package android.content.pm { method public void writeToParcel(android.os.Parcel, int); field public static final android.os.Parcelable.Creator CREATOR; field public static final int INVALID_ID = -1; // 0xffffffff - field public static final int STAGED_SESSION_ACTIVATION_FAILED = 2; // 0x2 - field public static final int STAGED_SESSION_CONFLICT = 4; // 0x4 - field public static final int STAGED_SESSION_NO_ERROR = 0; // 0x0 - field public static final int STAGED_SESSION_UNKNOWN = 3; // 0x3 - field public static final int STAGED_SESSION_VERIFICATION_FAILED = 1; // 0x1 + field public static final int SESSION_ACTIVATION_FAILED = 2; // 0x2 + field public static final int SESSION_CONFLICT = 4; // 0x4 + field public static final int SESSION_NO_ERROR = 0; // 0x0 + field public static final int SESSION_UNKNOWN_ERROR = 3; // 0x3 + field public static final int SESSION_VERIFICATION_FAILED = 1; // 0x1 + field @Deprecated public static final int STAGED_SESSION_ACTIVATION_FAILED = 2; // 0x2 + field @Deprecated public static final int STAGED_SESSION_CONFLICT = 4; // 0x4 + field @Deprecated public static final int STAGED_SESSION_NO_ERROR = 0; // 0x0 + field @Deprecated public static final int STAGED_SESSION_UNKNOWN = 3; // 0x3 + field @Deprecated public static final int STAGED_SESSION_VERIFICATION_FAILED = 1; // 0x1 } public static class PackageInstaller.SessionParams implements android.os.Parcelable { diff --git a/core/java/android/content/pm/PackageInstaller.java b/core/java/android/content/pm/PackageInstaller.java index 495100b0ae52b..08b07a73d4aff 100644 --- a/core/java/android/content/pm/PackageInstaller.java +++ b/core/java/android/content/pm/PackageInstaller.java @@ -2367,42 +2367,72 @@ public class PackageInstaller { private static final int[] NO_SESSIONS = {}; /** @hide */ - @IntDef(prefix = { "STAGED_SESSION_" }, value = { - STAGED_SESSION_NO_ERROR, - STAGED_SESSION_VERIFICATION_FAILED, - STAGED_SESSION_ACTIVATION_FAILED, - STAGED_SESSION_UNKNOWN, - STAGED_SESSION_CONFLICT}) + @IntDef(prefix = { "SESSION_" }, value = { + SESSION_NO_ERROR, + SESSION_VERIFICATION_FAILED, + SESSION_ACTIVATION_FAILED, + SESSION_UNKNOWN_ERROR, + SESSION_CONFLICT}) @Retention(RetentionPolicy.SOURCE) public @interface SessionErrorCode {} /** - * Constant indicating that no error occurred during the preparation or the activation of - * this staged session. + * @deprecated use {@link #SESSION_NO_ERROR}. */ + @Deprecated public static final int STAGED_SESSION_NO_ERROR = 0; /** - * Constant indicating that an error occurred during the verification phase (pre-reboot) of - * this staged session. + * @deprecated use {@link #SESSION_VERIFICATION_FAILED}. */ + @Deprecated public static final int STAGED_SESSION_VERIFICATION_FAILED = 1; /** - * Constant indicating that an error occurred during the activation phase (post-reboot) of - * this staged session. + * @deprecated use {@link #SESSION_ACTIVATION_FAILED}. */ + @Deprecated public static final int STAGED_SESSION_ACTIVATION_FAILED = 2; /** - * Constant indicating that an unknown error occurred while processing this staged session. + * @deprecated use {@link #SESSION_UNKNOWN_ERROR}. */ + @Deprecated public static final int STAGED_SESSION_UNKNOWN = 3; /** - * Constant indicating that the session was in conflict with another staged session and had + * @deprecated use {@link #SESSION_CONFLICT}. + */ + @Deprecated + public static final int STAGED_SESSION_CONFLICT = 4; + + /** + * Constant indicating that no error occurred during the preparation or the activation of + * this session. + */ + public static final int SESSION_NO_ERROR = 0; + + /** + * Constant indicating that an error occurred during the verification phase of + * this session. + */ + public static final int SESSION_VERIFICATION_FAILED = 1; + + /** + * Constant indicating that an error occurred during the activation phase of + * this session. + */ + public static final int SESSION_ACTIVATION_FAILED = 2; + + /** + * Constant indicating that an unknown error occurred while processing this session. + */ + public static final int SESSION_UNKNOWN_ERROR = 3; + + /** + * Constant indicating that the session was in conflict with another session and had * to be sacrificed for resolution. */ - public static final int STAGED_SESSION_CONFLICT = 4; + public static final int SESSION_CONFLICT = 4; private static String userActionToString(int requireUserAction) { switch(requireUserAction) { diff --git a/services/core/java/com/android/server/pm/ApexManager.java b/services/core/java/com/android/server/pm/ApexManager.java index 05567480e6bf9..c285e2795510d 100644 --- a/services/core/java/com/android/server/pm/ApexManager.java +++ b/services/core/java/com/android/server/pm/ApexManager.java @@ -799,7 +799,7 @@ public abstract class ApexManager { throw new RuntimeException(re); } catch (Exception e) { throw new PackageManagerException( - PackageInstaller.SessionInfo.STAGED_SESSION_VERIFICATION_FAILED, + PackageInstaller.SessionInfo.SESSION_VERIFICATION_FAILED, "apexd verification failed : " + e.getMessage()); } } @@ -826,7 +826,7 @@ public abstract class ApexManager { throw new RuntimeException(re); } catch (Exception e) { throw new PackageManagerException( - PackageInstaller.SessionInfo.STAGED_SESSION_VERIFICATION_FAILED, + PackageInstaller.SessionInfo.SESSION_VERIFICATION_FAILED, "Failed to mark apexd session as ready : " + e.getMessage()); } } diff --git a/services/core/java/com/android/server/pm/PackageInstallerService.java b/services/core/java/com/android/server/pm/PackageInstallerService.java index 416b3a426fa5e..8ebd254d03d33 100644 --- a/services/core/java/com/android/server/pm/PackageInstallerService.java +++ b/services/core/java/com/android/server/pm/PackageInstallerService.java @@ -331,7 +331,7 @@ public class PackageInstallerService extends IPackageInstaller.Stub implements StagingManager.StagedSession stagedSession = session.mStagedSession; if (!stagedSession.isInTerminalState() && stagedSession.hasParentSessionId() && getSession(stagedSession.getParentSessionId()) == null) { - stagedSession.setSessionFailed(SessionInfo.STAGED_SESSION_ACTIVATION_FAILED, + stagedSession.setSessionFailed(SessionInfo.SESSION_ACTIVATION_FAILED, "An orphan staged session " + stagedSession.sessionId() + " is found, " + "parent " + stagedSession.getParentSessionId() + " is missing"); continue; @@ -843,7 +843,7 @@ public class PackageInstallerService extends IPackageInstaller.Stub implements mSilentUpdatePolicy, mInstallThread.getLooper(), mStagingManager, sessionId, userId, callingUid, installSource, params, createdMillis, 0L, stageDir, stageCid, null, null, false, false, false, false, null, SessionInfo.INVALID_ID, - false, false, false, SessionInfo.STAGED_SESSION_NO_ERROR, ""); + false, false, false, SessionInfo.SESSION_NO_ERROR, ""); synchronized (mSessions) { mSessions.put(sessionId, session); diff --git a/services/core/java/com/android/server/pm/PackageInstallerSession.java b/services/core/java/com/android/server/pm/PackageInstallerSession.java index f45e54b04e548..304ad72c63597 100644 --- a/services/core/java/com/android/server/pm/PackageInstallerSession.java +++ b/services/core/java/com/android/server/pm/PackageInstallerSession.java @@ -460,7 +460,7 @@ public class PackageInstallerSession extends IPackageInstallerSession.Stub { @GuardedBy("mLock") private boolean mSessionFailed; @GuardedBy("mLock") - private int mSessionErrorCode = SessionInfo.STAGED_SESSION_NO_ERROR; + private int mSessionErrorCode = SessionInfo.SESSION_NO_ERROR; @GuardedBy("mLock") private String mSessionErrorMessage; @@ -2092,7 +2092,7 @@ public class PackageInstallerSession extends IPackageInstallerSession.Stub { if (isStaged()) { // This will clean up the session when it reaches the terminal state mStagedSession.setSessionFailed( - SessionInfo.STAGED_SESSION_VERIFICATION_FAILED, msgWithErrorCode); + SessionInfo.SESSION_VERIFICATION_FAILED, msgWithErrorCode); mStagedSession.notifyEndPreRebootVerification(); } else { // Session is sealed and committed but could not be verified, we need to destroy it. @@ -2547,7 +2547,7 @@ public class PackageInstallerSession extends IPackageInstallerSession.Stub { if (isStaged()) { mSessionProvider.getSessionVerifier().verifyStaged(mStagedSession, (error, msg) -> { mStagedSession.notifyEndPreRebootVerification(); - if (error == SessionInfo.STAGED_SESSION_NO_ERROR) { + if (error == SessionInfo.SESSION_NO_ERROR) { mStagingManager.commitSession(mStagedSession); } }); @@ -4168,7 +4168,7 @@ public class PackageInstallerSession extends IPackageInstallerSession.Stub { mSessionReady = true; mSessionApplied = false; mSessionFailed = false; - mSessionErrorCode = SessionInfo.STAGED_SESSION_NO_ERROR; + mSessionErrorCode = SessionInfo.SESSION_NO_ERROR; mSessionErrorMessage = ""; } mCallback.onSessionChanged(this); @@ -4196,7 +4196,7 @@ public class PackageInstallerSession extends IPackageInstallerSession.Stub { mSessionReady = false; mSessionApplied = true; mSessionFailed = false; - mSessionErrorCode = SessionInfo.STAGED_SESSION_NO_ERROR; + mSessionErrorCode = SessionInfo.SESSION_NO_ERROR; mSessionErrorMessage = ""; Slog.d(TAG, "Marking session " + sessionId + " as applied"); } @@ -4705,7 +4705,7 @@ public class PackageInstallerSession extends IPackageInstallerSession.Stub { final boolean isFailed = in.getAttributeBoolean(null, ATTR_IS_FAILED, false); final boolean isApplied = in.getAttributeBoolean(null, ATTR_IS_APPLIED, false); final int sessionErrorCode = in.getAttributeInt(null, ATTR_SESSION_ERROR_CODE, - SessionInfo.STAGED_SESSION_NO_ERROR); + SessionInfo.SESSION_NO_ERROR); final String sessionErrorMessage = readStringAttribute(in, ATTR_SESSION_ERROR_MESSAGE); if (!isStagedSessionStateValid(isReady, isApplied, isFailed)) { diff --git a/services/core/java/com/android/server/pm/PackageSessionVerifier.java b/services/core/java/com/android/server/pm/PackageSessionVerifier.java index a532fe3a3d4d3..ccabce7194025 100644 --- a/services/core/java/com/android/server/pm/PackageSessionVerifier.java +++ b/services/core/java/com/android/server/pm/PackageSessionVerifier.java @@ -202,7 +202,7 @@ final class PackageSessionVerifier { } private void onVerificationSuccess(StagingManager.StagedSession session, Callback callback) { - callback.onResult(SessionInfo.STAGED_SESSION_NO_ERROR, null); + callback.onResult(SessionInfo.SESSION_NO_ERROR, null); } private void onVerificationFailure(StagingManager.StagedSession session, Callback callback, @@ -298,7 +298,7 @@ final class PackageSessionVerifier { // Failed to get hold of StorageManager Slog.e(TAG, "Failed to get hold of StorageManager", e); throw new PackageManagerException( - SessionInfo.STAGED_SESSION_UNKNOWN, + SessionInfo.SESSION_UNKNOWN_ERROR, "Failed to get hold of StorageManager"); } // Proactively mark session as ready before calling apexd. Although this call order @@ -336,7 +336,7 @@ final class PackageSessionVerifier { final ParseResult newResult = ApkSignatureVerifier.verify( input.reset(), apexPath, minSignatureScheme); if (newResult.isError()) { - throw new PackageManagerException(SessionInfo.STAGED_SESSION_VERIFICATION_FAILED, + throw new PackageManagerException(SessionInfo.SESSION_VERIFICATION_FAILED, "Failed to parse APEX package " + apexPath + " : " + newResult.getException(), newResult.getException()); } @@ -355,7 +355,7 @@ final class PackageSessionVerifier { input.reset(), existingApexPkg.applicationInfo.sourceDir, SigningDetails.SignatureSchemeVersion.JAR); if (existingResult.isError()) { - throw new PackageManagerException(SessionInfo.STAGED_SESSION_VERIFICATION_FAILED, + throw new PackageManagerException(SessionInfo.SESSION_VERIFICATION_FAILED, "Failed to parse APEX package " + existingApexPkg.applicationInfo.sourceDir + " : " + existingResult.getException(), existingResult.getException()); } @@ -369,7 +369,7 @@ final class PackageSessionVerifier { return; } - throw new PackageManagerException(SessionInfo.STAGED_SESSION_VERIFICATION_FAILED, + throw new PackageManagerException(SessionInfo.SESSION_VERIFICATION_FAILED, "APK-container signature of APEX package " + packageName + " with version " + newApexPkg.versionCodeMajor + " and path " + apexPath + " is not" + " compatible with the one currently installed on device"); @@ -412,11 +412,11 @@ final class PackageSessionVerifier { packageInfo = PackageInfoWithoutStateUtils.generate(parsedPackage, apexInfo, flags); if (packageInfo == null) { throw new PackageManagerException( - SessionInfo.STAGED_SESSION_VERIFICATION_FAILED, + SessionInfo.SESSION_VERIFICATION_FAILED, "Unable to generate package info: " + apexInfo.modulePath); } } catch (PackageManagerException e) { - throw new PackageManagerException(SessionInfo.STAGED_SESSION_VERIFICATION_FAILED, + throw new PackageManagerException(SessionInfo.SESSION_VERIFICATION_FAILED, "Failed to parse APEX package " + apexInfo.modulePath + " : " + e, e); } result.add(packageInfo); @@ -438,7 +438,7 @@ final class PackageSessionVerifier { } } throw new PackageManagerException( - SessionInfo.STAGED_SESSION_VERIFICATION_FAILED, + SessionInfo.SESSION_VERIFICATION_FAILED, "Could not find rollback id for commit session: " + sessionId); } @@ -546,7 +546,7 @@ final class PackageSessionVerifier { try { checkActiveSessions(PackageHelper.getStorageManager().supportsCheckpoint()); } catch (RemoteException e) { - throw new PackageManagerException(SessionInfo.STAGED_SESSION_VERIFICATION_FAILED, + throw new PackageManagerException(SessionInfo.SESSION_VERIFICATION_FAILED, "Can't query fs-checkpoint status : " + e); } } @@ -562,7 +562,7 @@ final class PackageSessionVerifier { } if (!supportsCheckpoint && activeSessions > 1) { throw new PackageManagerException( - SessionInfo.STAGED_SESSION_VERIFICATION_FAILED, + SessionInfo.SESSION_VERIFICATION_FAILED, "Cannot stage multiple sessions without checkpoint support"); } } @@ -593,13 +593,13 @@ final class PackageSessionVerifier { // will be deleted. } stagedSession.setSessionFailed( - SessionInfo.STAGED_SESSION_CONFLICT, + SessionInfo.SESSION_CONFLICT, "Session was failed by rollback session: " + session.sessionId()); Slog.i(TAG, "Session " + stagedSession.sessionId() + " is marked failed due to " + "rollback session: " + session.sessionId()); } else if (!isRollback(session) && isRollback(stagedSession)) { throw new PackageManagerException( - SessionInfo.STAGED_SESSION_CONFLICT, + SessionInfo.SESSION_CONFLICT, "Session was failed by rollback session: " + stagedSession.sessionId()); } @@ -622,7 +622,7 @@ final class PackageSessionVerifier { final String packageName = child.getPackageName(); if (packageName == null) { throw new PackageManagerException( - SessionInfo.STAGED_SESSION_VERIFICATION_FAILED, + SessionInfo.SESSION_VERIFICATION_FAILED, "Cannot stage session " + child.sessionId() + " with package name null"); } for (StagingManager.StagedSession stagedSession : mStagedSessions) { @@ -634,14 +634,14 @@ final class PackageSessionVerifier { if (stagedSession.getCommittedMillis() < parent.getCommittedMillis()) { // Fail the session committed later when there are overlapping packages throw new PackageManagerException( - SessionInfo.STAGED_SESSION_VERIFICATION_FAILED, + SessionInfo.SESSION_VERIFICATION_FAILED, "Package: " + packageName + " in session: " + child.sessionId() + " has been staged already by session: " + stagedSession.sessionId()); } else { stagedSession.setSessionFailed( - SessionInfo.STAGED_SESSION_VERIFICATION_FAILED, + SessionInfo.SESSION_VERIFICATION_FAILED, "Package: " + packageName + " in session: " + stagedSession.sessionId() + " has been staged already by session: " diff --git a/services/core/java/com/android/server/pm/StagingManager.java b/services/core/java/com/android/server/pm/StagingManager.java index 8a6ef6bfcb414..29de5551cb27a 100644 --- a/services/core/java/com/android/server/pm/StagingManager.java +++ b/services/core/java/com/android/server/pm/StagingManager.java @@ -284,7 +284,7 @@ public class StagingManager { String packageName = apexSession.getPackageName(); String errorMsg = mApexManager.getApkInApexInstallError(packageName); if (errorMsg != null) { - throw new PackageManagerException(SessionInfo.STAGED_SESSION_ACTIVATION_FAILED, + throw new PackageManagerException(SessionInfo.SESSION_ACTIVATION_FAILED, "Failed to install apk-in-apex of " + packageName + " : " + errorMsg); } } @@ -397,7 +397,7 @@ public class StagingManager { revertMsg += " Reason for revert: " + reasonForRevert; } Slog.d(TAG, revertMsg); - session.setSessionFailed(SessionInfo.STAGED_SESSION_UNKNOWN, revertMsg); + session.setSessionFailed(SessionInfo.SESSION_UNKNOWN_ERROR, revertMsg); return; } @@ -484,7 +484,7 @@ public class StagingManager { for (String apkInApex : mApexManager.getApksInApex(packageName)) { if (!apkNames.add(apkInApex)) { throw new PackageManagerException( - SessionInfo.STAGED_SESSION_ACTIVATION_FAILED, + SessionInfo.SESSION_ACTIVATION_FAILED, "Package: " + packageName + " in session: " + apexSession.sessionId() + " has duplicate apk-in-apex: " + apkInApex, null); @@ -511,7 +511,7 @@ public class StagingManager { Slog.e(TAG, "Failure to install APK staged session " + session.sessionId() + " [" + errorMessage + "]"); throw new PackageManagerException( - SessionInfo.STAGED_SESSION_ACTIVATION_FAILED, errorMessage); + SessionInfo.SESSION_ACTIVATION_FAILED, errorMessage); } } @@ -665,7 +665,7 @@ public class StagingManager { // is upgrading. Fail all the sessions and exit early. for (int i = 0; i < sessions.size(); i++) { StagedSession session = sessions.get(i); - session.setSessionFailed(SessionInfo.STAGED_SESSION_ACTIVATION_FAILED, + session.setSessionFailed(SessionInfo.SESSION_ACTIVATION_FAILED, "Build fingerprint has changed"); } return; @@ -705,7 +705,7 @@ public class StagingManager { final ApexSessionInfo apexSession = apexSessions.get(session.sessionId()); if (apexSession == null || apexSession.isUnknown) { hasFailedApexSession = true; - session.setSessionFailed(SessionInfo.STAGED_SESSION_ACTIVATION_FAILED, "apexd did " + session.setSessionFailed(SessionInfo.SESSION_ACTIVATION_FAILED, "apexd did " + "not know anything about a staged session supposed to be activated"); continue; } else if (isApexSessionFailed(apexSession)) { @@ -721,7 +721,7 @@ public class StagingManager { errorMsg += " Error: " + apexSession.errorMessage; } Slog.d(TAG, errorMsg); - session.setSessionFailed(SessionInfo.STAGED_SESSION_ACTIVATION_FAILED, errorMsg); + session.setSessionFailed(SessionInfo.SESSION_ACTIVATION_FAILED, errorMsg); continue; } else if (apexSession.isActivated || apexSession.isSuccess) { hasAppliedApexSession = true; @@ -730,13 +730,13 @@ public class StagingManager { // Apexd did not apply the session for some unknown reason. There is no guarantee // that apexd will install it next time. Safer to proactively mark it as failed. hasFailedApexSession = true; - session.setSessionFailed(SessionInfo.STAGED_SESSION_ACTIVATION_FAILED, + session.setSessionFailed(SessionInfo.SESSION_ACTIVATION_FAILED, "Staged session " + session.sessionId() + " at boot didn't activate nor " + "fail. Marking it as failed anyway."); } else { Slog.w(TAG, "Apex session " + session.sessionId() + " is in impossible state"); hasFailedApexSession = true; - session.setSessionFailed(SessionInfo.STAGED_SESSION_ACTIVATION_FAILED, + session.setSessionFailed(SessionInfo.SESSION_ACTIVATION_FAILED, "Impossible state"); } } @@ -756,7 +756,7 @@ public class StagingManager { // Session has been already failed in the loop above. continue; } - session.setSessionFailed(SessionInfo.STAGED_SESSION_ACTIVATION_FAILED, + session.setSessionFailed(SessionInfo.SESSION_ACTIVATION_FAILED, "Another apex session failed"); } return; @@ -772,7 +772,7 @@ public class StagingManager { } catch (Exception e) { Slog.e(TAG, "Staged install failed due to unhandled exception", e); onInstallationFailure(session, new PackageManagerException( - SessionInfo.STAGED_SESSION_ACTIVATION_FAILED, + SessionInfo.SESSION_ACTIVATION_FAILED, "Staged install failed due to unhandled exception: " + e), supportsCheckpoint, needsCheckpoint); } diff --git a/services/tests/mockingservicestests/src/com/android/server/pm/StagingManagerTest.java b/services/tests/mockingservicestests/src/com/android/server/pm/StagingManagerTest.java index f2415b4665d55..bdfdf7723c026 100644 --- a/services/tests/mockingservicestests/src/com/android/server/pm/StagingManagerTest.java +++ b/services/tests/mockingservicestests/src/com/android/server/pm/StagingManagerTest.java @@ -158,10 +158,10 @@ public class StagingManagerTest { mStagingManager.restoreSessions(Arrays.asList(session1, session2), true); - assertThat(session1.getErrorCode()).isEqualTo(SessionInfo.STAGED_SESSION_ACTIVATION_FAILED); + assertThat(session1.getErrorCode()).isEqualTo(SessionInfo.SESSION_ACTIVATION_FAILED); assertThat(session1.getErrorMessage()).isEqualTo("Build fingerprint has changed"); - assertThat(session2.getErrorCode()).isEqualTo(SessionInfo.STAGED_SESSION_ACTIVATION_FAILED); + assertThat(session2.getErrorCode()).isEqualTo(SessionInfo.SESSION_ACTIVATION_FAILED); assertThat(session2.getErrorMessage()).isEqualTo("Build fingerprint has changed"); } @@ -247,12 +247,12 @@ public class StagingManagerTest { verify(mStorageManager, never()).abortChanges(eq("abort-staged-install"), eq(false)); assertThat(apexSession.getErrorCode()) - .isEqualTo(SessionInfo.STAGED_SESSION_ACTIVATION_FAILED); + .isEqualTo(SessionInfo.SESSION_ACTIVATION_FAILED); assertThat(apexSession.getErrorMessage()).isEqualTo("apexd did not know anything about a " + "staged session supposed to be activated"); assertThat(apkSession.getErrorCode()) - .isEqualTo(SessionInfo.STAGED_SESSION_ACTIVATION_FAILED); + .isEqualTo(SessionInfo.SESSION_ACTIVATION_FAILED); assertThat(apkSession.getErrorMessage()).isEqualTo("Another apex session failed"); } @@ -303,22 +303,22 @@ public class StagingManagerTest { verify(mStorageManager, never()).abortChanges(eq("abort-staged-install"), eq(false)); assertThat(apexSession1.getErrorCode()) - .isEqualTo(SessionInfo.STAGED_SESSION_ACTIVATION_FAILED); + .isEqualTo(SessionInfo.SESSION_ACTIVATION_FAILED); assertThat(apexSession1.getErrorMessage()).isEqualTo("APEX activation failed. " + "Error: Failed for test"); assertThat(apexSession2.getErrorCode()) - .isEqualTo(SessionInfo.STAGED_SESSION_ACTIVATION_FAILED); + .isEqualTo(SessionInfo.SESSION_ACTIVATION_FAILED); assertThat(apexSession2.getErrorMessage()).isEqualTo("Staged session 101 at boot didn't " + "activate nor fail. Marking it as failed anyway."); assertThat(apexSession3.getErrorCode()) - .isEqualTo(SessionInfo.STAGED_SESSION_ACTIVATION_FAILED); + .isEqualTo(SessionInfo.SESSION_ACTIVATION_FAILED); assertThat(apexSession3.getErrorMessage()).isEqualTo("apexd did not know anything about a " + "staged session supposed to be activated"); assertThat(apkSession.getErrorCode()) - .isEqualTo(SessionInfo.STAGED_SESSION_ACTIVATION_FAILED); + .isEqualTo(SessionInfo.SESSION_ACTIVATION_FAILED); assertThat(apkSession.getErrorMessage()).isEqualTo("Another apex session failed"); } @@ -351,12 +351,12 @@ public class StagingManagerTest { verify(mStorageManager, never()).abortChanges(eq("abort-staged-install"), eq(false)); assertThat(apexSession.getErrorCode()) - .isEqualTo(SessionInfo.STAGED_SESSION_ACTIVATION_FAILED); + .isEqualTo(SessionInfo.SESSION_ACTIVATION_FAILED); assertThat(apexSession.getErrorMessage()).isEqualTo("Staged session 1543 at boot didn't " + "activate nor fail. Marking it as failed anyway."); assertThat(apkSession.getErrorCode()) - .isEqualTo(SessionInfo.STAGED_SESSION_ACTIVATION_FAILED); + .isEqualTo(SessionInfo.SESSION_ACTIVATION_FAILED); assertThat(apkSession.getErrorMessage()).isEqualTo("Another apex session failed"); } @@ -445,11 +445,11 @@ public class StagingManagerTest { verify(mStorageManager, never()).abortChanges(eq("abort-staged-install"), eq(false)); assertThat(apexSession.getErrorCode()) - .isEqualTo(SessionInfo.STAGED_SESSION_ACTIVATION_FAILED); + .isEqualTo(SessionInfo.SESSION_ACTIVATION_FAILED); assertThat(apexSession.getErrorMessage()).isEqualTo("Impossible state"); assertThat(apkSession.getErrorCode()) - .isEqualTo(SessionInfo.STAGED_SESSION_ACTIVATION_FAILED); + .isEqualTo(SessionInfo.SESSION_ACTIVATION_FAILED); assertThat(apkSession.getErrorMessage()).isEqualTo("Another apex session failed"); } @@ -754,7 +754,7 @@ public class StagingManagerTest { /* isReady */ false, /* isFailed */ false, /* isApplied */false, - /* stagedSessionErrorCode */ PackageInstaller.SessionInfo.STAGED_SESSION_NO_ERROR, + /* stagedSessionErrorCode */ PackageInstaller.SessionInfo.SESSION_NO_ERROR, /* stagedSessionErrorMessage */ "no error"); StagingManager.StagedSession stagedSession = spy(session.mStagedSession); diff --git a/services/tests/servicestests/src/com/android/server/pm/PackageInstallerSessionTest.java b/services/tests/servicestests/src/com/android/server/pm/PackageInstallerSessionTest.java index 62a2b1be139d3..59f2ca4f61069 100644 --- a/services/tests/servicestests/src/com/android/server/pm/PackageInstallerSessionTest.java +++ b/services/tests/servicestests/src/com/android/server/pm/PackageInstallerSessionTest.java @@ -187,7 +187,7 @@ public class PackageInstallerSessionTest { /* isFailed */ false, /* isApplied */false, /* stagedSessionErrorCode */ - PackageInstaller.SessionInfo.STAGED_SESSION_VERIFICATION_FAILED, + PackageInstaller.SessionInfo.SESSION_VERIFICATION_FAILED, /* stagedSessionErrorMessage */ "some error"); }