Loading services/core/java/com/android/server/pm/PackageManagerService.java +3 −7 Original line number Diff line number Diff line Loading @@ -84,7 +84,6 @@ import android.content.pm.IOnChecksumsReadyListener; import android.content.pm.IPackageDataObserver; import android.content.pm.IPackageDeleteObserver2; import android.content.pm.IPackageLoadingProgressCallback; import android.content.pm.IPackageManager; import android.content.pm.IPackageMoveObserver; import android.content.pm.IncrementalStatesInfo; import android.content.pm.InstallSourceInfo; Loading Loading @@ -1460,7 +1459,8 @@ public class PackageManagerService implements PackageSender, TestUtilityService } }; public static Pair<PackageManagerService, IPackageManager> main(Context context, /** Starts PackageManagerService. */ public static PackageManagerService main(Context context, Installer installer, @NonNull DomainVerificationService domainVerificationService, boolean factoryTest) { // Self-check for initial settings. Loading Loading @@ -1590,7 +1590,7 @@ public class PackageManagerService implements PackageSender, TestUtilityService ServiceManager.addService("package_native", pmn); LocalManagerRegistry.addManager(PackageManagerLocal.class, new PackageManagerLocalImpl(m)); return Pair.create(m, iPackageManager); return m; } /** Install/uninstall system packages for all users based on their user-type, as applicable. */ Loading Loading @@ -5287,10 +5287,6 @@ public class PackageManagerService implements PackageSender, TestUtilityService Map<String, String> classLoaderContextMap, String loaderIsa) { int callingUid = Binder.getCallingUid(); // TODO(b/254043366): System server should not report its own dex load because there's // nothing ART can do with it. Computer snapshot = snapshot(); // System server should be able to report dex load on behalf of other apps. E.g., it Loading services/core/java/com/android/server/pm/dex/SystemServerDexLoadReporter.javadeleted 100644 → 0 +0 −83 Original line number Diff line number Diff line /* * Copyright (C) 2020 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.dex; import static com.android.server.pm.PackageManagerService.PLATFORM_PACKAGE_NAME; import android.content.pm.IPackageManager; import android.os.RemoteException; import android.util.Log; import android.util.Slog; import dalvik.system.BaseDexClassLoader; import dalvik.system.VMRuntime; import java.util.Map; /** * Reports dex file use to the package manager on behalf of system server. */ public class SystemServerDexLoadReporter implements BaseDexClassLoader.Reporter { private static final String TAG = "SystemServerDexLoadReporter"; private static final boolean DEBUG = Log.isLoggable(TAG, Log.DEBUG); private final IPackageManager mPackageManager; private SystemServerDexLoadReporter(IPackageManager pm) { mPackageManager = pm; } @Override public void report(Map<String, String> classLoaderContextMap) { if (DEBUG) { Slog.i(TAG, "Reporting " + classLoaderContextMap); } if (classLoaderContextMap.isEmpty()) { Slog.wtf(TAG, "Bad call to DexLoadReporter: empty classLoaderContextMap"); return; } try { mPackageManager.notifyDexLoad( PLATFORM_PACKAGE_NAME, classLoaderContextMap, VMRuntime.getRuntime().vmInstructionSet()); } catch (RemoteException ignored) { // We're in system server, it can't happen. } } /** * Configures system server dex file reporting. * <p>The method will install a reporter in the BaseDexClassLoader and also * force the reporting of any dex files already loaded by the system server. */ public static void configureSystemServerDexReporter(IPackageManager pm) { Slog.i(TAG, "Configuring system server dex reporter"); SystemServerDexLoadReporter reporter = new SystemServerDexLoadReporter(pm); BaseDexClassLoader.setReporter(reporter); ClassLoader currrentClassLoader = reporter.getClass().getClassLoader(); if (currrentClassLoader instanceof BaseDexClassLoader) { ((BaseDexClassLoader) currrentClassLoader).reportClassLoaderChain(); } else { Slog.wtf(TAG, "System server class loader is not a BaseDexClassLoader. type=" + currrentClassLoader.getClass().getName()); } } } services/java/com/android/server/SystemServer.java +1 −11 Original line number Diff line number Diff line Loading @@ -41,7 +41,6 @@ import android.app.usage.UsageStatsManagerInternal; import android.content.ContentResolver; import android.content.Context; import android.content.Intent; import android.content.pm.IPackageManager; import android.content.pm.PackageItemInfo; import android.content.pm.PackageManager; import android.content.pm.PackageManagerInternal; Loading Loading @@ -168,7 +167,6 @@ import com.android.server.pm.PackageManagerService; import com.android.server.pm.ShortcutService; import com.android.server.pm.UserManagerService; import com.android.server.pm.dex.OdsignStatsLogger; import com.android.server.pm.dex.SystemServerDexLoadReporter; import com.android.server.pm.verify.domain.DomainVerificationService; import com.android.server.policy.AppOpsPolicy; import com.android.server.policy.PermissionPolicyService; Loading Loading @@ -1210,24 +1208,16 @@ public final class SystemServer implements Dumpable { mSystemServiceManager.startService(domainVerificationService); t.traceEnd(); IPackageManager iPackageManager; t.traceBegin("StartPackageManagerService"); try { Watchdog.getInstance().pauseWatchingCurrentThread("packagemanagermain"); Pair<PackageManagerService, IPackageManager> pmsPair = PackageManagerService.main( mPackageManagerService = PackageManagerService.main( mSystemContext, installer, domainVerificationService, mFactoryTestMode != FactoryTest.FACTORY_TEST_OFF); mPackageManagerService = pmsPair.first; iPackageManager = pmsPair.second; } finally { Watchdog.getInstance().resumeWatchingCurrentThread("packagemanagermain"); } // Now that the package manager has started, register the dex load reporter to capture any // dex files loaded by system server. // These dex files will be optimized by the BackgroundDexOptService. SystemServerDexLoadReporter.configureSystemServerDexReporter(iPackageManager); mFirstBoot = mPackageManagerService.isFirstBoot(); mPackageManager = mSystemContext.getPackageManager(); t.traceEnd(); Loading Loading
services/core/java/com/android/server/pm/PackageManagerService.java +3 −7 Original line number Diff line number Diff line Loading @@ -84,7 +84,6 @@ import android.content.pm.IOnChecksumsReadyListener; import android.content.pm.IPackageDataObserver; import android.content.pm.IPackageDeleteObserver2; import android.content.pm.IPackageLoadingProgressCallback; import android.content.pm.IPackageManager; import android.content.pm.IPackageMoveObserver; import android.content.pm.IncrementalStatesInfo; import android.content.pm.InstallSourceInfo; Loading Loading @@ -1460,7 +1459,8 @@ public class PackageManagerService implements PackageSender, TestUtilityService } }; public static Pair<PackageManagerService, IPackageManager> main(Context context, /** Starts PackageManagerService. */ public static PackageManagerService main(Context context, Installer installer, @NonNull DomainVerificationService domainVerificationService, boolean factoryTest) { // Self-check for initial settings. Loading Loading @@ -1590,7 +1590,7 @@ public class PackageManagerService implements PackageSender, TestUtilityService ServiceManager.addService("package_native", pmn); LocalManagerRegistry.addManager(PackageManagerLocal.class, new PackageManagerLocalImpl(m)); return Pair.create(m, iPackageManager); return m; } /** Install/uninstall system packages for all users based on their user-type, as applicable. */ Loading Loading @@ -5287,10 +5287,6 @@ public class PackageManagerService implements PackageSender, TestUtilityService Map<String, String> classLoaderContextMap, String loaderIsa) { int callingUid = Binder.getCallingUid(); // TODO(b/254043366): System server should not report its own dex load because there's // nothing ART can do with it. Computer snapshot = snapshot(); // System server should be able to report dex load on behalf of other apps. E.g., it Loading
services/core/java/com/android/server/pm/dex/SystemServerDexLoadReporter.javadeleted 100644 → 0 +0 −83 Original line number Diff line number Diff line /* * Copyright (C) 2020 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.dex; import static com.android.server.pm.PackageManagerService.PLATFORM_PACKAGE_NAME; import android.content.pm.IPackageManager; import android.os.RemoteException; import android.util.Log; import android.util.Slog; import dalvik.system.BaseDexClassLoader; import dalvik.system.VMRuntime; import java.util.Map; /** * Reports dex file use to the package manager on behalf of system server. */ public class SystemServerDexLoadReporter implements BaseDexClassLoader.Reporter { private static final String TAG = "SystemServerDexLoadReporter"; private static final boolean DEBUG = Log.isLoggable(TAG, Log.DEBUG); private final IPackageManager mPackageManager; private SystemServerDexLoadReporter(IPackageManager pm) { mPackageManager = pm; } @Override public void report(Map<String, String> classLoaderContextMap) { if (DEBUG) { Slog.i(TAG, "Reporting " + classLoaderContextMap); } if (classLoaderContextMap.isEmpty()) { Slog.wtf(TAG, "Bad call to DexLoadReporter: empty classLoaderContextMap"); return; } try { mPackageManager.notifyDexLoad( PLATFORM_PACKAGE_NAME, classLoaderContextMap, VMRuntime.getRuntime().vmInstructionSet()); } catch (RemoteException ignored) { // We're in system server, it can't happen. } } /** * Configures system server dex file reporting. * <p>The method will install a reporter in the BaseDexClassLoader and also * force the reporting of any dex files already loaded by the system server. */ public static void configureSystemServerDexReporter(IPackageManager pm) { Slog.i(TAG, "Configuring system server dex reporter"); SystemServerDexLoadReporter reporter = new SystemServerDexLoadReporter(pm); BaseDexClassLoader.setReporter(reporter); ClassLoader currrentClassLoader = reporter.getClass().getClassLoader(); if (currrentClassLoader instanceof BaseDexClassLoader) { ((BaseDexClassLoader) currrentClassLoader).reportClassLoaderChain(); } else { Slog.wtf(TAG, "System server class loader is not a BaseDexClassLoader. type=" + currrentClassLoader.getClass().getName()); } } }
services/java/com/android/server/SystemServer.java +1 −11 Original line number Diff line number Diff line Loading @@ -41,7 +41,6 @@ import android.app.usage.UsageStatsManagerInternal; import android.content.ContentResolver; import android.content.Context; import android.content.Intent; import android.content.pm.IPackageManager; import android.content.pm.PackageItemInfo; import android.content.pm.PackageManager; import android.content.pm.PackageManagerInternal; Loading Loading @@ -168,7 +167,6 @@ import com.android.server.pm.PackageManagerService; import com.android.server.pm.ShortcutService; import com.android.server.pm.UserManagerService; import com.android.server.pm.dex.OdsignStatsLogger; import com.android.server.pm.dex.SystemServerDexLoadReporter; import com.android.server.pm.verify.domain.DomainVerificationService; import com.android.server.policy.AppOpsPolicy; import com.android.server.policy.PermissionPolicyService; Loading Loading @@ -1210,24 +1208,16 @@ public final class SystemServer implements Dumpable { mSystemServiceManager.startService(domainVerificationService); t.traceEnd(); IPackageManager iPackageManager; t.traceBegin("StartPackageManagerService"); try { Watchdog.getInstance().pauseWatchingCurrentThread("packagemanagermain"); Pair<PackageManagerService, IPackageManager> pmsPair = PackageManagerService.main( mPackageManagerService = PackageManagerService.main( mSystemContext, installer, domainVerificationService, mFactoryTestMode != FactoryTest.FACTORY_TEST_OFF); mPackageManagerService = pmsPair.first; iPackageManager = pmsPair.second; } finally { Watchdog.getInstance().resumeWatchingCurrentThread("packagemanagermain"); } // Now that the package manager has started, register the dex load reporter to capture any // dex files loaded by system server. // These dex files will be optimized by the BackgroundDexOptService. SystemServerDexLoadReporter.configureSystemServerDexReporter(iPackageManager); mFirstBoot = mPackageManagerService.isFirstBoot(); mPackageManager = mSystemContext.getPackageManager(); t.traceEnd(); Loading