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

Commit eef1b3b1 authored by TreeHugger Robot's avatar TreeHugger Robot Committed by Android (Google) Code Review
Browse files

Merge "Throw appropriate exception for session transferring"

parents 6b792986 b19810da
Loading
Loading
Loading
Loading
+5 −2
Original line number Diff line number Diff line
@@ -53,10 +53,12 @@ import android.os.SystemProperties;
import android.os.UserHandle;
import android.system.ErrnoException;
import android.system.Os;
import android.text.TextUtils;
import android.util.ArraySet;
import android.util.ExceptionUtils;

import com.android.internal.util.IndentingPrintWriter;
import com.android.internal.util.Preconditions;
import com.android.internal.util.function.pooled.PooledLambda;

import java.io.Closeable;
@@ -1349,12 +1351,13 @@ public class PackageInstaller {
         *
         * @throws PackageManager.NameNotFoundException if the new owner could not be found.
         * @throws SecurityException if called after the session has been committed or abandoned.
         * @throws IllegalArgumentException if streams opened through
         * @throws IllegalStateException if streams opened through
         *                                  {@link #openWrite(String, long, long) are still open.
         * @throws IllegalArgumentException if {@code packageName} is invalid.
         */
        public void transfer(@NonNull String packageName)
                throws PackageManager.NameNotFoundException {
            Objects.requireNonNull(packageName);
            Preconditions.checkArgument(!TextUtils.isEmpty(packageName));

            try {
                mSession.transfer(packageName);
+2 −2
Original line number Diff line number Diff line
@@ -1805,7 +1805,7 @@ public class PackageInstallerSession extends IPackageInstallerSession.Stub {

    @Override
    public void transfer(String packageName) {
        Objects.requireNonNull(packageName);
        Preconditions.checkArgument(!TextUtils.isEmpty(packageName));

        ApplicationInfo newOwnerAppInfo = mPm.getApplicationInfo(packageName, 0, userId);
        if (newOwnerAppInfo == null) {
@@ -1831,7 +1831,7 @@ public class PackageInstallerSession extends IPackageInstallerSession.Stub {
            try {
                sealLocked();
            } catch (PackageManagerException e) {
                throw new IllegalArgumentException("Package is not valid", e);
                throw new IllegalStateException("Package is not valid", e);
            }

            mInstallerUid = newOwnerAppInfo.uid;