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

Commit 9430e71f authored by Will Leshner's avatar Will Leshner
Browse files

Implement assistant attention icon in dream overlay status bar.

Bug: 265235507
Test: atest AssistantAttentionConditionTest
Test: atest DreamOverlayStateControllerTest
Test: atest DreamOverlayStatusBarViewControllerTest
Change-Id: Ic184d89a5ca684539ffed7b0dc8582322dc51d2f
parent c0bcd9af
Loading
Loading
Loading
Loading
+32 −0
Original line number Diff line number Diff line
<!--
  ~ Copyright (C) 2023 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.
  -->

<vector
    xmlns:android="http://schemas.android.com/apk/res/android"
    android:width="56dp"
    android:height="24dp"
    android:viewportWidth="56"
    android:viewportHeight="24">
    <group>
        <clip-path
            android:pathData="M12 0H44C50.6274 0 56 5.37258 56 12C56 18.6274 50.6274 24 44 24H12C5.37258 24 0 18.6274 0 12C0 5.37258 5.37258 0 12 0Z"
            />
        <path
            android:pathData="M0 0V24H56V0"
            android:fillColor="#FFFFFF"
            />
    </group>
</vector>
+10 −0
Original line number Diff line number Diff line
@@ -111,5 +111,15 @@
            android:visibility="gone"
            android:contentDescription="@string/dream_overlay_status_bar_camera_mic_off" />

        <ImageView
            android:id="@+id/dream_overlay_assistant_attention_indicator"
            android:layout_width="@dimen/dream_overlay_grey_chip_width"
            android:layout_height="match_parent"
            android:layout_marginStart="@dimen/dream_overlay_status_icon_margin"
            android:src="@drawable/dream_overlay_assistant_attention_indicator"
            android:visibility="gone"
            android:contentDescription=
                "@string/dream_overlay_status_bar_assistant_attention_indicator" />

    </LinearLayout>
</com.android.systemui.dreams.DreamOverlayStatusBarView>
+2 −0
Original line number Diff line number Diff line
@@ -2798,6 +2798,8 @@
    <string name="dream_overlay_status_bar_mic_off">Mic is off</string>
    <!-- Content description for the camera and mic off icon in the dream overlay status bar [CHAR LIMIT=NONE] -->
    <string name="dream_overlay_status_bar_camera_mic_off">Camera and mic are off</string>
    <!-- Content description for the assistant attention indicator [CHAR LIMIT=NONE] -->
    <string name="dream_overlay_status_bar_assistant_attention_indicator">Assistant is listening</string>
    <!-- Content description for the notifications indicator icon in the dream overlay status bar [CHAR LIMIT=NONE] -->
    <string name="dream_overlay_status_bar_notification_indicator">{count, plural,
    =1 {# notification}
+7 −0
Original line number Diff line number Diff line
@@ -28,6 +28,7 @@ import com.android.systemui.biometrics.AuthController
import com.android.systemui.biometrics.UdfpsOverlay
import com.android.systemui.clipboardoverlay.ClipboardListener
import com.android.systemui.dagger.qualifiers.PerUser
import com.android.systemui.dreams.AssistantAttentionMonitor
import com.android.systemui.dreams.DreamMonitor
import com.android.systemui.globalactions.GlobalActionsComponent
import com.android.systemui.keyboard.KeyboardUI
@@ -309,4 +310,10 @@ abstract class SystemUICoreStartableModule {
    @IntoMap
    @ClassKey(DreamMonitor::class)
    abstract fun bindDreamMonitor(sysui: DreamMonitor): CoreStartable

    /**Inject into AssistantAttentionMonitor */
    @Binds
    @IntoMap
    @ClassKey(AssistantAttentionMonitor::class)
    abstract fun bindAssistantAttentionMonitor(sysui: AssistantAttentionMonitor): CoreStartable
}
+59 −0
Original line number Diff line number Diff line
/*
 * Copyright (C) 2023 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.dreams;

import android.util.Log;

import com.android.systemui.CoreStartable;
import com.android.systemui.dreams.callbacks.AssistantAttentionCallback;
import com.android.systemui.dreams.conditions.AssistantAttentionCondition;
import com.android.systemui.shared.condition.Monitor;

import javax.inject.Inject;

/**
 * A {@link CoreStartable} to retain a monitor for tracking assistant attention.
 */
public class AssistantAttentionMonitor implements CoreStartable {
    private static final String TAG = "AssistAttentionMonitor";

    // We retain a reference to the monitor so it is not garbage-collected.
    private final Monitor mConditionMonitor;
    private final AssistantAttentionCondition mAssistantAttentionCondition;
    private final AssistantAttentionCallback mCallback;

    @Inject
    public AssistantAttentionMonitor(
            Monitor monitor,
            AssistantAttentionCondition assistantAttentionCondition,
            AssistantAttentionCallback callback) {
        mConditionMonitor = monitor;
        mAssistantAttentionCondition = assistantAttentionCondition;
        mCallback = callback;

    }
    @Override
    public void start() {
        if (Log.isLoggable(TAG, Log.DEBUG)) {
            Log.d(TAG, "started");
        }

        mConditionMonitor.addSubscription(new Monitor.Subscription.Builder(mCallback)
                .addCondition(mAssistantAttentionCondition)
                .build());
    }
}
Loading