diff options
author | Jiakai Zhang <jiakaiz@google.com> | 2024-05-03 12:19:48 +0100 |
---|---|---|
committer | Jiakai Zhang <jiakaiz@google.com> | 2024-05-03 16:16:48 +0000 |
commit | a3d056ef58b96a995abdb7213c51b9877f3f45f9 (patch) | |
tree | c1c5c63271ddb5f3e736d1a520aef1482a7e67d6 | |
parent | 51300eb2b71936ec69ab6737a2270b5019b6b888 (diff) | |
download | art-a3d056ef58b96a995abdb7213c51b9877f3f45f9.tar.gz |
Set the ART Service log tag to "ArtServicePreReboot" for Pre-Reboot.
Bug: 311377497
Test: manual - Run Pre-Reboot Dexopt and check logcat.
Change-Id: Ib5ca2dd270fb7373f8e16aa4879c082f89d96a1a
17 files changed, 148 insertions, 115 deletions
diff --git a/libartservice/service/java/com/android/server/art/ArtFileManager.java b/libartservice/service/java/com/android/server/art/ArtFileManager.java index 234ca01f7c..754b9ec1dd 100644 --- a/libartservice/service/java/com/android/server/art/ArtFileManager.java +++ b/libartservice/service/java/com/android/server/art/ArtFileManager.java @@ -29,7 +29,6 @@ import android.os.RemoteException; import android.os.ServiceSpecificException; import android.os.UserHandle; import android.os.UserManager; -import android.util.Log; import android.util.Pair; import androidx.annotation.RequiresApi; @@ -57,8 +56,6 @@ import java.util.Objects; */ @RequiresApi(Build.VERSION_CODES.UPSIDE_DOWN_CAKE) public class ArtFileManager { - private static final String TAG = ArtManagerLocal.TAG; - @NonNull private final Injector mInjector; public ArtFileManager(@NonNull Context context) { @@ -170,8 +167,7 @@ public class ArtFileManager { } } } catch (ServiceSpecificException e) { - Log.e(TAG, - String.format( + AsLog.e(String.format( "Failed to get dexopt status [packageName = %s, dexPath = %s, " + "isa = %s, classLoaderContext = %s]", pkgState.getPackageName(), dexInfo.dexPath(), abi.isa(), diff --git a/libartservice/service/java/com/android/server/art/ArtJni.java b/libartservice/service/java/com/android/server/art/ArtJni.java index 61384ca5f6..d46b889460 100644 --- a/libartservice/service/java/com/android/server/art/ArtJni.java +++ b/libartservice/service/java/com/android/server/art/ArtJni.java @@ -20,7 +20,6 @@ import android.annotation.NonNull; import android.annotation.Nullable; import android.os.Build; import android.os.RemoteException; -import android.util.Log; import androidx.annotation.RequiresApi; diff --git a/libartservice/service/java/com/android/server/art/ArtManagerLocal.java b/libartservice/service/java/com/android/server/art/ArtManagerLocal.java index c4b5324e1a..30decda68b 100644 --- a/libartservice/service/java/com/android/server/art/ArtManagerLocal.java +++ b/libartservice/service/java/com/android/server/art/ArtManagerLocal.java @@ -57,7 +57,6 @@ import android.os.UserHandle; import android.os.UserManager; import android.os.storage.StorageManager; import android.text.TextUtils; -import android.util.Log; import android.util.Pair; import androidx.annotation.RequiresApi; @@ -121,9 +120,6 @@ import java.util.stream.Stream; */ @SystemApi(client = SystemApi.Client.SYSTEM_SERVER) public final class ArtManagerLocal { - /** @hide */ - public static final String TAG = "ArtService"; - private static final String[] CLASSPATHS_FOR_BOOT_IMAGE_PROFILE = { "BOOTCLASSPATH", "SYSTEMSERVERCLASSPATH", "STANDALONE_SYSTEMSERVER_JARS"}; @@ -490,8 +486,7 @@ public final class ArtManagerLocal { dexoptResults.put(ArtFlags.PASS_DOWNGRADE, downgradeResult); } } - Log.i(TAG, - "Dexopting " + params.getPackages().size() + " packages with reason=" + reason); + AsLog.i("Dexopting " + params.getPackages().size() + " packages with reason=" + reason); DexoptResult mainResult = mInjector.getDexoptHelper().dexopt(snapshot, params.getPackages(), params.getDexoptParams(), cancellationSignal, dexoptExecutor, progressCallbackExecutor, @@ -760,9 +755,8 @@ public final class ArtManagerLocal { PrimaryDexUtils.buildOutputProfile(pkgState, dexInfo, Process.SYSTEM_UID, Process.SYSTEM_UID, false /* isPublic */, false /* isPreReboot */)); if (!result.externalProfileErrors().isEmpty()) { - Log.e(TAG, - "Error occurred when initializing from external profiles: " - + result.externalProfileErrors()); + AsLog.e("Error occurred when initializing from external profiles: " + + result.externalProfileErrors()); } ProfilePath refProfile = result.profile(); @@ -1146,8 +1140,7 @@ public final class ArtManagerLocal { // regression. mInjector.getArtd().commitPreRebootStagedFiles(artifacts, profiles); } catch (ServiceSpecificException e) { - Log.e(TAG, - "Failed to commit Pre-reboot staged files for package '" + AsLog.e("Failed to commit Pre-reboot staged files for package '" + pkgState.getPackageName() + "'", e); } @@ -1193,15 +1186,14 @@ public final class ArtManagerLocal { .filter(pkg -> !excludedPackages.contains(pkg)) .collect(Collectors.toList()); if (!packages.isEmpty()) { - Log.i(TAG, "Storage is low. Downgrading " + packages.size() + " inactive packages"); + AsLog.i("Storage is low. Downgrading " + packages.size() + " inactive packages"); DexoptParams params = new DexoptParams.Builder(ReasonMapping.REASON_INACTIVE).build(); return mInjector.getDexoptHelper().dexopt(snapshot, packages, params, cancellationSignal, executor, progressCallbackExecutor, progressCallback); } else { - Log.i(TAG, - "Storage is low, but downgrading is disabled or there's nothing to " - + "downgrade"); + AsLog.i("Storage is low, but downgrading is disabled or there's nothing to " + + "downgrade"); } } return null; @@ -1213,7 +1205,7 @@ public final class ArtManagerLocal { return mInjector.getStorageManager().getAllocatableBytes(StorageManager.UUID_DEFAULT) < DOWNGRADE_THRESHOLD_ABOVE_LOW_BYTES; } catch (IOException e) { - Log.e(TAG, "Failed to check storage. Assuming storage not low", e); + AsLog.e("Failed to check storage. Assuming storage not low", e); return false; } } @@ -1253,9 +1245,8 @@ public final class ArtManagerLocal { ArtFlags.FLAG_FORCE_MERGE_PROFILE) .build(); - Log.i(TAG, - "Dexopting " + packageNames.size() + " packages with reason=" - + dexoptParams.getReason() + " (supplementary pass)"); + AsLog.i("Dexopting " + packageNames.size() + + " packages with reason=" + dexoptParams.getReason() + " (supplementary pass)"); return mInjector.getDexoptHelper().dexopt(snapshot, packageNames, dexoptParams, cancellationSignal, dexoptExecutor, progressCallbackExecutor, progressCallback); } diff --git a/libartservice/service/java/com/android/server/art/ArtShellCommand.java b/libartservice/service/java/com/android/server/art/ArtShellCommand.java index ff714ee1b8..f3779eb93a 100644 --- a/libartservice/service/java/com/android/server/art/ArtShellCommand.java +++ b/libartservice/service/java/com/android/server/art/ArtShellCommand.java @@ -40,7 +40,6 @@ import android.os.Process; import android.system.ErrnoException; import android.system.Os; import android.system.StructStat; -import android.util.Log; import androidx.annotation.RequiresApi; @@ -88,8 +87,6 @@ import java.util.stream.Collectors; */ @RequiresApi(Build.VERSION_CODES.UPSIDE_DOWN_CAKE) public final class ArtShellCommand extends BasicShellCommandHandler { - private static final String TAG = ArtManagerLocal.TAG; - /** The default location for profile dumps. */ private final static String PROFILE_DEBUG_LOCATION = "/data/misc/profman"; diff --git a/libartservice/service/java/com/android/server/art/ArtdRefCache.java b/libartservice/service/java/com/android/server/art/ArtdRefCache.java index c4ed71203c..148e4759b7 100644 --- a/libartservice/service/java/com/android/server/art/ArtdRefCache.java +++ b/libartservice/service/java/com/android/server/art/ArtdRefCache.java @@ -44,7 +44,6 @@ import java.util.concurrent.ScheduledExecutorService; */ @RequiresApi(Build.VERSION_CODES.UPSIDE_DOWN_CAKE) public class ArtdRefCache { - private static final String TAG = ArtManagerLocal.TAG; // The 15s timeout is arbitrarily picked. // TODO(jiakaiz): Revisit this based on real CUJs. @VisibleForTesting public static final long CACHE_TIMEOUT_MS = 15_000; diff --git a/libartservice/service/java/com/android/server/art/AsLog.java b/libartservice/service/java/com/android/server/art/AsLog.java new file mode 100644 index 0000000000..ac6ae472cc --- /dev/null +++ b/libartservice/service/java/com/android/server/art/AsLog.java @@ -0,0 +1,89 @@ +/* + * Copyright (C) 2024 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.art; + +import android.annotation.NonNull; +import android.annotation.Nullable; +import android.os.Build; +import android.util.Log; +import android.util.Slog; + +import androidx.annotation.RequiresApi; + +/** + * A log wrapper that logs messages with the appropriate tag. + * + * @hide + */ +@RequiresApi(Build.VERSION_CODES.UPSIDE_DOWN_CAKE) +public class AsLog { + private static final String TAG = "ArtService"; + private static final String PRE_REBOOT_TAG = "ArtServicePreReboot"; + + @NonNull + public static String getTag() { + return GlobalInjector.getInstance().isPreReboot() ? PRE_REBOOT_TAG : TAG; + } + + public static void v(@NonNull String msg) { + Log.v(getTag(), msg); + } + + public static void v(@NonNull String msg, @Nullable Throwable tr) { + Log.v(getTag(), msg, tr); + } + + public static void d(@NonNull String msg) { + Log.d(getTag(), msg); + } + + public static void d(@NonNull String msg, @Nullable Throwable tr) { + Log.d(getTag(), msg, tr); + } + + public static void i(@NonNull String msg) { + Log.i(getTag(), msg); + } + + public static void i(@NonNull String msg, @Nullable Throwable tr) { + Log.i(getTag(), msg, tr); + } + + public static void w(@NonNull String msg) { + Log.w(getTag(), msg); + } + + public static void w(@NonNull String msg, @Nullable Throwable tr) { + Log.w(getTag(), msg, tr); + } + + public static void e(@NonNull String msg) { + Log.e(getTag(), msg); + } + + public static void e(@NonNull String msg, @Nullable Throwable tr) { + Log.e(getTag(), msg, tr); + } + + public static void wtf(@NonNull String msg) { + Slog.wtf(getTag(), msg); + } + + public static void wtf(@NonNull String msg, @Nullable Throwable tr) { + Slog.wtf(getTag(), msg, tr); + } +} diff --git a/libartservice/service/java/com/android/server/art/BackgroundDexoptJob.java b/libartservice/service/java/com/android/server/art/BackgroundDexoptJob.java index 289c7cd235..6dda5c9980 100644 --- a/libartservice/service/java/com/android/server/art/BackgroundDexoptJob.java +++ b/libartservice/service/java/com/android/server/art/BackgroundDexoptJob.java @@ -32,8 +32,6 @@ import android.os.Build; import android.os.CancellationSignal; import android.os.SystemClock; import android.os.SystemProperties; -import android.util.Log; -import android.util.Slog; import androidx.annotation.RequiresApi; @@ -61,8 +59,6 @@ import java.util.function.Consumer; /** @hide */ @RequiresApi(Build.VERSION_CODES.UPSIDE_DOWN_CAKE) public class BackgroundDexoptJob implements ArtServiceJobInterface { - private static final String TAG = ArtManagerLocal.TAG; - /** * "android" is the package name for a <service> declared in * frameworks/base/core/res/AndroidManifest.xml @@ -98,7 +94,7 @@ public class BackgroundDexoptJob implements ArtServiceJobInterface { writeStats(result); } catch (RuntimeException e) { // Not expected. Log wtf to surface it. - Slog.wtf(TAG, "Failed to write stats", e); + AsLog.wtf("Failed to write stats", e); } // This is a periodic job, where the interval is specified in the `JobInfo`. "true" @@ -132,7 +128,7 @@ public class BackgroundDexoptJob implements ArtServiceJobInterface { } if (SystemProperties.getBoolean("pm.dexopt.disable_bg_dexopt", false /* def */)) { - Log.i(TAG, "Job is disabled by system property 'pm.dexopt.disable_bg_dexopt'"); + AsLog.i("Job is disabled by system property 'pm.dexopt.disable_bg_dexopt'"); return ArtFlags.SCHEDULE_DISABLED_BY_SYSPROP; } @@ -177,17 +173,17 @@ public class BackgroundDexoptJob implements ArtServiceJobInterface { @NonNull public synchronized CompletableFuture<Result> start() { if (mRunningJob != null) { - Log.i(TAG, "Job is already running"); + AsLog.i("Job is already running"); return mRunningJob; } mCancellationSignal = new CancellationSignal(); mLastStopReason = Optional.empty(); mRunningJob = new CompletableFuture().supplyAsync(() -> { - try (var tracing = new Utils.TracingWithTimingLogging(TAG, "jobExecution")) { + try (var tracing = new Utils.TracingWithTimingLogging(AsLog.getTag(), "jobExecution")) { return run(mCancellationSignal); } catch (RuntimeException e) { - Log.e(TAG, "Fatal error", e); + AsLog.e("Fatal error", e); return new FatalErrorResult(); } finally { synchronized (this) { @@ -201,12 +197,12 @@ public class BackgroundDexoptJob implements ArtServiceJobInterface { public synchronized void cancel() { if (mRunningJob == null) { - Log.i(TAG, "Job is not running"); + AsLog.i("Job is not running"); return; } mCancellationSignal.cancel(); - Log.i(TAG, "Job cancelled"); + AsLog.i("Job cancelled"); } @Nullable @@ -247,7 +243,7 @@ public class BackgroundDexoptJob implements ArtServiceJobInterface { // lose some chance to dexopt when the storage is very low, but it's fine because we // can still dexopt in the next run. long freedBytes = mInjector.getArtManagerLocal().cleanup(snapshot); - Log.i(TAG, String.format("Freed %d bytes", freedBytes)); + AsLog.i(String.format("Freed %d bytes", freedBytes)); } } return CompletedResult.create(dexoptResultByPass, durationMsByPass); diff --git a/libartservice/service/java/com/android/server/art/DexMetadataHelper.java b/libartservice/service/java/com/android/server/art/DexMetadataHelper.java index 1252123479..99d92083d3 100644 --- a/libartservice/service/java/com/android/server/art/DexMetadataHelper.java +++ b/libartservice/service/java/com/android/server/art/DexMetadataHelper.java @@ -19,7 +19,6 @@ package com.android.server.art; import android.annotation.NonNull; import android.annotation.Nullable; import android.os.Build; -import android.util.Log; import androidx.annotation.RequiresApi; @@ -43,8 +42,6 @@ import java.util.zip.ZipFile; */ @RequiresApi(Build.VERSION_CODES.UPSIDE_DOWN_CAKE) public class DexMetadataHelper { - private static final String TAG = ArtManagerLocal.TAG; - @NonNull private final Injector mInjector; public DexMetadataHelper() { @@ -73,7 +70,7 @@ public class DexMetadataHelper { } } catch (IOException e) { if (!(e instanceof FileNotFoundException || e instanceof NoSuchFileException)) { - Log.e(TAG, String.format("Failed to read dm file '%s'", realDmPath), e); + AsLog.e(String.format("Failed to read dm file '%s'", realDmPath), e); } return getDefaultDexMetadataInfo(); } diff --git a/libartservice/service/java/com/android/server/art/DexUseManagerLocal.java b/libartservice/service/java/com/android/server/art/DexUseManagerLocal.java index d5b0bab949..9ef804919a 100644 --- a/libartservice/service/java/com/android/server/art/DexUseManagerLocal.java +++ b/libartservice/service/java/com/android/server/art/DexUseManagerLocal.java @@ -30,7 +30,6 @@ import android.os.Process; import android.os.RemoteException; import android.os.ServiceSpecificException; import android.os.UserHandle; -import android.util.Log; import androidx.annotation.RequiresApi; @@ -94,7 +93,6 @@ import java.util.stream.Collectors; @SystemApi(client = SystemApi.Client.SYSTEM_SERVER) @RequiresApi(Build.VERSION_CODES.UPSIDE_DOWN_CAKE) public class DexUseManagerLocal { - private static final String TAG = ArtManagerLocal.TAG; private static final String FILENAME = "/data/system/package-dex-usage.pb"; /** @@ -557,7 +555,7 @@ public class DexUseManagerLocal { } } } catch (IOException e) { - Log.e(TAG, "Failed to save dex use data", e); + AsLog.e("Failed to save dex use data", e); } finally { Utils.deleteIfExistsSafe(tempFile); } @@ -575,7 +573,7 @@ public class DexUseManagerLocal { proto = DexUseProto.parseFrom(in); } catch (IOException e) { // Nothing else we can do but to start from scratch. - Log.e(TAG, "Failed to load dex use data", e); + AsLog.e("Failed to load dex use data", e); } synchronized (mLock) { if (mDexUse != null) { @@ -636,7 +634,7 @@ public class DexUseManagerLocal { try { return mInjector.getArtd().getDexFileVisibility(dexPath); } catch (ServiceSpecificException | RemoteException e) { - Log.e(TAG, "Failed to get visibility of " + dexPath, e); + AsLog.e("Failed to get visibility of " + dexPath, e); return FileVisibility.NOT_FOUND; } } @@ -954,7 +952,7 @@ public class DexUseManagerLocal { // Skip invalid dex paths persisted by previous versions. String errorMsg = validateDexPath.apply(dexFile); if (errorMsg != null) { - Log.e(TAG, errorMsg); + AsLog.e(errorMsg); continue; } @@ -1018,7 +1016,7 @@ public class DexUseManagerLocal { String errorMsg = validateClassLoaderContext.apply( Utils.assertNonEmpty(recordProto.getClassLoaderContext())); if (errorMsg != null) { - Log.e(TAG, errorMsg); + AsLog.e(errorMsg); continue; } @@ -1027,10 +1025,9 @@ public class DexUseManagerLocal { if (!Utils.isNativeAbi(record.mAbiName)) { // The native ABI set has changed by an OTA since the ABI name was recorded. - Log.i(TAG, - String.format("Ignoring secondary dex use record with non-native ABI " - + "'%s' for '%s'", - record.mAbiName, proto.getDexFile())); + AsLog.i(String.format("Ignoring secondary dex use record with non-native ABI " + + "'%s' for '%s'", + record.mAbiName, proto.getDexFile())); continue; } diff --git a/libartservice/service/java/com/android/server/art/DexoptHelper.java b/libartservice/service/java/com/android/server/art/DexoptHelper.java index 8f402918f6..76edfd503f 100644 --- a/libartservice/service/java/com/android/server/art/DexoptHelper.java +++ b/libartservice/service/java/com/android/server/art/DexoptHelper.java @@ -69,8 +69,6 @@ import java.util.stream.Collectors; */ @RequiresApi(Build.VERSION_CODES.UPSIDE_DOWN_CAKE) public class DexoptHelper { - private static final String TAG = ArtManagerLocal.TAG; - @NonNull private final Injector mInjector; public DexoptHelper(@NonNull Context context, @NonNull Config config) { diff --git a/libartservice/service/java/com/android/server/art/Dexopter.java b/libartservice/service/java/com/android/server/art/Dexopter.java index 69b861527e..f66dde81fe 100644 --- a/libartservice/service/java/com/android/server/art/Dexopter.java +++ b/libartservice/service/java/com/android/server/art/Dexopter.java @@ -40,7 +40,6 @@ import android.os.SystemProperties; import android.os.UserManager; import android.os.storage.StorageManager; import android.text.TextUtils; -import android.util.Log; import android.util.Pair; import androidx.annotation.RequiresApi; @@ -69,7 +68,6 @@ import java.util.Objects; /** @hide */ @RequiresApi(Build.VERSION_CODES.UPSIDE_DOWN_CAKE) public abstract class Dexopter<DexInfoType extends DetailedDexInfo> { - private static final String TAG = ArtManagerLocal.TAG; private static final List<String> ART_PACKAGE_NAMES = List.of("com.google.android.art", "com.android.art", "com.google.android.go.art"); @@ -102,7 +100,7 @@ public abstract class Dexopter<DexInfoType extends DetailedDexInfo> { @NonNull public final List<DexContainerFileDexoptResult> dexopt() throws RemoteException { if (SystemProperties.getBoolean("dalvik.vm.disable-art-service-dexopt", false /* def */)) { - Log.i(TAG, "Dexopt skipped because it's disabled by system property"); + AsLog.i("Dexopt skipped because it's disabled by system property"); return List.of(); } @@ -135,7 +133,7 @@ public abstract class Dexopter<DexInfoType extends DetailedDexInfo> { if (!dmInfo.config().getEnableEmbeddedProfile()) { String dmPath = DexMetadataHelper.getDmPath( Objects.requireNonNull(dmInfo.dmPath())); - Log.i(TAG, "Embedded profile disabled by config in the dm file " + dmPath); + AsLog.i("Embedded profile disabled by config in the dm file " + dmPath); } if (needsToBeShared) { @@ -228,7 +226,7 @@ public abstract class Dexopter<DexInfoType extends DetailedDexInfo> { continue; } } catch (IOException e) { - Log.e(TAG, "Failed to check storage. Assuming storage not low", e); + AsLog.e("Failed to check storage. Assuming storage not low", e); } IArtdCancellationSignal artdCancellationSignal = @@ -237,8 +235,7 @@ public abstract class Dexopter<DexInfoType extends DetailedDexInfo> { try { artdCancellationSignal.cancel(); } catch (RemoteException e) { - Log.e(TAG, "An error occurred when sending a cancellation signal", - e); + AsLog.e("An error occurred when sending a cancellation signal", e); } }); @@ -257,8 +254,7 @@ public abstract class Dexopter<DexInfoType extends DetailedDexInfo> { } } catch (ServiceSpecificException e) { // Log the error and continue. - Log.e(TAG, - String.format("Failed to dexopt [packageName = %s, dexPath = %s, " + AsLog.e(String.format("Failed to dexopt [packageName = %s, dexPath = %s, " + "isa = %s, classLoaderContext = %s]", mPkgState.getPackageName(), dexInfo.dexPath(), abi.isa(), dexInfo.classLoaderContext()), @@ -272,9 +268,8 @@ public abstract class Dexopter<DexInfoType extends DetailedDexInfo> { abi.isPrimaryAbi(), abi.name(), compilerFilter, status, wallTimeMs, cpuTimeMs, sizeBytes, sizeBeforeBytes, extendedStatusFlags, externalProfileErrors); - Log.i(TAG, - String.format("Dexopt result: [packageName = %s] %s", - mPkgState.getPackageName(), result)); + AsLog.i(String.format("Dexopt result: [packageName = %s] %s", + mPkgState.getPackageName(), result)); results.add(result); if (status != DexoptResult.DEXOPT_SKIPPED && status != DexoptResult.DEXOPT_PERFORMED) { @@ -568,8 +563,7 @@ public abstract class Dexopter<DexInfoType extends DetailedDexInfo> { mInjector.getArtd().commitTmpProfile(profile); return true; } catch (ServiceSpecificException e) { - Log.e(TAG, "Failed to commit profile changes " + AidlUtils.toString(profile.finalPath), - e); + AsLog.e("Failed to commit profile changes " + AidlUtils.toString(profile.finalPath), e); return false; } } @@ -588,8 +582,7 @@ public abstract class Dexopter<DexInfoType extends DetailedDexInfo> { return ProfilePath.tmpProfilePath(output.profilePath); } } catch (ServiceSpecificException e) { - Log.e(TAG, - "Failed to merge profiles " + AidlUtils.toString(output.profilePath.finalPath), + AsLog.e("Failed to merge profiles " + AidlUtils.toString(output.profilePath.finalPath), e); } diff --git a/libartservice/service/java/com/android/server/art/DumpHelper.java b/libartservice/service/java/com/android/server/art/DumpHelper.java index 8bd2210f33..31c159c92c 100644 --- a/libartservice/service/java/com/android/server/art/DumpHelper.java +++ b/libartservice/service/java/com/android/server/art/DumpHelper.java @@ -24,7 +24,6 @@ import android.annotation.NonNull; import android.os.Build; import android.os.RemoteException; import android.os.ServiceSpecificException; -import android.util.Log; import androidx.annotation.RequiresApi; @@ -54,8 +53,6 @@ import java.util.stream.Collectors; */ @RequiresApi(Build.VERSION_CODES.UPSIDE_DOWN_CAKE) public class DumpHelper { - private static final String TAG = ArtManagerLocal.TAG; - @NonNull private final Injector mInjector; public DumpHelper(@NonNull ArtManagerLocal artManagerLocal) { diff --git a/libartservice/service/java/com/android/server/art/PreRebootDexoptJob.java b/libartservice/service/java/com/android/server/art/PreRebootDexoptJob.java index 099be02b13..eca05c995b 100644 --- a/libartservice/service/java/com/android/server/art/PreRebootDexoptJob.java +++ b/libartservice/service/java/com/android/server/art/PreRebootDexoptJob.java @@ -29,8 +29,6 @@ import android.os.Build; import android.os.CancellationSignal; import android.os.SystemProperties; import android.provider.DeviceConfig; -import android.util.Log; -import android.util.Slog; import androidx.annotation.RequiresApi; @@ -52,8 +50,6 @@ import java.util.concurrent.CompletableFuture; */ @RequiresApi(Build.VERSION_CODES.VANILLA_ICE_CREAM) public class PreRebootDexoptJob implements ArtServiceJobInterface { - private static final String TAG = ArtManagerLocal.TAG; - /** * "android" is the package name for a <service> declared in * frameworks/base/core/res/AndroidManifest.xml @@ -103,7 +99,7 @@ public class PreRebootDexoptJob implements ArtServiceJobInterface { // ignored. jobService.jobFinished(params, false /* wantsReschedule */); } catch (RuntimeException e) { - Slog.wtf(TAG, "Unexpected exception", e); + AsLog.wtf("Unexpected exception", e); } }); // "true" means the job will continue running until `jobFinished` is called. @@ -125,16 +121,15 @@ public class PreRebootDexoptJob implements ArtServiceJobInterface { if (!SystemProperties.getBoolean("dalvik.vm.enable_pr_dexopt", false /* def */) && !DeviceConfig.getBoolean(DeviceConfig.NAMESPACE_RUNTIME, "enable_pr_dexopt", false /* defaultValue */)) { - Log.i(TAG, "Pre-reboot Dexopt Job is not enabled by system property"); + AsLog.i("Pre-reboot Dexopt Job is not enabled by system property"); return ArtFlags.SCHEDULE_DISABLED_BY_SYSPROP; } // If `pm.dexopt.disable_bg_dexopt` is set, the user probably means to disable any dexopt // jobs in the background. if (SystemProperties.getBoolean("pm.dexopt.disable_bg_dexopt", false /* def */)) { - Log.i(TAG, - "Pre-reboot Dexopt Job is disabled by system property " - + "'pm.dexopt.disable_bg_dexopt'"); + AsLog.i("Pre-reboot Dexopt Job is disabled by system property " + + "'pm.dexopt.disable_bg_dexopt'"); return ArtFlags.SCHEDULE_DISABLED_BY_SYSPROP; } @@ -149,10 +144,10 @@ public class PreRebootDexoptJob implements ArtServiceJobInterface { /* @JobScheduler.Result */ int result = mInjector.getJobScheduler().schedule(info); if (result == JobScheduler.RESULT_SUCCESS) { - Log.i(TAG, "Pre-reboot Dexopt Job scheduled"); + AsLog.i("Pre-reboot Dexopt Job scheduled"); return ArtFlags.SCHEDULE_SUCCESS; } else { - Log.i(TAG, "Failed to schedule Pre-reboot Dexopt Job"); + AsLog.i("Failed to schedule Pre-reboot Dexopt Job"); return ArtFlags.SCHEDULE_JOB_SCHEDULER_FAILURE; } } @@ -168,7 +163,7 @@ public class PreRebootDexoptJob implements ArtServiceJobInterface { @NonNull public synchronized CompletableFuture<Void> start() { if (mRunningJob != null) { - Log.i(TAG, "Job is already running"); + AsLog.i("Job is already running"); return mRunningJob; } @@ -180,7 +175,7 @@ public class PreRebootDexoptJob implements ArtServiceJobInterface { // TODO(b/336239721): Consume the result and report metrics. mInjector.getPreRebootDriver().run(otaSlot, cancellationSignal); } catch (RuntimeException e) { - Log.e(TAG, "Fatal error", e); + AsLog.e("Fatal error", e); } finally { synchronized (this) { mRunningJob = null; @@ -204,7 +199,7 @@ public class PreRebootDexoptJob implements ArtServiceJobInterface { } mCancellationSignal.cancel(); - Log.i(TAG, "Job cancelled"); + AsLog.i("Job cancelled"); runningJob = mRunningJob; } if (blocking) { diff --git a/libartservice/service/java/com/android/server/art/PrimaryDexopter.java b/libartservice/service/java/com/android/server/art/PrimaryDexopter.java index 6ac7988f9e..7856dbeacd 100644 --- a/libartservice/service/java/com/android/server/art/PrimaryDexopter.java +++ b/libartservice/service/java/com/android/server/art/PrimaryDexopter.java @@ -31,7 +31,6 @@ import android.os.RemoteException; import android.os.ServiceSpecificException; import android.os.UserHandle; import android.text.TextUtils; -import android.util.Log; import androidx.annotation.RequiresApi; @@ -56,8 +55,6 @@ import java.util.Objects; /** @hide */ @RequiresApi(Build.VERSION_CODES.UPSIDE_DOWN_CAKE) public class PrimaryDexopter extends Dexopter<DetailedPrimaryDexInfo> { - private static final String TAG = ArtManagerLocal.TAG; - private final int mSharedGid; public PrimaryDexopter(@NonNull Context context, @NonNull Config config, diff --git a/libartservice/service/java/com/android/server/art/SecondaryDexopter.java b/libartservice/service/java/com/android/server/art/SecondaryDexopter.java index fe0cdb0091..9a158042c4 100644 --- a/libartservice/service/java/com/android/server/art/SecondaryDexopter.java +++ b/libartservice/service/java/com/android/server/art/SecondaryDexopter.java @@ -40,8 +40,6 @@ import java.util.List; /** @hide */ @RequiresApi(Build.VERSION_CODES.UPSIDE_DOWN_CAKE) public class SecondaryDexopter extends Dexopter<CheckedSecondaryDexInfo> { - private static final String TAG = ArtManagerLocal.TAG; - public SecondaryDexopter(@NonNull Context context, @NonNull Config config, @NonNull PackageState pkgState, @NonNull AndroidPackage pkg, @NonNull DexoptParams params, @NonNull CancellationSignal cancellationSignal) { diff --git a/libartservice/service/java/com/android/server/art/Utils.java b/libartservice/service/java/com/android/server/art/Utils.java index 6c01bbcb40..8132dbbab2 100644 --- a/libartservice/service/java/com/android/server/art/Utils.java +++ b/libartservice/service/java/com/android/server/art/Utils.java @@ -37,7 +37,6 @@ import android.os.UserManager; import android.text.TextUtils; import android.util.Log; import android.util.Pair; -import android.util.Slog; import android.util.SparseArray; import androidx.annotation.RequiresApi; @@ -73,7 +72,6 @@ import java.util.stream.Collectors; /** @hide */ @RequiresApi(Build.VERSION_CODES.UPSIDE_DOWN_CAKE) public final class Utils { - public static final String TAG = ArtManagerLocal.TAG; public static final String PLATFORM_PACKAGE_NAME = "android"; /** A copy of {@link android.os.Trace.TRACE_TAG_DALVIK}. */ @@ -217,7 +215,7 @@ public final class Utils { // This should never happen. Ignore the error and conservatively use dalvik-cache to // minimize the risk. // TODO(jiakaiz): Throw the error instead of ignoring it. - Log.e(TAG, "Failed to determine the location of the artifacts", e); + AsLog.e("Failed to determine the location of the artifacts", e); return true; } } @@ -343,7 +341,7 @@ public final class Utils { try { Files.deleteIfExists(path); } catch (IOException e) { - Log.e(TAG, "Failed to delete file '" + path + "'", e); + AsLog.e("Failed to delete file '" + path + "'", e); } } @@ -390,8 +388,7 @@ public final class Utils { refProfile, isOtherReadable, List.of() /* externalProfileErrors */); } } catch (ServiceSpecificException e) { - Log.e(TAG, - "Failed to use the existing reference profile " + AsLog.e("Failed to use the existing reference profile " + AidlUtils.toString(refProfile), e); } @@ -440,7 +437,7 @@ public final class Utils { externalProfileErrors.add(result.errorMsg); } } catch (ServiceSpecificException e) { - Log.e(TAG, "Failed to initialize profile from " + pair.first, e); + AsLog.e("Failed to initialize profile from " + pair.first, e); } } @@ -457,10 +454,10 @@ public final class Utils { // exception is expected. // In either case, we don't need to surface the exception from here. // The Java stack trace is intentionally omitted because it's not helpful. - Log.e(TAG, message); + AsLog.e(message); } else { // Not expected. Log wtf to surface it. - Slog.wtf(TAG, message, e); + AsLog.wtf(message, e); } } @@ -473,7 +470,7 @@ public final class Utils { try { Thread.sleep(millis); } catch (InterruptedException e) { - Slog.wtf(TAG, "Sleep interrupted", e); + AsLog.wtf("Sleep interrupted", e); } } diff --git a/libartservice/service/java/com/android/server/art/prereboot/PreRebootDriver.java b/libartservice/service/java/com/android/server/art/prereboot/PreRebootDriver.java index 2e43383161..44809b1c50 100644 --- a/libartservice/service/java/com/android/server/art/prereboot/PreRebootDriver.java +++ b/libartservice/service/java/com/android/server/art/prereboot/PreRebootDriver.java @@ -26,14 +26,13 @@ import android.os.Build; import android.os.CancellationSignal; import android.os.RemoteException; import android.os.ServiceSpecificException; -import android.util.Log; -import android.util.Slog; import androidx.annotation.RequiresApi; import com.android.internal.annotations.VisibleForTesting; import com.android.server.art.ArtManagerLocal; import com.android.server.art.ArtModuleServiceInitializer; +import com.android.server.art.AsLog; import com.android.server.art.GlobalInjector; import com.android.server.art.IDexoptChrootSetup; import com.android.server.art.Utils; @@ -49,8 +48,6 @@ import dalvik.system.DelegateLastClassLoader; */ @RequiresApi(Build.VERSION_CODES.VANILLA_ICE_CREAM) public class PreRebootDriver { - private static final String TAG = ArtManagerLocal.TAG; - @NonNull private final Injector mInjector; public PreRebootDriver(@NonNull Context context) { @@ -76,9 +73,9 @@ public class PreRebootDriver { } catch (RemoteException e) { Utils.logArtdException(e); } catch (ServiceSpecificException e) { - Log.e(TAG, "Failed to set up chroot", e); + AsLog.e("Failed to set up chroot", e); } catch (ReflectiveOperationException e) { - Log.e(TAG, "Failed to run pre-reboot dexopt", e); + AsLog.e("Failed to run pre-reboot dexopt", e); } finally { tearDown(); } @@ -107,14 +104,14 @@ public class PreRebootDriver { } catch (RemoteException e) { Utils.logArtdException(e); } catch (ServiceSpecificException e) { - Log.e(TAG, "Failed to tear down chroot", e); + AsLog.e("Failed to tear down chroot", e); } catch (IllegalStateException e) { // Not expected, but we still want retries in such an extreme case. - Slog.wtf(TAG, "Unexpected exception", e); + AsLog.wtf("Unexpected exception", e); } if (--numRetries > 0) { - Log.i(TAG, "Retrying...."); + AsLog.i("Retrying...."); Utils.sleep(30000); } } |