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

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

Merge "Add taskId to bubble xml" into sc-dev

parents f026ec2d a30ed1e3
Loading
Loading
Loading
Loading
+5 −2
Original line number Diff line number Diff line
@@ -124,6 +124,7 @@ public class Bubble implements BubbleViewProvider {
    private int mDesiredHeight;
    @DimenRes
    private int mDesiredHeightResId;
    private int mTaskId;

    /** for logging **/
    @Nullable
@@ -162,7 +163,7 @@ public class Bubble implements BubbleViewProvider {
     */
    Bubble(@NonNull final String key, @NonNull final ShortcutInfo shortcutInfo,
            final int desiredHeight, final int desiredHeightResId, @Nullable final String title,
            Executor mainExecutor) {
            int taskId, Executor mainExecutor) {
        Objects.requireNonNull(key);
        Objects.requireNonNull(shortcutInfo);
        mMetadataShortcutId = shortcutInfo.getId();
@@ -178,6 +179,7 @@ public class Bubble implements BubbleViewProvider {
        mTitle = title;
        mShowBubbleUpdateDot = false;
        mMainExecutor = mainExecutor;
        mTaskId = taskId;
    }

    @VisibleForTesting(visibility = PRIVATE)
@@ -197,6 +199,7 @@ public class Bubble implements BubbleViewProvider {
            });
        };
        mMainExecutor = mainExecutor;
        mTaskId = INVALID_TASK_ID;
        setEntry(entry);
    }

@@ -520,7 +523,7 @@ public class Bubble implements BubbleViewProvider {
     */
    @Override
    public int getTaskId() {
        return mExpandedView != null ? mExpandedView.getTaskId() : INVALID_TASK_ID;
        return mExpandedView != null ? mExpandedView.getTaskId() : mTaskId;
    }

    /**
+8 −4
Original line number Diff line number Diff line
@@ -28,7 +28,6 @@ import com.android.wm.shell.bubbles.storage.BubbleEntity
import com.android.wm.shell.bubbles.storage.BubblePersistentRepository
import com.android.wm.shell.bubbles.storage.BubbleVolatileRepository
import com.android.wm.shell.common.ShellExecutor
import com.android.wm.shell.common.annotations.ExternalThread
import kotlinx.coroutines.CoroutineScope
import kotlinx.coroutines.Dispatchers
import kotlinx.coroutines.Job
@@ -36,8 +35,11 @@ import kotlinx.coroutines.cancelAndJoin
import kotlinx.coroutines.launch
import kotlinx.coroutines.yield

internal class BubbleDataRepository(context: Context, private val launcherApps: LauncherApps,
        private val mainExecutor : ShellExecutor) {
internal class BubbleDataRepository(
    context: Context,
    private val launcherApps: LauncherApps,
    private val mainExecutor: ShellExecutor
) {
    private val volatileRepository = BubbleVolatileRepository(launcherApps)
    private val persistentRepository = BubblePersistentRepository(context)

@@ -78,7 +80,8 @@ internal class BubbleDataRepository(context: Context, private val launcherApps:
                    b.key,
                    b.rawDesiredHeight,
                    b.rawDesiredHeightResId,
                    b.title
                    b.title,
                    b.taskId
            )
        }
    }
@@ -168,6 +171,7 @@ internal class BubbleDataRepository(context: Context, private val launcherApps:
                            entity.desiredHeight,
                            entity.desiredHeightResId,
                            entity.title,
                            entity.taskId,
                            mainExecutor
                    ) }
        }
+2 −1
Original line number Diff line number Diff line
@@ -25,5 +25,6 @@ data class BubbleEntity(
    val key: String,
    val desiredHeight: Int,
    @DimenRes val desiredHeightResId: Int,
    val title: String? = null
    val title: String? = null,
    val taskId: Int
)
+5 −1
Original line number Diff line number Diff line
@@ -15,6 +15,7 @@
 */
package com.android.wm.shell.bubbles.storage

import android.app.ActivityTaskManager.INVALID_TASK_ID
import android.util.Xml
import com.android.internal.util.FastXmlSerializer
import com.android.internal.util.XmlUtils
@@ -38,6 +39,7 @@ private const val ATTR_KEY = "key"
private const val ATTR_DESIRED_HEIGHT = "h"
private const val ATTR_DESIRED_HEIGHT_RES_ID = "hid"
private const val ATTR_TITLE = "t"
private const val ATTR_TASK_ID = "tid"

/**
 * Writes the bubbles in xml format into given output stream.
@@ -70,6 +72,7 @@ private fun writeXmlEntry(serializer: XmlSerializer, bubble: BubbleEntity) {
        serializer.attribute(null, ATTR_DESIRED_HEIGHT, bubble.desiredHeight.toString())
        serializer.attribute(null, ATTR_DESIRED_HEIGHT_RES_ID, bubble.desiredHeightResId.toString())
        bubble.title?.let { serializer.attribute(null, ATTR_TITLE, it) }
        serializer.attribute(null, ATTR_TASK_ID, bubble.taskId.toString())
        serializer.endTag(null, TAG_BUBBLE)
    } catch (e: IOException) {
        throw RuntimeException(e)
@@ -103,7 +106,8 @@ private fun readXmlEntry(parser: XmlPullParser): BubbleEntity? {
            parser.getAttributeWithName(ATTR_KEY) ?: return null,
            parser.getAttributeWithName(ATTR_DESIRED_HEIGHT)?.toInt() ?: return null,
            parser.getAttributeWithName(ATTR_DESIRED_HEIGHT_RES_ID)?.toInt() ?: return null,
            parser.getAttributeWithName(ATTR_TITLE)
            parser.getAttributeWithName(ATTR_TITLE),
            parser.getAttributeWithName(ATTR_TASK_ID)?.toInt() ?: INVALID_TASK_ID
    )
}

+5 −3
Original line number Diff line number Diff line
@@ -16,6 +16,7 @@

package com.android.wm.shell.bubbles.storage

import android.app.ActivityTaskManager.INVALID_TASK_ID
import android.testing.AndroidTestingRunner
import androidx.test.filters.SmallTest
import com.android.wm.shell.ShellTestCase
@@ -31,9 +32,10 @@ import org.junit.runner.RunWith
class BubblePersistentRepositoryTest : ShellTestCase() {

    private val bubbles = listOf(
            BubbleEntity(0, "com.example.messenger", "shortcut-1", "key-1", 120, 0),
            BubbleEntity(10, "com.example.chat", "alice and bob", "key-2", 0, 16537428, "title"),
            BubbleEntity(0, "com.example.messenger", "shortcut-2", "key-3", 120, 0)
            BubbleEntity(0, "com.example.messenger", "shortcut-1", "key-1", 120, 0, null, 1),
            BubbleEntity(10, "com.example.chat", "alice and bob", "key-2", 0, 16537428, "title", 2),
            BubbleEntity(0, "com.example.messenger", "shortcut-2", "key-3", 120, 0, null,
                    INVALID_TASK_ID)
    )
    private lateinit var repository: BubblePersistentRepository

Loading