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

Commit 84b1f5dd authored by Abhijeet Kaur's avatar Abhijeet Kaur
Browse files

Add e2e tests for getstagedsessions for apex

Add get-stagedsession package manager command shell. Test by using the
added shell command.

Test: atest apex_e2e_tests

Bug: 122882120

Change-Id: I0418ee7ace740f3fb1f5d08a2c373c3ee8f8ceae
parent 9e063227
Loading
Loading
Loading
Loading
+25 −0
Original line number Diff line number Diff line
@@ -39,6 +39,7 @@ import android.content.pm.IPackageManager;
import android.content.pm.InstrumentationInfo;
import android.content.pm.PackageInfo;
import android.content.pm.PackageInstaller;
import android.content.pm.PackageInstaller.SessionInfo;
import android.content.pm.PackageInstaller.SessionParams;
import android.content.pm.PackageItemInfo;
import android.content.pm.PackageManager;
@@ -258,6 +259,8 @@ class PackageManagerShellCommand extends ShellCommand {
                    return runSetHarmfulAppWarning();
                case "get-harmful-app-warning":
                    return runGetHarmfulAppWarning();
                case "get-stagedsessions":
                    return getStagedSessions();
                case "uninstall-system-updates":
                    return uninstallSystemUpdates();
                default: {
@@ -282,6 +285,28 @@ class PackageManagerShellCommand extends ShellCommand {
        return -1;
    }

    private int getStagedSessions() {
        final PrintWriter pw = getOutPrintWriter();
        try {
            List<SessionInfo> stagedSessionsList =
                    mInterface.getPackageInstaller().getStagedSessions().getList();
            for (SessionInfo session: stagedSessionsList) {
                pw.println("appPackageName = " + session.getAppPackageName()
                        + "; sessionId = " + session.getSessionId()
                        + "; isStaged = " + session.isStaged()
                        + "; isSessionReady = " + session.isSessionReady()
                        + "; isSessionApplied = " + session.isSessionApplied()
                        + "; isSessionFailed = " + session.isSessionFailed() + ";");
            }
        } catch (RemoteException e) {
            pw.println("Failure ["
                    + e.getClass().getName() + " - "
                    + e.getMessage() + "]");
            return 0;
        }
        return 1;
    }

    private int uninstallSystemUpdates() {
        final PrintWriter pw = getOutPrintWriter();
        List<String> failedUninstalls = new LinkedList<>();