Merge changes from topic "caitlinshk-cs-transient" into main
* changes:
[CS] 2/ Remove ongoing call flags; make controller a CoreStartable.
[CS] 1/ Define transientShown in status bar repo not CentralSurfaces.
diff --git a/packages/SystemUI/src/com/android/systemui/dagger/SystemUIModule.java b/packages/SystemUI/src/com/android/systemui/dagger/SystemUIModule.java
index 3a942bd..1e002b8 100644
--- a/packages/SystemUI/src/com/android/systemui/dagger/SystemUIModule.java
+++ b/packages/SystemUI/src/com/android/systemui/dagger/SystemUIModule.java
@@ -89,6 +89,7 @@
import com.android.systemui.statusbar.NotificationLockscreenUserManager;
import com.android.systemui.statusbar.NotificationShadeWindowController;
import com.android.systemui.statusbar.connectivity.ConnectivityModule;
+import com.android.systemui.statusbar.dagger.StatusBarModule;
import com.android.systemui.statusbar.disableflags.dagger.DisableFlagsModule;
import com.android.systemui.statusbar.events.SystemStatusAnimationScheduler;
import com.android.systemui.statusbar.notification.NotifPipelineFlags;
@@ -198,6 +199,7 @@
SettingsUtilModule.class,
SmartRepliesInflationModule.class,
SmartspaceModule.class,
+ StatusBarModule.class,
StatusBarPipelineModule.class,
StatusBarPolicyModule.class,
StatusBarWindowModule.class,
diff --git a/packages/SystemUI/src/com/android/systemui/flags/Flags.kt b/packages/SystemUI/src/com/android/systemui/flags/Flags.kt
index 4d713a2..d5f9288 100644
--- a/packages/SystemUI/src/com/android/systemui/flags/Flags.kt
+++ b/packages/SystemUI/src/com/android/systemui/flags/Flags.kt
@@ -412,16 +412,6 @@
val NEW_SHADE_CARRIER_GROUP_MOBILE_ICONS =
releasedFlag("new_shade_carrier_group_mobile_icons")
- // 700 - dialer/calls
- // TODO(b/254512734): Tracking Bug
- val ONGOING_CALL_STATUS_BAR_CHIP = releasedFlag("ongoing_call_status_bar_chip")
-
- // TODO(b/254512681): Tracking Bug
- val ONGOING_CALL_IN_IMMERSIVE = releasedFlag("ongoing_call_in_immersive")
-
- // TODO(b/254512753): Tracking Bug
- val ONGOING_CALL_IN_IMMERSIVE_CHIP_TAP = releasedFlag("ongoing_call_in_immersive_chip_tap")
-
// 800 - general visual/theme
@JvmField val MONET = resourceBooleanFlag(R.bool.flag_monet, "monet")
diff --git a/packages/SystemUI/src/com/android/systemui/statusbar/CommandQueue.java b/packages/SystemUI/src/com/android/systemui/statusbar/CommandQueue.java
index 6304c1e..670fb12 100644
--- a/packages/SystemUI/src/com/android/systemui/statusbar/CommandQueue.java
+++ b/packages/SystemUI/src/com/android/systemui/statusbar/CommandQueue.java
@@ -375,15 +375,8 @@
/**
* @see IStatusBar#showTransient(int, int, boolean).
*/
- default void showTransient(int displayId, @InsetsType int types) { }
-
- /**
- * @see IStatusBar#showTransient(int, int, boolean).
- */
default void showTransient(int displayId, @InsetsType int types,
- boolean isGestureOnSystemBar) {
- showTransient(displayId, types);
- }
+ boolean isGestureOnSystemBar) {}
/**
* @see IStatusBar#abortTransient(int, int).
diff --git a/packages/SystemUI/src/com/android/systemui/statusbar/dagger/CentralSurfacesDependenciesModule.java b/packages/SystemUI/src/com/android/systemui/statusbar/dagger/CentralSurfacesDependenciesModule.java
index 3dfe068..d058d04 100644
--- a/packages/SystemUI/src/com/android/systemui/statusbar/dagger/CentralSurfacesDependenciesModule.java
+++ b/packages/SystemUI/src/com/android/systemui/statusbar/dagger/CentralSurfacesDependenciesModule.java
@@ -16,7 +16,6 @@
package com.android.systemui.statusbar.dagger;
-import android.app.IActivityManager;
import android.app.WallpaperManager;
import android.content.Context;
import android.hardware.display.DisplayManager;
@@ -38,7 +37,6 @@
import com.android.systemui.flags.FeatureFlags;
import com.android.systemui.flags.Flags;
import com.android.systemui.media.controls.pipeline.MediaDataManager;
-import com.android.systemui.plugins.ActivityStarter;
import com.android.systemui.plugins.statusbar.StatusBarStateController;
import com.android.systemui.power.domain.interactor.PowerInteractor;
import com.android.systemui.settings.DisplayTracker;
@@ -57,12 +55,10 @@
import com.android.systemui.statusbar.StatusBarStateControllerImpl;
import com.android.systemui.statusbar.SysuiStatusBarStateController;
import com.android.systemui.statusbar.commandline.CommandRegistry;
-import com.android.systemui.statusbar.gesture.SwipeStatusBarAwayGestureHandler;
import com.android.systemui.statusbar.notification.NotifPipelineFlags;
import com.android.systemui.statusbar.notification.RemoteInputControllerLogger;
import com.android.systemui.statusbar.notification.collection.NotifCollection;
import com.android.systemui.statusbar.notification.collection.NotifPipeline;
-import com.android.systemui.statusbar.notification.collection.notifcollection.CommonNotifCollection;
import com.android.systemui.statusbar.notification.collection.render.NotificationVisibilityProvider;
import com.android.systemui.statusbar.phone.CentralSurfacesImpl;
import com.android.systemui.statusbar.phone.KeyguardBypassController;
@@ -73,23 +69,15 @@
import com.android.systemui.statusbar.phone.StatusBarIconList;
import com.android.systemui.statusbar.phone.StatusBarNotificationPresenterModule;
import com.android.systemui.statusbar.phone.StatusBarRemoteInputCallback;
-import com.android.systemui.statusbar.phone.ongoingcall.OngoingCallController;
-import com.android.systemui.statusbar.phone.ongoingcall.OngoingCallFlags;
-import com.android.systemui.statusbar.phone.ongoingcall.OngoingCallLogger;
import com.android.systemui.statusbar.policy.KeyguardStateController;
import com.android.systemui.statusbar.policy.RemoteInputUriController;
-import com.android.systemui.statusbar.window.StatusBarWindowController;
import com.android.systemui.util.concurrency.DelayableExecutor;
-import com.android.systemui.util.time.SystemClock;
import dagger.Binds;
import dagger.Lazy;
import dagger.Module;
import dagger.Provides;
-import java.util.Optional;
-import java.util.concurrent.Executor;
-
/**
* This module provides instances needed to construct {@link CentralSurfacesImpl}. These are moved to
* this separate from {@link CentralSurfacesModule} module so that components that wish to build
@@ -230,51 +218,6 @@
}
/**
- */
- @Provides
- @SysUISingleton
- static OngoingCallController provideOngoingCallController(
- Context context,
- CommonNotifCollection notifCollection,
- SystemClock systemClock,
- ActivityStarter activityStarter,
- @Main Executor mainExecutor,
- IActivityManager iActivityManager,
- OngoingCallLogger logger,
- DumpManager dumpManager,
- StatusBarWindowController statusBarWindowController,
- SwipeStatusBarAwayGestureHandler swipeStatusBarAwayGestureHandler,
- StatusBarStateController statusBarStateController,
- OngoingCallFlags ongoingCallFlags) {
-
- boolean ongoingCallInImmersiveEnabled = ongoingCallFlags.isInImmersiveEnabled();
- Optional<StatusBarWindowController> windowController =
- ongoingCallInImmersiveEnabled
- ? Optional.of(statusBarWindowController)
- : Optional.empty();
- Optional<SwipeStatusBarAwayGestureHandler> gestureHandler =
- ongoingCallInImmersiveEnabled
- ? Optional.of(swipeStatusBarAwayGestureHandler)
- : Optional.empty();
- OngoingCallController ongoingCallController =
- new OngoingCallController(
- context,
- notifCollection,
- ongoingCallFlags,
- systemClock,
- activityStarter,
- mainExecutor,
- iActivityManager,
- logger,
- dumpManager,
- windowController,
- gestureHandler,
- statusBarStateController);
- ongoingCallController.init();
- return ongoingCallController;
- }
-
- /**
* {@link NotificationPanelViewController} implements two interfaces:
* - {@link com.android.systemui.shade.ShadeViewController}, which can be used by any class
* needing access to the shade.
diff --git a/packages/SystemUI/src/com/android/systemui/statusbar/dagger/StatusBarModule.kt b/packages/SystemUI/src/com/android/systemui/statusbar/dagger/StatusBarModule.kt
new file mode 100644
index 0000000..d1464ed
--- /dev/null
+++ b/packages/SystemUI/src/com/android/systemui/statusbar/dagger/StatusBarModule.kt
@@ -0,0 +1,52 @@
+/*
+ * Copyright (C) 2023 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.systemui.statusbar.dagger
+
+import com.android.systemui.CoreStartable
+import com.android.systemui.statusbar.data.repository.StatusBarModeRepository
+import com.android.systemui.statusbar.data.repository.StatusBarModeRepositoryImpl
+import com.android.systemui.statusbar.phone.ongoingcall.OngoingCallController
+import dagger.Binds
+import dagger.Module
+import dagger.multibindings.ClassKey
+import dagger.multibindings.IntoMap
+
+/**
+ * A module for **only** classes related to the status bar **UI element**. This module specifically
+ * should **not** include:
+ * - Classes in the `statusbar` package that are unrelated to the status bar UI.
+ * - Status bar classes that are already provided by other modules
+ * ([com.android.systemui.statusbar.pipeline.dagger.StatusBarPipelineModule],
+ * [com.android.systemui.statusbar.policy.dagger.StatusBarPolicyModule], etc.).
+ */
+@Module
+abstract class StatusBarModule {
+ @Binds
+ abstract fun bindStatusBarModeRepository(
+ impl: StatusBarModeRepositoryImpl
+ ): StatusBarModeRepository
+
+ @Binds
+ @IntoMap
+ @ClassKey(StatusBarModeRepositoryImpl::class)
+ abstract fun bindStatusBarModeRepositoryStart(impl: StatusBarModeRepositoryImpl): CoreStartable
+
+ @Binds
+ @IntoMap
+ @ClassKey(OngoingCallController::class)
+ abstract fun bindOngoingCallController(impl: OngoingCallController): CoreStartable
+}
diff --git a/packages/SystemUI/src/com/android/systemui/statusbar/data/repository/StatusBarModeRepository.kt b/packages/SystemUI/src/com/android/systemui/statusbar/data/repository/StatusBarModeRepository.kt
new file mode 100644
index 0000000..1de7a2f
--- /dev/null
+++ b/packages/SystemUI/src/com/android/systemui/statusbar/data/repository/StatusBarModeRepository.kt
@@ -0,0 +1,113 @@
+/*
+ * Copyright (C) 2023 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.systemui.statusbar.data.repository
+
+import android.view.WindowInsets
+import com.android.systemui.CoreStartable
+import com.android.systemui.dagger.SysUISingleton
+import com.android.systemui.dagger.qualifiers.DisplayId
+import com.android.systemui.statusbar.CommandQueue
+import javax.inject.Inject
+import kotlinx.coroutines.flow.MutableStateFlow
+import kotlinx.coroutines.flow.StateFlow
+import kotlinx.coroutines.flow.asStateFlow
+
+/**
+ * A repository for the current mode of the status bar on the homescreen (translucent, transparent,
+ * opaque, lights out, hidden, etc.).
+ *
+ * Note: These status bar modes are status bar *window* states that are sent to us from
+ * WindowManager, not determined internally.
+ */
+interface StatusBarModeRepository {
+ /**
+ * True if the status bar window is showing transiently and will disappear soon, and false
+ * otherwise. ("Otherwise" in this case means the status bar is persistently hidden OR
+ * persistently shown.)
+ *
+ * This behavior is controlled by WindowManager via
+ * [android.view.WindowInsetsController.BEHAVIOR_SHOW_TRANSIENT_BARS_BY_SWIPE], *not* calculated
+ * internally. SysUI merely obeys the behavior sent to us.
+ */
+ val isTransientShown: StateFlow<Boolean>
+
+ /**
+ * Requests for the status bar to be shown transiently.
+ *
+ * TODO(b/277764509): Don't allow [CentralSurfaces] to set the transient mode; have it
+ * determined internally instead.
+ */
+ fun showTransient()
+
+ /**
+ * Requests for the status bar to be no longer showing transiently.
+ *
+ * TODO(b/277764509): Don't allow [CentralSurfaces] to set the transient mode; have it
+ * determined internally instead.
+ */
+ fun clearTransient()
+}
+
+@SysUISingleton
+class StatusBarModeRepositoryImpl
+@Inject
+constructor(
+ @DisplayId thisDisplayId: Int,
+ private val commandQueue: CommandQueue,
+) : StatusBarModeRepository, CoreStartable {
+
+ private val commandQueueCallback =
+ object : CommandQueue.Callbacks {
+ override fun showTransient(
+ displayId: Int,
+ @WindowInsets.Type.InsetsType types: Int,
+ isGestureOnSystemBar: Boolean,
+ ) {
+ if (isTransientRelevant(displayId, types)) {
+ _isTransientShown.value = true
+ }
+ }
+
+ override fun abortTransient(displayId: Int, @WindowInsets.Type.InsetsType types: Int) {
+ if (isTransientRelevant(displayId, types)) {
+ _isTransientShown.value = false
+ }
+ }
+
+ private fun isTransientRelevant(
+ displayId: Int,
+ @WindowInsets.Type.InsetsType types: Int,
+ ): Boolean {
+ return displayId == thisDisplayId && (types and WindowInsets.Type.statusBars() != 0)
+ }
+ }
+
+ override fun start() {
+ commandQueue.addCallback(commandQueueCallback)
+ }
+
+ private val _isTransientShown = MutableStateFlow(false)
+ override val isTransientShown: StateFlow<Boolean> = _isTransientShown.asStateFlow()
+
+ override fun showTransient() {
+ _isTransientShown.value = true
+ }
+
+ override fun clearTransient() {
+ _isTransientShown.value = false
+ }
+}
diff --git a/packages/SystemUI/src/com/android/systemui/statusbar/phone/CentralSurfaces.java b/packages/SystemUI/src/com/android/systemui/statusbar/phone/CentralSurfaces.java
index 7d57568..6ed2089 100644
--- a/packages/SystemUI/src/com/android/systemui/statusbar/phone/CentralSurfaces.java
+++ b/packages/SystemUI/src/com/android/systemui/statusbar/phone/CentralSurfaces.java
@@ -306,10 +306,6 @@
@VisibleForTesting
void setBarStateForTest(int state);
- void showTransientUnchecked();
-
- void clearTransient();
-
void acquireGestureWakeLock(long time);
boolean setAppearance(int appearance);
diff --git a/packages/SystemUI/src/com/android/systemui/statusbar/phone/CentralSurfacesCommandQueueCallbacks.java b/packages/SystemUI/src/com/android/systemui/statusbar/phone/CentralSurfacesCommandQueueCallbacks.java
index ebcfb8a..c9db153 100644
--- a/packages/SystemUI/src/com/android/systemui/statusbar/phone/CentralSurfacesCommandQueueCallbacks.java
+++ b/packages/SystemUI/src/com/android/systemui/statusbar/phone/CentralSurfacesCommandQueueCallbacks.java
@@ -36,7 +36,6 @@
import android.util.Slog;
import android.view.HapticFeedbackConstants;
import android.view.KeyEvent;
-import android.view.WindowInsets;
import android.view.WindowInsets.Type.InsetsType;
import android.view.WindowInsetsController.Appearance;
import android.view.WindowInsetsController.Behavior;
@@ -192,17 +191,6 @@
}
@Override
- public void abortTransient(int displayId, @InsetsType int types) {
- if (displayId != mDisplayId) {
- return;
- }
- if ((types & WindowInsets.Type.statusBars()) == 0) {
- return;
- }
- mCentralSurfaces.clearTransient();
- }
-
- @Override
public void addQsTile(ComponentName tile) {
mQSHost.addTile(tile);
}
@@ -487,17 +475,6 @@
}
@Override
- public void showTransient(int displayId, @InsetsType int types, boolean isGestureOnSystemBar) {
- if (displayId != mDisplayId) {
- return;
- }
- if ((types & WindowInsets.Type.statusBars()) == 0) {
- return;
- }
- mCentralSurfaces.showTransientUnchecked();
- }
-
- @Override
public void toggleKeyboardShortcutsMenu(int deviceId) {
mCentralSurfaces.resendMessage(new CentralSurfaces.KeyboardShortcutsMessage(deviceId));
}
diff --git a/packages/SystemUI/src/com/android/systemui/statusbar/phone/CentralSurfacesEmptyImpl.kt b/packages/SystemUI/src/com/android/systemui/statusbar/phone/CentralSurfacesEmptyImpl.kt
index 5e505f7..50d8e99 100644
--- a/packages/SystemUI/src/com/android/systemui/statusbar/phone/CentralSurfacesEmptyImpl.kt
+++ b/packages/SystemUI/src/com/android/systemui/statusbar/phone/CentralSurfacesEmptyImpl.kt
@@ -86,8 +86,6 @@
override fun updateNotificationPanelTouchState() {}
override fun getRotation() = 0
override fun setBarStateForTest(state: Int) {}
- override fun showTransientUnchecked() {}
- override fun clearTransient() {}
override fun acquireGestureWakeLock(time: Long) {}
override fun setAppearance(appearance: Int) = false
override fun getBarMode() = 0
diff --git a/packages/SystemUI/src/com/android/systemui/statusbar/phone/CentralSurfacesImpl.java b/packages/SystemUI/src/com/android/systemui/statusbar/phone/CentralSurfacesImpl.java
index 8d35d39..bbca234 100644
--- a/packages/SystemUI/src/com/android/systemui/statusbar/phone/CentralSurfacesImpl.java
+++ b/packages/SystemUI/src/com/android/systemui/statusbar/phone/CentralSurfacesImpl.java
@@ -207,6 +207,7 @@
import com.android.systemui.statusbar.StatusBarState;
import com.android.systemui.statusbar.SysuiStatusBarStateController;
import com.android.systemui.statusbar.core.StatusBarInitializer;
+import com.android.systemui.statusbar.data.repository.StatusBarModeRepository;
import com.android.systemui.statusbar.notification.DynamicPrivacyController;
import com.android.systemui.statusbar.notification.NotificationActivityStarter;
import com.android.systemui.statusbar.notification.NotificationLaunchAnimatorControllerProvider;
@@ -238,6 +239,7 @@
import com.android.systemui.util.WallpaperController;
import com.android.systemui.util.concurrency.DelayableExecutor;
import com.android.systemui.util.concurrency.MessageRouter;
+import com.android.systemui.util.kotlin.JavaAdapter;
import com.android.systemui.volume.VolumeComponent;
import com.android.wm.shell.bubbles.Bubbles;
import com.android.wm.shell.startingsurface.SplashscreenContentDrawer;
@@ -410,6 +412,7 @@
private final NotificationShadeWindowController mNotificationShadeWindowController;
private final StatusBarInitializer mStatusBarInitializer;
private final StatusBarWindowController mStatusBarWindowController;
+ private final StatusBarModeRepository mStatusBarModeRepository;
private final KeyguardUpdateMonitor mKeyguardUpdateMonitor;
@VisibleForTesting
DozeServiceHost mDozeServiceHost;
@@ -496,8 +499,6 @@
/** @see android.view.WindowInsetsController#setSystemBarsAppearance(int, int) */
private @Appearance int mAppearance;
- private boolean mTransientShown;
-
private final DisplayMetrics mDisplayMetrics;
// XXX: gesture research
@@ -558,6 +559,7 @@
private final ScrimController mScrimController;
protected DozeScrimController mDozeScrimController;
private final BackActionInteractor mBackActionInteractor;
+ private final JavaAdapter mJavaAdapter;
private final Executor mUiBgExecutor;
protected boolean mDozing;
@@ -633,6 +635,7 @@
StatusBarInitializer statusBarInitializer,
StatusBarWindowController statusBarWindowController,
StatusBarWindowStateController statusBarWindowStateController,
+ StatusBarModeRepository statusBarModeRepository,
KeyguardUpdateMonitor keyguardUpdateMonitor,
StatusBarSignalPolicy statusBarSignalPolicy,
PulseExpansionHandler pulseExpansionHandler,
@@ -651,6 +654,7 @@
DisplayMetrics displayMetrics,
MetricsLogger metricsLogger,
ShadeLogger shadeLogger,
+ JavaAdapter javaAdapter,
@UiBackground Executor uiBgExecutor,
ShadeSurface shadeSurface,
NotificationMediaManager notificationMediaManager,
@@ -740,6 +744,7 @@
mAutoHideController = autoHideController;
mStatusBarInitializer = statusBarInitializer;
mStatusBarWindowController = statusBarWindowController;
+ mStatusBarModeRepository = statusBarModeRepository;
mKeyguardUpdateMonitor = keyguardUpdateMonitor;
mPulseExpansionHandler = pulseExpansionHandler;
mWakeUpCoordinator = notificationWakeUpCoordinator;
@@ -759,6 +764,7 @@
mDisplayMetrics = displayMetrics;
mMetricsLogger = metricsLogger;
mShadeLogger = shadeLogger;
+ mJavaAdapter = javaAdapter;
mUiBgExecutor = uiBgExecutor;
mShadeSurface = shadeSurface;
mMediaManager = notificationMediaManager;
@@ -934,7 +940,7 @@
setUpPresenter();
if ((result.mTransientBarTypes & WindowInsets.Type.statusBars()) != 0) {
- showTransientUnchecked();
+ mStatusBarModeRepository.showTransient();
}
mCommandQueueCallbacks.onSystemBarAttributesChanged(mDisplayId, result.mAppearance,
result.mAppearanceRegions, result.mNavbarColorManagedByIme, result.mBehavior,
@@ -1184,6 +1190,8 @@
mWallpaperController.setRootView(getNotificationShadeWindowView());
mDemoModeController.addCallback(mDemoModeCallback);
+ mJavaAdapter.alwaysCollectFlow(
+ mStatusBarModeRepository.isTransientShown(), this::onTransientShownChanged);
mCommandQueueCallbacks = mCommandQueueCallbacksLazy.get();
mCommandQueue.addCallback(mCommandQueueCallbacks);
@@ -1249,7 +1257,7 @@
@Override
public void hide() {
- clearTransient();
+ mStatusBarModeRepository.clearTransient();
}
});
@@ -1716,25 +1724,15 @@
return mCommandQueue.panelsEnabled();
}
- @Override
- public void showTransientUnchecked() {
- if (!mTransientShown) {
- mTransientShown = true;
+ private void onTransientShownChanged(boolean transientShown) {
+ if (transientShown) {
mNoAnimationOnNextBarModeChange = true;
- maybeUpdateBarMode();
}
- }
-
- @Override
- public void clearTransient() {
- if (mTransientShown) {
- mTransientShown = false;
- maybeUpdateBarMode();
- }
+ maybeUpdateBarMode();
}
private void maybeUpdateBarMode() {
- final int barMode = barMode(mTransientShown, mAppearance);
+ final int barMode = barMode(isTransientShown(), mAppearance);
if (updateBarMode(barMode)) {
mLightBarController.onStatusBarModeChanged(barMode);
updateBubblesVisibility();
@@ -3149,7 +3147,7 @@
// End Extra BaseStatusBarMethods.
boolean isTransientShown() {
- return mTransientShown;
+ return mStatusBarModeRepository.isTransientShown().getValue();
}
private void updateLightRevealScrimVisibility() {
diff --git a/packages/SystemUI/src/com/android/systemui/statusbar/phone/ongoingcall/OngoingCallController.kt b/packages/SystemUI/src/com/android/systemui/statusbar/phone/ongoingcall/OngoingCallController.kt
index b3af91d..52e444f 100644
--- a/packages/SystemUI/src/com/android/systemui/statusbar/phone/ongoingcall/OngoingCallController.kt
+++ b/packages/SystemUI/src/com/android/systemui/statusbar/phone/ongoingcall/OngoingCallController.kt
@@ -27,6 +27,7 @@
import android.view.View
import androidx.annotation.VisibleForTesting
import com.android.internal.jank.InteractionJankMonitor
+import com.android.systemui.CoreStartable
import com.android.systemui.Dumpable
import com.android.systemui.R
import com.android.systemui.animation.ActivityLaunchAnimator
@@ -43,7 +44,6 @@
import com.android.systemui.statusbar.window.StatusBarWindowController
import com.android.systemui.util.time.SystemClock
import java.io.PrintWriter
-import java.util.Optional
import java.util.concurrent.Executor
import javax.inject.Inject
@@ -54,17 +54,16 @@
class OngoingCallController @Inject constructor(
private val context: Context,
private val notifCollection: CommonNotifCollection,
- private val ongoingCallFlags: OngoingCallFlags,
private val systemClock: SystemClock,
private val activityStarter: ActivityStarter,
@Main private val mainExecutor: Executor,
private val iActivityManager: IActivityManager,
private val logger: OngoingCallLogger,
private val dumpManager: DumpManager,
- private val statusBarWindowController: Optional<StatusBarWindowController>,
- private val swipeStatusBarAwayGestureHandler: Optional<SwipeStatusBarAwayGestureHandler>,
+ private val statusBarWindowController: StatusBarWindowController,
+ private val swipeStatusBarAwayGestureHandler: SwipeStatusBarAwayGestureHandler,
private val statusBarStateController: StatusBarStateController
-) : CallbackController<OngoingCallListener>, Dumpable {
+) : CallbackController<OngoingCallListener>, Dumpable, CoreStartable {
private var isFullscreen: Boolean = false
/** Non-null if there's an active call notification. */
private var callNotificationInfo: CallNotificationInfo? = null
@@ -120,12 +119,10 @@
}
}
- fun init() {
+ override fun start() {
dumpManager.registerDumpable(this)
- if (ongoingCallFlags.isStatusBarChipEnabled()) {
- notifCollection.addCollectionListener(notifListener)
- statusBarStateController.addCallback(statusBarStateListener)
- }
+ notifCollection.addCollectionListener(notifListener)
+ statusBarStateController.addCallback(statusBarStateListener)
}
/**
@@ -138,7 +135,7 @@
this.chipView = chipView
val backgroundView: OngoingCallBackgroundContainer? =
chipView.findViewById(R.id.ongoing_call_chip_background)
- backgroundView?.maxHeightFetcher = { statusBarWindowController.get().statusBarHeight }
+ backgroundView?.maxHeightFetcher = { statusBarWindowController.statusBarHeight }
if (hasOngoingCall()) {
updateChip()
}
@@ -197,9 +194,7 @@
uidObserver.registerWithUid(currentCallNotificationInfo.uid)
if (!currentCallNotificationInfo.statusBarSwipedAway) {
- statusBarWindowController.ifPresent {
- it.setOngoingProcessRequiresStatusBarVisible(true)
- }
+ statusBarWindowController.setOngoingProcessRequiresStatusBarVisible(true)
}
updateGestureListening()
mListeners.forEach { l -> l.onOngoingCallStateChanged(animate = true) }
@@ -217,23 +212,19 @@
private fun updateChipClickListener() {
if (callNotificationInfo == null) { return }
- if (isFullscreen && !ongoingCallFlags.isInImmersiveChipTapEnabled()) {
- chipView?.setOnClickListener(null)
- } else {
- val currentChipView = chipView
- val backgroundView =
- currentChipView?.findViewById<View>(R.id.ongoing_call_chip_background)
- val intent = callNotificationInfo?.intent
- if (currentChipView != null && backgroundView != null && intent != null) {
- currentChipView.setOnClickListener {
- logger.logChipClicked()
- activityStarter.postStartActivityDismissingKeyguard(
- intent,
- ActivityLaunchAnimator.Controller.fromView(
- backgroundView,
- InteractionJankMonitor.CUJ_STATUS_BAR_APP_LAUNCH_FROM_CALL_CHIP)
- )
- }
+ val currentChipView = chipView
+ val backgroundView =
+ currentChipView?.findViewById<View>(R.id.ongoing_call_chip_background)
+ val intent = callNotificationInfo?.intent
+ if (currentChipView != null && backgroundView != null && intent != null) {
+ currentChipView.setOnClickListener {
+ logger.logChipClicked()
+ activityStarter.postStartActivityDismissingKeyguard(
+ intent,
+ ActivityLaunchAnimator.Controller.fromView(
+ backgroundView,
+ InteractionJankMonitor.CUJ_STATUS_BAR_APP_LAUNCH_FROM_CALL_CHIP)
+ )
}
}
}
@@ -247,10 +238,10 @@
if (callNotificationInfo == null ||
callNotificationInfo?.statusBarSwipedAway == true ||
!isFullscreen) {
- swipeStatusBarAwayGestureHandler.ifPresent { it.removeOnGestureDetectedCallback(TAG) }
+ swipeStatusBarAwayGestureHandler.removeOnGestureDetectedCallback(TAG)
} else {
- swipeStatusBarAwayGestureHandler.ifPresent {
- it.addOnGestureDetectedCallback(TAG) { _ -> onSwipeAwayGestureDetected() }
+ swipeStatusBarAwayGestureHandler.addOnGestureDetectedCallback(TAG) { _ ->
+ onSwipeAwayGestureDetected()
}
}
}
@@ -258,8 +249,8 @@
private fun removeChip() {
callNotificationInfo = null
tearDownChipView()
- statusBarWindowController.ifPresent { it.setOngoingProcessRequiresStatusBarVisible(false) }
- swipeStatusBarAwayGestureHandler.ifPresent { it.removeOnGestureDetectedCallback(TAG) }
+ statusBarWindowController.setOngoingProcessRequiresStatusBarVisible(false)
+ swipeStatusBarAwayGestureHandler.removeOnGestureDetectedCallback(TAG)
mListeners.forEach { l -> l.onOngoingCallStateChanged(animate = true) }
uidObserver.unregister()
}
@@ -283,12 +274,8 @@
private fun onSwipeAwayGestureDetected() {
if (DEBUG) { Log.d(TAG, "Swipe away gesture detected") }
callNotificationInfo = callNotificationInfo?.copy(statusBarSwipedAway = true)
- statusBarWindowController.ifPresent {
- it.setOngoingProcessRequiresStatusBarVisible(false)
- }
- swipeStatusBarAwayGestureHandler.ifPresent {
- it.removeOnGestureDetectedCallback(TAG)
- }
+ statusBarWindowController.setOngoingProcessRequiresStatusBarVisible(false)
+ swipeStatusBarAwayGestureHandler.removeOnGestureDetectedCallback(TAG)
}
private val statusBarStateListener = object : StatusBarStateController.StateListener {
diff --git a/packages/SystemUI/src/com/android/systemui/statusbar/phone/ongoingcall/OngoingCallFlags.kt b/packages/SystemUI/src/com/android/systemui/statusbar/phone/ongoingcall/OngoingCallFlags.kt
deleted file mode 100644
index fcfcb8f..0000000
--- a/packages/SystemUI/src/com/android/systemui/statusbar/phone/ongoingcall/OngoingCallFlags.kt
+++ /dev/null
@@ -1,35 +0,0 @@
-/*
- * Copyright (C) 2021 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.systemui.statusbar.phone.ongoingcall
-
-import com.android.systemui.dagger.SysUISingleton
-import com.android.systemui.flags.FeatureFlags
-import com.android.systemui.flags.Flags
-import javax.inject.Inject
-
-@SysUISingleton
-class OngoingCallFlags @Inject constructor(private val featureFlags: FeatureFlags) {
-
- fun isStatusBarChipEnabled(): Boolean =
- featureFlags.isEnabled(Flags.ONGOING_CALL_STATUS_BAR_CHIP)
-
- fun isInImmersiveEnabled(): Boolean = isStatusBarChipEnabled()
- && featureFlags.isEnabled(Flags.ONGOING_CALL_IN_IMMERSIVE)
-
- fun isInImmersiveChipTapEnabled(): Boolean = isInImmersiveEnabled()
- && featureFlags.isEnabled(Flags.ONGOING_CALL_IN_IMMERSIVE_CHIP_TAP)
-}
\ No newline at end of file
diff --git a/packages/SystemUI/tests/src/com/android/systemui/statusbar/data/repository/FakeStatusBarModeRepository.kt b/packages/SystemUI/tests/src/com/android/systemui/statusbar/data/repository/FakeStatusBarModeRepository.kt
new file mode 100644
index 0000000..bc62e5c
--- /dev/null
+++ b/packages/SystemUI/tests/src/com/android/systemui/statusbar/data/repository/FakeStatusBarModeRepository.kt
@@ -0,0 +1,30 @@
+/*
+ * Copyright (C) 2023 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.systemui.statusbar.data.repository
+
+import kotlinx.coroutines.flow.MutableStateFlow
+
+class FakeStatusBarModeRepository : StatusBarModeRepository {
+ override val isTransientShown = MutableStateFlow(false)
+
+ override fun showTransient() {
+ isTransientShown.value = true
+ }
+ override fun clearTransient() {
+ isTransientShown.value = false
+ }
+}
diff --git a/packages/SystemUI/tests/src/com/android/systemui/statusbar/data/repository/StatusBarModeRepositoryImplTest.kt b/packages/SystemUI/tests/src/com/android/systemui/statusbar/data/repository/StatusBarModeRepositoryImplTest.kt
new file mode 100644
index 0000000..fa018fd
--- /dev/null
+++ b/packages/SystemUI/tests/src/com/android/systemui/statusbar/data/repository/StatusBarModeRepositoryImplTest.kt
@@ -0,0 +1,183 @@
+/*
+ * Copyright (C) 2023 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.systemui.statusbar.data.repository
+
+import android.view.WindowInsets
+import androidx.test.filters.SmallTest
+import com.android.systemui.SysuiTestCase
+import com.android.systemui.statusbar.CommandQueue
+import com.android.systemui.util.mockito.argumentCaptor
+import com.android.systemui.util.mockito.mock
+import com.google.common.truth.Truth.assertThat
+import org.junit.Test
+import org.mockito.Mockito.verify
+
+@SmallTest
+class StatusBarModeRepositoryImplTest : SysuiTestCase() {
+ private val commandQueue = mock<CommandQueue>()
+
+ private val underTest =
+ StatusBarModeRepositoryImpl(
+ DISPLAY_ID,
+ commandQueue,
+ )
+ .apply { this.start() }
+
+ private val commandQueueCallback: CommandQueue.Callbacks
+ get() {
+ val callbackCaptor = argumentCaptor<CommandQueue.Callbacks>()
+ verify(commandQueue).addCallback(callbackCaptor.capture())
+ return callbackCaptor.value
+ }
+
+ @Test
+ fun isTransientShown_commandQueueShow_wrongDisplayId_notUpdated() {
+ commandQueueCallback.showTransient(
+ DISPLAY_ID + 1,
+ WindowInsets.Type.statusBars(),
+ /* isGestureOnSystemBar= */ false,
+ )
+
+ assertThat(underTest.isTransientShown.value).isFalse()
+ }
+
+ @Test
+ fun isTransientShown_commandQueueShow_notStatusBarType_notUpdated() {
+ commandQueueCallback.showTransient(
+ DISPLAY_ID,
+ WindowInsets.Type.navigationBars(),
+ /* isGestureOnSystemBar= */ false,
+ )
+
+ assertThat(underTest.isTransientShown.value).isFalse()
+ }
+
+ @Test
+ fun isTransientShown_commandQueueShow_true() {
+ commandQueueCallback.showTransient(
+ DISPLAY_ID,
+ WindowInsets.Type.statusBars(),
+ /* isGestureOnSystemBar= */ false,
+ )
+
+ assertThat(underTest.isTransientShown.value).isTrue()
+ }
+
+ @Test
+ fun isTransientShown_commandQueueShow_statusBarAndOtherTypes_true() {
+ commandQueueCallback.showTransient(
+ DISPLAY_ID,
+ WindowInsets.Type.statusBars().or(WindowInsets.Type.navigationBars()),
+ /* isGestureOnSystemBar= */ false,
+ )
+
+ assertThat(underTest.isTransientShown.value).isTrue()
+ }
+
+ @Test
+ fun isTransientShown_commandQueueAbort_wrongDisplayId_notUpdated() {
+ // Start as true
+ commandQueueCallback.showTransient(
+ DISPLAY_ID,
+ WindowInsets.Type.statusBars(),
+ /* isGestureOnSystemBar= */ false,
+ )
+ assertThat(underTest.isTransientShown.value).isTrue()
+
+ // GIVEN the wrong display ID
+ commandQueueCallback.abortTransient(DISPLAY_ID + 1, WindowInsets.Type.statusBars())
+
+ // THEN the old value remains
+ assertThat(underTest.isTransientShown.value).isTrue()
+ }
+
+ @Test
+ fun isTransientShown_commandQueueAbort_notStatusBarType_notUpdated() {
+ // Start as true
+ commandQueueCallback.showTransient(
+ DISPLAY_ID,
+ WindowInsets.Type.statusBars(),
+ /* isGestureOnSystemBar= */ false,
+ )
+ assertThat(underTest.isTransientShown.value).isTrue()
+
+ // GIVEN the wrong type
+ commandQueueCallback.abortTransient(DISPLAY_ID, WindowInsets.Type.navigationBars())
+
+ // THEN the old value remains
+ assertThat(underTest.isTransientShown.value).isTrue()
+ }
+
+ @Test
+ fun isTransientShown_commandQueueAbort_false() {
+ // Start as true
+ commandQueueCallback.showTransient(
+ DISPLAY_ID,
+ WindowInsets.Type.statusBars(),
+ /* isGestureOnSystemBar= */ false,
+ )
+ assertThat(underTest.isTransientShown.value).isTrue()
+
+ commandQueueCallback.abortTransient(DISPLAY_ID, WindowInsets.Type.statusBars())
+
+ assertThat(underTest.isTransientShown.value).isFalse()
+ }
+
+ @Test
+ fun isTransientShown_commandQueueAbort_statusBarAndOtherTypes_false() {
+ // Start as true
+ commandQueueCallback.showTransient(
+ DISPLAY_ID,
+ WindowInsets.Type.statusBars(),
+ /* isGestureOnSystemBar= */ false,
+ )
+ assertThat(underTest.isTransientShown.value).isTrue()
+
+ commandQueueCallback.abortTransient(
+ DISPLAY_ID,
+ WindowInsets.Type.statusBars().or(WindowInsets.Type.captionBar()),
+ )
+
+ assertThat(underTest.isTransientShown.value).isFalse()
+ }
+
+ @Test
+ fun isTransientShown_showTransient_true() {
+ underTest.showTransient()
+
+ assertThat(underTest.isTransientShown.value).isTrue()
+ }
+
+ @Test
+ fun isTransientShown_clearTransient_false() {
+ // Start as true
+ commandQueueCallback.showTransient(
+ DISPLAY_ID,
+ WindowInsets.Type.statusBars(),
+ /* isGestureOnSystemBar= */ false,
+ )
+ assertThat(underTest.isTransientShown.value).isTrue()
+
+ underTest.clearTransient()
+
+ assertThat(underTest.isTransientShown.value).isFalse()
+ }
+
+ private companion object {
+ const val DISPLAY_ID = 5
+ }
+}
diff --git a/packages/SystemUI/tests/src/com/android/systemui/statusbar/phone/CentralSurfacesImplTest.java b/packages/SystemUI/tests/src/com/android/systemui/statusbar/phone/CentralSurfacesImplTest.java
index 6b944ae..26c0fd6 100644
--- a/packages/SystemUI/tests/src/com/android/systemui/statusbar/phone/CentralSurfacesImplTest.java
+++ b/packages/SystemUI/tests/src/com/android/systemui/statusbar/phone/CentralSurfacesImplTest.java
@@ -82,6 +82,7 @@
import com.android.internal.logging.testing.FakeMetricsLogger;
import com.android.internal.statusbar.IStatusBarService;
import com.android.keyguard.KeyguardUpdateMonitor;
+import com.android.keyguard.TestScopeProvider;
import com.android.keyguard.ViewMediatorCallback;
import com.android.systemui.InitController;
import com.android.systemui.R;
@@ -145,6 +146,7 @@
import com.android.systemui.statusbar.StatusBarState;
import com.android.systemui.statusbar.StatusBarStateControllerImpl;
import com.android.systemui.statusbar.core.StatusBarInitializer;
+import com.android.systemui.statusbar.data.repository.FakeStatusBarModeRepository;
import com.android.systemui.statusbar.notification.DynamicPrivacyController;
import com.android.systemui.statusbar.notification.NotifPipelineFlags;
import com.android.systemui.statusbar.notification.NotificationActivityStarter;
@@ -177,6 +179,7 @@
import com.android.systemui.util.WallpaperController;
import com.android.systemui.util.concurrency.FakeExecutor;
import com.android.systemui.util.concurrency.MessageRouterImpl;
+import com.android.systemui.util.kotlin.JavaAdapter;
import com.android.systemui.util.time.FakeSystemClock;
import com.android.systemui.volume.VolumeComponent;
import com.android.wm.shell.bubbles.Bubbles;
@@ -452,6 +455,7 @@
emptySet()),
mStatusBarWindowController,
mStatusBarWindowStateController,
+ new FakeStatusBarModeRepository(),
mKeyguardUpdateMonitor,
mStatusBarSignalPolicy,
mPulseExpansionHandler,
@@ -470,6 +474,7 @@
new DisplayMetrics(),
mMetricsLogger,
mShadeLogger,
+ new JavaAdapter(TestScopeProvider.getTestScope()),
mUiBgExecutor,
mNotificationPanelViewController,
mNotificationMediaManager,
diff --git a/packages/SystemUI/tests/src/com/android/systemui/statusbar/phone/ongoingcall/OngoingCallControllerTest.kt b/packages/SystemUI/tests/src/com/android/systemui/statusbar/phone/ongoingcall/OngoingCallControllerTest.kt
index 711e4ac..6430856 100644
--- a/packages/SystemUI/tests/src/com/android/systemui/statusbar/phone/ongoingcall/OngoingCallControllerTest.kt
+++ b/packages/SystemUI/tests/src/com/android/systemui/statusbar/phone/ongoingcall/OngoingCallControllerTest.kt
@@ -84,7 +84,6 @@
private lateinit var controller: OngoingCallController
private lateinit var notifCollectionListener: NotifCollectionListener
- @Mock private lateinit var mockOngoingCallFlags: OngoingCallFlags
@Mock private lateinit var mockSwipeStatusBarAwayGestureHandler:
SwipeStatusBarAwayGestureHandler
@Mock private lateinit var mockOngoingCallListener: OngoingCallListener
@@ -103,24 +102,22 @@
}
MockitoAnnotations.initMocks(this)
- `when`(mockOngoingCallFlags.isStatusBarChipEnabled()).thenReturn(true)
val notificationCollection = mock(CommonNotifCollection::class.java)
controller = OngoingCallController(
context,
notificationCollection,
- mockOngoingCallFlags,
clock,
mockActivityStarter,
mainExecutor,
mockIActivityManager,
OngoingCallLogger(uiEventLoggerFake),
DumpManager(),
- Optional.of(mockStatusBarWindowController),
- Optional.of(mockSwipeStatusBarAwayGestureHandler),
+ mockStatusBarWindowController,
+ mockSwipeStatusBarAwayGestureHandler,
mockStatusBarStateController,
)
- controller.init()
+ controller.start()
controller.addCallback(mockOngoingCallListener)
controller.setChipView(chipView)
@@ -494,42 +491,7 @@
}
@Test
- fun fullscreenIsTrue_thenCallNotificationAdded_chipNotClickable() {
- `when`(mockOngoingCallFlags.isInImmersiveChipTapEnabled()).thenReturn(false)
-
- getStateListener().onFullscreenStateChanged(/* isFullscreen= */ true)
- notifCollectionListener.onEntryUpdated(createOngoingCallNotifEntry())
-
- assertThat(chipView.hasOnClickListeners()).isFalse()
- }
-
- @Test
- fun callNotificationAdded_thenFullscreenIsTrue_chipNotClickable() {
- `when`(mockOngoingCallFlags.isInImmersiveChipTapEnabled()).thenReturn(false)
-
- notifCollectionListener.onEntryUpdated(createOngoingCallNotifEntry())
- getStateListener().onFullscreenStateChanged(/* isFullscreen= */ true)
-
- assertThat(chipView.hasOnClickListeners()).isFalse()
- }
-
- @Test
- fun fullscreenChangesToFalse_chipClickable() {
- `when`(mockOngoingCallFlags.isInImmersiveChipTapEnabled()).thenReturn(false)
-
- notifCollectionListener.onEntryUpdated(createOngoingCallNotifEntry())
- // First, update to true
- getStateListener().onFullscreenStateChanged(/* isFullscreen= */ true)
- // Then, update to false
- getStateListener().onFullscreenStateChanged(/* isFullscreen= */ false)
-
- assertThat(chipView.hasOnClickListeners()).isTrue()
- }
-
- @Test
- fun fullscreenIsTrue_butChipClickInImmersiveEnabled_chipClickable() {
- `when`(mockOngoingCallFlags.isInImmersiveChipTapEnabled()).thenReturn(true)
-
+ fun fullscreenIsTrue_chipStillClickable() {
notifCollectionListener.onEntryUpdated(createOngoingCallNotifEntry())
getStateListener().onFullscreenStateChanged(/* isFullscreen= */ true)