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

Commit bc969f43 authored by Pinyao Ting's avatar Pinyao Ting
Browse files

Export timestamp of the creation of install session. The timestamp is an

useful signal for downstream to determine post-creation operation.

One specific case is in Launcher, we update the homescreen as a response
of session creation. Since launcher needs to register a listener, it
misses some of the sessions which were created while the Launcher process
was dead. This API allows launcher to keep a track of
"last-created-session" and on the next process start, go through all the
sessions to determine the new sessions.

The main use case would be for restore in Launcher, where if it sees
new restore sessions which were previously not there, Launcher will
"undelete" some of the restored app icons and widgets.

Bug: 141472083
Test: PackageInstallerSessionTest
Change-Id: I52d18c5bb8e687f11bb27169146d332f45699ede
parent 8f0903ae
Loading
Loading
Loading
Loading
+1 −0
Original line number Diff line number Diff line
@@ -11672,6 +11672,7 @@ package android.content.pm {
    method @Nullable public CharSequence getAppLabel();
    method @Nullable public String getAppPackageName();
    method @NonNull public int[] getChildSessionIds();
    method public long getCreatedMillis();
    method public int getInstallLocation();
    method public int getInstallReason();
    method @Nullable public String getInstallerPackageName();
+12 −0
Original line number Diff line number Diff line
@@ -2091,6 +2091,9 @@ public class PackageInstaller {
        /** {@hide} */
        public boolean isCommitted;

        /** {@hide} */
        public long createdMillis;

        /** {@hide} */
        public long updatedMillis;

@@ -2141,6 +2144,7 @@ public class PackageInstaller {
            mStagedSessionErrorMessage = source.readString();
            isCommitted = source.readBoolean();
            rollbackDataPolicy = source.readInt();
            createdMillis = source.readLong();
        }

        /**
@@ -2582,6 +2586,13 @@ public class PackageInstaller {
            return isCommitted;
        }

        /**
         * The timestamp of the initial creation of the session.
         */
        public long getCreatedMillis() {
            return createdMillis;
        }

        /**
         * The timestamp of the last update that occurred to the session, including changing of
         * states in case of staged sessions.
@@ -2631,6 +2642,7 @@ public class PackageInstaller {
            dest.writeString(mStagedSessionErrorMessage);
            dest.writeBoolean(isCommitted);
            dest.writeInt(rollbackDataPolicy);
            dest.writeLong(createdMillis);
        }

        public static final Parcelable.Creator<SessionInfo>
+1 −0
Original line number Diff line number Diff line
@@ -611,6 +611,7 @@ public class PackageInstallerSession extends IPackageInstallerSession.Stub {
            info.isStagedSessionReady = mStagedSessionReady;
            info.isStagedSessionFailed = mStagedSessionFailed;
            info.setStagedSessionErrorCode(mStagedSessionErrorCode, mStagedSessionErrorMessage);
            info.createdMillis = createdMillis;
            info.updatedMillis = updatedMillis;
        }
        return info;
+1 −0
Original line number Diff line number Diff line
@@ -309,6 +309,7 @@ public class PackageInstallerSessionTest {
                actual.getStagedSessionErrorMessage());
        assertEquals(expected.isPrepared(), actual.isPrepared());
        assertEquals(expected.isCommitted(), actual.isCommitted());
        assertEquals(expected.createdMillis, actual.createdMillis);
        assertEquals(expected.isSealed(), actual.isSealed());
        assertEquals(expected.isMultiPackage(), actual.isMultiPackage());
        assertEquals(expected.hasParentSessionId(), actual.hasParentSessionId());