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

Commit 6080c8fe authored by Alex Buynytskyy's avatar Alex Buynytskyy Committed by Automerger Merge Worker
Browse files

Merge "Mark all installations using PMSC as "ADB"." into tm-dev am: 3edaff19

Original change: https://googleplex-android-review.googlesource.com/c/platform/frameworks/base/+/17272503

Change-Id: I58d445c3afb44479344229b54a1d10c53760ada3
parents b516d1c4 3edaff19
Loading
Loading
Loading
Loading
+3 −3
Original line number Diff line number Diff line
@@ -640,7 +640,8 @@ public class PackageInstallerService extends IPackageInstaller.Stub implements
                && params.installerPackageName.length() < SessionParams.MAX_PACKAGE_NAME_LENGTH)
                ? params.installerPackageName : installerPackageName;

        if ((callingUid == Process.SHELL_UID) || (callingUid == Process.ROOT_UID)) {
        if ((callingUid == Process.SHELL_UID) || (callingUid == Process.ROOT_UID)
                || PackageInstallerSession.isSystemDataLoaderInstallation(params)) {
            params.installFlags |= PackageManager.INSTALL_FROM_ADB;
            // adb installs can override the installingPackageName, but not the
            // initiatingPackageName
@@ -666,8 +667,7 @@ public class PackageInstallerService extends IPackageInstaller.Stub implements
                    && !mPm.isCallerVerifier(snapshot, callingUid)) {
                params.installFlags &= ~PackageManager.INSTALL_VIRTUAL_PRELOAD;
            }
            if (mContext.checkCallingOrSelfPermission(
                    Manifest.permission.INSTALL_TEST_ONLY_PACKAGE)
            if (mContext.checkCallingOrSelfPermission(Manifest.permission.INSTALL_TEST_ONLY_PACKAGE)
                    != PackageManager.PERMISSION_GRANTED) {
                params.installFlags &= ~PackageManager.INSTALL_ALLOW_TEST;
            }
+31 −21
Original line number Diff line number Diff line
@@ -29,7 +29,6 @@ import static android.content.pm.PackageManager.INSTALL_FAILED_INTERNAL_ERROR;
import static android.content.pm.PackageManager.INSTALL_FAILED_INVALID_APK;
import static android.content.pm.PackageManager.INSTALL_FAILED_MEDIA_UNAVAILABLE;
import static android.content.pm.PackageManager.INSTALL_FAILED_MISSING_SPLIT;
import static android.content.pm.PackageManager.INSTALL_FROM_ADB;
import static android.content.pm.PackageManager.INSTALL_PARSE_FAILED_NO_CERTIFICATES;
import static android.content.pm.PackageManager.INSTALL_STAGED;
import static android.content.pm.PackageManager.INSTALL_SUCCEEDED;
@@ -705,6 +704,18 @@ public class PackageInstallerSession extends IPackageInstallerSession.Stub {
        }
    };

    static boolean isDataLoaderInstallation(SessionParams params) {
        return params.dataLoaderParams != null;
    }

    static boolean isSystemDataLoaderInstallation(SessionParams params) {
        if (!isDataLoaderInstallation(params)) {
            return false;
        }
        return SYSTEM_DATA_LOADER_PACKAGE.equals(
                params.dataLoaderParams.getComponentName().getPackageName());
    }

    private final Handler.Callback mHandlerCallback = new Handler.Callback() {
        @Override
        public boolean handleMessage(Message msg) {
@@ -744,7 +755,7 @@ public class PackageInstallerSession extends IPackageInstallerSession.Stub {
    };

    private boolean isDataLoaderInstallation() {
        return params.dataLoaderParams != null;
        return isDataLoaderInstallation(this.params);
    }

    private boolean isStreamingInstallation() {
@@ -756,11 +767,7 @@ public class PackageInstallerSession extends IPackageInstallerSession.Stub {
    }

    private boolean isSystemDataLoaderInstallation() {
        if (!isDataLoaderInstallation()) {
            return false;
        }
        return SYSTEM_DATA_LOADER_PACKAGE.equals(
                this.params.dataLoaderParams.getComponentName().getPackageName());
        return isSystemDataLoaderInstallation(this.params);
    }

    /**
@@ -957,18 +964,13 @@ public class PackageInstallerSession extends IPackageInstallerSession.Stub {
                        "DataLoader installation of APEX modules is not allowed.");
            }

            if (isSystemDataLoaderInstallation()) {
                if (mContext.checkCallingOrSelfPermission(
            if (isSystemDataLoaderInstallation() && mContext.checkCallingOrSelfPermission(
                    Manifest.permission.USE_SYSTEM_DATA_LOADERS)
                    != PackageManager.PERMISSION_GRANTED) {
                throw new SecurityException("You need the "
                        + "com.android.permission.USE_SYSTEM_DATA_LOADERS permission "
                        + "to use system data loaders");
            }

                // All installations using system dataloaders marked as ADB.
                this.params.installFlags |= INSTALL_FROM_ADB;
            }
        }

        if (isIncrementalInstallation() && !IncrementalManager.isAllowed()) {
@@ -1264,13 +1266,21 @@ public class PackageInstallerSession extends IPackageInstallerSession.Stub {
            return;
        }

        final String initiatingPackageName = getInstallSource().initiatingPackageName;
        final String installerPackageName;
        if (!TextUtils.isEmpty(getInstallSource().initiatingPackageName)) {
            installerPackageName = getInstallSource().initiatingPackageName;
        } else {
            installerPackageName = getInstallSource().installerPackageName;
        }
        if (TextUtils.isEmpty(installerPackageName)) {
            throw new IllegalStateException("Installer package is empty.");
        }

        final AppOpsManager appOps = mContext.getSystemService(AppOpsManager.class);
        appOps.checkPackage(Binder.getCallingUid(), initiatingPackageName);
        appOps.checkPackage(Binder.getCallingUid(), installerPackageName);

        final PackageManagerInternal pmi = LocalServices.getService(PackageManagerInternal.class);
        final AndroidPackage callingInstaller = pmi.getPackage(initiatingPackageName);
        final AndroidPackage callingInstaller = pmi.getPackage(installerPackageName);
        if (callingInstaller == null) {
            throw new IllegalStateException("Can't obtain calling installer's package.");
        }
+11 −2
Original line number Diff line number Diff line
@@ -1254,9 +1254,18 @@ public class PackageManagerService implements PackageSender, TestUtilityService
        if (applicationInfo == null) {
            throw new ParcelableException(new PackageManager.NameNotFoundException(packageName));
        }

        final InstallSourceInfo installSourceInfo = snapshot.getInstallSourceInfo(packageName);
        final String installerPackageName =
                installSourceInfo != null ? installSourceInfo.getInitiatingPackageName() : null;
        final String installerPackageName;
        if (installSourceInfo != null) {
            if (!TextUtils.isEmpty(installSourceInfo.getInitiatingPackageName())) {
                installerPackageName = installSourceInfo.getInitiatingPackageName();
            } else {
                installerPackageName = installSourceInfo.getInstallingPackageName();
            }
        } else {
            installerPackageName = null;
        }

        List<Pair<String, File>> filesToChecksum = new ArrayList<>();

+6 −1
Original line number Diff line number Diff line
@@ -111,6 +111,11 @@ static bool getAlwaysEnableReadTimeoutsForSystemDataLoaders() {
                            true);
}

static bool getEnableReadTimeoutsAfterInstall() {
    return android::base::GetBoolProperty("debug.incremental.enable_read_timeouts_after_install",
                                          true);
}

static bool getEnforceReadLogsMaxIntervalForSystemDataLoaders() {
    return android::base::GetBoolProperty("debug.incremental.enforce_readlogs_max_interval_for_"
                                          "system_dataloaders",
@@ -853,7 +858,7 @@ void IncrementalService::onInstallationComplete(StorageId storage) {

    // Always enable long read timeouts after installation is complete.
    std::unique_lock l(ifs->lock);
    ifs->setReadTimeoutsRequested(true);
    ifs->setReadTimeoutsRequested(getEnableReadTimeoutsAfterInstall());
    applyStorageParamsLocked(*ifs);
}