Separate job service for dynamic code logging.

Decouple logging of dynamic code loading from background DEX
optimisation/reconciliation (BackgroundDexOptService).

Add DynamicCodeLoggingService to run DCL logging daily while idle and
charging.

Update DexLoggerIntegrationTests to use the new job, and to verify
that we now handle unknown class loaders.

Bug: 111336847
Test: atest -p services/core/java/com/android/server/pm/dex
Change-Id: Id688a7eef5976120be12606e726830ce32451a1e
diff --git a/services/java/com/android/server/SystemServer.java b/services/java/com/android/server/SystemServer.java
index 88f645d..e1b83fc 100644
--- a/services/java/com/android/server/SystemServer.java
+++ b/services/java/com/android/server/SystemServer.java
@@ -109,6 +109,7 @@
 import com.android.server.os.SchedulingPolicyService;
 import com.android.server.pm.BackgroundDexOptService;
 import com.android.server.pm.CrossProfileAppsService;
+import com.android.server.pm.DynamicCodeLoggingService;
 import com.android.server.pm.Installer;
 import com.android.server.pm.LauncherAppsService;
 import com.android.server.pm.OtaDexoptService;
@@ -1667,6 +1668,18 @@
             traceEnd();
 
             if (!isWatch) {
+                // We don't run this on watches as there are no plans to use the data logged
+                // on watch devices.
+                traceBeginAndSlog("StartDynamicCodeLoggingService");
+                try {
+                    DynamicCodeLoggingService.schedule(context);
+                } catch (Throwable e) {
+                    reportWtf("starting DynamicCodeLoggingService", e);
+                }
+                traceEnd();
+            }
+
+            if (!isWatch) {
                 traceBeginAndSlog("StartPruneInstantAppsJobService");
                 try {
                     PruneInstantAppsJobService.schedule(context);