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

Commit d95fe42a authored by Stefan Andonian's avatar Stefan Andonian Committed by Android (Google) Code Review
Browse files

Merge "Create Service for IssueRecording Notifications and Tracing." into main

parents cc7a540c d9bc1e8c
Loading
Loading
Loading
Loading
+3 −0
Original line number Diff line number Diff line
@@ -475,6 +475,9 @@
        <service android:name=".screenrecord.RecordingService"
                 android:foregroundServiceType="systemExempted"/>

        <service android:name=".recordissue.IssueRecordingService"
                 android:foregroundServiceType="systemExempted"/>

        <receiver android:name=".SysuiRestartReceiver"
            android:exported="false">
            <intent-filter>
+21 −0
Original line number Diff line number Diff line
@@ -305,6 +305,27 @@
    <!-- A toast message shown when the screen recording cannot be started due to a generic error [CHAR LIMIT=NONE] -->
    <string name="screenrecord_start_error">Error starting screen recording</string>

    <!-- Notification title displayed for issue recording [CHAR LIMIT=50]-->
    <string name="issuerecord_title">Issue Recorder</string>
    <!-- Processing issue recoding data in the background [CHAR LIMIT=30]-->
    <string name="issuerecord_background_processing_label">Processing issue recording</string>
    <!-- Description of the screen recording notification channel [CHAR LIMIT=NONE]-->
    <string name="issuerecord_channel_description">Ongoing notification for an issue collection session</string>

    <!-- Notification text displayed when we are recording the screen [CHAR LIMIT=100]-->
    <string name="issuerecord_ongoing_screen_only">Recording issue</string>
    <!-- Label for notification action to share issue recording [CHAR LIMIT=35] -->
    <string name="issuerecord_share_label">Share</string>
    <!-- A toast message shown after successfully canceling a issue recording [CHAR LIMIT=NONE] -->
    <!-- Notification text shown after saving a issue recording [CHAR LIMIT=100] -->
    <string name="issuerecord_save_title">Issue recording saved</string>
    <!-- Subtext for a notification shown after saving a issue recording to prompt the user to view it [CHAR_LIMIT=100] -->
    <string name="issuerecord_save_text">Tap to view</string>
    <!-- A toast message shown when there is an error saving a issue recording [CHAR LIMIT=NONE] -->
    <string name="issuerecord_save_error">Error saving issue recording</string>
    <!-- A toast message shown when the issue recording cannot be started due to a generic error [CHAR LIMIT=NONE] -->
    <string name="issuerecord_start_error">Error starting issue recording</string>

    <!-- Cling help message title when hiding the navigation bar entering immersive mode [CHAR LIMIT=none] -->
    <string name="immersive_cling_title">Viewing full screen</string>
    <!-- Cling help message description when hiding the navigation bar entering immersive mode [CHAR LIMIT=none] -->
+8 −0
Original line number Diff line number Diff line
@@ -23,6 +23,7 @@ import com.android.systemui.doze.DozeService;
import com.android.systemui.dreams.DreamOverlayService;
import com.android.systemui.dump.SystemUIAuxiliaryDumpService;
import com.android.systemui.keyguard.KeyguardService;
import com.android.systemui.recordissue.IssueRecordingService;
import com.android.systemui.screenrecord.RecordingService;
import com.android.systemui.statusbar.phone.NotificationListenerWithPlugins;
import com.android.systemui.wallpapers.ImageWallpaper;
@@ -85,4 +86,11 @@ public abstract class DefaultServiceBinder {
    @IntoMap
    @ClassKey(RecordingService.class)
    public abstract Service bindRecordingService(RecordingService service);

    /** Inject into IssueRecordingService */
    @Binds
    @IntoMap
    @ClassKey(IssueRecordingService.class)
    public abstract Service bindIssueRecordingService(IssueRecordingService service);

}
+2 −1
Original line number Diff line number Diff line
@@ -42,6 +42,7 @@ import com.android.systemui.qs.QSHost
import com.android.systemui.qs.QsEventLogger
import com.android.systemui.qs.logging.QSLogger
import com.android.systemui.qs.tileimpl.QSTileImpl
import com.android.systemui.recordissue.IssueRecordingService
import com.android.systemui.recordissue.RecordIssueDialogDelegate
import com.android.systemui.res.R
import com.android.systemui.screenrecord.RecordingService
@@ -107,7 +108,7 @@ constructor(
        PendingIntent.getService(
                userContextProvider.userContext,
                RecordingService.REQUEST_CODE,
                RecordingService.getStopIntent(userContextProvider.userContext),
                IssueRecordingService.getStopIntent(userContextProvider.userContext),
                PendingIntent.FLAG_UPDATE_CURRENT or PendingIntent.FLAG_IMMUTABLE
            )
            .send(BroadcastOptions.makeBasic().apply { isInteractive = true }.toBundle())
+107 −0
Original line number Diff line number Diff line
/*
 * 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.systemui.recordissue

import android.app.NotificationManager
import android.content.Context
import android.content.Intent
import android.content.res.Resources
import android.os.Handler
import com.android.internal.logging.UiEventLogger
import com.android.systemui.dagger.qualifiers.LongRunning
import com.android.systemui.dagger.qualifiers.Main
import com.android.systemui.res.R
import com.android.systemui.screenrecord.RecordingController
import com.android.systemui.screenrecord.RecordingService
import com.android.systemui.screenrecord.RecordingServiceStrings
import com.android.systemui.settings.UserContextProvider
import com.android.systemui.statusbar.phone.KeyguardDismissUtil
import java.util.concurrent.Executor
import javax.inject.Inject

class IssueRecordingService
@Inject
constructor(
    controller: RecordingController,
    @LongRunning executor: Executor,
    @Main handler: Handler,
    uiEventLogger: UiEventLogger,
    notificationManager: NotificationManager,
    userContextProvider: UserContextProvider,
    keyguardDismissUtil: KeyguardDismissUtil
) :
    RecordingService(
        controller,
        executor,
        handler,
        uiEventLogger,
        notificationManager,
        userContextProvider,
        keyguardDismissUtil
    ) {

    override fun getTag(): String = TAG

    override fun getChannelId(): String = CHANNEL_ID

    override fun provideRecordingServiceStrings(): RecordingServiceStrings = IrsStrings(resources)

    companion object {
        private const val TAG = "IssueRecordingService"
        private const val CHANNEL_ID = "issue_record"

        /**
         * Get an intent to stop the issue recording service.
         *
         * @param context Context from the requesting activity
         * @return
         */
        fun getStopIntent(context: Context): Intent =
            Intent(context, RecordingService::class.java)
                .setAction(ACTION_STOP)
                .putExtra(Intent.EXTRA_USER_HANDLE, context.userId)

        /**
         * Get an intent to start the issue recording service.
         *
         * @param context Context from the requesting activity
         */
        fun getStartIntent(context: Context): Intent =
            Intent(context, RecordingService::class.java).setAction(ACTION_START)
    }
}

private class IrsStrings(private val res: Resources) : RecordingServiceStrings(res) {
    override val title
        get() = res.getString(R.string.issuerecord_title)
    override val notificationChannelDescription
        get() = res.getString(R.string.issuerecord_channel_description)
    override val startErrorResId
        get() = R.string.issuerecord_start_error
    override val startError
        get() = res.getString(R.string.issuerecord_start_error)
    override val saveErrorResId
        get() = R.string.issuerecord_save_error
    override val saveError
        get() = res.getString(R.string.issuerecord_save_error)
    override val ongoingRecording
        get() = res.getString(R.string.issuerecord_ongoing_screen_only)
    override val backgroundProcessingLabel
        get() = res.getString(R.string.issuerecord_background_processing_label)
    override val saveTitle
        get() = res.getString(R.string.issuerecord_save_title)
}
Loading