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

Commit 3d5f5686 authored by Liran Binyamin's avatar Liran Binyamin
Browse files

Pass bubble flyout from wm shell to launcher

Flag: com.android.wm.shell.enable_bubble_bar
Bug: 277815200
Test: atest BubbleInfoTest
Change-Id: I4d9165d511015739b1a621eea56a73927255e40d
parent 42d958cd
Loading
Loading
Loading
Loading
+22 −10
Original line number Original line Diff line number Diff line
@@ -30,29 +30,32 @@ import java.util.Objects;
 */
 */
public class BubbleInfo implements Parcelable {
public class BubbleInfo implements Parcelable {


    private String mKey; // Same key as the Notification
    private final String mKey; // Same key as the Notification
    private int mFlags;  // Flags from BubbleMetadata
    private int mFlags;  // Flags from BubbleMetadata
    @Nullable
    @Nullable
    private String mShortcutId;
    private final String mShortcutId;
    private int mUserId;
    private final int mUserId;
    private String mPackageName;
    private final String mPackageName;
    /**
    /**
     * All notification bubbles require a shortcut to be set on the notification, however, the
     * All notification bubbles require a shortcut to be set on the notification, however, the
     * app could still specify an Icon and PendingIntent to use for the bubble. In that case
     * app could still specify an Icon and PendingIntent to use for the bubble. In that case
     * this icon will be populated. If the bubble is entirely shortcut based, this will be null.
     * this icon will be populated. If the bubble is entirely shortcut based, this will be null.
     */
     */
    @Nullable
    @Nullable
    private Icon mIcon;
    private final Icon mIcon;
    @Nullable
    @Nullable
    private String mTitle;
    private final String mTitle;
    @Nullable
    @Nullable
    private String mAppName;
    private final String mAppName;
    private boolean mIsImportantConversation;
    private final boolean mIsImportantConversation;
    private boolean mShowAppBadge;
    private final boolean mShowAppBadge;
    @Nullable
    private final ParcelableFlyoutMessage mParcelableFlyoutMessage;


    public BubbleInfo(String key, int flags, @Nullable String shortcutId, @Nullable Icon icon,
    public BubbleInfo(String key, int flags, @Nullable String shortcutId, @Nullable Icon icon,
            int userId, String packageName, @Nullable String title, @Nullable String appName,
            int userId, String packageName, @Nullable String title, @Nullable String appName,
            boolean isImportantConversation, boolean showAppBadge) {
            boolean isImportantConversation, boolean showAppBadge,
            @Nullable ParcelableFlyoutMessage flyoutMessage) {
        mKey = key;
        mKey = key;
        mFlags = flags;
        mFlags = flags;
        mShortcutId = shortcutId;
        mShortcutId = shortcutId;
@@ -63,6 +66,7 @@ public class BubbleInfo implements Parcelable {
        mAppName = appName;
        mAppName = appName;
        mIsImportantConversation = isImportantConversation;
        mIsImportantConversation = isImportantConversation;
        mShowAppBadge = showAppBadge;
        mShowAppBadge = showAppBadge;
        mParcelableFlyoutMessage = flyoutMessage;
    }
    }


    private BubbleInfo(Parcel source) {
    private BubbleInfo(Parcel source) {
@@ -76,6 +80,8 @@ public class BubbleInfo implements Parcelable {
        mAppName = source.readString();
        mAppName = source.readString();
        mIsImportantConversation = source.readBoolean();
        mIsImportantConversation = source.readBoolean();
        mShowAppBadge = source.readBoolean();
        mShowAppBadge = source.readBoolean();
        mParcelableFlyoutMessage = source.readParcelable(
                ParcelableFlyoutMessage.class.getClassLoader(), ParcelableFlyoutMessage.class);
    }
    }


    public String getKey() {
    public String getKey() {
@@ -122,6 +128,11 @@ public class BubbleInfo implements Parcelable {
        return mShowAppBadge;
        return mShowAppBadge;
    }
    }


    @Nullable
    public ParcelableFlyoutMessage getParcelableFlyoutMessage() {
        return mParcelableFlyoutMessage;
    }

    /**
    /**
     * Whether this bubble is currently being hidden from the stack.
     * Whether this bubble is currently being hidden from the stack.
     */
     */
@@ -180,6 +191,7 @@ public class BubbleInfo implements Parcelable {
        parcel.writeString(mAppName);
        parcel.writeString(mAppName);
        parcel.writeBoolean(mIsImportantConversation);
        parcel.writeBoolean(mIsImportantConversation);
        parcel.writeBoolean(mShowAppBadge);
        parcel.writeBoolean(mShowAppBadge);
        parcel.writeParcelable(mParcelableFlyoutMessage, flags);
    }
    }


    @NonNull
    @NonNull
+55 −0
Original line number Original line 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.wm.shell.shared.bubbles

import android.graphics.drawable.Icon
import android.os.Parcel
import android.os.Parcelable

/** The contents of the flyout message to be passed to launcher for rendering in the bubble bar. */
class ParcelableFlyoutMessage(
    val icon: Icon?,
    val title: String?,
    val message: String?,
) : Parcelable {

    constructor(
        parcel: Parcel
    ) : this(
        icon = parcel.readParcelable(Icon::class.java.classLoader),
        title = parcel.readString(),
        message = parcel.readString(),
    )

    override fun writeToParcel(parcel: Parcel, flags: Int) {
        parcel.writeParcelable(icon, flags)
        parcel.writeString(title)
        parcel.writeString(message)
    }

    override fun describeContents() = 0

    companion object {
        @JvmField
        val CREATOR =
            object : Parcelable.Creator<ParcelableFlyoutMessage> {
                override fun createFromParcel(parcel: Parcel) = ParcelableFlyoutMessage(parcel)

                override fun newArray(size: Int) = arrayOfNulls<ParcelableFlyoutMessage>(size)
            }
    }
}
+17 −1
Original line number Original line Diff line number Diff line
@@ -56,6 +56,7 @@ import com.android.wm.shell.bubbles.bar.BubbleBarLayerView;
import com.android.wm.shell.shared.annotations.ShellBackgroundThread;
import com.android.wm.shell.shared.annotations.ShellBackgroundThread;
import com.android.wm.shell.shared.annotations.ShellMainThread;
import com.android.wm.shell.shared.annotations.ShellMainThread;
import com.android.wm.shell.shared.bubbles.BubbleInfo;
import com.android.wm.shell.shared.bubbles.BubbleInfo;
import com.android.wm.shell.shared.bubbles.ParcelableFlyoutMessage;


import java.io.PrintWriter;
import java.io.PrintWriter;
import java.util.List;
import java.util.List;
@@ -350,7 +351,22 @@ public class Bubble implements BubbleViewProvider {
                getTitle(),
                getTitle(),
                getAppName(),
                getAppName(),
                isImportantConversation(),
                isImportantConversation(),
                !isAppLaunchIntent());
                !isAppLaunchIntent(),
                getParcelableFlyoutMessage());
    }

    /** Creates a parcelable flyout message to send to launcher. */
    @Nullable
    private ParcelableFlyoutMessage getParcelableFlyoutMessage() {
        if (mFlyoutMessage == null) {
            return null;
        }
        // the icon is only used in group chats
        Icon icon = mFlyoutMessage.isGroupChat ? mFlyoutMessage.senderIcon : null;
        String title =
                mFlyoutMessage.senderName == null ? null : mFlyoutMessage.senderName.toString();
        String message = mFlyoutMessage.message == null ? null : mFlyoutMessage.message.toString();
        return new ParcelableFlyoutMessage(icon, title, message);
    }
    }


    @Override
    @Override
+5 −1
Original line number Original line Diff line number Diff line
@@ -274,7 +274,7 @@ public class BubbleViewInfoTask {
        @Nullable BubbleExpandedView expandedView;
        @Nullable BubbleExpandedView expandedView;
        int dotColor;
        int dotColor;
        Path dotPath;
        Path dotPath;
        @Nullable Bubble.FlyoutMessage flyoutMessage;
        Bubble.FlyoutMessage flyoutMessage;
        Bitmap bubbleBitmap;
        Bitmap bubbleBitmap;
        Bitmap badgeBitmap;
        Bitmap badgeBitmap;


@@ -300,6 +300,10 @@ public class BubbleViewInfoTask {
                return null;
                return null;
            }
            }


            // set the flyout message but don't load the avatar because we can't pass it on the
            // binder to launcher
            info.flyoutMessage = b.getFlyoutMessage();

            return info;
            return info;
        }
        }


+5 −1
Original line number Original line Diff line number Diff line
@@ -181,7 +181,7 @@ public class BubbleViewInfoTaskLegacy extends
        @Nullable BubbleExpandedView expandedView;
        @Nullable BubbleExpandedView expandedView;
        int dotColor;
        int dotColor;
        Path dotPath;
        Path dotPath;
        @Nullable Bubble.FlyoutMessage flyoutMessage;
        Bubble.FlyoutMessage flyoutMessage;
        Bitmap bubbleBitmap;
        Bitmap bubbleBitmap;
        Bitmap badgeBitmap;
        Bitmap badgeBitmap;


@@ -221,6 +221,10 @@ public class BubbleViewInfoTaskLegacy extends
                return null;
                return null;
            }
            }


            // set the flyout message but don't load the avatar because we can't pass it on the
            // binder to launcher
            info.flyoutMessage = b.getFlyoutMessage();

            return info;
            return info;
        }
        }


Loading