diff options
| -rw-r--r-- | packages/SystemUI/src/com/android/systemui/qs/tiles/dialog/InternetDialogDelegate.java | 12 | ||||
| -rw-r--r-- | packages/SystemUI/src/com/android/systemui/qs/tiles/dialog/InternetDialogManager.kt | 43 |
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 } } |