diff --git a/services/core/java/com/android/server/stats/StatsPullAtomService.java b/services/core/java/com/android/server/stats/StatsPullAtomService.java new file mode 100644 index 0000000000000..e367f284b39ad --- /dev/null +++ b/services/core/java/com/android/server/stats/StatsPullAtomService.java @@ -0,0 +1,58 @@ +/* + * 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.stats; + +import android.content.Context; +import android.util.Slog; + +import com.android.internal.os.BackgroundThread; +import com.android.server.SystemService; + +/** + * SystemService containing PullAtomCallbacks that are registered with statsd. + * + * @hide + */ +public class StatsPullAtomService extends SystemService { + private static final String TAG = "StatsPullAtomService"; + private static final boolean DEBUG = true; + + public StatsPullAtomService(Context context) { + super(context); + } + + @Override + public void onStart() { + // No op. + } + + @Override + public void onBootPhase(int phase) { + super.onBootPhase(phase); + if (phase == PHASE_SYSTEM_SERVICES_READY) { + BackgroundThread.getHandler().post(() -> { + registerAllPullers(); + }); + } + } + + void registerAllPullers() { + if (DEBUG) { + Slog.d(TAG, "Registering all pullers with statsd"); + } + } +} diff --git a/services/java/com/android/server/SystemServer.java b/services/java/com/android/server/SystemServer.java index cfe1318999871..08221f9275317 100644 --- a/services/java/com/android/server/SystemServer.java +++ b/services/java/com/android/server/SystemServer.java @@ -214,6 +214,8 @@ public final class SystemServer { "com.android.server.companion.CompanionDeviceManagerService"; private static final String STATS_COMPANION_LIFECYCLE_CLASS = "com.android.server.stats.StatsCompanion$Lifecycle"; + private static final String STATS_PULL_ATOM_SERVICE_CLASS = + "com.android.server.stats.StatsPullAtomService"; private static final String USB_SERVICE_CLASS = "com.android.server.usb.UsbService$Lifecycle"; private static final String MIDI_SERVICE_CLASS = @@ -1975,6 +1977,11 @@ public final class SystemServer { mSystemServiceManager.startService(STATS_COMPANION_LIFECYCLE_CLASS); t.traceEnd(); + // Statsd pulled atoms + t.traceBegin("StartStatsPullAtomService"); + mSystemServiceManager.startService(STATS_PULL_ATOM_SERVICE_CLASS); + t.traceEnd(); + // Incidentd and dumpstated helper t.traceBegin("StartIncidentCompanionService"); mSystemServiceManager.startService(IncidentCompanionService.class);