summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
author tomhsu <tomhsu@google.com> 2024-05-17 09:00:30 +0000
committer Tom Hsu <tomhsu@google.com> 2024-05-17 09:12:29 +0000
commita43b57f2320afa3d57613752ec87ea139bd92daf (patch)
tree424c603133da0f018122af900f13f48d6b4d7fc3
parent256196a191ee50491254d1993bb59c1e4c046d48 (diff)
CP partial ag/26460595 for coroutine instance.
Flag: NONE Bug: 329288009 Test: build pass Change-Id: I725adfa29163a5506f51bf54c73664e85a61ae88 Merged-In: I169eaf829684ad62bb566cd554880e137734e2f1
-rw-r--r--packages/SystemUI/src/com/android/systemui/qs/tiles/dialog/InternetDialogDelegate.java12
-rw-r--r--packages/SystemUI/src/com/android/systemui/qs/tiles/dialog/InternetDialogManager.kt43
2 files changed, 38 insertions, 17 deletions
diff --git a/packages/SystemUI/src/com/android/systemui/qs/tiles/dialog/InternetDialogDelegate.java b/packages/SystemUI/src/com/android/systemui/qs/tiles/dialog/InternetDialogDelegate.java
index dd40b7f55d64..f30a838552e3 100644
--- a/packages/SystemUI/src/com/android/systemui/qs/tiles/dialog/InternetDialogDelegate.java
+++ b/packages/SystemUI/src/com/android/systemui/qs/tiles/dialog/InternetDialogDelegate.java
@@ -68,13 +68,15 @@ import com.android.systemui.statusbar.phone.SystemUIDialog;
import com.android.systemui.statusbar.policy.KeyguardStateController;
import com.android.wifitrackerlib.WifiEntry;
-import java.util.List;
-import java.util.concurrent.Executor;
-
import dagger.assisted.Assisted;
import dagger.assisted.AssistedFactory;
import dagger.assisted.AssistedInject;
+import kotlinx.coroutines.CoroutineScope;
+
+import java.util.List;
+import java.util.concurrent.Executor;
+
/**
* Dialog for showing mobile network, connected Wi-Fi network and Wi-Fi networks.
*/
@@ -165,7 +167,8 @@ public class InternetDialogDelegate implements
InternetDialogDelegate create(
@Assisted(ABOVE_STATUS_BAR) boolean aboveStatusBar,
@Assisted(CAN_CONFIG_MOBILE_DATA) boolean canConfigMobileData,
- @Assisted(CAN_CONFIG_WIFI) boolean canConfigWifi);
+ @Assisted(CAN_CONFIG_WIFI) boolean canConfigWifi,
+ @Assisted CoroutineScope coroutineScope);
}
@AssistedInject
@@ -176,6 +179,7 @@ public class InternetDialogDelegate implements
@Assisted(ABOVE_STATUS_BAR) boolean canConfigMobileData,
@Assisted(CAN_CONFIG_MOBILE_DATA) boolean canConfigWifi,
@Assisted(CAN_CONFIG_WIFI) boolean aboveStatusBar,
+ @Assisted CoroutineScope coroutineScope,
UiEventLogger uiEventLogger,
DialogTransitionAnimator dialogTransitionAnimator,
@Main Handler handler,
diff --git a/packages/SystemUI/src/com/android/systemui/qs/tiles/dialog/InternetDialogManager.kt b/packages/SystemUI/src/com/android/systemui/qs/tiles/dialog/InternetDialogManager.kt
index 2a177c791a03..5aef950b6a19 100644
--- a/packages/SystemUI/src/com/android/systemui/qs/tiles/dialog/InternetDialogManager.kt
+++ b/packages/SystemUI/src/com/android/systemui/qs/tiles/dialog/InternetDialogManager.kt
@@ -21,26 +21,35 @@ import com.android.internal.jank.InteractionJankMonitor
import com.android.systemui.animation.DialogCuj
import com.android.systemui.animation.DialogTransitionAnimator
import com.android.systemui.dagger.SysUISingleton
+import com.android.systemui.dagger.qualifiers.Background
import com.android.systemui.statusbar.phone.SystemUIDialog
import javax.inject.Inject
+import kotlinx.coroutines.CoroutineDispatcher
+import kotlinx.coroutines.CoroutineScope
+import kotlinx.coroutines.cancel
private const val TAG = "InternetDialogFactory"
private val DEBUG = Log.isLoggable(TAG, Log.DEBUG)
-/**
- * Factory to create [InternetDialogDelegate] objects.
- */
+/** Factory to create [InternetDialogDelegate] objects. */
@SysUISingleton
-class InternetDialogManager @Inject constructor(
+class InternetDialogManager
+@Inject
+constructor(
private val dialogTransitionAnimator: DialogTransitionAnimator,
- private val dialogFactory: InternetDialogDelegate.Factory
+ private val dialogFactory: InternetDialogDelegate.Factory,
+ @Background private val bgDispatcher: CoroutineDispatcher,
) {
+ private lateinit var coroutineScope: CoroutineScope
companion object {
private const val INTERACTION_JANK_TAG = "internet"
var dialog: SystemUIDialog? = null
}
- /** Creates a [InternetDialogDelegate]. The dialog will be animated from [view] if it is not null. */
+ /**
+ * Creates a [InternetDialogDelegate]. The dialog will be animated from [view] if it is not
+ * null.
+ */
fun create(
aboveStatusBar: Boolean,
canConfigMobileData: Boolean,
@@ -53,16 +62,21 @@ class InternetDialogManager @Inject constructor(
}
return
} else {
- dialog = dialogFactory.create(
- aboveStatusBar, canConfigMobileData, canConfigWifi).createDialog()
+ coroutineScope = CoroutineScope(bgDispatcher)
+ dialog =
+ dialogFactory
+ .create(aboveStatusBar, canConfigMobileData, canConfigWifi, coroutineScope)
+ .createDialog()
if (view != null) {
dialogTransitionAnimator.showFromView(
- dialog!!, view,
+ dialog!!,
+ view,
animateBackgroundBoundsChange = true,
- cuj = DialogCuj(
- InteractionJankMonitor.CUJ_SHADE_DIALOG_OPEN,
- INTERACTION_JANK_TAG
- )
+ cuj =
+ DialogCuj(
+ InteractionJankMonitor.CUJ_SHADE_DIALOG_OPEN,
+ INTERACTION_JANK_TAG
+ )
)
} else {
dialog!!.show()
@@ -74,6 +88,9 @@ class InternetDialogManager @Inject constructor(
if (DEBUG) {
Log.d(TAG, "destroyDialog")
}
+ if (dialog != null) {
+ coroutineScope.cancel()
+ }
dialog = null
}
}