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

Commit 5028fb03 authored by Jeff Sharkey's avatar Jeff Sharkey Committed by Android (Google) Code Review
Browse files

Merge "Pass install result message; path selection." into lmp-dev

parents d4ce7e52 ad11eb52
Loading
Loading
Loading
Loading
+19 −21
Original line number Diff line number Diff line
@@ -50,6 +50,7 @@ import android.os.RemoteException;
import android.os.ServiceManager;
import android.os.UserHandle;
import android.os.UserManager;
import android.text.TextUtils;
import android.util.Log;

import com.android.internal.content.PackageHelper;
@@ -923,33 +924,13 @@ public final class Pm {
                    return;
                }
            } else if (opt.equals("--abi")) {
                abi = nextOptionData();
                if (abi == null) {
                    System.err.println("Error: must supply argument for --abi");
                    return;
                }
                abi = checkAbiArgument(nextOptionData());
            } else {
                System.err.println("Error: Unknown option: " + opt);
                return;
            }
        }

        if (abi != null) {
            final String[] supportedAbis = Build.SUPPORTED_ABIS;
            boolean matched = false;
            for (String supportedAbi : supportedAbis) {
                if (supportedAbi.equals(abi)) {
                    matched = true;
                    break;
                }
            }

            if (!matched) {
                System.err.println("Error: abi " + abi + " not supported on this device.");
                return;
            }
        }

        final Uri verificationURI;
        final Uri originatingURI;
        final Uri referrerURI;
@@ -1044,6 +1025,8 @@ public final class Pm {
            } else if (opt.equals("-S")) {
                params.deltaSize = Long.parseLong(nextOptionData());
                params.progressMax = (int) params.deltaSize;
            } else if (opt.equals("--abi")) {
                params.abiOverride = checkAbiArgument(nextOptionData());
            } else {
                throw new IllegalArgumentException("Unknown option " + opt);
            }
@@ -1684,6 +1667,21 @@ public final class Pm {
        }
    }

    private static String checkAbiArgument(String abi) {
        if (TextUtils.isEmpty(abi)) {
            throw new IllegalArgumentException("Missing ABI argument");
        }

        final String[] supportedAbis = Build.SUPPORTED_ABIS;
        for (String supportedAbi : supportedAbis) {
            if (supportedAbi.equals(abi)) {
                return abi;
            }
        }

        throw new IllegalArgumentException("ABI " + abi + " not supported on this device");
    }

    private String nextOption() {
        if (mNextArg >= mArgs.length) {
            return null;
+1 −1
Original line number Diff line number Diff line
@@ -25,7 +25,7 @@ public class PackageInstallObserver {
        @Override
        public void packageInstalled(String basePackageName, Bundle extras, int returnCode,
                String msg) {
            PackageInstallObserver.this.packageInstalled(basePackageName, extras, returnCode);
            PackageInstallObserver.this.packageInstalled(basePackageName, extras, returnCode, msg);
        }
    };

+2 −1
Original line number Diff line number Diff line
@@ -177,7 +177,8 @@ public class PackageInstallerSession extends IPackageInstallerSession.Stub {
    @Override
    public void setClientProgress(int progress) {
        mClientProgress = progress;
        mProgress = MathUtils.constrain((mClientProgress * 8 * 100) / (params.progressMax * 10), 0, 80);
        mProgress = MathUtils.constrain(
                (int) (((float) mClientProgress) / ((float) params.progressMax)) * 80, 0, 80);
        mCallback.onSessionProgress(this, mProgress);
    }

+17 −3
Original line number Diff line number Diff line
@@ -9331,14 +9331,18 @@ public class PackageManagerService extends IPackageManager.Stub {
                return false;
            } else {
                final File beforeCodeFile = codeFile;
                final File afterCodeFile = new File(mAppInstallDir,
                        getNextCodePath(oldCodePath, pkg.packageName, null));
                final File afterCodeFile = getNextCodePath(pkg.packageName);
                Slog.d(TAG, "Renaming " + beforeCodeFile + " to " + afterCodeFile);
                if (!beforeCodeFile.renameTo(afterCodeFile)) {
                try {
                    Os.rename(beforeCodeFile.getAbsolutePath(), afterCodeFile.getAbsolutePath());
                } catch (ErrnoException e) {
                    Slog.d(TAG, "Failed to rename", e);
                    return false;
                }
                if (!SELinux.restoreconRecursive(afterCodeFile)) {
                    Slog.d(TAG, "Failed to restorecon");
                    return false;
                }
@@ -9811,6 +9815,16 @@ public class PackageManagerService extends IPackageManager.Stub {
        return prefix + idxStr;
    }
    private File getNextCodePath(String packageName) {
        int suffix = 1;
        File result;
        do {
            result = new File(mAppInstallDir, packageName + "-" + suffix);
            suffix++;
        } while (result.exists());
        return result;
    }
    // Utility method used to ignore ADD/REMOVE events
    // by directory observer.
    private static boolean ignoreCodePath(String fullPathStr) {