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

Commit 2b8d5db1 authored by Martin Stjernholm's avatar Martin Stjernholm Committed by Android (Google) Code Review
Browse files

Merge "Retire the dalvik.vm.useartservice system property." into main

parents 5fea62d5 a4e60b3b
Loading
Loading
Loading
Loading
+0 −16
Original line number Diff line number Diff line
@@ -45,7 +45,6 @@ import android.util.SparseArray;

import com.android.internal.pm.pkg.component.ParsedMainComponent;
import com.android.internal.util.function.pooled.PooledLambda;
import com.android.server.pm.Installer.LegacyDexoptDisabledException;
import com.android.server.pm.KnownPackages;
import com.android.server.pm.PackageArchiver;
import com.android.server.pm.PackageList;
@@ -1396,21 +1395,6 @@ public abstract class PackageManagerInternal {
            @UserIdInt int userId, @Nullable String recentCallingPackage,
            @NonNull String debugInfo);

    /** @deprecated For legacy shell command only. */
    @Deprecated
    public abstract void legacyDumpProfiles(@NonNull String packageName,
            boolean dumpClassesAndMethods) throws LegacyDexoptDisabledException;

    /** @deprecated For legacy shell command only. */
    @Deprecated
    public abstract void legacyForceDexOpt(@NonNull String packageName)
            throws LegacyDexoptDisabledException;

    /** @deprecated For legacy shell command only. */
    @Deprecated
    public abstract void legacyReconcileSecondaryDexFiles(String packageName)
            throws LegacyDexoptDisabledException;

    /**
     * Gets {@link PackageManager.DistractionRestriction restrictions} of the given
     * packages of the given user.
+1 −59
Original line number Diff line number Diff line
@@ -45,7 +45,6 @@ import android.util.TimingsTraceLog;
import com.android.internal.annotations.GuardedBy;
import com.android.internal.util.Preconditions;
import com.android.server.SystemServerInitThreadPool;
import com.android.server.pm.Installer.LegacyDexoptDisabledException;
import com.android.server.pm.dex.ArtManagerService;
import com.android.server.pm.parsing.pkg.AndroidPackageUtils;
import com.android.server.pm.pkg.AndroidPackage;
@@ -256,41 +255,6 @@ public class AppDataHelper {
                }
            }

            if (!DexOptHelper.useArtService()) { // ART Service handles this on demand instead.
                // Prepare the application profiles only for upgrades and
                // first boot (so that we don't repeat the same operation at
                // each boot).
                //
                // We only have to cover the upgrade and first boot here
                // because for app installs we prepare the profiles before
                // invoking dexopt (in installPackageLI).
                //
                // We also have to cover non system users because we do not
                // call the usual install package methods for them.
                //
                // NOTE: in order to speed up first boot time we only create
                // the current profile and do not update the content of the
                // reference profile. A system image should already be
                // configured with the right profile keys and the profiles
                // for the speed-profile prebuilds should already be copied.
                // That's done in #performDexOptUpgrade.
                //
                // TODO(calin, mathieuc): We should use .dm files for
                // prebuilds profiles instead of manually copying them in
                // #performDexOptUpgrade. When we do that we should have a
                // more granular check here and only update the existing
                // profiles.
                if (pkg != null && (mPm.isDeviceUpgrading() || mPm.isFirstBoot()
                        || (userId != UserHandle.USER_SYSTEM))) {
                    try {
                        mArtManagerService.prepareAppProfiles(pkg, userId,
                                /* updateReferenceProfileContent= */ false);
                    } catch (LegacyDexoptDisabledException e2) {
                        throw new RuntimeException(e2);
                    }
                }
            }

            final long ceDataInode = createAppDataResult.ceDataInode;
            final long deDataInode = createAppDataResult.deDataInode;

@@ -615,15 +579,7 @@ public class AppDataHelper {
            Slog.wtf(TAG, "Package was null!", new Throwable());
            return;
        }
        if (DexOptHelper.useArtService()) {
            destroyAppProfilesWithArtService(pkg.getPackageName());
        } else {
            try {
                mArtManagerService.clearAppProfiles(pkg);
            } catch (LegacyDexoptDisabledException e) {
                throw new RuntimeException(e);
            }
        }
        destroyAppProfilesLIF(pkg.getPackageName());
    }

    public void destroyAppDataLIF(AndroidPackage pkg, int userId, int flags) {
@@ -657,20 +613,6 @@ public class AppDataHelper {
     * Destroy ART app profiles for the package.
     */
    void destroyAppProfilesLIF(String packageName) {
        if (DexOptHelper.useArtService()) {
            destroyAppProfilesWithArtService(packageName);
        } else {
            try {
                mInstaller.destroyAppProfiles(packageName);
            } catch (LegacyDexoptDisabledException e) {
                throw new RuntimeException(e);
            } catch (Installer.InstallerException e) {
                Slog.w(TAG, String.valueOf(e));
            }
        }
    }

    private void destroyAppProfilesWithArtService(String packageName) {
        if (!DexOptHelper.artManagerLocalIsInitialized()) {
            // This function may get called while PackageManagerService is constructed (via e.g.
            // InitAppsHelper.initSystemApps), and ART Service hasn't yet been started then (it
+0 −37
Original line number Diff line number Diff line
/*
 * Copyright (C) 2021 The Android Open Source Project
 *
 * Licensed under the Apache License, Version 2.0 (the "License");
 * you may not use this file except in compliance with the License.
 * You may obtain a copy of the License at
 *
 *      http://www.apache.org/licenses/LICENSE-2.0
 *
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS,
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 * See the License for the specific language governing permissions and
 * limitations under the License.
 */

package com.android.server.pm;

import android.app.job.JobParameters;
import android.app.job.JobService;

/**
 * JobService to run background dex optimization. This is a thin wrapper and most logic exits in
 * {@link BackgroundDexOptService}.
 */
public final class BackgroundDexOptJobService extends JobService {

    @Override
    public boolean onStartJob(JobParameters params) {
        return BackgroundDexOptService.getService().onStartJob(this, params);
    }

    @Override
    public boolean onStopJob(JobParameters params) {
        return BackgroundDexOptService.getService().onStopJob(this, params);
    }
}
+0 −1152

File deleted.

Preview size limit exceeded, changes collapsed.

+1 −37
Original line number Diff line number Diff line
@@ -137,7 +137,6 @@ import com.android.internal.util.CollectionUtils;
import com.android.internal.util.IndentingPrintWriter;
import com.android.internal.util.Preconditions;
import com.android.modules.utils.TypedXmlSerializer;
import com.android.server.pm.Installer.LegacyDexoptDisabledException;
import com.android.server.pm.dex.DexManager;
import com.android.server.pm.dex.PackageDexUsage;
import com.android.server.pm.parsing.PackageInfoUtils;
@@ -419,7 +418,6 @@ public class ComputerEngine implements Computer {
    private final PackageDexOptimizer mPackageDexOptimizer;
    private final DexManager mDexManager;
    private final CompilerStats mCompilerStats;
    private final BackgroundDexOptService mBackgroundDexOptService;
    private final PackageManagerInternal.ExternalSourcesPolicy mExternalSourcesPolicy;
    private final CrossProfileIntentResolverEngine mCrossProfileIntentResolverEngine;

@@ -472,7 +470,6 @@ public class ComputerEngine implements Computer {
        mPackageDexOptimizer = args.service.mPackageDexOptimizer;
        mDexManager = args.service.getDexManager();
        mCompilerStats = args.service.mCompilerStats;
        mBackgroundDexOptService = args.service.mBackgroundDexOptService;
        mExternalSourcesPolicy = args.service.mExternalSourcesPolicy;
        mCrossProfileIntentResolverEngine = new CrossProfileIntentResolverEngine(
                mUserManager, mDomainVerificationManager, mDefaultAppProvider, mContext);
@@ -3093,40 +3090,7 @@ public class ComputerEngine implements Computer {
                }
                ipw.println("Dexopt state:");
                ipw.increaseIndent();
                if (DexOptHelper.useArtService()) {
                DexOptHelper.dumpDexoptState(ipw, packageName);
                } else {
                    Collection<? extends PackageStateInternal> pkgSettings;
                    if (setting != null) {
                        pkgSettings = Collections.singletonList(setting);
                    } else {
                        pkgSettings = mSettings.getPackages().values();
                    }

                    for (PackageStateInternal pkgSetting : pkgSettings) {
                        final AndroidPackage pkg = pkgSetting.getPkg();
                        if (pkg == null || pkg.isApex()) {
                            // Skip APEX which is not dex-optimized
                            continue;
                        }
                        final String pkgName = pkg.getPackageName();
                        ipw.println("[" + pkgName + "]");
                        ipw.increaseIndent();

                        // TODO(b/251903639): Call into ART Service.
                        try {
                            mPackageDexOptimizer.dumpDexoptState(ipw, pkg, pkgSetting,
                                    mDexManager.getPackageUseInfoOrDefault(pkgName));
                        } catch (LegacyDexoptDisabledException e) {
                            throw new RuntimeException(e);
                        }
                        ipw.decreaseIndent();
                    }
                    ipw.println("BgDexopt state:");
                    ipw.increaseIndent();
                    mBackgroundDexOptService.dump(ipw);
                    ipw.decreaseIndent();
                }
                ipw.decreaseIndent();
                break;
            }
Loading