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

Commit 0966047e authored by Dario Freni's avatar Dario Freni
Browse files

Throw a checked exception on child session linkage

Instead of throwing a RuntimeException, throw a RemoteException and let
the client handle it.

Bug: 124215984
Test: n/a
Change-Id: Idbfe9b8426bbb7e2b6abe6b3d323709ca5a6f804
parent 3deb23fe
Loading
Loading
Loading
Loading
+2 −2
Original line number Original line Diff line number Diff line
@@ -1869,7 +1869,7 @@ public class PackageInstallerSession extends IPackageInstallerSession.Stub {
    }
    }


    @Override
    @Override
    public void addChildSessionId(int childSessionId) {
    public void addChildSessionId(int childSessionId) throws RemoteException {
        final PackageInstallerSession childSession = mSessionProvider.getSession(childSessionId);
        final PackageInstallerSession childSession = mSessionProvider.getSession(childSessionId);
        if (childSession == null) {
        if (childSession == null) {
            throw new RemoteException("Unable to add child.",
            throw new RemoteException("Unable to add child.",
@@ -1884,7 +1884,7 @@ public class PackageInstallerSession extends IPackageInstallerSession.Stub {
                    new PackageManagerException("Child session " + childSessionId
                    new PackageManagerException("Child session " + childSessionId
                            + " and parent session " + this.sessionId + " do not have consistent"
                            + " and parent session " + this.sessionId + " do not have consistent"
                            + " staging session settings."),
                            + " staging session settings."),
                    false, true).rethrowAsRuntimeException();
                    false, true);
        }
        }
        synchronized (mLock) {
        synchronized (mLock) {
            final int indexOfSession = mChildSessionIds.indexOfKey(childSessionId);
            final int indexOfSession = mChildSessionIds.indexOfKey(childSessionId);
+6 −1
Original line number Original line Diff line number Diff line
@@ -417,7 +417,12 @@ public class StagingManager {
                if (apkChildSession == null) {
                if (apkChildSession == null) {
                    return false;
                    return false;
                }
                }
                try {
                    apkParentSession.addChildSessionId(apkChildSession.sessionId);
                    apkParentSession.addChildSessionId(apkChildSession.sessionId);
                } catch (RemoteException e) {
                    Slog.e(TAG, "Failed to add a child session for installing the APK files", e);
                    return false;
                }
            }
            }
            return commitApkSession(apkParentSession, session.sessionId);
            return commitApkSession(apkParentSession, session.sessionId);
        }
        }