Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit 7d98a456 authored by Dario Freni's avatar Dario Freni Committed by Android (Google) Code Review
Browse files

Merge "Add "Staged" to API related to staged sessions."

parents 8e95f0bf 60a96c17
Loading
Loading
Loading
Loading
+3 −3
Original line number Diff line number Diff line
@@ -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
+27 −16
Original line number Diff line number Diff line
@@ -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);
        }
+3 −3
Original line number Diff line number Diff line
@@ -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;
+3 −3
Original line number Diff line number Diff line
@@ -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 ["
+4 −4
Original line number Diff line number Diff line
@@ -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.
Loading