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

Commit eb23072f authored by Nikita Ioffe's avatar Nikita Ioffe Committed by Android (Google) Code Review
Browse files

Merge "Populate error message if apexd verification fails"

parents d0d7e620 4e7d24a7
Loading
Loading
Loading
Loading
+17 −13
Original line number Original line Diff line number Diff line
@@ -29,6 +29,7 @@ import android.content.Intent;
import android.content.IntentFilter;
import android.content.IntentFilter;
import android.content.pm.ApplicationInfo;
import android.content.pm.ApplicationInfo;
import android.content.pm.PackageInfo;
import android.content.pm.PackageInfo;
import android.content.pm.PackageInstaller;
import android.content.pm.PackageManager;
import android.content.pm.PackageManager;
import android.content.pm.PackageParser;
import android.content.pm.PackageParser;
import android.os.RemoteException;
import android.os.RemoteException;
@@ -147,14 +148,10 @@ abstract class ApexManager {
     * @param childSessionIds if {@code sessionId} is a multi-package session, this should contain
     * @param childSessionIds if {@code sessionId} is a multi-package session, this should contain
     *                        an array of identifiers of all the child sessions. Otherwise it should
     *                        an array of identifiers of all the child sessions. Otherwise it should
     *                        be an empty array.
     *                        be an empty array.
     * @param apexInfoList this is an output parameter, which needs to be initialized by tha caller
     * @throws PackageManagerException if call to apexd fails
     *                     and will be filled with a list of {@link ApexInfo} objects, each of which
     *                     contains metadata about one of the packages being submitted as part of
     *                     the session.
     * @return whether the submission of the session was successful.
     */
     */
    abstract boolean submitStagedSession(
    abstract ApexInfoList submitStagedSession(int sessionId, @NonNull int[] childSessionIds)
            int sessionId, @NonNull int[] childSessionIds, @NonNull ApexInfoList apexInfoList);
            throws PackageManagerException;


    /**
    /**
     * Mark a staged session previously submitted using {@code submitStagedSession} as ready to be
     * Mark a staged session previously submitted using {@code submitStagedSession} as ready to be
@@ -388,13 +385,19 @@ abstract class ApexManager {
        }
        }


        @Override
        @Override
        boolean submitStagedSession(
        ApexInfoList submitStagedSession(int sessionId, @NonNull int[] childSessionIds)
                int sessionId, @NonNull int[] childSessionIds, @NonNull ApexInfoList apexInfoList) {
                throws PackageManagerException {
            try {
            try {
                return mApexService.submitStagedSession(sessionId, childSessionIds, apexInfoList);
                final ApexInfoList apexInfoList = new ApexInfoList();
                mApexService.submitStagedSession(sessionId, childSessionIds, apexInfoList);
                return apexInfoList;
            } catch (RemoteException re) {
            } catch (RemoteException re) {
                Slog.e(TAG, "Unable to contact apexservice", re);
                Slog.e(TAG, "Unable to contact apexservice", re);
                throw new RuntimeException(re);
                throw new RuntimeException(re);
            } catch (Exception e) {
                throw new PackageManagerException(
                        PackageInstaller.SessionInfo.STAGED_SESSION_VERIFICATION_FAILED,
                        "apexd verification failed : " + e.getMessage());
            }
            }
        }
        }


@@ -566,9 +569,10 @@ abstract class ApexManager {
        }
        }


        @Override
        @Override
        boolean submitStagedSession(int sessionId, int[] childSessionIds,
        ApexInfoList submitStagedSession(int sessionId, int[] childSessionIds)
                ApexInfoList apexInfoList) {
                throws PackageManagerException {
            throw new UnsupportedOperationException();
            throw new PackageManagerException(PackageManager.INSTALL_FAILED_INTERNAL_ERROR,
                    "Device doesn't support updating APEX");
        }
        }


        @Override
        @Override
+4 −7
Original line number Original line Diff line number Diff line
@@ -155,13 +155,10 @@ public class StagingManager {
                }
                }
            }
            }
        }
        }
        final ApexInfoList apexInfoList = new ApexInfoList();
        // submitStagedSession will throw a PackageManagerException if apexd verification fails,
        boolean submittedToApexd = mApexManager.submitStagedSession(session.sessionId,
        // which will be propagated to populate stagedSessionErrorMessage of this session.
                childSessionsIds.toArray(), apexInfoList);
        final ApexInfoList apexInfoList = mApexManager.submitStagedSession(session.sessionId,
        if (!submittedToApexd) {
                childSessionsIds.toArray());
            throw new PackageManagerException(SessionInfo.STAGED_SESSION_VERIFICATION_FAILED,
                    "APEX staging failed, check logcat messages from apexd for more details.");
        }
        final List<PackageInfo> result = new ArrayList<>();
        final List<PackageInfo> result = new ArrayList<>();
        for (ApexInfo newPackage : apexInfoList.apexInfos) {
        for (ApexInfo newPackage : apexInfoList.apexInfos) {
            final PackageInfo pkg;
            final PackageInfo pkg;