Rename DexLogger to DynamicCodeLogger.
Because it logs native code as well as DEX code now. Also fix up field
names, getters, comments, etc.
Test: atest -p services/core/java/com/android/server/pm/dex
Bug: 122946463
Change-Id: I797b698504d24a76186f2f429a0e2f23a68614f0
diff --git a/services/core/java/com/android/server/pm/DynamicCodeLoggingService.java b/services/core/java/com/android/server/pm/DynamicCodeLoggingService.java
index 5b765df..d53d81c 100644
--- a/services/core/java/com/android/server/pm/DynamicCodeLoggingService.java
+++ b/services/core/java/com/android/server/pm/DynamicCodeLoggingService.java
@@ -28,7 +28,7 @@
import android.util.EventLog;
import android.util.Log;
-import com.android.server.pm.dex.DexLogger;
+import com.android.server.pm.dex.DynamicCodeLogger;
import java.util.ArrayList;
import java.util.List;
@@ -38,9 +38,10 @@
/**
* Scheduled jobs related to logging of app dynamic code loading. The idle logging job runs daily
- * while idle and charging and calls {@link DexLogger} to write dynamic code information to the
- * event log. The audit watching job scans the event log periodically while idle to find AVC audit
- * messages indicating use of dynamic native code and adds the information to {@link DexLogger}.
+ * while idle and charging and calls {@link DynamicCodeLogger} to write dynamic code information
+ * to the event log. The audit watching job scans the event log periodically while idle to find AVC
+ * audit messages indicating use of dynamic native code and adds the information to
+ * {@link DynamicCodeLogger}.
* {@hide}
*/
public class DynamicCodeLoggingService extends JobService {
@@ -130,9 +131,9 @@
}
}
- private static DexLogger getDexLogger() {
+ private static DynamicCodeLogger getDynamicCodeLogger() {
PackageManagerService pm = (PackageManagerService) ServiceManager.getService("package");
- return pm.getDexManager().getDexLogger();
+ return pm.getDexManager().getDynamicCodeLogger();
}
private class IdleLoggingThread extends Thread {
@@ -149,14 +150,14 @@
Log.d(TAG, "Starting IdleLoggingJob run");
}
- DexLogger dexLogger = getDexLogger();
- for (String packageName : dexLogger.getAllPackagesWithDynamicCodeLoading()) {
+ DynamicCodeLogger dynamicCodeLogger = getDynamicCodeLogger();
+ for (String packageName : dynamicCodeLogger.getAllPackagesWithDynamicCodeLoading()) {
if (mIdleLoggingStopRequested) {
Log.w(TAG, "Stopping IdleLoggingJob run at scheduler request");
return;
}
- dexLogger.logDynamicCodeLoading(packageName);
+ dynamicCodeLogger.logDynamicCodeLoading(packageName);
}
jobFinished(mParams, /* reschedule */ false);
@@ -191,7 +192,7 @@
private boolean processAuditEvents() {
// Scan the event log for SELinux (avc) audit messages indicating when an
// (untrusted) app has executed native code from an app data
- // file. Matches are recorded in DexLogger.
+ // file. Matches are recorded in DynamicCodeLogger.
//
// These messages come from the kernel audit system via logd. (Note that
// some devices may not generate these messages at all, or the format may
@@ -213,7 +214,7 @@
// On each run we process all the matching events in the log. This may
// mean re-processing events we have already seen, and in any case there
// may be duplicate events for the same app+file. These are de-duplicated
- // by DexLogger.
+ // by DynamicCodeLogger.
//
// Note that any app can write a message to the event log, including one
// that looks exactly like an AVC audit message, so the information may
@@ -228,7 +229,7 @@
return true;
}
- DexLogger dexLogger = getDexLogger();
+ DynamicCodeLogger dynamicCodeLogger = getDynamicCodeLogger();
List<EventLog.Event> events = new ArrayList<>();
EventLog.readEvents(tags, events);
@@ -267,7 +268,7 @@
// hex-encodes the bytes; we need to undo that.
path = unhex(matcher.group(2));
}
- dexLogger.recordNative(uid, path);
+ dynamicCodeLogger.recordNative(uid, path);
}
return true;
diff --git a/services/core/java/com/android/server/pm/dex/DexManager.java b/services/core/java/com/android/server/pm/dex/DexManager.java
index ee6995b..3b805d51 100644
--- a/services/core/java/com/android/server/pm/dex/DexManager.java
+++ b/services/core/java/com/android/server/pm/dex/DexManager.java
@@ -86,11 +86,11 @@
// encode and save the dex usage data.
private final PackageDexUsage mPackageDexUsage;
- // DexLogger handles recording of dynamic code loading - which is similar to PackageDexUsage
- // but records a different aspect of the data.
+ // DynamicCodeLogger handles recording of dynamic code loading - which is similar to
+ // PackageDexUsage but records a different aspect of the data.
// (It additionally includes DEX files loaded with unsupported class loaders, and doesn't
// record class loaders or ISAs.)
- private final DexLogger mDexLogger;
+ private final DynamicCodeLogger mDynamicCodeLogger;
private final IPackageManager mPackageManager;
private final PackageDexOptimizer mPackageDexOptimizer;
@@ -126,11 +126,11 @@
mPackageDexOptimizer = pdo;
mInstaller = installer;
mInstallLock = installLock;
- mDexLogger = new DexLogger(pms, installer);
+ mDynamicCodeLogger = new DynamicCodeLogger(pms, installer);
}
- public DexLogger getDexLogger() {
- return mDexLogger;
+ public DynamicCodeLogger getDynamicCodeLogger() {
+ return mDynamicCodeLogger;
}
/**
@@ -230,8 +230,8 @@
if (!primaryOrSplit) {
// Record loading of a DEX file from an app data directory.
- mDexLogger.recordDex(loaderUserId, dexPath, searchResult.mOwningPackageName,
- loadingAppInfo.packageName);
+ mDynamicCodeLogger.recordDex(loaderUserId, dexPath,
+ searchResult.mOwningPackageName, loadingAppInfo.packageName);
}
if (classLoaderContexts != null) {
@@ -269,7 +269,7 @@
loadInternal(existingPackages);
} catch (Exception e) {
mPackageDexUsage.clear();
- mDexLogger.clear();
+ mDynamicCodeLogger.clear();
Slog.w(TAG, "Exception while loading. Starting with a fresh state.", e);
}
}
@@ -320,12 +320,12 @@
if (mPackageDexUsage.removePackage(packageName)) {
mPackageDexUsage.maybeWriteAsync();
}
- mDexLogger.removePackage(packageName);
+ mDynamicCodeLogger.removePackage(packageName);
} else {
if (mPackageDexUsage.removeUserPackage(packageName, userId)) {
mPackageDexUsage.maybeWriteAsync();
}
- mDexLogger.removeUserPackage(packageName, userId);
+ mDynamicCodeLogger.removeUserPackage(packageName, userId);
}
}
@@ -404,9 +404,9 @@
}
try {
- mDexLogger.readAndSync(packageToUsersMap);
+ mDynamicCodeLogger.readAndSync(packageToUsersMap);
} catch (Exception e) {
- mDexLogger.clear();
+ mDynamicCodeLogger.clear();
Slog.w(TAG, "Exception while loading package dynamic code usage. "
+ "Starting with a fresh state.", e);
}
@@ -692,7 +692,7 @@
*/
public void writePackageDexUsageNow() {
mPackageDexUsage.writeNow();
- mDexLogger.writeNow();
+ mDynamicCodeLogger.writeNow();
}
/**
diff --git a/services/core/java/com/android/server/pm/dex/DexLogger.java b/services/core/java/com/android/server/pm/dex/DynamicCodeLogger.java
similarity index 95%
rename from services/core/java/com/android/server/pm/dex/DexLogger.java
rename to services/core/java/com/android/server/pm/dex/DynamicCodeLogger.java
index 59cc0cf..2c75bcd 100644
--- a/services/core/java/com/android/server/pm/dex/DexLogger.java
+++ b/services/core/java/com/android/server/pm/dex/DynamicCodeLogger.java
@@ -11,7 +11,7 @@
* 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
+ * limitations under the License.
*/
package com.android.server.pm.dex;
@@ -44,12 +44,12 @@
import java.util.Set;
/**
- * This class is responsible for logging data about secondary dex files and, despite the name,
- * native code executed from an app's private directory. The data logged includes hashes of the
- * name and content of each file.
+ * This class is responsible for logging data about secondary dex files and native code executed
+ * from an app's private directory. The data logged includes hashes of the name and content of each
+ * file.
*/
-public class DexLogger {
- private static final String TAG = "DexLogger";
+public class DynamicCodeLogger {
+ private static final String TAG = "DynamicCodeLogger";
// Event log tag & subtags used for SafetyNet logging of dynamic code loading (DCL) -
// see b/63927552.
@@ -61,12 +61,12 @@
private final PackageDynamicCodeLoading mPackageDynamicCodeLoading;
private final Installer mInstaller;
- public DexLogger(IPackageManager pms, Installer installer) {
+ DynamicCodeLogger(IPackageManager pms, Installer installer) {
this(pms, installer, new PackageDynamicCodeLoading());
}
@VisibleForTesting
- DexLogger(IPackageManager pms, Installer installer,
+ DynamicCodeLogger(IPackageManager pms, Installer installer,
PackageDynamicCodeLoading packageDynamicCodeLoading) {
mPackageManager = pms;
mPackageDynamicCodeLoading = packageDynamicCodeLoading;
@@ -217,7 +217,7 @@
/**
* Record that an app running in the specified uid has executed native code from the file at
- * {@link path}.
+ * {@param path}.
*/
public void recordNative(int loadingUid, String path) {
String[] packages;