Loading libs/WindowManager/Shell/src/com/android/wm/shell/bubbles/Bubble.java +5 −2 Original line number Diff line number Diff line Loading @@ -124,6 +124,7 @@ public class Bubble implements BubbleViewProvider { private int mDesiredHeight; @DimenRes private int mDesiredHeightResId; private int mTaskId; /** for logging **/ @Nullable Loading Loading @@ -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(); Loading @@ -178,6 +179,7 @@ public class Bubble implements BubbleViewProvider { mTitle = title; mShowBubbleUpdateDot = false; mMainExecutor = mainExecutor; mTaskId = taskId; } @VisibleForTesting(visibility = PRIVATE) Loading @@ -197,6 +199,7 @@ public class Bubble implements BubbleViewProvider { }); }; mMainExecutor = mainExecutor; mTaskId = INVALID_TASK_ID; setEntry(entry); } Loading Loading @@ -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; } /** Loading libs/WindowManager/Shell/src/com/android/wm/shell/bubbles/BubbleDataRepository.kt +8 −4 Original line number Diff line number Diff line Loading @@ -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 Loading @@ -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) Loading Loading @@ -78,7 +80,8 @@ internal class BubbleDataRepository(context: Context, private val launcherApps: b.key, b.rawDesiredHeight, b.rawDesiredHeightResId, b.title b.title, b.taskId ) } } Loading Loading @@ -168,6 +171,7 @@ internal class BubbleDataRepository(context: Context, private val launcherApps: entity.desiredHeight, entity.desiredHeightResId, entity.title, entity.taskId, mainExecutor ) } } Loading libs/WindowManager/Shell/src/com/android/wm/shell/bubbles/storage/BubbleEntity.kt +2 −1 Original line number Diff line number Diff line Loading @@ -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 ) libs/WindowManager/Shell/src/com/android/wm/shell/bubbles/storage/BubbleXmlHelper.kt +5 −1 Original line number Diff line number Diff line Loading @@ -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 Loading @@ -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. Loading Loading @@ -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) Loading Loading @@ -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 ) } Loading libs/WindowManager/Shell/tests/unittest/src/com/android/wm/shell/bubbles/storage/BubblePersistentRepositoryTest.kt +5 −3 Original line number Diff line number Diff line Loading @@ -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 Loading @@ -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 Loading
libs/WindowManager/Shell/src/com/android/wm/shell/bubbles/Bubble.java +5 −2 Original line number Diff line number Diff line Loading @@ -124,6 +124,7 @@ public class Bubble implements BubbleViewProvider { private int mDesiredHeight; @DimenRes private int mDesiredHeightResId; private int mTaskId; /** for logging **/ @Nullable Loading Loading @@ -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(); Loading @@ -178,6 +179,7 @@ public class Bubble implements BubbleViewProvider { mTitle = title; mShowBubbleUpdateDot = false; mMainExecutor = mainExecutor; mTaskId = taskId; } @VisibleForTesting(visibility = PRIVATE) Loading @@ -197,6 +199,7 @@ public class Bubble implements BubbleViewProvider { }); }; mMainExecutor = mainExecutor; mTaskId = INVALID_TASK_ID; setEntry(entry); } Loading Loading @@ -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; } /** Loading
libs/WindowManager/Shell/src/com/android/wm/shell/bubbles/BubbleDataRepository.kt +8 −4 Original line number Diff line number Diff line Loading @@ -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 Loading @@ -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) Loading Loading @@ -78,7 +80,8 @@ internal class BubbleDataRepository(context: Context, private val launcherApps: b.key, b.rawDesiredHeight, b.rawDesiredHeightResId, b.title b.title, b.taskId ) } } Loading Loading @@ -168,6 +171,7 @@ internal class BubbleDataRepository(context: Context, private val launcherApps: entity.desiredHeight, entity.desiredHeightResId, entity.title, entity.taskId, mainExecutor ) } } Loading
libs/WindowManager/Shell/src/com/android/wm/shell/bubbles/storage/BubbleEntity.kt +2 −1 Original line number Diff line number Diff line Loading @@ -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 )
libs/WindowManager/Shell/src/com/android/wm/shell/bubbles/storage/BubbleXmlHelper.kt +5 −1 Original line number Diff line number Diff line Loading @@ -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 Loading @@ -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. Loading Loading @@ -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) Loading Loading @@ -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 ) } Loading
libs/WindowManager/Shell/tests/unittest/src/com/android/wm/shell/bubbles/storage/BubblePersistentRepositoryTest.kt +5 −3 Original line number Diff line number Diff line Loading @@ -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 Loading @@ -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