Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit e33b495c authored by Ned Burns's avatar Ned Burns
Browse files

Add service for dumping at NORMAL priority

SystemUIService is hard-coded to dump at CRITICAL priority and so can't
dump very much (and, most importantly, can't handle dumping our length
log buffers). So instead we create a new service,
SystemUIAuxiliaryDumpService, which will dump alongside all other
services in the NORMAL section. Its dump method calls straight into the
DumpManager.

Test: atest, manual
Change-Id: If76f206081a1663e23fc14076b50bef7396e517f
parent c7cfa69f
Loading
Loading
Loading
Loading
+6 −0
Original line number Diff line number Diff line
@@ -283,6 +283,12 @@
            android:exported="true"
        />

        <!-- Service for dumping extremely verbose content during a bug report -->
        <service android:name=".dump.SystemUIAuxiliaryDumpService"
             android:exported="false"
             android:permission="com.android.systemui.permission.SELF"
        />

        <!-- On user switch, this service is started to ensure that the associated SystemUI
             process for the current user is started. See the resource
             "config_systemUIServiceComponentsPerUser".
+7 −0
Original line number Diff line number Diff line
@@ -23,11 +23,13 @@ import android.os.Handler;
import android.os.IBinder;
import android.os.Process;
import android.os.SystemProperties;
import android.os.UserHandle;
import android.util.Slog;

import com.android.internal.os.BinderInternal;
import com.android.systemui.dagger.qualifiers.Main;
import com.android.systemui.dump.DumpManager;
import com.android.systemui.dump.SystemUIAuxiliaryDumpService;

import java.io.FileDescriptor;
import java.io.PrintWriter;
@@ -72,6 +74,11 @@ public class SystemUIService extends Service {
                        }
                    }, mMainHandler);
        }

        // Bind the dump service so we can dump extra info during a bug report
        startServiceAsUser(
                new Intent(getApplicationContext(), SystemUIAuxiliaryDumpService.class),
                UserHandle.SYSTEM);
    }

    @Override
+7 −0
Original line number Diff line number Diff line
@@ -21,6 +21,7 @@ import android.app.Service;
import com.android.systemui.ImageWallpaper;
import com.android.systemui.SystemUIService;
import com.android.systemui.doze.DozeService;
import com.android.systemui.dump.SystemUIAuxiliaryDumpService;
import com.android.systemui.keyguard.KeyguardService;
import com.android.systemui.screenrecord.RecordingService;
import com.android.systemui.screenshot.TakeScreenshotService;
@@ -59,6 +60,12 @@ public abstract class DefaultServiceBinder {
    @ClassKey(SystemUIService.class)
    public abstract Service bindSystemUIService(SystemUIService service);

    /** */
    @Binds
    @IntoMap
    @ClassKey(SystemUIAuxiliaryDumpService.class)
    public abstract Service bindSystemUIAuxiliaryDumpService(SystemUIAuxiliaryDumpService service);

    /** */
    @Binds
    @IntoMap
+58 −0
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.systemui.dump;

import android.app.Service;
import android.content.Intent;
import android.os.IBinder;

import java.io.FileDescriptor;
import java.io.PrintWriter;

import javax.inject.Inject;

/**
 * Service for dumping extremely verbose content during a bug report
 *
 * Our primary service, SystemUIService, is dumped during the CRITICAL section of a bug report.
 * This has some advantages (we get to go first!), but also imposes strict limitations on how much
 * we can dump. This service exists to handle any content that is too large to be safely dumped
 * within those constraints, namely log buffers. It's dumped during the NORMAL section, along with
 * all other services.
 */
public class SystemUIAuxiliaryDumpService extends Service {
    private final DumpManager mDumpManager;

    @Inject
    public SystemUIAuxiliaryDumpService(DumpManager dumpManager) {
        mDumpManager = dumpManager;
    }

    @Override
    public IBinder onBind(Intent intent) {
        return null;
    }

    @Override
    protected void dump(FileDescriptor fd, PrintWriter pw, String[] args) {
        // Simulate the NORMAL priority arg being passed to us
        mDumpManager.dump(
                fd,
                pw,
                new String[] { DumpManager.PRIORITY_ARG, DumpManager.PRIORITY_ARG_NORMAL });
    }
}