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

Commit ce70511a authored by Treehugger Robot's avatar Treehugger Robot Committed by Android (Google) Code Review
Browse files

Merge changes I0c19ab9e,Ia6fb78ee,I217aea65 into main

* changes:
  Fix messaging when screen recording stops without recording content.
  [SB][Screen chips] Don't change recording start time once it's started.
  [SB][Screen Chips] Update red color for screen chips to be brighter.
parents 678b110d ece03333
Loading
Loading
Loading
Loading
+2 −2
Original line number Diff line number Diff line
@@ -49,7 +49,7 @@
            android:alpha="0.0"
            />

        <!-- LINT.IfChange textColor -->
        <!-- LINT.IfChange -->
        <TextView
            android:id="@+id/text"
            android:layout_width="0dp"
@@ -78,7 +78,7 @@
            android:layout_height="@dimen/chipbar_end_icon_size"
            android:layout_marginStart="@dimen/chipbar_end_item_start_margin"
            android:src="@drawable/ic_warning"
            android:tint="@color/GM2_red_600"
            android:tint="@color/GM2_red_800"
            android:alpha="0.0"
            />

+1 −1
Original line number Diff line number Diff line
@@ -160,8 +160,8 @@

    <color name="GM2_red_300">#F28B82</color>
    <color name="GM2_red_500">#EA4335</color>
    <color name="GM2_red_600">#B3261E</color>
    <color name="GM2_red_700">#C5221F</color>
    <color name="GM2_red_800">#B3261E</color>

    <color name="GM2_blue_300">#8AB4F8</color>

+20 −7
Original line number Diff line number Diff line
@@ -181,7 +181,7 @@ public class RecordingService extends Service implements ScreenMediaRecorderList
                    mUiEventLogger.log(Events.ScreenRecordEvent.SCREEN_RECORD_START);
                } else {
                    updateState(false);
                    createErrorNotification();
                    createErrorStartingNotification();
                    stopForeground(STOP_FOREGROUND_DETACH);
                    stopSelf();
                    return Service.START_NOT_STICKY;
@@ -272,17 +272,30 @@ public class RecordingService extends Service implements ScreenMediaRecorderList
    }

    /**
     * Simple error notification, needed since startForeground must be called to avoid errors
     * Simple "error starting" notification, needed since startForeground must be called to avoid
     * errors.
     */
    @VisibleForTesting
    protected void createErrorNotification() {
    protected void createErrorStartingNotification() {
        createErrorNotification(strings().getStartError());
    }

    /**
     * Simple "error saving" notification, needed since startForeground must be called to avoid
     * errors.
     */
    @VisibleForTesting
    protected void createErrorSavingNotification() {
        createErrorNotification(strings().getSaveError());
    }

    private void createErrorNotification(String notificationContentTitle) {
        Bundle extras = new Bundle();
        extras.putString(Notification.EXTRA_SUBSTITUTE_APP_NAME, strings().getTitle());
        String notificationTitle = strings().getStartError();

        Notification.Builder builder = new Notification.Builder(this, getChannelId())
                .setSmallIcon(R.drawable.ic_screenrecord)
                .setContentTitle(notificationTitle)
                .setContentTitle(notificationContentTitle)
                .addExtras(extras);
        startForeground(mNotificationId, builder.build());
    }
@@ -427,11 +440,11 @@ public class RecordingService extends Service implements ScreenMediaRecorderList
                // let's release the recorder and delete all temporary files in this case
                getRecorder().release();
            }
            showErrorToast(R.string.screenrecord_start_error);
            showErrorToast(R.string.screenrecord_save_error);
            Log.e(getTag(), "stopRecording called, but there was an error when ending"
                    + "recording");
            exception.printStackTrace();
            createErrorNotification();
            createErrorSavingNotification();
        } catch (Throwable throwable) {
            if (getRecorder() != null) {
                // Something unexpected happen, SystemUI will crash but let's delete
+25 −2
Original line number Diff line number Diff line
@@ -41,6 +41,7 @@ import com.android.systemui.statusbar.chips.ui.model.OngoingActivityChipModel
import com.android.systemui.statusbar.chips.ui.viewmodel.ChipTransitionHelper
import com.android.systemui.statusbar.chips.ui.viewmodel.OngoingActivityChipViewModel
import com.android.systemui.statusbar.chips.ui.viewmodel.OngoingActivityChipViewModel.Companion.createDialogLaunchOnClickListener
import com.android.systemui.util.kotlin.pairwise
import com.android.systemui.util.time.SystemClock
import javax.inject.Inject
import kotlinx.coroutines.CoroutineScope
@@ -64,7 +65,8 @@ constructor(
    @StatusBarChipsLog private val logger: LogBuffer,
) : OngoingActivityChipViewModel {

    private val internalChip =
    /** A direct mapping from [ScreenRecordChipModel] to [OngoingActivityChipModel]. */
    private val simpleChip =
        interactor.screenRecordState
            .map { state ->
                when (state) {
@@ -105,10 +107,31 @@ constructor(
            // See b/347726238 for [SharingStarted.Lazily] reasoning.
            .stateIn(scope, SharingStarted.Lazily, OngoingActivityChipModel.Hidden())

    /**
     * The screen record chip to show that also ensures that the start time doesn't change once we
     * enter the recording state. If we change the start time while we're recording, the chronometer
     * could skip a second. See b/349620526.
     */
    private val chipWithConsistentTimer: StateFlow<OngoingActivityChipModel> =
        simpleChip
            .pairwise(initialValue = OngoingActivityChipModel.Hidden())
            .map { (old, new) ->
                if (
                    old is OngoingActivityChipModel.Shown.Timer &&
                        new is OngoingActivityChipModel.Shown.Timer
                ) {
                    new.copy(startTimeMs = old.startTimeMs)
                } else {
                    new
                }
            }
            // See b/347726238 for [SharingStarted.Lazily] reasoning.
            .stateIn(scope, SharingStarted.Lazily, OngoingActivityChipModel.Hidden())

    private val chipTransitionHelper = ChipTransitionHelper(scope)

    override val chip: StateFlow<OngoingActivityChipModel> =
        chipTransitionHelper.createChipFlow(internalChip)
        chipTransitionHelper.createChipFlow(chipWithConsistentTimer)

    private fun createDelegate(
        recordedTask: ActivityManager.RunningTaskInfo?
+1 −4
Original line number Diff line number Diff line
@@ -18,7 +18,6 @@ package com.android.systemui.statusbar.chips.ui.model

import android.content.Context
import android.content.res.ColorStateList
import android.view.ContextThemeWrapper
import androidx.annotation.ColorInt
import com.android.settingslib.Utils
import com.android.systemui.res.R
@@ -43,9 +42,7 @@ sealed interface ColorsModel {
    /** The chip should have a red background with white text. */
    data object Red : ColorsModel {
        override fun background(context: Context): ColorStateList {
            val themedContext =
                ContextThemeWrapper(context, com.android.internal.R.style.Theme_DeviceDefault_Light)
            return Utils.getColorAttr(themedContext, com.android.internal.R.attr.materialColorError)
            return ColorStateList.valueOf(context.getColor(R.color.GM2_red_700))
        }

        override fun text(context: Context) = context.getColor(android.R.color.white)
Loading