diff --git a/services/core/java/com/android/server/pm/ApexManager.java b/services/core/java/com/android/server/pm/ApexManager.java index 7e1bc79399b9d..2301e3fb093d1 100644 --- a/services/core/java/com/android/server/pm/ApexManager.java +++ b/services/core/java/com/android/server/pm/ApexManager.java @@ -29,6 +29,7 @@ import android.content.Intent; import android.content.IntentFilter; import android.content.pm.ApplicationInfo; import android.content.pm.PackageInfo; +import android.content.pm.PackageInstaller; import android.content.pm.PackageManager; import android.content.pm.PackageParser; import android.os.RemoteException; @@ -147,14 +148,10 @@ abstract class ApexManager { * @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 * be an empty array. - * @param apexInfoList this is an output parameter, which needs to be initialized by tha caller - * 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. + * @throws PackageManagerException if call to apexd fails */ - abstract boolean submitStagedSession( - int sessionId, @NonNull int[] childSessionIds, @NonNull ApexInfoList apexInfoList); + abstract ApexInfoList submitStagedSession(int sessionId, @NonNull int[] childSessionIds) + throws PackageManagerException; /** * Mark a staged session previously submitted using {@code submitStagedSession} as ready to be @@ -388,13 +385,19 @@ abstract class ApexManager { } @Override - boolean submitStagedSession( - int sessionId, @NonNull int[] childSessionIds, @NonNull ApexInfoList apexInfoList) { + ApexInfoList submitStagedSession(int sessionId, @NonNull int[] childSessionIds) + throws PackageManagerException { try { - return mApexService.submitStagedSession(sessionId, childSessionIds, apexInfoList); + final ApexInfoList apexInfoList = new ApexInfoList(); + mApexService.submitStagedSession(sessionId, childSessionIds, apexInfoList); + return apexInfoList; } catch (RemoteException re) { Slog.e(TAG, "Unable to contact apexservice", 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 - boolean submitStagedSession(int sessionId, int[] childSessionIds, - ApexInfoList apexInfoList) { - throw new UnsupportedOperationException(); + ApexInfoList submitStagedSession(int sessionId, int[] childSessionIds) + throws PackageManagerException { + throw new PackageManagerException(PackageManager.INSTALL_FAILED_INTERNAL_ERROR, + "Device doesn't support updating APEX"); } @Override diff --git a/services/core/java/com/android/server/pm/StagingManager.java b/services/core/java/com/android/server/pm/StagingManager.java index f9a019703f4da..404b515e233ea 100644 --- a/services/core/java/com/android/server/pm/StagingManager.java +++ b/services/core/java/com/android/server/pm/StagingManager.java @@ -155,13 +155,10 @@ public class StagingManager { } } } - final ApexInfoList apexInfoList = new ApexInfoList(); - boolean submittedToApexd = mApexManager.submitStagedSession(session.sessionId, - childSessionsIds.toArray(), apexInfoList); - if (!submittedToApexd) { - throw new PackageManagerException(SessionInfo.STAGED_SESSION_VERIFICATION_FAILED, - "APEX staging failed, check logcat messages from apexd for more details."); - } + // submitStagedSession will throw a PackageManagerException if apexd verification fails, + // which will be propagated to populate stagedSessionErrorMessage of this session. + final ApexInfoList apexInfoList = mApexManager.submitStagedSession(session.sessionId, + childSessionsIds.toArray()); final List result = new ArrayList<>(); for (ApexInfo newPackage : apexInfoList.apexInfos) { final PackageInfo pkg;