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

Commit c5f10b97 authored by Abhijeet Kaur's avatar Abhijeet Kaur Committed by Android (Google) Code Review
Browse files

Merge "Add e2e tests for getstagedsessions for apex"

parents ced0b0c9 84b1f5dd
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<>();